mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-23 05:58:04 +00:00
qemu: add support for pidfile option
Add input for -pidfile option of qemu, so that we can get pid of qemu main process, and apply resource limitations to it. Fixes #62 Signed-off-by: l00397676 <lujingxiao@huawei.com>
This commit is contained in:
parent
e82e8498c5
commit
10c36a13da
11
qemu/qemu.go
11
qemu/qemu.go
@ -1516,6 +1516,9 @@ type Config struct {
|
|||||||
|
|
||||||
IOThreads []IOThread
|
IOThreads []IOThread
|
||||||
|
|
||||||
|
// PidFile is the -pidfile parameter
|
||||||
|
PidFile string
|
||||||
|
|
||||||
qemuParams []string
|
qemuParams []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1830,6 +1833,13 @@ func (config *Config) appendIncoming() {
|
|||||||
config.qemuParams = append(config.qemuParams, "-S", "-incoming", uri)
|
config.qemuParams = append(config.qemuParams, "-S", "-incoming", uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (config *Config) appendPidFile() {
|
||||||
|
if config.PidFile != "" {
|
||||||
|
config.qemuParams = append(config.qemuParams, "-pidfile")
|
||||||
|
config.qemuParams = append(config.qemuParams, config.PidFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
@ -1855,6 +1865,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
|
|||||||
config.appendBios()
|
config.appendBios()
|
||||||
config.appendIOThreads()
|
config.appendIOThreads()
|
||||||
config.appendIncoming()
|
config.appendIncoming()
|
||||||
|
config.appendPidFile()
|
||||||
|
|
||||||
if err := config.appendCPUs(); err != nil {
|
if err := config.appendCPUs(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -738,7 +738,8 @@ func TestAppendQMPSocketServer(t *testing.T) {
|
|||||||
testAppend(qmp, qmpSocketServerString, t)
|
testAppend(qmp, qmpSocketServerString, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
var qemuString = "-name cc-qemu -cpu host -uuid " + agentUUID
|
var pidfile = "/run/vc/vm/iamsandboxid/pidfile"
|
||||||
|
var qemuString = "-name cc-qemu -cpu host -uuid " + agentUUID + " -pidfile " + pidfile
|
||||||
|
|
||||||
func TestAppendStrings(t *testing.T) {
|
func TestAppendStrings(t *testing.T) {
|
||||||
config := Config{
|
config := Config{
|
||||||
@ -746,11 +747,13 @@ func TestAppendStrings(t *testing.T) {
|
|||||||
Name: "cc-qemu",
|
Name: "cc-qemu",
|
||||||
UUID: agentUUID,
|
UUID: agentUUID,
|
||||||
CPUModel: "host",
|
CPUModel: "host",
|
||||||
|
PidFile: pidfile,
|
||||||
}
|
}
|
||||||
|
|
||||||
config.appendName()
|
config.appendName()
|
||||||
config.appendCPUModel()
|
config.appendCPUModel()
|
||||||
config.appendUUID()
|
config.appendUUID()
|
||||||
|
config.appendPidFile()
|
||||||
|
|
||||||
result := strings.Join(config.qemuParams, " ")
|
result := strings.Join(config.qemuParams, " ")
|
||||||
if result != qemuString {
|
if result != qemuString {
|
||||||
|
Loading…
Reference in New Issue
Block a user