1 /* $OpenBSD: vmctl.h,v 1.8 2016/09/03 20:49:05 deraadt Exp $ */ 2 3 /* 4 * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef VMCTL_PARSER_H 20 #define VMCTL_PARSER_H 21 22 #define VMCTL_CU "/usr/bin/cu" 23 24 enum actions { 25 NONE, 26 CMD_CONSOLE, 27 CMD_CREATE, 28 CMD_LOAD, 29 CMD_RELOAD, 30 CMD_START, 31 CMD_STATUS, 32 CMD_STOP, 33 }; 34 35 struct ctl_command; 36 37 struct parse_result { 38 enum actions action; 39 uint32_t id; 40 char *name; 41 char *path; 42 long long size; 43 int nifs; 44 size_t ndisks; 45 char **disks; 46 int disable; 47 struct ctl_command *ctl; 48 }; 49 50 struct ctl_command { 51 const char *name; 52 enum actions action; 53 int (*main)(struct parse_result *, int, char *[]); 54 const char *usage; 55 int has_pledge; 56 }; 57 58 struct imsgbuf *ibuf; 59 60 /* main.c */ 61 int vmmaction(struct parse_result *); 62 int parse_ifs(struct parse_result *, char *, int); 63 int parse_size(struct parse_result *, char *, long long); 64 int parse_disk(struct parse_result *, char *); 65 int parse_vmid(struct parse_result *, char *); 66 void parse_free(struct parse_result *); 67 int parse(int, char *[]); 68 __dead void 69 ctl_openconsole(const char *); 70 71 /* vmctl.c */ 72 int create_imagefile(const char *, long); 73 int start_vm(const char *, int, int, int, char **, char *); 74 int start_vm_complete(struct imsg *, int *, int); 75 void terminate_vm(uint32_t, const char *); 76 int terminate_vm_complete(struct imsg *, int *); 77 int check_info_id(const char *, uint32_t); 78 void get_info_vm(uint32_t, const char *, int); 79 int add_info(struct imsg *, int *); 80 void print_vm_info(struct vmop_info_result *, size_t); 81 __dead void 82 vm_console(struct vmop_info_result *, size_t); 83 84 #endif /* VMCTL_PARSER_H */ 85