qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/9] Green the msys2 CI make
@ 2020-09-02 21:42 Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 1/9] configure: fixes dtc not cloned when running msys2 CI Yonggang Luo
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Yonggang Luo @ 2020-09-02 21:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yonggang Luo

Also it's fixes two issues about make check

Yonggang Luo (9):
  configure: fixes dtc not cloned when running msys2 CI
  meson: Convert undefsym.sh to undefsym.py
  tcg: Fixes dup_const link error
  tests: handling signal on win32 properly
  configure: Fix include and linkage issue on msys2
  block: Fixes nfs on msys2/mingw
  osdep: These function are only available on Non-Win32 system.
  ci: fixes msys2 build by upgrading capstone to 4.0.2
  ci: Enable msys2 ci in cirrus

 .cirrus.yml                         | 23 ++++++++++++
 block/nfs.c                         | 26 ++++++++-----
 capstone                            |  2 +-
 configure                           | 48 +++++++++++++++---------
 include/qemu/osdep.h                |  2 +-
 include/tcg/tcg.h                   |  6 +--
 meson.build                         |  2 +-
 scripts/ci/windows/msys2_build.sh   | 34 +++++++++++++++++
 scripts/ci/windows/msys2_install.sh | 31 ++++++++++++++++
 scripts/undefsym.py                 | 57 +++++++++++++++++++++++++++++
 scripts/undefsym.sh                 | 20 ----------
 tcg/tcg-op-gvec.c                   |  2 +-
 tests/test-replication.c            |  4 ++
 13 files changed, 204 insertions(+), 53 deletions(-)
 create mode 100644 scripts/ci/windows/msys2_build.sh
 create mode 100644 scripts/ci/windows/msys2_install.sh
 create mode 100644 scripts/undefsym.py
 delete mode 100755 scripts/undefsym.sh

-- 
2.27.0.windows.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/9] configure: fixes dtc not cloned when running msys2 CI
  2020-09-02 21:42 [PATCH v2 0/9] Green the msys2 CI make Yonggang Luo
@ 2020-09-02 21:42 ` Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 2/9] meson: Convert undefsym.sh to undefsym.py Yonggang Luo
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Yonggang Luo @ 2020-09-02 21:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yonggang Luo

Symlink dtc after git submodule update, because on win32 symlink to non-exist folder are forbidden.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 configure | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 8a3acef89d..30f8c4db29 100755
--- a/configure
+++ b/configure
@@ -2053,9 +2053,6 @@ fi
 if test "$meson" = git; then
     git_submodules="${git_submodules} meson"
 fi
-if test "$git_update" = yes; then
-    (cd "${source_path}" && GIT="$git" "./scripts/git-submodule.sh" update "$git_submodules")
-fi
 
 case "$meson" in
     git | internal)
@@ -4261,9 +4258,6 @@ EOF
       if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
           fdt=git
           mkdir -p dtc
-          if [ "$pwd_is_source_path" != "y" ] ; then
-              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
-          fi
           fdt_cflags="-I${source_path}/dtc/libfdt"
           fdt_ldflags="-L$PWD/dtc/libfdt"
           fdt_libs="$fdt_libs"
@@ -6593,6 +6587,16 @@ if test "$cpu" = "s390x" ; then
   fi
 fi
 
+if test $git_update = 'yes' ; then
+    (cd "${source_path}" && GIT="$git" "./scripts/git-submodule.sh" update "$git_submodules")
+
+    if test "$fdt" = "git" ; then
+        if [ "$pwd_is_source_path" != "y" ] ; then
+            symlink "$source_path/dtc/Makefile" "dtc/Makefile"
+        fi
+    fi
+fi
+
 # Check that the C++ compiler exists and works with the C compiler.
 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
 if has $cxx; then
-- 
2.27.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/9] meson: Convert undefsym.sh to undefsym.py
  2020-09-02 21:42 [PATCH v2 0/9] Green the msys2 CI make Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 1/9] configure: fixes dtc not cloned when running msys2 CI Yonggang Luo
@ 2020-09-02 21:42 ` Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 3/9] tcg: Fixes dup_const link error Yonggang Luo
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Yonggang Luo @ 2020-09-02 21:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yonggang Luo

undefsym.sh are not msys2 compatible, convert it to python script

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 meson.build         |  2 +-
 scripts/undefsym.py | 57 +++++++++++++++++++++++++++++++++++++++++++++
 scripts/undefsym.sh | 20 ----------------
 3 files changed, 58 insertions(+), 21 deletions(-)
 create mode 100644 scripts/undefsym.py
 delete mode 100755 scripts/undefsym.sh

diff --git a/meson.build b/meson.build
index 55c7d2318c..c9f5d05664 100644
--- a/meson.build
+++ b/meson.build
@@ -863,7 +863,7 @@ foreach d, list : modules
 endforeach
 
 nm = find_program('nm')
-undefsym = find_program('scripts/undefsym.sh')
+undefsym = find_program('scripts/undefsym.py')
 block_syms = custom_target('block.syms', output: 'block.syms',
                              input: [libqemuutil, block_mods],
                              capture: true,
diff --git a/scripts/undefsym.py b/scripts/undefsym.py
new file mode 100644
index 0000000000..c690f88c7a
--- /dev/null
+++ b/scripts/undefsym.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# Before a shared module's DSO is produced, a static library is built for it
+# and passed to this script.  The script generates -Wl,-u options to force
+# the inclusion of symbol from libqemuutil.a if the shared modules need them,
+# This is necessary because the modules may use functions not needed by the
+# executable itself, which would cause the function to not be linked in.
+# Then the DSO loading would fail because of the missing symbol.
+
+
+"""
+Compare the static library with the shared module for compute the symbol duplication
+"""
+
+import sys
+import subprocess
+
+def filter_lines_set(stdout, is_static = True):
+    linesSet = set()
+    for line in stdout.splitlines():
+        tokens = line.split(b' ')
+        if len(tokens) >= 1:
+            if len(tokens) > 1:
+                if is_static and tokens[1] == b'U':
+                    continue
+                if not is_static and tokens[1] != b'U':
+                    continue
+            new_line = b'-Wl,-u,' + tokens[0]
+            if not new_line in linesSet:
+                linesSet.add(new_line)
+    return linesSet
+
+def main(args):
+    if len(args) <= 3:
+        sys.exit(0)
+
+    nm = args[1]
+    staticlib = args[2]
+    pc = subprocess.run([nm, "-P", "-g", staticlib], stdout=subprocess.PIPE)
+    if pc.returncode != 0:
+        sys.exit(-1)
+    lines_set_left = filter_lines_set(pc.stdout)
+
+    shared_modules = args[3:]
+    pc = subprocess.run([nm, "-P", "-g"] + shared_modules, stdout=subprocess.PIPE)
+    if pc.returncode != 0:
+        sys.exit(-1)
+    lines_set_right = filter_lines_set(pc.stdout, False)
+    lines = []
+    for line in sorted(list(lines_set_right)):
+        if line in lines_set_left:
+            lines.append(line)
+    sys.stdout.write(b'\n'.join(lines).decode())
+
+if __name__ == "__main__":
+    main(sys.argv)
diff --git a/scripts/undefsym.sh b/scripts/undefsym.sh
deleted file mode 100755
index b9ec332e95..0000000000
--- a/scripts/undefsym.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#! /usr/bin/env bash
-
-# Before a shared module's DSO is produced, a static library is built for it
-# and passed to this script.  The script generates -Wl,-u options to force
-# the inclusion of symbol from libqemuutil.a if the shared modules need them,
-# This is necessary because the modules may use functions not needed by the
-# executable itself, which would cause the function to not be linked in.
-# Then the DSO loading would fail because of the missing symbol.
-
-if test $# -le 2; then
-  exit 0
-fi
-
-NM=$1
-staticlib=$2
-shift 2
-# Find symbols defined in static libraries and undefined in shared modules
-comm -12 \
-  <( $NM -P -g $staticlib | awk '$2!="U"{print "-Wl,-u," $1}' | sort -u) \
-  <( $NM -P -g "$@" | awk '$2=="U"{print "-Wl,-u," $1}' | sort -u)
-- 
2.27.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 3/9] tcg: Fixes dup_const link error
  2020-09-02 21:42 [PATCH v2 0/9] Green the msys2 CI make Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 1/9] configure: fixes dtc not cloned when running msys2 CI Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 2/9] meson: Convert undefsym.sh to undefsym.py Yonggang Luo
