From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Jiri Denemark <jdenemar@redhat.com>,
dahi@linux.vnet.ibm.com, libvir-list@redhat.com,
Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PATCH 3/3] target-i386: Implement arch_query_host_cpu_info()
Date: Mon, 20 Jun 2016 17:12:44 -0300 [thread overview]
Message-ID: <1466453564-7572-4-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1466453564-7572-1-git-send-email-ehabkost@redhat.com>
Return information on the host CPU using the "host" CPU model.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 3d3635d..06b0b99 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -30,6 +30,7 @@
#include "qemu/config-file.h"
#include "qapi/qmp/qerror.h"
+#include "qom/qom-qobject.h"
#include "qapi-types.h"
#include "qapi-visit.h"
#include "qapi/visitor.h"
@@ -2222,6 +2223,69 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
return cpu_list;
}
+/* Return host CPU info by instantiating a "host" CPU object,
+ * and returning all the default values for QOM properties
+ */
+void arch_query_host_cpu_info(HostCPUInfo *r, bool migratable, Error **errp)
+{
+ Object *obj = NULL;
+ ObjectPropertyIterator iter;
+ ObjectProperty *prop;
+ QDict *propdict = NULL;
+ Error *err = NULL;
+
+ /* Host CPU information is returned only in KVM mode, by now */
+ if (!kvm_enabled()) {
+ goto out;
+ }
+
+ obj = object_new(X86_CPU_TYPE_NAME("host"));
+
+ object_property_set_bool(obj, migratable, "migratable", &err);
+ if (err) {
+ goto out;
+ }
+
+ x86_cpu_load_host_data(X86_CPU(obj));
+
+ propdict = qdict_new();
+
+ object_property_iter_init(&iter, obj);
+ while ((prop = object_property_iter_next(&iter))) {
+ QObject *v;
+
+ /* Skip properties that aren't useful for the query because
+ * they don't make sense here:
+ * - "realized" doesn't make sense because we never realize
+ * the CPU object above.
+ * - "filtered-features" doesn't make sense because we
+ * never filter the feature list (as it is done inside
+ * realizefn).
+ */
+ if (!strcmp(prop->name, "realized") ||
+ !strcmp(prop->name, "filtered-features")) {
+ continue;
+ }
+
+ v = object_property_get_qobject(obj, prop->name, &err);
+ if (err) {
+ goto out;
+ }
+ qdict_put_obj(propdict, prop->name, v);
+ }
+
+ r->has_qom_properties = true;
+ r->qom_properties = QOBJECT(propdict);
+
+out:
+ object_unref(obj);
+ if (err) {
+ qobject_decref(QOBJECT(propdict));
+ error_propagate(errp, err);
+ }
+ return;
+}
+
static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
bool migratable_only)
{
--
2.5.5
next prev parent reply other threads:[~2016-06-20 20:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-20 20:12 [Qemu-devel] [PATCH 0/3] qmp: query-host-cpu command Eduardo Habkost
2016-06-20 20:12 ` [Qemu-devel] [PATCH 1/3] qmp: Add " Eduardo Habkost
2016-06-21 21:48 ` Eric Blake
2016-06-23 16:37 ` Eduardo Habkost
2016-06-20 20:12 ` [Qemu-devel] [PATCH 2/3] target-i386: Introduce x86_cpu_load_host_data() function Eduardo Habkost
2016-06-23 14:59 ` Igor Mammedov
2016-06-23 16:04 ` Eduardo Habkost
2016-06-23 16:56 ` Igor Mammedov
2016-06-23 19:16 ` Eduardo Habkost
2016-06-20 20:12 ` Eduardo Habkost [this message]
2016-06-21 6:20 ` [Qemu-devel] [PATCH 0/3] qmp: query-host-cpu command David Hildenbrand
2016-06-21 12:45 ` Eduardo Habkost
2016-06-21 12:52 ` David Hildenbrand
2016-06-21 16:15 ` Eduardo Habkost
2016-06-21 17:04 ` David Hildenbrand
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=1466453564-7572-4-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=dahi@linux.vnet.ibm.com \
--cc=imammedo@redhat.com \
--cc=jdenemar@redhat.com \
--cc=libvir-list@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).