Does macvtap support host to guest communication?
Hi, folks
I am trying to use qemu/qemu-kvm with macvtap using following commands:
# ip link add link eth0 name v0 type macvtap mode {vepa,bridge,private}
# ip link set v0 address da:4e:17:88:42:b1 up
# idx=`ip link show v0 | grep mtu| awk -F":" '{print $1}'`
# kvm -net nic,macaddr=da:4e:17:88:42:b1 -net tap,fd=3 -hda
/home/asias/qemu-stuff/sid.img 3<>/dev/tap${idx}I found that guest can access other hosts on the LAN except the host where guest lives, and host where guest lives can not access guest.
My question is: Does macvtap support host(hypervisor host) to guest communication?
Signature · 2 lines
Best Regards, Asias He
Quoted 11 lines · Asias He
Hi, folks
I am trying to use qemu/qemu-kvm with macvtap using following commands:
# ip link add link eth0 name v0 type macvtap mode {vepa,bridge,private} # ip link set v0 address da:4e:17:88:42:b1 up # idx=`ip link show v0 | grep mtu| awk -F":" '{print $1}'` # kvm -net nic,macaddr=da:4e:17:88:42:b1 -net tap,fd=3 -hda /home/asias/qemu-stuff/sid.img 3<>/dev/tap${idx}
Quoted 6 lines
I found that guest can access other hosts on the LAN except the host where guest lives, and host where guest lives can not access guest.
My question is: Does macvtap support host(hypervisor host) to guest communication?
You can communicate between macvtap and macvlan devices when they are in bridge mode, but these devices cannot communicate with clients that run on the underlying device.
Just add a macvlan device to your hardware interface and use that in the host instead of running on the low-level device directly.
The other option is to use a vepa enabled bridge, but these are relatively rare.
Arnd
Quoted 19 lines · Arnd Bergmann
Quoted 11 lines · Asias He
Hi, folks
I am trying to use qemu/qemu-kvm with macvtap using following commands:
# ip link add link eth0 name v0 type macvtap mode {vepa,bridge,private} # ip link set v0 address da:4e:17:88:42:b1 up # idx=`ip link show v0 | grep mtu| awk -F":" '{print $1}'` # kvm -net nic,macaddr=da:4e:17:88:42:b1 -net tap,fd=3 -hda /home/asias/qemu-stuff/sid.img 3<>/dev/tap${idx}Quoted 6 lines
I found that guest can access other hosts on the LAN except the host where guest lives, and host where guest lives can not access guest.
My question is: Does macvtap support host(hypervisor host) to guest communication?
Quoted 6 lines
You can communicate between macvtap and macvlan devices when they are in bridge mode, but these devices cannot communicate with clients that run on the underlying device.
Just add a macvlan device to your hardware interface and use that in the host instead of running on the low-level device directly.
Hi, Arnd
Works for me now. Thanks!
Here are some thoughts on the macvtap:
(1) Is it possible to add an interface to macvtap like /dev/net/tun, eg, /dev/net/macvtap. Currently, it is hard to use macvtap programmatically.
(2) Adding another macvlan device(e.g., macvlan0) to the hardware interface(e.g., eth0) and using it as the old eth0 make the process of using macvtap complicate. One has to reconfigure the network. This is not optimal from the user perspective. Is it possible to leave the low-level device as is when using the macvtap device?
Quoted 6 lines
The other option is to use a vepa enabled bridge, but these are relatively rare.
Arnd
Signature · 2 lines
Best Regards, Asias He
Quoted 2 lines · Asias He
(1) Is it possible to add an interface to macvtap like
/dev/net/tun, eg,/dev/net/macvtap. Currently, it is hard to use macvtap programmatically.
I decided against having a multiplexor device because it makes permission handling rather hard. One chardev per network interface makes it possible to handle permissions in multiuser setups.
Quoted 5 lines
(2) Adding another macvlan
device(e.g., macvlan0)to the hardwareinterface(e.g., eth0)and using it as the old eth0 make the process of using macvtap complicate. One has to reconfigure the network. This is not optimal from the user perspective. Is it possible to leave the low-level device as is when using the macvtap device?
Only in VEPA mode. Note that a similar restriction applies when using the bridge device, for the same technical reasons.
Arnd
Quoted 8 lines · Arnd Bergmann
Quoted 2 lines · Asias He
(1) Is it possible to add an interface to macvtap like
/dev/net/tun, eg,/dev/net/macvtap. Currently, it is hard to use macvtap programmatically.I decided against having a multiplexor device because it makes permission handling rather hard. One chardev per network interface makes it possible to handle permissions in multiuser setups.
Quoted 8 lines
Quoted 5 lines
(2) Adding another macvlan
device(e.g., macvlan0)to the hardwareinterface(e.g., eth0)and using it as the old eth0 make the process of using macvtap complicate. One has to reconfigure the network. This is not optimal from the user perspective. Is it possible to leave the low-level device as is when using the macvtap device?Only in VEPA mode. Note that a similar restriction applies when using the bridge device, for the same technical reasons.
Just to sum things up, our goal is to allow the tools/kvm/ unprivileged tool to provide TCP connectivity to Linux guests transparently, with the following parameters:
- the kvm tool runs unprivileged - as ordinary user
- without having to configure much (preferably zero configuration: without having to configure anything) on the guest Linux side
- multiple guests should just work without interfering with each other
- the kvm tool wants to be stateless - i.e. it does not want to allocate or manage host side devices - it just wants to provide the kind of TCP/IP connectivity host unprivileged user-space has, to the guest. The tool wants to be a generic tool with no global state, not a daemon.
So it wants to be a stateless, unprivileged and zero-configuration solution.
Is this possible with macvtap, and if yes, what kind of macvtap mode and usage would you recommend for that goal?
Thanks,
Ingo
Quoted 19 lines · Ingo Molnar
Quoted 2 lines
Only in VEPA mode. Note that a similar restriction applies when using the bridge device, for the same technical reasons.
Just to sum things up, our goal is to allow the
tools/kvm/unprivileged tool to provide TCP connectivity to Linux guests transparently, with the following parameters:- the kvm tool runs unprivileged - as ordinary user
- without having to configure much (preferably zero configuration: without having to configure anything) on the guest Linux side
- multiple guests should just work without interfering with each other
- the kvm tool wants to be stateless - i.e. it does not want to allocate or manage host side devices - it just wants to provide the kind of TCP/IP connectivity host unprivileged user-space has, to the guest. The tool wants to be a generic tool with no global state, not a daemon.
Quoted 4 lines
So it wants to be a stateless, unprivileged and zero-configuration solution.
Is this possible with macvtap, and if yes, what kind of macvtap mode and usage would you recommend for that goal?
With the above requirements, I would suggest using something like the the qemu user networking. This is slower and does not allow servers to be present in the guest, but those are not your goal as it seems.
The primary goals of macvtap are to allow efficient networking (zero-copy, multi-queue, although we're not completely there yet) and proper security abstractions.
If you want a guest to appear on the same network as the host, you can not do that without privileges to manage the host network setup, and I guess that will have to stay that way.
Arnd
Quoted 29 lines · Arnd Bergmann
Quoted 19 lines · Ingo Molnar
Quoted 2 lines
Only in VEPA mode. Note that a similar restriction applies when using the bridge device, for the same technical reasons.
Just to sum things up, our goal is to allow the
tools/kvm/unprivileged tool to provide TCP connectivity to Linux guests transparently, with the following parameters:- the kvm tool runs unprivileged - as ordinary user
- without having to configure much (preferably zero configuration: without having to configure anything) on the guest Linux side
- multiple guests should just work without interfering with each other
- the kvm tool wants to be stateless - i.e. it does not want to allocate or manage host side devices - it just wants to provide the kind of TCP/IP connectivity host unprivileged user-space has, to the guest. The tool wants to be a generic tool with no global state, not a daemon.
Quoted 4 lines
So it wants to be a stateless, unprivileged and zero-configuration solution.
Is this possible with macvtap, and if yes, what kind of macvtap mode and usage would you recommend for that goal?
With the above requirements, I would suggest using something like the the qemu user networking. This is slower and does not allow servers to be present in the guest, but those are not your goal as it seems.
Quoted 7 lines
The primary goals of macvtap are to allow efficient networking (zero-copy, multi-queue, although we're not completely there yet) and proper security abstractions.
If you want a guest to appear on the same network as the host, you can not do that without privileges to manage the host network setup, and I guess that will have to stay that way.
We do need "guest appearing on the same network as the host" support as well. The reason I am considering using macvatp instead of tap plus brctl is that it simplifies the bridge configuration and it is more efficient.
However, IMHO, the interface of macvtap is not user friendly, at least for me. I have no idea about the technical reasons that make the low-level device inaccessible. But if it is accessible, a lot of configuration can be eliminated. I know virtualbox's bridge mode has this kind of restriction, while VMware's bridge mode does not.
Quoted 3 lines
Arnd
Signature · 2 lines
Best Regards, Asias He
Quoted 4 lines · Asias He
We do need "guest appearing on the same network as the host" support as well. The reason I am considering using macvatp instead of tap plus brctl is that it simplifies the bridge configuration and it is more efficient.
Right, you certainly don't need to consider tap/brctl any more.
Quoted 5 lines
However, IMHO, the interface of macvtap is not user friendly, at least for me. I have no idea about the technical reasons that make the low-level device inaccessible. But if it is accessible, a lot of configuration can be eliminated. I know virtualbox's bridge mode has this kind of restriction, while VMware's bridge mode does not.
The main reason is that having a MAC address scan in the regular networking core would make the common TX case where there is no macvlan device more complex. Macvtap is derived from the plain macvlan driver, which used to support only sending out to the wire until I added the optional bridge mode.
If you want a regular device to be able to send to a macvlan port, that would require at least these changes:
* Add an option to put a plain device into macvlan-bridge mode
* Add support for that option into iproute2
* Add a hook into dev_queue_xmit() to check for macvlan ports
Arnd
Quoted 20 lines · Arnd Bergmann
Quoted 4 lines · Asias He
We do need "guest appearing on the same network as the host" support as well. The reason I am considering using macvatp instead of tap plus brctl is that it simplifies the bridge configuration and it is more efficient.
Right, you certainly don't need to consider tap/brctl any more.
Quoted 5 lines
However, IMHO, the interface of macvtap is not user friendly, at least for me. I have no idea about the technical reasons that make the low-level device inaccessible. But if it is accessible, a lot of configuration can be eliminated. I know virtualbox's bridge mode has this kind of restriction, while VMware's bridge mode does not.
The main reason is that having a MAC address scan in the regular networking core would make the common TX case where there is no macvlan device more complex. Macvtap is derived from the plain macvlan driver, which used to support only sending out to the wire until I added the optional bridge mode.
Quoted 6 lines
If you want a regular device to be able to send to a macvlan port, that would require at least these changes:
* Add an option to put a plain device into macvlan-bridge mode
* Add support for that option into iproute2
* Add a hook intodev_queue_xmit()to check for macvlan ports
Cool! Arnd, mind to add this feature to macvtap?
Signature · 2 lines
Best Regards, Asias He
Quoted 9 lines · Asias He
Quoted 7 lines
If you want a regular device to be able to send to a macvlan port, that would require at least these changes:
* Add an option to put a plain device into macvlan-bridge mode
* Add support for that option into iproute2
* Add a hook intodev_queue_xmit()to check for macvlan portsCool! Arnd, mind to add this feature to macvtap?
No, not after I just explained why I haven't done it before and why it's so controversial.
Also, I have moved on to other projects and am no longer doing active development of the macvtap driver. I'd be happy to pass on the ownership to someone else and help him or her extend it.
Arnd
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · Ashish Saxena
@Arnd, I would like to initiate the dig into into macvtap driver. Could you please provide me some pointers/docs to start with.
I dont' have any general recommendations.
I'd suggest you start reading the macvlan.c and macvtap.c source code and come back when you have specific questions.
Arnd
Quoted 14 lines · Arnd Bergmann
Quoted 9 lines · Asias He
Quoted 7 lines
If you want a regular device to be able to send to a macvlan port, that would require at least these changes:
* Add an option to put a plain device into macvlan-bridge mode
* Add support for that option into iproute2
* Add a hook intodev_queue_xmit()to check for macvlan portsCool! Arnd, mind to add this feature to macvtap?
No, not after I just explained why I haven't done it before and why it's so controversial.
Quoted 6 lines
Also, I have moved on to other projects and am no longer doing active development of the macvtap driver. I'd be happy to pass on the ownership to someone else and help him or her extend it.
Arnd
There's overlap between macvtap and some
ongoing work on vhost-net. In particular there are efforts to add zero copy and multiqueue support. So if you like, apply something like the below:
MAINTAINERS +7 -0
@@ -4034,6 +4034,13 @@ S: Maintained F: drivers/net/macvlan.c F: include/linux/if_macvlan.h +MACVTAP DRIVER +M: Michael S. Tsirkin <[email protected]> +M: Arnd Bergmann <[email protected]> +L: [email protected] +S: Maintained +F: drivers/net/macvtap.c + MAN-PAGES: MANUAL PAGES FOR LINUX -- Sections 2, 3, 4, 5, and 7 M: Michael Kerrisk <[email protected]> W: http://www.kernel.org/doc/man-pages
Quoted 9 lines · Ingo Molnar
- the kvm tool wants to be stateless - i.e. it does not want to allocate or manage host side devices - it just wants to provide the kind of TCP/IP connectivity host unprivileged user-space has, to the guest. The tool wants to be a generic tool with no global state, not a daemon.
So it wants to be a stateless, unprivileged and zero-configuration solution.
Is this possible with macvtap, and if yes, what kind of macvtap mode and usage would you recommend for that goal?
Well current approaches really all boil down to a network device in guest passing us raw packets. Typically this means the backend deals with raw packets as well. For example,
macvtap injects raw packets into host device, That's a priveledged operation. For tap you can setup NAT to reduce the priveledge. This is at the moment far from stateless though.
I would love to see something that does NAT but does not
need priveledges or host state. qemu uses slirp to
do (most of) this in userspace but it just seems silly to maintain yet another networking stack just for this. What do others think?
Signature · 1 line
MST