diff --git a/api/descriptions.pb.go b/api/descriptions.pb.go index 98f5c843..31865f40 100644 --- a/api/descriptions.pb.go +++ b/api/descriptions.pb.go @@ -308,13 +308,15 @@ func (m *VolumeDescription) GetReadOnly() bool { type InterfaceDescription struct { Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` - Lo bool `protobuf:"varint,2,opt,name=lo" json:"lo,omitempty"` - Bridge string `protobuf:"bytes,3,opt,name=bridge" json:"bridge,omitempty"` - Ip string `protobuf:"bytes,4,opt,name=ip" json:"ip,omitempty"` - Mac string `protobuf:"bytes,5,opt,name=mac" json:"mac,omitempty"` - Gw string `protobuf:"bytes,6,opt,name=gw" json:"gw,omitempty"` - TapName string `protobuf:"bytes,7,opt,name=tapName" json:"tapName,omitempty"` - Options string `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` + Lo bool `protobuf:"varint,3,opt,name=lo" json:"lo,omitempty"` + Bridge string `protobuf:"bytes,4,opt,name=bridge" json:"bridge,omitempty"` + Ip string `protobuf:"bytes,5,opt,name=ip" json:"ip,omitempty"` + Mac string `protobuf:"bytes,6,opt,name=mac" json:"mac,omitempty"` + Mtu uint64 `protobuf:"varint,7,opt,name=mtu" json:"mtu,omitempty"` + Gw string `protobuf:"bytes,8,opt,name=gw" json:"gw,omitempty"` + TapName string `protobuf:"bytes,9,opt,name=tapName" json:"tapName,omitempty"` + Options string `protobuf:"bytes,10,opt,name=options" json:"options,omitempty"` } func (m *InterfaceDescription) Reset() { *m = InterfaceDescription{} } @@ -329,6 +331,13 @@ func (m *InterfaceDescription) GetId() string { return "" } +func (m *InterfaceDescription) GetName() string { + if m != nil { + return m.Name + } + return "" +} + func (m *InterfaceDescription) GetLo() bool { if m != nil { return m.Lo @@ -357,6 +366,13 @@ func (m *InterfaceDescription) GetMac() string { return "" } +func (m *InterfaceDescription) GetMtu() uint64 { + if m != nil { + return m.Mtu + } + return 0 +} + func (m *InterfaceDescription) GetGw() string { if m != nil { return m.Gw @@ -692,71 +708,71 @@ func init() { func init() { proto.RegisterFile("descriptions.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 1050 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x56, 0x6f, 0x6b, 0x1b, 0x47, - 0x13, 0xe7, 0xce, 0x92, 0x25, 0x8d, 0xe2, 0xd8, 0x59, 0xfc, 0x84, 0x25, 0x3c, 0x14, 0x73, 0x4d, - 0x8a, 0x49, 0xc1, 0x2f, 0x1c, 0x68, 0x9a, 0x42, 0xa0, 0x21, 0x09, 0x41, 0xd0, 0xda, 0x62, 0xdd, - 0xb4, 0xf4, 0xe5, 0xea, 0x6e, 0x25, 0x6f, 0x7d, 0xda, 0x3d, 0x76, 0x57, 0x76, 0xd4, 0x0f, 0xd1, - 0xf7, 0xfd, 0x16, 0x7d, 0xd1, 0x8f, 0xd3, 0x2f, 0xd0, 0x6f, 0x51, 0x66, 0x6e, 0xef, 0x7c, 0x96, - 0x9d, 0x96, 0xbc, 0x9b, 0xf9, 0xdd, 0xcc, 0xec, 0xfc, 0x9f, 0x03, 0x56, 0x28, 0x9f, 0x3b, 0x5d, - 0x05, 0x6d, 0x8d, 0x3f, 0xaa, 0x9c, 0x0d, 0x96, 0x6d, 0xc9, 0x4a, 0x67, 0x7f, 0x24, 0xb0, 0x73, - 0x26, 0x4d, 0x31, 0xb3, 0x1f, 0x5e, 0x5b, 0x33, 0xd7, 0x0b, 0xf6, 0x08, 0x86, 0xe7, 0xd6, 0x07, - 0x23, 0x97, 0x8a, 0x27, 0x07, 0xc9, 0xe1, 0x48, 0xb4, 0x3c, 0xdb, 0x83, 0xad, 0xc2, 0x78, 0x9e, - 0x1e, 0x6c, 0x1d, 0x8e, 0x04, 0x92, 0xec, 0x19, 0x8c, 0x8c, 0xd2, 0x8b, 0xf3, 0x99, 0x75, 0x9e, - 0x6f, 0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xb4, 0x0f, 0xfd, 0x05, 0x0a, 0x34, - 0xeb, 0x82, 0x18, 0xac, 0x88, 0x2c, 0x0a, 0x8d, 0x61, 0xc8, 0x92, 0x0c, 0xe0, 0xb9, 0xa7, 0x8a, - 0x6c, 0xe2, 0xd9, 0x1b, 0xd8, 0xae, 0x37, 0x37, 0xda, 0xa7, 0x91, 0x8d, 0xf6, 0x69, 0x60, 0x19, - 0xf4, 0xce, 0xa5, 0x2b, 0xc8, 0x7c, 0x4f, 0x10, 0x8d, 0x98, 0xb7, 0xf3, 0x7a, 0xe4, 0x7b, 0x82, - 0xe8, 0xec, 0xef, 0x04, 0x06, 0x53, 0x67, 0x73, 0xe5, 0xe9, 0x87, 0xa0, 0xdd, 0xd2, 0xd1, 0xd8, - 0x35, 0x80, 0x23, 0x32, 0x29, 0xa2, 0xbb, 0xe9, 0x84, 0xac, 0x61, 0x98, 0x31, 0x67, 0x44, 0x63, - 0x54, 0xe4, 0x5d, 0x9c, 0xb5, 0x9a, 0x61, 0x87, 0xb0, 0xfb, 0xea, 0xa6, 0xf7, 0xf1, 0x77, 0x63, - 0x13, 0xc6, 0x32, 0xfd, 0xa0, 0xdc, 0x52, 0x37, 0xe7, 0x7c, 0x28, 0x5a, 0x1e, 0xdf, 0x7b, 0x85, - 0x17, 0x6d, 0x50, 0x5f, 0x34, 0xa4, 0x11, 0xc3, 0x75, 0xce, 0x87, 0x35, 0xf6, 0x36, 0xde, 0xc9, - 0x9f, 0xe2, 0x9d, 0xac, 0x2f, 0x74, 0xc3, 0xce, 0xb6, 0x69, 0x72, 0x9e, 0xfd, 0x13, 0x00, 0x00, - 0xff, 0xff, 0xb9, 0xd4, 0x30, 0xfc, 0xa7, 0x09, 0x00, 0x00, + // 1056 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x56, 0xef, 0x6a, 0x1b, 0x47, + 0x10, 0xe7, 0x64, 0xc9,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xa3, 0x7d, 0x1a, + 0xec, 0x68, 0x9f, 0xc6, 0x9a, 0x41, 0xf7, 0x42, 0xba, 0x9c, 0xcc, 0x77, 0x05, 0xd1, 0x88, 0x79, + 0x3b, 0xab, 0x16, 0x43, 0x57, 0x10, 0x9d, 0xfe, 0x9b, 0x40, 0x7f, 0xe2, 0x6c, 0xa6, 0x3c, 0xfd, + 0x36, 0x34, 0xbb, 0x3c, 0x1a, 0xbb, 0x01, 0x70, 0x44, 0xc6, 0x79, 0x74, 0xb7, 0x33, 0x26, 0x6b, + 0x18, 0x66, 0xcc, 0x19, 0xd1, 0x18, 0x15, 0x79, 0x17, 0x27, 0xb2, 0x62, 0xd8, 0x21, 0x6c, 0xbf, + 0xb9, 0xed, 0x7d, 0xfc, 0x29, 0x59, 0x87, 0xb1, 0x4c, 0x3f, 0x29, 0xb7, 0xd0, 0xf5, 0xd1, 0x1f, + 0x88, 0x86, 0xc7, 0xf7, 0xde, 0xe0, 0xdd, 0xeb, 0x57, 0x77, 0x0f, 0x69, 0xc4, 0x70, 0xe9, 0xf3, + 0x41, 0x85, 0x9d, 0xc4, 0x6b, 0xfa, 0x4b, 0xbc, 0xa6, 0x71, 0x74, 0x23, 0x3b, 0xdd, 0xa4, 0xc9, + 0x79, 0xf1, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcb, 0x19, 0x4a, 0x06, 0xcd, 0x09, 0x00, 0x00, } diff --git a/api/descriptions.proto b/api/descriptions.proto index 2ecde84e..3027519e 100644 --- a/api/descriptions.proto +++ b/api/descriptions.proto @@ -2,6 +2,9 @@ syntax = "proto3"; package api; +// To generate description.pb.go, run: +// $ protoc --go_out=plugins=grpc:. descriptions.proto + message SandboxConfig { string hostname = 1; repeated string dns = 2; @@ -52,13 +55,15 @@ message VolumeDescription { message InterfaceDescription { string id = 1; - bool lo = 2; - string bridge = 3; - string ip = 4; - string mac = 5; - string gw = 6; - string tapName = 7; - string options = 8; + string name = 2; + bool lo = 3; + string bridge = 4; + string ip = 5; + string mac = 6; + uint64 mtu = 7; + string gw = 8; + string tapName = 9; + string options = 10; } message PortDescription { diff --git a/cli/container.go b/cli/container.go index 87802765..da6bc27b 100644 --- a/cli/container.go +++ b/cli/container.go @@ -148,7 +148,7 @@ func createContainer(options runvOptions, vm *hypervisor.Vm, container, bundle, } // If runv is launched via docker/containerd, we start netlistener to watch/collect network changes. - // TODO: if runv is launched by cni compatible tools, the cni script can use `runv cni` cmdline to update the network. + // TODO: if runv is launched by cni compatible tools, the cni script can use `runv interface` cmdline to update the network. // Create the listener process which will enters into the netns of the shim options.withContainer = state if err = startNsListener(options, vm); err != nil { diff --git a/cli/interface.go b/cli/interface.go new file mode 100644 index 00000000..4e833e7c --- /dev/null +++ b/cli/interface.go @@ -0,0 +1,212 @@ +package main + +import ( + "fmt" + "os" + "path/filepath" + "text/tabwriter" + + "github.com/hyperhq/runv/api" + "github.com/hyperhq/runv/hypervisor" + "github.com/urfave/cli" +) + +var interfaceCommand = cli.Command{ + Name: "interface", + Usage: "manage interfaces for container", + Subcommands: []cli.Command{ + infAddCommand, + infRmCommand, + infUpdateCommand, + infListCommand, + }, + Before: func(context *cli.Context) error { + return cmdPrepare(context, true, true) + }, + Action: func(context *cli.Context) error { + return cli.ShowSubcommandHelp(context) + }, +} + +var infAddCommand = cli.Command{ + Name: "add", + Usage: "add an interface into a container", + ArgsUsage: `add `, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "host-device", + Usage: "set tap name, if interface with same name exists, use existing one instead of creating new one", + }, + cli.StringFlag{ + Name: "name", + Usage: "set interface name in container", + }, + cli.StringFlag{ + Name: "ip", + Usage: "set ip address with a mask, format: 192.168.0.2/24", + }, + cli.StringFlag{ + Name: "mac", + Usage: "set mac address", + }, + cli.IntFlag{ + Name: "mtu", + Usage: "set mtu", + }, + }, + Action: func(context *cli.Context) error { + container := context.Args().First() + vm, releaseFunc, err := vmByContainerID(context, container) + if err != nil { + return err + } + defer releaseFunc() + conf := &api.InterfaceDescription{ + Name: context.String("name"), + Ip: context.String("ip"), + Mac: context.String("mac"), + TapName: context.String("host-device"), + Mtu: context.Uint64("mtu"), + } + + if err = vm.AddNic(conf); err != nil { + return err + } + fmt.Println("Add interface successfully.") + return nil + }, +} + +var infListCommand = cli.Command{ + Name: "ls", + Aliases: []string{"list"}, + Usage: "list network interfaces in a container", + ArgsUsage: `ls `, + Flags: []cli.Flag{}, + Action: func(context *cli.Context) error { + container := context.Args().First() + vm, releaseFunc, err := vmByContainerID(context, container) + if err != nil { + return err + } + defer releaseFunc() + + tw := tabwriter.NewWriter(os.Stdout, 10, 1, 3, ' ', 0) + fmt.Fprintln(tw, "Name\tMac\tIP\tMtu") + nics := vm.AllNics() + for _, i := range nics { + fmt.Fprintf(tw, "%s\t%s\t%s\t%d\n", i.NewName, i.MacAddr, i.IpAddr, i.Mtu) + } + tw.Flush() + return nil + }, +} + +var infRmCommand = cli.Command{ + Name: "rm", + Aliases: []string{"delete"}, + Usage: "remove an interface from container", + ArgsUsage: `rm `, + Flags: []cli.Flag{}, + Action: func(context *cli.Context) error { + container := context.Args().First() + inf := context.Args().Get(1) + if inf == "" { + return cli.NewExitError("please specify an interface to delete", -1) + } + vm, releaseFunc, err := vmByContainerID(context, container) + if err != nil { + return err + } + defer releaseFunc() + + nics := vm.AllNics() + for _, i := range nics { + if i.NewName == inf { + if err = vm.DeleteNic(i.Id); err != nil { + return cli.NewExitError(fmt.Sprintf("failed to delete interface %q: %v", inf, err), -1) + } + fmt.Printf("Interface %q is deleted\n", inf) + break + } + } + return nil + }, +} + +var infUpdateCommand = cli.Command{ + Name: "update", + Usage: "update configuration of interface", + ArgsUsage: `update `, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "add-ip", + Usage: "add a new ip address with mask (format: 192.168.0.2/24)", + }, + cli.StringFlag{ + Name: "delete-ip", + Usage: "add a new ip address with mask (format: 192.168.0.2/24)", + }, + cli.IntFlag{ + Name: "mtu", + Usage: "update mtu", + }, + }, + Action: func(context *cli.Context) error { + container := context.Args().First() + vm, releaseFunc, err := vmByContainerID(context, container) + if err != nil { + return err + } + defer releaseFunc() + + targetInf := context.Args().Get(1) + if targetInf == "" { + return cli.NewExitError("please specify an interface name to update", -1) + } + + conf := &api.InterfaceDescription{ + Id: "-1", + Mtu: context.Uint64("mtu"), + } + if ip := context.String("add-ip"); ip != "" { + conf.Ip = ip + } + if ip := context.String("delete-ip"); ip != "" { + // an IP address prefixed with "-" indicates deleting an ip + conf.Ip += ",-" + ip + } + + nics := vm.AllNics() + for _, i := range nics { + if i.NewName == targetInf { + conf.Id = i.Id + break + } + } + + if conf.Id == "-1" { + return cli.NewExitError(fmt.Sprintf("Can't find target interface name %q", targetInf), -1) + } + + if err = vm.UpdateNic(conf); err != nil { + return err + } + fmt.Printf("Interface %q is updated\n", targetInf) + return nil + }, +} + +type releaseFunc func() + +func vmByContainerID(context *cli.Context, cid string) (*hypervisor.Vm, releaseFunc, error) { + if cid == "" { + return nil, nil, cli.NewExitError("Please specify container ID", -1) + } + + vm, lockfile, err := getSandbox(filepath.Join(context.GlobalString("root"), cid, "sandbox")) + if err != nil { + return nil, nil, fmt.Errorf("failed to get sandbox for container %q: %v", cid, err) + } + return vm, func() { putSandbox(vm, lockfile) }, nil +} diff --git a/cli/main.go b/cli/main.go index 04c9b477..27d25599 100644 --- a/cli/main.go +++ b/cli/main.go @@ -69,6 +69,7 @@ func main() { }, cli.StringFlag{ Name: "log", + Value: "/dev/null", Usage: "[ignored on runv] set the log file path where internal debug information is written", }, cli.StringFlag{ @@ -128,6 +129,7 @@ func main() { app.Commands = []cli.Command{ createCommand, execCommand, + interfaceCommand, killCommand, listCommand, psCommand, diff --git a/cli/network.go b/cli/network.go index 62af9128..c8087dfc 100644 --- a/cli/network.go +++ b/cli/network.go @@ -46,6 +46,9 @@ type InterfaceInfo struct { Index int PeerIndex int Ip string + Mac string + Name string + Mtu uint64 } type nsListener struct { @@ -110,6 +113,9 @@ func initSandboxNetwork(vm *hypervisor.Vm, enc *gob.Encoder, dec *gob.Decoder, p Lo: false, Bridge: fakeBridge, Ip: info.Ip, + Name: info.Name, + Mac: info.Mac, + Mtu: info.Mtu, } if gw_route != nil && gw_route.LinkIndex == info.Index { @@ -387,6 +393,9 @@ func collectionInterfaceInfo() []InterfaceInfo { info := InterfaceInfo{ Index: link.Attrs().Index, PeerIndex: link.Attrs().ParentIndex, + Name: link.Attrs().Name, + Mac: link.Attrs().HardwareAddr.String(), + Mtu: uint64(link.Attrs().MTU), } ipAddrs := []string{} addrs, err := netlink.AddrList(link, netlink.FAMILY_V4) diff --git a/hyperstart/api/grpc/hyperstart.pb.go b/hyperstart/api/grpc/hyperstart.pb.go index 1332d32c..03306b25 100644 --- a/hyperstart/api/grpc/hyperstart.pb.go +++ b/hyperstart/api/grpc/hyperstart.pb.go @@ -392,8 +392,11 @@ func (m *IpAddress) GetMask() string { } type UpdateInterfaceRequest struct { - Device string `protobuf:"bytes,1,opt,name=device" json:"device,omitempty"` - IpAddresses []*IpAddress `protobuf:"bytes,2,rep,name=ipAddresses" json:"ipAddresses,omitempty"` + Type uint64 `protobuf:"varint,1,opt,name=type" json:"type,omitempty"` + Device string `protobuf:"bytes,2,opt,name=device" json:"device,omitempty"` + NewName string `protobuf:"bytes,3,opt,name=newName" json:"newName,omitempty"` + IpAddresses []*IpAddress `protobuf:"bytes,4,rep,name=ipAddresses" json:"ipAddresses,omitempty"` + Mtu uint64 `protobuf:"varint,5,opt,name=mtu" json:"mtu,omitempty"` } func (m *UpdateInterfaceRequest) Reset() { *m = UpdateInterfaceRequest{} } @@ -401,6 +404,13 @@ func (m *UpdateInterfaceRequest) String() string { return proto.Compa func (*UpdateInterfaceRequest) ProtoMessage() {} func (*UpdateInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } +func (m *UpdateInterfaceRequest) GetType() uint64 { + if m != nil { + return m.Type + } + return 0 +} + func (m *UpdateInterfaceRequest) GetDevice() string { if m != nil { return m.Device @@ -408,6 +418,13 @@ func (m *UpdateInterfaceRequest) GetDevice() string { return "" } +func (m *UpdateInterfaceRequest) GetNewName() string { + if m != nil { + return m.NewName + } + return "" +} + func (m *UpdateInterfaceRequest) GetIpAddresses() []*IpAddress { if m != nil { return m.IpAddresses @@ -415,6 +432,13 @@ func (m *UpdateInterfaceRequest) GetIpAddresses() []*IpAddress { return nil } +func (m *UpdateInterfaceRequest) GetMtu() uint64 { + if m != nil { + return m.Mtu + } + return 0 +} + type AddRouteRequest struct { Routes []*Route `protobuf:"bytes,1,rep,name=routes" json:"routes,omitempty"` } @@ -1213,71 +1237,73 @@ var _HyperstartService_serviceDesc = grpc1.ServiceDesc{ func init() { proto.RegisterFile("hyperstart.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 1045 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x56, 0xff, 0x6b, 0x5b, 0x37, - 0x10, 0xc7, 0xc9, 0x8b, 0x1d, 0x9f, 0xf3, 0xa5, 0x91, 0x9b, 0xe4, 0xd5, 0x2d, 0x23, 0x7b, 0x83, - 0x36, 0x30, 0xea, 0xb2, 0x14, 0xb6, 0x65, 0x50, 0x86, 0x97, 0x86, 0xae, 0x6c, 0x61, 0x45, 0x5e, - 0x08, 0x0c, 0x06, 0x53, 0x2c, 0xc5, 0x11, 0xb1, 0x25, 0x4f, 0xd2, 0x4b, 0xe6, 0xfd, 0x17, 0xfb, - 0x4f, 0xf6, 0xd3, 0xfe, 0xbe, 0xa1, 0x6f, 0x2f, 0xcf, 0xf1, 0x73, 0xa1, 0x6d, 0x7e, 0xbb, 0x3b, - 0x9d, 0x3e, 0x77, 0x3a, 0x9d, 0xee, 0x23, 0x78, 0x70, 0x39, 0x9d, 0x30, 0xa5, 0x0d, 0x51, 0xa6, - 0x3b, 0x51, 0xd2, 0x48, 0x94, 0x0c, 0xd5, 0x64, 0xd0, 0x79, 0x3c, 0x94, 0x72, 0x38,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x91, 0x05, 0x2e, 0xfb, 0x64, 0x5f, 0xc3, - 0x66, 0x8f, 0x52, 0x2c, 0x73, 0x53, 0xa0, 0x7f, 0x01, 0x75, 0x65, 0x75, 0x9b, 0xa4, 0x05, 0x68, - 0x79, 0x00, 0xef, 0x13, 0x96, 0xb2, 0x6d, 0x68, 0xff, 0x22, 0x46, 0x5c, 0xb0, 0xa3, 0x77, 0xa7, - 0x27, 0x2c, 0xb6, 0x61, 0xf6, 0x6f, 0x0d, 0x9a, 0xc5, 0x8c, 0x42, 0x1b, 0xb0, 0xc4, 0x69, 0xc8, - 0x71, 0x89, 0x53, 0x8b, 0x3c, 0x96, 0xb9, 0x30, 0x31, 0xb5, 0x80, 0x7c, 0x62, 0x6d, 0x38, 0x2c, - 0xa1, 0x97, 0x50, 0xd7, 0x53, 0x3d, 0x30, 0xf6, 0xf9, 0x5b, 0xa7, 0xc7, 0x77, 0x26, 0x5f, 0xb7, - 0xef, 0x56, 0x8f, 0x85, 0x51, 0x53, 0x1c, 0x5c, 0x3b, 0x87, 0xd0, 0x2a, 0x99, 0xed, 0x05, 0x5d, - 0xb1, 0x69, 0x88, 0x6c, 0x45, 0xf4, 0x10, 0x56, 0xae, 0xc9, 0x28, 0x67, 0xa1, 0xc2, 0x5e, 0xf9, - 0x6e, 0xe9, 0xdb, 0x5a, 0x46, 0x60, 0xc5, 0x25, 0xe0, 0x5a, 0x9c, 0x69, 0x13, 0x76, 0x39, 0xd9, - 0x8d, 0x03, 0x99, 0xab, 0x41, 0xdc, 0x17, 0x34, 0xeb, 0x6b, 0xa6, 0x13, 0xe6, 0xfa, 0xab, 0x89, - 0x9d, 0x6c, 0x6f, 0x57, 0x4e, 0x0c, 0x97, 0x42, 0xa7, 0x89, 0xeb, 0x8c, 0xa8, 0x66, 0xff, 0x2c, - 0x41, 0x23, 0x0c, 0x9a, 0xb9, 0x9a, 0x20, 0x48, 0x88, 0x1a, 0xc6, 0x66, 0x72, 0x32, 0xfa, 0x12, - 0x12, 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7d, 0xa6, 0xdc, 0x53, 0xed, 0xc1, 0x5a, 0x99, 0xf9, - 0xd1, 0x23, 0x5f, 0xde, 0x8a, 0xdf, 0x40, 0x67, 0xa7, 0xeb, 0xbf, 0x10, 0xdd, 0xf8, 0x85, 0xe8, - 0x1e, 0xdb, 0x2f, 0x04, 0x7a, 0x05, 0x70, 0xcb, 0xe9, 0x68, 0xb7, 0x00, 0x98, 0x25, 0xc8, 0x85, - 0xdb, 0x8f, 0x60, 0x7d, 0x86, 0xb6, 0x51, 0xc7, 0x23, 0x54, 0x71, 0xf9, 0x42, 0x90, 0x1f, 0xa0, - 0x55, 0x62, 0x51, 0x94, 0x7a, 0x88, 0x79, 0x9a, 0xee, 0x3c, 0xaa, 0x58, 0x09, 0xd4, 0xd2, 0x03, - 0x08, 0xc4, 0x47, 0xb9, 0x28, 0x20, 0xe6, 0xc8, 0xb6, 0x80, 0xa8, 0x20, 0xc9, 0xef, 0x01, 0x3c, - 0x67, 0x51, 0x99, 0x9b, 0x58, 0x8a, 0x39, 0x92, 0xec, 0xa4, 0xf3, 0x0b, 0x73, 0x00, 0x4c, 0xa9, - 0x8f, 0x01, 0x78, 0x05, 0x70, 0xcb, 0x85, 0x11, 0x60, 0x8e, 0x1d, 0x17, 0xd6, 0xb1, 0x07, 0x6b, - 0x65, 0xf6, 0x8b, 0xed, 0x50, 0xc1, 0x88, 0xef, 0x83, 0x28, 0xf3, 0x58, 0x84, 0xa8, 0xe0, 0xb6, - 0x85, 0x10, 0xc7, 0xb0, 0x31, 0xcb, 0x62, 0x28, 0x0c, 0xdf, 0x4a, 0x6e, 0x5b, 0x08, 0xf3, 0x06, - 0x36, 0xef, 0x10, 0x17, 0x7a, 0x12, 0xc6, 0x52, 0x25, 0x9f, 0x2d, 0x04, 0x3a, 0x84, 0xd5, 0x48, - 0x4e, 0x68, 0xbb, 0xe8, 0xef, 0x32, 0x59, 0xbd, 0xaf, 0x1a, 0x65, 0x7e, 0x8a, 0xd5, 0xa8, 0xe0, - 0xac, 0x45, 0x10, 0xe7, 0x75, 0xa7, 0xbf, 0xfc, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xd5, 0xa0, 0x2a, - 0x02, 0xda, 0x0b, 0x00, 0x00, + // 1077 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x56, 0x6d, 0x6b, 0x5b, 0xb7, + 0x17, 0xc7, 0xf1, 0x8d, 0x1d, 0x1f, 0xe7, 0xa1, 0x91, 0x9b, 0xe4, 0xd6, 0x2d, 0x7f, 0xf2, 0xbf, + 0x83, 0x36, 0x30, 0xea, 0xb2, 0x14, 0xb6, 0x65, 0x50, 0x86, 0xe7, 0x86, 0xae, 0x6c, 0xd9, 0x8a, + 0xbc, 0x10, 0x18, 0x0c, 0xa6, 0x58, 0x8a, 0x23, 0x62, 0x5f, 0x79, 0x92, 0x6e, 0x3c, 0xef, 0x5b, + 0xec, 0x33, 0xec, 0x0b, 0xec, 0xd5, 0x3e, 0xdf, 0xd0, 0xd3, 0xf5, 0x75, 0x7c, 0x5d, 0xe8, 0x9a, + 0x77, 0xe7, 0x48, 0x47, 0xbf, 0xf3, 0x24, 0x9d, 0x9f, 0xe0, 0xc1, 0xf5, 0x6c, 0xc2, 0xa4, 0xd2, + 0x44, 0xea, 0xce, 0x44, 0x0a, 0x2d, 0x50, 0x34, 0x94, 0x93, 0x41, 0xfb, 0xf1, 0x50, 0x88, 0xe1, + 0x88, 0xbd, 0xb0, 0x6b, 0x97, 0xd9, 0xd5, 0x0b, 0x36, 0x9e, 0xe8, 0x99, 0x33, 0x49, 0x86, 0xd0, + 0xea, 0x52, 0xda, 0x13, 0xa9, 0x26, 0x3c, 0x65, 0x12, 0xb3, 0xdf, 0x32, 0xa6, 0x34, 0x7a, 0x0e, + 0x8d, 0x41, 0x58, 0x8b, 0x2b, 0x87, 0x95, 0xa3, 0xe6, 0xf1, 0x4e, 0xc7, 0xa0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0xa0, 0x48, + 0x94, 0x1b, 0x0c, 0x00, 0x00, } diff --git a/hyperstart/api/grpc/hyperstart.proto b/hyperstart/api/grpc/hyperstart.proto index 568f57cf..3c511342 100644 --- a/hyperstart/api/grpc/hyperstart.proto +++ b/hyperstart/api/grpc/hyperstart.proto @@ -4,6 +4,9 @@ package grpc; import "google/protobuf/empty.proto"; +// To generate hyperstart.pb.go, run: +// $ protoc --go_out=plugins=grpc:. hyperstart.proto + // unstable service HyperstartService { // execution @@ -98,8 +101,11 @@ message IpAddress { } message UpdateInterfaceRequest { - string device = 1; - repeated IpAddress ipAddresses = 2; + uint64 type =1; + string device = 2; + string newName = 3; + repeated IpAddress ipAddresses = 4; + uint64 mtu = 5; } message AddRouteRequest { diff --git a/hyperstart/api/json/constants.go b/hyperstart/api/json/constants.go index ee41877a..7fcaca1e 100644 --- a/hyperstart/api/json/constants.go +++ b/hyperstart/api/json/constants.go @@ -29,6 +29,7 @@ const ( INIT_REMOVECONTAINER INIT_PROCESSASYNCEVENT INIT_SIGNALPROCESS + INIT_DELETEINTERFACE // 25 ) // "hyperstart" is the special container ID for adding processes. diff --git a/hyperstart/api/json/spec.go b/hyperstart/api/json/spec.go index fb7525dc..3d334b21 100644 --- a/hyperstart/api/json/spec.go +++ b/hyperstart/api/json/spec.go @@ -84,9 +84,9 @@ type IpAddress struct { type NetworkInf struct { Device string `json:"device"` - IpAddress string `json:"ipAddress,omitempty"` - NetMask string `json:"netMask,omitempty"` + NewName string `json:"newDeviceName"` IpAddresses []IpAddress `json:"ipAddresses"` + Mtu uint64 `json:"mtu"` } type Route struct { diff --git a/hyperstart/libhyperstart/grpc.go b/hyperstart/libhyperstart/grpc.go index 63df14ba..7a7ea825 100644 --- a/hyperstart/libhyperstart/grpc.go +++ b/hyperstart/libhyperstart/grpc.go @@ -86,9 +86,12 @@ func (h *grpcBasedHyperstart) AddRoute(routes []hyperstartjson.Route) error { return err } -func (h *grpcBasedHyperstart) UpdateInterface(dev string, ipAddresses []hyperstartjson.IpAddress) error { +func (h *grpcBasedHyperstart) UpdateInterface(t InfUpdateType, dev, newName string, ipAddresses []hyperstartjson.IpAddress, mtu uint64) error { req := &hyperstartgrpc.UpdateInterfaceRequest{ - Device: dev, + Type: uint64(t), + Device: dev, + NewName: newName, + Mtu: mtu, } for _, addr := range ipAddresses { req.IpAddresses = append(req.IpAddresses, &hyperstartgrpc.IpAddress{addr.IpAddress, addr.NetMask}) diff --git a/hyperstart/libhyperstart/hyperstart.go b/hyperstart/libhyperstart/hyperstart.go index becc794c..c7a8e31f 100644 --- a/hyperstart/libhyperstart/hyperstart.go +++ b/hyperstart/libhyperstart/hyperstart.go @@ -6,6 +6,16 @@ import ( hyperstartapi "github.com/hyperhq/runv/hyperstart/api/json" ) +type InfUpdateType uint64 + +const ( + AddInf InfUpdateType = 1 << iota + DelInf + AddIP + DelIP + SetMtu +) + // Hyperstart interface to hyperstart API type Hyperstart interface { Close() @@ -32,7 +42,7 @@ type Hyperstart interface { WriteFile(container, path string, data []byte) error ReadFile(container, path string) ([]byte, error) AddRoute(r []hyperstartapi.Route) error - UpdateInterface(dev string, addresses []hyperstartapi.IpAddress) error + UpdateInterface(t InfUpdateType, dev, newName string, addresses []hyperstartapi.IpAddress, mtu uint64) error OnlineCpuMem() error } diff --git a/hyperstart/libhyperstart/json.go b/hyperstart/libhyperstart/json.go index b1e516ec..d7a0aeb2 100644 --- a/hyperstart/libhyperstart/json.go +++ b/hyperstart/libhyperstart/json.go @@ -646,11 +646,39 @@ func (h *jsonBasedHyperstart) AddRoute(r []hyperstartapi.Route) error { return h.hyperstartCommand(hyperstartapi.INIT_SETUPROUTE, hyperstartapi.Routes{Routes: r}) } -func (h *jsonBasedHyperstart) UpdateInterface(dev string, ipAddresses []hyperstartapi.IpAddress) error { - return h.hyperstartCommand(hyperstartapi.INIT_SETUPINTERFACE, hyperstartapi.NetworkInf{ +func (h *jsonBasedHyperstart) UpdateInterface(t InfUpdateType, dev, newName string, ipAddresses []hyperstartapi.IpAddress, mtu uint64) error { + inf := hyperstartapi.NetworkInf{ Device: dev, - IpAddresses: ipAddresses, - }) + IpAddresses: []hyperstartapi.IpAddress{}, + } + switch t { + case AddInf: + inf.NewName = newName + inf.Mtu = mtu + inf.IpAddresses = ipAddresses + if err := h.hyperstartCommand(hyperstartapi.INIT_SETUPINTERFACE, inf); err != nil { + return fmt.Errorf("json: failed to send command to hyperstart: %v", err) + } + case DelInf: + if err := h.hyperstartCommand(hyperstartapi.INIT_DELETEINTERFACE, inf); err != nil { + return fmt.Errorf("json: failed to send command to hyperstart. inf: %#v, error: %v", inf, err) + } + case AddIP: + inf.IpAddresses = ipAddresses + if err := h.hyperstartCommand(hyperstartapi.INIT_SETUPINTERFACE, inf); err != nil { + return fmt.Errorf("json: failed to send command to hyperstart: %v", err) + } + case DelIP: + // TODO: add new interface to handle hyperstart delete interface @weizhang555 + case SetMtu: + if mtu > 0 { + inf.Mtu = mtu + if err := h.hyperstartCommand(hyperstartapi.INIT_SETUPINTERFACE, inf); err != nil { + return fmt.Errorf("json: failed to send command to hyperstart: %v", err) + } + } + } + return nil } func (h *jsonBasedHyperstart) WriteStdin(container, process string, data []byte) (int, error) { diff --git a/hyperstart/proxy/proxy.go b/hyperstart/proxy/proxy.go index 3fcd18ad..dece735a 100644 --- a/hyperstart/proxy/proxy.go +++ b/hyperstart/proxy/proxy.go @@ -128,7 +128,7 @@ func (proxy *jsonProxy) UpdateInterface(ctx context.Context, req *hyperstartgrpc addresses = append(addresses, hyperstartjson.IpAddress{addr.Address, addr.Mask}) } - err := proxy.json.UpdateInterface(req.Device, addresses) + err := proxy.json.UpdateInterface(libhyperstart.InfUpdateType(req.Type), req.Device, req.NewName, addresses, req.Mtu) return pbEmpty(err), err } func (proxy *jsonProxy) AddRoute(ctx context.Context, req *hyperstartgrpc.AddRouteRequest) (*google_protobuf.Empty, error) { diff --git a/hypervisor/context.go b/hypervisor/context.go index e720b12f..d49acf80 100644 --- a/hypervisor/context.go +++ b/hypervisor/context.go @@ -272,6 +272,24 @@ func (ctx *VmContext) RemoveInterface(id string, result chan api.Result) { ctx.networks.removeInterface(id, result) } +func (ctx *VmContext) UpdateInterface(inf *api.InterfaceDescription) error { + ctx.lock.Lock() + defer ctx.lock.Unlock() + + if ctx.current != StateRunning { + ctx.Log(DEBUG, "update interface %s during %v", inf.Name, ctx.current) + return fmt.Errorf("pod not running") + } + + return ctx.networks.updateInterface(inf) +} + +func (ctx *VmContext) AllInterfaces() []*InterfaceCreated { + ctx.lock.Lock() + defer ctx.lock.Unlock() + return ctx.networks.allInterfaces() +} + func (ctx *VmContext) validateContainer(c *api.ContainerDescription) error { for vn, vr := range c.Volumes { if _, ok := ctx.volumes[vn]; !ok { diff --git a/hypervisor/events.go b/hypervisor/events.go index 28890293..9430659d 100644 --- a/hypervisor/events.go +++ b/hypervisor/events.go @@ -57,6 +57,8 @@ type InterfaceCreated struct { DeviceName string MacAddr string IpAddr string + NewName string + Mtu uint64 RouteTable []*RouteRule } diff --git a/hypervisor/network.go b/hypervisor/network.go index cdae8357..190f366f 100644 --- a/hypervisor/network.go +++ b/hypervisor/network.go @@ -2,6 +2,7 @@ package hypervisor import ( "fmt" + "strings" "sync" "github.com/hyperhq/runv/api" @@ -81,18 +82,46 @@ func (nc *NetworkContext) freeSlot(slot int) { delete(nc.eth, slot) } +// nextAvailableDevName find the initial device name in guest when add a new tap device +// then rename it to some new name. +// For example: user want to insert a new nic named "eth5" into container, which already owns +// "eth0", "eth3" and "eth4". After tap device is added to VM, guest will detect a new device +// named "eth1" which is first available "ethX" device, then guest will try to rename "eth1" to +// "eth5". Then container will have "eth0", "eth3", "eth4" and "eth5" in the last. +// This function try to find the first available "ethX" as said above. @WeiZhang555 +func (nc *NetworkContext) nextAvailableDevName() string { + for i := 0; i <= MAX_NIC; i++ { + find := false + for _, inf := range nc.eth { + if inf != nil && inf.NewName == fmt.Sprintf("eth%d", i) { + find = true + break + } + } + if !find { + return fmt.Sprintf("eth%d", i) + } + } + + return "" +} + func (nc *NetworkContext) addInterface(inf *api.InterfaceDescription, result chan api.Result) { if inf.Lo { - if inf.Ip == "" { + if len(inf.Ip) == 0 { estr := fmt.Sprintf("creating an interface without an IP address: %#v", inf) nc.sandbox.Log(ERROR, estr) result <- NewSpecError(inf.Id, estr) return } + if inf.Id == "" { + inf.Id = "lo" + } i := &InterfaceCreated{ Id: inf.Id, DeviceName: DEFAULT_LO_DEVICE_NAME, IpAddr: inf.Ip, + Mtu: inf.Mtu, } nc.lo[inf.Ip] = i nc.idMap[inf.Id] = i @@ -111,14 +140,19 @@ func (nc *NetworkContext) addInterface(inf *api.InterfaceDescription, result cha defer nc.slotLock.Unlock() idx := nc.applySlot() - if idx < 0 { - estr := fmt.Sprintf("no available ethernet slot for interface %#v", inf) + initialDevName := nc.nextAvailableDevName() + if inf.Id == "" { + inf.Id = fmt.Sprintf("%d", idx) + } + if idx < 0 || initialDevName == "" { + estr := fmt.Sprintf("no available ethernet slot/name for interface %#v", inf) nc.sandbox.Log(ERROR, estr) result <- NewBusyError(inf.Id, estr) close(devChan) return } - nc.configureInterface(idx, nc.sandbox.NextPciAddr(), fmt.Sprintf("eth%d", idx), inf, devChan) + + nc.configureInterface(idx, nc.sandbox.NextPciAddr(), initialDevName, inf, devChan) }() go func() { @@ -201,6 +235,64 @@ func (nc *NetworkContext) removeInterface(id string, result chan api.Result) { } } +// allInterfaces return all the network interfaces except loop +func (nc *NetworkContext) allInterfaces() (nics []*InterfaceCreated) { + nc.slotLock.Lock() + defer nc.slotLock.Unlock() + + for _, v := range nc.eth { + if v != nil { + nics = append(nics, v) + } + } + return +} + +func (nc *NetworkContext) updateInterface(inf *api.InterfaceDescription) error { + oldInf, ok := nc.idMap[inf.Id] + if !ok { + nc.sandbox.Log(WARNING, "trying update a non-exist interface %s", inf.Id) + return fmt.Errorf("interface %q not exists", inf.Id) + } + + // only support update some fields: Name, ip addresses, mtu + nc.slotLock.Lock() + defer nc.slotLock.Unlock() + + if inf.Name != "" { + oldInf.NewName = inf.Name + } + + if inf.Mtu > 0 { + oldInf.Mtu = inf.Mtu + } + + if len(inf.Ip) > 0 { + addrs := strings.Split(inf.Ip, ",") + oldAddrs := strings.Split(oldInf.IpAddr, ",") + for _, ip := range addrs { + var found bool + if ip[0] == '-' { // to delete + ip = ip[1:] + for k, i := range oldAddrs { + if i == ip { + oldAddrs = append(oldAddrs[:k], oldAddrs[k+1:]...) + found = true + break + } + } + if !found { + return fmt.Errorf("failed to delete %q: not found", ip) + } + } else { // to add + oldAddrs = append(oldAddrs, ip) + } + } + oldInf.IpAddr = strings.Join(oldAddrs, ",") + } + return nil +} + func (nc *NetworkContext) netdevInsertFailed(idx int, name string) { nc.slotLock.Lock() defer nc.slotLock.Unlock() @@ -222,12 +314,12 @@ func (nc *NetworkContext) configureInterface(index, pciAddr int, name string, in settings, err := network.Configure(inf) if err != nil { nc.sandbox.Log(ERROR, "interface creating failed: %v", err.Error()) - session := &InterfaceCreated{Id: inf.Id, Index: index, PCIAddr: pciAddr, DeviceName: name} + session := &InterfaceCreated{Id: inf.Id, Index: index, PCIAddr: pciAddr, DeviceName: name, NewName: inf.Name, Mtu: inf.Mtu} result <- &DeviceFailed{Session: session} return } - created, err := interfaceGot(inf.Id, index, pciAddr, name, settings) + created, err := interfaceGot(inf.Id, index, pciAddr, name, inf.Name, settings) if err != nil { result <- &DeviceFailed{Session: created} return @@ -241,8 +333,12 @@ func (nc *NetworkContext) configureInterface(index, pciAddr int, name string, in Gateway: created.Bridge, Options: inf.Options, } + + // Note: Use created.NewName add tap name + // this is because created.DeviceName isn't always uniq, + // instead NewName is real nic name in VM which is certainly uniq g := &GuestNicInfo{ - Device: created.DeviceName, + Device: created.NewName, Ipaddr: created.IpAddr, Index: created.Index, Busaddr: created.PCIAddr, @@ -268,13 +364,16 @@ func (nc *NetworkContext) getInterface(id string) *InterfaceCreated { return nil } -func (nc *NetworkContext) getIpAddrs() []string { +func (nc *NetworkContext) getIPAddrs() []string { nc.slotLock.RLock() defer nc.slotLock.RUnlock() res := []string{} for _, inf := range nc.eth { - res = append(res, inf.IpAddr) + if inf.IpAddr != "" { + addrs := strings.Split(inf.IpAddr, ",") + res = append(res, addrs...) + } } return res @@ -310,7 +409,7 @@ func (nc *NetworkContext) close() { nc.idMap = map[string]*InterfaceCreated{} } -func interfaceGot(id string, index int, pciAddr int, name string, inf *network.Settings) (*InterfaceCreated, error) { +func interfaceGot(id string, index int, pciAddr int, deviceName, newName string, inf *network.Settings) (*InterfaceCreated, error) { rt := []*RouteRule{} /* Route rule is generated automaticly on first interface, * or generated on the gateway configured interface. */ @@ -321,15 +420,18 @@ func interfaceGot(id string, index int, pciAddr int, name string, inf *network.S }) } - return &InterfaceCreated{ + infc := &InterfaceCreated{ Id: id, Index: index, PCIAddr: pciAddr, Bridge: inf.Bridge, HostDevice: inf.Device, - DeviceName: name, + DeviceName: deviceName, + NewName: newName, MacAddr: inf.Mac, IpAddr: inf.IPAddress, + Mtu: inf.Mtu, RouteTable: rt, - }, nil + } + return infc, nil } diff --git a/hypervisor/network/network.go b/hypervisor/network/network.go index e5e06729..c76f8299 100644 --- a/hypervisor/network/network.go +++ b/hypervisor/network/network.go @@ -13,6 +13,7 @@ type Settings struct { Gateway string Bridge string Device string + Mtu uint64 Automatic bool } @@ -29,6 +30,13 @@ var ( ) func NicName(id string, index int) string { + // make sure nic name has less than 15 chars + // hold 3 chars for index. + // TODO: index could be larger than 3 chars, make it more robust + if len(id) > 12 { + id = string([]rune(id)[:12]) + } + return fmt.Sprintf("%s%d", id, index) } diff --git a/hypervisor/network/network_linux.go b/hypervisor/network/network_linux.go index 66123caa..49034e9e 100644 --- a/hypervisor/network/network_linux.go +++ b/hypervisor/network/network_linux.go @@ -201,14 +201,16 @@ func UpAndAddToBridge(name, bridge, options string) error { if bridge == "" { bridge = BridgeIface } - master, err := netlink.LinkByName(bridge) - if err != nil { - glog.Error("cannot find bridge interface ", bridge) - return err - } - if err = addToBridge(iface, master, options); err != nil { - glog.Errorf("cannot add %s to %s ", name, bridge) - return err + if bridge != "" { + master, err := netlink.LinkByName(bridge) + if err != nil { + glog.Error("cannot find bridge interface ", bridge) + return err + } + if err = addToBridge(iface, master, options); err != nil { + glog.Errorf("cannot add %s to %s ", name, bridge) + return err + } } if err = netlink.LinkSetUp(iface); err != nil { glog.Error("cannot up interface ", name) @@ -258,6 +260,7 @@ func Configure(inf *api.InterfaceDescription) (*Settings, error) { Gateway: inf.Gw, Bridge: inf.Bridge, Device: inf.TapName, + Mtu: inf.Mtu, Automatic: false, }, nil } diff --git a/hypervisor/persistence.go b/hypervisor/persistence.go index b8f0c28a..e9fa9a81 100644 --- a/hypervisor/persistence.go +++ b/hypervisor/persistence.go @@ -38,8 +38,12 @@ type PersistNetworkInfo struct { Id string Index int PciAddr int + HostDevice string DeviceName string + NewName string IpAddr string + Mac string + Mtu uint64 } type PersistInfo struct { @@ -108,6 +112,7 @@ func (ctx *VmContext) dump() (*PersistInfo, error) { Id: nic.Id, Index: nic.Index, PciAddr: nic.PCIAddr, + HostDevice: nic.HostDevice, DeviceName: nic.DeviceName, IpAddr: nic.IpAddr, } @@ -119,8 +124,12 @@ func (ctx *VmContext) dump() (*PersistInfo, error) { Id: nic.Id, Index: nic.Index, PciAddr: nic.PCIAddr, + HostDevice: nic.HostDevice, DeviceName: nic.DeviceName, + NewName: nic.NewName, IpAddr: nic.IpAddr, + Mac: nic.MacAddr, + Mtu: nic.Mtu, } nid++ } @@ -206,8 +215,12 @@ func (nc *NetworkContext) load(pinfo *PersistInfo) { Id: pi.Id, Index: pi.Index, PCIAddr: pi.PciAddr, + HostDevice: pi.HostDevice, DeviceName: pi.DeviceName, + NewName: pi.NewName, IpAddr: pi.IpAddr, + Mtu: pi.Mtu, + MacAddr: pi.Mac, } // if empty, may be old data, generate one for compatibility. if ifc.Id == "" { @@ -225,6 +238,7 @@ func (nc *NetworkContext) load(pinfo *PersistInfo) { func vmDeserialize(s []byte) (*PersistInfo, error) { info := &PersistInfo{} + // TODO: REMOVE THIS err := json.Unmarshal(s, info) return info, err } diff --git a/hypervisor/qemu/qemu.go b/hypervisor/qemu/qemu.go index ebccd4be..74deaa5e 100644 --- a/hypervisor/qemu/qemu.go +++ b/hypervisor/qemu/qemu.go @@ -290,11 +290,11 @@ func (qc *QemuContext) AddNic(ctx *hypervisor.VmContext, host *hypervisor.HostNi result <- ev } }() - newNetworkAddSession(ctx, qc, host.Id, fd, guest.Device, host.Mac, guest.Index, guest.Busaddr, waitChan) + newNetworkAddSession(ctx, qc, host.Id, host.Device, fd, guest.Device, host.Mac, guest.Index, guest.Busaddr, waitChan) } func (qc *QemuContext) RemoveNic(ctx *hypervisor.VmContext, n *hypervisor.InterfaceCreated, callback hypervisor.VmEvent, result chan<- hypervisor.VmEvent) { - newNetworkDelSession(ctx, qc, n.DeviceName, callback, result) + newNetworkDelSession(ctx, qc, n.NewName, callback, result) } func (qc *QemuContext) SetCpus(ctx *hypervisor.VmContext, cpus int) error { diff --git a/hypervisor/qemu/qmp_wrapper_amd64.go b/hypervisor/qemu/qmp_wrapper_amd64.go index 01b9eec7..59223a9b 100644 --- a/hypervisor/qemu/qmp_wrapper_amd64.go +++ b/hypervisor/qemu/qmp_wrapper_amd64.go @@ -10,12 +10,12 @@ import ( "github.com/hyperhq/runv/hypervisor" ) -func newNetworkAddSession(ctx *hypervisor.VmContext, qc *QemuContext, id string, fd int, device, mac string, index, addr int, result chan<- hypervisor.VmEvent) { +func newNetworkAddSession(ctx *hypervisor.VmContext, qc *QemuContext, id, tapname string, fd int, device, mac string, index, addr int, result chan<- hypervisor.VmEvent) { busAddr := fmt.Sprintf("0x%x", addr) - commands := make([]*QmpCommand, 3) + commands := []*QmpCommand{} if ctx.Boot.EnableVhostUser { chardevId := device + "-chardev" - commands[0] = &QmpCommand{ + commands = append(commands, &QmpCommand{ Execute: "chardev-add", Arguments: map[string]interface{}{ "id": chardevId, @@ -33,8 +33,7 @@ func newNetworkAddSession(ctx *hypervisor.VmContext, qc *QemuContext, id string, }, }, }, - } - commands[1] = &QmpCommand{ + }, &QmpCommand{ Execute: "netdev_add", Arguments: map[string]interface{}{ "type": "vhost-user", @@ -42,26 +41,31 @@ func newNetworkAddSession(ctx *hypervisor.VmContext, qc *QemuContext, id string, "chardev": chardevId, "vhostforce": true, }, - } - } else { + }) + } else if fd > 0 { scm := syscall.UnixRights(fd) glog.V(1).Infof("send net to qemu at %d", fd) - commands[0] = &QmpCommand{ + commands = append(commands, &QmpCommand{ Execute: "getfd", Arguments: map[string]interface{}{ "fdname": "fd" + device, }, Scm: scm, - } - commands[1] = &QmpCommand{ + }, &QmpCommand{ Execute: "netdev_add", Arguments: map[string]interface{}{ "type": "tap", "id": device, "fd": "fd" + device, }, - } + }) + } else if tapname != "" { + commands = append(commands, &QmpCommand{ + Execute: "netdev_add", + Arguments: map[string]interface{}{ + "type": "tap", "id": device, "ifname": tapname, "script": "no", + }, + }) } - - commands[2] = &QmpCommand{ + commands = append(commands, &QmpCommand{ Execute: "device_add", Arguments: map[string]interface{}{ "driver": "virtio-net-pci", @@ -71,7 +75,7 @@ func newNetworkAddSession(ctx *hypervisor.VmContext, qc *QemuContext, id string, "addr": busAddr, "id": device, }, - } + }) qc.qmp <- &QmpSession{ commands: commands, diff --git a/hypervisor/vm.go b/hypervisor/vm.go index b5602a15..eb09d91f 100644 --- a/hypervisor/vm.go +++ b/hypervisor/vm.go @@ -316,10 +316,17 @@ func (vm *Vm) AddNic(info *api.InterfaceDescription) error { if vm.ctx.LogLevel(TRACE) { vm.Log(TRACE, "finial vmSpec.Interface is %#v", vm.ctx.networks.getInterface(info.Id)) } - return vm.ctx.updateInterface(info.Id) + return vm.ctx.hyperstartAddInterface(info.Id) +} + +func (vm *Vm) AllNics() []*InterfaceCreated { + return vm.ctx.AllInterfaces() } func (vm *Vm) DeleteNic(id string) error { + if err := vm.ctx.hyperstartDeleteInterface(id); err != nil { + return err + } client := make(chan api.Result, 1) vm.ctx.RemoveInterface(id, client) @@ -331,9 +338,17 @@ func (vm *Vm) DeleteNic(id string) error { if !ev.IsSuccess() { return fmt.Errorf("remove device failed") } + return nil } +func (vm *Vm) UpdateNic(inf *api.InterfaceDescription) error { + if err := vm.ctx.hyperstartUpdateInterface(inf.Id, inf.Ip, inf.Mtu); err != nil { + return err + } + return vm.ctx.UpdateInterface(inf) +} + func (vm *Vm) SetCpus(cpus int) error { if vm.Cpu >= cpus { return nil @@ -713,7 +728,7 @@ func (vm *Vm) GetIPAddrs() []string { return ips } - res := vm.ctx.networks.getIpAddrs() + res := vm.ctx.networks.getIPAddrs() ips = append(ips, res...) return ips diff --git a/hypervisor/vm_states.go b/hypervisor/vm_states.go index 575ac1ed..b495562b 100644 --- a/hypervisor/vm_states.go +++ b/hypervisor/vm_states.go @@ -112,7 +112,7 @@ func (ctx *VmContext) restoreContainer(id string) (alive bool, err error) { return true, nil } -func (ctx *VmContext) updateInterface(id string) error { +func (ctx *VmContext) hyperstartAddInterface(id string) error { if inf := ctx.networks.getInterface(id); inf == nil { return fmt.Errorf("can't find interface whose ID is %s", id) } else { @@ -123,10 +123,12 @@ func (ctx *VmContext) updateInterface(id string) error { if err != nil { return err } - size, _ := mask.Size() - addrs = append(addrs, hyperstartapi.IpAddress{ip.String(), fmt.Sprintf("%d", size)}) + // size, _ := mask.Size() + // addrs = append(addrs, hyperstartapi.IpAddress{ip.String(), fmt.Sprintf("%d", size)}) + maskStr := fmt.Sprintf("%d.%d.%d.%d", mask[0], mask[1], mask[2], mask[3]) + addrs = append(addrs, hyperstartapi.IpAddress{ip.String(), maskStr}) } - if err := ctx.hyperstart.UpdateInterface(inf.DeviceName, addrs); err != nil { + if err := ctx.hyperstart.UpdateInterface(libhyperstart.AddInf, inf.DeviceName, inf.NewName, addrs, inf.Mtu); err != nil { return err } @@ -134,6 +136,71 @@ func (ctx *VmContext) updateInterface(id string) error { return nil } +func (ctx *VmContext) hyperstartDeleteInterface(id string) error { + if inf := ctx.networks.getInterface(id); inf == nil { + return fmt.Errorf("can't find interface whose ID is %s", id) + } else { + // using new name as device name + return ctx.hyperstart.UpdateInterface(libhyperstart.DelInf, inf.NewName, "", nil, 0) + } +} + +func (ctx *VmContext) hyperstartUpdateInterface(id string, addresses string, mtu uint64) error { + var ( + addIP, delIP []hyperstartapi.IpAddress + ) + inf := ctx.networks.getInterface(id) + if inf == nil { + return fmt.Errorf("can't find interface whose ID is %s", id) + } + + if addresses != "" { + addrs := strings.Split(addresses, ",") + // TODO: currently if an IP address start with a '-', + // we treat it as deleting an IP which is not very elegant. + // Try to add one new field and function to handle this! @weizhang555 + for _, addr := range addrs { + var del bool + if addr[0] == '-' { + del = true + addr = addr[1:] + } + ip, mask, err := network.IpParser(addr) + if err != nil { + return err + } + // size, _ := mask.Size() + // addrs = append(addrs, hyperstartapi.IpAddress{ip.String(), fmt.Sprintf("%d", size)}) + maskStr := fmt.Sprintf("%d.%d.%d.%d", mask[0], mask[1], mask[2], mask[3]) + + if del { + delIP = append(delIP, hyperstartapi.IpAddress{ip.String(), maskStr}) + } else { + addIP = append(addIP, hyperstartapi.IpAddress{ip.String(), maskStr}) + } + } + } + + if len(addIP) != 0 { + if err := ctx.hyperstart.UpdateInterface(libhyperstart.AddIP, inf.NewName, "", addIP, 0); err != nil { + return err + } + } + + if len(delIP) != 0 { + if err := ctx.hyperstart.UpdateInterface(libhyperstart.DelIP, inf.NewName, "", delIP, 0); err != nil { + return err + } + } + + if mtu > 0 { + if err := ctx.hyperstart.UpdateInterface(libhyperstart.SetMtu, inf.NewName, "", nil, mtu); err != nil { + return err + } + } + return nil +} + // TODO remove attachCmd and move streamCopy to hyperd func (ctx *VmContext) attachCmd(cmd *AttachCommand) error { ctx.lock.Lock() diff --git a/hypervisor/xen/xen.go b/hypervisor/xen/xen.go index 958ac0d2..a39c6081 100644 --- a/hypervisor/xen/xen.go +++ b/hypervisor/xen/xen.go @@ -249,7 +249,7 @@ func (xc *XenContext) AddNic(ctx *hypervisor.VmContext, host *hypervisor.HostNic glog.V(1).Infof("add network for %d - ip: %s, br: %s, gw: %s, dev: %s, hw: %s", xc.domId, guest.Ipaddr, host.Bridge, host.Bridge, dev, hw.String()) - res := HyperxlNicAdd(xc.driver.Ctx, (uint32)(xc.domId), guest.Ipaddr, host.Bridge, host.Bridge, dev, []byte(hw)) + res := HyperxlNicAdd(xc.driver.Ctx, (uint32)(xc.domId), guest.Ipaddr[0], host.Bridge, host.Bridge, dev, []byte(hw)) if res == 0 { glog.V(1).Infof("nic %s insert succeeded", guest.Device)