aboutsummaryrefslogtreecommitdiff
path: root/hw/ide
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-02-10 23:37:09 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-02-10 16:53:25 -0600
commit428c149b0be790b440e1cbee185b152cdb22feec (patch)
treed44fa0cdd84ba5fb9b4ea3c37791846c36d0a811 /hw/ide
parent37d5ddd6f4a898134b6430c0126378baf5abff4b (diff)
block: add topology qdev properties
Add three new qdev properties to export block topology information to the guest. This is needed to get optimal I/O alignment for RAID arrays or SSDs. The options are: - physical_block_size to specify the physical block size of the device, this is going to increase from 512 bytes to 4096 kilobytes for many modern storage devices - min_io_size to specify the minimal I/O size without performance impact, this is typically set to the RAID chunk size for arrays. - opt_io_size to specify the optimal sustained I/O size, this is typically the RAID stripe width for arrays. I decided to not auto-probe these values from blkid which might easily be possible as I don't know how to deal with these issues on migration. Note that we specificly only set the physical_block_size, and not the logial one which is the unit all I/O is described in. The reason for that is that IDE does not support increasing the logical block size and at last for now I want to stick to one meachnisms in queue and allow for easy switching of transports for a given backing image which would not be possible if scsi and virtio use real 4k sectors, while ide only uses the physical block exponent. To make this more common for the different block drivers introduce a new BlockConf structure holding all common block properties and a DEFINE_BLOCK_PROPERTIES macro to add them all together, mirroring what is done for network drivers. Also switch over all block drivers to use it, except for the floppy driver which has weird driveA/driveB properties and probably won't require any advanced block options ever. Example usage for a virtio device with 4k physical block size and 8k optimal I/O size: -drive file=scratch.img,media=disk,cache=none,id=scratch \ -device virtio-blk-pci,drive=scratch,physical_block_size=4096,opt_io_size=8192 aliguori: updated patch to take into account BLOCK events Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/ide')
-rw-r--r--hw/ide/core.c10
-rw-r--r--hw/ide/internal.h7
-rw-r--r--hw/ide/qdev.c7
3 files changed, 16 insertions, 8 deletions
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 603e53776e..4cfaf38211 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2594,7 +2594,8 @@ void ide_bus_reset(IDEBus *bus)
ide_clear_hob(bus);
}
-void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version)
+void ide_init_drive(IDEState *s, DriveInfo *dinfo, BlockConf *conf,
+ const char *version)
{
int cylinders, heads, secs;
uint64_t nb_sectors;
@@ -2619,6 +2620,9 @@ void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version)
}
strncpy(s->drive_serial_str, drive_get_serial(s->bs),
sizeof(s->drive_serial_str));
+ if (conf) {
+ s->conf = conf;
+ }
}
if (strlen(s->drive_serial_str) == 0)
snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),
@@ -2648,9 +2652,9 @@ void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,
s->sector_write_timer = qemu_new_timer(vm_clock,
ide_sector_write_timer_cb, s);
if (i == 0)
- ide_init_drive(s, hd0, NULL);
+ ide_init_drive(s, hd0, NULL, NULL);
if (i == 1)
- ide_init_drive(s, hd1, NULL);
+ ide_init_drive(s, hd1, NULL, NULL);
}
bus->irq = irq;
}
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index 1cc4b550f7..9945993655 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -7,6 +7,7 @@
* non-internal declarations are in hw/ide.h
*/
#include <hw/ide.h>
+#include "block_int.h"
/* debug IDE devices */
//#define DEBUG_IDE
@@ -397,6 +398,7 @@ struct IDEState {
/* set for lba48 access */
uint8_t lba48;
BlockDriverState *bs;
+ BlockConf *conf;
char version[9];
/* ATAPI specific */
uint8_t sense_key;
@@ -449,7 +451,7 @@ struct IDEBus {
struct IDEDevice {
DeviceState qdev;
uint32_t unit;
- DriveInfo *dinfo;
+ BlockConf conf;
char *version;
};
@@ -551,7 +553,8 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr);
void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);
uint32_t ide_data_readl(void *opaque, uint32_t addr);
-void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version);
+void ide_init_drive(IDEState *s, DriveInfo *dinfo, BlockConf *conf,
+ const char *version);
void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,
qemu_irq irq);
void ide_init_ioport(IDEBus *bus, int iobase, int iobase2);
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 0b84a4f1d0..b18693d945 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -40,7 +40,7 @@ static int ide_qdev_init(DeviceState *qdev, DeviceInfo *base)
IDEDeviceInfo *info = DO_UPCAST(IDEDeviceInfo, qdev, base);
IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev->parent_bus);
- if (!dev->dinfo) {
+ if (!dev->conf.dinfo) {
fprintf(stderr, "%s: no drive specified\n", qdev->info->name);
goto err;
}
@@ -99,7 +99,8 @@ typedef struct IDEDrive {
static int ide_drive_initfn(IDEDevice *dev)
{
IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
- ide_init_drive(bus->ifs + dev->unit, dev->dinfo, dev->version);
+ ide_init_drive(bus->ifs + dev->unit, dev->conf.dinfo, &dev->conf,
+ dev->version);
return 0;
}
@@ -109,7 +110,7 @@ static IDEDeviceInfo ide_drive_info = {
.init = ide_drive_initfn,
.qdev.props = (Property[]) {
DEFINE_PROP_UINT32("unit", IDEDrive, dev.unit, -1),
- DEFINE_PROP_DRIVE("drive", IDEDrive, dev.dinfo),
+ DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf),
DEFINE_PROP_STRING("ver", IDEDrive, dev.version),
DEFINE_PROP_END_OF_LIST(),
}