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

Re: [libvirt] bug: try to take disk snapshot for LVM2 Volume



> On 11/06/2011 09:14 PM, MATSUDA, Daiki wrote:
>> I made the patch for the problem to take the snapshot but qcow2. It use
>> the 'qemu-img' command, I know that it is not essential solution. But I
>> think it is better than to link qemu's libraries.
>>
>> Regards
> 
>> @@ -9002,6 +9021,13 @@ qemuDomainSnapshotCreateSingleDiskActive
>>            return -1;
>>        }
>>
>> +    ret = qemuDomainSnapshotCheckSrcQcow2(src->disk);
>> +    if (ret) {
>> +        qemuReportError(VIR_ERR_INTERNAL_ERROR,
>> +                        "%s", _("src image is not qcow2 format"));
>> +        return ret;
>> +    }
> 
> NACK.  There is nothing inherently wrong with the source file not being
> a qcow2 file.  The whole point of creating a runtime snapshot is that
> the original file (of _any_ format) becomes the backing file of a new
> qcow2 file, so that the original file now serves as the snapshot.
> Forbidding a live snapshot of a raw source file interferes with this intent.
> 

I have some tested since you replied. Certainly other image file, e.g.
raw type, has no problem after snapshot is taken in qcow2 format.

But in the case that direct disk block, e.g. /dev/sdc, is given for the
guest OS, the same error occurs. It may not be accepted by qemu-kvm.

I do not understand which qemu-kvm or libvirt should be fixed. But at
least libvirt should be stop to take snapshot for block device with
following patch.

Regards
MATSUDA Daiki
--- libvirt-0.9.7.orig/src/qemu/qemu_driver.c	2011-11-03 23:48:23.000000000 +0900
+++ libvirt-0.9.7/src/qemu/qemu_driver.c	2011-11-14 12:56:51.870453885 +0900
@@ -9025,6 +9025,7 @@ qemuDomainSnapshotCreateSingleDiskActive
     char *origsrc = NULL;
     char *origdriver = NULL;
     bool need_unlink = false;
+    struct stat sb;
 
     if (snap->snapshot != VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL) {
         qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -9032,6 +9033,17 @@ qemuDomainSnapshotCreateSingleDiskActive
         return -1;
     }
 
+    if (stat(disk->src, &sb) < 0) {
+        virReportSystemError(errno,
+                             _("unable to stat for disk %s"),
+                             disk->src);
+    }
+    if (S_ISBLK(sb.st_mode)) {
+        qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                        "%s", _("src image is Block Device"));
+        return -1;
+    }
+
     if (virAsprintf(&device, "drive-%s", disk->info.alias) < 0 ||
         !(source = strdup(snap->file)) ||
         (STRNEQ_NULLABLE(disk->driverType, "qcow2") &&

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