From nobody Mon May 6 10:13:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569843557; cv=none; d=zoho.com; s=zohoarc; b=MPstg+CLmTWJVAiAbH9RBqCfD+mU70rbabD+VY9Pa9x7kM1cm1igzci95dXUwDx1/9qvHSYP/qqCInoX97faMibdDyS67SimXxLipa0anrOoqtGG2g5Hf/nuo7KySjy5L0EcKaf3S1X8LRcejiIfdRWSTUYcYAEh1xxpRyAMXxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569843557; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=81TAe/rv41kfxLvZs5fCKKma2DXx5lNd63x+GIJ5AOY=; b=Ry5loWpc2IryYjX0gqS9Ijdm7SjHI4UqZic+9SoVcP8dWZfXOqnow37JOvfssb6/ap4xnn498NLLNHGES1Wq8oaRN5bO79AQgi6ukIRXIMbBmOu6gyvUlJrIsuQjvlsL+H5vcbAbJ5iuHj9simkF7Pr6nm/yzUqKh6xR7Oztrxw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156984355790021.005373885740596; Mon, 30 Sep 2019 04:39:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 208DE20E3; Mon, 30 Sep 2019 11:39:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED26A60C5D; Mon, 30 Sep 2019 11:39:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A74751803B37; Mon, 30 Sep 2019 11:39:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8UBdEZY002563 for ; Mon, 30 Sep 2019 07:39:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id F369F1001B2D; Mon, 30 Sep 2019 11:39:13 +0000 (UTC) Received: from dhcp-17-55.lcy.redhat.com (unknown [10.42.17.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 650DB10027A1; Mon, 30 Sep 2019 11:39:11 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 30 Sep 2019 12:39:08 +0100 Message-Id: <20190930113908.5675-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] qemu: ensure vhostuser FD is initialized to -1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Mon, 30 Sep 2019 11:39:16 +0000 (UTC) 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=C3=A9 Lureau 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 =3D=3D 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- In v2: - Fix FD initialization in test suite src/qemu/qemu_domain.c | 2 ++ .../vhost-user-gpu-secondary.x86_64-latest.args | 4 ++-- .../qemuxml2argvdata/vhost-user-vga.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/virtio-options.args | 2 +- tests/qemuxml2argvtest.c | 10 ++++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e8e895d9aa..e2b78c2457 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1367,6 +1367,8 @@ qemuDomainVideoPrivateNew(void) if (!(priv =3D virObjectNew(qemuDomainVideoPrivateClass))) return NULL; =20 + priv->vhost_user_fd =3D -1; + return (virObjectPtr) priv; } =20 diff --git a/tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.= args b/tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.args index 58f49595e7..77643d31c0 100644 --- a/tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.args @@ -31,8 +31,8 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --chardev socket,id=3Dchr-vu-video0,fd=3D0 \ --chardev socket,id=3Dchr-vu-video1,fd=3D0 \ +-chardev socket,id=3Dchr-vu-video0,fd=3D1729 \ +-chardev socket,id=3Dchr-vu-video1,fd=3D1729 \ -device vhost-user-vga,id=3Dvideo0,max_outputs=3D1,chardev=3Dchr-vu-video0= ,bus=3Dpci.0,\ addr=3D0x2 \ -device vhost-user-gpu-pci,id=3Dvideo1,max_outputs=3D1,chardev=3Dchr-vu-vi= deo1,\ diff --git a/tests/qemuxml2argvdata/vhost-user-vga.x86_64-latest.args b/tes= ts/qemuxml2argvdata/vhost-user-vga.x86_64-latest.args index 6640d86fa5..dd5f9800d9 100644 --- a/tests/qemuxml2argvdata/vhost-user-vga.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-vga.x86_64-latest.args @@ -31,7 +31,7 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --chardev socket,id=3Dchr-vu-video0,fd=3D0 \ +-chardev socket,id=3Dchr-vu-video0,fd=3D1729 \ -device vhost-user-vga,id=3Dvideo0,max_outputs=3D1,chardev=3Dchr-vu-video0= ,bus=3Dpci.0,\ addr=3D0x2 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 \ diff --git a/tests/qemuxml2argvdata/virtio-options.args b/tests/qemuxml2arg= vdata/virtio-options.args index 79216a5503..33ecd8f4e8 100644 --- a/tests/qemuxml2argvdata/virtio-options.args +++ b/tests/qemuxml2argvdata/virtio-options.args @@ -49,7 +49,7 @@ ats=3Don \ ats=3Don \ -device virtio-input-host-pci,id=3Dinput3,evdev=3D/dev/input/event1234,bus= =3Dpci.0,\ addr=3D0x12,iommu_platform=3Don,ats=3Don \ --chardev socket,id=3Dchr-vu-video0,fd=3D0 \ +-chardev socket,id=3Dchr-vu-video0,fd=3D1729 \ -device vhost-user-gpu-pci,id=3Dvideo0,max_outputs=3D1,chardev=3Dchr-vu-vi= deo0,\ bus=3Dpci.0,addr=3D0x2,iommu_platform=3Don,ats=3Don \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0xc,iommu_plat= form=3Don,\ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5bbac1c8b8..5f4e87aa6d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -528,6 +528,16 @@ testCompareXMLToArgv(const void *data) } } =20 + for (i =3D 0; i < vm->def->nvideos; i++) { + virDomainVideoDefPtr video =3D vm->def->videos[i]; + + if (video->backend =3D=3D VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER)= { + qemuDomainVideoPrivatePtr vpriv =3D QEMU_DOMAIN_VIDEO_PRIVATE(= video); + + vpriv->vhost_user_fd =3D 1729; + } + } + if (flags & FLAG_SLIRP_HELPER) { for (i =3D 0; i < vm->def->nnets; i++) { virDomainNetDefPtr net =3D vm->def->nets[i]; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list