On a Thursday in 2023, Peter Krempa wrote:
Until now resizing a disk with a storage slice would break in one of
the
following ways:
1) for a non-raw format, the virtual size would change, but the slice
would still remain in place
2) for raw disks qemu would refuse to change the size
The only reasonable scenario we want to support is a 'raw' image with 0
offset (inside a block device), where we can just drop the slice.
Anything else comes from a non-standard storage setup that we don't want
to touch.
To facilitate the resize, we first remove the 'size' parameter in qemu
thus dropping the slice and then instructing qemu to resize the disk.
Resolves:
https://issues.redhat.com/browse/RHEL-18782
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_block.c | 65 +++++++++++++++++++++++++++++++++++
src/qemu/qemu_block.h | 4 +++
src/qemu/qemu_driver.c | 77 ++++++++++++++++++++++++++++++++++++++----
3 files changed, 139 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 8e2da95139..db620bf836 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -3265,6 +3265,71 @@ qemuBlockStorageSourceIsRaw(const virStorageSource *src)
}
+/**
+ * qemuBlockReopenSliceExpand:
+ * @vm: domain object
+ * @src: storage source to reopen
+ *
+ * Reopen @src image to remove it's storage slice. Note that this currently
*its
+ * works only for 'raw' disks.
+ *
+ * Note: This changes transforms the definition such that the 'raw' driver
+ * becomes the 'format' layer rather than the 'slice' layer, to be
able
+ * to free the slice definition.
+ */
+int
+qemuBlockReopenSliceExpand(virDomainObj *vm,
+ virStorageSource *src)
...
@@ -9319,6 +9328,55 @@ qemuDomainBlockResize(virDomainPtr dom,
...
+ /* trying to resize a block device to a size not equal to the
actual
+ * size of the block device will cause qemu to fail */
+ if (virStorageSourceIsBlockLocal(disk->src) &&
+ disk->src->physical != size) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+ _("block device backed disk must be resized to it's
actual size '%1$llu'"),
*its
+ disk->src->physical);
+ goto endjob;
+ }
+
Jano