conf: add <audio type='dbus'> support

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Marc-André Lureau 2022-05-13 20:38:15 +02:00 committed by Michal Privoznik
parent bf213aa965
commit a062f5f777
9 changed files with 121 additions and 5 deletions

View File

@ -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));

View File

@ -770,6 +770,7 @@ VIR_ENUM_IMPL(virDomainAudioType,
"sdl",
"spice",
"file",
"dbus",
);
VIR_ENUM_IMPL(virDomainAudioSDLDriver,
@ -3074,6 +3075,7 @@ virDomainAudioDefFree(virDomainAudioDef *def)
g_free(def->backend.file.path);
break;
case VIR_DOMAIN_AUDIO_TYPE_DBUS:
case VIR_DOMAIN_AUDIO_TYPE_LAST:
break;
}
@ -12809,6 +12811,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;
}
@ -13296,6 +13306,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);
@ -25719,6 +25732,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);
@ -26660,7 +26676,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) {
@ -26669,10 +26685,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;
@ -29993,6 +30016,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;

View File

@ -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;

View File

@ -4076,6 +4076,13 @@
</optional>
</element>
</optional>
<optional>
<element name="audio">
<attribute name="id">
<ref name="uint8"/>
</attribute>
</element>
</optional>
</interleave>
</group>
<group>
@ -4918,6 +4925,11 @@
<ref name="audiocommonchild"/>
</define>
<define name="audiodbus">
<ref name="audiocommonattr"/>
<ref name="audiocommonchild"/>
</define>
<define name="audio">
<element name="audio">
<attribute name="id">
@ -4946,6 +4958,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>

View File

@ -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;
}
@ -7957,6 +7958,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);
@ -8161,6 +8165,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);

View File

@ -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);

View File

@ -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>

View File

@ -0,0 +1 @@
../qemuxml2argvdata/graphics-dbus-audio.xml

View File

@ -412,6 +412,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");