This will freeze filesystems within guest. The API takes @mountPoint
arguments which are currently not used, for future extensions of guest
agent.
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama(a)hds.com>
---
include/libvirt/libvirt.h.in | 8 ++++
src/driver.h | 12 +++++
src/libvirt.c | 92 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 6 +++
4 files changed, 118 insertions(+)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 80b2d78..559d916 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -5069,6 +5069,14 @@ int virDomainFSTrim(virDomainPtr dom,
unsigned long long minimum,
unsigned int flags);
+int virDomainFSFreeze(virDomainPtr dom,
+ const char *mountPoint,
+ unsigned int flags);
+
+int virDomainFSThaw(virDomainPtr dom,
+ const char *mountPoint,
+ unsigned int flags);
+
/**
* virSchedParameterType:
*
diff --git a/src/driver.h b/src/driver.h
index 8cd164a..dd41aea 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1128,6 +1128,16 @@ typedef int
unsigned int flags,
int cancelled);
+typedef int
+(*virDrvDomainFSFreeze)(virDomainPtr dom,
+ const char *mountPoint,
+ unsigned int flags);
+
+typedef int
+(*virDrvDomainFSThaw)(virDomainPtr dom,
+ const char *mountPoint,
+ unsigned int flags);
+
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;
@@ -1339,6 +1349,8 @@ struct _virDriver {
virDrvDomainMigrateFinish3Params domainMigrateFinish3Params;
virDrvDomainMigrateConfirm3Params domainMigrateConfirm3Params;
virDrvConnectGetCPUModelNames connectGetCPUModelNames;
+ virDrvDomainFSFreeze domainFSFreeze;
+ virDrvDomainFSThaw domainFSThaw;
};
diff --git a/src/libvirt.c b/src/libvirt.c
index 90608ab..1c09c43 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -22042,3 +22042,95 @@ error:
virDispatchError(dom->conn);
return -1;
}
+
+/**
+ * virDomainFSFreeze:
+ * @dom: a domain object
+ * @mountPoint: which mount points to fsfreeze
+ * @flags: extra flags, not used yet, so callers should always pass 0
+ *
+ * Freeze filesystems within the guest (hence guest agent may be
+ * required depending on hypervisor used). Either call it on each
+ * mounted filesystem (@mountPoint is NULL) or on specified @mountPoint.
+ *
+ * Returns 0 on success, -1 otherwise.
+ */
+int
+virDomainFSFreeze(virDomainPtr dom,
+ const char *mountPoint,
+ unsigned int flags)
+{
+ VIR_DOMAIN_DEBUG(dom, "mountPoint=%s, flags=%x", mountPoint, flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_DOMAIN(dom)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ if (dom->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ if (dom->conn->driver->domainFSFreeze) {
+ int ret = dom->conn->driver->domainFSFreeze(dom, mountPoint, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(dom->conn);
+ return -1;
+}
+
+/**
+ * virDomainFSThaw:
+ * @dom: a domain object
+ * @mountPoint: which mount points to thaw
+ * @flags: extra flags, not used yet, so callers should always pass 0
+ *
+ * Thaw the frozen filesystems within the guest (hence guest agent
+ * may be required depending on hypervisor used). Either call it on each
+ * mounted filesystem (@mountPoint is NULL) or on specified @mountPoint.
+ *
+ * Returns 0 on success, -1 otherwise.
+ */
+int
+virDomainFSThaw(virDomainPtr dom,
+ const char *mountPoint,
+ unsigned int flags)
+{
+ VIR_DOMAIN_DEBUG(dom, "mountPoint=%s, flags=%x", mountPoint, flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_DOMAIN(dom)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ if (dom->conn->flags & VIR_CONNECT_RO) {
+ virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ if (dom->conn->driver->domainFSThaw) {
+ int ret = dom->conn->driver->domainFSThaw(dom, mountPoint, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(dom->conn);
+ return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index fe9b497..412192f 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -639,4 +639,10 @@ LIBVIRT_1.1.3 {
virConnectGetCPUModelNames;
} LIBVIRT_1.1.1;
+LIBVIRT_1.1.5 {
+ global:
+ virDomainFSFreeze;
+ virDomainFSThaw;
+} LIBVIRT_1.1.3;
+
# .... define new API here using predicted next version number ....