diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2018-12-06 09:23:16 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2018-12-06 09:23:16 +0000 |
commit | 97bef4c1d0b92215e63006d754555d38107418d3 (patch) | |
tree | 5148d75af81a48b7ceb800d0f4684e77a71ae406 | |
parent | 232ccf2186c725c6c77341f3b4bed35c91d322d2 (diff) |
Add a new argument -B device to vmctl start. It allows to set the boot device.
At the moment only 'net' is supported and all other values are silently ignored.
This allows to kick of an OpenBSD autoinstall by using:
vmctl start "installer" -Lc -B net -b bsd.rd -d disk.img
OK ccardenas@
-rw-r--r-- | usr.sbin/vmctl/main.c | 14 | ||||
-rw-r--r-- | usr.sbin/vmctl/vmctl.8 | 14 | ||||
-rw-r--r-- | usr.sbin/vmctl/vmctl.c | 5 | ||||
-rw-r--r-- | usr.sbin/vmctl/vmctl.h | 5 |
4 files changed, 28 insertions, 10 deletions
diff --git a/usr.sbin/vmctl/main.c b/usr.sbin/vmctl/main.c index 7a7f5d874d7..6269f2c24e3 100644 --- a/usr.sbin/vmctl/main.c +++ b/usr.sbin/vmctl/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.49 2018/12/04 08:17:17 claudio Exp $ */ +/* $OpenBSD: main.c,v 1.50 2018/12/06 09:23:15 claudio Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -79,7 +79,7 @@ struct ctl_command ctl_commands[] = { { "reset", CMD_RESET, ctl_reset, "[all|vms|switches]" }, { "show", CMD_STATUS, ctl_status, "[id]" }, { "start", CMD_START, ctl_start, "\"name\"" - " [-Lc] [-b image] [-r image] [-m size]\n" + " [-Lc] [-b image] [-B device] [-r image] [-m size]\n" "\t\t[-n switch] [-i count] [-d disk]* [-t name]" }, { "status", CMD_STATUS, ctl_status, "[id]" }, { "stop", CMD_STOP, ctl_stop, "[id|-a] [-fw]" }, @@ -224,7 +224,7 @@ vmmaction(struct parse_result *res) case CMD_START: ret = vm_start(res->id, res->name, res->size, res->nifs, res->nets, res->ndisks, res->disks, res->disktypes, - res->path, res->isopath, res->instance); + res->path, res->isopath, res->instance, res->bootdevice); if (ret) { errno = ret; err(1, "start VM operation failed"); @@ -843,7 +843,7 @@ ctl_start(struct parse_result *res, int argc, char *argv[]) argc--; argv++; - while ((ch = getopt(argc, argv, "b:r:cLm:n:d:i:t:")) != -1) { + while ((ch = getopt(argc, argv, "b:B:cd:i:Lm:n:r:t:")) != -1) { switch (ch) { case 'b': if (res->path) @@ -853,6 +853,12 @@ ctl_start(struct parse_result *res, int argc, char *argv[]) if ((res->path = strdup(path)) == NULL) errx(1, "strdup"); break; + case 'B': + if (res->bootdevice) + errx(1, "boot device specified multiple times"); + if (strcmp("net", optarg) == 0) + res->bootdevice = VMBOOTDEV_NET; + break; case 'r': if (res->isopath) errx(1, "iso image specified multiple times"); diff --git a/usr.sbin/vmctl/vmctl.8 b/usr.sbin/vmctl/vmctl.8 index 9ff53217599..75bd987cb3b 100644 --- a/usr.sbin/vmctl/vmctl.8 +++ b/usr.sbin/vmctl/vmctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: vmctl.8,v 1.55 2018/12/04 08:17:17 claudio Exp $ +.\" $OpenBSD: vmctl.8,v 1.56 2018/12/06 09:23:15 claudio 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: December 4 2018 $ +.Dd $Mdocdate: December 6 2018 $ .Dt VMCTL 8 .Os .Sh NAME @@ -143,6 +143,7 @@ command. .It Xo Cm start Ar name .Op Fl cL .Op Fl b Ar path +.Op Fl B Ar device .Op Fl d Ar disk .Op Fl i Ar count .Op Fl m Ar size @@ -158,6 +159,15 @@ Starts a VM defined by the specified name and parameters: Boot the VM with the specified kernel or BIOS image. If not specified, the default is to boot using the BIOS image in .Pa /etc/firmware/vmm-bios . +.It Fl B Ar device +Force system to boot from the specified device for the next boot. +.Ar device +can be set to +.Ar net +to perform a PXE boot using the first network interface. +Currently only supported when starting the VM with +.Fl b +specifying a kernel image. .It Fl c Automatically connect to the VM console. .It Fl d Ar disk diff --git a/usr.sbin/vmctl/vmctl.c b/usr.sbin/vmctl/vmctl.c index 334f43968c8..68e6c1d6a97 100644 --- a/usr.sbin/vmctl/vmctl.c +++ b/usr.sbin/vmctl/vmctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmctl.c,v 1.64 2018/12/04 08:17:17 claudio Exp $ */ +/* $OpenBSD: vmctl.c,v 1.65 2018/12/06 09:23:15 claudio Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> @@ -73,7 +73,7 @@ unsigned int info_flags; int vm_start(uint32_t start_id, const char *name, int memsize, int nnics, char **nics, int ndisks, char **disks, int *disktypes, char *kernel, - char *iso, char *instance) + char *iso, char *instance, unsigned int bootdevice) { struct vmop_create_params *vmc; struct vm_create_params *vcp; @@ -184,6 +184,7 @@ vm_start(uint32_t start_id, const char *name, int memsize, int nnics, if (strlcpy(vmc->vmc_instance, instance, sizeof(vmc->vmc_instance)) >= sizeof(vmc->vmc_instance)) errx(1, "instance vm name too long"); + vmc->vmc_bootdevice = bootdevice; imsg_compose(ibuf, IMSG_VMDOP_START_VM_REQUEST, 0, 0, -1, vmc, sizeof(struct vmop_create_params)); diff --git a/usr.sbin/vmctl/vmctl.h b/usr.sbin/vmctl/vmctl.h index 420dc0c00fb..7c26b42d8cd 100644 --- a/usr.sbin/vmctl/vmctl.h +++ b/usr.sbin/vmctl/vmctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmctl.h,v 1.29 2018/12/04 08:17:17 claudio Exp $ */ +/* $OpenBSD: vmctl.h,v 1.30 2018/12/06 09:23:15 claudio Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -59,6 +59,7 @@ struct parse_result { char *instance; unsigned int flags; unsigned int mode; + unsigned int bootdevice; struct ctl_command *ctl; }; @@ -93,7 +94,7 @@ int create_imagefile(int, const char *, const char *, long, const char **); int create_raw_imagefile(const char *, long); int create_qc2_imagefile(const char *, const char *, long); int vm_start(uint32_t, const char *, int, int, char **, int, - char **, int *, char *, char *, char *); + char **, int *, char *, char *, char *, unsigned int); int vm_start_complete(struct imsg *, int *, int); void terminate_vm(uint32_t, const char *, unsigned int); int terminate_vm_complete(struct imsg *, int *, unsigned int); |