diff --git a/qemu/qemu.go b/qemu/qemu.go index 218507808d..89d053fe95 100644 --- a/qemu/qemu.go +++ b/qemu/qemu.go @@ -1117,6 +1117,9 @@ type Kernel struct { // Path is the guest kernel path on the host filesystem. Path string + // InitrdPath is the guest initrd path on the host filesystem. + InitrdPath string + // Params is the kernel parameters string. Params string } @@ -1395,6 +1398,11 @@ func (config *Config) appendKernel() { config.qemuParams = append(config.qemuParams, "-kernel") config.qemuParams = append(config.qemuParams, config.Kernel.Path) + if config.Kernel.InitrdPath != "" { + config.qemuParams = append(config.qemuParams, "-initrd") + config.qemuParams = append(config.qemuParams, config.Kernel.InitrdPath) + } + if config.Kernel.Params != "" { config.qemuParams = append(config.qemuParams, "-append") config.qemuParams = append(config.qemuParams, config.Kernel.Params) diff --git a/qemu/qemu_test.go b/qemu/qemu_test.go index bcbdb2ec13..b7e60e7271 100644 --- a/qemu/qemu_test.go +++ b/qemu/qemu_test.go @@ -395,12 +395,13 @@ func TestAppendKnobsAllFalse(t *testing.T) { testAppend(knobs, knobsString, t) } -var kernelString = "-kernel /opt/vmlinux.container -append root=/dev/pmem0p1 rootflags=dax,data=ordered,errors=remount-ro rw rootfstype=ext4 tsc=reliable" +var kernelString = "-kernel /opt/vmlinux.container -initrd /opt/initrd.container -append root=/dev/pmem0p1 rootflags=dax,data=ordered,errors=remount-ro rw rootfstype=ext4 tsc=reliable" func TestAppendKernel(t *testing.T) { kernel := Kernel{ - Path: "/opt/vmlinux.container", - Params: "root=/dev/pmem0p1 rootflags=dax,data=ordered,errors=remount-ro rw rootfstype=ext4 tsc=reliable", + Path: "/opt/vmlinux.container", + InitrdPath: "/opt/initrd.container", + Params: "root=/dev/pmem0p1 rootflags=dax,data=ordered,errors=remount-ro rw rootfstype=ext4 tsc=reliable", } testAppend(kernel, kernelString, t)