1 | The following changes since commit 508ba0f7e2092d3ca56e3f75e894d52d8b94818e: | 1 | The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20171109' into staging (2017-11-13 11:41:47 +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 0761562687e0d8135310a94b1d3e08376387c027: | 9 | for you to fetch changes up to d45c83328feab2e4083991693160f0a417cfd9b0: |
10 | 10 | ||
11 | qemu-iotests: Test I/O limits with removable media (2017-11-13 15:46:26 +0000) | 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 | The following disk I/O throttling fixes solve recent bugs. | 16 | Small contrib/vhost-user-blk, contrib/vhost-user-scsi, and tools/virtiofsd |
17 | improvements. | ||
17 | 18 | ||
18 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
19 | 20 | ||
20 | Alberto Garcia (3): | 21 | Liu Yiding (1): |
21 | block: Check for inserted BlockDriverState in blk_io_limits_disable() | 22 | virtiofsd: Add docs/helper for killpriv_v2/no_killpriv_v2 option |
22 | block: Leave valid throttle timers when removing a BDS from a backend | 23 | |
23 | qemu-iotests: Test I/O limits with removable media | 24 | Sakshi Kaushik (1): |
25 | Implements Backend Program conventions for vhost-user-scsi | ||
24 | 26 | ||
25 | Stefan Hajnoczi (1): | 27 | Stefan Hajnoczi (1): |
26 | throttle-groups: drain before detaching ThrottleState | 28 | contrib/vhost-user-blk: add missing GOptionEntry NULL terminator |
27 | 29 | ||
28 | Zhengui (1): | 30 | docs/tools/virtiofsd.rst | 5 ++ |
29 | block: all I/O should be completed before removing throttle timers. | 31 | contrib/vhost-user-blk/vhost-user-blk.c | 3 +- |
30 | 32 | contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++-------- | |
31 | block/block-backend.c | 36 ++++++++++++++++++--------- | 33 | tools/virtiofsd/helper.c | 3 + |
32 | block/throttle-groups.c | 6 +++++ | 34 | 4 files changed, 62 insertions(+), 26 deletions(-) |
33 | tests/qemu-iotests/093 | 62 ++++++++++++++++++++++++++++++++++++++++++++++ | ||
34 | tests/qemu-iotests/093.out | 4 +-- | ||
35 | 4 files changed, 94 insertions(+), 14 deletions(-) | ||
36 | 35 | ||
37 | -- | 36 | -- |
38 | 2.13.6 | 37 | 2.35.1 |
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhengui <lizhengui@huawei.com> | ||
2 | 1 | ||
3 | In blk_remove_bs, all I/O should be completed before removing throttle | ||
4 | timers. If there has inflight I/O, removing throttle timers here will | ||
5 | cause the inflight I/O never return. | ||
6 | This patch add bdrv_drained_begin before throttle_timers_detach_aio_context | ||
7 | to let all I/O completed before removing throttle timers. | ||
8 | |||
9 | [Moved declaration of bs as suggested by Alberto Garcia | ||
10 | <berto@igalia.com>. | ||
11 | --Stefan] | ||
12 | |||
13 | Signed-off-by: Zhengui <lizhengui@huawei.com> | ||
14 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
16 | Message-id: 1508564040-120700-1-git-send-email-lizhengui@huawei.com | ||
17 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
18 | --- | ||
19 | block/block-backend.c | 4 ++++ | ||
20 | 1 file changed, 4 insertions(+) | ||
21 | |||
22 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/block/block-backend.c | ||
25 | +++ b/block/block-backend.c | ||
26 | @@ -XXX,XX +XXX,XX @@ BlockBackend *blk_by_public(BlockBackendPublic *public) | ||
27 | */ | ||
28 | void blk_remove_bs(BlockBackend *blk) | ||
29 | { | ||
30 | + BlockDriverState *bs; | ||
31 | ThrottleTimers *tt; | ||
32 | |||
33 | notifier_list_notify(&blk->remove_bs_notifiers, blk); | ||
34 | if (blk->public.throttle_group_member.throttle_state) { | ||
35 | tt = &blk->public.throttle_group_member.throttle_timers; | ||
36 | + bs = blk_bs(blk); | ||
37 | + bdrv_drained_begin(bs); | ||
38 | throttle_timers_detach_aio_context(tt); | ||
39 | + bdrv_drained_end(bs); | ||
40 | } | ||
41 | |||
42 | blk_update_root_state(blk); | ||
43 | -- | ||
44 | 2.13.6 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | I/O requests hang after stop/cont commands at least since QEMU 2.10.0 | ||
2 | with -drive iops=100: | ||
3 | 1 | ||
4 | (guest)$ dd if=/dev/zero of=/dev/vdb oflag=direct count=1000 | ||
5 | (qemu) stop | ||
6 | (qemu) cont | ||
7 | ...I/O is stuck... | ||
8 | |||
9 | This happens because blk_set_aio_context() detaches the ThrottleState | ||
10 | while requests may still be in flight: | ||
11 | |||
12 | if (tgm->throttle_state) { | ||
13 | throttle_group_detach_aio_context(tgm); | ||
14 | throttle_group_attach_aio_context(tgm, new_context); | ||
15 | } | ||
16 | |||
17 | This patch encloses the detach/attach calls in a drained region so no | ||
18 | I/O request is left hanging. Also add assertions so we don't make the | ||
19 | same mistake again in the future. | ||
20 | |||
21 | Reported-by: Yongxue Hong <yhong@redhat.com> | ||
22 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
23 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
24 | Message-id: 20171110151934.16883-1-stefanha@redhat.com | ||
25 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
26 | --- | ||
27 | block/block-backend.c | 2 ++ | ||
28 | block/throttle-groups.c | 6 ++++++ | ||
29 | 2 files changed, 8 insertions(+) | ||
30 | |||
31 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/block/block-backend.c | ||
34 | +++ b/block/block-backend.c | ||
35 | @@ -XXX,XX +XXX,XX @@ void blk_set_aio_context(BlockBackend *blk, AioContext *new_context) | ||
36 | |||
37 | if (bs) { | ||
38 | if (tgm->throttle_state) { | ||
39 | + bdrv_drained_begin(bs); | ||
40 | throttle_group_detach_aio_context(tgm); | ||
41 | throttle_group_attach_aio_context(tgm, new_context); | ||
42 | + bdrv_drained_end(bs); | ||
43 | } | ||
44 | bdrv_set_aio_context(bs, new_context); | ||
45 | } | ||
46 | diff --git a/block/throttle-groups.c b/block/throttle-groups.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/block/throttle-groups.c | ||
49 | +++ b/block/throttle-groups.c | ||
50 | @@ -XXX,XX +XXX,XX @@ void throttle_group_attach_aio_context(ThrottleGroupMember *tgm, | ||
51 | void throttle_group_detach_aio_context(ThrottleGroupMember *tgm) | ||
52 | { | ||
53 | ThrottleTimers *tt = &tgm->throttle_timers; | ||
54 | + | ||
55 | + /* Requests must have been drained */ | ||
56 | + assert(tgm->pending_reqs[0] == 0 && tgm->pending_reqs[1] == 0); | ||
57 | + assert(qemu_co_queue_empty(&tgm->throttled_reqs[0])); | ||
58 | + assert(qemu_co_queue_empty(&tgm->throttled_reqs[1])); | ||
59 | + | ||
60 | throttle_timers_detach_aio_context(tt); | ||
61 | tgm->aio_context = NULL; | ||
62 | } | ||
63 | -- | ||
64 | 2.13.6 | ||
65 | |||
66 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Sakshi Kaushik <sakshikaushik717@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | If a BlockBackend has I/O limits set then its ThrottleGroupMember | 3 | Signed-off-by: Sakshi Kaushik <sakshikaushik717@gmail.com> |
4 | structure uses the AioContext from its attached BlockDriverState. | 4 | Message-id: 20220406162410.8536-1-sakshikaushik717@gmail.com |
5 | Those two contexts must be kept in sync manually. This is not | ||
6 | ideal and will be fixed in the future by removing the throttling | ||
7 | configuration from the BlockBackend and storing it in an implicit | ||
8 | filter node instead, but for now we have to live with this. | ||
9 | 5 | ||
10 | When you remove the BlockDriverState from the backend then the | 6 | [Name the iSCSI URL long option --iscsi-uri instead of --iscsi_uri for |
11 | throttle timers are destroyed. If a new BlockDriverState is later | 7 | consistency, fix --fd which was rejected due to an outdated |
12 | inserted then they are created again using the new AioContext. | 8 | --socket-path check, and add missing entries[] terminator. |
13 | |||
14 | There are a couple of problems with this: | ||
15 | |||
16 | a) The code manipulates the timers directly, leaving the | ||
17 | ThrottleGroupMember.aio_context field in an inconsisent state. | ||
18 | |||
19 | b) If you remove the I/O limits (e.g by destroying the backend) | ||
20 | when the timers are gone then throttle_group_unregister_tgm() | ||
21 | will attempt to destroy them again, crashing QEMU. | ||
22 | |||
23 | While b) could be fixed easily by allowing the timers to be freed | ||
24 | twice, this would result in a situation in which we can no longer | ||
25 | guarantee that a valid ThrottleState has a valid AioContext and | ||
26 | timers. | ||
27 | |||
28 | This patch ensures that the timers and AioContext are always valid | ||
29 | when I/O limits are set, regardless of whether the BlockBackend has a | ||
30 | BlockDriverState inserted or not. | ||
31 | |||
32 | [Fixed "There'a" typo as suggested by Max Reitz <mreitz@redhat.com> | ||
33 | --Stefan] | 9 | --Stefan] |
34 | 10 | ||
35 | Reported-by: sochin jiang <sochin.jiang@huawei.com> | ||
36 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
37 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
38 | Message-id: e089c66e7c20289b046d782cea4373b765c5bc1d.1510339534.git.berto@igalia.com | ||
39 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
40 | --- | 12 | --- |
41 | block/block-backend.c | 16 ++++++++-------- | 13 | contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++-------- |
42 | 1 file changed, 8 insertions(+), 8 deletions(-) | 14 | 1 file changed, 52 insertions(+), 25 deletions(-) |
43 | 15 | ||
44 | diff --git a/block/block-backend.c b/block/block-backend.c | 16 | diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c |
45 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/block/block-backend.c | 18 | --- a/contrib/vhost-user-scsi/vhost-user-scsi.c |
47 | +++ b/block/block-backend.c | 19 | +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c |
48 | @@ -XXX,XX +XXX,XX @@ BlockBackend *blk_by_public(BlockBackendPublic *public) | 20 | @@ -XXX,XX +XXX,XX @@ fail: |
49 | */ | 21 | |
50 | void blk_remove_bs(BlockBackend *blk) | 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) | ||
51 | { | 42 | { |
52 | + ThrottleGroupMember *tgm = &blk->public.throttle_group_member; | 43 | VusDev *vdev_scsi = NULL; |
53 | BlockDriverState *bs; | 44 | - char *unix_fn = NULL; |
54 | - ThrottleTimers *tt; | 45 | - char *iscsi_uri = NULL; |
55 | 46 | - int lsock = -1, csock = -1, opt, err = EXIT_SUCCESS; | |
56 | notifier_list_notify(&blk->remove_bs_notifiers, blk); | 47 | + int lsock = -1, csock = -1, err = EXIT_SUCCESS; |
57 | - if (blk->public.throttle_group_member.throttle_state) { | 48 | |
58 | - tt = &blk->public.throttle_group_member.throttle_timers; | 49 | - while ((opt = getopt(argc, argv, "u:i:")) != -1) { |
59 | + if (tgm->throttle_state) { | 50 | - switch (opt) { |
60 | bs = blk_bs(blk); | 51 | - case 'h': |
61 | bdrv_drained_begin(bs); | 52 | - goto help; |
62 | - throttle_timers_detach_aio_context(tt); | 53 | - case 'u': |
63 | + throttle_group_detach_aio_context(tgm); | 54 | - unix_fn = g_strdup(optarg); |
64 | + throttle_group_attach_aio_context(tgm, qemu_get_aio_context()); | 55 | - break; |
65 | bdrv_drained_end(bs); | 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; | ||
66 | } | 77 | } |
67 | 78 | - if (!unix_fn || !iscsi_uri) { | |
68 | @@ -XXX,XX +XXX,XX @@ void blk_remove_bs(BlockBackend *blk) | 79 | + |
69 | */ | 80 | + if (!iscsi_uri) { |
70 | int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp) | 81 | goto help; |
71 | { | ||
72 | + ThrottleGroupMember *tgm = &blk->public.throttle_group_member; | ||
73 | blk->root = bdrv_root_attach_child(bs, "root", &child_root, | ||
74 | blk->perm, blk->shared_perm, blk, errp); | ||
75 | if (blk->root == NULL) { | ||
76 | @@ -XXX,XX +XXX,XX @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp) | ||
77 | bdrv_ref(bs); | ||
78 | |||
79 | notifier_list_notify(&blk->insert_bs_notifiers, blk); | ||
80 | - if (blk->public.throttle_group_member.throttle_state) { | ||
81 | - throttle_timers_attach_aio_context( | ||
82 | - &blk->public.throttle_group_member.throttle_timers, | ||
83 | - bdrv_get_aio_context(bs)); | ||
84 | + if (tgm->throttle_state) { | ||
85 | + throttle_group_detach_aio_context(tgm); | ||
86 | + throttle_group_attach_aio_context(tgm, bdrv_get_aio_context(bs)); | ||
87 | } | 82 | } |
88 | 83 | ||
89 | return 0; | 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; | ||
90 | -- | 134 | -- |
91 | 2.13.6 | 135 | 2.35.1 |
92 | |||
93 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.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 | This test hotplugs a CD drive to a VM and checks that I/O limits can | 6 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
4 | be set only when the drive has media inserted and that they are kept | 7 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> |
5 | when the media is replaced. | 8 | Message-id: 20220411150057.3009667-1-stefanha@redhat.com |
6 | |||
7 | This also tests the removal of a device with valid I/O limits set but | ||
8 | no media inserted. This involves deleting and disabling the limits | ||
9 | of a BlockBackend without BlockDriverState, a scenario that has been | ||
10 | crashing until the fixes from the last couple of patches. | ||
11 | |||
12 | [Python PEP8 fixup: "Don't use spaces are the = sign when used to | ||
13 | indicate a keyword argument or a default parameter value" | ||
14 | --Stefan] | ||
15 | |||
16 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
17 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
18 | Message-id: 071eb397118ed207c5a7f01d58766e415ee18d6a.1510339534.git.berto@igalia.com | ||
19 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
20 | --- | 10 | --- |
21 | tests/qemu-iotests/093 | 62 ++++++++++++++++++++++++++++++++++++++++++++++ | 11 | contrib/vhost-user-blk/vhost-user-blk.c | 3 ++- |
22 | tests/qemu-iotests/093.out | 4 +-- | 12 | 1 file changed, 2 insertions(+), 1 deletion(-) |
23 | 2 files changed, 64 insertions(+), 2 deletions(-) | ||
24 | 13 | ||
25 | diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093 | 14 | diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c |
26 | index XXXXXXX..XXXXXXX 100755 | ||
27 | --- a/tests/qemu-iotests/093 | ||
28 | +++ b/tests/qemu-iotests/093 | ||
29 | @@ -XXX,XX +XXX,XX @@ class ThrottleTestGroupNames(iotests.QMPTestCase): | ||
30 | groupname = "group%d" % i | ||
31 | self.verify_name(devname, groupname) | ||
32 | |||
33 | +class ThrottleTestRemovableMedia(iotests.QMPTestCase): | ||
34 | + def setUp(self): | ||
35 | + self.vm = iotests.VM() | ||
36 | + if iotests.qemu_default_machine == 's390-ccw-virtio': | ||
37 | + self.vm.add_device("virtio-scsi-ccw,id=virtio-scsi") | ||
38 | + else: | ||
39 | + self.vm.add_device("virtio-scsi-pci,id=virtio-scsi") | ||
40 | + self.vm.launch() | ||
41 | + | ||
42 | + def tearDown(self): | ||
43 | + self.vm.shutdown() | ||
44 | + | ||
45 | + def test_removable_media(self): | ||
46 | + # Add a couple of dummy nodes named cd0 and cd1 | ||
47 | + result = self.vm.qmp("blockdev-add", driver="null-aio", | ||
48 | + node_name="cd0") | ||
49 | + self.assert_qmp(result, 'return', {}) | ||
50 | + result = self.vm.qmp("blockdev-add", driver="null-aio", | ||
51 | + node_name="cd1") | ||
52 | + self.assert_qmp(result, 'return', {}) | ||
53 | + | ||
54 | + # Attach a CD drive with cd0 inserted | ||
55 | + result = self.vm.qmp("device_add", driver="scsi-cd", | ||
56 | + id="dev0", drive="cd0") | ||
57 | + self.assert_qmp(result, 'return', {}) | ||
58 | + | ||
59 | + # Set I/O limits | ||
60 | + args = { "id": "dev0", "iops": 100, "iops_rd": 0, "iops_wr": 0, | ||
61 | + "bps": 50, "bps_rd": 0, "bps_wr": 0 } | ||
62 | + result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **args) | ||
63 | + self.assert_qmp(result, 'return', {}) | ||
64 | + | ||
65 | + # Check that the I/O limits have been set | ||
66 | + result = self.vm.qmp("query-block") | ||
67 | + self.assert_qmp(result, 'return[0]/inserted/iops', 100) | ||
68 | + self.assert_qmp(result, 'return[0]/inserted/bps', 50) | ||
69 | + | ||
70 | + # Now eject cd0 and insert cd1 | ||
71 | + result = self.vm.qmp("blockdev-open-tray", id='dev0') | ||
72 | + self.assert_qmp(result, 'return', {}) | ||
73 | + result = self.vm.qmp("x-blockdev-remove-medium", id='dev0') | ||
74 | + self.assert_qmp(result, 'return', {}) | ||
75 | + result = self.vm.qmp("x-blockdev-insert-medium", id='dev0', node_name='cd1') | ||
76 | + self.assert_qmp(result, 'return', {}) | ||
77 | + | ||
78 | + # Check that the I/O limits are still the same | ||
79 | + result = self.vm.qmp("query-block") | ||
80 | + self.assert_qmp(result, 'return[0]/inserted/iops', 100) | ||
81 | + self.assert_qmp(result, 'return[0]/inserted/bps', 50) | ||
82 | + | ||
83 | + # Eject cd1 | ||
84 | + result = self.vm.qmp("x-blockdev-remove-medium", id='dev0') | ||
85 | + self.assert_qmp(result, 'return', {}) | ||
86 | + | ||
87 | + # Check that we can't set limits if the device has no medium | ||
88 | + result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **args) | ||
89 | + self.assert_qmp(result, 'error/class', 'GenericError') | ||
90 | + | ||
91 | + # Remove the CD drive | ||
92 | + result = self.vm.qmp("device_del", id='dev0') | ||
93 | + self.assert_qmp(result, 'return', {}) | ||
94 | + | ||
95 | |||
96 | if __name__ == '__main__': | ||
97 | iotests.main(supported_fmts=["raw"]) | ||
98 | diff --git a/tests/qemu-iotests/093.out b/tests/qemu-iotests/093.out | ||
99 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
100 | --- a/tests/qemu-iotests/093.out | 16 | --- a/contrib/vhost-user-blk/vhost-user-blk.c |
101 | +++ b/tests/qemu-iotests/093.out | 17 | +++ b/contrib/vhost-user-blk/vhost-user-blk.c |
102 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static GOptionEntry entries[] = { |
103 | -....... | 19 | {"blk-file", 'b', 0, G_OPTION_ARG_FILENAME, &opt_blk_file, |
104 | +........ | 20 | "block device or file path", "PATH"}, |
105 | ---------------------------------------------------------------------- | 21 | { "read-only", 'r', 0, G_OPTION_ARG_NONE, &opt_read_only, |
106 | -Ran 7 tests | 22 | - "Enable read-only", NULL } |
107 | +Ran 8 tests | 23 | + "Enable read-only", NULL }, |
108 | 24 | + { NULL, }, | |
109 | OK | 25 | }; |
26 | |||
27 | int main(int argc, char **argv) | ||
110 | -- | 28 | -- |
111 | 2.13.6 | 29 | 2.35.1 |
112 | |||
113 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Liu Yiding <liuyd.fnst@fujitsu.com> |
---|---|---|---|
2 | 2 | ||
3 | When you set I/O limits using block_set_io_throttle or the command | 3 | virtiofsd has introduced killpriv_v2/no_killpriv_v2 for a while. Add |
4 | line throttling.* options they are kept in the BlockBackend regardless | 4 | description of it to docs/helper. |
5 | of whether a BlockDriverState is attached to the backend or not. | ||
6 | 5 | ||
7 | Therefore when removing the limits using blk_io_limits_disable() we | 6 | Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com> |
8 | need to check if there's a BDS before attempting to drain it, else it | 7 | Message-Id: <20220421095151.2231099-1-liuyd.fnst@fujitsu.com> |
9 | will crash QEMU. This can be reproduced very easily using HMP: | ||
10 | 8 | ||
11 | (qemu) drive_add 0 if=none,throttling.iops-total=5000 | 9 | [Small documentation fixes: s/as client supports/as the client supports/ |
12 | (qemu) drive_del none0 | 10 | and s/. /. /. |
11 | --Stefan] | ||
13 | 12 | ||
14 | Reported-by: sochin jiang <sochin.jiang@huawei.com> | ||
15 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
16 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
17 | Message-id: 0d3a67ce8d948bb33e08672564714dcfb76a3d8c.1510339534.git.berto@igalia.com | ||
18 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
19 | --- | 14 | --- |
20 | block/block-backend.c | 14 ++++++++++---- | 15 | docs/tools/virtiofsd.rst | 5 +++++ |
21 | 1 file changed, 10 insertions(+), 4 deletions(-) | 16 | tools/virtiofsd/helper.c | 3 +++ |
17 | 2 files changed, 8 insertions(+) | ||
22 | 18 | ||
23 | diff --git a/block/block-backend.c b/block/block-backend.c | 19 | diff --git a/docs/tools/virtiofsd.rst b/docs/tools/virtiofsd.rst |
24 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/block/block-backend.c | 21 | --- a/docs/tools/virtiofsd.rst |
26 | +++ b/block/block-backend.c | 22 | +++ b/docs/tools/virtiofsd.rst |
27 | @@ -XXX,XX +XXX,XX @@ void blk_set_io_limits(BlockBackend *blk, ThrottleConfig *cfg) | 23 | @@ -XXX,XX +XXX,XX @@ Options |
28 | 24 | label. Server will try to set that label on newly created file | |
29 | void blk_io_limits_disable(BlockBackend *blk) | 25 | atomically wherever possible. |
30 | { | 26 | |
31 | - assert(blk->public.throttle_group_member.throttle_state); | 27 | + * killpriv_v2|no_killpriv_v2 - |
32 | - bdrv_drained_begin(blk_bs(blk)); | 28 | + Enable/disable ``FUSE_HANDLE_KILLPRIV_V2`` support. KILLPRIV_V2 is enabled |
33 | - throttle_group_unregister_tgm(&blk->public.throttle_group_member); | 29 | + by default as long as the client supports it. Enabling this option helps |
34 | - bdrv_drained_end(blk_bs(blk)); | 30 | + with performance in write path. |
35 | + BlockDriverState *bs = blk_bs(blk); | 31 | + |
36 | + ThrottleGroupMember *tgm = &blk->public.throttle_group_member; | 32 | .. option:: --socket-path=PATH |
37 | + assert(tgm->throttle_state); | 33 | |
38 | + if (bs) { | 34 | Listen on vhost-user UNIX domain socket at PATH. |
39 | + bdrv_drained_begin(bs); | 35 | diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c |
40 | + } | 36 | index XXXXXXX..XXXXXXX 100644 |
41 | + throttle_group_unregister_tgm(tgm); | 37 | --- a/tools/virtiofsd/helper.c |
42 | + if (bs) { | 38 | +++ b/tools/virtiofsd/helper.c |
43 | + bdrv_drained_end(bs); | 39 | @@ -XXX,XX +XXX,XX @@ void fuse_cmdline_help(void) |
44 | + } | 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 | ); | ||
45 | } | 47 | } |
46 | 48 | ||
47 | /* should be called before blk_set_io_limits if a limit is set */ | ||
48 | -- | 49 | -- |
49 | 2.13.6 | 50 | 2.35.1 |
50 | |||
51 | diff view generated by jsdifflib |