Skip to content

Commit

Permalink
qemu: explicitly pass the basedisk format to QEMU
Browse files Browse the repository at this point in the history
Signed-off-by: Akihiro Suda <[email protected]>
  • Loading branch information
AkihiroSuda committed May 29, 2023
1 parent efe1c47 commit bfa5bab
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,21 @@ func Cmdline(cfg Config) (string, []string, error) {
}
if isBaseDiskCDROM {
args = appendArgsIfNoConflict(args, "-boot", "order=d,splash-time=0,menu=on")
args = append(args, "-drive", fmt.Sprintf("file=%s,media=cdrom,readonly=on", baseDisk))
args = append(args, "-drive", fmt.Sprintf("file=%s,format=raw,media=cdrom,readonly=on", baseDisk))
} else {
args = appendArgsIfNoConflict(args, "-boot", "order=c,splash-time=0,menu=on")
}
if diskSize, _ := units.RAMInBytes(*cfg.LimaYAML.Disk); diskSize > 0 {
args = append(args, "-drive", fmt.Sprintf("file=%s,if=virtio,discard=on", diffDisk))
} else if !isBaseDiskCDROM {
args = append(args, "-drive", fmt.Sprintf("file=%s,if=virtio,discard=on", baseDisk))
baseDiskInfo, err := imgutil.GetInfo(baseDisk)
if err != nil {
return "", nil, fmt.Errorf("failed to get the information of %q: %w", baseDisk, err)
}
if baseDiskInfo.Format == "" {
return "", nil, fmt.Errorf("failed to inspect the format of %q", baseDisk)
}
args = append(args, "-drive", fmt.Sprintf("file=%s,format=%s,if=virtio,discard=on", baseDisk, baseDiskInfo.Format))
}
for _, extraDisk := range extraDisks {
args = append(args, "-drive", fmt.Sprintf("file=%s,if=virtio,discard=on", extraDisk))
Expand Down

0 comments on commit bfa5bab

Please sign in to comment.