OpenBSD CVS

CVS log for src/usr.sbin/vmd/vmm.c


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.119 / (download) - annotate - [select for diffs], Mon Feb 5 21:58:09 2024 UTC (3 months, 3 weeks ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, HEAD
Changes since 1.118: +12 -27 lines
Diff to previous 1.118 (colored)

Cleanup fcntl(3) usage and fd lifetimes in vmd(8).

Remove extraneous fcntl(3) usage for setting fd features that can
be set at time of open(2), pipe2(2), or socketpair(2). Also cleans
up pty creation switching to using functions from libutil instead
of direct ioctl(2) calls.

ok mlarkin@, original diff ok claudio@ as well.

Revision 1.118 / (download) - annotate - [select for diffs], Sun Feb 4 14:57:00 2024 UTC (3 months, 3 weeks ago) by dv
Branch: MAIN
Changes since 1.117: +2 -4 lines
Diff to previous 1.117 (colored)

Remove dead code and fix null deref if vm is not found.

Return early if no vm is found in vmd(8)'s primary vm fork/exec
function, preventing null deref in the 'fail' section. Also remove
inner return from the parent routine to prevent unreachable code.

Found by smatch, reported by and ok jsg@.

Revision 1.117 / (download) - annotate - [select for diffs], Thu Jan 18 14:49:59 2024 UTC (4 months, 1 week ago) by claudio
Branch: MAIN
Changes since 1.116: +11 -11 lines
Diff to previous 1.116 (colored)

Use imsg_get_fd() in vmd.

vmd uses a lot of fd passing and does it sometimes via extra abstraction
so this just tries to convert the code without any optimisations.

ok dv@

Revision 1.116 / (download) - annotate - [select for diffs], Wed Jan 3 22:34:39 2024 UTC (4 months, 4 weeks ago) by dv
Branch: MAIN
Changes since 1.115: +24 -9 lines
Diff to previous 1.115 (colored)

vmd(8): improve error messages when out of tap devices.

The logging and the (lack of) errno don't describe the actual reason
a vm fails to start when there are not enough tap(4) special files
in /dev. Improve the log message to specify the tap file in question
and set ENOENT so vmctl(8) gets something other than an undefined
errno value to report.

ok bluhm@

Revision 1.115 / (download) - annotate - [select for diffs], Tue Sep 26 01:53:54 2023 UTC (8 months ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.114: +2 -2 lines
Diff to previous 1.114 (colored)

vmd(8): disambiguate log messages per vm and device.

The logging output from vmd(8) often specifies the function performing
the logging, but leaves which vm or vm device to guesswork and
reading tea leaves.

Change the logging formatting to prefix with information about the
specific vm and potentially the device subprocess. Most of this
logging is behind the "verbose" mode, but for warnings this will
clarify which vm or device logged the warning.

The format of vm/<name>/<device><index> is chosen to be concise and
less ugly than other approaches. This adjusts the process naming
for devices to match, dropping the use of brackets.

In the process of this change, updating log settings dynamically
via vmctl(8) is fixed by properly broadcasting that information to
the device subprocesses. The "vmm" process also now updates its own
state properly, so settings survive vm reboots.

ok mlarkin@

Revision 1.114 / (download) - annotate - [select for diffs], Thu Jul 27 09:27:43 2023 UTC (10 months ago) by dv
Branch: MAIN
Changes since 1.113: +8 -5 lines
Diff to previous 1.113 (colored)

vmd(8): fix verbose logging in child processes.

The introduction of exec for vm's and fork+exec for virtio block
and network devices missed passing the log verbosity in argv. Add
the "-v" arguments based on current vverbosity at time of exec.

ok brynet@, mlarkin@

Revision 1.113 / (download) - annotate - [select for diffs], Thu Jul 13 18:31:59 2023 UTC (10 months, 2 weeks ago) by dv
Branch: MAIN
Changes since 1.112: +11 -1 lines
Diff to previous 1.112 (colored)

vmd(8): pull validation into local prefix parser.

Validation for local prefixes, both inet and inet6, was scattered
around. To make it even more confusing, vmd was using generic address
parsing logic from prior network daemons. vmd doesn't need to parse
addresses other than when parsing the local prefix settings in
vm.conf and no runtime parsing is needed.

This change merges parsing and validation based on vmd's specific
needs for local prefixes (e.g. reserving enough bits for vm id and
network interface id encoding in an ipv4 address). In addition, it
simplifies the struct from a generic address struct to one focused
on just storing the v4 and v6 prefixes and masks. This cleans up an
unused TAILQ struct member that isn't used by vmd and was leftover
copy-pasta from those prior daemons.

The address parsing that vmd uses is also updated to using the
latest logic in bgpd(8).

ok mlarkin@

Revision 1.112 / (download) - annotate - [select for diffs], Sat May 13 23:15:28 2023 UTC (12 months, 2 weeks ago) by dv
Branch: MAIN
Changes since 1.111: +9 -15 lines
Diff to previous 1.111 (colored)

vmm(4)/vmd(8): switch to anonymous shared mappings.

While splitting out emulated virtio network and block devices into
separate processes, I originally used named mappings via shm_mkstemp(3).
While this functionally achieved the desired result, it had two
unintended consequences:

1) tearing down a vm process and its child processes required
excessive locking as the guest memory was tied into the VFS layer.

2) it was observed by mlarkin@ that actions in other parts of the
VFS layer could cause some of the guest memory to flush to storage,
possibly filling /tmp.

This commit adds a new vmm(4) ioctl dedicated to allowing a process
request the kernel share a mapping of guest memory into its own vm
space. This requires an open fd to /dev/vmm (requiring root) and
both the "vmm" and "proc" pledge(2) promises. In addition, the caller
must know enough about the original memory ranges to reconstruct them
to make the vm's ranges.

Tested with help from Mischa Peters.

ok mlarkin@

