From nobody Mon Feb 9 11:47:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696832192; cv=none; d=zohomail.com; s=zohoarc; b=b/Lytusl9Cm65Unh9dNZM/Scmd9RHVwB0Zp4+FIhC+RG8YuzjYmkmm477VuPGYPEv447aEfzvqFTjs4WmDoirAjhOGMzE1AOJMJsfxG4Q3cuRQExErMqVeGyWopbowe+kq04TcOAsTiJ0vlZX+MwyzBp6OA5z1jlfK7IsfQEoA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696832192; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=C/1ePbcBB8Uz0B+0Begvyi1qtAYmZ4EhUM+N9mhL7YA=; b=a3lnLE6TagN6X3OvOTcpOief/QW6vF0GAY4LaYCWgq3kM1eBWiIy0QfK0gTGEl4ZUKmBftPFkQKNykzdyCW7zjoYCjNmYUoCUKOtMgEwb8T9FnMVGUtL930a+BMFdZnEYPHYDW1Tiam0MS01seLlCtCTu6fEyTzWhMw5OIZnsEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1696832192827275.4263785588464; Sun, 8 Oct 2023 23:16:32 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-421-ryFYl-7rOd-RcYaZqZEcNg-1; Mon, 09 Oct 2023 02:16:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 95E5481D783; Mon, 9 Oct 2023 06:16:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48FC720268C8; Mon, 9 Oct 2023 06:16:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AE73119465A3; Mon, 9 Oct 2023 06:16:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3117C194658C for ; Mon, 9 Oct 2023 06:16:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2067B215671F; Mon, 9 Oct 2023 06:16:25 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 18F5C215670B for ; Mon, 9 Oct 2023 06:16:25 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EEF428002B2 for ; Mon, 9 Oct 2023 06:16:24 +0000 (UTC) Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-AHlabAHWM1uQz-B6WwzudQ-1; Mon, 09 Oct 2023 02:16:22 -0400 Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-9936b3d0286so741533166b.0 for ; Sun, 08 Oct 2023 23:16:22 -0700 (PDT) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id cw11-20020a170906c78b00b0099e12a49c8fsm6446477ejb.173.2023.10.08.23.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 23:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696832191; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=C/1ePbcBB8Uz0B+0Begvyi1qtAYmZ4EhUM+N9mhL7YA=; b=VAfyrD83/vzHYpLXw26eaxW62OfB9kX+XrfJDZFFF1orzAm/rne/k5KbiCpK0p4kDcim5C 7A2wJTvhhtaDAz4R4tgOyHQp3DmE0tpsgGKTMuqQUnHtRbl3ep0sdpAV1IjcEl6H6g9aZU Dfj21GdhPdK6nNG5G/02AYTULqjOR5Y= X-MC-Unique: ryFYl-7rOd-RcYaZqZEcNg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: AHlabAHWM1uQz-B6WwzudQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696832181; x=1697436981; 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=C/1ePbcBB8Uz0B+0Begvyi1qtAYmZ4EhUM+N9mhL7YA=; b=xLGMSUfFnJsQyQ/kpJmynlbMxilYVsCN0LH3bKjoGRSchyLp/cJFJ7LCSNIeg2L65s Vh/9wU2VL+hL0ujCg0MuYdkv8NneR/3jJlQb0m6wCEl9rleqMJnLiWiqKmUYg/mlcgow Md9JPbSEuP3t6mAnPcdWaDfIj2p1ekFJYF9dtlVv3CuHozi6dKJjS6ckjjLEgfXuzDFO dbb8A325iVEjHGheMLzBxh80M0JRpiwKfNJtw+wr5pTMQNEGgNGZktiA//D8Tprwrv+6 kR3XFnKCxhs9FNXnmwEHVmGYUeSJvDOrL8R9IMwrMORTJXta15gvVps+xBa5mj0qhQzw 1LGQ== X-Gm-Message-State: AOJu0Yyj01mbFBZmnAg8N+s2DIfRdrmcwhPcQx9bVjNtavnI07BvPr14 RRIb5N0ttBtgbKeztgVyLNpo6MhY0JEtM2pF1ws= X-Google-Smtp-Source: AGHT+IF7jP9IhCzFLQ0J4BuLN78dHdCjJSJdCh/Fgv78J5jzmY9Od01gi6L26M+yD0ZDIUtJmgxaJQ== X-Received: by 2002:a17:906:2da:b0:9b7:1e26:e2ea with SMTP id 26-20020a17090602da00b009b71e26e2eamr12074674ejk.41.1696832181264; Sun, 08 Oct 2023 23:16:21 -0700 (PDT) From: Andrew Melnychenko To: libvir-list@redhat.com Subject: [RFC PATCH 1/4] qemu_monitor: Added QEMU's "request-ebpf" support. Date: Mon, 9 Oct 2023 09:16:11 +0300 Message-ID: <20231009061616.1663330-2-andrew@daynix.com> In-Reply-To: <20231009061616.1663330-1-andrew@daynix.com> References: <20231009061616.1663330-1-andrew@daynix.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, yuri.benditovich@daynix.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: daynix.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1696832193376100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Added code for monitor and monitor_json. The "request-ebpf" return's eBPF binary object encoded in base64. The function qemuMonitorGetEbpf() returns a decoded blob. 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 prog= ram and maps. Signed-off-by: Andrew Melnychenko --- src/qemu/qemu_monitor.c | 23 +++++++++++++++++++++++ src/qemu/qemu_monitor.h | 3 +++ src/qemu/qemu_monitor_json.c | 21 +++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 3 +++ 4 files changed, 50 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 320729f067..07596c78ee 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4512,3 +4512,26 @@ qemuMonitorGetStatsByQOMPath(virJSONValue *arr, =20 return NULL; } + +void * +qemuMonitorGetEbpf(qemuMonitor *mon, const char *ebpfName, size_t *size) +{ + QEMU_CHECK_MONITOR_NULL(mon); + g_autoptr(virJSONValue) reply =3D NULL; + const char *ebpfBase64 =3D NULL; + void *ebpfObject =3D NULL; + + if (ebpfName =3D=3D NULL || size =3D=3D NULL) + return NULL; + + reply =3D qemuMonitorJSONGetEbpf(mon, ebpfName); + + if (reply =3D=3D NULL) + return NULL; + + ebpfBase64 =3D virJSONValueObjectGetString(reply, "object"); + + ebpfObject =3D g_base64_decode(ebpfBase64, size); + + return ebpfObject; +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 6c590933aa..15f32f105c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1579,3 +1579,6 @@ qemuMonitorExtractQueryStats(virJSONValue *info); virJSONValue * qemuMonitorGetStatsByQOMPath(virJSONValue *arr, char *qom_path); + +void * +qemuMonitorGetEbpf(qemuMonitor *mon, const char *ebpfName, size_t *size); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8152eea9a0..a7d0865ddc 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8851,3 +8851,24 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, =20 return virJSONValueObjectStealArray(reply, "return"); } + + +virJSONValue * +qemuMonitorJSONGetEbpf(qemuMonitor *mon, const char *ebpfName) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("request-ebpf", + "s:id", ebpfName, NULL))) + return NULL; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return NULL; + + /* return empty hash */ + if (qemuMonitorJSONHasError(reply, "CommandNotFound")) + return NULL; + + return virJSONValueObjectStealObject(reply, "return"); +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 06023b98ea..6a2fc963ba 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -825,3 +825,6 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, qemuMonitorQueryStatsTargetType target, char **vcpus, GPtrArray *providers); + +virJSONValue * +qemuMonitorJSONGetEbpf(qemuMonitor *mon, const char *ebpfName); --=20 2.42.0