Skip to content

Add support for namespace attach/detach during runtime

Daniel Wagner qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 patch 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1hw/nvme: Add hotplug handler to nvme bushw/nvme/ctrl.c+13 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH v1 0/1] Add support for namespace attach/detach during runtime

This is a follow up on a very old thread[1]. My aim is to attach/detatch nvme devices during runtime and test the Linux nvme subsystem in the guest.

In order to it working, I had first to add hotplug able PCI bus and the nvme-subsystem. The nvme-subsystem can't be instatiated during runtime so far (libvirtd config):

<qemu:commandline>

    <qemu:arg value='-device'/>
    <qemu:arg value='pcie-root-port,id=root,bus=pcie.0,addr=0x6'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='nvme-subsys,id=nvme-subsys-1,nqn=nvme-1'/>

</qemu:commandline>

and then with a bunch of monitor commands:

  qemu-monitor-command tw --hmp device_add nvme,id=nvme1,serial=nvme-1,subsys=nvme-subsys-1,bus=root
  qemu-monitor-command tw --hmp drive_add 0 if=none,file=/var/lib/libvirt/images/tw-nvme1.img,format=raw,id=nvme1
  qemu-monitor-command tw --hmp device_add nvme-ns,drive=nvme1,shared=on

  qemu-monitor-command tw --hmp info block

  qemu-monitor-command tw --hmp device_del nvme1

I see the nvme device pop up in the guest:

  [  187.047693 ] pci 0000:0f:00.0: [1b36:0010] type 00 class 0x010802
  [  187.050324 ] pci 0000:0f:00.0: reg 0x10: [mem 0x00000000-0x00003fff 64bit]
  [  187.098823 ] pci 0000:0f:00.0: BAR 0: assigned [mem 0xc0800000-0xc0803fff 64bit]
  [  187.102173 ] nvme nvme1: pci function 0000:0f:00.0
  [  187.103084 ] nvme 0000:0f:00.0: enabling device (0000 -> 0002)
  [  187.131154 ] nvme nvme1: 4/0/0 default/read/poll queues
  [  187.133460 ] nvme nvme1: Ignoring bogus Namespace Identifiers

and it looks pretty reasonable:

  # nvme list -v
  Subsystem        Subsystem-NQN                                                                                    Controllers
  ---------------- ------------------------------------------------------------------------------------------------ ----------------
  nvme-subsys1     nqn.2019-08.org.qemu:nvme-1                                                                      nvme1
  nvme-subsys0     nqn.2019-08.org.qemu:nvme-0                                                                      nvme0

Device SN MN FR TxPort Address Subsystem Namespaces
-------- -------------------- ---------------------------------------- -------- ------ -------------- ------------ ----------------

  nvme1    nvme-1               QEMU NVMe Ctrl                           8.0.0    pcie   0000:0f:00.0   nvme-subsys1 nvme1n1
  nvme0    nvme-0               QEMU NVMe Ctrl                           8.0.0    pcie   0000:00:05.0   nvme-subsys0 nvme0n1

Device Generic NSID Usage Format Controllers
------------ ------------ ---------- -------------------------- ---------------- ----------------

  /dev/nvme1n1 /dev/ng1n1   0x1          1.07  GB /   1.07  GB    512   B +  0 B   nvme1
  /dev/nvme0n1 /dev/ng0n1   0x1          1.07  GB /   1.07  GB    512   B +  0 B   nvme0

[1] https://lore.kernel.org/all/[email protected]/

Daniel Wagner (1):
hw/nvme: Add hotplug handler to nvme bus

 hw/nvme/ctrl.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Signature · 1 line
2.40.0