summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/vmd.h
AgeCommit message (Collapse)Author
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@
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-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-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-21Add support for "local inet6" interfaces.Reyk Floeter
ok & test ccardenas@, additional review from kn@
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-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-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-28Support vmd-internal's vmboot with qcow2 disk images.Reyk Floeter
OK mlarkin@
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-07-15Track resources and enforce cpu/memory/interface limits for non-root users.Reyk Floeter
The limits are currently hard-coded and undocumented (4 CPUs/VMs, 2G memory, 8 interfaces) but will be configurable in an upcoming diff. These limits are tracked in total usage; for example, a user will be able to run up to 4 VMs with 512M of memory or a single VM with 2G. OK ccardenas@ mlarkin@
2018-07-13Check the disk/kernel/cdrom file permissions after openening the fd.Reyk Floeter
This prevents time of TOCTOU attacks for instances. OK mlarkin@
2018-07-13Add "allow instance" option.Reyk Floeter
This allows users to create VM instances and change desired options, for example a user can be allowed to run a VM with all the pre-configured options but specify an own disk image. (mlarkin@ was fine with iterating over it) OK ccardenas@
2018-07-12Allow to use configured/running VMs as templates for other VM instances.Reyk Floeter
This introduces new grammar and the -t optional in vmctl start. (For now, only root can create VM instances; but it is planned to allow users to create their own VMs based on permissions and quota.) OK ccardenas@ mlarkin@ jmc@
2018-07-11Add -w option to vmctl stop to wait for completion of VM termination.Reyk Floeter
Use it in /etc/rc.d/vmd accordingly. OK sthen@
2018-07-11Add -f option to vmctl stop to forcefully kill a VM.Reyk Floeter
This also fixes a bug in vmm_sighdlr where it might have missed forwarding the TERMINATE_EVENT to the vmd parent after a VM child died, leading to an abandoned VM in the vmd parent process. OK ccardenas@ mlarkin@ benno@ kn@
2018-07-10vmd already had DEBUG/DPRINTF, there is no need for VMD_DEBUG/dprintfReyk Floeter
Replace all occurences of dprintf with DPRINTF (defined in proc.h).
2018-07-10Tweak debug log messagesReyk Floeter
- Turn tracing messages into DPRINTF (only compiled with DEBUG). - Pass __func__ to vm_stop and vm_remove: this way we can track who called the function in the async context. It replaces the manual log_debug in front of each vm_stop/vm_remove. This debug logging trick can be removed in the future once we are more confident about it. OK ccardenas@ mlarkin@
2018-07-09vmd(8): stash device IRQ in the device structMike Larkin
ok kettenis
2018-06-26Add "socket owner" to allow changing the owner of the vmd control socket.Reyk Floeter
This allows to open vmctl control or console access to other users that are not in group wheel. Access for non-root users still defaults to read-only actions unless you change the owner (user/group) of each individual VM. Requested by Mischa Peters OK mlarkin@
2018-04-27vmd(8): implement vmd side of ELCR registersMike Larkin
ok guenther
2018-01-03Add initial CD-ROM support to VMD via vioscsi.ccardenas
* Adds 'cdrom' keyword to vm.conf(5) and '-r' to vmctl(8) * Support various sized ISOs (Limitation of 4G ISOs on Linux guests) * Known working guests: OpenBSD (primary), Alpine Linux (primary), CentOS 6 (secondary), Ubuntu 17.10 (secondary). NOTE: Secondary indicates some issue(s) preventing full/reliable functionality outside the scope of the vioscsi work. * If the attached disks are non-bootable (i.e. empty), SeaBIOS (vmd's default BIOS) will boot from CD-ROM. ok mlarkin@, jca@
2017-11-11update switch handling in vmd(8). vmd now gets switch information (rdomain,Mike Larkin
etc) from underlying switch interface instead of handling this on its own. Diff from carlos cardenas, Thanks! ok reyk@
2017-10-30vmd no longer creates bridges by default. users should create bridges inMike Larkin
/etc/hostname.bridge* files, and specify which bridge to use for a given virtual switch in vm.conf. diff from Carlos Cardenas, thanks
2017-09-11add functions to provide direct access to guest memory as vmd addressesDavid Gwynne
iovec_mem() populates an iovec array based on guest physical addresses. this allows the use of things like readv and writev for moving data between the guest and a disk image file without having to bounce the memory. vaddr_mem() provides a vmd usable pointer based on a guests physical address. this makes it possible to directly reference things like virtio rings without having to bounce that memory either. however, it assumes that a contiguous range of guest physical memory will sit in a single vm memory range. mlarkin@ says this is right. ok mlarkin@
2017-09-11bring SET, CLR, and ISSET macros inDavid Gwynne
they make bit fiddling easier to read in later diffs. ok mlarkin@
2017-09-08better VM termination handling.Mike Larkin
diff provided by Carlos Cardenas, thanks
2017-08-31vmd/vmctl: disallow use of block or character devices as disks in VMs.Mike Larkin
These don't work today and present the user with a confusing error message if an attempt is made to use them. This commit detects attempts to use block or character devices and if detected, presents the user with a better message. ok jasper From Carlos Cardenas, thanks!
2017-08-20vmd: Allow only upward migrationpd
This restricts receiving vms from hosts with more cpu features. Tested on broadwell -> skylake (works) skylake -> broadwell (don't work) ok mlarkin@
2017-08-18distinguish errors during vm launch and return different error codes toMike Larkin
vmctl so that it can display proper errors for "disk missing" and "bios missing" situations. Expands on an earlier idea/diff from jasper. ok jasper@, pd@, tedu@
2017-07-15Add vmctl send and vmctl receivepd
ok reyk@ and mlarkin@
2017-07-09vmd/vmctl: Add ability to pause / unpause vmspd
With help from Ashwin Agrawal ok reyk@ mlarkin@
2017-06-12device path should be PATH_MAX. Any NAME_MAX without +1 is suspectTheo de Raadt
to begin with anyways.
2017-05-30split vioblk read/write functions into start and finish as prep forTed Unangst
async io operations. ok mlarkin
2017-05-04Report command failure back to vmctl reload, reset, load, log verbose.Reyk Floeter
OK mlarkin@
2017-05-04Add support for rdomains.Reyk Floeter
This allows to configure VM interfaces and switches in individual rdomains. OK mlarkin@
2017-04-21Add global configuration option "local prefix" to change prefix for -L.Reyk Floeter
The default prefix is 100.64.0.0/10 from RFC6598. Requested by sthen@ chris@ OK mlarkin@
2017-04-19Add support for dynamic "NAT" interfaces (-L/local interface).Reyk Floeter
When a local interface is configured, vmd configures a /31 address on the tap(4) interface of the host and provides another IP in the same subnet via DHCP (BOOTP) to the VM. vmd runs an internal BOOTP server that replies with IP, gateway, and DNS addresses to the VM. The built-in server only ever responds to the VM on the inside and cannot leak its DHCP responses to the outside. Thanks to Uwe Werler, Josh Grosse, and some others for testing! OK deraadt@
2017-04-06Do not expose vmm(4) VM IDs to the user, use vmd(8)'s IDs instead.Reyk Floeter
Each VM has two IDs: one from the kernel (vmm) and a different one from userland (vmd). The vmm ID is not consistent and incremented on every boot during runtimg of the host system. The vmd ID remains the same during the lifetime of a configured VM, even after reboots. Configured VMs will even get and keep their IDs when the configuration is loaded. This is more what users expect. Pointed out and tested by otto@ OK deraadt@
2017-03-25Boot using BIOS from /etc/firmware/vmm-bios by default.Reyk Floeter
Instead of using the internal "vmboot", VMs will now be booted using the external BIOS firmware in /etc/firmware/vmm-bios (which is subject to a LGPLv3 license). Direct booting of OpenBSD kernels or non-default BIOS images is still supported for now using the -b/boot option that is replacing the -k/kernel option. As requested by Theo, vmd(8) fails if neither the default BIOS is found nor a kernel has been specified in the VM configuration. The "vmm" BIOS has to be installed using fw_update(1), which will be done automatically in most cases where the OpenBSD can fetch it after install/upgrade. OK mlarkin@
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-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-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-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-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-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@