qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 00/16] Msys2 patches patches
@ 2020-09-08 18:49 Yonggang Luo
  2020-09-08 18:49 ` [PULL 01/16] block: Fixes nfs on msys2/mingw Yonggang Luo
                   ` (16 more replies)
  0 siblings, 17 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

The following changes since commit 6779038537360e957dbded830f76b08ef5070161:

  Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-09-08' int=
o staging (2020-09-08 17:23:31 +0100)

are available in the Git repository at:

  http://github.com/lygstate/qemu tags/msys2-patches-pull-request

for you to fetch changes up to 1892e4360f55ac8cbeeeae0043e0a9dc05c50269:

  rcu: add uninit destructor for rcu (2020-09-09 02:34:59 +0800)

----------------------------------------------------------------
msys2 patch queue 2020-09-09

It first introduce msys2 CI on cirrus by fixes nfs, capstone, curses and disa=
ble
partial test-char tests.
And then fixes a number of unit tests failure on msys2/mingw

----------------------------------------------------------------

Yonggang Luo (16):
  block: Fixes nfs on msys2/mingw
  ci: fixes msys2 build by upgrading capstone to 4.0.2
  configure: Fixes ncursesw detection under msys2/mingw and enable
    curses
  curses: Fixes curses compiling errors.
  tests: disable /char/stdio/* tests in test-char.c on win32
  ci: Enable msys2 ci in cirrus
  tests: Trying fixes test-replication.c on msys2/mingw.
  block: get file-win32.c handle locking option consistence with
    file-posix.c
  osdep: These function are only available on Non-Win32 system.
  meson: Use -b to ignore CR vs. CR-LF issues on Windows
  meson: disable crypto tests are empty under win32
  meson: remove empty else and duplicated gio deps
  vmstate: Fixes test-vmstate.c on msys2/mingw
  cirrus: Building freebsd in a single short
  logging: Fixes memory leak in test-logging.c
  rcu: add uninit destructor for rcu

 .cirrus.yml                         | 59 ++++++++++++++++-------------
 block/file-win32.c                  | 23 ++++++++++-
 block/nfs.c                         | 26 ++++++++-----
 capstone                            |  2 +-
 configure                           | 11 ++----
 include/qemu/osdep.h                |  2 +-
 include/qemu/rcu.h                  |  5 +++
 meson.build                         |  6 ---
 scripts/ci/windows/msys2-build.sh   | 28 ++++++++++++++
 scripts/ci/windows/msys2-install.sh | 33 ++++++++++++++++
 tests/meson.build                   |  3 +-
 tests/qapi-schema/meson.build       |  2 +-
 tests/test-char.c                   |  4 ++
 tests/test-logging.c                |  4 +-
 tests/test-replication.c            | 13 +++++--
 tests/test-vmstate.c                |  2 +-
 ui/curses.c                         | 14 +++----
 util/rcu.c                          | 37 +++++++++++++++++-
 18 files changed, 205 insertions(+), 69 deletions(-)
 create mode 100644 scripts/ci/windows/msys2-build.sh
 create mode 100644 scripts/ci/windows/msys2-install.sh

--=20
2.28.0.windows.1



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

* [PULL 01/16] block: Fixes nfs on msys2/mingw
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:57   ` Eric Blake
  2020-09-08 18:49 ` [PULL 02/16] ci: fixes msys2 build by upgrading capstone to 4.0.2 Yonggang Luo
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

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.28.0.windows.1



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

* [PULL 02/16] ci: fixes msys2 build by upgrading capstone to 4.0.2
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
  2020-09-08 18:49 ` [PULL 01/16] block: Fixes nfs on msys2/mingw Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:59   ` Eric Blake
  2020-09-08 18:49 ` [PULL 03/16] configure: Fixes ncursesw detection under msys2/mingw and enable curses Yonggang Luo
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 capstone  | 2 +-
 configure | 2 +-
 2 files changed, 2 insertions(+), 2 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 4231d56bcc..f4f8bc3756 100755
--- a/configure
+++ b/configure
@@ -5156,7 +5156,7 @@ case "$capstone" in
       LIBCAPSTONE=libcapstone.a
     fi
     capstone_libs="-Lcapstone -lcapstone"
-    capstone_cflags="-I${source_path}/capstone/include"
+    capstone_cflags="-I${source_path}/capstone/include -I${source_path}/capstone/include/capstone"
     ;;
 
   system)
-- 
2.28.0.windows.1



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

* [PULL 03/16] configure: Fixes ncursesw detection under msys2/mingw and enable curses
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
  2020-09-08 18:49 ` [PULL 01/16] block: Fixes nfs on msys2/mingw Yonggang Luo
  2020-09-08 18:49 ` [PULL 02/16] ci: fixes msys2 build by upgrading capstone to 4.0.2 Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 19:02   ` Eric Blake
  2020-09-08 18:49 ` [PULL 04/16] curses: Fixes curses compiling errors Yonggang Luo
                   ` (13 subsequent siblings)
  16 siblings, 1 reply; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

The mingw pkg-config are showing following absolute path and contains : as the separator,
so we must handling : properly.

-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC:/CI-Tools/msys64/mingw64/include/ncursesw:-I/usr/include/ncursesw:
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -pipe -lncursesw -lgnurx -ltre -lintl -liconv
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lncursesw
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lcursesw
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lncursesw
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lcursesw
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -lncursesw
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -lcursesw

MINGW doesn't have langinfo.h, only exist in glic and musl

gcc test.c -DNCURSES_WIDECHAR -I/mingw64/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv
test.c:4:10: fatal error: langinfo.h: No such file or directory
    4 | #include <langinfo.h>
      |          ^~~~~~~~~~~~
compilation terminated.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 configure   |  9 +++------
 ui/curses.c | 10 +++++-----
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index f4f8bc3756..2e6d54e15b 100755
--- a/configure
+++ b/configure
@@ -3653,8 +3653,8 @@ if test "$iconv" = "no" ; then
 fi
 if test "$curses" != "no" ; then
   if test "$mingw32" = "yes" ; then
-    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
-    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
+    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/${MSYSTEM,,}/include/ncursesw:"
+    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw"
   else
     curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
     curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
@@ -3664,17 +3664,14 @@ if test "$curses" != "no" ; then
 #include <locale.h>
 #include <curses.h>
 #include <wchar.h>
-#include <langinfo.h>
 int main(void) {
-  const char *codeset;
   wchar_t wch = L'w';
   setlocale(LC_ALL, "");
   resize_term(0, 0);
   addwstr(L"wide chars\n");
   addnwstr(&wch, 1);
   add_wch(WACS_DEGREE);
-  codeset = nl_langinfo(CODESET);
-  return codeset != 0;
+  return 0;
 }
 EOF
   IFS=:
diff --git a/ui/curses.c b/ui/curses.c
index a59b23a9cf..12bc682cf9 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -30,7 +30,6 @@
 #endif
 #include <locale.h>
 #include <wchar.h>
-#include <langinfo.h>
 #include <iconv.h>
 
 #include "qapi/error.h"
@@ -526,6 +525,7 @@ static void font_setup(void)
     iconv_t nativecharset_to_ucs2;
     iconv_t font_conv;
     int i;
+    g_autofree gchar *local_codeset = g_get_codeset();
 
     /*
      * Control characters are normally non-printable, but VGA does have
@@ -566,14 +566,14 @@ static void font_setup(void)
       0x25bc
     };
 
-    ucs2_to_nativecharset = iconv_open(nl_langinfo(CODESET), "UCS-2");
+    ucs2_to_nativecharset = iconv_open(local_codeset, "UCS-2");
     if (ucs2_to_nativecharset == (iconv_t) -1) {
         fprintf(stderr, "Could not convert font glyphs from UCS-2: '%s'\n",
                         strerror(errno));
         exit(1);
     }
 
-    nativecharset_to_ucs2 = iconv_open("UCS-2", nl_langinfo(CODESET));
+    nativecharset_to_ucs2 = iconv_open("UCS-2", local_codeset);
     if (nativecharset_to_ucs2 == (iconv_t) -1) {
         iconv_close(ucs2_to_nativecharset);
         fprintf(stderr, "Could not convert font glyphs to UCS-2: '%s'\n",
@@ -581,7 +581,7 @@ static void font_setup(void)
         exit(1);
     }
 
-    font_conv = iconv_open(nl_langinfo(CODESET), font_charset);
+    font_conv = iconv_open(local_codeset, font_charset);
     if (font_conv == (iconv_t) -1) {
         iconv_close(ucs2_to_nativecharset);
         iconv_close(nativecharset_to_ucs2);
@@ -602,7 +602,7 @@ static void font_setup(void)
     /* DEL */
     convert_ucs(0x7F, 0x2302, ucs2_to_nativecharset);
 
