drivers/virt: vm_gen_counter: initial driver implementation
PATCH v2 1/1 drivers/virt: vm_gen_counter: initial driver implementation
From: Or Idgar <[email protected]>
This patch is a driver which expose the Virtual Machine Generation ID via sysfs. The ID is a UUID value used to differentiate between virtual machines.
The VM-Generation ID is a feature defined by Microsoft (paper:
http://go.microsoft.com/fwlink/?LinkId=260709) and supported by multiple hypervisor vendors.
--- Documentation/ABI/testing/sysfs-hypervisor | 13 +++ drivers/misc/Kconfig | 6 ++ drivers/misc/Makefile | 1 + drivers/misc/vmgenid.c | 140 +++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-hypervisor create mode 100644 drivers/misc/vmgenid.c
Documentation/ABI/testing/sysfs-hypervisor new file +13 -0
@@ -0,0 +1,13 @@ +What: /sys/hypervisor/vm_gen_counter +Date: February 2018 +Contact: Or Idgar <[email protected]> + Gal Hammer <[email protected]> +Description: Expose the virtual machine generation ID. The directory + contains two files: "generation_id" and "raw". Both files + represent the same information. + + "generation_id" file is a UUID string + representation. + + "raw" file is a 128-bit integer + representation (binary).
drivers/misc/Kconfig +6 -0
@@ -500,6 +500,12 @@ config MISC_RTSX tristate default MISC_RTSX_PCI || MISC_RTSX_USB +config VMGENID + tristate "Virtual Machine Generation ID driver" + help + This is a Virtual Machine Generation ID driver which provides + a virtual machine unique identifier. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -57,6 +57,7 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP) += aspeed-lpc-snoop.o obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o obj-$(CONFIG_OCXL) += ocxl/ obj-$(CONFIG_MISC_RTSX) += cardreader/ +obj-$(CONFIG_VMGENID) += vmgenid.o lkdtm-$(CONFIG_LKDTM) += lkdtm_core.o lkdtm-$(CONFIG_LKDTM) += lkdtm_bugs.o
drivers/misc/vmgenid.c new file +140 -0
140 lines not on this page · raw message
Signature · 1 line
2.14.3
Greg KH
maintainerQuoted 11 lines · Or Idgar
From: Or Idgar <[email protected]>
This patch is a driver which expose the Virtual Machine Generation ID via sysfs. The ID is a UUID value used to differentiate between virtual machines.
The VM-Generation ID is a feature defined by Microsoft (paper:
http://go.microsoft.com/fwlink/?LinkId=260709) and supported by multiple hypervisor vendors.Signed-off-by Or Idgar <[email protected]>
Quoted 8 lines
--- Documentation/ABI/testing/sysfs-hypervisor | 13 +++ drivers/misc/Kconfig | 6 ++ drivers/misc/Makefile | 1 + drivers/misc/vmgenid.c | 140 +++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-hypervisor create mode 100644 drivers/misc/vmgenid.c
What changed from v1? Always put that below the --- line like Documentation/SubmittingPatches describes how to do.
v3?
thanks,
greg k-h
kbuild test robot
build botThank you for the patch! Yet something to improve:
Hi Or,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.16-rc3 next-20180301]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Or-Idgar/drivers-virt-vm_gen_counter-initial-driver-implementation/20180227-050111
config: openrisc-allyesconfig (attached as .config)
compiler: or1k-linux-gcc (GCC) 6.0.0 20160327 (experimental)
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=openrisc
All errors (new ones prefixed by >>):
drivers/misc/vmgenid.c: In function 'acpi_vmgenid_add':
drivers/misc/vmgenid.c:102:29: error: dereferencing pointer to incomplete type 'struct acpi_device'
retval = get_vmgenid(device->handle);
^~
drivers/misc/vmgenid.c: At top level:
drivers/misc/vmgenid.c:114:36: error: array type has incomplete element type 'struct acpi_device_id'
static const struct acpi_device_id vmgenid_ids[] = {
^~~~~~~~~~~
drivers/misc/vmgenid.c:119:15: error: variable 'acpi_vmgenid_driver' has initializer but incomplete type
static struct acpi_driver acpi_vmgenid_driver = {
^~~~~~~~~~~
>> drivers/misc/vmgenid.c:120:2: error: unknown field 'name' specified in initializer
.name = "vm_gen_counter",
^
drivers/misc/vmgenid.c:120:10: warning: excess elements in struct initializer
.name = "vm_gen_counter",
^~~~~~~~~~~~~~~~
drivers/misc/vmgenid.c:120:10: note: (near initialization for 'acpi_vmgenid_driver')
>> drivers/misc/vmgenid.c:121:2: error: unknown field 'ids' specified in initializer
.ids = vmgenid_ids,
^
drivers/misc/vmgenid.c:121:9: warning: excess elements in struct initializer
.ids = vmgenid_ids,
^~~~~~~~~~~
drivers/misc/vmgenid.c:121:9: note: (near initialization for 'acpi_vmgenid_driver')
>> drivers/misc/vmgenid.c:122:2: error: unknown field 'owner' specified in initializer
.owner = THIS_MODULE,
^
In file included from include/linux/linkage.h:7:0,
from include/linux/kernel.h:7,
from include/linux/list.h:9,
from include/linux/module.h:9,
from drivers/misc/vmgenid.c:12:
include/linux/export.h:37:21: warning: excess elements in struct initializer
#define THIS_MODULE ((struct module *)0)
^
drivers/misc/vmgenid.c:122:11: note: in expansion of macro 'THIS_MODULE'
.owner = THIS_MODULE,
^~~~~~~~~~~
include/linux/export.h:37:21: note: (near initialization for 'acpi_vmgenid_driver')
#define THIS_MODULE ((struct module *)0)
^
drivers/misc/vmgenid.c:122:11: note: in expansion of macro 'THIS_MODULE'
.owner = THIS_MODULE,
^~~~~~~~~~~
>> drivers/misc/vmgenid.c:123:2: error: unknown field 'ops' specified in initializer
.ops = {
^
drivers/misc/vmgenid.c:123:9: error: extra brace group at end of initializer
.ops = {
^
drivers/misc/vmgenid.c:123:9: note: (near initialization for 'acpi_vmgenid_driver')
drivers/misc/vmgenid.c:123:9: warning: excess elements in struct initializer
drivers/misc/vmgenid.c:123:9: note: (near initialization for 'acpi_vmgenid_driver')
drivers/misc/vmgenid.c: In function 'vmgenid_init':
>> drivers/misc/vmgenid.c:131:9: error: implicit declaration of function 'acpi_bus_register_driver' [-Werror=implicit-function-declaration]
return acpi_bus_register_driver(&acpi_vmgenid_driver);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/vmgenid.c: In function 'vmgenid_exit':
>> drivers/misc/vmgenid.c:136:2: error: implicit declaration of function 'acpi_bus_unregister_driver' [-Werror=implicit-function-declaration]
acpi_bus_unregister_driver(&acpi_vmgenid_driver);
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/vmgenid.c: At top level:
drivers/misc/vmgenid.c:119:27: error: storage size of 'acpi_vmgenid_driver' isn't known
static struct acpi_driver acpi_vmgenid_driver = {
^~~~~~~~~~~~~~~~~~~
drivers/misc/vmgenid.c:114:36: warning: 'vmgenid_ids' defined but not used [-Wunused-variable]
static const struct acpi_device_id vmgenid_ids[] = {
^~~~~~~~~~~cc1: some warnings being treated as errors
vim +/name +120 drivers/misc/vmgenid.c
113
> 114 static const struct acpi_device_id vmgenid_ids[] = {
115 {"QEMUVGID", 0},
116 {"", 0},
117 };
118
119 static struct acpi_driver acpi_vmgenid_driver = {
> 120 .name = "vm_gen_counter",
> 121 .ids = vmgenid_ids,
> 122 .owner = THIS_MODULE,
> 123 .ops = {
124 .add = acpi_vmgenid_add,
125 .remove = acpi_vmgenid_remove,
126 }
127 };
128
129 static int __init vmgenid_init(void)
130 {
> 131 return acpi_bus_register_driver(&acpi_vmgenid_driver);
132 }
133
134 static void __exit vmgenid_exit(void)
135 {
> 136 acpi_bus_unregister_driver(&acpi_vmgenid_driver); 137 }
138
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botThank you for the patch! Yet something to improve:
Hi Or,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.16-rc3 next-20180228]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Or-Idgar/drivers-virt-vm_gen_counter-initial-driver-implementation/20180227-050111
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sh
All errors (new ones prefixed by >>):
drivers/misc/vmgenid.c: In function 'acpi_vmgenid_add':
>> drivers/misc/vmgenid.c:102:29: error: dereferencing pointer to incomplete type 'struct acpi_device'
retval = get_vmgenid(device->handle);
^~
drivers/misc/vmgenid.c: At top level:
>> drivers/misc/vmgenid.c:114:36: error: array type has incomplete element type 'struct acpi_device_id'
static const struct acpi_device_id vmgenid_ids[] = {
^~~~~~~~~~~
>> drivers/misc/vmgenid.c:119:15: error: variable 'acpi_vmgenid_driver' has initializer but incomplete type
static struct acpi_driver acpi_vmgenid_driver = {
^~~~~~~~~~~
>> drivers/misc/vmgenid.c:120:3: error: 'struct acpi_driver' has no member named 'name'
.name = "vm_gen_counter",
^~~~
drivers/misc/vmgenid.c:120:10: warning: excess elements in struct initializer
.name = "vm_gen_counter",
^~~~~~~~~~~~~~~~
drivers/misc/vmgenid.c:120:10: note: (near initialization for 'acpi_vmgenid_driver')
>> drivers/misc/vmgenid.c:121:3: error: 'struct acpi_driver' has no member named 'ids'
.ids = vmgenid_ids,
^~~
drivers/misc/vmgenid.c:121:9: warning: excess elements in struct initializer
.ids = vmgenid_ids,
^~~~~~~~~~~
drivers/misc/vmgenid.c:121:9: note: (near initialization for 'acpi_vmgenid_driver')
>> drivers/misc/vmgenid.c:122:3: error: 'struct acpi_driver' has no member named 'owner'
.owner = THIS_MODULE,
^~~~~
In file included from include/linux/linkage.h:7:0,
from include/linux/kernel.h:7,
from include/linux/list.h:9,
from include/linux/module.h:9,
from drivers/misc/vmgenid.c:12:
include/linux/export.h:35:21: warning: excess elements in struct initializer
#define THIS_MODULE (&__this_module)
^
drivers/misc/vmgenid.c:122:11: note: in expansion of macro 'THIS_MODULE'
.owner = THIS_MODULE,
^~~~~~~~~~~
include/linux/export.h:35:21: note: (near initialization for 'acpi_vmgenid_driver')
#define THIS_MODULE (&__this_module)
^
drivers/misc/vmgenid.c:122:11: note: in expansion of macro 'THIS_MODULE'
.owner = THIS_MODULE,
^~~~~~~~~~~
>> drivers/misc/vmgenid.c:123:3: error: 'struct acpi_driver' has no member named 'ops'
.ops = {
^~~
>> drivers/misc/vmgenid.c:123:9: error: extra brace group at end of initializer
.ops = {
^
drivers/misc/vmgenid.c:123:9: note: (near initialization for 'acpi_vmgenid_driver')
drivers/misc/vmgenid.c:123:9: warning: excess elements in struct initializer
drivers/misc/vmgenid.c:123:9: note: (near initialization for 'acpi_vmgenid_driver')
drivers/misc/vmgenid.c: In function 'vmgenid_init':
>> drivers/misc/vmgenid.c:131:9: error: implicit declaration of function 'acpi_bus_register_driver'; did you mean 'acpi_nvs_register'? [-Werror=implicit-function-declaration]
return acpi_bus_register_driver(&acpi_vmgenid_driver);
^~~~~~~~~~~~~~~~~~~~~~~~
acpi_nvs_register
drivers/misc/vmgenid.c: In function 'vmgenid_exit':
>> drivers/misc/vmgenid.c:136:2: error: implicit declaration of function 'acpi_bus_unregister_driver'; did you mean 'bus_unregister_notifier'? [-Werror=implicit-function-declaration]
acpi_bus_unregister_driver(&acpi_vmgenid_driver);
^~~~~~~~~~~~~~~~~~~~~~~~~~
bus_unregister_notifier
drivers/misc/vmgenid.c: At top level:
>> drivers/misc/vmgenid.c:119:27: error: storage size of 'acpi_vmgenid_driver' isn't known
static struct acpi_driver acpi_vmgenid_driver = {
^~~~~~~~~~~~~~~~~~~
drivers/misc/vmgenid.c:114:36: warning: 'vmgenid_ids' defined but not used [-Wunused-variable]
static const struct acpi_device_id vmgenid_ids[] = {
^~~~~~~~~~~cc1: some warnings being treated as errors
vim +102 drivers/misc/vmgenid.c
95
96 static int acpi_vmgenid_add(struct acpi_device *device)
97 {
98 int retval;
99
100 if (!device)
101 return -EINVAL;
> 102 retval = get_vmgenid(device->handle);
103 if (retval < 0)
104 return retval;
105 return sysfs_create_group(hypervisor_kobj, &vmgenid_group);
106 }
107
108 static int acpi_vmgenid_remove(struct acpi_device *device)
109 {
110 sysfs_remove_group(hypervisor_kobj, &vmgenid_group);
111 return 0;
112 }
113
> 114 static const struct acpi_device_id vmgenid_ids[] = {
115 {"QEMUVGID", 0},
116 {"", 0},
117 };
118
> 119 static struct acpi_driver acpi_vmgenid_driver = {
> 120 .name = "vm_gen_counter",
> 121 .ids = vmgenid_ids,
> 122 .owner = THIS_MODULE,
> 123 .ops = {
124 .add = acpi_vmgenid_add,
125 .remove = acpi_vmgenid_remove,
126 }
127 };
128
129 static int __init vmgenid_init(void)
130 {
> 131 return acpi_bus_register_driver(&acpi_vmgenid_driver);
132 }
133
134 static void __exit vmgenid_exit(void)
135 {
> 136 acpi_bus_unregister_driver(&acpi_vmgenid_driver); 137 }
138
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation