On 10/09/2015 01:13 PM, Montorsi, Francesco wrote: >>> It seems the patch missed the boat :) >> >> Correct, sorry. I'm attaching it now. > Ok, for some reason the email client is removing the attachment... I'm > copying and pasting it: > (the points marked as TODO are functions that still contain rte_panic() > calls...)
I actually did receive the attachment from the previous mail, but inlined patches are far better for commenting purposes. > + */ > +struct internal_config; > +int rte_eal_init_raw(const char* logid, struct internal_config *cfg); Like the name indicates, struct internal_config is internal to librte_eal, you'd need to "export" the eal_internal_cfg.h header for this to be useful to users outside librte_eal itself. But I'd say there's a reason why its internal... > - if (rte_eal_pci_init() < 0) > - rte_panic("Cannot init PCI\n"); > + if (rte_eal_pci_init() < 0) { > + RTE_LOG (ERR, EAL, "Cannot init PCI\n"); > + return -1; > + } > > #ifdef RTE_LIBRTE_IVSHMEM > - if (rte_eal_ivshmem_init() < 0) > - rte_panic("Cannot init IVSHMEM\n"); > + if (rte_eal_ivshmem_init() < 0) { > + RTE_LOG (ERR, EAL, "Cannot init IVSHMEM\n"); > + return -1; > + } > #endif > > - if (rte_eal_memory_init() < 0) > - rte_panic("Cannot init memory\n"); > + if (rte_eal_memory_init() < 0) { > + RTE_LOG (ERR, EAL, "Cannot init memory\n"); > + return -1; > + } [...] Something like that, sure. The big question with this conversion is what to do with already allocated/initialized resources in case of failure, which I'd guess is the reason rte_panic() is there - to avoid having to deal with all that. Getting to a point where all or even most inialization can be undone in case of failure is likely going to be a long road, I think many subsystems dont even have a shutdown function. To beging with, EAL itself doesn't have one :) Anyway, one has to start someplace. But in order to make the cleanup eventually possible, I'd suggest using a common point of exit instead of a dozen returns, ie something in spirit of { [...] if (rte_eal_pci_init() < 0) { RTE_LOG (ERR, EAL, "Cannot init PCI\n"); goto err; } if (rte_eal_memory_init() < 0) RTE_LOG (ERR, EAL, "Cannot init memory\n"); goto err; } [...] return 0; err: /* TODO: undo all initialization work */ return -1; } - Panu -