-    if (strcmp(nl_langinfo(CODESET), "UTF-8")) {
+    if (strcmp(local_codeset, "UTF-8")) {
         /* Non-Unicode capable, use termcap equivalents for those available */
         for (i = 0; i <= 0xFF; i++) {
             wchar_t wch[CCHARW_MAX];
-- 
2.28.0.windows.1



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

* [PULL 04/16] curses: Fixes curses compiling errors.
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (2 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 03/16] configure: Fixes ncursesw detection under msys2/mingw and enable curses Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 20:28   ` Peter Maydell
  2020-09-08 18:49 ` [PULL 05/16] tests: disable /char/stdio/* tests in test-char.c on win32 Yonggang Luo
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

This is the compiling error:
../ui/curses.c: In function 'curses_refresh':
../ui/curses.c:256:5: error: 'next_maybe_keycode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  256 |     curses2foo(_curses2keycode, _curseskey2keycode, chr, maybe_keycode)
      |     ^~~~~~~~~~
../ui/curses.c:302:32: note: 'next_maybe_keycode' was declared here
  302 |             enum maybe_keycode next_maybe_keycode;
      |                                ^~~~~~~~~~~~~~~~~~
../ui/curses.c:256:5: error: 'maybe_keycode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  256 |     curses2foo(_curses2keycode, _curseskey2keycode, chr, maybe_keycode)
      |     ^~~~~~~~~~
../ui/curses.c:265:24: note: 'maybe_keycode' was declared here
  265 |     enum maybe_keycode maybe_keycode;
      |                        ^~~~~~~~~~~~~
cc1.exe: all warnings being treated as errors

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 ui/curses.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui/curses.c b/ui/curses.c
index 12bc682cf9..e4f9588c3e 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -262,7 +262,7 @@ static int curses2foo(const int _curses2foo[], const int _curseskey2foo[],
 static void curses_refresh(DisplayChangeListener *dcl)
 {
     int chr, keysym, keycode, keycode_alt;
-    enum maybe_keycode maybe_keycode;
+    enum maybe_keycode maybe_keycode = CURSES_KEYCODE;
 
     curses_winch_check();
 
@@ -299,7 +299,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
 
         /* alt or esc key */
         if (keycode == 1) {
-            enum maybe_keycode next_maybe_keycode;
+            enum maybe_keycode next_maybe_keycode = CURSES_KEYCODE;
             int nextchr = console_getch(&next_maybe_keycode);
 
             if (nextchr != -1) {
-- 
2.28.0.windows.1



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

* [PULL 05/16] tests: disable /char/stdio/* tests in test-char.c on win32
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (3 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 04/16] curses: Fixes curses compiling errors Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 06/16] ci: Enable msys2 ci in cirrus Yonggang Luo
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

These tests are blocking test-char to be finished.

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

diff --git a/tests/test-char.c b/tests/test-char.c
index d35cc839bc..80e5bac61a 100644
--- a/tests/test-char.c
+++ b/tests/test-char.c
@@ -103,6 +103,7 @@ static void char_console_test(void)
     g_test_trap_assert_stdout("CONSOLE");
 }
 #endif
+#ifndef _WIN32
 static void char_stdio_test_subprocess(void)
 {
     Chardev *chr;
@@ -126,6 +127,7 @@ static void char_stdio_test(void)
     g_test_trap_assert_passed();
     g_test_trap_assert_stdout("buf");
 }
+#endif
 
 static void char_ringbuf_test(void)
 {
@@ -1471,8 +1473,10 @@ int main(int argc, char **argv)
     g_test_add_func("/char/console/subprocess", char_console_test_subprocess);
     g_test_add_func("/char/console", char_console_test);
 #endif
+#ifndef _WIN32
     g_test_add_func("/char/stdio/subprocess", char_stdio_test_subprocess);
     g_test_add_func("/char/stdio", char_stdio_test);
+#endif
 #ifndef _WIN32
     g_test_add_func("/char/pipe", char_pipe_test);
 #endif
-- 
2.28.0.windows.1



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

* [PULL 06/16] ci: Enable msys2 ci in cirrus
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (4 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 05/16] tests: disable /char/stdio/* tests in test-char.c on win32 Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 07/16] tests: Trying fixes test-replication.c on msys2/mingw Yonggang Luo
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

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 we using environment variable settings:
    MSYS: winsymlinks:nativestrict
    MSYSTEM: MINGW64
    CHERE_INVOKING: 1
to opening mingw64 native shell.
We now running tests with make -i check to skip tests errors.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 .cirrus.yml                         | 24 +++++++++++++++++++++
 scripts/ci/windows/msys2-build.sh   | 28 ++++++++++++++++++++++++
 scripts/ci/windows/msys2-install.sh | 33 +++++++++++++++++++++++++++++
 3 files changed, 85 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 3dd9fcff7f..49335e68c9 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -63,3 +63,27 @@ macos_xcode_task:
                    --enable-werror --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..d9d046b5b0
--- /dev/null
+++ b/scripts/ci/windows/msys2-build.sh
@@ -0,0 +1,28 @@
+mkdir build
+cd build
+../configure \
+--python=python3 \
+--ninja=ninja \
+--enable-stack-protector \
+--enable-guest-agent \
+--disable-pie \
+--enable-gnutls --enable-nettle \
+--enable-sdl --enable-sdl-image --enable-gtk --disable-vte --enable-curses --enable-iconv \
+--enable-vnc --enable-vnc-sasl --enable-vnc-jpeg --enable-vnc-png \
+--enable-slirp=git \
+--disable-brlapi --enable-curl \
+--enable-fdt \
+--disable-kvm --enable-hax --enable-whpx \
+--enable-libnfs --enable-libusb --enable-live-block-migration --enable-usb-redir \
+--enable-lzo --enable-snappy --enable-bzip2 --enable-zstd \
+--enable-membarrier --enable-coroutine-pool \
+--enable-libssh --enable-libxml2 \
+--enable-jemalloc --enable-avx2 \
+--enable-replication \
+--enable-tools \
+--enable-bochs --enable-cloop --enable-dmg --enable-qcow1 --enable-vdi --enable-vvfat --enable-qed --enable-parallels \
+--enable-sheepdog \
+--enable-capstone=git
+
+make -j$NUMBER_OF_PROCESSORS
+make -i -j$NUMBER_OF_PROCESSORS check
diff --git a/scripts/ci/windows/msys2-install.sh b/scripts/ci/windows/msys2-install.sh
new file mode 100644
index 0000000000..6086452399
--- /dev/null
+++ b/scripts/ci/windows/msys2-install.sh
@@ -0,0 +1,33 @@
+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-glib2 \
+mingw-w64-x86_64-ninja \
+mingw-w64-x86_64-make \
+mingw-w64-x86_64-jemalloc \
+mingw-w64-x86_64-lzo2 \
+mingw-w64-x86_64-zstd \
+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 \
+
-- 
2.28.0.windows.1



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

* [PULL 07/16] tests: Trying fixes test-replication.c on msys2/mingw.
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (5 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 06/16] ci: Enable msys2 ci in cirrus Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 08/16] block: get file-win32.c handle locking option consistence with file-posix.c Yonggang Luo
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

On Windows there is no path like /tmp/s_local_disk.XXXXXX

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

diff --git a/tests/test-replication.c b/tests/test-replication.c
index 9ab3666a90..cfc1ae6feb 100644
--- a/tests/test-replication.c
+++ b/tests/test-replication.c
@@ -23,14 +23,14 @@
 
 /* primary */
 #define P_ID "primary-id"
-static char p_local_disk[] = "/tmp/p_local_disk.XXXXXX";
+static char p_local_disk[PATH_MAX];
 
 /* secondary */
 #define S_ID "secondary-id"
 #define S_LOCAL_DISK_ID "secondary-local-disk-id"
-static char s_local_disk[] = "/tmp/s_local_disk.XXXXXX";
-static char s_active_disk[] = "/tmp/s_active_disk.XXXXXX";
-static char s_hidden_disk[] = "/tmp/s_hidden_disk.XXXXXX";
+static char s_local_disk[PATH_MAX];
+static char s_active_disk[PATH_MAX];
+static char s_hidden_disk[PATH_MAX];
 
 /* FIXME: steal from blockdev.c */
 QemuOptsList qemu_drive_opts = {
@@ -571,6 +571,11 @@ static void setup_sigabrt_handler(void)
 int main(int argc, char **argv)
 {
     int ret;
+    const char *tmpdir = g_get_tmp_dir();
+    snprintf(p_local_disk, sizeof(p_local_disk), "%s/p_local_disk.XXXXXX", tmpdir);
+    snprintf(s_local_disk, sizeof(s_local_disk), "%s/s_local_disk.XXXXXX", tmpdir);
+    snprintf(s_active_disk, sizeof(s_active_disk), "%s/s_active_disk.XXXXXX", tmpdir);
+    snprintf(s_hidden_disk, sizeof(s_hidden_disk), "%s/s_hidden_disk.XXXXXX", tmpdir);
     qemu_init_main_loop(&error_fatal);
     bdrv_init();
 
-- 
2.28.0.windows.1



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

* [PULL 08/16] block: get file-win32.c handle locking option consistence with file-posix.c
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (6 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 07/16] tests: Trying fixes test-replication.c on msys2/mingw Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 09/16] osdep: These function are only available on Non-Win32 system Yonggang Luo
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 block/file-win32.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/block/file-win32.c b/block/file-win32.c
index ab69bd811a..14e5f5c3b5 100644
--- a/block/file-win32.c
+++ b/block/file-win32.c
@@ -299,6 +299,11 @@ static QemuOptsList raw_runtime_opts = {
             .type = QEMU_OPT_STRING,
             .help = "host AIO implementation (threads, native)",
         },
+        {
+            .name = "locking",
+            .type = QEMU_OPT_STRING,
+            .help = "file locking mode (on/off/auto, default: auto)",
+        },
         { /* end of list */ }
     },
 };
@@ -334,6 +339,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
     const char *filename;
     bool use_aio;
     int ret;
+    OnOffAuto locking;
 
     s->type = FTYPE_FILE;
 
@@ -342,11 +348,24 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
         ret = -EINVAL;
         goto fail;
     }
-
-    if (qdict_get_try_bool(options, "locking", false)) {
+    locking = qapi_enum_parse(&OnOffAuto_lookup,
+                              qemu_opt_get(opts, "locking"),
+                              ON_OFF_AUTO_AUTO, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        ret = -EINVAL;
+        goto fail;
+    }
+    switch (locking) {
+    case ON_OFF_AUTO_ON:
         error_setg(errp, "locking=on is not supported on Windows");
         ret = -EINVAL;
         goto fail;
+    case ON_OFF_AUTO_OFF:
+    case ON_OFF_AUTO_AUTO:
+        break;
+    default:
+        g_assert_not_reached();
     }
 
     filename = qemu_opt_get(opts, "filename");
-- 
2.28.0.windows.1



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

* [PULL 09/16] osdep: These function are only available on Non-Win32 system.
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (7 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 08/16] block: get file-win32.c handle locking option consistence with file-posix.c Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 10/16] meson: Use -b to ignore CR vs. CR-LF issues on Windows Yonggang Luo
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

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.28.0.windows.1



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

* [PULL 10/16] meson: Use -b to ignore CR vs. CR-LF issues on Windows
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (8 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 09/16] osdep: These function are only available on Non-Win32 system Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 11/16] meson: disable crypto tests are empty under win32 Yonggang Luo
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

On windows, a difference in line endings causes testsuite failures
complaining that every single line in files such as
'tests/qapi-schemadoc-good.texi' is wrong.  Fix it by adding -b to diff.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 tests/qapi-schema/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build
index c87d141417..f1449298b0 100644
--- a/tests/qapi-schema/meson.build
+++ b/tests/qapi-schema/meson.build
@@ -220,6 +220,6 @@ qapi_doc = custom_target('QAPI doc',
 
 # "full_path()" needed here to work around
 # https://github.com/mesonbuild/meson/issues/7585
-test('QAPI doc', diff, args: ['-u', files('doc-good.texi'), qapi_doc[0].full_path()],
+test('QAPI doc', diff, args: ['-b', '-u', files('doc-good.texi'), qapi_doc[0].full_path()],
      depends: qapi_doc,
      suite: ['qapi-schema', 'qapi-doc'])
-- 
2.28.0.windows.1



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

* [PULL 11/16] meson: disable crypto tests are empty under win32
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (9 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 10/16] meson: Use -b to ignore CR vs. CR-LF issues on Windows Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 12/16] meson: remove empty else and duplicated gio deps Yonggang Luo
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

Disable following tests on msys2/mingw
      'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
                                   tasn1, crypto],
      'test-crypto-tlssession': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c', 'crypto-tls-psk-helpers.c',
                                 tasn1, crypto],
      'test-io-channel-tls': ['io-channel-helpers.c', 'crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
                              tasn1, io, crypto]}

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 tests/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/meson.build b/tests/meson.build
index 998e4c48f9..b470a90e3a 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -145,7 +145,8 @@ if have_block
     'test-crypto-block': [io],
   }
   if 'CONFIG_GNUTLS' in config_host and \
-     'CONFIG_TASN1' in config_host
+     'CONFIG_TASN1' in config_host and \
+     'CONFIG_POSIX' in config_host
     tests += {
       'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
                                    tasn1, crypto],
-- 
2.28.0.windows.1



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

* [PULL 12/16] meson: remove empty else and duplicated gio deps
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (10 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 11/16] meson: disable crypto tests are empty under win32 Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 13/16] vmstate: Fixes test-vmstate.c on msys2/mingw Yonggang Luo
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 meson.build | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/meson.build b/meson.build
index 5421eca66a..0b1741557d 100644
--- a/meson.build
+++ b/meson.build
@@ -317,7 +317,6 @@ opengl = not_found
 if 'CONFIG_OPENGL' in config_host
   opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
                               link_args: config_host['OPENGL_LIBS'].split())
-else
 endif
 gtk = not_found
 if 'CONFIG_GTK' in config_host
@@ -344,11 +343,6 @@ if 'CONFIG_ICONV' in config_host
   iconv = declare_dependency(compile_args: config_host['ICONV_CFLAGS'].split(),
                              link_args: config_host['ICONV_LIBS'].split())
 endif
-gio = not_found
-if 'CONFIG_GIO' in config_host
-  gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
-                           link_args: config_host['GIO_LIBS'].split())
-endif
 vnc = not_found
 png = not_found
 jpeg = not_found
