@@ -12,57 +12,63 @@ import (
1212)
1313
1414func (uvm * UtilityVM ) StartLogForwarding (ctx context.Context ) error {
15- // Implementation for stopping the log forwarder
16- if uvm .OS () == "windows" && uvm .gc ! = nil {
17- wcaps := gcs . GetWCOWCapabilities ( uvm . gc . Capabilities ())
18- if wcaps != nil && wcaps . IsLogForwardingSupported () {
19- req := guestrequest. LogForwardServiceRPCRequest {
20- RPCType : guestrequest . RPCStartLogForwarding ,
21- Settings : "" ,
22- }
23- err := uvm . gc . ModifyServiceSettings ( ctx , prot . LogForwardService , req )
24- if err != nil {
25- return err
26- }
27- } else {
28- log . G ( ctx ). WithField ( "os" , uvm . operatingSystem ). Error ( "Log forwarding not supported for this OS" )
15+ // Implementation for starting the log forwarding service
16+ if uvm .OS () != "windows" || uvm .gc = = nil {
17+ return errNotSupported
18+ }
19+
20+ wcaps := gcs . GetWCOWCapabilities ( uvm . gc . Capabilities ())
21+ if wcaps != nil && wcaps . IsLogForwardingSupported () {
22+ req := guestrequest. LogForwardServiceRPCRequest {
23+ RPCType : guestrequest . RPCStartLogForwarding ,
24+ Settings : "" ,
25+ }
26+ err := uvm . gc . ModifyServiceSettings ( ctx , prot . LogForwardService , req )
27+ if err != nil {
28+ return err
2929 }
30+ } else {
31+ log .G (ctx ).WithField ("os" , uvm .operatingSystem ).Error ("Log forwarding not supported for this OS" )
3032 }
3133 return nil
3234}
3335
3436func (uvm * UtilityVM ) StopLogForwarding (ctx context.Context ) error {
35- // Implementation for stopping the log forwarder
36- if uvm .OS () == "windows" && uvm .gc != nil {
37- wcaps := gcs .GetWCOWCapabilities (uvm .gc .Capabilities ())
38- if wcaps != nil && wcaps .IsLogForwardingSupported () {
39- req := guestrequest.LogForwardServiceRPCRequest {
40- RPCType : guestrequest .RPCStopLogForwarding ,
41- Settings : "" ,
42- }
43- err := uvm .gc .ModifyServiceSettings (ctx , prot .LogForwardService , req )
44- if err != nil {
45- return err
46- }
37+ // Implementation for stopping the log forwarding service
38+ if uvm .OS () != "windows" || uvm .gc == nil {
39+ return errNotSupported
40+ }
41+
42+ wcaps := gcs .GetWCOWCapabilities (uvm .gc .Capabilities ())
43+ if wcaps != nil && wcaps .IsLogForwardingSupported () {
44+ req := guestrequest.LogForwardServiceRPCRequest {
45+ RPCType : guestrequest .RPCStopLogForwarding ,
46+ Settings : "" ,
47+ }
48+ err := uvm .gc .ModifyServiceSettings (ctx , prot .LogForwardService , req )
49+ if err != nil {
50+ return err
4751 }
4852 }
4953 return nil
5054}
5155
5256func (uvm * UtilityVM ) SetLogSources (ctx context.Context ) error {
5357 // Implementation for setting the log sources
54- if uvm .OS () == "windows" && uvm .logSources != "" && uvm .gc != nil {
55- wcaps := gcs .GetWCOWCapabilities (uvm .gc .Capabilities ())
56- if wcaps != nil && wcaps .IsLogForwardingSupported () {
57- // Make a call to the GCS to set the ETW providers
58- req := guestrequest.LogForwardServiceRPCRequest {
59- RPCType : guestrequest .RPCModifyServiceSettings ,
60- Settings : uvm .logSources ,
61- }
62- err := uvm .gc .ModifyServiceSettings (ctx , prot .LogForwardService , req )
63- if err != nil {
64- return err
65- }
58+ if uvm .OS () != "windows" || uvm .gc == nil {
59+ return errNotSupported
60+ }
61+
62+ wcaps := gcs .GetWCOWCapabilities (uvm .gc .Capabilities ())
63+ if wcaps != nil && wcaps .IsLogForwardingSupported () {
64+ // Make a call to the GCS to set the ETW providers
65+ req := guestrequest.LogForwardServiceRPCRequest {
66+ RPCType : guestrequest .RPCModifyServiceSettings ,
67+ Settings : uvm .logSources ,
68+ }
69+ err := uvm .gc .ModifyServiceSettings (ctx , prot .LogForwardService , req )
70+ if err != nil {
71+ return err
6672 }
6773 }
6874 return nil
0 commit comments