qemu: ensure vhostuser FD is initialized to -1

The video private data was not initializing the vhostuser FD
causing us to attempt to close FD 0 many times over.

Fixes

  commit ca60ecfa8c
  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>
This commit is contained in:
Daniel P. Berrangé 2019-09-27 17:34:44 +01:00
parent 7a46bd5202
commit 227925a2e5
5 changed files with 16 additions and 4 deletions

View File

@ -1368,6 +1368,8 @@ qemuDomainVideoPrivateNew(void)
if (!(priv = virObjectNew(qemuDomainVideoPrivateClass)))
return NULL;
priv->vhost_user_fd = -1;
return (virObjectPtr) priv;
}

View 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,\

View 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 \

View 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,\

View 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];