pci: Introduce virPCIStubDriver enumeration

This replaces the virPCIKnownStubs string array that was used
internally for stub driver validation.

Advantages:

  * possible values are well-defined
  * typos in driver names will be detected at compile time
  * avoids having several copies of the same string around
  * no error checking required when setting / getting value

The names used mirror those in the
virDomainHostdevSubsysPCIBackendType enumeration.
This commit is contained in:
Andrea Bolognani
2015-10-23 11:54:07 +02:00
parent e1b2458364
commit 6d9cdd2a57
9 changed files with 99 additions and 91 deletions

View File

@@ -97,9 +97,10 @@ myInit(void)
}
for (i = 0; i < nhostdevs; i++) {
if (!(dev[i] = virPCIDeviceNew(0, 0, i + 1, 0)) ||
virPCIDeviceSetStubDriver(dev[i], "pci-stub") < 0)
if (!(dev[i] = virPCIDeviceNew(0, 0, i + 1, 0)))
goto cleanup;
virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_KVM);
}
if (VIR_ALLOC(mgr) < 0)