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

[libvirt] [PATCHv2 08/21] fix fallout in src/qemu/



---
 src/qemu/qemu_command.c   |   9 ++--
 src/qemu/qemu_command.h   |   3 ++
 src/qemu/qemu_conf.c      |  10 ++--
 src/qemu/qemu_conf.h      |   4 ++
 src/qemu/qemu_domain.c    |  58 +++++++++-------------
 src/qemu/qemu_domain.h    |   6 +--
 src/qemu/qemu_driver.c    | 123 +++++++++++++++++++++-------------------------
 src/qemu/qemu_migration.c |  22 ++++-----
 src/qemu/qemu_process.c   | 109 +++++++---------------------------------
 9 files changed, 130 insertions(+), 214 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 201fac1..88b7652 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8562,6 +8562,7 @@ qemuParseCommandLineBootDevs(virDomainDefPtr def, const char *str) {
  * as is practical. This is not an exact science....
  */
 virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
+                                     virDomainXMLConfPtr xmlconf,
                                      const char **progenv,
                                      const char **progargv,
                                      char **pidfile,
@@ -9423,7 +9424,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
         goto error;

     if (cmd->num_args || cmd->num_env) {
-        def->ns = qemuCaps->ns;
+        def->ns = virDomainXMLConfGetNamespace(xmlconf);
         def->namespaceData = cmd;
     }
     else
@@ -9449,6 +9450,7 @@ error:


 virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps,
+                                           virDomainXMLConfPtr xmlconf,
                                            const char *args,
                                            char **pidfile,
                                            virDomainChrSourceDefPtr *monConfig,
@@ -9462,7 +9464,7 @@ virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps,
     if (qemuStringToArgvEnv(args, &progenv, &progargv) < 0)
         goto cleanup;

-    def = qemuParseCommandLine(qemuCaps, progenv, progargv,
+    def = qemuParseCommandLine(qemuCaps, xmlconf, progenv, progargv,
                                pidfile, monConfig, monJSON);

 cleanup:
@@ -9538,6 +9540,7 @@ cleanup:
 }

 virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps,
+                                        virDomainXMLConfPtr xmlconf,
                                         pid_t pid,
                                         char **pidfile,
                                         virDomainChrSourceDefPtr *monConfig,
@@ -9557,7 +9560,7 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps,
         qemuParseProcFileStrings(pid, "environ", &progenv) < 0)
         goto cleanup;

-    if (!(def = qemuParseCommandLine(qemuCaps, progenv, progargv,
+    if (!(def = qemuParseCommandLine(qemuCaps, xmlconf, progenv, progargv,
                                      pidfile, monConfig, monJSON)))
         goto cleanup;

diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index e4db000..a1214d8 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -167,17 +167,20 @@ int qemuOpenVhostNet(virDomainDefPtr def,
  * *must* decide how to fill in a name in this case
  */
 virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
+                                     virDomainXMLConfPtr xmlconf,
                                      const char **progenv,
                                      const char **progargv,
                                      char **pidfile,
                                      virDomainChrSourceDefPtr *monConfig,
                                      bool *monJSON);
 virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps,
+                                           virDomainXMLConfPtr xmlconf,
                                            const char *args,
                                            char **pidfile,
                                            virDomainChrSourceDefPtr *monConfig,
                                            bool *monJSON);
 virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps,
+                                        virDomainXMLConfPtr xmlconf,
                                         pid_t pid,
                                         char **pidfile,
                                         virDomainChrSourceDefPtr *monConfig,
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 3ef3499..1beff6d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -551,6 +551,13 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver)
     return conf;
 }

+virDomainXMLConfPtr
+virQEMUDriverCreateXMLConf(void)
+{
+    return virDomainXMLConfNew(&virQEMUDriverPrivateDataCallbacks,
+                               &virQEMUDriverDomainXMLNamespace);
+}
+

 virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver)
 {
@@ -573,9 +580,6 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver)
         caps->defaultDiskDriverType = VIR_STORAGE_FILE_RAW;
     }

