This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A file based memory backend mapped to the host, fot eg: '/dev/shm' will be used by virtio-fs for performance reasons. This change is a generic implementation of that for kata. This will be enabled default for virtio-fs negating the need to enable hugepages in that scenario. This option can be used without virtio-fs by setting 'file_mem_backend' to the location in the configuration file. Default value is an empty string. Fixes: #1656 Signed-off-by: Ganesh Maharaj Mahalingam <[email protected]>
- Loading branch information
Ganesh Maharaj Mahalingam
committed
May 24, 2019
1 parent
9a27ac2
commit a41894d
Showing
7 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,9 +96,10 @@ const ( | |
qmpCapErrMsg = "Failed to negoatiate QMP capabilities" | ||
qmpExecCatCmd = "exec:cat" | ||
|
||
scsiControllerID = "scsi0" | ||
rngID = "rng0" | ||
vsockKernelOption = "agent.use_vsock" | ||
scsiControllerID = "scsi0" | ||
rngID = "rng0" | ||
vsockKernelOption = "agent.use_vsock" | ||
fallbackFileBackedMemDir = "/dev/shm" | ||
) | ||
|
||
var qemuMajorVersion int | ||
|
@@ -423,6 +424,23 @@ func (q *qemu) setupTemplate(knobs *govmmQemu.Knobs, memory *govmmQemu.Memory) g | |
return incoming | ||
} | ||
|
||
func (q *qemu) setupFileBackedMem(knobs *govmmQemu.Knobs, memory *govmmQemu.Memory) { | ||
var target string | ||
if q.config.FileBackedMemRootDir != "" { | ||
target = q.config.FileBackedMemRootDir | ||
} else { | ||
target = fallbackFileBackedMemDir | ||
} | ||
if _, err := os.Stat(target); err != nil { | ||
q.Logger().WithError(err).Error("File backed memory location does not exist") | ||
return | ||
} | ||
|
||
knobs.FileBackedMem = true | ||
knobs.FileBackedMemShared = true | ||
memory.Path = target | ||
} | ||
|
||
// createSandbox is the Hypervisor sandbox creation implementation for govmmQemu. | ||
func (q *qemu) createSandbox(ctx context.Context, id string, hypervisorConfig *HypervisorConfig, store *store.VCStore) error { | ||
// Save the tracing context | ||
|
@@ -476,6 +494,19 @@ func (q *qemu) createSandbox(ctx context.Context, id string, hypervisorConfig *H | |
|
||
incoming := q.setupTemplate(&knobs, &memory) | ||
|
||
// With the current implementations, VM templating will not work with file | ||
// based memory (stand-alone) or virtiofs. This is because VM templating | ||
// builds the first VM with file-backed memory and shared=on and the | ||
// subsequent ones with shared=off. virtio-fs always requires shared=on for | ||
// memory. | ||
if q.config.SharedFS == config.VirtioFS || q.config.FileBackedMemRootDir != "" { | ||
if !(q.config.BootToBeTemplate || q.config.BootFromTemplate) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
egernst
Member
|
||
q.setupFileBackedMem(&knobs, &memory) | ||
} else { | ||
return errors.New("VM templating has been enabled with either virtio-fs or file backed memory and this configuration will not work") | ||
} | ||
} | ||
|
||
rtc := govmmQemu.RTC{ | ||
Base: "utc", | ||
DriftFix: "slew", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Consider readability, if (!q.config.BootToBeTemplate && !q.config.BootFromTemplate) {} is preferred.