Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit d5c1fe1

Browse files
committed
HyperConfig: add GDBTCPPort
If add GDBTCPPort to hyper config, runv will add "-gdb tcp::xxx" to qemu arguments. Then GDB can connect this port to debug guest kernel. Signed-off-by: Hui Zhu <[email protected]>
1 parent cb3fa68 commit d5c1fe1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

daemon/daemon.go

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ func (daemon *Daemon) initRunV(c *apitypes.HyperConfig) error {
227227
Kernel: c.Kernel,
228228
Initrd: c.Initrd,
229229
EnableVsock: c.EnableVsock,
230+
GDBTCPPort: c.GDBTCPPort,
230231
}
231232
daemon.Factory = factory.NewFromPolicy(bootConfig, c.VmFactoryPolicy)
232233

types/config.go

+10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package types
33
import (
44
"fmt"
55
"os"
6+
"strconv"
67
"strings"
78

89
"github.com/Unknwon/goconfig"
@@ -28,6 +29,7 @@ type HyperConfig struct {
2829
EnableVsock bool
2930
DefaultLog string
3031
DefaultLogOpt map[string]string
32+
GDBTCPPort int
3133

3234
logPrefix string
3335
}
@@ -70,6 +72,14 @@ func NewHyperConfig(config string) *HyperConfig {
7072
c.DefaultLogOpt, _ = cfg.GetSection("Log")
7173
c.VmFactoryPolicy, _ = cfg.GetValue(goconfig.DEFAULT_SECTION, "VmFactoryPolicy")
7274
c.GRPCHost, _ = cfg.GetValue(goconfig.DEFAULT_SECTION, "gRPCHost")
75+
port, _ := cfg.GetValue(goconfig.DEFAULT_SECTION, "GDBTCPPort")
76+
if port != "" {
77+
c.GDBTCPPort, err = strconv.Atoi(port)
78+
if err != nil {
79+
c.Log(hlog.ERROR, "read config file GDBTCPPort %s failed: %v", port, err)
80+
return nil
81+
}
82+
}
7383

7484
c.Log(hlog.INFO, "config items: %#v", c)
7585
return c

0 commit comments

Comments
 (0)