Merge pull request #5720 from YchauWang/wyc-docs-test-22

runtime: add log record to the qemu config method `appendDevices` for…
This commit is contained in:
Bin Liu 2022-11-24 13:15:06 +08:00 committed by GitHub
commit 06a604b753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -2705,9 +2705,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 {
if !d.Valid() {
logger.Errorf("vm device is not valid: %+v", config.Devices)
continue
}
@ -2982,7 +2987,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
config.appendCPUModel()
config.appendQMPSockets()
config.appendMemory()
config.appendDevices()
config.appendDevices(logger)
config.appendRTC()
config.appendGlobalParam()
config.appendPFlashParam()

View File

@ -34,7 +34,7 @@ func testConfigAppend(config *Config, structure interface{}, expected string, t
case Device:
config.Devices = []Device{s}
config.appendDevices()
config.appendDevices(nil)
case Knobs:
config.Knobs = s
@ -889,7 +889,7 @@ func TestBadQMPSockets(t *testing.T) {
func TestBadDevices(t *testing.T) {
c := &Config{}
c.appendDevices()
c.appendDevices(nil)
if len(c.qemuParams) != 0 {
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 {
t.Errorf("Expected empty qemuParams, found %s", c.qemuParams)
}