Skip to content

Commit

Permalink
Merge pull request #265 from microsoft/sumsharma/upstr-clh-memory-shared
Browse files Browse the repository at this point in the history
runtime: Set memory config shared=false when shared_fs=None in CLH
  • Loading branch information
Sumynwa authored Dec 12, 2024
2 parents 1f4360c + 9224163 commit 7e24498
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/runtime/virtcontainers/clh.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,14 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net

// Create the VM memory config via the constructor to ensure default values are properly assigned
clh.vmconfig.Memory = chclient.NewMemoryConfig(int64((utils.MemUnit(clh.config.MemorySize) * utils.MiB).ToBytes()))
// shared memory should be enabled if using vhost-user(kata uses virtiofsd)
clh.vmconfig.Memory.Shared = func(b bool) *bool { return &b }(true)
// Memory config shared is to be enabled when using vhost_user backends,
// ex. virtio-fs or when using HugePages.
// If such features are disabled, turn off shared memory config.
if clh.config.SharedFS == config.NoSharedFS && !clh.config.HugePages {
clh.vmconfig.Memory.Shared = func(b bool) *bool { return &b }(false)
} else {
clh.vmconfig.Memory.Shared = func(b bool) *bool { return &b }(true)
}
// Enable hugepages if needed
clh.vmconfig.Memory.Hugepages = func(b bool) *bool { return &b }(clh.config.HugePages)
if !clh.config.ConfidentialGuest && igvmPath == "" {
Expand Down

0 comments on commit 7e24498

Please sign in to comment.