qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 05/12] util/oslib-win32: add qemu_get_host_physmem impleme


From: Yonggang Luo
Subject: Re: [PATCH v2 05/12] util/oslib-win32: add qemu_get_host_physmem implementation
Date: Wed, 22 Jul 2020 18:32:59 +0800

I would suggest use loadLibrary to retrieve the function, if not available, then return 0 (For Win Xp and Vista);

On Wed, Jul 22, 2020 at 2:34 PM Alex Bennée <alex.bennee@linaro.org> wrote:
It seems GetPhysicallyInstalledSystemMemory isn't available in the
MinGW headers so we have to declare it ourselves. Compile tested only.

Cc: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 util/oslib-win32.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 31030463cc9..f0f94833197 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -43,6 +43,8 @@
 /* this must come after including "trace.h" */
 #include <shlobj.h>

+WINBASEAPI BOOL WINAPI GetPhysicallyInstalledSystemMemory (PULONGLONG);
+
 void *qemu_oom_check(void *ptr)
 {
     if (ptr == NULL) {
@@ -831,6 +833,15 @@ char *qemu_get_host_name(Error **errp)

 size_t qemu_get_host_physmem(void)
 {
-    /* currently unimplemented */
-    return 0;
+    ULONGLONG mem;
+
+    if (GetPhysicallyInstalledSystemMemory(&mem)) {
+        if (mem > SIZE_MAX) {
+            return SIZE_MAX;
+        } else {
+            return mem;
+        }
+    } else {
+        return 0;
+    }
 }
--
2.20.1




--
         此致

罗勇刚
Yours
    sincerely,
Yonggang Luo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]