qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Adds virtio_net as the default netcard for boston b


From: Tommy Jin
Subject: [Qemu-devel] [PATCH] Adds virtio_net as the default netcard for boston board
Date: Mon, 1 Apr 2019 05:26:00 +0000

Boston didn't bring up any netcard by default, this is not so convenient.
As the linux kernel has supported virtio_net, now add a virtio netcard for 
boston.
To make virtio work properly, please:
1. set virtio net options in linux kernel, saying CONFIG_VIRTIO && 
CONFIG_VIRTIO_PCI && CONFIG_VIRTIO_NET
2. specify model=virtio when you start netcard in qemu.

Signed-off-by: tjin <address@hidden>
---
 hw/mips/boston.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index e5bab3c..930bb9d 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -32,6 +32,7 @@
 #include "hw/mips/cps.h"
 #include "hw/mips/cpudevs.h"
 #include "hw/pci-host/xilinx-pcie.h"
+#include "hw/virtio/virtio-pci.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
@@ -422,6 +423,20 @@ xilinx_pcie_init(MemoryRegion *sys_mem, uint32_t bus_nr,
     return XILINX_PCIE_HOST(dev);
 }
 
+/* Plug network card  in pcie slot.*/
+static void network_init(PCIBus *bus)
+{
+       PCIDevice *eth;
+
+       /*Please set CONFIG_VIRTIO && CONFIG_VIRTIO_PCI && CONFIG_VIRTIO_NET
+       of Linux kernel.*/
+       eth = pci_create(bus,
+                                        PCI_DEVFN(0, 1), "virtio-net-pci");
+
+       qdev_set_nic_properties(&eth->qdev, &nd_table[0]);
+       qdev_init_nofail(&eth->qdev);
+}
+
 static void boston_mach_init(MachineState *machine)
 {
     DeviceState *dev;
@@ -545,6 +560,9 @@ static void boston_mach_init(MachineState *machine)
         error_printf("Please provide either a -kernel or -bios argument\n");
         exit(1);
     }
+
+       /* Network card */
+       network_init(&PCI_BRIDGE(&pcie2->root)->sec_bus);
 }
 
 static void boston_mach_class_init(MachineClass *mc)
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]