diff mbox

hw/arm/virt: Initialize NICs configured in PCI bus

Message ID 1452091659-17698-1-git-send-email-ashoks@broadcom.com
State New
Headers show

Commit Message

Ashok Kumar Jan. 6, 2016, 2:47 p.m. UTC
virtio model is used for default case.

Signed-off-by: Ashok Kumar <ashoks@broadcom.com>
---
 hw/arm/virt.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Peter Maydell Jan. 6, 2016, 6:10 p.m. UTC | #1
On 6 January 2016 at 14:47, Ashok Kumar <ashoks@broadcom.com> wrote:
> virtio model is used for default case.
>
> Signed-off-by: Ashok Kumar <ashoks@broadcom.com>

Could you explain why you think this needs to be done?
Virtio networking works OK for me...

I guess from the patch that this is adding support for
the legacy '-net' way of configuring networking, but do
we need that if we never supported it in the first place?
(If virt is the only PCI machine which doesn't support
-net syntax that would probably be a strong argument for
supporting it.)

thanks
-- PMM
Ashok Kumar Jan. 7, 2016, 5:53 a.m. UTC | #2
On Wed, Jan 06, 2016 at 06:10:15PM +0000, Peter Maydell wrote:
Hi,

> On 6 January 2016 at 14:47, Ashok Kumar <ashoks@broadcom.com> wrote:
> > virtio model is used for default case.
> >
> > Signed-off-by: Ashok Kumar <ashoks@broadcom.com>
> 
> Could you explain why you think this needs to be done?
Yes, for -net. Honestly, I didn't know this is obsolete and the
only syntax I knew for networking. 

> Virtio networking works OK for me...
I tried the new syntax now and it is working fine.

> 
> I guess from the patch that this is adding support for
> the legacy '-net' way of configuring networking, but do
> we need that if we never supported it in the first place?
> (If virt is the only PCI machine which doesn't support
> -net syntax that would probably be a strong argument for
> supporting it.)
Fine with me. But there are some documentation for e.g [1] which says "-net" is
still supported.

[1] http://www.linux-kvm.org/page/Networking#Compatibility

Thanks,
Ashok
> 
> thanks
> -- PMM
>
Peter Maydell Jan. 7, 2016, 2:47 p.m. UTC | #3
On 7 January 2016 at 05:53, Ashok Kumar <ashoks@broadcom.com> wrote:
> On Wed, Jan 06, 2016 at 06:10:15PM +0000, Peter Maydell wrote:
>> I guess from the patch that this is adding support for
>> the legacy '-net' way of configuring networking, but do
>> we need that if we never supported it in the first place?
>> (If virt is the only PCI machine which doesn't support
>> -net syntax that would probably be a strong argument for
>> supporting it.)
> Fine with me. But there are some documentation for e.g [1] which says "-net" is
> still supported.
>
> [1] http://www.linux-kvm.org/page/Networking#Compatibility

I've cc'd the networking maintainer and some other people
who might have an opinion. Basically the question is
"should we support the legacy -net syntax for new board models
which didn't exist back when -net was the only option and
have never supported -net" ?

The argument for "don't support it" is that -net is legacy and
if there aren't any legacy command lines to support then we
should avoid extending the scope of legacy behaviour.

The argument for "do support it" is consistency -- we don't
document that -net is only for certain boards, and users
will expect that network config options that work on some machines
(including x86 PC and many of the ARM embedded board models)
will also work on the ARM virt board.

I think my current inclination is to say that virt should
support -net, because I would prefer to avoid having yet
another speedbump in the path of people trying to move to
using KVM-on-ARM based on their previous experience with
KVM-on-x86.

thanks
-- PMM
Paolo Bonzini Jan. 7, 2016, 3:21 p.m. UTC | #4
On 07/01/2016 15:47, Peter Maydell wrote:
> I think my current inclination is to say that virt should
> support -net, because I would prefer to avoid having yet
> another speedbump in the path of people trying to move to
> using KVM-on-ARM based on their previous experience with
> KVM-on-x86.

I agree.

Paolo
Jason Wang Jan. 11, 2016, 2:54 a.m. UTC | #5
On 01/07/2016 11:21 PM, Paolo Bonzini wrote:
>
> On 07/01/2016 15:47, Peter Maydell wrote:
>> I think my current inclination is to say that virt should
>> support -net, because I would prefer to avoid having yet
>> another speedbump in the path of people trying to move to
>> using KVM-on-ARM based on their previous experience with
>> KVM-on-x86.
> I agree.
>
> Paolo

+1
Peter Maydell Jan. 11, 2016, 1:24 p.m. UTC | #6
On 11 January 2016 at 02:54, Jason Wang <jasowang@redhat.com> wrote:
>
>
> On 01/07/2016 11:21 PM, Paolo Bonzini wrote:
>>
>> On 07/01/2016 15:47, Peter Maydell wrote:
>>> I think my current inclination is to say that virt should
>>> support -net, because I would prefer to avoid having yet
>>> another speedbump in the path of people trying to move to
>>> using KVM-on-ARM based on their previous experience with
>>> KVM-on-x86.

>> I agree.
>
> +1

OK, we seem to have a consensus. I'm going to apply this patch
to target-arm.next, with an expanded commit message:

    hw/arm/virt: Support legacy -nic command line syntax

    Support the legacy -nic syntax for creating PCI network devices
    as well as the new-style -device options. This makes life easier
    for people moving from x86 KVM virtualization to ARM KVM virtualization
    and expecting their network configuration options to work the same
    way for both setups.

    We use "virtio" as the default NIC model if the user doesn't specify one.

thanks
-- PMM
diff mbox

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index acc1fcb..fd52b76 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -808,6 +808,7 @@  static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
     DeviceState *dev;
     char *nodename;
     int i;
+    PCIHostState *pci;
 
     dev = qdev_create(NULL, TYPE_GPEX_HOST);
     qdev_init_nofail(dev);
@@ -847,6 +848,19 @@  static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
         sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]);
     }
 
+    pci = PCI_HOST_BRIDGE(dev);
+    if (pci->bus) {
+        for (i = 0; i < nb_nics; i++) {
+            NICInfo *nd = &nd_table[i];
+
+            if (!nd->model) {
+                nd->model = g_strdup("virtio");
+            }
+
+            pci_nic_init_nofail(nd, pci->bus, nd->model, NULL);
+        }
+    }
+
     nodename = g_strdup_printf("/pcie@%" PRIx64, base);
     qemu_fdt_add_subnode(vbi->fdt, nodename);
     qemu_fdt_setprop_string(vbi->fdt, nodename,