Received: from eggs.gnu.org ([2001:4830:134:3::10]:51002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP9TO-0006KS-DC for qemu-devel@nongnu.org; Mon, 18 Jul 2016 10:24:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bP9TI-0005KL-8w for qemu-devel@nongnu.org; Mon, 18 Jul 2016 10:24:41 -0400 References: <1468502894-18098-1-git-send-email-kwolf@redhat.com> <1468502894-18098-9-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <11ea02be-c28f-c8d3-b0ef-a061c8a8c109@redhat.com> Date: Mon, 18 Jul 2016 16:24:20 +0200 MIME-Version: 1.0 In-Reply-To: <1468502894-18098-9-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XegjfMF5AcTWJeBXWPC8HJJX9NUg5LKbp" Subject: Re: [Qemu-devel] [PATCH v4 08/11] block: Accept node-name for drive-backup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: eblake@redhat.com, berto@igalia.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --XegjfMF5AcTWJeBXWPC8HJJX9NUg5LKbp From: Max Reitz To: Kevin Wolf , qemu-block@nongnu.org Cc: eblake@redhat.com, berto@igalia.com, qemu-devel@nongnu.org Message-ID: <11ea02be-c28f-c8d3-b0ef-a061c8a8c109@redhat.com> Subject: Re: [PATCH v4 08/11] block: Accept node-name for drive-backup References: <1468502894-18098-1-git-send-email-kwolf@redhat.com> <1468502894-18098-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1468502894-18098-9-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 14.07.2016 15:28, Kevin Wolf wrote: > In order to remove the necessity to use BlockBackend names in the > external API, we want to allow node-names everywhere. This converts > drive-backup and the corresponding transaction action to accept a > node-name without lifting the restriction that we're operating at a roo= t > node. >=20 > In case of an invalid device name, the command returns the GenericError= > error class now instead of DeviceNotFound, because this is what > qmp_get_root_bs() returns. >=20 > Signed-off-by: Kevin Wolf > --- > blockdev.c | 36 +++++++++--------------------------- > qapi/block-core.json | 4 ++-- > qmp-commands.hx | 2 +- > tests/qemu-iotests/055 | 7 ++----- > 4 files changed, 14 insertions(+), 35 deletions(-) >=20 > diff --git a/blockdev.c b/blockdev.c > index 6b1f2f0..b89b5f8 100644 > --- a/blockdev.c > +++ b/blockdev.c [...] > @@ -3203,24 +3195,14 @@ static void do_drive_backup(const char *job_id,= const char *device, > mode =3D NEW_IMAGE_MODE_ABSOLUTE_PATHS; > } > =20 > - blk =3D blk_by_name(device); > - if (!blk) { > - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, > - "Device '%s' not found", device); > + bs =3D qmp_get_root_bs(device, errp); > + if (!bs) { > return; > } > =20 > - aio_context =3D blk_get_aio_context(blk); > + aio_context =3D bdrv_get_aio_context(bs); > aio_context_acquire(aio_context); > =20 > - /* Although backup_run has this check too, we need to use bs->drv = below, so > - * do an early check redundantly. */ This comment makes a good point, bs->drv may be NULL. I think you should either call bdrv_is_inserted() or check bs->drv directly. Max > - if (!blk_is_available(blk)) { > - error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); > - goto out; > - } > - bs =3D blk_bs(blk); > - > if (!has_format) { > format =3D mode =3D=3D NEW_IMAGE_MODE_EXISTING ? NULL : bs->dr= v->format_name; > } --XegjfMF5AcTWJeBXWPC8HJJX9NUg5LKbp 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 iQEvBAEBCAAZBQJXjOaVEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6Disrfgs B/0ZBBG+OltF84owQ0JgJaDquCwJBSQfY4rs8mC/igfKQxLnjXGrm81q9nFfYaLG wFrlf7f67YWSpRZehfwxi8Gcsh1ITFvf3VsUsKsNL/RDJvcaebFTkg8GI3QQ7Rb1 bVEtcRpkzSlwk6ef14+xDF7GOhsjBu86WdE+6bkbjalEy3Ag/xlAtOJ0hNTtZiAN KwzByyEa9gYr+SS4qEmxkbS4OOclZfaeOvc2HO0foSbjXbzCT6Pd9Mn1n45Iin6d A6GqX/su7T4JgM/NhnXLex4NGjjoEAcIYSNnbjwre6bTUKnOSOTVIMTJiOsDCr5g O6d4tflmCnqSVKu+Vo1JaDhH =bSJ0 -----END PGP SIGNATURE----- --XegjfMF5AcTWJeBXWPC8HJJX9NUg5LKbp--