[PATCH v5.1 02/11] conf: Add post XML parse callbacks and prepare for cleaning of virCaps

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

 



This patch adds instrumentation that will allow hypervisor drivers to
fill and validate domain and device definitions after parsed by the XML
parser.

With this patch, after the XML is parsed, a callback to the driver is
issued requesing to fill and validate driver specific details of the
configuration. This allows to use sensible defaults and checks on a per
driver basis at the time the XML is parsed.

Two callback pointers are stored in the new virDomainXMLConf object:
* virDomainDeviceDefPostParseCallback (devicesPostParseCallback)
  - called for a single device parsed and for every single device in a
    domain config. A virDomainDeviceDefPtr is passed along with the
    domain definition and virCaps.

* virDomainDefPostParseCallback, (domainPostParseCallback)
  - A callback that is meant to process the domain config after it's
  parsed.  A virDomainDefPtr is passed along with virCaps.

Both types of callbacks support arbitrary opaque data passed for the
callback functions.

Errors may be reported in those callbacks resulting in a XML parsing
failure.
---
 src/conf/domain_conf.c           | 101 +++++++++++++++++++++++++++++++++++++--
 src/conf/domain_conf.h           |  26 ++++++++--
 src/esx/esx_driver.c             |   2 +-
 src/libxl/libxl_driver.c         |  11 +++--
 src/lxc/lxc_conf.c               |   4 +-
 src/lxc/lxc_driver.c             |   6 ++-
 src/openvz/openvz_conf.c         |   1 +
 src/openvz/openvz_driver.c       |   6 +--
 src/parallels/parallels_driver.c |   2 +-
 src/phyp/phyp_driver.c           |   6 +--
 src/qemu/qemu_conf.c             |   5 +-
 src/qemu/qemu_driver.c           |  11 +++--
 src/security/virt-aa-helper.c    |   2 +-
 src/test/test_driver.c           |   2 +-
 src/uml/uml_driver.c             |   7 ++-
 src/vbox/vbox_tmpl.c             |  10 ++--
 src/vmware/vmware_driver.c       |   2 +-
 src/xen/xen_driver.c             |   2 +-
 src/xen/xend_internal.c          |   6 +--
 src/xen/xm_internal.c            |   2 +
 src/xenapi/xenapi_driver.c       |   2 +-
 tests/testutilsxen.c             |   2 +-
 tests/xml2vmxtest.c              |   2 +-
 23 files changed, 174 insertions(+), 46 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6714a8c..a13a871 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -73,6 +73,9 @@ struct _virDomainObjList {
 struct _virDomainXMLOption {
     virObject parent;

+    /* XML parser callbacks and defaults */
+    virDomainDefParserConfig config;
+
     /* domain private data management callbacks */
     virDomainXMLPrivateDataCallbacks privateData;

@@ -723,6 +726,7 @@ static virClassPtr virDomainObjListClass;
 static virClassPtr virDomainXMLOptionClass;
 static void virDomainObjDispose(void *obj);
 static void virDomainObjListDispose(void *obj);
+static void virDomainXMLOptionClassDispose(void *obj);

 static int virDomainObjOnceInit(void)
 {
@@ -741,7 +745,7 @@ static int virDomainObjOnceInit(void)
     if (!(virDomainXMLOptionClass = virClassNew(virClassForObject(),
                                                 "virDomainXMLOption",
                                                 sizeof(virDomainXMLOption),
-                                                NULL)))
+                                                virDomainXMLOptionClassDispose)))
         return -1;

     return 0;
@@ -750,13 +754,24 @@ static int virDomainObjOnceInit(void)
 VIR_ONCE_GLOBAL_INIT(virDomainObj)


+static void
+virDomainXMLOptionClassDispose(void *obj)
+{
+    virDomainXMLOptionPtr xmlopt = obj;
+
+    if (xmlopt->config.privFree)
+        (xmlopt->config.privFree)(xmlopt->config.priv);
+}
+
+
 /**
  * virDomainXMLOptionNew:
  *
  * Allocate a new domain XML configuration
  */
 virDomainXMLOptionPtr
