Skip to content

Commit 741fc8c

Browse files
authored
Merge pull request #171 from smira/root-device-validation
Relax validation for configuration without root disk device
2 parents 57d08e3 + eead6e9 commit 741fc8c

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)