On 10/31/2013 07:23 AM, Michal Privoznik wrote: > This commit introduces yet another test under virpcitest: > virPCIDeviceDetach. However, in order to be able to do this, the > virpcimock needs to be extended to model the kernel behavior on PCI > device binding and unbinding (create 'driver' symlinks under the device > tree, check for device ID in driver's ID table, etc.) > > Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> > --- > cfg.mk | 2 +- > tests/Makefile.am | 10 +- > tests/virpcimock.c | 603 ++++++++++++++++++++++++++++++++++++++++++++++++++++- > tests/virpcitest.c | 42 ++++ > 4 files changed, 652 insertions(+), 5 deletions(-) > Coverity has found a problem... <...snip...> > diff --git a/tests/virpcimock.c b/tests/virpcimock.c > index d545361..2adc337 100644 > --- a/tests/virpcimock.c > +++ b/tests/virpcimock.c <...snip...> > +/* > + * PCI Driver functions > + */ > +static void > +pci_driver_new(const char *name, ...) > +{ > + struct pciDriver *driver; > + va_list args; > + int vendor, device; > + char *driverpath; > + > + if (VIR_ALLOC_QUIET(driver) < 0 || > + VIR_STRDUP_QUIET(driver->name, name) < 0 || > + virAsprintfQuiet(&driverpath, "%s/drivers/%s", fakesysfsdir, name) < 0) > + ABORT_OOM(); > + > + if (virFileMakePath(driverpath) < 0) > + ABORT("Unable to create: %s", driverpath); > + 391 ABORT("Unable to create: %s", driverpath); 392 (5) Event va_init: Initializing va_list "args". Also see events: [missing_va_end] 393 va_start(args, name); > + va_start(args, name); > + > + while ((vendor = va_arg(args, int)) != -1) { > + if ((device = va_arg(args, int)) == -1) > + ABORT("Invalid vendor device pair for driver %s", name); > + > + if (VIR_REALLOC_N_QUIET(driver->vendor, driver->len + 1) < 0 || > + VIR_REALLOC_N_QUIET(driver->device, driver->len + 1) < 0) > + ABORT_OOM(); > + > + driver->vendor[driver->len] = vendor; > + driver->device[driver->len] = device; > + driver->len++; > + } > + > + make_file(driverpath, "bind", NULL); > + make_file(driverpath, "unbind", NULL); > + make_file(driverpath, "new_id", NULL); > + make_file(driverpath, "remove_id", NULL); > + > + if (VIR_APPEND_ELEMENT_QUIET(pciDrivers, pciDrivers_size, driver) < 0) > + ABORT_OOM(); 413 if (VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPciDrivers, driver) < 0) 414 ABORT_OOM(); (15) Event missing_va_end: va_end was not called for "args". Also see events: [va_init] 415 } 416 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list