mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
Add helpers qemuPrepareHostdevPCIDevice and qemuDomainReAttachHostdevDevices
- src/qemu/qemu_driver.c: These new helpers take hostdev list and count directly rather than getting them indirectly from domain definition. This will allow reuse for the attach-device case.
This commit is contained in:
parent
8bd00c0edf
commit
f1365b558d
@ -3070,14 +3070,15 @@ cleanup:
|
||||
|
||||
|
||||
static int
|
||||
qemuPrepareHostPCIDevices(struct qemud_driver *driver,
|
||||
virDomainDefPtr def)
|
||||
qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
|
||||
virDomainHostdevDefPtr *hostdevs,
|
||||
int nhostdevs)
|
||||
{
|
||||
pciDeviceList *pcidevs;
|
||||
int i;
|
||||
int ret = -1;
|
||||
|
||||
if (!(pcidevs = qemuGetPciHostDeviceList(def->hostdevs, def->nhostdevs)))
|
||||
if (!(pcidevs = qemuGetPciHostDeviceList(hostdevs, nhostdevs)))
|
||||
return -1;
|
||||
|
||||
/* We have to use 3 loops here. *All* devices must
|
||||
@ -3127,6 +3128,13 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
qemuPrepareHostPCIDevices(struct qemud_driver *driver,
|
||||
virDomainDefPtr def)
|
||||
{
|
||||
return qemuPrepareHostdevPCIDevices(driver, def->hostdevs, def->nhostdevs);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuPrepareHostUSBDevices(struct qemud_driver *driver ATTRIBUTE_UNUSED,
|
||||
@ -3220,16 +3228,14 @@ qemudReattachManagedDevice(pciDevice *dev, struct qemud_driver *driver)
|
||||
}
|
||||
|
||||
static void
|
||||
qemuDomainReAttachHostDevices(struct qemud_driver *driver,
|
||||
virDomainDefPtr def)
|
||||
qemuDomainReAttachHostdevDevices(struct qemud_driver *driver,
|
||||
virDomainHostdevDefPtr *hostdevs,
|
||||
int nhostdevs)
|
||||
{
|
||||
pciDeviceList *pcidevs;
|
||||
int i;
|
||||
|
||||
if (!def->nhostdevs)
|
||||
return;
|
||||
|
||||
if (!(pcidevs = qemuGetPciHostDeviceList(def->hostdevs, def->nhostdevs))) {
|
||||
if (!(pcidevs = qemuGetPciHostDeviceList(hostdevs, nhostdevs))) {
|
||||
virErrorPtr err = virGetLastError();
|
||||
VIR_ERROR(_("Failed to allocate pciDeviceList: %s"),
|
||||
err ? err->message : _("unknown error"));
|
||||
@ -3263,6 +3269,16 @@ qemuDomainReAttachHostDevices(struct qemud_driver *driver,
|
||||
pciDeviceListFree(pcidevs);
|
||||
}
|
||||
|
||||
static void
|
||||
qemuDomainReAttachHostDevices(struct qemud_driver *driver,
|
||||
virDomainDefPtr def)
|
||||
{
|
||||
if (!def->nhostdevs)
|
||||
return;
|
||||
|
||||
qemuDomainReAttachHostdevDevices(driver, def->hostdevs, def->nhostdevs);
|
||||
}
|
||||
|
||||
static const char *const defaultDeviceACL[] = {
|
||||
"/dev/null", "/dev/full", "/dev/zero",
|
||||
"/dev/random", "/dev/urandom",
|
||||
|
Loading…
Reference in New Issue
Block a user