]> git.proxmox.com Git - qemu.git/commitdiff
error: Replace qemu_error() by error_report()
authorMarkus Armbruster <armbru@redhat.com>
Thu, 18 Feb 2010 16:25:24 +0000 (17:25 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 16 Mar 2010 15:58:32 +0000 (16:58 +0100)
error_report() terminates the message with a newline.  Strip it it
from its arguments.

This fixes a few error messages lacking a newline:
net_handle_fd_param()'s "No file descriptor named %s found", and
tap_open()'s "vnet_hdr=1 requested, but no kernel support for
IFF_VNET_HDR available" (all three versions).

There's one place that passes arguments without newlines
intentionally: load_vmstate().  Fix it up.

29 files changed:
hw/pc.c
hw/pci-hotplug.c
hw/pci.c
hw/qdev.c
hw/scsi-bus.c
hw/scsi-disk.c
hw/scsi-generic.c
hw/usb-bus.c
hw/usb-msd.c
hw/usb-serial.c
hw/virtio-net.c
hw/virtio-pci.c
hw/virtio-serial-bus.c
net.c
net/dump.c
net/slirp.c
net/socket.c
net/tap-bsd.c
net/tap-linux.c
net/tap-solaris.c
net/tap-win32.c
net/tap.c
qemu-config.c
qemu-error.c
qemu-error.h
qemu-tool.c
qerror.c
savevm.c
vl.c

diff --git a/hw/pc.c b/hw/pc.c
index a150f8d9dc690e190da7d3e61b0a0127c422b05f..2b3063df8d743406366596804e474ae6553395c8 100644 (file)
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -238,14 +238,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);
         }
     }
index 41c243c27b614630879acf5f1cecbb5c8d3dd14e..d608a85f192c8a54da3fc7a64cbc0959dff6e293 100644 (file)
@@ -81,7 +81,7 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
 
     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;
     }
 
index eb2043e5003e693d8fe3c3ce7ec6539ae7872372..0dbca173e3de35bd1e4aab125a536fc445ba48f7 100644 (file)
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -589,12 +589,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;
@@ -1476,8 +1476,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;
     }
 
@@ -1768,8 +1768,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)) {
index 8dd995f1a1b9b607e5c97db75b1648a2aad663b9..98123e661026b76c3df70d532562fb4a0d3eaf54 100644 (file)
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -139,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;
@@ -184,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;
     }
 
@@ -195,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;
     }
 
@@ -208,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;
     }
 
@@ -229,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;
@@ -268,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);
@@ -538,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;
@@ -557,13 +557,13 @@ 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) {
-            qemu_error("device \"%s\" not found\n", elem);
+            error_report("device \"%s\" not found", elem);
             qbus_list_dev(bus);
             return NULL;
         }
@@ -572,12 +572,12 @@ 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:
-                qemu_error("device has multiple child busses (%s)\n", path);
+                error_report("device has multiple child busses (%s)", path);
                 qbus_list_bus(dev);
                 return NULL;
             }
