cli: add --sound codec support

Add codec support to virt-install so that it can accommodate
multiple instances of codec configuration.

The commandline argument:

  --sound codec0.type=micro,codec1.type=duplex,codec2.type=output

maps to the sound XML below:

    <sound model="es1370">
      <codec type="micro"/>
      <codec type="duplex"/>
      <codec type="output"/>
    </sound>

Signed-off-by: Anya Harter <aharter@redhat.com>
This commit is contained in:
Anya Harter 2018-06-11 11:48:30 -04:00 committed by Cole Robinson
parent 02635d3358
commit 846e2f711a
4 changed files with 27 additions and 1 deletions

View File

@ -300,6 +300,11 @@
</graphics>
<sound model="ich6"/>
<sound model="ac97"/>
<sound model="ich6">
<codec type="micro"/>
<codec type="duplex"/>
<codec type="output"/>
</sound>
<video>
<model type="cirrus"/>
</video>

View File

@ -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 \

View File

@ -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)
#####################

View File

@ -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 <sound> child <codec> 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)