From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVL7C-0003c2-8N for qemu-devel@nongnu.org; Thu, 04 Aug 2016 12:03:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVL7B-0001Zi-7k for qemu-devel@nongnu.org; Thu, 04 Aug 2016 12:03:22 -0400 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> From: Eric Blake Message-ID: <57A36741.9080801@redhat.com> Date: Thu, 4 Aug 2016 10:03:13 -0600 MIME-Version: 1.0 In-Reply-To: <20160801194746.GC17511@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="65g9gJ7UhPEQlmmBTDRwUK11DlwmgeecH" 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: Kevin Wolf Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --65g9gJ7UhPEQlmmBTDRwUK11DlwmgeecH Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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()? 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --65g9gJ7UhPEQlmmBTDRwUK11DlwmgeecH 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXo2dBAAoJEKeha0olJ0NqI3AH/3LNtWlCzYJqTzLTawz+4d8w 9SnPVDzUcCo4tbmLrNBtfvEMjlusjNNbiJrfLr+Cs0RZuC5YVaI0EnZ5cXZKfCgx +pcwg5DjI0zFg4/snI4FdgYI9WEbJrHh0cFKX2bEeTWuKNARDsq4U1vEYqDOvP2k LKJmqf16G5NThRHmU5WGi7eUNSOhqGH9qnUOSsu1RavPtLQvfN20tdcYVmHkN5ac MCguyJg+EkwJEunl23dwlTUMsBKqGNDQ8cplzxDAxk3w1PJK3szjl1K2pXnzkowp rZdAXBh8py0mU3X+YjsuachMdeqeWPxwUMOkw/luyGqoxmTzOfkZ2x6OR4iyBpU= =6coP -----END PGP SIGNATURE----- --65g9gJ7UhPEQlmmBTDRwUK11DlwmgeecH--