[libvirt] [PATCH] blockcopy: check dst = identical device

Eric Blake eblake at redhat.com
Tue Jul 29 13:37:22 UTC 2014


On 07/29/2014 03:59 AM, Chunyan Liu wrote:
> Check whether dst is the same device as source, if yes, report
> error and exit.
> 
> Currently if dst is the same device as source, blockcopy is still
> going and qemu 'drive-mirror' is executed. Considering that:
> a). blockcopy to the same device is meaningless. b.) result is
> unexpected. (tested with block device whose source path is /dev/sdaX,
> after blockcopy, shutdown VM and then create VM from xml again, the
> VM cannot be started.) This case should not be allowed.
> 
> Signed-off-by: Chunyan Liu <cyliu at suse.com>
> ---
>  src/qemu/qemu_driver.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 704ba39..87a3790 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -15309,6 +15309,13 @@ qemuDomainBlockCopy(virDomainObjPtr vm,
>      }
>  
>      /* Prepare the destination file.  */
> +    if (STREQ(disk->src->path, dest)) {

STREQ is too weak (consider symlinks, or even "a/b" vs. "a//b").  It
will catch some cases, but not all.

I don't know that we can reliably detect all possible ways the user can
shoot themselves in the foot, so I'm not sure this patch is a good idea.


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 539 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140729/aa5bcd11/attachment-0001.sig>


More information about the libvir-list mailing list