mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
Deal with CPU models in []
Qemu committed a patch which list some CPU names in [] when asked for supported CPUs (qemu -cpu ?). Yet, it needs such CPUs to be passed without those square braces. When probing for supported CPU models, we can just strip the square braces and pretend we have never seen them.
This commit is contained in:
parent
9fbb810cf4
commit
e07314f4c1
@ -628,7 +628,9 @@ typedef int
|
||||
const char ***retcpus);
|
||||
|
||||
/* Format:
|
||||
* <arch> <model>
|
||||
* <arch> <model>
|
||||
* qemu-0.13 encloses some model names in []:
|
||||
* <arch> [<model>]
|
||||
*/
|
||||
static int
|
||||
qemudParseX86Models(const char *output,
|
||||
@ -661,15 +663,22 @@ qemudParseX86Models(const char *output,
|
||||
continue;
|
||||
|
||||
if (retcpus) {
|
||||
unsigned int len;
|
||||
|
||||
if (VIR_REALLOC_N(cpus, count + 1) < 0)
|
||||
goto error;
|
||||
|
||||
if (next)
|
||||
cpus[count] = strndup(p, next - p - 1);
|
||||
len = next - p - 1;
|
||||
else
|
||||
cpus[count] = strdup(p);
|
||||
len = strlen(p);
|
||||
|
||||
if (!cpus[count])
|
||||
if (len > 2 && *p == '[' && p[len - 1] == ']') {
|
||||
p++;
|
||||
len -= 2;
|
||||
}
|
||||
|
||||
if (!(cpus[count] = strndup(p, len)))
|
||||
goto error;
|
||||
}
|
||||
count++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user