summaryrefslogtreecommitdiffstats
path: root/usr.sbin/vmd/vmd.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Propagate host-side tap(4) lladdr to guest vm process to allow unicast dhcpdv2021-03-291-2/+21
| | | | | | | | | | and bootp renewals with vmd(8)'s built-in dhcp server. Previous behavior ignored did not intercept these packets and instead transmitted them. This should make vmd(8)'s dhcp behave more as a true dhcp server should and allows it to work properly with the new dhcpleased(8) attempting a renewal. OK mlarkin@
* these programs (with common ancestry) had a -fno-common problem relatedderaadt2021-01-271-1/+3
| | | | | to privsep_procid. ok mortimer
* Revert agentx support for now, we're too close to release.martijn2020-09-231-19/+3
| | | | requested by deraadt@
* Add support for agentx to vmd.martijn2020-09-231-3/+19
| | | | | This is based around VM-MIB from RFC7666,but does not export the full spec. People more knowledgeable of vmd are encouraged to expand on this.
* vmd: start vms defined in vm.conf in a staggered fashionpd2019-12-121-29/+53
| | | | | | | | | | | | This addresses 'thundering herd' problem when a lot of vms are configured in vm.conf. A lot of vms booting in parallel can overload the host and also mess up tsc calibration in openbsd guests as it uses PIT which doesn't fire reliably if the host is overloaded. We default to starting vms with parallelism of ncpuonline and a delay 30 seconds between batches. This is configurable in vm.conf. ok mlarkin@ (also addressed comments from cheloha@)
* vmd(8): memory leak in an error pathmlarkin2019-09-041-1/+2
| | | | Found by Hiltjo Posthuma, thanks!
* Improve the error message when supplying an invalid template to vmctlanton2019-08-141-2/+7
| | | | | | | start. Favoring 'invalid template' over 'permission denied' should give the user a better hint on what went wrong. ok kn@ mlarkin@
* When system calls indicate an error they return -1, not some arbitraryderaadt2019-06-281-2/+2
| | | | | | value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
* drop fatalx calls when claiming a new vm id; otherwise it's possiblejasper2019-05-201-15/+31
| | | | | | | | to crash vmd and take all other vms with it. this required a little shuffling to get the error value reported back to the caller to handle the error properly. ok mlarkin@
* report vm state through 'vmctl status'; whereas previously this would display the state ofjasper2019-05-111-8/+6
| | | | | | | the vcpu (which is why it got removed), it now actually reports the correct state (running, stopped, disabled, paused, etc) ok ccardenas@ mlarkin@
* vm_dump_header allocated space for a signature but it was never set;jasper2019-05-111-1/+5
| | | | | | set it to VMM_HV_SIGNATURE and check for it upon restoring a vm image ok mlarkin@ pd@
* track the state of the vm (running, paused, etc) using a single bitfield instead ofjasper2019-05-111-21/+21
| | | | | | | | | a handful of separate variables. this will makes it easier for vmd to report and check on the individual vm states no functional change intended ok ccardenas@ mlarkin@
* sync the vm state in vmd too when (un)pausing a vm, otherwise the vm processjasper2019-05-111-1/+3
| | | | | | knows the vm is paused, but vmd does not. ok mlarkin@ pd@
* When -B is used to specify a specific boot device also change the rebootclaudio2018-12-091-2/+3
| | | | | behaviour of vmd to stop / exit at guest reboot. OK ccardenas@
* Introduce IMSG_VMDOP_WAIT_VM_REQUEST a control message that registers aclaudio2018-12-041-1/+2
| | | | | | | vmctl peerid that should be informed when the VM is stopped (like when the guest does a shutdown). Uses the same logic as using the VMOP_WAIT flag on IMSG_VMDOP_TERMINATE_VM_REQUEST. Ok ccardenas@, reyk@
* Keep a list of known vms, and reuse the VM IDs.ori2018-11-261-5/+25
| | | | | | This means that when using '-L', the IP addresses of the VMs are stable. ok reyk@
* Add support for "local inet6" interfaces.reyk2018-11-211-1/+20
| | | | ok & test ccardenas@, additional review from kn@
* Prevent VM reboot loops by rate-limiting the interval a VM can reboot.reyk2018-10-151-1/+12
| | | | | | | | | | | | | | | | | | | This looping has been experienced by people who run VMs with a broken kernel or boot loader that trigger a very fast reboot loop (triple fault) of a VM that ends up using a lot of CPU and resources on the host. Some fixes in vmm(4) and vmd(8) helped to avoid such conditions but it can still occur if something is wrong in the guest VM itself. If the VM restarts after less than VM_START_RATE_SEC (6) seconds, we increment the limit counter. After VM_START_RATE_LIMIT (3) of suchs fast reboots the VM is stopped. There are only very few people who intentionally want to reboot-loop a VM very quickly (many times within a second); mostly for fuzzing. They will have to recompile and adjust the stated #defines in the code as we don't have a config option to disable it. OK mlarkin@
* Add support for qcow2 base images (external snapshots).reyk2018-10-081-7/+10
| | | | | | | | | | | | | | | | | | | | | 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@
* vmd: don't remove vm if sending failedpd2018-09-291-2/+19
| | | | | | | Fix a bug where a vm was removed in vmd.c after vmctl send even if sending failed. spotted by solene@ ok mlarkin@
* Fix copy-pasto to use maxmem instead of maxcpureyk2018-09-281-2/+2
| | | | | | Reported by Greg Steuck OK mlarkin@
* vmd(8) clould close file descriptor 0 as not all fd fields werebluhm2018-09-101-4/+4
| | | | | properly initialized with -1. Also avoid closing -1. OK mlarkin@
* During the fork+exec implementation, daemon(3) was moved afterbluhm2018-09-101-2/+3
| | | | | | | proc_init(). As a consequence vmd(8) child processes did not detach from the terminal anymore. Dup /dev/null to the stdio file descriptors in the children. OK mlarkin@ reyk@
* Track resources and enforce cpu/memory/interface limits for non-root users.reyk2018-07-151-1/+113
| | | | | | | | | The limits are currently hard-coded and undocumented (4 CPUs/VMs, 2G memory, 8 interfaces) but will be configurable in an upcoming diff. These limits are tracked in total usage; for example, a user will be able to run up to 4 VMs with 512M of memory or a single VM with 2G. OK ccardenas@ mlarkin@
* Check the disk/kernel/cdrom file permissions after openening the fd.reyk2018-07-131-34/+20
| | | | | | This prevents time of TOCTOU attacks for instances. OK mlarkin@
* Add "allow instance" option.reyk2018-07-131-45/+232
| | | | | | | | | | This allows users to create VM instances and change desired options, for example a user can be allowed to run a VM with all the pre-configured options but specify an own disk image. (mlarkin@ was fine with iterating over it) OK ccardenas@
* Allow to use configured/running VMs as templates for other VM instances.reyk2018-07-121-9/+161
| | | | | | | | | 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@
* style - indent each case statement in a switch.reyk2018-07-111-81/+86
|
* Add -w option to vmctl stop to wait for completion of VM termination.reyk2018-07-111-8/+21
| | | | | | Use it in /etc/rc.d/vmd accordingly. OK sthen@
* Rename function to vmd_check_vmhreyk2018-07-111-4/+4
|
* Add -f option to vmctl stop to forcefully kill a VM.reyk2018-07-111-2/+4
| | | | | | | | 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@
* style (single-line ifs don't need braces)reyk2018-07-101-4/+3
|
* vmd already had DEBUG/DPRINTF, there is no need for VMD_DEBUG/dprintfreyk2018-07-101-3/+3
| | | | Replace all occurences of dprintf with DPRINTF (defined in proc.h).
* Tweak debug log messagesreyk2018-07-101-27/+30
| | | | | | | | | | | | - Turn tracing messages into DPRINTF (only compiled with DEBUG). - Pass __func__ to vm_stop and vm_remove: this way we can track who called the function in the async context. It replaces the manual log_debug in front of each vm_stop/vm_remove. This debug logging trick can be removed in the future once we are more confident about it. OK ccardenas@ mlarkin@
* Add "socket owner" to allow changing the owner of the vmd control socket.reyk2018-06-261-1/+8
| | | | | | | | | | | This allows to open vmctl control or console access to other users that are not in group wheel. Access for non-root users still defaults to read-only actions unless you change the owner (user/group) of each individual VM. Requested by Mischa Peters OK mlarkin@
* knfreyk2018-06-191-13/+20
|
* vmd(8): enable pause / unpause for vm ownerspd2018-05-131-2/+7
| | | | | Patch from Mohamed Aslan. Thanks! ok kn@
* vmd(8)'s early error messages weren't visible when started via /etc/rcmlarkin2018-04-251-3/+2
| | | | | | | (such as errors relating to not having VMX/etc). Change the log_init to log to syslog so at least we have some chance of seeing these errors. requested and ok beck@
* spelling error in log messagemlarkin2018-04-211-3/+3
|
* Make sure that the global config is send out immediately when it ismartijn2018-03-291-9/+11
| | | | | | | loaded. This makes sure that the local prefix specied in the config is always used. OK ccardenas@
* block two VMs from using the same disk image file at the same time.mlarkin2018-03-141-2/+3
| | | | Also changes an error message in vmctl to reflect same.
* vmd: fix vmctl pause for non existing vm ids (never returns)pd2018-02-181-1/+5
| | | | | | | | | | | check if vm id is valid before sending to vmm for pausing. The 'lock' is caused by vmm sending back ENOENT for a non existent vm but vmd drops the message because it doesn't recogize the vmid vmm is talking about. This is an artifact of the 'policy' don't trust any imsg from a sibling priv sep process and do your own checking. reported by Abel Abraham Camarillo Ojeda ok mlarkin@ and ccardenas@
* Don't require "disk" or "kernel", also allow just "cdrom" instead, a VM cansthen2018-01-101-3/+4
| | | | still be useful with only cdrom storage. ok ccardenas@
* Enable TIOCUCNTL to be able to set ns8250's break detected condition.mpi2018-01-081-2/+11
| | | | | | | | | It is now possible to send BREAK commands to vmd(8) independently of the serial terminal emulator. Happy virtual ddb(4) hacking! No objection from mlarkin@, ok nicm@, ccardenas@, deraadt@
* Add initial CD-ROM support to VMD via vioscsi.ccardenas2018-01-031-1/+6
| | | | | | | | | | | | | * 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@
* Make vmd respect owner when starting non-disabled vms.abieber2017-12-061-4/+4
| | | | OK pd@, benno@
* When performing vmctl reload and a previously configured vm is running,ccardenas2017-11-301-2/+2
| | | | | | exit with an EALREADY vs EPERM. ok mlarkin@
* update switch handling in vmd(8). vmd now gets switch information (rdomain,mlarkin2017-11-111-14/+1
| | | | | | | | | etc) from underlying switch interface instead of handling this on its own. Diff from carlos cardenas, Thanks! ok reyk@
* typo in previousmlarkin2017-11-071-2/+2
|
* comment function vm_checkpermmlarkin2017-11-071-1/+16
|