Re: [PATCH resend v2 1/3] virt: Add vboxguest driver for Virtual Box Guest integration UAPI

From: Hans de Goede
Date: Tue Nov 28 2017 - 05:09:09 EST


Hi,

On 27-11-17 20:44, Larry Finger wrote:
On 11/26/2017 09:12 AM, Hans de Goede wrote:
This commit adds the headers describing the ioctl API for the
/dev/vboxguest device used by the Virtual Box Guest Additions
in Virtual Box virtual machines.

The driver providing the /dev/vboxguest device will allow Virtual Box
Guest Additions features such as copy-and-paste, seamless mode and
OpenGL pass-through.

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>

Minor comments inline in the code.

Reviewed-by: Larry Finger <Larry.Finger@xxxxxxxxxxxx>

Larry

---
Changes in v2:
-Change all uapi headers to kernel coding style: Drop struct and enum typedefs
 make type and struct-member names all lowercase, enum values all uppercase.
-Remove unused struct type declarations from some headers (shaving of another
 1000 lines)
-Remove or fixup doxygen style comments
-Get rid of CHECK macros, use a function taking in_ and out_size args instead
-Some other small codyingstyle fixes
-Split into multiple patches
---
 MAINTAINERS | 7 +
 include/uapi/linux/vbox_err.h | 170 ++++++++++++++++
 include/uapi/linux/vbox_vmmdev_types.h | 237 +++++++++++++++++++++++
 include/uapi/linux/vboxguest.h | 341 +++++++++++++++++++++++++++++++++
 4 files changed, 755 insertions(+)
 create mode 100644 include/uapi/linux/vbox_err.h
 create mode 100644 include/uapi/linux/vbox_vmmdev_types.h
 create mode 100644 include/uapi/linux/vboxguest.h


<snip>

diff --git a/include/uapi/linux/vbox_vmmdev_types.h b/include/uapi/linux/vbox_vmmdev_types.h
new file mode 100644
index 000000000000..1fdabee603fa
--- /dev/null
+++ b/include/uapi/linux/vbox_vmmdev_types.h
@@ -0,0 +1,237 @@
+/*
+ * Virtual Device for Guest <-> VMM/Host communication, type definitions
+ * which are also used for the vboxguest ioctl interface / by vboxsf
+ *
+ * Copyright (C) 2006-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.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, in which case the provisions of the CDDL are applicable
+ * instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef __UAPI_VBOX_VMMDEV_TYPES_H__
+#define __UAPI_VBOX_VMMDEV_TYPES_H__
+
+#include <asm/bitsperlong.h>
+#include <linux/types.h>
+
+/*
+ * We cannot use linux' compiletime_assert here because it expects to be used
+ * inside a function only. Use a typedef to a char array with a negative size.
+ */
+#define VMMDEV_ASSERT_SIZE(type, size) \
+ÂÂÂ typedef char type ## _asrt_size[1 - 2*!!(sizeof(struct type) != (size))]

I wondered about defining a new typedef here, and checkpatch.pl complained about it. I think your comment explains it very well.

Ok :)

