[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] qemu: Allow using regular audio backends with VNC



Currently all host audio backends are disabled if a VM is using VNC, in
favor of the QEMU VNC audio extension. Unfortunately no released VNC
client supports this extension, so users have no way of getting audio
to work if using VNC.

Add a new config option in qemu.conf which allows changing libvirt's
behavior, but keep the default intact.

Signed-off-by: Cole Robinson <crobinso redhat com>
---
 src/qemu/qemu.conf   |   10 ++++++++++
 src/qemu/qemu_conf.c |   17 ++++++++++++-----
 src/qemu/qemu_conf.h |    2 ++
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 3da332f..fec946d 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -168,3 +168,13 @@
 # be assigned to guests.
 #
 # relaxed_acs_check = 1
+
+
+# QEMU implements anextension for providing audio over a VNC connection,
+# though if your VNC client does not support it, your only chance for getting
+# sound output is through regular audio backends. By default, libvirt will
+# disable all QEMU sound backends if using VNC, since they can cause
+# permissions issues. Enabling this option will make libvirtd honor the
+# QEMU_AUDIO_DRV environment variable when using VNC.
+#
+# vnc_enable_audio_backend = 0
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index d7bc798..5c30f48 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -351,6 +351,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
     CHECK_TYPE ("relaxed_acs_check", VIR_CONF_LONG);
     if (p) driver->relaxedACS = p->l;
 
+    p = virConfGetValue (conf, "vnc_enable_audio_backend");
+    CHECK_TYPE ("vnc_enable_audio_backend", VIR_CONF_LONG);
+    if (p) driver->vncEnableAudioBackend = p->l;
+
     virConfFree (conf);
     return 0;
 }
@@ -4394,12 +4398,15 @@ int qemudBuildCommandLine(virConnectPtr conn,
             ADD_ARG_LIT(def->graphics[0]->data.vnc.keymap);
         }
 
-        /* QEMU implements a VNC extension for providing audio, so we
-         * set the audio backend to none, to prevent it opening the
-         * host OS audio devices since that causes security issues
-         * and is non-sensical when using VNC.
+        /* Unless user requested it, set the audio backend to none, to
+         * prevent it opening the host OS audio devices since that causes
+         * security issues and is may not work when using VNC.
          */
-        ADD_ENV_LIT("QEMU_AUDIO_DRV=none");
+        if (driver->vncEnableAudioBackend) {
+            ADD_ENV_COPY("QEMU_AUDIO_DRV");
+        } else {
+            ADD_ENV_LIT("QEMU_AUDIO_DRV=none");
+        }
     } else if ((def->ngraphics == 1) &&
                def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
         char *xauth = NULL;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 11f8dcd..aa6ed61 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -137,6 +137,8 @@ struct qemud_driver {
 
     unsigned int relaxedACS : 1;
 
+    unsigned int vncEnableAudioBackend : 1;
+
     virCapsPtr caps;
 
     /* An array of callbacks */
-- 
1.6.6.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]