From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [PULL 09/15] block: Fixes nfs compiling error on msys2/mingw
Date: Mon, 9 Nov 2020 18:38:33 +0100 [thread overview]
Message-ID: <20201109173839.2135984-10-mreitz@redhat.com> (raw)
In-Reply-To: <20201109173839.2135984-1-mreitz@redhat.com>
From: Yonggang Luo <luoyonggang@gmail.com>
These 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
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Message-Id: <20201105123116.674-2-luoyonggang@gmail.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block/nfs.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/block/nfs.c b/block/nfs.c
index f86e660374..77905f516d 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"
@@ -58,7 +60,7 @@ typedef struct NFSClient {
bool has_zero_init;
AioContext *aio_context;
QemuMutex mutex;
- blkcnt_t st_blocks;
+ uint64_t st_blocks;
bool cache_used;
NFSServer *server;
char *path;
@@ -545,7 +547,9 @@ static int64_t nfs_client_open(NFSClient *client, BlockdevOptionsNfs *opts,
}
ret = DIV_ROUND_UP(st.st_size, BDRV_SECTOR_SIZE);
+#if !defined(_WIN32)
client->st_blocks = st.st_blocks;
+#endif
client->has_zero_init = S_ISREG(st.st_mode);
*strp = '/';
goto out;
@@ -706,6 +710,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,
@@ -748,6 +753,7 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)
return (task.ret < 0 ? task.ret : st.st_blocks * 512);
}
+#endif
static int coroutine_fn
nfs_file_co_truncate(BlockDriverState *bs, int64_t offset, bool exact,
@@ -800,7 +806,9 @@ static int nfs_reopen_prepare(BDRVReopenState *state,
nfs_get_error(client->context));
return ret;
}
+#if !defined(_WIN32)
client->st_blocks = st.st_blocks;
+#endif
}
return 0;
@@ -869,7 +877,10 @@ static BlockDriver bdrv_nfs = {
.create_opts = &nfs_create_opts,
.bdrv_has_zero_init = nfs_has_zero_init,
+/* libnfs does not provide the allocated filesize of a file on win32. */
+#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,
--
2.28.0
next prev parent reply other threads:[~2020-11-09 17:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-09 17:38 [PULL 00/15] Block patches for 5.2.0-rc1 Max Reitz
2020-11-09 17:38 ` [PULL 01/15] block: Remove unused include Max Reitz
2020-11-09 17:38 ` [PULL 02/15] block: Move bdrv_drain_all_end_quiesce() to block_int.h Max Reitz
2020-11-09 17:38 ` [PULL 03/15] qcow2: Document and enforce the QCowL2Meta invariants Max Reitz
2020-11-09 17:38 ` [PULL 04/15] hw/block/nvme: fix null ns in register namespace Max Reitz
2020-11-09 17:38 ` [PULL 05/15] hw/block/nvme: fix uint16_t use of uint32_t sgls member Max Reitz
2020-11-09 17:38 ` [PULL 06/15] hw/block/nvme: fix free of array-typed value Max Reitz
2020-11-09 17:38 ` [PULL 07/15] iotests: add filter_qmp_virtio_scsi function Max Reitz
2020-11-09 17:38 ` [PULL 08/15] iotests: rewrite iotest 240 in python Max Reitz
2020-11-09 17:38 ` Max Reitz [this message]
2020-11-09 17:38 ` [PULL 10/15] block: enable libnfs on msys2/mingw in cirrus.yml Max Reitz
2020-11-09 17:38 ` [PULL 11/15] block: Fix integer promotion error in bdrv_getlength() Max Reitz
2020-11-09 17:38 ` [PULL 12/15] block: Fix some code style problems, "foo* bar" should be "foo *bar" Max Reitz
2020-11-09 17:38 ` [PULL 13/15] block: add forgotten bdrv_abort_perm_update() to bdrv_co_invalidate_cache() Max Reitz
2020-11-09 17:38 ` [PULL 14/15] block: add bdrv_replace_node_common() Max Reitz
2020-11-09 17:38 ` [PULL 15/15] block: make bdrv_drop_intermediate() less wrong Max Reitz
2020-11-09 17:49 ` [PULL 00/15] Block patches for 5.2.0-rc1 Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201109173839.2135984-10-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).