[PATCH 06/12] qemu: update callers of qemuProcessStartValidate to use virDomainObjPtr

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

 



This change is required by following patches.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c   | 33 ++++++++++++++++----------------
 tests/qemuxml2argvtest.c | 49 +++++++++++++++++++++++++-----------------------
 2 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a0d6596..24fa3ec 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6949,9 +6949,9 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
                                           unsigned int flags)
 {
     virQEMUDriverPtr driver = conn->privateData;
-    virDomainDefPtr def = NULL;
     virDomainChrSourceDef monConfig;
     virQEMUCapsPtr qemuCaps = NULL;
+    virDomainObjPtr vm = NULL;
     bool monitor_json = false;
     virCommandPtr cmd = NULL;
     char *ret = NULL;
@@ -6977,22 +6977,21 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;
 
-    def = virDomainDefParseString(xmlData, caps, driver->xmlopt,
-                                  VIR_DOMAIN_DEF_PARSE_INACTIVE |
-                                  VIR_DOMAIN_DEF_PARSE_ABI_UPDATE);
-    if (!def)
+    if (!(vm = virDomainObjNew(driver->xmlopt)))
         goto cleanup;
 
-    if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator)))
+    if (!(vm->def = virDomainDefParseString(xmlData, caps, driver->xmlopt,
+                                            VIR_DOMAIN_DEF_PARSE_INACTIVE |
+                                            VIR_DOMAIN_DEF_PARSE_ABI_UPDATE)))
         goto cleanup;
 
-    if (qemuProcessStartValidate(def, qemuCaps, false, false) < 0)
+    if (qemuProcessStartValidate(driver, vm, qemuCaps, false, false) < 0)
         goto cleanup;
 
     /* Generate per-domain paths because we don't have the domain object */
     if (qemuDomainSetPrivatePaths(&domainLibDir, &domainChannelTargetDir,
                                   cfg->libDir, cfg->channelTargetDir,
-                                  def->name, -1) < 0)
+                                  vm->def->name, -1) < 0)
         goto cleanup;
 
     /* Since we're just exporting args, we can't do bridge/network/direct
@@ -7000,8 +6999,8 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
      * directly. We convert those configs into generic 'ethernet'
      * config and assume the user has suitable 'ifup-qemu' scripts
      */