@@ -585,13 +585,13 @@ static BusState *qbus_find(const char *path)
 
         /* 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) {
-            qemu_error("child bus \"%s\" not found\n", elem);
+            error_report("child bus \"%s\" not found", elem);
             qbus_list_bus(dev);
             return NULL;
         }
@@ -749,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);
index c41ce9b32a86b05b70f3a7cd87eb1cdc1965f524..383240bc073ce79ad47153be730e9dbba768c609 100644 (file)
@@ -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;
     }
 
index 9cc35f8e97a22ec2f351a057f2cb82eab8712c56..da56d2bc1ce938cddc1598e73aec061b78fe5204 100644 (file)
@@ -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;
     }
 
index cfd990352f02516fc1d83ec093041f4eb0f07caa..c9aa853cc499f77f3eae0bd6e923ddb1225a5bc3 100644 (file)
@@ -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;
     }
 
index 7c823147abbae68dcab07ac12eea36518e5e5366..e2d87f2d1f002ad3b4276650a4a444db5bce70d4 100644 (file)
@@ -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);
index 0afb03133ccaac5246ffbbc8bc961210b3212c23..e90a47e0e19babd614b1addbb81ca81fd7241aa5 100644 (file)
@@ -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;
     }
 
index 6db9446b82324763200cec4ad907567b6bbb8180..69f0e44f11eb2d319895fc22eec1a62bf0ab4c6d 100644 (file)
@@ -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++;
index 8359be69e7dd259e23d6d567a78202087e86838c..be33c68bbc76d95a714bda49ec5a6cf9d5ba5660 100644 (file)
@@ -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;
         }
     }
index 52f8812b0b24a309b5b90c64bc0247edbc6b0f02..6eb19cdf8cd12a9089069d6dc9420cfdd42389b9 100644 (file)
@@ -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);
index d0e021932c8fe227b11a2408e9cb0e7338f1cd45..17c1ec1d06e2aec794be8b7120f08972a8c13dff 100644 (file)
@@ -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;
diff --git a/net.c b/net.c
index e47f727629b6ac542260ec6f1436fc06a480ba25..bb7ab1567a8b47f4aef5da31c4cecd01aeb2914d 100644 (file)
--- a/net.c
+++ b/net.c
@@ -733,7 +733,7 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models,
             return i;
     }
 
-    qemu_error("qemu: Unsupported NIC model: %s\n", nd->model);
+    error_report("qemu: Unsupported NIC model: %s", nd->model);
     return -1;
 }
 
@@ -744,7 +744,7 @@ int net_handle_fd_param(Monitor *mon, const char *param)
 
         fd = monitor_get_fd(mon, param);
         if (fd == -1) {
-            qemu_error("No file descriptor named %s found", param);
+            error_report("No file descriptor named %s found", param);
             return -1;
         }
 
@@ -765,7 +765,7 @@ static int net_init_nic(QemuOpts *opts,
 
     idx = nic_get_free_idx();
     if (idx == -1 || nb_nics >= MAX_NICS) {
-        qemu_error("Too Many NICs\n");
+        error_report("Too Many NICs");
         return -1;
     }
 
@@ -776,7 +776,7 @@ static int net_init_nic(QemuOpts *opts,
     if ((netdev = qemu_opt_get(opts, "netdev"))) {
         nd->netdev = qemu_find_netdev(netdev);
         if (!nd->netdev) {
-            qemu_error("netdev '%s' not found\n", netdev);
+            error_report("netdev '%s' not found", netdev);
             return -1;
         }
     } else {
@@ -802,7 +802,7 @@ static int net_init_nic(QemuOpts *opts,
 
     if (qemu_opt_get(opts, "macaddr") &&
         net_parse_macaddr(nd->macaddr, qemu_opt_get(opts, "macaddr")) < 0) {
-        qemu_error("invalid syntax for ethernet address\n");
+        error_report("invalid syntax for ethernet address");
         return -1;
     }
 
@@ -810,7 +810,7 @@ static int net_init_nic(QemuOpts *opts,
                                        DEV_NVECTORS_UNSPECIFIED);
     if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
         (nd->nvectors < 0 || nd->nvectors > 0x7ffffff)) {
-        qemu_error("invalid # of vectors: %d\n", nd->nvectors);
+        error_report("invalid # of vectors: %d", nd->nvectors);
         return -1;
     }
 
@@ -1060,12 +1060,12 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
 
     if (!is_netdev) {
         if (!type) {
-            qemu_error("No type specified for -net\n");
+            error_report("No type specified for -net");
             return -1;
         }
     } else {
         if (!type) {
-            qemu_error("No type specified for -netdev\n");
+            error_report("No type specified for -netdev");
             return -1;
         }
 
@@ -1077,21 +1077,21 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
             strcmp(type, "vde") != 0 &&
 #endif
             strcmp(type, "socket") != 0) {
-            qemu_error("The '%s' network backend type is not valid with -netdev\n",
-                       type);
+            error_report("The '%s' network backend type is not valid with -netdev",
+                         type);
             return -1;
         }
 
         if (qemu_opt_get(opts, "vlan")) {
-            qemu_error("The 'vlan' parameter is not valid with -netdev\n");
+            error_report("The 'vlan' parameter is not valid with -netdev");
             return -1;
         }
         if (qemu_opt_get(opts, "name")) {
-            qemu_error("The 'name' parameter is not valid with -netdev\n");
+            error_report("The 'name' parameter is not valid with -netdev");
             return -1;
         }
         if (!qemu_opts_id(opts)) {
-            qemu_error("The id= parameter is required with -netdev\n");
+            error_report("The id= parameter is required with -netdev");
             return -1;
         }
     }
@@ -1124,7 +1124,7 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
         }
     }
 
-    qemu_error("Invalid -net type '%s'\n", type);
+    error_report("Invalid -net type '%s'", type);
     return -1;
 }
 
index e702830108db3a25069c23647fb0caf261ea4d1c..6db7ecf95939b53d68cf8025acf82c04015dfd78 100644 (file)
@@ -108,7 +108,7 @@ static int net_dump_init(VLANState *vlan, const char *device,
 
     fd = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644);
     if (fd < 0) {
-        qemu_error("-net dump: can't open %s\n", filename);
+        error_report("-net dump: can't open %s", filename);
         return -1;
     }
 
@@ -121,7 +121,7 @@ static int net_dump_init(VLANState *vlan, const char *device,
     hdr.linktype = 1;
 
     if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {
-        qemu_error("-net dump write error: %s\n", strerror(errno));
+        error_report("-net dump write error: %s", strerror(errno));
         close(fd);
         return -1;
     }
index 7f846ec6f9e6fc95923d61c867003ea659700393..b41c60a39bb65d8bbb7c4143ddde6039aa90164c 100644 (file)
@@ -413,14 +413,14 @@ static int slirp_hostfwd(SlirpState *s, const char *redir_str,
 
     if (slirp_add_hostfwd(s->slirp, is_udp, host_addr, host_port, guest_addr,
                           guest_port) < 0) {
-        qemu_error("could not set up host forwarding rule '%s'\n",
-                   redir_str);
+        error_report("could not set up host forwarding rule '%s'",
+                     redir_str);
         return -1;
     }
     return 0;
 
  fail_syntax:
-    qemu_error("invalid host forwarding rule '%s'\n", redir_str);
+    error_report("invalid host forwarding rule '%s'", redir_str);
     return -1;
 }
 
@@ -473,10 +473,10 @@ static void slirp_smb_cleanup(SlirpState *s)
         snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
         ret = system(cmd);
         if (ret == -1 || !WIFEXITED(ret)) {
-            qemu_error("'%s' failed.\n", cmd);
+            error_report("'%s' failed.", cmd);
         } else if (WEXITSTATUS(ret)) {
-            qemu_error("'%s' failed. Error code: %d\n",
-                    cmd, WEXITSTATUS(ret));
+            error_report("'%s' failed. Error code: %d",
+                         cmd, WEXITSTATUS(ret));
         }
         s->smb_dir[0] = '\0';
     }
@@ -493,7 +493,7 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,
     snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d",
              (long)getpid(), instance++);
     if (mkdir(s->smb_dir, 0700) < 0) {
-        qemu_error("could not create samba server dir '%s'\n", s->smb_dir);
+        error_report("could not create samba server dir '%s'", s->smb_dir);
         return -1;
     }
     snprintf(smb_conf, sizeof(smb_conf), "%s/%s", s->smb_dir, "smb.conf");
@@ -501,8 +501,8 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,
     f = fopen(smb_conf, "w");
     if (!f) {
         slirp_smb_cleanup(s);
-        qemu_error("could not create samba server configuration file '%s'\n",
-                   smb_conf);
+        error_report("could not create samba server configuration file '%s'",
+                     smb_conf);
         return -1;
     }
     fprintf(f,
@@ -533,7 +533,7 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,
 
     if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) {
         slirp_smb_cleanup(s);
-        qemu_error("conflicting/invalid smbserver address\n");
+        error_report("conflicting/invalid smbserver address");
         return -1;
     }
     return 0;
@@ -618,14 +618,14 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str,
     snprintf(buf, sizeof(buf), "guestfwd.tcp:%d", port);
     fwd->hd = qemu_chr_open(buf, p, NULL);
     if (!fwd->hd) {
-        qemu_error("could not open guest forwarding device '%s'\n", buf);
+        error_report("could not open guest forwarding device '%s'", buf);
         qemu_free(fwd);
         return -1;
     }
 
     if (slirp_add_exec(s->slirp, 3, fwd->hd, &server, port) < 0) {
-        qemu_error("conflicting/invalid host:port in guest forwarding "
-                   "rule '%s'\n", config_str);
+        error_report("conflicting/invalid host:port in guest forwarding "
+                     "rule '%s'", config_str);
         qemu_free(fwd);
         return -1;
     }
@@ -638,7 +638,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str,
     return 0;
 
  fail_syntax:
-    qemu_error("invalid guest forwarding rule '%s'\n", config_str);
+    error_report("invalid guest forwarding rule '%s'", config_str);
     return -1;
 }
 
index 474d573a47e0b765d9075e2b47ea7949fc5e3282..1c4e153e3f4bd27c5560f1b9aba37c1f4d4b9d3e 100644 (file)
@@ -506,7 +506,7 @@ int net_init_socket(QemuOpts *opts,
         if (qemu_opt_get(opts, "listen") ||
             qemu_opt_get(opts, "connect") ||
             qemu_opt_get(opts, "mcast")) {
-            qemu_error("listen=, connect= and mcast= is invalid with fd=\n");
+            error_report("listen=, connect= and mcast= is invalid with fd=");
             return -1;
         }
 
@@ -525,7 +525,7 @@ int net_init_socket(QemuOpts *opts,
         if (qemu_opt_get(opts, "fd") ||
             qemu_opt_get(opts, "connect") ||
             qemu_opt_get(opts, "mcast")) {
-            qemu_error("fd=, connect= and mcast= is invalid with listen=\n");
+            error_report("fd=, connect= and mcast= is invalid with listen=");
             return -1;
         }
 
@@ -540,7 +540,7 @@ int net_init_socket(QemuOpts *opts,
         if (qemu_opt_get(opts, "fd") ||
             qemu_opt_get(opts, "listen") ||
             qemu_opt_get(opts, "mcast")) {
-            qemu_error("fd=, listen= and mcast= is invalid with connect=\n");
+            error_report("fd=, listen= and mcast= is invalid with connect=");
             return -1;
         }
 
@@ -555,7 +555,7 @@ int net_init_socket(QemuOpts *opts,
         if (qemu_opt_get(opts, "fd") ||
             qemu_opt_get(opts, "connect") ||
             qemu_opt_get(opts, "listen")) {
-            qemu_error("fd=, connect= and listen= is invalid with mcast=\n");
+            error_report("fd=, connect= and listen= is invalid with mcast=");
             return -1;
         }
 
@@ -565,7 +565,7 @@ int net_init_socket(QemuOpts *opts,
             return -1;
         }
     } else {
-        qemu_error("-socket requires fd=, listen=, connect= or mcast=\n");
+        error_report("-socket requires fd=, listen=, connect= or mcast=");
         return -1;
     }
 
index 815997dc7b0b765844119b28cf3688783aa40a15..e51d06848df1be62ef63d63e7a8418ab3e26c9b2 100644 (file)
@@ -69,7 +69,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
         }
     }
     if (fd < 0) {
-        qemu_error("warning: could not open %s (%s): no virtual network emulation\n", dname, strerror(errno));
+        error_report("warning: could not open %s (%s): no virtual network emulation",
+                   dname, strerror(errno));
         return -1;
     }
 #else
@@ -89,8 +90,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
         *vnet_hdr = 0;
 
         if (vnet_hdr_required && !*vnet_hdr) {
-            qemu_error("vnet_hdr=1 requested, but no kernel "
-                       "support for IFF_VNET_HDR available");
+            error_report("vnet_hdr=1 requested, but no kernel "
+                         "support for IFF_VNET_HDR available");
             close(fd);
             return -1;
         }
index c5748e631b8c8eeb6a8949d2ddd6fff984086f86..03b83012f85656ef5c7d909fda33a12f3c301639 100644 (file)
@@ -58,8 +58,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
         }
 
         if (vnet_hdr_required && !*vnet_hdr) {
-            qemu_error("vnet_hdr=1 requested, but no kernel "
-                       "support for IFF_VNET_HDR available");
+            error_report("vnet_hdr=1 requested, but no kernel "
+                         "support for IFF_VNET_HDR available");
             close(fd);
             return -1;
         }
@@ -97,7 +97,7 @@ int tap_set_sndbuf(int fd, QemuOpts *opts)
     }
 
     if (ioctl(fd, TUNSETSNDBUF, &sndbuf) == -1 && qemu_opt_get(opts, "sndbuf")) {
-        qemu_error("TUNSETSNDBUF ioctl failed: %s\n", strerror(errno));
+        error_report("TUNSETSNDBUF ioctl failed: %s", strerror(errno));
         return -1;
     }
     return 0;
@@ -108,7 +108,7 @@ int tap_probe_vnet_hdr(int fd)
     struct ifreq ifr;
 
     if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
-        qemu_error("TUNGETIFF ioctl() failed: %s\n", strerror(errno));
+        error_report("TUNGETIFF ioctl() failed: %s", strerror(errno));
         return 0;
     }
 
index 0b428617bda7e0af89efc7f39dcec53b7118b329..50d127ad3f52766edc9a9ae972063d4c6bcfe280 100644 (file)
@@ -186,8 +186,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
         *vnet_hdr = 0;
 
         if (vnet_hdr_required && !*vnet_hdr) {
-            qemu_error("vnet_hdr=1 requested, but no kernel "
-                       "support for IFF_VNET_HDR available");
+            error_report("vnet_hdr=1 requested, but no kernel "
+                         "support for IFF_VNET_HDR available");
             close(fd);
             return -1;
         }
index 8370c803bf4373ba8237e6018ef3019e0a1c317c..a5c2ce9e3246bf6af063c517004fa288f71af966 100644 (file)
@@ -706,7 +706,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
     ifname = qemu_opt_get(opts, "ifname");
 
     if (!ifname) {
-        qemu_error("tap: no interface name\n");
+        error_report("tap: no interface name");
         return -1;
     }
 
index 9ba9b4a5d44b9c5131fa644bd009968edd4860cf..672b0ee0b49c226d41f9dc44ce6e8ac8706b41a9 100644 (file)
--- a/net/tap.c
+++ b/net/tap.c
@@ -394,7 +394,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
             qemu_opt_get(opts, "script") ||
             qemu_opt_get(opts, "downscript") ||
             qemu_opt_get(opts, "vnet_hdr")) {
-            qemu_error("ifname=, script=, downscript= and vnet_hdr= is invalid with fd=\n");
+            error_report("ifname=, script=, downscript= and vnet_hdr= is invalid with fd=");
             return -1;
         }
 
index 2c9a7a5f2daa93ab941dc8e92f91c72911e7b5b6..8e06770a1d7ab5ab676b7fa38e73696e05883e72 100644 (file)
@@ -313,7 +313,7 @@ static QemuOptsList *find_list(const char *group)
             break;
     }
     if (lists[i] == NULL) {
-        qemu_error("there is no option group \"%s\"\n", group);
+        error_report("there is no option group \"%s\"", group);
     }
     return lists[i];
 }
@@ -327,7 +327,7 @@ int qemu_set_option(const char *str)
 
     rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset);
     if (rc < 3 || str[offset] != '=') {
-        qemu_error("can't parse: \"%s\"\n", str);
+        error_report("can't parse: \"%s\"", str);
         return -1;
     }
 
@@ -338,8 +338,8 @@ int qemu_set_option(const char *str)
 
     opts = qemu_opts_find(list, id);
     if (!opts) {
-        qemu_error("there is no %s \"%s\" defined\n",
-                   list->name, id);
+        error_report("there is no %s \"%s\" defined",
+                     list->name, id);
         return -1;
     }
 
@@ -357,7 +357,7 @@ int qemu_global_option(const char *str)
 
     rc = sscanf(str, "%63[^.].%63[^=]%n", driver, property, &offset);
     if (rc < 2 || str[offset] != '=') {
-        qemu_error("can't parse: \"%s\"\n", str);
+        error_report("can't parse: \"%s\"", str);
         return -1;
     }
 
index d20fd0f4d2868417974f6ab31d54f4f0cc6b307a..51e2abf63668b83fb1ff3685e54d7bc4f113c3a7 100644 (file)
@@ -41,13 +41,19 @@ void error_printf(const char *fmt, ...)
     va_end(ap);
 }
 
-void qemu_error(const char *fmt, ...)
+/*
+ * Print an error message to current monitor if we have one, else to stderr.
+ * Appends a newline to the message.
+ * It's wrong to call this in a QMP monitor.  Use qemu_error_new() there.
+ */
+void error_report(const char *fmt, ...)
 {
     va_list ap;
 
     va_start(ap, fmt);
     error_vprintf(fmt, ap);
     va_end(ap);
+    error_printf("\n");
 }
 
 void qemu_error_internal(const char *file, int linenr, const char *func,
index d90f1daec0f011e03cb6d9166716cc2d21b4a594..99dfccedb109e05e056c2f2d9ba71d22f7e53776 100644 (file)
@@ -15,7 +15,7 @@
 
 void error_vprintf(const char *fmt, va_list ap);
 void error_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
-void qemu_error(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
+void error_report(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
 void qemu_error_internal(const char *file, int linenr, const char *func,
                          const char *fmt, ...)
                          __attribute__ ((format(printf, 4, 5)));
index 26f46eb09caee91c75db64405bd6e2c908833cc3..939049a9a148a4e9e14b48293cf4b192b73600f7 100644 (file)
@@ -104,7 +104,7 @@ int64_t qemu_get_clock(QEMUClock *clock)
     return (tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000)) / 1000000;
 }
 
-void qemu_error(const char *fmt, ...)
+void error_report(const char *fmt, ...)
 {
     va_list args;
 
index a418bde37f5b0fcf0cec8ad51505d56adbd9c80b..a6f021395aa331390d92b903609f1cafa3452436 100644 (file)
--- a/qerror.c
+++ b/qerror.c
@@ -318,13 +318,13 @@ QString *qerror_human(const QError *qerror)
  * qerror_print(): Print QError data
  *
  * This function will print the member 'desc' of the specified QError object,
- * it uses qemu_error() for this, so that the output is routed to the right
+ * it uses error_report() for this, so that the output is routed to the right
  * place (ie. stderr or Monitor's device).
  */
 void qerror_print(const QError *qerror)
 {
     QString *qstring = qerror_human(qerror);
-    qemu_error("%s\n", qstring_get_str(qstring));
+    error_report("%s", qstring_get_str(qstring));
     QDECREF(qstring);
 }
 
index b634686e4f6c141fa30e6fc17bfd2db1eb1f4edc..bee1be18a566291baddffcefe140c1b3b40b1e74 100644 (file)
--- a/savevm.c
+++ b/savevm.c
@@ -1747,7 +1747,7 @@ int load_vmstate(const char *name)
 
     bs = get_bs_snapshots();
     if (!bs) {
-        qemu_error("No block device supports snapshots\n");
+        error_report("No block device supports snapshots");
         return -EINVAL;
     }
 
@@ -1759,20 +1759,21 @@ int load_vmstate(const char *name)
         if (bdrv_has_snapshot(bs1)) {
             ret = bdrv_snapshot_goto(bs1, name);
             if (ret < 0) {
-                if (bs != bs1)
-                    qemu_error("Warning: ");
                 switch(ret) {
                 case -ENOTSUP:
-                    qemu_error("Snapshots not supported on device '%s'\n",
-                               bdrv_get_device_name(bs1));
+                    error_report("%sSnapshots not supported on device '%s'",
+                                 bs != bs1 ? "Warning: " : "",
+                                 bdrv_get_device_name(bs1));
                     break;
                 case -ENOENT:
-                    qemu_error("Could not find snapshot '%s' on device '%s'\n",
-                               name, bdrv_get_device_name(bs1));
+                    error_report("%sCould not find snapshot '%s' on device '%s'",
+                                 bs != bs1 ? "Warning: " : "",
+                                 name, bdrv_get_device_name(bs1));
                     break;
                 default:
-                    qemu_error("Error %d while activating snapshot on '%s'\n",
-                               ret, bdrv_get_device_name(bs1));
+                    error_report("%sError %d while activating snapshot on '%s'",
+                                 bs != bs1 ? "Warning: " : "",
+                                 ret, bdrv_get_device_name(bs1));
                     break;
                 }
                 /* fatal on snapshot block device */
@@ -1790,13 +1791,13 @@ int load_vmstate(const char *name)
     /* restore the VM state */
     f = qemu_fopen_bdrv(bs, 0);
     if (!f) {
-        qemu_error("Could not open VM state file\n");
+        error_report("Could not open VM state file");
         return -EINVAL;
     }
     ret = qemu_loadvm_state(f);
     qemu_fclose(f);
     if (ret < 0) {
-        qemu_error("Error %d while loading VM state\n", ret);
+        error_report("Error %d while loading VM state", ret);
         return ret;
     }
     return 0;
diff --git a/vl.c b/vl.c
index 99d6ec1d609233baf885078025a7dc735d68971f..160f30a3205c237628224f0b2f33e2a3ce4ba667 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -2539,7 +2539,7 @@ void do_usb_add(Monitor *mon, const QDict *qdict)
 {
     const char *devname = qdict_get_str(qdict, "devname");
     if (usb_device_add(devname, 1) < 0) {
-        qemu_error("could not add USB device '%s'\n", devname);
+        error_report("could not add USB device '%s'", devname);
     }
 }
 
@@ -2547,7 +2547,7 @@ void do_usb_del(Monitor *mon, const QDict *qdict)
 {
     const char *devname = qdict_get_str(qdict, "devname");
     if (usb_device_del(devname) < 0) {
-        qemu_error("could not delete USB device '%s'\n", devname);
+        error_report("could not delete USB device '%s'", devname);
     }
 }