cli: Add --disk type= support

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-01-29 19:17:54 -05:00
parent 8c0704a921
commit 82be5dccad
3 changed files with 12 additions and 0 deletions

View File

@ -222,6 +222,11 @@
<source dev="/dev/disk-pool/disk"/>
<target dev="vdq" bus="virtio"/>
</disk>
<disk type="dir" device="disk">
<driver name="qemu" type="qcow2"/>
<source dir="/dev/default-pool/testvol1.img"/>
<target dev="vdr" 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

@ -616,6 +616,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
--disk vol=iscsi-direct/unit:0:0:1
--disk size=.0001,format=raw
--disk size=.0001,pool=disk-pool
--disk path=%(EXISTIMG1)s,type=dir
--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,filterref=foobar,rom.bar=off,rom.file=/some/rom,source.portgroup=foo

View File

@ -3087,6 +3087,7 @@ class ParserDisk(VirtCLIParser):
fmt = self.optdict.pop("format", None)
sparse = _on_off_convert("sparse", self.optdict.pop("sparse", "yes"))
convert_perms(self.optdict.pop("perms", None))
disktype = self.optdict.pop("type", None)
if volname:
if volname.count("/") != 1:
@ -3096,6 +3097,9 @@ class ParserDisk(VirtCLIParser):
log.debug("Parsed --disk volume as: pool=%s vol=%s",
poolname, volname)
# Set this up front, it has lots of follow on effects
if disktype:
inst.type = disktype
super()._parse(inst)
if (size and
@ -3165,6 +3169,8 @@ class ParserDisk(VirtCLIParser):
cls.add_arg("size", None, lookup_cb=None, cb=cls.noset_cb)
cls.add_arg("format", None, lookup_cb=None, cb=cls.noset_cb)
cls.add_arg("sparse", None, lookup_cb=None, cb=cls.noset_cb)
cls.add_arg("type", None, lookup_cb=None, cb=cls.noset_cb)
# These are handled in _add_advertised_aliases
cls.add_arg("bus", "bus", cb=cls.noset_cb)
cls.add_arg("cache", "driver_cache", cb=cls.noset_cb)