yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-scsi-Fix-scsi_bus_legacy_add_drive-scsi-generic-with.patch

218e99
From 284ff94d1e2c50f7314d5a60e0a45d6710160420 Mon Sep 17 00:00:00 2001
218e99
From: Markus Armbruster <armbru@redhat.com>
218e99
Date: Mon, 30 Sep 2013 12:03:39 +0200
218e99
Subject: [PATCH 09/25] scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial
218e99
MIME-Version: 1.0
218e99
Content-Type: text/plain; charset=UTF-8
218e99
Content-Transfer-Encoding: 8bit
218e99
218e99
RH-Author: Markus Armbruster <armbru@redhat.com>
218e99
Message-id: <1380542619-20274-2-git-send-email-armbru@redhat.com>
218e99
Patchwork-id: 54583
218e99
O-Subject: [PATCH 7.0 qemu-kvm 1/1] scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial
218e99
Bugzilla: 1009285
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
218e99
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
218e99
218e99
From: Markus Armbruster <armbru@redhat.com>
218e99
218e99
scsi_bus_legacy_add_drive() creates either a scsi-disk or a
218e99
scsi-generic device.  It sets property "serial" to argument serial
218e99
unless null.  Crashes with scsi-generic, because it doesn't have such
218e99
the property.
218e99
218e99
Only usb_msd_initfn_storage() passes non-null serial.  Reproducer:
218e99
218e99
    $ qemu-system-x86_64 -nodefaults -display none -S -usb \
218e99
    -drive if=none,file=/dev/sg1,id=usb-drv0 \
218e99
    -device usb-storage,id=usb-msd0,drive=usb-drv0,serial=123
218e99
    qemu-system-x86_64: -device usb-storage,id=usb-msd0,drive=usb-drv0,serial=123: Property '.serial' not found
218e99
    Aborted (core dumped)
218e99
218e99
Fix by handling exactly like "removable": set the property only when
218e99
it exists.
218e99
218e99
Cc: qemu-stable@nongnu.org
218e99
Reviewed-by: Andreas Färber <afaerber@suse.de>
218e99
Signed-off-by: Markus Armbruster <armbru@redhat.com>
218e99
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
(cherry picked from commit c24e7517ee4a98e90eee5f0f07708a1fa12326b3)
218e99
---
218e99
 hw/scsi/scsi-bus.c | 2 +-
218e99
 1 file changed, 1 insertion(+), 1 deletion(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 hw/scsi/scsi-bus.c |    2 +-
218e99
 1 files changed, 1 insertions(+), 1 deletions(-)
218e99
218e99
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
218e99
index 53ea906..0885d9d 100644
218e99
--- a/hw/scsi/scsi-bus.c
218e99
+++ b/hw/scsi/scsi-bus.c
218e99
@@ -223,7 +223,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
218e99
     if (object_property_find(OBJECT(dev), "removable", NULL)) {
218e99
         qdev_prop_set_bit(dev, "removable", removable);
218e99
     }
218e99
-    if (serial) {
218e99
+    if (serial && object_property_find(OBJECT(dev), "serial", NULL)) {
218e99
         qdev_prop_set_string(dev, "serial", serial);
218e99
     }
218e99
     if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) {
218e99
-- 
218e99
1.7.1
218e99