Skip to content

Commit ab9417b

Browse files
committed
Apply reviews
- hack/convert-diffdisk-to-asif.sh: Add description of script. - pkg/driver/vz: Refine error text on detecting unexpected image type. Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
1 parent bd17109 commit ab9417b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

hack/convert-diffdisk-to-asif.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# SPDX-FileCopyrightText: Copyright The Lima Authors
44
# SPDX-License-Identifier: Apache-2.0
55

6+
# This script converts the diffdisk of a Lima instance to ASIF format.
7+
# It requires that the instance is stopped before conversion.
8+
# Usage: hack/convert-diffdisk-to-asif.sh [instance-name]
9+
610
set -eux -o pipefail
711

812
instance="${1:-asif-test}"

pkg/driver/vz/vm_darwin.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"os"
1515
"path/filepath"
1616
"runtime"
17+
"slices"
1718
"strconv"
1819
"sync"
1920
"syscall"
@@ -22,6 +23,7 @@ import (
2223
"github.com/coreos/go-semver/semver"
2324
"github.com/docker/go-units"
2425
"github.com/lima-vm/go-qcow2reader"
26+
"github.com/lima-vm/go-qcow2reader/image"
2527
"github.com/lima-vm/go-qcow2reader/image/asif"
2628
"github.com/lima-vm/go-qcow2reader/image/raw"
2729
"github.com/sirupsen/logrus"
@@ -452,8 +454,9 @@ func validateDiskFormat(diskPath string) error {
452454
if err != nil {
453455
return fmt.Errorf("failed to detect the format of %q: %w", diskPath, err)
454456
}
455-
if t := img.Type(); t != raw.Type && t != asif.Type {
456-
return fmt.Errorf("expected the format of %q to be %q, got %q", diskPath, raw.Type, t)
457+
supportedDiskTypes := []image.Type{raw.Type, asif.Type}
458+
if t := img.Type(); !slices.Contains(supportedDiskTypes, t) {
459+
return fmt.Errorf("expected the format of %q to be one of %v, got %q", diskPath, supportedDiskTypes, t)
457460
}
458461
// TODO: ensure that the disk is formatted with GPT or ISO9660
459462
return nil

0 commit comments

Comments
 (0)