Skip to content

kvm: createtmplt.sh ignores qemu-img errors and marks an empty template ready #14858

Todo

Description

@Damans227

problem

When qemu-img fails while creating a template from a volume on KVM, createtmplt.sh ignores the error and exits 0. CloudStack marks the template Ready, but the image is empty. It only shows up later, when a VM from that template fails to boot with "No bootable device".

In create_from_file the qemu-img convert and cp results are never checked. The script then writes template.properties and exits 0. KVMStorageProcessor only looks at the exit code, so it reports success. create_from_snapshot in the same script already checks and exits non-zero.

This is not specific to any storage type. It was found on FlashArray FibreChannel, where a dead multipath device made every read fail.

versions

ACS 4.22.1.1, KVM on Ubuntu 24.04, qemu-img 8.2.2. The script is the same on 4.22 and main.

The steps to reproduce the bug

Run the script against a block device that fails every read:

dmsetup create fix6err --table "0 2097152 error"
/usr/share/cloudstack-common/scripts/storage/qcow2/createtmplt.sh -t tmp/fix6/stock -n t.qcow2 -f /dev/mapper/fix6err
echo $?
qemu-img: error while reading at byte 8388608: Input/output error
qemu-img: error while reading at byte 14680064: Input/output error
0
> qemu-img info /tmp/fix6/stock/t.qcow2
virtual size: 1 GiB (1073741824 bytes)
disk size: 196 KiB

template.properties is written too, so CloudStack treats it as a good template.

What to do about it?

Check the result of qemu-img convert and cp in create_from_file and exit non-zero when they fail, the same way create_from_snapshot already does.

Activity

  1. self-assigned this
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions