|
From: | Max Reitz |
Subject: | Re: [Qemu-devel] [PATCH v3 23/38] blockdev: Pull out blockdev option extraction |
Date: | Tue, 09 Jun 2015 21:03:57 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
On 09.06.2015 02:37, Fam Zheng wrote:
On Wed, 06/03 21:44, Max Reitz wrote:Extract some of the blockdev option extraction code from blockdev_init() into its own function. This simplifies blockdev_init() and will allow reusing the code in a different function added in a follow-up patch. Signed-off-by: Max Reitz <address@hidden> Reviewed-by: Eric Blake <address@hidden> --- blockdev.c | 201 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 108 insertions(+), 93 deletions(-) diff --git a/blockdev.c b/blockdev.c index 8c91532..8d672ac 100644 --- a/blockdev.c +++ b/blockdev.c @@ -341,24 +341,123 @@ static bool check_throttle_config(ThrottleConfig *cfg, Error **errp)typedef enum { MEDIA_DISK, MEDIA_CDROM } DriveMediaType; +static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags,+ ThrottleConfig *throttle_cfg, BlockdevDetectZeroesOptions *detect_zeroes, + Error **errp) +{ + const char *discard, *aio;This breaks build without CONFIG_LINUX_AIO: /home/fam/qemu/blockdev.c: In function ‘extract_common_blockdev_options’: /home/fam/qemu/blockdev.c:348:27: error: unused variable ‘aio’ [-Werror=unused-variable] const char *discard, *aio; ^ cc1: all warnings being treated as errors
Thanks, I'll fix it. Max
+ Error *local_error = NULL; + + if (!qemu_opt_get_bool(opts, "read-only", false)) { + *bdrv_flags |= BDRV_O_RDWR; + } + if (qemu_opt_get_bool(opts, "copy-on-read", false)) { + *bdrv_flags |= BDRV_O_COPY_ON_READ; + } + + if ((discard = qemu_opt_get(opts, "discard")) != NULL) { + if (bdrv_parse_discard_flags(discard, bdrv_flags) != 0) { + error_setg(errp, "Invalid discard option"); + return; + } + } + + if (qemu_opt_get_bool(opts, "cache.writeback", true)) { + *bdrv_flags |= BDRV_O_CACHE_WB; + } + if (qemu_opt_get_bool(opts, "cache.direct", false)) { + *bdrv_flags |= BDRV_O_NOCACHE; + } + if (qemu_opt_get_bool(opts, "cache.no-flush", false)) { + *bdrv_flags |= BDRV_O_NO_FLUSH; + } + +#ifdef CONFIG_LINUX_AIO + if ((aio = qemu_opt_get(opts, "aio")) != NULL) { + if (!strcmp(aio, "native")) { + *bdrv_flags |= BDRV_O_NATIVE_AIO; + } else if (!strcmp(aio, "threads")) { + /* this is the default */ + } else { + error_setg(errp, "invalid aio option"); + return; + } + } +#endif[snip] Fam
[Prev in Thread] | Current Thread | [Next in Thread] |