[Qemu-devel] [PATCH v2 0/6] block: Add VFIO based driver for NVMe device

Fam Zheng posted 6 patches 7 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170223091845.18523-1-famz@redhat.com
Test checkpatch failed
Test docker passed
Test s390x passed
There is a newer version of this series
MAINTAINERS                    |    6 +
block/Makefile.objs            |    1 +
block/block-backend.c          |   10 +
block/io.c                     |   24 +
block/nvme-vfio.c              |  664 +++++++++++++++++++++++++
block/nvme-vfio.h              |   31 ++
block/nvme.c                   | 1073 ++++++++++++++++++++++++++++++++++++++++
block/trace-events             |   27 +
hw/block/nvme.h                |  629 +----------------------
include/block/block.h          |    2 +
include/block/block_int.h      |    4 +
include/block/nvme.h           |  632 +++++++++++++++++++++++
include/sysemu/block-backend.h |    3 +
qemu-img.c                     |   15 +
stubs/Makefile.objs            |    1 +
stubs/ram-block-notifier.c     |   10 +
16 files changed, 2504 insertions(+), 628 deletions(-)
create mode 100644 block/nvme-vfio.c
create mode 100644 block/nvme-vfio.h
create mode 100644 block/nvme.c
create mode 100644 include/block/nvme.h
create mode 100644 stubs/ram-block-notifier.c
[Qemu-devel] [PATCH v2 0/6] block: Add VFIO based driver for NVMe device
Posted by Fam Zheng 7 years, 2 months ago
This is a refresh of the NVMe VFIO driver patches.

The first three patches add the driver, the others are to make qemu-img more
efficient with the new driver.

v2:
    - Implement "split vfio addr space" appraoch. [Paolo]
    - Add back 'device reset' in nvme_close(). [Paolo]
    - Better variable namings. [Stefan]
    - "Reuse" macro definitions from NVMe emulation code.
    - Rebase onto current master which has polling by default and update
      performance results accordingly.
    - Update MAINTAINERS.
    - Specify namespace in URI.
    - The sporadical I/O error from v1 "disappeared" in this version.
    - Tests one: qemu-img bench, fio, bonnie++ and installation of
      ubuntu/fedora/rhel on QEMU emulated nvme and a Intel P3700 card.

Fam Zheng (6):
  nvme: Move NVMe definitions to a separate header
  stubs: Add stubs for ram block notifier API
  block: Add VFIO based NVMe driver
  block: Introduce bdrv_dma_map and bdrv_dma_unmap
  block/nvme: Implement .bdrv_dma_map and .bdrv_dma_unmap
  qemu-img: dma map buffers

 MAINTAINERS                    |    6 +
 block/Makefile.objs            |    1 +
 block/block-backend.c          |   10 +
 block/io.c                     |   24 +
 block/nvme-vfio.c              |  664 +++++++++++++++++++++++++
 block/nvme-vfio.h              |   31 ++
 block/nvme.c                   | 1073 ++++++++++++++++++++++++++++++++++++++++
 block/trace-events             |   27 +
 hw/block/nvme.h                |  629 +----------------------
 include/block/block.h          |    2 +
 include/block/block_int.h      |    4 +
 include/block/nvme.h           |  632 +++++++++++++++++++++++
 include/sysemu/block-backend.h |    3 +
 qemu-img.c                     |   15 +
 stubs/Makefile.objs            |    1 +
 stubs/ram-block-notifier.c     |   10 +
 16 files changed, 2504 insertions(+), 628 deletions(-)
 create mode 100644 block/nvme-vfio.c
 create mode 100644 block/nvme-vfio.h
 create mode 100644 block/nvme.c
 create mode 100644 include/block/nvme.h
 create mode 100644 stubs/ram-block-notifier.c

-- 
2.9.3


Re: [Qemu-devel] [PATCH v2 0/6] block: Add VFIO based driver for NVMe device
Posted by no-reply@patchew.org 7 years, 2 months ago
Hi,

This series seems to have some coding style problems. See output below for
more information:

Message-id: 20170223091845.18523-1-famz@redhat.com
Type: series
Subject: [Qemu-devel] [PATCH v2 0/6] block: Add VFIO based driver for NVMe device

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/20170223091845.18523-1-famz@redhat.com -> patchew/20170223091845.18523-1-famz@redhat.com
Switched to a new branch 'test'
2ae086a qemu-img: dma map buffers
0d6bed0 block/nvme: Implement .bdrv_dma_map and .bdrv_dma_unmap
ddc2044 block: Introduce bdrv_dma_map and bdrv_dma_unmap
fec4a5e block: Add VFIO based NVMe driver
57517a8 stubs: Add stubs for ram block notifier API
98b0e5f nvme: Move NVMe definitions to a separate header