-virDomainXMLOptionNew(virDomainXMLPrivateDataCallbacksPtr priv,
+virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
+                      virDomainXMLPrivateDataCallbacksPtr priv,
                       virDomainXMLNamespacePtr xmlns)
 {
     virDomainXMLOptionPtr xmlopt;
@@ -770,6 +785,9 @@ virDomainXMLOptionNew(virDomainXMLPrivateDataCallbacksPtr priv,
     if (priv)
         xmlopt->privateData = *priv;

+    if (config)
+        xmlopt->config = *config;
+
     if (xmlns)
         xmlopt->ns = *xmlns;

@@ -2461,6 +2479,73 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def,
 }


+static int
+virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
+                            virDomainDefPtr def,
+                            virCapsPtr caps,
+                            virDomainXMLOptionPtr xmlopt)
+{
+    int ret;
+
+    if (xmlopt && xmlopt->config.devicesPostParseCallback) {
+        ret = xmlopt->config.devicesPostParseCallback(dev, def, caps,
+                                                    xmlopt->config.priv);
+        if (ret < 0)
+            return ret;
+    }
+
+    return 0;
+}
+
+
+struct virDomainDefPostParseDeviceIteratorData {
+    virDomainDefPtr def;
+    virCapsPtr caps;
+    virDomainXMLOptionPtr xmlopt;
+};
+
+
+static int
+virDomainDefPostParseDeviceIterator(virDomainDefPtr def ATTRIBUTE_UNUSED,
+                                    virDomainDeviceDefPtr dev,
+                                    virDomainDeviceInfoPtr info ATTRIBUTE_UNUSED,
+                                    void *opaque)
+{
+    struct virDomainDefPostParseDeviceIteratorData *data = opaque;
+    return virDomainDeviceDefPostParse(dev, data->def, data->caps, data->xmlopt);
+}
+
+
+static int
+virDomainDefPostParse(virDomainDefPtr def,
+                      virCapsPtr caps,
+                      virDomainXMLOptionPtr xmlopt)
+{
+    int ret;
+    struct virDomainDefPostParseDeviceIteratorData data = {
+        .def = def,
+        .caps = caps,
+        .xmlopt = xmlopt,
+    };
+
+    /* call the domain config callback */
+    if (xmlopt && xmlopt->config.domainPostParseCallback) {
+        ret = xmlopt->config.domainPostParseCallback(def, caps,
+                                                   xmlopt->config.priv);
+        if (ret < 0)
+            return ret;
+    }
+
+    /* iterate the devices */
+    if ((ret = virDomainDeviceInfoIterate(def,
+                                          virDomainDefPostParseDeviceIterator,
+                                          &data)) < 0)
+        return ret;
+
+    return 0;
+}
+
+
 void virDomainDefClearPCIAddresses(virDomainDefPtr def)
 {
     virDomainDeviceInfoIterate(def, virDomainDeviceInfoClearPCIAddress, NULL);
@@ -8386,6 +8471,7 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt,

 virDomainDeviceDefPtr
 virDomainDeviceDefParse(virCapsPtr caps,
+                        virDomainXMLOptionPtr xmlopt,
                         virDomainDefPtr def,
                         const char *xmlStr,
                         unsigned int flags)
@@ -8472,6 +8558,10 @@ virDomainDeviceDefParse(virCapsPtr caps,
         goto error;
     }

+    /* callback to fill driver specific device aspects */
+    if (virDomainDeviceDefPostParse(dev, def,  caps, xmlopt) < 0)
+        goto error;
+
 cleanup:
     xmlFreeDoc(xml);
     xmlXPathFreeContext(ctxt);
@@ -11029,6 +11119,10 @@ virDomainDefParseXML(virCapsPtr caps,
     if (virDomainDefAddImplicitControllers(def) < 0)
         goto error;

+    /* callback to fill driver specific domain aspects */
+    if (virDomainDefPostParse(def, caps, xmlopt) < 0)
+        goto error;
+
     virBitmapFree(bootMap);

     return def;
@@ -16426,6 +16520,7 @@ virDomainNetFind(virDomainDefPtr def, const char *device)
  */
 virDomainDeviceDefPtr
 virDomainDeviceDefCopy(virCapsPtr caps,
+                       virDomainXMLOptionPtr xmlopt,
                        const virDomainDefPtr def,
                        virDomainDeviceDefPtr src)
 {
@@ -16494,7 +16589,7 @@ virDomainDeviceDefCopy(virCapsPtr caps,
         goto cleanup;

     xmlStr = virBufferContentAndReset(&buf);
-    ret = virDomainDeviceDefParse(caps, def, xmlStr, flags);
+    ret = virDomainDeviceDefParse(caps, xmlopt, def, xmlStr, flags);

 cleanup:
     VIR_FREE(xmlStr);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5fb2023..69a468a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1938,6 +1938,24 @@ typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
 typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *);
 typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *);

+typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
+                                             virCapsPtr caps,
+                                             void *opaque);
+typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
+                                                   virDomainDefPtr def,
+                                                   virCapsPtr caps,
+                                                   void *opaque);
+
+typedef struct _virDomainDefParserConfig virDomainDefParserConfig;
+typedef virDomainDefParserConfig *virDomainDefParserConfigPtr;
+struct _virDomainDefParserConfig {
+    virDomainDefPostParseCallback domainPostParseCallback;
+    virDomainDeviceDefPostParseCallback devicesPostParseCallback;
+
+    void *priv;
+    virFreeCallback privFree;
+};
+
 typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
 typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
 struct _virDomainXMLPrivateDataCallbacks {
@@ -1947,9 +1965,9 @@ struct _virDomainXMLPrivateDataCallbacks {
     virDomainXMLPrivateDataParseFunc  parse;
 };

-virDomainXMLOptionPtr
-virDomainXMLOptionNew(virDomainXMLPrivateDataCallbacksPtr priv,
-                    virDomainXMLNamespacePtr xmlns);
+virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
+                                            virDomainXMLPrivateDataCallbacksPtr priv,
+                                            virDomainXMLNamespacePtr xmlns);

 virDomainXMLNamespacePtr
 virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
