snapshot: conf: Make virDomainSnapshotIsExternal more reusable

Allow to use definition objects with this predicate function.
This commit is contained in:
Peter Krempa 2013-01-03 14:10:39 +01:00
parent 346e43ecfd
commit 51b12b8cca
3 changed files with 12 additions and 4 deletions

View File

@ -1058,17 +1058,23 @@ cleanup:
bool bool
virDomainSnapshotIsExternal(virDomainSnapshotObjPtr snap) virDomainSnapshotDefIsExternal(virDomainSnapshotDefPtr def)
{ {
int i; int i;
if (snap->def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) if (def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
return true; return true;
for (i = 0; i < snap->def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
if (snap->def->disks[i].snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) if (def->disks[i].snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
return true; return true;
} }
return false; return false;
} }
bool
virDomainSnapshotIsExternal(virDomainSnapshotObjPtr snap)
{
return virDomainSnapshotDefIsExternal(snap->def);
}

View File

@ -166,6 +166,7 @@ int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
virDomainSnapshotPtr **snaps, virDomainSnapshotPtr **snaps,
unsigned int flags); unsigned int flags);
bool virDomainSnapshotDefIsExternal(virDomainSnapshotDefPtr def);
bool virDomainSnapshotIsExternal(virDomainSnapshotObjPtr snap); bool virDomainSnapshotIsExternal(virDomainSnapshotObjPtr snap);
VIR_ENUM_DECL(virDomainSnapshotLocation) VIR_ENUM_DECL(virDomainSnapshotLocation)

View File

@ -1097,6 +1097,7 @@ virDomainSnapshotAlignDisks;
virDomainSnapshotAssignDef; virDomainSnapshotAssignDef;
virDomainSnapshotDefFormat; virDomainSnapshotDefFormat;
virDomainSnapshotDefFree; virDomainSnapshotDefFree;
virDomainSnapshotDefIsExternal;
virDomainSnapshotDefParseString; virDomainSnapshotDefParseString;
virDomainSnapshotDropParent; virDomainSnapshotDropParent;
virDomainSnapshotFindByName; virDomainSnapshotFindByName;