1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-09 01:18:00 +03:00

qemu: Do not pass qemuCaps to virQEMUCapsCPUFeature{To,From}QEMU

The only part of qemuCaps both functions are interested in is the CPU
architecture. Changing them to expect just virArch makes the functions
more reusable.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jiri Denemark 2022-09-30 18:34:05 +02:00
parent 0cc8e87520
commit 6f927dce93
8 changed files with 22 additions and 38 deletions

View File

@ -3108,7 +3108,7 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps,
if (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO)
continue;
list[n++] = g_strdup(virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name));
list[n++] = g_strdup(virQEMUCapsCPUFeatureFromQEMU(qemuCaps->arch, prop->name));
}
*features = g_steal_pointer(&list);
@ -3434,14 +3434,14 @@ virQEMUCapsCPUFeatureTranslationTable virQEMUCapsCPUFeaturesX86[] = {
static const char *
virQEMUCapsCPUFeatureTranslate(virQEMUCaps *qemuCaps,
virQEMUCapsCPUFeatureTranslate(virArch arch,
const char *feature,
bool reversed)
{
virQEMUCapsCPUFeatureTranslationTable *table = NULL;
virQEMUCapsCPUFeatureTranslationTable *entry;
if (ARCH_IS_X86(qemuCaps->arch))
if (ARCH_IS_X86(arch))
table = virQEMUCapsCPUFeaturesX86;
if (!table ||
@ -3460,18 +3460,18 @@ virQEMUCapsCPUFeatureTranslate(virQEMUCaps *qemuCaps,
const char *
virQEMUCapsCPUFeatureToQEMU(virQEMUCaps *qemuCaps,
virQEMUCapsCPUFeatureToQEMU(virArch arch,
const char *feature)
{
return virQEMUCapsCPUFeatureTranslate(qemuCaps, feature, false);
return virQEMUCapsCPUFeatureTranslate(arch, feature, false);
}
const char *
virQEMUCapsCPUFeatureFromQEMU(virQEMUCaps *qemuCaps,
virQEMUCapsCPUFeatureFromQEMU(virArch arch,
const char *feature)
{
return virQEMUCapsCPUFeatureTranslate(qemuCaps, feature, true);
return virQEMUCapsCPUFeatureTranslate(arch, feature, true);
}
@ -3510,7 +3510,7 @@ virQEMUCapsInitCPUModelS390(virQEMUCaps *qemuCaps,
for (i = 0; i < modelInfo->nprops; i++) {
virCPUFeatureDef *feature = cpu->features + cpu->nfeatures;
qemuMonitorCPUProperty *prop = modelInfo->props + i;
const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name);
const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps->arch, prop->name);
if (prop->type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN)
continue;
@ -3545,7 +3545,7 @@ virQEMUCapsGetCPUModelX86Data(virQEMUCaps *qemuCaps,
for (i = 0; i < model->nprops; i++) {
qemuMonitorCPUProperty *prop = model->props + i;
const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name);
const char *name = virQEMUCapsCPUFeatureFromQEMU(qemuCaps->arch, prop->name);
switch (prop->type) {
case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN:

View File

@ -838,11 +838,11 @@ bool virQEMUCapsCPUFilterFeatures(const char *name,
void *opaque);
const char *
virQEMUCapsCPUFeatureToQEMU(virQEMUCaps *qemuCaps,
virQEMUCapsCPUFeatureToQEMU(virArch arch,
const char *feature);
const char *
virQEMUCapsCPUFeatureFromQEMU(virQEMUCaps *qemuCaps,
virQEMUCapsCPUFeatureFromQEMU(virArch arch,
const char *feature);
virSEVCapability *

View File

@ -6111,7 +6111,7 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
for (i = 0; i < cpu->nfeatures; i++) {
const char *featname =
virQEMUCapsCPUFeatureToQEMU(qemuCaps, cpu->features[i].name);
virQEMUCapsCPUFeatureToQEMU(def->os.arch, cpu->features[i].name);
switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
case VIR_CPU_FEATURE_FORCE:
case VIR_CPU_FEATURE_REQUIRE:

View File

@ -3633,12 +3633,11 @@ qemuMonitorGetGuestCPU(qemuMonitor *mon,
virArch arch,
const char *cpuQOMPath,
qemuMonitorCPUFeatureTranslationCallback translate,
void *opaque,
virCPUData **enabled,
virCPUData **disabled)
{
VIR_DEBUG("arch=%s cpuQOMPath=%s translate=%p opaque=%p enabled=%p disabled=%p",
virArchToString(arch), cpuQOMPath, translate, opaque, enabled, disabled);
VIR_DEBUG("arch=%s cpuQOMPath=%s translate=%p enabled=%p disabled=%p",
virArchToString(arch), cpuQOMPath, translate, enabled, disabled);
QEMU_CHECK_MONITOR(mon);
@ -3646,7 +3645,7 @@ qemuMonitorGetGuestCPU(qemuMonitor *mon,
if (disabled)
*disabled = NULL;
return qemuMonitorJSONGetGuestCPU(mon, arch, cpuQOMPath, translate, opaque,
return qemuMonitorJSONGetGuestCPU(mon, arch, cpuQOMPath, translate,
enabled, disabled);
}

View File

@ -1219,14 +1219,13 @@ int qemuMonitorGetGuestCPUx86(qemuMonitor *mon,
virCPUData **data,
virCPUData **disabled);
typedef const char *(*qemuMonitorCPUFeatureTranslationCallback)(const char *name,
void *opaque);
typedef const char *(*qemuMonitorCPUFeatureTranslationCallback)(virArch arch,
const char *name);
int qemuMonitorGetGuestCPU(qemuMonitor *mon,
virArch arch,
const char *cpuQOMPath,
qemuMonitorCPUFeatureTranslationCallback translate,
void *opaque,
virCPUData **enabled,
virCPUData **disabled);

View File

@ -6781,7 +6781,6 @@ static int
qemuMonitorJSONGetCPUData(qemuMonitor *mon,
const char *cpuQOMPath,
qemuMonitorCPUFeatureTranslationCallback translate,
void *opaque,
virCPUData *data)
{
qemuMonitorJSONObjectProperty prop = { .type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN };
@ -6801,7 +6800,7 @@ qemuMonitorJSONGetCPUData(qemuMonitor *mon,
continue;
if (translate)
name = translate(name, opaque);
name = translate(data->arch, name);
if (virCPUDataAddFeature(data, name) < 0)
return -1;
@ -6815,7 +6814,6 @@ static int
qemuMonitorJSONGetCPUDataDisabled(qemuMonitor *mon,
const char *cpuQOMPath,
qemuMonitorCPUFeatureTranslationCallback translate,
void *opaque,
virCPUData *data)
{
g_auto(GStrv) props = NULL;
@ -6829,7 +6827,7 @@ qemuMonitorJSONGetCPUDataDisabled(qemuMonitor *mon,
const char *name = *p;
if (translate)
name = translate(name, opaque);
name = translate(data->arch, name);
if (virCPUDataAddFeature(data, name) < 0)
return -1;
@ -6859,7 +6857,6 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon,
virArch arch,
const char *cpuQOMPath,
qemuMonitorCPUFeatureTranslationCallback translate,
void *opaque,
virCPUData **enabled,
virCPUData **disabled)
{
@ -6870,11 +6867,11 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon,
!(cpuDisabled = virCPUDataNew(arch)))
return -1;
if (qemuMonitorJSONGetCPUData(mon, cpuQOMPath, translate, opaque, cpuEnabled) < 0)
if (qemuMonitorJSONGetCPUData(mon, cpuQOMPath, translate, cpuEnabled) < 0)
return -1;
if (disabled &&
qemuMonitorJSONGetCPUDataDisabled(mon, cpuQOMPath, translate, opaque, cpuDisabled) < 0)
qemuMonitorJSONGetCPUDataDisabled(mon, cpuQOMPath, translate, cpuDisabled) < 0)
return -1;
*enabled = g_steal_pointer(&cpuEnabled);

View File

@ -605,7 +605,6 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon,
virArch arch,
const char *cpuQOMPath,
qemuMonitorCPUFeatureTranslationCallback translate,
void *opaque,
virCPUData **enabled,
virCPUData **disabled);

View File

@ -4295,16 +4295,6 @@ qemuProcessVerifyCPUFeatures(virDomainDef *def,
}
static const char *
qemuProcessTranslateCPUFeatures(const char *name,
void *opaque)
{
virQEMUCaps *qemuCaps = opaque;
return virQEMUCapsCPUFeatureFromQEMU(qemuCaps, name);
}
/* returns the QOM path to the first vcpu */
static const char *
qemuProcessGetVCPUQOMPath(virDomainObj *vm)
@ -4349,7 +4339,7 @@ qemuProcessFetchGuestCPU(virDomainObj *vm,
rc = qemuMonitorGetGuestCPU(priv->mon,
vm->def->os.arch,
cpuQOMPath,
qemuProcessTranslateCPUFeatures, priv->qemuCaps,
virQEMUCapsCPUFeatureFromQEMU,
&dataEnabled, &dataDisabled);
} else {
rc = qemuMonitorGetGuestCPUx86(priv->mon, cpuQOMPath, &dataEnabled, &dataDisabled);