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

Commit 664bbb1

Browse files
authored
Merge pull request #684 from teawater/gdb
BootConfig: add GDBTCPPort
2 parents af3acb5 + 63823a1 commit 664bbb1

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

hypervisor/context.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ type VmContext struct {
6262

6363
logPrefix string
6464

65+
GDBTCPPort int
66+
6567
lock sync.RWMutex //protect update of context
6668
idLock sync.Mutex
6769
pauseLock sync.Mutex
@@ -140,6 +142,7 @@ func InitContext(id string, hub chan VmEvent, client chan *types.VmResponse, dc
140142
logPrefix: fmt.Sprintf("SB[%s] ", id),
141143
sockConnected: make(chan bool),
142144
cancelWatchHyperstart: make(chan struct{}),
145+
GDBTCPPort: boot.GDBTCPPort,
143146
}
144147
ctx.networks.sandbox = ctx
145148

hypervisor/driver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type BootConfig struct {
2222
Initrd string
2323
Bios string
2424
Cbfs string
25+
GDBTCPPort int
2526

2627
// For network QoS (kilobytes/s)
2728
InboundAverage string

hypervisor/hypervisor.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ func (ctx *VmContext) Launch() {
8686
ctx.hyperstart, err = libhyperstart.NewHyperstart(ctx.Id, ctx.ctlSockAddr(), ctx.ttySockAddr(), 1, false, true)
8787
} else {
8888
ctx.hyperstart, err = libhyperstart.NewHyperstart(ctx.Id, ctx.ctlSockAddr(), ctx.ttySockAddr(), 1, true, false)
89-
go ctx.watchHyperstart()
89+
if ctx.GDBTCPPort == 0 {
90+
go ctx.watchHyperstart()
91+
}
9092
}
9193
if err != nil {
9294
ctx.Log(ERROR, "failed to create hypervisor")

hypervisor/qemu/qemu_process.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ func launchQemu(qc *QemuContext, ctx *hypervisor.VmContext) {
128128

129129
args := qc.arguments(ctx)
130130
args = append(args, "-daemonize", "-pidfile", qc.qemuPidFile, "-D", qc.qemuLogFile.Name)
131+
if ctx.GDBTCPPort != 0 {
132+
args = append(args, "-gdb", fmt.Sprintf("tcp::%d", ctx.GDBTCPPort))
133+
glog.Infof("qemu GDB TCP port is %d", ctx.GDBTCPPort)
134+
}
131135
if ctx.Boot.EnableVsock && qc.driver.hasVsock && ctx.GuestCid > 0 {
132136
addr := ctx.NextPciAddr()
133137
vsockDev := fmt.Sprintf("vhost-vsock-pci,id=vsock0,bus=pci.0,addr=%x,guest-cid=%d", addr, ctx.GuestCid)

0 commit comments

Comments
 (0)