summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--net.c2
-rw-r--r--sysemu.h3
-rw-r--r--vl.c14
3 files changed, 11 insertions, 8 deletions
diff --git a/net.c b/net.c
index 6edeee81da..c581dcc087 100644
--- a/net.c
+++ b/net.c
@@ -1597,7 +1597,7 @@ int net_client_init(const char *device, const char *p)
name = NULL;
nb_nics++;
vlan->nb_guest_devs++;
- ret = 0;
+ ret = idx;
} else
if (!strcmp(device, "none")) {
/* does nothing. It is needed to signal that no network cards
diff --git a/sysemu.h b/sysemu.h
index 9b99343368..2cd16b1f60 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -163,6 +163,9 @@ struct drive_opt {
extern struct drive_opt drives_opt[MAX_DRIVES];
extern int nb_drives_opt;
+extern int drive_add(const char *file, const char *fmt, ...);
+extern int drive_init(struct drive_opt *arg, int snapshot, void *machine);
+
/* serial ports */
#define MAX_SERIAL_PORTS 4
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;
}
/***********************************************************/