The bhyve NVMe backend should support a device path of 'ram=<size_in_MiB>'
and this no longer works following the recent configuration management
changes.
Details
- Reviewers
jhb andy_omniosce.org - Group Reviewers
bhyve - Commits
- rG704d90845ce2: bhyve: Fix cli regression with NVMe ram
rG3a4ab18377c8: bhyve: Fix cli regression with NVMe ram
I've tested that bhyve now correctly sets the ram configuration variable
when parsing legacy options:
# usr.sbin/bhyve/bhyve -o config.dump=1 -s 7,nvme,ram=16384 xx pci.0.7.0.device=nvme pci.0.7.0.ram=16384 # usr.sbin/bhyve/bhyve -o config.dump=1 -s 7,nvme,/dev/gpt/rootfs xx pci.0.7.0.device=nvme pci.0.7.0.path=/dev/gpt/rootfs
and with some other options, for completeness:
# usr.sbin/bhyve/bhyve -o config.dump=1 -s 7,nvme,ram=1234,direct,ro,sectorsize=512/512 xx pci.0.7.0.device=nvme pci.0.7.0.direct=true pci.0.7.0.ro=true pci.0.7.0.sectorsize=512/512 pci.0.7.0.ram=1234
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Thank you for finding this bug!
What would you think of the following? It should work the same but avoids duplicating some of the logic found elsewhere:
diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c index 0abc0415a1d..d31a977c7bf 100644 --- a/usr.sbin/bhyve/pci_nvme.c +++ b/usr.sbin/bhyve/pci_nvme.c @@ -2800,11 +2800,30 @@ pci_nvme_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) return (error); } +static int +pci_nvme_legacy_config(nvlist_t *nvl, const char *opts) +{ + char *cp; + + if (opts == NULL) + return (0); + + if (strncmp(opts, "ram=", 4) == 0) { + cp = strchr(opts, ','); + if (cp) { + *cp = '\0'; + cp++; + } + set_config_value_node(nvl, "ram", opts + 4); + return (pci_parse_legacy_config(nvl, cp)); + } else + return (blockif_legacy_config(nvl, opts)); +} struct pci_devemu pci_de_nvme = { .pe_emu = "nvme", .pe_init = pci_nvme_init, - .pe_legacy_config = blockif_legacy_config, + .pe_legacy_config = pci_nvme_legacy_config, .pe_barwrite = pci_nvme_write, .pe_barread = pci_nvme_read };
I think I like Chuck's shorter version a bit better, but Chuck's version needs to use strndup() instead of modifying the 'cosnt char *' input. (strchr's weird signature breaks the compiler noticing since it accepts a const char and silently "casts" away the const via the char * return type). Sorry for the regression though. The commit log should use a 'Fixes:' tag that references the original commit.
Perhaps I'll commandeer this review to keep all the history in one place unless there are objections