]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: ensure vhostuser FD is initialized to -1
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 27 Sep 2019 16:34:44 +0000 (17:34 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Mon, 30 Sep 2019 12:08:43 +0000 (13:08 +0100)
The video private data was not initializing the vhostuser FD
causing us to attempt to close FD 0 many times over.

Fixes

  commit ca60ecfa8cc1bd85baf7137dd1864d5f00f019f0
  Author: Marc-André Lureau <marcandre.lureau@redhat.com>
  Date:   Mon Sep 23 14:44:36 2019 +0400

      qemu: add qemuDomainVideoPrivate

Since the test suite does not invoke qemuExtDevicesStart(), no
vhost_user_fd will be present when generating test XML. To deal
with this we can must a fake FD number. While the current XML
is using FD == 0, we pick a very interesting number that's unlikely
to be a real FD, so that we're more likely to see any mistakes
closing the invalid FD.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_domain.c
tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.args
tests/qemuxml2argvdata/vhost-user-vga.x86_64-latest.args
tests/qemuxml2argvdata/virtio-options.args
tests/qemuxml2argvtest.c

index 24c8896ceb0cecb0ce70c9c492f858f9a3f243cf..28e5555b995b3a95672477d806a34d463f8b6bdd 100644 (file)
@@ -1368,6 +1368,8 @@ qemuDomainVideoPrivateNew(void)
     if (!(priv = virObjectNew(qemuDomainVideoPrivateClass)))
         return NULL;
 
+    priv->vhost_user_fd = -1;
+
     return (virObjectPtr) priv;
 }
 
index 58f49595e7a48f1652376e3e11eec2bc2481e1c1..77643d31c07d1da0965d94f3179a012f39c81b14 100644 (file)
@@ -31,8 +31,8 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--chardev socket,id=chr-vu-video0,fd=0 \
--chardev socket,id=chr-vu-video1,fd=0 \
+-chardev socket,id=chr-vu-video0,fd=1729 \
+-chardev socket,id=chr-vu-video1,fd=1729 \
 -device vhost-user-vga,id=video0,max_outputs=1,chardev=chr-vu-video0,bus=pci.0,\
 addr=0x2 \
 -device vhost-user-gpu-pci,id=video1,max_outputs=1,chardev=chr-vu-video1,\
index 6640d86fa5071afdca24bc89e60509e4690c42dc..dd5f9800d922d0b2af7eccd158aece0126f58013 100644 (file)
@@ -31,7 +31,7 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--chardev socket,id=chr-vu-video0,fd=0 \
+-chardev socket,id=chr-vu-video0,fd=1729 \
 -device vhost-user-vga,id=video0,max_outputs=1,chardev=chr-vu-video0,bus=pci.0,\
 addr=0x2 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
index 79216a5503743caa2829a7c618e9a9cff09c0d69..33ecd8f4e890b59307636534282fdd4f04366cd9 100644 (file)
@@ -49,7 +49,7 @@ ats=on \
 ats=on \
 -device virtio-input-host-pci,id=input3,evdev=/dev/input/event1234,bus=pci.0,\
 addr=0x12,iommu_platform=on,ats=on \
--chardev socket,id=chr-vu-video0,fd=0 \
+-chardev socket,id=chr-vu-video0,fd=1729 \
 -device vhost-user-gpu-pci,id=video0,max_outputs=1,chardev=chr-vu-video0,\
 bus=pci.0,addr=0x2,iommu_platform=on,ats=on \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0xc,iommu_platform=on,\
index 5bbac1c8b8375256a1ec4609166e2d4947b413ad..5f4e87aa6dab1da29bcad293d94b3cc47c1f2e65 100644 (file)
@@ -528,6 +528,16 @@ testCompareXMLToArgv(const void *data)
        }
     }
 
+    for (i = 0; i < vm->def->nvideos; i++) {
+        virDomainVideoDefPtr video = vm->def->videos[i];
+
+        if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
+            qemuDomainVideoPrivatePtr vpriv = QEMU_DOMAIN_VIDEO_PRIVATE(video);
+
+            vpriv->vhost_user_fd = 1729;
+        }
+    }
+
     if (flags & FLAG_SLIRP_HELPER) {
         for (i = 0; i < vm->def->nnets; i++) {
             virDomainNetDefPtr net = vm->def->nets[i];