qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH 1/2] ide: ide-cd without drive prop


From: Eric Blake
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/2] ide: ide-cd without drive property for empty drive
Date: Thu, 14 Jul 2016 13:48:21 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

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 <address@hidden>
> ---
>  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?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]