From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNmcZ-0001Oq-Mw for qemu-devel@nongnu.org; Thu, 14 Jul 2016 15:48:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNmcY-0003KE-NB for qemu-devel@nongnu.org; Thu, 14 Jul 2016 15:48:31 -0400 References: <1468504183-20180-1-git-send-email-kwolf@redhat.com> <1468504183-20180-2-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <5787EC85.9010109@redhat.com> Date: Thu, 14 Jul 2016 13:48:21 -0600 MIME-Version: 1.0 In-Reply-To: <1468504183-20180-2-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lvBljQKQALaahFqnFsDPBRNpKfUbqd5Jh" 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 , qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, mreitz@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --lvBljQKQALaahFqnFsDPBRNpKfUbqd5Jh From: Eric Blake To: Kevin Wolf , qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, mreitz@redhat.com Message-ID: <5787EC85.9010109@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] ide: ide-cd without drive property for empty drive References: <1468504183-20180-1-git-send-email-kwolf@redhat.com> <1468504183-20180-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1468504183-20180-2-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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(-) > @@ -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(); 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 : IDE= _HD); =2E..yet, this claims dev->conf.blk can be NULL. What am I missing? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --lvBljQKQALaahFqnFsDPBRNpKfUbqd5Jh 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/ iQEcBAEBCAAGBQJXh+yFAAoJEKeha0olJ0NqkOwH/3g+AC+IKEBNoTTUu0dl/X6/ nit+4eoA41pf7eF6xFRcjaZU5knHcaap6IDcKxFQ4nJdbnDHIOpk5d9aLs3uREAC TJTTw2qZhWU3vOTbD8DYxkVfFiLbV4KWzNsZRDqhM1tsiHw6Vy7Dwi38nGk98yuF Hl3ZV4Vt/DF+JVuREG3sJWc97ZJOz540y6oJHffZsbLpuEEsWyXTyA1lMGEYmgF8 pir4dNM8nYj8M18Vfc/RKUEWPfeFSQ3aLD67ywYWrEPQQS6H6oSV8DgPTzmPcqmO 6f2tibw2BsgHQe/ReeoYgI4hmZEQphaAnpBhxo7303bwhIaBGc0wsjDZ0h4B/rI= =A9LX -----END PGP SIGNATURE----- --lvBljQKQALaahFqnFsDPBRNpKfUbqd5Jh--