aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-02-11 15:20:46 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-02-11 15:20:46 +0000
commit4d73cd3b3f55fcff433ce64b125b7adb8aaece29 (patch)
tree573ae20025d481672fcbd3499f7d3b3509c4502f /vl.c
parentec691c804f66ee99dc24a6cfe4467a56982f9115 (diff)
qemu: net/drive add/remove tweaks (Marcelo Tosatti)
Export net/drive add/remove functions for device hotplug usage. Return the table index on add. Return failure instead of exiting if limit has been reached on drive_add. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6599 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/vl.c b/vl.c
index 7b51b54b9e..ba1e643573 100644
--- a/vl.c
+++ b/vl.c
@@ -2158,14 +2158,14 @@ static int drive_get_free_idx(void)
return -1;
}
-static int drive_add(const char *file, const char *fmt, ...)
+int drive_add(const char *file, const char *fmt, ...)
{
va_list ap;
int index = drive_opt_get_free_idx();
if (nb_drives_opt >= MAX_DRIVES || index == -1) {
fprintf(stderr, "qemu: too many drives\n");
- exit(1);
+ return -1;
}
drives_opt[index].file = file;
@@ -2255,8 +2255,7 @@ void drive_uninit(BlockDriverState *bdrv)
}
}
-static int drive_init(struct drive_opt *arg, int snapshot,
- QEMUMachine *machine)
+int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
{
char buf[128];
char file[1024];
@@ -2269,6 +2268,7 @@ static int drive_init(struct drive_opt *arg, int snapshot,
int cyls, heads, secs, translation;
BlockDriverState *bdrv;
BlockDriver *drv = NULL;
+ QEMUMachine *machine = opaque;
int max_devs;
int index;
int cache;
@@ -2535,7 +2535,7 @@ static int drive_init(struct drive_opt *arg, int snapshot,
*/
if (drive_get_index(type, bus_id, unit_id) != -1)
- return 0;
+ return -2;
/* init */
@@ -2585,7 +2585,7 @@ static int drive_init(struct drive_opt *arg, int snapshot,
break;
}
if (!file[0])
- return 0;
+ return -2;
bdrv_flags = 0;
if (snapshot) {
bdrv_flags |= BDRV_O_SNAPSHOT;
@@ -2602,7 +2602,7 @@ static int drive_init(struct drive_opt *arg, int snapshot,
file);
return -1;
}
- return 0;
+ return drives_table_idx;
}
/***********************************************************/