[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [patch 11/24] QEMU/KVM: net/drive add/remove tweaks
From: |
Marcelo Tosatti |
Subject: |
[Qemu-devel] [patch 11/24] QEMU/KVM: net/drive add/remove tweaks |
Date: |
Tue, 11 Mar 2008 17:12:02 -0300 |
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: kvm-userspace.hotplug2/qemu/vl.c
===================================================================
--- kvm-userspace.hotplug2.orig/qemu/vl.c
+++ kvm-userspace.hotplug2/qemu/vl.c
@@ -4797,7 +4797,7 @@ static int nic_get_free_idx(void)
return -1;
}
-static int net_client_init(const char *str)
+int net_client_init(const char *str)
{
const char *p;
char *q;
@@ -4856,7 +4856,7 @@ static int net_client_init(const char *s
nd->used = 1;
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
@@ -4986,14 +4986,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;
@@ -5056,9 +5056,10 @@ 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)
{
+ QEMUMachine *machine = opaque;
char buf[128];
char file[1024];
char devname[128];
@@ -5311,7 +5312,7 @@ static int drive_init(struct drive_opt *
*/
if (drive_get_index(type, bus_id, unit_id) != -1)
- return 0;
+ return -2;
/* init */
@@ -5359,7 +5360,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;
@@ -5370,7 +5371,7 @@ static int drive_init(struct drive_opt *
file);
return -1;
}
- return 0;
+ return drives_table_idx;
}
/***********************************************************/
Index: kvm-userspace.hotplug2/qemu/net.h
===================================================================
--- kvm-userspace.hotplug2.orig/qemu/net.h
+++ kvm-userspace.hotplug2/qemu/net.h
@@ -37,6 +37,8 @@ void do_info_network(void);
/* virtio hack for zero copy receive */
int hack_around_tap(void *opaque);
+int net_client_init(const char *str);
+
/* NIC info */
#define MAX_NICS 8
Index: kvm-userspace.hotplug2/qemu/sysemu.h
===================================================================
--- kvm-userspace.hotplug2.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug2/qemu/sysemu.h
@@ -166,6 +166,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);
+
/* acpi */
void qemu_system_cpu_hot_add(int cpu, int state);
void qemu_system_hot_add_init(char *cpu_model);
--
- [Qemu-devel] [patch 03/24] QEMU/KVM: add pci_find_bus, (continued)
- [Qemu-devel] [patch 03/24] QEMU/KVM: add pci_find_bus, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 07/24] QEMU/KVM: dynamic nic info index allocation, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 06/24] QEMU/KVM: dynamic drive/drive_opt index allocation, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 04/24] QEMU/KVM: return PCIDevice on net device init and record devfn, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 09/24] QEMU/KVM: record devfn on block driver instance, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 13/24] QEMU/KVM: export get_param_value/check_params, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 10/24] QEMU/KVM: move drives_opt for external use, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 12/24] QEMU/KVM: add net_client_uninit, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 14/24] QEMU/KVM: add pci_find_device, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 15/24] QEMU/KVM: virtio_blk_init return PCIDevice pointer, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 11/24] QEMU/KVM: net/drive add/remove tweaks,
Marcelo Tosatti <=
- [Qemu-devel] [patch 17/24] QEMU/KVM: add cpu_unregister_io_memory and make io mem table index dynamic, Marcelo Tosatti, 2008/03/12
[Qemu-devel] [patch 19/24] QEMU/KVM: handle SEJ notifications, Marcelo Tosatti, 2008/03/12
[Qemu-devel] [patch 20/24] QEMU/KVM: add qemu_free_irqs, Marcelo Tosatti, 2008/03/12
[Qemu-devel] [patch 22/24] QEMU/KVM: LSI SCSI and e1000 unregister callbacks, Marcelo Tosatti, 2008/03/12
[Qemu-devel] [patch 23/24] QEMU/KVM: zero ioport_opaque on isa_unassign_ioport, Marcelo Tosatti, 2008/03/12
[Qemu-devel] [patch 24/24] QEMU/KVM: device hot-remove, Marcelo Tosatti, 2008/03/12