1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

Use pciDeviceIsAssignable in qemu driver

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2009-12-22 18:21:16 +01:00
parent 379eb3956c
commit a3e1f04b76
6 changed files with 23 additions and 2 deletions

View File

@ -36,6 +36,7 @@ module Libvirtd_qemu =
| str_array_entry "cgroup_device_acl"
| str_entry "save_image_format"
| str_entry "hugetlbfs_mount"
| bool_entry "relaxed_acs_check"
(* Each enty in the config is one of the following three ... *)
let entry = vnc_entry

View File

@ -157,3 +157,9 @@
# This currently requires ebtables to be installed.
#
# mac_filter = 1
# By default, PCI devices below non-ACS switch are not allowed to be assigned
# to guests. By setting relaxed_acs_check to 1 such devices will be allowed to
# be assigned to guests.
#
# relaxed_acs_check = 1

View File

@ -340,6 +340,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
}
}
p = virConfGetValue (conf, "relaxed_acs_check");
CHECK_TYPE ("relaxed_acs_check", VIR_CONF_LONG);
if (p) driver->relaxedACS = p->l;
virConfFree (conf);
return 0;
}

View File

@ -125,6 +125,8 @@ struct qemud_driver {
unsigned int macFilter : 1;
ebtablesContext *ebtables;
unsigned int relaxedACS : 1;
virCapsPtr caps;
/* An array of callbacks */

View File

@ -2192,6 +2192,9 @@ qemuPrepareHostDevices(virConnectPtr conn,
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
if (!pciDeviceIsAssignable(conn, dev, !driver->relaxedACS))
goto cleanup;
if (pciDeviceGetManaged(dev) &&
pciDettachDevice(conn, dev) < 0)
goto cleanup;
@ -5792,7 +5795,8 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn,
if (!pci)
return -1;
if ((hostdev->managed && pciDettachDevice(conn, pci) < 0) ||
if (!pciDeviceIsAssignable(conn, pci, !driver->relaxedACS) ||
(hostdev->managed && pciDettachDevice(conn, pci) < 0) ||
pciResetDevice(conn, pci, driver->activePciHostdevs) < 0) {
pciFreeDevice(conn, pci);
return -1;

View File

@ -93,6 +93,8 @@ cgroup_device_acl = [ \"/dev/null\", \"/dev/full\", \"/dev/zero\" ]
save_image_format = \"gzip\"
hugetlbfs_mount = \"/dev/hugepages\"
relaxed_acs_check = 1
"
test Libvirtd_qemu.lns get conf =
@ -195,4 +197,6 @@ hugetlbfs_mount = \"/dev/hugepages\"
{ "#empty" }
{ "save_image_format" = "gzip" }
{ "#empty" }
{ "hugetlbfs_mount" = "/dev/hugepages" }
{ "hugetlbfs_mount" = "/dev/hugepages" }
{ "#empty" }
{ "relaxed_acs_check" = "1" }