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

[Xen-changelog] [qemu-upstream-unstable] scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial



commit 964e0d4ec52ea7400ccc69de69b05ac913bbfff8
Author:     Markus Armbruster <armbru@xxxxxxxxxx>
AuthorDate: Fri Aug 23 18:01:58 2013 +0200
Commit:     Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
CommitDate: Tue Sep 24 19:10:35 2013 -0500

    scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial
    
    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@xxxxxxxxxx
    Reviewed-by: Andreas Färber <afaerber@xxxxxxx>
    Signed-off-by: Markus Armbruster <armbru@xxxxxxxxxx>
    Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
    (cherry picked from commit c24e7517ee4a98e90eee5f0f07708a1fa12326b3)
    
    Signed-off-by: Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
---
 hw/scsi/scsi-bus.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

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) {
--
generated by git-patchbot for /home/xen/git/qemu-upstream-unstable.git

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.