1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

conf: Add USB sound card support and implement it for qemu

This commit is contained in:
Peter Krempa 2014-07-24 17:32:31 +02:00
parent 2e194e5bcc
commit e260a0e60a
17 changed files with 38 additions and 9 deletions

View File

@ -5031,9 +5031,10 @@ qemu-kvm -net nic,model=? /dev/null
The <code>sound</code> element has one mandatory attribute, The <code>sound</code> element has one mandatory attribute,
<code>model</code>, which specifies what real sound device is emulated. <code>model</code>, which specifies what real sound device is emulated.
Valid values are specific to the underlying hypervisor, though typical Valid values are specific to the underlying hypervisor, though typical
choices are 'es1370', 'sb16', 'ac97', and 'ich6' choices are 'es1370', 'sb16', 'ac97', 'ich6' and 'usb'.
(<span class="since"> (<span class="since">
'ac97' only since 0.6.0, 'ich6' only since 0.8.8</span>) 'ac97' only since 0.6.0, 'ich6' only since 0.8.8,
'usb' only since 1.2.7</span>)
</dd> </dd>
</dl> </dl>

View File

@ -3168,6 +3168,7 @@
<value>ac97</value> <value>ac97</value>
<value>ich6</value> <value>ich6</value>
<value>ich9</value> <value>ich9</value>
<value>usb</value>
</choice> </choice>
</attribute> </attribute>
<interleave> <interleave>

View File

@ -458,7 +458,8 @@ VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST,
"pcspk", "pcspk",
"ac97", "ac97",
"ich6", "ich6",
"ich9") "ich9",
"usb")
VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST, VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST,
"virtio", "virtio",

View File

@ -1177,6 +1177,7 @@ typedef enum {
VIR_DOMAIN_SOUND_MODEL_AC97, VIR_DOMAIN_SOUND_MODEL_AC97,
VIR_DOMAIN_SOUND_MODEL_ICH6, VIR_DOMAIN_SOUND_MODEL_ICH6,
VIR_DOMAIN_SOUND_MODEL_ICH9, VIR_DOMAIN_SOUND_MODEL_ICH9,
VIR_DOMAIN_SOUND_MODEL_USB,
VIR_DOMAIN_SOUND_MODEL_LAST VIR_DOMAIN_SOUND_MODEL_LAST
} virDomainSoundModel; } virDomainSoundModel;

View File

@ -264,6 +264,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"memory-backend-ram", /* 170 */ "memory-backend-ram", /* 170 */
"numa", "numa",
"memory-backend-file", "memory-backend-file",
"usb-audio",
); );
@ -1483,6 +1484,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "usb-kbd", QEMU_CAPS_DEVICE_USB_KBD }, { "usb-kbd", QEMU_CAPS_DEVICE_USB_KBD },
{ "memory-backend-ram", QEMU_CAPS_OBJECT_MEMORY_RAM }, { "memory-backend-ram", QEMU_CAPS_OBJECT_MEMORY_RAM },
{ "memory-backend-file", QEMU_CAPS_OBJECT_MEMORY_FILE }, { "memory-backend-file", QEMU_CAPS_OBJECT_MEMORY_FILE },
{ "usb-audio", QEMU_CAPS_OBJECT_USB_AUDIO },
}; };
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {

View File

@ -212,6 +212,7 @@ typedef enum {
QEMU_CAPS_OBJECT_MEMORY_RAM = 170, /* -object memory-backend-ram */ QEMU_CAPS_OBJECT_MEMORY_RAM = 170, /* -object memory-backend-ram */
QEMU_CAPS_NUMA = 171, /* newer -numa handling with disjoint cpu ranges */ QEMU_CAPS_NUMA = 171, /* newer -numa handling with disjoint cpu ranges */
QEMU_CAPS_OBJECT_MEMORY_FILE = 172, /* -object memory-backend-file */ QEMU_CAPS_OBJECT_MEMORY_FILE = 172, /* -object memory-backend-file */
QEMU_CAPS_OBJECT_USB_AUDIO = 173, /* usb-audio device support */
QEMU_CAPS_LAST, /* this must always be the last item */ QEMU_CAPS_LAST, /* this must always be the last item */
} virQEMUCapsFlags; } virQEMUCapsFlags;

View File

