Luiz Capitulino wrote:
On Thu, 10 Dec 2009 11:09:53 +0100
Markus Armbruster <arm...@redhat.com> wrote:

Luiz Capitulino <lcapitul...@redhat.com> writes:

Signed-off-by: Luiz Capitulino <lcapitul...@redhat.com>
---
 monitor.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/monitor.c b/monitor.c
index 47f794d..3d33bd8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -514,10 +514,30 @@ static void do_info_version(Monitor *mon, QObject 
**ret_data)
                                    QEMU_VERSION, QEMU_PKGVERSION);
 }
-static void do_info_name(Monitor *mon)
+static void do_info_name_print(Monitor *mon, const QObject *data)
 {
-    if (qemu_name)
-        monitor_printf(mon, "%s\n", qemu_name);
+    const char *str;
+
+    str = qdict_get_str(qobject_to_qdict(data), "name");
+    if (strlen(str) > 0) {
+        monitor_printf(mon, "%s\n", str);
+    }
+}
+
+/**
+ * do_info_name(): Show VM name
+ *
+ * Return a QDict with the following information:
+ *
+ * - "name": VM's name. If the VM has no name, the string will be empty
So you can't distinguish name "" from unnamed.  Do we care?

 I don't think so, but if we do the best way to deal with the fact
that qemu_name can be NULL would be to return null, like:

{ "name": null }

 But we don't support json-null yet... There are other two
ways to solve this, but they seem workarounds for not supporting
null: return an empty dict or return { "name": false }.

I'd prefer an empty dict.  I actually prefer that over null.

--
Regards,

Anthony Liguori



Reply via email to