]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: cold-plug of sound
authorJidong Xia <xiajidong@cmss.chinamobile.com>
Tue, 15 Oct 2019 06:41:27 +0000 (14:41 +0800)
committerCole Robinson <crobinso@redhat.com>
Thu, 14 Nov 2019 13:42:59 +0000 (08:42 -0500)
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>
src/qemu/qemu_driver.c

index 159a6dc4645687bee34a3e410b98b830e010f378..b648386ac93abca96403f0949a4483066d51be93 100644 (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: