Patchwork [RFC,13/48] error: Make qemu_error() add a newline, strip it from arguments

login
register
mail settings
Submitter Markus Armbruster
Date Feb. 24, 2010, 5:55 p.m.
Message ID <1267034160-3517-14-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/46160/
State New
Headers show

Comments

Markus Armbruster - Feb. 24, 2010, 5:55 p.m.
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.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/pc.c                |    4 ++--
 hw/pci-hotplug.c       |    4 ++--
 hw/pci.c               |    8 ++++----
 hw/qdev.c              |   36 ++++++++++++++++++------------------
 hw/scsi-bus.c          |    2 +-
 hw/scsi-disk.c         |    2 +-
 hw/scsi-generic.c      |    8 ++++----
 hw/usb-bus.c           |    4 ++--
 hw/usb-msd.c           |    2 +-
 hw/usb-serial.c        |    8 ++++----
 hw/virtio-net.c        |    4 ++--
 hw/virtio-pci.c        |    2 +-
 hw/virtio-serial-bus.c |    2 +-
 net.c                  |   24 ++++++++++++------------
 net/dump.c             |    4 ++--
 net/slirp.c            |   20 ++++++++++----------
 net/socket.c           |   10 +++++-----
 net/tap-bsd.c          |    3 ++-
 net/tap-linux.c        |    4 ++--
 net/tap-win32.c        |    2 +-
 net/tap.c              |    2 +-
 qemu-config.c          |    8 ++++----
 qemu-error.c           |    1 +
 qerror.c               |    2 +-
 savevm.c               |   17 +++++++++--------
 vl.c                   |    4 ++--
 26 files changed, 95 insertions(+), 92 deletions(-)
Luiz Capitulino - Feb. 26, 2010, 7:44 p.m.
On Wed, 24 Feb 2010 18:55:25 +0100
Markus Armbruster <armbru@redhat.com> wrote:

> 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.

 I'm not a big fun of printing functions that add automatic newline,
specially in C. But I understand that you're doing this because you're
going to prefix some info to the printed string.

 In this case, you could rename the function to qemu_error_nl(). Or at
least document it properly in the function definition.
Markus Armbruster - March 1, 2010, 8:55 a.m.
Luiz Capitulino <lcapitulino@redhat.com> writes:

> On Wed, 24 Feb 2010 18:55:25 +0100
> Markus Armbruster <armbru@redhat.com> wrote:
>
>> 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.
>
>  I'm not a big fun of printing functions that add automatic newline,
> specially in C. But I understand that you're doing this because you're
> going to prefix some info to the printed string.
>
>  In this case, you could rename the function to qemu_error_nl(). Or at
> least document it properly in the function definition.

Fair enough, I'll document it.

Patch

diff --git a/hw/pc.c b/hw/pc.c
index 1595283..e9d66d4 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -238,13 +238,13 @@  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");
+        qemu_error("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",
+            qemu_error("Invalid boot device for PC: '%c'",
                        boot_device[i]);
             return(1);
         }
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index bd82c6a..215dc42 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -80,7 +80,7 @@  static int scsi_hot_add(DeviceState *adapter, DriveInfo *dinfo, int printinfo)
 
     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");
+        qemu_error("Device is not a SCSI adapter");
         return -1;
     }
 
@@ -97,7 +97,7 @@  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);
+        qemu_error("OK bus %d, unit %d", scsibus->busnr, scsidev->id);
     return 0;
 }
 
diff --git a/hw/pci.c b/hw/pci.c
index eb2043e..a9aad5b 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -589,11 +589,11 @@  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);
+        qemu_error("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,
+        qemu_error("PCI: devfn %d not available for %s, in use by %s", devfn,
                  name, bus->devices[devfn]->name);
         return NULL;
     }
@@ -1476,7 +1476,7 @@  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",
+        qemu_error("Invalid PCI device address %s for device %s",
                    devaddr, pci_nic_names[i]);
         return NULL;
     }
