diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 94e5672ed8..83abad251e 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -6389,8 +6389,9 @@ virDomainBlockPeek(virDomainPtr dom, * to the next alignment boundary. * * If @flag contains VIR_DOMAIN_BLOCK_RESIZE_CAPACITY (since 10.0.0) the - * hypervisor will resize the guest block device to fully fill the source, - * ignoring @size. This is possible only for image formats with no metadata + * hypervisor will resize the guest block device to fully fill the source. + * @size must be either set to zero, or to the exact size of the block + * device source. This is possible only for image formats with no metadata * ('raw') and for source devices with limited capacity such as block devices. * * The @disk parameter is either an unambiguous source name of the diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ee7774f115..448e6b1591 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9324,7 +9324,14 @@ qemuDomainBlockResize(virDomainPtr dom, goto endjob; } - size = disk->src->physical; + if (size == 0) { + size = disk->src->physical; + } else if (size != disk->src->physical) { + virReportError(VIR_ERR_INVALID_ARG, + _("Requested resize to '%1$llu' but device size is '%2$llu'"), + size, disk->src->physical); + goto endjob; + } } /* qcow2 and qed must be sized on 512 byte blocks/sectors,