summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-06-23 12:55:22 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-06-23 12:55:22 +0100
commitd9c1647d896d3192cba9dbf98fb7efab876edde5 (patch)
treea18d31b5578e0267be6ed052c6ab5096f1d127d0 /block.c
parent910f66fcda2d410249697d959dcbdf8c82d77844 (diff)
parent2bd3bce8efebe86b031beab5c0e3b9bbaec0b502 (diff)
downloadqemu-d9c1647d896d3192cba9dbf98fb7efab876edde5.tar.gz
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Block pull request # gpg: Signature made Mon 23 Jun 2014 09:53:49 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: block: asynchronously stop the VM on I/O errors vl: allow other threads to do qemu_system_vmstop_request sheepdog: fix NULL dereference in sd_create QemuOpts: check NULL opts in qemu_opt_get functions block: m25p80: Support read only bdrvs. block: m25p80: sync_page(): Deindent function body. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block.c')
-rw-r--r--block.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/block.c b/block.c
index 43abe96db6..ff44e76c87 100644
--- a/block.c
+++ b/block.c
@@ -3626,10 +3626,27 @@ void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action,
bool is_read, int error)
{
assert(error >= 0);
- bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read);
+
if (action == BDRV_ACTION_STOP) {
- vm_stop(RUN_STATE_IO_ERROR);
+ /* First set the iostatus, so that "info block" returns an iostatus
+ * that matches the events raised so far (an additional error iostatus
+ * is fine, but not a lost one).
+ */
bdrv_iostatus_set_err(bs, error);
+
+ /* Then raise the request to stop the VM and the event.
+ * qemu_system_vmstop_request_prepare has two effects. First,
+ * it ensures that the STOP event always comes after the
+ * BLOCK_IO_ERROR event. Second, it ensures that even if management
+ * can observe the STOP event and do a "cont" before the STOP
+ * event is issued, the VM will not stop. In this case, vm_start()
+ * also ensures that the STOP/RESUME pair of events is emitted.
+ */
+ qemu_system_vmstop_request_prepare();
+ bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read);
+ qemu_system_vmstop_request(RUN_STATE_IO_ERROR);
+ } else {
+ bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read);
}
}