From c2cc47a449c3e16f7dd4d19a536c649ec56a9ac9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 18 Jun 2009 15:14:10 +0200 Subject: Support addr=... in option argument of -drive if=virtio 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 Signed-off-by: Anthony Liguori --- vl.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index ca26450e30..7ef97484bf 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; -- cgit v1.2.1