Skip to content

Conversation

@ashwat287
Copy link
Contributor

@ashwat287 ashwat287 commented Dec 2, 2025

Fixes #4418
Ensure diffDisk is converted to the requested format instead of staying sparse.

…t executes.

Ensure diffDisk is converted to the requested format instead of staying sparse.

Signed-off-by: ashwat287 <[email protected]>
return fmt.Errorf("failed to create sparse diff disk %q: %w", diffDisk, err)
}
return diffDiskF.Close()
diffDiskF.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you test this PR?
The diffDisk created in L43 will be overwritten by a new disk converted from baseDisk in L57, no?

Copy link
Contributor Author

@ashwat287 ashwat287 Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes diffDisk would get converted in L57 when the base image is ISO.
I have include the tests to verify the conditions when base image is ISO and non-ISO
Can you please clarify on what should be the desired behaviors in each test cases?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the base disk is an ISO9660 image, the diff disk has to be a new empty disk.
("diff" is misnomer here)

Copy link
Contributor Author

@ashwat287 ashwat287 Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff disk when created as a sparse file in L49 is empty and has size 0 bytes.
On debugging, I find that after conversion the diffdisk size becomes equal to diskSizeInBytes.

To keep the diffDisk empty we can either:

  1. not convert the diffDisk and leave it as a sparse file and eventually ignore diskImageFormat when the base disk is ISO. or,
  2. convert the diffDisk to the available formats while keeping diskSizeInBytes=0 in case of ISO base disk. The problem here arises when the disk is being converted to asif format, the following error gets thrown specified size 0 is smaller than the original image size because of
    if size != nil && *size < srcImg.Size() {
    return fmt.Errorf("specified size %d is smaller than the original image size (%d) of %q", *size, srcImg.Size(), source)
    }

Add pkg/driverutil/disk_test.go covering:
 - Base image is ISO: EnsureDisk creates/keeps diffdisk and converts to raw; base ISO remains unchanged (content hash and ISO signature).
 - Base image is non-ISO: EnsureDisk converts diffdisk to raw.

Signed-off-by: ashwat287 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg/driverutil.EnsureDisk: diskImageFormat is ignored for ISO mode

2 participants