From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UuKLI-0000dz-Eh for qemu-devel@nongnu.org; Wed, 03 Jul 2013 06:31:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UuKLG-0000bD-VD for qemu-devel@nongnu.org; Wed, 03 Jul 2013 06:31:20 -0400 Received: from mail-ee0-x22e.google.com ([2a00:1450:4013:c00::22e]:47776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UuKLG-0000b4-MQ for qemu-devel@nongnu.org; Wed, 03 Jul 2013 06:31:18 -0400 Received: by mail-ee0-f46.google.com with SMTP id d41so3254304eek.19 for ; Wed, 03 Jul 2013 03:31:18 -0700 (PDT) Date: Wed, 3 Jul 2013 12:31:14 +0200 From: Stefan Hajnoczi Message-ID: <20130703103114.GA17929@stefanha-thinkpad.muc.redhat.com> References: <7b4a213d18eb103fb737286ab4e5b641317e1d8d.1372072312.git.phrdina@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7b4a213d18eb103fb737286ab4e5b641317e1d8d.1372072312.git.phrdina@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 3/3] blockdev: do not open block device if password is not required but user provides one List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Hrdina Cc: kwolf@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com On Mon, Jun 24, 2013 at 02:12:52PM +0200, Pavel Hrdina wrote: > This fixes the issue that block device is openned successfully with an error > as warning if password is provided but not required. Now the open fails with > the error message. > > Signed-off-by: Pavel Hrdina > --- > blockdev.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/blockdev.c b/blockdev.c > index 2dbd781..7fc8dcf 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1065,6 +1065,11 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename, > { > int ret; > > + if (!bdrv_key_required(bs) && password) { > + error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs)); > + return; > + } > + > ret = bdrv_open(bs, filename, NULL, bdrv_flags, drv); How can bdrv_key_required(bs) work when bs isn't opened yet?