From nobody Tue May 7 00:13:49 2024
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=1566577331; cv=none;
d=zoho.com; s=zohoarc;
b=D87fal0VDc6R6iGZ1jM8+IlDgT4R1kwgmn88CR5pEEsZs45kzI3xxFcDsxw/OubM1TqRLKzRaQU4U4xZ/r1Ph/ciES7X4B6XwXKAomM87CXGnqPC2gRhorRWL9D0Gn2+TEFdBpXi3332fczYAkE52IERhwC6Hrl8QcA/+rmsajc=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577331;
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=3dlm0jdNYplLWDJo7y+x4dhE3Qs0gY7qc7hKobfueoA=;
b=OowhjAWferzccTnAcWySfi5J1GAGHty3pVMSlEyIHo9zSuLlFu1PRGtaMFl2QwraYbmASjdMTMTEe7ybvyMd7FKpjfp5J0WsP2HqvrRbJW3+bSHc7lDobD1OwgU+1yzshbOFNlbSk+75BURhD27wFRQ+PUPUWn7XOJ2yAY2PTjU=
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 156657733132757.47193857024138;
Fri, 23 Aug 2019 09:22:11 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com
[10.5.11.22])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 725FE10F23F6;
Fri, 23 Aug 2019 16:22:09 +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 156C81001B17;
Fri, 23 Aug 2019 16:22:09 +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 8C9E524F2F;
Fri, 23 Aug 2019 16:22:05 +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 x7NGM41a005977 for ;
Fri, 23 Aug 2019 12:22:04 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 4FF8B6092D; Fri, 23 Aug 2019 16:22:04 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id 888F260605;
Fri, 23 Aug 2019 16:22:03 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:45 -0400
Message-Id:
<56d8740d08f75e7f722c027391921c9c2ea43d35.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=20Lureau?=
Subject: [libvirt] [PATCH v2 01/16] qemu: extract out qemuFetchConfigs from
firmware
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.22
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]);
Fri, 23 Aug 2019 16:22:09 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
The same config files disovery & priority rules are used for
vhost-user backends.
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
---
src/qemu/Makefile.inc.am | 2 +
src/qemu/qemu_configs.c | 183 +++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_configs.h | 28 ++++++
src/qemu/qemu_firmware.c | 144 +-----------------------------
4 files changed, 215 insertions(+), 142 deletions(-)
create mode 100644 src/qemu/qemu_configs.c
create mode 100644 src/qemu/qemu_configs.h
diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am
index 30a9751cfd..f7a0fa4a84 100644
--- a/src/qemu/Makefile.inc.am
+++ b/src/qemu/Makefile.inc.am
@@ -30,6 +30,8 @@ QEMU_DRIVER_SOURCES =3D \
qemu/qemu_hotplugpriv.h \
qemu/qemu_conf.c \
qemu/qemu_conf.h \
+ qemu/qemu_configs.c \
+ qemu/qemu_configs.h \
qemu/qemu_process.c \
qemu/qemu_process.h \
qemu/qemu_processpriv.h \
diff --git a/src/qemu/qemu_configs.c b/src/qemu/qemu_configs.c
new file mode 100644
index 0000000000..39b8906be5
--- /dev/null
+++ b/src/qemu/qemu_configs.c
@@ -0,0 +1,183 @@
+/*
+ * qemu_configs.c: QEMU firmware/vhost-user etc configs
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * .
+ */
+
+#include
+
+#include "qemu_configs.h"
+#include "configmake.h"
+#include "viralloc.h"
+#include "virenum.h"
+#include "virfile.h"
+#include "virhash.h"
+#include "virlog.h"
+#include "virstring.h"
+
+#define VIR_FROM_THIS VIR_FROM_QEMU
+
+VIR_LOG_INIT("qemu.qemu_configs");
+
+static int
+qemuBuildFileList(virHashTablePtr files, const char *dir)
+{
+ DIR *dirp;
+ struct dirent *ent =3D NULL;
+ int rc;
+ int ret =3D -1;
+
+ if ((rc =3D virDirOpenIfExists(&dirp, dir)) < 0)
+ return -1;
+
+ if (rc =3D=3D 0)
+ return 0;
+
+ while ((rc =3D virDirRead(dirp, &ent, dir)) > 0) {
+ VIR_AUTOFREE(char *) filename =3D NULL;
+ VIR_AUTOFREE(char *) path =3D NULL;
+ struct stat sb;
+
+ if (STRPREFIX(ent->d_name, "."))
+ continue;
+
+ if (VIR_STRDUP(filename, ent->d_name) < 0)
+ goto cleanup;
+
+ if (virAsprintf(&path, "%s/%s", dir, filename) < 0)
+ goto cleanup;
+
+ if (stat(path, &sb) < 0) {
+ virReportSystemError(errno, _("Unable to access %s"), path);
+ goto cleanup;
+ }
+
+ if (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))
+ continue;
+
+ if (virHashUpdateEntry(files, filename, path) < 0)
+ goto cleanup;
+
+ path =3D NULL;
+ }
+
+ if (rc < 0)
+ goto cleanup;
+
+ ret =3D 0;
+ cleanup:
+ virDirClose(&dirp);
+ return ret;
+}
+
+static int
+qemuConfigFilesSorter(const virHashKeyValuePair *a,
+ const virHashKeyValuePair *b)
+{
+ return strcmp(a->key, b->key);
+}
+
+#define QEMU_SYSTEM_LOCATION PREFIX "/share/qemu"
+#define QEMU_ETC_LOCATION SYSCONFDIR "/qemu"
+
+int
+qemuFetchConfigs(const char *name,
+ char ***configs,
+ bool privileged)
+{
+ VIR_AUTOPTR(virHashTable) files =3D NULL;
+ VIR_AUTOFREE(char *) homeConfig =3D NULL;
+ VIR_AUTOFREE(char *) xdgConfig =3D NULL;
+ VIR_AUTOFREE(char *) sysLocation =3D virFileBuildPath(QEMU_SYSTEM_LOCA=
TION, name, NULL);
+ VIR_AUTOFREE(char *) etcLocation =3D virFileBuildPath(QEMU_ETC_LOCATIO=
N, name, NULL);
+ VIR_AUTOFREE(virHashKeyValuePairPtr) pairs =3D NULL;
+ virHashKeyValuePairPtr tmp =3D NULL;
+
+ *configs =3D NULL;
+
+ if (!privileged) {
+ /* This is a slight divergence from the specification.
+ * Since the system daemon runs as root, it doesn't make
+ * much sense to parse files in root's home directory. It
+ * makes sense only for session daemon which runs under
+ * regular user. */
+ if (VIR_STRDUP(xdgConfig, getenv("XDG_CONFIG_HOME")) < 0)
+ return -1;
+
+ if (!xdgConfig) {
+ VIR_AUTOFREE(char *) home =3D virGetUserDirectory();
+
+ if (!home)
+ return -1;
+
+ if (virAsprintf(&xdgConfig, "%s/.config", home) < 0)
+ return -1;
+ }
+
+ if (virAsprintf(&homeConfig, "%s/qemu/%s", xdgConfig, name) < 0)
+ return -1;
+ }
+
+ if (!(files =3D virHashCreate(10, virHashValueFree)))
+ return -1;
+
+ if (qemuBuildFileList(files, sysLocation) < 0)
+ return -1;
+
+ if (qemuBuildFileList(files, etcLocation) < 0)
+ return -1;
+
+ if (homeConfig &&
+ qemuBuildFileList(files, homeConfig) < 0)
+ return -1;
+
+ /* At this point, the @files hash table contains unique set of filenam=
es
+ * where each filename (as key) has the highest priority full pathname
+ * associated with it. */
+
+ if (virHashSize(files) =3D=3D 0)
+ return 0;
+
+ if (!(pairs =3D virHashGetItems(files, qemuConfigFilesSorter)))
+ return -1;
+
+ for (tmp =3D pairs; tmp->key; tmp++) {
+ const char *path =3D tmp->value;
+ off_t len;
+
+ if ((len =3D virFileLength(path, -1)) < 0) {
+ virReportSystemError(errno,
+ _("unable to get size of '%s'"),
+ path);
+ return -1;
+ }
+
+ VIR_DEBUG("%s description path '%s' len=3D%jd",
+ name, path, (intmax_t) len);
+
+ if (len =3D=3D 0) {
+ /* Empty files are used to mask less specific instances
+ * of the same file. */
+ continue;
+ }
+
+ if (virStringListAdd(configs, path) < 0)
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/src/qemu/qemu_configs.h b/src/qemu/qemu_configs.h
new file mode 100644
index 0000000000..5c113752d0
--- /dev/null
+++ b/src/qemu/qemu_configs.h
@@ -0,0 +1,28 @@
+/*
+ * qemu_configs.h: QEMU firmware/vhost-user etc configs
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * .
+ */
+
+#pragma once
+
+#include "internal.h"
+
+int
+qemuFetchConfigs(const char *name,
+ char ***configs,
+ bool privileged);
diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index 983a7c83b2..f0a6953d8b 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -23,13 +23,12 @@
#include
=20
#include "qemu_firmware.h"
+#include "qemu_configs.h"
#include "configmake.h"
#include "qemu_capabilities.h"
#include "qemu_domain.h"
#include "qemu_process.h"
#include "virarch.h"
-#include "virfile.h"
-#include "virhash.h"
#include "virjson.h"
#include "virlog.h"
#include "virstring.h"
@@ -907,150 +906,11 @@ qemuFirmwareFormat(qemuFirmwarePtr fw)
}
=20
=20
-static int
-qemuFirmwareBuildFileList(virHashTablePtr files, const char *dir)
-{
- DIR *dirp;
- struct dirent *ent =3D NULL;
- int rc;
- int ret =3D -1;
-
- if ((rc =3D virDirOpenIfExists(&dirp, dir)) < 0)
- return -1;
-
- if (rc =3D=3D 0)
- return 0;
-
- while ((rc =3D virDirRead(dirp, &ent, dir)) > 0) {
- VIR_AUTOFREE(char *) filename =3D NULL;
- VIR_AUTOFREE(char *) path =3D NULL;
- struct stat sb;
-
- if (STRPREFIX(ent->d_name, "."))
- continue;
-
- if (VIR_STRDUP(filename, ent->d_name) < 0)
- goto cleanup;
-
- if (virAsprintf(&path, "%s/%s", dir, filename) < 0)
- goto cleanup;
-
- if (stat(path, &sb) < 0) {
- virReportSystemError(errno, _("Unable to access %s"), path);
- goto cleanup;
- }
-
- if (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))
- continue;
-
- if (virHashUpdateEntry(files, filename, path) < 0)
- goto cleanup;
-
- path =3D NULL;
- }
-
- if (rc < 0)
- goto cleanup;
-
- ret =3D 0;
- cleanup:
- virDirClose(&dirp);
- return ret;
-}
-
-static int
-qemuFirmwareFilesSorter(const virHashKeyValuePair *a,
- const virHashKeyValuePair *b)
-{
- return strcmp(a->key, b->key);
-}
-
-#define QEMU_FIRMWARE_SYSTEM_LOCATION PREFIX "/share/qemu/firmware"
-#define QEMU_FIRMWARE_ETC_LOCATION SYSCONFDIR "/qemu/firmware"
-
int
qemuFirmwareFetchConfigs(char ***firmwares,
bool privileged)
{
- VIR_AUTOPTR(virHashTable) files =3D NULL;
- VIR_AUTOFREE(char *) homeConfig =3D NULL;
- VIR_AUTOFREE(char *) xdgConfig =3D NULL;
- VIR_AUTOFREE(virHashKeyValuePairPtr) pairs =3D NULL;
- virHashKeyValuePairPtr tmp =3D NULL;
-
- *firmwares =3D NULL;
-
- if (!privileged) {
- /* This is a slight divergence from the specification.
- * Since the system daemon runs as root, it doesn't make
- * much sense to parse files in root's home directory. It
- * makes sense only for session daemon which runs under
- * regular user. */
- if (VIR_STRDUP(xdgConfig, getenv("XDG_CONFIG_HOME")) < 0)
- return -1;
-
- if (!xdgConfig) {
- VIR_AUTOFREE(char *) home =3D virGetUserDirectory();
-
- if (!home)
- return -1;
-
- if (virAsprintf(&xdgConfig, "%s/.config", home) < 0)
- return -1;
- }
-
- if (virAsprintf(&homeConfig, "%s/qemu/firmware", xdgConfig) < 0)
- return -1;
- }
-
- if (!(files =3D virHashCreate(10, virHashValueFree)))
- return -1;
-
- if (qemuFirmwareBuildFileList(files, QEMU_FIRMWARE_SYSTEM_LOCATION) < =
0)
- return -1;
-
- if (qemuFirmwareBuildFileList(files, QEMU_FIRMWARE_ETC_LOCATION) < 0)
- return -1;
-
- if (homeConfig &&
- qemuFirmwareBuildFileList(files, homeConfig) < 0)
- return -1;
-
- /* At this point, the @files hash table contains unique set of filenam=
es
- * where each filename (as key) has the highest priority full pathname
- * associated with it. */
-
- if (virHashSize(files) =3D=3D 0)
- return 0;
-
- if (!(pairs =3D virHashGetItems(files, qemuFirmwareFilesSorter)))
- return -1;
-
- for (tmp =3D pairs; tmp->key; tmp++) {
- const char *path =3D tmp->value;
- off_t len;
-
- if ((len =3D virFileLength(path, -1)) < 0) {
- virReportSystemError(errno,
- _("unable to get size of '%s'"),
- path);
- return -1;
- }
-
- VIR_DEBUG("firmware description path '%s' len=3D%jd",
- path, (intmax_t) len);
-
- if (len =3D=3D 0) {
- /* Empty files are used to mask less specific instances
- * of the same file. */
- continue;
- }
-
- if (virStringListAdd(firmwares, path) < 0)
- return -1;
- }
-
- return 0;
+ return qemuFetchConfigs("firmware", firmwares, privileged);
}
=20
=20
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577331; cv=none;
d=zoho.com; s=zohoarc;
b=lA/M0O9hWNvwzahVn8L2WBAEE5XjCwuUgtBZaW70+zVIyB0bnsrVQSshbeG/sdtzDu5gBq24nNECd59aCJ9fTTwoNE3NvFx4UH8waQtelLENU12m6vp2Sh8PoM8Sz+H89WTMyH6j8yARz5uq6xexhQY7Hk3WoKsWyVfosThFzlk=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577331;
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=AU1kwMhv3k0LIn3YvkuXKA6Cwtzzl6l0+lWUOTPKBfs=;
b=XnIv42eEEUX0JeTXFmiIi5GL1RVAyXKVAZrRHha/1DibmKfPYxc6JfMTPGx2chPdBlRwSp2YKw+VjlMMvQDFB+Qvwdv5UpXmA+mGXtSZQkr+vaVdeRIVWbt9IvSLtncQ0/F3WfGhWsDVIwSOMEvMTMan/V7L8NWb/VWhUbf7bL4=
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 1566577331256269.2696087921813;
Fri, 23 Aug 2019 09:22:11 -0700 (PDT)
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 9492618DE768;
Fri, 23 Aug 2019 16:22:09 +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 171A24142;
Fri, 23 Aug 2019 16:22:09 +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 5137324F35;
Fri, 23 Aug 2019 16:22:07 +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 x7NGM51R005984 for ;
Fri, 23 Aug 2019 12:22:05 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 0724C60605; Fri, 23 Aug 2019 16:22:05 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id 89E0F6092D;
Fri, 23 Aug 2019 16:22:04 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:46 -0400
Message-Id:
<76dadadc00b9c519e4b25f321776347672781cb9.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=20Lureau?=
Subject: [libvirt] [PATCH v2 02/16] domain: add "vhostuser" attribute to
virtio video model
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.12
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]);
Fri, 23 Aug 2019 16:22:10 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
Accept a new attribute to specify usage of helper process, ex:
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
---
docs/formatdomain.html.in | 6 ++++++
docs/schemas/domaincommon.rng | 11 ++++++++++-
src/conf/domain_conf.c | 14 ++++++++++++++
src/conf/domain_conf.h | 1 +
4 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index fcb7c59c00..ec650fbe17 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7039,6 +7039,12 @@ qemu-kvm -net nic,model=3D? /dev/null
Attribute vram64
(since 1.3.3=
)
extends secondary bar and makes it addressable as 64bit memory.
+
+ For guest type "kvm" and model type "virtio" there are
+ optional attributes. Attribute vhost-user
+ (since 5.5.0) specify that a
+ vhost-user helper process should be associated with the GPU.
+
=20
acceleration
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index c48f8c4f56..bac566855d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3581,7 +3581,6 @@
vmvga
xen
vbox
- virtio
gop
none
bochs
@@ -3607,6 +3606,16 @@
+
+
+ virtio
+
+
+
+ [
+ ]
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b7a342bb91..f51575d57d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15358,6 +15358,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xml=
opt,
xmlNodePtr cur;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
VIR_AUTOFREE(char *) type =3D NULL;
+ VIR_AUTOFREE(char *) vhostuser =3D NULL;
VIR_AUTOFREE(char *) heads =3D NULL;
VIR_AUTOFREE(char *) vram =3D NULL;
VIR_AUTOFREE(char *) vram64 =3D NULL;
@@ -15376,6 +15377,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xml=
opt,
if (!type && !vram && !ram && !heads &&
virXMLNodeNameEqual(cur, "model")) {
type =3D virXMLPropString(cur, "type");
+ vhostuser =3D virXMLPropString(cur, "vhostuser");
ram =3D virXMLPropString(cur, "ram");
vram =3D virXMLPropString(cur, "vram");
vram64 =3D virXMLPropString(cur, "vram64");
@@ -15408,6 +15410,16 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm=
lopt,
def->type =3D virDomainVideoDefaultType(dom);
}
=20
+ if (vhostuser !=3D NULL) {
+ if (virStringParseYesNo(vhostuser, &def->vhostuser) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown vhostuser value '%s'"), vhostuser);
+ goto cleanup;
+ }
+ } else {
+ def->vhostuser =3D false;
+ }
+
if (ram) {
if (def->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -26486,6 +26498,8 @@ virDomainVideoDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " heads=3D'%u'", def->heads);
if (def->primary)
virBufferAddLit(buf, " primary=3D'yes'");
+ if (def->vhostuser)
+ virBufferAddLit(buf, " vhostuser=3D'yes'");
if (def->accel) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 33cef5b75c..bc2450f25e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1424,6 +1424,7 @@ struct _virDomainVideoDef {
virDomainVideoDriverDefPtr driver;
virDomainDeviceInfo info;
virDomainVirtioOptionsPtr virtio;
+ bool vhostuser;
};
=20
/* graphics console modes */
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577347; cv=none;
d=zoho.com; s=zohoarc;
b=IQQ0xAfn4OmnD67lQY24/0nP/Mv6CI7QriKQ8MB56vwMeKKBWAEpDr1n0DiTOGz90ePRtjVOnUFnqyjtH+ufd3ADHssP6cShxC57mDt8c9ruF0uStTNl4bufLHOmf8gLtLdRo/383Hn/Lu6IfB8RLl57i4TIEVPJrWVu/n65sqg=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577347;
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=UHRQzObOpVvU0jfgn71csAfJ83VE4aCGzVCZC2cdleI=;
b=l05NU4cZfF6dPfSG3jXVt0yIsN6c05YXARCmaJyiPnFO7lZJor18p995ciZkuBkDV7mclJ6ZJDCC+Z52MO/kB+BDXEQrRTDJlAG9gZJj6vXbySvx3VqFe1d/MXmUyZ5g3KIiaNQrHX2ssdTOP3ILRoVt6NzQdUtYv9jT9UDpUgU=
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 1566577347073694.7252488634921;
Fri, 23 Aug 2019 09:22:27 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com
[10.5.11.15])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id D61FC3CA16;
Fri, 23 Aug 2019 16:22:25 +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 B56465D784;
Fri, 23 Aug 2019 16:22:25 +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 790531802220;
Fri, 23 Aug 2019 16:22:25 +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 x7NGM5tc005992 for ;
Fri, 23 Aug 2019 12:22:05 -0400
Received: by smtp.corp.redhat.com (Postfix)
id A3A7760605; Fri, 23 Aug 2019 16:22:05 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id 3045160872;
Fri, 23 Aug 2019 16:22:05 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:47 -0400
Message-Id:
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=20Lureau?=
Subject: [libvirt] [PATCH v2 03/16] domain: add rendernode attribute on
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.15
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]);
Fri, 23 Aug 2019 16:22:26 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
vhost-user-gpu helper may accept --render-node option to specify on
which GPU should the renderning be done.
(by comparison rendernode is the target/display rendering)
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
---
docs/formatdomain.html.in | 5 +++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 18 +++++++++++++++++-
src/conf/domain_conf.h | 1 +
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index ec650fbe17..5a4807d937 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7059,6 +7059,11 @@ qemu-kvm -net nic,model=3D? /dev/null
Enable 3D acceleration (for vbox driver
since 0.7.1, qemu driver
since 1.3.0)
+
+ rendernode
+ Absolute path to a host's DRI device to be used for
+ rendering (for vhost-user driver only, since 5.5.0)
=20
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index bac566855d..6e91fe6cef 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3644,6 +3644,11 @@
[
]
+
+
+ [
+ ]
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f51575d57d..2cc055491d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2832,6 +2832,8 @@ virDomainVideoDefClear(virDomainVideoDefPtr def)
=20
virDomainDeviceInfoClear(&def->info);
=20
+ if (def->accel)
+ VIR_FREE(def->accel->rendernode);
VIR_FREE(def->accel);
VIR_FREE(def->virtio);
VIR_FREE(def->driver);
@@ -15270,6 +15272,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
int val;
VIR_AUTOFREE(char *) accel2d =3D NULL;
VIR_AUTOFREE(char *) accel3d =3D NULL;
+ VIR_AUTOFREE(char *) rendernode =3D NULL;
=20
cur =3D node->children;
while (cur !=3D NULL) {
@@ -15278,12 +15281,13 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
virXMLNodeNameEqual(cur, "acceleration")) {
accel3d =3D virXMLPropString(cur, "accel3d");
accel2d =3D virXMLPropString(cur, "accel2d");
+ rendernode =3D virXMLPropString(cur, "rendernode");
}
}
cur =3D cur->next;
}
=20
- if (!accel3d && !accel2d)
+ if (!accel3d && !accel2d && !rendernode)
return NULL;
=20
if (VIR_ALLOC(def) < 0)
@@ -15307,6 +15311,9 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
def->accel2d =3D val;
}
=20
+ if (VIR_STRDUP(def->rendernode, rendernode) < 0)
+ goto cleanup;
+
cleanup:
return def;
}
@@ -15474,6 +15481,11 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xm=
lopt,
goto error;
}
}
+ if (!def->vhostuser && def->accel && def->accel->rendernode) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("unsupported rendernode accel attribute without '=
vhost-user'"));
+ goto error;
+ }
=20
if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0)
goto error;
@@ -26452,6 +26464,10 @@ virDomainVideoAccelDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " accel2d=3D'%s'",
virTristateBoolTypeToString(def->accel2d));
}
+ if (def->rendernode) {
+ virBufferAsprintf(buf, " rendernode=3D'%s'",
+ def->rendernode);
+ }
virBufferAddLit(buf, "/>\n");
}
=20
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bc2450f25e..707fbd1cd3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1405,6 +1405,7 @@ VIR_ENUM_DECL(virDomainVideoVGAConf);
struct _virDomainVideoAccelDef {
int accel2d; /* enum virTristateBool */
int accel3d; /* enum virTristateBool */
+ char *rendernode;
};
=20
=20
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577347; cv=none;
d=zoho.com; s=zohoarc;
b=Bv0RGIi3BXG5LwIPDDsCZRiSo82Ic7TmM0+q1kJT30V91BWAzSXREIfCjNaaA8hU5cWF0Y5x5y/y699pSc4euz8vAQPev8T4fr3J7waxVmyG1HZrf0H6CrwLV0X2RFq/+8Zh0Gna3FNvCna/1GrxQVMJsT/u91SxRchoVjOUDBQ=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577347;
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=x53LEDDYOGDvRskIUKw103kFla+HOQZzlWoA+lZTcYM=;
b=I6W6F6xMC6VGkFnr+Wu/BARNnPotQ7TZtX5dGFTFCQLaVll25ssaWqcMLbfCZsbe6GP9ZLG6PDaBUc9XjThEYwyxACgERDNriwfU0rUx2SfTiMAzLW4RgDxKoKe0nI61lSgnaO+W7PtllQupPXzeHxluNFqiU4yfa0hzwMS1dGY=
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 156657734726271.28526522120569;
Fri, 23 Aug 2019 09:22:27 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com
[10.5.11.11])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id DFBB818C427C;
Fri, 23 Aug 2019 16:22:25 +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 B8CA86012D;
Fri, 23 Aug 2019 16:22:25 +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 79BB724F33;
Fri, 23 Aug 2019 16:22:25 +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 x7NGM6rW005999 for ;
Fri, 23 Aug 2019 12:22:06 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 49DE360628; Fri, 23 Aug 2019 16:22:06 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id CC01260872;
Fri, 23 Aug 2019 16:22:05 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:48 -0400
Message-Id:
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=20Lureau?=
Subject: [libvirt] [PATCH v2 04/16] qemu-cgroup: allow accel rendernode
access
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.11
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]);
Fri, 23 Aug 2019 16:22:26 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
Reviewed-by: J=C3=A1n Tomko
---
src/qemu/qemu_cgroup.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index ecd96efb0a..eb6f993d8e 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -503,6 +503,25 @@ qemuSetupGraphicsCgroup(virDomainObjPtr vm,
}
=20
=20
+static int
+qemuSetupVideoAccelCgroup(virDomainObjPtr vm,
+ virDomainVideoAccelDefPtr def)
+{
+ qemuDomainObjPrivatePtr priv =3D vm->privateData;
+ int ret;
+
+ if (!def->rendernode ||
+ !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICE=
S))
+ return 0;
+
+ ret =3D virCgroupAllowDevicePath(priv->cgroup, def->rendernode,
+ VIR_CGROUP_DEVICE_RW, false);
+ virDomainAuditCgroupPath(vm, priv->cgroup, "allow", def->rendernode,
+ "rw", ret);
+ return ret;
+}
+
+
static int
qemuSetupBlkioCgroup(virDomainObjPtr vm)
{
@@ -803,6 +822,11 @@ qemuSetupDevicesCgroup(virDomainObjPtr vm)
goto cleanup;
}
=20
+ for (i =3D 0; i < vm->def->nvideos; i++) {
+ if (qemuSetupVideoAccelCgroup(vm, vm->def->videos[i]->accel) < 0)
+ goto cleanup;
+ }
+
for (i =3D 0; i < vm->def->ninputs; i++) {
if (qemuSetupInputCgroup(vm, vm->def->inputs[i]) < 0)
goto cleanup;
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577347; cv=none;
d=zoho.com; s=zohoarc;
b=gI+TX4d8w+FXyCNOGDm29RhY/RJaBu5EoRZMQtSr3/jWOnpOsUJKUihWKjb1ucm7YeozYD2/7GO0cegczGD8UtrxFIiXkg2ZY5MgW59n5/ylUsBAldqrqHcUnd55fEfQVD3POFro6Yc3obRzQ+OLnvn1Iwh7esHfFGvANCKLeso=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577347;
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=zYiL0PmFcv/Ngi+rcEYNYb+jqB988T/9G81b1XUz1ok=;
b=Hhr9MK0OrTataDbDecCYPpZ96n5aOPfep648J/zWZWKeHt0TEqbNXyoaxYUVoZxxwxLi+xtpQl2/hiywRlkMEglZLp9xS8WHdc0rWMTa0TEHrSCJ2vg4Wxs9CNSXtNt80aGC8gI6gH/UxlgBsX4NjIUCZvoT5qBniDrDTPdaGFA=
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 156657734703212.537901054408053;
Fri, 23 Aug 2019 09:22:27 -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 D5B33881361;
Fri, 23 Aug 2019 16:22:25 +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 B10492634D;
Fri, 23 Aug 2019 16:22:25 +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 76ABA180221F;
Fri, 23 Aug 2019 16:22:25 +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 x7NGM6oe006004 for ;
Fri, 23 Aug 2019 12:22:06 -0400
Received: by smtp.corp.redhat.com (Postfix)
id E3DE660606; Fri, 23 Aug 2019 16:22:06 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id 71AEB60872;
Fri, 23 Aug 2019 16:22:06 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:49 -0400
Message-Id:
<662e7bc629a2b549b4be48471e36fb798ca08d22.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=20Lureau?=
Subject: [libvirt] [PATCH v2 05/16] qemu: add vhost-user-gpu capabilities
checks
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.6.2 (mx1.redhat.com [10.5.110.69]);
Fri, 23 Aug 2019 16:22:26 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
Those new devices are merged for QEMU 4.1.
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
Reviewed-by: J=C3=A1n Tomko
---
src/qemu/qemu_capabilities.c | 4 ++++
src/qemu/qemu_capabilities.h | 2 ++
tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml | 2 ++
3 files changed, 8 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 73300128ea..d27f54d16e 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -537,6 +537,8 @@ VIR_ENUM_IMPL(virQEMUCaps,
/* 335 */
"bochs-display",
"migration-file-drop-cache",
+ "vhost-user-gpu",
+ "vhost-user-vga",
);
=20
=20
@@ -1127,6 +1129,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[=
] =3D {
{ "virtio-serial-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_TRANSITIO=
NAL },
{ "max-x86_64-cpu", QEMU_CAPS_X86_MAX_CPU },
{ "bochs-display", QEMU_CAPS_DEVICE_BOCHS_DISPLAY },
+ { "vhost-user-gpu", QEMU_CAPS_DEVICE_VHOST_USER_GPU },
+ { "vhost-user-vga", QEMU_CAPS_DEVICE_VHOST_USER_VGA },
};
=20
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[]=
=3D {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 68ef6c49b4..6f1e1dd2f3 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -518,6 +518,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for =
syntax-check */
/* 335 */
QEMU_CAPS_DEVICE_BOCHS_DISPLAY, /* -device bochs-display */
QEMU_CAPS_MIGRATION_FILE_DROP_CACHE, /* migration with disk cache on i=
s safe for type=3D'file' disks */
+ QEMU_CAPS_DEVICE_VHOST_USER_GPU, /* -device vhost-user-gpu */
+ QEMU_CAPS_DEVICE_VHOST_USER_VGA, /* -device vhost-user-vga */
=20
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml b/tests/qemuc=
apabilitiesdata/caps_4.1.0.x86_64.xml
index f4583d7fe7..5d4540b3f7 100644
--- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
@@ -209,6 +209,8 @@
+
+
4000050
0
43100759
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577351; cv=none;
d=zoho.com; s=zohoarc;
b=R+ru2+t6HZqb0kuZ/z2+lYg15/+lO4Em6YCaZ4hy4NcHBGgxa09cqEaKGPNp0cs5gfwnnsre33Cprayxw0tH3ZKBvtUxa3w/tIoiHRhY8V4pvGbkJH3Qmbj+us/hUsulyPHR0fVXwn/o4W7gfp3zS6+rek3i928lQFp+H8q1T5g=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577351;
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=OhJ4aSjXADNqQ07RCTV5gV91e9QW/Q50WeIbFeyAsa4=;
b=MVCYe8+AmUgSpQW+eGjMjkSqnaMlLPSgv0yH73T4xWfegQ3UrLtFJSUZn3zhtb/XF581uCPIYUXao4q/GgSy5m4JxqkRw8rSa4NwBgZNWg4F/5fvt2KbgdP+iWF1N/AjiESak8MWPrCfjzgtb+XR7dcAgg0W8oOesJxrC+yDSdo=
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 1566577351416445.0411401043218;
Fri, 23 Aug 2019 09:22:31 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
[10.5.11.13])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 4A60F30860BE;
Fri, 23 Aug 2019 16:22:30 +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 2C12C60A9F;
Fri, 23 Aug 2019 16:22:30 +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 DF5FC24F34;
Fri, 23 Aug 2019 16:22:29 +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 x7NGM7sd006012 for ;
Fri, 23 Aug 2019 12:22:07 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 8BEEA60605; Fri, 23 Aug 2019 16:22:07 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id 1969F6092D;
Fri, 23 Aug 2019 16:22:07 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:50 -0400
Message-Id:
<58e9b4aefdd87f77f681955746ff93e62bb98c5c.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=20Lureau?=
Subject: [libvirt] [PATCH v2 06/16] qemu: check that qemu is vhost-user-vga
capable
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.13
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]);
Fri, 23 Aug 2019 16:22:30 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
To support virtio VGA with vhost-user, vhost-user-vga device is necessary.
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
Reviewed-by: J=C3=A1n Tomko
---
src/qemu/qemu_domain.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d0722f8761..bf0531126d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -12386,9 +12386,14 @@ bool
qemuDomainSupportsVideoVga(virDomainVideoDefPtr video,
virQEMUCapsPtr qemuCaps)
{
- if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_VGA))
- return false;
+ if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) {
+ if (video->vhostuser) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_VGA))
+ return false;
+ } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_VGA))=
{
+ return false;
+ }
+ }
=20
return true;
}
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577355; cv=none;
d=zoho.com; s=zohoarc;
b=YuejR8z4nOIG4bVR2w8kd/eN6NTweto4fag9nX6/xrcrqNQa7CY3SM1LzfeteQ5xiHKJMdhb4WQZgC8wKLgZo8plfpiDCwx91nzcHwA4/0D/Ie7gtZe+dPo9Jc9azdfe1nVLsbt1Q2pGO7QRhkBftoMYMgM/r4zD+XjDJt+pEO8=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577355;
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=2djRaFfMhbkMmqYV32xS5dyMrC2v0LIsrbV1xRX88Ys=;
b=hgUMwXTLn8p3r7VVvOsC3n9zKOggdjspf9iwMTjh9soWdzALj90hvND+uZYyOpJqN5FChOQo0GQFKLrosyPWGbO/WuyKQvJF3I5IPcst5tps625ZIiFPrO9xdLReffDLZ8LCbH65djfKSvl5FLKAz0TbV0fLKS4IJ+IB9fzozlI=
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 1566577355834682.7161794189506;
Fri, 23 Aug 2019 09:22:35 -0700 (PDT)
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 8A6A210C030C;
Fri, 23 Aug 2019 16:22:34 +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 5F84DBA8A;
Fri, 23 Aug 2019 16:22:34 +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 19700180BA99;
Fri, 23 Aug 2019 16:22:34 +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 x7NGM8HZ006022 for ;
Fri, 23 Aug 2019 12:22:08 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 33E8260605; Fri, 23 Aug 2019 16:22:08 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id B3C186092D;
Fri, 23 Aug 2019 16:22:07 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:51 -0400
Message-Id:
<96949c1e9b5df8c986a9b36f640dd3dec8dcb0c9.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=20Lureau?=
Subject: [libvirt] [PATCH v2 07/16] qemu: validate virtio-gpu with vhost-user
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.12
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]);
Fri, 23 Aug 2019 16:22:35 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
Check qemu capability, and accept 3d acceleration. 3d acceleration
support is checked when looking for a suitable vhost-user helper.
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
---
src/qemu/qemu_process.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c9921646e9..c439f17011 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5274,8 +5274,10 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm,
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMWARE_SVGA)) ||
(video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_QXL &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL)) ||
- (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
+ (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && !video->vh=
ostuser &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU)) ||
+ (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && video->vho=
stuser &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_GPU)) ||
(video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
video->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW))) {
@@ -5285,7 +5287,15 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm,
return -1;
}
=20
- if (video->accel) {
+ if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
+ video->vhostuser &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_GPU)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("this QEMU does not support vhost-user backed=
video device"));
+ return -1;
+ }
+
+ if (!video->vhostuser && video->accel) {
if (video->accel->accel3d =3D=3D VIR_TRISTATE_SWITCH_ON &&
(video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO ||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_VIRGL))) {
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577350; cv=none;
d=zoho.com; s=zohoarc;
b=oTX6rsAfhPrNfbXvplkTeqeq0v2ik/PVLaHP8YEKxI7uSMV8NKzFxk/bfdwLEGesPRPTNPGmNZOJk536DLxhRcw6MMazpGsKyROKT8zkoNSRSp9rUXkCx3qYosiJiXr7EfEaPisng08bCVzIjuA4ZR+5AoFtT5P2RkMEctPCglg=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577350;
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=QDtDM6fTz95wXv3XUI2/+5jRWctaTqsxW10wafluDuw=;
b=EVPpLAdxDkwASZ32HDGNozg1+06Euh8AK1NOTE9EVp4+gHwuZlKnnUQAylCb/5ZZQXxlSUCf26Pe1jBxTB+Ie5Z9CPwmqy8RekCZQaKPCdlLdDNVTsoLOFDboxYpT8DDbfLBNu7Oy693DZaiFlHN7vBGLySHxsne1q9uQl1fAQ8=
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 1566577350363831.9541448203801;
Fri, 23 Aug 2019 09:22:30 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
[10.5.11.13])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 02357A35FE5;
Fri, 23 Aug 2019 16:22:29 +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 D2ADA60623;
Fri, 23 Aug 2019 16:22:28 +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 97F5C18034E0;
Fri, 23 Aug 2019 16:22:28 +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 x7NGM8Jw006032 for ;
Fri, 23 Aug 2019 12:22:08 -0400
Received: by smtp.corp.redhat.com (Postfix)
id CE80A60A9F; Fri, 23 Aug 2019 16:22:08 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id 5CA5660872;
Fri, 23 Aug 2019 16:22:08 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:52 -0400
Message-Id:
<4d4c6ee46622dbfaf84cef5dfd2471111e9a5723.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=20Lureau?=
Subject: [libvirt] [PATCH v2 08/16] qemu: restrict 'virgl=' option to
non-vhostuser video type
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.13
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]);
Fri, 23 Aug 2019 16:22:29 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
vhost-user device doesn't have a virgl option, it is passed to the
vhost-user-gpu helper process instead.
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
---
src/qemu/qemu_command.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 49652a8565..8bef103f68 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4683,9 +4683,11 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
=20
virBufferAsprintf(&buf, ",id=3D%s", video->info.alias);
=20
- if (video->accel && video->accel->accel3d =3D=3D VIR_TRISTATE_SWITCH_O=
N) {
- virBufferAsprintf(&buf, ",virgl=3D%s",
- virTristateSwitchTypeToString(video->accel->acce=
l3d));
+ if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && !video->vhostus=
er) {
+ if (video->accel && video->accel->accel3d =3D=3D VIR_TRISTATE_SWIT=
CH_ON) {
+ virBufferAsprintf(&buf, ",virgl=3D%s",
+ virTristateSwitchTypeToString(video->accel->=
accel3d));
+ }
}
=20
if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_QXL) {
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577358; cv=none;
d=zoho.com; s=zohoarc;
b=Bal0GKADV0q+zNls7uaIHHzc+CKY+sqYtgrHgF4nd/ICNOxIh4Hp1bLlHVxKGLaWBl7h/MuDKFI96vWHIgoYLMGcjcg4UzWWs0aNKBh4WZ37Uvg41/lNA4fbiT8yS/62IK1MVZThkNOgGuExoYCOdYNZMrn2yT68kHG8JcMRmSM=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577358;
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=zjgVAFOjv1nQTZqwVoT7tM/hAAiRIIDkR0tztELJA3M=;
b=V0mTaSgeAZfV9itjVLsjNlJqdgV+oGHNn/57AYbTTH4ZsNiX1P22GmvT0JUydfVc619UuJjkvkcsP3HutDQxqQshtpABx6v42o4psT6pZ26fSpSJcPkr4epnHTN4YHHUiIiii+IHm2Q2t3HkJSFP1wHgWYk4k5ZKsTwfyysm3ek=
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 1566577358959216.48757252650114;
Fri, 23 Aug 2019 09:22:38 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
[10.5.11.13])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id E4FEB898101;
Fri, 23 Aug 2019 16:22:37 +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 C29A160872;
Fri, 23 Aug 2019 16:22:37 +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 8863224C10;
Fri, 23 Aug 2019 16:22:37 +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 x7NGM9kC006042 for ;
Fri, 23 Aug 2019 12:22:09 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 8ACBB60606; Fri, 23 Aug 2019 16:22:09 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id 03D5C60872;
Fri, 23 Aug 2019 16:22:08 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:53 -0400
Message-Id:
<0c6d743253400594ad567d4f255ff30a80c62c4e.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=20Lureau?=
Subject: [libvirt] [PATCH v2 09/16] qemu: add vhost-user helpers
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.13
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]);
Fri, 23 Aug 2019 16:22:38 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
Add qemuVhostUserFetchConfigs() to discover vhost-user helpers.
qemuVhostUserFillDomainGPU() will find the first matching GPU helper
with the required capabilities and set the associated
vhost_user_binary.
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
---
src/conf/device_conf.c | 1 +
src/conf/device_conf.h | 1 +
src/qemu/Makefile.inc.am | 2 +
src/qemu/qemu_vhost_user.c | 394 ++++++++++++++++++
src/qemu/qemu_vhost_user.h | 48 +++
tests/Makefile.am | 9 +
.../etc/qemu/vhost-user/40-gpu.json | 1 +
.../etc/qemu/vhost-user/50-gpu.json | 0
.../qemu/vhost-user/test-vhost-user-gpu | 11 +
.../usr/share/qemu/vhost-user/30-gpu.json | 1 +
.../usr/share/qemu/vhost-user/50-gpu.json | 8 +
.../usr/share/qemu/vhost-user/60-gpu.json | 1 +
tests/qemuvhostusertest.c | 132 ++++++
13 files changed, 609 insertions(+)
create mode 100644 src/qemu/qemu_vhost_user.c
create mode 100644 src/qemu/qemu_vhost_user.h
create mode 120000 tests/qemuvhostuserdata/etc/qemu/vhost-user/40-gpu.json
create mode 100644 tests/qemuvhostuserdata/etc/qemu/vhost-user/50-gpu.json
create mode 100755 tests/qemuvhostuserdata/usr/libexec/qemu/vhost-user/tes=
t-vhost-user-gpu
create mode 120000 tests/qemuvhostuserdata/usr/share/qemu/vhost-user/30-gp=
u.json
create mode 100644 tests/qemuvhostuserdata/usr/share/qemu/vhost-user/50-gp=
u.json
create mode 120000 tests/qemuvhostuserdata/usr/share/qemu/vhost-user/60-gp=
u.json
create mode 100644 tests/qemuvhostusertest.c
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index 4c57f0995f..2f7077ddc4 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -96,6 +96,7 @@ virDomainDeviceInfoClear(virDomainDeviceInfoPtr info)
VIR_FREE(info->loadparm);
info->isolationGroup =3D 0;
info->isolationGroupLocked =3D false;
+ VIR_FREE(info->vhost_user_binary);
}
=20
void
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index d0854925e3..0b0c525ad8 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -179,6 +179,7 @@ struct _virDomainDeviceInfo {
* cases we might want to prevent that from happening by
* locking the isolation group */
bool isolationGroupLocked;
+ char *vhost_user_binary;
};
=20
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am
index f7a0fa4a84..18a9220d01 100644
--- a/src/qemu/Makefile.inc.am
+++ b/src/qemu/Makefile.inc.am
@@ -60,6 +60,8 @@ QEMU_DRIVER_SOURCES =3D \
qemu/qemu_qapi.h \
qemu/qemu_tpm.c \
qemu/qemu_tpm.h \
+ qemu/qemu_vhost_user.c \
+ qemu/qemu_vhost_user.h \
$(NULL)
=20
=20
diff --git a/src/qemu/qemu_vhost_user.c b/src/qemu/qemu_vhost_user.c
new file mode 100644
index 0000000000..7a97052ab9
--- /dev/null
+++ b/src/qemu/qemu_vhost_user.c
@@ -0,0 +1,394 @@
+/*
+ * qemu_vhost_user.c: QEMU vhost-user
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * .
+ */
+
+#include
+
+#include "qemu_vhost_user.h"
+#include "qemu_configs.h"
+#include "virjson.h"
+#include "virlog.h"
+#include "virstring.h"
+#include "viralloc.h"
+#include "virenum.h"
+
+#define VIR_FROM_THIS VIR_FROM_QEMU
+
+VIR_LOG_INIT("qemu.qemu_vhost_user");
+
+typedef enum {
+ QEMU_VHOST_USER_TYPE_NONE =3D 0,
+ QEMU_VHOST_USER_TYPE_9P,
+ QEMU_VHOST_USER_TYPE_BALLOON,
+ QEMU_VHOST_USER_TYPE_BLOCK,
+ QEMU_VHOST_USER_TYPE_CAIF,
+ QEMU_VHOST_USER_TYPE_CONSOLE,
+ QEMU_VHOST_USER_TYPE_CRYPTO,
+ QEMU_VHOST_USER_TYPE_GPU,
+ QEMU_VHOST_USER_TYPE_INPUT,
+ QEMU_VHOST_USER_TYPE_NET,
+ QEMU_VHOST_USER_TYPE_RNG,
+ QEMU_VHOST_USER_TYPE_RPMSG,
+ QEMU_VHOST_USER_TYPE_RPROC_SERIAL,
+ QEMU_VHOST_USER_TYPE_SCSI,
+ QEMU_VHOST_USER_TYPE_VSOCK,
+
+ QEMU_VHOST_USER_TYPE_LAST
+} qemuVhostUserType;
+
+VIR_ENUM_DECL(qemuVhostUserType);
+VIR_ENUM_IMPL(qemuVhostUserType,
+ QEMU_VHOST_USER_TYPE_LAST,
+ "",
+ "9p",
+ "balloon",
+ "block",
+ "caif",
+ "console",
+ "crypto",
+ "gpu",
+ "input",
+ "net",
+ "rng",
+ "rpmsg",
+ "rproc-serial",
+ "scsi",
+ "vsock",
+);
+
+typedef enum {
+ QEMU_VHOST_USER_GPU_FEATURE_NONE =3D 0,
+ QEMU_VHOST_USER_GPU_FEATURE_VIRGL,
+ QEMU_VHOST_USER_GPU_FEATURE_RENDER_NODE,
+
+ QEMU_VHOST_USER_GPU_FEATURE_LAST
+} qemuVhostUserGPUFeature;
+
+VIR_ENUM_DECL(qemuVhostUserGPUFeature);
+VIR_ENUM_IMPL(qemuVhostUserGPUFeature,
+ QEMU_VHOST_USER_GPU_FEATURE_LAST,
+ "",
+ "virgl",
+ "render-node",
+);
+
+typedef struct _qemuVhostUserGPU qemuVhostUserGPU;
+typedef qemuVhostUserGPU *qemuVhostUserGPUPtr;
+struct _qemuVhostUserGPU {
+ size_t nfeatures;
+ qemuVhostUserGPUFeature *features;
+};
+
+struct _qemuVhostUser {
+ /* Description intentionally not parsed. */
+ qemuVhostUserType type;
+ char *binary;
+ /* Tags intentionally not parsed. */
+
+ union {
+ qemuVhostUserGPU gpu;
+ } capabilities;
+};
+
+static void
+qemuVhostUserGPUFeatureFree(qemuVhostUserGPUFeature *features)
+{
+ VIR_FREE(features);
+}
+
+
+VIR_DEFINE_AUTOPTR_FUNC(qemuVhostUserGPUFeature, qemuVhostUserGPUFeatureFr=
ee);
+
+void
+qemuVhostUserFree(qemuVhostUserPtr vu)
+{
+ if (!vu)
+ return;
+
+ if (vu->type =3D=3D QEMU_VHOST_USER_TYPE_GPU)
+ VIR_FREE(vu->capabilities.gpu.features);
+
+ VIR_FREE(vu->binary);
+
+ VIR_FREE(vu);
+}
+
+/* 1MiB should be enough for everybody (TM) */
+#define DOCUMENT_SIZE (1024 * 1024)
+
+static int
+qemuVhostUserTypeParse(const char *path,
+ virJSONValuePtr doc,
+ qemuVhostUserPtr vu)
+{
+ const char *type =3D virJSONValueObjectGetString(doc, "type");
+ int tmp;
+
+ VIR_DEBUG("vhost-user description path '%s' type : %s",
+ path, type);
+
+ if ((tmp =3D qemuVhostUserTypeTypeFromString(type)) <=3D 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown vhost-user type: '%s'"),
+ type);
+ return -1;
+ }
+
+ vu->type =3D tmp;
+
+ return 0;
+}
+
+static int
+qemuVhostUserBinaryParse(const char *path,
+ virJSONValuePtr doc,
+ qemuVhostUserPtr vu)
+{
+ const char *binary =3D virJSONValueObjectGetString(doc, "binary");
+
+ VIR_DEBUG("vhost-user description path '%s' binary : %s",
+ path, binary);
+
+ if (VIR_STRDUP(vu->binary, binary) < 0)
+ return -1;
+
+ return 0;
+}
+
+qemuVhostUserPtr
+qemuVhostUserParse(const char *path)
+{
+ VIR_AUTOFREE(char *) cont =3D NULL;
+ VIR_AUTOPTR(virJSONValue) doc =3D NULL;
+ VIR_AUTOPTR(qemuVhostUser) vu =3D NULL;
+ qemuVhostUserPtr ret =3D NULL;
+
+ if (virFileReadAll(path, DOCUMENT_SIZE, &cont) < 0)
+ return NULL;
+
+ if (!(doc =3D virJSONValueFromString(cont))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unable to parse json file '%s'"),
+ path);
+ return NULL;
+ }
+
+ if (VIR_ALLOC(vu) < 0)
+ return NULL;
+
+ if (qemuVhostUserTypeParse(path, doc, vu) < 0)
+ return NULL;
+
+ if (qemuVhostUserBinaryParse(path, doc, vu) < 0)
+ return NULL;
+
+ VIR_STEAL_PTR(ret, vu);
+ return ret;
+}
+
+char *
+qemuVhostUserFormat(qemuVhostUserPtr vu)
+{
+ VIR_AUTOPTR(virJSONValue) doc =3D NULL;
+
+ if (!vu)
+ return NULL;
+
+ if (!(doc =3D virJSONValueNewObject()))
+ return NULL;
+
+ if (virJSONValueObjectAppendString(doc, "type",
+ qemuVhostUserTypeTypeToString(vu->t=
ype)) < 0)
+ return NULL;
+
+ if (virJSONValueObjectAppendString(doc, "binary", vu->binary) < 0)
+ return NULL;
+
+ return virJSONValueToString(doc, true);
+}
+
+int
+qemuVhostUserFetchConfigs(char ***configs,
+ bool privileged)
+{
+ return qemuFetchConfigs("vhost-user", configs, privileged);
+}
+
+static ssize_t
+qemuVhostUserFetchParsedConfigs(bool privileged,
+ qemuVhostUserPtr **vhostuserRet,
+ char ***pathsRet)
+{
+ VIR_AUTOSTRINGLIST paths =3D NULL;
+ size_t npaths;
+ qemuVhostUserPtr *vus =3D NULL;
+ size_t i;
+
+ if (qemuVhostUserFetchConfigs(&paths, privileged) < 0)
+ return -1;
+
+ npaths =3D virStringListLength((const char **)paths);
+
+ if (VIR_ALLOC_N(vus, npaths) < 0)
+ return -1;
+
+ for (i =3D 0; i < npaths; i++) {
+ if (!(vus[i] =3D qemuVhostUserParse(paths[i])))
+ goto error;
+ }
+
+ VIR_STEAL_PTR(*vhostuserRet, vus);
+ if (pathsRet)
+ VIR_STEAL_PTR(*pathsRet, paths);
+ return npaths;
+
+ error:
+ while (i > 0)
+ qemuVhostUserFree(vus[--i]);
+ VIR_FREE(vus);
+ return -1;
+}
+
+
+static int
+qemuVhostUserGPUFillCapabilities(qemuVhostUserPtr vu,
+ virJSONValuePtr doc)
+{
+ qemuVhostUserGPUPtr gpu =3D &vu->capabilities.gpu;
+ virJSONValuePtr featuresJSON;
+ size_t nfeatures;
+ size_t i;
+ VIR_AUTOPTR(qemuVhostUserGPUFeature) features =3D NULL;
+
+ if (!(featuresJSON =3D virJSONValueObjectGetArray(doc, "features"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("failed to get features from '%s'"),
+ vu->binary);
+ return -1;
+ }
+
+ nfeatures =3D virJSONValueArraySize(featuresJSON);
+ if (VIR_ALLOC_N(features, nfeatures) < 0)
+ return -1;
+
+ for (i =3D 0; i < nfeatures; i++) {
+ virJSONValuePtr item =3D virJSONValueArrayGet(featuresJSON, i);
+ const char *tmpStr =3D virJSONValueGetString(item);
+ int tmp;
+
+ if ((tmp =3D qemuVhostUserGPUFeatureTypeFromString(tmpStr)) <=3D 0=
) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown feature %s"),
+ tmpStr);
+ continue;
+ }
+
+ features[i] =3D tmp;
+ }
+
+ VIR_STEAL_PTR(gpu->features, features);
+ gpu->nfeatures =3D nfeatures;
+
+ return 0;
+}
+
+
+static bool
+qemuVhostUserGPUHasFeature(qemuVhostUserGPUPtr gpu,
+ qemuVhostUserGPUFeature feature)
+{
+ size_t i;
+
+ for (i =3D 0; i < gpu->nfeatures; i++) {
+ if (gpu->features[i] =3D=3D feature)
+ return true;
+ }
+
+ return false;
+}
+
+
+int
+qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver,
+ virDomainVideoDefPtr video)
+{
+ qemuVhostUserPtr *vus =3D NULL;
+ ssize_t nvus =3D 0;
+ ssize_t i;
+ int ret =3D -1;
+
+ if ((nvus =3D qemuVhostUserFetchParsedConfigs(driver->privileged,
+ &vus, NULL)) < 0)
+ goto end;
+
+ for (i =3D 0; i < nvus; i++) {
+ qemuVhostUserPtr vu =3D vus[i];
+ VIR_AUTOPTR(virJSONValue) doc =3D NULL;
+ VIR_AUTOFREE(char *) output =3D NULL;
+ VIR_AUTOPTR(virCommand) cmd =3D NULL;
+
+ if (vu->type !=3D QEMU_VHOST_USER_TYPE_GPU)
+ continue;
+
+ cmd =3D virCommandNewArgList(vu->binary, "--print-capabilities", N=
ULL);
+ virCommandSetOutputBuffer(cmd, &output);
+ if (virCommandRun(cmd, NULL) < 0)
+ continue;
+
+ if (!(doc =3D virJSONValueFromString(output))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unable to parse json capabilities '%s'"),
+ vu->binary);
+ continue;
+ }
+
+ if (qemuVhostUserGPUFillCapabilities(vu, doc) < 0)
+ continue;
+
+ if (video->accel) {
+ if (video->accel->accel3d &&
+ !qemuVhostUserGPUHasFeature(&vu->capabilities.gpu,
+ QEMU_VHOST_USER_GPU_FEATURE_VI=
RGL))
+ continue;
+
+ if (video->accel->rendernode &&
+ !qemuVhostUserGPUHasFeature(&vu->capabilities.gpu,
+ QEMU_VHOST_USER_GPU_FEATURE_RE=
NDER_NODE))
+ continue;
+ }
+
+ VIR_FREE(video->info.vhost_user_binary);
+ if (VIR_STRDUP(video->info.vhost_user_binary, vu->binary) < 0)
+ goto end;
+
+ ret =3D 0;
+ break;
+ }
+
+ if (i =3D=3D nvus) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("Unable to find a satisfying vhost-user-gpu"));
+ }
+
+ end:
+ for (i =3D 0; i < nvus; i++)
+ qemuVhostUserFree(vus[i]);
+ VIR_FREE(vus);
+ return ret;
+}
diff --git a/src/qemu/qemu_vhost_user.h b/src/qemu/qemu_vhost_user.h
new file mode 100644
index 0000000000..76701dd1fa
--- /dev/null
+++ b/src/qemu/qemu_vhost_user.h
@@ -0,0 +1,48 @@
+/*
+ * qemu_vhost_user.h: QEMU vhost-user
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * .
+ */
+
+#pragma once
+
+#include "domain_conf.h"
+#include "qemu_conf.h"
+#include "virautoclean.h"
+#include "virarch.h"
+
+typedef struct _qemuVhostUser qemuVhostUser;
+typedef qemuVhostUser *qemuVhostUserPtr;
+
+void
+qemuVhostUserFree(qemuVhostUserPtr fw);
+
+VIR_DEFINE_AUTOPTR_FUNC(qemuVhostUser, qemuVhostUserFree);
+
+qemuVhostUserPtr
+qemuVhostUserParse(const char *path);
+
+char *
+qemuVhostUserFormat(qemuVhostUserPtr fw);
+
+int
+qemuVhostUserFetchConfigs(char ***configs,
+ bool privileged);
+
+int
+qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver,
+ virDomainVideoDefPtr video);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f92710db43..4f4a5236ea 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -290,6 +290,7 @@ test_programs +=3D qemuxml2argvtest qemuxml2xmltest \
qemumigparamstest \
qemusecuritytest \
qemufirmwaretest \
+ qemuvhostusertest \
$(NULL)
test_helpers +=3D qemucapsprobe
test_libraries +=3D libqemumonitortestutils.la \
@@ -692,6 +693,13 @@ qemufirmwaretest_SOURCES =3D \
$(NULL)
qemufirmwaretest_LDADD =3D $(qemu_LDADDS)
=20
+qemuvhostusertest_SOURCES =3D \
+ qemuvhostusertest.c \
+ testutils.h testutils.c \
+ virfilewrapper.c virfilewrapper.h \
+ $(NULL)
+qemuvhostusertest_LDADD =3D $(qemu_LDADDS)
+
else ! WITH_QEMU
EXTRA_DIST +=3D qemuxml2argvtest.c qemuxml2xmltest.c \
qemudomaincheckpointxml2xmltest.c qemudomainsnapshotxml2xmltest.c \
@@ -706,6 +714,7 @@ EXTRA_DIST +=3D qemuxml2argvtest.c qemuxml2xmltest.c \
qemusecuritytest.c qemusecuritytest.h \
qemusecuritymock.c \
qemufirmwaretest.c \
+ qemuvhostusertest.c \
$(QEMUMONITORTESTUTILS_SOURCES)
endif ! WITH_QEMU
=20
diff --git a/tests/qemuvhostuserdata/etc/qemu/vhost-user/40-gpu.json b/test=
s/qemuvhostuserdata/etc/qemu/vhost-user/40-gpu.json
new file mode 120000
index 0000000000..aa93864aa7
--- /dev/null
+++ b/tests/qemuvhostuserdata/etc/qemu/vhost-user/40-gpu.json
@@ -0,0 +1 @@
+../../../usr/share/qemu/vhost-user/50-gpu.json
\ No newline at end of file
diff --git a/tests/qemuvhostuserdata/etc/qemu/vhost-user/50-gpu.json b/test=
s/qemuvhostuserdata/etc/qemu/vhost-user/50-gpu.json
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/qemuvhostuserdata/usr/libexec/qemu/vhost-user/test-vhost=
-user-gpu b/tests/qemuvhostuserdata/usr/libexec/qemu/vhost-user/test-vhost-=
user-gpu
new file mode 100755
index 0000000000..a2c2ee0713
--- /dev/null
+++ b/tests/qemuvhostuserdata/usr/libexec/qemu/vhost-user/test-vhost-user-g=
pu
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+cat <
+
+#include
+
+#include "testutils.h"
+#include "virfilewrapper.h"
+#include "qemu/qemu_vhost_user.h"
+#include "configmake.h"
+
+#define VIR_FROM_THIS VIR_FROM_QEMU
+
+/* A very basic test. Parse given JSON vhostuser description into
+ * an internal structure, format it back and compare with the
+ * contents of the file (minus some keys that are not parsed).
+ */
+static int
+testParseFormatVU(const void *opaque)
+{
+ const char *filename =3D opaque;
+ VIR_AUTOFREE(char *) path =3D NULL;
+ VIR_AUTOPTR(qemuVhostUser) vu =3D NULL;
+ VIR_AUTOFREE(char *) buf =3D NULL;
+ VIR_AUTOPTR(virJSONValue) json =3D NULL;
+ VIR_AUTOFREE(char *) expected =3D NULL;
+ VIR_AUTOFREE(char *) actual =3D NULL;
+
+ if (virAsprintf(&path, "%s/qemuvhostuserdata/%s",
+ abs_srcdir, filename) < 0)
+ return -1;
+
+ if (!(vu =3D qemuVhostUserParse(path)))
+ return -1;
+
+ if (virFileReadAll(path,
+ 1024 * 1024, /* 1MiB */
+ &buf) < 0)
+ return -1;
+
+ if (!(json =3D virJSONValueFromString(buf)))
+ return -1;
+
+ /* Description and tags are not parsed. */
+ if (virJSONValueObjectRemoveKey(json, "description", NULL) < 0 ||
+ virJSONValueObjectRemoveKey(json, "tags", NULL) < 0)
+ return -1;
+
+ if (!(expected =3D virJSONValueToString(json, true)))
+ return -1;
+
+ if (!(actual =3D qemuVhostUserFormat(vu)))
+ return -1;
+
+ return virTestCompareToString(expected, actual);
+}
+
+
+static int
+testVUPrecedence(const void *opaque ATTRIBUTE_UNUSED)
+{
+ VIR_AUTOFREE(char *) fakehome =3D NULL;
+ VIR_AUTOSTRINGLIST vuList =3D NULL;
+ size_t nvuList;
+ size_t i;
+ const char *expected[] =3D {
+ PREFIX "/share/qemu/vhost-user/30-gpu.json",
+ SYSCONFDIR "/qemu/vhost-user/40-gpu.json",
+ PREFIX "/share/qemu/vhost-user/60-gpu.json",
+ };
+ const size_t nexpected =3D ARRAY_CARDINALITY(expected);
+
+ if (VIR_STRDUP(fakehome, abs_srcdir "/qemuvhostuserdata/home/user/.con=
fig") < 0)
+ return -1;
+
+ setenv("XDG_CONFIG_HOME", fakehome, 1);
+
+ if (qemuVhostUserFetchConfigs(&vuList, false) < 0)
+ return -1;
+
+ if (!vuList) {
+ fprintf(stderr, "Expected a non-NULL result, but got a NULL result=
\n");
+ return -1;
+ }
+
+ nvuList =3D virStringListLength((const char **)vuList);
+
+ for (i =3D 0; i < MAX(nvuList, nexpected); i++) {
+ const char *e =3D i < nexpected ? expected[i] : NULL;
+ const char *f =3D i < nvuList ? vuList[i] : NULL;
+
+ if (STRNEQ_NULLABLE(e, f)) {
+ fprintf(stderr,
+ "Unexpected path (i=3D%zu). Expected %s got %s \n",
+ i, NULLSTR(e), NULLSTR(f));
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
+static int
+mymain(void)
+{
+ int ret =3D 0;
+
+ virFileWrapperAddPrefix(SYSCONFDIR "/qemu/vhost-user",
+ abs_srcdir "/qemuvhostuserdata/etc/qemu/vhost-=
user");
+ virFileWrapperAddPrefix(PREFIX "/share/qemu/vhost-user",
+ abs_srcdir "/qemuvhostuserdata/usr/share/qemu/=
vhost-user");
+ virFileWrapperAddPrefix("/home/user/.config/qemu/vhost-user",
+ abs_srcdir "/qemuvhostuserdata/home/user/.conf=
ig/qemu/vhost-user");
+
+#define DO_PARSE_TEST(filename) \
+ do { \
+ if (virTestRun("QEMU vhost-user " filename, \
+ testParseFormatVU, filename) < 0) \
+ ret =3D -1; \
+ } while (0)
+
+ DO_PARSE_TEST("usr/share/qemu/vhost-user/50-gpu.json");
+
+ if (virTestRun("QEMU vhost-user precedence test", testVUPrecedence, NU=
LL) < 0)
+ ret =3D -1;
+
+ virFileWrapperClearPrefixes();
+
+ return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+
+VIR_TEST_MAIN(mymain)
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577353; cv=none;
d=zoho.com; s=zohoarc;
b=OGhk0VOaOI/YAGum88JDp622LRXHSa8uTkhPY2JhKCDlzgBuVSLQleGXAqKzHc7/z53YgE12E8gV9Z21voC7f0lJDg1FBo2L0DgeHGWa50VmyRZEaXWwF/JXDSFt4shaL0yW6NtTXo/lfhPcBsxe5ZYqfUHX0rN2v4dnFUQFNO0=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577353;
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=hzpVpgOP76dE6UcEe4UsIQepP48OHBmVWtJrHIc1M18=;
b=ViGm8qFIBzRReAozutkB7nXQyrMQEqEFbqsZovgBmc5/zZxbjHwc7ugmzfbcmicmczDr0be0nk66VrwS1MuSwS+gJNC6SAj10oU9erVbTQVg98BAt10tSMh7ZJJIuikrDZ5Sz2FcQkm82NEMB/AFNB2REKFTxbkUJ7TtN9Jzg4E=
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 1566577353630243.80234508864032;
Fri, 23 Aug 2019 09:22:33 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com
[10.5.11.22])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 324D0335C1;
Fri, 23 Aug 2019 16:22:32 +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 0BEBA1001B35;
Fri, 23 Aug 2019 16:22:32 +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 C974124F37;
Fri, 23 Aug 2019 16:22:31 +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 x7NGMA8q006048 for ;
Fri, 23 Aug 2019 12:22:10 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 339BE60605; Fri, 23 Aug 2019 16:22:10 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id B5DAE60872;
Fri, 23 Aug 2019 16:22:09 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:54 -0400
Message-Id:
<0d43c27193a39be9ef207e8b7f476d30e883e53c.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=20Lureau?=
Subject: [libvirt] [PATCH v2 10/16] qemu: add qemuSecurityStartVhostUserGPU
helper
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.22
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]);
Fri, 23 Aug 2019 16:22:32 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
See function documentation. Used in a following patch.
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
---
src/qemu/qemu_security.c | 47 ++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_security.h | 6 +++++
2 files changed, 53 insertions(+)
diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c
index 3cd6d9bd3d..86b06594f6 100644
--- a/src/qemu/qemu_security.c
+++ b/src/qemu/qemu_security.c
@@ -433,6 +433,53 @@ qemuSecurityRestoreChardevLabel(virQEMUDriverPtr drive=
r,
}
=20
=20
+/*
+ * qemuSecurityStartVhostUserGPU:
+ *
+ * @driver: the QEMU driver
+ * @vm: the domain object
+ * @cmd: the command to run
+ * @existstatus: pointer to int returning exit status of process
+ * @cmdret: pointer to int returning result of virCommandRun
+ *
+ * Start the vhost-user-gpu process with approriate labels.
+ * This function returns -1 on security setup error, 0 if all the
+ * setup was done properly. In case the virCommand failed to run
+ * 0 is returned but cmdret is set appropriately with the process
+ * exitstatus also set.
+ */
+int
+qemuSecurityStartVhostUserGPU(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virCommandPtr cmd,
+ int *exitstatus,
+ int *cmdret)
+{
+ int ret =3D -1;
+
+ if (virSecurityManagerSetChildProcessLabel(driver->securityManager,
+ vm->def, cmd) < 0)
+ goto cleanup;
+
+ if (virSecurityManagerPreFork(driver->securityManager) < 0)
+ goto cleanup;
+
+ ret =3D 0;
+
+ *cmdret =3D virCommandRun(cmd, exitstatus);
+
+ virSecurityManagerPostFork(driver->securityManager);
+
+ if (*cmdret < 0)
+ goto cleanup;
+
+ return 0;
+
+ cleanup:
+ return ret;
+}
+
+
/*
* qemuSecurityStartTPMEmulator:
*
diff --git a/src/qemu/qemu_security.h b/src/qemu/qemu_security.h
index 68e377f418..a48ed8ec78 100644
--- a/src/qemu/qemu_security.h
+++ b/src/qemu/qemu_security.h
@@ -77,6 +77,12 @@ int qemuSecurityRestoreChardevLabel(virQEMUDriverPtr dri=
ver,
virDomainObjPtr vm,
virDomainChrDefPtr chr);
=20
+int qemuSecurityStartVhostUserGPU(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virCommandPtr cmd,
+ int *exitstatus,
+ int *cmdret);
+
int qemuSecurityStartTPMEmulator(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virCommandPtr cmd,
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577357; cv=none;
d=zoho.com; s=zohoarc;
b=QKCjREUD9xhBxA/QmZJjH0LaNV116xrv9VgiSewlS7l7OaV+I7nUTb63E3+ZslA3u6pp6l44yMBv283TVW5k0UDo/fWz3X6S178gPdhZ6yeBgqKV8P3UyHSDN3Wozhl8I+i59cWiO5HQqY6tZPD99+BRhm9KPmbZtAsuu1k6rJ8=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577357;
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=szTQEPzxbYBLOl+FNcB6bKGpHpUn8fGcvb2Tj99QtpA=;
b=kiMi0s2jv8TPA6qwt51ihFZxXC10JzfCnbWjDcY614L1Q5ISRD6lIJRgRwt/G+6R8ZbtV0XLDDxHuC5poqTpIEdyaCr7W9v36si6PqcjuDmO2/xB+YwgH0P7ai0h5GxPG683dqvG+axuaHH50aJic6Gk6z5tOQGVZuyykniT8pw=
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 1566577357855667.8265167512931;
Fri, 23 Aug 2019 09:22:37 -0700 (PDT)
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 7CF763B71F;
Fri, 23 Aug 2019 16:22:36 +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 582C2BA8A;
Fri, 23 Aug 2019 16:22:36 +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 1C57A180BA9C;
Fri, 23 Aug 2019 16:22:36 +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 x7NGMAXR006056 for ;
Fri, 23 Aug 2019 12:22:10 -0400
Received: by smtp.corp.redhat.com (Postfix)
id D061160A9F; Fri, 23 Aug 2019 16:22:10 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id 5C87060872;
Fri, 23 Aug 2019 16:22:10 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:55 -0400
Message-Id:
<556480400e3d312cc3310fe27d04253d4d98f024.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=20Lureau?=
Subject: [libvirt] [PATCH v2 11/16] qemu: add vhost-user-gpu helper unit
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.12
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]);
Fri, 23 Aug 2019 16:22:36 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
Similar to the qemu_tpm.c, add a unit with a few functions to
start/stop and setup the cgroup of the external vhost-user-gpu
process. See function documentation.
Since the vhost-user connection fd isn't necessarily specific to QEMU,
it was easier to add it to virDomainDeviceInfo, although a reasonable
place could be qemuDomainObjPrivate (with an associate hashtable
device-info -> qemu-device-info for example).
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
---
src/conf/device_conf.h | 1 +
src/qemu/Makefile.inc.am | 2 +
src/qemu/qemu_vhost_user_gpu.c | 305 +++++++++++++++++++++++++++++++++
src/qemu/qemu_vhost_user_gpu.h | 50 ++++++
4 files changed, 358 insertions(+)
create mode 100644 src/qemu/qemu_vhost_user_gpu.c
create mode 100644 src/qemu/qemu_vhost_user_gpu.h
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index 0b0c525ad8..23cc2e9ba6 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -180,6 +180,7 @@ struct _virDomainDeviceInfo {
* locking the isolation group */
bool isolationGroupLocked;
char *vhost_user_binary;
+ int vhost_user_fd;
};
=20
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am
index 18a9220d01..d394eab957 100644
--- a/src/qemu/Makefile.inc.am
+++ b/src/qemu/Makefile.inc.am
@@ -62,6 +62,8 @@ QEMU_DRIVER_SOURCES =3D \
qemu/qemu_tpm.h \
qemu/qemu_vhost_user.c \
qemu/qemu_vhost_user.h \
+ qemu/qemu_vhost_user_gpu.c \
+ qemu/qemu_vhost_user_gpu.h \
$(NULL)
=20
=20
diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c
new file mode 100644
index 0000000000..0735af1473
--- /dev/null
+++ b/src/qemu/qemu_vhost_user_gpu.c
@@ -0,0 +1,305 @@
+/*
+ * qemu_vhost_user_gpu.c: QEMU vhost-user GPU support
+ *
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * .
+ */
+
+#include
+
+#include "qemu_vhost_user_gpu.h"
+#include "qemu_vhost_user.h"
+#include "qemu_extdevice.h"
+
+#include "conf/domain_conf.h"
+#include "configmake.h"
+#include "vircommand.h"
+#include "viralloc.h"
+#include "virlog.h"
+#include "virutil.h"
+#include "virfile.h"
+#include "virstring.h"
+#include "virtime.h"
+#include "virpidfile.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+VIR_LOG_INIT("qemu.vhost-user-gpu");
+
+
+static char *
+qemuVhostUserGPUCreatePidFilename(const char *stateDir,
+ const char *shortName,
+ const char *alias)
+{
+ char *pidfile =3D NULL;
+ char *devicename =3D NULL;
+
+ if (virAsprintf(&devicename, "%s-%s-vhost-user-gpu", shortName, alias)=
< 0)
+ return NULL;
+
+ pidfile =3D virPidFileBuildPath(stateDir, devicename);
+
+ VIR_FREE(devicename);
+
+ return pidfile;
+}
+
+
+/*
+ * qemuVhostUserGPUGetPid:
+ * @binpath: path of executable associated with the pidfile
+ * @stateDir: the directory where vhost-user-gpu writes the pidfile into
+ * @shortName: short name of the domain
+ * @alias: video device alias
+ * @pid: pointer to pid
+ *
+ * Return -errno upon error, or zero on successful reading of the pidfile.
+ * If the PID was not still alive, zero will be returned, and @pid will be
+ * set to -1;
+ */
+static int
+qemuVhostUserGPUGetPid(const char *binPath,
+ const char *stateDir,
+ const char *shortName,
+ const char *alias,
+ pid_t *pid)
+{
+ int ret;
+ char *pidfile =3D qemuVhostUserGPUCreatePidFilename(stateDir, shortNam=
e, alias);
+ if (!pidfile)
+ return -ENOMEM;
+
+ ret =3D virPidFileReadPathIfAlive(pidfile, pid, binPath);
+
+ VIR_FREE(pidfile);
+
+ return ret;
+}
+
+
+int qemuExtVhostUserGPUPrepareDomain(virQEMUDriverPtr driver,
+ virDomainVideoDefPtr video)
+{
+ return qemuVhostUserFillDomainGPU(driver, video);
+}
+
+
+/*
+ * qemuExtVhostUserGPUStart:
+ * @driver: QEMU driver
+ * @vm: the VM domain
+ * @video: the video device
+ * @logCtxt: log context
+ *
+ * Start the external vhost-user-gpu process:
+ * - open a socketpair for vhost-user communication
+ * - have the command line built
+ * - start the external process and sync with it before QEMU start
+ */
+int qemuExtVhostUserGPUStart(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainVideoDefPtr video,
+ qemuDomainLogContextPtr logCtxt)
+{
+ int ret =3D -1;
+ virCommandPtr cmd =3D NULL;
+ int exitstatus =3D 0;
+ char *errbuf =3D NULL;
+ virQEMUDriverConfigPtr cfg;
+ char *pidfile =3D NULL, *shortName =3D virDomainDefGetShortName(vm->de=
f);
+ virTimeBackOffVar timebackoff;
+ const unsigned long long timeout =3D 500 * 1000; /* ms */
+ int cmdret =3D 0, rc;
+ int pair[2] =3D { -1, -1 };
+
+ pid_t pid;
+
+ if (!shortName)
+ return -1;
+
+ cfg =3D virQEMUDriverGetConfig(driver);
+
+ /* stop any left-over for this VM */
+ qemuExtVhostUserGPUStop(driver, vm, video);
+
+ if (!(pidfile =3D qemuVhostUserGPUCreatePidFilename(
+ cfg->stateDir, shortName, video->info.alias)))
+ goto error;
+
+ if (qemuSecuritySetSocketLabel(driver->securityManager, vm->def) < 0)
+ goto cleanup;
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) < 0) {
+ virReportSystemError(errno, "%s", _("failed to create socket"));
+ goto error;
+ }
+
+ if (qemuSecurityClearSocketLabel(driver->securityManager, vm->def) < 0)
+ goto cleanup;
+
+ cmd =3D virCommandNew(video->info.vhost_user_binary);
+ if (!cmd)
+ goto error;
+
+ virCommandClearCaps(cmd);
+ virCommandSetPidFile(cmd, pidfile);
+ virCommandDaemonize(cmd);
+
+ if (qemuExtDeviceLogCommand(logCtxt, cmd, "vhost-user-gpu") < 0)
+ goto error;
+
+ virCommandAddArgFormat(cmd, "--fd=3D%d", pair[0]);
+ virCommandPassFD(cmd, pair[0], VIR_COMMAND_PASS_FD_CLOSE_PARENT);
+ pair[0] =3D -1;
+
+ if (video->accel) {
+ if (video->accel->accel3d)
+ virCommandAddArg(cmd, "--virgl");
+
+ if (video->accel->rendernode)
+ virCommandAddArgFormat(cmd, "--render-node=3D%s", video->accel=
->rendernode);
+ }
+ if (qemuSecurityStartVhostUserGPU(driver, vm, cmd,
+ &exitstatus, &cmdret) < 0)
+ goto error;
+
+ if (cmdret < 0 || exitstatus !=3D 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not start 'vhost-user-gpu'. exitstatus: %d=
, "
+ "error: %s"), exitstatus, errbuf);
+ goto cleanup;
+ }
+
+ /* check that the helper has written its pid into the file */
+ if (virTimeBackOffStart(&timebackoff, 1, timeout) < 0)
+ goto error;
+ while (virTimeBackOffWait(&timebackoff)) {
+ rc =3D qemuVhostUserGPUGetPid(video->info.vhost_user_binary,
+ cfg->stateDir, shortName, video->info.=
alias, &pid);
+ if (rc < 0)
+ continue;
+ if (rc =3D=3D 0 && pid =3D=3D (pid_t)-1)
+ goto error;
+ break;
+ }
+
+ ret =3D 0;
+ video->info.vhost_user_fd =3D pair[1];
+ pair[1] =3D -1;
+
+ cleanup:
+ VIR_FORCE_CLOSE(pair[0]);
+ VIR_FORCE_CLOSE(pair[1]);
+ virObjectUnref(cfg);
+ VIR_FREE(pidfile);
+ virCommandFree(cmd);
+
+ return ret;
+
+ error:
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("vhost-user-gpu failed to start"));
+ goto cleanup;
+}
+
+
+/*
+ * qemuExtVhostUserGPUStop:
+ *
+ * @driver: QEMU driver
+ * @vm: the VM domain
+ * @video: the video device
+ *
+ * Check if vhost-user process pidfile is around, kill the process,
+ * and remove the pidfile.
+ */
+void qemuExtVhostUserGPUStop(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainVideoDefPtr video)
+{
+ virErrorPtr orig_err;
+ char *pidfile, *shortName =3D virDomainDefGetShortName(vm->def);
+ virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver);
+
+ if (!(pidfile =3D qemuVhostUserGPUCreatePidFilename(
+ cfg->stateDir, shortName, video->info.alias))) {
+ VIR_WARN("Unable to construct vhost-user-gpu pidfile path");
+ return;
+ }
+
+ virErrorPreserveLast(&orig_err);
+ if (virPidFileForceCleanupPath(pidfile) < 0) {
+ VIR_WARN("Unable to kill vhost-user-gpu process");
+ } else {
+ if (unlink(pidfile) < 0 &&
+ errno !=3D ENOENT) {
+ virReportSystemError(errno,
+ _("Unable to remove stale pidfile %s"),
+ pidfile);
+ }
+ }
+ virErrorRestore(&orig_err);
+
+ VIR_FREE(pidfile);
+}
+
+
+/*
+ * qemuExtVhostUserGPUSetupCgroup:
+ *
+ * @driver: QEMU driver
+ * @def: domain definition
+ * @video: the video device
+ * @cgroupe: a cgroup
+ *
+ * Add the vhost-user-gpu PID to the given cgroup.
+ */
+int
+qemuExtVhostUserGPUSetupCgroup(virQEMUDriverPtr driver,
+ virDomainDefPtr def,
+ virDomainVideoDefPtr video,
+ virCgroupPtr cgroup)
+{
+ virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver);
+ char *pidfile =3D NULL;
+ char *shortName =3D NULL;
+ int ret =3D -1, rc;
+ pid_t pid;
+
+ shortName =3D virDomainDefGetShortName(def);
+ if (!shortName)
+ goto cleanup;
+
+ rc =3D qemuVhostUserGPUGetPid(video->info.vhost_user_binary,
+ cfg->stateDir, shortName, video->info.alia=
s, &pid);
+ if (rc < 0 || (rc =3D=3D 0 && pid =3D=3D (pid_t)-1)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not get process id of vhost-user-gpu"));
+ goto cleanup;
+ }
+ if (virCgroupAddProcess(cgroup, pid) < 0)
+ goto cleanup;
+
+ ret =3D 0;
+
+ cleanup:
+ VIR_FREE(pidfile);
+ VIR_FREE(shortName);
+ virObjectUnref(cfg);
+
+ return ret;
+}
diff --git a/src/qemu/qemu_vhost_user_gpu.h b/src/qemu/qemu_vhost_user_gpu.h
new file mode 100644
index 0000000000..85054894fd
--- /dev/null
+++ b/src/qemu/qemu_vhost_user_gpu.h
@@ -0,0 +1,50 @@
+/*
+ * qemu_vhost_user_gpu.h: QEMU vhost-user GPU support
+ *
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * .
+ */
+
+#pragma once
+
+#include "domain_conf.h"
+#include "qemu_domain.h"
+#include "qemu_security.h"
+
+int qemuExtVhostUserGPUPrepareDomain(virQEMUDriverPtr driver,
+ virDomainVideoDefPtr video)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
+ ATTRIBUTE_RETURN_CHECK;
+
+int qemuExtVhostUserGPUStart(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainVideoDefPtr video,
+ qemuDomainLogContextPtr logCtxt)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
+ ATTRIBUTE_RETURN_CHECK;
+
+void qemuExtVhostUserGPUStop(virQEMUDriverPtr driver,
+ virDomainObjPtr def,
+ virDomainVideoDefPtr video)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
+int
+qemuExtVhostUserGPUSetupCgroup(virQEMUDriverPtr driver,
+ virDomainDefPtr def,
+ virDomainVideoDefPtr video,
+ virCgroupPtr cgroup)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
+ ATTRIBUTE_RETURN_CHECK;
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577356; cv=none;
d=zoho.com; s=zohoarc;
b=apa+4C6QTpooH3z/3Yzhn0Xkqq2us6LNgs4fV96QZ6XcmQySl2TUzXZKDEJ8GNlhQKnzLLBuBHx0Fti3gd5AWW7TDYOAtExwzRggaaZa+gP8gy3XajMJ5wRmtFtXjyKVdCbh93jbI98nyY3QHCCezb3TIF4zC5wdGo3qkiXGsp0=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577356;
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=CZSTzLxG3IIVlltJ0sS2ngM32kw/yJ4UpNGYx2Y0+nA=;
b=hv/UsEkSaXIxISu8dG+aXPtw0BnDgjYP69+oNuhADvwDYzfeeiK8bBOyy4sQ8o4I4Hg1x3/+avrYLBNnfbG7xy20vJGd9SvJqbphsNUxB8cSay1wAUaVTG4MBL7f94xzX2EED8b4A3Nv5GwRgFEchOpm7/U8pJLdPIHHncb8yno=
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 1566577356957864.669051656265;
Fri, 23 Aug 2019 09:22:36 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com
[10.5.11.16])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id BAC448BA01;
Fri, 23 Aug 2019 16:22:35 +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 93D155C1B5;
Fri, 23 Aug 2019 16:22: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 5A76C24F3B;
Fri, 23 Aug 2019 16:22:35 +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 x7NGMBpb006067 for ;
Fri, 23 Aug 2019 12:22:11 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 7975160A9F; Fri, 23 Aug 2019 16:22:11 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id 0478860872;
Fri, 23 Aug 2019 16:22:10 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:56 -0400
Message-Id:
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=20Lureau?=
Subject: [libvirt] [PATCH v2 12/16] qemu: prepare domain for vhost-user GPU
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.16
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]);
Fri, 23 Aug 2019 16:22:36 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
Call qemuExtVhostUserGPUPrepareDomain() to fill the domain with the
location of the vhost-user binary to start.
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
---
src/qemu/qemu_extdevice.c | 29 +++++++++++++++++++++++++++++
src/qemu/qemu_extdevice.h | 5 +++++
src/qemu/qemu_process.c | 4 ++++
3 files changed, 38 insertions(+)
diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
index dc032aa60c..5c55aba006 100644
--- a/src/qemu/qemu_extdevice.c
+++ b/src/qemu/qemu_extdevice.c
@@ -21,6 +21,7 @@
#include
=20
#include "qemu_extdevice.h"
+#include "qemu_vhost_user_gpu.h"
#include "qemu_domain.h"
#include "qemu_tpm.h"
=20
@@ -92,6 +93,34 @@ qemuExtDevicesInitPaths(virQEMUDriverPtr driver,
}
=20
=20
+/*
+ * qemuExtDevicesPrepareDomain:
+ *
+ * @driver: QEMU driver
+ * @vm: domain
+ *
+ * Code that modifies live XML of a domain which is about to start.
+ */
+int
+qemuExtDevicesPrepareDomain(virQEMUDriverPtr driver,
+ virDomainObjPtr vm)
+{
+ int ret =3D 0;
+ size_t i;
+
+ 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) {
+ if ((ret =3D qemuExtVhostUserGPUPrepareDomain(driver, video) <=
0))
+ break;
+ }
+ }
+
+ return ret;
+}
+
+
/*
* qemuExtDevicesPrepareHost:
*
diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h
index 039b3e60dd..2412244d60 100644
--- a/src/qemu/qemu_extdevice.h
+++ b/src/qemu/qemu_extdevice.h
@@ -29,6 +29,11 @@ int qemuExtDeviceLogCommand(qemuDomainLogContextPtr logC=
txt,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_RETURN_CHECK;
=20
+int qemuExtDevicesPrepareDomain(virQEMUDriverPtr driver,
+ virDomainObjPtr vm)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
+ ATTRIBUTE_RETURN_CHECK;
+
int qemuExtDevicesPrepareHost(virQEMUDriverPtr driver,
virDomainDefPtr def)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c439f17011..ed767b0807 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6358,6 +6358,10 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
if (qemuFirmwareFillDomain(driver, vm, flags) < 0)
goto cleanup;
=20
+ VIR_DEBUG("Preparing external devices");
+ if (qemuExtDevicesPrepareDomain(driver, vm) < 0)
+ goto cleanup;
+
for (i =3D 0; i < vm->def->nchannels; i++) {
if (qemuDomainPrepareChannel(vm->def->channels[i],
priv->channelTargetDir) < 0)
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577360; cv=none;
d=zoho.com; s=zohoarc;
b=P05NO70xYk7LORebnjl/n+IJQcInoXdaK3Mp2arek5YGs0C7wY2OTsJyal1zVTz3om1HOGa3NVtx0ZSAgVFQyqKJ9ldk+U2xsb7yp5/m4pIh0w3Coip4DI+6tWbxFx9Z4ln9BT3pOcaDjMcD1g04NBTNSbTVF4IPLxwDKcuM0Ek=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577360;
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=6jVRExrwbAHpiKbghfXaHksd0Peusj/zEJ6jpglAkfs=;
b=eWSyFg7eohIJqPFgZjn15JxOy/nC7pOROuP9q6scwRs5cNKhoPbxQh30aT/lG4xOXCOF8mgjL9BYcNUCUWUDogNR5BBNbQsFsqsIEoGJIa9QUVCndAd32kJdn3YI2Y2Um9zUHHkUr/NkOreKenVdCS5f5jUpG4KoSCaGMVzPiZQ=
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 1566577360890646.6312179748782;
Fri, 23 Aug 2019 09:22:40 -0700 (PDT)
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)
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=20Lureau?=
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: ,
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.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=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
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 =3D 0;
+ size_t i;
=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, incomingMigration);
=20
@@ -176,9 +187,18 @@ void
qemuExtDevicesStop(virQEMUDriverPtr driver,
virDomainObjPtr vm)
{
+ size_t 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 +207,14 @@ qemuExtDevicesStop(virQEMUDriverPtr driver,
bool
qemuExtDevicesHasDevice(virDomainDefPtr def)
{
+ size_t 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 +227,20 @@ qemuExtDevicesSetupCgroup(virQEMUDriverPtr driver,
virDomainDefPtr def,
virCgroupPtr cgroup)
{
- int ret =3D 0;
+ size_t 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.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577364; cv=none;
d=zoho.com; s=zohoarc;
b=HtE2NILD2s2aOWaTCldvxSVbdxYPJ7BzeV4yestckiUwtceFpQ9eB7MJZZFZ9LNNhlvKC+iv+B3vygsWblQv3ui8Kq+I18P8siVI26J503QKIpb4/i62A6PhZWU16950fTEG0w/QVTF1zcLv0yzL3ESy0VOHES1/m74RV+XBNHc=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577364;
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=/QW/Zi8t//W0D2Ss0PBdY0fqCCq7AqvpmDiJ0ltUtIY=;
b=WRHRRBw48LsVjD3koXpvrmNg5m8QrpjK8tgAw8HW93MfdXqZ7MfVZutxUUb7n1HZ8TLJBge7NSH7UwLfvh5fAlzBb5OkO5u6a0pZb/Z9Pcfpp2J0MhBjIWrctzHxMd+0Z4oYgvD88E9LYmnTKRrj+YFAP7XHV+rqDakg/SOD0LM=
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 1566577364974734.5859935552597;
Fri, 23 Aug 2019 09:22:44 -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 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)
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=20Lureau?=
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: ,
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.6.2 (mx1.redhat.com [10.5.110.64]);
Fri, 23 Aug 2019 16:22:44 +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
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;
}
=20
- if (STREQ(model, "virtio-gpu")) {
- if (qemuBuildVirtioDevStr(&buf, "virtio-gpu", qemuCaps,
+ if (video->vhostuser) {
+ if (STREQ(model, "virtio-vga"))
+ model =3D "vhost-user-vga";
+ if (STREQ(model, "virtio-gpu"))
+ model =3D "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=3D%u", video->heads);
}
+ } else if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && video->v=
hostuser) {
+ 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)
@@ -4830,6 +4841,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,
@@ -4837,6 +4865,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->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && video->vhos=
tuser) {
+ if (!(chardev =3D qemuBuildVhostUserChardevStr(video->info.ali=
as,
+ &video->info.vhos=
t_user_fd,
+ cmd)))
+ return -1;
+
+ virCommandAddArgList(cmd, "-chardev", chardev, NULL);
+ }
+ }
+
for (i =3D 0; i < def->nvideos; i++) {
char *str =3D NULL;
virDomainVideoDefPtr video =3D def->videos[i];
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577362; cv=none;
d=zoho.com; s=zohoarc;
b=I5Ue/kTA4Yd06uck0BIfXYShycds8TVKyY5BYETPKMuI4TGI+g6YwZgPARRGsA9T6zSprzgOaFh5Eb2oOeQSHj1jmawjExCbTn+dlOCsF3fyRrRlZkwNYNf+4R5JYJGKeaPbVAn5spl6KcF3V9egxjx2kiTGv228DTo6CzxJ7h8=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577362;
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=9+OOeBSZ4nvRKdUERdgyMf+CDN8VvXsDiaJzWqqqhWY=;
b=EsmNUAr2kLW6yRCwEGjEArRG117NYD4heqGJmtxcaLDlZCdvhhuCw7X5hquxcF13BtgSbBXlVLr913LkSK8Wi7LKaoluhLp+46Uy6H9+KCEHNv97hgAS3gahpbM3PimD18RlVuC6UkR0KF4d0hy6Fypzmzwib6c+axa1i7OmwRM=
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 1566577362572605.7267769591544;
Fri, 23 Aug 2019 09:22:42 -0700 (PDT)
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 60CD01E2029;
Fri, 23 Aug 2019 16:22:41 +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 3A6A3BA8F;
Fri, 23 Aug 2019 16:22:41 +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 F12ED180BAA2;
Fri, 23 Aug 2019 16:22:40 +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 x7NGMDeC006098 for ;
Fri, 23 Aug 2019 12:22:13 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 6275460605; Fri, 23 Aug 2019 16:22:13 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id E3BDE60872;
Fri, 23 Aug 2019 16:22:12 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:21:59 -0400
Message-Id:
<91200df1c0012490e08a68101b1ec4c362dee6b8.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=20Lureau?=
Subject: [libvirt] [PATCH v2 15/16] tests: mock execv/execve
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.12
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]);
Fri, 23 Aug 2019 16:22:41 +0000 (UTC)
From: Marc-Andr=C3=A9 Lureau
Learn to override the paths to the program to execute (vhost-user
helpers are executed to check for runtime capabilities).
Signed-off-by: Marc-Andr=C3=A9 Lureau
Signed-off-by: Cole Robinson
---
tests/virfilewrapper.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tests/virfilewrapper.c b/tests/virfilewrapper.c
index 160cd571e0..3d3f319f2c 100644
--- a/tests/virfilewrapper.c
+++ b/tests/virfilewrapper.c
@@ -44,6 +44,8 @@ static FILE *(*real_fopen)(const char *path, const char *=
mode);
static int (*real_access)(const char *path, int mode);
static int (*real_mkdir)(const char *path, mode_t mode);
static DIR *(*real_opendir)(const char *path);
+static int (*real_execv)(const char *path, char *const argv[]);
+static int (*real_execve)(const char *path, char *const argv[], char *cons=
t envp[]);
=20
static void init_syms(void)
{
@@ -55,6 +57,8 @@ static void init_syms(void)
VIR_MOCK_REAL_INIT(mkdir);
VIR_MOCK_REAL_INIT(open);
VIR_MOCK_REAL_INIT(opendir);
+ VIR_MOCK_REAL_INIT(execv);
+ VIR_MOCK_REAL_INIT(execve);
}
=20
=20
@@ -191,4 +195,22 @@ DIR *opendir(const char *path)
return real_opendir(newpath ? newpath : path);
}
=20
+int execv(const char *path, char *const argv[])
+{
+ VIR_AUTOFREE(char *) newpath =3D NULL;
+
+ PATH_OVERRIDE(newpath, path);
+
+ return real_execv(newpath ? newpath : path, argv);
+}
+
+int execve(const char *path, char *const argv[], char *const envp[])
+{
+ VIR_AUTOFREE(char *) newpath =3D NULL;
+
+ PATH_OVERRIDE(newpath, path);
+
+ return real_execve(newpath ? newpath : path, argv, envp);
+}
+
#endif
--=20
2.21.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Tue May 7 00:13:49 2024
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=1566577366; cv=none;
d=zoho.com; s=zohoarc;
b=P4dKrIFb3MmqcIu+hU9voFJCqg/CPZ508iJLVpl6PUg8QYHD2QlavhF84FJ+hXoI4G2uqFx/K7uzE9HvM8HABvr209h394a40LFVWlLR+QxrTVpgQ/z19FeeL1b5qVUazDLfv1WpH59Uh6abjUiu6gpNfkjKvVTK4g5U7eSYd/g=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
s=zohoarc;
t=1566577366;
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=ys6oxaVXvoN+zmwY6sbH8YjQCQXlpCkv36a5MMB86y0=;
b=Ou347l2kM/wiMoQ8f+xz4YgMpAahjrCuhLBzfMEKHT/UzwnD45+Crgcwjmkf8RB2W/k2GZIKEj77B8RbakUwrvo62J4b8f4XdVrwxLd+Jw4Fd6/sDxYwXliltUX+5R7vHQiCNSrqliVcMBYzXHnCcmFu9OESWlpIxxBOKonyzoQ=
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 1566577366130315.68183207022355;
Fri, 23 Aug 2019 09:22:46 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com
[10.5.11.16])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 1275118C892F;
Fri, 23 Aug 2019 16:22:45 +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 DF3C417168;
Fri, 23 Aug 2019 16:22:44 +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 A5419180BAA8;
Fri, 23 Aug 2019 16:22:44 +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 x7NGMEl4006106 for ;
Fri, 23 Aug 2019 12:22:14 -0400
Received: by smtp.corp.redhat.com (Postfix)
id 0E2B760A9F; Fri, 23 Aug 2019 16:22:14 +0000 (UTC)
Received: from worklaptop.redhat.com (ovpn-122-169.rdu2.redhat.com
[10.10.122.169])
by smtp.corp.redhat.com (Postfix) with ESMTP id 8E3AF60872;
Fri, 23 Aug 2019 16:22:13 +0000 (UTC)
From: Cole Robinson
To: libvirt-list@redhat.com
Date: Fri, 23 Aug 2019 12:22:00 -0400
Message-Id:
<979d2cf172bda54e7a56724a64099a11733a37c3.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=20Lureau?=
Subject: [libvirt] [PATCH v2 16/16] tests: add vhost-user-gpu xml2argv tests
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: ,