diff options
author | ccardenas <ccardenas@openbsd.org> | 2018-01-03 05:39:56 +0000 |
---|---|---|
committer | ccardenas <ccardenas@openbsd.org> | 2018-01-03 05:39:56 +0000 |
commit | 95ab188f112e9222b375a8ba5e758d43cbe60f74 (patch) | |
tree | 7fbcf54a8b3658689db8aa8d37c436d9917a4d99 /usr.sbin/vmctl | |
parent | Add remap_bynode() since I use it in the rkpcie(4) implementation. (diff) | |
download | wireguard-openbsd-95ab188f112e9222b375a8ba5e758d43cbe60f74.tar.xz wireguard-openbsd-95ab188f112e9222b375a8ba5e758d43cbe60f74.zip |
Add initial CD-ROM support to VMD via vioscsi.
* Adds 'cdrom' keyword to vm.conf(5) and '-r' to vmctl(8)
* Support various sized ISOs (Limitation of 4G ISOs on Linux guests)
* Known working guests: OpenBSD (primary), Alpine Linux (primary),
CentOS 6 (secondary), Ubuntu 17.10 (secondary).
NOTE: Secondary indicates some issue(s) preventing full/reliable
functionality outside the scope of the vioscsi work.
* If the attached disks are non-bootable (i.e. empty), SeaBIOS (vmd's
default BIOS) will boot from CD-ROM.
ok mlarkin@, jca@
Diffstat (limited to 'usr.sbin/vmctl')
-rw-r--r-- | usr.sbin/vmctl/main.c | 18 | ||||
-rw-r--r-- | usr.sbin/vmctl/vmctl.8 | 9 | ||||
-rw-r--r-- | usr.sbin/vmctl/vmctl.c | 19 | ||||
-rw-r--r-- | usr.sbin/vmctl/vmctl.h | 5 |
4 files changed, 41 insertions, 10 deletions
diff --git a/usr.sbin/vmctl/main.c b/usr.sbin/vmctl/main.c index 91fac99b48c..329504638e3 100644 --- a/usr.sbin/vmctl/main.c +++ b/usr.sbin/vmctl/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.33 2017/10/07 19:48:30 guenther Exp $ */ +/* $OpenBSD: main.c,v 1.34 2018/01/03 05:39:56 ccardenas Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -69,7 +69,7 @@ struct ctl_command ctl_commands[] = { { "reload", CMD_RELOAD, ctl_reload, "" }, { "reset", CMD_RESET, ctl_reset, "[all|vms|switches]" }, { "start", CMD_START, ctl_start, "\"name\"" - " [-Lc] [-b image] [-m size]\n" + " [-Lc] [-b image] [-r image] [-m size]\n" "\t\t[-n switch] [-i count] [-d disk]*" }, { "status", CMD_STATUS, ctl_status, "[id]" }, { "stop", CMD_STOP, ctl_stop, "id" }, @@ -203,7 +203,8 @@ vmmaction(struct parse_result *res) switch (res->action) { case CMD_START: ret = vm_start(res->id, res->name, res->size, res->nifs, - res->nets, res->ndisks, res->disks, res->path); + res->nets, res->ndisks, res->disks, res->path, + res->isopath); if (ret) { errno = ret; err(1, "start VM operation failed"); @@ -324,6 +325,7 @@ parse_free(struct parse_result *res) free(res->name); free(res->path); + free(res->isopath); for (i = 0; i < res->ndisks; i++) free(res->disks[i]); free(res->disks); @@ -571,7 +573,7 @@ ctl_start(struct parse_result *res, int argc, char *argv[]) argc--; argv++; - while ((ch = getopt(argc, argv, "b:cLm:n:d:i:")) != -1) { + while ((ch = getopt(argc, argv, "b:r:cLm:n:d:i:")) != -1) { switch (ch) { case 'b': if (res->path) @@ -581,6 +583,14 @@ ctl_start(struct parse_result *res, int argc, char *argv[]) if ((res->path = strdup(path)) == NULL) errx(1, "strdup"); break; + case 'r': + if (res->isopath) + errx(1, "iso image specified multiple times"); + if (realpath(optarg, path) == NULL) + err(1, "invalid iso image path"); + if ((res->isopath = strdup(path)) == NULL) + errx(1, "strdup"); + break; case 'c': tty_autoconnect = 1; break; diff --git a/usr.sbin/vmctl/vmctl.8 b/usr.sbin/vmctl/vmctl.8 index 2efcf035531..bcdbca3d9ad 100644 --- a/usr.sbin/vmctl/vmctl.8 +++ b/usr.sbin/vmctl/vmctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: vmctl.8,v 1.35 2017/11/05 20:01:09 reyk Exp $ +.\" $OpenBSD: vmctl.8,v 1.36 2018/01/03 05:39:56 ccardenas Exp $ .\" .\" Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 5 2017 $ +.Dd $Mdocdate: January 3 2018 $ .Dt VMCTL 8 .Os .Sh NAME @@ -84,6 +84,7 @@ to standard output and terminate it. .It Xo Cm start Ar name .Op Fl Lc .Op Fl b Ar path +.Op Fl r Ar path .Op Fl d Ar path .Op Fl i Ar count .Op Fl m Ar size @@ -126,6 +127,10 @@ See in .Xr vm.conf 5 for more information. +.It Fl r Ar path +ISO image file for virtual CD-ROM. This image file will be available in the +selected VM as a SCSI CD-ROM device attached to a virtio SCSI adapter (eg. +.Xr vioscsi 4 ) .El .Pp Note that the VM name supplied to the 'start' command can only consist of diff --git a/usr.sbin/vmctl/vmctl.c b/usr.sbin/vmctl/vmctl.c index c6cd8e3dc8a..fbe0ff66a7e 100644 --- a/usr.sbin/vmctl/vmctl.c +++ b/usr.sbin/vmctl/vmctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmctl.c,v 1.44 2017/09/08 07:08:49 mlarkin Exp $ */ +/* $OpenBSD: vmctl.c,v 1.45 2018/01/03 05:39:56 ccardenas Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> @@ -61,6 +61,7 @@ int info_console; * ndisks: number of disk images * disks: disk image file names * kernel: kernel image to load + * iso: iso image file * * Return: * 0 if the request to start the VM was sent successfully. @@ -68,7 +69,7 @@ int info_console; */ int vm_start(uint32_t start_id, const char *name, int memsize, int nnics, - char **nics, int ndisks, char **disks, char *kernel) + char **nics, int ndisks, char **disks, char *kernel, char *iso) { struct vmop_create_params *vmc; struct vm_create_params *vcp; @@ -84,6 +85,8 @@ vm_start(uint32_t start_id, const char *name, int memsize, int nnics, flags |= VMOP_CREATE_DISK; if (kernel) flags |= VMOP_CREATE_KERNEL; + if (iso) + flags |= VMOP_CREATE_CDROM; if (flags != 0) { if (memsize < 1) memsize = VM_DEFAULT_MEMORY; @@ -155,6 +158,9 @@ vm_start(uint32_t start_id, const char *name, int memsize, int nnics, if (kernel != NULL) strlcpy(vcp->vcp_kernel, kernel, VMM_MAX_KERNEL_PATH); + if (iso != NULL) + strlcpy(vcp->vcp_cdrom, iso, VMM_MAX_PATH_CDROM); + imsg_compose(ibuf, IMSG_VMDOP_START_VM_REQUEST, 0, 0, -1, vmc, sizeof(struct vmop_create_params)); @@ -209,6 +215,15 @@ vm_start_complete(struct imsg *imsg, int *ret, int autoconnect) "not regular files"); *ret = ENOENT; break; + case VMD_CDROM_MISSING: + warnx("could not find specified iso image"); + *ret = ENOENT; + break; + case VMD_CDROM_INVALID: + warnx("specified iso image is " + "not a regular file"); + *ret = ENOENT; + break; default: errno = res; warn("start vm command failed"); diff --git a/usr.sbin/vmctl/vmctl.h b/usr.sbin/vmctl/vmctl.h index 0fc019e9eeb..203c89b85e8 100644 --- a/usr.sbin/vmctl/vmctl.h +++ b/usr.sbin/vmctl/vmctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmctl.h,v 1.17 2017/08/15 15:51:54 jasper Exp $ */ +/* $OpenBSD: vmctl.h,v 1.18 2018/01/03 05:39:56 ccardenas Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -45,6 +45,7 @@ struct parse_result { uint32_t id; char *name; char *path; + char *isopath; long long size; int nifs; char **nets; @@ -82,7 +83,7 @@ __dead void /* vmctl.c */ int create_imagefile(const char *, long); int vm_start(uint32_t, const char *, int, int, char **, int, - char **, char *); + char **, char *, char *); int vm_start_complete(struct imsg *, int *, int); void terminate_vm(uint32_t, const char *); int terminate_vm_complete(struct imsg *, int *); |