From: Luiz Capitulino <lcapitulino@redhat.com>
To: Amit Shah <amit.shah@redhat.com>
Cc: kwolf@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org,
armbru@redhat.com
Subject: Re: [Qemu-devel] [RFC 10/10] QMP/HMP: change: Use QMP tray commands
Date: Mon, 6 Jun 2011 11:45:06 -0300 [thread overview]
Message-ID: <20110606114506.41410b4e@doriath> (raw)
In-Reply-To: <20110606114831.GC8114@amit-x200.redhat.com>
On Mon, 6 Jun 2011 17:18:31 +0530
Amit Shah <amit.shah@redhat.com> wrote:
> On (Fri) 03 Jun 2011 [16:04:02], Luiz Capitulino wrote:
> > This commit rewrites change in terms of blockdev-tray-open,
> > blockdev-media-insert and blockdev-tray-close.
> >
> > There should be no visible changes in HMP or QMP, except that
> > the use of this command causes the BLOCK_TRAY_OPEN *and*
> > BLOCK_TRAY_CLOSE events to emitted.
> >
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> > ---
> > blockdev.c | 43 +++++++++----------------------------------
> > 1 files changed, 9 insertions(+), 34 deletions(-)
> >
> > diff --git a/blockdev.c b/blockdev.c
> > index 36c56fd..e9edcb3 100644
> > --- a/blockdev.c
> > +++ b/blockdev.c
> > @@ -648,23 +648,6 @@ out:
> > return ret;
> > }
> >
> > -static int eject_device(Monitor *mon, BlockDriverState *bs, int force)
> > -{
> > - if (!force) {
> > - if (!bdrv_is_removable(bs)) {
> > - qerror_report(QERR_DEVICE_NOT_REMOVABLE,
> > - bdrv_get_device_name(bs));
> > - return -1;
> > - }
> > - if (bdrv_is_locked(bs)) {
> > - qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));
> > - return -1;
> > - }
> > - }
> > - bdrv_close(bs);
> > - return 0;
> > -}
> > -
> > static BlockDriverState *bdrv_removable_find(const char *name)
> > {
> > BlockDriverState *bs;
> > @@ -819,30 +802,22 @@ int do_change_block(Monitor *mon, const char *device,
> > const char *filename, const char *fmt)
> > {
> > BlockDriverState *bs;
> > - BlockDriver *drv = NULL;
> > - int bdrv_flags;
> >
> > - bs = bdrv_find(device);
> > - if (!bs) {
> > - qerror_report(QERR_DEVICE_NOT_FOUND, device);
> > + if (tray_open(device, 1, 0) < 0) { /* XXX: should we force? */
> > return -1;
> > }
> > - if (fmt) {
> > - drv = bdrv_find_whitelisted_format(fmt);
> > - if (!drv) {
> > - qerror_report(QERR_INVALID_BLOCK_FORMAT, fmt);
> > - return -1;
> > - }
> > - }
> > - if (eject_device(mon, bs, 0) < 0) {
> > +
> > + if (media_insert(device, filename, fmt) < 0) {
> > return -1;
> > }
> > - bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR;
> > - bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0;
> > - if (bdrv_open(bs, filename, bdrv_flags, drv) < 0) {
> > - qerror_report(QERR_OPEN_FILE_FAILED, filename);
> > +
> > + if (tray_close(device) < 0) {
> > + /* XXX: open the tray and remove the media? */
> > return -1;
> > }
>
> So if the new medium points to a non-existent file, close will fail,
media_insert() will and tray_close() won't be called. That's what you
meant, right?
> and leave the tray in the open state. A next change command will fail
> because the tray is already open. Not a good thing.
tray_open() shouldn't fail if the tray is already open.
next prev parent reply other threads:[~2011-06-06 14:45 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-03 19:03 [Qemu-devel] [RFC 00/10]: QMP/HMP: Introduce tray handling commands Luiz Capitulino
2011-06-03 19:03 ` [Qemu-devel] [RFC 01/10] block: bdrv_eject(): Add 'force' parameter Luiz Capitulino
2011-06-03 19:03 ` [Qemu-devel] [RFC 02/10] block: Rename bdrv_mon_event() Luiz Capitulino
2011-06-03 19:03 ` [Qemu-devel] [RFC 03/10] QMP: query-block: Add the 'tray-open' key Luiz Capitulino
2011-06-03 19:03 ` [Qemu-devel] [RFC 04/10] HMP: info block: Print " Luiz Capitulino
2011-06-06 13:19 ` Markus Armbruster
2011-06-06 14:46 ` Luiz Capitulino
2011-06-03 19:03 ` [Qemu-devel] [RFC 05/10] QMP: Introduce the blockdev-tray-open command Luiz Capitulino
2011-06-06 11:40 ` Amit Shah
2011-06-06 14:38 ` Luiz Capitulino
2011-06-07 13:29 ` Amit Shah
2011-06-07 13:53 ` Luiz Capitulino
2011-06-06 13:35 ` Markus Armbruster
2011-06-03 19:03 ` [Qemu-devel] [RFC 06/10] QMP: Introduce the blockdev-tray-close command Luiz Capitulino
2011-06-03 19:03 ` [Qemu-devel] [RFC 07/10] QMP: Introduce the blockdev-media-insert command Luiz Capitulino
2011-06-06 11:44 ` Amit Shah
2011-06-06 13:40 ` Markus Armbruster
2011-06-06 14:58 ` Luiz Capitulino
2011-06-03 19:04 ` [Qemu-devel] [RFC 08/10] QMP: Introduce the BLOCK_TRAY_OPEN and BLOCK_TRAY_CLOSE events Luiz Capitulino
2011-06-03 19:04 ` [Qemu-devel] [RFC 09/10] QMP/HMP: eject: Use blockdev-tray-open Luiz Capitulino
2011-06-03 19:04 ` [Qemu-devel] [RFC 10/10] QMP/HMP: change: Use QMP tray commands Luiz Capitulino
2011-06-06 11:48 ` Amit Shah
2011-06-06 14:45 ` Luiz Capitulino [this message]
2011-06-07 13:32 ` Amit Shah
2011-06-06 13:31 ` [Qemu-devel] [RFC 00/10]: QMP/HMP: Introduce tray handling commands Markus Armbruster
2011-06-06 14:56 ` Luiz Capitulino
2011-12-20 6:49 ` Osier Yang
2012-01-03 19:28 ` Luiz Capitulino
2012-01-11 7:34 ` Osier Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110606114506.41410b4e@doriath \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).