mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
drivers: Reject unsupported firmware formats
This ensures that, as we add support for more formats at the domain XML level, we don't accidentally cause drivers to misbehave or users to get confused. All existing drivers support the raw format, and supporting additional formats will require explicit opt-in on the driver's part. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
1a6469e81f
commit
9c39840673
@ -80,6 +80,13 @@ bhyveFirmwareFillDomain(bhyveConn *driver,
|
||||
if (!def->os.loader)
|
||||
def->os.loader = virDomainLoaderDefNew();
|
||||
|
||||
if (def->os.loader->format != VIR_STORAGE_FILE_RAW) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported loader format '%s'"),
|
||||
virStorageFileFormatTypeToString(def->os.loader->format));
|
||||
return -1;
|
||||
}
|
||||
|
||||
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
|
||||
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
|
||||
|
||||
|
@ -656,6 +656,13 @@ libxlMakeDomBuildInfo(virDomainDef *def,
|
||||
b_info->u.hvm.bios = LIBXL_BIOS_TYPE_OVMF;
|
||||
}
|
||||
|
||||
if (def->os.loader && def->os.loader->format != VIR_STORAGE_FILE_RAW) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported loader format '%s'"),
|
||||
virStorageFileFormatTypeToString(def->os.loader->format));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (def->emulator) {
|
||||
if (!virFileExists(def->emulator)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
|
@ -1545,6 +1545,7 @@ qemuFirmwareFillDomain(virQEMUDriver *driver,
|
||||
{
|
||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||
virDomainLoaderDef *loader = def->os.loader;
|
||||
virStorageSource *nvram = loader ? loader->nvram : NULL;
|
||||
bool autoSelection = (def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_NONE);
|
||||
int ret;
|
||||
|
||||
@ -1559,6 +1560,21 @@ qemuFirmwareFillDomain(virQEMUDriver *driver,
|
||||
if (virDomainDefOSValidate(def, NULL) < 0)
|
||||
return -1;
|
||||
|
||||
if (loader &&
|
||||
loader->format != VIR_STORAGE_FILE_RAW) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported loader format '%s'"),
|
||||
virStorageFileFormatTypeToString(loader->format));
|
||||
return -1;
|
||||
}
|
||||
if (nvram &&
|
||||
nvram->format != VIR_STORAGE_FILE_RAW) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported nvram format '%s'"),
|
||||
virStorageFileFormatTypeToString(nvram->format));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If firmware autoselection is disabled and the loader is a ROM
|
||||
* instead of a PFLASH device, then we're using BIOS and we don't
|
||||
* need any information at all */
|
||||
|
Loading…
x
Reference in New Issue
Block a user