]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuPrepareNVRAM: Don't attempt to create NVRAM on block device
authorPeter Krempa <pkrempa@redhat.com>
Fri, 23 Aug 2024 11:14:33 +0000 (13:14 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 15 Nov 2024 08:42:03 +0000 (09:42 +0100)
'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 <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_process.c

index 0815bffe3c1c6d879ca67c0dae8069ce50feb3e9..7a40e09d47d58fab15b837a4d68c00546dfe331a 100644 (file)
@@ -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"),