From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0tCB-0002Eu-Mm for qemu-devel@nongnu.org; Fri, 05 Jun 2015 11:06:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0tC8-0000hd-2O for qemu-devel@nongnu.org; Fri, 05 Jun 2015 11:06:07 -0400 Message-ID: <5571BACA.5030206@redhat.com> Date: Fri, 05 Jun 2015 17:05:46 +0200 From: Max Reitz MIME-Version: 1.0 References: <1433360659-1915-1-git-send-email-mreitz@redhat.com> <1433360659-1915-11-git-send-email-mreitz@redhat.com> <556F658D.9000609@redhat.com> In-Reply-To: <556F658D.9000609@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 10/38] hw/usb-storage: Check whether BB is inserted List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-block@nongnu.org Cc: Kevin Wolf , John Snow , qemu-devel@nongnu.org, Stefan Hajnoczi , Markus Armbruster On 03.06.2015 22:37, Eric Blake wrote: > On 06/03/2015 01:43 PM, Max Reitz wrote: >> Only call bdrv_add_key() on the BlockDriverState if it is not NULL. >> >> Signed-off-by: Max Reitz >> --- >> hw/usb/dev-storage.c | 30 ++++++++++++++++-------------- >> 1 file changed, 16 insertions(+), 14 deletions(-) >> >> diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c >> index abe0e1d..5b1dc90 100644 >> --- a/hw/usb/dev-storage.c >> +++ b/hw/usb/dev-storage.c >> @@ -612,20 +612,22 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp) >> return; >> } >> >> - bdrv_add_key(blk_bs(blk), NULL, &err); >> - if (err) { >> - if (monitor_cur_is_qmp()) { >> - error_propagate(errp, err); >> - return; >> - } >> - error_free(err); >> - err = NULL; >> - if (cur_mon) { >> - monitor_read_bdrv_key_start(cur_mon, blk_bs(blk), >> - usb_msd_password_cb, s); >> - s->dev.auto_attach = 0; >> - } else { >> - autostart = 0; >> + if (blk_bs(blk)) { >> + bdrv_add_key(blk_bs(blk), NULL, &err); >> + if (err) { >> + if (monitor_cur_is_qmp()) { > Hopefully doesn't conflict with Markus' work to refactor error handling > here (https://lists.gnu.org/archive/html/qemu-devel/2015-06/msg00431.html) He doesn't touch this file in this series, and I'm just wrapping this block inside of an "if (blk_bs(blk))", so it should be fine. On the other hand, Markus did modify this part in some previous series of his, but that has been merged already and this patch is (re-)based on it. > Reviewed-by: Eric Blake Thanks :-) Max