1
The following changes since commit bfec359afba088aaacc7d316f43302f28c6e642a:
1
The following changes since commit 8507c9d5c9a62de2a0e281b640f995e26eac46af:
2
2
3
Merge remote-tracking branch 'remotes/armbru/tags/pull-qdev-2017-04-21' into staging (2017-04-21 11:42:03 +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
git://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 1507631e438930bc07f776f303af127a9cdb4d41:
9
for you to fetch changes up to fc107d86840b3364e922c26cf7631b7fd38ce523:
10
10
11
qemu-iotests: _cleanup_qemu must be called on exit (2017-04-21 08:32:44 -0400)
11
util/vfio-helpers: Assert offset is aligned to page size (2020-11-03 19:06:23 +0000)
12
13
----------------------------------------------------------------
14
Pull request for 5.2
15
16
NVMe fixes to solve IOMMU issues on non-x86 and error message/tracing
17
improvements. Elena Afanasova's ioeventfd fixes are also included.
18
19
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
20
13
----------------------------------------------------------------
21
----------------------------------------------------------------
14
22
15
Block patches for 2.10
23
Elena Afanasova (2):
24
accel/kvm: add PIO ioeventfds only in case kvm_eventfds_allowed is
25
true
26
softmmu/memory: fix memory_region_ioeventfd_equal()
16
27
17
----------------------------------------------------------------
28
Eric Auger (4):
29
block/nvme: Change size and alignment of IDENTIFY response buffer
30
block/nvme: Change size and alignment of queue
31
block/nvme: Change size and alignment of prp_list_pages
32
block/nvme: Align iov's va and size on host page size
18
33
19
Ashish Mittal (2):
34
Philippe Mathieu-Daudé (27):
20
block/vxhs.c: Add support for a new block device type called "vxhs"
35
MAINTAINERS: Cover "block/nvme.h" file
21
block/vxhs.c: Add qemu-iotests for new block device type "vxhs"
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
22
62
23
Jeff Cody (10):
63
MAINTAINERS | 2 +
24
qemu-iotests: exclude vxhs from image creation via protocol
64
include/block/nvme.h | 18 ++--
25
block: add bdrv_set_read_only() helper function
65
accel/kvm/kvm-all.c | 6 +-
26
block: do not set BDS read_only if copy_on_read enabled
66
block/nvme.c | 209 ++++++++++++++++++++++++-------------------
27
block: honor BDRV_O_ALLOW_RDWR when clearing bs->read_only
67
softmmu/memory.c | 11 ++-
28
block: code movement
68
util/vfio-helpers.c | 43 +++++----
29
block: introduce bdrv_can_set_read_only()
69
block/trace-events | 30 ++++---
30
block: use bdrv_can_set_read_only() during reopen
70
util/trace-events | 10 ++-
31
block/rbd - update variable names to more apt names
71
8 files changed, 195 insertions(+), 134 deletions(-)
32
block/rbd: Add support for reopen()
33
qemu-iotests: _cleanup_qemu must be called on exit
34
35
block.c | 56 +++-
36
block/Makefile.objs | 2 +
37
block/bochs.c | 5 +-
38
block/cloop.c | 5 +-
39
block/dmg.c | 6 +-
40
block/rbd.c | 65 +++--
41
block/trace-events | 17 ++
42
block/vvfat.c | 19 +-
43
block/vxhs.c | 575 +++++++++++++++++++++++++++++++++++++++
44
configure | 39 +++
45
include/block/block.h | 2 +
46
qapi/block-core.json | 23 +-
47
tests/qemu-iotests/017 | 1 +
48
tests/qemu-iotests/020 | 1 +
49
tests/qemu-iotests/028 | 1 +
50
tests/qemu-iotests/029 | 1 +
51
tests/qemu-iotests/073 | 1 +
52
tests/qemu-iotests/094 | 11 +-
53
tests/qemu-iotests/102 | 5 +-
54
tests/qemu-iotests/109 | 1 +
55
tests/qemu-iotests/114 | 1 +
56
tests/qemu-iotests/117 | 1 +
57
tests/qemu-iotests/130 | 2 +
58
tests/qemu-iotests/134 | 1 +
59
tests/qemu-iotests/140 | 1 +
60
tests/qemu-iotests/141 | 1 +
61
tests/qemu-iotests/143 | 1 +
62
tests/qemu-iotests/156 | 2 +
63
tests/qemu-iotests/158 | 1 +
64
tests/qemu-iotests/common | 6 +
65
tests/qemu-iotests/common.config | 13 +
66
tests/qemu-iotests/common.filter | 1 +
67
tests/qemu-iotests/common.rc | 19 ++
68
33 files changed, 844 insertions(+), 42 deletions(-)
69
create mode 100644 block/vxhs.c
70
72
71
--
73
--
72
2.9.3
74
2.28.0
73
75
74
diff view generated by jsdifflib
New patch
1
From: Elena Afanasova <eafanasova@gmail.com>
1
2
3
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4
Signed-off-by: Elena Afanasova <eafanasova@gmail.com>
5
Message-Id: <20201017210102.26036-1-eafanasova@gmail.com>
6
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7
---
8
accel/kvm/kvm-all.c | 6 ++++--
9
1 file changed, 4 insertions(+), 2 deletions(-)
10
11
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/accel/kvm/kvm-all.c
14
+++ b/accel/kvm/kvm-all.c
15
@@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms)
16
17
kvm_memory_listener_register(s, &s->memory_listener,
18
&address_space_memory, 0);
19
- memory_listener_register(&kvm_io_listener,
20
- &address_space_io);
21
+ if (kvm_eventfds_allowed) {
22
+ memory_listener_register(&kvm_io_listener,
23
+ &address_space_io);
24
+ }
25
memory_listener_register(&kvm_coalesced_pio_listener,
26
&address_space_io);
27
28
--
29
2.28.0
30
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
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
The "block/nvme.h" header is shared by both the NVMe block
4
driver and the NVMe emulated device. Add the 'F:' entry on
5
both sections, so all maintainers/reviewers are notified
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>
12
---
13
MAINTAINERS | 2 ++
14
1 file changed, 2 insertions(+)
15
16
diff --git a/MAINTAINERS b/MAINTAINERS
17
index XXXXXXX..XXXXXXX 100644
18
--- a/MAINTAINERS
19
+++ b/MAINTAINERS
20
@@ -XXX,XX +XXX,XX @@ M: Klaus Jensen <its@irrelevant.dk>
21
L: qemu-block@nongnu.org
22
S: Supported
23
F: hw/block/nvme*
24
+F: include/block/nvme.h
25
F: tests/qtest/nvme-test.c
26
F: docs/specs/nvme.txt
27
T: git git://git.infradead.org/qemu-nvme.git nvme-next
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
36
--
37
2.28.0
38
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
1
Move bdrv_is_read_only() up with its friends.
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
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>
3
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4
Reviewed-by: John Snow <jsnow@redhat.com>
9
Tested-by: Eric Auger <eric.auger@redhat.com>
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Message-id: 73b2399459760c32506f9407efb9dddb3a2789de.1491597120.git.jcody@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>
7
---
14
---
8
block.c | 10 +++++-----
15
block/nvme.c | 2 +-
9
1 file changed, 5 insertions(+), 5 deletions(-)
16
block/trace-events | 2 +-
17
2 files changed, 2 insertions(+), 2 deletions(-)
10
18
11
diff --git a/block.c b/block.c
19
diff --git a/block/nvme.c b/block/nvme.c
12
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
13
--- a/block.c
21
--- a/block/nvme.c
14
+++ b/block.c
22
+++ b/block/nvme.c
15
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
23
@@ -XXX,XX +XXX,XX @@ static bool nvme_poll_queue(NVMeQueuePair *q)
16
}
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);
17
}
37
}
18
38
19
+bool bdrv_is_read_only(BlockDriverState *bs)
39
diff --git a/block/trace-events b/block/trace-events
20
+{
40
index XXXXXXX..XXXXXXX 100644
21
+ return bs->read_only;
41
--- a/block/trace-events
22
+}
42
+++ b/block/trace-events
23
+
43
@@ -XXX,XX +XXX,XX @@ nvme_complete_command(void *s, int index, int cid) "s %p queue %d cid %d"
24
int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
44
nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d"
25
{
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"
26
/* Do not set read_only if copy_on_read is enabled */
46
nvme_handle_event(void *s) "s %p"
27
@@ -XXX,XX +XXX,XX @@ void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr)
47
-nvme_poll_cb(void *s) "s %p"
28
*nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors;
48
+nvme_poll_queue(void *s, unsigned q_index) "s %p q #%u"
29
}
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"
30
50
nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s %p offset 0x%"PRIx64" bytes %"PRId64" flags %d"
31
-bool bdrv_is_read_only(BlockDriverState *bs)
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"
32
-{
33
- return bs->read_only;
34
-}
35
-
36
bool bdrv_is_sg(BlockDriverState *bs)
37
{
38
return bs->sg;
39
--
52
--
40
2.9.3
53
2.28.0
41
54
42
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
1
From: Ashish Mittal <ashmit602@gmail.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Source code for the qnio library that this code loads can be downloaded from:
3
We can not have negative queue count/size/index, use unsigned type.
4
https://github.com/VeritasHyperScale/libqnio.git
4
Rename 'nr_queues' as 'queue_count' to match the spec naming.
5
5
6
Sample command line using JSON syntax:
6
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
./x86_64-softmmu/qemu-system-x86_64 -name instance-00000008 -S -vnc 0.0.0.0:0
8
-k en-us -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
9
-msg timestamp=on
10
'json:{"driver":"vxhs","vdisk-id":"c3e9095a-a5ee-4dce-afeb-2a59fb387410",
11
"server":{"host":"172.172.17.4","port":"9999"}}'
12
13
Sample command line using URI syntax:
14
qemu-img convert -f raw -O raw -n
15
/var/lib/nova/instances/_base/0c5eacd5ebea5ed914b6a3e7b18f1ce734c386ad
16
vxhs://192.168.0.1:9999/c6718f6b-0401-441d-a8c3-1f0064d75ee0
17
18
Sample command line using TLS credentials (run in secure mode):
19
./qemu-io --object
20
tls-creds-x509,id=tls0,dir=/etc/pki/qemu/vxhs,endpoint=client -c 'read
21
-v 66000 2.5k' 'json:{"server.host": "127.0.0.1", "server.port": "9999",
22
"vdisk-id": "/test.raw", "driver": "vxhs", "tls-creds":"tls0"}'
23
24
Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
25
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
26
Reviewed-by: Jeff Cody <jcody@redhat.com>
8
Tested-by: Eric Auger <eric.auger@redhat.com>
27
Signed-off-by: Jeff Cody <jcody@redhat.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
28
Message-id: 1491277689-24949-2-git-send-email-Ashish.Mittal@veritas.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>
29
---
13
---
30
block/Makefile.objs | 2 +
14
block/nvme.c | 38 ++++++++++++++++++--------------------
31
block/trace-events | 17 ++
15
block/trace-events | 10 +++++-----
32
block/vxhs.c | 575 +++++++++++++++++++++++++++++++++++++++++++++++++++
16
2 files changed, 23 insertions(+), 25 deletions(-)
33
configure | 39 ++++
17
34
qapi/block-core.json | 23 ++-
18
diff --git a/block/nvme.c b/block/nvme.c
35
5 files changed, 654 insertions(+), 2 deletions(-)
36
create mode 100644 block/vxhs.c
37
38
diff --git a/block/Makefile.objs b/block/Makefile.objs
39
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
40
--- a/block/Makefile.objs
20
--- a/block/nvme.c
41
+++ b/block/Makefile.objs
21
+++ b/block/nvme.c
42
@@ -XXX,XX +XXX,XX @@ block-obj-$(CONFIG_LIBNFS) += nfs.o
22
@@ -XXX,XX +XXX,XX @@ struct BDRVNVMeState {
43
block-obj-$(CONFIG_CURL) += curl.o
23
* [1..]: io queues.
44
block-obj-$(CONFIG_RBD) += rbd.o
24
*/
45
block-obj-$(CONFIG_GLUSTERFS) += gluster.o
25
NVMeQueuePair **queues;
46
+block-obj-$(CONFIG_VXHS) += vxhs.o
26
- int nr_queues;
47
block-obj-$(CONFIG_LIBSSH2) += ssh.o
27
+ unsigned queue_count;
48
block-obj-y += accounting.o dirty-bitmap.o
28
size_t page_size;
49
block-obj-y += write-threshold.o
29
/* How many uint32_t elements does each doorbell entry take. */
50
@@ -XXX,XX +XXX,XX @@ rbd.o-cflags := $(RBD_CFLAGS)
30
size_t doorbell_scale;
51
rbd.o-libs := $(RBD_LIBS)
31
@@ -XXX,XX +XXX,XX @@ static QemuOptsList runtime_opts = {
52
gluster.o-cflags := $(GLUSTERFS_CFLAGS)
32
};
53
gluster.o-libs := $(GLUSTERFS_LIBS)
33
54
+vxhs.o-libs := $(VXHS_LIBS)
34
static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
55
ssh.o-cflags := $(LIBSSH2_CFLAGS)
35
- int nentries, int entry_bytes, Error **errp)
56
ssh.o-libs := $(LIBSSH2_LIBS)
36
+ unsigned nentries, size_t entry_bytes, Error **errp)
57
block-obj-$(if $(CONFIG_BZIP2),m,n) += dmg-bz2.o
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);
58
diff --git a/block/trace-events b/block/trace-events
183
diff --git a/block/trace-events b/block/trace-events
59
index XXXXXXX..XXXXXXX 100644
184
index XXXXXXX..XXXXXXX 100644
60
--- a/block/trace-events
185
--- a/block/trace-events
61
+++ b/block/trace-events
186
+++ b/block/trace-events
62
@@ -XXX,XX +XXX,XX @@ qed_aio_write_data(void *s, void *acb, int ret, uint64_t offset, size_t len) "s
187
@@ -XXX,XX +XXX,XX @@ qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s
63
qed_aio_write_prefill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64
188
# nvme.c
64
qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64
189
nvme_controller_capability_raw(uint64_t value) "0x%08"PRIx64
65
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"
190
nvme_controller_capability(const char *desc, uint64_t value) "%s: %"PRIu64
66
+
191
-nvme_kick(void *s, int queue) "s %p queue %d"
67
+# block/vxhs.c
192
+nvme_kick(void *s, unsigned q_index) "s %p q #%u"
68
+vxhs_iio_callback(int error) "ctx is NULL: error %d"
193
nvme_dma_flush_queue_wait(void *s) "s %p"
69
+vxhs_iio_callback_chnfail(int err, int error) "QNIO channel failed, no i/o %d, %d"
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"
70
+vxhs_iio_callback_unknwn(int opcode, int err) "unexpected opcode %d, errno %d"
195
-nvme_process_completion(void *s, int index, int inflight) "s %p queue %d inflight %d"
71
+vxhs_aio_rw_invalid(int req) "Invalid I/O request iodir %d"
196
-nvme_process_completion_queue_plugged(void *s, int index) "s %p queue %d"
72
+vxhs_aio_rw_ioerr(char *guid, int iodir, uint64_t size, uint64_t off, void *acb, int ret, int err) "IO ERROR (vDisk %s) FOR : Read/Write = %d size = %lu offset = %lu ACB = %p. Error = %d, errno = %d"
197
-nvme_complete_command(void *s, int index, int cid) "s %p queue %d cid %d"
73
+vxhs_get_vdisk_stat_err(char *guid, int ret, int err) "vDisk (%s) stat ioctl failed, ret = %d, errno = %d"
198
-nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d"
74
+vxhs_get_vdisk_stat(char *vdisk_guid, uint64_t vdisk_size) "vDisk %s stat ioctl returned size %lu"
199
+nvme_process_completion(void *s, unsigned q_index, int inflight) "s %p q #%u inflight %d"
75
+vxhs_complete_aio(void *acb, uint64_t ret) "aio failed acb %p ret %ld"
200
+nvme_process_completion_queue_plugged(void *s, unsigned q_index) "s %p q #%u"
76
+vxhs_parse_uri_filename(const char *filename) "URI passed via bdrv_parse_filename %s"
201
+nvme_complete_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d"
77
+vxhs_open_vdiskid(const char *vdisk_id) "Opening vdisk-id %s"
202
+nvme_submit_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d"
78
+vxhs_open_hostinfo(char *of_vsa_addr, int port) "Adding host %s:%d to BDRVVXHSState"
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"
79
+vxhs_open_iio_open(const char *host) "Failed to connect to storage agent on host %s"
204
nvme_handle_event(void *s) "s %p"
80
+vxhs_parse_uri_hostinfo(char *host, int port) "Host: IP %s, Port %d"
205
nvme_poll_queue(void *s, unsigned q_index) "s %p q #%u"
81
+vxhs_close(char *vdisk_guid) "Closing vdisk %s"
82
+vxhs_get_creds(const char *cacert, const char *client_key, const char *client_cert) "cacert %s, client_key %s, client_cert %s"
83
diff --git a/block/vxhs.c b/block/vxhs.c
84
new file mode 100644
85
index XXXXXXX..XXXXXXX
86
--- /dev/null
87
+++ b/block/vxhs.c
88
@@ -XXX,XX +XXX,XX @@
89
+/*
90
+ * QEMU Block driver for Veritas HyperScale (VxHS)
91
+ *
92
+ * Copyright (c) 2017 Veritas Technologies LLC.
93
+ *
94
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
95
+ * See the COPYING file in the top-level directory.
96
+ *
97
+ */
98
+
99
+#include "qemu/osdep.h"
100
+#include <qnio/qnio_api.h>
101
+#include <sys/param.h>
102
+#include "block/block_int.h"
103
+#include "qapi/qmp/qerror.h"
104
+#include "qapi/qmp/qdict.h"
105
+#include "qapi/qmp/qstring.h"
106
+#include "trace.h"
107
+#include "qemu/uri.h"
108
+#include "qapi/error.h"
109
+#include "qemu/uuid.h"
110
+#include "crypto/tlscredsx509.h"
111
+
112
+#define VXHS_OPT_FILENAME "filename"
113
+#define VXHS_OPT_VDISK_ID "vdisk-id"
114
+#define VXHS_OPT_SERVER "server"
115
+#define VXHS_OPT_HOST "host"
116
+#define VXHS_OPT_PORT "port"
117
+
118
+/* Only accessed under QEMU global mutex */
119
+static uint32_t vxhs_ref;
120
+
121
+typedef enum {
122
+ VDISK_AIO_READ,
123
+ VDISK_AIO_WRITE,
124
+} VDISKAIOCmd;
125
+
126
+/*
127
+ * HyperScale AIO callbacks structure
128
+ */
129
+typedef struct VXHSAIOCB {
130
+ BlockAIOCB common;
131
+ int err;
132
+} VXHSAIOCB;
133
+
134
+typedef struct VXHSvDiskHostsInfo {
135
+ void *dev_handle; /* Device handle */
136
+ char *host; /* Host name or IP */
137
+ int port; /* Host's port number */
138
+} VXHSvDiskHostsInfo;
139
+
140
+/*
141
+ * Structure per vDisk maintained for state
142
+ */
143
+typedef struct BDRVVXHSState {
144
+ VXHSvDiskHostsInfo vdisk_hostinfo; /* Per host info */
145
+ char *vdisk_guid;
146
+ char *tlscredsid; /* tlscredsid */
147
+} BDRVVXHSState;
148
+
149
+static void vxhs_complete_aio_bh(void *opaque)
150
+{
151
+ VXHSAIOCB *acb = opaque;
152
+ BlockCompletionFunc *cb = acb->common.cb;
153
+ void *cb_opaque = acb->common.opaque;
154
+ int ret = 0;
155
+
156
+ if (acb->err != 0) {
157
+ trace_vxhs_complete_aio(acb, acb->err);
158
+ ret = (-EIO);
159
+ }
160
+
161
+ qemu_aio_unref(acb);
162
+ cb(cb_opaque, ret);
163
+}
164
+
165
+/*
166
+ * Called from a libqnio thread
167
+ */
168
+static void vxhs_iio_callback(void *ctx, uint32_t opcode, uint32_t error)
169
+{
170
+ VXHSAIOCB *acb = NULL;
171
+
172
+ switch (opcode) {
173
+ case IRP_READ_REQUEST:
174
+ case IRP_WRITE_REQUEST:
175
+
176
+ /*
177
+ * ctx is VXHSAIOCB*
178
+ * ctx is NULL if error is QNIOERROR_CHANNEL_HUP
179
+ */
180
+ if (ctx) {
181
+ acb = ctx;
182
+ } else {
183
+ trace_vxhs_iio_callback(error);
184
+ goto out;
185
+ }
186
+
187
+ if (error) {
188
+ if (!acb->err) {
189
+ acb->err = error;
190
+ }
191
+ trace_vxhs_iio_callback(error);
192
+ }
193
+
194
+ aio_bh_schedule_oneshot(bdrv_get_aio_context(acb->common.bs),
195
+ vxhs_complete_aio_bh, acb);
196
+ break;
197
+
198
+ default:
199
+ if (error == QNIOERROR_HUP) {
200
+ /*
201
+ * Channel failed, spontaneous notification,
202
+ * not in response to I/O
203
+ */
204
+ trace_vxhs_iio_callback_chnfail(error, errno);
205
+ } else {
206
+ trace_vxhs_iio_callback_unknwn(opcode, error);
207
+ }
208
+ break;
209
+ }
210
+out:
211
+ return;
212
+}
213
+
214
+static QemuOptsList runtime_opts = {
215
+ .name = "vxhs",
216
+ .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
217
+ .desc = {
218
+ {
219
+ .name = VXHS_OPT_FILENAME,
220
+ .type = QEMU_OPT_STRING,
221
+ .help = "URI to the Veritas HyperScale image",
222
+ },
223
+ {
224
+ .name = VXHS_OPT_VDISK_ID,
225
+ .type = QEMU_OPT_STRING,
226
+ .help = "UUID of the VxHS vdisk",
227
+ },
228
+ {
229
+ .name = "tls-creds",
230
+ .type = QEMU_OPT_STRING,
231
+ .help = "ID of the TLS/SSL credentials to use",
232
+ },
233
+ { /* end of list */ }
234
+ },
235
+};
236
+
237
+static QemuOptsList runtime_tcp_opts = {
238
+ .name = "vxhs_tcp",
239
+ .head = QTAILQ_HEAD_INITIALIZER(runtime_tcp_opts.head),
240
+ .desc = {
241
+ {
242
+ .name = VXHS_OPT_HOST,
243
+ .type = QEMU_OPT_STRING,
244
+ .help = "host address (ipv4 addresses)",
245
+ },
246
+ {
247
+ .name = VXHS_OPT_PORT,
248
+ .type = QEMU_OPT_NUMBER,
249
+ .help = "port number on which VxHSD is listening (default 9999)",
250
+ .def_value_str = "9999"
251
+ },
252
+ { /* end of list */ }
253
+ },
254
+};
255
+
256
+/*
257
+ * Parse incoming URI and populate *options with the host
258
+ * and device information
259
+ */
260
+static int vxhs_parse_uri(const char *filename, QDict *options)
261
+{
262
+ URI *uri = NULL;
263
+ char *port;
264
+ int ret = 0;
265
+
266
+ trace_vxhs_parse_uri_filename(filename);
267
+ uri = uri_parse(filename);
268
+ if (!uri || !uri->server || !uri->path) {
269
+ uri_free(uri);
270
+ return -EINVAL;
271
+ }
272
+
273
+ qdict_put(options, VXHS_OPT_SERVER".host", qstring_from_str(uri->server));
274
+
275
+ if (uri->port) {
276
+ port = g_strdup_printf("%d", uri->port);
277
+ qdict_put(options, VXHS_OPT_SERVER".port", qstring_from_str(port));
278
+ g_free(port);
279
+ }
280
+
281
+ qdict_put(options, "vdisk-id", qstring_from_str(uri->path));
282
+
283
+ trace_vxhs_parse_uri_hostinfo(uri->server, uri->port);
284
+ uri_free(uri);
285
+
286
+ return ret;
287
+}
288
+
289
+static void vxhs_parse_filename(const char *filename, QDict *options,
290
+ Error **errp)
291
+{
292
+ if (qdict_haskey(options, "vdisk-id") || qdict_haskey(options, "server")) {
293
+ error_setg(errp, "vdisk-id/server and a file name may not be specified "
294
+ "at the same time");
295
+ return;
296
+ }
297
+
298
+ if (strstr(filename, "://")) {
299
+ int ret = vxhs_parse_uri(filename, options);
300
+ if (ret < 0) {
301
+ error_setg(errp, "Invalid URI. URI should be of the form "
302
+ " vxhs://<host_ip>:<port>/<vdisk-id>");
303
+ }
304
+ }
305
+}
306
+
307
+static int vxhs_init_and_ref(void)
308
+{
309
+ if (vxhs_ref++ == 0) {
310
+ if (iio_init(QNIO_VERSION, vxhs_iio_callback)) {
311
+ return -ENODEV;
312
+ }
313
+ }
314
+ return 0;
315
+}
316
+
317
+static void vxhs_unref(void)
318
+{
319
+ if (--vxhs_ref == 0) {
320
+ iio_fini();
321
+ }
322
+}
323
+
324
+static void vxhs_get_tls_creds(const char *id, char **cacert,
325
+ char **key, char **cert, Error **errp)
326
+{
327
+ Object *obj;
328
+ QCryptoTLSCreds *creds;
329
+ QCryptoTLSCredsX509 *creds_x509;
330
+
331
+ obj = object_resolve_path_component(
332
+ object_get_objects_root(), id);
333
+
334
+ if (!obj) {
335
+ error_setg(errp, "No TLS credentials with id '%s'",
336
+ id);
337
+ return;
338
+ }
339
+
340
+ creds_x509 = (QCryptoTLSCredsX509 *)
341
+ object_dynamic_cast(obj, TYPE_QCRYPTO_TLS_CREDS_X509);
342
+
343
+ if (!creds_x509) {
344
+ error_setg(errp, "Object with id '%s' is not TLS credentials",
345
+ id);
346
+ return;
347
+ }
348
+
349
+ creds = &creds_x509->parent_obj;
350
+
351
+ if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {
352
+ error_setg(errp,
353
+ "Expecting TLS credentials with a client endpoint");
354
+ return;
355
+ }
356
+
357
+ /*
358
+ * Get the cacert, client_cert and client_key file names.
359
+ */
360
+ if (!creds->dir) {
361
+ error_setg(errp, "TLS object missing 'dir' property value");
362
+ return;
363
+ }
364
+
365
+ *cacert = g_strdup_printf("%s/%s", creds->dir,
366
+ QCRYPTO_TLS_CREDS_X509_CA_CERT);
367
+ *cert = g_strdup_printf("%s/%s", creds->dir,
368
+ QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
369
+ *key = g_strdup_printf("%s/%s", creds->dir,
370
+ QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
371
+}
372
+
373
+static int vxhs_open(BlockDriverState *bs, QDict *options,
374
+ int bdrv_flags, Error **errp)
375
+{
376
+ BDRVVXHSState *s = bs->opaque;
377
+ void *dev_handlep;
378
+ QDict *backing_options = NULL;
379
+ QemuOpts *opts = NULL;
380
+ QemuOpts *tcp_opts = NULL;
381
+ char *of_vsa_addr = NULL;
382
+ Error *local_err = NULL;
383
+ const char *vdisk_id_opt;
384
+ const char *server_host_opt;
385
+ int ret = 0;
386
+ char *cacert = NULL;
387
+ char *client_key = NULL;
388
+ char *client_cert = NULL;
389
+
390
+ ret = vxhs_init_and_ref();
391
+ if (ret < 0) {
392
+ ret = -EINVAL;
393
+ goto out;
394
+ }
395
+
396
+ /* Create opts info from runtime_opts and runtime_tcp_opts list */
397
+ opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
398
+ tcp_opts = qemu_opts_create(&runtime_tcp_opts, NULL, 0, &error_abort);
399
+
400
+ qemu_opts_absorb_qdict(opts, options, &local_err);
401
+ if (local_err) {
402
+ ret = -EINVAL;
403
+ goto out;
404
+ }
405
+
406
+ /* vdisk-id is the disk UUID */
407
+ vdisk_id_opt = qemu_opt_get(opts, VXHS_OPT_VDISK_ID);
408
+ if (!vdisk_id_opt) {
409
+ error_setg(&local_err, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID);
410
+ ret = -EINVAL;
411
+ goto out;
412
+ }
413
+
414
+ /* vdisk-id may contain a leading '/' */
415
+ if (strlen(vdisk_id_opt) > UUID_FMT_LEN + 1) {
416
+ error_setg(&local_err, "vdisk-id cannot be more than %d characters",
417
+ UUID_FMT_LEN);
418
+ ret = -EINVAL;
419
+ goto out;
420
+ }
421
+
422
+ s->vdisk_guid = g_strdup(vdisk_id_opt);
423
+ trace_vxhs_open_vdiskid(vdisk_id_opt);
424
+
425
+ /* get the 'server.' arguments */
426
+ qdict_extract_subqdict(options, &backing_options, VXHS_OPT_SERVER".");
427
+
428
+ qemu_opts_absorb_qdict(tcp_opts, backing_options, &local_err);
429
+ if (local_err != NULL) {
430
+ ret = -EINVAL;
431
+ goto out;
432
+ }
433
+
434
+ server_host_opt = qemu_opt_get(tcp_opts, VXHS_OPT_HOST);
435
+ if (!server_host_opt) {
436
+ error_setg(&local_err, QERR_MISSING_PARAMETER,
437
+ VXHS_OPT_SERVER"."VXHS_OPT_HOST);
438
+ ret = -EINVAL;
439
+ goto out;
440
+ }
441
+
442
+ if (strlen(server_host_opt) > MAXHOSTNAMELEN) {
443
+ error_setg(&local_err, "server.host cannot be more than %d characters",
444
+ MAXHOSTNAMELEN);
445
+ ret = -EINVAL;
446
+ goto out;
447
+ }
448
+
449
+ /* check if we got tls-creds via the --object argument */
450
+ s->tlscredsid = g_strdup(qemu_opt_get(opts, "tls-creds"));
451
+ if (s->tlscredsid) {
452
+ vxhs_get_tls_creds(s->tlscredsid, &cacert, &client_key,
453
+ &client_cert, &local_err);
454
+ if (local_err != NULL) {
455
+ ret = -EINVAL;
456
+ goto out;
457
+ }
458
+ trace_vxhs_get_creds(cacert, client_key, client_cert);
459
+ }
460
+
461
+ s->vdisk_hostinfo.host = g_strdup(server_host_opt);
462
+ s->vdisk_hostinfo.port = g_ascii_strtoll(qemu_opt_get(tcp_opts,
463
+ VXHS_OPT_PORT),
464
+ NULL, 0);
465
+
466
+ trace_vxhs_open_hostinfo(s->vdisk_hostinfo.host,
467
+ s->vdisk_hostinfo.port);
468
+
469
+ of_vsa_addr = g_strdup_printf("of://%s:%d",
470
+ s->vdisk_hostinfo.host,
471
+ s->vdisk_hostinfo.port);
472
+
473
+ /*
474
+ * Open qnio channel to storage agent if not opened before
475
+ */
476
+ dev_handlep = iio_open(of_vsa_addr, s->vdisk_guid, 0,
477
+ cacert, client_key, client_cert);
478
+ if (dev_handlep == NULL) {
479
+ trace_vxhs_open_iio_open(of_vsa_addr);
480
+ ret = -ENODEV;
481
+ goto out;
482
+ }
483
+ s->vdisk_hostinfo.dev_handle = dev_handlep;
484
+
485
+out:
486
+ g_free(of_vsa_addr);
487
+ QDECREF(backing_options);
488
+ qemu_opts_del(tcp_opts);
489
+ qemu_opts_del(opts);
490
+ g_free(cacert);
491
+ g_free(client_key);
492
+ g_free(client_cert);
493
+
494
+ if (ret < 0) {
495
+ vxhs_unref();
496
+ error_propagate(errp, local_err);
497
+ g_free(s->vdisk_hostinfo.host);
498
+ g_free(s->vdisk_guid);
499
+ g_free(s->tlscredsid);
500
+ s->vdisk_guid = NULL;
501
+ }
502
+
503
+ return ret;
504
+}
505
+
506
+static const AIOCBInfo vxhs_aiocb_info = {
507
+ .aiocb_size = sizeof(VXHSAIOCB)
508
+};
509
+
510
+/*
511
+ * This allocates QEMU-VXHS callback for each IO
512
+ * and is passed to QNIO. When QNIO completes the work,
513
+ * it will be passed back through the callback.
514
+ */
515
+static BlockAIOCB *vxhs_aio_rw(BlockDriverState *bs, int64_t sector_num,
516
+ QEMUIOVector *qiov, int nb_sectors,
517
+ BlockCompletionFunc *cb, void *opaque,
518
+ VDISKAIOCmd iodir)
519
+{
520
+ VXHSAIOCB *acb = NULL;
521
+ BDRVVXHSState *s = bs->opaque;
522
+ size_t size;
523
+ uint64_t offset;
524
+ int iio_flags = 0;
525
+ int ret = 0;
526
+ void *dev_handle = s->vdisk_hostinfo.dev_handle;
527
+
528
+ offset = sector_num * BDRV_SECTOR_SIZE;
529
+ size = nb_sectors * BDRV_SECTOR_SIZE;
530
+ acb = qemu_aio_get(&vxhs_aiocb_info, bs, cb, opaque);
531
+
532
+ /*
533
+ * Initialize VXHSAIOCB.
534
+ */
535
+ acb->err = 0;
536
+
537
+ iio_flags = IIO_FLAG_ASYNC;
538
+
539
+ switch (iodir) {
540
+ case VDISK_AIO_WRITE:
541
+ ret = iio_writev(dev_handle, acb, qiov->iov, qiov->niov,
542
+ offset, (uint64_t)size, iio_flags);
543
+ break;
544
+ case VDISK_AIO_READ:
545
+ ret = iio_readv(dev_handle, acb, qiov->iov, qiov->niov,
546
+ offset, (uint64_t)size, iio_flags);
547
+ break;
548
+ default:
549
+ trace_vxhs_aio_rw_invalid(iodir);
550
+ goto errout;
551
+ }
552
+
553
+ if (ret != 0) {
554
+ trace_vxhs_aio_rw_ioerr(s->vdisk_guid, iodir, size, offset,
555
+ acb, ret, errno);
556
+ goto errout;
557
+ }
558
+ return &acb->common;
559
+
560
+errout:
561
+ qemu_aio_unref(acb);
562
+ return NULL;
563
+}
564
+
565
+static BlockAIOCB *vxhs_aio_readv(BlockDriverState *bs,
566
+ int64_t sector_num, QEMUIOVector *qiov,
567
+ int nb_sectors,
568
+ BlockCompletionFunc *cb, void *opaque)
569
+{
570
+ return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors, cb,
571
+ opaque, VDISK_AIO_READ);
572
+}
573
+
574
+static BlockAIOCB *vxhs_aio_writev(BlockDriverState *bs,
575
+ int64_t sector_num, QEMUIOVector *qiov,
576
+ int nb_sectors,
577
+ BlockCompletionFunc *cb, void *opaque)
578
+{
579
+ return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors,
580
+ cb, opaque, VDISK_AIO_WRITE);
581
+}
582
+
583
+static void vxhs_close(BlockDriverState *bs)
584
+{
585
+ BDRVVXHSState *s = bs->opaque;
586
+
587
+ trace_vxhs_close(s->vdisk_guid);
588
+
589
+ g_free(s->vdisk_guid);
590
+ s->vdisk_guid = NULL;
591
+
592
+ /*
593
+ * Close vDisk device
594
+ */
595
+ if (s->vdisk_hostinfo.dev_handle) {
596
+ iio_close(s->vdisk_hostinfo.dev_handle);
597
+ s->vdisk_hostinfo.dev_handle = NULL;
598
+ }
599
+
600
+ vxhs_unref();
601
+
602
+ /*
603
+ * Free the dynamically allocated host string etc
604
+ */
605
+ g_free(s->vdisk_hostinfo.host);
606
+ g_free(s->tlscredsid);
607
+ s->tlscredsid = NULL;
608
+ s->vdisk_hostinfo.host = NULL;
609
+ s->vdisk_hostinfo.port = 0;
610
+}
611
+
612
+static int64_t vxhs_get_vdisk_stat(BDRVVXHSState *s)
613
+{
614
+ int64_t vdisk_size = -1;
615
+ int ret = 0;
616
+ void *dev_handle = s->vdisk_hostinfo.dev_handle;
617
+
618
+ ret = iio_ioctl(dev_handle, IOR_VDISK_STAT, &vdisk_size, 0);
619
+ if (ret < 0) {
620
+ trace_vxhs_get_vdisk_stat_err(s->vdisk_guid, ret, errno);
621
+ return -EIO;
622
+ }
623
+
624
+ trace_vxhs_get_vdisk_stat(s->vdisk_guid, vdisk_size);
625
+ return vdisk_size;
626
+}
627
+
628
+/*
629
+ * Returns the size of vDisk in bytes. This is required
630
+ * by QEMU block upper block layer so that it is visible
631
+ * to guest.
632
+ */
633
+static int64_t vxhs_getlength(BlockDriverState *bs)
634
+{
635
+ BDRVVXHSState *s = bs->opaque;
636
+ int64_t vdisk_size;
637
+
638
+ vdisk_size = vxhs_get_vdisk_stat(s);
639
+ if (vdisk_size < 0) {
640
+ return -EIO;
641
+ }
642
+
643
+ return vdisk_size;
644
+}
645
+
646
+static BlockDriver bdrv_vxhs = {
647
+ .format_name = "vxhs",
648
+ .protocol_name = "vxhs",
649
+ .instance_size = sizeof(BDRVVXHSState),
650
+ .bdrv_file_open = vxhs_open,
651
+ .bdrv_parse_filename = vxhs_parse_filename,
652
+ .bdrv_close = vxhs_close,
653
+ .bdrv_getlength = vxhs_getlength,
654
+ .bdrv_aio_readv = vxhs_aio_readv,
655
+ .bdrv_aio_writev = vxhs_aio_writev,
656
+};
657
+
658
+static void bdrv_vxhs_init(void)
659
+{
660
+ bdrv_register(&bdrv_vxhs);
661
+}
662
+
663
+block_init(bdrv_vxhs_init);
664
diff --git a/configure b/configure
665
index XXXXXXX..XXXXXXX 100755
666
--- a/configure
667
+++ b/configure
668
@@ -XXX,XX +XXX,XX @@ numa=""
669
tcmalloc="no"
670
jemalloc="no"
671
replication="yes"
672
+vxhs=""
673
674
supported_cpu="no"
675
supported_os="no"
676
@@ -XXX,XX +XXX,XX @@ for opt do
677
;;
678
--enable-replication) replication="yes"
679
;;
680
+ --disable-vxhs) vxhs="no"
681
+ ;;
682
+ --enable-vxhs) vxhs="yes"
683
+ ;;
684
*)
685
echo "ERROR: unknown option $opt"
686
echo "Try '$0 --help' for more information"
687
@@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available:
688
xfsctl xfsctl support
689
qom-cast-debug cast debugging support
690
tools build qemu-io, qemu-nbd and qemu-image tools
691
+ vxhs Veritas HyperScale vDisk backend support
692
693
NOTE: The object files are built at the place where configure is launched
694
EOF
695
@@ -XXX,XX +XXX,XX @@ if compile_prog "" "" ; then
696
fi
697
698
##########################################
699
+# Veritas HyperScale block driver VxHS
700
+# Check if libvxhs is installed
701
+
702
+if test "$vxhs" != "no" ; then
703
+ cat > $TMPC <<EOF
704
+#include <stdint.h>
705
+#include <qnio/qnio_api.h>
706
+
707
+void *vxhs_callback;
708
+
709
+int main(void) {
710
+ iio_init(QNIO_VERSION, vxhs_callback);
711
+ return 0;
712
+}
713
+EOF
714
+ vxhs_libs="-lvxhs -lssl"
715
+ if compile_prog "" "$vxhs_libs" ; then
716
+ vxhs=yes
717
+ else
718
+ if test "$vxhs" = "yes" ; then
719
+ feature_not_found "vxhs block device" "Install libvxhs See github"
720
+ fi
721
+ vxhs=no
722
+ fi
723
+fi
724
+
725
+##########################################
726
# End of CC checks
727
# After here, no more $cc or $ld runs
728
729
@@ -XXX,XX +XXX,XX @@ echo "tcmalloc support $tcmalloc"
730
echo "jemalloc support $jemalloc"
731
echo "avx2 optimization $avx2_opt"
732
echo "replication support $replication"
733
+echo "VxHS block device $vxhs"
734
735
if test "$sdl_too_old" = "yes"; then
736
echo "-> Your SDL version is too old - please upgrade to have SDL support"
737
@@ -XXX,XX +XXX,XX @@ if test "$pthread_setname_np" = "yes" ; then
738
echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
739
fi
740
741
+if test "$vxhs" = "yes" ; then
742
+ echo "CONFIG_VXHS=y" >> $config_host_mak
743
+ echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
744
+fi
745
+
746
if test "$tcg_interpreter" = "yes"; then
747
QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
748
elif test "$ARCH" = "sparc64" ; then
749
diff --git a/qapi/block-core.json b/qapi/block-core.json
750
index XXXXXXX..XXXXXXX 100644
751
--- a/qapi/block-core.json
752
+++ b/qapi/block-core.json
753
@@ -XXX,XX +XXX,XX @@
754
#
755
# Drivers that are supported in block device operations.
756
#
757
+# @vxhs: Since 2.10
758
+#
759
# Since: 2.9
760
##
761
{ 'enum': 'BlockdevDriver',
762
@@ -XXX,XX +XXX,XX @@
763
'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs',
764
'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed',
765
'quorum', 'raw', 'rbd', 'replication', 'sheepdog', 'ssh',
766
- 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
767
+ 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] }
768
769
##
770
# @BlockdevOptionsFile:
771
@@ -XXX,XX +XXX,XX @@
772
'data': { '*offset': 'int', '*size': 'int' } }
773
774
##
775
+# @BlockdevOptionsVxHS:
776
+#
777
+# Driver specific block device options for VxHS
778
+#
779
+# @vdisk-id: UUID of VxHS volume
780
+# @server: vxhs server IP, port
781
+# @tls-creds: TLS credentials ID
782
+#
783
+# Since: 2.10
784
+##
785
+{ 'struct': 'BlockdevOptionsVxHS',
786
+ 'data': { 'vdisk-id': 'str',
787
+ 'server': 'InetSocketAddressBase',
788
+ '*tls-creds': 'str' } }
789
+
790
+##
791
# @BlockdevOptions:
792
#
793
# Options for creating a block device. Many options are available for all
794
@@ -XXX,XX +XXX,XX @@
795
'vhdx': 'BlockdevOptionsGenericFormat',
796
'vmdk': 'BlockdevOptionsGenericCOWFormat',
797
'vpc': 'BlockdevOptionsGenericFormat',
798
- 'vvfat': 'BlockdevOptionsVVFAT'
799
+ 'vvfat': 'BlockdevOptionsVVFAT',
800
+ 'vxhs': 'BlockdevOptionsVxHS'
801
} }
802
803
##
804
--
206
--
805
2.9.3
207
2.28.0
806
208
807
diff view generated by jsdifflib
1
This adds support for reopen in rbd, for changing between r/w and r/o.
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Note, that this is only a flag change, but we will block a change from
3
Just for consistency, following the example documented since
4
r/o to r/w if we are using an RBD internal snapshot.
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.
5
8
9
Tested-by: Eric Auger <eric.auger@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Signed-off-by: Jeff Cody <jcody@redhat.com>
12
Message-id: 20201029093306.1063879-11-philmd@redhat.com
8
Reviewed-by: John Snow <jsnow@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Message-id: d4e87539167ec6527d44c97b164eabcccf96e4f3.1491597120.git.jcody@redhat.com
14
Tested-by: Eric Auger <eric.auger@redhat.com>
10
---
15
---
11
block/rbd.c | 21 +++++++++++++++++++++
16
block/nvme.c | 12 +++++++-----
12
1 file changed, 21 insertions(+)
17
1 file changed, 7 insertions(+), 5 deletions(-)
13
18
14
diff --git a/block/rbd.c b/block/rbd.c
19
diff --git a/block/nvme.c b/block/nvme.c
15
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
16
--- a/block/rbd.c
21
--- a/block/nvme.c
17
+++ b/block/rbd.c
22
+++ b/block/nvme.c
18
@@ -XXX,XX +XXX,XX @@ failed_opts:
23
@@ -XXX,XX +XXX,XX @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q,
19
return r;
24
return ret;
20
}
25
}
21
26
22
+
27
-static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
23
+/* Since RBD is currently always opened R/W via the API,
28
+/* Returns true on success, false on failure. */
24
+ * we just need to check if we are using a snapshot or not, in
29
+static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
25
+ * order to determine if we will allow it to be R/W */
30
{
26
+static int qemu_rbd_reopen_prepare(BDRVReopenState *state,
31
BDRVNVMeState *s = bs->opaque;
27
+ BlockReopenQueue *queue, Error **errp)
32
+ bool ret = false;
28
+{
33
union {
29
+ BDRVRBDState *s = state->bs->opaque;
34
NvmeIdCtrl ctrl;
30
+ int ret = 0;
35
NvmeIdNs ns;
31
+
36
@@ -XXX,XX +XXX,XX @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
32
+ if (s->snap && state->flags & BDRV_O_RDWR) {
37
goto out;
33
+ error_setg(errp,
38
}
34
+ "Cannot change node '%s' to r/w when using RBD snapshot",
39
35
+ bdrv_get_device_or_node_name(state->bs));
40
+ ret = true;
36
+ ret = -EINVAL;
41
s->blkshift = lbaf->ds;
37
+ }
42
out:
43
qemu_vfio_dma_unmap(s->vfio, id);
44
qemu_vfree(id);
38
+
45
+
39
+ return ret;
46
+ return ret;
40
+}
47
}
41
+
48
42
static void qemu_rbd_close(BlockDriverState *bs)
49
static bool nvme_poll_queue(NVMeQueuePair *q)
43
{
50
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
44
BDRVRBDState *s = bs->opaque;
51
uint64_t cap;
45
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_rbd = {
52
uint64_t timeout_ms;
46
.bdrv_parse_filename = qemu_rbd_parse_filename,
53
uint64_t deadline, now;
47
.bdrv_file_open = qemu_rbd_open,
54
- Error *local_err = NULL;
48
.bdrv_close = qemu_rbd_close,
55
volatile NvmeBar *regs = NULL;
49
+ .bdrv_reopen_prepare = qemu_rbd_reopen_prepare,
56
50
.bdrv_create = qemu_rbd_create,
57
qemu_co_mutex_init(&s->dma_map_lock);
51
.bdrv_has_zero_init = bdrv_has_zero_init_1,
58
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
52
.bdrv_get_info = qemu_rbd_getinfo,
59
&s->irq_notifier[MSIX_SHARED_IRQ_IDX],
60
false, nvme_handle_event, nvme_poll_cb);
61
62
- nvme_identify(bs, namespace, &local_err);
63
- if (local_err) {
64
- error_propagate(errp, local_err);
65
+ if (!nvme_identify(bs, namespace, errp)) {
66
ret = -EIO;
67
goto out;
68
}
53
--
69
--
54
2.9.3
70
2.28.0
55
71
56
diff view generated by jsdifflib
1
We have a helper wrapper for checking for the BDS read_only flag,
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
add a helper wrapper to set the read_only flag as well.
2
3
Just for consistency, following the example documented since
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().
3
8
4
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
10
Tested-by: Eric Auger <eric.auger@redhat.com>
6
Reviewed-by: John Snow <jsnow@redhat.com>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Message-id: 9b18972d05f5fa2ac16c014f0af98d680553048d.1491597120.git.jcody@redhat.com
12
Message-id: 20201029093306.1063879-12-philmd@redhat.com
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Tested-by: Eric Auger <eric.auger@redhat.com>
8
---
15
---
9
block.c | 5 +++++
16
block/nvme.c | 16 +++++++---------
10
block/bochs.c | 2 +-
17
1 file changed, 7 insertions(+), 9 deletions(-)
11
block/cloop.c | 2 +-
12
block/dmg.c | 2 +-
13
block/rbd.c | 2 +-
14
block/vvfat.c | 4 ++--
15
include/block/block.h | 1 +
16
7 files changed, 12 insertions(+), 6 deletions(-)
17
18
18
diff --git a/block.c b/block.c
19
diff --git a/block/nvme.c b/block/nvme.c
19
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
20
--- a/block.c
21
--- a/block/nvme.c
21
+++ b/block.c
22
+++ b/block/nvme.c
22
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
23
@@ -XXX,XX +XXX,XX @@ static QemuOptsList runtime_opts = {
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;
23
}
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;
24
}
47
}
25
48
26
+void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
49
static void nvme_free_queue_pair(NVMeQueuePair *q)
27
+{
50
@@ -XXX,XX +XXX,XX @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
28
+ bs->read_only = read_only;
51
Error **errp)
29
+}
52
{
30
+
53
int i, r;
31
void bdrv_get_full_backing_filename_from_filename(const char *backed,
54
- Error *local_err = NULL;
32
const char *backing,
55
NVMeQueuePair *q;
33
char *dest, size_t sz,
56
uint64_t prp_list_iova;
34
diff --git a/block/bochs.c b/block/bochs.c
57
35
index XXXXXXX..XXXXXXX 100644
58
@@ -XXX,XX +XXX,XX @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
36
--- a/block/bochs.c
59
req->prp_list_iova = prp_list_iova + i * s->page_size;
37
+++ b/block/bochs.c
38
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
39
return -EINVAL;
40
}
60
}
41
61
42
- bs->read_only = true; /* no write support yet */
62
- nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err);
43
+ bdrv_set_read_only(bs, true); /* no write support yet */
63
- if (local_err) {
44
64
- error_propagate(errp, local_err);
45
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
65
+ if (!nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, errp)) {
46
if (ret < 0) {
66
goto fail;
47
diff --git a/block/cloop.c b/block/cloop.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/block/cloop.c
50
+++ b/block/cloop.c
51
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
52
return -EINVAL;
53
}
67
}
54
68
q->sq.doorbell = &s->doorbells[idx * s->doorbell_scale].sq_tail;
55
- bs->read_only = true;
69
56
+ bdrv_set_read_only(bs, true);
70
- nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err);
57
71
- if (local_err) {
58
/* read header */
72
- error_propagate(errp, local_err);
59
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
73
+ if (!nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, errp)) {
60
diff --git a/block/dmg.c b/block/dmg.c
74
goto fail;
61
index XXXXXXX..XXXXXXX 100644
62
--- a/block/dmg.c
63
+++ b/block/dmg.c
64
@@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
65
}
75
}
66
76
q->cq.doorbell = &s->doorbells[idx * s->doorbell_scale].cq_head;
67
block_module_load_one("dmg-bz2");
68
- bs->read_only = true;
69
+ bdrv_set_read_only(bs, true);
70
71
s->n_chunks = 0;
72
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
73
diff --git a/block/rbd.c b/block/rbd.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/block/rbd.c
76
+++ b/block/rbd.c
77
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
78
goto failed_open;
79
}
80
81
- bs->read_only = (s->snap != NULL);
82
+ bdrv_set_read_only(bs, (s->snap != NULL));
83
84
qemu_opts_del(opts);
85
return 0;
86
diff --git a/block/vvfat.c b/block/vvfat.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/block/vvfat.c
89
+++ b/block/vvfat.c
90
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
91
s->current_cluster=0xffffffff;
92
93
/* read only is the default for safety */
94
- bs->read_only = true;
95
+ bdrv_set_read_only(bs, true);
96
s->qcow = NULL;
97
s->qcow_filename = NULL;
98
s->fat2 = NULL;
99
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
100
if (ret < 0) {
101
goto fail;
102
}
103
- bs->read_only = false;
104
+ bdrv_set_read_only(bs, false);
105
}
106
107
bs->total_sectors = cyls * heads * secs;
108
diff --git a/include/block/block.h b/include/block/block.h
109
index XXXXXXX..XXXXXXX 100644
110
--- a/include/block/block.h
111
+++ b/include/block/block.h
112
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
113
int64_t sector_num, int nb_sectors, int *pnum);
114
115
bool bdrv_is_read_only(BlockDriverState *bs);
116
+void bdrv_set_read_only(BlockDriverState *bs, bool read_only);
117
bool bdrv_is_sg(BlockDriverState *bs);
118
bool bdrv_is_inserted(BlockDriverState *bs);
119
int bdrv_media_changed(BlockDriverState *bs);
120
--
77
--
121
2.9.3
78
2.28.0
122
79
123
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
The protocol VXHS does not support image creation. Some tests expect
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
to be able to create images through the protocol. Exclude VXHS from
3
these tests.
4
2
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
3
From the specification chapter 3.1.8 "AQA - Admin Queue Attributes"
4
the Admin Submission Queue Size field is a 0’s based value:
5
6
Admin Submission Queue Size (ASQS):
7
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>
6
---
25
---
7
tests/qemu-iotests/017 | 1 +
26
block/nvme.c | 6 +++---
8
tests/qemu-iotests/020 | 1 +
27
1 file changed, 3 insertions(+), 3 deletions(-)
9
tests/qemu-iotests/029 | 1 +
10
tests/qemu-iotests/073 | 1 +
11
tests/qemu-iotests/114 | 1 +
12
tests/qemu-iotests/130 | 1 +
13
tests/qemu-iotests/134 | 1 +
14
tests/qemu-iotests/156 | 1 +
15
tests/qemu-iotests/158 | 1 +
16
9 files changed, 9 insertions(+)
17
28
18
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
29
diff --git a/block/nvme.c b/block/nvme.c
19
index XXXXXXX..XXXXXXX 100755
30
index XXXXXXX..XXXXXXX 100644
20
--- a/tests/qemu-iotests/017
31
--- a/block/nvme.c
21
+++ b/tests/qemu-iotests/017
32
+++ b/block/nvme.c
22
@@ -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,
23
# Any format supporting backing files
34
goto out;
24
_supported_fmt qcow qcow2 vmdk qed
35
}
25
_supported_proto generic
36
s->queue_count = 1;
26
+_unsupported_proto vxhs
37
- QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000);
27
_supported_os Linux
38
- regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << AQA_ACQS_SHIFT) |
28
_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
39
- (NVME_QUEUE_SIZE << AQA_ASQS_SHIFT));
29
40
+ QEMU_BUILD_BUG_ON((NVME_QUEUE_SIZE - 1) & 0xF000);
30
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
41
+ regs->aqa = cpu_to_le32(((NVME_QUEUE_SIZE - 1) << AQA_ACQS_SHIFT) |
31
index XXXXXXX..XXXXXXX 100755
42
+ ((NVME_QUEUE_SIZE - 1) << AQA_ASQS_SHIFT));
32
--- a/tests/qemu-iotests/020
43
regs->asq = cpu_to_le64(s->queues[INDEX_ADMIN]->sq.iova);
33
+++ b/tests/qemu-iotests/020
44
regs->acq = cpu_to_le64(s->queues[INDEX_ADMIN]->cq.iova);
34
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
35
# Any format supporting backing files
36
_supported_fmt qcow qcow2 vmdk qed
37
_supported_proto generic
38
+_unsupported_proto vxhs
39
_supported_os Linux
40
_unsupported_imgopts "subformat=monolithicFlat" \
41
"subformat=twoGbMaxExtentFlat" \
42
diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029
43
index XXXXXXX..XXXXXXX 100755
44
--- a/tests/qemu-iotests/029
45
+++ b/tests/qemu-iotests/029
46
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
47
# Any format supporting intenal snapshots
48
_supported_fmt qcow2
49
_supported_proto generic
50
+_unsupported_proto vxhs
51
_supported_os Linux
52
# Internal snapshots are (currently) impossible with refcount_bits=1
53
_unsupported_imgopts 'refcount_bits=1[^0-9]'
54
diff --git a/tests/qemu-iotests/073 b/tests/qemu-iotests/073
55
index XXXXXXX..XXXXXXX 100755
56
--- a/tests/qemu-iotests/073
57
+++ b/tests/qemu-iotests/073
58
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
59
60
_supported_fmt qcow2
61
_supported_proto generic
62
+_unsupported_proto vxhs
63
_supported_os Linux
64
65
CLUSTER_SIZE=64k
66
diff --git a/tests/qemu-iotests/114 b/tests/qemu-iotests/114
67
index XXXXXXX..XXXXXXX 100755
68
--- a/tests/qemu-iotests/114
69
+++ b/tests/qemu-iotests/114
70
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
71
72
_supported_fmt qcow2
73
_supported_proto generic
74
+_unsupported_proto vxhs
75
_supported_os Linux
76
77
78
diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130
79
index XXXXXXX..XXXXXXX 100755
80
--- a/tests/qemu-iotests/130
81
+++ b/tests/qemu-iotests/130
82
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
83
84
_supported_fmt qcow2
85
_supported_proto generic
86
+_unsupported_proto vxhs
87
_supported_os Linux
88
89
qemu_comm_method="monitor"
90
diff --git a/tests/qemu-iotests/134 b/tests/qemu-iotests/134
91
index XXXXXXX..XXXXXXX 100755
92
--- a/tests/qemu-iotests/134
93
+++ b/tests/qemu-iotests/134
94
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
95
96
_supported_fmt qcow2
97
_supported_proto generic
98
+_unsupported_proto vxhs
99
_supported_os Linux
100
101
102
diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156
103
index XXXXXXX..XXXXXXX 100755
104
--- a/tests/qemu-iotests/156
105
+++ b/tests/qemu-iotests/156
106
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
107
108
_supported_fmt qcow2 qed
109
_supported_proto generic
110
+_unsupported_proto vxhs
111
_supported_os Linux
112
113
# Create source disk
114
diff --git a/tests/qemu-iotests/158 b/tests/qemu-iotests/158
115
index XXXXXXX..XXXXXXX 100755
116
--- a/tests/qemu-iotests/158
117
+++ b/tests/qemu-iotests/158
118
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
119
120
_supported_fmt qcow2
121
_supported_proto generic
122
+_unsupported_proto vxhs
123
_supported_os Linux
124
125
45
126
--
46
--
127
2.9.3
47
2.28.0
128
48
129
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
1
From: Ashish Mittal <ashmit602@gmail.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
These changes use a vxhs test server that is a part of the following
3
As all commands use the ADMIN queue, it is pointless to pass
4
repository:
4
it as argument each time. Remove the argument, and rename the
5
https://github.com/VeritasHyperScale/libqnio.git
5
function as nvme_admin_cmd_sync() to make this new behavior
6
clearer.
6
7
7
Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.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>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: Jeff Cody <jcody@redhat.com>
12
Message-id: 20201029093306.1063879-17-philmd@redhat.com
10
Signed-off-by: Jeff Cody <jcody@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Message-id: 1491277689-24949-3-git-send-email-Ashish.Mittal@veritas.com
14
Tested-by: Eric Auger <eric.auger@redhat.com>
12
---
15
---
13
tests/qemu-iotests/common | 6 ++++++
16
block/nvme.c | 19 ++++++++++---------
14
tests/qemu-iotests/common.config | 13 +++++++++++++
17
1 file changed, 10 insertions(+), 9 deletions(-)
15
tests/qemu-iotests/common.filter | 1 +
16
tests/qemu-iotests/common.rc | 19 +++++++++++++++++++
17
4 files changed, 39 insertions(+)
18
18
19
diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
19
diff --git a/block/nvme.c b/block/nvme.c
20
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
21
--- a/tests/qemu-iotests/common
21
--- a/block/nvme.c
22
+++ b/tests/qemu-iotests/common
22
+++ b/block/nvme.c
23
@@ -XXX,XX +XXX,XX @@ check options
23
@@ -XXX,XX +XXX,XX @@ static void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req,
24
-ssh test ssh
24
qemu_mutex_unlock(&q->lock);
25
-nfs test nfs
25
}
26
-luks test luks
26
27
+ -vxhs test vxhs
27
-static void nvme_cmd_sync_cb(void *opaque, int ret)
28
-xdiff graphical mode diff
28
+static void nvme_admin_cmd_sync_cb(void *opaque, int ret)
29
-nocache use O_DIRECT on backing file
30
-misalign misalign memory allocations
31
@@ -XXX,XX +XXX,XX @@ testlist options
32
xpand=false
33
;;
34
35
+ -vxhs)
36
+ IMGPROTO=vxhs
37
+ xpand=false
38
+ ;;
39
+
40
-ssh)
41
IMGPROTO=ssh
42
xpand=false
43
diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
44
index XXXXXXX..XXXXXXX 100644
45
--- a/tests/qemu-iotests/common.config
46
+++ b/tests/qemu-iotests/common.config
47
@@ -XXX,XX +XXX,XX @@ if [ -z "$QEMU_NBD_PROG" ]; then
48
export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
49
fi
50
51
+if [ -z "$QEMU_VXHS_PROG" ]; then
52
+ export QEMU_VXHS_PROG="`set_prog_path qnio_server`"
53
+fi
54
+
55
_qemu_wrapper()
56
{
29
{
57
(
30
int *pret = opaque;
58
@@ -XXX,XX +XXX,XX @@ _qemu_nbd_wrapper()
31
*pret = ret;
59
)
32
aio_wait_kick();
60
}
33
}
61
34
62
+_qemu_vxhs_wrapper()
35
-static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q,
63
+{
36
- NvmeCmd *cmd)
64
+ (
37
+static int nvme_admin_cmd_sync(BlockDriverState *bs, NvmeCmd *cmd)
65
+ echo $BASHPID > "${TEST_DIR}/qemu-vxhs.pid"
38
{
66
+ exec "$QEMU_VXHS_PROG" $QEMU_VXHS_OPTIONS "$@"
39
+ BDRVNVMeState *s = bs->opaque;
67
+ )
40
+ NVMeQueuePair *q = s->queues[INDEX_ADMIN];
68
+}
41
AioContext *aio_context = bdrv_get_aio_context(bs);
69
+
42
NVMeRequest *req;
70
export QEMU=_qemu_wrapper
43
int ret = -EINPROGRESS;
71
export QEMU_IMG=_qemu_img_wrapper
44
@@ -XXX,XX +XXX,XX @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q,
72
export QEMU_IO=_qemu_io_wrapper
45
if (!req) {
73
export QEMU_NBD=_qemu_nbd_wrapper
46
return -EBUSY;
74
+export QEMU_VXHS=_qemu_vxhs_wrapper
47
}
75
48
- nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret);
76
QEMU_IMG_EXTRA_ARGS=
49
+ nvme_submit_command(q, req, cmd, nvme_admin_cmd_sync_cb, &ret);
77
if [ "$IMGOPTSSYNTAX" = "true" ]; then
50
78
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
51
AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS);
79
index XXXXXXX..XXXXXXX 100644
52
return ret;
80
--- a/tests/qemu-iotests/common.filter
53
@@ -XXX,XX +XXX,XX @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
81
+++ b/tests/qemu-iotests/common.filter
54
82
@@ -XXX,XX +XXX,XX @@ _filter_img_info()
55
memset(id, 0, sizeof(*id));
83
-e "s#$TEST_DIR#TEST_DIR#g" \
56
cmd.dptr.prp1 = cpu_to_le64(iova);
84
-e "s#$IMGFMT#IMGFMT#g" \
57
- if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
85
-e 's#nbd://127.0.0.1:10810$#TEST_DIR/t.IMGFMT#g' \
58
+ if (nvme_admin_cmd_sync(bs, &cmd)) {
86
+ -e 's#json.*vdisk-id.*vxhs"}}#TEST_DIR/t.IMGFMT#' \
59
error_setg(errp, "Failed to identify controller");
87
-e "/encrypted: yes/d" \
60
goto out;
88
-e "/cluster_size: [0-9]\\+/d" \
61
}
89
-e "/table_size: [0-9]\\+/d" \
62
@@ -XXX,XX +XXX,XX @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
90
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
63
memset(id, 0, sizeof(*id));
91
index XXXXXXX..XXXXXXX 100644
64
cmd.cdw10 = 0;
92
--- a/tests/qemu-iotests/common.rc
65
cmd.nsid = cpu_to_le32(namespace);
93
+++ b/tests/qemu-iotests/common.rc
66
- if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
94
@@ -XXX,XX +XXX,XX @@ else
67
+ if (nvme_admin_cmd_sync(bs, &cmd)) {
95
elif [ "$IMGPROTO" = "nfs" ]; then
68
error_setg(errp, "Failed to identify namespace");
96
TEST_DIR="nfs://127.0.0.1/$TEST_DIR"
69
goto out;
97
TEST_IMG=$TEST_DIR/t.$IMGFMT
70
}
98
+ elif [ "$IMGPROTO" = "vxhs" ]; then
71
@@ -XXX,XX +XXX,XX @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
99
+ TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
72
.cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n),
100
+ TEST_IMG="vxhs://127.0.0.1:9999/t.$IMGFMT"
73
.cdw11 = cpu_to_le32(NVME_CQ_IEN | NVME_CQ_PC),
101
else
74
};
102
TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
75
- if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
103
fi
76
+ if (nvme_admin_cmd_sync(bs, &cmd)) {
104
@@ -XXX,XX +XXX,XX @@ _make_test_img()
77
error_setg(errp, "Failed to create CQ io queue [%u]", n);
105
eval "$QEMU_NBD -v -t -b 127.0.0.1 -p 10810 -f $IMGFMT $TEST_IMG_FILE >/dev/null &"
78
goto out_error;
106
sleep 1 # FIXME: qemu-nbd needs to be listening before we continue
79
}
107
fi
80
@@ -XXX,XX +XXX,XX @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
108
+
81
.cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n),
109
+ # Start QNIO server on image directory for vxhs protocol
82
.cdw11 = cpu_to_le32(NVME_SQ_PC | (n << 16)),
110
+ if [ $IMGPROTO = "vxhs" ]; then
83
};
111
+ eval "$QEMU_VXHS -d $TEST_DIR > /dev/null &"
84
- if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
112
+ sleep 1 # Wait for server to come up.
85
+ if (nvme_admin_cmd_sync(bs, &cmd)) {
113
+ fi
86
error_setg(errp, "Failed to create SQ io queue [%u]", n);
114
}
87
goto out_error;
115
88
}
116
_rm_test_img()
89
@@ -XXX,XX +XXX,XX @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable,
117
@@ -XXX,XX +XXX,XX @@ _cleanup_test_img()
90
.cdw11 = cpu_to_le32(enable ? 0x01 : 0x00),
118
fi
91
};
119
rm -f "$TEST_IMG_FILE"
92
120
;;
93
- ret = nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd);
121
+ vxhs)
94
+ ret = nvme_admin_cmd_sync(bs, &cmd);
122
+ if [ -f "${TEST_DIR}/qemu-vxhs.pid" ]; then
95
if (ret) {
123
+ local QEMU_VXHS_PID
96
error_setg(errp, "Failed to configure NVMe write cache");
124
+ read QEMU_VXHS_PID < "${TEST_DIR}/qemu-vxhs.pid"
97
}
125
+ kill ${QEMU_VXHS_PID} >/dev/null 2>&1
126
+ rm -f "${TEST_DIR}/qemu-vxhs.pid"
127
+ fi
128
+ rm -f "$TEST_IMG_FILE"
129
+ ;;
130
+
131
file)
132
_rm_test_img "$TEST_DIR/t.$IMGFMT"
133
_rm_test_img "$TEST_DIR/t.$IMGFMT.orig"
134
--
98
--
135
2.9.3
99
2.28.0
136
100
137
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
Signed-off-by: Jeff Cody <jcody@redhat.com>
1
From: Eric Auger <eric.auger@redhat.com>
2
3
Make sure iov's va and size are properly aligned on the
4
host page size.
5
6
Signed-off-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
3
Reviewed-by: John Snow <jsnow@redhat.com>
9
Tested-by: Eric Auger <eric.auger@redhat.com>
4
Message-id: 00aed7ffdd7be4b9ed9ce1007d50028a72b34ebe.1491597120.git.jcody@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>
5
---
14
---
6
block.c | 14 ++++++++------
15
block/nvme.c | 14 ++++++++------
7
1 file changed, 8 insertions(+), 6 deletions(-)
16
1 file changed, 8 insertions(+), 6 deletions(-)
8
17
9
diff --git a/block.c b/block.c
18
diff --git a/block/nvme.c b/block/nvme.c
10
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
11
--- a/block.c
20
--- a/block/nvme.c
12
+++ b/block.c
21
+++ b/block/nvme.c
13
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
22
@@ -XXX,XX +XXX,XX @@ static coroutine_fn int nvme_cmd_map_qiov(BlockDriverState *bs, NvmeCmd *cmd,
14
BlockDriver *drv;
23
for (i = 0; i < qiov->niov; ++i) {
15
QemuOpts *opts;
24
bool retry = true;
16
const char *value;
25
uint64_t iova;
17
+ bool read_only;
26
+ size_t len = QEMU_ALIGN_UP(qiov->iov[i].iov_len,
18
27
+ qemu_real_host_page_size);
19
assert(reopen_state != NULL);
28
try_map:
20
assert(reopen_state->bs->drv != NULL);
29
r = qemu_vfio_dma_map(s->vfio,
21
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
30
qiov->iov[i].iov_base,
22
qdict_put(reopen_state->options, "driver", qstring_from_str(value));
31
- qiov->iov[i].iov_len,
32
- true, &iova);
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,
23
}
59
}
24
60
s->stats.unaligned_accesses++;
25
- /* if we are to stay read-only, do not allow permission change
61
trace_nvme_prw_buffered(s, offset, bytes, qiov->niov, is_write);
26
- * to r/w */
62
- buf = qemu_try_memalign(s->page_size, bytes);
27
- if (!(reopen_state->bs->open_flags & BDRV_O_ALLOW_RDWR) &&
63
+ buf = qemu_try_memalign(qemu_real_host_page_size, len);
28
- reopen_state->flags & BDRV_O_RDWR) {
64
29
- error_setg(errp, "Node '%s' is read only",
65
if (!buf) {
30
- bdrv_get_device_or_node_name(reopen_state->bs));
66
return -ENOMEM;
31
+ /* If we are to stay read-only, do not allow permission change
32
+ * to r/w. Attempting to set to r/w may fail if either BDRV_O_ALLOW_RDWR is
33
+ * not set, or if the BDS still has copy_on_read enabled */
34
+ read_only = !(reopen_state->flags & BDRV_O_RDWR);
35
+ ret = bdrv_can_set_read_only(reopen_state->bs, read_only, &local_err);
36
+ if (local_err) {
37
+ error_propagate(errp, local_err);
38
goto error;
39
}
40
41
--
67
--
42
2.9.3
68
2.28.0
43
69
44
diff view generated by jsdifflib
1
Update 'clientname' to be 'user', which tracks better with both
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
the QAPI and rados variable naming.
3
2
4
Update 'name' to be 'image_name', as it indicates the rbd image.
3
qemu_vfio_pci_map_bar() calls mmap(), and mmap(2) states:
5
Naming it 'image' would have been ideal, but we are using that for
6
the rados_image_t value returned by rbd_open().
7
4
5
'offset' must be a multiple of the page size as returned
6
by sysconf(_SC_PAGE_SIZE).
7
8
In commit f68453237b9 we started to use an offset of 4K which
9
broke this contract on Aarch64 arch.
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>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
16
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Signed-off-by: Jeff Cody <jcody@redhat.com>
17
Tested-by: Eric Auger <eric.auger@redhat.com>
10
Reviewed-by: John Snow <jsnow@redhat.com>
18
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: b7ec1fb2e1cf36f9b6911631447a5b0422590b7d.1491597120.git.jcody@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>
12
---
22
---
13
block/rbd.c | 33 +++++++++++++++++----------------
23
block/nvme.c | 11 +++++++----
14
1 file changed, 17 insertions(+), 16 deletions(-)
24
1 file changed, 7 insertions(+), 4 deletions(-)
15
25
16
diff --git a/block/rbd.c b/block/rbd.c
26
diff --git a/block/nvme.c b/block/nvme.c
17
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
18
--- a/block/rbd.c
28
--- a/block/nvme.c
19
+++ b/block/rbd.c
29
+++ b/block/nvme.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVRBDState {
30
@@ -XXX,XX +XXX,XX @@ typedef struct {
21
rados_t cluster;
31
struct BDRVNVMeState {
22
rados_ioctx_t io_ctx;
32
AioContext *aio_context;
23
rbd_image_t image;
33
QEMUVFIOState *vfio;
24
- char *name;
34
+ void *bar0_wo_map;
25
+ char *image_name;
35
/* Memory mapped registers */
26
char *snap;
36
volatile struct {
27
} BDRVRBDState;
37
uint32_t sq_tail;
28
38
@@ -XXX,XX +XXX,XX @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
29
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
39
}
30
int64_t bytes = 0;
31
int64_t objsize;
32
int obj_order = 0;
33
- const char *pool, *name, *conf, *clientname, *keypairs;
34
+ const char *pool, *image_name, *conf, *user, *keypairs;
35
const char *secretid;
36
rados_t cluster;
37
rados_ioctx_t io_ctx;
38
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
39
*/
40
pool = qdict_get_try_str(options, "pool");
41
conf = qdict_get_try_str(options, "conf");
42
- clientname = qdict_get_try_str(options, "user");
43
- name = qdict_get_try_str(options, "image");
44
+ user = qdict_get_try_str(options, "user");
45
+ image_name = qdict_get_try_str(options, "image");
46
keypairs = qdict_get_try_str(options, "=keyvalue-pairs");
47
48
- ret = rados_create(&cluster, clientname);
49
+ ret = rados_create(&cluster, user);
50
if (ret < 0) {
51
error_setg_errno(errp, -ret, "error initializing");
52
goto exit;
53
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
54
goto shutdown;
55
}
40
}
56
41
57
- ret = rbd_create(io_ctx, name, bytes, &obj_order);
42
- s->doorbells = qemu_vfio_pci_map_bar(s->vfio, 0, sizeof(NvmeBar),
58
+ ret = rbd_create(io_ctx, image_name, bytes, &obj_order);
43
- NVME_DOORBELL_SIZE, PROT_WRITE, errp);
59
if (ret < 0) {
44
+ s->bar0_wo_map = qemu_vfio_pci_map_bar(s->vfio, 0, 0,
60
error_setg_errno(errp, -ret, "error rbd create");
45
+ sizeof(NvmeBar) + NVME_DOORBELL_SIZE,
61
}
46
+ PROT_WRITE, errp);
62
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
47
+ s->doorbells = (void *)((uintptr_t)s->bar0_wo_map + sizeof(NvmeBar));
63
Error **errp)
48
if (!s->doorbells) {
64
{
49
ret = -EINVAL;
65
BDRVRBDState *s = bs->opaque;
50
goto out;
66
- const char *pool, *snap, *conf, *clientname, *name, *keypairs;
51
@@ -XXX,XX +XXX,XX @@ static void nvme_close(BlockDriverState *bs)
67
+ const char *pool, *snap, *conf, *user, *image_name, *keypairs;
52
&s->irq_notifier[MSIX_SHARED_IRQ_IDX],
68
const char *secretid;
53
false, NULL, NULL);
69
QemuOpts *opts;
54
event_notifier_cleanup(&s->irq_notifier[MSIX_SHARED_IRQ_IDX]);
70
Error *local_err = NULL;
55
- qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->doorbells,
71
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
56
- sizeof(NvmeBar), NVME_DOORBELL_SIZE);
72
pool = qemu_opt_get(opts, "pool");
57
+ qemu_vfio_pci_unmap_bar(s->vfio, 0, s->bar0_wo_map,
73
conf = qemu_opt_get(opts, "conf");
58
+ 0, sizeof(NvmeBar) + NVME_DOORBELL_SIZE);
74
snap = qemu_opt_get(opts, "snapshot");
59
qemu_vfio_close(s->vfio);
75
- clientname = qemu_opt_get(opts, "user");
60
76
- name = qemu_opt_get(opts, "image");
61
g_free(s->device);
77
+ user = qemu_opt_get(opts, "user");
78
+ image_name = qemu_opt_get(opts, "image");
79
keypairs = qemu_opt_get(opts, "=keyvalue-pairs");
80
81
- if (!pool || !name) {
82
+ if (!pool || !image_name) {
83
error_setg(errp, "Parameters 'pool' and 'image' are required");
84
r = -EINVAL;
85
goto failed_opts;
86
}
87
88
- r = rados_create(&s->cluster, clientname);
89
+ r = rados_create(&s->cluster, user);
90
if (r < 0) {
91
error_setg_errno(errp, -r, "error initializing");
92
goto failed_opts;
93
}
94
95
s->snap = g_strdup(snap);
96
- s->name = g_strdup(name);
97
+ s->image_name = g_strdup(image_name);
98
99
/* try default location when conf=NULL, but ignore failure */
100
r = rados_conf_read_file(s->cluster, conf);
101
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
102
}
103
104
/* rbd_open is always r/w */
105
- r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
106
+ r = rbd_open(s->io_ctx, s->image_name, &s->image, s->snap);
107
if (r < 0) {
108
- error_setg_errno(errp, -r, "error reading header from %s", s->name);
109
+ error_setg_errno(errp, -r, "error reading header from %s",
110
+ s->image_name);
111
goto failed_open;
112
}
113
114
@@ -XXX,XX +XXX,XX @@ failed_open:
115
failed_shutdown:
116
rados_shutdown(s->cluster);
117
g_free(s->snap);
118
- g_free(s->name);
119
+ g_free(s->image_name);
120
failed_opts:
121
qemu_opts_del(opts);
122
g_free(mon_host);
123
@@ -XXX,XX +XXX,XX @@ static void qemu_rbd_close(BlockDriverState *bs)
124
rbd_close(s->image);
125
rados_ioctx_destroy(s->io_ctx);
126
g_free(s->snap);
127
- g_free(s->name);
128
+ g_free(s->image_name);
129
rados_shutdown(s->cluster);
130
}
131
132
--
62
--
133
2.9.3
63
2.28.0
134
64
135
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
The Completion Queue Command Identifier is a 16-bit value,
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
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 void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req,
24
assert(!req->cb);
25
req->cb = cb;
26
req->opaque = opaque;
27
- cmd->cid = cpu_to_le32(req->cid);
28
+ cmd->cid = cpu_to_le16(req->cid);
29
30
trace_nvme_submit_command(q->s, q->index, req->cid);
31
nvme_trace_command(cmd);
32
--
33
2.28.0
34
diff view generated by jsdifflib
1
Introduce check function for setting read_only flags. Will return < 0 on
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
error, with appropriate Error value set. Does not alter any flags.
3
2
4
Signed-off-by: Jeff Cody <jcody@redhat.com>
3
Change the confuse "VFIO IOMMU check failed" error message by
4
the explicit "VFIO IOMMU Type1 is not supported" once.
5
6
Example on POWER:
7
8
$ qemu-system-ppc64 -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw
9
qemu-system-ppc64: -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw: VFIO IOMMU Type1 is not supported
10
11
Suggested-by: Alex Williamson <alex.williamson@redhat.com>
12
Reviewed-by: Fam Zheng <fam@euphon.net>
5
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Reviewed-by: John Snow <jsnow@redhat.com>
14
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Message-id: e2bba34ac3bc76a0c42adc390413f358ae0566e8.1491597120.git.jcody@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>
8
---
18
---
9
block.c | 14 +++++++++++++-
19
util/vfio-helpers.c | 2 +-
10
include/block/block.h | 1 +
20
1 file changed, 1 insertion(+), 1 deletion(-)
11
2 files changed, 14 insertions(+), 1 deletion(-)
12
21
13
diff --git a/block.c b/block.c
22
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
14
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
15
--- a/block.c
24
--- a/util/vfio-helpers.c
16
+++ b/block.c
25
+++ b/util/vfio-helpers.c
17
@@ -XXX,XX +XXX,XX @@ bool bdrv_is_read_only(BlockDriverState *bs)
26
@@ -XXX,XX +XXX,XX @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device,
18
return bs->read_only;
19
}
20
21
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
22
+int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
23
{
24
/* Do not set read_only if copy_on_read is enabled */
25
if (bs->copy_on_read && read_only) {
26
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
27
return -EPERM;
28
}
27
}
29
28
30
+ return 0;
29
if (!ioctl(s->container, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) {
31
+}
30
- error_setg_errno(errp, errno, "VFIO IOMMU check failed");
32
+
31
+ error_setg_errno(errp, errno, "VFIO IOMMU Type1 is not supported");
33
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
32
ret = -EINVAL;
34
+{
33
goto fail_container;
35
+ int ret = 0;
34
}
36
+
37
+ ret = bdrv_can_set_read_only(bs, read_only, errp);
38
+ if (ret < 0) {
39
+ return ret;
40
+ }
41
+
42
bs->read_only = read_only;
43
return 0;
44
}
45
diff --git a/include/block/block.h b/include/block/block.h
46
index XXXXXXX..XXXXXXX 100644
47
--- a/include/block/block.h
48
+++ b/include/block/block.h
49
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
50
int64_t sector_num, int nb_sectors, int *pnum);
51
52
bool bdrv_is_read_only(BlockDriverState *bs);
53
+int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
54
int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
55
bool bdrv_is_sg(BlockDriverState *bs);
56
bool bdrv_is_inserted(BlockDriverState *bs);
57
--
35
--
58
2.9.3
36
2.28.0
59
37
60
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
We sometime get kernel panic with some devices on Aarch64
4
hosts. Alex Williamson suggests it might be broken PCIe
5
root complex. Add trace event to record the latest I/O
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>
15
---
16
util/vfio-helpers.c | 8 ++++++++
17
util/trace-events | 2 ++
18
2 files changed, 10 insertions(+)
19
20
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/util/vfio-helpers.c
23
+++ b/util/vfio-helpers.c
24
@@ -XXX,XX +XXX,XX @@ static int qemu_vfio_pci_read_config(QEMUVFIOState *s, void *buf,
25
{
26
int ret;
27
28
+ trace_qemu_vfio_pci_read_config(buf, ofs, size,
29
+ s->config_region_info.offset,
30
+ s->config_region_info.size);
31
+ assert(QEMU_IS_ALIGNED(s->config_region_info.offset + ofs, size));
32
do {
33
ret = pread(s->device, buf, size, s->config_region_info.offset + ofs);
34
} while (ret == -1 && errno == EINTR);
35
@@ -XXX,XX +XXX,XX @@ static int qemu_vfio_pci_write_config(QEMUVFIOState *s, void *buf, int size, int
36
{
37
int ret;
38
39
+ trace_qemu_vfio_pci_write_config(buf, ofs, size,
40
+ s->config_region_info.offset,
41
+ s->config_region_info.size);
42
+ assert(QEMU_IS_ALIGNED(s->config_region_info.offset + ofs, size));
43
do {
44
ret = pwrite(s->device, buf, size, s->config_region_info.offset + ofs);
45
} while (ret == -1 && errno == EINTR);
46
diff --git a/util/trace-events b/util/trace-events
47
index XXXXXXX..XXXXXXX 100644
48
--- a/util/trace-events
49
+++ b/util/trace-events
50
@@ -XXX,XX +XXX,XX @@ qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova
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
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"
53
qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p"
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")"
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")"
56
--
57
2.28.0
58
diff view generated by jsdifflib
1
The BDRV_O_ALLOW_RDWR flag allows / prohibits the changing of
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
the BDS 'read_only' state, but there are a few places where it
3
is ignored. In the bdrv_set_read_only() helper, make sure to
4
honor the flag.
5
2
6
Signed-off-by: Jeff Cody <jcody@redhat.com>
3
For debug purpose, trace BAR regions info.
4
5
Reviewed-by: Fam Zheng <fam@euphon.net>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Reviewed-by: John Snow <jsnow@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Message-id: be2e5fb2d285cbece2b6d06bed54a6f56520d251.1491597120.git.jcody@redhat.com
8
Message-id: 20201103020733.2303148-4-philmd@redhat.com
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10
Tested-by: Eric Auger <eric.auger@redhat.com>
10
---
11
---
11
block.c | 7 +++++++
12
util/vfio-helpers.c | 8 ++++++++
12
1 file changed, 7 insertions(+)
13
util/trace-events | 1 +
14
2 files changed, 9 insertions(+)
13
15
14
diff --git a/block.c b/block.c
16
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/block.c
18
--- a/util/vfio-helpers.c
17
+++ b/block.c
19
+++ b/util/vfio-helpers.c
18
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
20
@@ -XXX,XX +XXX,XX @@ static inline void assert_bar_index_valid(QEMUVFIOState *s, int index)
19
return -EINVAL;
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;
20
}
31
}
21
32
+ barname = g_strdup_printf("bar[%d]", index);
22
+ /* Do not clear read_only if it is prohibited */
33
+ trace_qemu_vfio_region_info(barname, s->bar_region_info[index].offset,
23
+ if (!read_only && !(bs->open_flags & BDRV_O_ALLOW_RDWR)) {
34
+ s->bar_region_info[index].size,
24
+ error_setg(errp, "Node '%s' is read only",
35
+ s->bar_region_info[index].cap_offset);
25
+ bdrv_get_device_or_node_name(bs));
36
26
+ return -EPERM;
27
+ }
28
+
29
bs->read_only = read_only;
30
return 0;
37
return 0;
31
}
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
32
--
58
--
33
2.9.3
59
2.28.0
34
60
35
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
For debugging purpose, trace where a BAR is mapped.
4
5
Reviewed-by: Fam Zheng <fam@euphon.net>
6
Reviewed-by: Stefan Hajnoczi <stefanha@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>
11
---
12
util/vfio-helpers.c | 2 ++
13
util/trace-events | 1 +
14
2 files changed, 3 insertions(+)
15
16
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/util/vfio-helpers.c
19
+++ b/util/vfio-helpers.c
20
@@ -XXX,XX +XXX,XX @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index,
21
p = mmap(NULL, MIN(size, s->bar_region_info[index].size - offset),
22
prot, MAP_SHARED,
23
s->device, s->bar_region_info[index].offset + offset);
24
+ trace_qemu_vfio_pci_map_bar(index, s->bar_region_info[index].offset ,
25
+ size, offset, p);
26
if (p == MAP_FAILED) {
27
error_setg_errno(errp, errno, "Failed to map BAR region");
28
p = NULL;
29
diff --git a/util/trace-events b/util/trace-events
30
index XXXXXXX..XXXXXXX 100644
31
--- a/util/trace-events
32
+++ b/util/trace-events
33
@@ -XXX,XX +XXX,XX @@ qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p"
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"
38
--
39
2.28.0
40
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
For debugging purpose, trace where DMA regions are mapped.
4
5
Reviewed-by: Fam Zheng <fam@euphon.net>
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@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
---
12
util/vfio-helpers.c | 3 ++-
13
util/trace-events | 5 +++--
14
2 files changed, 5 insertions(+), 3 deletions(-)
15
16
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/util/vfio-helpers.c
19
+++ b/util/vfio-helpers.c
20
@@ -XXX,XX +XXX,XX @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size,
21
.vaddr = (uintptr_t)host,
22
.size = size,
23
};
24
- trace_qemu_vfio_do_mapping(s, host, size, iova);
25
+ trace_qemu_vfio_do_mapping(s, host, iova, size);
26
27
if (ioctl(s->container, VFIO_IOMMU_MAP_DMA, &dma_map)) {
28
error_report("VFIO_MAP_DMA failed: %s", strerror(errno));
29
@@ -XXX,XX +XXX,XX @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size,
30
}
31
}
32
}
33
+ trace_qemu_vfio_dma_mapped(s, host, iova0, size);
34
if (iova) {
35
*iova = iova0;
36
}
37
diff --git a/util/trace-events b/util/trace-events
38
index XXXXXXX..XXXXXXX 100644
39
--- a/util/trace-events
40
+++ b/util/trace-events
41
@@ -XXX,XX +XXX,XX @@ qemu_vfio_ram_block_added(void *s, void *p, size_t size) "s %p host %p size 0x%z
42
qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p size 0x%zx"
43
qemu_vfio_find_mapping(void *s, void *p) "s %p host %p"
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
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
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"
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"
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"
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"
50
qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p"
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")"
53
--
54
2.28.0
55
diff view generated by jsdifflib
1
A few block drivers will set the BDS read_only flag from their
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
.bdrv_open() function. This means the bs->read_only flag could
3
be set after we enable copy_on_read, as the BDRV_O_COPY_ON_READ
4
flag check occurs prior to the call to bdrv->bdrv_open().
5
2
6
This adds an error return to bdrv_set_read_only(), and an error will be
3
The QEMU_VFIO_DEBUG definition is only modifiable at build-time.
7
return if we try to set the BDS to read_only while copy_on_read is
4
Trace events can be enabled at run-time. As we prefer the latter,
8
enabled.
5
convert qemu_vfio_dump_mappings() to use trace events instead
6
of fprintf().
9
7
10
This patch also changes the behavior of vvfat. Before, vvfat could
8
Reviewed-by: Fam Zheng <fam@euphon.net>
11
override the drive 'readonly' flag with its own, internal 'rw' flag.
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>
14
---
15
util/vfio-helpers.c | 19 ++++---------------
16
util/trace-events | 1 +
17
2 files changed, 5 insertions(+), 15 deletions(-)
12
18
13
For instance, this -drive parameter would result in a writable image:
19
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
14
15
"-drive format=vvfat,dir=/tmp/vvfat,rw,if=virtio,readonly=on"
16
17
This is not correct. Now, attempting to use the above -drive parameter
18
will result in an error (i.e., 'rw' is incompatible with 'readonly=on').
19
20
Signed-off-by: Jeff Cody <jcody@redhat.com>
21
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
22
Reviewed-by: John Snow <jsnow@redhat.com>
23
Message-id: 0c5b4c1cc2c651471b131f21376dfd5ea24d2196.1491597120.git.jcody@redhat.com
24
---
25
block.c | 10 +++++++++-
26
block/bochs.c | 5 ++++-
27
block/cloop.c | 5 ++++-
28
block/dmg.c | 6 +++++-
29
block/rbd.c | 11 ++++++++++-
30
block/vvfat.c | 19 +++++++++++++++----
31
include/block/block.h | 2 +-
32
7 files changed, 48 insertions(+), 10 deletions(-)
33
34
diff --git a/block.c b/block.c
35
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
36
--- a/block.c
21
--- a/util/vfio-helpers.c
37
+++ b/block.c
22
+++ b/util/vfio-helpers.c
38
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
23
@@ -XXX,XX +XXX,XX @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp)
24
return s;
25
}
26
27
-static void qemu_vfio_dump_mapping(IOVAMapping *m)
28
-{
29
- if (QEMU_VFIO_DEBUG) {
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)
36
{
37
- int i;
38
-
39
- if (QEMU_VFIO_DEBUG) {
40
- printf("vfio mappings\n");
41
- for (i = 0; i < s->nr_mappings; ++i) {
42
- qemu_vfio_dump_mapping(&s->mappings[i]);
43
- }
44
+ for (int i = 0; i < s->nr_mappings; ++i) {
45
+ trace_qemu_vfio_dump_mapping(s->mappings[i].host,
46
+ s->mappings[i].iova,
47
+ s->mappings[i].size);
39
}
48
}
40
}
49
}
41
50
42
-void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
51
diff --git a/util/trace-events b/util/trace-events
43
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
44
{
45
+ /* Do not set read_only if copy_on_read is enabled */
46
+ if (bs->copy_on_read && read_only) {
47
+ error_setg(errp, "Can't set node '%s' to r/o with copy-on-read enabled",
48
+ bdrv_get_device_or_node_name(bs));
49
+ return -EINVAL;
50
+ }
51
+
52
bs->read_only = read_only;
53
+ return 0;
54
}
55
56
void bdrv_get_full_backing_filename_from_filename(const char *backed,
57
diff --git a/block/bochs.c b/block/bochs.c
58
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
59
--- a/block/bochs.c
53
--- a/util/trace-events
60
+++ b/block/bochs.c
54
+++ b/util/trace-events
61
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
55
@@ -XXX,XX +XXX,XX @@ qemu_mutex_unlock(void *mutex, const char *file, const int line) "released mutex
62
return -EINVAL;
56
qemu_vfio_dma_reset_temporary(void *s) "s %p"
63
}
57
qemu_vfio_ram_block_added(void *s, void *p, size_t size) "s %p host %p size 0x%zx"
64
58
qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p size 0x%zx"
65
- bdrv_set_read_only(bs, true); /* no write support yet */
59
+qemu_vfio_dump_mapping(void *host, uint64_t iova, size_t size) "vfio mapping %p to iova 0x%08" PRIx64 " size 0x%zx"
66
+ ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */
60
qemu_vfio_find_mapping(void *s, void *p) "s %p host %p"
67
+ if (ret < 0) {
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
68
+ return ret;
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"
69
+ }
70
71
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
72
if (ret < 0) {
73
diff --git a/block/cloop.c b/block/cloop.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/block/cloop.c
76
+++ b/block/cloop.c
77
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
78
return -EINVAL;
79
}
80
81
- bdrv_set_read_only(bs, true);
82
+ ret = bdrv_set_read_only(bs, true, errp);
83
+ if (ret < 0) {
84
+ return ret;
85
+ }
86
87
/* read header */
88
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
89
diff --git a/block/dmg.c b/block/dmg.c
90
index XXXXXXX..XXXXXXX 100644
91
--- a/block/dmg.c
92
+++ b/block/dmg.c
93
@@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
94
return -EINVAL;
95
}
96
97
+ ret = bdrv_set_read_only(bs, true, errp);
98
+ if (ret < 0) {
99
+ return ret;
100
+ }
101
+
102
block_module_load_one("dmg-bz2");
103
- bdrv_set_read_only(bs, true);
104
105
s->n_chunks = 0;
106
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
107
diff --git a/block/rbd.c b/block/rbd.c
108
index XXXXXXX..XXXXXXX 100644
109
--- a/block/rbd.c
110
+++ b/block/rbd.c
111
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
112
goto failed_shutdown;
113
}
114
115
+ /* rbd_open is always r/w */
116
r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
117
if (r < 0) {
118
error_setg_errno(errp, -r, "error reading header from %s", s->name);
119
goto failed_open;
120
}
121
122
- bdrv_set_read_only(bs, (s->snap != NULL));
123
+ /* If we are using an rbd snapshot, we must be r/o, otherwise
124
+ * leave as-is */
125
+ if (s->snap != NULL) {
126
+ r = bdrv_set_read_only(bs, true, &local_err);
127
+ if (r < 0) {
128
+ error_propagate(errp, local_err);
129
+ goto failed_open;
130
+ }
131
+ }
132
133
qemu_opts_del(opts);
134
return 0;
135
diff --git a/block/vvfat.c b/block/vvfat.c
136
index XXXXXXX..XXXXXXX 100644
137
--- a/block/vvfat.c
138
+++ b/block/vvfat.c
139
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
140
141
s->current_cluster=0xffffffff;
142
143
- /* read only is the default for safety */
144
- bdrv_set_read_only(bs, true);
145
s->qcow = NULL;
146
s->qcow_filename = NULL;
147
s->fat2 = NULL;
148
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
149
s->sector_count = cyls * heads * secs - (s->first_sectors_number - 1);
150
151
if (qemu_opt_get_bool(opts, "rw", false)) {
152
- ret = enable_write_target(bs, errp);
153
+ if (!bdrv_is_read_only(bs)) {
154
+ ret = enable_write_target(bs, errp);
155
+ if (ret < 0) {
156
+ goto fail;
157
+ }
158
+ } else {
159
+ ret = -EPERM;
160
+ error_setg(errp,
161
+ "Unable to set VVFAT to 'rw' when drive is read-only");
162
+ goto fail;
163
+ }
164
+ } else {
165
+ /* read only is the default for safety */
166
+ ret = bdrv_set_read_only(bs, true, &local_err);
167
if (ret < 0) {
168
+ error_propagate(errp, local_err);
169
goto fail;
170
}
171
- bdrv_set_read_only(bs, false);
172
}
173
174
bs->total_sectors = cyls * heads * secs;
175
diff --git a/include/block/block.h b/include/block/block.h
176
index XXXXXXX..XXXXXXX 100644
177
--- a/include/block/block.h
178
+++ b/include/block/block.h
179
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
180
int64_t sector_num, int nb_sectors, int *pnum);
181
182
bool bdrv_is_read_only(BlockDriverState *bs);
183
-void bdrv_set_read_only(BlockDriverState *bs, bool read_only);
184
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
185
bool bdrv_is_sg(BlockDriverState *bs);
186
bool bdrv_is_inserted(BlockDriverState *bs);
187
int bdrv_media_changed(BlockDriverState *bs);
188
--
63
--
189
2.9.3
64
2.28.0
190
65
191
diff view generated by jsdifflib
1
For the tests that use the common.qemu functions for running a QEMU
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
process, _cleanup_qemu must be called in the exit function.
3
2
4
If it is not, if the qemu process aborts, then not all of the droppings
3
mmap(2) states:
5
are cleaned up (e.g. pidfile, fifos).
6
4
7
This updates those tests that did not have a cleanup in qemu-iotests.
5
'offset' must be a multiple of the page size as returned
6
by sysconf(_SC_PAGE_SIZE).
8
7
9
(I swapped spaces for tabs in test 102 as well)
8
Add an assertion to be sure we don't break this contract.
10
9
11
Reported-by: Eric Blake <eblake@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Reviewed-by: Eric Blake <eblake@redhat.com>
11
Message-id: 20201103020733.2303148-8-philmd@redhat.com
13
Signed-off-by: Jeff Cody <jcody@redhat.com>
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Message-id: d59c2f6ad6c1da8b9b3c7f357c94a7122ccfc55a.1492544096.git.jcody@redhat.com
13
Tested-by: Eric Auger <eric.auger@redhat.com>
15
---
14
---
16
tests/qemu-iotests/028 | 1 +
15
util/vfio-helpers.c | 1 +
17
tests/qemu-iotests/094 | 11 ++++++++---
16
1 file changed, 1 insertion(+)
18
tests/qemu-iotests/102 | 5 +++--
19
tests/qemu-iotests/109 | 1 +
20
tests/qemu-iotests/117 | 1 +
21
tests/qemu-iotests/130 | 1 +
22
tests/qemu-iotests/140 | 1 +
23
tests/qemu-iotests/141 | 1 +
24
tests/qemu-iotests/143 | 1 +
25
tests/qemu-iotests/156 | 1 +
26
10 files changed, 19 insertions(+), 5 deletions(-)
27
17
28
diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028
18
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
29
index XXXXXXX..XXXXXXX 100755
19
index XXXXXXX..XXXXXXX 100644
30
--- a/tests/qemu-iotests/028
20
--- a/util/vfio-helpers.c
31
+++ b/tests/qemu-iotests/028
21
+++ b/util/vfio-helpers.c
32
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
22
@@ -XXX,XX +XXX,XX @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index,
33
23
Error **errp)
34
_cleanup()
35
{
24
{
36
+ _cleanup_qemu
25
void *p;
37
rm -f "${TEST_IMG}.copy"
26
+ assert(QEMU_IS_ALIGNED(offset, qemu_real_host_page_size));
38
_cleanup_test_img
27
assert_bar_index_valid(s, index);
39
}
28
p = mmap(NULL, MIN(size, s->bar_region_info[index].size - offset),
40
diff --git a/tests/qemu-iotests/094 b/tests/qemu-iotests/094
29
prot, MAP_SHARED,
41
index XXXXXXX..XXXXXXX 100755
42
--- a/tests/qemu-iotests/094
43
+++ b/tests/qemu-iotests/094
44
@@ -XXX,XX +XXX,XX @@ echo "QA output created by $seq"
45
here="$PWD"
46
status=1    # failure is the default!
47
48
-trap "exit \$status" 0 1 2 3 15
49
+_cleanup()
50
+{
51
+ _cleanup_qemu
52
+ _cleanup_test_img
53
+ rm -f "$TEST_DIR/source.$IMGFMT"
54
+}
55
+
56
+trap "_cleanup; exit \$status" 0 1 2 3 15
57
58
# get standard environment, filters and checks
59
. ./common.rc
60
@@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $QEMU_HANDLE \
61
62
wait=1 _cleanup_qemu
63
64
-_cleanup_test_img
65
-rm -f "$TEST_DIR/source.$IMGFMT"
66
67
# success, all done
68
echo '*** done'
69
diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102
70
index XXXXXXX..XXXXXXX 100755
71
--- a/tests/qemu-iotests/102
72
+++ b/tests/qemu-iotests/102
73
@@ -XXX,XX +XXX,XX @@ seq=$(basename $0)
74
echo "QA output created by $seq"
75
76
here=$PWD
77
-status=1    # failure is the default!
78
+status=1 # failure is the default!
79
80
_cleanup()
81
{
82
-    _cleanup_test_img
83
+ _cleanup_qemu
84
+ _cleanup_test_img
85
}
86
trap "_cleanup; exit \$status" 0 1 2 3 15
87
88
diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109
89
index XXXXXXX..XXXXXXX 100755
90
--- a/tests/qemu-iotests/109
91
+++ b/tests/qemu-iotests/109
92
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
93
94
_cleanup()
95
{
96
+ _cleanup_qemu
97
rm -f $TEST_IMG.src
98
    _cleanup_test_img
99
}
100
diff --git a/tests/qemu-iotests/117 b/tests/qemu-iotests/117
101
index XXXXXXX..XXXXXXX 100755
102
--- a/tests/qemu-iotests/117
103
+++ b/tests/qemu-iotests/117
104
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
105
106
_cleanup()
107
{
108
+ _cleanup_qemu
109
    _cleanup_test_img
110
}
111
trap "_cleanup; exit \$status" 0 1 2 3 15
112
diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130
113
index XXXXXXX..XXXXXXX 100755
114
--- a/tests/qemu-iotests/130
115
+++ b/tests/qemu-iotests/130
116
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
117
118
_cleanup()
119
{
120
+ _cleanup_qemu
121
_cleanup_test_img
122
}
123
trap "_cleanup; exit \$status" 0 1 2 3 15
124
diff --git a/tests/qemu-iotests/140 b/tests/qemu-iotests/140
125
index XXXXXXX..XXXXXXX 100755
126
--- a/tests/qemu-iotests/140
127
+++ b/tests/qemu-iotests/140
128
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
129
130
_cleanup()
131
{
132
+ _cleanup_qemu
133
_cleanup_test_img
134
rm -f "$TEST_DIR/nbd"
135
}
136
diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141
137
index XXXXXXX..XXXXXXX 100755
138
--- a/tests/qemu-iotests/141
139
+++ b/tests/qemu-iotests/141
140
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
141
142
_cleanup()
143
{
144
+ _cleanup_qemu
145
_cleanup_test_img
146
rm -f "$TEST_DIR/{b,m,o}.$IMGFMT"
147
}
148
diff --git a/tests/qemu-iotests/143 b/tests/qemu-iotests/143
149
index XXXXXXX..XXXXXXX 100755
150
--- a/tests/qemu-iotests/143
151
+++ b/tests/qemu-iotests/143
152
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
153
154
_cleanup()
155
{
156
+ _cleanup_qemu
157
rm -f "$TEST_DIR/nbd"
158
}
159
trap "_cleanup; exit \$status" 0 1 2 3 15
160
diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156
161
index XXXXXXX..XXXXXXX 100755
162
--- a/tests/qemu-iotests/156
163
+++ b/tests/qemu-iotests/156
164
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
165
166
_cleanup()
167
{
168
+ _cleanup_qemu
169
rm -f "$TEST_IMG{,.target}{,.backing,.overlay}"
170
}
171
trap "_cleanup; exit \$status" 0 1 2 3 15
172
--
30
--
173
2.9.3
31
2.28.0
174
32
175
diff view generated by jsdifflib