Skip to content

Conversation

@joshwhieb
Copy link

Otherwise we can't realize the nvme disk through LUA. closes #27 . Was able to test this on qbox 3.0.1. How do I test this on the latest qbox master? I don't have access to the qemu "libqemu-v9.1-v0.17" tag.

Updated the documentation with an example of instantiating via lua. Not sure if we want to clean up the documentation a little bit since the gpex.add_device() is part of the constructor now?

Was able to add the following to conf.lua

    nvme_disk_0 = {
        moduletype = "nvme_disk",
        dylib_path = "nvme",
        args = {"&platform.qemu_inst", "&platform.gpex_0"},
        serial = "nvme_serial_001",
        blob_file=top().."fw/Artifacts/nvme_disk.img",
        max_ioqpairs = 64
    };

Now the device shows up in lspci on boot:

#> lspci -vv

00:01.0 Non-Volatile memory controller: Red Hat, Inc. QEMU NVM Express Controller (rev 02) (prog-if 02 [NVM Express])
        Subsystem: Red Hat, Inc. QEMU NVM Express Controller
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Interrupt: pin A routed to IRQ 18
        Region 0: Memory at 400000000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [80] Express (v2) Root Complex Integrated Endpoint, MSI 00
                DevCap: MaxPayload 128 bytes, PhantFunc 0
                        ExtTag- RBE+ FLReset+
                DevCtl: CorrErr- NonFatalErr- FatalErr- UnsupReq-
                        RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
                        MaxPayload 128 bytes, MaxReadReq 128 bytes
                DevSta: CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr- TransPend-
                DevCap2: Completion Timeout: Not Supported, TimeoutDis- NROPrPrP- LTR-
                         10BitTagComp- 10BitTagReq- OBFF Not Supported, ExtFmt+ EETLPPrefix+, MaxEETLPPrefixes 4
                         EmergencyPowerReduction Not Supported, EmergencyPowerReductionInit-
                         FRS-
                         AtomicOpsCap: 32bit- 64bit- 128bitCAS-
                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- LTR- OBFF Disabled,
                         AtomicOpsCtl: ReqEn-
        Capabilities: [60] Power Management version 3
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
        Kernel driver in use: nvme
        Kernel modules: nvme

Also able to read/write to the device.

#> dd if=/dev/nvme0n1 of=/dev/null bs=1K count=100 iflag=direct
100+0 records in
100+0 records out
102400 bytes (102 kB, 100 KiB) copied, 0.0622617 s, 1.6 MB/s

#> dd if=/dev/zero of=/dev/nvme0n1 bs=1K count=100 oflag=direct
100+0 records in
100+0 records out
102400 bytes (102 kB, 100 KiB) copied, 0.0702145 s, 1.5 MB/s

I do get a warning that MSI-X isn't supported by the interrupt controller before the kernel starts but still seems to work? Half the time the simulation on start also segmentation faults so there is some instability under the surface.

libqbox: warning: MSI-X is not supported by interrupt controller

Updated the nvme disk to take an instance of the gpex via constructor so that it is realized.  Updated the documentation with an example of instantiating via lua.

Signed-off-by: jhieb <jhieb@micron.com>
@joshwhieb joshwhieb changed the title Add qpex to nvme_disk for lua config support. Add gpex to nvme_disk for lua config support. Aug 18, 2025
@markfoodyburton
Copy link
Contributor

Thanks for the patch Josh, I'll review.

Copy link
Contributor

@androm3da androm3da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rebase this PR on eac997e or a later commit?

@joshwhieb
Copy link
Author

@androm3da sure I rebased it with your most recent changes.

8110161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nvme disk not realized or connected when defining through lua

4 participants