mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 00:37:24 +00:00
qemu: add debug logfile
When LogFile is specified, output debug log there. Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
parent
aa341b005e
commit
30bfcaaa6d
11
qemu/qemu.go
11
qemu/qemu.go
@ -1557,6 +1557,9 @@ type Config struct {
|
||||
// PidFile is the -pidfile parameter
|
||||
PidFile string
|
||||
|
||||
// LogFile is the -D parameter
|
||||
LogFile string
|
||||
|
||||
qemuParams []string
|
||||
}
|
||||
|
||||
@ -1880,6 +1883,13 @@ func (config *Config) appendPidFile() {
|
||||
}
|
||||
}
|
||||
|
||||
func (config *Config) appendLogFile() {
|
||||
if config.LogFile != "" {
|
||||
config.qemuParams = append(config.qemuParams, "-D")
|
||||
config.qemuParams = append(config.qemuParams, config.LogFile)
|
||||
}
|
||||
}
|
||||
|
||||
// LaunchQemu can be used to launch a new qemu instance.
|
||||
//
|
||||
// The Config parameter contains a set of qemu parameters and settings.
|
||||
@ -1906,6 +1916,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
|
||||
config.appendIOThreads()
|
||||
config.appendIncoming()
|
||||
config.appendPidFile()
|
||||
config.appendLogFile()
|
||||
|
||||
if err := config.appendCPUs(); err != nil {
|
||||
return "", err
|
||||
|
@ -712,7 +712,8 @@ func TestAppendQMPSocketServer(t *testing.T) {
|
||||
}
|
||||
|
||||
var pidfile = "/run/vc/vm/iamsandboxid/pidfile"
|
||||
var qemuString = "-name cc-qemu -cpu host -uuid " + agentUUID + " -pidfile " + pidfile
|
||||
var logfile = "/run/vc/vm/iamsandboxid/logfile"
|
||||
var qemuString = "-name cc-qemu -cpu host -uuid " + agentUUID + " -pidfile " + pidfile + " -D " + logfile
|
||||
|
||||
func TestAppendStrings(t *testing.T) {
|
||||
config := Config{
|
||||
@ -721,12 +722,14 @@ func TestAppendStrings(t *testing.T) {
|
||||
UUID: agentUUID,
|
||||
CPUModel: "host",
|
||||
PidFile: pidfile,
|
||||
LogFile: logfile,
|
||||
}
|
||||
|
||||
config.appendName()
|
||||
config.appendCPUModel()
|
||||
config.appendUUID()
|
||||
config.appendPidFile()
|
||||
config.appendLogFile()
|
||||
|
||||
result := strings.Join(config.qemuParams, " ")
|
||||
if result != qemuString {
|
||||
|
Loading…
Reference in New Issue
Block a user