qdev error logging

Use the new qemu_error() function in qdev.c

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Gerd Hoffmann 2009-08-14 10:36:08 +02:00 committed by Anthony Liguori
parent 84fc5589f8
commit 286c2321ec

View file

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