1 | The following changes since commit 718d7f4f9cf772e5784093d8e6085680a235acdb: | 1 | The following changes since commit cf7ca7d5b9faca13f1f8e3ea92cfb2f741eb0c0e: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2017-07-18 13:09:51 +0100) | 3 | Merge remote-tracking branch 'remotes/stefanha-gitlab/tags/tracing-pull-request' into staging (2021-02-01 16:28:00 +0000) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the Git repository at: |
6 | |||
7 | 6 | ||
8 | git://repo.or.cz/qemu/kevin.git tags/for-upstream | 7 | git://repo.or.cz/qemu/kevin.git tags/for-upstream |
9 | 8 | ||
10 | for you to fetch changes up to 6e6e55f5c2e5b520d6506c2716287ba3b5d1bbc8: | 9 | for you to fetch changes up to 26513a01741f51650f5dd716681995359794ba6f: |
11 | 10 | ||
12 | qemu-img: Check for backing image if specified during create (2017-07-18 15:27:37 +0200) | 11 | block: Fix VM size column width in bdrv_snapshot_dump() (2021-02-02 17:23:55 +0100) |
13 | 12 | ||
14 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
15 | Block layer patches | 14 | Block layer patches: |
15 | |||
16 | - Fix double processing of nodes in bdrv_set_aio_context() | ||
17 | - Fix potential hang in block export shutdown | ||
18 | - block/nvme: Minor tracing improvements | ||
19 | - iotests: Some more fixups for the 'check' rewrite | ||
20 | - MAINTAINERS: Add Vladimir as co-maintainer for Block Jobs | ||
16 | 21 | ||
17 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
18 | Hervé Poussineau (4): | 23 | Kevin Wolf (3): |
19 | vvfat: add constants for special values of name[0] | 24 | iotests: Revert emulator selection to old behaviour |
20 | vvfat: add a constant for bootsector name | 25 | iotests: Fix -makecheck output |
21 | vvfat: correctly parse non-ASCII short and long file names | 26 | block: Fix VM size column width in bdrv_snapshot_dump() |
22 | vvfat: initialize memory after allocating it | ||
23 | 27 | ||
24 | John Snow (2): | 28 | Philippe Mathieu-Daudé (2): |
25 | blockdev: move BDRV_O_NO_BACKING option forward | 29 | block/nvme: Properly display doorbell stride length in trace event |
26 | qemu-img: Check for backing image if specified during create | 30 | block/nvme: Trace NVMe spec version supported by the controller |
27 | 31 | ||
28 | Kevin Wolf (10): | 32 | Sergio Lopez (2): |
29 | commit: Add NULL check for overlay_bs | 33 | block: Avoid processing BDS twice in bdrv_set_aio_context_ignore() |
30 | block: Make blk_get_attached_dev_id() public | 34 | block: move blk_exp_close_all() to qemu_cleanup() |
31 | block/qapi: Add qdev device name to query-block | ||
32 | block: Make blk_all_next() public | ||
33 | block/qapi: Use blk_all_next() for query-block | ||
34 | block: List anonymous device BBs in query-block | ||
35 | ide: bdrv_attach_dev() for empty CD-ROM | ||
36 | scsi-disk: bdrv_attach_dev() for empty CD-ROM | ||
37 | qemu-iotests: Test 'info block' | ||
38 | qemu-iotests: Test unplug of -device without drive | ||
39 | 35 | ||
40 | Manos Pitsidianakis (2): | 36 | Vladimir Sementsov-Ogievskiy (3): |
41 | block: add clock_type field to ThrottleGroup | 37 | MAINTAINERS: Add Vladimir as co-maintainer for Block Jobs |
42 | block: remove timer canceling in throttle_config() | 38 | iotests/297: pylint: ignore too many statements |
39 | iotests: check: return 1 on failure | ||
43 | 40 | ||
44 | Max Reitz (1): | 41 | block.c | 35 +++++++++++++++++++++++++++-------- |
45 | block/vvfat: Fix compiler warning with gcc 7 | 42 | block/nvme.c | 8 +++++++- |
43 | block/qapi.c | 4 ++-- | ||
44 | qemu-nbd.c | 1 + | ||
45 | softmmu/runstate.c | 9 +++++++++ | ||
46 | storage-daemon/qemu-storage-daemon.c | 1 + | ||
47 | tests/qemu-iotests/testenv.py | 2 +- | ||
48 | tests/qemu-iotests/testrunner.py | 10 +++++++--- | ||
49 | MAINTAINERS | 10 ++++++++++ | ||
50 | block/trace-events | 1 + | ||
51 | tests/qemu-iotests/check | 5 ++++- | ||
52 | tests/qemu-iotests/pylintrc | 2 ++ | ||
53 | 12 files changed, 72 insertions(+), 16 deletions(-) | ||
46 | 54 | ||
47 | Peter Maydell (2): | ||
48 | block/vmdk: Report failures in vmdk_read_cid() | ||
49 | block/vpc.c: Handle write failures in get_image_offset() | ||
50 | 55 | ||
51 | block.c | 94 ++++---- | ||
52 | block/block-backend.c | 5 +- | ||
53 | block/commit.c | 4 +- | ||
54 | block/qapi.c | 20 +- | ||
55 | block/throttle-groups.c | 28 +-- | ||
56 | block/vmdk.c | 44 +++- | ||
57 | block/vpc.c | 30 ++- | ||
58 | block/vvfat.c | 90 +++++--- | ||
59 | blockdev.c | 11 +- | ||
60 | fsdev/qemu-fsdev-throttle.c | 2 +- | ||
61 | hmp.c | 11 +- | ||
62 | hw/ide/qdev.c | 3 + | ||
63 | hw/scsi/scsi-disk.c | 5 + | ||
64 | include/qemu/throttle.h | 2 +- | ||
65 | include/sysemu/block-backend.h | 2 + | ||
66 | qapi/block-core.json | 9 +- | ||
67 | qemu-img-cmds.hx | 4 +- | ||
68 | qemu-img.c | 16 +- | ||
69 | qemu-img.texi | 9 +- | ||
70 | tests/qemu-iotests/067 | 13 ++ | ||
71 | tests/qemu-iotests/067.out | 40 ++++ | ||
72 | tests/qemu-iotests/082 | 4 +- | ||
73 | tests/qemu-iotests/082.out | 4 +- | ||
74 | tests/qemu-iotests/085 | 2 +- | ||
75 | tests/qemu-iotests/111.out | 1 + | ||
76 | tests/qemu-iotests/139 | 2 +- | ||
77 | tests/qemu-iotests/156 | 2 +- | ||
78 | tests/qemu-iotests/158 | 2 +- | ||
79 | tests/qemu-iotests/186 | 147 +++++++++++++ | ||
80 | tests/qemu-iotests/186.out | 489 +++++++++++++++++++++++++++++++++++++++++ | ||
81 | tests/qemu-iotests/189 | 2 +- | ||
82 | tests/qemu-iotests/group | 1 + | ||
83 | tests/test-throttle.c | 4 +- | ||
84 | util/throttle.c | 18 +- | ||
85 | 34 files changed, 958 insertions(+), 162 deletions(-) | ||
86 | create mode 100755 tests/qemu-iotests/186 | ||
87 | create mode 100644 tests/qemu-iotests/186.out | ||
88 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | I can't see how overlay_bs could become NULL with the current code, but | ||
2 | other code in this function already checks it and we can make Coverity | ||
3 | happy with this check, so let's add it. | ||
4 | 1 | ||
5 | Cc: qemu-stable@nongnu.org | ||
6 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | --- | ||
9 | block/commit.c | 4 +++- | ||
10 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/block/commit.c b/block/commit.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/block/commit.c | ||
15 | +++ b/block/commit.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void commit_complete(BlockJob *job, void *opaque) | ||
17 | |||
18 | /* Make sure overlay_bs and top stay around until bdrv_set_backing_hd() */ | ||
19 | bdrv_ref(top); | ||
20 | - bdrv_ref(overlay_bs); | ||
21 | + if (overlay_bs) { | ||
22 | + bdrv_ref(overlay_bs); | ||
23 | + } | ||
24 | |||
25 | /* Remove base node parent that still uses BLK_PERM_WRITE/RESIZE before | ||
26 | * the normal backing chain can be restored. */ | ||
27 | -- | ||
28 | 1.8.3.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Manos Pitsidianakis <el13635@mail.ntua.gr> | ||
2 | 1 | ||
3 | Clock type in throttling is currently inferred by the ThrottleTimer's | ||
4 | clock type even though it is a per-ThrottleGroup property; it doesn't | ||
5 | make sense to have different clock types in the same group. Moving this | ||
6 | to a field in ThrottleGroup can simplify some of the throttle functions. | ||
7 | |||
8 | Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr> | ||
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
11 | --- | ||
12 | block/throttle-groups.c | 20 ++++++++++---------- | ||
13 | fsdev/qemu-fsdev-throttle.c | 2 +- | ||
14 | include/qemu/throttle.h | 1 + | ||
15 | tests/test-throttle.c | 4 ++-- | ||
16 | util/throttle.c | 4 +++- | ||
17 | 5 files changed, 17 insertions(+), 14 deletions(-) | ||
18 | |||
19 | diff --git a/block/throttle-groups.c b/block/throttle-groups.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/block/throttle-groups.c | ||
22 | +++ b/block/throttle-groups.c | ||
23 | @@ -XXX,XX +XXX,XX @@ typedef struct ThrottleGroup { | ||
24 | QLIST_HEAD(, BlockBackendPublic) head; | ||
25 | BlockBackend *tokens[2]; | ||
26 | bool any_timer_armed[2]; | ||
27 | + QEMUClockType clock_type; | ||
28 | |||
29 | /* These two are protected by the global throttle_groups_lock */ | ||
30 | unsigned refcount; | ||
31 | @@ -XXX,XX +XXX,XX @@ ThrottleState *throttle_group_incref(const char *name) | ||
32 | if (!tg) { | ||
33 | tg = g_new0(ThrottleGroup, 1); | ||
34 | tg->name = g_strdup(name); | ||
35 | + tg->clock_type = QEMU_CLOCK_REALTIME; | ||
36 | + | ||
37 | + if (qtest_enabled()) { | ||
38 | + /* For testing block IO throttling only */ | ||
39 | + tg->clock_type = QEMU_CLOCK_VIRTUAL; | ||
40 | + } | ||
41 | qemu_mutex_init(&tg->lock); | ||
42 | throttle_init(&tg->ts); | ||
43 | QLIST_INIT(&tg->head); | ||
44 | @@ -XXX,XX +XXX,XX @@ static void schedule_next_request(BlockBackend *blk, bool is_write) | ||
45 | token = blk; | ||
46 | } else { | ||
47 | ThrottleTimers *tt = &blk_get_public(token)->throttle_timers; | ||
48 | - int64_t now = qemu_clock_get_ns(tt->clock_type); | ||
49 | + int64_t now = qemu_clock_get_ns(tg->clock_type); | ||
50 | timer_mod(tt->timers[is_write], now); | ||
51 | tg->any_timer_armed[is_write] = true; | ||
52 | } | ||
53 | @@ -XXX,XX +XXX,XX @@ void throttle_group_config(BlockBackend *blk, ThrottleConfig *cfg) | ||
54 | if (timer_pending(tt->timers[1])) { | ||
55 | tg->any_timer_armed[1] = false; | ||
56 | } | ||
57 | - throttle_config(ts, tt, cfg); | ||
58 | + throttle_config(ts, tg->clock_type, tt, cfg); | ||
59 | qemu_mutex_unlock(&tg->lock); | ||
60 | |||
61 | throttle_group_restart_blk(blk); | ||
62 | @@ -XXX,XX +XXX,XX @@ void throttle_group_register_blk(BlockBackend *blk, const char *groupname) | ||
63 | BlockBackendPublic *blkp = blk_get_public(blk); | ||
64 | ThrottleState *ts = throttle_group_incref(groupname); | ||
65 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); | ||
66 | - int clock_type = QEMU_CLOCK_REALTIME; | ||
67 | - | ||
68 | - if (qtest_enabled()) { | ||
69 | - /* For testing block IO throttling only */ | ||
70 | - clock_type = QEMU_CLOCK_VIRTUAL; | ||
71 | - } | ||
72 | - | ||
73 | blkp->throttle_state = ts; | ||
74 | |||
75 | qemu_mutex_lock(&tg->lock); | ||
76 | @@ -XXX,XX +XXX,XX @@ void throttle_group_register_blk(BlockBackend *blk, const char *groupname) | ||
77 | |||
78 | throttle_timers_init(&blkp->throttle_timers, | ||
79 | blk_get_aio_context(blk), | ||
80 | - clock_type, | ||
81 | + tg->clock_type, | ||
82 | read_timer_cb, | ||
83 | write_timer_cb, | ||
84 | blk); | ||
85 | diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/fsdev/qemu-fsdev-throttle.c | ||
88 | +++ b/fsdev/qemu-fsdev-throttle.c | ||
89 | @@ -XXX,XX +XXX,XX @@ void fsdev_throttle_init(FsThrottle *fst) | ||
90 | fsdev_throttle_read_timer_cb, | ||
91 | fsdev_throttle_write_timer_cb, | ||
92 | fst); | ||
93 | - throttle_config(&fst->ts, &fst->tt, &fst->cfg); | ||
94 | + throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->tt, &fst->cfg); | ||
95 | qemu_co_queue_init(&fst->throttled_reqs[0]); | ||
96 | qemu_co_queue_init(&fst->throttled_reqs[1]); | ||
97 | } | ||
98 | diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/include/qemu/throttle.h | ||
101 | +++ b/include/qemu/throttle.h | ||
102 | @@ -XXX,XX +XXX,XX @@ bool throttle_enabled(ThrottleConfig *cfg); | ||
103 | bool throttle_is_valid(ThrottleConfig *cfg, Error **errp); | ||
104 | |||
105 | void throttle_config(ThrottleState *ts, | ||
106 | + QEMUClockType clock_type, | ||
107 | ThrottleTimers *tt, | ||
108 | ThrottleConfig *cfg); | ||
109 | |||
110 | diff --git a/tests/test-throttle.c b/tests/test-throttle.c | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/tests/test-throttle.c | ||
113 | +++ b/tests/test-throttle.c | ||
114 | @@ -XXX,XX +XXX,XX @@ static void test_config_functions(void) | ||
115 | read_timer_cb, write_timer_cb, &ts); | ||
116 | /* structure reset by throttle_init previous_leak should be null */ | ||
117 | g_assert(!ts.previous_leak); | ||
118 | - throttle_config(&ts, &tt, &orig_cfg); | ||
119 | + throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &orig_cfg); | ||
120 | |||
121 | /* has previous leak been initialized by throttle_config ? */ | ||
122 | g_assert(ts.previous_leak); | ||
123 | @@ -XXX,XX +XXX,XX @@ static bool do_test_accounting(bool is_ops, /* are we testing bps or ops */ | ||
124 | throttle_init(&ts); | ||
125 | throttle_timers_init(&tt, ctx, QEMU_CLOCK_VIRTUAL, | ||
126 | read_timer_cb, write_timer_cb, &ts); | ||
127 | - throttle_config(&ts, &tt, &cfg); | ||
128 | + throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &cfg); | ||
129 | |||
130 | /* account a read */ | ||
131 | throttle_account(&ts, false, size); | ||
132 | diff --git a/util/throttle.c b/util/throttle.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/util/throttle.c | ||
135 | +++ b/util/throttle.c | ||
136 | @@ -XXX,XX +XXX,XX @@ static void throttle_cancel_timer(QEMUTimer *timer) | ||
137 | /* Used to configure the throttle | ||
138 | * | ||
139 | * @ts: the throttle state we are working on | ||
140 | + * @clock_type: the group's clock_type | ||
141 | * @tt: the throttle timers we use in this aio context | ||
142 | * @cfg: the config to set | ||
143 | */ | ||
144 | void throttle_config(ThrottleState *ts, | ||
145 | + QEMUClockType clock_type, | ||
146 | ThrottleTimers *tt, | ||
147 | ThrottleConfig *cfg) | ||
148 | { | ||
149 | @@ -XXX,XX +XXX,XX @@ void throttle_config(ThrottleState *ts, | ||
150 | throttle_fix_bucket(&ts->cfg.buckets[i]); | ||
151 | } | ||
152 | |||
153 | - ts->previous_leak = qemu_clock_get_ns(tt->clock_type); | ||
154 | + ts->previous_leak = qemu_clock_get_ns(clock_type); | ||
155 | |||
156 | for (i = 0; i < 2; i++) { | ||
157 | throttle_cancel_timer(tt->timers[i]); | ||
158 | -- | ||
159 | 1.8.3.1 | ||
160 | |||
161 | diff view generated by jsdifflib |
1 | From: John Snow <jsnow@redhat.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | For both external_snapshot_prepare and qmp_drive_mirror, we eventually | 3 | I'm developing Qemu backup for several years, and finally new backup |
4 | append the option BDRV_O_NO_BACKING. However, we generally do so after | 4 | architecture, including block-copy generic engine and backup-top filter |
5 | we create the image. | 5 | landed upstream, great thanks to reviewers and especially to |
6 | Max Reitz! | ||
6 | 7 | ||
7 | To accommodate image creation wanting to verify that a backing file | 8 | I also have plans of moving other block-jobs onto block-copy, so that |
8 | exists or not, add this option prior to create to override checking | 9 | we finally have one generic block copying path, fast and well-formed. |
9 | the existence of the backing file. This prevents QEMU from trying to | ||
10 | re-open a backing file that's already in use (thanks to qcow2 locking). | ||
11 | 10 | ||
12 | Signed-off-by: John Snow <jsnow@redhat.com> | 11 | So, now I suggest to bring all parts of backup architecture into |
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | 12 | "Block Jobs" subsystem (actually, aio_task is shared with qcow2 and |
13 | qemu-co-shared-resource can be reused somewhere else, but I'd keep an | ||
14 | eye on them in context of block-jobs) and add myself as co-maintainer. | ||
15 | |||
16 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
17 | Message-Id: <20210128144144.27617-1-vsementsov@virtuozzo.com> | ||
18 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
19 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
20 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 21 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
15 | --- | 22 | --- |
16 | blockdev.c | 11 ++++++----- | 23 | MAINTAINERS | 10 ++++++++++ |
17 | 1 file changed, 6 insertions(+), 5 deletions(-) | 24 | 1 file changed, 10 insertions(+) |
18 | 25 | ||
19 | diff --git a/blockdev.c b/blockdev.c | 26 | diff --git a/MAINTAINERS b/MAINTAINERS |
20 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/blockdev.c | 28 | --- a/MAINTAINERS |
22 | +++ b/blockdev.c | 29 | +++ b/MAINTAINERS |
23 | @@ -XXX,XX +XXX,XX @@ static void external_snapshot_prepare(BlkActionState *common, | 30 | @@ -XXX,XX +XXX,XX @@ F: scsi/* |
24 | } | 31 | |
25 | 32 | Block Jobs | |
26 | flags = state->old_bs->open_flags; | 33 | M: John Snow <jsnow@redhat.com> |
27 | - flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_COPY_ON_READ); | 34 | +M: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
28 | + flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_COPY_ON_READ); | 35 | L: qemu-block@nongnu.org |
29 | + flags |= BDRV_O_NO_BACKING; | 36 | S: Supported |
30 | 37 | F: blockjob.c | |
31 | /* create new image w/backing file */ | 38 | @@ -XXX,XX +XXX,XX @@ F: block/commit.c |
32 | mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS; | 39 | F: block/stream.c |
33 | @@ -XXX,XX +XXX,XX @@ static void external_snapshot_prepare(BlkActionState *common, | 40 | F: block/mirror.c |
34 | qdict_put_str(options, "node-name", snapshot_node_name); | 41 | F: qapi/job.json |
35 | } | 42 | +F: block/block-copy.c |
36 | qdict_put_str(options, "driver", format); | 43 | +F: include/block/block-copy.c |
37 | - | 44 | +F: block/backup-top.h |
38 | - flags |= BDRV_O_NO_BACKING; | 45 | +F: block/backup-top.c |
39 | } | 46 | +F: include/block/aio_task.h |
40 | 47 | +F: block/aio_task.c | |
41 | state->new_bs = bdrv_open(new_image_file, snapshot_ref, options, flags, | 48 | +F: util/qemu-co-shared-resource.c |
42 | @@ -XXX,XX +XXX,XX @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) | 49 | +F: include/qemu/co-shared-resource.h |
43 | backing_mode = MIRROR_OPEN_BACKING_CHAIN; | 50 | T: git https://gitlab.com/jsnow/qemu.git jobs |
44 | } | 51 | +T: git https://src.openvz.org/scm/~vsementsov/qemu.git jobs |
45 | 52 | ||
46 | + /* Don't open backing image in create() */ | 53 | Block QAPI, monitor, command line |
47 | + flags |= BDRV_O_NO_BACKING; | 54 | M: Markus Armbruster <armbru@redhat.com> |
48 | + | ||
49 | if ((arg->sync == MIRROR_SYNC_MODE_FULL || !source) | ||
50 | && arg->mode != NEW_IMAGE_MODE_EXISTING) | ||
51 | { | ||
52 | @@ -XXX,XX +XXX,XX @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) | ||
53 | /* Mirroring takes care of copy-on-write using the source's backing | ||
54 | * file. | ||
55 | */ | ||
56 | - target_bs = bdrv_open(arg->target, NULL, options, | ||
57 | - flags | BDRV_O_NO_BACKING, errp); | ||
58 | + target_bs = bdrv_open(arg->target, NULL, options, flags, errp); | ||
59 | if (!target_bs) { | ||
60 | goto out; | ||
61 | } | ||
62 | -- | 55 | -- |
63 | 1.8.3.1 | 56 | 2.29.2 |
64 | 57 | ||
65 | 58 | diff view generated by jsdifflib |
1 | From: John Snow <jsnow@redhat.com> | 1 | From: Sergio Lopez <slp@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Or, rather, force the open of a backing image if one was specified | 3 | Some graphs may contain an indirect reference to the first BDS in the |
4 | for creation. Using a similar -unsafe option as rebase, allow qemu-img | 4 | chain that can be reached while walking it bottom->up from one its |
5 | to ignore the backing file validation if possible. | 5 | children. |
6 | 6 | ||
7 | It may not always be possible, as in the existing case when a filesize | 7 | Doubling-processing of a BDS is especially problematic for the |
8 | for the new image was not specified. | 8 | aio_notifiers, as they might attempt to work on both the old and the |
9 | new AIO contexts. | ||
9 | 10 | ||
10 | This is accomplished by shifting around the conditionals in | 11 | To avoid this problem, add every child and parent to the ignore list |
11 | bdrv_img_create, such that a backing file is always opened unless we | 12 | before actually processing them. |
12 | provide BDRV_O_NO_BACKING. qemu-img is adjusted to pass this new flag | ||
13 | when -u is provided to create. | ||
14 | 13 | ||
15 | Sorry for the heinous looking diffstat, but it's mostly whitespace. | 14 | Suggested-by: Kevin Wolf <kwolf@redhat.com> |
16 | 15 | Signed-off-by: Sergio Lopez <slp@redhat.com> | |
17 | Inspired by: https://bugzilla.redhat.com/show_bug.cgi?id=1213786 | 16 | Message-Id: <20210201125032.44713-2-slp@redhat.com> |
18 | |||
19 | Signed-off-by: John Snow <jsnow@redhat.com> | ||
20 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
21 | --- | 18 | --- |
22 | block.c | 94 +++++++++++++++++++++++++--------------------- | 19 | block.c | 34 +++++++++++++++++++++++++++------- |
23 | qemu-img-cmds.hx | 4 +- | 20 | 1 file changed, 27 insertions(+), 7 deletions(-) |
24 | qemu-img.c | 16 +++++--- | ||
25 | qemu-img.texi | 9 ++++- | ||
26 | tests/qemu-iotests/082 | 4 +- | ||
27 | tests/qemu-iotests/082.out | 4 +- | ||
28 | tests/qemu-iotests/085 | 2 +- | ||
29 | tests/qemu-iotests/111.out | 1 + | ||
30 | tests/qemu-iotests/139 | 2 +- | ||
31 | tests/qemu-iotests/156 | 2 +- | ||
32 | tests/qemu-iotests/158 | 2 +- | ||
33 | tests/qemu-iotests/189 | 2 +- | ||
34 | 12 files changed, 83 insertions(+), 59 deletions(-) | ||
35 | 21 | ||
36 | diff --git a/block.c b/block.c | 22 | diff --git a/block.c b/block.c |
37 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/block.c | 24 | --- a/block.c |
39 | +++ b/block.c | 25 | +++ b/block.c |
40 | @@ -XXX,XX +XXX,XX @@ void bdrv_img_create(const char *filename, const char *fmt, | 26 | @@ -XXX,XX +XXX,XX @@ void bdrv_set_aio_context_ignore(BlockDriverState *bs, |
41 | 27 | AioContext *new_context, GSList **ignore) | |
42 | backing_fmt = qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); | 28 | { |
43 | 29 | AioContext *old_context = bdrv_get_aio_context(bs); | |
44 | - // The size for the image must always be specified, with one exception: | 30 | - BdrvChild *child; |
45 | - // If we are using a backing file, we can obtain the size from there | 31 | + GSList *children_to_process = NULL; |
46 | + /* The size for the image must always be specified, unless we have a backing | 32 | + GSList *parents_to_process = NULL; |
47 | + * file and we have not been forbidden from opening it. */ | 33 | + GSList *entry; |
48 | size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0); | 34 | + BdrvChild *child, *parent; |
49 | - if (size == -1) { | 35 | |
50 | - if (backing_file) { | 36 | g_assert(qemu_get_current_aio_context() == qemu_get_aio_context()); |
51 | - BlockDriverState *bs; | 37 | |
52 | - char *full_backing = g_new0(char, PATH_MAX); | 38 | @@ -XXX,XX +XXX,XX @@ void bdrv_set_aio_context_ignore(BlockDriverState *bs, |
53 | - int64_t size; | 39 | continue; |
54 | - int back_flags; | 40 | } |
55 | - QDict *backing_options = NULL; | 41 | *ignore = g_slist_prepend(*ignore, child); |
56 | - | 42 | - bdrv_set_aio_context_ignore(child->bs, new_context, ignore); |
57 | - bdrv_get_full_backing_filename_from_filename(filename, backing_file, | 43 | + children_to_process = g_slist_prepend(children_to_process, child); |
58 | - full_backing, PATH_MAX, | 44 | } |
59 | - &local_err); | 45 | - QLIST_FOREACH(child, &bs->parents, next_parent) { |
60 | - if (local_err) { | 46 | - if (g_slist_find(*ignore, child)) { |
61 | - g_free(full_backing); | ||
62 | - goto out; | ||
63 | - } | ||
64 | + if (backing_file && !(flags & BDRV_O_NO_BACKING)) { | ||
65 | + BlockDriverState *bs; | ||
66 | + char *full_backing = g_new0(char, PATH_MAX); | ||
67 | + int back_flags; | ||
68 | + QDict *backing_options = NULL; | ||
69 | + | 47 | + |
70 | + bdrv_get_full_backing_filename_from_filename(filename, backing_file, | 48 | + QLIST_FOREACH(parent, &bs->parents, next_parent) { |
71 | + full_backing, PATH_MAX, | 49 | + if (g_slist_find(*ignore, parent)) { |
72 | + &local_err); | 50 | continue; |
73 | + if (local_err) { | ||
74 | + g_free(full_backing); | ||
75 | + goto out; | ||
76 | + } | ||
77 | |||
78 | - /* backing files always opened read-only */ | ||
79 | - back_flags = flags; | ||
80 | - back_flags &= ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); | ||
81 | + /* backing files always opened read-only */ | ||
82 | + back_flags = flags; | ||
83 | + back_flags &= ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); | ||
84 | |||
85 | - if (backing_fmt) { | ||
86 | - backing_options = qdict_new(); | ||
87 | - qdict_put_str(backing_options, "driver", backing_fmt); | ||
88 | - } | ||
89 | + if (backing_fmt) { | ||
90 | + backing_options = qdict_new(); | ||
91 | + qdict_put_str(backing_options, "driver", backing_fmt); | ||
92 | + } | ||
93 | |||
94 | - bs = bdrv_open(full_backing, NULL, backing_options, back_flags, | ||
95 | - &local_err); | ||
96 | - g_free(full_backing); | ||
97 | - if (!bs) { | ||
98 | - goto out; | ||
99 | - } | ||
100 | - size = bdrv_getlength(bs); | ||
101 | - if (size < 0) { | ||
102 | - error_setg_errno(errp, -size, "Could not get size of '%s'", | ||
103 | - backing_file); | ||
104 | - bdrv_unref(bs); | ||
105 | - goto out; | ||
106 | + bs = bdrv_open(full_backing, NULL, backing_options, back_flags, | ||
107 | + &local_err); | ||
108 | + g_free(full_backing); | ||
109 | + if (!bs && size != -1) { | ||
110 | + /* Couldn't open BS, but we have a size, so it's nonfatal */ | ||
111 | + warn_reportf_err(local_err, | ||
112 | + "Could not verify backing image. " | ||
113 | + "This may become an error in future versions.\n"); | ||
114 | + local_err = NULL; | ||
115 | + } else if (!bs) { | ||
116 | + /* Couldn't open bs, do not have size */ | ||
117 | + error_append_hint(&local_err, | ||
118 | + "Could not open backing image to determine size.\n"); | ||
119 | + goto out; | ||
120 | + } else { | ||
121 | + if (size == -1) { | ||
122 | + /* Opened BS, have no size */ | ||
123 | + size = bdrv_getlength(bs); | ||
124 | + if (size < 0) { | ||
125 | + error_setg_errno(errp, -size, "Could not get size of '%s'", | ||
126 | + backing_file); | ||
127 | + bdrv_unref(bs); | ||
128 | + goto out; | ||
129 | + } | ||
130 | + qemu_opt_set_number(opts, BLOCK_OPT_SIZE, size, &error_abort); | ||
131 | } | ||
132 | - | ||
133 | - qemu_opt_set_number(opts, BLOCK_OPT_SIZE, size, &error_abort); | ||
134 | - | ||
135 | bdrv_unref(bs); | ||
136 | - } else { | ||
137 | - error_setg(errp, "Image creation needs a size parameter"); | ||
138 | - goto out; | ||
139 | } | 51 | } |
140 | + } /* (backing_file && !(flags & BDRV_O_NO_BACKING)) */ | 52 | - assert(child->klass->set_aio_ctx); |
53 | - *ignore = g_slist_prepend(*ignore, child); | ||
54 | - child->klass->set_aio_ctx(child, new_context, ignore); | ||
55 | + *ignore = g_slist_prepend(*ignore, parent); | ||
56 | + parents_to_process = g_slist_prepend(parents_to_process, parent); | ||
57 | + } | ||
141 | + | 58 | + |
142 | + if (size == -1) { | 59 | + for (entry = children_to_process; |
143 | + error_setg(errp, "Image creation needs a size parameter"); | 60 | + entry != NULL; |
144 | + goto out; | 61 | + entry = g_slist_next(entry)) { |
62 | + child = entry->data; | ||
63 | + bdrv_set_aio_context_ignore(child->bs, new_context, ignore); | ||
64 | + } | ||
65 | + g_slist_free(children_to_process); | ||
66 | + | ||
67 | + for (entry = parents_to_process; | ||
68 | + entry != NULL; | ||
69 | + entry = g_slist_next(entry)) { | ||
70 | + parent = entry->data; | ||
71 | + assert(parent->klass->set_aio_ctx); | ||
72 | + parent->klass->set_aio_ctx(parent, new_context, ignore); | ||
145 | } | 73 | } |
146 | 74 | + g_slist_free(parents_to_process); | |
147 | if (!quiet) { | 75 | |
148 | diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx | 76 | bdrv_detach_aio_context(bs); |
149 | index XXXXXXX..XXXXXXX 100644 | 77 | |
150 | --- a/qemu-img-cmds.hx | ||
151 | +++ b/qemu-img-cmds.hx | ||
152 | @@ -XXX,XX +XXX,XX @@ STEXI | ||
153 | ETEXI | ||
154 | |||
155 | DEF("create", img_create, | ||
156 | - "create [-q] [--object objectdef] [-f fmt] [-b backing_file] [-F backing_fmt] [-o options] filename [size]") | ||
157 | + "create [-q] [--object objectdef] [-f fmt] [-b backing_file] [-F backing_fmt] [-u] [-o options] filename [size]") | ||
158 | STEXI | ||
159 | -@item create [--object @var{objectdef}] [-q] [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-o @var{options}] @var{filename} [@var{size}] | ||
160 | +@item create [--object @var{objectdef}] [-q] [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-u] [-o @var{options}] @var{filename} [@var{size}] | ||
161 | ETEXI | ||
162 | |||
163 | DEF("commit", img_commit, | ||
164 | diff --git a/qemu-img.c b/qemu-img.c | ||
165 | index XXXXXXX..XXXXXXX 100644 | ||
166 | --- a/qemu-img.c | ||
167 | +++ b/qemu-img.c | ||
168 | @@ -XXX,XX +XXX,XX @@ static void QEMU_NORETURN help(void) | ||
169 | " 'snapshot_id_or_name' is deprecated, use 'snapshot_param'\n" | ||
170 | " instead\n" | ||
171 | " '-c' indicates that target image must be compressed (qcow format only)\n" | ||
172 | - " '-u' enables unsafe rebasing. It is assumed that old and new backing file\n" | ||
173 | - " match exactly. The image doesn't need a working backing file before\n" | ||
174 | - " rebasing in this case (useful for renaming the backing file)\n" | ||
175 | + " '-u' allows unsafe backing chains. For rebasing, it is assumed that old and\n" | ||
176 | + " new backing file match exactly. The image doesn't need a working\n" | ||
177 | + " backing file before rebasing in this case (useful for renaming the\n" | ||
178 | + " backing file). For image creation, allow creating without attempting\n" | ||
179 | + " to open the backing file.\n" | ||
180 | " '-h' with or without a command shows this help and lists the supported formats\n" | ||
181 | " '-p' show progress of command (only certain commands)\n" | ||
182 | " '-q' use Quiet mode - do not print any output (except errors)\n" | ||
183 | @@ -XXX,XX +XXX,XX @@ static int img_create(int argc, char **argv) | ||
184 | char *options = NULL; | ||
185 | Error *local_err = NULL; | ||
186 | bool quiet = false; | ||
187 | + int flags = 0; | ||
188 | |||
189 | for(;;) { | ||
190 | static const struct option long_options[] = { | ||
191 | @@ -XXX,XX +XXX,XX @@ static int img_create(int argc, char **argv) | ||
192 | {"object", required_argument, 0, OPTION_OBJECT}, | ||
193 | {0, 0, 0, 0} | ||
194 | }; | ||
195 | - c = getopt_long(argc, argv, ":F:b:f:ho:q", | ||
196 | + c = getopt_long(argc, argv, ":F:b:f:ho:qu", | ||
197 | long_options, NULL); | ||
198 | if (c == -1) { | ||
199 | break; | ||
200 | @@ -XXX,XX +XXX,XX @@ static int img_create(int argc, char **argv) | ||
201 | case 'q': | ||
202 | quiet = true; | ||
203 | break; | ||
204 | + case 'u': | ||
205 | + flags |= BDRV_O_NO_BACKING; | ||
206 | + break; | ||
207 | case OPTION_OBJECT: { | ||
208 | QemuOpts *opts; | ||
209 | opts = qemu_opts_parse_noisily(&qemu_object_opts, | ||
210 | @@ -XXX,XX +XXX,XX @@ static int img_create(int argc, char **argv) | ||
211 | } | ||
212 | |||
213 | bdrv_img_create(filename, fmt, base_filename, base_fmt, | ||
214 | - options, img_size, 0, quiet, &local_err); | ||
215 | + options, img_size, flags, quiet, &local_err); | ||
216 | if (local_err) { | ||
217 | error_reportf_err(local_err, "%s: ", filename); | ||
218 | goto fail; | ||
219 | diff --git a/qemu-img.texi b/qemu-img.texi | ||
220 | index XXXXXXX..XXXXXXX 100644 | ||
221 | --- a/qemu-img.texi | ||
222 | +++ b/qemu-img.texi | ||
223 | @@ -XXX,XX +XXX,XX @@ If @code{-r} is specified, exit codes representing the image state refer to the | ||
224 | state after (the attempt at) repairing it. That is, a successful @code{-r all} | ||
225 | will yield the exit code 0, independently of the image state before. | ||
226 | |||
227 | -@item create [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-o @var{options}] @var{filename} [@var{size}] | ||
228 | +@item create [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-u] [-o @var{options}] @var{filename} [@var{size}] | ||
229 | |||
230 | Create the new disk image @var{filename} of size @var{size} and format | ||
231 | @var{fmt}. Depending on the file format, you can add one or more @var{options} | ||
232 | @@ -XXX,XX +XXX,XX @@ only the differences from @var{backing_file}. No size needs to be specified in | ||
233 | this case. @var{backing_file} will never be modified unless you use the | ||
234 | @code{commit} monitor command (or qemu-img commit). | ||
235 | |||
236 | +Note that a given backing file will be opened to check that it is valid. Use | ||
237 | +the @code{-u} option to enable unsafe backing file mode, which means that the | ||
238 | +image will be created even if the associated backing file cannot be opened. A | ||
239 | +matching backing file must be created or additional options be used to make the | ||
240 | +backing file specification valid when you want to use an image created this | ||
241 | +way. | ||
242 | + | ||
243 | The size can also be specified using the @var{size} option with @code{-o}, | ||
244 | it doesn't need to be specified separately in this case. | ||
245 | |||
246 | diff --git a/tests/qemu-iotests/082 b/tests/qemu-iotests/082 | ||
247 | index XXXXXXX..XXXXXXX 100755 | ||
248 | --- a/tests/qemu-iotests/082 | ||
249 | +++ b/tests/qemu-iotests/082 | ||
250 | @@ -XXX,XX +XXX,XX @@ run_qemu_img create -f $IMGFMT -o cluster_size=4k -o help "$TEST_IMG" $size | ||
251 | run_qemu_img create -f $IMGFMT -o cluster_size=4k -o \? "$TEST_IMG" $size | ||
252 | |||
253 | # Looks like a help option, but is part of the backing file name | ||
254 | -run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG",,help "$TEST_IMG" $size | ||
255 | -run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG",,\? "$TEST_IMG" $size | ||
256 | +run_qemu_img create -f $IMGFMT -u -o backing_file="$TEST_IMG",,help "$TEST_IMG" $size | ||
257 | +run_qemu_img create -f $IMGFMT -u -o backing_file="$TEST_IMG",,\? "$TEST_IMG" $size | ||
258 | |||
259 | # Try to trick qemu-img into creating escaped commas | ||
260 | run_qemu_img create -f $IMGFMT -o backing_file="$TEST_IMG", -o help "$TEST_IMG" $size | ||
261 | diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out | ||
262 | index XXXXXXX..XXXXXXX 100644 | ||
263 | --- a/tests/qemu-iotests/082.out | ||
264 | +++ b/tests/qemu-iotests/082.out | ||
265 | @@ -XXX,XX +XXX,XX @@ lazy_refcounts Postpone refcount updates | ||
266 | refcount_bits Width of a reference count entry in bits | ||
267 | nocow Turn off copy-on-write (valid only on btrfs) | ||
268 | |||
269 | -Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M | ||
270 | +Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,help TEST_DIR/t.qcow2 128M | ||
271 | Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,help cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
272 | |||
273 | -Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2 128M | ||
274 | +Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,? TEST_DIR/t.qcow2 128M | ||
275 | Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2,,? cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
276 | |||
277 | Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2, -o help TEST_DIR/t.qcow2 128M | ||
278 | diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085 | ||
279 | index XXXXXXX..XXXXXXX 100755 | ||
280 | --- a/tests/qemu-iotests/085 | ||
281 | +++ b/tests/qemu-iotests/085 | ||
282 | @@ -XXX,XX +XXX,XX @@ function add_snapshot_image() | ||
283 | { | ||
284 | base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" | ||
285 | snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}" | ||
286 | - _make_test_img -b "${base_image}" "$size" | ||
287 | + _make_test_img -u -b "${base_image}" "$size" | ||
288 | mv "${TEST_IMG}" "${snapshot_file}" | ||
289 | do_blockdev_add "$1" "'backing': '', " "${snapshot_file}" | ||
290 | } | ||
291 | diff --git a/tests/qemu-iotests/111.out b/tests/qemu-iotests/111.out | ||
292 | index XXXXXXX..XXXXXXX 100644 | ||
293 | --- a/tests/qemu-iotests/111.out | ||
294 | +++ b/tests/qemu-iotests/111.out | ||
295 | @@ -XXX,XX +XXX,XX @@ | ||
296 | QA output created by 111 | ||
297 | qemu-img: TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT.inexistent': No such file or directory | ||
298 | +Could not open backing image to determine size. | ||
299 | *** done | ||
300 | diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139 | ||
301 | index XXXXXXX..XXXXXXX 100644 | ||
302 | --- a/tests/qemu-iotests/139 | ||
303 | +++ b/tests/qemu-iotests/139 | ||
304 | @@ -XXX,XX +XXX,XX @@ class TestBlockdevDel(iotests.QMPTestCase): | ||
305 | # Add a BlockDriverState that will be used as overlay for the base_img BDS | ||
306 | def addBlockDriverStateOverlay(self, node): | ||
307 | self.checkBlockDriverState(node, False) | ||
308 | - iotests.qemu_img('create', '-f', iotests.imgfmt, | ||
309 | + iotests.qemu_img('create', '-u', '-f', iotests.imgfmt, | ||
310 | '-b', base_img, new_img, '1M') | ||
311 | opts = {'driver': iotests.imgfmt, | ||
312 | 'node-name': node, | ||
313 | diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156 | ||
314 | index XXXXXXX..XXXXXXX 100755 | ||
315 | --- a/tests/qemu-iotests/156 | ||
316 | +++ b/tests/qemu-iotests/156 | ||
317 | @@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $QEMU_HANDLE \ | ||
318 | 'return' | ||
319 | |||
320 | # Create snapshot | ||
321 | -TEST_IMG="$TEST_IMG.overlay" _make_test_img -b "$TEST_IMG" 1M | ||
322 | +TEST_IMG="$TEST_IMG.overlay" _make_test_img -u -b "$TEST_IMG" 1M | ||
323 | _send_qemu_cmd $QEMU_HANDLE \ | ||
324 | "{ 'execute': 'blockdev-snapshot-sync', | ||
325 | 'arguments': { 'device': 'source', | ||
326 | diff --git a/tests/qemu-iotests/158 b/tests/qemu-iotests/158 | ||
327 | index XXXXXXX..XXXXXXX 100755 | ||
328 | --- a/tests/qemu-iotests/158 | ||
329 | +++ b/tests/qemu-iotests/158 | ||
330 | @@ -XXX,XX +XXX,XX @@ echo "== verify pattern ==" | ||
331 | $QEMU_IO --object $SECRET -c "read -P 0xa 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir | ||
332 | |||
333 | echo "== create overlay ==" | ||
334 | -_make_test_img --object $SECRET -o "encryption=on,encrypt.key-secret=sec0" -b "$TEST_IMG_BASE" $size | ||
335 | +_make_test_img -u --object $SECRET -o "encryption=on,encrypt.key-secret=sec0" -b "$TEST_IMG_BASE" $size | ||
336 | |||
337 | echo | ||
338 | echo "== writing part of a cluster ==" | ||
339 | diff --git a/tests/qemu-iotests/189 b/tests/qemu-iotests/189 | ||
340 | index XXXXXXX..XXXXXXX 100755 | ||
341 | --- a/tests/qemu-iotests/189 | ||
342 | +++ b/tests/qemu-iotests/189 | ||
343 | @@ -XXX,XX +XXX,XX @@ echo "== verify pattern ==" | ||
344 | $QEMU_IO --object $SECRET0 -c "read -P 0xa 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir | ||
345 | |||
346 | echo "== create overlay ==" | ||
347 | -_make_test_img --object $SECRET1 -o "encrypt.format=luks,encrypt.key-secret=sec1,encrypt.iter-time=10" -b "$TEST_IMG_BASE" $size | ||
348 | +_make_test_img --object $SECRET1 -o "encrypt.format=luks,encrypt.key-secret=sec1,encrypt.iter-time=10" -u -b "$TEST_IMG_BASE" $size | ||
349 | |||
350 | echo | ||
351 | echo "== writing part of a cluster ==" | ||
352 | -- | 78 | -- |
353 | 1.8.3.1 | 79 | 2.29.2 |
354 | 80 | ||
355 | 81 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | From: Sergio Lopez <slp@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | The function vmdk_read_cid() can fail if the read on the underlying | 3 | Move blk_exp_close_all() from bdrv_close() to qemu_cleanup(), before |
4 | block device fails, or if there's a format error in the VMDK file. | 4 | bdrv_drain_all_begin(). |
5 | However its API doesn't provide a mechanism to report these errors, | ||
6 | and in some cases we were returning a CID of 0 and in some cases a | ||
7 | CID of 0xffffffff, either of which might potentially be valid values. | ||
8 | 5 | ||
9 | Change the function to return 0 on success or a negative errno, and | 6 | Export drivers may have coroutines yielding at some point in the block |
10 | return the CID via a uint32_t* argument. Update the callsites to | 7 | layer, so we need to shut them down before draining the block layer, |
11 | handle and propagate the error appropriately. | 8 | as otherwise they may get stuck blk_wait_while_drained(). |
12 | 9 | ||
13 | This fixes in passing a Coverity-spotted issue (CID 1350038) where | 10 | RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1900505 |
14 | we weren't checking the return value from sscanf(). | 11 | Signed-off-by: Sergio Lopez <slp@redhat.com> |
15 | 12 | Message-Id: <20210201125032.44713-3-slp@redhat.com> | |
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
18 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
19 | --- | 14 | --- |
20 | block/vmdk.c | 44 ++++++++++++++++++++++++++++++++------------ | 15 | block.c | 1 - |
21 | 1 file changed, 32 insertions(+), 12 deletions(-) | 16 | qemu-nbd.c | 1 + |
17 | softmmu/runstate.c | 9 +++++++++ | ||
18 | storage-daemon/qemu-storage-daemon.c | 1 + | ||
19 | 4 files changed, 11 insertions(+), 1 deletion(-) | ||
22 | 20 | ||
23 | diff --git a/block/vmdk.c b/block/vmdk.c | 21 | diff --git a/block.c b/block.c |
24 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/block/vmdk.c | 23 | --- a/block.c |
26 | +++ b/block/vmdk.c | 24 | +++ b/block.c |
27 | @@ -XXX,XX +XXX,XX @@ static void vmdk_free_last_extent(BlockDriverState *bs) | 25 | @@ -XXX,XX +XXX,XX @@ static void bdrv_close(BlockDriverState *bs) |
28 | s->extents = g_renew(VmdkExtent, s->extents, s->num_extents); | 26 | void bdrv_close_all(void) |
27 | { | ||
28 | assert(job_next(NULL) == NULL); | ||
29 | - blk_exp_close_all(); | ||
30 | |||
31 | /* Drop references from requests still in flight, such as canceled block | ||
32 | * jobs whose AIO context has not been polled yet */ | ||
33 | diff --git a/qemu-nbd.c b/qemu-nbd.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/qemu-nbd.c | ||
36 | +++ b/qemu-nbd.c | ||
37 | @@ -XXX,XX +XXX,XX @@ static const char *socket_activation_validate_opts(const char *device, | ||
38 | static void qemu_nbd_shutdown(void) | ||
39 | { | ||
40 | job_cancel_sync_all(); | ||
41 | + blk_exp_close_all(); | ||
42 | bdrv_close_all(); | ||
29 | } | 43 | } |
30 | 44 | ||
31 | -static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent) | 45 | diff --git a/softmmu/runstate.c b/softmmu/runstate.c |
32 | +/* Return -ve errno, or 0 on success and write CID into *pcid. */ | 46 | index XXXXXXX..XXXXXXX 100644 |
33 | +static int vmdk_read_cid(BlockDriverState *bs, int parent, uint32_t *pcid) | 47 | --- a/softmmu/runstate.c |
34 | { | 48 | +++ b/softmmu/runstate.c |
35 | char *desc; | 49 | @@ -XXX,XX +XXX,XX @@ |
36 | - uint32_t cid = 0xffffffff; | 50 | #include "qemu/osdep.h" |
37 | + uint32_t cid; | 51 | #include "audio/audio.h" |
38 | const char *p_name, *cid_str; | 52 | #include "block/block.h" |
39 | size_t cid_str_size; | 53 | +#include "block/export.h" |
40 | BDRVVmdkState *s = bs->opaque; | 54 | #include "chardev/char.h" |
41 | @@ -XXX,XX +XXX,XX @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent) | 55 | #include "crypto/cipher.h" |
42 | desc = g_malloc0(DESC_SIZE); | 56 | #include "crypto/init.h" |
43 | ret = bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE); | 57 | @@ -XXX,XX +XXX,XX @@ void qemu_cleanup(void) |
44 | if (ret < 0) { | 58 | */ |
45 | - g_free(desc); | 59 | migration_shutdown(); |
46 | - return 0; | 60 | |
47 | + goto out; | 61 | + /* |
62 | + * Close the exports before draining the block layer. The export | ||
63 | + * drivers may have coroutines yielding on it, so we need to clean | ||
64 | + * them up before the drain, as otherwise they may be get stuck in | ||
65 | + * blk_wait_while_drained(). | ||
66 | + */ | ||
67 | + blk_exp_close_all(); | ||
68 | + | ||
69 | /* | ||
70 | * We must cancel all block jobs while the block layer is drained, | ||
71 | * or cancelling will be affected by throttling and thus may block | ||
72 | diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/storage-daemon/qemu-storage-daemon.c | ||
75 | +++ b/storage-daemon/qemu-storage-daemon.c | ||
76 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) | ||
77 | main_loop_wait(false); | ||
48 | } | 78 | } |
49 | 79 | ||
50 | if (parent) { | 80 | + blk_exp_close_all(); |
51 | @@ -XXX,XX +XXX,XX @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent) | 81 | bdrv_drain_all_begin(); |
52 | 82 | bdrv_close_all(); | |
53 | desc[DESC_SIZE - 1] = '\0'; | 83 | |
54 | p_name = strstr(desc, cid_str); | ||
55 | - if (p_name != NULL) { | ||
56 | - p_name += cid_str_size; | ||
57 | - sscanf(p_name, "%" SCNx32, &cid); | ||
58 | + if (p_name == NULL) { | ||
59 | + ret = -EINVAL; | ||
60 | + goto out; | ||
61 | } | ||
62 | + p_name += cid_str_size; | ||
63 | + if (sscanf(p_name, "%" SCNx32, &cid) != 1) { | ||
64 | + ret = -EINVAL; | ||
65 | + goto out; | ||
66 | + } | ||
67 | + *pcid = cid; | ||
68 | + ret = 0; | ||
69 | |||
70 | +out: | ||
71 | g_free(desc); | ||
72 | - return cid; | ||
73 | + return ret; | ||
74 | } | ||
75 | |||
76 | static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid) | ||
77 | @@ -XXX,XX +XXX,XX @@ static int vmdk_is_cid_valid(BlockDriverState *bs) | ||
78 | if (!s->cid_checked && bs->backing) { | ||
79 | BlockDriverState *p_bs = bs->backing->bs; | ||
80 | |||
81 | - cur_pcid = vmdk_read_cid(p_bs, 0); | ||
82 | + if (vmdk_read_cid(p_bs, 0, &cur_pcid) != 0) { | ||
83 | + /* read failure: report as not valid */ | ||
84 | + return 0; | ||
85 | + } | ||
86 | if (s->parent_cid != cur_pcid) { | ||
87 | /* CID not valid */ | ||
88 | return 0; | ||
89 | @@ -XXX,XX +XXX,XX @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, | ||
90 | if (ret) { | ||
91 | goto fail; | ||
92 | } | ||
93 | - s->cid = vmdk_read_cid(bs, 0); | ||
94 | - s->parent_cid = vmdk_read_cid(bs, 1); | ||
95 | + ret = vmdk_read_cid(bs, 0, &s->cid); | ||
96 | + if (ret) { | ||
97 | + goto fail; | ||
98 | + } | ||
99 | + ret = vmdk_read_cid(bs, 1, &s->parent_cid); | ||
100 | + if (ret) { | ||
101 | + goto fail; | ||
102 | + } | ||
103 | qemu_co_mutex_init(&s->lock); | ||
104 | |||
105 | /* Disable migration when VMDK images are used */ | ||
106 | @@ -XXX,XX +XXX,XX @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp) | ||
107 | ret = -EINVAL; | ||
108 | goto exit; | ||
109 | } | ||
110 | - parent_cid = vmdk_read_cid(blk_bs(blk), 0); | ||
111 | + ret = vmdk_read_cid(blk_bs(blk), 0, &parent_cid); | ||
112 | blk_unref(blk); | ||
113 | + if (ret) { | ||
114 | + goto exit; | ||
115 | + } | ||
116 | snprintf(parent_desc_line, BUF_SIZE, | ||
117 | "parentFileNameHint=\"%s\"", backing_file); | ||
118 | } | ||
119 | -- | 84 | -- |
120 | 1.8.3.1 | 85 | 2.29.2 |
121 | 86 | ||
122 | 87 | diff view generated by jsdifflib |
1 | From: Hervé Poussineau <hpoussin@reactos.org> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | This prevents some host to guest memory content leaks. | 3 | Ignore two complains, which now lead to 297 failure on testenv.py and |
4 | testrunner.py. | ||
4 | 5 | ||
5 | Fixes: https://bugs.launchpad.net/qemu/+bug/1599539 | 6 | Fixes: 2e5a2f57db481f18fcf70be2a36b1417370b8476 |
6 | 7 | Fixes: d74c754c924ca34e90b7c96ce2f5609d82c0e628 | |
7 | Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> | 8 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
9 | Message-Id: <20210129161323.615027-1-vsementsov@virtuozzo.com> | ||
10 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | --- | 12 | --- |
10 | block/vvfat.c | 1 + | 13 | tests/qemu-iotests/pylintrc | 2 ++ |
11 | 1 file changed, 1 insertion(+) | 14 | 1 file changed, 2 insertions(+) |
12 | 15 | ||
13 | diff --git a/block/vvfat.c b/block/vvfat.c | 16 | diff --git a/tests/qemu-iotests/pylintrc b/tests/qemu-iotests/pylintrc |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/block/vvfat.c | 18 | --- a/tests/qemu-iotests/pylintrc |
16 | +++ b/block/vvfat.c | 19 | +++ b/tests/qemu-iotests/pylintrc |
17 | @@ -XXX,XX +XXX,XX @@ static inline int array_ensure_allocated(array_t* array, int index) | 20 | @@ -XXX,XX +XXX,XX @@ disable=invalid-name, |
18 | array->pointer = g_realloc(array->pointer, new_size); | 21 | unsubscriptable-object, |
19 | if (!array->pointer) | 22 | # These are temporary, and should be removed: |
20 | return -1; | 23 | missing-docstring, |
21 | + memset(array->pointer + array->size, 0, new_size - array->size); | 24 | + too-many-return-statements, |
22 | array->size = new_size; | 25 | + too-many-statements |
23 | array->next = index + 1; | 26 | |
24 | } | 27 | [FORMAT] |
28 | |||
25 | -- | 29 | -- |
26 | 1.8.3.1 | 30 | 2.29.2 |
27 | 31 | ||
28 | 32 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | If the qemu-system-{arch} binary for the host architecture can't be |
---|---|---|---|
2 | found, the old 'check' implementation selected the alphabetically first | ||
3 | system emulator binary that it could find. The new Python implementation | ||
4 | just uses the first result of glob.iglob(), which has an undefined | ||
5 | order. | ||
2 | 6 | ||
3 | gcc 7 complains that the sprintf() might write a null byte beyond the | 7 | This is a problem that breaks CI because the iotests aren't actually |
4 | end of the tail buffer. That is wrong, but we can silence it by making | 8 | prepared to run on any emulator. They should be, so this is really a bug |
5 | i unsigned (it can never be negative anyway, see the if condition right | 9 | in the failing test cases that should be fixed there, but as a quick |
6 | before). For some reason, this allows gcc to suddenly accurately | 10 | fix, let's revert to the old behaviour to let CI runs succeed again. |
7 | calculate the range of i so we can give the tail[] array the exact size | ||
8 | it needs to have (which is 8 bytes) without gcc complaining. | ||
9 | 11 | ||
10 | In addition, let us convert the sprintf() to snprintf(), because that is | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
11 | always nicer, and add an assertion about the range of the return value | 13 | Message-Id: <20210202142802.119999-1-kwolf@redhat.com> |
12 | afterwards so we can see that "8 - len" will never be negative and thus | 14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
13 | "entry->name + MIN(j, 8 - len)" will never be out of bounds. | 15 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
14 | 16 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | |
15 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
16 | Reviewed-by: Eric Blake <eblake@redhat.com> | 17 | Reviewed-by: Eric Blake <eblake@redhat.com> |
17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 18 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
18 | --- | 19 | --- |
19 | block/vvfat.c | 5 +++-- | 20 | tests/qemu-iotests/testenv.py | 2 +- |
20 | 1 file changed, 3 insertions(+), 2 deletions(-) | 21 | 1 file changed, 1 insertion(+), 1 deletion(-) |
21 | 22 | ||
22 | diff --git a/block/vvfat.c b/block/vvfat.c | 23 | diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py |
23 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/block/vvfat.c | 25 | --- a/tests/qemu-iotests/testenv.py |
25 | +++ b/block/vvfat.c | 26 | +++ b/tests/qemu-iotests/testenv.py |
26 | @@ -XXX,XX +XXX,XX @@ static direntry_t *create_short_filename(BDRVVVFATState *s, | 27 | @@ -XXX,XX +XXX,XX @@ class TestEnv(ContextManager['TestEnv']): |
27 | const gchar *p, *last_dot = NULL; | 28 | if not os.path.exists(self.qemu_prog): |
28 | gunichar c; | 29 | pattern = root('qemu-system-*') |
29 | bool lossy_conversion = false; | 30 | try: |
30 | - char tail[11]; | 31 | - progs = glob.iglob(pattern) |
31 | + char tail[8]; | 32 | + progs = sorted(glob.iglob(pattern)) |
32 | 33 | self.qemu_prog = next(p for p in progs if isxfile(p)) | |
33 | if (!entry) { | 34 | except StopIteration: |
34 | return NULL; | 35 | sys.exit("Not found any Qemu executable binary by pattern " |
35 | @@ -XXX,XX +XXX,XX @@ static direntry_t *create_short_filename(BDRVVVFATState *s, | ||
36 | for (i = lossy_conversion ? 1 : 0; i < 999999; i++) { | ||
37 | direntry_t *entry1; | ||
38 | if (i > 0) { | ||
39 | - int len = sprintf(tail, "~%d", i); | ||
40 | + int len = snprintf(tail, sizeof(tail), "~%u", (unsigned)i); | ||
41 | + assert(len <= 7); | ||
42 | memcpy(entry->name + MIN(j, 8 - len), tail, len); | ||
43 | } | ||
44 | for (entry1 = array_get(&(s->directory), directory_start); | ||
45 | -- | 36 | -- |
46 | 1.8.3.1 | 37 | 2.29.2 |
47 | 38 | ||
48 | 39 | diff view generated by jsdifflib |
1 | From: Hervé Poussineau <hpoussin@reactos.org> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Write support works again when image contains non-ASCII names. It is either the | 3 | We should indicate failure by exit code, not only output. |
4 | case when user created a non-ASCII filename, or when initial directory contained | ||
5 | a non-ASCII filename (since 0c36111f57ec2188f679e7fa810291b7386bdca1) | ||
6 | 4 | ||
7 | Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> | 5 | Reported-by: Peter Maydell |
6 | Fixes: f203080bbd9f9e5b31041b1f2afcd6040c5aaec5 | ||
7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
8 | Message-Id: <20210201085041.3079-1-vsementsov@virtuozzo.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | --- | 10 | --- |
10 | block/vvfat.c | 59 +++++++++++++++++++++++++++++++++++++---------------------- | 11 | tests/qemu-iotests/testrunner.py | 4 +++- |
11 | 1 file changed, 37 insertions(+), 22 deletions(-) | 12 | tests/qemu-iotests/check | 5 ++++- |
13 | 2 files changed, 7 insertions(+), 2 deletions(-) | ||
12 | 14 | ||
13 | diff --git a/block/vvfat.c b/block/vvfat.c | 15 | diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/block/vvfat.c | 17 | --- a/tests/qemu-iotests/testrunner.py |
16 | +++ b/block/vvfat.c | 18 | +++ b/tests/qemu-iotests/testrunner.py |
17 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 19 | @@ -XXX,XX +XXX,XX @@ class TestRunner(ContextManager['TestRunner']): |
18 | * filename length is 0x3f * 13 bytes. | 20 | |
19 | */ | 21 | return res |
20 | unsigned char name[0x3f * 13 + 1]; | 22 | |
21 | + gunichar2 name2[0x3f * 13 + 1]; | 23 | - def run_tests(self, tests: List[str]) -> None: |
22 | int checksum, len; | 24 | + def run_tests(self, tests: List[str]) -> bool: |
23 | int sequence_number; | 25 | n_run = 0 |
24 | } long_file_name; | 26 | failed = [] |
25 | @@ -XXX,XX +XXX,XX @@ static int parse_long_name(long_file_name* lfn, | 27 | notrun = [] |
26 | return 1; | 28 | @@ -XXX,XX +XXX,XX @@ class TestRunner(ContextManager['TestRunner']): |
27 | 29 | if failed: | |
28 | if (pointer[0] & 0x40) { | 30 | print('Failures:', ' '.join(failed)) |
29 | + /* first entry; do some initialization */ | 31 | print(f'Failed {len(failed)} of {n_run} iotests') |
30 | lfn->sequence_number = pointer[0] & 0x3f; | 32 | + return False |
31 | lfn->checksum = pointer[13]; | 33 | else: |
32 | lfn->name[0] = 0; | 34 | print(f'Passed all {n_run} iotests') |
33 | lfn->name[lfn->sequence_number * 13] = 0; | 35 | + return True |
34 | - } else if ((pointer[0] & 0x3f) != --lfn->sequence_number) | 36 | diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check |
35 | + } else if ((pointer[0] & 0x3f) != --lfn->sequence_number) { | 37 | index XXXXXXX..XXXXXXX 100755 |
36 | + /* not the expected sequence number */ | 38 | --- a/tests/qemu-iotests/check |
37 | return -1; | 39 | +++ b/tests/qemu-iotests/check |
38 | - else if (pointer[13] != lfn->checksum) | 40 | @@ -XXX,XX +XXX,XX @@ if __name__ == '__main__': |
39 | + } else if (pointer[13] != lfn->checksum) { | 41 | else: |
40 | + /* not the expected checksum */ | 42 | with TestRunner(env, makecheck=args.makecheck, |
41 | return -2; | 43 | color=args.color) as tr: |
42 | - else if (pointer[12] || pointer[26] || pointer[27]) | 44 | - tr.run_tests([os.path.join(env.source_iotests, t) for t in tests]) |
43 | + } else if (pointer[12] || pointer[26] || pointer[27]) { | 45 | + paths = [os.path.join(env.source_iotests, t) for t in tests] |
44 | + /* invalid zero fields */ | 46 | + ok = tr.run_tests(paths) |
45 | return -3; | 47 | + if not ok: |
46 | + } | 48 | + sys.exit(1) |
47 | |||
48 | offset = 13 * (lfn->sequence_number - 1); | ||
49 | for (i = 0, j = 1; i < 13; i++, j+=2) { | ||
50 | @@ -XXX,XX +XXX,XX @@ static int parse_long_name(long_file_name* lfn, | ||
51 | else if (j == 26) | ||
52 | j = 28; | ||
53 | |||
54 | - if (pointer[j+1] == 0) | ||
55 | - lfn->name[offset + i] = pointer[j]; | ||
56 | - else if (pointer[j+1] != 0xff || (pointer[0] & 0x40) == 0) | ||
57 | - return -4; | ||
58 | - else | ||
59 | - lfn->name[offset + i] = 0; | ||
60 | + if (pointer[j] == 0 && pointer[j + 1] == 0) { | ||
61 | + /* end of long file name */ | ||
62 | + break; | ||
63 | + } | ||
64 | + gunichar2 c = (pointer[j + 1] << 8) + pointer[j]; | ||
65 | + lfn->name2[offset + i] = c; | ||
66 | } | ||
67 | |||
68 | - if (pointer[0] & 0x40) | ||
69 | - lfn->len = offset + strlen((char*)lfn->name + offset); | ||
70 | + if (pointer[0] & 0x40) { | ||
71 | + /* first entry; set len */ | ||
72 | + lfn->len = offset + i; | ||
73 | + } | ||
74 | + if ((pointer[0] & 0x3f) == 0x01) { | ||
75 | + /* last entry; finalize entry */ | ||
76 | + glong olen; | ||
77 | + gchar *utf8 = g_utf16_to_utf8(lfn->name2, lfn->len, NULL, &olen, NULL); | ||
78 | + if (!utf8) { | ||
79 | + return -4; | ||
80 | + } | ||
81 | + lfn->len = olen; | ||
82 | + memcpy(lfn->name, utf8, olen + 1); | ||
83 | + g_free(utf8); | ||
84 | + } | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | @@ -XXX,XX +XXX,XX @@ static int parse_short_name(BDRVVVFATState* s, | ||
89 | |||
90 | for (j = 7; j >= 0 && direntry->name[j] == ' '; j--); | ||
91 | for (i = 0; i <= j; i++) { | ||
92 | - if (direntry->name[i] <= ' ' || direntry->name[i] > 0x7f) | ||
93 | + uint8_t c = direntry->name[i]; | ||
94 | + if (c != to_valid_short_char(c)) { | ||
95 | return -1; | ||
96 | - else if (s->downcase_short_names) | ||
97 | + } else if (s->downcase_short_names) { | ||
98 | lfn->name[i] = qemu_tolower(direntry->name[i]); | ||
99 | - else | ||
100 | + } else { | ||
101 | lfn->name[i] = direntry->name[i]; | ||
102 | + } | ||
103 | } | ||
104 | |||
105 | for (j = 2; j >= 0 && direntry->name[8 + j] == ' '; j--) { | ||
106 | @@ -XXX,XX +XXX,XX @@ static int parse_short_name(BDRVVVFATState* s, | ||
107 | lfn->name[i + j + 1] = '\0'; | ||
108 | for (;j >= 0; j--) { | ||
109 | uint8_t c = direntry->name[8 + j]; | ||
110 | - if (c <= ' ' || c > 0x7f) { | ||
111 | + if (c != to_valid_short_char(c)) { | ||
112 | return -2; | ||
113 | } else if (s->downcase_short_names) { | ||
114 | lfn->name[i + j] = qemu_tolower(c); | ||
115 | @@ -XXX,XX +XXX,XX @@ DLOG(checkpoint()); | ||
116 | /* | ||
117 | * Some sanity checks: | ||
118 | * - do not allow writing to the boot sector | ||
119 | - * - do not allow to write non-ASCII filenames | ||
120 | */ | ||
121 | |||
122 | if (sector_num < s->offset_to_fat) | ||
123 | @@ -XXX,XX +XXX,XX @@ DLOG(checkpoint()); | ||
124 | direntries = (direntry_t*)(buf + 0x200 * (begin - sector_num)); | ||
125 | |||
126 | for (k = 0; k < (end - begin) * 0x10; k++) { | ||
127 | - /* do not allow non-ASCII filenames */ | ||
128 | - if (parse_long_name(&lfn, direntries + k) < 0) { | ||
129 | - fprintf(stderr, "Warning: non-ASCII filename\n"); | ||
130 | - return -1; | ||
131 | - } | ||
132 | /* no access to the direntry of a read-only file */ | ||
133 | - else if (is_short_name(direntries+k) && | ||
134 | + if (is_short_name(direntries + k) && | ||
135 | (direntries[k].attributes & 1)) { | ||
136 | if (memcmp(direntries + k, | ||
137 | array_get(&(s->directory), dir_index + k), | ||
138 | -- | 49 | -- |
139 | 1.8.3.1 | 50 | 2.29.2 |
140 | 51 | ||
141 | 52 | diff view generated by jsdifflib |
1 | From: Hervé Poussineau <hpoussin@reactos.org> | 1 | For -makecheck, the old 'check' implementation skipped the output when |
---|---|---|---|
2 | starting a test. It only had the condensed output at the end of a test. | ||
2 | 3 | ||
3 | Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> | 4 | testrunner.py prints the normal output when starting a test even for |
5 | -makecheck. This output contains '\r' at the end so that it can be | ||
6 | overwritten with the result at the end of the test. However, for | ||
7 | -makecheck this is shorter output in a different format, so effectively | ||
8 | we end up with garbled output that mixes both output forms. | ||
9 | |||
10 | Revert to the old behaviour of only printing a message after the test | ||
11 | had completed in -makecheck mode. | ||
12 | |||
13 | Fixes: d74c754c924ca34e90b7c96ce2f5609d82c0e628 | ||
14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
15 | Message-Id: <20210201161024.127921-1-kwolf@redhat.com> | ||
16 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | --- | 18 | --- |
6 | block/vvfat.c | 17 +++++++++++------ | 19 | tests/qemu-iotests/testrunner.py | 6 ++++-- |
7 | 1 file changed, 11 insertions(+), 6 deletions(-) | 20 | 1 file changed, 4 insertions(+), 2 deletions(-) |
8 | 21 | ||
9 | diff --git a/block/vvfat.c b/block/vvfat.c | 22 | diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py |
10 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/block/vvfat.c | 24 | --- a/tests/qemu-iotests/testrunner.py |
12 | +++ b/block/vvfat.c | 25 | +++ b/tests/qemu-iotests/testrunner.py |
13 | @@ -XXX,XX +XXX,XX @@ void nonono(const char* file, int line, const char* msg) { | 26 | @@ -XXX,XX +XXX,XX @@ class TestRunner(ContextManager['TestRunner']): |
14 | 27 | last_el = self.last_elapsed.get(test) | |
15 | #endif | 28 | start = datetime.datetime.now().strftime('%H:%M:%S') |
16 | 29 | ||
17 | +#define DIR_DELETED 0xe5 | 30 | - self.test_print_one_line(test=test, starttime=start, lasttime=last_el, |
18 | +#define DIR_KANJI DIR_DELETED | 31 | - end='\r', test_field_width=test_field_width) |
19 | +#define DIR_KANJI_FAKE 0x05 | 32 | + if not self.makecheck: |
20 | +#define DIR_FREE 0x00 | 33 | + self.test_print_one_line(test=test, starttime=start, |
21 | + | 34 | + lasttime=last_el, end='\r', |
22 | /* dynamic array functions */ | 35 | + test_field_width=test_field_width) |
23 | typedef struct array_t { | 36 | |
24 | char* pointer; | 37 | res = self.do_run_test(test) |
25 | @@ -XXX,XX +XXX,XX @@ static direntry_t *create_long_filename(BDRVVVFATState *s, const char *filename) | ||
26 | |||
27 | static char is_free(const direntry_t* direntry) | ||
28 | { | ||
29 | - return direntry->name[0]==0xe5 || direntry->name[0]==0x00; | ||
30 | + return direntry->name[0] == DIR_DELETED || direntry->name[0] == DIR_FREE; | ||
31 | } | ||
32 | |||
33 | static char is_volume_label(const direntry_t* direntry) | ||
34 | @@ -XXX,XX +XXX,XX @@ static char is_short_name(const direntry_t* direntry) | ||
35 | |||
36 | static char is_directory(const direntry_t* direntry) | ||
37 | { | ||
38 | - return direntry->attributes & 0x10 && direntry->name[0] != 0xe5; | ||
39 | + return direntry->attributes & 0x10 && direntry->name[0] != DIR_DELETED; | ||
40 | } | ||
41 | |||
42 | static inline char is_dot(const direntry_t* direntry) | ||
43 | @@ -XXX,XX +XXX,XX @@ static direntry_t *create_short_filename(BDRVVVFATState *s, | ||
44 | } | ||
45 | } | ||
46 | |||
47 | - if (entry->name[0] == 0xe5) { | ||
48 | - entry->name[0] = 0x05; | ||
49 | + if (entry->name[0] == DIR_KANJI) { | ||
50 | + entry->name[0] = DIR_KANJI_FAKE; | ||
51 | } | ||
52 | |||
53 | /* numeric-tail generation */ | ||
54 | @@ -XXX,XX +XXX,XX @@ static int parse_short_name(BDRVVVFATState* s, | ||
55 | } else | ||
56 | lfn->name[i + j + 1] = '\0'; | ||
57 | |||
58 | - if (lfn->name[0] == 0x05) { | ||
59 | - lfn->name[0] = 0xe5; | ||
60 | + if (lfn->name[0] == DIR_KANJI_FAKE) { | ||
61 | + lfn->name[0] = DIR_KANJI; | ||
62 | } | ||
63 | lfn->len = strlen((char*)lfn->name); | ||
64 | 38 | ||
65 | -- | 39 | -- |
66 | 1.8.3.1 | 40 | 2.29.2 |
67 | 41 | ||
68 | 42 | diff view generated by jsdifflib |
1 | From: Hervé Poussineau <hpoussin@reactos.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Also add links to related compatibility problems. | 3 | Commit 15b2260bef3 ("block/nvme: Trace controller capabilities") |
4 | misunderstood the doorbell stride value from the datasheet, use | ||
5 | the correct one. The 'doorbell_scale' variable used few lines | ||
6 | later is correct. | ||
4 | 7 | ||
5 | Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | Message-Id: <20210127212137.3482291-2-philmd@redhat.com> |
10 | Reviewed-by: Klaus Jensen <k.jensen@samsung.com> | ||
7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
8 | --- | 12 | --- |
9 | block/vvfat.c | 8 +++++++- | 13 | block/nvme.c | 2 +- |
10 | 1 file changed, 7 insertions(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | 15 | ||
12 | diff --git a/block/vvfat.c b/block/vvfat.c | 16 | diff --git a/block/nvme.c b/block/nvme.c |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/block/vvfat.c | 18 | --- a/block/nvme.c |
15 | +++ b/block/vvfat.c | 19 | +++ b/block/nvme.c |
16 | @@ -XXX,XX +XXX,XX @@ void nonono(const char* file, int line, const char* msg) { | 20 | @@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, |
17 | 21 | trace_nvme_controller_capability("Contiguous Queues Required", | |
18 | #endif | 22 | NVME_CAP_CQR(cap)); |
19 | 23 | trace_nvme_controller_capability("Doorbell Stride", | |
20 | +/* bootsector OEM name. see related compatibility problems at: | 24 | - 2 << (2 + NVME_CAP_DSTRD(cap))); |
21 | + * https://jdebp.eu/FGA/volume-boot-block-oem-name-field.html | 25 | + 1 << (2 + NVME_CAP_DSTRD(cap))); |
22 | + * http://seasip.info/Misc/oemid.html | 26 | trace_nvme_controller_capability("Subsystem Reset Supported", |
23 | + */ | 27 | NVME_CAP_NSSRS(cap)); |
24 | +#define BOOTSECTOR_OEM_NAME "MSWIN4.1" | 28 | trace_nvme_controller_capability("Memory Page Size Minimum", |
25 | + | ||
26 | #define DIR_DELETED 0xe5 | ||
27 | #define DIR_KANJI DIR_DELETED | ||
28 | #define DIR_KANJI_FAKE 0x05 | ||
29 | @@ -XXX,XX +XXX,XX @@ static int init_directories(BDRVVVFATState* s, | ||
30 | bootsector->jump[0]=0xeb; | ||
31 | bootsector->jump[1]=0x3e; | ||
32 | bootsector->jump[2]=0x90; | ||
33 | - memcpy(bootsector->name, "MSWIN4.1", 8); | ||
34 | + memcpy(bootsector->name, BOOTSECTOR_OEM_NAME, 8); | ||
35 | bootsector->sector_size=cpu_to_le16(0x200); | ||
36 | bootsector->sectors_per_cluster=s->sectors_per_cluster; | ||
37 | bootsector->reserved_sectors=cpu_to_le16(1); | ||
38 | -- | 29 | -- |
39 | 1.8.3.1 | 30 | 2.29.2 |
40 | 31 | ||
41 | 32 | diff view generated by jsdifflib |
1 | From: Manos Pitsidianakis <el13635@mail.ntua.gr> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | throttle_config() cancels the timers of the calling BlockBackend. This | 3 | NVMe controllers implement different versions of the spec, |
4 | doesn't make sense because other BlockBackends in the group remain | 4 | and different features of it. It is useful to gather this |
5 | untouched. There's no need to cancel the timers in the one specific | 5 | information when debugging. |
6 | BlockBackend so let's not do that. Throttled requests will run as | ||
7 | scheduled and future requests will follow the new configuration. This | ||
8 | also allows a throttle group's configuration to be changed even when it | ||
9 | has no members. | ||
10 | 6 | ||
11 | Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
12 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 8 | Message-Id: <20210127212137.3482291-3-philmd@redhat.com> |
9 | Reviewed-by: Klaus Jensen <k.jensen@samsung.com> | ||
13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
14 | --- | 11 | --- |
15 | block/throttle-groups.c | 10 +--------- | 12 | block/nvme.c | 6 ++++++ |
16 | fsdev/qemu-fsdev-throttle.c | 2 +- | 13 | block/trace-events | 1 + |
17 | include/qemu/throttle.h | 1 - | 14 | 2 files changed, 7 insertions(+) |
18 | tests/test-throttle.c | 4 ++-- | ||
19 | util/throttle.c | 14 -------------- | ||
20 | 5 files changed, 4 insertions(+), 27 deletions(-) | ||
21 | 15 | ||
22 | diff --git a/block/throttle-groups.c b/block/throttle-groups.c | 16 | diff --git a/block/nvme.c b/block/nvme.c |
23 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/block/throttle-groups.c | 18 | --- a/block/nvme.c |
25 | +++ b/block/throttle-groups.c | 19 | +++ b/block/nvme.c |
26 | @@ -XXX,XX +XXX,XX @@ void throttle_group_restart_blk(BlockBackend *blk) | 20 | @@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, |
27 | void throttle_group_config(BlockBackend *blk, ThrottleConfig *cfg) | 21 | AioContext *aio_context = bdrv_get_aio_context(bs); |
28 | { | 22 | int ret; |
29 | BlockBackendPublic *blkp = blk_get_public(blk); | 23 | uint64_t cap; |
30 | - ThrottleTimers *tt = &blkp->throttle_timers; | 24 | + uint32_t ver; |
31 | ThrottleState *ts = blkp->throttle_state; | 25 | uint64_t timeout_ms; |
32 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); | 26 | uint64_t deadline, now; |
33 | qemu_mutex_lock(&tg->lock); | 27 | volatile NvmeBar *regs = NULL; |
34 | - /* throttle_config() cancels the timers */ | 28 | @@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, |
35 | - if (timer_pending(tt->timers[0])) { | 29 | bs->bl.request_alignment = s->page_size; |
36 | - tg->any_timer_armed[0] = false; | 30 | timeout_ms = MIN(500 * NVME_CAP_TO(cap), 30000); |
37 | - } | 31 | |
38 | - if (timer_pending(tt->timers[1])) { | 32 | + ver = le32_to_cpu(regs->vs); |
39 | - tg->any_timer_armed[1] = false; | 33 | + trace_nvme_controller_spec_version(extract32(ver, 16, 16), |
40 | - } | 34 | + extract32(ver, 8, 8), |
41 | - throttle_config(ts, tg->clock_type, tt, cfg); | 35 | + extract32(ver, 0, 8)); |
42 | + throttle_config(ts, tg->clock_type, cfg); | 36 | + |
43 | qemu_mutex_unlock(&tg->lock); | 37 | /* Reset device to get a clean state. */ |
44 | 38 | regs->cc = cpu_to_le32(le32_to_cpu(regs->cc) & 0xFE); | |
45 | throttle_group_restart_blk(blk); | 39 | /* Wait for CSTS.RDY = 0. */ |
46 | diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c | 40 | diff --git a/block/trace-events b/block/trace-events |
47 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/fsdev/qemu-fsdev-throttle.c | 42 | --- a/block/trace-events |
49 | +++ b/fsdev/qemu-fsdev-throttle.c | 43 | +++ b/block/trace-events |
50 | @@ -XXX,XX +XXX,XX @@ void fsdev_throttle_init(FsThrottle *fst) | 44 | @@ -XXX,XX +XXX,XX @@ qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s |
51 | fsdev_throttle_read_timer_cb, | 45 | # nvme.c |
52 | fsdev_throttle_write_timer_cb, | 46 | nvme_controller_capability_raw(uint64_t value) "0x%08"PRIx64 |
53 | fst); | 47 | nvme_controller_capability(const char *desc, uint64_t value) "%s: %"PRIu64 |
54 | - throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->tt, &fst->cfg); | 48 | +nvme_controller_spec_version(uint32_t mjr, uint32_t mnr, uint32_t ter) "Specification supported: %u.%u.%u" |
55 | + throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->cfg); | 49 | nvme_kick(void *s, unsigned q_index) "s %p q #%u" |
56 | qemu_co_queue_init(&fst->throttled_reqs[0]); | 50 | nvme_dma_flush_queue_wait(void *s) "s %p" |
57 | qemu_co_queue_init(&fst->throttled_reqs[1]); | 51 | nvme_error(int cmd_specific, int sq_head, int sqid, int cid, int status) "cmd_specific %d sq_head %d sqid %d cid %d status 0x%x" |
58 | } | ||
59 | diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/include/qemu/throttle.h | ||
62 | +++ b/include/qemu/throttle.h | ||
63 | @@ -XXX,XX +XXX,XX @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp); | ||
64 | |||
65 | void throttle_config(ThrottleState *ts, | ||
66 | QEMUClockType clock_type, | ||
67 | - ThrottleTimers *tt, | ||
68 | ThrottleConfig *cfg); | ||
69 | |||
70 | void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg); | ||
71 | diff --git a/tests/test-throttle.c b/tests/test-throttle.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/tests/test-throttle.c | ||
74 | +++ b/tests/test-throttle.c | ||
75 | @@ -XXX,XX +XXX,XX @@ static void test_config_functions(void) | ||
76 | read_timer_cb, write_timer_cb, &ts); | ||
77 | /* structure reset by throttle_init previous_leak should be null */ | ||
78 | g_assert(!ts.previous_leak); | ||
79 | - throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &orig_cfg); | ||
80 | + throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &orig_cfg); | ||
81 | |||
82 | /* has previous leak been initialized by throttle_config ? */ | ||
83 | g_assert(ts.previous_leak); | ||
84 | @@ -XXX,XX +XXX,XX @@ static bool do_test_accounting(bool is_ops, /* are we testing bps or ops */ | ||
85 | throttle_init(&ts); | ||
86 | throttle_timers_init(&tt, ctx, QEMU_CLOCK_VIRTUAL, | ||
87 | read_timer_cb, write_timer_cb, &ts); | ||
88 | - throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &cfg); | ||
89 | + throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &cfg); | ||
90 | |||
91 | /* account a read */ | ||
92 | throttle_account(&ts, false, size); | ||
93 | diff --git a/util/throttle.c b/util/throttle.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/util/throttle.c | ||
96 | +++ b/util/throttle.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void throttle_unfix_bucket(LeakyBucket *bkt) | ||
98 | } | ||
99 | } | ||
100 | |||
101 | -/* take care of canceling a timer */ | ||
102 | -static void throttle_cancel_timer(QEMUTimer *timer) | ||
103 | -{ | ||
104 | - assert(timer != NULL); | ||
105 | - | ||
106 | - timer_del(timer); | ||
107 | -} | ||
108 | - | ||
109 | /* Used to configure the throttle | ||
110 | * | ||
111 | * @ts: the throttle state we are working on | ||
112 | * @clock_type: the group's clock_type | ||
113 | - * @tt: the throttle timers we use in this aio context | ||
114 | * @cfg: the config to set | ||
115 | */ | ||
116 | void throttle_config(ThrottleState *ts, | ||
117 | QEMUClockType clock_type, | ||
118 | - ThrottleTimers *tt, | ||
119 | ThrottleConfig *cfg) | ||
120 | { | ||
121 | int i; | ||
122 | @@ -XXX,XX +XXX,XX @@ void throttle_config(ThrottleState *ts, | ||
123 | } | ||
124 | |||
125 | ts->previous_leak = qemu_clock_get_ns(clock_type); | ||
126 | - | ||
127 | - for (i = 0; i < 2; i++) { | ||
128 | - throttle_cancel_timer(tt->timers[i]); | ||
129 | - } | ||
130 | } | ||
131 | |||
132 | /* used to get config | ||
133 | -- | 52 | -- |
134 | 1.8.3.1 | 53 | 2.29.2 |
135 | 54 | ||
136 | 55 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Maydell <peter.maydell@linaro.org> | ||
2 | 1 | ||
3 | Coverity (CID 1355236) points out that get_image_offset() doesn't check that | ||
4 | it actually succeeded in writing the updated block bitmap to the file. | ||
5 | Check the error return from bdrv_pwrite_sync() and propagate an error | ||
6 | response back up to the function which calls get_image_offset() for | ||
7 | a write so that it can return the error to its caller. | ||
8 | |||
9 | get_sector_offset() is only used for reads, but we move it to the | ||
10 | same API for consistency. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
14 | --- | ||
15 | block/vpc.c | 30 +++++++++++++++++++++++------- | ||
16 | 1 file changed, 23 insertions(+), 7 deletions(-) | ||
17 | |||
18 | diff --git a/block/vpc.c b/block/vpc.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/block/vpc.c | ||
21 | +++ b/block/vpc.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static int vpc_reopen_prepare(BDRVReopenState *state, | ||
23 | /* | ||
24 | * Returns the absolute byte offset of the given sector in the image file. | ||
25 | * If the sector is not allocated, -1 is returned instead. | ||
26 | + * If an error occurred trying to write an updated block bitmap back to | ||
27 | + * the file, -2 is returned, and the error value is written to *err. | ||
28 | + * This can only happen for a write operation. | ||
29 | * | ||
30 | * The parameter write must be 1 if the offset will be used for a write | ||
31 | * operation (the block bitmaps is updated then), 0 otherwise. | ||
32 | + * If write is true then err must not be NULL. | ||
33 | */ | ||
34 | static inline int64_t get_image_offset(BlockDriverState *bs, uint64_t offset, | ||
35 | - bool write) | ||
36 | + bool write, int *err) | ||
37 | { | ||
38 | BDRVVPCState *s = bs->opaque; | ||
39 | uint64_t bitmap_offset, block_offset; | ||
40 | uint32_t pagetable_index, offset_in_block; | ||
41 | |||
42 | + assert(!(write && err == NULL)); | ||
43 | + | ||
44 | pagetable_index = offset / s->block_size; | ||
45 | offset_in_block = offset % s->block_size; | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ static inline int64_t get_image_offset(BlockDriverState *bs, uint64_t offset, | ||
48 | correctness. */ | ||
49 | if (write && (s->last_bitmap_offset != bitmap_offset)) { | ||
50 | uint8_t bitmap[s->bitmap_size]; | ||
51 | + int r; | ||
52 | |||
53 | s->last_bitmap_offset = bitmap_offset; | ||
54 | memset(bitmap, 0xff, s->bitmap_size); | ||
55 | - bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size); | ||
56 | + r = bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size); | ||
57 | + if (r < 0) { | ||
58 | + *err = r; | ||
59 | + return -2; | ||
60 | + } | ||
61 | } | ||
62 | |||
63 | return block_offset; | ||
64 | @@ -XXX,XX +XXX,XX @@ static int64_t alloc_block(BlockDriverState* bs, int64_t offset) | ||
65 | if (ret < 0) | ||
66 | goto fail; | ||
67 | |||
68 | - return get_image_offset(bs, offset, false); | ||
69 | + return get_image_offset(bs, offset, false, NULL); | ||
70 | |||
71 | fail: | ||
72 | s->free_data_block_offset -= (s->block_size + s->bitmap_size); | ||
73 | @@ -XXX,XX +XXX,XX @@ vpc_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | ||
74 | qemu_iovec_init(&local_qiov, qiov->niov); | ||
75 | |||
76 | while (bytes > 0) { | ||
77 | - image_offset = get_image_offset(bs, offset, false); | ||
78 | + image_offset = get_image_offset(bs, offset, false, NULL); | ||
79 | n_bytes = MIN(bytes, s->block_size - (offset % s->block_size)); | ||
80 | |||
81 | if (image_offset == -1) { | ||
82 | @@ -XXX,XX +XXX,XX @@ vpc_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | ||
83 | qemu_iovec_init(&local_qiov, qiov->niov); | ||
84 | |||
85 | while (bytes > 0) { | ||
86 | - image_offset = get_image_offset(bs, offset, true); | ||
87 | + image_offset = get_image_offset(bs, offset, true, &ret); | ||
88 | + if (image_offset == -2) { | ||
89 | + /* Failed to write block bitmap: can't proceed with write */ | ||
90 | + goto fail; | ||
91 | + } | ||
92 | n_bytes = MIN(bytes, s->block_size - (offset % s->block_size)); | ||
93 | |||
94 | if (image_offset == -1) { | ||
95 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn vpc_co_get_block_status(BlockDriverState *bs, | ||
96 | |||
97 | qemu_co_mutex_lock(&s->lock); | ||
98 | |||
99 | - offset = get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false); | ||
100 | + offset = get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false, NULL); | ||
101 | start = offset; | ||
102 | allocated = (offset != -1); | ||
103 | *pnum = 0; | ||
104 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn vpc_co_get_block_status(BlockDriverState *bs, | ||
105 | if (nb_sectors == 0) { | ||
106 | break; | ||
107 | } | ||
108 | - offset = get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false); | ||
109 | + offset = get_image_offset(bs, sector_num << BDRV_SECTOR_BITS, false, | ||
110 | + NULL); | ||
111 | } while (offset == -1); | ||
112 | |||
113 | qemu_co_mutex_unlock(&s->lock); | ||
114 | -- | ||
115 | 1.8.3.1 | ||
116 | |||
117 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
2 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
3 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
4 | --- | ||
5 | block/block-backend.c | 3 +-- | ||
6 | include/sysemu/block-backend.h | 1 + | ||
7 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
8 | 1 | ||
9 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/block/block-backend.c | ||
12 | +++ b/block/block-backend.c | ||
13 | @@ -XXX,XX +XXX,XX @@ static const AIOCBInfo block_backend_aiocb_info = { | ||
14 | |||
15 | static void drive_info_del(DriveInfo *dinfo); | ||
16 | static BlockBackend *bdrv_first_blk(BlockDriverState *bs); | ||
17 | -static char *blk_get_attached_dev_id(BlockBackend *blk); | ||
18 | |||
19 | /* All BlockBackends */ | ||
20 | static QTAILQ_HEAD(, BlockBackend) block_backends = | ||
21 | @@ -XXX,XX +XXX,XX @@ void *blk_get_attached_dev(BlockBackend *blk) | ||
22 | |||
23 | /* Return the qdev ID, or if no ID is assigned the QOM path, of the block | ||
24 | * device attached to the BlockBackend. */ | ||
25 | -static char *blk_get_attached_dev_id(BlockBackend *blk) | ||
26 | +char *blk_get_attached_dev_id(BlockBackend *blk) | ||
27 | { | ||
28 | DeviceState *dev; | ||
29 | |||
30 | diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/include/sysemu/block-backend.h | ||
33 | +++ b/include/sysemu/block-backend.h | ||
34 | @@ -XXX,XX +XXX,XX @@ int blk_attach_dev(BlockBackend *blk, DeviceState *dev); | ||
35 | void blk_attach_dev_legacy(BlockBackend *blk, void *dev); | ||
36 | void blk_detach_dev(BlockBackend *blk, void *dev); | ||
37 | void *blk_get_attached_dev(BlockBackend *blk); | ||
38 | +char *blk_get_attached_dev_id(BlockBackend *blk); | ||
39 | BlockBackend *blk_by_dev(void *dev); | ||
40 | BlockBackend *blk_by_qdev_id(const char *id, Error **errp); | ||
41 | void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaque); | ||
42 | -- | ||
43 | 1.8.3.1 | ||
44 | |||
45 | diff view generated by jsdifflib |
1 | With -blockdev/-device, users can indirectly create anonymous | 1 | size_to_str() can return a size like "4.24 MiB", with a single digit |
---|---|---|---|
2 | BlockBackends, while the state of such backends is still of interest. As | 2 | integer part and two fractional digits. This is eight characters, but |
3 | a preparation for making such BBs visible in query-block, make sure that | 3 | commit b39847a5 changed the format string to only reserve seven |
4 | they can be identified even without a name by adding the ID/QOM path of | 4 | characters for the column. |
5 | their qdev device to BlockInfo. | ||
6 | 5 | ||
6 | This can result in unaligned columns, which in turn changes the output of | ||
7 | iotests case 267 because exceeding the column size defeats the attempt | ||
8 | to filter the size out of the output (observed with the ppc64 emulator). | ||
9 | The resulting change is only a whitespace change, but since commit | ||
10 | f203080b this is enough for iotests to consider the test failed. | ||
11 | |||
12 | Taking a character away from the tag name column and adding it to the VM | ||
13 | size column doesn't change anything in the common case (the tag name is | ||
14 | left justified, the VM size is right justified), but fixes this case. | ||
15 | |||
16 | Fixes: b39847a50553b7679d6d7fefbe6a108a17aacf8d | ||
7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
8 | Reviewed-by: John Snow <jsnow@redhat.com> | 18 | Message-Id: <20210202155911.179865-1-kwolf@redhat.com> |
19 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
20 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | 21 | --- |
10 | block/qapi.c | 10 ++++++++++ | 22 | block/qapi.c | 4 ++-- |
11 | hmp.c | 3 +++ | 23 | 1 file changed, 2 insertions(+), 2 deletions(-) |
12 | qapi/block-core.json | 9 ++++++++- | ||
13 | tests/qemu-iotests/067.out | 1 + | ||
14 | 4 files changed, 22 insertions(+), 1 deletion(-) | ||
15 | 24 | ||
16 | diff --git a/block/qapi.c b/block/qapi.c | 25 | diff --git a/block/qapi.c b/block/qapi.c |
17 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/block/qapi.c | 27 | --- a/block/qapi.c |
19 | +++ b/block/qapi.c | 28 | +++ b/block/qapi.c |
20 | @@ -XXX,XX +XXX,XX @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, | 29 | @@ -XXX,XX +XXX,XX @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn) |
21 | { | 30 | char *sizing = NULL; |
22 | BlockInfo *info = g_malloc0(sizeof(*info)); | 31 | |
23 | BlockDriverState *bs = blk_bs(blk); | 32 | if (!sn) { |
24 | + char *qdev; | 33 | - qemu_printf("%-10s%-18s%7s%20s%13s%11s", |
25 | + | 34 | + qemu_printf("%-10s%-17s%8s%20s%13s%11s", |
26 | info->device = g_strdup(blk_name(blk)); | 35 | "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK", "ICOUNT"); |
27 | info->type = g_strdup("unknown"); | 36 | } else { |
28 | info->locked = blk_dev_is_medium_locked(blk); | 37 | ti = sn->date_sec; |
29 | info->removable = blk_dev_has_removable_media(blk); | 38 | @@ -XXX,XX +XXX,XX @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn) |
30 | 39 | snprintf(icount_buf, sizeof(icount_buf), | |
31 | + qdev = blk_get_attached_dev_id(blk); | 40 | "%"PRId64, sn->icount); |
32 | + if (qdev && *qdev) { | ||
33 | + info->has_qdev = true; | ||
34 | + info->qdev = qdev; | ||
35 | + } else { | ||
36 | + g_free(qdev); | ||
37 | + } | ||
38 | + | ||
39 | if (blk_dev_has_tray(blk)) { | ||
40 | info->has_tray_open = true; | ||
41 | info->tray_open = blk_dev_is_tray_open(blk); | ||
42 | diff --git a/hmp.c b/hmp.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/hmp.c | ||
45 | +++ b/hmp.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static void print_block_info(Monitor *mon, BlockInfo *info, | ||
47 | } | ||
48 | |||
49 | if (info) { | ||
50 | + if (info->has_qdev) { | ||
51 | + monitor_printf(mon, " Attached to: %s\n", info->qdev); | ||
52 | + } | ||
53 | if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) { | ||
54 | monitor_printf(mon, " I/O status: %s\n", | ||
55 | BlockDeviceIoStatus_lookup[info->io_status]); | ||
56 | diff --git a/qapi/block-core.json b/qapi/block-core.json | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/qapi/block-core.json | ||
59 | +++ b/qapi/block-core.json | ||
60 | @@ -XXX,XX +XXX,XX @@ | ||
61 | # | ||
62 | # @device: The device name associated with the virtual device. | ||
63 | # | ||
64 | +# @qdev: The qdev ID, or if no ID is assigned, the QOM path of the block | ||
65 | +# device. (since 2.10) | ||
66 | +# | ||
67 | # @type: This field is returned only for compatibility reasons, it should | ||
68 | # not be used (always returns 'unknown') | ||
69 | # | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | # Since: 0.14.0 | ||
72 | ## | ||
73 | { 'struct': 'BlockInfo', | ||
74 | - 'data': {'device': 'str', 'type': 'str', 'removable': 'bool', | ||
75 | + 'data': {'device': 'str', '*qdev': 'str', 'type': 'str', 'removable': 'bool', | ||
76 | 'locked': 'bool', '*inserted': 'BlockDeviceInfo', | ||
77 | '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus', | ||
78 | '*dirty-bitmaps': ['BlockDirtyInfo'] } } | ||
79 | @@ -XXX,XX +XXX,XX @@ | ||
80 | # } | ||
81 | # } | ||
82 | # }, | ||
83 | +# "qdev": "ide_disk", | ||
84 | # "type":"unknown" | ||
85 | # }, | ||
86 | # { | ||
87 | @@ -XXX,XX +XXX,XX @@ | ||
88 | # "device":"ide1-cd0", | ||
89 | # "locked":false, | ||
90 | # "removable":true, | ||
91 | +# "qdev": "/machine/unattached/device[23]", | ||
92 | +# "tray_open": false, | ||
93 | # "type":"unknown" | ||
94 | # }, | ||
95 | # { | ||
96 | # "device":"floppy0", | ||
97 | # "locked":false, | ||
98 | # "removable":true, | ||
99 | +# "qdev": "/machine/unattached/device[20]", | ||
100 | # "type":"unknown" | ||
101 | # }, | ||
102 | # { | ||
103 | diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/tests/qemu-iotests/067.out | ||
106 | +++ b/tests/qemu-iotests/067.out | ||
107 | @@ -XXX,XX +XXX,XX @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virti | ||
108 | "file": "TEST_DIR/t.qcow2", | ||
109 | "encryption_key_missing": false | ||
110 | }, | ||
111 | + "qdev": "/machine/peripheral/virtio0/virtio-backend", | ||
112 | "type": "unknown" | ||
113 | } | 41 | } |
114 | ] | 42 | - qemu_printf("%-9s %-17s %7s%20s%13s%11s", |
43 | + qemu_printf("%-9s %-16s %8s%20s%13s%11s", | ||
44 | sn->id_str, sn->name, | ||
45 | sizing, | ||
46 | date_buf, | ||
115 | -- | 47 | -- |
116 | 1.8.3.1 | 48 | 2.29.2 |
117 | 49 | ||
118 | 50 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
2 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
3 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
4 | --- | ||
5 | block/block-backend.c | 2 +- | ||
6 | include/sysemu/block-backend.h | 1 + | ||
7 | 2 files changed, 2 insertions(+), 1 deletion(-) | ||
8 | 1 | ||
9 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
10 | index XXXXXXX..XXXXXXX 100644 | ||
11 | --- a/block/block-backend.c | ||
12 | +++ b/block/block-backend.c | ||
13 | @@ -XXX,XX +XXX,XX @@ void blk_unref(BlockBackend *blk) | ||
14 | * Behaves similarly to blk_next() but iterates over all BlockBackends, even the | ||
15 | * ones which are hidden (i.e. are not referenced by the monitor). | ||
16 | */ | ||
17 | -static BlockBackend *blk_all_next(BlockBackend *blk) | ||
18 | +BlockBackend *blk_all_next(BlockBackend *blk) | ||
19 | { | ||
20 | return blk ? QTAILQ_NEXT(blk, link) | ||
21 | : QTAILQ_FIRST(&block_backends); | ||
22 | diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/include/sysemu/block-backend.h | ||
25 | +++ b/include/sysemu/block-backend.h | ||
26 | @@ -XXX,XX +XXX,XX @@ void blk_remove_all_bs(void); | ||
27 | const char *blk_name(const BlockBackend *blk); | ||
28 | BlockBackend *blk_by_name(const char *name); | ||
29 | BlockBackend *blk_next(BlockBackend *blk); | ||
30 | +BlockBackend *blk_all_next(BlockBackend *blk); | ||
31 | bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp); | ||
32 | void monitor_remove_blk(BlockBackend *blk); | ||
33 | |||
34 | -- | ||
35 | 1.8.3.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This patch replaces the blk_next() loop in query-block by a | ||
2 | blk_all_next() one so that we also get access to BlockBackends that | ||
3 | aren't owned by the monitor. For now, the next thing we do is check | ||
4 | whether each BB has a name, so there is no semantic difference. | ||
5 | 1 | ||
6 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
7 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
8 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
9 | --- | ||
10 | block/qapi.c | 10 ++++++++-- | ||
11 | 1 file changed, 8 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/block/qapi.c b/block/qapi.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/block/qapi.c | ||
16 | +++ b/block/qapi.c | ||
17 | @@ -XXX,XX +XXX,XX @@ BlockInfoList *qmp_query_block(Error **errp) | ||
18 | BlockBackend *blk; | ||
19 | Error *local_err = NULL; | ||
20 | |||
21 | - for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { | ||
22 | - BlockInfoList *info = g_malloc0(sizeof(*info)); | ||
23 | + for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { | ||
24 | + BlockInfoList *info; | ||
25 | + | ||
26 | + if (!*blk_name(blk)) { | ||
27 | + continue; | ||
28 | + } | ||
29 | + | ||
30 | + info = g_malloc0(sizeof(*info)); | ||
31 | bdrv_query_info(blk, &info->value, &local_err); | ||
32 | if (local_err) { | ||
33 | error_propagate(errp, local_err); | ||
34 | -- | ||
35 | 1.8.3.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Instead of listing only monitor-owned BlockBackends in query-block, also | ||
2 | add those anonymous BlockBackends that are owned by a qdev device and as | ||
3 | such under the control of the user. | ||
4 | 1 | ||
5 | This allows using query-block to inspect BlockBackends for the modern | ||
6 | configuration syntax with -blockdev and -device. | ||
7 | |||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
10 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
11 | --- | ||
12 | block/qapi.c | 2 +- | ||
13 | hmp.c | 8 ++++---- | ||
14 | 2 files changed, 5 insertions(+), 5 deletions(-) | ||
15 | |||
16 | diff --git a/block/qapi.c b/block/qapi.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/block/qapi.c | ||
19 | +++ b/block/qapi.c | ||
20 | @@ -XXX,XX +XXX,XX @@ BlockInfoList *qmp_query_block(Error **errp) | ||
21 | for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { | ||
22 | BlockInfoList *info; | ||
23 | |||
24 | - if (!*blk_name(blk)) { | ||
25 | + if (!*blk_name(blk) && !blk_get_attached_dev(blk)) { | ||
26 | continue; | ||
27 | } | ||
28 | |||
29 | diff --git a/hmp.c b/hmp.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hmp.c | ||
32 | +++ b/hmp.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void print_block_info(Monitor *mon, BlockInfo *info, | ||
34 | |||
35 | assert(!info || !info->has_inserted || info->inserted == inserted); | ||
36 | |||
37 | - if (info) { | ||
38 | + if (info && *info->device) { | ||
39 | monitor_printf(mon, "%s", info->device); | ||
40 | if (inserted && inserted->has_node_name) { | ||
41 | monitor_printf(mon, " (%s)", inserted->node_name); | ||
42 | } | ||
43 | } else { | ||
44 | - assert(inserted); | ||
45 | + assert(info || inserted); | ||
46 | monitor_printf(mon, "%s", | ||
47 | - inserted->has_node_name | ||
48 | - ? inserted->node_name | ||
49 | + inserted && inserted->has_node_name ? inserted->node_name | ||
50 | + : info && info->has_qdev ? info->qdev | ||
51 | : "<anonymous>"); | ||
52 | } | ||
53 | |||
54 | -- | ||
55 | 1.8.3.1 | ||
56 | |||
57 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If no drive=... option is passed (for an empty drive), we don't only | ||
2 | lack the BlockBackend normally created by parse_drive(), but we also | ||
3 | need to manually call blk_attach_dev(). | ||
4 | 1 | ||
5 | IDE does not support hot unplug, but if it did, qdev would take care to | ||
6 | call the matching blk_detach_dev() on unplug. | ||
7 | |||
8 | This fixes at least the bug that such devices didn't show up in | ||
9 | query-block, and probably some more problems. | ||
10 | |||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
12 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
13 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
14 | --- | ||
15 | hw/ide/qdev.c | 3 +++ | ||
16 | 1 file changed, 3 insertions(+) | ||
17 | |||
18 | diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/ide/qdev.c | ||
21 | +++ b/hw/ide/qdev.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) | ||
23 | IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); | ||
24 | IDEState *s = bus->ifs + dev->unit; | ||
25 | Error *err = NULL; | ||
26 | + int ret; | ||
27 | |||
28 | if (!dev->conf.blk) { | ||
29 | if (kind != IDE_CD) { | ||
30 | @@ -XXX,XX +XXX,XX @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) | ||
31 | } else { | ||
32 | /* Anonymous BlockBackend for an empty drive */ | ||
33 | dev->conf.blk = blk_new(0, BLK_PERM_ALL); | ||
34 | + ret = blk_attach_dev(dev->conf.blk, &dev->qdev); | ||
35 | + assert(ret == 0); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | -- | ||
40 | 1.8.3.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | If no drive=... option is passed (for an empty drive), we don't only | ||
2 | lack the BlockBackend normally created by parse_drive(), but we also | ||
3 | need to manually call blk_attach_dev(). | ||
4 | 1 | ||
5 | This fixes at least a segfault when unplugging such devices, the bug | ||
6 | that they didn't show up in query-block, and probably some more | ||
7 | problems. | ||
8 | |||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
10 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
11 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
12 | --- | ||
13 | hw/scsi/scsi-disk.c | 5 +++++ | ||
14 | 1 file changed, 5 insertions(+) | ||
15 | |||
16 | diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/scsi/scsi-disk.c | ||
19 | +++ b/hw/scsi/scsi-disk.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void scsi_hd_realize(SCSIDevice *dev, Error **errp) | ||
21 | static void scsi_cd_realize(SCSIDevice *dev, Error **errp) | ||
22 | { | ||
23 | SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); | ||
24 | + int ret; | ||
25 | |||
26 | if (!dev->conf.blk) { | ||
27 | + /* Anonymous BlockBackend for an empty drive. As we put it into | ||
28 | + * dev->conf, qdev takes care of detaching on unplug. */ | ||
29 | dev->conf.blk = blk_new(0, BLK_PERM_ALL); | ||
30 | + ret = blk_attach_dev(dev->conf.blk, &dev->qdev); | ||
31 | + assert(ret == 0); | ||
32 | } | ||
33 | |||
34 | s->qdev.blocksize = 2048; | ||
35 | -- | ||
36 | 1.8.3.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This test makes sure that all block devices show up on 'info block', | ||
2 | with all of the expected information, in different configurations. | ||
3 | 1 | ||
4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
6 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
7 | --- | ||
8 | tests/qemu-iotests/186 | 147 ++++++++++++++ | ||
9 | tests/qemu-iotests/186.out | 489 +++++++++++++++++++++++++++++++++++++++++++++ | ||
10 | tests/qemu-iotests/group | 1 + | ||
11 | 3 files changed, 637 insertions(+) | ||
12 | create mode 100755 tests/qemu-iotests/186 | ||
13 | create mode 100644 tests/qemu-iotests/186.out | ||
14 | |||
15 | diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186 | ||
16 | new file mode 100755 | ||
17 | index XXXXXXX..XXXXXXX | ||
18 | --- /dev/null | ||
19 | +++ b/tests/qemu-iotests/186 | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | +#!/bin/bash | ||
22 | +# | ||
23 | +# Test 'info block' with all kinds of configurations | ||
24 | +# | ||
25 | +# Copyright (C) 2017 Red Hat, Inc. | ||
26 | +# | ||
27 | +# This program is free software; you can redistribute it and/or modify | ||
28 | +# it under the terms of the GNU General Public License as published by | ||
29 | +# the Free Software Foundation; either version 2 of the License, or | ||
30 | +# (at your option) any later version. | ||
31 | +# | ||
32 | +# This program is distributed in the hope that it will be useful, | ||
33 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
34 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
35 | +# GNU General Public License for more details. | ||
36 | +# | ||
37 | +# You should have received a copy of the GNU General Public License | ||
38 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
39 | +# | ||
40 | + | ||
41 | +# creator | ||
42 | +owner=kwolf@redhat.com | ||
43 | + | ||
44 | +seq=`basename $0` | ||
45 | +echo "QA output created by $seq" | ||
46 | + | ||
47 | +here=`pwd` | ||
48 | +status=1 # failure is the default! | ||
49 | + | ||
50 | +_cleanup() | ||
51 | +{ | ||
52 | + _cleanup_test_img | ||
53 | +} | ||
54 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
55 | + | ||
56 | +# get standard environment, filters and checks | ||
57 | +. ./common.rc | ||
58 | +. ./common.filter | ||
59 | + | ||
60 | +_supported_fmt qcow2 | ||
61 | +_supported_proto file | ||
62 | +_supported_os Linux | ||
63 | + | ||
64 | +if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then | ||
65 | + _notrun "Requires a PC machine" | ||
66 | +fi | ||
67 | + | ||
68 | +function do_run_qemu() | ||
69 | +{ | ||
70 | + echo Testing: "$@" | ||
71 | + | ||
72 | + ( | ||
73 | + if ! test -t 0; then | ||
74 | + while read cmd; do | ||
75 | + echo $cmd | ||
76 | + done | ||
77 | + fi | ||
78 | + echo quit | ||
79 | + ) | $QEMU -S -nodefaults -display none -device virtio-scsi-pci -monitor stdio "$@" | ||
80 | + echo | ||
81 | +} | ||
82 | + | ||
83 | +function check_info_block() | ||
84 | +{ | ||
85 | + echo "info block" | | ||
86 | + QEMU_OPTIONS="" do_run_qemu "$@" | _filter_win32 | _filter_hmp | | ||
87 | + _filter_qemu | _filter_generated_node_ids | ||
88 | +} | ||
89 | + | ||
90 | + | ||
91 | +size=64M | ||
92 | +_make_test_img $size | ||
93 | + | ||
94 | +removable="floppy ide-cd scsi-cd" | ||
95 | +fixed="ide-hd scsi-hd virtio-blk-pci" | ||
96 | + | ||
97 | +echo | ||
98 | +echo "=== Empty drives ===" | ||
99 | +echo | ||
100 | + | ||
101 | +for dev in $removable; do | ||
102 | + check_info_block -device $dev | ||
103 | + check_info_block -device $dev,id=qdev_id | ||
104 | +done | ||
105 | + | ||
106 | +echo | ||
107 | +echo "=== -blockdev/-device=<node-name> ===" | ||
108 | +echo | ||
109 | + | ||
110 | +for dev in $fixed $removable; do | ||
111 | + check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null | ||
112 | + check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null,id=qdev_id | ||
113 | +done | ||
114 | + | ||
115 | +echo | ||
116 | +echo "=== -drive if=none/-device=<node-name> ===" | ||
117 | +echo | ||
118 | + | ||
119 | +# This creates two BlockBackends that will show up in 'info block'! | ||
120 | +# A monitor-owned one from -drive, and anonymous one from -device | ||
121 | +for dev in $fixed $removable; do | ||
122 | + check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=null,id=qdev_id | ||
123 | +done | ||
124 | + | ||
125 | +echo | ||
126 | +echo "=== -drive if=none/-device=<bb-name> (with medium) ===" | ||
127 | +echo | ||
128 | + | ||
129 | +for dev in $fixed $removable; do | ||
130 | + check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0 | ||
131 | + check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0,id=qdev_id | ||
132 | +done | ||
133 | + | ||
134 | +echo | ||
135 | +echo "=== -drive if=none/-device=<bb-name> (without medium) ===" | ||
136 | +echo | ||
137 | + | ||
138 | +check_info_block -drive if=none | ||
139 | + | ||
140 | +for dev in $removable; do | ||
141 | + check_info_block -drive if=none -device $dev,drive=none0 | ||
142 | + check_info_block -drive if=none -device $dev,drive=none0,id=qdev_id | ||
143 | +done | ||
144 | + | ||
145 | +echo | ||
146 | +echo "=== -drive if=... ===" | ||
147 | +echo | ||
148 | + | ||
149 | +check_info_block -drive if=floppy | ||
150 | +check_info_block -drive if=floppy,driver=null-co | ||
151 | + | ||
152 | +check_info_block -drive if=ide,driver=null-co | ||
153 | +check_info_block -drive if=ide,media=cdrom | ||
154 | +check_info_block -drive if=ide,driver=null-co,media=cdrom | ||
155 | + | ||
156 | +check_info_block -drive if=scsi,driver=null-co | ||
157 | +check_info_block -drive if=scsi,media=cdrom | ||
158 | +check_info_block -drive if=scsi,driver=null-co,media=cdrom | ||
159 | + | ||
160 | +check_info_block -drive if=virtio,driver=null-co | ||
161 | + | ||
162 | +check_info_block -drive if=pflash,driver=null-co,size=1M | ||
163 | + | ||
164 | +# success, all done | ||
165 | +echo "*** done" | ||
166 | +rm -f $seq.full | ||
167 | +status=0 | ||
168 | diff --git a/tests/qemu-iotests/186.out b/tests/qemu-iotests/186.out | ||
169 | new file mode 100644 | ||
170 | index XXXXXXX..XXXXXXX | ||
171 | --- /dev/null | ||
172 | +++ b/tests/qemu-iotests/186.out | ||
173 | @@ -XXX,XX +XXX,XX @@ | ||
174 | +QA output created by 186 | ||
175 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
176 | + | ||
177 | +=== Empty drives === | ||
178 | + | ||
179 | +Testing: -device floppy | ||
180 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
181 | +(qemu) info block | ||
182 | +/machine/peripheral-anon/device[1]: [not inserted] | ||
183 | + Attached to: /machine/peripheral-anon/device[1] | ||
184 | + Removable device: not locked, tray closed | ||
185 | +(qemu) quit | ||
186 | + | ||
187 | +Testing: -device floppy,id=qdev_id | ||
188 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
189 | +(qemu) info block | ||
190 | +qdev_id: [not inserted] | ||
191 | + Attached to: qdev_id | ||
192 | + Removable device: not locked, tray closed | ||
193 | +(qemu) quit | ||
194 | + | ||
195 | +Testing: -device ide-cd | ||
196 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
197 | +(qemu) info block | ||
198 | +/machine/peripheral-anon/device[1]: [not inserted] | ||
199 | + Attached to: /machine/peripheral-anon/device[1] | ||
200 | + Removable device: not locked, tray closed | ||
201 | +(qemu) quit | ||
202 | + | ||
203 | +Testing: -device ide-cd,id=qdev_id | ||
204 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
205 | +(qemu) info block | ||
206 | +qdev_id: [not inserted] | ||
207 | + Attached to: qdev_id | ||
208 | + Removable device: not locked, tray closed | ||
209 | +(qemu) quit | ||
210 | + | ||
211 | +Testing: -device scsi-cd | ||
212 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
213 | +(qemu) info block | ||
214 | +/machine/peripheral-anon/device[1]: [not inserted] | ||
215 | + Attached to: /machine/peripheral-anon/device[1] | ||
216 | + Removable device: not locked, tray closed | ||
217 | +(qemu) quit | ||
218 | + | ||
219 | +Testing: -device scsi-cd,id=qdev_id | ||
220 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
221 | +(qemu) info block | ||
222 | +qdev_id: [not inserted] | ||
223 | + Attached to: qdev_id | ||
224 | + Removable device: not locked, tray closed | ||
225 | +(qemu) quit | ||
226 | + | ||
227 | + | ||
228 | +=== -blockdev/-device=<node-name> === | ||
229 | + | ||
230 | +Testing: -blockdev driver=null-co,node-name=null -device ide-hd,drive=null | ||
231 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
232 | +(qemu) info block | ||
233 | +null: null-co:// (null-co) | ||
234 | + Attached to: /machine/peripheral-anon/device[1] | ||
235 | + Cache mode: writeback | ||
236 | +(qemu) quit | ||
237 | + | ||
238 | +Testing: -blockdev driver=null-co,node-name=null -device ide-hd,drive=null,id=qdev_id | ||
239 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
240 | +(qemu) info block | ||
241 | +null: null-co:// (null-co) | ||
242 | + Attached to: qdev_id | ||
243 | + Cache mode: writeback | ||
244 | +(qemu) quit | ||
245 | + | ||
246 | +Testing: -blockdev driver=null-co,node-name=null -device scsi-hd,drive=null | ||
247 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
248 | +(qemu) info block | ||
249 | +null: null-co:// (null-co) | ||
250 | + Attached to: /machine/peripheral-anon/device[1] | ||
251 | + Cache mode: writeback | ||
252 | +(qemu) quit | ||
253 | + | ||
254 | +Testing: -blockdev driver=null-co,node-name=null -device scsi-hd,drive=null,id=qdev_id | ||
255 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
256 | +(qemu) info block | ||
257 | +null: null-co:// (null-co) | ||
258 | + Attached to: qdev_id | ||
259 | + Cache mode: writeback | ||
260 | +(qemu) quit | ||
261 | + | ||
262 | +Testing: -blockdev driver=null-co,node-name=null -device virtio-blk-pci,drive=null | ||
263 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
264 | +(qemu) info block | ||
265 | +null: null-co:// (null-co) | ||
266 | + Attached to: /machine/peripheral-anon/device[1]/virtio-backend | ||
267 | + Cache mode: writeback | ||
268 | +(qemu) quit | ||
269 | + | ||
270 | +Testing: -blockdev driver=null-co,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id | ||
271 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
272 | +(qemu) info block | ||
273 | +null: null-co:// (null-co) | ||
274 | + Attached to: /machine/peripheral/qdev_id/virtio-backend | ||
275 | + Cache mode: writeback | ||
276 | +(qemu) quit | ||
277 | + | ||
278 | +Testing: -blockdev driver=null-co,node-name=null -device floppy,drive=null | ||
279 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
280 | +(qemu) info block | ||
281 | +null: null-co:// (null-co) | ||
282 | + Attached to: /machine/peripheral-anon/device[1] | ||
283 | + Removable device: not locked, tray closed | ||
284 | + Cache mode: writeback | ||
285 | +(qemu) quit | ||
286 | + | ||
287 | +Testing: -blockdev driver=null-co,node-name=null -device floppy,drive=null,id=qdev_id | ||
288 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
289 | +(qemu) info block | ||
290 | +null: null-co:// (null-co) | ||
291 | + Attached to: qdev_id | ||
292 | + Removable device: not locked, tray closed | ||
293 | + Cache mode: writeback | ||
294 | +(qemu) quit | ||
295 | + | ||
296 | +Testing: -blockdev driver=null-co,node-name=null -device ide-cd,drive=null | ||
297 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
298 | +(qemu) info block | ||
299 | +null: null-co:// (null-co) | ||
300 | + Attached to: /machine/peripheral-anon/device[1] | ||
301 | + Removable device: not locked, tray closed | ||
302 | + Cache mode: writeback | ||
303 | +(qemu) quit | ||
304 | + | ||
305 | +Testing: -blockdev driver=null-co,node-name=null -device ide-cd,drive=null,id=qdev_id | ||
306 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
307 | +(qemu) info block | ||
308 | +null: null-co:// (null-co) | ||
309 | + Attached to: qdev_id | ||
310 | + Removable device: not locked, tray closed | ||
311 | + Cache mode: writeback | ||
312 | +(qemu) quit | ||
313 | + | ||
314 | +Testing: -blockdev driver=null-co,node-name=null -device scsi-cd,drive=null | ||
315 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
316 | +(qemu) info block | ||
317 | +null: null-co:// (null-co) | ||
318 | + Attached to: /machine/peripheral-anon/device[1] | ||
319 | + Removable device: not locked, tray closed | ||
320 | + Cache mode: writeback | ||
321 | +(qemu) quit | ||
322 | + | ||
323 | +Testing: -blockdev driver=null-co,node-name=null -device scsi-cd,drive=null,id=qdev_id | ||
324 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
325 | +(qemu) info block | ||
326 | +null: null-co:// (null-co) | ||
327 | + Attached to: qdev_id | ||
328 | + Removable device: not locked, tray closed | ||
329 | + Cache mode: writeback | ||
330 | +(qemu) quit | ||
331 | + | ||
332 | + | ||
333 | +=== -drive if=none/-device=<node-name> === | ||
334 | + | ||
335 | +Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=null,id=qdev_id | ||
336 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
337 | +(qemu) info block | ||
338 | +none0 (null): null-co:// (null-co) | ||
339 | + Removable device: not locked, tray closed | ||
340 | + Cache mode: writeback | ||
341 | + | ||
342 | +null: null-co:// (null-co) | ||
343 | + Attached to: qdev_id | ||
344 | + Cache mode: writeback | ||
345 | +(qemu) quit | ||
346 | + | ||
347 | +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=null,id=qdev_id | ||
348 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
349 | +(qemu) info block | ||
350 | +none0 (null): null-co:// (null-co) | ||
351 | + Removable device: not locked, tray closed | ||
352 | + Cache mode: writeback | ||
353 | + | ||
354 | +null: null-co:// (null-co) | ||
355 | + Attached to: qdev_id | ||
356 | + Cache mode: writeback | ||
357 | +(qemu) quit | ||
358 | + | ||
359 | +Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=null,id=qdev_id | ||
360 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
361 | +(qemu) info block | ||
362 | +none0 (null): null-co:// (null-co) | ||
363 | + Removable device: not locked, tray closed | ||
364 | + Cache mode: writeback | ||
365 | + | ||
366 | +null: null-co:// (null-co) | ||
367 | + Attached to: /machine/peripheral/qdev_id/virtio-backend | ||
368 | + Cache mode: writeback | ||
369 | +(qemu) quit | ||
370 | + | ||
371 | +Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=null,id=qdev_id | ||
372 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
373 | +(qemu) info block | ||
374 | +none0 (null): null-co:// (null-co) | ||
375 | + Removable device: not locked, tray closed | ||
376 | + Cache mode: writeback | ||
377 | + | ||
378 | +null: null-co:// (null-co) | ||
379 | + Attached to: qdev_id | ||
380 | + Removable device: not locked, tray closed | ||
381 | + Cache mode: writeback | ||
382 | +(qemu) quit | ||
383 | + | ||
384 | +Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=null,id=qdev_id | ||
385 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
386 | +(qemu) info block | ||
387 | +none0 (null): null-co:// (null-co) | ||
388 | + Removable device: not locked, tray closed | ||
389 | + Cache mode: writeback | ||
390 | + | ||
391 | +null: null-co:// (null-co) | ||
392 | + Attached to: qdev_id | ||
393 | + Removable device: not locked, tray closed | ||
394 | + Cache mode: writeback | ||
395 | +(qemu) quit | ||
396 | + | ||
397 | +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=null,id=qdev_id | ||
398 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
399 | +(qemu) info block | ||
400 | +none0 (null): null-co:// (null-co) | ||
401 | + Removable device: not locked, tray closed | ||
402 | + Cache mode: writeback | ||
403 | + | ||
404 | +null: null-co:// (null-co) | ||
405 | + Attached to: qdev_id | ||
406 | + Removable device: not locked, tray closed | ||
407 | + Cache mode: writeback | ||
408 | +(qemu) quit | ||
409 | + | ||
410 | + | ||
411 | +=== -drive if=none/-device=<bb-name> (with medium) === | ||
412 | + | ||
413 | +Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=none0 | ||
414 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
415 | +(qemu) info block | ||
416 | +none0 (null): null-co:// (null-co) | ||
417 | + Attached to: /machine/peripheral-anon/device[1] | ||
418 | + Cache mode: writeback | ||
419 | +(qemu) quit | ||
420 | + | ||
421 | +Testing: -drive if=none,driver=null-co,node-name=null -device ide-hd,drive=none0,id=qdev_id | ||
422 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
423 | +(qemu) info block | ||
424 | +none0 (null): null-co:// (null-co) | ||
425 | + Attached to: qdev_id | ||
426 | + Cache mode: writeback | ||
427 | +(qemu) quit | ||
428 | + | ||
429 | +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=none0 | ||
430 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
431 | +(qemu) info block | ||
432 | +none0 (null): null-co:// (null-co) | ||
433 | + Attached to: /machine/peripheral-anon/device[1] | ||
434 | + Cache mode: writeback | ||
435 | +(qemu) quit | ||
436 | + | ||
437 | +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-hd,drive=none0,id=qdev_id | ||
438 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
439 | +(qemu) info block | ||
440 | +none0 (null): null-co:// (null-co) | ||
441 | + Attached to: qdev_id | ||
442 | + Cache mode: writeback | ||
443 | +(qemu) quit | ||
444 | + | ||
445 | +Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=none0 | ||
446 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
447 | +(qemu) info block | ||
448 | +none0 (null): null-co:// (null-co) | ||
449 | + Attached to: /machine/peripheral-anon/device[1]/virtio-backend | ||
450 | + Cache mode: writeback | ||
451 | +(qemu) quit | ||
452 | + | ||
453 | +Testing: -drive if=none,driver=null-co,node-name=null -device virtio-blk-pci,drive=none0,id=qdev_id | ||
454 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
455 | +(qemu) info block | ||
456 | +none0 (null): null-co:// (null-co) | ||
457 | + Attached to: /machine/peripheral/qdev_id/virtio-backend | ||
458 | + Cache mode: writeback | ||
459 | +(qemu) quit | ||
460 | + | ||
461 | +Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=none0 | ||
462 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
463 | +(qemu) info block | ||
464 | +none0 (null): null-co:// (null-co) | ||
465 | + Attached to: /machine/peripheral-anon/device[1] | ||
466 | + Removable device: not locked, tray closed | ||
467 | + Cache mode: writeback | ||
468 | +(qemu) quit | ||
469 | + | ||
470 | +Testing: -drive if=none,driver=null-co,node-name=null -device floppy,drive=none0,id=qdev_id | ||
471 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
472 | +(qemu) info block | ||
473 | +none0 (null): null-co:// (null-co) | ||
474 | + Attached to: qdev_id | ||
475 | + Removable device: not locked, tray closed | ||
476 | + Cache mode: writeback | ||
477 | +(qemu) quit | ||
478 | + | ||
479 | +Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=none0 | ||
480 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
481 | +(qemu) info block | ||
482 | +none0 (null): null-co:// (null-co) | ||
483 | + Attached to: /machine/peripheral-anon/device[1] | ||
484 | + Removable device: not locked, tray closed | ||
485 | + Cache mode: writeback | ||
486 | +(qemu) quit | ||
487 | + | ||
488 | +Testing: -drive if=none,driver=null-co,node-name=null -device ide-cd,drive=none0,id=qdev_id | ||
489 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
490 | +(qemu) info block | ||
491 | +none0 (null): null-co:// (null-co) | ||
492 | + Attached to: qdev_id | ||
493 | + Removable device: not locked, tray closed | ||
494 | + Cache mode: writeback | ||
495 | +(qemu) quit | ||
496 | + | ||
497 | +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=none0 | ||
498 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
499 | +(qemu) info block | ||
500 | +none0 (null): null-co:// (null-co) | ||
501 | + Attached to: /machine/peripheral-anon/device[1] | ||
502 | + Removable device: not locked, tray closed | ||
503 | + Cache mode: writeback | ||
504 | +(qemu) quit | ||
505 | + | ||
506 | +Testing: -drive if=none,driver=null-co,node-name=null -device scsi-cd,drive=none0,id=qdev_id | ||
507 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
508 | +(qemu) info block | ||
509 | +none0 (null): null-co:// (null-co) | ||
510 | + Attached to: qdev_id | ||
511 | + Removable device: not locked, tray closed | ||
512 | + Cache mode: writeback | ||
513 | +(qemu) quit | ||
514 | + | ||
515 | + | ||
516 | +=== -drive if=none/-device=<bb-name> (without medium) === | ||
517 | + | ||
518 | +Testing: -drive if=none | ||
519 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
520 | +(qemu) info block | ||
521 | +none0: [not inserted] | ||
522 | + Removable device: not locked, tray closed | ||
523 | +(qemu) quit | ||
524 | + | ||
525 | +Testing: -drive if=none -device floppy,drive=none0 | ||
526 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
527 | +(qemu) info block | ||
528 | +none0: [not inserted] | ||
529 | + Attached to: /machine/peripheral-anon/device[1] | ||
530 | + Removable device: not locked, tray closed | ||
531 | +(qemu) quit | ||
532 | + | ||
533 | +Testing: -drive if=none -device floppy,drive=none0,id=qdev_id | ||
534 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
535 | +(qemu) info block | ||
536 | +none0: [not inserted] | ||
537 | + Attached to: qdev_id | ||
538 | + Removable device: not locked, tray closed | ||
539 | +(qemu) quit | ||
540 | + | ||
541 | +Testing: -drive if=none -device ide-cd,drive=none0 | ||
542 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
543 | +(qemu) info block | ||
544 | +none0: [not inserted] | ||
545 | + Attached to: /machine/peripheral-anon/device[1] | ||
546 | + Removable device: not locked, tray closed | ||
547 | +(qemu) quit | ||
548 | + | ||
549 | +Testing: -drive if=none -device ide-cd,drive=none0,id=qdev_id | ||
550 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
551 | +(qemu) info block | ||
552 | +none0: [not inserted] | ||
553 | + Attached to: qdev_id | ||
554 | + Removable device: not locked, tray closed | ||
555 | +(qemu) quit | ||
556 | + | ||
557 | +Testing: -drive if=none -device scsi-cd,drive=none0 | ||
558 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
559 | +(qemu) info block | ||
560 | +none0: [not inserted] | ||
561 | + Attached to: /machine/peripheral-anon/device[1] | ||
562 | + Removable device: not locked, tray closed | ||
563 | +(qemu) quit | ||
564 | + | ||
565 | +Testing: -drive if=none -device scsi-cd,drive=none0,id=qdev_id | ||
566 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
567 | +(qemu) info block | ||
568 | +none0: [not inserted] | ||
569 | + Attached to: qdev_id | ||
570 | + Removable device: not locked, tray closed | ||
571 | +(qemu) quit | ||
572 | + | ||
573 | + | ||
574 | +=== -drive if=... === | ||
575 | + | ||
576 | +Testing: -drive if=floppy | ||
577 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
578 | +(qemu) info block | ||
579 | +floppy0: [not inserted] | ||
580 | + Attached to: /machine/unattached/device[17] | ||
581 | + Removable device: not locked, tray closed | ||
582 | +(qemu) quit | ||
583 | + | ||
584 | +Testing: -drive if=floppy,driver=null-co | ||
585 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
586 | +(qemu) info block | ||
587 | +floppy0 (NODE_NAME): null-co:// (null-co) | ||
588 | + Attached to: /machine/unattached/device[17] | ||
589 | + Removable device: not locked, tray closed | ||
590 | + Cache mode: writeback | ||
591 | +(qemu) quit | ||
592 | + | ||
593 | +Testing: -drive if=ide,driver=null-co | ||
594 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
595 | +(qemu) info block | ||
596 | +ide0-hd0 (NODE_NAME): null-co:// (null-co) | ||
597 | + Attached to: /machine/unattached/device[18] | ||
598 | + Cache mode: writeback | ||
599 | +(qemu) quit | ||
600 | + | ||
601 | +Testing: -drive if=ide,media=cdrom | ||
602 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
603 | +(qemu) info block | ||
604 | +ide0-cd0: [not inserted] | ||
605 | + Attached to: /machine/unattached/device[18] | ||
606 | + Removable device: not locked, tray closed | ||
607 | +(qemu) quit | ||
608 | + | ||
609 | +Testing: -drive if=ide,driver=null-co,media=cdrom | ||
610 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
611 | +(qemu) info block | ||
612 | +ide0-cd0 (NODE_NAME): null-co:// (null-co, read-only) | ||
613 | + Attached to: /machine/unattached/device[18] | ||
614 | + Removable device: not locked, tray closed | ||
615 | + Cache mode: writeback | ||
616 | +(qemu) quit | ||
617 | + | ||
618 | +warning: qemu-system-x86_64: -drive if=scsi,driver=null-co: bus=0,unit=0 is deprecated with this machine type | ||
619 | +Testing: -drive if=scsi,driver=null-co | ||
620 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
621 | +(qemu) info block | ||
622 | +scsi0-hd0 (NODE_NAME): null-co:// (null-co) | ||
623 | + Attached to: /machine/unattached/device[27]/scsi.0/legacy[0] | ||
624 | + Cache mode: writeback | ||
625 | +(qemu) quit | ||
626 | + | ||
627 | +warning: qemu-system-x86_64: -drive if=scsi,media=cdrom: bus=0,unit=0 is deprecated with this machine type | ||
628 | +Testing: -drive if=scsi,media=cdrom | ||
629 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
630 | +(qemu) info block | ||
631 | +scsi0-cd0: [not inserted] | ||
632 | + Attached to: /machine/unattached/device[27]/scsi.0/legacy[0] | ||
633 | + Removable device: not locked, tray closed | ||
634 | +(qemu) quit | ||
635 | + | ||
636 | +warning: qemu-system-x86_64: -drive if=scsi,driver=null-co,media=cdrom: bus=0,unit=0 is deprecated with this machine type | ||
637 | +Testing: -drive if=scsi,driver=null-co,media=cdrom | ||
638 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
639 | +(qemu) info block | ||
640 | +scsi0-cd0 (NODE_NAME): null-co:// (null-co, read-only) | ||
641 | + Attached to: /machine/unattached/device[27]/scsi.0/legacy[0] | ||
642 | + Removable device: not locked, tray closed | ||
643 | + Cache mode: writeback | ||
644 | +(qemu) quit | ||
645 | + | ||
646 | +Testing: -drive if=virtio,driver=null-co | ||
647 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
648 | +(qemu) info block | ||
649 | +virtio0 (NODE_NAME): null-co:// (null-co) | ||
650 | + Attached to: /machine/peripheral-anon/device[1]/virtio-backend | ||
651 | + Cache mode: writeback | ||
652 | +(qemu) quit | ||
653 | + | ||
654 | +Testing: -drive if=pflash,driver=null-co,size=1M | ||
655 | +QEMU X.Y.Z monitor - type 'help' for more information | ||
656 | +(qemu) info block | ||
657 | +pflash0 (NODE_NAME): json:{"driver": "null-co", "size": "1M"} (null-co) | ||
658 | + Attached to: /machine/unattached/device[2] | ||
659 | + Cache mode: writeback | ||
660 | +(qemu) quit | ||
661 | + | ||
662 | +*** done | ||
663 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | ||
664 | index XXXXXXX..XXXXXXX 100644 | ||
665 | --- a/tests/qemu-iotests/group | ||
666 | +++ b/tests/qemu-iotests/group | ||
667 | @@ -XXX,XX +XXX,XX @@ | ||
668 | 182 rw auto quick | ||
669 | 183 rw auto migration | ||
670 | 185 rw auto | ||
671 | +186 rw auto | ||
672 | 188 rw auto quick | ||
673 | 189 rw auto quick | ||
674 | -- | ||
675 | 1.8.3.1 | ||
676 | |||
677 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This caused an assertion failure until recently because the BlockBackend | ||
2 | would be detached on unplug, but was in fact never attached in the first | ||
3 | place. Add a regression test. | ||
4 | 1 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | --- | ||
9 | tests/qemu-iotests/067 | 13 +++++++++++++ | ||
10 | tests/qemu-iotests/067.out | 39 +++++++++++++++++++++++++++++++++++++++ | ||
11 | 2 files changed, 52 insertions(+) | ||
12 | |||
13 | diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067 | ||
14 | index XXXXXXX..XXXXXXX 100755 | ||
15 | --- a/tests/qemu-iotests/067 | ||
16 | +++ b/tests/qemu-iotests/067 | ||
17 | @@ -XXX,XX +XXX,XX @@ run_qemu <<EOF | ||
18 | { "execute": "quit" } | ||
19 | EOF | ||
20 | |||
21 | +echo | ||
22 | +echo === Empty drive with -device and device_del === | ||
23 | +echo | ||
24 | + | ||
25 | +run_qemu -device virtio-scsi-pci -device scsi-cd,id=cd0 <<EOF | ||
26 | +{ "execute": "qmp_capabilities" } | ||
27 | +{ "execute": "query-block" } | ||
28 | +{ "execute": "device_del", "arguments": { "id": "cd0" } } | ||
29 | +{ "execute": "system_reset" } | ||
30 | +{ "execute": "query-block" } | ||
31 | +{ "execute": "quit" } | ||
32 | +EOF | ||
33 | + | ||
34 | # success, all done | ||
35 | echo "*** done" | ||
36 | rm -f $seq.full | ||
37 | diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/tests/qemu-iotests/067.out | ||
40 | +++ b/tests/qemu-iotests/067.out | ||
41 | @@ -XXX,XX +XXX,XX @@ Testing: | ||
42 | "return": { | ||
43 | } | ||
44 | } | ||
45 | + | ||
46 | +=== Empty drive with -device and device_del === | ||
47 | + | ||
48 | +Testing: -device virtio-scsi-pci -device scsi-cd,id=cd0 | ||
49 | +{ | ||
50 | + QMP_VERSION | ||
51 | +} | ||
52 | +{ | ||
53 | + "return": { | ||
54 | + } | ||
55 | +} | ||
56 | +{ | ||
57 | + "return": [ | ||
58 | + { | ||
59 | + "device": "", | ||
60 | + "locked": false, | ||
61 | + "removable": true, | ||
62 | + "qdev": "cd0", | ||
63 | + "tray_open": false, | ||
64 | + "type": "unknown" | ||
65 | + } | ||
66 | + ] | ||
67 | +} | ||
68 | +{ | ||
69 | + "return": { | ||
70 | + } | ||
71 | +} | ||
72 | +{ | ||
73 | + "return": { | ||
74 | + } | ||
75 | +} | ||
76 | +{ | ||
77 | + "return": [ | ||
78 | + ] | ||
79 | +} | ||
80 | +{ | ||
81 | + "return": { | ||
82 | + } | ||
83 | +} | ||
84 | *** done | ||
85 | -- | ||
86 | 1.8.3.1 | ||
87 | |||
88 | diff view generated by jsdifflib |