From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
---
docs/schemas/domaincommon.rng | 29 +++++++++++++
src/bhyve/bhyve_command.c | 1 +
src/conf/domain_conf.c | 16 +++++++
src/conf/domain_conf.h | 2 +
src/qemu/qemu_command.c | 17 +++++++-
src/qemu/qemu_validate.c | 33 +++++++++++++-
.../qemuxml2argvdata/graphics-dbus-audio.args | 32 ++++++++++++++
.../qemuxml2argvdata/graphics-dbus-audio.xml | 40 +++++++++++++++++
tests/qemuxml2argvtest.c | 2 +
.../graphics-dbus-audio.xml | 43 +++++++++++++++++++
tests/qemuxml2xmltest.c | 4 ++
11 files changed, 217 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/graphics-dbus-audio.args
create mode 100644 tests/qemuxml2argvdata/graphics-dbus-audio.xml
create mode 100644 tests/qemuxml2xmloutdata/graphics-dbus-audio.xml
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 1dba199db7ec..fcd14162bc9a 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4027,6 +4027,13 @@
</optional>
</element>
</optional>
+ <optional>
+ <element name="audio">
+ <attribute name="id">
+ <ref name="uint8"/>
+ </attribute>
+ </element>
+ </optional>
</interleave>
</group>
<group>
@@ -4839,6 +4846,11 @@
<ref name="audiocommonchild"/>
</define>
+ <define name="audiodbus">
+ <ref name="audiocommonattr"/>
+ <ref name="audiocommonchild"/>
+ </define>
+
<define name="audio">
<element name="audio">
<attribute name="id">
@@ -4867,6 +4879,23 @@
</optional>
</interleave>
</group>
+ <group>
+ <attribute name="type">
+ <value>dbus</value>
+ </attribute>
+ <interleave>
+ <optional>
+ <element name="input">
+ <ref name="audiodbus"/>
+ </element>
+ </optional>
+ <optional>
+ <element name="output">
+ <ref name="audiodbus"/>
+ </element>
+ </optional>
+ </interleave>
+ </group>
<group>
<attribute name="type">
<value>alsa</value>
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index ab9d3026cc8c..17712c1e6e69 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -551,6 +551,7 @@ bhyveBuildSoundArgStr(const virDomainDef *def G_GNUC_UNUSED,
case VIR_DOMAIN_AUDIO_TYPE_SDL:
case VIR_DOMAIN_AUDIO_TYPE_SPICE:
case VIR_DOMAIN_AUDIO_TYPE_FILE:
+ case VIR_DOMAIN_AUDIO_TYPE_DBUS:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported audio backend '%s'"),
virDomainAudioTypeTypeToString(audio->type));
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8a2f3c4115e0..82f5e44951d5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -755,6 +755,7 @@ VIR_ENUM_IMPL(virDomainAudioType,
"sdl",
"spice",
"file",
+ "dbus",
);
VIR_ENUM_IMPL(virDomainAudioSDLDriver,
@@ -3023,6 +3024,7 @@ virDomainAudioDefFree(virDomainAudioDef *def)
g_free(def->backend.file.path);
break;
+ case VIR_DOMAIN_AUDIO_TYPE_DBUS:
case VIR_DOMAIN_AUDIO_TYPE_LAST:
break;
}
@@ -12930,6 +12932,14 @@ virDomainGraphicsDefParseXMLDBus(virDomainGraphicsDef *def,
return -1;
}
+ cur = virXPathNode("./audio", ctxt);
+ if (cur) {
+ if (virXMLPropUInt(cur, "id", 10,
+ VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
+ &def->data.dbus.audioId) < 0)
+ return -1;
+ }
+
return 0;
}
@@ -13420,6 +13430,9 @@ virDomainAudioDefParseXML(virDomainXMLOption *xmlopt
G_GNUC_UNUSED,
def->backend.file.path = virXMLPropString(node, "path");
break;
+ case VIR_DOMAIN_AUDIO_TYPE_DBUS:
+ break;
+
case VIR_DOMAIN_AUDIO_TYPE_LAST:
default:
virReportEnumRangeError(virDomainAudioType, def->type);
@@ -25776,6 +25789,9 @@ virDomainAudioDefFormat(virBuffer *buf,
virBufferEscapeString(&attrBuf, " path='%s'",
def->backend.file.path);
break;
+ case VIR_DOMAIN_AUDIO_TYPE_DBUS:
+ break;
+
case VIR_DOMAIN_AUDIO_TYPE_LAST:
default:
virReportEnumRangeError(virDomainAudioType, def->type);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 42fe583418a6..6eec4230fab5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1504,6 +1504,7 @@ typedef enum {
VIR_DOMAIN_AUDIO_TYPE_SDL,
VIR_DOMAIN_AUDIO_TYPE_SPICE,
VIR_DOMAIN_AUDIO_TYPE_FILE,
+ VIR_DOMAIN_AUDIO_TYPE_DBUS,
VIR_DOMAIN_AUDIO_TYPE_LAST
} virDomainAudioType;
@@ -1922,6 +1923,7 @@ struct _virDomainGraphicsDef {
char *address;
char *rendernode;
virTristateBool gl;
+ unsigned int audioId;
} dbus;
} data;
/* nListens, listens, and *port are only useful if type is vnc,
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1960861015c6..20cafa1abb0e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -152,6 +152,7 @@ VIR_ENUM_IMPL(qemuAudioDriver,
"sdl",
"spice",
"wav",
+ "dbus",
);
@@ -8010,6 +8011,9 @@ qemuBuildAudioCommandLineArg(virCommand *cmd,
virBufferEscapeString(&buf, ",path=%s",
def->backend.file.path);
break;
+ case VIR_DOMAIN_AUDIO_TYPE_DBUS:
+ break;
+
case VIR_DOMAIN_AUDIO_TYPE_LAST:
default:
virReportEnumRangeError(virDomainAudioType, def->type);
@@ -8205,6 +8209,9 @@ qemuBuildAudioCommandLineEnv(virCommand *cmd,
audio->backend.file.path);
break;
+ case VIR_DOMAIN_AUDIO_TYPE_DBUS:
+ break;
+
case VIR_DOMAIN_AUDIO_TYPE_LAST:
default:
virReportEnumRangeError(virDomainAudioType, audio->type);
@@ -8603,6 +8610,7 @@ qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfig *cfg
G_GNUC_UNUSED,
static int
qemuBuildGraphicsDBusCommandLine(virQEMUDriver *driver,
virDomainObj *vm,
+ virDomainDef *def,
virCommand *cmd,
virDomainGraphicsDef *graphics)
{
@@ -8630,6 +8638,13 @@ qemuBuildGraphicsDBusCommandLine(virQEMUDriver *driver,
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);
@@ -8676,7 +8691,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriver *driver,
break;
case VIR_DOMAIN_GRAPHICS_TYPE_DBUS:
- if (qemuBuildGraphicsDBusCommandLine(driver, vm, cmd,
+ if (qemuBuildGraphicsDBusCommandLine(driver, vm, def, cmd,
graphics) < 0)
return -1;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 23c7e9f94cd0..56949775a3e6 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -4088,6 +4088,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,
@@ -4165,10 +4183,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;
}
@@ -4415,6 +4438,14 @@ qemuValidateDomainDeviceDefAudio(virDomainAudioDef *audio,
case VIR_DOMAIN_AUDIO_TYPE_FILE:
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:
default:
virReportEnumRangeError(virDomainAudioType, audio->type);
diff --git a/tests/qemuxml2argvdata/graphics-dbus-audio.args
b/tests/qemuxml2argvdata/graphics-dbus-audio.args
new file mode 100644
index 000000000000..83f7d3f6a5a9
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-audio.args
@@ -0,0 +1,32 @@
+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,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev
socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,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=off,out.mixing-engine=off \
+-display dbus,p2p=on,audiodev=audio1 \
+-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/graphics-dbus-audio.xml
b/tests/qemuxml2argvdata/graphics-dbus-audio.xml
new file mode 100644
index 000000000000..592e3d535d91
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-dbus-audio.xml
@@ -0,0 +1,40 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='dbus' p2p='yes'>
+ <audio id='1'/>
+ </graphics>
+ <audio id='1' type='dbus'>
+ <input mixingEngine='no'/>
+ <output mixingEngine='no'/>
+ </audio>
+ <video>
+ <model type='cirrus' vram='16384' heads='1'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4345ab47e053..e5454f03eccf 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1524,6 +1524,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");
diff --git a/tests/qemuxml2xmloutdata/graphics-dbus-audio.xml
b/tests/qemuxml2xmloutdata/graphics-dbus-audio.xml
new file mode 100644
index 000000000000..16c37a34c6d5
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/graphics-dbus-audio.xml
@@ -0,0 +1,43 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='dbus' p2p='yes'/>
+ <audio id='1' type='dbus'>
+ <input mixingEngine='no'/>
+ <output mixingEngine='no'/>
+ </audio>
+ <video>
+ <model type='cirrus' vram='16384' heads='1'
primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 92d1c02fd3e8..ee3677ec5c38 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -382,6 +382,10 @@ mymain(void)
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_CAPS_ARCH_LATEST("default-video-type-aarch64",
"aarch64");
DO_TEST_CAPS_ARCH_LATEST("default-video-type-ppc64", "ppc64");
--
2.33.0.721.g106298f7f9