+
+/** enum vmmdev_request_type - VMMDev request types. */
+enum vmmdev_request_type {
+ÂÂÂ VMMDEVREQ_INVALID_REQUESTÂÂÂÂÂÂÂÂÂÂÂÂÂ =Â 0,
+ÂÂÂ VMMDEVREQ_GET_MOUSE_STATUSÂÂÂÂÂÂÂÂÂÂÂÂ =Â 1,
+ÂÂÂ VMMDEVREQ_SET_MOUSE_STATUSÂÂÂÂÂÂÂÂÂÂÂÂ =Â 2,
+ÂÂÂ VMMDEVREQ_SET_POINTER_SHAPEÂÂÂÂÂÂÂÂÂÂÂ =Â 3,
+ÂÂÂ VMMDEVREQ_GET_HOST_VERSIONÂÂÂÂÂÂÂÂÂÂÂÂ =Â 4,
+ÂÂÂ VMMDEVREQ_IDLEÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ =Â 5,
+ÂÂÂ VMMDEVREQ_GET_HOST_TIMEÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ = 10,
+ÂÂÂ VMMDEVREQ_GET_HYPERVISOR_INFOÂÂÂÂÂÂÂÂÂ = 20,
+ÂÂÂ VMMDEVREQ_SET_HYPERVISOR_INFOÂÂÂÂÂÂÂÂÂ = 21,
+ÂÂÂ VMMDEVREQ_REGISTER_PATCH_MEMORYÂÂÂÂÂÂÂ = 22, /* since version 3.0.6 */
+ÂÂÂ VMMDEVREQ_DEREGISTER_PATCH_MEMORYÂÂÂÂÂ = 23, /* since version 3.0.6 */
+ÂÂÂ VMMDEVREQ_SET_POWER_STATUSÂÂÂÂÂÂÂÂÂÂÂÂ = 30,
+ÂÂÂ VMMDEVREQ_ACKNOWLEDGE_EVENTSÂÂÂÂÂÂÂÂÂÂ = 41,
+ÂÂÂ VMMDEVREQ_CTL_GUEST_FILTER_MASKÂÂÂÂÂÂÂ = 42,
+ÂÂÂ VMMDEVREQ_REPORT_GUEST_INFOÂÂÂÂÂÂÂÂÂÂÂ = 50,
+ÂÂÂ VMMDEVREQ_REPORT_GUEST_INFO2ÂÂÂÂÂÂÂÂÂÂ = 58, /* since version 3.2.0 */
+ÂÂÂ VMMDEVREQ_REPORT_GUEST_STATUSÂÂÂÂÂÂÂÂÂ = 59, /* since version 3.2.8 */
+ÂÂÂ VMMDEVREQ_REPORT_GUEST_USER_STATEÂÂÂÂÂ = 74, /* since version 4.3 */
+ÂÂÂ /* Retrieve a display resize request sent by the host, deprecated. */
+ÂÂÂ VMMDEVREQ_GET_DISPLAY_CHANGE_REQÂÂÂÂÂÂ = 51,
+ÂÂÂ VMMDEVREQ_VIDEMODE_SUPPORTEDÂÂÂÂÂÂÂÂÂÂ = 52,
+ÂÂÂ VMMDEVREQ_GET_HEIGHT_REDUCTIONÂÂÂÂÂÂÂÂ = 53,
+ÂÂÂ /**
+ÂÂÂÂ * @VMMDEVREQ_GET_DISPLAY_CHANGE_REQ2:
+ÂÂÂÂ * Retrieve a display resize request sent by the host.
+ÂÂÂÂ *
+ * Queries a display resize request sent from the host. If the
+ÂÂÂÂ * event_ack member is sent to true and there is an unqueried request
+ÂÂÂÂ * available for one of the virtual display then that request will
+ * be returned. If several displays have unqueried requests the lowest
+ * numbered display will be chosen first. Only the most recent unseen
+ÂÂÂÂ * request for each display is remembered.
+ÂÂÂÂ * If event_ack is set to false, the last host request queried with
+ÂÂÂÂ * event_ack set is resent, or failing that the most recent received
+ * from the host. If no host request was ever received then all zeros
+ÂÂÂÂ * are returned.
+ÂÂÂÂ */
+ÂÂÂ VMMDEVREQ_GET_DISPLAY_CHANGE_REQ2ÂÂÂÂÂ = 54,
+ÂÂÂ VMMDEVREQ_REPORT_GUEST_CAPABILITIESÂÂÂ = 55,
+ÂÂÂ VMMDEVREQ_SET_GUEST_CAPABILITIESÂÂÂÂÂÂ = 56,
+ÂÂÂ VMMDEVREQ_VIDEMODE_SUPPORTED2ÂÂÂÂÂÂÂÂÂ = 57, /* since version 3.2.0 */
+ÂÂÂ VMMDEVREQ_GET_DISPLAY_CHANGE_REQEXÂÂÂÂ = 80, /* since version 4.2.4 */
+ÂÂÂ VMMDEVREQ_HGCM_CONNECTÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ = 60,
+ÂÂÂ VMMDEVREQ_HGCM_DISCONNECTÂÂÂÂÂÂÂÂÂÂÂÂÂ = 61,
+ÂÂÂ VMMDEVREQ_HGCM_CALL32ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ = 62,
+ÂÂÂ VMMDEVREQ_HGCM_CALL64ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ = 63,
+ÂÂÂ VMMDEVREQ_HGCM_CANCELÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ = 64,
+ÂÂÂ VMMDEVREQ_HGCM_CANCEL2ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ = 65,
+ÂÂÂ VMMDEVREQ_VIDEO_ACCEL_ENABLEÂÂÂÂÂÂÂÂÂÂ = 70,
+ÂÂÂ VMMDEVREQ_VIDEO_ACCEL_FLUSHÂÂÂÂÂÂÂÂÂÂÂ = 71,
+ÂÂÂ VMMDEVREQ_VIDEO_SET_VISIBLE_REGIONÂÂÂÂ = 72,
+ÂÂÂ VMMDEVREQ_GET_SEAMLESS_CHANGE_REQÂÂÂÂÂ = 73,
+ÂÂÂ VMMDEVREQ_QUERY_CREDENTIALSÂÂÂÂÂÂÂÂÂÂÂ = 100,
+ÂÂÂ VMMDEVREQ_REPORT_CREDENTIALS_JUDGEMENT = 101,
+ÂÂÂ VMMDEVREQ_REPORT_GUEST_STATSÂÂÂÂÂÂÂÂÂÂ = 110,
+ÂÂÂ VMMDEVREQ_GET_MEMBALLOON_CHANGE_REQÂÂÂ = 111,
+ÂÂÂ VMMDEVREQ_GET_STATISTICS_CHANGE_REQÂÂÂ = 112,
+ÂÂÂ VMMDEVREQ_CHANGE_MEMBALLOONÂÂÂÂÂÂÂÂÂÂÂ = 113,
+ÂÂÂ VMMDEVREQ_GET_VRDPCHANGE_REQÂÂÂÂÂÂÂÂÂÂ = 150,
+ÂÂÂ VMMDEVREQ_LOG_STRINGÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ = 200,
+ÂÂÂ VMMDEVREQ_GET_CPU_HOTPLUG_REQÂÂÂÂÂÂÂÂÂ = 210,
+ÂÂÂ VMMDEVREQ_SET_CPU_HOTPLUG_STATUSÂÂÂÂÂÂ = 211,
+ÂÂÂ VMMDEVREQ_REGISTER_SHARED_MODULEÂÂÂÂÂÂ = 212,
+ÂÂÂ VMMDEVREQ_UNREGISTER_SHARED_MODULEÂÂÂÂ = 213,
+ÂÂÂ VMMDEVREQ_CHECK_SHARED_MODULESÂÂÂÂÂÂÂÂ = 214,
+ÂÂÂ VMMDEVREQ_GET_PAGE_SHARING_STATUSÂÂÂÂÂ = 215,
+ÂÂÂ VMMDEVREQ_DEBUG_IS_PAGE_SHAREDÂÂÂÂÂÂÂÂ = 216,
+ÂÂÂ VMMDEVREQ_GET_SESSION_IDÂÂÂÂÂÂÂÂÂÂÂÂÂÂ = 217, /* since version 3.2.8 */
+ÂÂÂ VMMDEVREQ_WRITE_COREDUMPÂÂÂÂÂÂÂÂÂÂÂÂÂÂ = 218,
+ÂÂÂ VMMDEVREQ_GUEST_HEARTBEATÂÂÂÂÂÂÂÂÂÂÂÂÂ = 219,
+ÂÂÂ VMMDEVREQ_HEARTBEAT_CONFIGUREÂÂÂÂÂÂÂÂÂ = 220,
+ÂÂÂ /* Ensure the enum is a 32 bit data-type */
+ÂÂÂ VMMDEVREQ_SIZEHACKÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ = 0x7fffffff
+};
+
+#if __BITS_PER_LONG == 64
+#define VMMDEVREQ_HGCM_CALL VMMDEVREQ_HGCM_CALL64
+#else
+#define VMMDEVREQ_HGCM_CALL VMMDEVREQ_HGCM_CALL32
+#endif
+
+/** HGCM service location types. */
+enum vmmdev_hgcm_service_location_type {
+ÂÂÂ VMMDEV_HGCM_LOC_INVALIDÂÂÂ = 0,
+ÂÂÂ VMMDEV_HGCM_LOC_LOCALHOSTÂ = 1,
+ÂÂÂ VMMDEV_HGCM_LOC_LOCALHOST_EXISTING = 2,
+ÂÂÂ /* Ensure the enum is a 32 bit data-type */
+ÂÂÂ VMMDEV_HGCM_LOC_SIZEHACKÂÂ = 0x7fffffff
+};
+
+/** HGCM host service location. */
+struct vmmdev_hgcm_service_location_localhost {
+ÂÂÂ /** Service name */
+ÂÂÂ char service_name[128];
+};
+VMMDEV_ASSERT_SIZE(vmmdev_hgcm_service_location_localhost, 128);
+
+/** HGCM service location. */
+struct vmmdev_hgcm_service_location {
+ÂÂÂ /** Type of the location. */
+ÂÂÂ enum vmmdev_hgcm_service_location_type type;
+
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ struct vmmdev_hgcm_service_location_localhost localhost;
+ÂÂÂ } u;
+};