-- 
2.28.0.windows.1



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

* [PULL 13/16] vmstate: Fixes test-vmstate.c on msys2/mingw
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (11 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 12/16] meson: remove empty else and duplicated gio deps Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 14/16] cirrus: Building freebsd in a single short Yonggang Luo
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang,
	Philippe Mathieu-Daudé,
	Li-Wen Hsu

The vmstate are valid on win32, just need generate tmp path properly

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/test-vmstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index f8de709a0b..4c453575bb 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -34,7 +34,6 @@
 #include "qemu/module.h"
 #include "io/channel-file.h"
 
-static char temp_file[] = "/tmp/vmst.test.XXXXXX";
 static int temp_fd;
 
 
@@ -1487,6 +1486,7 @@ static void test_tmp_struct(void)
 
 int main(int argc, char **argv)
 {
+    g_autofree char* temp_file = g_strdup_printf("%s/vmst.test.XXXXXX", g_get_tmp_dir());
     temp_fd = mkstemp(temp_file);
 
     module_call_init(MODULE_INIT_QOM);
-- 
2.28.0.windows.1



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

* [PULL 14/16] cirrus: Building freebsd in a single short
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (12 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 13/16] vmstate: Fixes test-vmstate.c on msys2/mingw Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 15/16] logging: Fixes memory leak in test-logging.c Yonggang Luo
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

freebsd 1 hour limit not hit anymore

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 .cirrus.yml | 35 ++++++++---------------------------
 1 file changed, 8 insertions(+), 27 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 49335e68c9..b0004273bb 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -1,38 +1,19 @@
 env:
   CIRRUS_CLONE_DEPTH: 1
 
-freebsd_1st_task:
+freebsd_12_task:
   freebsd_instance:
     image_family: freebsd-12-1
-    cpu: 4
-    memory: 4G
-  install_script: ASSUME_ALWAYS_YES=yes pkg bootstrap -f ; pkg install -y
-    bash curl cyrus-sasl git glib gmake gnutls gsed
-    nettle perl5 pixman pkgconf png usbredir
+    cpu: 8
+    memory: 8G
+  install_script:
+    - ASSUME_ALWAYS_YES=yes pkg bootstrap -f ;
+    - pkg install -y bash curl cyrus-sasl git glib gmake gnutls gsed 
+          nettle perl5 pixman pkgconf png usbredir
   script:
     - mkdir build
     - cd build
-    - ../configure --disable-user --target-list-exclude='alpha-softmmu
-        ppc64-softmmu ppc-softmmu riscv32-softmmu riscv64-softmmu s390x-softmmu
-        sparc64-softmmu sparc-softmmu x86_64-softmmu i386-softmmu'
-        --enable-werror || { cat config.log; exit 1; }
-    - gmake -j$(sysctl -n hw.ncpu)
-    - gmake -j$(sysctl -n hw.ncpu) check
-
-freebsd_2nd_task:
-  freebsd_instance:
-    image_family: freebsd-12-1
-    cpu: 4
-    memory: 4G
-  install_script: ASSUME_ALWAYS_YES=yes pkg bootstrap -f ; pkg install -y
-    bash curl cyrus-sasl git glib gmake gnutls gtk3 gsed libepoxy mesa-libs
-    nettle perl5 pixman pkgconf png SDL2 usbredir
-  script:
-    - ./configure --enable-werror --target-list='alpha-softmmu ppc64-softmmu
-        ppc-softmmu riscv32-softmmu riscv64-softmmu s390x-softmmu
-        sparc64-softmmu sparc-softmmu x86_64-softmmu i386-softmmu
-        sparc-bsd-user sparc64-bsd-user x86_64-bsd-user i386-bsd-user'
-        || { cat config.log; exit 1; }
+    - ../configure --enable-werror || { cat config.log; exit 1; }
     - gmake -j$(sysctl -n hw.ncpu)
     - gmake -j$(sysctl -n hw.ncpu) check
 
-- 
2.28.0.windows.1



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

* [PULL 15/16] logging: Fixes memory leak in test-logging.c
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (13 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 14/16] cirrus: Building freebsd in a single short Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:49 ` [PULL 16/16] rcu: add uninit destructor for rcu Yonggang Luo
  2020-09-08 18:56 ` [PULL 00/16] Msys2 patches patches Eric Blake
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang,
	Philippe Mathieu-Daudé,
	Li-Wen Hsu

