lima-vm/lima · error

expected the format of %#q to be one of %v, got %#q

Error message

expected the format of %#q to be one of %v, got %#q

What it means

The image format was detected, but it is not one of raw or ASIF, the only formats the vz driver supports for disk attachments. Any other format (e.g. qcow2, vhd, iso detected differently) is rejected before the VM is created.

Source

Thrown at pkg/driver/vz/vm_darwin.go:541

		}
	}
	vmConfig.SetNetworkDevicesVirtualMachineConfiguration(configurations)
	return nil
}

func validateDiskFormat(diskPath string) error {
	f, err := os.Open(diskPath)
	if err != nil {
		return err
	}
	defer f.Close()
	img, err := qcow2reader.Open(f)
	if err != nil {
		return fmt.Errorf("failed to detect the format of %#q: %w", diskPath, err)
	}
	supportedDiskTypes := []image.Type{raw.Type, asif.Type}
	if t := img.Type(); !slices.Contains(supportedDiskTypes, t) {
		return fmt.Errorf("expected the format of %#q to be one of %v, got %#q", diskPath, supportedDiskTypes, t)
	}
	// TODO: ensure that the disk is formatted with GPT or ISO9660
	return nil
}

func attachDisks(ctx context.Context, inst *limatype.Instance, vmConfig *vz.VirtualMachineConfiguration) error {
	diskPath := filepath.Join(inst.Dir, filenames.Disk)
	isoPath := filepath.Join(inst.Dir, filenames.ISO)
	ciDataPath := filepath.Join(inst.Dir, filenames.CIDataISO)
	var configurations []vz.StorageDeviceConfiguration

	if osutil.FileExists(diskPath) {
		if err := validateDiskFormat(diskPath); err != nil {
			return err
		}
		diskAttachment, err := vz.NewDiskImageStorageDeviceAttachmentWithCacheAndSync(diskPath, false, diskImageCachingMode, vz.DiskImageSynchronizationModeFsync)
		if err != nil {
			return err

View on GitHub (pinned to dd909d0973)

Solutions

  1. Convert the image to raw: `qemu-img convert -O raw in.qcow2 out.raw` or rely on Lima's Convert step for additional disks
  2. Recreate the disk in ASIF format on macOS hosts that support it
  3. Use the qemu driver if you need qcow2 disks directly

Example fix

// before
qemu-img create -f qcow2 disk.qcow2 10G
// after
qemu-img convert -O raw disk.qcow2 disk.raw
Defensive patterns

Strategy: validation

Validate before calling

out, _ := exec.Command("qemu-img", "info", "--output=json", diskPath).Output()
var info map[string]any
json.Unmarshal(out, &info)
if info["format"] != "raw" {
    return fmt.Errorf("convert %s to raw before using the vz driver", diskPath)
}

Try / catch

if err := start(); err != nil {
    if strings.Contains(err.Error(), "expected the format") {
        // run qemu-img convert -O raw and retry
    }
}

Prevention

When it happens

Trigger: attachDisks -> validateDiskFormat finds img.Type() not in {raw.Type, asif.Type} — e.g. handing vz a qcow2 image or other container format.

Common situations: Reusing disks created for the qemu driver (qcow2); converting tools produced vpc/vdi; older Lima disks in a format vz never supported.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/5ece1d7fa33f534a. Report an issue: GitHub.