From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony PERARD Subject: Re: [PATCH 1/2] libxl, Introduce the command line handler for the new qemu. Date: Thu, 05 Aug 2010 14:25:10 +0100 Message-ID: <4C5ABBB6.6070608@citrix.com> References: <1280938265-12107-1-git-send-email-anthony.perard@citrix.com> <1280938265-12107-2-git-send-email-anthony.perard@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: 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 Cc: "xen-devel@lists.xensource.com" , Gianni Tedesco List-Id: xen-devel@lists.xenproject.org Stefano Stabellini wrote: > On Wed, 4 Aug 2010, anthony.perard@citrix.com wrote: >> From: Anthony PERARD >> >> This patch adds a function to check the version of the device model. >> Depending on the version of the DM, the command line arguments will be >> built differently. >> >> Signed-off-by: Anthony PERARD >> --- >> tools/libxl/libxl.c | 163 ++++++++++++++++++++++++++++++++++++++++++++- >> tools/libxl/libxl_utils.c | 73 ++++++++++++++++++++ >> tools/libxl/libxl_utils.h | 5 ++ >> 3 files changed, 240 insertions(+), 1 deletions(-) >> >> [...] >> >> + // Search for the new version or the old version: >> + // QEMU emulator version 0.12.50, ... >> + // QEMU PC emulator version 0.10.2, ... >> + if (strncmp("QEMU", buf, 4) == 0) { >> + char *v = strstr(buf, "version "); >> + if (v) { >> + int major, minor; >> + char *endptr = NULL; >> + >> + v += strlen("version "); >> + major = strtol(v, &endptr, 10); >> + if (major == 0 && endptr && *endptr == '.') { >> + v = endptr + 1; >> + minor = strtol(v, &endptr, 10); >> + if (minor >= 12) >> + return 1; >> + } >> + return 0; >> + } >> + } >> + return 0; >> +} > > I think Gianni is right about the string to search: it is probably > better to add a Xen specific string to qemu-dm, like "QEMU-DM", and rely > on that and the version (0.10.2 or older) to distinguish between the > two. I can do something better by run "qemu -M ?" and check if "xenfv" machine is supported. This work with both versions. -- Anthony PERARD