File tree Expand file tree Collapse file tree 4 files changed +24
-5
lines changed Expand file tree Collapse file tree 4 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -204,14 +204,15 @@ func main() {
204
204
CPUTemplate : firecracker .CPUTemplate (opts .FcCPUTemplate ),
205
205
HtEnabled : ! opts .FcDisableHt ,
206
206
MemInMiB : opts .FcMemSz ,
207
+ Debug : opts .Debug ,
207
208
}
208
209
209
210
err = checkConfig (fcCfg )
210
211
if err != nil {
211
212
log .Fatalf ("Configuration error: %s" , err )
212
213
}
213
214
214
- m := firecracker .NewMachine (fcCfg , firecracker .WithLogger (logger ))
215
+ m := firecracker .NewMachine (fcCfg , firecracker .WithLogger (log . NewEntry ( logger ) ))
215
216
216
217
ctx := context .Background ()
217
218
vmmCtx , vmmCancel := context .WithCancel (ctx )
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
19
19
"net/http"
20
20
"time"
21
21
22
+ "github.com/sirupsen/logrus"
22
23
"github.com/go-openapi/strfmt"
23
24
24
25
"github.com/firecracker-microvm/firecracker-go-sdk/client"
@@ -33,7 +34,7 @@ type FirecrackerClient struct {
33
34
client * client.Firecracker
34
35
}
35
36
36
- func NewFirecrackerClient (socketPath string ) * FirecrackerClient {
37
+ func NewFirecrackerClient (socketPath string , logger * logrus. Entry , debug bool ) * FirecrackerClient {
37
38
httpClient := client .NewHTTPClient (strfmt .NewFormats ())
38
39
39
40
socketTransport := & http.Transport {
@@ -49,6 +50,15 @@ func NewFirecrackerClient(socketPath string) *FirecrackerClient {
49
50
50
51
transport := httptransport .New (client .DefaultHost , client .DefaultBasePath , client .DefaultSchemes )
51
52
transport .Transport = socketTransport
53
+
54
+ if debug {
55
+ transport .SetDebug (debug )
56
+ }
57
+
58
+ if logger != nil {
59
+ transport .SetLogger (logger )
60
+ }
61
+
52
62
httpClient .SetTransport (transport )
53
63
54
64
return & FirecrackerClient {client : httpClient }
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ type Config struct {
80
80
NetworkInterfaces []NetworkInterface
81
81
VsockDevices []VsockDevice
82
82
Console string
83
+ Debug bool
83
84
machineCfg models.MachineConfiguration
84
85
}
85
86
@@ -143,11 +144,17 @@ func NewMachine(cfg Config, opts ...Opt) *Machine {
143
144
}
144
145
145
146
if m .logger == nil {
146
- m .logger = log .NewEntry (log .New ())
147
+ logger := log .New ()
148
+
149
+ if cfg .Debug {
150
+ logger .SetLevel (log .DebugLevel )
151
+ }
152
+
153
+ m .logger = log .NewEntry (logger )
147
154
}
148
155
149
156
if m .client == nil {
150
- m .client = NewFirecrackerClient (cfg .SocketPath )
157
+ m .client = NewFirecrackerClient (cfg .SocketPath , m . logger , cfg . Debug )
151
158
}
152
159
153
160
m .logger .Debug ("Called NewMachine()" )
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ func init() {
39
39
40
40
// Ensure that we can create a new machine
41
41
func TestNewMachine (t * testing.T ) {
42
- m := NewMachine (Config {})
42
+ m := NewMachine (Config {Debug : true })
43
43
if m == nil {
44
44
t .Errorf ("NewMachine did not create a Machine" )
45
45
}
@@ -62,6 +62,7 @@ func TestMicroVMExecution(t *testing.T) {
62
62
CPUCount : nCpus ,
63
63
CPUTemplate : cpuTemplate ,
64
64
MemInMiB : memSz ,
65
+ Debug : true ,
65
66
}
66
67
m := NewMachine (cfg )
67
68
ctx := context .Background ()
You can’t perform that action at this time.
0 commit comments