mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
vbox: Rewrite vboxDomainHasCurrentSnapshot
This commit is contained in:
parent
e36d9a7637
commit
7528bf20a2
@ -6214,3 +6214,35 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom, const char *name,
|
||||
vboxIIDUnalloc(&iid);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vboxDomainHasCurrentSnapshot(virDomainPtr dom,
|
||||
unsigned int flags)
|
||||
{
|
||||
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
||||
vboxIIDUnion iid;
|
||||
IMachine *machine = NULL;
|
||||
ISnapshot *snapshot = NULL;
|
||||
nsresult rc;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, &snapshot);
|
||||
if (NS_FAILED(rc)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("could not get current snapshot"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (snapshot)
|
||||
ret = 1;
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VBOX_RELEASE(machine);
|
||||
vboxIIDUnalloc(&iid);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1523,44 +1523,6 @@ vboxDomainSnapshotGet(vboxGlobalData *data,
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
static int
|
||||
vboxDomainHasCurrentSnapshot(virDomainPtr dom,
|
||||
unsigned int flags)
|
||||
{
|
||||
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
||||
vboxIID iid = VBOX_IID_INITIALIZER;
|
||||
IMachine *machine = NULL;
|
||||
ISnapshot *snapshot = NULL;
|
||||
nsresult rc;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
vboxIIDFromUUID(&iid, dom->uuid);
|
||||
rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
|
||||
if (NS_FAILED(rc)) {
|
||||
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||
_("no domain with matching UUID"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rc = machine->vtbl->GetCurrentSnapshot(machine, &snapshot);
|
||||
if (NS_FAILED(rc)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("could not get current snapshot"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (snapshot)
|
||||
ret = 1;
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VBOX_RELEASE(machine);
|
||||
vboxIIDUnalloc(&iid);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static virDomainSnapshotPtr
|
||||
vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
|
||||
unsigned int flags)
|
||||
|
@ -583,6 +583,7 @@ int vboxDomainSnapshotListNames(virDomainPtr dom, char **names,
|
||||
virDomainSnapshotPtr
|
||||
vboxDomainSnapshotLookupByName(virDomainPtr dom, const char *name,
|
||||
unsigned int flags);
|
||||
int vboxDomainHasCurrentSnapshot(virDomainPtr dom, unsigned int flags);
|
||||
|
||||
/* Version specified functions for installing uniformed API */
|
||||
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
|
||||
|
Loading…
x
Reference in New Issue
Block a user