[libvirt RFC v3 04/19] libvirt: introduce virDomainRestoreParametersFlags public API

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

 



add new API in order to be able to extend parameters to the domain
restore operation. We will use it to fit the existing arguments of
VirDomainRestoreFlags, and then add parallel restore functionality.

Signed-off-by: Claudio Fontana <cfontana@xxxxxxx>
---
 include/libvirt/libvirt-domain.h |  4 +++
 src/driver-hypervisor.h          |  7 +++++
 src/libvirt-domain.c             | 48 ++++++++++++++++++++++++++++++++
 src/libvirt_public.syms          |  1 +
 4 files changed, 60 insertions(+)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 4beea34f93..3deaf78cd7 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1500,6 +1500,10 @@ int                     virDomainRestoreFlags   (virConnectPtr conn,
                                                  const char *from,
                                                  const char *dxml,
                                                  unsigned int flags);
+int                     virDomainRestoreParametersFlags (virConnectPtr conn,
+                                                         virTypedParameterPtr params,
+                                                         int nparams,
+                                                         unsigned int flags);
 
 # define VIR_SAVE_PARAM_FILE                     "file"
 # define VIR_SAVE_PARAM_DXML                     "dxml"
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index a4e1d21e76..e62e4c8f74 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -256,6 +256,12 @@ typedef int
                             const char *dxml,
                             unsigned int flags);
 
+typedef int
+(*virDrvDomainRestoreParametersFlags)(virConnectPtr conn,
+                                      virTypedParameterPtr params,
+                                      int nparams,
+                                      unsigned int flags);
+
 typedef char *
 (*virDrvDomainSaveImageGetXMLDesc)(virConnectPtr conn,
                                    const char *file,
@@ -1498,6 +1504,7 @@ struct _virHypervisorDriver {
     virDrvDomainSaveParametersFlags domainSaveParametersFlags;
     virDrvDomainRestore domainRestore;
     virDrvDomainRestoreFlags domainRestoreFlags;
+    virDrvDomainRestoreParametersFlags domainRestoreParametersFlags;
     virDrvDomainSaveImageGetXMLDesc domainSaveImageGetXMLDesc;
     virDrvDomainSaveImageDefineXML domainSaveImageDefineXML;
     virDrvDomainCoreDump domainCoreDump;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 9e4fcfd022..f967efa473 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -1140,6 +1140,54 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,
 }
 
 
+/**
+ * virDomainRestoreParametersFlags:
+ * @conn: pointer to the hypervisor connection
+ * @params: restore parameters
+ * @nparams: number of restore parameters
+ * @flags: bitwise-OR of virDomainSaveRestoreFlags
+ *
+ * This method extends virDomainRestoreFlags by adding parameters to Restore.
+ *
+ * If @flags includes VIR_DOMAIN_SAVE_PARALLEL, then libvirt will
+ * attempt to restore from multiple files in parallel,
+ * where the number of extra files is determined by the parameter
+ * VIR_SAVE_PARAM_PARALLEL_CONNECTIONS.
+ *
+ * Returns 0 in case of success and -1 in case of failure.
+ */
+int
+virDomainRestoreParametersFlags(virConnectPtr conn,
+                                virTypedParameterPtr params, int nparams,
+                                unsigned int flags)
+{
+    VIR_DEBUG("conn=%p, params=%p, nparams=%d, flags=0x%x",
+              conn, params, nparams, flags);
+    VIR_TYPED_PARAMS_DEBUG(params, nparams);
+
+    virResetLastError();
+
+    virCheckConnectReturn(conn, -1);
+    virCheckReadOnlyGoto(conn->flags, error);
+
+    VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_SAVE_RUNNING,
+                             VIR_DOMAIN_SAVE_PAUSED,
+                             error);
+
+    if (conn->driver->domainRestoreParametersFlags) {
+        if (conn->driver->domainRestoreParametersFlags(conn, params, nparams, flags) < 0)
+            goto error;
+        return 0;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(conn);
+    return -1;
+}
+
+
 /**
  * virDomainSaveImageGetXMLDesc:
  * @conn: pointer to the hypervisor connection
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index eb3a7afb75..74c1464b38 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -919,6 +919,7 @@ LIBVIRT_8.0.0 {
 LIBVIRT_8.3.0 {
     global:
         virDomainSaveParametersFlags;
+        virDomainRestoreParametersFlags;
 } LIBVIRT_8.0.0;
 
 # .... define new API here using predicted next version number ....
-- 
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