From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve8MW-0003MW-0N for qemu-devel@nongnu.org; Wed, 06 Nov 2013 14:02:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ve8MR-0000DR-55 for qemu-devel@nongnu.org; Wed, 06 Nov 2013 14:01:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24907) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve8MQ-0000DK-Ty for qemu-devel@nongnu.org; Wed, 06 Nov 2013 14:01:51 -0500 Message-ID: <527A9219.40108@redhat.com> Date: Wed, 06 Nov 2013 12:01:45 -0700 From: Eric Blake MIME-Version: 1.0 References: <1383763845-30340-1-git-send-email-mreitz@redhat.com> <1383763845-30340-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1383763845-30340-2-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vLpGHiVkWNir9aTUFP8quuTR7wMRn8car" Subject: Re: [Qemu-devel] [PATCH v3 1/2] block/drive-mirror: Check for NULL backing_hd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng , Wenchao Xia , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --vLpGHiVkWNir9aTUFP8quuTR7wMRn8car Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11/06/2013 11:50 AM, Max Reitz wrote: > It should be possible to execute the QMP "drive-mirror" command in > "none" sync mode and "absolute-paths" mode even for block devices > lacking a backing file. >=20 > "absolute-paths" does in fact not require a backing file to be present,= > as can be seen from the "top" sync mode code path. "top" basically > states that the device should indeed have a backing file - however, the= > current code catches the case if it doesn't and then simply treats it a= s > "full" sync mode, creating a target image without a backing file (in > "absolute-paths" mode). Thus, "absolute-paths" does not imply the targe= t > file must indeed have a backing file. >=20 > Therefore, the target file may be left unbacked in case of "none" sync > mode as well, if the specified device is not backed either. Currently, > qemu will crash trying to dereference the backing file pointer since it= > assumes that it will always be non-NULL in that case ("none" with > "absolute-paths"). >=20 > Signed-off-by: Max Reitz > --- > blockdev.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Eric Blake >=20 > diff --git a/blockdev.c b/blockdev.c > index b260477..1c426b0 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -2026,7 +2026,9 @@ void qmp_drive_mirror(const char *device, const c= har *target, > return; > } > =20 > - if (sync =3D=3D MIRROR_SYNC_MODE_FULL && mode !=3D NEW_IMAGE_MODE_= EXISTING) { > + if ((sync =3D=3D MIRROR_SYNC_MODE_FULL || !source) > + && mode !=3D NEW_IMAGE_MODE_EXISTING) > + { > /* create new image w/o backing file */ > assert(format && drv); > bdrv_img_create(target, format, >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --vLpGHiVkWNir9aTUFP8quuTR7wMRn8car Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSepIZAAoJEKeha0olJ0NquBsH/3cVeOa+qHF8DRlmFz0bV9Wz nyB6SENSluE4XybMS0UQtR+fkBFLZLo6Hmfk+7iwqu7M0dKLSKC0WjME+37IU2q9 9sO/JCQKgEZrgE0n/w2w80TIHaTK1THxkaAhN0pKtxLE/wQXKRT++KOGnEOwa3Ka CjNcRRM0kb1oNYvxvqXfKWtwRhPpCvS/Zp/MnjqSM9ZfweC/Sok5Fzph7rWVSL9O KEzz88rUWF7cmLP04baZr/wz1EGmj1WX6tlFtDii1CV6AEOVn2ym8uRJW2nILT+d mvcdqwHZllgrhSKlIpoTyiBFawLe2flLR57+N4zHqfGRZQDV1rxNfVfs4fNrUqQ= =m78Z -----END PGP SIGNATURE----- --vLpGHiVkWNir9aTUFP8quuTR7wMRn8car--