Page MenuHomeFreeBSD

D25396.id73455.diff
No OneTemporary

D25396.id73455.diff

Index: usr.sbin/bhyve/bhyve.8
===================================================================
--- usr.sbin/bhyve/bhyve.8
+++ usr.sbin/bhyve/bhyve.8
@@ -532,8 +532,6 @@
Max elements in each queue.
.It Li ioslots
Max number of concurrent I/O requests.
-.It Li sectsz
-Sector size (defaults to blockif sector size).
.It Li ser
Serial number with maximum 20 characters.
.El
Index: usr.sbin/bhyve/pci_nvme.c
===================================================================
--- usr.sbin/bhyve/pci_nvme.c
+++ usr.sbin/bhyve/pci_nvme.c
@@ -33,7 +33,9 @@
* bhyve PCIe-NVMe device emulation.
*
* options:
- * -s <n>,nvme,devpath,maxq=#,qsz=#,ioslots=#,sectsz=#,ser=A-Z,eui64=#
+ * -s <n>,nvme,devpath,maxq=#,qsz=#,ioslots=#,ser=A-Z,eui64=#
+ *
+ * block device options is also can be appended
*
* accepted devpath:
* /dev/blockdev
@@ -43,7 +45,6 @@
* maxq = max number of queues
* qsz = max elements in each queue
* ioslots = max number of concurrent io requests
- * sectsz = sector size (defaults to blockif sector size)
* ser = serial number (20-chars max)
* eui64 = IEEE Extended Unique Identifier (8 byte value)
*
@@ -2019,9 +2020,10 @@
pci_nvme_parse_opts(struct pci_nvme_softc *sc, char *opts)
{
char bident[sizeof("XX:X:X")];
- char *uopt, *xopts, *config;
- uint32_t sectsz;
+ char *bopt, *uopt, *xopts, *config;
int optidx;
+ size_t block_len;
+ FILE* fp;
sc->max_queues = NVME_QUEUES;
sc->max_qentries = NVME_MAX_QENTRIES;
@@ -2029,7 +2031,6 @@
sc->num_squeues = sc->max_queues;
sc->num_cqueues = sc->max_queues;
sc->dataset_management = NVME_DATASET_MANAGEMENT_AUTO;
- sectsz = 0;
uopt = strdup(opts);
optidx = 0;
@@ -2048,8 +2049,6 @@
sc->max_qentries = atoi(config);
} else if (!strcmp("ioslots", xopts)) {
sc->ioslots = atoi(config);
- } else if (!strcmp("sectsz", xopts)) {
- sectsz = atoi(config);
} else if (!strcmp("ser", xopts)) {
/*
* This field indicates the Product Serial Number in
@@ -2064,8 +2063,6 @@
sc->nvstore.type = NVME_STOR_RAM;
sc->nvstore.size = sz * 1024 * 1024;
sc->nvstore.ctx = calloc(1, sc->nvstore.size);
- sc->nvstore.sectsz = 4096;
- sc->nvstore.sectsz_bits = 12;
if (sc->nvstore.ctx == NULL) {
perror("Unable to allocate RAM");
free(uopt);
@@ -2081,34 +2078,43 @@
else if (!strcmp("disable", config))
sc->dataset_management = NVME_DATASET_MANAGEMENT_DISABLE;
} else if (optidx == 0) {
- snprintf(bident, sizeof(bident), "%d:%d",
- sc->nsc_pi->pi_slot, sc->nsc_pi->pi_func);
- sc->nvstore.ctx = blockif_open(xopts, bident);
- if (sc->nvstore.ctx == NULL) {
- perror("Could not open backing file");
+ bopt = NULL;
+ fp = open_memstream(&bopt, &block_len);
+ fprintf(fp, "%s", xopts);
+ sc->nvstore.type = NVME_STOR_BLOCKIF;
+ } else {
+ if (sc->nvstore.type == NVME_STOR_BLOCKIF) {
+ /* Pass other options to blockif_open. */
+ fprintf(fp, ",%s", xopts);
+ } else {
+ EPRINTLN("Invalid option %s", xopts);
free(uopt);
return (-1);
}
- sc->nvstore.type = NVME_STOR_BLOCKIF;
- sc->nvstore.size = blockif_size(sc->nvstore.ctx);
- } else {
- EPRINTLN("Invalid option %s", xopts);
- free(uopt);
- return (-1);
}
optidx++;
}
free(uopt);
- if (sc->nvstore.ctx == NULL || sc->nvstore.size == 0) {
- EPRINTLN("backing store not specified");
- return (-1);
+ if (sc->nvstore.type == NVME_STOR_BLOCKIF) {
+ snprintf(bident, sizeof(bident), "%d:%d",
+ sc->nsc_pi->pi_slot, sc->nsc_pi->pi_func);
+ sc->nvstore.ctx = blockif_open(bopt, bident);
+ free(bopt);
+ if (sc->nvstore.ctx == NULL) {
+ EPRINTLN("backing store not specified");
+ return (-1);
+ }
+ sc->nvstore.size = blockif_size(sc->nvstore.ctx);
}
- if (sectsz == 512 || sectsz == 4096 || sectsz == 8192)
- sc->nvstore.sectsz = sectsz;
- else if (sc->nvstore.type != NVME_STOR_RAM)
+
+ if (sc->nvstore.type == NVME_STOR_RAM) {
+ sc->nvstore.sectsz = 4096;
+ } else {
sc->nvstore.sectsz = blockif_sectsz(sc->nvstore.ctx);
+ }
+
for (sc->nvstore.sectsz_bits = 9;
(1 << sc->nvstore.sectsz_bits) < sc->nvstore.sectsz;
sc->nvstore.sectsz_bits++);

File Metadata

Mime Type
text/plain
Expires
Sun, May 17, 6:43 PM (8 m, 2 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33202987
Default Alt Text
D25396.id73455.diff (4 KB)

Event Timeline