Hi, Eric. > On 09/29/2011 11:26 PM, MATSUDA, Daiki wrote: >> I tried the new snapshot function implemented by Eric Blake. >> >> It works very well for QCOW2 disk image system. >> But I often use LVM2 volume for QEMU virtual machines and tried to take >> disk snapshot by virsh command ( snapshot-create DOMNAME --disk-only). >> So, finally qemu monitor command 'snapshot_blkdev' accepts the LVM2 >> volume and create QCOW2 snapshot image. In addition, domain's >> configuration file is replaced to use snapshot disk image instead of >> LVM2 volume. > > It sounds like virsh did what it was told, but that you told it so > little information that it had to fill in the gaps and choose its own > destination file name (hence the .1317357844 suffix after the action). > Your situation sounds like a case where you may want a bit more control > over the destination file name. 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 MATSUDA Daiki
diff -uNrp libvirt-0.9.7.orig/src/qemu/qemu_driver.c libvirt-0.9.7/src/qemu/qemu_driver.c --- libvirt-0.9.7.orig/src/qemu/qemu_driver.c 2011-10-31 12:46:04.000000000 +0900 +++ libvirt-0.9.7/src/qemu/qemu_driver.c 2011-11-07 13:03:07.162639142 +0900 @@ -8976,6 +8976,25 @@ cleanup: return ret; } +static int ATTRIBUTE_NONNULL(1) +qemuDomainSnapshotCheckSrcQcow2(const char *src) +{ + const char *qemuimgarg[] = {NULL, "check", "-f", "qcow2", NULL, NULL}; + int ret = -1; + + qemuimgarg[0] = virFindFileInPath("qemu-img"); + if (!qemuimgarg[0]) { + qemuReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("unable to find qemu-img")); + return ret; + } + qemuimgarg[4] = src; + + ret = virRun(qemuimgarg, NULL); + VIR_FREE(qemuimgarg[0]); + return ret; +} + /* The domain is expected to hold monitor lock. */ static int qemuDomainSnapshotCreateSingleDiskActive(struct qemud_driver *driver, @@ -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; + } + if (virAsprintf(&device, "drive-%s", disk->info.alias) < 0 || !(source = strdup(snap->file)) || (STRNEQ_NULLABLE(disk->driverType, "qcow2") &&
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list