From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVcSp-0006Bc-Sw for qemu-devel@nongnu.org; Fri, 05 Aug 2016 06:34:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVcSn-0002as-Qw for qemu-devel@nongnu.org; Fri, 05 Aug 2016 06:34:50 -0400 Date: Fri, 5 Aug 2016 12:34:39 +0200 From: Kevin Wolf Message-ID: <20160805103439.GB5503@noname.redhat.com> References: <1468504183-20180-1-git-send-email-kwolf@redhat.com> <1468504183-20180-2-git-send-email-kwolf@redhat.com> <5787EC85.9010109@redhat.com> <20160801194746.GC17511@noname.redhat.com> <57A36741.9080801@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline In-Reply-To: <57A36741.9080801@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] ide: ide-cd without drive property for empty drive List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 04.08.2016 um 18:03 hat Eric Blake geschrieben: > On 08/01/2016 01:47 PM, Kevin Wolf wrote: > > Am 14.07.2016 um 21:48 hat Eric Blake geschrieben: > >> On 07/14/2016 07:49 AM, Kevin Wolf wrote: > >>> This allows to create an empty ide-cd device without manually creatin= g a > >>> BlockBackend. > >>> > >>> Signed-off-by: Kevin Wolf > >>> --- > >>> hw/ide/qdev.c | 20 +++++++++++++++----- > >>> 1 file changed, 15 insertions(+), 5 deletions(-) > >> > >>> @@ -158,6 +154,16 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDri= veKind kind) > >>> IDEState *s =3D bus->ifs + dev->unit; > >>> Error *err =3D NULL; > >>> =20 > >>> + if (!dev->conf.blk) { > >>> + if (kind !=3D IDE_CD) { > >>> + error_report("No drive specified"); > >>> + return -1; > >>> + } else { > >>> + /* Anonymous BlockBackend for an empty drive */ > >>> + dev->conf.blk =3D blk_new(); > >> > >> So we either fail or dev->conf.blk is set... > >> > >>> + } > >>> + } > >>> + > >>> if (dev->conf.discard_granularity =3D=3D -1) { > >>> dev->conf.discard_granularity =3D 512; > >>> } else if (dev->conf.discard_granularity && > >>> @@ -257,7 +263,11 @@ static int ide_cd_initfn(IDEDevice *dev) > >>> =20 > >>> static int ide_drive_initfn(IDEDevice *dev) > >>> { > >>> - DriveInfo *dinfo =3D blk_legacy_dinfo(dev->conf.blk); > >>> + DriveInfo *dinfo =3D NULL; > >>> + > >>> + if (dev->conf.blk) { > >>> + dinfo =3D blk_legacy_dinfo(dev->conf.blk); > >>> + } > >>> =20 > >>> return ide_dev_initfn(dev, dinfo && dinfo->media_cd ? IDE_CD : I= DE_HD); > >> > >> ...yet, this claims dev->conf.blk can be NULL. What am I missing? > >=20 > > That ide_drive_initfn() is the outer function and runs first, before we > > handle the case in ide_dev_initfn()? >=20 > Ah, I think I glazed over the difference between 'dev' and 'drive', and > was thinking 'both of these are initfn, what's different?'. I think you > are okay, after all. I noted this down as an Acked-by for now. If you decide to give an actual R-b, I'll update that. Applied the series to block-next. Kevin --Q68bSM7Ycu6FN28Q Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJXpGu/AAoJEH8JsnLIjy/W0YMQALAAt38AXAOfHNwviu+hNclA Rc/aF3Pgc8o8NPYAg77VMmSlm7aPka+2pnLLck+DT0w+FDvZf/F2lTVTpKuEoJx5 ORPyHgvjUWBNIA87O/kSQsxKlBZg9kDO267a8evfDKT6uOOVcHGyRMSkdStZcEIi YhG/ESvSB96HYPw7nu5bdPQik8bbNWwj+ZmE9ZAbHBuToVBZdvM1r2fEvltqlG6o +m2pQDq4cWzVKFXzYckQQRFfAHJgGQe6WThi/MeAxyb9G6wzsHJTojrQIUmYCiv8 ZSsA8kmqX6pQ4EDPtZQGFexEAmb6e2BD5aWygqiLKWMKc/i89OTOCKNhLeFY9+Vw KnDi4HvULH0uzLQ9cQe3mJGIDfXpJx1ZC08yUMDqBkmqNlo0xiuuyc1Xhwkdh4Rf C27YsXT7t3f9ud/nqvR3eNW6W1ri0T4Hi33cAou5akMLydhJWfh256pkAGwZzoJs c6t1da8DSZmpxyeHt31vwcaGpGtNpARsfc8E4qOj7aDNuXmWTBH81KxbZQmpxMfP q61z4nrvO/UtHTLR9gbsJ0Fg/EacRrSAd4pneEtYsCwMkHCeHWqiB363LZzzaPKC /syCMAY5KogYH0IkdfZF9cNImB4WRkMPJKqmfwHSvL2RZIYs8y1nuuNqKDPo3tFO Ee+1dDASD1SaX1lu0TT7 =0JlA -----END PGP SIGNATURE----- --Q68bSM7Ycu6FN28Q--