summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd
AgeCommit message (Collapse)Author
2019-09-07Remove unused VMD_DISK_INVALID message type and mark it obsolete.tobhe
ok mlarkin@
2019-09-04vmd(8): memory leak in an error pathMike Larkin
Found by Hiltjo Posthuma, thanks!
2019-08-14Improve the error message when supplying an invalid template to vmctlanton
start. Favoring 'invalid template' over 'permission denied' should give the user a better hint on what went wrong. ok kn@ mlarkin@
2019-07-17vmm/vmd: Fix migration with pvclockpd
Implement VMM_IOC_READVMPARAMS and VMM_IOC_WRITEVMPARAMS ioctls to read and write pvclock state. reads ok mlarkin@
2019-06-28When system calls indicate an error they return -1, not some arbitraryTheo de Raadt
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.
2019-05-28Make vmd(8)'s ns8250 emulation more correctMike Larkin
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!
2019-05-28vmd: unset CR0_CD and CR0_NW in default flat64 register valuespd
These never got unset on AMD/SVM guests when booted via vmctl start -b causing them to run very slow ok mlarkin@
2019-05-27only reschedule the periodic interrupt after updating register AJasper Lievisse Adriaanse
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@
2019-05-20drop fatalx calls when claiming a new vm id; otherwise it's possibleJasper Lievisse Adriaanse
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@
2019-05-16Unbreak vmctl start foo -b /bsd -d disk.img -cLClaudio Jeker
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@
2019-05-14Delete some .Sx macros that were used in a wrong way.Ingo Schwarze
Part of a patch from Stephen Gregoratto <dev at sgregoratto dot me>.
2019-05-14Add support for `boot device' to vm.conf grammar which is the `-B device'anton
counterpart from vmctl. ok mlarkin@
2019-05-12vmm: add a x86 page table walkerpd
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@
2019-05-11report vm state through 'vmctl status'; whereas previously this would ↵Jasper Lievisse Adriaanse
display the state of the vcpu (which is why it got removed), it now actually reports the correct state (running, stopped, disabled, paused, etc) ok ccardenas@ mlarkin@
2019-05-11vm_dump_header allocated space for a signature but it was never set;Jasper Lievisse Adriaanse
set it to VMM_HV_SIGNATURE and check for it upon restoring a vm image ok mlarkin@ pd@
2019-05-11add missing comment about VM_STATE_SHUTDOWN; as discussed with ccardenas@Jasper Lievisse Adriaanse
2019-05-11track the state of the vm (running, paused, etc) using a single bitfield ↵Jasper Lievisse Adriaanse
instead of 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@
2019-05-11sync the vm state in vmd too when (un)pausing a vm, otherwise the vm processJasper Lievisse Adriaanse
knows the vm is paused, but vmd does not. ok mlarkin@ pd@
2019-05-10remove receive_vm prototype for the function does not exist (anymore)Jasper Lievisse Adriaanse
ok pd@
2019-03-11Do not unconditionally wait for read events on the pty associated with aanton
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@
2019-03-07Clarify that VM names must start with a letterkn
`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
2019-03-01vmd(8): remove some i386 remnants that missed the original cleanupMike Larkin
ok pd, kn, deraadt
2019-02-20vmd(8): initialize guest %drX registers to power-on defaults on launchMike Larkin
Initializes the %drX registers to power on defaults, and bump the VM send/recieve header to reflect same discussed with deraadt@
2019-02-13(unsigned) means (unsigned int) which on ptrdiff_t or size_t or otherTheo de Raadt
larger types really is a range reduction... Almost any cast to (unsigned) is a bug. ok millert tb benno
2019-01-22vmd: reorder PCI device assignment to fix Linux network interface numberingMike Larkin
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@
2019-01-18disable vmd/vmctl for i386pd
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@
2019-01-10an alloca() snuck into the tree. We don't use alloca() in our tree unlessTheo de Raadt
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.
2019-01-10unbreak vmd buildStefan Fritsch
include new virtio_pcireg.h header
2018-12-27When netbooting a vm using the `-B net' option, set the hostname DHCPanton
option in the lease to the name of the vm. Makes it easier to use dedicated autoinstall response files for different vms. ok ccardenas@
2018-12-12Simplify mbzero() by using mem_write with a NULL buf which does zero outClaudio Jeker
all memory at once without having to use a zero buffer. OK mlarkin@
2018-12-12Set the com speed to 115200 like we do in our bootloader when using SeaBIOS.Claudio Jeker
OK mlarkin@
2018-12-10Implement the fw_cfg interface basics and use it to set the bootorderClaudio Jeker
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@
2018-12-10No need to \n in log_debug. Part of a larger diff.Claudio Jeker
OK mlarkin@ ccardenas@
2018-12-09When -B is used to specify a specific boot device also change the rebootClaudio Jeker
behaviour of vmd to stop / exit at guest reboot. OK ccardenas@
2018-12-06Make it possible to define the bootdevice in vmd. This information is usedClaudio Jeker
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@
2018-12-04Introduce IMSG_VMDOP_WAIT_VM_REQUEST a control message that registers aClaudio Jeker
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@
2018-11-26Move the {qcow2,raw} create functions from vmctl into vmd/vio{qcow2,raw}.cReyk Floeter
This way they are in the appropriate place and code can be shared with vmd. Ok ori@ mlarkin@ ccardenas@
2018-11-26Keep a list of known vms, and reuse the VM IDs.ori
This means that when using '-L', the IP addresses of the VMs are stable. ok reyk@
2018-11-24Improve error handling and logging in qcow2ori
This turns most warn + returns that should never happen into hard failures, and improves the user directed error messages. ok @mlarkin, @reyk
2018-11-21avoid unwanted double space;Jason McIntyre
2018-11-21Add support for "local inet6" interfaces.Reyk Floeter
ok & test ccardenas@, additional review from kn@
2018-11-01- odd condition/test in PF lexerAlexandr Nedvedicky
(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@
2018-10-30add missing Pf macro; ok jmc@anton
2018-10-26I broke base images with my previous commit by missing a line.Reyk Floeter
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@
2018-10-24Fix qcow2 disk images for data sizes greater than 4 gigs.ori
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.
2018-10-22The recent switch to realpath(3) for the boot string in vmd(8) brokeAlexander Bluhm
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@
2018-10-19Add support to create and convert disk images from existing imagesReyk Floeter
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@
2018-10-18Use realpath(3) on the "boot" config option as well.Reyk Floeter
This fixes code that detects if boot and the first disk are identical. OK mlarkin@
2018-10-15Prevent VM reboot loops by rate-limiting the interval a VM can reboot.Reyk Floeter
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@
2018-10-08Add support for qcow2 base images (external snapshots).Reyk Floeter
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@