qemu-stable
[Top][All Lists]
Advanced

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

Re: [Qemu-stable] [PATCH] scsi: Fix scsi_bus_legacy_add_drive() scsi-gen


From: Paolo Bonzini
Subject: Re: [Qemu-stable] [PATCH] scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial
Date: Mon, 26 Aug 2013 09:48:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8

Il 23/08/2013 18:01, address@hidden ha scritto:
> From: Markus Armbruster <address@hidden>
> 
> 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: address@hidden
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  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



reply via email to

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