Revision 1.111 / (download) - annotate - [select for diffs], Thu Apr 27 22:47:27 2023 UTC (13 months ago) by dv
Branch: MAIN
Changes since 1.110: +9 -3 lines
Diff to previous 1.110 (colored)

vmd(8): introduce multi-process model for virtio devices.

Isolate virtio network and block device emulation in dedicated
processes, forked and exec'd from the vm process. This allows for
tightening pledge promises to just "stdio".

Communication between the vcpu's and these devices now occurs via
imsg channels, which adds the benefit of not always blocking the
vcpu thread while emulating the device.

With this commit, it's possible that vmd is the first open source
hypervisor that *defaults* to a multi-process device emulation
model without requiring any additional configuration from the
operator.

Testing help from phessler@ and Mischa Peters.

ok mlarkin@

Revision 1.110 / (download) - annotate - [select for diffs], Tue Apr 25 12:46:13 2023 UTC (13 months, 1 week ago) by dv
Branch: MAIN
Changes since 1.109: +5 -5 lines
Diff to previous 1.109 (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.109 / (download) - annotate - [select for diffs], Sun Apr 23 12:11:37 2023 UTC (13 months, 1 week ago) by dv
Branch: MAIN
Changes since 1.108: +101 -13 lines
Diff to previous 1.108 (colored)

vmd(8): teach vmm process how to exec.

Use execvp(2) to launch vm children with new address spaces.
Consequently, introduces use of unveil(2) into the vmm and vm
processes.

This imposes the requirement of launching vmd with absolute paths,
similar to sshd(8).

ok mlarkin@

Revision 1.108 / (download) - annotate - [select for diffs], Sun Apr 16 12:47:26 2023 UTC (13 months, 2 weeks ago) by dv
Branch: MAIN
Changes since 1.107: +13 -22 lines
Diff to previous 1.107 (colored)

vmd(8): clean up fd closing in vmm process.

Some mild tidying of fd closing in the vmm process in prep for
landing parts of my fork+exec diff.

With input from guenther@ on the nuances of if/when EINTR may happen
in a call to close(2).

ok mlarkin@

Revision 1.107 / (download) - annotate - [select for diffs], Sat Jan 14 20:55:55 2023 UTC (16 months, 2 weeks ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.106: +9 -4 lines
Diff to previous 1.106 (colored)

Only open /dev/vmm once in vmd(8).

Have the parent process open /dev/vmm and send the fd to the vmm
child process. Only the vmm process and its resulting children
(guest vms) need it for ioctl calls.

ok kn@

Revision 1.106 / (download) - annotate - [select for diffs], Sun Nov 6 11:54:08 2022 UTC (18 months, 3 weeks ago) by dv
Branch: MAIN
Changes since 1.105: +2 -2 lines
Diff to previous 1.105 (colored)

Fix typo in comment about pledges (send -> sendfd).

No functional change.

Revision 1.105 / (download) - annotate - [select for diffs], Sun Apr 10 19:36:58 2022 UTC (2 years, 1 month ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.104: +7 -5 lines
Diff to previous 1.104 (colored)

Free vm_info_result in error paths.

vmd(8)'s get_info_vm() mallocs vm_info_result structs when using
the VMM_IOC_INFO ioctl. The error paths failed to free the resulting
objects.

Diff adapted from suggestions by jca@. ok mlarkin@.

Revision 1.104 / (download) - annotate - [select for diffs], Tue Mar 1 21:46:19 2022 UTC (2 years, 3 months ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.103: +17 -10 lines
Diff to previous 1.103 (colored)

vmd(8): gracefully handle hitting data limits when starting a vm

With recent changes to login.conf(5) to restrict daemon datasize
to a finite value, users can now hit resource limits when attempting
to start a vm.

This change fixes the error path when hitting the limit. vmd(8)
will no longer abort and memory error messages are relayed to the
user.

While here, address potential under-reads/writes using atomicio
when relaying data between the child vm process and vmd's vmm
process.

Original diff from tedu@. OK mlarkin@.

Revision 1.103 / (download) - annotate - [select for diffs], Tue Jan 4 15:25:05 2022 UTC (2 years, 4 months ago) by claudio
Branch: MAIN
Changes since 1.102: +9 -4 lines
Diff to previous 1.102 (colored)

Try to handle possible vm_register() failures and return an error back
to the caller instead of most probably crashing because of a NULL pointer
access. This fixes also another -Wunused-but-set-variable warning.
OK benno@ dv@

Revision 1.102 / (download) - annotate - [select for diffs], Mon Nov 29 05:17:35 2021 UTC (2 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.101: +2 -3 lines
Diff to previous 1.101 (colored)

mostly avoid sys/param.h with a local nitems()
ok mlarkin

Revision 1.101 / (download) - annotate - [select for diffs], Mon Apr 26 22:58:27 2021 UTC (3 years, 1 month ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.100: +1 -34 lines
Diff to previous 1.100 (colored)

vmd(8): fix vmctl client "wait" state corruption

Adds queue-based tracking of waiting client state to fix the cause of
state corruption when a vmctl(8) user cancels a wait and restarts it.
The socket fd value for the control process client was being used to
track the waiting party, but this also prevented multiple waiting
clients.

This moves all the state tracking of who to notify of a vm's stopping
to the control process and no longer requires the parent process to
track it in the global environment state.

Future work will be needed to smooth out the difference between the
IMSG_VMDOP_TERMINATE_VM_{EVENT,RESPONSE} events instead of needing to
translate before relaying to the vmctl(8) client.

Tested by Mischa Peters (thanks!)

ok mlarkin@

Revision 1.100 / (download) - annotate - [select for diffs], Sun Apr 11 21:02:40 2021 UTC (3 years, 1 month ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.99: +22 -21 lines
Diff to previous 1.99 (colored)

KNF, capitalization, whitespace

Revision 1.99 / (download) - annotate - [select for diffs], Thu Apr 1 11:05:47 2021 UTC (3 years, 2 months ago) by dv
Branch: MAIN
Changes since 1.98: +1 -2 lines
Diff to previous 1.98 (colored)

Remove extraneous call of vm_getbyvmid during pause event

The vm is already being assigned by a call in the if-condition.

Revision 1.98 / (download) - annotate - [select for diffs], Mon Mar 29 23:37:01 2021 UTC (3 years, 2 months ago) by dv
Branch: MAIN
Changes since 1.97: +14 -1 lines
Diff to previous 1.97 (colored)

Propagate host-side tap(4) lladdr to guest vm process to allow unicast dhcp
and bootp renewals with vmd(8)'s built-in dhcp server. Previous behavior
ignored did not intercept these packets and instead transmitted them.

This should make vmd(8)'s dhcp behave more as a true dhcp server should and
allows it to work properly with the new dhcpleased(8) attempting a renewal.

OK mlarkin@

Revision 1.97 / (download) - annotate - [select for diffs], Tue Mar 2 02:56:22 2021 UTC (3 years, 3 months ago) by jsg
Branch: MAIN
Changes since 1.96: +2 -2 lines
Diff to previous 1.96 (colored)

don't read past the end of an array
ok mvs@ mlarkin@

Revision 1.96 / (download) - annotate - [select for diffs], Thu Apr 30 03:50:53 2020 UTC (4 years, 1 month ago) by pd
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.95: +1 -5 lines
Diff to previous 1.95 (colored)

vmd(8): correctly terminate vm processes after sending vm

Instead of a round about way of sending a message to vmm that 'send is
successful' and terminating by vm_remove from vmm, we can send the imsg and
exit in the vm process.  The sigchld handler in vmm will vm_remove it from its
structures.  This is how a normal vm is terminated as well.

Previously, vm_remove was called in vmm_dispatch_vm (ie. the event handler to
receive messages from vm process) when hanlding the IMSG_VMDOP_SEND_VM_RESPONSE
(ie. the vm process has written the vm state to the fd passed on by vmctl
send).  This is not how vm_remove was intented to be used as it does a
free(vm).  The vm struct holds the buffers for imsg and so after handling this
IMSG_VMDOP_SEND_VM_RESPONSE message, vmm_dispatch_vm loops again to do
imsg_get(ibuf, &imsg) to read the next message (and we had just freed this
*ibuf when we freed the vm struct) causing it to segfault.

reported by kn@
ok kn@

Revision 1.95 / (download) - annotate - [select for diffs], Wed Dec 11 06:45:17 2019 UTC (4 years, 5 months ago) by pd
Branch: MAIN
Changes since 1.94: +2 -1 lines
Diff to previous 1.94 (colored)

vmd: proper concurrency control when pausing a vm

Removes an XXX which slept for 1s waiting for the vcpu thread to reach HLT and
pause.  We now define a paused and unpaused condition so that a call to
pause_vm() / vmctl pause blocks till the vm really reaches a paused state.

Also, detach events for devices from event loop when pausing and add them back
when unpausing.  This is because some callbacks call pthread_mutex_lock and if
the vm is paused, it would block also causing the libevent thread to block.
This would mean that we would not be able to process any IMSGs received from vmm
(parent process) including a message to unpause.


ok mlarkin@

Revision 1.94 / (download) - annotate - [select for diffs], Fri Oct 25 09:57:33 2019 UTC (4 years, 7 months ago) by kn
Branch: MAIN
Changes since 1.93: +4 -5 lines
Diff to previous 1.93 (colored)

ifname in opentap() is not optional

The function argument is not checked at all and the only caller in config.c
always passes a buffer valid buffer.

Defer the error case's default value to the end to avoid rewriting in case
a node is opened.

Feedback and OK reyk

Revision 1.93 / (download) - annotate - [select for diffs], Fri Jun 28 13:32:51 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.92: +3 -3 lines
Diff to previous 1.92 (colored)

When system calls indicate an error they return -1, not some arbitrary
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.

Revision 1.92 / (download) - annotate - [select for diffs], Sat May 11 19:55:14 2019 UTC (5 years ago) by jasper
Branch: MAIN
Changes since 1.91: +10 -10 lines
Diff to previous 1.91 (colored)

track the state of the vm (running, paused, etc) using a single bitfield 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@

Revision 1.91 / (download) - annotate - [select for diffs], Tue Dec 4 08:15:09 2018 UTC (5 years, 5 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.90: +33 -5 lines
Diff to previous 1.90 (colored)

Introduce IMSG_VMDOP_WAIT_VM_REQUEST a control message that registers a
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@

Revision 1.90 / (download) - annotate - [select for diffs], Mon Oct 8 16:32:01 2018 UTC (5 years, 7 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.89: +7 -4 lines
Diff to previous 1.89 (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.89 / (download) - annotate - [select for diffs], Mon Sep 10 10:39:26 2018 UTC (5 years, 8 months ago) by bluhm
Branch: MAIN
Changes since 1.88: +13 -11 lines
Diff to previous 1.88 (colored)

vmd(8) clould close file descriptor 0 as not all fd fields were
properly initialized with -1.  Also avoid closing -1.
OK mlarkin@

Revision 1.88 / (download) - annotate - [select for diffs], Fri Jul 13 08:42:49 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.87: +2 -2 lines
Diff to previous 1.87 (colored)

Add "allow instance" option.

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@

Revision 1.87 / (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.86: +3 -2 lines
Diff to previous 1.86 (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.86 / (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.85: +17 -11 lines
Diff to previous 1.85 (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.85 / (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.84: +25 -19 lines
Diff to previous 1.84 (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.84 / (download) - annotate - [select for diffs], Tue Jul 10 20:52:51 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.83: +9 -5 lines
Diff to previous 1.83 (colored)

Return the VM pid to the vmd parent.  This pid field already existed
in the result but wasn't filled in by the vmm process.  No functional
change.

Revision 1.83 / (download) - annotate - [select for diffs], Tue Jul 10 20:43:15 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.82: +2 -2 lines
Diff to previous 1.82 (colored)

vmd already had DEBUG/DPRINTF, there is no need for VMD_DEBUG/dprintf

Replace all occurences of dprintf with DPRINTF (defined in proc.h).

Revision 1.82 / (download) - annotate - [select for diffs], Tue Jul 10 16:15:51 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.81: +10 -13 lines
Diff to previous 1.81 (colored)

Tweak debug log messages

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

Revision 1.81 / (download) - annotate - [select for diffs], Fri Apr 13 17:12:44 2018 UTC (6 years, 1 month ago) by martijn
Branch: MAIN
Changes since 1.80: +2 -1 lines
Diff to previous 1.80 (colored)

Close socket from vmm to parent after forking to vm process.

Ok ccardenas@

Revision 1.80 / (download) - annotate - [select for diffs], Mon Feb 5 05:01:08 2018 UTC (6 years, 3 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.79: +1 -2 lines
Diff to previous 1.79 (colored)

remove unused function prototype

Revision 1.79 / (download) - annotate - [select for diffs], Wed Jan 3 05:39:56 2018 UTC (6 years, 4 months ago) by ccardenas
Branch: MAIN
Changes since 1.78: +11 -1 lines
Diff to previous 1.78 (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.78 / (download) - annotate - [select for diffs], Tue Oct 24 07:58:52 2017 UTC (6 years, 7 months ago) by mlarkin
Branch: MAIN
Changes since 1.77: +7 -9 lines
Diff to previous 1.77 (colored)

Remove terminate_vm/vm_remove logic from vmm_dispatch_parent. This
logic is present in vmm_sighdlr when a VM process has signaled
SIGCHLD for proper cleanup.

From: Carlos Cardenas, thanks!

Revision 1.77 / (download) - annotate - [select for diffs], Fri Sep 15 02:36:29 2017 UTC (6 years, 8 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.76: +2 -2 lines
Diff to previous 1.76 (colored)

vmd: improve a debug message with more information

Revision 1.76 / (download) - annotate - [select for diffs], Thu Sep 14 10:07:17 2017 UTC (6 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.75: +3 -4 lines
Diff to previous 1.75 (colored)

spacing

Revision 1.75 / (download) - annotate - [select for diffs], Fri Sep 8 07:08:49 2017 UTC (6 years, 8 months ago) by mlarkin
Branch: MAIN
Changes since 1.74: +42 -23 lines
Diff to previous 1.74 (colored)

better VM termination handling.

diff provided by Carlos Cardenas, thanks

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

fix a wrong comment.

Noticed by Carlos Cardenas

Revision 1.73 / (download) - annotate - [select for diffs], Fri Sep 8 06:24:31 2017 UTC (6 years, 8 months ago) by mlarkin
Branch: MAIN
Changes since 1.72: +13 -3 lines
Diff to previous 1.72 (colored)

vmd: add more explanatory log_debug messages

From Carlos Cardenas, many thanks!

Revision 1.72 / (download) - annotate - [select for diffs], Tue Aug 15 15:10:35 2017 UTC (6 years, 9 months ago) by pd
Branch: MAIN
Changes since 1.71: +4 -1 lines
Diff to previous 1.71 (colored)

vmd: fix vm id displayed by vmctl when receiving a vm

Also fix two debug messages and an IMSG type.

Revision 1.71 / (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.70: +50 -7 lines
Diff to previous 1.70 (colored)

Add vmctl send and vmctl receive

ok reyk@ and mlarkin@

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

vmd/vmctl: Add ability to pause / unpause vms

With help from Ashwin Agrawal

ok reyk@ mlarkin@

Revision 1.69 / (download) - annotate - [select for diffs], Fri Apr 21 07:03:26 2017 UTC (7 years, 1 month ago) by reyk
Branch: MAIN
Changes since 1.68: +4 -1 lines
Diff to previous 1.68 (colored)

Add global configuration option "local prefix" to change prefix for -L.

The default prefix is 100.64.0.0/10 from RFC6598.

Requested by sthen@ chris@
OK mlarkin@

Revision 1.68 / (download) - annotate - [select for diffs], Thu Apr 6 18:07:13 2017 UTC (7 years, 1 month ago) by reyk
Branch: MAIN
Changes since 1.67: +17 -10 lines
Diff to previous 1.67 (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.67 / (download) - annotate - [select for diffs], Wed Mar 15 18:06:18 2017 UTC (7 years, 2 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.66: +7 -1 lines
Diff to previous 1.66 (colored)

Improve vmmci(4) shutdown and reboot.

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@

Revision 1.66 / (download) - annotate - [select for diffs], Wed Mar 1 18:00:50 2017 UTC (7 years, 3 months ago) by reyk
Branch: MAIN
Changes since 1.65: +26 -1191 lines
Diff to previous 1.65 (colored)

Split vmm.c into two files: vm.c for the VM child, vmm.c for the parent

As discussed with mlarkin@, it makes it easier to maintain the file.

OK mlarkin@

Revision 1.65 / (download) - annotate - [select for diffs], Tue Jan 24 09:58:00 2017 UTC (7 years, 4 months ago) by mlarkin
Branch: MAIN
Changes since 1.64: +5 -1 lines
Diff to previous 1.64 (colored)

SVM: vmd(8) support for SVM

Revision 1.64 / (download) - annotate - [select for diffs], Tue Jan 17 21:51:01 2017 UTC (7 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.63: +8 -8 lines
Diff to previous 1.63 (colored)

Nuke some whitespace that keeps poking me in the eye as I try to
steal code.

Revision 1.63 / (download) - annotate - [select for diffs], Fri Jan 13 14:50:56 2017 UTC (7 years, 4 months ago) by reyk
Branch: MAIN
Changes since 1.62: +37 -5 lines
Diff to previous 1.62 (colored)

Add host side of vmmci(4) to vmd(8).

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@

Revision 1.62 / (download) - annotate - [select for diffs], Wed Jan 11 22:38:10 2017 UTC (7 years, 4 months ago) by reyk
Branch: MAIN
Changes since 1.61: +148 -6 lines
Diff to previous 1.61 (colored)

Add imsg communication channel between vmd and invividual VMs.
For now, this is only used to forward "log verbose|brief" requests,
but it will be used for better things later.

OK mlarkin@

Revision 1.61 / (download) - annotate - [select for diffs], Sun Jan 8 21:23:32 2017 UTC (7 years, 4 months ago) by mlarkin
Branch: MAIN
Changes since 1.60: +12 -3 lines
Diff to previous 1.60 (colored)

Reduce "vmd -v" spam a bit by not printing useless exit information. These
were being printed because vmm(4) was in the middle of processing an exit
that vmd(8) didn't care about, but still exited to vmd(8) because of
a pending interrupt.

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

Allow a guest to reboot by reinitializing its state and booting again.
This is technically a reset since memory is cleared and the dmesg
buffer is lost.

Patch from Jon Bernard (jbernard at jbernard.io) - Thanks

OK reyk@ mlarkin@

Revision 1.59 / (download) - annotate - [select for diffs], Wed Nov 30 19:27:21 2016 UTC (7 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.58: +8 -9 lines
Diff to previous 1.58 (colored)

Always remove the local vm after calling terminate_vm().

Revision 1.58 / (download) - annotate - [select for diffs], Sat Nov 26 20:03:42 2016 UTC (7 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.57: +6 -5 lines
Diff to previous 1.57 (colored)

Implement basic support for boot.conf(8) on the disk image.

Like the real boot loader, load and parse hd0a:/etc/boot.conf from the
first disk and fall back to /bsd.  Not all boot loader options are
supported, but it at least does set device, set image, and boot -acds
(eg. for booting single-user).

For example, it can now boot install60.fs that includes a boot.conf
with "set image /6.0/amd64/bsd.rd":
	vmctl start install -c -d install60.fs -d OpenBSD.img

This pseudo-bootloader is only needed without BIOS and could
potentially be replaced in the future.

OK mlarkin@

Revision 1.57 / (download) - annotate - [select for diffs], Sat Nov 26 15:29:33 2016 UTC (7 years, 6 months ago) by martijn
Branch: MAIN
Changes since 1.56: +2 -35 lines
Diff to previous 1.56 (colored)

Remove start_client_vmd.
It was nothing more than a wrapper around fork(2).

OK edd@ and mlarkin@

Revision 1.56 / (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.55: +14 -4 lines
Diff to previous 1.55 (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.55 / (download) - annotate - [select for diffs], Tue Nov 22 22:51:45 2016 UTC (7 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.54: +7 -6 lines
Diff to previous 1.54 (colored)

Don't attempt to call vm_remove() with a NULL vm: some functions like
config_getvm() already removed the vm on failure!

Found by mlarkin@

Revision 1.54 / (download) - annotate - [select for diffs], Fri Nov 4 15:07:26 2016 UTC (7 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.53: +3 -13 lines
Diff to previous 1.53 (colored)

Update the config/register/get VM methods to match the config_set/get
style that is used in other places.  Also keep the vmid from the parent.

OK edd@

Revision 1.53 / (download) - annotate - [select for diffs], Sat Oct 29 14:56:05 2016 UTC (7 years, 7 months ago) by edd
Branch: MAIN
Changes since 1.52: +14 -7 lines
Diff to previous 1.52 (colored)

Separate parsing vms and switches from starting them in vmd(8).

Brings us one step closer to having disabled by default vms is vm.conf(5),
which can be started with vmctl(8).

Input, testing and OK reyk@. Thanks.

Revision 1.52 / (download) - annotate - [select for diffs], Wed Oct 26 05:26:36 2016 UTC (7 years, 7 months ago) by mlarkin
Branch: MAIN
Changes since 1.51: +7 -1 lines
Diff to previous 1.51 (colored)


vmd(8)/vmctl(8) for i386. Some ugliness in #ifdef __i386__ areas will be
fixed in tree, but the changes required were pretty minimal.

Note that i386 hosts are still presently limited to running i386 guests.

ok deraadt, stefan, jca

Revision 1.51 / (download) - annotate - [select for diffs], Wed Oct 12 19:10:03 2016 UTC (7 years, 7 months ago) by reyk
Branch: MAIN
Changes since 1.50: +13 -2 lines
Diff to previous 1.50 (colored)

Fix functionality and semantics of vmctl load/reload/reset.

OK rzalamena@

Revision 1.50 / (download) - annotate - [select for diffs], Wed Oct 12 06:56:54 2016 UTC (7 years, 7 months ago) by mlarkin
Branch: MAIN
Changes since 1.49: +3 -4 lines
Diff to previous 1.49 (colored)


Allow 4 vio(4) interfaces in each VM. Also fix a bad interrupt assignment that
caused IRQ9 to be shared between the second disk device and the vio(4)s,
which caused poor network performance.

ok reyk, stefan

Revision 1.49 / (download) - annotate - [select for diffs], Thu Oct 6 20:41:28 2016 UTC (7 years, 7 months ago) by reyk
Branch: MAIN
Changes since 1.48: +3 -8 lines
Diff to previous 1.48 (colored)

Enable pledge(2) in vmm and the VM processes: This way the VMs and
their monitor run in a very restricted environment.  VMs only pledge
"stdio vmm" which allows them to do most basic functions and a subset
of vmm ioctls (the other part of vmm ioctls are only permitted in the
parent).

This requires the previous change in the vmm kernel part.

OK mlarkin@

Revision 1.48 / (download) - annotate - [select for diffs], Thu Oct 6 18:48:41 2016 UTC (7 years, 7 months ago) by reyk
Branch: MAIN
Changes since 1.47: +20 -1 lines
Diff to previous 1.47 (colored)

Terminate VMs on shutdown of vmd instead of leaving them running as
undead VM processes.

OK mlarkin@

Revision 1.47 / (download) - annotate - [select for diffs], Wed Oct 5 17:30:13 2016 UTC (7 years, 7 months ago) by reyk
Branch: MAIN
Changes since 1.46: +13 -9 lines
Diff to previous 1.46 (colored)

Add support for enhanced networking configuration and virtual switches.
See vm.conf(5) for more details.

OK mlarkin@

Revision 1.46 / (download) - annotate - [select for diffs], Tue Oct 4 17:17:30 2016 UTC (7 years, 7 months ago) by reyk
Branch: MAIN
Changes since 1.45: +12 -4 lines
Diff to previous 1.45 (colored)

Add a new "priv" process that is responsible for ioctls and restricted
operations that aren't allowed under pledge.  This is a companion to
the "vmd" process that runs as root but with pledge.

With the "priv" process, each new tap(4) interface now gets a
description to indicate the vm, eg. "vm1-if0-myvm".  For network
configuration will be done by vmd/priv later.

OK mlarkin@

Revision 1.45 / (download) - annotate - [select for diffs], Thu Sep 29 22:42:04 2016 UTC (7 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.44: +3 -3 lines
Diff to previous 1.44 (colored)

Implement fork+exec for vmd, using the same framework from httpd etc.

No objections from mlarkin@ sunil@

Revision 1.44 / (download) - annotate - [select for diffs], Sat Sep 3 11:38:08 2016 UTC (7 years, 8 months ago) by mlarkin
Branch: MAIN
Changes since 1.43: +5 -3 lines
Diff to previous 1.43 (colored)


As vmm(4) can now exit to vmd at any time to process pending interrupts,
don't kill the VM if we are presented with an exit type that is not
something we directly need to handle. Instead, simply re-enter the guest,
possibly injecting an interrupt along the way. Still exit the process
if presented with a triple fault, until we implement reboot support.

ok stefan@

Revision 1.43 / (download) - annotate - [select for diffs], Fri Sep 2 17:10:08 2016 UTC (7 years, 9 months ago) by stefan
Branch: MAIN
Changes since 1.42: +2 -7 lines
Diff to previous 1.42 (colored)

Process incoming com data asynchronously to running VCPU

This registers a handler with libevent that is triggered on incoming
data on the com port.

ok mlarkin@

Revision 1.42 / (download) - annotate - [select for diffs], Fri Sep 2 16:23:40 2016 UTC (7 years, 9 months ago) by stefan
Branch: MAIN
Changes since 1.41: +150 -29 lines
Diff to previous 1.41 (colored)

Move event handling to separate thread

That allows the main thread to handle the termination
of a VM on reboot/shutdown or normal exit. The way it works
is that VCPUs that terminate for some reason communicate this
to a main thread that takes care of shutdown.

ok mlarkin@

Revision 1.41 / (download) - annotate - [select for diffs], Thu Sep 1 17:09:33 2016 UTC (7 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.40: +36 -13 lines
Diff to previous 1.40 (colored)


fix a merge collision, and add some retval checking on various pthread_*
functions

Revision 1.40 / (download) - annotate - [select for diffs], Thu Sep 1 16:40:06 2016 UTC (7 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.39: +14 -14 lines
Diff to previous 1.39 (colored)


change some log_warn to log_warnx and convert some integer literals to
enumerand values

Revision 1.39 / (download) - annotate - [select for diffs], Thu Sep 1 16:04:47 2016 UTC (7 years, 9 months ago) by stefan
Branch: MAIN
Changes since 1.38: +29 -29 lines
Diff to previous 1.38 (colored)

Make vcpu_reset_regs use new writeregs code

Makes reset code a little simpler. ok mlarkin@

Revision 1.38 / (download) - annotate - [select for diffs], Thu Sep 1 14:48:09 2016 UTC (7 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.37: +166 -564 lines
Diff to previous 1.37 (colored)


Add a set of emulated legacy devices (PIT, PIC, RTC)

discussed with stefan and deraadt

Revision 1.37 / (download) - annotate - [select for diffs], Wed Aug 31 06:55:39 2016 UTC (7 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.36: +19 -13 lines
Diff to previous 1.36 (colored)


Style, and clarify some out of date comments

Revision 1.36 / (download) - annotate - [select for diffs], Wed Aug 17 05:07:13 2016 UTC (7 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.35: +2 -3 lines
Diff to previous 1.35 (colored)

small bits of header cleanup; ok mlarkin

Revision 1.35 / (download) - annotate - [select for diffs], Mon Aug 1 16:32:10 2016 UTC (7 years, 10 months ago) by stefan
Branch: MAIN
Changes since 1.34: +2 -2 lines
Diff to previous 1.34 (colored)

Do not pass VM name directly to setproctitle format string.

Use a secure idiom instead.
ok mlarkin@

Revision 1.34 / (download) - annotate - [select for diffs], Fri Jul 29 16:36:51 2016 UTC (7 years, 10 months ago) by stefan
Branch: MAIN
Changes since 1.33: +63 -9 lines
Diff to previous 1.33 (colored)

Allow starting a VM again after it was terminated

If a VM exits, terminate it and remove it from the list of
available VMs. That allows a VM with name `foo' to be restarted
after it has exited.

This changes structures shared between vmd and vmctl. You need to
rebuild vmctl also.

ok mlarkin@

Revision 1.33 / (download) - annotate - [select for diffs], Tue Jul 19 09:52:34 2016 UTC (7 years, 10 months ago) by natano
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.32: +3 -3 lines
Diff to previous 1.32 (colored)

Replace malloc() + memset() with calloc().
ok mlarkin

Revision 1.32 / (download) - annotate - [select for diffs], Sat Jul 9 09:06:22 2016 UTC (7 years, 10 months ago) by stefan
Branch: MAIN
Changes since 1.31: +23 -1 lines
Diff to previous 1.31 (colored)

Prepare vionet to be handled asynchronously to the VCPU thread

This splits the handling of received data into a separate function
that can later be called in parallel to the VCPU thread instead of
handling received packets on VCPU exits only.

It also makes virtq accesses in the rx path safe to run in parallel
to the VCPU thread: the last index into the 'avail' ring the driver
has notified to the host is kept track of. It also makes sure that
the host only writes back to the 'avail' ring instead of modifying
the whole receive virtq.

While there, describe what virtio_vq_info and virtio_io_cfg are used
for, as suggested by mlarkin@

ok mlarkin@

Revision 1.31 / (download) - annotate - [select for diffs], Fri Jul 8 06:35:12 2016 UTC (7 years, 10 months ago) by mlarkin
Branch: MAIN
Changes since 1.30: +3 -3 lines
Diff to previous 1.30 (colored)


Return 0 on read from PIT control port. Intel explicitly says this is not
supported, and it looks like other emulators/hypervisors do a variety of
different things here. Most return 0, but at least one might return random
garbage. Returning 0 seems safest here, but leave a warning in place for
the logs in case a guest VM does this.

Revision 1.30 / (download) - annotate - [select for diffs], Thu Jul 7 00:58:31 2016 UTC (7 years, 10 months ago) by mlarkin
Branch: MAIN
Changes since 1.29: +26 -6 lines
Diff to previous 1.29 (colored)


sanity check vm create and run args earlier

Revision 1.29 / (download) - annotate - [select for diffs], Wed Jul 6 07:09:15 2016 UTC (7 years, 10 months ago) by mlarkin
Branch: MAIN
Changes since 1.28: +4 -3 lines
Diff to previous 1.28 (colored)


clarify a comment about memory regions

Revision 1.28 / (download) - annotate - [select for diffs], Fri Jun 10 16:33:15 2016 UTC (7 years, 11 months ago) by stefan
Branch: MAIN
Changes since 1.27: +118 -58 lines
Diff to previous 1.27 (colored)

Access guest memory with normal loads and stores in vmd(8)

read_mem() and write_mem() in vmd(8) now use memcpy() instead of the
vm_readpage() and vm_writepage() ioctls to read/write guest memory.

ok mlarkin@

Revision 1.27 / (download) - annotate - [select for diffs], Tue Jun 7 16:19:06 2016 UTC (7 years, 11 months ago) by stefan
Branch: MAIN
Changes since 1.26: +63 -6 lines
Diff to previous 1.26 (colored)

Allocate RAM for guest VM in vmd(8) and pass it to vmm(4)

vmm(4) then maps the pages allocated by the vmd(8) user process into the
address space of the guest. This gives vmm(4) and vmd(8) a shared view of
the guest RAM. This will allow us to have faster guest<->host data
exchange by ordinary memory loads/stores later, as well as remove the
vm_readpage and vm_writepage ioctls next.

ok mlarkin@

Revision 1.26 / (download) - annotate - [select for diffs], Thu Apr 7 05:51:26 2016 UTC (8 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.25: +1 -11 lines
Diff to previous 1.25 (colored)

Remove headers associated with code that's been moved to other .c files

ok mlarkin@

Revision 1.25 / (download) - annotate - [select for diffs], Tue Apr 5 09:33:05 2016 UTC (8 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.24: +6 -3 lines
Diff to previous 1.24 (colored)


Support processors without unrestricted guest capability.

ok stefan

Revision 1.24 / (download) - annotate - [select for diffs], Mon Apr 4 17:13:54 2016 UTC (8 years, 1 month ago) by stefan
Branch: MAIN
Changes since 1.23: +3 -25 lines
Diff to previous 1.23 (colored)

Directly use physical addresses from ELF header for kernel loading.

This allows us to remove the 'do_mask' parameters in read_mem and
write_mem as well as the address mask operaton itself.

ok mlarkin@

Revision 1.23 / (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.22: +80 -17 lines
Diff to previous 1.22 (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.22 / (download) - annotate - [select for diffs], Sun Mar 13 02:37:29 2016 UTC (8 years, 2 months ago) by mlarkin
Branch: MAIN
Changes since 1.21: +9 -17 lines
Diff to previous 1.21 (colored)


Rework an erroneous warning message about 16 bit i8253 PIT counter I/O.
The unimplemented mode is MSB/LSB (8 bit), not 16 bit mode.

Revision 1.21 / (download) - annotate - [select for diffs], Tue Feb 16 19:00:16 2016 UTC (8 years, 3 months ago) by stefan
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.20: +3 -1 lines
Diff to previous 1.20 (colored)

Pass down the initial value of CR0 down to the RESETCPU ioctl() as well.
This gives us the opportunity later to start VCPUs in real-mode, etc.
(for those CPUs that support unrestricted guest).

You need to build an updated kernel for this first, the ioctl interface
has changed.

ok mlarkin@, deraadt@

Revision 1.20 / (download) - annotate - [select for diffs], Sat Jan 16 08:55:40 2016 UTC (8 years, 4 months ago) by stefan
Branch: MAIN
Changes since 1.19: +57 -23 lines
Diff to previous 1.19 (colored)

vmd(8) sometimes attempts page-crossing data copies between the host
and guest. The readpage/writepage ioctls of vmm(4) do not support this
and they return EINVAL on such attempts since recently.

Avoid page-crossing guest memory accesses by changing read_page() and
write_page() into read_mem() and write_mem() that can copy arbitrary
lengths of data between host<->guest without page-crossing accesses.

This also allows us to remove page-wise copy-loops in a few places.

ok mlarkin@

Revision 1.19 / (download) - annotate - [select for diffs], Wed Jan 13 12:55:18 2016 UTC (8 years, 4 months ago) by reyk
Branch: MAIN
Changes since 1.18: +4 -5 lines
Diff to previous 1.18 (colored)

Update the comment that is decribing terminate_vm()'s arguments,
sort the description of arguments for init_emulated_hw().

Pointed out my mlarkin

Revision 1.18 / (download) - annotate - [select for diffs], Fri Jan 8 11:28:05 2016 UTC (8 years, 4 months ago) by reyk
Branch: MAIN
Changes since 1.17: +16 -3 lines
Diff to previous 1.17 (colored)

Keep the pledge of the vmm and vm processes disabled for now as long
as there is some more expected progress in the kernel interface.  It
can be tested, and should work, with the previous kernel commit of the
"vmm" pledge, but is not called.

Revision 1.17 / (download) - annotate - [select for diffs], Fri Jan 8 08:12:21 2016 UTC (8 years, 4 months ago) by stefan
Branch: MAIN
Changes since 1.16: +2 -2 lines
Diff to previous 1.16 (colored)

Must set MAX_PORTS to 65536, since we assign to
ioports_map[VMM_PCI_IO_BAR_END (= 65535)]. Fixes an off-by-one.

ok mlarkin@, reyk@

Revision 1.16 / (download) - annotate - [select for diffs], Mon Jan 4 07:27:24 2016 UTC (8 years, 4 months ago) by mlarkin
Branch: MAIN
Changes since 1.15: +60 -40 lines
Diff to previous 1.15 (colored)


Use an bitmap of handler function pointers to track I/O device to handler
function mappings. First step in reworking device support in vmd to better
handle interrupts.

Revision 1.15 / (download) - annotate - [select for diffs], Mon Jan 4 02:07:28 2016 UTC (8 years, 4 months ago) by mlarkin
Branch: MAIN
Changes since 1.14: +4 -4 lines
Diff to previous 1.14 (colored)


bzero -> memset for consistency

Revision 1.14 / (download) - annotate - [select for diffs], Thu Dec 17 09:29:28 2015 UTC (8 years, 5 months ago) by mlarkin
Branch: MAIN
Changes since 1.13: +83 -6 lines
Diff to previous 1.13 (colored)


Move vcpu register state init to vmd. Allows vmd bootloader to make the
decision as to how the vcpu should be set up for initial start and
reset. Also removes some hardcoded register constants from vmm(4).

ok jsing@, mpi@

Revision 1.13 / (download) - annotate - [select for diffs], Tue Dec 15 02:18:34 2015 UTC (8 years, 5 months ago) by mlarkin
Branch: MAIN
Changes since 1.12: +9 -1 lines
Diff to previous 1.12 (colored)


if a vcpu run thread in vmd exits unexpectedly, teardown the VM's kernel
components as well.

ok deraadt@

Revision 1.12 / (download) - annotate - [select for diffs], Mon Dec 7 16:02:09 2015 UTC (8 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.11: +5 -1 lines
Diff to previous 1.11 (colored)

Forcibly remove the local vm reference on error.

Revision 1.11 / (download) - annotate - [select for diffs], Mon Dec 7 14:43:24 2015 UTC (8 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.10: +9 -4 lines
Diff to previous 1.10 (colored)

Fix error handling in a few cases: some function return (-1) on error,
while others return (errno) on error.  We probably have to agree on
something.

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

Print the TTY in the vmctl status output.

Revision 1.9 / (download) - annotate - [select for diffs], Sun Dec 6 01:58:21 2015 UTC (8 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.8: +59 -9 lines
Diff to previous 1.8 (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.8 / (download) - annotate - [select for diffs], Sun Dec 6 00:32:57 2015 UTC (8 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.7: +24 -14 lines
Diff to previous 1.7 (colored)

Terminate all running VMs on startup: we're not able to pick up state
of "zombie" VMs yet, they are not useful without the device layer, so
terminate them on vmd startup.

As discussed with mlarkin@

Revision 1.7 / (download) - annotate - [select for diffs], Thu Dec 3 23:32:32 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.6: +4 -1 lines
Diff to previous 1.6 (colored)

Re-add the "load" and "reload" commands to vmctl: Instead of parsing
the configuration in vmctl directly, it now sends a (re)load request
to vmd.  The reload also resets the existing configuration status -
this doesn't do much difference yet but a future change will compare
if a specified VM is already running.  "load" will allow to add
configuration, while "reload" resets the state before loading.

Revision 1.6 / (download) - annotate - [select for diffs], Thu Dec 3 13:27:14 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.5: +7 -4 lines
Diff to previous 1.5 (colored)

prepare config_getvm() for parse.y

Revision 1.5 / (download) - annotate - [select for diffs], Thu Dec 3 08:42:11 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.4: +16 -16 lines
Diff to previous 1.4 (colored)

spacing

Revision 1.4 / (download) - annotate - [select for diffs], Wed Dec 2 22:19:11 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.3: +85 -127 lines
Diff to previous 1.3 (colored)

Split the fully privileged parent into two processes "parent" and
"vmm" with reduced privileges:
- the "parent" opens fds (disks, ifs, etc.) but runs as root but pledged as
  "stdio rpath wpath proc tty sendfd".
- the "vmm" process handles the creation and supervision of vm processes,
  and the primary communication with the vmm(4) subsystem.  It runs as _vmd
  in the chroot but does not use pledge, as the vmm ioctls are not allowed
  by any pledge model yet.
With this change, vmd starts to track the configuration state of VMs
in vmd and will allow other things later (like terminating a vm by
name, moving the configuration parser to vmd, ...).  More incremental
changes will follow.

Revision 1.3 / (download) - annotate - [select for diffs], Wed Dec 2 13:43:36 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.2: +6 -6 lines
Diff to previous 1.2 (colored)

Sync with relayd, fix previous use of proc_compose*_imsg()

Revision 1.2 / (download) - annotate - [select for diffs], Wed Dec 2 09:39:41 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.1: +4 -4 lines
Diff to previous 1.1 (colored)

Add back the "peerid" to the proc_compose*() functions: in relayd, I
initially left it out because I didn't have a need for it.  But it is
actually quite useful to carry a reference to the imsg data context
across processes.

Revision 1.1 / (download) - annotate - [select for diffs], Wed Dec 2 09:14:25 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN

Start tweaking vmd's privsep and daemon model by splitting the main
process into multiple parts and adopting the "proc.c"-style from other
daemons.  This allows to further reduce the privileges, to give better
pledge(2), and to add some upcoming changes.

"please do" mlarkin@, 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.