VM Sockets for Linux upstreaming
Subsystems (6)
cover VM Sockets for Linux upstreaming
In an effort to improve the out-of-the-box experience with Linux kernels for VMware users, VMware is working on readying the VM Sockets (VSOCK, formerly VMCI Sockets) (vsock) kernel module for inclusion in the Linux kernel. The purpose of this post is to acquire feedback on the vsock kernel module.
Unlike previous submissions, where the new socket family was entirely reliant on VMware's VMCI PCI device (and thus VMware's hypervisor), VM Sockets is now *completely* separated out into two parts, each in its own module:
o Core socket code, which is transport-neutral and invokes transport callbacks to communicate with the hypervisor. This is vsock.ko.
o A VMCI transport, which communicates over VMCI with the VMware hypervisor. This is vmw_vsock_vmci_transport.ko, and it registers with the core module as a transport.
This should provide a path to introducing additional transports, for example virtio, with the ultimate goal being to make this new socket family hypervisor-neutral.
Andy King (1):
VSOCK: Introduce VM Sockets
include/linux/socket.h | 4 +- include/uapi/linux/vm_sockets.h | 169 +++ net/Kconfig | 1 + net/Makefile | 1 + net/vmw_vsock/Kconfig | 28 + net/vmw_vsock/Makefile | 7 + net/vmw_vsock/af_vsock.c | 2085 ++++++++++++++++++++++++++ net/vmw_vsock/af_vsock.h | 170 +++ net/vmw_vsock/vmci_transport.c | 2050 +++++++++++++++++++++++++ net/vmw_vsock/vmci_transport.h | 139 ++ net/vmw_vsock/vmci_transport_notify.c | 680 +++++++++ net/vmw_vsock/vmci_transport_notify.h | 83 + net/vmw_vsock/vmci_transport_notify_qstate.c | 438 ++++++ net/vmw_vsock/vsock_addr.c | 128 ++ net/vmw_vsock/vsock_addr.h | 36 + net/vmw_vsock/vsock_version.h | 22 + 16 files changed, 6040 insertions(+), 1 deletions(-) create mode 100644 include/uapi/linux/vm_sockets.h create mode 100644 net/vmw_vsock/Kconfig create mode 100644 net/vmw_vsock/Makefile create mode 100644 net/vmw_vsock/af_vsock.c create mode 100644 net/vmw_vsock/af_vsock.h create mode 100644 net/vmw_vsock/vmci_transport.c create mode 100644 net/vmw_vsock/vmci_transport.h create mode 100644 net/vmw_vsock/vmci_transport_notify.c create mode 100644 net/vmw_vsock/vmci_transport_notify.h create mode 100644 net/vmw_vsock/vmci_transport_notify_qstate.c create mode 100644 net/vmw_vsock/vsock_addr.c create mode 100644 net/vmw_vsock/vsock_addr.h create mode 100644 net/vmw_vsock/vsock_version.h
Signature · 1 line
1.7.4.1
PATCH 1/1 VSOCK: Introduce VM Sockets
VM Sockets allows communication between virtual machines and the hypervisor. User level applications both in a virtual machine and on the host can use the VM Sockets API, which facilitates fast and efficient communication between guest virtual machines and their host. A socket address family, designed to be compatible with UDP and TCP at the interface level, is provided.
Today, VM Sockets is used by various VMware Tools components inside the guest for zero-config, network-less access to VMware host services. In addition to this, VMware's users are using VM Sockets for various applications, where network access of the virtual machine is restricted or non-existent. Examples of this are VMs communicating with device proxies for proprietary hardware running as host applications and automated testing of applications running within virtual machines.
The VMware VM Sockets are similar to other socket types, like Berkeley UNIX socket interface. The VM Sockets module supports both connection-oriented stream sockets like TCP, and connectionless datagram sockets like UDP. The VM Sockets protocol family is defined as "AF_VSOCK" and the socket operations split for SOCK_DGRAM and SOCK_STREAM.
For additional information about the use of VM Sockets, please refer to the VM Sockets Programming Guide available at:
https://www.vmware.com/support/developer/vmci-sdk/
--- include/linux/socket.h | 4 +- include/uapi/linux/vm_sockets.h | 169 +++ net/Kconfig | 1 + net/Makefile | 1 + net/vmw_vsock/Kconfig | 28 + net/vmw_vsock/Makefile | 7 + net/vmw_vsock/af_vsock.c | 2085 ++++++++++++++++++++++++++ net/vmw_vsock/af_vsock.h | 170 +++ net/vmw_vsock/vmci_transport.c | 2050 +++++++++++++++++++++++++ net/vmw_vsock/vmci_transport.h | 139 ++ net/vmw_vsock/vmci_transport_notify.c | 680 +++++++++ net/vmw_vsock/vmci_transport_notify.h | 83 + net/vmw_vsock/vmci_transport_notify_qstate.c | 438 ++++++ net/vmw_vsock/vsock_addr.c | 128 ++ net/vmw_vsock/vsock_addr.h | 36 + net/vmw_vsock/vsock_version.h | 22 + 16 files changed, 6040 insertions(+), 1 deletions(-) create mode 100644 include/uapi/linux/vm_sockets.h create mode 100644 net/vmw_vsock/Kconfig create mode 100644 net/vmw_vsock/Makefile create mode 100644 net/vmw_vsock/af_vsock.c create mode 100644 net/vmw_vsock/af_vsock.h create mode 100644 net/vmw_vsock/vmci_transport.c create mode 100644 net/vmw_vsock/vmci_transport.h create mode 100644 net/vmw_vsock/vmci_transport_notify.c create mode 100644 net/vmw_vsock/vmci_transport_notify.h create mode 100644 net/vmw_vsock/vmci_transport_notify_qstate.c create mode 100644 net/vmw_vsock/vsock_addr.c create mode 100644 net/vmw_vsock/vsock_addr.h create mode 100644 net/vmw_vsock/vsock_version.h
include/linux/socket.h +3 -1
@@ -178,7 +178,8 @@ struct ucred {#define AF_CAIF 37/* CAIF sockets */ #define AF_ALG 38/* Algorithm sockets */ #define AF_NFC 39/* NFC sockets */ -#define AF_MAX 40/* For now.. */ +#define AF_VSOCK 40/* vSockets */ +#define AF_MAX 41/* For now.. */ /* Protocol families, same as address families. */ #define PF_UNSPEC AF_UNSPEC
@@ -221,6 +222,7 @@ struct ucred {#define PF_CAIF AF_CAIF#define PF_ALG AF_ALG#define PF_NFC AF_NFC +#define PF_VSOCK AF_VSOCK#define PF_MAX AF_MAX/* Maximum queue length specifiable by listen. */
include/uapi/linux/vm_sockets.h new file +169 -0
169 lines not on this page · raw message
net/Kconfig +1 -0
@@ -218,6 +218,7 @@ source "net/dcb/Kconfig" source "net/dns_resolver/Kconfig" source "net/batman-adv/Kconfig" source "net/openvswitch/Kconfig" +source "net/vmw_vsock/Kconfig" config RPS boolean
net/Makefile +1 -0
@@ -70,3 +70,4 @@ obj-$(CONFIG_CEPH_LIB) += ceph/ obj-$(CONFIG_BATMAN_ADV) += batman-adv/ obj-$(CONFIG_NFC) += nfc/ obj-$(CONFIG_OPENVSWITCH) += openvswitch/ +obj-$(CONFIG_VSOCKETS) += vmw_vsock/
net/vmw_vsock/Kconfig new file +28 -0
@@ -0,0 +1,28 @@ +# +# Vsock protocol +# + +config VSOCKETS + tristate "Virtual Socket protocol" + help + Virtual Socket Protocol is a socket protocol similar to TCP/IP + allowing comunication between Virtual Machines and hypervisor + or host. + + You should also select one or more hypervisor-specific transports + below. + + To compile this driver as a module, choose M here: the module + will be called vsock. If unsure, say N. + +config VMWARE_VMCI_VSOCKETS + tristate "VMware VMCI transport for Virtual Sockets" + depends on VSOCKETS && VMWARE_VMCI + help + This module implements a VMCI transport for Virtual Sockets. + + Enable this transport if your Virtual Machine runs on a VMware + hypervisor. + + To compile this driver as a module, choose M here: the module + will be called vmw_vsock_vmci_transport. If unsure, say N.
net/vmw_vsock/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +obj-$(CONFIG_VSOCKETS) += vsock.o +obj-$(CONFIG_VMWARE_VMCI_VSOCKETS) += vmw_vsock_vmci_transport.o + +vsock-y += af_vsock.o vsock_addr.o + +vmw_vsock_vmci_transport-y += vmci_transport.o vmci_transport_notify.o \ + vmci_transport_notify_qstate.o
net/vmw_vsock/af_vsock.c new file +2085 -0
2,085 lines not on this page · raw message
net/vmw_vsock/af_vsock.h new file +170 -0
170 lines not on this page · raw message
net/vmw_vsock/vmci_transport.c new file +2050 -0
514 lines not on this page · raw message
net/vmw_vsock/vmci_transport.h new file +139 -0
139 lines not on this page · raw message
net/vmw_vsock/vmci_transport_notify.c new file +680 -0
680 lines not on this page · raw message
net/vmw_vsock/vmci_transport_notify.h new file +83 -0
83 lines not on this page · raw message
net/vmw_vsock/vmci_transport_notify_qstate.c new file +438 -0
438 lines not on this page · raw message
net/vmw_vsock/vsock_addr.c new file +128 -0
128 lines not on this page · raw message
net/vmw_vsock/vsock_version.h new file +22 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.4.1
Part of the diff is not shown here. View the raw message.
Hi,
Quoted 3 lines
Unlike previous submissions, where the new socket family was entirely reliant on VMware's VMCI PCI device (and thus VMware's hypervisor), VM Sockets is now *completely* separated out into two parts, each in its own module:
Some separation still needs to be done:
CC [M] net/vmw_vsock/af_vsock.o
In file included from /home/kraxel/projects/linux/net/vmw_vsock/af_vsock.c:102:0:/home/kraxel/projects/linux/net/vmw_vsock/af_vsock.h:21:33: fatal error:linux/vmw_vmci_defs.h: No such file or directory
compilation terminated.
make[4]: *** [net/vmw_vsock/af_vsock.o] Error 1
[ with vmci series from jan 9th applied on top it builds ]
Module deps are a bit bogous too:
vmw_vsock_vmci_transport 26162 0
vsock 34481 1 vmw_vsock_vmci_transport vmw_vmci 61602 2 vsock,vmw_vsock_vmci_transport
Only vmw_vsock_vmci_transport should have a vmw_vmci dependency, not vsock ...
Nevertheless this should be good enough to start hacking up a virtio prototype.
cheers,
Gerd
Hi Gerd,
Quoted 10 lines
Some separation still needs to be done:
CC [M]
net/vmw_vsock/af_vsock.o
In file included from/home/kraxel/projects/linux/net/vmw_vsock/af_vsock.c:102:0:/home/kraxel/projects/linux/net/vmw_vsock/af_vsock.h:21:33: fatal error:linux/vmw_vmci_defs.h: No such file or directory compilation terminated.
make[4]: *** [net/vmw_vsock/af_vsock.o] Error 1
Oops, you're right, it really shouldn't need that header. Sorry about that, let me rip that out.
Quoted 8 lines
Module deps are a bit bogous too:
vmw_vsock_vmci_transport26162 0vsock 34481 1 vmw_vsock_vmci_transport vmw_vmci 61602 2 vsock,vmw_vsock_vmci_transportOnly
vmw_vsock_vmci_transportshould have avmw_vmcidependency, not vsock ...
Agreed, that's not right, I'll fix that too.
Quoted 2 lines
Nevertheless this should be good enough to start hacking up a virtio prototype.
Great!
Thanks!
- Andy
Hi Gerd,
Quoted 6 lines
Quoted 3 lines
linux/vmw_vmci_defs.h: No such file or directory
compilation terminated.
make[4]: *** [net/vmw_vsock/af_vsock.o] Error 1Oops, you're right, it really shouldn't need that header. Sorry about that, let me rip that out.
Fixed. The VMCI headers are now gone from the core in af_vsock.* and vsock_addr.*
Quoted 4 lines
Quoted 2 lines
Only
vmw_vsock_vmci_transportshould have avmw_vmcidependency, not vsock ...Agreed, that's not right, I'll fix that too.
Fixed, lsmod now shows that only the transport has a dependency.
Also, it turns out that we do need a dgram_recv(), since our transport currently enqueues skbs with VMCI DGRAMs in them, which need to be converted before copying into the user's buffer. I've added that too.
Please see latest patchset (sent a few minutes ago), hope it works for you this time.
Thanks!
- Andy