qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] RFC: powerpc: add PVR compatibility check
@ 2013-11-04  3:36 Alexey Kardashevskiy
  2013-11-04  7:47 ` Alexander Graf
  0 siblings, 1 reply; 12+ messages in thread
From: Alexey Kardashevskiy @ 2013-11-04  3:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf, Anthony Liguori,
	Andreas Färber

If QEMU is started with KVM enabled and -cpu specified, and the CPU is not
from the family which the host is running on, an error should be displayed
so this the patch does.

Cc: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

---

Is that correct to assume that the closest abstract class is a CPU family?
It is most likely true but I want to double check :)

Is there any nicer way of doing what the patch does?

Thanks.


---
 target-ppc/translate_init.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 3d3952c..6888214 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -8314,6 +8314,14 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
     return ret;
 }
 
+ObjectClass *object_class_get_abstract_parent(ObjectClass *class)
+{
+    while (class && !object_class_is_abstract(class)) {
+        class = object_class_get_parent(class);
+    }
+    return class;
+}
+
 PowerPCCPU *cpu_ppc_init(const char *cpu_model)
 {
     PowerPCCPU *cpu;
@@ -8325,6 +8333,26 @@ PowerPCCPU *cpu_ppc_init(const char *cpu_model)
         return NULL;
     }
 
+    /*
+     * Make sure that if we run with a specific CPU in the command line when
+     * KVM is enabled, it still from the same CPU family as the host CPU
+     * because if they are not, the compatibility mode should be used.
+     */
+    if (strcmp(object_class_get_name(oc), TYPE_HOST_POWERPC_CPU)) {
+        ObjectClass *oc_host = object_class_by_name(TYPE_HOST_POWERPC_CPU);
+        ObjectClass *ocp = object_class_get_abstract_parent(oc);
+
+        if (oc_host) {
+            ObjectClass *ocp_host = object_class_get_abstract_parent(oc_host);
+            if (ocp != ocp_host) {
+                error_report("The chosen CPU \"%s\" is incompatible with the host CPU \"%s\"",
+                             object_class_get_name(oc),
+                             object_class_get_name(ocp_host));
+                return NULL;
+            }
+        }
+    }
+
     cpu = POWERPC_CPU(object_new(object_class_get_name(oc)));
 
     object_property_set_bool(OBJECT(cpu), true, "realized", &err);
-- 
1.8.4.rc4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-11-06 12:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-04  3:36 [Qemu-devel] [PATCH] RFC: powerpc: add PVR compatibility check Alexey Kardashevskiy
2013-11-04  7:47 ` Alexander Graf
2013-11-04  8:58   ` Alexey Kardashevskiy
2013-11-04  9:05     ` Alexander Graf
2013-11-04  9:24       ` Alexey Kardashevskiy
2013-11-04  9:29         ` Alexander Graf
2013-11-05  4:00       ` Paul Mackerras
2013-11-05  6:05         ` Alexander Graf
2013-11-05 16:16           ` Andreas Färber
2013-11-05 16:18             ` Alexander Graf
2013-11-06  3:02             ` Paul Mackerras
2013-11-06 12:19               ` Alexander Graf

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).