These will freeze and thaw filesystems within guest specified by
@mountpoints parameters. The parameters can be NULL and 0, then the all
mounted filesystes are frozen or thawed. @flags parameter, which are
currently not used, is for future extensions.
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama(a)hds.com>
---
include/libvirt/libvirt.h.in | 10 +++++
src/driver.h | 14 ++++++
src/libvirt.c | 93 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 6 +++
4 files changed, 123 insertions(+)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 930b7e8..878ddc5 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 **mountpoints,
+ unsigned int nmountpoints,
+ unsigned int flags);
+
+int virDomainFSThaw(virDomainPtr dom,
+ const char **mountpoints,
+ unsigned int nmountpoints,
+ unsigned int flags);
+
/**
* virSchedParameterType:
*
diff --git a/src/driver.h b/src/driver.h
index 729e743..502f30e 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 **mountpoints,
+ unsigned int nmountpoints,
+ unsigned int flags);
+
+typedef int
+(*virDrvDomainFSThaw)(virDomainPtr dom,
+ const char **mountpoints,
+ unsigned int nmountpoints,
+ 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 b6c99c5..4dfacf6 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -20682,3 +20682,96 @@ virDomainFSTrim(virDomainPtr dom,
virDispatchError(dom->conn);
return -1;
}
+
+/**
+ * virDomainFSFreeze:
+ * @dom: a domain object
+ * @mountpoints: list of mount points to be frozen
+ * @nmountpoints: the number of mount points specified in @mountpoints
+ * @flags: extra flags, not used yet, so callers should always pass 0
+ *
+ * Freeze specified filesystems within the guest (hence guest agent
+ * may be required depending on hypervisor used). If @mountpoints is NULL or
+ * @nmountpoints is 0, every mounted filesystem on the guest is frozen.
+ * In some environments (e.g. QEMU guest with guest agent which doesn't
+ * support mountpoints argument), @mountpoints may be ignored.
+ *
+ * Returns the number of frozen filesystems on success, -1 otherwise.
+ */
+int
+virDomainFSFreeze(virDomainPtr dom,
+ const char **mountpoints,
+ unsigned int nmountpoints,
+ unsigned int flags)
+{
+ VIR_DOMAIN_DEBUG(dom, "mountpoints=%p, nmountpoints=%d, flags=%x",
+ mountpoints, nmountpoints, flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(dom, -1);
+ virCheckReadOnlyGoto(dom->conn->flags, error);
+ if (nmountpoints)
+ virCheckNonNullArgGoto(mountpoints, error);
+ else
+ virCheckNullArgGoto(mountpoints, error);
+
+ if (dom->conn->driver->domainFSFreeze) {
+ int ret = dom->conn->driver->domainFSFreeze(
+ dom, mountpoints, nmountpoints, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(dom->conn);
+ return -1;
+}
+
+/**
+ * virDomainFSThaw:
+ * @dom: a domain object
+ * @mountpoints: list of mount points to be thawed
+ * @nmountpoints: the number of mount points specified in @mountpoints
+ * @flags: extra flags, not used yet, so callers should always pass 0
+ *
+ * Thaw specified filesystems within the guest. If @mountpoints is NULL or
+ * @nmountpoints is 0, every mounted filesystem on the guest is thawed.
+ * In some drivers (e.g. QEMU driver), @mountpoints may always be ignored.
+ *
+ * Returns the number of thawed filesystems on success, -1 otherwise.
+ */
+int
+virDomainFSThaw(virDomainPtr dom,
+ const char **mountpoints,
+ unsigned int nmountpoints,
+ unsigned int flags)
+{
+ VIR_DOMAIN_DEBUG(dom, "flags=%x", flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(dom, -1);
+ virCheckReadOnlyGoto(dom->conn->flags, error);
+ if (nmountpoints)
+ virCheckNonNullArgGoto(mountpoints, error);
+ else
+ virCheckNullArgGoto(mountpoints, error);
+
+ if (dom->conn->driver->domainFSThaw) {
+ int ret = dom->conn->driver->domainFSThaw(
+ dom, mountpoints, nmountpoints, 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..f8113f4 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.5 {
+ global:
+ virDomainFSFreeze;
+ virDomainFSThaw;
+} LIBVIRT_1.2.3;
+
# .... define new API here using predicted next version number ....