summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd
AgeCommit message (Collapse)Author
2017-03-23Various mc146818 emulation fixes - don't block interrupts needlessly, andMike Larkin
set proper return data size (don't clobber high %eax bits). Also apply a mask on incoming data (from OUT instruction in guest) to avoid misinterpreting register index values. Found when implementing Linux and seabios support.
2017-03-23use proper return data size when doing PIC reads - don't clobber %eaxMike Larkin
high bits.
2017-03-21From a syslog perspective it does not make sense to log fatal andAlexander Bluhm
warn with the same severity. Switch log_warn() to LOG_ERR and keep fatal() at LOG_CRIT. OK reyk@ florian@
2017-03-21Fix two errors in NS8250 (UART) emulation. The first error zeroed out theMike Larkin
high bits of %eax on reading register data from the emulated UART ports. The second error didn't properly assert the TXRDY bit during init - this bit was only set after the first character was sent. Both these bugs caused seabios to not be able to output any data. Found during the recent effort to get Linux guests booting.
2017-03-19Don't identify the MC146818 RTC as operating in binary mode when we are reallyMike Larkin
operating in BCD mode. Linux assumes the RTC will be in BCD mode by default and if not, it does a WARN_ON warning about this, and misinterprets the RTC TOD registers. Tested with existing vmd/vmm guests with what's in tree.
2017-03-19Emulated i8253 should not start out in TIMER_RATEGEN mode on bootMike Larkin
automatically. This worked for OpenBSD guests but breaks seabios as soon as the first interrupt fires since it has not programmed the PIT to do anything yet. And OpenBSD reprograms the clock to rategen mode as soon as it boots anyway, so this still works with vmctl(8)'s -k option, as well as the faux-bootloader implemented in vmd(8)
2017-03-19Handle master/slave PIC vector base properly. OpenBSD uses 0x20/0x28Mike Larkin
(respectively). Seabios uses 0x8/0x78 and linux uses 0x30/0x38. Respond properly to PIC vector base assignment and calculate VMX injection vectors based on current values, instead of always assuming OpenBSD defaults. Needed for both seabios serial console support as well as linux guest support. Tested on -current as is, does not break existing OpenBSD guest support.
2017-03-19Convert some log_warn into log_warnx, and provide pic names (master,slave)Mike Larkin
in debugging output.
2017-03-15More fixes for starting and stopping VMs, fixing fallout from vm_running.Reyk Floeter
- Don't start a VM that is already running - Keep the VM as running until it is powered off (and not stopping) - Don't fatal in the parent if the vmm process referenced an unknown VM - Don't stop a VM that is already stopping - Indicate that a VM is stopping in "vmctl status" The previous "vmctl stop; vmctl stop" to force-shutdown is not supported anymore - the shutdown timeout should make sure that the VM is really terminated. To force-shutdown, reference the VM by ID. We might add a flag to vmctl stop to just turn the VM off.
2017-03-15Improve vmmci(4) shutdown and reboot.Reyk Floeter
This change handles various cases to power off the VM, even if it is unresponsive, stuck in ddb, or when the shutdown was initiated from the VM guest side. Usage of timeout and VM ACKs make sure that the VM is really turned off at some point. OK mlarkin@
2017-03-15Close the tty if the VM was powered down.Reyk Floeter
The parent keeps a copy of each VM's tty fd to reuse it on reboot. Close this tty if the VM was stopped, and not rebooted, by calling vm_stop(vm, 0) instead of just setting vm_running to 0. Also make sure that vm_ttyname is not used after free'ing it.
2017-03-15Don't terminate vmd(8) when we lost the control connection.Reyk Floeter
When a start vm request is received from vmctl via the control socket, vmd's control process forwards it to the parent to trigger the action. A response is received later, in an async way, and send back to vmctl that is supposed to wait for it. But now, if vmctl got terminated before receiving the response, vmd fails to find the control connection. In this case it should not abort, print and warning, and ignore the error. The fix is a simple as changing a return (-1) to a return (0). This fixes an issue that was reported by mlarkin@
2017-03-02Add "locked lladdr" option to prevent VMs from spoofing MAC addresses.Reyk Floeter
This is especially useful when multiple VMs share a switch, the implementation is independent from the underlying switch or bridge. no objections mlarkin@
2017-03-01Split vmm.c into two files: vm.c for the VM child, vmm.c for the parentReyk Floeter
As discussed with mlarkin@, it makes it easier to maintain the file. OK mlarkin@
2017-03-01tweak previous; ok reykJason McIntyre
2017-03-01Add "owner" option to set a user/group ownership for pre-configured VMsReyk Floeter
This allows matching users to start or stop VMs that they "own" and to access the console accordingly. OK mlarkin@
2017-02-28Sort vm.conf(5) config options alphabeticallyReyk Floeter
OK mlarkin@
2017-02-27Replace openpty(3) with local function that uses pre-opened /dev/ptm fdReyk Floeter
This allows more flexibility for upcoming changes and better pledge. We also didn't use half of the features of libutil's openpty function. Additionally, make sure that the ttys are closed correctly on shutdown. OK gilles@
2017-02-27Add size checks for imsg received over the control socket.Reyk Floeter
Additionally, make sure that vmd never fatal()s when receiving an invalid imsg from an arbitrary user over the control socket. OK gilles@
2017-02-13Fix powerdown with vmmci(4) VMs using a shutdown and no reset.Reyk Floeter
vmm VMs don't support powerdown - no ACPI or power management - so we use a trick to issue a reboot and just don't reset after the triple fault. This worked before but was broken with the previous fix to pvbus_shutdown() - move the trick to vmd instead. OK mlarkin@
2017-02-04missing function prototypeMike Larkin
2017-01-24SVM: vmd(8) support for SVMMike Larkin
2017-01-21updated include paths for recently moved virtio stuffMike Larkin
2017-01-21Switch include of virtio header from dev/pci/ to dev/pv/Reyk Floeter
2017-01-19Export the host time to the guest, add it as a timedelta sensor in vmmci(4)Reyk Floeter
OK kettenis@ mlarkin@
2017-01-17Nuke some whitespace that keeps poking me in the eye as I try toKenneth R Westerback
steal code.
2017-01-13Make it possible to remove VMs from vmd(8)'s internal queue.Edd Barrett
The semantics agreed with reyk@ are: * ad-hoc created vms, created with `vmctl start`, are removed once stopped. * Stopped VMs defined in a config file are flushed before a `vmctl reload`. OK reyk@
2017-01-13I accidentally committed three lines from the future.Reyk Floeter
2017-01-13Add host side of vmmci(4) to vmd(8).Reyk Floeter
It currently uses the device to request graceful shutdown of a VM on "vmctl stop myvm" but will be extended for reboot and a other edge cases. OK mlarkin@
2017-01-11Add imsg communication channel between vmd and invividual VMs.Reyk Floeter
For now, this is only used to forward "log verbose|brief" requests, but it will be used for better things later. OK mlarkin@
2017-01-09Rename control_dispatch_vmm to control_dispatch_vmd to reflect reality.Reyk Floeter
No function change.
2017-01-09Stop accessing verbose and debug variables from log.c directly.Reyk Floeter
This replaces log_verbose() and "extern int verbose" with the two functions log_setverbose() and log_getverbose(). Pointed out by benno@ OK krw@ eric@ gilles@ (OK gilles@ for the snmpd bits as well)
2017-01-09Replace hand-rolled for(;;) traversal of ctl_conns TAILQ withKenneth R Westerback
TAILQ_FOREACH(). No intentional functional change. ok reyk@
2017-01-08Reduce "vmd -v" spam a bit by not printing useless exit information. TheseMike Larkin
were being printed because vmm(4) was in the middle of processing an exit that vmd(8) didn't care about, but still exited to vmd(8) because of a pending interrupt.
2017-01-05Replace hand-rolled for(;;) emptying of 'symhead' TAILQ with moreKenneth R Westerback
modern TAILQ_FOREACH_SAFE(). No intentional functional change. ok millert@ bluhm@ gilles@
2017-01-05Replace symset()'s hand-rolled for(;;) traversal of 'symhead' TAILQKenneth R Westerback
with more modern TAILQ_FOREACH(). This what symget() was already doing. Add paranoia '{}' around body of symget()'s TAILQ_FOREACH(). No intentional functional change. ok bluhm@ otto@
2016-12-14Allow to start disabled and pre-configured VMs by name, "vmctl start foo".Reyk Floeter
With testing from Jon Bernard OK mlarkin@
2016-12-14Allow a guest to reboot by reinitializing its state and booting again.Reyk Floeter
This is technically a reset since memory is cleared and the dmesg buffer is lost. Patch from Jon Bernard (jbernard at jbernard.io) - Thanks OK reyk@ mlarkin@
2016-12-14If a VM terminates with the result EAGAIN, close all fds except theReyk Floeter
pty and re-send it to the vmm monitor process. With additional changes in vmm.c, this will allow perform a cold reboot of VM. With testing and feedback from Jon Bernard OK mlarkin@
2016-12-05Add debug message to print VM's mac addresses (lladdr).Reyk Floeter
2016-11-30Always remove the local vm after calling terminate_vm().Reyk Floeter
2016-11-26Implement basic support for boot.conf(8) on the disk image.Reyk Floeter
Like the real boot loader, load and parse hd0a:/etc/boot.conf from the first disk and fall back to /bsd. Not all boot loader options are supported, but it at least does set device, set image, and boot -acds (eg. for booting single-user). For example, it can now boot install60.fs that includes a boot.conf with "set image /6.0/amd64/bsd.rd": vmctl start install -c -d install60.fs -d OpenBSD.img This pseudo-bootloader is only needed without BIOS and could potentially be replaced in the future. OK mlarkin@
2016-11-26If -m/memory is not specified, use 512M by default.Reyk Floeter
Default value picked with mlarkin - not too small and not too large. OK mlarkin@
2016-11-26virtio-net: Partially implement device resetStefan Fritsch
Implement some bits of the device reset and don't do DMA if the DRIVER_OK bit is not set. This is enough to avoid vio(4) panicking on if down/up. Tested by rzalamena@ and mikeb@ OK reyk@
2016-11-26Remove start_client_vmd.Martijn van Duren
It was nothing more than a wrapper around fork(2). OK edd@ and mlarkin@
2016-11-25Do not call ufs_close() if ufs_open() failed, fixes potential double-free.Reyk Floeter
2016-11-25sync with libsa/ufs.cReyk Floeter
2016-11-24Restore the errno in vlog() as well to have the same "safe errno"Reyk Floeter
effect in log_debug(), log_warn*() and all the other logging functions.
2016-11-24Better cast for consistencyReyk Floeter
2016-11-24Fix a few signedness warnings in our copy of libsa's ufs.c.Reyk Floeter