summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd
AgeCommit message (Collapse)Author
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@
2018-10-04vmd(8): don't forget to set TXRDY in the case when the rate limiter isn'tMike Larkin
going to be used. Issue caused by yesterday's commit, affected certain guests' consoles after interrupts had been enabled. spotted by bluhm@, thanks.
2018-10-03Add check to ensure vioscsi pointer if validccardenas
implicit ok from pd@ since he came up with the same diff
2018-10-03vmd(8): avoid a divide by zero when the user specified a low baud rateMike Larkin
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
2018-10-01Fix potential double-free in error pathReyk Floeter
qc2_open() calls qc2_close() on error which already frees diskp. OK ccardenas@
2018-10-01Try to derive the qcow2 file format from an image file automatically.Reyk Floeter
This makes the "-d qcow2:" and "format qcow" arguments optional as vmctl and vmd will read the magic bytes at the beginning of a file to guess if it is a raw or a qcow image file. The "vmctl create" command has been changed by removing the -f qcow2 option and replacing it with the same syntax as -d: "vmctl create qcow2:foo.img". In a slightly ununixy but intended way, the create command now also considers the file extension for the format as "vmctl create foo.qcow2" creates a qcow2 disk and not a raw image file. Ok mlarkin@ (and ccardenas@ on an earlier version of the diff)
2018-09-30Add size limitation of group-name and a reference to ifconfig about itsolene
ok mlarkin@ jmc@ jca@
2018-09-29vmd: don't remove vm if sending failedpd
Fix a bug where a vm was removed in vmd.c after vmctl send even if sending failed. spotted by solene@ ok mlarkin@
2018-09-28Support vmd-internal's vmboot with qcow2 disk images.Reyk Floeter
OK mlarkin@
2018-09-28Compress qcow2 open debug messages into a single lineReyk Floeter
Please avoid tabs and excessive multi-line information with log_debug as it also goes to syslog. No functional change.
2018-09-28Fix copy-pasto to use maxmem instead of maxcpuReyk Floeter
Reported by Greg Steuck OK mlarkin@
2018-09-19Various clean up items for disks.ccardenas
- qcow2: general cleanup - vioraw: check malloc - virtio: add function to sync disks - vm: call virtio_shutdown to sync disks when vm is finished executing Thanks to Ori Bernstein. Ok miko@
2018-09-13vmd: set irq and vm_id in virtio dev structs on restorepd
This unbreaks vmctl receive. ok ccardenas@
2018-09-11Be consistent in logging messages.ccardenas
Change "fmt" to "format". Ok kn@
2018-09-11Fail fast when we are unable to determine disk format.ccardenas
While here, minor cleanup on logging.
2018-09-10vmd(8) clould close file descriptor 0 as not all fd fields wereAlexander Bluhm
properly initialized with -1. Also avoid closing -1. OK mlarkin@
2018-09-10During the fork+exec implementation, daemon(3) was moved afterAlexander Bluhm
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@
2018-09-09Add initial qcow2 image support.ccardenas
Users are able to declare disk images as 'raw' or 'qcow2' using either vmctl and vm.conf. The default disk image format is 'raw' if not specified. Examples of using disk format: vmctl start bsd -Lc -r cd64.iso -d qcow2:current.qc2 or vmctl start bsd -Lc -r cd64.iso -d raw:current.raw is equivalent to vmctl start bsd -Lc -r cd64.iso -d current.raw in vm.conf vm "current" { disable memory 2G disk "/home/user/vmm/current.qc2" format "qcow2" interface { switch "external" } } or vm "current" { disable memory 2G disk "/home/user/vmm/current.raw" format "raw" interface { switch "external" } } is equivlanet to vm "current" { disable memory 2G disk "/home/user/vmm/current.raw" interface { switch "external" } } Tested by many. Big Thanks to Ori Bernstein.
2018-09-07replace malloc()+strlcpy() with strndup() in cmdline_symset().miko
"looks good" gilles@ halex@
2018-08-25Rework disks to have pluggable backends.ccardenas
This is prep work for adding qcow2 image support. From Ori Bernstein. Many thanks! Tested by many. OK ccardenas@