* [RFT 0/4] guestfs: few custom image fixes
@ 2025-08-27 3:57 Luis Chamberlain
2025-08-27 3:57 ` [RFT 1/4] guestfs: fix custom image partition not expanded after disk resize Luis Chamberlain
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Luis Chamberlain @ 2025-08-27 3:57 UTC (permalink / raw)
To: Chuck Lever, Daniel Gomez, kdevops; +Cc: Luis Chamberlain
Here's a few custom images fixes I found along the way after deciding
to nuke my old base image and starting fresh again for debian testing.
Would appreciate feedback on testing, review. This is under the kdevops
branch: mcgrof/20250826
Luis Chamberlain (4):
guestfs: fix custom image partition not expanded after disk resize
guestfs: fix custom image bringup failure for Debian 13
guestfs: fix virt-resize failure for custom images
guestfs: fix checksum verification for resized custom images
.../roles/base_image/tasks/custom-image.yml | 112 ++++++++++++------
playbooks/roles/base_image/tasks/main.yml | 1 +
2 files changed, 78 insertions(+), 35 deletions(-)
--
2.50.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFT 1/4] guestfs: fix custom image partition not expanded after disk resize
2025-08-27 3:57 [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
@ 2025-08-27 3:57 ` Luis Chamberlain
2025-08-27 3:57 ` [RFT 2/4] guestfs: fix custom image bringup failure for Debian 13 Luis Chamberlain
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luis Chamberlain @ 2025-08-27 3:57 UTC (permalink / raw)
To: Chuck Lever, Daniel Gomez, kdevops; +Cc: Luis Chamberlain
The commit e46bf3cd54de ("guestfs: add unified LIBVIRT_IMAGE_SIZE
configuration") added disk resizing for custom images but only resized
the disk image file, not the partition inside. This resulted in VMs
having a 20GB disk but only a 2.9GB root filesystem partition, causing
out-of-space errors during kernel installation.
Add virt-resize step after qemu-img resize to expand the root partition
(/dev/sda1) to use the full disk space. This ensures VMs get the full
20GB root filesystem as intended.
Without this fix, VMs show:
/dev/vda1 2.8G (despite 20GB disk)
With this fix, VMs will have:
/dev/vda1 20G (using full disk)
Fixes: e46bf3cd54de ("guestfs: add unified LIBVIRT_IMAGE_SIZE configuration")
Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
.../roles/base_image/tasks/custom-image.yml | 31 ++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index 46701e75..207a5fa1 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -53,7 +53,36 @@
cmd: "qemu-img resize {{ custom_image }} {{ libvirt_image_size }}"
changed_when: true
when:
- - custom_image_download is changed or custom_image_stat.stat.exists
+ - custom_image_download is changed
+ - guestfs_has_custom_raw_image_url|bool
+
+- name: Create temporary file for partition-expanded image
+ ansible.builtin.tempfile:
+ state: file
+ suffix: .raw
+ register: temp_resized_image
+ when:
+ - custom_image_download is changed
+ - guestfs_has_custom_raw_image_url|bool
+
+- name: Expand root partition to use full disk
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.command:
+ cmd: "virt-resize --expand /dev/sda1 {{ custom_image }} {{ temp_resized_image.path }}"
+ changed_when: true
+ when:
+ - custom_image_download is changed
+ - guestfs_has_custom_raw_image_url|bool
+
+- name: Replace original image with partition-expanded one
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.command:
+ cmd: "mv -f {{ temp_resized_image.path }} {{ custom_image }}"
+ changed_when: true
+ when:
+ - custom_image_download is changed
- guestfs_has_custom_raw_image_url|bool
- name: Check if the custom image sentinel file already exists
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFT 2/4] guestfs: fix custom image bringup failure for Debian 13
2025-08-27 3:57 [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
2025-08-27 3:57 ` [RFT 1/4] guestfs: fix custom image partition not expanded after disk resize Luis Chamberlain
@ 2025-08-27 3:57 ` Luis Chamberlain
2025-08-27 3:57 ` [RFT 3/4] guestfs: fix virt-resize failure for custom images Luis Chamberlain
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luis Chamberlain @ 2025-08-27 3:57 UTC (permalink / raw)
To: Chuck Lever, Daniel Gomez, kdevops; +Cc: Luis Chamberlain
When using custom images (like Debian 13 daily builds), the base_image
role would incorrectly attempt to build the image using virt-builder
even though a custom image workflow was configured. This failed because
"debian-13-generic-amd64-daily" is not a valid virt-builder template.
The issue had two root causes:
1. The base-image.yml task would run even when custom images were
configured, attempting to use virt-builder with an invalid template
2. The custom-image.yml task prepared the custom image but never copied
it to the base_image_pathname location expected by subsequent tasks
Fix both issues by:
- Adding a condition to skip base-image.yml when using custom images
- Copying the prepared custom image to the base_image_pathname location
This ensures custom images are properly downloaded, prepared with the
kdevops user configuration, and placed in the expected location for
VM provisioning.
Fixes: df31e8f55d7d ("guestfs: fix custom image partition not expanded after disk resize")
Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
playbooks/roles/base_image/tasks/custom-image.yml | 11 +++++++++++
playbooks/roles/base_image/tasks/main.yml | 1 +
2 files changed, 12 insertions(+)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index 207a5fa1..296424bc 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -281,3 +281,14 @@
- "--no-compression"
- "{{ custom_image_dir }}"
changed_when: true
+
+- name: Copy custom image to base image location
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.copy:
+ src: "{{ custom_image }}"
+ dest: "{{ base_image_pathname }}"
+ remote_src: true
+ mode: "u=rw,g=r,o=r"
+ when:
+ - custom_image_stat.stat.exists or custom_image_download is changed
diff --git a/playbooks/roles/base_image/tasks/main.yml b/playbooks/roles/base_image/tasks/main.yml
index 37907d71..05ab68bd 100644
--- a/playbooks/roles/base_image/tasks/main.yml
+++ b/playbooks/roles/base_image/tasks/main.yml
@@ -17,3 +17,4 @@
file: "{{ role_path }}/tasks/base-image.yml"
when:
- not result.stat.exists
+ - not guestfs_has_custom_raw_image|bool
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFT 3/4] guestfs: fix virt-resize failure for custom images
2025-08-27 3:57 [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
2025-08-27 3:57 ` [RFT 1/4] guestfs: fix custom image partition not expanded after disk resize Luis Chamberlain
2025-08-27 3:57 ` [RFT 2/4] guestfs: fix custom image bringup failure for Debian 13 Luis Chamberlain
@ 2025-08-27 3:57 ` Luis Chamberlain
2025-08-27 3:57 ` [RFT 4/4] guestfs: fix checksum verification for resized " Luis Chamberlain
2025-08-29 2:01 ` [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
4 siblings, 0 replies; 6+ messages in thread
From: Luis Chamberlain @ 2025-08-27 3:57 UTC (permalink / raw)
To: Chuck Lever, Daniel Gomez, kdevops; +Cc: Luis Chamberlain
The virt-resize command was failing because it requires a pre-allocated
output file with the target size, not an empty temporary file.
Fix by:
1. Pre-allocating the temporary image file with qemu-img create before
running virt-resize
2. Adding -f raw flag to qemu-img resize to avoid format detection
warnings
This ensures the partition expansion works correctly when resizing
custom images like Debian 13 daily builds.
Error was:
virt-resize: error: /tmp/ansible.depq5vk0.raw: file is too small to
be a disk image (0 bytes)
Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
playbooks/roles/base_image/tasks/custom-image.yml | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index 296424bc..a3a8cbbd 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -50,7 +50,7 @@
become: true
become_method: ansible.builtin.sudo
ansible.builtin.command:
- cmd: "qemu-img resize {{ custom_image }} {{ libvirt_image_size }}"
+ cmd: "qemu-img resize -f raw {{ custom_image }} {{ libvirt_image_size }}"
changed_when: true
when:
- custom_image_download is changed
@@ -65,6 +65,17 @@
- custom_image_download is changed
- guestfs_has_custom_raw_image_url|bool
+- name: Pre-allocate space for the resized image
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.command:
+ cmd: "qemu-img create -f raw {{ temp_resized_image.path }} {{ libvirt_image_size }}"
+ changed_when: true
+ when:
+ - custom_image_download is changed
+ - guestfs_has_custom_raw_image_url|bool
+ - temp_resized_image.path is defined
+
- name: Expand root partition to use full disk
become: true
become_method: ansible.builtin.sudo
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFT 4/4] guestfs: fix checksum verification for resized custom images
2025-08-27 3:57 [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
` (2 preceding siblings ...)
2025-08-27 3:57 ` [RFT 3/4] guestfs: fix virt-resize failure for custom images Luis Chamberlain
@ 2025-08-27 3:57 ` Luis Chamberlain
2025-08-29 2:01 ` [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
4 siblings, 0 replies; 6+ messages in thread
From: Luis Chamberlain @ 2025-08-27 3:57 UTC (permalink / raw)
To: Chuck Lever, Daniel Gomez, kdevops; +Cc: Luis Chamberlain
The SHA512 checksum verification was failing because it was being run
after the image had been resized and modified. The checksum from the
upstream source is only valid for the original downloaded image, not
the modified version.
Fix by:
1. Verifying the checksum immediately after download, before any
modifications
2. Removing the redundant checksum verification that happened after
resize operations
This ensures the image integrity is verified when downloaded, but
doesn't fail on subsequent runs when the image has been customized
for kdevops use.
Error was:
sha512sum: WARNING: 1 computed checksum did NOT match
debian-13-generic-amd64-daily.raw: FAILED
Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
.../roles/base_image/tasks/custom-image.yml | 57 ++++++++-----------
1 file changed, 24 insertions(+), 33 deletions(-)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index a3a8cbbd..d23cce96 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -46,6 +46,29 @@
- not custom_image_stat.stat.exists
- guestfs_has_custom_raw_image_url|bool
+- name: Verify custom image checksum immediately after download
+ when:
+ - custom_image_download is changed
+ - guestfs_has_custom_raw_image_sha512sums|bool
+ block:
+ - name: Get the base name of the sha512sums file for verification
+ ansible.builtin.set_fact:
+ sha512sums_file: "{{ guestfs_custom_raw_image_sha512sums_url | basename }}"
+
+ - name: Fetch the sha512sums file for verification
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.get_url:
+ url: "{{ guestfs_custom_raw_image_sha512sums_url }}"
+ dest: "{{ custom_image_dir }}"
+ mode: "u=rw,g=r,o=r"
+
+ - name: Verify checksum of freshly downloaded image
+ ansible.builtin.command:
+ cmd: "sha512sum --ignore-missing -c {{ sha512sums_file }}"
+ chdir: "{{ custom_image_dir }}"
+ changed_when: false
+
- name: Resize custom image to match configured size
become: true
become_method: ansible.builtin.sudo
@@ -104,42 +127,10 @@
get_mime: false
register: sentinel_stat
-- name: Check the custom image
+- name: Configure custom image with kdevops settings
when:
- not sentinel_stat.stat.exists
- - guestfs_has_custom_raw_image_sha512sums|bool
block:
- - name: Get the base name of the sha512sums file
- ansible.builtin.set_fact:
- sha512sums_file: "{{ guestfs_custom_raw_image_sha512sums_url | basename }}"
-
- - name: Set the full pathname of sha512sums file
- ansible.builtin.set_fact:
- custom_image_sha512sum: "{{ custom_image_dir }}/{{ sha512sums_file }}"
-
- - name: Check if the sha512sums file already exists
- ansible.builtin.stat:
- path: "{{ custom_image_sha512sum }}"
- get_attributes: false
- get_checksum: false
- get_mime: false
- register: sha512sums_stat
-
- - name: Fetch the sha512sums file
- become: true
- become_method: ansible.builtin.sudo
- ansible.builtin.get_url:
- url: "{{ guestfs_custom_raw_image_sha512sums_url }}"
- dest: "{{ custom_image_dir }}"
- mode: "u=rw,g=r,o=r"
- when:
- - not sha512sums_stat.stat.exists
-
- - name: Compute checksum of something
- ansible.builtin.command:
- cmd: "sha512sum --ignore-missing -c {{ sha512sums_file }}"
- chdir: "{{ custom_image_dir }}"
- changed_when: false
- name: Get the UID of the kdevops user on the control host
ansible.builtin.command:
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFT 0/4] guestfs: few custom image fixes
2025-08-27 3:57 [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
` (3 preceding siblings ...)
2025-08-27 3:57 ` [RFT 4/4] guestfs: fix checksum verification for resized " Luis Chamberlain
@ 2025-08-29 2:01 ` Luis Chamberlain
4 siblings, 0 replies; 6+ messages in thread
From: Luis Chamberlain @ 2025-08-29 2:01 UTC (permalink / raw)
To: Chuck Lever, Daniel Gomez, kdevops
On Tue, Aug 26, 2025 at 08:57:43PM -0700, Luis Chamberlain wrote:
> Here's a few custom images fixes I found along the way after deciding
> to nuke my old base image and starting fresh again for debian testing.
>
> Would appreciate feedback on testing, review. This is under the kdevops
> branch: mcgrof/20250826
>
> Luis Chamberlain (4):
> guestfs: fix custom image partition not expanded after disk resize
> guestfs: fix custom image bringup failure for Debian 13
> guestfs: fix virt-resize failure for custom images
> guestfs: fix checksum verification for resized custom images
>
> .../roles/base_image/tasks/custom-image.yml | 112 ++++++++++++------
> playbooks/roles/base_image/tasks/main.yml | 1 +
> 2 files changed, 78 insertions(+), 35 deletions(-)
I'll be merging these shortly.
Luis
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-08-29 2:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27 3:57 [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
2025-08-27 3:57 ` [RFT 1/4] guestfs: fix custom image partition not expanded after disk resize Luis Chamberlain
2025-08-27 3:57 ` [RFT 2/4] guestfs: fix custom image bringup failure for Debian 13 Luis Chamberlain
2025-08-27 3:57 ` [RFT 3/4] guestfs: fix virt-resize failure for custom images Luis Chamberlain
2025-08-27 3:57 ` [RFT 4/4] guestfs: fix checksum verification for resized " Luis Chamberlain
2025-08-29 2:01 ` [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).