W32, W64 msys2/mingw patches
Subsystems (2)
v9 cover W32, W64 msys2/mingw patches
V8-V9
* ci: Enable msys2 ci in cirrus
do not install libnfs, libcapstone and jemalloc ident lines properly
Do not install libnfs when the add the msys2 ci,
* Revert "configure: add --ninja option"
Skip this revision
* block: Fixes nfs compiling error on msys2/mingw
Use typedef long long blkcnt_t; for libnfs on msys2/mingw
for futher implemenation, still disable nfs_get_allocated_file_size on win32 as it not working yet, but preserve the possibility implemenation it in futher
* gcrypt: test_tls_psk_init should write binary file instead text file. only fixes the file open mode parameter
* osdep: file locking functions are not available on Win32:
Reword with "Do not declare the following locking functions on Win32:"
* meson: Use -b to ignore CR vs. CR-LF issues on Windows Reword of commit message
* tests: Enable crypto tests under msys2/mingw
Reimplement qemu_socketpair in a simpler way. without thirdparty code
* block: enable libnfs on msys2/mingw in cirrus.yml New commit
* tests: disable /char/stdio/* tests in test-char.c on win32 Needs review
* tests: fixes aio-win32 about aio_remove_fd_handler, get it consistence with= aio-posix.c
Needs review
* rcu: fixes test-logging.c by call drain_call_rcu before rmdir_full Needs review
It first introduce msys2 CI on cirrus by fixes nfs, capstone, curses and disable partial test-char tests.
And then fixes all unit tests failure on msys2/mingw
This fixes the reviews suggested in the mailling list
All cirrus CI are passed
Maxim Levitsky (1):
rcu: Implement drain_call_rcu
Yonggang Luo (25):
ci: fixes msys2 build by upgrading capstone to 4.0.2
configure: Fixes ncursesw detection under msys2/mingw and enable
curses
win32: Simplify gmtime_r detection direct base on
_POSIX_THREAD_SAFE_FUNCTIONS.
curses: Fixes curses compiling errors.
tests: disable /char/stdio/* tests in test-char.c on win32
tests: Fixes test-replication.c on msys2/mingw.
tests: test-replication disable /replication/secondary/* on
msys2/mingw.
osdep: file locking functions are not available on Win32
meson: Use -b to ignore CR vs. CR-LF issues on Windows
gcrypt: test_tls_psk_init should write binary file instead text file.
tests: Enable crypto tests under msys2/mingw
meson: remove empty else and duplicated gio deps
vmstate: Fixes test-vmstate.c on msys2/mingw
cirrus: Building freebsd in a single short
tests: Convert g_free to g_autofree macro in test-logging.c
tests: Fixes test-io-channel-socket.c tests under msys2/mingw
tests: fixes aio-win32 about aio_remove_fd_handler, get it consistence
with aio-posix.c
tests: Fixes test-io-channel-file by mask only owner file state mask
bits
tests: fix test-util-sockets.c
tests: Fixes test-qdev-global-props.c
rcu: fixes test-logging.c by call drain_call_rcu before rmdir_full
meson: upgrade meson for execute custom ninjatool under msys2 properly
ci: Enable msys2 ci in cirrus
block: Fixes nfs compiling error on msys2/mingw
block: enable libnfs on msys2/mingw in cirrus.yml
.cirrus.yml | 97 ++++++++++++++++++++-------- block/nfs.c | 37 +++++++++-- capstone | 2 +- configure | 61 +++++------------- include/qemu/osdep.h | 2 +- include/qemu/rcu.h | 1 + include/sysemu/os-win32.h | 4 +- meson | 2 +- meson.build | 6 -- tests/crypto-tls-psk-helpers.c | 6 +- tests/crypto-tls-x509-helpers.c | 106 ++++++++++++++++++++++++++++++- tests/crypto-tls-x509-helpers.h | 9 ++- tests/qapi-schema/meson.build | 2 +- tests/test-char.c | 26 +++++--- tests/test-crypto-tlscredsx509.c | 47 +++++++------- tests/test-crypto-tlssession.c | 68 +++++++++++--------- tests/test-io-channel-file.c | 10 ++- tests/test-io-channel-socket.c | 2 + tests/test-io-channel-tls.c | 51 ++++++++------- tests/test-logging.c | 5 +- tests/test-qdev-global-props.c | 6 +- tests/test-replication.c | 22 +++++-- tests/test-util-sockets.c | 6 +- tests/test-vmstate.c | 3 +- ui/curses.c | 14 ++-- util/aio-win32.c | 11 +++- util/oslib-win32.c | 2 +- util/rcu.c | 55 ++++++++++++++++ 28 files changed, 460 insertions(+), 203 deletions(-)
--=20
2.28.0.windows.1
PATCH v9 1/26 rcu: Implement drain_call_rcu
From: Maxim Levitsky <[email protected]>
This will allow is to preserve the semantics of hmp_device_del, that the device is deleted immediatly which was changed by previos patch that delayed this to RCU callback
--- include/qemu/rcu.h | 1 + util/rcu.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+)
include/qemu/rcu.h +1 -0
@@ -133,6 +133,7 @@ struct rcu_head { };extern void call_rcu1 (struct rcu_head *head,RCUCBFunc *func); +extern void drain_call_rcu (void );/* The operands of the minus operator must have the same type, * which must be the one that we specify in the cast.
util/rcu.c +55 -0
61 lines not on this page · raw message
Signature · 1 line
2.28.0.windows.1
PATCH v9 2/26 ci: fixes msys2 build by upgrading capstone to 4.0.2
In reply to Yonggang LuoThe currently random version capstone have the following compiling issue:
CC /c/work/xemu/qemu/build/slirp/src/arp_table.o
make[1]: *** No rule to make target “/c/work/xemu/qemu/build/capstone/capstone.lib”。 Stop.
Subproject commit 1d230532840a37ac032c6ab80128238fc930c6c1 are the tagged version 4.0.2 when upgrading to this version, the folder structure of include are changed to qemu\capstone\include
│ platform.h │ ├─capstone │ arm.h │ arm64.h │ capstone.h │ evm.h │ m680x.h │ m68k.h │ mips.h │ platform.h │ ppc.h │ sparc.h │ systemz.h │ tms320c64x.h │ x86.h │ xcore.h │ └─windowsce
intrin.h
stdint.h
in capstone. so we need add extra include path -I${source_path}/capstone/include/capstone for directly #include <capstone.h>, and the exist include path should preserve, because in capstone code there something like #include "capstone/capstone.h"
If only using
capstone_cflags="-I${source_path}/capstone/include/capstone"Then will cause the following compiling error:
CC cs.o
cs.c:17:10: fatal error: 'capstone/capstone.h' file not found
#include <capstone/capstone.h>
^~~~~~~~~~~~~~~~~~~~~1 error generated.
--- capstone | 2 +- configure | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
capstone +1 -1
@@ -1 +1 @@ -Subproject commit 22ead3e0bfdb87516656453336160e0a37b066bf +Subproject commit 1d230532840a37ac032c6ab80128238fc930c6c1
configure +1 -1
@@ -5157,7 +5157,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)
Signature · 1 line
2.28.0.windows.1
PATCH v9 3/26 configure: Fixes ncursesw detection under msys2/mingw and enable curses
In reply to Yonggang LuoThe mingw pkg-config are showing following absolute path and contains : as the separator, so we must not use : as path separator. and we know the command line parameter are not likely contains newline, we could use newline as path command line parameter separator
-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
Refer to https://unix.stackexchange.com/a/103011/218958
If your file names are guaranteed not to contain newlines, you can use newlines as the separator. W hen you expand the variable, first turn off globbing with set -f and set the list of field splitting characters IFS to contain only a newline.
msys2/mingw lacks the POSIX-required langinfo.h.
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.
So we using g_get_codeset instead of nl_langinfo(CODESET)
--- configure | 25 +++++++++++++++---------- ui/curses.c | 10 +++++----- 2 files changed, 20 insertions(+), 15 deletions(-)
configure +15 -10
@@ -3654,35 +3654,40 @@ 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 ncurses 2>/dev/null) + $($pkg_config --cflags ncursesw 2>/dev/null)" + curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null) + $($pkg_config --libs ncursesw 2>/dev/null) + -lpdcurses" 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" + 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" fi curses_found=no cat > $TMPC << EOF #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=: + IFS=' +' # turn off variable value expansion except for splitting at newlines for curses_inc in $curses_inc_list; do # Make sure we get the wide character prototypes curses_inc="-DNCURSES_WIDECHAR $curses_inc" - IFS=: + IFS=' +' # turn off variable value expansion except for splitting at newlines for curses_lib in $curses_lib_list; do unset IFS if compile_prog "$curses_inc" "$curses_lib" ; then
ui/curses.c +5 -5
@@ -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 ];
Signature · 1 line
2.28.0.windows.1
PATCH v9 4/26 win32: Simplify gmtime_r detection direct base on _POSIX_THREAD_SAFE_FUNCTIONS.
In reply to Yonggang LuoFirst, this reduce the size of configure, configure are tending to removal in future, and this didn't introduce any new feature or remove any exist feature. Second, the current localtime_r detection are conflict with ncursesw detection in mingw, when ncursesw detected, it will provide the following compile flags pkg-config --cflags ncursesw
-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC:/CI-Tools/msys64/mingw64/include/ncursesw And the compile flag _POSIX_C_SOURCE will always cause _POSIX_THREAD_SAFE_FUNCTIONS to be defined, in new version of mingw, that's will cause localtime_r to be defined. But the configure script didn't provide _POSIX_C_SOURCE macro, and that's will result localtime_r not detected because localtime_r are defined in forceinline manner.
And finally cause conflict between QEMU defined localtime_r struct tm *localtime_r(const time_t *timep, struct tm *result); with mingw defined localtime_r
```
#if defined(_POSIX_C_SOURCE) && !defined(_POSIX_THREAD_SAFE_FUNCTIONS)
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
#endif
#ifdef _POSIX_THREAD_SAFE_FUNCTIONS
__forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
return localtime_s(_Tm, _Time) ? NULL : _Tm;
}
__forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
return gmtime_s(_Tm, _Time) ? NULL : _Tm;
}
__forceinline char *__CRTDECL ctime_r(const time_t *_Time, char *_Str) {
return ctime_s(_Str, 0x7fffffff, _Time) ? NULL : _Str;
}
__forceinline char *__CRTDECL asctime_r(const struct tm *_Tm, char * _Str) {
return asctime_s(_Str, 0x7fffffff, _Tm) ? NULL : _Str;
}
#endif
```So I suggest remove this configure script, and restrict msys2/mingw version to easy to maintain. And use _POSIX_THREAD_SAFE_FUNCTIONS to guard the localtime_r and counterpart functions
--- configure | 34 ---------------------------------- include/sysemu/os-win32.h | 4 ++-- util/oslib-win32.c | 2 +- 3 files changed, 3 insertions(+), 37 deletions(-)
configure +0 -34
@@ -2496,37 +2496,6 @@ if test "$vhost_net" = ""; then test "$vhost_kernel" = "yes" && vhost_net=yes fi -########################################## -# MinGW / Mingw-w64 localtime_r/gmtime_r check - -if test "$mingw32" = "yes"; then - # Some versions of MinGW / Mingw-w64 lack localtime_r - # and gmtime_r entirely. - # - # Some versions of Mingw-w64 define a macro for - # localtime_r/gmtime_r. - # - # Some versions of Mingw-w64 will define functions - # for localtime_r/gmtime_r, but only if you have - # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun - # though, unistd.h and pthread.h both define - # that for you. - # - # So this #undef localtime_r and #include <unistd.h> - # are not in fact redundant. -cat > $TMPC << EOF -#include <unistd.h> -#include <time.h> -#undef localtime_r -int main(void) { localtime_r(NULL, NULL); return 0; } -EOF - if compile_prog "" "" ; then - localtime_r="yes" - else - localtime_r="no" - fi -fi - ########################################## # pkg-config probe
@@ -7088,9 +7057,6 @@ if [ "$bsd" = "yes" ] ; then echo "CONFIG_BSD=y" >> $config_host_mak fi -if test "$localtime_r" = "yes" ; then - echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak -fi if test "$qom_cast_debug" = "yes" ; then echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak fi
include/sysemu/os-win32.h +2 -2
@@ -48,12 +48,12 @@#define siglongjmp (env, val) longjmp(env, val)/* Missing POSIX functions. Don't use MinGW-w64 macros. */ -#ifndef CONFIG_LOCALTIME_R +#ifndef _POSIX_THREAD_SAFE_FUNCTIONS#undef gmtime_rstruct tm *gmtime_r (const time_t *timep,struct tm *result);#undef localtime_rstruct tm *localtime_r (const time_t *timep,struct tm *result); -#endif /* CONFIG_LOCALTIME_R */ +#endif static inline void os_setup_signal_handling (void ) {}static inline void os_daemonize (void ) {}
util/oslib-win32.c +1 -1
@@ -106,7 +106,7 @@ void qemu_anon_ram_free(void *ptr, size_t size) } } -#ifndef CONFIG_LOCALTIME_R +#ifndef _POSIX_THREAD_SAFE_FUNCTIONS/* FIXME: add proper locking */ struct tm *gmtime_r (const time_t *timep,struct tm *result) {
Signature · 1 line
2.28.0.windows.1
Re: [PATCH v9 04/26] win32: Simplify gmtime_r detection direct base on _POSIX_THREAD_SAFE_FUNCTIONS.
Quoted 10 lines · Yonggang Luo
First, this reduce the size of configure, configure are tending to removal in future, and this didn't introduce any new feature or remove any exist feature. Second, the current
localtime_rdetection are conflict with ncursesw detection in mingw, when ncursesw detected, it will provide the following compile flags pkg-config --cflags ncursesw
-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC:/CI-Tools/msys64/mingw64/include/ncursesw And the compile flag_POSIX_C_SOURCEwill always cause_POSIX_THREAD_SAFE_FUNCTIONSto be defined, in new version of mingw, that's will causelocaltime_rto be defined. But the configure script didn't provide_POSIX_C_SOURCEmacro, and that's will resultlocaltime_rnot detected becauselocaltime_rare defined in forceinline manner.
ncursesw is just one of the three curses impls we can select for building against, so it doesn't feel right to make an assumption that _POSIX_C_SOURCE is always defined.
Quoted 124 lines
And finally cause conflict between QEMU defined
localtime_rstruct tm *localtime_r(consttime_t*timep, struct tm *result); with mingw definedlocaltime_r``` #if defined(_POSIX_C_SOURCE) && !defined(_POSIX_THREAD_SAFE_FUNCTIONS) #define _POSIX_THREAD_SAFE_FUNCTIONS 200112L #endif #ifdef _POSIX_THREAD_SAFE_FUNCTIONS __forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) { return localtime_s(_Tm, _Time) ? NULL : _Tm; } __forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) { return gmtime_s(_Tm, _Time) ? NULL : _Tm; } __forceinline char *__CRTDECL ctime_r(const time_t *_Time, char *_Str) { return ctime_s(_Str, 0x7fffffff, _Time) ? NULL : _Str; } __forceinline char *__CRTDECL asctime_r(const struct tm *_Tm, char * _Str) { return asctime_s(_Str, 0x7fffffff, _Tm) ? NULL : _Str; } #endif ```So I suggest remove this configure script, and restrict msys2/mingw version to easy to maintain. And use
_POSIX_THREAD_SAFE_FUNCTIONSto guard thelocaltime_rand counterpart functionsSigned-off-by Yonggang Luo <[email protected]>--- configure | 34 ---------------------------------- include/sysemu/os-win32.h | 4 ++-- util/oslib-win32.c | 2 +- 3 files changed, 3 insertions(+), 37 deletions(-)configure +0
-34@@ -2496,37 +2496,6 @@ if test "$vhost_net" = ""; then test "$vhost_kernel" = "yes" && vhost_net=yes fi -########################################## -# MinGW / Mingw-w64 localtime_r/gmtime_r check - -if test "$mingw32" = "yes"; then - # Some versions of MinGW / Mingw-w64 lack localtime_r - # and gmtime_r entirely. - # - # Some versions of Mingw-w64 define a macro for - # localtime_r/gmtime_r. - # - # Some versions of Mingw-w64 will define functions - # for localtime_r/gmtime_r, but only if you have - # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun - # though, unistd.h and pthread.h both define - # that for you. - # - # So this #undef localtime_r and #include <unistd.h> - # are not in fact redundant. -cat > $TMPC << EOF -#include <unistd.h> -#include <time.h> -#undef localtime_r -int main(void) { localtime_r(NULL, NULL); return 0; } -EOF - if compile_prog "" "" ; then - localtime_r="yes" - else - localtime_r="no" - fi -fi - ########################################## # pkg-config probe@@ -7088,9 +7057,6 @@ if [ "$bsd" = "yes" ] ; then echo "CONFIG_BSD=y" >> $config_host_mak fi -if test "$localtime_r" = "yes" ; then - echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak -fi if test "$qom_cast_debug" = "yes" ; then echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak fiinclude/sysemu/os-win32.h +2
-2@@ -48,12 +48,12 @@#define siglongjmp (env, val) longjmp(env, val)/* Missing POSIX functions. Don't use MinGW-w64 macros. */ -#ifndef CONFIG_LOCALTIME_R +#ifndef _POSIX_THREAD_SAFE_FUNCTIONS#undef gmtime_rstruct tm *gmtime_r (const time_t *timep,struct tm *result);#undef localtime_rstruct tm *localtime_r (const time_t *timep,struct tm *result); -#endif /* CONFIG_LOCALTIME_R */ +#endif static inline void os_setup_signal_handling (void ) {}static inline void os_daemonize (void ) {}util/oslib-win32.c +1
-1@@ -106,7 +106,7 @@ void qemu_anon_ram_free(void *ptr, size_t size) } } -#ifndef CONFIG_LOCALTIME_R +#ifndef _POSIX_THREAD_SAFE_FUNCTIONS/* FIXME: add proper locking */ struct tm *gmtime_r (const time_t *timep,struct tm *result) {Signature · 1 line
2.28.0.windows.1
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v9 04/26] win32: Simplify gmtime_r detection direct base on _POSIX_THREAD_SAFE_FUNCTIONS.
Quoted 3 lines · Daniel P. Berrangé
Quoted 1 line · Yonggang Luo
First, this reduce the size of configure, configure are tending to
removal in future,
Quoted 2 lines
Quoted 2 lines
and this didn't introduce any new feature or remove any exist feature. Second, the current
localtime_rdetection are conflict with ncursesw
detection in
Quoted 1 line
Quoted 1 line
mingw, when ncursesw detected, it will provide the following compile
flags
Quoted 2 lines
Quoted 2 lines
pkg-config --cflags ncursesw
-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L
-IC:/CI-Tools/msys64/mingw64/include/ncursesw
Quoted 1 line
Quoted 1 line
And the compile flag
_POSIX_C_SOURCEwill always cause
_POSIX_THREAD_SAFE_FUNCTIONS to
Quoted 1 line
Quoted 1 line
be defined, in new version of mingw, that's will cause
localtime_rto
be defined.
Quoted 1 line
Quoted 1 line
But the configure script didn't provide
_POSIX_C_SOURCEmacro, and
that's will result
Quoted 1 line
Quoted 1 line
localtime_rnot detected becauselocaltime_rare defined in forceinline
manner.
Quoted 4 lines
ncursesw is just one of the three curses impls we can select for building against, so it doesn't feel right to make an assumption that
_POSIX_C_SOURCEis always defined.
That's what I am trying to do, not depends on if _POSIX_C_SOURCE are defined.
After this patch, whenever ncursesw or other curses lib trying define or
not define _POSIX_C_SOURCE, the source will building properly Because now, we don't make any assumption about _POSIX_C_SOURCE, but before this patch,
The configure always assume msys2/mingw not define _POSIX_C_SOURCE at all.
Now this restriction are removed, only depends on mingw related _POSIX_THREAD_SAFE_FUNCTIONS
Quoted 6 lines
Quoted 6 lines
And finally cause conflict between QEMU defined
localtime_rstruct tm *localtime_r(consttime_t*timep, struct tm *result); with mingw definedlocaltime_r
Quoted 7 lines
Quoted 7 lines
```
#ifdefined(_POSIX_C_SOURCE)&& !defined(_POSIX_THREAD_SAFE_FUNCTIONS) #define_POSIX_THREAD_SAFE_FUNCTIONS200112L
#endif#ifdef
_POSIX_THREAD_SAFE_FUNCTIONS__forceinlinestruct tm*__CRTDECLlocaltime_r(consttime_t*_Time,
struct tm *_Tm) {
Quoted 3 lines
Quoted 3 lines
return
localtime_s(_Tm, _Time)? NULL :_Tm;
}__forceinlinestruct tm*__CRTDECLgmtime_r(consttime_t*_Time, struct
tm *_Tm) {
Quoted 6 lines
Quoted 6 lines
return
gmtime_s(_Tm, _Time)? NULL :_Tm;
}__forceinlinechar*__CRTDECLctime_r(const time_t *_Time, char *_Str){
returnctime_s(_Str, 0x7fffffff, _Time)? NULL :_Str;
}__forceinlinechar*__CRTDECLasctime_r(const struct tm*_Tm, char *
_Str) {
Quoted 6 lines
Quoted 6 lines
return
asctime_s(_Str, 0x7fffffff, _Tm)? NULL :_Str;
}
#endif
```So I suggest remove this configure script, and restrict msys2/mingw
version to easy to maintain.
Quoted 1 line
Quoted 1 line
And use
_POSIX_THREAD_SAFE_FUNCTIONSto guard thelocaltime_rand
counterpart functions
Quoted 87 lines
Quoted 87 lines
Signed-off-by Yonggang Luo <[email protected]>--- configure | 34 ---------------------------------- include/sysemu/os-win32.h | 4 ++-- util/oslib-win32.c | 2 +- 3 files changed, 3 insertions(+), 37 deletions(-)configure +0
-34@@ -2496,37 +2496,6 @@ if test "$vhost_net" = ""; then test "$vhost_kernel" = "yes" && vhost_net=yes fi -########################################## -# MinGW / Mingw-w64 localtime_r/gmtime_r check - -if test "$mingw32" = "yes"; then - # Some versions of MinGW / Mingw-w64 lack localtime_r - # and gmtime_r entirely. - # - # Some versions of Mingw-w64 define a macro for - # localtime_r/gmtime_r. - # - # Some versions of Mingw-w64 will define functions - # for localtime_r/gmtime_r, but only if you have - # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun - # though, unistd.h and pthread.h both define - # that for you. - # - # So this #undef localtime_r and #include <unistd.h> - # are not in fact redundant. -cat > $TMPC << EOF -#include <unistd.h> -#include <time.h> -#undef localtime_r -int main(void) { localtime_r(NULL, NULL); return 0; } -EOF - if compile_prog "" "" ; then - localtime_r="yes" - else - localtime_r="no" - fi -fi - ########################################## # pkg-config probe@@ -7088,9 +7057,6 @@ if [ "$bsd" = "yes" ] ; then echo "CONFIG_BSD=y" >> $config_host_mak fi -if test "$localtime_r" = "yes" ; then - echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak -fi if test "$qom_cast_debug" = "yes" ; then echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak fiinclude/sysemu/os-win32.h +2
-2@@ -48,12 +48,12 @@#define siglongjmp (env, val) longjmp(env, val)/* Missing POSIX functions. Don't use MinGW-w64 macros. */ -#ifndef CONFIG_LOCALTIME_R +#ifndef _POSIX_THREAD_SAFE_FUNCTIONS#undef gmtime_rstruct tm *gmtime_r (const time_t *timep,struct tm *result);#undef localtime_rstruct tm *localtime_r (const time_t *timep,struct tm *result); -#endif /* CONFIG_LOCALTIME_R */ +#endif static inline void os_setup_signal_handling (void ) {}static inline void os_daemonize (void ) {}util/oslib-win32.c +0
-0@@ -106,7 +106,7 @@ void qemu_anon_ram_free(void *ptr, size_t size) } }
Quoted 14 lines
Quoted 9 lines
util/oslib-win32.c +1
-2-#ifndef CONFIG_LOCALTIME_R +#ifndef _POSIX_THREAD_SAFE_FUNCTIONS/* FIXME: add proper locking */ struct tm *gmtime_r (const time_t *timep,struct tm *result) { --2.28.0.windows.1
Regards,
Daniel
--
|: https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
Quoted 1 line
|: https://libvirt.org -o-
https://fstop138.berrange.com :|
Quoted 1 line
|: https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|
Quoted 1 line
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
PATCH v9 5/26 curses: Fixes curses compiling errors.
In reply to Yonggang LuoThis 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
gcc version 10.2.0 (Rev1, Built by MSYS2 project)
--- ui/curses.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ui/curses.c +2 -2
@@ -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 ) {
Signature · 1 line
2.28.0.windows.1
PATCH v9 6/26 tests: disable /char/stdio/* tests in test-char.c on win32
In reply to Yonggang LuoThese tests are blocking test-char to be finished. Disable them by using variable is_win32, so we doesn't need macro to open it. and easy recover those function latter.
--- tests/test-char.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
tests/test-char.c +16 -10
@@ -77,7 +77,6 @@ static void fe_event(void *opaque, QEMUChrEvent event) } } -#ifdef _WIN32static void char_console_test_subprocess (void ) {QemuOpts *opts;
@@ -102,7 +101,7 @@ static void char_console_test(void)g_test_trap_assert_passed ();g_test_trap_assert_stdout ("CONSOLE" ); } -#endif +static void char_stdio_test_subprocess (void ) {Chardev *chr;
@@ -1448,7 +1447,11 @@ static SocketAddress unixaddr = {int main (int argc,char **argv) { -bool has_ipv4, has_ipv6; +bool has_ipv4, has_ipv6, is_win32 = false; + +#ifdef _WIN32 + is_win32 = true; +#endif qemu_init_main_loop (&error_abort);socket_init ();
@@ -1467,12 +1470,15 @@ int main(int argc, char **argv)g_test_add_func ("/char/invalid" , char_invalid_test);g_test_add_func ("/char/ringbuf" , char_ringbuf_test);g_test_add_func ("/char/mux" , char_mux_test); -#ifdef _WIN32 -g_test_add_func ("/char/console/subprocess" , char_console_test_subprocess); -g_test_add_func ("/char/console" , char_console_test); -#endif -g_test_add_func ("/char/stdio/subprocess" , char_stdio_test_subprocess); -g_test_add_func ("/char/stdio" , char_stdio_test); +if (0 ) { +g_test_add_func ("/char/console/subprocess" , char_console_test_subprocess); +g_test_add_func ("/char/console" , char_console_test); + } + +if (!is_win32) { +g_test_add_func ("/char/stdio/subprocess" , char_stdio_test_subprocess); +g_test_add_func ("/char/stdio" , char_stdio_test); + }#ifndef _WIN32g_test_add_func ("/char/pipe" , char_pipe_test);#endif
@@ -1534,7 +1540,7 @@ int main(int argc, char **argv) g_test_add_data_func("/char/socket/client/dupid-reconnect/" # name, \ &client8 ##name, char_socket_client_dupid_test) -if (has_ipv4) { +if (has_ipv4 && !is_win32) {SOCKET_SERVER_TEST (tcp, &tcpaddr);SOCKET_CLIENT_TEST (tcp, &tcpaddr); g_test_add_data_func("/char/socket/server/two-clients/tcp", &tcpaddr,
Signature · 1 line
2.28.0.windows.1
PATCH v9 7/26 tests: Fixes test-replication.c on msys2/mingw.
In reply to Yonggang LuoOn Windows there is no path like /tmp/s_local_disk.XXXXXX Use g_get_tmp_dir instead of /tmp.
--- tests/test-replication.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
tests/test-replication.c +14 -4
@@ -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;/* 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; +static char *s_active_disk; +static char *s_hidden_disk;/* 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 (); + p_local_disk =g_strdup_printf ("%s/p_local_disk.XXXXXX" , tmpdir); + s_local_disk =g_strdup_printf ("%s/s_local_disk.XXXXXX" , tmpdir); + s_active_disk =g_strdup_printf ("%s/s_active_disk.XXXXXX" , tmpdir); + s_hidden_disk =g_strdup_printf ("%s/s_hidden_disk.XXXXXX" , tmpdir);qemu_init_main_loop (&error_fatal);bdrv_init ();
@@ -605,5 +610,10 @@ int main(int argc, char **argv)cleanup_imgs (); +g_free (p_local_disk); +g_free (s_local_disk); +g_free (s_active_disk); +g_free (s_hidden_disk); +return ret; }
Signature · 1 line
2.28.0.windows.1
PATCH v9 8/26 tests: test-replication disable /replication/secondary/* on msys2/mingw.
In reply to Yonggang LuoThey caused failure on msys2/mingw, that's because file-win32.c not implement .bdrv_reopen_prepare/commit/abort yet.
This is the error message:
Quoted 10 lines
$ ./tests/test-replication.exe # random seed: R02S3f4d1c01af2b0a046990e0235c481faf 1..13 # Start of replication tests # Start of primary tests ok 1 /replication/primary/read ok 2 /replication/primary/write ok 3 /replication/primary/start ok 4 /replication/primary/stop ok 5 /replication/primary/do_checkpoint
Quoted 8 lines
ok 6 /replication/primary/get_error_all # End of primary tests # Start of secondary tests ok 7 /replication/secondary/read ok 8 /replication/secondary/write Unexpected error in bdrv_reopen_prepare() at ../block.c:4191: Block format 'file' used by node '#block4287' does not support reopening files
--- tests/test-replication.c | 4 ++++ 1 file changed, 4 insertions(+)
tests/test-replication.c +4 -0
@@ -392,6 +392,7 @@ static void test_secondary_write(void)teardown_secondary (); } +#ifndef _WIN32static void test_secondary_start (void ) {BlockBackend *top_blk, *local_blk;
@@ -546,6 +547,7 @@ static void test_secondary_get_error_all(void) teardown_secondary(); } +#endif static void sigabrt_handler (int signo) {
@@ -597,6 +599,7 @@ int main(int argc, char **argv)/* Secondary */ g_test_add_func ("/replication/secondary/read" , test_secondary_read);g_test_add_func ("/replication/secondary/write" , test_secondary_write); +#ifndef _WIN32g_test_add_func ("/replication/secondary/start" , test_secondary_start);g_test_add_func ("/replication/secondary/stop" , test_secondary_stop); g_test_add_func("/replication/secondary/continuous_replication",
@@ -605,6 +608,7 @@ int main(int argc, char **argv) test_secondary_do_checkpoint);g_test_add_func ("/replication/secondary/get_error_all" , test_secondary_get_error_all); +#endif ret =g_test_run ();
Signature · 1 line
2.28.0.windows.1
PATCH v9 9/26 osdep: file locking functions are not available on Win32
In reply to Yonggang LuoDo not declare the following locking functions on Win32:
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);
--- include/qemu/osdep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/qemu/osdep.h +1 -1
@@ -502,11 +502,11 @@ int qemu_close(int fd);int qemu_unlink (const char *name);#ifndef _WIN32int 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"
Signature · 1 line
2.28.0.windows.1
PATCH v9 10/26 meson: Use -b to ignore CR vs. CR-LF issues on Windows
In reply to Yonggang LuoIdeally we would use the '--strip-trailing-cr' option, but not being POSIX is a portability problem (i.e. BSDs and Solaris based OSes). Instead use the '-b' option which, although doing slightly more, produce the expected result on Windows."
--- tests/qapi-schema/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qapi-schema/meson.build +1 -1
@@ -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'])
Signature · 1 line
2.28.0.windows.1
PATCH v9 11/26 gcrypt: test_tls_psk_init should write binary file instead text file.
In reply to Yonggang LuoOn windows, if open file with "w", it's will automatically convert "\n" to "\r\n" when writing to file.
--- tests/crypto-tls-psk-helpers.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tests/crypto-tls-psk-helpers.c +3 -1
@@ -26,13 +26,15 @@#include "crypto-tls-psk-helpers.h" #include "qemu/sockets.h" +#include <glib/gstdio.h> +#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT void test_tls_psk_init (const char *pskfile) {FILE *fp; - fp =fopen (pskfile,"w" ); + fp =fopen (pskfile,"wb" );if (fp ==NULL ) {g_critical ("Failed to create pskfile %s" , pskfile);abort ();
Signature · 1 line
2.28.0.windows.1
PATCH v9 12/26 tests: Enable crypto tests under msys2/mingw
In reply to Yonggang LuoFixes following tests on msys2/mingw
'test-crypto-tlscredsx509'
test-crypto-tlssession'
'test-io-channel-tls'
These tests are failure with:
ERROR test-crypto-tlscredsx509 - missing test plan ERROR test-crypto-tlssession - missing test plan ERROR test-io-channel-tls - missing test plan
Because on win32 those test case are all disabled in the header
Add qemu_socket_pair for cross platform support
Convert file system handling functions to glib
Add qemu_link function instead posix only link function.
Use send ad recv from qemu that convert Windows Socks error to errno properly. Use g_remove instead unlink
Use g_mkdir instead mkdir
--- tests/crypto-tls-psk-helpers.c | 2 +- tests/crypto-tls-x509-helpers.c | 106 ++++++++++++++++++++++++++++++- tests/crypto-tls-x509-helpers.h | 9 ++- tests/test-crypto-tlscredsx509.c | 47 +++++++------- tests/test-crypto-tlssession.c | 68 +++++++++++--------- tests/test-io-channel-tls.c | 51 ++++++++------- 6 files changed, 204 insertions(+), 79 deletions(-)
tests/crypto-tls-psk-helpers.c +1 -1
@@ -46,7 +46,7 @@ void test_tls_psk_init(const char *pskfile)void test_tls_psk_cleanup (const char *pskfile) { -unlink (pskfile); +g_remove (pskfile); }#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */
tests/crypto-tls-x509-helpers.c +104 -2
125 lines not on this page · raw message
tests/crypto-tls-x509-helpers.h +7 -2
@@ -24,8 +24,9 @@#include <gnutls/gnutls.h> #include <gnutls/x509.h> -#if !(definedWIN32 ) && \ - defined(CONFIG_TASN1 ) +#include "qemu/osdep.h" + +#if defined(CONFIG_TASN1 )# define QCRYPTO_HAVE_TLS_TEST_SUPPORT #endif
@@ -127,6 +128,10 @@ void test_tls_cleanup(const char *keyfile);extern const ASN1_ARRAY_TYPE pkix_asn1_tab[]; +int qemu_link (const char *exist_path1,const char *new_path2); + +int qemu_socketpair (int family,int type,int protocol,int channel[2 ]); +#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */ #endif
tests/test-crypto-tlscredsx509.c +25 -22
94 lines not on this page · raw message
tests/test-crypto-tlssession.c +38 -30
142 lines not on this page · raw message
tests/test-io-channel-tls.c +29 -22
94 lines not on this page · raw message
Signature · 1 line
2.28.0.windows.1
Re: [PATCH v9 12/26] tests: Enable crypto tests under msys2/mingw
Quoted 91 lines · Yonggang Luo
Fixes following tests on msys2/mingw
'test-crypto-tlscredsx509'
test-crypto-tlssession'
'test-io-channel-tls'These tests are failure with:
ERROR test-crypto-tlscredsx509 - missing test plan ERROR test-crypto-tlssession - missing test plan ERROR test-io-channel-tls - missing test planBecause on win32 those test case are all disabled in the header
Add
qemu_socket_pairfor cross platform support
Convert file system handling functions to glib
Addqemu_linkfunction instead posix only link function.
Use send ad recv from qemu that convert Windows Socks error to errno properly. Useg_removeinstead unlink
Useg_mkdirinstead mkdirSigned-off-by Yonggang Luo <[email protected]>--- tests/crypto-tls-psk-helpers.c | 2 +- tests/crypto-tls-x509-helpers.c | 106 ++++++++++++++++++++++++++++++- tests/crypto-tls-x509-helpers.h | 9 ++- tests/test-crypto-tlscredsx509.c | 47 +++++++------- tests/test-crypto-tlssession.c | 68 +++++++++++--------- tests/test-io-channel-tls.c | 51 ++++++++------- 6 files changed, 204 insertions(+), 79 deletions(-)tests/crypto-tls-psk-helpers.c +1
-1@@ -46,7 +46,7 @@ void test_tls_psk_init(const char *pskfile)void test_tls_psk_cleanup (const char *pskfile) { -unlink (pskfile); +g_remove (pskfile); }#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */ tests/crypto-tls-x509-helpers.c +22
-2@@ -23,6 +23,8 @@#include "crypto-tls-x509-helpers.h" #include "crypto/init.h" #include "qemu/sockets.h" +#include <glib.h> +#include <glib/gstdio.h> #ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT @@ -133,7 +135,7 @@ void test_tls_init(const char *keyfile)void test_tls_cleanup (const char *keyfile) {asn1_delete_structure (&pkix_asn1); -unlink (keyfile); +g_remove (keyfile); }/* @@ -501,8 +503,108 @@ void test_tls_discard_cert(QCryptoTLSTestCertReq *req) req->crt =NULL ;if (getenv ("QEMU_TEST_DEBUG_CERTS" ) ==NULL ) { -unlink (req->filename); +g_remove (req->filename); } } +int qemu_link (const char *exist_path1,const char *new_path2) +{ +#if defined(_WIN32) + g_autofree gchar *current_dir = g_get_current_dir(); + g_autofree gchar *full_path = g_build_filename(current_dir, exist_path1, NULL); +return CreateSymbolicLinkA ( + new_path2, full_path,0 |SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE ) ?0 :-1 ; +#else +return link (exist_path1, new_path2); +#endif +} + +#if defined(_WIN32) + +int qemu_socketpair (int family,int type,int protocol,int channel[2 ]) +{ +struct addrinfo addr_data; +struct addrinfo *addr =NULL ;
tests/crypto-tls-x509-helpers.c void test_tls_discard_cert(QCryptoTLSTestCertReq *req) · line 537
Quoted 10 lines
tests/crypto-tls-x509-helpers.c +10
-0+int sock_listener =-1 ; +int sock_client =-1 ; +int sock_server =-1 ; +int one =1 ; + +memset (&addr_data,0 ,sizeof (addr_data)); + addr_data.ai_family =AF_INET ; + addr_data.ai_socktype = type; + addr_data.ai_protocol = protocol; +if (0 !=getaddrinfo ("127.0.0.1" ,"0" , &addr_data, &addr)) {
This test is backwards - QEMU style is "getaddrinfo(...) != 0"
tests/crypto-tls-x509-helpers.c void test_tls_discard_cert(QCryptoTLSTestCertReq *req) · line 548
Quoted 11 lines
tests/crypto-tls-x509-helpers.c +11
-0+ goto error; + } + +if (NULL == addr) { + goto error; + } + + sock_listener =socket (addr->ai_family, addr->ai_socktype, addr->ai_protocol); +if (-1 == sock_listener) { + goto error; + }
Normal code style is "sock_listener < 0"
tests/crypto-tls-x509-helpers.c void test_tls_discard_cert(QCryptoTLSTestCertReq *req) · line 552
Quoted 4 lines
tests/crypto-tls-x509-helpers.c +4
-0+ +if (-1 ==setsockopt (sock_listener,SOL_SOCKET ,SO_REUSEADDR , (const char *)&one,sizeof (one))) { + goto error; + }
SO_REUSEADDR is not desirable on Windows - see os-win32.c comments about it.
Quoted 75 lines
tests/crypto-tls-x509-helpers.c +57
-0+if (-1 ==bind (sock_listener, addr->ai_addr, addr->ai_addrlen)) { + goto error; + } +if (-1 ==getsockname (sock_listener, addr->ai_addr, (int *)&(addr->ai_addrlen))) { + goto error; + } +if (-1 ==listen (sock_listener,1 )) { + goto error; + } + + sock_client =socket (addr->ai_family, addr->ai_socktype, addr->ai_protocol); + +if (-1 == sock_client) { + goto error; + } + +if (-1 ==connect (sock_client, addr->ai_addr, addr->ai_addrlen)) { + goto error; + } + + sock_server =accept (sock_listener,0 ,0 ); + +if (-1 == sock_server) { + goto error; + } + +closesocket (sock_listener); + + channel[0 ] = sock_client; + channel[1 ] = sock_server; +return 0 ; + +error: +if (-1 != sock_server) { +closesocket (sock_server); + } +if (-1 != sock_client) { +closesocket (sock_client); + } +if (-1 != sock_listener) { +closesocket (sock_listener); + } +if (NULL != addr) { +freeaddrinfo (addr); + } +return -1 ; +} + +#else + +int qemu_socketpair (int family,int type,int protocol,int recv[2 ]) +{ +return socketpair (family, type, protocol, recv); +} + +#endif +#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */ tests/crypto-tls-x509-helpers.h +3
-2@@ -24,8 +24,9 @@#include <gnutls/gnutls.h> #include <gnutls/x509.h> -#if !(definedWIN32 ) && \ - defined(CONFIG_TASN1 ) +#include "qemu/osdep.h" + +#if defined(CONFIG_TASN1 )# define QCRYPTO_HAVE_TLS_TEST_SUPPORT #endif
tests/crypto-tls-x509-helpers.h void test_tls_cleanup(const char *keyfile); · line 134
Quoted 7 lines
tests/crypto-tls-x509-helpers.h +4
-0@@ -127,6 +128,10 @@ void test_tls_cleanup(const char *keyfile);extern const ASN1_ARRAY_TYPE pkix_asn1_tab[]; +int qemu_link (const char *exist_path1,const char *new_path2); + +int qemu_socketpair (int family,int type,int protocol,int channel[2 ]); +
THese aren't really related t the TLS tests - they're platform portability wrappers, so osdep.{ch} and qemu-sockets.c is where they ought to live
tests/crypto-tls-x509-helpers.h void test_tls_cleanup(const char *keyfile); · line 137
Quoted 3 lines
tests/crypto-tls-x509-helpers.h +0
-0#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */ #endif
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v9 13/26 meson: remove empty else and duplicated gio deps
In reply to Yonggang Luo--- meson.build | 6 ------ 1 file changed, 6 deletions(-)
meson.build +0 -6
@@ -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
Signature · 1 line
2.28.0.windows.1
PATCH v9 14/26 vmstate: Fixes test-vmstate.c on msys2/mingw
In reply to Yonggang LuoThe vmstate are valid on win32, just need generate tmp path properly
--- tests/test-vmstate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/test-vmstate.c +2 -1
@@ -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;
@@ -1484,6 +1483,8 @@ 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 );
Signature · 1 line
2.28.0.windows.1
PATCH v9 15/26 cirrus: Building freebsd in a single short
In reply to Yonggang LuoThis reverts commit 45f7b7b9f38f5c4d1529a37c93dedfc26a231bba ("cirrus.yml: Split FreeBSD job into two parts").
freebsd 1 hour limit not hit anymore
I think we going to a wrong direction, I think there is some tests a stall the test runner, please look at
https://cirrus-ci.com/task/5110577531977728
When its running properly, the consumed time are little, but when tests running too long, look at the cpu usage, the cpu usage are nearly zero. doesn't consuming time.
And look at
https://cirrus-ci.com/task/6119341601062912
If the tests running properly, the time consuming are little We should not hide the error by split them
--- .cirrus.yml | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-)
.cirrus.yml +8 -27
@@ -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
Signature · 1 line
2.28.0.windows.1
PATCH v9 16/26 tests: Convert g_free to g_autofree macro in test-logging.c
In reply to Yonggang Luog_autofree are prefer than g_free when possible.
--- tests/test-logging.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tests/test-logging.c +1 -2
@@ -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 );
@@ -212,6 +212,5 @@ int main(int argc, char **argv) rc =g_test_run ();rmdir_full (tmp_path); -g_free (tmp_path);return rc; }
Signature · 1 line
2.28.0.windows.1
PATCH v9 17/26 tests: Fixes test-io-channel-socket.c tests under msys2/mingw
In reply to Yonggang LuoCurrently test-io-channel-socket doesn't init with qemu_init_main_loop
and that's cause the qemu_aio_context not inited, and the following is the stack when null pointer accessed:
qemu_fd_register (c:\work\xemu\qemu\util\main-loop.c:336) qemu_try_set_nonblock (c:\work\xemu\qemu\util\oslib-win32.c:224) qemu_set_nonblock (c:\work\xemu\qemu\util\oslib-win32.c:230) socket_can_bind_connect (c:\work\xemu\qemu\tests\socket-helpers.c:93) socket_check_protocol_support (c:\work\xemu\qemu\tests\socket-helpers.c:141) main (c:\work\xemu\qemu\tests\test-io-channel-socket.c:568) __tmainCRTStartup (@__tmainCRTStartup:142)
mainCRTStartup (@1400014f6..140001539:3)
BaseThreadInitThunk (@BaseThreadInitThunk:9)
RtlUserThreadStart (@RtlUserThreadStart:12)
--- tests/test-io-channel-socket.c | 2 ++ 1 file changed, 2 insertions(+)
tests/test-io-channel-socket.c +2 -0
@@ -25,6 +25,7 @@#include "socket-helpers.h" #include "qapi/error.h" #include "qemu/module.h" +#include "qemu/main-loop.h" static void test_io_channel_set_socket_bufs(QIOChannel *src,
@@ -556,6 +557,7 @@ int main(int argc, char **argv)bool has_ipv4, has_ipv6;module_call_init (MODULE_INIT_QOM ); +qemu_init_main_loop (&error_abort);socket_init ();g_test_init (&argc, &argv,NULL );
Signature · 1 line
2.28.0.windows.1
PATCH v9 18/26 tests: fixes aio-win32 about aio_remove_fd_handler, get it consistence with aio-posix.c
In reply to Yonggang LuoThis is a fixes for
(C:\work\xemu\qemu\build\tests\test-aio-multithread.exe:19100): GLib-CRITICAL **: 23:03:24.965: g_source_remove_poll: assertion '!SOURCE_DESTROYED (source)' failed ERROR test-aio-multithread - Bail out! GLib-FATAL-CRITICAL: g_source_remove_poll: assertion '!SOURCE_DESTROYED (source)' failed
(C:\work\xemu\qemu\build\tests\test-bdrv-drain.exe:21036): GLib-CRITICAL **: 23:03:29.861: g_source_remove_poll: assertion '!SOURCE_DESTROYED (source)' failed ERROR test-bdrv-drain - Bail out! GLib-FATAL-CRITICAL: g_source_remove_poll: assertion '!SOURCE_DESTROYED (source)' failed
And the idea comes from https://patchwork.kernel.org/patch/9975239/
--- util/aio-win32.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
util/aio-win32.c +9 -2
@@ -37,6 +37,15 @@ struct AioHandler {static void aio_remove_fd_handler (AioContext *ctx,AioHandler *node) { +/* If the GSource is in the process of being destroyed then +* g_source_remove_poll() causes an assertion failure. Skip +* removal in that case, because glib cleans up its state during +* destruction anyway. +*/ +if (!g_source_is_destroyed (&ctx->source)) { +g_source_remove_poll (&ctx->source, &node->pfd); + } +/* If aio_poll is in progress, just mark the node as deleted */ if (qemu_lockcnt_count (&ctx->list_lock)) { node->deleted =1 ;
@@ -139,8 +148,6 @@ void aio_set_event_notifier(AioContext *ctx,/* Are we deleting the fd handler? */ if (!io_notify) {if (node) { -g_source_remove_poll (&ctx->source, &node->pfd); -aio_remove_fd_handler (ctx, node); } }else {
Signature · 1 line
2.28.0.windows.1
PATCH v9 19/26 tests: Fixes test-io-channel-file by mask only owner file state mask bits
In reply to Yonggang LuoThis is the error on msys2/mingw
Running test test-io-channel-file
**
ERROR:../tests/test-io-channel-file.c:59:test_io_channel_file_helper: assertion failed (TEST_MASK & ~mask == st.st_mode & 0777): (384 == 438)
ERROR test-io-channel-file - Bail out! ERROR:../tests/test-io-channel-file.c:59:test_io_channel_file_helper: assertion failed (TEST_MASK & ~mask == st.st_mode & 0777): (384 == 438)
--- tests/test-io-channel-file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
tests/test-io-channel-file.c +9 -1
@@ -28,6 +28,12 @@#define TEST_FILE "tests/test-io-channel-file.txt"#define TEST_MASK 0600 +#ifdef _WIN32 +#define TEST_MASK_EXPECT 0700 +#else +#define TEST_MASK_EXPECT 0777 +#endif +static void test_io_channel_file_helper (int flags) {QIOChannel *src, *dst;
@@ -56,7 +62,9 @@ static void test_io_channel_file_helper(int flags)umask (mask); ret =stat (TEST_FILE , &st); g_assert_cmpint(ret, >, -1); - g_assert_cmpuint(TEST_MASK & ~mask, ==, st.st_mode & 0777); +/* On Windows the stat() function in the C library checks only +the FAT-style READONLY attribute and does not look at the ACL at all. */ + g_assert_cmpuint(TEST_MASK & ~mask, ==, st.st_mode & TEST_MASK_EXPECT);unlink (TEST_FILE );object_unref (OBJECT (src));
Signature · 1 line
2.28.0.windows.1
Re: [PATCH v9 19/26] tests: Fixes test-io-channel-file by mask only owner file state mask bits
Quoted 10 lines · Yonggang Luo
This is the error on msys2/mingw
Running test test-io-channel-file
**
ERROR:../tests/test-io-channel-file.c:59:test_io_channel_file_helper: assertion failed (TEST_MASK& ~mask == st.st_mode & 0777): (384 == 438)
ERROR test-io-channel-file - Bail out! ERROR:../tests/test-io-channel-file.c:59:test_io_channel_file_helper: assertion failed (TEST_MASK& ~mask == st.st_mode & 0777): (384 == 438)Signed-off-by Yonggang Luo <[email protected]>--- tests/test-io-channel-file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v9 20/26 tests: fix test-util-sockets.c
In reply to Yonggang LuoFixes following errors:
Running test test-util-sockets
ERROR test-util-sockets - missing test plan
# Start of name tests
**
ERROR:../tests/test-util-sockets.c:93:test_socket_fd_pass_name_good: assertion failed (fd != -1): (-1 != -1) Bail out! ERROR:../tests/test-util-sockets.c:93:test_socket_fd_pass_name_good: assertion failed (fd != -1): (-1 != -1)
First should call to qemu_init_main_loop before socket_init, then on win32 doesn't support for SOCKET_ADDRESS_TYPE_FD socket type
--- tests/test-util-sockets.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tests/test-util-sockets.c +5 -1
@@ -75,7 +75,7 @@ int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { abort(); }void monitor_init_qmp (Chardev *chr,bool pretty,Error **errp) {}void monitor_init_hmp (Chardev *chr,bool use_readline,Error **errp) {} - +#ifndef _WIN32static void test_socket_fd_pass_name_good (void ) {SocketAddress addr;
@@ -227,6 +227,7 @@ static void test_socket_fd_pass_num_nocli(void) g_free(addr.u.fd.str); } +#endif #ifdef __linux__static gchar *abstract_sock_name;
@@ -321,6 +322,7 @@ int main(int argc, char **argv) {bool has_ipv4, has_ipv6; +qemu_init_main_loop (&error_abort);socket_init ();g_test_init (&argc, &argv,NULL );
@@ -340,6 +342,7 @@ int main(int argc, char **argv) test_fd_is_socket_bad);g_test_add_func ("/util/socket/is-socket/good" , test_fd_is_socket_good); +#ifndef _WIN32g_test_add_func ("/socket/fd-pass/name/good" , test_socket_fd_pass_name_good); g_test_add_func("/socket/fd-pass/name/bad",
@@ -352,6 +355,7 @@ int main(int argc, char **argv) test_socket_fd_pass_num_bad);g_test_add_func ("/socket/fd-pass/num/nocli" , test_socket_fd_pass_num_nocli); +#endif }#ifdef __linux__
Signature · 1 line
2.28.0.windows.1
PATCH v9 21/26 tests: Fixes test-qdev-global-props.c
In reply to Yonggang LuoOn win32 the line ending are \r\n, so we skip the \n in function test_dynamic_globalprop
--- tests/test-qdev-global-props.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/test-qdev-global-props.c +3 -3
@@ -251,10 +251,10 @@ static void test_dynamic_globalprop(void)g_test_trap_assert_passed ();g_test_trap_assert_stderr_unmatched ("*prop1*" );g_test_trap_assert_stderr_unmatched ("*prop2*" ); -g_test_trap_assert_stderr ("*warning: global dynamic-prop-type-bad.prop3 has invalid class name\n*" ); +g_test_trap_assert_stderr ("*warning: global dynamic-prop-type-bad.prop3 has invalid class name*" );g_test_trap_assert_stderr_unmatched ("*prop4*" ); -g_test_trap_assert_stderr ("*warning: global nohotplug-type.prop5=105 not used\n*" ); -g_test_trap_assert_stderr ("*warning: global nondevice-type.prop6 has invalid class name\n*" ); +g_test_trap_assert_stderr ("*warning: global nohotplug-type.prop5=105 not used*" ); +g_test_trap_assert_stderr ("*warning: global nondevice-type.prop6 has invalid class name*" );g_test_trap_assert_stdout ("" ); }
Signature · 1 line
2.28.0.windows.1
PATCH v9 22/26 rcu: fixes test-logging.c by call drain_call_rcu before rmdir_full
In reply to Yonggang Luodrain_call_rcu is necessary on win32, because under win32, if you don't close the file before remove it, the remove would be fail.
--- tests/test-logging.c | 2 ++ 1 file changed, 2 insertions(+)
tests/test-logging.c +2 -0
@@ -210,6 +210,8 @@ int main(int argc, char **argv) tmp_path, test_logfile_lock); rc =g_test_run (); +qemu_log_close (); +drain_call_rcu ();rmdir_full (tmp_path);return rc;
Signature · 1 line
2.28.0.windows.1
PATCH v9 23/26 meson: upgrade meson for execute custom ninjatool under msys2 properly
In reply to Yonggang Luo* Bump versions to 0.55.2 for release
* Tag Info:
object 008d13038f95e7c7d8ad553f14e408da5b94c360 type commit
tag 0.55.2
tagger Jussi Pakkanen <[email protected]> 2020/9/11 1:24:47
--- meson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meson +1 -1
@@ -1 +1 @@ -Subproject commit 68ed748f84f14c2d4e62dcbd123816e5898eb04c +Subproject commit 008d13038f95e7c7d8ad553f14e408da5b94c360
Signature · 1 line
2.28.0.windows.1
PATCH v9 24/26 ci: Enable msys2 ci in cirrus
In reply to Yonggang LuoInstall 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.
--- .cirrus.yml | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
.cirrus.yml +61 -0
@@ -44,3 +44,64 @@ 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 --noconfirm -Sy" + - C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -S --needed + 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 "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-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-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-nettle + mingw-w64-x86_64-cyrus-sasl + mingw-w64-x86_64-curl + mingw-w64-x86_64-gnutls + mingw-w64-x86_64-zstd" + script: + - C:\tools\msys64\usr\bin\bash.exe -lc "mkdir build" + - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure --python=python3" + - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make -j$NUMBER_OF_PROCESSORS" + test_script: + - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make V=1 check" +
Signature · 1 line
2.28.0.windows.1
PATCH v9 25/26 block: Fixes nfs compiling error on msys2/mingw
In reply to Yonggang LuoThese compiling errors are fixed:../block/nfs.c:27:10: fatal error: poll.h: No such file or directory
27 | #include <poll.h>
| ^~~~~~~~
compilation terminated.
../block/nfs.c:63:5: error: unknown type name 'blkcnt_t'
63 | blkcnt_t st_blocks;
| ^~~~~~~~../block/nfs.c: In function 'nfs_client_open':../block/nfs.c:550:27: error: 'struct _stat64' has no member named 'st_blocks'
550 | client->st_blocks = st.st_blocks;
| ^../block/nfs.c: In function 'nfs_get_allocated_file_size':../block/nfs.c:751:41: error: 'struct _stat64' has no member named 'st_blocks'
751 | return (task.ret < 0 ? task.ret : st.st_blocks * 512);
| ^../block/nfs.c: In function 'nfs_reopen_prepare':../block/nfs.c:805:31: error: 'struct _stat64' has no member named 'st_blocks'
805 | client->st_blocks = st.st_blocks;
| ^../block/nfs.c: In function 'nfs_get_allocated_file_size':../block/nfs.c:752:1: error: control reaches end of non-void function [-Werror=return-type]
752 | }
| ^
On msys2/mingw, there is no st_blocks in struct _stat64 yet, we disable the usage of it on msys2/mingw, and create a typedef long long blkcnt_t; for further implementation
--- block/nfs.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-)
block/nfs.c +30 -7
@@ -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,13 @@#define QEMU_NFS_MAX_PAGECACHE_SIZE (8388608 / NFS_BLKSIZE)#define QEMU_NFS_MAX_DEBUG_LEVEL 2 +#if defined (_WIN32) +#define nfs_stat __stat64 +typedef long long blkcnt_t ; +#else +#define nfs_stat stat +#endif + typedef struct NFSClient { struct nfs_context *context; struct nfsfh *fh;
@@ -70,7 +79,7 @@ typedef struct NFSRPC {int ret;int complete;QEMUIOVector *iov; -struct stat *st; +struct nfs_stat *st;Coroutine *co;NFSClient *client; }NFSRPC ;
@@ -415,11 +424,21 @@ static void nfs_file_close(BlockDriverState *bs)nfs_client_close (client); } +static blkcnt_t nfs_get_st_blocks (const struct nfs_stat *st) +{ +#if defined(_WIN32) +/* TODO: Not be possible implement on win32 yet, place here for futher implementation */ +return 0 ; +#else +return st->st_blocks; +#endif +} +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 +564,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_blocks =nfs_get_st_blocks (&st); client->has_zero_init =S_ISREG (st.st_mode); *strp ='/' ; goto out;
@@ -706,6 +725,7 @@ static int nfs_has_zero_init(BlockDriverState *bs)return client->has_zero_init; } +#if !defined (_WIN32)/* Called (via nfs_service) with QemuMutex held. */ static void nfs_get_allocated_file_size_cb(int ret, struct nfs_context *nfs, void *data,
@@ -729,7 +749,7 @@ 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 )) {
@@ -746,8 +766,9 @@ 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 :nfs_get_st_blocks (&st) *512 ); } +#endif static int coroutine_fn nfs_file_co_truncate(BlockDriverState *bs, int64_t offset, bool exact,
@@ -778,7 +799,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 +821,7 @@ static int nfs_reopen_prepare(BDRVReopenState *state, nfs_get_error(client->context));return ret; } - client->st_blocks = st.st_blocks; + client->st_blocks =nfs_get_st_blocks (&st); }return 0 ;
@@ -869,7 +890,9 @@ static BlockDriver bdrv_nfs = { .create_opts = &nfs_create_opts, .bdrv_has_zero_init = nfs_has_zero_init, +#if !defined (_WIN32) .bdrv_get_allocated_file_size = nfs_get_allocated_file_size, +#endif .bdrv_co_truncate = nfs_file_co_truncate, .bdrv_file_open = nfs_file_open,
Signature · 1 line
2.28.0.windows.1
PATCH v9 26/26 block: enable libnfs on msys2/mingw in cirrus.yml
In reply to Yonggang LuoAt the begging libnfs are not enabled because of compiling error, now it's fixed so enable it
--- .cirrus.yml | 1 + 1 file changed, 1 insertion(+)
.cirrus.yml +1 -0
@@ -93,6 +93,7 @@ windows_msys2_task: 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
Signature · 1 line
2.28.0.windows.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PATCH v9 00/26] W32, W64 msys2/mingw patches
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
0b113c6 block: enable libnfs on msys2/mingw in cirrus.yml
948c78c block: Fixes nfs compiling error on msys2/mingw
083ce32 ci: Enable msys2 ci in cirrus
bc69278 meson: upgrade meson for execute custom ninjatool under msys2 properly fef8a0c rcu: fixes test-logging.c by call drain_call_rcu before rmdir_full 58f2e78 tests: Fixes test-qdev-global-props.c
4a17a57 tests: fix test-util-sockets.c
6d2b926 tests: Fixes test-io-channel-file by mask only owner file state mask bits e170301 tests: fixes aio-win32 about aio_remove_fd_handler, get it consistence with aio-posix.c 95d2579 tests: Fixes test-io-channel-socket.c tests under msys2/mingw
7e27f27 tests: Convert g_free to g_autofree macro in test-logging.c
07bddec cirrus: Building freebsd in a single short
ae61ebd vmstate: Fixes test-vmstate.c on msys2/mingw
787eeb4 meson: remove empty else and duplicated gio deps
ad29b42 tests: Enable crypto tests under msys2/mingw
eb97064 gcrypt: test_tls_psk_init should write binary file instead text file. 7ebfac6 meson: Use -b to ignore CR vs. CR-LF issues on Windows
6c6166c osdep: file locking functions are not available on Win32
5ae548a tests: test-replication disable /replication/secondary/* on msys2/mingw. 74a6589 tests: Fixes test-replication.c on msys2/mingw.
4a06ce7 tests: disable /char/stdio/* tests in test-char.c on win32
1c1fb53 curses: Fixes curses compiling errors.
bbfe966 win32: Simplify gmtime_r detection direct base on _POSIX_THREAD_SAFE_FUNCTIONS. 588c2f6 configure: Fixes ncursesw detection under msys2/mingw and enable curses 44ed485 ci: fixes msys2 build by upgrading capstone to 4.0.2
2f25baf rcu: Implement drain_call_rcu
=== OUTPUT BEGIN ===
1/26 Checking commit 2f25baf35413 (rcu: Implement drain_call_rcu)
2/26 Checking commit 44ed4856e1ef (ci: fixes msys2 build by upgrading capstone to 4.0.2)
3/26 Checking commit 588c2f6c1827 (configure: Fixes ncursesw detection under msys2/mingw and enable curses) 4/26 Checking commit bbfe966b472f (win32: Simplify gmtime_r detection direct base on _POSIX_THREAD_SAFE_FUNCTIONS.) 5/26 Checking commit 1c1fb5366733 (curses: Fixes curses compiling errors.)
6/26 Checking commit 4a06ce772c82 (tests: disable /char/stdio/* tests in test-char.c on win32)
WARNING: line over 80 characters
#60: FILE: tests/test-char.c:1474:
+ g_test_add_func("/char/console/subprocess", char_console_test_subprocess);
total: 0 errors, 1 warnings, 56 lines checked
Patch 6/26 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
7/26 Checking commit 74a6589a34e0 (tests: Fixes test-replication.c on msys2/mingw.)
8/26 Checking commit 5ae548ac2ff9 (tests: test-replication disable /replication/secondary/* on msys2/mingw.) 9/26 Checking commit 6c6166c50138 (osdep: file locking functions are not available on Win32) 10/26 Checking commit 7ebfac6615e0 (meson: Use -b to ignore CR vs. CR-LF issues on Windows) 11/26 Checking commit eb97064abc00 (gcrypt: test_tls_psk_init should write binary file instead text file.) 12/26 Checking commit ad29b4253ac2 (tests: Enable crypto tests under msys2/mingw)
WARNING: line over 80 characters
#77: FILE: tests/crypto-tls-x509-helpers.c:514:
+ g_autofree gchar *full_path = g_build_filename(current_dir, exist_path1, NULL);
WARNING: line over 80 characters
#79: FILE: tests/crypto-tls-x509-helpers.c:516:
+ new_path2, full_path, 0 | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE) ? 0 : -1;
WARNING: line over 80 characters
#108: FILE: tests/crypto-tls-x509-helpers.c:545:
+ sock_listener = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
ERROR: line over 90 characters
#113: FILE: tests/crypto-tls-x509-helpers.c:550:
+ if (-1 == setsockopt(sock_listener, SOL_SOCKET, SO_REUSEADDR, (const char *)&one, sizeof(one))) {
WARNING: line over 80 characters
#119: FILE: tests/crypto-tls-x509-helpers.c:556:
+ if (-1 == getsockname(sock_listener, addr->ai_addr, (int *)&(addr->ai_addrlen))) {
ERROR: space prohibited between function name and open parenthesis '(' #223: FILE: tests/test-crypto-tlscredsx509.c:85:
+ g_remove (CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT);
ERROR: space prohibited between function name and open parenthesis '(' #227: FILE: tests/test-crypto-tlscredsx509.c:87:
+ g_remove (CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT);
ERROR: space prohibited between function name and open parenthesis '(' #228: FILE: tests/test-crypto-tlscredsx509.c:88:
+ g_remove (CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_KEY);
ERROR: space prohibited between function name and open parenthesis '(' #232: FILE: tests/test-crypto-tlscredsx509.c:90:
+ g_remove (CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
ERROR: space prohibited between function name and open parenthesis '(' #233: FILE: tests/test-crypto-tlscredsx509.c:91:
+ g_remove (CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
total: 6 errors, 4 warnings, 484 lines checked
Patch 12/26 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
13/26 Checking commit 787eeb4e379b (meson: remove empty else and duplicated gio deps) 14/26 Checking commit ae61ebd5b394 (vmstate: Fixes test-vmstate.c on msys2/mingw) 15/26 Checking commit 07bddec81421 (cirrus: Building freebsd in a single short)
ERROR: trailing whitespace
#50: FILE: .cirrus.yml:11:
+ - pkg install -y bash curl cyrus-sasl git glib gmake gnutls gsed $
total: 1 errors, 0 warnings, 46 lines checked
Patch 15/26 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
16/26 Checking commit 7e27f274ff7d (tests: Convert g_free to g_autofree macro in test-logging.c)
WARNING: line over 80 characters
#23: FILE: tests/test-logging.c:199:
+ g_autofree gchar *tmp_path = g_dir_make_tmp("qemu-test-logging.XXXXXX", NULL);
total: 0 errors, 1 warnings, 14 lines checked
Patch 16/26 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
17/26 Checking commit 95d25796fe97 (tests: Fixes test-io-channel-socket.c tests under msys2/mingw)
18/26 Checking commit e170301e71d0 (tests: fixes aio-win32 about aio_remove_fd_handler, get it consistence with aio-posix.c)
WARNING: Block comments use a leading /* on a separate line
#27: FILE: util/aio-win32.c:40:
+ /* If the GSource is in the process of being destroyed then
total: 0 errors, 1 warnings, 23 lines checked
Patch 18/26 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
19/26 Checking commit 6d2b926af4c1 (tests: Fixes test-io-channel-file by mask only owner file state mask bits)
WARNING: Block comments use a leading /* on a separate line
#38: FILE: tests/test-io-channel-file.c:65:
+ /* On Windows the stat() function in the C library checks only
WARNING: Block comments use * on subsequent lines
#39: FILE: tests/test-io-channel-file.c:66:
+ /* On Windows the stat() function in the C library checks only
+ the FAT-style READONLY attribute and does not look at the ACL at all. */
WARNING: Block comments use a trailing */ on a separate line #39: FILE: tests/test-io-channel-file.c:66:
+ the FAT-style READONLY attribute and does not look at the ACL at all. */
total: 0 errors, 3 warnings, 22 lines checked
Patch 19/26 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
20/26 Checking commit 4a17a57935f0 (tests: fix test-util-sockets.c) 21/26 Checking commit 58f2e782a28e (tests: Fixes test-qdev-global-props.c)
ERROR: line over 90 characters
#22: FILE: tests/test-qdev-global-props.c:254:
+ g_test_trap_assert_stderr("*warning: global dynamic-prop-type-bad.prop3 has invalid class name*");
WARNING: line over 80 characters
#26: FILE: tests/test-qdev-global-props.c:256:
+ g_test_trap_assert_stderr("*warning: global nohotplug-type.prop5=105 not used*");
ERROR: line over 90 characters
#27: FILE: tests/test-qdev-global-props.c:257:
+ g_test_trap_assert_stderr("*warning: global nondevice-type.prop6 has invalid class name*");
total: 2 errors, 1 warnings, 13 lines checked
Patch 21/26 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
22/26 Checking commit fef8a0ca31eb (rcu: fixes test-logging.c by call drain_call_rcu before rmdir_full) 23/26 Checking commit bc6927878363 (meson: upgrade meson for execute custom ninjatool under msys2 properly) 24/26 Checking commit 083ce32943f5 (ci: Enable msys2 ci in cirrus)
25/26 Checking commit 948c78c3f338 (block: Fixes nfs compiling error on msys2/mingw)
ERROR: space prohibited between function name and open parenthesis '('
#57: FILE: block/nfs.c:56:
+#if defined (_WIN32)
ERROR: line over 90 characters
#83: FILE: block/nfs.c:430:
+ /* TODO: Not be possible implement on win32 yet, place here for futher implementation */
ERROR: space prohibited between function name and open parenthesis '(' #112: FILE: block/nfs.c:728:
+#if !defined (_WIN32)
ERROR: space prohibited between function name and open parenthesis '(' #158: FILE: block/nfs.c:893:
+#if !defined (_WIN32)
total: 4 errors, 0 warnings, 110 lines checked
Patch 25/26 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
26/26 Checking commit 0b113c632dab (block: enable libnfs on msys2/mingw in cirrus.yml) === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]