@@ -2009,6 +2027,7 @@ void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
 void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
 void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
 virDomainDeviceDefPtr virDomainDeviceDefCopy(virCapsPtr caps,
+                                             virDomainXMLOptionPtr xmlopt,
                                              const virDomainDefPtr def,
                                              virDomainDeviceDefPtr src);
 int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
@@ -2072,6 +2091,7 @@ void virDomainObjListRemove(virDomainObjListPtr doms,
                             virDomainObjPtr dom);

 virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
+                                              virDomainXMLOptionPtr xmlopt,
                                               virDomainDefPtr def,
                                               const char *xmlStr,
                                               unsigned int flags);
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 3e49ec0..1335ee6 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1100,7 +1100,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth,
         goto cleanup;
     }

-    if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL)))
+    if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)))
         goto cleanup;

     conn->privateData = priv;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 7c033fa..4015389 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1239,8 +1239,9 @@ libxlStartup(bool privileged,
         goto error;
     }

-    if (!(libxl_driver->xmlopt = virDomainXMLOptionNew(&libxlDomainXMLPrivateDataCallbacks,
-                                                      NULL)))
+    if (!(libxl_driver->xmlopt = virDomainXMLOptionNew(NULL,
+                                                       &libxlDomainXMLPrivateDataCallbacks,
+                                                       NULL)))
         goto error;

     /* Load running domains first. */
@@ -3556,7 +3557,8 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
     priv = vm->privateData;

     if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
