These will freeze and thaw filesystems within guest. The APIs take @disks
and @ndisks parameters to specify disks to be frozen or thawed.
The parameters can be NULL and 0, then the all mounted filesystes are
frozen or thawed. If some disks are frozen multiple times, they are not
thawed until requested to be thawed as many times as freeze request.
@flags parameter, which are currently not used, is for future extensions.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiy...@hds.com>
---
 include/libvirt/libvirt.h.in |   10 +++++
 src/driver.h                 |   14 ++++++
 src/libvirt.c                |   92 ++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |    6 +++
 4 files changed, 122 insertions(+)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 930b7e8..d408f19 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -5277,6 +5277,16 @@ int virDomainFSTrim(virDomainPtr dom,
                     unsigned long long minimum,
                     unsigned int flags);
 
+int virDomainFSFreeze(virDomainPtr dom,
+                      const char **disks,
+                      unsigned int ndisks,
+                      unsigned int flags);
+
+int virDomainFSThaw(virDomainPtr dom,
+                    const char **disks,
+                    unsigned int ndisks,
+                    unsigned int flags);
+
 /**
  * virSchedParameterType:
  *
diff --git a/src/driver.h b/src/driver.h
index e66fc7a..5c81d96 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1149,6 +1149,18 @@ typedef int
                                      unsigned int flags,
                                      int cancelled);
 
+typedef int
+(*virDrvDomainFSFreeze)(virDomainPtr dom,
+                        const char **disks,
+                        unsigned int ndisks,
+                        unsigned int flags);
+
+typedef int
+(*virDrvDomainFSThaw)(virDomainPtr dom,
+                      const char **disks,
+                      unsigned int ndisks,
+                      unsigned int flags);
+
 typedef struct _virDriver virDriver;
 typedef virDriver *virDriverPtr;
 
@@ -1363,6 +1375,8 @@ struct _virDriver {
     virDrvDomainMigrateFinish3Params domainMigrateFinish3Params;
     virDrvDomainMigrateConfirm3Params domainMigrateConfirm3Params;
     virDrvConnectGetCPUModelNames connectGetCPUModelNames;
+    virDrvDomainFSFreeze domainFSFreeze;
+    virDrvDomainFSThaw domainFSThaw;
 };
 
 
diff --git a/src/libvirt.c b/src/libvirt.c
index 4454829..43614b5 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -20658,3 +20658,95 @@ virDomainFSTrim(virDomainPtr dom,
     virDispatchError(dom->conn);
     return -1;
 }
+
+/**
+ * virDomainFSFreeze:
+ * @dom: a domain object
+ * @disks: list of disk names to be frozen
+ * @ndisks: the number of disks specified in @disks
+ * @flags: extra flags, not used yet, so callers should always pass 0
+ *
+ * Freeze filesystems on the specified disks within the guest (hence guest
+ * agent may be required depending on hypervisor used). If @ndisks is 0,
+ * every mounted filesystem on the guest is frozen.
+ * Freeze can be nested. When it is called on the same disk multiple times,
+ * the disk will not be thawed until virDomainFSThaw is called the same times.
+ *
+ * Returns 0 on success, -1 otherwise.
+ */
+int
+virDomainFSFreeze(virDomainPtr dom,
+                  const char **disks,
+                  unsigned int ndisks,
+                  unsigned int flags)
+{
+    VIR_DOMAIN_DEBUG(dom, "disks=%p, ndisks=%d, flags=%x",
+                     disks, ndisks, flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(dom, -1);
+    virCheckReadOnlyGoto(dom->conn->flags, error);
+    if (ndisks)
+        virCheckNonNullArgGoto(disks, error);
+    else
+        virCheckNullArgGoto(disks, error);
+
+    if (dom->conn->driver->domainFSFreeze) {
+        int ret = dom->conn->driver->domainFSFreeze(dom, disks, ndisks, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(dom->conn);
+    return -1;
+}
+
+/**
+ * virDomainFSThaw:
+ * @dom: a domain object
+ * @disks: list of disk names to be thawed
+ * @ndisks: the number of disks specified in @disks
+ * @flags: extra flags, not used yet, so callers should always pass 0
+ *
+ * Thaw filesystems on the specified disks within the guest (hence guest
+ * agent may be required depending on hypervisor used). If @ndisks is 0,
+ * every mounted filesystem on the guest is thawed.
+ *
+ * Returns 0 on success, -1 otherwise.
+ */
+int
+virDomainFSThaw(virDomainPtr dom,
+                const char **disks,
+                unsigned int ndisks,
+                unsigned int flags)
+{
+    VIR_DOMAIN_DEBUG(dom, "disks=%p, ndisks=%d, flags=%x",
+                     disks, ndisks, flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(dom, -1);
+    virCheckReadOnlyGoto(dom->conn->flags, error);
+    if (ndisks)
+        virCheckNonNullArgGoto(disks, error);
+    else
+        virCheckNullArgGoto(disks, error);
+
+    if (dom->conn->driver->domainFSThaw) {
+        int ret = dom->conn->driver->domainFSThaw(dom, disks, ndisks, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(dom->conn);
+    return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 9ab0c92..79d3edc 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -650,5 +650,11 @@ LIBVIRT_1.2.3 {
         virDomainCoreDumpWithFormat;
 } LIBVIRT_1.2.1;
 
+LIBVIRT_1.2.4 {
+    global:
+        virDomainFSFreeze;
+        virDomainFSThaw;
+} LIBVIRT_1.2.3;
+
 
 # .... define new API here using predicted next version number ....

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to