From nobody Thu Oct 31 00:18:24 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