@ -2086,9 +2086,10 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
for (i = 0; i < def->nsounds; i++) { for (i = 0; i < def->nsounds; i++) {
if (def->sounds[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) if (def->sounds[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
continue; continue;
/* Skip ISA sound card, and PCSPK */ /* Skip ISA sound card, PCSPK and usb-audio */
if (def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_SB16 || if (def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_SB16 ||
def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_PCSPK) def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_PCSPK ||
def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_USB)
continue; continue;
if (virDomainPCIAddressReserveNextSlot(addrs, &def->sounds[i]->info, if (virDomainPCIAddressReserveNextSlot(addrs, &def->sounds[i]->info,
@ -4683,6 +4684,15 @@ qemuBuildSoundDevStr(virDomainDefPtr def,
case VIR_DOMAIN_SOUND_MODEL_ICH6: case VIR_DOMAIN_SOUND_MODEL_ICH6:
model = "intel-hda"; model = "intel-hda";
break; break;
case VIR_DOMAIN_SOUND_MODEL_USB:
model = "usb-audio";
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_USB_AUDIO)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("usb-audio controller is not supported "
"by this QEMU binary"));
goto error;
}
break;
case VIR_DOMAIN_SOUND_MODEL_ICH9: case VIR_DOMAIN_SOUND_MODEL_ICH9:
model = "ich9-intel-hda"; model = "ich9-intel-hda";
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ICH9_INTEL_HDA)) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ICH9_INTEL_HDA)) {

View File

@ -115,4 +115,5 @@
<flag name='enable-fips'/> <flag name='enable-fips'/>
<flag name='usb-kbd'/> <flag name='usb-kbd'/>
<flag name='host-pci-multidomain'/> <flag name='host-pci-multidomain'/>
<flag name='usb-audio'/>
</qemuCaps> </qemuCaps>

View File

@ -128,4 +128,5 @@
<flag name='kvm-pit-lost-tick-policy'/> <flag name='kvm-pit-lost-tick-policy'/>
<flag name='usb-kbd'/> <flag name='usb-kbd'/>
<flag name='host-pci-multidomain'/> <flag name='host-pci-multidomain'/>
<flag name='usb-audio'/>
</qemuCaps> </qemuCaps>

View File

@ -129,4 +129,5 @@
<flag name='kvm-pit-lost-tick-policy'/> <flag name='kvm-pit-lost-tick-policy'/>
<flag name='usb-kbd'/> <flag name='usb-kbd'/>
<flag name='host-pci-multidomain'/> <flag name='host-pci-multidomain'/>
<flag name='usb-audio'/>
</qemuCaps> </qemuCaps>

View File

@ -137,4 +137,5 @@
<flag name='spiceport'/> <flag name='spiceport'/>
<flag name='usb-kbd'/> <flag name='usb-kbd'/>
<flag name='host-pci-multidomain'/> <flag name='host-pci-multidomain'/>
<flag name='usb-audio'/>
</qemuCaps> </qemuCaps>

View File

@ -144,4 +144,5 @@
<flag name='usb-kbd'/> <flag name='usb-kbd'/>
<flag name='host-pci-multidomain'/> <flag name='host-pci-multidomain'/>
<flag name='msg-timestamp'/> <flag name='msg-timestamp'/>
<flag name='usb-audio'/>
</qemuCaps> </qemuCaps>

View File

@ -143,4 +143,5 @@
<flag name='host-pci-multidomain'/> <flag name='host-pci-multidomain'/>
<flag name='msg-timestamp'/> <flag name='msg-timestamp'/>
<flag name='numa'/> <flag name='numa'/>
<flag name='usb-audio'/>
</qemuCaps> </qemuCaps>

View File

@ -842,7 +842,8 @@ mymain(void)
QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX, QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX,
QEMU_CAPS_VNC_SHARE_POLICY, QEMU_CAPS_VNC_SHARE_POLICY,
QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_USB_KBD,
QEMU_CAPS_DEVICE_USB_STORAGE); QEMU_CAPS_DEVICE_USB_STORAGE,
QEMU_CAPS_OBJECT_USB_AUDIO);
DO_TEST("qemu-1.2.0", 1002000, 0, 0, DO_TEST("qemu-1.2.0", 1002000, 0, 0,
QEMU_CAPS_VNC_COLON, QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT, QEMU_CAPS_NO_REBOOT,
@ -951,7 +952,8 @@ mymain(void)
QEMU_CAPS_VNC_SHARE_POLICY, QEMU_CAPS_VNC_SHARE_POLICY,
QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_DEVICE_USB_STORAGE,
QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_USB_KBD,
QEMU_CAPS_USB_STORAGE_REMOVABLE); QEMU_CAPS_USB_STORAGE_REMOVABLE,
QEMU_CAPS_OBJECT_USB_AUDIO);
DO_TEST("qemu-kvm-1.2.0", 1002000, 1, 0, DO_TEST("qemu-kvm-1.2.0", 1002000, 1, 0,
QEMU_CAPS_VNC_COLON, QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT, QEMU_CAPS_NO_REBOOT,
@ -1065,7 +1067,8 @@ mymain(void)
QEMU_CAPS_VNC_SHARE_POLICY, QEMU_CAPS_VNC_SHARE_POLICY,
QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_DEVICE_USB_STORAGE,
QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_USB_KBD,
QEMU_CAPS_USB_STORAGE_REMOVABLE); QEMU_CAPS_USB_STORAGE_REMOVABLE,
QEMU_CAPS_OBJECT_USB_AUDIO);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
} }

View File

@ -14,4 +14,5 @@ id=sound6-codec0,bus=sound6.0,cad=0 \
-device ich9-intel-hda,id=sound7,bus=pci.0,addr=0x8 \ -device ich9-intel-hda,id=sound7,bus=pci.0,addr=0x8 \
-device hda-micro,id=sound7-codec0,bus=sound7.0,cad=0 \ -device hda-micro,id=sound7-codec0,bus=sound7.0,cad=0 \
-device hda-duplex,id=sound7-codec1,bus=sound7.0,cad=1 \ -device hda-duplex,id=sound7-codec1,bus=sound7.0,cad=1 \
-device usb-audio,id=sound8 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9

View File

@ -36,6 +36,7 @@
<codec type='micro'/> <codec type='micro'/>
<codec type='duplex'/> <codec type='duplex'/>
</sound> </sound>
<sound model='usb'/>
<memballoon model='virtio'/> <memballoon model='virtio'/>
</devices> </devices>
</domain> </domain>

View File

@ -1136,7 +1136,8 @@ mymain(void)
DO_TEST("sound-device", DO_TEST("sound-device",
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO, QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO,
QEMU_CAPS_DEVICE_ICH9_INTEL_HDA); QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,
QEMU_CAPS_OBJECT_USB_AUDIO);
DO_TEST("fs9p", DO_TEST("fs9p",
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV,
QEMU_CAPS_FSDEV_WRITEOUT); QEMU_CAPS_FSDEV_WRITEOUT);