Use MachineClass->default_nic in more machines
cover Use MachineClass->default_nic in more machines
These patches are required for running more tests with "make check" on builds that use "--without-default-devices". By marking the default NIC in the generic MachineClass, the main code can decide whether the NIC is available in the binary or not, so the instantiation can be skipped if it has not been compiled in.
See https://lore.kernel.org/qemu-devel/[email protected]/
and the other patches in that series for more information.
Thomas Huth (5):
hw/hppa: Use MachineClass->default_nic in the hppa machine hw/alpha: Use MachineClass->default_nic in the alpha machine hw/arm: Use MachineClass->default_nic in the virt machine hw/loongarch64: Use MachineClass->default_nic in the virt machine hw/xtensa: Use MachineClass->default_nic in the virt machine
hw/alpha/dp264.c | 4 +++- hw/arm/virt.c | 4 +++- hw/hppa/machine.c | 4 +++- hw/loongarch/virt.c | 4 +++- hw/xtensa/virt.c | 9 ++++++--- 5 files changed, 18 insertions(+), 7 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/5 hw/hppa: Use MachineClass->default_nic in the hppa machine
Mark the default NIC via the new MachineClass->default_nic setting so that the machine-defaults code in vl.c can decide whether the default NIC is usable or not (for example when compiling with the "--without-default-devices" configure switch).
--- hw/hppa/machine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/hppa/machine.c +3 -1
@@ -177,6 +177,7 @@ static void machine_hppa_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;const char *kernel_cmdline = machine->kernel_cmdline;const char *initrd_filename = machine->initrd_filename; +MachineClass *mc =MACHINE_GET_CLASS (machine);DeviceState *dev, *dino_dev, *lasi_dev;PCIBus *pci_bus;ISABus *isa_bus;
@@ -272,7 +273,7 @@ static void machine_hppa_init(MachineState *machine)for (i =0 ; i < nb_nics; i++) {if (!enable_lasi_lan ()) { -pci_nic_init_nofail (&nd_table[i], pci_bus,"tulip" ,NULL ); +pci_nic_init_nofail (&nd_table[i], pci_bus, mc->default_nic,NULL ); } }
@@ -462,6 +463,7 @@ static void hppa_machine_init_class_init(ObjectClass *oc, void *data) mc->default_ram_size =512 * MiB; mc->default_boot_order ="cd" ; mc->default_ram_id ="ram" ; + mc->default_nic ="tulip" ; nc->nmi_monitor_handler = hppa_nmi; }
Signature · 1 line
2.31.1
PATCH 2/5 hw/alpha: Use MachineClass->default_nic in the alpha machine
In reply to Thomas HuthMark the default NIC via the new MachineClass->default_nic setting so that the machine-defaults code in vl.c can decide whether the default NIC is usable or not (for example when compiling with the "--without-default-devices" configure switch).
--- hw/alpha/dp264.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/alpha/dp264.c +3 -1
@@ -49,6 +49,7 @@ static void clipper_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;const char *kernel_cmdline = machine->kernel_cmdline;const char *initrd_filename = machine->initrd_filename; +MachineClass *mc =MACHINE_GET_CLASS (machine);AlphaCPU *cpus[4 ];PCIBus *pci_bus;PCIDevice *pci_dev;
@@ -124,7 +125,7 @@ static void clipper_init(MachineState *machine)/* Network setup. e1000 is good enough, failing Tulip support. */ for (i =0 ; i < nb_nics; i++) { -pci_nic_init_nofail (&nd_table[i], pci_bus,"e1000" ,NULL ); +pci_nic_init_nofail (&nd_table[i], pci_bus, mc->default_nic,NULL ); }/* Super I/O */
@@ -213,6 +214,7 @@ static void clipper_machine_init(MachineClass *mc) mc->is_default = true; mc->default_cpu_type =ALPHA_CPU_TYPE_NAME ("ev67" ); mc->default_ram_id ="ram" ; + mc->default_nic ="e1000" ; }DEFINE_MACHINE ("clipper" , clipper_machine_init)
Signature · 1 line
2.31.1
PATCH 3/5 hw/arm: Use MachineClass->default_nic in the virt machine
In reply to Thomas HuthMark the default NIC via the new MachineClass->default_nic setting so that the machine-defaults code in vl.c can decide whether the default NIC is usable or not (for example when compiling with the "--without-default-devices" configure switch).
--- hw/arm/virt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/arm/virt.c +3 -1
@@ -1426,6 +1426,7 @@ static void create_pcie(VirtMachineState *vms)int i, ecam_id;PCIHostState *pci;MachineState *ms =MACHINE (vms); +MachineClass *mc =MACHINE_GET_CLASS (ms); dev =qdev_new (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -1479,7 +1480,7 @@ static void create_pcie(VirtMachineState *vms)NICInfo *nd = &nd_table[i];if (!nd->model) { - nd->model =g_strdup ("virtio" ); + nd->model =g_strdup (mc->default_nic); }pci_nic_init_nofail (nd, pci->bus, nd->model,NULL );
@@ -3033,6 +3034,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->auto_enable_numa_with_memhp = true; mc->auto_enable_numa_with_memdev = true; mc->default_ram_id ="mach-virt.ram" ; + mc->default_nic ="virtio-net-pci" ; object_class_property_add(oc, "acpi", "OnOffAuto", virt_get_acpi, virt_set_acpi,
Signature · 1 line
2.31.1
PATCH 4/5 hw/loongarch64: Use MachineClass->default_nic in the virt machine
In reply to Thomas HuthMark the default NIC via the new MachineClass->default_nic setting so that the machine-defaults code in vl.c can decide whether the default NIC is usable or not (for example when compiling with the "--without-default-devices" configure switch).
--- hw/loongarch/virt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/loongarch/virt.c +3 -1
@@ -474,6 +474,7 @@ static DeviceState *create_platform_bus(DeviceState *pch_pic)static void loongarch_devices_init (DeviceState *pch_pic,LoongArchMachineState *lams) { +MachineClass *mc =MACHINE_GET_CLASS (lams);DeviceState *gpex_dev;SysBusDevice *d;PCIBus *pci_bus;
@@ -528,7 +529,7 @@ static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState *NICInfo *nd = &nd_table[i];if (!nd->model) { - nd->model =g_strdup ("virtio" ); + nd->model =g_strdup (mc->default_nic); }pci_nic_init_nofail (nd, pci_bus, nd->model,NULL );
@@ -1038,6 +1039,7 @@ static void loongarch_class_init(ObjectClass *oc, void *data) mc->default_boot_order ="c" ; mc->no_cdrom =1 ; mc->get_hotplug_handler = virt_machine_get_hotplug_handler; + mc->default_nic ="virtio-net-pci" ; hc->plug = loongarch_machine_device_plug_cb; hc->pre_plug = virt_machine_device_pre_plug; hc->unplug_request = virt_machine_device_unplug_request;
Signature · 1 line
2.31.1
Re: [PATCH 4/5] hw/loongarch64: Use MachineClass->default_nic in the virt machine
Quoted 9 lines · Thomas Huth
Mark the default NIC via the new
MachineClass->default_nicsetting so that the machine-defaults code invl.ccan decide whether the default NIC is usable or not (for example when compiling with the "--without-default-devices" configure switch).Signed-off-by Thomas Huth <[email protected]>--- hw/loongarch/virt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Thanks.
Song Gao
Quoted 29 lines
hw/loongarch/virt.c +3
-1@@ -474,6 +474,7 @@ static DeviceState *create_platform_bus(DeviceState *pch_pic)static void loongarch_devices_init (DeviceState *pch_pic,LoongArchMachineState *lams) { +MachineClass *mc =MACHINE_GET_CLASS (lams);DeviceState *gpex_dev;SysBusDevice *d;PCIBus *pci_bus;@@ -528,7 +529,7 @@ static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState *NICInfo *nd = &nd_table[i];if (!nd->model) { - nd->model =g_strdup ("virtio" ); + nd->model =g_strdup (mc->default_nic); }pci_nic_init_nofail (nd, pci_bus, nd->model,NULL );@@ -1038,6 +1039,7 @@ static void loongarch_class_init(ObjectClass *oc, void *data) mc->default_boot_order ="c" ; mc->no_cdrom =1 ; mc->get_hotplug_handler = virt_machine_get_hotplug_handler; + mc->default_nic ="virtio-net-pci" ; hc->plug = loongarch_machine_device_plug_cb; hc->pre_plug = virt_machine_device_pre_plug; hc->unplug_request = virt_machine_device_unplug_request;
PATCH 5/5 hw/xtensa: Use MachineClass->default_nic in the virt machine
In reply to Thomas HuthMark the default NIC via the new MachineClass->default_nic setting so that the machine-defaults code in vl.c can decide whether the default NIC is usable or not (for example when compiling with the "--without-default-devices" configure switch).
--- hw/xtensa/virt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
hw/xtensa/virt.c +6 -3
@@ -38,7 +38,8 @@#include "xtensa_memory.h" #include "xtensa_sim.h" -static void create_pcie (CPUXtensaState *env,int irq_base,hwaddr addr_base) +static void create_pcie (MachineState *ms,CPUXtensaState *env,int irq_base, +hwaddr addr_base) {hwaddr base_ecam = addr_base +0x00100000 ;hwaddr size_ecam =0x03f00000 ;
@@ -54,6 +55,7 @@ static void create_pcie(CPUXtensaState *env, int irq_base, hwaddr addr_base)MemoryRegion *mmio_alias;MemoryRegion *mmio_reg; +MachineClass *mc =MACHINE_GET_CLASS (ms);DeviceState *dev;PCIHostState *pci;qemu_irq *extints;
@@ -104,7 +106,7 @@ static void create_pcie(CPUXtensaState *env, int irq_base, hwaddr addr_base)NICInfo *nd = &nd_table[i];if (!nd->model) { - nd->model =g_strdup ("virtio" ); + nd->model =g_strdup (mc->default_nic); }pci_nic_init_nofail (nd, pci->bus, nd->model,NULL );
@@ -117,7 +119,7 @@ static void xtensa_virt_init(MachineState *machine)XtensaCPU *cpu =xtensa_sim_common_init (machine);CPUXtensaState *env = &cpu->env; -create_pcie (env,0 ,0xf0000000 ); +create_pcie (machine, env,0 ,0xf0000000 );xtensa_sim_load_kernel (cpu, machine); }
@@ -127,6 +129,7 @@ static void xtensa_virt_machine_init(MachineClass *mc) mc->init = xtensa_virt_init; mc->max_cpus =32 ; mc->default_cpu_type =XTENSA_DEFAULT_CPU_TYPE ; + mc->default_nic ="virtio-net-pci" ; }DEFINE_MACHINE ("virt" , xtensa_virt_machine_init)
Signature · 1 line
2.31.1
Quoted 8 lines · Thomas Huth
These patches are required for running more tests with "make check" on builds that use "--without-default-devices". By marking the default NIC in the generic MachineClass, the main code can decide whether the NIC is available in the binary or not, so the instantiation can be skipped if it has not been compiled in.
Seehttps://lore.kernel.org/qemu-devel/[email protected]/ and the other patches in that series for more information.
r~
Quoted 9 lines · Thomas Huth
These patches are required for running more tests with "make check" on builds that use "--without-default-devices". By marking the default NIC in the generic MachineClass, the main code can decide whether the NIC is available in the binary or not, so the instantiation can be skipped if it has not been compiled in.
See https://lore.kernel.org/qemu-devel/[email protected]/
and the other patches in that series for more information.
Quoted 6 lines
Thomas Huth (5):
hw/hppa: UseMachineClass->default_nicin the hppa machine hw/alpha: UseMachineClass->default_nicin the alpha machine hw/arm: UseMachineClass->default_nicin the virt machine hw/loongarch64: UseMachineClass->default_nicin the virt machine hw/xtensa: UseMachineClass->default_nicin the virt machine