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

[virt-tools-list] [python-virtinst PATCH] Add basic support for VDI images.



Handling of VDI images is fully supported in QEMU, for example, but we
still disallow using 'vdi' as a disk type.
---
 virtconv/diskcfg.py           |  5 +++++
 virtconv/parsers/virtimage.py |  2 ++
 virtinst/ImageParser.py       | 10 ++++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/virtconv/diskcfg.py b/virtconv/diskcfg.py
index 978ecb1..3fbed4f 100644
--- a/virtconv/diskcfg.py
+++ b/virtconv/diskcfg.py
@@ -1,4 +1,5 @@
 #
+# Copyright 2013 Red Hat, Inc.
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
@@ -35,6 +36,7 @@ DISK_FORMAT_VDISK = 3
 DISK_FORMAT_QCOW = 4
 DISK_FORMAT_QCOW2 = 5
 DISK_FORMAT_COW = 6
+DISK_FORMAT_VDI = 7

 DISK_TYPE_DISK = 0
 DISK_TYPE_CDROM = 1
@@ -50,6 +52,7 @@ disk_suffixes = {
     DISK_FORMAT_QCOW: ".qcow",
     DISK_FORMAT_QCOW2: ".qcow2",
     DISK_FORMAT_COW: ".cow",
+    DISK_FORMAT_VDI: ".vdi",
 }

 qemu_formats = {
@@ -59,6 +62,7 @@ qemu_formats = {
     DISK_FORMAT_QCOW: "qcow",
     DISK_FORMAT_QCOW2: "qcow2",
     DISK_FORMAT_COW: "cow",
+    DISK_FORMAT_VDI: "vdi",
 }

 disk_format_names = {
@@ -69,6 +73,7 @@ disk_format_names = {
     "qcow": DISK_FORMAT_QCOW,
     "qcow2": DISK_FORMAT_QCOW2,
     "cow": DISK_FORMAT_COW,
+    "vdi": DISK_FORMAT_VDI,
 }

 checksum_types = {
diff --git a/virtconv/parsers/virtimage.py b/virtconv/parsers/virtimage.py
index 7a561cf..15a9cd6 100644
--- a/virtconv/parsers/virtimage.py
+++ b/virtconv/parsers/virtimage.py
@@ -1,4 +1,5 @@
 #
+# Copyright 2013 Red Hat, Inc.
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
@@ -246,6 +247,7 @@ class virtimage_parser(formats.parser):
                 ImageParser.Disk.FORMAT_VMDK: diskcfg.DISK_FORMAT_VMDK,
                 ImageParser.Disk.FORMAT_QCOW: diskcfg.DISK_FORMAT_QCOW,
                 ImageParser.Disk.FORMAT_QCOW2: diskcfg.DISK_FORMAT_QCOW2,
+                ImageParser.Disk.FORMAT_VDI: diskcfg.DISK_FORMAT_VDI,
             }

             fmt = None
diff --git a/virtinst/ImageParser.py b/virtinst/ImageParser.py
index 8b37078..ea074cf 100644
--- a/virtinst/ImageParser.py
+++ b/virtinst/ImageParser.py
@@ -1,7 +1,7 @@
 # Sample code to parse an image XML description and
 # spit out libvirt XML; will be hooked into virt-install
 #
-# Copyright 2007  Red Hat, Inc.
+# Copyright 2007, 2013  Red Hat, Inc.
 # David Lutterkort <dlutter redhat com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -205,6 +205,7 @@ class Disk:
     FORMAT_QCOW = "qcow"
     FORMAT_QCOW2 = "qcow2"
     FORMAT_VMDK = "vmdk"
+    FORMAT_VDI = "vdi"

     USE_SYSTEM = "system"
     USE_USER = "user"
@@ -231,7 +232,12 @@ class Disk:
             csumtype = xpathString(d, "@type")
             csumvalue = xpathString(d, "")
             self.csum[csumtype] = csumvalue
-        formats = [Disk.FORMAT_RAW, Disk.FORMAT_QCOW, Disk.FORMAT_QCOW2, Disk.FORMAT_VMDK, Disk.FORMAT_ISO]
+        formats = [Disk.FORMAT_RAW,
+                   Disk.FORMAT_QCOW,
+                   Disk.FORMAT_QCOW2,
+                   Disk.FORMAT_VMDK,
+                   Disk.FORMAT_ISO,
+                   Disk.FORMAT_VDI]
         validate(formats.count(self.format) > 0,
                  _("The format for disk %s must be one of %s") %
                  (self.file, ",".join(formats)))
-- 
1.8.1.2


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