* [Qemu-devel] [RFC PATCH 1/2] qga: Introduce guest-get-os-version command with stubs
2014-12-16 7:30 [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version for windows zhanghailiang
@ 2014-12-16 7:30 ` zhanghailiang
2014-12-16 16:23 ` Eric Blake
2014-12-16 7:30 ` [Qemu-devel] [RFC PATCH 2/2] qga: implement qmp_guest_get_os_version for windows zhanghailiang
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: zhanghailiang @ 2014-12-16 7:30 UTC (permalink / raw)
To: qemu-devel
Cc: zhanghailiang, peter.huangpeng, mdroth, lcapitulino, lersek,
lilei
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
qga/commands-posix.c | 7 +++++++
qga/commands-win32.c | 6 ++++++
qga/qapi-schema.json | 26 ++++++++++++++++++++++++++
3 files changed, 39 insertions(+)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index f6f3e3c..b4d5c29 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1912,6 +1912,12 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
#endif
+struct GuestOSVersion *qmp_guest_get_os_version(Error **errp)
+{
+ error_set(errp, QERR_UNSUPPORTED);
+ return NULL;
+}
+
#if !defined(CONFIG_FSFREEZE)
GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
@@ -1993,6 +1999,7 @@ GList *ga_command_blacklist_init(GList *blacklist)
blacklist = g_list_append(blacklist, (char *)"guest-fstrim");
#endif
+ blacklist = g_list_append(blacklist, (char *)"guest-get-os-version");
return blacklist;
}
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 3bcbeae..d133082 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -446,6 +446,12 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
return -1;
}
+struct GuestOSVersion *qmp_guest_get_os_version(Error **errp)
+{
+ error_set(errp, QERR_UNSUPPORTED);
+ return NULL;
+}
+
/* add unsupported commands to the blacklist */
GList *ga_command_blacklist_init(GList *blacklist)
{
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index 376e79f..f94404d 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -738,3 +738,29 @@
##
{ 'command': 'guest-get-fsinfo',
'returns': ['GuestFilesystemInfo'] }
+##
+# @GuestOSVersion:
+#
+# @name: system version.
+#
+# @:type: 64-bit or 32-bit.
+#
+# Since: 2.3
+##
+{ 'type': 'GuestOSVersion',
+ 'data': {'name': 'str', 'type': 'int'} }
+
+##
+# @guest-get-os-version:
+#
+# Get the guest's operating system version and bit.
+#
+# This is a read-only operation.
+#
+# Returns: version
+#
+# Since: 2.3
+##
+{ 'command': 'guest-get-os-version',
+ 'returns': 'GuestOSVersion' }
+
--
1.7.12.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 1/2] qga: Introduce guest-get-os-version command with stubs
2014-12-16 7:30 ` [Qemu-devel] [RFC PATCH 1/2] qga: Introduce guest-get-os-version command with stubs zhanghailiang
@ 2014-12-16 16:23 ` Eric Blake
2015-01-03 0:32 ` Richard W.M. Jones
0 siblings, 1 reply; 12+ messages in thread
From: Eric Blake @ 2014-12-16 16:23 UTC (permalink / raw)
To: zhanghailiang, qemu-devel
Cc: lilei, lcapitulino, lersek, peter.huangpeng, mdroth
[-- Attachment #1: Type: text/plain, Size: 1993 bytes --]
On 12/16/2014 12:30 AM, zhanghailiang wrote:
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
Might be nice to show an example (intended) usage of the new command in
the commit message.
> +++ b/qga/qapi-schema.json
> @@ -738,3 +738,29 @@
> ##
> { 'command': 'guest-get-fsinfo',
> 'returns': ['GuestFilesystemInfo'] }
> +##
Blank line between commands.
> +# @GuestOSVersion:
> +#
> +# @name: system version.
> +#
> +# @:type: 64-bit or 32-bit.
s/@:/@/
'type' feels like the wrong name for word-width. Maybe 'word-width' is
a better name?
> +#
> +# Since: 2.3
> +##
> +{ 'type': 'GuestOSVersion',
> + 'data': {'name': 'str', 'type': 'int'} }
'name' feels a bit vague; it looks like you are intending to use the
string as a free-form text field, where the guest can supply arbitrary
strings. Maybe name it 'info' instead? Is it worth being any stricter,
such as having actual enums of known values? On the other hand, tying
to known enums means we have to update qemu-ga every time a new guest
gains support for running the agent, while free-form string leaves us a
bit more flexible. Or maybe you want both, as in:
{ 'enum': 'GuestOSFamily', 'data': ['Windows', 'Linux', 'other'] }
{ 'type': 'GuestOSVersion',
'data': { 'info': 'str', 'family': 'GuestOSFamily',
'word-width': 'int' } }
> +
> +##
> +# @guest-get-os-version:
> +#
> +# Get the guest's operating system version and bit.
s/bit/word width/
> +#
> +# This is a read-only operation.
> +#
> +# Returns: version
> +#
> +# Since: 2.3
> +##
> +{ 'command': 'guest-get-os-version',
> + 'returns': 'GuestOSVersion' }
with my suggestions, a usage might be:
=> { "execute": "guest-get-os-version" }
<= { "return": { "family": "Windows",
"info": "Microsoft Windows Server 2012 R2",
"word-width": 64 } }
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 1/2] qga: Introduce guest-get-os-version command with stubs
2014-12-16 16:23 ` Eric Blake
@ 2015-01-03 0:32 ` Richard W.M. Jones
0 siblings, 0 replies; 12+ messages in thread
From: Richard W.M. Jones @ 2015-01-03 0:32 UTC (permalink / raw)
To: Eric Blake
Cc: lilei, qemu-devel, peter.huangpeng, lcapitulino, lersek, mdroth,
zhanghailiang
On Tue, Dec 16, 2014 at 09:23:46AM -0700, Eric Blake wrote:
> On 12/16/2014 12:30 AM, zhanghailiang wrote:
> > +# Since: 2.3
> > +##
> > +{ 'type': 'GuestOSVersion',
> > + 'data': {'name': 'str', 'type': 'int'} }
>
> 'name' feels a bit vague; it looks like you are intending to use the
> string as a free-form text field, where the guest can supply arbitrary
> strings. Maybe name it 'info' instead? Is it worth being any stricter,
> such as having actual enums of known values? On the other hand, tying
> to known enums means we have to update qemu-ga every time a new guest
> gains support for running the agent, while free-form string leaves us a
> bit more flexible. Or maybe you want both, as in:
>
> { 'enum': 'GuestOSFamily', 'data': ['Windows', 'Linux', 'other'] }
> { 'type': 'GuestOSVersion',
> 'data': { 'info': 'str', 'family': 'GuestOSFamily',
> 'word-width': 'int' } }
I think it's better to tie this to libosinfo, rather than
invent yet another new classification for OSes.
Rich.
> > +
> > +##
> > +# @guest-get-os-version:
> > +#
> > +# Get the guest's operating system version and bit.
>
> s/bit/word width/
>
> > +#
> > +# This is a read-only operation.
> > +#
> > +# Returns: version
> > +#
> > +# Since: 2.3
> > +##
> > +{ 'command': 'guest-get-os-version',
> > + 'returns': 'GuestOSVersion' }
>
> with my suggestions, a usage might be:
> => { "execute": "guest-get-os-version" }
> <= { "return": { "family": "Windows",
> "info": "Microsoft Windows Server 2012 R2",
> "word-width": 64 } }
>
> --
> Eric Blake eblake redhat com +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] [RFC PATCH 2/2] qga: implement qmp_guest_get_os_version for windows
2014-12-16 7:30 [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version for windows zhanghailiang
2014-12-16 7:30 ` [Qemu-devel] [RFC PATCH 1/2] qga: Introduce guest-get-os-version command with stubs zhanghailiang
@ 2014-12-16 7:30 ` zhanghailiang
2014-12-16 11:48 ` Yan Vugenfirer
2014-12-16 9:38 ` [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version " Yan Vugenfirer
2014-12-16 16:25 ` Eric Blake
3 siblings, 1 reply; 12+ messages in thread
From: zhanghailiang @ 2014-12-16 7:30 UTC (permalink / raw)
To: qemu-devel
Cc: zhanghailiang, peter.huangpeng, mdroth, lcapitulino, lersek,
lilei
We can get guest's OS version info by using 'guest-get-os-version',
The return value contains version name and type (32-bit or 64-bit).
For example:
{"return":{"name":"Microsoft Windows Server 2012 R2","type":64}}
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
qga/commands-win32.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 121 insertions(+), 2 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index d133082..7743e1a 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -446,10 +446,129 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
return -1;
}
+static int get_system_type(Error **errp)
+{
+ SYSTEM_INFO si;
+
+ typedef void (WINAPI * LPFN_GetNativeSystemInfo)(LPSYSTEM_INFO systemInfo);
+ LPFN_GetNativeSystemInfo ga_GetNativeSystemInfo =
+ (LPFN_GetNativeSystemInfo)GetProcAddress(
+ GetModuleHandle("kernel32"),
+ "GetNativeSystemInfo");
+ if (ga_GetNativeSystemInfo) {
+ ga_GetNativeSystemInfo(&si);
+ } else {
+ GetSystemInfo(&si);
+ }
+
+ if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
+ si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {
+ return 64;
+ } else {
+ return 32;
+ }
+}
+
+static BOOL compare_windows_version(DWORD dwMajorVersion,
+ DWORD dwMinorVersion)
+{
+ OSVERSIONINFOEX osvi;
+ DWORDLONG dwlConditionMask = 0;
+
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ osvi.dwMajorVersion = dwMajorVersion;
+ osvi.dwMinorVersion = dwMinorVersion;
+
+ VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_EQUAL);
+ VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_EQUAL);
+
+ return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION,
+ dwlConditionMask);
+}
+
+/*
+* We get the version by using version information, you can find more info
+* about operating systems and identical version numbers from bellow links:
+* http://msdn.microsoft.com/en-us/library/ms724834(v=vs.85).aspx
+* http://msdn.microsoft.com/en-us/library/ms724832(v=vs.85).aspx
+*/
struct GuestOSVersion *qmp_guest_get_os_version(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
- return NULL;
+ OSVERSIONINFOEX osvi;
+ GuestOSVersion *osv = g_malloc0(sizeof(GuestOSVersion));
+
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ if (!(GetVersionEx((OSVERSIONINFO *)&osvi))) {
+ error_setg(errp, "GetVersionEx failed\n");
+ return NULL;
+ }
+ osv->type = get_system_type(NULL);
+
+ switch (osvi.dwMajorVersion) {
+ case 5:
+ switch (osvi.dwMinorVersion) {
+ case 0:
+ osv->name = g_strdup("Microsoft Windows 2000");
+ break;
+ case 1:
+ osv->name = g_strdup("Microsoft Windows XP");
+ break;
+ case 2:
+ if (GetSystemMetrics(SM_SERVERR2) == 0) {
+ osv->name = g_strdup("Microsoft Windows Server 2003");
+ } else {
+ osv->name = g_strdup("Microsoft Windows Server 2003 R2");
+ }
+ break;
+ }
+ break; /* case 5*/
+ case 6:
+ switch (osvi.dwMinorVersion) {
+ case 0:
+ if (osvi.wProductType == VER_NT_WORKSTATION) {
+ osv->name = g_strdup("Microsoft Windows Vista");
+ } else {
+ osv->name = g_strdup("Microsoft Windows Server 2008");
+ }
+ break;
+ case 1:
+ if (osvi.wProductType == VER_NT_WORKSTATION) {
+ osv->name = g_strdup("Microsoft Windows 7");
+ } else {
+ osv->name = g_strdup("Microsoft Windows Server 2008 R2");
+ }
+ break;
+ case 2:
+ /*
+ * GetVersionEx APIs have been deprecated.
+ * if we do not specifically target Windows 8.1 Preview,
+ * we will get Windows 8 version. So here we use
+ * VerifyVersionInfo to verify the correct version number.
+ * More info can be found at:
+ * http://msdn.microsoft.com/en-us/library/ms724834(v=vs.85).aspx
+ */
+ if (compare_windows_version(6, 3)) {
+ if (osvi.wProductType == VER_NT_WORKSTATION) {
+ osv->name = g_strdup("Microsoft Windows 8.1");
+ } else {
+ osv->name = g_strdup("Microsoft Windows Server 2012 R2");
+ }
+ } else {
+ if (osvi.wProductType == VER_NT_WORKSTATION) {
+ osv->name = g_strdup("Microsoft Windows 8");
+ } else {
+ osv->name = g_strdup("Microsoft Windows Server 2012");
+ }
+ }
+ break;
+ }
+ break; /* case 6*/
+ default:
+ osv->name = g_strdup("unknow os");
+ } /* switch (osvi.dwMajorVersion) */
+ return osv;
}
/* add unsupported commands to the blacklist */
--
1.7.12.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 2/2] qga: implement qmp_guest_get_os_version for windows
2014-12-16 7:30 ` [Qemu-devel] [RFC PATCH 2/2] qga: implement qmp_guest_get_os_version for windows zhanghailiang
@ 2014-12-16 11:48 ` Yan Vugenfirer
2014-12-16 16:26 ` Eric Blake
0 siblings, 1 reply; 12+ messages in thread
From: Yan Vugenfirer @ 2014-12-16 11:48 UTC (permalink / raw)
To: zhanghailiang
Cc: lilei, qemu-devel, mdroth, Luiz Capitulino, peter.huangpeng,
Laszlo Ersek
> On Dec 16, 2014, at 9:30 AM, zhanghailiang <zhang.zhanghailiang@huawei.com> wrote:
>
> We can get guest's OS version info by using 'guest-get-os-version',
> The return value contains version name and type (32-bit or 64-bit).
> For example:
> {"return":{"name":"Microsoft Windows Server 2012 R2","type":64}}
>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
> qga/commands-win32.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 121 insertions(+), 2 deletions(-)
>
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index d133082..7743e1a 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -446,10 +446,129 @@ int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
> return -1;
> }
>
> +static int get_system_type(Error **errp)
> +{
> + SYSTEM_INFO si;
> +
> + typedef void (WINAPI * LPFN_GetNativeSystemInfo)(LPSYSTEM_INFO systemInfo);
> + LPFN_GetNativeSystemInfo ga_GetNativeSystemInfo =
> + (LPFN_GetNativeSystemInfo)GetProcAddress(
> + GetModuleHandle("kernel32"),
> + "GetNativeSystemInfo");
> + if (ga_GetNativeSystemInfo) {
> + ga_GetNativeSystemInfo(&si);
> + } else {
> + GetSystemInfo(&si);
> + }
> +
> + if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
> + si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {
If one of the motivations is to update drivers on the guest - those should be treated as deferent architectures.
Why not return string as well (x64, x86, IA64, ARM)?
> + return 64;
> + } else {
> + return 32;
> + }
> +}
> +
> +static BOOL compare_windows_version(DWORD dwMajorVersion,
> + DWORD dwMinorVersion)
> +{
> + OSVERSIONINFOEX osvi;
> + DWORDLONG dwlConditionMask = 0;
> +
> + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
> + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
> + osvi.dwMajorVersion = dwMajorVersion;
> + osvi.dwMinorVersion = dwMinorVersion;
> +
> + VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_EQUAL);
> + VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_EQUAL);
> +
> + return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION,
> + dwlConditionMask);
> +}
> +
> +/*
> +* We get the version by using version information, you can find more info
> +* about operating systems and identical version numbers from bellow links:
> +* http://msdn.microsoft.com/en-us/library/ms724834(v=vs.85).aspx
> +* http://msdn.microsoft.com/en-us/library/ms724832(v=vs.85).aspx
> +*/
> struct GuestOSVersion *qmp_guest_get_os_version(Error **errp)
> {
> - error_set(errp, QERR_UNSUPPORTED);
> - return NULL;
> + OSVERSIONINFOEX osvi;
> + GuestOSVersion *osv = g_malloc0(sizeof(GuestOSVersion));
> +
> + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
> + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
> + if (!(GetVersionEx((OSVERSIONINFO *)&osvi))) {
> + error_setg(errp, "GetVersionEx failed\n");
> + return NULL;
> + }
> + osv->type = get_system_type(NULL);
> +
> + switch (osvi.dwMajorVersion) {
> + case 5:
> + switch (osvi.dwMinorVersion) {
> + case 0:
> + osv->name = g_strdup("Microsoft Windows 2000");
> + break;
> + case 1:
> + osv->name = g_strdup("Microsoft Windows XP");
> + break;
> + case 2:
> + if (GetSystemMetrics(SM_SERVERR2) == 0) {
> + osv->name = g_strdup("Microsoft Windows Server 2003");
> + } else {
> + osv->name = g_strdup("Microsoft Windows Server 2003 R2");
> + }
> + break;
> + }
> + break; /* case 5*/
> + case 6:
> + switch (osvi.dwMinorVersion) {
> + case 0:
> + if (osvi.wProductType == VER_NT_WORKSTATION) {
> + osv->name = g_strdup("Microsoft Windows Vista");
> + } else {
> + osv->name = g_strdup("Microsoft Windows Server 2008");
> + }
> + break;
> + case 1:
> + if (osvi.wProductType == VER_NT_WORKSTATION) {
> + osv->name = g_strdup("Microsoft Windows 7");
> + } else {
> + osv->name = g_strdup("Microsoft Windows Server 2008 R2");
> + }
> + break;
> + case 2:
> + /*
> + * GetVersionEx APIs have been deprecated.
> + * if we do not specifically target Windows 8.1 Preview,
> + * we will get Windows 8 version. So here we use
> + * VerifyVersionInfo to verify the correct version number.
> + * More info can be found at:
> + * http://msdn.microsoft.com/en-us/library/ms724834(v=vs.85).aspx
> + */
> + if (compare_windows_version(6, 3)) {
> + if (osvi.wProductType == VER_NT_WORKSTATION) {
> + osv->name = g_strdup("Microsoft Windows 8.1");
> + } else {
> + osv->name = g_strdup("Microsoft Windows Server 2012 R2");
> + }
> + } else {
> + if (osvi.wProductType == VER_NT_WORKSTATION) {
> + osv->name = g_strdup("Microsoft Windows 8");
> + } else {
> + osv->name = g_strdup("Microsoft Windows Server 2012");
> + }
> + }
> + break;
> + }
> + break; /* case 6*/
> + default:
> + osv->name = g_strdup("unknow os");
> + } /* switch (osvi.dwMajorVersion) */
> + return osv;
> }
>
> /* add unsupported commands to the blacklist */
> --
> 1.7.12.4
>
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 2/2] qga: implement qmp_guest_get_os_version for windows
2014-12-16 11:48 ` Yan Vugenfirer
@ 2014-12-16 16:26 ` Eric Blake
2014-12-17 8:14 ` zhanghailiang
0 siblings, 1 reply; 12+ messages in thread
From: Eric Blake @ 2014-12-16 16:26 UTC (permalink / raw)
To: Yan Vugenfirer, zhanghailiang
Cc: lilei, qemu-devel, mdroth, peter.huangpeng, Luiz Capitulino,
Laszlo Ersek
[-- Attachment #1: Type: text/plain, Size: 654 bytes --]
On 12/16/2014 04:48 AM, Yan Vugenfirer wrote:
>> +
>> + if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
>> + si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {
>
> If one of the motivations is to update drivers on the guest - those should be treated as deferent architectures.
> Why not return string as well (x64, x86, IA64, ARM)?
The architecture should already be known by the host (after all, the
flavor of qemu running the guest should tell you what architecture the
guest would report).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 2/2] qga: implement qmp_guest_get_os_version for windows
2014-12-16 16:26 ` Eric Blake
@ 2014-12-17 8:14 ` zhanghailiang
0 siblings, 0 replies; 12+ messages in thread
From: zhanghailiang @ 2014-12-17 8:14 UTC (permalink / raw)
To: Eric Blake, Yan Vugenfirer
Cc: hangaohuai, lilei, qemu-devel, mdroth, Luiz Capitulino,
peter.huangpeng, Laszlo Ersek
On 2014/12/17 0:26, Eric Blake wrote:
> On 12/16/2014 04:48 AM, Yan Vugenfirer wrote:
>>> +
>>> + if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
>>> + si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {
>>
>> If one of the motivations is to update drivers on the guest - those should be treated as deferent architectures.
>> Why not return string as well (x64, x86, IA64, ARM)?
>
> The architecture should already be known by the host (after all, the
> flavor of qemu running the guest should tell you what architecture the
> guest would report).
>
Yes, we can easily get this info from host ;)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version for windows
2014-12-16 7:30 [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version for windows zhanghailiang
2014-12-16 7:30 ` [Qemu-devel] [RFC PATCH 1/2] qga: Introduce guest-get-os-version command with stubs zhanghailiang
2014-12-16 7:30 ` [Qemu-devel] [RFC PATCH 2/2] qga: implement qmp_guest_get_os_version for windows zhanghailiang
@ 2014-12-16 9:38 ` Yan Vugenfirer
2014-12-16 11:06 ` zhanghailiang
2014-12-16 16:25 ` Eric Blake
3 siblings, 1 reply; 12+ messages in thread
From: Yan Vugenfirer @ 2014-12-16 9:38 UTC (permalink / raw)
To: zhanghailiang
Cc: lilei, qemu-devel, mdroth, lcapitulino, peter.huangpeng, lersek
[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]
Hi,
My suggestion is to handle the case when the newer OS will be installed in the guest as well.
Please look at version helper API - http://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx <http://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx>
and keep in mind that the usual GetVersion and GetVersionEx (that returned major, minor versions and build number) will be deprecated or changed after Windows 8.1.
Thanks,
Yan.
> On Dec 16, 2014, at 9:30 AM, zhanghailiang <zhang.zhanghailiang@huawei.com> wrote:
>
> Hi,
>
> This patch series add a new guest command 'guest-get-os-version'.
> It is now only available for windows guest.
>
> It will return guest's OS version name and type, like bellow:
> '{"return":{"name":"Microsoft Windows Server 2012 R2","type":64}}'
>
> Sometimes we need to know guest's OS version info.
> (Actually, we need this info when we update guest's applications and drivers
> in our project.)
>
> This patch is only RFC, it is another try to add more commands for qemu-ga.
> Though qemu-ga has supported some commands now, but it is not enough and some
> of them only support for linux ...
>
> I would like to enrich it, if someone think it is acceptable.
>
> So, any comments will be welcome! Thanks ;)
>
> zhanghailiang (2):
> qga: Introduce guest-get-os-version command with stubs
> qga: implement qmp_guest_get_os_version for windows
>
> qga/commands-posix.c | 7 +++
> qga/commands-win32.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
> qga/qapi-schema.json | 26 +++++++++++
> 3 files changed, 158 insertions(+)
>
> --
> 1.7.12.4
>
>
>
[-- Attachment #2: Type: text/html, Size: 2785 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version for windows
2014-12-16 9:38 ` [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version " Yan Vugenfirer
@ 2014-12-16 11:06 ` zhanghailiang
0 siblings, 0 replies; 12+ messages in thread
From: zhanghailiang @ 2014-12-16 11:06 UTC (permalink / raw)
To: Yan Vugenfirer
Cc: lilei, qemu-devel, mdroth, lcapitulino, peter.huangpeng, lersek
On 2014/12/16 17:38, Yan Vugenfirer wrote:
> Hi,
>
> My suggestion is to handle the case when the newer OS will be installed in the guest as well.
>
Yes, we can do this when we install guest OS, save the version info into some places,
and get the info when we need, But it is not so flexible, especially when we manage the OS image directly,
we have to record the relationship between image name and its OS version, besides, we need to apply an API to
return image's OS version.
So IMHO, get the OS version info from guest and use qga command to get the info are more flexible and reliable.
> Please look at version helper API - http://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx <http://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx>
> and keep in mind that the usual GetVersion and GetVersionEx (that returned major, minor versions and build number) will be deprecated or changed after Windows 8.1.
>
Hmm, i noticed this ;), i have handle it specially for windows 8.1 in this patch.
We can still get its real version by other method.
And here i just add a framework for get-os-version, we can improve it when new OS comes out.
Thanks,
zhanghailiang
>
>
>> On Dec 16, 2014, at 9:30 AM, zhanghailiang <zhang.zhanghailiang@huawei.com> wrote:
>>
>> Hi,
>>
>> This patch series add a new guest command 'guest-get-os-version'.
>> It is now only available for windows guest.
>>
>> It will return guest's OS version name and type, like bellow:
>> '{"return":{"name":"Microsoft Windows Server 2012 R2","type":64}}'
>>
>> Sometimes we need to know guest's OS version info.
>> (Actually, we need this info when we update guest's applications and drivers
>> in our project.)
>>
>> This patch is only RFC, it is another try to add more commands for qemu-ga.
>> Though qemu-ga has supported some commands now, but it is not enough and some
>> of them only support for linux ...
>>
>> I would like to enrich it, if someone think it is acceptable.
>>
>> So, any comments will be welcome! Thanks ;)
>>
>> zhanghailiang (2):
>> qga: Introduce guest-get-os-version command with stubs
>> qga: implement qmp_guest_get_os_version for windows
>>
>> qga/commands-posix.c | 7 +++
>> qga/commands-win32.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
>> qga/qapi-schema.json | 26 +++++++++++
>> 3 files changed, 158 insertions(+)
>>
>> --
>> 1.7.12.4
>>
>>
>>
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version for windows
2014-12-16 7:30 [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version for windows zhanghailiang
` (2 preceding siblings ...)
2014-12-16 9:38 ` [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version " Yan Vugenfirer
@ 2014-12-16 16:25 ` Eric Blake
2014-12-17 8:12 ` zhanghailiang
3 siblings, 1 reply; 12+ messages in thread
From: Eric Blake @ 2014-12-16 16:25 UTC (permalink / raw)
To: zhanghailiang, qemu-devel
Cc: lilei, lcapitulino, lersek, peter.huangpeng, mdroth
[-- Attachment #1: Type: text/plain, Size: 912 bytes --]
On 12/16/2014 12:30 AM, zhanghailiang wrote:
> Hi,
>
> This patch series add a new guest command 'guest-get-os-version'.
> It is now only available for windows guest.
Why not also supply it for Linux guests? uname() is your friend; it
should be fairly easy to wire up.
>
> It will return guest's OS version name and type, like bellow:
> '{"return":{"name":"Microsoft Windows Server 2012 R2","type":64}}'
>
> Sometimes we need to know guest's OS version info.
> (Actually, we need this info when we update guest's applications and drivers
> in our project.)
Have you looked into libguestfs' ability to get this information from an
(offline) guest image? I'm not rejecting this command, but trying to
make sure that it is not duplicating something that can already be done.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [RFC PATCH 0/2] qga: add guest-get-os-version for windows
2014-12-16 16:25 ` Eric Blake
@ 2014-12-17 8:12 ` zhanghailiang
0 siblings, 0 replies; 12+ messages in thread
From: zhanghailiang @ 2014-12-17 8:12 UTC (permalink / raw)
To: Eric Blake, qemu-devel
Cc: hangaohuai, lilei, peter.huangpeng, lcapitulino, lersek, mdroth
On 2014/12/17 0:25, Eric Blake wrote:
> On 12/16/2014 12:30 AM, zhanghailiang wrote:
>> Hi,
>>
>> This patch series add a new guest command 'guest-get-os-version'.
>> It is now only available for windows guest.
>
> Why not also supply it for Linux guests? uname() is your friend; it
> should be fairly easy to wire up.
>
Er, this patch is RFC, i don't know if this idea (support get-os-version command) is acceptable,
I will add it in next formal version if it is acceptable. ;)
>>
>> It will return guest's OS version name and type, like bellow:
>> '{"return":{"name":"Microsoft Windows Server 2012 R2","type":64}}'
>>
>> Sometimes we need to know guest's OS version info.
>> (Actually, we need this info when we update guest's applications and drivers
>> in our project.)
>
> Have you looked into libguestfs' ability to get this information from an
> (offline) guest image? I'm not rejecting this command, but trying to
> make sure that it is not duplicating something that can already be done.
>
I have look into libgustfs codes, and yes, it supports get this info from offline guest image,
but unfortunately we don't use libguestfs in our project.
(I also make a simple test to get proudct name by using
"virt-inspector -d redhat-6.4 | virt-inspector --xpath '//product_name'",
it is a little time consuming (about 12s)).
So, what's your suggestion?
Thanks,
zhanghailiang
^ permalink raw reply [flat|nested] 12+ messages in thread