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

[libvirt] [PATCH v2 4/6] qemu: add support for running domains with qcow3 images



Translate the 'qcow3' format to 'qcow2' driver when dealing with qemu.
This allows running domains with qcow3 images and creating internal
snapshots.
---
 docs/schemas/domaincommon.rng | 1 +
 src/libvirt_private.syms      | 1 +
 src/qemu/qemu_command.c       | 2 +-
 src/qemu/qemu_driver.c        | 3 ++-
 src/qemu/qemu_hotplug.c       | 4 ++--
 src/util/virstoragefile.c     | 8 ++++++++
 src/util/virstoragefile.h     | 1 +
 7 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 049f232..39c4cac 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1263,6 +1263,7 @@
       <value>iso</value>
       <value>qcow</value>
       <value>qcow2</value>
+      <value>qcow3</value>
       <value>qed</value>
       <value>vmdk</value>
       <value>vpc</value>
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c589236..4504ccd 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1168,6 +1168,7 @@ virStorageGenerateQcowPassphrase;
 
 # storage_file.h
 virStorageFileChainLookup;
+virStorageFileFormatToStringQemu;
 virStorageFileFormatTypeFromString;
 virStorageFileFormatTypeToString;
 virStorageFileFreeMetadata;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f6273c1..fc76a35 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2440,7 +2440,7 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
         disk->type != VIR_DOMAIN_DISK_TYPE_DIR &&
         qemuCapsGet(caps, QEMU_CAPS_DRIVE_FORMAT))
         virBufferAsprintf(&opt, ",format=%s",
-                          virStorageFileFormatTypeToString(disk->format));
+                          virStorageFileFormatToStringQemu(disk->format));
 
     /* generate geometry command string */
     if (disk->geometry.cylinders > 0 &&
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 812bf95..79f78fa 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10735,7 +10735,8 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def,
                 break;
             }
             if (vm->def->disks[i]->format > 0 &&
-                vm->def->disks[i]->format != VIR_STORAGE_FILE_QCOW2) {
+                vm->def->disks[i]->format != VIR_STORAGE_FILE_QCOW2 &&
+                vm->def->disks[i]->format != VIR_STORAGE_FILE_QCOW3) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("internal snapshot for disk %s unsupported "
                                  "for storage type %s"),
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 18c4109..35fad91 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -134,9 +134,9 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
 
         if (disk->type != VIR_DOMAIN_DISK_TYPE_DIR) {
             if (disk->format > 0)
-                format = virStorageFileFormatTypeToString(disk->format);
+                format = virStorageFileFormatToStringQemu(disk->format);
             else if (origdisk->format > 0)
-                format = virStorageFileFormatTypeToString(origdisk->format);
+                format = virStorageFileFormatToStringQemu(origdisk->format);
         }
         ret = qemuMonitorChangeMedia(priv->mon,
                                      driveAlias,
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index c74a8fd..1d6a13e 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1474,3 +1474,11 @@ error:
         *meta = NULL;
     return NULL;
 }
+
+const char *virStorageFileFormatToStringQemu(enum virStorageFileFormat format)
+{
+    if (format == VIR_STORAGE_FILE_QCOW3)
+        return virStorageFileFormatTypeToString(VIR_STORAGE_FILE_QCOW2);
+    else
+        return virStorageFileFormatTypeToString(format);
+}
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 88b3b6f..f765e71 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -117,5 +117,6 @@ int virStorageFileGetLVMKey(const char *path,
                             char **key);
 int virStorageFileGetSCSIKey(const char *path,
                              char **key);
+const char *virStorageFileFormatToStringQemu(enum virStorageFileFormat format);
 
 #endif /* __VIR_STORAGE_FILE_H__ */
-- 
1.7.12.4


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