[libvirt RFC v2 03/11] qemu: add a stub for virDomainSaveParametersFlags API

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

 



Signed-off-by: Claudio Fontana <cfontana@xxxxxxx>
---
 src/qemu/qemu_driver.c    | 66 ++++++++++++++++++++++++++++++++++++---
 src/qemu/qemu_saveimage.c |  2 ++
 src/qemu/qemu_saveimage.h |  1 +
 src/qemu/qemu_snapshot.c  |  2 +-
 4 files changed, 66 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 77012eb527..cfc68e3135 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2631,7 +2631,7 @@ static int
 qemuDomainSaveInternal(virQEMUDriver *driver,
                        virDomainObj *vm, const char *path,
                        int compressed, virCommand *compressor,
-                       const char *xmlin, unsigned int flags)
+                       const char *xmlin, int nconn, unsigned int flags)
 {
     g_autofree char *xml = NULL;
     bool was_running = false;
@@ -2712,7 +2712,7 @@ qemuDomainSaveInternal(virQEMUDriver *driver,
     xml = NULL;
 
     ret = qemuSaveImageCreate(driver, vm, path, data, compressor,
-                              flags, VIR_ASYNC_JOB_SAVE);
+                              nconn, flags, VIR_ASYNC_JOB_SAVE);
     if (ret < 0)
         goto endjob;
 
@@ -2781,7 +2781,7 @@ qemuDomainSaveFlags(virDomainPtr dom, const char *path, const char *dxml,
         goto cleanup;
 
     ret = qemuDomainSaveInternal(driver, vm, path, compressed,
-                                 compressor, dxml, flags);
+                                 compressor, dxml, 0, flags);
 
  cleanup:
     virDomainObjEndAPI(&vm);
@@ -2794,6 +2794,63 @@ qemuDomainSave(virDomainPtr dom, const char *path)
     return qemuDomainSaveFlags(dom, path, NULL, 0);
 }
 
+static int
+qemuDomainSaveParametersFlags(virDomainPtr dom,
+                              virTypedParameterPtr params, int nparams,
+                              unsigned int flags)
+{
+    const char *to = NULL;
+    const char *dxml = NULL;
+    virQEMUDriver *driver = dom->conn->privateData;
+    int compressed;
+    g_autoptr(virCommand) compressor = NULL;
+    int ret = -1;
+    int nconn = 0;
+    virDomainObj *vm = NULL;
+    g_autoptr(virQEMUDriverConfig) cfg = NULL;
+
+    virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE |
+                  VIR_DOMAIN_SAVE_RUNNING |
+                  VIR_DOMAIN_SAVE_PAUSED |
+                  VIR_DOMAIN_SAVE_PARALLEL, -1);
+
+    if (virTypedParamsValidate(params, nparams,
+                               VIR_SAVE_PARAM_TO, VIR_TYPED_PARAM_STRING,
+                               VIR_SAVE_PARAM_DXML, VIR_TYPED_PARAM_STRING,
+                               VIR_SAVE_PARAM_PARALLEL_CONNECTIONS, VIR_TYPED_PARAM_INT,
+                               NULL) < 0)
+        return -1;
+
+    if (virTypedParamsGetString(params, nparams, VIR_SAVE_PARAM_TO, &to) < 0)
+        return -1;
+    if (virTypedParamsGetString(params, nparams, VIR_SAVE_PARAM_DXML, &dxml) < 0)
+        return -1;
+    if (virTypedParamsGetInt(params, nparams, VIR_SAVE_PARAM_PARALLEL_CONNECTIONS, &nconn) < 0)
+        return -1;
+
+    cfg = virQEMUDriverGetConfig(driver);
+    if ((compressed = qemuSaveImageGetCompressionProgram(cfg->saveImageFormat,
+                                                         &compressor,
+                                                         "save", false)) < 0)
+        goto cleanup;
+
+    if (!(vm = qemuDomainObjFromDomain(dom)))
+        goto cleanup;
+
+    if (virDomainSaveFlagsEnsureACL(dom->conn, vm->def) < 0)
+        goto cleanup;
+
+    if (virDomainObjCheckActive(vm) < 0)
+        goto cleanup;
+
+    ret = qemuDomainSaveInternal(driver, vm, to, compressed,
+                                 compressor, dxml, nconn, flags);
+
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
+
 static char *
 qemuDomainManagedSavePath(virQEMUDriver *driver, virDomainObj *vm)
 {
@@ -2844,7 +2901,7 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
     VIR_INFO("Saving state of domain '%s' to '%s'", vm->def->name, name);
 
     ret = qemuDomainSaveInternal(driver, vm, name, compressed,
-                                 compressor, NULL, flags);
+                                 compressor, NULL, 0, flags);
     if (ret == 0)
         vm->hasManagedSave = true;
 
@@ -20826,6 +20883,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
     .domainGetControlInfo = qemuDomainGetControlInfo, /* 0.9.3 */
     .domainSave = qemuDomainSave, /* 0.2.0 */
     .domainSaveFlags = qemuDomainSaveFlags, /* 0.9.4 */
+    .domainSaveParametersFlags = qemuDomainSaveParametersFlags, /* 8.3.0 */
     .domainRestore = qemuDomainRestore, /* 0.2.0 */
     .domainRestoreFlags = qemuDomainRestoreFlags, /* 0.9.4 */
     .domainSaveImageGetXMLDesc = qemuDomainSaveImageGetXMLDesc, /* 0.9.4 */
diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c
index 4fd4c5cfcd..6e7f067be2 100644
--- a/src/qemu/qemu_saveimage.c
+++ b/src/qemu/qemu_saveimage.c
@@ -258,6 +258,7 @@ qemuSaveImageCreate(virQEMUDriver *driver,
                     const char *path,
                     virQEMUSaveData *data,
                     virCommand *compressor,
+                    int nconn,
                     unsigned int flags,
                     virDomainAsyncJob asyncJob)
 {
@@ -269,6 +270,7 @@ qemuSaveImageCreate(virQEMUDriver *driver,
     virFileWrapperFd *wrapperFd = NULL;
     unsigned int wrapperFlags = VIR_FILE_WRAPPER_NON_BLOCKING;
 
+    nconn = nconn; /* unused */
     /* Obtain the file handle.  */
     if ((flags & VIR_DOMAIN_SAVE_BYPASS_CACHE)) {
         wrapperFlags |= VIR_FILE_WRAPPER_BYPASS_CACHE;
diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h
index 391cd55ed0..b3d5c02fd6 100644
--- a/src/qemu/qemu_saveimage.h
+++ b/src/qemu/qemu_saveimage.h
@@ -96,6 +96,7 @@ qemuSaveImageCreate(virQEMUDriver *driver,
                     const char *path,
                     virQEMUSaveData *data,
                     virCommand *compressor,
+                    int nconn,
                     unsigned int flags,
                     virDomainAsyncJob asyncJob);
 
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index b62fab7bb3..f4eeb9276c 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -1457,7 +1457,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *driver,
         memory_existing = virFileExists(snapdef->memorysnapshotfile);
 
         if ((ret = qemuSaveImageCreate(driver, vm, snapdef->memorysnapshotfile,
-                                       data, compressor, 0,
+                                       data, compressor, 0, 0,
                                        VIR_ASYNC_JOB_SNAPSHOT)) < 0)
             goto cleanup;
 
-- 
2.34.1





[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