From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andre Przywara Subject: [PATCH 3/3] xl: allow parsing of both old and new cpuid syntax Date: Mon, 27 Sep 2010 12:20:05 +0200 Message-ID: <4CA06FD5.5080803@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070504050304040301080006" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini , Ian Jackson Cc: xen-devel List-Id: xen-devel@lists.xenproject.org --------------070504050304040301080006 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Allow parsing of both versions of the cpuid syntax, the old xm used one and the new one for xl. This works automatically, as the parser can tell a Python list apart from a string before processing the line. Signed-off-by: Andre Przywara -- Andre Przywara AMD-Operating System Research Center (OSRC), Dresden, Germany Tel: +49 351 448-3567-12 --------------070504050304040301080006 Content-Type: text/x-patch; name="0003-xl-enable-parser-switch-for-both-legacy-and-new-cpui.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0003-xl-enable-parser-switch-for-both-legacy-and-new-cpui.pa"; filename*1="tch" >>From c285b07724124b4e05b189587ad3a76009704b28 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Mon, 6 Sep 2010 18:01:59 +0200 Subject: [PATCH 3/3] xl: enable parser switch for both legacy and new cpuid parsers allow parsing of both versions of cpuid syntax. This works automatically, as the parser can tell a Python list apart from a string before processing the line. Signed-off-by: Andre Przywara --- tools/libxl/xl_cmdimpl.c | 87 ++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 77 insertions(+), 10 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index e9940f9..c41991d 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -637,7 +637,7 @@ static void parse_config_data(const char *configfile_filename_report, const char *buf; long l; XLU_Config *config; - XLU_ConfigList *vbds, *nics, *pcis, *cvfbs, *net2s; + XLU_ConfigList *vbds, *nics, *pcis, *cvfbs, *net2s, *cpuids; int pci_power_mgmt = 0; int pci_msitranslate = 1; int e; @@ -1075,15 +1075,82 @@ skip_vfb: } } - if (!xlu_cfg_get_string(config, "cpuid", &buf)) { - char *buf2, *p, *strtok_ptr; + switch (xlu_cfg_get_list(config, "cpuid", &cpuids, 0, 1)) { + case 0: + { + int i; + char *errstr; - buf2 = strdup(buf); - p = strtok_r(buf2, ",", &strtok_ptr); - for (p = strtok_r(NULL, ",", &strtok_ptr); p != NULL; - p = strtok_r(NULL, ",", &strtok_ptr)) - libxl_cpuid_parse_config(&b_info->cpuid, p); - free(buf2); + for (i = 0; (buf = xlu_cfg_get_listitem(cpuids, i)) != NULL; i++) { + e = libxl_cpuid_parse_config_xend(&b_info->cpuid, buf); + switch (e) { + case 0: continue; + case 1: + errstr = "illegal leaf number"; + break; + case 2: + errstr = "illegal subleaf number"; + break; + case 3: + errstr = "missing colon"; + break; + case 4: + errstr = "invalid register name (must be e[abcd]x)"; + break; + case 5: + errstr = "policy string must be exactly 32 characters long"; + break; + default: + errstr = "unknown error"; + break; + } + fprintf(stderr, "while parsing CPUID line: \"%s\":\n", buf); + fprintf(stderr, " error #%i: %s\n", e, errstr); + } + } + break; + case EINVAL: /* config option is not a list, parse as a string */ + if (!xlu_cfg_get_string(config, "cpuid", &buf)) { + char *buf2, *p, *errstr, *strtok_ptr; + + buf2 = strdup(buf); + p = strtok_r(buf2, ",", &strtok_ptr); + if (p == NULL) { + free(buf2); + break; + } + if (strcmp(p, "host")) { + fprintf(stderr, "while parsing CPUID string: \"%s\":\n", buf); + fprintf(stderr, " error: first word must be \"host\"\n"); + free(buf2); + break; + } + for (p = strtok_r(NULL, ",", &strtok_ptr); p != NULL; + p = strtok_r(NULL, ",", &strtok_ptr)) { + e = libxl_cpuid_parse_config(&b_info->cpuid, p); + switch (e) { + case 0: continue; + case 1: + errstr = "missing \"=\" in key=value"; + break; + case 2: + errstr = "unknown CPUID flag name"; + break; + case 3: + errstr = "illegal CPUID value (must be: [0|1|x|k|s])"; + break; + default: + errstr = "unknown error"; + break; + } + fprintf(stderr, "while parsing CPUID flag: \"%s\":\n", p); + fprintf(stderr, " error #%i: %s\n", e, errstr); + } + free(buf2); + } + break; + default: + break; } if (c_info->hvm == 1) { -- 1.6.4 --------------070504050304040301080006 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------070504050304040301080006--