File tree Expand file tree Collapse file tree 5 files changed +22
-12
lines changed Expand file tree Collapse file tree 5 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ rec {
107
107
=> { values = ["linux"]; args = ["-vnc" ":0" "-usb"]; }
108
108
109
109
# Extract multiple occurrences:
110
- extractOptValues "-platform " ["-a" "a" "-b" "b" "-c" "c" "-b" "b2"]
110
+ extractOptValues "-b " ["-a" "a" "-b" "b" "-c" "c" "-b" "b2"]
111
111
=> { values = ["b" "b2"]; args = ["-b" "b" "-c" "c"]; }
112
112
113
113
# Extract with multiple flag aliases:
Original file line number Diff line number Diff line change 8
8
9
9
inherit ( microvmConfig ) hostName ;
10
10
11
- inherit ( import ./. { inherit lib ; } ) createVolumesScript makeMacvtap withDriveLetters ;
11
+ inherit ( import ./. { inherit lib ; } ) createVolumesScript makeMacvtap withDriveLetters extractOptValues ;
12
12
inherit ( makeMacvtap {
13
13
inherit microvmConfig hypervisorConfig ;
14
14
} ) openMacvtapFds macvtapFds ;
15
15
16
16
hypervisorConfig = import ( ./runners + "/${ microvmConfig . hypervisor } .nix" ) {
17
- inherit pkgs microvmConfig macvtapFds withDriveLetters ;
17
+ inherit pkgs microvmConfig macvtapFds withDriveLetters extractOptValues ;
18
18
} ;
19
19
20
20
inherit ( hypervisorConfig ) command canShutdown shutdownCommand ;
Original file line number Diff line number Diff line change 1
1
{ pkgs
2
2
, microvmConfig
3
3
, macvtapFds
4
+ , extractOptValues
4
5
, ...
5
6
} :
6
7
7
8
let
8
9
inherit ( pkgs ) lib ;
9
- inherit ( import ../. { inherit ( pkgs ) lib ; } ) extractOptValues ;
10
10
inherit ( microvmConfig ) vcpu mem balloon initialBalloonMem deflateOnOOM hotplugMem hotpluggedMem user interfaces volumes shares socket devices hugepageMem graphics storeDisk storeOnDisk kernel initrdPath ;
11
11
inherit ( microvmConfig . cloud-hypervisor ) platformOEMStrings extraArgs ;
12
12
95
95
96
96
supportsNotifySocket = true ;
97
97
98
- oemStringValues = ( lib . optionals supportsNotifySocket [ "io.systemd.credential:vmm.notify_socket=vsock-stream:2:8888" ] ) ++ platformOEMStrings ;
99
- oemStringOptions = lib . optionals ( oemStringValues != [ ] ) [ "oem_strings=[${ lib . concatStringsSep "," oemStringValues } ]" ] ;
100
- extraArgsWithoutPlatform = ( extractOptValues "--platform" extraArgs ) . args ;
101
- userPlatformOpts = ( extractOptValues "--platform" extraArgs ) . values ;
98
+ oemStringValues = platformOEMStrings ++ lib . optional supportsNotifySocket "io.systemd.credential:vmm.notify_socket=vsock-stream:2:8888" ;
99
+ oemStringOptions = lib . optional ( oemStringValues != [ ] ) "oem_strings=[${ lib . concatStringsSep "," oemStringValues } ]" ;
100
+ platformExtracted = extractOptValues "--platform" extraArgs ;
101
+ extraArgsWithoutPlatform = platformExtracted . args ;
102
+ userPlatformOpts = platformExtracted . values ;
102
103
platformOps = lib . concatStringsSep "," ( oemStringOptions ++ userPlatformOpts ) ;
103
104
in {
104
105
inherit tapMultiQueue ;
Original file line number Diff line number Diff line change @@ -105,8 +105,17 @@ lib.mkIf config.microvm.guest.enable {
105
105
message = ''
106
106
MicroVM ${ hostName } : `config.microvm.forwardPorts` works only with qemu and one network interface with `type = "user"`
107
107
'' ;
108
+ } ]
109
+ ++
110
+ # cloud-hypervisor specific asserts
111
+ lib . optionals ( config . microvm . hypervisor == "cloud-hypervisor" ) [ {
112
+ assertion = ! ( lib . any ( str : lib . hasInfix "oem_strings" str ) config . microvm . cloud-hypervisor . platformOEMStrings ) ;
113
+ message = ''
114
+ MicroVM ${ hostName } : `config.microvm.cloud-hypervisor.platformOEMStrings` items must not contain `oem_strings`
115
+ '' ;
108
116
} ] ;
109
117
118
+
110
119
warnings =
111
120
# 32 MB is just an optimistic guess, not based on experience
112
121
lib . optional ( config . microvm . mem < 32 ) ''
Original file line number Diff line number Diff line change 519
519
type = with types ; listOf str ;
520
520
default = [ ] ;
521
521
description = ''
522
- Extra arguments to pass to cloud-hypervisor's --platform oem_strings= argument.
522
+ Extra arguments to pass to cloud-hypervisor's --platform oem_strings=[] argument.
523
523
524
524
All the oem strings will be concatenated with a comma (,) and wrapped in oem_string=[].
525
525
526
+ Do not include oem_string= or the [] brackets in the value.
527
+
526
528
The resulting string will be combined with any --platform options in
527
529
`config.microvm.cloud-hypervisor.extraArgs` and passed as a single
528
530
--platform option to cloud-hypervisor
529
531
'' ;
530
- example = lib . literalExpression /* nix */ ''
531
- [ "io.systemd.credential:APIKEY=supersecret" ]
532
- '' ;
532
+ example = lib . literalExpression /* nix */ ''[ "io.systemd.credential:APIKEY=supersecret" ]'' ;
533
533
} ;
534
534
535
535
cloud-hypervisor . extraArgs = mkOption {
You can’t perform that action at this time.
0 commit comments