-        if (!(dev = virDomainDeviceDefParse(driver->caps, vm->def, xml,
+        if (!(dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt,
+                                            vm->def, xml,
                                             VIR_DOMAIN_XML_INACTIVE)))
             goto cleanup;

@@ -3586,7 +3588,8 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
     if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
         /* If dev exists it was created to modify the domain config. Free it. */
         virDomainDeviceDefFree(dev);
-        if (!(dev = virDomainDeviceDefParse(driver->caps, vm->def, xml,
+        if (!(dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt,
+                                            vm->def, xml,
                                             VIR_DOMAIN_XML_INACTIVE)))
             goto cleanup;

diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index ab6c749..377d8af 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -159,7 +159,9 @@ error:
 virDomainXMLOptionPtr
 lxcDomainXMLConfInit(void)
 {
-    return virDomainXMLOptionNew(&virLXCDriverPrivateDataCallbacks, NULL);
+    return virDomainXMLOptionNew(NULL,
+                                 &virLXCDriverPrivateDataCallbacks,
+                                 NULL);
 }

 int lxcLoadDriverConfig(virLXCDriverPtr driver)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 130544c..572329d 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -4360,7 +4360,8 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
          goto cleanup;
     }

-    dev = dev_copy = virDomainDeviceDefParse(driver->caps, vm->def, xml,
+    dev = dev_copy = virDomainDeviceDefParse(driver->caps, driver->xmlopt,
+                                             vm->def, xml,
                                              VIR_DOMAIN_XML_INACTIVE);
     if (dev == NULL)
         goto cleanup;
@@ -4371,7 +4372,8 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
          * create a deep copy of device as adding
          * to CONFIG takes one instance.
          */
-        dev_copy = virDomainDeviceDefCopy(driver->caps, vm->def, dev);
+        dev_copy = virDomainDeviceDefCopy(driver->caps, driver->xmlopt,
+                                          vm->def, dev);
         if (!dev_copy)
             goto cleanup;
     }
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 8858c2d..3cd27a4 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -174,6 +174,7 @@ static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
     return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ;
 }

+
 virCapsPtr openvzCapsInit(void)
 {
     virCapsPtr caps;
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 2fd6a41..d334486 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1453,7 +1453,7 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
     if (!(driver->caps = openvzCapsInit()))
         goto cleanup;

-    if (!(driver->xmlopt = virDomainXMLOptionNew(NULL, NULL)))
+    if (!(driver->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)))
         goto cleanup;

     if (openvzLoadDomains(driver) < 0)
@@ -2085,8 +2085,8 @@ openvzDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
                                         &vmdef) < 0)
         goto cleanup;

-    dev = virDomainDeviceDefParse(driver->caps, vmdef, xml,
-                                  VIR_DOMAIN_XML_INACTIVE);
+    dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt,
+                                  vmdef, xml, VIR_DOMAIN_XML_INACTIVE);
     if (!dev)
         goto cleanup;

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 1d74340..5d5353a 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -929,7 +929,7 @@ parallelsOpenDefault(virConnectPtr conn)
     if (!(privconn->caps = parallelsBuildCapabilities()))
         goto error;

-    if (!(privconn->xmlopt = virDomainXMLOptionNew(NULL, NULL)))
+    if (!(privconn->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)))
         goto error;

     if (!(privconn->domains = virDomainObjListNew()))
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 090581c..cd9a989 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1204,7 +1204,7 @@ phypOpen(virConnectPtr conn,
         goto failure;
     }

-    if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(NULL, NULL)))
+    if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)))
         goto failure;

     conn->privateData = phyp_driver;
@@ -1754,8 +1754,8 @@ phypAttachDevice(virDomainPtr domain, const char *xml)
         goto cleanup;
     }

-    dev = virDomainDeviceDefParse(phyp_driver->caps, def, xml,
-                                  VIR_DOMAIN_XML_INACTIVE);
+    dev = virDomainDeviceDefParse(phyp_driver->caps, NULL,
+                                  def, xml, VIR_DOMAIN_XML_INACTIVE);
     if (!dev) {
         goto cleanup;
     }
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 15c6d89..c709188 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -554,8 +554,9 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver)
 virDomainXMLOptionPtr
 virQEMUDriverCreateXMLConf(void)
 {
-    return virDomainXMLOptionNew(&virQEMUDriverPrivateDataCallbacks,
-                               &virQEMUDriverDomainXMLNamespace);
+    return virDomainXMLOptionNew(NULL,
+                                 &virQEMUDriverPrivateDataCallbacks,
+                                 &virQEMUDriverDomainXMLNamespace);
 }


diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6ba899f..d3276de 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5786,7 +5786,8 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
         tmp = dev->data.disk;
         dev->data.disk = orig_disk;

-        if (!(dev_copy = virDomainDeviceDefCopy(caps, vm->def, dev))) {
+        if (!(dev_copy = virDomainDeviceDefCopy(caps, driver->xmlopt,
+                                                vm->def, dev))) {
             dev->data.disk = tmp;
             goto end;
         }
@@ -6062,7 +6063,8 @@ qemuDomainChangeDiskMediaLive(virDomainObjPtr vm,
         tmp = dev->data.disk;
         dev->data.disk = orig_disk;

-        if (!(dev_copy = virDomainDeviceDefCopy(caps, vm->def, dev))) {
+        if (!(dev_copy = virDomainDeviceDefCopy(caps, driver->xmlopt,
+                                                vm->def, dev))) {
             dev->data.disk = tmp;
             goto end;
         }
@@ -6468,7 +6470,8 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
          goto endjob;
     }

-    dev = dev_copy = virDomainDeviceDefParse(caps, vm->def, xml,
+    dev = dev_copy = virDomainDeviceDefParse(caps, driver->xmlopt,
+                                             vm->def, xml,
                                              VIR_DOMAIN_XML_INACTIVE);
     if (dev == NULL)
         goto endjob;
@@ -6479,7 +6482,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
          * create a deep copy of device as adding
          * to CONFIG takes one instance.
          */
-        dev_copy = virDomainDeviceDefCopy(caps, vm->def, dev);
+        dev_copy = virDomainDeviceDefCopy(caps, driver->xmlopt, vm->def, dev);
         if (!dev_copy)
             goto endjob;
     }
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 6534bea..06c19fa 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -711,7 +711,7 @@ get_definition(vahControl * ctl, const char *xmlStr)
         goto exit;
     }

-    if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL))) {
+    if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) {
         vah_error(ctl, 0, _("Failed to create XML config object"));
         goto exit;
     }
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 4c8b21b..d35dfc4 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -164,7 +164,7 @@ testBuildXMLConfig(void)
 {
     virDomainXMLPrivateDataCallbacks priv = { .alloc = testDomainObjPrivateAlloc,
                                               .free = testDomainObjPrivateFree };
-    return virDomainXMLOptionNew(&priv, NULL);
+    return virDomainXMLOptionNew(NULL, &priv, NULL);
 }


diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 1d21d71..f9a7920 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -505,8 +505,7 @@ umlStartup(bool privileged,
     if ((uml_driver->caps = umlCapsInit()) == NULL)
         goto out_of_memory;

-    if (!(uml_driver->xmlopt = virDomainXMLOptionNew(&privcb,
-                                                    NULL)))
+    if (!(uml_driver->xmlopt = virDomainXMLOptionNew(NULL, &privcb, NULL)))
         goto error;

     if ((uml_driver->inotifyFD = inotify_init()) < 0) {
@@ -2081,7 +2080,7 @@ static int umlDomainAttachDevice(virDomainPtr dom, const char *xml)
         goto cleanup;
     }

-    dev = virDomainDeviceDefParse(driver->caps, vm->def, xml,
+    dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, vm->def, xml,
                                   VIR_DOMAIN_XML_INACTIVE);

     if (dev == NULL)
@@ -2199,7 +2198,7 @@ static int umlDomainDetachDevice(virDomainPtr dom, const char *xml) {
         goto cleanup;
     }

-    dev = virDomainDeviceDefParse(driver->caps, vm->def, xml,
+    dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, vm->def, xml,
                                   VIR_DOMAIN_XML_INACTIVE);
     if (dev == NULL)
         goto cleanup;
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index f5d687a..eb6460c 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -854,7 +854,7 @@ static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
 static virDomainXMLOptionPtr
 vboxXMLConfInit(void)
 {
-    return virDomainXMLOptionNew(NULL, NULL);
+    return virDomainXMLOptionNew(NULL, NULL, NULL);
 }


@@ -5396,8 +5396,8 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
         goto cleanup;
     }

