On success update the domain-private data. Consider / and /boot to be
the only mountpoints avaiable in order to be consistent with the other
FS-related calls.
Signed-off-by: Ilias Stamatis <stamatis.iliass(a)gmail.com>
---
src/test/test_driver.c | 72 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 88a1d330c1..a8b75b175a 100755
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -390,6 +390,8 @@ typedef struct _testDomainObjPrivate testDomainObjPrivate;
typedef testDomainObjPrivate *testDomainObjPrivatePtr;
struct _testDomainObjPrivate {
testDriverPtr driver;
+
+ bool frozen[2]; /* used by file system related calls */
};
@@ -402,6 +404,7 @@ testDomainObjPrivateAlloc(void *opaque)
return NULL;
priv->driver = opaque;
+ priv->frozen[0] = priv->frozen[1] = false;
return priv;
}
@@ -4046,6 +4049,74 @@ static int testDomainUndefine(virDomainPtr domain)
return testDomainUndefineFlags(domain, 0);
}
+
+static int
+testDomainFSFreeze(virDomainPtr dom,
+ const char **mountpoints,
+ unsigned int nmountpoints,
+ unsigned int flags)
+{
+ virDomainObjPtr vm;
+ testDomainObjPrivatePtr priv;
+ size_t i;
+ int ret = -1;
+
+ virCheckFlags(0, -1);
+
+ if (!(vm = testDomObjFromDomain(dom)))
+ goto cleanup;
+
+ if (virDomainObjCheckActive(vm) < 0)
+ goto cleanup;
+
+ priv = vm->privateData;
+
+ if (nmountpoints == 0) {
+ ret = 0;
+ if (priv->frozen[0] == false) {
+ priv->frozen[0] = true;
+ ret++;
+ }
+ if (priv->frozen[1] == false) {
+ priv->frozen[1] = true;
+ ret++;
+ }
+ } else {
+ int nfreeze = 0;
+ bool freeze[2];
+
+ memcpy(&freeze, priv->frozen, 2);
+
+ for (i = 0; i < nmountpoints; i++) {
+ if (STREQ(mountpoints[i], "/")) {
+ if (!freeze[0]) {
+ freeze[0] = true;
+ nfreeze++;
+ }
+ } else if (STREQ(mountpoints[i], "/boot")) {
+ if (!freeze[1]) {
+ freeze[1] = true;
+ nfreeze++;
+ }
+ } else {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("mount point not found: %s"),
+ mountpoints[i]);
+ goto cleanup;
+ }
+ }
+
+ /* steal the helper copy */
+ memcpy(priv->frozen, &freeze, 2);
+ ret = nfreeze;
+ }
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+
static int testDomainGetAutostart(virDomainPtr domain,
int *autostart)
{
@@ -8692,6 +8763,7 @@ static virHypervisorDriver testHypervisorDriver = {
.domainDefineXMLFlags = testDomainDefineXMLFlags, /* 1.2.12 */
.domainUndefine = testDomainUndefine, /* 0.1.11 */
.domainUndefineFlags = testDomainUndefineFlags, /* 0.9.4 */
+ .domainFSFreeze = testDomainFSFreeze, /* 5.7.0 */
.domainGetAutostart = testDomainGetAutostart, /* 0.3.2 */
.domainSetAutostart = testDomainSetAutostart, /* 0.3.2 */
.domainGetDiskErrors = testDomainGetDiskErrors, /* 5.4.0 */
--
2.22.0