-    for (i = 0; i < def->nnets; i++) {
-        virDomainNetDefPtr net = def->nets[i];
+    for (i = 0; i < vm->def->nnets; i++) {
+        virDomainNetDefPtr net = vm->def->nets[i];
         int bootIndex = net->info.bootIndex;
         char *model = net->model;
         virMacAddr mac = net->mac;
@@ -7085,18 +7084,18 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
 
     monitor_json = virQEMUCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON);
 
-    if (qemuProcessPrepareMonitorChr(&monConfig, def->name) < 0)
+    if (qemuProcessPrepareMonitorChr(&monConfig, vm->def->name) < 0)
         goto cleanup;
 
-    if (qemuAssignDeviceAliases(def, qemuCaps) < 0)
+    if (qemuAssignDeviceAliases(vm->def, qemuCaps) < 0)
         goto cleanup;
 
-    if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
+    if (qemuDomainAssignAddresses(vm->def, qemuCaps, NULL) < 0)
         goto cleanup;
 
     /* do fake auto-alloc of graphics ports, if such config is used */
-    for (i = 0; i < def->ngraphics; ++i) {
-        virDomainGraphicsDefPtr graphics = def->graphics[i];
+    for (i = 0; i < vm->def->ngraphics; ++i) {
+        virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
         if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
             !graphics->data.vnc.socket && graphics->data.vnc.autoport) {
             graphics->data.vnc.port = 5900;
@@ -7106,7 +7105,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
         }
     }
 
-    if (!(cmd = qemuBuildCommandLine(conn, driver, NULL, def,
+    if (!(cmd = qemuBuildCommandLine(conn, driver, NULL, vm->def,
                                      &monConfig, monitor_json, qemuCaps,
                                      NULL, NULL,
                                      VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
@@ -7123,7 +7122,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
  cleanup:
     virObjectUnref(qemuCaps);
     virCommandFree(cmd);
-    virDomainDefFree(def);
+    virObjectUnref(vm);
     virObjectUnref(caps);
     virObjectUnref(cfg);
     VIR_FREE(domainLibDir);
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 150a50d..135fbd5 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -258,7 +258,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 {
     char *actualargv = NULL;
     int ret = -1;
-    virDomainDefPtr vmdef = NULL;
+    virDomainObjPtr vm = NULL;
     virDomainChrSourceDef monitor_chr;
     virConnectPtr conn;
     char *log = NULL;
@@ -276,24 +276,27 @@ static int testCompareXMLToArgvFiles(const char *xml,
     if (virBitmapParse("0-3", '\0', &nodeset, 4) < 0)
         goto out;
 
-    if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
-                                        (VIR_DOMAIN_DEF_PARSE_INACTIVE |
-                                         parseFlags)))) {
+    if (!(vm = virDomainObjNew(driver.xmlopt)))
+        goto out;
+
+    if (!(vm->def = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
+                                          (VIR_DOMAIN_DEF_PARSE_INACTIVE |
+                                           parseFlags)))) {
         if (flags & FLAG_EXPECT_PARSE_ERROR)
             goto ok;
         goto out;
     }
 
-    if (!virDomainDefCheckABIStability(vmdef, vmdef)) {
+    if (!virDomainDefCheckABIStability(vm->def, vm->def)) {
         VIR_TEST_DEBUG("ABI stability check failed on %s", xml);
         goto out;
     }
 
-    vmdef->id = -1;
+    vm->def->id = -1;
 
     if (qemuDomainSetPrivatePaths(&domainLibDir, &domainChannelTargetDir,
                                   "/tmp/lib", "/tmp/channel",
-                                  vmdef->name, vmdef->id) < 0)
+                                  vm->def->name, vm->def->id) < 0)
         goto out;
 
     memset(&monitor_chr, 0, sizeof(monitor_chr));
@@ -305,16 +308,16 @@ static int testCompareXMLToArgvFiles(const char *xml,
                        QEMU_CAPS_DEVICE,
                        QEMU_CAPS_LAST);
 
-    if (STREQ(vmdef->os.machine, "pc") &&
-        STREQ(vmdef->emulator, "/usr/bin/qemu-system-x86_64")) {
-        VIR_FREE(vmdef->os.machine);
-        if (VIR_STRDUP(vmdef->os.machine, "pc-0.11") < 0)
+    if (STREQ(vm->def->os.machine, "pc") &&
+        STREQ(vm->def->emulator, "/usr/bin/qemu-system-x86_64")) {
+        VIR_FREE(vm->def->os.machine);
+        if (VIR_STRDUP(vm->def->os.machine, "pc-0.11") < 0)
             goto out;
     }
 
-    virQEMUCapsFilterByMachineType(extraFlags, vmdef->os.machine);
+    virQEMUCapsFilterByMachineType(extraFlags, vm->def->os.machine);
 
-    if (qemuDomainAssignAddresses(vmdef, extraFlags, NULL)) {
+    if (qemuDomainAssignAddresses(vm->def, extraFlags, NULL)) {
         if (flags & FLAG_EXPECT_ERROR)
             goto ok;
         goto out;
@@ -324,16 +327,16 @@ static int testCompareXMLToArgvFiles(const char *xml,
     VIR_FREE(log);
     virResetLastError();
 
-    if (vmdef->os.arch == VIR_ARCH_X86_64 ||
-        vmdef->os.arch == VIR_ARCH_I686) {
+    if (vm->def->os.arch == VIR_ARCH_X86_64 ||
+        vm->def->os.arch == VIR_ARCH_I686) {
         virQEMUCapsSet(extraFlags, QEMU_CAPS_PCI_MULTIBUS);
     }
 
-    if (qemuAssignDeviceAliases(vmdef, extraFlags) < 0)
+    if (qemuAssignDeviceAliases(vm->def, extraFlags) < 0)
         goto out;
 
-    for (i = 0; i < vmdef->nhostdevs; i++) {
-        virDomainHostdevDefPtr hostdev = vmdef->hostdevs[i];
+    for (i = 0; i < vm->def->nhostdevs; i++) {
+        virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
 
         if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
@@ -342,18 +345,18 @@ static int testCompareXMLToArgvFiles(const char *xml,
         }
     }
 
-    for (i = 0; i < vmdef->ndisks; i++) {
-        if (virStorageTranslateDiskSourcePool(conn, vmdef->disks[i]) < 0)
+    for (i = 0; i < vm->def->ndisks; i++) {
+        if (virStorageTranslateDiskSourcePool(conn, vm->def->disks[i]) < 0)
             goto out;
     }
 
-    if (qemuProcessStartValidate(vmdef, extraFlags, !!migrateURI, false) < 0) {
+    if (qemuProcessStartValidate(&driver, vm, extraFlags, !!migrateURI, false) < 0) {
         if (flags & FLAG_EXPECT_FAILURE)
             goto ok;
         goto out;
     }
 
-    if (!(cmd = qemuBuildCommandLine(conn, &driver, NULL, vmdef, &monitor_chr,
+    if (!(cmd = qemuBuildCommandLine(conn, &driver, NULL, vm->def, &monitor_chr,
                                      (flags & FLAG_JSON), extraFlags,
                                      migrateURI, NULL,
                                      VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
@@ -398,7 +401,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
     VIR_FREE(log);
     VIR_FREE(actualargv);
     virCommandFree(cmd);
-    virDomainDefFree(vmdef);
+    virObjectUnref(vm);
     virObjectUnref(conn);
     virBitmapFree(nodeset);
     VIR_FREE(domainLibDir);
-- 
2.7.2

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