[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-8.3 v2 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices()
- To: David Woodhouse <dwmw2@xxxxxxxxxxxxx>, qemu-devel@xxxxxxxxxx, Bernhard Beschow <shentey@xxxxxxxxx>, Markus Armbruster <armbru@xxxxxxxxxx>
- From: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
- Date: Fri, 10 Nov 2023 08:40:23 +0100
- Cc: Richard Henderson <richard.henderson@xxxxxxxxxx>, Beniamino Galvani <b.galvani@xxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Strahinja Jankovic <strahinja.p.jankovic@xxxxxxxxx>, Niek Linnenbank <nieklinnenbank@xxxxxxxxx>, Cédric Le Goater <clg@xxxxxxxx>, Andrew Jeffery <andrew@xxxxxxxxxxxxxxxxxxxx>, Joel Stanley <joel@xxxxxxxxx>, Igor Mitsyanko <i.mitsyanko@xxxxxxxxx>, Jean-Christophe Dubois <jcd@xxxxxxxxxxxxxxx>, Andrey Smirnov <andrew.smirnov@xxxxxxxxx>, Rob Herring <robh@xxxxxxxxxx>, Subbaraya Sundeep <sundeep.lkml@xxxxxxxxx>, Jan Kiszka <jan.kiszka@xxxxxx>, Tyrone Ting <kfting@xxxxxxxxxxx>, Hao Wu <wuhaotsh@xxxxxxxxxx>, Radoslaw Biernacki <rad@xxxxxxxxxxxx>, Leif Lindholm <quic_llindhol@xxxxxxxxxxx>, Marcin Juszkiewicz <marcin.juszkiewicz@xxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, Alistair Francis <alistair@xxxxxxxxxxxxx>, Helge Deller <deller@xxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Eduardo Habkost <eduardo@xxxxxxxxxxx>, Song Gao <gaosong@xxxxxxxxxxx>, Thomas Huth <huth@xxxxxxxxxxxxx>, Laurent Vivier <laurent@xxxxxxxxx>, Huacai Chen <chenhuacai@xxxxxxxxxx>, Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>, Hervé Poussineau <hpoussin@xxxxxxxxxxx>, Aleksandar Rikalo <aleksandar.rikalo@xxxxxxxxxx>, Aurelien Jarno <aurelien@xxxxxxxxxxx>, Jason Wang <jasowang@xxxxxxxxxx>, Jia Liu <proljc@xxxxxxxxx>, Stafford Horne <shorne@xxxxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Daniel Henrique Barboza <danielhb413@xxxxxxxxx>, David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>, Harsh Prateek Bora <harshpb@xxxxxxxxxxxxx>, Bin Meng <bin.meng@xxxxxxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Weiwei Li <liweiwei@xxxxxxxxxxx>, Liu Zhiwei <zhiwei_liu@xxxxxxxxxxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Ilya Leoshkevich <iii@xxxxxxxxxxxxx>, Halil Pasic <pasic@xxxxxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>, Eric Farman <farman@xxxxxxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, Magnus Damm <magnus.damm@xxxxxxxxx>, Artyom Tarasenko <atar4qemu@xxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, qemu-arm@xxxxxxxxxx, qemu-ppc@xxxxxxxxxx, qemu-riscv@xxxxxxxxxx, qemu-s390x@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Fri, 10 Nov 2023 07:40:46 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Hi David,
+Markus/Bernhard
On 6/11/23 20:49, David Woodhouse wrote:
From: David Woodhouse <dwmw@xxxxxxxxxxxx>
Eliminate direct access to nd_table[] and nb_nics by processing the the
Xen and ISA NICs first and then calling pci_init_nic_devices() for the
rest.
Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
Reviewed-by: Paul Durrant <paul@xxxxxxx>
---
hw/i386/pc.c | 26 ++++++++++++++++----------
include/hw/net/ne2000-isa.h | 2 --
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index c2bc3fa52d..4078d2d231 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -652,8 +652,11 @@ static void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd)
{
static int nb_ne2k = 0;
- if (nb_ne2k == NE2000_NB_MAX)
+ if (nb_ne2k == NE2000_NB_MAX) {
+ error_setg(&error_fatal,
In the context of dynamically created machines I'd rather have
this function,
+ "maximum number of ISA NE2000 devices exceeded");
return;
+ }
isa_ne2000_init(bus, ne2000_io[nb_ne2k],
ne2000_irq[nb_ne2k], nd);
nb_ne2k++;
@@ -1291,23 +1294,26 @@ void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus,
PCIBus *pci_bus,
BusState *xen_bus)
{
MachineClass *mc = MACHINE_CLASS(pcmc);
- int i;
+ bool default_is_ne2k = g_str_equal(mc->default_nic, TYPE_ISA_NE2000);
+ NICInfo *nd;
rom_set_order_override(FW_CFG_ORDER_OVERRIDE_NIC);
- for (i = 0; i < nb_nics; i++) {
- NICInfo *nd = &nd_table[i];
- const char *model = nd->model ? nd->model : mc->default_nic;
- if (xen_bus && (!nd->model || g_str_equal(model, "xen-net-device"))) {
+ if (xen_bus) {
+ while (nc = qemu_find_nic_info("xen-net-device", true, NULL)) {
DeviceState *dev = qdev_new("xen-net-device");
qdev_set_nic_properties(dev, nd);
qdev_realize_and_unref(dev, xen_bus, &error_fatal);
and this one non-fatal (primarily for API example). But this is pending
on a discussion on another thread, see:
https://lore.kernel.org/qemu-devel/c1322f3b-2ae2-4ca7-9a76-a2a434dc8315@xxxxxxxxxx/
so no changed requested so far.
- } else if (g_str_equal(model, "ne2k_isa")) {
- pc_init_ne2k_isa(isa_bus, nd);
- } else {
- pci_nic_init_nofail(nd, pci_bus, model, NULL);
}
}
Regards,
Phil.
|