@@ -1768,7 +1768,7 @@  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__,
+        qemu_error("%s: failed to find romfile \"%s\"", __FUNCTION__,
                    pdev->romfile);
         return -1;
     }
diff --git a/hw/qdev.c b/hw/qdev.c
index d0052d4..a992479 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -146,7 +146,7 @@  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",
+        qemu_error("can't set property \"%s\" to \"%s\" for \"%s\"",
                    name, value, dev->info->name);
         return -1;
     }
@@ -164,7 +164,7 @@  int qdev_device_help(QemuOpts *opts)
     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);
+            qemu_error("%s", msg);
         }
         return 1;
     }
@@ -179,7 +179,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);
+        qemu_error("%s.%s=%s", info->name, prop->name, prop->info->name);
     }
     return 1;
 }
@@ -193,7 +193,7 @@  DeviceState *qdev_device_add(QemuOpts *opts)
 
     driver = qemu_opt_get(opts, "driver");
     if (!driver) {
-        qemu_error("-device: no driver specified\n");
+        qemu_error("-device: no driver specified");
         return NULL;
     }
 
@@ -204,7 +204,7 @@  DeviceState *qdev_device_add(QemuOpts *opts)
         return NULL;
     }
     if (info->no_user) {
-        qemu_error("device \"%s\" can't be added via command line\n",
+        qemu_error("device \"%s\" can't be added via command line",
                    info->name);
         return NULL;
     }
@@ -217,12 +217,12 @@  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",
+        qemu_error("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",
+        qemu_error("Bus %s does not support hotplugging",
                    bus->name);
         return NULL;
     }
@@ -238,7 +238,7 @@  DeviceState *qdev_device_add(QemuOpts *opts)
         return NULL;
     }
     if (qdev_init(qdev) < 0) {
-        qemu_error("Error initializing device %s\n", driver);
+        qemu_error("Error initializing device %s", driver);
         return NULL;
     }
     qdev->opts = opts;
@@ -277,7 +277,7 @@  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",
+        qemu_error("Bus %s does not support hotplugging",
                    dev->parent_bus->name);
         return -1;
     }
@@ -549,12 +549,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);
+            qemu_error("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);
+            qemu_error("bus \"%s\" not found", elem);
             return NULL;
         }
         pos = len;
@@ -568,14 +568,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);
+            qemu_error("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);
+            qemu_error("device \"%s\" not found\n%s", elem, msg);
             return NULL;
         }
         if (path[pos] == '\0') {
@@ -583,13 +583,13 @@  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);
+                qemu_error("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",
+                qemu_error("device has multiple child busses (%s)\n%s",
                            path, msg);
                 return NULL;
             }
@@ -597,14 +597,14 @@  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);
+            qemu_error("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);
+            qemu_error("child bus \"%s\" not found\n%s", elem, msg);
             return NULL;
         }
     }
@@ -763,7 +763,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);
+        qemu_error("Device '%s' not found", id);
         return;
     }
     qdev_unplug(dev);
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index c41ce9b..0aaf068 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);
+        qemu_error("bad scsi device id: %d", dev->id);
         goto err;
     }
 
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index b1424de..93ece93 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1021,7 +1021,7 @@  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");
+        qemu_error("scsi-disk: drive property not set");
         return -1;
     }
     s->bs = s->qdev.conf.dinfo->bdrv;
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index cfd9903..f3f101f 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");
+        qemu_error("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");
+        qemu_error("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");
+        qemu_error("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");
+        qemu_error("scsi-generic: SG_GET_SCSI_ID ioctl failed");
         return -1;
     }
 
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 54027df..2eba8a0 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -288,14 +288,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);
+        qemu_error("usbdevice %s not found", driver);
 #endif
         return NULL;
     }
 
     if (!usb->usbdevice_init) {
         if (params) {
-            qemu_error("usbdevice %s accepts no params\n", driver);
+            qemu_error("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 1e3e101..db79f71 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");
+        qemu_error("usb-msd: drive property not set");
         return -1;
     }
 
diff --git a/hw/usb-serial.c b/hw/usb-serial.c
index e78c6c0..b724de6 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);
+                qemu_error("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);
+                qemu_error("bogus product ID %s", p);
                 return NULL;
             }
             filename = e;
         } else {
-            qemu_error("unrecognized serial USB option %s\n", filename);
+            qemu_error("unrecognized serial USB option %s", filename);
             return NULL;
         }
         while(*filename == ',')
             filename++;
     }
     if (!*filename) {
-        qemu_error("character device specification needed\n");
+        qemu_error("character device specification needed");
         return NULL;
     }
     filename++;
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 8359be6..a26eb21 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");
+            qemu_error("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");
+            qemu_error("virtio-net: saved image requires TUN_F_UFO support");
             return -1;
         }
     }
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 7781328..4e0d5a2 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");
+        qemu_error("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 d0e0219..2ba4c4a 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");
+        qemu_error("virtio-serial-bus: Maximum device limit reached");
         return -1;
     }
     dev->info = info;
