mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 20:54:26 +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 = []
|
pflashes = []
|
||||||
|
|
||||||
# This option changes the default hypervisor and kernel parameters
|
# 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
|
# Default false
|
||||||
#enable_debug = true
|
#enable_debug = true
|
||||||
|
@ -2336,10 +2336,14 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// QMPSocket represents a qemu QMP socket configuration.
|
// QMPSocket represents a qemu QMP socket configuration.
|
||||||
|
// nolint: govet
|
||||||
type QMPSocket struct {
|
type QMPSocket struct {
|
||||||
// Type is the socket type (e.g. "unix").
|
// Type is the socket type (e.g. "unix").
|
||||||
Type QMPSocketType
|
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
|
// QMP listener file descriptor to be passed to qemu
|
||||||
FD *os.File
|
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, ","))
|
config.qemuParams = append(config.qemuParams, strings.Join(qmpParams, ","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ type HypervisorConfig struct {
|
|||||||
EnableIOThreads bool
|
EnableIOThreads bool
|
||||||
|
|
||||||
// Debug changes the default hypervisor and kernel parameters to
|
// 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
|
Debug bool
|
||||||
|
|
||||||
// MemPrealloc specifies if the memory should be pre-allocated
|
// MemPrealloc specifies if the memory should be pre-allocated
|
||||||
|
@ -121,6 +121,7 @@ type qemu struct {
|
|||||||
const (
|
const (
|
||||||
consoleSocket = "console.sock"
|
consoleSocket = "console.sock"
|
||||||
qmpSocket = "qmp.sock"
|
qmpSocket = "qmp.sock"
|
||||||
|
hmpSocket = "hmp.sock"
|
||||||
vhostFSSocket = "vhost-fs.sock"
|
vhostFSSocket = "vhost-fs.sock"
|
||||||
nydusdAPISock = "nydusd-api.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)
|
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) {
|
func (q *qemu) getQemuMachine() (govmmQemu.Machine, error) {
|
||||||
machine := q.arch.machine()
|
machine := q.arch.machine()
|
||||||
|
|
||||||
@ -369,13 +374,30 @@ func (q *qemu) createQmpSocket() ([]govmmQemu.QMPSocket, error) {
|
|||||||
path: monitorSockPath,
|
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",
|
Type: "unix",
|
||||||
|
IsHmp: true,
|
||||||
|
Name: humanMonitorSockPath,
|
||||||
Server: true,
|
Server: true,
|
||||||
NoWait: true,
|
NoWait: true,
|
||||||
},
|
})
|
||||||
}, nil
|
}
|
||||||
|
|
||||||
|
return sockets, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemu) buildDevices(ctx context.Context, initrdPath string) ([]govmmQemu.Device, *govmmQemu.IOThread, error) {
|
func (q *qemu) buildDevices(ctx context.Context, initrdPath string) ([]govmmQemu.Device, *govmmQemu.IOThread, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user