mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35: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 (i = 0; i < defs->ncpus; i++) {
|
||||
if (STRCASENEQ(defs->cpus[i]->name, *name))
|
||||
if (STRCASENEQ(defs->cpus[i].name, *name))
|
||||
continue;
|
||||
|
||||
VIR_FREE(defs->cpus[i]->name);
|
||||
defs->cpus[i]->name = g_strdup(*name);
|
||||
VIR_FREE(defs->cpus[i].name);
|
||||
defs->cpus[i].name = g_strdup(*name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2487,13 +2487,13 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon,
|
||||
for (i = 0; i < defs->ncpus; i++) {
|
||||
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;
|
||||
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;
|
||||
|
||||
if (virDomainCapsCPUModelsAddSteal(models, &defs->cpus[i]->name, usable,
|
||||
&defs->cpus[i]->blockers) < 0)
|
||||
if (virDomainCapsCPUModelsAddSteal(models, &defs->cpus[i].name, usable,
|
||||
&defs->cpus[i].blockers) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -3569,9 +3569,8 @@ qemuMonitorCPUDefsFree(qemuMonitorCPUDefsPtr defs)
|
||||
return;
|
||||
|
||||
for (i = 0; i < defs->ncpus; i++) {
|
||||
g_strfreev(defs->cpus[i]->blockers);
|
||||
g_free(defs->cpus[i]->name);
|
||||
g_free(defs->cpus[i]);
|
||||
g_strfreev(defs->cpus[i].blockers);
|
||||
g_free(defs->cpus[i].name);
|
||||
}
|
||||
|
||||
g_free(defs->cpus);
|
||||
@ -3585,7 +3584,7 @@ qemuMonitorCPUDefsNew(size_t count)
|
||||
g_autoptr(qemuMonitorCPUDefs) defs = NULL;
|
||||
|
||||
defs = g_new0(qemuMonitorCPUDefs, 1);
|
||||
defs->cpus = g_new0(qemuMonitorCPUDefInfoPtr, count);
|
||||
defs->cpus = g_new0(qemuMonitorCPUDefInfo, count);
|
||||
defs->ncpus = count;
|
||||
|
||||
return g_steal_pointer(&defs);
|
||||
|
@ -1097,7 +1097,7 @@ typedef struct _qemuMonitorCPUDefs qemuMonitorCPUDefs;
|
||||
typedef qemuMonitorCPUDefs *qemuMonitorCPUDefsPtr;
|
||||
struct _qemuMonitorCPUDefs {
|
||||
size_t ncpus;
|
||||
qemuMonitorCPUDefInfoPtr *cpus;
|
||||
qemuMonitorCPUDefInfoPtr cpus;
|
||||
};
|
||||
|
||||
int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon,
|
||||
|
@ -5607,12 +5607,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
|
||||
for (i = 0; i < defs->ncpus; i++) {
|
||||
virJSONValuePtr child = virJSONValueArrayGet(data, i);
|
||||
const char *tmp;
|
||||
qemuMonitorCPUDefInfoPtr cpu;
|
||||
|
||||
if (VIR_ALLOC(cpu) < 0)
|
||||
return -1;
|
||||
|
||||
defs->cpus[i] = cpu;
|
||||
qemuMonitorCPUDefInfoPtr cpu = defs->cpus + i;
|
||||
|
||||
if (!(tmp = virJSONValueObjectGetString(child, "name"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
|
@ -463,16 +463,16 @@ testQemuMonitorJSONGetCPUDefinitions(const void *opaque)
|
||||
|
||||
#define CHECK_FULL(i, wantname, Usable) \
|
||||
do { \
|
||||
if (STRNEQ(defs->cpus[i]->name, (wantname))) { \
|
||||
if (STRNEQ(defs->cpus[i].name, (wantname))) { \
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
||||
"name %s is not %s", \
|
||||
defs->cpus[i]->name, (wantname)); \
|
||||
defs->cpus[i].name, (wantname)); \
|
||||
return -1; \
|
||||
} \
|
||||
if (defs->cpus[i]->usable != (Usable)) { \
|
||||
if (defs->cpus[i].usable != (Usable)) { \
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
||||
"%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; \
|
||||
} \
|
||||
} while (0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user