aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-02-11 15:20:20 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-02-11 15:20:20 +0000
commitb01b11113c32425e888139d8e99e699f90da3a8d (patch)
treefea209ba7bd81596fa1b1522c27677a59c24d5af /vl.c
parent7697079b73360cef3d8f1cd014a87bd923464b26 (diff)
qemu: drive removal support (Marcelo Tosatti)
To be used by hot-remove. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6596 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index fb61903ea9..219815114d 100644
--- a/vl.c
+++ b/vl.c
@@ -2182,6 +2182,12 @@ static int drive_add(const char *file, const char *fmt, ...)
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 *opaque, const char *name)
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 *arg, int snapshot,
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++;