Re: [libvirt RFC v3 03/19] libvirt: introduce virDomainSaveParametersFlags public API

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

 



On 4/26/22 10:47, Claudio Fontana wrote:
add new API in order to be able to extend parameters to the domain
save operation. We will use it to fit the existing arguments of
VirDomainSaveFlags, and then add parallel saves functionality.

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

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 9aa214f3df..4beea34f93 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1481,6 +1481,7 @@ typedef enum {
      VIR_DOMAIN_SAVE_RUNNING      = 1 << 1, /* Favor running over paused */
      VIR_DOMAIN_SAVE_PAUSED       = 1 << 2, /* Favor paused over running */
      VIR_DOMAIN_SAVE_RESET_NVRAM  = 1 << 3, /* Re-initialize NVRAM from template */
+    VIR_DOMAIN_SAVE_PARALLEL     = 1 << 4, /* Parallel Save/Restore to multiple files */
  } virDomainSaveRestoreFlags;
int virDomainSave (virDomainPtr domain,
@@ -1489,6 +1490,10 @@ int                     virDomainSaveFlags      (virDomainPtr domain,
                                                   const char *to,
                                                   const char *dxml,
                                                   unsigned int flags);
+int                     virDomainSaveParametersFlags (virDomainPtr domain,
+                                                      virTypedParameterPtr params,
+                                                      int nparams,
+                                                      unsigned int flags);
  int                     virDomainRestore        (virConnectPtr conn,
                                                   const char *from);
  int                     virDomainRestoreFlags   (virConnectPtr conn,
@@ -1496,6 +1501,10 @@ int                     virDomainRestoreFlags   (virConnectPtr conn,
                                                   const char *dxml,
                                                   unsigned int flags);
+# define VIR_SAVE_PARAM_FILE "file"
+# define VIR_SAVE_PARAM_DXML                     "dxml"
+# define VIR_SAVE_PARAM_PARALLEL_CONNECTIONS     "parallel.connections"

The common pattern is to use '_' in multi-word parameter names, i.e. "parallel_connections". Also, this fails to build the API docs

[499/508] Generating docs/generate-api with a custom command
FAILED: docs/libvirt-api.xml docs/libvirt-lxc-api.xml docs/libvirt-qemu-api.xml docs/libvirt-admin-api.xml /home/jfehlig/virt/gitlab/libvirt/scripts/meson-python.sh /usr/bin/python3 /home/jfehlig/virt/gitlab/libvirt/scripts/apibuild.py /home/jfehlig/virt/gitlab/libvirt/docs /home/jfehlig/virt/gitlab/libvirt/build/docs
Misformatted macro comment for VIR_SAVE_PARAM_FILE
  Expecting '* VIR_SAVE_PARAM_FILE:' got '* virDomainSaveRestoreFlags:'
Misformatted macro comment for VIR_SAVE_PARAM_DXML
  Expecting '* VIR_SAVE_PARAM_DXML:' got '* virDomainSaveRestoreFlags:'
Misformatted macro comment for VIR_SAVE_PARAM_PARALLEL_CONNECTIONS
Expecting '* VIR_SAVE_PARAM_PARALLEL_CONNECTIONS:' got '* virDomainSaveRestoreFlags:'
Missing 'Since' tag for: VIR_SAVE_PARAM_DXML
Missing 'Since' tag for: VIR_SAVE_PARAM_FILE
Missing 'Since' tag for: VIR_SAVE_PARAM_PARALLEL_CONNECTIONS
Missing 'Since' tag for: VIR_DOMAIN_SAVE_PARALLEL
Missing 'Since' tag for: virDomainSaveParametersFlags

+
  /* See below for virDomainSaveImageXMLFlags */
  char *          virDomainSaveImageGetXMLDesc    (virConnectPtr conn,
                                                   const char *file,
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 4423eb0885..a4e1d21e76 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -240,6 +240,12 @@ typedef int
                           const char *dxml,
                           unsigned int flags);
+typedef int
+(*virDrvDomainSaveParametersFlags)(virDomainPtr domain,
+                                   virTypedParameterPtr params,
+                                   int nparams,
+                                   unsigned int flags);
+
  typedef int
  (*virDrvDomainRestore)(virConnectPtr conn,
                         const char *from);
@@ -1489,6 +1495,7 @@ struct _virHypervisorDriver {
      virDrvDomainGetControlInfo domainGetControlInfo;
      virDrvDomainSave domainSave;
      virDrvDomainSaveFlags domainSaveFlags;
+    virDrvDomainSaveParametersFlags domainSaveParametersFlags;
      virDrvDomainRestore domainRestore;
      virDrvDomainRestoreFlags domainRestoreFlags;
      virDrvDomainSaveImageGetXMLDesc domainSaveImageGetXMLDesc;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index cbd7902d2d..9e4fcfd022 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -959,6 +959,57 @@ virDomainSaveFlags(virDomainPtr domain, const char *to,
      return -1;
  }
+/**
+ * virDomainSaveParametersFlags:
+ * @domain: a domain object
+ * @params: save parameters
+ * @nparams: number of save parameters
+ * @flags: bitwise-OR of virDomainSaveRestoreFlags
+ *
+ * This method extends virDomainSaveFlags by adding parameters to Save.
+ *
+ * If @flags includes VIR_DOMAIN_SAVE_PARALLEL, then libvirt will
+ * attempt to trigger a parallel transfer to multiple files,
+ * 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
+virDomainSaveParametersFlags(virDomainPtr domain,
+                             virTypedParameterPtr params, int nparams,
+                             unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%d, flags=0x%x",
+                     params, nparams, flags);
+    VIR_TYPED_PARAMS_DEBUG(params, nparams);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, -1);
+    conn = domain->conn;
+
+    virCheckReadOnlyGoto(conn->flags, error);
+
+    VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_SAVE_RUNNING,
+                             VIR_DOMAIN_SAVE_PAUSED,
+                             error);

Check for the new flag?

Jim

+
+    if (conn->driver->domainSaveParametersFlags) {
+        if (conn->driver->domainSaveParametersFlags(domain, params, nparams, flags) < 0)
+            goto error;
+        return 0;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(domain->conn);
+    return -1;
+}
+
/**
   * virDomainRestore:
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index f93692c427..eb3a7afb75 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -916,4 +916,9 @@ LIBVIRT_8.0.0 {
          virDomainSetLaunchSecurityState;
  } LIBVIRT_7.8.0;
+LIBVIRT_8.3.0 {
+    global:
+        virDomainSaveParametersFlags;
+} LIBVIRT_8.0.0;
+
  # .... define new API here using predicted next version number ....




[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