From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUJBt-0002Tr-OJ for qemu-devel@nongnu.org; Mon, 01 Aug 2016 15:47:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUJBr-0003fy-Op for qemu-devel@nongnu.org; Mon, 01 Aug 2016 15:47:56 -0400 Date: Mon, 1 Aug 2016 21:47:46 +0200 From: Kevin Wolf Message-ID: <20160801194746.GC17511@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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="oLBj+sq0vYjzfsbl" Content-Disposition: inline In-Reply-To: <5787EC85.9010109@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 --oLBj+sq0vYjzfsbl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 creating a > > BlockBackend. > >=20 > > Signed-off-by: Kevin Wolf > > --- > > hw/ide/qdev.c | 20 +++++++++++++++----- > > 1 file changed, 15 insertions(+), 5 deletions(-) >=20 > > @@ -158,6 +154,16 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDrive= Kind 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(); >=20 > So we either fail or dev->conf.blk is set... >=20 > > + } > > + } > > + > > 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 : IDE= _HD); >=20 > ...yet, this claims dev->conf.blk can be NULL. What am I missing? That ide_drive_initfn() is the outer function and runs first, before we handle the case in ide_dev_initfn()? Kevin --oLBj+sq0vYjzfsbl Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJXn6diAAoJEH8JsnLIjy/WTtUP/2nYNcnfoTrIxF72ezupxPqq QDdDcMJ53JffybL19WtirTTzwEISp+IX0G8/7MoMWRmXrhj3gqKznl+IwqqCBR+9 3NybZMQeIxm4HsxQF5XuQw6sjNrgaF5RXetYuOg7PCtSllhN101HM3vjwaE2JWu0 OpPeDScG6e7DDH6zpgRiuPMfBGzBOCOPeJSLTdGm0PWEbqb6tcgLt0LLwNGia+m3 lJ3sPrSpAAc8YGadpzSo2Z8usY4sz0b25k2sOJCIVpvgDmgYWw+hvJBo5rJkiNZ3 lTYLI1BRvG4v3wmldFwg8+aN82w8sCaQfWj4Cl+o80tWwO5uJJEAR7nhJMBfGplq mO9F93qi7VQcEXMYkCdXuGVSNQLMqF/KbtizLd6iK88WMHjeErjbvt9J8r7UPjo2 XmnLDW+v/RhBTZBYnzgF67517orFWjIft9kXgTxIQB7q83U6wIXGkWLoFCkHmAUY AOk/G3sKlRazCpnPS8brENEPPcsgDWs9R39xXXzi3zawiSY/sccur0H7Ds0mHR39 PuqGrDmAy/LXGfaWFLzNTGt9/zn/FFNR5/OQjqtdYPkmnZjFC4Z/aliytbnofuHX OBXJfZ5J4DAHUfEGP1AIEkdROIO/UzP+0tOM6/dzFEF9v6bQz/9U/RQlUHRy79zE BLSjAUFvH1pubLMKNDJl =rcUz -----END PGP SIGNATURE----- --oLBj+sq0vYjzfsbl--