This union only has one member. Is there some reason to keep the union here?

This is the ABI as defined by vbox upstream, I believe the intend
is that in the future there may be other values for
type then VMMDEV_HGCM_LOC_LOCALHOST and those would get a different
member in the union to represent the address/location format
for this to-be-added-in-the-future service_location_type.

+VMMDEV_ASSERT_SIZE(vmmdev_hgcm_service_location, 128 + 4);
+
+/** HGCM function parameter type. */
+enum vmmdev_hgcm_function_parameter_type {
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_INVALIDÂÂÂÂÂÂÂÂÂÂÂ = 0,
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_32BITÂÂÂÂÂÂÂÂÂÂÂÂÂ = 1,
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_64BITÂÂÂÂÂÂÂÂÂÂÂÂÂ = 2,
+ÂÂÂ /** Deprecated Doesn't work, use PAGELIST. */
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_PHYSADDRÂÂÂÂÂÂÂÂÂÂ = 3,
+ÂÂÂ /** In and Out, user-memory */
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_LINADDRÂÂÂÂÂÂÂÂÂÂÂ = 4,
+ /** In, user-memory (read; host<-guest) */
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_LINADDR_INÂÂÂÂÂÂÂÂ = 5,
+ÂÂÂ /** Out, user-memory (write; host->guest) */
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_LINADDR_OUTÂÂÂÂÂÂÂ = 6,
+ÂÂÂ /** In and Out, kernel-memory */
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNELÂÂÂÂ = 7,
+ /** In, kernel-memory (read; host<-guest) */
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_INÂ = 8,
+ÂÂÂ /** Out, kernel-memory (write; host->guest) */
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_OUT = 9,
+ÂÂÂ /** Physical addresses of locked pages for a buffer. */
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_PAGELISTÂÂÂÂÂÂÂÂÂÂ = 10,
+ÂÂÂ /* Ensure the enum is a 32 bit data-type */
+ÂÂÂ VMMDEV_HGCM_PARM_TYPE_SIZEHACKÂÂÂÂÂÂÂÂÂÂ = 0x7fffffff
+};
+
+/** HGCM function parameter, 32-bit client. */
+struct vmmdev_hgcm_function_parameter32 {
+ÂÂÂ enum vmmdev_hgcm_function_parameter_type type;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ __u32 value32;
+ÂÂÂÂÂÂÂ __u64 value64;
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 size;
+ÂÂÂÂÂÂÂÂÂÂÂ union {
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ __u32 phys_addr;
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ __u32 linear_addr;
+ÂÂÂÂÂÂÂÂÂÂÂ } u;
+ÂÂÂÂÂÂÂ } pointer;
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /** Size of the buffer described by the page list. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 size;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Relative to the request header. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 offset;
+ÂÂÂÂÂÂÂ } page_list;
+ÂÂÂ } u;
+} __packed;
+VMMDEV_ASSERT_SIZE(vmmdev_hgcm_function_parameter32, 4 + 8);
+
+/** HGCM function parameter, 64-bit client. */
+struct vmmdev_hgcm_function_parameter64 {
+ÂÂÂ enum vmmdev_hgcm_function_parameter_type type;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ __u32 value32;
+ÂÂÂÂÂÂÂ __u64 value64;
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 size;
+ÂÂÂÂÂÂÂÂÂÂÂ union {
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ __u64 phys_addr;
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ __u64 linear_addr;
+ÂÂÂÂÂÂÂÂÂÂÂ } u;
+ÂÂÂÂÂÂÂ } __packed pointer;
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /** Size of the buffer described by the page list. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 size;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Relative to the request header. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 offset;
+ÂÂÂÂÂÂÂ } page_list;
+ÂÂÂ } __packed u;
+} __packed;
+VMMDEV_ASSERT_SIZE(vmmdev_hgcm_function_parameter64, 4 + 12);
+
+#if __BITS_PER_LONG == 64
+#define vmmdev_hgcm_function_parameter vmmdev_hgcm_function_parameter64
+#else
+#define vmmdev_hgcm_function_parameter vmmdev_hgcm_function_parameter32
+#endif
+
+#define VMMDEV_HGCM_F_PARM_DIRECTION_NONEÂÂÂÂÂ 0x00000000U
+#define VMMDEV_HGCM_F_PARM_DIRECTION_TO_HOSTÂÂ 0x00000001U
+#define VMMDEV_HGCM_F_PARM_DIRECTION_FROM_HOST 0x00000002U
+#define VMMDEV_HGCM_F_PARM_DIRECTION_BOTHÂÂÂÂÂ 0x00000003U
+
+/**
+ * struct vmmdev_hgcm_pagelist - VMMDEV_HGCM_PARM_TYPE_PAGELIST parameters
+ * point to this structure to actually describe the buffer.
+ */
+struct vmmdev_hgcm_pagelist {
+ÂÂÂ __u32 flags;ÂÂÂÂÂÂÂÂÂÂÂÂ /** VMMDEV_HGCM_F_PARM_*. */
+ÂÂÂ __u16 offset_first_page; /** Data offset in the first page. */
+ÂÂÂ __u16 page_count;ÂÂÂÂÂÂÂ /** Number of pages. */
+ÂÂÂ __u64 pages[1];ÂÂÂÂÂÂÂÂÂ /** Page addresses. */
+};
+VMMDEV_ASSERT_SIZE(vmmdev_hgcm_pagelist, 4 + 2 + 2 + 8);
+
+#endif
diff --git a/include/uapi/linux/vboxguest.h b/include/uapi/linux/vboxguest.h
new file mode 100644
index 000000000000..d201eb080df2
--- /dev/null
+++ b/include/uapi/linux/vboxguest.h
@@ -0,0 +1,341 @@
+/*
+ * VBoxGuest - VirtualBox Guest Additions Driver Interface.
+ *
+ * Copyright (C) 2006-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.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, in which case the provisions of the CDDL are applicable
+ * instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef __UAPI_VBOXGUEST_H__
+#define __UAPI_VBOXGUEST_H__
+
+#include <asm/bitsperlong.h>
+#include <linux/ioctl.h>
+#include <linux/vbox_err.h>
+#include <linux/vbox_vmmdev_types.h>
+
+/* Version of vbg_ioctl_hdr structure. */
+#define VBG_IOCTL_HDR_VERSIONÂÂÂÂÂÂÂ 0x10001
+/* Default request type. Use this for non-VMMDev requests. */
+#define VBG_IOCTL_HDR_TYPE_DEFAULTÂÂÂÂÂÂÂ 0
+
+/**
+ * Common ioctl header.
+ *
+ * This is a mirror of vmmdev_request_header to prevent duplicating data and
+ * needing to verify things multiple times.
+ */
+struct vbg_ioctl_hdr {
+ÂÂÂ /** IN: The request input size, and output size if size_out is zero. */
+ÂÂÂ __u32 size_in;
+ÂÂÂ /** IN: Structure version (VBG_IOCTL_HDR_VERSION) */
+ÂÂÂ __u32 version;
+ÂÂÂ /** IN: The VMMDev request type or VBG_IOCTL_HDR_TYPE_DEFAULT. */
+ÂÂÂ __u32 type;
+ÂÂÂ /**
+ÂÂÂÂ * OUT: The VBox status code of the operation, out direction only.
+ÂÂÂÂ * This is a VINF_ or VERR_ value as defined in vbox_err.h.
+ÂÂÂÂ */
+ÂÂÂ __s32 rc;
+ÂÂÂ /** IN: Output size. Set to zero to use size_in as output size. */
+ÂÂÂ __u32 size_out;
+ÂÂÂ /** Reserved, MBZ. */
+ÂÂÂ __u32 reserved;
+};
+VMMDEV_ASSERT_SIZE(vbg_ioctl_hdr, 24);
+
+
+/*
+ * The VBoxGuest I/O control version.
+ *
+ * As usual, the high word contains the major version and changes to it
+ * signifies incompatible changes.
+ *
+ * The lower word is the minor version number, it is increased when new
+ * functions are added or existing changed in a backwards compatible manner.
+ */
+#define VBG_IOC_VERSIONÂÂÂÂÂÂÂ 0x00010000u
+
+/**
+ * VBG_IOCTL_DRIVER_VERSION_INFO data structure
+ *
+ * Note VBG_IOCTL_DRIVER_VERSION_INFO may switch the session to a backwards
+ * compatible interface version if uClientVersion indicates older client code.
+ */
+struct vbg_ioctl_driver_version_info {
+ÂÂÂ /** The header. */
+ÂÂÂ struct vbg_ioctl_hdr hdr;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /** Requested interface version (VBG_IOC_VERSION). */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 req_version;
+ÂÂÂÂÂÂÂÂÂÂÂ /**
+ÂÂÂÂÂÂÂÂÂÂÂÂ * Minimum interface version number (typically the
+ÂÂÂÂÂÂÂÂÂÂÂÂ * major version part of VBG_IOC_VERSION).
+ÂÂÂÂÂÂÂÂÂÂÂÂ */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 min_version;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Reserved, MBZ. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 reserved1;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Reserved, MBZ. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 reserved2;
+ÂÂÂÂÂÂÂ } in;
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /** Version for this session (typ. VBG_IOC_VERSION). */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 session_version;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Version of the IDC interface (VBG_IOC_VERSION). */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 driver_version;
+ÂÂÂÂÂÂÂÂÂÂÂ /** The SVN revision of the driver, or 0. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 driver_revision;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Reserved \#1 (zero until defined). */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 reserved1;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Reserved \#2 (zero until defined). */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 reserved2;
+ÂÂÂÂÂÂÂ } out;
+ÂÂÂ } u;
+};
+VMMDEV_ASSERT_SIZE(vbg_ioctl_driver_version_info, 24 + 20);
+
+#define VBG_IOCTL_DRIVER_VERSION_INFO \
+ÂÂÂ _IOWR('V', 0, struct vbg_ioctl_driver_version_info)
+
+
+/* IOCTL to perform a VMM Device request less than 1KB in size. */
+#define VBG_IOCTL_VMMDEV_REQUEST(s)ÂÂÂ _IOC(_IOC_READ | _IOC_WRITE, 'V', 2, s)
+
+
+/* IOCTL to perform a VMM Device request larger then 1KB. */
+#define VBG_IOCTL_VMMDEV_REQUEST_BIGÂÂÂ _IOC(_IOC_READ | _IOC_WRITE, 'V', 3, 0)
+
+
+/** VBG_IOCTL_HGCM_CONNECT data structure. */
+struct vbg_ioctl_hgcm_connect {
+ÂÂÂ struct vbg_ioctl_hdr hdr;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ struct vmmdev_hgcm_service_location loc;
+ÂÂÂÂÂÂÂ } in;
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 client_id;
+ÂÂÂÂÂÂÂ } out;
+ÂÂÂ } u;
+};
+VMMDEV_ASSERT_SIZE(vbg_ioctl_hgcm_connect, 24 + 132);
+
+#define VBG_IOCTL_HGCM_CONNECT \
+ÂÂÂ _IOWR('V', 4, struct vbg_ioctl_hgcm_connect)
+
+
+/** VBG_IOCTL_HGCM_DISCONNECT data structure. */
+struct vbg_ioctl_hgcm_disconnect {
+ÂÂÂ struct vbg_ioctl_hdr hdr;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 client_id;
+ÂÂÂÂÂÂÂ } in;
+ÂÂÂ } u;
+};