-    dev = virDomainDeviceDefParse(data->caps, def, xml,
-                                  VIR_DOMAIN_XML_INACTIVE);
+    dev = virDomainDeviceDefParse(data->caps, data->xmlopt,
+                                  def, xml, VIR_DOMAIN_XML_INACTIVE);
     if (dev == NULL)
         goto cleanup;

@@ -5631,8 +5631,8 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
         goto cleanup;
     }

-    dev = virDomainDeviceDefParse(data->caps, def, xml,
-                                  VIR_DOMAIN_XML_INACTIVE);
+    dev = virDomainDeviceDefParse(data->caps, data->xmlopt,
+                                  def, xml, VIR_DOMAIN_XML_INACTIVE);
     if (dev == NULL)
         goto cleanup;

diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 28b4e17..2dd6f81 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -78,7 +78,7 @@ vmwareDomainXMLConfigInit(void)
     virDomainXMLPrivateDataCallbacks priv = { .alloc = vmwareDataAllocFunc,
                                               .free = vmwareDataFreeFunc };

-    return virDomainXMLOptionNew(&priv, NULL);
+    return virDomainXMLOptionNew(NULL, &priv, NULL);
 }

 static virDrvOpenStatus
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index edb8e98..38dce0a 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -401,7 +401,7 @@ xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
         goto fail;
     }

-    if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL)))
+    if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)))
         goto fail;

 #if WITH_XEN_INOTIFY
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index ea9814b..f6ce8eb 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -2519,7 +2519,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain,
                                      NULL)))
         goto cleanup;

-    if (!(dev = virDomainDeviceDefParse(priv->caps,
+    if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlopt,
                                         def, xml, VIR_DOMAIN_XML_INACTIVE)))
         goto cleanup;

@@ -2679,7 +2679,7 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain,
                                      NULL)))
         goto cleanup;

-    if (!(dev = virDomainDeviceDefParse(priv->caps,
+    if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlopt,
                                         def, xml, VIR_DOMAIN_XML_INACTIVE)))
         goto cleanup;

@@ -2786,7 +2786,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain,
                                      NULL)))
         goto cleanup;

-    if (!(dev = virDomainDeviceDefParse(priv->caps,
+    if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlopt,
                                         def, xml, VIR_DOMAIN_XML_INACTIVE)))
         goto cleanup;

diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index c406ee3..69c8f4a 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -1311,6 +1311,7 @@ xenXMDomainAttachDeviceFlags(virDomainPtr domain,
     def = entry->def;

     if (!(dev = virDomainDeviceDefParse(priv->caps,
+                                        priv->xmlopt,
                                         entry->def,
                                         xml, VIR_DOMAIN_XML_INACTIVE)))
         goto cleanup;
@@ -1404,6 +1405,7 @@ xenXMDomainDetachDeviceFlags(virDomainPtr domain,
     def = entry->def;

     if (!(dev = virDomainDeviceDefParse(priv->caps,
+                                        priv->xmlopt,
                                         entry->def,
                                         xml, VIR_DOMAIN_XML_INACTIVE)))
         goto cleanup;
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 0e15e26..712c20b 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -169,7 +169,7 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth,
         goto error;
     }

-    if (!(privP->xmlopt = virDomainXMLOptionNew(NULL, NULL))) {
+    if (!(privP->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) {
         xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
                                   _("Failed to create XML conf object"));
         goto error;
diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c
index bfced0c..2eb4730 100644
--- a/tests/testutilsxen.c
+++ b/tests/testutilsxen.c
@@ -18,7 +18,7 @@ static int testXenDefaultConsoleType(const char *ostype,
 virDomainXMLOptionPtr
 testXenXMLConfInit(void)
 {
-    return virDomainXMLOptionNew(NULL, NULL);
+    return virDomainXMLOptionNew(NULL, NULL, NULL);
 }

 virCapsPtr testXenCapsInit(void) {
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index 344b097..5195ffa 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -240,7 +240,7 @@ mymain(void)
         return EXIT_FAILURE;
     }

-    if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL)))
+    if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)))
         return EXIT_FAILURE;

     ctx.opaque = NULL;
-- 
1.8.1.5

--
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]