qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	"Beniamino Galvani" <b.galvani@gmail.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Strahinja Jankovic" <strahinja.p.jankovic@gmail.com>,
	"Niek Linnenbank" <nieklinnenbank@gmail.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Andrew Jeffery" <andrew@aj.id.au>,
	"Joel Stanley" <joel@jms.id.au>,
	"Igor Mitsyanko" <i.mitsyanko@gmail.com>,
	"Jean-Christophe Dubois" <jcd@tribudubois.net>,
	"Andrey Smirnov" <andrew.smirnov@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Rob Herring" <robh@kernel.org>,
	"Subbaraya Sundeep" <sundeep.lkml@gmail.com>,
	"Jan Kiszka" <jan.kiszka@web.de>,
	"Tyrone Ting" <kfting@nuvoton.com>,
	"Hao Wu" <wuhaotsh@google.com>,
	"Radoslaw Biernacki" <rad@semihalf.com>,
	"Leif Lindholm" <quic_llindhol@quicinc.com>,
	"Marcin Juszkiewicz" <marcin.juszkiewicz@linaro.org>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Helge Deller" <deller@gmx.de>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Song Gao" <gaosong@loongson.cn>,
	"Thomas Huth" <huth@tuxfamily.org>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"Jason Wang" <jasowang@redhat.com>, "Jia Liu" <proljc@gmail.com>,
	"Stafford Horne" <shorne@gmail.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"David Gibson" <david@gibson.dropbear.id.au>,
	"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"Bin Meng" <bin.meng@windriver.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Weiwei Li" <liweiwei@iscas.ac.cn>,
	"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Yoshinori Sato" <ysato@users.sourceforge.jp>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	"Paul Durrant" <paul@xen.org>,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org,
	qemu-s390x@nongnu.org, xen-devel@lists.xenproject.org
Subject: [PATCH 06/45] hw/xen: use qemu_create_nic_bus_devices() to instantiate Xen NICs
Date: Sun, 22 Oct 2023 16:51:21 +0100	[thread overview]
Message-ID: <20231022155200.436340-7-dwmw2@infradead.org> (raw)
In-Reply-To: <20231022155200.436340-1-dwmw2@infradead.org>

From: David Woodhouse <dwmw@amazon.co.uk>

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 this fixes
the setup for Xen PV guests, which was previously broken in various
ways and never actually managed to peer with the netdev.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 hw/xen/xen-bus.c                    |  4 ++++
 hw/xen/xen_devconfig.c              | 25 -------------------------
 hw/xenpv/xen_machine_pv.c           |  9 ---------
 include/hw/xen/xen-legacy-backend.h |  1 -
 4 files changed, 4 insertions(+), 35 deletions(-)

diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
index 0da2aa219a..194c1b7311 100644
--- a/hw/xen/xen-bus.c
+++ b/hw/xen/xen-bus.c
@@ -19,6 +19,7 @@
 #include "qapi/error.h"
 #include "qapi/qmp/qdict.h"
 #include "sysemu/sysemu.h"
+#include "net/net.h"
 #include "trace.h"
 
 static char *xen_device_get_backend_path(XenDevice *xendev)
@@ -1134,4 +1135,7 @@ void xen_bus_init(void)
 
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
     qbus_set_bus_hotplug_handler(bus);
+
+    qemu_create_nic_bus_devices(bus, TYPE_XEN_DEVICE, "xen-net-device",
+                                "xen", "xen-net-device");
 }
diff --git a/hw/xen/xen_devconfig.c b/hw/xen/xen_devconfig.c
index 3f77c675c6..2150869f60 100644
--- a/hw/xen/xen_devconfig.c
+++ b/hw/xen/xen_devconfig.c
@@ -46,31 +46,6 @@ static int xen_config_dev_all(char *fe, char *be)
 
 /* ------------------------------------------------------------- */
 
