From 59d1c1c2d774cccb0a88ff73501f97bea190c154 Mon Sep 17 00:00:00 2001 From: Scott Tsai Date: Wed, 23 Dec 2009 04:30:18 +0800 Subject: USB: Improve usbdevice error messages When an non-existent USB device is specified on the command line, print "qemu: could not add USB device 'X'". Likewise for the usb_{add,del} monitor commands. Signed-off-by: Scott Tsai Signed-off-by: Aurelien Jarno --- vl.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index e60690346..e881e456b 100644 --- a/vl.c +++ b/vl.c @@ -2689,17 +2689,28 @@ static int usb_device_del(const char *devname) static int usb_parse(const char *cmdline) { - return usb_device_add(cmdline, 0); + int r; + r = usb_device_add(cmdline, 0); + if (r < 0) { + fprintf(stderr, "qemu: could not add USB device '%s'\n", cmdline); + } + return r; } void do_usb_add(Monitor *mon, const QDict *qdict) { - usb_device_add(qdict_get_str(qdict, "devname"), 1); + 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); + } } void do_usb_del(Monitor *mon, const QDict *qdict) { - usb_device_del(qdict_get_str(qdict, "devname")); + const char *devname = qdict_get_str(qdict, "devname"); + if (usb_device_del(devname) < 0) { + qemu_error("could not delete USB device '%s'\n", devname); + } } /***********************************************************/ -- cgit v1.2.3