@ 2020-09-02 21:42 ` Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 4/9] tests: handling signal on win32 properly Yonggang Luo
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Yonggang Luo @ 2020-09-02 21:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yonggang Luo

Rename function dup_const to dup_const_eval for avoid confliction with macro dup_const

The link error on msys2

Linking target qemu-system-alpha.exe
C:/CI-Tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libqemu-alpha-softmmu.fa.p/tcg_optimize.c.obj: in function `tcg_optimize':
E:\CI-Cor-Ready\xemu\qemu-build/../qemu.org/tcg/optimize.c:1106: undefined reference to `dup_const'
C:/CI-Tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libqemu-alpha-softmmu.fa.p/tcg_tcg-op-vec.c.obj: in function `tcg_gen_dupi_vec':
E:\CI-Cor-Ready\xemu\qemu-build/../qemu.org/tcg/tcg-op-vec.c:283: undefined reference to `dup_const'
collect2.exe: error: ld returned 1 exit status

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 include/tcg/tcg.h | 6 +++---
 tcg/tcg-op-gvec.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 53ce94c2c5..7f6fe8454b 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -1251,15 +1251,15 @@ static inline int tcg_can_emit_vec_op(TCGOpcode o, TCGType t, unsigned ve)
 void tcg_expand_vec_op(TCGOpcode, TCGType, unsigned, TCGArg, ...);
 
 /* Replicate a constant C accoring to the log2 of the element size.  */
-uint64_t dup_const(unsigned vece, uint64_t c);
+uint64_t dup_const_eval(unsigned vece, uint64_t c);
 
 #define dup_const(VECE, C)                                         \
     (__builtin_constant_p(VECE)                                    \
      ? (  (VECE) == MO_8  ? 0x0101010101010101ull * (uint8_t)(C)   \
         : (VECE) == MO_16 ? 0x0001000100010001ull * (uint16_t)(C)  \
         : (VECE) == MO_32 ? 0x0000000100000001ull * (uint32_t)(C)  \
-        : dup_const(VECE, C))                                      \
-     : dup_const(VECE, C))
+        : dup_const_eval(VECE, C))                                      \
+     : dup_const_eval(VECE, C))
 
 
 /*
diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c
index 3707c0effb..cbb6cd04bc 100644
--- a/tcg/tcg-op-gvec.c
+++ b/tcg/tcg-op-gvec.c
@@ -359,7 +359,7 @@ static inline bool check_size_impl(uint32_t oprsz, uint32_t lnsz)
 static void expand_clr(uint32_t dofs, uint32_t maxsz);
 
 /* Duplicate C as per VECE.  */
-uint64_t (dup_const)(unsigned vece, uint64_t c)
+uint64_t dup_const_eval(unsigned vece, uint64_t c)
 {
     switch (vece) {
     case MO_8:
-- 
2.27.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 4/9] tests: handling signal on win32 properly
  2020-09-02 21:42 [PATCH v2 0/9] Green the msys2 CI make Yonggang Luo
                   ` (2 preceding siblings ...)
  2020-09-02 21:42 ` [PATCH v2 3/9] tcg: Fixes dup_const link error Yonggang Luo
@ 2020-09-02 21:42 ` Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 5/9] configure: Fix include and linkage issue on msys2 Yonggang Luo
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Yonggang Luo @ 2020-09-02 21:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yonggang Luo

SIGABRT should use signal(SIGABRT, sigabrt_handler) to handle on win32

The error:
E:/CI-Cor-Ready/xemu/qemu.org/tests/test-replication.c:559:33: error: invalid use of undefined type 'struct sigaction'
  559 |     sigact = (struct sigaction) {
      |                                 ^

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 tests/test-replication.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/test-replication.c b/tests/test-replication.c
index e0b03dafc2..9ab3666a90 100644
--- a/tests/test-replication.c
+++ b/tests/test-replication.c
@@ -554,6 +554,9 @@ static void sigabrt_handler(int signo)
 
 static void setup_sigabrt_handler(void)
 {
+#ifdef _WIN32
+    signal(SIGABRT, sigabrt_handler);
+#else
     struct sigaction sigact;
 
     sigact = (struct sigaction) {
@@ -562,6 +565,7 @@ static void setup_sigabrt_handler(void)
     };
     sigemptyset(&sigact.sa_mask);
     sigaction(SIGABRT, &sigact, NULL);
+#endif
 }
 
 int main(int argc, char **argv)
-- 
2.27.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 5/9] configure: Fix include and linkage issue on msys2
  2020-09-02 21:42 [PATCH v2 0/9] Green the msys2 CI make Yonggang Luo
                   ` (3 preceding siblings ...)
  2020-09-02 21:42 ` [PATCH v2 4/9] tests: handling signal on win32 properly Yonggang Luo
@ 2020-09-02 21:42 ` Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 6/9] block: Fixes nfs on msys2/mingw Yonggang Luo
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Yonggang Luo @ 2020-09-02 21:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yonggang Luo

On msys2, the -I/e/path/to/qemu -L/e/path/to/qemu are not recognized by the compiler
Cause $PWD are result posix style path such as /e/path/to/qemu that can not be recognized
by mingw gcc, and `pwd -W` are result Windows style path such as E:/path/to/qemu that can
be recognized by the mingw gcc. So we replace all $PWD with $build_path that can
building qemu under msys2/mingw environment.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 configure | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 30f8c4db29..5f2bcc4b57 100755
--- a/configure
+++ b/configure
@@ -13,8 +13,13 @@ export CCACHE_RECACHE=yes
 
 # make source path absolute
 source_path=$(cd "$(dirname -- "$0")"; pwd)
+build_path=$PWD
+if [ "$MSYSTEM" = "MINGW64" -o  "$MSYSTEM" = "MINGW32" ]; then
+source_path=$(cd "$(dirname -- "$0")"; pwd -W)
+build_path=`pwd -W`
+fi
 
-if test "$PWD" = "$source_path"
+if test "$build_path" = "$source_path"
 then
     echo "Using './build' as the directory for build output"
 
@@ -346,7 +351,12 @@ ld_has() {
     $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
 }
 
-if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
+check_valid_build_path="[[:space:]:]"
+if [ "$MSYSTEM" = "MINGW64" -o  "$MSYSTEM" = "MINGW32" ]; then
+check_valid_build_path="[[:space:]]"
+fi
+
+if printf %s\\n "$source_path" "$build_path" | grep -q "$check_valid_build_path";
 then
   error_exit "main directory cannot contain spaces nor colons"
 fi
@@ -943,7 +953,7 @@ Linux)
   linux="yes"
   linux_user="yes"
   kvm="yes"
-  QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
+  QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I${build_path}/linux-headers $QEMU_INCLUDES"
   libudev="yes"
 ;;
 esac
@@ -4259,7 +4269,7 @@ EOF
           fdt=git
           mkdir -p dtc
           fdt_cflags="-I${source_path}/dtc/libfdt"
-          fdt_ldflags="-L$PWD/dtc/libfdt"
+          fdt_ldflags="-L${build_path}/dtc/libfdt"
           fdt_libs="$fdt_libs"
       elif test "$fdt" = "yes" ; then
           # Not a git build & no libfdt found, prompt for system install
@@ -5244,7 +5254,7 @@ case "$capstone" in
     else
       LIBCAPSTONE=libcapstone.a
     fi
-    capstone_libs="-L$PWD/capstone -lcapstone"
+    capstone_libs="-L${build_path}/capstone -lcapstone"
     capstone_cflags="-I${source_path}/capstone/include"
     ;;
 
@@ -6244,8 +6254,8 @@ case "$slirp" in
       git_submodules="${git_submodules} slirp"
     fi
     mkdir -p slirp
-    slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src"
-    slirp_libs="-L$PWD/slirp -lslirp"
+    slirp_cflags="-I${source_path}/slirp/src -I${build_path}/slirp/src"
+    slirp_libs="-L${build_path}/slirp -lslirp"
     if test "$mingw32" = "yes" ; then
       slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
     fi
@@ -8190,7 +8200,7 @@ fi
 mv $cross config-meson.cross
 
 rm -rf meson-private meson-info meson-logs
-NINJA=${ninja:-$PWD/ninjatool} $meson setup \
+NINJA=${ninja:-${build_path}/ninjatool} $meson setup \
         --prefix "${pre_prefix}$prefix" \
         --libdir "${pre_prefix}$libdir" \
         --libexecdir "${pre_prefix}$libexecdir" \
@@ -8212,7 +8222,7 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \
 	-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
 	-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f\
         $cross_arg \
-        "$PWD" "$source_path"
+        "$build_path" "$source_path"
 
 if test "$?" -ne 0 ; then
     error_exit "meson setup failed"
-- 
2.27.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 6/9] block: Fixes nfs on msys2/mingw
  2020-09-02 21:42 [PATCH v2 0/9] Green the msys2 CI make Yonggang Luo
                   ` (4 preceding siblings ...)
  2020-09-02 21:42 ` [PATCH v2 5/9] configure: Fix include and linkage issue on msys2 Yonggang Luo
@ 2020-09-02 21:42 ` Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 7/9] osdep: These function are only available on Non-Win32 system Yonggang Luo
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Yonggang Luo @ 2020-09-02 21:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yonggang Luo

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 block/nfs.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/block/nfs.c b/block/nfs.c
index 61a249a9fc..34b2cd5708 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -24,7 +24,9 @@
 
 #include "qemu/osdep.h"
 
+#if !defined(_WIN32)
 #include <poll.h>
+#endif
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
@@ -51,6 +53,12 @@
 #define QEMU_NFS_MAX_PAGECACHE_SIZE (8388608 / NFS_BLKSIZE)
 #define QEMU_NFS_MAX_DEBUG_LEVEL 2
 
+#if defined (_WIN32)
+#define nfs_stat __stat64
+#else
+#define nfs_stat stat
+#endif
+
 typedef struct NFSClient {
     struct nfs_context *context;
     struct nfsfh *fh;
@@ -58,7 +66,7 @@ typedef struct NFSClient {
     bool has_zero_init;
     AioContext *aio_context;
     QemuMutex mutex;
-    blkcnt_t st_blocks;
+    int64_t st_size;
     bool cache_used;
     NFSServer *server;
     char *path;
@@ -70,7 +78,7 @@ typedef struct NFSRPC {
     int ret;
     int complete;
     QEMUIOVector *iov;
-    struct stat *st;
+    struct nfs_stat *st;
     Coroutine *co;
     NFSClient *client;
 } NFSRPC;
@@ -419,7 +427,7 @@ static int64_t nfs_client_open(NFSClient *client, BlockdevOptionsNfs *opts,
                                int flags, int open_flags, Error **errp)
 {
     int64_t ret = -EINVAL;
-    struct stat st;
+    struct nfs_stat st;
     char *file = NULL, *strp = NULL;
 
     qemu_mutex_init(&client->mutex);
@@ -545,7 +553,7 @@ static int64_t nfs_client_open(NFSClient *client, BlockdevOptionsNfs *opts,
     }
 
     ret = DIV_ROUND_UP(st.st_size, BDRV_SECTOR_SIZE);
-    client->st_blocks = st.st_blocks;
+    client->st_size = st.st_size;
     client->has_zero_init = S_ISREG(st.st_mode);
     *strp = '/';
     goto out;
@@ -729,11 +737,11 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)
 {
     NFSClient *client = bs->opaque;
     NFSRPC task = {0};
-    struct stat st;
+    struct nfs_stat st;
 
     if (bdrv_is_read_only(bs) &&
         !(bs->open_flags & BDRV_O_NOCACHE)) {
-        return client->st_blocks * 512;
+        return client->st_size;
     }
 
     task.bs = bs;
@@ -746,7 +754,7 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)
     nfs_set_events(client);
     BDRV_POLL_WHILE(bs, !task.complete);
 
-    return (task.ret < 0 ? task.ret : st.st_blocks * 512);
+    return (task.ret < 0 ? task.ret : st.st_size);
 }
 
 static int coroutine_fn
@@ -778,7 +786,7 @@ static int nfs_reopen_prepare(BDRVReopenState *state,
                               BlockReopenQueue *queue, Error **errp)
 {
     NFSClient *client = state->bs->opaque;
-    struct stat st;
+    struct nfs_stat st;
     int ret = 0;
 
     if (state->flags & BDRV_O_RDWR && bdrv_is_read_only(state->bs)) {
@@ -800,7 +808,7 @@ static int nfs_reopen_prepare(BDRVReopenState *state,
                        nfs_get_error(client->context));
             return ret;
         }
-        client->st_blocks = st.st_blocks;
+        client->st_size = st.st_size;
     }
 
     return 0;
-- 
2.27.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 7/9] osdep: These function are only available on Non-Win32 system.
  2020-09-02 21:42 [PATCH v2 0/9] Green the msys2 CI make Yonggang Luo
                   ` (5 preceding siblings ...)
  2020-09-02 21:42 ` [PATCH v2 6/9] block: Fixes nfs on msys2/mingw Yonggang Luo
@ 2020-09-02 21:42 ` Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 8/9] ci: fixes msys2 build by upgrading capstone to 4.0.2 Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 9/9] ci: Enable msys2 ci in cirrus Yonggang Luo
  8 siblings, 0 replies; 10+ messages in thread
From: Yonggang Luo @ 2020-09-02 21:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yonggang Luo

int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive);
int qemu_unlock_fd(int fd, int64_t start, int64_t len);
int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive);
bool qemu_has_ofd_lock(void);

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 include/qemu/osdep.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 412962d91a..e80fddd1e8 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -502,11 +502,11 @@ int qemu_close(int fd);
 int qemu_unlink(const char *name);
 #ifndef _WIN32
 int qemu_dup(int fd);
-#endif
 int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive);
 int qemu_unlock_fd(int fd, int64_t start, int64_t len);
 int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive);
 bool qemu_has_ofd_lock(void);
+#endif
 
 #if defined(__HAIKU__) && defined(__i386__)
 #define FMT_pid "%ld"
-- 
2.27.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 8/9] ci: fixes msys2 build by upgrading capstone to 4.0.2
  2020-09-02 21:42 [PATCH v2 0/9] Green the msys2 CI make Yonggang Luo
                   ` (6 preceding siblings ...)
  2020-09-02 21:42 ` [PATCH v2 7/9] osdep: These function are only available on Non-Win32 system Yonggang Luo
@ 2020-09-02 21:42 ` Yonggang Luo
  2020-09-02 21:42 ` [PATCH v2 9/9] ci: Enable msys2 ci in cirrus Yonggang Luo
  8 siblings, 0 replies; 10+ messages in thread
From: Yonggang Luo @ 2020-09-02 21:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yonggang Luo

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 capstone  | 2 +-
 configure | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/capstone b/capstone
index 22ead3e0bf..1d23053284 160000
--- a/capstone
+++ b/capstone
@@ -1 +1 @@
-Subproject commit 22ead3e0bfdb87516656453336160e0a37b066bf
+Subproject commit 1d230532840a37ac032c6ab80128238fc930c6c1
diff --git a/configure b/configure
index 5f2bcc4b57..e42d210e5f 100755
--- a/configure
+++ b/configure
@@ -5248,14 +5248,14 @@ case "$capstone" in
       git_submodules="${git_submodules} capstone"
     fi
     mkdir -p capstone
-    QEMU_CFLAGS="$QEMU_CFLAGS -I${source_path}/capstone/include"
+    QEMU_CFLAGS="$QEMU_CFLAGS -I${source_path}/capstone/include -I${source_path}/capstone/include/capstone"
     if test "$mingw32" = "yes"; then
       LIBCAPSTONE=capstone.lib
     else
       LIBCAPSTONE=libcapstone.a
     fi
     capstone_libs="-L${build_path}/capstone -lcapstone"
-    capstone_cflags="-I${source_path}/capstone/include"
+    capstone_cflags="-I${source_path}/capstone/include -I${source_path}/capstone/include/capstone"
     ;;
 
   system)
-- 
2.27.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 9/9] ci: Enable msys2 ci in cirrus
  2020-09-02 21:42 [PATCH v2 0/9] Green the msys2 CI make Yonggang Luo
                   ` (7 preceding siblings ...)
  2020-09-02 21:42 ` [PATCH v2 8/9] ci: fixes msys2 build by upgrading capstone to 4.0.2 Yonggang Luo
@ 2020-09-02 21:42 ` Yonggang Luo
  8 siblings, 0 replies; 10+ messages in thread
From: Yonggang Luo @ 2020-09-02 21:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yonggang Luo

Install msys2 in a proper way refer to https://github.com/cirruslabs/cirrus-ci-docs/issues/699
The https://wiki.qemu.org/Hosts/W32#Native_builds_with_MSYS2 need to be updated.
There is no need of --cross-prefix, open mingw64.exe instead of msys2.exe then we don't
need the --cross-prefix, besides using ENV
    MSYS: winsymlinks:nativestrict
    MSYSTEM: MINGW64
    CHERE_INVOKING: 1
to opening mingw64 native shell.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 .cirrus.yml                         | 23 +++++++++++++++++++
 scripts/ci/windows/msys2_build.sh   | 34 +++++++++++++++++++++++++++++
 scripts/ci/windows/msys2_install.sh | 31 ++++++++++++++++++++++++++
 3 files changed, 88 insertions(+)
 create mode 100644 scripts/ci/windows/msys2_build.sh
 create mode 100644 scripts/ci/windows/msys2_install.sh

diff --git a/.cirrus.yml b/.cirrus.yml
index f287d23c5b..d377c28412 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -40,3 +40,26 @@ macos_xcode_task:
     - ../configure --cc=clang || { cat config.log; exit 1; }
     - gmake -j$(sysctl -n hw.ncpu)
     - gmake check
+
+windows_msys2_task:
+  windows_container:
+    image: cirrusci/windowsservercore:cmake
+    os_version: 2019
+    cpu: 8
+    memory: 8G
+  env:
+    MSYS: winsymlinks:nativestrict
+    MSYSTEM: MINGW64
+    CHERE_INVOKING: 1
+  printenv_script: C:\tools\msys64\usr\bin\bash.exe -lc 'printenv'
+  install_script:
+    - C:\tools\msys64\usr\bin\bash.exe -lc "cd /c/tools && curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz"
+    - C:\tools\msys64\usr\bin\bash.exe -lc "cd /c/tools && curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig"
+    - C:\tools\msys64\usr\bin\bash.exe -lc "cd /c/tools && pacman -U --noconfirm msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz"
+    - C:\tools\msys64\usr\bin\bash.exe -lc "pacman -Sy --noconfirm"
+    - C:\tools\msys64\usr\bin\bash.exe -lc "pacman --needed --noconfirm -S bash pacman pacman-mirrors msys2-runtime"
+    - taskkill /F /IM gpg-agent.exe
+    - C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -Su"
+    - C:\tools\msys64\usr\bin\bash.exe -lc "sh scripts/ci/windows/msys2_install.sh"
+  script:
+    C:\tools\msys64\usr\bin\bash.exe -lc "sh scripts/ci/windows/msys2_build.sh"
diff --git a/scripts/ci/windows/msys2_build.sh b/scripts/ci/windows/msys2_build.sh
new file mode 100644
index 0000000000..850baccd49
--- /dev/null
+++ b/scripts/ci/windows/msys2_build.sh
@@ -0,0 +1,34 @@
+export QEMU_DIR=$PWD
+mkdir ../qemu-build
+cd ../qemu-build
+$QEMU_DIR/configure \
+  --python=python3 \
+  --enable-gtk --enable-sdl \
+  --enable-capstone=git \
+  --enable-stack-protector \
+  --ninja=ninja \
+  --enable-gnutls \
+  --enable-nettle \
+  --enable-vnc \
+  --enable-vnc-sasl \
+  --enable-vnc-jpeg \
+  --enable-vnc-png \
+  --enable-membarrier \
+  --enable-slirp=git \
+  --disable-kvm \
+  --enable-hax \
+  --enable-whpx \
+  --disable-spice \
+  --enable-lzo \
+  --enable-snappy \
+  --enable-bzip2 \
+  --enable-vdi \
+  --enable-qcow1 \
+  --enable-tools \
+  --enable-libusb \
+  --enable-usb-redir \
+  --enable-libnfs \
+  --enable-libssh \
+  --disable-pie
+make -j$NUMBER_OF_PROCESSORS
+# make check
diff --git a/scripts/ci/windows/msys2_install.sh b/scripts/ci/windows/msys2_install.sh
new file mode 100644
index 0000000000..ff35b73ef2
--- /dev/null
+++ b/scripts/ci/windows/msys2_install.sh
@@ -0,0 +1,31 @@
+pacman --noconfirm -S --needed \
+base-devel \
+git \
+mingw-w64-x86_64-python \
+mingw-w64-x86_64-python-setuptools \
+mingw-w64-x86_64-toolchain \
+mingw-w64-x86_64-SDL2 \
+mingw-w64-x86_64-SDL2_image \
+mingw-w64-x86_64-gtk3 \
+mingw-w64-x86_64-ninja \
+mingw-w64-x86_64-make \
+mingw-w64-x86_64-lzo2 \
+mingw-w64-x86_64-libjpeg-turbo \
+mingw-w64-x86_64-pixman \
+mingw-w64-x86_64-libgcrypt \
+mingw-w64-x86_64-capstone \
+mingw-w64-x86_64-libpng \
+mingw-w64-x86_64-libssh \
+mingw-w64-x86_64-libxml2 \
+mingw-w64-x86_64-snappy \
+mingw-w64-x86_64-libusb \
+mingw-w64-x86_64-usbredir \
+mingw-w64-x86_64-libtasn1 \
+mingw-w64-x86_64-libnfs \
+mingw-w64-x86_64-nettle \
+mingw-w64-x86_64-cyrus-sasl \
+mingw-w64-x86_64-curl \
+mingw-w64-x86_64-gnutls \
+mingw-w64-x86_64-zstd \
+mingw-w64-x86_64-glib2
+
-- 
2.27.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-09-02 21:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-02 21:42 [PATCH v2 0/9] Green the msys2 CI make Yonggang Luo
2020-09-02 21:42 ` [PATCH v2 1/9] configure: fixes dtc not cloned when running msys2 CI Yonggang Luo
2020-09-02 21:42 ` [PATCH v2 2/9] meson: Convert undefsym.sh to undefsym.py Yonggang Luo
2020-09-02 21:42 ` [PATCH v2 3/9] tcg: Fixes dup_const link error Yonggang Luo
2020-09-02 21:42 ` [PATCH v2 4/9] tests: handling signal on win32 properly Yonggang Luo
2020-09-02 21:42 ` [PATCH v2 5/9] configure: Fix include and linkage issue on msys2 Yonggang Luo
2020-09-02 21:42 ` [PATCH v2 6/9] block: Fixes nfs on msys2/mingw Yonggang Luo
2020-09-02 21:42 ` [PATCH v2 7/9] osdep: These function are only available on Non-Win32 system Yonggang Luo
2020-09-02 21:42 ` [PATCH v2 8/9] ci: fixes msys2 build by upgrading capstone to 4.0.2 Yonggang Luo
2020-09-02 21:42 ` [PATCH v2 9/9] ci: Enable msys2 ci in cirrus Yonggang Luo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).