VM Sockets for Linux upstreaming
Subsystems (6)
cover VM Sockets for Linux upstreaming
From: Andy King <[email protected]>
** Introduce VM Sockets ***
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) (vmw_vsock) kernel module for inclusion in the Linux kernel. The purpose of this post is to acquire feedback on the vmw_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 _mostly_ separated out into two parts:
o Core socket code, which is transport-neutral and invokes transport callbacks to communicate with the hypervisor.
o A VMCI transport, which communicates over VMCI with the VMware hypervisor.
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 | 14 + net/vmw_vsock/Makefile | 4 + net/vmw_vsock/af_vsock.c | 1983 ++++++++++++++++++++++++++ net/vmw_vsock/af_vsock.h | 256 ++++ net/vmw_vsock/vmci_transport.c | 1863 ++++++++++++++++++++++++ net/vmw_vsock/vmci_transport.h | 90 ++ net/vmw_vsock/vmci_transport_notify.c | 677 +++++++++ net/vmw_vsock/vmci_transport_notify.h | 126 ++ net/vmw_vsock/vmci_transport_notify_qstate.c | 411 ++++++ net/vmw_vsock/vsock_addr.c | 118 ++ net/vmw_vsock/vsock_addr.h | 36 + net/vmw_vsock/vsock_version.h | 22 + 16 files changed, 5774 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
From: Andy King <[email protected]>
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 | 14 + net/vmw_vsock/Makefile | 4 + net/vmw_vsock/af_vsock.c | 1983 ++++++++++++++++++++++++++ net/vmw_vsock/af_vsock.h | 256 ++++ net/vmw_vsock/vmci_transport.c | 1863 ++++++++++++++++++++++++ net/vmw_vsock/vmci_transport.h | 90 ++ net/vmw_vsock/vmci_transport_notify.c | 677 +++++++++ net/vmw_vsock/vmci_transport_notify.h | 126 ++ net/vmw_vsock/vmci_transport_notify_qstate.c | 411 ++++++ net/vmw_vsock/vsock_addr.c | 118 ++ net/vmw_vsock/vsock_addr.h | 36 + net/vmw_vsock/vsock_version.h | 22 + 16 files changed, 5774 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_VMWARE_VSOCK) += vmw_vsock/
net/vmw_vsock/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# +# Vsock protocol +# + +config VMWARE_VSOCK + tristate "Virtual Socket protocol" + depends on VMWARE_VMCI + help + Virtual Socket Protocol is a socket protocol similar to TCP/IP + allowing comunication between Virtual Machines and VMware + hypervisor. + + To compile this driver as a module, choose M here: the module + will be called vsock. If unsure, say N.
net/vmw_vsock/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock.o + +vmw_vsock-y += af_vsock.o vmci_transport.o vmci_transport_notify.o \ + vmci_transport_notify_qstate.o vsock_addr.o
net/vmw_vsock/af_vsock.c new file +1983 -0
1,983 lines not on this page · raw message
net/vmw_vsock/af_vsock.h new file +256 -0
256 lines not on this page · raw message
net/vmw_vsock/vmci_transport.c new file +1863 -0
547 lines not on this page · raw message
net/vmw_vsock/vmci_transport.h new file +90 -0
90 lines not on this page · raw message
net/vmw_vsock/vmci_transport_notify.c new file +677 -0
677 lines not on this page · raw message
net/vmw_vsock/vmci_transport_notify.h new file +126 -0
126 lines not on this page · raw message
net/vmw_vsock/vmci_transport_notify_qstate.c new file +411 -0
411 lines not on this page · raw message
net/vmw_vsock/vsock_addr.c new file +118 -0
118 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.
Re: [PATCH 1/1] VSOCK: Introduce VM Sockets
Quoted 34 lines · On Fri, Jan 25, 2013 at 09:37:50AM -0800, [email protected] wrote:
From: Andy King <[email protected]>
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 forSOCK_DGRAMandSOCK_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/
Signed-off-by George Zhang <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>Signed-off-by Andy king <[email protected]>index 0000000..95e2568
net/vmw_vsock/Kconfig line 7
Quoted 7 lines
net/vmw_vsock/Kconfig new file +7
-0@@ -0,0 +1,14 @@ +# +# Vsock protocol +# + +config VMWARE_VSOCK + tristate "Virtual Socket protocol" + depends on VMWARE_VMCI
What is CONFIG_VMWARE_VMCI? I don't find that in any Kconfig in the tree?
I''m still looking over the rest, but I get build issues if I just remove the dependency.
Neil
Re: [Pv-drivers] [PATCH 1/1] VSOCK: Introduce VM Sockets
Hi Neil,
Quoted 10 lines · Neil Horman
net/vmw_vsock/Kconfig line 7
Quoted 4 lines · On Fri, Jan 25, 2013 at 09:37:50AM -0800, [email protected] wrote:
net/vmw_vsock/Kconfig new file +4
-0+ +config VMWARE_VSOCK + tristate "Virtual Socket protocol" + depends on VMWARE_VMCIWhat is
CONFIG_VMWARE_VMCI? I don't find that in anyKconfigin the tree?I''m still looking over the rest, but I get build issues if I just remove the dependency.
VMCI is in linux-next at the moment.
Thanks,
Dmitry
Re: [Pv-drivers] [PATCH 1/1] VSOCK: Introduce VM Sockets
In reply to Neil HormanHi Neil,
Quoted 10 lines · Neil Horman
net/vmw_vsock/Kconfig line 7
Quoted 4 lines · On Fri, Jan 25, 2013 at 09:37:50AM -0800, [email protected] wrote:
net/vmw_vsock/Kconfig new file +4
-0+ +config VMWARE_VSOCK + tristate "Virtual Socket protocol" + depends on VMWARE_VMCIWhat is
CONFIG_VMWARE_VMCI? I don't find that in anyKconfigin the tree?I''m still looking over the rest, but I get build issues if I just remove the dependency.
VMCI is in linux-next at the moment.
Thanks,
Dmitry
Re: [Pv-drivers] [PATCH 1/1] VSOCK: Introduce VM Sockets
Quoted 11 lines · Dmitry Torokhov
Hi Neil,
Quoted 8 lines · Neil Horman
net/vmw_vsock/Kconfig line 7
Quoted 4 lines · On Fri, Jan 25, 2013 at 09:37:50AM -0800, [email protected] wrote:
net/vmw_vsock/Kconfig new file +4
-0+ +config VMWARE_VSOCK + tristate "Virtual Socket protocol" + depends on VMWARE_VMCIWhat is
CONFIG_VMWARE_VMCI? I don't find that in anyKconfigin the tree?
Quoted 6 lines
Quoted 2 lines
I''m still looking over the rest, but I get build issues if I just remove the dependency.
VMCI is in linux-next at the moment.
From the char-misc-next git tree to be specific.
thanks,
greg k-h
Re: [Pv-drivers] [PATCH 1/1] VSOCK: Introduce VM Sockets
In reply to Dmitry TorokhovQuoted 11 lines · Dmitry Torokhov
Hi Neil,
Quoted 8 lines · Neil Horman
net/vmw_vsock/Kconfig line 7
Quoted 4 lines · On Fri, Jan 25, 2013 at 09:37:50AM -0800, [email protected] wrote:
net/vmw_vsock/Kconfig new file +4
-0+ +config VMWARE_VSOCK + tristate "Virtual Socket protocol" + depends on VMWARE_VMCIWhat is
CONFIG_VMWARE_VMCI? I don't find that in anyKconfigin the tree?
Quoted 8 lines
Quoted 2 lines
I''m still looking over the rest, but I get build issues if I just remove the dependency.
VMCI is in linux-next at the moment.
Thanks,
Dmitry
Thanks, I'll pull that in.
Neil
Re: [PATCH 1/1] VSOCK: Introduce VM Sockets
In reply to [email protected]Quoted 34 lines · On Fri, Jan 25, 2013 at 09:37:50AM -0800, [email protected] wrote:
From: Andy King <[email protected]>
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 forSOCK_DGRAMandSOCK_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/
Signed-off-by George Zhang <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>Signed-off-by Andy king <[email protected]>index 0000000..95e2568
net/vmw_vsock/Kconfig line 7
Quoted 7 lines
net/vmw_vsock/Kconfig new file +7
-0@@ -0,0 +1,14 @@ +# +# Vsock protocol +# + +config VMWARE_VSOCK + tristate "Virtual Socket protocol" + depends on VMWARE_VMCI
What is CONFIG_VMWARE_VMCI? I don't find that in any Kconfig in the tree?
I''m still looking over the rest, but I get build issues if I just remove the dependency.
Neil
Re: [PATCH 1/1] VSOCK: Introduce VM Sockets
In reply to [email protected]Hi,
net/vmw_vsock/Kconfig line 7
Quoted 13 lines
net/vmw_vsock/Kconfig new file +7
-0@@ -0,0 +1,14 @@ +# +# Vsock protocol +# + +config VMWARE_VSOCK + tristate "Virtual Socket protocol" + depends on VMWARE_VMCI
I guess this is temporary? Cover letter says *mostly* separated ...
net/vmw_vsock/Kconfig line 9
Quoted 2 lines
net/vmw_vsock/Kconfig new file +2
-0+vmw_vsock-y += af_vsock.o vmci_transport.o vmci_transport_notify.o \ + vmci_transport_notify_qstate.o vsock_addr.o
Likewise, I expect with the final version vmci_transport is a separate module (or moves into the vmci driver), correct?
Quoted 4 lines
net/vmw_vsock/Kconfig new file +4
-0+static long vsock_dev_do_ioctl(struct file *filp, + unsigned int cmd, void __user *ptr) +{ + static const u16 parts[4] = VSOCK_DRIVER_VERSION_PARTS;
net/vmw_vsock/Kconfig
Quoted 10 lines
net/vmw_vsock/Kconfig new file +10
-0+ u32 __user *p = ptr; + int retval = 0; + u32 version; + + switch (cmd) { + case IOCTL_VMCI_SOCKETS_VERSION: + version = VMCI_SOCKETS_MAKE_VERSION(parts); + if (put_user(version, p) != 0) + retval = -EFAULT; + break;
Still needed?
net/vmw_vsock/Kconfig
Quoted 5 lines
net/vmw_vsock/Kconfig new file +5
-0+ case IOCTL_VMCI_SOCKETS_GET_AF_VALUE: + if (put_user(AF_VSOCK, p) != 0) + retval = -EFAULT; + + break;
That can go away, with the upstream merge vsock will get a fixed AF_VSOCK.
net/vmw_vsock/Kconfig
Quoted 3 lines
net/vmw_vsock/Kconfig new file +3
-0+ case IOCTL_VMCI_SOCKETS_GET_LOCAL_CID: + if (put_user(vmci_get_context_id(), p) != 0) + retval = -EFAULT;
What is this?
Quoted 7 lines
net/vmw_vsock/Kconfig new file +7
-0+static int __init vsock_init(void) +{ + int err; + + vsock_init_tables(); + + err = misc_register(&vsock_device);
net/vmw_vsock/Kconfig
Quoted 10 lines
net/vmw_vsock/Kconfig new file +10
-0+ if (err) { + pr_err("Failed to register misc device\n"); + return -ENOENT; + } + + err = vmci_transport_register(&transport); + if (err) { + pr_err("Cannot register with VMCI device\n"); + goto err_misc_deregister; + }
Hmm? There should be a vsock_(un)register_transport which the vmci transport code can call (and likewise virtio transport some day).
net/vmw_vsock/Kconfig
Quoted 12 lines
net/vmw_vsock/Kconfig new file +11
-0+struct vsock_sock { + /* sk must be the first member. */ + struct sock sk; + struct sockaddr_vm local_addr; + struct sockaddr_vm remote_addr; + /* The rest is transport-specific: this is the stuff we need to pull + * out to make it work with something other than VMCI. + */ + struct { + /* For DGRAMs. */ + struct vmci_handle dg_handle;
Yep, should be a pointer where transports can hook in their private data.
Quoted 9 lines
net/vmw_vsock/Kconfig new file +9
-0+/**** TRANSPORT ****/ + +struct vsock_transport { + void (*init)(struct vsock_sock *, struct vsock_sock *); + void (*destruct)(struct vsock_sock *); + void (*release)(struct vsock_sock *); + int (*connect)(struct vsock_sock *); + int (*bind_dgram)(struct vsock_sock *, struct sockaddr_vm *); + int (*send_dgram)(struct vsock_sock *, struct sockaddr_vm *,
net/vmw_vsock/Kconfig
Quoted 10 lines
net/vmw_vsock/Kconfig new file +10
-0+ struct iovec *, size_t len); + ssize_t (*recv_stream)(struct vsock_sock *, struct iovec *, + size_t len, int flags); + ssize_t (*send_stream)(struct vsock_sock *, struct iovec *, + size_t len); + s64 (*stream_has_data)(struct vsock_sock *); + s64 (*stream_has_space)(struct vsock_sock *); + int (*send_shutdown)(struct sock *sk, int mode); + void (*unregister)(void); +};
So that is the interface transports have to implement. Looks reasonable to me. Some documentation would be nice, although most of it is self-explaining.
Where is recv_dgram?
Also why bind_dgram? I guess binding stream sockets doesn't make sense for the vsock family?
I'd make the naming a bit more consistent, some stream callbacks are prefixed and some postfixed with "stream".
I'd also name send_shutdown just shutdown (same name the system call has).
What does unregister?
cheers,
Gerd
Re: [PATCH 1/1] VSOCK: Introduce VM Sockets
In reply to [email protected]Hi,
net/vmw_vsock/Kconfig line 7
Quoted 13 lines
net/vmw_vsock/Kconfig new file +7
-0@@ -0,0 +1,14 @@ +# +# Vsock protocol +# + +config VMWARE_VSOCK + tristate "Virtual Socket protocol" + depends on VMWARE_VMCI
I guess this is temporary? Cover letter says *mostly* separated ...
net/vmw_vsock/Kconfig line 9
Quoted 2 lines
net/vmw_vsock/Kconfig new file +2
-0+vmw_vsock-y += af_vsock.o vmci_transport.o vmci_transport_notify.o \ + vmci_transport_notify_qstate.o vsock_addr.o
Likewise, I expect with the final version vmci_transport is a separate module (or moves into the vmci driver), correct?
Quoted 4 lines
net/vmw_vsock/Kconfig new file +4
-0+static long vsock_dev_do_ioctl(struct file *filp, + unsigned int cmd, void __user *ptr) +{ + static const u16 parts[4] = VSOCK_DRIVER_VERSION_PARTS;
net/vmw_vsock/Kconfig
Quoted 10 lines
net/vmw_vsock/Kconfig new file +10
-0+ u32 __user *p = ptr; + int retval = 0; + u32 version; + + switch (cmd) { + case IOCTL_VMCI_SOCKETS_VERSION: + version = VMCI_SOCKETS_MAKE_VERSION(parts); + if (put_user(version, p) != 0) + retval = -EFAULT; + break;
Still needed?
net/vmw_vsock/Kconfig
Quoted 5 lines
net/vmw_vsock/Kconfig new file +5
-0+ case IOCTL_VMCI_SOCKETS_GET_AF_VALUE: + if (put_user(AF_VSOCK, p) != 0) + retval = -EFAULT; + + break;
That can go away, with the upstream merge vsock will get a fixed AF_VSOCK.
net/vmw_vsock/Kconfig
Quoted 3 lines
net/vmw_vsock/Kconfig new file +3
-0+ case IOCTL_VMCI_SOCKETS_GET_LOCAL_CID: + if (put_user(vmci_get_context_id(), p) != 0) + retval = -EFAULT;
What is this?
Quoted 7 lines
net/vmw_vsock/Kconfig new file +7
-0+static int __init vsock_init(void) +{ + int err; + + vsock_init_tables(); + + err = misc_register(&vsock_device);
net/vmw_vsock/Kconfig
Quoted 10 lines
net/vmw_vsock/Kconfig new file +10
-0+ if (err) { + pr_err("Failed to register misc device\n"); + return -ENOENT; + } + + err = vmci_transport_register(&transport); + if (err) { + pr_err("Cannot register with VMCI device\n"); + goto err_misc_deregister; + }
Hmm? There should be a vsock_(un)register_transport which the vmci transport code can call (and likewise virtio transport some day).
net/vmw_vsock/Kconfig
Quoted 12 lines
net/vmw_vsock/Kconfig new file +11
-0+struct vsock_sock { + /* sk must be the first member. */ + struct sock sk; + struct sockaddr_vm local_addr; + struct sockaddr_vm remote_addr; + /* The rest is transport-specific: this is the stuff we need to pull + * out to make it work with something other than VMCI. + */ + struct { + /* For DGRAMs. */ + struct vmci_handle dg_handle;
Yep, should be a pointer where transports can hook in their private data.
Quoted 9 lines
net/vmw_vsock/Kconfig new file +9
-0+/**** TRANSPORT ****/ + +struct vsock_transport { + void (*init)(struct vsock_sock *, struct vsock_sock *); + void (*destruct)(struct vsock_sock *); + void (*release)(struct vsock_sock *); + int (*connect)(struct vsock_sock *); + int (*bind_dgram)(struct vsock_sock *, struct sockaddr_vm *); + int (*send_dgram)(struct vsock_sock *, struct sockaddr_vm *,
net/vmw_vsock/Kconfig
Quoted 10 lines
net/vmw_vsock/Kconfig new file +10
-0+ struct iovec *, size_t len); + ssize_t (*recv_stream)(struct vsock_sock *, struct iovec *, + size_t len, int flags); + ssize_t (*send_stream)(struct vsock_sock *, struct iovec *, + size_t len); + s64 (*stream_has_data)(struct vsock_sock *); + s64 (*stream_has_space)(struct vsock_sock *); + int (*send_shutdown)(struct sock *sk, int mode); + void (*unregister)(void); +};
So that is the interface transports have to implement. Looks reasonable to me. Some documentation would be nice, although most of it is self-explaining.
Where is recv_dgram?
Also why bind_dgram? I guess binding stream sockets doesn't make sense for the vsock family?
I'd make the naming a bit more consistent, some stream callbacks are prefixed and some postfixed with "stream".
I'd also name send_shutdown just shutdown (same name the system call has).
What does unregister?
cheers,
Gerd
Re: [PATCH 1/1] VSOCK: Introduce VM Sockets
Hi Gerd,
Thanks so much for taking a look and apologies for the delay!
Quoted 5 lines
net/vmw_vsock/Kconfig line 7
Quoted 3 lines
net/vmw_vsock/Kconfig new file +3
-0+config VMWARE_VSOCK + tristate "Virtual Socket protocol" + depends on VMWARE_VMCII guess this is temporary? Cover letter says *mostly* separated ...
Yes, right now everything is still munged into one driver.
Quoted 6 lines
net/vmw_vsock/Makefile line 4
Quoted 3 lines
+vmw_vsock-y += af_vsock.o vmci_transport.o vmci_transport_notify.o \
net/vmw_vsock/Makefile new file +1
-0+ vmci_transport_notify_qstate.o vsock_addr.oLikewise, I expect with the final version
vmci_transportis a separate module (or moves into the vmci driver), correct?
When you say final, do you mean something that we have to do before acceptance into mainline or something we can refine over time? I'm rather hoping for the latter: it'd be nice to come to an agreement about whether VM Sockets is the right way to go, and actually get this in, before we go to the trouble of splitting this out, only to find that nobody actually implements their own transport ;)
Quoted 8 lines
net/vmw_vsock/af_vsock.c line 1875
Quoted 6 lines
net/vmw_vsock/af_vsock.c new file +6
-0+switch (cmd) { +case IOCTL_VMCI_SOCKETS_VERSION : + version =VMCI_SOCKETS_MAKE_VERSION (parts); +if (put_user (version, p) !=0 ) + retval = -EFAULT ; +break ;Still needed?
Cut.
Quoted 8 lines
net/vmw_vsock/af_vsock.c line 1881
Quoted 5 lines
net/vmw_vsock/af_vsock.c new file +5
-0+case IOCTL_VMCI_SOCKETS_GET_AF_VALUE : +if (put_user (AF_VSOCK , p) !=0 ) + retval = -EFAULT ; + +break ;That can go away, with the upstream merge vsock will get a fixed
AF_VSOCK.
Cut.
Quoted 5 lines
net/vmw_vsock/af_vsock.c line 1885
Quoted 3 lines
net/vmw_vsock/af_vsock.c new file +3
-0+case IOCTL_VMCI_SOCKETS_GET_LOCAL_CID : +if (put_user (vmci_get_context_id (), p) !=0 ) + retval = -EFAULT ;What is this?
A CID, or "context ID" is how we identify a VM. It's also in the address structure (svm_cid). If you look at vm_sockets.h, you'll see that we have definitions for various endpoints (the host, anonymous and so forth). It's sometimes useful for VMs to be able to query their own ID, for example, to be able to pass it out-of-band via INET to a peer. So we'd like to keep this, although I guess it should be transport-defined, i.e., we should ask the transport for this value.
Quoted 8 lines
net/vmw_vsock/af_vsock.c line 1942
Quoted 5 lines
net/vmw_vsock/af_vsock.c new file +5
-0+ err =vmci_transport_register (&transport); +if (err) { +pr_err ("Cannot register with VMCI device\n" ); + goto err_misc_deregister; + }Hmm? There should be a vsock_(un)register_transport which the vmci transport code can call (and likewise virtio transport some day).
Yes, it's still totally topsy-turvy. But see comment about coming to an agreement :)
Quoted 6 lines
net/vmw_vsock/af_vsock.h line 72
Quoted 3 lines
net/vmw_vsock/af_vsock.h new file +3
-0+struct { +/* For DGRAMs. */ +struct vmci_handle dg_handle;Yep, should be a pointer where transports can hook in their private data.
I'm fixing this.
Quoted 22 lines
Quoted 7 lines
net/vmw_vsock/af_vsock.h new file +7
-0+struct vsock_transport { +void (*init)(struct vsock_sock *,struct vsock_sock *); +void (*destruct)(struct vsock_sock *); +void (*release)(struct vsock_sock *); +int (*connect)(struct vsock_sock *); +int (*bind_dgram)(struct vsock_sock *,struct sockaddr_vm *); + int (*send_dgram)(struct vsock_sock *, struct sockaddr_vm *,net/vmw_vsock/af_vsock.h line 114
Quoted 10 lines
net/vmw_vsock/af_vsock.h new file +10
-0+ struct iovec *, size_t len); +ssize_t (*recv_stream)(struct vsock_sock *,struct iovec *, +size_t len,int flags); +ssize_t (*send_stream)(struct vsock_sock *,struct iovec *, +size_t len); +s64 (*stream_has_data)(struct vsock_sock *); +s64 (*stream_has_space)(struct vsock_sock *); +int (*send_shutdown)(struct sock *sk,int mode); +void (*unregister)(void ); +};So that is the interface transports have to implement. Looks reasonable to me. Some documentation would be nice, although most of it is self-explaining.
Quoted 1 line
Where is
recv_dgram?
The transport just enqueues sk_buffs in the socket's buffer, so the core socket code can just pull them off. So there's no explicit recv_dgram.
Quoted 2 lines
Also why
bind_dgram? I guess binding stream sockets doesn't make sense for the vsock family?
Ah, for our transport, there's nothing special involved in binding a STREAM, everything is handled by the core socket code. So I didn't add a transport callback. This is something we can add when it becomes necessary, if that's okay?
Quoted 2 lines
I'd make the naming a bit more consistent, some stream callbacks are prefixed and some postfixed with "stream".
Fixed.
Quoted 2 lines
I'd also name
send_shutdownjust shutdown (same name the system call has).
Fixed.
Quoted 1 line
What does unregister?
That's topsy-turvy unregistration, it drops the transport. It will go away eventually.
I'll send out a patch soon addressing the (easy) issues above.
Thanks!
- Andy
Re: [PATCH 1/1] VSOCK: Introduce VM Sockets
Hi,
Quoted 5 lines
Quoted 2 lines
Likewise, I expect with the final version
vmci_transportis a separate module (or moves into the vmci driver), correct?When you say final, do you mean something that we have to do before acceptance into mainline or something we can refine over time?
IMHO refining in-tree is fine.
This is the purpose of staging after all.
Quoted 1 line
From my side the minimum requirement is to have
vsock_(un)register_transport calls available, so it is possible to write a virtio transport module without having to patch vsock code to hook it up. Having the vsock bits in staging would actually make it a bit easier to add virtio.
In the end it is Greg's / Dave's call though as those have to ack & merge the bits.
Quoted 6 lines
Quoted 5 lines
net/vmw_vsock/af_vsock.c line 1885
Quoted 3 lines
net/vmw_vsock/af_vsock.c new file +3
-0+case IOCTL_VMCI_SOCKETS_GET_LOCAL_CID : +if (put_user (vmci_get_context_id (), p) !=0 ) + retval = -EFAULT ;What is this?
Quoted 8 lines
A CID, or "context ID" is how we identify a VM. It's also in the address structure (
svm_cid). If you look atvm_sockets.h, you'll see that we have definitions for various endpoints (the host, anonymous and so forth). It's sometimes useful for VMs to be able to query their own ID, for example, to be able to pass it out-of-band via INET to a peer. So we'd like to keep this, although I guess it should be transport-defined, i.e., we should ask the transport for this value.
Yes, should be transport specific (and optional). virtio will (at least initially) support guest <=> host only, so we don't need a context id.
Quoted 8 lines
Quoted 6 lines
net/vmw_vsock/af_vsock.h line 72
Quoted 3 lines
net/vmw_vsock/af_vsock.h new file +3
-0+struct { +/* For DGRAMs. */ +struct vmci_handle dg_handle;Yep, should be a pointer where transports can hook in their private data.
I'm fixing this.
Yes, please, that is needed too to get started with virtio support.
Quoted 5 lines
Quoted 1 line
Where is
recv_dgram?The transport just enqueues
sk_buffsin the socket's buffer, so the core socket code can just pull them off. So there's no explicitrecv_dgram.
Ok.
Quoted 7 lines
Quoted 2 lines
Also why
bind_dgram? I guess binding stream sockets doesn't make sense for the vsock family?Ah, for our transport, there's nothing special involved in binding a STREAM, everything is handled by the core socket code. So I didn't add a transport callback. This is something we can add when it becomes necessary, if that's okay?
Sure. Was just wondering. TCP can bind stream sockets to interfaces to listen -- for example -- on loopback only. I can't see something simliar which makes sense for vsock.
cheers,
Gerd
Re: [PATCH 1/1] VSOCK: Introduce VM Sockets
Hi Gerd,
Quoted 4 lines
From my side the minimum requirement is to have vsock_(un)register_transport calls available, so it is possible to write a virtio transport module without having to patch vsock code to hook it up.
We've done exactly that. It's now split into two separate modules, with the core module offering precisely the calls you've requested. All transport code is now its own module. So now you should be able to add a vsock_transport_virtio module, which can register with the core.
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
net/vmw_vsock/af_vsock.h line 72
Quoted 3 lines
net/vmw_vsock/af_vsock.h new file +3
-0+struct { +/* For DGRAMs. */ +struct vmci_handle dg_handle;Yep, should be a pointer where transports can hook in their private
data.I'm fixing this.
Yes, please, that is needed too to get started with virtio support.
Fixed: it's now a void * in the core socket structure.
I believe it's now at the point where you can start working on the virtio transport, and we'll address API issues as they arise and refine it as necessary. So please take one last look and let us know what you think; hopefully we can make the current merge window :)
Thanks!
- Andy