On 02/22/2012 03:44 AM, Andreas Färber wrote:
Hello,
For listing registered CPU classes I needed a way to sort classes in a
custom (i.e., non-hashtable) order. I found it easiest to sort the classes
using the existing foreach infrastructure, on the go via GLib's binary tree.
Patch is still missing documentation, but do you think this is the right
direction, Anthony?
I think it might be better to have an object_class_search() function that acts
like object_class_foreach() but returns a GSList. You can then call
g_list_sort() on the resulting data structure.
I've been wondering if it might make sense to replace the current filtering
mechanism (abstract and type) with another callback function or whether that
would be overkill - currently the only other filtering I needed to do was
to ignore the "host" CPU class, which can be done by simple if in the callback.
I'd prefer not to do callbacks because this interface gets exposed via QMP and
callbacks can't be modeled via QMP.
Regards,
Anthony Liguori
Regards,
Andreas
Andreas Färber (1):
qom: Introduce object_class_foreach_ordered()
include/qemu/object.h | 6 ++++++
qom/object.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 0 deletions(-)