g_dir_make_tmp Returns the actual name used. This string should be
freed with g_free() when not needed any longer and is is in the GLib
file name encoding. In case of errors, NULL is returned and error will
be set. Use g_autofree to free it properly

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 tests/test-logging.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/test-logging.c b/tests/test-logging.c
index 8a1161de1d..957f6c08cd 100644
--- a/tests/test-logging.c
+++ b/tests/test-logging.c
@@ -196,7 +196,7 @@ static void rmdir_full(gchar const *root)
 
 int main(int argc, char **argv)
 {
-    gchar *tmp_path = g_dir_make_tmp("qemu-test-logging.XXXXXX", NULL);
+    g_autofree gchar *tmp_path = g_dir_make_tmp("qemu-test-logging.XXXXXX", NULL);
     int rc;
 
     g_test_init(&argc, &argv, NULL);
-- 
2.28.0.windows.1



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

* [PULL 16/16] rcu: add uninit destructor for rcu
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (14 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 15/16] logging: Fixes memory leak in test-logging.c Yonggang Luo
@ 2020-09-08 18:49 ` Yonggang Luo
  2020-09-08 18:56 ` [PULL 00/16] Msys2 patches patches Eric Blake
  16 siblings, 0 replies; 26+ messages in thread
From: Yonggang Luo @ 2020-09-08 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Ed Maste, Michael Roth, qemu-block, Stefan Weil,
	Xie Changlong, Peter Lieven, Markus Armbruster, Max Reitz,
	Yonggang Luo, Gerd Hoffmann, Wen Congyang, Li-Wen Hsu

This is necessary if the pending  rcu calls are closing and removing
temp files. This also provide a function
void rcu_wait_finished(void);
to fixes test-logging.c test failure on msys2/mingw.
On windows if the file doesn't closed, you can not remove it.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 include/qemu/rcu.h   |  5 +++++
 tests/test-logging.c |  2 ++
 util/rcu.c           | 37 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h
index 570aa603eb..dd0a92c1d0 100644
--- a/include/qemu/rcu.h
+++ b/include/qemu/rcu.h
@@ -124,6 +124,11 @@ extern void rcu_unregister_thread(void);
 extern void rcu_enable_atfork(void);
 extern void rcu_disable_atfork(void);
 
+/*
+ * Wait all rcu call executed and exit the rcu thread.
+ */
+extern void rcu_wait_finished(void);
+
 struct rcu_head;
 typedef void RCUCBFunc(struct rcu_head *head);
 
diff --git a/tests/test-logging.c b/tests/test-logging.c
index 957f6c08cd..7a5b59f4a5 100644
--- a/tests/test-logging.c
+++ b/tests/test-logging.c
@@ -210,6 +210,8 @@ int main(int argc, char **argv)
                          tmp_path, test_logfile_lock);
 
     rc = g_test_run();
+    qemu_log_close();
+    rcu_wait_finished();
 
     rmdir_full(tmp_path);
     g_free(tmp_path);
diff --git a/util/rcu.c b/util/rcu.c
index 60a37f72c3..43367988b9 100644
--- a/util/rcu.c
+++ b/util/rcu.c
@@ -308,10 +308,20 @@ void rcu_unregister_thread(void)
     qemu_mutex_unlock(&rcu_registry_lock);
 }
 
+typedef struct QemuRcuMessage {
+    struct rcu_head rcu;
+    void *message;
+} QemuRcuMessage;
+
+static int rcu_thread_exit_called = 0;
+static int rcu_thread_exited = 0;
+static QemuRcuMessage rcu_thread_message;
+
 static void rcu_init_complete(void)
 {
     QemuThread thread;
-
+    atomic_mb_set(&rcu_thread_exit_called, 0);
+    atomic_mb_set(&rcu_thread_exited, 0);
     qemu_mutex_init(&rcu_registry_lock);
     qemu_mutex_init(&rcu_sync_lock);
     qemu_event_init(&rcu_gp_event, true);
@@ -327,6 +337,26 @@ static void rcu_init_complete(void)
     rcu_register_thread();
 }
 
+static void rcu_thread_exit(QemuRcuMessage *param)
+{
+    atomic_mb_set((int*)param->message, 1);
+    qemu_thread_exit(NULL);
+}
+
+void rcu_wait_finished(void)
+{
+    if (atomic_xchg(&rcu_thread_exit_called, 1) == 0)
+    {
+        rcu_thread_message.message = &rcu_thread_exited;
+        call_rcu(&rcu_thread_message, rcu_thread_exit, rcu);
+    }
+
+    while (atomic_mb_read(&rcu_thread_exited) == 0)
+    {
+        g_usleep(10000);
+    }
+}
+
 static int atfork_depth = 1;
 
 void rcu_enable_atfork(void)
@@ -379,3 +409,8 @@ static void __attribute__((__constructor__)) rcu_init(void)
 #endif
     rcu_init_complete();
 }
+
+static void __attribute__((__destructor__)) rcu_uninit(void)
+{
+    rcu_wait_finished();
+}
-- 
2.28.0.windows.1



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

* Re: [PULL 00/16] Msys2 patches patches
  2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
                   ` (15 preceding siblings ...)
  2020-09-08 18:49 ` [PULL 16/16] rcu: add uninit destructor for rcu Yonggang Luo
@ 2020-09-08 18:56 ` Eric Blake
  2020-09-08 19:09   ` Philippe Mathieu-Daudé
  2020-09-09  7:05   ` Thomas Huth
  16 siblings, 2 replies; 26+ messages in thread
From: Eric Blake @ 2020-09-08 18:56 UTC (permalink / raw)
  To: Yonggang Luo, qemu-devel
  Cc: Kevin Wolf, Ed Maste, qemu-block, Stefan Weil, Xie Changlong,
	Peter Lieven, Michael Roth, Markus Armbruster, Gerd Hoffmann,
	Wen Congyang, Max Reitz, Li-Wen Hsu

On 9/8/20 1:49 PM, Yonggang Luo wrote:
> The following changes since commit 6779038537360e957dbded830f76b08ef5070161:
> 
>    Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-09-08' int=
> o staging (2020-09-08 17:23:31 +0100)
> 
> are available in the Git repository at:
> 
>    http://github.com/lygstate/qemu tags/msys2-patches-pull-request
> 
> for you to fetch changes up to 1892e4360f55ac8cbeeeae0043e0a9dc05c50269:
> 
>    rcu: add uninit destructor for rcu (2020-09-09 02:34:59 +0800)
> 
> ----------------------------------------------------------------
> msys2 patch queue 2020-09-09

MAINTAINERS doesn't mention a category for msys2, and this patch series 
doesn't add one.  It is unusual to send a pull request without being a 
listed maintainer for the code in question.  I'm not objecting to you 
taking on a maintainership role, if we are ready for that, but I also 
worry that you have so few contributions currently in the main 
repository that you have not necessarily proven the quality of your 
work.  Maybe it's better to just send this as an ordinary patch series, 
and let an existing maintainer incorporate it?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



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

* Re: [PULL 01/16] block: Fixes nfs on msys2/mingw
  2020-09-08 18:49 ` [PULL 01/16] block: Fixes nfs on msys2/mingw Yonggang Luo
