Page MenuHomeFreeBSD

VMware Virtual Machine Communication Interface (VMCI) kernel module
ClosedPublic

Authored by vdasahar_gmail.com on Feb 9 2018, 10:27 PM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

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.

bcr added a subscriber: bcr.Feb 10 2018, 11:44 AM

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
26 ↗(On Diff #39118)

No blank lines in man page sources.

28 ↗(On Diff #39118)

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

38 ↗(On Diff #39118)

Another blank line

46 ↗(On Diff #39118)

This line is also blank.

vdasahar_gmail.com marked 4 inline comments as done.Feb 10 2018, 1:18 PM
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.

bcr added a comment.Feb 10 2018, 2:02 PM

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.

bcr accepted this revision.Feb 10 2018, 4:07 PM

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!

Ping. Gentle reminder.

imp added a comment.Mar 22 2018, 12:41 AM

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
7 ↗(On Diff #39141)

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

would be better

imp accepted this revision.Mar 22 2018, 12:42 AM

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
vdasahar_gmail.com marked an inline comment as done.Mar 22 2018, 3:54 AM

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

mp accepted this revision.Mar 23 2018, 11:54 PM

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()