mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
runtime: Add hmp for qemu
Fixes: #6092 Signed-off-by: zhaojizhuang <571130360@qq.com>
This commit is contained in:
parent
af125b1498
commit
9092c23a2e
@ -311,7 +311,7 @@ valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
||||
pflashes = []
|
||||
|
||||
# This option changes the default hypervisor and kernel parameters
|
||||
# to enable debug output where available.
|
||||
# to enable debug output where available. And Debug also enable the hmp socket.
|
||||
#
|
||||
# Default false
|
||||
#enable_debug = true
|
||||
|
@ -2336,10 +2336,14 @@ const (
|
||||
)
|
||||
|
||||
// QMPSocket represents a qemu QMP socket configuration.
|
||||
// nolint: govet
|
||||
type QMPSocket struct {
|
||||
// Type is the socket type (e.g. "unix").
|
||||
Type QMPSocketType
|
||||
|
||||
// Human Monitor Interface (HMP) (true for HMP, false for QMP, default false)
|
||||
IsHmp bool
|
||||
|
||||
// QMP listener file descriptor to be passed to qemu
|
||||
FD *os.File
|
||||
|
||||
@ -2710,7 +2714,12 @@ func (config *Config) appendQMPSockets() {
|
||||
}
|
||||
}
|
||||
|
||||
config.qemuParams = append(config.qemuParams, "-qmp")
|
||||
if q.IsHmp {
|
||||
config.qemuParams = append(config.qemuParams, "-monitor")
|
||||
} else {
|
||||
config.qemuParams = append(config.qemuParams, "-qmp")
|
||||
}
|
||||
|
||||
config.qemuParams = append(config.qemuParams, strings.Join(qmpParams, ","))
|
||||
}
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ type HypervisorConfig struct {
|
||||
EnableIOThreads bool
|
||||
|
||||
// Debug changes the default hypervisor and kernel parameters to
|
||||
// enable debug output where available.
|
||||
// enable debug output where available. And Debug also enable the hmp socket.
|
||||
Debug bool
|
||||
|
||||
// MemPrealloc specifies if the memory should be pre-allocated
|
||||
|
@ -121,6 +121,7 @@ type qemu struct {
|
||||
const (
|
||||
consoleSocket = "console.sock"
|
||||
qmpSocket = "qmp.sock"
|
||||
hmpSocket = "hmp.sock"
|
||||
vhostFSSocket = "vhost-fs.sock"
|
||||
nydusdAPISock = "nydusd-api.sock"
|
||||
|
||||
@ -328,6 +329,10 @@ func (q *qemu) qmpSocketPath(id string) (string, error) {
|
||||
return utils.BuildSocketPath(q.config.VMStorePath, id, qmpSocket)
|
||||
}
|
||||
|
||||
func (q *qemu) hmpSocketPath(id string) (string, error) {
|
||||
return utils.BuildSocketPath(q.config.VMStorePath, id, hmpSocket)
|
||||
}
|
||||
|
||||
func (q *qemu) getQemuMachine() (govmmQemu.Machine, error) {
|
||||
machine := q.arch.machine()
|
||||
|
||||
@ -369,13 +374,30 @@ func (q *qemu) createQmpSocket() ([]govmmQemu.QMPSocket, error) {
|
||||
path: monitorSockPath,
|
||||
}
|
||||
|
||||
return []govmmQemu.QMPSocket{
|
||||
{
|
||||
var sockets []govmmQemu.QMPSocket
|
||||
|
||||
sockets = append(sockets, govmmQemu.QMPSocket{
|
||||
Type: "unix",
|
||||
Server: true,
|
||||
NoWait: true,
|
||||
})
|
||||
|
||||
if q.HypervisorConfig().Debug {
|
||||
humanMonitorSockPath, err := q.hmpSocketPath(q.id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sockets = append(sockets, govmmQemu.QMPSocket{
|
||||
Type: "unix",
|
||||
IsHmp: true,
|
||||
Name: humanMonitorSockPath,
|
||||
Server: true,
|
||||
NoWait: true,
|
||||
},
|
||||
}, nil
|
||||
})
|
||||
}
|
||||
|
||||
return sockets, nil
|
||||
}
|
||||
|
||||
func (q *qemu) buildDevices(ctx context.Context, initrdPath string) ([]govmmQemu.Device, *govmmQemu.IOThread, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user