mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +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
|
static int
|
||||||
qemuPrepareHostPCIDevices(struct qemud_driver *driver,
|
qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
|
||||||
virDomainDefPtr def)
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
|
int nhostdevs)
|
||||||
{
|
{
|
||||||
pciDeviceList *pcidevs;
|
pciDeviceList *pcidevs;
|
||||||
int i;
|
int i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(pcidevs = qemuGetPciHostDeviceList(def->hostdevs, def->nhostdevs)))
|
if (!(pcidevs = qemuGetPciHostDeviceList(hostdevs, nhostdevs)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* We have to use 3 loops here. *All* devices must
|
/* We have to use 3 loops here. *All* devices must
|
||||||
@ -3127,6 +3128,13 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuPrepareHostPCIDevices(struct qemud_driver *driver,
|
||||||
|
virDomainDefPtr def)
|
||||||
|
{
|
||||||
|
return qemuPrepareHostdevPCIDevices(driver, def->hostdevs, def->nhostdevs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuPrepareHostUSBDevices(struct qemud_driver *driver ATTRIBUTE_UNUSED,
|
qemuPrepareHostUSBDevices(struct qemud_driver *driver ATTRIBUTE_UNUSED,
|
||||||
@ -3220,16 +3228,14 @@ qemudReattachManagedDevice(pciDevice *dev, struct qemud_driver *driver)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qemuDomainReAttachHostDevices(struct qemud_driver *driver,
|
qemuDomainReAttachHostdevDevices(struct qemud_driver *driver,
|
||||||
virDomainDefPtr def)
|
virDomainHostdevDefPtr *hostdevs,
|
||||||
|
int nhostdevs)
|
||||||
{
|
{
|
||||||
pciDeviceList *pcidevs;
|
pciDeviceList *pcidevs;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!def->nhostdevs)
|
if (!(pcidevs = qemuGetPciHostDeviceList(hostdevs, nhostdevs))) {
|
||||||
return;
|
|
||||||
|
|
||||||
if (!(pcidevs = qemuGetPciHostDeviceList(def->hostdevs, def->nhostdevs))) {
|
|
||||||
virErrorPtr err = virGetLastError();
|
virErrorPtr err = virGetLastError();
|
||||||
VIR_ERROR(_("Failed to allocate pciDeviceList: %s"),
|
VIR_ERROR(_("Failed to allocate pciDeviceList: %s"),
|
||||||
err ? err->message : _("unknown error"));
|
err ? err->message : _("unknown error"));
|
||||||
@ -3263,6 +3269,16 @@ qemuDomainReAttachHostDevices(struct qemud_driver *driver,
|
|||||||
pciDeviceListFree(pcidevs);
|
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[] = {
|
static const char *const defaultDeviceACL[] = {
|
||||||
"/dev/null", "/dev/full", "/dev/zero",
|
"/dev/null", "/dev/full", "/dev/zero",
|
||||||
"/dev/random", "/dev/urandom",
|
"/dev/random", "/dev/urandom",
|
||||||
|
Loading…
Reference in New Issue
Block a user