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

[libvirt] [PATCH 29/35] qemu: Refactor qemuDomainChgIOThread by reusing virDomainObjGetDefs



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

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c1dca36..5a01514 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6151,32 +6151,22 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
                       unsigned int flags)
 {
     virQEMUDriverConfigPtr cfg = NULL;
-    virCapsPtr caps = NULL;
     qemuDomainObjPrivatePtr priv;
+    virDomainDefPtr def;
     virDomainDefPtr persistentDef;
     int ret = -1;

     cfg = virQEMUDriverGetConfig(driver);

-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;
-
     priv = vm->privateData;

     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) {
-        if (!virDomainObjIsActive(vm)) {
-            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                           _("cannot change IOThreads for an inactive domain"));
-            goto endjob;
-        }
-
+    if (def) {
         if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("IOThreads not supported with this binary"));
@@ -6195,7 +6185,7 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
             goto endjob;
     }

-    if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+    if (persistentDef) {
         if (add) {
             if (!virDomainIOThreadIDAdd(persistentDef, iothread_id))
                 goto endjob;
@@ -6227,7 +6217,6 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
     qemuDomainObjEndJob(driver, vm);

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


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