From patchwork Fri Aug 23 16:21:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 172123 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp886268ily; Fri, 23 Aug 2019 09:22:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyS/bmwAorBqkGnxFHAX8YpGtAKaYjWeLVzi4nzSG8R4Gr8heXaqf0I0JvxGvgVBGOR6qKU X-Received: by 2002:a37:94d:: with SMTP id 74mr4858729qkj.101.1566577361056; Fri, 23 Aug 2019 09:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566577361; cv=none; d=google.com; s=arc-20160816; b=OM5/UwkZ5ARhLx8mDNoGPlBEjuGIJS4fCcydPfbmJg8Y4tOOnS7sbIE3+rwE1ubQwW fcVyMcXCfjIOmZdznF+niRCwsoiKS7pr2Hhh35svp17BRWxngZrWFI/1mINwjyMh/Tns QlcfMqNSRecpwWCTv4ZWjxC4rprWaOc1xeAlkiByGr6yUrTZFT+IRKNeJcl7IB8s4os7 v3/WuN0mvA7fNeZ+IdHVVd/7ohtE+oCXAw6FDFWuXp5soCUZoVDeikSQBIpwyvDI8hob L3/sg9NpaTCbagIkYVUxWDZMrr+T5mjscDfNSNHlrWIWDDtygymUJmNaEzjO7B7d8zfx irwg== 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=6jVRExrwbAHpiKbghfXaHksd0Peusj/zEJ6jpglAkfs=; b=ZARL9cyUECTUAvHOMURofvNC5PlqlMqBuTcKdH/8LyNwTnJ3tQ19VEkgFTKD2A1VU0 mXYuQSF+ITD1gcOOpZXCx/1DLcLMwYz9dkG6PUZLVOj++zyzRteC2SGVeuJhn1gjxrSn ahbnaewMYP1B6wvy16dL5SbWOxttR7Bmf0gFmE1gDmZQv4IyX3yZ2TWY0Q96IU0NbqqH 7voNyPyo3pgN+bwoNV+ONK9Q5aXvTg9y69RPUehb7UDH2wyNvLZJyo5YbNFJGVox8NWk mrue/EUN/OaFr4uz0dgzShd/xprSPllxmFtbXva7DTmQ3ckG500JTQhZBDnvRVcFSRQd vP8Q== 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 k37si2358782qte.6.2019.08.23.09.22.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2019 09:22:41 -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-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 D2CB88D6CAA; Fri, 23 Aug 2019 16:22:39 +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 AE00F1813D; Fri, 23 Aug 2019 16:22:39 +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 693DB24AD6; Fri, 23 Aug 2019 16:22:39 +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 x7NGMCx0006081 for ; Fri, 23 Aug 2019 12:22:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 204F660605; 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 A267B6092D; Fri, 23 Aug 2019 16:22:11 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 23 Aug 2019 12:21:57 -0400 Message-Id: <4d239a3b4ce0dbd10672fee6c78121dfbf4a5b76.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 13/16] 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: , 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.69]); Fri, 23 Aug 2019 16:22:40 +0000 (UTC) From: Marc-André 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é Lureau Signed-off-by: Cole Robinson --- src/qemu/qemu_extdevice.c | 46 +++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index 5c55aba006..3dbcec3546 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -161,10 +161,21 @@ qemuExtDevicesStart(virQEMUDriverPtr driver, bool incomingMigration) { int ret = 0; + size_t i; if (qemuExtDevicesInitPaths(driver, vm->def) < 0) return -1; + for (i = 0; i < vm->def->nvideos; i++) { + virDomainVideoDefPtr video = vm->def->videos[i]; + + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO && video->vhostuser) { + ret = qemuExtVhostUserGPUStart(driver, vm, video, logCtxt); + if (ret < 0) + return ret; + } + } + if (vm->def->tpm) ret = qemuExtTPMStart(driver, vm, logCtxt, incomingMigration); @@ -176,9 +187,18 @@ void qemuExtDevicesStop(virQEMUDriverPtr driver, virDomainObjPtr vm) { + size_t i; + if (qemuExtDevicesInitPaths(driver, vm->def) < 0) return; + for (i = 0; i < vm->def->nvideos; i++) { + virDomainVideoDefPtr video = vm->def->videos[i]; + + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO && video->vhostuser) + qemuExtVhostUserGPUStop(driver, vm, video); + } + if (vm->def->tpm) qemuExtTPMStop(driver, vm); } @@ -187,6 +207,14 @@ qemuExtDevicesStop(virQEMUDriverPtr driver, bool qemuExtDevicesHasDevice(virDomainDefPtr def) { + size_t i; + + for (i = 0; i < def->nvideos; i++) { + if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO && + def->videos[i]->vhostuser) + return true; + } + if (def->tpm && def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) return true; @@ -199,10 +227,20 @@ qemuExtDevicesSetupCgroup(virQEMUDriverPtr driver, virDomainDefPtr def, virCgroupPtr cgroup) { - int ret = 0; + size_t i; - if (def->tpm) - ret = qemuExtTPMSetupCgroup(driver, def, cgroup); + for (i = 0; i < def->nvideos; i++) { + virDomainVideoDefPtr video = def->videos[i]; - return ret; + if (video->type == 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; }