From nobody Mon Feb 9 17:23:52 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=1696832195; cv=none; d=zohomail.com; s=zohoarc; b=jRszkyRVChHg/VFWxUjiGqMZQf0HxOIiClHJA026TBw4zFb5dSxEcVStIMLTKdeX8u5PjMMPmt7xj2fhEascto1BaBkkeSOxqTR6J2X8rtcW8djSIyyof1fpAwGFgeAa0jLvxUkb+bdCt+ZdunnUSrGw7+G/8VAsotS/mX39vmY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696832195; 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=UO8SbMmUq5CrUoap3fcaksm7b9cYjvbUGYRV1m632As=; b=ZKe/r3fxBO80ipMNf8Pc/plbrK77FzFuUnxDE7BXTVZb/rabb0PGtrCyiSgrGUBWoIOGuWDAdMtFIV8kEkIto6xq6qgTFDrV4THnr6wCd/ne82doQLJeQdTKskgE9c802ZR96o/KKxnpwXU5dt+Vuj0AbibY7jf0Dw3ffKvp2mw= 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 1696832195160715.7123062870128; Sun, 8 Oct 2023 23:16:35 -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-629-ux5Ulw_5PBaWzNVlOmPKLw-1; Mon, 09 Oct 2023 02:16:30 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 70CE081D88D; Mon, 9 Oct 2023 06:16:28 +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 5A21B40C6EA8; Mon, 9 Oct 2023 06:16:28 +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 232051946595; Mon, 9 Oct 2023 06:16:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 75353194658C for ; Mon, 9 Oct 2023 06:16:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 474A040C6EBF; Mon, 9 Oct 2023 06:16:27 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 407B640C6EC0 for ; Mon, 9 Oct 2023 06:16:27 +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 232D7185A73B for ; Mon, 9 Oct 2023 06:16:27 +0000 (UTC) Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-79-67C_gkztN3y8j5s2a-YxQw-1; Mon, 09 Oct 2023 02:16:24 -0400 Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-9b2cee40de8so902983866b.1 for ; Sun, 08 Oct 2023 23:16:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 23:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696832194; 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=UO8SbMmUq5CrUoap3fcaksm7b9cYjvbUGYRV1m632As=; b=aozGK+jHjK2QORu7cD380FSdBVyYUL2zJk88Cn+Wg2tSXGaXmHyncTwaIjLBnnus6Al0W9 FyK/HQbefzkp6uLXASQRqy05tClDZyzJQHG2sNZQSDMq8BH2hcWPDswNX3p8e4BdgNrgCv v9WbxF+UxbYQR2qvQ4G6rWGtexNZ5bo= X-MC-Unique: ux5Ulw_5PBaWzNVlOmPKLw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 67C_gkztN3y8j5s2a-YxQw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696832183; x=1697436983; 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=UO8SbMmUq5CrUoap3fcaksm7b9cYjvbUGYRV1m632As=; b=Lk0ao4g32BoEJJCqRuXaF6D3Nj97uPeyO+ohWoLYvqQNq5JDOlNqOuceKLsgk4DQW8 9zBkUq8GakobBQBU5QUk48C9/8+wF9lcXSNKGqjYP4N+gnb4IVMnr6hnFFs8JbWNuRUh 4jTUsiHTsQTnEEeY/o2Fo6RXlYBPqaWIrcAdWLc4jRm0TvXHWc9h2cmGoB7yWBrB+EOH qesIXdpusI3VdDK553RI4AUsVSvEXmxN4VlIal/1QUUcVnhjhHLsktgptgGbZGeJgbe5 JcnpQR9+uywslFOuG7AsHxB2uR4xr8mmAdGbgCXgDiLkMknF8SKbPS6Cekzd0H2+ugfa ZWtA== X-Gm-Message-State: AOJu0YwBi/2EFaKsemWgu72vx2ZT9ex59F15Sbn2DpPbBaK62jlJGf+g HGOZUYIGuforykpKlUt7z1qtiRR6zA1L9we/4xw= X-Google-Smtp-Source: AGHT+IFEEnO412A1rGjk/lA4h5bRk/1MH1BXP1lnvhLVcw59qkN+bAYk3ylW/tY+ry6ifwDgU1ynEw== X-Received: by 2002:a17:906:c106:b0:9b8:df8e:cbd0 with SMTP id do6-20020a170906c10600b009b8df8ecbd0mr7766831ejc.37.1696832183205; Sun, 08 Oct 2023 23:16:23 -0700 (PDT) From: Andrew Melnychenko To: libvir-list@redhat.com Subject: [RFC PATCH 3/4] qemu_interface: Added routine for loading the eBPF objects. Date: Mon, 9 Oct 2023 09:16:13 +0300 Message-ID: <20231009061616.1663330-4-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.2 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.2 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: 1696832197339100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Also, added dependencies for libbpf with bpf option. Signed-off-by: Andrew Melnychenko --- meson.build | 6 ++++++ meson_options.txt | 1 + src/qemu/meson.build | 1 + src/qemu/qemu_interface.c | 42 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_interface.h | 4 ++++ 5 files changed, 54 insertions(+) diff --git a/meson.build b/meson.build index de23fbda1e..b68e916246 100644 --- a/meson.build +++ b/meson.build @@ -1381,6 +1381,11 @@ if yajl_dep.found() conf.set('WITH_YAJL', 1) endif =20 +bpf_version =3D '1.1.0' +bpf_dep =3D dependency('libbpf', version: '>=3D' + bpf_version, required: = get_option('bpf')) +if bpf_dep.found() + conf.set('WITH_BPF', 1) +endif =20 # generic build dependencies checks =20 @@ -2269,6 +2274,7 @@ libs_summary =3D { 'udev': udev_dep.found(), 'xdr': xdr_dep.found(), 'yajl': yajl_dep.found(), + 'bpf': bpf_dep.found(), } summary(libs_summary, section: 'Libraries', bool_yn: true) =20 diff --git a/meson_options.txt b/meson_options.txt index 7c428a9eb0..092b2efe06 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -44,6 +44,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('bpf', type: 'feature', value: 'auto', description: 'qemu libbpf su= pport') =20 =20 # build driver options diff --git a/src/qemu/meson.build b/src/qemu/meson.build index 64c62e584f..afd9133ae0 100644 --- a/src/qemu/meson.build +++ b/src/qemu/meson.build @@ -105,6 +105,7 @@ if conf.has('WITH_QEMU') selinux_dep, src_dep, xdr_dep, + bpf_dep, ], include_directories: [ conf_inc_dir, diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index 8856bb95a8..a3a43a43c5 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -36,6 +36,7 @@ =20 #include #include +#include =20 #define VIR_FROM_THIS VIR_FROM_QEMU =20 @@ -763,3 +764,44 @@ qemuInterfaceOpenVhostNet(virDomainObj *vm, virDomainAuditNetDevice(vm->def, net, vhostnet_path, vhostfdSize); return 0; } + + +int qemuInterfaceLoadEbpf(const void *ebpfObject, size_t ebpfSize, void **= retLibbpfObj, int *fds, int nfds) { + int err =3D 0; + int i =3D 0; + + struct bpf_object *obj =3D bpf_object__open_mem(ebpfObject, ebpfSize, = NULL); + err =3D libbpf_get_error(obj); + if(err) { + return -1; + } + + struct bpf_program *prog; + struct bpf_map *map; + + err =3D bpf_object__load(obj); + if (err) { + return -1; + } + + bpf_object__for_each_program(prog, obj) { + fds[i] =3D bpf_program__fd(prog); + ++i; + } + + bpf_object__for_each_map(map, obj) { + fds[i] =3D bpf_map__fd(map); + ++i; + } + + *retLibbpfObj =3D obj; + + return i; +} + + +void qemuInterfaceCloseEbpf(void *libbpfObj) +{ + if(libbpfObj) + bpf_object__close(libbpfObj); +} diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h index 6eed3e6bd7..dbc1fd625c 100644 --- a/src/qemu/qemu_interface.h +++ b/src/qemu/qemu_interface.h @@ -55,3 +55,7 @@ int qemuInterfaceOpenVhostNet(virDomainObj *def, =20 int qemuInterfacePrepareSlirp(virQEMUDriver *driver, virDomainNetDef *net); + +int qemuInterfaceLoadEbpf(const void *ebpfObject, size_t ebpfSize, void **= retLibbpfObj, int *fds, int nfds); + +void qemuInterfaceCloseEbpf(void *libbpfObj); --=20 2.42.0