From: Marcelo Tosatti <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> diff --git a/qemu/net.h b/qemu/net.h index d45fc9d..bb30e05 100644 --- a/qemu/net.h +++ b/qemu/net.h @@ -37,6 +37,8 @@ void do_info_network(void); /* virtio hack for zero copy receive */ int hack_around_tap(void *opaque); +int net_client_init(const char *str); + /* NIC info */ #define MAX_NICS 8 diff --git a/qemu/sysemu.h b/qemu/sysemu.h index 9a5c17a..e74d56b 100644 --- a/qemu/sysemu.h +++ b/qemu/sysemu.h @@ -166,6 +166,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); + /* acpi */ void qemu_system_cpu_hot_add(int cpu, int state); void qemu_system_hot_add_init(char *cpu_model); diff --git a/qemu/vl.c b/qemu/vl.c index f5d26a0..9a02343 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -4797,7 +4797,7 @@ static int nic_get_free_idx(void) return -1; } -static int net_client_init(const char *str) +int net_client_init(const char *str) { const char *p; char *q; @@ -4856,7 +4856,7 @@ static int net_client_init(const char *str) nd->used = 1; 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 @@ -4986,14 +4986,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; @@ -5056,9 +5056,10 @@ 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) { + QEMUMachine *machine = opaque; char buf[128]; char file[1024]; char devname[128]; @@ -5311,7 +5312,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 */ @@ -5359,7 +5360,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; @@ -5370,7 +5371,7 @@ static int drive_init(struct drive_opt *arg, int snapshot, file); return -1; } - return 0; + return drives_table_idx; } /***********************************************************/ ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ kvm-commits mailing list kvm-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-commits