From 678c5195c496ee02d46554f0e80216b20928358e Mon Sep 17 00:00:00 2001 From: jiangdawei15 Date: Thu, 18 Aug 2022 20:43:49 +0800 Subject: [PATCH 09/22] qemu: fix formatting of pflash readonly attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the had an explicit readonly='no' attribute we accidentally still marked the plfash as readonly due to the bad conversion from virTristateBool to bool. This was missed because the test cases run with no capabilities set and thus are validated the -drive approach for pflash configuration, not the -blockdev approach. This affected the following config: /var/lib/libvirt/qemu/nvram/test-bios.fd for the sake of completeness, we also add a test XML config with no readonly attribute at all, to demonstrate that the default for pflash is intended to be r/w. Reviewed-by: Ján Tomko Signed-off-by: Daniel P. Berrangé --- src/qemu/qemu_domain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bf09ad517b..c4c3bb57ac 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -17166,7 +17166,8 @@ qemuDomainInitializePflashStorageSource(virDomainObjPtr vm) pflash0->type = VIR_STORAGE_TYPE_FILE; pflash0->format = VIR_STORAGE_FILE_RAW; pflash0->path = g_strdup(def->os.loader->path); - pflash0->readonly = def->os.loader->readonly; + pflash0->readonly = false; + virTristateBoolToBool(def->os.loader->readonly, &pflash0->readonly); pflash0->nodeformat = g_strdup("libvirt-pflash0-format"); pflash0->nodestorage = g_strdup("libvirt-pflash0-storage"); -- 2.33.0