mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
qemu: Flatten qemuMonitorCPUDefs.cpus
Let's store qemuMonitorCPUDefInfo directly in the array of CPUs in qemuMonitorCPUDefs rather then using an array of pointers. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3aa53dcf01
commit
7e0a6ac04b
@ -2472,11 +2472,11 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
for (name = libvirtModels; name && *name; name++) {
|
for (name = libvirtModels; name && *name; name++) {
|
||||||
for (i = 0; i < defs->ncpus; i++) {
|
for (i = 0; i < defs->ncpus; i++) {
|
||||||
if (STRCASENEQ(defs->cpus[i]->name, *name))
|
if (STRCASENEQ(defs->cpus[i].name, *name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
VIR_FREE(defs->cpus[i]->name);
|
VIR_FREE(defs->cpus[i].name);
|
||||||
defs->cpus[i]->name = g_strdup(*name);
|
defs->cpus[i].name = g_strdup(*name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2487,13 +2487,13 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon,
|
|||||||
for (i = 0; i < defs->ncpus; i++) {
|
for (i = 0; i < defs->ncpus; i++) {
|
||||||
virDomainCapsCPUUsable usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
|
virDomainCapsCPUUsable usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
|
||||||
|
|
||||||
if (defs->cpus[i]->usable == VIR_TRISTATE_BOOL_YES)
|
if (defs->cpus[i].usable == VIR_TRISTATE_BOOL_YES)
|
||||||
usable = VIR_DOMCAPS_CPU_USABLE_YES;
|
usable = VIR_DOMCAPS_CPU_USABLE_YES;
|
||||||
else if (defs->cpus[i]->usable == VIR_TRISTATE_BOOL_NO)
|
else if (defs->cpus[i].usable == VIR_TRISTATE_BOOL_NO)
|
||||||
usable = VIR_DOMCAPS_CPU_USABLE_NO;
|
usable = VIR_DOMCAPS_CPU_USABLE_NO;
|
||||||
|
|
||||||
if (virDomainCapsCPUModelsAddSteal(models, &defs->cpus[i]->name, usable,
|
if (virDomainCapsCPUModelsAddSteal(models, &defs->cpus[i].name, usable,
|
||||||
&defs->cpus[i]->blockers) < 0)
|
&defs->cpus[i].blockers) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3569,9 +3569,8 @@ qemuMonitorCPUDefsFree(qemuMonitorCPUDefsPtr defs)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < defs->ncpus; i++) {
|
for (i = 0; i < defs->ncpus; i++) {
|
||||||
g_strfreev(defs->cpus[i]->blockers);
|
g_strfreev(defs->cpus[i].blockers);
|
||||||
g_free(defs->cpus[i]->name);
|
g_free(defs->cpus[i].name);
|
||||||
g_free(defs->cpus[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(defs->cpus);
|
g_free(defs->cpus);
|
||||||
@ -3585,7 +3584,7 @@ qemuMonitorCPUDefsNew(size_t count)
|
|||||||
g_autoptr(qemuMonitorCPUDefs) defs = NULL;
|
g_autoptr(qemuMonitorCPUDefs) defs = NULL;
|
||||||
|
|
||||||
defs = g_new0(qemuMonitorCPUDefs, 1);
|
defs = g_new0(qemuMonitorCPUDefs, 1);
|
||||||
defs->cpus = g_new0(qemuMonitorCPUDefInfoPtr, count);
|
defs->cpus = g_new0(qemuMonitorCPUDefInfo, count);
|
||||||
defs->ncpus = count;
|
defs->ncpus = count;
|
||||||
|
|
||||||
return g_steal_pointer(&defs);
|
return g_steal_pointer(&defs);
|
||||||
|
@ -1097,7 +1097,7 @@ typedef struct _qemuMonitorCPUDefs qemuMonitorCPUDefs;
|
|||||||
typedef qemuMonitorCPUDefs *qemuMonitorCPUDefsPtr;
|
typedef qemuMonitorCPUDefs *qemuMonitorCPUDefsPtr;
|
||||||
struct _qemuMonitorCPUDefs {
|
struct _qemuMonitorCPUDefs {
|
||||||
size_t ncpus;
|
size_t ncpus;
|
||||||
qemuMonitorCPUDefInfoPtr *cpus;
|
qemuMonitorCPUDefInfoPtr cpus;
|
||||||
};
|
};
|
||||||
|
|
||||||
int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon,
|
int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon,
|
||||||
|
@ -5607,12 +5607,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
|
|||||||
for (i = 0; i < defs->ncpus; i++) {
|
for (i = 0; i < defs->ncpus; i++) {
|
||||||
virJSONValuePtr child = virJSONValueArrayGet(data, i);
|
virJSONValuePtr child = virJSONValueArrayGet(data, i);
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
qemuMonitorCPUDefInfoPtr cpu;
|
qemuMonitorCPUDefInfoPtr cpu = defs->cpus + i;
|
||||||
|
|
||||||
if (VIR_ALLOC(cpu) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
defs->cpus[i] = cpu;
|
|
||||||
|
|
||||||
if (!(tmp = virJSONValueObjectGetString(child, "name"))) {
|
if (!(tmp = virJSONValueObjectGetString(child, "name"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
@ -463,16 +463,16 @@ testQemuMonitorJSONGetCPUDefinitions(const void *opaque)
|
|||||||
|
|
||||||
#define CHECK_FULL(i, wantname, Usable) \
|
#define CHECK_FULL(i, wantname, Usable) \
|
||||||
do { \
|
do { \
|
||||||
if (STRNEQ(defs->cpus[i]->name, (wantname))) { \
|
if (STRNEQ(defs->cpus[i].name, (wantname))) { \
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
||||||
"name %s is not %s", \
|
"name %s is not %s", \
|
||||||
defs->cpus[i]->name, (wantname)); \
|
defs->cpus[i].name, (wantname)); \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
if (defs->cpus[i]->usable != (Usable)) { \
|
if (defs->cpus[i].usable != (Usable)) { \
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
||||||
"%s: expecting usable flag %d, got %d", \
|
"%s: expecting usable flag %d, got %d", \
|
||||||
defs->cpus[i]->name, Usable, defs->cpus[i]->usable); \
|
defs->cpus[i].name, Usable, defs->cpus[i].usable); \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
Loading…
Reference in New Issue
Block a user