mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
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: Ilias Stamatis <stamatis.iliass@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
9ebdb3b0aa
commit
8037637941
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user