From 8d4e58c50163023a22fbba150cbd165048d3c97b Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 16 Jun 2016 20:08:53 -0400 Subject: [PATCH] cli: Add --disk backing_format= option --- man/virt-install.pod | 4 ++++ tests/cli-test-xml/compare/virt-install-many-devices.xml | 5 +++++ tests/clitest.py | 1 + virtinst/cli.py | 5 ++++- virtinst/devicedisk.py | 3 ++- virtinst/storage.py | 1 + 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/man/virt-install.pod b/man/virt-install.pod index dfbac82f..40e18449 100644 --- a/man/virt-install.pod +++ b/man/virt-install.pod @@ -622,6 +622,10 @@ and to avoid I/O errors in the guest should the host filesystem fill up. Path to a disk to use as the backing store for the newly created image. +=item B + +Disk image format of B + =item B The cache mode to be used. The host pagecache provides cache memory. diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml b/tests/cli-test-xml/compare/virt-install-many-devices.xml index c0b81a8c..94774b05 100644 --- a/tests/cli-test-xml/compare/virt-install-many-devices.xml +++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml @@ -140,6 +140,11 @@
+ + + + +
diff --git a/tests/clitest.py b/tests/clitest.py index 70f3dc8f..51c948b4 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -465,6 +465,7 @@ c.add_compare(""" \ --disk path=http://[1:2:3:4:1:2:3:4]:5522/my/path?query=foo \ --disk vol=gluster-pool/test-gluster.raw,startup_policy=optional \ --disk %(DIR)s,device=floppy,address.type=ccw,address.cssid=0xfe,address.ssid=0,address.devno=01 \ +--disk %(NEWIMG2)s,size=1,backing_store=/tmp/foo.img,backing_format=vmdk \ \ --network user,mac=12:34:56:78:11:22,portgroup=foo,link_state=down,rom_bar=on,rom_file=/tmp/foo \ --network bridge=foobar,model=virtio,driver_name=qemu,driver_queues=3 \ diff --git a/virtinst/cli.py b/virtinst/cli.py index d01fcb7b..cd1f18f7 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -1806,6 +1806,7 @@ class ParserDisk(VirtCLIParser): has_path = "path" in self.optdict backing_store = self.optdict.pop("backing_store", None) + backing_format = self.optdict.pop("backing_format", None) poolname = self.optdict.pop("pool", None) volname = self.optdict.pop("vol", None) size = parse_size(self.optdict.pop("size", None)) @@ -1859,7 +1860,8 @@ class ParserDisk(VirtCLIParser): fmt) vol_install = VirtualDisk.build_vol_install( self.guest.conn, newvolname, poolobj, size, sparse, - fmt=fmt, backing_store=backing_store) + fmt=fmt, backing_store=backing_store, + backing_format=backing_format) inst.set_vol_install(vol_install) if not inst.target: @@ -1875,6 +1877,7 @@ _add_device_address_args(ParserDisk) # These are all handled specially in _parse ParserDisk.add_arg(None, "backing_store", cb=ParserDisk.noset_cb) +ParserDisk.add_arg(None, "backing_format", cb=ParserDisk.noset_cb) ParserDisk.add_arg(None, "pool", cb=ParserDisk.noset_cb) ParserDisk.add_arg(None, "vol", cb=ParserDisk.noset_cb) ParserDisk.add_arg(None, "size", cb=ParserDisk.noset_cb) diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py index cbcfd945..2736c9a8 100644 --- a/virtinst/devicedisk.py +++ b/virtinst/devicedisk.py @@ -377,7 +377,7 @@ class VirtualDisk(VirtualDevice): @staticmethod def build_vol_install(conn, volname, poolobj, size, sparse, - fmt=None, backing_store=None): + fmt=None, backing_store=None, backing_format=None): """ Helper for building a StorageVolume instance to pass to VirtualDisk for eventual storage creation. @@ -412,6 +412,7 @@ class VirtualDisk(VirtualDevice): volinst.capacity = cap volinst.allocation = alloc volinst.backing_store = backing_store + volinst.backing_format = backing_format if fmt: if not volinst.supports_property("format"): diff --git a/virtinst/storage.py b/virtinst/storage.py index 801ce268..ebab016c 100644 --- a/virtinst/storage.py +++ b/virtinst/storage.py @@ -707,6 +707,7 @@ class StorageVolume(_StorageObject): format = XMLProperty("./target/format/@type", default_cb=_default_format) target_path = XMLProperty("./target/path") backing_store = XMLProperty("./backingStore/path") + backing_format = XMLProperty("./backingStore/format/@type") def _lazy_refcounts_default_cb(self): if self.format != "qcow2":