From 53db76965d3e08021f2d3a97e45587272646a9c7 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 14 Sep 2012 11:01:17 -0300 Subject: [RHEL6 qemu-kvm PATCH 4/6] skip media change notify on reopen RH-Author: Gerd Hoffmann Message-id: <1347620477-30144-1-git-send-email-kraxel@redhat.com> Patchwork-id: 41930 O-Subject: [RHEL-6.4 qemu-kvm PATCH] skip media change notify on reopen Bugzilla: 849657 RH-Acked-by: Laszlo Ersek RH-Acked-by: Paolo Bonzini RH-Acked-by: Pavel Hrdina RH-Acked-by: Kevin Wolf The block device reopening after accepting the incoming migration is guest-visible due to blk_{open,close} calling media change callbacks, which in turn causes a unit attention. Fix this by skipping the notification in case the block device is opened or closed while the runstate is RUN_STATE_INMIGRATE. bugzilla: 849657 - scsi devices see an unit attention condition on migration upstream: no, we are in rhel6-only area, upstream doesn't reopen the block devices in the first place. Signed-off-by: Gerd Hoffmann --- block.c | 9 +++++++-- qemu-tool.c | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) Signed-off-by: Eduardo Habkost --- block.c | 9 +++++++-- qemu-tool.c | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index aa5f011..162706c 100644 --- a/block.c +++ b/block.c @@ -29,6 +29,7 @@ #include "module.h" #include "qemu-objects.h" #include "qemu-coroutine.h" +#include "sysemu.h" #ifdef CONFIG_BSD #include @@ -695,7 +696,9 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags, } if (!bdrv_key_required(bs)) { - bdrv_dev_change_media_cb(bs, true); + if (!runstate_check(RUN_STATE_INMIGRATE)) { + bdrv_dev_change_media_cb(bs, true); + } } return 0; @@ -739,7 +742,9 @@ void bdrv_close(BlockDriverState *bs) bdrv_close(bs->file); } - bdrv_dev_change_media_cb(bs, false); + if (!runstate_check(RUN_STATE_INMIGRATE)) { + bdrv_dev_change_media_cb(bs, false); + } } } diff --git a/qemu-tool.c b/qemu-tool.c index e205cb7..d80a0c1 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -15,6 +15,7 @@ #include "monitor.h" #include "qemu-timer.h" #include "qemu-log.h" +#include "sysemu.h" #include @@ -106,3 +107,8 @@ int64_t get_clock(void) void qemu_notify_event(void) { } + +bool runstate_check(RunState state) +{ + return state == RUN_STATE_RUNNING; +} -- 1.7.11.4