[libvirt RFCv5 09/27] libvirt: introduce virDomainRestoreParams 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 for now.

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

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 7a6170c5ad..d88aa603a9 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1572,6 +1572,10 @@ int                     virDomainRestoreFlags   (virConnectPtr conn,
                                                  const char *from,
                                                  const char *dxml,
                                                  unsigned int flags);
+int                     virDomainRestoreParams  (virConnectPtr conn,
+                                                 virTypedParameterPtr params,
+                                                 int nparams,
+                                                 unsigned int flags);
 
 /**
  * VIR_SAVE_PARAM_FILE:
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 434a7d7cc4..69516e8fea 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
+(*virDrvDomainRestoreParams)(virConnectPtr conn,
+                             virTypedParameterPtr params,
+                             int nparams,
+                             unsigned int flags);
+
 typedef char *
 (*virDrvDomainSaveImageGetXMLDesc)(virConnectPtr conn,
                                    const char *file,
@@ -1498,6 +1504,7 @@ struct _virHypervisorDriver {
     virDrvDomainSaveParams domainSaveParams;
     virDrvDomainRestore domainRestore;
     virDrvDomainRestoreFlags domainRestoreFlags;
+    virDrvDomainRestoreParams domainRestoreParams;
     virDrvDomainSaveImageGetXMLDesc domainSaveImageGetXMLDesc;
     virDrvDomainSaveImageDefineXML domainSaveImageDefineXML;
     virDrvDomainCoreDump domainCoreDump;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index fff5644c62..6f0f3649f7 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -1181,6 +1181,51 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,
 }
 
 
+/**
+ * virDomainRestoreParams:
+ * @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.
+ *
+ * Returns 0 in case of success and -1 in case of failure.
+ *
+ * Since: v8.3.0
+ */
+int
+virDomainRestoreParams(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->domainRestoreParams) {
+        if (conn->driver->domainRestoreParams(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 759735c798..43d071420c 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -919,6 +919,7 @@ LIBVIRT_8.0.0 {
 LIBVIRT_8.3.0 {
     global:
         virDomainSaveParams;
+        virDomainRestoreParams;
 } 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