clh: Boot from persistent memory device

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 <chen.bo@intel.com>
This commit is contained in:
Bo Chen 2020-04-09 17:40:10 -07:00
parent e8fc25a7f4
commit 7aa3168500

View File

@ -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
@ -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)
}
clh.vmconfig.Disks = append(clh.vmconfig.Disks, disk)
pmem := chclient.PmemConfig{
File: imagePath,
Size: st.Size(),
DiscardWrites: true,
}
clh.vmconfig.Pmem = append(clh.vmconfig.Pmem, pmem)
// set the serial console to the cloud hypervisor
if clh.config.Debug {