From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: [patch 08/24] QEMU/KVM: drive removal support Date: Tue, 11 Mar 2008 17:11:59 -0300 Message-ID: <20080311201417.831948218@localhost.localdomain> References: <20080311201151.959635433@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti To: qemu-devel@nongnu.org, kvm-devel@lists.sourceforge.net Return-path: Content-Disposition: inline; filename=device-removal List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org To be used by hot-remove. Signed-off-by: Marcelo Tosatti Index: kvm-userspace.hotplug2/qemu/vl.c =================================================================== --- kvm-userspace.hotplug2.orig/qemu/vl.c +++ kvm-userspace.hotplug2/qemu/vl.c @@ -5010,6 +5010,12 @@ static int drive_add(const char *file, c 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; @@ -5040,6 +5046,20 @@ int drive_get_max_bus(BlockInterfaceType return max_bus; } +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) { @@ -5313,6 +5333,7 @@ static int drive_init(struct drive_opt * drives_table[drives_table_idx].type = type; drives_table[drives_table_idx].bus = bus_id; drives_table[drives_table_idx].unit = unit_id; + drives_table[drives_table_idx].drive_opt_idx = arg - drives_opt; nb_drives++; switch(type) { Index: kvm-userspace.hotplug2/qemu/sysemu.h =================================================================== --- kvm-userspace.hotplug2.orig/qemu/sysemu.h +++ kvm-userspace.hotplug2/qemu/sysemu.h @@ -140,6 +140,7 @@ typedef struct DriveInfo { int bus; int unit; int used; + int drive_opt_idx; } DriveInfo; #define MAX_IDE_DEVS 2 @@ -153,6 +154,9 @@ int extboot_drive; 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); + /* acpi */ void qemu_system_cpu_hot_add(int cpu, int state); void qemu_system_hot_add_init(char *cpu_model); -- ------------------------------------------------------------------------- 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/ From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JZAyJ-0000x4-RB for qemu-devel@nongnu.org; Tue, 11 Mar 2008 16:21:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JZAyG-0000wd-KC for qemu-devel@nongnu.org; Tue, 11 Mar 2008 16:21:15 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JZAyG-0000wa-Dp for qemu-devel@nongnu.org; Tue, 11 Mar 2008 16:21:12 -0400 Received: from mx1.redhat.com ([66.187.233.31]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JZAyG-0005CE-3D for qemu-devel@nongnu.org; Tue, 11 Mar 2008 16:21:12 -0400 Message-Id: <20080311201417.831948218@localhost.localdomain> References: <20080311201151.959635433@localhost.localdomain> Date: Tue, 11 Mar 2008 17:11:59 -0300 From: Marcelo Tosatti Content-Disposition: inline; filename=device-removal Subject: [Qemu-devel] [patch 08/24] QEMU/KVM: drive removal support 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, kvm-devel@lists.sourceforge.net Cc: aliguori@us.ibm.com, Marcelo Tosatti To be used by hot-remove. Signed-off-by: Marcelo Tosatti Index: kvm-userspace.hotplug2/qemu/vl.c =================================================================== --- kvm-userspace.hotplug2.orig/qemu/vl.c +++ kvm-userspace.hotplug2/qemu/vl.c @@ -5010,6 +5010,12 @@ static int drive_add(const char *file, c 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; @@ -5040,6 +5046,20 @@ int drive_get_max_bus(BlockInterfaceType return max_bus; } +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) { @@ -5313,6 +5333,7 @@ static int drive_init(struct drive_opt * drives_table[drives_table_idx].type = type; drives_table[drives_table_idx].bus = bus_id; drives_table[drives_table_idx].unit = unit_id; + drives_table[drives_table_idx].drive_opt_idx = arg - drives_opt; nb_drives++; switch(type) { Index: kvm-userspace.hotplug2/qemu/sysemu.h =================================================================== --- kvm-userspace.hotplug2.orig/qemu/sysemu.h +++ kvm-userspace.hotplug2/qemu/sysemu.h @@ -140,6 +140,7 @@ typedef struct DriveInfo { int bus; int unit; int used; + int drive_opt_idx; } DriveInfo; #define MAX_IDE_DEVS 2 @@ -153,6 +154,9 @@ int extboot_drive; 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); + /* acpi */ void qemu_system_cpu_hot_add(int cpu, int state); void qemu_system_hot_add_init(char *cpu_model); --