From: Pavel Hrdina <phrdina@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@gmail.com, phrdina@redhat.com,
lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH v4 2/3] block: move the bdrv_dev_change_media_cb()
Date: Mon, 24 Jun 2013 14:12:51 +0200 [thread overview]
Message-ID: <2748e94e71dc324d489710c949dd9fed15138989.1372072312.git.phrdina@redhat.com> (raw)
In-Reply-To: <cover.1372072312.git.phrdina@redhat.com>
In-Reply-To: <cover.1372072312.git.phrdina@redhat.com>
This fixes a regression introduced by commit 9ca111544.
The QEVENT_DEVICE_TRAY_MOVED is emitted while shutting down the guest, which
is not right because it comes from bdrv_close_all() and therefore this
event doesn't happen at all.
The bdrv_dev_change_media_cb() should be called only for eject and change
commands because these are the only commands to emit this event. We should
call that function only if that command is successful.
What this function does is that it calls the change_media_cb() and also emit
the QEVENT_DEVICE_TRAY_MOVED event.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
block.c | 8 --------
blockdev.c | 5 +++++
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/block.c b/block.c
index 89574de..aad3091 100644
--- a/block.c
+++ b/block.c
@@ -1092,10 +1092,6 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
}
QDECREF(options);
- if (!bdrv_key_required(bs)) {
- bdrv_dev_change_media_cb(bs, true);
- }
-
/* throttling disk I/O limits */
if (bs->io_limits_enabled) {
bdrv_io_limits_enable(bs);
@@ -1394,8 +1390,6 @@ void bdrv_close(BlockDriverState *bs)
}
}
- bdrv_dev_change_media_cb(bs, false);
-
/*throttling disk I/O limits*/
if (bs->io_limits_enabled) {
bdrv_io_limits_disable(bs);
@@ -2846,8 +2840,6 @@ int bdrv_set_key(BlockDriverState *bs, const char *key)
bs->valid_key = 0;
} else if (!bs->valid_key) {
bs->valid_key = 1;
- /* call the change callback now, we skipped it on open */
- bdrv_dev_change_media_cb(bs, true);
}
return ret;
}
diff --git a/blockdev.c b/blockdev.c
index 5975dde..2dbd781 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1022,6 +1022,7 @@ static void eject_device(BlockDriverState *bs, int force, Error **errp)
}
bdrv_close(bs);
+ bdrv_dev_change_media_cb(bs, false);
}
void qmp_eject(const char *device, bool has_force, bool force, Error **errp)
@@ -1074,14 +1075,18 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename,
if (password) {
if (bdrv_set_key(bs, password) < 0) {
error_set(errp, QERR_INVALID_PASSWORD);
+ return;
}
} else {
error_set(errp, QERR_DEVICE_ENCRYPTED, bdrv_get_device_name(bs),
bdrv_get_encrypted_filename(bs));
+ return;
}
} else if (password) {
error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
}
+
+ bdrv_dev_change_media_cb(bs, true);
}
void qmp_change_blockdev(const char *device, const char *filename,
--
1.8.1.4
next prev parent reply other threads:[~2013-06-24 12:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-24 12:12 [Qemu-devel] [PATCH v4 0/3] block: fix spurious DEVICE_TRAY_MOVED events on shutdown Pavel Hrdina
2013-06-24 12:12 ` [Qemu-devel] [PATCH v4 1/3] block: make bdrv_dev_change_media_cb() public Pavel Hrdina
2013-06-24 12:12 ` Pavel Hrdina [this message]
2013-06-24 12:12 ` [Qemu-devel] [PATCH v4 3/3] blockdev: do not open block device if password is not required but user provides one Pavel Hrdina
2013-07-03 10:31 ` Stefan Hajnoczi
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=2748e94e71dc324d489710c949dd9fed15138989.1372072312.git.phrdina@redhat.com \
--to=phrdina@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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).