Another single-member union.

Right, in this case this is done for consistency to follow the
format of all the other ioctls which also have a union with in /
out parameters, as this ioctl only sends data from the
caller to the kernel it only has the in member.

+VMMDEV_ASSERT_SIZE(vbg_ioctl_hgcm_disconnect, 24 + 4);
+
+#define VBG_IOCTL_HGCM_DISCONNECT \
+ÂÂÂ _IOWR('V', 5, struct vbg_ioctl_hgcm_disconnect)
+
+
+/** VBG_IOCTL_HGCM_CALL data structure. */
+struct vbg_ioctl_hgcm_call {
+ÂÂÂ /** The header. */
+ÂÂÂ struct vbg_ioctl_hdr hdr;
+ÂÂÂ /** Input: The id of the caller. */
+ÂÂÂ __u32 client_id;
+ÂÂÂ /** Input: Function number. */
+ÂÂÂ __u32 function;
+ÂÂÂ /**
+ÂÂÂÂ * Input: How long to wait (milliseconds) for completion before
+ÂÂÂÂ * cancelling the call. Set to -1 to wait indefinitely.
+ÂÂÂÂ */
+ÂÂÂ __u32 timeout_ms;
+ÂÂÂ /** Interruptable flag, ignored for userspace calls. */
+ÂÂÂ __u8 interruptible;
+ÂÂÂ /** Explicit padding, MBZ. */
+ÂÂÂ __u8 reserved;
+ÂÂÂ /**
+ÂÂÂÂ * Input: How many parameters following this structure.
+ÂÂÂÂ *
+ÂÂÂÂ * The parameters are either HGCMFunctionParameter64 or 32,
+ÂÂÂÂ * depending on whether we're receiving a 64-bit or 32-bit request.
+ÂÂÂÂ *
+ÂÂÂÂ * The current maximum is 61 parameters (given a 1KB max request size,
+ÂÂÂÂ * and a 64-bit parameter size of 16 bytes).
+ÂÂÂÂ */
+ÂÂÂ __u16 parm_count;
+ÂÂÂ /*
+ÂÂÂÂ * Parameters follow in form:
+ÂÂÂÂ * struct hgcm_function_parameter<32|64> parms[parm_count]
+ÂÂÂÂ */
+};
+VMMDEV_ASSERT_SIZE(vbg_ioctl_hgcm_call, 24 + 16);
+
+#define VBG_IOCTL_HGCM_CALL_32(s)ÂÂÂ _IOC(_IOC_READ | _IOC_WRITE, 'V', 6, s)
+#define VBG_IOCTL_HGCM_CALL_64(s)ÂÂÂ _IOC(_IOC_READ | _IOC_WRITE, 'V', 7, s)
+#if __BITS_PER_LONG == 64
+#define VBG_IOCTL_HGCM_CALL(s)ÂÂÂÂÂÂÂ VBG_IOCTL_HGCM_CALL_64(s)
+#else
+#define VBG_IOCTL_HGCM_CALL(s)ÂÂÂÂÂÂÂ VBG_IOCTL_HGCM_CALL_32(s)
+#endif
+
+
+/** VBG_IOCTL_LOG data structure. */
+struct vbg_ioctl_log {
+ÂÂÂ /** The header. */
+ÂÂÂ struct vbg_ioctl_hdr hdr;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /**
+ÂÂÂÂÂÂÂÂÂÂÂÂ * The log message, this may be zero terminated. If it
+ÂÂÂÂÂÂÂÂÂÂÂÂ * is not zero terminated then the length is determined
+ÂÂÂÂÂÂÂÂÂÂÂÂ * from the input size.
+ÂÂÂÂÂÂÂÂÂÂÂÂ */
+ÂÂÂÂÂÂÂÂÂÂÂ char msg[1];
+ÂÂÂÂÂÂÂ } in;
+ÂÂÂ } u;
+};

