qemu: cold-plug of sound

With this patch users can cold plug some sound devices.
use "virsh attach-device vm sound.xml --config" command.
Consider the following sound.xml for a domain:
    <sound model='ich6'>
         <address type='pci' domain='0x0000' bus='0x00' slot='xxx' function='0'/>
    </sound>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jidong Xia <xiajidong@cmss.chinamobile.com>
This commit is contained in:
Jidong Xia 2019-10-15 14:41:27 +08:00 committed by Cole Robinson
parent 35e1547870
commit 9ec64b591e

View File

@ -8103,6 +8103,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
{
virDomainDiskDefPtr disk;
virDomainNetDefPtr net;
virDomainSoundDefPtr sound;
virDomainHostdevDefPtr hostdev;
virDomainLeaseDefPtr lease;
virDomainControllerDefPtr controller;
@ -8137,6 +8138,13 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
dev->data.net = NULL;
break;
case VIR_DOMAIN_DEVICE_SOUND:
sound = dev->data.sound;
if (VIR_APPEND_ELEMENT(vmdef->sounds, vmdef->nsounds, sound) < 0)
return -1;
dev->data.sound = NULL;
break;
case VIR_DOMAIN_DEVICE_HOSTDEV:
hostdev = dev->data.hostdev;
if (virDomainHostdevFind(vmdef, hostdev, NULL) >= 0) {
@ -8271,7 +8279,6 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
vmdef->vsock = g_steal_pointer(&dev->data.vsock);
break;
case VIR_DOMAIN_DEVICE_SOUND:
case VIR_DOMAIN_DEVICE_VIDEO:
case VIR_DOMAIN_DEVICE_GRAPHICS:
case VIR_DOMAIN_DEVICE_HUB: