Repository navigation
Conversation
li041
reviewed
Nov 26, 2026
agicy
force-pushed
the
luanlai/virtio-resource-shutdown-release
branch
from
November 26, 2026 13:38
54f9714 to
3eaea9e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix per-zone virtio and SCMI resource cleanup on administrator-initiated zone shutdown in
hvisor-tool:abd79ec4): look up events byfdunderevent_lock, track active handlers soremove_event()waits before device teardown frees memory, reuse freed event slots, and unregister console/net events before closing their file descriptors.virtio-blkimage on close (c4517e10): callfdatasyncviablk_do_flush()after joining the block worker thread and before closingimg_fd.zone shutdownthrough the virtio daemon (8591ada4): add ashutdown-zonecontrol-socket operation (preserving the existing request/response wire layout and restricting/run/hvisor-virtio.sockto0600), detach the target zone'sVirtIODevices, wait for in-flight MMIO references to drain (5 s deadline with rollback on-EBUSY), close per-zone devices, and unmap the zone's guest memory afterHVISOR_ZONE_SHUTDOWNsucceeds. Fall back to the directHVISOR_ZONE_SHUTDOWNioctl when no daemon is running or when talking to an older daemon.54f9714d): align with syswonder/hvisor-tool#122 by stampingzone_idon SCMI clock/power ioctls and tracking per-zone positive enable/power-on counts inhvisor.ko. Release a zone's clocks first and power domains second uponHVISOR_ZONE_SHUTDOWN, beforeHVISOR_ZONE_STARTwhen no live instance of thatzone_idexists, and on module unload, serialized underscmi_lifecycle_lock.Motivation
Previously,
hvisor zone shutdown -id <N>invokedHVISOR_ZONE_SHUTDOWNdirectly without notifying the long-lived virtio daemon (hvisor virtio start), andhvisor.konever undid SCMI clock or power-domain operations performed on behalf of a zone:VirtIODeviceentries, block image fds, PTY/TAP fds, worker threads, epoll registrations, andzone_memmmaps remained open in the daemon. Re-provisioning the zone viahvisor virtio addfailed MMIO overlap validation, and closingvirtio-blkwithoutfdatasyncrisked losing buffered writes.event_monitorthread was running could dereference a freedepoll_event.data.ptrorEPOLL_CTL_DELa recycled fd, and event slots were never reclaimed.clk_prepare_enable) and power domains resumed (pm_runtime_resume_and_get) by a guest stayed active in the host kernel across zone shutdowns and restarts.Verification
make -C hvisor-tool/tools -B ARCH=arm64 VIRTIO_SCMI=n CROSS_COMPILE=aarch64-linux-gnu- LOG=LOG_INFO(andVIRTIO_SCMI=y, verified across each individual commit andHEAD)make elf BID=aarch64/qemu-gicv3 MODE=releasemake -C hvisor-tool/driver ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- KDIR=/lib/modules/6.8.0-117-generic/build VIRTIO_SCMI=yaarch64/qemu-gicv3end-to-end admin shutdown test (passed):virtio-blkandvirtio-consoleserved by the virtio daemon./proc/<daemon_pid>/fdheld zone1's disk image fd and PTY master/slave fds beforehvisor zone shutdown -id 1.hvisor zone shutdown -id 1: confirmed hvisor loggedzone 1 has been shutdown, zone1's disk image and PTY fds were closed, the control socket and daemon PID remained alive, and zone0 continued running normally.git ls-files -z -- '*.c' '*.h' | xargs -0 clang-format --dry-run --Werror(clang-format 23.1.5)cargo fmt --all -- --check& non-srcrustfmt --check --edition 2021ruff format --check .(ruff 0.17.6)typos --config _typos.toml&./tools/license_checker.shqemu-gicv3has no SCMI DT clocks/power-domains, so the SCMI accounting path in this branch is compile-verified only; companion design verified on RK3588 in syswonder/hvisor-tool#122).Risks and Limitations
hvisor+hvisor.ko):struct hvisor_scmi_clock_argsandstruct hvisor_scmi_power_argsaddzone_id, changing_IOWR-encoded ioctl command numbers.hvisoruserspace andhvisor.komust be built and deployed from the same revision (mismatched binaries fail SCMI ioctls cleanly with-EINVAL).PSCI_SYSTEM_OFF) still lacks a hypervisor-to-userspace zone-death notification, so daemon-sideVirtIODevicecleanup only runs on explicithvisor zone shutdown(whereas kernel-owned SCMI state is also cleaned up before the nextHVISOR_ZONE_STARTof thatzone_id).hvisor zone shutdownnow removes the zone's virtio devices from the daemon, restarting that zone under a persistent daemon requires re-adding its devices viahvisor virtio addbeforehvisor zone start.SCMI_MAX_ZONES = 16, matching hvisor'sMAX_ZONE_NUM); clock rates and reset domains are not restored.