Skip to content

Commit 22aedc4

Browse files
authored
Merge pull request kata-containers#588 from nitkon/master
cli: Error out if initrd/rootfs not define in config file
2 parents 516b6ff + bce6859 commit 22aedc4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cli/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
327327
errors.New("having both an image and an initrd defined in the configuration file is not supported")
328328
}
329329

330+
if image == "" && initrd == "" {
331+
return vc.HypervisorConfig{},
332+
errors.New("either image or initrd must be defined in the configuration file")
333+
}
334+
330335
firmware, err := h.firmware()
331336
if err != nil {
332337
return vc.HypervisorConfig{}, err

cli/config_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ func TestMinimalRuntimeConfigWithVsock(t *testing.T) {
636636
defaultHypervisorPath = hypervisorPath
637637
defaultKernelPath = kernelPath
638638

639-
for _, file := range []string{proxyPath, shimPath, hypervisorPath, kernelPath} {
639+
for _, file := range []string{proxyPath, shimPath, hypervisorPath, kernelPath, imagePath} {
640640
err = writeFile(file, "foo", testFileMode)
641641
if err != nil {
642642
t.Fatal(err)
@@ -648,6 +648,7 @@ func TestMinimalRuntimeConfigWithVsock(t *testing.T) {
648648
# Runtime configuration file
649649
[hypervisor.qemu]
650650
use_vsock = true
651+
image = "` + imagePath + `"
651652
652653
[proxy.kata]
653654
path = "` + proxyPath + `"

0 commit comments

Comments
 (0)