vsock.7: document VSOCK socket address family
Subsystems (3)
PATCH 1/1 vsock.7: document VSOCK socket address family
The AF_VSOCK address family has been available since Linux 3.9 without a corresponding man page.
This patch adds vsock.7 and describes its use along the same lines as existing ip.7, unix.7, and netlink.7 man pages.
--- man7/vsock.7 | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 man7/vsock.7
man7/vsock.7 new file +175 -0
@@ -0,0 +1,175 @@ +.TH VSOCK 7 2017-11-30 "Linux" "Linux Programmer's Manual" +.SH NAME +vsock \- Linux VSOCK address family +.SH SYNOPSIS +.B #include <sys/socket.h> +.br +.B #include <linux/vm_sockets.h> +.PP +.IB stream_socket " = socket(AF_VSOCK, SOCK_STREAM, 0);" +.br +.IB datagram_socket " = socket(AF_VSOCK, SOCK_DGRAM, 0);" +.SH DESCRIPTION +The VSOCK address family facilitates communication between virtual machines and +the host they are running on. This address family is used by guest agents and +hypervisor services that need a communications channel that is independent of +virtual machine network configuration. +.PP +Valid socket types are +.B SOCK_STREAM +and +.B SOCK_DGRAM . +.B SOCK_STREAM +provides connection-oriented byte streams with guaranteed, in-order delivery. +.B SOCK_DGRAM +provides a connectionless datagram packet service. Availability of these +socket types is dependent on the underlying hypervisor. +.PP +A new socket is created with +.PP + socket(AF_VSOCK, socket_type, 0); +.PP +When a process wants to establish a connection it calls +.BR connect (2) +with a given destination socket address. The socket is automatically bound to +a free port if unbound. +.PP +A process can listen for incoming connections by first binding to a socket address using +.BR bind (2) +and then calling +.BR listen (2). +.PP +Data is transferred using the usual +.BR send (2) +and +.BR recv (2) +family of socket system calls. +.SS Address format +A socket address is defined as a combination of a 32-bit Context Identifier (CID) and a 32-bit port number. The CID identifies the source or destination, which is either a virtual machine or the host. The port number differentiates between multiple services running on a single machine. +.PP +.in +4n +.EX +struct sockaddr_vm { + sa_family_t svm_family; /* address family: AF_VSOCK */ + unsigned short svm_reserved1; + unsigned int svm_port; /* port in native byte order */ + unsigned int svm_cid; /* address in native byte order */ +}; +.EE +.in +.PP +.I svm_family +is always set to +.BR AF_VSOCK . +.I svm_reserved1 +is always set to 0. +.I svm_port +contains the port in native byte order. +The port numbers below 1024 are called +.IR "privileged ports" . +Only a process with +.B CAP_NET_BIND_SERVER +capability may +.BR bind (2) +to these port numbers. +.PP +There are several special addresses: +.B VMADDR_CID_ANY +(-1U) +means any address for binding; +.B VMADDR_CID_HYPERVISOR +(0) and +.B VMADDR_CID_RESERVED +(1) are unused addresses; +.B VMADDR_CID_HOST +(2) +is the well-known address of the host. +.PP +The special constant +.B VMADDR_PORT_ANY +(-1U) +means any port number for binding. +.SS Live migration +Sockets are affected by live migration of virtual machines. Connected +.B SOCK_STREAM +sockets become disconnected when the virtual machine migrates to a new host. +Applications must reconnect when this happens. +.PP +The local CID may change across live migration if the old CID is not available +on the new host. Bound sockets are automatically updated to the new CID. +.SS Ioctls +.TP +.B IOCTL_VM_SOCKETS_GET_LOCAL_CID +Get the CID of the local machine. The argument is a pointer to an unsigned int. +.IP +.in +4n +.EX +.IB error " = ioctl(" socket ", " IOCTL_VM_SOCKETS_GET_LOCAL_CID ", " &cid ");" +.EE +.in +.IP +Consider using +.B VMADDR_CID_ANY +when binding instead of getting the local CID with +.B IOCTL_VM_SOCKETS_GET_LOCAL_CID . +.SH ERRORS +.TP +.B EACCES +Unable to bind to a privileged port without the +.B CAP_NET_BIND_SERVICE +capability. +.TP +.B EINVAL +Invalid parameters. This includes: +attempting to bind a socket that is already bound, providing an invalid struct +.B sockaddr_vm , +and other input validation errors. +.TP +.B EOPNOTSUPP +Operation not supported. This includes: +the +.B MSG_OOB +flag that is not implemented for +.B sendmsg (2) +and +.B MSG_PEEK +for +.B recvmsg (2). +.TP +.B EADDRINUSE +Unable to bind to a port that is already in use. +.TP +.B EADDRNOTAVAIL +Unable to find a free port for binding or unable to bind to a non-local CID. +.TP +.B ENOTCONN +Unable to perform operation on an unconnected socket. +.TP +.B ENOPROTOOPT +Invalid socket option in +.B setsockopt (2) +or +.B getsockopt (2). +.TP +.B EPROTONOSUPPORT +Invalid socket protocol number. Protocol should always be 0. +.TP +.B ESOCKTNOSUPPORT +Unsupported socket type in +.B socket (2). +Only +.B SOCK_STREAM +and +.B SOCK_DGRAM +are valid. +.SH VERSIONS +Support for VMware has been available since Linux 3.9. KVM (virtio) is +supported since Linux 4.8. Hyper-V is supported since 4.14. +.SH SEE ALSO +.BR socket (2), +.BR bind (2), +.BR connect (2), +.BR listen (2), +.BR send (2), +.BR recv (2), +.BR capabilities (7)
Signature · 1 line
2.14.3
A message that is not in the archive (sent off-list or not yet received): 20171130112153.13885-1-stefanha-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
DQo+IE9uIE5vdiAzMCwgMjAxNywgYXQgMTI6MjEgUE0sIFN0ZWZhbiBIYWpub2N6aSA8c3RlZmFu aGFAcmVkaGF0LmNvbT4gd3JvdGU6DQo+IA0KPiBUaGUgQUZfVlNPQ0sgYWRkcmVzcyBmYW1pbHkg aGFzIGJlZW4gYXZhaWxhYmxlIHNpbmNlIExpbnV4IDMuOSB3aXRob3V0IGENCj4gY29ycmVzcG9u ZGluZyBtYW4gcGFnZS4NCj4gDQo+IFRoaXMgcGF0Y2ggYWRkcyB2c29jay43IGFuZCBkZXNjcmli ZXMgaXRzIHVzZSBhbG9uZyB0aGUgc2FtZSBsaW5lcyBhcw0KPiBleGlzdGluZyBpcC43LCB1bml4 LjcsIGFuZCBuZXRsaW5rLjcgbWFuIHBhZ2VzLg0KPiANCj4gQ0M6IEpvcmdlbiBIYW5zZW4gPGpo YW5zZW5Adm13YXJlLmNvbT4NCj4gQ0M6IERleHVhbiBDdWkgPGRlY3VpQG1pY3Jvc29mdC5jb20+ DQo+IFNpZ25lZC1vZmYtYnk6IFN0ZWZhbiBIYWpub2N6aSA8c3RlZmFuaGFAcmVkaGF0LmNvbT4N Cj4gLS0tDQo+IG1hbjcvdnNvY2suNyB8IDE3NSArKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrKysr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iArLkIgc29ja2V0ICgyKS4NCj4gK09ubHkNCj4gKy5CIFNPQ0tfU1RSRUFNDQo+ ICthbmQNCj4gKy5CIFNPQ0tfREdSQU0NCj4gK2FyZSB2YWxpZC4NCj4gKy5TSCBWRVJTSU9OUw0K PiArU3VwcG9ydCBmb3IgVk13YXJlIGhhcyBiZWVuIGF2YWlsYWJsZSBzaW5jZSBMaW51eCAzLjku ICBLVk0gKHZpcnRpbykgaXMNCg0KVk13YXJlIChWTUNJKSBmb3IgY2xhcml0eS4NCg0KPiArc3Vw cG9ydGVkIHNpbmNlIExpbnV4IDQuOC4gIEh5cGVyLVYgaXMgc3VwcG9ydGVkIHNpbmNlIDQuMTQu DQo+ICsuU0ggU0VFIEFMU08NCj4gKy5CUiBzb2NrZXQgKDIpLA0KPiArLkJSIGJpbmQgKDIpLA0K PiArLkJSIGNvbm5lY3QgKDIpLA0KPiArLkJSIGxpc3RlbiAoMiksDQo+ICsuQlIgc2VuZCAoMiks DQo+ICsuQlIgcmVjdiAoMiksDQo+ICsuQlIgY2FwYWJpbGl0aWVzICg3KQ0KPiAtLSANCj4gMi4x NC4zDQo+IA0KDQpBcGFydCBmcm9tIHRoZSBuaXRzLCB0aGlzIGxvb2tzIGdyZWF0Lg0KDQpUaGFu a3MsDQpKb3JnZW4NCg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 33989114-7BC7-455A-BE36-9EEC989DBDF1-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org
Quoted 1 line · Jorgen S. Hansen
Quoted 1 line · Stefan Hajnoczi
Thanks for the quick review!
I forgot to ask you: Is SOCK_DGRAM reliable and in-order over VMCI?
Quoted 7 lines
man7/vsock.7 line 21
Quoted 5 lines
+.PP
man7/vsock.7 new file +4
-0+Valid socket types are +.B SOCK_STREAM +and +.B SOCK_DGRAM .The space here results in a space between
SOCK_DGRAMand the “.” in the formatted text. Is that intentional?
I haven't figured out the groff syntax to avoid the space :(. Any ideas?
Quoted 8 lines
man7/vsock.7 line 80
Quoted 6 lines
+.PP
man7/vsock.7 new file +5
-0+There are several special addresses: +.B VMADDR_CID_ANY +(-1U) +means any address for binding; +.B VMADDR_CID_HYPERVISORWe use
VMADDR_CID_HYPERVISORfor communicating with services in the hypervisor, so you could describe this as “an address reserved for services built into the hypervisor”.
Will fix.
Quoted 4 lines
Quoted 2 lines
+.SH VERSIONS
+Support for VMware has been available since Linux 3.9. KVM (virtio) isVMware (VMCI) for clarity.
Will fix.
Quoted 1 line
Apart from the nits, this looks great.
Please let me know if there are any other topics that we should cover in the man page.
A message that is not in the archive (sent off-list or not yet received): 20171201130901.GA12803-lxVrvc10SDRcolVlb+j0YCZi+YwRKgec@public.gmane.org
DQo+IE9uIERlYyAxLCAyMDE3LCBhdCAyOjA5IFBNLCBTdGVmYW4gSGFqbm9jemkgPHN0ZWZhbmhh QHJlZGhhdC5jb20+IHdyb3RlOg0KPiANCj4gT24gVGh1LCBOb3YgMzAsIDIwMTcgYXQgMDE6MjE6 MjZQTSArMDAwMCwgSm9yZ2VuIFMuIEhhbnNlbiB3cm90ZToNCj4+PiBPbiBOb3YgMzAsIDIwMTcs IGF0IDEyOjIxIFBNLCBTdGVmYW4gSGFqbm9jemkgPHN0ZWZhbmhhQHJlZGhhdC5jb20+IHdyb3Rl Og0KPiANCj4gVGhhbmtzIGZvciB0aGUgcXVpY2sgcmV2aWV3IQ0KPiANCj4gSSBmb3Jnb3QgdG8g YXNrIHlvdTogSXMgU09DS19ER1JBTSByZWxpYWJsZSBhbmQgaW4tb3JkZXIgb3ZlciBWTUNJPw0K DQpObywgdGhhdCBpc27igJl0IGd1YXJhbnRlZWQuDQoNCj4gDQo+Pj4gKy5QUA0KPj4+ICtWYWxp ZCBzb2NrZXQgdHlwZXMgYXJlDQo+Pj4gKy5CIFNPQ0tfU1RSRUFNDQo+Pj4gK2FuZA0KPj4+ICsu QiBTT0NLX0RHUkFNIC4NCj4+IA0KPj4gVGhlIHNwYWNlIGhlcmUgcmVzdWx0cyBpbiBhIHNwYWNl IGJldHdlZW4gU09DS19ER1JBTSBhbmQgdGhlIOKAnC7igJ0gaW4gdGhlIGZvcm1hdHRlZCB0ZXh0 LiBJcyB0aGF0IGludGVudGlvbmFsPw0KPiANCj4gSSBoYXZlbid0IGZpZ3VyZWQgb3V0IHRoZSBn cm9mZiBzeW50YXggdG8gYXZvaWQgdGhlIHNwYWNlIDooLiAgQW55DQo+IGlkZWFzPw0KDQpMb29r cyBsaWtlIG1hbiA3IHVuaXggaGFzIGEgZmV3IGV4YW1wbGVzIHdpdGggYm9sZCBhbmQg4oCcLOKA nSAtIG1heWJlIGxvb2sgYXQgdGhlIHNvdXJjZSBmb3IgdGhhdC4NCg0KPiANCj4+IEFwYXJ0IGZy b20gdGhlIG5pdHMsIHRoaXMgbG9va3MgZ3JlYXQuDQo+IA0KPiBQbGVhc2UgbGV0IG1lIGtub3cg aWYgdGhlcmUgYXJlIGFueSBvdGhlciB0b3BpY3MgdGhhdCB3ZSBzaG91bGQgY292ZXIgaW4NCj4g dGhlIG1hbiBwYWdlLg0KDQpTdXJlLCBJ4oCZbGwgZ2V0IGJhY2sgdG8geW91IHNvb24sIGlmIEkg dGhpbmsgb2YgYW55dGhpbmcuDQoNClRoYW5rcywNCkpvcmdlbg==
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 15 lines · Stefan Hajnoczi
Quoted 1 line · Jorgen S. Hansen
Quoted 1 line · Stefan Hajnoczi
Thanks for the quick review!
I forgot to ask you: Is
SOCK_DGRAMreliable and in-order over VMCI?Quoted 7 lines
man7/vsock.7 line 21
Quoted 5 lines
+.PP
man7/vsock.7 new file +4
-0+Valid socket types are +.B SOCK_STREAM +and +.B SOCK_DGRAM .The space here results in a space between
SOCK_DGRAMand the “.” in the formatted text. Is that intentional?
Quoted 2 lines
I haven't figured out the groff syntax to avoid the space :(. Any ideas?
What you want is the .BR macro.
.BR SOCK_DGRAM .
The man macro package defines six "two-font" macros for switching between roman, bold, and italic faces without intervening space.
See man(7) and groff_man(7).
Signature · 2 lines
Regards, Branden
A message that is not in the archive (sent off-list or not yet received): 20171201145702.saqodo5qqh4ucbaq-Z0uaYDh/[email protected]
Quoted 19 lines · G. Branden Robinson
Quoted 15 lines · Stefan Hajnoczi
Quoted 1 line · Jorgen S. Hansen
Quoted 1 line · Stefan Hajnoczi
Thanks for the quick review!
I forgot to ask you: Is
SOCK_DGRAMreliable and in-order over VMCI?Quoted 7 lines
Review
Quoted 5 lines
+.PP
(quoted diff) +4
-0+Valid socket types are +.B SOCK_STREAM +and +.B SOCK_DGRAM .The space here results in a space between
SOCK_DGRAMand the “.” in the formatted text. Is that intentional?Quoted 2 lines
I haven't figured out the groff syntax to avoid the space :(. Any ideas?
Quoted 8 lines
What you want is the .BR macro.
.BR
SOCK_DGRAM.The man macro package defines six "two-font" macros for switching between roman, bold, and italic faces without intervening space.
See man(7) and
groff_man(7).
Excellent, thank you!
Stefan
Stefan,
I've just now noted that your page came with no license. What license do you want to use Please see
https://www.kernel.org/doc/man-pages/licenses.html
Thanks,
Michael
Quoted 202 lines · Stefan Hajnoczi
The
AF_VSOCKaddress family has been available since Linux 3.9 without a corresponding man page.This patch adds vsock.7 and describes its use along the same lines as existing ip.7, unix.7, and netlink.7 man pages.
CC Jorgen Hansen <[email protected]>CC Dexuan Cui <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- man7/vsock.7 | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 man7/vsock.7man7/vsock.7 new file +175
-1@@ -0,0 +1,175 @@ +.TH VSOCK 7 2017-11-30 "Linux" "Linux Programmer's Manual" +.SH NAME +vsock \- Linux VSOCK address family +.SH SYNOPSIS +.B #include <sys/socket.h> +.br +.B #include <linux/vm_sockets.h> +.PP +.IB stream_socket " = socket(AF_VSOCK, SOCK_STREAM, 0);" +.br +.IB datagram_socket " = socket(AF_VSOCK, SOCK_DGRAM, 0);" +.SH DESCRIPTION +The VSOCK address family facilitates communication between virtual machines and +the host they are running on. This address family is used by guest agents and +hypervisor services that need a communications channel that is independent of +virtual machine network configuration. +.PP +Valid socket types are +.B SOCK_STREAM +and +.B SOCK_DGRAM . +.B SOCK_STREAM +provides connection-oriented byte streams with guaranteed, in-order delivery. +.B SOCK_DGRAM +provides a connectionless datagram packet service. Availability of these +socket types is dependent on the underlying hypervisor. +.PP +A new socket is created with +.PP + socket(AF_VSOCK, socket_type, 0); +.PP +When a process wants to establish a connection it calls +.BR connect (2) +with a given destination socket address. The socket is automatically bound to +a free port if unbound. +.PP +A process can listen for incoming connections by first binding to a socket address using +.BR bind (2) +and then calling +.BR listen (2). +.PP +Data is transferred using the usual +.BR send (2) +and +.BR recv (2) +family of socket system calls. +.SS Address format +A socket address is defined as a combination of a 32-bit Context Identifier (CID) and a 32-bit port number. The CID identifies the source or destination, which is either a virtual machine or the host. The port number differentiates between multiple services running on a single machine. +.PP +.in +4n +.EX +struct sockaddr_vm { + sa_family_t svm_family; /* address family: AF_VSOCK */ + unsigned short svm_reserved1; + unsigned int svm_port; /* port in native byte order */ + unsigned int svm_cid; /* address in native byte order */ +}; +.EE +.in +.PP +.I svm_family +is always set to +.BR AF_VSOCK . +.I svm_reserved1 +is always set to 0. +.I svm_port +contains the port in native byte order. +The port numbers below 1024 are called +.IR "privileged ports" . +Only a process with +.B CAP_NET_BIND_SERVER +capability may +.BR bind (2) +to these port numbers. +.PP +There are several special addresses: +.B VMADDR_CID_ANY +(-1U) +means any address for binding; +.B VMADDR_CID_HYPERVISOR +(0) and +.B VMADDR_CID_RESERVED +(1) are unused addresses; +.B VMADDR_CID_HOST +(2) +is the well-known address of the host. +.PP +The special constant +.B VMADDR_PORT_ANY +(-1U) +means any port number for binding. +.SS Live migration +Sockets are affected by live migration of virtual machines. Connected +.B SOCK_STREAM +sockets become disconnected when the virtual machine migrates to a new host. +Applications must reconnect when this happens. +.PP +The local CID may change across live migration if the old CID is not available +on the new host. Bound sockets are automatically updated to the new CID. +.SS Ioctls +.TP +.B IOCTL_VM_SOCKETS_GET_LOCAL_CID +Get the CID of the local machine. The argument is a pointer to an unsigned int. +.IP +.in +4n +.EX +.IB error " = ioctl(" socket ", " IOCTL_VM_SOCKETS_GET_LOCAL_CID ", " &cid ");" +.EE +.in +.IP +Consider using +.B VMADDR_CID_ANY +when binding instead of getting the local CID with +.B IOCTL_VM_SOCKETS_GET_LOCAL_CID . +.SH ERRORS +.TP +.B EACCES +Unable to bind to a privileged port without the +.B CAP_NET_BIND_SERVICE +capability. +.TP +.B EINVAL +Invalid parameters. This includes: +attempting to bind a socket that is already bound, providing an invalid struct +.B sockaddr_vm , +and other input validation errors. +.TP +.B EOPNOTSUPP +Operation not supported. This includes: +the +.B MSG_OOB +flag that is not implemented for +.B sendmsg (2) +and +.B MSG_PEEK +for +.B recvmsg (2). +.TP +.B EADDRINUSE +Unable to bind to a port that is already in use. +.TP +.B EADDRNOTAVAIL +Unable to find a free port for binding or unable to bind to a non-local CID. +.TP +.B ENOTCONN +Unable to perform operation on an unconnected socket. +.TP +.B ENOPROTOOPT +Invalid socket option in +.B setsockopt (2) +or +.B getsockopt (2). +.TP +.B EPROTONOSUPPORT +Invalid socket protocol number. Protocol should always be 0. +.TP +.B ESOCKTNOSUPPORT +Unsupported socket type in +.B socket (2). +Only +.B SOCK_STREAM +and +.B SOCK_DGRAM +are valid. +.SH VERSIONS +Support for VMware has been available since Linux 3.9. KVM (virtio) is +supported since Linux 4.8. Hyper-V is supported since 4.14. +.SH SEE ALSO +.BR socket (2), +.BR bind (2), +.BR connect (2), +.BR listen (2), +.BR send (2), +.BR recv (2), +.BR capabilities (7) --2.14.3
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAKgNAkj=SvKSgg+hp3MXBpQF9PqJLGrEmiJuxJb3b-N=NfFYSQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Hi Stefan,
Ping on the below please, since it either blocks the man-pages release I'd currently like to make, or I must remove the vsock.7 page for this release.
Thanks,
Michael
Quoted 221 lines · Michael Kerrisk (man-pages)
Stefan,
I've just now noted that your page came with no license. What license do you want to use Please see
https://www.kernel.org/doc/man-pages/licenses.htmlThanks,
Michael
Quoted 198 lines · Stefan Hajnoczi
The
AF_VSOCKaddress family has been available since Linux 3.9 without a corresponding man page.This patch adds vsock.7 and describes its use along the same lines as existing ip.7, unix.7, and netlink.7 man pages.
CC Jorgen Hansen <[email protected]>CC Dexuan Cui <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- man7/vsock.7 | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 man7/vsock.7man7/vsock.7 new file +175
-1@@ -0,0 +1,175 @@ +.TH VSOCK 7 2017-11-30 "Linux" "Linux Programmer's Manual" +.SH NAME +vsock \- Linux VSOCK address family +.SH SYNOPSIS +.B #include <sys/socket.h> +.br +.B #include <linux/vm_sockets.h> +.PP +.IB stream_socket " = socket(AF_VSOCK, SOCK_STREAM, 0);" +.br +.IB datagram_socket " = socket(AF_VSOCK, SOCK_DGRAM, 0);" +.SH DESCRIPTION +The VSOCK address family facilitates communication between virtual machines and +the host they are running on. This address family is used by guest agents and +hypervisor services that need a communications channel that is independent of +virtual machine network configuration. +.PP +Valid socket types are +.B SOCK_STREAM +and +.B SOCK_DGRAM . +.B SOCK_STREAM +provides connection-oriented byte streams with guaranteed, in-order delivery. +.B SOCK_DGRAM +provides a connectionless datagram packet service. Availability of these +socket types is dependent on the underlying hypervisor. +.PP +A new socket is created with +.PP + socket(AF_VSOCK, socket_type, 0); +.PP +When a process wants to establish a connection it calls +.BR connect (2) +with a given destination socket address. The socket is automatically bound to +a free port if unbound. +.PP +A process can listen for incoming connections by first binding to a socket address using +.BR bind (2) +and then calling +.BR listen (2). +.PP +Data is transferred using the usual +.BR send (2) +and +.BR recv (2) +family of socket system calls. +.SS Address format +A socket address is defined as a combination of a 32-bit Context Identifier (CID) and a 32-bit port number. The CID identifies the source or destination, which is either a virtual machine or the host. The port number differentiates between multiple services running on a single machine. +.PP +.in +4n +.EX +struct sockaddr_vm { + sa_family_t svm_family; /* address family: AF_VSOCK */ + unsigned short svm_reserved1; + unsigned int svm_port; /* port in native byte order */ + unsigned int svm_cid; /* address in native byte order */ +}; +.EE +.in +.PP +.I svm_family +is always set to +.BR AF_VSOCK . +.I svm_reserved1 +is always set to 0. +.I svm_port +contains the port in native byte order. +The port numbers below 1024 are called +.IR "privileged ports" . +Only a process with +.B CAP_NET_BIND_SERVER +capability may +.BR bind (2) +to these port numbers. +.PP +There are several special addresses: +.B VMADDR_CID_ANY +(-1U) +means any address for binding; +.B VMADDR_CID_HYPERVISOR +(0) and +.B VMADDR_CID_RESERVED +(1) are unused addresses; +.B VMADDR_CID_HOST +(2) +is the well-known address of the host. +.PP +The special constant +.B VMADDR_PORT_ANY +(-1U) +means any port number for binding. +.SS Live migration +Sockets are affected by live migration of virtual machines. Connected +.B SOCK_STREAM +sockets become disconnected when the virtual machine migrates to a new host. +Applications must reconnect when this happens. +.PP +The local CID may change across live migration if the old CID is not available +on the new host. Bound sockets are automatically updated to the new CID. +.SS Ioctls +.TP +.B IOCTL_VM_SOCKETS_GET_LOCAL_CID +Get the CID of the local machine. The argument is a pointer to an unsigned int. +.IP +.in +4n +.EX +.IB error " = ioctl(" socket ", " IOCTL_VM_SOCKETS_GET_LOCAL_CID ", " &cid ");" +.EE +.in +.IP +Consider using +.B VMADDR_CID_ANY +when binding instead of getting the local CID with +.B IOCTL_VM_SOCKETS_GET_LOCAL_CID . +.SH ERRORS +.TP +.B EACCES +Unable to bind to a privileged port without the +.B CAP_NET_BIND_SERVICE +capability. +.TP +.B EINVAL +Invalid parameters. This includes: +attempting to bind a socket that is already bound, providing an invalid struct +.B sockaddr_vm , +and other input validation errors. +.TP +.B EOPNOTSUPP +Operation not supported. This includes: +the +.B MSG_OOB +flag that is not implemented for +.B sendmsg (2) +and +.B MSG_PEEK +for +.B recvmsg (2). +.TP +.B EADDRINUSE +Unable to bind to a port that is already in use. +.TP +.B EADDRNOTAVAIL +Unable to find a free port for binding or unable to bind to a non-local CID. +.TP +.B ENOTCONN +Unable to perform operation on an unconnected socket. +.TP +.B ENOPROTOOPT +Invalid socket option in +.B setsockopt (2) +or +.B getsockopt (2). +.TP +.B EPROTONOSUPPORT +Invalid socket protocol number. Protocol should always be 0. +.TP +.B ESOCKTNOSUPPORT +Unsupported socket type in +.B socket (2). +Only +.B SOCK_STREAM +and +.B SOCK_DGRAM +are valid. +.SH VERSIONS +Support for VMware has been available since Linux 3.9. KVM (virtio) is +supported since Linux 4.8. Hyper-V is supported since 4.14. +.SH SEE ALSO +.BR socket (2), +.BR bind (2), +.BR connect (2), +.BR listen (2), +.BR send (2), +.BR recv (2), +.BR capabilities (7) --2.14.3
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Michael Kerrisk (man-pages)
Hi Stefan,
Ping on the below please, since it either blocks the man-pages release I'd currently like to make, or I must remove the vsock.7 page for this release.
Sorry for the delay. The verbatim license is fine.
Stefan
A message that is not in the archive (sent off-list or not yet received): 20180201180349.GJ5578-lxVrvc10SDRcolVlb+j0YCZi+YwRKgec@public.gmane.org
Quoted 8 lines · Stefan Hajnoczi
Quoted 5 lines · Michael Kerrisk (man-pages)
Hi Stefan,
Ping on the below please, since it either blocks the man-pages release I'd currently like to make, or I must remove the vsock.7 page for this release.
Sorry for the delay. The verbatim license is fine.
Thanks, Stefan!
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html