Skip to content

Commit eead6e9

Browse files
committed
Relax validation for configuration without root disk device
If there's no root disk in the config, validation fails while trying to stat path `""`. Signed-off-by: Andrey Smirnov <[email protected]>
1 parent 57d08e3 commit eead6e9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

machine.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,17 @@ func (cfg *Config) Validate() error {
134134
return fmt.Errorf("failed to stat kernel image path, %q: %v", cfg.KernelImagePath, err)
135135
}
136136

137-
rootPath := ""
138137
for _, drive := range cfg.Drives {
139138
if BoolValue(drive.IsRootDevice) {
140-
rootPath = StringValue(drive.PathOnHost)
139+
rootPath := StringValue(drive.PathOnHost)
140+
if _, err := os.Stat(rootPath); err != nil {
141+
return fmt.Errorf("failed to stat host path, %q: %v", rootPath, err)
142+
}
143+
141144
break
142145
}
143146
}
144147

145-
if _, err := os.Stat(rootPath); err != nil {
146-
return fmt.Errorf("failed to stat host path, %q: %v", rootPath, err)
147-
}
148-
149148
// Check the non-existence of some files:
150149
if _, err := os.Stat(cfg.SocketPath); err == nil {
151150
return fmt.Errorf("socket %s already exists", cfg.SocketPath)

0 commit comments

Comments
 (0)