unsigned int flags)
{
virDomainSnapshotLocation align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL;
- bool align_match = true;
bool external = def->state == VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT ||
virDomainSnapshotDefIsExternal(def);
}
if (def->parent.dom) {
- if (external) {
+ if (external)
align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
- align_match = false;
- }
- if (virDomainSnapshotAlignDisks(def, align_location,
- align_match) < 0)
+
+ if (virDomainSnapshotAlignDisks(def, align_location, true) < 0)
return -1;
}
* virDomainSnapshotAlignDisks:
* @snapdef: Snapshot definition to align
* @default_snapshot: snapshot location to assign to disks which don't have any
- * @require_match: Require that all disks use the same snapshot mode
+ * @uniform_internal_snapshot: Require that for an internal snapshot all disks
+ * take part in the internal snapshot
*
* Align snapdef->disks to snapdef->parent.dom, filling in any missing disks or
* snapshot state defaults given by the domain, with a fallback to
* definitions in @snapdef and there are no disks described in @snapdef but
* missing from the domain definition.
*
+ * When @uniform_internal_snapshot is true and @default_snapshot is
+ * VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL, all disks in @snapdef must take part
+ * in the internal snapshot. This is for hypervisors where granularity of an
+ * internal snapshot can't be controlled.
+ *
* Convert paths to disk targets for uniformity.
*
* On error -1 is returned and a libvirt error is reported.
int
virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapdef,
virDomainSnapshotLocation default_snapshot,
- bool require_match)
+ bool uniform_internal_snapshot)
{
virDomainDef *domdef = snapdef->parent.dom;
g_autoptr(GHashTable) map = virHashNew(NULL);
g_autofree virDomainSnapshotDiskDef *olddisks = NULL;
+ bool require_match = false;
size_t oldndisks;
size_t i;
return -1;
}
+ if (uniform_internal_snapshot &&
+ default_snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL)
+ require_match = true;
+
/* Unlikely to have a guest without disks but technically possible. */
if (!domdef->ndisks)
return 0;
unsigned int flags);
int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapshot,
virDomainSnapshotLocation default_snapshot,
- bool require_match);
+ bool uniform_internal_snapshot);
bool virDomainSnapshotDefIsExternal(virDomainSnapshotDef *def);
bool virDomainSnapshotIsExternal(virDomainMomentObj *snap);
g_autofree char *xml = NULL;
qemuDomainObjPrivate *priv = vm->privateData;
virDomainSnapshotLocation align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL;
- bool align_match = true;
/* Easiest way to clone inactive portion of vm->def is via
* conversion in and back out of xml. */
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) {
align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
- align_match = false;
if (virDomainObjIsActive(vm))
def->state = VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT;
else
} else if (def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
def->state = virDomainObjGetState(vm, NULL);
align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
- align_match = false;
} else {
def->state = virDomainObjGetState(vm, NULL);
VIR_DOMAIN_SNAPSHOT_LOCATION_NONE :
VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL);
}
- if (virDomainSnapshotAlignDisks(def, align_location, align_match) < 0)
+ if (virDomainSnapshotAlignDisks(def, align_location, true) < 0)
return -1;
return 0;
unsigned int flags)
{
virDomainSnapshotLocation align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL;
- bool align_match = true;
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) {
align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
- align_match = false;
if (virDomainObjIsActive(vm))
def->state = VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT;
else
} else if (def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
def->state = virDomainObjGetState(vm, NULL);
align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
- align_match = false;
} else {
def->state = virDomainObjGetState(vm, NULL);
def->memory = def->state == VIR_DOMAIN_SNAPSHOT_SHUTOFF ?
VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL;
}
- return virDomainSnapshotAlignDisks(def, align_location, align_match);
+ return virDomainSnapshotAlignDisks(def, align_location, true);
}
static virDomainSnapshotPtr