[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 54/73] plugin: expand the plugin_init function to include an in
From: |
Alex Bennée |
Subject: |
[PULL v2 54/73] plugin: expand the plugin_init function to include an info block |
Date: |
Fri, 25 Oct 2019 07:36:54 +0100 |
This provides a limited amount of info to plugins about the guest
system that will allow them to make some additional decisions on
setup.
Signed-off-by: Alex Bennée <address@hidden>
diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
index c213d1dd19f..784f1dfc3da 100644
--- a/include/qemu/qemu-plugin.h
+++ b/include/qemu/qemu-plugin.h
@@ -38,9 +38,27 @@
typedef uint64_t qemu_plugin_id_t;
+typedef struct {
+ /* string describing architecture */
+ const char *target_name;
+ /* is this a full system emulation? */
+ bool system_emulation;
+ union {
+ /*
+ * smp_vcpus may change if vCPUs can be hot-plugged, max_vcpus
+ * is the system-wide limit.
+ */
+ struct {
+ int smp_vcpus;
+ int max_vcpus;
+ } system;
+ };
+} qemu_info_t;
+
/**
* qemu_plugin_install() - Install a plugin
* @id: this plugin's opaque ID
+ * @info: a block describing some details about the guest
* @argc: number of arguments
* @argv: array of arguments (@argc elements)
*
@@ -49,10 +67,14 @@ typedef uint64_t qemu_plugin_id_t;
* Note: Calling qemu_plugin_uninstall() from this function is a bug. To raise
* an error during install, return !0.
*
+ * Note: @info is only live during the call. Copy any information we
+ * want to keep.
+ *
* Note: @argv remains valid throughout the lifetime of the loaded plugin.
*/
-QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc,
- char **argv);
+QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
+ const qemu_info_t *info,
+ int argc, char **argv);
/*
* Prototypes for the various callback styles we will be registering
diff --git a/plugins/loader.c b/plugins/loader.c
index eaedff577c3..ce724ed5839 100644
--- a/plugins/loader.c
+++ b/plugins/loader.c
@@ -28,6 +28,10 @@
#include "hw/core/cpu.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#ifndef CONFIG_USER_ONLY
+#include "hw/boards.h"
+#endif
+
#include "plugin.h"
/*
@@ -58,7 +62,7 @@ QemuOptsList qemu_plugin_opts = {
},
};
-typedef int (*qemu_plugin_install_func_t)(qemu_plugin_id_t, int, char **);
+typedef int (*qemu_plugin_install_func_t)(qemu_plugin_id_t, const qemu_info_t
*, int, char **);
extern struct qemu_plugin_state plugin;
@@ -145,7 +149,7 @@ static uint64_t xorshift64star(uint64_t x)
return x * UINT64_C(2685821657736338717);
}
-static int plugin_load(struct qemu_plugin_desc *desc)
+static int plugin_load(struct qemu_plugin_desc *desc, const qemu_info_t *info)
{
qemu_plugin_install_func_t install;
struct qemu_plugin_ctx *ctx;
@@ -193,7 +197,7 @@ static int plugin_load(struct qemu_plugin_desc *desc)
}
QTAILQ_INSERT_TAIL(&plugin.ctxs, ctx, entry);
ctx->installing = true;
- rc = install(ctx->id, desc->argc, desc->argv);
+ rc = install(ctx->id, info, desc->argc, desc->argv);
ctx->installing = false;
if (rc) {
error_report("%s: qemu_plugin_install returned error code %d",
@@ -241,11 +245,22 @@ static void plugin_desc_free(struct qemu_plugin_desc
*desc)
int qemu_plugin_load_list(QemuPluginList *head)
{
struct qemu_plugin_desc *desc, *next;
+ g_autofree qemu_info_t *info = g_new0(qemu_info_t, 1);
+
+ info->target_name = TARGET_NAME;
+#ifndef CONFIG_USER_ONLY
+ MachineState *ms = MACHINE(qdev_get_machine());
+ info->system_emulation = true;
+ info->system.smp_vcpus = ms->smp.cpus;
+ info->system.max_vcpus = ms->smp.max_cpus;
+#else
+ info->system_emulation = false;
+#endif
QTAILQ_FOREACH_SAFE(desc, head, entry, next) {
int err;
- err = plugin_load(desc);
+ err = plugin_load(desc, info);
if (err) {
return err;
}
--
2.20.1
- [PULL v2 02/73] travis.yml: Add libvdeplug-dev to compile-test net/vde.c, (continued)
- [PULL v2 02/73] travis.yml: Add libvdeplug-dev to compile-test net/vde.c, Alex Bennée, 2019/10/25
- [PULL v2 01/73] travis.yml: reduce scope of the --enable-debug build, Alex Bennée, 2019/10/25
- [PULL v2 04/73] travis.yml: Use newer version of libgnutls and libpng, Alex Bennée, 2019/10/25
- [PULL v2 06/73] travis.yml: Test the release tarball, Alex Bennée, 2019/10/25
- [PULL v2 03/73] travis.yml: Use libsdl2 instead of libsdl1.2, and install libsdl2-image, Alex Bennée, 2019/10/25
- [PULL v2 10/73] tests/vm: Let subclasses disable IPv6, Alex Bennée, 2019/10/25
- [PULL v2 08/73] cirrus.yml: add latest Xcode build target, Alex Bennée, 2019/10/25
- [PULL v2 05/73] travis.yml: Fix the ccache lines, Alex Bennée, 2019/10/25
- [PULL v2 09/73] tests/vm: netbsd autoinstall, using serial console, Alex Bennée, 2019/10/25
- [PULL v2 53/73] plugin: add API symbols to qemu-plugins.symbols, Alex Bennée, 2019/10/25
- [PULL v2 54/73] plugin: expand the plugin_init function to include an info block,
Alex Bennée <=
- [PULL v2 07/73] travis.yml: bump Xcode 10 to latest dot release, Alex Bennée, 2019/10/25
- [PULL v2 11/73] tests/vm/netbsd: Disable IPv6, Alex Bennée, 2019/10/25
- [PULL v2 13/73] gitlab-ci.yml: Use libvdeplug-dev to compile-test the VDE network backend, Alex Bennée, 2019/10/25
- [PULL v2 19/73] cpu: introduce cpu_in_exclusive_context(), Alex Bennée, 2019/10/25
- [PULL v2 56/73] plugin: add qemu_plugin_outs helper, Alex Bennée, 2019/10/25
- [PULL v2 72/73] MAINTAINERS: add me for the TCG plugins code, Alex Bennée, 2019/10/25
- [PULL v2 59/73] tests/plugin: add sample plugins, Alex Bennée, 2019/10/25
- [PULL v2 22/73] plugin: add user-facing API, Alex Bennée, 2019/10/25
- [PULL v2 12/73] travis.yml: cache the clang sanitizer build, Alex Bennée, 2019/10/25
- [PULL v2 21/73] docs/devel: add plugins.rst design document, Alex Bennée, 2019/10/25