mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-27 15:57:09 +00:00
qemu: Simplify (Object).Valid()
so that more object types can be added without going over cyclomatic complexity limits Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
This commit is contained in:
parent
a6cec2d38c
commit
7a367dc0a8
16
qemu/qemu.go
16
qemu/qemu.go
@ -275,24 +275,14 @@ type Object struct {
|
||||
func (object Object) Valid() bool {
|
||||
switch object.Type {
|
||||
case MemoryBackendFile:
|
||||
if object.ID == "" || object.MemPath == "" || object.Size == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
return object.ID != "" && object.MemPath != "" && object.Size != 0
|
||||
case TDXGuest:
|
||||
if object.ID == "" || object.File == "" || object.DeviceID == "" {
|
||||
return false
|
||||
}
|
||||
return object.ID != "" && object.File != "" && object.DeviceID != ""
|
||||
case SEVGuest:
|
||||
if object.ID == "" || object.File == "" || object.CBitPos == 0 || object.ReducedPhysBits == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
return object.ID != "" && object.File != "" && object.CBitPos != 0 && object.ReducedPhysBits != 0
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// QemuParams returns the qemu parameters built out of this Object device.
|
||||
|
Loading…
Reference in New Issue
Block a user