Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/unikontainers/hypervisors/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func (q *Qemu) Path() string {
func (q *Qemu) BuildExecCmd(args types.ExecArgs, ukernel types.Unikernel) ([]string, error) {
qemuMem := BytesToStringMB(args.MemSizeB)
cmdString := q.binaryPath + " -m " + qemuMem + "M"
cmdString += " -L /usr/share/qemu" // Set the path for qemu bios/data
cmdString += " -cpu host" // Choose CPU
cmdString += " -enable-kvm" // Enable KVM to use CPU virt extensions
cmdString += " -L /usr/share/qemu" // Set the path for qemu bios/data
cmdString += " -cpu host" // Choose CPU
cmdString += " -enable-kvm" // Enable KVM to use CPU virt extensions
cmdString += " -display none -vga none -serial stdio -monitor null" // Disable graphic output

if args.VCPUs > 0 {
Expand Down
24 changes: 12 additions & 12 deletions pkg/unikontainers/initrd/initrd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/opencontainers/runtime-spec/specs-go"
)

func AddInitrdRecord(w *cpio.Writer, content []byte, fileInfo *syscall.Stat_t, name string) error {
func addInitrdRecord(w *cpio.Writer, content []byte, fileInfo *syscall.Stat_t, name string) error {
hdr := &cpio.Header{
Name: name,
Mode: cpio.FileMode(fileInfo.Mode),
Expand All @@ -35,11 +35,11 @@ func AddInitrdRecord(w *cpio.Writer, content []byte, fileInfo *syscall.Stat_t, n
}
err := w.WriteHeader(hdr)
if err != nil {
return fmt.Errorf("could not write header in initrd: %v", err)
return fmt.Errorf("could not write header in initrd: %w", err)
}
_, err = w.Write(content)
if err != nil {
return fmt.Errorf("could not write contents in initrd: %v", err)
return fmt.Errorf("could not write contents in initrd: %w", err)
}

return nil
Expand All @@ -49,15 +49,15 @@ func CopyFileToInitrd(w *cpio.Writer, srcFile string, destFile string) error {
// Get the info of the original file
fi, err := os.Stat(srcFile)
if err != nil {
return fmt.Errorf("Could not Stat file %s: %w", srcFile, err)
return fmt.Errorf("could not stat file %s: %w", srcFile, err)
}
fileInfo := fi.Sys().(*syscall.Stat_t)
if fi.Mode().IsRegular() {
content, err := os.ReadFile(srcFile)
if err != nil {
return fmt.Errorf("could not read file %s: %w", srcFile, err)
}
err = AddInitrdRecord(w, content, fileInfo, destFile)
err = addInitrdRecord(w, content, fileInfo, destFile)
if err != nil {
return fmt.Errorf("could not add record for %s: %w", srcFile, err)
}
Expand All @@ -69,7 +69,7 @@ func CopyFileToInitrd(w *cpio.Writer, srcFile string, destFile string) error {
func CopyFileMountsToInitrd(oldInitrd string, mounts []specs.Mount) error {
f, err := os.OpenFile(oldInitrd, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return fmt.Errorf("Could not open %s: %v", oldInitrd, err)
return fmt.Errorf("could not open %s: %w", oldInitrd, err)
}
defer f.Close()

Expand All @@ -80,12 +80,12 @@ func CopyFileMountsToInitrd(oldInitrd string, mounts []specs.Mount) error {
}
err = CopyFileToInitrd(w, m.Source, m.Destination)
if err != nil {
return fmt.Errorf("Could not add file %s to initrd: %v", m.Source, err)
return fmt.Errorf("could not add file %s to initrd: %w", m.Source, err)
}
}
err = w.Close()
if err != nil {
return fmt.Errorf("Could not close initrd %v", err)
return fmt.Errorf("could not close initrd: %w", err)
}

return nil
Expand All @@ -94,7 +94,7 @@ func CopyFileMountsToInitrd(oldInitrd string, mounts []specs.Mount) error {
func AddFileToInitrd(oldInitrd string, data string, name string) error {
f, err := os.OpenFile(oldInitrd, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return fmt.Errorf("could not open %s: %v", oldInitrd, err)
return fmt.Errorf("could not open %s: %w", oldInitrd, err)
}
defer f.Close()

Expand All @@ -106,14 +106,14 @@ func AddFileToInitrd(oldInitrd string, data string, name string) error {
Uid: 0,
Gid: 0,
}
err = AddInitrdRecord(w, []byte(data), &fileInfo, name)
err = addInitrdRecord(w, []byte(data), &fileInfo, name)
if err != nil {
return fmt.Errorf("Could not add file %s to initrd: %v", name, err)
return fmt.Errorf("could not add file %s to initrd: %w", name, err)
}

err = w.Close()
if err != nil {
return fmt.Errorf("Could not close initrd %v", err)
return fmt.Errorf("could not close initrd: %w", err)
}

return nil
Expand Down