From 07a5d95a3b32820662194d353da9c098adddde77 Mon Sep 17 00:00:00 2001 From: Ryan Harper Date: Thu, 25 Mar 2010 09:32:58 -0500 Subject: [PATCH] Add qerror message if the 'change' target filename can't be opened Currently when using the change command to switch the file in the cd drive the command doesn't complain if the file doesn't exit or can't be opened and the drive keeps the existing image. This patch adds a qerror_report call to print a message out indicating the failure. This error message can be used to catch failures. Current behavior: QEMU 0.12.50 monitor - type 'help' for more information (qemu) info block ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0 ide1-cd0: type=cdrom removable=1 locked=0 [not inserted] floppy0: type=floppy removable=1 locked=0 [not inserted] sd0: type=floppy removable=1 locked=0 [not inserted] (qemu) change ide1-cd0 /home/rharper/work/isos/Fedora-9-i386-DVD.iso (qemu) info block ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0 ide1-cd0: type=cdrom removable=1 locked=0 file=/home/rharper/work/isos/Fedora-9-i386-DVD.iso ro=0 drv=raw encrypted=0 floppy0: type=floppy removable=1 locked=0 [not inserted] sd0: type=floppy removable=1 locked=0 [not inserted] (qemu) change ide1-cd0 /tmp/non_existent_file.iso (qemu) info block ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0 ide1-cd0: type=cdrom removable=1 locked=0 [not inserted] floppy0: type=floppy removable=1 locked=0 [not inserted] sd0: type=floppy removable=1 locked=0 [not inserted] (qemu) With patch: QEMU 0.12.50 monitor - type 'help' for more information (qemu) change ide1-cd0 /tmp/non_existent_file.iso Could not open '/tmp/non_existent_file.iso' (qemu) Signed-off-by: Ryan Harper Signed-off-by: Aurelien Jarno --- monitor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/monitor.c b/monitor.c index 5659991b87..e5f6b1cd12 100644 --- a/monitor.c +++ b/monitor.c @@ -1097,6 +1097,7 @@ static int do_change_block(Monitor *mon, const char *device, return -1; } if (bdrv_open2(bs, filename, BDRV_O_RDWR, drv) < 0) { + qerror_report(QERR_OPEN_FILE_FAILED, filename); return -1; } return monitor_read_bdrv_key_start(mon, bs, NULL, NULL); -- 2.11.4.GIT