diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-11-26 18:37:33 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-11-26 18:37:33 +0000 |
commit | 3cf9ca9fe284de59d75237c4be11f2972f547154 (patch) | |
tree | a89ca6d1edcebf86e37a822229709a412ac309b7 /usr.sbin/vmctl/vmctl.c | |
parent | 54f0405fdc0795a9ecaffe10844aeb082cfaa451 (diff) |
Add the vmctl start -n option to specify add a network interface to
the specified virtual switch from the command line.
OK mlarkin@
Diffstat (limited to 'usr.sbin/vmctl/vmctl.c')
-rw-r--r-- | usr.sbin/vmctl/vmctl.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/vmctl/vmctl.c b/usr.sbin/vmctl/vmctl.c index 3f69c4b6bcf..79eadc2ff73 100644 --- a/usr.sbin/vmctl/vmctl.c +++ b/usr.sbin/vmctl/vmctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmctl.c,v 1.18 2016/11/24 07:58:55 reyk Exp $ */ +/* $OpenBSD: vmctl.c,v 1.19 2016/11/26 18:37:32 reyk Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> @@ -52,6 +52,7 @@ int info_console; * name: optional name of the VM * memsize: memory size (MB) of the VM to create * nnics: number of vionet network interfaces to create + * nics: switch names of the network interfaces to create * ndisks: number of disk images * disks: disk image file names * kernel: kernel image to load @@ -61,8 +62,8 @@ int info_console; * ENOMEM if a memory allocation failure occurred. */ int -start_vm(const char *name, int memsize, int nnics, int ndisks, char **disks, - char *kernel) +start_vm(const char *name, int memsize, int nnics, char **nics, + int ndisks, char **disks, char *kernel) { struct vmop_create_params *vmc; struct vm_create_params *vcp; @@ -78,6 +79,8 @@ start_vm(const char *name, int memsize, int nnics, int ndisks, char **disks, errx(1, "no kernel or disk specified"); if (nnics == -1) nnics = 0; + if (nnics > VMM_MAX_NICS_PER_VM) + errx(1, "too many network interfaces"); if (nnics == 0) warnx("starting without network interfaces"); @@ -97,15 +100,16 @@ start_vm(const char *name, int memsize, int nnics, int ndisks, char **disks, vcp->vcp_ncpus = 1; vcp->vcp_ndisks = ndisks; + vcp->vcp_nnics = nnics; for (i = 0 ; i < ndisks; i++) strlcpy(vcp->vcp_disks[i], disks[i], VMM_MAX_PATH_DISK); - + for (i = 0 ; i < nnics; i++) + strlcpy(vmc->vmc_ifswitch[i], nics[i], IF_NAMESIZE); if (name != NULL) strlcpy(vcp->vcp_name, name, VMM_MAX_NAME_LEN); if (kernel != NULL) strlcpy(vcp->vcp_kernel, kernel, VMM_MAX_KERNEL_PATH); - vcp->vcp_nnics = nnics; imsg_compose(ibuf, IMSG_VMDOP_START_VM_REQUEST, 0, 0, -1, vmc, sizeof(struct vmop_create_params)); |