mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-11 12:52:23 +00:00
Merge pull request #319 from jodh-intel/error-on-image+initrd
config: Error if image+initrd specified
This commit is contained in:
commit
8347f4d5ca
@ -309,6 +309,11 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
|||||||
return vc.HypervisorConfig{}, err
|
return vc.HypervisorConfig{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if image != "" && initrd != "" {
|
||||||
|
return vc.HypervisorConfig{},
|
||||||
|
errors.New("cannot specify an image and an initrd in configuration file")
|
||||||
|
}
|
||||||
|
|
||||||
firmware, err := h.firmware()
|
firmware, err := h.firmware()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return vc.HypervisorConfig{}, err
|
return vc.HypervisorConfig{}, err
|
||||||
|
@ -625,6 +625,43 @@ func TestNewQemuHypervisorConfig(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewQemuHypervisorConfigImageAndInitrd(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
tmpdir, err := ioutil.TempDir(testDir, "")
|
||||||
|
assert.NoError(err)
|
||||||
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
|
imagePath := filepath.Join(tmpdir, "image")
|
||||||
|
initrdPath := filepath.Join(tmpdir, "initrd")
|
||||||
|
hypervisorPath := path.Join(tmpdir, "hypervisor")
|
||||||
|
kernelPath := path.Join(tmpdir, "kernel")
|
||||||
|
|
||||||
|
for _, file := range []string{imagePath, initrdPath, hypervisorPath, kernelPath} {
|
||||||
|
err = createEmptyFile(file)
|
||||||
|
assert.NoError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
machineType := "machineType"
|
||||||
|
disableBlock := true
|
||||||
|
enableIOThreads := true
|
||||||
|
|
||||||
|
hypervisor := hypervisor{
|
||||||
|
Path: hypervisorPath,
|
||||||
|
Kernel: kernelPath,
|
||||||
|
Image: imagePath,
|
||||||
|
Initrd: initrdPath,
|
||||||
|
MachineType: machineType,
|
||||||
|
DisableBlockDeviceUse: disableBlock,
|
||||||
|
EnableIOThreads: enableIOThreads,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = newQemuHypervisorConfig(hypervisor)
|
||||||
|
|
||||||
|
// specifying both an image+initrd is invalid
|
||||||
|
assert.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestNewShimConfig(t *testing.T) {
|
func TestNewShimConfig(t *testing.T) {
|
||||||
dir, err := ioutil.TempDir(testDir, "shim-config-")
|
dir, err := ioutil.TempDir(testDir, "shim-config-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user