[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
From: |
David Woodhouse |
Subject: |
Re: [PATCH for-8.3 v2 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices() |
Date: |
Fri, 10 Nov 2023 09:27:31 +0000 |
User-agent: |
Evolution 3.44.4-0ubuntu2 |
On Fri, 2023-11-10 at 08:40 +0100, Philippe Mathieu-Daudé wrote:
> Hi David,
>
> +Markus/Bernhard
>
> On 6/11/23 20:49, David Woodhouse wrote:
> > From: David Woodhouse <dwmw@amazon.co.uk>
> >
> > 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@amazon.co.uk>
> > Reviewed-by: Paul Durrant <paul@xen.org>
> > ---
> > 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@linaro.org/
> so no changed requested so far.
Thanks for the reference.
I'm happy to make pc_init_ne2k_isa() and even pc_nic_init() take an
'Error **' argument and use that instead of &error_fatal... and for the
*caller* to pass &error_fatal for now until/unless that discussion is
resolved? Not sure it helps much?
Then again... I do not favour the "my caller cannot *currently*
handle/propagate an error therefore I won't bother to return one
coherently" approach. That leads to someone else thinking "my callee
does not return an error coherently therefore I won't bother to handle
it", and nothing ever gets fixed.
I'll go fix it to take an errp argument.
smime.p7s
Description: S/MIME cryptographic signature
- [PATCH for-8.3 v2 17/46] hw/ppc: use pci_init_nic_devices(), (continued)
- [PATCH for-8.3 v2 17/46] hw/ppc: use pci_init_nic_devices(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 39/46] hw/riscv: use qemu_configure_nic_device(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 33/46] hw/m68k/q800: use qemu_find_nic_info(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 27/46] hw/arm/highbank: use qemu_create_nic_device(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 28/46] hw/arm/npcm7xx: use qemu_configure_nic_device, allow emc0/emc1 as aliases, David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 04/46] hw/pci: add pci_init_nic_devices(), pci_init_nic_in_slot(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 05/46] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 09/46] hw/arm/virt: use pci_init_nic_devices(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 19/46] hw/sparc64/sun4u: use pci_init_nic_devices(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 23/46] hw/arm/exynos4: use qemu_create_nic_device(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 38/46] hw/openrisc/openrisc_sim: use qemu_create_nic_device(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 22/46] hw/arm/aspeed: use qemu_configure_nic_device(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 40/46] hw/s390x/s390-virtio-ccw: use qemu_create_nic_device(), David Woodhouse, 2023/11/06
- [PATCH for-8.3 v2 08/46] hw/arm/sbsa-ref: use pci_init_nic_devices(), David Woodhouse, 2023/11/06