Skip to content

Commit fcff615

Browse files
committed
set App virtulization mode via PodConfig
Signed-off-by: Shahriyar Jalayeri <[email protected]>
1 parent f81d991 commit fcff615

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

cmd/edenPod.go

+15
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/lf-edge/eden/pkg/defaults"
77
"github.com/lf-edge/eden/pkg/openevec"
88
edgeRegistry "github.com/lf-edge/edge-containers/pkg/registry"
9+
"github.com/lf-edge/eve-api/go/config"
910
log "github.com/sirupsen/logrus"
1011
"github.com/spf13/cobra"
1112
"github.com/thediveo/enumflag"
@@ -76,6 +77,13 @@ func newPodPublishCmd() *cobra.Command {
7677

7778
func newPodDeployCmd(cfg *openevec.EdenSetupArgs) *cobra.Command {
7879
var pc openevec.PodConfig
80+
var virtMode string
81+
switch cfg.Eve.Arch {
82+
case "amd64":
83+
virtMode = "HVM"
84+
case "arm64":
85+
virtMode = "PV"
86+
}
7987

8088
var podDeployCmd = &cobra.Command{
8189
Use: "deploy (docker|http(s)|file|directory)://(<TAG|PATH>[:<VERSION>] | <URL for qcow2 image> | <path to qcow2 image>)",
@@ -88,6 +96,12 @@ func newPodDeployCmd(cfg *openevec.EdenSetupArgs) *cobra.Command {
8896
log.Fatal(err)
8997
}
9098
},
99+
PreRun: func(cmd *cobra.Command, args []string) {
100+
if _, ok := config.VmMode_value[virtMode]; !ok {
101+
log.Fatalf("Unknown virt-mode: %s", virtMode)
102+
}
103+
pc.VirtMode = config.VmMode(config.VmMode_value[virtMode])
104+
},
91105
}
92106

93107
podDeployCmd.Flags().StringVar(&pc.AppMemory, "memory", humanize.Bytes(defaults.DefaultAppMem*1024), "memory for app")
@@ -122,6 +136,7 @@ You can set access VLAN ID (VID) for a particular network in the format '<networ
122136
podDeployCmd.Flags().StringVar(&pc.DatastoreOverride, "datastoreOverride", "", "Override datastore path for disks (when we use different URL for Eden and EVE or for local datastore)")
123137
podDeployCmd.Flags().Uint32Var(&pc.StartDelay, "start-delay", 0, "The amount of time (in seconds) that EVE waits (after boot finish) before starting application")
124138
podDeployCmd.Flags().BoolVar(&pc.PinCpus, "pin-cpus", false, "Pin the CPUs used by the pod")
139+
podDeployCmd.Flags().StringVar(&virtMode, "virt-mode", virtMode, "Virtualization mode for the pod (PV, HVM, Filter, FML, NOHYPER, LEGACY)")
125140

126141
return podDeployCmd
127142
}

pkg/openevec/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/lf-edge/eden/pkg/defaults"
1212
"github.com/lf-edge/eden/pkg/utils"
13+
"github.com/lf-edge/eve-api/go/config"
1314
log "github.com/sirupsen/logrus"
1415
"github.com/spf13/pflag"
1516
"github.com/spf13/viper"
@@ -210,6 +211,7 @@ type PodConfig struct {
210211
OpenStackMetadata bool
211212
DatastoreOverride string
212213
ACLOnlyHost bool
214+
VirtMode config.VmMode
213215
}
214216

215217
func Merge(dst, src reflect.Value, flags *pflag.FlagSet) {

pkg/openevec/pod.go

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (openEVEC *OpenEVEC) PodDeploy(appLink string, pc PodConfig, cfg *EdenSetup
7777
opts = append(opts, expect.WithVnc(pc.VncDisplay))
7878
opts = append(opts, expect.WithVncPassword(pc.VncPassword))
7979
opts = append(opts, expect.WithAppAdapters(pc.AppAdapters))
80+
opts = append(opts, expect.WithVirtualizationMode(pc.VirtMode))
8081
if len(pc.Networks) > 0 {
8182
for i, el := range pc.Networks {
8283
if i == 0 {

0 commit comments

Comments
 (0)