Skip to content

Commit

Permalink
rename machine package to firecracker
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelkarp committed Nov 15, 2018
1 parent f453f1f commit 1ba5c44
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
38 changes: 19 additions & 19 deletions cmd/firectl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strconv"
"strings"

"github.com/awslabs/go-firecracker"
firecracker "github.com/awslabs/go-firecracker"
flags "github.com/jessevdk/go-flags"
log "github.com/sirupsen/logrus"
)
Expand All @@ -31,7 +31,7 @@ func validateDriveEntry(entry string) error {
return nil
}

func checkConfig(cfg machine.Config) error {
func checkConfig(cfg firecracker.Config) error {
var err error

// Check for the existence of some required files:
Expand All @@ -57,8 +57,8 @@ func checkConfig(cfg machine.Config) error {
return nil
}

func parseBlockDevices(entries []string) ([]machine.BlockDevice, error) {
var devices []machine.BlockDevice
func parseBlockDevices(entries []string) ([]firecracker.BlockDevice, error) {
var devices []firecracker.BlockDevice
for _, entry := range entries {
var path string
if strings.HasSuffix(entry, ":rw") {
Expand All @@ -67,7 +67,7 @@ func parseBlockDevices(entries []string) ([]machine.BlockDevice, error) {
path = strings.TrimSuffix(entry, ":ro")
} else {
msg := fmt.Sprintf("Invalid drive specification. Must have :rw or :ro suffix")
return []machine.BlockDevice{}, errors.New(msg)
return []firecracker.BlockDevice{}, errors.New(msg)
}
if path == "" {
return nil, errors.New("Invalid drive specification")
Expand All @@ -76,7 +76,7 @@ func parseBlockDevices(entries []string) ([]machine.BlockDevice, error) {
if err != nil {
return nil, err
}
e := machine.BlockDevice{
e := firecracker.BlockDevice{
HostPath: path,
Mode: "rw",
}
Expand All @@ -99,18 +99,18 @@ func parseNicConfig(cfg string) (string, string, error) {

// Given a list of string representations of vsock devices,
// return a corresponding slice of machine.VsockDevice objects
func parseVsocks(devices []string) ([]machine.VsockDevice, error) {
var result []machine.VsockDevice
func parseVsocks(devices []string) ([]firecracker.VsockDevice, error) {
var result []firecracker.VsockDevice
for _, entry := range devices {
fields := strings.Split(entry, ":")
if len(fields) != 2 {
return []machine.VsockDevice{}, errors.New("Could not parse")
return []firecracker.VsockDevice{}, errors.New("Could not parse")
}
CID, err := strconv.ParseUint(fields[1], 10, 32)
if err != nil {
return []machine.VsockDevice{}, errors.New("Vsock CID could not be parsed as a number")
return []firecracker.VsockDevice{}, errors.New("Vsock CID could not be parsed as a number")
}
dev := machine.VsockDevice{
dev := firecracker.VsockDevice{
Path: fields[0],
CID: uint32(CID),
}
Expand Down Expand Up @@ -162,24 +162,24 @@ func main() {
logger.SetLevel(log.DebugLevel)
}

var NICs []machine.NetworkInterface
var NICs []firecracker.NetworkInterface

if len(opts.FcNicConfig) > 0 {
tapDev, tapMacAddr, err := parseNicConfig(opts.FcNicConfig)
if err != nil {
log.Fatalf("Unable to parse NIC config: %s", err)
} else {
log.Printf("Adding tap device %s", tapDev)
NICs = []machine.NetworkInterface{
machine.NetworkInterface{
NICs = []firecracker.NetworkInterface{
firecracker.NetworkInterface{
MacAddress: tapMacAddr,
HostDevName: tapDev,
},
}
}
}

rootDrive := machine.BlockDevice{HostPath: opts.FcRootDrivePath, Mode: "rw"}
rootDrive := firecracker.BlockDevice{HostPath: opts.FcRootDrivePath, Mode: "rw"}

blockDevices, err := parseBlockDevices(opts.FcAdditionalDrives)
if err != nil {
Expand All @@ -191,7 +191,7 @@ func main() {
log.Fatalf("Invalid vsock specification: %s", err)
}

fcCfg := machine.Config{
fcCfg := firecracker.Config{
BinPath: opts.FcBinary,
SocketPath: "./firecracker.sock",
LogFifo: opts.FcLogFifo,
Expand All @@ -206,7 +206,7 @@ func main() {
VsockDevices: vsocks,
Console: opts.FcConsole,
CPUCount: opts.FcCPUCount,
CPUTemplate: machine.CPUTemplate(opts.FcCPUTemplate),
CPUTemplate: firecracker.CPUTemplate(opts.FcCPUTemplate),
HtEnabled: !opts.FcDisableHt,
MemInMiB: opts.FcMemSz,
}
Expand All @@ -216,8 +216,8 @@ func main() {
log.Fatalf("Configuration error: %s", err)
}

fireracker := machine.NewFirecrackerClient(fcCfg.SocketPath)
m := machine.NewMachine(fcCfg, fireracker, logger)
fireracker := firecracker.NewFirecrackerClient(fcCfg.SocketPath)
m := firecracker.NewMachine(fcCfg, fireracker, logger)

ctx := context.Background()
vmmCtx, vmmCancel := context.WithCancel(ctx)
Expand Down
2 changes: 1 addition & 1 deletion firecracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.

package machine
package firecracker

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.

package machine
package firecracker

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.

package machine
package firecracker

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
//go:generate docker run --rm -v $PWD:/work -w /work quay.io/goswagger/swagger generate model -f ./client/swagger.yaml --model-package=client/models --client-package=client --copyright-file=COPYRIGHT_HEADER
//go:generate docker run --rm -v $PWD:/work -w /work quay.io/goswagger/swagger generate client -f ./client/swagger.yaml --model-package=client/models --client-package=client --copyright-file=COPYRIGHT_HEADER

package machine
package firecracker

0 comments on commit 1ba5c44

Please sign in to comment.