mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu: snapshot: Change 'data-file' to read-only after snapshot
For the reason outlined in previous commit qemu doesn't do this automatically. Handle it manually after the snapshot. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
754ca45c45
commit
2a9349c8e8
@ -1434,12 +1434,14 @@ qemuSnapshotGetTransientDiskDef(virDomainDiskDef *domdisk,
|
|||||||
* qemuSnapshotDiskUpdateSource:
|
* qemuSnapshotDiskUpdateSource:
|
||||||
* @vm: domain object
|
* @vm: domain object
|
||||||
* @dd: snapshot disk data object
|
* @dd: snapshot disk data object
|
||||||
|
* @asyncJob: async job type
|
||||||
*
|
*
|
||||||
* Updates disk definition after a successful snapshot.
|
* Updates disk definition after a successful snapshot.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
qemuSnapshotDiskUpdateSource(virDomainObj *vm,
|
qemuSnapshotDiskUpdateSource(virDomainObj *vm,
|
||||||
qemuSnapshotDiskData *dd)
|
qemuSnapshotDiskData *dd,
|
||||||
|
virDomainAsyncJob asyncJob)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
virQEMUDriver *driver = priv->driver;
|
virQEMUDriver *driver = priv->driver;
|
||||||
@ -1451,6 +1453,11 @@ qemuSnapshotDiskUpdateSource(virDomainObj *vm,
|
|||||||
if (qemuSecurityMoveImageMetadata(driver, vm, dd->disk->src, dd->src) < 0)
|
if (qemuSecurityMoveImageMetadata(driver, vm, dd->disk->src, dd->src) < 0)
|
||||||
VIR_WARN("Unable to move disk metadata on vm %s", vm->def->name);
|
VIR_WARN("Unable to move disk metadata on vm %s", vm->def->name);
|
||||||
|
|
||||||
|
/* if the original image has a data-file turn it read-only */
|
||||||
|
if (dd->disk->src->dataFileStore) {
|
||||||
|
ignore_value(qemuBlockReopenReadOnly(vm, dd->disk->src->dataFileStore, asyncJob));
|
||||||
|
}
|
||||||
|
|
||||||
/* unlock the write lock on the original image as qemu will no longer write to it */
|
/* unlock the write lock on the original image as qemu will no longer write to it */
|
||||||
virDomainLockImageDetach(driver->lockManager, vm, dd->disk->src);
|
virDomainLockImageDetach(driver->lockManager, vm, dd->disk->src);
|
||||||
|
|
||||||
@ -1498,7 +1505,7 @@ qemuSnapshotDiskCreate(qemuSnapshotDiskContext *snapctxt)
|
|||||||
virDomainAuditDisk(snapctxt->vm, dd->disk->src, dd->src, "snapshot", rc >= 0);
|
virDomainAuditDisk(snapctxt->vm, dd->disk->src, dd->src, "snapshot", rc >= 0);
|
||||||
|
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
qemuSnapshotDiskUpdateSource(snapctxt->vm, dd);
|
qemuSnapshotDiskUpdateSource(snapctxt->vm, dd, snapctxt->asyncJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user