Make drive_init() accept addr=, put the value into struct DriveInfo.
Use it in all the places that create virtio-blk-pci devices:
pc_init1(), bamboo_init(), mpc8544ds_init().
Don't support addr= in third argument of monitor command pci_add and
second argument of drive_add, because that clashes with their first
arguments. Admittedly unelegant.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
int bios_size, isa_bios_size, oprom_area_size;
PCIBus *pci_bus;
+ PCIDevice *pci_dev;
int piix3_devfn = -1;
CPUState *env;
qemu_irq *cpu_irq;
int unit_id = 0;
while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
- pci_create_simple(pci_bus, -1, "virtio-blk-pci");
+ pci_dev = pci_create("virtio-blk-pci",
+ drives_table[index].devaddr);
+ qdev_init(&pci_dev->qdev);
unit_id++;
}
}
drive_idx = add_init_drive(opts);
if (drive_idx < 0)
return;
+ if (drives_table[drive_idx].devaddr) {
+ monitor_printf(mon, "Parameter addr not supported\n");
+ return;
+ }
type = drives_table[drive_idx].type;
bus = drive_get_max_bus (type);
drive_idx = add_init_drive(opts);
if (drive_idx < 0)
return NULL;
+ if (drives_table[drive_idx].devaddr) {
+ monitor_printf(mon, "Parameter addr not supported\n");
+ return NULL;
+ }
} else if (type == IF_VIRTIO) {
monitor_printf(mon, "virtio requires a backing file/device.\n");
return NULL;
{
unsigned int pci_irq_nrs[4] = { 28, 27, 26, 25 };
PCIBus *pcibus;
+ PCIDevice *pci_dev;
CPUState *env;
uint64_t elf_entry;
uint64_t elf_lowaddr;
/* Add virtio block devices. */
while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
- pci_create_simple(pcibus, -1, "virtio-blk-pci");
+ pci_dev = pci_create("virtio-blk-pci", drives_table[i].devaddr);
+ qdev_init(&pci_dev->qdev);
unit_id++;
}
const char *cpu_model)
{
PCIBus *pci_bus;
+ PCIDevice *pci_dev;
CPUState *env;
uint64_t elf_entry;
uint64_t elf_lowaddr;
/* Add virtio block devices. */
while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
- pci_create_simple(pci_bus, -1, "virtio-blk-pci");
+ pci_dev = pci_create("virtio-blk-pci", drives_table[i].devaddr);
+ qdev_init(&pci_dev->qdev);
unit_id++;
}
"-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
" [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
" [,cache=writethrough|writeback|none][,format=f][,serial=s]\n"
+ " [,addr=A]\n"
" use 'file' as a drive image\n")
STEXI
@item -drive @var{option}[,@var{option}[,@var{option}[,...]]]
an untrusted format header.
@item serial=@var{serial}
This option specifies the serial number to assign to the device.
+@item addr=@var{addr}
+Specify the controller's PCI address (if=virtio only).
@end table
By default, writethrough caching is used for all block device. This means that
typedef struct DriveInfo {
BlockDriverState *bdrv;
+ const char *devaddr;
BlockInterfaceType type;
int bus;
int unit;
int index;
int cache;
int bdrv_flags, onerror;
+ const char *devaddr;
int drives_table_idx;
char *str = arg->opt;
static const char * const params[] = { "bus", "unit", "if", "index",
"cyls", "heads", "secs", "trans",
"media", "snapshot", "file",
- "cache", "format", "serial", "werror",
+ "cache", "format", "serial",
+ "werror", "addr",
NULL };
if (check_params(buf, sizeof(buf), params, str) < 0) {
}
}
+ devaddr = NULL;
+ if (get_param_value(buf, sizeof(buf), "addr", str)) {
+ if (type != IF_VIRTIO) {
+ fprintf(stderr, "addr is not supported by in '%s'\n", str);
+ return -1;
+ }
+ devaddr = strdup(buf);
+ }
+
/* compute bus and unit according index */
if (index != -1) {
bdrv = bdrv_new(buf);
drives_table_idx = drive_get_free_idx();
drives_table[drives_table_idx].bdrv = bdrv;
+ drives_table[drives_table_idx].devaddr = devaddr;
drives_table[drives_table_idx].type = type;
drives_table[drives_table_idx].bus = bus_id;
drives_table[drives_table_idx].unit = unit_id;