From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Xiaojuan Yang" <yangxiaojuan@loongson.cn>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Greg Kurz" <groug@kaod.org>, "Cédric Le Goater" <clg@kaod.org>,
qemu-ppc@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
"Aurelien Jarno" <aurelien@aurel32.net>,
"Song Gao" <gaosong@loongson.cn>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Huacai Chen" <chenhuacai@kernel.org>,
"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
qemu-arm@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>
Subject: [PATCH v2 2/5] target/i386: Restrict 'qapi-commands-machine.h' to system emulation
Date: Tue, 20 Dec 2022 12:03:07 +0100 [thread overview]
Message-ID: <20221220110310.8656-3-philmd@linaro.org> (raw)
In-Reply-To: <20221220110310.8656-1-philmd@linaro.org>
From: Philippe Mathieu-Daude <philmd@linaro.org>
Since commit a0e61807a3 ("qapi: Remove QMP events and commands from
user-mode builds") we don't generate the "qapi-commands-machine.h"
header in a user-emulation-only build.
Guard qmp_query_cpu_definitions() within CONFIG_USER_ONLY; move
x86_cpu_class_check_missing_features() closer since it is only used
by this QMP command handler.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/cpu.c | 74 +++++++++++++++++++++++++----------------------
1 file changed, 39 insertions(+), 35 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index ae502f0bfe..435980dd3a 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -31,11 +31,11 @@
#include "qapi/error.h"
#include "qapi/qapi-visit-machine.h"
#include "qapi/qmp/qerror.h"
-#include "qapi/qapi-commands-machine-target.h"
#include "standard-headers/asm-x86/kvm_para.h"
#include "hw/qdev-properties.h"
#include "hw/i386/topology.h"
#ifndef CONFIG_USER_ONLY
+#include "qapi/qapi-commands-machine-target.h"
#include "exec/address-spaces.h"
#include "hw/boards.h"
#include "hw/i386/sgx-epc.h"
@@ -4713,40 +4713,6 @@ static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v,
visit_type_strList(v, "unavailable-features", &result, errp);
}
-/* Check for missing features that may prevent the CPU class from
- * running using the current machine and accelerator.
- */
-static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
- strList **list)
-{
- strList **tail = list;
- X86CPU *xc;
- Error *err = NULL;
-
- if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {
- QAPI_LIST_APPEND(tail, g_strdup("kvm"));
- return;
- }
-
- xc = X86_CPU(object_new_with_class(OBJECT_CLASS(xcc)));
-
- x86_cpu_expand_features(xc, &err);
- if (err) {
- /* Errors at x86_cpu_expand_features should never happen,
- * but in case it does, just report the model as not
- * runnable at all using the "type" property.
- */
- QAPI_LIST_APPEND(tail, g_strdup("type"));
- error_free(err);
- }
-
- x86_cpu_filter_features(xc, false);
-
- x86_cpu_list_feature_names(xc->filtered_features, tail);
-
- object_unref(OBJECT(xc));
-}
-
/* Print all cpuid feature names in featureset
*/
static void listflags(GList *features)
@@ -4875,6 +4841,42 @@ void x86_cpu_list(void)
g_list_free(names);
}
+#ifndef CONFIG_USER_ONLY
+
+/* Check for missing features that may prevent the CPU class from
+ * running using the current machine and accelerator.
+ */
+static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
+ strList **list)
+{
+ strList **tail = list;
+ X86CPU *xc;
+ Error *err = NULL;
+
+ if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {
+ QAPI_LIST_APPEND(tail, g_strdup("kvm"));
+ return;
+ }
+
+ xc = X86_CPU(object_new_with_class(OBJECT_CLASS(xcc)));
+
+ x86_cpu_expand_features(xc, &err);
+ if (err) {
+ /* Errors at x86_cpu_expand_features should never happen,
+ * but in case it does, just report the model as not
+ * runnable at all using the "type" property.
+ */
+ QAPI_LIST_APPEND(tail, g_strdup("type"));
+ error_free(err);
+ }
+
+ x86_cpu_filter_features(xc, false);
+
+ x86_cpu_list_feature_names(xc->filtered_features, tail);
+
+ object_unref(OBJECT(xc));
+}
+
static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
{
ObjectClass *oc = data;
@@ -4915,6 +4917,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
return cpu_list;
}
+#endif /* !CONFIG_USER_ONLY */
+
uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
bool migratable_only)
{
--
2.38.1
next prev parent reply other threads:[~2022-12-20 11:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-20 11:03 [PATCH v2 0/5] target: Restrict 'qapi-commands-machine.h' to system emulation Philippe Mathieu-Daudé
2022-12-20 11:03 ` [PATCH v2 1/5] target/arm: " Philippe Mathieu-Daudé
2022-12-20 11:03 ` Philippe Mathieu-Daudé [this message]
2022-12-20 11:03 ` [PATCH v2 3/5] target/loongarch: " Philippe Mathieu-Daudé
2022-12-20 11:03 ` [PATCH v2 4/5] target/mips: " Philippe Mathieu-Daudé
2022-12-20 11:03 ` [PATCH v2 5/5] target/ppc: " Philippe Mathieu-Daudé
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=20221220110310.8656-3-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=aleksandar.rikalo@syrmia.com \
--cc=armbru@redhat.com \
--cc=aurelien@aurel32.net \
--cc=chenhuacai@kernel.org \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=gaosong@loongson.cn \
--cc=groug@kaod.org \
--cc=jiaxun.yang@flygoat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=yangxiaojuan@loongson.cn \
/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).