Merge pull request #588 from nitkon/master

cli: Error out if initrd/rootfs not define in config file
This commit is contained in:
Frank Cao 2018-09-14 00:20:18 +08:00 committed by GitHub
commit 22aedc4fb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -636,7 +636,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)
@ -648,6 +648,7 @@ func TestMinimalRuntimeConfigWithVsock(t *testing.T) {
# Runtime configuration file
[hypervisor.qemu]
use_vsock = true
image = "` + imagePath + `"
[proxy.kata]
path = "` + proxyPath + `"