From patchwork Fri Aug 23 16:21:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 172125 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp886357ily; Fri, 23 Aug 2019 09:22:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXNGWZuFiEtbRrhynSEFAkl+2gpPhD+0WJfl82oNEciCZriZtb0uJ0zrRdOmQraXoi526u X-Received: by 2002:a05:620a:1287:: with SMTP id w7mr4820709qki.25.1566577365018; Fri, 23 Aug 2019 09:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566577365; cv=none; d=google.com; s=arc-20160816; b=hBsGjPK1rrtPdQqrXgIdq2j2ku6SbOlbni3a9QRYHEGRxdRWuStQwQRThBmXT467MD YIoWAJRROXrrsk6m0upB0flsXYMKsDOWG0sWWi2FS/GJZvxcbN/vzkItpr+z57ZkkQnL 3XfLntlTDCH9J3KMvQ+WlT+5iCmu6BrNeKjH933XA2ZTzxQaXGYh16Pq4uMk8NH1An0b KV5MsTr0IERzXkQfryVhwFMyL9jr57V8qAeie53apTX45qJ3giGkoVDeNDt5JM7Ssn2V ToQwjXlSc1wppNO/IZg3ALGiTq5nCuTptfq/A9kZz4izIa+TzZNOz+oCysINi18nvdFe f6YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=/QW/Zi8t//W0D2Ss0PBdY0fqCCq7AqvpmDiJ0ltUtIY=; b=s7INu5XDSJc1eVe5oX4CTP0DkAc4oNMY/6oJw3AFMnfkCuqtrpjaDjrA6o1opHrdyx EyOaaVb5ocNsg0jcVms3G3QFeLTMdvsrWQc19++orx6jyitgBwl2Vlrsumh6H+Xjewr2 ZhhmVjV+1WRxC0s99/bHo/UzhG8OlGEwIvoDqswUVHJAKgwDhvvo9Eh/37sdgmjtwM/9 sZo12tbPt9Ns+l9/fUjuZu2lfyWvR4+nFO5USWIB4NHzi+nkH7pR2PP+yvmwtRjQ6Ry3 5vQ0a1B4YDaU4vlj6IVIPlQ+TDEhQmkaTWaLhRX1ru/E0FybD+2ktAjHRZxiqE7HCl+G VGLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id f1si2239112qtk.51.2019.08.23.09.22.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2019 09:22:45 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 84F1410576E0; Fri, 23 Aug 2019 16:22:43 +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 5B0B11901F; Fri, 23 Aug 2019 16:22: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 1F40C180BAA4; Fri, 23 Aug 2019 16:22: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 x7NGMCjl006091 for ; Fri, 23 Aug 2019 12:22:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB3806092D; Fri, 23 Aug 2019 16:22:12 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com [10.10.122.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49DB960605; Fri, 23 Aug 2019 16:22:12 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 23 Aug 2019 12:21:58 -0400 Message-Id: <98d3ca86997a6171090d1a6cc544fcafc31305b7.1566576129.git.crobinso@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 Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [libvirt] [PATCH v2 14/16] 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: , 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.6.2 (mx1.redhat.com [10.5.110.64]); Fri, 23 Aug 2019 16:22:44 +0000 (UTC) From: Marc-André 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é Lureau Signed-off-by: Cole Robinson --- src/qemu/qemu_command.c | 46 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8bef103f68..0e1d9510e5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4672,8 +4672,15 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, goto error; } - if (STREQ(model, "virtio-gpu")) { - if (qemuBuildVirtioDevStr(&buf, "virtio-gpu", qemuCaps, + if (video->vhostuser) { + if (STREQ(model, "virtio-vga")) + model = "vhost-user-vga"; + if (STREQ(model, "virtio-gpu")) + model = "vhost-user-gpu"; + } + + if (STREQ(model, "virtio-gpu") || STREQ(model, "vhost-user-gpu")) { + if (qemuBuildVirtioDevStr(&buf, model, qemuCaps, VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { goto error; } @@ -4715,6 +4722,10 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, if (video->heads) virBufferAsprintf(&buf, ",max_outputs=%u", video->heads); } + } else if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO && video->vhostuser) { + if (video->heads) + virBufferAsprintf(&buf, ",max_outputs=%u", video->heads); + virBufferAsprintf(&buf, ",chardev=chr-vu-%s", video->info.alias); } else if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS)) { if (video->heads) @@ -4830,6 +4841,23 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd, } +static char * +qemuBuildVhostUserChardevStr(const char *alias, + int *fd, + virCommandPtr cmd) +{ + char *chardev = NULL; + + if (virAsprintf(&chardev, "socket,id=chr-vu-%s,fd=%d", alias, *fd) < 0) + return NULL; + + virCommandPassFD(cmd, *fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); + *fd = -1; + + return chardev; +} + + static int qemuBuildVideoCommandLine(virCommandPtr cmd, const virDomainDef *def, @@ -4837,6 +4865,20 @@ qemuBuildVideoCommandLine(virCommandPtr cmd, { size_t i; + for (i = 0; i < def->nvideos; i++) { + VIR_AUTOFREE(char *) chardev = NULL; + virDomainVideoDefPtr video = def->videos[i]; + + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO && video->vhostuser) { + if (!(chardev = qemuBuildVhostUserChardevStr(video->info.alias, + &video->info.vhost_user_fd, + cmd))) + return -1; + + virCommandAddArgList(cmd, "-chardev", chardev, NULL); + } + } + for (i = 0; i < def->nvideos; i++) { char *str = NULL; virDomainVideoDefPtr video = def->videos[i];