-int xen_config_dev_nic(NICInfo *nic)
-{
-    char fe[256], be[256];
-    char mac[20];
-    int vlan_id = -1;
-
-    net_hub_id_for_client(nic->netdev, &vlan_id);
-    snprintf(mac, sizeof(mac), "%02x:%02x:%02x:%02x:%02x:%02x",
-             nic->macaddr.a[0], nic->macaddr.a[1], nic->macaddr.a[2],
-             nic->macaddr.a[3], nic->macaddr.a[4], nic->macaddr.a[5]);
-    xen_pv_printf(NULL, 1, "config nic %d: mac=\"%s\"\n", vlan_id, mac);
-    xen_config_dev_dirs("vif", "qnic", vlan_id, fe, be, sizeof(fe));
-
-    /* frontend */
-    xenstore_write_int(fe, "handle",     vlan_id);
-    xenstore_write_str(fe, "mac",        mac);
-
-    /* backend */
-    xenstore_write_int(be, "handle",     vlan_id);
-    xenstore_write_str(be, "mac",        mac);
-
-    /* common stuff */
-    return xen_config_dev_all(fe, be);
-}
-
 int xen_config_dev_vfb(int vdev, const char *type)
 {
     char fe[256], be[256];
diff --git a/hw/xenpv/xen_machine_pv.c b/hw/xenpv/xen_machine_pv.c
index 9f9f137f99..1130d1a147 100644
--- a/hw/xenpv/xen_machine_pv.c
+++ b/hw/xenpv/xen_machine_pv.c
@@ -32,8 +32,6 @@
 
 static void xen_init_pv(MachineState *machine)
 {
-    int i;
-
     setup_xen_backend_ops();
 
     /* Initialize backend core & drivers */
@@ -62,13 +60,6 @@ static void xen_init_pv(MachineState *machine)
         vga_interface_created = true;
     }
 
-    /* configure nics */
-    for (i = 0; i < nb_nics; i++) {
-        if (!nd_table[i].model || 0 != strcmp(nd_table[i].model, "xen"))
-            continue;
-        xen_config_dev_nic(nd_table + i);
-    }
-
     xen_bus_init();
 
     /* config cleanup hook */
diff --git a/include/hw/xen/xen-legacy-backend.h b/include/hw/xen/xen-legacy-backend.h
index fc42146bc2..2cca174778 100644
--- a/include/hw/xen/xen-legacy-backend.h
+++ b/include/hw/xen/xen-legacy-backend.h
@@ -81,7 +81,6 @@ extern struct XenDevOps xen_usb_ops;          /* xen-usb.c         */
 
 /* configuration (aka xenbus setup) */
 void xen_config_cleanup(void);
-int xen_config_dev_nic(NICInfo *nic);
 int xen_config_dev_vfb(int vdev, const char *type);
 int xen_config_dev_vkbd(int vdev);
 int xen_config_dev_console(int vdev);
-- 
2.40.1



  parent reply	other threads:[~2023-10-22 15:59 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-22 15:51 [PATCH 0/45] Rework matching of network devices to -nic options David Woodhouse
2023-10-22 15:51 ` [PATCH 01/45] net: add qemu_{configure, create}_nic_device(), qemu_find_nic_info() David Woodhouse
2023-10-22 15:51 ` [PATCH 02/45] net: report list of available models according to platform David Woodhouse
2023-10-22 15:51 ` [PATCH 03/45] net: add qemu_create_nic_bus_devices() David Woodhouse
2023-10-22 15:51 ` [PATCH 04/45] hw/pci: add pci_init_nic_devices(), pci_init_nic_in_slot() David Woodhouse
2023-10-22 15:51 ` [PATCH 05/45] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices() David Woodhouse
2023-10-22 15:51 ` David Woodhouse [this message]
2023-10-22 15:51 ` [PATCH 07/45] hw/alpha/dp264: use pci_init_nic_devices() David Woodhouse
2023-10-22 15:51 ` [PATCH 08/45] hw/arm/sbsa-ref: " David Woodhouse
2023-10-24 11:32   ` Leif Lindholm
2023-10-22 15:51 ` [PATCH 09/45] hw/arm/virt: " David Woodhouse
2023-10-22 15:51 ` [PATCH 10/45] hw/hppa: " David Woodhouse
2023-10-22 15:51 ` [PATCH 11/45] hw/loongarch: " David Woodhouse
2023-10-22 15:51 ` [PATCH 12/45] hw/mips/fuloong2e: " David Woodhouse
2023-10-22 15:51 ` [PATCH 13/45] hw/mips/malta: " David Woodhouse
2023-10-22 15:51 ` [PATCH 14/45] hw/mips/loongson3_virt: " David Woodhouse
2023-10-22 15:51 ` [PATCH 15/45] hw/ppc/prep: " David Woodhouse
2023-10-22 15:51 ` [PATCH 16/45] hw/ppc/spapr: use qemu_get_nic_info() and pci_init_nic_devices() David Woodhouse
2023-10-22 15:51 ` [PATCH 17/45] hw/ppc: use pci_init_nic_devices() David Woodhouse
2023-10-22 15:51 ` [PATCH 18/45] hw/sh4/r2d: " David Woodhouse
2023-10-27 12:31   ` Yoshinori Sato
2023-10-22 15:51 ` [PATCH 19/45] hw/sparc64/sun4u: " David Woodhouse
2023-10-22 15:51 ` [PATCH 20/45] hw/xtensa/virt: " David Woodhouse
2023-10-22 15:51 ` [PATCH 21/45] hw/arm/allwinner: use qemu_configure_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 22/45] hw/arm/aspeed: " David Woodhouse
2023-10-22 15:51 ` [PATCH 23/45] hw/arm/exynos4: use qemu_create_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 24/45] hw/arm/fsl: use qemu_configure_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 25/45] hw/net/smc91c111: " David Woodhouse
2023-10-22 15:51 ` [PATCH 26/45] hw/net/lan9118: " David Woodhouse
2023-10-22 15:51 ` [PATCH 27/45] hw/arm/highbank: use qemu_create_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 28/45] hw/arm/npcm7xx: use qemu_configure_nic_device, allow emc0/emc1 as aliases David Woodhouse
2023-10-22 15:51 ` [PATCH 29/45] hw/arm/stellaris: use qemu_find_nic_info() David Woodhouse
2023-10-22 15:51 ` [PATCH 30/45] hw/arm: use qemu_configure_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 31/45] hw/net/etraxfs-eth: " David Woodhouse
2023-10-22 15:51 ` [PATCH 32/45] hw/m68k/mcf5208: use qemu_create_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 33/45] hw/m68k/q800: use qemu_configure_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 34/45] hw/microblaze: " David Woodhouse
2023-10-22 15:51 ` [PATCH 35/45] hw/mips: use qemu_create_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 36/45] hw/net/lasi_i82596: use qemu_configure_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 37/45] hw/openrisc/openrisc_sim: use qemu_create_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 38/45] hw/riscv: use qemu_configure_nic_device() David Woodhouse
2023-10-25 15:42   ` Daniel Henrique Barboza
2023-10-25 15:51     ` David Woodhouse
2023-10-22 15:51 ` [PATCH 39/45] hw/s390x/s390-virtio-ccw: use qemu_create_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 40/45] hw/sparc/sun4m: use qemu_configure_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 41/45] hw/xtensa/xtfpga: use qemu_create_nic_device() David Woodhouse
2023-10-22 15:51 ` [PATCH 42/45] net: remove qemu_check_nic_model() David Woodhouse
2023-10-22 15:51 ` [PATCH 43/45] hw/pci: remove pci_nic_init_nofail() David Woodhouse
2023-10-22 15:51 ` [PATCH 44/45] net: remove qemu_show_nic_models(), qemu_find_nic_model() David Woodhouse
2023-10-22 15:52 ` [PATCH 45/45] net: make nb_nics and nd_table[] static in net/net.c David Woodhouse

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=20231022155200.436340-7-dwmw2@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=aleksandar.rikalo@syrmia.com \
    --cc=alistair@alistair23.me \
    --cc=andrew.smirnov@gmail.com \
    --cc=andrew@aj.id.au \
    --cc=anthony.perard@citrix.com \
    --cc=atar4qemu@gmail.com \
    --cc=aurelien@aurel32.net \
    --cc=b.galvani@gmail.com \
    --cc=bin.meng@windriver.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=chenhuacai@kernel.org \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=david@redhat.com \
    --cc=deller@gmx.de \
    --cc=edgar.iglesias@gmail.com \
    --cc=eduardo@habkost.net \
    --cc=farman@linux.ibm.com \
    --cc=gaosong@loongson.cn \
    --cc=harshpb@linux.ibm.com \
    --cc=hpoussin@reactos.org \
    --cc=huth@tuxfamily.org \
    --cc=i.mitsyanko@gmail.com \
    --cc=iii@linux.ibm.com \
    --cc=jan.kiszka@web.de \
    --cc=jasowang@redhat.com \
    --cc=jcd@tribudubois.net \
    --cc=jcmvbkbc@gmail.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=joel@jms.id.au \
    --cc=kfting@nuvoton.com \
    --cc=laurent@vivier.eu \
    --cc=liweiwei@iscas.ac.cn \
    --cc=magnus.damm@gmail.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=marcin.juszkiewicz@linaro.org \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=nieklinnenbank@gmail.com \
    --cc=npiggin@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pasic@linux.ibm.com \
    --cc=paul@xen.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=proljc@gmail.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=quic_llindhol@quicinc.com \
    --cc=rad@semihalf.com \
    --cc=richard.henderson@linaro.org \
    --cc=robh@kernel.org \
    --cc=shorne@gmail.com \
    --cc=sstabellini@kernel.org \
    --cc=strahinja.p.jankovic@gmail.com \
    --cc=sundeep.lkml@gmail.com \
    --cc=wuhaotsh@google.com \
    --cc=xen-devel@lists.xenproject.org \
    --cc=ysato@users.sourceforge.jp \
    --cc=zhiwei_liu@linux.alibaba.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).