All of lore.kernel.org
 help / color / mirror / Atom feed
* [V2 PATCH 1/2] KVM test: Use -device to add nic device when possible
@ 2010-09-26  2:28 Jason Wang
  2010-09-26  2:28 ` [V2 PATCH 2/2] KVM test: Add vhost-net support Jason Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Jason Wang @ 2010-09-26  2:28 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm, mst

This patch tries to use "-device" to add nic device becuase recent qemu suggest
to use it. A nic_extra_params was also introduced to add some advanced params to
a nic (currently only availabe for virtio_net) such as mrg_rxbuf.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/kvm_vm.py             |   28 +++++++++++++++++++++-------
 client/tests/kvm/tests_base.cfg.sample |    2 ++
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 135d08e..644903b 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -234,13 +234,26 @@ class VM:
             if boot: cmd += ",boot=on"
             return cmd
 
-        def add_nic(help, vlan, model=None, mac=None, netdev_id=None):
-            if has_option(help, "netdev"):
-                cmd = " -net nic,netdev=%s" % netdev_id
+        def add_nic(help, vlan, model=None, mac=None, netdev_id=None,
+                    nic_extra_params=None):
+            if has_option(help, "device"):
+                if model == "virtio": model="virtio-net-pci"
+                if not model: model= "rtl8139"
+                cmd = " -device %s" % model
+                if mac: cmd += ",mac=%s" % mac
+                if has_option(help, "netdev"):
+                    cmd += ",netdev=%s" % netdev_id
+                else:
+                    cmd += "vlan=%d,"  % vlan
+                if nic_extra_params:
+                    cmd += ",%s" % nic_extra_params
             else:
-                cmd = " -net nic,vlan=%d" % vlan
-            if model: cmd += ",model=%s" % model
-            if mac: cmd += ",macaddr='%s'" % mac
+                if has_option(help, "netdev"):
+                    cmd = " -net nic,netdev=%s" % netdev_id
+                else:
+                    cmd = " -net nic,vlan=%d" % vlan
+                if model: cmd += ",model=%s" % model
+                if mac: cmd += ",macaddr='%s'" % mac
             return cmd
 
         def add_net(help, vlan, mode, ifname=None, script=None,
@@ -388,7 +401,8 @@ class VM:
             if "address_index" in nic_params:
                 mac = kvm_utils.get_mac_ip_pair_from_dict(nic_params)[0]
             qemu_cmd += add_nic(help, vlan, nic_params.get("nic_model"), mac,
-                                self.netdev_id[vlan])
+                                self.netdev_id[vlan],
+                                nic_params.get("nic_extra_params"))
             # Handle the '-net tap' or '-net user' part
             script = nic_params.get("nic_script")
             downscript = nic_params.get("nic_downscript")
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index c8fbf50..89e6f45 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -618,6 +618,8 @@ variants:
         nic_model = e1000
     - virtio_net:
         nic_model = virtio
+        # you can add advanced attributes here
+        # nic_extra_params =
 
 
 # Guests


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [V2 PATCH 2/2] KVM test: Add vhost-net support
  2010-09-26  2:28 [V2 PATCH 1/2] KVM test: Use -device to add nic device when possible Jason Wang
@ 2010-09-26  2:28 ` Jason Wang
  2010-10-08 15:19   ` Lucas Meneghel Rodrigues
  0 siblings, 1 reply; 6+ messages in thread
From: Jason Wang @ 2010-09-26  2:28 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm, mst

Vhost is a kernel-level backend for virtio. This patch add a nic_params named
"vhost" to enable/disable vhost backend.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/kvm_vm.py             |    7 +++++--
 client/tests/kvm/tests_base.cfg.sample |    2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 644903b..f448684 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -258,9 +258,11 @@ class VM:
 
         def add_net(help, vlan, mode, ifname=None, script=None,
                     downscript=None, tftp=None, bootfile=None, hostfwd=[],
-                    netdev_id=None):
+                    netdev_id=None, vhost=False):
             if has_option(help, "netdev"):
                 cmd = " -netdev %s,id=%s" % (mode, netdev_id)
+                if vhost:
+                    cmd +=",vhost=on"
             else:
                 cmd = " -net %s,vlan=%d" % (mode, vlan)
             if mode == "tap":
@@ -417,7 +419,8 @@ class VM:
                                 nic_params.get("nic_ifname"),
                                 script, downscript, tftp,
                                 nic_params.get("bootp"), redirs,
-                                self.netdev_id[vlan])
+                                self.netdev_id[vlan],
+                                nic_params.get("vhost")=="yes")
             # Proceed to next NIC
             vlan += 1
 
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index 89e6f45..14e85af 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -620,6 +620,8 @@ variants:
         nic_model = virtio
         # you can add advanced attributes here
         # nic_extra_params =
+        # you can uncomment the following line to enable vhost-net backend
+        # vhost = yes
 
 
 # Guests


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [V2 PATCH 2/2] KVM test: Add vhost-net support
  2010-09-26  2:28 ` [V2 PATCH 2/2] KVM test: Add vhost-net support Jason Wang
