mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 08:47:56 +00:00
hypervisor: cleanup valid method
The boolean return value is not necessary. Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
parent
18e6a6effc
commit
7f20dd89a3
@ -218,13 +218,13 @@ type HypervisorConfig struct {
|
||||
Msize9p uint32
|
||||
}
|
||||
|
||||
func (conf *HypervisorConfig) valid() (bool, error) {
|
||||
func (conf *HypervisorConfig) valid() error {
|
||||
if conf.KernelPath == "" {
|
||||
return false, fmt.Errorf("Missing kernel path")
|
||||
return fmt.Errorf("Missing kernel path")
|
||||
}
|
||||
|
||||
if conf.ImagePath == "" && conf.InitrdPath == "" {
|
||||
return false, fmt.Errorf("Missing image and initrd path")
|
||||
return fmt.Errorf("Missing image and initrd path")
|
||||
}
|
||||
|
||||
if conf.DefaultVCPUs == 0 {
|
||||
@ -251,7 +251,7 @@ func (conf *HypervisorConfig) valid() (bool, error) {
|
||||
conf.Msize9p = defaultMsize9p
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddKernelParam allows the addition of new kernel parameters to an existing
|
||||
|
@ -107,9 +107,12 @@ func TestNewHypervisorFromUnknownHypervisorType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testHypervisorConfigValid(t *testing.T, hypervisorConfig *HypervisorConfig, expected bool) {
|
||||
ret, _ := hypervisorConfig.valid()
|
||||
if ret != expected {
|
||||
func testHypervisorConfigValid(t *testing.T, hypervisorConfig *HypervisorConfig, success bool) {
|
||||
err := hypervisorConfig.valid()
|
||||
if success && err != nil {
|
||||
t.Fatal()
|
||||
}
|
||||
if !success && err == nil {
|
||||
t.Fatal()
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ type mockHypervisor struct {
|
||||
}
|
||||
|
||||
func (m *mockHypervisor) init(id string, hypervisorConfig *HypervisorConfig, vmConfig Resources, storage resourceStorage) error {
|
||||
valid, err := hypervisorConfig.valid()
|
||||
if valid == false || err != nil {
|
||||
err := hypervisorConfig.valid()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -173,8 +173,8 @@ func (q *qemu) qemuPath() (string, error) {
|
||||
|
||||
// init intializes the Qemu structure.
|
||||
func (q *qemu) init(id string, hypervisorConfig *HypervisorConfig, vmConfig Resources, storage resourceStorage) error {
|
||||
valid, err := hypervisorConfig.valid()
|
||||
if valid == false || err != nil {
|
||||
err := hypervisorConfig.valid()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user