Skip to contentSkip to conversation

Patches for Windows

GIT PULL Applied Stefan Weil via 2 participants 6 messages Oct 31, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The following changes since commit 75d30fde55485b965a1168a21d016dd07b50ed32:

Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2022-10-30 15:07:25 -0400)

are available in the Git repository at:

https://gitlab.com/stweil/qemu.git tags/pull-qemu-20221031

for you to fetch changes up to 588fec8a4c3fe9e0d1cb3f7ea6fdd46221e42814:

block/nfs: Fix 32-bit Windows build (2022-10-31 10:06:11 +0100)

----------------------------------------------------------------
Patches for Windows

----------------------------------------------------------------
Bin Meng (4):
scripts/nsis.py: Drop the unnecessary path separator scripts/nsis.py: Fix destination directory name when invoked on Windows scripts/nsis.py: Automatically package required DLLs of QEMU executables block/nfs: Fix 32-bit Windows build

 block/nfs.c     |  8 ++++++++
 meson.build     |  1 +
 scripts/nsis.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++----------
 3 files changed, 59 insertions(+), 10 deletions(-)
#1 lore raw

[PULL 1/4] scripts/nsis.py: Drop the unnecessary path separator

From: Bin Meng <[email protected]>

There is no need to append a path separator to the destination directory that is passed to "make install".

Message-Id: <[email protected]>

---
 scripts/nsis.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/nsis.py +1 -1
index 462d6cac3b..bbb41d9386 100644
@@ -30,7 +30,7 @@ def main():
 
     destdir = tempfile.mkdtemp()
     try:
-        subprocess.run(["make", "install", "DESTDIR=" + destdir + os.path.sep])
+        subprocess.run(["make", "install", "DESTDIR=" + destdir])
         with open(
             os.path.join(destdir + args.prefix, "system-emulations.nsh"), "w"
         ) as nsh, open(
Signature · 1 line
2.30.2
#2 lore raw

[PULL 3/4] scripts/nsis.py: Automatically package required DLLs of QEMU executables

In reply to Stefan Weil via

From: Bin Meng <[email protected]>

At present packaging the required DLLs of QEMU executables is a manual process, and error prone.

Actually build/config-host.mak contains a GLIB_BINDIR variable which is the directory where glib and other DLLs reside. This works for both Windows native build and cross-build on Linux. We can use it as the search directory for DLLs and automate the whole DLL packaging process.

Message-Id: <[email protected]>

---
 meson.build     |  1 +
 scripts/nsis.py | 46 ++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 43 insertions(+), 4 deletions(-)
meson.build +1 -0
index 37737913df..d0a186e7f5 100644
@@ -3616,6 +3616,7 @@ if host_machine.system() == 'windows'
     '@OUTPUT@',
     get_option('prefix'),
     meson.current_source_dir(),
+    config_host['GLIB_BINDIR'],
     host_machine.cpu(),
     '--',
     '-DDISPLAYVERSION=' + meson.project_version(),
scripts/nsis.py +42 -4

75 lines not on this page · raw message

Signature · 1 line
2.30.2
#3 lore raw

[PULL 4/4] block/nfs: Fix 32-bit Windows build

In reply to Stefan Weil via

From: Bin Meng <[email protected]>

libnfs.h declares nfs_fstat() as the following for win32:

int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh,

                struct __stat64 *st);

The 'st' parameter should be of type 'struct __stat64'. The codes happen to build successfully for 64-bit Windows, but it does not build for 32-bit Windows.

Fixes 6542aa9c75bc ("block: add native support for NFS")
Fixes 18a8056e0bc7 ("block/nfs: cache allocated filesize for read-only files")

Message-Id: <[email protected]>

---
 block/nfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)
block/nfs.c +8 -0
index 596ebe98cb..ece22353ac 100644
@@ -418,7 +418,11 @@ static int64_t nfs_client_open(NFSClient *client, BlockdevOptionsNfs *opts,
                                int flags, int open_flags, Error **errp)
 {
     int64_t ret = -EINVAL;
+#ifdef _WIN32
+    struct __stat64 st;
+#else
     struct stat st;
+#endif
     char *file = NULL, *strp = NULL;
 
     qemu_mutex_init(&client->mutex);
@@ -781,7 +785,11 @@ static int nfs_reopen_prepare(BDRVReopenState *state,
                               BlockReopenQueue *queue, Error **errp)
 {
     NFSClient *client = state->bs->opaque;
+#ifdef _WIN32
+    struct __stat64 st;
+#else
     struct stat st;
+#endif
     int ret = 0;
 
     if (state->flags & BDRV_O_RDWR && bdrv_is_read_only(state->bs)) {
Signature · 1 line
2.30.2
#4 lore raw

[PULL 2/4] scripts/nsis.py: Fix destination directory name when invoked on Windows

In reply to Stefan Weil via

From: Bin Meng <[email protected]>

"make installer" on Windows fails with the following message:

Traceback (most recent call last):

    File "G:\msys64\home\foo\git\qemu\scripts\nsis.py", line 89, in <module>
      main()
    File "G:\msys64\home\foo\git\qemu\scripts\nsis.py", line 34, in main
      with open(

OSError: [Errno 22] Invalid argument:
'R:/Temp/tmpw83xhjquG:/msys64/qemu/system-emulations.nsh'
ninja: build stopped: subcommand failed.

Use os.path.splitdrive() to form a canonical path without the drive letter on Windows. This works with cross-build on Linux too.

Fixes 8adfeba953e0 ("meson: add NSIS building")

Message-Id: <[email protected]>

---
 scripts/nsis.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
scripts/nsis.py +7 -5
index bbb41d9386..baa6ef9594 100644
@@ -28,16 +28,18 @@ def main():
     parser.add_argument("nsisargs", nargs="*")
     args = parser.parse_args()
 
+    # canonicalize the Windows native prefix path
+    prefix = os.path.splitdrive(args.prefix)[1]
     destdir = tempfile.mkdtemp()
     try:
         subprocess.run(["make", "install", "DESTDIR=" + destdir])
         with open(
-            os.path.join(destdir + args.prefix, "system-emulations.nsh"), "w"
+            os.path.join(destdir + prefix, "system-emulations.nsh"), "w"
         ) as nsh, open(
-            os.path.join(destdir + args.prefix, "system-mui-text.nsh"), "w"
+            os.path.join(destdir + prefix, "system-mui-text.nsh"), "w"
         ) as muinsh:
             for exe in sorted(glob.glob(
-                os.path.join(destdir + args.prefix, "qemu-system-*.exe")
+                os.path.join(destdir + prefix, "qemu-system-*.exe")
             )):
                 exe = os.path.basename(exe)
                 arch = exe[12:-4]
@@ -61,7 +63,7 @@ def main():
                 !insertmacro MUI_DESCRIPTION_TEXT ${{Section_{0}}} "{1}"
                 """.format(arch, desc))
 
-        for exe in glob.glob(os.path.join(destdir + args.prefix, "*.exe")):
+        for exe in glob.glob(os.path.join(destdir + prefix, "*.exe")):
             signcode(exe)
 
         makensis = [
@@ -69,7 +71,7 @@ def main():
             "-V2",
             "-NOCD",
             "-DSRCDIR=" + args.srcdir,
-            "-DBINDIR=" + destdir + args.prefix,
+            "-DBINDIR=" + destdir + prefix,
         ]
         dlldir = "w32"
         if args.cpu == "x86_64":
Signature · 1 line
2.30.2