-
-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build: add vmnet script * chore: minor refactors and fixes * net: begin ptp network * net: embed vmnet * chore: remove obsolete dry-run command * net: vmnet support checkpoint * net: vmnet works * net: add ip address to colima list * net: make network instance dynamic * net: fix embedded archives * net: ptp network works * net: route fixed, general refactor * misc: minor refactor * cli: enable force stop * cli: add json to colima list * k8s: bind to VM ip address * fix lint
- Loading branch information
Showing
30 changed files
with
856 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.idea/ | ||
.vscode/ | ||
_output/ | ||
_build/ | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
_ "github.com/abiosoft/colima/cmd" // for other commands | ||
"os" | ||
"path/filepath" | ||
|
||
_ "github.com/abiosoft/colima/cmd" // for other commands | ||
_ "github.com/abiosoft/colima/embedded" // for embedded assets | ||
|
||
"github.com/abiosoft/colima/cmd/root" | ||
"github.com/abiosoft/colima/cmd/vmnet" | ||
) | ||
|
||
func main() { | ||
root.Execute() | ||
_, cmd := filepath.Split(os.Args[0]) | ||
switch cmd { | ||
case "colima-vmnet": | ||
vmnet.Execute() | ||
default: | ||
root.Execute() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package vmnet | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
|
||
"github.com/abiosoft/colima/cli" | ||
"github.com/abiosoft/colima/config" | ||
"github.com/abiosoft/colima/environment/vm/lima/network" | ||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// Execute adds all child commands to the root command and sets flags appropriately. | ||
// This is called by main.main(). It only needs to happen once to the rootCmd. | ||
func Execute() { | ||
if err := vmnetCmd.Execute(); err != nil { | ||
logrus.Fatal(err) | ||
} | ||
} | ||
|
||
// vmnetCmd represents the base command when called without any subcommands | ||
var vmnetCmd = &cobra.Command{ | ||
Use: "vmnet", | ||
Short: "vde_vmnet runner", | ||
Long: `vde_vmnet runner for vde_vmnet daemons.`, | ||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
cmd.SilenceUsage = true | ||
cmd.SilenceErrors = true | ||
}, | ||
} | ||
|
||
// startCmd represents the kubernetes start command | ||
var startCmd = &cobra.Command{ | ||
Use: "start", | ||
Short: "start daemon", | ||
Long: `start the daemon`, | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
config.SetProfile(args[0]) | ||
|
||
ptp, err := network.PTPFile() | ||
if err != nil { | ||
logrus.Warnln("ptp file error: %w", err) // this should never happen | ||
} | ||
pid := strings.TrimSuffix(ptp, ".ptp") + ".pid" | ||
|
||
// delete existing sockets if exist | ||
// errors ignored on purpose | ||
_ = forceDeleteFileIfExists(ptp) | ||
_ = forceDeleteFileIfExists(ptp + "+") // created by running qemu instance | ||
|
||
command := cli.CommandInteractive(network.VmnetBinary, | ||
"--vmnet-mode", "shared", | ||
"--vmnet-gateway", "192.168.106.1", | ||
"--vmnet-dhcp-end", "192.168.106.254", | ||
"--pidfile", pid, | ||
ptp+"[]", | ||
) | ||
|
||
return command.Run() | ||
}, | ||
} | ||
|
||
func forceDeleteFileIfExists(name string) error { | ||
if stat, err := os.Stat(name); err == nil && !stat.IsDir() { | ||
return os.Remove(name) | ||
} | ||
return nil | ||
} | ||
|
||
func init() { | ||
vmnetCmd.AddCommand(startCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.