From 273157dd9f3163ff9b9ab185ee06ba581dd133ce Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 23 Aug 2024 13:14:33 +0200 Subject: [PATCH] qemuPrepareNVRAM: Don't attempt to create NVRAM on block device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'virFileRewrite()' which is used to setup the NVRAM image if it doesn't exist or when it is requested by the user forcibly replaces the destination file by the file it creates. For block devices this overwrites the device node file or the symlink pointing to the device node by a regular file instead of formatting it. As this not only makes the VM fail to start but also breaks user's /dev/ filesystem forbid it for now. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/qemu/qemu_process.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0815bffe3c..7a40e09d47 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4609,6 +4609,14 @@ qemuPrepareNVRAM(virQEMUDriver *driver, if (virFileExists(loader->nvram->path) && !reset_nvram) return 0; + /* virFileRewrite() would overwrite the device node-file/symlink rather than + * just write the data to it, thus block-device nvram is not yet supported */ + if (virStorageSourceIsBlockLocal(loader->nvram)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("creation or formatting of nvram type='block' is not supported")); + return -1; + } + if (!loader->nvramTemplate) { virReportError(VIR_ERR_OPERATION_FAILED, _("unable to find any master var store for loader: %1$s"),