qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH][STABLE] Add qerror message if the 'change' target filename can't be opened
@ 2010-04-09 12:46 Ryan Harper
  2010-04-18 20:47 ` Aurelien Jarno
  0 siblings, 1 reply; 3+ messages in thread
From: Ryan Harper @ 2010-04-09 12:46 UTC (permalink / raw)
  To: qemu-devel

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 <ryanh@us.ibm.com>
---
 monitor.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/monitor.c b/monitor.c
index 0448a70..196c7a6 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1099,6 +1099,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);
-- 
1.6.3.3

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh@us.ibm.com

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH][STABLE] Add qerror message if the 'change' target filename can't be opened
  2010-04-09 12:46 [Qemu-devel] [PATCH][STABLE] Add qerror message if the 'change' target filename can't be opened Ryan Harper
@ 2010-04-18 20:47 ` Aurelien Jarno
  2010-04-19  2:37   ` Ryan Harper
  0 siblings, 1 reply; 3+ messages in thread
From: Aurelien Jarno @ 2010-04-18 20:47 UTC (permalink / raw)
  To: Ryan Harper; +Cc: qemu-devel

On Fri, Apr 09, 2010 at 07:46:38AM -0500, Ryan Harper wrote:
> 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.

Applied to HEAD, however it doesn't apply to stable. Is it really needed
here?

> 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 <ryanh@us.ibm.com>
> ---
>  monitor.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 0448a70..196c7a6 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1099,6 +1099,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);
> -- 
> 1.6.3.3
> 
> -- 
> Ryan Harper
> Software Engineer; Linux Technology Center
> IBM Corp., Austin, Tx
> ryanh@us.ibm.com
> 
> 
> 

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH][STABLE] Add qerror message if the 'change' target filename can't be opened
  2010-04-18 20:47 ` Aurelien Jarno
@ 2010-04-19  2:37   ` Ryan Harper
  0 siblings, 0 replies; 3+ messages in thread
From: Ryan Harper @ 2010-04-19  2:37 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: Ryan Harper, qemu-devel

* Aurelien Jarno <aurelien@aurel32.net> [2010-04-18 15:55]:
> On Fri, Apr 09, 2010 at 07:46:38AM -0500, Ryan Harper wrote:
> > 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.
> 
> Applied to HEAD, however it doesn't apply to stable. Is it really needed
> here?

No, you're right.  Qemu doesnt' segfault or anything bad.  That and the
qerror class for open file failed isn't in stable so we'd have to pull
that new code in (it's small, like 7 lines.  Anyhow, I have the patches,
but I agree that they aren't necessary for stable.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh@us.ibm.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-19  2:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-09 12:46 [Qemu-devel] [PATCH][STABLE] Add qerror message if the 'change' target filename can't be opened Ryan Harper
2010-04-18 20:47 ` Aurelien Jarno
2010-04-19  2:37   ` Ryan Harper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).