@ 2010-10-08 15:19   ` Lucas Meneghel Rodrigues
  2010-10-08 15:23     ` Lucas Meneghel Rodrigues
  0 siblings, 1 reply; 6+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-10-08 15:19 UTC (permalink / raw)
  To: Jason Wang; +Cc: autotest, kvm, mst

On Sun, 2010-09-26 at 10:28 +0800, Jason Wang wrote:
> Vhost is a kernel-level backend for virtio. This patch add a nic_params named
> "vhost" to enable/disable vhost backend.

Jason, I had rebased your patches. The patches themselves look good, but
apparently the syntax proposed here is invalid, and I've tried with
different qemu variants:

- qemu from rhel6
- qemu-kvm.git HEAD
- qemu.git HEAD

All of them don't support vhost with netdev:


> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  client/tests/kvm/kvm_vm.py             |    7 +++++--
>  client/tests/kvm/tests_base.cfg.sample |    2 ++
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index 644903b..f448684 100755
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -258,9 +258,11 @@ class VM:
>  
>          def add_net(help, vlan, mode, ifname=None, script=None,
>                      downscript=None, tftp=None, bootfile=None, hostfwd=[],
> -                    netdev_id=None):
> +                    netdev_id=None, vhost=False):
>              if has_option(help, "netdev"):
>                  cmd = " -netdev %s,id=%s" % (mode, netdev_id)
> +                if vhost:
> +                    cmd +=",vhost=on"
>              else:
>                  cmd = " -net %s,vlan=%d" % (mode, vlan)
>              if mode == "tap":
> @@ -417,7 +419,8 @@ class VM:
>                                  nic_params.get("nic_ifname"),
>                                  script, downscript, tftp,
>                                  nic_params.get("bootp"), redirs,
> -                                self.netdev_id[vlan])
> +                                self.netdev_id[vlan],
> +                                nic_params.get("vhost")=="yes")
>              # Proceed to next NIC
>              vlan += 1
>  
> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
> index 89e6f45..14e85af 100644
> --- a/client/tests/kvm/tests_base.cfg.sample
> +++ b/client/tests/kvm/tests_base.cfg.sample
> @@ -620,6 +620,8 @@ variants:
>          nic_model = virtio
>          # you can add advanced attributes here
>          # nic_extra_params =
> +        # you can uncomment the following line to enable vhost-net backend
> +        # vhost = yes
>  
> 
>  # Guests
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [V2 PATCH 2/2] KVM test: Add vhost-net support
  2010-10-08 15:19   ` Lucas Meneghel Rodrigues
@ 2010-10-08 15:23     ` Lucas Meneghel Rodrigues
  2010-10-09  1:46       ` Jason Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-10-08 15:23 UTC (permalink / raw)
  To: Jason Wang; +Cc: autotest, kvm, mst

On Fri, 2010-10-08 at 12:19 -0300, Lucas Meneghel Rodrigues wrote:
> On Sun, 2010-09-26 at 10:28 +0800, Jason Wang wrote:
> > Vhost is a kernel-level backend for virtio. This patch add a nic_params named
> > "vhost" to enable/disable vhost backend.
> 
> Jason, I had rebased your patches. The patches themselves look good, but
> apparently the syntax proposed here is invalid, and I've tried with
> different qemu variants:
> 
> - qemu from rhel6
> - qemu-kvm.git HEAD
> - qemu.git HEAD
> 
> All of them don't support vhost with netdev:

10:40:01 ERROR| VM could not be created; qemu command failed:
/root/autotest/client/tests/kvm/qemu -name 'vm1' -monitor unix:'/tmp/monitor-humanmonitor1-20101008-103957-4nMr',server,nowait -serial unix:'/tmp/serial-20101008-103957-4nMr',server,nowait -drive file='/tmp/kvm_autotest_root/images/f13-64.qcow2',index=0,if=virtio,boot=on -device virtio-net-pci,mac=9a:0b:5d:7a:c1:7b,netdev=idlTBuUt -netdev user,id=idlTBuUt,vhost=on,hostfwd=tcp::5000-:22 -m 512 -smp 2 -drive file='/tmp/kvm_autotest_root/isos/linux/Fedora-13-x86_64-DVD.iso',media=cdrom,index=1 -vnc :0
10:40:01 ERROR| Status: 1
10:40:01 ERROR| Output:
qemu: -drive file=/tmp/kvm_autotest_root/images/f13-64.qcow2,index=0,if=virtio,boot=on: Invalid parameter 'boot'
qemu: -netdev user,id=idlTBuUt,vhost=on,hostfwd=tcp::5000-:22: Invalid parameter 'vhost'

Ok, the 'drive' problem I am going to fix, let's consider only 'vhost'.
When I read all the different qemu helps, it seems that vhost is tied to
-net:

-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h]
                connect the host TAP network interface to VLAN 'n' and use the
                network scripts 'file' (default=/etc/qemu-ifup)
                and 'dfile' (default=/etc/qemu-ifdown);
                use '[down]script=no' to disable script execution;
                use 'fd=h' to connect to an already opened TAP interface
                use 'sndbuf=nbytes' to limit the size of the send buffer; the
                default of 'sndbuf=1048576' can be disabled using 'sndbuf=0'
                use vnet_hdr=off to avoid enabling the IFF_VNET_HDR tap flag; use
                vnet_hdr=on to make the lack of IFF_VNET_HDR support an error condition
                use vhost=on to enable experimental in kernel accelerator
                use 'vhostfd=h' to connect to an already opened vhost net device

I don't think what I am missing here. I'd like to apply this, but since
I couldn't verify it working with none of the qemu versions I tried, I
am going to hold on for your comments.

Cheers,

Lucas


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [V2 PATCH 2/2] KVM test: Add vhost-net support
  2010-10-08 15:23     ` Lucas Meneghel Rodrigues
