From d4f00fb1936c202b9a030b4919fd54a0934ed7bf Mon Sep 17 00:00:00 2001 From: Plamen Dimitrov Date: Sat, 28 Dec 2024 12:59:10 +0800 Subject: [PATCH] Use raw image format by default for block devices Not providing a default behavior leads to use of variable without a value and thus cryptic errors regarding the simple fact that we have to provide an image format. It is also not recommended in any conditionals as it leads to undefined behaviors. Finally, in the case of multiple images we may have "image_format=" to use empty string which should be handled similarly to None (lack of any image_format parameter) or generally as the comment suggests to a meaningful default behavior. Signed-off-by: Plamen Dimitrov --- virttest/qemu_devices/qcontainer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virttest/qemu_devices/qcontainer.py b/virttest/qemu_devices/qcontainer.py index 841d125caf..454e97ac73 100644 --- a/virttest/qemu_devices/qcontainer.py +++ b/virttest/qemu_devices/qcontainer.py @@ -2563,8 +2563,8 @@ def define_hbas( format_cls = qdevices.QBlockdevFormatLuks elif imgfmt == "nvme": format_cls = qdevices.QBlockdevFormatRaw - elif imgfmt is None: - # use RAW type as the default + else: + # use RAW type as the default (None, empty string, or else) format_cls = qdevices.QBlockdevFormatRaw protocol_node = protocol_cls(name)