From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: Andrew Melnychenko <andrew@daynix.com>,
mst@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com,
thuth@redhat.com, philmd@linaro.org, armbru@redhat.com,
eblake@redhat.com, qemu-devel@nongnu.org, toke@redhat.com,
mprivozn@redhat.com, yuri.benditovich@daynix.com, yan@daynix.com
Subject: Re: [RFC PATCH 3/5] ebpf: Added declaration/initialization routines.
Date: Thu, 30 Mar 2023 09:34:42 +0100 [thread overview]
Message-ID: <ZCVJoi7YQlt3axba@redhat.com> (raw)
In-Reply-To: <CACGkMEs1hRNLL67W96MO3eMg4H=ex4bYvFxcUkNPgfXXbOvo3A@mail.gmail.com>
On Thu, Mar 30, 2023 at 02:54:32PM +0800, Jason Wang wrote:
> On Thu, Mar 30, 2023 at 8:33 AM Andrew Melnychenko <andrew@daynix.com> wrote:
> >
> > Now, the binary objects may be retrieved by id/name.
> > It would require for future qmp commands that may require specific
> > eBPF blob.
> >
> > Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> > ---
> > ebpf/ebpf.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
> > ebpf/ebpf.h | 25 +++++++++++++++++++++++++
> > ebpf/ebpf_rss.c | 4 ++++
> > ebpf/meson.build | 1 +
> > 4 files changed, 78 insertions(+)
> > create mode 100644 ebpf/ebpf.c
> > create mode 100644 ebpf/ebpf.h
> >
> > diff --git a/ebpf/ebpf.c b/ebpf/ebpf.c
> > new file mode 100644
> > index 0000000000..86320d72f5
> > --- /dev/null
> > +++ b/ebpf/ebpf.c
> > @@ -0,0 +1,48 @@
> > +/*
> > + * QEMU eBPF binary declaration routine.
> > + *
> > + * Developed by Daynix Computing LTD (http://www.daynix.com)
> > + *
> > + * Authors:
> > + * Andrew Melnychenko <andrew@daynix.com>
> > + *
> > + * This work is licensed under the terms of the GNU GPL, version 2 or
> > + * later. See the COPYING file in the top-level directory.
> > + */
> > +
> > +#include "qemu/osdep.h"
> > +#include "qemu/queue.h"
> > +#include "ebpf/ebpf.h"
> > +
> > +struct ElfBinaryDataEntry {
> > + const char *id;
> > + const void * (*fn)(size_t *);
> > +
> > + QSLIST_ENTRY(ElfBinaryDataEntry) node;
> > +};
> > +
> > +static QSLIST_HEAD(, ElfBinaryDataEntry) ebpf_elf_obj_list =
> > + QSLIST_HEAD_INITIALIZER();
> > +
> > +void ebpf_register_binary_data(const char *id, const void * (*fn)(size_t *))
> > +{
> > + struct ElfBinaryDataEntry *data = NULL;
> > +
> > + data = g_malloc0(sizeof(*data));
> > + data->fn = fn;
> > + data->id = id;
> > +
> > + QSLIST_INSERT_HEAD(&ebpf_elf_obj_list, data, node);
> > +}
> > +
> > +const void *ebpf_find_binary_by_id(const char *id, size_t *sz)
> > +{
> > + struct ElfBinaryDataEntry *it = NULL;
> > + QSLIST_FOREACH(it, &ebpf_elf_obj_list, node) {
> > + if (strcmp(id, it->id) == 0) {
> > + return it->fn(sz);
> > + }
> > + }
> > +
> > + return NULL;
> > +}
> > diff --git a/ebpf/ebpf.h b/ebpf/ebpf.h
> > new file mode 100644
> > index 0000000000..fd705cb73e
> > --- /dev/null
> > +++ b/ebpf/ebpf.h
> > @@ -0,0 +1,25 @@
> > +/*
> > + * QEMU eBPF binary declaration routine.
> > + *
> > + * Developed by Daynix Computing LTD (http://www.daynix.com)
> > + *
> > + * Authors:
> > + * Andrew Melnychenko <andrew@daynix.com>
> > + *
> > + * This work is licensed under the terms of the GNU GPL, version 2 or
> > + * later. See the COPYING file in the top-level directory.
> > + */
> > +
> > +#ifndef EBPF_H
> > +#define EBPF_H
> > +
> > +void ebpf_register_binary_data(const char *id, const void * (*fn)(size_t *));
> > +const void *ebpf_find_binary_by_id(const char *id, size_t *sz);
> > +
> > +#define ebpf_binary_init(id, fn) \
> > +static void __attribute__((constructor)) ebpf_binary_init_ ## fn(void) \
> > +{ \
> > + ebpf_register_binary_data(id, fn); \
> > +}
> > +
> > +#endif /* EBPF_H */
> > diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
> > index 08015fecb1..b4038725f2 100644
> > --- a/ebpf/ebpf_rss.c
> > +++ b/ebpf/ebpf_rss.c
> > @@ -21,6 +21,8 @@
> >
> > #include "ebpf/ebpf_rss.h"
> > #include "ebpf/rss.bpf.skeleton.h"
> > +#include "ebpf/ebpf.h"
> > +
> > #include "trace.h"
> >
> > void ebpf_rss_init(struct EBPFRSSContext *ctx)
> > @@ -237,3 +239,5 @@ void ebpf_rss_unload(struct EBPFRSSContext *ctx)
> > ctx->obj = NULL;
> > ctx->program_fd = -1;
> > }
> > +
> > +ebpf_binary_init("rss", rss_bpf__elf_bytes)
>
> Who or how the ABI compatibility is preserved between libvirt and Qemu?
There's no real problem with binary compatibility to solve any more.
When libvirt first launches a QEMU VM, it will fetch the eBPF programs
it needs from that running QEMU using QMP. WHen it later needs to
enable features that use eBPF, it already has the program data that
matches the running QEMU
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2023-03-30 8:35 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 0:15 [RFC PATCH 0/4] eBPF RSS through QMP support Andrew Melnychenko
2023-03-30 0:15 ` [RFC PATCH 1/5] ebpf: Added eBPF initialization by fds and map update Andrew Melnychenko
2023-03-30 6:53 ` Jason Wang
2023-03-30 6:56 ` Jason Wang
2023-03-30 7:10 ` Daniel P. Berrangé
2023-03-30 11:13 ` Andrew Melnichenko
2023-03-30 0:15 ` [RFC PATCH 2/5] virtio-net: Added property to load eBPF RSS with fds Andrew Melnychenko
2023-03-30 8:52 ` Daniel P. Berrangé
2023-03-30 0:15 ` [RFC PATCH 3/5] ebpf: Added declaration/initialization routines Andrew Melnychenko
2023-03-30 6:54 ` Jason Wang
2023-03-30 8:34 ` Daniel P. Berrangé [this message]
2023-03-31 7:48 ` Jason Wang
2023-03-31 7:59 ` Daniel P. Berrangé
2023-03-31 8:03 ` Jason Wang
2023-03-31 8:13 ` Daniel P. Berrangé
2023-03-31 8:21 ` Jason Wang
2023-03-30 8:33 ` Daniel P. Berrangé
2023-03-30 11:02 ` Andrew Melnichenko
2023-03-30 0:15 ` [RFC PATCH 4/5] qmp: Added new command to retrieve eBPF blob Andrew Melnychenko
2023-03-30 8:39 ` Daniel P. Berrangé
2023-03-30 10:42 ` Andrew Melnichenko
2023-03-30 0:15 ` [RFC PATCH 5/5] ebpf: Updated eBPF program and skeleton Andrew Melnychenko
2023-03-30 6:57 ` [RFC PATCH 0/4] eBPF RSS through QMP support Jason Wang
2023-03-30 10:48 ` Andrew Melnichenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZCVJoi7YQlt3axba@redhat.com \
--to=berrange@redhat.com \
--cc=andrew@daynix.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=jasowang@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mprivozn@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
--cc=toke@redhat.com \
--cc=yan@daynix.com \
--cc=yuri.benditovich@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).