[PATCH 3/3] Make QEMU migration use cached qemu capabilities data

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

 



* src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Remove
  qemuCaps parameters & use cached data
* src/qemu/qemu_driver.c: Don't create & pass qemuCaps to
  migration methods
---
 src/qemu/qemu_driver.c    |   11 ++---------
 src/qemu/qemu_migration.c |   32 ++++++--------------------------
 src/qemu/qemu_migration.h |    1 -
 3 files changed, 8 insertions(+), 36 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b214e44..f033ea3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1878,7 +1878,6 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
     struct stat sb;
     bool is_reg = false;
     unsigned long long offset;
-    virBitmapPtr qemuCaps = NULL;
     int fd = -1;
 
     memset(&header, 0, sizeof(header));
@@ -1910,11 +1909,6 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
         }
     }
 
-    if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
-                                   NULL,
-                                   &qemuCaps) < 0)
-        goto endjob;
-
     /* Get XML for the domain */
     xml = virDomainDefFormat(vm->def, VIR_DOMAIN_XML_SECURE);
     if (!xml) {
@@ -2040,7 +2034,7 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
     }
 
     /* Perform the migration */
-    if (qemuMigrationToFile(driver, vm, qemuCaps, fd, offset, path,
+    if (qemuMigrationToFile(driver, vm, fd, offset, path,
                             qemuCompressProgramName(compressed),
                             is_reg, bypassSecurityDriver) < 0)
         goto endjob;
@@ -2078,7 +2072,6 @@ endjob:
     }
 
 cleanup:
-    qemuCapsFree(qemuCaps);
     VIR_FORCE_CLOSE(fd);
     VIR_FREE(xml);
     if (ret != 0 && is_reg)
@@ -2296,7 +2289,7 @@ static int doCoreDump(struct qemud_driver *driver,
         goto cleanup;
     }
 
-    if (qemuMigrationToFile(driver, vm, NULL, fd, 0, path,
+    if (qemuMigrationToFile(driver, vm, fd, 0, path,
                             qemuCompressProgramName(compress), true, false) < 0)
         goto cleanup;
 
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 7f4b111..670c4a6 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -255,7 +255,6 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
     int ret = -1;
     int internalret;
     int dataFD[2] = { -1, -1 };
-    virBitmapPtr qemuCaps = NULL;
     qemuDomainObjPrivatePtr priv = NULL;
     struct timeval now;
 
@@ -307,14 +306,6 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
         goto endjob;
     }
 
-    /* check that this qemu version supports the interactive exec */
-    if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
-                                   NULL, &qemuCaps) < 0) {
-        qemuReportError(VIR_ERR_INTERNAL_ERROR,
-                        _("Cannot determine QEMU argv syntax %s"),
-                        vm->def->emulator);
-        goto endjob;
-    }
     /* Start the QEMU daemon, with the same command-line arguments plus
      * -incoming stdio (which qemu_command might convert to exec:cat or fd:n)
      */
@@ -371,7 +362,6 @@ endjob:
     }
 
 cleanup:
-    qemuCapsFree(qemuCaps);
     virDomainDefFree(def);
     VIR_FORCE_CLOSE(dataFD[0]);
     VIR_FORCE_CLOSE(dataFD[1]);
@@ -703,7 +693,6 @@ static int doTunnelMigrate(struct qemud_driver *driver,
     virStreamPtr st = NULL;
     char *unixfile = NULL;
     int internalret;
-    virBitmapPtr qemuCaps = NULL;
     int status;
     unsigned long long transferred, remaining, total;
     unsigned int background_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
@@ -764,16 +753,9 @@ static int doTunnelMigrate(struct qemud_driver *driver,
     }
 
     /* check that this qemu version supports the unix migration */
-    if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
-                                   NULL, &qemuCaps) < 0) {
-        qemuReportError(VIR_ERR_INTERNAL_ERROR,
-                        _("Cannot extract Qemu version from '%s'"),
-                        vm->def->emulator);
-        goto cleanup;
-    }
 
-    if (!qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX) &&
-        !qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
+    if (!qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX) &&
+        !qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
         qemuReportError(VIR_ERR_OPERATION_FAILED,
                         "%s", _("Source qemu is too old to support tunnelled migration"));
         goto cleanup;
@@ -815,11 +797,11 @@ static int doTunnelMigrate(struct qemud_driver *driver,
         background_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_DISK;
     if (flags & VIR_MIGRATE_NON_SHARED_INC)
         background_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_INC;
-    if (qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX)) {
+    if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX)) {
         internalret = qemuMonitorMigrateToUnix(priv->mon, background_flags,
                                                unixfile);
     }
-    else if (qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
+    else if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
         const char *args[] = { "nc", "-U", unixfile, NULL };
         internalret = qemuMonitorMigrateToCommand(priv->mon, QEMU_MONITOR_MIGRATE_BACKGROUND, args);
     } else {
@@ -889,7 +871,6 @@ finish:
 cleanup:
     VIR_FORCE_CLOSE(client_sock);
     VIR_FORCE_CLOSE(qemu_sock);
-    qemuCapsFree(qemuCaps);
 
     if (ddomain)
         virUnrefDomain(ddomain);
@@ -1289,7 +1270,6 @@ cleanup:
 /* Helper function called while driver lock is held and vm is active.  */
 int
 qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
-                    virBitmapPtr qemuCaps,
                     int fd, off_t offset, const char *path,
                     const char *compressor,
                     bool is_reg, bool bypassSecurityDriver)
@@ -1302,7 +1282,7 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
     virCommandPtr cmd = NULL;
     int pipeFD[2] = { -1, -1 };
 
-    if (qemuCaps && qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
+    if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
         (!compressor || pipe(pipeFD) == 0)) {
         /* All right! We can use fd migration, which means that qemu
          * doesn't have to open() the file, so while we still have to
@@ -1349,7 +1329,7 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
     if (!compressor) {
         const char *args[] = { "cat", NULL };
 
-        if (qemuCaps && qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
+        if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
             priv->monConfig->type == VIR_DOMAIN_CHR_TYPE_UNIX) {
             rc = qemuMonitorMigrateToFd(priv->mon,
                                         QEMU_MONITOR_MIGRATE_BACKGROUND,
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index db16ce4..f4e86c8 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -61,7 +61,6 @@ virDomainPtr qemuMigrationFinish(struct qemud_driver *driver,
 
 
 int qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
-                        virBitmapPtr qemuCaps,
                         int fd, off_t offset, const char *path,
                         const char *compressor,
                         bool is_reg, bool bypassSecurityDriver)
-- 
1.7.4.4

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