Skip to content

Commit a1d7cb4

Browse files
committed
Create DerivationBuilderParams::exposeKVM bool
Do this to avoid checking "system features" from the store config directly.
1 parent d7612f3 commit a1d7cb4

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/libstore/build/derivation-building-goal.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,9 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
768768
std::move(defaultPathsInChroot),
769769
std::move(finalEnv),
770770
std::move(extraFiles),
771+
# ifdef __linux__
772+
worker.store.config.systemFeatures.get().count("kvm") > 0,
773+
# endif
771774
});
772775
}
773776

src/libstore/include/nix/store/build/derivation-builder.hh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ struct DerivationBuilderParams
8888
*/
8989
std::map<std::string, EnvEntry, std::less<>> finalEnv;
9090

91+
#ifdef __linux__
92+
/**
93+
* On Linux, whether `/dev/kvm` should be exposed to the builder
94+
* within the sandbox.
95+
*/
96+
bool exposeKVM;
97+
#endif
98+
9199
/**
92100
* Inserted in the temp dir, but no file names placed in env, unlike
93101
* `EnvEntry::nameOfPassAsFile` above.
@@ -104,7 +112,12 @@ struct DerivationBuilderParams
104112
std::map<std::string, InitialOutput> & initialOutputs,
105113
PathsInChroot defaultPathsInChroot,
106114
std::map<std::string, EnvEntry, std::less<>> finalEnv,
107-
StringMap extraFiles)
115+
StringMap extraFiles
116+
#ifdef __linux__
117+
,
118+
bool exposeKVM
119+
#endif
120+
)
108121
: drvPath{drvPath}
109122
, buildResult{buildResult}
110123
, drv{drv}

src/libstore/unix/build/linux-derivation-builder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ struct ChrootLinuxDerivationBuilder : ChrootDerivationBuilder, LinuxDerivationBu
492492
createDirs(chrootRootDir + "/dev/shm");
493493
createDirs(chrootRootDir + "/dev/pts");
494494
ss.push_back("/dev/full");
495-
if (store.Store::config.systemFeatures.get().count("kvm") && pathExists("/dev/kvm"))
495+
if (exposeKVM && pathExists("/dev/kvm"))
496496
ss.push_back("/dev/kvm");
497497
ss.push_back("/dev/null");
498498
ss.push_back("/dev/random");

0 commit comments

Comments
 (0)