From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46534) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjmCQ-0006em-HN for qemu-devel@nongnu.org; Wed, 07 Oct 2015 06:43:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjmCP-000309-Ol for qemu-devel@nongnu.org; Wed, 07 Oct 2015 06:43:54 -0400 Date: Wed, 7 Oct 2015 12:43:44 +0200 From: Kevin Wolf Message-ID: <20151007104344.GD4337@noname.redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-23-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442589793-7105-23-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 22/38] block: Prepare for NULL BDS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: > blk_bs() will not necessarily return a non-NULL value any more (unless > blk_is_available() is true or it can be assumed to otherwise, e.g. > because it is called immediately after a successful blk_new_with_bs() or > blk_new_open()). > > Signed-off-by: Max Reitz > @@ -1922,8 +1939,9 @@ void qmp_change_blockdev(const char *device, const char *filename, > return; > } > bs = blk_bs(blk); > + new_bs = !bs; > > - aio_context = bdrv_get_aio_context(bs); > + aio_context = blk_get_aio_context(blk); > aio_context_acquire(aio_context); > > eject_device(blk, 0, &err); > @@ -1932,10 +1950,18 @@ void qmp_change_blockdev(const char *device, const char *filename, > goto out; > } > > - bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR; > - bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0; > + bdrv_flags = blk_is_read_only(blk) ? 0 : BDRV_O_RDWR; > + bdrv_flags |= blk_get_root_state(blk)->open_flags & ~BDRV_O_RDWR; > > - qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, format, NULL, errp); > + qmp_bdrv_open_encrypted(&bs, filename, bdrv_flags, format, NULL, &err); > + if (err) { > + error_propagate(errp, err); > + } else if (new_bs) { > + blk_insert_bs(blk, bs); > + /* Has been sent automatically by bdrv_open() if blk_bs(blk) was not > + * NULL */ > + blk_dev_change_media_cb(blk, true); > + } Was this change supposed to be in this patch? It looks like it's doing a bit more than just fixing blk_bs() == NULL cases. Kevin