Skip to content

Commit

Permalink
Add common directory
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Kharin <[email protected]>
  • Loading branch information
remimimimimi committed Sep 23, 2024
1 parent 67edf00 commit 7bebddd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/microvm/virtualization/microvm/appvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ let
})

./common/storagevm.nix
(lib.optionalAttrs config.ghaf.virtualization.microvm-host.sharedVmDirectory.enable ./common/common-directory.nix)

# To push logs to central location
../../../common/logging/client.nix
Expand Down
35 changes: 35 additions & 0 deletions modules/microvm/virtualization/microvm/common/common-directory.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
{ lib, config, ... }:
let
cfg = config.ghaf.storagevm;
common-mountPath = "/tmp/common";
in
{
config = lib.mkIf cfg.enable {
fileSystems.${common-mountPath}.neededForBoot = true;

microvm.shares = [
{
tag = "common-directory-share";
proto = "virtiofs";
securityModel = "passthrough";
source = "/storagevm/common";
mountPoint = common-mountPath;
}
];

environment.persistence.${common-mountPath} = {
hideMounts = true;

directories = [
{
directory = "/home/${config.ghaf.users.accounts.user}/common";
inherit (config.ghaf.users.accounts) user;
group = config.ghaf.users.accounts.user;
mode = "u=rwx,g=,o=";
}
];
};
};
}
1 change: 1 addition & 0 deletions modules/microvm/virtualization/microvm/guivm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let
})

./common/storagevm.nix
(lib.optionalAttrs config.ghaf.virtualization.microvm-host.sharedVmDirectory.enable ./common/common-directory.nix)

# To push logs to central location
../../../common/logging/client.nix
Expand Down
3 changes: 3 additions & 0 deletions modules/microvm/virtualization/microvm/microvm-host.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ in
options.ghaf.virtualization.microvm-host = {
enable = lib.mkEnableOption "MicroVM Host";
networkSupport = lib.mkEnableOption "Network support services to run host applications.";
sharedVmDirectory.enable = lib.mkEnableOption "shared directory" // {
default = true;
};
};

config = lib.mkIf cfg.enable {
Expand Down

0 comments on commit 7bebddd

Please sign in to comment.