1
The following changes since commit 22c5f446514a2a4bb0dbe1fea26713da92fc85fa:
1
The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b:
2
2
3
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190211' into staging (2019-02-11 17:04:57 +0000)
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 9a6719d572e99a4e79f589d0b73f7475b86f982d:
9
for you to fetch changes up to d45c83328feab2e4083991693160f0a417cfd9b0:
10
10
11
virtio-blk: cleanup using VirtIOBlock *s and VirtIODevice *vdev (2019-02-12 11:49:17 +0800)
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
Small contrib/vhost-user-blk, contrib/vhost-user-scsi, and tools/virtiofsd
17
improvements.
18
16
----------------------------------------------------------------
19
----------------------------------------------------------------
17
20
18
Peter Xu (1):
21
Liu Yiding (1):
19
iothread: fix iothread hang when stop too soon
22
virtiofsd: Add docs/helper for killpriv_v2/no_killpriv_v2 option
20
23
21
Stefano Garzarella (1):
24
Sakshi Kaushik (1):
22
virtio-blk: cleanup using VirtIOBlock *s and VirtIODevice *vdev
25
Implements Backend Program conventions for vhost-user-scsi
23
26
24
Vladimir Sementsov-Ogievskiy (1):
27
Stefan Hajnoczi (1):
25
qemugdb/coroutine: fix arch_prctl has unknown return type
28
contrib/vhost-user-blk: add missing GOptionEntry NULL terminator
26
29
27
hw/block/virtio-blk.c | 22 +++++++++-------------
30
docs/tools/virtiofsd.rst | 5 ++
28
iothread.c | 6 +++++-
31
contrib/vhost-user-blk/vhost-user-blk.c | 3 +-
29
scripts/qemugdb/coroutine.py | 2 +-
32
contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++--------
30
3 files changed, 15 insertions(+), 15 deletions(-)
33
tools/virtiofsd/helper.c | 3 +
34
4 files changed, 62 insertions(+), 26 deletions(-)
31
35
32
--
36
--
33
2.20.1
37
2.35.1
34
35
diff view generated by jsdifflib
1
From: Stefano Garzarella <sgarzare@redhat.com>
1
From: Sakshi Kaushik <sakshikaushik717@gmail.com>
2
2
3
In several part we still using req->dev or VIRTIO_DEVICE(req->dev)
3
Signed-off-by: Sakshi Kaushik <sakshikaushik717@gmail.com>
4
when we have already defined s and vdev pointers:
4
Message-id: 20220406162410.8536-1-sakshikaushik717@gmail.com
5
VirtIOBlock *s = req->dev;
6
VirtIODevice *vdev = VIRTIO_DEVICE(s);
7
5
8
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
6
[Name the iSCSI URL long option --iscsi-uri instead of --iscsi_uri for
9
Reviewed-by: Liam Merwick <liam.merwick@oracle.com>
7
consistency, fix --fd which was rejected due to an outdated
10
Message-id: 20190208142347.214815-1-sgarzare@redhat.com
8
--socket-path check, and add missing entries[] terminator.
9
--Stefan]
10
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
---
12
---
13
hw/block/virtio-blk.c | 22 +++++++++-------------
13
contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++--------
14
1 file changed, 9 insertions(+), 13 deletions(-)
14
1 file changed, 52 insertions(+), 25 deletions(-)
15
15
16
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
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
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/block/virtio-blk.c
18
--- a/contrib/vhost-user-scsi/vhost-user-scsi.c
19
+++ b/hw/block/virtio-blk.c
19
+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
20
@@ -XXX,XX +XXX,XX @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
20
@@ -XXX,XX +XXX,XX @@ fail:
21
static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
21
22
bool is_read)
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)
23
{
42
{
24
- BlockErrorAction action = blk_get_error_action(req->dev->blk,
43
VusDev *vdev_scsi = NULL;
25
- is_read, error);
44
- char *unix_fn = NULL;
26
VirtIOBlock *s = req->dev;
45
- char *iscsi_uri = NULL;
27
+ BlockErrorAction action = blk_get_error_action(s->blk, is_read, error);
46
- int lsock = -1, csock = -1, opt, err = EXIT_SUCCESS;
28
47
+ int lsock = -1, csock = -1, err = EXIT_SUCCESS;
29
if (action == BLOCK_ERROR_ACTION_STOP) {
48
30
/* Break the link as the next request is going to be parsed from the
49
- while ((opt = getopt(argc, argv, "u:i:")) != -1) {
31
@@ -XXX,XX +XXX,XX @@ static void virtio_blk_flush_complete(void *opaque, int ret)
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;
32
}
77
}
33
78
- if (!unix_fn || !iscsi_uri) {
34
virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
79
+
35
- block_acct_done(blk_get_stats(req->dev->blk), &req->acct);
80
+ if (!iscsi_uri) {
36
+ block_acct_done(blk_get_stats(s->blk), &req->acct);
81
goto help;
37
virtio_blk_free_request(req);
82
}
38
83
39
out:
84
- lsock = unix_sock_new(unix_fn);
40
@@ -XXX,XX +XXX,XX @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)
85
- if (lsock < 0) {
41
- sizeof(struct virtio_blk_inhdr);
86
- goto err;
42
iov_discard_back(in_iov, &in_num, sizeof(struct virtio_blk_inhdr));
87
+ if (opt_socket_path) {
43
88
+ lsock = unix_sock_new(opt_socket_path);
44
- type = virtio_ldl_p(VIRTIO_DEVICE(req->dev), &req->out.type);
89
+ if (lsock < 0) {
45
+ type = virtio_ldl_p(vdev, &req->out.type);
90
+ exit(EXIT_FAILURE);
46
91
+ }
47
/* VIRTIO_BLK_T_OUT defines the command direction. VIRTIO_BLK_T_BARRIER
92
+ } else if (opt_fdnum < 0) {
48
* is an optional flag. Although a guest should not send this flag if
93
+ g_print("%s\n", g_option_context_get_help(context, true, NULL));
49
@@ -XXX,XX +XXX,XX @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)
94
+ exit(EXIT_FAILURE);
50
case VIRTIO_BLK_T_IN:
95
+ } else {
51
{
96
+ lsock = opt_fdnum;
52
bool is_write = type & VIRTIO_BLK_T_OUT;
97
}
53
- req->sector_num = virtio_ldq_p(VIRTIO_DEVICE(req->dev),
98
54
- &req->out.sector);
99
csock = accept(lsock, NULL, NULL);
55
+ req->sector_num = virtio_ldq_p(vdev, &req->out.sector);
100
@@ -XXX,XX +XXX,XX @@ out:
56
101
if (vdev_scsi) {
57
if (is_write) {
102
g_main_loop_unref(vdev_scsi->loop);
58
qemu_iovec_init_external(&req->qiov, out_iov, out_num);
103
g_free(vdev_scsi);
59
@@ -XXX,XX +XXX,XX @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)
104
- unlink(unix_fn);
60
req->qiov.size / BDRV_SECTOR_SIZE);
105
+ unlink(opt_socket_path);
61
}
106
}
62
107
if (csock >= 0) {
63
- if (!virtio_blk_sect_range_ok(req->dev, req->sector_num,
108
close(csock);
64
- req->qiov.size)) {
109
@@ -XXX,XX +XXX,XX @@ out:
65
+ if (!virtio_blk_sect_range_ok(s, req->sector_num, req->qiov.size)) {
110
if (lsock >= 0) {
66
virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
111
close(lsock);
67
- block_acct_invalid(blk_get_stats(req->dev->blk),
112
}
68
+ block_acct_invalid(blk_get_stats(s->blk),
113
- g_free(unix_fn);
69
is_write ? BLOCK_ACCT_WRITE : BLOCK_ACCT_READ);
114
+ g_free(opt_socket_path);
70
virtio_blk_free_request(req);
115
g_free(iscsi_uri);
71
return 0;
116
72
}
117
return err;
73
118
@@ -XXX,XX +XXX,XX @@ err:
74
- block_acct_start(blk_get_stats(req->dev->blk),
119
goto out;
75
- &req->acct, req->qiov.size,
120
76
+ block_acct_start(blk_get_stats(s->blk), &req->acct, req->qiov.size,
121
help:
77
is_write ? BLOCK_ACCT_WRITE : BLOCK_ACCT_READ);
122
- fprintf(stderr, "Usage: %s [ -u unix_sock_path -i iscsi_uri ] | [ -h ]\n",
78
123
+ fprintf(stderr, "Usage: %s [ -s socket-path -i iscsi-uri -f fd -p print-capabilities ] | [ -h ]\n",
79
/* merge would exceed maximum number of requests or IO direction
124
argv[0]);
80
* changes */
125
- fprintf(stderr, " -u path to unix socket\n");
81
if (mrb->num_reqs > 0 && (mrb->num_reqs == VIRTIO_BLK_MAX_MERGE_REQS ||
126
- fprintf(stderr, " -i iscsi uri for lun 0\n");
82
is_write != mrb->is_write ||
127
+ fprintf(stderr, " -s, --socket-path=SOCKET_PATH path to unix socket\n");
83
- !req->dev->conf.request_merging)) {
128
+ fprintf(stderr, " -i, --iscsi-uri=ISCSI_URI iscsi uri for lun 0\n");
84
- virtio_blk_submit_multireq(req->dev->blk, mrb);
129
+ fprintf(stderr, " -f, --fd=FILE_DESCRIPTOR file-descriptor\n");
85
+ !s->conf.request_merging)) {
130
+ fprintf(stderr, " -p, --print-capabilities=PRINT_CAPABILITIES denotes print-capabilities\n");
86
+ virtio_blk_submit_multireq(s->blk, mrb);
131
fprintf(stderr, " -h print help and quit\n");
87
}
132
88
133
goto err;
89
assert(mrb->num_reqs < VIRTIO_BLK_MAX_MERGE_REQS);
90
--
134
--
91
2.20.1
135
2.35.1
92
93
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
The GLib documentation says "a NULL-terminated array of GOptionEntrys"
2
so we'd better make sure there is a terminator that lets
3
g_option_context_add_main_entries() know when the end of the array has
4
been reached.
2
5
3
qemu coroutine command results in following error output:
6
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4
7
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
5
Python Exception <class 'gdb.error'> 'arch_prctl' has unknown return
8
Message-id: 20220411150057.3009667-1-stefanha@redhat.com
6
type; cast the call to its declared return type: Error occurred in
7
Python command: 'arch_prctl' has unknown return type; cast the call to
8
its declared return type
9
10
Fix it by giving it what it wants: arch_prctl return type.
11
12
Information on the topic:
13
https://sourceware.org/gdb/onlinedocs/gdb/Calling.html
14
15
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
16
Message-id: 20190206151425.105871-1-vsementsov@virtuozzo.com
17
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
18
---
10
---
19
scripts/qemugdb/coroutine.py | 2 +-
11
contrib/vhost-user-blk/vhost-user-blk.c | 3 ++-
20
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 2 insertions(+), 1 deletion(-)
21
13
22
diff --git a/scripts/qemugdb/coroutine.py b/scripts/qemugdb/coroutine.py
14
diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
23
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
24
--- a/scripts/qemugdb/coroutine.py
16
--- a/contrib/vhost-user-blk/vhost-user-blk.c
25
+++ b/scripts/qemugdb/coroutine.py
17
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
26
@@ -XXX,XX +XXX,XX @@ def get_fs_base():
18
@@ -XXX,XX +XXX,XX @@ static GOptionEntry entries[] = {
27
pthread_self().'''
19
{"blk-file", 'b', 0, G_OPTION_ARG_FILENAME, &opt_blk_file,
28
# %rsp - 120 is scratch space according to the SystemV ABI
20
"block device or file path", "PATH"},
29
old = gdb.parse_and_eval('*(uint64_t*)($rsp - 120)')
21
{ "read-only", 'r', 0, G_OPTION_ARG_NONE, &opt_read_only,
30
- gdb.execute('call arch_prctl(0x1003, $rsp - 120)', False, True)
22
- "Enable read-only", NULL }
31
+ gdb.execute('call (int)arch_prctl(0x1003, $rsp - 120)', False, True)
23
+ "Enable read-only", NULL },
32
fs_base = gdb.parse_and_eval('*(uint64_t*)($rsp - 120)')
24
+ { NULL, },
33
gdb.execute('set *(uint64_t*)($rsp - 120) = %s' % old, False, True)
25
};
34
return fs_base
26
27
int main(int argc, char **argv)
35
--
28
--
36
2.20.1
29
2.35.1
37
38
diff view generated by jsdifflib
1
From: Peter Xu <peterx@redhat.com>
1
From: Liu Yiding <liuyd.fnst@fujitsu.com>
2
2
3
Lukas reported an hard to reproduce QMP iothread hang on s390 that
3
virtiofsd has introduced killpriv_v2/no_killpriv_v2 for a while. Add
4
QEMU might hang at pthread_join() of the QMP monitor iothread before
4
description of it to docs/helper.
5
quitting:
6
5
7
Thread 1
6
Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
8
#0 0x000003ffad10932c in pthread_join
7
Message-Id: <20220421095151.2231099-1-liuyd.fnst@fujitsu.com>
9
#1 0x0000000109e95750 in qemu_thread_join
10
at /home/thuth/devel/qemu/util/qemu-thread-posix.c:570
11
#2 0x0000000109c95a1c in iothread_stop
12
#3 0x0000000109bb0874 in monitor_cleanup
13
#4 0x0000000109b55042 in main
14
8
15
While the iothread is still in the main loop:
9
[Small documentation fixes: s/as client supports/as the client supports/
10
and s/. /. /.
11
--Stefan]
16
12
17
Thread 4
18
#0 0x000003ffad0010e4 in ??
19
#1 0x000003ffad553958 in g_main_context_iterate.isra.19
20
#2 0x000003ffad553d90 in g_main_loop_run
21
#3 0x0000000109c9585a in iothread_run
22
at /home/thuth/devel/qemu/iothread.c:74
23
#4 0x0000000109e94752 in qemu_thread_start
24
at /home/thuth/devel/qemu/util/qemu-thread-posix.c:502
25
#5 0x000003ffad10825a in start_thread
26
#6 0x000003ffad00dcf2 in thread_start
27
28
IMHO it's because there's a race between the main thread and iothread
29
when stopping the thread in following sequence:
30
31
main thread iothread
32
=========== ==============
33
aio_poll()
34
iothread_get_g_main_context
35
set iothread->worker_context
36
iothread_stop
37
schedule iothread_stop_bh
38
execute iothread_stop_bh [1]
39
set iothread->running=false
40
(since main_loop==NULL so
41
skip to quit main loop.
42
Note: although main_loop is
43
NULL but worker_context is
44
not!)
45
atomic_read(&iothread->worker_context) [2]
46
create main_loop object
47
g_main_loop_run() [3]
48
pthread_join() [4]
49
50
We can see that when execute iothread_stop_bh() at [1] it's possible
51
that main_loop is still NULL because it's only created until the first
52
check of the worker_context later at [2]. Then the iothread will hang
53
in the main loop [3] and it'll starve the main thread too [4].
54
55
Here the simple solution should be that we check again the "running"
56
variable before check against worker_context.
57
58
CC: Thomas Huth <thuth@redhat.com>
59
CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
60
CC: Stefan Hajnoczi <stefanha@redhat.com>
61
CC: Lukáš Doktor <ldoktor@redhat.com>
62
CC: Markus Armbruster <armbru@redhat.com>
63
CC: Eric Blake <eblake@redhat.com>
64
CC: Paolo Bonzini <pbonzini@redhat.com>
65
Reported-by: Lukáš Doktor <ldoktor@redhat.com>
66
Signed-off-by: Peter Xu <peterx@redhat.com>
67
Tested-by: Thomas Huth <thuth@redhat.com>
68
Message-id: 20190129051432.22023-1-peterx@redhat.com
69
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
70
---
14
---
71
iothread.c | 6 +++++-
15
docs/tools/virtiofsd.rst | 5 +++++
72
1 file changed, 5 insertions(+), 1 deletion(-)
16
tools/virtiofsd/helper.c | 3 +++
17
2 files changed, 8 insertions(+)
73
18
74
diff --git a/iothread.c b/iothread.c
19
diff --git a/docs/tools/virtiofsd.rst b/docs/tools/virtiofsd.rst
75
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
76
--- a/iothread.c
21
--- a/docs/tools/virtiofsd.rst
77
+++ b/iothread.c
22
+++ b/docs/tools/virtiofsd.rst
78
@@ -XXX,XX +XXX,XX @@ static void *iothread_run(void *opaque)
23
@@ -XXX,XX +XXX,XX @@ Options
79
while (iothread->running) {
24
label. Server will try to set that label on newly created file
80
aio_poll(iothread->ctx, true);
25
atomically wherever possible.
81
26
82
- if (atomic_read(&iothread->worker_context)) {
27
+ * killpriv_v2|no_killpriv_v2 -
83
+ /*
28
+ Enable/disable ``FUSE_HANDLE_KILLPRIV_V2`` support. KILLPRIV_V2 is enabled
84
+ * We must check the running state again in case it was
29
+ by default as long as the client supports it. Enabling this option helps
85
+ * changed in previous aio_poll()
30
+ with performance in write path.
86
+ */
31
+
87
+ if (iothread->running && atomic_read(&iothread->worker_context)) {
32
.. option:: --socket-path=PATH
88
GMainLoop *loop;
33
89
34
Listen on vhost-user UNIX domain socket at PATH.
90
g_main_context_push_thread_default(iothread->worker_context);
35
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/tools/virtiofsd/helper.c
38
+++ b/tools/virtiofsd/helper.c
39
@@ -XXX,XX +XXX,XX @@ void fuse_cmdline_help(void)
40
" -o announce_submounts Announce sub-mount points to the guest\n"
41
" -o posix_acl/no_posix_acl Enable/Disable posix_acl. (default: disabled)\n"
42
" -o security_label/no_security_label Enable/Disable security label. (default: disabled)\n"
43
+ " -o killpriv_v2/no_killpriv_v2\n"
44
+ " Enable/Disable FUSE_HANDLE_KILLPRIV_V2.\n"
45
+ " (default: enabled as long as client supports it)\n"
46
);
47
}
48
91
--
49
--
92
2.20.1
50
2.35.1
93
94
diff view generated by jsdifflib