diff mbox

[RFC,06/11] qdev: sysbus_dev_info

Message ID 1261861899-1984-7-git-send-email-nathan@parenthephobia.org.uk
State New
Headers show

Commit Message

Nathan Baum Dec. 26, 2009, 9:11 p.m. UTC
Returns information about the system bus as a QObject.

Signed-off-by: Nathan Baum <nathan@parenthephobia.org.uk>
---
 hw/sysbus.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

Comments

Markus Armbruster Jan. 15, 2010, 6:17 p.m. UTC | #1
Nathan Baum <nathan@parenthephobia.org.uk> writes:

> Returns information about the system bus as a QObject.
>
> Signed-off-by: Nathan Baum <nathan@parenthephobia.org.uk>
> ---
>  hw/sysbus.c |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
>
> diff --git a/hw/sysbus.c b/hw/sysbus.c
> index 1f7f138..2092d9f 100644
> --- a/hw/sysbus.c
> +++ b/hw/sysbus.c
> @@ -20,6 +20,7 @@
>  #include "sysbus.h"
>  #include "sysemu.h"
>  #include "monitor.h"
> +#include "qjson.h"
>  
>  static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent);
>  
> @@ -170,3 +171,20 @@ static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
>                         indent, "", s->mmio[i].addr, s->mmio[i].size);
>      }
>  }
> +
> +static QObject *sysbus_dev_info(Monitor *mon, DeviceState *dev)
> +{
> +    SysBusDevice *s = sysbus_from_qdev(dev);
> +    QDict *dict = qdict_new();
> +    QList *list = qlist_new();
> +    int i;
> +    
> +    for (i = 0; i < s->num_mmio; i++) {
> +        qlist_append_obj(list, qobject_from_jsonf("{ 'addr': " TARGET_FMT_plx ", 'size': " TARGET_FMT_plx " }",
> +                                                  s->mmio[i].addr, s->mmio[i].size));
> +    }
> +    
> +    qdict_put(dict, "mmio", list);
> +    return (QObject *) dict;

I think Luiz wants you to use QOBJECT() here.

> +    
> +}
diff mbox

Patch

diff --git a/hw/sysbus.c b/hw/sysbus.c
index 1f7f138..2092d9f 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -20,6 +20,7 @@ 
 #include "sysbus.h"
 #include "sysemu.h"
 #include "monitor.h"
+#include "qjson.h"
 
 static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent);
 
@@ -170,3 +171,20 @@  static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
                        indent, "", s->mmio[i].addr, s->mmio[i].size);
     }
 }
+
+static QObject *sysbus_dev_info(Monitor *mon, DeviceState *dev)
+{
+    SysBusDevice *s = sysbus_from_qdev(dev);
+    QDict *dict = qdict_new();
+    QList *list = qlist_new();
+    int i;
+    
+    for (i = 0; i < s->num_mmio; i++) {
+        qlist_append_obj(list, qobject_from_jsonf("{ 'addr': " TARGET_FMT_plx ", 'size': " TARGET_FMT_plx " }",
+                                                  s->mmio[i].addr, s->mmio[i].size));
+    }
+    
+    qdict_put(dict, "mmio", list);
+    return (QObject *) dict;
+    
+}