mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
vbox: Rewrite vboxDomainSnapshotNum
This commit is contained in:
parent
72c23d65c1
commit
1157d85c12
@ -6069,3 +6069,43 @@ char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
vboxIIDUnalloc(&domiid);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vboxDomainSnapshotNum(virDomainPtr dom, unsigned int flags)
|
||||
{
|
||||
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
||||
vboxIIDUnion iid;
|
||||
IMachine *machine = NULL;
|
||||
nsresult rc;
|
||||
PRUint32 snapshotCount;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
|
||||
VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
|
||||
|
||||
if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* VBox snapshots do not require libvirt to maintain any metadata. */
|
||||
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) {
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rc = gVBoxAPI.UIMachine.GetSnapshotCount(machine, &snapshotCount);
|
||||
if (NS_FAILED(rc)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("could not get snapshot count for domain %s"),
|
||||
dom->name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* VBox has at most one root snapshot. */
|
||||
if (snapshotCount && (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS))
|
||||
ret = 1;
|
||||
else
|
||||
ret = snapshotCount;
|
||||
|
||||
cleanup:
|
||||
VBOX_RELEASE(machine);
|
||||
vboxIIDUnalloc(&iid);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1523,53 +1523,6 @@ vboxDomainSnapshotGet(vboxGlobalData *data,
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
static int
|
||||
vboxDomainSnapshotNum(virDomainPtr dom,
|
||||
unsigned int flags)
|
||||
{
|
||||
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
||||
vboxIID iid = VBOX_IID_INITIALIZER;
|
||||
IMachine *machine = NULL;
|
||||
nsresult rc;
|
||||
PRUint32 snapshotCount;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
|
||||
VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -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;
|
||||
}
|
||||
|
||||
/* VBox snapshots do not require libvirt to maintain any metadata. */
|
||||
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) {
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rc = machine->vtbl->GetSnapshotCount(machine, &snapshotCount);
|
||||
if (NS_FAILED(rc)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("could not get snapshot count for domain %s"),
|
||||
dom->name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* VBox has at most one root snapshot. */
|
||||
if (snapshotCount && (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS))
|
||||
ret = 1;
|
||||
else
|
||||
ret = snapshotCount;
|
||||
|
||||
cleanup:
|
||||
VBOX_RELEASE(machine);
|
||||
vboxIIDUnalloc(&iid);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
vboxDomainSnapshotListNames(virDomainPtr dom,
|
||||
char **names,
|
||||
|
@ -577,6 +577,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
|
||||
unsigned int flags);
|
||||
char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
unsigned int flags);
|
||||
int vboxDomainSnapshotNum(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