[RFC PATCH v3 1/6] qemu_monitor: Added QEMU's "request-ebpf" support.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <andrew@xxxxxxxxxx>
---
 src/qemu/qemu_monitor.c      | 13 +++++++++++++
 src/qemu/qemu_monitor.h      |  3 +++
 src/qemu/qemu_monitor_json.c | 26 ++++++++++++++++++++++++++
 src/qemu/qemu_monitor_json.h |  3 +++
 4 files changed, 45 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 34e2ccab97..1dc2fa3fac 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4511,3 +4511,16 @@ qemuMonitorDisplayReload(qemuMonitor *mon,
 
     return qemuMonitorJSONDisplayReload(mon, type, tlsCerts);
 }
+
+const char *
+qemuMonitorGetEbpf(qemuMonitor *mon, const char *ebpfName)
+{
+    QEMU_CHECK_MONITOR_NULL(mon);
+
+    if (ebpfName == NULL) {
+        virReportInvalidNonNullArg(ebpfName);
+        return NULL;
+    }
+
+    return qemuMonitorJSONGetEbpf(mon, ebpfName);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 6e81945201..fe8853a2c4 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1586,3 +1586,6 @@ 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 eb84a3d938..585a645e66 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -8896,3 +8896,29 @@ int qemuMonitorJSONDisplayReload(qemuMonitor *mon,
 
     return 0;
 }
+
+const char *
+qemuMonitorJSONGetEbpf(qemuMonitor *mon, const char *ebpfName)
+{
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
+    virJSONValue *ret = NULL;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("request-ebpf", "s:id", ebpfName, NULL)))
+        return NULL;
+
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+        return NULL;
+
+    if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+        return NULL;
+
+    ret = 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 9684660d86..4a6fc9324e 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -829,3 +829,6 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon,
 int qemuMonitorJSONDisplayReload(qemuMonitor *mon,
                                  const char *type,
                                  bool tlsCerts);
+
+const char *
+qemuMonitorJSONGetEbpf(qemuMonitor *mon, const char *ebpfName);
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux