[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [patch 08/19] qemu: net/drive add/remove tweaks
From: |
Marcelo Tosatti |
Subject: |
[Qemu-devel] [patch 08/19] qemu: net/drive add/remove tweaks |
Date: |
Tue, 10 Feb 2009 18:30:59 -0200 |
User-agent: |
quilt/0.46-1 |
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 <address@hidden>
Index: trunk/net.c
===================================================================
--- trunk.orig/net.c
+++ trunk/net.c
@@ -1597,7 +1597,7 @@ int net_client_init(const char *device,
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
Index: trunk/sysemu.h
===================================================================
--- trunk.orig/sysemu.h
+++ trunk/sysemu.h
@@ -163,6 +163,9 @@ struct drive_opt {
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
Index: trunk/vl.c
===================================================================
--- trunk.orig/vl.c
+++ trunk/vl.c
@@ -2158,14 +2158,14 @@ static int drive_get_free_idx(void)
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 @@ void drive_uninit(BlockDriverState *bdrv
}
}
-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 @@ static int drive_init(struct drive_opt *
int cyls, heads, secs, translation;
BlockDriverState *bdrv;
BlockDriver *drv = NULL;
+ QEMUMachine *machine = opaque;
int max_devs;
int index;
int cache;
@@ -2535,7 +2535,7 @@ static int drive_init(struct drive_opt *
*/
if (drive_get_index(type, bus_id, unit_id) != -1)
- return 0;
+ return -2;
/* init */
@@ -2585,7 +2585,7 @@ static int drive_init(struct drive_opt *
break;
}
if (!file[0])
- return 0;
+ return -2;
bdrv_flags = 0;
if (snapshot) {
bdrv_flags |= BDRV_O_SNAPSHOT;
@@ -2602,7 +2602,7 @@ static int drive_init(struct drive_opt *
file);
return -1;
}
- return 0;
+ return drives_table_idx;
}
/***********************************************************/
--
- [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, 2009/02/10
- [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 <=
- [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
- [Qemu-devel] [patch 15/19] qemu: zero ioport_opaque on isa_unassign_ioport, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 18/19] From: Markus Armbruster <address@hidden>, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 17/19] qemu: pci hotplug GPE support, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 19/19] qemu: PCI device, disk and host network hot-add / hot-remove, Marcelo Tosatti, 2009/02/10