All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: armbru@redhat.com
Cc: qemu-stable@nongnu.org, qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH] scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial
Date: Mon, 26 Aug 2013 09:48:00 +0200	[thread overview]
Message-ID: <521B0830.5070209@redhat.com> (raw)
In-Reply-To: <1377273718-26937-1-git-send-email-armbru@redhat.com>

Il 23/08/2013 18:01, armbru@redhat.com ha scritto:
> From: Markus Armbruster <armbru@redhat.com>
> 
> scsi_bus_legacy_add_drive() creates either a scsi-disk or a
> scsi-generic device.  It sets property "serial" to argument serial
> unless null.  Crashes with scsi-generic, because it doesn't have such
> the property.
> 
> Only usb_msd_initfn_storage() passes non-null serial.  Reproducer:
> 
>     $ qemu-system-x86_64 -nodefaults -display none -S -usb \
>     -drive if=none,file=/dev/sg1,id=usb-drv0 \
>     -device usb-storage,id=usb-msd0,drive=usb-drv0,serial=123
>     qemu-system-x86_64: -device usb-storage,id=usb-msd0,drive=usb-drv0,serial=123: Property '.serial' not found
>     Aborted (core dumped)
> 
> Fix by handling exactly like "removable": set the property only when
> it exists.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/scsi/scsi-bus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
> index fbf9173..8fe4f4c 100644
> --- a/hw/scsi/scsi-bus.c
> +++ b/hw/scsi/scsi-bus.c
> @@ -224,7 +224,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
>      if (object_property_find(OBJECT(dev), "removable", NULL)) {
>          qdev_prop_set_bit(dev, "removable", removable);
>      }
> -    if (serial) {
> +    if (serial && object_property_find(OBJECT(dev), "serial", NULL)) {
>          qdev_prop_set_string(dev, "serial", serial);
>      }
>      if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) {
> 

Applied to scsi-next branch, thanks.

Paolo

      parent reply	other threads:[~2013-08-26  7:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-23 16:01 [Qemu-devel] [PATCH] scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial armbru
2013-08-23 16:08 ` Andreas Färber
2013-08-26  7:48 ` Paolo Bonzini [this message]

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=521B0830.5070209@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.