From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> --- src/bhyve/bhyve_command.c | 1 + src/conf/domain_conf.c | 34 +++++++++++--- src/conf/domain_conf.h | 2 + src/conf/schemas/domaincommon.rng | 29 ++++++++++++ src/qemu/qemu_command.c | 7 +++ src/qemu/qemu_validate.c | 3 ++ .../qemuxml2argvdata/graphics-dbus-audio.xml | 45 +++++++++++++++++++ .../graphics-dbus-audio.xml | 1 + tests/qemuxml2xmltest.c | 4 ++ 9 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/graphics-dbus-audio.xml create mode 120000 tests/qemuxml2xmloutdata/graphics-dbus-audio.xml diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index f0e47ce232..1c0f2e2bfb 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 eb56974fbe..fbefba6200 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -770,6 +770,7 @@ VIR_ENUM_IMPL(virDomainAudioType, "sdl", "spice", "file", + "dbus", ); VIR_ENUM_IMPL(virDomainAudioSDLDriver, @@ -3073,6 +3074,7 @@ virDomainAudioDefFree(virDomainAudioDef *def) g_free(def->backend.file.path); break; + case VIR_DOMAIN_AUDIO_TYPE_DBUS: case VIR_DOMAIN_AUDIO_TYPE_LAST: break; } @@ -12808,6 +12810,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; } @@ -13295,6 +13305,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); @@ -25706,6 +25719,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); @@ -26644,7 +26660,7 @@ virDomainGraphicsDefFormat(virBuffer *buf, virBufferAsprintf(buf, " address='%s'", def->data.dbus.address); - if (!def->data.dbus.gl) + if (!def->data.dbus.gl && def->data.dbus.audioId <= 0) break; if (!children) { @@ -26653,10 +26669,17 @@ virDomainGraphicsDefFormat(virBuffer *buf, children = true; } - virBufferAsprintf(buf, "<gl enable='%s'", - virTristateBoolTypeToString(def->data.dbus.gl)); - virBufferEscapeString(buf, " rendernode='%s'", def->data.dbus.rendernode); - virBufferAddLit(buf, "/>\n"); + if (def->data.dbus.gl) { + virBufferAsprintf(buf, "<gl enable='%s'", + virTristateBoolTypeToString(def->data.dbus.gl)); + virBufferEscapeString(buf, " rendernode='%s'", def->data.dbus.rendernode); + virBufferAddLit(buf, "/>\n"); + } + + if (def->data.dbus.audioId > 0) + virBufferAsprintf(buf, "<audio id='%d'/>\n", + def->data.dbus.audioId); + break; case VIR_DOMAIN_GRAPHICS_TYPE_LAST: break; @@ -29977,6 +30000,7 @@ virDomainAudioBackendIsEqual(virDomainAudioDef *this, case VIR_DOMAIN_AUDIO_TYPE_FILE: return STREQ_NULLABLE(this->backend.file.path, that->backend.file.path); + case VIR_DOMAIN_AUDIO_TYPE_DBUS: case VIR_DOMAIN_AUDIO_TYPE_LAST: default: return false; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 025ed55169..db50e552b0 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1548,6 +1548,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; @@ -1959,6 +1960,7 @@ struct _virDomainGraphicsDef { char *address; char *rendernode; virTristateBool gl; + unsigned int audioId; bool fromConfig; /* true if the @address is config file originated */ } dbus; } data; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 14b5955cad..6c210f6e78 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -4068,6 +4068,13 @@ </optional> </element> </optional> + <optional> + <element name="audio"> + <attribute name="id"> + <ref name="uint8"/> + </attribute> + </element> + </optional> </interleave> </group> <group> @@ -4910,6 +4917,11 @@ <ref name="audiocommonchild"/> </define> + <define name="audiodbus"> + <ref name="audiocommonattr"/> + <ref name="audiocommonchild"/> + </define> + <define name="audio"> <element name="audio"> <attribute name="id"> @@ -4938,6 +4950,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/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5e10f522e5..4ae946ec00 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -147,6 +147,7 @@ qemuAudioDriverTypeToString(virDomainAudioType type) case VIR_DOMAIN_AUDIO_TYPE_OSS: case VIR_DOMAIN_AUDIO_TYPE_SDL: case VIR_DOMAIN_AUDIO_TYPE_SPICE: + case VIR_DOMAIN_AUDIO_TYPE_DBUS: case VIR_DOMAIN_AUDIO_TYPE_LAST: break; } @@ -7986,6 +7987,9 @@ qemuBuildAudioCommandLineArg(virCommand *cmd, return -1; break; + case VIR_DOMAIN_AUDIO_TYPE_DBUS: + break; + case VIR_DOMAIN_AUDIO_TYPE_LAST: default: virReportEnumRangeError(virDomainAudioType, def->type); @@ -8190,6 +8194,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); diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 5a437562c2..5bfb9fd311 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4507,6 +4507,9 @@ qemuValidateDomainDeviceDefAudio(virDomainAudioDef *audio, case VIR_DOMAIN_AUDIO_TYPE_FILE: break; + case VIR_DOMAIN_AUDIO_TYPE_DBUS: + break; + case VIR_DOMAIN_AUDIO_TYPE_LAST: default: virReportEnumRangeError(virDomainAudioType, audio->type); diff --git a/tests/qemuxml2argvdata/graphics-dbus-audio.xml b/tests/qemuxml2argvdata/graphics-dbus-audio.xml new file mode 100644 index 0000000000..b1304e3f6f --- /dev/null +++ b/tests/qemuxml2argvdata/graphics-dbus-audio.xml @@ -0,0 +1,45 @@ +<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'/> + </graphics> + <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/qemuxml2xmloutdata/graphics-dbus-audio.xml b/tests/qemuxml2xmloutdata/graphics-dbus-audio.xml new file mode 120000 index 0000000000..fe0f4a81d9 --- /dev/null +++ b/tests/qemuxml2xmloutdata/graphics-dbus-audio.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/graphics-dbus-audio.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 6578a80213..eb4e070f9e 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -409,6 +409,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.36.1