FAQ Search Today's Posts Mark Forums Read

» Linux Archive
Home
New Posts
Search
FAQ


Go Back   Linux Archive > Redhat > Fedora/Linux Management Tools

 
 
LinkBack Thread Tools
 
Old 07-09-2008, 03:21 PM
Cole Robinson
 
Default virtinst: add VirtualAudio class

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@redhat.com>"
# 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 += "
"
+ 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@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 07-09-2008, 03:25 PM
"Daniel P. Berrange"
 
Default virtinst: add VirtualAudio class

On Wed, Jul 09, 2008 at 11:21:28AM -0400, Cole Robinson wrote:
> 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.

ACK.

Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 

Thread Tools




All times are GMT. The time now is 09:00 PM.

VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org