Patchwork [v2,06/15] qdev: Push QMP mode checks into qbus_list_bus/dev

login
register
mail settings
Submitter Jan Kiszka
Date May 22, 2010, 8:18 a.m.
Message ID <94cfebce71a4a511672068166e60df770a16b02f.1274516288.git.jan.kiszka@web.de>
Download mbox | patch
Permalink /patch/53250/
State New
Headers show

Comments

Jan Kiszka - May 22, 2010, 8:18 a.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

Simplifies the usage.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/qdev.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

Patch

diff --git a/hw/qdev.c b/hw/qdev.c
index fa611a1..db005ce 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -492,6 +492,9 @@  static void qbus_list_bus(DeviceState *dev)
     BusState *child;
     const char *sep = " ";
 
+    if (monitor_cur_is_qmp()) {
+        return;
+    }
     error_printf("child busses at \"%s\":",
                  dev->id ? dev->id : dev->info->name);
     QTAILQ_FOREACH(child, &dev->child_bus, sibling) {
@@ -506,6 +509,9 @@  static void qbus_list_dev(BusState *bus)
     DeviceState *dev;
     const char *sep = " ";
 
+    if (monitor_cur_is_qmp()) {
+        return;
+    }
     error_printf("devices at \"%s\":", bus->name);
     QTAILQ_FOREACH(dev, &bus->children, sibling) {
         error_printf("%s\"%s\"", sep, dev->info->name);
@@ -611,9 +617,7 @@  static BusState *qbus_find(const char *path)
         dev = qbus_find_dev(bus, elem);
         if (!dev) {
             qerror_report(QERR_DEVICE_NOT_FOUND, elem);
-            if (!monitor_cur_is_qmp()) {
-                qbus_list_dev(bus);
-            }
+            qbus_list_dev(bus);
             return NULL;
         }
 
@@ -633,9 +637,7 @@  search_dev_bus:
                 return QTAILQ_FIRST(&dev->child_bus);
             default:
                 qerror_report(QERR_DEVICE_MULTIPLE_BUSSES, elem);
-                if (!monitor_cur_is_qmp()) {
-                    qbus_list_bus(dev);
-                }
+                qbus_list_bus(dev);
                 return NULL;
             }
         }
@@ -658,9 +660,7 @@  search_dev_bus:
                 }
             }
             qerror_report(QERR_BUS_NOT_FOUND, elem);
-            if (!monitor_cur_is_qmp()) {
-                qbus_list_bus(dev);
-            }
+            qbus_list_bus(dev);
             return NULL;
         }
     }
@@ -697,9 +697,7 @@  static DeviceState *qdev_find(const char *path)
     dev = qbus_find_dev(bus, dev_name);
     if (!dev) {
         qerror_report(QERR_DEVICE_NOT_FOUND, dev_name);
-        if (!monitor_cur_is_qmp()) {
-            qbus_list_dev(bus);
-        }
+        qbus_list_dev(bus);
     }
     return dev;
 }