summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2014-01-24 19:05:04 -0500
committerCole Robinson <crobinso@redhat.com>2014-01-25 17:20:29 -0500
commitec359fd5b2f2c2d671fde81bafbe99145bd6ef10 (patch)
treed4adc43957d9b0db1f6ac1b2cc3032f5157c5e18
parent7ba76b5748ff45157c0a98c784a0450b666a19df (diff)
downloadvirt-manager-ec359fd5b2f2c2d671fde81bafbe99145bd6ef10.tar.gz
cli: Add --disk readonly and shareable options
This deprecates the difficult perms= sub option
-rw-r--r--man/virt-install.pod9
-rw-r--r--tests/cli-test-xml/compare/many-devices.xml4
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-all.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-neg-num.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-pos-num.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-select-disk-path.xml13
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-select-network-mac.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-select-sound-model.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-channel.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-console.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-controller.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-filesystem.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-graphics.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-host-device.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-memballoon.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-network.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-parallel.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-redirdev.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-rng.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-security.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-serial.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-smartcard.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-soundhw.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-tpm.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-video.xml2
-rw-r--r--tests/cli-test-xml/compare/virtxml-edit-simple-watchdog.xml2
-rw-r--r--tests/clitest.py1
-rw-r--r--tests/testdriver.xml1
-rwxr-xr-xvirt-xml2
-rw-r--r--virtinst/cli.py78
30 files changed, 89 insertions, 65 deletions
diff --git a/man/virt-install.pod b/man/virt-install.pod
index 37bb7479..568ba461 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -481,10 +481,13 @@ bus types.
Sets the removable flag (/sys/block/$dev/removable on Linux). Only
used with QEMU and bus=usb. Value can be 'on' or 'off'.
-=item B<perms>
+=item B<readonly>
-Disk permissions. Value can be 'rw' (Read/Write), 'ro' (Readonly),
-or 'sh' (Shared Read/Write). Default is 'rw'
+Set drive as readonly (takes 'on' or 'off')
+
+=item B<shareable>
+
+Set drive as shareable (takes 'on' or 'off')
=item B<size>
diff --git a/tests/cli-test-xml/compare/many-devices.xml b/tests/cli-test-xml/compare/many-devices.xml
index 17b64855..40a49edd 100644
--- a/tests/cli-test-xml/compare/many-devices.xml
+++ b/tests/cli-test-xml/compare/many-devices.xml
@@ -34,8 +34,8 @@
<driver cache="writeback" io="threads"/>
<source file="/dev/default-pool/UPPER"/>
<target dev="hda" bus="ide"/>
- <shareable/>
<serial>WD-WMAP9A966149</serial>
+ <shareable/>
</disk>
<disk type="file" device="disk">
<driver error_policy="enospace"/>
@@ -141,8 +141,8 @@
<driver cache="writeback" io="threads"/>
<source file="/dev/default-pool/UPPER"/>
<target dev="hda" bus="ide"/>
- <shareable/>
<serial>WD-WMAP9A966149</serial>
+ <shareable/>
</disk>
<disk type="file" device="disk">
<driver error_policy="enospace"/>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-all.xml b/tests/cli-test-xml/compare/virtxml-edit-all.xml
index f239b0fd..111ae7f9 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-all.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-all.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -265,21 +265,25 @@
+@@ -266,21 +266,25 @@
<vendor id="0x04b3"/>
<product id="0x4485"/>
</source>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-neg-num.xml b/tests/cli-test-xml/compare/virtxml-edit-neg-num.xml
index aea38550..250e4cb7 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-neg-num.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-neg-num.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -258,7 +258,7 @@
+@@ -259,7 +259,7 @@
<model type="vmvga" vram="9216" heads="1"/>
</video>
<video>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-pos-num.xml b/tests/cli-test-xml/compare/virtxml-edit-pos-num.xml
index 10a64999..a8dae71d 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-pos-num.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-pos-num.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -253,7 +253,7 @@
+@@ -254,7 +254,7 @@
</graphics>
<sound model="sb16"/>
<sound model="es1370"/>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-select-disk-path.xml b/tests/cli-test-xml/compare/virtxml-edit-select-disk-path.xml
new file mode 100644
index 00000000..88f7b138
--- /dev/null
+++ b/tests/cli-test-xml/compare/virtxml-edit-select-disk-path.xml
@@ -0,0 +1,13 @@
+--- Original XML
++++ Altered XML
+@@ -88,7 +88,7 @@
+ <driver name="qemu" type="qcow2" cache="none"/>
+ <source file="/tmp/foobar2"/>
+ <target dev="vdc" bus="virtio"/>
+- <shareable/>
++ <readonly/>
+ </disk>
+ <disk type="block" device="disk">
+ <source dev="/dev/default-pool/overlay.img"/>
+
+Domain 'test-many-devices' defined successfully. \ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virtxml-edit-select-network-mac.xml b/tests/cli-test-xml/compare/virtxml-edit-select-network-mac.xml
index 2d1fe324..fc884b59 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-select-network-mac.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-select-network-mac.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -159,7 +159,7 @@
+@@ -160,7 +160,7 @@
<interface type="ethernet">
<mac address="00:11:7f:33:44:55"/>
<script path="/etc/qemu-ifup"/>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-select-sound-model.xml b/tests/cli-test-xml/compare/virtxml-edit-select-sound-model.xml
index 10a64999..a8dae71d 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-select-sound-model.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-select-sound-model.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -253,7 +253,7 @@
+@@ -254,7 +254,7 @@
</graphics>
<sound model="sb16"/>
<sound model="es1370"/>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-channel.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-channel.xml
index 59738b52..f92912d6 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-channel.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-channel.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -214,7 +214,7 @@
+@@ -215,7 +215,7 @@
<console type="pty">
<target type="uml" port="1"/>
</console>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-console.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-console.xml
index a496d452..8adc1d9c 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-console.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-console.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -209,7 +209,7 @@
+@@ -210,7 +210,7 @@
<target port="2"/>
</parallel>
<console type="pty">
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-controller.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-controller.xml
index b59e93da..fba22d62 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-controller.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-controller.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -98,7 +98,7 @@
+@@ -99,7 +99,7 @@
<source file="/tmp/foobar4"/>
<target dev="xvdc" bus="xen"/>
</disk>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-filesystem.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-filesystem.xml
index 720cb540..f92fb0a8 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-filesystem.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-filesystem.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -105,10 +105,10 @@
+@@ -106,10 +106,10 @@
<controller type="virtio-serial" index="1"/>
<controller type="virtio-serial" index="0"/>
<controller type="ccid" index="0"/>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-graphics.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-graphics.xml
index 139f7c9b..792b823f 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-graphics.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-graphics.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -238,7 +238,7 @@
+@@ -239,7 +239,7 @@
</backend>
</tpm>
<input type="mouse" bus="ps2"/>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-host-device.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-host-device.xml
index eef05b17..65d60883 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-host-device.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-host-device.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -262,9 +262,10 @@
+@@ -263,9 +263,10 @@
</video>
<hostdev mode="subsystem" type="usb" managed="yes">
<source>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-memballoon.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-memballoon.xml
index e38ec27c..f8c52e6d 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-memballoon.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-memballoon.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -293,7 +293,7 @@
+@@ -294,7 +294,7 @@
<usbdev allow="no"/>
</redirfilter>
<watchdog model="ib700" action="poweroff"/>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-network.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-network.xml
index 288f9061..32ad6f62 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-network.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-network.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -124,11 +124,10 @@
+@@ -125,11 +125,10 @@
<source dir="/foo/bar"/>
<target dir="/bar/baz"/>
</filesystem>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-parallel.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-parallel.xml
index 2cde1c54..a1e8644e 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-parallel.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-parallel.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -195,8 +195,8 @@
+@@ -196,8 +196,8 @@
<protocol type="telnet"/>
<target port="1"/>
</serial>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-redirdev.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-redirdev.xml
index 855e4c83..9d1166e7 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-redirdev.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-redirdev.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -281,8 +281,8 @@
+@@ -282,8 +282,8 @@
<address domain="0x0003" bus="0x00" slot="0x19" function="0x0"/>
</source>
</hostdev>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-rng.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-rng.xml
index 396f7699..14b3400e 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-rng.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-rng.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -295,7 +295,7 @@
+@@ -296,7 +296,7 @@
<watchdog model="ib700" action="poweroff"/>
<memballoon model="virtio"/>
<rng model="virtio">
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-security.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-security.xml
index 9de0c392..50d7e507 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-security.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-security.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -302,4 +302,7 @@
+@@ -303,4 +303,7 @@
</backend>
</rng>
</devices>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-serial.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-serial.xml
index 71884748..c0b27fa6 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-serial.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-serial.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -187,7 +187,7 @@
+@@ -188,7 +188,7 @@
<protocol type="raw"/>
<address type="ccid" controller="0" slot="3"/>
</smartcard>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-smartcard.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-smartcard.xml
index 5d1baa4b..2b193db2 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-smartcard.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-smartcard.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -170,7 +170,7 @@
+@@ -171,7 +171,7 @@
<target dev="testnet6"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x07" function="0x0"/>
</interface>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-soundhw.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-soundhw.xml
index 3318f8eb..cfa25b89 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-soundhw.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-soundhw.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -251,7 +251,7 @@
+@@ -252,7 +252,7 @@
<channel name="inputs" mode="secure"/>
<channel name="record" mode="insecure"/>
</graphics>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-tpm.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-tpm.xml
index b3ba4264..866f1b62 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-tpm.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-tpm.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -234,7 +234,7 @@
+@@ -235,7 +235,7 @@
<input type="tablet" bus="usb"/>
<tpm model="tpm-tis">
<backend type="passthrough">
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-video.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-video.xml
index d73bc719..551d3c5e 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-video.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-video.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -255,7 +255,7 @@
+@@ -256,7 +256,7 @@
<sound model="es1370"/>
<sound model="ich6"/>
<video>
diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-watchdog.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-watchdog.xml
index 736af59a..23c050bb 100644
--- a/tests/cli-test-xml/compare/virtxml-edit-simple-watchdog.xml
+++ b/tests/cli-test-xml/compare/virtxml-edit-simple-watchdog.xml
@@ -1,6 +1,6 @@
--- Original XML
+++ Altered XML
-@@ -292,7 +292,7 @@
+@@ -293,7 +293,7 @@
<usbdev class="0x08" vendor="0x15E1" product="0x2007" version="1.10" allow="yes"/>
<usbdev allow="no"/>
</redirfilter>
diff --git a/tests/clitest.py b/tests/clitest.py
index b8cc4ba0..dec25c9a 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -793,6 +793,7 @@ c.add_compare("--edit -1 --video qxl", "virtxml-edit-neg-num")
c.add_compare("--edit all --host-device driver_name=vfio", "virtxml-edit-all")
c.add_compare("--edit ich6 --soundhw pcspk", "virtxml-edit-select-sound-model")
c.add_compare("--edit target=hda --disk /dev/null", "virtxml-edit-select-disk-target")
+c.add_compare("--edit /tmp/foobar2 --disk shareable=off,readonly=on", "virtxml-edit-select-disk-path")
c.add_compare("--edit mac=00:11:7f:33:44:55 --network target=nic55", "virtxml-edit-select-network-mac")
diff --git a/tests/testdriver.xml b/tests/testdriver.xml
index 1e709ee1..457e12bc 100644
--- a/tests/testdriver.xml
+++ b/tests/testdriver.xml
@@ -141,6 +141,7 @@
<driver name="qemu" type="qcow2" cache="none"/>
<source file='/tmp/foobar2'/>
<target dev='vdc' bus='virtio'/>
+ <shareable/>
</disk>
<disk type='block' device='disk'>
<source dev='/dev/default-pool/overlay.img'/>
diff --git a/virt-xml b/virt-xml
index a476a7f0..c694d095 100755
--- a/virt-xml
+++ b/virt-xml
@@ -170,7 +170,7 @@ def change_xml(guest, options, parsermap):
"just use empty '--edit'") %
(options.edit, parserobj.cli_arg_name))
- cli.parse_option_strings(parsermap, options, guest, inst)
+ cli.parse_option_strings(parsermap, options, guest, inst, update=True)
#######################
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 343c4a68..f8eeb899 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -234,6 +234,7 @@ def fail(msg, do_exit=True):
"""
Convenience function when failing in cli app
"""
+ logging.debug("".join(traceback.format_stack()))
logging.error(msg)
if traceback.format_exc().strip() != "None":
logging.debug("", exc_info=True)
@@ -1199,7 +1200,7 @@ class VirtCLIParser(object):
"from parse handler.")
self._params.append(_VirtCLIArgument(*args, **kwargs))
- def parse(self, guest, optlist, inst=None, validate=True):
+ def parse(self, guest, optlist, inst, validate=True):
optlist = util.listify(optlist)
editting = bool(inst)
@@ -1614,19 +1615,18 @@ class ParserDisk(VirtCLIParser):
self.devclass = virtinst.VirtualDisk
self.remove_first = "path"
- def noset_cb(val):
- ignore = val
+ def noset_cb(opts, inst, cliname, val):
+ ignore = opts, inst, cliname, val
# These are all handled specially in _parse
- self.set_param(noset_cb, "path")
- self.set_param(noset_cb, "backing_store")
- self.set_param(noset_cb, "pool")
- self.set_param(noset_cb, "vol")
- self.set_param(noset_cb, "size")
- self.set_param(noset_cb, "format")
- self.set_param(noset_cb, "sparse")
- self.set_param(noset_cb, "perms")
-
+ self.set_param(None, "backing_store", setter_cb=noset_cb)
+ self.set_param(None, "pool", setter_cb=noset_cb)
+ self.set_param(None, "vol", setter_cb=noset_cb)
+ self.set_param(None, "size", setter_cb=noset_cb)
+ self.set_param(None, "format", setter_cb=noset_cb)
+ self.set_param(None, "sparse", setter_cb=noset_cb)
+
+ self.set_param("path", "path")
self.set_param("device", "device")
self.set_param("bus", "bus")
self.set_param("removable", "removable", is_onoff=True)
@@ -1638,6 +1638,8 @@ class ParserDisk(VirtCLIParser):
self.set_param("serial", "serial")
self.set_param("target", "target")
self.set_param("sourceStartupPolicy", "startup_policy")
+ self.set_param("read_only", "readonly", is_onoff=True)
+ self.set_param("shareable", "shareable", is_onoff=True)
def _parse(self, opts, inst):
@@ -1649,21 +1651,19 @@ class ParserDisk(VirtCLIParser):
except Exception, e:
fail(_("Improper value for 'size': %s" % str(e)))
- def parse_perms(val):
- ro = False
- shared = False
- if val is not None:
- if val == "ro":
- ro = True
- elif val == "sh":
- shared = True
- elif val == "rw":
- # It's default. Nothing to do.
- pass
- else:
- fail(_("Unknown '%s' value '%s'" % ("perms", val)))
-
- return ro, shared
+ def convert_perms(val):
+ if val is None:
+ return
+ if val == "ro":
+ opts.opts["readonly"] = "on"
+ elif val == "sh":
+ opts.opts["shareable"] = "on"
+ elif val == "rw":
+ # It's default. Nothing to do.
+ pass
+ else:
+ fail(_("Unknown '%s' value '%s'" % ("perms", val)))
+ convert_perms(opts.get_opt_param("perms"))
path = opts.get_opt_param("path")
backing_store = opts.get_opt_param("backing_store")
@@ -1672,18 +1672,21 @@ class ParserDisk(VirtCLIParser):
size = parse_size(opts.get_opt_param("size"))
fmt = opts.get_opt_param("format")
sparse = _on_off_convert("sparse", opts.get_opt_param("sparse"))
- ro, shared = parse_perms(opts.get_opt_param("perms"))
abspath, volinst, volobj = _parse_disk_source(
self.guest, path, pool, vol, size, fmt, sparse)
- inst.path = volobj and volobj.path() or abspath
- inst.read_only = ro
- inst.shareable = shared
- inst.set_create_storage(size=size, fmt=fmt, sparse=sparse,
- vol_install=volinst, backing_store=backing_store)
+ path = volobj and volobj.path() or abspath
+ if path:
+ opts.opts["path"] = path
inst = VirtCLIParser._parse(self, opts, inst)
+
+ create_kwargs = {"size": size, "fmt": fmt, "sparse": sparse,
+ "vol_install": volinst, "backing_store": backing_store}
+ if any(create_kwargs.values()):
+ inst.set_create_storage(**create_kwargs)
+
inst.cli_size = size
return inst
@@ -2150,11 +2153,13 @@ def build_parser_map(options, skip=None, only=None):
return parsermap
-def parse_option_strings(parsermap, options, guest, instlist):
+def parse_option_strings(parsermap, options, guest, instlist, update=False):
"""
Iterate over the parsermap, and launch the associated parser
function for every value that was filled in on 'options', which
came from argparse/the command line.
+
+ @update: If we are updating an existing guest, like from virt-xml
"""
instlist = util.listify(instlist)
if not instlist:
@@ -2166,12 +2171,13 @@ def parse_option_strings(parsermap, options, guest, instlist):
for inst in util.listify(instlist):
parsermap[option_variable_name].parse(
- guest, getattr(options, option_variable_name), inst)
+ guest, getattr(options, option_variable_name), inst,
+ validate=not update)
def check_option_introspection(options, parsermap):
"""
- Check if the user requested option introspection with ex: '--disk ?'
+ Check if the user requested option introspection with ex: '--disk=?'
"""
ret = False
for option_variable_name in dir(options):