This is an automated email from the ASF dual-hosted git repository.
weizhouapache pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.22 by this push:
new 63c142be261 KVM: fix LUKS/volume-encryption detection for qemu-img >=
10.1.0 (#13587)
63c142be261 is described below
commit 63c142be261753314bb8d33446f20ab553aefec9
Author: Nikolaus Eppinger <[email protected]>
AuthorDate: Mon Jul 13 09:42:40 2026 +0200
KVM: fix LUKS/volume-encryption detection for qemu-img >= 10.1.0 (#13587)
qemu-img 10.1.0 changed the "qemu-img --help" supported-formats header
from "Supported formats:" to "Supported image formats:". The regex in
QemuImg.helpSupportsImageFormat() only matched the old header, so
hostSupportsVolumeEncryption() returned false on affected hosts even
though cryptsetup and the luks format were both available, blocking
encrypted offerings.
Make the "image" keyword optional in the regex so it matches both the
legacy and current qemu-img help output.
---
.../java/org/apache/cloudstack/utils/qemu/QemuImg.java | 5 ++++-
.../org/apache/cloudstack/utils/qemu/QemuImgTest.java | 15 +++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git
a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuImg.java
b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuImg.java
index 80e44d8059a..e51c80e521c 100644
---
a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuImg.java
+++
b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/qemu/QemuImg.java
@@ -927,7 +927,10 @@ public class QemuImg {
}
protected static boolean helpSupportsImageFormat(String text,
QemuImg.PhysicalDiskFormat format) {
- Pattern pattern =
Pattern.compile("Supported\\sformats:[a-zA-Z0-9-_\\s]*?\\b" + format + "\\b",
CASE_INSENSITIVE);
+ // QEMU >= 10.1.0 changed the qemu-img --help header from
+ // "Supported formats:" to "Supported image formats:", so the word
+ // "image" must be treated as optional here.
+ Pattern pattern =
Pattern.compile("Supported\\s(image\\s)?formats:[a-zA-Z0-9-_\\s]*?\\b" + format
+ "\\b", CASE_INSENSITIVE);
return pattern.matcher(text).find();
}
diff --git
a/plugins/hypervisors/kvm/src/test/java/org/apache/cloudstack/utils/qemu/QemuImgTest.java
b/plugins/hypervisors/kvm/src/test/java/org/apache/cloudstack/utils/qemu/QemuImgTest.java
index 5a027425776..15f6785c1fd 100644
---
a/plugins/hypervisors/kvm/src/test/java/org/apache/cloudstack/utils/qemu/QemuImgTest.java
+++
b/plugins/hypervisors/kvm/src/test/java/org/apache/cloudstack/utils/qemu/QemuImgTest.java
@@ -390,6 +390,21 @@ public class QemuImgTest {
Assert.assertFalse("should not support http",
QemuImg.helpSupportsImageFormat(partialHelp, PhysicalDiskFormat.SHEEPDOG));
}
+ @Test
+ public void testHelpSupportsImageFormatQemu101Header() throws
QemuImgException, LibvirtException {
+ // qemu-img 10.1.0 (e.g. RHEL 9.8: qemu-kvm-10.1.0-17.el9_8.3) changed
the
+ // help header from "Supported formats:" to "Supported image formats:"
+ String help = "Supported image formats:\n" +
+ " blkdebug blklogwrites blkverify compress copy-before-write
copy-on-read\n" +
+ " file ftp ftps host_cdrom host_device http https io_uring
luks nbd null-aio\n" +
+ " null-co nvme nvme-io_uring preallocate qcow2 quorum raw
rbd\n" +
+ " snapshot-access throttle vdi vhdx virtio-blk-vfio-pci\n" +
+ " virtio-blk-vhost-user virtio-blk-vhost-vdpa vmdk vpc\n";
+ Assert.assertTrue("should support luks",
QemuImg.helpSupportsImageFormat(help, PhysicalDiskFormat.LUKS));
+ Assert.assertTrue("should support qcow2",
QemuImg.helpSupportsImageFormat(help, PhysicalDiskFormat.QCOW2));
+ Assert.assertFalse("should not support sheepdog",
QemuImg.helpSupportsImageFormat(help, PhysicalDiskFormat.SHEEPDOG));
+ }
+
@Test
public void testCheckAndRepair() throws LibvirtException {
String filename = "/tmp/" + UUID.randomUUID() + ".qcow2";