Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save evidex/1f869ff8adad12dc035f to your computer and use it in GitHub Desktop.
Save evidex/1f869ff8adad12dc035f to your computer and use it in GitHub Desktop.
From b34b22d28c231c6d9739146e026725422325e1ad Mon Sep 17 00:00:00 2001
From: David Hayes <evidex@freeshell.de>
Date: Mon, 27 Jul 2015 22:23:47 +0100
Subject: [PATCH] Add libvirt.sound_driver option
---
nova/virt/libvirt/config.py | 16 ++++++++++++++++
nova/virt/libvirt/driver.py | 12 ++++++++++++
2 files changed, 28 insertions(+)
diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py
index a2a88b0..ea6041c 100644
--- a/nova/virt/libvirt/config.py
+++ b/nova/virt/libvirt/config.py
@@ -1197,6 +1197,16 @@ class LibvirtConfigGuestInput(LibvirtConfigGuestDevice):
return dev
+class LibvirtConfigGuestSound(LibvirtConfigGuestDevice):
+ def __init__(self, **kwargs):
+ super(LibvirtConfigGuestSound, self).__init__(root_name="sound", **kwargs)
+ self.model = "ich6"
+
+ def format_dom(self):
+ dev = super(LibvirtConfigGuestSound, self).format_dom()
+ dev.set("model", self.model)
+ return dev
+
class LibvirtConfigGuestGraphics(LibvirtConfigGuestDevice):
@@ -1982,3 +1992,9 @@ class LibvirtConfigGuestMetaNovaOwner(LibvirtConfigObject):
project.set("uuid", self.projectid)
meta.append(project)
return meta
+
+
+class LibvirtConfigGuestSoundDev(LibvirtConfigObject):
+ def __init__(self):
+ super(LibvirtConfigGuestSoundDev, self).__init__(model="all")
+ self.model = None
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index cf6cb3e..cba8afe 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -126,6 +126,10 @@ libvirt_opts = [
help='Rescue aki image'),
cfg.StrOpt('rescue_ramdisk_id',
help='Rescue ari image'),
+ cfg.StrOpt('sound_driver',
+ default=None,
+ help='For QEMU or KVM guests, set this option to specify'
+ 'which sound driver to pass to libvirt'),
cfg.StrOpt('virt_type',
default='kvm',
help='Libvirt domain type (valid options are: '
@@ -3975,6 +3979,14 @@ class LibvirtDriver(driver.ComputeDriver):
flavor, CONF.libvirt.virt_type)
guest.add_device(config)
+
+ if ((CONF.libvirt.virt_type == "qemu" or
+ CONF.libvirt.virt_type == "kvm") and
+ (CONF.libvirt.sound_driver)):
+ sound_dev = vconfig.LibvirtConfigGuestSound()
+ sound_dev.model = CONF.libvirt.sound_driver
+ guest.add_device(sound_dev)
+
if ((CONF.libvirt.virt_type == "qemu" or
CONF.libvirt.virt_type == "kvm")):
# Create the serial console char devices
--
1.9.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment