Skip to contentSkip to conversation

util: fix to check if target OS is linux in util/mmap-alloc.c

PATCH In review Jingqi Liu 3 participants 4 messages Mar 6, 2020

lore
Share & tools
lore

Jingqi Liu

author
#0 lore raw

PATCH 1/1 util: fix to check if target OS is linux in util/mmap-alloc.c

The CONFIG_LINUX symbol is always undefined before including "qemu/osdep.h". Use __linux__ to check if target OS is linux instead of CONFIG_LINUX.

---
 util/mmap-alloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
util/mmap-alloc.c +3 -3
index 27dcccd8ec..8340540292 100644
@@ -10,12 +10,12 @@
  * later.  See the COPYING file in the top-level directory.
  */
 
-#ifdef CONFIG_LINUX
+#ifdef __linux__
 #include <linux/mman.h>
-#else  /* !CONFIG_LINUX */
+#else
 #define MAP_SYNC              0x0
 #define MAP_SHARED_VALIDATE   0x0
-#endif /* CONFIG_LINUX */
+#endif
 
 #include "qemu/osdep.h"
 #include "qemu/mmap-alloc.h"
Signature · 1 line
2.17.1
#1 lore raw
Quoted 16 lines · Jingqi Liu

The CONFIG_LINUX symbol is always undefined before including "qemu/osdep.h". Use __linux__ to check if target OS is linux instead of CONFIG_LINUX.

---
 util/mmap-alloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
util/mmap-alloc.c +0 -0
index 27dcccd8ec..8340540292 100644
@@ -10,12 +10,12 @@
  * later.  See the COPYING file in the top-level directory.
  */

util/mmap-alloc.c line 18

Quoted 10 lines
util/mmap-alloc.c +3 -3
 
-#ifdef CONFIG_LINUX
+#ifdef __linux__
 #include <linux/mman.h>
-#else  /* !CONFIG_LINUX */
+#else
 #define MAP_SYNC              0x0
 #define MAP_SHARED_VALIDATE   0x0
-#endif /* CONFIG_LINUX */
+#endif

This is not the right way to fix this. osdep.h must go first, no exceptions.

thanks
-- PMM

#2 lore raw
Quoted 17 lines · Peter Maydell
Quoted 16 lines · Jingqi Liu

The CONFIG_LINUX symbol is always undefined before including "qemu/osdep.h". Use __linux__ to check if target OS is linux instead of CONFIG_LINUX.

---
  util/mmap-alloc.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
util/mmap-alloc.c +0 -0
index 27dcccd8ec..8340540292 100644
@@ -10,12 +10,12 @@
   * later.  See the COPYING file in the top-level directory.
   */
 
Quoted 11 lines

util/mmap-alloc.c line 18

Quoted 9 lines
util/mmap-alloc.c +3 -3
-#ifdef CONFIG_LINUX
+#ifdef __linux__
  #include <linux/mman.h>
-#else  /* !CONFIG_LINUX */
+#else
  #define MAP_SYNC              0x0
  #define MAP_SHARED_VALIDATE   0x0
-#endif /* CONFIG_LINUX */
+#endif

This is not the right way to fix this. osdep.h must go first, no exceptions.

osdep.h pulls in sys/mman.h, which defines the MAP_* constants

except for MAP_SYNC and MAP_SHARED_VALIDATE.

I'm curious that this system header doesn't define them.

How about just adding the following code in util/mmap-alloc.c ?

#ifndef MAP_SYNC
#define MAP_SYNC 0x80000
#endif
#ifndef MAP_SYNC
#define MAP_SYNC 0x80000
#endif

#ifndef MAP_SHARED_VALIDATE
#define MAP_SHARED_VALIDATE 0x03
#endif

Thanks,

Jingqi

Quoted 3 lines

thanks
-- PMM

#3 lore raw
In reply to Jingqi Liu
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===

File: "/tmp/qemu-nsis\qemu-doc.html" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only)
Error in script "/tmp/qemu-test/src/qemu.nsi" on line 180 -- aborting creation process
make: *** [Makefile:1162: qemu-setup-4.2.50.exe] Error 1
Traceback (most recent call last):
File "./tests/docker/docker.py", line 664, in <module>

    sys.exit(main())

---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=129637ca425f4fae823349cd2ea3d4b0', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-lcaifi77/src/docker-src.2020-03-06-08.36.29.5278:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=129637ca425f4fae823349cd2ea3d4b0
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-lcaifi77/src'
make: *** [docker-run-test-mingw@fedora] Error 2

real 3m26.534s
user 0m7.926s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]