From: Igor Mammedov <imammedo@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] raw-posix: Fix build without posix_fallocate()
Date: Mon, 29 Sep 2014 18:02:26 +0200 [thread overview]
Message-ID: <20140929180226.56ab576e@igors-macbook-pro.local> (raw)
In-Reply-To: <1412003579-31693-1-git-send-email-kwolf@redhat.com>
On Mon, 29 Sep 2014 17:12:59 +0200
Kevin Wolf <kwolf@redhat.com> wrote:
> Check for the presence of posix_fallocate() in configure and only
> compile in support for PREALLOC_MODE_FALLOC when it's there.
With this patch QEMU builds fine on OS X
Tested-By: Igor Mammedov <imammedo@redhat.com>
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/raw-posix.c | 18 ++++++++++++++----
> configure | 18 ++++++++++++++++++
> 2 files changed, 32 insertions(+), 4 deletions(-)
>
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index a253697..86ce4f2 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -1416,16 +1416,21 @@ static int raw_create(const char *filename,
> QemuOpts *opts, Error **errp) goto out_close;
> }
>
> - if (prealloc == PREALLOC_MODE_FALLOC) {
> + switch (prealloc) {
> +#ifdef CONFIG_POSIX_FALLOCATE
> + case PREALLOC_MODE_FALLOC:
> /* posix_fallocate() doesn't set errno. */
> result = -posix_fallocate(fd, 0, total_size);
> if (result != 0) {
> error_setg_errno(errp, -result,
> "Could not preallocate data for the new
> file"); }
> - } else if (prealloc == PREALLOC_MODE_FULL) {
> - buf = g_malloc0(65536);
> + break;
> +#endif
> + case PREALLOC_MODE_FULL:
> + {
> int64_t num = 0, left = total_size;
> + buf = g_malloc0(65536);
>
> while (left > 0) {
> num = MIN(left, 65536);
> @@ -1440,10 +1445,15 @@ static int raw_create(const char *filename,
> QemuOpts *opts, Error **errp) }
> fsync(fd);
> g_free(buf);
> - } else if (prealloc != PREALLOC_MODE_OFF) {
> + break;
> + }
> + case PREALLOC_MODE_OFF:
> + break;
> + default:
> result = -EINVAL;
> error_setg(errp, "Unsupported preallocation mode: %s",
> PreallocMode_lookup[prealloc]);
> + break;
> }
>
> out_close:
> diff --git a/configure b/configure
> index a2c0f2a..681abfc 100755
> --- a/configure
> +++ b/configure
> @@ -3308,6 +3308,21 @@ if compile_prog "" "" ; then
> fallocate_punch_hole=yes
> fi
>
> +# check for posix_fallocate
> +posix_fallocate=no
> +cat > $TMPC << EOF
> +#include <fcntl.h>
> +
> +int main(void)
> +{
> + posix_fallocate(0, 0, 0);
> + return 0;
> +}
> +EOF
> +if compile_prog "" "" ; then
> + posix_fallocate=yes
> +fi
> +
> # check for sync_file_range
> sync_file_range=no
> cat > $TMPC << EOF
> @@ -4522,6 +4537,9 @@ fi
> if test "$fallocate_punch_hole" = "yes" ; then
> echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
> fi
> +if test "$posix_fallocate" = "yes" ; then
> + echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
> +fi
> if test "$sync_file_range" = "yes" ; then
> echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
> fi
next prev parent reply other threads:[~2014-09-29 16:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-29 15:12 [Qemu-devel] [PATCH] raw-posix: Fix build without posix_fallocate() Kevin Wolf
2014-09-29 16:02 ` Igor Mammedov [this message]
2014-09-29 16:27 ` Peter Maydell
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=20140929180226.56ab576e@igors-macbook-pro.local \
--to=imammedo@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).