1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2022 Oxide Computer Company
14  */
15 
16 #include <stdio.h>
17 #include <unistd.h>
18 #include <stdlib.h>
19 #include <fcntl.h>
20 #include <libgen.h>
21 
22 #include <sys/vmm.h>
23 #include <sys/vmm_dev.h>
24 
25 int
26 main(int argc, char *argv[])
27 {
28 	const char *suite_name = basename(argv[0]);
29 
30 	int ctl_fd = open(VMM_CTL_DEV, O_EXCL | O_RDWR);
31 	if (ctl_fd < 0) {
32 		perror("could not open vmmctl device");
33 	}
34 
35 	int version = ioctl(ctl_fd, VMM_INTERFACE_VERSION, 0);
36 	if (version < 0) {
37 		perror("VMM_INTERFACE_VERSION ioctl failed");
38 	}
39 	if (version != VMM_CURRENT_INTERFACE_VERSION) {
40 		(void) fprintf(stderr, "kernel version %d != expected %d\n",
41 		    version, VMM_CURRENT_INTERFACE_VERSION);
42 		return (EXIT_FAILURE);
43 	}
44 
45 	(void) close(ctl_fd);
46 	(void) printf("%s\tPASS\n", suite_name);
47 	return (0);
48 }
49