1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-14 23:24:23 +03:00

vbox: Rewrite vboxDomainSnapshotHasMetadata

This commit is contained in:
Taowei 2014-08-11 18:07:02 +08:00 committed by Michal Privoznik
parent d722d8c7a9
commit 410b2183b7
3 changed files with 29 additions and 34 deletions

View File

@ -6417,3 +6417,30 @@ int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
vboxIIDUnalloc(&iid); vboxIIDUnalloc(&iid);
return ret; return ret;
} }
int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
virDomainPtr dom = snapshot->domain;
VBOX_OBJECT_CHECK(dom->conn, int, -1);
vboxIIDUnion iid;
IMachine *machine = NULL;
ISnapshot *snap = NULL;
virCheckFlags(0, -1);
if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
goto cleanup;
/* Check that snapshot exists. If so, there is no metadata. */
if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
goto cleanup;
ret = 0;
cleanup:
VBOX_RELEASE(snap);
VBOX_RELEASE(machine);
vboxIIDUnalloc(&iid);
return ret;
}

View File

@ -1523,40 +1523,6 @@ vboxDomainSnapshotGet(vboxGlobalData *data,
return snapshot; return snapshot;
} }
static int
vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
virDomainPtr dom = snapshot->domain;
VBOX_OBJECT_CHECK(dom->conn, int, -1);
vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snap = 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;
}
/* Check that snapshot exists. If so, there is no metadata. */
if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
goto cleanup;
ret = 0;
cleanup:
VBOX_RELEASE(snap);
VBOX_RELEASE(machine);
vboxIIDUnalloc(&iid);
return ret;
}
#if VBOX_API_VERSION < 3001000 #if VBOX_API_VERSION < 3001000
static int static int
vboxDomainSnapshotRestore(virDomainPtr dom, vboxDomainSnapshotRestore(virDomainPtr dom,

View File

@ -591,6 +591,8 @@ virDomainSnapshotPtr
vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags); vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags);
int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
unsigned int flags); unsigned int flags);
int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
unsigned int flags);
/* Version specified functions for installing uniformed API */ /* Version specified functions for installing uniformed API */
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);