From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm-devel@lists.sourceforge.net
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
Avi Kivity <avi@qumranet.com>, Glauber Costa <gcosta@redhat.com>
Subject: [patch 05/23] QEMU/KVM: return PCIDevice on net device init and record devfn
Date: Tue, 04 Mar 2008 15:34:24 -0300 [thread overview]
Message-ID: <20080304183902.991361986@localhost.localdomain> (raw)
In-Reply-To: 20080304183419.187172133@localhost.localdomain
[-- Attachment #1: return-pcidev --]
[-- Type: text/plain, Size: 10023 bytes --]
Change the PCI network drivers init functions to return the PCIDev, to
inform which slot has been hot-plugged.
Also record devfn on the NICInfo structure to locate for release
on hot-removal.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.hotplug/qemu/hw/e1000.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/e1000.c
+++ kvm-userspace.hotplug/qemu/hw/e1000.c
@@ -932,7 +932,7 @@ e1000_mmio_map(PCIDevice *pci_dev, int r
cpu_register_physical_memory(addr, PNPMMIO_SIZE, d->mmio_index);
}
-void
+PCIDevice *
pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)
{
E1000State *d;
@@ -996,4 +996,6 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd,
d->nd->macaddr[3], d->nd->macaddr[4], d->nd->macaddr[5]);
register_savevm(info_str, d->instance, 1, nic_save, nic_load, d);
+
+ return (PCIDevice *)d;
}
Index: kvm-userspace.hotplug/qemu/hw/eepro100.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/eepro100.c
+++ kvm-userspace.hotplug/qemu/hw/eepro100.c
@@ -1742,7 +1742,7 @@ static void nic_save(QEMUFile * f, void
qemu_put_buffer(f, s->configuration, sizeof(s->configuration));
}
-static void nic_init(PCIBus * bus, NICInfo * nd,
+static PCIDevice *nic_init(PCIBus * bus, NICInfo * nd,
const char *name, uint32_t device)
{
PCIEEPRO100State *d;
@@ -1794,22 +1794,23 @@ static void nic_init(PCIBus * bus, NICIn
/* XXX: instance number ? */
register_savevm(name, 0, 3, nic_save, nic_load, s);
+ return (PCIDevice *)d;
}
-void pci_i82551_init(PCIBus * bus, NICInfo * nd, int devfn)
+PCIDevice *pci_i82551_init(PCIBus * bus, NICInfo * nd, int devfn)
{
- nic_init(bus, nd, "i82551", i82551);
+ return nic_init(bus, nd, "i82551", i82551);
//~ uint8_t *pci_conf = d->dev.config;
}
-void pci_i82557b_init(PCIBus * bus, NICInfo * nd, int devfn)
+PCIDevice *pci_i82557b_init(PCIBus * bus, NICInfo * nd, int devfn)
{
- nic_init(bus, nd, "i82557b", i82557B);
+ return nic_init(bus, nd, "i82557b", i82557B);
}
-void pci_i82559er_init(PCIBus * bus, NICInfo * nd, int devfn)
+PCIDevice *pci_i82559er_init(PCIBus * bus, NICInfo * nd, int devfn)
{
- nic_init(bus, nd, "i82559er", i82559ER);
+ return nic_init(bus, nd, "i82559er", i82559ER);
}
/* eof */
Index: kvm-userspace.hotplug/qemu/hw/ne2000.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/ne2000.c
+++ kvm-userspace.hotplug/qemu/hw/ne2000.c
@@ -786,7 +786,7 @@ static void ne2000_map(PCIDevice *pci_de
register_ioport_read(addr + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
}
-void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
{
PCINE2000State *d;
NE2000State *s;
@@ -827,4 +827,6 @@ void pci_ne2000_init(PCIBus *bus, NICInf
/* XXX: instance number ? */
register_savevm("ne2000", ne2000_id++, 3, ne2000_save, ne2000_load, s);
+
+ return (PCIDevice *)d;
}
Index: kvm-userspace.hotplug/qemu/hw/pc.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pc.h
+++ kvm-userspace.hotplug/qemu/hw/pc.h
@@ -146,7 +146,7 @@ void isa_ne2000_init(int base, qemu_irq
/* virtio-net.c */
-void *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
void virtio_net_poll(void);
/* virtio-blk.h */
Index: kvm-userspace.hotplug/qemu/hw/pci.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug/qemu/hw/pci.c
@@ -625,24 +625,26 @@ void pci_info(void)
}
/* Initialize a PCI NIC. */
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)
{
+ PCIDevice *pci_dev;
+
if (strcmp(nd->model, "ne2k_pci") == 0) {
- pci_ne2000_init(bus, nd, devfn);
+ pci_dev = pci_ne2000_init(bus, nd, devfn);
} else if (strcmp(nd->model, "i82551") == 0) {
- pci_i82551_init(bus, nd, devfn);
+ pci_dev = pci_i82551_init(bus, nd, devfn);
} else if (strcmp(nd->model, "i82557b") == 0) {
- pci_i82557b_init(bus, nd, devfn);
+ pci_dev = pci_i82557b_init(bus, nd, devfn);
} else if (strcmp(nd->model, "i82559er") == 0) {
- pci_i82559er_init(bus, nd, devfn);
+ pci_dev = pci_i82559er_init(bus, nd, devfn);
} else if (strcmp(nd->model, "rtl8139") == 0) {
- pci_rtl8139_init(bus, nd, devfn);
+ pci_dev = pci_rtl8139_init(bus, nd, devfn);
} else if (strcmp(nd->model, "e1000") == 0) {
- pci_e1000_init(bus, nd, devfn);
+ pci_dev = pci_e1000_init(bus, nd, devfn);
} else if (strcmp(nd->model, "pcnet") == 0) {
- pci_pcnet_init(bus, nd, devfn);
+ pci_dev = pci_pcnet_init(bus, nd, devfn);
} else if (strcmp(nd->model, "virtio") == 0) {
- virtio_net_init(bus, nd, devfn);
+ pci_dev = virtio_net_init(bus, nd, devfn);
} else if (strcmp(nd->model, "?") == 0) {
fprintf(stderr, "qemu: Supported PCI NICs: i82551 i82557b i82559er"
" ne2k_pci pcnet rtl8139 e1000 virtio\n");
@@ -651,6 +653,8 @@ void pci_nic_init(PCIBus *bus, NICInfo *
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
exit (1);
}
+ nd->devfn = pci_dev->devfn;
+ return pci_dev;
}
typedef struct {
Index: kvm-userspace.hotplug/qemu/hw/pci.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.h
+++ kvm-userspace.hotplug/qemu/hw/pci.h
@@ -87,7 +87,7 @@ typedef int (*pci_map_irq_fn)(PCIDevice
PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
qemu_irq *pic, int devfn_min, int nirq);
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn);
void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
int pci_bus_num(PCIBus *s);
@@ -116,23 +116,23 @@ void usb_ohci_init_pci(struct PCIBus *bu
/* eepro100.c */
-void pci_i82551_init(PCIBus *bus, NICInfo *nd, int devfn);
-void pci_i82557b_init(PCIBus *bus, NICInfo *nd, int devfn);
-void pci_i82559er_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_i82551_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_i82557b_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_i82559er_init(PCIBus *bus, NICInfo *nd, int devfn);
/* ne2000.c */
-void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn);
/* rtl8139.c */
-void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
/* e1000.c */
-void pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn);
/* pcnet.c */
-void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn);
/* prep_pci.c */
PCIBus *pci_prep_init(qemu_irq *pic);
Index: kvm-userspace.hotplug/qemu/hw/pcnet.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pcnet.c
+++ kvm-userspace.hotplug/qemu/hw/pcnet.c
@@ -1958,7 +1958,7 @@ static void pci_physical_memory_read(voi
cpu_physical_memory_read(addr, buf, len);
}
-void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
{
PCNetState *d;
uint8_t *pci_conf;
@@ -2006,6 +2006,7 @@ void pci_pcnet_init(PCIBus *bus, NICInfo
d->pci_dev = &d->dev;
pcnet_common_init(d, nd, "pcnet");
+ return (PCIDevice *)d;
}
/* SPARC32 interface */
Index: kvm-userspace.hotplug/qemu/hw/rtl8139.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/rtl8139.c
+++ kvm-userspace.hotplug/qemu/hw/rtl8139.c
@@ -3410,7 +3410,7 @@ static void rtl8139_timer(void *opaque)
}
#endif /* RTL8139_ONBOARD_TIMER */
-void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
{
PCIRTL8139State *d;
RTL8139State *s;
@@ -3474,5 +3474,6 @@ void pci_rtl8139_init(PCIBus *bus, NICIn
qemu_mod_timer(s->timer,
rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock)));
#endif /* RTL8139_ONBOARD_TIMER */
+ return (PCIDevice *)d;
}
Index: kvm-userspace.hotplug/qemu/hw/virtio-net.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/virtio-net.c
+++ kvm-userspace.hotplug/qemu/hw/virtio-net.c
@@ -279,7 +279,7 @@ static void virtio_net_tx_timer(void *op
virtio_net_flush_tx(n, n->tx_vq);
}
-void *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
{
VirtIONet *n;
@@ -306,5 +306,5 @@ void *virtio_net_init(PCIBus *bus, NICIn
n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);
n->tx_timer_active = 0;
- return &n->vdev;
+ return (PCIDevice *)n;
}
Index: kvm-userspace.hotplug/qemu/net.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/net.h
+++ kvm-userspace.hotplug/qemu/net.h
@@ -45,6 +45,7 @@ struct NICInfo {
uint8_t macaddr[6];
const char *model;
VLANState *vlan;
+ int devfn;
};
extern int nb_nics;
--
-------------------------------------------------------------------------
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/
next prev parent reply other threads:[~2008-03-04 18:34 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-04 18:34 [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Marcelo Tosatti
2008-03-04 18:34 ` [patch 01/23] QEMU/KVM: add PCI IRQ routing information up to slot 32 Marcelo Tosatti
2008-03-05 5:40 ` Avi Kivity
2008-03-04 18:34 ` [patch 02/23] QEMU/KVM: add devices to represent PCI slots with _EJ0 method Marcelo Tosatti
2008-03-04 18:34 ` [patch 03/23] QEMU/KVM: add OperationRegion and GPE handler for add/removal notification Marcelo Tosatti
2008-03-04 18:34 ` [patch 04/23] QEMU/KVM: add pci_find_bus Marcelo Tosatti
2008-03-04 18:34 ` Marcelo Tosatti [this message]
2008-03-04 18:34 ` [patch 06/23] QEMU/KVM: pci hotplug GPE support Marcelo Tosatti
2008-03-04 18:34 ` [patch 07/23] QEMU/KVM: dynamic drive/drive_opt index allocation Marcelo Tosatti
2008-03-04 18:34 ` [patch 08/23] QEMU/KVM: dynamic nic info " Marcelo Tosatti
2008-03-04 18:34 ` [patch 09/23] QEMU/KVM: drive removal support Marcelo Tosatti
2008-03-04 18:34 ` [patch 10/23] QEMU/KVM: record devfn on block driver instance Marcelo Tosatti
2008-03-04 18:34 ` [patch 11/23] QEMU/KVM: move drives_opt for external use Marcelo Tosatti
2008-03-04 18:34 ` [patch 12/23] QEMU/KVM: net/drive add/remove tweaks Marcelo Tosatti
2008-03-04 18:34 ` [patch 13/23] QEMU/KVM: add net_client_uninit Marcelo Tosatti
2008-03-04 18:34 ` [patch 14/23] QEMU/KVM: device hot-add Marcelo Tosatti
2008-03-04 19:14 ` Daniel P. Berrange
2008-03-04 19:30 ` Anthony Liguori
2008-03-04 19:53 ` Daniel P. Berrange
2008-03-04 21:44 ` Itamar Heim
2008-03-05 5:50 ` Avi Kivity
2008-03-11 14:18 ` Marcelo Tosatti
2008-03-04 18:34 ` [patch 15/23] QEMU/KVM: add pci_find_device Marcelo Tosatti
2008-03-04 18:34 ` [patch 16/23] QEMU/KVM: add cpu_unregister_io_memory and make io mem table index dynamic Marcelo Tosatti
2008-03-04 18:34 ` [patch 17/23] QEMU/KVM: notify _EJ0 through _SEJ OperationRegion Marcelo Tosatti
2008-03-04 18:34 ` [patch 18/23] QEMU/KVM: handle SEJ notifications Marcelo Tosatti
2008-03-04 18:34 ` [patch 19/23] QEMU/KVM: add qemu_free_irqs Marcelo Tosatti
2008-03-04 18:34 ` [patch 20/23] QEMU/KVM: add pci_unregister_device Marcelo Tosatti
2008-03-04 18:34 ` [patch 21/23] QEMU/KVM: LSI SCSI unregister callback Marcelo Tosatti
2008-03-04 18:34 ` [patch 22/23] QEMU/KVM: zero ioport_opaque on isa_unassign_ioport Marcelo Tosatti
2008-03-04 18:34 ` [patch 23/23] QEMU/KVM: device hot-remove Marcelo Tosatti
2008-03-04 19:18 ` Daniel P. Berrange
2008-03-04 19:32 ` Anthony Liguori
2008-03-04 20:00 ` Marcelo Tosatti
2008-03-04 20:06 ` Daniel P. Berrange
2008-03-05 6:28 ` Avi Kivity
2008-03-05 5:46 ` Avi Kivity
2008-03-05 6:47 ` Avi Kivity
2008-03-05 6:00 ` [patch 00/23] [RFC] QEMU/KVM ACPI PCI hotplug Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080304183902.991361986@localhost.localdomain \
--to=mtosatti@redhat.com \
--cc=avi@qumranet.com \
--cc=gcosta@redhat.com \
--cc=kvm-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.