提交 80376379 编写于 作者: I Ilias Stamatis 提交者: Erik Skultety

test_driver: implement virDomainFSFreeze

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: NIlias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 9ebdb3b0
......@@ -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;
}
......@@ -4070,6 +4073,67 @@ 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 = 2 - (priv->frozen[0] + priv->frozen[1]);
priv->frozen[0] = priv->frozen[1] = true;
} 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)
{
......@@ -8771,6 +8835,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 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册