diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-07-22 16:42:57 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-07-27 14:08:23 -0500 |
commit | 751c6a17042b5d011013d6963c0505d671cf708e (patch) | |
tree | 61a769ed1a1c16ebdfc1397ce9d775222dfa8e57 /hw/device-hotplug.c | |
parent | 8a14daa5a1ae22fcfc317f4727a88d6c15c39aae (diff) |
kill drives_table
First step cleaning up the drives handling. This one does nothing but
removing drives_table[], still it became seriously big.
drive_get_index() is gone and is replaced by drives_get() which hands
out DriveInfo pointers instead of a table index. This needs adaption in
*tons* of places all over.
The drives are now maintained as linked list.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/device-hotplug.c')
-rw-r--r-- | hw/device-hotplug.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index e178083419..5257274efd 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -28,22 +28,23 @@ #include "block_int.h" #include "sysemu.h" -int add_init_drive(const char *opts) +DriveInfo *add_init_drive(const char *opts) { - int drive_opt_idx, drive_idx; - int ret = -1; + int drive_opt_idx; + int fatal_error; + DriveInfo *dinfo; drive_opt_idx = drive_add(NULL, "%s", opts); if (!drive_opt_idx) - return ret; + return NULL; - drive_idx = drive_init(&drives_opt[drive_opt_idx], 0, current_machine); - if (drive_idx == -1) { + dinfo = drive_init(&drives_opt[drive_opt_idx], 0, current_machine, &fatal_error); + if (!dinfo) { drive_remove(drive_opt_idx); - return ret; + return NULL; } - return drive_idx; + return dinfo; } void destroy_nic(dev_match_fn *match_fn, void *arg) @@ -64,11 +65,11 @@ void destroy_nic(dev_match_fn *match_fn, void *arg) void destroy_bdrvs(dev_match_fn *match_fn, void *arg) { - int i; + DriveInfo *dinfo; struct BlockDriverState *bs; - for (i = 0; i <= MAX_DRIVES; i++) { - bs = drives_table[i].bdrv; + TAILQ_FOREACH(dinfo, &drives, next) { + bs = dinfo->bdrv; if (bs) { if (bs->private && match_fn(bs->private, arg)) { drive_uninit(bs); |