Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added wasm functionality #2210

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion cmd/gcs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"


"github.com/Microsoft/hcsshim/global"
"github.com/Microsoft/hcsshim/internal/guest/bridge"
"github.com/Microsoft/hcsshim/internal/guest/kmsg"
"github.com/Microsoft/hcsshim/internal/guest/runtime/hcsv2"
Expand Down Expand Up @@ -195,6 +196,9 @@ func main() {
disableTimeSync := flag.Bool("disable-time-sync",
false,
"If true do not run chronyd time synchronization service inside the UVM")
crun := flag.Bool("crun",
false,
"setting global runtime")
scrubLogs := flag.Bool("scrub-logs", false, "If true, scrub potentially sensitive information from logging")
initialPolicyStance := flag.String("initial-policy-stance",
"allow",
Expand Down Expand Up @@ -294,6 +298,11 @@ func main() {
// Continuously log /dev/kmsg
go kmsg.ReadForever(kmsg.LogLevel(*kmsgLogLevel))


if *crun {
global.SetGlobalRuntime("crun")
}

tport := &transport.VsockTransport{}
rtime, err := runc.NewRuntime(baseLogPath)
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions global/global.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// config/config.go
package global

var global_runtime string

// Setter function
func SetGlobalRuntime(value string) {
global_runtime = value
}

// Getter function
func GetGlobalRuntime() string {
return global_runtime
}
4 changes: 4 additions & 0 deletions internal/guest/runtime/runc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/Microsoft/hcsshim/global"
"github.com/Microsoft/hcsshim/internal/guest/runtime"
)

Expand Down Expand Up @@ -171,5 +172,8 @@ func runcCommandLog(logPath string, args ...string) *exec.Cmd {
}

func runcCommand(args ...string) *exec.Cmd {
if global.GetGlobalRuntime() == "crun" {
return exec.Command("crun", args...)
}
return exec.Command("runc", args...)
}
1 change: 1 addition & 0 deletions internal/oci/uvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ func SpecToUVMCreateOpts(ctx context.Context, s *specs.Spec, id, owner string) (
handleAnnotationBootFilesPath(ctx, s.Annotations, lopts)
lopts.EnableScratchEncryption = ParseAnnotationsBool(ctx, s.Annotations, annotations.EncryptedScratchDisk, lopts.EnableScratchEncryption)
lopts.SecurityPolicy = ParseAnnotationsString(s.Annotations, annotations.SecurityPolicy, lopts.SecurityPolicy)
lopts.Runtime = ParseAnnotationsString(s.Annotations, annotations.Runtime, lopts.Runtime)
lopts.SecurityPolicyEnforcer = ParseAnnotationsString(s.Annotations, annotations.SecurityPolicyEnforcer, lopts.SecurityPolicyEnforcer)
lopts.UVMReferenceInfoFile = ParseAnnotationsString(s.Annotations, annotations.UVMReferenceInfoFile, lopts.UVMReferenceInfoFile)
lopts.KernelBootOptions = ParseAnnotationsString(s.Annotations, annotations.KernelBootOptions, lopts.KernelBootOptions)
Expand Down
6 changes: 6 additions & 0 deletions internal/uvm/create_lcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ type OptionsLCOW struct {
HclEnabled *bool // Whether to enable the host compatibility layer
ExtraVSockPorts []uint32 // Extra vsock ports to allow
AssignedDevices []VPCIDeviceID // AssignedDevices are devices to add on pod boot
Runtime string // runtime
}

// defaultLCOWOSBootFilesPath returns the default path used to locate the LCOW
Expand Down Expand Up @@ -182,6 +183,7 @@ func NewDefaultOptionsLCOW(id, owner string) *OptionsLCOW {
SecurityPolicyEnabled: false,
UVMReferenceInfoFile: UVMReferenceInfoFile,
},
Runtime: "",
}

opts.UpdateBootFilesPath(context.TODO(), defaultLCOWOSBootFilesPath())
Expand Down Expand Up @@ -835,6 +837,10 @@ func makeLCOWDoc(ctx context.Context, opts *OptionsLCOW, uvm *UtilityVM) (_ *hcs
kernelArgs += " " + opts.KernelBootOptions
}

if opts.Runtime == "runhcs-lcow-crun" {
opts.ExecCommandLine = fmt.Sprintf("%s -crun", opts.ExecCommandLine)
}

if !opts.VPCIEnabled {
kernelArgs += ` pci=off`
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/annotations/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ const (
// VPMemNoMultiMapping indicates that we should disable LCOW vpmem layer multi mapping.
VPMemNoMultiMapping = "io.microsoft.virtualmachine.lcow.vpmem.nomultimapping"

// runtime is used to specify low-level runtime option.
Runtime = "runtime"

// KernelBootOptions is used to specify kernel options used while booting a linux kernel.
KernelBootOptions = "io.microsoft.virtualmachine.lcow.kernelbootoptions"

Expand Down