=== OUTPUT BEGIN ===
Checking PATCH 1/6: nvme: Move NVMe definitions to a separate header...
Checking PATCH 2/6: stubs: Add stubs for ram block notifier API...
Checking PATCH 3/6: block: Add VFIO based NVMe driver...
WARNING: line over 80 characters
#187: FILE: block/nvme-vfio.c:131:
+    if (ioctl(s->device, VFIO_DEVICE_GET_REGION_INFO, &s->bar_region_info[index])) {

WARNING: line over 80 characters
#265: FILE: block/nvme-vfio.c:209:
+static int nvme_vfio_pci_read_config(NVMeVFIOState *s, void *buf, int size, int ofs)

WARNING: line over 80 characters
#267: FILE: block/nvme-vfio.c:211:
+    if (pread(s->device, buf, size, s->config_region_info.offset + ofs) == size) {

WARNING: line over 80 characters
#273: FILE: block/nvme-vfio.c:217:
+static int nvme_vfio_pci_write_config(NVMeVFIOState *s, void *buf, int size, int ofs)

WARNING: line over 80 characters
#409: FILE: block/nvme-vfio.c:353:
+static void nvme_vfio_ram_block_added(RAMBlockNotifier *n, void *host, size_t size)

WARNING: line over 80 characters
#416: FILE: block/nvme-vfio.c:360:
+static void nvme_vfio_ram_block_removed(RAMBlockNotifier *n, void *host, size_t size)

ERROR: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
#797: FILE: block/nvme.c:34:
+    volatile uint32_t *doorbell;

ERROR: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
#823: FILE: block/nvme.c:60:
+typedef volatile struct {

WARNING: line over 80 characters
#1302: FILE: block/nvme.c:539:
+            error_setg(errp, "Timeout while waiting for device to reset (%ld ms)",

WARNING: line over 80 characters
#1331: FILE: block/nvme.c:568:
+            error_setg(errp, "Timeout while waiting for device to start (%ld ms)",

total: 2 errors, 8 warnings, 1800 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 4/6: block: Introduce bdrv_dma_map and bdrv_dma_unmap...
Checking PATCH 5/6: block/nvme: Implement .bdrv_dma_map and .bdrv_dma_unmap...
Checking PATCH 6/6: qemu-img: dma map buffers...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
Re: [Qemu-devel] [PATCH v2 0/6] block: Add VFIO based driver for NVMe device
Posted by Fam Zheng 7 years, 2 months ago
On Thu, 02/23 17:18, Fam Zheng wrote:
> This is a refresh of the NVMe VFIO driver patches.
> 
> The first three patches add the driver, the others are to make qemu-img more
> efficient with the new driver.

Paolo, I wanted to also make ram_block_notifier_add notify existing ram blocks,
so that hot plugging of nvme:// will work as expected, but I don't know how to
write the code. Any suggestions? Or do you have a patch for that already?

Fam

Re: [Qemu-devel] [PATCH v2 0/6] block: Add VFIO based driver for NVMe device
Posted by Paolo Bonzini 7 years, 2 months ago

On 23/02/2017 11:48, Fam Zheng wrote:
>>
>> The first three patches add the driver, the others are to make qemu-img more
>> efficient with the new driver.
> Paolo, I wanted to also make ram_block_notifier_add notify existing ram blocks,
> so that hot plugging of nvme:// will work as expected, but I don't know how to
> write the code. Any suggestions? Or do you have a patch for that already?

I don't :) but it shouldn't be hard to do using qemu_ram_foreach_block:

typedef int (RAMBlockIterFunc)(const char *block_name, void *host_addr,
    ram_addr_t offset, ram_addr_t length, void *opaque);

int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);

Paolo

Re: [Qemu-devel] [PATCH v2 0/6] block: Add VFIO based driver for NVMe device
Posted by Fam Zheng 7 years, 2 months ago
On Thu, 02/23 11:50, Paolo Bonzini wrote:
> 
> 
> On 23/02/2017 11:48, Fam Zheng wrote:
> >>
> >> The first three patches add the driver, the others are to make qemu-img more
> >> efficient with the new driver.
> > Paolo, I wanted to also make ram_block_notifier_add notify existing ram blocks,
> > so that hot plugging of nvme:// will work as expected, but I don't know how to
> > write the code. Any suggestions? Or do you have a patch for that already?
> 
> I don't :) but it shouldn't be hard to do using qemu_ram_foreach_block:
> 
> typedef int (RAMBlockIterFunc)(const char *block_name, void *host_addr,
>     ram_addr_t offset, ram_addr_t length, void *opaque);
> 
> int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);
> 

Cool, I'll add that in v3.

Fam