[PATCH v3 18/28] hw/xen: only remove peers of PCI NICs on unplug

2023-10-25 Thread David Woodhouse
From: David Woodhouse When the Xen guest asks to unplug *emulated* NICs, it's kind of unhelpful also to unplug the peer of the *Xen* PV NIC. Signed-off-by: David Woodhouse --- hw/i386/xen/xen_platform.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/i386/xen

[PATCH v3 20/28] net: do not delete nics in net_cleanup()

2023-10-25 Thread David Woodhouse
From: David Woodhouse In net_cleanup() we only need to delete the netdevs, as those may have state which outlives Qemu when it exits, and thus may actually need to be cleaned up on exit. The nics, on the other hand, are owned by the device which created them. Most devices don't bother to clean

[PATCH v3 05/28] hw/xen: fix XenStore watch delivery to guest

2023-10-25 Thread David Woodhouse
From: David Woodhouse When fire_watch_cb() found the response buffer empty, it would call deliver_watch() to generate the XS_WATCH_EVENT message in the response buffer and send an event channel notification to the guest… without actually *copying* the response buffer into the ring. So

[PATCH v3 08/28] i386/xen: Ignore VCPU_SSHOTTMR_future flag in set_singleshot_timer()

2023-10-25 Thread David Woodhouse
From: David Woodhouse Upstream Xen now ignores this flag¹, since the only guest kernel ever to use it was buggy. ¹ https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=19c6cbd909 Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 20

[PATCH v3 24/28] net: add qemu_create_nic_bus_devices()

2023-10-25 Thread David Woodhouse
From: David Woodhouse This will instantiate any NICs which live on a given bus type. Each bus is allowed *one* substitution (for PCI it's virtio → virtio-net-pci, for Xen it's xen → xen-net-device; no point in overengineering it unless we actually want more). Signed-off-by: David Woodhouse

[PATCH v3 22/28] net: add qemu_{configure, create}_nic_device(), qemu_find_nic_info()

2023-10-25 Thread David Woodhouse
From: David Woodhouse Most code which directly accesses nd_table[] and nb_nics uses them for one of two things. Either "I have created a NIC device and I'd like a configuration for it", or "I will create a NIC device *if* there is a configuration for it". With some variants

[PATCH v3 27/28] hw/xen: use qemu_create_nic_bus_devices() to instantiate Xen NICs

2023-10-25 Thread David Woodhouse
From: David Woodhouse When instantiating XenBus itself, for each NIC which is configured with either the model unspecified, or set to to "xen" or "xen-net-device", create a corresponding xen-net-device for it. Now we can launch emulated Xen guests with '-nic user', and

[PATCH v3 23/28] net: report list of available models according to platform

2023-10-25 Thread David Woodhouse
From: David Woodhouse By noting the models for which a configuration was requested, we can give the user an accurate list of which NIC models were actually available on the platform/configuration that was otherwise chosen. Signed-off-by: David Woodhouse --- net/net.c | 94

[PATCH v3 26/28] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices()

2023-10-25 Thread David Woodhouse
From: David Woodhouse Eliminate direct access to nd_table[] and nb_nics by processing the the ISA NICs first and then calling pci_init_nic_devices() for the test. It's important to do this *before* the subsequent patch which registers the Xen PV network devices, because the code being remove

[PATCH v3 14/28] hw/xen: add get_frontend_path() method to XenDeviceClass

2023-10-25 Thread David Woodhouse
From: David Woodhouse The primary Xen console is special. The guest's side is set up for it by the toolstack automatically and not by the standard PV init sequence. Accordingly, its *frontend* doesn't appear in …/device/console/0 either; instead it appears under …/console in the guest's

Re: [PATCH 12/12] hw/xen: add support for Xen primary console in emulated mode

2023-10-25 Thread David Woodhouse
On Wed, 2023-10-25 at 09:31 +0100, Paul Durrant wrote: > On 24/10/2023 17:34, David Woodhouse wrote: > > On Tue, 2023-10-24 at 17:25 +0100, Paul Durrant wrote: > > > On 24/10/2023 16:49, David Woodhouse wrote: > > > > On Tue, 2023-10-24 at 16:39 +0100, Paul Durrant

