Skip to contentSkip to conversation

QEMU Guest Agent: Add an interface to determine guest os type

PATCH In review Huang Yong 3 participants 3 messages Apr 12, 2017

lore
Share & tools
lore

Huang Yong

author
#0 lore raw

PATCH 1/1 QEMU Guest Agent: Add an interface to determine guest os type

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.

---
 qga/commands-posix.c | 10 ++++++++++
 qga/commands-win32.c | 10 ++++++++++
 qga/qapi-schema.json | 12 ++++++++++++
 3 files changed, 32 insertions(+)
qga/commands-posix.c +10 -0
index 915df9e..24ec2b6 100644
@@ -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)
 {
qga/commands-win32.c +10 -0
index 19d72b2..a6639dd 100644
@@ -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;
qga/qapi-schema.json +12 -0
index a02dbf2..496ae55 100644
@@ -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' }
Signature · 1 line
1.8.3.1
#1 lore raw

Hi

Quoted 4 lines · Huang Yong

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.

This proposal is probably redundant with "qemu-ga: add guest-get-osrelease command" http://patchew.org/QEMU/[email protected]

Quoted 97 lines
---
 qga/commands-posix.c | 10 ++++++++++
 qga/commands-win32.c | 10 ++++++++++
 qga/qapi-schema.json | 12 ++++++++++++
 3 files changed, 32 insertions(+)
qga/commands-posix.c +10 -0
index 915df9e..24ec2b6 100644
@@ -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)

{

qga/commands-win32.c +10 -0
index 19d72b2..a6639dd 100644
@@ -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;
qga/qapi-schema.json +12 -1
index a02dbf2..496ae55 100644
@@ -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' }
--

1.8.3.1

Quoted 1 line

--

Marc-André Lureau

#2 lore raw
Quoted 11 lines · Marc-André Lureau

Hi

On Wed, Apr 12, 2017 at 1:12 PM Huang Yong <[email protected] <mailto:[email protected]>> wrote:
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.

This proposal is probably redundant with "qemu-ga: add guest-get-osrelease command" http://patchew.org/QEMU/[email protected] <http://patchew.org/QEMU/[email protected]>

Indeed, that’s going the same direction just that we’re trying to report a bit more extensive information.

Quoted 94 lines
Signed-off-by Huang Yong <[email protected] <mailto:[email protected]>>
---
 qga/commands-posix.c | 10 ++++++++++
 qga/commands-win32.c | 10 ++++++++++
 qga/qapi-schema.json | 12 ++++++++++++
 3 files changed, 32 insertions(+)
qga/commands-posix.c +10 -0
index 915df9e..24ec2b6 100644
@@ -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)
 {
qga/commands-win32.c +10 -0
index 19d72b2..a6639dd 100644
@@ -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;
qga/qapi-schema.json +12 -1
index a02dbf2..496ae55 100644
@@ -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' }
--
Quoted 6 lines

1.8.3.1

Signature · 1 line
Marc-André Lureau

--
Vinzenz Feenstra
Senior Software Developer
Red Hat Czech