[libvirt] [PATCH] nwfilter: fix deadlock when nwfilter reload
by Wang Yechao
user run "firewalld-cmd --reload"
nwfilterStateReload called in main thread
step 1. virRWLockWrite(&updateLock)
step 2. virNWFilterLoadAllConfigs
step 3. virRWLockUnlock(&updateLock);
lauch a vm: qemuDomainCreateXML runs in other thread
step 1. virRWLockRead(&updateLock);
step 2. qemuProcessStart
step 3. qemuProcessWaitForMonitor
step 4. ...
step 5 virRWLockUnlock(&updateLock);
if nwfilterStateReload called in the middle of step 1 and step 5 of
qemuDomainCreateXML, it can't get the updateLock and then block the event_loop,
so event_loop can't handle the qemu-monitor messages, cause deadlock
move nwfilterStateReload into thread to fix this problem.
Signed-off-by: Wang Yechao <wang.yechao255(a)zte.com.cn>
Reviewed-by: Wang Yi <wang.yi59(a)zte.com.cn>
---
src/nwfilter/nwfilter_driver.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 1ee5162..8dcc40b 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -80,18 +80,27 @@ static void nwfilterDriverUnlock(void)
}
#if HAVE_FIREWALLD
+static void nwfilterReloadThread(void *opaque ATTRIBUTE_UNUSED)
+{
+ nwfilterStateReload();
+}
static DBusHandlerResult
nwfilterFirewalldDBusFilter(DBusConnection *connection ATTRIBUTE_UNUSED,
DBusMessage *message,
void *user_data ATTRIBUTE_UNUSED)
{
+ virThread thread;
+
if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
"NameOwnerChanged") ||
dbus_message_is_signal(message, "org.fedoraproject.FirewallD1",
"Reloaded")) {
VIR_DEBUG("Reload in nwfilter_driver because of firewalld.");
- nwfilterStateReload();
+
+ if (virThreadCreate(&thread, false, nwfilterReloadThread, NULL) < 0) {
+ VIR_ERROR("create nwfilterThread failed.");
+ }
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
--
1.8.3.1
6 years, 3 months
[libvirt] [PATCH] rpm: increase min required Fedora to 27
by Fabiano Fidêncio
Fedora 26 has reached its EOL on May 29th 2018.
https://lists.fedoraproject.org/archives/list/announce@lists.fedoraprojec...
Signed-off-by: Fabiano Fidêncio <fidencio(a)redhat.com>
---
libvirt.spec.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index cc2e662e27..b31947b0f4 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -4,7 +4,7 @@
# that's still supported by the vendor. It may work on other distros
# or versions, but no effort will be made to ensure that going forward.
%define min_rhel 7
-%define min_fedora 26
+%define min_fedora 27
%if (0%{?fedora} && 0%{?fedora} >= %{min_fedora}) || (0%{?rhel} && 0%{?rhel} >= %{min_rhel})
%define supported_platform 1
--
2.17.1
6 years, 3 months
[libvirt] [PATCH] nwfilter:fix deadlock when nwfilter reload
by Wang Yechao
user run "firewalld-cmd --reload"
nwfilterStateReload called in main thread
step 1. virRWLockWrite(&updateLock)
step 2. virNWFilterLoadAllConfigs
step 3. virRWLockUnlock(&updateLock);
lauch a vm: qemuDomainCreateXML runs in other thread
step 1. virRWLockRead(&updateLock);
step 2. qemuProcessStart
step 3. qemuProcessWaitForMonitor
step 4. ...
step 5 virRWLockUnlock(&updateLock);
if nwfilterStateReload called in the middle of step 1 and step 5 of
qemuDomainCreateXML, it can't get the updateLock and then block the event_loop,
so event_loop can't handle the qemu-monitor messages, cause deadlock
move nwfilterStateReload into thread to fix this problem.
Signed-off-by: Wang Yechao <wang.yechao255(a)zte.com.cn>
Reviewed-by: Yi Wang <wang.yi59(a)zte.com.cn>
---
src/nwfilter/nwfilter_driver.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
mode change 100644 => 100755 src/nwfilter/nwfilter_driver.c
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
old mode 100644
new mode 100755
index ac3a964..2c099e2
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -81,17 +81,28 @@ static void nwfilterDriverUnlock(void)
#if HAVE_FIREWALLD
+static void nwfilterThread(void *opaque ATTRIBUTE_UNUSED)
+{
+ nwfilterStateReload();
+}
+
static DBusHandlerResult
nwfilterFirewalldDBusFilter(DBusConnection *connection ATTRIBUTE_UNUSED,
DBusMessage *message,
void *user_data ATTRIBUTE_UNUSED)
{
+ virThread thread;
+
if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
"NameOwnerChanged") ||
dbus_message_is_signal(message, "org.fedoraproject.FirewallD1",
"Reloaded")) {
VIR_DEBUG("Reload in nwfilter_driver because of firewalld.");
- nwfilterStateReload();
+
+ /* create thread handle the nwfilter reload, don't block the event_loop.*/
+ if (virThreadCreate(&thread, false, nwfilterThread, NULL) < 0) {
+ VIR_ERROR("create nwfilterThread failed.");
+ }
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
--
1.8.3.1
6 years, 3 months
[libvirt] [PATCH v3 0/3] libxl: implement virDomainPM* functions
by Marek Marczykowski-Górecki
Needed libxl_domain_suspend_only is supported in Xen >= 4.11. But wakeup should
work with older versions.
Marek Marczykowski-Górecki (3):
libxl: send lifecycle event on suspend
libxl: implement virDomainPM* functions
libxl: initialize domain state with real data
src/libxl/libxl_domain.c | 20 +++---
src/libxl/libxl_driver.c | 138 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 150 insertions(+), 8 deletions(-)
base-commit: 3ad77f853230f870efa396636e008292c7f2b1c0
--
git-series 0.9.1
6 years, 3 months
[libvirt] [PATCH] nwfilter:fix deadlock when nwfilter reload
by Wang Yechao
user run "firewalld-cmd --reload"
nwfilterStateReload called in main thread
step 1. virRWLockWrite(&updateLock)
step 2. virNWFilterLoadAllConfigs
step 3. virRWLockUnlock(&updateLock);
lauch a vm: qemuDomainCreateXML runs in other thread
step 1. virRWLockRead(&updateLock);
step 2. qemuProcessStart
step 3. qemuProcessWaitForMonitor
step 4. ...
step 5 virRWLockUnlock(&updateLock);
if nwfilterStateReload called in the middle of step 1 and step 5 of
qemuDomainCreateXML, it can't get the updateLock and then block the event_loop,
so event_loop can't handle the qemu-monitor messages, cause deadlock
move nwfilterStateReload into thread to fix this problem.
Signed-off-by: Wang Yechao <wang.yechao255(a)zte.com.cn>
Reviewed-by: Wang Yi <wang.yi59(a)zte.com.cn>
---
src/nwfilter/nwfilter_driver.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
mode change 100644 => 100755 src/nwfilter/nwfilter_driver.c
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
old mode 100644
new mode 100755
index ac3a964..2c099e2
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -81,17 +81,28 @@ static void nwfilterDriverUnlock(void)
#if HAVE_FIREWALLD
+static void nwfilterThread(void *opaque ATTRIBUTE_UNUSED)
+{
+ nwfilterStateReload();
+}
+
static DBusHandlerResult
nwfilterFirewalldDBusFilter(DBusConnection *connection ATTRIBUTE_UNUSED,
DBusMessage *message,
void *user_data ATTRIBUTE_UNUSED)
{
+ virThread thread;
+
if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
"NameOwnerChanged") ||
dbus_message_is_signal(message, "org.fedoraproject.FirewallD1",
"Reloaded")) {
VIR_DEBUG("Reload in nwfilter_driver because of firewalld.");
- nwfilterStateReload();
+
+ /* create thread handle the nwfilter reload, don't block the event_loop.*/
+ if (virThreadCreate(&thread, false, nwfilterThread, NULL) < 0) {
+ VIR_ERROR("create nwfilterThread failed.");
+ }
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
--
1.8.3.1
6 years, 3 months
[libvirt] [PATCH] util: netlink: Remove virNetDevPutExtraHeader and replace with nlmsg_append
by Shi Lei
This patch removes virNetDevPutExtraHeader and replaces
it with nlmsg_append directly.
Signed-off-by: Shi Lei <shi_lei(a)massclouds.com>
---
src/util/virnetdev.c | 44 ++++++++++++--------------------------------
1 file changed, 12 insertions(+), 32 deletions(-)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index c4dd354..5d4ad24 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -3163,28 +3163,6 @@ virNetDevGetEthtoolFeatures(virBitmapPtr bitmap,
# if HAVE_DECL_DEVLINK_CMD_ESWITCH_GET
-/**
- * virNetDevPutExtraHeader
- * reserve and prepare room for an extra header
- * This function sets to zero the room that is required to put the extra
- * header after the initial Netlink header. This function also increases
- * the nlmsg_len field.
- *
- * @nlh: pointer to Netlink header
- * @size: size of the extra header that we want to put
- *
- * Returns pointer to the start of the extended header
- */
-static void *
-virNetDevPutExtraHeader(struct nlmsghdr *nlh,
- size_t size)
-{
- char *ptr = (char *)nlh + nlh->nlmsg_len;
- size_t len = NLMSG_ALIGN(size);
- nlh->nlmsg_len += len;
- return ptr;
-}
-
/**
* virNetDevGetFamilyId:
@@ -3199,7 +3177,11 @@ virNetDevGetFamilyId(const char *family_name)
{
struct nl_msg *nl_msg = NULL;
struct nlmsghdr *resp = NULL;
- struct genlmsghdr* gmsgh = NULL;
+ struct genlmsghdr gmsgh = {
+ .cmd = CTRL_CMD_GETFAMILY,
+ .version = DEVLINK_GENL_VERSION,
+ .reserved = 0,
+ };
struct nlattr *tb[CTRL_ATTR_MAX + 1] = {NULL, };
unsigned int recvbuflen;
uint32_t family_id = 0;
@@ -3210,12 +3192,9 @@ virNetDevGetFamilyId(const char *family_name)
goto cleanup;
}
- if (!(gmsgh = virNetDevPutExtraHeader(nlmsg_hdr(nl_msg), sizeof(struct genlmsghdr))))
+ if (nlmsg_append(nl_msg, &gmsgh, sizeof(gmsgh), NLMSG_ALIGNTO) < 0)
goto cleanup;
- gmsgh->cmd = CTRL_CMD_GETFAMILY;
- gmsgh->version = DEVLINK_GENL_VERSION;
-
if (nla_put_string(nl_msg, CTRL_ATTR_FAMILY_NAME, family_name) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("allocated netlink buffer is too small"));
@@ -3262,7 +3241,11 @@ virNetDevSwitchdevFeature(const char *ifname,
unsigned int recvbuflen;
struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {NULL, };
virPCIDevicePtr pci_device_ptr = NULL;
- struct genlmsghdr* gmsgh = NULL;
+ struct genlmsghdr gmsgh = {
+ .cmd = DEVLINK_CMD_ESWITCH_GET,
+ .version = DEVLINK_GENL_VERSION,
+ .reserved = 0,
+ };
const char *pci_name;
char *pfname = NULL;
int is_vf = -1;
@@ -3292,12 +3275,9 @@ virNetDevSwitchdevFeature(const char *ifname,
goto cleanup;
}
- if (!(gmsgh = virNetDevPutExtraHeader(nlmsg_hdr(nl_msg), sizeof(struct genlmsghdr))))
+ if (nlmsg_append(nl_msg, &gmsgh, sizeof(gmsgh), NLMSG_ALIGNTO) < 0)
goto cleanup;
- gmsgh->cmd = DEVLINK_CMD_ESWITCH_GET;
- gmsgh->version = DEVLINK_GENL_VERSION;
-
pci_name = virPCIDeviceGetName(pci_device_ptr);
if (nla_put(nl_msg, DEVLINK_ATTR_BUS_NAME, strlen("pci")+1, "pci") < 0 ||
--
2.17.1
6 years, 3 months
[libvirt] [PATCH] util: netdev: fix memleak of virNetDevIPRouteAdd
by Shi Lei
This patch fixes memleak for *resp* in virNetDevIPRouteAdd.
Signed-off-by: Shi Lei <shi_lei(a)massclouds.com>
---
src/util/virnetdevip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index 0f080a5..16570a5 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -283,7 +283,7 @@ virNetDevIPRouteAdd(const char *ifname,
virSocketAddrPtr gateway,
unsigned int metric)
{
- struct nlmsghdr *resp = NULL;
+ VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
unsigned int recvbuflen;
unsigned int ifindex;
struct rtmsg rtmsg;
--
2.17.1
6 years, 3 months
[libvirt] [PATCH v2 0/3] libxl: implement virDomainPM* functions
by Marek Marczykowski-Górecki
Needed libxl_domain_suspend_only is supported in Xen >= 4.11. But wakeup should
work with older versions.
Marek Marczykowski-Górecki (3):
libxl: send lifecycle event on suspend
libxl: implement virDomainPM* functions
libxl: initialize domain state with real data
src/libxl/libxl_domain.c | 20 +++---
src/libxl/libxl_driver.c | 132 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 144 insertions(+), 8 deletions(-)
base-commit: 3ad77f853230f870efa396636e008292c7f2b1c0
--
git-series 0.9.1
6 years, 3 months
[libvirt] [PATCH] qemuProcessBuildDestroyMemoryPathsImpl: Don't overwrite error
by Michal Privoznik
The qemuSecurityDomainSetPathLabel() function reports perfect
error itself. Do not overwrite it to something less meaningful.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_process.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 960c3ed011..eb9904b7ba 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3669,11 +3669,8 @@ qemuProcessBuildDestroyMemoryPathsImpl(virQEMUDriverPtr driver,
}
if (qemuSecurityDomainSetPathLabel(driver->securityManager,
- def, path, true) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to label %s"), path);
+ def, path, true) < 0)
return -1;
- }
} else {
if (virFileDeleteTree(path) < 0)
return -1;
--
2.16.4
6 years, 3 months
[libvirt] [PATCH] conf: Fix check for chardev source path
by Andrea Bolognani
Attempting to use a chardev definition like
<serial type='unix'>
<target type='isa-serial'/>
</serial>
correctly results in an error being reported, since the source
path - a required piece of information - is missing; however,
the very similar
<serial type='unix'>
<target type='pci-serial'/>
</serial>
was happily accepted by libvirt, only to result in libvirtd
crashing as soon as the guest was started.
The issue was caused by checking the chardev's targetType
against whitelisted values from virDomainChrChannelTargetType
without first checking the chardev's deviceType to make sure
it is actually a channel, for which the check makes sense,
rather than a different type of chardev.
The only reason this wasn't spotted earlier is that the
whitelisted values just so happen to correspond to USB and
PCI serial devices and Xen and UML consoles respectively,
all of which are fairly uncommon.
https://bugzilla.redhat.com/show_bug.cgi?id=1609720
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
I feel compelled to point out that stuff like this wouldn't
happen if libvirt was written in Rust O:-)
src/conf/domain_conf.c | 8 ++++++--
.../serial-unix-missing-source.xml | 15 +++++++++++++++
tests/qemuxml2argvtest.c | 1 +
3 files changed, 22 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/serial-unix-missing-source.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 86199623cc..6162843028 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5467,10 +5467,14 @@ virDomainChrSourceDefValidate(const virDomainChrSourceDef *def,
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
- /* path can be auto generated */
+ /* The source path can be auto generated for certain specific
+ * types of channels, but in most cases we should report an
+ * error if the user didn't provide it */
if (!def->data.nix.path &&
(!chr_def ||
- (chr_def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN &&
+ chr_def->deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL ||
+ (chr_def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
+ chr_def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN &&
chr_def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing source path attribute for char device"));
diff --git a/tests/qemuxml2argvdata/serial-unix-missing-source.xml b/tests/qemuxml2argvdata/serial-unix-missing-source.xml
new file mode 100644
index 0000000000..1e1221f12d
--- /dev/null
+++ b/tests/qemuxml2argvdata/serial-unix-missing-source.xml
@@ -0,0 +1,15 @@
+<domain type='qemu'>
+ <name>guest</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>1048576</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='aarch64' machine='virt'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-aarch64</emulator>
+ <serial type='unix'>
+ <target type='pci-serial'/>
+ </serial>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 35df63b2ac..949b203998 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1417,6 +1417,7 @@ mymain(void)
DO_TEST("serial-unix-chardev",
QEMU_CAPS_DEVICE_ISA_SERIAL);
DO_TEST_CAPS_LATEST("serial-unix-chardev");
+ DO_TEST_PARSE_ERROR("serial-unix-missing-source", NONE);
DO_TEST("serial-tcp-chardev",
QEMU_CAPS_DEVICE_ISA_SERIAL);
DO_TEST("serial-udp-chardev",
--
2.17.1
6 years, 3 months