qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/4] misc block fixes
@ 2011-11-18 15:31 Paolo Bonzini
  2011-11-18 15:31 ` [Qemu-devel] [PATCH 1/4] virtio-blk: fix cross-endian config space Paolo Bonzini
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Paolo Bonzini @ 2011-11-18 15:31 UTC (permalink / raw)
  To: qemu-devel

See individual patches, all for 1.0.

Paolo Bonzini (4):
  virtio-blk: fix cross-endian config space
  usb-msd: do not register twice in the boot order
  scsi: fix fw path
  scsi-generic: add as boot device

 hw/pci-hotplug.c  |    3 ++-
 hw/scsi-bus.c     |   11 +++++++----
 hw/scsi-disk.c    |    2 +-
 hw/scsi-generic.c |    5 +++++
 hw/scsi.h         |    2 +-
 hw/usb-msd.c      |    4 ++--
 hw/virtio-blk.c   |    7 ++++---
 7 files changed, 22 insertions(+), 12 deletions(-)

-- 
1.7.7.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 1/4] virtio-blk: fix cross-endian config space
  2011-11-18 15:31 [Qemu-devel] [PATCH 0/4] misc block fixes Paolo Bonzini
@ 2011-11-18 15:31 ` Paolo Bonzini
  2011-11-18 15:32 ` [Qemu-devel] [PATCH 2/4] usb-msd: do not register twice in the boot order Paolo Bonzini
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2011-11-18 15:31 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
	v1->v2: do not rely on blkcfg since it is now guest-endian

 hw/virtio-blk.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 01aeb28..0d6f53b 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -474,6 +474,7 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
     struct virtio_blk_config blkcfg;
     uint64_t capacity;
     int cylinders, heads, secs;
+    int blk_size = s->conf->logical_block_size;
 
     bdrv_get_geometry(s->bs, &capacity);
     bdrv_get_geometry_hint(s->bs, &cylinders, &heads, &secs);
@@ -481,14 +482,14 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
     stq_raw(&blkcfg.capacity, capacity);
     stl_raw(&blkcfg.seg_max, 128 - 2);
     stw_raw(&blkcfg.cylinders, cylinders);
+    stl_raw(&blkcfg.blk_size, blk_size);
+    stw_raw(&blkcfg.min_io_size, s->conf->min_io_size / blk_size);
+    stw_raw(&blkcfg.opt_io_size, s->conf->opt_io_size / blk_size);
     blkcfg.heads = heads;
     blkcfg.sectors = secs & ~s->sector_mask;
-    blkcfg.blk_size = s->conf->logical_block_size;
     blkcfg.size_max = 0;
     blkcfg.physical_block_exp = get_physical_block_exp(s->conf);
     blkcfg.alignment_offset = 0;
-    blkcfg.min_io_size = s->conf->min_io_size / blkcfg.blk_size;
-    blkcfg.opt_io_size = s->conf->opt_io_size / blkcfg.blk_size;
     memcpy(config, &blkcfg, sizeof(struct virtio_blk_config));
 }
 
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 2/4] usb-msd: do not register twice in the boot order
  2011-11-18 15:31 [Qemu-devel] [PATCH 0/4] misc block fixes Paolo Bonzini
  2011-11-18 15:31 ` [Qemu-devel] [PATCH 1/4] virtio-blk: fix cross-endian config space Paolo Bonzini
@ 2011-11-18 15:32 ` Paolo Bonzini
  2011-11-18 15:32 ` [Qemu-devel] [PATCH 3/4] scsi: fix fw path Paolo Bonzini
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2011-11-18 15:32 UTC (permalink / raw)
  To: qemu-devel

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>
---
 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 372fe7f..61c883f 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -166,7 +166,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;
@@ -174,6 +174,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);
     }
@@ -199,7 +202,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 796ecf1..92e7b43 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -131,7 +131,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 9ba77a3..0e37b9d 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 3/4] scsi: fix fw path
  2011-11-18 15:31 [Qemu-devel] [PATCH 0/4] misc block fixes Paolo Bonzini
  2011-11-18 15:31 ` [Qemu-devel] [PATCH 1/4] virtio-blk: fix cross-endian config space Paolo Bonzini
  2011-11-18 15:32 ` [Qemu-devel] [PATCH 2/4] usb-msd: do not register twice in the boot order Paolo Bonzini
@ 2011-11-18 15:32 ` Paolo Bonzini
  2011-11-18 16:03   ` [Qemu-devel] [PATCH rebased " Paolo Bonzini
  2011-11-18 15:32 ` [Qemu-devel] [PATCH 4/4] scsi-generic: add as boot device Paolo Bonzini
  2011-11-21 14:15 ` [Qemu-devel] [PATCH 0/4] misc block fixes Kevin Wolf
  4 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2011-11-18 15:32 UTC (permalink / raw)
  To: qemu-devel

The pre-1.0 firmware path for SCSI devices already included the LUN
using the suffix argument to add_boot_device_path.  Avoid that it is
included twice, and, for consistency with the OpenFirmware spec:
1) move the "channel" to a separate device path; 2) convert the colons
to commas; 3) use hex for the numbers.

This is compatible with SeaBIOS USB boot, which only looks at the
prefix for the usb-storage device (e.g. /pci@i0cf8/usb@1,2/storage@1),
and never at the SCSI part.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi-bus.c  |    4 ++--
 hw/scsi-disk.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 61c883f..07d6a7d 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -1307,8 +1307,8 @@ static char *scsibus_get_fw_dev_path(DeviceState *dev)
     SCSIDevice *d = DO_UPCAST(SCSIDevice, qdev, dev);
     char path[100];
 
-    snprintf(path, sizeof(path), "%s@%d:%d:%d", qdev_fw_name(dev),
-             d->channel, d->id, d->lun);
+    snprintf(path, sizeof(path), "channel@%x/%s@%x,%x", d->channel,
+             qdev_fw_name(dev), d->id, d->lun);
 
     return strdup(path);
 }
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 9da6d36..16a4714 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1581,7 +1581,7 @@ static int scsi_initfn(SCSIDevice *dev)
     bdrv_set_buffer_alignment(s->qdev.conf.bs, s->qdev.blocksize);
 
     bdrv_iostatus_enable(s->qdev.conf.bs);
-    add_boot_device_path(s->qdev.conf.bootindex, &dev->qdev, ",0");
+    add_boot_device_path(s->qdev.conf.bootindex, &dev->qdev, NULL);
     return 0;
 }
 
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 4/4] scsi-generic: add as boot device
  2011-11-18 15:31 [Qemu-devel] [PATCH 0/4] misc block fixes Paolo Bonzini
                   ` (2 preceding siblings ...)
  2011-11-18 15:32 ` [Qemu-devel] [PATCH 3/4] scsi: fix fw path Paolo Bonzini
@ 2011-11-18 15:32 ` Paolo Bonzini
  2011-11-21 14:15 ` [Qemu-devel] [PATCH 0/4] misc block fixes Kevin Wolf
  4 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2011-11-18 15:32 UTC (permalink / raw)
  To: qemu-devel

There is no reason why a scsi-generic device cannot boot if it has
the right type, and indeed it provides already a bootindex property.
So register those devices too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi-generic.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 48e0b50..6f7d3db 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -409,6 +409,10 @@ static int scsi_generic_initfn(SCSIDevice *s)
     /* define device state */
     s->type = scsiid.scsi_type;
     DPRINTF("device type %d\n", s->type);
+    if (s->type == TYPE_DISK || s->type == TYPE_ROM) {
+        add_boot_device_path(s->conf.bootindex, &s->qdev, NULL);
+    }
+
     switch (s->type) {
     case TYPE_TAPE:
         s->blocksize = get_stream_blocksize(s->conf.bs);
@@ -455,6 +459,7 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun,
 
 static SCSIDeviceInfo scsi_generic_info = {
     .qdev.name    = "scsi-generic",
+    .qdev.fw_name = "disk",
     .qdev.desc    = "pass through generic scsi device (/dev/sg*)",
     .qdev.size    = sizeof(SCSIDevice),
     .qdev.reset   = scsi_generic_reset,
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH rebased 3/4] scsi: fix fw path
  2011-11-18 15:32 ` [Qemu-devel] [PATCH 3/4] scsi: fix fw path Paolo Bonzini
@ 2011-11-18 16:03   ` Paolo Bonzini
  0 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2011-11-18 16:03 UTC (permalink / raw)
  To: qemu-devel

The pre-1.0 firmware path for SCSI devices already included the LUN
using the suffix argument to add_boot_device_path.  Avoid that it is
included twice, and convert the colons to commas for consistency with
other kinds of devices

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi-bus.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 086bddd..8f19f07 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -1395,8 +1395,8 @@ static char *scsibus_get_fw_dev_path(DeviceState *dev)
     SCSIDevice *d = DO_UPCAST(SCSIDevice, qdev, dev);
     char path[100];
 
-    snprintf(path, sizeof(path), "%s@%d,%d,%d", qdev_fw_name(dev),
-             d->channel, d->id, d->lun);
+    snprintf(path, sizeof(path), "channel@%x/%s@%x,%x", d->channel,
+             qdev_fw_name(dev), d->id, d->lun);
 
     return strdup(path);
 }
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH 0/4] misc block fixes
  2011-11-18 15:31 [Qemu-devel] [PATCH 0/4] misc block fixes Paolo Bonzini
                   ` (3 preceding siblings ...)
  2011-11-18 15:32 ` [Qemu-devel] [PATCH 4/4] scsi-generic: add as boot device Paolo Bonzini
@ 2011-11-21 14:15 ` Kevin Wolf
  4 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2011-11-21 14:15 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

Am 18.11.2011 16:31, schrieb Paolo Bonzini:
> See individual patches, all for 1.0.
> 
> Paolo Bonzini (4):
>   virtio-blk: fix cross-endian config space
>   usb-msd: do not register twice in the boot order
>   scsi: fix fw path
>   scsi-generic: add as boot device
> 
>  hw/pci-hotplug.c  |    3 ++-
>  hw/scsi-bus.c     |   11 +++++++----
>  hw/scsi-disk.c    |    2 +-
>  hw/scsi-generic.c |    5 +++++
>  hw/scsi.h         |    2 +-
>  hw/usb-msd.c      |    4 ++--
>  hw/virtio-blk.c   |    7 ++++---
>  7 files changed, 22 insertions(+), 12 deletions(-)

Thanks, applied all to the block-stable branch (for 1.0)

Kevin

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-11-21 14:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-18 15:31 [Qemu-devel] [PATCH 0/4] misc block fixes Paolo Bonzini
2011-11-18 15:31 ` [Qemu-devel] [PATCH 1/4] virtio-blk: fix cross-endian config space Paolo Bonzini
2011-11-18 15:32 ` [Qemu-devel] [PATCH 2/4] usb-msd: do not register twice in the boot order Paolo Bonzini
2011-11-18 15:32 ` [Qemu-devel] [PATCH 3/4] scsi: fix fw path Paolo Bonzini
2011-11-18 16:03   ` [Qemu-devel] [PATCH rebased " Paolo Bonzini
2011-11-18 15:32 ` [Qemu-devel] [PATCH 4/4] scsi-generic: add as boot device Paolo Bonzini
2011-11-21 14:15 ` [Qemu-devel] [PATCH 0/4] misc block fixes Kevin Wolf

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).