[PATCH] qemuDomainAttachDeviceFlags: Parse device xml as inactive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In all other drivers we are doing so. Moreover, we don't want to parse
runtime information in attach (even if the attach is meant as live)
because we are generating the runtime info ourselves. We can't trust
users they supply sane values anyway.

==1140== 9 bytes in 1 blocks are definitely lost in loss record 72 of 1,151
==1140==    at 0x4A06C2B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1140==    by 0x623C758: xmlStrndup (in /usr/lib64/libxml2.so.2.9.1)
==1140==    by 0x50FD763: virXMLPropString (virxml.c:483)
==1140==    by 0x510F8B7: virDomainDeviceInfoParseXML (domain_conf.c:3685)
==1140==    by 0x511ACFD: virDomainChrDefParseXML (domain_conf.c:7535)
==1140==    by 0x5121D13: virDomainDeviceDefParse (domain_conf.c:9918)
==1140==    by 0x13AE6313: qemuDomainAttachDeviceFlags (qemu_driver.c:6926)
==1140==    by 0x13AE65FA: qemuDomainAttachDevice (qemu_driver.c:7005)
==1140==    by 0x51C77DA: virDomainAttachDevice (libvirt.c:10231)
==1140==    by 0x127FDD: remoteDispatchDomainAttachDevice (remote_dispatch.h:2404)
==1140==    by 0x127EC5: remoteDispatchDomainAttachDeviceHelper (remote_dispatch.h:2382)
==1140==    by 0x5241F81: virNetServerProgramDispatchCall (virnetserverprogram.c:437)

When doing live attach, we are passing the inactive definition anyway
since we are passing the result of virDomainDeviceDefCopy() which does
inactive copy by default.

Moreover, we are doing the same mistake in qemuhotplugtest.

Just a side note - it makes perfect sense to parse the runtime info
like alias in qemuDomainDetachDevice and qemuDomainUpdateDeviceFlags()
as in some cases the only difference to distinguish two devices can be
just their alias.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c  | 6 +-----
 tests/qemuhotplugtest.c | 7 ++++++-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2707bec..8678d24 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6871,7 +6871,7 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
     virDomainDefPtr vmdef = NULL;
     virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
     int ret = -1;
-    unsigned int affect, parse_flags = 0;
+    unsigned int affect, parse_flags = VIR_DOMAIN_XML_INACTIVE;
     virQEMUCapsPtr qemuCaps = NULL;
     qemuDomainObjPrivatePtr priv;
     virQEMUDriverConfigPtr cfg = NULL;
@@ -6919,10 +6919,6 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
          goto endjob;
     }
 
-    if ((flags & VIR_DOMAIN_AFFECT_CONFIG) &&
-        !(flags & VIR_DOMAIN_AFFECT_LIVE))
-        parse_flags |= VIR_DOMAIN_XML_INACTIVE;
-
     dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
                                              caps, driver->xmlopt,
                                              parse_flags);
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 4ef81e0..a7a4065 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -209,6 +209,7 @@ testQemuHotplug(const void *data)
     const char *const *tmp;
     bool fail = test->fail;
     bool keep = test->keep;
+    unsigned int device_parse_flags = 0;
     virDomainObjPtr vm = NULL;
     virDomainDeviceDefPtr dev = NULL;
     virCapsPtr caps = NULL;
@@ -244,8 +245,12 @@ testQemuHotplug(const void *data)
             goto cleanup;
     }
 
+    if (test->action == ATTACH)
+        device_parse_flags = VIR_DOMAIN_XML_INACTIVE;
+
     if (!(dev = virDomainDeviceDefParse(device_xml, vm->def,
-                                        caps, driver.xmlopt, 0)))
+                                        caps, driver.xmlopt,
+                                        device_parse_flags)))
         goto cleanup;
 
     /* Now is the best time to feed the spoofed monitor with predefined
-- 
1.9.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]