Skip to content

Conversation

@elibosley
Copy link
Member

@elibosley elibosley commented Jan 4, 2026

Motivation

  • Address the issue where domains in the PMSUSPENDED state cannot be resumed via the normal resume path.
  • Ensure guests suspended by guest power management are woken using the libvirt PM API before attempting a normal resume.
  • Provide a transparent fallback so existing resume behavior is unchanged for other states.

Description

  • Add a native DomainPMWakeup binding and worker that calls virDomainPMWakeup and expose it from src/hypervisor-domain.cc, src/hypervisor.cc, and src/hypervisor.h.
  • Add domainPMWakeup wrapper to lib/hypervisor.ts that calls the native binding via wrapMethod.
  • Update Domain.resume() in lib/domain.ts to call getInfo() and invoke domainPMWakeup when info.state === DomainState.PMSUSPENDED, otherwise call the existing domainResume.
  • Extend unit tests in lib/domain.spec.ts to mock domainGetInfo and domainPMWakeup and verify both the normal resume path and the PMSUSPENDED wakeup path.

Testing

  • Updated unit tests in lib/domain.spec.ts to cover the PMSUSPENDED wakeup behavior and the normal resume path.
  • No automated test suite was executed as part of this change (tests were modified but not run).
  • Manual build and compilation were not reported in this rollout.

Codex Task

Summary by CodeRabbit

  • New Features

    • Added domain power‑management: Domain.pmSuspend(target), hypervisor suspend/wake operations, and a NodeSuspendTarget enum to choose suspend target.
  • Bug Fixes

    • Resume now detects PMSUSPENDED domains and triggers wake‑up instead of performing a normal resume.
  • Tests

    • Added tests for resume/wake flows, suspend behavior, target override handling, and hypervisor suspend/wake calls.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 4, 2026

📝 Walkthrough

Walkthrough

Domain.resume now checks runtime state and, if PMSUSPENDED, calls domainPMWakeup instead of domainResume; a new Domain.pmSuspend(target) API was added. TypeScript wrappers, unit tests, and native N-API workers/bindings for domainPMWakeup and domainPMSuspend were introduced.

Changes

Cohort / File(s) Summary
Domain logic & tests
lib/domain.ts, lib/domain.spec.ts
Domain.resume() queries domainGetInfo() and, if state === PMSUSPENDED, calls domainPMWakeup() instead of domainResume(); new pmSuspend(target: NodeSuspendTarget = NodeSuspendTarget.MEM): Promise<void> added; tests updated/added to mock/assert domainGetInfo, domainPMWakeup, domainResume, and domainPMSuspend.
Hypervisor TS wrapper & tests
lib/hypervisor.ts, lib/hypervisor.spec.ts
Added domainPMWakeup(domain: Domain) and domainPMSuspend(domain: Domain, target?: NodeSuspendTarget) which forward to native via wrapMethod; tests verify native method calls and correct suspend-target forwarding.
Types
lib/types.ts, lib/types.spec.ts
Added exported enum NodeSuspendTarget { MEM = 0, DISK = 1, HYBRID = 2 }; minor LibvirtError message formatting test added.
Native implementation (C++)
src/hypervisor-domain.cc, src/hypervisor.cc
Added DomainPMWakeupWorker and DomainPMSuspendWorker performing virDomainPMWakeup and virDomainPMSuspendForDuration (default MEM); added N-API wrappers Hypervisor::DomainPMWakeup and Hypervisor::DomainPMSuspend; exported instance methods bound in Hypervisor::Init.
Native headers / declarations
src/hypervisor.h, src/domain.h
Added forward/friend declarations for the two new worker classes and declarations for DomainPMWakeup and DomainPMSuspend.
Misc / tests / tooling
package.json, ...
New unit tests added; minor formatting/trailing-newline adjustments; no manifest functional changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant DomainTS as Domain (TS)
  participant HyperTS as Hypervisor (TS)
  participant Native as Hypervisor (N-API)
  participant Libvirt as libvirt

  Note over DomainTS,HyperTS: Domain.resume() checks runtime state
  DomainTS->>HyperTS: domainGetInfo(domain)
  HyperTS-->>DomainTS: { state: PMSUSPENDED }
  alt state == PMSUSPENDED
    DomainTS->>HyperTS: domainPMWakeup(domain)
    HyperTS->>Native: DomainPMWakeup(domainObject)
    activate Native
    Native->>Libvirt: virDomainPMWakeup(domainPtr)
    Libvirt-->>Native: result
    deactivate Native
    Native-->>HyperTS: Promise settles
    HyperTS-->>DomainTS: Promise settles
  else other state
    DomainTS->>HyperTS: domainResume(domain)
    HyperTS->>Native: DomainResume(domainObject)
    activate Native
    Native->>Libvirt: virDomainResume(domainPtr)
    Libvirt-->>Native: result
    deactivate Native
    Native-->>HyperTS: Promise settles
    HyperTS-->>DomainTS: Promise settles
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nudged a sleeping VM with a tiny twitch,
C++ workers queued while TypeScript flipped the switch,
MEM or DISK — the targets pick the night,
Promises hop awake and blink at morning light,
A rabbit applauds this suspend-and-wake glitch.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main feature: enabling resume of PMSUSPENDED domains via PM wakeup, which is the core objective of this PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/fix-resume-functionality-for-pmsuspended-vm

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a152ea and df79743.

📒 Files selected for processing (1)
  • lib/types.spec.ts
🧰 Additional context used
🧬 Code graph analysis (1)
lib/types.spec.ts (1)
lib/types.ts (1)
  • LibvirtError (141-169)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Docker Integration Tests (amd64)
🔇 Additional comments (1)
lib/types.spec.ts (1)

11-14: LGTM!

The test correctly covers the edge case where str1 is undefined, complementing the existing test that provides an explicit string value. The assertion aligns with the implementation's use of the nullish coalescing operator (str1 ?? 'undefined').


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/domain.ts (1)

64-68: Logic correctly handles PMSUSPENDED state.

The implementation properly checks the domain state and dispatches to domainPMWakeup for PMSUSPENDED domains while preserving existing behavior for other states. This aligns with the PR objective.

Optional consideration: The getInfo() call adds one extra round-trip to the hypervisor for every resume operation, even when the domain is not in PMSUSPENDED state. For VM management operations (typically not a hot path), this overhead is likely acceptable and the straightforward implementation is preferred over alternatives like try/catch error handling.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1fe643 and 4862e21.

📒 Files selected for processing (6)
  • lib/domain.spec.ts
  • lib/domain.ts
  • lib/hypervisor.ts
  • src/hypervisor-domain.cc
  • src/hypervisor.cc
  • src/hypervisor.h
🧰 Additional context used
🧬 Code graph analysis (4)
lib/domain.spec.ts (1)
lib/hypervisor.ts (2)
  • domainGetInfo (249-254)
  • domainPMWakeup (212-217)
src/hypervisor-domain.cc (3)
src/hypervisor-node.cc (3)
  • ret (26-29)
  • dummyCallback (12-16)
  • dummyCallback (12-12)
src/worker.cc (2)
  • SetVirError (12-17)
  • SetVirError (12-12)
src/hypervisor-connect.cc (2)
  • dummyCallback (15-19)
  • dummyCallback (15-15)
src/hypervisor.h (1)
src/hypervisor-domain.cc (3)
  • DomainPMWakeupWorker (950-955)
  • DomainPMWakeup (966-986)
  • DomainPMWakeup (966-966)
src/hypervisor.cc (1)
src/hypervisor-domain.cc (2)
  • DomainPMWakeup (966-986)
  • DomainPMWakeup (966-966)
🪛 GitHub Actions: Docker Integration Tests
src/hypervisor-domain.cc

[error] 958-958: virDomainPMWakeup(domain->domainPtr, 0) uses private member 'Domain::domainPtr'. Access to private member is forbidden.

🪛 GitHub Actions: Test Libvirt
src/hypervisor-domain.cc

[error] 958-958: virDomainPMWakeup(domain->domainPtr, 0) uses private member Domain::domainPtr. The member 'domainPtr' is declared private in src/domain.h, causing access violation during build.

🔇 Additional comments (7)
src/hypervisor.cc (1)

44-44: LGTM!

The binding is correctly added following the established pattern.

src/hypervisor.h (1)

44-44: LGTM!

The forward declaration, method signature, and friendship declaration are correctly placed and follow the established pattern in this file. Note that DomainPMWakeupWorker also requires a friend declaration in src/domain.h to access domain->domainPtr (see comment on src/hypervisor-domain.cc).

Also applies to: 79-79, 112-112

lib/hypervisor.ts (1)

207-217: LGTM!

The method implementation follows the established pattern, and the JSDoc clearly documents the purpose and behavior.

lib/domain.spec.ts (3)

9-10: LGTM!

The mock setup correctly initializes both domainGetInfo and domainPMWakeup, and properly adds them to the hypervisor mock object.

Also applies to: 20-26, 32-32, 47-48


105-105: LGTM!

Good addition to verify that domainGetInfo is called as part of the new resume flow.


109-123: LGTM!

Excellent test coverage for the PMSUSPENDED path. The test properly verifies that:

  • domainGetInfo is called to check the state
  • domainPMWakeup is invoked when the state is PMSUSPENDED
  • domainResume is NOT called in this case
lib/domain.ts (1)

1-1: LGTM: Import correctly adds DomainState.

The addition of DomainState to the imports is necessary for the new state check in the resume() method.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Fix all issues with AI Agents 🤖
In @lib/hypervisor.spec.ts:
- Around line 7-12: The test currently stubs nativeHypervisor directly which
bypasses the wrapMethod middleware; update the test to exercise the real
domainPMWakeup through Hypervisor.wrapMethod by instantiating a Hypervisor (or
setting up its native binding) so wrapMethod is invoked, or if that’s too heavy,
explicitly document in the test that it only verifies delegation to
nativeHypervisor and does not exercise wrapMethod; target symbols: use
Hypervisor (constructor/instance), wrapMethod, domainPMWakeup, and
nativeHypervisor to either wire the real binding or add the documented note.
🧹 Nitpick comments (2)
lib/hypervisor.spec.ts (2)

6-6: Test name doesn't match scope.

The test name "should wake a PMSUSPENDED domain" suggests it verifies PMSUSPENDED-specific behavior, but it only tests that domainPMWakeup delegates to the native binding. The PMSUSPENDED state logic resides in Domain.resume(), not here.

Consider renaming to clarify scope, e.g., "should delegate domainPMWakeup to native binding".


18-21: Consider adding error case coverage.

The test verifies the happy path, but could benefit from additional test cases:

  • Error propagation when nativeHypervisor.domainPMWakeup rejects
  • Handling of edge cases (though Domain validation may occur upstream)

These additions would improve robustness but are not critical for the current implementation.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bcd1398 and 7214d64.

📒 Files selected for processing (1)
  • lib/hypervisor.spec.ts
🧰 Additional context used
🧬 Code graph analysis (1)
lib/hypervisor.spec.ts (1)
lib/hypervisor.ts (1)
  • domainPMWakeup (212-217)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build and (Possibly) Publish Pre-built Binaries (18, arm64, ubuntu-latest)
  • GitHub Check: Docker Integration Tests (amd64)
🔇 Additional comments (1)
lib/hypervisor.spec.ts (1)

1-5: LGTM: Clean test setup.

The imports and test suite structure are appropriate for testing the Hypervisor class with Vitest.

Comment on lines +7 to +12
const hypervisor = Object.create(Hypervisor.prototype) as Hypervisor;
const domainPMWakeup = vi.fn().mockResolvedValue(undefined);

(hypervisor as any).nativeHypervisor = {
domainPMWakeup
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Test bypasses wrapMethod integration.

The test mocks nativeHypervisor directly, which skips the wrapMethod wrapper used in the actual implementation (see lib/hypervisor.ts:212-215). This means error handling, promise transformation, or other middleware behavior in wrapMethod is not tested.

Consider testing the actual domainPMWakeup method without mocking nativeHypervisor, or at minimum document that this test only verifies delegation to the native binding.

🔎 Alternative approach to test full integration
-    it('should wake a PMSUSPENDED domain', async () => {
-        const hypervisor = Object.create(Hypervisor.prototype) as Hypervisor;
-        const domainPMWakeup = vi.fn().mockResolvedValue(undefined);
-
-        (hypervisor as any).nativeHypervisor = {
-            domainPMWakeup
-        };
+    it('should delegate to native domainPMWakeup', async () => {
+        // Mock the native binding module that provides the C++ binding
+        const mockNativeBinding = {
+            domainPMWakeup: vi.fn().mockResolvedValue(undefined)
+        };
+        
+        // Create hypervisor with the mocked native binding
+        const hypervisor = new Hypervisor(mockNativeBinding);

Note: This approach tests through wrapMethod but requires understanding how Hypervisor is constructed with the native binding.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In @lib/hypervisor.spec.ts around lines 7-12, The test currently stubs
nativeHypervisor directly which bypasses the wrapMethod middleware; update the
test to exercise the real domainPMWakeup through Hypervisor.wrapMethod by
instantiating a Hypervisor (or setting up its native binding) so wrapMethod is
invoked, or if that’s too heavy, explicitly document in the test that it only
verifies delegation to nativeHypervisor and does not exercise wrapMethod; target
symbols: use Hypervisor (constructor/instance), wrapMethod, domainPMWakeup, and
nativeHypervisor to either wire the real binding or add the documented note.

@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f1fe643) to head (df79743).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #65   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          785       811   +26     
  Branches       154       157    +3     
=========================================
+ Hits           785       811   +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@elibosley elibosley marked this pull request as ready for review January 5, 2026 04:57
@elibosley elibosley requested a review from zackspear January 5, 2026 04:57
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Fix all issues with AI Agents 🤖
In @src/hypervisor-domain.cc:
- Around line 1002-1006: The call to virDomainPMSuspendForDuration is using a
non-existent constant; replace VIR_DOMAIN_PMSUSPEND_MEM with the correct libvirt
suspend target enum value VIR_NODE_SUSPEND_TARGET_MEM (suspend-to-RAM) in the
virDomainPMSuspendForDuration call (e.g., in the code around function/method
using domain->domainPtr and virDomainPMSuspendForDuration) so the function
receives a virNodeSuspendTarget value; ensure any headers required for that enum
are included if not already.
♻️ Duplicate comments (1)
lib/hypervisor.spec.ts (1)

6-21: Same concern as previous review: tests bypass wrapMethod integration.

Both test cases mock nativeHypervisor directly, which skips the wrapMethod wrapper and its error handling. The previous review comment on lines 7-12 already identified this issue for the first test, and the same concern applies to the second test (lines 23-38).

Also applies to: 23-38

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7214d64 and 29feb4f.

📒 Files selected for processing (8)
  • lib/domain.spec.ts
  • lib/domain.ts
  • lib/hypervisor.spec.ts
  • lib/hypervisor.ts
  • src/domain.h
  • src/hypervisor-domain.cc
  • src/hypervisor.cc
  • src/hypervisor.h
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/domain.h
  • src/hypervisor.cc
  • lib/domain.ts
🧰 Additional context used
🧬 Code graph analysis (4)
lib/domain.spec.ts (1)
lib/hypervisor.ts (3)
  • domainGetInfo (261-266)
  • domainPMWakeup (212-217)
  • domainPMSuspend (224-229)
src/hypervisor-domain.cc (3)
src/hypervisor-node.cc (3)
  • ret (26-29)
  • dummyCallback (12-16)
  • dummyCallback (12-12)
src/worker.cc (2)
  • SetVirError (12-17)
  • SetVirError (12-12)
src/hypervisor-connect.cc (2)
  • dummyCallback (15-19)
  • dummyCallback (15-15)
src/hypervisor.h (1)
src/hypervisor-domain.cc (6)
  • DomainPMWakeupWorker (950-955)
  • DomainPMSuspendWorker (994-999)
  • DomainPMWakeup (966-986)
  • DomainPMWakeup (966-966)
  • DomainPMSuspend (1014-1034)
  • DomainPMSuspend (1014-1014)
lib/hypervisor.ts (2)
lib/domain.ts (1)
  • Domain (8-151)
lib/error.ts (1)
  • wrapMethod (55-61)
🪛 GitHub Actions: Test Libvirt
src/hypervisor-domain.cc

[error] 1004-1004: Build error in libvirt-domain.cc:1004: use of undeclared identifier 'VIR_DOMAIN_PMSUSPEND_MEM'; did you mean 'VIR_DOMAIN_PMSUSPENDED'?

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Docker Integration Tests (amd64)
🔇 Additional comments (7)
src/hypervisor.h (1)

44-45: LGTM! Declarations follow existing patterns.

The forward declarations, public method declarations, and friend declarations for DomainPMWakeupWorker and DomainPMSuspendWorker are consistent with the existing code structure and properly mirror the pattern used by other domain worker classes.

Also applies to: 80-81, 114-115

lib/domain.spec.ts (4)

9-10: LGTM! Test setup properly integrates new mocks.

The mock setup for domainGetInfo, domainPMWakeup, and domainPMSuspend follows the existing test patterns and properly initializes all required mocks in the beforeEach hook.

Also applies to: 20-33, 48-50


107-109: LGTM! Correctly verifies domain state check.

The assertion confirms that domainGetInfo is called before resuming, which aligns with the updated resume flow that inspects domain state before deciding which operation to perform.


111-125: LGTM! Test correctly verifies PMSUSPENDED wakeup path.

The test properly validates that when a domain is in the PMSUSPENDED state, resume() calls domainPMWakeup instead of domainResume. Good use of mockResolvedValueOnce and the negative assertion.


128-133: LGTM! Test adequately covers pmSuspend delegation.

The test follows the established pattern for verifying that Domain.pmSuspend() correctly delegates to hypervisor.domainPMSuspend().

lib/hypervisor.ts (1)

207-229: LGTM! Methods follow existing patterns and are properly documented.

Both domainPMWakeup and domainPMSuspend methods:

  • Use wrapMethod correctly for error handling
  • Include clear JSDoc documentation
  • Follow the same pattern as other domain operation methods in the class
  • Properly delegate to the native hypervisor with domain.getNativeDomain()
src/hypervisor-domain.cc (1)

944-986: LGTM! DomainPMWakeup implementation is correct.

The DomainPMWakeupWorker class and Hypervisor::DomainPMWakeup method follow the established worker pattern consistently. The call to virDomainPMWakeup(domain->domainPtr, 0) is correct, with flags set to 0.

@elibosley elibosley changed the title Resume PMSUSPENDED domains by invoking PM wakeup feat: Resume PMSUSPENDED domains by invoking PM wakeup Jan 5, 2026
@elibosley elibosley requested a review from SimonFair January 5, 2026 20:04
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/types.ts (1)

160-162: Logic error in type error message construction.

The code uses typeof str1 to show the received type, but since str1 is already typed as string | undefined, typeof str1 will always evaluate to "string" or "undefined", not the actual type of the original argument that caused the error. This means the error message won't accurately reflect what type was received.

🔎 Consider capturing the actual argument type

The current approach can't recover the original argument's type because by the time this constructor runs, the argument has already been processed. If you need to report the actual type that was passed incorrectly, you should either:

  1. Catch the type error at the call site where the actual argument type is known, or
  2. Pass the stringified value of the problematic argument (not its type) in str1

For example, if the intent is to show the actual value:

-        if (message === 'Expected a number.') {
-            this.message = `Type error: Expected a number but received ${typeof str1 || 'undefined'}. This error typically occurs when calling libvirt methods that require numeric parameters.`;
-        }
+        if (message === 'Expected a number.' && str1) {
+            this.message = `Type error: Expected a number but received '${str1}'. This error typically occurs when calling libvirt methods that require numeric parameters.`;
+        }
♻️ Duplicate comments (1)
lib/hypervisor.spec.ts (1)

7-56: Existing concern about wrapMethod bypass applies to all tests.

All three tests in this file share the same pattern of mocking nativeHypervisor directly, which bypasses the wrapMethod integration. This issue was previously flagged in the existing review comment (lines 8-13) for the first test. The same concern applies to all tests here: error handling, promise transformation, and other middleware behavior in wrapMethod is not exercised.

🧹 Nitpick comments (1)
lib/domain.ts (1)

63-69: Consider updating JSDoc to reflect PM wakeup handling.

The method now handles both regular resume (for paused domains) and PM wakeup (for PMSUSPENDED domains), but the JSDoc only mentions "Resumes a paused domain." Consider updating the documentation to reflect both behaviors.

🔎 Suggested JSDoc improvement
     /**
-     * Resumes a paused domain.
-     * This operation restarts execution of a domain that was previously paused.
+     * Resumes a paused or PM-suspended domain.
+     * If the domain is in PMSUSPENDED state, wakes it using PM wakeup.
+     * Otherwise, resumes execution of a domain that was previously paused.
      * @throws {LibvirtError} If resuming the domain fails
      */
     async resume(): Promise<void> {
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc746fe and 581f211.

📒 Files selected for processing (6)
  • lib/domain.spec.ts
  • lib/domain.ts
  • lib/hypervisor.spec.ts
  • lib/hypervisor.ts
  • lib/types.ts
  • src/hypervisor-domain.cc
🧰 Additional context used
🧬 Code graph analysis (4)
lib/hypervisor.ts (3)
lib/domain.ts (1)
  • Domain (8-151)
lib/types.ts (1)
  • Domain (139-139)
lib/error.ts (1)
  • wrapMethod (55-61)
lib/domain.spec.ts (2)
lib/domain.ts (1)
  • Domain (8-151)
lib/hypervisor.ts (3)
  • Hypervisor (13-365)
  • domainPMWakeup (212-217)
  • domainPMSuspend (224-230)
lib/hypervisor.spec.ts (3)
lib/hypervisor.ts (3)
  • Hypervisor (13-365)
  • domainPMWakeup (212-217)
  • domainPMSuspend (224-230)
lib/domain.ts (1)
  • Domain (8-151)
lib/types.ts (1)
  • Domain (139-139)
src/hypervisor-domain.cc (2)
src/worker.cc (2)
  • SetVirError (12-17)
  • SetVirError (12-12)
src/hypervisor-connect.cc (2)
  • dummyCallback (15-19)
  • dummyCallback (15-15)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Docker Integration Tests (amd64)
🔇 Additional comments (7)
lib/types.ts (1)

94-101: LGTM!

The enum is well-defined and aligns with libvirt's power-management suspend targets.

lib/domain.ts (1)

71-77: LGTM!

The method correctly delegates to the hypervisor and provides a sensible default for the suspend target.

lib/domain.spec.ts (1)

9-10: LGTM!

The test extensions properly cover the new PM suspend/wakeup functionality:

  • Resume path correctly tests both normal resume and PMSUSPENDED wakeup scenarios
  • pmSuspend tests validate default MEM target and custom target override
  • Mock structure allows flexible per-test behavior overrides

Also applies to: 20-26, 32-33, 48-50, 107-109, 111-138

lib/hypervisor.ts (2)

207-217: LGTM!

The method correctly delegates to the native PM wakeup binding and follows the established pattern for domain operations.


219-230: LGTM!

The method correctly delegates to the native PM suspend binding with an appropriate default target value.

src/hypervisor-domain.cc (2)

948-986: LGTM! DomainPMWakeup implementation follows established patterns.

The worker and N-API binding correctly implement the PM wakeup functionality using virDomainPMWakeup. The implementation is consistent with other domain lifecycle operations in this file, with proper input validation and error handling.


992-1044: LGTM! DomainPMSuspend implementation with configurable target.

The worker and N-API binding correctly implement PM suspend with an optional target parameter. The default VIR_NODE_SUSPEND_TARGET_MEM is appropriate, and the optional override allows flexibility for different suspend modes (MEM/DISK/HYBRID). Input validation and error handling are consistent with the codebase patterns.

@elibosley elibosley merged commit d22d53b into main Jan 5, 2026
14 checks passed
@elibosley elibosley deleted the codex/fix-resume-functionality-for-pmsuspended-vm branch January 5, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants