summaryrefslogtreecommitdiffstats
path: root/usr.sbin/vmctl/main.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Remove superflouus mmcpy()dv2021-04-021-2/+1
| | | | Reported by Preben Guldberg. ok mlarkin@
* Simplify argument parsing of vmctl stoptb2021-03-261-15/+10
| | | | | | | | | | | | The previous argument parsing logic had at least three bugs: a copy-paste error led to an off-by-one and a printf "%s" NULL, as reported by Preben Guldberg. A previous commit led to a dead else branch and a use of uninitialized. This can all be avoided by reworking the logic so as to be readable. Prompted by a diff from Preben ok dv
* vmctl(8): fix vmctl send exit codepd2020-01-031-1/+2
| | | | | | | vmctl send always returned exit code 1 Patch by Benjamin Baier ok kn@
* Run cu(1) in restricted modekn2019-12-281-2/+3
| | | | | | | | | | | Users must not not be able to transfer files from the local hypervisor filesystem to VMs/LDOMs, especially since the "vmctl/ldomctl console ..." might be run as root. Disable all relevant escape sequences and cause cu to run under "stdio tty" pledge by using -r. OK deraadt mlarkin
* Use local variable isntead of function parameterkn2019-12-171-4/+6
| | | | | | | | | | The parse_size() wrapper around scan_scaled(3) writes its intermediate result to the function argument which is always passed as literal zero. This seems odd, the function parameter has no meaning but merely serves as storage, so let's use a proper function scoped variable instead. OK pd
* Require at least one interface with -ikn2019-10-271-3/+3
| | | | | | | | | | Either a positive count is given or -i is omitted entirely; vm.conf(5) does not allow interface configuration that results in zero interfaces either. Raise the minimium count value to one and tell more about invalid counts with the usual strtonum(3) idiom. OK reyk
* vmctl(8): fix wrong output when using 'vmctl stop'mlarkin2019-08-231-2/+5
| | | | | | | | Fix a wrong output when using 'vmctl stop' without any further arguments. Patch from Caspar Schutijser, thanks! ok deraadt
* zap an extra space in usage();jmc2019-07-051-2/+2
| | | | from alessandro gallo
* Change vmctl(8) syntax: command options before the disk/name/id argument.reyk2019-05-291-40/+23
| | | | | | | | | | | | | | | vmctl had a CLI-style syntax (bgpctl-style) for a short time but I changed it back to a more suitable getopt syntax. I replaced the CLI tokens to getopts flags but didn't consider swapping the order of command options and arguments to be more UNIX-like again ("vmctl create disk.img size 10G" simply became "vmctl create disk.img -s 10G"). This changes "create", "start", and "stop" commands to the commonly expected syntax like "vmctl create -s 10G disk.img". Requested by many OK mlarkin@ kn@ solene@
* An existing VM may be started by referencing its IDkn2019-03-181-2/+2
| | | | | | | | Document `vmctl start id ...' again but be clear about the difference between starting new and existing VMs by name and ID respectively. This completes what I started with vmctl.8 revision 1.61. Feedback and OK jmc
* Fix previous extra arguments commitkn2019-03-011-1/+7
| | | | | | | | | I blatantly missed the argc/argv adjustments after getopt(3), resulting in valid commands like `vmctl create a -s 1G' to fail. Noticed by ajacoutot the hard way. OK ajacoutot jca
* Print usage on extra create, start and stop argumentskn2019-03-011-1/+10
| | | | OK mlarkin
* sync usage(); also, stop enclosing arg names in quotes, since it wasjmc2018-12-141-13/+13
| | | | | | | applied inconsistently, and applied consistently would make it look like spaghetti; ok mlarkin
* Extend vmctl start -B argument to work for disk, cdrom and net.claudio2018-12-111-2/+8
| | | | | | Currently SeaBIOS will respect disk and cdrom and our kernel will understand net. OK ccardenas@, reyk@, mlarkin@
* Add a new argument -B device to vmctl start. It allows to set the boot device.claudio2018-12-061-4/+10
| | | | | | | 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@
* Add 'vmctl wait <VM>' a command that waits until the specified VM isclaudio2018-12-041-3/+26
| | | | | | stopped/terminates. Useful in scripts when waiting until a vm has finished its work. Ok ccardenas@, reyk@
* Move the {qcow2,raw} create functions from vmctl into vmd/vio{qcow2,raw}.creyk2018-11-261-2/+2
| | | | | | This way they are in the appropriate place and code can be shared with vmd. Ok ori@ mlarkin@ ccardenas@
* Add support to create and convert disk images from existing imagesreyk2018-10-191-22/+168
| | | | | | | | | | | | | | The -i option to vmctl create (eg. vmctl create output.qcow2 -i input.img) lets you create a new image from an input file and convert it if it is a different format. This allows to convert qcow2 images from raw images, raw from qcow2, or even qcow2 from qcow2 and raw from raw to re-optimize the disk. This re-uses Ori's vioqcow2.c from vmd by reaching into it and compiling it in. The API has been adjust to be used from both vmctl and vmd accordingly. OK mlarkin@
* Add support for qcow2 base images (external snapshots).reyk2018-10-081-14/+23
| | | | | | | | | | | | | | | | | | | | | This works is from Ori Bernstein, committing on his behalf: Add support to vmd for external snapshots. That is, snapshots that are derived from a base image. Data lookups start in the derived image, and if the derived image does not contain some data, the search proceeds ot the base image. Multiple derived images may exist off of a single base image. A limitation of this format is that modifying the base image will corrupt the derived image. This change also adds support for creating disk derived disk images to vmctl. To use it: vmctl create derived.qcow2 -s 16G -b base.qcow2 From Ori Bernstein OK mlarkin@ reyk@
* Setting getopt optreset to 1 needs an additional reset of optind to 1.reyk2018-10-051-1/+2
| | | | OK millert@
* Try to derive the qcow2 file format from an image file automatically.reyk2018-10-011-29/+66
| | | | | | | | | | | | | | This makes the "-d qcow2:" and "format qcow" arguments optional as vmctl and vmd will read the magic bytes at the beginning of a file to guess if it is a raw or a qcow image file. The "vmctl create" command has been changed by removing the -f qcow2 option and replacing it with the same syntax as -d: "vmctl create qcow2:foo.img". In a slightly ununixy but intended way, the create command now also considers the file extension for the format as "vmctl create foo.qcow2" creates a qcow2 disk and not a raw image file. Ok mlarkin@ (and ccardenas@ on an earlier version of the diff)
* Add vmctl stop -a [-fw] option to stop or terminate all running VMs.reyk2018-09-271-13/+24
| | | | | | This is also be used to simplify the vmd rc stop script. OK mlarkin@ ccardenas@
* Add initial set of unveil's to vmctl.ccardenas2018-09-131-4/+12
| | | | | | Was in snaps for a while. Ok mlarkin@ and reyk@
* Add ability to create qcow2 disk.ccardenas2018-09-111-5/+15
| | | | | | | vmctl create now takes an optional disk format parameter: raw or qcow2. If format is omitted, raw is used. Many thanks to Ori Bernstein.
* Add initial qcow2 image support.ccardenas2018-09-091-8/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Users are able to declare disk images as 'raw' or 'qcow2' using either vmctl and vm.conf. The default disk image format is 'raw' if not specified. Examples of using disk format: vmctl start bsd -Lc -r cd64.iso -d qcow2:current.qc2 or vmctl start bsd -Lc -r cd64.iso -d raw:current.raw is equivalent to vmctl start bsd -Lc -r cd64.iso -d current.raw in vm.conf vm "current" { disable memory 2G disk "/home/user/vmm/current.qc2" format "qcow2" interface { switch "external" } } or vm "current" { disable memory 2G disk "/home/user/vmm/current.raw" format "raw" interface { switch "external" } } is equivlanet to vm "current" { disable memory 2G disk "/home/user/vmm/current.raw" interface { switch "external" } } Tested by many. Big Thanks to Ori Bernstein.
* The vmctl start -I option was changed to -t.reyk2018-07-121-7/+7
| | | | | | I committed the manpage but accidentally forgot the main.c part. OK ccardenas@
* Allow to use configured/running VMs as templates for other VM instances.reyk2018-07-121-4/+23
| | | | | | | | | This introduces new grammar and the -t optional in vmctl start. (For now, only root can create VM instances; but it is planned to allow users to create their own VMs based on permissions and quota.) OK ccardenas@ mlarkin@ jmc@
* Add -w option to vmctl stop to wait for completion of VM termination.reyk2018-07-111-6/+12
| | | | | | Use it in /etc/rc.d/vmd accordingly. OK sthen@
* Add -f option to vmctl stop to forcefully kill a VM.reyk2018-07-111-7/+23
| | | | | | | | This also fixes a bug in vmm_sighdlr where it might have missed forwarding the TERMINATE_EVENT to the vmd parent after a VM child died, leading to an abandoned VM in the vmd parent process. OK ccardenas@ mlarkin@ benno@ kn@
* add an alias for vmctl show, matches finger memory and the rest of thephessler2018-02-241-1/+2
| | | | | | *ctl programs OK mlarkin@ benno@ deraadt@
* Add initial CD-ROM support to VMD via vioscsi.ccardenas2018-01-031-4/+14
| | | | | | | | | | | | | * 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@
* Prefer memset() over bzero()guenther2017-10-071-2/+2
| | | | ok deraadt@ mlarkin@
* merge parse_vmid() and parse_vmname()jasper2017-08-151-37/+15
| | | | ok mlarkin@ pd@
* Add vmctl send and vmctl receivepd2017-07-151-1/+70
| | | | ok reyk@ and mlarkin@
* vmd/vmctl: Add ability to pause / unpause vmspd2017-07-091-1/+41
| | | | | | With help from Ashwin Agrawal ok reyk@ mlarkin@
* vmctl: change default "vmctl console" (cu) baud rate to 115200. Notmlarkin2017-06-071-2/+2
| | | | | | | strictly needed but matches the previous baudrate diff committed earlier to vmd. ok deraadt, phessler
* Report command failure back to vmctl reload, reset, load, log verbose.reyk2017-05-041-2/+6
| | | | OK mlarkin@
* Report error for vmctl commands that need root privileges.reyk2017-05-041-11/+4
| | | | | | specifically: vmctl (load|reload|reset|log) Reported by Christian Barthel
* Add support for dynamic "NAT" interfaces (-L/local interface).reyk2017-04-191-3/+7
| | | | | | | | | | | | | When a local interface is configured, vmd configures a /31 address on the tap(4) interface of the host and provides another IP in the same subnet via DHCP (BOOTP) to the VM. vmd runs an internal BOOTP server that replies with IP, gateway, and DNS addresses to the VM. The built-in server only ever responds to the VM on the inside and cannot leak its DHCP responses to the outside. Thanks to Uwe Werler, Josh Grosse, and some others for testing! OK deraadt@
* Do not expose vmm(4) VM IDs to the user, use vmd(8)'s IDs instead.reyk2017-04-061-5/+6
| | | | | | | | | | | | | Each VM has two IDs: one from the kernel (vmm) and a different one from userland (vmd). The vmm ID is not consistent and incremented on every boot during runtimg of the host system. The vmd ID remains the same during the lifetime of a configured VM, even after reboots. Configured VMs will even get and keep their IDs when the configuration is loaded. This is more what users expect. Pointed out and tested by otto@ OK deraadt@
* Boot using BIOS from /etc/firmware/vmm-bios by default.reyk2017-03-251-9/+9
| | | | | | | | | | | | | | | | Instead of using the internal "vmboot", VMs will now be booted using the external BIOS firmware in /etc/firmware/vmm-bios (which is subject to a LGPLv3 license). Direct booting of OpenBSD kernels or non-default BIOS images is still supported for now using the -b/boot option that is replacing the -k/kernel option. As requested by Theo, vmd(8) fails if neither the default BIOS is found nor a kernel has been specified in the VM configuration. The "vmm" BIOS has to be installed using fw_update(1), which will be done automatically in most cases where the OpenBSD can fetch it after install/upgrade. OK mlarkin@
* Rename start_vm_complete to vm_start_complete for consistency.reyk2017-03-011-2/+2
|
* unbreak vmctl build by renaming a function that now conflicts withmlarkin2017-03-011-2/+2
| | | | | something from vmd.h . Temporary fix until the original committer can fix it the way he desires.
* Add "owner" option to set a user/group ownership for pre-configured VMsreyk2017-03-011-2/+2
| | | | | | | This allows matching users to start or stop VMs that they "own" and to access the console accordingly. OK mlarkin@
* Add imsg communication channel between vmd and invividual VMs.reyk2017-01-111-1/+24
| | | | | | | For now, this is only used to forward "log verbose|brief" requests, but it will be used for better things later. OK mlarkin@
* Add the vmctl start -n option to specify add a network interface toreyk2016-11-261-5/+41
| | | | | | the specified virtual switch from the command line. OK mlarkin@
* Fix functionality and semantics of vmctl load/reload/reset.reyk2016-10-121-15/+47
| | | | OK rzalamena@
* move some argument checking from vmmaction() to start_vm()mlarkin2016-05-101-15/+1
| | | | from a diff posted to tech@ by Fabien Siron, thanks.
* make vmctl 'create' usage description match the man pagemlarkin2016-04-251-2/+2
|
* Last parameter to execl[e]() functions *must* be cast to a pointer.krw2016-03-171-2/+2
| | | | | | | | | | | | Just NULL is not good practise as NULL is theoretically allowed to be an integer rather than a pointer. Use (char *)NULL consistently instead of scattering a few (char *)0 and (void *)NULL into the mix. Prompted by and probably ok deraadt@ millert@ kettenis@ Definitely ok mestre@ ratchov@