Skip to content

v4.0.0

Latest

Choose a tag to compare

@Code-Hex Code-Hex released this 06 Dec 05:19
243fa5d

vz v4 lets Go applications change devices on a running VM, embed a guest display in their own window, and build custom Virtio devices. It also adds packages for virtual networking and layered disk images. The main source changes for applications upgrading from v3 are the module path and the event notification APIs.

Upgrading from v3.8.0

  • Update your imports from github.com/Code-Hex/vz/v3 to github.com/Code-Hex/vz/v4. The minimum Go version is now 1.26.0. Go 1.26.x supports macOS 12 Monterey and later. Go 1.27.x requires macOS 13 Ventura or later. Individual framework APIs may require a newer macOS release.
  • Pass a channel when subscribing to events. For example, vm.StateChangedNotify() becomes stop, err := vm.StateChangedNotify(ch). Handle the error and call stop() when done. Delivery is nonblocking, so a full channel can drop a notification. When waiting for a particular VM state, check vm.State() before each wait. The network disconnect method is now NetworkDeviceAttachmentWasDisconnectedNotify. The NBD methods Connected and DidEncounterError are now WasConnectedNotify and DidEncounterErrorNotify. Migration examples · Notification API changes
  • Build with cgo enabled. v4 uses generated purego bindings for most framework calls. A normal go build compiles the remaining Objective-C helpers from source using Xcode or Command Line Tools. Vendored builds use the same sources. Native bridge changes

Highlights

  • Reconfigure a running VM. Change directory shares, switch network or console attachments, and resize or reconfigure guest displays. Each VM now has its own dispatch queue. Applications can also observe guest shutdown and retrieve the error behind an abnormal stop. Directory sharing · Networking · Console ports · Displays
  • Embed the guest display in your application. VirtualMachineView lets the host application own the window, layout, and event loop while forwarding keyboard and mouse input to the guest. The built-in graphics API also supports multiple VM windows in one process. Examples cover MyGo, Fyne, Wails v3, and Gio. Embeddable views and examples · Multiple VM windows
  • Use the macOS 27 virtualization APIs. Configure EFI Secure Boot and signature databases, provision a restored macOS guest on first boot, attach USB passthrough devices, and implement custom Virtio devices in Go with access to device queues and guest memory. macOS 27 API additions
  • Build virtual networks on macOS 26 and later. The new vmnet package supports bridged interfaces, port forwarding, batched packet I/O, and sharing a network between processes over XPC. VMNetNetworkDeviceAttachment connects a guest to one of these networks. The vmnetsock package connects packet interfaces to socket peers and handles Virtio network offloads. vmnet · vmnetsock
  • Serve layered disk images to a guest. The new diskimagekit package opens RAW and ASIF images and works with image stacks. DiskImageServer exports an image or stack over a local Unix socket for use with NetworkBlockDeviceStorageDeviceAttachment. Disk image stacks · DiskImageServer
  • Control socket and serial lifetimes explicitly. VirtioSocketDevice.ConnectContext supports cancellation. VirtioSocketConnection.CloseWrite lets a host signal EOF and still read the guest’s reply. Both CloseWrite and CloseRead report unsupported operations through errors.Is(err, errors.ErrUnsupported). File-handle serial attachments now support one-way I/O and explicit cleanup after VM shutdown. Context-aware connections · Socket half-close · Serial attachment cleanup

Virtual networking on macOS 26 and later

The new vmnet package lets applications create host-only and shared networks, reserve guest IP addresses with DHCP, configure port forwarding, and share networks between processes over XPC. Attach a Virtualization.framework guest with vz.NewVMNetNetworkDeviceAttachment. For QEMU and krunkit, vmnetsock exposes a packet interface as a Unix socket the VM process can inherit. It also supports bridging to a physical interface. Network configuration · Socket adapter examples

Packet batching brought median host-to-guest TCP throughput from 0.68 to 7.88 Gbit/s compared with the single-packet implementation tested during v4 development. Host CPU time per GiB transferred fell from 32.81 to 1.83 seconds, including the adapter and benchmark server. Both versions used the same single-vCPU QEMU/Linux guest on a shared network with MTU 1500, with three two-second transfers per version. Batched packet I/O

In a separate three-run QEMU/Linux comparison on macOS 27, batching packets received from the stream socket raised median guest-to-host TCP throughput from 2.83 to 6.53 Gbit/s. Host-to-guest throughput held steady at 7.87–7.88 Gbit/s. Stream forwarding benchmark

Full changelog since v3.8.0

