Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
clh: Boot from persistent memory device
Browse files Browse the repository at this point in the history
This patch enables clh to mount the guest rootfs on a pmem device while
booting, which can reduce the guest memory footprint.

Fixes: #2589

Depends-on: github.com/kata-containers/packaging#1014

Signed-off-by: Bo Chen <[email protected]>
  • Loading branch information
likebreath committed Apr 16, 2020
1 parent e8fc25a commit 7aa3168
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions virtcontainers/clh.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ type cloudHypervisor struct {

var clhKernelParams = []Param{

{"root", "/dev/vda1"},
{"root", "/dev/pmem0p1"},
{"panic", "1"}, // upon kernel panic wait 1 second before reboot
{"no_timer_check", ""}, // do not check broken timer IRQ resources
{"noreplace-smp", ""}, // do not replace SMP instructions
Expand Down Expand Up @@ -269,11 +269,17 @@ func (clh *cloudHypervisor) createSandbox(ctx context.Context, id string, networ
return errors.New("image path is empty")
}

disk := chclient.DiskConfig{
Path: imagePath,
Readonly: true,
st, err := os.Stat(imagePath)
if err != nil {
return fmt.Errorf("Failed to get information for image file '%v': %v", imagePath, err)
}

pmem := chclient.PmemConfig{
File: imagePath,
Size: st.Size(),
DiscardWrites: true,
}
clh.vmconfig.Disks = append(clh.vmconfig.Disks, disk)
clh.vmconfig.Pmem = append(clh.vmconfig.Pmem, pmem)

// set the serial console to the cloud hypervisor
if clh.config.Debug {
Expand Down

0 comments on commit 7aa3168

Please sign in to comment.