From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@pond.sub.org>
Subject: [Qemu-devel] [PATCH 4/4] Support addr=... in option argument of -drive if=virtio
Date: Thu, 18 Jun 2009 15:14:10 +0200 [thread overview]
Message-ID: <cef4948c23919581eb8e391a06f2e52c9715b2ad.1245324582.git.armbru@redhat.com> (raw)
In-Reply-To: <cover.1245324581.git.armbru@redhat.com>
From: Markus Armbruster <armbru@pond.sub.org>
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>
---
hw/pc.c | 5 ++++-
hw/pci-hotplug.c | 8 ++++++++
hw/ppc440_bamboo.c | 4 +++-
hw/ppce500_mpc8544ds.c | 4 +++-
qemu-options.hx | 3 +++
sysemu.h | 1 +
vl.c | 14 +++++++++++++-
7 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 4b918bb..cd3ac82 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -848,6 +848,7 @@ static void pc_init1(ram_addr_t ram_size,
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;
@@ -1146,7 +1147,9 @@ static void pc_init1(ram_addr_t ram_size,
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++;
}
}
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index 031643e..952e27a 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -70,6 +70,10 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
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);
@@ -116,6 +120,10 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
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;
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index 312abde..3bc04a2 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -90,6 +90,7 @@ static void bamboo_init(ram_addr_t ram_size,
{
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;
@@ -110,7 +111,8 @@ static void bamboo_init(ram_addr_t ram_size,
/* 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++;
}
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index aff3ae2..c0e367d 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -157,6 +157,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
const char *cpu_model)
{
PCIBus *pci_bus;
+ PCIDevice *pci_dev;
CPUState *env;
uint64_t elf_entry;
uint64_t elf_lowaddr;
@@ -219,7 +220,8 @@ static void mpc8544ds_init(ram_addr_t ram_size,
/* 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++;
}
diff --git a/qemu-options.hx b/qemu-options.hx
index 895b248..fdeda10 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -92,6 +92,7 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive,
"-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}[,...]]]
@@ -126,6 +127,8 @@ the format. Can be used to specifiy format=raw to avoid interpreting
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
diff --git a/sysemu.h b/sysemu.h
index fe24415..e48668c 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -156,6 +156,7 @@ typedef enum {
typedef struct DriveInfo {
BlockDriverState *bdrv;
+ const char *devaddr;
BlockInterfaceType type;
int bus;
int unit;
diff --git a/vl.c b/vl.c
index 3242c23..2e812d3 100644
--- a/vl.c
+++ b/vl.c
@@ -2209,12 +2209,14 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
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) {
@@ -2428,6 +2430,15 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
}
}
+ 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) {
@@ -2489,6 +2500,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
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;
--
1.6.0.6
next prev parent reply other threads:[~2009-06-18 13:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-18 13:14 [Qemu-devel] [RFC PATCH 0/4] Configurable PCI device addresses Markus Armbruster
2009-06-18 13:14 ` [Qemu-devel] [PATCH 1/4] Fix do_pci_register_device() to reject devfn already in use Markus Armbruster
2009-06-18 13:14 ` [Qemu-devel] [PATCH 2/4] Support addr=... in option argument of -net nic Markus Armbruster
2009-06-18 13:14 ` [Qemu-devel] [PATCH 3/4] Make first argument of monitor command pci_add work Markus Armbruster
2009-06-18 13:14 ` Markus Armbruster [this message]
2009-06-18 14:18 ` [Qemu-devel] [RFC PATCH 0/4] Configurable PCI device addresses Richard W.M. Jones
2009-06-18 14:25 ` Gerd Hoffmann
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=cef4948c23919581eb8e391a06f2e52c9715b2ad.1245324582.git.armbru@redhat.com \
--to=armbru@redhat.com \
--cc=armbru@pond.sub.org \
--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).