From e834d721cbe829b2f9b6c44c8aca8b4af5374cd3 Mon Sep 17 00:00:00 2001 From: Benny Zlotnik Date: Tue, 17 May 2022 16:50:15 +0300 Subject: [PATCH 1/2] core: use content type to determine memory disks Since we have the disk_content_type field we can use it to distinguish between the two memory related disks instead of checking the size. Signed-off-by: Benny Zlotnik --- .../java/org/ovirt/engine/core/bll/HibernateVmCommand.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java index 852c3c0009e..171a230bce8 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java @@ -27,6 +27,7 @@ import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType; import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.VMStatus; +import org.ovirt.engine.core.common.businessentities.storage.DiskContentType; import org.ovirt.engine.core.common.businessentities.storage.DiskImage; import org.ovirt.engine.core.common.errors.EngineException; import org.ovirt.engine.core.common.errors.EngineMessage; @@ -279,7 +280,7 @@ protected void endSuccessfully() { private DiskImage getMemoryDumpDisk(List returnValues) { for (ActionReturnValue returnValue : returnValues) { DiskImage disk = returnValue.getActionReturnValue(); - if (disk.getSize() != MemoryUtils.METADATA_SIZE_IN_BYTES) { + if (disk.getContentType() == DiskContentType.MEMORY_DUMP_VOLUME) { return disk; } } @@ -290,7 +291,7 @@ private DiskImage getMemoryDumpDisk(List returnValues) { private DiskImage getMemoryMetadataDisk(List returnValues) { for (ActionReturnValue returnValue : returnValues) { DiskImage disk = returnValue.getActionReturnValue(); - if (disk.getSize() == MemoryUtils.METADATA_SIZE_IN_BYTES) { + if (disk.getContentType() == DiskContentType.MEMORY_METADATA_VOLUME) { return disk; } } From e03dcb58472b264489365f95e83783fe58e9bcfb Mon Sep 17 00:00:00 2001 From: Benny Zlotnik Date: Wed, 13 Apr 2022 13:35:32 +0300 Subject: [PATCH 2/2] core: always update volume size when creating a new image Vdsm often aligns the size of the volume when creating, and the volume will end up having a different size in the engine than what is on the storage. This is already handled when a new disk is created but not when a new snapshot is created. Since there is already a getVolumeInfo request at the end of snapshot creation, we can use this opportunity to update the size of the volume as well. Bug-Url: https://bugzilla.redhat.com/1852308 Signed-off-by: Benny Zlotnik --- .../engine/core/bll/storage/disk/image/BaseImagesCommand.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/BaseImagesCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/BaseImagesCommand.java index 489276eb88e..a8e4022dee4 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/BaseImagesCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/disk/image/BaseImagesCommand.java @@ -384,6 +384,9 @@ protected void endSuccessfully() { newStorageDomainID, getDestinationDiskImage()); } + + // Update image's size if it's changed + getDestinationDiskImage().setSize(newImageIRS.getSize()); } } catch (EngineException e) { // Logging only