qemu: snapshot: Allow internal snapshots with PFLASH nvram

With the new snapshot QMP command we can select which block device
backend receives the VM state and thus the main issue with internal
snapshots with pflash was addressed.

Thus we can relax the check and allow snapshots if the pflash nvram is
on qcow2.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2024-10-01 15:16:14 +02:00
parent 8be8b7de78
commit aa08a30048

View File

@ -798,6 +798,7 @@ qemuSnapshotPrepare(virDomainObj *vm,
bool *has_manual,
unsigned int *flags)
{
qemuDomainObjPrivate *priv = vm->privateData;
size_t i;
bool active = virDomainObjIsActive(vm);
bool reuse = (*flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
@ -899,7 +900,8 @@ qemuSnapshotPrepare(virDomainObj *vm,
return -1;
}
/* internal snapshots + pflash based loader have the following problems:
/* internal snapshots + pflash based loader have the following problems when
* using the old HMP 'savevm' command:
* - if the variable store is raw, the snapshot fails
* - allowing a qcow2 image as the varstore would make it eligible to receive
* the vmstate dump, which would make it huge
@ -910,16 +912,30 @@ qemuSnapshotPrepare(virDomainObj *vm,
* not an issue. Allow this as there are existing users of this case.
*
* Avoid the issues by forbidding internal snapshot with pflash if the
* VM is active.
* VM is active when using 'savevm'.
*
* With the new QMP commands we can control where the VM state (memory)
* image goes and thus can allow snapshots, but we'll still require that the
* varstore is in qcow2 format.
*/
if (active &&
found_internal &&
virDomainDefHasOldStyleUEFI(vm->def)) {
if (active && found_internal) {
if (virDomainDefHasOldStyleUEFI(vm->def) &&
!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SNAPSHOT_INTERNAL_QMP)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("internal snapshots of a VM with pflash based firmware are not supported"));
_("internal snapshots of a VM with pflash based firmware are not supported with this qemu"));
return -1;
}
if (vm->def->os.loader &&
vm->def->os.loader->nvram &&
vm->def->os.loader->nvram->format != VIR_STORAGE_FILE_QCOW2) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("internal snapshots of a VM with pflash based firmware require QCOW2 nvram format"));
return -1;
}
}
/* Alter flags to let later users know what we learned. */
if (external && !active)
*flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;