Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
cli: Error out if initrd/rootfs not define in config file
Browse files Browse the repository at this point in the history
If neither initrd nor rootfs path is mentioned in
the configuration.toml file, then error out stating
the same

Fixes: #587

Signed-off-by: Nitesh Konkar [email protected]
  • Loading branch information
nitkon committed Sep 13, 2018
1 parent e02695b commit bce6859
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
errors.New("having both an image and an initrd defined in the configuration file is not supported")
}

if image == "" && initrd == "" {
return vc.HypervisorConfig{},
errors.New("either image or initrd must be defined in the configuration file")
}

firmware, err := h.firmware()
if err != nil {
return vc.HypervisorConfig{}, err
Expand Down
3 changes: 2 additions & 1 deletion cli/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ func TestMinimalRuntimeConfigWithVsock(t *testing.T) {
defaultHypervisorPath = hypervisorPath
defaultKernelPath = kernelPath

for _, file := range []string{proxyPath, shimPath, hypervisorPath, kernelPath} {
for _, file := range []string{proxyPath, shimPath, hypervisorPath, kernelPath, imagePath} {
err = writeFile(file, "foo", testFileMode)
if err != nil {
t.Fatal(err)
Expand All @@ -638,6 +638,7 @@ func TestMinimalRuntimeConfigWithVsock(t *testing.T) {
# Runtime configuration file
[hypervisor.qemu]
use_vsock = true
image = "` + imagePath + `"
[proxy.kata]
path = "` + proxyPath + `"
Expand Down

0 comments on commit bce6859

Please sign in to comment.