[libvirt RFCv11 31/33] qemu: saveimage: implement multifd-compression in parallel save

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

 



Signed-off-by: Claudio Fontana <cfontana@xxxxxxx>
---
 src/qemu/qemu_migration.c | 17 +++++++++++++----
 src/qemu/qemu_migration.h |  2 +-
 src/qemu/qemu_saveimage.c | 15 ++++++++++++---
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index c214f88dd1..5127dc07fe 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -5884,7 +5884,7 @@ qemuMigrationSrcToFileAux(virQEMUDriver *driver, virDomainObj *vm,
                           virCommand *compressor,
                           virDomainAsyncJob asyncJob,
                           const char *sun_path,
-                          int nchannels)
+                          int nchannels, const char *pcomp)
 {
     qemuDomainObjPrivate *priv = vm->privateData;
     bool bwParam = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH);
@@ -5931,6 +5931,15 @@ qemuMigrationSrcToFileAux(virQEMUDriver *driver, virDomainObj *vm,
                                       QEMU_MIGRATION_PARAM_MULTIFD_CHANNELS,
                                       nchannels) < 0)
             return -1;
+        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_MULTIFD_COMPRESSION)) {
+            if (qemuMigrationParamsSetString(migParams,
+                                             QEMU_MIGRATION_PARAM_MULTIFD_COMPRESSION, pcomp) < 0)
+                return -1;
+        } else {
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                           _("QEMU does not seem to support multifd compression"));
+            return -1;
+        }
     }
 
     if (needParams && qemuMigrationParamsApply(driver, vm, asyncJob, migParams) < 0)
@@ -6056,17 +6065,17 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm,
                        virDomainAsyncJob asyncJob)
 {
     return qemuMigrationSrcToFileAux(driver, vm, fd, compressor,
-                                     asyncJob, NULL, -1);
+                                     asyncJob, NULL, -1, NULL);
 }
 
 int
 qemuMigrationSrcToFilesMultiFd(virQEMUDriver *driver, virDomainObj *vm,
                                virDomainAsyncJob asyncJob,
                                const char *sun_path,
-                               int nchannels)
+                               int nchannels, const char *pcomp)
 {
     return qemuMigrationSrcToFileAux(driver, vm, -1, NULL,
-                                     asyncJob, sun_path, nchannels);
+                                     asyncJob, sun_path, nchannels, pcomp);
 }
 
 int
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 38f4877cf0..d6185770b2 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -223,7 +223,7 @@ int
 qemuMigrationSrcToFilesMultiFd(virQEMUDriver *driver, virDomainObj *vm,
                                virDomainAsyncJob asyncJob,
                                const char *sun_path,
-                               int nchannels)
+                               int nchannels, const char *pcomp)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
 
 int
diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c
index 505d9b615f..f60040ef25 100644
--- a/src/qemu/qemu_saveimage.c
+++ b/src/qemu/qemu_saveimage.c
@@ -561,12 +561,13 @@ qemuSaveImageCreate(virQEMUDriver *driver,
                     virQEMUSaveData *data,
                     virCommand *compressor,
                     int nconn,
-                    const char *pcomp G_GNUC_UNUSED,
+                    const char *pcomp,
                     unsigned int flags,
                     virDomainAsyncJob asyncJob)
 {
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
     virQEMUSaveFd saveFd = QEMU_SAVEFD_INVALID;
+    virQEMUSaveMultiFdComp multiComp = QEMU_SAVE_MULTIFD_COMP_NONE;
     unsigned int oflags = O_WRONLY | O_TRUNC | O_CREAT;
     int ret = -1;
 
@@ -578,11 +579,19 @@ qemuSaveImageCreate(virQEMUDriver *driver,
         }
         oflags |= O_DIRECT;
     }
-
+    if (!pcomp || !pcomp[0]) {
+        pcomp = qemuSaveMultiFdCompTypeToString(QEMU_SAVE_MULTIFD_COMP_NONE);
+    }
     if (virQEMUSaveFdInit(&saveFd, path, oflags, cfg, flags & VIR_DOMAIN_SAVE_PARALLEL) < 0)
         goto cleanup;
     if (nconn > 0) {
         data->header.multifd_channels = nconn;
+        if ((multiComp = qemuSaveMultiFdCompTypeFromString(pcomp)) < 0) {
+            virReportError(VIR_ERR_OPERATION_FAILED,
+                           _("Invalid %s multifd compression format specified"), pcomp);
+            goto cleanup;
+        }
+        data->header.multifd_comp = multiComp;
     }
     if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, saveFd.fd) < 0)
         goto cleanup;
@@ -614,7 +623,7 @@ qemuSaveImageCreate(virQEMUDriver *driver,
             goto cleanup;
         if (chown(sun_path, cfg->user, cfg->group) < 0)
             goto cleanup;
-        if (qemuMigrationSrcToFilesMultiFd(driver, vm, asyncJob, sun_path, nconn) < 0)
+        if (qemuMigrationSrcToFilesMultiFd(driver, vm, asyncJob, sun_path, nconn, pcomp) < 0)
             goto cleanup;
     } else {
         /* Perform non-parallel migration to file */
-- 
2.26.2





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

  Powered by Linux