@ 2020-09-08 18:57   ` Eric Blake
  0 siblings, 0 replies; 26+ messages in thread
From: Eric Blake @ 2020-09-08 18:57 UTC (permalink / raw)
  To: Yonggang Luo, qemu-devel
  Cc: Kevin Wolf, Ed Maste, qemu-block, Stefan Weil, Xie Changlong,
	Peter Lieven, Michael Roth, Markus Armbruster, Gerd Hoffmann,
	Wen Congyang, Max Reitz, Li-Wen Hsu

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

The commit message is too sparse.  You say that nfs is broken, but fail 
to give any details how, or why this patch improves the situation. 
Also, the patch has no 'Reviewed-by' tag from anyone, and accepting 
unreviewed code into mainline can be risky (we tolerate it from 
well-established contributors, but you are still working toward that point).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



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

* Re: [PULL 02/16] ci: fixes msys2 build by upgrading capstone to 4.0.2
  2020-09-08 18:49 ` [PULL 02/16] ci: fixes msys2 build by upgrading capstone to 4.0.2 Yonggang Luo
@ 2020-09-08 18:59   ` Eric Blake
  2020-09-08 19:07     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 26+ messages in thread
From: Eric Blake @ 2020-09-08 18:59 UTC (permalink / raw)
  To: Yonggang Luo, qemu-devel
  Cc: Kevin Wolf, Ed Maste, qemu-block, Stefan Weil, Xie Changlong,
	Peter Lieven, Michael Roth, Markus Armbruster, Gerd Hoffmann,
	Wen Congyang, Max Reitz, Li-Wen Hsu

On 9/8/20 1:49 PM, Yonggang Luo wrote:
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>   capstone  | 2 +-
>   configure | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)

The commit message is sparse; it might be nice to give more details 
about what error is fixed, or possibly even mention of the fact of which 
capstone commit id that is in 4.0.2 but not the current version matters 
to qemu on msys.

> 
> 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 4231d56bcc..f4f8bc3756 100755
> --- a/configure
> +++ b/configure
> @@ -5156,7 +5156,7 @@ case "$capstone" in
>         LIBCAPSTONE=libcapstone.a
>       fi
>       capstone_libs="-Lcapstone -lcapstone"
> -    capstone_cflags="-I${source_path}/capstone/include"
> +    capstone_cflags="-I${source_path}/capstone/include -I${source_path}/capstone/include/capstone"

This change was not mentioned in the commit message.  Did capstone 4.0.2 
change where its include files live?  Or is it a separate bug, and you 
are fixing two things at once (in which case, doing two separate commits 
might be nicer)?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



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

* Re: [PULL 03/16] configure: Fixes ncursesw detection under msys2/mingw and enable curses
  2020-09-08 18:49 ` [PULL 03/16] configure: Fixes ncursesw detection under msys2/mingw and enable curses Yonggang Luo
@ 2020-09-08 19:02   ` Eric Blake
  0 siblings, 0 replies; 26+ messages in thread
From: Eric Blake @ 2020-09-08 19:02 UTC (permalink / raw)
  To: Yonggang Luo, qemu-devel
  Cc: Kevin Wolf, Ed Maste, qemu-block, Stefan Weil, Xie Changlong,
	Peter Lieven, Michael Roth, Markus Armbruster, Gerd Hoffmann,
	Wen Congyang, Max Reitz, Li-Wen Hsu

On 9/8/20 1:49 PM, Yonggang Luo wrote:
> The mingw pkg-config are showing following absolute path and contains : as the separator,
> so we must handling : properly.
> 
> -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC:/CI-Tools/msys64/mingw64/include/ncursesw:-I/usr/include/ncursesw:
> -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -pipe -lncursesw -lgnurx -ltre -lintl -liconv
> -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lncursesw
> -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lcursesw
> -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv
> -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lncursesw
> -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lcursesw
> -DNCURSES_WIDECHAR -I/usr/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv
> -DNCURSES_WIDECHAR -I/usr/include/ncursesw -lncursesw
> -DNCURSES_WIDECHAR -I/usr/include/ncursesw -lcursesw
> 
> MINGW doesn't have langinfo.h, only exist in glic and musl

Grammar and spelling are off; if I were keeping the sentence as-is, I 
would use:

MINGW lacks langinfo.h, which only exists in glibc and musl

But that statement is a lie, since POSIX requires <langinfo.h> and we 
build on BSD systems which use neither glibc nor musl.  So better would be:

mingw lacks the POSIX-required langinfo.h.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



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

* Re: [PULL 02/16] ci: fixes msys2 build by upgrading capstone to 4.0.2
  2020-09-08 18:59   ` Eric Blake
@ 2020-09-08 19:07     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-08 19:07 UTC (permalink / raw)
  To: Eric Blake, Yonggang Luo, qemu-devel, Richard Henderson
  Cc: Kevin Wolf, Ed Maste, qemu-block, Stefan Weil, Xie Changlong,
	Peter Lieven, Michael Roth, Markus Armbruster, Gerd Hoffmann,
	Wen Congyang, Max Reitz, Li-Wen Hsu

On 9/8/20 8:59 PM, Eric Blake wrote:
> On 9/8/20 1:49 PM, Yonggang Luo wrote:
>> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
>> ---
>>   capstone  | 2 +-
>>   configure | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> The commit message is sparse; it might be nice to give more details
> about what error is fixed, or possibly even mention of the fact of which
> capstone commit id that is in 4.0.2 but not the current version matters
> to qemu on msys.
> 
>>
>> 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 4231d56bcc..f4f8bc3756 100755
>> --- a/configure
>> +++ b/configure
>> @@ -5156,7 +5156,7 @@ case "$capstone" in
>>         LIBCAPSTONE=libcapstone.a
>>       fi
>>       capstone_libs="-Lcapstone -lcapstone"
>> -    capstone_cflags="-I${source_path}/capstone/include"
>> +    capstone_cflags="-I${source_path}/capstone/include
>> -I${source_path}/capstone/include/capstone"
> 
> This change was not mentioned in the commit message.  Did capstone 4.0.2
> change where its include files live?  Or is it a separate bug, and you
> are fixing two things at once (in which case, doing two separate commits
> might be nicer)?

As Richard Henderson introduced the capstone submodule, it would be
nice to have his Ack-by before updating it.

Thanks,

Phil.


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

