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 | 34 +++++++++++---
src/conf/domain_conf.h | 2 +
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/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 cf858dfcd6e8..0ed58384c5ea 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 11eb1422d8c1..45bbed8dcced 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;
}
@@ -12901,6 +12903,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;
}
@@ -13391,6 +13401,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);
@@ -25738,6 +25751,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);
@@ -26672,7 +26688,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) {
@@ -26681,10 +26697,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;
@@ -29991,6 +30014,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 384b85db3a2c..ff765e4cc282 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;
bool fromConfig; /* true if the @address is config file originated */
} dbus;
} data;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7265aae0f503..fd1943e94a2d 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",
);
@@ -8038,6 +8039,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);
@@ -8242,6 +8246,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 05792f4e4c0a..cebaa81361cb 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -4417,6 +4417,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 000000000000..b1304e3f6ff8
--- /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 000000000000..fe0f4a81d9e4
--- /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 ba891df0dfb6..e3bcd49c810f 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.34.1.8.g35151cf07204