Re: [PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass

2023-10-25 Thread David Woodhouse
On Tue, 2023-10-24 at 14:37 +0100, Paul Durrant wrote: > > > > Ok, but a prepend to say that a lack of path there means we skip > > > frontend creation seems reasonable? > > > > No, it *is* returning an error. Perhaps I can make it > > > > I understand it is returning an error. I thought the

Re: [PATCH 2/4] hw/xen: update Xen PV NIC to XenDevice model

2023-10-25 Thread David Woodhouse
On Tue, 2023-10-24 at 15:47 +0100, Paul Durrant wrote: > > >    > > -    if (netdev->xendev.be_state != XenbusStateConnected) { > > +    if (netdev->rx_ring.sring == NULL) { > > Why not a straight swap for xen_device_backend_get_state()? Hard to see > whether there any hidden side effects of

Re: [PATCH v2 16/24] hw/xen: handle soft reset for primary console

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 17:22 +0100, Paul Durrant wrote: > On 24/10/2023 16:48, David Woodhouse wrote: > > On Tue, 2023-10-24 at 16:44 +0100, Paul Durrant wrote: > > > On 19/10/2023 16:40, David Woodhouse wrote: > > > > From: David Woodhouse > > > > > &

Re: [PATCH 12/12] hw/xen: add support for Xen primary console in emulated mode

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 17:25 +0100, Paul Durrant wrote: > On 24/10/2023 16:49, David Woodhouse wrote: > > On Tue, 2023-10-24 at 16:39 +0100, Paul Durrant wrote: > > > On 24/10/2023 16:37, David Woodhouse wrote: > > > > On Tue, 2023-10-24 at 15:20 +0100, Paul Durrant

Re: [PATCH 0/12] Get Xen PV shim running in qemu

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 16:24 +0100, Alex Bennée wrote: > > David Woodhouse writes: > > > I hadn't got round to getting the PV shim running yet; I thought it would > > need work on the multiboot loader. Turns out it doesn't. I *did* need to > > fix a couple of brown-pap

Re: [PATCH 12/12] hw/xen: add support for Xen primary console in emulated mode

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 16:39 +0100, Paul Durrant wrote: > On 24/10/2023 16:37, David Woodhouse wrote: > > On Tue, 2023-10-24 at 15:20 +0100, Paul Durrant wrote: > > > On 16/10/2023 16:19, David Woodhouse wrote: > > > > From: David Woodhouse > > > > >

Re: [PATCH v2 16/24] hw/xen: handle soft reset for primary console

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 16:44 +0100, Paul Durrant wrote: > On 19/10/2023 16:40, David Woodhouse wrote: > > From: David Woodhouse > > > > On soft reset, the prinary console event channel needs to be rebound to > > the backend port (in the xen-console driver). We coul

Re: [PATCH 12/12] hw/xen: add support for Xen primary console in emulated mode

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 15:20 +0100, Paul Durrant wrote: > On 16/10/2023 16:19, David Woodhouse wrote: > > From: David Woodhouse > > > > The primary console is special because the toolstack maps a page at a > > fixed GFN and also allocates the guest-side

Re: [PATCH v2 05/24] hw/xen: fix XenStore watch delivery to guest

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 16:19 +0100, Paul Durrant wrote: > On 19/10/2023 16:40, David Woodhouse wrote: > > From: David Woodhouse > > > > When fire_watch_cb() found the response buffer empty, it would call > > deliver_watch() to generate the XS_WATCH_EVENT message

Re: [PATCH 1/4] hw/xen: only remove peers of PCI NICs on unplug

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 15:32 +0100, Paul Durrant wrote: > On 17/10/2023 19:25, David Woodhouse wrote: > > From: David Woodhouse > > > > When the Xen guest asks to unplug *emulated* NICs, it's kind of unhelpful > > also to unplug the peer of the *Xen* PV NIC. &g

Re: [PATCH 2/4] hw/xen: update Xen PV NIC to XenDevice model

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 15:47 +0100, Paul Durrant wrote: > On 17/10/2023 19:25, David Woodhouse wrote: > > + > > +#define xen_pv_printf(a, n, ...) qemu_printf(__VA_ARGS__) > > Why define this... In the first place, just to make it build in the short term. Then I forgot

Re: [PATCH 09/12] hw/xen: prevent duplicate device registrations

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 15:10 +0100, Paul Durrant wrote: > On 16/10/2023 16:19, David Woodhouse wrote: > > --- a/hw/char/xen_console.c > > +++ b/hw/char/xen_console.c > > @@ -468,7 +468,7 @@ static void > > xen_console_device_create(XenBackendInstance *backend, &

Re: [PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 13:59 +0100, Paul Durrant wrote: > On 24/10/2023 13:56, David Woodhouse wrote: > > On Tue, 2023-10-24 at 13:42 +0100, Paul Durrant wrote: > > > > > > > --- a/hw/xen/xen-bus.c > > > > +++ b/hw/xen/xen-bus.c > > > > @@ -7

Re: [PATCH 02/12] hw/xen: select kernel mode for per-vCPU event channel upcall vector

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 13:29 +0100, Paul Durrant wrote: > > > +    /* If the guest has set a per-vCPU callback vector, prefer that. */ > > +    if (gsi && kvm_xen_has_vcpu_callback_vector()) { > > +    in_kernel = kvm_xen_has_cap(EVTCHN_SEND); > > +    gsi = 0; > > +    } > > + > > So

Re: [PATCH 01/12] i386/xen: fix per-vCPU upcall vector for Xen emulation

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 13:16 +0100, Paul Durrant wrote: > On 16/10/2023 16:18, David Woodhouse wrote: > > From: David Woodhouse > > > > The per-vCPU upcall vector support had two problems. Firstly it was > > using the wrong hypercall argument and would always retur

Re: [PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 13:42 +0100, Paul Durrant wrote: > > > --- a/hw/xen/xen-bus.c > > +++ b/hw/xen/xen-bus.c > > @@ -711,8 +711,16 @@ static void xen_device_frontend_create(XenDevice > > *xendev, Error **errp) > >    { > >    ERRP_GUARD(); > >    XenBus *xenbus =

Re: [PATCH 05/12] hw/xen: populate store frontend nodes with XenStore PFN/port

2023-10-24 Thread David Woodhouse
On Tue, 2023-10-24 at 13:35 +0100, Paul Durrant wrote: > On 16/10/2023 16:19, David Woodhouse wrote: > > From: David Woodhouse > > > > This is kind of redundant since without being able to get these > > through > > ome other method (HVMOP_get_param) the gue

Re: [RFC PATCH 01/19] cpus: Add argument to qemu_get_cpu() to filter CPUs by QOM type

2023-10-23 Thread David Woodhouse
On Fri, 2023-10-20 at 18:36 +0200, Philippe Mathieu-Daudé wrote: > Heterogeneous machines have different type of CPU. > qemu_get_cpu() returning unfiltered CPUs doesn't make > sense anymore. Add a 'type' argument to filter CPU by > QOM type. > > Type in "hw/core/cpu.h" and implementation in

Re: [PATCH 11/12] hw/xen: automatically assign device index to block devices

2023-10-23 Thread David Woodhouse
On 23 October 2023 10:30:02 BST, Igor Mammedov wrote: >On Wed, 18 Oct 2023 09:32:47 +0100 >David Woodhouse wrote: > >> On Wed, 2023-10-18 at 09:32 +0200, Igor Mammedov wrote: >> > On Mon, 16 Oct 2023 16:19:08 +0100 >> > David Woodhouse wrote: >

Re: [PATCH v2 22/24] tests/avocado: switch to using xen-net-device for Xen guest tests

2023-10-23 Thread David Woodhouse
On Thu, 2023-10-19 at 16:40 +0100, David Woodhouse wrote: > From: David Woodhouse > > Fix the filename in the MAINTAINERS file too. > > Signed-off-by: David Woodhouse > --- >  MAINTAINERS    | 2 +- >  tests/avocado/kvm_xen_guest.py | 2 +- >  2 files

[PATCH 32/45] hw/m68k/mcf5208: use qemu_create_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/m68k/mcf5208.c | 20 ++-- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index be1033f84f..cf23b7dc6e 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c

[PATCH 08/45] hw/arm/sbsa-ref: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/arm/sbsa-ref.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 3c7dfcd6dc..582a28ce92 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -691,9 +691,7 @@ static

[PATCH 29/45] hw/arm/stellaris: use qemu_find_nic_info()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Rather than just using qemu_configure_nic_device(), populate the MAC address in the system-registers device by peeking at the NICInfo before it's assigned to the device. Generate the MAC address early, if there is no matching -nic option. Otherwise the MAC address wouldn't

[PATCH 04/45] hw/pci: add pci_init_nic_devices(), pci_init_nic_in_slot()

2023-10-22 Thread David Woodhouse
From: David Woodhouse The loop over nd_table[] to add PCI NICs is repeated in quite a few places. Add a helper function to do it. Some platforms also try to instantiate a specific model in a specific slot, to match the real hardware. Add pci_init_nic_in_slot() for that purpose. Signed-off

[PATCH 11/45] hw/loongarch: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/loongarch/virt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 2952fe452e..9905e525b1 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -504,9 +504,7

[PATCH 09/45] hw/arm/virt: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/arm/virt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 15e74249f9..6b43b92b89 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1477,9 +1477,7 @@ static void create_pcie

[PATCH 07/45] hw/alpha/dp264: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/alpha/dp264.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index 03495e1e60..52a1fa310b 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -124,9 +124,7 @@ static void

[PATCH 44/45] net: remove qemu_show_nic_models(), qemu_find_nic_model()

2023-10-22 Thread David Woodhouse
From: David Woodhouse These old functions can be removed now too. Let net_param_nic() print the full set of network devices directly, and also make it note that a list more specific to this platform/config will be available by using '-nic model=help' instead. Signed-off-by: David Woodhouse

[PATCH 39/45] hw/s390x/s390-virtio-ccw: use qemu_create_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/s390x/s390-virtio-ccw.c | 11 ++- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 2d75f2131f..b8b8a2a201 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b

[PATCH 12/45] hw/mips/fuloong2e: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse The previous behaviour was: *if* the first NIC specified on the command line was an RTL8139 (or unspecified model) then it gets assigned to PCI slot 7, which is where the Fuloong board had an RTL8139. All other devices (including the first, if it was specified a anything

[PATCH 20/45] hw/xtensa/virt: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/xtensa/virt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/xtensa/virt.c b/hw/xtensa/virt.c index a6cf646e99..5310a88861 100644 --- a/hw/xtensa/virt.c +++ b/hw/xtensa/virt.c @@ -102,9 +102,7 @@ static void

[PATCH 45/45] net: make nb_nics and nd_table[] static in net/net.c

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- include/net/net.h | 4 net/net.c | 3 +++ system/globals.c | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 290e604f03..5a38766942 100644 --- a/include/net

[PATCH 40/45] hw/sparc/sun4m: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/sparc/sun4m.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 17bf5f2879..259cf2f383 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -299,7 +299,7 @@ static

[PATCH 34/45] hw/microblaze: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/microblaze/petalogix_ml605_mmu.c | 3 +-- hw/microblaze/petalogix_s3adsp1800_mmu.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c

[PATCH 42/45] net: remove qemu_check_nic_model()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- include/net/net.h | 1 - net/net.c | 13 - 2 files changed, 14 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index ce830a47d0..1512650190 100644 --- a/include/net/net.h +++ b/include/net/net.h

[PATCH 23/45] hw/arm/exynos4: use qemu_create_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/arm/exynos4_boards.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c index ef5bcbc212..b804357e2a 100644 --- a/hw/arm/exynos4_boards.c +++ b/hw/arm

[PATCH 10/45] hw/hppa: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/hppa/machine.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index cf28cb9586..97d9b44c4f 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -272,10 +272,8

[PATCH 05/45] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Eliminate direct access to nd_table[] and nb_nics by processing the the ISA NICs first and then calling pci_init_nic_devices() for the test. It's important to do this *before* the subsequent patch which registers the Xen PV network devices, because the code being remove

[PATCH 30/45] hw/arm: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/arm/mps2-tz.c | 8 ++-- hw/arm/msf2-soc.c| 6 +- hw/arm/musicpal.c| 3 +-- hw/arm/xilinx_zynq.c | 11 --- hw/arm/xlnx-versal.c | 7 +-- hw/arm/xlnx-zynqmp.c | 8 +--- 6 files changed, 10

[PATCH 0/45] Rework matching of network devices to -nic options

2023-10-22 Thread David Woodhouse
nd nb_nics static in net/net.c because nothing else has any business poking at them directly. David Woodhouse (45): net: add qemu_{configure,create}_nic_device(), qemu_find_nic_info() net: report list of available models according to platform net: add qemu_create_nic_bus_devices()

[PATCH 19/45] hw/sparc64/sun4u: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse The first sunhme NIC gets placed a function 1 on slot 1 of PCI bus A, and the rest are dynamically assigned on PCI bus B. Previously, any PCI NIC would get the special treatment purely by virtue of being first in the list. Signed-off-by: David Woodhouse --- hw/sparc64

[PATCH 13/45] hw/mips/malta: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse The Malta board setup code would previously place the first NIC into PCI slot 11 if was a PCNet card, and the rest (including the first if it was anything other than a PCNet card) would be dynamically assigned. Now it will place any PCNet NIC into slot 11

[PATCH 24/45] hw/arm/fsl: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/arm/fsl-imx25.c | 2 +- hw/arm/fsl-imx6.c | 2 +- hw/arm/fsl-imx6ul.c | 2 +- hw/arm/fsl-imx7.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c index 24c4374590

[PATCH 26/45] hw/net/lan9118: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Some callers instantiate the device unconditionally, others will do so only if there is a NICInfo to go with it. This appears to be fairly random, but preseve the existing behaviour for now. Signed-off-by: David Woodhouse --- hw/arm/kzm.c | 4 ++-- hw/arm

[PATCH 21/45] hw/arm/allwinner: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/arm/allwinner-a10.c | 6 +- hw/arm/allwinner-h3.c | 6 +- hw/arm/allwinner-r40.c | 27 ++- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner

[PATCH 06/45] hw/xen: use qemu_create_nic_bus_devices() to instantiate Xen NICs

2023-10-22 Thread David Woodhouse
From: David Woodhouse When instantiating XenBus itself, for each NIC which is configured with either the model unspecified, or set to to "xen" or "xen-net-device", create a corresponding xen-net-device for it. Now we can launch emulated Xen guests with '-nic user', and

[PATCH 17/45] hw/ppc: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/ppc/e500.c | 4 +--- hw/ppc/mac_newworld.c | 4 +--- hw/ppc/mac_oldworld.c | 4 +--- hw/ppc/ppc440_bamboo.c | 13 + 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500

[PATCH 43/45] hw/pci: remove pci_nic_init_nofail()

2023-10-22 Thread David Woodhouse
From: David Woodhouse This function is no longer used. Signed-off-by: David Woodhouse --- hw/pci/pci.c | 72 include/hw/pci/pci.h | 3 -- 2 files changed, 75 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 904f189d30

[PATCH 01/45] net: add qemu_{configure, create}_nic_device(), qemu_find_nic_info()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Most code which directly accesses nd_table[] and nb_nics uses them for one of two things. Either "I have created a NIC device and I'd like a configuration for it", or "I will create a NIC device *if* there is a configuration for it". With some variants

[PATCH 31/45] hw/net/etraxfs-eth: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/cris/axis_dev88.c | 9 - hw/net/etraxfs_eth.c | 5 ++--- include/hw/cris/etraxfs.h | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/cris/axis_dev88.c b/hw/cris/axis_dev88.c index d82050d927

[PATCH 02/45] net: report list of available models according to platform

2023-10-22 Thread David Woodhouse
From: David Woodhouse By noting the models for which a configuration was requested, we can give the user an accurate list of which NIC models were actually available on the platform/configuration that was otherwise chosen. Signed-off-by: David Woodhouse --- net/net.c | 94

[PATCH 16/45] hw/ppc/spapr: use qemu_get_nic_info() and pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Avoid directly referencing nd_table[] by first instantiating any spapr-vlan devices using a qemu_get_nic_info() loop, then calling pci_init_nic_devices() to do the rest. No functional change intended. Signed-off-by: David Woodhouse --- hw/ppc/spapr.c | 18

[PATCH 15/45] hw/ppc/prep: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Previously, the first PCI NIC would be placed in PCI slot 3 and the rest would be dynamically assigned. Even if the user overrode the default NIC type and made it something other than PCNet. Now, the first PCNet NIC (that is, anything not explicitly specified

[PATCH 35/45] hw/mips: use qemu_create_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse The Jazz and MIPS SIM platforms both instantiate their NIC only if a corresponding configuration exists for it. Convert them to use the qemu_create_nic_device() function for that. Signed-off-by: David Woodhouse --- hw/mips/jazz.c| 16 ++-- hw/mips

[PATCH 36/45] hw/net/lasi_i82596: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/net/lasi_i82596.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/net/lasi_i82596.c b/hw/net/lasi_i82596.c index e37f7fabe9..c4c197aaa8 100644 --- a/hw/net/lasi_i82596.c +++ b/hw/net/lasi_i82596.c @@ -125,11

[PATCH 14/45] hw/mips/loongson3_virt: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/mips/loongson3_virt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index b74b358874..d9d6d4f5b6 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips

[PATCH 25/45] hw/net/smc91c111: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Some callers instantiate the device unconditionally, others will do so only if there is a NICInfo to go with it. This appears to be fairly random, but preserve the existing behaviour for now. Signed-off-by: David Woodhouse --- hw/arm/gumstix.c | 6 ++ hw

[PATCH 18/45] hw/sh4/r2d: use pci_init_nic_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Previously, the first PCI NIC would be assigned to slot 2 even if the user override the model and made it something other than an rtl8139 which is the default. Everything else would be dynamically assigned. Now, the first rtl8139 gets slot 2 and everything else is dynamic

[PATCH 41/45] hw/xtensa/xtfpga: use qemu_create_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/xtensa/xtfpga.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index fbad1c83a3..519e461354 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -147,8

[PATCH 28/45] hw/arm/npcm7xx: use qemu_configure_nic_device, allow emc0/emc1 as aliases

2023-10-22 Thread David Woodhouse
From: David Woodhouse Also update the test to specify which device to attach the test socket to, and remove the comment lamenting the fact that we can't do so. Signed-off-by: David Woodhouse --- hw/arm/npcm7xx.c | 16 +--- tests/qtest/npcm7xx_emc-test.c | 18

[PATCH 38/45] hw/riscv: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/riscv/microchip_pfsoc.c | 13 ++--- hw/riscv/sifive_u.c| 7 +-- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index b775aa8946..8e0e3aa20c

[PATCH 22/45] hw/arm/aspeed: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/arm/aspeed.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index f8ba67531a..945ad97835 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -356,7 +356,6 @@ static

[PATCH 37/45] hw/openrisc/openrisc_sim: use qemu_create_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/openrisc/openrisc_sim.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c index 35da123aef..bffd6f721f 100644 --- a/hw/openrisc

[PATCH 03/45] net: add qemu_create_nic_bus_devices()

2023-10-22 Thread David Woodhouse
From: David Woodhouse This will instantiate any NICs which live on a given bus type. Each bus is allowed *one* substitution (for PCI it's virtio → virtio-net-pci, for Xen it's xen → xen-net-device; no point in overengineering it unless we actually want more). Signed-off-by: David Woodhouse

[PATCH 33/45] hw/m68k/q800: use qemu_configure_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Then fetch the MAC that was assigned, if any. And assign one if not, ensuring that it uses the Apple OUI. Signed-off-by: David Woodhouse --- hw/m68k/q800.c | 28 +++- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/hw/m68k/q800.c b

[PATCH 27/45] hw/arm/highbank: use qemu_create_nic_device()

2023-10-22 Thread David Woodhouse
From: David Woodhouse Signed-off-by: David Woodhouse --- hw/arm/highbank.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index f12aacea6b..798e5391dc 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -296,19

Re: [PATCH 11/12] hw/xen: automatically assign device index to block devices

2023-10-20 Thread David Woodhouse
On Wed, 2023-10-18 at 11:52 +0100, David Woodhouse wrote: > > And xen_config_dev_nic() probably just needs to loop doing the same > as > I did in pc_init_nic() in > https://lore.kernel.org/qemu-devel/20231017182545.97973-5-dw...@infradead.org/T/#u > > +    if (x

[PATCH v2 20/24] hw/xenpv: fix '-nic' support for xen-net-device

2023-10-19 Thread David Woodhouse
From: David Woodhouse I can't see how this has ever worked. If I start with the simple attempt "-nic user,model=xen", it creates a device with index -1 because it's assuming that it'll be attached to a hubport. So it creates a frontend at e.g. "/local/domain/84/device/vif/-1"

[PATCH v2 13/24] hw/xen: do not repeatedly try to create a failing backend device

2023-10-19 Thread David Woodhouse
From: David Woodhouse If xen_backend_device_create() fails to instantiate a device, the XenBus code will just keep trying over and over again each time the bus is re-enumerated, as long as the backend appears online and in XenbusStateInitialising. The only thing which prevents the XenBus code

[PATCH v2 01/24] i386/xen: Don't advertise XENFEAT_supervisor_mode_kernel

2023-10-19 Thread David Woodhouse
From: David Woodhouse This confuses lscpu into thinking it's running in PVH mode. Fixes: bedcc139248 ("i386/xen: implement HYPERVISOR_xen_version") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 1 - 1 file changed, 1 deletion(-) diff --gi

[PATCH v2 22/24] tests/avocado: switch to using xen-net-device for Xen guest tests

2023-10-19 Thread David Woodhouse
From: David Woodhouse Fix the filename in the MAINTAINERS file too. Signed-off-by: David Woodhouse --- MAINTAINERS| 2 +- tests/avocado/kvm_xen_guest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 9bd4fe378d

[PATCH v2 10/24] hw/xen: populate store frontend nodes with XenStore PFN/port

2023-10-19 Thread David Woodhouse
From: David Woodhouse This is kind of redundant since without being able to get these through some other method (HVMOP_get_param) the guest wouldn't be able to access XenStore in order to find them. But Xen populates them, and it does allow guests to *rebind* to the event channel port after

[PATCH v2 09/24] i386/xen: advertise XEN_HVM_CPUID_UPCALL_VECTOR in CPUID

2023-10-19 Thread David Woodhouse
From: David Woodhouse This will allow Linux guests (since v6.0) to use the per-vCPU upcall vector delivered as MSI through the local APIC. Signed-off-by: David Woodhouse --- target/i386/kvm/kvm.c | 4 1 file changed, 4 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm

[PATCH v2 15/24] hw/xen: add support for Xen primary console in emulated mode

2023-10-19 Thread David Woodhouse
From: David Woodhouse The primary console is special because the toolstack maps a page at a fixed GFN and also allocates the guest-side event channel. Add support for that in emulated mode, so that we can have a primary console. Add a *very* rudimentary stub of foriegnmem ops for emulated mode

[PATCH v2 08/24] include: update Xen public headers to Xen 4.17.2 release

2023-10-19 Thread David Woodhouse
From: David Woodhouse ... in order to advertise the XEN_HVM_CPUID_UPCALL_VECTOR feature, which will come in a subsequent commit. Signed-off-by: David Woodhouse --- hw/i386/kvm/xen_xenstore.c| 2 +- include/hw/xen/interface/arch-arm.h | 37 +++--- include

[PATCH v2 18/24] hw/xen: update Xen PV NIC to XenDevice model

2023-10-19 Thread David Woodhouse
From: David Woodhouse This allows us to use Xen PV networking with emulated Xen guests, and to add them on the command line or hotplug. Signed-off-by: David Woodhouse --- hw/net/meson.build| 2 +- hw/net/trace-events | 11 + hw/net/xen_nic.c | 471

[PATCH v2 07/24] hw/xen: Clean up event channel 'type_val' handling to use union

2023-10-19 Thread David Woodhouse
From: David Woodhouse A previous implementation of this stuff used a 64-bit field for all of the port information (vcpu/type/type_val) and did atomic exchanges on them. When I implemented that in Qemu I regretted my life choices and just kept it simple with locking instead. So there's no need

[PATCH v2 02/24] i386/xen: fix per-vCPU upcall vector for Xen emulation

2023-10-19 Thread David Woodhouse
From: David Woodhouse The per-vCPU upcall vector support had two problems. Firstly it was using the wrong hypercall argument and would always return -EFAULT. And secondly it was using the wrong ioctl() to pass the vector to the kernel and thus the *kernel* would always return -EINVAL. Linux

[PATCH v2 24/24] docs: update Xen-on-KVM documentation

2023-10-19 Thread David Woodhouse
From: David Woodhouse Add notes about console and network support, and how to launch PV guests. Clean up the disk configuration examples now that that's simpler, and remove the comment about IDE unplug on q35/AHCI now that it's fixed. Signed-off-by: David Woodhouse --- docs/system/i386

[PATCH v2 0/24] Get Xen PV shim running in Qemu, add net & console

2023-10-19 Thread David Woodhouse
dead.org/users/dwmw2/qemu.git/shortlog/refs/heads/xenfv-pv-2 David Woodhouse (24): i386/xen: Don't advertise XENFEAT_supervisor_mode_kernel i386/xen: fix per-vCPU upcall vector for Xen emulation hw/xen: select kernel mode for per-vCPU event channel upcall vector hw/xen: d

[PATCH v2 14/24] hw/xen: update Xen console to XenDevice model

2023-10-19 Thread David Woodhouse
From: David Woodhouse This allows (non-primary) console devices to be created on the command line and hotplugged. Signed-off-by: David Woodhouse --- hw/char/trace-events| 8 + hw/char/xen_console.c | 529 +++- hw/xen/xen-legacy-backend.c | 1

[PATCH v2 23/24] xen-platform: unplug AHCI disks

2023-10-19 Thread David Woodhouse
From: David Woodhouse To support Xen guests using the Q35 chipset, the unplug protocol needs to also remove AHCI disks. Make pci_xen_ide_unplug() more generic, iterating over the children of the PCI device and destroying the "ide-hd" devices. That works the same for both AHCI and ID

[PATCH v2 21/24] net: do not delete nics in net_cleanup()

2023-10-19 Thread David Woodhouse
From: David Woodhouse In net_cleanup() we only need to delete the netdevs, as those may have state which outlives Qemu when it exits, and thus may actually need to be cleaned up on exit. The nics, on the other hand, are owned by the device which created them. Most devices don't bother to clean

[PATCH v2 06/24] i386/xen: Ignore VCPU_SSHOTTMR_future flag in set_singleshot_timer()

2023-10-19 Thread David Woodhouse
From: David Woodhouse Upstream Xen now ignores this flag¹, since the only guest kernel ever to use it was buggy. ¹ https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=19c6cbd909 Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- target/i386/kvm/xen-emu.c | 20

[PATCH v2 04/24] hw/xen: don't clear map_track[] in xen_gnttab_reset()

2023-10-19 Thread David Woodhouse
From: David Woodhouse The refcounts actually correspond to 'active_ref' structures stored in a GHashTable per "user" on the backend side (mostly, per XenDevice). If we zero map_track[] on reset, then when the backend drivers get torn down and release their mapping we hit the assert(s-

[PATCH v2 05/24] hw/xen: fix XenStore watch delivery to guest

2023-10-19 Thread David Woodhouse
From: David Woodhouse When fire_watch_cb() found the response buffer empty, it would call deliver_watch() to generate the XS_WATCH_EVENT message in the response buffer and send an event channel notification to the guest… without actually *copying* the response buffer into the ring. So

[PATCH v2 16/24] hw/xen: handle soft reset for primary console

2023-10-19 Thread David Woodhouse
From: David Woodhouse On soft reset, the prinary console event channel needs to be rebound to the backend port (in the xen-console driver). We could put that into the xen-console driver itself, but it's slightly less ugly to keep it within the KVM/Xen code, by stashing the backend port# on event

[PATCH v2 11/24] hw/xen: automatically assign device index to block devices

2023-10-19 Thread David Woodhouse
From: David Woodhouse There's no need to force the user to assign a vdev. We can automatically assign one, starting at xvda and searching until we find the first disk name that's unused. This means we can now allow '-drive if=xen,file=xxx' to work without an explicit separate -driver argument

[PATCH v2 03/24] hw/xen: select kernel mode for per-vCPU event channel upcall vector

2023-10-19 Thread David Woodhouse
From: David Woodhouse A guest which has configured the per-vCPU upcall vector may set the HVM_PARAM_CALLBACK_IRQ param to fairly much anything other than zero. For example, Linux v6.0+ after commit b1c3497e604 ("x86/xen: Add support for HVMOP_set_evtchn_upcall_vector") will just do

<    1   2   3   4   5   6   7   8   9   10   >