diff options
author | grehan <grehan@FreeBSD.org> | 2013-07-04 05:35:56 +0000 |
---|---|---|
committer | grehan <grehan@FreeBSD.org> | 2013-07-04 05:35:56 +0000 |
commit | 4afc69bc7618a2445997ba51f65a74a54d461acb (patch) | |
tree | 1475820278721b7a4feacaea3c2716ad349e638a /usr.sbin/bhyve/pci_emul.c | |
parent | 67f40d0cd39e244cabb915e7828711647be1f159 (diff) | |
download | FreeBSD-src-4afc69bc7618a2445997ba51f65a74a54d461acb.zip FreeBSD-src-4afc69bc7618a2445997ba51f65a74a54d461acb.tar.gz |
Support an optional "mac=" parameter to virtio-net config, to allow
users to set the MAC address for a device.
Clean up some obsolete code in pci_virtio_net.c
Allow an error return from a PCI device emulation's init routine
to be propagated all the way back to the top-level and result in
the process exiting.
Submitted by: Dinakar Medavaram dinnu sun at gmail (original version)
Diffstat (limited to 'usr.sbin/bhyve/pci_emul.c')
-rw-r--r-- | usr.sbin/bhyve/pci_emul.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 76e536c..00adf62 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -662,11 +662,13 @@ pci_emul_finddev(char *name) return (NULL); } -static void +static int pci_emul_init(struct vmctx *ctx, struct pci_devemu *pde, int slot, int func, char *params) { struct pci_devinst *pdi; + int err; + pdi = malloc(sizeof(struct pci_devinst)); bzero(pdi, sizeof(*pdi)); @@ -684,12 +686,15 @@ pci_emul_init(struct vmctx *ctx, struct pci_devemu *pde, int slot, int func, pci_set_cfgdata8(pdi, PCIR_COMMAND, PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN); - if ((*pde->pe_init)(ctx, pdi, params) != 0) { + err = (*pde->pe_init)(ctx, pdi, params); + if (err != 0) { free(pdi); } else { pci_emul_devices++; pci_slotinfo[slot][func].si_devi = pdi; - } + } + + return (err); } void @@ -989,7 +994,7 @@ pci_emul_fallback_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr, return (0); } -void +int init_pci(struct vmctx *ctx) { struct mem_range memp; @@ -1009,8 +1014,10 @@ init_pci(struct vmctx *ctx) if (si->si_name != NULL) { pde = pci_emul_finddev(si->si_name); assert(pde != NULL); - pci_emul_init(ctx, pde, slot, func, - si->si_param); + error = pci_emul_init(ctx, pde, slot, func, + si->si_param); + if (error) + return (error); } } } @@ -1047,6 +1054,8 @@ init_pci(struct vmctx *ctx) error = register_mem_fallback(&memp); assert(error == 0); + + return (0); } int |