Up to [local] / src / usr.sbin / vmd
Request diff between arbitrary revisions
Default branch: MAIN
Revision 1.13 / (download) - annotate - [select for diffs], Tue Feb 20 21:40:37 2024 UTC (3 months, 2 weeks ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE,
OPENBSD_7_5,
HEAD
Changes since 1.12: +2 -2 lines
Diff to previous 1.12 (colored)
Utilize separate threads for RX and TX in vmd(8)'s vionet. This commit adds multithreading to allow both virtqueues to be processed in parallel along with additional synchronization primitives to protect device configuration state. Allowing RX and TX to operate independently reduces overall network latency for guests and helps alleviate the TX side dominating cpu time. Tested with help from phessler@, kn@, and mlarkin@. ok mlarkin@.
Revision 1.12 / (download) - annotate - [select for diffs], Mon Feb 5 21:58:09 2024 UTC (4 months ago) by dv
Branch: MAIN
Changes since 1.11: +1 -6 lines
Diff to previous 1.11 (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.11 / (download) - annotate - [select for diffs], Sun Feb 4 14:54:51 2024 UTC (4 months ago) by dv
Branch: MAIN
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)
Initialize result in vioblk notification handler. In the event the driver kicks the vioblk device, but the guest doesn't have any available virtqueue space, vmd will return an uninitialized value. If non-zero, it results in a notification to the driver and effectively a spurious interrupt. Found by smatch, reported by and ok jsg@
Revision 1.10 / (download) - annotate - [select for diffs], Sat Feb 3 00:28:07 2024 UTC (4 months ago) by jsg
Branch: MAIN
Changes since 1.9: +7 -5 lines
Diff to previous 1.9 (colored)
fix vmd vioblk fd closing bounds test found by "buffer overflow 'vioblk->disk_fd' 4 <= 15" smatch error ok dv@
Revision 1.9 / (download) - annotate - [select for diffs], Tue Sep 26 01:53:54 2023 UTC (8 months, 1 week ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE,
OPENBSD_7_4
Changes since 1.8: +11 -5 lines
Diff to previous 1.8 (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.8 / (download) - annotate - [select for diffs], Thu Sep 14 15:25:43 2023 UTC (8 months, 3 weeks ago) by dv
Branch: MAIN
Changes since 1.7: +223 -363 lines
Diff to previous 1.7 (colored)
vmd(8)/vioblk: use zero-copy approach & vectored io. The original version of the virtio block device dynamically allocated buffers to hold intermediate data when reading or writing to the underlying disk fd(s). Since vioblk drivers may chain multiple segments together, this leads to overly complex logic and on read(2)/write(2) call per data segment. Additionally, the virtio block logic in vmd didn't handle segments that weren't block aligned (e.g. 512 bytes). If a guest provided unaligned segments, garbage will be read or written. Since virtio descriptors mimic iovec structures, this changes vmd's device emulation to use that model. (This is how other hypervisors emulate virtio devices.) This allows for zero-copy semantics using iovec's, reducing memcpy and multiple read/write syscalls per io transaction. Testing by phessler@ and mlarkin@. OK mlarkin@.
Revision 1.7 / (download) - annotate - [select for diffs], Wed Sep 6 19:27:54 2023 UTC (9 months ago) by dv
Branch: MAIN
Changes since 1.6: +2 -2 lines
Diff to previous 1.6 (colored)
Correct error message: vionet -> vioblk. No functional change.
Revision 1.6 / (download) - annotate - [select for diffs], Wed Sep 6 19:26:39 2023 UTC (9 months ago) by dv
Branch: MAIN
Changes since 1.5: +7 -12 lines
Diff to previous 1.5 (colored)
vmd(8): clean up struct ioinfo. In prep for fixing some vioblk device issues, simplify the ioinfo struct by dropping members that aren't needed. ok mlarkin@
Revision 1.5 / (download) - annotate - [select for diffs], Fri Sep 1 19:42:26 2023 UTC (9 months, 1 week ago) by dv
Branch: MAIN
Changes since 1.4: +9 -5 lines
Diff to previous 1.4 (colored)
vmd(8): ignore masks on asserts, use synchronous deasserts. The i8259 was considering the state of the mask register when a device requested raising the bit in the interrupt request register. This caused a race condition where if the virtio device asserted the irq while it was masked in the i8259 by the vm, we'd miss the interrupt request. The device and the pic would become out of sync and users reported virtio block device stalls as the vioblk(4) driver would starve, waiting for an interrupt that will never arrive. The mask is now considered only at ack time, when finding possible interrupts to inject. This bug was never a problem previously as virtio devices were emulated synchronously. Deasserts related to the vcpu reading the virtio isr register are also made now in response to the read request instead of issued asynchronously. This removes a subsequent race condition. Testing from mbuhl@, stsp@, and Florian Riehm. ok mlarkin@
Revision 1.4 / (download) - annotate - [select for diffs], Sun May 28 05:28:50 2023 UTC (12 months, 1 week ago) by asou
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)
Used number of bytes instead of number of 512 byte sectors. ok dv@
Revision 1.3 / (download) - annotate - [select for diffs], Sat May 13 23:15:28 2023 UTC (12 months, 3 weeks ago) by dv
Branch: MAIN
Changes since 1.2: +18 -7 lines
Diff to previous 1.2 (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.2 / (download) - annotate - [select for diffs], Fri Apr 28 18:52:22 2023 UTC (13 months, 1 week ago) by dv
Branch: MAIN
Changes since 1.1: +1 -3 lines
Diff to previous 1.1 (colored)
Remove unneeded header includes in vmd. No functional change. virtio block/networking emulation do not need to know about vmm or any kernel types.
Revision 1.1 / (download) - annotate - [select for diffs], Thu Apr 27 22:47:27 2023 UTC (13 months, 1 week ago) by dv
Branch: MAIN
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@