@impz/testing 7.8.1 → 7.10.0
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.
- package/dist/index.js +274 -127
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -18837,7 +18837,8 @@ import { join } from "path";
|
|
|
18837
18837
|
var UFFD_RUN_FILES = {
|
|
18838
18838
|
socket: "uffd.sock",
|
|
18839
18839
|
pidFile: "uffd.pid",
|
|
18840
|
-
statsFile: "uffd.stats"
|
|
18840
|
+
statsFile: "uffd.stats",
|
|
18841
|
+
touchedFile: "uffd.touched"
|
|
18841
18842
|
};
|
|
18842
18843
|
var DATA_DIRS = ["db", "system", "images", "imps"];
|
|
18843
18844
|
function createDataDirs(dataDir) {
|
|
@@ -18869,6 +18870,7 @@ function buildImpPaths(dataDir, impId) {
|
|
|
18869
18870
|
uffdSocket: join(runDir, UFFD_RUN_FILES.socket),
|
|
18870
18871
|
uffdPidFile: join(runDir, UFFD_RUN_FILES.pidFile),
|
|
18871
18872
|
uffdStatsFile: join(runDir, UFFD_RUN_FILES.statsFile),
|
|
18873
|
+
uffdTouchedFile: join(runDir, UFFD_RUN_FILES.touchedFile),
|
|
18872
18874
|
...buildSnapshotPaths(join(directory, "snapshot")),
|
|
18873
18875
|
vmIdentity: join(directory, "vm.json"),
|
|
18874
18876
|
checkpointsDir: join(directory, "checkpoints"),
|
|
@@ -18883,6 +18885,7 @@ function buildSnapshotPaths(snapshotDir) {
|
|
|
18883
18885
|
snapshotDir,
|
|
18884
18886
|
vmstate: join(snapshotDir, "vmstate"),
|
|
18885
18887
|
memFile: join(snapshotDir, "mem"),
|
|
18888
|
+
memTouched: join(snapshotDir, "mem.touched"),
|
|
18886
18889
|
snapshotMeta: join(snapshotDir, "meta.json")
|
|
18887
18890
|
};
|
|
18888
18891
|
}
|
|
@@ -18924,7 +18927,7 @@ var BACKUP_TREE = {
|
|
|
18924
18927
|
};
|
|
18925
18928
|
|
|
18926
18929
|
// packages/testing/src/stand-in/start-test-impd.ts
|
|
18927
|
-
import { copyFileSync as
|
|
18930
|
+
import { copyFileSync as copyFileSync6, mkdirSync as mkdirSync32, mkdtempSync, writeFileSync as writeFileSync18 } from "fs";
|
|
18928
18931
|
import { rm as rm2 } from "fs/promises";
|
|
18929
18932
|
import { tmpdir } from "os";
|
|
18930
18933
|
|
|
@@ -21750,6 +21753,11 @@ function resolveMaxMemoryMib(memoryMib, requested) {
|
|
|
21750
21753
|
message: `the max memory (${String(requested)} MiB) is more than ${String(MAX_GROWTH_FACTOR)} \xD7 the memory (${String(ceiling)} MiB): memory the guest grows into cannot hold its kernel's own allocations, so raise the memory too`
|
|
21751
21754
|
});
|
|
21752
21755
|
}
|
|
21756
|
+
if (requested > memoryMib && (memoryMib % BLOCK_MIB !== 0 || requested % BLOCK_MIB !== 0)) {
|
|
21757
|
+
throw new ImpdError("BAD_REQUEST", {
|
|
21758
|
+
message: `an imp that grows needs a memory (${String(memoryMib)} MiB) and a max memory (${String(requested)} MiB) of whole ${String(BLOCK_MIB)} MiB blocks`
|
|
21759
|
+
});
|
|
21760
|
+
}
|
|
21753
21761
|
return requested;
|
|
21754
21762
|
}
|
|
21755
21763
|
function toWholeBlocks(mib) {
|
|
@@ -21811,6 +21819,7 @@ var EnvSchema = z54.object({
|
|
|
21811
21819
|
IMP_KSM_EXEC: z54.string().default("ksm-exec"),
|
|
21812
21820
|
IMP_KSM_HEADROOM_PERCENT: z54.string().default("100"),
|
|
21813
21821
|
IMP_HUGE_PAGES: z54.enum(["off", "2M"]).default("off"),
|
|
21822
|
+
IMP_ELASTIC_TRANSPARENT_HUGE_PAGES: z54.enum(["on", "off"]).default("on"),
|
|
21814
21823
|
IMP_UFFD_HANDLER: z54.string().default("uffd-handler"),
|
|
21815
21824
|
IMP_WARM_CAP_MIB: CountSchema3.default(2048),
|
|
21816
21825
|
IMP_DNS: z54.string().default("1.1.1.1,8.8.8.8").transform(splitList).pipe(DnsServersSchema),
|
|
@@ -21985,6 +21994,7 @@ function loadConfig(env) {
|
|
|
21985
21994
|
jailDir: join4(parsed.IMP_DATA_DIR, "jail"),
|
|
21986
21995
|
ksm: parseKsmConfig(parsed),
|
|
21987
21996
|
hugePages: parsed.IMP_HUGE_PAGES === "2M" ? { handlerBin: parsed.IMP_UFFD_HANDLER, warmCapMib: parsed.IMP_WARM_CAP_MIB } : null,
|
|
21997
|
+
isElasticTransparentHugePages: parsed.IMP_ELASTIC_TRANSPARENT_HUGE_PAGES === "on",
|
|
21988
21998
|
kernelPath: join4(parsed.IMP_DATA_DIR, "system", "vmlinux"),
|
|
21989
21999
|
kernelSource: parsed.IMP_KERNEL ?? null,
|
|
21990
22000
|
systemDriveSource: parsed.IMP_SYSTEM_DRIVE ?? join4(parsed.IMP_DATA_DIR, "system", "imp-system.squashfs"),
|
|
@@ -22145,13 +22155,13 @@ function readHostAddresses() {
|
|
|
22145
22155
|
}
|
|
22146
22156
|
|
|
22147
22157
|
// packages/daemon/src/impd/create-impd.ts
|
|
22148
|
-
import { readFileSync as
|
|
22158
|
+
import { readFileSync as readFileSync39 } from "fs";
|
|
22149
22159
|
import { release as release2 } from "os";
|
|
22150
22160
|
import { join as join49 } from "path";
|
|
22151
22161
|
// packages/daemon/package.json
|
|
22152
22162
|
var package_default = {
|
|
22153
22163
|
name: "@impz/daemon",
|
|
22154
|
-
version: "7.
|
|
22164
|
+
version: "7.10.0",
|
|
22155
22165
|
private: true,
|
|
22156
22166
|
description: "impd: the imp host daemon",
|
|
22157
22167
|
type: "module",
|
|
@@ -25788,7 +25798,7 @@ var SnapshotIdentitySchema = z62.object({
|
|
|
25788
25798
|
ipv6Prefix: z62.string().nullable().optional(),
|
|
25789
25799
|
cpuModel: z62.string().optional(),
|
|
25790
25800
|
cpuFlags: z62.string().optional(),
|
|
25791
|
-
hugePages: z62.enum(["None", "2M"]).optional()
|
|
25801
|
+
hugePages: z62.enum(["None", "2M", "Transparent"]).optional()
|
|
25792
25802
|
});
|
|
25793
25803
|
var AGENT_RECORD_JSON = { useProtoFieldName: true, alwaysEmitImplicit: true };
|
|
25794
25804
|
var SeenSessionJsonSchema = z62.json().transform((json, ctx) => {
|
|
@@ -29473,7 +29483,7 @@ var VmIdentitySchema = z70.object({
|
|
|
29473
29483
|
ipv6Prefix: z70.string().nullable().optional(),
|
|
29474
29484
|
cpuModel: z70.string().optional(),
|
|
29475
29485
|
cpuFlags: z70.string().optional(),
|
|
29476
|
-
hugePages: z70.enum(["None", "2M"]).optional()
|
|
29486
|
+
hugePages: z70.enum(["None", "2M", "Transparent"]).optional()
|
|
29477
29487
|
});
|
|
29478
29488
|
function readHostIdentity(firecrackerBin, systemFiles, ipv6Prefix = null) {
|
|
29479
29489
|
return {
|
|
@@ -43128,7 +43138,7 @@ async function createImpdFirewall(config, deps, secretFiles, plan) {
|
|
|
43128
43138
|
}
|
|
43129
43139
|
|
|
43130
43140
|
// packages/daemon/src/impd/create-impd-imps.ts
|
|
43131
|
-
import { readFileSync as
|
|
43141
|
+
import { readFileSync as readFileSync36 } from "fs";
|
|
43132
43142
|
import { availableParallelism } from "os";
|
|
43133
43143
|
|
|
43134
43144
|
// packages/daemon/src/host-net/net/read-guest-net-bytes.ts
|
|
@@ -44560,7 +44570,7 @@ function createMarks() {
|
|
|
44560
44570
|
return { marks, setMark };
|
|
44561
44571
|
}
|
|
44562
44572
|
var BASE_BOOT_ARGS = [
|
|
44563
|
-
"console=ttyS0 reboot=k panic=1 pci=off",
|
|
44573
|
+
"console=ttyS0 quiet loglevel=5 reboot=k panic=1 pci=off",
|
|
44564
44574
|
"i8042.noaux i8042.nomux i8042.nopnp i8042.dumbkbd",
|
|
44565
44575
|
"root=/dev/vdb rootfstype=squashfs ro init=/imp-agent"
|
|
44566
44576
|
];
|
|
@@ -44745,7 +44755,7 @@ var TemplateMetaSchema = z86.object({
|
|
|
44745
44755
|
buildId: z86.string(),
|
|
44746
44756
|
vcpus: z86.int().positive(),
|
|
44747
44757
|
memoryMib: z86.int().positive(),
|
|
44748
|
-
hugePages: z86.enum(["None", "2M"]).default("None"),
|
|
44758
|
+
hugePages: z86.enum(["None", "2M", "Transparent"]).default("None"),
|
|
44749
44759
|
systemDrivePath: z86.string()
|
|
44750
44760
|
});
|
|
44751
44761
|
|
|
@@ -45157,31 +45167,56 @@ function splitRun(run) {
|
|
|
45157
45167
|
}
|
|
45158
45168
|
|
|
45159
45169
|
// packages/daemon/src/vm/vmm/create-memory-warm.ts
|
|
45170
|
+
import { existsSync as existsSync21 } from "fs";
|
|
45160
45171
|
import invariant12 from "tiny-invariant";
|
|
45161
45172
|
import { match as match23 } from "ts-pattern";
|
|
45162
45173
|
import * as z87 from "zod";
|
|
45163
45174
|
var BLOCK_MIB2 = 2;
|
|
45164
45175
|
var WARM_CONCURRENCY = 2;
|
|
45176
|
+
var WHOLE_MODES = { count: "--count-data", warm: "--warm" };
|
|
45177
|
+
var RECORDED_MODES = { count: "--count-blocks", warm: "--warm-blocks" };
|
|
45165
45178
|
var WarmReportSchema = z87.object({ blocks: z87.int().nonnegative() });
|
|
45166
45179
|
function createMemoryWarm(deps) {
|
|
45167
45180
|
const running = new Map;
|
|
45168
45181
|
const lifetime = { isStopped: false };
|
|
45169
45182
|
const slots = createSemaphore(WARM_CONCURRENCY);
|
|
45170
|
-
const readBlocks = async (mode,
|
|
45183
|
+
const readBlocks = async (mode, target, signal) => {
|
|
45171
45184
|
signal.throwIfAborted();
|
|
45172
|
-
const argv = [deps.handlerBin, mode, memFile];
|
|
45185
|
+
const argv = isBlockListMode(mode) ? [deps.handlerBin, mode, target.blockList, target.memFile] : [deps.handlerBin, mode, target.memFile];
|
|
45173
45186
|
const stdout = await runChecked(argv, { signal }, deps.run);
|
|
45174
45187
|
return WarmReportSchema.parse(JSON.parse(stdout)).blocks;
|
|
45175
45188
|
};
|
|
45176
|
-
const
|
|
45189
|
+
const countBlocks = async (target, signal) => {
|
|
45190
|
+
if (existsSync21(target.blockList)) {
|
|
45191
|
+
try {
|
|
45192
|
+
return {
|
|
45193
|
+
scope: "recorded",
|
|
45194
|
+
blocks: await readBlocks(RECORDED_MODES.count, target, signal)
|
|
45195
|
+
};
|
|
45196
|
+
} catch (error) {
|
|
45197
|
+
signal.throwIfAborted();
|
|
45198
|
+
getImpdLogger("imps").with({ imp: target.name }).warning("the recorded blocks of the memory file cannot be counted, so the whole file is: {error}", {
|
|
45199
|
+
error: getErrorMessage(error)
|
|
45200
|
+
});
|
|
45201
|
+
}
|
|
45202
|
+
}
|
|
45203
|
+
return { scope: "whole", blocks: await readBlocks(WHOLE_MODES.count, target, signal) };
|
|
45204
|
+
};
|
|
45205
|
+
const runWarm = async (target, signal) => {
|
|
45177
45206
|
const startedMs = performance.now();
|
|
45178
45207
|
try {
|
|
45179
|
-
const
|
|
45180
|
-
if (blocks * BLOCK_MIB2 > deps.capMib) {
|
|
45181
|
-
return { kind: "overCap", blocks };
|
|
45208
|
+
const counted = await countBlocks(target, signal);
|
|
45209
|
+
if (counted.blocks * BLOCK_MIB2 > deps.capMib) {
|
|
45210
|
+
return { kind: "overCap", scope: counted.scope, blocks: counted.blocks };
|
|
45182
45211
|
}
|
|
45183
|
-
const
|
|
45184
|
-
|
|
45212
|
+
const modes = counted.scope === "recorded" ? RECORDED_MODES : WHOLE_MODES;
|
|
45213
|
+
const read = await readBlocks(modes.warm, target, signal);
|
|
45214
|
+
return {
|
|
45215
|
+
kind: "warmed",
|
|
45216
|
+
scope: counted.scope,
|
|
45217
|
+
blocks: read,
|
|
45218
|
+
warmMs: Math.round(performance.now() - startedMs)
|
|
45219
|
+
};
|
|
45185
45220
|
} catch (error) {
|
|
45186
45221
|
return { kind: "failed", error: getErrorMessage(error) };
|
|
45187
45222
|
}
|
|
@@ -45216,7 +45251,7 @@ function createMemoryWarm(deps) {
|
|
|
45216
45251
|
return Promise.resolve(null);
|
|
45217
45252
|
}
|
|
45218
45253
|
state.phase = "running";
|
|
45219
|
-
return runWarm(target
|
|
45254
|
+
return runWarm(target, controller.signal);
|
|
45220
45255
|
};
|
|
45221
45256
|
const runAndLog = async () => {
|
|
45222
45257
|
const outcome = await slots.run(runInSlot);
|
|
@@ -45239,14 +45274,24 @@ function createMemoryWarm(deps) {
|
|
|
45239
45274
|
}
|
|
45240
45275
|
};
|
|
45241
45276
|
}
|
|
45277
|
+
function isBlockListMode(mode) {
|
|
45278
|
+
return mode === "--count-blocks" || mode === "--warm-blocks";
|
|
45279
|
+
}
|
|
45242
45280
|
function logWarm(target, outcome, capMib) {
|
|
45243
45281
|
const logger = getImpdLogger("imps").with({ imp: target.name });
|
|
45244
|
-
match23(outcome).with({ kind: "warmed" }, (warmed) => {
|
|
45245
|
-
logger.info("warmed the memory file in {warmMs}ms
|
|
45282
|
+
match23(outcome).with({ kind: "warmed", scope: "recorded" }, (warmed) => {
|
|
45283
|
+
logger.info("warmed {blocks} recorded blocks of the memory file in {warmMs}ms", {
|
|
45284
|
+
warmMs: String(warmed.warmMs),
|
|
45285
|
+
blocks: String(warmed.blocks)
|
|
45286
|
+
});
|
|
45287
|
+
}).with({ kind: "warmed", scope: "whole" }, (warmed) => {
|
|
45288
|
+
logger.info("warmed the whole memory file in {warmMs}ms: {blocks} blocks of 2 MiB", {
|
|
45246
45289
|
warmMs: String(warmed.warmMs),
|
|
45247
45290
|
blocks: String(warmed.blocks)
|
|
45248
45291
|
});
|
|
45249
|
-
}).with({ kind: "overCap" }, (over) => {
|
|
45292
|
+
}).with({ kind: "overCap", scope: "recorded" }, (over) => {
|
|
45293
|
+
logger.info("left the memory file cold: its {dataMib} MiB of recorded blocks pass the warm cap of {capMib} MiB", { dataMib: String(over.blocks * BLOCK_MIB2), capMib: String(capMib) });
|
|
45294
|
+
}).with({ kind: "overCap", scope: "whole" }, (over) => {
|
|
45250
45295
|
logger.info("left the memory file cold: its {dataMib} MiB of data pass the warm cap of {capMib} MiB", { dataMib: String(over.blocks * BLOCK_MIB2), capMib: String(capMib) });
|
|
45251
45296
|
}).with({ kind: "ended" }, (ended) => {
|
|
45252
45297
|
logger.info("stopped the memory file's warm after {warmMs}ms: {reason}", {
|
|
@@ -45474,12 +45519,12 @@ function buildLogKey(impId, generation) {
|
|
|
45474
45519
|
import { createActor as createActor3 } from "xstate";
|
|
45475
45520
|
|
|
45476
45521
|
// packages/daemon/src/imps/imps/session-logs/read-session-log-range.ts
|
|
45477
|
-
import { existsSync as
|
|
45522
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync20, readdirSync as readdirSync12, rmSync as rmSync23, rmdirSync as rmdirSync2 } from "fs";
|
|
45478
45523
|
import { open as open5 } from "fs/promises";
|
|
45479
45524
|
import { basename as basename5, dirname as dirname13, join as join36, resolve as resolve2 } from "path";
|
|
45480
45525
|
|
|
45481
45526
|
// packages/daemon/src/imps/imps/session-logs/generation-log.ts
|
|
45482
|
-
import { existsSync as
|
|
45527
|
+
import { existsSync as existsSync22, readFileSync as readFileSync32, readdirSync as readdirSync11, rmSync as rmSync22 } from "fs";
|
|
45483
45528
|
import { mkdir, open as open4, stat, truncate, unlink } from "fs/promises";
|
|
45484
45529
|
import { join as join35 } from "path";
|
|
45485
45530
|
import * as z88 from "zod";
|
|
@@ -45547,7 +45592,7 @@ function getSegmentPath(directory, start) {
|
|
|
45547
45592
|
}
|
|
45548
45593
|
function readGenerationMeta(directory) {
|
|
45549
45594
|
const path = join35(directory, META_FILE);
|
|
45550
|
-
if (!
|
|
45595
|
+
if (!existsSync22(path)) {
|
|
45551
45596
|
return null;
|
|
45552
45597
|
}
|
|
45553
45598
|
try {
|
|
@@ -45788,7 +45833,7 @@ function getGenerationDir(sessionLogsDir, generation) {
|
|
|
45788
45833
|
return directory;
|
|
45789
45834
|
}
|
|
45790
45835
|
function readImpMetas(sessionLogsDir, readLive) {
|
|
45791
|
-
if (!
|
|
45836
|
+
if (!existsSync23(sessionLogsDir)) {
|
|
45792
45837
|
return [];
|
|
45793
45838
|
}
|
|
45794
45839
|
return readdirSync12(sessionLogsDir).filter((entry) => isGenerationName(entry)).flatMap((generation) => {
|
|
@@ -45802,11 +45847,11 @@ function writeTombstone(sessionLogsDir, generation) {
|
|
|
45802
45847
|
writeFileDurably(path, "");
|
|
45803
45848
|
}
|
|
45804
45849
|
function probeTombstone(sessionLogsDir, generation) {
|
|
45805
|
-
return isGenerationName(generation) &&
|
|
45850
|
+
return isGenerationName(generation) && existsSync23(getTombstonePath(sessionLogsDir, generation));
|
|
45806
45851
|
}
|
|
45807
45852
|
function listTombstones(sessionLogsDir) {
|
|
45808
45853
|
const directory = join36(sessionLogsDir, TOMBSTONES);
|
|
45809
|
-
return
|
|
45854
|
+
return existsSync23(directory) ? readdirSync12(directory).filter((entry) => isGenerationName(entry)) : [];
|
|
45810
45855
|
}
|
|
45811
45856
|
function removeTombstone(sessionLogsDir, generation) {
|
|
45812
45857
|
rmSync23(getTombstonePath(sessionLogsDir, generation), { force: true });
|
|
@@ -46709,6 +46754,7 @@ function createImpContext(deps) {
|
|
|
46709
46754
|
readSleepRamMib: deps.config.ksm === null ? deps.readRamMib : deps.readUnsharedRamMib,
|
|
46710
46755
|
checkGuestMerge: deps.checkGuestMerge,
|
|
46711
46756
|
probeUffdDevice: deps.probeUffdDevice,
|
|
46757
|
+
probeTransparentHugePages: deps.probeTransparentHugePages,
|
|
46712
46758
|
mergeFlags: createMergeFlags(),
|
|
46713
46759
|
memoryLimit: deps.memoryLimit ?? NO_MEMORY_LIMIT,
|
|
46714
46760
|
priorityNames,
|
|
@@ -47166,10 +47212,12 @@ function removePartialFiles(paths) {
|
|
|
47166
47212
|
for (const path of [
|
|
47167
47213
|
paths.vmstate,
|
|
47168
47214
|
paths.memFile,
|
|
47215
|
+
paths.memTouched,
|
|
47169
47216
|
paths.snapshotMeta,
|
|
47170
47217
|
paths.vmIdentity,
|
|
47171
47218
|
slot.vmstate,
|
|
47172
47219
|
slot.memFile,
|
|
47220
|
+
slot.memTouched,
|
|
47173
47221
|
slot.snapshotMeta
|
|
47174
47222
|
]) {
|
|
47175
47223
|
rmSync24(`${path}.new`, { force: true });
|
|
@@ -47836,7 +47884,7 @@ function buildUffdDeviceError() {
|
|
|
47836
47884
|
}
|
|
47837
47885
|
|
|
47838
47886
|
// packages/daemon/src/imps/imps/make-sleep-imp-vm.ts
|
|
47839
|
-
import { statSync as
|
|
47887
|
+
import { statSync as statSync14 } from "fs";
|
|
47840
47888
|
|
|
47841
47889
|
// packages/daemon/src/vm/agent-client/send-services-list.ts
|
|
47842
47890
|
var STOP_TIMEOUT_MS = 15000;
|
|
@@ -47969,6 +48017,35 @@ async function waitForGuestAge(wait) {
|
|
|
47969
48017
|
return wanted ? Math.round(now() - started) : null;
|
|
47970
48018
|
}
|
|
47971
48019
|
|
|
48020
|
+
// packages/daemon/src/vm/vmm/keep-touched-blocks.ts
|
|
48021
|
+
import { copyFileSync as copyFileSync4, renameSync as renameSync7, rmSync as rmSync25, statSync as statSync13 } from "fs";
|
|
48022
|
+
function keepTouchedBlocks(paths) {
|
|
48023
|
+
dropTouchedBlocks(paths);
|
|
48024
|
+
if (!probeMarks(paths.uffdTouchedFile)) {
|
|
48025
|
+
return;
|
|
48026
|
+
}
|
|
48027
|
+
const staged = `${paths.memTouched}.new`;
|
|
48028
|
+
try {
|
|
48029
|
+
copyFileSync4(paths.uffdTouchedFile, staged);
|
|
48030
|
+
renameSync7(staged, paths.memTouched);
|
|
48031
|
+
} catch (error) {
|
|
48032
|
+
rmSync25(staged, { force: true });
|
|
48033
|
+
getImpdLogger("imps").with({ imp: paths.impId }).warning("kept no record of the blocks the wake served: {error}", {
|
|
48034
|
+
error: getErrorMessage(error)
|
|
48035
|
+
});
|
|
48036
|
+
}
|
|
48037
|
+
}
|
|
48038
|
+
function dropTouchedBlocks(paths) {
|
|
48039
|
+
rmSync25(paths.memTouched, { force: true });
|
|
48040
|
+
}
|
|
48041
|
+
function probeMarks(path) {
|
|
48042
|
+
try {
|
|
48043
|
+
return statSync13(path).size > 0;
|
|
48044
|
+
} catch {
|
|
48045
|
+
return false;
|
|
48046
|
+
}
|
|
48047
|
+
}
|
|
48048
|
+
|
|
47972
48049
|
// packages/daemon/src/imps/imps/format-timings.ts
|
|
47973
48050
|
function formatTimings(timings) {
|
|
47974
48051
|
return Object.entries(timings).map(([step, durationMs]) => `${step}=${String(durationMs)}ms`).join(" ");
|
|
@@ -48034,10 +48111,12 @@ function makeSleepImpVm(deps) {
|
|
|
48034
48111
|
isOnHugePages: false
|
|
48035
48112
|
};
|
|
48036
48113
|
removeSnapshotMeta(paths);
|
|
48114
|
+
dropTouchedBlocks(paths);
|
|
48037
48115
|
const hasOomKill = startOomWatch(context.cgroups, imp.id);
|
|
48038
48116
|
try {
|
|
48039
48117
|
const cgroup = context.cgroups.setup(imp.id, imp.cpu, imp.memoryMib);
|
|
48040
48118
|
const timings = await deps.withSleepSlot(() => context.vms.sleepVm(pid, paths, cgroup, paths));
|
|
48119
|
+
keepTouchedBlocks(paths);
|
|
48041
48120
|
const booted = readVmIdentity(paths);
|
|
48042
48121
|
slept.isOnHugePages = booted?.hugePages === "2M";
|
|
48043
48122
|
writeSnapshotMeta(paths, {
|
|
@@ -48100,7 +48179,12 @@ function makeSleepImpVm(deps) {
|
|
|
48100
48179
|
sleptAt: new Date
|
|
48101
48180
|
});
|
|
48102
48181
|
if (slept.isOnHugePages) {
|
|
48103
|
-
context.memoryWarm?.start({
|
|
48182
|
+
context.memoryWarm?.start({
|
|
48183
|
+
impID: imp.id,
|
|
48184
|
+
name: imp.name,
|
|
48185
|
+
memFile: paths.memFile,
|
|
48186
|
+
blockList: paths.memTouched
|
|
48187
|
+
});
|
|
48104
48188
|
}
|
|
48105
48189
|
return sleeping;
|
|
48106
48190
|
};
|
|
@@ -48136,7 +48220,7 @@ function setDetached(session) {
|
|
|
48136
48220
|
}
|
|
48137
48221
|
function readDiskMib(path) {
|
|
48138
48222
|
try {
|
|
48139
|
-
return Math.round(
|
|
48223
|
+
return Math.round(statSync14(path).blocks * 512 / 1048576);
|
|
48140
48224
|
} catch {
|
|
48141
48225
|
return 0;
|
|
48142
48226
|
}
|
|
@@ -48148,12 +48232,27 @@ function formatPageHandler(stats) {
|
|
|
48148
48232
|
}
|
|
48149
48233
|
|
|
48150
48234
|
// packages/daemon/src/imps/imps/pick-huge-pages.ts
|
|
48151
|
-
function pickHugePages(
|
|
48152
|
-
|
|
48235
|
+
function pickHugePages(settings, imp) {
|
|
48236
|
+
if (imp.memoryMib % 2 !== 0) {
|
|
48237
|
+
return "None";
|
|
48238
|
+
}
|
|
48239
|
+
if (imp.maxMemoryMib > imp.memoryMib) {
|
|
48240
|
+
return settings.isElasticTransparent && imp.maxMemoryMib % 2 === 0 ? "Transparent" : "None";
|
|
48241
|
+
}
|
|
48242
|
+
return settings.isOn ? "2M" : "None";
|
|
48243
|
+
}
|
|
48244
|
+
function readPageSettings(context) {
|
|
48245
|
+
return {
|
|
48246
|
+
isOn: context.config.hugePages !== null,
|
|
48247
|
+
isElasticTransparent: context.config.isElasticTransparentHugePages && context.probeTransparentHugePages()
|
|
48248
|
+
};
|
|
48153
48249
|
}
|
|
48154
48250
|
|
|
48155
48251
|
// packages/daemon/src/imps/imps/pick-wake-huge-pages.ts
|
|
48156
48252
|
function pickWakeHugePages(recorded, isOn) {
|
|
48253
|
+
if (recorded === "Transparent") {
|
|
48254
|
+
return "None";
|
|
48255
|
+
}
|
|
48157
48256
|
if (recorded !== "2M") {
|
|
48158
48257
|
return null;
|
|
48159
48258
|
}
|
|
@@ -48274,7 +48373,7 @@ function makeWakeImpVm(deps) {
|
|
|
48274
48373
|
return imp;
|
|
48275
48374
|
}
|
|
48276
48375
|
};
|
|
48277
|
-
const canBootOnPool = (imp) => pickHugePages(context.config.hugePages !== null, imp) === "2M";
|
|
48376
|
+
const canBootOnPool = (imp) => pickHugePages({ isOn: context.config.hugePages !== null, isElasticTransparent: false }, imp) === "2M";
|
|
48278
48377
|
const writeHostPagesIdentity = (imp, paths) => {
|
|
48279
48378
|
const booted = readVmIdentity(paths);
|
|
48280
48379
|
if (booted !== null) {
|
|
@@ -48340,11 +48439,11 @@ function logTrustFailure(imp, error) {
|
|
|
48340
48439
|
|
|
48341
48440
|
// packages/daemon/src/imps/imps/start-cold-vm.ts
|
|
48342
48441
|
import { randomBytes as randomBytes11 } from "crypto";
|
|
48343
|
-
import { statSync as
|
|
48442
|
+
import { statSync as statSync16 } from "fs";
|
|
48344
48443
|
import { resolve as resolve3 } from "path";
|
|
48345
48444
|
|
|
48346
48445
|
// packages/daemon/src/vm/vmm/create-template-vm.ts
|
|
48347
|
-
import { mkdirSync as mkdirSync22, rmSync as
|
|
48446
|
+
import { mkdirSync as mkdirSync22, rmSync as rmSync28 } from "fs";
|
|
48348
48447
|
|
|
48349
48448
|
// packages/daemon/src/vm/agent-client/wait-for-agent.ts
|
|
48350
48449
|
import { systemClock as systemClock4 } from "@zgeoff/std";
|
|
@@ -48378,14 +48477,14 @@ async function waitForAgent(vsockPath, options) {
|
|
|
48378
48477
|
import {
|
|
48379
48478
|
chmodSync as chmodSync7,
|
|
48380
48479
|
closeSync as closeSync9,
|
|
48381
|
-
existsSync as
|
|
48480
|
+
existsSync as existsSync24,
|
|
48382
48481
|
lchownSync as lchownSync2,
|
|
48383
48482
|
lstatSync as lstatSync3,
|
|
48384
48483
|
mkdirSync as mkdirSync21,
|
|
48385
48484
|
openSync as openSync7,
|
|
48386
48485
|
readdirSync as readdirSync13,
|
|
48387
|
-
rmSync as
|
|
48388
|
-
statSync as
|
|
48486
|
+
rmSync as rmSync26,
|
|
48487
|
+
statSync as statSync15,
|
|
48389
48488
|
truncateSync as truncateSync3
|
|
48390
48489
|
} from "fs";
|
|
48391
48490
|
import { basename as basename6, dirname as dirname14, join as join37 } from "path";
|
|
@@ -48444,7 +48543,7 @@ function createJails(deps) {
|
|
|
48444
48543
|
const remove = async (impId) => {
|
|
48445
48544
|
await removeMounts(impId);
|
|
48446
48545
|
if (listMountsUnder(readMounts2(), getRoot(impId)).length === 0) {
|
|
48447
|
-
|
|
48546
|
+
rmSync26(getJailDir(impId), { recursive: true, force: true });
|
|
48448
48547
|
}
|
|
48449
48548
|
};
|
|
48450
48549
|
const setupDirBind = async (source, target) => {
|
|
@@ -48465,7 +48564,7 @@ function createJails(deps) {
|
|
|
48465
48564
|
throw new Error(`jail ${chroot.id}: ${root} still has mounts`);
|
|
48466
48565
|
}
|
|
48467
48566
|
chroot.setupFiles();
|
|
48468
|
-
|
|
48567
|
+
rmSync26(getJailDir(chroot.id), { recursive: true, force: true });
|
|
48469
48568
|
mkdirSync21(root, { recursive: true });
|
|
48470
48569
|
await runMount(["mount", "--bind", root, root]);
|
|
48471
48570
|
await runMount(["mount", "--make-private", root]);
|
|
@@ -48527,7 +48626,7 @@ function createJails(deps) {
|
|
|
48527
48626
|
remove,
|
|
48528
48627
|
removeOrphans: async (impIds) => {
|
|
48529
48628
|
const base = join37(deps.chrootBase, execName);
|
|
48530
|
-
const ids =
|
|
48629
|
+
const ids = existsSync24(base) ? readdirSync13(base) : [];
|
|
48531
48630
|
const orphans = ids.filter((impId) => !impIds.has(impId));
|
|
48532
48631
|
const removed = [];
|
|
48533
48632
|
for (const impId of orphans) {
|
|
@@ -48553,7 +48652,7 @@ function createJails(deps) {
|
|
|
48553
48652
|
`);
|
|
48554
48653
|
},
|
|
48555
48654
|
removeUffdDevice: (id) => {
|
|
48556
|
-
|
|
48655
|
+
rmSync26(join37(getRoot(id), "dev", "userfaultfd"), { force: true });
|
|
48557
48656
|
}
|
|
48558
48657
|
};
|
|
48559
48658
|
}
|
|
@@ -48576,7 +48675,7 @@ function readOwnerUid(path) {
|
|
|
48576
48675
|
function setupScratchFile(source, target, user) {
|
|
48577
48676
|
mkdirSync21(dirname14(target), { recursive: true });
|
|
48578
48677
|
closeSync9(openSync7(target, "wx", 384));
|
|
48579
|
-
truncateSync3(target,
|
|
48678
|
+
truncateSync3(target, statSync15(source).size);
|
|
48580
48679
|
lchownSync2(target, user.uid, user.gid);
|
|
48581
48680
|
}
|
|
48582
48681
|
function buildJailerCommand(command) {
|
|
@@ -48609,7 +48708,7 @@ function setupOwnership(paths, user, isDiskLate) {
|
|
|
48609
48708
|
lchownSync2(paths.runDir, user.uid, user.gid);
|
|
48610
48709
|
setupImpdDir(paths.snapshotDir);
|
|
48611
48710
|
for (const file of [paths.vmstate, paths.memFile]) {
|
|
48612
|
-
if (
|
|
48711
|
+
if (existsSync24(file)) {
|
|
48613
48712
|
requireRegularFile(file);
|
|
48614
48713
|
}
|
|
48615
48714
|
}
|
|
@@ -48618,7 +48717,7 @@ function setupOwnership(paths, user, isDiskLate) {
|
|
|
48618
48717
|
lchownSync2(paths.disk, user.uid, user.gid);
|
|
48619
48718
|
}
|
|
48620
48719
|
for (const file of [paths.vmstate, paths.memFile]) {
|
|
48621
|
-
if (
|
|
48720
|
+
if (existsSync24(file)) {
|
|
48622
48721
|
setupSnapshotFile(file, user.gid);
|
|
48623
48722
|
}
|
|
48624
48723
|
}
|
|
@@ -48628,7 +48727,7 @@ function setupImpdRunDir(paths) {
|
|
|
48628
48727
|
for (const name of readdirSync13(paths.runDir)) {
|
|
48629
48728
|
const path = join37(paths.runDir, name);
|
|
48630
48729
|
if (!probeSealedEntry(paths, path)) {
|
|
48631
|
-
|
|
48730
|
+
rmSync26(path, { recursive: true, force: true });
|
|
48632
48731
|
}
|
|
48633
48732
|
}
|
|
48634
48733
|
}
|
|
@@ -48652,7 +48751,7 @@ function setupSnapshotFile(file, gid) {
|
|
|
48652
48751
|
function setupRealDir(directory) {
|
|
48653
48752
|
const found = lstatSync3(directory, { throwIfNoEntry: false });
|
|
48654
48753
|
if (found !== undefined && !found.isDirectory()) {
|
|
48655
|
-
|
|
48754
|
+
rmSync26(directory, { force: true });
|
|
48656
48755
|
}
|
|
48657
48756
|
mkdirSync21(directory, { recursive: true });
|
|
48658
48757
|
}
|
|
@@ -48661,10 +48760,11 @@ function probeSealedEntry(paths, path) {
|
|
|
48661
48760
|
const uffdSocket = join37(paths.runDir, UFFD_RUN_FILES.socket);
|
|
48662
48761
|
const uffdPidFile = join37(paths.runDir, UFFD_RUN_FILES.pidFile);
|
|
48663
48762
|
const uffdStatsFile = join37(paths.runDir, UFFD_RUN_FILES.statsFile);
|
|
48763
|
+
const uffdTouchedFile = join37(paths.runDir, UFFD_RUN_FILES.touchedFile);
|
|
48664
48764
|
if (path === paths.apiSocket || path === paths.vsockSocket || path === uffdSocket) {
|
|
48665
48765
|
return entry.isSocket();
|
|
48666
48766
|
}
|
|
48667
|
-
return (path === paths.logFile || path === paths.pidFile || path === uffdPidFile || path === uffdStatsFile) && entry.isFile() && entry.uid === IMPD_USER.uid && entry.nlink === 1;
|
|
48767
|
+
return (path === paths.logFile || path === paths.pidFile || path === uffdPidFile || path === uffdStatsFile || path === uffdTouchedFile) && entry.isFile() && entry.uid === IMPD_USER.uid && entry.nlink === 1;
|
|
48668
48768
|
}
|
|
48669
48769
|
function requireRegularFile(file) {
|
|
48670
48770
|
if (!lstatSync3(file).isFile()) {
|
|
@@ -48740,16 +48840,21 @@ function createFirecrackerClient(socketPath, timeouts = DEFAULT_TIMEOUTS) {
|
|
|
48740
48840
|
kernel_image_path: source.kernelImagePath,
|
|
48741
48841
|
boot_args: source.bootArgs
|
|
48742
48842
|
}),
|
|
48743
|
-
putMachineConfig: (config) =>
|
|
48744
|
-
|
|
48745
|
-
|
|
48746
|
-
|
|
48747
|
-
|
|
48843
|
+
putMachineConfig: async (config) => {
|
|
48844
|
+
if (config.hugePages !== "None" && config.memSizeMib % 2 !== 0) {
|
|
48845
|
+
throw new Error(`${config.hugePages} huge pages need a whole number of 2 MiB pages, and ${String(config.memSizeMib)} MiB is not`);
|
|
48846
|
+
}
|
|
48847
|
+
await sendPut("/machine-config", {
|
|
48848
|
+
vcpu_count: config.vcpuCount,
|
|
48849
|
+
mem_size_mib: config.memSizeMib,
|
|
48850
|
+
...config.hugePages !== "None" && { huge_pages: config.hugePages }
|
|
48851
|
+
});
|
|
48852
|
+
},
|
|
48748
48853
|
loadMachineConfig: async () => {
|
|
48749
48854
|
const parsed = await readAnswer("/machine-config", MachineConfigSchema);
|
|
48750
48855
|
return {
|
|
48751
48856
|
isTrackingDirtyPages: parsed.track_dirty_pages === true,
|
|
48752
|
-
hugePages: parsed.huge_pages
|
|
48857
|
+
hugePages: readHugePages(parsed.huge_pages)
|
|
48753
48858
|
};
|
|
48754
48859
|
},
|
|
48755
48860
|
putDrive: (drive) => sendPut(`/drives/${drive.driveId}`, {
|
|
@@ -48831,12 +48936,15 @@ function createFirecrackerClient(socketPath, timeouts = DEFAULT_TIMEOUTS) {
|
|
|
48831
48936
|
}
|
|
48832
48937
|
};
|
|
48833
48938
|
}
|
|
48939
|
+
function readHugePages(reported) {
|
|
48940
|
+
return reported === "2M" || reported === "Transparent" ? reported : "None";
|
|
48941
|
+
}
|
|
48834
48942
|
function toMib(bytes) {
|
|
48835
48943
|
return Math.floor(bytes / 1048576);
|
|
48836
48944
|
}
|
|
48837
48945
|
|
|
48838
48946
|
// packages/daemon/src/vm/vmm/start-uffd-handler.ts
|
|
48839
|
-
import { closeSync as closeSync10, existsSync as
|
|
48947
|
+
import { closeSync as closeSync10, existsSync as existsSync25, openSync as openSync8, rmSync as rmSync27 } from "fs";
|
|
48840
48948
|
|
|
48841
48949
|
// packages/daemon/src/vm/vmm/uffd-stats-layout.ts
|
|
48842
48950
|
var UFFD_STATS_LAYOUT = {
|
|
@@ -48860,18 +48968,20 @@ async function startUffdHandler(plan) {
|
|
|
48860
48968
|
];
|
|
48861
48969
|
const memFd = openSync8(plan.memFile, "r");
|
|
48862
48970
|
const statsFd = createZeroedFile(paths.uffdStatsFile, UFFD_STATS_BYTES);
|
|
48971
|
+
const touchedFd = createZeroedFile(paths.uffdTouchedFile, 0);
|
|
48863
48972
|
const log = setupLogFile(paths.logFile);
|
|
48864
48973
|
const child = Bun.spawn(buildSpawnArgv(command, plan.cgroup?.procsPath ?? null, null), {
|
|
48865
|
-
stdio: ["ignore", log, log, memFd, statsFd]
|
|
48974
|
+
stdio: ["ignore", log, log, memFd, statsFd, touchedFd]
|
|
48866
48975
|
});
|
|
48867
48976
|
closeSync10(memFd);
|
|
48868
48977
|
closeSync10(statsFd);
|
|
48978
|
+
closeSync10(touchedFd);
|
|
48869
48979
|
closeSync10(log);
|
|
48870
48980
|
child.unref();
|
|
48871
48981
|
writeRegularFile(paths.uffdPidFile, `${String(child.pid)}
|
|
48872
48982
|
`);
|
|
48873
48983
|
const deadline = Date.now() + SOCKET_WAIT_MS2;
|
|
48874
|
-
while (!
|
|
48984
|
+
while (!existsSync25(paths.uffdSocket)) {
|
|
48875
48985
|
if (child.exitCode !== null || Date.now() > deadline) {
|
|
48876
48986
|
stopPid(child.pid);
|
|
48877
48987
|
throw new Error(`the page handler did not open its socket (exit ${String(child.exitCode)}): ${readLogTail(paths.logFile, 5)}`);
|
|
@@ -48881,10 +48991,11 @@ async function startUffdHandler(plan) {
|
|
|
48881
48991
|
return child.pid;
|
|
48882
48992
|
}
|
|
48883
48993
|
function removeUffdFiles(paths) {
|
|
48884
|
-
|
|
48885
|
-
|
|
48886
|
-
|
|
48887
|
-
|
|
48994
|
+
rmSync27(paths.uffdSocket, { force: true });
|
|
48995
|
+
rmSync27(`${paths.uffdSocket}.new`, { force: true });
|
|
48996
|
+
rmSync27(paths.uffdPidFile, { force: true });
|
|
48997
|
+
rmSync27(paths.uffdStatsFile, { force: true });
|
|
48998
|
+
rmSync27(paths.uffdTouchedFile, { force: true });
|
|
48888
48999
|
}
|
|
48889
49000
|
function readUffdStats(paths, readFile) {
|
|
48890
49001
|
const raw = readFile(paths.uffdStatsFile);
|
|
@@ -48895,7 +49006,7 @@ function readUffdStats(paths, readFile) {
|
|
|
48895
49006
|
};
|
|
48896
49007
|
}
|
|
48897
49008
|
function readHandlerState(paths, procRoot = "/proc") {
|
|
48898
|
-
if (!
|
|
49009
|
+
if (!existsSync25(paths.uffdPidFile)) {
|
|
48899
49010
|
return { state: "none" };
|
|
48900
49011
|
}
|
|
48901
49012
|
const pid = readPidFile(paths.uffdPidFile);
|
|
@@ -48930,7 +49041,7 @@ async function createTemplateVm(plan, jails, options = {}) {
|
|
|
48930
49041
|
setupTemplateFile(plan.memFile);
|
|
48931
49042
|
writeToDisk([plan.vmstate, plan.memFile, plan.snapshotDir]);
|
|
48932
49043
|
} catch (error) {
|
|
48933
|
-
|
|
49044
|
+
rmSync28(plan.snapshotDir, { recursive: true, force: true });
|
|
48934
49045
|
throw new Error(`template build failed: ${getErrorMessage(error)}
|
|
48935
49046
|
${readLogTail(plan.paths.logFile)}`, { cause: error });
|
|
48936
49047
|
}
|
|
@@ -49110,13 +49221,24 @@ var STALL_FIGURES = [
|
|
|
49110
49221
|
["memory", "memoryStallUs"],
|
|
49111
49222
|
["steal", "stealUs"]
|
|
49112
49223
|
];
|
|
49224
|
+
var HUGE_PAGE_FIGURES = [
|
|
49225
|
+
["thp_fault_alloc", "thpFaultAlloc"],
|
|
49226
|
+
["thp_fault_fallback", "thpFaultFallback"],
|
|
49227
|
+
["compact_stall", "compactStall"]
|
|
49228
|
+
];
|
|
49113
49229
|
function formatHostStall(before, after) {
|
|
49114
|
-
const
|
|
49230
|
+
const stalls = STALL_FIGURES.flatMap(([name, field]) => {
|
|
49115
49231
|
const startUs = before[field];
|
|
49116
49232
|
const endUs = after[field];
|
|
49117
49233
|
return startUs === null || endUs === null ? [] : [`${name}=${String(Math.round((endUs - startUs) / 1000))}ms`];
|
|
49118
49234
|
});
|
|
49119
|
-
|
|
49235
|
+
const hugePages = HUGE_PAGE_FIGURES.flatMap(([name, field]) => {
|
|
49236
|
+
const start = before[field];
|
|
49237
|
+
const end = after[field];
|
|
49238
|
+
return start === null || end === null ? [] : [`${name}=${String(end - start)}`];
|
|
49239
|
+
});
|
|
49240
|
+
const sections = [...stalls.length === 0 ? [] : [`stall ${stalls.join(" ")}`], ...hugePages];
|
|
49241
|
+
return sections.length === 0 ? "" : `; host ${sections.join(" ")}`;
|
|
49120
49242
|
}
|
|
49121
49243
|
|
|
49122
49244
|
// packages/daemon/src/imps/imps/start-cold-vm.ts
|
|
@@ -49140,7 +49262,7 @@ async function startColdVm(context, start) {
|
|
|
49140
49262
|
disk.isFailed = true;
|
|
49141
49263
|
throw error;
|
|
49142
49264
|
}
|
|
49143
|
-
return
|
|
49265
|
+
return statSync16(paths.disk).size;
|
|
49144
49266
|
};
|
|
49145
49267
|
const diskBytes = readDiskBytes();
|
|
49146
49268
|
Promise.allSettled([diskBytes]);
|
|
@@ -49285,7 +49407,7 @@ function createImpVmOps(host) {
|
|
|
49285
49407
|
const paths = context.findPaths(imp.id);
|
|
49286
49408
|
const address = context.findAddress(imp.slot);
|
|
49287
49409
|
const admitStarted = performance.now();
|
|
49288
|
-
const hugePages = pickHugePages(context
|
|
49410
|
+
const hugePages = pickHugePages(readPageSettings(context), imp);
|
|
49289
49411
|
if (hugePages === "2M" && !context.probeUffdDevice()) {
|
|
49290
49412
|
throw buildUffdDeviceError();
|
|
49291
49413
|
}
|
|
@@ -49324,7 +49446,7 @@ function createImpVmOps(host) {
|
|
|
49324
49446
|
...context.identity,
|
|
49325
49447
|
agentVersion: vm.agentVersion,
|
|
49326
49448
|
bootReason: reason,
|
|
49327
|
-
...vm.hugePages
|
|
49449
|
+
...vm.hugePages !== "None" && { hugePages: vm.hugePages }
|
|
49328
49450
|
});
|
|
49329
49451
|
await updateImpActivity(context.db, imp.id, new Date);
|
|
49330
49452
|
await (vm.bootId === undefined ? removeNextBootCause(context.db, imp.id) : writeColdBoot(context.db, imp.id, { bootId: vm.bootId, cause, at: new Date }));
|
|
@@ -50032,7 +50154,8 @@ function readHostLoad(sources) {
|
|
|
50032
50154
|
cpuStallUs: parsePressureTotal(readProc("pressure", "cpu")),
|
|
50033
50155
|
ioStallUs: parsePressureTotal(readProc("pressure", "io")),
|
|
50034
50156
|
memoryStallUs: parsePressureTotal(readProc("pressure", "memory")),
|
|
50035
|
-
stealUs: parseStealUs(readProc("stat"))
|
|
50157
|
+
stealUs: parseStealUs(readProc("stat")),
|
|
50158
|
+
...buildVmstatCounters(readProc("vmstat"))
|
|
50036
50159
|
};
|
|
50037
50160
|
}
|
|
50038
50161
|
function readProcFile(sources, path) {
|
|
@@ -50058,6 +50181,17 @@ function parseStealUs(stat) {
|
|
|
50058
50181
|
const steal = fields?.[STEAL_FIELD];
|
|
50059
50182
|
return steal === undefined ? null : Number(steal) * US_PER_TICK;
|
|
50060
50183
|
}
|
|
50184
|
+
function buildVmstatCounters(vmstat) {
|
|
50185
|
+
const findCounter = (name) => {
|
|
50186
|
+
const found = vmstat === null ? null : new RegExp(`^${name} (?<count>\\d+)$`, "mv").exec(vmstat);
|
|
50187
|
+
return found?.groups?.["count"] === undefined ? null : Number(found.groups["count"]);
|
|
50188
|
+
};
|
|
50189
|
+
return {
|
|
50190
|
+
thpFaultAlloc: findCounter("thp_fault_alloc"),
|
|
50191
|
+
thpFaultFallback: findCounter("thp_fault_fallback"),
|
|
50192
|
+
compactStall: findCounter("compact_stall")
|
|
50193
|
+
};
|
|
50194
|
+
}
|
|
50061
50195
|
|
|
50062
50196
|
// packages/daemon/src/platform/process/read-text.ts
|
|
50063
50197
|
import { readFileSync as readFileSync33 } from "fs";
|
|
@@ -50439,7 +50573,7 @@ function createMemoryController(deps) {
|
|
|
50439
50573
|
|
|
50440
50574
|
// packages/daemon/src/vm/vmm/cpu-cgroups.ts
|
|
50441
50575
|
import {
|
|
50442
|
-
existsSync as
|
|
50576
|
+
existsSync as existsSync26,
|
|
50443
50577
|
mkdirSync as mkdirSync23,
|
|
50444
50578
|
readFileSync as readFileSync34,
|
|
50445
50579
|
readdirSync as readdirSync14,
|
|
@@ -50547,7 +50681,7 @@ function createCpuCgroups(options) {
|
|
|
50547
50681
|
isMemoryEnforced,
|
|
50548
50682
|
setup,
|
|
50549
50683
|
apply: (impId, cpu) => {
|
|
50550
|
-
if (isEnforced &&
|
|
50684
|
+
if (isEnforced && existsSync26(getDir(impId))) {
|
|
50551
50685
|
tryWrite(impId, "apply the limit", () => {
|
|
50552
50686
|
writeSettings(impId, cpu, cpu.limit);
|
|
50553
50687
|
});
|
|
@@ -50570,7 +50704,7 @@ function createCpuCgroups(options) {
|
|
|
50570
50704
|
},
|
|
50571
50705
|
setGuestMib: (impId, guestMib) => {
|
|
50572
50706
|
guestMibs.set(impId, guestMib);
|
|
50573
|
-
if (isMemoryEnforced &&
|
|
50707
|
+
if (isMemoryEnforced && existsSync26(getDir(impId))) {
|
|
50574
50708
|
tryWrite(impId, "set the memory limit", () => {
|
|
50575
50709
|
writeMemory(impId);
|
|
50576
50710
|
});
|
|
@@ -50582,7 +50716,7 @@ function createCpuCgroups(options) {
|
|
|
50582
50716
|
if (!isEnforced) {
|
|
50583
50717
|
return;
|
|
50584
50718
|
}
|
|
50585
|
-
for (let attempt = 1;
|
|
50719
|
+
for (let attempt = 1;existsSync26(getDir(impId)); attempt += 1) {
|
|
50586
50720
|
try {
|
|
50587
50721
|
rmdir(getDir(impId));
|
|
50588
50722
|
return;
|
|
@@ -50611,7 +50745,7 @@ function createCpuCgroups(options) {
|
|
|
50611
50745
|
return orphans;
|
|
50612
50746
|
},
|
|
50613
50747
|
kill: (impId) => {
|
|
50614
|
-
if (isEnforced &&
|
|
50748
|
+
if (isEnforced && existsSync26(getDir(impId))) {
|
|
50615
50749
|
tryWrite(impId, "kill", () => {
|
|
50616
50750
|
writeFileSync13(join39(getDir(impId), "cgroup.kill"), "1");
|
|
50617
50751
|
});
|
|
@@ -50655,6 +50789,16 @@ function tryWrite(impId, what, write) {
|
|
|
50655
50789
|
}
|
|
50656
50790
|
}
|
|
50657
50791
|
|
|
50792
|
+
// packages/daemon/src/vm/vmm/probe-transparent-huge-pages.ts
|
|
50793
|
+
import { readFileSync as readFileSync35 } from "fs";
|
|
50794
|
+
function probeTransparentHugePages(path = "/sys/kernel/mm/transparent_hugepage/enabled") {
|
|
50795
|
+
try {
|
|
50796
|
+
return !readFileSync35(path, "utf8").includes("[never]");
|
|
50797
|
+
} catch {
|
|
50798
|
+
return false;
|
|
50799
|
+
}
|
|
50800
|
+
}
|
|
50801
|
+
|
|
50658
50802
|
// packages/daemon/src/vm/vmm/probe-uffd-device.ts
|
|
50659
50803
|
import { accessSync, constants as constants5 } from "fs";
|
|
50660
50804
|
function probeUffdDevice(path = "/dev/userfaultfd") {
|
|
@@ -50667,7 +50811,7 @@ function probeUffdDevice(path = "/dev/userfaultfd") {
|
|
|
50667
50811
|
}
|
|
50668
50812
|
|
|
50669
50813
|
// packages/daemon/src/vm/vmm/vm-runner.ts
|
|
50670
|
-
import { lstatSync as lstatSync4, mkdirSync as mkdirSync24, renameSync as
|
|
50814
|
+
import { lstatSync as lstatSync4, mkdirSync as mkdirSync24, renameSync as renameSync8, rmSync as rmSync29 } from "fs";
|
|
50671
50815
|
import { systemClock as systemClock5 } from "@zgeoff/std";
|
|
50672
50816
|
|
|
50673
50817
|
// packages/daemon/src/vm/vmm/build-boot-args.ts
|
|
@@ -50899,9 +51043,9 @@ ${readLogTail(plan.paths.logFile)}`, {
|
|
|
50899
51043
|
setMark("pause");
|
|
50900
51044
|
await api.createSnapshot(files, type);
|
|
50901
51045
|
} catch (error) {
|
|
50902
|
-
|
|
50903
|
-
|
|
50904
|
-
|
|
51046
|
+
rmSync29(files.snapshotPath, { force: true });
|
|
51047
|
+
rmSync29(files.memFilePath, { force: true });
|
|
51048
|
+
rmSync29(paths.memFile, { force: true });
|
|
50905
51049
|
try {
|
|
50906
51050
|
await api.resume();
|
|
50907
51051
|
cgroup?.applyLimit();
|
|
@@ -50918,10 +51062,10 @@ ${readLogTail(plan.paths.logFile)}`, {
|
|
|
50918
51062
|
for (const file of [files.snapshotPath, files.memFilePath]) {
|
|
50919
51063
|
setupSnapshotFile(file, owner.gid);
|
|
50920
51064
|
}
|
|
50921
|
-
|
|
50922
|
-
|
|
50923
|
-
|
|
50924
|
-
|
|
51065
|
+
renameSync8(files.snapshotPath, target.vmstate);
|
|
51066
|
+
renameSync8(files.memFilePath, target.memFile);
|
|
51067
|
+
rmSync29(paths.apiSocket, { force: true });
|
|
51068
|
+
rmSync29(paths.vsockSocket, { force: true });
|
|
50925
51069
|
const dug = await runCommand(["fallocate", "--dig-holes", target.memFile]);
|
|
50926
51070
|
const digStep = dug.exitCode === 0 ? "digHoles" : "digHolesFailed";
|
|
50927
51071
|
setMark(digStep);
|
|
@@ -51081,7 +51225,7 @@ function createImpdImps(config, deps, parts) {
|
|
|
51081
51225
|
}), {
|
|
51082
51226
|
mergeWrapper: config.ksm?.execBin ?? null,
|
|
51083
51227
|
uffdHandlerBin: config.hugePages?.handlerBin ?? null,
|
|
51084
|
-
readFile:
|
|
51228
|
+
readFile: readFileSync36
|
|
51085
51229
|
});
|
|
51086
51230
|
const {
|
|
51087
51231
|
readVmRam,
|
|
@@ -51231,6 +51375,7 @@ function resolveImpBoundaries(boundaries) {
|
|
|
51231
51375
|
readUnsharedRamMib: boundaries.readUnsharedRamMib ?? readUnsharedRamMib,
|
|
51232
51376
|
checkGuestMerge: boundaries.checkGuestMerge ?? checkGuestMemoryMergeable,
|
|
51233
51377
|
probeUffdDevice: boundaries.probeUffdDevice ?? (() => probeUffdDevice()),
|
|
51378
|
+
probeTransparentHugePages: boundaries.probeTransparentHugePages ?? (() => probeTransparentHugePages()),
|
|
51234
51379
|
readKsmProfitMib: boundaries.readKsmProfitMib ?? readKsmProfitMib,
|
|
51235
51380
|
readHugePagePool: boundaries.readHugePagePool ?? (() => readHugePagePool()),
|
|
51236
51381
|
readHugetlbMib: boundaries.readHugetlbMib ?? ((pid, apiSocket) => readHugetlbMibAsync(pid, apiSocket)),
|
|
@@ -51258,7 +51403,7 @@ function makeStandInVmRam(readRam) {
|
|
|
51258
51403
|
}
|
|
51259
51404
|
|
|
51260
51405
|
// packages/daemon/src/imp-ops/moves/move-receiver.ts
|
|
51261
|
-
import { existsSync as
|
|
51406
|
+
import { existsSync as existsSync28, rmSync as rmSync31 } from "fs";
|
|
51262
51407
|
import { join as join41 } from "path";
|
|
51263
51408
|
|
|
51264
51409
|
// packages/daemon/src/platform/db/probe-slot-free.ts
|
|
@@ -51583,7 +51728,7 @@ class MoveRequestError extends ImpdError {
|
|
|
51583
51728
|
}
|
|
51584
51729
|
|
|
51585
51730
|
// packages/daemon/src/imp-ops/moves/read-move-stream.ts
|
|
51586
|
-
import { mkdirSync as mkdirSync26, rmSync as
|
|
51731
|
+
import { mkdirSync as mkdirSync26, rmSync as rmSync30 } from "fs";
|
|
51587
51732
|
import { open as open7 } from "fs/promises";
|
|
51588
51733
|
import { join as join40 } from "path";
|
|
51589
51734
|
import invariant13 from "tiny-invariant";
|
|
@@ -51599,7 +51744,7 @@ config ${configContentSha256}
|
|
|
51599
51744
|
|
|
51600
51745
|
// packages/daemon/src/imp-ops/moves/check-warm-move.ts
|
|
51601
51746
|
import { createHash as createHash7 } from "crypto";
|
|
51602
|
-
import { existsSync as
|
|
51747
|
+
import { existsSync as existsSync27, mkdirSync as mkdirSync25, renameSync as renameSync9 } from "fs";
|
|
51603
51748
|
import { dirname as dirname15 } from "path";
|
|
51604
51749
|
|
|
51605
51750
|
// packages/daemon/src/imp-ops/moves/read-warm-host.ts
|
|
@@ -51766,9 +51911,9 @@ async function writeSystemDrive(deps, temp, meta) {
|
|
|
51766
51911
|
if (!isSameHash(sha256, meta.systemDrive)) {
|
|
51767
51912
|
throw new MoveRequestError("BAD_REQUEST", "the system drive does not match its sha256");
|
|
51768
51913
|
}
|
|
51769
|
-
if (!
|
|
51914
|
+
if (!existsSync27(path)) {
|
|
51770
51915
|
mkdirSync25(dirname15(path), { recursive: true });
|
|
51771
|
-
|
|
51916
|
+
renameSync9(temp, path);
|
|
51772
51917
|
}
|
|
51773
51918
|
}
|
|
51774
51919
|
async function readFileSha256(path) {
|
|
@@ -52294,7 +52439,7 @@ async function readMoveStream(deps, options) {
|
|
|
52294
52439
|
await removeStagedImp(deps, header.imp.name, header.imp.id);
|
|
52295
52440
|
throw error;
|
|
52296
52441
|
} finally {
|
|
52297
|
-
|
|
52442
|
+
rmSync30(temp, { force: true });
|
|
52298
52443
|
}
|
|
52299
52444
|
await createGrants(deps, header);
|
|
52300
52445
|
const receipt = buildReceipt({ ticketId: row.id, name: header.imp.name, impId: header.imp.id, files }, options.secret);
|
|
@@ -52395,8 +52540,8 @@ async function requireImage(deps, options) {
|
|
|
52395
52540
|
}));
|
|
52396
52541
|
return { name, files };
|
|
52397
52542
|
} finally {
|
|
52398
|
-
|
|
52399
|
-
|
|
52543
|
+
rmSync30(temps.rootfs, { force: true });
|
|
52544
|
+
rmSync30(temps.config, { force: true });
|
|
52400
52545
|
}
|
|
52401
52546
|
}
|
|
52402
52547
|
async function createGrants(deps, header) {
|
|
@@ -52453,7 +52598,7 @@ function createMoveReceiver(deps) {
|
|
|
52453
52598
|
const offer = async (offered) => {
|
|
52454
52599
|
const digests = buildOfferedDigests(offered.imageDigest, offered.receivedImageDigest);
|
|
52455
52600
|
const existing = await readImageInUse(deps.db, digests, deps.now());
|
|
52456
|
-
const needsSystemDrive = offered.systemDrive !== undefined && !
|
|
52601
|
+
const needsSystemDrive = offered.systemDrive !== undefined && !existsSync28(buildSystemDrivePath(deps.dataDir, offered.systemDrive));
|
|
52457
52602
|
return {
|
|
52458
52603
|
needsImage: existing === undefined,
|
|
52459
52604
|
needsSystemDrive,
|
|
@@ -52655,7 +52800,7 @@ function createMoveReceiver(deps) {
|
|
|
52655
52800
|
await removeStagedImp(deps, imp.name, imp.id);
|
|
52656
52801
|
}
|
|
52657
52802
|
}
|
|
52658
|
-
|
|
52803
|
+
rmSync31(tempDir, { recursive: true, force: true });
|
|
52659
52804
|
}
|
|
52660
52805
|
};
|
|
52661
52806
|
}
|
|
@@ -53629,7 +53774,7 @@ function createImpdMoves(config, deps, parts, hooks) {
|
|
|
53629
53774
|
}
|
|
53630
53775
|
|
|
53631
53776
|
// packages/daemon/src/imps/images/template-service.ts
|
|
53632
|
-
import { copyFileSync as
|
|
53777
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync29, statSync as statSync17, writeFileSync as writeFileSync14 } from "fs";
|
|
53633
53778
|
import { join as join42 } from "path";
|
|
53634
53779
|
import { systemClock as systemClock7 } from "@zgeoff/std";
|
|
53635
53780
|
|
|
@@ -53687,8 +53832,8 @@ function createTemplateService(deps) {
|
|
|
53687
53832
|
const image = await readImageById(deps.db, imageId);
|
|
53688
53833
|
const target = join42(directory, "config.json");
|
|
53689
53834
|
const config = image === undefined ? undefined : buildImagePaths(deps.config.dataDir, image.digest).config;
|
|
53690
|
-
if (config !== undefined &&
|
|
53691
|
-
|
|
53835
|
+
if (config !== undefined && existsSync29(config)) {
|
|
53836
|
+
copyFileSync5(config, target);
|
|
53692
53837
|
} else {
|
|
53693
53838
|
writeFileSync14(target, "{}");
|
|
53694
53839
|
}
|
|
@@ -53721,7 +53866,7 @@ function createTemplateService(deps) {
|
|
|
53721
53866
|
digest,
|
|
53722
53867
|
source: "imp",
|
|
53723
53868
|
sourceImp: imp.name,
|
|
53724
|
-
sizeBytes:
|
|
53869
|
+
sizeBytes: statSync17(rootfs).blocks * 512
|
|
53725
53870
|
}, clock.now()).catch(async (error) => {
|
|
53726
53871
|
await storage.removeImage(digest);
|
|
53727
53872
|
throw error;
|
|
@@ -54089,14 +54234,14 @@ function updateImageAlias(db, alias, imageName, atMs) {
|
|
|
54089
54234
|
}
|
|
54090
54235
|
|
|
54091
54236
|
// packages/daemon/src/imps/images/build/create-image-builds.ts
|
|
54092
|
-
import { existsSync as
|
|
54237
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync27, rmSync as rmSync32, statSync as statSync18 } from "fs";
|
|
54093
54238
|
import { join as join44, posix as posix3 } from "path";
|
|
54094
54239
|
|
|
54095
54240
|
// packages/local-tar/src/create-local-extractor.ts
|
|
54096
54241
|
import tar from "tar-stream";
|
|
54097
54242
|
import * as z95 from "zod";
|
|
54098
54243
|
// packages/local-tar/src/list-context-entries.ts
|
|
54099
|
-
import { existsSync as
|
|
54244
|
+
import { existsSync as existsSync30 } from "fs";
|
|
54100
54245
|
import { lstat, readFile as readFile5, readdir } from "fs/promises";
|
|
54101
54246
|
import { join as join43, posix as posix2 } from "path";
|
|
54102
54247
|
import ignore from "@balena/dockerignore";
|
|
@@ -54382,7 +54527,7 @@ class MissingDockerfileError extends Error {
|
|
|
54382
54527
|
name = "MissingDockerfileError";
|
|
54383
54528
|
}
|
|
54384
54529
|
function listContextEntries(root, dockerfile) {
|
|
54385
|
-
const found = listDockerfileCandidates(posix2.normalize(dockerfile)).find((candidate) =>
|
|
54530
|
+
const found = listDockerfileCandidates(posix2.normalize(dockerfile)).find((candidate) => existsSync30(join43(root, candidate)));
|
|
54386
54531
|
if (found === undefined) {
|
|
54387
54532
|
return Promise.reject(new MissingDockerfileError(`there is no ${dockerfile} in ${root}`));
|
|
54388
54533
|
}
|
|
@@ -54394,8 +54539,8 @@ var ENTRY_KINDS = [
|
|
|
54394
54539
|
["file", "isFile"]
|
|
54395
54540
|
];
|
|
54396
54541
|
async function listEntries2(root, dockerfile) {
|
|
54397
|
-
const ignoreName =
|
|
54398
|
-
const patterns =
|
|
54542
|
+
const ignoreName = existsSync30(join43(root, `${dockerfile}.dockerignore`)) ? `${dockerfile}.dockerignore` : ".dockerignore";
|
|
54543
|
+
const patterns = existsSync30(join43(root, ignoreName)) ? await readFile5(join43(root, ignoreName), "utf8") : "";
|
|
54399
54544
|
const matcher = ignore().add(patterns);
|
|
54400
54545
|
const hasExceptions = patterns.split(`
|
|
54401
54546
|
`).some((line) => line.trim().startsWith("!"));
|
|
@@ -55774,7 +55919,7 @@ function createImageBuilds(deps, writer) {
|
|
|
55774
55919
|
const imageName = requireClientImageName(name);
|
|
55775
55920
|
await requireUnaliasedName(deps.db, imageName);
|
|
55776
55921
|
const tag = `imp/${imageName}:latest`;
|
|
55777
|
-
const tarBytes =
|
|
55922
|
+
const tarBytes = statSync18(tarPath).size;
|
|
55778
55923
|
const dockerfilePath = normalizeDockerfilePath(givenDockerfile);
|
|
55779
55924
|
const rewrittenPath = `${tarPath}.rewritten`;
|
|
55780
55925
|
let pins = [];
|
|
@@ -55851,7 +55996,7 @@ function createImageBuilds(deps, writer) {
|
|
|
55851
55996
|
}
|
|
55852
55997
|
throw error;
|
|
55853
55998
|
} finally {
|
|
55854
|
-
|
|
55999
|
+
rmSync32(rewrittenPath, { force: true });
|
|
55855
56000
|
}
|
|
55856
56001
|
};
|
|
55857
56002
|
const createOnHost = async (contextDir, name, dockerfile, options) => {
|
|
@@ -55861,7 +56006,7 @@ function createImageBuilds(deps, writer) {
|
|
|
55861
56006
|
message: `build context ${JSON.stringify(contextDir)} is not an absolute path`
|
|
55862
56007
|
});
|
|
55863
56008
|
}
|
|
55864
|
-
if (!
|
|
56009
|
+
if (!existsSync31(contextDir)) {
|
|
55865
56010
|
throw new ImpdError("BAD_REQUEST", {
|
|
55866
56011
|
message: `build context ${contextDir} does not exist on the impd host; build the image there and use \`impz image add\``
|
|
55867
56012
|
});
|
|
@@ -55888,7 +56033,7 @@ function createImageBuilds(deps, writer) {
|
|
|
55888
56033
|
signal: options.signal ?? new AbortController().signal
|
|
55889
56034
|
});
|
|
55890
56035
|
} finally {
|
|
55891
|
-
|
|
56036
|
+
rmSync32(tarPath, { force: true });
|
|
55892
56037
|
}
|
|
55893
56038
|
});
|
|
55894
56039
|
};
|
|
@@ -56033,7 +56178,7 @@ function buildImageRuntimeConfig(ociConfig) {
|
|
|
56033
56178
|
}
|
|
56034
56179
|
|
|
56035
56180
|
// packages/daemon/src/imps/images/rootfs/create-image-writer.ts
|
|
56036
|
-
import { existsSync as
|
|
56181
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync29, rmSync as rmSync34, statSync as statSync19, writeFileSync as writeFileSync15 } from "fs";
|
|
56037
56182
|
import { join as join46 } from "path";
|
|
56038
56183
|
|
|
56039
56184
|
// packages/daemon/src/imps/images/rootfs/read-oci-config.ts
|
|
@@ -56053,7 +56198,7 @@ async function readOciConfig(ref, signal, run) {
|
|
|
56053
56198
|
}
|
|
56054
56199
|
|
|
56055
56200
|
// packages/daemon/src/imps/images/rootfs/write-image-config.ts
|
|
56056
|
-
import { closeSync as closeSync11, constants as constants6, lstatSync as lstatSync5, mkdirSync as mkdirSync28, openSync as openSync9, rmSync as
|
|
56201
|
+
import { closeSync as closeSync11, constants as constants6, lstatSync as lstatSync5, mkdirSync as mkdirSync28, openSync as openSync9, rmSync as rmSync33, writeSync as writeSync3 } from "fs";
|
|
56057
56202
|
import { join as join45 } from "path";
|
|
56058
56203
|
function writeImageConfig(root, contents) {
|
|
56059
56204
|
const etc = join45(root, "etc");
|
|
@@ -56061,7 +56206,7 @@ function writeImageConfig(root, contents) {
|
|
|
56061
56206
|
createDirectory(etc, "/etc");
|
|
56062
56207
|
createDirectory(directory, "/etc/imp");
|
|
56063
56208
|
const file = join45(directory, "image.json");
|
|
56064
|
-
|
|
56209
|
+
rmSync33(file, { recursive: true, force: true });
|
|
56065
56210
|
const fd = openSync9(file, constants6.O_WRONLY | constants6.O_CREAT | constants6.O_EXCL | constants6.O_NOFOLLOW, 420);
|
|
56066
56211
|
try {
|
|
56067
56212
|
writeSync3(fd, contents);
|
|
@@ -56196,7 +56341,7 @@ function createImageWriter(deps) {
|
|
|
56196
56341
|
try {
|
|
56197
56342
|
guest.signal.throwIfAborted();
|
|
56198
56343
|
const sizeBytes = await createRootfsOnce(digest, () => {
|
|
56199
|
-
if (
|
|
56344
|
+
if (existsSync32(rootfs)) {
|
|
56200
56345
|
return Promise.resolve(readDiskUsage(rootfs));
|
|
56201
56346
|
}
|
|
56202
56347
|
freshRootfs.add(digest);
|
|
@@ -56233,7 +56378,7 @@ function createImageWriter(deps) {
|
|
|
56233
56378
|
signal
|
|
56234
56379
|
});
|
|
56235
56380
|
} finally {
|
|
56236
|
-
|
|
56381
|
+
rmSync34(workDir.work, { recursive: true, force: true });
|
|
56237
56382
|
}
|
|
56238
56383
|
}));
|
|
56239
56384
|
};
|
|
@@ -56268,7 +56413,7 @@ function createImageWriter(deps) {
|
|
|
56268
56413
|
signal: new AbortController().signal
|
|
56269
56414
|
});
|
|
56270
56415
|
} finally {
|
|
56271
|
-
|
|
56416
|
+
rmSync34(workDir.work, { recursive: true, force: true });
|
|
56272
56417
|
}
|
|
56273
56418
|
}));
|
|
56274
56419
|
};
|
|
@@ -56300,7 +56445,7 @@ function parseDuCount(stdout) {
|
|
|
56300
56445
|
return count;
|
|
56301
56446
|
}
|
|
56302
56447
|
function readDiskUsage(path) {
|
|
56303
|
-
return
|
|
56448
|
+
return statSync19(path).blocks * 512;
|
|
56304
56449
|
}
|
|
56305
56450
|
|
|
56306
56451
|
// packages/daemon/src/imps/images/create-image-adds.ts
|
|
@@ -57301,7 +57446,7 @@ function registerReconcilers(deps) {
|
|
|
57301
57446
|
}
|
|
57302
57447
|
|
|
57303
57448
|
// packages/daemon/src/network/https/wire-https-service.ts
|
|
57304
|
-
import { readFileSync as
|
|
57449
|
+
import { readFileSync as readFileSync38 } from "fs";
|
|
57305
57450
|
|
|
57306
57451
|
// packages/daemon/src/platform/db/read-public-imp.ts
|
|
57307
57452
|
async function readPublicImp(db, name) {
|
|
@@ -57325,7 +57470,7 @@ async function listPublicImpNames(db) {
|
|
|
57325
57470
|
}
|
|
57326
57471
|
|
|
57327
57472
|
// packages/daemon/src/network/https/acme/cert-store.ts
|
|
57328
|
-
import { existsSync as
|
|
57473
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync30, readFileSync as readFileSync37, rmSync as rmSync35 } from "fs";
|
|
57329
57474
|
import { join as join48 } from "path";
|
|
57330
57475
|
import * as z103 from "zod";
|
|
57331
57476
|
var AttemptStateSchema = z103.object({
|
|
@@ -57385,7 +57530,7 @@ ${certificate.chainPem.trimEnd()}
|
|
|
57385
57530
|
},
|
|
57386
57531
|
readAccount: (directoryUrl) => {
|
|
57387
57532
|
const account = readStoredAccount(directoryUrl);
|
|
57388
|
-
|
|
57533
|
+
rmSync35(legacyKeyPath, { force: true });
|
|
57389
57534
|
return account?.directoryUrl === directoryUrl ? account : null;
|
|
57390
57535
|
},
|
|
57391
57536
|
writeAccount: (account) => {
|
|
@@ -57407,7 +57552,7 @@ ${certificate.chainPem.trimEnd()}
|
|
|
57407
57552
|
};
|
|
57408
57553
|
}
|
|
57409
57554
|
function readIfExists(path) {
|
|
57410
|
-
return
|
|
57555
|
+
return existsSync33(path) ? readFileSync37(path, "utf8") : null;
|
|
57411
57556
|
}
|
|
57412
57557
|
function parseJson2(text) {
|
|
57413
57558
|
try {
|
|
@@ -58398,7 +58543,7 @@ function wireHttpsService(options) {
|
|
|
58398
58543
|
const issue = createAcmeIssuer({
|
|
58399
58544
|
directoryUrl: config.acmeDirectory,
|
|
58400
58545
|
email: config.acmeEmail,
|
|
58401
|
-
caPem: config.acmeCaFile === null ? null :
|
|
58546
|
+
caPem: config.acmeCaFile === null ? null : readFileSync38(config.acmeCaFile, "utf8"),
|
|
58402
58547
|
store,
|
|
58403
58548
|
dns
|
|
58404
58549
|
});
|
|
@@ -60444,7 +60589,7 @@ async function startImpdParts(config, boundaries, plan) {
|
|
|
60444
60589
|
readTailnetNames: tailnetNames === null ? null : tailnetNames.readStatus,
|
|
60445
60590
|
hostReaders: {
|
|
60446
60591
|
readKernel: () => deps.hostKernelRelease ?? release2(),
|
|
60447
|
-
readCpuInfo: deps.readCpuInfo ?? (() =>
|
|
60592
|
+
readCpuInfo: deps.readCpuInfo ?? (() => readFileSync39("/proc/cpuinfo", "utf8")),
|
|
60448
60593
|
readHugePagePool: deps.imps?.readHugePagePool ?? (() => readHugePagePool())
|
|
60449
60594
|
},
|
|
60450
60595
|
isReady: () => state.ready,
|
|
@@ -60683,7 +60828,7 @@ function startImpdLogCapture(onLine) {
|
|
|
60683
60828
|
}
|
|
60684
60829
|
|
|
60685
60830
|
// packages/testing/src/stand-in/vm/build-stub-vmm.ts
|
|
60686
|
-
import { existsSync as
|
|
60831
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync31, renameSync as renameSync10, writeFileSync as writeFileSync16 } from "fs";
|
|
60687
60832
|
var STUB_AGENT_VERSION = "0.1.0";
|
|
60688
60833
|
var IMPD_OWNER = { uid: process.getuid?.() ?? 0, cgroup: null };
|
|
60689
60834
|
|
|
@@ -60833,7 +60978,7 @@ log tail`);
|
|
|
60833
60978
|
}),
|
|
60834
60979
|
wakeVm: (plan) => runInGeneration(async () => {
|
|
60835
60980
|
const files = [plan.paths.disk, plan.paths.vmstate, plan.paths.memFile];
|
|
60836
|
-
wakeJails.push({ jail: plan.jail, files: files.filter((file) =>
|
|
60981
|
+
wakeJails.push({ jail: plan.jail, files: files.filter((file) => existsSync34(file)) });
|
|
60837
60982
|
wakePlans.push(plan);
|
|
60838
60983
|
const drive = readLoadingMeta(plan.paths)?.systemDrivePath;
|
|
60839
60984
|
if (plan.jail !== null && drive !== undefined && !plan.readOnlyFiles.includes(drive)) {
|
|
@@ -60871,8 +61016,8 @@ log tail`);
|
|
|
60871
61016
|
mkdirSync31(target.snapshotDir, { recursive: true });
|
|
60872
61017
|
writeFileSync16(`${target.vmstate}.new`, "vmstate");
|
|
60873
61018
|
writeFileSync16(`${target.memFile}.new`, "mem");
|
|
60874
|
-
|
|
60875
|
-
|
|
61019
|
+
renameSync10(`${target.vmstate}.new`, target.vmstate);
|
|
61020
|
+
renameSync10(`${target.memFile}.new`, target.memFile);
|
|
60876
61021
|
usedSnapshots.delete(target.snapshotDir);
|
|
60877
61022
|
return {};
|
|
60878
61023
|
}),
|
|
@@ -61087,7 +61232,7 @@ log tail`);
|
|
|
61087
61232
|
}
|
|
61088
61233
|
|
|
61089
61234
|
// packages/testing/src/stand-in/vm/create-stub-uffd-handler.ts
|
|
61090
|
-
import { existsSync as
|
|
61235
|
+
import { existsSync as existsSync35, readFileSync as readFileSync40, writeFileSync as writeFileSync17 } from "fs";
|
|
61091
61236
|
import { join as join50 } from "path";
|
|
61092
61237
|
import * as z105 from "zod";
|
|
61093
61238
|
var StartSchema = z105.object({
|
|
@@ -61099,8 +61244,9 @@ var StartSchema = z105.object({
|
|
|
61099
61244
|
served: z105.string()
|
|
61100
61245
|
});
|
|
61101
61246
|
var WarmRunSchema = z105.object({
|
|
61102
|
-
mode: z105.enum(["--count-data", "--warm"]),
|
|
61247
|
+
mode: z105.enum(["--count-data", "--warm", "--count-blocks", "--warm-blocks"]),
|
|
61103
61248
|
memFile: z105.string(),
|
|
61249
|
+
blockList: z105.string().optional(),
|
|
61104
61250
|
pid: z105.int()
|
|
61105
61251
|
});
|
|
61106
61252
|
function createStubUffdHandler(directory, mode = "serve") {
|
|
@@ -61121,7 +61267,7 @@ exec '${process.execPath}' '${script}' '${mode}' '${recorded}' '${warmAnswer}' "
|
|
|
61121
61267
|
};
|
|
61122
61268
|
}
|
|
61123
61269
|
function readRecords(path, schema) {
|
|
61124
|
-
return
|
|
61270
|
+
return existsSync35(path) ? readFileSync40(path, "utf8").trimEnd().split(`
|
|
61125
61271
|
`).map((line) => schema.parse(JSON.parse(line))) : [];
|
|
61126
61272
|
}
|
|
61127
61273
|
|
|
@@ -61179,7 +61325,7 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61179
61325
|
const logs = [];
|
|
61180
61326
|
const filesystemGrows = [];
|
|
61181
61327
|
const cloneDisk = options.cloneDisk ?? ((source, target) => {
|
|
61182
|
-
|
|
61328
|
+
copyFileSync6(source, target);
|
|
61183
61329
|
return Promise.resolve();
|
|
61184
61330
|
});
|
|
61185
61331
|
const createStorage = () => options.createStorage?.(dataDir) ?? createXfsBackend({ dataDir, cloneFile: cloneDisk });
|
|
@@ -61296,6 +61442,7 @@ async function startTestImpd(stack, options = {}) {
|
|
|
61296
61442
|
readRssMib: (pid) => fake.alive.has(pid) ? FAKE_VM_RSS_MIB : null,
|
|
61297
61443
|
readHugePagePool: () => null,
|
|
61298
61444
|
probeUffdDevice: () => true,
|
|
61445
|
+
probeTransparentHugePages: () => true,
|
|
61299
61446
|
readHugetlbMib: (pid) => {
|
|
61300
61447
|
const hugetlbMib = fake.alive.has(pid) ? 0 : null;
|
|
61301
61448
|
return Promise.resolve(hugetlbMib);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@impz/testing",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.10.0",
|
|
4
4
|
"description": "A real impd on stand-ins, for Bun tests of code that drives impd through @impz/client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@zgeoff/kysely-bun-sqlite": "^0.3.3",
|
|
35
35
|
"@zgeoff/mcp-auth": "^0.3.0",
|
|
36
36
|
"@zgeoff/std": "^0.4.5",
|
|
37
|
-
"@zgeoff/testing": "^0.4.
|
|
37
|
+
"@zgeoff/testing": "^0.4.3",
|
|
38
38
|
"dns-packet": "^5.6.1",
|
|
39
39
|
"elysia": "^2.0.0-rc.3",
|
|
40
40
|
"ipaddr.js": "^2.5.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"ts-pattern": "^5.9.2",
|
|
48
48
|
"xstate": "^5.33.3",
|
|
49
49
|
"zod": "^4.6.7",
|
|
50
|
-
"@impz/client": "7.
|
|
50
|
+
"@impz/client": "7.10.0"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"bun": ">=1.4.3"
|