From nobody Wed Oct 30 22:11:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1722282639129450.8934057389656; Mon, 29 Jul 2024 12:50:39 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EE5221350; Mon, 29 Jul 2024 15:50:37 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0AB8012DE; Mon, 29 Jul 2024 15:49:44 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C33D01258; Mon, 29 Jul 2024 15:49:39 -0400 (EDT) Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 127531231 for ; Mon, 29 Jul 2024 15:49:39 -0400 (EDT) Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5a1f9bc80e3so3255827a12.2 for ; Mon, 29 Jul 2024 12:49:39 -0700 (PDT) Received: from localhost.localdomain ([2001:4bb8:181:247f:e288:8f76:5999:3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac6339bcb3sm6121862a12.5.2024.07.29.12.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 12:49:37 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722282578; x=1722887378; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RLJVTi0l7KvCdu1unkFxGSkO1Feo8WPbVE5sEI0BKtw=; b=N9WSot//efaY4do2lXaVqmVl9bHanY7koo/U9W9rZukeGb3UiJlSlutjNsPRYrz1gV 2adtd4jCNC9uphbTkALWXoipkGMmu7Hm3LZY1PhZT9xXIVyvWGCAUAkyEk4CbqbFKM4k rstBKF9CTNsHqw3N8eMd8FFysinU2ROycTDifoacc1BhJXSpINV0s/WTCalkJ54k8Tx0 WGC6Yu/ThLJGLs8/Qzfxid7moj38zji4MVAywMKTcm9kM1Nmn4E+Stur9dUpTf5U9Jjr U6M1FOQGCXj2+E1yPP80z2jfA8bCAPwnBPY98GMjEhfCVFTPqO+GEICExXfPc9rdOrss Qf5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722282578; x=1722887378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RLJVTi0l7KvCdu1unkFxGSkO1Feo8WPbVE5sEI0BKtw=; b=FUmgE4X78e3C10QZ5/uJUGzMJLjgSqrxow6kAx+wfbQvu+5h0tvs+mDgaI4H8xvyB0 fQE/jVLeG4dOO9s3sntMyqP2uHLCRfsf2PGdOSKDwUE3AJK/fLIojnw/I47KVGxB0UCi k/GPEeTJWDIfY4jFV4QyQaz6dxWJvISvio5h+umGUYyOaGl231zEUphfMMOMr9iYTu4M F0zYZF6huvfU8ZnLWwJ9DS7an27FAD+IAHHeZD953FmzA5WMiXnhFbyUeISRJUF0Pn1V R4dKOJomhJnp3XWR2a6BajA2dOw0ReNrt1vxJbfrGWxSFV933ubN/j5hcsEGkcPQw9H7 mRtA== X-Gm-Message-State: AOJu0Yx6ljz7oeeo4ytiEA3ahBztKW5HzpQ79Mr0Kc4fIExnwrDoT0eV hBwRd8IUH9VsD3jEdg8e+Xu1GMRBXCMvTVZmBGVI2N7EAQyxqFGsyJhoFcVPxOpvN8Z5oLRUJEV Y X-Google-Smtp-Source: AGHT+IGcm/Yl7c6wwh7Sd7ERUdsQK8pbbXFw9901yllEFaa9mzo51lKkNv3kTZsN6oPke3Nbi4Vj6A== X-Received: by 2002:a50:99de:0:b0:5a2:c1b1:4d3 with SMTP id 4fb4d7f45d1cf-5b02317cfecmr6336298a12.28.1722282577538; Mon, 29 Jul 2024 12:49:37 -0700 (PDT) From: Andrew Melnychenko To: devel@lists.libvirt.org Subject: [RFC PATCH v4 1/5] qemu_monitor: Added QEMU's "request-ebpf" support. Date: Mon, 29 Jul 2024 23:48:49 +0200 Message-ID: <20240729214853.458886-2-andrew@daynix.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240729214853.458886-1-andrew@daynix.com> References: <20240729214853.458886-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3ONRFU3ULVHVHKX7GL6MGQAAFJM6COLS X-Message-ID-Hash: 3ONRFU3ULVHVHKX7GL6MGQAAFJM6COLS X-MailFrom: andrew@daynix.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: yuri.benditovich@daynix.com, yan@daynix.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1722282641226116600 Content-Type: text/plain; charset="utf-8" Added code for monitor and monitor_json. The "request-ebpf" return's eBPF binary object encoded in base64. QEMU provides eBPF that can be loaded and passed to it from Libvirt. QEMU requires exact eBPF program/maps, so it can be retrieved using QAPI. To load eBPF program - administrative capabilities are required, so Libvirt may load it and pass it to the QEMU instance. For now, there is only "RSS"(Receive Side Scaling) for virtio-net eBPF program and maps. Signed-off-by: Andrew Melnychenko --- src/qemu/qemu_monitor.c | 9 +++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 27 +++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ 4 files changed, 44 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index b1c0c6a064..82729279ff 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4508,3 +4508,12 @@ qemuMonitorDisplayReload(qemuMonitor *mon, =20 return qemuMonitorJSONDisplayReload(mon, type, tlsCerts); } + +const char * +qemuMonitorGetEbpf(qemuMonitor *mon, + const char *ebpfName) +{ + QEMU_CHECK_MONITOR_NULL(mon); + + return qemuMonitorJSONGetEbpf(mon, ebpfName); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 76c859a888..720e9efbb8 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1617,3 +1617,7 @@ int qemuMonitorDisplayReload(qemuMonitor *mon, const char *type, bool tlsCerts); + +const char * +qemuMonitorGetEbpf(qemuMonitor *mon, + const char *ebpfName); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8a20ce57e6..92bc7bd062 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8955,3 +8955,30 @@ int qemuMonitorJSONDisplayReload(qemuMonitor *mon, =20 return 0; } + +const char * +qemuMonitorJSONGetEbpf(qemuMonitor *mon, + const char *ebpfName) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + virJSONValue *ret =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("request-ebpf", "s:id", ebpfN= ame, NULL))) + return NULL; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return NULL; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return NULL; + + ret =3D virJSONValueObjectGet(reply, "return"); + if (!ret) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("request-ebpf reply was missing 'return' data")); + return NULL; + } + + return g_strdup(virJSONValueObjectGetString(ret, "object")); +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 921dd34ed2..161f6b909f 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -825,3 +825,7 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, int qemuMonitorJSONDisplayReload(qemuMonitor *mon, const char *type, bool tlsCerts); + +const char * +qemuMonitorJSONGetEbpf(qemuMonitor *mon, + const char *ebpfName); --=20 2.45.2 From nobody Wed Oct 30 22:11:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1722282786534626.6583544685373; Mon, 29 Jul 2024 12:53:06 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 20D45136A; Mon, 29 Jul 2024 15:53:05 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 09D7711C; Mon, 29 Jul 2024 15:49:51 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 08CAA1231; Mon, 29 Jul 2024 15:49:43 -0400 (EDT) Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id CCB5F1239 for ; Mon, 29 Jul 2024 15:49:40 -0400 (EDT) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5a3b866ebc9so5457394a12.3 for ; Mon, 29 Jul 2024 12:49:40 -0700 (PDT) Received: from localhost.localdomain ([2001:4bb8:181:247f:e288:8f76:5999:3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac6339bcb3sm6121862a12.5.2024.07.29.12.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 12:49:38 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722282579; x=1722887379; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GHe/eNcX20EwoUkEFgRUGTkT7nmlDaTfadzx3bPkehI=; b=BXGacsSYW4dvg0/xt4enfW1g5zplfgQYESsWcQDxWhn8iYwOHf1ooXy2Eu1h8k23BU teSdVrqmxs7n8w0AJrodqZ4KLOpyJslQTDg/WeatkwuEPEXhDS596x33imQTmzKwgsvQ jsBdVAtDCf0UpvGgnJVtzFiPdXGQ4y0zlWK6WEKC19j6iJsV3ThrsehpqmWIOh5W91bD BUPBfrgQ1+IHv6wf86CAzKs22+41IK+xOURnRdoJweucX/z8R5gyrC+G9KS/yLCd7C6h T+NyjZ2xzCcQkJT5WN8TIPrLBKRmTjHnieEL8ja9axPfVjMqJL++z5nU7jqdfWlzAjNT 2wcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722282579; x=1722887379; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GHe/eNcX20EwoUkEFgRUGTkT7nmlDaTfadzx3bPkehI=; b=aZP8N41x7vUyHyBEXsODzO8XLOtuSgEK7vERVNWRdJwMy0mwbvf7IECKjWpaMBIFBS dOfKgMLVoZWqNgIlldcflP7nFwtgYyMnzEU/ygiNagGJ8bZVfHOG/617YTHFOCLpDI5W 2BttsnT8S5GBFKhOqXj4ssHtRlzU0ECFdXaLkJG8r5bdlAiGRcm2ZoHRJQYyViAgCDxm mXB4AJe0GetBrpzKOTDhQEPOSWY3jZh64tJXIqJIXdvzg7uCHrP5ApJGQZ43DsBwVcNI dTxQX0IdLNutlPhViubRlxMvlpS8k4Il80j4BLUcnAmHzaF8WdtKu7Kx1IBK9SmKEFh5 IIcQ== X-Gm-Message-State: AOJu0YyT7lDSlgE3bWmG1sB1kJrRJUxmVFpat3XymIIm7uAk2btZJqRt fOwj36iuLVPf3KiGCfdWGPz1wOqkcDfLqcx9xCu1O7grXZdeOmu0qm4Swa2uS1eFLPjjLDz76lS e X-Google-Smtp-Source: AGHT+IHFsP9r5LvCnqgFJxqH5A1krjgb6FHMD8HF/bUV0NHNTlSXFi3PFj3uT8ZN9BgFlMGAeOSxWQ== X-Received: by 2002:a50:d6d4:0:b0:58b:9561:650b with SMTP id 4fb4d7f45d1cf-5b021d21cd1mr5639943a12.25.1722282578759; Mon, 29 Jul 2024 12:49:38 -0700 (PDT) From: Andrew Melnychenko To: devel@lists.libvirt.org Subject: [RFC PATCH v4 2/5] qemu_capabilities: Added logic for retrieving eBPF objects from QEMU. Date: Mon, 29 Jul 2024 23:48:50 +0200 Message-ID: <20240729214853.458886-3-andrew@daynix.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240729214853.458886-1-andrew@daynix.com> References: <20240729214853.458886-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MHNOP5HK5RXEUXFTSZICZ7I77MNT6DP6 X-Message-ID-Hash: MHNOP5HK5RXEUXFTSZICZ7I77MNT6DP6 X-MailFrom: andrew@daynix.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: yuri.benditovich@daynix.com, yan@daynix.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1722282787932116600 Content-Type: text/plain; charset="utf-8" eBPF objects stored in the hash table during runtime. eBPF objects cached encoded in base64 in the .xml cache file. Signed-off-by: Andrew Melnychenko --- src/qemu/qemu_capabilities.c | 130 ++++++++++++ src/qemu/qemu_capabilities.h | 4 + .../caps_9.0.0_sparc.replies | 95 +++++---- .../qemucapabilitiesdata/caps_9.0.0_sparc.xml | 3 + .../caps_9.0.0_x86_64.replies | 199 ++++++++++-------- .../caps_9.0.0_x86_64.xml | 3 + .../caps_9.1.0_x86_64.replies | 199 ++++++++++-------- .../caps_9.1.0_x86_64.xml | 3 + 8 files changed, 412 insertions(+), 224 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 29dfe8d35a..2d2603e519 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -804,6 +804,9 @@ struct _virQEMUCaps { virQEMUCapsAccel kvm; virQEMUCapsAccel hvf; virQEMUCapsAccel tcg; + + /* Hash of ebpf objects encoded in base64 */ + GHashTable *ebpfObjects; }; =20 static virClass *virQEMUCapsClass; @@ -845,6 +848,14 @@ const char *virQEMUCapsArchToString(virArch arch) } =20 =20 +const char * +virQEMUCapsGetEbpf(virQEMUCaps *qemuCaps, + const char *id) +{ + return virHashLookup(qemuCaps->ebpfObjects, id); +} + + /* Checks whether a domain with @guest arch can run natively on @host. */ bool @@ -1824,6 +1835,8 @@ virQEMUCapsNew(void) qemuCaps->invalidation =3D true; qemuCaps->flags =3D virBitmapNew(QEMU_CAPS_LAST); =20 + qemuCaps->ebpfObjects =3D virHashNew(g_free); + return qemuCaps; } =20 @@ -1966,6 +1979,9 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps) { g_autoptr(virQEMUCaps) ret =3D virQEMUCapsNewBinary(qemuCaps->binary); size_t i; + GHashTableIter iter; + const char *key; + const char *value; =20 ret->invalidation =3D qemuCaps->invalidation; ret->kvmSupportsNesting =3D qemuCaps->kvmSupportsNesting; @@ -2004,6 +2020,12 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCap= s) ret->hypervCapabilities =3D g_memdup(qemuCaps->hypervCapabilities, sizeof(virDomainCapsFeatureHyperv)); =20 + ret->ebpfObjects =3D virHashNew(g_free); + g_hash_table_iter_init(&iter, qemuCaps->ebpfObjects); + while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &= value)) { + g_hash_table_insert(ret->ebpfObjects, g_strdup(key), g_strdup(valu= e)); + } + return g_steal_pointer(&ret); } =20 @@ -2046,6 +2068,8 @@ void virQEMUCapsDispose(void *obj) =20 g_free(qemuCaps->hypervCapabilities); =20 + g_hash_table_destroy(qemuCaps->ebpfObjects); + virQEMUCapsAccelClear(&qemuCaps->kvm); virQEMUCapsAccelClear(&qemuCaps->hvf); virQEMUCapsAccelClear(&qemuCaps->tcg); @@ -4563,6 +4587,41 @@ virQEMUCapsValidateArch(virQEMUCaps *qemuCaps, xmlXP= athContextPtr ctxt) } =20 =20 +static int +virQEMUCapsParseEbpfObjects(virQEMUCaps *qemuCaps, + xmlXPathContextPtr ctxt) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + size_t i; + int n; + + if ((n =3D virXPathNodeSet("./ebpf/object", ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to parse qemu cached eBPF object")); + return -1; + } + + for (i =3D 0; i < n; i++) { + g_autofree char *id =3D NULL; + g_autofree char *ebpf =3D NULL; + + if (!(id =3D virXMLPropStringRequired(nodes[i], "id"))) + return -1; + + if (!(ebpf =3D virXMLPropStringRequired(nodes[i], "data"))) + return -1; + + if (virHashAddEntry(qemuCaps->ebpfObjects, id, ebpf) < 0) + return -1; + + /* steal the ebpf if it was added to the hash without issues */ + g_steal_pointer(&ebpf); + } + + return 0; +} + + /* * Parsing a doc that looks like * @@ -4710,6 +4769,9 @@ virQEMUCapsLoadCache(virArch hostArch, if (skipInvalidation) qemuCaps->invalidation =3D false; =20 + if (virQEMUCapsParseEbpfObjects(qemuCaps, ctxt) < 0) + return -1; + return 0; } =20 @@ -4947,6 +5009,18 @@ virQEMUCapsFormatHypervCapabilities(virQEMUCaps *qem= uCaps, } =20 =20 +static int +virQEMUCapsFormatEbpfObjectsIterator(void *payload, + const char *name, + void *opaque) +{ + virBuffer *buf =3D opaque; + + virBufferAsprintf(buf, "\n", name, (con= st char *)payload); + + return 0; +} + char * virQEMUCapsFormatCache(virQEMUCaps *qemuCaps) { @@ -5037,6 +5111,14 @@ virQEMUCapsFormatCache(virQEMUCaps *qemuCaps) if (qemuCaps->kvmSupportsSecureGuest) virBufferAddLit(&buf, "\n"); =20 + if (virHashSize(qemuCaps->ebpfObjects) > 0) { + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); + virHashForEachSorted(qemuCaps->ebpfObjects, virQEMUCapsFormatEbpfO= bjectsIterator, &buf); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + } + virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); =20 @@ -5453,6 +5535,51 @@ virQEMUCapsInitProcessCaps(virQEMUCaps *qemuCaps) } =20 =20 +static int +virQEMUCapsProbeQMPEbpfObject(virQEMUCaps *qemuCaps, + const char *id, + qemuMonitor *mon) +{ + const char *ebpfObject =3D NULL; + + ebpfObject =3D qemuMonitorGetEbpf(mon, id); + if (ebpfObject =3D=3D NULL) + return -1; + + return virHashAddEntry(qemuCaps->ebpfObjects, id, (void *)ebpfObject); +} + + +static int +virQEMUCapsProbeQMPSchemaEbpf(virQEMUCaps *qemuCaps, + GHashTable *schema, + qemuMonitor *mon) +{ + virJSONValue *ebpfIdsArray; + virJSONValue *ebpfIdsSchema; + size_t i; + + if (virQEMUQAPISchemaPathGet("request-ebpf/arg-type/id", schema, &ebpf= IdsSchema) !=3D 1) + return 0; + + if (!(ebpfIdsArray =3D virJSONValueObjectGetArray(ebpfIdsSchema, "valu= es"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed QMP schema of 'request-ebpf'")); + return -1; + } + + /* Try to request every eBPF */ + for (i =3D 0; i < virJSONValueArraySize(ebpfIdsArray); i++) { + virJSONValue *id =3D virJSONValueArrayGet(ebpfIdsArray, i); + + if (virQEMUCapsProbeQMPEbpfObject(qemuCaps, virJSONValueGetString(= id), mon) < 0) + return -1; + } + + return 0; +} + + static int virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCaps *qemuCaps, qemuMonitor *mon) @@ -5486,6 +5613,9 @@ virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCaps *qe= muCaps, virQEMUQAPISchemaPathExists("block-stream/arg-type/backing-mask-pr= otocol", schema)) virQEMUCapsSet(qemuCaps, QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL); =20 + if (virQEMUCapsProbeQMPSchemaEbpf(qemuCaps, schema, mon) < 0) + return -1; + return 0; } =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 51d951771d..2c53236132 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -917,3 +917,7 @@ int virQEMUCapsProbeQMPMachineTypes(virQEMUCaps *qemuCaps, virDomainVirtType virtType, qemuMonitor *mon); + +const char * +virQEMUCapsGetEbpf(virQEMUCaps *qemuCaps, + const char *id); diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_sparc.replies b/tests/qe= mucapabilitiesdata/caps_9.0.0_sparc.replies index 9ddfcfae21..e1f46336c9 100644 --- a/tests/qemucapabilitiesdata/caps_9.0.0_sparc.replies +++ b/tests/qemucapabilitiesdata/caps_9.0.0_sparc.replies @@ -23356,21 +23356,36 @@ } =20 { - "execute": "query-kvm", + "execute": "request-ebpf", + "arguments": { + "id": "rss" + }, "id": "libvirt-5" } =20 +{ + "return": { + "object": "Test data" + }, + "id": "libvirt-5" +} + +{ + "execute": "query-kvm", + "id": "libvirt-6" +} + { "return": { "enabled": false, "present": false }, - "id": "libvirt-5" + "id": "libvirt-6" } =20 { "execute": "qom-list-types", - "id": "libvirt-6" + "id": "libvirt-7" } =20 { @@ -23976,7 +23991,7 @@ "parent": "base-sysbus-fdc" } ], - "id": "libvirt-6" + "id": "libvirt-7" } =20 { @@ -23984,11 +23999,11 @@ "arguments": { "typename": "virtio-blk-pci" }, - "id": "libvirt-7" + "id": "libvirt-8" } =20 { - "id": "libvirt-7", + "id": "libvirt-8", "error": { "class": "DeviceNotFound", "desc": "Device 'virtio-blk-pci' not found" @@ -24000,7 +24015,7 @@ "arguments": { "typename": "scsi-hd" }, - "id": "libvirt-8" + "id": "libvirt-9" } =20 { @@ -24201,7 +24216,7 @@ "type": "int32" } ], - "id": "libvirt-8" + "id": "libvirt-9" } =20 { @@ -24209,11 +24224,11 @@ "arguments": { "typename": "ide-hd" }, - "id": "libvirt-9" + "id": "libvirt-10" } =20 { - "id": "libvirt-9", + "id": "libvirt-10", "error": { "class": "DeviceNotFound", "desc": "Device 'ide-hd' not found" @@ -24225,11 +24240,11 @@ "arguments": { "typename": "PIIX4_PM" }, - "id": "libvirt-10" + "id": "libvirt-11" } =20 { - "id": "libvirt-10", + "id": "libvirt-11", "error": { "class": "DeviceNotFound", "desc": "Device 'PIIX4_PM' not found" @@ -24241,11 +24256,11 @@ "arguments": { "typename": "kvm-pit" }, - "id": "libvirt-11" + "id": "libvirt-12" } =20 { - "id": "libvirt-11", + "id": "libvirt-12", "error": { "class": "DeviceNotFound", "desc": "Device 'kvm-pit' not found" @@ -24257,11 +24272,11 @@ "arguments": { "typename": "ICH9-LPC" }, - "id": "libvirt-12" + "id": "libvirt-13" } =20 { - "id": "libvirt-12", + "id": "libvirt-13", "error": { "class": "DeviceNotFound", "desc": "Device 'ICH9-LPC' not found" @@ -24273,11 +24288,11 @@ "arguments": { "typename": "virtio-balloon-pci" }, - "id": "libvirt-13" + "id": "libvirt-14" } =20 { - "id": "libvirt-13", + "id": "libvirt-14", "error": { "class": "DeviceNotFound", "desc": "Device 'virtio-balloon-pci' not found" @@ -24289,11 +24304,11 @@ "arguments": { "typename": "virtio-balloon-ccw" }, - "id": "libvirt-14" + "id": "libvirt-15" } =20 { - "id": "libvirt-14", + "id": "libvirt-15", "error": { "class": "DeviceNotFound", "desc": "Device 'virtio-balloon-ccw' not found" @@ -24305,11 +24320,11 @@ "arguments": { "typename": "virtio-balloon-device" }, - "id": "libvirt-15" + "id": "libvirt-16" } =20 { - "id": "libvirt-15", + "id": "libvirt-16", "error": { "class": "DeviceNotFound", "desc": "Device 'virtio-balloon-device' not found" @@ -24321,11 +24336,11 @@ "arguments": { "typename": "usb-host" }, - "id": "libvirt-16" + "id": "libvirt-17" } =20 { - "id": "libvirt-16", + "id": "libvirt-17", "error": { "class": "DeviceNotFound", "desc": "Device 'usb-host' not found" @@ -24337,7 +24352,7 @@ "arguments": { "typename": "memory-backend-file" }, - "id": "libvirt-17" + "id": "libvirt-18" } =20 { @@ -24431,7 +24446,7 @@ "type": "bool" } ], - "id": "libvirt-17" + "id": "libvirt-18" } =20 { @@ -24439,7 +24454,7 @@ "arguments": { "typename": "memory-backend-memfd" }, - "id": "libvirt-18" + "id": "libvirt-19" } =20 { @@ -24518,12 +24533,12 @@ "type": "int" } ], - "id": "libvirt-18" + "id": "libvirt-19" } =20 { "execute": "query-machines", - "id": "libvirt-19" + "id": "libvirt-20" } =20 { @@ -24639,7 +24654,7 @@ "default-ram-id": "ram" } ], - "id": "libvirt-19" + "id": "libvirt-20" } =20 { @@ -24647,7 +24662,7 @@ "arguments": { "typename": "none-machine" }, - "id": "libvirt-20" + "id": "libvirt-21" } =20 { @@ -24760,32 +24775,32 @@ "type": "child" } ], - "id": "libvirt-20" + "id": "libvirt-21" } =20 { "execute": "query-tpm-models", - "id": "libvirt-21" + "id": "libvirt-22" } =20 { "return": [], - "id": "libvirt-21" + "id": "libvirt-22" } =20 { "execute": "query-tpm-types", - "id": "libvirt-22" + "id": "libvirt-23" } =20 { "return": [], - "id": "libvirt-22" + "id": "libvirt-23" } =20 { "execute": "query-command-line-options", - "id": "libvirt-23" + "id": "libvirt-24" } =20 { @@ -26118,12 +26133,12 @@ "option": "drive" } ], - "id": "libvirt-23" + "id": "libvirt-24" } =20 { "execute": "query-migrate-capabilities", - "id": "libvirt-24" + "id": "libvirt-25" } =20 { @@ -26225,5 +26240,5 @@ "capability": "mapped-ram" } ], - "id": "libvirt-24" + "id": "libvirt-25" } diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_sparc.xml b/tests/qemuca= pabilitiesdata/caps_9.0.0_sparc.xml index 7fe971fc3a..3fbc83124a 100644 --- a/tests/qemucapabilitiesdata/caps_9.0.0_sparc.xml +++ b/tests/qemucapabilitiesdata/caps_9.0.0_sparc.xml @@ -93,4 +93,7 @@ + + + diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies b/tests/q= emucapabilitiesdata/caps_9.0.0_x86_64.replies index 5d36853ce3..b94625904b 100644 --- a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies +++ b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies @@ -23654,21 +23654,36 @@ } =20 { - "execute": "query-kvm", + "execute": "request-ebpf", + "arguments": { + "id": "rss" + }, + "id": "libvirt-5" +} + +{ + "return": { + "object": "Test data" + }, "id": "libvirt-5" } =20 +{ + "execute": "query-kvm", + "id": "libvirt-6" +} + { "return": { "enabled": true, "present": true }, - "id": "libvirt-5" + "id": "libvirt-6" } =20 { "execute": "qom-list-types", - "id": "libvirt-6" + "id": "libvirt-7" } =20 { @@ -26378,7 +26393,7 @@ "parent": "x86_64-cpu" } ], - "id": "libvirt-6" + "id": "libvirt-7" } =20 { @@ -26386,7 +26401,7 @@ "arguments": { "typename": "virtio-blk-pci" }, - "id": "libvirt-7" + "id": "libvirt-8" } =20 { @@ -26801,7 +26816,7 @@ "type": "bool" } ], - "id": "libvirt-7" + "id": "libvirt-8" } =20 { @@ -26809,7 +26824,7 @@ "arguments": { "typename": "virtio-net-pci" }, - "id": "libvirt-8" + "id": "libvirt-9" } =20 { @@ -27268,7 +27283,7 @@ "type": "bool" } ], - "id": "libvirt-8" + "id": "libvirt-9" } =20 { @@ -27276,7 +27291,7 @@ "arguments": { "typename": "virtio-scsi-pci" }, - "id": "libvirt-9" + "id": "libvirt-10" } =20 { @@ -27542,7 +27557,7 @@ "type": "child" } ], - "id": "libvirt-9" + "id": "libvirt-10" } =20 { @@ -27550,11 +27565,11 @@ "arguments": { "typename": "virtio-net-ccw" }, - "id": "libvirt-10" + "id": "libvirt-11" } =20 { - "id": "libvirt-10", + "id": "libvirt-11", "error": { "class": "DeviceNotFound", "desc": "Device 'virtio-net-ccw' not found" @@ -27566,11 +27581,11 @@ "arguments": { "typename": "virtio-scsi-ccw" }, - "id": "libvirt-11" + "id": "libvirt-12" } =20 { - "id": "libvirt-11", + "id": "libvirt-12", "error": { "class": "DeviceNotFound", "desc": "Device 'virtio-scsi-ccw' not found" @@ -27582,7 +27597,7 @@ "arguments": { "typename": "vfio-pci" }, - "id": "libvirt-12" + "id": "libvirt-13" } =20 { @@ -27800,7 +27815,7 @@ "type": "int32" } ], - "id": "libvirt-12" + "id": "libvirt-13" } =20 { @@ -27808,7 +27823,7 @@ "arguments": { "typename": "scsi-hd" }, - "id": "libvirt-13" + "id": "libvirt-14" } =20 { @@ -28009,7 +28024,7 @@ "type": "int32" } ], - "id": "libvirt-13" + "id": "libvirt-14" } =20 { @@ -28017,7 +28032,7 @@ "arguments": { "typename": "ide-hd" }, - "id": "libvirt-14" + "id": "libvirt-15" } =20 { @@ -28168,7 +28183,7 @@ "type": "int32" } ], - "id": "libvirt-14" + "id": "libvirt-15" } =20 { @@ -28176,7 +28191,7 @@ "arguments": { "typename": "PIIX4_PM" }, - "id": "libvirt-15" + "id": "libvirt-16" } =20 { @@ -28299,7 +28314,7 @@ "type": "link" } ], - "id": "libvirt-15" + "id": "libvirt-16" } =20 { @@ -28307,7 +28322,7 @@ "arguments": { "typename": "usb-redir" }, - "id": "libvirt-16" + "id": "libvirt-17" } =20 { @@ -28363,7 +28378,7 @@ "type": "bool" } ], - "id": "libvirt-16" + "id": "libvirt-17" } =20 { @@ -28371,7 +28386,7 @@ "arguments": { "typename": "usb-storage" }, - "id": "libvirt-17" + "id": "libvirt-18" } =20 { @@ -28486,7 +28501,7 @@ "type": "bool" } ], - "id": "libvirt-17" + "id": "libvirt-18" } =20 { @@ -28494,7 +28509,7 @@ "arguments": { "typename": "kvm-pit" }, - "id": "libvirt-18" + "id": "libvirt-19" } =20 { @@ -28510,7 +28525,7 @@ "type": "LostTickPolicy" } ], - "id": "libvirt-18" + "id": "libvirt-19" } =20 { @@ -28518,7 +28533,7 @@ "arguments": { "typename": "VGA" }, - "id": "libvirt-19" + "id": "libvirt-20" } =20 { @@ -28640,7 +28655,7 @@ "type": "uint32" } ], - "id": "libvirt-19" + "id": "libvirt-20" } =20 { @@ -28648,7 +28663,7 @@ "arguments": { "typename": "vmware-svga" }, - "id": "libvirt-20" + "id": "libvirt-21" } =20 { @@ -28723,7 +28738,7 @@ "type": "uint32" } ], - "id": "libvirt-20" + "id": "libvirt-21" } =20 { @@ -28731,7 +28746,7 @@ "arguments": { "typename": "qxl" }, - "id": "libvirt-21" + "id": "libvirt-22" } =20 { @@ -28871,7 +28886,7 @@ "type": "int32" } ], - "id": "libvirt-21" + "id": "libvirt-22" } =20 { @@ -28879,7 +28894,7 @@ "arguments": { "typename": "virtio-gpu-pci" }, - "id": "libvirt-22" + "id": "libvirt-23" } =20 { @@ -29141,7 +29156,7 @@ "type": "child" } ], - "id": "libvirt-22" + "id": "libvirt-23" } =20 { @@ -29149,7 +29164,7 @@ "arguments": { "typename": "virtio-gpu-device" }, - "id": "libvirt-23" + "id": "libvirt-24" } =20 { @@ -29249,7 +29264,7 @@ "type": "size" } ], - "id": "libvirt-23" + "id": "libvirt-24" } =20 { @@ -29257,7 +29272,7 @@ "arguments": { "typename": "ICH9-LPC" }, - "id": "libvirt-24" + "id": "libvirt-25" } =20 { @@ -29515,7 +29530,7 @@ "type": "link" } ], - "id": "libvirt-24" + "id": "libvirt-25" } =20 { @@ -29523,7 +29538,7 @@ "arguments": { "typename": "virtio-balloon-pci" }, - "id": "libvirt-25" + "id": "libvirt-26" } =20 { @@ -29778,7 +29793,7 @@ "type": "child" } ], - "id": "libvirt-25" + "id": "libvirt-26" } =20 { @@ -29786,11 +29801,11 @@ "arguments": { "typename": "virtio-balloon-ccw" }, - "id": "libvirt-26" + "id": "libvirt-27" } =20 { - "id": "libvirt-26", + "id": "libvirt-27", "error": { "class": "DeviceNotFound", "desc": "Device 'virtio-balloon-ccw' not found" @@ -29802,7 +29817,7 @@ "arguments": { "typename": "virtio-balloon-device" }, - "id": "libvirt-27" + "id": "libvirt-28" } =20 { @@ -29906,7 +29921,7 @@ "type": "guest statistics" } ], - "id": "libvirt-27" + "id": "libvirt-28" } =20 { @@ -29914,7 +29929,7 @@ "arguments": { "typename": "intel-iommu" }, - "id": "libvirt-28" + "id": "libvirt-29" } =20 { @@ -29987,7 +30002,7 @@ "type": "bool" } ], - "id": "libvirt-28" + "id": "libvirt-29" } =20 { @@ -29995,7 +30010,7 @@ "arguments": { "typename": "mch" }, - "id": "libvirt-29" + "id": "libvirt-30" } =20 { @@ -30070,7 +30085,7 @@ "type": "uint16" } ], - "id": "libvirt-29" + "id": "libvirt-30" } =20 { @@ -30078,7 +30093,7 @@ "arguments": { "typename": "nvdimm" }, - "id": "libvirt-30" + "id": "libvirt-31" } =20 { @@ -30120,7 +30135,7 @@ "type": "uint64" } ], - "id": "libvirt-30" + "id": "libvirt-31" } =20 { @@ -30128,7 +30143,7 @@ "arguments": { "typename": "pcie-root-port" }, - "id": "libvirt-31" + "id": "libvirt-32" } =20 { @@ -30281,7 +30296,7 @@ "type": "size" } ], - "id": "libvirt-31" + "id": "libvirt-32" } =20 { @@ -30289,7 +30304,7 @@ "arguments": { "typename": "usb-host" }, - "id": "libvirt-32" + "id": "libvirt-33" } =20 { @@ -30385,7 +30400,7 @@ "type": "bool" } ], - "id": "libvirt-32" + "id": "libvirt-33" } =20 { @@ -30393,7 +30408,7 @@ "arguments": { "typename": "vhost-user-fs-device" }, - "id": "libvirt-33" + "id": "libvirt-34" } =20 { @@ -30479,7 +30494,7 @@ "type": "int32" } ], - "id": "libvirt-33" + "id": "libvirt-34" } =20 { @@ -30487,7 +30502,7 @@ "arguments": { "typename": "virtio-mem-pci" }, - "id": "libvirt-34" + "id": "libvirt-35" } =20 { @@ -30748,7 +30763,7 @@ "type": "child" } ], - "id": "libvirt-34" + "id": "libvirt-35" } =20 { @@ -30756,7 +30771,7 @@ "arguments": { "typename": "virtio-iommu-pci" }, - "id": "libvirt-35" + "id": "libvirt-36" } =20 { @@ -31000,7 +31015,7 @@ "type": "child" } ], - "id": "libvirt-35" + "id": "libvirt-36" } =20 { @@ -31008,7 +31023,7 @@ "arguments": { "typename": "memory-backend-file" }, - "id": "libvirt-36" + "id": "libvirt-37" } =20 { @@ -31102,7 +31117,7 @@ "type": "bool" } ], - "id": "libvirt-36" + "id": "libvirt-37" } =20 { @@ -31110,7 +31125,7 @@ "arguments": { "typename": "memory-backend-memfd" }, - "id": "libvirt-37" + "id": "libvirt-38" } =20 { @@ -31189,7 +31204,7 @@ "type": "int" } ], - "id": "libvirt-37" + "id": "libvirt-38" } =20 { @@ -31197,7 +31212,7 @@ "arguments": { "typename": "max-x86_64-cpu" }, - "id": "libvirt-38" + "id": "libvirt-39" } =20 { @@ -33114,12 +33129,12 @@ "type": "bool" } ], - "id": "libvirt-38" + "id": "libvirt-39" } =20 { "execute": "query-machines", - "id": "libvirt-39" + "id": "libvirt-40" } =20 { @@ -33755,7 +33770,7 @@ "default-ram-id": "pc.ram" } ], - "id": "libvirt-39" + "id": "libvirt-40" } =20 { @@ -33763,7 +33778,7 @@ "arguments": { "typename": "none-machine" }, - "id": "libvirt-40" + "id": "libvirt-41" } =20 { @@ -33876,12 +33891,12 @@ "type": "child" } ], - "id": "libvirt-40" + "id": "libvirt-41" } =20 { "execute": "query-cpu-definitions", - "id": "libvirt-41" + "id": "libvirt-42" } =20 { @@ -36263,12 +36278,12 @@ "deprecated": false } ], - "id": "libvirt-41" + "id": "libvirt-42" } =20 { "execute": "query-tpm-models", - "id": "libvirt-42" + "id": "libvirt-43" } =20 { @@ -36276,12 +36291,12 @@ "tpm-crb", "tpm-tis" ], - "id": "libvirt-42" + "id": "libvirt-43" } =20 { "execute": "query-tpm-types", - "id": "libvirt-43" + "id": "libvirt-44" } =20 { @@ -36289,12 +36304,12 @@ "passthrough", "emulator" ], - "id": "libvirt-43" + "id": "libvirt-44" } =20 { "execute": "query-command-line-options", - "id": "libvirt-44" + "id": "libvirt-45" } =20 { @@ -37769,12 +37784,12 @@ "option": "drive" } ], - "id": "libvirt-44" + "id": "libvirt-45" } =20 { "execute": "query-migrate-capabilities", - "id": "libvirt-45" + "id": "libvirt-46" } =20 { @@ -37876,16 +37891,16 @@ "capability": "mapped-ram" } ], - "id": "libvirt-45" + "id": "libvirt-46" } =20 { "execute": "query-sev-capabilities", - "id": "libvirt-46" + "id": "libvirt-47" } =20 { - "id": "libvirt-46", + "id": "libvirt-47", "error": { "class": "GenericError", "desc": "SEV: Failed to open /dev/sev: No such file or directory" @@ -37894,11 +37909,11 @@ =20 { "execute": "query-sgx-capabilities", - "id": "libvirt-47" + "id": "libvirt-48" } =20 { - "id": "libvirt-47", + "id": "libvirt-48", "error": { "class": "GenericError", "desc": "SGX is not enabled in KVM" @@ -37913,7 +37928,7 @@ "name": "host" } }, - "id": "libvirt-48" + "id": "libvirt-49" } =20 { @@ -38281,7 +38296,7 @@ } } }, - "id": "libvirt-48" + "id": "libvirt-49" } =20 { @@ -38295,7 +38310,7 @@ } } }, - "id": "libvirt-49" + "id": "libvirt-50" } =20 { @@ -38663,7 +38678,7 @@ } } }, - "id": "libvirt-49" + "id": "libvirt-50" } =20 { @@ -38678,7 +38693,7 @@ } } }, - "id": "libvirt-50" + "id": "libvirt-51" } =20 { @@ -39152,7 +39167,7 @@ } } }, - "id": "libvirt-50" + "id": "libvirt-51" } =20 { diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml b/tests/qemuc= apabilitiesdata/caps_9.0.0_x86_64.xml index b646377dec..dbe015d287 100644 --- a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml @@ -3693,4 +3693,7 @@ + + + diff --git a/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.replies b/tests/q= emucapabilitiesdata/caps_9.1.0_x86_64.replies index 96a8a8ed2b..019e2f26d9 100644 --- a/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.replies +++ b/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.replies @@ -23660,21 +23660,36 @@ } =20 { - "execute": "query-kvm", + "execute": "request-ebpf", + "arguments": { + "id": "rss" + }, + "id": "libvirt-5" +} + +{ + "return": { + "object": "Test data" + }, "id": "libvirt-5" } =20 +{ + "execute": "query-kvm", + "id": "libvirt-6" +} + { "return": { "enabled": true, "present": true }, - "id": "libvirt-5" + "id": "libvirt-6" } =20 { "execute": "qom-list-types", - "id": "libvirt-6" + "id": "libvirt-7" } =20 { @@ -26404,7 +26419,7 @@ "parent": "x86_64-cpu" } ], - "id": "libvirt-6" + "id": "libvirt-7" } =20 { @@ -26412,7 +26427,7 @@ "arguments": { "typename": "virtio-blk-pci" }, - "id": "libvirt-7" + "id": "libvirt-8" } =20 { @@ -26821,7 +26836,7 @@ "type": "bool" } ], - "id": "libvirt-7" + "id": "libvirt-8" } =20 { @@ -26829,7 +26844,7 @@ "arguments": { "typename": "virtio-net-pci" }, - "id": "libvirt-8" + "id": "libvirt-9" } =20 { @@ -27288,7 +27303,7 @@ "type": "bool" } ], - "id": "libvirt-8" + "id": "libvirt-9" } =20 { @@ -27296,7 +27311,7 @@ "arguments": { "typename": "virtio-scsi-pci" }, - "id": "libvirt-9" + "id": "libvirt-10" } =20 { @@ -27562,7 +27577,7 @@ "type": "child" } ], - "id": "libvirt-9" + "id": "libvirt-10" } =20 { @@ -27570,11 +27585,11 @@ "arguments": { "typename": "virtio-net-ccw" }, - "id": "libvirt-10" + "id": "libvirt-11" } =20 { - "id": "libvirt-10", + "id": "libvirt-11", "error": { "class": "DeviceNotFound", "desc": "Device 'virtio-net-ccw' not found" @@ -27586,11 +27601,11 @@ "arguments": { "typename": "virtio-scsi-ccw" }, - "id": "libvirt-11" + "id": "libvirt-12" } =20 { - "id": "libvirt-11", + "id": "libvirt-12", "error": { "class": "DeviceNotFound", "desc": "Device 'virtio-scsi-ccw' not found" @@ -27602,7 +27617,7 @@ "arguments": { "typename": "vfio-pci" }, - "id": "libvirt-12" + "id": "libvirt-13" } =20 { @@ -27830,7 +27845,7 @@ "type": "int32" } ], - "id": "libvirt-12" + "id": "libvirt-13" } =20 { @@ -27838,7 +27853,7 @@ "arguments": { "typename": "scsi-hd" }, - "id": "libvirt-13" + "id": "libvirt-14" } =20 { @@ -28039,7 +28054,7 @@ "type": "int32" } ], - "id": "libvirt-13" + "id": "libvirt-14" } =20 { @@ -28047,7 +28062,7 @@ "arguments": { "typename": "ide-hd" }, - "id": "libvirt-14" + "id": "libvirt-15" } =20 { @@ -28198,7 +28213,7 @@ "type": "int32" } ], - "id": "libvirt-14" + "id": "libvirt-15" } =20 { @@ -28206,7 +28221,7 @@ "arguments": { "typename": "PIIX4_PM" }, - "id": "libvirt-15" + "id": "libvirt-16" } =20 { @@ -28329,7 +28344,7 @@ "type": "link" } ], - "id": "libvirt-15" + "id": "libvirt-16" } =20 { @@ -28337,7 +28352,7 @@ "arguments": { "typename": "usb-redir" }, - "id": "libvirt-16" + "id": "libvirt-17" } =20 { @@ -28393,7 +28408,7 @@ "type": "bool" } ], - "id": "libvirt-16" + "id": "libvirt-17" } =20 { @@ -28401,7 +28416,7 @@ "arguments": { "typename": "usb-storage" }, - "id": "libvirt-17" + "id": "libvirt-18" } =20 { @@ -28516,7 +28531,7 @@ "type": "bool" } ], - "id": "libvirt-17" + "id": "libvirt-18" } =20 { @@ -28524,7 +28539,7 @@ "arguments": { "typename": "kvm-pit" }, - "id": "libvirt-18" + "id": "libvirt-19" } =20 { @@ -28540,7 +28555,7 @@ "type": "LostTickPolicy" } ], - "id": "libvirt-18" + "id": "libvirt-19" } =20 { @@ -28548,7 +28563,7 @@ "arguments": { "typename": "VGA" }, - "id": "libvirt-19" + "id": "libvirt-20" } =20 { @@ -28670,7 +28685,7 @@ "type": "uint32" } ], - "id": "libvirt-19" + "id": "libvirt-20" } =20 { @@ -28678,7 +28693,7 @@ "arguments": { "typename": "vmware-svga" }, - "id": "libvirt-20" + "id": "libvirt-21" } =20 { @@ -28753,7 +28768,7 @@ "type": "uint32" } ], - "id": "libvirt-20" + "id": "libvirt-21" } =20 { @@ -28761,7 +28776,7 @@ "arguments": { "typename": "qxl" }, - "id": "libvirt-21" + "id": "libvirt-22" } =20 { @@ -28901,7 +28916,7 @@ "type": "int32" } ], - "id": "libvirt-21" + "id": "libvirt-22" } =20 { @@ -28909,7 +28924,7 @@ "arguments": { "typename": "virtio-gpu-pci" }, - "id": "libvirt-22" + "id": "libvirt-23" } =20 { @@ -29176,7 +29191,7 @@ "type": "child" } ], - "id": "libvirt-22" + "id": "libvirt-23" } =20 { @@ -29184,7 +29199,7 @@ "arguments": { "typename": "virtio-gpu-device" }, - "id": "libvirt-23" + "id": "libvirt-24" } =20 { @@ -29289,7 +29304,7 @@ "type": "size" } ], - "id": "libvirt-23" + "id": "libvirt-24" } =20 { @@ -29297,7 +29312,7 @@ "arguments": { "typename": "ICH9-LPC" }, - "id": "libvirt-24" + "id": "libvirt-25" } =20 { @@ -29555,7 +29570,7 @@ "type": "link" } ], - "id": "libvirt-24" + "id": "libvirt-25" } =20 { @@ -29563,7 +29578,7 @@ "arguments": { "typename": "virtio-balloon-pci" }, - "id": "libvirt-25" + "id": "libvirt-26" } =20 { @@ -29818,7 +29833,7 @@ "type": "child" } ], - "id": "libvirt-25" + "id": "libvirt-26" } =20 { @@ -29826,11 +29841,11 @@ "arguments": { "typename": "virtio-balloon-ccw" }, - "id": "libvirt-26" + "id": "libvirt-27" } =20 { - "id": "libvirt-26", + "id": "libvirt-27", "error": { "class": "DeviceNotFound", "desc": "Device 'virtio-balloon-ccw' not found" @@ -29842,7 +29857,7 @@ "arguments": { "typename": "virtio-balloon-device" }, - "id": "libvirt-27" + "id": "libvirt-28" } =20 { @@ -29946,7 +29961,7 @@ "type": "guest statistics" } ], - "id": "libvirt-27" + "id": "libvirt-28" } =20 { @@ -29954,7 +29969,7 @@ "arguments": { "typename": "intel-iommu" }, - "id": "libvirt-28" + "id": "libvirt-29" } =20 { @@ -30027,7 +30042,7 @@ "type": "bool" } ], - "id": "libvirt-28" + "id": "libvirt-29" } =20 { @@ -30035,7 +30050,7 @@ "arguments": { "typename": "mch" }, - "id": "libvirt-29" + "id": "libvirt-30" } =20 { @@ -30110,7 +30125,7 @@ "type": "uint16" } ], - "id": "libvirt-29" + "id": "libvirt-30" } =20 { @@ -30118,7 +30133,7 @@ "arguments": { "typename": "nvdimm" }, - "id": "libvirt-30" + "id": "libvirt-31" } =20 { @@ -30160,7 +30175,7 @@ "type": "uint64" } ], - "id": "libvirt-30" + "id": "libvirt-31" } =20 { @@ -30168,7 +30183,7 @@ "arguments": { "typename": "pcie-root-port" }, - "id": "libvirt-31" + "id": "libvirt-32" } =20 { @@ -30321,7 +30336,7 @@ "type": "size" } ], - "id": "libvirt-31" + "id": "libvirt-32" } =20 { @@ -30329,7 +30344,7 @@ "arguments": { "typename": "usb-host" }, - "id": "libvirt-32" + "id": "libvirt-33" } =20 { @@ -30425,7 +30440,7 @@ "type": "bool" } ], - "id": "libvirt-32" + "id": "libvirt-33" } =20 { @@ -30433,7 +30448,7 @@ "arguments": { "typename": "vhost-user-fs-device" }, - "id": "libvirt-33" + "id": "libvirt-34" } =20 { @@ -30519,7 +30534,7 @@ "type": "int32" } ], - "id": "libvirt-33" + "id": "libvirt-34" } =20 { @@ -30527,7 +30542,7 @@ "arguments": { "typename": "virtio-mem-pci" }, - "id": "libvirt-34" + "id": "libvirt-35" } =20 { @@ -30788,7 +30803,7 @@ "type": "child" } ], - "id": "libvirt-34" + "id": "libvirt-35" } =20 { @@ -30796,7 +30811,7 @@ "arguments": { "typename": "virtio-iommu-pci" }, - "id": "libvirt-35" + "id": "libvirt-36" } =20 { @@ -31040,7 +31055,7 @@ "type": "child" } ], - "id": "libvirt-35" + "id": "libvirt-36" } =20 { @@ -31048,7 +31063,7 @@ "arguments": { "typename": "memory-backend-file" }, - "id": "libvirt-36" + "id": "libvirt-37" } =20 { @@ -31142,7 +31157,7 @@ "type": "bool" } ], - "id": "libvirt-36" + "id": "libvirt-37" } =20 { @@ -31150,7 +31165,7 @@ "arguments": { "typename": "memory-backend-memfd" }, - "id": "libvirt-37" + "id": "libvirt-38" } =20 { @@ -31229,7 +31244,7 @@ "type": "int" } ], - "id": "libvirt-37" + "id": "libvirt-38" } =20 { @@ -31237,7 +31252,7 @@ "arguments": { "typename": "max-x86_64-cpu" }, - "id": "libvirt-38" + "id": "libvirt-39" } =20 { @@ -33282,12 +33297,12 @@ "type": "bool" } ], - "id": "libvirt-38" + "id": "libvirt-39" } =20 { "execute": "query-machines", - "id": "libvirt-39" + "id": "libvirt-40" } =20 { @@ -33943,7 +33958,7 @@ "default-ram-id": "pc.ram" } ], - "id": "libvirt-39" + "id": "libvirt-40" } =20 { @@ -33951,7 +33966,7 @@ "arguments": { "typename": "none-machine" }, - "id": "libvirt-40" + "id": "libvirt-41" } =20 { @@ -34064,12 +34079,12 @@ "type": "child" } ], - "id": "libvirt-40" + "id": "libvirt-41" } =20 { "execute": "query-cpu-definitions", - "id": "libvirt-41" + "id": "libvirt-42" } =20 { @@ -36620,12 +36635,12 @@ "deprecated": false } ], - "id": "libvirt-41" + "id": "libvirt-42" } =20 { "execute": "query-tpm-models", - "id": "libvirt-42" + "id": "libvirt-43" } =20 { @@ -36633,12 +36648,12 @@ "tpm-crb", "tpm-tis" ], - "id": "libvirt-42" + "id": "libvirt-43" } =20 { "execute": "query-tpm-types", - "id": "libvirt-43" + "id": "libvirt-44" } =20 { @@ -36646,12 +36661,12 @@ "passthrough", "emulator" ], - "id": "libvirt-43" + "id": "libvirt-44" } =20 { "execute": "query-command-line-options", - "id": "libvirt-44" + "id": "libvirt-45" } =20 { @@ -38134,12 +38149,12 @@ "option": "drive" } ], - "id": "libvirt-44" + "id": "libvirt-45" } =20 { "execute": "query-migrate-capabilities", - "id": "libvirt-45" + "id": "libvirt-46" } =20 { @@ -38233,16 +38248,16 @@ "capability": "mapped-ram" } ], - "id": "libvirt-45" + "id": "libvirt-46" } =20 { "execute": "query-sev-capabilities", - "id": "libvirt-46" + "id": "libvirt-47" } =20 { - "id": "libvirt-46", + "id": "libvirt-47", "error": { "class": "GenericError", "desc": "SEV is not configured" @@ -38251,11 +38266,11 @@ =20 { "execute": "query-sgx-capabilities", - "id": "libvirt-47" + "id": "libvirt-48" } =20 { - "id": "libvirt-47", + "id": "libvirt-48", "error": { "class": "GenericError", "desc": "SGX is not enabled in KVM" @@ -38270,7 +38285,7 @@ "name": "host" } }, - "id": "libvirt-48" + "id": "libvirt-49" } =20 { @@ -38647,7 +38662,7 @@ } } }, - "id": "libvirt-48" + "id": "libvirt-49" } =20 { @@ -38661,7 +38676,7 @@ } } }, - "id": "libvirt-49" + "id": "libvirt-50" } =20 { @@ -39038,7 +39053,7 @@ } } }, - "id": "libvirt-49" + "id": "libvirt-50" } =20 { @@ -39053,7 +39068,7 @@ } } }, - "id": "libvirt-50" + "id": "libvirt-51" } =20 { @@ -39540,7 +39555,7 @@ } } }, - "id": "libvirt-50" + "id": "libvirt-51" } =20 { diff --git a/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml b/tests/qemuc= apabilitiesdata/caps_9.1.0_x86_64.xml index dc548583a5..b0c16a0440 100644 --- a/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml @@ -3955,4 +3955,7 @@ + + + --=20 2.45.2 From nobody Wed Oct 30 22:11:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1722282666977713.7516717741543; Mon, 29 Jul 2024 12:51:06 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B1ACC12B5; Mon, 29 Jul 2024 15:51:05 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0640B1373; Mon, 29 Jul 2024 15:49:47 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C97D6127F; Mon, 29 Jul 2024 15:49:41 -0400 (EDT) Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 049E81258 for ; Mon, 29 Jul 2024 15:49:41 -0400 (EDT) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5af6a1afa7bso3526381a12.1 for ; Mon, 29 Jul 2024 12:49:40 -0700 (PDT) Received: from localhost.localdomain ([2001:4bb8:181:247f:e288:8f76:5999:3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac6339bcb3sm6121862a12.5.2024.07.29.12.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 12:49:39 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722282580; x=1722887380; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s9oW95deZF+cVr/3fRi3p0VyrjEGRlnCPLHovdQXKS0=; b=zYYWYfPW+mkQC52VO56oBhAufrS07BoLNz6nIv6hCrzrr3wQB3wIO20GPf5eO15Xds S+Q2EmmFnikv2qge02VLPYMWAaPb9dEkvzo33ehdvMGMPvDy0tQgTScMIKQhpaFBn1LZ sXhG/jCZsc6pAeX+JAt3KkeVy3gIugCHsBH1a8Etd5WN15hVZJlNVldG9wMyYjtzzXKX 6/IOQ0dk509X18DvtYM9Q1WuefFx3AwWHj+saqmV0N9Et9wRC2fCXKxcCUZ2HSmsiF3R 0iVrUIkVV5Mwgf0Jwff+NQssI+Ibeq5rvTg7VmxodY9NK5LbLN61d3FyshsB/08aZ4a3 OQkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722282580; x=1722887380; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s9oW95deZF+cVr/3fRi3p0VyrjEGRlnCPLHovdQXKS0=; b=e48JCk/wUz16QIucgNFbENN3rvkKjRqPKkG4zK+36WLuPwEFrUpVRoaC1SvpUaGP2s ZaNF4KkBN2Zqr8cLG6M3Y3xK1OeYNcR+jIhDrVTjbI+tXsjqWFGwQtA2psz+nMN6kHrd WspfZr1tMkYwDyrdN3siEX9oD/TYPGC4c2mNipNxtovW8rGYDVw41gSYpcUwpVzqS1Te Dp/htDzuafS0nZyHIMhKYOHeV65WvZEwRYXx13e+KyZS55SpdlfGyKSpXh5XyDabuJBc GxN8wbdiVoi45mZ5Dew5bqF21IJD7QRu3PIXi9HWQABVqnQ5GilvcMHAzZcciT9Nd+wN 2DTA== X-Gm-Message-State: AOJu0YxZGMaA4J9M31GucIFZPgIWGGoSyg9+dV6cuoYAALVWeJazf7Eb MI9+3Oh+i/0dTBKD16ERlWl82nn61+n3cay+jX1Ir1cX9knHjkgEFm3QZUTo5jJOEWFiBnoSuUR Z X-Google-Smtp-Source: AGHT+IHfRIDY0aEdBvYM/CGHleR1/BlGMkWESTnqOo1fZp7kjl1SWO2Lcdn880hcibysr7dOIoJAuA== X-Received: by 2002:a50:c057:0:b0:5a1:e92b:acb5 with SMTP id 4fb4d7f45d1cf-5b0205d4d49mr5248999a12.11.1722282579672; Mon, 29 Jul 2024 12:49:39 -0700 (PDT) From: Andrew Melnychenko To: devel@lists.libvirt.org Subject: [RFC PATCH v4 3/5] qemu_interface: Added routine for loading the eBPF objects. Date: Mon, 29 Jul 2024 23:48:51 +0200 Message-ID: <20240729214853.458886-4-andrew@daynix.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240729214853.458886-1-andrew@daynix.com> References: <20240729214853.458886-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: E36LOACFMXYXW76VXVIWUTSC5QF3WCM5 X-Message-ID-Hash: E36LOACFMXYXW76VXVIWUTSC5QF3WCM5 X-MailFrom: andrew@daynix.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: yuri.benditovich@daynix.com, yan@daynix.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1722282667399116600 Content-Type: text/plain; charset="utf-8" Also, added dependencies for libbpf with bpf option. Signed-off-by: Andrew Melnychenko --- libvirt.spec.in | 3 ++ meson.build | 7 ++++ meson_options.txt | 1 + src/qemu/meson.build | 1 + src/qemu/qemu_interface.c | 87 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_interface.h | 7 ++++ 6 files changed, 106 insertions(+) diff --git a/libvirt.spec.in b/libvirt.spec.in index 29101e74fe..9a27123487 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -366,6 +366,7 @@ BuildRequires: yajl-devel BuildRequires: sanlock-devel >=3D 2.4 %endif BuildRequires: libpcap-devel >=3D 1.5.0 +BuildRequires: libbpf-devel >=3D 1.1.0 BuildRequires: libnl3-devel BuildRequires: libselinux-devel # For modprobe @@ -1374,6 +1375,7 @@ export SOURCE_DATE_EPOCH=3D$(stat --printf=3D'%Y' %{_= specdir}/libvirt.spec) -Dlibpcap=3Denabled \ %{?arg_nbdkit} \ %{?arg_nbdkit_config_default} \ + -Dlibbpf=3Denabled \ -Dlibnl=3Denabled \ -Daudit=3Denabled \ -Ddtrace=3Denabled \ @@ -1444,6 +1446,7 @@ export SOURCE_DATE_EPOCH=3D$(stat --printf=3D'%Y' %{_= specdir}/libvirt.spec) -Dlibiscsi=3Ddisabled \ -Dnbdkit=3Ddisabled \ -Dnbdkit_config_default=3Ddisabled \ + -Dlibbpf=3Ddisabled \ -Dlibnl=3Ddisabled \ -Dlibpcap=3Ddisabled \ -Dlibssh2=3Ddisabled \ diff --git a/meson.build b/meson.build index 231470e2ee..0647fc74bf 100644 --- a/meson.build +++ b/meson.build @@ -1025,6 +1025,12 @@ else libkvm_dep =3D dependency('', required: false) endif =20 +libbpf_version =3D '1.1.0' +libbpf_dep =3D dependency('libbpf', version: '>=3D' + libbpf_version, requ= ired: get_option('libbpf')) +if libbpf_dep.found() + conf.set('WITH_BPF', 1) +endif + libiscsi_version =3D '1.18.0' libiscsi_dep =3D dependency('libiscsi', version: '>=3D' + libiscsi_version= , required: get_option('libiscsi')) =20 @@ -2339,6 +2345,7 @@ libs_summary =3D { 'dlopen': dlopen_dep.found(), 'fuse': fuse_dep.found(), 'glusterfs': glusterfs_dep.found(), + 'libbpf': libbpf_dep.found(), 'libiscsi': libiscsi_dep.found(), 'libkvm': libkvm_dep.found(), 'libnbd': libnbd_dep.found(), diff --git a/meson_options.txt b/meson_options.txt index 2d440c63d8..be1582186e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -51,6 +51,7 @@ option('udev', type: 'feature', value: 'auto', descriptio= n: 'udev support') option('wireshark_dissector', type: 'feature', value: 'auto', description:= 'wireshark support') option('wireshark_plugindir', type: 'string', value: '', description: 'wir= eshark plugins directory for use when installing wireshark plugin') option('yajl', type: 'feature', value: 'auto', description: 'yajl support') +option('libbpf', type: 'feature', value: 'auto', description: 'qemu libbpf= support') =20 =20 # build driver options diff --git a/src/qemu/meson.build b/src/qemu/meson.build index 57356451e4..60e7e02373 100644 --- a/src/qemu/meson.build +++ b/src/qemu/meson.build @@ -99,6 +99,7 @@ if conf.has('WITH_QEMU') access_dep, capng_dep, gnutls_dep, + libbpf_dep, libnbd_dep, libnl_dep, log_dep, diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index c2007c7043..3f141afd26 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -38,6 +38,10 @@ #include #include =20 +#ifdef WITH_BPF +# include +#endif + #define VIR_FROM_THIS VIR_FROM_QEMU =20 VIR_LOG_INIT("qemu.qemu_interface"); @@ -432,3 +436,86 @@ qemuInterfaceOpenVhostNet(virDomainObj *vm, virDomainAuditNetDevice(vm->def, net, vhostnet_path, vhostfdSize); return 0; } + +#ifdef WITH_BPF + +int +qemuInterfaceLoadEbpf(const char *ebpfObject, + void **retLibbpfObj, + int *fds, + size_t nfds) +{ + int err =3D 0; + size_t i =3D 0; + struct bpf_program *prog; + struct bpf_map *map; + struct bpf_object *obj; + size_t ebpfSize =3D 0; + g_autofree void *ebpfRawData =3D NULL; + + ebpfRawData =3D g_base64_decode(ebpfObject, &ebpfSize); + if (ebpfRawData =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("can't decode the e= BPF from base64")); + return -1; + } + + obj =3D bpf_object__open_mem(ebpfRawData, ebpfSize, NULL); + if (!obj) { + virReportError(errno, "%s", _("can't open eBPF object")); + return -1; + } + + + err =3D bpf_object__load(obj); + if (err) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("can't load eBPF ob= ject")); + return -1; + } + + bpf_object__for_each_program(prog, obj) { + fds[i] =3D bpf_program__fd(prog); + ++i; + if (i > nfds) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("to much file d= escriptors in eBPF")); + return -1; + } + } + + bpf_object__for_each_map(map, obj) { + fds[i] =3D bpf_map__fd(map); + ++i; + if (i > nfds) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("to much file d= escriptors in eBPF")); + return -1; + } + } + + *retLibbpfObj =3D obj; + + return i - 1; +} + + +void +qemuInterfaceCloseEbpf(void *libbpfObj) +{ + if (libbpfObj) + bpf_object__close(libbpfObj); +} +#else + +int +qemuInterfaceLoadEbpf(const char *ebpfObject G_GNUC_UNUSED, + void **retLibbpfObj G_GNUC_UNUSED, + int *fds G_GNUC_UNUSED, + size_t nfds G_GNUC_UNUSED) +{ + return -2; +} + +void +qemuInterfaceCloseEbpf(void *libbpfObj G_GNUC_UNUSED) +{ +} + +#endif diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h index aee5f9efb0..8ce86b8769 100644 --- a/src/qemu/qemu_interface.h +++ b/src/qemu/qemu_interface.h @@ -44,3 +44,10 @@ int qemuInterfaceOpenVhostNet(virDomainObj *def, =20 int qemuInterfacePrepareSlirp(virQEMUDriver *driver, virDomainNetDef *net); + +int qemuInterfaceLoadEbpf(const char *ebpfObject, + void **retLibbpfObj, + int *fds, + size_t nfds); + +void qemuInterfaceCloseEbpf(void *libbpfObj); --=20 2.45.2 From nobody Wed Oct 30 22:11:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1722282699681696.4566172501438; Mon, 29 Jul 2024 12:51:39 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7E43793A; Mon, 29 Jul 2024 15:51:38 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BC334137B; Mon, 29 Jul 2024 15:49:48 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DD6C61258; Mon, 29 Jul 2024 15:49:42 -0400 (EDT) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 05D681231 for ; Mon, 29 Jul 2024 15:49:42 -0400 (EDT) Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5af6a1afa63so3437204a12.0 for ; Mon, 29 Jul 2024 12:49:41 -0700 (PDT) Received: from localhost.localdomain ([2001:4bb8:181:247f:e288:8f76:5999:3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac6339bcb3sm6121862a12.5.2024.07.29.12.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 12:49:40 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722282581; x=1722887381; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MbspqfRAMni4ZrOVX2T2bpeKTR5VPEboLHWzVhpTUu4=; b=UuY4Oq3krrkaUOHHKcK8c3KpMHFaxzLC/tugyrJbWNvPUGUNQUE0LxXJ6GtPt/kEzk xXlvYOvQT6lpD7IRNz5lGnhy1wlF/VPWbVRjl/EZZvNSa9bfLBC1wWUN7w3GsSY58iLH wKO5sSTiEATiN3PzcdCeL2KQb6HCrDJmRMxtmrXIMVugzXoKFzwx6drIs+XZJwasZh9w 2Eh/fnMmRnMpHZgUxVyB+fQn8/wCiEmTCZsiLVLF9zEReYVhG3IIS2GNlaRAepipZAr5 7fEZsRCUnYl9jLoM6UXsu7iByTudpXzc4XVF5DrEzo1l7NUfr2B5oZTDziGza2q8Br0O yafQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722282581; x=1722887381; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MbspqfRAMni4ZrOVX2T2bpeKTR5VPEboLHWzVhpTUu4=; b=l9Ksg7usWuzRNFDeoMUU55gNGjBLa/hCS3zwsKAfOnQzzVzIom/IHfk91lYi5Go8gh j2Bssb+f8T/STMJcfLNHFYywOatSpCGNQzgdCdZpm03n0jwdwjTXNxh/fyN5E2lE1k3G z44I4aiyB7h7qX05DceP6lpAbU1qpe2D5e4UHM0TwTCy94LzWcSV6xZKqwMPTxbxIoD6 Rn8kIUVEi61VQkz4NcdBhr2YWbE7C1HvMDLw4PCNOlNgse+um4XMko3F0Y2kjJ8mO3sX JLP/mBVYbngBmVtlPIVxEVQNbLL1kP2tSpts1u1+hOkghZ+Fz697G5dR8QfO2fjfHZUO T6FA== X-Gm-Message-State: AOJu0Yxf6jAcYR7550tNxm7Y35CslVPc0Sm6dmwAXTPm7nVUYTz207uy CA7GmFT1JidDX8eMMswGJrNvIjQnw8v5lLNLw6auuJb/HpL9v9jeVBvPU6Qo/fq8yb2pzhB+Kpg p X-Google-Smtp-Source: AGHT+IGObliuCMAp1g8YrvFEtUad1pAWZd9wKeU8uo+LrjCChoZ9RoEVX6rZWJwDi0VbZX3ldxFYXw== X-Received: by 2002:a50:d5c5:0:b0:5a2:4d19:4c08 with SMTP id 4fb4d7f45d1cf-5b021756bcdmr5104480a12.11.1722282580596; Mon, 29 Jul 2024 12:49:40 -0700 (PDT) From: Andrew Melnychenko To: devel@lists.libvirt.org Subject: [RFC PATCH v4 4/5] qemu_command: Added "ebpf_rss_fds" support for virtio-net. Date: Mon, 29 Jul 2024 23:48:52 +0200 Message-ID: <20240729214853.458886-5-andrew@daynix.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240729214853.458886-1-andrew@daynix.com> References: <20240729214853.458886-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4762WCMSUQ5DTQPPKBZDUWXQCA5MEHZO X-Message-ID-Hash: 4762WCMSUQ5DTQPPKBZDUWXQCA5MEHZO X-MailFrom: andrew@daynix.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: yuri.benditovich@daynix.com, yan@daynix.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1722282701500116600 Content-Type: text/plain; charset="utf-8" Added new capability ebpf_rss_fds for QEMU. Added logic for loading the "RSS" eBPF program. eBPF file descriptors passed to the QEMU. Signed-off-by: Andrew Melnychenko --- src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 60 +++++++++++++++++++ src/qemu/qemu_domain.c | 4 ++ src/qemu/qemu_domain.h | 3 + .../caps_9.0.0_x86_64.xml | 1 + .../caps_9.1.0_x86_64.xml | 1 + 7 files changed, 72 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2d2603e519..1191f96bec 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -713,6 +713,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "sev-snp-guest", /* QEMU_CAPS_SEV_SNP_GUEST */ "netdev.user", /* QEMU_CAPS_NETDEV_USER */ "acpi-erst", /* QEMU_CAPS_DEVICE_ACPI_ERST */ + "virtio-net.ebpf_rss_fds", /* QEMU_CAPS_VIRTIO_NET_EBPF_RSS_= FDS */ ); =20 =20 @@ -1454,6 +1455,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCaps= DevicePropsVirtioBlk[] =3D { static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioNet[= ] =3D { { "acpi-index", QEMU_CAPS_ACPI_INDEX, NULL }, { "rss", QEMU_CAPS_VIRTIO_NET_RSS, NULL }, + { "ebpf-rss-fds", QEMU_CAPS_VIRTIO_NET_EBPF_RSS_FDS, NULL }, }; =20 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsPCIeRootPo= rt[] =3D { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 2c53236132..4af5e657e4 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -692,6 +692,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_SEV_SNP_GUEST, /* -object sev-snp-guest */ QEMU_CAPS_NETDEV_USER, /* -netdev user */ QEMU_CAPS_DEVICE_ACPI_ERST, /* -device acpi-erst */ + QEMU_CAPS_VIRTIO_NET_EBPF_RSS_FDS, /* virtio-net ebpf_rss_fds feature = */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f15e6bda1e..570bc9d1e6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3806,6 +3806,25 @@ qemuBuildLegacyNicStr(virDomainNetDef *net) } =20 =20 +static virJSONValue * +qemuBuildEbpfRssArg(virDomainNetDef *net) +{ + qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); + g_autoptr(virJSONValue) props =3D NULL; + GSList *n; + + if (!netpriv->ebpfrssfds) + return NULL; + + props =3D virJSONValueNewArray(); + for (n =3D netpriv->ebpfrssfds; n; n =3D n->next) { + virJSONValueArrayAppendString(props, qemuFDPassDirectGetPath(n->da= ta)); + } + + return g_steal_pointer(&props); +} + + virJSONValue * qemuBuildNicDevProps(virDomainDef *def, virDomainNetDef *net, @@ -3820,6 +3839,7 @@ qemuBuildNicDevProps(virDomainDef *def, virTristateSwitch mq =3D VIR_TRISTATE_SWITCH_ABSENT; unsigned long long vectors =3D 0; virTristateSwitch failover =3D VIR_TRISTATE_SWITCH_ABSENT; + g_autoptr(virJSONValue) ebpffds =3D NULL; =20 switch (net->driver.virtio.txmode) { case VIR_DOMAIN_NET_VIRTIO_TX_MODE_IOTHREAD: @@ -3864,6 +3884,8 @@ qemuBuildNicDevProps(virDomainDef *def, if (!(props =3D qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_NET, net= , qemuCaps))) return NULL; =20 + ebpffds =3D qemuBuildEbpfRssArg(net); + if (virJSONValueObjectAdd(&props, "S:tx", tx, "T:ioeventfd", net->driver.virtio.ioeven= tfd, @@ -3888,6 +3910,7 @@ qemuBuildNicDevProps(virDomainDef *def, "T:hash", net->driver.virtio.rss_hash_re= port, "p:host_mtu", net->mtu, "T:failover", failover, + "A:ebpf-rss-fds", &ebpffds, NULL) < 0) return NULL; } else { @@ -4171,6 +4194,38 @@ qemuBuildWatchdogDevProps(const virDomainDef *def, } =20 =20 +static void +qemuOpenEbpfRssFds(virDomainNetDef *net, + virQEMUCaps *qemuCaps) +{ + const char *ebpfRSSObject =3D NULL; + int fds[16]; + int nfds =3D 0; + size_t i =3D 0; + qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); + + /* Add ebpf values */ + if (net->driver.virtio.rss =3D=3D VIR_TRISTATE_SWITCH_ON + && net->driver.virtio.rss_hash_report !=3D VIR_TRISTATE_SWITCH_ON + && virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_EBPF_RSS_FDS)) { + ebpfRSSObject =3D virQEMUCapsGetEbpf(qemuCaps, "rss"); + nfds =3D qemuInterfaceLoadEbpf(ebpfRSSObject, &netpriv->libbpfRSSO= bject, fds, G_N_ELEMENTS(fds)); + + if (nfds <=3D 0) + return; + + for (i =3D 0; i < nfds; ++i) { + g_autofree char *name =3D g_strdup_printf("ebpfrssfd-%s-%zu", = net->info.alias, i); + + netpriv->ebpfrssfds =3D + g_slist_prepend(netpriv->ebpfrssfds, qemuFDPassDirectNew(n= ame, fds + i)); + } + + netpriv->ebpfrssfds =3D g_slist_reverse(netpriv->ebpfrssfds); + } +} + + static int qemuBuildWatchdogCommandLine(virCommand *cmd, const virDomainDef *def, @@ -8729,6 +8784,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, g_autoptr(virJSONValue) hostnetprops =3D NULL; qemuDomainNetworkPrivate *netpriv =3D QEMU_DOMAIN_NETWORK_PRIVATE(net); GSList *n; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); =20 if (qemuDomainValidateActualNetDef(net, qemuCaps) < 0) return -1; @@ -8864,6 +8920,10 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, qemuFDPassDirectTransferCommand(netpriv->slirpfd, cmd); qemuFDPassTransferCommand(netpriv->vdpafd, cmd); =20 + qemuOpenEbpfRssFds(net, qemuCaps); + for (n =3D netpriv->ebpfrssfds; n; n =3D n->next) + qemuFDPassDirectTransferCommand(n->data, cmd); + if (!(hostnetprops =3D qemuBuildHostNetProps(vm, net))) goto cleanup; =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 298f4bfb9e..a73f62fb44 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -38,6 +38,7 @@ #include "qemu_checkpoint.h" #include "qemu_validate.h" #include "qemu_namespace.h" +#include "qemu_interface.h" #include "viralloc.h" #include "virlog.h" #include "virerror.h" @@ -1085,6 +1086,7 @@ qemuDomainNetworkPrivateClearFDs(qemuDomainNetworkPri= vate *priv) g_clear_pointer(&priv->vdpafd, qemuFDPassFree); g_slist_free_full(g_steal_pointer(&priv->vhostfds), (GDestroyNotify) q= emuFDPassDirectFree); g_slist_free_full(g_steal_pointer(&priv->tapfds), (GDestroyNotify) qem= uFDPassDirectFree); + g_slist_free_full(g_steal_pointer(&priv->ebpfrssfds), (GDestroyNotify)= qemuFDPassDirectFree); } =20 =20 @@ -1096,6 +1098,8 @@ qemuDomainNetworkPrivateDispose(void *obj G_GNUC_UNUS= ED) qemuSlirpFree(priv->slirp); =20 qemuDomainNetworkPrivateClearFDs(priv); + + qemuInterfaceCloseEbpf(priv->libbpfRSSObject); } =20 =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index a5092dd7f0..3e0345c29d 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -435,6 +435,9 @@ struct _qemuDomainNetworkPrivate { GSList *tapfds; /* qemuFDPassDirect */ GSList *vhostfds; /* qemuFDPassDirect */ qemuFDPass *vdpafd; + + void *libbpfRSSObject; + GSList *ebpfrssfds; /* qemuFDPassDirect eBPF RSS fds from helper */ }; =20 =20 diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml b/tests/qemuc= apabilitiesdata/caps_9.0.0_x86_64.xml index dbe015d287..689402b472 100644 --- a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml @@ -207,6 +207,7 @@ + 9000000 43100245 v9.0.0 diff --git a/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml b/tests/qemuc= apabilitiesdata/caps_9.1.0_x86_64.xml index b0c16a0440..74cf1db19c 100644 --- a/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_9.1.0_x86_64.xml @@ -205,6 +205,7 @@ + 9000050 43100246 v9.0.0-1388-g80e8f06021-dirty --=20 2.45.2 From nobody Wed Oct 30 22:11:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 17222828336621016.6786878343137; Mon, 29 Jul 2024 12:53:53 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 68F2193A; Mon, 29 Jul 2024 15:53:52 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7422712E9; Mon, 29 Jul 2024 15:49:57 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A7AE712A2; Mon, 29 Jul 2024 15:49:53 -0400 (EDT) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 89AA812A2 for ; Mon, 29 Jul 2024 15:49:43 -0400 (EDT) Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2eeb1051360so40687201fa.0 for ; Mon, 29 Jul 2024 12:49:43 -0700 (PDT) Received: from localhost.localdomain ([2001:4bb8:181:247f:e288:8f76:5999:3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac6339bcb3sm6121862a12.5.2024.07.29.12.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 12:49:41 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722282582; x=1722887382; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/giwz8MvIsY37JugIi1Sn/lgfa73n9K7WXiQR9D0PiM=; b=pgh4cYkHltVQ7rFyF2eDCUghtBffZLB+7SZenck8TMRPkeDZMi7bTrleFA0iJ2euFH ouSfqKYdo8zXj7KkEbUIybMsXAW8T6w1yrx6193vv3+TjWk0/KlBnbK4Osc7NKyoxvXy jM7+Uw5U9WH+sjVIc5zVPL2gsabXLv61WXOK7I4oH4sYBz0Y+wFR6oVn9ldsLDlbWkte QGUST1jfy/HpTKFLs1mR9tP1jOf6mzDE+S720BvlgTEVTKFUiQRAprPci8QAMyUkTv5o Muh6/SMQkp+kbLJGf6VA3Mju4UbXCKwCWw0MDdjMKbQC64xKJkkGKRN0L1KlfNCxeV8+ SXVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722282582; x=1722887382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/giwz8MvIsY37JugIi1Sn/lgfa73n9K7WXiQR9D0PiM=; b=PNzQD1+bp1bDi/JDhYzdGwxRNxICCqGY9UuQ2F9W+AqXuvXXuc2gpMjWh3estma1f5 5g+JFjAjMLDpzsLwI5AlL2ewqL9tTWQ2McI7AVp3vph05ZOUaTkWwwn9KvhrbWj5p5S8 gpRKHq77KvrOSSkvM5LHZytJ5VbpTIYOPcowBCClRh0Yyjpuv413MAisYSmCvvrUIziV 4nt+Zo6p+pXcbfvT8E/HelyW/v5CpS209dvcFJpL0ScXuT4F6SE1ItKNVB8bV1rApbYq OpWIDyFcy+zvuoYkq1MVew88kzB9wXx67xytlWJMQUPdXmJSYyWaps8Kgdo97y1wuz0Q 3/9g== X-Gm-Message-State: AOJu0Yya7A0u77cLMmstzvKskwdkpZdIJmzTDbQmuX6ND19yU4zC4FeL Ks/zTamHe9tN4wiwFjORXvkcwuKeDMOY2geHY5AXr2/AbnJ+f0E1R6OWPcScIzGNpmhkfiITxhN E X-Google-Smtp-Source: AGHT+IGpH6ZRuwIWBLMq6sydOXdcvmpFUESiRJBwXp3RAH8ffwt+Dv2ZB/Vj0kk9DuwAvct9TCjtFA== X-Received: by 2002:a05:651c:4ca:b0:2ef:18b7:4408 with SMTP id 38308e7fff4ca-2f12edf742amr72593541fa.5.1722282581757; Mon, 29 Jul 2024 12:49:41 -0700 (PDT) From: Andrew Melnychenko To: devel@lists.libvirt.org Subject: [RFC PATCH v4 5/5] tests: Added tests for eBPF blob loading. Date: Mon, 29 Jul 2024 23:48:53 +0200 Message-ID: <20240729214853.458886-6-andrew@daynix.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240729214853.458886-1-andrew@daynix.com> References: <20240729214853.458886-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: T44GWJYFUYOYUNHSSMLBSAUDQDDSONE6 X-Message-ID-Hash: T44GWJYFUYOYUNHSSMLBSAUDQDDSONE6 X-MailFrom: andrew@daynix.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: yuri.benditovich@daynix.com, yan@daynix.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1722282834044116600 Content-Type: text/plain; charset="utf-8" Added net-virtio-rss-bpf to qemuxmlconf's test. Synthetically modified caps-9.0.0 with a reply. Added mock functions for loading eBPF. Signed-off-by: Andrew Melnychenko Fixed Tests for 9.1.0 Added tests for SPARK Fixed issue with ident Signed-off-by: Andrew Melnychenko --- tests/qemuxml2argvmock.c | 24 ++++++++++ .../net-virtio-rss-bpf.x86_64-latest.args | 37 +++++++++++++++ .../net-virtio-rss-bpf.x86_64-latest.xml | 46 +++++++++++++++++++ tests/qemuxmlconfdata/net-virtio-rss-bpf.xml | 46 +++++++++++++++++++ tests/qemuxmlconftest.c | 5 ++ 5 files changed, 158 insertions(+) create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.= args create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.= xml create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.xml diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 9cc97199c4..f0dba04a10 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -292,3 +292,27 @@ virNetDevSetMTU(const char *ifname G_GNUC_UNUSED, { return 0; } + +int +qemuInterfaceLoadEbpf(__attribute__((unused)) const char *ebpfObject, + __attribute__((unused)) void **retLibbpfObj, int *fds, size_t nfds) +{ + if (g_getenv("QEMU_NET_RSS_EBPF_DISABLED")) + return -1; + + if (nfds >=3D 4) { + fds[0] =3D 0x100; + fds[1] =3D 0x101; + fds[2] =3D 0x102; + fds[3] =3D 0x103; + return 4; + } else { + return -1; + } +} + +void +qemuInterfaceCloseEbpf(__attribute__((unused)) void *libbpfObj) +{ + return; +} diff --git a/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args b/= tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args new file mode 100644 index 0000000000..b9497e5a73 --- /dev/null +++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args @@ -0,0 +1,37 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,acpi= =3Doff \ +-accel tcg \ +-cpu qemu64 \ +-m size=3D219136k \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'= \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","read-only":false}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-stor= age","id":"ide0-0-0","bootindex":1}' \ +-netdev '{"type":"user","id":"hostnet0"}' \ +-device '{"driver":"virtio-net-pci","rss":true,"ebpf-rss-fds":["256","257"= ,"258","259"],"netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:55","bu= s":"pci.0","addr":"0x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x5"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml b/t= ests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml new file mode 100644 index 0000000000..198540380c --- /dev/null +++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml @@ -0,0 +1,46 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + +
+ + + +
+ + + + + +
+ + + +