cli: Add --disk backing_format= option

This commit is contained in:
Cole Robinson 2016-06-16 20:08:53 -04:00
parent 5cd1b57852
commit 8d4e58c501
6 changed files with 17 additions and 2 deletions

View File

@ -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<backing_format>
Disk image format of B<backing_store>
=item B<cache>
The cache mode to be used. The host pagecache provides cache memory.

View File

@ -140,6 +140,11 @@
<target dev="fda" bus="fdc"/>
<address type="ccw" cssid="0xfe" ssid="0" devno="01"/>
</disk>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"/>
<source file="/dev/default-pool/new2.img"/>
<target dev="vdm" bus="virtio"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1">
<address type="pci" domain="0" bus="0" slot="4" function="7"/>
</controller>

View File

@ -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 \

View File

@ -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)

View File

@ -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"):

View File

@ -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":