mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuBuildIOMMUCommandLine: Generate via JSON
QEMU declares the following types for fields we control: intremap=<OnOffAuto> - on/off/auto (default: "auto") caching-mode=<bool> - (default: false) eim=<OnOffAuto> - on/off/auto (default: "auto") device-iotlb=<bool> - (default: false) aw-bits=<uint8> - (default: 39) Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5d51f836b0
commit
cefa20b727
@ -6486,7 +6486,8 @@ qemuBuildBootCommandLine(virCommand *cmd,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
qemuBuildIOMMUCommandLine(virCommand *cmd,
|
qemuBuildIOMMUCommandLine(virCommand *cmd,
|
||||||
const virDomainDef *def)
|
const virDomainDef *def,
|
||||||
|
virQEMUCaps *qemuCaps)
|
||||||
{
|
{
|
||||||
const virDomainIOMMUDef *iommu = def->iommu;
|
const virDomainIOMMUDef *iommu = def->iommu;
|
||||||
|
|
||||||
@ -6495,31 +6496,22 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
|
|||||||
|
|
||||||
switch (iommu->model) {
|
switch (iommu->model) {
|
||||||
case VIR_DOMAIN_IOMMU_MODEL_INTEL: {
|
case VIR_DOMAIN_IOMMU_MODEL_INTEL: {
|
||||||
g_auto(virBuffer) opts = VIR_BUFFER_INITIALIZER;
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
|
|
||||||
virBufferAddLit(&opts, "intel-iommu");
|
if (virJSONValueObjectCreate(&props,
|
||||||
if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
|
"s:driver", "intel-iommu",
|
||||||
virBufferAsprintf(&opts, ",intremap=%s",
|
"S:intremap", qemuOnOffAuto(iommu->intremap),
|
||||||
virTristateSwitchTypeToString(iommu->intremap));
|
"T:caching-mode", iommu->caching_mode,
|
||||||
}
|
"S:eim", qemuOnOffAuto(iommu->eim),
|
||||||
if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) {
|
"T:device-iotlb", iommu->iotlb,
|
||||||
virBufferAsprintf(&opts, ",caching-mode=%s",
|
"z:aw-bits", iommu->aw_bits,
|
||||||
virTristateSwitchTypeToString(iommu->caching_mode));
|
NULL) < 0)
|
||||||
}
|
return -1;
|
||||||
if (iommu->eim != VIR_TRISTATE_SWITCH_ABSENT) {
|
|
||||||
virBufferAsprintf(&opts, ",eim=%s",
|
|
||||||
virTristateSwitchTypeToString(iommu->eim));
|
|
||||||
}
|
|
||||||
if (iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT) {
|
|
||||||
virBufferAsprintf(&opts, ",device-iotlb=%s",
|
|
||||||
virTristateSwitchTypeToString(iommu->iotlb));
|
|
||||||
}
|
|
||||||
if (iommu->aw_bits > 0)
|
|
||||||
virBufferAsprintf(&opts, ",aw-bits=%d", iommu->aw_bits);
|
|
||||||
|
|
||||||
virCommandAddArg(cmd, "-device");
|
if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
|
||||||
virCommandAddArgBuffer(cmd, &opts);
|
return -1;
|
||||||
break;
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
|
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
|
||||||
@ -10705,7 +10697,7 @@ qemuBuildCommandLine(virQEMUDriver *driver,
|
|||||||
if (qemuBuildBootCommandLine(cmd, def) < 0)
|
if (qemuBuildBootCommandLine(cmd, def) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (qemuBuildIOMMUCommandLine(cmd, def) < 0)
|
if (qemuBuildIOMMUCommandLine(cmd, def, qemuCaps) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (qemuBuildGlobalControllerCommandLine(cmd, def) < 0)
|
if (qemuBuildGlobalControllerCommandLine(cmd, def) < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user