summaryrefslogtreecommitdiffstats
path: root/usr.sbin/vmd (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Remove extraneous call of vm_getbyvmid during pause eventdv2021-04-011-2/+1
| | | | The vm is already being assigned by a call in the if-condition.
* Propagate host-side tap(4) lladdr to guest vm process to allow unicast dhcpdv2021-03-299-12/+124
| | | | | | | | | | 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@
* Cleanly teardown and restore emulated device state on vm send/receive.dv2021-03-293-5/+21
| | | | | | | | This cleans up events on a pause or resume, but also fixes an issue where the vm_pipe event channels are not properly reinitialized on a received guest leading to broken serial console. OK pd@, mlarkin@
* inspect all the packets to see if they are dhcp, not just the first onederaadt2021-03-261-3/+2
| | | | | in a ring bundle. ok florian
* Remove booting from kernels in raw/qcow2 imageskn2021-03-1910-1435/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Diff and (slightly tweaked) text below from Dave Voutila < dave at sisu dot io >, thanks! -- Since 6.7 switched to FFS2 as the default filesystem for new installs, the ability for vmd(8) to load a kernel and boot.conf from a disk image directly (without SeaBIOS) has been broken. A diff from tb to add FFS2 support never mdae it into the tree. On 5th Jan 2021, new ramdisks for amd64 have started shipping gzipped, breaking the ability to load the bsd.rd directly as a kernel image for a vmd guest without first uncompressing the image. Using BIOS works, the FFS2 change happend ten months ago and few if any have complained about the breakage. vmctl(8) is still vague about supporting it per its man page and one still has to pass the disk image twice as a "-b" and "-d" argument to boot an OpenBSD guest *without* BIOS. Josh Rickmar reported the gzip issue on bugs@ and provided patches to add support for compressed ramdisks and kernel images. The easiest way to do so is to drop support for FFS images since they require a call to fmemopen(3) while all the other logic uses fopen(3)/fdopen(3) calls and a file descriptor. It is much easier to get thsoe patches merged if they don't have to account for extracting files from disk images. -- No objections anyone "Removing it makes sense" reyk (who wrote the FFS module) OK mlarkin
* off by one in array bounds testsjsg2021-03-031-4/+4
| | | | ok mlarkin@
* don't read past the end of an arrayjsg2021-03-021-2/+2
| | | | ok mvs@ mlarkin@
* Document veb(4) supportkn2021-03-011-5/+7
| | | | | Feedback jmc OK dlg
* add veb(4) to the list of supported bridges/switches you can configure.dlg2021-02-282-4/+5
| | | | | tested by josh rickmar ok kn@
* Fix some wrong comments and KNF/long line wrapsmlarkin2021-02-131-5/+8
|
* these programs (with common ancestry) had a -fno-common problem relatedderaadt2021-01-272-3/+6
| | | | | to privsep_procid. ok mortimer
* bump VM shutdown event timeout ok mlarkin@ stsp@ florian@tracey2021-01-071-2/+2
| | | | | VMs with addition package daemons were not given enough time to shutdown gracefully.
* De-daddr32_t.krw2020-12-102-9/+9
| | | | ok mlarkin@ tb@
* Remove an unneeded variable.visa2020-10-261-5/+5
| | | | OK kettenis@
* Accommodate POSIX basename(3) that takes a non-const parameter andnaddy2020-10-191-2/+8
| | | | | | may in fact modify the string buffer. truncation check requested and ok florian@
* Revert agentx support for now, we're too close to release.martijn2020-09-237-891/+13
| | | | requested by deraadt@
* Add support for agentx to vmd.martijn2020-09-237-14/+892
| | | | | 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.
* Fix PCI config space union such that the register state is properlykettenis2020-09-081-37/+38
| | | | | | separated from the non-register state. Committed on behalf of jordan@
* No need for a private #define for the INQUIRY response_format value '2'. Justkrw2020-09-032-4/+3
| | | | use the new SID_SCSI2_RESPONSE.
* Rename [READ|WRITE]_BIG to [READ|WRITE]_10. Rename struct scsi_rw_big tokrw2020-09-011-6/+6
| | | | | | struct scsi_rw_10. ok gnezdo@ jmatthew@ (who also did sparc64 compile test)
* vmd(8): Eliminate libevent state corruptionpd2020-06-285-16/+203
| | | | | | | | | | | | | | libevent functions for com, pic and rtc are now only called on event_thread. vcpu exit handlers send messages on a dev pipe and callbacks on these events do the event management (event_add, evtimer_add, etc). Previously, libevent state was mutated by two threads, event_thread, that runs all the callbacks and the vcpu thread when running exit handlers. This could have lead to libevent state corruption. Patch from Dave Voutila <dave@sisu.io> ok claudio@ tested by abieber@ and brynet@
* vmd(8): fix ns8250 lockup due to race conditionpd2020-06-211-16/+16
| | | | | | | | | | | | | | | | | Inject a pending interrupt even if the rcv_pending flag is set to avoid the endless EV_READ loop where a byte lingers read to be read but the vcpu never gets the interrupt to read it. (e.g. the result of spamming RETURN via the serial console) Also, protect com ratelimit handler with mutexes to avoid corruption of the device state. These changes help preventing linux vm crashes when the return key is held on boot. Discovered by and patch from Dave Voutila <dave@sisu.io> ok tb@
* vmd(8): backout previous commit to ns8250.c as it reintroduced the bug where thepd2020-06-161-17/+9
| | | | | | | vm would get stuck if disconnected from console and get unstuck once console is attached. Spotted by tb@
* vmd(8): fix ns8250 lockup due to race conditionpd2020-06-161-9/+17
| | | | | | | | | | | | Inject pending interrupt if com has receive pending. This was previously accidently checked in with an unrelated change by Mike Larkin and was backed out as it didn't fix the intended problem. Also, protect com ratelimit handler with mutexes to avoid corruption of the device state. These changes help preventing linux vm crashes when the return key is held on boot. Discovered by and patch from Dave Voutila <dave@sisu.io>
* vmd(8): correctly terminate vm processes after sending vmpd2020-04-302-6/+6
| | | | | | | | | | | | | | | | | | | Instead of a round about way of sending a message to vmm that 'send is successful' and terminating by vm_remove from vmm, we can send the imsg and exit in the vm process. The sigchld handler in vmm will vm_remove it from its structures. This is how a normal vm is terminated as well. Previously, vm_remove was called in vmm_dispatch_vm (ie. the event handler to receive messages from vm process) when hanlding the IMSG_VMDOP_SEND_VM_RESPONSE (ie. the vm process has written the vm state to the fd passed on by vmctl send). This is not how vm_remove was intented to be used as it does a free(vm). The vm struct holds the buffers for imsg and so after handling this IMSG_VMDOP_SEND_VM_RESPONSE message, vmm_dispatch_vm loops again to do imsg_get(ibuf, &imsg) to read the next message (and we had just freed this *ibuf when we freed the vm struct) causing it to segfault. reported by kn@ ok kn@
* vmd: improve concurrency control in pausepd2020-04-211-38/+25
| | | | | | | | Previous implementation hit a deadlock sometimes as the pthread_cond_broadcast for the pause mutex could happen before pthread_cond_wait. This implementation uses a barrier which is hit when all vpcus are paused. ok mpi@
* vmm(4): add IOCTL handler to sets the access protections of the eptpd2020-04-081-2/+40
| | | | | | | | | | | | This exposes VMM_IOC_MPROTECT_EPT which can be used by vmd to lock in physical pages. Currently, vmd just terminates the vm in case it gets a protection fault in the future. This feature is used by solo5 which uses vmm(4) as a backend hypervisor. ok mpi@ Patch from Adam Steen <adam@adamsteen.com.au>
* Backout "DHCP is configured on the first interface only"kn2020-02-161-3/+3
| | | | | | | | | | | | | | | | | I completely missed that part from vmctl.5's "LOCAL INTERFACES" section. Reading `-L's description itself and the fact that it functions as a boolean switch contrary to how `-i' expects a number, I made the wrong assumption that it can only work for the first interface. "vmctl -Li2" configures two interfaces, one witch DHCP and one without. "vmctl -L -L" however configures two interfaces with DHCP IPs each. My second mistake was to imply analogue behaviour for the configuration. Now that you stated the obvious about `local' being per `interface' line, it makes absoloutely no sense to above mentioned behaviour for static VM definitions. Pointed out by tb
* DHCP is configured on the first interface onlykn2020-02-151-3/+3
| | | | | | | A VM can have multiple interfaces, but only the first one gets DHCP if "-L" (vmctl) or "local" (vm.conf) is specified. Positive feedback Mike Larkin
* briefly mention /etc/examples/ in the FILES section of all theschwarze2020-02-101-2/+7
| | | | | manual pages that document the corresponding configuration files; OK jmc@, and general direction discussed with many
* Guest VMs require some resources that are managed outside of vmm(4), sophessler2020-01-151-2/+11
| | | | | | | | | | try to document and enumerate them. This is most helpful when you try to assign the 5th interface to a guest, and are confused why vmd(8) won't start the guest when only 4 tap devices exist. OK jmc@, kn@, pamela@
* "allow instance {...}" requires optionskn2019-12-171-3/+3
| | | | The parameter block must not be omitted, so remove the Op markup.
* kn pointed out that the changes i made to "socket owner" can bejmc2019-12-171-5/+11
| | | | applied to "owner" too;
* combine "socket owner user[:group]" and "socket owner :group"jmc2019-12-171-7/+13
| | | | | | into one logical item; ok pd
* tweak previous; ok pdjmc2019-12-131-12/+13
|
* Make owner value mandatorykn2019-12-121-6/+2
| | | | | | | | | | | Omitting the owner value is not documented and ought to be rather invalid syntax, but it parses as "[socket] owner root:wheel" which is the same as simply omitting the owner line entirely. Require a value, that is treat "socket owner" and "owner" as invalid syntax and fail. OK denis
* vmd: start vms defined in vm.conf in a staggered fashionpd2019-12-124-34/+87
| | | | | | | | | | | | 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: proper concurrency control when pausing a vmpd2019-12-116-42/+169
| | | | | | | | | | | | | | | Removes an XXX which slept for 1s waiting for the vcpu thread to reach HLT and pause. We now define a paused and unpaused condition so that a call to pause_vm() / vmctl pause blocks till the vm really reaches a paused state. Also, detach events for devices from event loop when pausing and add them back when unpausing. This is because some callbacks call pthread_mutex_lock and if the vm is paused, it would block also causing the libevent thread to block. This would mean that we would not be able to process any IMSGs received from vmm (parent process) including a message to unpause. ok mlarkin@
* Fully reinstate revision 1.21. Apparently, revision 1.22 (part oftb2019-12-081-27/+15
| | | | | | | | | the "Fix at least one cause of VMs spinning at 100% host CPU" commit) accidentally included some pieces of a different WIP. These pieces remained in the tree after the revert and caused vmd to busy loop after attaching to and detaching from a VM's console. "please commit" mlarkin
* Revert previous - the stability was not as improved as we had thought andmlarkin2019-11-305-31/+7
| | | | | | we ended up accidentally breaking vmctl. This will need more thought. ok ori@
* Fix at least one cause of VMs spinning at 100% host CPUmlarkin2019-11-295-21/+56
| | | | | | | | | | | | | | | After debugging with ori@, it looks like an event ends up on the wrong libevent queue, and we end continually de-queueing and re-queueing the event continually. While it's unclear exactly why this happened, a clue on libevent's github issues page for the same problem pointed us to using a different event base for the device events. This seems to have unstuck ori@'s problematic VM, and I have also seen no more hangs after this. We have not completely separated the queues; ori@ will work on setting new libevent bases for those later. But those events are pretty frequency. with help from and ok ori@
* Consistently use _rcctl enable foo_ in examples, it's simpler and lesslandry2019-11-101-5/+10
| | | | | | | | | | | | | error prone than manually editing rc.conf.local, and also works to enable ipsec and accounting. tweak from schwarze@ to use the \(dq\(dq syntax for quotes in '.Dl foo_flags="" lines' instead of \&"\&". while at it, fix a reference to a bogus /dev/dhclient.conf file that recently snuck in. ok jmc@ deraadt@ schwarze@
* ifname in opentap() is not optionalkn2019-10-251-5/+4
| | | | | | | | | | The function argument is not checked at all and the only caller in config.c always passes a buffer valid buffer. Defer the error case's default value to the end to avoid rewriting in case a node is opened. Feedback and OK reyk
* vmd(8): provide some additional info in a debug msgmlarkin2019-10-161-3/+4
| | | | | | | Print the guest %rip when it tries to do I/O to a nonexistent port. Also convert the message to a DPRINTF so that it doesn't leak guest address information into any logging the host might be doing under normal non-debug conditions.
* use sizeof(struct) not sizeof(pointer) in calloc calljsg2019-10-111-2/+2
| | | | ok deraadt@
* vmd(8): fix memory leak in virtio network TX path.mlarkin2019-09-241-1/+4
| | | | ok reyk, mpi, benno, tb
* vmd(8): virtio.c whitespace removalmlarkin2019-09-241-2/+2
|
* Remove unused VMD_DISK_INVALID message type and mark it obsolete.tobhe2019-09-071-2/+2
| | | | ok mlarkin@
* 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-142-3/+9
| | | | | | | start. Favoring 'invalid template' over 'permission denied' should give the user a better hint on what went wrong. ok kn@ mlarkin@