summaryrefslogtreecommitdiffstats
path: root/usr.sbin/vmd (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* vmm/vmd: Fix migration with pvclockpd2019-07-172-3/+45
| | | | | | | Implement VMM_IOC_READVMPARAMS and VMM_IOC_WRITEVMPARAMS ioctls to read and write pvclock state. reads ok mlarkin@
* When system calls indicate an error they return -1, not some arbitraryderaadt2019-06-284-24/+24
| | | | | | 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.
* Make vmd(8)'s ns8250 emulation more correctmlarkin2019-05-282-12/+31
| | | | | | | | | | Remove the scratch register (8250s don't have this), and reorganize some constants to be able to more easily support more than one serial port in the future. ok deraadt Diff from Katherine Rohl, thanks!
* vmd: unset CR0_CD and CR0_NW in default flat64 register valuespd2019-05-281-2/+2
| | | | | | | These never got unset on AMD/SVM guests when booted via vmctl start -b causing them to run very slow ok mlarkin@
* only reschedule the periodic interrupt after updating register Ajasper2019-05-271-2/+2
| | | | | | | | | | | | | | if something changed in register A. when updating register A we were checking in register B if the PIE bit was set in order to decide if rtc_reschedule_per needed to be called. if that bit was changed then the timer rate would already have been adjusted by rtc_update_regb so the call from rtc_update_rega is not needed. this now matches what qemu and other emulators are doing too. ok mlarkin@
* 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@
* Unbreak vmctl start foo -b /bsd -d disk.img -cLclaudio2019-05-162-5/+6
| | | | | | | Define a local definition of LOADADDR() instead of pulling in machine/loadfile_machdep.h. vmd -b requires the addresses to be masked and the new bootloader no longer does that. OK pd@ kettenis@
* Delete some .Sx macros that were used in a wrong way.schwarze2019-05-141-6/+2
| | | | Part of a patch from Stephen Gregoratto <dev at sgregoratto dot me>.
* Add support for `boot device' to vm.conf grammar which is the `-B device'anton2019-05-142-6/+48
| | | | | | counterpart from vmctl. ok mlarkin@
* vmm: add a x86 page table walkerpd2019-05-121-1/+137
| | | | | | | | | | Add a first cut of x86 page table walker to vmd(8) and vmm(4). This function is not used right now but is a building block for future features like HPET, OUTSB and INSB emulation, nested virtualisation support, etc. With help from Mike Larkin ok mlarkin@
* report vm state through 'vmctl status'; whereas previously this would display the state ofjasper2019-05-112-9/+8
| | | | | | | 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-112-2/+9
| | | | | | set it to VMM_HV_SIGNATURE and check for it upon restoring a vm image ok mlarkin@ pd@
* add missing comment about VM_STATE_SHUTDOWN; as discussed with ccardenas@jasper2019-05-111-1/+2
|
* track the state of the vm (running, paused, etc) using a single bitfield instead ofjasper2019-05-116-60/+62
| | | | | | | | | 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@
* remove receive_vm prototype for the function does not exist (anymore)jasper2019-05-101-2/+1
| | | | ok pd@
* Do not unconditionally wait for read events on the pty associated with aanton2019-03-112-4/+27
| | | | | | | | | | | | vm console. Instead, wait for the controlling end of the pty to become writeable, which implies that the slave end is connected. A recent change to the kqueue pty implementation caused vmd to hammer the log due to constantly hitting EOF while reading from the pty since the slave end was disconnected. Issue found the hard way by mlarkin@ and tb@ ok mlarkin@
* Clarify that VM names must start with a letterkn2019-03-071-5/+7
| | | | | | | | `start' requires an alphanumeric VM name, must not be a number and in fact must not start with a digit. Improve and simplify the current requirements as starting with a letter directly implies all of the above. OK mlarkin, feedback jmc
* vmd(8): remove some i386 remnants that missed the original cleanupmlarkin2019-03-012-47/+2
| | | | ok pd, kn, deraadt
* vmd(8): initialize guest %drX registers to power-on defaults on launchmlarkin2019-02-202-3/+15
| | | | | | | Initializes the %drX registers to power on defaults, and bump the VM send/recieve header to reflect same discussed with deraadt@
* (unsigned) means (unsigned int) which on ptrdiff_t or size_t or otherderaadt2019-02-131-3/+3
| | | | | | larger types really is a range reduction... Almost any cast to (unsigned) is a bug. ok millert tb benno
* vmd: reorder PCI device assignment to fix Linux network interface numberingmlarkin2019-01-221-51/+51
| | | | | | | | | | | | | | | | | | | | On some recent Linux guests, the virtio network interface is named based on its PCI slot assignment, eg "enp0s3". Prior to this change, vmd assigned disks first, meaning if you used a disk image to install Linux and then removed it after install, the network interface name would change from "enp0s3" to "enp0s2" (for example). This broke any autoconfiguration script config files written during the install and generally led to users just being confused about what was going on. This change reorders the vmd PCI device assignment to put network interfaces before disks, as disk devices don't seem to have the same naming issue. This means the slot for network interfaces won't change. IMPORTANT NOTE - if you have existing Linux guest VMs, you'll need to manually fixup your config files (once). ok ajacoutot, phessler, ccardenas, deraadt@
* disable vmd/vmctl for i386pd2019-01-181-2/+2
| | | | | | | | | | | | Next commit will delete vmm(4) for i386. Reasons to delete i386 vmm: - Been broken for a while, almost no one complained. - Had been falling out of sync from amd64 while it worked. - If your machine has vmx, you most probably can run amd64, so why not run that? ok mlarkin@ deraadt@
* an alloca() snuck into the tree. We don't use alloca() in our tree unlessderaadt2019-01-101-2/+3
| | | | | | it is entirely unavoidable (for example libc/*/exec.c), because any erroneous size controlled by an attacker turns into a known-location object placement in a very dangerous region. So use malloc() instead.
* unbreak vmd buildsf2019-01-102-2/+4
| | | | include new virtio_pcireg.h header
* When netbooting a vm using the `-B net' option, set the hostname DHCPanton2018-12-271-3/+18
| | | | | | | option in the lease to the name of the vm. Makes it easier to use dedicated autoinstall response files for different vms. ok ccardenas@
* Simplify mbzero() by using mem_write with a NULL buf which does zero outclaudio2018-12-121-28/+3
| | | | | all memory at once without having to use a zero buffer. OK mlarkin@
* Set the com speed to 115200 like we do in our bootloader when using SeaBIOS.claudio2018-12-121-2/+2
| | | | OK mlarkin@
* Implement the fw_cfg interface basics and use it to set the bootorderclaudio2018-12-105-9/+491
| | | | | | | | | if a bootdevice was forced. This implements both the pure IO port interface and also the new DMA interface, a few direct commands are implemented which are needed but in general the "file" interface should be used. There is no write support for the guest. Tested against the latest vmm-firmware port. This requires also a -current kernel to pass the IO ports to vmd(8). OK mlarkin@ ccardenas@
* No need to \n in log_debug. Part of a larger diff.claudio2018-12-101-2/+2
| | | | OK mlarkin@ ccardenas@
* 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@
* Make it possible to define the bootdevice in vmd. This information is usedclaudio2018-12-067-24/+49
| | | | | | | | currently only when booting a OpenBSD kernel. If VMBOOTDEV_NET is used the internal dhcp server will pass "auto_install" as boot file to the client and the boot loader passes the MAC of the first interface to the kernel to indicate PXE booting. Adding boot order support to SeaBIOS is not yet implemented. Ok ccardenas@
* Introduce IMSG_VMDOP_WAIT_VM_REQUEST a control message that registers aclaudio2018-12-044-8/+40
| | | | | | | 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@
* Move the {qcow2,raw} create functions from vmctl into vmd/vio{qcow2,raw}.creyk2018-11-265-13/+197
| | | | | | This way they are in the appropriate place and code can be shared with vmd. Ok ori@ mlarkin@ ccardenas@
* Keep a list of known vms, and reuse the VM IDs.ori2018-11-263-7/+44
| | | | | | This means that when using '-L', the IP addresses of the VMs are stable. ok reyk@
* Improve error handling and logging in qcow2ori2018-11-242-124/+76
| | | | | | | This turns most warn + returns that should never happen into hard failures, and improves the user directed error messages. ok @mlarkin, @reyk
* avoid unwanted double space;jmc2018-11-211-2/+2
|
* Add support for "local inet6" interfaces.reyk2018-11-217-39/+262
| | | | ok & test ccardenas@, additional review from kn@
* - odd condition/test in PF lexersashan2018-11-011-2/+3
| | | | | | | | | | | | | | (and other lexers too) This commit rectifies earlier change: in the lex... even inside quotes, a \ followed by space or tab should expand to space or tab, and a \ followed by newline should be ignored (as a line continuation). compatible with the needs of hoststated (which has the most strict quoted string requirements), and ifstated (where one commonly does line continuations in strings). OK deraadt@, OK millert@
* add missing Pf macro; ok jmc@anton2018-10-301-3/+3
|
* I broke base images with my previous commit by missing a line.reyk2018-10-261-2/+3
| | | | | | | The disk path wasn't updated so vmd tried to open the derived disk image for each base over and over again. OK ori@ mlarkin@
* Fix qcow2 disk images for data sizes greater than 4 gigs.ori2018-10-241-5/+5
| | | | | | | | | | | We used to truncate the disk end by anding it with a 32 bit value. The 32 bit value was not sign extended, which causes the disk size to wrap at 4 gigabytes: disk->end = (disk->end + disk->clustersz - 1) & ~(disk->clustersz - 1); This change converts the clustersz to an off_t in order to remove the class of errors by avoiding type conversions entirely.
* The recent switch to realpath(3) for the boot string in vmd(8) brokebluhm2018-10-221-2/+3
| | | | | | vmd-fail-boot-name-too-long regress. Use a relative existing path for this test. Print the error message in vmd config parser. OK ccardenas@ reyk@
* Add support to create and convert disk images from existing imagesreyk2018-10-195-45/+50
| | | | | | | | | | | | | | 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@
* Use realpath(3) on the "boot" config option as well.reyk2018-10-181-4/+10
| | | | | | This fixes code that detects if boot and the first disk are identical. OK mlarkin@
* Prevent VM reboot loops by rate-limiting the interval a VM can reboot.reyk2018-10-153-3/+57
| | | | | | | | | | | | | | | | | | | 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-0810-127/+245
| | | | | | | | | | | | | | | | | | | | | 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(8): don't forget to set TXRDY in the case when the rate limiter isn'tmlarkin2018-10-041-4/+5
| | | | | | | going to be used. Issue caused by yesterday's commit, affected certain guests' consoles after interrupts had been enabled. spotted by bluhm@, thanks.
* Add check to ensure vioscsi pointer if validccardenas2018-10-031-2/+4
| | | | implicit ok from pd@ since he came up with the same diff
* vmd(8): avoid a divide by zero when the user specified a low baud ratemlarkin2018-10-031-3/+4
| | | | | | | | | | | | | | | Low baud rates would result in a 0 "rate limiter pause count" in the serial port output code. This pause counter is used to implement a delay in what otherwise is an instantaneous serial port output path, and is needed by some guest OS kernels. This fix only enables the rate limiter pause if the count is > 0 ("pause after 0 characters" makes no sense anyway). Note that this will result in skipping the limiter on unusually low baud rates, but since nobody is using a low baud rate console in vmd, I don't think this is going to be a problem. ok pd