qemuPrepareNVRAM: Don't attempt to create NVRAM on block device

'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>
This commit is contained in:
Peter Krempa 2024-08-23 13:14:33 +02:00
parent fde04774db
commit 273157dd9f

View File

@ -4609,6 +4609,14 @@ qemuPrepareNVRAM(virQEMUDriver *driver,
if (virFileExists(loader->nvram->path) && !reset_nvram) if (virFileExists(loader->nvram->path) && !reset_nvram)
return 0; 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) { if (!loader->nvramTemplate) {
virReportError(VIR_ERR_OPERATION_FAILED, virReportError(VIR_ERR_OPERATION_FAILED,
_("unable to find any master var store for loader: %1$s"), _("unable to find any master var store for loader: %1$s"),