From nobody Mon Feb 9 22:19:13 2026 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=1567188337; cv=none; d=zoho.com; s=zohoarc; b=azKxts/FHlcCgUVknhbkv9yDiB9rZcqHUn92on87f4RmuPXJVXHNWxJTHP8Eh9UvaZ77z7NSKpMfPUPIh1ftWlukk2MhgGgH94w4l0BMel4ZS7DTc5zfE/zhFXbNwTxxf2g5EkOLDU9VTJXj2MeK1BjWhJbPaaHYpQFAIOewCwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567188337; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hvX9C2daD8W3wX5hf6yEoz/3mrzt15YHSlgEJeQEKpg=; b=A0MHB6zbvVRT8tic3+Cqus4AywkSj/hf9vqAx5j6g4zayTWlZNkXlNkdBVJxgpBiCjSrnrlGIw1dPUY3ZKwquLl4wouVj3e8naPNoo+jzrHkSSRd/j3FjlRDIXiXQ+yFuxH7c67QNBRxDvZWlfJ/lp5fEZDp+EzwWl9MQY8Q8ks= 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 1567188337147215.22658743820125; Fri, 30 Aug 2019 11:05:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F10446CFCD; Fri, 30 Aug 2019 18:05:35 +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 C37285D9CA; Fri, 30 Aug 2019 18:05:35 +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 85B69180B536; Fri, 30 Aug 2019 18:05:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7UI5XjV031839 for ; Fri, 30 Aug 2019 14:05:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC5A360167; Fri, 30 Aug 2019 18:05:33 +0000 (UTC) Received: from localhost (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C94B6012C; Fri, 30 Aug 2019 18:05:27 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Fri, 30 Aug 2019 22:02:00 +0400 Message-Id: <20190830180202.22278-18-marcandre.lureau@redhat.com> In-Reply-To: <20190830180202.22278-1-marcandre.lureau@redhat.com> References: <20190830180202.22278-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , jtomko@redhat.com Subject: [libvirt] [PATCH v3 17/19] qemu: build vhost-user GPU devices 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 30 Aug 2019 18:05:36 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau For each vhost-user GPUs, - build a socket chardev, and pass the vhost-user socket to it - build a vhost-user video device and associate it with the chardev Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_command.c | 56 +++++++++++++++++++--- tests/qemuxml2argvdata/virtio-options.args | 5 +- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e232406ff9..bf71f447a4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4519,16 +4519,23 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { VIR_AUTOCLEAN(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - const char *model; + const char *model =3D NULL; =20 /* We try to chose the best model for primary video device by preferri= ng * model with VGA compatibility mode. For some video devices on some * architectures there might not be such model so fallback to one * without VGA compatibility mode. */ - if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) - model =3D qemuDeviceVideoTypeToString(video->type); - else - model =3D qemuDeviceVideoSecondaryTypeToString(video->type); + if (video->backend =3D=3D VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { + if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) + model =3D "vhost-user-vga"; + else + model =3D "vhost-user-gpu"; + } else { + if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) + model =3D qemuDeviceVideoTypeToString(video->type); + else + model =3D qemuDeviceVideoSecondaryTypeToString(video->type); + } =20 if (!model || STREQ(model, "")) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -4537,8 +4544,8 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, return NULL; } =20 - if (STREQ(model, "virtio-gpu")) { - if (qemuBuildVirtioDevStr(&buf, "virtio-gpu", qemuCaps, + if (STREQ(model, "virtio-gpu") || STREQ(model, "vhost-user-gpu")) { + if (qemuBuildVirtioDevStr(&buf, model, qemuCaps, VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { return NULL; } @@ -4581,6 +4588,10 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, if (video->heads) virBufferAsprintf(&buf, ",max_outputs=3D%u", video->heads); } + } else if (video->backend =3D=3D VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUS= ER) { + if (video->heads) + virBufferAsprintf(&buf, ",max_outputs=3D%u", video->heads); + virBufferAsprintf(&buf, ",chardev=3Dchr-vu-%s", video->info.alias); } else if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS)) { if (video->heads) @@ -4692,6 +4703,23 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd, } =20 =20 +static char * +qemuBuildVhostUserChardevStr(const char *alias, + int *fd, + virCommandPtr cmd) +{ + char *chardev =3D NULL; + + if (virAsprintf(&chardev, "socket,id=3Dchr-vu-%s,fd=3D%d", alias, *fd)= < 0) + return NULL; + + virCommandPassFD(cmd, *fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); + *fd =3D -1; + + return chardev; +} + + static int qemuBuildVideoCommandLine(virCommandPtr cmd, const virDomainDef *def, @@ -4699,6 +4727,20 @@ qemuBuildVideoCommandLine(virCommandPtr cmd, { size_t i; =20 + for (i =3D 0; i < def->nvideos; i++) { + VIR_AUTOFREE(char *) chardev =3D NULL; + virDomainVideoDefPtr video =3D def->videos[i]; + + if (video->backend =3D=3D VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER)= { + if (!(chardev =3D qemuBuildVhostUserChardevStr(video->info.ali= as, + &QEMU_DOMAIN_VIDEO_PRIVATE(video)->vhost_u= ser_fd, + cmd))) + return -1; + + virCommandAddArgList(cmd, "-chardev", chardev, NULL); + } + } + for (i =3D 0; i < def->nvideos; i++) { VIR_AUTOFREE(char *) str =3D NULL; virDomainVideoDefPtr video =3D def->videos[i]; diff --git a/tests/qemuxml2argvdata/virtio-options.args b/tests/qemuxml2arg= vdata/virtio-options.args index 69dc1c73e5..f3d0f507f6 100644 --- a/tests/qemuxml2argvdata/virtio-options.args +++ b/tests/qemuxml2argvdata/virtio-options.args @@ -49,8 +49,9 @@ 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 \ --device virtio-gpu-pci,id=3Dvideo0,bus=3Dpci.0,addr=3D0x2,iommu_platform= =3Don,\ -ats=3Don \ +-chardev socket,id=3Dchr-vu-video0,fd=3D0 \ +-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,\ ats=3Don \ -object rng-random,id=3Dobjrng0,filename=3D/dev/random \ --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list