All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-arm: Implement qmp query-cpu-definitions
@ 2013-09-04 15:23 Cole Robinson
  2013-09-05 15:02 ` Andreas Färber
  2013-09-05 17:09 ` Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Cole Robinson @ 2013-09-04 15:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Cole Robinson

Libvirt uses this to introspect available CPU models.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
Maybe this will be centrally handled after the QOM CPU work is done?

 target-arm/helper.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/target-arm/helper.c b/target-arm/helper.c
index e51ef20..1874377 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -2,6 +2,7 @@
 #include "exec/gdbstub.h"
 #include "helper.h"
 #include "qemu/host-utils.h"
+#include "sysemu/arch_init.h"
 #include "sysemu/sysemu.h"
 #include "qemu/bitops.h"
 
@@ -1829,6 +1830,37 @@ void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf)
     g_slist_free(list);
 }
 
+static void arm_cpu_add_definition(gpointer data, gpointer user_data)
+{
+    ObjectClass *oc = data;
+    CpuDefinitionInfoList **cpu_list = user_data;
+    CpuDefinitionInfoList *entry;
+    CpuDefinitionInfo *info;
+    const char *typename;
+
+    typename = object_class_get_name(oc);
+    info = g_malloc0(sizeof(*info));
+    info->name = g_strndup(typename,
+                           strlen(typename) - strlen("-" TYPE_ARM_CPU));
+
+    entry = g_malloc0(sizeof(*entry));
+    entry->value = info;
+    entry->next = *cpu_list;
+    *cpu_list = entry;
+}
+
+CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
+{
+    CpuDefinitionInfoList *cpu_list = NULL;
+    GSList *list;
+
+    list = object_class_get_list(TYPE_ARM_CPU, false);
+    g_slist_foreach(list, arm_cpu_add_definition, &cpu_list);
+    g_slist_free(list);
+
+    return cpu_list;
+}
+
 void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
                                        const ARMCPRegInfo *r, void *opaque)
 {
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PATCH] target-arm: Implement qmp query-cpu-definitions
  2013-09-04 15:23 [Qemu-devel] [PATCH] target-arm: Implement qmp query-cpu-definitions Cole Robinson
@ 2013-09-05 15:02 ` Andreas Färber
  2013-09-05 17:09 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Färber @ 2013-09-05 15:02 UTC (permalink / raw)
  To: Cole Robinson; +Cc: Peter Maydell, qemu-ppc, qemu-devel, Alexander Graf

Hi,

Am 04.09.2013 17:23, schrieb Cole Robinson:
> Libvirt uses this to introspect available CPU models.
> 
> Signed-off-by: Cole Robinson <crobinso@redhat.com>
> ---
> Maybe this will be centrally handled after the QOM CPU work is done?

No, this API is about a pre-QOM command line switch, whose
implementation is target-specific. What got standardized for multiple
targets was the CPUClass::class_by_name() hook for the opposite
direction of -cpu to ObjectClass lookup (with the goal of obsoleting
cpu_init()). It is not wrong to implement query-cpus for arm, but -cpu
is considered deprecated.

And personally especially for arm I would rather welcome someone
contributing a proper, e.g., Raspberry Pi board (with clean separation
of what is on the SoC and what on the board to avoid duplication among
boards) than tweaking some other unrelated board with -cpu and then
complaining that it doesn't work as expected. ;) For machines that use
soft-core CPUs (FPGAs) or for mach-virt as non-physical machine it does
make sense, but query-cpus gives us a list irrespective of whether they
are compatible with the board. Same for ppc btw - plugging, e.g., a 440
CPU into pseries or mac99 won't work.
Short-term my view is to use fixed CPU types, ignoring -cpu, where the
CPU cannot be exchanged (e.g., DIGIC patch series) and a suitable link<>
type otherwise.

The long-term goal is to have machines be config files (thereby
user-creatable) assembling QOM objects by specifying memory mapping and
IRQ routing. The latter two parts don't work with the old qdev and
SysBusDevice APIs.

That said, patch itself looks correct,

Reviewed-by: Andreas Färber <afaerber@suse.de>

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH] target-arm: Implement qmp query-cpu-definitions
  2013-09-04 15:23 [Qemu-devel] [PATCH] target-arm: Implement qmp query-cpu-definitions Cole Robinson
  2013-09-05 15:02 ` Andreas Färber
@ 2013-09-05 17:09 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2013-09-05 17:09 UTC (permalink / raw)
  To: Cole Robinson; +Cc: QEMU Developers, Andreas Färber

On 4 September 2013 16:23, Cole Robinson <crobinso@redhat.com> wrote:
> Libvirt uses this to introspect available CPU models.
>
> Signed-off-by: Cole Robinson <crobinso@redhat.com>

Thanks, applied to target-arm.next.

-- PMM

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

end of thread, other threads:[~2013-09-05 17:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-04 15:23 [Qemu-devel] [PATCH] target-arm: Implement qmp query-cpu-definitions Cole Robinson
2013-09-05 15:02 ` Andreas Färber
2013-09-05 17:09 ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.