Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 | 1 |
# the following lines are in sorted order, FYI |
| 2 | 2 |
github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109 |
| 3 |
-github.com/Microsoft/hcsshim v0.7.12-1 |
|
| 3 |
+github.com/Microsoft/hcsshim v0.8.3 |
|
| 4 | 4 |
github.com/Microsoft/go-winio v0.4.11 |
| 5 | 5 |
github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a |
| 6 | 6 |
github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git |
| ... | ... |
@@ -424,7 +424,7 @@ func (w *Writer) makeInode(f *File, node *inode) (*inode, error) {
|
| 424 | 424 |
case format.S_IFREG: |
| 425 | 425 |
size = f.Size |
| 426 | 426 |
if f.Size > maxFileSize {
|
| 427 |
- return nil, fmt.Errorf("file too big: %d > %d", f.Size, maxFileSize)
|
|
| 427 |
+ return nil, fmt.Errorf("file too big: %d > %d", f.Size, int64(maxFileSize))
|
|
| 428 | 428 |
} |
| 429 | 429 |
if f.Size <= inlineDataSize && w.supportInlineData {
|
| 430 | 430 |
node.Data = make([]byte, f.Size) |
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"syscall" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/Microsoft/hcsshim/internal/interop" |
| 8 |
+ "github.com/sirupsen/logrus" |
|
| 8 | 9 |
) |
| 9 | 10 |
|
| 10 | 11 |
var ( |
| ... | ... |
@@ -75,7 +76,13 @@ func notificationWatcher(notificationType hcsNotification, callbackNumber uintpt |
| 75 | 75 |
return 0 |
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 |
- context.channels[notificationType] <- result |
|
| 78 |
+ if channel, ok := context.channels[notificationType]; ok {
|
|
| 79 |
+ channel <- result |
|
| 80 |
+ } else {
|
|
| 81 |
+ logrus.WithFields(logrus.Fields{
|
|
| 82 |
+ "notification-type": notificationType, |
|
| 83 |
+ }).Warn("Received a callback of an unsupported type")
|
|
| 84 |
+ } |
|
| 79 | 85 |
|
| 80 | 86 |
return 0 |
| 81 | 87 |
} |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"syscall" |
| 8 | 8 |
|
| 9 | 9 |
"github.com/Microsoft/hcsshim/internal/interop" |
| 10 |
+ "github.com/Microsoft/hcsshim/internal/logfields" |
|
| 10 | 11 |
"github.com/sirupsen/logrus" |
| 11 | 12 |
) |
| 12 | 13 |
|
| ... | ... |
@@ -116,10 +117,14 @@ func (ev *ErrorEvent) String() string {
|
| 116 | 116 |
func processHcsResult(resultp *uint16) []ErrorEvent {
|
| 117 | 117 |
if resultp != nil {
|
| 118 | 118 |
resultj := interop.ConvertAndFreeCoTaskMemString(resultp) |
| 119 |
- logrus.Debugf("Result: %s", resultj)
|
|
| 119 |
+ logrus.WithField(logfields.JSON, resultj). |
|
| 120 |
+ Debug("HCS Result")
|
|
| 120 | 121 |
result := &hcsResult{}
|
| 121 | 122 |
if err := json.Unmarshal([]byte(resultj), result); err != nil {
|
| 122 |
- logrus.Warnf("Could not unmarshal HCS result %s: %s", resultj, err)
|
|
| 123 |
+ logrus.WithFields(logrus.Fields{
|
|
| 124 |
+ logfields.JSON: resultj, |
|
| 125 |
+ logrus.ErrorKey: err, |
|
| 126 |
+ }).Warning("Could not unmarshal HCS result")
|
|
| 123 | 127 |
return nil |
| 124 | 128 |
} |
| 125 | 129 |
return result.ErrorEvents |
| 126 | 130 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,15 @@ |
| 0 |
+package hcs |
|
| 1 |
+ |
|
| 2 |
+import "github.com/sirupsen/logrus" |
|
| 3 |
+ |
|
| 4 |
+func logOperationBegin(ctx logrus.Fields, msg string) {
|
|
| 5 |
+ logrus.WithFields(ctx).Debug(msg) |
|
| 6 |
+} |
|
| 7 |
+ |
|
| 8 |
+func logOperationEnd(ctx logrus.Fields, msg string, err error) {
|
|
| 9 |
+ if err == nil {
|
|
| 10 |
+ logrus.WithFields(ctx).Debug(msg) |
|
| 11 |
+ } else {
|
|
| 12 |
+ logrus.WithFields(ctx).WithError(err).Error(msg) |
|
| 13 |
+ } |
|
| 14 |
+} |
| ... | ... |
@@ -2,7 +2,6 @@ package hcs |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"encoding/json" |
| 5 |
- "fmt" |
|
| 6 | 5 |
"io" |
| 7 | 6 |
"sync" |
| 8 | 7 |
"syscall" |
| ... | ... |
@@ -10,6 +9,7 @@ import ( |
| 10 | 10 |
|
| 11 | 11 |
"github.com/Microsoft/hcsshim/internal/guestrequest" |
| 12 | 12 |
"github.com/Microsoft/hcsshim/internal/interop" |
| 13 |
+ "github.com/Microsoft/hcsshim/internal/logfields" |
|
| 13 | 14 |
"github.com/sirupsen/logrus" |
| 14 | 15 |
) |
| 15 | 16 |
|
| ... | ... |
@@ -21,6 +21,21 @@ type Process struct {
|
| 21 | 21 |
system *System |
| 22 | 22 |
cachedPipes *cachedPipes |
| 23 | 23 |
callbackNumber uintptr |
| 24 |
+ |
|
| 25 |
+ logctx logrus.Fields |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+func newProcess(process hcsProcess, processID int, computeSystem *System) *Process {
|
|
| 29 |
+ return &Process{
|
|
| 30 |
+ handle: process, |
|
| 31 |
+ processID: processID, |
|
| 32 |
+ system: computeSystem, |
|
| 33 |
+ logctx: logrus.Fields{
|
|
| 34 |
+ logfields.HCSOperation: "", |
|
| 35 |
+ logfields.ContainerID: computeSystem.ID(), |
|
| 36 |
+ logfields.ProcessID: processID, |
|
| 37 |
+ }, |
|
| 38 |
+ } |
|
| 24 | 39 |
} |
| 25 | 40 |
|
| 26 | 41 |
type cachedPipes struct {
|
| ... | ... |
@@ -72,13 +87,36 @@ func (process *Process) SystemID() string {
|
| 72 | 72 |
return process.system.ID() |
| 73 | 73 |
} |
| 74 | 74 |
|
| 75 |
+func (process *Process) logOperationBegin(operation string) {
|
|
| 76 |
+ process.logctx[logfields.HCSOperation] = operation |
|
| 77 |
+ logOperationBegin( |
|
| 78 |
+ process.logctx, |
|
| 79 |
+ "hcsshim::Process - Begin Operation") |
|
| 80 |
+} |
|
| 81 |
+ |
|
| 82 |
+func (process *Process) logOperationEnd(err error) {
|
|
| 83 |
+ var result string |
|
| 84 |
+ if err == nil {
|
|
| 85 |
+ result = "Success" |
|
| 86 |
+ } else {
|
|
| 87 |
+ result = "Error" |
|
| 88 |
+ } |
|
| 89 |
+ |
|
| 90 |
+ logOperationEnd( |
|
| 91 |
+ process.logctx, |
|
| 92 |
+ "hcsshim::Process - End Operation - "+result, |
|
| 93 |
+ err) |
|
| 94 |
+ process.logctx[logfields.HCSOperation] = "" |
|
| 95 |
+} |
|
| 96 |
+ |
|
| 75 | 97 |
// Signal signals the process with `options`. |
| 76 |
-func (process *Process) Signal(options guestrequest.SignalProcessOptions) error {
|
|
| 98 |
+func (process *Process) Signal(options guestrequest.SignalProcessOptions) (err error) {
|
|
| 77 | 99 |
process.handleLock.RLock() |
| 78 | 100 |
defer process.handleLock.RUnlock() |
| 79 |
- operation := "Signal" |
|
| 80 |
- title := "hcsshim::Process::" + operation |
|
| 81 |
- logrus.Debugf(title+" processid=%d", process.processID) |
|
| 101 |
+ |
|
| 102 |
+ operation := "hcsshim::Process::Signal" |
|
| 103 |
+ process.logOperationBegin(operation) |
|
| 104 |
+ defer process.logOperationEnd(err) |
|
| 82 | 105 |
|
| 83 | 106 |
if process.handle == 0 {
|
| 84 | 107 |
return makeProcessError(process, operation, ErrAlreadyClosed, nil) |
| ... | ... |
@@ -93,7 +131,7 @@ func (process *Process) Signal(options guestrequest.SignalProcessOptions) error |
| 93 | 93 |
|
| 94 | 94 |
var resultp *uint16 |
| 95 | 95 |
completed := false |
| 96 |
- go syscallWatcher(fmt.Sprintf("SignalProcess %s: %d", process.SystemID(), process.Pid()), &completed)
|
|
| 96 |
+ go syscallWatcher(process.logctx, &completed) |
|
| 97 | 97 |
err = hcsSignalProcess(process.handle, optionsStr, &resultp) |
| 98 | 98 |
completed = true |
| 99 | 99 |
events := processHcsResult(resultp) |
| ... | ... |
@@ -101,17 +139,17 @@ func (process *Process) Signal(options guestrequest.SignalProcessOptions) error |
| 101 | 101 |
return makeProcessError(process, operation, err, events) |
| 102 | 102 |
} |
| 103 | 103 |
|
| 104 |
- logrus.Debugf(title+" succeeded processid=%d", process.processID) |
|
| 105 | 104 |
return nil |
| 106 | 105 |
} |
| 107 | 106 |
|
| 108 | 107 |
// Kill signals the process to terminate but does not wait for it to finish terminating. |
| 109 |
-func (process *Process) Kill() error {
|
|
| 108 |
+func (process *Process) Kill() (err error) {
|
|
| 110 | 109 |
process.handleLock.RLock() |
| 111 | 110 |
defer process.handleLock.RUnlock() |
| 112 |
- operation := "Kill" |
|
| 113 |
- title := "hcsshim::Process::" + operation |
|
| 114 |
- logrus.Debugf(title+" processid=%d", process.processID) |
|
| 111 |
+ |
|
| 112 |
+ operation := "hcsshim::Process::Kill" |
|
| 113 |
+ process.logOperationBegin(operation) |
|
| 114 |
+ defer process.logOperationEnd(err) |
|
| 115 | 115 |
|
| 116 | 116 |
if process.handle == 0 {
|
| 117 | 117 |
return makeProcessError(process, operation, ErrAlreadyClosed, nil) |
| ... | ... |
@@ -119,56 +157,54 @@ func (process *Process) Kill() error {
|
| 119 | 119 |
|
| 120 | 120 |
var resultp *uint16 |
| 121 | 121 |
completed := false |
| 122 |
- go syscallWatcher(fmt.Sprintf("TerminateProcess %s: %d", process.SystemID(), process.Pid()), &completed)
|
|
| 123 |
- err := hcsTerminateProcess(process.handle, &resultp) |
|
| 122 |
+ go syscallWatcher(process.logctx, &completed) |
|
| 123 |
+ err = hcsTerminateProcess(process.handle, &resultp) |
|
| 124 | 124 |
completed = true |
| 125 | 125 |
events := processHcsResult(resultp) |
| 126 | 126 |
if err != nil {
|
| 127 | 127 |
return makeProcessError(process, operation, err, events) |
| 128 | 128 |
} |
| 129 | 129 |
|
| 130 |
- logrus.Debugf(title+" succeeded processid=%d", process.processID) |
|
| 131 | 130 |
return nil |
| 132 | 131 |
} |
| 133 | 132 |
|
| 134 | 133 |
// Wait waits for the process to exit. |
| 135 |
-func (process *Process) Wait() error {
|
|
| 136 |
- operation := "Wait" |
|
| 137 |
- title := "hcsshim::Process::" + operation |
|
| 138 |
- logrus.Debugf(title+" processid=%d", process.processID) |
|
| 134 |
+func (process *Process) Wait() (err error) {
|
|
| 135 |
+ operation := "hcsshim::Process::Wait" |
|
| 136 |
+ process.logOperationBegin(operation) |
|
| 137 |
+ defer process.logOperationEnd(err) |
|
| 139 | 138 |
|
| 140 |
- err := waitForNotification(process.callbackNumber, hcsNotificationProcessExited, nil) |
|
| 139 |
+ err = waitForNotification(process.callbackNumber, hcsNotificationProcessExited, nil) |
|
| 141 | 140 |
if err != nil {
|
| 142 | 141 |
return makeProcessError(process, operation, err, nil) |
| 143 | 142 |
} |
| 144 | 143 |
|
| 145 |
- logrus.Debugf(title+" succeeded processid=%d", process.processID) |
|
| 146 | 144 |
return nil |
| 147 | 145 |
} |
| 148 | 146 |
|
| 149 | 147 |
// WaitTimeout waits for the process to exit or the duration to elapse. It returns |
| 150 | 148 |
// false if timeout occurs. |
| 151 |
-func (process *Process) WaitTimeout(timeout time.Duration) error {
|
|
| 152 |
- operation := "WaitTimeout" |
|
| 153 |
- title := "hcsshim::Process::" + operation |
|
| 154 |
- logrus.Debugf(title+" processid=%d", process.processID) |
|
| 149 |
+func (process *Process) WaitTimeout(timeout time.Duration) (err error) {
|
|
| 150 |
+ operation := "hcssshim::Process::WaitTimeout" |
|
| 151 |
+ process.logOperationBegin(operation) |
|
| 152 |
+ defer process.logOperationEnd(err) |
|
| 155 | 153 |
|
| 156 |
- err := waitForNotification(process.callbackNumber, hcsNotificationProcessExited, &timeout) |
|
| 154 |
+ err = waitForNotification(process.callbackNumber, hcsNotificationProcessExited, &timeout) |
|
| 157 | 155 |
if err != nil {
|
| 158 | 156 |
return makeProcessError(process, operation, err, nil) |
| 159 | 157 |
} |
| 160 | 158 |
|
| 161 |
- logrus.Debugf(title+" succeeded processid=%d", process.processID) |
|
| 162 | 159 |
return nil |
| 163 | 160 |
} |
| 164 | 161 |
|
| 165 | 162 |
// ResizeConsole resizes the console of the process. |
| 166 |
-func (process *Process) ResizeConsole(width, height uint16) error {
|
|
| 163 |
+func (process *Process) ResizeConsole(width, height uint16) (err error) {
|
|
| 167 | 164 |
process.handleLock.RLock() |
| 168 | 165 |
defer process.handleLock.RUnlock() |
| 169 |
- operation := "ResizeConsole" |
|
| 170 |
- title := "hcsshim::Process::" + operation |
|
| 171 |
- logrus.Debugf(title+" processid=%d", process.processID) |
|
| 166 |
+ |
|
| 167 |
+ operation := "hcsshim::Process::ResizeConsole" |
|
| 168 |
+ process.logOperationBegin(operation) |
|
| 169 |
+ defer process.logOperationEnd(err) |
|
| 172 | 170 |
|
| 173 | 171 |
if process.handle == 0 {
|
| 174 | 172 |
return makeProcessError(process, operation, ErrAlreadyClosed, nil) |
| ... | ... |
@@ -196,16 +232,16 @@ func (process *Process) ResizeConsole(width, height uint16) error {
|
| 196 | 196 |
return makeProcessError(process, operation, err, events) |
| 197 | 197 |
} |
| 198 | 198 |
|
| 199 |
- logrus.Debugf(title+" succeeded processid=%d", process.processID) |
|
| 200 | 199 |
return nil |
| 201 | 200 |
} |
| 202 | 201 |
|
| 203 |
-func (process *Process) Properties() (*ProcessStatus, error) {
|
|
| 202 |
+func (process *Process) Properties() (_ *ProcessStatus, err error) {
|
|
| 204 | 203 |
process.handleLock.RLock() |
| 205 | 204 |
defer process.handleLock.RUnlock() |
| 206 |
- operation := "Properties" |
|
| 207 |
- title := "hcsshim::Process::" + operation |
|
| 208 |
- logrus.Debugf(title+" processid=%d", process.processID) |
|
| 205 |
+ |
|
| 206 |
+ operation := "hcsshim::Process::Properties" |
|
| 207 |
+ process.logOperationBegin(operation) |
|
| 208 |
+ defer process.logOperationEnd(err) |
|
| 209 | 209 |
|
| 210 | 210 |
if process.handle == 0 {
|
| 211 | 211 |
return nil, makeProcessError(process, operation, ErrAlreadyClosed, nil) |
| ... | ... |
@@ -216,8 +252,8 @@ func (process *Process) Properties() (*ProcessStatus, error) {
|
| 216 | 216 |
propertiesp *uint16 |
| 217 | 217 |
) |
| 218 | 218 |
completed := false |
| 219 |
- go syscallWatcher(fmt.Sprintf("GetProcessProperties %s: %d", process.SystemID(), process.Pid()), &completed)
|
|
| 220 |
- err := hcsGetProcessProperties(process.handle, &propertiesp, &resultp) |
|
| 219 |
+ go syscallWatcher(process.logctx, &completed) |
|
| 220 |
+ err = hcsGetProcessProperties(process.handle, &propertiesp, &resultp) |
|
| 221 | 221 |
completed = true |
| 222 | 222 |
events := processHcsResult(resultp) |
| 223 | 223 |
if err != nil {
|
| ... | ... |
@@ -234,14 +270,16 @@ func (process *Process) Properties() (*ProcessStatus, error) {
|
| 234 | 234 |
return nil, makeProcessError(process, operation, err, nil) |
| 235 | 235 |
} |
| 236 | 236 |
|
| 237 |
- logrus.Debugf(title+" succeeded processid=%d, properties=%s", process.processID, propertiesRaw) |
|
| 238 | 237 |
return properties, nil |
| 239 | 238 |
} |
| 240 | 239 |
|
| 241 | 240 |
// ExitCode returns the exit code of the process. The process must have |
| 242 | 241 |
// already terminated. |
| 243 |
-func (process *Process) ExitCode() (int, error) {
|
|
| 244 |
- operation := "ExitCode" |
|
| 242 |
+func (process *Process) ExitCode() (_ int, err error) {
|
|
| 243 |
+ operation := "hcsshim::Process::ExitCode" |
|
| 244 |
+ process.logOperationBegin(operation) |
|
| 245 |
+ defer process.logOperationEnd(err) |
|
| 246 |
+ |
|
| 245 | 247 |
properties, err := process.Properties() |
| 246 | 248 |
if err != nil {
|
| 247 | 249 |
return 0, makeProcessError(process, operation, err, nil) |
| ... | ... |
@@ -261,12 +299,13 @@ func (process *Process) ExitCode() (int, error) {
|
| 261 | 261 |
// Stdio returns the stdin, stdout, and stderr pipes, respectively. Closing |
| 262 | 262 |
// these pipes does not close the underlying pipes; it should be possible to |
| 263 | 263 |
// call this multiple times to get multiple interfaces. |
| 264 |
-func (process *Process) Stdio() (io.WriteCloser, io.ReadCloser, io.ReadCloser, error) {
|
|
| 264 |
+func (process *Process) Stdio() (_ io.WriteCloser, _ io.ReadCloser, _ io.ReadCloser, err error) {
|
|
| 265 | 265 |
process.handleLock.RLock() |
| 266 | 266 |
defer process.handleLock.RUnlock() |
| 267 |
- operation := "Stdio" |
|
| 268 |
- title := "hcsshim::Process::" + operation |
|
| 269 |
- logrus.Debugf(title+" processid=%d", process.processID) |
|
| 267 |
+ |
|
| 268 |
+ operation := "hcsshim::Process::Stdio" |
|
| 269 |
+ process.logOperationBegin(operation) |
|
| 270 |
+ defer process.logOperationEnd(err) |
|
| 270 | 271 |
|
| 271 | 272 |
if process.handle == 0 {
|
| 272 | 273 |
return nil, nil, nil, makeProcessError(process, operation, ErrAlreadyClosed, nil) |
| ... | ... |
@@ -279,7 +318,7 @@ func (process *Process) Stdio() (io.WriteCloser, io.ReadCloser, io.ReadCloser, e |
| 279 | 279 |
processInfo hcsProcessInformation |
| 280 | 280 |
resultp *uint16 |
| 281 | 281 |
) |
| 282 |
- err := hcsGetProcessInfo(process.handle, &processInfo, &resultp) |
|
| 282 |
+ err = hcsGetProcessInfo(process.handle, &processInfo, &resultp) |
|
| 283 | 283 |
events := processHcsResult(resultp) |
| 284 | 284 |
if err != nil {
|
| 285 | 285 |
return nil, nil, nil, makeProcessError(process, operation, err, events) |
| ... | ... |
@@ -299,18 +338,18 @@ func (process *Process) Stdio() (io.WriteCloser, io.ReadCloser, io.ReadCloser, e |
| 299 | 299 |
return nil, nil, nil, makeProcessError(process, operation, err, nil) |
| 300 | 300 |
} |
| 301 | 301 |
|
| 302 |
- logrus.Debugf(title+" succeeded processid=%d", process.processID) |
|
| 303 | 302 |
return pipes[0], pipes[1], pipes[2], nil |
| 304 | 303 |
} |
| 305 | 304 |
|
| 306 | 305 |
// CloseStdin closes the write side of the stdin pipe so that the process is |
| 307 | 306 |
// notified on the read side that there is no more data in stdin. |
| 308 |
-func (process *Process) CloseStdin() error {
|
|
| 307 |
+func (process *Process) CloseStdin() (err error) {
|
|
| 309 | 308 |
process.handleLock.RLock() |
| 310 | 309 |
defer process.handleLock.RUnlock() |
| 311 |
- operation := "CloseStdin" |
|
| 312 |
- title := "hcsshim::Process::" + operation |
|
| 313 |
- logrus.Debugf(title+" processid=%d", process.processID) |
|
| 310 |
+ |
|
| 311 |
+ operation := "hcsshim::Process::CloseStdin" |
|
| 312 |
+ process.logOperationBegin(operation) |
|
| 313 |
+ defer process.logOperationEnd(err) |
|
| 314 | 314 |
|
| 315 | 315 |
if process.handle == 0 {
|
| 316 | 316 |
return makeProcessError(process, operation, ErrAlreadyClosed, nil) |
| ... | ... |
@@ -337,35 +376,34 @@ func (process *Process) CloseStdin() error {
|
| 337 | 337 |
return makeProcessError(process, operation, err, events) |
| 338 | 338 |
} |
| 339 | 339 |
|
| 340 |
- logrus.Debugf(title+" succeeded processid=%d", process.processID) |
|
| 341 | 340 |
return nil |
| 342 | 341 |
} |
| 343 | 342 |
|
| 344 | 343 |
// Close cleans up any state associated with the process but does not kill |
| 345 | 344 |
// or wait on it. |
| 346 |
-func (process *Process) Close() error {
|
|
| 345 |
+func (process *Process) Close() (err error) {
|
|
| 347 | 346 |
process.handleLock.Lock() |
| 348 | 347 |
defer process.handleLock.Unlock() |
| 349 |
- operation := "Close" |
|
| 350 |
- title := "hcsshim::Process::" + operation |
|
| 351 |
- logrus.Debugf(title+" processid=%d", process.processID) |
|
| 348 |
+ |
|
| 349 |
+ operation := "hcsshim::Process::Close" |
|
| 350 |
+ process.logOperationBegin(operation) |
|
| 351 |
+ defer process.logOperationEnd(err) |
|
| 352 | 352 |
|
| 353 | 353 |
// Don't double free this |
| 354 | 354 |
if process.handle == 0 {
|
| 355 | 355 |
return nil |
| 356 | 356 |
} |
| 357 | 357 |
|
| 358 |
- if err := process.unregisterCallback(); err != nil {
|
|
| 358 |
+ if err = process.unregisterCallback(); err != nil {
|
|
| 359 | 359 |
return makeProcessError(process, operation, err, nil) |
| 360 | 360 |
} |
| 361 | 361 |
|
| 362 |
- if err := hcsCloseProcess(process.handle); err != nil {
|
|
| 362 |
+ if err = hcsCloseProcess(process.handle); err != nil {
|
|
| 363 | 363 |
return makeProcessError(process, operation, err, nil) |
| 364 | 364 |
} |
| 365 | 365 |
|
| 366 | 366 |
process.handle = 0 |
| 367 | 367 |
|
| 368 |
- logrus.Debugf(title+" succeeded processid=%d", process.processID) |
|
| 369 | 368 |
return nil |
| 370 | 369 |
} |
| 371 | 370 |
|
| ... | ... |
@@ -2,7 +2,6 @@ package hcs |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"encoding/json" |
| 5 |
- "fmt" |
|
| 6 | 5 |
"os" |
| 7 | 6 |
"strconv" |
| 8 | 7 |
"sync" |
| ... | ... |
@@ -10,6 +9,7 @@ import ( |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 | 12 |
"github.com/Microsoft/hcsshim/internal/interop" |
| 13 |
+ "github.com/Microsoft/hcsshim/internal/logfields" |
|
| 13 | 14 |
"github.com/Microsoft/hcsshim/internal/schema1" |
| 14 | 15 |
"github.com/Microsoft/hcsshim/internal/timeout" |
| 15 | 16 |
"github.com/sirupsen/logrus" |
| ... | ... |
@@ -41,16 +41,49 @@ type System struct {
|
| 41 | 41 |
handle hcsSystem |
| 42 | 42 |
id string |
| 43 | 43 |
callbackNumber uintptr |
| 44 |
-} |
|
| 45 | 44 |
|
| 46 |
-// CreateComputeSystem creates a new compute system with the given configuration but does not start it. |
|
| 47 |
-func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (*System, error) {
|
|
| 48 |
- operation := "CreateComputeSystem" |
|
| 49 |
- title := "hcsshim::" + operation |
|
| 45 |
+ logctx logrus.Fields |
|
| 46 |
+} |
|
| 50 | 47 |
|
| 51 |
- computeSystem := &System{
|
|
| 48 |
+func newSystem(id string) *System {
|
|
| 49 |
+ return &System{
|
|
| 52 | 50 |
id: id, |
| 51 |
+ logctx: logrus.Fields{
|
|
| 52 |
+ logfields.HCSOperation: "", |
|
| 53 |
+ logfields.ContainerID: id, |
|
| 54 |
+ }, |
|
| 53 | 55 |
} |
| 56 |
+} |
|
| 57 |
+ |
|
| 58 |
+func (computeSystem *System) logOperationBegin(operation string) {
|
|
| 59 |
+ computeSystem.logctx[logfields.HCSOperation] = operation |
|
| 60 |
+ logOperationBegin( |
|
| 61 |
+ computeSystem.logctx, |
|
| 62 |
+ "hcsshim::ComputeSystem - Begin Operation") |
|
| 63 |
+} |
|
| 64 |
+ |
|
| 65 |
+func (computeSystem *System) logOperationEnd(err error) {
|
|
| 66 |
+ var result string |
|
| 67 |
+ if err == nil {
|
|
| 68 |
+ result = "Success" |
|
| 69 |
+ } else {
|
|
| 70 |
+ result = "Error" |
|
| 71 |
+ } |
|
| 72 |
+ |
|
| 73 |
+ logOperationEnd( |
|
| 74 |
+ computeSystem.logctx, |
|
| 75 |
+ "hcsshim::ComputeSystem - End Operation - "+result, |
|
| 76 |
+ err) |
|
| 77 |
+ computeSystem.logctx[logfields.HCSOperation] = "" |
|
| 78 |
+} |
|
| 79 |
+ |
|
| 80 |
+// CreateComputeSystem creates a new compute system with the given configuration but does not start it. |
|
| 81 |
+func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (_ *System, err error) {
|
|
| 82 |
+ operation := "hcsshim::CreateComputeSystem" |
|
| 83 |
+ |
|
| 84 |
+ computeSystem := newSystem(id) |
|
| 85 |
+ computeSystem.logOperationBegin(operation) |
|
| 86 |
+ defer computeSystem.logOperationEnd(err) |
|
| 54 | 87 |
|
| 55 | 88 |
hcsDocumentB, err := json.Marshal(hcsDocumentInterface) |
| 56 | 89 |
if err != nil {
|
| ... | ... |
@@ -58,19 +91,22 @@ func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (*System,
|
| 58 | 58 |
} |
| 59 | 59 |
|
| 60 | 60 |
hcsDocument := string(hcsDocumentB) |
| 61 |
- logrus.Debugf(title+" ID=%s config=%s", id, hcsDocument) |
|
| 61 |
+ |
|
| 62 |
+ logrus.WithFields(computeSystem.logctx). |
|
| 63 |
+ WithField(logfields.JSON, hcsDocument). |
|
| 64 |
+ Debug("HCS ComputeSystem Document")
|
|
| 62 | 65 |
|
| 63 | 66 |
var ( |
| 64 | 67 |
resultp *uint16 |
| 65 | 68 |
identity syscall.Handle |
| 66 | 69 |
) |
| 67 | 70 |
completed := false |
| 68 |
- go syscallWatcher(fmt.Sprintf("CreateCompleteSystem %s: %s", id, hcsDocument), &completed)
|
|
| 71 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 69 | 72 |
createError := hcsCreateComputeSystem(id, hcsDocument, identity, &computeSystem.handle, &resultp) |
| 70 | 73 |
completed = true |
| 71 | 74 |
|
| 72 | 75 |
if createError == nil || IsPending(createError) {
|
| 73 |
- if err := computeSystem.registerCallback(); err != nil {
|
|
| 76 |
+ if err = computeSystem.registerCallback(); err != nil {
|
|
| 74 | 77 |
// Terminate the compute system if it still exists. We're okay to |
| 75 | 78 |
// ignore a failure here. |
| 76 | 79 |
computeSystem.Terminate() |
| ... | ... |
@@ -88,25 +124,22 @@ func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (*System,
|
| 88 | 88 |
return nil, makeSystemError(computeSystem, operation, hcsDocument, err, events) |
| 89 | 89 |
} |
| 90 | 90 |
|
| 91 |
- logrus.Debugf(title+" succeeded id=%s handle=%d", id, computeSystem.handle) |
|
| 92 | 91 |
return computeSystem, nil |
| 93 | 92 |
} |
| 94 | 93 |
|
| 95 | 94 |
// OpenComputeSystem opens an existing compute system by ID. |
| 96 |
-func OpenComputeSystem(id string) (*System, error) {
|
|
| 97 |
- operation := "OpenComputeSystem" |
|
| 98 |
- title := "hcsshim::" + operation |
|
| 99 |
- logrus.Debugf(title+" ID=%s", id) |
|
| 95 |
+func OpenComputeSystem(id string) (_ *System, err error) {
|
|
| 96 |
+ operation := "hcsshim::OpenComputeSystem" |
|
| 100 | 97 |
|
| 101 |
- computeSystem := &System{
|
|
| 102 |
- id: id, |
|
| 103 |
- } |
|
| 98 |
+ computeSystem := newSystem(id) |
|
| 99 |
+ computeSystem.logOperationBegin(operation) |
|
| 100 |
+ defer computeSystem.logOperationEnd(err) |
|
| 104 | 101 |
|
| 105 | 102 |
var ( |
| 106 | 103 |
handle hcsSystem |
| 107 | 104 |
resultp *uint16 |
| 108 | 105 |
) |
| 109 |
- err := hcsOpenComputeSystem(id, &handle, &resultp) |
|
| 106 |
+ err = hcsOpenComputeSystem(id, &handle, &resultp) |
|
| 110 | 107 |
events := processHcsResult(resultp) |
| 111 | 108 |
if err != nil {
|
| 112 | 109 |
return nil, makeSystemError(computeSystem, operation, "", err, events) |
| ... | ... |
@@ -114,18 +147,36 @@ func OpenComputeSystem(id string) (*System, error) {
|
| 114 | 114 |
|
| 115 | 115 |
computeSystem.handle = handle |
| 116 | 116 |
|
| 117 |
- if err := computeSystem.registerCallback(); err != nil {
|
|
| 117 |
+ if err = computeSystem.registerCallback(); err != nil {
|
|
| 118 | 118 |
return nil, makeSystemError(computeSystem, operation, "", err, nil) |
| 119 | 119 |
} |
| 120 | 120 |
|
| 121 |
- logrus.Debugf(title+" succeeded id=%s handle=%d", id, handle) |
|
| 122 | 121 |
return computeSystem, nil |
| 123 | 122 |
} |
| 124 | 123 |
|
| 125 | 124 |
// GetComputeSystems gets a list of the compute systems on the system that match the query |
| 126 |
-func GetComputeSystems(q schema1.ComputeSystemQuery) ([]schema1.ContainerProperties, error) {
|
|
| 127 |
- operation := "GetComputeSystems" |
|
| 128 |
- title := "hcsshim::" + operation |
|
| 125 |
+func GetComputeSystems(q schema1.ComputeSystemQuery) (_ []schema1.ContainerProperties, err error) {
|
|
| 126 |
+ operation := "hcsshim::GetComputeSystems" |
|
| 127 |
+ fields := logrus.Fields{
|
|
| 128 |
+ logfields.HCSOperation: operation, |
|
| 129 |
+ } |
|
| 130 |
+ logOperationBegin( |
|
| 131 |
+ fields, |
|
| 132 |
+ "hcsshim::ComputeSystem - Begin Operation") |
|
| 133 |
+ |
|
| 134 |
+ defer func() {
|
|
| 135 |
+ var result string |
|
| 136 |
+ if err == nil {
|
|
| 137 |
+ result = "Success" |
|
| 138 |
+ } else {
|
|
| 139 |
+ result = "Error" |
|
| 140 |
+ } |
|
| 141 |
+ |
|
| 142 |
+ logOperationEnd( |
|
| 143 |
+ fields, |
|
| 144 |
+ "hcsshim::ComputeSystem - End Operation - "+result, |
|
| 145 |
+ err) |
|
| 146 |
+ }() |
|
| 129 | 147 |
|
| 130 | 148 |
queryb, err := json.Marshal(q) |
| 131 | 149 |
if err != nil {
|
| ... | ... |
@@ -133,14 +184,17 @@ func GetComputeSystems(q schema1.ComputeSystemQuery) ([]schema1.ContainerPropert |
| 133 | 133 |
} |
| 134 | 134 |
|
| 135 | 135 |
query := string(queryb) |
| 136 |
- logrus.Debugf(title+" query=%s", query) |
|
| 136 |
+ |
|
| 137 |
+ logrus.WithFields(fields). |
|
| 138 |
+ WithField(logfields.JSON, query). |
|
| 139 |
+ Debug("HCS ComputeSystem Query")
|
|
| 137 | 140 |
|
| 138 | 141 |
var ( |
| 139 | 142 |
resultp *uint16 |
| 140 | 143 |
computeSystemsp *uint16 |
| 141 | 144 |
) |
| 142 | 145 |
completed := false |
| 143 |
- go syscallWatcher(fmt.Sprintf("GetComputeSystems %s:", query), &completed)
|
|
| 146 |
+ go syscallWatcher(fields, &completed) |
|
| 144 | 147 |
err = hcsEnumerateComputeSystems(query, &computeSystemsp, &resultp) |
| 145 | 148 |
completed = true |
| 146 | 149 |
events := processHcsResult(resultp) |
| ... | ... |
@@ -153,20 +207,21 @@ func GetComputeSystems(q schema1.ComputeSystemQuery) ([]schema1.ContainerPropert |
| 153 | 153 |
} |
| 154 | 154 |
computeSystemsRaw := interop.ConvertAndFreeCoTaskMemBytes(computeSystemsp) |
| 155 | 155 |
computeSystems := []schema1.ContainerProperties{}
|
| 156 |
- if err := json.Unmarshal(computeSystemsRaw, &computeSystems); err != nil {
|
|
| 156 |
+ if err = json.Unmarshal(computeSystemsRaw, &computeSystems); err != nil {
|
|
| 157 | 157 |
return nil, err |
| 158 | 158 |
} |
| 159 | 159 |
|
| 160 |
- logrus.Debugf(title + " succeeded") |
|
| 161 | 160 |
return computeSystems, nil |
| 162 | 161 |
} |
| 163 | 162 |
|
| 164 | 163 |
// Start synchronously starts the computeSystem. |
| 165 |
-func (computeSystem *System) Start() error {
|
|
| 164 |
+func (computeSystem *System) Start() (err error) {
|
|
| 166 | 165 |
computeSystem.handleLock.RLock() |
| 167 | 166 |
defer computeSystem.handleLock.RUnlock() |
| 168 |
- title := "hcsshim::ComputeSystem::Start ID=" + computeSystem.ID() |
|
| 169 |
- logrus.Debugf(title) |
|
| 167 |
+ |
|
| 168 |
+ operation := "hcsshim::ComputeSystem::Start" |
|
| 169 |
+ computeSystem.logOperationBegin(operation) |
|
| 170 |
+ defer computeSystem.logOperationEnd(err) |
|
| 170 | 171 |
|
| 171 | 172 |
if computeSystem.handle == 0 {
|
| 172 | 173 |
return makeSystemError(computeSystem, "Start", "", ErrAlreadyClosed, nil) |
| ... | ... |
@@ -200,15 +255,14 @@ func (computeSystem *System) Start() error {
|
| 200 | 200 |
|
| 201 | 201 |
var resultp *uint16 |
| 202 | 202 |
completed := false |
| 203 |
- go syscallWatcher(fmt.Sprintf("StartComputeSystem %s:", computeSystem.ID()), &completed)
|
|
| 204 |
- err := hcsStartComputeSystem(computeSystem.handle, "", &resultp) |
|
| 203 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 204 |
+ err = hcsStartComputeSystem(computeSystem.handle, "", &resultp) |
|
| 205 | 205 |
completed = true |
| 206 | 206 |
events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemStartCompleted, &timeout.SystemStart) |
| 207 | 207 |
if err != nil {
|
| 208 | 208 |
return makeSystemError(computeSystem, "Start", "", err, events) |
| 209 | 209 |
} |
| 210 | 210 |
|
| 211 |
- logrus.Debugf(title + " succeeded") |
|
| 212 | 211 |
return nil |
| 213 | 212 |
} |
| 214 | 213 |
|
| ... | ... |
@@ -219,36 +273,40 @@ func (computeSystem *System) ID() string {
|
| 219 | 219 |
|
| 220 | 220 |
// Shutdown requests a compute system shutdown, if IsPending() on the error returned is true, |
| 221 | 221 |
// it may not actually be shut down until Wait() succeeds. |
| 222 |
-func (computeSystem *System) Shutdown() error {
|
|
| 222 |
+func (computeSystem *System) Shutdown() (err error) {
|
|
| 223 | 223 |
computeSystem.handleLock.RLock() |
| 224 | 224 |
defer computeSystem.handleLock.RUnlock() |
| 225 |
- title := "hcsshim::ComputeSystem::Shutdown" |
|
| 226 |
- logrus.Debugf(title) |
|
| 225 |
+ |
|
| 226 |
+ operation := "hcsshim::ComputeSystem::Shutdown" |
|
| 227 |
+ computeSystem.logOperationBegin(operation) |
|
| 228 |
+ defer computeSystem.logOperationEnd(err) |
|
| 229 |
+ |
|
| 227 | 230 |
if computeSystem.handle == 0 {
|
| 228 | 231 |
return makeSystemError(computeSystem, "Shutdown", "", ErrAlreadyClosed, nil) |
| 229 | 232 |
} |
| 230 | 233 |
|
| 231 | 234 |
var resultp *uint16 |
| 232 | 235 |
completed := false |
| 233 |
- go syscallWatcher(fmt.Sprintf("ShutdownComputeSystem %s:", computeSystem.ID()), &completed)
|
|
| 234 |
- err := hcsShutdownComputeSystem(computeSystem.handle, "", &resultp) |
|
| 236 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 237 |
+ err = hcsShutdownComputeSystem(computeSystem.handle, "", &resultp) |
|
| 235 | 238 |
completed = true |
| 236 | 239 |
events := processHcsResult(resultp) |
| 237 | 240 |
if err != nil {
|
| 238 | 241 |
return makeSystemError(computeSystem, "Shutdown", "", err, events) |
| 239 | 242 |
} |
| 240 | 243 |
|
| 241 |
- logrus.Debugf(title + " succeeded") |
|
| 242 | 244 |
return nil |
| 243 | 245 |
} |
| 244 | 246 |
|
| 245 | 247 |
// Terminate requests a compute system terminate, if IsPending() on the error returned is true, |
| 246 | 248 |
// it may not actually be shut down until Wait() succeeds. |
| 247 |
-func (computeSystem *System) Terminate() error {
|
|
| 249 |
+func (computeSystem *System) Terminate() (err error) {
|
|
| 248 | 250 |
computeSystem.handleLock.RLock() |
| 249 | 251 |
defer computeSystem.handleLock.RUnlock() |
| 250 |
- title := "hcsshim::ComputeSystem::Terminate ID=" + computeSystem.ID() |
|
| 251 |
- logrus.Debugf(title) |
|
| 252 |
+ |
|
| 253 |
+ operation := "hcsshim::ComputeSystem::Terminate" |
|
| 254 |
+ computeSystem.logOperationBegin(operation) |
|
| 255 |
+ defer computeSystem.logOperationEnd(err) |
|
| 252 | 256 |
|
| 253 | 257 |
if computeSystem.handle == 0 {
|
| 254 | 258 |
return makeSystemError(computeSystem, "Terminate", "", ErrAlreadyClosed, nil) |
| ... | ... |
@@ -256,59 +314,66 @@ func (computeSystem *System) Terminate() error {
|
| 256 | 256 |
|
| 257 | 257 |
var resultp *uint16 |
| 258 | 258 |
completed := false |
| 259 |
- go syscallWatcher(fmt.Sprintf("TerminateComputeSystem %s:", computeSystem.ID()), &completed)
|
|
| 260 |
- err := hcsTerminateComputeSystem(computeSystem.handle, "", &resultp) |
|
| 259 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 260 |
+ err = hcsTerminateComputeSystem(computeSystem.handle, "", &resultp) |
|
| 261 | 261 |
completed = true |
| 262 | 262 |
events := processHcsResult(resultp) |
| 263 | 263 |
if err != nil {
|
| 264 | 264 |
return makeSystemError(computeSystem, "Terminate", "", err, events) |
| 265 | 265 |
} |
| 266 | 266 |
|
| 267 |
- logrus.Debugf(title + " succeeded") |
|
| 268 | 267 |
return nil |
| 269 | 268 |
} |
| 270 | 269 |
|
| 271 | 270 |
// Wait synchronously waits for the compute system to shutdown or terminate. |
| 272 |
-func (computeSystem *System) Wait() error {
|
|
| 273 |
- title := "hcsshim::ComputeSystem::Wait ID=" + computeSystem.ID() |
|
| 274 |
- logrus.Debugf(title) |
|
| 271 |
+func (computeSystem *System) Wait() (err error) {
|
|
| 272 |
+ operation := "hcsshim::ComputeSystem::Wait" |
|
| 273 |
+ computeSystem.logOperationBegin(operation) |
|
| 274 |
+ defer computeSystem.logOperationEnd(err) |
|
| 275 | 275 |
|
| 276 |
- err := waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, nil) |
|
| 276 |
+ err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, nil) |
|
| 277 | 277 |
if err != nil {
|
| 278 | 278 |
return makeSystemError(computeSystem, "Wait", "", err, nil) |
| 279 | 279 |
} |
| 280 | 280 |
|
| 281 |
- logrus.Debugf(title + " succeeded") |
|
| 282 | 281 |
return nil |
| 283 | 282 |
} |
| 284 | 283 |
|
| 285 | 284 |
// WaitTimeout synchronously waits for the compute system to terminate or the duration to elapse. |
| 286 | 285 |
// If the timeout expires, IsTimeout(err) == true |
| 287 |
-func (computeSystem *System) WaitTimeout(timeout time.Duration) error {
|
|
| 288 |
- title := "hcsshim::ComputeSystem::WaitTimeout ID=" + computeSystem.ID() |
|
| 289 |
- logrus.Debugf(title) |
|
| 286 |
+func (computeSystem *System) WaitTimeout(timeout time.Duration) (err error) {
|
|
| 287 |
+ operation := "hcsshim::ComputeSystem::WaitTimeout" |
|
| 288 |
+ computeSystem.logOperationBegin(operation) |
|
| 289 |
+ defer computeSystem.logOperationEnd(err) |
|
| 290 | 290 |
|
| 291 |
- err := waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, &timeout) |
|
| 291 |
+ err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, &timeout) |
|
| 292 | 292 |
if err != nil {
|
| 293 | 293 |
return makeSystemError(computeSystem, "WaitTimeout", "", err, nil) |
| 294 | 294 |
} |
| 295 | 295 |
|
| 296 |
- logrus.Debugf(title + " succeeded") |
|
| 297 | 296 |
return nil |
| 298 | 297 |
} |
| 299 | 298 |
|
| 300 |
-func (computeSystem *System) Properties(types ...schema1.PropertyType) (*schema1.ContainerProperties, error) {
|
|
| 299 |
+func (computeSystem *System) Properties(types ...schema1.PropertyType) (_ *schema1.ContainerProperties, err error) {
|
|
| 301 | 300 |
computeSystem.handleLock.RLock() |
| 302 | 301 |
defer computeSystem.handleLock.RUnlock() |
| 303 | 302 |
|
| 303 |
+ operation := "hcsshim::ComputeSystem::Properties" |
|
| 304 |
+ computeSystem.logOperationBegin(operation) |
|
| 305 |
+ defer computeSystem.logOperationEnd(err) |
|
| 306 |
+ |
|
| 304 | 307 |
queryj, err := json.Marshal(schema1.PropertyQuery{types})
|
| 305 | 308 |
if err != nil {
|
| 306 | 309 |
return nil, makeSystemError(computeSystem, "Properties", "", err, nil) |
| 307 | 310 |
} |
| 308 | 311 |
|
| 312 |
+ logrus.WithFields(computeSystem.logctx). |
|
| 313 |
+ WithField(logfields.JSON, queryj). |
|
| 314 |
+ Debug("HCS ComputeSystem Properties Query")
|
|
| 315 |
+ |
|
| 309 | 316 |
var resultp, propertiesp *uint16 |
| 310 | 317 |
completed := false |
| 311 |
- go syscallWatcher(fmt.Sprintf("GetComputeSystemProperties %s:", computeSystem.ID()), &completed)
|
|
| 318 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 312 | 319 |
err = hcsGetComputeSystemProperties(computeSystem.handle, string(queryj), &propertiesp, &resultp) |
| 313 | 320 |
completed = true |
| 314 | 321 |
events := processHcsResult(resultp) |
| ... | ... |
@@ -324,15 +389,18 @@ func (computeSystem *System) Properties(types ...schema1.PropertyType) (*schema1 |
| 324 | 324 |
if err := json.Unmarshal(propertiesRaw, properties); err != nil {
|
| 325 | 325 |
return nil, makeSystemError(computeSystem, "Properties", "", err, nil) |
| 326 | 326 |
} |
| 327 |
+ |
|
| 327 | 328 |
return properties, nil |
| 328 | 329 |
} |
| 329 | 330 |
|
| 330 | 331 |
// Pause pauses the execution of the computeSystem. This feature is not enabled in TP5. |
| 331 |
-func (computeSystem *System) Pause() error {
|
|
| 332 |
+func (computeSystem *System) Pause() (err error) {
|
|
| 332 | 333 |
computeSystem.handleLock.RLock() |
| 333 | 334 |
defer computeSystem.handleLock.RUnlock() |
| 334 |
- title := "hcsshim::ComputeSystem::Pause ID=" + computeSystem.ID() |
|
| 335 |
- logrus.Debugf(title) |
|
| 335 |
+ |
|
| 336 |
+ operation := "hcsshim::ComputeSystem::Pause" |
|
| 337 |
+ computeSystem.logOperationBegin(operation) |
|
| 338 |
+ defer computeSystem.logOperationEnd(err) |
|
| 336 | 339 |
|
| 337 | 340 |
if computeSystem.handle == 0 {
|
| 338 | 341 |
return makeSystemError(computeSystem, "Pause", "", ErrAlreadyClosed, nil) |
| ... | ... |
@@ -340,24 +408,25 @@ func (computeSystem *System) Pause() error {
|
| 340 | 340 |
|
| 341 | 341 |
var resultp *uint16 |
| 342 | 342 |
completed := false |
| 343 |
- go syscallWatcher(fmt.Sprintf("PauseComputeSystem %s:", computeSystem.ID()), &completed)
|
|
| 344 |
- err := hcsPauseComputeSystem(computeSystem.handle, "", &resultp) |
|
| 343 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 344 |
+ err = hcsPauseComputeSystem(computeSystem.handle, "", &resultp) |
|
| 345 | 345 |
completed = true |
| 346 | 346 |
events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemPauseCompleted, &timeout.SystemPause) |
| 347 | 347 |
if err != nil {
|
| 348 | 348 |
return makeSystemError(computeSystem, "Pause", "", err, events) |
| 349 | 349 |
} |
| 350 | 350 |
|
| 351 |
- logrus.Debugf(title + " succeeded") |
|
| 352 | 351 |
return nil |
| 353 | 352 |
} |
| 354 | 353 |
|
| 355 | 354 |
// Resume resumes the execution of the computeSystem. This feature is not enabled in TP5. |
| 356 |
-func (computeSystem *System) Resume() error {
|
|
| 355 |
+func (computeSystem *System) Resume() (err error) {
|
|
| 357 | 356 |
computeSystem.handleLock.RLock() |
| 358 | 357 |
defer computeSystem.handleLock.RUnlock() |
| 359 |
- title := "hcsshim::ComputeSystem::Resume ID=" + computeSystem.ID() |
|
| 360 |
- logrus.Debugf(title) |
|
| 358 |
+ |
|
| 359 |
+ operation := "hcsshim::ComputeSystem::Resume" |
|
| 360 |
+ computeSystem.logOperationBegin(operation) |
|
| 361 |
+ defer computeSystem.logOperationEnd(err) |
|
| 361 | 362 |
|
| 362 | 363 |
if computeSystem.handle == 0 {
|
| 363 | 364 |
return makeSystemError(computeSystem, "Resume", "", ErrAlreadyClosed, nil) |
| ... | ... |
@@ -365,23 +434,26 @@ func (computeSystem *System) Resume() error {
|
| 365 | 365 |
|
| 366 | 366 |
var resultp *uint16 |
| 367 | 367 |
completed := false |
| 368 |
- go syscallWatcher(fmt.Sprintf("ResumeComputeSystem %s:", computeSystem.ID()), &completed)
|
|
| 369 |
- err := hcsResumeComputeSystem(computeSystem.handle, "", &resultp) |
|
| 368 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 369 |
+ err = hcsResumeComputeSystem(computeSystem.handle, "", &resultp) |
|
| 370 | 370 |
completed = true |
| 371 | 371 |
events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemResumeCompleted, &timeout.SystemResume) |
| 372 | 372 |
if err != nil {
|
| 373 | 373 |
return makeSystemError(computeSystem, "Resume", "", err, events) |
| 374 | 374 |
} |
| 375 | 375 |
|
| 376 |
- logrus.Debugf(title + " succeeded") |
|
| 377 | 376 |
return nil |
| 378 | 377 |
} |
| 379 | 378 |
|
| 380 | 379 |
// CreateProcess launches a new process within the computeSystem. |
| 381 |
-func (computeSystem *System) CreateProcess(c interface{}) (*Process, error) {
|
|
| 380 |
+func (computeSystem *System) CreateProcess(c interface{}) (_ *Process, err error) {
|
|
| 382 | 381 |
computeSystem.handleLock.RLock() |
| 383 | 382 |
defer computeSystem.handleLock.RUnlock() |
| 384 |
- title := "hcsshim::ComputeSystem::CreateProcess ID=" + computeSystem.ID() |
|
| 383 |
+ |
|
| 384 |
+ operation := "hcsshim::ComputeSystem::CreateProcess" |
|
| 385 |
+ computeSystem.logOperationBegin(operation) |
|
| 386 |
+ defer computeSystem.logOperationEnd(err) |
|
| 387 |
+ |
|
| 385 | 388 |
var ( |
| 386 | 389 |
processInfo hcsProcessInformation |
| 387 | 390 |
processHandle hcsProcess |
| ... | ... |
@@ -398,10 +470,13 @@ func (computeSystem *System) CreateProcess(c interface{}) (*Process, error) {
|
| 398 | 398 |
} |
| 399 | 399 |
|
| 400 | 400 |
configuration := string(configurationb) |
| 401 |
- logrus.Debugf(title+" config=%s", configuration) |
|
| 401 |
+ |
|
| 402 |
+ logrus.WithFields(computeSystem.logctx). |
|
| 403 |
+ WithField(logfields.JSON, configuration). |
|
| 404 |
+ Debug("HCS ComputeSystem Process Document")
|
|
| 402 | 405 |
|
| 403 | 406 |
completed := false |
| 404 |
- go syscallWatcher(fmt.Sprintf("CreateProcess %s: %s", computeSystem.ID(), configuration), &completed)
|
|
| 407 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 405 | 408 |
err = hcsCreateProcess(computeSystem.handle, configuration, &processInfo, &processHandle, &resultp) |
| 406 | 409 |
completed = true |
| 407 | 410 |
events := processHcsResult(resultp) |
| ... | ... |
@@ -409,31 +484,37 @@ func (computeSystem *System) CreateProcess(c interface{}) (*Process, error) {
|
| 409 | 409 |
return nil, makeSystemError(computeSystem, "CreateProcess", configuration, err, events) |
| 410 | 410 |
} |
| 411 | 411 |
|
| 412 |
- process := &Process{
|
|
| 413 |
- handle: processHandle, |
|
| 414 |
- processID: int(processInfo.ProcessId), |
|
| 415 |
- system: computeSystem, |
|
| 416 |
- cachedPipes: &cachedPipes{
|
|
| 417 |
- stdIn: processInfo.StdInput, |
|
| 418 |
- stdOut: processInfo.StdOutput, |
|
| 419 |
- stdErr: processInfo.StdError, |
|
| 420 |
- }, |
|
| 412 |
+ logrus.WithFields(computeSystem.logctx). |
|
| 413 |
+ WithField(logfields.ProcessID, processInfo.ProcessId). |
|
| 414 |
+ Debug("HCS ComputeSystem CreateProcess PID")
|
|
| 415 |
+ |
|
| 416 |
+ process := newProcess(processHandle, int(processInfo.ProcessId), computeSystem) |
|
| 417 |
+ process.cachedPipes = &cachedPipes{
|
|
| 418 |
+ stdIn: processInfo.StdInput, |
|
| 419 |
+ stdOut: processInfo.StdOutput, |
|
| 420 |
+ stdErr: processInfo.StdError, |
|
| 421 | 421 |
} |
| 422 | 422 |
|
| 423 |
- if err := process.registerCallback(); err != nil {
|
|
| 423 |
+ if err = process.registerCallback(); err != nil {
|
|
| 424 | 424 |
return nil, makeSystemError(computeSystem, "CreateProcess", "", err, nil) |
| 425 | 425 |
} |
| 426 | 426 |
|
| 427 |
- logrus.Debugf(title+" succeeded processid=%d", process.processID) |
|
| 428 | 427 |
return process, nil |
| 429 | 428 |
} |
| 430 | 429 |
|
| 431 | 430 |
// OpenProcess gets an interface to an existing process within the computeSystem. |
| 432 |
-func (computeSystem *System) OpenProcess(pid int) (*Process, error) {
|
|
| 431 |
+func (computeSystem *System) OpenProcess(pid int) (_ *Process, err error) {
|
|
| 433 | 432 |
computeSystem.handleLock.RLock() |
| 434 | 433 |
defer computeSystem.handleLock.RUnlock() |
| 435 |
- title := "hcsshim::ComputeSystem::OpenProcess ID=" + computeSystem.ID() |
|
| 436 |
- logrus.Debugf(title+" processid=%d", pid) |
|
| 434 |
+ |
|
| 435 |
+ // Add PID for the context of this operation |
|
| 436 |
+ computeSystem.logctx[logfields.ProcessID] = pid |
|
| 437 |
+ defer delete(computeSystem.logctx, logfields.ProcessID) |
|
| 438 |
+ |
|
| 439 |
+ operation := "hcsshim::ComputeSystem::OpenProcess" |
|
| 440 |
+ computeSystem.logOperationBegin(operation) |
|
| 441 |
+ defer computeSystem.logOperationEnd(err) |
|
| 442 |
+ |
|
| 437 | 443 |
var ( |
| 438 | 444 |
processHandle hcsProcess |
| 439 | 445 |
resultp *uint16 |
| ... | ... |
@@ -444,47 +525,43 @@ func (computeSystem *System) OpenProcess(pid int) (*Process, error) {
|
| 444 | 444 |
} |
| 445 | 445 |
|
| 446 | 446 |
completed := false |
| 447 |
- go syscallWatcher(fmt.Sprintf("OpenProcess %s: %d", computeSystem.ID(), pid), &completed)
|
|
| 448 |
- err := hcsOpenProcess(computeSystem.handle, uint32(pid), &processHandle, &resultp) |
|
| 447 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 448 |
+ err = hcsOpenProcess(computeSystem.handle, uint32(pid), &processHandle, &resultp) |
|
| 449 | 449 |
completed = true |
| 450 | 450 |
events := processHcsResult(resultp) |
| 451 | 451 |
if err != nil {
|
| 452 | 452 |
return nil, makeSystemError(computeSystem, "OpenProcess", "", err, events) |
| 453 | 453 |
} |
| 454 | 454 |
|
| 455 |
- process := &Process{
|
|
| 456 |
- handle: processHandle, |
|
| 457 |
- processID: pid, |
|
| 458 |
- system: computeSystem, |
|
| 459 |
- } |
|
| 460 |
- |
|
| 461 |
- if err := process.registerCallback(); err != nil {
|
|
| 455 |
+ process := newProcess(processHandle, pid, computeSystem) |
|
| 456 |
+ if err = process.registerCallback(); err != nil {
|
|
| 462 | 457 |
return nil, makeSystemError(computeSystem, "OpenProcess", "", err, nil) |
| 463 | 458 |
} |
| 464 | 459 |
|
| 465 |
- logrus.Debugf(title+" succeeded processid=%s", process.processID) |
|
| 466 | 460 |
return process, nil |
| 467 | 461 |
} |
| 468 | 462 |
|
| 469 | 463 |
// Close cleans up any state associated with the compute system but does not terminate or wait for it. |
| 470 |
-func (computeSystem *System) Close() error {
|
|
| 464 |
+func (computeSystem *System) Close() (err error) {
|
|
| 471 | 465 |
computeSystem.handleLock.Lock() |
| 472 | 466 |
defer computeSystem.handleLock.Unlock() |
| 473 |
- title := "hcsshim::ComputeSystem::Close ID=" + computeSystem.ID() |
|
| 474 |
- logrus.Debugf(title) |
|
| 467 |
+ |
|
| 468 |
+ operation := "hcsshim::ComputeSystem::Close" |
|
| 469 |
+ computeSystem.logOperationBegin(operation) |
|
| 470 |
+ defer computeSystem.logOperationEnd(err) |
|
| 475 | 471 |
|
| 476 | 472 |
// Don't double free this |
| 477 | 473 |
if computeSystem.handle == 0 {
|
| 478 | 474 |
return nil |
| 479 | 475 |
} |
| 480 | 476 |
|
| 481 |
- if err := computeSystem.unregisterCallback(); err != nil {
|
|
| 477 |
+ if err = computeSystem.unregisterCallback(); err != nil {
|
|
| 482 | 478 |
return makeSystemError(computeSystem, "Close", "", err, nil) |
| 483 | 479 |
} |
| 484 | 480 |
|
| 485 | 481 |
completed := false |
| 486 |
- go syscallWatcher(fmt.Sprintf("CloseComputeSystem %s:", computeSystem.ID()), &completed)
|
|
| 487 |
- err := hcsCloseComputeSystem(computeSystem.handle) |
|
| 482 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 483 |
+ err = hcsCloseComputeSystem(computeSystem.handle) |
|
| 488 | 484 |
completed = true |
| 489 | 485 |
if err != nil {
|
| 490 | 486 |
return makeSystemError(computeSystem, "Close", "", err, nil) |
| ... | ... |
@@ -492,7 +569,6 @@ func (computeSystem *System) Close() error {
|
| 492 | 492 |
|
| 493 | 493 |
computeSystem.handle = 0 |
| 494 | 494 |
|
| 495 |
- logrus.Debugf(title + " succeeded") |
|
| 496 | 495 |
return nil |
| 497 | 496 |
} |
| 498 | 497 |
|
| ... | ... |
@@ -553,11 +629,14 @@ func (computeSystem *System) unregisterCallback() error {
|
| 553 | 553 |
return nil |
| 554 | 554 |
} |
| 555 | 555 |
|
| 556 |
-// Modifies the System by sending a request to HCS |
|
| 557 |
-func (computeSystem *System) Modify(config interface{}) error {
|
|
| 556 |
+// Modify the System by sending a request to HCS |
|
| 557 |
+func (computeSystem *System) Modify(config interface{}) (err error) {
|
|
| 558 | 558 |
computeSystem.handleLock.RLock() |
| 559 | 559 |
defer computeSystem.handleLock.RUnlock() |
| 560 |
- title := "hcsshim::Modify ID=" + computeSystem.id |
|
| 560 |
+ |
|
| 561 |
+ operation := "hcsshim::ComputeSystem::Modify" |
|
| 562 |
+ computeSystem.logOperationBegin(operation) |
|
| 563 |
+ defer computeSystem.logOperationEnd(err) |
|
| 561 | 564 |
|
| 562 | 565 |
if computeSystem.handle == 0 {
|
| 563 | 566 |
return makeSystemError(computeSystem, "Modify", "", ErrAlreadyClosed, nil) |
| ... | ... |
@@ -569,17 +648,20 @@ func (computeSystem *System) Modify(config interface{}) error {
|
| 569 | 569 |
} |
| 570 | 570 |
|
| 571 | 571 |
requestString := string(requestJSON) |
| 572 |
- logrus.Debugf(title + " " + requestString) |
|
| 572 |
+ |
|
| 573 |
+ logrus.WithFields(computeSystem.logctx). |
|
| 574 |
+ WithField(logfields.JSON, requestString). |
|
| 575 |
+ Debug("HCS ComputeSystem Modify Document")
|
|
| 573 | 576 |
|
| 574 | 577 |
var resultp *uint16 |
| 575 | 578 |
completed := false |
| 576 |
- go syscallWatcher(fmt.Sprintf("ModifyComputeSystem %s: %s", computeSystem.ID(), requestString), &completed)
|
|
| 579 |
+ go syscallWatcher(computeSystem.logctx, &completed) |
|
| 577 | 580 |
err = hcsModifyComputeSystem(computeSystem.handle, requestString, &resultp) |
| 578 | 581 |
completed = true |
| 579 | 582 |
events := processHcsResult(resultp) |
| 580 | 583 |
if err != nil {
|
| 581 | 584 |
return makeSystemError(computeSystem, "Modify", requestString, err, events) |
| 582 | 585 |
} |
| 583 |
- logrus.Debugf(title + " succeeded ") |
|
| 586 |
+ |
|
| 584 | 587 |
return nil |
| 585 | 588 |
} |
| ... | ... |
@@ -3,6 +3,7 @@ package hcs |
| 3 | 3 |
import ( |
| 4 | 4 |
"time" |
| 5 | 5 |
|
| 6 |
+ "github.com/Microsoft/hcsshim/internal/logfields" |
|
| 6 | 7 |
"github.com/Microsoft/hcsshim/internal/timeout" |
| 7 | 8 |
"github.com/sirupsen/logrus" |
| 8 | 9 |
) |
| ... | ... |
@@ -17,14 +18,16 @@ import ( |
| 17 | 17 |
// Usage is: |
| 18 | 18 |
// |
| 19 | 19 |
// completed := false |
| 20 |
-// go syscallWatcher("some description", &completed)
|
|
| 20 |
+// go syscallWatcher(context, &completed) |
|
| 21 | 21 |
// <syscall> |
| 22 | 22 |
// completed = true |
| 23 | 23 |
// |
| 24 |
-func syscallWatcher(description string, syscallCompleted *bool) {
|
|
| 24 |
+func syscallWatcher(context logrus.Fields, syscallCompleted *bool) {
|
|
| 25 | 25 |
time.Sleep(timeout.SyscallWatcher) |
| 26 | 26 |
if *syscallCompleted {
|
| 27 | 27 |
return |
| 28 | 28 |
} |
| 29 |
- logrus.Warnf("%s: Did not complete within %s. This may indicate a platform issue. If it appears to be making no forward progress, obtain the stacks and see is there is a syscall stuck in the platform API for a significant length of time.", description, timeout.SyscallWatcher)
|
|
| 29 |
+ logrus.WithFields(context). |
|
| 30 |
+ WithField(logfields.Timeout, timeout.SyscallWatcher). |
|
| 31 |
+ Warning("Syscall did not complete within operation timeout. This may indicate a platform issue. If it appears to be making no forward progress, obtain the stacks and see if there is a syscall stuck in the platform API for a significant length of time.")
|
|
| 30 | 32 |
} |
| ... | ... |
@@ -20,6 +20,7 @@ type ELBPolicy struct {
|
| 20 | 20 |
SourceVIP string `json:"SourceVIP,omitempty"` |
| 21 | 21 |
VIPs []string `json:"VIPs,omitempty"` |
| 22 | 22 |
ILB bool `json:"ILB,omitempty"` |
| 23 |
+ DSR bool `json:"IsDSR,omitempty"` |
|
| 23 | 24 |
} |
| 24 | 25 |
|
| 25 | 26 |
// LBPolicy is a structure defining schema for LoadBalancing based Policy |
| 5 | 5 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,37 @@ |
| 0 |
+package logfields |
|
| 1 |
+ |
|
| 2 |
+const ( |
|
| 3 |
+ // Identifiers |
|
| 4 |
+ |
|
| 5 |
+ ContainerID = "cid" |
|
| 6 |
+ UVMID = "uvm-id" |
|
| 7 |
+ ProcessID = "pid" |
|
| 8 |
+ |
|
| 9 |
+ // Common Misc |
|
| 10 |
+ |
|
| 11 |
+ // Timeout represents an operation timeout. |
|
| 12 |
+ Timeout = "timeout" |
|
| 13 |
+ JSON = "json" |
|
| 14 |
+ |
|
| 15 |
+ // Keys/values |
|
| 16 |
+ |
|
| 17 |
+ Field = "field" |
|
| 18 |
+ OCIAnnotation = "oci-annotation" |
|
| 19 |
+ Value = "value" |
|
| 20 |
+ |
|
| 21 |
+ // Golang type's |
|
| 22 |
+ |
|
| 23 |
+ ExpectedType = "expected-type" |
|
| 24 |
+ Bool = "bool" |
|
| 25 |
+ Uint32 = "uint32" |
|
| 26 |
+ Uint64 = "uint64" |
|
| 27 |
+ |
|
| 28 |
+ // HCS |
|
| 29 |
+ |
|
| 30 |
+ HCSOperation = "hcs-op" |
|
| 31 |
+ HCSOperationResult = "hcs-op-result" |
|
| 32 |
+ |
|
| 33 |
+ // runhcs |
|
| 34 |
+ |
|
| 35 |
+ VMShimOperation = "vmshim-op" |
|
| 36 |
+) |
| ... | ... |
@@ -10,7 +10,6 @@ |
| 10 | 10 |
package hcsschema |
| 11 | 11 |
|
| 12 | 12 |
type Chipset struct {
|
| 13 |
- |
|
| 14 | 13 |
Uefi *Uefi `json:"Uefi,omitempty"` |
| 15 | 14 |
|
| 16 | 15 |
IsNumLockDisabled bool `json:"IsNumLockDisabled,omitempty"` |
| ... | ... |
@@ -22,4 +21,7 @@ type Chipset struct {
|
| 22 | 22 |
ChassisAssetTag string `json:"ChassisAssetTag,omitempty"` |
| 23 | 23 |
|
| 24 | 24 |
UseUtc bool `json:"UseUtc,omitempty"` |
| 25 |
+ |
|
| 26 |
+ // LinuxKernelDirect - Added in v2.2 Builds >=181117 |
|
| 27 |
+ LinuxKernelDirect *LinuxKernelDirect `json:"LinuxKernelDirect,omitempty"` |
|
| 25 | 28 |
} |
| 26 | 29 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,18 @@ |
| 0 |
+/* |
|
| 1 |
+ * HCS API |
|
| 2 |
+ * |
|
| 3 |
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) |
|
| 4 |
+ * |
|
| 5 |
+ * API version: 2.2 |
|
| 6 |
+ * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) |
|
| 7 |
+ */ |
|
| 8 |
+ |
|
| 9 |
+package hcsschema |
|
| 10 |
+ |
|
| 11 |
+type LinuxKernelDirect struct {
|
|
| 12 |
+ KernelFilePath string `json:"KernelFilePath,omitempty"` |
|
| 13 |
+ |
|
| 14 |
+ InitRdPath string `json:"InitRdPath,omitempty"` |
|
| 15 |
+ |
|
| 16 |
+ KernelCmdLine string `json:"KernelCmdLine,omitempty"` |
|
| 17 |
+} |
| ... | ... |
@@ -10,7 +10,6 @@ |
| 10 | 10 |
package hcsschema |
| 11 | 11 |
|
| 12 | 12 |
type Memory2 struct {
|
| 13 |
- |
|
| 14 | 13 |
SizeInMB int32 `json:"SizeInMB,omitempty"` |
| 15 | 14 |
|
| 16 | 15 |
AllowOvercommit bool `json:"AllowOvercommit,omitempty"` |
| ... | ... |
@@ -20,4 +19,7 @@ type Memory2 struct {
|
| 20 | 20 |
EnableColdHint bool `json:"EnableColdHint,omitempty"` |
| 21 | 21 |
|
| 22 | 22 |
EnableEpf bool `json:"EnableEpf,omitempty"` |
| 23 |
+ |
|
| 24 |
+ // EnableDeferredCommit is private in the schema. If regenerated need to add back. |
|
| 25 |
+ EnableDeferredCommit bool `json:"EnableDeferredCommit,omitempty"` |
|
| 23 | 26 |
} |
| ... | ... |
@@ -10,12 +10,11 @@ |
| 10 | 10 |
package hcsschema |
| 11 | 11 |
|
| 12 | 12 |
type VirtualPMemController struct {
|
| 13 |
- |
|
| 14 | 13 |
Devices map[string]VirtualPMemDevice `json:"Devices,omitempty"` |
| 15 | 14 |
|
| 16 |
- MaximumCount int32 `json:"MaximumCount,omitempty"` |
|
| 15 |
+ MaximumCount uint32 `json:"MaximumCount,omitempty"` |
|
| 17 | 16 |
|
| 18 |
- MaximumSizeBytes int32 `json:"MaximumSizeBytes,omitempty"` |
|
| 17 |
+ MaximumSizeBytes uint64 `json:"MaximumSizeBytes,omitempty"` |
|
| 19 | 18 |
|
| 20 | 19 |
Backing string `json:"Backing,omitempty"` |
| 21 | 20 |
} |
| ... | ... |
@@ -1,14 +1,11 @@ |
| 1 | 1 |
package wclayer |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "io" |
|
| 5 | 4 |
"io/ioutil" |
| 6 | 5 |
"os" |
| 7 |
- "syscall" |
|
| 8 | 6 |
|
| 9 | 7 |
"github.com/Microsoft/go-winio" |
| 10 | 8 |
"github.com/Microsoft/hcsshim/internal/hcserror" |
| 11 |
- "github.com/Microsoft/hcsshim/internal/interop" |
|
| 12 | 9 |
"github.com/sirupsen/logrus" |
| 13 | 10 |
) |
| 14 | 11 |
|
| ... | ... |
@@ -44,96 +41,20 @@ type LayerReader interface {
|
| 44 | 44 |
Close() error |
| 45 | 45 |
} |
| 46 | 46 |
|
| 47 |
-// FilterLayerReader provides an interface for extracting the contents of an on-disk layer. |
|
| 48 |
-type FilterLayerReader struct {
|
|
| 49 |
- context uintptr |
|
| 50 |
-} |
|
| 51 |
- |
|
| 52 |
-// Next reads the next available file from a layer, ensuring that parent directories are always read |
|
| 53 |
-// before child files and directories. |
|
| 54 |
-// |
|
| 55 |
-// Next returns the file's relative path, size, and basic file metadata. Read() should be used to |
|
| 56 |
-// extract a Win32 backup stream with the remainder of the metadata and the data. |
|
| 57 |
-func (r *FilterLayerReader) Next() (string, int64, *winio.FileBasicInfo, error) {
|
|
| 58 |
- var fileNamep *uint16 |
|
| 59 |
- fileInfo := &winio.FileBasicInfo{}
|
|
| 60 |
- var deleted uint32 |
|
| 61 |
- var fileSize int64 |
|
| 62 |
- err := exportLayerNext(r.context, &fileNamep, fileInfo, &fileSize, &deleted) |
|
| 63 |
- if err != nil {
|
|
| 64 |
- if err == syscall.ERROR_NO_MORE_FILES {
|
|
| 65 |
- err = io.EOF |
|
| 66 |
- } else {
|
|
| 67 |
- err = hcserror.New(err, "ExportLayerNext", "") |
|
| 68 |
- } |
|
| 69 |
- return "", 0, nil, err |
|
| 70 |
- } |
|
| 71 |
- fileName := interop.ConvertAndFreeCoTaskMemString(fileNamep) |
|
| 72 |
- if deleted != 0 {
|
|
| 73 |
- fileInfo = nil |
|
| 74 |
- } |
|
| 75 |
- if fileName[0] == '\\' {
|
|
| 76 |
- fileName = fileName[1:] |
|
| 77 |
- } |
|
| 78 |
- return fileName, fileSize, fileInfo, nil |
|
| 79 |
-} |
|
| 80 |
- |
|
| 81 |
-// Read reads from the current file's Win32 backup stream. |
|
| 82 |
-func (r *FilterLayerReader) Read(b []byte) (int, error) {
|
|
| 83 |
- var bytesRead uint32 |
|
| 84 |
- err := exportLayerRead(r.context, b, &bytesRead) |
|
| 85 |
- if err != nil {
|
|
| 86 |
- return 0, hcserror.New(err, "ExportLayerRead", "") |
|
| 87 |
- } |
|
| 88 |
- if bytesRead == 0 {
|
|
| 89 |
- return 0, io.EOF |
|
| 90 |
- } |
|
| 91 |
- return int(bytesRead), nil |
|
| 92 |
-} |
|
| 93 |
- |
|
| 94 |
-// Close frees resources associated with the layer reader. It will return an |
|
| 95 |
-// error if there was an error while reading the layer or of the layer was not |
|
| 96 |
-// completely read. |
|
| 97 |
-func (r *FilterLayerReader) Close() (err error) {
|
|
| 98 |
- if r.context != 0 {
|
|
| 99 |
- err = exportLayerEnd(r.context) |
|
| 100 |
- if err != nil {
|
|
| 101 |
- err = hcserror.New(err, "ExportLayerEnd", "") |
|
| 102 |
- } |
|
| 103 |
- r.context = 0 |
|
| 104 |
- } |
|
| 105 |
- return |
|
| 106 |
-} |
|
| 107 |
- |
|
| 108 | 47 |
// NewLayerReader returns a new layer reader for reading the contents of an on-disk layer. |
| 109 | 48 |
// The caller must have taken the SeBackupPrivilege privilege |
| 110 | 49 |
// to call this and any methods on the resulting LayerReader. |
| 111 | 50 |
func NewLayerReader(path string, parentLayerPaths []string) (LayerReader, error) {
|
| 112 |
- if procExportLayerBegin.Find() != nil {
|
|
| 113 |
- // The new layer reader is not available on this Windows build. Fall back to the |
|
| 114 |
- // legacy export code path. |
|
| 115 |
- exportPath, err := ioutil.TempDir("", "hcs")
|
|
| 116 |
- if err != nil {
|
|
| 117 |
- return nil, err |
|
| 118 |
- } |
|
| 119 |
- err = ExportLayer(path, exportPath, parentLayerPaths) |
|
| 120 |
- if err != nil {
|
|
| 121 |
- os.RemoveAll(exportPath) |
|
| 122 |
- return nil, err |
|
| 123 |
- } |
|
| 124 |
- return &legacyLayerReaderWrapper{newLegacyLayerReader(exportPath)}, nil
|
|
| 125 |
- } |
|
| 126 |
- |
|
| 127 |
- layers, err := layerPathsToDescriptors(parentLayerPaths) |
|
| 51 |
+ exportPath, err := ioutil.TempDir("", "hcs")
|
|
| 128 | 52 |
if err != nil {
|
| 129 | 53 |
return nil, err |
| 130 | 54 |
} |
| 131 |
- r := &FilterLayerReader{}
|
|
| 132 |
- err = exportLayerBegin(&stdDriverInfo, path, layers, &r.context) |
|
| 55 |
+ err = ExportLayer(path, exportPath, parentLayerPaths) |
|
| 133 | 56 |
if err != nil {
|
| 134 |
- return nil, hcserror.New(err, "ExportLayerBegin", "") |
|
| 57 |
+ os.RemoveAll(exportPath) |
|
| 58 |
+ return nil, err |
|
| 135 | 59 |
} |
| 136 |
- return r, err |
|
| 60 |
+ return &legacyLayerReaderWrapper{newLegacyLayerReader(exportPath)}, nil
|
|
| 137 | 61 |
} |
| 138 | 62 |
|
| 139 | 63 |
type legacyLayerReaderWrapper struct {
|
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package wclayer |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "errors" |
|
| 5 | 4 |
"io/ioutil" |
| 6 | 5 |
"os" |
| 7 | 6 |
"path/filepath" |
| ... | ... |
@@ -52,69 +51,6 @@ type LayerWriter interface {
|
| 52 | 52 |
Close() error |
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 |
-// FilterLayerWriter provides an interface to write the contents of a layer to the file system. |
|
| 56 |
-type FilterLayerWriter struct {
|
|
| 57 |
- context uintptr |
|
| 58 |
-} |
|
| 59 |
- |
|
| 60 |
-// Add adds a file or directory to the layer. The file's parent directory must have already been added. |
|
| 61 |
-// |
|
| 62 |
-// name contains the file's relative path. fileInfo contains file times and file attributes; the rest |
|
| 63 |
-// of the file metadata and the file data must be written as a Win32 backup stream to the Write() method. |
|
| 64 |
-// winio.BackupStreamWriter can be used to facilitate this. |
|
| 65 |
-func (w *FilterLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) error {
|
|
| 66 |
- if name[0] != '\\' {
|
|
| 67 |
- name = `\` + name |
|
| 68 |
- } |
|
| 69 |
- err := importLayerNext(w.context, name, fileInfo) |
|
| 70 |
- if err != nil {
|
|
| 71 |
- return hcserror.New(err, "ImportLayerNext", "") |
|
| 72 |
- } |
|
| 73 |
- return nil |
|
| 74 |
-} |
|
| 75 |
- |
|
| 76 |
-// AddLink adds a hard link to the layer. The target of the link must have already been added. |
|
| 77 |
-func (w *FilterLayerWriter) AddLink(name string, target string) error {
|
|
| 78 |
- return errors.New("hard links not yet supported")
|
|
| 79 |
-} |
|
| 80 |
- |
|
| 81 |
-// Remove removes a file from the layer. The file must have been present in the parent layer. |
|
| 82 |
-// |
|
| 83 |
-// name contains the file's relative path. |
|
| 84 |
-func (w *FilterLayerWriter) Remove(name string) error {
|
|
| 85 |
- if name[0] != '\\' {
|
|
| 86 |
- name = `\` + name |
|
| 87 |
- } |
|
| 88 |
- err := importLayerNext(w.context, name, nil) |
|
| 89 |
- if err != nil {
|
|
| 90 |
- return hcserror.New(err, "ImportLayerNext", "") |
|
| 91 |
- } |
|
| 92 |
- return nil |
|
| 93 |
-} |
|
| 94 |
- |
|
| 95 |
-// Write writes more backup stream data to the current file. |
|
| 96 |
-func (w *FilterLayerWriter) Write(b []byte) (int, error) {
|
|
| 97 |
- err := importLayerWrite(w.context, b) |
|
| 98 |
- if err != nil {
|
|
| 99 |
- err = hcserror.New(err, "ImportLayerWrite", "") |
|
| 100 |
- return 0, err |
|
| 101 |
- } |
|
| 102 |
- return len(b), err |
|
| 103 |
-} |
|
| 104 |
- |
|
| 105 |
-// Close completes the layer write operation. The error must be checked to ensure that the |
|
| 106 |
-// operation was successful. |
|
| 107 |
-func (w *FilterLayerWriter) Close() (err error) {
|
|
| 108 |
- if w.context != 0 {
|
|
| 109 |
- err = importLayerEnd(w.context) |
|
| 110 |
- if err != nil {
|
|
| 111 |
- err = hcserror.New(err, "ImportLayerEnd", "") |
|
| 112 |
- } |
|
| 113 |
- w.context = 0 |
|
| 114 |
- } |
|
| 115 |
- return |
|
| 116 |
-} |
|
| 117 |
- |
|
| 118 | 55 |
type legacyLayerWriterWrapper struct {
|
| 119 | 56 |
*legacyLayerWriter |
| 120 | 57 |
path string |
| ... | ... |
@@ -175,32 +111,17 @@ func NewLayerWriter(path string, parentLayerPaths []string) (LayerWriter, error) |
| 175 | 175 |
}, nil |
| 176 | 176 |
} |
| 177 | 177 |
|
| 178 |
- if procImportLayerBegin.Find() != nil {
|
|
| 179 |
- // The new layer reader is not available on this Windows build. Fall back to the |
|
| 180 |
- // legacy export code path. |
|
| 181 |
- importPath, err := ioutil.TempDir("", "hcs")
|
|
| 182 |
- if err != nil {
|
|
| 183 |
- return nil, err |
|
| 184 |
- } |
|
| 185 |
- w, err := newLegacyLayerWriter(importPath, parentLayerPaths, path) |
|
| 186 |
- if err != nil {
|
|
| 187 |
- return nil, err |
|
| 188 |
- } |
|
| 189 |
- return &legacyLayerWriterWrapper{
|
|
| 190 |
- legacyLayerWriter: w, |
|
| 191 |
- path: importPath, |
|
| 192 |
- parentLayerPaths: parentLayerPaths, |
|
| 193 |
- }, nil |
|
| 194 |
- } |
|
| 195 |
- layers, err := layerPathsToDescriptors(parentLayerPaths) |
|
| 178 |
+ importPath, err := ioutil.TempDir("", "hcs")
|
|
| 196 | 179 |
if err != nil {
|
| 197 | 180 |
return nil, err |
| 198 | 181 |
} |
| 199 |
- |
|
| 200 |
- w := &FilterLayerWriter{}
|
|
| 201 |
- err = importLayerBegin(&stdDriverInfo, path, layers, &w.context) |
|
| 182 |
+ w, err := newLegacyLayerWriter(importPath, parentLayerPaths, path) |
|
| 202 | 183 |
if err != nil {
|
| 203 |
- return nil, hcserror.New(err, "ImportLayerStart", "") |
|
| 184 |
+ return nil, err |
|
| 204 | 185 |
} |
| 205 |
- return w, nil |
|
| 186 |
+ return &legacyLayerWriterWrapper{
|
|
| 187 |
+ legacyLayerWriter: w, |
|
| 188 |
+ path: importPath, |
|
| 189 |
+ parentLayerPaths: parentLayerPaths, |
|
| 190 |
+ }, nil |
|
| 206 | 191 |
} |
| ... | ... |
@@ -2,7 +2,7 @@ package wclayer |
| 2 | 2 |
|
| 3 | 3 |
import "github.com/Microsoft/hcsshim/internal/guid" |
| 4 | 4 |
|
| 5 |
-//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go -winio wclayer.go |
|
| 5 |
+//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go wclayer.go |
|
| 6 | 6 |
|
| 7 | 7 |
//sys activateLayer(info *driverInfo, id string) (hr error) = vmcompute.ActivateLayer? |
| 8 | 8 |
//sys copyLayer(info *driverInfo, srcId string, dstId string, descriptors []WC_LAYER_DESCRIPTOR) (hr error) = vmcompute.CopyLayer? |
| ... | ... |
@@ -22,16 +22,6 @@ import "github.com/Microsoft/hcsshim/internal/guid" |
| 22 | 22 |
//sys processBaseImage(path string) (hr error) = vmcompute.ProcessBaseImage? |
| 23 | 23 |
//sys processUtilityImage(path string) (hr error) = vmcompute.ProcessUtilityImage? |
| 24 | 24 |
|
| 25 |
-//sys importLayerBegin(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR, context *uintptr) (hr error) = vmcompute.ImportLayerBegin? |
|
| 26 |
-//sys importLayerNext(context uintptr, fileName string, fileInfo *winio.FileBasicInfo) (hr error) = vmcompute.ImportLayerNext? |
|
| 27 |
-//sys importLayerWrite(context uintptr, buffer []byte) (hr error) = vmcompute.ImportLayerWrite? |
|
| 28 |
-//sys importLayerEnd(context uintptr) (hr error) = vmcompute.ImportLayerEnd? |
|
| 29 |
- |
|
| 30 |
-//sys exportLayerBegin(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR, context *uintptr) (hr error) = vmcompute.ExportLayerBegin? |
|
| 31 |
-//sys exportLayerNext(context uintptr, fileName **uint16, fileInfo *winio.FileBasicInfo, fileSize *int64, deleted *uint32) (hr error) = vmcompute.ExportLayerNext? |
|
| 32 |
-//sys exportLayerRead(context uintptr, buffer []byte, bytesRead *uint32) (hr error) = vmcompute.ExportLayerRead? |
|
| 33 |
-//sys exportLayerEnd(context uintptr) (hr error) = vmcompute.ExportLayerEnd? |
|
| 34 |
- |
|
| 35 | 25 |
//sys grantVmAccess(vmid string, filepath string) (hr error) = vmcompute.GrantVmAccess? |
| 36 | 26 |
|
| 37 | 27 |
type _guid = guid.GUID |
| ... | ... |
@@ -1,4 +1,4 @@ |
| 1 |
-// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT |
|
| 1 |
+// Code generated mksyscall_windows.exe DO NOT EDIT |
|
| 2 | 2 |
|
| 3 | 3 |
package wclayer |
| 4 | 4 |
|
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"syscall" |
| 7 | 7 |
"unsafe" |
| 8 | 8 |
|
| 9 |
- "github.com/Microsoft/go-winio" |
|
| 10 | 9 |
"github.com/Microsoft/hcsshim/internal/interop" |
| 11 | 10 |
"golang.org/x/sys/windows" |
| 12 | 11 |
) |
| ... | ... |
@@ -58,14 +57,6 @@ var ( |
| 58 | 58 |
procUnprepareLayer = modvmcompute.NewProc("UnprepareLayer")
|
| 59 | 59 |
procProcessBaseImage = modvmcompute.NewProc("ProcessBaseImage")
|
| 60 | 60 |
procProcessUtilityImage = modvmcompute.NewProc("ProcessUtilityImage")
|
| 61 |
- procImportLayerBegin = modvmcompute.NewProc("ImportLayerBegin")
|
|
| 62 |
- procImportLayerNext = modvmcompute.NewProc("ImportLayerNext")
|
|
| 63 |
- procImportLayerWrite = modvmcompute.NewProc("ImportLayerWrite")
|
|
| 64 |
- procImportLayerEnd = modvmcompute.NewProc("ImportLayerEnd")
|
|
| 65 |
- procExportLayerBegin = modvmcompute.NewProc("ExportLayerBegin")
|
|
| 66 |
- procExportLayerNext = modvmcompute.NewProc("ExportLayerNext")
|
|
| 67 |
- procExportLayerRead = modvmcompute.NewProc("ExportLayerRead")
|
|
| 68 |
- procExportLayerEnd = modvmcompute.NewProc("ExportLayerEnd")
|
|
| 69 | 61 |
procGrantVmAccess = modvmcompute.NewProc("GrantVmAccess")
|
| 70 | 62 |
) |
| 71 | 63 |
|
| ... | ... |
@@ -440,137 +431,6 @@ func _processUtilityImage(path *uint16) (hr error) {
|
| 440 | 440 |
return |
| 441 | 441 |
} |
| 442 | 442 |
|
| 443 |
-func importLayerBegin(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR, context *uintptr) (hr error) {
|
|
| 444 |
- var _p0 *uint16 |
|
| 445 |
- _p0, hr = syscall.UTF16PtrFromString(id) |
|
| 446 |
- if hr != nil {
|
|
| 447 |
- return |
|
| 448 |
- } |
|
| 449 |
- return _importLayerBegin(info, _p0, descriptors, context) |
|
| 450 |
-} |
|
| 451 |
- |
|
| 452 |
-func _importLayerBegin(info *driverInfo, id *uint16, descriptors []WC_LAYER_DESCRIPTOR, context *uintptr) (hr error) {
|
|
| 453 |
- var _p1 *WC_LAYER_DESCRIPTOR |
|
| 454 |
- if len(descriptors) > 0 {
|
|
| 455 |
- _p1 = &descriptors[0] |
|
| 456 |
- } |
|
| 457 |
- if hr = procImportLayerBegin.Find(); hr != nil {
|
|
| 458 |
- return |
|
| 459 |
- } |
|
| 460 |
- r0, _, _ := syscall.Syscall6(procImportLayerBegin.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(_p1)), uintptr(len(descriptors)), uintptr(unsafe.Pointer(context)), 0) |
|
| 461 |
- if int32(r0) < 0 {
|
|
| 462 |
- hr = interop.Win32FromHresult(r0) |
|
| 463 |
- } |
|
| 464 |
- return |
|
| 465 |
-} |
|
| 466 |
- |
|
| 467 |
-func importLayerNext(context uintptr, fileName string, fileInfo *winio.FileBasicInfo) (hr error) {
|
|
| 468 |
- var _p0 *uint16 |
|
| 469 |
- _p0, hr = syscall.UTF16PtrFromString(fileName) |
|
| 470 |
- if hr != nil {
|
|
| 471 |
- return |
|
| 472 |
- } |
|
| 473 |
- return _importLayerNext(context, _p0, fileInfo) |
|
| 474 |
-} |
|
| 475 |
- |
|
| 476 |
-func _importLayerNext(context uintptr, fileName *uint16, fileInfo *winio.FileBasicInfo) (hr error) {
|
|
| 477 |
- if hr = procImportLayerNext.Find(); hr != nil {
|
|
| 478 |
- return |
|
| 479 |
- } |
|
| 480 |
- r0, _, _ := syscall.Syscall(procImportLayerNext.Addr(), 3, uintptr(context), uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(fileInfo))) |
|
| 481 |
- if int32(r0) < 0 {
|
|
| 482 |
- hr = interop.Win32FromHresult(r0) |
|
| 483 |
- } |
|
| 484 |
- return |
|
| 485 |
-} |
|
| 486 |
- |
|
| 487 |
-func importLayerWrite(context uintptr, buffer []byte) (hr error) {
|
|
| 488 |
- var _p0 *byte |
|
| 489 |
- if len(buffer) > 0 {
|
|
| 490 |
- _p0 = &buffer[0] |
|
| 491 |
- } |
|
| 492 |
- if hr = procImportLayerWrite.Find(); hr != nil {
|
|
| 493 |
- return |
|
| 494 |
- } |
|
| 495 |
- r0, _, _ := syscall.Syscall(procImportLayerWrite.Addr(), 3, uintptr(context), uintptr(unsafe.Pointer(_p0)), uintptr(len(buffer))) |
|
| 496 |
- if int32(r0) < 0 {
|
|
| 497 |
- hr = interop.Win32FromHresult(r0) |
|
| 498 |
- } |
|
| 499 |
- return |
|
| 500 |
-} |
|
| 501 |
- |
|
| 502 |
-func importLayerEnd(context uintptr) (hr error) {
|
|
| 503 |
- if hr = procImportLayerEnd.Find(); hr != nil {
|
|
| 504 |
- return |
|
| 505 |
- } |
|
| 506 |
- r0, _, _ := syscall.Syscall(procImportLayerEnd.Addr(), 1, uintptr(context), 0, 0) |
|
| 507 |
- if int32(r0) < 0 {
|
|
| 508 |
- hr = interop.Win32FromHresult(r0) |
|
| 509 |
- } |
|
| 510 |
- return |
|
| 511 |
-} |
|
| 512 |
- |
|
| 513 |
-func exportLayerBegin(info *driverInfo, id string, descriptors []WC_LAYER_DESCRIPTOR, context *uintptr) (hr error) {
|
|
| 514 |
- var _p0 *uint16 |
|
| 515 |
- _p0, hr = syscall.UTF16PtrFromString(id) |
|
| 516 |
- if hr != nil {
|
|
| 517 |
- return |
|
| 518 |
- } |
|
| 519 |
- return _exportLayerBegin(info, _p0, descriptors, context) |
|
| 520 |
-} |
|
| 521 |
- |
|
| 522 |
-func _exportLayerBegin(info *driverInfo, id *uint16, descriptors []WC_LAYER_DESCRIPTOR, context *uintptr) (hr error) {
|
|
| 523 |
- var _p1 *WC_LAYER_DESCRIPTOR |
|
| 524 |
- if len(descriptors) > 0 {
|
|
| 525 |
- _p1 = &descriptors[0] |
|
| 526 |
- } |
|
| 527 |
- if hr = procExportLayerBegin.Find(); hr != nil {
|
|
| 528 |
- return |
|
| 529 |
- } |
|
| 530 |
- r0, _, _ := syscall.Syscall6(procExportLayerBegin.Addr(), 5, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(_p1)), uintptr(len(descriptors)), uintptr(unsafe.Pointer(context)), 0) |
|
| 531 |
- if int32(r0) < 0 {
|
|
| 532 |
- hr = interop.Win32FromHresult(r0) |
|
| 533 |
- } |
|
| 534 |
- return |
|
| 535 |
-} |
|
| 536 |
- |
|
| 537 |
-func exportLayerNext(context uintptr, fileName **uint16, fileInfo *winio.FileBasicInfo, fileSize *int64, deleted *uint32) (hr error) {
|
|
| 538 |
- if hr = procExportLayerNext.Find(); hr != nil {
|
|
| 539 |
- return |
|
| 540 |
- } |
|
| 541 |
- r0, _, _ := syscall.Syscall6(procExportLayerNext.Addr(), 5, uintptr(context), uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(fileInfo)), uintptr(unsafe.Pointer(fileSize)), uintptr(unsafe.Pointer(deleted)), 0) |
|
| 542 |
- if int32(r0) < 0 {
|
|
| 543 |
- hr = interop.Win32FromHresult(r0) |
|
| 544 |
- } |
|
| 545 |
- return |
|
| 546 |
-} |
|
| 547 |
- |
|
| 548 |
-func exportLayerRead(context uintptr, buffer []byte, bytesRead *uint32) (hr error) {
|
|
| 549 |
- var _p0 *byte |
|
| 550 |
- if len(buffer) > 0 {
|
|
| 551 |
- _p0 = &buffer[0] |
|
| 552 |
- } |
|
| 553 |
- if hr = procExportLayerRead.Find(); hr != nil {
|
|
| 554 |
- return |
|
| 555 |
- } |
|
| 556 |
- r0, _, _ := syscall.Syscall6(procExportLayerRead.Addr(), 4, uintptr(context), uintptr(unsafe.Pointer(_p0)), uintptr(len(buffer)), uintptr(unsafe.Pointer(bytesRead)), 0, 0) |
|
| 557 |
- if int32(r0) < 0 {
|
|
| 558 |
- hr = interop.Win32FromHresult(r0) |
|
| 559 |
- } |
|
| 560 |
- return |
|
| 561 |
-} |
|
| 562 |
- |
|
| 563 |
-func exportLayerEnd(context uintptr) (hr error) {
|
|
| 564 |
- if hr = procExportLayerEnd.Find(); hr != nil {
|
|
| 565 |
- return |
|
| 566 |
- } |
|
| 567 |
- r0, _, _ := syscall.Syscall(procExportLayerEnd.Addr(), 1, uintptr(context), 0, 0) |
|
| 568 |
- if int32(r0) < 0 {
|
|
| 569 |
- hr = interop.Win32FromHresult(r0) |
|
| 570 |
- } |
|
| 571 |
- return |
|
| 572 |
-} |
|
| 573 |
- |
|
| 574 | 443 |
func grantVmAccess(vmid string, filepath string) (hr error) {
|
| 575 | 444 |
var _p0 *uint16 |
| 576 | 445 |
_p0, hr = syscall.UTF16PtrFromString(vmid) |
| ... | ... |
@@ -5,7 +5,6 @@ import ( |
| 5 | 5 |
"path/filepath" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/Microsoft/hcsshim/internal/guid" |
| 8 |
- |
|
| 9 | 8 |
"github.com/Microsoft/hcsshim/internal/wclayer" |
| 10 | 9 |
) |
| 11 | 10 |
|
| ... | ... |
@@ -74,9 +73,6 @@ type DriverInfo struct {
|
| 74 | 74 |
HomeDir string |
| 75 | 75 |
} |
| 76 | 76 |
|
| 77 |
-type FilterLayerReader = wclayer.FilterLayerReader |
|
| 78 |
-type FilterLayerWriter = wclayer.FilterLayerWriter |
|
| 79 |
- |
|
| 80 | 77 |
type GUID [16]byte |
| 81 | 78 |
|
| 82 | 79 |
func NameToGuid(name string) (id GUID, err error) {
|