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

[libvirt] [PATCH 30/35] qemu: Refactor qemuDomainSetBlkioParameters by reusing virDomainObjGetDefs



---
 src/qemu/qemu_driver.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5a01514..e7382ea 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9197,10 +9197,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
     virQEMUDriverPtr driver = dom->conn->privateData;
     size_t i;
     virDomainObjPtr vm = NULL;
-    virDomainDefPtr persistentDef = NULL;
+    virDomainDefPtr def;
+    virDomainDefPtr persistentDef;
     int ret = -1;
     virQEMUDriverConfigPtr cfg = NULL;
-    virCapsPtr caps = NULL;
     qemuDomainObjPrivatePtr priv;

     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
@@ -9236,14 +9236,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
         goto cleanup;
     }

-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;
-
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;

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

     if (flags & VIR_DOMAIN_AFFECT_LIVE) {
@@ -9255,7 +9251,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
     }

     ret = 0;
-    if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+    if (def) {
         for (i = 0; i < nparams; i++) {
             virTypedParameterPtr param = &params[i];

@@ -9335,8 +9331,8 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
                 }

                 if (j != ndevices ||
-                    qemuDomainMergeBlkioDevice(&vm->def->blkio.devices,
-                                               &vm->def->blkio.ndevices,
+                    qemuDomainMergeBlkioDevice(&def->blkio.devices,
+                                               &def->blkio.ndevices,
                                                devices, ndevices, param->field) < 0)
                     ret = -1;
                 virBlkioDeviceArrayClear(devices, ndevices);
@@ -9349,10 +9345,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
     }
     if (ret < 0)
         goto endjob;
-    if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
-        /* Clang can't see that if we get here, persistentDef was set.  */
-        sa_assert(persistentDef);
-
+    if (persistentDef) {
         for (i = 0; i < nparams; i++) {
             virTypedParameterPtr param = &params[i];

@@ -9391,7 +9384,6 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,

  cleanup:
     virDomainObjEndAPI(&vm);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return ret;
 }
-- 
2.4.1


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