From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: [Qemu-devel] [PATCH v3 11/38] usb-msd: do not register twice in the boot order
Date: Wed, 23 Nov 2011 11:45:01 +0000 [thread overview]
Message-ID: <1322048728-26061-12-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1322048728-26061-1-git-send-email-stefanha@linux.vnet.ibm.com>
From: Paolo Bonzini <pbonzini@redhat.com>
USB mass storage devices are registered twice in the boot order.
To avoid having to keep the two paths in sync, pass the bootindex
property down to the scsi-disk device and let it register itself.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/pci-hotplug.c | 3 ++-
hw/scsi-bus.c | 7 +++++--
hw/scsi.h | 2 +-
hw/usb-msd.c | 4 ++--
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index b59be2a..12f61fe 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -91,7 +91,8 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
*/
dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1);
dinfo->bus = scsibus->busnr;
- scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo->bdrv, dinfo->unit, false);
+ scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo->bdrv, dinfo->unit,
+ false, -1);
if (!scsidev) {
return -1;
}
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 3a2a7bb..2feeaa2 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -162,7 +162,7 @@ void scsi_qdev_register(SCSIDeviceInfo *info)
/* handle legacy '-drive if=scsi,...' cmd line args */
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
- int unit, bool removable)
+ int unit, bool removable, int bootindex)
{
const char *driver;
DeviceState *dev;
@@ -170,6 +170,9 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
driver = bdrv_is_sg(bdrv) ? "scsi-generic" : "scsi-disk";
dev = qdev_create(&bus->qbus, driver);
qdev_prop_set_uint32(dev, "scsi-id", unit);
+ if (bootindex >= 0) {
+ qdev_prop_set_int32(dev, "bootindex", bootindex);
+ }
if (qdev_prop_exists(dev, "removable")) {
qdev_prop_set_bit(dev, "removable", removable);
}
@@ -195,7 +198,7 @@ int scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
continue;
}
qemu_opts_loc_restore(dinfo->opts);
- if (!scsi_bus_legacy_add_drive(bus, dinfo->bdrv, unit, false)) {
+ if (!scsi_bus_legacy_add_drive(bus, dinfo->bdrv, unit, false, -1)) {
res = -1;
break;
}
diff --git a/hw/scsi.h b/hw/scsi.h
index 61c64d5..ab6e952 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -128,7 +128,7 @@ static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
}
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
- int unit, bool removable);
+ int unit, bool removable, int bootindex);
int scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
/*
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index b734177..e97736b 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -541,7 +541,8 @@ static int usb_msd_initfn(USBDevice *dev)
usb_desc_init(dev);
scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info);
- s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable);
+ s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable,
+ s->conf.bootindex);
if (!s->scsi_dev) {
return -1;
}
@@ -557,7 +558,6 @@ static int usb_msd_initfn(USBDevice *dev)
}
}
- add_boot_device_path(s->conf.bootindex, &dev->qdev, "/disk@0,0");
return 0;
}
--
1.7.7.1
next prev parent reply other threads:[~2011-11-23 11:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-23 11:44 [Qemu-devel] [PATCH v3 00/38] block: generic copy-on-read Stefan Hajnoczi
2011-11-23 11:44 ` [Qemu-devel] [PATCH v3 01/38] Documentation: Add section about iSCSI LUNS to qemu-doc Stefan Hajnoczi
2011-11-23 11:44 ` [Qemu-devel] [PATCH v3 02/38] scsi: fix fw path Stefan Hajnoczi
2011-11-23 11:44 ` [Qemu-devel] [PATCH v3 03/38] scsi-disk: guess geometry Stefan Hajnoczi
2011-11-23 11:44 ` [Qemu-devel] [PATCH v3 04/38] atapi: kill MODE SENSE(6), fix MODE SENSE(10) Stefan Hajnoczi
2011-11-23 11:44 ` [Qemu-devel] [PATCH v3 05/38] scsi: update list of commands Stefan Hajnoczi
2011-11-23 11:44 ` [Qemu-devel] [PATCH v3 06/38] scsi: fix parsing of allocation length field Stefan Hajnoczi
2011-11-23 11:44 ` [Qemu-devel] [PATCH v3 07/38] scsi: remove block descriptors from CDs Stefan Hajnoczi
2011-11-23 11:44 ` [Qemu-devel] [PATCH v3 08/38] scsi: pass down REQUEST SENSE to the device when there is no stored sense Stefan Hajnoczi
2011-11-23 11:44 ` [Qemu-devel] [PATCH v3 09/38] scsi-block: always use SG_IO for MMC devices Stefan Hajnoczi
2011-11-23 11:45 ` [Qemu-devel] [PATCH v3 10/38] virtio-blk: fix cross-endian config space Stefan Hajnoczi
2011-11-23 11:45 ` Stefan Hajnoczi [this message]
2011-11-23 11:45 ` [Qemu-devel] [PATCH v3 12/38] scsi: fix fw path Stefan Hajnoczi
2011-11-23 11:45 ` [Qemu-devel] [PATCH v3 13/38] scsi-generic: add as boot device Stefan Hajnoczi
2011-11-23 11:45 ` [Qemu-devel] [PATCH v3 14/38] qed: adjust the way to get nb_sectors Stefan Hajnoczi
2011-11-23 11:49 ` [Qemu-devel] [PATCH v3 00/38] block: generic copy-on-read Stefan Hajnoczi
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=1322048728-26061-12-git-send-email-stefanha@linux.vnet.ibm.com \
--to=stefanha@linux.vnet.ibm.com \
--cc=kwolf@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@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).