Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 86 additions & 77 deletions api/descriptions.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions api/descriptions.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ syntax = "proto3";

package api;

// To generate description.pb.go, run:
// $ protoc --go_out=. descriptions.proto

message SandboxConfig {
string hostname = 1;
repeated string dns = 2;
Expand Down Expand Up @@ -54,11 +57,12 @@ message InterfaceDescription {
string id = 1;
bool lo = 2;
string bridge = 3;
string ip = 4;
repeated string ip = 4;
string mac = 5;
string gw = 6;
string tapName = 7;
string options = 8;
uint64 mtu = 6;
string gw = 7;
string tapName = 8;
string options = 9;
}

message PortDescription {
Expand Down
1 change: 1 addition & 0 deletions hyperstart/api/json/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
INIT_REMOVECONTAINER
INIT_PROCESSASYNCEVENT
INIT_SIGNALPROCESS
INIT_DELETEINTERFACE // 25
)

// "hyperstart" is the special container ID for adding processes.
Expand Down
1 change: 1 addition & 0 deletions hyperstart/api/json/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type NetworkInf struct {
Device string `json:"device"`
IpAddress string `json:"ipAddress"`
NetMask string `json:"netMask"`
Mtu uint64 `json:"mtu"`
}

type Route struct {
Expand Down
3 changes: 2 additions & 1 deletion hyperstart/libhyperstart/hyperstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Hyperstart interface {
WriteFile(container, path string, data []byte) error
ReadFile(container, path string) ([]byte, error)
AddRoute(r []hyperstartapi.Route) error
UpdateInterface(dev, ip, mask string) error
AddInterface(inf *hyperstartapi.NetworkInf) error
DeleteInterface(inf *hyperstartapi.NetworkInf) error
OnlineCpuMem() error
}
12 changes: 6 additions & 6 deletions hyperstart/libhyperstart/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,12 +646,12 @@ func (h *jsonBasedHyperstart) AddRoute(r []hyperstartapi.Route) error {
return h.hyperstartCommand(hyperstartapi.INIT_SETUPROUTE, hyperstartapi.Routes{Routes: r})
}

func (h *jsonBasedHyperstart) UpdateInterface(dev, ip, mask string) error {
return h.hyperstartCommand(hyperstartapi.INIT_SETUPINTERFACE, hyperstartapi.NetworkInf{
Device: dev,
IpAddress: ip,
NetMask: mask,
})
func (h *jsonBasedHyperstart) AddInterface(inf *hyperstartapi.NetworkInf) error {
return h.hyperstartCommand(hyperstartapi.INIT_SETUPINTERFACE, inf)
}

func (h *jsonBasedHyperstart) DeleteInterface(inf *hyperstartapi.NetworkInf) error {
return h.hyperstartCommand(hyperstartapi.INIT_DELETEINTERFACE, inf)
}

func (h *jsonBasedHyperstart) TtyWinResize4242(container, process string, row, col uint16) error {
Expand Down
21 changes: 21 additions & 0 deletions hypervisor/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,27 @@ func (ctx *VmContext) RemoveInterface(id string, result chan api.Result) {
ctx.networks.removeInterface(id, result)
}

func (ctx *VmContext) AddIPAddr(id, ip string) error {
ctx.lock.Lock()
defer ctx.lock.Unlock()

return ctx.networks.AddIPAddr(id, ip)
}

func (ctx *VmContext) DeleteIPAddr(id, ip string) error {
ctx.lock.Lock()
defer ctx.lock.Unlock()

return ctx.networks.DeleteIPAddr(id, ip)
}

func (ctx *VmContext) UpdateMtu(id string, mtu uint64) error {
ctx.lock.Lock()
defer ctx.lock.Unlock()

return ctx.networks.UpdateMtu(id, mtu)
}

func (ctx *VmContext) validateContainer(c *api.ContainerDescription) error {
for vn, vr := range c.Volumes {
if _, ok := ctx.volumes[vn]; !ok {
Expand Down
1 change: 1 addition & 0 deletions hypervisor/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type GuestNicInfo struct {
Ipaddr string
Index int
Busaddr int
Mtu uint64
}

type HypervisorDriver interface {
Expand Down
7 changes: 5 additions & 2 deletions hypervisor/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package hypervisor

import (
"os"

"github.com/hyperhq/runv/api"
)

type VmEvent interface {
Expand Down Expand Up @@ -56,14 +58,15 @@ type InterfaceCreated struct {
Id string //user specified in (ref api.InterfaceDescription: a user identifier of interface, user may use this to specify a nic, normally you can use IPAddr as an Id, however, in some driver (probably vbox?), user may not specify the IPAddr.)
Index int
PCIAddr int
Mtu uint64
Fd *os.File
Bridge string
HostDevice string
DeviceName string
MacAddr string
IpAddr string
NetMask string
IpAddr []string
RouteTable []*RouteRule
Desc *api.InterfaceDescription
}

type RouteRule struct {
Expand Down
Loading