From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjqKL-00050I-HS for qemu-devel@nongnu.org; Wed, 07 Oct 2015 11:08:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjqKG-0000Hx-PK for qemu-devel@nongnu.org; Wed, 07 Oct 2015 11:08:21 -0400 References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-23-git-send-email-mreitz@redhat.com> <20151007104344.GD4337@noname.redhat.com> From: Max Reitz Message-ID: <56153552.308@redhat.com> Date: Wed, 7 Oct 2015 17:08:02 +0200 MIME-Version: 1.0 In-Reply-To: <20151007104344.GD4337@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="e92b0VP9qDm0G3C1DV38a4Qxf5xF3L0OG" 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: Kevin Wolf Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --e92b0VP9qDm0G3C1DV38a4Qxf5xF3L0OG Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 07.10.2015 12:43, Kevin Wolf wrote: > 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 >=20 >> @@ -1922,8 +1939,9 @@ void qmp_change_blockdev(const char *device, con= st char *filename, >> return; >> } >> bs =3D blk_bs(blk); >> + new_bs =3D !bs; >> =20 >> - aio_context =3D bdrv_get_aio_context(bs); >> + aio_context =3D blk_get_aio_context(blk); >> aio_context_acquire(aio_context); >> =20 >> eject_device(blk, 0, &err); >> @@ -1932,10 +1950,18 @@ void qmp_change_blockdev(const char *device, c= onst char *filename, >> goto out; >> } >> =20 >> - bdrv_flags =3D bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR; >> - bdrv_flags |=3D bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0; >> + bdrv_flags =3D blk_is_read_only(blk) ? 0 : BDRV_O_RDWR; >> + bdrv_flags |=3D blk_get_root_state(blk)->open_flags & ~BDRV_O_RDW= R; >> =20 >> - qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, format, NULL, e= rrp); >> + 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); >> + } >=20 > Was this change supposed to be in this patch? It looks like it's doing = a > bit more than just fixing blk_bs() =3D=3D NULL cases. Yes, it's supposed to be here. Before this patch, qmp_change_blockdev() took the BDS from the specified BB, closed it (eject_device()) and "re-opened" it (bdrv_open() in qmp_bdrv_open_encrypted()), and we're done= =2E Now, the BB does not have to have a BDS anymore. In this case (new_bs =3D=3D true) qmp_bdrv_open_encrypted() will now create a new BDS (which is why now it needs to take a BDS ** instead of a plain BDS *) and we have to then attach it to the BB. The comment above blk_dev_change_media_cb() then explains why we need that, too. Later ("Implement change with basic operations") I'll drop it altogether anyway, and then, since the "eject" part of "change" will then detach the BDS from the BB, we'll always have the "need to attach a new BDS to the BB" case. Max --e92b0VP9qDm0G3C1DV38a4Qxf5xF3L0OG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWFTVSAAoJEDuxQgLoOKytAuoIAJhMEMOBeT7rquSHVLKm9vpF 4/SDJEqHkb4aYJEWtY45X+epalEYLT2eWp27eO3BonLTz3IihKkt07Aq9BKUOb5x 1qdWgQbhLQrtIBa9gCQOA0hNdD68EEIqC3n/PoQy2s6SkZQb8CKF/rJ/W2iXSNYD xJSaiUQn/2zKc7/2iTXvnRxBFcl0VpRVGXbA+8atqd9qNzKcTc8IRHBii7M8Z2Ph yVouKA4KCL5+nHxUD5eDuQeMjJdPFqAmM9VQ6Gf2HZEoCZwoLCVyN7bPOWZ45Vac dF8TEvESPXxf8UOtWvzFMbG44r3613NCY8vT3kMha/MUz8YPsCJQaTAs0GQufxE= =JAtp -----END PGP SIGNATURE----- --e92b0VP9qDm0G3C1DV38a4Qxf5xF3L0OG--