Page MenuHomeFreeBSD

VMware Virtual Machine Communication Interface (VMCI) kernel module
ClosedPublic

Authored by vdasahar_gmail.com on Feb 9 2018, 10:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 27, 8:41 PM
Unknown Object (File)
Tue, Oct 22, 5:54 PM
Unknown Object (File)
Tue, Oct 22, 5:54 PM
Unknown Object (File)
Tue, Oct 22, 5:54 PM
Unknown Object (File)
Tue, Oct 22, 5:53 PM
Unknown Object (File)
Tue, Oct 22, 5:53 PM
Unknown Object (File)
Tue, Oct 22, 5:53 PM
Unknown Object (File)
Oct 18 2024, 12:42 AM

Details

Summary

In an effort to improve the out-of-the-box experience with FreeBSD kernels for
VMware users, VMware intends to include the Virtual Machine Communication
Interface (VMCI) kernel module in FreeBSD kernel.

VMCI allows virtual machines to communicate with host kernel modules and the
VMware hypervisors. User level applications in a virtual machine can use VMCI
through vSockets (also known as VMCI Sockets and not included in this kernel
module), a socket address family designed to be compatible with UDP and TCP at
the interface level. Today, VMCI and vSockets are 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 vSockets 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.

In a virtual machine, VMCI is exposed as a regular PCI device. The primary
communication mechanisms supported are a point-to-point bidirectional transport
based on a pair of memory-mapped queues, and asynchronous notifications in the
form of datagrams and doorbells. These features are available to kernel level
components such as vSockets through the VMCI kernel API. In addition to
this, the VMCI kernel API provides support for receiving events related to the
state of the VMCI communication channels, and the virtual machine itself.

For additional information about the use of VMCI and in particular vSockets,
please refer to the vSocket Programming Guide available at
https://www.vmware.com/support/developer/vmci-sdk/.

Test Plan

Compiled the driver on amd64 and i386 FreeBSD installations as a kernel module.
Compiled the driver into the kernel on amd64 and i386 FreeBSD installations.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 15706
Build 15734: arc lint + arc unit

Event Timeline

Fix the file permissions to be 644

Remove unnecessary newline with SUBDIR+= in the upper level Makefile at vmxnet3.
Use more SRCS+= to keep the list to below 80 characters.

A few comments on the man page. You can use textproc/igor to check the man page for various common errors.
Thank you very much for working on this kernel module!

share/man/man4/vmci.4
27

No blank lines in man page sources.

29

You need to start every new sentence at a new line after the sentence stop.

39

Another blank line

47

This line is also blank.

In D14289#299768, @bcr wrote:

A few comments on the man page. You can use textproc/igor to check the man page for various common errors.
Thank you very much for working on this kernel module!

Thanks a lot for the tips and review! I've addressed your comments and used igor to proofread the man page.

Fixed formatting errors in man page. Used igor to proofread the document after
the changes.

OK, the man page looks better now.
You should also add an AUTHORS, HISTORY, and maybe SEE ALSO section at the bottom. See the examples here:
https://www.freebsd.org/doc/en_US.ISO8859-1/books/fdp-primer/manpages-sample-structures.html

Thank you @bcr! I've added AUTHORS, HISTORY and SEE ALSO section to the man
page.

Add socket(2) to SEE ALSO section in man page.

Looks good now. OK from the manpages part of the module.

This revision is now accepted and ready to land.Feb 10 2018, 4:07 PM
In D14289#299838, @bcr wrote:

Looks good now. OK from the manpages part of the module.

Thanks a lot Benedict!

This code is long and difficult to keep all in my head....

But it seems fine, modulo the makefile issue. There may be subtle issues, but I see nothing major here.

sys/modules/vmware/vmci/Makefile
8

${SRCTOP}/sys/dev/vmeware/vmci

would be better

Mark, I don't have the bandwidth to shepherd this into the tree, but I know of no reason we can't commit this. The license is good and the code seems complete.

Change path in Makefile

Changing path from "${.CURDIR}/../../../dev/vmware/vmci" to
"${SRCTOP}/sys/dev/vmware/vmci" in ${SRCTOP}/sys/dev/vmeware/vmci

Compiled vmci using command "make vmci" at /sys/dev/vmware as a sanity
check test.

This revision now requires review to proceed.Mar 22 2018, 3:50 AM

@imp Thank you Warner! I have made the change that you suggested.

Looks good to me. I'll get it committed.

This revision is now accepted and ready to land.Mar 23 2018, 11:54 PM
This revision was automatically updated to reflect the committed changes.

Coverity found a number of issues with this commit. It is possible they are false positives:

  • CID 1056844: API usage errors (SWAPPED_ARGUMENTS)

/sys/dev/vmware/vmci/vmci_qpair.c: 400 in vmci_qpair_consume_free_space()
394
395 if (!qpair)
396 return (VMCI_ERROR_INVALID_ARGS);
397
398 vmci_qpair_get_queue_headers(qpair, &produce_q_header,
399 &consume_q_header);

CID 1056844:  API usage errors  (SWAPPED_ARGUMENTS)
The positions of arguments in the call to "vmci_queue_header_free_space" do not match the ordering of the parameters:
  • "consume_q_header" is passed to "produce_q_header"
  • "produce_q_header" is passed to "consume_q_header"

400 result = vmci_queue_header_free_space(consume_q_header, produce_q_header,
401 qpair->consume_q_size);
402
403 return (result);
404 }
405

  • CID 1056845: API usage errors (SWAPPED_ARGUMENTS)

/sys/dev/vmware/vmci/vmci_qpair.c: 320 in vmci_qpair_get_consume_indexes()

  • CID 1056846: API usage errors (SWAPPED_ARGUMENTS)

/sys/dev/vmware/vmci/vmci_qpair.c: 438 in vmci_qpair_produce_buf_ready()

Coverity found a number of issues with this commit. It is possible they are false positives:

  • CID 1056844: API usage errors (SWAPPED_ARGUMENTS)

/sys/dev/vmware/vmci/vmci_qpair.c: 400 in vmci_qpair_consume_free_space()
394
395 if (!qpair)
396 return (VMCI_ERROR_INVALID_ARGS);
397
398 vmci_qpair_get_queue_headers(qpair, &produce_q_header,
399 &consume_q_header);

CID 1056844:  API usage errors  (SWAPPED_ARGUMENTS)
The positions of arguments in the call to "vmci_queue_header_free_space" do not match the ordering of the parameters:
  • "consume_q_header" is passed to "produce_q_header"
  • "produce_q_header" is passed to "consume_q_header"

400 result = vmci_queue_header_free_space(consume_q_header, produce_q_header,
401 qpair->consume_q_size);
402
403 return (result);
404 }
405

  • CID 1056845: API usage errors (SWAPPED_ARGUMENTS)

/sys/dev/vmware/vmci/vmci_qpair.c: 320 in vmci_qpair_get_consume_indexes()

  • CID 1056846: API usage errors (SWAPPED_ARGUMENTS)

/sys/dev/vmware/vmci/vmci_qpair.c: 438 in vmci_qpair_produce_buf_ready()

@allanjude Thanks a lot for reporting the coverity failures. I can confirm that these 3 instances are false positives. What would be your recommendation on getting coverity to not fire on these? Also, are there more or only these 3?
/sys/dev/vmware/vmci/vmci_qpair.c: 400 in vmci_qpair_consume_free_space()
/sys/dev/vmware/vmci/vmci_qpair.c: 320 in vmci_qpair_get_consume_indexes()
/sys/dev/vmware/vmci/vmci_qpair.c: 438 in vmci_qpair_produce_buf_ready()