mirror of https://gitee.com/openkylin/libvirt.git
qemu: command: Extract formatting of -drive for pflash
Extract the old way to instantiate pflash devices to hold the firmware via -drive to a separate function so that it can later be conditionally disabled when -blockdev will be used. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c78fadb57c
commit
316223b6ad
|
@ -9415,13 +9415,50 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
qemuBuldDomainLoaderPflashCommandLine(virCommandPtr cmd,
|
||||||
|
virDomainLoaderDefPtr loader)
|
||||||
|
{
|
||||||
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
int unit = 0;
|
||||||
|
|
||||||
|
if (loader->secure == VIR_TRISTATE_BOOL_YES) {
|
||||||
|
virCommandAddArgList(cmd,
|
||||||
|
"-global",
|
||||||
|
"driver=cfi.pflash01,property=secure,value=on",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
virBufferAddLit(&buf, "file=");
|
||||||
|
virQEMUBuildBufferEscapeComma(&buf, loader->path);
|
||||||
|
virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit);
|
||||||
|
unit++;
|
||||||
|
|
||||||
|
if (loader->readonly) {
|
||||||
|
virBufferAsprintf(&buf, ",readonly=%s",
|
||||||
|
virTristateSwitchTypeToString(loader->readonly));
|
||||||
|
}
|
||||||
|
|
||||||
|
virCommandAddArg(cmd, "-drive");
|
||||||
|
virCommandAddArgBuffer(cmd, &buf);
|
||||||
|
|
||||||
|
if (loader->nvram) {
|
||||||
|
virBufferFreeAndReset(&buf);
|
||||||
|
virBufferAddLit(&buf, "file=");
|
||||||
|
virQEMUBuildBufferEscapeComma(&buf, loader->nvram);
|
||||||
|
virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit);
|
||||||
|
|
||||||
|
virCommandAddArg(cmd, "-drive");
|
||||||
|
virCommandAddArgBuffer(cmd, &buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
|
qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
|
||||||
virDomainDefPtr def)
|
virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
virDomainLoaderDefPtr loader = def->os.loader;
|
virDomainLoaderDefPtr loader = def->os.loader;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
|
||||||
int unit = 0;
|
|
||||||
|
|
||||||
if (!loader)
|
if (!loader)
|
||||||
return;
|
return;
|
||||||
|
@ -9433,36 +9470,7 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_LOADER_TYPE_PFLASH:
|
case VIR_DOMAIN_LOADER_TYPE_PFLASH:
|
||||||
|
qemuBuldDomainLoaderPflashCommandLine(cmd, loader);
|
||||||
if (loader->secure == VIR_TRISTATE_BOOL_YES) {
|
|
||||||
virCommandAddArgList(cmd,
|
|
||||||
"-global",
|
|
||||||
"driver=cfi.pflash01,property=secure,value=on",
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAddLit(&buf, "file=");
|
|
||||||
virQEMUBuildBufferEscapeComma(&buf, loader->path);
|
|
||||||
virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit);
|
|
||||||
unit++;
|
|
||||||
|
|
||||||
if (loader->readonly) {
|
|
||||||
virBufferAsprintf(&buf, ",readonly=%s",
|
|
||||||
virTristateSwitchTypeToString(loader->readonly));
|
|
||||||
}
|
|
||||||
|
|
||||||
virCommandAddArg(cmd, "-drive");
|
|
||||||
virCommandAddArgBuffer(cmd, &buf);
|
|
||||||
|
|
||||||
if (loader->nvram) {
|
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
virBufferAddLit(&buf, "file=");
|
|
||||||
virQEMUBuildBufferEscapeComma(&buf, loader->nvram);
|
|
||||||
virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit);
|
|
||||||
|
|
||||||
virCommandAddArg(cmd, "-drive");
|
|
||||||
virCommandAddArgBuffer(cmd, &buf);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_LOADER_TYPE_NONE:
|
case VIR_DOMAIN_LOADER_TYPE_NONE:
|
||||||
|
|
Loading…
Reference in New Issue