diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml b/tests/cli-test-xml/compare/virt-install-many-devices.xml index 25f76016..7b9bb7c7 100644 --- a/tests/cli-test-xml/compare/virt-install-many-devices.xml +++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml @@ -300,6 +300,11 @@ + + + + + diff --git a/tests/clitest.py b/tests/clitest.py index c84156f9..09c3e2d6 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -533,6 +533,7 @@ c.add_compare(""" \ \ --soundhw default \ --sound ac97 \ +--sound codec0.type=micro,codec1.type=duplex,codec2.type=output \ \ --video cirrus \ --video model=qxl,vgamem=1,ram=2,vram=3,heads=4,accel3d=yes,vram64=65 \ diff --git a/virtinst/cli.py b/virtinst/cli.py index e0ef8e59..0668c315 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -2754,9 +2754,18 @@ class ParserSound(VirtCLIParser): return return VirtCLIParser._parse(self, inst) + def codec_find_inst_cb(self, *args, **kwargs): + cliarg = "codec" # codec[0-9]* + objpropname = "codecs" + cb = self._make_find_inst_cb(cliarg, objpropname) + return cb(*args, **kwargs) + _register_virt_parser(ParserSound) _add_device_address_args(ParserSound) ParserSound.add_arg("model", "model", ignore_default=True) +# Options for sound.codecs config +ParserSound.add_arg("type", "codec[0-9]*.type", + find_inst_cb=ParserSound.codec_find_inst_cb) ##################### diff --git a/virtinst/devices/sound.py b/virtinst/devices/sound.py index e0f710a8..0eee6f64 100644 --- a/virtinst/devices/sound.py +++ b/virtinst/devices/sound.py @@ -6,7 +6,16 @@ # See the COPYING file in the top-level directory. from .device import Device -from ..xmlbuilder import XMLProperty +from ..xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty + + +class _Codec(XMLBuilder): + """ + Class for generating child XML + """ + XML_NAME = "codec" + + type = XMLProperty("./@type") class DeviceSound(Device): @@ -25,3 +34,5 @@ class DeviceSound(Device): model = XMLProperty("./@model", default_cb=lambda s: "es1370", default_name=MODEL_DEFAULT) + + codecs = XMLChildProperty(_Codec)