[libvirt] [PATCH] blockcopy: check dst = identical device
Kashyap Chamarthy
kchamart at redhat.com
Tue Jul 29 10:23:30 UTC 2014
On Tue, Jul 29, 2014 at 05:59:32PM +0800, 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.
True, I can't think of any useful reason to have dst and src be same
device, except for a negative test case.
> 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)) {
> + virReportError(VIR_ERR_INVALID_ARG,
> + _("destination '%s' is the same as disk '%s' source"),
> + dest, path);
> + goto endjob;
> + }
> +
> if (stat(dest, &st) < 0) {
> if (errno != ENOENT) {
> virReportSystemError(errno, _("unable to stat for disk %s: %s"),
> --
> 1.8.4.5
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
/kashyap
More information about the libvir-list
mailing list