From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] ide: ide-cd without drive property for empty drive
Date: Mon, 1 Aug 2016 21:47:46 +0200 [thread overview]
Message-ID: <20160801194746.GC17511@noname.redhat.com> (raw)
In-Reply-To: <5787EC85.9010109@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1686 bytes --]
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.
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> > hw/ide/qdev.c | 20 +++++++++++++++-----
> > 1 file changed, 15 insertions(+), 5 deletions(-)
>
> > @@ -158,6 +154,16 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
> > IDEState *s = bus->ifs + dev->unit;
> > Error *err = NULL;
> >
> > + if (!dev->conf.blk) {
> > + if (kind != IDE_CD) {
> > + error_report("No drive specified");
> > + return -1;
> > + } else {
> > + /* Anonymous BlockBackend for an empty drive */
> > + dev->conf.blk = blk_new();
>
> So we either fail or dev->conf.blk is set...
>
> > + }
> > + }
> > +
> > if (dev->conf.discard_granularity == -1) {
> > dev->conf.discard_granularity = 512;
> > } else if (dev->conf.discard_granularity &&
> > @@ -257,7 +263,11 @@ static int ide_cd_initfn(IDEDevice *dev)
> >
> > static int ide_drive_initfn(IDEDevice *dev)
> > {
> > - DriveInfo *dinfo = blk_legacy_dinfo(dev->conf.blk);
> > + DriveInfo *dinfo = NULL;
> > +
> > + if (dev->conf.blk) {
> > + dinfo = blk_legacy_dinfo(dev->conf.blk);
> > + }
> >
> > return ide_dev_initfn(dev, dinfo && dinfo->media_cd ? IDE_CD : IDE_HD);
>
> ...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
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2016-08-01 19:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-14 13:49 [Qemu-devel] [PATCH 0/2] block: Create empty drives without explicit BB Kevin Wolf
2016-07-14 13:49 ` [Qemu-devel] [PATCH 1/2] ide: ide-cd without drive property for empty drive Kevin Wolf
2016-07-14 19:48 ` Eric Blake
2016-08-01 19:47 ` Kevin Wolf [this message]
2016-08-04 16:03 ` Eric Blake
2016-08-05 10:34 ` Kevin Wolf
2016-07-14 13:49 ` [Qemu-devel] [PATCH 2/2] scsi: scsi-cd " Kevin Wolf
2016-07-14 19:49 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160801194746.GC17511@noname.redhat.com \
--to=kwolf@redhat.com \
--cc=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).