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
++) {
117 unsigned long long val
;
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
, &val
, 0)) {
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
),
199 (ev
& POLLIN
) ? nfs_process_read
: NULL
,
200 (ev
& POLLOUT
) ? nfs_process_write
: NULL
,
207 static void nfs_process_read(void *arg
)
209 NFSClient
*client
= arg
;
211 qemu_mutex_lock(&client
->mutex
);
212 nfs_service(client
->context
, POLLIN
);
213 nfs_set_events(client
);
214 qemu_mutex_unlock(&client
->mutex
);
217 static void nfs_process_write(void *arg
)
219 NFSClient
*client
= arg
;
221 qemu_mutex_lock(&client
->mutex
);
222 nfs_service(client
->context
, POLLOUT
);
223 nfs_set_events(client
);
224 qemu_mutex_unlock(&client
->mutex
);
227 static void coroutine_fn
nfs_co_init_task(BlockDriverState
*bs
, NFSRPC
*task
)
230 .co
= qemu_coroutine_self(),
232 .client
= bs
->opaque
,
236 static void nfs_co_generic_bh_cb(void *opaque
)
238 NFSRPC
*task
= opaque
;
241 aio_co_wake(task
->co
);
244 /* Called (via nfs_service) with QemuMutex held. */
246 nfs_co_generic_cb(int ret
, struct nfs_context
*nfs
, void *data
,
249 NFSRPC
*task
= private_data
;
252 if (task
->ret
> 0 && task
->iov
) {
253 if (task
->ret
<= task
->iov
->size
) {
254 qemu_iovec_from_buf(task
->iov
, 0, data
, task
->ret
);
260 error_report("NFS Error: %s", nfs_get_error(nfs
));
262 replay_bh_schedule_oneshot_event(task
->client
->aio_context
,
263 nfs_co_generic_bh_cb
, task
);
266 static int coroutine_fn
nfs_co_preadv(BlockDriverState
*bs
, int64_t offset
,
267 int64_t bytes
, QEMUIOVector
*iov
,
268 BdrvRequestFlags flags
)
270 NFSClient
*client
= bs
->opaque
;
273 nfs_co_init_task(bs
, &task
);
276 WITH_QEMU_LOCK_GUARD(&client
->mutex
) {
277 if (nfs_pread_async(client
->context
, client
->fh
,
278 offset
, bytes
, nfs_co_generic_cb
, &task
) != 0) {
282 nfs_set_events(client
);
284 while (!task
.complete
) {
285 qemu_coroutine_yield();
292 /* zero pad short reads */
293 if (task
.ret
< iov
->size
) {
294 qemu_iovec_memset(iov
, task
.ret
, 0, iov
->size
- task
.ret
);
300 static int coroutine_fn
nfs_co_pwritev(BlockDriverState
*bs
, int64_t offset
,
301 int64_t bytes
, QEMUIOVector
*iov
,
302 BdrvRequestFlags flags
)
304 NFSClient
*client
= bs
->opaque
;
307 bool my_buffer
= false;
309 nfs_co_init_task(bs
, &task
);
311 if (iov
->niov
!= 1) {
312 buf
= g_try_malloc(bytes
);
313 if (bytes
&& buf
== NULL
) {
316 qemu_iovec_to_buf(iov
, 0, buf
, bytes
);
319 buf
= iov
->iov
[0].iov_base
;
322 WITH_QEMU_LOCK_GUARD(&client
->mutex
) {
323 if (nfs_pwrite_async(client
->context
, client
->fh
,
325 nfs_co_generic_cb
, &task
) != 0) {
332 nfs_set_events(client
);
334 while (!task
.complete
) {
335 qemu_coroutine_yield();
342 if (task
.ret
!= bytes
) {
343 return task
.ret
< 0 ? task
.ret
: -EIO
;
349 static int coroutine_fn
nfs_co_flush(BlockDriverState
*bs
)
351 NFSClient
*client
= bs
->opaque
;
354 nfs_co_init_task(bs
, &task
);
356 WITH_QEMU_LOCK_GUARD(&client
->mutex
) {
357 if (nfs_fsync_async(client
->context
, client
->fh
, nfs_co_generic_cb
,
362 nfs_set_events(client
);
364 while (!task
.complete
) {
365 qemu_coroutine_yield();
371 static void nfs_detach_aio_context(BlockDriverState
*bs
)
373 NFSClient
*client
= bs
->opaque
;
375 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
376 false, NULL
, NULL
, NULL
, NULL
, NULL
);
380 static void nfs_attach_aio_context(BlockDriverState
*bs
,
381 AioContext
*new_context
)
383 NFSClient
*client
= bs
->opaque
;
385 client
->aio_context
= new_context
;
386 nfs_set_events(client
);
389 static void nfs_client_close(NFSClient
*client
)
391 if (client
->context
) {
392 qemu_mutex_lock(&client
->mutex
);
393 aio_set_fd_handler(client
->aio_context
, nfs_get_fd(client
->context
),
394 false, NULL
, NULL
, NULL
, NULL
, NULL
);
395 qemu_mutex_unlock(&client
->mutex
);
397 nfs_close(client
->context
, client
->fh
);
400 #ifdef LIBNFS_FEATURE_UMOUNT
401 nfs_umount(client
->context
);
403 nfs_destroy_context(client
->context
);
404 client
->context
= NULL
;
406 g_free(client
->path
);
407 qemu_mutex_destroy(&client
->mutex
);
408 qapi_free_NFSServer(client
->server
);
409 client
->server
= NULL
;
412 static void nfs_file_close(BlockDriverState
*bs
)
414 NFSClient
*client
= bs
->opaque
;
415 nfs_client_close(client
);
418 static int64_t nfs_client_open(NFSClient
*client
, BlockdevOptionsNfs
*opts
,
419 int flags
, int open_flags
, Error
**errp
)
421 int64_t ret
= -EINVAL
;
427 char *file
= NULL
, *strp
= NULL
;
429 qemu_mutex_init(&client
->mutex
);
431 client
->path
= g_strdup(opts
->path
);
433 strp
= strrchr(client
->path
, '/');
435 error_setg(errp
, "Invalid URL specified");
438 file
= g_strdup(strp
);
441 /* Steal the NFSServer object from opts; set the original pointer to NULL
442 * to avoid use after free and double free. */
443 client
->server
= opts
->server
;
446 client
->context
= nfs_init_context();
447 if (client
->context
== NULL
) {
448 error_setg(errp
, "Failed to init NFS context");
452 if (opts
->has_user
) {
453 client
->uid
= opts
->user
;
454 nfs_set_uid(client
->context
, client
->uid
);
457 if (opts
->has_group
) {
458 client
->gid
= opts
->group
;
459 nfs_set_gid(client
->context
, client
->gid
);
462 if (opts
->has_tcp_syn_count
) {
463 client
->tcp_syncnt
= opts
->tcp_syn_count
;
464 nfs_set_tcp_syncnt(client
->context
, client
->tcp_syncnt
);
467 #ifdef LIBNFS_FEATURE_READAHEAD
468 if (opts
->has_readahead_size
) {
469 if (open_flags
& BDRV_O_NOCACHE
) {
470 error_setg(errp
, "Cannot enable NFS readahead "
471 "if cache.direct = on");
474 client
->readahead
= opts
->readahead_size
;
475 if (client
->readahead
> QEMU_NFS_MAX_READAHEAD_SIZE
) {
476 warn_report("Truncating NFS readahead size to %d",
477 QEMU_NFS_MAX_READAHEAD_SIZE
);
478 client
->readahead
= QEMU_NFS_MAX_READAHEAD_SIZE
;
480 nfs_set_readahead(client
->context
, client
->readahead
);
481 #ifdef LIBNFS_FEATURE_PAGECACHE
482 nfs_set_pagecache_ttl(client
->context
, 0);
484 client
->cache_used
= true;
488 #ifdef LIBNFS_FEATURE_PAGECACHE
489 if (opts
->has_page_cache_size
) {
490 if (open_flags
& BDRV_O_NOCACHE
) {
491 error_setg(errp
, "Cannot enable NFS pagecache "
492 "if cache.direct = on");
495 client
->pagecache
= opts
->page_cache_size
;
496 if (client
->pagecache
> QEMU_NFS_MAX_PAGECACHE_SIZE
) {
497 warn_report("Truncating NFS pagecache size to %d pages",
498 QEMU_NFS_MAX_PAGECACHE_SIZE
);
499 client
->pagecache
= QEMU_NFS_MAX_PAGECACHE_SIZE
;
501 nfs_set_pagecache(client
->context
, client
->pagecache
);
502 nfs_set_pagecache_ttl(client
->context
, 0);
503 client
->cache_used
= true;
507 #ifdef LIBNFS_FEATURE_DEBUG
508 if (opts
->has_debug
) {
509 client
->debug
= opts
->debug
;
510 /* limit the maximum debug level to avoid potential flooding
511 * of our log files. */
512 if (client
->debug
> QEMU_NFS_MAX_DEBUG_LEVEL
) {
513 warn_report("Limiting NFS debug level to %d",
514 QEMU_NFS_MAX_DEBUG_LEVEL
);
515 client
->debug
= QEMU_NFS_MAX_DEBUG_LEVEL
;
517 nfs_set_debug(client
->context
, client
->debug
);
521 ret
= nfs_mount(client
->context
, client
->server
->host
, client
->path
);
523 error_setg(errp
, "Failed to mount nfs share: %s",
524 nfs_get_error(client
->context
));
528 if (flags
& O_CREAT
) {
529 ret
= nfs_creat(client
->context
, file
, 0600, &client
->fh
);
531 error_setg(errp
, "Failed to create file: %s",
532 nfs_get_error(client
->context
));
536 ret
= nfs_open(client
->context
, file
, flags
, &client
->fh
);
538 error_setg(errp
, "Failed to open file : %s",
539 nfs_get_error(client
->context
));
544 ret
= nfs_fstat(client
->context
, client
->fh
, &st
);
546 error_setg(errp
, "Failed to fstat file: %s",
547 nfs_get_error(client
->context
));
551 ret
= DIV_ROUND_UP(st
.st_size
, BDRV_SECTOR_SIZE
);
553 client
->st_blocks
= st
.st_blocks
;
555 client
->has_zero_init
= S_ISREG(st
.st_mode
);
560 nfs_client_close(client
);
566 static BlockdevOptionsNfs
*nfs_options_qdict_to_qapi(QDict
*options
,
569 BlockdevOptionsNfs
*opts
= NULL
;
573 v
= qobject_input_visitor_new_flat_confused(options
, errp
);
578 visit_type_BlockdevOptionsNfs(v
, NULL
, &opts
, errp
);
584 /* Remove the processed options from the QDict (the visitor processes
585 * _all_ options in the QDict) */
586 while ((e
= qdict_first(options
))) {
587 qdict_del(options
, e
->key
);
593 static int64_t nfs_client_open_qdict(NFSClient
*client
, QDict
*options
,
594 int flags
, int open_flags
, Error
**errp
)
596 BlockdevOptionsNfs
*opts
;
599 opts
= nfs_options_qdict_to_qapi(options
, errp
);
605 ret
= nfs_client_open(client
, opts
, flags
, open_flags
, errp
);
607 qapi_free_BlockdevOptionsNfs(opts
);
611 static int nfs_file_open(BlockDriverState
*bs
, QDict
*options
, int flags
,
613 NFSClient
*client
= bs
->opaque
;
616 client
->aio_context
= bdrv_get_aio_context(bs
);
618 ret
= nfs_client_open_qdict(client
, options
,
619 (flags
& BDRV_O_RDWR
) ? O_RDWR
: O_RDONLY
,
620 bs
->open_flags
, errp
);
625 bs
->total_sectors
= ret
;
626 if (client
->has_zero_init
) {
627 bs
->supported_truncate_flags
= BDRV_REQ_ZERO_WRITE
;
632 static QemuOptsList nfs_create_opts
= {
633 .name
= "nfs-create-opts",
634 .head
= QTAILQ_HEAD_INITIALIZER(nfs_create_opts
.head
),
637 .name
= BLOCK_OPT_SIZE
,
638 .type
= QEMU_OPT_SIZE
,
639 .help
= "Virtual disk size"
641 { /* end of list */ }
645 static int nfs_file_co_create(BlockdevCreateOptions
*options
, Error
**errp
)
647 BlockdevCreateOptionsNfs
*opts
= &options
->u
.nfs
;
648 NFSClient
*client
= g_new0(NFSClient
, 1);
651 assert(options
->driver
== BLOCKDEV_DRIVER_NFS
);
653 client
->aio_context
= qemu_get_aio_context();
655 ret
= nfs_client_open(client
, opts
->location
, O_CREAT
, 0, errp
);
659 ret
= nfs_ftruncate(client
->context
, client
->fh
, opts
->size
);
660 nfs_client_close(client
);
667 static int coroutine_fn
nfs_file_co_create_opts(BlockDriver
*drv
,
672 BlockdevCreateOptions
*create_options
;
673 BlockdevCreateOptionsNfs
*nfs_opts
;
677 create_options
= g_new0(BlockdevCreateOptions
, 1);
678 create_options
->driver
= BLOCKDEV_DRIVER_NFS
;
679 nfs_opts
= &create_options
->u
.nfs
;
681 /* Read out options */
682 nfs_opts
->size
= ROUND_UP(qemu_opt_get_size_del(opts
, BLOCK_OPT_SIZE
, 0),
685 options
= qdict_new();
686 ret
= nfs_parse_uri(url
, options
, errp
);
691 nfs_opts
->location
= nfs_options_qdict_to_qapi(options
, errp
);
692 if (nfs_opts
->location
== NULL
) {
697 ret
= nfs_file_co_create(create_options
, errp
);
704 qobject_unref(options
);
705 qapi_free_BlockdevCreateOptions(create_options
);
709 static int nfs_has_zero_init(BlockDriverState
*bs
)
711 NFSClient
*client
= bs
->opaque
;
712 return client
->has_zero_init
;
716 /* Called (via nfs_service) with QemuMutex held. */
718 nfs_get_allocated_file_size_cb(int ret
, struct nfs_context
*nfs
, void *data
,
721 NFSRPC
*task
= private_data
;
723 if (task
->ret
== 0) {
724 memcpy(task
->st
, data
, sizeof(struct stat
));
727 error_report("NFS Error: %s", nfs_get_error(nfs
));
730 /* Set task->complete before reading bs->wakeup. */
731 qatomic_mb_set(&task
->complete
, 1);
732 bdrv_wakeup(task
->bs
);
735 static int64_t coroutine_fn
nfs_co_get_allocated_file_size(BlockDriverState
*bs
)
737 NFSClient
*client
= bs
->opaque
;
741 if (bdrv_is_read_only(bs
) &&
742 !(bs
->open_flags
& BDRV_O_NOCACHE
)) {
743 return client
->st_blocks
* 512;
748 if (nfs_fstat_async(client
->context
, client
->fh
, nfs_get_allocated_file_size_cb
,
753 nfs_set_events(client
);
754 BDRV_POLL_WHILE(bs
, !task
.complete
);
756 return (task
.ret
< 0 ? task
.ret
: st
.st_blocks
* 512);
760 static int coroutine_fn
761 nfs_file_co_truncate(BlockDriverState
*bs
, int64_t offset
, bool exact
,
762 PreallocMode prealloc
, BdrvRequestFlags flags
,
765 NFSClient
*client
= bs
->opaque
;
768 if (prealloc
!= PREALLOC_MODE_OFF
) {
769 error_setg(errp
, "Unsupported preallocation mode '%s'",
770 PreallocMode_str(prealloc
));
774 ret
= nfs_ftruncate(client
->context
, client
->fh
, offset
);
776 error_setg_errno(errp
, -ret
, "Failed to truncate file");
783 /* Note that this will not re-establish a connection with the NFS server
784 * - it is effectively a NOP. */
785 static int nfs_reopen_prepare(BDRVReopenState
*state
,
786 BlockReopenQueue
*queue
, Error
**errp
)
788 NFSClient
*client
= state
->bs
->opaque
;
796 if (state
->flags
& BDRV_O_RDWR
&& bdrv_is_read_only(state
->bs
)) {
797 error_setg(errp
, "Cannot open a read-only mount as read-write");
801 if ((state
->flags
& BDRV_O_NOCACHE
) && client
->cache_used
) {
802 error_setg(errp
, "Cannot disable cache if libnfs readahead or"
803 " pagecache is enabled");
807 /* Update cache for read-only reopens */
808 if (!(state
->flags
& BDRV_O_RDWR
)) {
809 ret
= nfs_fstat(client
->context
, client
->fh
, &st
);
811 error_setg(errp
, "Failed to fstat file: %s",
812 nfs_get_error(client
->context
));
816 client
->st_blocks
= st
.st_blocks
;
823 static void nfs_refresh_filename(BlockDriverState
*bs
)
825 NFSClient
*client
= bs
->opaque
;
827 if (client
->uid
&& !client
->gid
) {
828 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
829 "nfs://%s%s?uid=%" PRId64
, client
->server
->host
, client
->path
,
831 } else if (!client
->uid
&& client
->gid
) {
832 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
833 "nfs://%s%s?gid=%" PRId64
, client
->server
->host
, client
->path
,
835 } else if (client
->uid
&& client
->gid
) {
836 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
837 "nfs://%s%s?uid=%" PRId64
"&gid=%" PRId64
,
838 client
->server
->host
, client
->path
, client
->uid
, client
->gid
);
840 snprintf(bs
->exact_filename
, sizeof(bs
->exact_filename
),
841 "nfs://%s%s", client
->server
->host
, client
->path
);
845 static char *nfs_dirname(BlockDriverState
*bs
, Error
**errp
)
847 NFSClient
*client
= bs
->opaque
;
849 if (client
->uid
|| client
->gid
) {
850 bdrv_refresh_filename(bs
);
851 error_setg(errp
, "Cannot generate a base directory for NFS node '%s'",
856 return g_strdup_printf("nfs://%s%s/", client
->server
->host
, client
->path
);
859 #ifdef LIBNFS_FEATURE_PAGECACHE
860 static void coroutine_fn
nfs_co_invalidate_cache(BlockDriverState
*bs
,
863 NFSClient
*client
= bs
->opaque
;
864 nfs_pagecache_invalidate(client
->context
, client
->fh
);
868 static const char *nfs_strong_runtime_opts
[] = {
877 static BlockDriver bdrv_nfs
= {
878 .format_name
= "nfs",
879 .protocol_name
= "nfs",
881 .instance_size
= sizeof(NFSClient
),
882 .bdrv_parse_filename
= nfs_parse_filename
,
883 .create_opts
= &nfs_create_opts
,
885 .bdrv_has_zero_init
= nfs_has_zero_init
,
886 /* libnfs does not provide the allocated filesize of a file on win32. */
888 .bdrv_co_get_allocated_file_size
= nfs_co_get_allocated_file_size
,
890 .bdrv_co_truncate
= nfs_file_co_truncate
,
892 .bdrv_file_open
= nfs_file_open
,
893 .bdrv_close
= nfs_file_close
,
894 .bdrv_co_create
= nfs_file_co_create
,
895 .bdrv_co_create_opts
= nfs_file_co_create_opts
,
896 .bdrv_reopen_prepare
= nfs_reopen_prepare
,
898 .bdrv_co_preadv
= nfs_co_preadv
,
899 .bdrv_co_pwritev
= nfs_co_pwritev
,
900 .bdrv_co_flush_to_disk
= nfs_co_flush
,
902 .bdrv_detach_aio_context
= nfs_detach_aio_context
,
903 .bdrv_attach_aio_context
= nfs_attach_aio_context
,
904 .bdrv_refresh_filename
= nfs_refresh_filename
,
905 .bdrv_dirname
= nfs_dirname
,
907 .strong_runtime_opts
= nfs_strong_runtime_opts
,
909 #ifdef LIBNFS_FEATURE_PAGECACHE
910 .bdrv_co_invalidate_cache
= nfs_co_invalidate_cache
,
914 static void nfs_block_init(void)
916 bdrv_register(&bdrv_nfs
);
919 block_init(nfs_block_init
);