From nobody Mon Feb 9 19:47:52 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=1559730922; cv=none; d=zoho.com; s=zohoarc; b=doBVi3tmfLlT/yEiSHPpnAYtHJ0Nig+obkgQQg/d9ZD9SBMz9wdSN4Gr+soos2Fy+JkppzfM4HgOpqUKpv1G9xj4sCNNveT+CLsLBAzYin6UhEfXjl4GF6YmG6vSEjhXeBdxPZI3MeU21BeKkqdfG5Nh8Ea97j7SzH0L70ZNbuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559730922; 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=+D1YH343uNRDRwH4MyCa2WwmeEbTXxRt4UoJ2YCqqxo=; b=gUFvZJjbPDorrFGog4DONHnsBf0kh66VIgCxs+VV8+xj+CJFT+AV9ljuEQ2UpnQMoLhrB/MD1j/xF70HShWt4lunu8vC28in+OI8Z3HAuKu9UOFto9UcKm04y+tknByfmr/87kgUQAqDjzuk5ocf+FjsaINE06jw8WTjHOAaUFI= 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 155973092201154.21818827100981; Wed, 5 Jun 2019 03:35:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 41B897CB95; Wed, 5 Jun 2019 10:35:20 +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 1441519749; Wed, 5 Jun 2019 10:35:20 +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 BD09F1806B15; Wed, 5 Jun 2019 10:35:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x55AWtuG020405 for ; Wed, 5 Jun 2019 06:32:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6A77C3844; Wed, 5 Jun 2019 10:32:55 +0000 (UTC) Received: from localhost (ovpn-112-54.ams2.redhat.com [10.36.112.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 478895D9CC; Wed, 5 Jun 2019 10:32:49 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Wed, 5 Jun 2019 12:31:14 +0200 Message-Id: <20190605103117.19047-17-marcandre.lureau@redhat.com> In-Reply-To: <20190605103117.19047-1-marcandre.lureau@redhat.com> References: <20190605103117.19047-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 16/19] qemu: start/stop the vhost-user-gpu external device 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 05 Jun 2019 10:35:20 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau Each vhost-user-gpu needs its own helper gpu process. Start/stop them, and apply the emulator cgroup controller. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_extdevice.c | 49 +++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 977743d240..7e78e10cdd 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -24,6 +24,7 @@ #include "qemu_vhost_user_gpu.h" #include "qemu_domain.h" #include "qemu_tpm.h" +#include "qemu_vhost_user_gpu.h" =20 #include "viralloc.h" #include "virlog.h" @@ -160,11 +161,21 @@ qemuExtDevicesStart(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainLogContextPtr logCtxt) { - int ret =3D 0; + int i, ret =3D 0; =20 if (qemuExtDevicesInitPaths(driver, vm->def) < 0) return -1; =20 + for (i =3D 0; i < vm->def->nvideos; i++) { + virDomainVideoDefPtr video =3D vm->def->videos[i]; + + if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && video->vhos= tuser) { + ret =3D qemuExtVhostUserGPUStart(driver, vm, video, logCtxt); + if (ret < 0) + return ret; + } + } + if (vm->def->tpm) ret =3D qemuExtTPMStart(driver, vm, logCtxt); =20 @@ -176,9 +187,19 @@ void qemuExtDevicesStop(virQEMUDriverPtr driver, virDomainObjPtr vm) { + int i; + if (qemuExtDevicesInitPaths(driver, vm->def) < 0) return; =20 + for (i =3D 0; i < vm->def->nvideos; i++) { + virDomainVideoDefPtr video =3D vm->def->videos[i]; + + if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && video->vhos= tuser) { + qemuExtVhostUserGPUStop(driver, vm, video); + } + } + if (vm->def->tpm) qemuExtTPMStop(driver, vm); } @@ -187,6 +208,14 @@ qemuExtDevicesStop(virQEMUDriverPtr driver, bool qemuExtDevicesHasDevice(virDomainDefPtr def) { + int i; + + for (i =3D 0; i < def->nvideos; i++) { + if (def->videos[i]->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && + def->videos[i]->vhostuser) + return true; + } + if (def->tpm && def->tpm->type =3D=3D VIR_DOMAIN_TPM_TYPE_EMULATOR) return true; =20 @@ -199,10 +228,20 @@ qemuExtDevicesSetupCgroup(virQEMUDriverPtr driver, virDomainDefPtr def, virCgroupPtr cgroup) { - int ret =3D 0; + int i; =20 - if (def->tpm) - ret =3D qemuExtTPMSetupCgroup(driver, def, cgroup); + for (i =3D 0; i < def->nvideos; i++) { + virDomainVideoDefPtr video =3D def->videos[i]; =20 - return ret; + if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && + video->vhostuser && + qemuExtVhostUserGPUSetupCgroup(driver, def, video, cgroup) < 0) + return -1; + } + + if (def->tpm && + qemuExtTPMSetupCgroup(driver, def, cgroup) < 0) + return -1; + + return 0; } --=20 2.22.0.rc2.384.g1a9a72ea1d -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list