[libvirt] [PATCH v2 3/3] XMLToNative: Parse XML as INACTIVE

Cole Robinson crobinso at redhat.com
Fri Mar 14 13:41:13 UTC 2014


Right now we are parsing the XML as though it's live, which for example
will choke on hardcoded XML like:

  <seclabel type='dynamic' model='selinux' relabel='yes'/>

Erroring with:

  $ sudo virsh domxml-to-native qemu-argv f
  error: XML error: security label is missing

All drivers are fixed, but only qemu was tested.
---

v2:
    Fix all drivers

 src/esx/esx_driver.c     | 3 ++-
 src/libxl/libxl_driver.c | 3 ++-
 src/qemu/qemu_driver.c   | 3 ++-
 src/xen/xen_driver.c     | 3 ++-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 886d984..6a2efe3 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2836,7 +2836,8 @@ esxConnectDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
     }
 
     def = virDomainDefParseString(domainXml, priv->caps, priv->xmlopt,
-                                  1 << VIR_DOMAIN_VIRT_VMWARE, 0);
+                                  1 << VIR_DOMAIN_VIRT_VMWARE,
+                                  VIR_DOMAIN_XML_INACTIVE);
 
     if (!def) {
         return NULL;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ae7342a..09ae075 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2979,7 +2979,8 @@ libxlConnectDomainXMLToNative(virConnectPtr conn, const char * nativeFormat,
 
     if (!(def = virDomainDefParseString(domainXml,
                                         cfg->caps, driver->xmlopt,
-                                        1 << VIR_DOMAIN_VIRT_XEN, 0)))
+                                        1 << VIR_DOMAIN_VIRT_XEN,
+                                        VIR_DOMAIN_XML_INACTIVE)))
         goto cleanup;
 
     if (!(conf = xenFormatXM(conn, def, cfg->verInfo->xen_version_major)))
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a01739c..89f443f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5812,7 +5812,8 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
         goto cleanup;
 
     def = virDomainDefParseString(xmlData, caps, driver->xmlopt,
-                                  QEMU_EXPECTED_VIRT_TYPES, 0);
+                                  QEMU_EXPECTED_VIRT_TYPES,
+                                  VIR_DOMAIN_XML_INACTIVE);
     if (!def)
         goto cleanup;
 
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 1880b22..9204f88 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1657,7 +1657,8 @@ xenUnifiedConnectDomainXMLToNative(virConnectPtr conn,
     }
 
     if (!(def = virDomainDefParseString(xmlData, priv->caps, priv->xmlopt,
-                                        1 << VIR_DOMAIN_VIRT_XEN, 0)))
+                                        1 << VIR_DOMAIN_VIRT_XEN,
+                                        VIR_DOMAIN_XML_INACTIVE)))
         goto cleanup;
 
     if (STREQ(format, XEN_CONFIG_FORMAT_XM)) {
-- 
1.8.5.3




More information about the libvir-list mailing list