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

Change runhcs create-scratch to use physical backed memory by default #2152

Merged
Merged
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
12 changes: 11 additions & 1 deletion cmd/runhcs/create-scratch.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ var createScratchCommand = cli.Command{
Name: "cache-path",
Usage: "optional: The path to an existing scratch.vhdx to copy instead of create.",
},
cli.BoolFlag{
Name: "use-virtual-memory",
Usage: "optional: Whether the UVM should be backed with virtual memory.",
},
},
Before: appargs.Validate(),
Action: func(context *cli.Context) (err error) {
Expand All @@ -52,11 +56,17 @@ var createScratchCommand = cli.Command{

// 256MB with boot from vhd supported.
opts.MemorySizeInMB = 256
opts.VPMemDeviceCount = 1
// Default SCSI controller count is 4, we don't need that for this UVM,
// bring it back to 1 to avoid any confusion with SCSI controller numbers.
opts.SCSIControllerCount = 1

if context.Bool("use-virtual-memory") {
opts.VPMemDeviceCount = 1
} else {
opts.AllowOvercommit = false
opts.VPMemDeviceCount = 0
}

sizeGB := uint32(context.Uint("sizeGB"))
if sizeGB == 0 {
sizeGB = lcow.DefaultScratchSizeGB
Expand Down
6 changes: 6 additions & 0 deletions pkg/go-runhcs/runhcs_create-scratch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ type CreateScratchOpts struct {
// CacheFile is the path to an existing `scratch.vhx` to copy. If
// `CacheFile` does not exit the scratch will be created.
CacheFile string
// UseVirtualMemory indicates whether the UVM used to create the
// scratch should be backed with virtual memory or not.
UseVirtualMemory bool
}

func (opt *CreateScratchOpts) args() ([]string, error) {
Expand All @@ -38,6 +41,9 @@ func (opt *CreateScratchOpts) args() ([]string, error) {
}
out = append(out, "--cache-path", abs)
}
if opt.UseVirtualMemory {
out = append(out, "--use-virtual-memory")
}
return out, nil
}

Expand Down