[libvirt] [PATCH] conf: Fix memory leak caused by missing VIR_FREE for video resolution.
by jcfaracco@gmail.com
From: Julio Faracco <jcfaracco(a)gmail.com>
Commit 72862797 introduced resolution settings for QEMU video drivers.
It includes a new structure inside video definition. So, the code needs
to clear pointer allocation for that structure into clear function
virDomainVideoDefClear(). This commit adds this missing VIR_FREE().
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/conf/domain_conf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 88e93f6fb8..696a01043e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2850,6 +2850,7 @@ virDomainVideoDefClear(virDomainVideoDefPtr def)
if (def->accel)
VIR_FREE(def->accel->rendernode);
VIR_FREE(def->accel);
+ VIR_FREE(def->res);
VIR_FREE(def->virtio);
if (def->driver)
VIR_FREE(def->driver->vhost_user_binary);
--
2.20.1
5 years, 1 month
[libvirt] [PATCH v3] glibcompat: Reimplement g_strdup_printf() and g_strdup_vprintf()
by Michal Privoznik
These functions don't really abort() on OOM. The fix was merged
upstream, but not in the minimal version we require. Provide our
own implementation which can be removed once we bump the minimal
version.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Diff to v3:
- fixed infinite recursion
src/internal.h | 1 +
src/libvirt_private.syms | 5 ++++
src/util/Makefile.inc.am | 2 ++
src/util/glibcompat.c | 51 ++++++++++++++++++++++++++++++++++++++++
src/util/glibcompat.h | 31 ++++++++++++++++++++++++
5 files changed, 90 insertions(+)
create mode 100644 src/util/glibcompat.c
create mode 100644 src/util/glibcompat.h
diff --git a/src/internal.h b/src/internal.h
index fb17b87baa..5b0a2335f5 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -64,6 +64,7 @@
#include "libvirt/virterror.h"
#include "c-strcase.h"
+#include "glibcompat.h"
/* Merely casting to (void) is not sufficient since the
* introduction of the "warn_unused_result" attribute
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0da02bb8bd..206295bef0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1485,6 +1485,11 @@ virSecurityManagerTransactionStart;
virSecurityManagerVerify;
+# util/glibcompat.h
+vir_g_strdup_printf;
+vir_g_strdup_vprintf;
+
+
# util/viralloc.h
virAlloc;
virAllocN;
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index 705b93c93c..d8c8e61c4b 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -3,6 +3,8 @@
# These files are not related to driver APIs. Simply generic
# helper APIs for various purposes
UTIL_SOURCES = \
+ util/glibcompat.c \
+ util/glibcompat.h \
util/viralloc.c \
util/viralloc.h \
util/virarch.c \
diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c
new file mode 100644
index 0000000000..5c50153efe
--- /dev/null
+++ b/src/util/glibcompat.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "glibcompat.h"
+
+#undef g_strdup_printf
+#undef g_strdup_vprintf
+
+/* Due to a bug in glib, g_strdup_printf() nor g_strdup_vprintf()
+ * abort on OOM. It's fixed in glib's upstream. Provide our own
+ * implementation until the fix get's distributed. */
+char *
+vir_g_strdup_printf(const char *msg, ...)
+{
+ va_list args;
+ char *ret;
+ va_start(args, msg);
+ ret = g_strdup_vprintf(msg, args);
+ if (!ret)
+ abort();
+ va_end(args);
+ return ret;
+}
+
+
+char *
+vir_g_strdup_vprintf(const char *msg, va_list args)
+{
+ char *ret;
+ ret = g_strdup_vprintf(msg, args);
+ if (!ret)
+ abort();
+ return ret;
+}
diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h
new file mode 100644
index 0000000000..9c5fef09bf
--- /dev/null
+++ b/src/util/glibcompat.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <glib.h>
+
+char *vir_g_strdup_printf(const char *msg, ...)
+ G_GNUC_PRINTF(1, 2);
+char *vir_g_strdup_vprintf(const char *msg, va_list args)
+ G_GNUC_PRINTF(1, 0);
+
+#if !GLIB_CHECK_VERSION(2, 64, 0)
+# define g_strdup_printf vir_g_strdup_printf
+# define g_strdup_vprintf vir_g_strdup_vprintf
+#endif
--
2.21.0
5 years, 1 month
[libvirt] [PATCH v2] glibcompat: Reimplement g_strdup_printf() and g_strdup_vprintf()
by Michal Privoznik
These functions don't really abort() on OOM. The fix was merged
upstream, but not in the minimal version we require. Provide our
own implementation which can be removed once we bump the minimal
version.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
v2 of:
https://www.redhat.com/archives/libvir-list/2019-October/msg01153.html
diff to v1:
- moved the code to src/utils/glibcompat.c
src/internal.h | 1 +
src/libvirt_private.syms | 5 +++++
src/util/Makefile.inc.am | 2 ++
src/util/glibcompat.c | 48 ++++++++++++++++++++++++++++++++++++++++
src/util/glibcompat.h | 31 ++++++++++++++++++++++++++
5 files changed, 87 insertions(+)
create mode 100644 src/util/glibcompat.c
create mode 100644 src/util/glibcompat.h
diff --git a/src/internal.h b/src/internal.h
index fb17b87baa..5b0a2335f5 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -64,6 +64,7 @@
#include "libvirt/virterror.h"
#include "c-strcase.h"
+#include "glibcompat.h"
/* Merely casting to (void) is not sufficient since the
* introduction of the "warn_unused_result" attribute
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0da02bb8bd..206295bef0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1485,6 +1485,11 @@ virSecurityManagerTransactionStart;
virSecurityManagerVerify;
+# util/glibcompat.h
+vir_g_strdup_printf;
+vir_g_strdup_vprintf;
+
+
# util/viralloc.h
virAlloc;
virAllocN;
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index 705b93c93c..d8c8e61c4b 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -3,6 +3,8 @@
# These files are not related to driver APIs. Simply generic
# helper APIs for various purposes
UTIL_SOURCES = \
+ util/glibcompat.c \
+ util/glibcompat.h \
util/viralloc.c \
util/viralloc.h \
util/virarch.c \
diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c
new file mode 100644
index 0000000000..af638f4d8c
--- /dev/null
+++ b/src/util/glibcompat.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "glibcompat.h"
+
+/* Due to a bug in glib, g_strdup_printf() nor g_strdup_vprintf()
+ * abort on OOM. It's fixed in glib's upstream. Provide our own
+ * implementation until the fix get's distributed. */
+char *
+vir_g_strdup_printf(const char *msg, ...)
+{
+ va_list args;
+ char *ret;
+ va_start(args, msg);
+ ret = g_strdup_vprintf(msg, args);
+ if (!ret)
+ abort();
+ va_end(args);
+ return ret;
+}
+
+
+char *
+vir_g_strdup_vprintf(const char *msg, va_list args)
+{
+ char *ret;
+ ret = g_strdup_vprintf(msg, args);
+ if (!ret)
+ abort();
+ return ret;
+}
diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h
new file mode 100644
index 0000000000..9c5fef09bf
--- /dev/null
+++ b/src/util/glibcompat.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <glib.h>
+
+char *vir_g_strdup_printf(const char *msg, ...)
+ G_GNUC_PRINTF(1, 2);
+char *vir_g_strdup_vprintf(const char *msg, va_list args)
+ G_GNUC_PRINTF(1, 0);
+
+#if !GLIB_CHECK_VERSION(2, 64, 0)
+# define g_strdup_printf vir_g_strdup_printf
+# define g_strdup_vprintf vir_g_strdup_vprintf
+#endif
--
2.21.0
5 years, 1 month
[libvirt] Some questions about live migration
by Luyao Zhong
Hi libvirt experts,
I have some questions about live migration.
* If a live migration failed during migrating, will the domain exist on the
destination host?
* Is the flag VIR_MIGRATE_PAUSED make sense to live migration? It's a little
confusing for me. Does that indicate if I set this flag, then the domain on
the destination will not disappear even if the migration is failed, and it will
in 'paused' status? If not setting this flag, what will it be? It may be similar
to the question above.
I filed a bug https://bugzilla.redhat.com/show_bug.cgi?id=1762703 about this flag,
since its description is not very clear.
Thanks in advance, looking forward to your reply.
Regards,
Luyao
--
2.7.4
5 years, 1 month
[libvirt] [PATCH v4 0/2] Add resolution properties for QEMU video devices
by jcfaracco@gmail.com
From: Julio Faracco <jcfaracco(a)gmail.com>
This serie adds resolution ('x' and 'y') properties into XML definition
for QEMU video devices to specify a default resolution. This specific
case is not considering those attributes as a QEMU capabilities due to
complexity of code versus test complexity versus a real gain. This
skeleton would work very well initially. After, it should be possible to
include them as a capabilities without changing this serie.
v1-v2: Adds suggestions of multiple members.
v2-v3: Adds Cole's suggestions.
v3-v4: Adds Cole's suggestions again.
Julio Faracco (2):
conf: Add 'x' and 'y' resolution into video XML definition
qemu: Generate 'xres' and 'yres' for QEMU video devices
docs/formatdomain.html.in | 5 +-
docs/schemas/domaincommon.rng | 10 +++
src/conf/domain_conf.c | 63 ++++++++++++++++++-
src/conf/domain_conf.h | 5 ++
src/conf/virconftypes.h | 3 +
src/qemu/qemu_command.c | 5 ++
src/qemu/qemu_domain.c | 11 ++++
.../video-qxl-resolution.args | 32 ++++++++++
.../qemuxml2argvdata/video-qxl-resolution.xml | 42 +++++++++++++
tests/qemuxml2argvtest.c | 4 ++
.../video-qxl-resolution.xml | 42 +++++++++++++
tests/qemuxml2xmltest.c | 1 +
12 files changed, 221 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/video-qxl-resolution.args
create mode 100644 tests/qemuxml2argvdata/video-qxl-resolution.xml
create mode 100644 tests/qemuxml2xmloutdata/video-qxl-resolution.xml
--
2.20.1
5 years, 1 month
[libvirt] [PATCH] util: set bridge device MAC address explicitly during virNetDevBridgeCreate
by Laine Stump
Remember when the MAC address of libvirt-created bridges weren't
stable, and changed as guests were started and stopped? Pepperidge
Farms remembers.
(No, I would never actually push a comment like that! Just wanted to
get your attention).
When libvirt first implemented a stable and configurable MAC address
for the bridges created for libvirt virtual networks (commit
5754dbd56d, in libvirt v8.8.0) most distro stable releases didn't
support explicitly setting the MAC address of a bridge; the bridge
just always assumed the lowest numbered MAC of all attached
interfaces. Because of this, we stabilized the bridge MAC address by
creating a "dummy" tap interface with a MAC address guaranteed to be
lower than any of the guest tap devices' MACs (which all started with
0xFE, so it's not difficult to do) and attached it to the bridge -
this was the inception of the "virbr0-nic" device that has confused so
many people over the years.
Even though the linux kernel had recently gained support for
explicitly setting a bridge MAC, we deemed it unnecessary to set the
MAC that way, because the other (indirect) method worked everywhere.
But recently there have been reports that the bridge MAC address was
not following the setting in the network config, and mismatched the
MAC of the dummy tap device (which was still correct). It turns out
that this is due to a change in systemd/udev that persists whatever
MAC address is set for a bridge when it's initially started:
https://github.com/systemd/systemd/blob/master/NEWS#L499
which was the result of:
https://github.com/systemd/systemd/issues/3374
(apparently if there is no MAC saved for a bridge by the name of a
bridge being created, the random MAC generated during creation is
saved, and then that same MAC is used to explicitly set the MAC each
time it is created). Once a bridge has an explicitly set MAC, the "use
the lowest numbered MAC of attached devices" rule is ignored, so our
dummy tap device is like the goggles - it does nothing! (well, almost).
We could whine about changes in default behavior, etc. etc., but
because the change was in response to actual user problems, that seems
likely a fruitless task. Fortunately, time has marched on, and even
distro releases that are old enough that they are no longer supported
by upstream libvirt (e.g. RHEL6) have support for explicitly setting a
bridge device MAC address, either during creation or with a separate
ioctl after creation, so we can now do that.
The method is to add a mac arg to virNetDevBridgeCreate(). In the case
of platforms where the bridge is created with a netlink RTM_NEWLINK
message, we just add the desired mac to the message. For platforms
that still use an ioctl (either SIOCBRADDBR or SIOCIFCREATE2), we make
a separate call to virNetDevSetMAC() after creating the bridge.
This makes the dummy tap pointless for purposes of setting the MAC
address, but it is still useful for IPv6 DAD initialization (which
apparently requires at least one interface to be attached to the
bridge and online), so it hasn't been removed. (I'm considered making
another patch to add the dummy tap device only if the network needs
IPv6 DAD, but haven't decided yet if it's worthwhile).
(NB: we can safely *always* call virNetDevBridgeCreate() with
&def->mac from the network driver because, in spite of the existence
of a "mac_specified" bool in the config suggesting that it may not
always be present, in reality a mac address will always be added to
any network that doesn't have one - this is guaranteed in all cases by
commit a47ae7c004)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1760851
---
NB: I was unable to test the calling of virNetDevSetMAC() from the
SIOCIFCREATE2 (BSD) version of virNetDevBridgeCreate(); even though I
managed to get a FreeBSD system setup and libvirt built there, when I
tried to start the default network the SIOCIFCREATE2 ioctl itself
failed, so it never even got to the virNetDevSetMAC(). I would
sincerely appreciate if someone more up to speed with libvirt on
FreeBSD/OpenBSD could check that out and let me know if it works
properly.
src/network/bridge_driver.c | 2 +-
src/util/virnetdevbridge.c | 43 ++++++++++++++++++++++++++++++-------
src/util/virnetdevbridge.h | 2 +-
3 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 6862818698..4f01bf6664 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2498,7 +2498,7 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver,
def->name);
return -1;
}
- if (virNetDevBridgeCreate(def->bridge) < 0)
+ if (virNetDevBridgeCreate(def->bridge, &def->mac) < 0)
return -1;
if (def->mac_specified) {
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index edf4cc6236..d3a1e3c13e 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -379,7 +379,7 @@ virNetDevBridgePortSetUnicastFlood(const char *brname G_GNUC_UNUSED,
*/
#if defined(HAVE_STRUCT_IFREQ) && defined(SIOCBRADDBR)
static int
-virNetDevBridgeCreateWithIoctl(const char *brname)
+virNetDevBridgeCreateWithIoctl(const char *brname, const virMacAddr *mac)
{
VIR_AUTOCLOSE fd = -1;
@@ -392,22 +392,35 @@ virNetDevBridgeCreateWithIoctl(const char *brname)
return -1;
}
+ if (virNetDevSetMAC(brname, mac) < 0) {
+ virErrorPtr savederr;
+
+ virErrorPreserveLast(&savederr);
+ ignore_value(ioctl(fd, SIOCBRDELBR, brname));
+ virErrorRestore(&savederr);
+ return -1;
+ }
+
return 0;
}
#endif
#if defined(__linux__) && defined(HAVE_LIBNL)
int
-virNetDevBridgeCreate(const char *brname)
+virNetDevBridgeCreate(const char *brname, const virMacAddr *mac)
{
/* use a netlink RTM_NEWLINK message to create the bridge */
int error = 0;
+ virNetlinkNewLinkData data = {
+ .mac = mac,
+ };
+
- if (virNetlinkNewLink(brname, "bridge", NULL, &error) < 0) {
+ if (virNetlinkNewLink(brname, "bridge", &data, &error) < 0) {
# if defined(HAVE_STRUCT_IFREQ) && defined(SIOCBRADDBR)
if (error == -EOPNOTSUPP) {
/* fallback to ioctl if netlink doesn't support creating bridges */
- return virNetDevBridgeCreateWithIoctl(brname);
+ return virNetDevBridgeCreateWithIoctl(brname, mac);
}
# endif
if (error < 0)
@@ -423,15 +436,17 @@ virNetDevBridgeCreate(const char *brname)
#elif defined(HAVE_STRUCT_IFREQ) && defined(SIOCBRADDBR)
int
-virNetDevBridgeCreate(const char *brname)
+virNetDevBridgeCreate(const char *brname,
+ const virMacAddr *mac)
{
- return virNetDevBridgeCreateWithIoctl(brname);
+ return virNetDevBridgeCreateWithIoctl(brname, mac);
}
#elif defined(HAVE_STRUCT_IFREQ) && defined(SIOCIFCREATE2)
int
-virNetDevBridgeCreate(const char *brname)
+virNetDevBridgeCreate(const char *brname,
+ const virMacAddr *mac)
{
struct ifreq ifr;
VIR_AUTOCLOSE s = -1;
@@ -448,10 +463,21 @@ virNetDevBridgeCreate(const char *brname)
if (virNetDevSetName(ifr.ifr_name, brname) == -1)
return -1;
+ if (virNetDevSetMAC(brname, mac) < 0) {
+ virErrorPtr savederr;
+
+ virErrorPreserveLast(&savederr);
+ ignore_value(virNetDevBridgeDelete(brname));
+ virErrorRestore(&savederr);
+ return -1;
+ }
+
return 0;
}
#else
-int virNetDevBridgeCreate(const char *brname)
+int
+virNetDevBridgeCreate(const char *brname,
+ const virMacAddr *mac ATTRIBUTE_UNUSED)
{
virReportSystemError(ENOSYS,
_("Unable to create bridge %s"), brname);
@@ -528,6 +554,7 @@ virNetDevBridgeDelete(const char *brname)
_("Unable to remove bridge %s"),
brname);
return -1;
+
}
return 0;
diff --git a/src/util/virnetdevbridge.h b/src/util/virnetdevbridge.h
index 88284d6bed..c47597dec9 100644
--- a/src/util/virnetdevbridge.h
+++ b/src/util/virnetdevbridge.h
@@ -21,7 +21,7 @@
#include "internal.h"
#include "virmacaddr.h"
-int virNetDevBridgeCreate(const char *brname)
+int virNetDevBridgeCreate(const char *brname, const virMacAddr *mac)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
int virNetDevBridgeDelete(const char *brname)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
--
2.23.0
5 years, 1 month
[libvirt] [PATCH v3] util: Block SIGPIPE until execve in child process
by Wang Yechao
Libvirtd has set SIGPIPE to ignored, and virFork resets all signal
handlers to the defaults. But child process may write logs to
stderr/stdout, that may generate SIGPIPE if journald has stopped.
So block SIGPIPE in virFork, and unblock it before execve.
Signed-off-by: Wang Yechao <wang.yechao255(a)zte.com.cn>
---
v1 patch:
https://www.redhat.com/archives/libvir-list/2019-October/msg00720.html
Changes in v2:
- use pthread_sigmask to block SIGPIPE
Changes in v3:
- pass SIG_UNBLOCK(not SIG_SETMASK) to pthread_sigmask when unlock SIGPIPE
---
src/util/vircommand.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 79e1e87..bd3a582 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -321,6 +321,15 @@ virFork(void)
virDispatchError(NULL);
_exit(EXIT_CANCELED);
}
+
+ sigemptyset(&newmask);
+ sigaddset(&newmask, SIGPIPE);
+ if (pthread_sigmask(SIG_BLOCK, &newmask, NULL) != 0) {
+ virReportSystemError(errno, "%s", _("cannot block SIGPIPE"));
+ virDispatchError(NULL);
+ _exit(EXIT_CANCELED);
+ }
+
}
return pid;
}
@@ -553,6 +562,7 @@ virExec(virCommandPtr cmd)
struct sigaction waxon, waxoff;
VIR_AUTOFREE(gid_t *) groups = NULL;
int ngroups;
+ sigset_t set;
if (cmd->args[0][0] != '/') {
if (!(binary = binarystr = virFindFileInPath(cmd->args[0]))) {
@@ -792,6 +802,13 @@ virExec(virCommandPtr cmd)
/* Close logging again to ensure no FDs leak to child */
virLogReset();
+ sigemptyset(&set);
+ sigaddset(&set, SIGPIPE);
+ if (pthread_sigmask(SIG_UNBLOCK, &set, NULL) != 0) {
+ virReportSystemError(errno, "%s", _("cannot unblock SIGPIPE"));
+ goto fork_error;
+ }
+
if (cmd->env)
execve(binary, cmd->args, cmd->env);
else
--
1.8.3.1
5 years, 1 month
[libvirt] [PULL v2 00/19] Bitmaps patches
by John Snow
The following changes since commit c760cb77e511eb05094df67c1b30029a952efa35:
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20191011a' into staging (2019-10-14 16:09:52 +0100)
are available in the Git repository at:
https://github.com/jnsnow/qemu.git tags/bitmaps-pull-request
for you to fetch changes up to b2ca29ee390743c42a6062d44ee3b10fb51f9fa6:
dirty-bitmaps: remove deprecated autoload parameter (2019-10-14 15:28:17 -0400)
----------------------------------------------------------------
Pull request
----------------------------------------------------------------
John Snow (2):
MAINTAINERS: Add Vladimir as a reviewer for bitmaps
dirty-bitmaps: remove deprecated autoload parameter
Vladimir Sementsov-Ogievskiy (17):
util/hbitmap: strict hbitmap_reset
block: move bdrv_can_store_new_dirty_bitmap to block/dirty-bitmap.c
block/dirty-bitmap: return int from
bdrv_remove_persistent_dirty_bitmap
block/qcow2: proper locking on bitmap add/remove paths
block/dirty-bitmap: drop meta
block/dirty-bitmap: add bs link
block/dirty-bitmap: drop BdrvDirtyBitmap.mutex
block/dirty-bitmap: refactor bdrv_dirty_bitmap_next
block: switch reopen queue from QSIMPLEQ to QTAILQ
block: reverse order for reopen commits
iotests: add test-case to 165 to test reopening qcow2 bitmaps to RW
block/qcow2-bitmap: get rid of bdrv_has_changed_persistent_bitmaps
block/qcow2-bitmap: drop qcow2_reopen_bitmaps_rw_hint()
block/qcow2-bitmap: do not remove bitmaps on reopen-ro
iotests: add test 260 to check bitmap life after snapshot + commit
block/qcow2-bitmap: fix and improve qcow2_reopen_bitmaps_rw
qcow2-bitmap: move bitmap reopen-rw code to qcow2_reopen_commit
qemu-deprecated.texi | 20 ++-
qapi/block-core.json | 6 +-
block/qcow2.h | 19 +--
include/block/block.h | 2 +-
include/block/block_int.h | 20 +--
include/block/dirty-bitmap.h | 34 ++--
include/qemu/hbitmap.h | 5 +
block.c | 79 +++------
block/backup.c | 8 +-
block/block-copy.c | 2 +-
block/dirty-bitmap.c | 290 +++++++++++++++++++--------------
block/mirror.c | 4 +-
block/qcow2-bitmap.c | 212 +++++++++++++++---------
block/qcow2.c | 22 ++-
blockdev.c | 40 ++---
migration/block-dirty-bitmap.c | 11 +-
migration/block.c | 4 +-
tests/test-hbitmap.c | 2 +-
util/hbitmap.c | 4 +
MAINTAINERS | 3 +-
tests/qemu-iotests/165 | 57 ++++++-
tests/qemu-iotests/165.out | 4 +-
tests/qemu-iotests/260 | 89 ++++++++++
tests/qemu-iotests/260.out | 52 ++++++
tests/qemu-iotests/group | 1 +
25 files changed, 623 insertions(+), 367 deletions(-)
create mode 100755 tests/qemu-iotests/260
create mode 100644 tests/qemu-iotests/260.out
--
2.21.0
5 years, 1 month
[libvirt] [PATCH] qemu: caps: Use unique key for domCaps caching
by Cole Robinson
When searching qemuCaps->domCapsCache for existing domCaps data,
we check for a matching pair of arch+virttype+machine+emulator. However
for the hash table key we only use the machine string. So if the
cache already contains:
x86_64 + kvm + pc + /usr/bin/qemu-kvm
But a new VM is defined with
x86_64 + qemu + pc + /usr/bin/qemu-kvm
We correctly fail to find matching cached domCaps, but then attempt
to use a colliding key with virHashAddEntry
Fix this by building a hash key from the 4 values, not just machine
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
qemu_domain.c validation should be affected, but it is covered up
by another bug, fixed here:
https://www.redhat.com/archives/libvir-list/2019-October/msg00708.html
src/qemu/qemu_conf.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 08cd784054..64ac8cbdd3 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1396,6 +1396,8 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver,
domCaps = virHashSearch(domCapsCache,
virQEMUDriverSearchDomcaps, &data, NULL);
if (!domCaps) {
+ VIR_AUTOFREE(char *) key = NULL;
+
/* hash miss, build new domcaps */
if (!(domCaps = virDomainCapsNew(data.path, data.machine,
data.arch, data.virttype)))
@@ -1406,7 +1408,14 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver,
cfg->firmwares, cfg->nfirmwares) < 0)
return NULL;
- if (virHashAddEntry(domCapsCache, machine, domCaps) < 0)
+ if (virAsprintf(&key, "%d:%d:%s:%s",
+ data.arch,
+ data.virttype,
+ NULLSTR(data.machine),
+ NULLSTR(data.path)) < 0)
+ return NULL;
+
+ if (virHashAddEntry(domCapsCache, key, domCaps) < 0)
return NULL;
}
--
2.23.0
5 years, 1 month