Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 250aa88

Browse files
mkletzancrobinso
authored andcommitted
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.
1 parent 0ac0616 commit 250aa88

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

virtconv/diskcfg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#
2+
# Copyright 2013 Red Hat, Inc.
23
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
34
# Use is subject to license terms.
45
#
@@ -35,6 +36,7 @@
3536
DISK_FORMAT_QCOW = 4
3637
DISK_FORMAT_QCOW2 = 5
3738
DISK_FORMAT_COW = 6
39+
DISK_FORMAT_VDI = 7
3840

3941
DISK_TYPE_DISK = 0
4042
DISK_TYPE_CDROM = 1
@@ -50,6 +52,7 @@
5052
DISK_FORMAT_QCOW: ".qcow",
5153
DISK_FORMAT_QCOW2: ".qcow2",
5254
DISK_FORMAT_COW: ".cow",
55+
DISK_FORMAT_VDI: ".vdi",
5356
}
5457

5558
qemu_formats = {
@@ -59,6 +62,7 @@
5962
DISK_FORMAT_QCOW: "qcow",
6063
DISK_FORMAT_QCOW2: "qcow2",
6164
DISK_FORMAT_COW: "cow",
65+
DISK_FORMAT_VDI: "vdi",
6266
}
6367

6468
disk_format_names = {
@@ -69,6 +73,7 @@
6973
"qcow": DISK_FORMAT_QCOW,
7074
"qcow2": DISK_FORMAT_QCOW2,
7175
"cow": DISK_FORMAT_COW,
76+
"vdi": DISK_FORMAT_VDI,
7277
}
7378

7479
checksum_types = {

virtconv/parsers/virtimage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#
2+
# Copyright 2013 Red Hat, Inc.
23
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
34
# Use is subject to license terms.
45
#
@@ -246,6 +247,7 @@ def import_file(input_file):
246247
ImageParser.Disk.FORMAT_VMDK: diskcfg.DISK_FORMAT_VMDK,
247248
ImageParser.Disk.FORMAT_QCOW: diskcfg.DISK_FORMAT_QCOW,
248249
ImageParser.Disk.FORMAT_QCOW2: diskcfg.DISK_FORMAT_QCOW2,
250+
ImageParser.Disk.FORMAT_VDI: diskcfg.DISK_FORMAT_VDI,
249251
}
250252

251253
fmt = None

virtinst/ImageParser.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Sample code to parse an image XML description and
22
# spit out libvirt XML; will be hooked into virt-install
33
#
4-
# Copyright 2007 Red Hat, Inc.
4+
# Copyright 2007, 2013 Red Hat, Inc.
55
# David Lutterkort <dlutter@redhat.com>
66
#
77
# This program is free software; you can redistribute it and/or modify
@@ -205,6 +205,7 @@ class Disk:
205205
FORMAT_QCOW = "qcow"
206206
FORMAT_QCOW2 = "qcow2"
207207
FORMAT_VMDK = "vmdk"
208+
FORMAT_VDI = "vdi"
208209

209210
USE_SYSTEM = "system"
210211
USE_USER = "user"
@@ -231,7 +232,12 @@ def parseXML(self, node):
231232
csumtype = xpathString(d, "@type")
232233
csumvalue = xpathString(d, "")
233234
self.csum[csumtype] = csumvalue
234-
formats = [Disk.FORMAT_RAW, Disk.FORMAT_QCOW, Disk.FORMAT_QCOW2, Disk.FORMAT_VMDK, Disk.FORMAT_ISO]
235+
formats = [Disk.FORMAT_RAW,
236+
Disk.FORMAT_QCOW,
237+
Disk.FORMAT_QCOW2,
238+
Disk.FORMAT_VMDK,
239+
Disk.FORMAT_ISO,
240+
Disk.FORMAT_VDI]
235241
validate(formats.count(self.format) > 0,
236242
_("The format for disk %s must be one of %s") %
237243
(self.file, ",".join(formats)))

0 commit comments

Comments
 (0)