* Re: [PULL 00/16] Msys2 patches patches
  2020-09-08 18:56 ` [PULL 00/16] Msys2 patches patches Eric Blake
@ 2020-09-08 19:09   ` Philippe Mathieu-Daudé
  2020-09-09  7:05   ` Thomas Huth
  1 sibling, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-08 19:09 UTC (permalink / raw)
  To: Eric Blake, Yonggang Luo, qemu-devel
  Cc: Kevin Wolf, Ed Maste, qemu-block, Stefan Weil, Xie Changlong,
	Peter Lieven, Michael Roth, Markus Armbruster, Gerd Hoffmann,
	Wen Congyang, Max Reitz, Li-Wen Hsu

On 9/8/20 8:56 PM, Eric Blake wrote:
> On 9/8/20 1:49 PM, Yonggang Luo wrote:
>> The following changes since commit
>> 6779038537360e957dbded830f76b08ef5070161:
>>
>>    Merge remote-tracking branch
>> 'remotes/armbru/tags/pull-qapi-2020-09-08' int=
>> o staging (2020-09-08 17:23:31 +0100)
>>
>> are available in the Git repository at:
>>
>>    http://github.com/lygstate/qemu tags/msys2-patches-pull-request
>>
>> for you to fetch changes up to 1892e4360f55ac8cbeeeae0043e0a9dc05c50269:
>>
>>    rcu: add uninit destructor for rcu (2020-09-09 02:34:59 +0800)
>>
>> ----------------------------------------------------------------
>> msys2 patch queue 2020-09-09
> 
> MAINTAINERS doesn't mention a category for msys2, and this patch series
> doesn't add one.  It is unusual to send a pull request without being a
> listed maintainer for the code in question.  I'm not objecting to you
> taking on a maintainership role, if we are ready for that, but I also
> worry that you have so few contributions currently in the main
> repository that you have not necessarily proven the quality of your
> work.  Maybe it's better to just send this as an ordinary patch series,
> and let an existing maintainer incorporate it?

Beside what Eric said, you sent all your patches altogether, this is
already an improvement for reviewers, thanks!


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

* Re: [PULL 04/16] curses: Fixes curses compiling errors.
  2020-09-08 18:49 ` [PULL 04/16] curses: Fixes curses compiling errors Yonggang Luo
@ 2020-09-08 20:28   ` Peter Maydell
  2020-09-08 21:04     ` 罗勇刚(Yonggang Luo)
  0 siblings, 1 reply; 26+ messages in thread
From: Peter Maydell @ 2020-09-08 20:28 UTC (permalink / raw)
  To: Yonggang Luo
  Cc: Kevin Wolf, Ed Maste, Qemu-block, Stefan Weil, Xie Changlong,
	Peter Lieven, QEMU Developers, Michael Roth, Gerd Hoffmann,
	Wen Congyang, Max Reitz, Li-Wen Hsu, Markus Armbruster

On Tue, 8 Sep 2020 at 19:56, Yonggang Luo <luoyonggang@gmail.com> wrote:
>
> This is the compiling error:
> ../ui/curses.c: In function 'curses_refresh':
> ../ui/curses.c:256:5: error: 'next_maybe_keycode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   256 |     curses2foo(_curses2keycode, _curseskey2keycode, chr, maybe_keycode)
>       |     ^~~~~~~~~~
> ../ui/curses.c:302:32: note: 'next_maybe_keycode' was declared here
>   302 |             enum maybe_keycode next_maybe_keycode;
>       |                                ^~~~~~~~~~~~~~~~~~
> ../ui/curses.c:256:5: error: 'maybe_keycode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   256 |     curses2foo(_curses2keycode, _curseskey2keycode, chr, maybe_keycode)
>       |     ^~~~~~~~~~
> ../ui/curses.c:265:24: note: 'maybe_keycode' was declared here
>   265 |     enum maybe_keycode maybe_keycode;
>       |                        ^~~~~~~~~~~~~
> cc1.exe: all warnings being treated as errors

> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  ui/curses.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ui/curses.c b/ui/curses.c
> index 12bc682cf9..e4f9588c3e 100644
> --- a/ui/curses.c
> +++ b/ui/curses.c
> @@ -262,7 +262,7 @@ static int curses2foo(const int _curses2foo[], const int _curseskey2foo[],
>  static void curses_refresh(DisplayChangeListener *dcl)
>  {
>      int chr, keysym, keycode, keycode_alt;
> -    enum maybe_keycode maybe_keycode;
> +    enum maybe_keycode maybe_keycode = CURSES_KEYCODE;
>
>      curses_winch_check();
>
> @@ -299,7 +299,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
>
>          /* alt or esc key */
>          if (keycode == 1) {
> -            enum maybe_keycode next_maybe_keycode;
> +            enum maybe_keycode next_maybe_keycode = CURSES_KEYCODE;
>              int nextchr = console_getch(&next_maybe_keycode);
>
>              if (nextchr != -1) {

The problem here is that the compiler hasn't noticed that it's
impossible to return something other than -1 from console_getch()
without initializing next_maybe_keycode.

There are two possible reasons for this:
(1) your gcc is a bit old -- newer gcc are better at working
out this kind of thing. But you said on irc that you're using
gcc 10.2.0, which is new...

(2) this is a variant of the problem with the system headers
that causes us to have to redefine assert() in osdep.h, only
with abort() (ie abort() is perhaps not marked as noreturn in
the system headers). If this theory is true, then changing
the abort() in console_getch() to instead be g_assert_not_reached()
would be a different way to avoid the warnings (and if that works
we should probably fix up abort() the way we do assert()).

thanks
-- PMM


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

* Re: [PULL 04/16] curses: Fixes curses compiling errors.
  2020-09-08 20:28   ` Peter Maydell
@ 2020-09-08 21:04     ` 罗勇刚(Yonggang Luo)
  0 siblings, 0 replies; 26+ messages in thread
From: 罗勇刚(Yonggang Luo) @ 2020-09-08 21:04 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Kevin Wolf, Ed Maste, Qemu-block, Stefan Weil, Xie Changlong,
	Peter Lieven, QEMU Developers, Michael Roth, Gerd Hoffmann,
	Wen Congyang, Max Reitz, Li-Wen Hsu, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 3477 bytes --]

On Wed, Sep 9, 2020 at 4:29 AM Peter Maydell <peter.maydell@linaro.org>
wrote:

> On Tue, 8 Sep 2020 at 19:56, Yonggang Luo <luoyonggang@gmail.com> wrote:
> >
> > This is the compiling error:
> > ../ui/curses.c: In function 'curses_refresh':
> > ../ui/curses.c:256:5: error: 'next_maybe_keycode' may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
> >   256 |     curses2foo(_curses2keycode, _curseskey2keycode, chr,
> maybe_keycode)
> >       |     ^~~~~~~~~~
> > ../ui/curses.c:302:32: note: 'next_maybe_keycode' was declared here
> >   302 |             enum maybe_keycode next_maybe_keycode;
> >       |                                ^~~~~~~~~~~~~~~~~~
> > ../ui/curses.c:256:5: error: 'maybe_keycode' may be used uninitialized
> in this function [-Werror=maybe-uninitialized]
> >   256 |     curses2foo(_curses2keycode, _curseskey2keycode, chr,
> maybe_keycode)
> >       |     ^~~~~~~~~~
> > ../ui/curses.c:265:24: note: 'maybe_keycode' was declared here
> >   265 |     enum maybe_keycode maybe_keycode;
> >       |                        ^~~~~~~~~~~~~
> > cc1.exe: all warnings being treated as errors
>
> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> > ---
> >  ui/curses.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/ui/curses.c b/ui/curses.c
> > index 12bc682cf9..e4f9588c3e 100644
> > --- a/ui/curses.c
> > +++ b/ui/curses.c
> > @@ -262,7 +262,7 @@ static int curses2foo(const int _curses2foo[], const
> int _curseskey2foo[],
> >  static void curses_refresh(DisplayChangeListener *dcl)
> >  {
> >      int chr, keysym, keycode, keycode_alt;
> > -    enum maybe_keycode maybe_keycode;
> > +    enum maybe_keycode maybe_keycode = CURSES_KEYCODE;
> >
> >      curses_winch_check();
> >
> > @@ -299,7 +299,7 @@ static void curses_refresh(DisplayChangeListener
> *dcl)
> >
> >          /* alt or esc key */
> >          if (keycode == 1) {
> > -            enum maybe_keycode next_maybe_keycode;
> > +            enum maybe_keycode next_maybe_keycode = CURSES_KEYCODE;
> >              int nextchr = console_getch(&next_maybe_keycode);
> >
> >              if (nextchr != -1) {
>
> The problem here is that the compiler hasn't noticed that it's
> impossible to return something other than -1 from console_getch()
> without initializing next_maybe_keycode.
>
> There are two possible reasons for this:
> (1) your gcc is a bit old -- newer gcc are better at working
> out this kind of thing. But you said on irc that you're using
> gcc 10.2.0, which is new...
>
> (2) this is a variant of the problem with the system headers
> that causes us to have to redefine assert() in osdep.h, only
> with abort() (ie abort() is perhaps not marked as noreturn in
> the system headers). If this theory is true, then changing
> the abort() in console_getch() to instead be g_assert_not_reached()
> would be a different way to avoid the warnings (and if that works
> we should probably fix up abort() the way we do assert()).
>
Tried   g_assert_not_reached still not fixes the issue, and I verified
on debug build, either g_assert_not_reached or abort, the compiling error
doesn't appear,
the debug build are the build that configured with --enable-debug-info
--enable-debug

this compiling error only appear in release build.

>
> thanks
> -- PMM
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

[-- Attachment #2: Type: text/html, Size: 4620 bytes --]

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

* Re: [PULL 00/16] Msys2 patches patches
  2020-09-08 18:56 ` [PULL 00/16] Msys2 patches patches Eric Blake
  2020-09-08 19:09   ` Philippe Mathieu-Daudé
@ 2020-09-09  7:05   ` Thomas Huth
  1 sibling, 0 replies; 26+ messages in thread
From: Thomas Huth @ 2020-09-09  7:05 UTC (permalink / raw)
  To: Eric Blake, Yonggang Luo, qemu-devel, Stefan Weil
  Cc: Kevin Wolf, Ed Maste, qemu-block, Wen Congyang, Xie Changlong,
	Peter Lieven, Michael Roth, Markus Armbruster, Gerd Hoffmann,
	Max Reitz, Li-Wen Hsu

On 08/09/2020 20.56, Eric Blake wrote:
> On 9/8/20 1:49 PM, Yonggang Luo wrote:
>> The following changes since commit
>> 6779038537360e957dbded830f76b08ef5070161:
>>
>>    Merge remote-tracking branch
>> 'remotes/armbru/tags/pull-qapi-2020-09-08' int=
>> o staging (2020-09-08 17:23:31 +0100)
>>
>> are available in the Git repository at:
>>
>>    http://github.com/lygstate/qemu tags/msys2-patches-pull-request
>>
>> for you to fetch changes up to 1892e4360f55ac8cbeeeae0043e0a9dc05c50269:
>>
>>    rcu: add uninit destructor for rcu (2020-09-09 02:34:59 +0800)
>>
>> ----------------------------------------------------------------
>> msys2 patch queue 2020-09-09
> 
> MAINTAINERS doesn't mention a category for msys2, and this patch series
> doesn't add one.  It is unusual to send a pull request without being a
> listed maintainer for the code in question.  I'm not objecting to you
> taking on a maintainership role, if we are ready for that, but I also
> worry that you have so few contributions currently in the main
> repository that you have not necessarily proven the quality of your
> work.  Maybe it's better to just send this as an ordinary patch series,
> and let an existing maintainer incorporate it?

We already have a maintainer for Windows-related patches (see W32, W64
section in maintainers), so I was hoping that Stefan Weil could pick up
the msys2 related patches, too. Stefan?

 Thomas




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

end of thread, other threads:[~2020-09-09  7:06 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 18:49 [PULL 00/16] Msys2 patches patches Yonggang Luo
2020-09-08 18:49 ` [PULL 01/16] block: Fixes nfs on msys2/mingw Yonggang Luo
2020-09-08 18:57   ` Eric Blake
2020-09-08 18:49 ` [PULL 02/16] ci: fixes msys2 build by upgrading capstone to 4.0.2 Yonggang Luo
2020-09-08 18:59   ` Eric Blake
2020-09-08 19:07     ` Philippe Mathieu-Daudé
2020-09-08 18:49 ` [PULL 03/16] configure: Fixes ncursesw detection under msys2/mingw and enable curses Yonggang Luo
2020-09-08 19:02   ` Eric Blake
2020-09-08 18:49 ` [PULL 04/16] curses: Fixes curses compiling errors Yonggang Luo
2020-09-08 20:28   ` Peter Maydell
2020-09-08 21:04     ` 罗勇刚(Yonggang Luo)
2020-09-08 18:49 ` [PULL 05/16] tests: disable /char/stdio/* tests in test-char.c on win32 Yonggang Luo
2020-09-08 18:49 ` [PULL 06/16] ci: Enable msys2 ci in cirrus Yonggang Luo
2020-09-08 18:49 ` [PULL 07/16] tests: Trying fixes test-replication.c on msys2/mingw Yonggang Luo
2020-09-08 18:49 ` [PULL 08/16] block: get file-win32.c handle locking option consistence with file-posix.c Yonggang Luo
2020-09-08 18:49 ` [PULL 09/16] osdep: These function are only available on Non-Win32 system Yonggang Luo
2020-09-08 18:49 ` [PULL 10/16] meson: Use -b to ignore CR vs. CR-LF issues on Windows Yonggang Luo
2020-09-08 18:49 ` [PULL 11/16] meson: disable crypto tests are empty under win32 Yonggang Luo
2020-09-08 18:49 ` [PULL 12/16] meson: remove empty else and duplicated gio deps Yonggang Luo
2020-09-08 18:49 ` [PULL 13/16] vmstate: Fixes test-vmstate.c on msys2/mingw Yonggang Luo
2020-09-08 18:49 ` [PULL 14/16] cirrus: Building freebsd in a single short Yonggang Luo
2020-09-08 18:49 ` [PULL 15/16] logging: Fixes memory leak in test-logging.c Yonggang Luo
2020-09-08 18:49 ` [PULL 16/16] rcu: add uninit destructor for rcu Yonggang Luo
2020-09-08 18:56 ` [PULL 00/16] Msys2 patches patches Eric Blake
2020-09-08 19:09   ` Philippe Mathieu-Daudé
2020-09-09  7:05   ` Thomas Huth

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).