Blame 0007-scsi-Fix-scsi_bus_legacy_add_drive-scsi-generic-with.patch

298366
From 964e0d4ec52ea7400ccc69de69b05ac913bbfff8 Mon Sep 17 00:00:00 2001
298366
From: Markus Armbruster <armbru@redhat.com>
298366
Date: Fri, 23 Aug 2013 18:01:58 +0200
298366
Subject: [PATCH] scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with
298366
 serial
298366
MIME-Version: 1.0
298366
Content-Type: text/plain; charset=UTF-8
298366
Content-Transfer-Encoding: 8bit
298366
298366
scsi_bus_legacy_add_drive() creates either a scsi-disk or a
298366
scsi-generic device.  It sets property "serial" to argument serial
298366
unless null.  Crashes with scsi-generic, because it doesn't have such
298366
the property.
298366
298366
Only usb_msd_initfn_storage() passes non-null serial.  Reproducer:
298366
298366
    $ qemu-system-x86_64 -nodefaults -display none -S -usb \
298366
    -drive if=none,file=/dev/sg1,id=usb-drv0 \
298366
    -device usb-storage,id=usb-msd0,drive=usb-drv0,serial=123
298366
    qemu-system-x86_64: -device usb-storage,id=usb-msd0,drive=usb-drv0,serial=123: Property '.serial' not found
298366
    Aborted (core dumped)
298366
298366
Fix by handling exactly like "removable": set the property only when
298366
it exists.
298366
298366
Cc: qemu-stable@nongnu.org
298366
Reviewed-by: Andreas Färber <afaerber@suse.de>
298366
Signed-off-by: Markus Armbruster <armbru@redhat.com>
298366
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
298366
(cherry picked from commit c24e7517ee4a98e90eee5f0f07708a1fa12326b3)
298366
298366
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
298366
---
298366
 hw/scsi/scsi-bus.c | 2 +-
298366
 1 file changed, 1 insertion(+), 1 deletion(-)
298366
298366
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
298366
index fbf9173..8fe4f4c 100644
298366
--- a/hw/scsi/scsi-bus.c
298366
+++ b/hw/scsi/scsi-bus.c
298366
@@ -224,7 +224,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
298366
     if (object_property_find(OBJECT(dev), "removable", NULL)) {
298366
         qdev_prop_set_bit(dev, "removable", removable);
298366
     }
298366
-    if (serial) {
298366
+    if (serial && object_property_find(OBJECT(dev), "serial", NULL)) {
298366
         qdev_prop_set_string(dev, "serial", serial);
298366
     }
298366
     if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) {