Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_virtio_block.c
Show First 20 Lines • Show All 431 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct pci_vtblk_softc *sc = vsc; | struct pci_vtblk_softc *sc = vsc; | ||||
while (vq_has_descs(vq)) | while (vq_has_descs(vq)) | ||||
pci_vtblk_proc(sc, vq); | pci_vtblk_proc(sc, vq); | ||||
} | } | ||||
static int | static int | ||||
pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) | pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) | ||||
{ | { | ||||
char bident[sizeof("XX:X:X")]; | char bident[sizeof("XX:X:X")]; | ||||
struct blockif_ctxt *bctxt; | struct blockif_ctxt *bctxt; | ||||
const char *path; | const char *path; | ||||
MD5_CTX mdctx; | MD5_CTX mdctx; | ||||
u_char digest[16]; | u_char digest[16]; | ||||
struct pci_vtblk_softc *sc; | struct pci_vtblk_softc *sc; | ||||
off_t size; | off_t size; | ||||
int i, sectsz, sts, sto; | int i, sectsz, sts, sto; | ||||
/* | /* | ||||
* The supplied backing file has to exist | * The supplied backing file has to exist | ||||
*/ | */ | ||||
snprintf(bident, sizeof(bident), "%d:%d", pi->pi_slot, pi->pi_func); | snprintf(bident, sizeof(bident), "%d:%d", pi->pi_slot, pi->pi_func); | ||||
bctxt = blockif_open(nvl, bident); | bctxt = blockif_open(node, bident); | ||||
if (bctxt == NULL) { | if (bctxt == NULL) { | ||||
perror("Could not open backing file"); | perror("Could not open backing file"); | ||||
return (1); | return (1); | ||||
} | } | ||||
size = blockif_size(bctxt); | size = blockif_size(bctxt); | ||||
sectsz = blockif_sectsz(bctxt); | sectsz = blockif_sectsz(bctxt); | ||||
blockif_psectsz(bctxt, &sts, &sto); | blockif_psectsz(bctxt, &sts, &sto); | ||||
Show All 20 Lines | pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) | ||||
sc->vbsc_vq.vq_qsize = VTBLK_RINGSZ; | sc->vbsc_vq.vq_qsize = VTBLK_RINGSZ; | ||||
/* sc->vbsc_vq.vq_notify = we have no per-queue notify */ | /* sc->vbsc_vq.vq_notify = we have no per-queue notify */ | ||||
/* | /* | ||||
* Create an identifier for the backing file. Use parts of the | * Create an identifier for the backing file. Use parts of the | ||||
* md5 sum of the filename | * md5 sum of the filename | ||||
*/ | */ | ||||
path = get_config_value_node(nvl, "path"); | path = get_config_value_node(node, "path"); | ||||
MD5Init(&mdctx); | MD5Init(&mdctx); | ||||
MD5Update(&mdctx, path, strlen(path)); | MD5Update(&mdctx, path, strlen(path)); | ||||
MD5Final(digest, &mdctx); | MD5Final(digest, &mdctx); | ||||
snprintf(sc->vbsc_ident, VTBLK_BLK_ID_BYTES, | snprintf(sc->vbsc_ident, VTBLK_BLK_ID_BYTES, | ||||
"BHYVE-%02X%02X-%02X%02X-%02X%02X", | "BHYVE-%02X%02X-%02X%02X-%02X%02X", | ||||
digest[0], digest[1], digest[2], digest[3], digest[4], digest[5]); | digest[0], digest[1], digest[2], digest[3], digest[4], digest[5]); | ||||
/* setup virtio block config space */ | /* setup virtio block config space */ | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |