[PATCH 26/35] qemu: Refactor qemuDomainGetVcpusFlags by reusing virDomainObjGetDefs

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

 



---
 src/qemu/qemu_driver.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d729e6c..5969f5c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5514,8 +5514,8 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
     qemuDomainObjPrivatePtr priv;
     virDomainObjPtr vm;
     virDomainDefPtr def;
+    virDomainDefPtr persistentDef;
     int ret = -1;
-    virCapsPtr caps = NULL;
     qemuAgentCPUInfoPtr cpuinfo = NULL;
     int ncpuinfo = -1;
     size_t i;
@@ -5533,18 +5533,11 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
     if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;

-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;
-
-    if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
-                                        vm, &flags, &def) < 0)
+    if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
         goto cleanup;

-    if (flags & VIR_DOMAIN_AFFECT_LIVE)
-        def = vm->def;
-
     if (flags & VIR_DOMAIN_VCPU_GUEST) {
-        if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+        if (persistentDef) {
             virReportError(VIR_ERR_INVALID_ARG, "%s",
                            _("vCPU count provided by the guest agent can only be "
                              " requested for live domains"));
@@ -5585,6 +5578,9 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
                 ret++;
         }
     } else {
+        if (!def)
+            def = persistentDef;
+
         if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
             ret = def->maxvcpus;
         else
@@ -5594,7 +5590,6 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)

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

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