diff --git a/Gopkg.lock b/Gopkg.lock index 58fa448b7d..8750957dcb 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -115,21 +115,21 @@ revision = "3520598351bb3500a49ae9563f5539666ae0a27c" [[projects]] - digest = "1:28e35e3d543955b2cb091308a4aeb3400ba66510dde85743719772c677482183" + digest = "1:a801632523299b53fbd954449f36020cf751e4bd6fe2d923e3416e8f0603b4af" name = "github.com/intel/govmm" packages = ["qemu"] pruneopts = "NUT" - revision = "6ff20ae2f409df976574d0139b5ec2fa3e314769" + revision = "eda239928bfa12b214e9c93192d548cccf4e7f1e" [[projects]] - digest = "1:b06e09c4554e80f208a583009e54369d109549501b776ca9fc6d59968c68aa29" + digest = "1:f2f0d25f32da7843fa4cdc2becb88eea9d1aa9f9c4167431b4c1cd1c3b7fb17c" name = "github.com/kata-containers/agent" packages = [ "protocols/client", "protocols/grpc", ] pruneopts = "NUT" - revision = "eec68398287d9491fe648a8e54fb942cf6b6d934" + revision = "e6d26c1bbbaf1c7292b1ee5dfa17ca13159f73b7" [[projects]] digest = "1:04054595e5c5a35d1553a7f3464d18577caf597445d643992998643df56d4afd" diff --git a/Gopkg.toml b/Gopkg.toml index 92c37defe4..23b20327d5 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -52,11 +52,11 @@ [[constraint]] name = "github.com/intel/govmm" - revision = "6ff20ae2f409df976574d0139b5ec2fa3e314769" + revision = "eda239928bfa12b214e9c93192d548cccf4e7f1e" [[constraint]] name = "github.com/kata-containers/agent" - revision = "eec68398287d9491fe648a8e54fb942cf6b6d934" + revision = "e6d26c1bbbaf1c7292b1ee5dfa17ca13159f73b7" [[constraint]] name = "github.com/containerd/cri-containerd" diff --git a/cli/main.go b/cli/main.go index be6f8db115..f3d6ba580a 100644 --- a/cli/main.go +++ b/cli/main.go @@ -129,6 +129,7 @@ var runtimeCommands = []cli.Command{ // Kata Containers specific extensions kataCheckCLICommand, kataEnvCLICommand, + kataNetworkCLICommand, factoryCLICommand, } diff --git a/cli/network.go b/cli/network.go new file mode 100644 index 0000000000..a90ab10fe2 --- /dev/null +++ b/cli/network.go @@ -0,0 +1,203 @@ +// Copyright (c) 2018 Huawei Corporation. +// +// SPDX-License-Identifier: Apache-2.0 +// + +package main + +import ( + "encoding/json" + "fmt" + "os" + + "github.com/kata-containers/agent/protocols/grpc" + vc "github.com/kata-containers/runtime/virtcontainers" + "github.com/sirupsen/logrus" + "github.com/urfave/cli" +) + +type networkType int + +const ( + // interfaceType for interface operation + interfaceType networkType = iota + + routeType +) + +var kataNetworkCLICommand = cli.Command{ + Name: "kata-network", + Usage: "manage interfaces and routes for container", + Subcommands: []cli.Command{ + addIfaceCommand, + delIfaceCommand, + listIfacesCommand, + updateRoutesCommand, + listRoutesCommand, + }, + Action: func(context *cli.Context) error { + return cli.ShowSubcommandHelp(context) + }, +} + +var addIfaceCommand = cli.Command{ + Name: "add-iface", + Usage: "add an interface to a container", + ArgsUsage: `add-iface file or - for stdin`, + Flags: []cli.Flag{}, + Action: func(context *cli.Context) error { + return networkModifyCommand(context.Args().First(), context.Args().Get(1), interfaceType, true) + }, +} + +var delIfaceCommand = cli.Command{ + Name: "del-iface", + Usage: "delete an interface from a container", + ArgsUsage: `del-iface file or - for stdin`, + Flags: []cli.Flag{}, + Action: func(context *cli.Context) error { + return networkModifyCommand(context.Args().First(), context.Args().Get(1), interfaceType, false) + }, +} + +var listIfacesCommand = cli.Command{ + Name: "list-ifaces", + Usage: "list network interfaces in a container", + ArgsUsage: `list-ifaces `, + Flags: []cli.Flag{}, + Action: func(context *cli.Context) error { + return networkListCommand(context.Args().First(), interfaceType) + }, +} + +var updateRoutesCommand = cli.Command{ + Name: "update-routes", + Usage: "update routes of a container", + ArgsUsage: `update-routes file or - for stdin`, + Flags: []cli.Flag{}, + Action: func(context *cli.Context) error { + return networkModifyCommand(context.Args().First(), context.Args().Get(1), routeType, true) + }, +} + +var listRoutesCommand = cli.Command{ + Name: "list-routes", + Usage: "list network routes in a container", + ArgsUsage: `list-routes `, + Flags: []cli.Flag{}, + Action: func(context *cli.Context) error { + return networkListCommand(context.Args().First(), routeType) + }, +} + +func networkModifyCommand(containerID, input string, opType networkType, add bool) (err error) { + status, sandboxID, err := getExistingContainerInfo(containerID) + if err != nil { + return err + } + + containerID = status.ID + + kataLog = kataLog.WithFields(logrus.Fields{ + "container": containerID, + "sandbox": sandboxID, + }) + + setExternalLoggers(kataLog) + + // container MUST be running + if status.State.State != vc.StateRunning { + return fmt.Errorf("container %s is not running", containerID) + } + + var ( + f *os.File + output = defaultOutputFile + ) + + if input == "-" { + f = os.Stdin + } else { + f, err = os.Open(input) + if err != nil { + return err + } + defer f.Close() + } + switch opType { + case interfaceType: + var inf, resultingInf *grpc.Interface + if err = json.NewDecoder(f).Decode(&inf); err != nil { + return err + } + if add { + resultingInf, err = vci.AddInterface(sandboxID, inf) + if err != nil { + kataLog.WithField("resulting-interface", fmt.Sprintf("%+v", resultingInf)). + WithError(err).Error("add interface failed") + } + } else { + resultingInf, err = vci.RemoveInterface(sandboxID, inf) + if err != nil { + kataLog.WithField("resulting-interface", fmt.Sprintf("%+v", resultingInf)). + WithError(err).Error("delete interface failed") + } + } + json.NewEncoder(output).Encode(resultingInf) + case routeType: + var routes, resultingRoutes []*grpc.Route + if err = json.NewDecoder(f).Decode(&routes); err != nil { + return err + } + resultingRoutes, err = vci.UpdateRoutes(sandboxID, routes) + json.NewEncoder(output).Encode(resultingRoutes) + if err != nil { + kataLog.WithField("resulting-routes", fmt.Sprintf("%+v", resultingRoutes)). + WithError(err).Error("update routes failed") + } + } + return err +} + +func networkListCommand(containerID string, opType networkType) (err error) { + status, sandboxID, err := getExistingContainerInfo(containerID) + if err != nil { + return err + } + + containerID = status.ID + + kataLog = kataLog.WithFields(logrus.Fields{ + "container": containerID, + "sandbox": sandboxID, + }) + + setExternalLoggers(kataLog) + + // container MUST be running + if status.State.State != vc.StateRunning { + return fmt.Errorf("container %s is not running", containerID) + } + + var file = defaultOutputFile + + switch opType { + case interfaceType: + var interfaces []*grpc.Interface + interfaces, err = vci.ListInterfaces(sandboxID) + if err != nil { + kataLog.WithField("existing-interfaces", fmt.Sprintf("%+v", interfaces)). + WithError(err).Error("list interfaces failed") + } + json.NewEncoder(file).Encode(interfaces) + case routeType: + var routes []*grpc.Route + routes, err = vci.ListRoutes(sandboxID) + if err != nil { + kataLog.WithField("resulting-routes", fmt.Sprintf("%+v", routes)). + WithError(err).Error("update routes failed") + } + json.NewEncoder(file).Encode(routes) + } + return err +} diff --git a/cli/network_test.go b/cli/network_test.go new file mode 100644 index 0000000000..37a63ea040 --- /dev/null +++ b/cli/network_test.go @@ -0,0 +1,88 @@ +// Copyright (c) 2018 Huawei Corporation. +// +// SPDX-License-Identifier: Apache-2.0 +// + +package main + +import ( + "flag" + "io/ioutil" + "os" + "testing" + + "github.com/kata-containers/agent/protocols/grpc" + vc "github.com/kata-containers/runtime/virtcontainers" + "github.com/stretchr/testify/assert" +) + +var ( + testAddInterfaceFuncReturnNil = func(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) { + return nil, nil + } + testRemoveInterfaceFuncReturnNil = func(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) { + return nil, nil + } + testListInterfacesFuncReturnNil = func(sandboxID string) ([]*grpc.Interface, error) { + return nil, nil + } + testUpdateRoutsFuncReturnNil = func(sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error) { + return nil, nil + } + testListRoutesFuncReturnNil = func(sandboxID string) ([]*grpc.Route, error) { + return nil, nil + } +) + +func TestNetworkCliFunction(t *testing.T) { + assert := assert.New(t) + + state := vc.State{ + State: vc.StateRunning, + } + + testingImpl.AddInterfaceFunc = testAddInterfaceFuncReturnNil + testingImpl.RemoveInterfaceFunc = testRemoveInterfaceFuncReturnNil + testingImpl.ListInterfacesFunc = testListInterfacesFuncReturnNil + testingImpl.UpdateRoutesFunc = testUpdateRoutsFuncReturnNil + testingImpl.ListRoutesFunc = testListRoutesFuncReturnNil + + path, err := createTempContainerIDMapping(testContainerID, testSandboxID) + assert.NoError(err) + defer os.RemoveAll(path) + + testingImpl.StatusContainerFunc = func(sandboxID, containerID string) (vc.ContainerStatus, error) { + return newSingleContainerStatus(testContainerID, state, map[string]string{}), nil + } + + defer func() { + testingImpl.AddInterfaceFunc = nil + testingImpl.RemoveInterfaceFunc = nil + testingImpl.ListInterfacesFunc = nil + testingImpl.UpdateRoutesFunc = nil + testingImpl.ListRoutesFunc = nil + testingImpl.StatusContainerFunc = nil + }() + + set := flag.NewFlagSet("", 0) + execCLICommandFunc(assert, addIfaceCommand, set, true) + + set.Parse([]string{testContainerID}) + execCLICommandFunc(assert, listIfacesCommand, set, false) + execCLICommandFunc(assert, listRoutesCommand, set, false) + + f, err := ioutil.TempFile("", "interface") + defer os.Remove(f.Name()) + assert.NoError(err) + assert.NotNil(f) + f.WriteString("{}") + + set.Parse([]string{testContainerID, f.Name()}) + execCLICommandFunc(assert, addIfaceCommand, set, false) + execCLICommandFunc(assert, delIfaceCommand, set, false) + + f.Seek(0, 0) + f.WriteString("[{}]") + f.Close() + execCLICommandFunc(assert, updateRoutesCommand, set, false) +} diff --git a/vendor/github.com/intel/govmm/qemu/image.go b/vendor/github.com/intel/govmm/qemu/image.go index 4f064c681b..352659adbb 100644 --- a/vendor/github.com/intel/govmm/qemu/image.go +++ b/vendor/github.com/intel/govmm/qemu/image.go @@ -45,9 +45,11 @@ func CreateCloudInitISO(ctx context.Context, scratchDir, isoPath string, userDataPath := path.Join(dataDirPath, "user_data") defer func() { + /* #nosec */ _ = os.RemoveAll(configDrivePath) }() + /* #nosec */ err := os.MkdirAll(dataDirPath, 0755) if err != nil { return fmt.Errorf("Unable to create config drive directory %s : %v", diff --git a/vendor/github.com/intel/govmm/qemu/qemu.go b/vendor/github.com/intel/govmm/qemu/qemu.go index 4f7a383ee1..31254231d2 100644 --- a/vendor/github.com/intel/govmm/qemu/qemu.go +++ b/vendor/github.com/intel/govmm/qemu/qemu.go @@ -63,28 +63,28 @@ const ( NVDIMM DeviceDriver = "nvdimm" // Virtio9P is the 9pfs device driver. - Virtio9P = "virtio-9p-pci" + Virtio9P DeviceDriver = "virtio-9p-pci" // VirtioNet is the virt-io networking device driver. - VirtioNet = "virtio-net" + VirtioNet DeviceDriver = "virtio-net" // VirtioNetPCI is the virt-io pci networking device driver. - VirtioNetPCI = "virtio-net-pci" + VirtioNetPCI DeviceDriver = "virtio-net-pci" // VirtioSerial is the serial device driver. - VirtioSerial = "virtio-serial-pci" + VirtioSerial DeviceDriver = "virtio-serial-pci" // VirtioBlock is the block device driver. - VirtioBlock = "virtio-blk" + VirtioBlock DeviceDriver = "virtio-blk" // Console is the console device driver. - Console = "virtconsole" + Console DeviceDriver = "virtconsole" // VirtioSerialPort is the serial port device driver. - VirtioSerialPort = "virtserialport" + VirtioSerialPort DeviceDriver = "virtserialport" // VHostVSockPCI is the vhost vsock pci driver. - VHostVSockPCI = "vhost-vsock-pci" + VHostVSockPCI DeviceDriver = "vhost-vsock-pci" ) // ObjectType is a string representing a qemu object type. @@ -171,10 +171,10 @@ const ( Local FSDriver = "local" // Handle is the handle qemu filesystem driver. - Handle = "handle" + Handle FSDriver = "handle" // Proxy is the proxy qemu filesystem driver. - Proxy = "proxy" + Proxy FSDriver = "proxy" ) const ( @@ -182,13 +182,13 @@ const ( None SecurityModelType = "none" // PassThrough uses the same credentials on both the host and guest. - PassThrough = "passthrough" + PassThrough SecurityModelType = "passthrough" // MappedXattr stores some files attributes as extended attributes. - MappedXattr = "mapped-xattr" + MappedXattr SecurityModelType = "mapped-xattr" // MappedFile stores some files attributes in the .virtfs directory. - MappedFile = "mapped-file" + MappedFile SecurityModelType = "mapped-file" ) // FSDevice represents a qemu filesystem configuration. @@ -259,19 +259,19 @@ const ( Pipe CharDeviceBackend = "pipe" // Socket creates a 2 way stream socket (TCP or Unix). - Socket = "socket" + Socket CharDeviceBackend = "socket" // CharConsole sends traffic from the guest to QEMU's standard output. - CharConsole = "console" + CharConsole CharDeviceBackend = "console" // Serial sends traffic from the guest to a serial device on the host. - Serial = "serial" + Serial CharDeviceBackend = "serial" // TTY is an alias for Serial. - TTY = "tty" + TTY CharDeviceBackend = "tty" // PTY creates a new pseudo-terminal on the host and connect to it. - PTY = "pty" + PTY CharDeviceBackend = "pty" ) // CharDevice represents a qemu character device. @@ -348,19 +348,19 @@ const ( TAP NetDeviceType = "tap" // MACVTAP is a macvtap networking device type. - MACVTAP = "macvtap" + MACVTAP NetDeviceType = "macvtap" // IPVTAP is a ipvtap virtual networking device type. - IPVTAP = "ipvtap" + IPVTAP NetDeviceType = "ipvtap" // VETHTAP is a veth-tap virtual networking device type. - VETHTAP = "vethtap" + VETHTAP NetDeviceType = "vethtap" // VFIO is a direct assigned PCI device or PCI VF - VFIO = "VFIO" + VFIO NetDeviceType = "VFIO" // VHOSTUSER is a vhost-user port (socket) - VHOSTUSER = "vhostuser" + VHOSTUSER NetDeviceType = "vhostuser" ) // QemuNetdevParam converts to the QEMU -netdev parameter notation @@ -637,7 +637,7 @@ const ( NoInterface BlockDeviceInterface = "none" // SCSI represents a SCSI block device interface. - SCSI = "scsi" + SCSI BlockDeviceInterface = "scsi" ) const ( @@ -645,7 +645,7 @@ const ( Threads BlockDeviceAIO = "threads" // Native is the pthread asynchronous I/O implementation. - Native = "native" + Native BlockDeviceAIO = "native" ) const ( @@ -976,7 +976,9 @@ type VSOCKDevice struct { const ( // MinimalGuestCID is the smallest valid context ID for a guest. MinimalGuestCID uint32 = 3 +) +const ( // VhostVSOCKPCI is the VSOCK vhost device type. VhostVSOCKPCI = "vhost-vsock-pci" @@ -1029,7 +1031,7 @@ const ( UTC RTCBaseType = "utc" // LocalTime is the local base time for qemu RTC. - LocalTime = "localtime" + LocalTime RTCBaseType = "localtime" ) const ( @@ -1037,7 +1039,7 @@ const ( Host RTCClock = "host" // VM is for using the guest clock as a reference - VM = "vm" + VM RTCClock = "vm" ) const ( @@ -1045,7 +1047,7 @@ const ( Slew RTCDriftFix = "slew" // NoDriftFix means we don't want/need to fix qemu's RTC drift. - NoDriftFix = "none" + NoDriftFix RTCDriftFix = "none" ) // RTC represents a qemu Real Time Clock configuration. @@ -1669,6 +1671,7 @@ func LaunchCustomQemu(ctx context.Context, path string, params []string, fds []* path = "qemu-system-x86_64" } + /* #nosec */ cmd := exec.Command(path, params...) if len(fds) > 0 { logger.Infof("Adding extra file %v", fds) diff --git a/vendor/github.com/intel/govmm/qemu/qmp.go b/vendor/github.com/intel/govmm/qemu/qmp.go index 32a59ef04b..ea6cb6454e 100644 --- a/vendor/github.com/intel/govmm/qemu/qmp.go +++ b/vendor/github.com/intel/govmm/qemu/qmp.go @@ -24,9 +24,12 @@ import ( "fmt" "io" "net" + "os" + "syscall" "time" "context" + "strings" ) // QMPLog is a logging interface used by the qemu package to log various @@ -118,6 +121,7 @@ type qmpCommand struct { args map[string]interface{} filter *qmpEventFilter resultReceived bool + oob []byte } // QMP is a structure that contains the internal state used by startQMPLoop and @@ -302,7 +306,12 @@ func (q *QMP) writeNextQMPCommand(cmdQueue *list.List) { } q.cfg.Logger.Infof("%s", string(encodedCmd)) encodedCmd = append(encodedCmd, '\n') - _, err = q.conn.Write(encodedCmd) + if unixConn, ok := q.conn.(*net.UnixConn); ok && len(cmd.oob) > 0 { + _, _, err = unixConn.WriteMsgUnix(encodedCmd, cmd.oob, nil) + } else { + _, err = q.conn.Write(encodedCmd) + } + if err != nil { cmd.res <- qmpResult{ err: fmt.Errorf("Unable to write command to qmp socket %v", err), @@ -409,13 +418,14 @@ func (q *QMP) mainLoop() { if q.cfg.EventCh != nil { close(q.cfg.EventCh) } + /* #nosec */ _ = q.conn.Close() _ = <-fromVMCh failOutstandingCommands(cmdQueue) close(q.disconnectedCh) }() - version := []byte{} + var version []byte var cmdDoneCh <-chan struct{} DONE: @@ -485,7 +495,7 @@ func startQMPLoop(conn io.ReadWriteCloser, cfg QMPConfig, } func (q *QMP) executeCommandWithResponse(ctx context.Context, name string, args map[string]interface{}, - filter *qmpEventFilter) (interface{}, error) { + oob []byte, filter *qmpEventFilter) (interface{}, error) { var err error var response interface{} resCh := make(chan qmpResult) @@ -498,6 +508,7 @@ func (q *QMP) executeCommandWithResponse(ctx context.Context, name string, args name: name, args: args, filter: filter, + oob: oob, }: } @@ -519,7 +530,7 @@ func (q *QMP) executeCommandWithResponse(ctx context.Context, name string, args func (q *QMP) executeCommand(ctx context.Context, name string, args map[string]interface{}, filter *qmpEventFilter) error { - _, err := q.executeCommandWithResponse(ctx, name, args, filter) + _, err := q.executeCommandWithResponse(ctx, name, args, nil, filter) return err } @@ -727,6 +738,68 @@ func (q *QMP) ExecuteBlockdevDel(ctx context.Context, blockdevID string) error { return q.executeCommand(ctx, "x-blockdev-del", args, nil) } +// ExecuteNetdevAdd adds a Net device to a QEMU instance +// using the netdev_add command. netdevID is the id of the device to add. +// Must be valid QMP identifier. +func (q *QMP) ExecuteNetdevAdd(ctx context.Context, netdevType, netdevID, ifname, downscript, script string, queues int) error { + args := map[string]interface{}{ + "type": netdevType, + "id": netdevID, + "ifname": ifname, + "downscript": downscript, + "script": script, + } + if queues > 1 { + args["queues"] = queues + } + + return q.executeCommand(ctx, "netdev_add", args, nil) +} + +// ExecuteNetdevAddByFds adds a Net device to a QEMU instance +// using the netdev_add command by fds and vhostfds. netdevID is the id of the device to add. +// Must be valid QMP identifier. +func (q *QMP) ExecuteNetdevAddByFds(ctx context.Context, netdevType, netdevID string, fdNames, vhostFdNames []string) error { + fdNameStr := strings.Join(fdNames, ":") + vhostFdNameStr := strings.Join(vhostFdNames, ":") + args := map[string]interface{}{ + "type": netdevType, + "id": netdevID, + "fds": fdNameStr, + "vhost": "on", + "vhostfds": vhostFdNameStr, + } + + return q.executeCommand(ctx, "netdev_add", args, nil) +} + +// ExecuteNetdevDel deletes a Net device from a QEMU instance +// using the netdev_del command. netdevID is the id of the device to delete. +func (q *QMP) ExecuteNetdevDel(ctx context.Context, netdevID string) error { + args := map[string]interface{}{ + "id": netdevID, + } + return q.executeCommand(ctx, "netdev_del", args, nil) +} + +// ExecuteNetPCIDeviceAdd adds a Net PCI device to a QEMU instance +// using the device_add command. devID is the id of the device to add. +// Must be valid QMP identifier. netdevID is the id of nic added by previous netdev_add. +func (q *QMP) ExecuteNetPCIDeviceAdd(ctx context.Context, netdevID, devID, macAddr, addr, bus string) error { + args := map[string]interface{}{ + "id": devID, + "driver": VirtioNetPCI, + "netdev": netdevID, + "mac": macAddr, + "addr": addr, + } + + if bus != "" { + args["bus"] = bus + } + return q.executeCommand(ctx, "device_add", args, nil) +} + // ExecuteDeviceDel deletes guest portion of a QEMU device by sending a // device_del command. devId is the identifier of the device to delete. // Typically it would match the devID parameter passed to an earlier call @@ -809,7 +882,7 @@ func (q *QMP) ExecuteCPUDeviceAdd(ctx context.Context, driver, cpuID, socketID, // ExecuteQueryHotpluggableCPUs returns a slice with the list of hotpluggable CPUs func (q *QMP) ExecuteQueryHotpluggableCPUs(ctx context.Context) ([]HotpluggableCPU, error) { - response, err := q.executeCommandWithResponse(ctx, "query-hotpluggable-cpus", nil, nil) + response, err := q.executeCommandWithResponse(ctx, "query-hotpluggable-cpus", nil, nil, nil) if err != nil { return nil, err } @@ -883,11 +956,65 @@ func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string } // ExecutePCIVSockAdd adds a vhost-vsock-pci bus -func (q *QMP) ExecutePCIVSockAdd(ctx context.Context, id, guestCID string) error { +func (q *QMP) ExecutePCIVSockAdd(ctx context.Context, id, guestCID, vhostfd string, disableModern bool) error { args := map[string]interface{}{ "driver": VHostVSockPCI, "id": id, "guest-cid": guestCID, + "vhostfd": vhostfd, + } + + if disableModern { + args["disable-modern"] = disableModern + } + + return q.executeCommand(ctx, "device_add", args, nil) +} + +// ExecuteGetFD sends a file descriptor via SCM rights and assigns it a name +func (q *QMP) ExecuteGetFD(ctx context.Context, fdname string, fd *os.File) error { + oob := syscall.UnixRights(int(fd.Fd())) + args := map[string]interface{}{ + "fdname": fdname, } + + _, err := q.executeCommandWithResponse(ctx, "getfd", args, oob, nil) + return err +} + +// ExecuteCharDevUnixSocketAdd adds a character device using as backend a unix socket, +// id is an identifier for the device, path specifies the local path of the unix socket, +// wait is to block waiting for a client to connect, server specifies that the socket is a listening socket. +func (q *QMP) ExecuteCharDevUnixSocketAdd(ctx context.Context, id, path string, wait, server bool) error { + args := map[string]interface{}{ + "id": id, + "backend": map[string]interface{}{ + "type": "socket", + "data": map[string]interface{}{ + "wait": wait, + "server": server, + "addr": map[string]interface{}{ + "type": "unix", + "data": map[string]interface{}{ + "path": path, + }, + }, + }, + }, + } + return q.executeCommand(ctx, "chardev-add", args, nil) +} + +// ExecuteVirtSerialPortAdd adds a virtserialport. +// id is an identifier for the virtserialport, name is a name for the virtserialport and +// it will be visible in the VM, chardev is the character device id previously added. +func (q *QMP) ExecuteVirtSerialPortAdd(ctx context.Context, id, name, chardev string) error { + args := map[string]interface{}{ + "driver": VirtioSerialPort, + "id": id, + "name": name, + "chardev": chardev, + } + return q.executeCommand(ctx, "device_add", args, nil) } diff --git a/vendor/github.com/kata-containers/agent/protocols/grpc/agent.pb.go b/vendor/github.com/kata-containers/agent/protocols/grpc/agent.pb.go index 91ce01be5f..07164f1360 100644 --- a/vendor/github.com/kata-containers/agent/protocols/grpc/agent.pb.go +++ b/vendor/github.com/kata-containers/agent/protocols/grpc/agent.pb.go @@ -44,12 +44,15 @@ DestroySandboxRequest IPAddress Interface + Interfaces Route Routes UpdateInterfaceRequest AddInterfaceRequest RemoveInterfaceRequest UpdateRoutesRequest + ListInterfacesRequest + ListRoutesRequest OnlineCPUMemRequest ReseedRandomDevRequest Storage @@ -1212,6 +1215,22 @@ func (m *Interface) GetHwAddr() string { return "" } +type Interfaces struct { + Interfaces []*Interface `protobuf:"bytes,1,rep,name=Interfaces" json:"Interfaces,omitempty"` +} + +func (m *Interfaces) Reset() { *m = Interfaces{} } +func (m *Interfaces) String() string { return proto.CompactTextString(m) } +func (*Interfaces) ProtoMessage() {} +func (*Interfaces) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{34} } + +func (m *Interfaces) GetInterfaces() []*Interface { + if m != nil { + return m.Interfaces + } + return nil +} + type Route struct { Dest string `protobuf:"bytes,1,opt,name=dest,proto3" json:"dest,omitempty"` Gateway string `protobuf:"bytes,2,opt,name=gateway,proto3" json:"gateway,omitempty"` @@ -1223,7 +1242,7 @@ type Route struct { func (m *Route) Reset() { *m = Route{} } func (m *Route) String() string { return proto.CompactTextString(m) } func (*Route) ProtoMessage() {} -func (*Route) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{34} } +func (*Route) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{35} } func (m *Route) GetDest() string { if m != nil { @@ -1267,7 +1286,7 @@ type Routes struct { func (m *Routes) Reset() { *m = Routes{} } func (m *Routes) String() string { return proto.CompactTextString(m) } func (*Routes) ProtoMessage() {} -func (*Routes) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{35} } +func (*Routes) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{36} } func (m *Routes) GetRoutes() []*Route { if m != nil { @@ -1283,7 +1302,7 @@ type UpdateInterfaceRequest struct { func (m *UpdateInterfaceRequest) Reset() { *m = UpdateInterfaceRequest{} } func (m *UpdateInterfaceRequest) String() string { return proto.CompactTextString(m) } func (*UpdateInterfaceRequest) ProtoMessage() {} -func (*UpdateInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{36} } +func (*UpdateInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{37} } func (m *UpdateInterfaceRequest) GetInterface() *Interface { if m != nil { @@ -1299,7 +1318,7 @@ type AddInterfaceRequest struct { func (m *AddInterfaceRequest) Reset() { *m = AddInterfaceRequest{} } func (m *AddInterfaceRequest) String() string { return proto.CompactTextString(m) } func (*AddInterfaceRequest) ProtoMessage() {} -func (*AddInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{37} } +func (*AddInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{38} } func (m *AddInterfaceRequest) GetInterface() *Interface { if m != nil { @@ -1315,7 +1334,7 @@ type RemoveInterfaceRequest struct { func (m *RemoveInterfaceRequest) Reset() { *m = RemoveInterfaceRequest{} } func (m *RemoveInterfaceRequest) String() string { return proto.CompactTextString(m) } func (*RemoveInterfaceRequest) ProtoMessage() {} -func (*RemoveInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{38} } +func (*RemoveInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{39} } func (m *RemoveInterfaceRequest) GetInterface() *Interface { if m != nil { @@ -1331,7 +1350,7 @@ type UpdateRoutesRequest struct { func (m *UpdateRoutesRequest) Reset() { *m = UpdateRoutesRequest{} } func (m *UpdateRoutesRequest) String() string { return proto.CompactTextString(m) } func (*UpdateRoutesRequest) ProtoMessage() {} -func (*UpdateRoutesRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{39} } +func (*UpdateRoutesRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{40} } func (m *UpdateRoutesRequest) GetRoutes() *Routes { if m != nil { @@ -1340,6 +1359,22 @@ func (m *UpdateRoutesRequest) GetRoutes() *Routes { return nil } +type ListInterfacesRequest struct { +} + +func (m *ListInterfacesRequest) Reset() { *m = ListInterfacesRequest{} } +func (m *ListInterfacesRequest) String() string { return proto.CompactTextString(m) } +func (*ListInterfacesRequest) ProtoMessage() {} +func (*ListInterfacesRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{41} } + +type ListRoutesRequest struct { +} + +func (m *ListRoutesRequest) Reset() { *m = ListRoutesRequest{} } +func (m *ListRoutesRequest) String() string { return proto.CompactTextString(m) } +func (*ListRoutesRequest) ProtoMessage() {} +func (*ListRoutesRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{42} } + type OnlineCPUMemRequest struct { // Wait specifies if the caller waits for the agent to online all resources. // If true the agent returns once all resources have been connected, otherwise all @@ -1352,7 +1387,7 @@ type OnlineCPUMemRequest struct { func (m *OnlineCPUMemRequest) Reset() { *m = OnlineCPUMemRequest{} } func (m *OnlineCPUMemRequest) String() string { return proto.CompactTextString(m) } func (*OnlineCPUMemRequest) ProtoMessage() {} -func (*OnlineCPUMemRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{40} } +func (*OnlineCPUMemRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{43} } func (m *OnlineCPUMemRequest) GetWait() bool { if m != nil { @@ -1376,7 +1411,7 @@ type ReseedRandomDevRequest struct { func (m *ReseedRandomDevRequest) Reset() { *m = ReseedRandomDevRequest{} } func (m *ReseedRandomDevRequest) String() string { return proto.CompactTextString(m) } func (*ReseedRandomDevRequest) ProtoMessage() {} -func (*ReseedRandomDevRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{41} } +func (*ReseedRandomDevRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{44} } func (m *ReseedRandomDevRequest) GetData() []byte { if m != nil { @@ -1418,7 +1453,7 @@ type Storage struct { func (m *Storage) Reset() { *m = Storage{} } func (m *Storage) String() string { return proto.CompactTextString(m) } func (*Storage) ProtoMessage() {} -func (*Storage) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{42} } +func (*Storage) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{45} } func (m *Storage) GetDriver() string { if m != nil { @@ -1501,7 +1536,7 @@ type Device struct { func (m *Device) Reset() { *m = Device{} } func (m *Device) String() string { return proto.CompactTextString(m) } func (*Device) ProtoMessage() {} -func (*Device) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{43} } +func (*Device) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{46} } func (m *Device) GetId() string { if m != nil { @@ -1547,7 +1582,7 @@ type StringUser struct { func (m *StringUser) Reset() { *m = StringUser{} } func (m *StringUser) String() string { return proto.CompactTextString(m) } func (*StringUser) ProtoMessage() {} -func (*StringUser) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{44} } +func (*StringUser) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{47} } func (m *StringUser) GetUid() string { if m != nil { @@ -1605,12 +1640,15 @@ func init() { proto.RegisterType((*DestroySandboxRequest)(nil), "grpc.DestroySandboxRequest") proto.RegisterType((*IPAddress)(nil), "grpc.IPAddress") proto.RegisterType((*Interface)(nil), "grpc.Interface") + proto.RegisterType((*Interfaces)(nil), "grpc.Interfaces") proto.RegisterType((*Route)(nil), "grpc.Route") proto.RegisterType((*Routes)(nil), "grpc.Routes") proto.RegisterType((*UpdateInterfaceRequest)(nil), "grpc.UpdateInterfaceRequest") proto.RegisterType((*AddInterfaceRequest)(nil), "grpc.AddInterfaceRequest") proto.RegisterType((*RemoveInterfaceRequest)(nil), "grpc.RemoveInterfaceRequest") proto.RegisterType((*UpdateRoutesRequest)(nil), "grpc.UpdateRoutesRequest") + proto.RegisterType((*ListInterfacesRequest)(nil), "grpc.ListInterfacesRequest") + proto.RegisterType((*ListRoutesRequest)(nil), "grpc.ListRoutesRequest") proto.RegisterType((*OnlineCPUMemRequest)(nil), "grpc.OnlineCPUMemRequest") proto.RegisterType((*ReseedRandomDevRequest)(nil), "grpc.ReseedRandomDevRequest") proto.RegisterType((*Storage)(nil), "grpc.Storage") @@ -1659,6 +1697,8 @@ type AgentServiceClient interface { UpdateInterface(ctx context.Context, in *UpdateInterfaceRequest, opts ...grpc1.CallOption) (*Interface, error) RemoveInterface(ctx context.Context, in *RemoveInterfaceRequest, opts ...grpc1.CallOption) (*Interface, error) UpdateRoutes(ctx context.Context, in *UpdateRoutesRequest, opts ...grpc1.CallOption) (*Routes, error) + ListInterfaces(ctx context.Context, in *ListInterfacesRequest, opts ...grpc1.CallOption) (*Interfaces, error) + ListRoutes(ctx context.Context, in *ListRoutesRequest, opts ...grpc1.CallOption) (*Routes, error) // misc (TODO: some rpcs can be replaced by hyperstart-exec) CreateSandbox(ctx context.Context, in *CreateSandboxRequest, opts ...grpc1.CallOption) (*google_protobuf2.Empty, error) DestroySandbox(ctx context.Context, in *DestroySandboxRequest, opts ...grpc1.CallOption) (*google_protobuf2.Empty, error) @@ -1854,6 +1894,24 @@ func (c *agentServiceClient) UpdateRoutes(ctx context.Context, in *UpdateRoutesR return out, nil } +func (c *agentServiceClient) ListInterfaces(ctx context.Context, in *ListInterfacesRequest, opts ...grpc1.CallOption) (*Interfaces, error) { + out := new(Interfaces) + err := grpc1.Invoke(ctx, "/grpc.AgentService/ListInterfaces", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *agentServiceClient) ListRoutes(ctx context.Context, in *ListRoutesRequest, opts ...grpc1.CallOption) (*Routes, error) { + out := new(Routes) + err := grpc1.Invoke(ctx, "/grpc.AgentService/ListRoutes", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *agentServiceClient) CreateSandbox(ctx context.Context, in *CreateSandboxRequest, opts ...grpc1.CallOption) (*google_protobuf2.Empty, error) { out := new(google_protobuf2.Empty) err := grpc1.Invoke(ctx, "/grpc.AgentService/CreateSandbox", in, out, c.cc, opts...) @@ -1922,6 +1980,8 @@ type AgentServiceServer interface { UpdateInterface(context.Context, *UpdateInterfaceRequest) (*Interface, error) RemoveInterface(context.Context, *RemoveInterfaceRequest) (*Interface, error) UpdateRoutes(context.Context, *UpdateRoutesRequest) (*Routes, error) + ListInterfaces(context.Context, *ListInterfacesRequest) (*Interfaces, error) + ListRoutes(context.Context, *ListRoutesRequest) (*Routes, error) // misc (TODO: some rpcs can be replaced by hyperstart-exec) CreateSandbox(context.Context, *CreateSandboxRequest) (*google_protobuf2.Empty, error) DestroySandbox(context.Context, *DestroySandboxRequest) (*google_protobuf2.Empty, error) @@ -2293,6 +2353,42 @@ func _AgentService_UpdateRoutes_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _AgentService_ListInterfaces_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc1.UnaryServerInterceptor) (interface{}, error) { + in := new(ListInterfacesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AgentServiceServer).ListInterfaces(ctx, in) + } + info := &grpc1.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.AgentService/ListInterfaces", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AgentServiceServer).ListInterfaces(ctx, req.(*ListInterfacesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AgentService_ListRoutes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc1.UnaryServerInterceptor) (interface{}, error) { + in := new(ListRoutesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AgentServiceServer).ListRoutes(ctx, in) + } + info := &grpc1.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.AgentService/ListRoutes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AgentServiceServer).ListRoutes(ctx, req.(*ListRoutesRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _AgentService_CreateSandbox_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc1.UnaryServerInterceptor) (interface{}, error) { in := new(CreateSandboxRequest) if err := dec(in); err != nil { @@ -2449,6 +2545,14 @@ var _AgentService_serviceDesc = grpc1.ServiceDesc{ MethodName: "UpdateRoutes", Handler: _AgentService_UpdateRoutes_Handler, }, + { + MethodName: "ListInterfaces", + Handler: _AgentService_ListInterfaces_Handler, + }, + { + MethodName: "ListRoutes", + Handler: _AgentService_ListRoutes_Handler, + }, { MethodName: "CreateSandbox", Handler: _AgentService_CreateSandbox_Handler, @@ -3847,6 +3951,36 @@ func (m *Interface) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *Interfaces) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Interfaces) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Interfaces) > 0 { + for _, msg := range m.Interfaces { + dAtA[i] = 0xa + i++ + i = encodeVarintAgent(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + func (m *Route) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -4036,6 +4170,42 @@ func (m *UpdateRoutesRequest) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *ListInterfacesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListInterfacesRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + return i, nil +} + +func (m *ListRoutesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListRoutesRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + return i, nil +} + func (m *OnlineCPUMemRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -4885,6 +5055,18 @@ func (m *Interface) Size() (n int) { return n } +func (m *Interfaces) Size() (n int) { + var l int + _ = l + if len(m.Interfaces) > 0 { + for _, e := range m.Interfaces { + l = e.Size() + n += 1 + l + sovAgent(uint64(l)) + } + } + return n +} + func (m *Route) Size() (n int) { var l int _ = l @@ -4962,6 +5144,18 @@ func (m *UpdateRoutesRequest) Size() (n int) { return n } +func (m *ListInterfacesRequest) Size() (n int) { + var l int + _ = l + return n +} + +func (m *ListRoutesRequest) Size() (n int) { + var l int + _ = l + return n +} + func (m *OnlineCPUMemRequest) Size() (n int) { var l int _ = l @@ -9609,6 +9803,87 @@ func (m *Interface) Unmarshal(dAtA []byte) error { } return nil } +func (m *Interfaces) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Interfaces: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Interfaces: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Interfaces", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAgent + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Interfaces = append(m.Interfaces, &Interface{}) + if err := m.Interfaces[len(m.Interfaces)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAgent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAgent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Route) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -10207,6 +10482,106 @@ func (m *UpdateRoutesRequest) Unmarshal(dAtA []byte) error { } return nil } +func (m *ListInterfacesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListInterfacesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListInterfacesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipAgent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAgent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListRoutesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListRoutesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListRoutesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipAgent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAgent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *OnlineCPUMemRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -11041,149 +11416,152 @@ var ( func init() { proto.RegisterFile("agent.proto", fileDescriptorAgent) } var fileDescriptorAgent = []byte{ - // 2290 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0x5b, 0x73, 0x1c, 0x47, - 0x15, 0x66, 0xaf, 0xd2, 0x9e, 0xdd, 0x95, 0xb4, 0x23, 0x59, 0xde, 0xac, 0x8d, 0x51, 0xc6, 0xe0, - 0x88, 0x04, 0xcb, 0x15, 0xc5, 0x05, 0x29, 0xbb, 0x52, 0xc1, 0xba, 0x20, 0x8b, 0xc4, 0x78, 0x19, - 0x59, 0x65, 0xaa, 0x78, 0xd8, 0x6a, 0xcd, 0xb4, 0x56, 0x1d, 0xef, 0x4c, 0x4f, 0xba, 0x7b, 0x24, - 0x2d, 0xa9, 0xe2, 0x91, 0x5f, 0xc0, 0x2b, 0x7f, 0x80, 0xe2, 0x2d, 0x7f, 0x81, 0x07, 0x1e, 0xf9, - 0x05, 0x14, 0xe5, 0x9f, 0xc0, 0x1b, 0x6f, 0x54, 0xdf, 0xe6, 0xb2, 0x17, 0x19, 0x14, 0x55, 0xf1, - 0xb2, 0x3b, 0xe7, 0xf4, 0xe9, 0xef, 0x5c, 0xba, 0xfb, 0xf4, 0xe9, 0x03, 0x4d, 0x34, 0xc4, 0x91, - 0xd8, 0x8a, 0x19, 0x15, 0xd4, 0xa9, 0x0e, 0x59, 0xec, 0xf7, 0x1a, 0xd4, 0x27, 0x9a, 0xd1, 0xbb, - 0x33, 0xa4, 0x74, 0x38, 0xc2, 0x8f, 0x14, 0x75, 0x92, 0x9c, 0x3e, 0xc2, 0x61, 0x2c, 0xc6, 0x7a, - 0xd0, 0xfd, 0x53, 0x19, 0xd6, 0x77, 0x19, 0x46, 0x02, 0xef, 0xd2, 0x48, 0x20, 0x12, 0x61, 0xe6, - 0xe1, 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3, 0xc7, - 0x93, 0xf0, 0x5a, 0x93, 0xff, 0x5c, 0x82, 0xc5, 0xdd, 0x38, 0x39, 0xe6, 0x68, 0x88, 0x9d, 0x1f, - 0x40, 0x53, 0x50, 0x81, 0x46, 0x83, 0x44, 0x92, 0x4a, 0xbc, 0xea, 0x81, 0x62, 0x69, 0x01, 0x19, - 0x76, 0xcc, 0xfc, 0x38, 0x31, 0x12, 0xe5, 0x8d, 0xca, 0x66, 0xd5, 0x6b, 0x6a, 0x9e, 0x16, 0xd9, - 0x82, 0x55, 0x35, 0x36, 0x20, 0xd1, 0xe0, 0x0d, 0x66, 0x11, 0x1e, 0x85, 0x34, 0xc0, 0x6a, 0xff, - 0x56, 0xbd, 0x8e, 0x1a, 0x3a, 0x8c, 0xbe, 0x48, 0x07, 0x9c, 0x0f, 0xa1, 0x93, 0xca, 0xcb, 0x43, - 0xa9, 0xa4, 0xab, 0x4a, 0x7a, 0xd9, 0x48, 0x1f, 0x1b, 0xb6, 0xfb, 0x7b, 0x58, 0x7a, 0x75, 0xc6, - 0xa8, 0x10, 0x23, 0x12, 0x0d, 0xf7, 0x90, 0x40, 0x32, 0x7b, 0xc4, 0x98, 0x11, 0x1a, 0x70, 0x63, - 0xad, 0x25, 0x9d, 0x8f, 0xa0, 0x23, 0xb4, 0x2c, 0x0e, 0x06, 0x56, 0xa6, 0xac, 0x64, 0x56, 0xd2, - 0x81, 0xbe, 0x11, 0xfe, 0x11, 0x2c, 0x65, 0xc2, 0x32, 0xff, 0x18, 0x7b, 0xdb, 0x29, 0xf7, 0x15, - 0x09, 0xb1, 0x7b, 0xae, 0x62, 0xa5, 0x16, 0xd9, 0xf9, 0x08, 0x1a, 0x59, 0x1c, 0x4a, 0x6a, 0x87, - 0x2c, 0xe9, 0x1d, 0x62, 0xc3, 0xe9, 0x2d, 0xa6, 0x41, 0xf9, 0x0c, 0x96, 0x45, 0x6a, 0xf8, 0x20, - 0x40, 0x02, 0x15, 0x37, 0x55, 0xd1, 0x2b, 0x6f, 0x49, 0x14, 0x68, 0xf7, 0x29, 0x34, 0xfa, 0x24, - 0xe0, 0x5a, 0x71, 0x17, 0x16, 0xfc, 0x84, 0x31, 0x1c, 0x09, 0xeb, 0xb2, 0x21, 0x9d, 0x35, 0xa8, - 0x8d, 0x48, 0x48, 0x84, 0x71, 0x53, 0x13, 0x2e, 0x05, 0x78, 0x81, 0x43, 0xca, 0xc6, 0x2a, 0x60, - 0x6b, 0x50, 0xcb, 0x2f, 0xae, 0x26, 0x9c, 0x3b, 0xd0, 0x08, 0xd1, 0x65, 0xba, 0xa8, 0x72, 0x64, - 0x31, 0x44, 0x97, 0xda, 0xf8, 0x2e, 0x2c, 0x9c, 0x22, 0x32, 0xf2, 0x23, 0x61, 0xa2, 0x62, 0xc9, - 0x4c, 0x61, 0x35, 0xaf, 0xf0, 0xaf, 0x65, 0x68, 0x6a, 0x8d, 0xda, 0xe0, 0x35, 0xa8, 0xf9, 0xc8, - 0x3f, 0x4b, 0x55, 0x2a, 0xc2, 0x79, 0x60, 0x0d, 0x29, 0xe7, 0x93, 0x70, 0x66, 0xa9, 0x35, 0xed, - 0x11, 0x00, 0xbf, 0x40, 0xb1, 0xb1, 0xad, 0x32, 0x47, 0xb8, 0x21, 0x65, 0xb4, 0xb9, 0x9f, 0x40, - 0x4b, 0xef, 0x3b, 0x33, 0xa5, 0x3a, 0x67, 0x4a, 0x53, 0x4b, 0xe9, 0x49, 0xf7, 0xa1, 0x9d, 0x70, - 0x3c, 0x38, 0x23, 0x98, 0x21, 0xe6, 0x9f, 0x8d, 0xbb, 0x35, 0x7d, 0x47, 0x26, 0x1c, 0x3f, 0xb7, - 0x3c, 0x67, 0x1b, 0x6a, 0x32, 0xfd, 0xf1, 0x6e, 0x5d, 0x5d, 0xc7, 0x77, 0xf3, 0x90, 0xca, 0xd5, - 0x2d, 0xf5, 0xbb, 0x1f, 0x09, 0x36, 0xf6, 0xb4, 0x68, 0xef, 0x53, 0x80, 0x8c, 0xe9, 0xac,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, 0x12, 0x89, 0x41, - 0x4c, 0x49, 0x24, 0x54, 0xff, 0xac, 0xe1, 0x81, 0x62, 0xf5, 0x25, 0xc7, 0xfd, 0x43, 0x09, 0xea, - 0xba, 0x2f, 0x27, 0xeb, 0xe9, 0x34, 0x31, 0x96, 0x89, 0xba, 0x64, 0x94, 0x2e, 0x73, 0xe8, 0x94, - 0xa6, 0xdb, 0xb0, 0x70, 0x1e, 0x0e, 0x62, 0x24, 0xce, 0xac, 0x69, 0xe7, 0x61, 0x1f, 0x89, 0x33, - 0xe9, 0x59, 0x96, 0x5f, 0xd5, 0xb8, 0x36, 0xb1, 0x9d, 0x72, 0x95, 0xd8, 0x5c, 0x4b, 0xdd, 0xdf, - 0xc8, 0x67, 0x44, 0xda, 0x93, 0x5a, 0x81, 0x4a, 0x92, 0x1a, 0x23, 0x3f, 0x25, 0x67, 0x98, 0x66, - 0x66, 0xf9, 0xe9, 0x3c, 0x80, 0x25, 0x14, 0x04, 0x44, 0x4e, 0x47, 0xa3, 0x03, 0x12, 0xd8, 0xc6, - 0xca, 0x04, 0xf7, 0xc3, 0x1e, 0x2c, 0xda, 0x24, 0xe5, 0xd4, 0xa1, 0x7c, 0xfe, 0x78, 0xe5, 0x7b, - 0xea, 0xff, 0xa7, 0x2b, 0xa5, 0xed, 0x7f, 0xb7, 0xa0, 0xf5, 0x6c, 0x88, 0x23, 0x61, 0x8a, 0x5e, - 0xe7, 0x00, 0x96, 0x27, 0x9a, 0xa8, 0x8e, 0x79, 0x05, 0xcd, 0xee, 0xad, 0xf6, 0xd6, 0xb7, 0x74, - 0x53, 0x76, 0xcb, 0x36, 0x65, 0xb7, 0xf6, 0xc3, 0x58, 0x8c, 0x9d, 0x7d, 0x58, 0x2a, 0xb6, 0x1b, - 0x9d, 0x3b, 0x36, 0x87, 0xcf, 0x68, 0x42, 0xce, 0x85, 0x39, 0x80, 0xe5, 0x89, 0xce, 0xa3, 0xb5, - 0x67, 0x76, 0x43, 0x72, 0x2e, 0xd0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, 0x2d, 0xc4, 0x8c, 0x1b, 0xb7, - 0x37, 0x79, 0x2b, 0x3a, 0x3f, 0xb7, 0x1b, 0x35, 0x63, 0x15, 0x36, 0xea, 0x7f, 0x85, 0x30, 0x71, - 0x2b, 0x17, 0xf3, 0xc8, 0xbb, 0x11, 0x7e, 0x06, 0xad, 0xfc, 0x75, 0x6c, 0xed, 0x9f, 0x71, 0x45, - 0xf7, 0x0a, 0x57, 0xb2, 0x4c, 0x1c, 0x85, 0x9a, 0xd8, 0x9e, 0xd7, 0x59, 0x85, 0xf2, 0x55, 0xe9, - 0xb4, 0x58, 0xa3, 0xda, 0x43, 0x31, 0xb3, 0x72, 0xbd, 0x6a, 0x1d, 0xf3, 0x65, 0x81, 0x75, 0x62, - 0x46, 0xa9, 0xf0, 0x8e, 0x73, 0x95, 0xaf, 0x0a, 0x72, 0xe7, 0x6a, 0x46, 0xb1, 0x30, 0x0f, 0x68, - 0xa7, 0xf5, 0xb7, 0xb7, 0xf7, 0x4a, 0x7f, 0x7f, 0x7b, 0xaf, 0xf4, 0xcf, 0xb7, 0xf7, 0x4a, 0x27, - 0x75, 0x35, 0xfa, 0xc9, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x4b, 0xe9, 0x79, 0x55, 0x02, 0x1c, - 0x00, 0x00, + // 2352 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0x5f, 0x6f, 0x1c, 0x49, + 0x11, 0x67, 0xff, 0xda, 0x5b, 0xbb, 0x6b, 0x7b, 0xdb, 0x8e, 0xb3, 0xb7, 0x39, 0x82, 0x6f, 0x02, + 0x39, 0x73, 0x47, 0x1c, 0x9d, 0x13, 0xc1, 0x29, 0x51, 0x14, 0x62, 0xc7, 0x38, 0xe6, 0x2e, 0x64, + 0x19, 0xc7, 0x0a, 0x12, 0x0f, 0xab, 0xf1, 0x4c, 0x7b, 0xdd, 0x97, 0x9d, 0xe9, 0xb9, 0xee, 0x1e, + 0xdb, 0xcb, 0x49, 0x3c, 0xf2, 0x09, 0x78, 0xe5, 0x0b, 0x20, 0xde, 0xee, 0x2b, 0xf0, 0xc0, 0x23, + 0x9f, 0x00, 0xa1, 0x7c, 0x01, 0x24, 0x3e, 0x01, 0xea, 0x7f, 0xf3, 0x67, 0xff, 0x38, 0xe0, 0xb3, + 0xc4, 0xcb, 0xee, 0x54, 0x75, 0x75, 0xd5, 0xaf, 0xaa, 0xbb, 0xab, 0xab, 0x0b, 0x9a, 0xde, 0x10, + 0x47, 0x62, 0x2b, 0x66, 0x54, 0x50, 0x54, 0x1d, 0xb2, 0xd8, 0xef, 0x35, 0xa8, 0x4f, 0x34, 0xa3, + 0x77, 0x6b, 0x48, 0xe9, 0x70, 0x84, 0xef, 0x2b, 0xea, 0x38, 0x39, 0xb9, 0x8f, 0xc3, 0x58, 0x8c, + 0xf5, 0xa0, 0xf3, 0xa7, 0x32, 0xac, 0xef, 0x32, 0xec, 0x09, 0xbc, 0x4b, 0x23, 0xe1, 0x91, 0x08, + 0x33, 0x17, 0x7f, 0x9d, 0x60, 0x2e, 0xd0, 0x47, 0xd0, 0xf2, 0x2d, 0x6f, 0x40, 0x82, 0x6e, 0x69, + 0xa3, 0xb4, 0xd9, 0x70, 0x9b, 0x29, 0xef, 0x20, 0x40, 0x37, 0x61, 0x01, 0x5f, 0x60, 0x5f, 0x8e, + 0x96, 0xd5, 0x68, 0x5d, 0x92, 0x07, 0x01, 0xfa, 0x0c, 0x9a, 0x5c, 0x30, 0x12, 0x0d, 0x07, 0x09, + 0xc7, 0xac, 0x5b, 0xd9, 0x28, 0x6d, 0x36, 0xb7, 0x57, 0xb6, 0x24, 0xb4, 0xad, 0x43, 0x35, 0x70, + 0xc4, 0x31, 0x73, 0x81, 0xa7, 0xdf, 0xe8, 0x2e, 0x2c, 0x04, 0xf8, 0x8c, 0xf8, 0x98, 0x77, 0xab, + 0x1b, 0x95, 0xcd, 0x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15, 0xc7, 0xff, 0x0b, 0x84, + 0x75, 0xa8, 0x9f, 0x50, 0x16, 0x7a, 0xc2, 0x22, 0xd0, 0x14, 0x42, 0x50, 0xf5, 0xd8, 0x90, 0x77, + 0x2b, 0x1b, 0x95, 0xcd, 0x86, 0xab, 0xbe, 0xe5, 0xae, 0x9c, 0x30, 0x63, 0x70, 0x7d, 0x04, 0x2d, + 0x13, 0xf7, 0xc1, 0x88, 0x70, 0xa1, 0xec, 0xb4, 0xdc, 0xa6, 0xe1, 0xc9, 0x39, 0x0e, 0x85, 0xf5, + 0xa3, 0x38, 0xb8, 0xe2, 0x81, 0xdf, 0x86, 0x06, 0xc3, 0x9c, 0x26, 0x4c, 0x1e, 0xd3, 0xb2, 0x5a, + 0xf7, 0x35, 0xbd, 0xee, 0x5f, 0x92, 0x28, 0xb9, 0x70, 0xed, 0x98, 0x9b, 0x89, 0x99, 0x23, 0x24, + 0xf8, 0x55, 0x8e, 0xd0, 0x23, 0xb8, 0xd1, 0xf7, 0x12, 0x7e, 0x15, 0xac, 0xce, 0x63, 0x79, 0xfc, + 0x78, 0x12, 0x5e, 0x69, 0xf2, 0x9f, 0x4b, 0xb0, 0xb8, 0x1b, 0x27, 0x47, 0xdc, 0x1b, 0x62, 0xf4, + 0x03, 0x68, 0x0a, 0x2a, 0xbc, 0xd1, 0x20, 0x91, 0xa4, 0x12, 0xaf, 0xba, 0xa0, 0x58, 0x5a, 0x40, + 0x86, 0x1d, 0x33, 0x3f, 0x4e, 0x8c, 0x44, 0x79, 0xa3, 0xb2, 0x59, 0x75, 0x9b, 0x9a, 0xa7, 0x45, + 0xb6, 0x60, 0x55, 0x8d, 0x0d, 0x48, 0x34, 0x78, 0x8b, 0x59, 0x84, 0x47, 0x21, 0x0d, 0xb0, 0xda, + 0xbf, 0x55, 0xb7, 0xa3, 0x86, 0x0e, 0xa2, 0x2f, 0xd2, 0x01, 0xf4, 0x09, 0x74, 0x52, 0x79, 0x79, + 0x28, 0x95, 0x74, 0x55, 0x49, 0x2f, 0x1b, 0xe9, 0x23, 0xc3, 0x76, 0x7e, 0x0f, 0x4b, 0xaf, 0x4f, + 0x19, 0x15, 0x62, 0x44, 0xa2, 0xe1, 0x73, 0x4f, 0x78, 0x32, 0x7b, 0xc4, 0x98, 0x11, 0x1a, 0x70, + 0x83, 0xd6, 0x92, 0xe8, 0x53, 0xe8, 0x08, 0x2d, 0x8b, 0x83, 0x81, 0x95, 0x29, 0x2b, 0x99, 0x95, + 0x74, 0xa0, 0x6f, 0x84, 0x7f, 0x04, 0x4b, 0x99, 0xb0, 0xcc, 0x3f, 0x06, 0x6f, 0x3b, 0xe5, 0xbe, + 0x26, 0x21, 0x76, 0xce, 0x54, 0xac, 0xd4, 0x22, 0xa3, 0x4f, 0xa1, 0x91, 0xc5, 0xa1, 0xa4, 0x76, + 0xc8, 0x92, 0xde, 0x21, 0x36, 0x9c, 0xee, 0x62, 0x1a, 0x94, 0x27, 0xb0, 0x2c, 0x52, 0xe0, 0x83, + 0xc0, 0x13, 0x5e, 0x71, 0x53, 0x15, 0xbd, 0x72, 0x97, 0x44, 0x81, 0x76, 0x1e, 0x43, 0xa3, 0x4f, + 0x02, 0xae, 0x0d, 0x77, 0x61, 0xc1, 0x4f, 0x18, 0xc3, 0x91, 0xb0, 0x2e, 0x1b, 0x12, 0xad, 0x41, + 0x6d, 0x44, 0x42, 0x22, 0x8c, 0x9b, 0x9a, 0x70, 0x28, 0xc0, 0x4b, 0x1c, 0x52, 0x36, 0x56, 0x01, + 0x5b, 0x83, 0x5a, 0x7e, 0x71, 0x35, 0x81, 0x6e, 0x41, 0x23, 0xf4, 0x2e, 0xd2, 0x45, 0x95, 0x23, + 0x8b, 0xa1, 0x77, 0xa1, 0xc1, 0x77, 0x61, 0xe1, 0xc4, 0x23, 0x23, 0x3f, 0x12, 0x26, 0x2a, 0x96, + 0xcc, 0x0c, 0x56, 0xf3, 0x06, 0xff, 0x5a, 0x86, 0xa6, 0xb6, 0xa8, 0x01, 0xa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x85, 0xea, 0xe8, 0x1a, 0x79, 0x9d, + 0x87, 0x3a, 0x53, 0x87, 0xda, 0x6d, 0x86, 0xb9, 0x64, 0xb6, 0x05, 0x10, 0x93, 0x80, 0x9b, 0x39, + 0x3a, 0x1d, 0x2d, 0x9b, 0x8a, 0xd0, 0xa6, 0x68, 0xb7, 0x11, 0xa7, 0xd9, 0xfa, 0x33, 0x68, 0x1e, + 0xcb, 0x20, 0x99, 0x09, 0x85, 0x64, 0x94, 0x45, 0xcf, 0x85, 0xe3, 0xec, 0x10, 0xbe, 0x80, 0xf6, + 0xa9, 0x0e, 0x99, 0x99, 0xa4, 0xf7, 0xd0, 0x1d, 0xe3, 0x49, 0xe6, 0xef, 0x56, 0x3e, 0xb2, 0x7a, + 0x01, 0x5a, 0xa7, 0x39, 0x56, 0xef, 0x10, 0x3a, 0x53, 0x22, 0x33, 0x72, 0xd0, 0x66, 0x3e, 0x07, + 0x35, 0xb7, 0x91, 0x36, 0x94, 0x9f, 0x99, 0xcf, 0x4b, 0xbf, 0x82, 0xf5, 0xc9, 0x32, 0xc7, 0x14, + 0x65, 0x0f, 0xa1, 0xe5, 0x2b, 0x74, 0x85, 0x15, 0xe8, 0x4c, 0xe1, 0x76, 0x9b, 0x7e, 0x46, 0x38, + 0x01, 0xa0, 0x37, 0x8c, 0x08, 0x7c, 0x28, 0x18, 0xf6, 0xc2, 0xeb, 0xa8, 0x9a, 0x11, 0x54, 0xd5, + 0x15, 0x5b, 0x51, 0x45, 0xa1, 0xfa, 0x76, 0x3e, 0x86, 0xd5, 0x82, 0x15, 0x03, 0x79, 0x05, 0x2a, + 0x23, 0x1c, 0x29, 0xed, 0x6d, 0x57, 0x7e, 0x3a, 0x1e, 0x74, 0x5c, 0xec, 0x05, 0xd7, 0x87, 0xc6, + 0x98, 0xa8, 0x64, 0x26, 0x36, 0x01, 0xe5, 0x4d, 0x18, 0x28, 0x16, 0x75, 0x29, 0x87, 0xfa, 0x15, + 0x74, 0x76, 0x47, 0x94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 0x61, 0x98, 0xa3, 0x07, 0x00, 0xd9, 0x05, 0x6f, 0xd7, 0x6e, 0xea, 0xca, 0x9f, + 0xb0, 0xba, 0x0b, 0xed, 0x42, 0xd9, 0x6f, 0xb3, 0xc4, 0xac, 0xb7, 0xc0, 0x65, 0x49, 0xbc, 0x58, + 0x86, 0x5b, 0xe8, 0x33, 0x8b, 0xf3, 0xcb, 0x76, 0x4f, 0xbe, 0x18, 0xb1, 0xa1, 0x9b, 0x51, 0xa0, + 0xbc, 0xe7, 0x34, 0xe7, 0x6b, 0x91, 0xdc, 0x69, 0x9e, 0x51, 0xa2, 0xcc, 0x53, 0xb4, 0xd3, 0xfa, + 0xdb, 0xbb, 0xdb, 0xa5, 0xbf, 0xbf, 0xbb, 0x5d, 0xfa, 0xe7, 0xbb, 0xdb, 0xa5, 0xe3, 0xba, 0x1a, + 0x7d, 0xf0, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2b, 0xc8, 0x6c, 0x30, 0xe5, 0x1c, 0x00, 0x00, } diff --git a/virtcontainers/agent.go b/virtcontainers/agent.go index f1d6f5b7c0..bf8706d308 100644 --- a/virtcontainers/agent.go +++ b/virtcontainers/agent.go @@ -9,6 +9,7 @@ import ( "fmt" "syscall" + "github.com/kata-containers/agent/protocols/grpc" "github.com/mitchellh/mapstructure" specs "github.com/opencontainers/runtime-spec/specs-go" ) @@ -221,4 +222,16 @@ type agent interface { // reseedRNG will reseed the guest random number generator reseedRNG(data []byte) error + + // updateInterface will tell the agent to update a nic for an existed Sandbox. + updateInterface(inf *grpc.Interface) (*grpc.Interface, error) + + // listInterfaces will tell the agent to list interfaces of an existed Sandbox + listInterfaces() ([]*grpc.Interface, error) + + // updateRoutes will tell the agent to update route table for an existed Sandbox. + updateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) + + // listRoutes will tell the agent to list routes of an existed Sandbox + listRoutes() ([]*grpc.Route, error) } diff --git a/virtcontainers/api.go b/virtcontainers/api.go index c8e8d8bbc9..95c6ff042c 100644 --- a/virtcontainers/api.go +++ b/virtcontainers/api.go @@ -10,6 +10,7 @@ import ( "runtime" "syscall" + "github.com/kata-containers/agent/protocols/grpc" deviceApi "github.com/kata-containers/runtime/virtcontainers/device/api" deviceConfig "github.com/kata-containers/runtime/virtcontainers/device/config" specs "github.com/opencontainers/runtime-spec/specs-go" @@ -782,3 +783,93 @@ func AddDevice(sandboxID string, info deviceConfig.DeviceInfo) (deviceApi.Device return s.AddDevice(info) } + +func toggleInterface(sandboxID string, inf *grpc.Interface, add bool) (*grpc.Interface, error) { + if sandboxID == "" { + return nil, errNeedSandboxID + } + + lockFile, err := rwLockSandbox(sandboxID) + if err != nil { + return nil, err + } + defer unlockSandbox(lockFile) + + s, err := fetchSandbox(sandboxID) + if err != nil { + return nil, err + } + if add { + return s.AddInterface(inf) + } + return s.RemoveInterface(inf) +} + +// AddInterface is the virtcontainers add interface entry point. +func AddInterface(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) { + return toggleInterface(sandboxID, inf, true) +} + +// RemoveInterface is the virtcontainers remove interface entry point. +func RemoveInterface(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) { + return toggleInterface(sandboxID, inf, false) +} + +// ListInterfaces is the virtcontainers list interfaces entry point. +func ListInterfaces(sandboxID string) ([]*grpc.Interface, error) { + if sandboxID == "" { + return nil, errNeedSandboxID + } + + lockFile, err := rLockSandbox(sandboxID) + if err != nil { + return nil, err + } + defer unlockSandbox(lockFile) + + s, err := fetchSandbox(sandboxID) + if err != nil { + return nil, err + } + + return s.ListInterfaces() +} + +// UpdateRoutes is the virtcontainers update routes entry point. +func UpdateRoutes(sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error) { + if sandboxID == "" { + return nil, errNeedSandboxID + } + + lockFile, err := rwLockSandbox(sandboxID) + if err != nil { + return nil, err + } + defer unlockSandbox(lockFile) + + s, err := fetchSandbox(sandboxID) + if err != nil { + return nil, err + } + return s.UpdateRoutes(routes) +} + +// ListRoutes is the virtcontainers list routes entry point. +func ListRoutes(sandboxID string) ([]*grpc.Route, error) { + if sandboxID == "" { + return nil, errNeedSandboxID + } + + lockFile, err := rLockSandbox(sandboxID) + if err != nil { + return nil, err + } + defer unlockSandbox(lockFile) + + s, err := fetchSandbox(sandboxID) + if err != nil { + return nil, err + } + + return s.ListRoutes() +} diff --git a/virtcontainers/api_test.go b/virtcontainers/api_test.go index 0cb1086bf4..11dca61e8a 100644 --- a/virtcontainers/api_test.go +++ b/virtcontainers/api_test.go @@ -16,6 +16,7 @@ import ( "syscall" "testing" + "github.com/kata-containers/agent/protocols/grpc" "github.com/kata-containers/runtime/virtcontainers/pkg/mock" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/assert" @@ -2349,3 +2350,59 @@ func TestPauseResumeContainer(t *testing.T) { err = ResumeContainer(s.ID(), contID) assert.NoError(err) } + +func TestNetworkOperation(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + + cleanUp() + + assert := assert.New(t) + inf := &grpc.Interface{ + Name: "eno1", + Mtu: 1500, + HwAddr: "02:00:ca:fe:00:48", + } + ip := grpc.IPAddress{ + Family: 0, + Address: "192.168.0.101", + Mask: "24", + } + inf.IPAddresses = append(inf.IPAddresses, &ip) + + _, err := AddInterface("", inf) + assert.Error(err) + + _, err = AddInterface("abc", inf) + assert.Error(err) + + netNSPath, err := createNetNS() + assert.NoError(err) + defer deleteNetNS(netNSPath) + + config := newTestSandboxConfigNoop() + config.NetworkModel = CNMNetworkModel + config.NetworkConfig = NetworkConfig{ + NetNSPath: netNSPath, + } + + s, _, err := createAndStartSandbox(config) + assert.NoError(err) + assert.NotNil(s) + + _, err = AddInterface(s.ID(), inf) + assert.Error(err) + + _, err = RemoveInterface(s.ID(), inf) + assert.NoError(err) + + _, err = ListInterfaces(s.ID()) + assert.NoError(err) + + _, err = UpdateRoutes(s.ID(), nil) + assert.NoError(err) + + _, err = ListRoutes(s.ID()) + assert.NoError(err) +} diff --git a/virtcontainers/hyperstart_agent.go b/virtcontainers/hyperstart_agent.go index 936865df5c..5c1181887a 100644 --- a/virtcontainers/hyperstart_agent.go +++ b/virtcontainers/hyperstart_agent.go @@ -18,6 +18,7 @@ import ( "github.com/vishvananda/netlink" proxyClient "github.com/clearcontainers/proxy/client" + "github.com/kata-containers/agent/protocols/grpc" "github.com/kata-containers/runtime/virtcontainers/device/config" "github.com/kata-containers/runtime/virtcontainers/pkg/hyperstart" ns "github.com/kata-containers/runtime/virtcontainers/pkg/nsenter" @@ -852,6 +853,26 @@ func (h *hyper) onlineCPUMem(cpus uint32) error { return nil } +func (h *hyper) updateInterface(inf *grpc.Interface) (*grpc.Interface, error) { + // hyperstart-agent does not support update interface + return nil, nil +} + +func (h *hyper) listInterfaces() ([]*grpc.Interface, error) { + // hyperstart-agent does not support list interfaces + return nil, nil +} + +func (h *hyper) updateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) { + // hyperstart-agent does not support update routes + return nil, nil +} + +func (h *hyper) listRoutes() ([]*grpc.Route, error) { + // hyperstart-agent does not support list routes + return nil, nil +} + func (h *hyper) check() error { // hyperstart-agent does not support check return nil diff --git a/virtcontainers/hyperstart_agent_test.go b/virtcontainers/hyperstart_agent_test.go index d0c4ec43c5..41b5faf9e1 100644 --- a/virtcontainers/hyperstart_agent_test.go +++ b/virtcontainers/hyperstart_agent_test.go @@ -206,3 +206,35 @@ func TestHyperReseedAPI(t *testing.T) { err := h.reseedRNG([]byte{}) assert.Nil(err) } + +func TestHyperUpdateInterface(t *testing.T) { + assert := assert.New(t) + + h := &hyper{} + _, err := h.updateInterface(nil) + assert.Nil(err) +} + +func TestHyperListInterfaces(t *testing.T) { + assert := assert.New(t) + + h := &hyper{} + _, err := h.listInterfaces() + assert.Nil(err) +} + +func TestHyperUpdateRoutes(t *testing.T) { + assert := assert.New(t) + + h := &hyper{} + _, err := h.updateRoutes(nil) + assert.Nil(err) +} + +func TestHyperListRoutes(t *testing.T) { + assert := assert.New(t) + + h := &hyper{} + _, err := h.listRoutes() + assert.Nil(err) +} diff --git a/virtcontainers/implementation.go b/virtcontainers/implementation.go index e9006fbc18..81727dd5a2 100644 --- a/virtcontainers/implementation.go +++ b/virtcontainers/implementation.go @@ -12,6 +12,7 @@ package virtcontainers import ( "syscall" + "github.com/kata-containers/agent/protocols/grpc" "github.com/kata-containers/runtime/virtcontainers/device/api" "github.com/kata-containers/runtime/virtcontainers/device/config" specs "github.com/opencontainers/runtime-spec/specs-go" @@ -148,3 +149,28 @@ func (impl *VCImpl) ResumeContainer(sandboxID, containerID string) error { func (impl *VCImpl) AddDevice(sandboxID string, info config.DeviceInfo) (api.Device, error) { return AddDevice(sandboxID, info) } + +// AddInterface implements the VC function of the same name. +func (impl *VCImpl) AddInterface(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) { + return AddInterface(sandboxID, inf) +} + +// RemoveInterface implements the VC function of the same name. +func (impl *VCImpl) RemoveInterface(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) { + return RemoveInterface(sandboxID, inf) +} + +// ListInterfaces implements the VC function of the same name. +func (impl *VCImpl) ListInterfaces(sandboxID string) ([]*grpc.Interface, error) { + return ListInterfaces(sandboxID) +} + +// UpdateRoutes implements the VC function of the same name. +func (impl *VCImpl) UpdateRoutes(sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error) { + return UpdateRoutes(sandboxID, routes) +} + +// ListRoutes implements the VC function of the same name. +func (impl *VCImpl) ListRoutes(sandboxID string) ([]*grpc.Route, error) { + return ListRoutes(sandboxID) +} diff --git a/virtcontainers/interfaces.go b/virtcontainers/interfaces.go index d54843e49e..e83ee37447 100644 --- a/virtcontainers/interfaces.go +++ b/virtcontainers/interfaces.go @@ -9,6 +9,7 @@ import ( "io" "syscall" + "github.com/kata-containers/agent/protocols/grpc" "github.com/kata-containers/runtime/virtcontainers/device/api" "github.com/kata-containers/runtime/virtcontainers/device/config" specs "github.com/opencontainers/runtime-spec/specs-go" @@ -45,6 +46,12 @@ type VC interface { ResumeContainer(sandboxID, containerID string) error AddDevice(sandboxID string, info config.DeviceInfo) (api.Device, error) + + AddInterface(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) + RemoveInterface(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) + ListInterfaces(sandboxID string) ([]*grpc.Interface, error) + UpdateRoutes(sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error) + ListRoutes(sandboxID string) ([]*grpc.Route, error) } // VCSandbox is the Sandbox interface @@ -76,6 +83,12 @@ type VCSandbox interface { IOStream(containerID, processID string) (io.WriteCloser, io.Reader, io.Reader, error) AddDevice(info config.DeviceInfo) (api.Device, error) + + AddInterface(inf *grpc.Interface) (*grpc.Interface, error) + RemoveInterface(inf *grpc.Interface) (*grpc.Interface, error) + ListInterfaces() ([]*grpc.Interface, error) + UpdateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) + ListRoutes() ([]*grpc.Route, error) } // VCContainer is the Container interface diff --git a/virtcontainers/kata_agent.go b/virtcontainers/kata_agent.go index a9372897bc..141b6eef86 100644 --- a/virtcontainers/kata_agent.go +++ b/virtcontainers/kata_agent.go @@ -440,6 +440,82 @@ func (k *kataAgent) generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]* return ifaces, routes, nil } +func (k *kataAgent) updateInterface(ifc *grpc.Interface) (*grpc.Interface, error) { + // send update interface request + ifcReq := &grpc.UpdateInterfaceRequest{ + Interface: ifc, + } + resultingInterface, err := k.sendReq(ifcReq) + if err != nil { + k.Logger().WithFields(logrus.Fields{ + "interface-requested": fmt.Sprintf("%+v", ifc), + "resulting-interface": fmt.Sprintf("%+v", resultingInterface), + }).WithError(err).Error("update interface request failed") + } + if resultInterface, ok := resultingInterface.(*grpc.Interface); ok { + return resultInterface, err + } + return nil, err +} + +func (k *kataAgent) updateInterfaces(interfaces []*grpc.Interface) error { + for _, ifc := range interfaces { + if _, err := k.updateInterface(ifc); err != nil { + return err + } + } + return nil +} + +func (k *kataAgent) updateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) { + if routes != nil { + routesReq := &grpc.UpdateRoutesRequest{ + Routes: &grpc.Routes{ + Routes: routes, + }, + } + resultingRoutes, err := k.sendReq(routesReq) + if err != nil { + k.Logger().WithFields(logrus.Fields{ + "routes-requested": fmt.Sprintf("%+v", routes), + "resulting-routes": fmt.Sprintf("%+v", resultingRoutes), + }).WithError(err).Error("update routes request failed") + } + resultRoutes, ok := resultingRoutes.(*grpc.Routes) + if ok && resultRoutes != nil { + return resultRoutes.Routes, err + } + return nil, err + } + return nil, nil +} + +func (k *kataAgent) listInterfaces() ([]*grpc.Interface, error) { + req := &grpc.ListInterfacesRequest{} + resultingInterfaces, err := k.sendReq(req) + if err != nil { + return nil, err + } + resultInterfaces, ok := resultingInterfaces.(*grpc.Interfaces) + if ok { + return resultInterfaces.Interfaces, err + } + return nil, err +} + +func (k *kataAgent) listRoutes() ([]*grpc.Route, error) { + req := &grpc.ListRoutesRequest{} + resultingRoutes, err := k.sendReq(req) + if err != nil { + return nil, err + } + resultRoutes, ok := resultingRoutes.(*grpc.Routes) + if ok { + return resultRoutes.Routes, err + } + return nil, err +} + func (k *kataAgent) startProxy(sandbox *Sandbox) error { var err error @@ -515,36 +591,11 @@ func (k *kataAgent) startSandbox(sandbox *Sandbox) error { if err != nil { return err } - for _, ifc := range interfaces { - // send update interface request - ifcReq := &grpc.UpdateInterfaceRequest{ - Interface: ifc, - } - resultingInterface, err := k.sendReq(ifcReq) - if err != nil { - k.Logger().WithFields(logrus.Fields{ - "interface-requested": fmt.Sprintf("%+v", ifc), - "resulting-interface": fmt.Sprintf("%+v", resultingInterface), - }).WithError(err).Error("update interface request failed") - return err - } + if err := k.updateInterfaces(interfaces); err != nil { + return err } - - if routes != nil { - routesReq := &grpc.UpdateRoutesRequest{ - Routes: &grpc.Routes{ - Routes: routes, - }, - } - - resultingRoutes, err := k.sendReq(routesReq) - if err != nil { - k.Logger().WithFields(logrus.Fields{ - "routes-requested": fmt.Sprintf("%+v", routes), - "resulting-routes": fmt.Sprintf("%+v", resultingRoutes), - }).WithError(err).Error("update routes request failed") - return err - } + if _, err := k.updateRoutes(routes); err != nil { + return err } sharedDir9pOptions = append(sharedDir9pOptions, fmt.Sprintf("msize=%d", sandbox.config.HypervisorConfig.Msize9p)) @@ -1335,6 +1386,12 @@ func (k *kataAgent) installReqFunc(c *kataclient.AgentClient) { k.reqHandlers["grpc.UpdateInterfaceRequest"] = func(ctx context.Context, req interface{}, opts ...golangGrpc.CallOption) (interface{}, error) { return k.client.UpdateInterface(ctx, req.(*grpc.UpdateInterfaceRequest), opts...) } + k.reqHandlers["grpc.ListInterfacesRequest"] = func(ctx context.Context, req interface{}, opts ...golangGrpc.CallOption) (interface{}, error) { + return k.client.ListInterfaces(ctx, req.(*grpc.ListInterfacesRequest), opts...) + } + k.reqHandlers["grpc.ListRoutesRequest"] = func(ctx context.Context, req interface{}, opts ...golangGrpc.CallOption) (interface{}, error) { + return k.client.ListRoutes(ctx, req.(*grpc.ListRoutesRequest), opts...) + } k.reqHandlers["grpc.OnlineCPUMemRequest"] = func(ctx context.Context, req interface{}, opts ...golangGrpc.CallOption) (interface{}, error) { return k.client.OnlineCPUMem(ctx, req.(*grpc.OnlineCPUMemRequest), opts...) } diff --git a/virtcontainers/kata_agent_test.go b/virtcontainers/kata_agent_test.go index 5e9965f743..cc908d9e14 100644 --- a/virtcontainers/kata_agent_test.go +++ b/virtcontainers/kata_agent_test.go @@ -194,11 +194,19 @@ func (p *gRPCProxy) RemoveInterface(ctx context.Context, req *pb.RemoveInterface } func (p *gRPCProxy) UpdateInterface(ctx context.Context, req *pb.UpdateInterfaceRequest) (*pb.Interface, error) { - return nil, nil + return &pb.Interface{}, nil } func (p *gRPCProxy) UpdateRoutes(ctx context.Context, req *pb.UpdateRoutesRequest) (*pb.Routes, error) { - return nil, nil + return &pb.Routes{}, nil +} + +func (p *gRPCProxy) ListInterfaces(ctx context.Context, req *pb.ListInterfacesRequest) (*pb.Interfaces, error) { + return &pb.Interfaces{}, nil +} + +func (p *gRPCProxy) ListRoutes(ctx context.Context, req *pb.ListRoutesRequest) (*pb.Routes, error) { + return &pb.Routes{}, nil } func (p *gRPCProxy) OnlineCPUMem(ctx context.Context, req *pb.OnlineCPUMemRequest) (*gpb.Empty, error) { @@ -839,3 +847,44 @@ func TestAgentCreateContainer(t *testing.T) { _, err = k.createContainer(sandbox, container) assert.Error(err) } + +func TestAgentNetworkOperation(t *testing.T) { + assert := assert.New(t) + + impl := &gRPCProxy{} + + proxy := mock.ProxyGRPCMock{ + GRPCImplementer: impl, + GRPCRegister: gRPCRegister, + } + + sockDir, err := testGenerateKataProxySockDir() + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(sockDir) + + testKataProxyURL := fmt.Sprintf(testKataProxyURLTempl, sockDir) + if err := proxy.Start(testKataProxyURL); err != nil { + t.Fatal(err) + } + defer proxy.Stop() + + k := &kataAgent{ + state: KataAgentState{ + URL: testKataProxyURL, + }, + } + + _, err = k.updateInterface(nil) + assert.Nil(err) + + _, err = k.listInterfaces() + assert.Nil(err) + + _, err = k.updateRoutes([]*pb.Route{}) + assert.Nil(err) + + _, err = k.listRoutes() + assert.Nil(err) +} diff --git a/virtcontainers/network.go b/virtcontainers/network.go index baeb43b9a6..bfbac528ba 100644 --- a/virtcontainers/network.go +++ b/virtcontainers/network.go @@ -156,6 +156,8 @@ type Endpoint interface { SetProperties(NetworkInfo) Attach(hypervisor) error Detach(netNsCreated bool, netNsPath string) error + HotAttach(h hypervisor) error + HotDetach(h hypervisor, netNsCreated bool, netNsPath string) error } // VirtualEndpoint gathers a network pair and its properties. @@ -164,6 +166,7 @@ type VirtualEndpoint struct { EndpointProperties NetworkInfo Physical bool EndpointType EndpointType + PCIAddr string } // PhysicalEndpoint gathers a physical network interface and its properties @@ -247,6 +250,41 @@ func (endpoint *VirtualEndpoint) Detach(netNsCreated bool, netNsPath string) err }) } +// HotAttach for the virtual endpoint uses hot plug device +func (endpoint *VirtualEndpoint) HotAttach(h hypervisor) error { + networkLogger().Info("Hot attaching virtual endpoint") + if err := xconnectVMNetwork(&(endpoint.NetPair), true); err != nil { + networkLogger().WithError(err).Error("Error bridging virtual ep") + return err + } + + if _, err := h.hotplugAddDevice(*endpoint, netDev); err != nil { + networkLogger().WithError(err).Error("Error attach virtual ep") + return err + } + return nil +} + +// HotDetach for the virtual endpoint uses hot pull device +func (endpoint *VirtualEndpoint) HotDetach(h hypervisor, netNsCreated bool, netNsPath string) error { + if !netNsCreated { + return nil + } + networkLogger().Info("Hot detaching virtual endpoint") + if err := doNetNS(netNsPath, func(_ ns.NetNS) error { + return xconnectVMNetwork(&(endpoint.NetPair), false) + }); err != nil { + networkLogger().WithError(err).Error("Error abridging virtual ep") + return err + } + + if _, err := h.hotplugRemoveDevice(*endpoint, netDev); err != nil { + networkLogger().WithError(err).Error("Error detach virtual ep") + return err + } + return nil +} + // Properties returns the properties of the interface. func (endpoint *VhostUserEndpoint) Properties() NetworkInfo { return endpoint.EndpointProperties @@ -298,6 +336,16 @@ func (endpoint *VhostUserEndpoint) Detach(netNsCreated bool, netNsPath string) e return nil } +// HotAttach for vhostuser endpoint not supported yet +func (endpoint *VhostUserEndpoint) HotAttach(h hypervisor) error { + return fmt.Errorf("VhostUserEndpoint does not support Hot attach") +} + +// HotDetach for vhostuser endpoint not supported yet +func (endpoint *VhostUserEndpoint) HotDetach(h hypervisor, netNsCreated bool, netNsPath string) error { + return fmt.Errorf("VhostUserEndpoint does not support Hot detach") +} + // Create a vhostuser endpoint func createVhostUserEndpoint(netInfo NetworkInfo, socket string) (*VhostUserEndpoint, error) { @@ -367,6 +415,16 @@ func (endpoint *PhysicalEndpoint) Detach(netNsCreated bool, netNsPath string) er return bindNICToHost(endpoint) } +// HotAttach for physical endpoint not supported yet +func (endpoint *PhysicalEndpoint) HotAttach(h hypervisor) error { + return fmt.Errorf("PhysicalEndpoint does not support Hot attach") +} + +// HotDetach for physical endpoint not supported yet +func (endpoint *PhysicalEndpoint) HotDetach(h hypervisor, netNsCreated bool, netNsPath string) error { + return fmt.Errorf("PhysicalEndpoint does not support Hot detach") +} + // EndpointType identifies the type of the network endpoint. type EndpointType string diff --git a/virtcontainers/network_test.go b/virtcontainers/network_test.go index 75ed18ecfd..ce1ddaf08b 100644 --- a/virtcontainers/network_test.go +++ b/virtcontainers/network_test.go @@ -480,6 +480,60 @@ func TestVhostUserEndpointAttach(t *testing.T) { } } +func TestVhostUserEndpoint_HotAttach(t *testing.T) { + assert := assert.New(t) + v := &VhostUserEndpoint{ + SocketPath: "/tmp/sock", + HardAddr: "mac-addr", + EndpointType: VhostUserEndpointType, + } + + h := &mockHypervisor{} + + err := v.HotAttach(h) + assert.Error(err) +} + +func TestVhostUserEndpoint_HotDetach(t *testing.T) { + assert := assert.New(t) + v := &VhostUserEndpoint{ + SocketPath: "/tmp/sock", + HardAddr: "mac-addr", + EndpointType: VhostUserEndpointType, + } + + h := &mockHypervisor{} + + err := v.HotDetach(h, true, "") + assert.Error(err) +} + +func TestPhysicalEndpoint_HotAttach(t *testing.T) { + assert := assert.New(t) + v := &PhysicalEndpoint{ + IfaceName: "eth0", + HardAddr: net.HardwareAddr{0x02, 0x00, 0xca, 0xfe, 0x00, 0x04}.String(), + } + + h := &mockHypervisor{} + + err := v.HotAttach(h) + assert.Error(err) +} + +func TestPhysicalEndpoint_HotDetach(t *testing.T) { + assert := assert.New(t) + v := &PhysicalEndpoint{ + IfaceName: "eth0", + HardAddr: net.HardwareAddr{0x02, 0x00, 0xca, 0xfe, 0x00, 0x04}.String(), + } + + h := &mockHypervisor{} + + err := v.HotDetach(h, true, "") + assert.Error(err) +} + func TestGetNetNsFromBindMount(t *testing.T) { assert := assert.New(t) diff --git a/virtcontainers/noop_agent.go b/virtcontainers/noop_agent.go index fe919ec587..d5073166e5 100644 --- a/virtcontainers/noop_agent.go +++ b/virtcontainers/noop_agent.go @@ -8,6 +8,7 @@ package virtcontainers import ( "syscall" + "github.com/kata-containers/agent/protocols/grpc" specs "github.com/opencontainers/runtime-spec/specs-go" ) @@ -96,6 +97,26 @@ func (n *noopAgent) onlineCPUMem(cpus uint32) error { return nil } +// updateInterface is the Noop agent Interface update implementation. It does nothing. +func (n *noopAgent) updateInterface(inf *grpc.Interface) (*grpc.Interface, error) { + return nil, nil +} + +// listInterfaces is the Noop agent Interfaces list implementation. It does nothing. +func (n *noopAgent) listInterfaces() ([]*grpc.Interface, error) { + return nil, nil +} + +// updateRoutes is the Noop agent Routes update implementation. It does nothing. +func (n *noopAgent) updateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) { + return nil, nil +} + +// listRoutes is the Noop agent Routes list implementation. It does nothing. +func (n *noopAgent) listRoutes() ([]*grpc.Route, error) { + return nil, nil +} + // check is the Noop agent health checker. It does nothing. func (n *noopAgent) check() error { return nil diff --git a/virtcontainers/noop_agent_test.go b/virtcontainers/noop_agent_test.go index 847997b202..39b689abb1 100644 --- a/virtcontainers/noop_agent_test.go +++ b/virtcontainers/noop_agent_test.go @@ -217,3 +217,35 @@ func TestNoopAgentReseedRNG(t *testing.T) { t.Fatal("reseedRNG failed") } } + +func TestNoopAgentUpdateInterface(t *testing.T) { + n := &noopAgent{} + _, err := n.updateInterface(nil) + if err != nil { + t.Fatal("updateInterface failed") + } +} + +func TestNoopAgentListInterfaces(t *testing.T) { + n := &noopAgent{} + _, err := n.listInterfaces() + if err != nil { + t.Fatal("listInterfaces failed") + } +} + +func TestNoopAgentUpdateRoutes(t *testing.T) { + n := &noopAgent{} + _, err := n.updateRoutes(nil) + if err != nil { + t.Fatal("updateRoutes failed") + } +} + +func TestNoopAgentListRoutes(t *testing.T) { + n := &noopAgent{} + _, err := n.listRoutes() + if err != nil { + t.Fatal("listRoutes failed") + } +} diff --git a/virtcontainers/pkg/vcmock/mock.go b/virtcontainers/pkg/vcmock/mock.go index bf4cb27724..4c74b0065e 100644 --- a/virtcontainers/pkg/vcmock/mock.go +++ b/virtcontainers/pkg/vcmock/mock.go @@ -19,6 +19,7 @@ import ( "fmt" "syscall" + "github.com/kata-containers/agent/protocols/grpc" vc "github.com/kata-containers/runtime/virtcontainers" "github.com/kata-containers/runtime/virtcontainers/device/api" "github.com/kata-containers/runtime/virtcontainers/device/config" @@ -250,3 +251,48 @@ func (m *VCMock) AddDevice(sandboxID string, info config.DeviceInfo) (api.Device return nil, fmt.Errorf("%s: %s (%+v): sandboxID: %v", mockErrorPrefix, getSelf(), m, sandboxID) } + +// AddInterface implements the VC function of the same name. +func (m *VCMock) AddInterface(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) { + if m.AddInterfaceFunc != nil { + return m.AddInterfaceFunc(sandboxID, inf) + } + + return nil, fmt.Errorf("%s: %s (%+v): sandboxID: %v", mockErrorPrefix, getSelf(), m, sandboxID) +} + +// RemoveInterface implements the VC function of the same name. +func (m *VCMock) RemoveInterface(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) { + if m.RemoveInterfaceFunc != nil { + return m.RemoveInterfaceFunc(sandboxID, inf) + } + + return nil, fmt.Errorf("%s: %s (%+v): sandboxID: %v", mockErrorPrefix, getSelf(), m, sandboxID) +} + +// ListInterfaces implements the VC function of the same name. +func (m *VCMock) ListInterfaces(sandboxID string) ([]*grpc.Interface, error) { + if m.ListInterfacesFunc != nil { + return m.ListInterfacesFunc(sandboxID) + } + + return nil, fmt.Errorf("%s: %s (%+v): sandboxID: %v", mockErrorPrefix, getSelf(), m, sandboxID) +} + +// UpdateRoutes implements the VC function of the same name. +func (m *VCMock) UpdateRoutes(sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error) { + if m.UpdateRoutesFunc != nil { + return m.UpdateRoutesFunc(sandboxID, routes) + } + + return nil, fmt.Errorf("%s: %s (%+v): sandboxID: %v", mockErrorPrefix, getSelf(), m, sandboxID) +} + +// ListRoutes implements the VC function of the same name. +func (m *VCMock) ListRoutes(sandboxID string) ([]*grpc.Route, error) { + if m.ListRoutesFunc != nil { + return m.ListRoutesFunc(sandboxID) + } + + return nil, fmt.Errorf("%s: %s (%+v): sandboxID: %v", mockErrorPrefix, getSelf(), m, sandboxID) +} diff --git a/virtcontainers/pkg/vcmock/mock_test.go b/virtcontainers/pkg/vcmock/mock_test.go index 411bc05541..2dc53a3122 100644 --- a/virtcontainers/pkg/vcmock/mock_test.go +++ b/virtcontainers/pkg/vcmock/mock_test.go @@ -10,6 +10,7 @@ import ( "syscall" "testing" + "github.com/kata-containers/agent/protocols/grpc" vc "github.com/kata-containers/runtime/virtcontainers" "github.com/kata-containers/runtime/virtcontainers/factory" "github.com/sirupsen/logrus" @@ -710,3 +711,133 @@ func TestVCMockSetVMFactory(t *testing.T) { m.SetFactory(f) assert.Equal(factoryTriggered, 1) } + +func TestVCMockAddInterface(t *testing.T) { + assert := assert.New(t) + + m := &VCMock{} + config := &vc.SandboxConfig{} + assert.Nil(m.AddInterfaceFunc) + + _, err := m.AddInterface(config.ID, nil) + assert.Error(err) + assert.True(IsMockError(err)) + + m.AddInterfaceFunc = func(sid string, inf *grpc.Interface) (*grpc.Interface, error) { + return nil, nil + } + + _, err = m.AddInterface(config.ID, nil) + assert.NoError(err) + + // reset + m.AddInterfaceFunc = nil + + _, err = m.AddInterface(config.ID, nil) + assert.Error(err) + assert.True(IsMockError(err)) +} + +func TestVCMockRemoveInterface(t *testing.T) { + assert := assert.New(t) + + m := &VCMock{} + config := &vc.SandboxConfig{} + assert.Nil(m.RemoveInterfaceFunc) + + _, err := m.RemoveInterface(config.ID, nil) + assert.Error(err) + assert.True(IsMockError(err)) + + m.RemoveInterfaceFunc = func(sid string, inf *grpc.Interface) (*grpc.Interface, error) { + return nil, nil + } + + _, err = m.RemoveInterface(config.ID, nil) + assert.NoError(err) + + // reset + m.RemoveInterfaceFunc = nil + + _, err = m.RemoveInterface(config.ID, nil) + assert.Error(err) + assert.True(IsMockError(err)) +} + +func TestVCMockListInterfaces(t *testing.T) { + assert := assert.New(t) + + m := &VCMock{} + config := &vc.SandboxConfig{} + assert.Nil(m.ListInterfacesFunc) + + _, err := m.ListInterfaces(config.ID) + assert.Error(err) + assert.True(IsMockError(err)) + + m.ListInterfacesFunc = func(sid string) ([]*grpc.Interface, error) { + return nil, nil + } + + _, err = m.ListInterfaces(config.ID) + assert.NoError(err) + + // reset + m.ListInterfacesFunc = nil + + _, err = m.ListInterfaces(config.ID) + assert.Error(err) + assert.True(IsMockError(err)) +} + +func TestVCMockUpdateRoutes(t *testing.T) { + assert := assert.New(t) + + m := &VCMock{} + config := &vc.SandboxConfig{} + assert.Nil(m.UpdateRoutesFunc) + + _, err := m.UpdateRoutes(config.ID, nil) + assert.Error(err) + assert.True(IsMockError(err)) + + m.UpdateRoutesFunc = func(sid string, routes []*grpc.Route) ([]*grpc.Route, error) { + return nil, nil + } + + _, err = m.UpdateRoutes(config.ID, nil) + assert.NoError(err) + + // reset + m.UpdateRoutesFunc = nil + + _, err = m.UpdateRoutes(config.ID, nil) + assert.Error(err) + assert.True(IsMockError(err)) +} + +func TestVCMockListRoutes(t *testing.T) { + assert := assert.New(t) + + m := &VCMock{} + config := &vc.SandboxConfig{} + assert.Nil(m.ListRoutesFunc) + + _, err := m.ListRoutes(config.ID) + assert.Error(err) + assert.True(IsMockError(err)) + + m.ListRoutesFunc = func(sid string) ([]*grpc.Route, error) { + return nil, nil + } + + _, err = m.ListRoutes(config.ID) + assert.NoError(err) + + // reset + m.ListRoutesFunc = nil + + _, err = m.ListRoutes(config.ID) + assert.Error(err) + assert.True(IsMockError(err)) +} diff --git a/virtcontainers/pkg/vcmock/sandbox.go b/virtcontainers/pkg/vcmock/sandbox.go index 7f27888dd4..f3a3c0cf82 100644 --- a/virtcontainers/pkg/vcmock/sandbox.go +++ b/virtcontainers/pkg/vcmock/sandbox.go @@ -9,6 +9,7 @@ import ( "io" "syscall" + "github.com/kata-containers/agent/protocols/grpc" vc "github.com/kata-containers/runtime/virtcontainers" "github.com/kata-containers/runtime/virtcontainers/device/api" "github.com/kata-containers/runtime/virtcontainers/device/config" @@ -145,3 +146,28 @@ func (s *Sandbox) IOStream(containerID, processID string) (io.WriteCloser, io.Re func (s *Sandbox) AddDevice(info config.DeviceInfo) (api.Device, error) { return nil, nil } + +// AddInterface implements the VCSandbox function of the same name. +func (s *Sandbox) AddInterface(inf *grpc.Interface) (*grpc.Interface, error) { + return nil, nil +} + +// RemoveInterface implements the VCSandbox function of the same name. +func (s *Sandbox) RemoveInterface(inf *grpc.Interface) (*grpc.Interface, error) { + return nil, nil +} + +// ListInterfaces implements the VCSandbox function of the same name. +func (s *Sandbox) ListInterfaces() ([]*grpc.Interface, error) { + return nil, nil +} + +// UpdateRoutes implements the VCSandbox function of the same name. +func (s *Sandbox) UpdateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) { + return nil, nil +} + +// ListRoutes implements the VCSandbox function of the same name. +func (s *Sandbox) ListRoutes() ([]*grpc.Route, error) { + return nil, nil +} diff --git a/virtcontainers/pkg/vcmock/types.go b/virtcontainers/pkg/vcmock/types.go index c04f2a7cd0..1c7237f13f 100644 --- a/virtcontainers/pkg/vcmock/types.go +++ b/virtcontainers/pkg/vcmock/types.go @@ -8,6 +8,7 @@ package vcmock import ( "syscall" + "github.com/kata-containers/agent/protocols/grpc" vc "github.com/kata-containers/runtime/virtcontainers" "github.com/kata-containers/runtime/virtcontainers/device/api" "github.com/kata-containers/runtime/virtcontainers/device/config" @@ -65,4 +66,10 @@ type VCMock struct { ResumeContainerFunc func(sandboxID, containerID string) error AddDeviceFunc func(sandboxID string, info config.DeviceInfo) (api.Device, error) + + AddInterfaceFunc func(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) + RemoveInterfaceFunc func(sandboxID string, inf *grpc.Interface) (*grpc.Interface, error) + ListInterfacesFunc func(sandboxID string) ([]*grpc.Interface, error) + UpdateRoutesFunc func(sandboxID string, routes []*grpc.Route) ([]*grpc.Route, error) + ListRoutesFunc func(sandboxID string) ([]*grpc.Route, error) } diff --git a/virtcontainers/qemu.go b/virtcontainers/qemu.go index e45b31f8ed..ade8a5ed6b 100644 --- a/virtcontainers/qemu.go +++ b/virtcontainers/qemu.go @@ -757,6 +757,78 @@ func (q *qemu) hotplugVFIODevice(device *config.VFIODev, op operation) error { return nil } +func (q *qemu) hotplugMacvtap(drive VirtualEndpoint) error { + var ( + VMFdNames []string + VhostFdNames []string + ) + for i, VMFd := range drive.NetPair.VMFds { + fdName := fmt.Sprintf("fd%d", i) + err := q.qmpMonitorCh.qmp.ExecuteGetFD(q.qmpMonitorCh.ctx, fdName, VMFd) + if err != nil { + return err + } + VMFdNames = append(VMFdNames, fdName) + } + for i, VhostFd := range drive.NetPair.VhostFds { + fdName := fmt.Sprintf("vhostfd%d", i) + err := q.qmpMonitorCh.qmp.ExecuteGetFD(q.qmpMonitorCh.ctx, fdName, VhostFd) + if err != nil { + return err + } + VhostFdNames = append(VhostFdNames, fdName) + } + return q.qmpMonitorCh.qmp.ExecuteNetdevAddByFds(q.qmpMonitorCh.ctx, "tap", drive.NetPair.Name, VMFdNames, VhostFdNames) +} + +func (q *qemu) hotplugNetDevice(drive VirtualEndpoint, op operation) error { + defer func(qemu *qemu) { + if q.qmpMonitorCh.qmp != nil { + q.qmpMonitorCh.qmp.Shutdown() + } + }(q) + + err := q.qmpSetup() + if err != nil { + return err + } + devID := "virtio-" + drive.NetPair.ID + + if op == addDevice { + switch drive.NetPair.NetInterworkingModel { + case NetXConnectBridgedModel: + if err := q.qmpMonitorCh.qmp.ExecuteNetdevAdd(q.qmpMonitorCh.ctx, "tap", drive.NetPair.Name, drive.NetPair.TAPIface.Name, "no", "no", defaultQueues); err != nil { + return err + } + case NetXConnectMacVtapModel: + if err := q.hotplugMacvtap(drive); err != nil { + return err + } + default: + return fmt.Errorf("this net interworking model is not supported") + } + addr, bridge, err := q.addDeviceToBridge(drive.NetPair.ID) + if err != nil { + return err + } + drive.PCIAddr = fmt.Sprintf("%02x/%s", bridge.Addr, addr) + if err = q.qmpMonitorCh.qmp.ExecuteNetPCIDeviceAdd(q.qmpMonitorCh.ctx, drive.NetPair.Name, devID, drive.NetPair.TAPIface.HardAddr, addr, bridge.ID); err != nil { + return err + } + } else { + if err := q.removeDeviceFromBridge(drive.NetPair.ID); err != nil { + return err + } + if err := q.qmpMonitorCh.qmp.ExecuteDeviceDel(q.qmpMonitorCh.ctx, devID); err != nil { + return err + } + if err := q.qmpMonitorCh.qmp.ExecuteNetdevDel(q.qmpMonitorCh.ctx, drive.NetPair.Name); err != nil { + return err + } + } + return nil +} + func (q *qemu) hotplugDevice(devInfo interface{}, devType deviceType, op operation) (interface{}, error) { switch devType { case blockDev: @@ -771,6 +843,9 @@ func (q *qemu) hotplugDevice(devInfo interface{}, devType deviceType, op operati case memoryDev: memdev := devInfo.(*memoryDevice) return nil, q.hotplugMemory(memdev, op) + case netDev: + device := devInfo.(VirtualEndpoint) + return nil, q.hotplugNetDevice(device, op) default: return nil, fmt.Errorf("cannot hotplug device: unsupported device type '%v'", devType) } @@ -1038,7 +1113,7 @@ func genericAppendBridges(devices []govmmQemu.Device, bridges []Bridge, machineT Bus: bus, ID: b.ID, // Each bridge is required to be assigned a unique chassis id > 0 - Chassis: (idx + 1), + Chassis: idx + 1, SHPC: true, Addr: strconv.FormatInt(int64(bridges[idx].Addr), 10), }, diff --git a/virtcontainers/sandbox.go b/virtcontainers/sandbox.go index c2b17448a2..1ac8e65a4c 100644 --- a/virtcontainers/sandbox.go +++ b/virtcontainers/sandbox.go @@ -8,19 +8,23 @@ package virtcontainers import ( "fmt" "io" + "net" "os" "path/filepath" "strings" "sync" "syscall" + "github.com/containernetworking/plugins/pkg/ns" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" + "github.com/kata-containers/agent/protocols/grpc" "github.com/kata-containers/runtime/virtcontainers/device/api" "github.com/kata-containers/runtime/virtcontainers/device/config" "github.com/kata-containers/runtime/virtcontainers/device/drivers" deviceManager "github.com/kata-containers/runtime/virtcontainers/device/manager" + "github.com/vishvananda/netlink" ) // vmStartTimeout represents the time in seconds a sandbox can wait before @@ -976,6 +980,93 @@ func (s *Sandbox) removeNetwork() error { return s.network.remove(s, s.networkNS, s.networkNS.NetNsCreated) } +func (s *Sandbox) generateNetInfo(inf *grpc.Interface) (NetworkInfo, error) { + hw, err := net.ParseMAC(inf.HwAddr) + if err != nil { + return NetworkInfo{}, err + } + + var addrs []netlink.Addr + for _, addr := range inf.IPAddresses { + netlinkAddrStr := fmt.Sprintf("%s/%s", addr.Address, addr.Mask) + netlinkAddr, err := netlink.ParseAddr(netlinkAddrStr) + if err != nil { + return NetworkInfo{}, fmt.Errorf("could not parse %q: %v", netlinkAddrStr, err) + } + + addrs = append(addrs, *netlinkAddr) + } + + return NetworkInfo{ + Iface: NetlinkIface{ + LinkAttrs: netlink.LinkAttrs{ + Name: inf.Name, + HardwareAddr: hw, + MTU: int(inf.Mtu), + }, + Type: "", + }, + Addrs: addrs, + }, nil +} + +// AddInterface adds new nic to the sandbox. +func (s *Sandbox) AddInterface(inf *grpc.Interface) (*grpc.Interface, error) { + netInfo, err := s.generateNetInfo(inf) + if err != nil { + return nil, err + } + + endpoint, err := createVirtualNetworkEndpoint(len(s.networkNS.Endpoints), inf.Name, s.config.NetworkConfig.InterworkingModel) + if err != nil { + return nil, err + } + endpoint.SetProperties(netInfo) + if err := doNetNS(s.networkNS.NetNsPath, func(_ ns.NetNS) error { + return endpoint.HotAttach(s.hypervisor) + }); err != nil { + return nil, err + } + + // Update the sandbox storage + s.networkNS.Endpoints = append(s.networkNS.Endpoints, endpoint) + if err := s.storage.storeSandboxNetwork(s.id, s.networkNS); err != nil { + return nil, err + } + + // Add network for vm + return s.agent.updateInterface(inf) +} + +// RemoveInterface removes a nic of the sandbox. +func (s *Sandbox) RemoveInterface(inf *grpc.Interface) (*grpc.Interface, error) { + for i, endpoint := range s.networkNS.Endpoints { + if endpoint.HardwareAddr() == inf.HwAddr { + if err := endpoint.HotDetach(s.hypervisor, s.networkNS.NetNsCreated, s.networkNS.NetNsPath); err != nil { + return inf, err + } + s.networkNS.Endpoints = append(s.networkNS.Endpoints[:i], s.networkNS.Endpoints[i+1:]...) + break + } + } + return nil, nil +} + +// ListInterfaces lists all nics and their configurations in the sandbox. +func (s *Sandbox) ListInterfaces() ([]*grpc.Interface, error) { + return s.agent.listInterfaces() +} + +// UpdateRoutes updates the sandbox route table (e.g. for portmapping support). +func (s *Sandbox) UpdateRoutes(routes []*grpc.Route) ([]*grpc.Route, error) { + return s.agent.updateRoutes(routes) +} + +// ListRoutes lists all routes and their configurations in the sandbox. +func (s *Sandbox) ListRoutes() ([]*grpc.Route, error) { + return s.agent.listRoutes() +} + // startVM starts the VM. func (s *Sandbox) startVM() error { s.Logger().Info("Starting VM")