summaryrefslogtreecommitdiff
path: root/usr.sbin/vmctl/main.c
AgeCommit message (Collapse)Author
20 hoursConvert vmd over to check for imsgbuf_init failure and sprinkle a lot ofClaudio Jeker
imsgbuf_allow_fdpass() since vmd and vmctl pass fds left and right. OK tb@
20 hoursUnify error reporting in various control programs.Claudio Jeker
Just use "read error" since the code also uses "write error" for the imsg_flush case. OK tb@
20 hoursConvert the common imsgbuf_read calls to the post EAGAIN world.Claudio Jeker
OK tb@
20 hoursRename imsg_init, imsg_clear, imsg_read, imsg_write and imsg_flush toClaudio Jeker
imsgbuf_init, imsgbuf_clear, imsgbuf_read, imsgbuf_write and imsgbuf_flush. This separates the imsgbuf API from the per-imsg API. OK tb@
21 hoursUse imsg_flush() instead of implementing the same by hand.Claudio Jeker
OK tb@
2024-08-17Use 'int ch' instead of 'char ch' in one place for getopt.Mike Larkin
Forgot one change during an earlier commit; use 'int ch' to make builds complete without warning on arm64. ok dv
2024-05-18remove prototypes with no matching functionJonathan Gray
2024-05-02vmctl(8): Add 'vmctl status -r'Mike Larkin
The -r option can be used to limit the output of 'vmctl status' to only running VMs. This is useful for machines that have a large number of stopped VMs, as the running ones are printed at the top by default and previously required scrolling back to see the list of running VMs, and/or using 'grep RUNNING'. There is no change for users not using -r. ok dv
2024-04-10vmctl: fix incorrect scaling when converting disk images.Dave Voutila
ctl_convert still had old logic assuming disk sizes were in MiB and not bytes, causing an attempt to create a new disk using the '-i' argument to generate impossibly large output disk images (e.g. 1 MiB ends up 1 TiB). Reported by and diff from Jesper Wallin.
2023-04-28vmd(8)/vmctl(8): allow vm owners to override boot kernel.Dave Voutila
vmd allows non-root users to "own" a vm defined in vm.conf(5). While the user can start/stop the vm, if they break their filesystem they have no means of booting recovery media like a ramdisk kernel. This change opens the provided boot kernel via vmctl and passes the file descriptor through the control channel to vmd. The next boot of the vm will use the provided file descriptor as boot kernel/bios. Subsequent boots (e.g. a reboot) will return to using behavior defined in vm.conf or the default bios image. ok mlarkin@
2023-04-25vmctl(8): no longer needs vmmvar.hDave Voutila
Finally! We can remove kernel headers from vmctl. ok mlarkin@
2022-09-01fix unveil(2) in vmctl(8), unix socket needs :w:Sebastian Benoit
ok mestre@ martijn@
2022-07-30vmctl create accepts exactly one argumentKlemens Nanni
Make "vmctl create -s3G 1.img 2.img" fail instead of just creating 1.img and ignoring 2.img. OK dv cheloha
2022-05-13Follow the recent change that the unit of `imgsize' argument ofYASUOKA Masahiko
create_imagefile() became MB. Also change the arguement's type from long to uint64_t that is preferred. ok dv
2022-05-04vmctl(8)/vmd(8): convert disk sizes from MB to bytesDave Voutila
Continue converting other parts to storing data in bytes instead of MB. In this case, the logic for disk sizes was being scaled. This fixes issues reported by Martin Vahlensieck where vmctl could no longer create disks larger than 7 MiB after previous commits to change storing memory sizes as bytes. While this keeps the vm memory limit check in vmctl's size parser, it skips the limit check for disks. The error messages adjust accordingly and this removes the double error message logging. Update comments and function types accordingly. ok marlkin@
2022-05-03vmm/vmd/vmctl: standardize memory units to bytesDave Voutila
At different points in the vm lifecycle vmm(4), vmctl(8), and vmd(8) refer to a vm's memory range sizes in either bytes or megabytes. This is needlessly complex. Switch to using bytes everywhere and adjust types and constants accordingly. While this makes it possible to specify vm's with memory in fractions of megabytes, the logic requiring whole megabyte values remains. Feedback from deraadt@, mlarkin@, and Matthew Martin. ok mlarkin@
2021-07-12Change the error reporting pattern throughout the tree when unveilBob Beck
fails to report the path that the failure occured on. Suggested by deraadt@ after some tech discussion. Work done and verified by Ashton Fagg <ashton@fagg.id.au> ok deraadt@ semarie@ claudio@
2021-06-28Garbage collect loop index i which is no longer used after usage tweak.Theo Buehler
2021-06-26make usage less chatty; ok mlarkinJason McIntyre
2021-05-12vmctl(8): remove unveil from disk image creation routinesdv
James Cook reported an issue creating images from qcow2 disks that contained base images. Initial approach suggested was to replace the use of realpath(3), but since this is common code used in vmd(8) the better option is to just remove the use of unveil(1) in vmctl. (It was added very early in vmctl's development before support for disk conversion was added.) This does not change existing unveil usage in vmctl for things like the control socket or the serial console. There's no change to vmd either. Discussed with and OK from mlarkin@
2021-04-02Remove superflouus mmcpy()dv
Reported by Preben Guldberg. ok mlarkin@
2021-03-26Simplify argument parsing of vmctl stopTheo Buehler
The previous argument parsing logic had at least three bugs: a copy-paste error led to an off-by-one and a printf "%s" NULL, as reported by Preben Guldberg. A previous commit led to a dead else branch and a use of uninitialized. This can all be avoided by reworking the logic so as to be readable. Prompted by a diff from Preben ok dv
2020-01-03vmctl(8): fix vmctl send exit codepd
vmctl send always returned exit code 1 Patch by Benjamin Baier ok kn@
2019-12-28Run cu(1) in restricted modekn
Users must not not be able to transfer files from the local hypervisor filesystem to VMs/LDOMs, especially since the "vmctl/ldomctl console ..." might be run as root. Disable all relevant escape sequences and cause cu to run under "stdio tty" pledge by using -r. OK deraadt mlarkin
2019-12-17Use local variable isntead of function parameterkn
The parse_size() wrapper around scan_scaled(3) writes its intermediate result to the function argument which is always passed as literal zero. This seems odd, the function parameter has no meaning but merely serves as storage, so let's use a proper function scoped variable instead. OK pd
2019-10-27Require at least one interface with -ikn
Either a positive count is given or -i is omitted entirely; vm.conf(5) does not allow interface configuration that results in zero interfaces either. Raise the minimium count value to one and tell more about invalid counts with the usual strtonum(3) idiom. OK reyk
2019-08-23vmctl(8): fix wrong output when using 'vmctl stop'Mike Larkin
Fix a wrong output when using 'vmctl stop' without any further arguments. Patch from Caspar Schutijser, thanks! ok deraadt
2019-07-05zap an extra space in usage();Jason McIntyre
from alessandro gallo
2019-05-29Change vmctl(8) syntax: command options before the disk/name/id argument.Reyk Floeter
vmctl had a CLI-style syntax (bgpctl-style) for a short time but I changed it back to a more suitable getopt syntax. I replaced the CLI tokens to getopts flags but didn't consider swapping the order of command options and arguments to be more UNIX-like again ("vmctl create disk.img size 10G" simply became "vmctl create disk.img -s 10G"). This changes "create", "start", and "stop" commands to the commonly expected syntax like "vmctl create -s 10G disk.img". Requested by many OK mlarkin@ kn@ solene@
2019-03-18An existing VM may be started by referencing its IDkn
Document `vmctl start id ...' again but be clear about the difference between starting new and existing VMs by name and ID respectively. This completes what I started with vmctl.8 revision 1.61. Feedback and OK jmc
2019-03-01Fix previous extra arguments commitkn
I blatantly missed the argc/argv adjustments after getopt(3), resulting in valid commands like `vmctl create a -s 1G' to fail. Noticed by ajacoutot the hard way. OK ajacoutot jca
2019-03-01Print usage on extra create, start and stop argumentskn
OK mlarkin
2018-12-14sync usage(); also, stop enclosing arg names in quotes, since it wasJason McIntyre
applied inconsistently, and applied consistently would make it look like spaghetti; ok mlarkin
2018-12-11Extend vmctl start -B argument to work for disk, cdrom and net.Claudio Jeker
Currently SeaBIOS will respect disk and cdrom and our kernel will understand net. OK ccardenas@, reyk@, mlarkin@
2018-12-06Add a new argument -B device to vmctl start. It allows to set the boot device.Claudio Jeker
At the moment only 'net' is supported and all other values are silently ignored. This allows to kick of an OpenBSD autoinstall by using: vmctl start "installer" -Lc -B net -b bsd.rd -d disk.img OK ccardenas@
2018-12-04Add 'vmctl wait <VM>' a command that waits until the specified VM isClaudio Jeker
stopped/terminates. Useful in scripts when waiting until a vm has finished its work. 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-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-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-05Setting getopt optreset to 1 needs an additional reset of optind to 1.Reyk Floeter
OK millert@
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-27Add vmctl stop -a [-fw] option to stop or terminate all running VMs.Reyk Floeter
This is also be used to simplify the vmd rc stop script. OK mlarkin@ ccardenas@
2018-09-13Add initial set of unveil's to vmctl.ccardenas
Was in snaps for a while. Ok mlarkin@ and reyk@
2018-09-11Add ability to create qcow2 disk.ccardenas
vmctl create now takes an optional disk format parameter: raw or qcow2. If format is omitted, raw is used. Many thanks to Ori Bernstein.
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-12The vmctl start -I option was changed to -t.Reyk Floeter
I committed the manpage but accidentally forgot the main.c part. 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-02-24add an alias for vmctl show, matches finger memory and the rest of thePeter Hessler
*ctl programs OK mlarkin@ benno@ deraadt@