From nobody Mon Feb 9 13:59:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1639053172; cv=none; d=zohomail.com; s=zohoarc; b=PNvNOEENPLVTZ6n5+WFdRSrm2rrYNjeDKGk/C0IIyARqp/sT6hXjZBe8RrDG46XG6tQAnA4H6jOdL68EcrWEprz74iBDm7H2wCPFCXUir6bPxSVUiasORDzbJYFJj+BvXYoIEVgfvTOGr6gFFf95T8THWb5Pn2GPinFvLh5wbzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639053172; h=Content-Type:Content-Transfer-Encoding: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; bh=hxJCjaQyzO8z8Qq0O/eYiBFpM2me4jGtKm3WV7Za4+Y=; b=Ns3i5xm5XH/B5VF9WmuB4Iktec+D0FYkmiKCg4k+2ZGZB69wmshAx6w1yUjjUqnesWa8gRzSt10vTI9RoN+H7m3tl8u0NAzAnmszhCwJkLAaWPxp0wtaCnWtMpLNZ/qKTGhpvdLcDCOjwIARqyI5iQG1+GqHmYnWGH2joX5KH7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639053172920535.6745352260685; Thu, 9 Dec 2021 04:32:52 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-366-xSTSD5cROXiZVzZM5395vA-1; Thu, 09 Dec 2021 07:32:48 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 039C510144E9; Thu, 9 Dec 2021 12:32:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DAF3E5E275; Thu, 9 Dec 2021 12:32:43 +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 A749C4A70D; Thu, 9 Dec 2021 12:32:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9CVPof017969 for ; Thu, 9 Dec 2021 07:31:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 383814ABB5; Thu, 9 Dec 2021 12:31:25 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E1321B472 for ; Thu, 9 Dec 2021 12:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639053171; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hxJCjaQyzO8z8Qq0O/eYiBFpM2me4jGtKm3WV7Za4+Y=; b=Df1hkeESjsUR9KtUBKTrZVFomMK7GpiCqU66lN0AnPEZ/waLfQqVany4VpJ2Oe+GuLgqrE kI9Ci7Wl61xjCKLuIe3FPXEU/L4+XTk69Bjnaj4MQcqnXnlXr7TZxc7a6PzTRYb4l3sPYz w+UWrmpoZuKNQHkmD0EX8riaiDnhlHs= X-MC-Unique: xSTSD5cROXiZVzZM5395vA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/24] qemu: Use qemuBuildChrChardevCommand for vhost-user-gpu backend chardev Date: Thu, 9 Dec 2021 13:30:57 +0100 Message-Id: <23b7fe0e6710766de2788c633abe4c3d0ea78ea6.1639052639.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639053174205100001 Content-Type: text/plain; charset="utf-8" Now that the API for qemuBuildChrChardevCommand is sane enough, we can use it to centralize formatting of '-chardev' generally. The 'virDomainVideoDef' doesn't use 'virDomainChrSourceDef' internally so we create it for this occasion manually. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 57 ++++++------------- ...host-user-gpu-secondary.x86_64-latest.args | 2 +- ...irtio-options-video-ats.x86_64-latest.args | 2 +- ...tio-options-video-iommu.x86_64-latest.args | 2 +- ...io-options-video-packed.x86_64-latest.args | 2 +- 5 files changed, 21 insertions(+), 44 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3a5796fed8..3ca7da9d5d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4939,60 +4939,37 @@ qemuBuildDeviceVideoCmd(virCommand *cmd, } -static char * -qemuBuildVhostUserChardevStr(const char *alias, - int *fd, - virCommand *cmd) -{ - g_autofree char *chardev_alias =3D qemuDomainGetVhostUserChrAlias(alia= s); - char *chardev =3D NULL; - - if (*fd =3D=3D -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Attempt to pass closed vhostuser FD")); - return NULL; - } - - chardev =3D g_strdup_printf("socket,id=3D%s,fd=3D%d", chardev_alias, *= fd); - - virCommandPassFD(cmd, *fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); - *fd =3D -1; - - return chardev; -} - - static int qemuBuildVideoCommandLine(virCommand *cmd, const virDomainDef *def, - virQEMUCaps *qemuCaps) + qemuDomainObjPrivate *priv) { size_t i; for (i =3D 0; i < def->nvideos; i++) { - g_autofree char *chardev =3D NULL; virDomainVideoDef *video =3D def->videos[i]; + if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE) + continue; + 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; + qemuDomainVideoPrivate *videopriv =3D QEMU_DOMAIN_VIDEO_PRIVAT= E(video); + g_autoptr(virDomainChrSourceDef) chrsrc =3D virDomainChrSource= DefNew(priv->driver->xmlopt); + g_autofree char *chrAlias =3D qemuDomainGetVhostUserChrAlias(v= ideo->info.alias); + qemuDomainChrSourcePrivate *chrsrcpriv =3D QEMU_DOMAIN_CHR_SOU= RCE_PRIVATE(chrsrc); - virCommandAddArgList(cmd, "-chardev", chardev, NULL); - } - } + chrsrc->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + chrsrcpriv->fd =3D videopriv->vhost_user_fd; + videopriv->vhost_user_fd =3D -1; - for (i =3D 0; i < def->nvideos; i++) { - virDomainVideoDef *video =3D def->videos[i]; - - if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE) - continue; + if (qemuBuildChardevCommand(cmd, chrsrc, chrAlias, priv->qemuC= aps) < 0) + return -1; + } - if (qemuCommandAddExtDevice(cmd, &def->videos[i]->info, qemuCaps) = < 0) + if (qemuCommandAddExtDevice(cmd, &def->videos[i]->info, priv->qemu= Caps) < 0) return -1; - if (qemuBuildDeviceVideoCmd(cmd, def, video, qemuCaps) < 0) + if (qemuBuildDeviceVideoCmd(cmd, def, video, priv->qemuCaps) < 0) return -1; } @@ -10646,7 +10623,7 @@ qemuBuildCommandLine(virQEMUDriver *driver, if (qemuBuildGraphicsCommandLine(cfg, cmd, def, qemuCaps) < 0) return NULL; - if (qemuBuildVideoCommandLine(cmd, def, qemuCaps) < 0) + if (qemuBuildVideoCommandLine(cmd, def, priv) < 0) return NULL; if (qemuBuildSoundCommandLine(cmd, def, qemuCaps) < 0) 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 7f0db5fbce..43ae421715 100644 --- a/tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.args @@ -34,8 +34,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -chardev socket,id=3Dchr-vu-video0,fd=3D1729 \ --chardev socket,id=3Dchr-vu-video1,fd=3D1729 \ -device '{"driver":"vhost-user-vga","id":"video0","max_outputs":1,"chardev= ":"chr-vu-video0","bus":"pci.0","addr":"0x2"}' \ +-chardev socket,id=3Dchr-vu-video1,fd=3D1729 \ -device '{"driver":"vhost-user-gpu-pci","id":"video1","max_outputs":1,"cha= rdev":"chr-vu-video1","bus":"pci.0","addr":"0x4"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x3"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ diff --git a/tests/qemuxml2argvdata/virtio-options-video-ats.x86_64-latest.= args b/tests/qemuxml2argvdata/virtio-options-video-ats.x86_64-latest.args index 4ec8d006e7..c0b5ad781a 100644 --- a/tests/qemuxml2argvdata/virtio-options-video-ats.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-video-ats.x86_64-latest.args @@ -30,8 +30,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -chardev socket,id=3Dchr-vu-video0,fd=3D1729 \ --chardev socket,id=3Dchr-vu-video1,fd=3D1729 \ -device '{"driver":"vhost-user-vga","id":"video0","max_outputs":1,"chardev= ":"chr-vu-video0","bus":"pci.0","addr":"0x2"}' \ +-chardev socket,id=3Dchr-vu-video1,fd=3D1729 \ -device '{"driver":"vhost-user-gpu-pci","ats":false,"id":"video1","max_out= puts":1,"chardev":"chr-vu-video1","bus":"pci.0","addr":"0x3"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x4"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ diff --git a/tests/qemuxml2argvdata/virtio-options-video-iommu.x86_64-lates= t.args b/tests/qemuxml2argvdata/virtio-options-video-iommu.x86_64-latest.ar= gs index d90b5c674f..48c7bcf7f6 100644 --- a/tests/qemuxml2argvdata/virtio-options-video-iommu.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-video-iommu.x86_64-latest.args @@ -30,8 +30,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -chardev socket,id=3Dchr-vu-video0,fd=3D1729 \ --chardev socket,id=3Dchr-vu-video1,fd=3D1729 \ -device '{"driver":"vhost-user-vga","id":"video0","max_outputs":1,"chardev= ":"chr-vu-video0","bus":"pci.0","addr":"0x2"}' \ +-chardev socket,id=3Dchr-vu-video1,fd=3D1729 \ -device '{"driver":"vhost-user-gpu-pci","iommu_platform":false,"id":"video= 1","max_outputs":1,"chardev":"chr-vu-video1","bus":"pci.0","addr":"0x3"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x4"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ diff --git a/tests/qemuxml2argvdata/virtio-options-video-packed.x86_64-late= st.args b/tests/qemuxml2argvdata/virtio-options-video-packed.x86_64-latest.= args index 532285eb85..f1b96b92d7 100644 --- a/tests/qemuxml2argvdata/virtio-options-video-packed.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-video-packed.x86_64-latest.args @@ -30,8 +30,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -chardev socket,id=3Dchr-vu-video0,fd=3D1729 \ --chardev socket,id=3Dchr-vu-video1,fd=3D1729 \ -device '{"driver":"vhost-user-vga","id":"video0","max_outputs":1,"chardev= ":"chr-vu-video0","bus":"pci.0","addr":"0x2"}' \ +-chardev socket,id=3Dchr-vu-video1,fd=3D1729 \ -device '{"driver":"vhost-user-gpu-pci","packed":false,"id":"video1","max_= outputs":1,"chardev":"chr-vu-video1","bus":"pci.0","addr":"0x3"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x4"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ --=20 2.31.1