qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>, qemu-stable@nongnu.org
Subject: [Qemu-devel] [PULL 04/11] scsi: Fix scsi_bus_legacy_add_drive() scsi-generic with serial
Date: Thu, 12 Sep 2013 13:17:07 +0200	[thread overview]
Message-ID: <1378984634-765-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1378984634-765-1-git-send-email-pbonzini@redhat.com>

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
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@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 5cd6137..4d36841 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) {
-- 
1.8.3.1

  parent reply	other threads:[~2013-09-12 11:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-12 11:17 [Qemu-devel] [PULL 00/11] SCSI patches for 2013-09-11 Paolo Bonzini
2013-09-12 11:17 ` [Qemu-devel] [PULL 01/11] scsi: prefer UUID to VM name for the initiator name Paolo Bonzini
2013-09-12 11:17 ` [Qemu-devel] [PULL 02/11] spapr-vscsi: add task management Paolo Bonzini
2013-09-12 11:17 ` [Qemu-devel] [PULL 03/11] virtio-scsi: Make type virtio-scsi-common abstract Paolo Bonzini
2013-09-12 11:17 ` Paolo Bonzini [this message]
2013-09-12 11:17 ` [Qemu-devel] [PULL 05/11] hw/scsi/lsi53c895a: Use sextract32 for sign-extension Paolo Bonzini
2013-09-12 11:17 ` [Qemu-devel] [PULL 06/11] hw/scsi/lsi53c895a: Use deposit32 rather than handcoded shift/mask Paolo Bonzini
2013-09-12 11:17 ` [Qemu-devel] [PULL 07/11] iscsi: add logical block provisioning information to iscsilun Paolo Bonzini
2013-09-12 11:17 ` [Qemu-devel] [PULL 08/11] iscsi: add .bdrv_get_block_status Paolo Bonzini
2013-09-17 17:18   ` Stefan Weil
2013-09-17 17:21     ` Paolo Bonzini
2013-09-19  7:24       ` Peter Lieven
2013-09-19 13:46         ` Paolo Bonzini
2013-10-02 11:37           ` Peter Lieven
2013-09-12 11:17 ` [Qemu-devel] [PULL 09/11] iscsi: split discard requests in multiple parts Paolo Bonzini
2013-09-12 11:17 ` [Qemu-devel] [PULL 10/11] spapr-vscsi: Adding VSCSI capabilities Paolo Bonzini
2013-09-12 11:17 ` [Qemu-devel] [PULL 11/11] spapr-vscsi: Report error on unsupported MAD requests Paolo Bonzini

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=1378984634-765-5-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).