summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2014-02-05 12:32:53 -0500
committerCole Robinson <crobinso@redhat.com>2014-02-05 12:41:34 -0500
commite70ab961f9b06a3204926825916707c5850a51df (patch)
treed802e78dc3ac262702b00e19e2ae9039d87bb870
parent69015c048f3ce29fb5c5cccceffad7309aa20fc7 (diff)
downloadvirt-manager-e70ab961f9b06a3204926825916707c5850a51df.tar.gz
virt-install: Switch back to using --sound argument
Since argparse allows optional arguments, we can back compat handle the original boolean --sound option. This is nicer than using an option named --soundhw
-rw-r--r--man/virt-install.pod6
-rw-r--r--man/virt-xml.pod6
-rw-r--r--tests/clitest.py16
-rwxr-xr-xvirt-install14
-rw-r--r--virtinst/cli.py21
5 files changed, 35 insertions, 28 deletions
diff --git a/man/virt-install.pod b/man/virt-install.pod
index 711d657d..360ebe44 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -954,16 +954,16 @@ PCI device (via lspci).
Use --host-device=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsHostDev>
-=item --soundhw MODEL
+=item --sound MODEL
Attach a virtual audio device to the guest. MODEL specifies the emulated
sound card model. Possible values are ich6, ac97, es1370, sb16, pcspk,
or default. 'default' will try to pick the best model that the specified
OS supports.
-This deprecates the old boolean --sound option.
+This deprecates the old --soundhw option.
-Use --soundhw=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsSound>
+Use --sound=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsSound>
=item --watchdog MODEL[,action=ACTION]
diff --git a/man/virt-xml.pod b/man/virt-xml.pod
index 3513f44e..b99ccb97 100644
--- a/man/virt-xml.pod
+++ b/man/virt-xml.pod
@@ -110,7 +110,7 @@ Remove the second disk device
Remove all network devices
-=item --remove-device --soundhw pcspk
+=item --remove-device --sound pcspk
Remove all sound devices with model='pcspk'
@@ -206,7 +206,7 @@ Before defining or updating the domain, show the generated XML diff and interact
=item --host-device
-=item --soundhw
+=item --sound
=item --watchdog
@@ -278,7 +278,7 @@ Clear the previous <cpu> definition of domain 'winxp', change it to 'host-model'
Change the second sound card to model=ich6 on 'fedora19', but only output the diff:
- # virt-xml fedora19 --edit 2 --soundhw model=ich6 --print-diff
+ # virt-xml fedora19 --edit 2 --sound model=ich6 --print-diff
Update the every graphics device password to 'foo' of the running VM 'rhel6':
diff --git a/tests/clitest.py b/tests/clitest.py
index 90456179..ec36cdda 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -580,8 +580,8 @@ c.add_valid("--hvm --cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k
c.add_valid("--hvm --cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0 --print-step 3") # HVM windows install, print 3rd stage XML
c.add_valid("--hvm --nodisks --pxe --watchdog default") # --watchdog dev default
c.add_valid("--hvm --nodisks --pxe --watchdog ib700,action=pause") # --watchdog opts
-c.add_valid("--hvm --nodisks --pxe --sound") # --sound option
-c.add_valid("--hvm --nodisks --pxe --soundhw default --soundhw ac97") # --soundhw option
+c.add_valid("--hvm --nodisks --pxe --sound") # --sound with no option back compat
+c.add_valid("--hvm --nodisks --pxe --soundhw default --sound ac97") # --soundhw option
c.add_valid("--hvm --nodisks --pxe --security type=dynamic") # --security dynamic
c.add_valid("--hvm --nodisks --pxe --security label=foobar.label,relabel=yes") # --security implicit static
c.add_valid("--hvm --nodisks --pxe --security label=foobar.label,a1,z2,b3,type=static,relabel=no") # --security static with commas 1
@@ -775,7 +775,7 @@ c.add_invalid("--hvm --boot kernel=%(TREEDIR)s/pxeboot/vmlinuz,initrd=%(TREEDIR)
vixml = App("virt-xml")
c = vixml.add_category("misc", "")
c.add_valid("--help") # basic --help test
-c.add_valid("--soundhw=? --tpm=?") # basic introspection test
+c.add_valid("--sound=? --tpm=?") # basic introspection test
c.add_invalid("test --edit --hostdev driver_name=vfio") # Guest has no hostdev to edit
c.add_invalid("test --edit --cpu host-passthrough --boot hd,network") # Specified more than 1 option
c.add_invalid("test --edit") # specified no edit option
@@ -822,15 +822,15 @@ c.add_compare("--channel null", "virtxml-edit-simple-channel")
c.add_compare("--console target_type=serial", "virtxml-edit-simple-console")
c.add_compare("--filesystem /1/2/3,/4/5/6,mode=mapped", "virtxml-edit-simple-filesystem")
c.add_compare("--video cirrus", "virtxml-edit-simple-video")
-c.add_compare("--soundhw pcspk", "virtxml-edit-simple-soundhw")
+c.add_compare("--sound pcspk", "virtxml-edit-simple-soundhw")
c.add_compare("--host-device 0x0781:0x5151,driver_name=vfio", "virtxml-edit-simple-host-device")
c = vixml.add_category("edit selection", "test-many-devices --print-diff --define", compare_check=support.SUPPORT_CONN_PANIC_DEVICE)
c.add_invalid("--edit target=vvv --disk /dev/null") # no match found
-c.add_compare("--edit 3 --soundhw pcspk", "virtxml-edit-pos-num")
+c.add_compare("--edit 3 --sound pcspk", "virtxml-edit-pos-num")
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 ich6 --sound 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")
@@ -845,11 +845,11 @@ c = vixml.add_category("add/rm devices", "test-many-devices --print-diff --defin
c.add_invalid("--add-device --security foo") # --add-device without a device
c.add_invalid("--remove-device --clock utc") # --remove-device without a dev
c.add_compare("--add-device --host-device net_00_1c_25_10_b1_e4", "virtxml-add-host-device")
-c.add_compare("--add-device --soundhw pcspk", "virtxml-add-sound")
+c.add_compare("--add-device --sound pcspk", "virtxml-add-sound")
c.add_compare("--add-device --disk %(EXISTIMG1)s,bus=virtio,target=vdf", "virtxml-add-disk-basic")
c.add_compare("--add-device --disk %(EXISTIMG1)s", "virtxml-add-disk-notarget") # filling in acceptable target
c.add_compare("--add-device --disk %(NEWIMG1)s,size=.01", "virtxml-add-disk-create-storage")
-c.add_compare("--remove-device --soundhw ich6", "virtxml-remove-sound-model")
+c.add_compare("--remove-device --sound ich6", "virtxml-remove-sound-model")
c.add_compare("--remove-device --disk 6", "virtxml-remove-disk-index")
c.add_compare("--remove-device --disk /dev/null", "virtxml-remove-disk-path")
c.add_compare("--remove-device --video all", "virtxml-remove-video-all")
diff --git a/virt-install b/virt-install
index 297077cc..fe7ce6bd 100755
--- a/virt-install
+++ b/virt-install
@@ -114,11 +114,11 @@ def check_cdrom_option_error(options):
##############################
def convert_old_sound(options):
- if options.soundhw:
+ if not options.sound:
return
- if not options.old_sound_bool:
- return
- options.soundhw = "default"
+ for idx in range(len(options.sound)):
+ if options.sound[idx] is None:
+ options.sound[idx] = "default"
def convert_old_init(options):
@@ -871,11 +871,7 @@ def parse_args():
"console"))
devg = parser.add_argument_group(_("Device Options"))
- cli.add_device_options(devg)
-
- # Deprecated
- devg.add_argument("--sound", action="store_true", dest="old_sound_bool",
- default=False, help=argparse.SUPPRESS)
+ cli.add_device_options(devg, sound_back_compat=True)
virg = parser.add_argument_group(_("Virtualization Platform Options"))
virg.add_argument("-v", "--hvm", action="store_true", dest="fullvirt",
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 9c8c22c1..4499a89d 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -629,7 +629,7 @@ def add_net_option(devg):
"--network help"))
-def add_device_options(devg):
+def add_device_options(devg, sound_back_compat=False):
devg.add_argument("--controller", action="append",
help=_("Configure a guest controller device. Ex:\n"
"--controller type=usb,model=ich9-ehci1"))
@@ -645,8 +645,19 @@ def add_device_options(devg):
devg.add_argument("--host-device", action="append",
help=_("Configure physical host devices attached to the "
"guest"))
- devg.add_argument("--soundhw", action="append",
- help=_("Configure guest sound device emulation"))
+
+ # --sound used to be a boolean option, hence the nargs handling
+ sound_kwargs = {
+ "action": "append",
+ "help": _("Configure guest sound device emulation"),
+ }
+ if sound_back_compat:
+ sound_kwargs["nargs"] = '?'
+ devg.add_argument("--sound", **sound_kwargs)
+ if sound_back_compat:
+ devg.add_argument("--soundhw", action="append", dest="sound",
+ help=argparse.SUPPRESS)
+
devg.add_argument("--watchdog", action="append",
help=_("Configure a guest watchdog device"))
devg.add_argument("--video", action="append",
@@ -1963,7 +1974,7 @@ class ParserVideo(VirtCLIParser):
#####################
-# --soundhw parsing #
+# --sound parsing #
#####################
class ParserSound(VirtCLIParser):
@@ -2044,7 +2055,7 @@ def build_parser_map(options, skip=None, only=None):
register_parser("console", ParserConsole)
register_parser("filesystem", ParserFilesystem)
register_parser("video", ParserVideo)
- register_parser("soundhw", ParserSound)
+ register_parser("sound", ParserSound)
register_parser("host-device", ParserHostdev)
register_parser("panic", ParserPanic)