summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrerna Saxena <prerna@linux.vnet.ibm.com>2011-10-03 06:01:33 -0700
committerStefan Berger <stefanb@us.ibm.com>2011-12-08 08:39:26 -0500
commit9bb8064dff69ac3edf4968a9e71606aad101f617 (patch)
tree109c7aa0778952bbf4ff8d5b3069a476c9938212
parent82ff25e108e2dfcb276d8024ae94ba44d711aba6 (diff)
downloadlibvirt-9bb8064dff69ac3edf4968a9e71606aad101f617.tar.gz
Add support for ppc64 qemu
This enables libvirt to select the correct qemu binary (qemu-system-ppc64) for a guest vm based on arch 'ppc64'. Also, libvirt is enabled to correctly parse the list of supported PowerPC CPUs, generated by running 'qemu-system-ppc64 -cpu ?' Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> Acked-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
-rw-r--r--src/qemu/qemu_capabilities.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f66cc9752f..04ad104777 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -186,6 +186,7 @@ static const struct qemu_arch_info const arch_info_hvm[] = {
{ "mipsel", 32, NULL, "qemu-system-mipsel", NULL, NULL, 0 },
{ "sparc", 32, NULL, "qemu-system-sparc", NULL, NULL, 0 },
{ "ppc", 32, NULL, "qemu-system-ppc", NULL, NULL, 0 },
+ { "ppc64", 64, NULL, "qemu-system-ppc64", NULL, NULL, 0 },
{ "itanium", 64, NULL, "qemu-system-ia64", NULL, NULL, 0 },
{ "s390x", 64, NULL, "qemu-system-s390x", NULL, NULL, 0 },
};
@@ -478,6 +479,77 @@ error:
return -1;
}
+/* ppc64 parser.
+ * Format : PowerPC <machine> <description>
+ */
+static int
+qemuCapsParsePPCModels(const char *output,
+ unsigned int *retcount,
+ const char ***retcpus)
+{
+ const char *p = output;
+ const char *next;
+ unsigned int count = 0;
+ const char **cpus = NULL;
+ int i;
+
+ if (!retcpus) {
+ VIR_DEBUG("No retcpus specified");
+ return -1;
+ }
+
+ do {
+ const char *t;
+
+ if ((next = strchr(p, '\n')))
+ next++;
+
+ if (!STRPREFIX(p, "PowerPC "))
+ continue;
+
+ /* Skip the preceding sub-string "PowerPC " */
+ p += 8;
+
+ /*Malformed string, does not obey the format 'PowerPC <model> <desc>'*/
+ if (!(t = strchr(p, ' ')) || (next && t >= next))
+ continue;
+
+ if (*p == '\0')
+ break;
+
+ if (*p == '\n')
+ continue;
+
+ if (retcpus) {
+ unsigned int len;
+
+ if (VIR_REALLOC_N(cpus, count + 1) < 0)
+ virReportOOMError();
+ goto error;
+
+ len = t - p - 1;
+
+ if (!(cpus[count] = strndup(p, len)))
+ virReportOOMError();
+ goto error;
+ }
+ count++;
+ } while ((p = next));
+
+ if (retcount)
+ *retcount = count;
+ if (retcpus)
+ *retcpus = cpus;
+ return 0;
+
+error:
+ if (cpus) {
+ for (i = 0; i < count; i++)
+ VIR_FREE(cpus[i]);
+ }
+ VIR_FREE(cpus);
+ return -1;
+}
int
qemuCapsProbeCPUModels(const char *qemu,
@@ -498,6 +570,8 @@ qemuCapsProbeCPUModels(const char *qemu,
if (STREQ(arch, "i686") || STREQ(arch, "x86_64"))
parse = qemuCapsParseX86Models;
+ else if (STREQ(arch, "ppc64"))
+ parse = qemuCapsParsePPCModels;
else {
VIR_DEBUG("don't know how to parse %s CPU models", arch);
return 0;