2 * QEMU Block driver for native access to files on NFS shares
4 * Copyright (c) 2014-2017 Peter Lieven <pl@kamp.de>
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #include "qemu/osdep.h"
30 #include "qemu/config-file.h"
31 #include "qemu/error-report.h"
32 #include "qapi/error.h"
33 #include "block/block-io.h"
34 #include "block/block_int.h"
35 #include "block/qdict.h"
38 #include "qemu/main-loop.h"
39 #include "qemu/module.h"
40 #include "qemu/option.h"
42 #include "qemu/cutils.h"
43 #include "sysemu/replay.h"
44 #include "qapi/qapi-visit-block-core.h"
45 #include "qapi/qmp/qdict.h"
46 #include "qapi/qmp/qstring.h"
47 #include "qapi/qobject-input-visitor.h"
48 #include "qapi/qobject-output-visitor.h"
49 #include <nfsc/libnfs.h>
52 #define QEMU_NFS_MAX_READAHEAD_SIZE 1048576
53 #define QEMU_NFS_MAX_PAGECACHE_SIZE (8388608 / NFS_BLKSIZE)
54 #define QEMU_NFS_MAX_DEBUG_LEVEL 2
56 typedef struct NFSClient
{
57 struct nfs_context
*context
;
61 AioContext
*aio_context
;
67 int64_t uid
, gid
, tcp_syncnt
, readahead
, pagecache
, debug
;
70 typedef struct NFSRPC
{
80 static int nfs_parse_uri(const char *filename
, QDict
*options
, Error
**errp
)
83 QueryParams
*qp
= NULL
;
86 uri
= uri_parse(filename
);
88 error_setg(errp
, "Invalid URI specified");
91 if (g_strcmp0(uri
->scheme
, "nfs") != 0) {
92 error_setg(errp
, "URI scheme must be 'nfs'");
97 error_setg(errp
, "missing hostname in URI");
102 error_setg(errp
, "missing file path in URI");
106 qp
= query_params_parse(uri
->query
);
108 error_setg(errp
, "could not parse query parameters");
112 qdict_put_str(options
, "server.host", uri
->server
);
113 qdict_put_str(options
, "server.type", "inet");
114 qdict_put_str(options
, "path", uri
->path
);
116 for (i
= 0; i
< qp
->n
; i
++) {
118 if (!qp
->p
[i
].value
) {
119 error_setg(errp
, "Value for NFS parameter expected: %s",
123 if (parse_uint_full(qp
->p
[i
].value
, 0, &val
)) {
124 error_setg(errp
, "Illegal value for NFS parameter: %s",
128 if (!strcmp(qp
->p
[i
].name
, "uid")) {
129 qdict_put_str(options
, "user", qp
->p
[i
].value
);
130 } else if (!strcmp(qp
->p
[i
].name
, "gid")) {
131 qdict_put_str(options
, "group", qp
->p
[i
].value
);
132 } else if (!strcmp(qp
->p
[i
].name
, "tcp-syncnt")) {
133 qdict_put_str(options
, "tcp-syn-count", qp
->p
[i
].value
);
134 } else if (!strcmp(qp
->p
[i
].name
, "readahead")) {
135 qdict_put_str(options
, "readahead-size", qp
->p
[i
].value
);
136 } else if (!strcmp(qp
->p
[i
].name
, "pagecache")) {
137 qdict_put_str(options
, "page-cache-size", qp
->p
[i
].value
);
138 } else if (!strcmp(qp
->p
[i
].name
, "debug")) {
139 qdict_put_str(options
, "debug", qp
->p
[i
].value
);
141 error_setg(errp
, "Unknown NFS parameter name: %s",
149 query_params_free(qp
);
155 static bool nfs_has_filename_options_conflict(QDict
*options
, Error
**errp
)
157 const QDictEntry
*qe
;
159 for (qe
= qdict_first(options
); qe
; qe
= qdict_next(options
, qe
)) {
160 if (!strcmp(qe
->key
, "host") ||
161 !strcmp(qe
->key
, "path") ||
162 !strcmp(qe
->key
, "user") ||
163 !strcmp(qe
->key
, "group") ||
164 !strcmp(qe
->key
, "tcp-syn-count") ||
165 !strcmp(qe
->key
, "readahead-size") ||
166 !strcmp(qe
->key
, "page-cache-size") ||
167 !strcmp(qe
->key
, "debug") ||
168 strstart(qe
->key
, "server.", NULL
))
170 error_setg(errp
, "Option %s cannot be used with a filename",
179 static void nfs_parse_filename(const char *filename
, QDict
*options
,
182 if (nfs_has_filename_options_conflict(options
, errp
)) {
186 nfs_parse_uri(filename
, options
, errp
);
189 static void nfs_process_read(void *arg
);
190 static void nfs_process_write(void *arg
);
192 /* Called with QemuMutex held. */
193 static void nfs_set_events(NFSClient
*client
)
195 int ev
= nfs_which_events(client
->context
);
196 if (ev
!= client
->events
) {
197 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
198 (ev
& POLLIN
) ? nfs_process_read
: NULL
,
199 (ev
& POLLOUT
) ? nfs_process_write
: NULL
,
206 static void nfs_process_read(void *arg
)
208 NFSClient
*client
= arg
;
210 qemu_mutex_lock(&client
->mutex
);
211 nfs_service(client
->context
, POLLIN
);
212 nfs_set_events(client
);
213 qemu_mutex_unlock(&client
->mutex
);
216 static void nfs_process_write(void *arg
)
218 NFSClient
*client
= arg
;
220 qemu_mutex_lock(&client
->mutex
);
221 nfs_service(client
->context
, POLLOUT
);
222 nfs_set_events(client
);
223 qemu_mutex_unlock(&client
->mutex
);
226 static void coroutine_fn
nfs_co_init_task(BlockDriverState
*bs
, NFSRPC
*task
)
229 .co
= qemu_coroutine_self(),
231 .client
= bs
->opaque
,
235 static void nfs_co_generic_bh_cb(void *opaque
)
237 NFSRPC
*task
= opaque
;
240 aio_co_wake(task
->co
);
243 /* Called (via nfs_service) with QemuMutex held. */
245 nfs_co_generic_cb(int ret
, struct nfs_context
*nfs
, void *data
,
248 NFSRPC
*task
= private_data
;
251 if (task
->ret
> 0 && task
->iov
) {
252 if (task
->ret
<= task
->iov
->size
) {
253 qemu_iovec_from_buf(task
->iov
, 0, data
, task
->ret
);
259 error_report("NFS Error: %s", nfs_get_error(nfs
));
261 replay_bh_schedule_oneshot_event(task
->client
->aio_context
,
262 nfs_co_generic_bh_cb
, task
);
265 static int coroutine_fn
nfs_co_preadv(BlockDriverState
*bs
, int64_t offset
,
266 int64_t bytes
, QEMUIOVector
*iov
,
267 BdrvRequestFlags flags
)
269 NFSClient
*client
= bs
->opaque
;
272 nfs_co_init_task(bs
, &task
);
275 WITH_QEMU_LOCK_GUARD(&client
->mutex
) {
276 if (nfs_pread_async(client
->context
, client
->fh
,
277 offset
, bytes
, nfs_co_generic_cb
, &task
) != 0) {
281 nfs_set_events(client
);
283 while (!task
.complete
) {
284 qemu_coroutine_yield();
291 /* zero pad short reads */
292 if (task
.ret
< iov
->size
) {
293 qemu_iovec_memset(iov
, task
.ret
, 0, iov
->size
- task
.ret
);
299 static int coroutine_fn
nfs_co_pwritev(BlockDriverState
*bs
, int64_t offset
,
300 int64_t bytes
, QEMUIOVector
*iov
,
301 BdrvRequestFlags flags
)
303 NFSClient
*client
= bs
->opaque
;
306 bool my_buffer
= false;
308 nfs_co_init_task(bs
, &task
);
310 if (iov
->niov
!= 1) {
311 buf
= g_try_malloc(bytes
);
312 if (bytes
&& buf
== NULL
) {
315 qemu_iovec_to_buf(iov
, 0, buf
, bytes
);
318 buf
= iov
->iov
[0].iov_base
;
321 WITH_QEMU_LOCK_GUARD(&client
->mutex
) {
322 if (nfs_pwrite_async(client
->context
, client
->fh
,
324 nfs_co_generic_cb
, &task
) != 0) {
331 nfs_set_events(client
);
333 while (!task
.complete
) {
334 qemu_coroutine_yield();
341 if (task
.ret
!= bytes
) {
342 return task
.ret
< 0 ? task
.ret
: -EIO
;
348 static int coroutine_fn
nfs_co_flush(BlockDriverState
*bs
)
350 NFSClient
*client
= bs
->opaque
;
353 nfs_co_init_task(bs
, &task
);
355 WITH_QEMU_LOCK_GUARD(&client
->mutex
) {
356 if (nfs_fsync_async(client
->context
, client
->fh
, nfs_co_generic_cb
,
361 nfs_set_events(client
);
363 while (!task
.complete
) {
364 qemu_coroutine_yield();
370 static void nfs_detach_aio_context(BlockDriverState
*bs
)
372 NFSClient
*client
= bs
->opaque
;
374 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
375 NULL
, NULL
, NULL
, NULL
, NULL
);
379 static void nfs_attach_aio_context(BlockDriverState
*bs
,
380 AioContext
*new_context
)
382 NFSClient
*client
= bs
->opaque
;
384 client
->aio_context
= new_context
;
385 nfs_set_events(client
);
388 static void nfs_client_close(NFSClient
*client
)
390 if (client
->context
) {
391 qemu_mutex_lock(&client
->mutex
);
392 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
393 NULL
, NULL
, NULL
, NULL
, NULL
);
394 qemu_mutex_unlock(&client
->mutex
);
396 nfs_close(client
->context
, client
->fh
);
399 #ifdef LIBNFS_FEATURE_UMOUNT
400 nfs_umount(client
->context
);
402 nfs_destroy_context(client
->context
);
403 client
->context
= NULL
;
405 g_free(client
->path
);
406 qemu_mutex_destroy(&client
->mutex
);
407 qapi_free_NFSServer(client
->server
);
408 client
->server
= NULL
;
411 static void nfs_file_close(BlockDriverState
*bs
)
413 NFSClient
*client
= bs
->opaque
;
414 nfs_client_close(client
);
417 static int64_t nfs_client_open(NFSClient
*client
, BlockdevOptionsNfs
*opts
,
418 int flags
, int open_flags
, Error
**errp
)
420 int64_t ret
= -EINVAL
;
426 char *file
= NULL
, *strp
= NULL
;
428 qemu_mutex_init(&client
->mutex
);
430 client
->path
= g_strdup(opts
->path
);
432 strp
= strrchr(client
->path
, '/');
434 error_setg(errp
, "Invalid URL specified");
437 file
= g_strdup(strp
);
440 /* Steal the NFSServer object from opts; set the original pointer to NULL
441 * to avoid use after free and double free. */
442 client
->server
= opts
->server
;
445 client
->context
= nfs_init_context();
446 if (client
->context
== NULL
) {
447 error_setg(errp
, "Failed to init NFS context");
451 if (opts
->has_user
) {
452 client
->uid
= opts
->user
;
453 nfs_set_uid(client
->context
, client
->uid
);
456 if (opts
->has_group
) {
457 client
->gid
= opts
->group
;
458 nfs_set_gid(client
->context
, client
->gid
);
461 if (opts
->has_tcp_syn_count
) {
462 client
->tcp_syncnt
= opts
->tcp_syn_count
;
463 nfs_set_tcp_syncnt(client
->context
, client
->tcp_syncnt
);
466 #ifdef LIBNFS_FEATURE_READAHEAD
467 if (opts
->has_readahead_size
) {
468 if (open_flags
& BDRV_O_NOCACHE
) {
469 error_setg(errp
, "Cannot enable NFS readahead "
470 "if cache.direct = on");
473 client
->readahead
= opts
->readahead_size
;
474 if (client
->readahead
> QEMU_NFS_MAX_READAHEAD_SIZE
) {
475 warn_report("Truncating NFS readahead size to %d",
476 QEMU_NFS_MAX_READAHEAD_SIZE
);
477 client
->readahead
= QEMU_NFS_MAX_READAHEAD_SIZE
;
479 nfs_set_readahead(client
->context
, client
->readahead
);
480 #ifdef LIBNFS_FEATURE_PAGECACHE
481 nfs_set_pagecache_ttl(client
->context
, 0);
483 client
->cache_used
= true;
487 #ifdef LIBNFS_FEATURE_PAGECACHE
488 if (opts
->has_page_cache_size
) {
489 if (open_flags
& BDRV_O_NOCACHE
) {
490 error_setg(errp
, "Cannot enable NFS pagecache "
491 "if cache.direct = on");
494 client
->pagecache
= opts
->page_cache_size
;
495 if (client
->pagecache
> QEMU_NFS_MAX_PAGECACHE_SIZE
) {
496 warn_report("Truncating NFS pagecache size to %d pages",
497 QEMU_NFS_MAX_PAGECACHE_SIZE
);
498 client
->pagecache
= QEMU_NFS_MAX_PAGECACHE_SIZE
;
500 nfs_set_pagecache(client
->context
, client
->pagecache
);
501 nfs_set_pagecache_ttl(client
->context
, 0);
502 client
->cache_used
= true;
506 #ifdef LIBNFS_FEATURE_DEBUG
507 if (opts
->has_debug
) {
508 client
->debug
= opts
->debug
;
509 /* limit the maximum debug level to avoid potential flooding
510 * of our log files. */
511 if (client
->debug
> QEMU_NFS_MAX_DEBUG_LEVEL
) {
512 warn_report("Limiting NFS debug level to %d",
513 QEMU_NFS_MAX_DEBUG_LEVEL
);
514 client
->debug
= QEMU_NFS_MAX_DEBUG_LEVEL
;
516 nfs_set_debug(client
->context
, client
->debug
);
520 ret
= nfs_mount(client
->context
, client
->server
->host
, client
->path
);
522 error_setg(errp
, "Failed to mount nfs share: %s",
523 nfs_get_error(client
->context
));
527 if (flags
& O_CREAT
) {
528 ret
= nfs_creat(client
->context
, file
, 0600, &client
->fh
);
530 error_setg(errp
, "Failed to create file: %s",
531 nfs_get_error(client
->context
));
535 ret
= nfs_open(client
->context
, file
, flags
, &client
->fh
);
537 error_setg(errp
, "Failed to open file : %s",
538 nfs_get_error(client
->context
));
543 ret
= nfs_fstat(client
->context
, client
->fh
, &st
);
545 error_setg(errp
, "Failed to fstat file: %s",
546 nfs_get_error(client
->context
));
550 ret
= DIV_ROUND_UP(st
.st_size
, BDRV_SECTOR_SIZE
);
552 client
->st_blocks
= st
.st_blocks
;
554 client
->has_zero_init
= S_ISREG(st
.st_mode
);
559 nfs_client_close(client
);
565 static BlockdevOptionsNfs
*nfs_options_qdict_to_qapi(QDict
*options
,
568 BlockdevOptionsNfs
*opts
= NULL
;
572 v
= qobject_input_visitor_new_flat_confused(options
, errp
);
577 visit_type_BlockdevOptionsNfs(v
, NULL
, &opts
, errp
);
583 /* Remove the processed options from the QDict (the visitor processes
584 * _all_ options in the QDict) */
585 while ((e
= qdict_first(options
))) {
586 qdict_del(options
, e
->key
);
592 static int64_t nfs_client_open_qdict(NFSClient
*client
, QDict
*options
,
593 int flags
, int open_flags
, Error
**errp
)
595 BlockdevOptionsNfs
*opts
;
598 opts
= nfs_options_qdict_to_qapi(options
, errp
);
604 ret
= nfs_client_open(client
, opts
, flags
, open_flags
, errp
);
606 qapi_free_BlockdevOptionsNfs(opts
);
610 static int nfs_file_open(BlockDriverState
*bs
, QDict
*options
, int flags
,
612 NFSClient
*client
= bs
->opaque
;
615 client
->aio_context
= bdrv_get_aio_context(bs
);
617 ret
= nfs_client_open_qdict(client
, options
,
618 (flags
& BDRV_O_RDWR
) ? O_RDWR
: O_RDONLY
,
619 bs
->open_flags
, errp
);
624 bs
->total_sectors
= ret
;
625 if (client
->has_zero_init
) {
626 bs
->supported_truncate_flags
= BDRV_REQ_ZERO_WRITE
;
631 static QemuOptsList nfs_create_opts
= {
632 .name
= "nfs-create-opts",
633 .head
= QTAILQ_HEAD_INITIALIZER(nfs_create_opts
.head
),
636 .name
= BLOCK_OPT_SIZE
,
637 .type
= QEMU_OPT_SIZE
,
638 .help
= "Virtual disk size"
640 { /* end of list */ }
644 static int nfs_file_co_create(BlockdevCreateOptions
*options
, Error
**errp
)
646 BlockdevCreateOptionsNfs
*opts
= &options
->u
.nfs
;
647 NFSClient
*client
= g_new0(NFSClient
, 1);
650 assert(options
->driver
== BLOCKDEV_DRIVER_NFS
);
652 client
->aio_context
= qemu_get_aio_context();
654 ret
= nfs_client_open(client
, opts
->location
, O_CREAT
, 0, errp
);
658 ret
= nfs_ftruncate(client
->context
, client
->fh
, opts
->size
);
659 nfs_client_close(client
);
666 static int coroutine_fn
nfs_file_co_create_opts(BlockDriver
*drv
,
671 BlockdevCreateOptions
*create_options
;
672 BlockdevCreateOptionsNfs
*nfs_opts
;
676 create_options
= g_new0(BlockdevCreateOptions
, 1);
677 create_options
->driver
= BLOCKDEV_DRIVER_NFS
;
678 nfs_opts
= &create_options
->u
.nfs
;
680 /* Read out options */
681 nfs_opts
->size
= ROUND_UP(qemu_opt_get_size_del(opts
, BLOCK_OPT_SIZE
, 0),
684 options
= qdict_new();
685 ret
= nfs_parse_uri(url
, options
, errp
);
690 nfs_opts
->location
= nfs_options_qdict_to_qapi(options
, errp
);
691 if (nfs_opts
->location
== NULL
) {
696 ret
= nfs_file_co_create(create_options
, errp
);
703 qobject_unref(options
);
704 qapi_free_BlockdevCreateOptions(create_options
);
708 static int nfs_has_zero_init(BlockDriverState
*bs
)
710 NFSClient
*client
= bs
->opaque
;
711 return client
->has_zero_init
;
715 /* Called (via nfs_service) with QemuMutex held. */
717 nfs_get_allocated_file_size_cb(int ret
, struct nfs_context
*nfs
, void *data
,
720 NFSRPC
*task
= private_data
;
722 if (task
->ret
== 0) {
723 memcpy(task
->st
, data
, sizeof(struct stat
));
726 error_report("NFS Error: %s", nfs_get_error(nfs
));
728 replay_bh_schedule_oneshot_event(task
->client
->aio_context
,
729 nfs_co_generic_bh_cb
, task
);
732 static int64_t coroutine_fn
nfs_co_get_allocated_file_size(BlockDriverState
*bs
)
734 NFSClient
*client
= bs
->opaque
;
738 if (bdrv_is_read_only(bs
) &&
739 !(bs
->open_flags
& BDRV_O_NOCACHE
)) {
740 return client
->st_blocks
* 512;
743 nfs_co_init_task(bs
, &task
);
745 WITH_QEMU_LOCK_GUARD(&client
->mutex
) {
746 if (nfs_fstat_async(client
->context
, client
->fh
, nfs_get_allocated_file_size_cb
,
751 nfs_set_events(client
);
753 while (!task
.complete
) {
754 qemu_coroutine_yield();
757 return (task
.ret
< 0 ? task
.ret
: st
.st_blocks
* 512);
761 static int coroutine_fn
762 nfs_file_co_truncate(BlockDriverState
*bs
, int64_t offset
, bool exact
,
763 PreallocMode prealloc
, BdrvRequestFlags flags
,
766 NFSClient
*client
= bs
->opaque
;
769 if (prealloc
!= PREALLOC_MODE_OFF
) {
770 error_setg(errp
, "Unsupported preallocation mode '%s'",
771 PreallocMode_str(prealloc
));
775 ret
= nfs_ftruncate(client
->context
, client
->fh
, offset
);
777 error_setg_errno(errp
, -ret
, "Failed to truncate file");
784 /* Note that this will not re-establish a connection with the NFS server
785 * - it is effectively a NOP. */
786 static int nfs_reopen_prepare(BDRVReopenState
*state
,
787 BlockReopenQueue
*queue
, Error
**errp
)
789 NFSClient
*client
= state
->bs
->opaque
;
797 if (state
->flags
& BDRV_O_RDWR
&& bdrv_is_read_only(state
->bs
)) {
798 error_setg(errp
, "Cannot open a read-only mount as read-write");
802 if ((state
->flags
& BDRV_O_NOCACHE
) && client
->cache_used
) {
803 error_setg(errp
, "Cannot disable cache if libnfs readahead or"
804 " pagecache is enabled");
808 /* Update cache for read-only reopens */
809 if (!(state
->flags
& BDRV_O_RDWR
)) {
810 ret
= nfs_fstat(client
->context
, client
->fh
, &st
);
812 error_setg(errp
, "Failed to fstat file: %s",
813 nfs_get_error(client
->context
));
817 client
->st_blocks
= st
.st_blocks
;
824 static void nfs_refresh_filename(BlockDriverState
*bs
)
826 NFSClient
*client
= bs
->opaque
;
828 if (client
->uid
&& !client
->gid
) {
829 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
830 "nfs://%s%s?uid=%" PRId64
, client
->server
->host
, client
->path
,
832 } else if (!client
->uid
&& client
->gid
) {
833 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
834 "nfs://%s%s?gid=%" PRId64
, client
->server
->host
, client
->path
,
836 } else if (client
->uid
&& client
->gid
) {
837 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
838 "nfs://%s%s?uid=%" PRId64
"&gid=%" PRId64
,
839 client
->server
->host
, client
->path
, client
->uid
, client
->gid
);
841 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
842 "nfs://%s%s", client
->server
->host
, client
->path
);
846 static char *nfs_dirname(BlockDriverState
*bs
, Error
**errp
)
848 NFSClient
*client
= bs
->opaque
;
850 if (client
->uid
|| client
->gid
) {
851 bdrv_refresh_filename(bs
);
852 error_setg(errp
, "Cannot generate a base directory for NFS node '%s'",
857 return g_strdup_printf("nfs://%s%s/", client
->server
->host
, client
->path
);
860 #ifdef LIBNFS_FEATURE_PAGECACHE
861 static void coroutine_fn
nfs_co_invalidate_cache(BlockDriverState
*bs
,
864 NFSClient
*client
= bs
->opaque
;
865 nfs_pagecache_invalidate(client
->context
, client
->fh
);
869 static const char *nfs_strong_runtime_opts
[] = {
878 static BlockDriver bdrv_nfs
= {
879 .format_name
= "nfs",
880 .protocol_name
= "nfs",
882 .instance_size
= sizeof(NFSClient
),
883 .bdrv_parse_filename
= nfs_parse_filename
,
884 .create_opts
= &nfs_create_opts
,
886 .bdrv_has_zero_init
= nfs_has_zero_init
,
887 /* libnfs does not provide the allocated filesize of a file on win32. */
889 .bdrv_co_get_allocated_file_size
= nfs_co_get_allocated_file_size
,
891 .bdrv_co_truncate
= nfs_file_co_truncate
,
893 .bdrv_file_open
= nfs_file_open
,
894 .bdrv_close
= nfs_file_close
,
895 .bdrv_co_create
= nfs_file_co_create
,
896 .bdrv_co_create_opts
= nfs_file_co_create_opts
,
897 .bdrv_reopen_prepare
= nfs_reopen_prepare
,
899 .bdrv_co_preadv
= nfs_co_preadv
,
900 .bdrv_co_pwritev
= nfs_co_pwritev
,
901 .bdrv_co_flush_to_disk
= nfs_co_flush
,
903 .bdrv_detach_aio_context
= nfs_detach_aio_context
,
904 .bdrv_attach_aio_context
= nfs_attach_aio_context
,
905 .bdrv_refresh_filename
= nfs_refresh_filename
,
906 .bdrv_dirname
= nfs_dirname
,
908 .strong_runtime_opts
= nfs_strong_runtime_opts
,
910 #ifdef LIBNFS_FEATURE_PAGECACHE
911 .bdrv_co_invalidate_cache
= nfs_co_invalidate_cache
,
915 static void nfs_block_init(void)
917 bdrv_register(&bdrv_nfs
);
920 block_init(nfs_block_init
);