What's Changed

  • Use generated purego bindings for the native bridge by @Code-Hex in #241
  • feat(network): add vmnet network attachments for macOS 26 by @Code-Hex in #242
  • refactor(vz): call objcutil functions directly by @Code-Hex in #244
  • feat(vmnet): add packet interfaces and file adapters by @Code-Hex in #245
  • feat(vmnet): support bridged interfaces by @Code-Hex in #246
  • docs(vmnet): clarify sandbox entitlement requirements by @Code-Hex in #247
  • feat(vmnet): add network serialization and restoration by @Code-Hex in #248
  • feat(vmnet): share networks between processes over XPC by @Code-Hex in #249
  • vmnet: add MTU configuration with bounds validation by @Code-Hex in #250
  • refactor(vmnet): configure networks with functional options by @Code-Hex in #251
  • feat(vmnet): add options to disable network services by @Code-Hex in #252
  • feat(vmnet): configure initial port forwarding rules by @Code-Hex in #253
  • docs(fileadapter): link to existing network capabilities by @Code-Hex in #254
  • refactor(vmnetsock): rename and move the socket adapter package by @Code-Hex in #255
  • feat(virtualization): give each VM its own dispatch queue by @Code-Hex in #256
  • fix(vz): guard save and restore validation on older macOS by @Code-Hex in #272
  • fix(vz): reject uninitialized shared directories by @Code-Hex in #273
  • feat(vz): support USB device configuration UUIDs by @Code-Hex in #274
  • feat(vz): support one-way serial attachments by @Code-Hex in #275
  • feat(diskimagekit): add RAW and ASIF image stacks by @Code-Hex in #277
  • feat(nbd): add an internal server for disk image stacks by @Code-Hex in #278
  • feat(vz): add DiskImageServer for NBD exports by @Code-Hex in #279
  • feat(vz): add silent audio input streams by @Code-Hex in #282
  • feat(vz): configure maximum console port count by @Code-Hex in #283
  • feat(vz): add storage overwrite options by @Code-Hex in #281
  • fix(vz): return SPICE attachments from console ports by @Code-Hex in #280
  • fix(vz): reject invalid MAC addresses by @Code-Hex in #284
  • feat(vz): expose macOS restore image metadata by @Code-Hex in #286
  • fix(vz): read MTU from the network attachment by @Code-Hex in #287
  • feat(vz): canonicalize directory share names in Go by @Code-Hex in #285
  • fix(vz): preserve the full CPU count in VM configurations by @Code-Hex in #288
  • feat(vmnet): add batched packet I/O by @Code-Hex in #289
  • feat(vmnet): support Virtio packet headers by @Code-Hex in #290
  • perf(vmnetsock): batch stream input and join shutdown by @Code-Hex in #291
  • perf(vmnetsock): batch datagram forwarding by @Code-Hex in #292
  • feat(vmnetsock): convert Virtio headers for Ethernet peers by @Code-Hex in #293
  • feat(vmnetsock): segment TCP frames using the peer MSS by @Code-Hex in #294
  • perf(vmnetsock): batch small frames and retry ENOBUFS by @Code-Hex in #295
  • perf(vmnetsock): reduce TCP tracking overhead by @Code-Hex in #296
  • feat(vmnetsock): convert standard Virtio TCP GSO by @Code-Hex in #297
  • feat(vmnetsock): normalize Virtio offloads from socket peers by @Code-Hex in #298
  • fix(graphics): avoid a segfault when closing VM windows by @Code-Hex in #299
  • chore(ci): refresh macOS and Go coverage and lock actions by @Code-Hex in #300
  • build(deps): bump golang.org/x/sys from 0.46.0 to 0.49.0 in /example/linux by @dependabot[bot] in #302
  • build(deps): bump github.com/Songmu/prompter from 0.5.1 to 1.0.0 in /example/gui-linux by @dependabot[bot] in #304
  • build(deps): bump golang.org/x/sys from 0.46.0 to 0.49.0 by @dependabot[bot] in #301
  • build(deps): bump github.com/ebitengine/purego from 0.10.1 to 0.11.2 by @dependabot[bot] in #303
  • build(deps): bump golang.org/x/mod from 0.22.0 to 0.42.0 by @dependabot[bot] in #305
  • build(deps): update x/crypto and stabilize Intel VM integration tests by @dependabot[bot] in #306
  • test: revert fixture changes bundled with the dependency update by @Code-Hex in #308
  • feat(vmnetsock): normalize TCP RSC packets by @Code-Hex in #307
  • feat(vmnetsock): normalize UDP L4 GSO datagrams by @Code-Hex in #309
  • chore(ci): switch Intel jobs to macos-26-intel by @Code-Hex in #310
  • feat(vz): add embeddable virtual machine views by @Code-Hex in #311
  • refactor(go): expand struct literals across multiple lines by @Code-Hex in #312
  • fix(rosetta): reject invalid caching socket strings by @Code-Hex in #315
  • feat(platform): expose nested virtualization enabled state by @Code-Hex in #314
  • feat(socket): add ConnectContext by @Code-Hex in #317
  • feat(examples): add macos provisioning options by @JanGutter in #313
  • build(deps): bump github.com/ebitengine/purego from 0.11.2 to 0.11.3 by @dependabot[bot] in #319
  • feat(serial): add explicit close for file handle attachments by @Code-Hex in #326
  • chore(vz): use the codehex.dev namespace by @Code-Hex in #327
  • build(deps): bump golang.org/x/sys from 0.49.0 to 0.50.0 in /example/linux by @dependabot[bot] in #321
  • build(deps): bump golang.org/x/sys from 0.49.0 to 0.50.0 by @dependabot[bot] in #322
  • build(deps): bump golang.org/x/mod from 0.42.0 to 0.43.0 by @dependabot[bot] in #324
  • build(deps): bump golang.org/x/crypto from 0.58.0 to 0.59.0 by @dependabot[bot] in #325
  • docs(serial): say when a VM has shut down for Close by @fcuny in #328
  • test(serial): gate guest shutdown on Start completion by @Code-Hex in #329
  • socket: add CloseWrite/CloseRead to VirtioSocketConnection by @naikaayush in #331
  • build(deps): bump actions/setup-go from 7.0.0 to 7.1.0 by @dependabot[bot] in #332
  • build(deps): bump jidicula/clang-format-action from 4.18.0 to 4.19.0 by @dependabot[bot] in #333
  • fix(socket): preserve connections on unsupported half-close by @Code-Hex in #334
  • ci: run Intel unit tests on Go 1.27 and allow five minutes per package by @Code-Hex in #335
  • docs: correct v4 build requirements and binding regeneration instructions by @Code-Hex in #336
  • build(deps): update golang.org/x/crypto to v0.60.0 by @Code-Hex in #337
  • build(examples): update native GUI and terminal dependencies by @Code-Hex in #338
  • docs: list v3 among deprecated major versions by @Code-Hex in #339

New Contributors

Full Changelog: v3.8.0...v4.0.0