[libvirt] [PATCHv2] qemu: blockCopy: Allow reuse of raw image for shallow block copy

The documentation states that for shallow block copy the image has to have the same guest visible content as backing file of the current image if the file is being reused. This condition can be achieved also with a raw file (or a qcow without a backing file) so remove the condition that would disallow it. (This patch additionally fixes crash described in https://bugzilla.redhat.com/show_bug.cgi?id=1215569 ) --- V2: - different approach to fix Eric's comment src/qemu/qemu_driver.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 80463f2..581211a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17122,11 +17122,17 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0) goto endjob; + /* clear the _SHALLOW flag if there is only one layer */ + if (!disk->src->backingStore) + flags &= ~VIR_DOMAIN_BLOCK_COPY_SHALLOW; + + /* unless the user provides a pre-created file, shallow copy into a raw + * file is not possible */ if ((flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW) && - mirror->format == VIR_STORAGE_FILE_RAW && - disk->src->backingStore->path) { + !(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT) && + mirror->format == VIR_STORAGE_FILE_RAW) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk '%s' has backing file, so raw shallow copy " + _("shallow copy of disk '%s' into a raw file " "is not possible"), disk->dst); goto endjob; -- 2.3.5

On 04/28/2015 09:53 AM, Peter Krempa wrote:
The documentation states that for shallow block copy the image has to have the same guest visible content as backing file of the current image if the file is being reused. This condition can be achieved also with a raw file (or a qcow without a backing file) so remove the condition that would disallow it.
(This patch additionally fixes crash described in https://bugzilla.redhat.com/show_bug.cgi?id=1215569 ) --- V2: - different approach to fix Eric's comment
src/qemu/qemu_driver.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
ACK; and I think it qualifies as a bug fix so safe for freeze. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Tue, Apr 28, 2015 at 20:43:47 -0600, Eric Blake wrote:
On 04/28/2015 09:53 AM, Peter Krempa wrote:
The documentation states that for shallow block copy the image has to have the same guest visible content as backing file of the current image if the file is being reused. This condition can be achieved also with a raw file (or a qcow without a backing file) so remove the condition that would disallow it.
(This patch additionally fixes crash described in https://bugzilla.redhat.com/show_bug.cgi?id=1215569 ) --- V2: - different approach to fix Eric's comment
src/qemu/qemu_driver.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
ACK; and I think it qualifies as a bug fix so safe for freeze.
Pushed; Thanks. Peter
participants (2)
-
Eric Blake
-
Peter Krempa