[PATCH] blockcopy: check dst = identical device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]