# HG changeset patch
# User "Cole Robinson <crobinso@redhat.com>"
# Date 1215131012 14400
# Node ID 6e23ea53ca5ad81afbf8e2a61c8f40fa63c4f890
# Parent  b19ba2a8a5d7c62b006e6e50830d5651941b8d74
Add --sound option to virt-install, which adds 'es1370' audio model

diff -r b19ba2a8a5d7 -r 6e23ea53ca5a virt-install
--- a/virt-install	Thu Jul 03 22:16:42 2008 -0400
+++ b/virt-install	Thu Jul 03 20:23:32 2008 -0400
@@ -266,7 +266,8 @@
     parser.add_option("", "--arch", type="string", dest="arch",
                       action="callback", callback=cli.check_before_store,
                       help=_("The CPU architecture to simulate"))
-    
+    parser.add_option("", "--sound", action="store_true", dest="sound",
+                      default=False, help=_("Use sound device emulation"))
     # paravirt options
     parser.add_option("-p", "--paravirt", action="store_true", dest="paravirt",
                       help=_("This guest should be a paravirtualized guest"))
@@ -405,6 +406,7 @@
     cli.get_memory(options.memory, guest)
     cli.get_uuid(options.uuid, guest)
     cli.get_vcpus(options.vcpus, options.check_cpu, guest, conn)
+    cli.get_sound(options.sound, guest)
 
     # set up cpuset
     if type == "xen":
diff -r b19ba2a8a5d7 -r 6e23ea53ca5a virtinst/cli.py
--- a/virtinst/cli.py	Thu Jul 03 22:16:42 2008 -0400
+++ b/virtinst/cli.py	Thu Jul 03 20:23:32 2008 -0400
@@ -28,7 +28,7 @@
 import libvirt
 import util
 from virtinst import Guest, CapabilitiesParser, VirtualNetworkInterface, \
-                     VirtualGraphics
+                     VirtualGraphics, VirtualAudio
 from virtinst import _virtinst as _
 
 MIN_RAM = 64
@@ -330,6 +330,14 @@
     if keymap:
         guest.graphics_dev.keymap = keymap
 
+def get_sound(sound, guest):
+
+    # Sound is just a boolean value, so just specify a default of 'es1370'
+    # model since this should provide audio out of the box for most modern
+    # distros
+    if sound:
+        guest.sound_devs.append(VirtualAudio(model="es1370"))
+
 ### Option parsing
 def check_before_store(option, opt_str, value, parser):
     if len(value) == 0:
