mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 08:47:56 +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 is the -pidfile parameter
|
||||||
PidFile string
|
PidFile string
|
||||||
|
|
||||||
|
// LogFile is the -D parameter
|
||||||
|
LogFile string
|
||||||
|
|
||||||
qemuParams []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.
|
// LaunchQemu can be used to launch a new qemu instance.
|
||||||
//
|
//
|
||||||
// The Config parameter contains a set of qemu parameters and settings.
|
// 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.appendIOThreads()
|
||||||
config.appendIncoming()
|
config.appendIncoming()
|
||||||
config.appendPidFile()
|
config.appendPidFile()
|
||||||
|
config.appendLogFile()
|
||||||
|
|
||||||
if err := config.appendCPUs(); err != nil {
|
if err := config.appendCPUs(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -712,7 +712,8 @@ func TestAppendQMPSocketServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pidfile = "/run/vc/vm/iamsandboxid/pidfile"
|
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) {
|
func TestAppendStrings(t *testing.T) {
|
||||||
config := Config{
|
config := Config{
|
||||||
@ -721,12 +722,14 @@ func TestAppendStrings(t *testing.T) {
|
|||||||
UUID: agentUUID,
|
UUID: agentUUID,
|
||||||
CPUModel: "host",
|
CPUModel: "host",
|
||||||
PidFile: pidfile,
|
PidFile: pidfile,
|
||||||
|
LogFile: logfile,
|
||||||
}
|
}
|
||||||
|
|
||||||
config.appendName()
|
config.appendName()
|
||||||
config.appendCPUModel()
|
config.appendCPUModel()
|
||||||
config.appendUUID()
|
config.appendUUID()
|
||||||
config.appendPidFile()
|
config.appendPidFile()
|
||||||
|
config.appendLogFile()
|
||||||
|
|
||||||
result := strings.Join(config.qemuParams, " ")
|
result := strings.Join(config.qemuParams, " ")
|
||||||
if result != qemuString {
|
if result != qemuString {
|
||||||
|
Loading…
Reference in New Issue
Block a user