-
Notifications
You must be signed in to change notification settings - Fork 780
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Lines 21 to 61 in cbe7241
| // EnsureDisk ensures that the diff disk exists with the specified size and format. | |
| func EnsureDisk(ctx context.Context, instDir, diskSize string, diskImageFormat image.Type) error { | |
| diffDisk := filepath.Join(instDir, filenames.DiffDisk) | |
| if _, err := os.Stat(diffDisk); err == nil || !errors.Is(err, os.ErrNotExist) { | |
| // disk is already ensured | |
| return err | |
| } | |
| diskUtil := proxyimgutil.NewDiskUtil(ctx) | |
| baseDisk := filepath.Join(instDir, filenames.BaseDisk) | |
| diskSizeInBytes, _ := units.RAMInBytes(diskSize) | |
| if diskSizeInBytes == 0 { | |
| return nil | |
| } | |
| isBaseDiskISO, err := iso9660util.IsISO9660(baseDisk) | |
| if err != nil { | |
| return err | |
| } | |
| if isBaseDiskISO { | |
| // Create an empty data volume (sparse) | |
| diffDiskF, err := os.Create(diffDisk) | |
| if err != nil { | |
| return err | |
| } | |
| err = diskUtil.MakeSparse(ctx, diffDiskF, 0) | |
| if err != nil { | |
| diffDiskF.Close() | |
| return fmt.Errorf("failed to create sparse diff disk %q: %w", diffDisk, err) | |
| } | |
| return diffDiskF.Close() | |
| } | |
| // Check whether to use ASIF format | |
| if err = diskUtil.Convert(ctx, diskImageFormat, baseDisk, diffDisk, &diskSizeInBytes, false); err != nil { | |
| return fmt.Errorf("failed to convert %q to a disk %q: %w", baseDisk, diffDisk, err) | |
| } | |
| return err | |
| } |
diskImageFormat is ignored for ISO mode
Originally posted by @AkihiroSuda in #4327 (comment)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working