qemu: Instantiate pflash via -machine when using blockdev

Install the convertor function which enables the internals that will use
-blockdev to make qemu open the firmware image and stop using -drive.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Peter Krempa 2019-11-15 12:27:42 +01:00
parent c8eb99eebf
commit 86085c9a2f
2 changed files with 16 additions and 4 deletions

View File

@ -9425,7 +9425,8 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
static void static void
qemuBuldDomainLoaderPflashCommandLine(virCommandPtr cmd, qemuBuldDomainLoaderPflashCommandLine(virCommandPtr cmd,
virDomainLoaderDefPtr loader) virDomainLoaderDefPtr loader,
virQEMUCapsPtr qemuCaps)
{ {
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
int unit = 0; int unit = 0;
@ -9437,6 +9438,10 @@ qemuBuldDomainLoaderPflashCommandLine(virCommandPtr cmd,
NULL); NULL);
} }
/* with blockdev we instantiate the pflash when formatting -machine */
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV))
return;
virBufferAddLit(&buf, "file="); virBufferAddLit(&buf, "file=");
virQEMUBuildBufferEscapeComma(&buf, loader->path); virQEMUBuildBufferEscapeComma(&buf, loader->path);
virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit); virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit);
@ -9464,7 +9469,8 @@ qemuBuldDomainLoaderPflashCommandLine(virCommandPtr cmd,
static void static void
qemuBuildDomainLoaderCommandLine(virCommandPtr cmd, qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
virDomainDefPtr def) virDomainDefPtr def,
virQEMUCapsPtr qemuCaps)
{ {
virDomainLoaderDefPtr loader = def->os.loader; virDomainLoaderDefPtr loader = def->os.loader;
@ -9478,7 +9484,7 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
break; break;
case VIR_DOMAIN_LOADER_TYPE_PFLASH: case VIR_DOMAIN_LOADER_TYPE_PFLASH:
qemuBuldDomainLoaderPflashCommandLine(cmd, loader); qemuBuldDomainLoaderPflashCommandLine(cmd, loader, qemuCaps);
break; break;
case VIR_DOMAIN_LOADER_TYPE_NONE: case VIR_DOMAIN_LOADER_TYPE_NONE:
@ -10263,7 +10269,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildCpuCommandLine(cmd, driver, def, qemuCaps) < 0) if (qemuBuildCpuCommandLine(cmd, driver, def, qemuCaps) < 0)
return NULL; return NULL;
qemuBuildDomainLoaderCommandLine(cmd, def); qemuBuildDomainLoaderCommandLine(cmd, def, qemuCaps);
if (!migrateURI && !snapshot && qemuDomainAlignMemorySizes(def) < 0) if (!migrateURI && !snapshot && qemuDomainAlignMemorySizes(def) < 0)
return NULL; return NULL;

View File

@ -6291,6 +6291,8 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
VIR_DEBUG("Prepare bios/uefi paths"); VIR_DEBUG("Prepare bios/uefi paths");
if (qemuFirmwareFillDomain(driver, vm, flags) < 0) if (qemuFirmwareFillDomain(driver, vm, flags) < 0)
goto cleanup; goto cleanup;
if (qemuDomainInitializePflashStorageSource(vm) < 0)
goto cleanup;
VIR_DEBUG("Preparing external devices"); VIR_DEBUG("Preparing external devices");
if (qemuExtDevicesPrepareDomain(driver, vm) < 0) if (qemuExtDevicesPrepareDomain(driver, vm) < 0)
@ -8020,6 +8022,10 @@ qemuProcessReconnect(void *opaque)
if (qemuDomainPerfRestart(obj) < 0) if (qemuDomainPerfRestart(obj) < 0)
goto error; goto error;
/* recreate the pflash storage sources */
if (qemuDomainInitializePflashStorageSource(obj) < 0)
goto error;
/* XXX: Need to change as long as lock is introduced for /* XXX: Need to change as long as lock is introduced for
* qemu_driver->sharedDevices. * qemu_driver->sharedDevices.
*/ */