mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 12:44:39 +00:00
runtime: Log invalid devices in QEMU config
When the user tried to add new devices to the VM, there is no error info for the invalid device. This PR adds a log record to the `appendDevices` for the invalid device of the qemu config. Fixes: #5719 Signed-off-by: wangyongchao.bj <wangyongchao.bj@inspur.com>
This commit is contained in:
parent
8b04ba95cb
commit
30a7ebf430
@ -2699,9 +2699,14 @@ func (config *Config) appendQMPSockets() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *Config) appendDevices() {
|
func (config *Config) appendDevices(logger QMPLog) {
|
||||||
|
if logger == nil {
|
||||||
|
logger = qmpNullLogger{}
|
||||||
|
}
|
||||||
|
|
||||||
for _, d := range config.Devices {
|
for _, d := range config.Devices {
|
||||||
if !d.Valid() {
|
if !d.Valid() {
|
||||||
|
logger.Errorf("vm device is not valid: %+v", config.Devices)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2976,7 +2981,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
|
|||||||
config.appendCPUModel()
|
config.appendCPUModel()
|
||||||
config.appendQMPSockets()
|
config.appendQMPSockets()
|
||||||
config.appendMemory()
|
config.appendMemory()
|
||||||
config.appendDevices()
|
config.appendDevices(logger)
|
||||||
config.appendRTC()
|
config.appendRTC()
|
||||||
config.appendGlobalParam()
|
config.appendGlobalParam()
|
||||||
config.appendPFlashParam()
|
config.appendPFlashParam()
|
||||||
|
@ -34,7 +34,7 @@ func testConfigAppend(config *Config, structure interface{}, expected string, t
|
|||||||
|
|
||||||
case Device:
|
case Device:
|
||||||
config.Devices = []Device{s}
|
config.Devices = []Device{s}
|
||||||
config.appendDevices()
|
config.appendDevices(nil)
|
||||||
|
|
||||||
case Knobs:
|
case Knobs:
|
||||||
config.Knobs = s
|
config.Knobs = s
|
||||||
@ -889,7 +889,7 @@ func TestBadQMPSockets(t *testing.T) {
|
|||||||
|
|
||||||
func TestBadDevices(t *testing.T) {
|
func TestBadDevices(t *testing.T) {
|
||||||
c := &Config{}
|
c := &Config{}
|
||||||
c.appendDevices()
|
c.appendDevices(nil)
|
||||||
if len(c.qemuParams) != 0 {
|
if len(c.qemuParams) != 0 {
|
||||||
t.Errorf("Expected empty qemuParams, found %s", c.qemuParams)
|
t.Errorf("Expected empty qemuParams, found %s", c.qemuParams)
|
||||||
}
|
}
|
||||||
@ -941,7 +941,7 @@ func TestBadDevices(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
c.appendDevices()
|
c.appendDevices(nil)
|
||||||
if len(c.qemuParams) != 0 {
|
if len(c.qemuParams) != 0 {
|
||||||
t.Errorf("Expected empty qemuParams, found %s", c.qemuParams)
|
t.Errorf("Expected empty qemuParams, found %s", c.qemuParams)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user