@ 2010-10-09  1:46       ` Jason Wang
  2010-10-11 14:12         ` Lucas Meneghel Rodrigues
  0 siblings, 1 reply; 6+ messages in thread
From: Jason Wang @ 2010-10-09  1:46 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: autotest, kvm, mst

Hi Lucas:

Vhost-net backend is only valid when we use tap, so it should work with
"nic_mode=tap". Maybe we could add a comment above the "vhost=on" to warn the
user to use tap when he need vhost.

----- "Lucas Meneghel Rodrigues" <lmr@redhat.com> wrote:

> On Fri, 2010-10-08 at 12:19 -0300, Lucas Meneghel Rodrigues wrote:
> > On Sun, 2010-09-26 at 10:28 +0800, Jason Wang wrote:
> > > Vhost is a kernel-level backend for virtio. This patch add a
> nic_params named
> > > "vhost" to enable/disable vhost backend.
> > 
> > Jason, I had rebased your patches. The patches themselves look good,
> but
> > apparently the syntax proposed here is invalid, and I've tried with
> > different qemu variants:
> > 
> > - qemu from rhel6
> > - qemu-kvm.git HEAD
> > - qemu.git HEAD
> > 
> > All of them don't support vhost with netdev:
> 
> 10:40:01 ERROR| VM could not be created; qemu command failed:
> /root/autotest/client/tests/kvm/qemu -name 'vm1' -monitor
> unix:'/tmp/monitor-humanmonitor1-20101008-103957-4nMr',server,nowait
> -serial unix:'/tmp/serial-20101008-103957-4nMr',server,nowait -drive
> file='/tmp/kvm_autotest_root/images/f13-64.qcow2',index=0,if=virtio,boot=on
> -device virtio-net-pci,mac=9a:0b:5d:7a:c1:7b,netdev=idlTBuUt -netdev
> user,id=idlTBuUt,vhost=on,hostfwd=tcp::5000-:22 -m 512 -smp 2 -drive
> file='/tmp/kvm_autotest_root/isos/linux/Fedora-13-x86_64-DVD.iso',media=cdrom,index=1
> -vnc :0
> 10:40:01 ERROR| Status: 1
> 10:40:01 ERROR| Output:
> qemu: -drive
> file=/tmp/kvm_autotest_root/images/f13-64.qcow2,index=0,if=virtio,boot=on:
> Invalid parameter 'boot'
> qemu: -netdev user,id=idlTBuUt,vhost=on,hostfwd=tcp::5000-:22: Invalid
> parameter 'vhost'
> 
> Ok, the 'drive' problem I am going to fix, let's consider only
> 'vhost'.
> When I read all the different qemu helps, it seems that vhost is tied
> to
> -net:
> 
> -net
> tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h]
>                 connect the host TAP network interface to VLAN 'n' and
> use the
>                 network scripts 'file' (default=/etc/qemu-ifup)
>                 and 'dfile' (default=/etc/qemu-ifdown);
>                 use '[down]script=no' to disable script execution;
>                 use 'fd=h' to connect to an already opened TAP
> interface
>                 use 'sndbuf=nbytes' to limit the size of the send
> buffer; the
>                 default of 'sndbuf=1048576' can be disabled using
> 'sndbuf=0'
>                 use vnet_hdr=off to avoid enabling the IFF_VNET_HDR
> tap flag; use
>                 vnet_hdr=on to make the lack of IFF_VNET_HDR support
> an error condition
>                 use vhost=on to enable experimental in kernel
> accelerator
>                 use 'vhostfd=h' to connect to an already opened vhost
> net device
> 
> I don't think what I am missing here. I'd like to apply this, but
> since
> I couldn't verify it working with none of the qemu versions I tried,
> I
> am going to hold on for your comments.
> 
> Cheers,
> 
> Lucas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [V2 PATCH 2/2] KVM test: Add vhost-net support
  2010-10-09  1:46       ` Jason Wang
@ 2010-10-11 14:12         ` Lucas Meneghel Rodrigues
  0 siblings, 0 replies; 6+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-10-11 14:12 UTC (permalink / raw)
  To: Jason Wang; +Cc: autotest, kvm, mst

On Fri, 2010-10-08 at 21:46 -0400, Jason Wang wrote:
> Hi Lucas:
> 
> Vhost-net backend is only valid when we use tap, so it should work with
> "nic_mode=tap". Maybe we could add a comment above the "vhost=on" to warn the
> user to use tap when he need vhost.

Ok, fair enough, that's what I've done for v3, that I just sent to the
mailing list for future record and commited it:

http://autotest.kernel.org/changeset/4846

Thank you very much!

Lucas


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-10-11 14:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-26  2:28 [V2 PATCH 1/2] KVM test: Use -device to add nic device when possible Jason Wang
2010-09-26  2:28 ` [V2 PATCH 2/2] KVM test: Add vhost-net support Jason Wang
2010-10-08 15:19   ` Lucas Meneghel Rodrigues
2010-10-08 15:23     ` Lucas Meneghel Rodrigues
2010-10-09  1:46       ` Jason Wang
2010-10-11 14:12         ` Lucas Meneghel Rodrigues

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.