diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2010-04-05 19:05:39 -0300 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2010-04-05 19:05:39 -0300 |
commit | f43d541cb9ee6c40ae2af2ea37aa17f966264277 (patch) | |
tree | d8e7f9497ac6aac8779db11252c8fc1b5beae739 /hw | |
parent | afc6763567e6f43b8421f4d8db13e9257c9566c6 (diff) | |
parent | 1ecda02b24a13f501e747b8442934829d82698ae (diff) |
Merge commit '1ecda02b24a13f501e747b8442934829d82698ae' into upstream-merge
* commit '1ecda02b24a13f501e747b8442934829d82698ae':
error: Replace qemu_error() by error_report()
error: Don't abuse qemu_error() for non-error in scsi_hot_add()
error: Don't abuse qemu_error() for non-error in qbus_find()
error: Don't abuse qemu_error() for non-error in qdev_device_help()
error: New error_printf() and error_vprintf()
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/device-assignment.c | 6 | ||||
-rw-r--r-- | hw/pc.c | 6 | ||||
-rw-r--r-- | hw/pci-hotplug.c | 12 | ||||
-rw-r--r-- | hw/pci.c | 14 | ||||
-rw-r--r-- | hw/qdev.c | 104 | ||||
-rw-r--r-- | hw/scsi-bus.c | 2 | ||||
-rw-r--r-- | hw/scsi-disk.c | 4 | ||||
-rw-r--r-- | hw/scsi-generic.c | 8 | ||||
-rw-r--r-- | hw/usb-bus.c | 4 | ||||
-rw-r--r-- | hw/usb-msd.c | 2 | ||||
-rw-r--r-- | hw/usb-serial.c | 8 | ||||
-rw-r--r-- | hw/virtio-net.c | 4 | ||||
-rw-r--r-- | hw/virtio-pci.c | 2 | ||||
-rw-r--r-- | hw/virtio-serial-bus.c | 2 |
14 files changed, 83 insertions, 95 deletions
diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 00c10f2e3..8e3cf3827 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -1330,14 +1330,14 @@ static int assigned_initfn(struct PCIDevice *pci_dev) int r; if (!dev->host.seg && !dev->host.bus && !dev->host.dev && !dev->host.func) { - qemu_error("pci-assign: error: no host device specified\n"); + error_report("pci-assign: error: no host device specified"); goto out; } if (get_real_device(dev, dev->host.seg, dev->host.bus, dev->host.dev, dev->host.func)) { - qemu_error("pci-assign: Error: Couldn't get real device (%s)!\n", - dev->dev.qdev.id); + error_report("pci-assign: Error: Couldn't get real device (%s)!", + dev->dev.qdev.id); goto out; } @@ -245,14 +245,14 @@ static int set_boot_dev(RTCState *s, const char *boot_device, int fd_bootchk) nbds = strlen(boot_device); if (nbds > PC_MAX_BOOT_DEVICES) { - qemu_error("Too many boot devices for PC\n"); + error_report("Too many boot devices for PC"); return(1); } for (i = 0; i < nbds; i++) { bds[i] = boot_device2nibble(boot_device[i]); if (bds[i] == 0) { - qemu_error("Invalid boot device for PC: '%c'\n", - boot_device[i]); + error_report("Invalid boot device for PC: '%c'", + boot_device[i]); return(1); } } diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index b89580fee..36511941b 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -74,14 +74,15 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon, return pci_nic_init(&nd_table[ret], "rtl8139", devaddr); } -static int scsi_hot_add(DeviceState *adapter, DriveInfo *dinfo, int printinfo) +static int scsi_hot_add(Monitor *mon, DeviceState *adapter, + DriveInfo *dinfo, int printinfo) { SCSIBus *scsibus; SCSIDevice *scsidev; scsibus = DO_UPCAST(SCSIBus, qbus, QLIST_FIRST(&adapter->child_bus)); if (!scsibus || strcmp(scsibus->qbus.info->name, "SCSI") != 0) { - qemu_error("Device is not a SCSI adapter\n"); + error_report("Device is not a SCSI adapter"); return -1; } @@ -98,7 +99,8 @@ static int scsi_hot_add(DeviceState *adapter, DriveInfo *dinfo, int printinfo) dinfo->unit = scsidev->id; if (printinfo) - qemu_error("OK bus %d, unit %d\n", scsibus->busnr, scsidev->id); + monitor_printf(mon, "OK bus %d, unit %d\n", + scsibus->busnr, scsidev->id); return 0; } @@ -132,7 +134,7 @@ void drive_hot_add(Monitor *mon, const QDict *qdict) monitor_printf(mon, "no pci device with address %s\n", pci_addr); goto err; } - if (scsi_hot_add(&dev->qdev, dinfo, 1) != 0) { + if (scsi_hot_add(mon, &dev->qdev, dinfo, 1) != 0) { goto err; } break; @@ -204,7 +206,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, if (qdev_init(&dev->qdev) < 0) dev = NULL; if (dev && dinfo) { - if (scsi_hot_add(&dev->qdev, dinfo, 0) != 0) { + if (scsi_hot_add(mon, &dev->qdev, dinfo, 0) != 0) { qdev_unplug(&dev->qdev); dev = NULL; } @@ -670,12 +670,12 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, if (!bus->devices[devfn]) goto found; } - qemu_error("PCI: no devfn available for %s, all in use\n", name); + error_report("PCI: no devfn available for %s, all in use", name); return NULL; found: ; } else if (bus->devices[devfn]) { - qemu_error("PCI: devfn %d not available for %s, in use by %s\n", devfn, - name, bus->devices[devfn]->name); + error_report("PCI: devfn %d not available for %s, in use by %s", + devfn, name, bus->devices[devfn]->name); return NULL; } pci_dev->bus = bus; @@ -1621,8 +1621,8 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, bus = pci_get_bus_devfn(&devfn, devaddr); if (!bus) { - qemu_error("Invalid PCI device address %s for device %s\n", - devaddr, pci_nic_names[i]); + error_report("Invalid PCI device address %s for device %s", + devaddr, pci_nic_names[i]); return NULL; } @@ -1944,8 +1944,8 @@ static int pci_add_option_rom(PCIDevice *pdev) size = get_image_size(path); if (size < 0) { - qemu_error("%s: failed to find romfile \"%s\"\n", __FUNCTION__, - pdev->romfile); + error_report("%s: failed to find romfile \"%s\"", + __FUNCTION__, pdev->romfile); return -1; } if (size & (size - 1)) { @@ -113,27 +113,20 @@ DeviceState *qdev_create(BusState *bus, const char *name) return dev; } -static int qdev_print_devinfo(DeviceInfo *info, char *dest, int len) +static void qdev_print_devinfo(DeviceInfo *info) { - int pos = 0; - int ret; - - ret = snprintf(dest+pos, len-pos, "name \"%s\", bus %s", - info->name, info->bus_info->name); - pos += MIN(len-pos,ret); + error_printf("name \"%s\", bus %s", + info->name, info->bus_info->name); if (info->alias) { - ret = snprintf(dest+pos, len-pos, ", alias \"%s\"", info->alias); - pos += MIN(len-pos,ret); + error_printf(", alias \"%s\"", info->alias); } if (info->desc) { - ret = snprintf(dest+pos, len-pos, ", desc \"%s\"", info->desc); - pos += MIN(len-pos,ret); + error_printf(", desc \"%s\"", info->desc); } if (info->no_user) { - ret = snprintf(dest+pos, len-pos, ", no-user"); - pos += MIN(len-pos,ret); + error_printf(", no-user"); } - return pos; + error_printf("\n"); } static int set_property(const char *name, const char *value, void *opaque) @@ -146,8 +139,8 @@ static int set_property(const char *name, const char *value, void *opaque) return 0; if (qdev_prop_parse(dev, name, value) == -1) { - qemu_error("can't set property \"%s\" to \"%s\" for \"%s\"\n", - name, value, dev->info->name); + error_report("can't set property \"%s\" to \"%s\" for \"%s\"", + name, value, dev->info->name); return -1; } return 0; @@ -157,14 +150,12 @@ int qdev_device_help(QemuOpts *opts) { const char *driver; DeviceInfo *info; - char msg[256]; Property *prop; driver = qemu_opt_get(opts, "driver"); if (driver && !strcmp(driver, "?")) { for (info = device_info_list; info != NULL; info = info->next) { - qdev_print_devinfo(info, msg, sizeof(msg)); - qemu_error("%s\n", msg); + qdev_print_devinfo(info); } return 1; } @@ -179,7 +170,7 @@ int qdev_device_help(QemuOpts *opts) } for (prop = info->props; prop && prop->name; prop++) { - qemu_error("%s.%s=%s\n", info->name, prop->name, prop->info->name); + error_printf("%s.%s=%s\n", info->name, prop->name, prop->info->name); } return 1; } @@ -193,7 +184,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) driver = qemu_opt_get(opts, "driver"); if (!driver) { - qemu_error("-device: no driver specified\n"); + error_report("-device: no driver specified"); return NULL; } @@ -204,8 +195,8 @@ DeviceState *qdev_device_add(QemuOpts *opts) return NULL; } if (info->no_user) { - qemu_error("device \"%s\" can't be added via command line\n", - info->name); + error_report("device \"%s\" can't be added via command line", + info->name); return NULL; } @@ -217,13 +208,13 @@ DeviceState *qdev_device_add(QemuOpts *opts) bus = qbus_find_recursive(main_system_bus, NULL, info->bus_info); } if (!bus) { - qemu_error("Did not find %s bus for %s\n", - path ? path : info->bus_info->name, info->name); + error_report("Did not find %s bus for %s", + path ? path : info->bus_info->name, info->name); return NULL; } if (qdev_hotplug && !bus->allow_hotplug) { - qemu_error("Bus %s does not support hotplugging\n", - bus->name); + error_report("Bus %s does not support hotplugging", + bus->name); return NULL; } @@ -238,7 +229,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) return NULL; } if (qdev_init(qdev) < 0) { - qemu_error("Error initializing device %s\n", driver); + error_report("Error initializing device %s", driver); return NULL; } qdev->opts = opts; @@ -277,8 +268,8 @@ int qdev_init(DeviceState *dev) int qdev_unplug(DeviceState *dev) { if (!dev->parent_bus->allow_hotplug) { - qemu_error("Bus %s does not support hotplugging\n", - dev->parent_bus->name); + error_report("Bus %s does not support hotplugging", + dev->parent_bus->name); return -1; } assert(dev->info->unplug != NULL); @@ -465,35 +456,33 @@ static DeviceState *qdev_find_recursive(BusState *bus, const char *id) return NULL; } -static void qbus_list_bus(DeviceState *dev, char *dest, int len) +static void qbus_list_bus(DeviceState *dev) { BusState *child; const char *sep = " "; - int pos = 0; - pos += snprintf(dest+pos, len-pos,"child busses at \"%s\":", - dev->id ? dev->id : dev->info->name); + error_printf("child busses at \"%s\":", + dev->id ? dev->id : dev->info->name); QLIST_FOREACH(child, &dev->child_bus, sibling) { - pos += snprintf(dest+pos, len-pos, "%s\"%s\"", sep, child->name); + error_printf("%s\"%s\"", sep, child->name); sep = ", "; } + error_printf("\n"); } -static void qbus_list_dev(BusState *bus, char *dest, int len) +static void qbus_list_dev(BusState *bus) { DeviceState *dev; const char *sep = " "; - int pos = 0; - pos += snprintf(dest+pos, len-pos, "devices at \"%s\":", - bus->name); + error_printf("devices at \"%s\":", bus->name); QLIST_FOREACH(dev, &bus->children, sibling) { - pos += snprintf(dest+pos, len-pos, "%s\"%s\"", - sep, dev->info->name); + error_printf("%s\"%s\"", sep, dev->info->name); if (dev->id) - pos += snprintf(dest+pos, len-pos, "/\"%s\"", dev->id); + error_printf("/\"%s\"", dev->id); sep = ", "; } + error_printf("\n"); } static BusState *qbus_find_bus(DeviceState *dev, char *elem) @@ -540,7 +529,7 @@ static BusState *qbus_find(const char *path) { DeviceState *dev; BusState *bus; - char elem[128], msg[256]; + char elem[128]; int pos, len; /* find start element */ @@ -549,12 +538,12 @@ static BusState *qbus_find(const char *path) pos = 0; } else { if (sscanf(path, "%127[^/]%n", elem, &len) != 1) { - qemu_error("path parse error (\"%s\")\n", path); + error_report("path parse error (\"%s\")", path); return NULL; } bus = qbus_find_recursive(main_system_bus, elem, NULL); if (!bus) { - qemu_error("bus \"%s\" not found\n", elem); + error_report("bus \"%s\" not found", elem); return NULL; } pos = len; @@ -568,14 +557,14 @@ static BusState *qbus_find(const char *path) /* find device */ if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) { - qemu_error("path parse error (\"%s\" pos %d)\n", path, pos); + error_report("path parse error (\"%s\" pos %d)", path, pos); return NULL; } pos += len; dev = qbus_find_dev(bus, elem); if (!dev) { - qbus_list_dev(bus, msg, sizeof(msg)); - qemu_error("device \"%s\" not found\n%s\n", elem, msg); + error_report("device \"%s\" not found", elem); + qbus_list_dev(bus); return NULL; } if (path[pos] == '\0') { @@ -583,28 +572,27 @@ static BusState *qbus_find(const char *path) * one child bus accept it nevertheless */ switch (dev->num_child_bus) { case 0: - qemu_error("device has no child bus (%s)\n", path); + error_report("device has no child bus (%s)", path); return NULL; case 1: return QLIST_FIRST(&dev->child_bus); default: - qbus_list_bus(dev, msg, sizeof(msg)); - qemu_error("device has multiple child busses (%s)\n%s\n", - path, msg); + error_report("device has multiple child busses (%s)", path); + qbus_list_bus(dev); return NULL; } } /* find bus */ if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) { - qemu_error("path parse error (\"%s\" pos %d)\n", path, pos); + error_report("path parse error (\"%s\" pos %d)", path, pos); return NULL; } pos += len; bus = qbus_find_bus(dev, elem); if (!bus) { - qbus_list_bus(dev, msg, sizeof(msg)); - qemu_error("child bus \"%s\" not found\n%s\n", elem, msg); + error_report("child bus \"%s\" not found", elem); + qbus_list_bus(dev); return NULL; } } @@ -735,11 +723,9 @@ void do_info_qtree(Monitor *mon) void do_info_qdm(Monitor *mon) { DeviceInfo *info; - char msg[256]; for (info = device_info_list; info != NULL; info = info->next) { - qdev_print_devinfo(info, msg, sizeof(msg)); - monitor_printf(mon, "%s\n", msg); + qdev_print_devinfo(info); } } @@ -763,7 +749,7 @@ void do_device_del(Monitor *mon, const QDict *qdict) dev = qdev_find_recursive(main_system_bus, id); if (NULL == dev) { - qemu_error("Device '%s' not found\n", id); + error_report("Device '%s' not found", id); return; } qdev_unplug(dev); diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index c41ce9b32..383240bc0 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -41,7 +41,7 @@ static int scsi_qdev_init(DeviceState *qdev, DeviceInfo *base) } } if (dev->id >= bus->ndev) { - qemu_error("bad scsi device id: %d\n", dev->id); + error_report("bad scsi device id: %d", dev->id); goto err; } diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 9cc35f8e9..da56d2bc1 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1025,13 +1025,13 @@ static int scsi_disk_initfn(SCSIDevice *dev) uint64_t nb_sectors; if (!s->qdev.conf.dinfo || !s->qdev.conf.dinfo->bdrv) { - qemu_error("scsi-disk: drive property not set\n"); + error_report("scsi-disk: drive property not set"); return -1; } s->bs = s->qdev.conf.dinfo->bdrv; if (bdrv_is_sg(s->bs)) { - qemu_error("scsi-disk: unwanted /dev/sg*\n"); + error_report("scsi-disk: unwanted /dev/sg*"); return -1; } diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index cfd990352..c9aa853cc 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -464,27 +464,27 @@ static int scsi_generic_initfn(SCSIDevice *dev) struct sg_scsi_id scsiid; if (!s->qdev.conf.dinfo || !s->qdev.conf.dinfo->bdrv) { - qemu_error("scsi-generic: drive property not set\n"); + error_report("scsi-generic: drive property not set"); return -1; } s->bs = s->qdev.conf.dinfo->bdrv; /* check we are really using a /dev/sg* file */ if (!bdrv_is_sg(s->bs)) { - qemu_error("scsi-generic: not /dev/sg*\n"); + error_report("scsi-generic: not /dev/sg*"); return -1; } /* check we are using a driver managing SG_IO (version 3 and after */ if (bdrv_ioctl(s->bs, SG_GET_VERSION_NUM, &sg_version) < 0 || sg_version < 30000) { - qemu_error("scsi-generic: scsi generic interface too old\n"); + error_report("scsi-generic: scsi generic interface too old"); return -1; } /* get LUN of the /dev/sg? */ if (bdrv_ioctl(s->bs, SG_GET_SCSI_ID, &scsiid)) { - qemu_error("scsi-generic: SG_GET_SCSI_ID ioctl failed\n"); + error_report("scsi-generic: SG_GET_SCSI_ID ioctl failed"); return -1; } diff --git a/hw/usb-bus.c b/hw/usb-bus.c index 7c823147a..e2d87f2d1 100644 --- a/hw/usb-bus.c +++ b/hw/usb-bus.c @@ -291,14 +291,14 @@ USBDevice *usbdevice_create(const char *cmdline) if (info == NULL) { #if 0 /* no error because some drivers are not converted (yet) */ - qemu_error("usbdevice %s not found\n", driver); + error_report("usbdevice %s not found", driver); #endif return NULL; } if (!usb->usbdevice_init) { if (params) { - qemu_error("usbdevice %s accepts no params\n", driver); + error_report("usbdevice %s accepts no params", driver); return NULL; } return usb_create_simple(bus, usb->qdev.name); diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 0afb03133..e90a47e0e 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -524,7 +524,7 @@ static int usb_msd_initfn(USBDevice *dev) MSDState *s = DO_UPCAST(MSDState, dev, dev); if (!s->conf.dinfo || !s->conf.dinfo->bdrv) { - qemu_error("usb-msd: drive property not set\n"); + error_report("usb-msd: drive property not set"); return -1; } diff --git a/hw/usb-serial.c b/hw/usb-serial.c index 6db9446b8..69f0e44f1 100644 --- a/hw/usb-serial.c +++ b/hw/usb-serial.c @@ -565,26 +565,26 @@ static USBDevice *usb_serial_init(const char *filename) if (strstart(filename, "vendorid=", &p)) { vendorid = strtol(p, &e, 16); if (e == p || (*e && *e != ',' && *e != ':')) { - qemu_error("bogus vendor ID %s\n", p); + error_report("bogus vendor ID %s", p); return NULL; } filename = e; } else if (strstart(filename, "productid=", &p)) { productid = strtol(p, &e, 16); if (e == p || (*e && *e != ',' && *e != ':')) { - qemu_error("bogus product ID %s\n", p); + error_report("bogus product ID %s", p); return NULL; } filename = e; } else { - qemu_error("unrecognized serial USB option %s\n", filename); + error_report("unrecognized serial USB option %s", filename); return NULL; } while(*filename == ',') filename++; } if (!*filename) { - qemu_error("character device specification needed\n"); + error_report("character device specification needed"); return NULL; } filename++; diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 8359be69e..be33c68bb 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -765,7 +765,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) if (version_id >= 7) { if (qemu_get_be32(f) && !peer_has_vnet_hdr(n)) { - qemu_error("virtio-net: saved image requires vnet_hdr=on\n"); + error_report("virtio-net: saved image requires vnet_hdr=on"); return -1; } @@ -794,7 +794,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) if (version_id >= 11) { if (qemu_get_byte(f) && !peer_has_ufo(n)) { - qemu_error("virtio-net: saved image requires TUN_F_UFO support\n"); + error_report("virtio-net: saved image requires TUN_F_UFO support"); return -1; } } diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 52f8812b0..6eb19cdf8 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -459,7 +459,7 @@ static int virtio_blk_init_pci(PCIDevice *pci_dev) proxy->class_code = PCI_CLASS_STORAGE_SCSI; if (!proxy->block.dinfo) { - qemu_error("virtio-blk-pci: drive property not set\n"); + error_report("virtio-blk-pci: drive property not set"); return -1; } vdev = virtio_blk_init(&pci_dev->qdev, &proxy->block); diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index d0e021932..17c1ec1d0 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -485,7 +485,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base) plugging_port0 = port->is_console && !find_port_by_id(port->vser, 0); if (port->vser->config.nr_ports == bus->max_nr_ports && !plugging_port0) { - qemu_error("virtio-serial-bus: Maximum device limit reached\n"); + error_report("virtio-serial-bus: Maximum device limit reached"); return -1; } dev->info = info; |