From patchwork Fri Apr 19 17:47:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 238078 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4A6F12C0195 for ; Sat, 20 Apr 2013 03:48:02 +1000 (EST) Received: from localhost ([::1]:44582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UTFPk-0003tf-Hs for incoming@patchwork.ozlabs.org; Fri, 19 Apr 2013 13:48:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UTFPC-0003mX-T3 for qemu-devel@nongnu.org; Fri, 19 Apr 2013 13:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UTFPB-00073w-QR for qemu-devel@nongnu.org; Fri, 19 Apr 2013 13:47:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65110) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UTFPB-00073r-IH for qemu-devel@nongnu.org; Fri, 19 Apr 2013 13:47:25 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3JHlOHB026524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Apr 2013 13:47:25 -0400 Received: from localhost (ovpn-113-80.phx2.redhat.com [10.3.113.80]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3JHlNe0003353; Fri, 19 Apr 2013 13:47:23 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Fri, 19 Apr 2013 13:47:19 -0400 Message-Id: <1366393639-20651-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1366393639-20651-1-git-send-email-lcapitulino@redhat.com> References: <1366393639-20651-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, phrdina@redhat.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 2/2] block: move bdrv_dev_change_media_cb() to callers that really need it X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Commit 9ca111544c64b5abed2e79cf52e19a8f227b347b moved the call to bdrv_dev_change_media_cb() outside the media check in bdrv_close(), this added a regression where spurious DEVICE_TRAY_MOVED events are emitted at shutdown. To fix that this commit moves the bdrv_dev_change_media_cb() calls to the callers that really need to report a media change, which are eject_device() and do_drive_del(). This fixes the problem commit 9ca1115 intended to fix, plus the spurious events. Signed-off-by: Luiz Capitulino Reviewed-by: Eric Blake --- block.c | 2 -- blockdev.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 90d0ed1..7fc3014 100644 --- a/block.c +++ b/block.c @@ -1342,8 +1342,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); diff --git a/blockdev.c b/blockdev.c index 8a1652b..f1f3b6e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -950,6 +950,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) @@ -1100,6 +1101,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) bdrv_drain_all(); bdrv_flush(bs); bdrv_close(bs); + bdrv_dev_change_media_cb(bs, false); /* if we have a device attached to this BlockDriverState * then we need to make the drive anonymous until the device