From 060d4ec6a0e40c8391105c46ad31dd000435eb93 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 11 Jul 2017 08:23:38 +0200 Subject: [PATCH] qemu: blockcopy: Explicitly assert 'reuse' for block devices When copying to a block device, the block device will already exist. To allow users using a block device without any preparation, they need to use the block copy without VIR_DOMAIN_BLOCK_COPY_REUSE_EXT. This means that if the target is an existing block device we don't need to prepare it, but we can't reject it as being existing. To avoid breaking this feature, explicitly assume that existing block devices will be reused even without that flag explicitly specified, while skipping attempts to create it. qemuMonitorDriveMirror still needs to honor the flag as specified by the user, since qemu overwrites the metadata otherwise. --- src/qemu/qemu_driver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index eb02bb3633..3ab31764c5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16811,6 +16811,10 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, disk->dst, mirror->path); goto endjob; } + } else { + /* if the target is a block device, assume that we are reusing it, so + * there are no attempts to create it */ + reuse = true; } if (!mirror->format) { @@ -16850,6 +16854,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, /* Actually start the mirroring */ qemuDomainObjEnterMonitor(driver, vm); + /* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specified + * by the user regardless of how @reuse was modified */ ret = qemuMonitorDriveMirror(priv->mon, device, mirror->path, format, bandwidth, granularity, buf_size, flags); virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >= 0);