Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LXGtO-00042W-CW for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:20:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LXGtN-00042C-Or for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:20:50 -0500 Received: from [199.232.76.173] (port=52343 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LXGtN-000425-Ib for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:20:49 -0500 Received: from savannah.gnu.org ([199.232.41.3]:40289 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LXGtN-0002Cl-9e for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:20:49 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LXGtM-0004qV-0d for qemu-devel@nongnu.org; Wed, 11 Feb 2009 15:20:48 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LXGtL-0004qQ-2p for qemu-devel@nongnu.org; Wed, 11 Feb 2009 15:20:47 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Wed, 11 Feb 2009 15:20:47 +0000 Subject: [Qemu-devel] [6599] qemu: net/drive add/remove tweaks (Marcelo Tosatti) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6599 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6599 Author: aliguori Date: 2009-02-11 15:20:46 +0000 (Wed, 11 Feb 2009) Log Message: ----------- 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 Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/net.c trunk/sysemu.h trunk/vl.c Modified: trunk/net.c =================================================================== --- trunk/net.c 2009-02-11 15:20:37 UTC (rev 6598) +++ trunk/net.c 2009-02-11 15:20:46 UTC (rev 6599) @@ -1597,7 +1597,7 @@ 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 Modified: trunk/sysemu.h =================================================================== --- trunk/sysemu.h 2009-02-11 15:20:37 UTC (rev 6598) +++ trunk/sysemu.h 2009-02-11 15:20:46 UTC (rev 6599) @@ -163,6 +163,9 @@ 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 Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2009-02-11 15:20:37 UTC (rev 6598) +++ trunk/vl.c 2009-02-11 15:20:46 UTC (rev 6599) @@ -2158,14 +2158,14 @@ 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 @@ } } -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 @@ int cyls, heads, secs, translation; BlockDriverState *bdrv; BlockDriver *drv = NULL; + QEMUMachine *machine = opaque; int max_devs; int index; int cache; @@ -2535,7 +2535,7 @@ */ if (drive_get_index(type, bus_id, unit_id) != -1) - return 0; + return -2; /* init */ @@ -2585,7 +2585,7 @@ break; } if (!file[0]) - return 0; + return -2; bdrv_flags = 0; if (snapshot) { bdrv_flags |= BDRV_O_SNAPSHOT; @@ -2602,7 +2602,7 @@ file); return -1; } - return 0; + return drives_table_idx; } /***********************************************************/