diff mbox

[4/4] qdev error logging

Message ID 1250238968-2114-4-git-send-email-kraxel@redhat.com
State Superseded
Headers show

Commit Message

Gerd Hoffmann Aug. 14, 2009, 8:36 a.m. UTC
Use the new qemu_error() function in qdev.c

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qdev.c |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

Comments

Markus Armbruster Aug. 21, 2009, 4:16 p.m. UTC | #1
2/4 - 4/4 also look good to me.  More places remain to be converted to
qemu_error(), but that shouldn't delay this patch series.
diff mbox

Patch

diff --git a/hw/qdev.c b/hw/qdev.c
index 1b7d963..ff2f096 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -138,8 +138,8 @@  static int set_property(const char *name, const char *value, void *opaque)
         return 0;
 
     if (-1 == qdev_prop_parse(dev, name, value)) {
-        fprintf(stderr, "can't set property \"%s\" to \"%s\" for \"%s\"\n",
-                name, value, dev->info->name);
+        qemu_error("can't set property \"%s\" to \"%s\" for \"%s\"\n",
+                   name, value, dev->info->name);
         return -1;
     }
     return 0;
@@ -154,14 +154,14 @@  DeviceState *qdev_device_add(QemuOpts *opts)
 
     driver = qemu_opt_get(opts, "driver");
     if (!driver) {
-        fprintf(stderr, "-device: no driver specified\n");
+        qemu_error("-device: no driver specified\n");
         return NULL;
     }
     if (strcmp(driver, "?") == 0) {
         char msg[256];
         for (info = device_info_list; info != NULL; info = info->next) {
             qdev_print_devinfo(info, msg, sizeof(msg));
-            fprintf(stderr, "%s\n", msg);
+            qemu_error("%s\n", msg);
         }
         return NULL;
     }
@@ -169,13 +169,13 @@  DeviceState *qdev_device_add(QemuOpts *opts)
     /* find driver */
     info = qdev_find_info(NULL, driver);
     if (!info) {
-        fprintf(stderr, "Device \"%s\" not found.  Try -device '?' for a list.\n",
-                driver);
+        qemu_error("Device \"%s\" not found.  Try -device '?' for a list.\n",
+                   driver);
         return NULL;
     }
     if (info->no_user) {
-        fprintf(stderr, "device \"%s\" can't be added via command line\n",
-                info->name);
+        qemu_error("device \"%s\" can't be added via command line\n",
+                   info->name);
         return NULL;
     }
 
@@ -442,12 +442,12 @@  static BusState *qbus_find(const char *path)
         pos = 0;
     } else {
         if (sscanf(path, "%127[^/]%n", elem, &len) != 1) {
-            fprintf(stderr, "path parse error (\"%s\")\n", path);
+            qemu_error("path parse error (\"%s\")\n", path);
             return NULL;
         }
         bus = qbus_find_recursive(main_system_bus, elem, NULL);
         if (!bus) {
-            fprintf(stderr, "bus \"%s\" not found\n", elem);
+            qemu_error("bus \"%s\" not found\n", elem);
             return NULL;
         }
         pos = len;
@@ -461,14 +461,14 @@  static BusState *qbus_find(const char *path)
 
         /* find device */
         if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) {
-            fprintf(stderr, "path parse error (\"%s\" pos %d)\n", path, pos);
+            qemu_error("path parse error (\"%s\" pos %d)\n", path, pos);
             return NULL;
         }
         pos += len;
         dev = qbus_find_dev(bus, elem);
         if (!dev) {
             qbus_list_dev(bus, msg, sizeof(msg));
-            fprintf(stderr, "device \"%s\" not found\n%s\n", elem, msg);
+            qemu_error("device \"%s\" not found\n%s\n", elem, msg);
             return NULL;
         }
         if (path[pos] == '\0') {
@@ -476,28 +476,28 @@  static BusState *qbus_find(const char *path)
              * one child bus accept it nevertheless */
             switch (dev->num_child_bus) {
             case 0:
-                fprintf(stderr, "device has no child bus (%s)\n", path);
+                qemu_error("device has no child bus (%s)\n", path);
                 return NULL;
             case 1:
                 return LIST_FIRST(&dev->child_bus);
             default:
                 qbus_list_bus(dev, msg, sizeof(msg));
-                fprintf(stderr, "device has multiple child busses (%s)\n%s\n",
-                        path, msg);
+                qemu_error("device has multiple child busses (%s)\n%s\n",
+                           path, msg);
                 return NULL;
             }
         }
 
         /* find bus */
         if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) {
-            fprintf(stderr, "path parse error (\"%s\" pos %d)\n", path, pos);
+            qemu_error("path parse error (\"%s\" pos %d)\n", path, pos);
             return NULL;
         }
         pos += len;
         bus = qbus_find_bus(dev, elem);
         if (!bus) {
             qbus_list_bus(dev, msg, sizeof(msg));
-            fprintf(stderr, "child bus \"%s\" not found\n%s\n", elem, msg);
+            qemu_error("child bus \"%s\" not found\n%s\n", elem, msg);
             return NULL;
         }
     }