mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Fix up the default machine type for QMP probing
The default machine type must be stored in the first element of the caps->machineTypes array. This was done for help output parsing but not for QMP probing. Added a helper function qemuSetDefaultMachine to apply the same fix up for both probing methods. Further, it was necessary to set caps->nmachineTypes after QMP probing. Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
This commit is contained in:
parent
d01e427e01
commit
3c465728bf
@ -292,6 +292,23 @@ qemuCapsProbeCommand(const char *qemu,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
qemuSetDefaultMachine(qemuCapsPtr caps,
|
||||||
|
size_t defIdx)
|
||||||
|
{
|
||||||
|
char *name = caps->machineTypes[defIdx];
|
||||||
|
char *alias = caps->machineAliases[defIdx];
|
||||||
|
|
||||||
|
memmove(caps->machineTypes + 1,
|
||||||
|
caps->machineTypes,
|
||||||
|
sizeof(caps->machineTypes[0]) * defIdx);
|
||||||
|
memmove(caps->machineAliases + 1,
|
||||||
|
caps->machineAliases,
|
||||||
|
sizeof(caps->machineAliases[0]) * defIdx);
|
||||||
|
caps->machineTypes[0] = name;
|
||||||
|
caps->machineAliases[0] = alias;
|
||||||
|
}
|
||||||
|
|
||||||
/* Format is:
|
/* Format is:
|
||||||
* <machine> <desc> [(default)|(alias of <canonical>)]
|
* <machine> <desc> [(default)|(alias of <canonical>)]
|
||||||
*/
|
*/
|
||||||
@ -352,18 +369,8 @@ qemuCapsParseMachineTypesStr(const char *output,
|
|||||||
} while ((p = next));
|
} while ((p = next));
|
||||||
|
|
||||||
|
|
||||||
if (defIdx != 0) {
|
if (defIdx)
|
||||||
char *name = caps->machineTypes[defIdx];
|
qemuSetDefaultMachine(caps, defIdx);
|
||||||
char *alias = caps->machineAliases[defIdx];
|
|
||||||
memmove(caps->machineTypes + 1,
|
|
||||||
caps->machineTypes,
|
|
||||||
sizeof(caps->machineTypes[0]) * defIdx);
|
|
||||||
memmove(caps->machineAliases + 1,
|
|
||||||
caps->machineAliases,
|
|
||||||
sizeof(caps->machineAliases[0]) * defIdx);
|
|
||||||
caps->machineTypes[0] = name;
|
|
||||||
caps->machineAliases[0] = alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -2020,6 +2027,7 @@ qemuCapsProbeQMPMachineTypes(qemuCapsPtr caps,
|
|||||||
int nmachines = 0;
|
int nmachines = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
size_t defIdx = 0;
|
||||||
|
|
||||||
if ((nmachines = qemuMonitorGetMachines(mon, &machines)) < 0)
|
if ((nmachines = qemuMonitorGetMachines(mon, &machines)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2049,7 +2057,13 @@ qemuCapsProbeQMPMachineTypes(qemuCapsPtr caps,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (machines[i]->isDefault)
|
||||||
|
defIdx = i;
|
||||||
}
|
}
|
||||||
|
caps->nmachineTypes = nmachines;
|
||||||
|
|
||||||
|
if (defIdx)
|
||||||
|
qemuSetDefaultMachine(caps, defIdx);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user