Amother single-member union.

Same reason as the previous one.

+
+#define VBG_IOCTL_LOG(s)ÂÂÂÂÂÂÂ _IOC(_IOC_READ | _IOC_WRITE, 'V', 9, s)
+
+
+/** VBG_IOCTL_WAIT_FOR_EVENTS data structure. */
+struct vbg_ioctl_wait_for_events {
+ÂÂÂ /** The header. */
+ÂÂÂ struct vbg_ioctl_hdr hdr;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /** Timeout in milliseconds. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 timeout_ms;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Events to wait for. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 events;
+ÂÂÂÂÂÂÂ } in;
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /** Events that occurred. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 events;
+ÂÂÂÂÂÂÂ } out;
+ÂÂÂ } u;
+};
+VMMDEV_ASSERT_SIZE(vbg_ioctl_wait_for_events, 24 + 8);
+
+#define VBG_IOCTL_WAIT_FOR_EVENTS \
+ÂÂÂ _IOWR('V', 10, struct vbg_ioctl_wait_for_events)
+
+
+/*
+ * IOCTL to VBoxGuest to interrupt (cancel) any pending
+ * VBG_IOCTL_WAIT_FOR_EVENTS and return.
+ *
+ * Handled inside the vboxguest driver and not seen by the host at all.
+ * After calling this, VBG_IOCTL_WAIT_FOR_EVENTS should no longer be called in
+ * the same session. Any VBOXGUEST_IOCTL_WAITEVENT calls in the same session
+ * done after calling this will directly exit with -EINTR.
+ */
+#define VBG_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS \
+ÂÂÂ _IOWR('V', 11, struct vbg_ioctl_hdr)
+
+
+/** VBG_IOCTL_CHANGE_FILTER_MASK data structure. */
+struct vbg_ioctl_change_filter {
+ÂÂÂ /** The header. */
+ÂÂÂ struct vbg_ioctl_hdr hdr;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /** Flags to set. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 or_mask;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Flags to remove. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 not_mask;
+ÂÂÂÂÂÂÂ } in;
+ÂÂÂ } u;
+};

Amother single-member union.

Same reason as the previous ones :)

+VMMDEV_ASSERT_SIZE(vbg_ioctl_change_filter, 24 + 8);
+
+/* IOCTL to VBoxGuest to control the event filter mask. */
+#define VBG_IOCTL_CHANGE_FILTER_MASK \
+ÂÂÂ _IOWR('V', 12, struct vbg_ioctl_change_filter)
+
+
+/** VBG_IOCTL_CHANGE_GUEST_CAPABILITIES data structure. */
+struct vbg_ioctl_set_guest_caps {
+ÂÂÂ /** The header. */
+ÂÂÂ struct vbg_ioctl_hdr hdr;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /** Capabilities to set (VMMDEV_GUEST_SUPPORTS_XXX). */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 or_mask;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Capabilities to drop (VMMDEV_GUEST_SUPPORTS_XXX). */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 not_mask;
+ÂÂÂÂÂÂÂ } in;
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /** Capabilities held by the session after the call. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 session_caps;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Capabilities for all the sessions after the call. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 global_caps;
+ÂÂÂÂÂÂÂ } out;
+ÂÂÂ } u;
+};
+VMMDEV_ASSERT_SIZE(vbg_ioctl_set_guest_caps, 24 + 8);
+
+#define VBG_IOCTL_CHANGE_GUEST_CAPABILITIES \
+ÂÂÂ _IOWR('V', 14, struct vbg_ioctl_set_guest_caps)
+
+
+/** VBG_IOCTL_CHECK_BALLOON data structure. */
+struct vbg_ioctl_check_balloon {
+ÂÂÂ /** The header. */
+ÂÂÂ struct vbg_ioctl_hdr hdr;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ /** The size of the balloon in chunks of 1MB. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 balloon_chunks;
+ÂÂÂÂÂÂÂÂÂÂÂ /**
+ÂÂÂÂÂÂÂÂÂÂÂÂ * false = handled in R0, no further action required.
+ÂÂÂÂÂÂÂÂÂÂÂÂ *Â true = allocate balloon memory in R3.
+ÂÂÂÂÂÂÂÂÂÂÂÂ */
+ÂÂÂÂÂÂÂÂÂÂÂ __u8 handle_in_r3;
+ÂÂÂÂÂÂÂÂÂÂÂ /** Explicit padding, MBZ. */
+ÂÂÂÂÂÂÂÂÂÂÂ __u8 padding[3];
+ÂÂÂÂÂÂÂ } out;
+ÂÂÂ } u;
+};
+VMMDEV_ASSERT_SIZE(vbg_ioctl_check_balloon, 24 + 8);
+
+/*
+ * IOCTL to check memory ballooning.
+ *
+ * The guest kernel module will ask the host for the current size of the
+ * balloon and adjust the size. Or it will set handle_in_r3 = true and R3 is
+ * responsible for allocating memory and calling VBG_IOCTL_CHANGE_BALLOON.
+ */
+#define VBG_IOCTL_CHECK_BALLOON \
+ÂÂÂ _IOWR('V', 17, struct vbg_ioctl_check_balloon)
+
+
+/** VBG_IOCTL_WRITE_CORE_DUMP data structure. */
+struct vbg_ioctl_write_coredump {
+ÂÂÂ struct vbg_ioctl_hdr hdr;
+ÂÂÂ union {
+ÂÂÂÂÂÂÂ struct {
+ÂÂÂÂÂÂÂÂÂÂÂ __u32 flags; /** Flags (reserved, MBZ). */
+ÂÂÂÂÂÂÂ } in;
+ÂÂÂ } u;
+};
+VMMDEV_ASSERT_SIZE(vbg_ioctl_write_coredump, 24 + 4);

Another single-member union.

Yes, this is another input only ioctl.

+
+#define VBG_IOCTL_WRITE_CORE_DUMP \
+ÂÂÂ _IOWR('V', 19, struct vbg_ioctl_write_coredump)
+
+#endif



Regards,

Hans