[libvirt PATCH v4 07/11] qemu: add audio type 'dbus'

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

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
 src/qemu/qemu_command.c                       | 12 +++++--
 src/qemu/qemu_validate.c                      | 30 ++++++++++++++++-
 .../qemuxml2argvdata/graphics-dbus-audio.args | 33 +++++++++++++++++++
 tests/qemuxml2argvtest.c                      |  2 ++
 4 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/graphics-dbus-audio.args

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4ae946ec00..9367eb4dc6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8593,7 +8593,8 @@ qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfig *cfg G_GNUC_UNUSED,
 
 
 static int
-qemuBuildGraphicsDBusCommandLine(virCommand *cmd,
+qemuBuildGraphicsDBusCommandLine(virDomainDef *def,
+                                 virCommand *cmd,
                                  virDomainGraphicsDef *graphics)
 {
     g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
@@ -8615,6 +8616,13 @@ qemuBuildGraphicsDBusCommandLine(virCommand *cmd,
                                       graphics->data.dbus.rendernode);
     }
 
+    if (graphics->data.dbus.audioId > 0) {
+        g_autofree char *audioid = qemuGetAudioIDString(def, graphics->data.dbus.audioId);
+        if (!audioid)
+            return -1;
+        virBufferAsprintf(&opt, ",audiodev=%s", audioid);
+    }
+
     virCommandAddArg(cmd, "-display");
     virCommandAddArgBuffer(cmd, &opt);
 
@@ -8659,7 +8667,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfig *cfg,
 
             break;
         case VIR_DOMAIN_GRAPHICS_TYPE_DBUS:
-            if (qemuBuildGraphicsDBusCommandLine(cmd, graphics) < 0)
+            if (qemuBuildGraphicsDBusCommandLine(def, cmd, graphics) < 0)
                 return -1;
 
             break;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 5bfb9fd311..be6b2c508b 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -4174,6 +4174,24 @@ qemuValidateDomainDeviceDefVNCGraphics(const virDomainGraphicsDef *graphics,
 }
 
 
+static int
+qemuValidateDomainDeviceDefDBusGraphics(const virDomainGraphicsDef *graphics,
+                                        const virDomainDef *def)
+{
+    if (graphics->data.dbus.audioId > 0) {
+        virDomainAudioDef *audio = virDomainDefFindAudioByID(def, graphics->data.dbus.audioId);
+
+        if (audio && audio->type != VIR_DOMAIN_AUDIO_TYPE_DBUS) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("The associated audio is not of 'dbus' kind."));
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+
 static int
 qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics,
                                     const virDomainDef *def,
@@ -4251,10 +4269,15 @@ qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics,
 
         break;
 
+    case VIR_DOMAIN_GRAPHICS_TYPE_DBUS:
+        if (qemuValidateDomainDeviceDefDBusGraphics(graphics, def) < 0)
+            return -1;
+
+        break;
+
     case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
     case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
-    case VIR_DOMAIN_GRAPHICS_TYPE_DBUS:
     case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
         break;
     }
@@ -4508,6 +4531,11 @@ qemuValidateDomainDeviceDefAudio(virDomainAudioDef *audio,
         break;
 
     case VIR_DOMAIN_AUDIO_TYPE_DBUS:
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISPLAY_DBUS)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("D-Bus audio is not supported with this QEMU"));
+            return -1;
+        }
         break;
 
     case VIR_DOMAIN_AUDIO_TYPE_LAST:
diff --git a/tests/qemuxml2argvdata/graphics-dbus-audio.args b/tests/qemuxml2argvdata/graphics-dbus-audio.args
new file mode 100644
index 0000000000..968dddfd89
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-audio.args
@@ -0,0 +1,33 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-i386 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine pc,usb=off,dump-guest-core=off \
+-accel tcg \
+-m 214 \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
+-audiodev '{"id":"audio1","driver":"dbus","in":{"mixing-engine":false},"out":{"mixing-engine":false}}' \
+-display dbus,p2p=on,audiodev=audio1 \
+-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 0d0c75b253..c25290f55e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1544,6 +1544,8 @@ mymain(void)
             QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DISPLAY_DBUS);
     DO_TEST("graphics-dbus-p2p",
             QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DISPLAY_DBUS);
+    DO_TEST("graphics-dbus-audio",
+            QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DISPLAY_DBUS, QEMU_CAPS_AUDIODEV);
 
     DO_TEST_NOCAPS("input-usbmouse");
     DO_TEST_NOCAPS("input-usbtablet");
-- 
2.36.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux