@nosana/node 1.1.84-rc → 1.1.85-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/.env +2 -1
  2. package/dist/package.json +1 -1
  3. package/dist/packages/job-runtime/src/host/HostClient.d.ts +20 -4
  4. package/dist/packages/job-runtime/src/host/HostClient.js +35 -2
  5. package/dist/packages/job-runtime/src/host/contract.d.ts +27 -7
  6. package/dist/packages/job-runtime/src/host/contract.js +43 -7
  7. package/dist/packages/job-runtime/src/runtime/runJob.d.ts +8 -5
  8. package/dist/packages/job-runtime/src/runtime/runJob.js +44 -17
  9. package/dist/packages/vm-orchestrator/src/CidRegistry.d.ts +67 -0
  10. package/dist/packages/vm-orchestrator/src/CidRegistry.js +168 -0
  11. package/dist/packages/vm-orchestrator/src/GpuPool.d.ts +27 -0
  12. package/dist/packages/vm-orchestrator/src/GpuPool.js +41 -0
  13. package/dist/packages/vm-orchestrator/src/Hypervisor.d.ts +66 -0
  14. package/dist/packages/vm-orchestrator/src/Hypervisor.js +7 -0
  15. package/dist/packages/vm-orchestrator/src/QemuHypervisor.d.ts +62 -0
  16. package/dist/packages/vm-orchestrator/src/QemuHypervisor.js +185 -0
  17. package/dist/packages/vm-orchestrator/src/QemuHypervisorConfig.d.ts +61 -0
  18. package/dist/packages/vm-orchestrator/src/QemuHypervisorConfig.js +37 -0
  19. package/dist/packages/vm-orchestrator/src/QemuVmInstance.d.ts +37 -0
  20. package/dist/packages/vm-orchestrator/src/QemuVmInstance.js +44 -0
  21. package/dist/packages/vm-orchestrator/src/QmpClient.d.ts +43 -0
  22. package/dist/packages/vm-orchestrator/src/QmpClient.js +103 -0
  23. package/dist/packages/vm-orchestrator/src/VmSpec.d.ts +21 -0
  24. package/dist/packages/vm-orchestrator/src/VmSpec.js +30 -0
  25. package/dist/packages/vm-orchestrator/src/VmStateManager.d.ts +16 -0
  26. package/dist/packages/vm-orchestrator/src/VmStateManager.js +30 -0
  27. package/dist/packages/vm-orchestrator/src/bootAttempt.d.ts +31 -0
  28. package/dist/packages/vm-orchestrator/src/bootAttempt.js +193 -0
  29. package/dist/packages/vm-orchestrator/src/bootErrors.d.ts +33 -0
  30. package/dist/packages/vm-orchestrator/src/bootErrors.js +67 -0
  31. package/dist/packages/vm-orchestrator/src/buildCloudInit.d.ts +33 -0
  32. package/dist/packages/vm-orchestrator/src/buildCloudInit.js +55 -0
  33. package/dist/packages/vm-orchestrator/src/buildQemuArgs.d.ts +33 -0
  34. package/dist/packages/vm-orchestrator/src/buildQemuArgs.js +127 -0
  35. package/dist/packages/vm-orchestrator/src/diskSizing.d.ts +18 -0
  36. package/dist/packages/vm-orchestrator/src/diskSizing.js +41 -0
  37. package/dist/packages/vm-orchestrator/src/firmware.d.ts +5 -0
  38. package/dist/packages/vm-orchestrator/src/firmware.js +18 -0
  39. package/dist/packages/vm-orchestrator/src/hostAccess/VmHostAccess.d.ts +22 -0
  40. package/dist/packages/vm-orchestrator/src/hostAccess/VmHostAccess.js +33 -0
  41. package/dist/packages/vm-orchestrator/src/hostAccess/deviceProblems.d.ts +3 -0
  42. package/dist/packages/vm-orchestrator/src/hostAccess/deviceProblems.js +17 -0
  43. package/dist/packages/vm-orchestrator/src/hostAccess/findVmHostAccessProblems.d.ts +9 -0
  44. package/dist/packages/vm-orchestrator/src/hostAccess/findVmHostAccessProblems.js +17 -0
  45. package/dist/packages/vm-orchestrator/src/hostAccess/gpuProblems.d.ts +6 -0
  46. package/dist/packages/vm-orchestrator/src/hostAccess/gpuProblems.js +42 -0
  47. package/dist/packages/vm-orchestrator/src/hostAccess/index.d.ts +1 -0
  48. package/dist/packages/vm-orchestrator/src/hostAccess/index.js +1 -0
  49. package/dist/packages/vm-orchestrator/src/hostAccess/memlockProblems.d.ts +6 -0
  50. package/dist/packages/vm-orchestrator/src/hostAccess/memlockProblems.js +18 -0
  51. package/dist/packages/vm-orchestrator/src/hostAccess/workRootProblems.d.ts +7 -0
  52. package/dist/packages/vm-orchestrator/src/hostAccess/workRootProblems.js +30 -0
  53. package/dist/packages/vm-orchestrator/src/hostDevices.d.ts +12 -0
  54. package/dist/packages/vm-orchestrator/src/hostDevices.js +12 -0
  55. package/dist/packages/vm-orchestrator/src/hostTools.d.ts +25 -0
  56. package/dist/packages/vm-orchestrator/src/hostTools.js +39 -0
  57. package/dist/packages/vm-orchestrator/src/imageCache.d.ts +25 -0
  58. package/dist/packages/vm-orchestrator/src/imageCache.js +73 -0
  59. package/dist/packages/vm-orchestrator/src/imageDownload.d.ts +31 -0
  60. package/dist/packages/vm-orchestrator/src/imageDownload.js +85 -0
  61. package/dist/packages/vm-orchestrator/src/index.d.ts +19 -0
  62. package/dist/packages/vm-orchestrator/src/index.js +15 -0
  63. package/dist/packages/vm-orchestrator/src/memlockLimit.d.ts +5 -0
  64. package/dist/packages/vm-orchestrator/src/memlockLimit.js +23 -0
  65. package/dist/packages/vm-orchestrator/src/nvidiaHolders.d.ts +11 -0
  66. package/dist/packages/vm-orchestrator/src/nvidiaHolders.js +74 -0
  67. package/dist/packages/vm-orchestrator/src/pciNuma.d.ts +7 -0
  68. package/dist/packages/vm-orchestrator/src/pciNuma.js +18 -0
  69. package/dist/packages/vm-orchestrator/src/pciSysfs.d.ts +21 -0
  70. package/dist/packages/vm-orchestrator/src/pciSysfs.js +47 -0
  71. package/dist/packages/vm-orchestrator/src/processes.d.ts +37 -0
  72. package/dist/packages/vm-orchestrator/src/processes.js +102 -0
  73. package/dist/packages/vm-orchestrator/src/sockets.d.ts +21 -0
  74. package/dist/packages/vm-orchestrator/src/sockets.js +58 -0
  75. package/dist/packages/vm-orchestrator/src/sweepVmImageCache.d.ts +19 -0
  76. package/dist/packages/vm-orchestrator/src/sweepVmImageCache.js +132 -0
  77. package/dist/packages/vm-orchestrator/src/util.d.ts +14 -0
  78. package/dist/packages/vm-orchestrator/src/util.js +33 -0
  79. package/dist/packages/vm-orchestrator/src/vfioBinding.d.ts +27 -0
  80. package/dist/packages/vm-orchestrator/src/vfioBinding.js +163 -0
  81. package/dist/packages/vm-orchestrator/src/vmImageResolver.d.ts +20 -0
  82. package/dist/packages/vm-orchestrator/src/vmImageResolver.js +62 -0
  83. package/dist/packages/vm-orchestrator/src/vsockBridge.d.ts +20 -0
  84. package/dist/packages/vm-orchestrator/src/vsockBridge.js +27 -0
  85. package/dist/packages/vm-orchestrator/src/workDirs.d.ts +49 -0
  86. package/dist/packages/vm-orchestrator/src/workDirs.js +79 -0
  87. package/dist/src/NodeManager/configs/configs.d.ts +4 -0
  88. package/dist/src/NodeManager/configs/configs.js +3 -0
  89. package/dist/src/NodeManager/db/index.d.ts +10 -0
  90. package/dist/src/NodeManager/db/index.js +4 -0
  91. package/dist/src/NodeManager/monitoring/log/NodeLog.d.ts +2 -0
  92. package/dist/src/NodeManager/monitoring/log/NodeLog.js +21 -0
  93. package/dist/src/NodeManager/monitoring/log/console/ConsoleLogger.d.ts +8 -0
  94. package/dist/src/NodeManager/monitoring/log/console/ConsoleLogger.js +29 -5
  95. package/dist/src/NodeManager/monitoring/log/vmSetupLog.d.ts +11 -0
  96. package/dist/src/NodeManager/monitoring/log/vmSetupLog.js +33 -0
  97. package/dist/src/NodeManager/node/Node.d.ts +2 -0
  98. package/dist/src/NodeManager/node/Node.js +12 -5
  99. package/dist/src/NodeManager/node/job/ContainerJobRuntime.d.ts +141 -0
  100. package/dist/src/NodeManager/node/job/ContainerJobRuntime.js +419 -0
  101. package/dist/src/NodeManager/node/job/JobRuntimeEnvironment.d.ts +74 -0
  102. package/dist/src/NodeManager/node/job/JobRuntimeEnvironment.js +1 -0
  103. package/dist/src/NodeManager/node/job/JobRuntimeHost.d.ts +6 -2
  104. package/dist/src/NodeManager/node/job/JobRuntimeHost.js +13 -2
  105. package/dist/src/NodeManager/node/job/JobRuntimeSession.d.ts +12 -9
  106. package/dist/src/NodeManager/node/job/JobRuntimeSession.js +42 -71
  107. package/dist/src/NodeManager/node/job/VmJobRuntime.d.ts +109 -0
  108. package/dist/src/NodeManager/node/job/VmJobRuntime.js +258 -0
  109. package/dist/src/NodeManager/node/job/VmJobRuntimeConfig.d.ts +33 -0
  110. package/dist/src/NodeManager/node/job/VmJobRuntimeConfig.js +1 -0
  111. package/dist/src/NodeManager/node/job/buildJobRuntimeEnv.d.ts +41 -0
  112. package/dist/src/NodeManager/node/job/buildJobRuntimeEnv.js +25 -0
  113. package/dist/src/NodeManager/node/job/followFile.d.ts +14 -0
  114. package/dist/src/NodeManager/node/job/followFile.js +57 -0
  115. package/dist/src/NodeManager/node/job/jobHandler.d.ts +3 -3
  116. package/dist/src/NodeManager/node/job/jobHandler.js +7 -7
  117. package/dist/src/NodeManager/node/job/keepFailedConsole.d.ts +7 -0
  118. package/dist/src/NodeManager/node/job/keepFailedConsole.js +52 -0
  119. package/dist/src/NodeManager/node/job/selectJobRuntimeEnvironment.d.ts +50 -0
  120. package/dist/src/NodeManager/node/job/selectJobRuntimeEnvironment.js +117 -0
  121. package/dist/src/NodeManager/node/market/benchmark.d.ts +3 -3
  122. package/dist/src/NodeManager/node/market/benchmark.js +3 -3
  123. package/dist/src/NodeManager/node/market/marketHandler.d.ts +3 -3
  124. package/dist/src/NodeManager/node/market/marketHandler.js +3 -3
  125. package/dist/src/NodeManager/node/resource/resourceManager.d.ts +1 -1
  126. package/dist/src/NodeManager/node/resource/resourceManager.js +1 -1
  127. package/dist/src/NodeManager/provider/Provider.d.ts +3 -121
  128. package/dist/src/NodeManager/provider/Provider.js +3 -369
  129. package/dist/src/NodeManager/provider/vmHost/VmNodeOptions.d.ts +14 -0
  130. package/dist/src/NodeManager/provider/vmHost/VmNodeOptions.js +1 -0
  131. package/dist/src/NodeManager/provider/vmHost/capacity.d.ts +16 -0
  132. package/dist/src/NodeManager/provider/vmHost/capacity.js +47 -0
  133. package/dist/src/NodeManager/provider/vmHost/gpus.d.ts +19 -0
  134. package/dist/src/NodeManager/provider/vmHost/gpus.js +83 -0
  135. package/dist/src/NodeManager/provider/vmHost/index.d.ts +5 -0
  136. package/dist/src/NodeManager/provider/vmHost/index.js +4 -0
  137. package/dist/src/NodeManager/provider/vmHost/readVmSpec.d.ts +11 -0
  138. package/dist/src/NodeManager/provider/vmHost/readVmSpec.js +22 -0
  139. package/dist/src/NodeManager/provider/vmHost/setup/PrepareVmHostSystem.d.ts +27 -0
  140. package/dist/src/NodeManager/provider/vmHost/setup/PrepareVmHostSystem.js +25 -0
  141. package/dist/src/NodeManager/provider/vmHost/setup/fileOwnership.d.ts +6 -0
  142. package/dist/src/NodeManager/provider/vmHost/setup/fileOwnership.js +22 -0
  143. package/dist/src/NodeManager/provider/vmHost/setup/hostUser.d.ts +15 -0
  144. package/dist/src/NodeManager/provider/vmHost/setup/hostUser.js +25 -0
  145. package/dist/src/NodeManager/provider/vmHost/setup/index.d.ts +2 -0
  146. package/dist/src/NodeManager/provider/vmHost/setup/index.js +2 -0
  147. package/dist/src/NodeManager/provider/vmHost/setup/memlockLimits.d.ts +6 -0
  148. package/dist/src/NodeManager/provider/vmHost/setup/memlockLimits.js +12 -0
  149. package/dist/src/NodeManager/provider/vmHost/setup/prepareVmHost.d.ts +17 -0
  150. package/dist/src/NodeManager/provider/vmHost/setup/prepareVmHost.js +90 -0
  151. package/dist/src/NodeManager/provider/vmHost/setup/sudoCaller.d.ts +5 -0
  152. package/dist/src/NodeManager/provider/vmHost/setup/sudoCaller.js +35 -0
  153. package/dist/src/NodeManager/provider/vmHost/vmHostEnv.d.ts +20 -0
  154. package/dist/src/NodeManager/provider/vmHost/vmHostEnv.js +24 -0
  155. package/dist/src/NodeManager/provider/vmHost/workRoot.d.ts +14 -0
  156. package/dist/src/NodeManager/provider/vmHost/workRoot.js +84 -0
  157. package/dist/src/NodeManager/repository/NodeRepository.d.ts +12 -2
  158. package/dist/src/NodeManager/repository/NodeRepository.js +21 -1
  159. package/dist/src/cli/commands/prune/command.js +2 -1
  160. package/dist/src/cli/commands/run/action.d.ts +2 -2
  161. package/dist/src/cli/commands/run/action.js +15 -34
  162. package/dist/src/cli/commands/run/command.js +7 -2
  163. package/dist/src/cli/commands/sharedOptions/--config.d.ts +2 -0
  164. package/dist/src/cli/commands/sharedOptions/--config.js +2 -0
  165. package/dist/src/cli/commands/sharedOptions/--environment.d.ts +6 -0
  166. package/dist/src/cli/commands/sharedOptions/--environment.js +6 -0
  167. package/dist/src/cli/commands/sharedOptions/--gpu.js +5 -2
  168. package/dist/src/cli/commands/sharedOptions/--node-limits.d.ts +9 -0
  169. package/dist/src/cli/commands/sharedOptions/--node-limits.js +24 -0
  170. package/dist/src/cli/commands/sharedOptions/index.d.ts +3 -0
  171. package/dist/src/cli/commands/sharedOptions/index.js +3 -0
  172. package/dist/src/cli/commands/start/command.js +7 -2
  173. package/dist/src/cli/commands/vm-setup/action.d.ts +10 -0
  174. package/dist/src/cli/commands/vm-setup/action.js +14 -0
  175. package/dist/src/cli/commands/vm-setup/command.d.ts +3 -0
  176. package/dist/src/cli/commands/vm-setup/command.js +11 -0
  177. package/dist/src/cli/createNosanaCli.d.ts +1 -0
  178. package/dist/src/cli/createNosanaCli.js +4 -1
  179. package/npm-shrinkwrap.json +10 -2
  180. package/package.json +1 -1
@@ -0,0 +1,168 @@
1
+ import fs from 'fs/promises';
2
+ import os from 'os';
3
+ import path from 'path';
4
+ import { isPidAlive } from './processes.js';
5
+ import { describeError } from './util.js';
6
+ /**
7
+ * Candidate directories for the host-global lock registry, tried in order.
8
+ * `/run` is the canonical runtime dir (cleared on reboot, so no lock survives a
9
+ * host restart); the tmpdir fallback keeps unprivileged nodes working. All
10
+ * co-tenant node processes must resolve the same directory for the registry to
11
+ * be host-global, which holds when they run with equal privilege, the normal
12
+ * fleet setup (one launcher, N identical services).
13
+ */
14
+ const DEFAULT_LOCK_DIRS = ['/run/nosana/vsock-cids', path.join(os.tmpdir(), 'nosana-vsock-cids')];
15
+ /** The lowest CID handed out: vsock reserves CIDs 0-2. */
16
+ const DEFAULT_BASE_CID = 3;
17
+ /** Upper bound on the CID scan so a pathological registry can't loop forever. */
18
+ const MAX_CID_SCAN = 4096;
19
+ /**
20
+ * Host-global vsock guest-CID allocator. A guest CID, and the host vsock port
21
+ * derived from it, is a host-scoped resource, but N co-tenant node processes
22
+ * each boot VMs, so reservations live as lockfiles in a directory every node
23
+ * process resolves identically, not in per-process memory.
24
+ *
25
+ * A claim is a file named after the CID recording the owner pid, created
26
+ * atomically (write-to-temp + link(2), which fails EEXIST when the CID is
27
+ * taken). A lock whose recorded pid is dead is a crash leftover and is
28
+ * reclaimed in place; reclaim races are settled by an atomic rename. The
29
+ * kernel stays the ultimate arbiter regardless: QEMU refuses a duplicate
30
+ * guest-cid, which the hypervisor treats as a retriable allocation failure.
31
+ */
32
+ export class CidRegistry {
33
+ constructor(config = {}, system = {}) {
34
+ this.config = config;
35
+ this.owned = new Set();
36
+ this.seq = 0;
37
+ this.baseCid = config.baseCid ?? DEFAULT_BASE_CID;
38
+ this.isPidAlive = system.isPidAlive ?? isPidAlive;
39
+ }
40
+ /** Claim the lowest free CID, skipping any the caller has blacklisted. */
41
+ async claim(skip) {
42
+ const dir = await this.resolveDir();
43
+ const endCid = this.baseCid + MAX_CID_SCAN;
44
+ for (let cid = this.baseCid; cid < endCid; cid++) {
45
+ if (skip?.(cid))
46
+ continue;
47
+ if (await this.tryClaim(dir, cid))
48
+ return cid;
49
+ }
50
+ throw new Error(`no free vsock guest CID in [${this.baseCid}, ${endCid})`);
51
+ }
52
+ /**
53
+ * Hand a claimed CID's lock to the process that holds the CID from now on
54
+ * (the VM's QEMU, which outlives the node process that booted it), so the
55
+ * lock is live exactly as long as the VM. The lock is rewritten in place
56
+ * (temp file + rename), never left absent.
57
+ */
58
+ async transfer(cid, pid) {
59
+ if (!this.owned.delete(cid))
60
+ return;
61
+ const dir = await this.resolveDir();
62
+ const tmp = this.tempPath(dir, 'claim');
63
+ await fs.writeFile(tmp, JSON.stringify({ pid }));
64
+ await fs.rename(tmp, path.join(dir, String(cid)));
65
+ }
66
+ /**
67
+ * Release a CID: one this registry claimed (owner: this process), or, with
68
+ * `owner`, one whose lock was {@link transfer}red to that pid. A no-op for
69
+ * anything else.
70
+ */
71
+ async release(cid, owner) {
72
+ if (owner === undefined && !this.owned.delete(cid))
73
+ return;
74
+ const lockPath = path.join(await this.resolveDir(), String(cid));
75
+ // Only remove a lock that still records its owner: if another node
76
+ // misjudged it dead and reclaimed the slot, it is no longer ours to free.
77
+ if ((await readOwner(lockPath)) === (owner ?? process.pid)) {
78
+ await fs.unlink(lockPath).catch(() => undefined);
79
+ }
80
+ }
81
+ resolveDir() {
82
+ const candidates = this.config.dir ? [this.config.dir] : DEFAULT_LOCK_DIRS;
83
+ this.dir ??= firstWritableDir(candidates);
84
+ return this.dir;
85
+ }
86
+ async tryClaim(dir, cid) {
87
+ const lockPath = path.join(dir, String(cid));
88
+ const isClaimed = (await this.writeLock(dir, lockPath)) || (await this.reclaimStale(dir, cid, lockPath));
89
+ if (isClaimed)
90
+ this.owned.add(cid);
91
+ return isClaimed;
92
+ }
93
+ /**
94
+ * Take over a taken CID whose owner is dead (or whose lock is unreadable): a
95
+ * crash leftover. The stale lock is renamed aside, which exactly one
96
+ * contender wins, then re-verified stale (a fresh claim could have replaced
97
+ * it since it was read) before the slot is taken.
98
+ */
99
+ async reclaimStale(dir, cid, lockPath) {
100
+ if (this.isLiveOwner(await readOwner(lockPath)))
101
+ return false;
102
+ const aside = this.tempPath(dir, `stale-${cid}`);
103
+ const isRenamed = await fs.rename(lockPath, aside).then(() => true, () => false);
104
+ if (!isRenamed)
105
+ return false;
106
+ if (this.isLiveOwner(await readOwner(aside))) {
107
+ await fs.rename(aside, lockPath).catch(() => undefined);
108
+ return false;
109
+ }
110
+ await fs.unlink(aside).catch(() => undefined);
111
+ return this.writeLock(dir, lockPath);
112
+ }
113
+ /**
114
+ * Create the lockfile atomically-with-content: link(2) either publishes the
115
+ * fully written temp file under the lock name or fails EEXIST, so no reader
116
+ * ever sees a half-written (reclaimable-looking) lock.
117
+ */
118
+ async writeLock(dir, lockPath) {
119
+ const tmp = this.tempPath(dir, 'claim');
120
+ await fs.writeFile(tmp, JSON.stringify({ pid: process.pid }));
121
+ try {
122
+ await fs.link(tmp, lockPath);
123
+ return true;
124
+ }
125
+ catch (error) {
126
+ if (describeError(error).code === 'EEXIST')
127
+ return false;
128
+ throw error;
129
+ }
130
+ finally {
131
+ await fs.unlink(tmp).catch(() => undefined);
132
+ }
133
+ }
134
+ isLiveOwner(pid) {
135
+ return pid !== undefined && this.isPidAlive(pid);
136
+ }
137
+ /** A temp file name in the lock dir, unique to this process and call. */
138
+ tempPath(dir, kind) {
139
+ return path.join(dir, `.${kind}-${process.pid}-${++this.seq}`);
140
+ }
141
+ }
142
+ async function firstWritableDir(candidates) {
143
+ for (const candidate of candidates) {
144
+ if (await makeWritableDir(candidate))
145
+ return candidate;
146
+ }
147
+ throw new Error(`no writable directory for the vsock CID registry (tried ${candidates.join(', ')})`);
148
+ }
149
+ async function makeWritableDir(dir) {
150
+ try {
151
+ await fs.mkdir(dir, { recursive: true });
152
+ await fs.access(dir, fs.constants.W_OK);
153
+ return true;
154
+ }
155
+ catch {
156
+ return false;
157
+ }
158
+ }
159
+ /** The pid a lock records; undefined when it is missing or unreadable. */
160
+ async function readOwner(lockPath) {
161
+ try {
162
+ const parsed = JSON.parse(await fs.readFile(lockPath, 'utf8'));
163
+ return typeof parsed?.pid === 'number' ? parsed.pid : undefined;
164
+ }
165
+ catch {
166
+ return undefined;
167
+ }
168
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * How long to wait for a SIGKILLed QEMU to be reaped before freeing its GPU.
3
+ *
4
+ * A dying QEMU keeps its VFIO device file open for seconds after the signal
5
+ * (about 7s observed) while the kernel tears the guest down. Booting another VM
6
+ * on that GPU inside the window hits a kernel bug (6.17 VFIO cdev bind): the
7
+ * refused bind overwrites the holder's KVM pointer, so the holder's VM
8
+ * reference is never dropped and the VM leaks until reboot. Only a reaped QEMU
9
+ * is guaranteed to have closed the device.
10
+ */
11
+ export declare const QEMU_REAP_TIMEOUT_MS = 120000;
12
+ /**
13
+ * The VFIO GPUs this process's VMs hold, so a boot never passes through a GPU a previous VM
14
+ * has yet to let go of.
15
+ */
16
+ export declare class GpuPool {
17
+ private readonly inUse;
18
+ /**
19
+ * Reserve GPUs for the next VM. Throws while a previous VM, booted or attached, still holds
20
+ * any of them: its QEMU has not been reaped yet (see {@link QEMU_REAP_TIMEOUT_MS}).
21
+ */
22
+ reserve(gpus: string[]): void;
23
+ /** Mark GPUs held, as by a VM this process attached to. */
24
+ hold(gpus: string[]): void;
25
+ /** Free GPUs once the VM that held them has gone. */
26
+ release(gpus: string[]): void;
27
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * How long to wait for a SIGKILLed QEMU to be reaped before freeing its GPU.
3
+ *
4
+ * A dying QEMU keeps its VFIO device file open for seconds after the signal
5
+ * (about 7s observed) while the kernel tears the guest down. Booting another VM
6
+ * on that GPU inside the window hits a kernel bug (6.17 VFIO cdev bind): the
7
+ * refused bind overwrites the holder's KVM pointer, so the holder's VM
8
+ * reference is never dropped and the VM leaks until reboot. Only a reaped QEMU
9
+ * is guaranteed to have closed the device.
10
+ */
11
+ export const QEMU_REAP_TIMEOUT_MS = 120_000;
12
+ /**
13
+ * The VFIO GPUs this process's VMs hold, so a boot never passes through a GPU a previous VM
14
+ * has yet to let go of.
15
+ */
16
+ export class GpuPool {
17
+ constructor() {
18
+ this.inUse = new Set();
19
+ }
20
+ /**
21
+ * Reserve GPUs for the next VM. Throws while a previous VM, booted or attached, still holds
22
+ * any of them: its QEMU has not been reaped yet (see {@link QEMU_REAP_TIMEOUT_MS}).
23
+ */
24
+ reserve(gpus) {
25
+ const held = gpus.filter((gpu) => this.inUse.has(gpu));
26
+ if (held.length > 0) {
27
+ throw new Error(`GPU ${held.join(',')} is still held by a previous VM`);
28
+ }
29
+ this.hold(gpus);
30
+ }
31
+ /** Mark GPUs held, as by a VM this process attached to. */
32
+ hold(gpus) {
33
+ for (const gpu of gpus)
34
+ this.inUse.add(gpu);
35
+ }
36
+ /** Free GPUs once the VM that held them has gone. */
37
+ release(gpus) {
38
+ for (const gpu of gpus)
39
+ this.inUse.delete(gpu);
40
+ }
41
+ }
@@ -0,0 +1,66 @@
1
+ import type { CloudInitOptions } from './buildCloudInit.js';
2
+ import type { VmSpec } from './VmSpec.js';
3
+ /**
4
+ * A running VM as the node records it, so a later node process can find it
5
+ * again ({@link Hypervisor.attach}). Plain data: QEMU and the bridge run
6
+ * detached from the process that booted them.
7
+ */
8
+ export interface VmRecord {
9
+ /** The VM's work dir (overlay, sockets, logs). */
10
+ workdir: string;
11
+ /** The VM's QEMU. */
12
+ qemuPid: number;
13
+ /** The host `socat` bridging the guest's vsock connections to {@link hostSocket}. */
14
+ bridgePid: number;
15
+ /** The VM's vsock guest CID; the host vsock port it connects out to is `HOST_VSOCK_PORT_BASE + cid`. */
16
+ cid: number;
17
+ /** The host port forwarded to the job runtime's API in the guest (8080). */
18
+ apiHostPort: number;
19
+ /** The node-served unix socket the bridge connects to (the job dir's `host.sock`). */
20
+ hostSocket: string;
21
+ /** Host PCI addresses of the GPUs passed through (VFIO). */
22
+ gpus: string[];
23
+ }
24
+ /** What a VM is booted with besides its {@link VmSpec}. */
25
+ export interface BootOptions {
26
+ /** Resolved local path of the base image. */
27
+ imagePath: string;
28
+ /** The node-served unix socket the guest's `host.sock` is bridged to. */
29
+ hostSocket: string;
30
+ /** What cloud-init writes into the guest; the host vsock port is filled in at boot. */
31
+ cloudInit: Omit<CloudInitOptions, 'hostVsockPort'>;
32
+ /** Optional progress logger, called at each boot step. */
33
+ log?: (message: string) => void;
34
+ }
35
+ /** A VM this process booted or attached to. */
36
+ export interface VmInstance {
37
+ /** What to store to {@link Hypervisor.attach} again; updated when attach re-spawns the bridge. */
38
+ readonly record: VmRecord;
39
+ /** Resolves when QEMU has exited: its exit code when this process spawned it, else null. */
40
+ waitForExit(): Promise<number | null>;
41
+ /** Graceful guest power-down (ACPI). */
42
+ shutdown(): Promise<void>;
43
+ /** Kill QEMU and the bridge, wait for QEMU to be reaped, free its GPUs and CID, remove the work dir. */
44
+ destroy(): Promise<void>;
45
+ }
46
+ /** Boots VMs and finds them again after a node restart. */
47
+ export interface Hypervisor {
48
+ /** Boot a VM from a base image. */
49
+ boot(spec: VmSpec, opts: BootOptions): Promise<VmInstance>;
50
+ /** Take over a VM a previous node process booted; {@link VmNotRunningError} when it is gone. */
51
+ attach(record: VmRecord): Promise<VmInstance>;
52
+ /** Is the record's QEMU still running (its pid, naming the record's work dir)? */
53
+ isRunning(record: VmRecord): Promise<boolean>;
54
+ /** Remove the VM work dirs no record in `keep` names and no process uses. */
55
+ sweepWorkDirs(keep: string[]): Promise<void>;
56
+ /**
57
+ * Free what a VM whose QEMU is no longer running left behind: its bridge,
58
+ * its CID lock, its GPUs and its work dir. Refuses a VM that runs.
59
+ */
60
+ release(record: VmRecord): Promise<void>;
61
+ }
62
+ /** {@link Hypervisor.attach} found no QEMU of this record running. */
63
+ export declare class VmNotRunningError extends Error {
64
+ readonly record: VmRecord;
65
+ constructor(record: VmRecord);
66
+ }
@@ -0,0 +1,7 @@
1
+ /** {@link Hypervisor.attach} found no QEMU of this record running. */
2
+ export class VmNotRunningError extends Error {
3
+ constructor(record) {
4
+ super(`VM ${record.workdir} is not running (QEMU pid ${record.qemuPid})`);
5
+ this.record = record;
6
+ }
7
+ }
@@ -0,0 +1,62 @@
1
+ import { type BootOptions, type Hypervisor, type VmInstance, type VmRecord } from './Hypervisor.js';
2
+ import { type QemuHypervisorConfig, type QemuHypervisorSystem } from './QemuHypervisorConfig.js';
3
+ import type { VmSpec } from './VmSpec.js';
4
+ /**
5
+ * Boots VMs with QEMU. QEMU and the vsock bridge are spawned detached (own
6
+ * session, output to files in the work dir), so they outlive the node
7
+ * process; the {@link VmRecord} a boot returns is how a later process attaches
8
+ * to them. A boot first moves the VM's GPUs to vfio-pci, and is retried when
9
+ * the kernel reports a vsock CID or host port taken, and while a previous VM
10
+ * still holds the GPU.
11
+ */
12
+ export declare class QemuHypervisor implements Hypervisor {
13
+ private readonly config;
14
+ private readonly system;
15
+ private readonly gpus;
16
+ private readonly cids;
17
+ /** The OVMF firmware a GPU VM boots; undefined: the default firmware. */
18
+ private readonly biosPath;
19
+ /** CIDs the kernel reported taken despite a free lock: skipped while this process lives. */
20
+ private readonly badCids;
21
+ constructor(config: QemuHypervisorConfig, system?: Partial<QemuHypervisorSystem>);
22
+ boot(spec: VmSpec, opts: BootOptions): Promise<VmInstance>;
23
+ /**
24
+ * Take a VM a previous node process booted over again: its QEMU must be
25
+ * running with a command line naming the record's work dir (a recycled pid
26
+ * is not it), else {@link VmNotRunningError}. Reconnects QMP and the
27
+ * console, and re-spawns the host bridge when it is gone; the instance's
28
+ * record carries the new bridge pid then.
29
+ */
30
+ attach(record: VmRecord): Promise<VmInstance>;
31
+ isRunning(record: VmRecord): Promise<boolean>;
32
+ sweepWorkDirs(keep: string[]): Promise<void>;
33
+ /**
34
+ * Free what a VM whose QEMU has gone left (killed, crashed, the guest
35
+ * powered off): its bridge, which would otherwise keep the CID's host vsock
36
+ * port bound, when its pid still is that bridge (a recycled pid is left
37
+ * alone); its CID lock, when the dead QEMU still owns it; its GPUs in this
38
+ * process's pool; and its work dir. A VM still running is refused: destroy
39
+ * it through {@link attach}.
40
+ */
41
+ release(record: VmRecord): Promise<void>;
42
+ /**
43
+ * Boot attempts, each with a CID claimed from the host-global registry so
44
+ * co-tenant nodes' VMs never collide on a guest CID, nor (the host port
45
+ * being base + CID) on a bridge.
46
+ */
47
+ private bootWithRetries;
48
+ /** Is a failed attempt retried? Logs why, and waits out a held GPU. */
49
+ private shouldRetry;
50
+ /**
51
+ * Logged per attempt, with the time since the first, so the log records how
52
+ * long the previous VM kept the GPU after its QEMU exited.
53
+ */
54
+ private describeGpuBusyRetry;
55
+ private bootContext;
56
+ /** The record's bridge pid while it lives, else a re-spawned bridge's (undefined: it failed). */
57
+ private reviveBridge;
58
+ private instance;
59
+ private isBridgeLive;
60
+ /** Is `pid` alive with `marker` in its command line? */
61
+ private isLive;
62
+ }
@@ -0,0 +1,185 @@
1
+ import { bootAttempt } from './bootAttempt.js';
2
+ import { isGpuStillHeld, isHostPortCollision, isVsockCollision } from './bootErrors.js';
3
+ import { CidRegistry } from './CidRegistry.js';
4
+ import { GpuPool } from './GpuPool.js';
5
+ import { VmNotRunningError, } from './Hypervisor.js';
6
+ import { killProcessGroup } from './processes.js';
7
+ import { resolveQemuHypervisorConfig, resolveQemuHypervisorSystem, } from './QemuHypervisorConfig.js';
8
+ import { QemuVmInstance } from './QemuVmInstance.js';
9
+ import { connectVmSockets } from './sockets.js';
10
+ import { sleep } from './util.js';
11
+ import { VmStateManager } from './VmStateManager.js';
12
+ import { bridgeCommandMarker, hostVsockPort, spawnBridge } from './vsockBridge.js';
13
+ import { removeWorkDir, sweepWorkDirs, workDirPaths } from './workDirs.js';
14
+ /** Boot attempts per VM when the kernel reports our vsock CID/port or a host port taken. */
15
+ const MAX_BOOT_ATTEMPTS = 3;
16
+ /** Boot retries while the GPU is still held by a previous VM. */
17
+ const MAX_GPU_BUSY_RETRIES = 9;
18
+ /**
19
+ * Boots VMs with QEMU. QEMU and the vsock bridge are spawned detached (own
20
+ * session, output to files in the work dir), so they outlive the node
21
+ * process; the {@link VmRecord} a boot returns is how a later process attaches
22
+ * to them. A boot first moves the VM's GPUs to vfio-pci, and is retried when
23
+ * the kernel reports a vsock CID or host port taken, and while a previous VM
24
+ * still holds the GPU.
25
+ */
26
+ export class QemuHypervisor {
27
+ constructor(config, system = {}) {
28
+ this.gpus = new GpuPool();
29
+ /** CIDs the kernel reported taken despite a free lock: skipped while this process lives. */
30
+ this.badCids = new Set();
31
+ this.config = resolveQemuHypervisorConfig(config);
32
+ this.system = resolveQemuHypervisorSystem(system);
33
+ this.biosPath = this.system.discoverUefiBios();
34
+ this.cids = new CidRegistry({ dir: this.config.cidLockDir }, { isPidAlive: this.system.isPidAlive });
35
+ }
36
+ async boot(spec, opts) {
37
+ // The GPUs are reserved first so a boot fails fast, before any IO, while a
38
+ // previous VM still holds them.
39
+ this.gpus.reserve(spec.gpus);
40
+ try {
41
+ await this.system.bindGpusToVfio(spec.gpus);
42
+ return await this.bootWithRetries(spec, opts);
43
+ }
44
+ catch (error) {
45
+ this.gpus.release(spec.gpus);
46
+ throw error;
47
+ }
48
+ }
49
+ /**
50
+ * Take a VM a previous node process booted over again: its QEMU must be
51
+ * running with a command line naming the record's work dir (a recycled pid
52
+ * is not it), else {@link VmNotRunningError}. Reconnects QMP and the
53
+ * console, and re-spawns the host bridge when it is gone; the instance's
54
+ * record carries the new bridge pid then.
55
+ */
56
+ async attach(record) {
57
+ if (!(await this.isRunning(record)))
58
+ throw new VmNotRunningError(record);
59
+ this.gpus.hold(record.gpus);
60
+ try {
61
+ const connection = await connectVmSockets(this.system, workDirPaths(record.workdir));
62
+ const bridgePid = await this.reviveBridge(record);
63
+ if (bridgePid === undefined) {
64
+ connection.qmp.close();
65
+ connection.serial.destroy();
66
+ throw new Error('vsock host bridge failed to start');
67
+ }
68
+ return this.instance({ ...record, bridgePid }, connection);
69
+ }
70
+ catch (error) {
71
+ this.gpus.release(record.gpus);
72
+ throw error;
73
+ }
74
+ }
75
+ isRunning(record) {
76
+ return this.isLive(record.qemuPid, `${record.workdir}/`);
77
+ }
78
+ sweepWorkDirs(keep) {
79
+ return sweepWorkDirs(this.config.workRoot, keep, this.system.commandLines);
80
+ }
81
+ /**
82
+ * Free what a VM whose QEMU has gone left (killed, crashed, the guest
83
+ * powered off): its bridge, which would otherwise keep the CID's host vsock
84
+ * port bound, when its pid still is that bridge (a recycled pid is left
85
+ * alone); its CID lock, when the dead QEMU still owns it; its GPUs in this
86
+ * process's pool; and its work dir. A VM still running is refused: destroy
87
+ * it through {@link attach}.
88
+ */
89
+ async release(record) {
90
+ if (await this.isRunning(record)) {
91
+ throw new Error(`VM ${record.workdir} is still running (QEMU pid ${record.qemuPid})`);
92
+ }
93
+ if (await this.isBridgeLive(record))
94
+ killProcessGroup(this.system.killPid, record.bridgePid);
95
+ await this.cids.release(record.cid, record.qemuPid);
96
+ this.gpus.release(record.gpus);
97
+ await removeWorkDir(record.workdir);
98
+ }
99
+ /**
100
+ * Boot attempts, each with a CID claimed from the host-global registry so
101
+ * co-tenant nodes' VMs never collide on a guest CID, nor (the host port
102
+ * being base + CID) on a bridge.
103
+ */
104
+ async bootWithRetries(spec, options) {
105
+ const retries = { attempt: 1, gpuBusyRetries: 0, firstAttemptAt: Date.now() };
106
+ for (;; retries.attempt++) {
107
+ const cid = await this.cids.claim((candidate) => this.badCids.has(candidate));
108
+ try {
109
+ const vm = await bootAttempt(this.bootContext(), { spec, options, cid });
110
+ return this.instance(vm.record, vm, vm.qemu);
111
+ }
112
+ catch (error) {
113
+ await this.cids.release(cid);
114
+ if (!(await this.shouldRetry(error, cid, spec.gpus, retries, options)))
115
+ throw error;
116
+ }
117
+ }
118
+ }
119
+ /** Is a failed attempt retried? Logs why, and waits out a held GPU. */
120
+ async shouldRetry(error, cid, gpus, retries, { log }) {
121
+ const hasAttemptsLeft = retries.attempt < MAX_BOOT_ATTEMPTS;
122
+ if (hasAttemptsLeft && isVsockCollision(error)) {
123
+ this.badCids.add(cid);
124
+ log?.(`vsock CID ${cid} is taken on the host; retrying with a fresh CID`);
125
+ return true;
126
+ }
127
+ if (hasAttemptsLeft && isHostPortCollision(error)) {
128
+ log?.('A forwarded host port was taken; retrying with a fresh port');
129
+ return true;
130
+ }
131
+ if (!isGpuStillHeld(error) || retries.gpuBusyRetries >= MAX_GPU_BUSY_RETRIES)
132
+ return false;
133
+ retries.gpuBusyRetries++;
134
+ log?.(this.describeGpuBusyRetry(gpus, retries));
135
+ await sleep(this.config.gpuBusyRetryDelayMs);
136
+ return true;
137
+ }
138
+ /**
139
+ * Logged per attempt, with the time since the first, so the log records how
140
+ * long the previous VM kept the GPU after its QEMU exited.
141
+ */
142
+ describeGpuBusyRetry(gpus, retries) {
143
+ const elapsedS = Math.round((Date.now() - retries.firstAttemptAt) / 1000);
144
+ const delayS = Math.round(this.config.gpuBusyRetryDelayMs / 1000);
145
+ return (`GPU ${gpus.join(',')} is still held by a previous VM ` +
146
+ `(${elapsedS}s since first attempt); ` +
147
+ `retry ${retries.gpuBusyRetries}/${MAX_GPU_BUSY_RETRIES} in ${delayS}s`);
148
+ }
149
+ bootContext() {
150
+ return { config: this.config, system: this.system, cids: this.cids, biosPath: this.biosPath };
151
+ }
152
+ /** The record's bridge pid while it lives, else a re-spawned bridge's (undefined: it failed). */
153
+ async reviveBridge(record) {
154
+ if (await this.isBridgeLive(record))
155
+ return record.bridgePid;
156
+ const { bridgeLog } = workDirPaths(record.workdir);
157
+ const hostPort = hostVsockPort(record.cid);
158
+ const bridge = spawnBridge(this.system.spawn, bridgeLog, hostPort, record.hostSocket);
159
+ bridge.on('error', () => {
160
+ // a bridge that fails to start has no pid, which attach reports
161
+ });
162
+ return bridge.pid;
163
+ }
164
+ instance(record, connection, qemu) {
165
+ const consoleLog = new VmStateManager(connection.serial, workDirPaths(record.workdir).consoleLog);
166
+ consoleLog.start();
167
+ return new QemuVmInstance({ record, qmp: connection.qmp, consoleLog, qemu }, {
168
+ isPidAlive: this.system.isPidAlive,
169
+ killPid: this.system.killPid,
170
+ release: async () => {
171
+ this.gpus.release(record.gpus);
172
+ await this.cids.release(record.cid, record.qemuPid);
173
+ },
174
+ });
175
+ }
176
+ isBridgeLive(record) {
177
+ return this.isLive(record.bridgePid, bridgeCommandMarker(hostVsockPort(record.cid)));
178
+ }
179
+ /** Is `pid` alive with `marker` in its command line? */
180
+ async isLive(pid, marker) {
181
+ if (!this.system.isPidAlive(pid))
182
+ return false;
183
+ return (await this.system.pidCommand(pid))?.includes(marker) ?? false;
184
+ }
185
+ }
@@ -0,0 +1,61 @@
1
+ import type net from 'net';
2
+ import { type FreeSpaceLike } from './diskSizing.js';
3
+ import { type PciNumaNodeReader } from './pciNuma.js';
4
+ import { type KillLike, type RunLike, type SpawnLike } from './processes.js';
5
+ import type { QmpClient } from './QmpClient.js';
6
+ import { type VfioBinder } from './vfioBinding.js';
7
+ import type { CommandLinesLike } from './workDirs.js';
8
+ /**
9
+ * Where and how a QemuHypervisor boots VMs; what each VM gets (vCPUs, memory, GPUs, disk) is
10
+ * its VmSpec.
11
+ */
12
+ export interface QemuHypervisorConfig {
13
+ /** Where VM work dirs are made; the disk is sized from its filesystem's free space. */
14
+ workRoot: string;
15
+ /** QEMU accelerator: 'kvm' (default) on a Linux host, 'tcg' to emulate. */
16
+ accel?: string;
17
+ /** Directory of the host-global vsock CID lock registry (default: see CidRegistry). */
18
+ cidLockDir?: string;
19
+ /** Delay between boot retries while a GPU is still held (default 10s). */
20
+ gpuBusyRetryDelayMs?: number;
21
+ }
22
+ /** How a QemuHypervisor acts on the host; tests inject fakes for any of it. */
23
+ export interface QemuHypervisorSystem {
24
+ /** Spawn QEMU and the vsock bridge. */
25
+ spawn: SpawnLike;
26
+ /** Run qemu-img and the ISO tool to completion. */
27
+ run: RunLike;
28
+ /** Connect QEMU's QMP control socket (default: with retry while QEMU starts). */
29
+ connectQmp: (socketPath: string) => Promise<QmpClient>;
30
+ /** Connect QEMU's serial console socket (default: with retry while QEMU starts). */
31
+ connectSerial: (socketPath: string) => Promise<net.Socket>;
32
+ /** Allocate a free host port for the job API forward (default: OS-assigned). */
33
+ allocatePort: () => Promise<number>;
34
+ /** Probe the work root's filesystem capacity for disk auto-sizing (default: statfs). */
35
+ freeSpace: FreeSpaceLike;
36
+ /** Find the OVMF firmware a GPU VM boots, once (default: the well-known paths). */
37
+ discoverUefiBios: () => string | undefined;
38
+ /** Read the NUMA node of a GPU, which its VM is pinned to (default: sysfs). */
39
+ readPciNumaNode: PciNumaNodeReader;
40
+ /** Move a VM's GPUs to vfio-pci before it boots (default: sysfs, see bindGpusToVfio). */
41
+ bindGpusToVfio: VfioBinder;
42
+ /** Is a pid alive? */
43
+ isPidAlive: (pid: number) => boolean;
44
+ /** A pid's command line, to tell a recorded process from a recycled pid (default: procfs). */
45
+ pidCommand: (pid: number) => Promise<string | undefined>;
46
+ /** Every running process's command line, undefined when unlistable (default: procfs). */
47
+ commandLines: CommandLinesLike;
48
+ /** Signal a process (a negative pid: its process group). */
49
+ killPid: KillLike;
50
+ }
51
+ /** The config the node passes, by the name the package has always exported. */
52
+ export type QemuHypervisorOptions = QemuHypervisorConfig;
53
+ /** A {@link QemuHypervisorConfig} with its defaults filled in. */
54
+ export interface ResolvedQemuHypervisorConfig extends QemuHypervisorConfig {
55
+ accel: string;
56
+ gpuBusyRetryDelayMs: number;
57
+ }
58
+ /** Fill in the config's defaults. */
59
+ export declare function resolveQemuHypervisorConfig(config: QemuHypervisorConfig): ResolvedQemuHypervisorConfig;
60
+ /** The real host for whatever `system` leaves out. */
61
+ export declare function resolveQemuHypervisorSystem(system: Partial<QemuHypervisorSystem>): QemuHypervisorSystem;
@@ -0,0 +1,37 @@
1
+ import { spawn } from 'child_process';
2
+ import { DEFAULT_ACCEL } from './buildQemuArgs.js';
3
+ import { statfsCapacity } from './diskSizing.js';
4
+ import { discoverUefiBios } from './firmware.js';
5
+ import { readPciNumaNode } from './pciNuma.js';
6
+ import { isPidAlive, killPid, procCmdline, procCommandLines, runToCompletion, } from './processes.js';
7
+ import { allocateFreePort, connectQmpWithRetry, connectSerialWithRetry } from './sockets.js';
8
+ import { bindGpusToVfio } from './vfioBinding.js';
9
+ /** Delay between boot retries while a VFIO GPU is still held by a previous VM. */
10
+ const DEFAULT_GPU_BUSY_RETRY_DELAY_MS = 10_000;
11
+ /** Fill in the config's defaults. */
12
+ export function resolveQemuHypervisorConfig(config) {
13
+ return {
14
+ ...config,
15
+ accel: config.accel ?? DEFAULT_ACCEL,
16
+ gpuBusyRetryDelayMs: config.gpuBusyRetryDelayMs ?? DEFAULT_GPU_BUSY_RETRY_DELAY_MS,
17
+ };
18
+ }
19
+ /** The real host for whatever `system` leaves out. */
20
+ export function resolveQemuHypervisorSystem(system) {
21
+ return {
22
+ spawn,
23
+ run: runToCompletion,
24
+ connectQmp: connectQmpWithRetry,
25
+ connectSerial: connectSerialWithRetry,
26
+ allocatePort: allocateFreePort,
27
+ freeSpace: statfsCapacity,
28
+ discoverUefiBios,
29
+ readPciNumaNode,
30
+ bindGpusToVfio: (gpus) => bindGpusToVfio(gpus),
31
+ isPidAlive,
32
+ pidCommand: procCmdline,
33
+ commandLines: procCommandLines,
34
+ killPid,
35
+ ...system,
36
+ };
37
+ }