Capitalize USB, PCI and SCSI in hostdev variables

Change any variable names with Usb, Pci or Scsi to use
USB, PCI and SCSI since they are abbreviations.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2014-03-12 16:38:18 +00:00
parent e9a60dcc7c
commit a65e6d3626
4 changed files with 119 additions and 119 deletions

View File

@ -4735,9 +4735,9 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
VIR_WARN("cannot deny device %s for domain %s", VIR_WARN("cannot deny device %s for domain %s",
dst, vm->def->name); dst, vm->def->name);
virObjectLock(hostdev_mgr->activeUsbHostdevs); virObjectLock(hostdev_mgr->activeUSBHostdevs);
virUSBDeviceListDel(hostdev_mgr->activeUsbHostdevs, usb); virUSBDeviceListDel(hostdev_mgr->activeUSBHostdevs, usb);
virObjectUnlock(hostdev_mgr->activeUsbHostdevs); virObjectUnlock(hostdev_mgr->activeUSBHostdevs);
virDomainHostdevRemove(vm->def, idx); virDomainHostdevRemove(vm->def, idx);
virDomainHostdevDefFree(def); virDomainHostdevDefFree(def);

View File

@ -64,13 +64,13 @@ virLXCUpdateActiveUsbHostdevs(virLXCDriverPtr driver,
virUSBDeviceSetUsedBy(usb, LXC_DRIVER_NAME, def->name); virUSBDeviceSetUsedBy(usb, LXC_DRIVER_NAME, def->name);
virObjectLock(hostdev_mgr->activeUsbHostdevs); virObjectLock(hostdev_mgr->activeUSBHostdevs);
if (virUSBDeviceListAdd(hostdev_mgr->activeUsbHostdevs, usb) < 0) { if (virUSBDeviceListAdd(hostdev_mgr->activeUSBHostdevs, usb) < 0) {
virObjectUnlock(hostdev_mgr->activeUsbHostdevs); virObjectUnlock(hostdev_mgr->activeUSBHostdevs);
virUSBDeviceFree(usb); virUSBDeviceFree(usb);
return -1; return -1;
} }
virObjectUnlock(hostdev_mgr->activeUsbHostdevs); virObjectUnlock(hostdev_mgr->activeUSBHostdevs);
} }
return 0; return 0;
@ -89,10 +89,10 @@ virLXCPrepareHostdevUSBDevices(virLXCDriverPtr driver,
count = virUSBDeviceListCount(list); count = virUSBDeviceListCount(list);
virObjectLock(hostdev_mgr->activeUsbHostdevs); virObjectLock(hostdev_mgr->activeUSBHostdevs);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
virUSBDevicePtr usb = virUSBDeviceListGet(list, i); virUSBDevicePtr usb = virUSBDeviceListGet(list, i);
if ((tmp = virUSBDeviceListFind(hostdev_mgr->activeUsbHostdevs, usb))) { if ((tmp = virUSBDeviceListFind(hostdev_mgr->activeUSBHostdevs, usb))) {
const char *other_drvname; const char *other_drvname;
const char *other_domname; const char *other_domname;
@ -111,25 +111,25 @@ virLXCPrepareHostdevUSBDevices(virLXCDriverPtr driver,
} }
virUSBDeviceSetUsedBy(usb, LXC_DRIVER_NAME, name); virUSBDeviceSetUsedBy(usb, LXC_DRIVER_NAME, name);
VIR_DEBUG("Adding %03d.%03d dom=%s to activeUsbHostdevs", VIR_DEBUG("Adding %03d.%03d dom=%s to activeUSBHostdevs",
virUSBDeviceGetBus(usb), virUSBDeviceGetDevno(usb), name); virUSBDeviceGetBus(usb), virUSBDeviceGetDevno(usb), name);
/* /*
* The caller is responsible to steal these usb devices * The caller is responsible to steal these usb devices
* from the virUSBDeviceList that passed in on success, * from the virUSBDeviceList that passed in on success,
* perform rollback on failure. * perform rollback on failure.
*/ */
if (virUSBDeviceListAdd(hostdev_mgr->activeUsbHostdevs, usb) < 0) if (virUSBDeviceListAdd(hostdev_mgr->activeUSBHostdevs, usb) < 0)
goto error; goto error;
} }
virObjectUnlock(hostdev_mgr->activeUsbHostdevs); virObjectUnlock(hostdev_mgr->activeUSBHostdevs);
return 0; return 0;
error: error:
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
tmp = virUSBDeviceListGet(list, i); tmp = virUSBDeviceListGet(list, i);
virUSBDeviceListSteal(hostdev_mgr->activeUsbHostdevs, tmp); virUSBDeviceListSteal(hostdev_mgr->activeUSBHostdevs, tmp);
} }
virObjectUnlock(hostdev_mgr->activeUsbHostdevs); virObjectUnlock(hostdev_mgr->activeUSBHostdevs);
return -1; return -1;
} }
@ -355,7 +355,7 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver,
size_t i; size_t i;
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr; virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
virObjectLock(hostdev_mgr->activeUsbHostdevs); virObjectLock(hostdev_mgr->activeUSBHostdevs);
for (i = 0; i < nhostdevs; i++) { for (i = 0; i < nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i]; virDomainHostdevDefPtr hostdev = hostdevs[i];
virUSBDevicePtr usb, tmp; virUSBDevicePtr usb, tmp;
@ -387,7 +387,7 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver,
* Therefore we want to steal only those devices from * Therefore we want to steal only those devices from
* the list which were taken by @name */ * the list which were taken by @name */
tmp = virUSBDeviceListFind(hostdev_mgr->activeUsbHostdevs, usb); tmp = virUSBDeviceListFind(hostdev_mgr->activeUSBHostdevs, usb);
virUSBDeviceFree(usb); virUSBDeviceFree(usb);
if (!tmp) { if (!tmp) {
@ -401,15 +401,15 @@ virLXCDomainReAttachHostUsbDevices(virLXCDriverPtr driver,
virUSBDeviceGetUsedBy(tmp, &usedby_drvname, &usedby_domname); virUSBDeviceGetUsedBy(tmp, &usedby_drvname, &usedby_domname);
if (STREQ_NULLABLE(LXC_DRIVER_NAME, usedby_drvname) && if (STREQ_NULLABLE(LXC_DRIVER_NAME, usedby_drvname) &&
STREQ_NULLABLE(name, usedby_domname)) { STREQ_NULLABLE(name, usedby_domname)) {
VIR_DEBUG("Removing %03d.%03d dom=%s from activeUsbHostdevs", VIR_DEBUG("Removing %03d.%03d dom=%s from activeUSBHostdevs",
hostdev->source.subsys.u.usb.bus, hostdev->source.subsys.u.usb.bus,
hostdev->source.subsys.u.usb.device, hostdev->source.subsys.u.usb.device,
name); name);
virUSBDeviceListDel(hostdev_mgr->activeUsbHostdevs, tmp); virUSBDeviceListDel(hostdev_mgr->activeUSBHostdevs, tmp);
} }
} }
virObjectUnlock(hostdev_mgr->activeUsbHostdevs); virObjectUnlock(hostdev_mgr->activeUSBHostdevs);
} }
void virLXCDomainReAttachHostDevices(virLXCDriverPtr driver, void virLXCDomainReAttachHostDevices(virLXCDriverPtr driver,

View File

@ -75,10 +75,10 @@ virHostdevManagerDispose(void *obj)
if (!hostdevMgr) if (!hostdevMgr)
return; return;
virObjectUnref(hostdevMgr->activePciHostdevs); virObjectUnref(hostdevMgr->activePCIHostdevs);
virObjectUnref(hostdevMgr->inactivePciHostdevs); virObjectUnref(hostdevMgr->inactivePCIHostdevs);
virObjectUnref(hostdevMgr->activeUsbHostdevs); virObjectUnref(hostdevMgr->activeUSBHostdevs);
virObjectUnref(hostdevMgr->activeScsiHostdevs); virObjectUnref(hostdevMgr->activeSCSIHostdevs);
VIR_FREE(hostdevMgr->stateDir); VIR_FREE(hostdevMgr->stateDir);
VIR_FREE(hostdevMgr); VIR_FREE(hostdevMgr);
@ -92,16 +92,16 @@ virHostdevManagerNew(void)
if (!(hostdevMgr = virObjectNew(virHostdevManagerClass))) if (!(hostdevMgr = virObjectNew(virHostdevManagerClass)))
return NULL; return NULL;
if ((hostdevMgr->activePciHostdevs = virPCIDeviceListNew()) == NULL) if ((hostdevMgr->activePCIHostdevs = virPCIDeviceListNew()) == NULL)
goto error; goto error;
if ((hostdevMgr->activeUsbHostdevs = virUSBDeviceListNew()) == NULL) if ((hostdevMgr->activeUSBHostdevs = virUSBDeviceListNew()) == NULL)
goto error; goto error;
if ((hostdevMgr->inactivePciHostdevs = virPCIDeviceListNew()) == NULL) if ((hostdevMgr->inactivePCIHostdevs = virPCIDeviceListNew()) == NULL)
goto error; goto error;
if ((hostdevMgr->activeScsiHostdevs = virSCSIDeviceListNew()) == NULL) if ((hostdevMgr->activeSCSIHostdevs = virSCSIDeviceListNew()) == NULL)
goto error; goto error;
if (VIR_STRDUP(hostdevMgr->stateDir, HOSTDEV_STATE_DIR) < 0) if (VIR_STRDUP(hostdevMgr->stateDir, HOSTDEV_STATE_DIR) < 0)
@ -184,12 +184,12 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
/* /*
* virHostdevGetActivePCIHostDeviceList - make a new list with a *copy* of * virHostdevGetActivePCIHostDeviceList - make a new list with a *copy* of
* every virPCIDevice object that is found on the activePciHostdevs * every virPCIDevice object that is found on the activePCIHostdevs
* list *and* is in the hostdev list for this domain. * list *and* is in the hostdev list for this domain.
* *
* Return the new list, or NULL if there was a failure. * Return the new list, or NULL if there was a failure.
* *
* Pre-condition: activePciHostdevs is locked * Pre-condition: activePCIHostdevs is locked
*/ */
static virPCIDeviceListPtr static virPCIDeviceListPtr
virHostdevGetActivePCIHostDeviceList(virHostdevManagerPtr mgr, virHostdevGetActivePCIHostDeviceList(virHostdevManagerPtr mgr,
@ -213,7 +213,7 @@ virHostdevGetActivePCIHostDeviceList(virHostdevManagerPtr mgr,
continue; continue;
addr = &hostdev->source.subsys.u.pci.addr; addr = &hostdev->source.subsys.u.pci.addr;
activeDev = virPCIDeviceListFindByIDs(mgr->activePciHostdevs, activeDev = virPCIDeviceListFindByIDs(mgr->activePCIHostdevs,
addr->domain, addr->bus, addr->domain, addr->bus,
addr->slot, addr->function); addr->slot, addr->function);
if (activeDev && virPCIDeviceListAddCopy(list, activeDev) < 0) { if (activeDev && virPCIDeviceListAddCopy(list, activeDev) < 0) {
@ -465,8 +465,8 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
size_t i; size_t i;
int ret = -1; int ret = -1;
virObjectLock(hostdev_mgr->activePciHostdevs); virObjectLock(hostdev_mgr->activePCIHostdevs);
virObjectLock(hostdev_mgr->inactivePciHostdevs); virObjectLock(hostdev_mgr->inactivePCIHostdevs);
if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs)))
goto cleanup; goto cleanup;
@ -495,9 +495,9 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
goto cleanup; goto cleanup;
} }
/* The device is in use by other active domain if /* The device is in use by other active domain if
* the dev is in list activePciHostdevs. * the dev is in list activePCIHostdevs.
*/ */
if ((other = virPCIDeviceListFind(hostdev_mgr->activePciHostdevs, dev))) { if ((other = virPCIDeviceListFind(hostdev_mgr->activePCIHostdevs, dev))) {
const char *other_drvname; const char *other_drvname;
const char *other_domname; const char *other_domname;
@ -520,7 +520,7 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) { for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i); virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
if (virPCIDeviceGetManaged(dev) && if (virPCIDeviceGetManaged(dev) &&
virPCIDeviceDetach(dev, hostdev_mgr->activePciHostdevs, NULL) < 0) virPCIDeviceDetach(dev, hostdev_mgr->activePCIHostdevs, NULL) < 0)
goto reattachdevs; goto reattachdevs;
} }
@ -529,8 +529,8 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) { for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i); virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
if (virPCIDeviceReset(dev, hostdev_mgr->activePciHostdevs, if (virPCIDeviceReset(dev, hostdev_mgr->activePCIHostdevs,
hostdev_mgr->inactivePciHostdevs) < 0) hostdev_mgr->inactivePCIHostdevs) < 0)
goto reattachdevs; goto reattachdevs;
} }
@ -555,24 +555,24 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
/* Loop 5: Now mark all the devices as active */ /* Loop 5: Now mark all the devices as active */
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) { for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i); virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
if (virPCIDeviceListAdd(hostdev_mgr->activePciHostdevs, dev) < 0) if (virPCIDeviceListAdd(hostdev_mgr->activePCIHostdevs, dev) < 0)
goto inactivedevs; goto inactivedevs;
} }
/* Loop 6: Now remove the devices from inactive list. */ /* Loop 6: Now remove the devices from inactive list. */
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) { for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i); virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
virPCIDeviceListDel(hostdev_mgr->inactivePciHostdevs, dev); virPCIDeviceListDel(hostdev_mgr->inactivePCIHostdevs, dev);
} }
/* Loop 7: Now set the used_by_domain of the device in /* Loop 7: Now set the used_by_domain of the device in
* activePciHostdevs as domain name. * activePCIHostdevs as domain name.
*/ */
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) { for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev, activeDev; virPCIDevicePtr dev, activeDev;
dev = virPCIDeviceListGet(pcidevs, i); dev = virPCIDeviceListGet(pcidevs, i);
activeDev = virPCIDeviceListFind(hostdev_mgr->activePciHostdevs, dev); activeDev = virPCIDeviceListFind(hostdev_mgr->activePCIHostdevs, dev);
if (activeDev) if (activeDev)
virPCIDeviceSetUsedBy(activeDev, drv_name, dom_name); virPCIDeviceSetUsedBy(activeDev, drv_name, dom_name);
@ -618,12 +618,12 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
goto cleanup; goto cleanup;
inactivedevs: inactivedevs:
/* Only steal all the devices from activePciHostdevs. We will /* Only steal all the devices from activePCIHostdevs. We will
* free them in virObjectUnref(). * free them in virObjectUnref().
*/ */
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) { for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i); virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
virPCIDeviceListSteal(hostdev_mgr->activePciHostdevs, dev); virPCIDeviceListSteal(hostdev_mgr->activePCIHostdevs, dev);
} }
resetvfnetconfig: resetvfnetconfig:
@ -638,19 +638,19 @@ reattachdevs:
/* NB: This doesn't actually re-bind to original driver, just /* NB: This doesn't actually re-bind to original driver, just
* unbinds from the stub driver * unbinds from the stub driver
*/ */
ignore_value(virPCIDeviceReattach(dev, hostdev_mgr->activePciHostdevs, ignore_value(virPCIDeviceReattach(dev, hostdev_mgr->activePCIHostdevs,
NULL)); NULL));
} }
cleanup: cleanup:
virObjectUnlock(hostdev_mgr->activePciHostdevs); virObjectUnlock(hostdev_mgr->activePCIHostdevs);
virObjectUnlock(hostdev_mgr->inactivePciHostdevs); virObjectUnlock(hostdev_mgr->inactivePCIHostdevs);
virObjectUnref(pcidevs); virObjectUnref(pcidevs);
return ret; return ret;
} }
/* /*
* Pre-condition: inactivePciHostdevs & activePciHostdevs * Pre-condition: inactivePCIHostdevs & activePCIHostdevs
* are locked * are locked
*/ */
static void static void
@ -660,7 +660,7 @@ virHostdevReattachPCIDevice(virPCIDevicePtr dev, virHostdevManagerPtr mgr)
* successfully, it must have been inactive. * successfully, it must have been inactive.
*/ */
if (!virPCIDeviceGetManaged(dev)) { if (!virPCIDeviceGetManaged(dev)) {
if (virPCIDeviceListAdd(mgr->inactivePciHostdevs, dev) < 0) if (virPCIDeviceListAdd(mgr->inactivePCIHostdevs, dev) < 0)
virPCIDeviceFree(dev); virPCIDeviceFree(dev);
return; return;
} }
@ -675,8 +675,8 @@ virHostdevReattachPCIDevice(virPCIDevicePtr dev, virHostdevManagerPtr mgr)
} }
} }
if (virPCIDeviceReattach(dev, mgr->activePciHostdevs, if (virPCIDeviceReattach(dev, mgr->activePCIHostdevs,
mgr->inactivePciHostdevs) < 0) { mgr->inactivePCIHostdevs) < 0) {
virErrorPtr err = virGetLastError(); virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to re-attach PCI device: %s"), VIR_ERROR(_("Failed to re-attach PCI device: %s"),
err ? err->message : _("unknown error")); err ? err->message : _("unknown error"));
@ -699,8 +699,8 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
virPCIDeviceListPtr pcidevs; virPCIDeviceListPtr pcidevs;
size_t i; size_t i;
virObjectLock(hostdev_mgr->activePciHostdevs); virObjectLock(hostdev_mgr->activePCIHostdevs);
virObjectLock(hostdev_mgr->inactivePciHostdevs); virObjectLock(hostdev_mgr->inactivePCIHostdevs);
if (!(pcidevs = virHostdevGetActivePCIHostDeviceList(hostdev_mgr, if (!(pcidevs = virHostdevGetActivePCIHostDeviceList(hostdev_mgr,
hostdevs, hostdevs,
@ -721,10 +721,10 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
virPCIDevicePtr activeDev = NULL; virPCIDevicePtr activeDev = NULL;
/* delete the copy of the dev from pcidevs if it's used by /* delete the copy of the dev from pcidevs if it's used by
* other domain. Or delete it from activePciHostDevs if it had * other domain. Or delete it from activePCIHostDevs if it had
* been used by this domain. * been used by this domain.
*/ */
activeDev = virPCIDeviceListFind(hostdev_mgr->activePciHostdevs, dev); activeDev = virPCIDeviceListFind(hostdev_mgr->activePCIHostdevs, dev);
if (activeDev) { if (activeDev) {
const char *usedby_drvname; const char *usedby_drvname;
const char *usedby_domname; const char *usedby_domname;
@ -736,11 +736,11 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
} }
} }
virPCIDeviceListDel(hostdev_mgr->activePciHostdevs, dev); virPCIDeviceListDel(hostdev_mgr->activePCIHostdevs, dev);
} }
/* At this point, any device that had been used by the guest is in /* At this point, any device that had been used by the guest is in
* pcidevs, but has been removed from activePciHostdevs. * pcidevs, but has been removed from activePCIHostdevs.
*/ */
/* /*
@ -754,8 +754,8 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) { for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i); virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
if (virPCIDeviceReset(dev, hostdev_mgr->activePciHostdevs, if (virPCIDeviceReset(dev, hostdev_mgr->activePCIHostdevs,
hostdev_mgr->inactivePciHostdevs) < 0) { hostdev_mgr->inactivePCIHostdevs) < 0) {
virErrorPtr err = virGetLastError(); virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to reset PCI device: %s"), VIR_ERROR(_("Failed to reset PCI device: %s"),
err ? err->message : _("unknown error")); err ? err->message : _("unknown error"));
@ -770,8 +770,8 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
virObjectUnref(pcidevs); virObjectUnref(pcidevs);
cleanup: cleanup:
virObjectUnlock(hostdev_mgr->activePciHostdevs); virObjectUnlock(hostdev_mgr->activePCIHostdevs);
virObjectUnlock(hostdev_mgr->inactivePciHostdevs); virObjectUnlock(hostdev_mgr->inactivePCIHostdevs);
} }
int int
@ -784,8 +784,8 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,
size_t i; size_t i;
int ret = -1; int ret = -1;
virObjectLock(mgr->activePciHostdevs); virObjectLock(mgr->activePCIHostdevs);
virObjectLock(mgr->inactivePciHostdevs); virObjectLock(mgr->inactivePCIHostdevs);
for (i = 0; i < def->nhostdevs; i++) { for (i = 0; i < def->nhostdevs; i++) {
hostdev = def->hostdevs[i]; hostdev = def->hostdevs[i];
@ -820,7 +820,7 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,
virPCIDeviceSetRemoveSlot(dev, hostdev->origstates.states.pci.remove_slot); virPCIDeviceSetRemoveSlot(dev, hostdev->origstates.states.pci.remove_slot);
virPCIDeviceSetReprobe(dev, hostdev->origstates.states.pci.reprobe); virPCIDeviceSetReprobe(dev, hostdev->origstates.states.pci.reprobe);
if (virPCIDeviceListAdd(mgr->activePciHostdevs, dev) < 0) if (virPCIDeviceListAdd(mgr->activePCIHostdevs, dev) < 0)
goto cleanup; goto cleanup;
dev = NULL; dev = NULL;
} }
@ -828,8 +828,8 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,
ret = 0; ret = 0;
cleanup: cleanup:
virPCIDeviceFree(dev); virPCIDeviceFree(dev);
virObjectUnlock(mgr->activePciHostdevs); virObjectUnlock(mgr->activePCIHostdevs);
virObjectUnlock(mgr->inactivePciHostdevs); virObjectUnlock(mgr->inactivePCIHostdevs);
return ret; return ret;
} }
@ -842,7 +842,7 @@ virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr,
size_t i; size_t i;
int ret = -1; int ret = -1;
virObjectLock(mgr->activeUsbHostdevs); virObjectLock(mgr->activeUSBHostdevs);
for (i = 0; i < def->nhostdevs; i++) { for (i = 0; i < def->nhostdevs; i++) {
virUSBDevicePtr usb = NULL; virUSBDevicePtr usb = NULL;
hostdev = def->hostdevs[i]; hostdev = def->hostdevs[i];
@ -865,14 +865,14 @@ virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr,
virUSBDeviceSetUsedBy(usb, drv_name, def->name); virUSBDeviceSetUsedBy(usb, drv_name, def->name);
if (virUSBDeviceListAdd(mgr->activeUsbHostdevs, usb) < 0) { if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0) {
virUSBDeviceFree(usb); virUSBDeviceFree(usb);
goto cleanup; goto cleanup;
} }
} }
ret = 0; ret = 0;
cleanup: cleanup:
virObjectUnlock(mgr->activeUsbHostdevs); virObjectUnlock(mgr->activeUSBHostdevs);
return ret; return ret;
} }
@ -887,7 +887,7 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
virSCSIDevicePtr scsi = NULL; virSCSIDevicePtr scsi = NULL;
virSCSIDevicePtr tmp = NULL; virSCSIDevicePtr tmp = NULL;
virObjectLock(mgr->activeScsiHostdevs); virObjectLock(mgr->activeSCSIHostdevs);
for (i = 0; i < def->nhostdevs; i++) { for (i = 0; i < def->nhostdevs; i++) {
hostdev = def->hostdevs[i]; hostdev = def->hostdevs[i];
@ -904,7 +904,7 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
hostdev->shareable))) hostdev->shareable)))
goto cleanup; goto cleanup;
if ((tmp = virSCSIDeviceListFind(mgr->activeScsiHostdevs, scsi))) { if ((tmp = virSCSIDeviceListFind(mgr->activeSCSIHostdevs, scsi))) {
if (virSCSIDeviceSetUsedBy(tmp, drv_name, def->name) < 0) { if (virSCSIDeviceSetUsedBy(tmp, drv_name, def->name) < 0) {
virSCSIDeviceFree(scsi); virSCSIDeviceFree(scsi);
goto cleanup; goto cleanup;
@ -912,7 +912,7 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
virSCSIDeviceFree(scsi); virSCSIDeviceFree(scsi);
} else { } else {
if (virSCSIDeviceSetUsedBy(scsi, drv_name, def->name) < 0 || if (virSCSIDeviceSetUsedBy(scsi, drv_name, def->name) < 0 ||
virSCSIDeviceListAdd(mgr->activeScsiHostdevs, scsi) < 0) { virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0) {
virSCSIDeviceFree(scsi); virSCSIDeviceFree(scsi);
goto cleanup; goto cleanup;
} }
@ -921,7 +921,7 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
ret = 0; ret = 0;
cleanup: cleanup:
virObjectUnlock(mgr->activeScsiHostdevs); virObjectUnlock(mgr->activeSCSIHostdevs);
return ret; return ret;
} }
@ -935,12 +935,12 @@ virHostdevMarkUSBDevices(virHostdevManagerPtr mgr,
unsigned int count; unsigned int count;
virUSBDevicePtr tmp; virUSBDevicePtr tmp;
virObjectLock(mgr->activeUsbHostdevs); virObjectLock(mgr->activeUSBHostdevs);
count = virUSBDeviceListCount(list); count = virUSBDeviceListCount(list);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
virUSBDevicePtr usb = virUSBDeviceListGet(list, i); virUSBDevicePtr usb = virUSBDeviceListGet(list, i);
if ((tmp = virUSBDeviceListFind(mgr->activeUsbHostdevs, usb))) { if ((tmp = virUSBDeviceListFind(mgr->activeUSBHostdevs, usb))) {
const char *other_drvname; const char *other_drvname;
const char *other_domname; const char *other_domname;
@ -959,7 +959,7 @@ virHostdevMarkUSBDevices(virHostdevManagerPtr mgr,
} }
virUSBDeviceSetUsedBy(usb, drv_name, dom_name); virUSBDeviceSetUsedBy(usb, drv_name, dom_name);
VIR_DEBUG("Adding %03d.%03d dom=%s to activeUsbHostdevs", VIR_DEBUG("Adding %03d.%03d dom=%s to activeUSBHostdevs",
virUSBDeviceGetBus(usb), virUSBDeviceGetDevno(usb), virUSBDeviceGetBus(usb), virUSBDeviceGetDevno(usb),
dom_name); dom_name);
/* /*
@ -967,19 +967,19 @@ virHostdevMarkUSBDevices(virHostdevManagerPtr mgr,
* from the virUSBDeviceList that passed in on success, * from the virUSBDeviceList that passed in on success,
* perform rollback on failure. * perform rollback on failure.
*/ */
if (virUSBDeviceListAdd(mgr->activeUsbHostdevs, usb) < 0) if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0)
goto error; goto error;
} }
virObjectUnlock(mgr->activeUsbHostdevs); virObjectUnlock(mgr->activeUSBHostdevs);
return 0; return 0;
error: error:
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
tmp = virUSBDeviceListGet(list, i); tmp = virUSBDeviceListGet(list, i);
virUSBDeviceListSteal(mgr->activeUsbHostdevs, tmp); virUSBDeviceListSteal(mgr->activeUSBHostdevs, tmp);
} }
virObjectUnlock(mgr->activeUsbHostdevs); virObjectUnlock(mgr->activeUSBHostdevs);
return -1; return -1;
} }
@ -1196,12 +1196,12 @@ virHostdevPrepareSCSIDevices(virHostdevManagerPtr hostdev_mgr,
* and add them to driver list. However, if something goes * and add them to driver list. However, if something goes
* wrong, perform rollback. * wrong, perform rollback.
*/ */
virObjectLock(hostdev_mgr->activeScsiHostdevs); virObjectLock(hostdev_mgr->activeSCSIHostdevs);
count = virSCSIDeviceListCount(list); count = virSCSIDeviceListCount(list);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
virSCSIDevicePtr scsi = virSCSIDeviceListGet(list, i); virSCSIDevicePtr scsi = virSCSIDeviceListGet(list, i);
if ((tmp = virSCSIDeviceListFind(hostdev_mgr->activeScsiHostdevs, if ((tmp = virSCSIDeviceListFind(hostdev_mgr->activeSCSIHostdevs,
scsi))) { scsi))) {
bool scsi_shareable = virSCSIDeviceGetShareable(scsi); bool scsi_shareable = virSCSIDeviceGetShareable(scsi);
bool tmp_shareable = virSCSIDeviceGetShareable(tmp); bool tmp_shareable = virSCSIDeviceGetShareable(tmp);
@ -1221,14 +1221,14 @@ virHostdevPrepareSCSIDevices(virHostdevManagerPtr hostdev_mgr,
if (virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name) < 0) if (virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name) < 0)
goto error; goto error;
VIR_DEBUG("Adding %s to activeScsiHostdevs", virSCSIDeviceGetName(scsi)); VIR_DEBUG("Adding %s to activeSCSIHostdevs", virSCSIDeviceGetName(scsi));
if (virSCSIDeviceListAdd(hostdev_mgr->activeScsiHostdevs, scsi) < 0) if (virSCSIDeviceListAdd(hostdev_mgr->activeSCSIHostdevs, scsi) < 0)
goto error; goto error;
} }
} }
virObjectUnlock(hostdev_mgr->activeScsiHostdevs); virObjectUnlock(hostdev_mgr->activeSCSIHostdevs);
/* Loop 3: Temporary list was successfully merged with /* Loop 3: Temporary list was successfully merged with
* driver list, so steal all items to avoid freeing them * driver list, so steal all items to avoid freeing them
@ -1245,9 +1245,9 @@ virHostdevPrepareSCSIDevices(virHostdevManagerPtr hostdev_mgr,
error: error:
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
tmp = virSCSIDeviceListGet(list, i); tmp = virSCSIDeviceListGet(list, i);
virSCSIDeviceListSteal(hostdev_mgr->activeScsiHostdevs, tmp); virSCSIDeviceListSteal(hostdev_mgr->activeSCSIHostdevs, tmp);
} }
virObjectUnlock(hostdev_mgr->activeScsiHostdevs); virObjectUnlock(hostdev_mgr->activeSCSIHostdevs);
cleanup: cleanup:
virObjectUnref(list); virObjectUnref(list);
return -1; return -1;
@ -1262,7 +1262,7 @@ virHostdevReAttachUSBDevices(virHostdevManagerPtr hostdev_mgr,
{ {
size_t i; size_t i;
virObjectLock(hostdev_mgr->activeUsbHostdevs); virObjectLock(hostdev_mgr->activeUSBHostdevs);
for (i = 0; i < nhostdevs; i++) { for (i = 0; i < nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i]; virDomainHostdevDefPtr hostdev = hostdevs[i];
virUSBDevicePtr usb, tmp; virUSBDevicePtr usb, tmp;
@ -1294,7 +1294,7 @@ virHostdevReAttachUSBDevices(virHostdevManagerPtr hostdev_mgr,
* Therefore we want to steal only those devices from * Therefore we want to steal only those devices from
* the list which were taken by @name */ * the list which were taken by @name */
tmp = virUSBDeviceListFind(hostdev_mgr->activeUsbHostdevs, usb); tmp = virUSBDeviceListFind(hostdev_mgr->activeUSBHostdevs, usb);
virUSBDeviceFree(usb); virUSBDeviceFree(usb);
if (!tmp) { if (!tmp) {
@ -1308,15 +1308,15 @@ virHostdevReAttachUSBDevices(virHostdevManagerPtr hostdev_mgr,
virUSBDeviceGetUsedBy(tmp, &usedby_drvname, &usedby_domname); virUSBDeviceGetUsedBy(tmp, &usedby_drvname, &usedby_domname);
if (STREQ_NULLABLE(drv_name, usedby_drvname) && if (STREQ_NULLABLE(drv_name, usedby_drvname) &&
STREQ_NULLABLE(dom_name, usedby_domname)) { STREQ_NULLABLE(dom_name, usedby_domname)) {
VIR_DEBUG("Removing %03d.%03d dom=%s from activeUsbHostdevs", VIR_DEBUG("Removing %03d.%03d dom=%s from activeUSBHostdevs",
hostdev->source.subsys.u.usb.bus, hostdev->source.subsys.u.usb.bus,
hostdev->source.subsys.u.usb.device, hostdev->source.subsys.u.usb.device,
dom_name); dom_name);
virUSBDeviceListDel(hostdev_mgr->activeUsbHostdevs, tmp); virUSBDeviceListDel(hostdev_mgr->activeUSBHostdevs, tmp);
} }
} }
virObjectUnlock(hostdev_mgr->activeUsbHostdevs); virObjectUnlock(hostdev_mgr->activeUSBHostdevs);
} }
void void
@ -1328,7 +1328,7 @@ virHostdevReAttachSCSIDevices(virHostdevManagerPtr hostdev_mgr,
{ {
size_t i; size_t i;
virObjectLock(hostdev_mgr->activeScsiHostdevs); virObjectLock(hostdev_mgr->activeSCSIHostdevs);
for (i = 0; i < nhostdevs; i++) { for (i = 0; i < nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i]; virDomainHostdevDefPtr hostdev = hostdevs[i];
virSCSIDevicePtr scsi; virSCSIDevicePtr scsi;
@ -1357,7 +1357,7 @@ virHostdevReAttachSCSIDevices(virHostdevManagerPtr hostdev_mgr,
/* Only delete the devices which are marked as being used by @name, /* Only delete the devices which are marked as being used by @name,
* because qemuProcessStart could fail on the half way. */ * because qemuProcessStart could fail on the half way. */
if (!(tmp = virSCSIDeviceListFind(hostdev_mgr->activeScsiHostdevs, scsi))) { if (!(tmp = virSCSIDeviceListFind(hostdev_mgr->activeSCSIHostdevs, scsi))) {
VIR_WARN("Unable to find device %s:%d:%d:%d " VIR_WARN("Unable to find device %s:%d:%d:%d "
"in list of active SCSI devices", "in list of active SCSI devices",
hostdev->source.subsys.u.scsi.adapter, hostdev->source.subsys.u.scsi.adapter,
@ -1368,18 +1368,18 @@ virHostdevReAttachSCSIDevices(virHostdevManagerPtr hostdev_mgr,
continue; continue;
} }
VIR_DEBUG("Removing %s:%d:%d:%d dom=%s from activeScsiHostdevs", VIR_DEBUG("Removing %s:%d:%d:%d dom=%s from activeSCSIHostdevs",
hostdev->source.subsys.u.scsi.adapter, hostdev->source.subsys.u.scsi.adapter,
hostdev->source.subsys.u.scsi.bus, hostdev->source.subsys.u.scsi.bus,
hostdev->source.subsys.u.scsi.target, hostdev->source.subsys.u.scsi.target,
hostdev->source.subsys.u.scsi.unit, hostdev->source.subsys.u.scsi.unit,
dom_name); dom_name);
virSCSIDeviceListDel(hostdev_mgr->activeScsiHostdevs, tmp, virSCSIDeviceListDel(hostdev_mgr->activeSCSIHostdevs, tmp,
drv_name, dom_name); drv_name, dom_name);
virSCSIDeviceFree(scsi); virSCSIDeviceFree(scsi);
} }
virObjectUnlock(hostdev_mgr->activeScsiHostdevs); virObjectUnlock(hostdev_mgr->activeSCSIHostdevs);
} }
int int
@ -1388,18 +1388,18 @@ virHostdevPCINodeDeviceDetach(virHostdevManagerPtr hostdev_mgr,
{ {
int ret = -1; int ret = -1;
virObjectLock(hostdev_mgr->activePciHostdevs); virObjectLock(hostdev_mgr->activePCIHostdevs);
virObjectLock(hostdev_mgr->inactivePciHostdevs); virObjectLock(hostdev_mgr->inactivePCIHostdevs);
if (virPCIDeviceDetach(pci, hostdev_mgr->activePciHostdevs, if (virPCIDeviceDetach(pci, hostdev_mgr->activePCIHostdevs,
hostdev_mgr->inactivePciHostdevs) < 0) { hostdev_mgr->inactivePCIHostdevs) < 0) {
goto out; goto out;
} }
ret = 0; ret = 0;
out: out:
virObjectUnlock(hostdev_mgr->inactivePciHostdevs); virObjectUnlock(hostdev_mgr->inactivePCIHostdevs);
virObjectUnlock(hostdev_mgr->activePciHostdevs); virObjectUnlock(hostdev_mgr->activePCIHostdevs);
return ret; return ret;
} }
@ -1410,9 +1410,9 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr hostdev_mgr,
virPCIDevicePtr other; virPCIDevicePtr other;
int ret = -1; int ret = -1;
virObjectLock(hostdev_mgr->activePciHostdevs); virObjectLock(hostdev_mgr->activePCIHostdevs);
virObjectLock(hostdev_mgr->inactivePciHostdevs); virObjectLock(hostdev_mgr->inactivePCIHostdevs);
other = virPCIDeviceListFind(hostdev_mgr->activePciHostdevs, pci); other = virPCIDeviceListFind(hostdev_mgr->activePCIHostdevs, pci);
if (other) { if (other) {
const char *other_drvname = NULL; const char *other_drvname = NULL;
const char *other_domname = NULL; const char *other_domname = NULL;
@ -1433,14 +1433,14 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr hostdev_mgr,
virPCIDeviceReattachInit(pci); virPCIDeviceReattachInit(pci);
if (virPCIDeviceReattach(pci, hostdev_mgr->activePciHostdevs, if (virPCIDeviceReattach(pci, hostdev_mgr->activePCIHostdevs,
hostdev_mgr->inactivePciHostdevs) < 0) hostdev_mgr->inactivePCIHostdevs) < 0)
goto out; goto out;
ret = 0; ret = 0;
out: out:
virObjectUnlock(hostdev_mgr->inactivePciHostdevs); virObjectUnlock(hostdev_mgr->inactivePCIHostdevs);
virObjectUnlock(hostdev_mgr->activePciHostdevs); virObjectUnlock(hostdev_mgr->activePCIHostdevs);
return ret; return ret;
} }
@ -1450,15 +1450,15 @@ virHostdevPCINodeDeviceReset(virHostdevManagerPtr hostdev_mgr,
{ {
int ret = -1; int ret = -1;
virObjectLock(hostdev_mgr->activePciHostdevs); virObjectLock(hostdev_mgr->activePCIHostdevs);
virObjectLock(hostdev_mgr->inactivePciHostdevs); virObjectLock(hostdev_mgr->inactivePCIHostdevs);
if (virPCIDeviceReset(pci, hostdev_mgr->activePciHostdevs, if (virPCIDeviceReset(pci, hostdev_mgr->activePCIHostdevs,
hostdev_mgr->inactivePciHostdevs) < 0) hostdev_mgr->inactivePCIHostdevs) < 0)
goto out; goto out;
ret = 0; ret = 0;
out: out:
virObjectUnlock(hostdev_mgr->inactivePciHostdevs); virObjectUnlock(hostdev_mgr->inactivePCIHostdevs);
virObjectUnlock(hostdev_mgr->activePciHostdevs); virObjectUnlock(hostdev_mgr->activePCIHostdevs);
return ret; return ret;
} }

View File

@ -43,10 +43,10 @@ typedef virHostdevManager *virHostdevManagerPtr;
struct _virHostdevManager { struct _virHostdevManager {
char *stateDir; char *stateDir;
virPCIDeviceListPtr activePciHostdevs; virPCIDeviceListPtr activePCIHostdevs;
virPCIDeviceListPtr inactivePciHostdevs; virPCIDeviceListPtr inactivePCIHostdevs;
virUSBDeviceListPtr activeUsbHostdevs; virUSBDeviceListPtr activeUSBHostdevs;
virSCSIDeviceListPtr activeScsiHostdevs; virSCSIDeviceListPtr activeSCSIHostdevs;
}; };
virHostdevManagerPtr virHostdevManagerGetDefault(void); virHostdevManagerPtr virHostdevManagerGetDefault(void);