-    qemuDomainSetPrivateDataHooks(caps);
-    qemuDomainSetNamespaceHooks(caps);
-
     if (virGetHostUUID(caps->host.host_uuid)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("cannot get the host uuid"));
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 6bb3dee..c5ddaad 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -188,6 +188,9 @@ struct _virQEMUDriver {
      */
     virCapsPtr caps;

+    /* Immutable pointer, Immutable object */
+    virDomainXMLConfPtr xmlconf;
+
     /* Immutable pointer, self-locking APIs */
     virQEMUCapsCachePtr qemuCapsCache;

@@ -298,5 +301,6 @@ void qemuSharedDiskEntryFree(void *payload, const void *name)
     ATTRIBUTE_NONNULL(1);

 int qemuDriverAllocateID(virQEMUDriverPtr driver);
+virDomainXMLConfPtr virQEMUDriverCreateXMLConf(void);

 #endif /* __QEMUD_CONF_H */
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 0e56596..2be207f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -205,7 +205,8 @@ qemuDomainTrackJob(enum qemuDomainJob job)
 }


-static void *qemuDomainObjPrivateAlloc(void)
+static void
+*qemuDomainObjPrivateAlloc(void)
 {
     qemuDomainObjPrivatePtr priv;

@@ -227,7 +228,8 @@ error:
     return NULL;
 }

-static void qemuDomainObjPrivateFree(void *data)
+static void
+qemuDomainObjPrivateFree(void *data)
 {
     qemuDomainObjPrivatePtr priv = data;

@@ -256,7 +258,8 @@ static void qemuDomainObjPrivateFree(void *data)
 }


-static int qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
+static int
+qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
 {
     qemuDomainObjPrivatePtr priv = data;
     const char *monitorpath;
@@ -329,7 +332,8 @@ static int qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
     return 0;
 }

-static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
+static int
+qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
 {
     qemuDomainObjPrivatePtr priv = data;
     char *monitorpath;
@@ -482,6 +486,14 @@ error:
 }


+virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks = {
+    .alloc = qemuDomainObjPrivateAlloc,
+    .free = qemuDomainObjPrivateFree,
+    .parse = qemuDomainObjPrivateXMLParse,
+    .format = qemuDomainObjPrivateXMLFormat,
+};
+
+
 static void
 qemuDomainDefNamespaceFree(void *nsdata)
 {
@@ -641,42 +653,25 @@ qemuDomainDefNamespaceHref(void)
 }


-void qemuDomainSetPrivateDataHooks(virCapsPtr caps)
-{
-    /* Domain XML parser hooks */
-    caps->privateDataAllocFunc = qemuDomainObjPrivateAlloc;
-    caps->privateDataFreeFunc = qemuDomainObjPrivateFree;
-    caps->privateDataXMLFormat = qemuDomainObjPrivateXMLFormat;
-    caps->privateDataXMLParse = qemuDomainObjPrivateXMLParse;
-
-}
+virDomainXMLNamespace virQEMUDriverDomainXMLNamespace = {
+    .parse = qemuDomainDefNamespaceParse,
+    .free = qemuDomainDefNamespaceFree,
+    .format = qemuDomainDefNamespaceFormatXML,
+    .href = qemuDomainDefNamespaceHref,
+};

-void qemuDomainSetNamespaceHooks(virCapsPtr caps)
-{
-    /* Domain Namespace XML parser hooks */
-    caps->ns.parse = qemuDomainDefNamespaceParse;
-    caps->ns.free = qemuDomainDefNamespaceFree;
-    caps->ns.format = qemuDomainDefNamespaceFormatXML;
-    caps->ns.href = qemuDomainDefNamespaceHref;
-}

 static void
 qemuDomainObjSaveJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
 {
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     if (virDomainObjIsActive(obj)) {
-        if (virDomainSaveStatus(caps, cfg->stateDir, obj) < 0)
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, obj) < 0)
             VIR_WARN("Failed to save status on vm %s", obj->def->name);
     }

-cleanup:
     virObjectUnref(cfg);
-    virObjectUnref(caps);
 }

 void
@@ -1782,22 +1777,17 @@ qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     if (priv->fakeReboot == value)
         goto cleanup;

     priv->fakeReboot = value;

-    if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
         VIR_WARN("Failed to save status on vm %s", vm->def->name);

 cleanup:
     virObjectUnref(cfg);
-    virObjectUnref(caps);
 }

 int
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 7dbbaff..3a12b45 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -180,9 +180,6 @@ void qemuDomainEventFlush(int timer, void *opaque);
 void qemuDomainEventQueue(virQEMUDriverPtr driver,
                           virDomainEventPtr event);

-void qemuDomainSetPrivateDataHooks(virCapsPtr caps);
-void qemuDomainSetNamespaceHooks(virCapsPtr caps);
-
 int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
                           virDomainObjPtr obj,
                           enum qemuDomainJob job)
