Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 8ddb430

Browse files
committed
virt-install: Add more flexible --soundhw option, deprecate --sound
1 parent 3e15975 commit 8ddb430

4 files changed

Lines changed: 36 additions & 13 deletions

File tree

man/en/virt-install.pod.in

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,15 @@ PCI device (via lspci).
573573

574574
=back
575575

576-
=item --sound
576+
=item --soundhw MODEL
577577

578-
Attach a virtual audio device to the guest. The device model will be AC97
579-
if the hypervisor supports it, otherwise will be ES1370
578+
Attach a virtual audio device to the guest. MODEL specifies the emulated
579+
sound card model. Possible values are ac97, es1370, sb16, pcspk, or default.
580+
'default' willl be AC97 if the hypervisor supports it, otherwise it will be
581+
ES1370.
582+
583+
This deprecates the old boolean --sound model (which still works the same
584+
as a single '--soundhw default')
580585

581586
=item --watchdog MODEL[,action=ACTION]
582587

tests/clitest.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,19 +360,25 @@
360360
"--hvm --nodisks --pxe --description \"foobar & baz\"",
361361
# HVM windows install with disk
362362
"--hvm --cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0",
363-
# Watchdog dev default
363+
# --watchdog dev default
364364
"--hvm --nodisks --pxe --watchdog default",
365-
# Watchdog opts
365+
# --watchdog opts
366366
"--hvm --nodisks --pxe --watchdog ib700,action=pause",
367+
# --sound option
368+
"--hvm --nodisks --pxe --sound",
369+
# --soundhw option
370+
"--hvm --nodisks --pxe --soundhw default --soundhw ac97",
367371
],
368372

369373
"invalid": [
370374
# pxe and nonetworks
371375
"--nodisks --pxe --nonetworks",
372376
# Colliding name
373377
"--nodisks --pxe --name test",
374-
# Busted watchdog
378+
# Busted --watchdog
375379
"--hvm --nodisks --pxe --watchdog default,action=foobar",
380+
# Busted --soundhw
381+
"--hvm --nodisks --pxe --soundhw default --soundhw foobar",
376382
],
377383
}, # category "misc"
378384

virt-install

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,14 +642,19 @@ def parse_args():
642642
devg.add_option("", "--host-device", type="string", dest="hostdevs",
643643
action="callback", callback=cli.check_before_append,
644644
help=_("Physical host device to attach to the domain."))
645-
devg.add_option("", "--sound", action="store_true", dest="sound",
646-
default=False, help=_("Use sound device emulation"))
645+
devg.add_option("", "--soundhw", type='string', action="callback",
646+
callback=cli.check_before_append, dest="soundhw",
647+
help=_("Use sound device emulation"))
647648
devg.add_option("", "--watchdog", type="string", dest="watchdog",
648649
action="callback", callback=cli.check_before_append,
649650
help=_("Add a watchdog device to the domain."))
650651
devg.add_option("", "--video", dest="video", type="string",
651652
action="callback", callback=cli.check_before_append,
652653
help=_("Specify video hardware type."))
654+
655+
# Deprecated
656+
devg.add_option("", "--sound", action="store_true", dest="sound",
657+
default=False, help=optparse.SUPPRESS_HELP)
653658
parser.add_option_group(devg)
654659

655660
virg = OptionGroup(parser, _("Virtualization Platform Options"))
@@ -787,7 +792,7 @@ def main():
787792
cli.get_cpuset(options.cpuset, guest.memory, guest, conn)
788793
if ishvm:
789794
get_watchdog(options.watchdog, guest)
790-
cli.get_sound(options.sound, guest)
795+
cli.get_sound(options.sound, options.soundhw, guest)
791796
get_chardevs(VirtualDevice.VIRTUAL_DEV_SERIAL, options.serials, guest)
792797
get_chardevs(VirtualDevice.VIRTUAL_DEV_PARALLEL, options.parallels,
793798
guest)

virtinst/cli.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -794,11 +794,18 @@ def get_graphics(vnc, vncport, vnclisten, nographics, sdl, keymap,
794794

795795
guest.graphics_dev.keymap = use_keymap
796796

797-
def get_sound(sound, guest):
797+
def get_sound(old_sound_bool, sound_opts, guest):
798+
if not sound_opts:
799+
if old_sound_bool:
800+
# Use os default
801+
guest.sound_devs.append(VirtualAudio(conn=guest.conn))
802+
return
803+
804+
for model in listify(sound_opts):
805+
dev = VirtualAudio(conn=guest.conn)
806+
dev.model = model
807+
guest.add_device(dev)
798808

799-
# Use os default
800-
if sound:
801-
guest.sound_devs.append(VirtualAudio(conn=guest.conn))
802809

803810
def get_hostdevs(hostdevs, guest):
804811
if not hostdevs:

0 commit comments

Comments
 (0)