Add Virtual Box vboxguest and vboxsf guest drivers to the mainline kernel
v2 cover Add Virtual Box vboxguest and vboxsf guest drivers to the mainline kernel
Hi All,
Here is a 2nd RFC version of my cleaned up version of the VirtualBox vboxguest and vboxsf guest drivers.
This time my cleanup is complete and the patches are ready for a FULL review now.
This is still an RFC because VirtualBox upstream is considering making some final ioctl ABI changes for the vboxguest chardev now that they still can. As soon as I get the go ahead from them that the ioctl ABI is stable I will send a non RFC version.
Here is (part of) the RFC v1 cover-letter which is still relevant:
I've removed all depenencies on vbox's OO-independent runtime and the runtime itself, reducing the vboxguest driver from 100000+ lines of code to aprox. 6500 and the vboxsf driver from 60000 lines to 4500. This reduces the non debug vboxguest.ko size from 450kB to less then 100 kB. I've also cleaned up various other warts such as doing hardware init in module_init rather then in a pci_probe callback.
The vboxguest driver introduces a new userspace API + ABI in the form of ioctls on a character device. VirtualBox upstream not willing to commit to keeping this ABI stable was one of the things which has kept this driver driver out of mainline sofar. I've been talking to VirtualBox upstream about mainlining the guest drivers and VirtualBox upstream has agreed to consider the userspace ABI stable and only extend it in a backwards compatible manner.
Regards,
Hans
RFC v2 1/2 virt: Add vboxguest driver for Virtual Box Guest integration
This commit adds a driver for the Virtual Box Guest PCI device used in Virtual Box virtual machines. Enabling this driver will add support for Virtual Box Guest integration features such as copy-and-paste, seamless mode and OpenGL pass-through.
This driver also offers vboxguest IPC functionality which is needed for the vboxfs driver which offers folder sharing support.
--- drivers/virt/Kconfig | 1 + drivers/virt/Makefile | 1 + drivers/virt/vboxguest/Kconfig | 16 + drivers/virt/vboxguest/Makefile | 3 + drivers/virt/vboxguest/vboxguest_core.c | 1580 +++++++++++++++++++++++++ drivers/virt/vboxguest/vboxguest_core.h | 194 ++++ drivers/virt/vboxguest/vboxguest_linux.c | 478 ++++++++ drivers/virt/vboxguest/vboxguest_utils.c | 1094 +++++++++++++++++ drivers/virt/vboxguest/vboxguest_version.h | 18 + include/linux/vbox_utils.h | 107 ++ include/linux/vbox_vmmdev.h | 123 ++ include/uapi/linux/vbox_err.h | 178 +++ include/uapi/linux/vbox_ostypes.h | 153 +++ include/uapi/linux/vbox_vmmdev.h | 1745 ++++++++++++++++++++++++++++ include/uapi/linux/vboxguest.h | 359 ++++++ 15 files changed, 6050 insertions(+) create mode 100644 drivers/virt/vboxguest/Kconfig create mode 100644 drivers/virt/vboxguest/Makefile create mode 100644 drivers/virt/vboxguest/vboxguest_core.c create mode 100644 drivers/virt/vboxguest/vboxguest_core.h create mode 100644 drivers/virt/vboxguest/vboxguest_linux.c create mode 100644 drivers/virt/vboxguest/vboxguest_utils.c create mode 100644 drivers/virt/vboxguest/vboxguest_version.h create mode 100644 include/linux/vbox_utils.h create mode 100644 include/linux/vbox_vmmdev.h create mode 100644 include/uapi/linux/vbox_err.h create mode 100644 include/uapi/linux/vbox_ostypes.h create mode 100644 include/uapi/linux/vbox_vmmdev.h create mode 100644 include/uapi/linux/vboxguest.h
drivers/virt/Kconfig +1 -0
@@ -30,4 +30,5 @@ config FSL_HV_MANAGER 4) A kernel interface for receiving callbacks when a managed partition shuts down. +source "drivers/virt/vboxguest/Kconfig" endif
drivers/virt/Makefile +1 -0
@@ -3,3 +3,4 @@ # obj-$(CONFIG_FSL_HV_MANAGER) += fsl_hypervisor.o +obj-y += vboxguest/
drivers/virt/vboxguest/Kconfig new file +16 -0
@@ -0,0 +1,16 @@ +config VBOXGUEST + tristate "Virtual Box Guest integration support" + depends on X86 && PCI && INPUT + help + This is a driver for the Virtual Box Guest PCI device used in + Virtual Box virtual machines. Enabling this driver will add + support for Virtual Box Guest integration features such as + copy-and-paste, seamless mode and OpenGL pass-through. + + This driver also offers vboxguest IPC functionality which is needed + for the vboxfs driver which offers folder sharing support. + + Although it is possible to build this module in, it is advised + to build this driver as a module, so that it can be updated + independently of the kernel. Select M to build this driver as a + module.
drivers/virt/vboxguest/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +vboxguest-y := vboxguest_linux.o vboxguest_core.o vboxguest_utils.o + +obj-$(CONFIG_VBOXGUEST) += vboxguest.o
drivers/virt/vboxguest/vboxguest_core.c new file +1580 -0
1,580 lines not on this page · raw message
drivers/virt/vboxguest/vboxguest_core.h new file +194 -0
194 lines not on this page · raw message
drivers/virt/vboxguest/vboxguest_linux.c new file +478 -0
478 lines not on this page · raw message
drivers/virt/vboxguest/vboxguest_utils.c new file +1094 -0
720 lines not on this page · raw message
drivers/virt/vboxguest/vboxguest_version.h new file +18 -0
Lines of this file are not shown. View the raw message.
include/linux/vbox_utils.h new file +107 -0
107 lines not on this page · raw message
include/linux/vbox_vmmdev.h new file +123 -0
123 lines not on this page · raw message
include/uapi/linux/vbox_err.h new file +178 -0
178 lines not on this page · raw message
include/uapi/linux/vbox_ostypes.h new file +153 -0
153 lines not on this page · raw message
include/uapi/linux/vbox_vmmdev.h new file +1745 -0
1,745 lines not on this page · raw message
include/uapi/linux/vboxguest.h new file +359 -0
359 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.13.4
Part of the diff is not shown here. View the raw message.
Re: [RFC v2 1/2] virt: Add vboxguest driver for Virtual Box Guest integration
Please kill all the weird typedefs and camel case first, and then we can do a real review.
Re: [RFC v2 1/2] virt: Add vboxguest driver for Virtual Box Guest integration
Hi,
Quoted 2 lines · Christoph Hellwig
Please kill all the weird typedefs and camel case first, and then we can do a real review.
I've already removed all the typedefs and camel-case outside of include/uapi/linux
The ones in include/uapi/linux are preserved to preserve API compatibility with the existing VirtualBox userspace tools.
I was planning to mention this in the coverletter, but I forgot, sorry.
Regards,
Hans
Re: [RFC v2 1/2] virt: Add vboxguest driver for Virtual Box Guest integration
Quoted 5 lines · Hans de Goede
I've already removed all the typedefs and camel-case outside of
include/uapi/linuxThe ones in
include/uapi/linuxare preserved to preserve API compatibility with the existing VirtualBox userspace tools.
When merging new drivers we need to fix up the user abis anyway, we don't want to be stuck with mistakes from the past. And the APIs look pretty bad, so there will be a lot work required after this basic cleanup anyway.
Re: [RFC v2 1/2] virt: Add vboxguest driver for Virtual Box Guest integration
Hi,
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Hans de Goede
I've already removed all the typedefs and camel-case outside of
include/uapi/linuxThe ones in
include/uapi/linuxare preserved to preserve API compatibility with the existing VirtualBox userspace tools.When merging new drivers we need to fix up the user abis anyway, we don't want to be stuck with mistakes from the past. And the APIs look pretty bad, so there will be a lot work required after this basic cleanup anyway.
I'm afraid that the userspace API is more or less a take it or leave it kinda deal, we can do small cleanups, but an entire re-design is out of the question. The vboxguest code has a long (too long) out of tree history and the same ioctl interface is used by VirtualBox upstream on Windows, Mac OS X, the BSDs and Solaris, so we cannot just go and break it to out hart's content.
Regards,
Hans
Re: [RFC v2 1/2] virt: Add vboxguest driver for Virtual Box Guest integration
Quoted 7 lines · Hans de Goede
I'm afraid that the userspace API is more or less a take it or leave it kinda deal, we can do small cleanups, but an entire re-design is out of the question. The vboxguest code has a long (too long) out of tree history and the same ioctl interface is used by VirtualBox upstream on Windows, Mac OS X, the BSDs and Solaris, so we cannot just go and break it to out hart's content.
Then hard out NAK for the code.
Re: [RFC v2 1/2] virt: Add vboxguest driver for Virtual Box Guest integration
Hi,
Quoted 10 lines · Christoph Hellwig
Quoted 7 lines · Hans de Goede
I'm afraid that the userspace API is more or less a take it or leave it kinda deal, we can do small cleanups, but an entire re-design is out of the question. The vboxguest code has a long (too long) out of tree history and the same ioctl interface is used by VirtualBox upstream on Windows, Mac OS X, the BSDs and Solaris, so we cannot just go and break it to out hart's content.
Then hard out NAK for the code.
You know I've been working on this for almost 2 fulltime months and this has been discussed in several places already long before you jumped on this thread and so far everyone liked the idea of getting this merged and was ok with living with the existing ioctl API (assuming no security issues / other nasty warts are found during review).
So although your input on this is appreciated some pragmatism would also be much appreciated. Remember perfect is the enemy of good.
Regards,
Hans
Re: [RFC v2 1/2] virt: Add vboxguest driver for Virtual Box Guest integration
Quoted 1 line · Hans de Goede
You know I've been working on this for almost 2 fulltime months
I don't, and I don't care to be honest. Figuring out what do do about the userspace API/ABI should be your first priority, and you should have discussed this on the linux-api list where I didn't see anything about this driver.
We have a general stance to fix userspace APIs/ABIs before inclusion, and in the few cases where we did it turned into a giant trainwreck. The prime example is the Android binder, which has been a giant mess. And that's something a lot more important than a weird hobbyist hypersvior.
RFC v2 2/2 fs: Add VirtualBox guest shared folder (vboxsf) support
In reply to Hans de GoedeVirtualBox hosts can share folders with guests, this commit adds a VFS driver implementing the Linux-guest side of this, allowing folders exported by the host to be mounted under Linux.
This driver depends on the guest <-> host IPC functions exported by the vboxguest driver.
--- fs/Kconfig | 1 + fs/Makefile | 1 + fs/vboxsf/Kconfig | 9 + fs/vboxsf/Makefile | 3 + fs/vboxsf/dirops.c | 705 ++++++++++++++++++++++ fs/vboxsf/lnkops.c | 37 ++ fs/vboxsf/regops.c | 558 +++++++++++++++++ fs/vboxsf/shfl_hostintf.h | 1283 ++++++++++++++++++++++++++++++++++++++++ fs/vboxsf/utils.c | 674 +++++++++++++++++++++ fs/vboxsf/vboxsf_wrappers.c | 519 ++++++++++++++++ fs/vboxsf/vboxsf_wrappers.h | 98 +++ fs/vboxsf/vfsmod.c | 386 ++++++++++++ fs/vboxsf/vfsmod.h | 113 ++++ include/uapi/linux/vbsfmount.h | 62 ++ 14 files changed, 4449 insertions(+) create mode 100644 fs/vboxsf/Kconfig create mode 100644 fs/vboxsf/Makefile create mode 100644 fs/vboxsf/dirops.c create mode 100644 fs/vboxsf/lnkops.c create mode 100644 fs/vboxsf/regops.c create mode 100644 fs/vboxsf/shfl_hostintf.h create mode 100644 fs/vboxsf/utils.c create mode 100644 fs/vboxsf/vboxsf_wrappers.c create mode 100644 fs/vboxsf/vboxsf_wrappers.h create mode 100644 fs/vboxsf/vfsmod.c create mode 100644 fs/vboxsf/vfsmod.h create mode 100644 include/uapi/linux/vbsfmount.h
fs/Kconfig +1 -0
@@ -248,6 +248,7 @@ source "fs/pstore/Kconfig" source "fs/sysv/Kconfig" source "fs/ufs/Kconfig" source "fs/exofs/Kconfig" +source "fs/vboxsf/Kconfig" endif # MISC_FILESYSTEMS
fs/Makefile +1 -0
@@ -128,3 +128,4 @@ obj-y += exofs/ # Multiple modules obj-$(CONFIG_CEPH_FS) += ceph/ obj-$(CONFIG_PSTORE) += pstore/ obj-$(CONFIG_EFIVAR_FS) += efivarfs/ +obj-$(CONFIG_VBOXSF_FS) += vboxsf/
fs/vboxsf/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config VBOXSF_FS + tristate "VirtualBox guest shared folder (vboxsf) support" + depends on VBOXGUEST + help + VirtualBox hosts can share folders with guests, this driver + implements the Linux-guest side of this allowing folders exported + by the host to be mounted under Linux. + + If you want to use shared folders in VirtualBox guests, answer Y or M.
fs/vboxsf/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_VBOXSF_FS) += vboxsf.o + +vboxsf-objs := dirops.o lnkops.o regops.o utils.o vboxsf_wrappers.o vfsmod.o
fs/vboxsf/dirops.c new file +705 -0
705 lines not on this page · raw message
fs/vboxsf/lnkops.c new file +37 -0
@@ -0,0 +1,37 @@ +/* +* VirtualBox Guest Shared Folders: Operations for symbolic links. +* +* Copyright (C) 2010-2016 Oracle Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include "vfsmod.h" + +static const char *sf_get_link (struct dentry *dentry,struct inode *inode, +struct delayed_call *done) +{ +struct sf_glob_info *sf_g =GET_GLOB_INFO (inode->i_sb); +struct sf_inode_info *sf_i =GET_INODE_INFO (inode); +char *path; +int rc; + +if (!dentry) +return ERR_PTR (-ECHILD ); + path =kzalloc (PAGE_SIZE ,GFP_KERNEL ); +if (!path) +return ERR_PTR (-ENOMEM ); + rc =vboxsf_readlink (sf_g->root, sf_i->path,PATH_MAX , path); +if (rc <0 ) { +kfree (path); +return ERR_PTR (-EPROTO ); + } +set_delayed_call (done, kfree_link, path); +return path; +} + +const struct inode_operations sf_lnk_iops = { + .get_link = sf_get_link +};
fs/vboxsf/regops.c new file +558 -0
558 lines not on this page · raw message
fs/vboxsf/shfl_hostintf.h new file +1283 -0
1,283 lines not on this page · raw message
fs/vboxsf/utils.c new file +674 -0
394 lines not on this page · raw message
fs/vboxsf/vboxsf_wrappers.c new file +519 -0
519 lines not on this page · raw message
fs/vboxsf/vboxsf_wrappers.h new file +98 -0
98 lines not on this page · raw message
fs/vboxsf/vfsmod.c new file +386 -0
386 lines not on this page · raw message
fs/vboxsf/vfsmod.h new file +113 -0
113 lines not on this page · raw message
include/uapi/linux/vbsfmount.h new file +62 -0
62 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.13.4
Part of the diff is not shown here. View the raw message.
Re: [RFC v2 2/2] fs: Add VirtualBox guest shared folder (vboxsf) support
Please merge the files into a a lot fewer files - basically one .c file and a header for the protocol probably is enough.
Also kill all kinds of weird tiny wrappers that just obsfucate the code, and make sure linux-fsdevel is on Cc for your next submission.
Also don't use i_private, instead defined alloc_inode and destroy_inode methods and use container_of.
Quoted 6 lines
+/**
+ * @note Anyone wishing to make changes here might wish to take a look at
+ * http://www.atnf.csiro.au/people/rgooch/linux/vfs.txt
+ * which seems to be the closest there is to official documentation on
+ * writing filesystem drivers for Linux.
+ */
And drop comments like this which will create a lot more confusion than actually helping.