@@ -340,4 +337,7 @@ void qemuDomainCleanupRemove(virDomainObjPtr vm,
 void qemuDomainCleanupRun(virQEMUDriverPtr driver,
                           virDomainObjPtr vm);

+extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
+extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
+
 #endif /* __QEMU_DOMAIN_H__ */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 32b0522..4720090 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -441,6 +441,7 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
         }

         def = virDomainSnapshotDefParseString(xmlStr, caps,
+                                              qemu_driver->xmlconf,
                                               QEMU_EXPECTED_VIRT_TYPES,
                                               flags);
         if (def == NULL) {
@@ -722,6 +723,9 @@ qemuStartup(bool privileged,
     if ((qemu_driver->caps = virQEMUDriverCreateCapabilities(qemu_driver)) == NULL)
         goto error;

+    if (!(qemu_driver->xmlconf = virQEMUDriverCreateXMLConf()))
+        goto error;
+
     /* If hugetlbfs is present, then we need to create a sub-directory within
      * it, since we can't assume the root mount point has permissions that
      * will let our spawned QEMU instances use it.
@@ -763,6 +767,7 @@ qemuStartup(bool privileged,
     /* Get all the running persistent or transient configs first */
     if (virDomainObjListLoadAllConfigs(qemu_driver->domains,
                                        qemu_driver->caps,
+                                       qemu_driver->xmlconf,
                                        cfg->stateDir,
                                        NULL,
                                        1, QEMU_EXPECTED_VIRT_TYPES,
@@ -787,6 +792,7 @@ qemuStartup(bool privileged,
     /* Then inactive persistent configs */
     if (virDomainObjListLoadAllConfigs(qemu_driver->domains,
                                        qemu_driver->caps,
+                                       qemu_driver->xmlconf,
                                        cfg->configDir,
                                        cfg->autostartDir,
                                        0, QEMU_EXPECTED_VIRT_TYPES,
@@ -860,6 +866,7 @@ qemuReload(void) {
     cfg = virQEMUDriverGetConfig(qemu_driver);
     virDomainObjListLoadAllConfigs(qemu_driver->domains,
                                    caps,
+                                   qemu_driver->xmlconf,
                                    cfg->configDir,
                                    cfg->autostartDir,
                                    0, QEMU_EXPECTED_VIRT_TYPES,
@@ -953,6 +960,8 @@ qemuShutdown(void) {
     virObjectUnref(qemu_driver->domains);
     virObjectUnref(qemu_driver->remotePorts);

+    virObjectUnref(qemu_driver->xmlconf);
+
     virSysinfoDefFree(qemu_driver->hostsysinfo);

     virObjectUnref(qemu_driver->closeCallbacks);
@@ -1465,7 +1474,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (!(def = virDomainDefParseString(caps, xml,
+    if (!(def = virDomainDefParseString(caps, driver->xmlconf, xml,
                                         QEMU_EXPECTED_VIRT_TYPES,
                                         VIR_DOMAIN_XML_INACTIVE)))
         goto cleanup;
@@ -1483,7 +1492,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml,
         goto cleanup;

     if (!(vm = virDomainObjListAdd(driver->domains,
-                                   caps,
+                                   driver->xmlconf,
                                    def,
                                    VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
                                    NULL)))
@@ -1551,7 +1560,6 @@ static int qemuDomainSuspend(virDomainPtr dom) {
     int eventDetail;
     int state;
     virQEMUDriverConfigPtr cfg = NULL;
-    virCapsPtr caps = NULL;

     vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);

@@ -1607,9 +1615,7 @@ static int qemuDomainSuspend(virDomainPtr dom) {
                                              eventDetail);
         }
     }
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto endjob;
-    if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
         goto endjob;
     ret = 0;

@@ -1623,7 +1629,6 @@ cleanup:

     if (event)
         qemuDomainEventQueue(driver, event);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return ret;
 }
@@ -1679,7 +1684,7 @@ static int qemuDomainResume(virDomainPtr dom) {
     }
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto endjob;
-    if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
         goto endjob;
     ret = 0;

@@ -2077,7 +2082,7 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,

     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto endjob;
-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto endjob;

@@ -2838,7 +2843,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
     if (xmlin) {
         virDomainDefPtr def = NULL;

-        if (!(def = virDomainDefParseString(caps, xmlin,
+        if (!(def = virDomainDefParseString(caps, driver->xmlconf, xmlin,
                                             QEMU_EXPECTED_VIRT_TYPES,
                                             VIR_DOMAIN_XML_INACTIVE))) {
             goto endjob;
@@ -3752,7 +3757,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
     maximum = (flags & VIR_DOMAIN_VCPU_MAXIMUM) != 0;
     flags &= ~VIR_DOMAIN_VCPU_MAXIMUM;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto endjob;

@@ -3858,7 +3863,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -3949,7 +3954,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
         if (newVcpuPin)
             virDomainVcpuPinDefArrayFree(newVcpuPin, newVcpuPinNum);

-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
             goto cleanup;
     }

@@ -4038,7 +4043,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &targetDef) < 0)
         goto cleanup;

@@ -4134,7 +4139,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
         goto cleanup;
     }

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -4215,7 +4220,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
             goto cleanup;
         }

-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
             goto cleanup;
     }

@@ -4280,8 +4285,8 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
-                                        &targetDef) < 0)
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf,
+                                        vm, &flags, &targetDef) < 0)
         goto cleanup;

     if (flags & VIR_DOMAIN_AFFECT_LIVE)
@@ -4437,7 +4442,8 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags, &def) < 0)
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf,
+                                        vm, &flags, &def) < 0)
         goto cleanup;

     if (flags & VIR_DOMAIN_AFFECT_LIVE) {
@@ -4749,14 +4755,14 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
         header.was_running = state;

     /* Create a domain from this XML */
-    if (!(def = virDomainDefParseString(caps, xml,
+    if (!(def = virDomainDefParseString(caps, driver->xmlconf, xml,
                                         QEMU_EXPECTED_VIRT_TYPES,
                                         VIR_DOMAIN_XML_INACTIVE)))
         goto error;
     if (xmlin) {
         virDomainDefPtr def2 = NULL;

-        if (!(def2 = virDomainDefParseString(caps, xmlin,
+        if (!(def2 = virDomainDefParseString(caps, driver->xmlconf, xmlin,
                                              QEMU_EXPECTED_VIRT_TYPES,
                                              VIR_DOMAIN_XML_INACTIVE)))
             goto error;
@@ -4801,10 +4807,6 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
     virCommandPtr cmd = NULL;
     char *errbuf = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     if ((header->version == 2) &&
         (header->compressed != QEMU_SAVE_FORMAT_RAW)) {
@@ -4876,7 +4878,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
                                "%s", _("failed to resume domain"));
             goto cleanup;
         }
-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             VIR_WARN("Failed to save status on vm %s", vm->def->name);
             goto cleanup;
         }
@@ -4898,7 +4900,6 @@ cleanup:
     if (virSecurityManagerRestoreSavedStateLabel(driver->securityManager,
                                                  vm->def, path) < 0)
         VIR_WARN("failed to restore save state label on %s", path);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return ret;
 }
@@ -4917,7 +4918,6 @@ qemuDomainRestoreFlags(virConnectPtr conn,
     virQEMUSaveHeader header;
     virFileWrapperFdPtr wrapperFd = NULL;
     int state = -1;
-    virCapsPtr caps = NULL;

     virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE |
                   VIR_DOMAIN_SAVE_RUNNING |
@@ -4929,9 +4929,6 @@ qemuDomainRestoreFlags(virConnectPtr conn,
     else if (flags & VIR_DOMAIN_SAVE_PAUSED)
         state = 0;

-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;
-
     fd = qemuDomainSaveImageOpen(driver, path, &def, &header,
                                  (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) != 0,
                                  &wrapperFd, dxml, state, false, false);
@@ -4939,7 +4936,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
         goto cleanup;

     if (!(vm = virDomainObjListAdd(driver->domains,
-                                   caps,
+                                   driver->xmlconf,
                                    def,
                                    VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
                                    VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
@@ -4968,7 +4965,6 @@ cleanup:
     virFileWrapperFdFree(wrapperFd);
     if (vm)
         virObjectUnlock(vm);
-    virObjectUnref(caps);
     return ret;
 }

@@ -5221,7 +5217,7 @@ static char *qemuDomainXMLFromNative(virConnectPtr conn,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    def = qemuParseCommandLineString(caps, config,
+    def = qemuParseCommandLineString(caps, driver->xmlconf, config,
                                      NULL, NULL, NULL);
     if (!def)
         goto cleanup;
@@ -5269,7 +5265,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    def = virDomainDefParseString(caps, xmlData,
+    def = virDomainDefParseString(caps, driver->xmlconf, xmlData,
                                   QEMU_EXPECTED_VIRT_TYPES, 0);
     if (!def)
         goto cleanup;
@@ -5540,7 +5536,7 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) {
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (!(def = virDomainDefParseString(caps, xml,
+    if (!(def = virDomainDefParseString(caps, driver->xmlconf, xml,
                                         QEMU_EXPECTED_VIRT_TYPES,
                                         VIR_DOMAIN_XML_INACTIVE)))
         goto cleanup;
@@ -5558,7 +5554,7 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) {
         goto cleanup;

     if (!(vm = virDomainObjListAdd(driver->domains,
-                                   caps,
+                                   driver->xmlconf,
                                    def,
                                    0,
                                    &oldDef)))
@@ -6479,7 +6475,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
             goto endjob;

         /* Make a copy for updated domain. */
-        vmdef = virDomainObjCopyPersistentDef(caps, vm);
+        vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlconf, vm);
         if (!vmdef)
             goto endjob;
         switch (action) {
@@ -6530,7 +6526,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
          * changed even if we failed to attach the device. For example,
          * a new controller may be created.
          */
-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             ret = -1;
             goto endjob;
         }
@@ -6907,7 +6903,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -7072,7 +7068,7 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
         goto cleanup;
     }

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -7261,7 +7257,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -7391,7 +7387,7 @@ qemuDomainGetMemoryParameters(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -7557,7 +7553,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -7710,7 +7706,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -7920,13 +7916,13 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &vmdef) < 0)
         goto cleanup;

     if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
         /* Make a copy for updated domain. */
-        vmdef = virDomainObjCopyPersistentDef(caps, vm);
+        vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlconf, vm);
         if (!vmdef)
             goto cleanup;
     }
@@ -8021,7 +8017,7 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
         }
     }

-    if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
         goto cleanup;


@@ -8206,7 +8202,7 @@ qemuGetSchedulerParametersFlags(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -8742,7 +8738,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -8908,7 +8904,7 @@ qemuDomainGetInterfaceParameters(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -11213,10 +11209,6 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
     bool reuse = (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
     virCgroupPtr cgroup = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     if (!virDomainObjIsActive(vm)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
@@ -11311,11 +11303,10 @@ cleanup:
     virCgroupFree(&cgroup);

     if (ret == 0 || !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACTION)) {
-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0 ||
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0 ||
             (persist && virDomainSaveConfig(cfg->configDir, vm->newDef) < 0))
             ret = -1;
     }
-    virObjectUnref(caps);
     virObjectUnref(cfg);

     return ret;
@@ -11580,7 +11571,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
         !virDomainObjIsActive(vm))
         parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE;

-    if (!(def = virDomainSnapshotDefParseString(xmlDesc, caps,
+    if (!(def = virDomainSnapshotDefParseString(xmlDesc, caps, driver->xmlconf,
                                                 QEMU_EXPECTED_VIRT_TYPES,
                                                 parse_flags)))
         goto cleanup;
@@ -11756,7 +11747,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
         /* Easiest way to clone inactive portion of vm->def is via
          * conversion in and back out of xml.  */
         if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)) ||
-            !(def->dom = virDomainDefParseString(caps, xml,
+            !(def->dom = virDomainDefParseString(caps, driver->xmlconf, xml,
                                                  QEMU_EXPECTED_VIRT_TYPES,
                                                  VIR_DOMAIN_XML_INACTIVE)))
             goto cleanup;
@@ -12327,7 +12318,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
      * than inactive xml?  */
     snap->def->current = true;
     if (snap->def->dom) {
-        config = virDomainDefCopy(caps, snap->def->dom, true);
+        config = virDomainDefCopy(caps, driver->xmlconf, snap->def->dom, true);
         if (!config)
             goto cleanup;
     }
@@ -12787,7 +12778,7 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (!(def = qemuParseCommandLinePid(caps, pid,
+    if (!(def = qemuParseCommandLinePid(caps, driver->xmlconf, pid,
                                         &pidfile, &monConfig, &monJSON)))
         goto cleanup;

@@ -12821,7 +12812,7 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn,
         goto cleanup;

     if (!(vm = virDomainObjListAdd(driver->domains,
-                                   caps,
+                                   driver->xmlconf,
                                    def,
                                    VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
                                    VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
@@ -13901,7 +13892,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto endjob;

@@ -14061,7 +14052,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto endjob;

@@ -14250,7 +14241,7 @@ qemuDomainSetMetadata(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
                                         &persistentDef) < 0)
         goto cleanup;

@@ -14347,7 +14338,7 @@ qemuDomainGetMetadata(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, vm, &flags, &def) < 0)
+    if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, &def) < 0)
         goto cleanup;

     /* use correct domain definition according to flags */
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 4c6d7e1..537b834 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -919,7 +919,8 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
                            n);
             goto error;
         }
-        mig->persistent = virDomainDefParseNode(caps, doc, nodes[0],
+        mig->persistent = virDomainDefParseNode(caps, driver->xmlconf,
+                                                doc, nodes[0],
                                                 -1, VIR_DOMAIN_XML_INACTIVE);
         if (!mig->persistent) {
             /* virDomainDefParseNode already reported
@@ -1923,7 +1924,7 @@ char *qemuMigrationBegin(virQEMUDriverPtr driver,
     }

     if (xmlin) {
-        if (!(def = virDomainDefParseString(caps, xmlin,
+        if (!(def = virDomainDefParseString(caps, driver->xmlconf, xmlin,
                                             QEMU_EXPECTED_VIRT_TYPES,
                                             VIR_DOMAIN_XML_INACTIVE)))
             goto cleanup;
@@ -2025,7 +2026,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (!(def = virDomainDefParseString(caps, dom_xml,
+    if (!(def = virDomainDefParseString(caps, driver->xmlconf, dom_xml,
                                         QEMU_EXPECTED_VIRT_TYPES,
                                         VIR_DOMAIN_XML_INACTIVE)))
         goto cleanup;
@@ -2066,7 +2067,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
                 virDomainDefPtr newdef;

                 VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout);
-                newdef = virDomainDefParseString(caps, xmlout,
+                newdef = virDomainDefParseString(caps, driver->xmlconf, xmlout,
                                                  QEMU_EXPECTED_VIRT_TYPES,
                                                  VIR_DOMAIN_XML_INACTIVE);
                 if (!newdef)
@@ -2084,7 +2085,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
     }

     if (!(vm = virDomainObjListAdd(driver->domains,
-                                   caps,
+                                   driver->xmlconf,
                                    def,
                                    VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
                                    VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
@@ -3883,7 +3884,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
             if (mig->persistent)
                 vm->newDef = vmdef = mig->persistent;
             else
-                vmdef = virDomainObjGetPersistentDef(caps, vm);
+                vmdef = virDomainObjGetPersistentDef(caps, driver->xmlconf, vm);
             if (!vmdef || virDomainSaveConfig(cfg->configDir, vmdef) < 0) {
                 /* Hmpf.  Migration was successful, but making it persistent
                  * was not.  If we report successful, then when this domain
@@ -3978,7 +3979,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
         }

         if (virDomainObjIsActive(vm) &&
-            virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+            virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             VIR_WARN("Failed to save status on vm %s", vm->def->name);
             goto endjob;
         }
@@ -4035,7 +4036,6 @@ int qemuMigrationConfirm(virQEMUDriverPtr driver,
     virDomainEventPtr event = NULL;
     int rv = -1;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;

     VIR_DEBUG("driver=%p, conn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
               "flags=%x, retcode=%d",
@@ -4044,9 +4044,6 @@ int qemuMigrationConfirm(virQEMUDriverPtr driver,

     virCheckFlags(QEMU_MIGRATION_FLAGS, -1);

-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;
-
     qemuMigrationJobSetPhase(driver, vm,
                              retcode == 0
                              ? QEMU_MIGRATION_PHASE_CONFIRM3
@@ -4090,7 +4087,7 @@ int qemuMigrationConfirm(virQEMUDriverPtr driver,
         event = virDomainEventNewFromObj(vm,
                                          VIR_DOMAIN_EVENT_RESUMED,
                                          VIR_DOMAIN_EVENT_RESUMED_MIGRATED);
-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             VIR_WARN("Failed to save status on vm %s", vm->def->name);
             goto cleanup;
         }
@@ -4103,7 +4100,6 @@ done:
 cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return rv;
 }
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9f1507a..8796269 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -641,13 +641,9 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     qemuDomainObjPrivatePtr priv;
     virDomainEventPtr event = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;

     VIR_DEBUG("vm=%p", vm);

-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;
-
     virObjectLock(vm);

     priv = vm->privateData;
@@ -671,7 +667,7 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
                                      VIR_DOMAIN_EVENT_SHUTDOWN,
                                      VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED);

-    if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
         VIR_WARN("Unable to save status on vm %s after state change",
                  vm->def->name);
     }
@@ -683,10 +679,8 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,

 unlock:
     virObjectUnlock(vm);
-cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
-    virObjectUnref(caps);
     virObjectUnref(cfg);

     return 0;
@@ -700,10 +694,6 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virQEMUDriverPtr driver = qemu_driver;
     virDomainEventPtr event = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     virObjectLock(vm);
     if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
@@ -727,7 +717,7 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
             VIR_WARN("Unable to release lease on %s", vm->def->name);
         VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));

-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             VIR_WARN("Unable to save status on vm %s after state change",
                      vm->def->name);
         }
@@ -735,11 +725,8 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED,

 unlock:
     virObjectUnlock(vm);
-
-cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
-    virObjectUnref(caps);
     virObjectUnref(cfg);

     return 0;
@@ -753,10 +740,6 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virQEMUDriverPtr driver = qemu_driver;
     virDomainEventPtr event = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     virObjectLock(vm);
     if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
@@ -787,7 +770,7 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
         }
         VIR_FREE(priv->lockState);

-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             VIR_WARN("Unable to save status on vm %s after state change",
                      vm->def->name);
         }
@@ -795,10 +778,8 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,

 unlock:
     virObjectUnlock(vm);
-cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return 0;
 }
@@ -812,10 +793,6 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virQEMUDriverPtr driver = qemu_driver;
     virDomainEventPtr event = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     virObjectLock(vm);
     event = virDomainEventRTCChangeNewFromObj(vm, offset);
@@ -823,15 +800,13 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     if (vm->def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE)
         vm->def->clock.data.variable.adjustment = offset;

-    if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
         VIR_WARN("unable to save domain status with RTC change");

     virObjectUnlock(vm);

-cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return 0;
 }
@@ -846,10 +821,6 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr watchdogEvent = NULL;
     virDomainEventPtr lifecycleEvent = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     virObjectLock(vm);
     watchdogEvent = virDomainEventWatchdogNewFromObj(vm, action);
@@ -869,7 +840,7 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
             VIR_WARN("Unable to release lease on %s", vm->def->name);
         VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));

-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             VIR_WARN("Unable to save status on vm %s after watchdog event",
                      vm->def->name);
         }
@@ -896,14 +867,11 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,

     if (vm)
         virObjectUnlock(vm);
-
-cleanup:
     if (watchdogEvent)
         qemuDomainEventQueue(driver, watchdogEvent);
     if (lifecycleEvent)
         qemuDomainEventQueue(driver, lifecycleEvent);

-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return 0;
 }
@@ -924,10 +892,6 @@ qemuProcessHandleIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     const char *devAlias;
     virDomainDiskDefPtr disk;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     virObjectLock(vm);
     disk = qemuProcessFindDomainDiskByAlias(vm, diskAlias);
@@ -958,19 +922,17 @@ qemuProcessHandleIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
             VIR_WARN("Unable to release lease on %s", vm->def->name);
         VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));

-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
             VIR_WARN("Unable to save status on vm %s after IO error", vm->def->name);
     }
     virObjectUnlock(vm);

-cleanup:
     if (ioErrorEvent)
         qemuDomainEventQueue(driver, ioErrorEvent);
     if (ioErrorEvent2)
         qemuDomainEventQueue(driver, ioErrorEvent2);
     if (lifecycleEvent)
         qemuDomainEventQueue(driver, lifecycleEvent);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return 0;
 }
@@ -1121,10 +1083,6 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr event = NULL;
     virDomainDiskDefPtr disk;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     virObjectLock(vm);
     disk = qemuProcessFindDomainDiskByAlias(vm, devAlias);
@@ -1139,17 +1097,15 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
         else if (reason == VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE)
             disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED;

-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             VIR_WARN("Unable to save status on vm %s after tray moved event",
                      vm->def->name);
         }
     }

     virObjectUnlock(vm);
-cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return 0;
 }
@@ -1162,10 +1118,6 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr event = NULL;
     virDomainEventPtr lifecycleEvent = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     virObjectLock(vm);
     event = virDomainEventPMWakeupNewFromObj(vm);
@@ -1183,20 +1135,17 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
                                                   VIR_DOMAIN_EVENT_STARTED,
                                                   VIR_DOMAIN_EVENT_STARTED_WAKEUP);

-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             VIR_WARN("Unable to save status on vm %s after wakeup event",
                      vm->def->name);
         }
     }

     virObjectUnlock(vm);
-
-cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
     if (lifecycleEvent)
         qemuDomainEventQueue(driver, lifecycleEvent);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return 0;
 }
@@ -1209,10 +1158,6 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr event = NULL;
     virDomainEventPtr lifecycleEvent = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     virObjectLock(vm);
     event = virDomainEventPMSuspendNewFromObj(vm);
@@ -1229,7 +1174,7 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
                                      VIR_DOMAIN_EVENT_PMSUSPENDED,
                                      VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY);

-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             VIR_WARN("Unable to save status on vm %s after suspend event",
                      vm->def->name);
         }
@@ -1240,12 +1185,10 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED,

     virObjectUnlock(vm);

-cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
     if (lifecycleEvent)
         qemuDomainEventQueue(driver, lifecycleEvent);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return 0;
 }
@@ -1258,10 +1201,6 @@ qemuProcessHandleBalloonChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virQEMUDriverPtr driver = qemu_driver;
     virDomainEventPtr event = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     virObjectLock(vm);
     event = virDomainEventBalloonChangeNewFromObj(vm, actual);
@@ -1270,15 +1209,13 @@ qemuProcessHandleBalloonChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
               vm->def->mem.cur_balloon, actual);
     vm->def->mem.cur_balloon = actual;

-    if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
         VIR_WARN("unable to save domain status with balloon change");

     virObjectUnlock(vm);

-cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return 0;
 }
@@ -1291,10 +1228,6 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainEventPtr event = NULL;
     virDomainEventPtr lifecycleEvent = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virCapsPtr caps = NULL;
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;

     virObjectLock(vm);
     event = virDomainEventPMSuspendDiskNewFromObj(vm);
@@ -1311,7 +1244,7 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
                                      VIR_DOMAIN_EVENT_PMSUSPENDED,
                                      VIR_DOMAIN_EVENT_PMSUSPENDED_DISK);

-        if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+        if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
             VIR_WARN("Unable to save status on vm %s after suspend event",
                      vm->def->name);
         }
@@ -1322,12 +1255,10 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,

     virObjectUnlock(vm);

-cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
     if (lifecycleEvent)
         qemuDomainEventQueue(driver, lifecycleEvent);
-    virObjectUnref(caps);
     virObjectUnref(cfg);

     return 0;
@@ -3188,7 +3119,6 @@ qemuProcessReconnect(void *opaque)
     int state;
     int reason;
     virQEMUDriverConfigPtr cfg;
-    virCapsPtr caps = NULL;
     size_t i;

     memcpy(&oldjob, &data->oldjob, sizeof(oldjob));
@@ -3209,9 +3139,6 @@ qemuProcessReconnect(void *opaque)
      * deleted if qemuConnectMonitor() failed */
     virObjectRef(obj);

-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto error;
-
     /* XXX check PID liveliness & EXE path */
     if (qemuConnectMonitor(driver, obj) < 0)
         goto error;
@@ -3291,7 +3218,7 @@ qemuProcessReconnect(void *opaque)
         goto error;

     /* update domain state XML with possibly updated state in virDomainObj */
-    if (virDomainSaveStatus(caps, cfg->stateDir, obj) < 0)
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, obj) < 0)
         goto error;

     /* Run an hook to allow admins to do some magic */
@@ -3323,7 +3250,6 @@ endjob:

     virConnectClose(conn);
     virObjectUnref(cfg);
-    virObjectUnref(caps);

     return;

@@ -3361,7 +3287,6 @@ error:
         }
     }
     virConnectClose(conn);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
 }

@@ -3548,7 +3473,7 @@ int qemuProcessStart(virConnectPtr conn,
      * report implicit runtime defaults in the XML, like vnc listen/socket
      */
     VIR_DEBUG("Setting current domain def as transient");
-    if (virDomainObjSetDefTransient(caps, vm, true) < 0)
+    if (virDomainObjSetDefTransient(caps, driver->xmlconf, vm, true) < 0)
         goto cleanup;

     vm->def->id = qemuDriverAllocateID(driver);
@@ -3897,7 +3822,7 @@ int qemuProcessStart(virConnectPtr conn,
     }

     VIR_DEBUG("Writing early domain status to disk");
-    if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
         goto cleanup;
     }

@@ -4048,7 +3973,7 @@ int qemuProcessStart(virConnectPtr conn,
         goto cleanup;

     VIR_DEBUG("Writing domain status to disk");
-    if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
         goto cleanup;

     /* finally we can call the 'started' hook script if any */
@@ -4403,7 +4328,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
      * report implicit runtime defaults in the XML, like vnc listen/socket
      */
     VIR_DEBUG("Setting current domain def as transient");
-    if (virDomainObjSetDefTransient(caps, vm, true) < 0)
+    if (virDomainObjSetDefTransient(caps, driver->xmlconf, vm, true) < 0)
         goto cleanup;

     vm->def->id = qemuDriverAllocateID(driver);
@@ -4547,7 +4472,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
         virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, reason);

     VIR_DEBUG("Writing domain status to disk");
-    if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
+    if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
         goto cleanup;

     /* Run an hook to allow admins to do some magic */
-- 
1.8.1.1


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