A VirtualAudio class is added which is used to generate a single <sound/> xml tag. It validates the passed model against an internal whitelist, though hopefully this will eventually be exposed via libvirt capabilities xml so we won't need to maintain duplicate lists. The Guest class has a sound_devs list which holds any VirtualAudio devices to add to the xml. Thanks, Cole
# HG changeset patch # User "Cole Robinson <crobinso@xxxxxxxxxx>" # Date 1215137802 14400 # Node ID b19ba2a8a5d7c62b006e6e50830d5651941b8d74 # Parent a2be1263c2f5d3f346cfc3501682073fce2e8966 Add VirtualAudio class and export it diff -r a2be1263c2f5 -r b19ba2a8a5d7 virtinst/Guest.py --- a/virtinst/Guest.py Mon Jul 07 17:50:22 2008 -0400 +++ b/virtinst/Guest.py Thu Jul 03 22:16:42 2008 -0400 @@ -413,6 +413,27 @@ doc.freeDoc() return count +class VirtualAudio(object): + + MODELS = [ "es1370", "sb16", "pcspk" ] + + def __init__(self, model): + self.model = model + + def get_model(self): + return self._model + def set_model(self, new_model): + if type(new_model) != str: + raise ValueError, _("'model' must be a string, " + " was '%s'." % type(new_model)) + if not self.MODELS.count(new_model): + raise ValueError, _("Unsupported sound model '%s'" % new_model) + self._model = new_model + model = property(get_model, set_model) + + def get_xml_config(self): + return " <sound model='%s'/>" % self.model + # Back compat class to avoid ABI break class XenNetworkInterface(VirtualNetworkInterface): pass @@ -601,6 +622,7 @@ # Public device lists unaltered by install process self.disks = [] self.nics = [] + self.sound_devs = [] # Device lists to use/alter during install process self._install_disks = [] @@ -860,14 +882,25 @@ (type,bus) = self.get_input_device() return " <input type='%s' bus='%s'/>" % (type, bus) + def _get_sound_xml(self): + """Get the sound device configuration in libvirt XML format.""" + xml = "" + for sound_dev in self.sound_devs: + if xml != "": + xml += "\n" + xml += sound_dev.get_xml_config() + return xml + def _get_device_xml(self, install = True): return """%(disks)s %(networks)s %(input)s -%(graphics)s""" % { "disks": self._get_disk_xml(install), \ - "networks": self._get_network_xml(install), \ - "input": self._get_input_xml(install), \ - "graphics": self._get_graphics_xml(install) } +%(graphics)s +%(sound)s""" % { "disks": self._get_disk_xml(install), \ + "networks": self._get_network_xml(install), \ + "input": self._get_input_xml(install), \ + "graphics": self._get_graphics_xml(install), \ + "sound": self._get_sound_xml()} def get_config_xml(self, install = True, disk_boot = False): if install: diff -r a2be1263c2f5 -r b19ba2a8a5d7 virtinst/__init__.py --- a/virtinst/__init__.py Mon Jul 07 17:50:22 2008 -0400 +++ b/virtinst/__init__.py Thu Jul 03 22:16:42 2008 -0400 @@ -25,7 +25,7 @@ return gettext.dgettext(gettext_app, msg) import util -from Guest import Guest, VirtualDisk, VirtualNetworkInterface, XenGuest, XenDisk, XenNetworkInterface, VirtualGraphics +from Guest import Guest, VirtualDisk, VirtualNetworkInterface, XenGuest, XenDisk, XenNetworkInterface, VirtualGraphics, VirtualAudio from FullVirtGuest import FullVirtGuest from ParaVirtGuest import ParaVirtGuest from DistroManager import DistroInstaller, PXEInstaller
_______________________________________________ et-mgmt-tools mailing list et-mgmt-tools@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/et-mgmt-tools