1
The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4:
1
The following changes since commit 8507c9d5c9a62de2a0e281b640f995e26eac46af:
2
2
3
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging (2019-08-27 15:52:36 +0100)
3
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2020-11-03 15:59:44 +0000)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c:
9
for you to fetch changes up to fc107d86840b3364e922c26cf7631b7fd38ce523:
10
10
11
iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200)
11
util/vfio-helpers: Assert offset is aligned to page size (2020-11-03 19:06:23 +0000)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches:
14
Pull request for 5.2
15
- qemu-io now accepts a file to read a write pattern from
15
16
- Ensure that raw files have their first block allocated so we can probe
16
NVMe fixes to solve IOMMU issues on non-x86 and error message/tracing
17
the O_DIRECT alignment if necessary
17
improvements. Elena Afanasova's ioeventfd fixes are also included.
18
- Various fixes
18
19
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
19
20
20
----------------------------------------------------------------
21
----------------------------------------------------------------
21
Denis Plotnikov (1):
22
qemu-io: add pattern file for write command
23
22
24
Max Reitz (7):
23
Elena Afanasova (2):
25
iotests: Fix _filter_img_create()
24
accel/kvm: add PIO ioeventfds only in case kvm_eventfds_allowed is
26
vmdk: Use bdrv_dirname() for relative extent paths
25
true
27
iotests: Keep testing broken relative extent paths
26
softmmu/memory: fix memory_region_ioeventfd_equal()
28
vmdk: Reject invalid compressed writes
29
iotests: Disable broken streamOptimized tests
30
iotests: Disable 110 for vmdk.twoGbMaxExtentSparse
31
iotests: Disable 126 for flat vmdk subformats
32
27
33
Nir Soffer (3):
28
Eric Auger (4):
34
block: posix: Always allocate the first block
29
block/nvme: Change size and alignment of IDENTIFY response buffer
35
iotests: Test allocate_first_block() with O_DIRECT
30
block/nvme: Change size and alignment of queue
36
iotests: Unify cache mode quoting
31
block/nvme: Change size and alignment of prp_list_pages
32
block/nvme: Align iov's va and size on host page size
37
33
38
Stefan Hajnoczi (1):
34
Philippe Mathieu-Daudé (27):
39
file-posix: fix request_alignment typo
35
MAINTAINERS: Cover "block/nvme.h" file
36
block/nvme: Use hex format to display offset in trace events
37
block/nvme: Report warning with warn_report()
38
block/nvme: Trace controller capabilities
39
block/nvme: Trace nvme_poll_queue() per queue
40
block/nvme: Improve nvme_free_req_queue_wait() trace information
41
block/nvme: Trace queue pair creation/deletion
42
block/nvme: Move definitions before structure declarations
43
block/nvme: Use unsigned integer for queue counter/size
44
block/nvme: Make nvme_identify() return boolean indicating error
45
block/nvme: Make nvme_init_queue() return boolean indicating error
46
block/nvme: Introduce Completion Queue definitions
47
block/nvme: Use definitions instead of magic values in add_io_queue()
48
block/nvme: Correctly initialize Admin Queue Attributes
49
block/nvme: Simplify ADMIN queue access
50
block/nvme: Simplify nvme_cmd_sync()
51
block/nvme: Set request_alignment at initialization
52
block/nvme: Correct minimum device page size
53
block/nvme: Fix use of write-only doorbells page on Aarch64 arch
54
block/nvme: Fix nvme_submit_command() on big-endian host
55
util/vfio-helpers: Improve reporting unsupported IOMMU type
56
util/vfio-helpers: Trace PCI I/O config accesses
57
util/vfio-helpers: Trace PCI BAR region info
58
util/vfio-helpers: Trace where BARs are mapped
59
util/vfio-helpers: Improve DMA trace events
60
util/vfio-helpers: Convert vfio_dump_mapping to trace events
61
util/vfio-helpers: Assert offset is aligned to page size
40
62
41
Thomas Huth (2):
63
MAINTAINERS | 2 +
42
iotests: Check for enabled drivers before testing them
64
include/block/nvme.h | 18 ++--
43
tests/check-block: Skip iotests when sanitizers are enabled
65
accel/kvm/kvm-all.c | 6 +-
44
66
block/nvme.c | 209 ++++++++++++++++++++++++-------------------
45
Vladimir Sementsov-Ogievskiy (1):
67
softmmu/memory.c | 11 ++-
46
block: fix permission update in bdrv_replace_node
68
util/vfio-helpers.c | 43 +++++----
47
69
block/trace-events | 30 ++++---
48
block.c | 5 +-
70
util/trace-events | 10 ++-
49
block/file-posix.c | 53 +++++++++-
71
8 files changed, 195 insertions(+), 134 deletions(-)
50
block/vmdk.c | 64 ++++++++----
51
qemu-io-cmds.c | 99 +++++++++++++++++--
52
tests/check-block.sh | 5 +
53
tests/qemu-iotests/002 | 1 +
54
tests/qemu-iotests/003 | 1 +
55
tests/qemu-iotests/005 | 3 +-
56
tests/qemu-iotests/009 | 1 +
57
tests/qemu-iotests/010 | 1 +
58
tests/qemu-iotests/011 | 1 +
59
tests/qemu-iotests/017 | 3 +-
60
tests/qemu-iotests/018 | 3 +-
61
tests/qemu-iotests/019 | 3 +-
62
tests/qemu-iotests/020 | 3 +-
63
tests/qemu-iotests/026 | 4 +-
64
tests/qemu-iotests/027 | 1 +
65
tests/qemu-iotests/032 | 1 +
66
tests/qemu-iotests/033 | 1 +
67
tests/qemu-iotests/034 | 3 +-
68
tests/qemu-iotests/037 | 3 +-
69
tests/qemu-iotests/039 | 4 +-
70
tests/qemu-iotests/052 | 2 +-
71
tests/qemu-iotests/059 | 34 ++++++-
72
tests/qemu-iotests/059.out | 26 +++--
73
tests/qemu-iotests/063 | 3 +-
74
tests/qemu-iotests/071 | 1 +
75
tests/qemu-iotests/072 | 1 +
76
tests/qemu-iotests/081 | 4 +-
77
tests/qemu-iotests/091 | 4 +-
78
tests/qemu-iotests/099 | 1 +
79
tests/qemu-iotests/105 | 3 +-
80
tests/qemu-iotests/110 | 3 +-
81
tests/qemu-iotests/120 | 1 +
82
tests/qemu-iotests/126 | 2 +
83
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
84
tests/qemu-iotests/150.out.raw | 12 +++
85
tests/qemu-iotests/162 | 4 +-
86
tests/qemu-iotests/175 | 47 +++++++--
87
tests/qemu-iotests/175.out | 16 ++-
88
tests/qemu-iotests/178.out.qcow2 | 4 +-
89
tests/qemu-iotests/184 | 1 +
90
tests/qemu-iotests/186 | 1 +
91
tests/qemu-iotests/197 | 1 +
92
tests/qemu-iotests/215 | 1 +
93
tests/qemu-iotests/221.out | 12 ++-
94
tests/qemu-iotests/251 | 1 +
95
tests/qemu-iotests/253.out | 12 ++-
96
tests/qemu-iotests/common.filter | 4 +-
97
tests/qemu-iotests/common.rc | 14 +++
98
50 files changed, 391 insertions(+), 87 deletions(-)
99
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
100
create mode 100644 tests/qemu-iotests/150.out.raw
101
72
102
--
73
--
103
2.21.0
74
2.28.0
104
75
105
diff view generated by jsdifflib
1
The error message for the test case where we have a quorum node for
1
From: Elena Afanasova <eafanasova@gmail.com>
2
which no directory name can be generated is different: For
3
twoGbMaxExtentSparse, it complains that it cannot open the extent file.
4
For other (sub)formats, it just notes that it cannot determine the
5
backing file path. Both are fine, but just disable twoGbMaxExtentSparse
6
for simplicity's sake.
7
2
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: John Snow <jsnow@redhat.com>
4
Signed-off-by: Elena Afanasova <eafanasova@gmail.com>
10
Message-id: 20190815153638.4600-7-mreitz@redhat.com
5
Message-Id: <20201017210102.26036-1-eafanasova@gmail.com>
11
Reviewed-by: John Snow <jsnow@redhat.com>
6
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
7
---
14
tests/qemu-iotests/110 | 3 ++-
8
accel/kvm/kvm-all.c | 6 ++++--
15
1 file changed, 2 insertions(+), 1 deletion(-)
9
1 file changed, 4 insertions(+), 2 deletions(-)
16
10
17
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
11
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
18
index XXXXXXX..XXXXXXX 100755
12
index XXXXXXX..XXXXXXX 100644
19
--- a/tests/qemu-iotests/110
13
--- a/accel/kvm/kvm-all.c
20
+++ b/tests/qemu-iotests/110
14
+++ b/accel/kvm/kvm-all.c
21
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
15
@@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms)
22
# Any format supporting backing files
16
23
_supported_fmt qed qcow qcow2 vmdk
17
kvm_memory_listener_register(s, &s->memory_listener,
24
_supported_proto file
18
&address_space_memory, 0);
25
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
19
- memory_listener_register(&kvm_io_listener,
26
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
20
- &address_space_io);
27
+ "subformat=twoGbMaxExtentSparse"
21
+ if (kvm_eventfds_allowed) {
28
22
+ memory_listener_register(&kvm_io_listener,
29
TEST_IMG_REL=$(basename "$TEST_IMG")
23
+ &address_space_io);
24
+ }
25
memory_listener_register(&kvm_coalesced_pio_listener,
26
&address_space_io);
30
27
31
--
28
--
32
2.21.0
29
2.28.0
33
30
34
diff view generated by jsdifflib
New patch
1
From: Elena Afanasova <eafanasova@gmail.com>
1
2
3
Eventfd can be registered with a zero length when fast_mmio is true.
4
Handle this case properly when dispatching through QEMU.
5
6
Signed-off-by: Elena Afanasova <eafanasova@gmail.com>
7
Message-id: cf71a62eb04e61932ff8ffdd02e0b2aab4f495a0.camel@gmail.com
8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
---
10
softmmu/memory.c | 11 +++++++++--
11
1 file changed, 9 insertions(+), 2 deletions(-)
12
13
diff --git a/softmmu/memory.c b/softmmu/memory.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/softmmu/memory.c
16
+++ b/softmmu/memory.c
17
@@ -XXX,XX +XXX,XX @@ static bool memory_region_ioeventfd_before(MemoryRegionIoeventfd *a,
18
static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd *a,
19
MemoryRegionIoeventfd *b)
20
{
21
- return !memory_region_ioeventfd_before(a, b)
22
- && !memory_region_ioeventfd_before(b, a);
23
+ if (int128_eq(a->addr.start, b->addr.start) &&
24
+ (!int128_nz(a->addr.size) || !int128_nz(b->addr.size) ||
25
+ (int128_eq(a->addr.size, b->addr.size) &&
26
+ (a->match_data == b->match_data) &&
27
+ ((a->match_data && (a->data == b->data)) || !a->match_data) &&
28
+ (a->e == b->e))))
29
+ return true;
30
+
31
+ return false;
32
}
33
34
/* Range of memory in the global map. Addresses are absolute. */
35
--
36
2.28.0
37
diff view generated by jsdifflib
1
iotest 126 requires backing file support, which flat vmdks cannot offer.
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
Skip this test for such subformats.
3
2
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
The "block/nvme.h" header is shared by both the NVMe block
5
Message-id: 20190815153638.4600-8-mreitz@redhat.com
4
driver and the NVMe emulated device. Add the 'F:' entry on
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
both sections, so all maintainers/reviewers are notified
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
when it is changed.
7
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
11
Message-Id: <20200701140634.25994-1-philmd@redhat.com>
8
---
12
---
9
tests/qemu-iotests/126 | 2 ++
13
MAINTAINERS | 2 ++
10
1 file changed, 2 insertions(+)
14
1 file changed, 2 insertions(+)
11
15
12
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
16
diff --git a/MAINTAINERS b/MAINTAINERS
13
index XXXXXXX..XXXXXXX 100755
17
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/qemu-iotests/126
18
--- a/MAINTAINERS
15
+++ b/tests/qemu-iotests/126
19
+++ b/MAINTAINERS
16
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
20
@@ -XXX,XX +XXX,XX @@ M: Klaus Jensen <its@irrelevant.dk>
17
21
L: qemu-block@nongnu.org
18
# Needs backing file support
22
S: Supported
19
_supported_fmt qcow qcow2 qed vmdk
23
F: hw/block/nvme*
20
+_unsupported_imgopts "subformat=monolithicFlat" \
24
+F: include/block/nvme.h
21
+ "subformat=twoGbMaxExtentFlat"
25
F: tests/qtest/nvme-test.c
22
# This is the default protocol (and we want to test the difference between
26
F: docs/specs/nvme.txt
23
# colons which separate a protocol prefix from the rest and colons which are
27
T: git git://git.infradead.org/qemu-nvme.git nvme-next
24
# just part of the filename, so we cannot test protocols which require a prefix)
28
@@ -XXX,XX +XXX,XX @@ R: Fam Zheng <fam@euphon.net>
29
L: qemu-block@nongnu.org
30
S: Supported
31
F: block/nvme*
32
+F: include/block/nvme.h
33
T: git https://github.com/stefanha/qemu.git block
34
35
Bootdevice
25
--
36
--
26
2.21.0
37
2.28.0
27
38
28
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use the same format used for the hw/vfio/ trace events.
4
5
Suggested-by: Eric Auger <eric.auger@redhat.com>
6
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Tested-by: Eric Auger <eric.auger@redhat.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Message-id: 20201029093306.1063879-3-philmd@redhat.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Tested-by: Eric Auger <eric.auger@redhat.com>
13
---
14
block/trace-events | 12 ++++++------
15
1 file changed, 6 insertions(+), 6 deletions(-)
16
17
diff --git a/block/trace-events b/block/trace-events
18
index XXXXXXX..XXXXXXX 100644
19
--- a/block/trace-events
20
+++ b/block/trace-events
21
@@ -XXX,XX +XXX,XX @@ nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d"
22
nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, int c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x"
23
nvme_handle_event(void *s) "s %p"
24
nvme_poll_cb(void *s) "s %p"
25
-nvme_prw_aligned(void *s, int is_write, uint64_t offset, uint64_t bytes, int flags, int niov) "s %p is_write %d offset %"PRId64" bytes %"PRId64" flags %d niov %d"
26
-nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s %p offset %"PRId64" bytes %"PRId64" flags %d"
27
+nvme_prw_aligned(void *s, int is_write, uint64_t offset, uint64_t bytes, int flags, int niov) "s %p is_write %d offset 0x%"PRIx64" bytes %"PRId64" flags %d niov %d"
28
+nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s %p offset 0x%"PRIx64" bytes %"PRId64" flags %d"
29
nvme_qiov_unaligned(const void *qiov, int n, void *base, size_t size, int align) "qiov %p n %d base %p size 0x%zx align 0x%x"
30
-nvme_prw_buffered(void *s, uint64_t offset, uint64_t bytes, int niov, int is_write) "s %p offset %"PRId64" bytes %"PRId64" niov %d is_write %d"
31
-nvme_rw_done(void *s, int is_write, uint64_t offset, uint64_t bytes, int ret) "s %p is_write %d offset %"PRId64" bytes %"PRId64" ret %d"
32
-nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset %"PRId64" bytes %"PRId64""
33
-nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset %"PRId64" bytes %"PRId64" ret %d"
34
+nvme_prw_buffered(void *s, uint64_t offset, uint64_t bytes, int niov, int is_write) "s %p offset 0x%"PRIx64" bytes %"PRId64" niov %d is_write %d"
35
+nvme_rw_done(void *s, int is_write, uint64_t offset, uint64_t bytes, int ret) "s %p is_write %d offset 0x%"PRIx64" bytes %"PRId64" ret %d"
36
+nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset 0x%"PRIx64" bytes %"PRId64""
37
+nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset 0x%"PRIx64" bytes %"PRId64" ret %d"
38
nvme_dma_map_flush(void *s) "s %p"
39
nvme_free_req_queue_wait(void *q) "q %p"
40
nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d"
41
--
42
2.28.0
43
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Instead of displaying warning on stderr, use warn_report()
4
which also displays it on the monitor.
5
6
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Tested-by: Eric Auger <eric.auger@redhat.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Message-id: 20201029093306.1063879-4-philmd@redhat.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Tested-by: Eric Auger <eric.auger@redhat.com>
13
---
14
block/nvme.c | 4 ++--
15
1 file changed, 2 insertions(+), 2 deletions(-)
16
17
diff --git a/block/nvme.c b/block/nvme.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/block/nvme.c
20
+++ b/block/nvme.c
21
@@ -XXX,XX +XXX,XX @@ static bool nvme_process_completion(NVMeQueuePair *q)
22
}
23
cid = le16_to_cpu(c->cid);
24
if (cid == 0 || cid > NVME_QUEUE_SIZE) {
25
- fprintf(stderr, "Unexpected CID in completion queue: %" PRIu32 "\n",
26
- cid);
27
+ warn_report("NVMe: Unexpected CID in completion queue: %"PRIu32", "
28
+ "queue size: %u", cid, NVME_QUEUE_SIZE);
29
continue;
30
}
31
trace_nvme_complete_command(s, q->index, cid);
32
--
33
2.28.0
34
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Controllers have different capabilities and report them in the
4
CAP register. We are particularly interested by the page size
5
limits.
6
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Tested-by: Eric Auger <eric.auger@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20201029093306.1063879-5-philmd@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Tested-by: Eric Auger <eric.auger@redhat.com>
14
---
15
block/nvme.c | 13 +++++++++++++
16
block/trace-events | 2 ++
17
2 files changed, 15 insertions(+)
18
19
diff --git a/block/nvme.c b/block/nvme.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/nvme.c
22
+++ b/block/nvme.c
23
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
24
* Initialization". */
25
26
cap = le64_to_cpu(regs->cap);
27
+ trace_nvme_controller_capability_raw(cap);
28
+ trace_nvme_controller_capability("Maximum Queue Entries Supported",
29
+ 1 + NVME_CAP_MQES(cap));
30
+ trace_nvme_controller_capability("Contiguous Queues Required",
31
+ NVME_CAP_CQR(cap));
32
+ trace_nvme_controller_capability("Doorbell Stride",
33
+ 2 << (2 + NVME_CAP_DSTRD(cap)));
34
+ trace_nvme_controller_capability("Subsystem Reset Supported",
35
+ NVME_CAP_NSSRS(cap));
36
+ trace_nvme_controller_capability("Memory Page Size Minimum",
37
+ 1 << (12 + NVME_CAP_MPSMIN(cap)));
38
+ trace_nvme_controller_capability("Memory Page Size Maximum",
39
+ 1 << (12 + NVME_CAP_MPSMAX(cap)));
40
if (!NVME_CAP_CSS(cap)) {
41
error_setg(errp, "Device doesn't support NVMe command set");
42
ret = -EINVAL;
43
diff --git a/block/trace-events b/block/trace-events
44
index XXXXXXX..XXXXXXX 100644
45
--- a/block/trace-events
46
+++ b/block/trace-events
47
@@ -XXX,XX +XXX,XX @@ qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t
48
qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu"
49
50
# nvme.c
51
+nvme_controller_capability_raw(uint64_t value) "0x%08"PRIx64
52
+nvme_controller_capability(const char *desc, uint64_t value) "%s: %"PRIu64
53
nvme_kick(void *s, int queue) "s %p queue %d"
54
nvme_dma_flush_queue_wait(void *s) "s %p"
55
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"
56
--
57
2.28.0
58
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
As we want to enable multiple queues, report the event
4
in each nvme_poll_queue() call, rather than once in
5
the callback calling nvme_poll_queues().
6
7
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Tested-by: Eric Auger <eric.auger@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20201029093306.1063879-6-philmd@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Tested-by: Eric Auger <eric.auger@redhat.com>
14
---
15
block/nvme.c | 2 +-
16
block/trace-events | 2 +-
17
2 files changed, 2 insertions(+), 2 deletions(-)
18
19
diff --git a/block/nvme.c b/block/nvme.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/nvme.c
22
+++ b/block/nvme.c
23
@@ -XXX,XX +XXX,XX @@ static bool nvme_poll_queue(NVMeQueuePair *q)
24
const size_t cqe_offset = q->cq.head * NVME_CQ_ENTRY_BYTES;
25
NvmeCqe *cqe = (NvmeCqe *)&q->cq.queue[cqe_offset];
26
27
+ trace_nvme_poll_queue(q->s, q->index);
28
/*
29
* Do an early check for completions. q->lock isn't needed because
30
* nvme_process_completion() only runs in the event loop thread and
31
@@ -XXX,XX +XXX,XX @@ static bool nvme_poll_cb(void *opaque)
32
BDRVNVMeState *s = container_of(e, BDRVNVMeState,
33
irq_notifier[MSIX_SHARED_IRQ_IDX]);
34
35
- trace_nvme_poll_cb(s);
36
return nvme_poll_queues(s);
37
}
38
39
diff --git a/block/trace-events b/block/trace-events
40
index XXXXXXX..XXXXXXX 100644
41
--- a/block/trace-events
42
+++ b/block/trace-events
43
@@ -XXX,XX +XXX,XX @@ nvme_complete_command(void *s, int index, int cid) "s %p queue %d cid %d"
44
nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d"
45
nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, int c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x"
46
nvme_handle_event(void *s) "s %p"
47
-nvme_poll_cb(void *s) "s %p"
48
+nvme_poll_queue(void *s, unsigned q_index) "s %p q #%u"
49
nvme_prw_aligned(void *s, int is_write, uint64_t offset, uint64_t bytes, int flags, int niov) "s %p is_write %d offset 0x%"PRIx64" bytes %"PRId64" flags %d niov %d"
50
nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s %p offset 0x%"PRIx64" bytes %"PRId64" flags %d"
51
nvme_qiov_unaligned(const void *qiov, int n, void *base, size_t size, int align) "qiov %p n %d base %p size 0x%zx align 0x%x"
52
--
53
2.28.0
54
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
What we want to trace is the block driver state and the queue index.
4
5
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Tested-by: Eric Auger <eric.auger@redhat.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Message-id: 20201029093306.1063879-7-philmd@redhat.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Tested-by: Eric Auger <eric.auger@redhat.com>
13
---
14
block/nvme.c | 2 +-
15
block/trace-events | 2 +-
16
2 files changed, 2 insertions(+), 2 deletions(-)
17
18
diff --git a/block/nvme.c b/block/nvme.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/block/nvme.c
21
+++ b/block/nvme.c
22
@@ -XXX,XX +XXX,XX @@ static NVMeRequest *nvme_get_free_req(NVMeQueuePair *q)
23
24
while (q->free_req_head == -1) {
25
if (qemu_in_coroutine()) {
26
- trace_nvme_free_req_queue_wait(q);
27
+ trace_nvme_free_req_queue_wait(q->s, q->index);
28
qemu_co_queue_wait(&q->free_req_queue, &q->lock);
29
} else {
30
qemu_mutex_unlock(&q->lock);
31
diff --git a/block/trace-events b/block/trace-events
32
index XXXXXXX..XXXXXXX 100644
33
--- a/block/trace-events
34
+++ b/block/trace-events
35
@@ -XXX,XX +XXX,XX @@ nvme_rw_done(void *s, int is_write, uint64_t offset, uint64_t bytes, int ret) "s
36
nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset 0x%"PRIx64" bytes %"PRId64""
37
nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset 0x%"PRIx64" bytes %"PRId64" ret %d"
38
nvme_dma_map_flush(void *s) "s %p"
39
-nvme_free_req_queue_wait(void *q) "q %p"
40
+nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u"
41
nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d"
42
nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"PRIx64
43
nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d] %p pages %d"
44
--
45
2.28.0
46
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Reviewed-by: Eric Auger <eric.auger@redhat.com>
4
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
5
Tested-by: Eric Auger <eric.auger@redhat.com>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Message-id: 20201029093306.1063879-8-philmd@redhat.com
8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Tested-by: Eric Auger <eric.auger@redhat.com>
10
---
11
block/nvme.c | 3 +++
12
block/trace-events | 2 ++
13
2 files changed, 5 insertions(+)
14
15
diff --git a/block/nvme.c b/block/nvme.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/block/nvme.c
18
+++ b/block/nvme.c
19
@@ -XXX,XX +XXX,XX @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
20
21
static void nvme_free_queue_pair(NVMeQueuePair *q)
22
{
23
+ trace_nvme_free_queue_pair(q->index, q);
24
if (q->completion_bh) {
25
qemu_bh_delete(q->completion_bh);
26
}
27
@@ -XXX,XX +XXX,XX @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
28
if (!q) {
29
return NULL;
30
}
31
+ trace_nvme_create_queue_pair(idx, q, size, aio_context,
32
+ event_notifier_get_fd(s->irq_notifier));
33
q->prp_list_pages = qemu_try_memalign(s->page_size,
34
s->page_size * NVME_NUM_REQS);
35
if (!q->prp_list_pages) {
36
diff --git a/block/trace-events b/block/trace-events
37
index XXXXXXX..XXXXXXX 100644
38
--- a/block/trace-events
39
+++ b/block/trace-events
40
@@ -XXX,XX +XXX,XX @@ nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset 0x%"PRIx64" byte
41
nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset 0x%"PRIx64" bytes %"PRId64" ret %d"
42
nvme_dma_map_flush(void *s) "s %p"
43
nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u"
44
+nvme_create_queue_pair(unsigned q_index, void *q, unsigned size, void *aio_context, int fd) "index %u q %p size %u aioctx %p fd %d"
45
+nvme_free_queue_pair(unsigned q_index, void *q) "index %u q %p"
46
nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d"
47
nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"PRIx64
48
nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d] %p pages %d"
49
--
50
2.28.0
51
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
To be able to use some definitions in structure declarations,
4
move them earlier. No logical change.
5
6
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Tested-by: Eric Auger <eric.auger@redhat.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Message-id: 20201029093306.1063879-9-philmd@redhat.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Tested-by: Eric Auger <eric.auger@redhat.com>
13
---
14
block/nvme.c | 19 ++++++++++---------
15
1 file changed, 10 insertions(+), 9 deletions(-)
16
17
diff --git a/block/nvme.c b/block/nvme.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/block/nvme.c
20
+++ b/block/nvme.c
21
@@ -XXX,XX +XXX,XX @@
22
23
typedef struct BDRVNVMeState BDRVNVMeState;
24
25
+/* Same index is used for queues and IRQs */
26
+#define INDEX_ADMIN 0
27
+#define INDEX_IO(n) (1 + n)
28
+
29
+/* This driver shares a single MSIX IRQ for the admin and I/O queues */
30
+enum {
31
+ MSIX_SHARED_IRQ_IDX = 0,
32
+ MSIX_IRQ_COUNT = 1
33
+};
34
+
35
typedef struct {
36
int32_t head, tail;
37
uint8_t *queue;
38
@@ -XXX,XX +XXX,XX @@ typedef struct {
39
QEMUBH *completion_bh;
40
} NVMeQueuePair;
41
42
-#define INDEX_ADMIN 0
43
-#define INDEX_IO(n) (1 + n)
44
-
45
-/* This driver shares a single MSIX IRQ for the admin and I/O queues */
46
-enum {
47
- MSIX_SHARED_IRQ_IDX = 0,
48
- MSIX_IRQ_COUNT = 1
49
-};
50
-
51
struct BDRVNVMeState {
52
AioContext *aio_context;
53
QEMUVFIOState *vfio;
54
--
55
2.28.0
56
diff view generated by jsdifflib
New patch
1
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
3
We can not have negative queue count/size/index, use unsigned type.
4
Rename 'nr_queues' as 'queue_count' to match the spec naming.
5
6
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Tested-by: Eric Auger <eric.auger@redhat.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Message-id: 20201029093306.1063879-10-philmd@redhat.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Tested-by: Eric Auger <eric.auger@redhat.com>
13
---
14
block/nvme.c | 38 ++++++++++++++++++--------------------
15
block/trace-events | 10 +++++-----
16
2 files changed, 23 insertions(+), 25 deletions(-)
17
18
diff --git a/block/nvme.c b/block/nvme.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/block/nvme.c
21
+++ b/block/nvme.c
22
@@ -XXX,XX +XXX,XX @@ struct BDRVNVMeState {
23
* [1..]: io queues.
24
*/
25
NVMeQueuePair **queues;
26
- int nr_queues;
27
+ unsigned queue_count;
28
size_t page_size;
29
/* How many uint32_t elements does each doorbell entry take. */
30
size_t doorbell_scale;
31
@@ -XXX,XX +XXX,XX @@ static QemuOptsList runtime_opts = {
32
};
33
34
static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
35
- int nentries, int entry_bytes, Error **errp)
36
+ unsigned nentries, size_t entry_bytes, Error **errp)
37
{
38
size_t bytes;
39
int r;
40
@@ -XXX,XX +XXX,XX @@ static void nvme_free_req_queue_cb(void *opaque)
41
42
static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
43
AioContext *aio_context,
44
- int idx, int size,
45
+ unsigned idx, size_t size,
46
Error **errp)
47
{
48
int i, r;
49
@@ -XXX,XX +XXX,XX @@ static bool nvme_poll_queues(BDRVNVMeState *s)
50
bool progress = false;
51
int i;
52
53
- for (i = 0; i < s->nr_queues; i++) {
54
+ for (i = 0; i < s->queue_count; i++) {
55
if (nvme_poll_queue(s->queues[i])) {
56
progress = true;
57
}
58
@@ -XXX,XX +XXX,XX @@ static void nvme_handle_event(EventNotifier *n)
59
static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
60
{
61
BDRVNVMeState *s = bs->opaque;
62
- int n = s->nr_queues;
63
+ unsigned n = s->queue_count;
64
NVMeQueuePair *q;
65
NvmeCmd cmd;
66
- int queue_size = NVME_QUEUE_SIZE;
67
+ unsigned queue_size = NVME_QUEUE_SIZE;
68
69
q = nvme_create_queue_pair(s, bdrv_get_aio_context(bs),
70
n, queue_size, errp);
71
@@ -XXX,XX +XXX,XX @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
72
.cdw11 = cpu_to_le32(0x3),
73
};
74
if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
75
- error_setg(errp, "Failed to create CQ io queue [%d]", n);
76
+ error_setg(errp, "Failed to create CQ io queue [%u]", n);
77
goto out_error;
78
}
79
cmd = (NvmeCmd) {
80
@@ -XXX,XX +XXX,XX @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
81
.cdw11 = cpu_to_le32(0x1 | (n << 16)),
82
};
83
if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
84
- error_setg(errp, "Failed to create SQ io queue [%d]", n);
85
+ error_setg(errp, "Failed to create SQ io queue [%u]", n);
86
goto out_error;
87
}
88
s->queues = g_renew(NVMeQueuePair *, s->queues, n + 1);
89
s->queues[n] = q;
90
- s->nr_queues++;
91
+ s->queue_count++;
92
return true;
93
out_error:
94
nvme_free_queue_pair(q);
95
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
96
ret = -EINVAL;
97
goto out;
98
}
99
- s->nr_queues = 1;
100
+ s->queue_count = 1;
101
QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000);
102
regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << AQA_ACQS_SHIFT) |
103
(NVME_QUEUE_SIZE << AQA_ASQS_SHIFT));
104
@@ -XXX,XX +XXX,XX @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable,
105
106
static void nvme_close(BlockDriverState *bs)
107
{
108
- int i;
109
BDRVNVMeState *s = bs->opaque;
110
111
- for (i = 0; i < s->nr_queues; ++i) {
112
+ for (unsigned i = 0; i < s->queue_count; ++i) {
113
nvme_free_queue_pair(s->queues[i]);
114
}
115
g_free(s->queues);
116
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriverState *bs,
117
};
118
119
trace_nvme_prw_aligned(s, is_write, offset, bytes, flags, qiov->niov);
120
- assert(s->nr_queues > 1);
121
+ assert(s->queue_count > 1);
122
req = nvme_get_free_req(ioq);
123
assert(req);
124
125
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs)
126
.ret = -EINPROGRESS,
127
};
128
129
- assert(s->nr_queues > 1);
130
+ assert(s->queue_count > 1);
131
req = nvme_get_free_req(ioq);
132
assert(req);
133
nvme_submit_command(ioq, req, &cmd, nvme_rw_cb, &data);
134
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs,
135
cmd.cdw12 = cpu_to_le32(cdw12);
136
137
trace_nvme_write_zeroes(s, offset, bytes, flags);
138
- assert(s->nr_queues > 1);
139
+ assert(s->queue_count > 1);
140
req = nvme_get_free_req(ioq);
141
assert(req);
142
143
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs,
144
return -ENOTSUP;
145
}
146
147
- assert(s->nr_queues > 1);
148
+ assert(s->queue_count > 1);
149
150
buf = qemu_try_memalign(s->page_size, s->page_size);
151
if (!buf) {
152
@@ -XXX,XX +XXX,XX @@ static void nvme_detach_aio_context(BlockDriverState *bs)
153
{
154
BDRVNVMeState *s = bs->opaque;
155
156
- for (int i = 0; i < s->nr_queues; i++) {
157
+ for (unsigned i = 0; i < s->queue_count; i++) {
158
NVMeQueuePair *q = s->queues[i];
159
160
qemu_bh_delete(q->completion_bh);
161
@@ -XXX,XX +XXX,XX @@ static void nvme_attach_aio_context(BlockDriverState *bs,
162
aio_set_event_notifier(new_context, &s->irq_notifier[MSIX_SHARED_IRQ_IDX],
163
false, nvme_handle_event, nvme_poll_cb);
164
165
- for (int i = 0; i < s->nr_queues; i++) {
166
+ for (unsigned i = 0; i < s->queue_count; i++) {
167
NVMeQueuePair *q = s->queues[i];
168
169
q->completion_bh =
170
@@ -XXX,XX +XXX,XX @@ static void nvme_aio_plug(BlockDriverState *bs)
171
172
static void nvme_aio_unplug(BlockDriverState *bs)
173
{
174
- int i;
175
BDRVNVMeState *s = bs->opaque;
176
assert(s->plugged);
177
s->plugged = false;
178
- for (i = INDEX_IO(0); i < s->nr_queues; i++) {
179
+ for (unsigned i = INDEX_IO(0); i < s->queue_count; i++) {
180
NVMeQueuePair *q = s->queues[i];
181
qemu_mutex_lock(&q->lock);
182
nvme_kick(q);
183
diff --git a/block/trace-events b/block/trace-events
184
index XXXXXXX..XXXXXXX 100644
185
--- a/block/trace-events
186
+++ b/block/trace-events
187
@@ -XXX,XX +XXX,XX @@ qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s
188
# nvme.c
189
nvme_controller_capability_raw(uint64_t value) "0x%08"PRIx64
190
nvme_controller_capability(const char *desc, uint64_t value) "%s: %"PRIu64
191
-nvme_kick(void *s, int queue) "s %p queue %d"
192
+nvme_kick(void *s, unsigned q_index) "s %p q #%u"
193
nvme_dma_flush_queue_wait(void *s) "s %p"
194
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"
195
-nvme_process_completion(void *s, int index, int inflight) "s %p queue %d inflight %d"
196
-nvme_process_completion_queue_plugged(void *s, int index) "s %p queue %d"
197
-nvme_complete_command(void *s, int index, int cid) "s %p queue %d cid %d"
198
-nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d"
199
+nvme_process_completion(void *s, unsigned q_index, int inflight) "s %p q #%u inflight %d"
200
+nvme_process_completion_queue_plugged(void *s, unsigned q_index) "s %p q #%u"
201
+nvme_complete_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d"
202
+nvme_submit_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d"
203
nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, int c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x"
204
nvme_handle_event(void *s) "s %p"
205
nvme_poll_queue(void *s, unsigned q_index) "s %p q #%u"
206
--
207
2.28.0
208
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
When creating an image with preallocation "off" or "falloc", the first
3
Just for consistency, following the example documented since
4
block of the image is typically not allocated. When using Gluster
4
commit e3fe3988d7 ("error: Document Error API usage rules"),
5
storage backed by XFS filesystem, reading this block using direct I/O
5
return a boolean value indicating an error is set or not.
6
succeeds regardless of request length, fooling alignment detection.
6
Directly pass errp as the local_err is not requested in our
7
case.
7
8
8
In this case we fallback to a safe value (4096) instead of the optimal
9
Tested-by: Eric Auger <eric.auger@redhat.com>
9
value (512), which may lead to unneeded data copying when aligning
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
requests. Allocating the first block avoids the fallback.
11
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Message-id: 20201029093306.1063879-11-philmd@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Tested-by: Eric Auger <eric.auger@redhat.com>
15
---
16
block/nvme.c | 12 +++++++-----
17
1 file changed, 7 insertions(+), 5 deletions(-)
11
18
12
Since we allocate the first block even with preallocation=off, we no
19
diff --git a/block/nvme.c b/block/nvme.c
13
longer create images with zero disk size:
14
15
$ ./qemu-img create -f raw test.raw 1g
16
Formatting 'test.raw', fmt=raw size=1073741824
17
18
$ ls -lhs test.raw
19
4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw
20
21
And converting the image requires additional cluster:
22
23
$ ./qemu-img measure -f raw -O qcow2 test.raw
24
required size: 458752
25
fully allocated size: 1074135040
26
27
When using format like vmdk with multiple files per image, we allocate
28
one block per file:
29
30
$ ./qemu-img create -f vmdk -o subformat=twoGbMaxExtentFlat test.vmdk 4g
31
Formatting 'test.vmdk', fmt=vmdk size=4294967296 compat6=off hwversion=undefined subformat=twoGbMaxExtentFlat
32
33
$ ls -lhs test*.vmdk
34
4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f001.vmdk
35
4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f002.vmdk
36
4.0K -rw-r--r--. 1 nsoffer nsoffer 353 Aug 27 03:23 test.vmdk
37
38
I did quick performance test for copying disks with qemu-img convert to
39
new raw target image to Gluster storage with sector size of 512 bytes:
40
41
for i in $(seq 10); do
42
rm -f dst.raw
43
sleep 10
44
time ./qemu-img convert -f raw -O raw -t none -T none src.raw dst.raw
45
done
46
47
Here is a table comparing the total time spent:
48
49
Type Before(s) After(s) Diff(%)
50
---------------------------------------
51
real 530.028 469.123 -11.4
52
user 17.204 10.768 -37.4
53
sys 17.881 7.011 -60.7
54
55
We can see very clear improvement in CPU usage.
56
57
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
58
Message-id: 20190827010528.8818-2-nsoffer@redhat.com
59
Reviewed-by: Max Reitz <mreitz@redhat.com>
60
Signed-off-by: Max Reitz <mreitz@redhat.com>
61
---
62
block/file-posix.c | 51 +++++++++++++++++++
63
tests/qemu-iotests/059.out | 2 +-
64
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
65
tests/qemu-iotests/150.out.raw | 12 +++++
66
tests/qemu-iotests/175 | 19 ++++---
67
tests/qemu-iotests/175.out | 8 +--
68
tests/qemu-iotests/178.out.qcow2 | 4 +-
69
tests/qemu-iotests/221.out | 12 +++--
70
tests/qemu-iotests/253.out | 12 +++--
71
9 files changed, 99 insertions(+), 21 deletions(-)
72
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
73
create mode 100644 tests/qemu-iotests/150.out.raw
74
75
diff --git a/block/file-posix.c b/block/file-posix.c
76
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
77
--- a/block/file-posix.c
21
--- a/block/nvme.c
78
+++ b/block/file-posix.c
22
+++ b/block/nvme.c
79
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
23
@@ -XXX,XX +XXX,XX @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q,
80
return ret;
24
return ret;
81
}
25
}
82
26
83
+/*
27
-static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
84
+ * Help alignment probing by allocating the first block.
28
+/* Returns true on success, false on failure. */
85
+ *
29
+static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
86
+ * When reading with direct I/O from unallocated area on Gluster backed by XFS,
30
{
87
+ * reading succeeds regardless of request length. In this case we fallback to
31
BDRVNVMeState *s = bs->opaque;
88
+ * safe alignment which is not optimal. Allocating the first block avoids this
32
+ bool ret = false;
89
+ * fallback.
33
union {
90
+ *
34
NvmeIdCtrl ctrl;
91
+ * fd may be opened with O_DIRECT, but we don't know the buffer alignment or
35
NvmeIdNs ns;
92
+ * request alignment, so we use safe values.
36
@@ -XXX,XX +XXX,XX @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
93
+ *
37
goto out;
94
+ * Returns: 0 on success, -errno on failure. Since this is an optimization,
38
}
95
+ * caller may ignore failures.
39
96
+ */
40
+ ret = true;
97
+static int allocate_first_block(int fd, size_t max_size)
41
s->blkshift = lbaf->ds;
98
+{
42
out:
99
+ size_t write_size = (max_size < MAX_BLOCKSIZE)
43
qemu_vfio_dma_unmap(s->vfio, id);
100
+ ? BDRV_SECTOR_SIZE
44
qemu_vfree(id);
101
+ : MAX_BLOCKSIZE;
102
+ size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
103
+ void *buf;
104
+ ssize_t n;
105
+ int ret;
106
+
45
+
107
+ buf = qemu_memalign(max_align, write_size);
108
+ memset(buf, 0, write_size);
109
+
110
+ do {
111
+ n = pwrite(fd, buf, write_size, 0);
112
+ } while (n == -1 && errno == EINTR);
113
+
114
+ ret = (n == -1) ? -errno : 0;
115
+
116
+ qemu_vfree(buf);
117
+ return ret;
46
+ return ret;
118
+}
119
+
120
static int handle_aiocb_truncate(void *opaque)
121
{
122
RawPosixAIOData *aiocb = opaque;
123
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
124
/* posix_fallocate() doesn't set errno. */
125
error_setg_errno(errp, -result,
126
"Could not preallocate new data");
127
+ } else if (current_length == 0) {
128
+ /*
129
+ * posix_fallocate() uses fallocate() if the filesystem
130
+ * supports it, or fallback to manually writing zeroes. If
131
+ * fallocate() was used, unaligned reads from the fallocated
132
+ * area in raw_probe_alignment() will succeed, hence we need to
133
+ * allocate the first block.
134
+ *
135
+ * Optimize future alignment probing; ignore failures.
136
+ */
137
+ allocate_first_block(fd, offset);
138
}
139
} else {
140
result = 0;
141
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
142
if (ftruncate(fd, offset) != 0) {
143
result = -errno;
144
error_setg_errno(errp, -result, "Could not resize file");
145
+ } else if (current_length == 0 && offset > current_length) {
146
+ /* Optimize future alignment probing; ignore failures. */
147
+ allocate_first_block(fd, offset);
148
}
149
return result;
150
default:
151
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
152
index XXXXXXX..XXXXXXX 100644
153
--- a/tests/qemu-iotests/059.out
154
+++ b/tests/qemu-iotests/059.out
155
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMax
156
image: TEST_DIR/t.vmdk
157
file format: vmdk
158
virtual size: 0.977 TiB (1073741824000 bytes)
159
-disk size: 16 KiB
160
+disk size: 1.97 MiB
161
Format specific information:
162
cid: XXXXXXXX
163
parent cid: XXXXXXXX
164
diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out.qcow2
165
similarity index 100%
166
rename from tests/qemu-iotests/150.out
167
rename to tests/qemu-iotests/150.out.qcow2
168
diff --git a/tests/qemu-iotests/150.out.raw b/tests/qemu-iotests/150.out.raw
169
new file mode 100644
170
index XXXXXXX..XXXXXXX
171
--- /dev/null
172
+++ b/tests/qemu-iotests/150.out.raw
173
@@ -XXX,XX +XXX,XX @@
174
+QA output created by 150
175
+
176
+=== Mapping sparse conversion ===
177
+
178
+Offset Length File
179
+0 0x1000 TEST_DIR/t.IMGFMT
180
+
181
+=== Mapping non-sparse conversion ===
182
+
183
+Offset Length File
184
+0 0x100000 TEST_DIR/t.IMGFMT
185
+*** done
186
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
187
index XXXXXXX..XXXXXXX 100755
188
--- a/tests/qemu-iotests/175
189
+++ b/tests/qemu-iotests/175
190
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
191
# the file size. This function hides the resulting difference in the
192
# stat -c '%b' output.
193
# Parameter 1: Number of blocks an empty file occupies
194
-# Parameter 2: Image size in bytes
195
+# Parameter 2: Minimal number of blocks in an image
196
+# Parameter 3: Image size in bytes
197
_filter_blocks()
198
{
199
extra_blocks=$1
200
- img_size=$2
201
+ min_blocks=$2
202
+ img_size=$3
203
204
- sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \
205
- -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/"
206
+ sed -e "s/blocks=$min_blocks\\(\$\\|[^0-9]\\)/min allocation/" \
207
+ -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
208
}
47
}
209
48
210
# get standard environment, filters and checks
49
static bool nvme_poll_queue(NVMeQueuePair *q)
211
@@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024))
50
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
212
touch "$TEST_DIR/empty"
51
uint64_t cap;
213
extra_blocks=$(stat -c '%b' "$TEST_DIR/empty")
52
uint64_t timeout_ms;
214
53
uint64_t deadline, now;
215
+# We always write the first byte; check how many blocks this filesystem
54
- Error *local_err = NULL;
216
+# allocates to match empty image alloation.
55
volatile NvmeBar *regs = NULL;
217
+printf "\0" > "$TEST_DIR/empty"
56
218
+min_blocks=$(stat -c '%b' "$TEST_DIR/empty")
57
qemu_co_mutex_init(&s->dma_map_lock);
219
+
58
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
220
echo
59
&s->irq_notifier[MSIX_SHARED_IRQ_IDX],
221
echo "== creating image with default preallocation =="
60
false, nvme_handle_event, nvme_poll_cb);
222
_make_test_img $size | _filter_imgfmt
61
223
-stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size
62
- nvme_identify(bs, namespace, &local_err);
224
+stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
63
- if (local_err) {
225
64
- error_propagate(errp, local_err);
226
for mode in off full falloc; do
65
+ if (!nvme_identify(bs, namespace, errp)) {
227
echo
66
ret = -EIO;
228
echo "== creating image with preallocation $mode =="
67
goto out;
229
IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt
68
}
230
- stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size
231
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
232
done
233
234
# success, all done
235
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
236
index XXXXXXX..XXXXXXX 100644
237
--- a/tests/qemu-iotests/175.out
238
+++ b/tests/qemu-iotests/175.out
239
@@ -XXX,XX +XXX,XX @@ QA output created by 175
240
241
== creating image with default preallocation ==
242
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
243
-size=1048576, nothing allocated
244
+size=1048576, min allocation
245
246
== creating image with preallocation off ==
247
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off
248
-size=1048576, nothing allocated
249
+size=1048576, min allocation
250
251
== creating image with preallocation full ==
252
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full
253
-size=1048576, everything allocated
254
+size=1048576, max allocation
255
256
== creating image with preallocation falloc ==
257
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
258
-size=1048576, everything allocated
259
+size=1048576, max allocation
260
*** done
261
diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.qcow2
262
index XXXXXXX..XXXXXXX 100644
263
--- a/tests/qemu-iotests/178.out.qcow2
264
+++ b/tests/qemu-iotests/178.out.qcow2
265
@@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608
266
== raw input image with data (human) ==
267
268
Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824
269
-required size: 393216
270
+required size: 458752
271
fully allocated size: 1074135040
272
wrote 512/512 bytes at offset 512
273
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
274
@@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608
275
276
Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824
277
{
278
- "required": 393216,
279
+ "required": 458752,
280
"fully-allocated": 1074135040
281
}
282
wrote 512/512 bytes at offset 512
283
diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out
284
index XXXXXXX..XXXXXXX 100644
285
--- a/tests/qemu-iotests/221.out
286
+++ b/tests/qemu-iotests/221.out
287
@@ -XXX,XX +XXX,XX @@ QA output created by 221
288
=== Check mapping of unaligned raw image ===
289
290
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65537
291
-[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
292
-[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
293
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
294
+{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
295
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
296
+{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
297
wrote 1/1 bytes at offset 65536
298
1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
299
-[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
300
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
301
+{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
302
{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
303
{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
304
-[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
305
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
306
+{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
307
{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
308
{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
309
*** done
310
diff --git a/tests/qemu-iotests/253.out b/tests/qemu-iotests/253.out
311
index XXXXXXX..XXXXXXX 100644
312
--- a/tests/qemu-iotests/253.out
313
+++ b/tests/qemu-iotests/253.out
314
@@ -XXX,XX +XXX,XX @@ QA output created by 253
315
=== Check mapping of unaligned raw image ===
316
317
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048575
318
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
319
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
320
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
321
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
322
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
323
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
324
wrote 65535/65535 bytes at offset 983040
325
63.999 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
326
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
327
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
328
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
329
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
330
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
331
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
332
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
333
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
334
*** done
335
--
69
--
336
2.21.0
70
2.28.0
337
71
338
diff view generated by jsdifflib
1
From: Denis Plotnikov <dplotnikov@virtuozzo.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
The patch allows to provide a pattern file for write
3
Just for consistency, following the example documented since
4
command. There was no similar ability before.
4
commit e3fe3988d7 ("error: Document Error API usage rules"),
5
return a boolean value indicating an error is set or not.
6
Directly pass errp as the local_err is not requested in our
7
case. This simplifies a bit nvme_create_queue_pair().
5
8
6
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com
10
Tested-by: Eric Auger <eric.auger@redhat.com>
8
Reviewed-by: Eric Blake <eblake@redhat.com>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
[mreitz: Keep optstring in alphabetical order]
12
Message-id: 20201029093306.1063879-12-philmd@redhat.com
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Tested-by: Eric Auger <eric.auger@redhat.com>
11
---
15
---
12
qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++---
16
block/nvme.c | 16 +++++++---------
13
1 file changed, 93 insertions(+), 6 deletions(-)
17
1 file changed, 7 insertions(+), 9 deletions(-)
14
18
15
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
19
diff --git a/block/nvme.c b/block/nvme.c
16
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
17
--- a/qemu-io-cmds.c
21
--- a/block/nvme.c
18
+++ b/qemu-io-cmds.c
22
+++ b/block/nvme.c
19
@@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p)
23
@@ -XXX,XX +XXX,XX @@ static QemuOptsList runtime_opts = {
20
qemu_vfree(p);
24
},
25
};
26
27
-static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
28
+/* Returns true on success, false on failure. */
29
+static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
30
unsigned nentries, size_t entry_bytes, Error **errp)
31
{
32
size_t bytes;
33
@@ -XXX,XX +XXX,XX @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
34
q->queue = qemu_try_memalign(s->page_size, bytes);
35
if (!q->queue) {
36
error_setg(errp, "Cannot allocate queue");
37
- return;
38
+ return false;
39
}
40
memset(q->queue, 0, bytes);
41
r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova);
42
if (r) {
43
error_setg(errp, "Cannot map queue");
44
+ return false;
45
}
46
+ return true;
21
}
47
}
22
48
23
+/*
49
static void nvme_free_queue_pair(NVMeQueuePair *q)
24
+ * qemu_io_alloc_from_file()
50
@@ -XXX,XX +XXX,XX @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
25
+ *
51
Error **errp)
26
+ * Allocates the buffer and populates it with the content of the given file
27
+ * up to @len bytes. If the file length is less than @len, then the buffer
28
+ * is populated with the file content cyclically.
29
+ *
30
+ * @blk - the block backend where the buffer content is going to be written to
31
+ * @len - the buffer length
32
+ * @file_name - the file to read the content from
33
+ *
34
+ * Returns: the buffer pointer on success
35
+ * NULL on error
36
+ */
37
+static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len,
38
+ const char *file_name)
39
+{
40
+ char *buf, *buf_origin;
41
+ FILE *f = fopen(file_name, "r");
42
+ int pattern_len;
43
+
44
+ if (!f) {
45
+ perror(file_name);
46
+ return NULL;
47
+ }
48
+
49
+ if (qemuio_misalign) {
50
+ len += MISALIGN_OFFSET;
51
+ }
52
+
53
+ buf_origin = buf = blk_blockalign(blk, len);
54
+
55
+ if (qemuio_misalign) {
56
+ buf_origin += MISALIGN_OFFSET;
57
+ buf += MISALIGN_OFFSET;
58
+ len -= MISALIGN_OFFSET;
59
+ }
60
+
61
+ pattern_len = fread(buf_origin, 1, len, f);
62
+
63
+ if (ferror(f)) {
64
+ perror(file_name);
65
+ goto error;
66
+ }
67
+
68
+ if (pattern_len == 0) {
69
+ fprintf(stderr, "%s: file is empty\n", file_name);
70
+ goto error;
71
+ }
72
+
73
+ fclose(f);
74
+
75
+ if (len > pattern_len) {
76
+ len -= pattern_len;
77
+ buf += pattern_len;
78
+
79
+ while (len > 0) {
80
+ size_t len_to_copy = MIN(pattern_len, len);
81
+
82
+ memcpy(buf, buf_origin, len_to_copy);
83
+
84
+ len -= len_to_copy;
85
+ buf += len_to_copy;
86
+ }
87
+ }
88
+
89
+ return buf_origin;
90
+
91
+error:
92
+ qemu_io_free(buf_origin);
93
+ return NULL;
94
+}
95
+
96
static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
97
{
52
{
98
uint64_t i;
53
int i, r;
99
@@ -XXX,XX +XXX,XX @@ static void write_help(void)
54
- Error *local_err = NULL;
100
" -n, -- with -z, don't allow slow fallback\n"
55
NVMeQueuePair *q;
101
" -p, -- ignored for backwards compatibility\n"
56
uint64_t prp_list_iova;
102
" -P, -- use different pattern to fill file\n"
57
103
+" -s, -- use a pattern file to fill the write buffer\n"
58
@@ -XXX,XX +XXX,XX @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
104
" -C, -- report statistics in a machine parsable format\n"
59
req->prp_list_iova = prp_list_iova + i * s->page_size;
105
" -q, -- quiet mode, do not show I/O statistics\n"
106
" -u, -- with -z, allow unmapping\n"
107
@@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = {
108
.perm = BLK_PERM_WRITE,
109
.argmin = 2,
110
.argmax = -1,
111
- .args = "[-bcCfnquz] [-P pattern] off len",
112
+ .args = "[-bcCfnquz] [-P pattern | -s source_file] off len",
113
.oneline = "writes a number of bytes at a specified offset",
114
.help = write_help,
115
};
116
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
117
{
118
struct timespec t1, t2;
119
bool Cflag = false, qflag = false, bflag = false;
120
- bool Pflag = false, zflag = false, cflag = false;
121
+ bool Pflag = false, zflag = false, cflag = false, sflag = false;
122
int flags = 0;
123
int c, cnt, ret;
124
char *buf = NULL;
125
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
126
/* Some compilers get confused and warn if this is not initialized. */
127
int64_t total = 0;
128
int pattern = 0xcd;
129
+ const char *file_name = NULL;
130
131
- while ((c = getopt(argc, argv, "bcCfnpP:quz")) != -1) {
132
+ while ((c = getopt(argc, argv, "bcCfnpP:qs:uz")) != -1) {
133
switch (c) {
134
case 'b':
135
bflag = true;
136
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
137
case 'q':
138
qflag = true;
139
break;
140
+ case 's':
141
+ sflag = true;
142
+ file_name = optarg;
143
+ break;
144
case 'u':
145
flags |= BDRV_REQ_MAY_UNMAP;
146
break;
147
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
148
return -EINVAL;
149
}
60
}
150
61
151
- if (zflag && Pflag) {
62
- nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err);
152
- printf("-z and -P cannot be specified at the same time\n");
63
- if (local_err) {
153
+ if (zflag + Pflag + sflag > 1) {
64
- error_propagate(errp, local_err);
154
+ printf("Only one of -z, -P, and -s "
65
+ if (!nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, errp)) {
155
+ "can be specified at the same time\n");
66
goto fail;
156
return -EINVAL;
157
}
67
}
158
68
q->sq.doorbell = &s->doorbells[idx * s->doorbell_scale].sq_tail;
159
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
69
70
- nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err);
71
- if (local_err) {
72
- error_propagate(errp, local_err);
73
+ if (!nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, errp)) {
74
goto fail;
160
}
75
}
161
76
q->cq.doorbell = &s->doorbells[idx * s->doorbell_scale].cq_head;
162
if (!zflag) {
163
- buf = qemu_io_alloc(blk, count, pattern);
164
+ if (sflag) {
165
+ buf = qemu_io_alloc_from_file(blk, count, file_name);
166
+ if (!buf) {
167
+ return -EINVAL;
168
+ }
169
+ } else {
170
+ buf = qemu_io_alloc(blk, count, pattern);
171
+ }
172
}
173
174
clock_gettime(CLOCK_MONOTONIC, &t1);
175
--
77
--
176
2.21.0
78
2.28.0
177
79
178
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Rename Submission Queue flags with 'Sq' to differentiate
4
submission queue flags from command queue flags, and introduce
5
Completion Queue flag definitions.
6
7
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
Tested-by: Eric Auger <eric.auger@redhat.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Message-id: 20201029093306.1063879-13-philmd@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Tested-by: Eric Auger <eric.auger@redhat.com>
14
---
15
include/block/nvme.h | 18 ++++++++++++------
16
1 file changed, 12 insertions(+), 6 deletions(-)
17
18
diff --git a/include/block/nvme.h b/include/block/nvme.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/block/nvme.h
21
+++ b/include/block/nvme.h
22
@@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED NvmeCreateCq {
23
#define NVME_CQ_FLAGS_PC(cq_flags) (cq_flags & 0x1)
24
#define NVME_CQ_FLAGS_IEN(cq_flags) ((cq_flags >> 1) & 0x1)
25
26
+enum NvmeFlagsCq {
27
+ NVME_CQ_PC = 1,
28
+ NVME_CQ_IEN = 2,
29
+};
30
+
31
typedef struct QEMU_PACKED NvmeCreateSq {
32
uint8_t opcode;
33
uint8_t flags;
34
@@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED NvmeCreateSq {
35
#define NVME_SQ_FLAGS_PC(sq_flags) (sq_flags & 0x1)
36
#define NVME_SQ_FLAGS_QPRIO(sq_flags) ((sq_flags >> 1) & 0x3)
37
38
-enum NvmeQueueFlags {
39
- NVME_Q_PC = 1,
40
- NVME_Q_PRIO_URGENT = 0,
41
- NVME_Q_PRIO_HIGH = 1,
42
- NVME_Q_PRIO_NORMAL = 2,
43
- NVME_Q_PRIO_LOW = 3,
44
+enum NvmeFlagsSq {
45
+ NVME_SQ_PC = 1,
46
+
47
+ NVME_SQ_PRIO_URGENT = 0,
48
+ NVME_SQ_PRIO_HIGH = 1,
49
+ NVME_SQ_PRIO_NORMAL = 2,
50
+ NVME_SQ_PRIO_LOW = 3,
51
};
52
53
typedef struct QEMU_PACKED NvmeIdentify {
54
--
55
2.28.0
56
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Replace magic values by definitions, and simplifiy since the
4
number of queues will never reach 64K.
5
6
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Tested-by: Eric Auger <eric.auger@redhat.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Message-id: 20201029093306.1063879-14-philmd@redhat.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Tested-by: Eric Auger <eric.auger@redhat.com>
13
---
14
block/nvme.c | 9 +++++----
15
1 file changed, 5 insertions(+), 4 deletions(-)
16
17
diff --git a/block/nvme.c b/block/nvme.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/block/nvme.c
20
+++ b/block/nvme.c
21
@@ -XXX,XX +XXX,XX @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
22
NvmeCmd cmd;
23
unsigned queue_size = NVME_QUEUE_SIZE;
24
25
+ assert(n <= UINT16_MAX);
26
q = nvme_create_queue_pair(s, bdrv_get_aio_context(bs),
27
n, queue_size, errp);
28
if (!q) {
29
@@ -XXX,XX +XXX,XX @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
30
cmd = (NvmeCmd) {
31
.opcode = NVME_ADM_CMD_CREATE_CQ,
32
.dptr.prp1 = cpu_to_le64(q->cq.iova),
33
- .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)),
34
- .cdw11 = cpu_to_le32(0x3),
35
+ .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n),
36
+ .cdw11 = cpu_to_le32(NVME_CQ_IEN | NVME_CQ_PC),
37
};
38
if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
39
error_setg(errp, "Failed to create CQ io queue [%u]", n);
40
@@ -XXX,XX +XXX,XX @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
41
cmd = (NvmeCmd) {
42
.opcode = NVME_ADM_CMD_CREATE_SQ,
43
.dptr.prp1 = cpu_to_le64(q->sq.iova),
44
- .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)),
45
- .cdw11 = cpu_to_le32(0x1 | (n << 16)),
46
+ .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n),
47
+ .cdw11 = cpu_to_le32(NVME_SQ_PC | (n << 16)),
48
};
49
if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
50
error_setg(errp, "Failed to create SQ io queue [%u]", n);
51
--
52
2.28.0
53
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Quoting cache mode is not needed, and most tests use unquoted values.
3
From the specification chapter 3.1.8 "AQA - Admin Queue Attributes"
4
Unify all test to use the same style.
4
the Admin Submission Queue Size field is a 0’s based value:
5
5
6
Message-id: 20190827173432.7656-1-nsoffer@redhat.com
6
Admin Submission Queue Size (ASQS):
7
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
7
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Defines the size of the Admin Submission Queue in entries.
9
Enabling a controller while this field is cleared to 00h
10
produces undefined results. The minimum size of the Admin
11
Submission Queue is two entries. The maximum size of the
12
Admin Submission Queue is 4096 entries.
13
This is a 0’s based value.
14
15
This bug has never been hit because the device initialization
16
uses a single command synchronously :)
17
18
Reviewed-by: Eric Auger <eric.auger@redhat.com>
19
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
20
Tested-by: Eric Auger <eric.auger@redhat.com>
21
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22
Message-id: 20201029093306.1063879-15-philmd@redhat.com
23
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
Tested-by: Eric Auger <eric.auger@redhat.com>
9
---
25
---
10
tests/qemu-iotests/026 | 4 ++--
26
block/nvme.c | 6 +++---
11
tests/qemu-iotests/039 | 4 ++--
27
1 file changed, 3 insertions(+), 3 deletions(-)
12
tests/qemu-iotests/052 | 2 +-
13
tests/qemu-iotests/091 | 4 ++--
14
4 files changed, 7 insertions(+), 7 deletions(-)
15
28
16
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
29
diff --git a/block/nvme.c b/block/nvme.c
17
index XXXXXXX..XXXXXXX 100755
30
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/026
31
--- a/block/nvme.c
19
+++ b/tests/qemu-iotests/026
32
+++ b/block/nvme.c
20
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
33
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
21
# Currently only qcow2 supports rebasing
34
goto out;
22
_supported_fmt qcow2
35
}
23
_supported_proto file
36
s->queue_count = 1;
24
-_default_cache_mode "writethrough"
37
- QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000);
25
-_supported_cache_modes "writethrough" "none"
38
- regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << AQA_ACQS_SHIFT) |
26
+_default_cache_mode writethrough
39
- (NVME_QUEUE_SIZE << AQA_ASQS_SHIFT));
27
+_supported_cache_modes writethrough none
40
+ QEMU_BUILD_BUG_ON((NVME_QUEUE_SIZE - 1) & 0xF000);
28
# The refcount table tests expect a certain minimum width for refcount entries
41
+ regs->aqa = cpu_to_le32(((NVME_QUEUE_SIZE - 1) << AQA_ACQS_SHIFT) |
29
# (so that the refcount table actually needs to grow); that minimum is 16 bits,
42
+ ((NVME_QUEUE_SIZE - 1) << AQA_ASQS_SHIFT));
30
# being the default refcount entry width.
43
regs->asq = cpu_to_le64(s->queues[INDEX_ADMIN]->sq.iova);
31
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
44
regs->acq = cpu_to_le64(s->queues[INDEX_ADMIN]->cq.iova);
32
index XXXXXXX..XXXXXXX 100755
33
--- a/tests/qemu-iotests/039
34
+++ b/tests/qemu-iotests/039
35
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
36
_supported_fmt qcow2
37
_supported_proto file
38
_supported_os Linux
39
-_default_cache_mode "writethrough"
40
-_supported_cache_modes "writethrough"
41
+_default_cache_mode writethrough
42
+_supported_cache_modes writethrough
43
44
size=128M
45
46
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
47
index XXXXXXX..XXXXXXX 100755
48
--- a/tests/qemu-iotests/052
49
+++ b/tests/qemu-iotests/052
50
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
51
_supported_proto file
52
53
# Don't do O_DIRECT on tmpfs
54
-_supported_cache_modes "writeback" "writethrough" "unsafe"
55
+_supported_cache_modes writeback writethrough unsafe
56
57
size=128M
58
_make_test_img $size
59
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
60
index XXXXXXX..XXXXXXX 100755
61
--- a/tests/qemu-iotests/091
62
+++ b/tests/qemu-iotests/091
63
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
64
_supported_fmt qcow2
65
_supported_proto file
66
_supported_os Linux
67
-_default_cache_mode "none"
68
-_supported_cache_modes "writethrough" "none" "writeback"
69
+_default_cache_mode none
70
+_supported_cache_modes writethrough none writeback
71
72
size=1G
73
45
74
--
46
--
75
2.21.0
47
2.28.0
76
48
77
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
We don't need to dereference from BDRVNVMeState each time.
4
Use a NVMeQueuePair pointer on the admin queue.
5
The nvme_init() becomes easier to review, matching the style
6
of nvme_add_io_queue().
7
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Tested-by: Eric Auger <eric.auger@redhat.com>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-id: 20201029093306.1063879-16-philmd@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Tested-by: Eric Auger <eric.auger@redhat.com>
15
---
16
block/nvme.c | 12 ++++++------
17
1 file changed, 6 insertions(+), 6 deletions(-)
18
19
diff --git a/block/nvme.c b/block/nvme.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/nvme.c
22
+++ b/block/nvme.c
23
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
24
Error **errp)
25
{
26
BDRVNVMeState *s = bs->opaque;
27
+ NVMeQueuePair *q;
28
AioContext *aio_context = bdrv_get_aio_context(bs);
29
int ret;
30
uint64_t cap;
31
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
32
33
/* Set up admin queue. */
34
s->queues = g_new(NVMeQueuePair *, 1);
35
- s->queues[INDEX_ADMIN] = nvme_create_queue_pair(s, aio_context, 0,
36
- NVME_QUEUE_SIZE,
37
- errp);
38
- if (!s->queues[INDEX_ADMIN]) {
39
+ q = nvme_create_queue_pair(s, aio_context, 0, NVME_QUEUE_SIZE, errp);
40
+ if (!q) {
41
ret = -EINVAL;
42
goto out;
43
}
44
+ s->queues[INDEX_ADMIN] = q;
45
s->queue_count = 1;
46
QEMU_BUILD_BUG_ON((NVME_QUEUE_SIZE - 1) & 0xF000);
47
regs->aqa = cpu_to_le32(((NVME_QUEUE_SIZE - 1) << AQA_ACQS_SHIFT) |
48
((NVME_QUEUE_SIZE - 1) << AQA_ASQS_SHIFT));
49
- regs->asq = cpu_to_le64(s->queues[INDEX_ADMIN]->sq.iova);
50
- regs->acq = cpu_to_le64(s->queues[INDEX_ADMIN]->cq.iova);
51
+ regs->asq = cpu_to_le64(q->sq.iova);
52
+ regs->acq = cpu_to_le64(q->cq.iova);
53
54
/* After setting up all control registers we can enable device now. */
55
regs->cc = cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << CC_IOCQES_SHIFT) |
56
--
57
2.28.0
58
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
As all commands use the ADMIN queue, it is pointless to pass
4
it as argument each time. Remove the argument, and rename the
5
function as nvme_admin_cmd_sync() to make this new behavior
6
clearer.
7
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Tested-by: Eric Auger <eric.auger@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Message-id: 20201029093306.1063879-17-philmd@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Tested-by: Eric Auger <eric.auger@redhat.com>
15
---
16
block/nvme.c | 19 ++++++++++---------
17
1 file changed, 10 insertions(+), 9 deletions(-)
18
19
diff --git a/block/nvme.c b/block/nvme.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/nvme.c
22
+++ b/block/nvme.c
23
@@ -XXX,XX +XXX,XX @@ static void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req,
24
qemu_mutex_unlock(&q->lock);
25
}
26
27
-static void nvme_cmd_sync_cb(void *opaque, int ret)
28
+static void nvme_admin_cmd_sync_cb(void *opaque, int ret)
29
{
30
int *pret = opaque;
31
*pret = ret;
32
aio_wait_kick();
33
}
34
35
-static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q,
36
- NvmeCmd *cmd)
37
+static int nvme_admin_cmd_sync(BlockDriverState *bs, NvmeCmd *cmd)
38
{
39
+ BDRVNVMeState *s = bs->opaque;
40
+ NVMeQueuePair *q = s->queues[INDEX_ADMIN];
41
AioContext *aio_context = bdrv_get_aio_context(bs);
42
NVMeRequest *req;
43
int ret = -EINPROGRESS;
44
@@ -XXX,XX +XXX,XX @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q,
45
if (!req) {
46
return -EBUSY;
47
}
48
- nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret);
49
+ nvme_submit_command(q, req, cmd, nvme_admin_cmd_sync_cb, &ret);
50
51
AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS);
52
return ret;
53
@@ -XXX,XX +XXX,XX @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
54
55
memset(id, 0, sizeof(*id));
56
cmd.dptr.prp1 = cpu_to_le64(iova);
57
- if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
58
+ if (nvme_admin_cmd_sync(bs, &cmd)) {
59
error_setg(errp, "Failed to identify controller");
60
goto out;
61
}
62
@@ -XXX,XX +XXX,XX @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
63
memset(id, 0, sizeof(*id));
64
cmd.cdw10 = 0;
65
cmd.nsid = cpu_to_le32(namespace);
66
- if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
67
+ if (nvme_admin_cmd_sync(bs, &cmd)) {
68
error_setg(errp, "Failed to identify namespace");
69
goto out;
70
}
71
@@ -XXX,XX +XXX,XX @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
72
.cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n),
73
.cdw11 = cpu_to_le32(NVME_CQ_IEN | NVME_CQ_PC),
74
};
75
- if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
76
+ if (nvme_admin_cmd_sync(bs, &cmd)) {
77
error_setg(errp, "Failed to create CQ io queue [%u]", n);
78
goto out_error;
79
}
80
@@ -XXX,XX +XXX,XX @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
81
.cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n),
82
.cdw11 = cpu_to_le32(NVME_SQ_PC | (n << 16)),
83
};
84
- if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
85
+ if (nvme_admin_cmd_sync(bs, &cmd)) {
86
error_setg(errp, "Failed to create SQ io queue [%u]", n);
87
goto out_error;
88
}
89
@@ -XXX,XX +XXX,XX @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable,
90
.cdw11 = cpu_to_le32(enable ? 0x01 : 0x00),
91
};
92
93
- ret = nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd);
94
+ ret = nvme_admin_cmd_sync(bs, &cmd);
95
if (ret) {
96
error_setg(errp, "Failed to configure NVMe write cache");
97
}
98
--
99
2.28.0
100
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Commit bdd6a90a9e5 ("block: Add VFIO based NVMe driver")
4
sets the request_alignment in nvme_refresh_limits().
5
For consistency, also set it during initialization.
6
7
Reported-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Tested-by: Eric Auger <eric.auger@redhat.com>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-id: 20201029093306.1063879-18-philmd@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Tested-by: Eric Auger <eric.auger@redhat.com>
15
---
16
block/nvme.c | 1 +
17
1 file changed, 1 insertion(+)
18
19
diff --git a/block/nvme.c b/block/nvme.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/nvme.c
22
+++ b/block/nvme.c
23
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
24
s->page_size = MAX(4096, 1 << NVME_CAP_MPSMIN(cap));
25
s->doorbell_scale = (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t);
26
bs->bl.opt_mem_alignment = s->page_size;
27
+ bs->bl.request_alignment = s->page_size;
28
timeout_ms = MIN(500 * NVME_CAP_TO(cap), 30000);
29
30
/* Reset device to get a clean state. */
31
--
32
2.28.0
33
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
While trying to simplify the code using a macro, we forgot
4
the 12-bit shift... Correct that.
5
6
Fixes: fad1eb68862 ("block/nvme: Use register definitions from 'block/nvme.h'")
7
Reported-by: Eric Auger <eric.auger@redhat.com>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: Eric Auger <eric.auger@redhat.com>
10
Tested-by: Eric Auger <eric.auger@redhat.com>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-id: 20201029093306.1063879-19-philmd@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Tested-by: Eric Auger <eric.auger@redhat.com>
15
---
16
block/nvme.c | 2 +-
17
1 file changed, 1 insertion(+), 1 deletion(-)
18
19
diff --git a/block/nvme.c b/block/nvme.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/nvme.c
22
+++ b/block/nvme.c
23
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
24
goto out;
25
}
26
27
- s->page_size = MAX(4096, 1 << NVME_CAP_MPSMIN(cap));
28
+ s->page_size = 1u << (12 + NVME_CAP_MPSMIN(cap));
29
s->doorbell_scale = (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t);
30
bs->bl.opt_mem_alignment = s->page_size;
31
bs->bl.request_alignment = s->page_size;
32
--
33
2.28.0
34
diff view generated by jsdifflib
New patch
1
From: Eric Auger <eric.auger@redhat.com>
1
2
3
In preparation of 64kB host page support, let's change the size
4
and alignment of the IDENTIFY command response buffer so that
5
the VFIO DMA MAP succeeds. We align on the host page size.
6
7
Signed-off-by: Eric Auger <eric.auger@redhat.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Tested-by: Eric Auger <eric.auger@redhat.com>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-id: 20201029093306.1063879-20-philmd@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Tested-by: Eric Auger <eric.auger@redhat.com>
15
---
16
block/nvme.c | 9 +++++----
17
1 file changed, 5 insertions(+), 4 deletions(-)
18
19
diff --git a/block/nvme.c b/block/nvme.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/nvme.c
22
+++ b/block/nvme.c
23
@@ -XXX,XX +XXX,XX @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
24
.opcode = NVME_ADM_CMD_IDENTIFY,
25
.cdw10 = cpu_to_le32(0x1),
26
};
27
+ size_t id_size = QEMU_ALIGN_UP(sizeof(*id), qemu_real_host_page_size);
28
29
- id = qemu_try_memalign(s->page_size, sizeof(*id));
30
+ id = qemu_try_memalign(qemu_real_host_page_size, id_size);
31
if (!id) {
32
error_setg(errp, "Cannot allocate buffer for identify response");
33
goto out;
34
}
35
- r = qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova);
36
+ r = qemu_vfio_dma_map(s->vfio, id, id_size, true, &iova);
37
if (r) {
38
error_setg(errp, "Cannot map buffer for DMA");
39
goto out;
40
}
41
42
- memset(id, 0, sizeof(*id));
43
+ memset(id, 0, id_size);
44
cmd.dptr.prp1 = cpu_to_le64(iova);
45
if (nvme_admin_cmd_sync(bs, &cmd)) {
46
error_setg(errp, "Failed to identify controller");
47
@@ -XXX,XX +XXX,XX @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
48
s->supports_write_zeroes = !!(oncs & NVME_ONCS_WRITE_ZEROES);
49
s->supports_discard = !!(oncs & NVME_ONCS_DSM);
50
51
- memset(id, 0, sizeof(*id));
52
+ memset(id, 0, id_size);
53
cmd.cdw10 = 0;
54
cmd.nsid = cpu_to_le32(namespace);
55
if (nvme_admin_cmd_sync(bs, &cmd)) {
56
--
57
2.28.0
58
diff view generated by jsdifflib
New patch
1
From: Eric Auger <eric.auger@redhat.com>
1
2
3
In preparation of 64kB host page support, let's change the size
4
and alignment of the queue so that the VFIO DMA MAP succeeds.
5
We align on the host page size.
6
7
Signed-off-by: Eric Auger <eric.auger@redhat.com>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Tested-by: Eric Auger <eric.auger@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20201029093306.1063879-21-philmd@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Tested-by: Eric Auger <eric.auger@redhat.com>
14
---
15
block/nvme.c | 4 ++--
16
1 file changed, 2 insertions(+), 2 deletions(-)
17
18
diff --git a/block/nvme.c b/block/nvme.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/block/nvme.c
21
+++ b/block/nvme.c
22
@@ -XXX,XX +XXX,XX @@ static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
23
size_t bytes;
24
int r;
25
26
- bytes = ROUND_UP(nentries * entry_bytes, s->page_size);
27
+ bytes = ROUND_UP(nentries * entry_bytes, qemu_real_host_page_size);
28
q->head = q->tail = 0;
29
- q->queue = qemu_try_memalign(s->page_size, bytes);
30
+ q->queue = qemu_try_memalign(qemu_real_host_page_size, bytes);
31
if (!q->queue) {
32
error_setg(errp, "Cannot allocate queue");
33
return false;
34
--
35
2.28.0
36
diff view generated by jsdifflib
New patch
1
From: Eric Auger <eric.auger@redhat.com>
1
2
3
In preparation of 64kB host page support, let's change the size
4
and alignment of the prp_list_pages so that the VFIO DMA MAP succeeds
5
with 64kB host page size. We align on the host page size.
6
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Signed-off-by: Eric Auger <eric.auger@redhat.com>
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Tested-by: Eric Auger <eric.auger@redhat.com>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-id: 20201029093306.1063879-22-philmd@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Tested-by: Eric Auger <eric.auger@redhat.com>
15
---
16
block/nvme.c | 11 ++++++-----
17
1 file changed, 6 insertions(+), 5 deletions(-)
18
19
diff --git a/block/nvme.c b/block/nvme.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/nvme.c
22
+++ b/block/nvme.c
23
@@ -XXX,XX +XXX,XX @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
24
int i, r;
25
NVMeQueuePair *q;
26
uint64_t prp_list_iova;
27
+ size_t bytes;
28
29
q = g_try_new0(NVMeQueuePair, 1);
30
if (!q) {
31
@@ -XXX,XX +XXX,XX @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
32
}
33
trace_nvme_create_queue_pair(idx, q, size, aio_context,
34
event_notifier_get_fd(s->irq_notifier));
35
- q->prp_list_pages = qemu_try_memalign(s->page_size,
36
- s->page_size * NVME_NUM_REQS);
37
+ bytes = QEMU_ALIGN_UP(s->page_size * NVME_NUM_REQS,
38
+ qemu_real_host_page_size);
39
+ q->prp_list_pages = qemu_try_memalign(qemu_real_host_page_size, bytes);
40
if (!q->prp_list_pages) {
41
goto fail;
42
}
43
- memset(q->prp_list_pages, 0, s->page_size * NVME_NUM_REQS);
44
+ memset(q->prp_list_pages, 0, bytes);
45
qemu_mutex_init(&q->lock);
46
q->s = s;
47
q->index = idx;
48
qemu_co_queue_init(&q->free_req_queue);
49
q->completion_bh = aio_bh_new(aio_context, nvme_process_completion_bh, q);
50
- r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages,
51
- s->page_size * NVME_NUM_REQS,
52
+ r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, bytes,
53
false, &prp_list_iova);
54
if (r) {
55
goto fail;
56
--
57
2.28.0
58
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Eric Auger <eric.auger@redhat.com>
2
2
3
The sanitizers (especially the address sanitizer from Clang) are
3
Make sure iov's va and size are properly aligned on the
4
sometimes printing out warnings or false positives - this spoils
4
host page size.
5
the output of the iotests, causing some of the tests to fail.
6
Thus let's skip the automatic iotests during "make check" when the
7
user configured QEMU with --enable-sanitizers.
8
5
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
6
Signed-off-by: Eric Auger <eric.auger@redhat.com>
10
Message-id: 20190823084203.29734-1-thuth@redhat.com
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Tested-by: Eric Auger <eric.auger@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20201029093306.1063879-23-philmd@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Tested-by: Eric Auger <eric.auger@redhat.com>
12
---
14
---
13
tests/check-block.sh | 5 +++++
15
block/nvme.c | 14 ++++++++------
14
1 file changed, 5 insertions(+)
16
1 file changed, 8 insertions(+), 6 deletions(-)
15
17
16
diff --git a/tests/check-block.sh b/tests/check-block.sh
18
diff --git a/block/nvme.c b/block/nvme.c
17
index XXXXXXX..XXXXXXX 100755
19
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/check-block.sh
20
--- a/block/nvme.c
19
+++ b/tests/check-block.sh
21
+++ b/block/nvme.c
20
@@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then
22
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int nvme_cmd_map_qiov(BlockDriverState *bs, NvmeCmd *cmd,
21
exit 0
23
for (i = 0; i < qiov->niov; ++i) {
22
fi
24
bool retry = true;
23
25
uint64_t iova;
24
+if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then
26
+ size_t len = QEMU_ALIGN_UP(qiov->iov[i].iov_len,
25
+ echo "Sanitizers are enabled ==> Not running the qemu-iotests."
27
+ qemu_real_host_page_size);
26
+ exit 0
28
try_map:
27
+fi
29
r = qemu_vfio_dma_map(s->vfio,
28
+
30
qiov->iov[i].iov_base,
29
if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
31
- qiov->iov[i].iov_len,
30
echo "No qemu-system binary available ==> Not running the qemu-iotests."
32
- true, &iova);
31
exit 0
33
+ len, true, &iova);
34
if (r == -ENOMEM && retry) {
35
retry = false;
36
trace_nvme_dma_flush_queue_wait(s);
37
@@ -XXX,XX +XXX,XX @@ static inline bool nvme_qiov_aligned(BlockDriverState *bs,
38
BDRVNVMeState *s = bs->opaque;
39
40
for (i = 0; i < qiov->niov; ++i) {
41
- if (!QEMU_PTR_IS_ALIGNED(qiov->iov[i].iov_base, s->page_size) ||
42
- !QEMU_IS_ALIGNED(qiov->iov[i].iov_len, s->page_size)) {
43
+ if (!QEMU_PTR_IS_ALIGNED(qiov->iov[i].iov_base,
44
+ qemu_real_host_page_size) ||
45
+ !QEMU_IS_ALIGNED(qiov->iov[i].iov_len, qemu_real_host_page_size)) {
46
trace_nvme_qiov_unaligned(qiov, i, qiov->iov[i].iov_base,
47
qiov->iov[i].iov_len, s->page_size);
48
return false;
49
@@ -XXX,XX +XXX,XX @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
50
int r;
51
uint8_t *buf = NULL;
52
QEMUIOVector local_qiov;
53
-
54
+ size_t len = QEMU_ALIGN_UP(bytes, qemu_real_host_page_size);
55
assert(QEMU_IS_ALIGNED(offset, s->page_size));
56
assert(QEMU_IS_ALIGNED(bytes, s->page_size));
57
assert(bytes <= s->max_transfer);
58
@@ -XXX,XX +XXX,XX @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
59
}
60
s->stats.unaligned_accesses++;
61
trace_nvme_prw_buffered(s, offset, bytes, qiov->niov, is_write);
62
- buf = qemu_try_memalign(s->page_size, bytes);
63
+ buf = qemu_try_memalign(qemu_real_host_page_size, len);
64
65
if (!buf) {
66
return -ENOMEM;
32
--
67
--
33
2.21.0
68
2.28.0
34
69
35
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
It is possible to enable only a subset of the block drivers with the
3
qemu_vfio_pci_map_bar() calls mmap(), and mmap(2) states:
4
"--block-drv-rw-whitelist" option of the "configure" script. All other
5
drivers are marked as unusable (or only included as read-only with the
6
"--block-drv-ro-whitelist" option). If an iotest is now using such a
7
disabled block driver, it is failing - which is bad, since at least the
8
tests in the "auto" group should be able to deal with this situation.
9
Thus let's introduce a "_require_drivers" function that can be used by
10
the shell tests to check for the availability of certain drivers first,
11
and marks the test as "not run" if one of the drivers is missing.
12
4
13
This patch mainly targets the test in the "auto" group which should
5
'offset' must be a multiple of the page size as returned
14
never fail in such a case, but also improves some of the other tests
6
by sysconf(_SC_PAGE_SIZE).
15
along the way. Note that we also assume that the "qcow2" and "file"
16
drivers are always available - otherwise it does not make sense to
17
run "make check-block" at all (which only tests with qcow2 by default).
18
7
19
Signed-off-by: Thomas Huth <thuth@redhat.com>
8
In commit f68453237b9 we started to use an offset of 4K which
20
Message-id: 20190823133552.11680-1-thuth@redhat.com
9
broke this contract on Aarch64 arch.
21
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
11
Fix by mapping at offset 0, and and accessing doorbells at offset=4K.
12
13
Fixes: f68453237b9 ("block/nvme: Map doorbells pages write-only")
14
Reported-by: Eric Auger <eric.auger@redhat.com>
15
Reviewed-by: Eric Auger <eric.auger@redhat.com>
16
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
17
Tested-by: Eric Auger <eric.auger@redhat.com>
18
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
19
Message-id: 20201029093306.1063879-24-philmd@redhat.com
20
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
21
Tested-by: Eric Auger <eric.auger@redhat.com>
22
---
22
---
23
tests/qemu-iotests/071 | 1 +
23
block/nvme.c | 11 +++++++----
24
tests/qemu-iotests/081 | 4 +---
24
1 file changed, 7 insertions(+), 4 deletions(-)
25
tests/qemu-iotests/099 | 1 +
26
tests/qemu-iotests/120 | 1 +
27
tests/qemu-iotests/162 | 4 +---
28
tests/qemu-iotests/184 | 1 +
29
tests/qemu-iotests/186 | 1 +
30
tests/qemu-iotests/common.rc | 14 ++++++++++++++
31
8 files changed, 21 insertions(+), 6 deletions(-)
32
25
33
diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071
26
diff --git a/block/nvme.c b/block/nvme.c
34
index XXXXXXX..XXXXXXX 100755
35
--- a/tests/qemu-iotests/071
36
+++ b/tests/qemu-iotests/071
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
38
39
_supported_fmt qcow2
40
_supported_proto file
41
+_require_drivers blkdebug blkverify
42
43
do_run_qemu()
44
{
45
diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
46
index XXXXXXX..XXXXXXX 100755
47
--- a/tests/qemu-iotests/081
48
+++ b/tests/qemu-iotests/081
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
50
_supported_fmt raw
51
_supported_proto file
52
_supported_os Linux
53
+_require_drivers quorum
54
55
do_run_qemu()
56
{
57
@@ -XXX,XX +XXX,XX @@ run_qemu()
58
| _filter_qemu_io | _filter_generated_node_ids
59
}
60
61
-test_quorum=$($QEMU_IMG --help|grep quorum)
62
-[ "$test_quorum" = "" ] && _supported_fmt quorum
63
-
64
quorum="driver=raw,file.driver=quorum,file.vote-threshold=2"
65
quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
66
quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
67
diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099
68
index XXXXXXX..XXXXXXX 100755
69
--- a/tests/qemu-iotests/099
70
+++ b/tests/qemu-iotests/099
71
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
72
_supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc
73
_supported_proto file
74
_supported_os Linux
75
+_require_drivers blkdebug blkverify
76
_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
77
"subformat=twoGbMaxExtentSparse"
78
79
diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120
80
index XXXXXXX..XXXXXXX 100755
81
--- a/tests/qemu-iotests/120
82
+++ b/tests/qemu-iotests/120
83
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
84
_supported_fmt generic
85
_supported_proto file
86
_unsupported_fmt luks
87
+_require_drivers raw
88
89
_make_test_img 64M
90
91
diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162
92
index XXXXXXX..XXXXXXX 100755
93
--- a/tests/qemu-iotests/162
94
+++ b/tests/qemu-iotests/162
95
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
96
. ./common.filter
97
98
_supported_fmt generic
99
-
100
-test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
101
-[ "$test_ssh" = "" ] && _notrun "ssh support required"
102
+_require_drivers ssh
103
104
echo
105
echo '=== NBD ==='
106
diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184
107
index XXXXXXX..XXXXXXX 100755
108
--- a/tests/qemu-iotests/184
109
+++ b/tests/qemu-iotests/184
110
@@ -XXX,XX +XXX,XX @@ trap "exit \$status" 0 1 2 3 15
111
. ./common.filter
112
113
_supported_os Linux
114
+_require_drivers throttle
115
116
do_run_qemu()
117
{
118
diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186
119
index XXXXXXX..XXXXXXX 100755
120
--- a/tests/qemu-iotests/186
121
+++ b/tests/qemu-iotests/186
122
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
123
124
_supported_fmt qcow2
125
_supported_proto file
126
+_require_drivers null-co
127
128
if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
129
_notrun "Requires a PC machine"
130
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
131
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
132
--- a/tests/qemu-iotests/common.rc
28
--- a/block/nvme.c
133
+++ b/tests/qemu-iotests/common.rc
29
+++ b/block/nvme.c
134
@@ -XXX,XX +XXX,XX @@ _require_command()
30
@@ -XXX,XX +XXX,XX @@ typedef struct {
135
[ -x "$c" ] || _notrun "$1 utility required, skipped this test"
31
struct BDRVNVMeState {
136
}
32
AioContext *aio_context;
137
33
QEMUVFIOState *vfio;
138
+# Check that a set of drivers has been whitelisted in the QEMU binary
34
+ void *bar0_wo_map;
139
+#
35
/* Memory mapped registers */
140
+_require_drivers()
36
volatile struct {
141
+{
37
uint32_t sq_tail;
142
+ available=$($QEMU -drive format=help | \
38
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
143
+ sed -e '/Supported formats:/!d' -e 's/Supported formats://')
39
}
144
+ for driver
40
}
145
+ do
41
146
+ if ! echo "$available" | grep -q " $driver\( \|$\)"; then
42
- s->doorbells = qemu_vfio_pci_map_bar(s->vfio, 0, sizeof(NvmeBar),
147
+ _notrun "$driver not available"
43
- NVME_DOORBELL_SIZE, PROT_WRITE, errp);
148
+ fi
44
+ s->bar0_wo_map = qemu_vfio_pci_map_bar(s->vfio, 0, 0,
149
+ done
45
+ sizeof(NvmeBar) + NVME_DOORBELL_SIZE,
150
+}
46
+ PROT_WRITE, errp);
151
+
47
+ s->doorbells = (void *)((uintptr_t)s->bar0_wo_map + sizeof(NvmeBar));
152
# make sure this script returns success
48
if (!s->doorbells) {
153
true
49
ret = -EINVAL;
50
goto out;
51
@@ -XXX,XX +XXX,XX @@ static void nvme_close(BlockDriverState *bs)
52
&s->irq_notifier[MSIX_SHARED_IRQ_IDX],
53
false, NULL, NULL);
54
event_notifier_cleanup(&s->irq_notifier[MSIX_SHARED_IRQ_IDX]);
55
- qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->doorbells,
56
- sizeof(NvmeBar), NVME_DOORBELL_SIZE);
57
+ qemu_vfio_pci_unmap_bar(s->vfio, 0, s->bar0_wo_map,
58
+ 0, sizeof(NvmeBar) + NVME_DOORBELL_SIZE);
59
qemu_vfio_close(s->vfio);
60
61
g_free(s->device);
154
--
62
--
155
2.21.0
63
2.28.0
156
64
157
diff view generated by jsdifflib
1
From: Stefan Hajnoczi <stefanha@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Fixes: a6b257a08e3d72219f03e461a52152672fec0612
3
The Completion Queue Command Identifier is a 16-bit value,
4
("file-posix: Handle undetectable alignment")
4
so nvme_submit_command() is unlikely to work on big-endian
5
hosts, as the relevant bits are truncated.
6
Fix by using the correct byte-swap function.
7
8
Fixes: bdd6a90a9e5 ("block: Add VFIO based NVMe driver")
9
Reported-by: Keith Busch <kbusch@kernel.org>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Message-id: 20201029093306.1063879-25-philmd@redhat.com
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Message-id: 20190827101328.4062-1-stefanha@redhat.com
14
Tested-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
15
---
10
block/file-posix.c | 2 +-
16
block/nvme.c | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
17
1 file changed, 1 insertion(+), 1 deletion(-)
12
18
13
diff --git a/block/file-posix.c b/block/file-posix.c
19
diff --git a/block/nvme.c b/block/nvme.c
14
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
15
--- a/block/file-posix.c
21
--- a/block/nvme.c
16
+++ b/block/file-posix.c
22
+++ b/block/nvme.c
17
@@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
23
@@ -XXX,XX +XXX,XX @@ static void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req,
18
for (i = 0; i < ARRAY_SIZE(alignments); i++) {
24
assert(!req->cb);
19
align = alignments[i];
25
req->cb = cb;
20
if (raw_is_io_aligned(fd, buf + align, max_align)) {
26
req->opaque = opaque;
21
- /* Fallback to request_aligment. */
27
- cmd->cid = cpu_to_le32(req->cid);
22
+ /* Fallback to request_alignment. */
28
+ cmd->cid = cpu_to_le16(req->cid);
23
s->buf_align = (align != 1) ? align : bs->bl.request_alignment;
29
24
break;
30
trace_nvme_submit_command(q->s, q->index, req->cid);
25
}
31
nvme_trace_command(cmd);
26
--
32
--
27
2.21.0
33
2.28.0
28
34
29
diff view generated by jsdifflib
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
It's wrong to OR shared permissions. It may lead to crash on further
3
Change the confuse "VFIO IOMMU check failed" error message by
4
permission updates.
4
the explicit "VFIO IOMMU Type1 is not supported" once.
5
Also, no needs to consider previously calculated permissions, as at
6
this point we already bind all new parents and bdrv_get_cumulative_perm
7
result is enough. So fix the bug by just set permissions by
8
bdrv_get_cumulative_perm result.
9
5
10
Bug was introduced in long ago 234ac1a9025, in 2.9.
6
Example on POWER:
11
7
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
8
$ qemu-system-ppc64 -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw
13
Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com
9
qemu-system-ppc64: -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw: VFIO IOMMU Type1 is not supported
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
11
Suggested-by: Alex Williamson <alex.williamson@redhat.com>
12
Reviewed-by: Fam Zheng <fam@euphon.net>
13
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
15
Message-id: 20201103020733.2303148-2-philmd@redhat.com
16
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
17
Tested-by: Eric Auger <eric.auger@redhat.com>
15
---
18
---
16
block.c | 5 ++---
19
util/vfio-helpers.c | 2 +-
17
1 file changed, 2 insertions(+), 3 deletions(-)
20
1 file changed, 1 insertion(+), 1 deletion(-)
18
21
19
diff --git a/block.c b/block.c
22
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
20
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
21
--- a/block.c
24
--- a/util/vfio-helpers.c
22
+++ b/block.c
25
+++ b/util/vfio-helpers.c
23
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
26
@@ -XXX,XX +XXX,XX @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device,
24
{
25
BdrvChild *c, *next;
26
GSList *list = NULL, *p;
27
- uint64_t old_perm, old_shared;
28
uint64_t perm = 0, shared = BLK_PERM_ALL;
29
int ret;
30
31
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
32
bdrv_unref(from);
33
}
27
}
34
28
35
- bdrv_get_cumulative_perm(to, &old_perm, &old_shared);
29
if (!ioctl(s->container, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) {
36
- bdrv_set_perm(to, old_perm | perm, old_shared | shared);
30
- error_setg_errno(errp, errno, "VFIO IOMMU check failed");
37
+ bdrv_get_cumulative_perm(to, &perm, &shared);
31
+ error_setg_errno(errp, errno, "VFIO IOMMU Type1 is not supported");
38
+ bdrv_set_perm(to, perm, shared);
32
ret = -EINVAL;
39
33
goto fail_container;
40
out:
34
}
41
g_slist_free(list);
42
--
35
--
43
2.21.0
36
2.28.0
44
37
45
diff view generated by jsdifflib
1
streamOptimized does not support writes that do not span exactly one
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
cluster. Furthermore, it cannot rewrite already allocated clusters.
3
As such, many iotests do not work with it. Disable them.
4
2
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
We sometime get kernel panic with some devices on Aarch64
6
Message-id: 20190815153638.4600-6-mreitz@redhat.com
4
hosts. Alex Williamson suggests it might be broken PCIe
7
Reviewed-by: John Snow <jsnow@redhat.com>
5
root complex. Add trace event to record the latest I/O
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
access before crashing. In case, assert our accesses are
7
aligned.
8
9
Reviewed-by: Fam Zheng <fam@euphon.net>
10
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-id: 20201103020733.2303148-3-philmd@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Tested-by: Eric Auger <eric.auger@redhat.com>
9
---
15
---
10
tests/qemu-iotests/002 | 1 +
16
util/vfio-helpers.c | 8 ++++++++
11
tests/qemu-iotests/003 | 1 +
17
util/trace-events | 2 ++
12
tests/qemu-iotests/005 | 3 ++-
18
2 files changed, 10 insertions(+)
13
tests/qemu-iotests/009 | 1 +
14
tests/qemu-iotests/010 | 1 +
15
tests/qemu-iotests/011 | 1 +
16
tests/qemu-iotests/017 | 3 ++-
17
tests/qemu-iotests/018 | 3 ++-
18
tests/qemu-iotests/019 | 3 ++-
19
tests/qemu-iotests/020 | 3 ++-
20
tests/qemu-iotests/027 | 1 +
21
tests/qemu-iotests/032 | 1 +
22
tests/qemu-iotests/033 | 1 +
23
tests/qemu-iotests/034 | 3 ++-
24
tests/qemu-iotests/037 | 3 ++-
25
tests/qemu-iotests/063 | 3 ++-
26
tests/qemu-iotests/072 | 1 +
27
tests/qemu-iotests/105 | 3 ++-
28
tests/qemu-iotests/197 | 1 +
29
tests/qemu-iotests/215 | 1 +
30
tests/qemu-iotests/251 | 1 +
31
21 files changed, 30 insertions(+), 9 deletions(-)
32
19
33
diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002
20
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
34
index XXXXXXX..XXXXXXX 100755
21
index XXXXXXX..XXXXXXX 100644
35
--- a/tests/qemu-iotests/002
22
--- a/util/vfio-helpers.c
36
+++ b/tests/qemu-iotests/002
23
+++ b/util/vfio-helpers.c
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
24
@@ -XXX,XX +XXX,XX @@ static int qemu_vfio_pci_read_config(QEMUVFIOState *s, void *buf,
38
25
{
39
_supported_fmt generic
26
int ret;
40
_supported_proto generic
27
41
+_unsupported_imgopts "subformat=streamOptimized"
28
+ trace_qemu_vfio_pci_read_config(buf, ofs, size,
42
29
+ s->config_region_info.offset,
43
30
+ s->config_region_info.size);
44
size=128M
31
+ assert(QEMU_IS_ALIGNED(s->config_region_info.offset + ofs, size));
45
diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003
32
do {
46
index XXXXXXX..XXXXXXX 100755
33
ret = pread(s->device, buf, size, s->config_region_info.offset + ofs);
47
--- a/tests/qemu-iotests/003
34
} while (ret == -1 && errno == EINTR);
48
+++ b/tests/qemu-iotests/003
35
@@ -XXX,XX +XXX,XX @@ static int qemu_vfio_pci_write_config(QEMUVFIOState *s, void *buf, int size, int
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
36
{
50
37
int ret;
51
_supported_fmt generic
38
52
_supported_proto generic
39
+ trace_qemu_vfio_pci_write_config(buf, ofs, size,
53
+_unsupported_imgopts "subformat=streamOptimized"
40
+ s->config_region_info.offset,
54
41
+ s->config_region_info.size);
55
size=128M
42
+ assert(QEMU_IS_ALIGNED(s->config_region_info.offset + ofs, size));
56
offset=67M
43
do {
57
diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005
44
ret = pwrite(s->device, buf, size, s->config_region_info.offset + ofs);
58
index XXXXXXX..XXXXXXX 100755
45
} while (ret == -1 && errno == EINTR);
59
--- a/tests/qemu-iotests/005
46
diff --git a/util/trace-events b/util/trace-events
60
+++ b/tests/qemu-iotests/005
47
index XXXXXXX..XXXXXXX 100644
61
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
48
--- a/util/trace-events
62
_supported_proto generic
49
+++ b/util/trace-events
63
_supported_os Linux
50
@@ -XXX,XX +XXX,XX @@ qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova
64
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
51
qemu_vfio_do_mapping(void *s, void *host, size_t size, uint64_t iova) "s %p host %p size 0x%zx iova 0x%"PRIx64
65
- "subformat=twoGbMaxExtentSparse"
52
qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d iova %p"
66
+ "subformat=twoGbMaxExtentSparse" \
53
qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p"
67
+ "subformat=streamOptimized"
54
+qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size 0x%x (region addr 0x%"PRIx64" size 0x%"PRIx64")"
68
55
+qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size 0x%x (region addr 0x%"PRIx64" size 0x%"PRIx64")"
69
# vpc is limited to 127GB, so we can't test it here
70
if [ "$IMGFMT" = "vpc" ]; then
71
diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009
72
index XXXXXXX..XXXXXXX 100755
73
--- a/tests/qemu-iotests/009
74
+++ b/tests/qemu-iotests/009
75
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
76
77
_supported_fmt generic
78
_supported_proto generic
79
+_unsupported_imgopts "subformat=streamOptimized"
80
81
82
size=6G
83
diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010
84
index XXXXXXX..XXXXXXX 100755
85
--- a/tests/qemu-iotests/010
86
+++ b/tests/qemu-iotests/010
87
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
88
89
_supported_fmt generic
90
_supported_proto generic
91
+_unsupported_imgopts "subformat=streamOptimized"
92
93
94
size=6G
95
diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011
96
index XXXXXXX..XXXXXXX 100755
97
--- a/tests/qemu-iotests/011
98
+++ b/tests/qemu-iotests/011
99
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
100
101
_supported_fmt generic
102
_supported_proto generic
103
+_unsupported_imgopts "subformat=streamOptimized"
104
105
106
size=6G
107
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
108
index XXXXXXX..XXXXXXX 100755
109
--- a/tests/qemu-iotests/017
110
+++ b/tests/qemu-iotests/017
111
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
112
_supported_fmt qcow qcow2 vmdk qed
113
_supported_proto generic
114
_unsupported_proto vxhs
115
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
116
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
117
+ "subformat=streamOptimized"
118
119
TEST_OFFSETS="0 4294967296"
120
121
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
122
index XXXXXXX..XXXXXXX 100755
123
--- a/tests/qemu-iotests/018
124
+++ b/tests/qemu-iotests/018
125
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
126
_supported_fmt qcow qcow2 vmdk qed
127
_supported_proto file
128
_supported_os Linux
129
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
130
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
131
+ "streamOptimized"
132
133
TEST_OFFSETS="0 4294967296"
134
135
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
136
index XXXXXXX..XXXXXXX 100755
137
--- a/tests/qemu-iotests/019
138
+++ b/tests/qemu-iotests/019
139
@@ -XXX,XX +XXX,XX @@ _supported_proto file
140
_supported_os Linux
141
_unsupported_imgopts "subformat=monolithicFlat" \
142
"subformat=twoGbMaxExtentFlat" \
143
- "subformat=twoGbMaxExtentSparse"
144
+ "subformat=twoGbMaxExtentSparse" \
145
+ "subformat=streamOptimized"
146
147
TEST_OFFSETS="0 4294967296"
148
CLUSTER_SIZE=65536
149
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
150
index XXXXXXX..XXXXXXX 100755
151
--- a/tests/qemu-iotests/020
152
+++ b/tests/qemu-iotests/020
153
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
154
_supported_proto file
155
_unsupported_imgopts "subformat=monolithicFlat" \
156
"subformat=twoGbMaxExtentFlat" \
157
- "subformat=twoGbMaxExtentSparse"
158
+ "subformat=twoGbMaxExtentSparse" \
159
+ "subformat=streamOptimized"
160
161
TEST_OFFSETS="0 4294967296"
162
163
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
164
index XXXXXXX..XXXXXXX 100755
165
--- a/tests/qemu-iotests/027
166
+++ b/tests/qemu-iotests/027
167
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
168
169
_supported_fmt vmdk qcow qcow2 qed
170
_supported_proto generic
171
+_unsupported_imgopts "subformat=streamOptimized"
172
173
174
size=128M
175
diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032
176
index XXXXXXX..XXXXXXX 100755
177
--- a/tests/qemu-iotests/032
178
+++ b/tests/qemu-iotests/032
179
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
180
# This works for any image format (though unlikely to segfault for raw)
181
_supported_fmt generic
182
_supported_proto generic
183
+_unsupported_imgopts "subformat=streamOptimized"
184
185
echo
186
echo === Prepare image ===
187
diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033
188
index XXXXXXX..XXXXXXX 100755
189
--- a/tests/qemu-iotests/033
190
+++ b/tests/qemu-iotests/033
191
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
192
193
_supported_fmt generic
194
_supported_proto generic
195
+_unsupported_imgopts "subformat=streamOptimized"
196
197
198
size=128M
199
diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034
200
index XXXXXXX..XXXXXXX 100755
201
--- a/tests/qemu-iotests/034
202
+++ b/tests/qemu-iotests/034
203
@@ -XXX,XX +XXX,XX @@ _supported_proto file
204
_supported_os Linux
205
_unsupported_imgopts "subformat=monolithicFlat" \
206
"subformat=twoGbMaxExtentFlat" \
207
- "subformat=twoGbMaxExtentSparse"
208
+ "subformat=twoGbMaxExtentSparse" \
209
+ "subformat=streamOptimized"
210
211
CLUSTER_SIZE=4k
212
size=128M
213
diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037
214
index XXXXXXX..XXXXXXX 100755
215
--- a/tests/qemu-iotests/037
216
+++ b/tests/qemu-iotests/037
217
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
218
_supported_proto file
219
_unsupported_imgopts "subformat=monolithicFlat" \
220
"subformat=twoGbMaxExtentFlat" \
221
- "subformat=twoGbMaxExtentSparse"
222
+ "subformat=twoGbMaxExtentSparse" \
223
+ "subformat=streamOptimized"
224
225
CLUSTER_SIZE=4k
226
size=128M
227
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
228
index XXXXXXX..XXXXXXX 100755
229
--- a/tests/qemu-iotests/063
230
+++ b/tests/qemu-iotests/063
231
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw
232
_supported_proto file
233
_unsupported_imgopts "subformat=monolithicFlat" \
234
"subformat=twoGbMaxExtentFlat" \
235
- "subformat=twoGbMaxExtentSparse"
236
+ "subformat=twoGbMaxExtentSparse" \
237
+ "subformat=streamOptimized"
238
239
_make_test_img 4M
240
241
diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
242
index XXXXXXX..XXXXXXX 100755
243
--- a/tests/qemu-iotests/072
244
+++ b/tests/qemu-iotests/072
245
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
246
247
_supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow
248
_supported_proto file
249
+_unsupported_imgopts "subformat=streamOptimized"
250
251
IMG_SIZE=64M
252
253
diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105
254
index XXXXXXX..XXXXXXX 100755
255
--- a/tests/qemu-iotests/105
256
+++ b/tests/qemu-iotests/105
257
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
258
_supported_fmt qcow2 vmdk vhdx qed
259
_supported_proto generic
260
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
261
- "subformat=twoGbMaxExtentSparse"
262
+ "subformat=twoGbMaxExtentSparse" \
263
+ "subformat=streamOptimized"
264
265
echo
266
echo "creating large image"
267
diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
268
index XXXXXXX..XXXXXXX 100755
269
--- a/tests/qemu-iotests/197
270
+++ b/tests/qemu-iotests/197
271
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
272
_supported_proto generic
273
# LUKS support may be possible, but it complicates things.
274
_unsupported_fmt luks
275
+_unsupported_imgopts "subformat=streamOptimized"
276
277
echo
278
echo '=== Copy-on-read ==='
279
diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215
280
index XXXXXXX..XXXXXXX 100755
281
--- a/tests/qemu-iotests/215
282
+++ b/tests/qemu-iotests/215
283
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
284
_supported_proto generic
285
# LUKS support may be possible, but it complicates things.
286
_unsupported_fmt luks
287
+_unsupported_imgopts "subformat=streamOptimized"
288
289
echo
290
echo '=== Copy-on-read ==='
291
diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251
292
index XXXXXXX..XXXXXXX 100755
293
--- a/tests/qemu-iotests/251
294
+++ b/tests/qemu-iotests/251
295
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
296
_supported_fmt generic
297
_supported_proto file
298
_supported_os Linux
299
+_unsupported_imgopts "subformat=streamOptimized"
300
301
if [ "$IMGOPTSSYNTAX" = "true" ]; then
302
# We use json:{} filenames here, so we cannot work with additional options.
303
--
56
--
304
2.21.0
57
2.28.0
305
58
306
diff view generated by jsdifflib
1
Compressed writes generally have to write full clusters, not just in
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
theory but also in practice when it comes to vmdk's streamOptimized
3
subformat. It currently is just silently broken for writes with
4
non-zero in-cluster offsets:
5
2
6
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
3
For debug purpose, trace BAR regions info.
7
$ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk
8
wrote 4096/4096 bytes at offset 4096
9
4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec)
10
read failed: Invalid argument
11
4
12
(The technical reason is that vmdk_write_extent() just writes the
5
Reviewed-by: Fam Zheng <fam@euphon.net>
13
incomplete compressed data actually to offset 4k. When reading the
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
14
data, vmdk_read_extent() looks at offset 0 and finds the compressed data
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
15
size to be 0, because that is what it reads from there. This yields an
8
Message-id: 20201103020733.2303148-4-philmd@redhat.com
16
error.)
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Tested-by: Eric Auger <eric.auger@redhat.com>
11
---
12
util/vfio-helpers.c | 8 ++++++++
13
util/trace-events | 1 +
14
2 files changed, 9 insertions(+)
17
15
18
For incomplete writes with zero in-cluster offsets, the error path when
16
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
19
reading the rest of the cluster is a bit different, but the result is
17
index XXXXXXX..XXXXXXX 100644
20
the same:
18
--- a/util/vfio-helpers.c
19
+++ b/util/vfio-helpers.c
20
@@ -XXX,XX +XXX,XX @@ static inline void assert_bar_index_valid(QEMUVFIOState *s, int index)
21
22
static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, int index, Error **errp)
23
{
24
+ g_autofree char *barname = NULL;
25
assert_bar_index_valid(s, index);
26
s->bar_region_info[index] = (struct vfio_region_info) {
27
.index = VFIO_PCI_BAR0_REGION_INDEX + index,
28
@@ -XXX,XX +XXX,XX @@ static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, int index, Error **errp)
29
error_setg_errno(errp, errno, "Failed to get BAR region info");
30
return -errno;
31
}
32
+ barname = g_strdup_printf("bar[%d]", index);
33
+ trace_qemu_vfio_region_info(barname, s->bar_region_info[index].offset,
34
+ s->bar_region_info[index].size,
35
+ s->bar_region_info[index].cap_offset);
36
37
return 0;
38
}
39
@@ -XXX,XX +XXX,XX @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device,
40
ret = -errno;
41
goto fail;
42
}
43
+ trace_qemu_vfio_region_info("config", s->config_region_info.offset,
44
+ s->config_region_info.size,
45
+ s->config_region_info.cap_offset);
46
47
for (i = 0; i < ARRAY_SIZE(s->bar_region_info); i++) {
48
ret = qemu_vfio_pci_init_bar(s, i, errp);
49
diff --git a/util/trace-events b/util/trace-events
50
index XXXXXXX..XXXXXXX 100644
51
--- a/util/trace-events
52
+++ b/util/trace-events
53
@@ -XXX,XX +XXX,XX @@ qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *io
54
qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p"
55
qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size 0x%x (region addr 0x%"PRIx64" size 0x%"PRIx64")"
56
qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size 0x%x (region addr 0x%"PRIx64" size 0x%"PRIx64")"
57
+qemu_vfio_region_info(const char *desc, uint64_t region_ofs, uint64_t region_size, uint32_t cap_offset) "region '%s' addr 0x%"PRIx64" size 0x%"PRIx64" cap_ofs 0x%"PRIx32
58
--
59
2.28.0
21
60
22
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
23
$ qemu-io -c 'write 0k 4k' -c 'read 4k 4k' foo.vmdk
24
wrote 4096/4096 bytes at offset 0
25
4 KiB, 1 ops; 00.01 sec (362.641 KiB/sec and 90.6603 ops/sec)
26
read failed: Invalid argument
27
28
(Here, vmdk_read_extent() finds the data and then sees that the
29
uncompressed data is short.)
30
31
It is better to reject invalid writes than to make the user believe they
32
might have succeeded and then fail when trying to read it back.
33
34
Signed-off-by: Max Reitz <mreitz@redhat.com>
35
Reviewed-by: John Snow <jsnow@redhat.com>
36
Message-id: 20190815153638.4600-5-mreitz@redhat.com
37
Reviewed-by: John Snow <jsnow@redhat.com>
38
Signed-off-by: Max Reitz <mreitz@redhat.com>
39
---
40
block/vmdk.c | 10 ++++++++++
41
1 file changed, 10 insertions(+)
42
43
diff --git a/block/vmdk.c b/block/vmdk.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/block/vmdk.c
46
+++ b/block/vmdk.c
47
@@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,
48
if (extent->compressed) {
49
void *compressed_data;
50
51
+ /* Only whole clusters */
52
+ if (offset_in_cluster ||
53
+ n_bytes > (extent->cluster_sectors * SECTOR_SIZE) ||
54
+ (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) &&
55
+ offset + n_bytes != extent->end_sector * SECTOR_SIZE))
56
+ {
57
+ ret = -EINVAL;
58
+ goto out;
59
+ }
60
+
61
if (!extent->has_marker) {
62
ret = -EINVAL;
63
goto out;
64
--
65
2.21.0
66
67
diff view generated by jsdifflib
1
We had a test for a case where relative extent paths did not work, but
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
unfortunately we just fixed the underlying problem, so it works now.
3
This patch adds a new test case that still fails.
4
2
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
For debugging purpose, trace where a BAR is mapped.
6
Reviewed-by: John Snow <jsnow@redhat.com>
4
7
Message-id: 20190815153638.4600-4-mreitz@redhat.com
5
Reviewed-by: Fam Zheng <fam@euphon.net>
8
Reviewed-by: John Snow <jsnow@redhat.com>
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: 20201103020733.2303148-5-philmd@redhat.com
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Tested-by: Eric Auger <eric.auger@redhat.com>
10
---
11
---
11
tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++
12
util/vfio-helpers.c | 2 ++
12
tests/qemu-iotests/059.out | 4 ++++
13
util/trace-events | 1 +
13
2 files changed, 31 insertions(+)
14
2 files changed, 3 insertions(+)
14
15
15
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
16
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/qemu-iotests/059
18
+++ b/tests/qemu-iotests/059
19
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
20
21
echo
22
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
23
+
24
+echo '--- blkdebug ---'
25
# Should work, because bdrv_dirname() works fine with blkdebug
26
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
27
$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
28
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TE
29
| _filter_testdir | _filter_imgfmt | _filter_img_info
30
_cleanup_test_img
31
32
+echo '--- quorum ---'
33
+# Should not work, because bdrv_dirname() does not work with quorum
34
+IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
35
+cp "$TEST_IMG" "$TEST_IMG.orig"
36
+
37
+filename="json:{
38
+ \"driver\": \"$IMGFMT\",
39
+ \"file\": {
40
+ \"driver\": \"quorum\",
41
+ \"children\": [ {
42
+ \"driver\": \"file\",
43
+ \"filename\": \"$TEST_IMG\"
44
+ }, {
45
+ \"driver\": \"file\",
46
+ \"filename\": \"$TEST_IMG.orig\"
47
+ } ],
48
+ \"vote-threshold\": 1
49
+ } }"
50
+
51
+filename=$(echo "$filename" | tr '\n' ' ' | sed -e 's/\s\+/ /g')
52
+$QEMU_IMG info "$filename" 2>&1 \
53
+ | sed -e "s/'json:[^']*'/\$QUORUM_FILE/g" \
54
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
55
+
56
+
57
echo
58
echo "=== Testing version 3 ==="
59
_use_sample_img iotest-version3.vmdk.bz2
60
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
61
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
62
--- a/tests/qemu-iotests/059.out
18
--- a/util/vfio-helpers.c
63
+++ b/tests/qemu-iotests/059.out
19
+++ b/util/vfio-helpers.c
64
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
20
@@ -XXX,XX +XXX,XX @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index,
65
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
21
p = mmap(NULL, MIN(size, s->bar_region_info[index].size - offset),
66
22
prot, MAP_SHARED,
67
=== Testing monolithicFlat with internally generated JSON file name ===
23
s->device, s->bar_region_info[index].offset + offset);
68
+--- blkdebug ---
24
+ trace_qemu_vfio_pci_map_bar(index, s->bar_region_info[index].offset ,
69
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
25
+ size, offset, p);
70
format name: IMGFMT
26
if (p == MAP_FAILED) {
71
cluster size: 0 bytes
27
error_setg_errno(errp, errno, "Failed to map BAR region");
72
vm state offset: 0 bytes
28
p = NULL;
73
+--- quorum ---
29
diff --git a/util/trace-events b/util/trace-events
74
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
30
index XXXXXXX..XXXXXXX 100644
75
+qemu-img: Could not open $QUORUM_FILE: Cannot use relative paths with VMDK descriptor file $QUORUM_FILE: Cannot generate a base directory for quorum nodes
31
--- a/util/trace-events
76
32
+++ b/util/trace-events
77
=== Testing version 3 ===
33
@@ -XXX,XX +XXX,XX @@ qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p"
78
image: TEST_DIR/iotest-version3.IMGFMT
34
qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size 0x%x (region addr 0x%"PRIx64" size 0x%"PRIx64")"
35
qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size 0x%x (region addr 0x%"PRIx64" size 0x%"PRIx64")"
36
qemu_vfio_region_info(const char *desc, uint64_t region_ofs, uint64_t region_size, uint32_t cap_offset) "region '%s' addr 0x%"PRIx64" size 0x%"PRIx64" cap_ofs 0x%"PRIx32
37
+qemu_vfio_pci_map_bar(int index, uint64_t region_ofs, uint64_t region_size, int ofs, void *host) "map region bar#%d addr 0x%"PRIx64" size 0x%"PRIx64" ofs 0x%x host %p"
79
--
38
--
80
2.21.0
39
2.28.0
81
40
82
diff view generated by jsdifflib
1
fe646693acc changed qemu-img create's output so that it no longer prints
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
single quotes around parameter values. The subformat and adapter_type
3
filters in _filter_img_create() have never been adapted to that change.
4
2
5
Fixes: fe646693acc13ac48b98435d14149ab04dc597bc
3
For debugging purpose, trace where DMA regions are mapped.
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
7
Reviewed-by: John Snow <jsnow@redhat.com>
5
Reviewed-by: Fam Zheng <fam@euphon.net>
8
Message-id: 20190815153638.4600-2-mreitz@redhat.com
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: John Snow <jsnow@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
Message-id: 20201103020733.2303148-6-philmd@redhat.com
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Tested-by: Eric Auger <eric.auger@redhat.com>
11
---
11
---
12
tests/qemu-iotests/059.out | 16 ++++++++--------
12
util/vfio-helpers.c | 3 ++-
13
tests/qemu-iotests/common.filter | 4 ++--
13
util/trace-events | 5 +++--
14
2 files changed, 10 insertions(+), 10 deletions(-)
14
2 files changed, 5 insertions(+), 3 deletions(-)
15
15
16
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
16
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/059.out
18
--- a/util/vfio-helpers.c
19
+++ b/tests/qemu-iotests/059.out
19
+++ b/util/vfio-helpers.c
20
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
20
@@ -XXX,XX +XXX,XX @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size,
21
qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big
21
.vaddr = (uintptr_t)host,
22
22
.size = size,
23
=== Testing monolithicFlat creation and opening ===
23
};
24
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
24
- trace_qemu_vfio_do_mapping(s, host, size, iova);
25
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
25
+ trace_qemu_vfio_do_mapping(s, host, iova, size);
26
image: TEST_DIR/t.IMGFMT
26
27
file format: IMGFMT
27
if (ioctl(s->container, VFIO_IOMMU_MAP_DMA, &dma_map)) {
28
virtual size: 2 GiB (2147483648 bytes)
28
error_report("VFIO_MAP_DMA failed: %s", strerror(errno));
29
29
@@ -XXX,XX +XXX,XX @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size,
30
=== Testing monolithicFlat with zeroed_grain ===
30
}
31
qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
31
}
32
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
32
}
33
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
33
+ trace_qemu_vfio_dma_mapped(s, host, iova0, size);
34
34
if (iova) {
35
=== Testing big twoGbMaxExtentFlat ===
35
*iova = iova0;
36
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat
36
}
37
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000
37
diff --git a/util/trace-events b/util/trace-events
38
image: TEST_DIR/t.vmdk
39
file format: vmdk
40
virtual size: 0.977 TiB (1073741824000 bytes)
41
@@ -XXX,XX +XXX,XX @@ Format specific information:
42
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1
43
44
=== Testing truncated sparse ===
45
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse
46
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
47
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes
48
49
=== Converting to streamOptimized from image with small cluster size===
50
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
51
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
52
53
=== Testing monolithicFlat with internally generated JSON file name ===
54
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat
55
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
56
qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}'
57
58
=== Testing version 3 ===
59
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328
60
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
61
62
=== Testing 4TB monolithicFlat creation and IO ===
63
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat
64
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104
65
image: TEST_DIR/t.IMGFMT
66
file format: IMGFMT
67
virtual size: 4 TiB (4398046511104 bytes)
68
@@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600
69
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
70
71
=== Testing qemu-img map on extents ===
72
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse
73
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
74
wrote 1024/1024 bytes at offset 65024
75
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
76
wrote 1024/1024 bytes at offset 2147483136
77
@@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File
78
0 0x20000 0x3f0000 TEST_DIR/t.vmdk
79
0x7fff0000 0x20000 0x410000 TEST_DIR/t.vmdk
80
0x140000000 0x10000 0x430000 TEST_DIR/t.vmdk
81
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=twoGbMaxExtentSparse
82
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
83
wrote 1024/1024 bytes at offset 65024
84
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
85
wrote 1024/1024 bytes at offset 2147483136
86
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
87
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
88
--- a/tests/qemu-iotests/common.filter
39
--- a/util/trace-events
89
+++ b/tests/qemu-iotests/common.filter
40
+++ b/util/trace-events
90
@@ -XXX,XX +XXX,XX @@ _filter_img_create()
41
@@ -XXX,XX +XXX,XX @@ qemu_vfio_ram_block_added(void *s, void *p, size_t size) "s %p host %p size 0x%z
91
-e "s# compat6=\\(on\\|off\\)##g" \
42
qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p size 0x%zx"
92
-e "s# static=\\(on\\|off\\)##g" \
43
qemu_vfio_find_mapping(void *s, void *p) "s %p host %p"
93
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
44
qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova) "s %p host %p size 0x%zx index %d iova 0x%"PRIx64
94
- -e "s# subformat='[^']*'##g" \
45
-qemu_vfio_do_mapping(void *s, void *host, size_t size, uint64_t iova) "s %p host %p size 0x%zx iova 0x%"PRIx64
95
- -e "s# adapter_type='[^']*'##g" \
46
-qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d iova %p"
96
+ -e "s# subformat=[^ ]*##g" \
47
+qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64 " size 0x%zx"
97
+ -e "s# adapter_type=[^ ]*##g" \
48
+qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d &iova %p"
98
-e "s# hwversion=[^ ]*##g" \
49
+qemu_vfio_dma_mapped(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64" size 0x%zx"
99
-e "s# lazy_refcounts=\\(on\\|off\\)##g" \
50
qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p"
100
-e "s# block_size=[0-9]\\+##g" \
51
qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size 0x%x (region addr 0x%"PRIx64" size 0x%"PRIx64")"
52
qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size 0x%x (region addr 0x%"PRIx64" size 0x%"PRIx64")"
101
--
53
--
102
2.21.0
54
2.28.0
103
55
104
diff view generated by jsdifflib
1
This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
turns a former error in 059 into success.
3
2
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
3
The QEMU_VFIO_DEBUG definition is only modifiable at build-time.
5
Message-id: 20190815153638.4600-3-mreitz@redhat.com
4
Trace events can be enabled at run-time. As we prefer the latter,
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
convert qemu_vfio_dump_mappings() to use trace events instead
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
of fprintf().
7
8
Reviewed-by: Fam Zheng <fam@euphon.net>
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20201103020733.2303148-7-philmd@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Tested-by: Eric Auger <eric.auger@redhat.com>
8
---
14
---
9
block/vmdk.c | 54 ++++++++++++++++++++++++--------------
15
util/vfio-helpers.c | 19 ++++---------------
10
tests/qemu-iotests/059 | 7 +++--
16
util/trace-events | 1 +
11
tests/qemu-iotests/059.out | 4 ++-
17
2 files changed, 5 insertions(+), 15 deletions(-)
12
3 files changed, 42 insertions(+), 23 deletions(-)
13
18
14
diff --git a/block/vmdk.c b/block/vmdk.c
19
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
15
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
16
--- a/block/vmdk.c
21
--- a/util/vfio-helpers.c
17
+++ b/block/vmdk.c
22
+++ b/util/vfio-helpers.c
18
@@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s)
23
@@ -XXX,XX +XXX,XX @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp)
24
return s;
19
}
25
}
20
26
21
static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
27
-static void qemu_vfio_dump_mapping(IOVAMapping *m)
22
- const char *desc_file_path, QDict *options,
28
-{
23
- Error **errp)
29
- if (QEMU_VFIO_DEBUG) {
24
+ QDict *options, Error **errp)
30
- printf(" vfio mapping %p %" PRIx64 " to %" PRIx64 "\n", m->host,
31
- (uint64_t)m->size, (uint64_t)m->iova);
32
- }
33
-}
34
-
35
static void qemu_vfio_dump_mappings(QEMUVFIOState *s)
25
{
36
{
26
int ret;
37
- int i;
27
int matches;
38
-
28
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
39
- if (QEMU_VFIO_DEBUG) {
29
const char *p, *np;
40
- printf("vfio mappings\n");
30
int64_t sectors = 0;
41
- for (i = 0; i < s->nr_mappings; ++i) {
31
int64_t flat_offset;
42
- qemu_vfio_dump_mapping(&s->mappings[i]);
32
+ char *desc_file_dir = NULL;
33
char *extent_path;
34
BdrvChild *extent_file;
35
BDRVVmdkState *s = bs->opaque;
36
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
37
continue;
38
}
39
40
- if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
41
- !desc_file_path[0])
42
- {
43
- bdrv_refresh_filename(bs->file->bs);
44
- error_setg(errp, "Cannot use relative extent paths with VMDK "
45
- "descriptor file '%s'", bs->file->bs->filename);
46
- return -EINVAL;
47
- }
43
- }
48
+ if (path_is_absolute(fname)) {
44
+ for (int i = 0; i < s->nr_mappings; ++i) {
49
+ extent_path = g_strdup(fname);
45
+ trace_qemu_vfio_dump_mapping(s->mappings[i].host,
50
+ } else {
46
+ s->mappings[i].iova,
51
+ if (!desc_file_dir) {
47
+ s->mappings[i].size);
52
+ desc_file_dir = bdrv_dirname(bs->file->bs, errp);
53
+ if (!desc_file_dir) {
54
+ bdrv_refresh_filename(bs->file->bs);
55
+ error_prepend(errp, "Cannot use relative paths with VMDK "
56
+ "descriptor file '%s': ",
57
+ bs->file->bs->filename);
58
+ ret = -EINVAL;
59
+ goto out;
60
+ }
61
+ }
62
63
- extent_path = path_combine(desc_file_path, fname);
64
+ extent_path = g_strconcat(desc_file_dir, fname, NULL);
65
+ }
66
67
ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents);
68
assert(ret < 32);
69
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
70
g_free(extent_path);
71
if (local_err) {
72
error_propagate(errp, local_err);
73
- return -EINVAL;
74
+ ret = -EINVAL;
75
+ goto out;
76
}
77
78
/* save to extents array */
79
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
80
0, 0, 0, 0, 0, &extent, errp);
81
if (ret < 0) {
82
bdrv_unref_child(bs, extent_file);
83
- return ret;
84
+ goto out;
85
}
86
extent->flat_start_offset = flat_offset << 9;
87
} else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) {
88
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
89
g_free(buf);
90
if (ret) {
91
bdrv_unref_child(bs, extent_file);
92
- return ret;
93
+ goto out;
94
}
95
extent = &s->extents[s->num_extents - 1];
96
} else if (!strcmp(type, "SESPARSE")) {
97
ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp);
98
if (ret) {
99
bdrv_unref_child(bs, extent_file);
100
- return ret;
101
+ goto out;
102
}
103
extent = &s->extents[s->num_extents - 1];
104
} else {
105
error_setg(errp, "Unsupported extent type '%s'", type);
106
bdrv_unref_child(bs, extent_file);
107
- return -ENOTSUP;
108
+ ret = -ENOTSUP;
109
+ goto out;
110
}
111
extent->type = g_strdup(type);
112
}
48
}
113
- return 0;
114
+
115
+ ret = 0;
116
+ goto out;
117
118
invalid:
119
np = next_line(p);
120
@@ -XXX,XX +XXX,XX @@ invalid:
121
np--;
122
}
123
error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p);
124
- return -EINVAL;
125
+ ret = -EINVAL;
126
+
127
+out:
128
+ g_free(desc_file_dir);
129
+ return ret;
130
}
49
}
131
50
132
static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
51
diff --git a/util/trace-events b/util/trace-events
133
@@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
134
}
135
s->create_type = g_strdup(ct);
136
s->desc_offset = 0;
137
- ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options,
138
- errp);
139
+ ret = vmdk_parse_extents(buf, bs, options, errp);
140
exit:
141
return ret;
142
}
143
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
144
index XXXXXXX..XXXXXXX 100755
145
--- a/tests/qemu-iotests/059
146
+++ b/tests/qemu-iotests/059
147
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
148
149
echo
150
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
151
+# Should work, because bdrv_dirname() works fine with blkdebug
152
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
153
-$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" 2>&1 \
154
- | _filter_testdir | _filter_imgfmt
155
+$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
156
+ -c info \
157
+ 2>&1 \
158
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
159
_cleanup_test_img
160
161
echo
162
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
163
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
164
--- a/tests/qemu-iotests/059.out
53
--- a/util/trace-events
165
+++ b/tests/qemu-iotests/059.out
54
+++ b/util/trace-events
166
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
55
@@ -XXX,XX +XXX,XX @@ qemu_mutex_unlock(void *mutex, const char *file, const int line) "released mutex
167
56
qemu_vfio_dma_reset_temporary(void *s) "s %p"
168
=== Testing monolithicFlat with internally generated JSON file name ===
57
qemu_vfio_ram_block_added(void *s, void *p, size_t size) "s %p host %p size 0x%zx"
169
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
58
qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p size 0x%zx"
170
-qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}'
59
+qemu_vfio_dump_mapping(void *host, uint64_t iova, size_t size) "vfio mapping %p to iova 0x%08" PRIx64 " size 0x%zx"
171
+format name: IMGFMT
60
qemu_vfio_find_mapping(void *s, void *p) "s %p host %p"
172
+cluster size: 0 bytes
61
qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova) "s %p host %p size 0x%zx index %d iova 0x%"PRIx64
173
+vm state offset: 0 bytes
62
qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64 " size 0x%zx"
174
175
=== Testing version 3 ===
176
image: TEST_DIR/iotest-version3.IMGFMT
177
--
63
--
178
2.21.0
64
2.28.0
179
65
180
diff view generated by jsdifflib
1
From: Nir Soffer <nirsof@gmail.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Using block_resize we can test allocate_first_block() with file
3
mmap(2) states:
4
descriptor opened with O_DIRECT, ensuring that it works for any size
5
larger than 4096 bytes.
6
4
7
Testing smaller sizes is tricky as the result depends on the filesystem
5
'offset' must be a multiple of the page size as returned
8
used for testing. For example on NFS any size will work since O_DIRECT
6
by sysconf(_SC_PAGE_SIZE).
9
does not require any alignment.
10
7
11
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
8
Add an assertion to be sure we don't break this contract.
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
9
13
Message-id: 20190827010528.8818-3-nsoffer@redhat.com
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
Message-id: 20201103020733.2303148-8-philmd@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Tested-by: Eric Auger <eric.auger@redhat.com>
15
---
14
---
16
tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++
15
util/vfio-helpers.c | 1 +
17
tests/qemu-iotests/175.out | 8 ++++++++
16
1 file changed, 1 insertion(+)
18
2 files changed, 36 insertions(+)
19
17
20
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
18
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
21
index XXXXXXX..XXXXXXX 100755
22
--- a/tests/qemu-iotests/175
23
+++ b/tests/qemu-iotests/175
24
@@ -XXX,XX +XXX,XX @@ _filter_blocks()
25
-e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
26
}
27
28
+# Resize image using block_resize.
29
+# Parameter 1: image path
30
+# Parameter 2: new size
31
+_block_resize()
32
+{
33
+ local path=$1
34
+ local size=$2
35
+
36
+ $QEMU -qmp stdio -nographic -nodefaults \
37
+ -blockdev file,node-name=file,filename=$path,cache.direct=on \
38
+ <<EOF
39
+{'execute': 'qmp_capabilities'}
40
+{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}}
41
+{'execute': 'quit'}
42
+EOF
43
+}
44
+
45
# get standard environment, filters and checks
46
. ./common.rc
47
. ./common.filter
48
@@ -XXX,XX +XXX,XX @@ _supported_fmt raw
49
_supported_proto file
50
_supported_os Linux
51
52
+_default_cache_mode none
53
+_supported_cache_modes none directsync
54
+
55
size=$((1 * 1024 * 1024))
56
57
touch "$TEST_DIR/empty"
58
@@ -XXX,XX +XXX,XX @@ for mode in off full falloc; do
59
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
60
done
61
62
+for new_size in 4096 1048576; do
63
+ echo
64
+ echo "== resize empty image with block_resize =="
65
+ _make_test_img 0 | _filter_imgfmt
66
+ _block_resize $TEST_IMG $new_size >/dev/null
67
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size
68
+done
69
+
70
# success, all done
71
echo "*** done"
72
rm -f $seq.full
73
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
74
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
75
--- a/tests/qemu-iotests/175.out
20
--- a/util/vfio-helpers.c
76
+++ b/tests/qemu-iotests/175.out
21
+++ b/util/vfio-helpers.c
77
@@ -XXX,XX +XXX,XX @@ size=1048576, max allocation
22
@@ -XXX,XX +XXX,XX @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index,
78
== creating image with preallocation falloc ==
23
Error **errp)
79
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
24
{
80
size=1048576, max allocation
25
void *p;
81
+
26
+ assert(QEMU_IS_ALIGNED(offset, qemu_real_host_page_size));
82
+== resize empty image with block_resize ==
27
assert_bar_index_valid(s, index);
83
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
28
p = mmap(NULL, MIN(size, s->bar_region_info[index].size - offset),
84
+size=4096, min allocation
29
prot, MAP_SHARED,
85
+
86
+== resize empty image with block_resize ==
87
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
88
+size=1048576, min allocation
89
*** done
90
--
30
--
91
2.21.0
31
2.28.0
92
32
93
diff view generated by jsdifflib