From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LXGt4-0003vR-6k for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:20:30 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LXGt3-0003vA-Db for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:20:29 -0500 Received: from [199.232.76.173] (port=52330 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LXGt3-0003v0-5S for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:20:29 -0500 Received: from savannah.gnu.org ([199.232.41.3]:40278 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 1LXGt0-0002AB-CX for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:20:27 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LXGsy-0004pT-8c for qemu-devel@nongnu.org; Wed, 11 Feb 2009 15:20:24 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LXGsw-0004pP-I9 for qemu-devel@nongnu.org; Wed, 11 Feb 2009 15:20:22 +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:22 +0000 Subject: [Qemu-devel] [6596] qemu: drive removal support (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: 6596 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6596 Author: aliguori Date: 2009-02-11 15:20:20 +0000 (Wed, 11 Feb 2009) Log Message: ----------- qemu: drive removal support (Marcelo Tosatti) To be used by hot-remove. Signed-off-by: Marcelo Tosatti Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/sysemu.h trunk/vl.c Modified: trunk/sysemu.h =================================================================== --- trunk/sysemu.h 2009-02-11 15:20:03 UTC (rev 6595) +++ trunk/sysemu.h 2009-02-11 15:20:20 UTC (rev 6596) @@ -135,6 +135,7 @@ int bus; int unit; int used; + int drive_opt_idx; BlockInterfaceErrorAction onerror; char serial[21]; } DriveInfo; @@ -148,6 +149,8 @@ extern int drive_get_index(BlockInterfaceType type, int bus, int unit); extern int drive_get_max_bus(BlockInterfaceType type); +extern void drive_uninit(BlockDriverState *bdrv); +extern void drive_remove(int index); extern const char *drive_get_serial(BlockDriverState *bdrv); extern BlockInterfaceErrorAction drive_get_onerror(BlockDriverState *bdrv); Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2009-02-11 15:20:03 UTC (rev 6595) +++ trunk/vl.c 2009-02-11 15:20:20 UTC (rev 6596) @@ -2182,6 +2182,12 @@ return index; } +void drive_remove(int index) +{ + drives_opt[index].used = 0; + nb_drives_opt--; +} + int drive_get_index(BlockInterfaceType type, int bus, int unit) { int index; @@ -2239,6 +2245,20 @@ fprintf(stderr, " %s", name); } +void drive_uninit(BlockDriverState *bdrv) +{ + int i; + + for (i = 0; i < MAX_DRIVES; i++) + if (drives_table[i].bdrv == bdrv) { + drives_table[i].bdrv = NULL; + drives_table[i].used = 0; + drive_remove(drives_table[i].drive_opt_idx); + nb_drives--; + break; + } +} + static int drive_init(struct drive_opt *arg, int snapshot, QEMUMachine *machine) { @@ -2538,6 +2558,7 @@ drives_table[drives_table_idx].bus = bus_id; drives_table[drives_table_idx].unit = unit_id; drives_table[drives_table_idx].onerror = onerror; + drives_table[drives_table_idx].drive_opt_idx = arg - drives_opt; strncpy(drives_table[nb_drives].serial, serial, sizeof(serial)); nb_drives++;