diff --git a/net.c b/net.c
index a1bf49f..2479e65 100644
--- a/net.c
+++ b/net.c
@@ -731,7 +731,7 @@  int qemu_find_nic_model(NICInfo *nd, const char * const *models,
             return i;
     }
 
-    qemu_error("qemu: Unsupported NIC model: %s\n", nd->model);
+    qemu_error("qemu: Unsupported NIC model: %s", nd->model);
     return -1;
 }
 
@@ -763,7 +763,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");
+        qemu_error("Too Many NICs");
         return -1;
     }
 
@@ -774,7 +774,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);
+            qemu_error("netdev '%s' not found", netdev);
             return -1;
         }
     } else {
@@ -800,14 +800,14 @@  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");
+        qemu_error("invalid syntax for ethernet address");
         return -1;
     }
 
     nd->nvectors = qemu_opt_get_number(opts, "vectors", NIC_NVECTORS_UNSPECIFIED);
     if (nd->nvectors != NIC_NVECTORS_UNSPECIFIED &&
         (nd->nvectors < 0 || nd->nvectors > 0x7ffffff)) {
-        qemu_error("invalid # of vectors: %d\n", nd->nvectors);
+        qemu_error("invalid # of vectors: %d", nd->nvectors);
         return -1;
     }
 
@@ -1057,12 +1057,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");
+            qemu_error("No type specified for -net");
             return -1;
         }
     } else {
         if (!type) {
-            qemu_error("No type specified for -netdev\n");
+            qemu_error("No type specified for -netdev");
             return -1;
         }
 
@@ -1074,21 +1074,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",
+            qemu_error("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");
+            qemu_error("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");
+            qemu_error("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");
+            qemu_error("The id= parameter is required with -netdev");
             return -1;
         }
     }
@@ -1121,7 +1121,7 @@  int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
         }
     }
 
-    qemu_error("Invalid -net type '%s'\n", type);
+    qemu_error("Invalid -net type '%s'", type);
     return -1;
 }
 
diff --git a/net/dump.c b/net/dump.c
index e702830..9c7bab4 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -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);
+        qemu_error("-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));
+        qemu_error("-net dump write error: %s", strerror(errno));
         close(fd);
         return -1;
     }
diff --git a/net/slirp.c b/net/slirp.c
index 317cca7..b7ee3ab 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -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",
+        qemu_error("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);
+    qemu_error("invalid host forwarding rule '%s'", redir_str);
     return -1;
 }
 
@@ -473,9 +473,9 @@  static void slirp_smb_cleanup(SlirpState *s)
         snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
         ret = system(cmd);
         if (!WIFEXITED(ret)) {
-            qemu_error("'%s' failed.\n", cmd);
+            qemu_error("'%s' failed.", cmd);
         } else if (WEXITSTATUS(ret)) {
-            qemu_error("'%s' failed. Error code: %d\n",
+            qemu_error("'%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);
+        qemu_error("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,7 +501,7 @@  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",
+        qemu_error("could not create samba server configuration file '%s'",
                    smb_conf);
         return -1;
     }
@@ -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");
+        qemu_error("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);
+        qemu_error("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);
+                   "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);
+    qemu_error("invalid guest forwarding rule '%s'", config_str);
     return -1;
 }
 
diff --git a/net/socket.c b/net/socket.c
index 474d573..09d6ad8 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -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");
+            qemu_error("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");
+            qemu_error("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");
+            qemu_error("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");
+            qemu_error("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");
+        qemu_error("-socket requires fd=, listen=, connect= or mcast=");
         return -1;
     }
 
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index 815997d..5102829 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -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));
+        qemu_error("warning: could not open %s (%s): no virtual network emulation",
+                   dname, strerror(errno));
         return -1;
     }
 #else
diff --git a/net/tap-linux.c b/net/tap-linux.c
index c5748e6..646c707 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -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));
+        qemu_error("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));
+        qemu_error("TUNGETIFF ioctl() failed: %s", strerror(errno));
         return 0;
     }
 
diff --git a/net/tap-win32.c b/net/tap-win32.c
index 8370c80..f1c489e 100644
--- a/net/tap-win32.c
+++ b/net/tap-win32.c
@@ -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");
+        qemu_error("tap: no interface name");
         return -1;
     }
 
diff --git a/net/tap.c b/net/tap.c
index 9ba9b4a..b2ba29b 100644
--- 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");
+            qemu_error("ifname=, script=, downscript= and vnet_hdr= is invalid with fd=");
             return -1;
         }
 
diff --git a/qemu-config.c b/qemu-config.c
index 2c9a7a5..194a653 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -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);
+        qemu_error("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);
+        qemu_error("can't parse: \"%s\"", str);
         return -1;
     }
 
@@ -338,7 +338,7 @@  int qemu_set_option(const char *str)
 
     opts = qemu_opts_find(list, id);
     if (!opts) {
-        qemu_error("there is no %s \"%s\" defined\n",
+        qemu_error("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);
+        qemu_error("can't parse: \"%s\"", str);
         return -1;
     }
 
diff --git a/qemu-error.c b/qemu-error.c
index 76c660a..075c64d 100644
--- a/qemu-error.c
+++ b/qemu-error.c
@@ -48,6 +48,7 @@  void qemu_error(const char *fmt, ...)
     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,
diff --git a/qerror.c b/qerror.c
index a418bde..c09c3b8 100644
--- a/qerror.c
+++ b/qerror.c
@@ -324,7 +324,7 @@  QString *qerror_human(const QError *qerror)
 void qerror_print(const QError *qerror)
 {
     QString *qstring = qerror_human(qerror);
-    qemu_error("%s\n", qstring_get_str(qstring));
+    qemu_error("%s", qstring_get_str(qstring));
     QDECREF(qstring);
 }
 
diff --git a/savevm.c b/savevm.c
index 1f6c25e..93026f7 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1743,7 +1743,7 @@  int load_vmstate(const char *name)
 
     bs = get_bs_snapshots();
     if (!bs) {
-        qemu_error("No block device supports snapshots\n");
+        qemu_error("No block device supports snapshots");
         return -EINVAL;
     }
 
@@ -1755,19 +1755,20 @@  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",
+                    qemu_error("%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",
+                    qemu_error("%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",
+                    qemu_error("%sError %d while activating snapshot on '%s'",
+                               bs != bs1 ? "Warning: " : "",
                                ret, bdrv_get_device_name(bs1));
                     break;
                 }
@@ -1786,13 +1787,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");
+        qemu_error("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);
+        qemu_error("Error %d while loading VM state", ret);
         return ret;
     }
     return 0;
diff --git a/vl.c b/vl.c
index c4c8c1f..7d4b234 100644
--- a/vl.c
+++ b/vl.c
@@ -2526,7 +2526,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);
+        qemu_error("could not add USB device '%s'", devname);
     }
 }
 
@@ -2534,7 +2534,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);
+        qemu_error("could not delete USB device '%s'", devname);
     }
 }