[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [patch 05/19] qemu: drive removal support
From: |
Marcelo Tosatti |
Subject: |
[Qemu-devel] [patch 05/19] qemu: drive removal support |
Date: |
Tue, 10 Feb 2009 18:30:56 -0200 |
User-agent: |
quilt/0.46-1 |
To be used by hot-remove.
Signed-off-by: Marcelo Tosatti <address@hidden>
Index: trunk/sysemu.h
===================================================================
--- trunk.orig/sysemu.h
+++ trunk/sysemu.h
@@ -135,6 +135,7 @@ typedef struct DriveInfo {
int bus;
int unit;
int used;
+ int drive_opt_idx;
BlockInterfaceErrorAction onerror;
char serial[21];
} DriveInfo;
@@ -148,6 +149,8 @@ extern DriveInfo drives_table[MAX_DRIVES
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);
Index: trunk/vl.c
===================================================================
--- trunk.orig/vl.c
+++ trunk/vl.c
@@ -2182,6 +2182,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;
@@ -2239,6 +2245,20 @@ static void bdrv_format_print(void *opaq
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 @@ static int drive_init(struct drive_opt *
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++;
--
- [Qemu-devel] [patch 00/19] acpi pci hotplug, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 02/19] qemu: return PCIDevice on net device init and record devfn, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 03/19] qemu: dynamic drive/drive_opt index allocation, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 01/19] qemu: add pci helper functions, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 04/19] qemu: dynamic nic info index allocation, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 05/19] qemu: drive removal support,
Marcelo Tosatti <=
- [Qemu-devel] [patch 06/19] qemu: record devfn on block driver instance, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 07/19] qemu: move drives_opt for external use, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 09/19] qemu: add net_client_uninit / qemu_find_vlan_client, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 08/19] qemu: net/drive add/remove tweaks, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 10/19] qemu: add cpu_unregister_io_memory and make io mem table index dynamic, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 11/19] qemu: add qemu_free_irqs, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 12/19] qemu: add pci_unregister_device, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 13/19] qemu: warn if PCI region is not power of two, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 14/19] qemu: LSI SCSI and e1000 unregister callbacks, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 16/19] qemu: initialize hot add system / acpi gpe, Marcelo Tosatti, 2009/02/10