1
The following changes since commit 00928a421d47f49691cace1207481b7aad31b1f1:
1
The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b:
2
2
3
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20180626' into staging (2018-06-26 18:23:49 +0100)
3
Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging (2022-04-20 16:43:11 -0700)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/stefanha/qemu.git tags/block-pull-request
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to ed6e2161715c527330f936d44af4c547f25f687e:
9
for you to fetch changes up to d45c83328feab2e4083991693160f0a417cfd9b0:
10
10
11
linux-aio: properly bubble up errors from initialization (2018-06-27 13:06:34 +0100)
11
virtiofsd: Add docs/helper for killpriv_v2/no_killpriv_v2 option (2022-04-21 12:05:15 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Pull request
14
Pull request
15
15
16
* Gracefully handle Linux AIO init failure
16
Small contrib/vhost-user-blk, contrib/vhost-user-scsi, and tools/virtiofsd
17
improvements.
17
18
18
----------------------------------------------------------------
19
----------------------------------------------------------------
19
20
20
Nishanth Aravamudan (1):
21
Liu Yiding (1):
21
linux-aio: properly bubble up errors from initialization
22
virtiofsd: Add docs/helper for killpriv_v2/no_killpriv_v2 option
23
24
Sakshi Kaushik (1):
25
Implements Backend Program conventions for vhost-user-scsi
22
26
23
Stefan Hajnoczi (1):
27
Stefan Hajnoczi (1):
24
compiler: add a sizeof_field() macro
28
contrib/vhost-user-blk: add missing GOptionEntry NULL terminator
25
29
26
include/block/aio.h | 3 +++
30
docs/tools/virtiofsd.rst | 5 ++
27
include/block/raw-aio.h | 2 +-
31
contrib/vhost-user-blk/vhost-user-blk.c | 3 +-
28
include/hw/xen/io/ring.h | 2 +-
32
contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++--------
29
include/qemu/compiler.h | 2 ++
33
tools/virtiofsd/helper.c | 3 +
30
accel/tcg/translate-all.c | 2 +-
34
4 files changed, 62 insertions(+), 26 deletions(-)
31
block/file-posix.c | 33 ++++++++++++++++++++++++++++-----
32
block/linux-aio.c | 12 +++++++++---
33
hw/display/xenfb.c | 4 ++--
34
hw/net/rocker/rocker_of_dpa.c | 2 +-
35
hw/net/virtio-net.c | 2 +-
36
stubs/linux-aio.c | 2 +-
37
target/i386/kvm.c | 2 +-
38
target/ppc/arch_dump.c | 10 +++++-----
39
target/s390x/arch_dump.c | 20 ++++++++++----------
40
util/async.c | 14 +++++++++++---
41
15 files changed, 77 insertions(+), 35 deletions(-)
42
35
43
--
36
--
44
2.17.1
37
2.35.1
45
46
diff view generated by jsdifflib
New patch
1
From: Sakshi Kaushik <sakshikaushik717@gmail.com>
1
2
3
Signed-off-by: Sakshi Kaushik <sakshikaushik717@gmail.com>
4
Message-id: 20220406162410.8536-1-sakshikaushik717@gmail.com
5
6
[Name the iSCSI URL long option --iscsi-uri instead of --iscsi_uri for
7
consistency, fix --fd which was rejected due to an outdated
8
--socket-path check, and add missing entries[] terminator.
9
--Stefan]
10
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
---
13
contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++--------
14
1 file changed, 52 insertions(+), 25 deletions(-)
15
16
diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/contrib/vhost-user-scsi/vhost-user-scsi.c
19
+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
20
@@ -XXX,XX +XXX,XX @@ fail:
21
22
/** vhost-user-scsi **/
23
24
+static int opt_fdnum = -1;
25
+static char *opt_socket_path;
26
+static gboolean opt_print_caps;
27
+static char *iscsi_uri;
28
+
29
+static GOptionEntry entries[] = {
30
+ { "print-capabilities", 'c', 0, G_OPTION_ARG_NONE, &opt_print_caps,
31
+ "Print capabilities", NULL },
32
+ { "fd", 'f', 0, G_OPTION_ARG_INT, &opt_fdnum,
33
+ "Use inherited fd socket", "FDNUM" },
34
+ { "iscsi-uri", 'i', 0, G_OPTION_ARG_FILENAME, &iscsi_uri,
35
+ "iSCSI URI to connect to", "FDNUM" },
36
+ { "socket-path", 's', 0, G_OPTION_ARG_FILENAME, &opt_socket_path,
37
+ "Use UNIX socket path", "PATH" },
38
+ { NULL, }
39
+};
40
+
41
int main(int argc, char **argv)
42
{
43
VusDev *vdev_scsi = NULL;
44
- char *unix_fn = NULL;
45
- char *iscsi_uri = NULL;
46
- int lsock = -1, csock = -1, opt, err = EXIT_SUCCESS;
47
+ int lsock = -1, csock = -1, err = EXIT_SUCCESS;
48
49
- while ((opt = getopt(argc, argv, "u:i:")) != -1) {
50
- switch (opt) {
51
- case 'h':
52
- goto help;
53
- case 'u':
54
- unix_fn = g_strdup(optarg);
55
- break;
56
- case 'i':
57
- iscsi_uri = g_strdup(optarg);
58
- break;
59
- default:
60
- goto help;
61
- }
62
+ GError *error = NULL;
63
+ GOptionContext *context;
64
+
65
+ context = g_option_context_new(NULL);
66
+ g_option_context_add_main_entries(context, entries, NULL);
67
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
68
+ g_printerr("Option parsing failed: %s\n", error->message);
69
+ exit(EXIT_FAILURE);
70
+ }
71
+
72
+ if (opt_print_caps) {
73
+ g_print("{\n");
74
+ g_print(" \"type\": \"scsi\"\n");
75
+ g_print("}\n");
76
+ goto out;
77
}
78
- if (!unix_fn || !iscsi_uri) {
79
+
80
+ if (!iscsi_uri) {
81
goto help;
82
}
83
84
- lsock = unix_sock_new(unix_fn);
85
- if (lsock < 0) {
86
- goto err;
87
+ if (opt_socket_path) {
88
+ lsock = unix_sock_new(opt_socket_path);
89
+ if (lsock < 0) {
90
+ exit(EXIT_FAILURE);
91
+ }
92
+ } else if (opt_fdnum < 0) {
93
+ g_print("%s\n", g_option_context_get_help(context, true, NULL));
94
+ exit(EXIT_FAILURE);
95
+ } else {
96
+ lsock = opt_fdnum;
97
}
98
99
csock = accept(lsock, NULL, NULL);
100
@@ -XXX,XX +XXX,XX @@ out:
101
if (vdev_scsi) {
102
g_main_loop_unref(vdev_scsi->loop);
103
g_free(vdev_scsi);
104
- unlink(unix_fn);
105
+ unlink(opt_socket_path);
106
}
107
if (csock >= 0) {
108
close(csock);
109
@@ -XXX,XX +XXX,XX @@ out:
110
if (lsock >= 0) {
111
close(lsock);
112
}
113
- g_free(unix_fn);
114
+ g_free(opt_socket_path);
115
g_free(iscsi_uri);
116
117
return err;
118
@@ -XXX,XX +XXX,XX @@ err:
119
goto out;
120
121
help:
122
- fprintf(stderr, "Usage: %s [ -u unix_sock_path -i iscsi_uri ] | [ -h ]\n",
123
+ fprintf(stderr, "Usage: %s [ -s socket-path -i iscsi-uri -f fd -p print-capabilities ] | [ -h ]\n",
124
argv[0]);
125
- fprintf(stderr, " -u path to unix socket\n");
126
- fprintf(stderr, " -i iscsi uri for lun 0\n");
127
+ fprintf(stderr, " -s, --socket-path=SOCKET_PATH path to unix socket\n");
128
+ fprintf(stderr, " -i, --iscsi-uri=ISCSI_URI iscsi uri for lun 0\n");
129
+ fprintf(stderr, " -f, --fd=FILE_DESCRIPTOR file-descriptor\n");
130
+ fprintf(stderr, " -p, --print-capabilities=PRINT_CAPABILITIES denotes print-capabilities\n");
131
fprintf(stderr, " -h print help and quit\n");
132
133
goto err;
134
--
135
2.35.1
diff view generated by jsdifflib
1
Determining the size of a field is useful when you don't have a struct
1
The GLib documentation says "a NULL-terminated array of GOptionEntrys"
2
variable handy. Open-coding this is ugly.
2
so we'd better make sure there is a terminator that lets
3
3
g_option_context_add_main_entries() know when the end of the array has
4
This patch adds the sizeof_field() macro, which is similar to
4
been reached.
5
typeof_field(). Existing instances are updated to use the macro.
6
5
7
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Reviewed-by: John Snow <jsnow@redhat.com>
7
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
9
Message-id: 20180614164431.29305-1-stefanha@redhat.com
8
Message-id: 20220411150057.3009667-1-stefanha@redhat.com
10
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
---
10
---
12
include/hw/xen/io/ring.h | 2 +-
11
contrib/vhost-user-blk/vhost-user-blk.c | 3 ++-
13
include/qemu/compiler.h | 2 ++
12
1 file changed, 2 insertions(+), 1 deletion(-)
14
accel/tcg/translate-all.c | 2 +-
15
hw/display/xenfb.c | 4 ++--
16
hw/net/rocker/rocker_of_dpa.c | 2 +-
17
hw/net/virtio-net.c | 2 +-
18
target/i386/kvm.c | 2 +-
19
target/ppc/arch_dump.c | 10 +++++-----
20
target/s390x/arch_dump.c | 20 ++++++++++----------
21
9 files changed, 24 insertions(+), 22 deletions(-)
22
13
23
diff --git a/include/hw/xen/io/ring.h b/include/hw/xen/io/ring.h
14
diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
24
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/xen/io/ring.h
16
--- a/contrib/vhost-user-blk/vhost-user-blk.c
26
+++ b/include/hw/xen/io/ring.h
17
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
27
@@ -XXX,XX +XXX,XX @@ typedef unsigned int RING_IDX;
18
@@ -XXX,XX +XXX,XX @@ static GOptionEntry entries[] = {
28
*/
19
{"blk-file", 'b', 0, G_OPTION_ARG_FILENAME, &opt_blk_file,
29
#define __CONST_RING_SIZE(_s, _sz) \
20
"block device or file path", "PATH"},
30
(__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
21
{ "read-only", 'r', 0, G_OPTION_ARG_NONE, &opt_read_only,
31
-     sizeof(((struct _s##_sring *)0)->ring[0])))
22
- "Enable read-only", NULL }
32
+ sizeof_field(struct _s##_sring, ring[0])))
23
+ "Enable read-only", NULL },
33
/*
24
+ { NULL, },
34
* The same for passing in an actual pointer instead of a name tag.
35
*/
36
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
37
index XXXXXXX..XXXXXXX 100644
38
--- a/include/qemu/compiler.h
39
+++ b/include/qemu/compiler.h
40
@@ -XXX,XX +XXX,XX @@
41
(type *) ((char *) __mptr - offsetof(type, member));})
42
#endif
43
44
+#define sizeof_field(type, field) sizeof(((type *)0)->field)
45
+
46
/* Convert from a base type to a parent type, with compile time checking. */
47
#ifdef __GNUC__
48
#define DO_UPCAST(type, field, dev) ( __extension__ ( { \
49
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/accel/tcg/translate-all.c
52
+++ b/accel/tcg/translate-all.c
53
@@ -XXX,XX +XXX,XX @@ struct page_collection {
54
55
/* Make sure all possible CPU event bits fit in tb->trace_vcpu_dstate */
56
QEMU_BUILD_BUG_ON(CPU_TRACE_DSTATE_MAX_EVENTS >
57
- sizeof(((TranslationBlock *)0)->trace_vcpu_dstate)
58
+ sizeof_field(TranslationBlock, trace_vcpu_dstate)
59
* BITS_PER_BYTE);
60
61
/*
62
diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/hw/display/xenfb.c
65
+++ b/hw/display/xenfb.c
66
@@ -XXX,XX +XXX,XX @@ static int xenfb_configure_fb(struct XenFB *xenfb, size_t fb_len_lim,
67
int width, int height, int depth,
68
size_t fb_len, int offset, int row_stride)
69
{
70
- size_t mfn_sz = sizeof(*((struct xenfb_page *)0)->pd);
71
- size_t pd_len = sizeof(((struct xenfb_page *)0)->pd) / mfn_sz;
72
+ size_t mfn_sz = sizeof_field(struct xenfb_page, pd[0]);
73
+ size_t pd_len = sizeof_field(struct xenfb_page, pd) / mfn_sz;
74
size_t fb_pages = pd_len * XC_PAGE_SIZE / mfn_sz;
75
size_t fb_len_max = fb_pages * XC_PAGE_SIZE;
76
int max_width, max_height;
77
diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/net/rocker/rocker_of_dpa.c
80
+++ b/hw/net/rocker/rocker_of_dpa.c
81
@@ -XXX,XX +XXX,XX @@ typedef struct of_dpa_flow_key {
82
83
/* Width of key which includes field 'f' in u64s, rounded up */
84
#define FLOW_KEY_WIDTH(f) \
85
- DIV_ROUND_UP(offsetof(OfDpaFlowKey, f) + sizeof(((OfDpaFlowKey *)0)->f), \
86
+ DIV_ROUND_UP(offsetof(OfDpaFlowKey, f) + sizeof_field(OfDpaFlowKey, f), \
87
sizeof(uint64_t))
88
89
typedef struct of_dpa_flow_action {
90
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
91
index XXXXXXX..XXXXXXX 100644
92
--- a/hw/net/virtio-net.c
93
+++ b/hw/net/virtio-net.c
94
@@ -XXX,XX +XXX,XX @@
95
* 'container'.
96
*/
97
#define endof(container, field) \
98
- (offsetof(container, field) + sizeof(((container *)0)->field))
99
+ (offsetof(container, field) + sizeof_field(container, field))
100
101
typedef struct VirtIOFeature {
102
uint64_t flags;
103
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
104
index XXXXXXX..XXXXXXX 100644
105
--- a/target/i386/kvm.c
106
+++ b/target/i386/kvm.c
107
@@ -XXX,XX +XXX,XX @@ static int kvm_put_fpu(X86CPU *cpu)
108
#define XSAVE_PKRU 672
109
110
#define XSAVE_BYTE_OFFSET(word_offset) \
111
- ((word_offset) * sizeof(((struct kvm_xsave *)0)->region[0]))
112
+ ((word_offset) * sizeof_field(struct kvm_xsave, region[0]))
113
114
#define ASSERT_OFFSET(word_offset, field) \
115
QEMU_BUILD_BUG_ON(XSAVE_BYTE_OFFSET(word_offset) != \
116
diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/target/ppc/arch_dump.c
119
+++ b/target/ppc/arch_dump.c
120
@@ -XXX,XX +XXX,XX @@ static const struct NoteFuncDescStruct {
121
int contents_size;
122
void (*note_contents_func)(NoteFuncArg *arg, PowerPCCPU *cpu);
123
} note_func[] = {
124
- {sizeof(((Note *)0)->contents.prstatus), ppc_write_elf_prstatus},
125
- {sizeof(((Note *)0)->contents.fpregset), ppc_write_elf_fpregset},
126
- {sizeof(((Note *)0)->contents.vmxregset), ppc_write_elf_vmxregset},
127
- {sizeof(((Note *)0)->contents.vsxregset), ppc_write_elf_vsxregset},
128
- {sizeof(((Note *)0)->contents.speregset), ppc_write_elf_speregset},
129
+ {sizeof_field(Note, contents.prstatus), ppc_write_elf_prstatus},
130
+ {sizeof_field(Note, contents.fpregset), ppc_write_elf_fpregset},
131
+ {sizeof_field(Note, contents.vmxregset), ppc_write_elf_vmxregset},
132
+ {sizeof_field(Note, contents.vsxregset), ppc_write_elf_vsxregset},
133
+ {sizeof_field(Note, contents.speregset), ppc_write_elf_speregset},
134
{ 0, NULL}
135
};
25
};
136
26
137
diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c
27
int main(int argc, char **argv)
138
index XXXXXXX..XXXXXXX 100644
139
--- a/target/s390x/arch_dump.c
140
+++ b/target/s390x/arch_dump.c
141
@@ -XXX,XX +XXX,XX @@ typedef struct NoteFuncDescStruct {
142
} NoteFuncDesc;
143
144
static const NoteFuncDesc note_core[] = {
145
- {sizeof(((Note *)0)->contents.prstatus), s390x_write_elf64_prstatus},
146
- {sizeof(((Note *)0)->contents.fpregset), s390x_write_elf64_fpregset},
147
+ {sizeof_field(Note, contents.prstatus), s390x_write_elf64_prstatus},
148
+ {sizeof_field(Note, contents.fpregset), s390x_write_elf64_fpregset},
149
{ 0, NULL}
150
};
151
152
static const NoteFuncDesc note_linux[] = {
153
- {sizeof(((Note *)0)->contents.prefix), s390x_write_elf64_prefix},
154
- {sizeof(((Note *)0)->contents.ctrs), s390x_write_elf64_ctrs},
155
- {sizeof(((Note *)0)->contents.timer), s390x_write_elf64_timer},
156
- {sizeof(((Note *)0)->contents.todcmp), s390x_write_elf64_todcmp},
157
- {sizeof(((Note *)0)->contents.todpreg), s390x_write_elf64_todpreg},
158
- {sizeof(((Note *)0)->contents.vregslo), s390x_write_elf64_vregslo},
159
- {sizeof(((Note *)0)->contents.vregshi), s390x_write_elf64_vregshi},
160
- {sizeof(((Note *)0)->contents.gscb), s390x_write_elf64_gscb},
161
+ {sizeof_field(Note, contents.prefix), s390x_write_elf64_prefix},
162
+ {sizeof_field(Note, contents.ctrs), s390x_write_elf64_ctrs},
163
+ {sizeof_field(Note, contents.timer), s390x_write_elf64_timer},
164
+ {sizeof_field(Note, contents.todcmp), s390x_write_elf64_todcmp},
165
+ {sizeof_field(Note, contents.todpreg), s390x_write_elf64_todpreg},
166
+ {sizeof_field(Note, contents.vregslo), s390x_write_elf64_vregslo},
167
+ {sizeof_field(Note, contents.vregshi), s390x_write_elf64_vregshi},
168
+ {sizeof_field(Note, contents.gscb), s390x_write_elf64_gscb},
169
{ 0, NULL}
170
};
171
172
--
28
--
173
2.17.1
29
2.35.1
174
175
diff view generated by jsdifflib
1
From: Nishanth Aravamudan <naravamudan@digitalocean.com>
1
From: Liu Yiding <liuyd.fnst@fujitsu.com>
2
2
3
laio_init() can fail for a couple of reasons, which will lead to a NULL
3
virtiofsd has introduced killpriv_v2/no_killpriv_v2 for a while. Add
4
pointer dereference in laio_attach_aio_context().
4
description of it to docs/helper.
5
5
6
To solve this, add a aio_setup_linux_aio() function which is called
6
Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
7
early in raw_open_common. If this fails, propagate the error up. The
7
Message-Id: <20220421095151.2231099-1-liuyd.fnst@fujitsu.com>
8
signature of aio_get_linux_aio() was not modified, because it seems
9
preferable to return the actual errno from the possible failing
10
initialization calls.
11
8
12
Additionally, when the AioContext changes, we need to associate a
9
[Small documentation fixes: s/as client supports/as the client supports/
13
LinuxAioState with the new AioContext. Use the bdrv_attach_aio_context
10
and s/. /. /.
14
callback and call the new aio_setup_linux_aio(), which will allocate a
11
--Stefan]
15
new AioContext if needed, and return errors on failures. If it fails for
16
any reason, fallback to threaded AIO with an error message, as the
17
device is already in-use by the guest.
18
12
19
Add an assert that aio_get_linux_aio() cannot return NULL.
20
21
Signed-off-by: Nishanth Aravamudan <naravamudan@digitalocean.com>
22
Message-id: 20180622193700.6523-1-naravamudan@digitalocean.com
23
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
---
14
---
25
include/block/aio.h | 3 +++
15
docs/tools/virtiofsd.rst | 5 +++++
26
include/block/raw-aio.h | 2 +-
16
tools/virtiofsd/helper.c | 3 +++
27
block/file-posix.c | 33 ++++++++++++++++++++++++++++-----
17
2 files changed, 8 insertions(+)
28
block/linux-aio.c | 12 +++++++++---
29
stubs/linux-aio.c | 2 +-
30
util/async.c | 14 +++++++++++---
31
6 files changed, 53 insertions(+), 13 deletions(-)
32
18
33
diff --git a/include/block/aio.h b/include/block/aio.h
19
diff --git a/docs/tools/virtiofsd.rst b/docs/tools/virtiofsd.rst
34
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
35
--- a/include/block/aio.h
21
--- a/docs/tools/virtiofsd.rst
36
+++ b/include/block/aio.h
22
+++ b/docs/tools/virtiofsd.rst
37
@@ -XXX,XX +XXX,XX @@ GSource *aio_get_g_source(AioContext *ctx);
23
@@ -XXX,XX +XXX,XX @@ Options
38
/* Return the ThreadPool bound to this AioContext */
24
label. Server will try to set that label on newly created file
39
struct ThreadPool *aio_get_thread_pool(AioContext *ctx);
25
atomically wherever possible.
40
26
41
+/* Setup the LinuxAioState bound to this AioContext */
27
+ * killpriv_v2|no_killpriv_v2 -
42
+struct LinuxAioState *aio_setup_linux_aio(AioContext *ctx, Error **errp);
28
+ Enable/disable ``FUSE_HANDLE_KILLPRIV_V2`` support. KILLPRIV_V2 is enabled
29
+ by default as long as the client supports it. Enabling this option helps
30
+ with performance in write path.
43
+
31
+
44
/* Return the LinuxAioState bound to this AioContext */
32
.. option:: --socket-path=PATH
45
struct LinuxAioState *aio_get_linux_aio(AioContext *ctx);
33
46
34
Listen on vhost-user UNIX domain socket at PATH.
47
diff --git a/include/block/raw-aio.h b/include/block/raw-aio.h
35
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
48
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
49
--- a/include/block/raw-aio.h
37
--- a/tools/virtiofsd/helper.c
50
+++ b/include/block/raw-aio.h
38
+++ b/tools/virtiofsd/helper.c
51
@@ -XXX,XX +XXX,XX @@
39
@@ -XXX,XX +XXX,XX @@ void fuse_cmdline_help(void)
52
/* linux-aio.c - Linux native implementation */
40
" -o announce_submounts Announce sub-mount points to the guest\n"
53
#ifdef CONFIG_LINUX_AIO
41
" -o posix_acl/no_posix_acl Enable/Disable posix_acl. (default: disabled)\n"
54
typedef struct LinuxAioState LinuxAioState;
42
" -o security_label/no_security_label Enable/Disable security label. (default: disabled)\n"
55
-LinuxAioState *laio_init(void);
43
+ " -o killpriv_v2/no_killpriv_v2\n"
56
+LinuxAioState *laio_init(Error **errp);
44
+ " Enable/Disable FUSE_HANDLE_KILLPRIV_V2.\n"
57
void laio_cleanup(LinuxAioState *s);
45
+ " (default: enabled as long as client supports it)\n"
58
int coroutine_fn laio_co_submit(BlockDriverState *bs, LinuxAioState *s, int fd,
46
);
59
uint64_t offset, QEMUIOVector *qiov, int type);
60
diff --git a/block/file-posix.c b/block/file-posix.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/block/file-posix.c
63
+++ b/block/file-posix.c
64
@@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
65
66
#ifdef CONFIG_LINUX_AIO
67
/* Currently Linux does AIO only for files opened with O_DIRECT */
68
- if (s->use_linux_aio && !(s->open_flags & O_DIRECT)) {
69
- error_setg(errp, "aio=native was specified, but it requires "
70
- "cache.direct=on, which was not specified.");
71
- ret = -EINVAL;
72
- goto fail;
73
+ if (s->use_linux_aio) {
74
+ if (!(s->open_flags & O_DIRECT)) {
75
+ error_setg(errp, "aio=native was specified, but it requires "
76
+ "cache.direct=on, which was not specified.");
77
+ ret = -EINVAL;
78
+ goto fail;
79
+ }
80
+ if (!aio_setup_linux_aio(bdrv_get_aio_context(bs), errp)) {
81
+ error_prepend(errp, "Unable to use native AIO: ");
82
+ goto fail;
83
+ }
84
}
85
#else
86
if (s->use_linux_aio) {
87
@@ -XXX,XX +XXX,XX @@ static BlockAIOCB *raw_aio_flush(BlockDriverState *bs,
88
return paio_submit(bs, s->fd, 0, NULL, 0, cb, opaque, QEMU_AIO_FLUSH);
89
}
47
}
90
48
91
+static void raw_aio_attach_aio_context(BlockDriverState *bs,
92
+ AioContext *new_context)
93
+{
94
+#ifdef CONFIG_LINUX_AIO
95
+ BDRVRawState *s = bs->opaque;
96
+ if (s->use_linux_aio) {
97
+ Error *local_err;
98
+ if (!aio_setup_linux_aio(new_context, &local_err)) {
99
+ error_reportf_err(local_err, "Unable to use native AIO, "
100
+ "falling back to thread pool: ");
101
+ s->use_linux_aio = false;
102
+ }
103
+ }
104
+#endif
105
+}
106
+
107
static void raw_close(BlockDriverState *bs)
108
{
109
BDRVRawState *s = bs->opaque;
110
@@ -XXX,XX +XXX,XX @@ BlockDriver bdrv_file = {
111
.bdrv_refresh_limits = raw_refresh_limits,
112
.bdrv_io_plug = raw_aio_plug,
113
.bdrv_io_unplug = raw_aio_unplug,
114
+ .bdrv_attach_aio_context = raw_aio_attach_aio_context,
115
116
.bdrv_truncate = raw_truncate,
117
.bdrv_getlength = raw_getlength,
118
diff --git a/block/linux-aio.c b/block/linux-aio.c
119
index XXXXXXX..XXXXXXX 100644
120
--- a/block/linux-aio.c
121
+++ b/block/linux-aio.c
122
@@ -XXX,XX +XXX,XX @@
123
#include "block/raw-aio.h"
124
#include "qemu/event_notifier.h"
125
#include "qemu/coroutine.h"
126
+#include "qapi/error.h"
127
128
#include <libaio.h>
129
130
@@ -XXX,XX +XXX,XX @@ void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context)
131
qemu_laio_poll_cb);
132
}
133
134
-LinuxAioState *laio_init(void)
135
+LinuxAioState *laio_init(Error **errp)
136
{
137
+ int rc;
138
LinuxAioState *s;
139
140
s = g_malloc0(sizeof(*s));
141
- if (event_notifier_init(&s->e, false) < 0) {
142
+ rc = event_notifier_init(&s->e, false);
143
+ if (rc < 0) {
144
+ error_setg_errno(errp, -rc, "failed to to initialize event notifier");
145
goto out_free_state;
146
}
147
148
- if (io_setup(MAX_EVENTS, &s->ctx) != 0) {
149
+ rc = io_setup(MAX_EVENTS, &s->ctx);
150
+ if (rc < 0) {
151
+ error_setg_errno(errp, -rc, "failed to create linux AIO context");
152
goto out_close_efd;
153
}
154
155
diff --git a/stubs/linux-aio.c b/stubs/linux-aio.c
156
index XXXXXXX..XXXXXXX 100644
157
--- a/stubs/linux-aio.c
158
+++ b/stubs/linux-aio.c
159
@@ -XXX,XX +XXX,XX @@ void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context)
160
abort();
161
}
162
163
-LinuxAioState *laio_init(void)
164
+LinuxAioState *laio_init(Error **errp)
165
{
166
abort();
167
}
168
diff --git a/util/async.c b/util/async.c
169
index XXXXXXX..XXXXXXX 100644
170
--- a/util/async.c
171
+++ b/util/async.c
172
@@ -XXX,XX +XXX,XX @@ ThreadPool *aio_get_thread_pool(AioContext *ctx)
173
}
174
175
#ifdef CONFIG_LINUX_AIO
176
-LinuxAioState *aio_get_linux_aio(AioContext *ctx)
177
+LinuxAioState *aio_setup_linux_aio(AioContext *ctx, Error **errp)
178
{
179
if (!ctx->linux_aio) {
180
- ctx->linux_aio = laio_init();
181
- laio_attach_aio_context(ctx->linux_aio, ctx);
182
+ ctx->linux_aio = laio_init(errp);
183
+ if (ctx->linux_aio) {
184
+ laio_attach_aio_context(ctx->linux_aio, ctx);
185
+ }
186
}
187
return ctx->linux_aio;
188
}
189
+
190
+LinuxAioState *aio_get_linux_aio(AioContext *ctx)
191
+{
192
+ assert(ctx->linux_aio);
193
+ return ctx->linux_aio;
194
+}
195
#endif
196
197
void aio_notify(AioContext *ctx)
198
--
49
--
199
2.17.1
50
2.35.1
200
201
diff view generated by jsdifflib