...
1
2
3 package runhcs
4
5 import (
6 "encoding/json"
7
8 "github.com/Microsoft/go-winio"
9 )
10
11
12 type VMRequestOp string
13
14 const (
15
16 OpCreateContainer VMRequestOp = "create"
17
18 OpSyncNamespace VMRequestOp = "sync"
19
20 OpUnmountContainer VMRequestOp = "unmount"
21
22 OpUnmountContainerDiskOnly VMRequestOp = "unmount-disk"
23 )
24
25
26 type VMRequest struct {
27 ID string
28 Op VMRequestOp
29 }
30
31
32 func IssueVMRequest(pipepath string, req *VMRequest) error {
33 pipe, err := winio.DialPipe(pipepath, nil)
34 if err != nil {
35 return err
36 }
37 defer pipe.Close()
38 if err := json.NewEncoder(pipe).Encode(req); err != nil {
39 return err
40 }
41 if err := GetErrorFromPipe(pipe, nil); err != nil {
42 return err
43 }
44 return nil
45 }
46
View as plain text