qemu: Prepare BIOS/UEFI when starting a domain

https://bugzilla.redhat.com/show_bug.cgi?id=1527740

Users might use a block device as UEFI VAR store. Or even have
OVMF stored there. Therefore, when starting a domain and separate
mount namespace is used, we have to create all the /dev entries
that are configured for the domain.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Michal Privoznik 2018-01-03 08:08:07 +01:00
parent e3088bfd8e
commit 058b7fd0fe

View File

@ -9505,6 +9505,44 @@ qemuDomainSetupAllRNGs(virQEMUDriverConfigPtr cfg,
}
static int
qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
const struct qemuDomainCreateDeviceData *data)
{
virDomainLoaderDefPtr loader = vm->def->os.loader;
int ret = -1;
VIR_DEBUG("Setting up loader");
if (loader) {
switch ((virDomainLoader) loader->type) {
case VIR_DOMAIN_LOADER_TYPE_ROM:
if (qemuDomainCreateDevice(loader->path, data, false) < 0)
goto cleanup;
break;
case VIR_DOMAIN_LOADER_TYPE_PFLASH:
if (qemuDomainCreateDevice(loader->path, data, false) < 0)
goto cleanup;
if (loader->nvram &&
qemuDomainCreateDevice(loader->nvram, data, false) < 0)
goto cleanup;
break;
case VIR_DOMAIN_LOADER_TYPE_LAST:
break;
}
}
VIR_DEBUG("Setup loader");
ret = 0;
cleanup:
return ret;
}
int
qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
virSecurityManagerPtr mgr,
@ -9573,6 +9611,9 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
if (qemuDomainSetupAllRNGs(cfg, vm, &data) < 0)
goto cleanup;
if (qemuDomainSetupLoader(cfg, vm, &data) < 0)
goto cleanup;
/* Save some mount points because we want to share them with the host */
for (i = 0; i < ndevMountsPath; i++) {
struct stat sb;