From patchwork Wed Apr 12 11:10:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Yong X-Patchwork-Id: 749928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w31Vw6dZXz9s84 for ; Wed, 12 Apr 2017 21:13:05 +1000 (AEST) Received: from localhost ([::1]:43544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyGCr-0008Fq-W6 for incoming@patchwork.ozlabs.org; Wed, 12 Apr 2017 07:13:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyGCa-0008FW-CC for qemu-devel@nongnu.org; Wed, 12 Apr 2017 07:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cyGCV-0006Dj-Gh for qemu-devel@nongnu.org; Wed, 12 Apr 2017 07:12:44 -0400 Received: from out1.zte.com.cn ([202.103.147.172]:34780) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyGCU-0006Ba-UE for qemu-devel@nongnu.org; Wed, 12 Apr 2017 07:12:39 -0400 X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170412190502 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 12 Apr 2017 11:05:02 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v3CBCSkG049796; Wed, 12 Apr 2017 19:12:28 +0800 (GMT-8) (envelope-from huang.yong@zte.com.cn) Received: from localhost.localdomain ([10.74.121.225]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017041219123277-610008 ; Wed, 12 Apr 2017 19:12:32 +0800 From: Huang Yong To: mdroth@linux.vnet.ibm.com Date: Wed, 12 Apr 2017 19:10:56 +0800 Message-Id: <1491995456-6411-1-git-send-email-huang.yong@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-04-12 19:12:32, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-04-12 19:12:08, Serialize complete at 2017-04-12 19:12:08 X-MAIL: mse01.zte.com.cn v3CBCSkG049796 X-HQIP: 127.0.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 202.103.147.172 Subject: [Qemu-devel] [PATCH] QEMU Guest Agent: Add an interface to determine guest os type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huang Yong , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" vm management tools (e.g.libvirt) may tell if guest os is linux or windows, so they can design a customized application accordingly, we suggest to add an interface (guest-ostype) in QEMU. Signed-off-by: Huang Yong --- qga/commands-posix.c | 10 ++++++++++ qga/commands-win32.c | 10 ++++++++++ qga/qapi-schema.json | 12 ++++++++++++ 3 files changed, 32 insertions(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 915df9e..24ec2b6 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -49,6 +49,11 @@ extern char **environ; #endif #endif +typedef enum GuestArch { + ARCH_WINDOWS = 0, + ARCH_LINUX = 1, +} GuestArch; + static void ga_wait_child(pid_t pid, int *status, Error **errp) { pid_t rpid; @@ -2470,6 +2475,11 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp) } #endif +int64_t qmp_guest_ostype(Error **errp) +{ + return ARCH_LINUX; +} + /* add unsupported commands to the blacklist */ GList *ga_command_blacklist_init(GList *blacklist) { diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 19d72b2..a6639dd 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -58,6 +58,11 @@ static struct { .filehandles = QTAILQ_HEAD_INITIALIZER(guest_file_state.filehandles), }; +typedef enum GuestArch { + ARCH_WINDOWS = 0, + ARCH_LINUX = 1, +} GuestArch; + #define FILE_GENERIC_APPEND (FILE_GENERIC_WRITE & ~FILE_WRITE_DATA) typedef struct OpenFlags { @@ -214,6 +219,11 @@ void qmp_guest_file_close(int64_t handle, Error **errp) g_free(gfh); } +int64_t qmp_guest_ostype(Error **errp) +{ + return ARCH_WINDOWS; +} + static void acquire_privilege(const char *name, Error **errp) { HANDLE token = NULL; diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index a02dbf2..496ae55 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -26,6 +26,7 @@ 'guest-get-time', 'guest-set-vcpus', 'guest-sync', + 'guest-ostype', 'guest-sync-delimited' ] } } ## @@ -1042,3 +1043,14 @@ 'data': { 'path': 'str', '*arg': ['str'], '*env': ['str'], '*input-data': 'str', '*capture-output': 'bool' }, 'returns': 'GuestExec' } + +## +# @guest-ostype: +# +# Get guest os type info +# Returns: os type, Linux/Windows +# +# Since: 2.5.0 +## +{ 'command': 'guest-ostype', + 'returns': 'int' }