Skip to content

Commit a673b3a

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

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

cmd/edenPod.go

+22
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package cmd
22

33
import (
4+
"strings"
5+
46
"github.com/dustin/go-humanize"
57
"github.com/lf-edge/eden/pkg/controller/types"
68
"github.com/lf-edge/eden/pkg/defaults"
79
"github.com/lf-edge/eden/pkg/openevec"
810
edgeRegistry "github.com/lf-edge/edge-containers/pkg/registry"
11+
"github.com/lf-edge/eve-api/go/config"
912
log "github.com/sirupsen/logrus"
1013
"github.com/spf13/cobra"
1114
"github.com/thediveo/enumflag"
@@ -76,6 +79,13 @@ func newPodPublishCmd() *cobra.Command {
7679

7780
func newPodDeployCmd(cfg *openevec.EdenSetupArgs) *cobra.Command {
7881
var pc openevec.PodConfig
82+
var virtMode string
83+
switch cfg.Eve.Arch {
84+
case "amd64":
85+
virtMode = "HVM"
86+
case "arm64":
87+
virtMode = "PV"
88+
}
7989

8090
var podDeployCmd = &cobra.Command{
8191
Use: "deploy (docker|http(s)|file|directory)://(<TAG|PATH>[:<VERSION>] | <URL for qcow2 image> | <path to qcow2 image>)",
@@ -88,6 +98,17 @@ func newPodDeployCmd(cfg *openevec.EdenSetupArgs) *cobra.Command {
8898
log.Fatal(err)
8999
}
90100
},
101+
PreRun: func(cmd *cobra.Command, args []string) {
102+
virtMode = strings.ToUpper(virtMode)
103+
// XXX : fix this in EVE API
104+
if virtMode == "FILLER" {
105+
virtMode = "Filler"
106+
}
107+
if _, ok := config.VmMode_value[virtMode]; !ok {
108+
log.Fatalf("Unknown virt-mode: %s", virtMode)
109+
}
110+
pc.VirtMode = config.VmMode(config.VmMode_value[virtMode])
111+
},
91112
}
92113

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

126148
return podDeployCmd
127149
}

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)