]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vl.c: Error locations for options using add_device_config()
authorMarkus Armbruster <armbru@redhat.com>
Tue, 7 Feb 2012 14:09:12 +0000 (15:09 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 24 Feb 2012 15:06:58 +0000 (09:06 -0600)
These are -bt, -serial, -virtcon, -parallel, -debugcon, -usbdevice.
Improves messages emitted via proper error reporting interfaces.  For
instance:

    $ qemu-system-x86_64 -nodefaults -S -usb -usbdevice net:vlan=xxx
    qemu-system-x86_64: Parameter 'vlan' expects a number

becomes:

    qemu-system-x86_64: -usbdevice net:vlan=xxx: Parameter 'vlan' expects a number

Many more remain unimproved, because they're fprintf()ed.  The next
few commits will take care of that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
vl.c

diff --git a/vl.c b/vl.c
index 7a8cc081de036fd22edeba1297ca6719420af7a2..841d1e1414fa3fbf88ffcfe997fe9c628241540c 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1859,6 +1859,7 @@ struct device_config {
         DEV_DEBUGCON,  /* -debugcon */
     } type;
     const char *cmdline;
+    Location loc;
     QTAILQ_ENTRY(device_config) next;
 };
 QTAILQ_HEAD(, device_config) device_configs = QTAILQ_HEAD_INITIALIZER(device_configs);
@@ -1870,6 +1871,7 @@ static void add_device_config(int type, const char *cmdline)
     conf = g_malloc0(sizeof(*conf));
     conf->type = type;
     conf->cmdline = cmdline;
+    loc_save(&conf->loc);
     QTAILQ_INSERT_TAIL(&device_configs, conf, next);
 }
 
@@ -1881,7 +1883,9 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline))
     QTAILQ_FOREACH(conf, &device_configs, next) {
         if (conf->type != type)
             continue;
+        loc_push_restore(&conf->loc);
         rc = func(conf->cmdline);
+        loc_pop(&conf->loc);
         if (0 != rc)
             return rc;
     }