OpenBSD CVS

CVS log for src/usr.sbin/vmctl/vmctl.c


[BACK] Up to [local] / src / usr.sbin / vmctl

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.90 / (download) - annotate - [select for diffs], Thu May 2 15:46:10 2024 UTC (5 weeks, 2 days ago) by mlarkin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.89: +4 -1 lines
Diff to previous 1.89 (colored)

vmctl(8): Add 'vmctl status -r'

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

Revision 1.89 / (download) - annotate - [select for diffs], Thu Nov 9 12:26:08 2023 UTC (6 months, 4 weeks ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5
Changes since 1.88: +7 -1 lines
Diff to previous 1.88 (colored)

vmctl(8): avoid abort when given an invalid "kernel" file.

The vmctl `start` command allows the user to pass an optional
"kernel" file (either a ramdisk kernel or a SeaBIOS image). This
file is opened by vmctl and the descriptor passed via imsg.

If the file provided isn't a regular file, the attempt to send the
start message to vmd(8)'s control socket will fail and results in
a the vmctl process aborting.

Check the file type after open and fail gracefully if not a regular
file.

reported by and ok gnezdo@

Revision 1.88 / (download) - annotate - [select for diffs], Tue May 2 13:02:51 2023 UTC (13 months, 1 week ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.87: +2 -2 lines
Diff to previous 1.87 (colored)

free the correct pointer.  Missed in rev 1.16.
ok dv@

Revision 1.87 / (download) - annotate - [select for diffs], Fri Apr 28 19:46:41 2023 UTC (13 months, 1 week ago) by dv
Branch: MAIN
Changes since 1.86: +20 -8 lines
Diff to previous 1.86 (colored)

vmd(8)/vmctl(8): allow vm owners to override boot kernel.

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@

Revision 1.86 / (download) - annotate - [select for diffs], Tue Apr 25 12:51:07 2023 UTC (13 months, 2 weeks ago) by dv
Branch: MAIN
Changes since 1.85: +1 -3 lines
Diff to previous 1.85 (colored)

vmctl(8): no longer needs vmmvar.h

Finally! We can remove kernel headers from vmctl.

ok mlarkin@

Revision 1.85 / (download) - annotate - [select for diffs], Tue Apr 25 12:46:13 2023 UTC (13 months, 2 weeks ago) by dv
Branch: MAIN
Changes since 1.84: +11 -10 lines
Diff to previous 1.84 (colored)

vmm(4)/vmd(8): pull struct members out of vmm ioctl create struct.

The object sent to vmm(4) contained file paths and details the
kernel does not need for cpu virtualization as device emulation is
in userland. Effectively, "pull up" the struct members from the
vm_create_params struct to the parent vmop_create_params struct.

This allows us to clean up some of vmd(8) and simplify things for
switching to having vmctl(8) open the "kernel" file (SeaBIOS, bsd.rd,
etc.) to allow users to boot recovery ramdisk kernels.

ok mlarkin@

Revision 1.84 / (download) - annotate - [select for diffs], Sat Jan 28 14:40:53 2023 UTC (16 months, 1 week ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.83: +3 -3 lines
Diff to previous 1.83 (colored)

Move some header definitions from vmm(4) to vmd(8).

Part of an ongoing effort to move userland-specific information out
of a kernel header and directly into vmd(8). No functional change.

ok mlarkin@

Revision 1.83 / (download) - annotate - [select for diffs], Fri May 13 00:17:20 2022 UTC (2 years ago) by yasuoka
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.82: +2 -2 lines
Diff to previous 1.82 (colored)

Follow the recent change that the unit of `imgsize' argument of
create_imagefile() became MB.  Also change the arguement's type from
long to uint64_t that is preferred.

ok dv

Revision 1.82 / (download) - annotate - [select for diffs], Wed May 4 23:17:25 2022 UTC (2 years, 1 month ago) by dv
Branch: MAIN
Changes since 1.81: +3 -3 lines
Diff to previous 1.81 (colored)

vmctl(8)/vmd(8): convert disk sizes from MB to bytes

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@

Revision 1.81 / (download) - annotate - [select for diffs], Wed May 4 02:24:26 2022 UTC (2 years, 1 month ago) by dv
Branch: MAIN
Changes since 1.80: +2 -3 lines
Diff to previous 1.80 (colored)

Missed removing some memory scaling in vmm, vmctl.

Continuation of commitid RbITgDkOsW8SMssz removing use of megabytes
instead of bytes in vmm(4) and vmctl(8). Missed this spot that only
manifests after a vm is started and has its runtime details
inspected.

Revision 1.80 / (download) - annotate - [select for diffs], Tue May 3 21:39:18 2022 UTC (2 years, 1 month ago) by dv
Branch: MAIN
Changes since 1.79: +3 -3 lines
Diff to previous 1.79 (colored)

vmm/vmd/vmctl: standardize memory units to bytes

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@

Revision 1.79 / (download) - annotate - [select for diffs], Thu Jun 10 19:50:05 2021 UTC (2 years, 11 months ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.78: +42 -32 lines
Diff to previous 1.78 (colored)

vmctl(8)/vmd(8): communicate TERMINATE_VM_EVENT imsgs on vm stop.

Instead of translating imsg types, update vmclt(8) to handle receiving
IMSG_VMDOP_TERMINATE_VM_EVENT messages on vm termination.

This finishes the work previously committed for supporting multiple
waiters or the cancellation of a client waiting on a vm shutdown.
vmd no longer needs to translate an IMSG_VMDOP_TERMINATE_VM_RESPONSE
into an *_EVENT.

ok mlarkin@

Revision 1.78 / (download) - annotate - [select for diffs], Wed May 12 20:13:00 2021 UTC (3 years ago) by dv
Branch: MAIN
Changes since 1.77: +1 -10 lines
Diff to previous 1.77 (colored)

vmctl(8): remove unveil from disk image creation routines

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@

Revision 1.77 / (download) - annotate - [select for diffs], Mon Mar 22 18:50:11 2021 UTC (3 years, 2 months ago) by kn
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.76: +4 -4 lines
Diff to previous 1.76 (colored)

Properly reflect stopping state

Diff from Preben Guldberg < preben at guldberg dot org>, thanks!

In "vmctl status", VMs that are being stopped but are still running
will simply show up as "running".

Give preference to showing the "stopping" state akin to how a paused
VM is handled.

Tested by Dave Voutila
OK tb

Revision 1.76 / (download) - annotate - [select for diffs], Wed Jan 27 07:21:12 2021 UTC (3 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.75: +3 -1 lines
Diff to previous 1.75 (colored)

split out extern and decl for -fno-common

Revision 1.75 / (download) - annotate - [select for diffs], Wed Sep 2 19:57:33 2020 UTC (3 years, 9 months ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.74: +2 -2 lines
Diff to previous 1.74 (colored)

Fix clang warning in vmctl(8)

If the path to a tty doesn't contain a '/' or ends in a '/' use the full
path. (The intent is to chop off the leading "/dev/")

ok deraadt (who had the same diff) martijn millert

Revision 1.74 / (download) - annotate - [select for diffs], Wed Mar 11 12:47:49 2020 UTC (4 years, 2 months ago) by jasper
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.73: +2 -2 lines
Diff to previous 1.73 (colored)

fix spelling of IMSG_VMDOP_TERMINATE_VM_RESPONSE in comment

from Matt Schultz

Revision 1.73 / (download) - annotate - [select for diffs], Sun Dec 15 14:36:59 2019 UTC (4 years, 5 months ago) by kn
Branch: MAIN
Changes since 1.72: +1 -3 lines
Diff to previous 1.72 (colored)

Explicitly print root user in status OWNER column

With "owner root:wheel" (any group) the status output prints ":wheel" only,
presumably to emphasize that only group membership matters.

Always print whatever is configured to be explicit and less confusing.

OK jasper

Revision 1.72 / (download) - annotate - [select for diffs], Thu Dec 12 03:53:38 2019 UTC (4 years, 5 months ago) by pd
Branch: MAIN
Changes since 1.71: +3 -1 lines
Diff to previous 1.71 (colored)

vmd: start vms defined in vm.conf in a staggered fashion

This addresses 'thundering herd' problem when a lot of
vms are configured in vm.conf.  A lot of vms booting in parallel can
overload the host and also mess up tsc calibration in openbsd guests as
it uses PIT which doesn't fire reliably if the host is overloaded.

We default to starting vms with parallelism of ncpuonline and a delay 30 seconds
between batches.  This is configurable in vm.conf.

ok mlarkin@ (also addressed comments from cheloha@)

Revision 1.71 / (download) - annotate - [select for diffs], Sat Sep 7 09:11:14 2019 UTC (4 years, 9 months ago) by tobhe
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.70: +1 -6 lines
Diff to previous 1.70 (colored)

Remove unused VMD_DISK_INVALID message type and mark it obsolete.

ok mlarkin@

Revision 1.70 / (download) - annotate - [select for diffs], Wed Aug 14 07:34:49 2019 UTC (4 years, 9 months ago) by anton
Branch: MAIN
Changes since 1.69: +5 -1 lines
Diff to previous 1.69 (colored)

Improve the error message when supplying an invalid template to vmctl
start. Favoring 'invalid template' over 'permission denied' should give
the user a better hint on what went wrong.

ok kn@ mlarkin@

Revision 1.69 / (download) - annotate - [select for diffs], Wed May 22 16:19:21 2019 UTC (5 years ago) by jasper
Branch: MAIN
Changes since 1.68: +7 -7 lines
Diff to previous 1.68 (colored)

re-order to reported states based on order of significance:
paused takes priority over running; running takes priority over disabled

ok mlarkin@ pd@

Revision 1.68 / (download) - annotate - [select for diffs], Thu May 16 06:41:47 2019 UTC (5 years ago) by jasper
Branch: MAIN
Changes since 1.67: +2 -4 lines
Diff to previous 1.67 (colored)

treat vms that are disabled in vm.conf the same as any other vm that's stopped
"disabled" in this context might imply it being broken or otherwise unusable

prompted by and ok mlarkin@

Revision 1.67 / (download) - annotate - [select for diffs], Sat May 11 23:07:46 2019 UTC (5 years ago) by jasper
Branch: MAIN
Changes since 1.66: +37 -11 lines
Diff to previous 1.66 (colored)

report vm state through 'vmctl status'; whereas previously this would 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@

Revision 1.66 / (download) - annotate - [select for diffs], Tue Apr 2 03:58:57 2019 UTC (5 years, 2 months ago) by kn
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.65: +8 -17 lines
Diff to previous 1.65 (colored)

Report reliable VM state on status command

`vmctl status id' reports the VM's VCPU states, that is whether they are
running or halted.

Given that only one VCPU is currently supported per VM and the undocumented
states change across repetitive status commands, change it to indicate the
VM's general state based on whether the respective host procces is running
or not.

This makes vmctl reliably report "STATE: RUNNING" and "STATE: STOPPED" for
started and stopped VMs respectively.

OK mlarkin

Revision 1.65 / (download) - annotate - [select for diffs], Thu Dec 6 09:23:15 2018 UTC (5 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.64: +3 -2 lines
Diff to previous 1.64 (colored)

Add a new argument -B device to vmctl start. It allows to set the boot device.
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@

Revision 1.64 / (download) - annotate - [select for diffs], Tue Dec 4 08:17:17 2018 UTC (5 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.63: +32 -1 lines
Diff to previous 1.63 (colored)

Add 'vmctl wait <VM>' a command that waits until the specified VM is
stopped/terminates. Useful in scripts when waiting until a vm has finished
its work.
Ok ccardenas@, reyk@

Revision 1.63 / (download) - annotate - [select for diffs], Mon Nov 26 10:39:30 2018 UTC (5 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.62: +5 -182 lines
Diff to previous 1.62 (colored)

Move the {qcow2,raw} create functions from vmctl into vmd/vio{qcow2,raw}.c

This way they are in the appropriate place and code can be shared with vmd.

Ok ori@ mlarkin@ ccardenas@

Revision 1.62 / (download) - annotate - [select for diffs], Fri Oct 19 10:12:39 2018 UTC (5 years, 7 months ago) by reyk
Branch: MAIN
Changes since 1.61: +113 -4 lines
Diff to previous 1.61 (colored)

Add support to create and convert disk images from existing images

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@

Revision 1.61 / (download) - annotate - [select for diffs], Mon Oct 8 16:32:01 2018 UTC (5 years, 8 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.60: +34 -10 lines
Diff to previous 1.60 (colored)

Add support for qcow2 base images (external snapshots).

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@

Revision 1.60 / (download) - annotate - [select for diffs], Tue Oct 2 16:42:38 2018 UTC (5 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.59: +7 -8 lines
Diff to previous 1.59 (colored)

Fix potential rounding errors when calculating the qcow2 l1 and ref tables sizes

OK ccardenas@ mlarkin@

Revision 1.59 / (download) - annotate - [select for diffs], Thu Sep 27 17:15:36 2018 UTC (5 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.58: +73 -16 lines
Diff to previous 1.58 (colored)

Add vmctl stop -a [-fw] option to stop or terminate all running VMs.

This is also be used to simplify the vmd rc stop script.

OK mlarkin@ ccardenas@

Revision 1.58 / (download) - annotate - [select for diffs], Sun Sep 16 02:43:11 2018 UTC (5 years, 8 months ago) by millert
Branch: MAIN
Changes since 1.57: +8 -8 lines
Diff to previous 1.57 (colored)

Use user_from_uid(3) and group_from_gid(3) in a few more places
that do repeated lookups.  OK tb@

Revision 1.57 / (download) - annotate - [select for diffs], Tue Sep 11 04:03:16 2018 UTC (5 years, 8 months ago) by ccardenas
Branch: MAIN
Changes since 1.56: +123 -3 lines
Diff to previous 1.56 (colored)

Add ability to create qcow2 disk.

vmctl create now takes an optional disk format parameter: raw or qcow2.
If format is omitted, raw is used.

Many thanks to Ori Bernstein.

Revision 1.56 / (download) - annotate - [select for diffs], Sun Sep 9 04:09:32 2018 UTC (5 years, 9 months ago) by ccardenas
Branch: MAIN
Changes since 1.55: +6 -4 lines
Diff to previous 1.55 (colored)

Add initial qcow2 image support.

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.

Revision 1.55 / (download) - annotate - [select for diffs], Thu Aug 23 06:04:53 2018 UTC (5 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.54: +3 -3 lines
Diff to previous 1.54 (colored)

Allow to boot CDROM-only VMs.

Pointed out by Jon Williams

OK mlarkin@ kn@ ccardenas@

Revision 1.54 / (download) - annotate - [select for diffs], Thu Jul 12 12:04:49 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.53: +12 -4 lines
Diff to previous 1.53 (colored)

Allow to use configured/running VMs as templates for other VM instances.

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@

Revision 1.53 / (download) - annotate - [select for diffs], Wed Jul 11 21:29:05 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.52: +21 -10 lines
Diff to previous 1.52 (colored)

check string lengths in vm_start

Revision 1.52 / (download) - annotate - [select for diffs], Wed Jul 11 13:19:47 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.51: +13 -11 lines
Diff to previous 1.51 (colored)

Add -w option to vmctl stop to wait for completion of VM termination.

Use it in /etc/rc.d/vmd accordingly.

OK sthen@

Revision 1.51 / (download) - annotate - [select for diffs], Wed Jul 11 09:35:44 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.50: +10 -4 lines
Diff to previous 1.50 (colored)

Add -f option to vmctl stop to forcefully kill a VM.

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@

Revision 1.50 / (download) - annotate - [select for diffs], Wed Jul 4 02:55:37 2018 UTC (5 years, 11 months ago) by anton
Branch: MAIN
Changes since 1.49: +2 -1 lines
Diff to previous 1.49 (colored)

When a VM stop request fails, set errno prior to calling warn() in order to
display the correct error message. This is a pattern found elsewhere in vmctl.

With input from deraadt@ and encouraged by mlarkin@

Revision 1.49 / (download) - annotate - [select for diffs], Tue Jun 19 17:13:50 2018 UTC (5 years, 11 months ago) by reyk
Branch: MAIN
Changes since 1.48: +6 -5 lines
Diff to previous 1.48 (colored)

knf

Revision 1.48 / (download) - annotate - [select for diffs], Wed Mar 14 07:29:34 2018 UTC (6 years, 2 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.47: +2 -2 lines
Diff to previous 1.47 (colored)

block two VMs from using the same disk image file at the same time.
Also changes an error message in vmctl to reflect same.

Revision 1.47 / (download) - annotate - [select for diffs], Wed Mar 14 07:07:44 2018 UTC (6 years, 2 months ago) by mlarkin
Branch: MAIN
Changes since 1.46: +3 -3 lines
Diff to previous 1.46 (colored)

knf

Revision 1.46 / (download) - annotate - [select for diffs], Mon Feb 26 06:36:53 2018 UTC (6 years, 3 months ago) by ccardenas
Branch: MAIN
Changes since 1.45: +2 -2 lines
Diff to previous 1.45 (colored)

vmctl: clarify console error message

Clear up ambiguous error message when attaching to a console fails as
the vm id is not guaranteed to be populated.

ok mlarkin@

Revision 1.45 / (download) - annotate - [select for diffs], Wed Jan 3 05:39:56 2018 UTC (6 years, 5 months ago) by ccardenas
Branch: MAIN
Changes since 1.44: +17 -2 lines
Diff to previous 1.44 (colored)

Add initial CD-ROM support to VMD via vioscsi.

* 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@

Revision 1.44 / (download) - annotate - [select for diffs], Fri Sep 8 07:08:49 2017 UTC (6 years, 9 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.43: +13 -5 lines
Diff to previous 1.43 (colored)

better VM termination handling.

diff provided by Carlos Cardenas, thanks

Revision 1.43 / (download) - annotate - [select for diffs], Fri Sep 8 06:43:47 2017 UTC (6 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.42: +2 -2 lines
Diff to previous 1.42 (colored)

vmctl: style cleanup - spaces vs tabs.

Noticed by Carlos Cardenas

Revision 1.42 / (download) - annotate - [select for diffs], Thu Aug 31 09:15:31 2017 UTC (6 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.41: +2 -2 lines
Diff to previous 1.41 (colored)

vmctl: change a feedback message displayed to the user from "terminated
vm X" to "sent request to terminate vm X".

vmctl/vmd have not forcibly terminated VMs in a while, we try to let
vmmci(4) gracefully shutdown the VM, so "vmctl stop" commands are
really requests to stop, not forced stops. The new message indicates
that a shutdown is (possibly) in progress and not "complete".

Revision 1.41 / (download) - annotate - [select for diffs], Thu Aug 31 06:23:37 2017 UTC (6 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.40: +6 -1 lines
Diff to previous 1.40 (colored)

vmd/vmctl: disallow use of block or character devices as disks in VMs.

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!

Revision 1.40 / (download) - annotate - [select for diffs], Wed Aug 30 05:36:23 2017 UTC (6 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.39: +21 -6 lines
Diff to previous 1.39 (colored)

remove use of PAGE_SIZE and #include <sys/param.h>

ok deraadt

Revision 1.39 / (download) - annotate - [select for diffs], Tue Aug 29 21:10:20 2017 UTC (6 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.38: +2 -2 lines
Diff to previous 1.38 (colored)

quarterly rescan of the tree:  remove unneccessary sys/param.h, and
annotate the ones which are needed.

Revision 1.38 / (download) - annotate - [select for diffs], Fri Aug 18 07:01:29 2017 UTC (6 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.37: +12 -4 lines
Diff to previous 1.37 (colored)

distinguish errors during vm launch and return different error codes to
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@

Revision 1.37 / (download) - annotate - [select for diffs], Mon Aug 14 21:41:49 2017 UTC (6 years, 9 months ago) by jasper
Branch: MAIN
Changes since 1.36: +5 -2 lines
Diff to previous 1.36 (colored)

return a proper error message instead of 'no such file or directory' when
invoking 'stop' for a non-existent vm

ok mlarkin@

Revision 1.36 / (download) - annotate - [select for diffs], Mon Aug 14 19:46:44 2017 UTC (6 years, 9 months ago) by jasper
Branch: MAIN
Changes since 1.35: +5 -5 lines
Diff to previous 1.35 (colored)

whitespace and fix a comment typo

Revision 1.35 / (download) - annotate - [select for diffs], Mon Aug 14 19:38:04 2017 UTC (6 years, 9 months ago) by jasper
Branch: MAIN
Changes since 1.34: +8 -3 lines
Diff to previous 1.34 (colored)

catch ENOENT and display a proper error message when a specified disk image is
not found

ok mlarkin@

Revision 1.34 / (download) - annotate - [select for diffs], Mon Aug 14 17:52:05 2017 UTC (6 years, 9 months ago) by jasper
Branch: MAIN
Changes since 1.33: +18 -2 lines
Diff to previous 1.33 (colored)

don't allow starting vms whose name starts with '-', '.' or '_'

Revision 1.33 / (download) - annotate - [select for diffs], Thu Aug 10 19:17:43 2017 UTC (6 years, 9 months ago) by jasper
Branch: MAIN
Changes since 1.32: +4 -3 lines
Diff to previous 1.32 (colored)

don't have cu try to open '/dev', instead check if there's a valid tty
associated with the vm upfront

as discussed with and ok mlarkin@ pd@

Revision 1.32 / (download) - annotate - [select for diffs], Sat Jul 15 05:05:36 2017 UTC (6 years, 10 months ago) by pd
Branch: MAIN
Changes since 1.31: +64 -1 lines
Diff to previous 1.31 (colored)

Add vmctl send and vmctl receive

ok reyk@ and mlarkin@

Revision 1.31 / (download) - annotate - [select for diffs], Sun Jul 9 00:51:40 2017 UTC (6 years, 11 months ago) by pd
Branch: MAIN
Changes since 1.30: +79 -1 lines
Diff to previous 1.30 (colored)

vmd/vmctl: Add ability to pause / unpause vms

With help from Ashwin Agrawal

ok reyk@ mlarkin@

Revision 1.30 / (download) - annotate - [select for diffs], Wed Apr 19 15:38:32 2017 UTC (7 years, 1 month ago) by reyk
Branch: MAIN
Changes since 1.29: +10 -2 lines
Diff to previous 1.29 (colored)

Add support for dynamic "NAT" interfaces (-L/local interface).

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@

Revision 1.29 / (download) - annotate - [select for diffs], Thu Apr 6 18:07:13 2017 UTC (7 years, 2 months ago) by reyk
Branch: MAIN
Changes since 1.28: +8 -6 lines
Diff to previous 1.28 (colored)

Do not expose vmm(4) VM IDs to the user, use vmd(8)'s IDs instead.

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@

Revision 1.28 / (download) - annotate - [select for diffs], Thu Mar 30 03:39:35 2017 UTC (7 years, 2 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.27: +4 -2 lines
Diff to previous 1.27 (colored)

Set interface flag to VMIFF_UP when using -i option. This way vmd will make
sure the interfaces are up on startup.
OK deraadt@, reky@

Revision 1.27 / (download) - annotate - [select for diffs], Wed Mar 15 18:00:11 2017 UTC (7 years, 2 months ago) by reyk
Branch: MAIN
Changes since 1.26: +4 -2 lines
Diff to previous 1.26 (colored)

Print "-" if the tty name is empty.

Revision 1.26 / (download) - annotate - [select for diffs], Fri Mar 3 09:12:40 2017 UTC (7 years, 3 months ago) by reyk
Branch: MAIN
Changes since 1.25: +7 -6 lines
Diff to previous 1.25 (colored)

Undefined behavior: Variable 'user' was used as parameter and
destination in snprintf().  Use a temporary variable instead.

Found and OK by jsg@

Revision 1.25 / (download) - annotate - [select for diffs], Wed Mar 1 21:22:57 2017 UTC (7 years, 3 months ago) by reyk
Branch: MAIN
Changes since 1.24: +4 -4 lines
Diff to previous 1.24 (colored)

Rename start_vm_complete to vm_start_complete for consistency.

Revision 1.24 / (download) - annotate - [select for diffs], Wed Mar 1 21:15:26 2017 UTC (7 years, 3 months ago) by mlarkin
Branch: MAIN
Changes since 1.23: +3 -3 lines
Diff to previous 1.23 (colored)

unbreak vmctl build by renaming a function that now conflicts with
something from vmd.h . Temporary fix until the original committer can
fix it the way he desires.

Revision 1.23 / (download) - annotate - [select for diffs], Wed Mar 1 07:43:33 2017 UTC (7 years, 3 months ago) by reyk
Branch: MAIN
Changes since 1.22: +32 -8 lines
Diff to previous 1.22 (colored)

Add "owner" option to set a user/group ownership for pre-configured VMs

This allows matching users to start or stop VMs that they "own" and to
access the console accordingly.

OK mlarkin@

Revision 1.22 / (download) - annotate - [select for diffs], Tue Feb 28 08:35:08 2017 UTC (7 years, 3 months ago) by reyk
Branch: MAIN
Changes since 1.21: +29 -12 lines
Diff to previous 1.21 (colored)

Use fmt_scaled(3) in vmctl status output to print curmem/maxmem

This matches the accepted input in vmctl start and vm.conf that
supports using M, G, T etc. instead of a hardcoded MB.  It also allows
to shrink the column size as the unit will be scaled automatically.

OK mlarkin@

Revision 1.21 / (download) - annotate - [select for diffs], Wed Dec 14 21:17:25 2016 UTC (7 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.20: +28 -15 lines
Diff to previous 1.20 (colored)

Allow to start disabled and pre-configured VMs by name, "vmctl start foo".

With testing from Jon Bernard

OK mlarkin@

Revision 1.20 / (download) - annotate - [select for diffs], Sat Nov 26 19:49:11 2016 UTC (7 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.19: +2 -2 lines
Diff to previous 1.19 (colored)

If -m/memory is not specified, use 512M by default.

Default value picked with mlarkin - not too small and not too large.

OK mlarkin@

Revision 1.19 / (download) - annotate - [select for diffs], Sat Nov 26 18:37:32 2016 UTC (7 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.18: +9 -5 lines
Diff to previous 1.18 (colored)

Add the vmctl start -n option to specify add a network interface to
the specified virtual switch from the command line.

OK mlarkin@

Revision 1.18 / (download) - annotate - [select for diffs], Thu Nov 24 07:58:55 2016 UTC (7 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.17: +5 -4 lines
Diff to previous 1.17 (colored)

Add support for booting the kernel from the disk image.

This make the kernel/-k argument optional and, if not specified, tries
to find the /bsd kernel in the primary hd0a partition of the first
disk image itself.  It doesn't support hd0a:/etc/boot.conf yet, and it
is no BIOS or full boot loader, but it makes booting and handling of
VMs a bit easier - booting an external kernel is still supported.

The UFS file system code ufs.c is directly from libsa which is also
used by the real boot loader.  The code compiles with a few signedness
warning which will be fixed separately.

OK mlarkin@

Revision 1.17 / (download) - annotate - [select for diffs], Tue Nov 22 11:31:38 2016 UTC (7 years, 6 months ago) by edd
Branch: MAIN
Changes since 1.16: +16 -6 lines
Diff to previous 1.16 (colored)

Insert disabled VMs into vmd(8)'s queues and allow vmctl(8) to display them.

Tested by Jon Bernard and reyk@.

OK reyk@, no objections mlarkin@.

Thanks

Revision 1.16 / (download) - annotate - [select for diffs], Thu Oct 6 16:53:39 2016 UTC (7 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.15: +7 -5 lines
Diff to previous 1.15 (colored)

The start control imsg has been switched to a new "struct
vmop_create_params" that also includes configuration that is only for
userland.  I forgot to commit this chunk.

Found the hard way by mlarkin@

Revision 1.15 / (download) - annotate - [select for diffs], Tue May 10 11:00:54 2016 UTC (8 years, 1 month ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.14: +14 -1 lines
Diff to previous 1.14 (colored)


move some argument checking from vmmaction() to start_vm()

from a diff posted to tech@ by Fabien Siron, thanks.

Revision 1.14 / (download) - annotate - [select for diffs], Tue May 10 10:49:22 2016 UTC (8 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.13: +2 -2 lines
Diff to previous 1.13 (colored)


typo in comment

Revision 1.13 / (download) - annotate - [select for diffs], Sun Mar 13 13:11:47 2016 UTC (8 years, 2 months ago) by stefan
Branch: MAIN
Changes since 1.12: +8 -2 lines
Diff to previous 1.12 (colored)

Introduce memory ranges to support VMs with >= 4G RAM

Kernel bits:
- When creating a VM, a list of memory ranges has to be specified,
  similar to the BIOS memory map. This is necessary for VMs with
  RAM sizes approaching 4G because we'll need PCI MMIO space in
  the higher parts of the 32 bit address space.

vmctl and vmd bits:
- Construct appropriate memory ranges to create a VM with a given
  RAM size
- Construct a corresponding BIOS memory map from the memory ranges
  and update the boot params page accordingly.
- Make sure that all variables that represent guest physical addresses
  match the address width of the target CPU instead of using uint32_t.
- Fix some integer promotion glitches that actually restricted VM
  RAM size to 2G.

This changes the VM create ioctl interface, so update your kernel,
vmd, and vmctl.

ok mlarkin@

Revision 1.12 / (download) - annotate - [select for diffs], Tue Jan 26 07:58:35 2016 UTC (8 years, 4 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.11: +5 -15 lines
Diff to previous 1.11 (colored)

lseek() + write() can be replaced by a slightly shorter ftruncate()
call. Note that using ftruncate() to extend a file is not portable
(POSIX allows either zero-filling until the given size is reached, or
alternatively erroring out), but that shouldn't be a proble as vmm(4)
isn't cross-platform either.  unlink() the image file when extending
it fails for consistency with the other error case (the file can't be
created).

From Martin Natano
OK mlarkin@

Revision 1.11 / (download) - annotate - [select for diffs], Wed Jan 13 13:08:20 2016 UTC (8 years, 4 months ago) by reyk
Branch: MAIN
Changes since 1.10: +16 -2 lines
Diff to previous 1.10 (colored)

Update the comments in vmctl.c that are describing function arguments.

Revision 1.10 / (download) - annotate - [select for diffs], Mon Dec 14 06:59:07 2015 UTC (8 years, 5 months ago) by mlarkin
Branch: MAIN
Changes since 1.9: +6 -6 lines
Diff to previous 1.9 (colored)


track used memory in each VM. This is passed back to vmctl status.

ok reyk@, beck@, mpi@

Revision 1.9 / (download) - annotate - [select for diffs], Fri Dec 11 10:16:53 2015 UTC (8 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.8: +34 -10 lines
Diff to previous 1.8 (colored)

The vmctl "id" argument can now be a number of or a vm name, eg.
vmctl stop 3
vmctl stop "openbsd.vm"

Revision 1.8 / (download) - annotate - [select for diffs], Tue Dec 8 08:01:20 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.7: +36 -11 lines
Diff to previous 1.7 (colored)

Add "vmctl console" to connect to a specified VM console by id.

Requested by mlarkin@

Revision 1.7 / (download) - annotate - [select for diffs], Mon Dec 7 18:23:24 2015 UTC (8 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.6: +4 -11 lines
Diff to previous 1.6 (colored)

use O_EXCL rather than a race

Revision 1.6 / (download) - annotate - [select for diffs], Sun Dec 6 02:26:14 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.5: +19 -16 lines
Diff to previous 1.5 (colored)

Print the TTY in the vmctl status output.

Revision 1.5 / (download) - annotate - [select for diffs], Sun Dec 6 01:58:21 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.4: +16 -18 lines
Diff to previous 1.4 (colored)

When a new vm is created with VMM_IOC_CREATE, the kernel assigns a
unique id to it.  This happens in the vm child process and has to be
communicated to the parent processes to track the vm.  Knowing the vm
id in the parent and vmm processes also allows to remove vm from the
daemons list on terminate requests later.

Revision 1.4 / (download) - annotate - [select for diffs], Sat Dec 5 20:26:38 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.3: +2 -0 lines
Diff to previous 1.3 (colored)

Add OpenBSD Id

Revision 1.3 / (download) - annotate - [select for diffs], Sat Dec 5 18:48:24 2015 UTC (8 years, 6 months ago) by mlarkin
Branch: MAIN
Changes since 1.2: +1 -1 lines
Diff to previous 1.2 (colored)


Align columns to printed output in "vmctl status"

Revision 1.2 / (download) - annotate - [select for diffs], Fri Dec 4 15:40:17 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.1: +12 -1 lines
Diff to previous 1.1 (colored)

Add -c option to "vmctl start" to automatically connect to the VM
console after startup.  This calls 'cu -l $TTY -s 9600' internally -
a "safe mode" for cu is proposed by tedu@.

Requested by mlarkin@
OK tedu@ on the execl/cu chunk

Revision 1.1 / (download) - annotate - [select for diffs], Thu Dec 3 21:45:45 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN

Replace vmmctl with vmctl.  Also remove parse.y from the "new" vmctl.

As discussed with mlarkin@ and deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.