mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-02 13:44:33 +00:00
qemu: Add QMPSocket specific type
Instead of open coding the QMP socket type, we now have a specific type for it. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
2d736d7173
commit
cc9cb33a5d
25
qemu.go
25
qemu.go
@ -391,10 +391,18 @@ func (rtc RTC) Valid() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QMPSocketType is the type of socket used for QMP communication.
|
||||||
|
type QMPSocketType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Unix socket for QMP.
|
||||||
|
Unix QMPSocketType = "unix"
|
||||||
|
)
|
||||||
|
|
||||||
// QMPSocket represents a qemu QMP socket configuration.
|
// QMPSocket represents a qemu QMP socket configuration.
|
||||||
type QMPSocket struct {
|
type QMPSocket struct {
|
||||||
// Type is the socket type (e.g. "unix").
|
// Type is the socket type (e.g. "unix").
|
||||||
Type string
|
Type QMPSocketType
|
||||||
|
|
||||||
// Name is the socket name.
|
// Name is the socket name.
|
||||||
Name string
|
Name string
|
||||||
@ -406,6 +414,15 @@ type QMPSocket struct {
|
|||||||
NoWait bool
|
NoWait bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Valid returns true if the QMPSocket structure is valid and complete.
|
||||||
|
func (qmp QMPSocket) Valid() bool {
|
||||||
|
if qmp.Type == "" || qmp.Name == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// SMP is the multi processors configuration structure.
|
// SMP is the multi processors configuration structure.
|
||||||
type SMP struct {
|
type SMP struct {
|
||||||
// CPUs is the number of VCPUs made available to qemu.
|
// CPUs is the number of VCPUs made available to qemu.
|
||||||
@ -545,7 +562,10 @@ func appendCPUModel(params []string, config Config) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func appendQMPSocket(params []string, config Config) []string {
|
func appendQMPSocket(params []string, config Config) []string {
|
||||||
if config.QMPSocket.Type != "" && config.QMPSocket.Name != "" {
|
if config.QMPSocket.Valid() == false {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var qmpParams []string
|
var qmpParams []string
|
||||||
|
|
||||||
qmpParams = append(qmpParams, fmt.Sprintf("%s:", config.QMPSocket.Type))
|
qmpParams = append(qmpParams, fmt.Sprintf("%s:", config.QMPSocket.Type))
|
||||||
@ -559,7 +579,6 @@ func appendQMPSocket(params []string, config Config) []string {
|
|||||||
|
|
||||||
params = append(params, "-qmp")
|
params = append(params, "-qmp")
|
||||||
params = append(params, strings.Join(qmpParams, ""))
|
params = append(params, strings.Join(qmpParams, ""))
|
||||||
}
|
|
||||||
|
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ func TestAppendQMPSocketServer(t *testing.T) {
|
|||||||
|
|
||||||
func TestAppendQMPSocket(t *testing.T) {
|
func TestAppendQMPSocket(t *testing.T) {
|
||||||
qmp := QMPSocket{
|
qmp := QMPSocket{
|
||||||
Type: "unix",
|
Type: Unix,
|
||||||
Name: "cc-qmp",
|
Name: "cc-qmp",
|
||||||
Server: false,
|
Server: false,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user