summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorguillaume-thouvenin <guillaume.thouvenin@bull.net>2013-12-23 21:07:48 +0100
committerguillaume-thouvenin <guillaume.thouvenin@bull.net>2014-02-17 11:56:18 +0100
commitd5b8d5b18d3077060345a4728a26dde51d834af3 (patch)
tree6f220e12b2d444d5c9feea543e7ab3530dbdf543 /plugins
parent5aa0cac98fba1eddc09ecd20bffc4f495d899a3f (diff)
downloadnova-d5b8d5b18d3077060345a4728a26dde51d834af3.tar.gz
XenAPI: Add the support for updating the status of the host.
We added a function into the xenhost plugin to get information about PCI devices. Roughly we run the lspci command on dom0. This information will be used to get the list of pci devices that are passed on the pciback.hide dom0 command line. The hide option is used to hide the devices from the normal guest drivers and assign them to the pciback kernel driver at boot on dom0 instead of their normal driver. We will parse the output of the lspci command to find which device is using the pciback kernel driver and thus to know if it has been passed to the pciback.hide option. This information will be used to perform the match with the list of pci devices provided in pci_whitelist into /etc/nova/nova.conf. Implements: blueprint pci-passthrough-xenapi Change-Id: I465fc5d29f3c47ab0079adcfcc2d7d6501bd4b20
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/nova_plugin_version3
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost37
2 files changed, 36 insertions, 4 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/nova_plugin_version b/plugins/xenserver/xenapi/etc/xapi.d/plugins/nova_plugin_version
index 921847bc97..12a58bcb23 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/nova_plugin_version
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/nova_plugin_version
@@ -24,7 +24,8 @@ import utils
# 1.0 - Initial version.
# 1.1 - New call to check GC status
-PLUGIN_VERSION = "1.1"
+# 1.2 - Added support for pci passthrough devices
+PLUGIN_VERSION = "1.2"
def get_version(session):
return PLUGIN_VERSION
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
index e62664480a..b51d6db928 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost
@@ -27,8 +27,8 @@ except ImportError:
import simplejson as json
import logging
import re
-import time
import sys
+import time
import xmlrpclib
import utils
@@ -403,11 +403,42 @@ def query_gc(session, sr_uuid, vdi_uuid):
# Example output: "Currently running: True"
return result[19:].strip() == "True"
+def get_pci_device_details(session):
+ """Returns a string that is a list of pci devices with details.
+
+ This string is obtained by running the command lspci. With -vmm option,
+ it dumps PCI device data in machine readable form. This verbose format
+ display a sequence of records separated by a blank line. We will also
+ use option "-n" to get vendor_id and device_id as numeric values and
+ the "-k" option to get the kernel driver used if any.
+ """
+ return _run_command(["lspci", "-vmmnk"])
+
+
+def get_pci_type(session, pci_device):
+ """Returns the type of the PCI device (type-PCI, type-VF or type-PF).
+
+ pci-device -- The address of the pci device
+ """
+ # We need to add the domain if it is missing
+ if pci_device.count(':') == 1:
+ pci_device = "0000:" + pci_device
+ output = _run_command(["ls", "/sys/bus/pci/devices/" + pci_device + "/"])
+
+ if "physfn" in output:
+ return "type-VF"
+ if "virtfn" in output:
+ return "type-PF"
+ return "type-PCI"
+
+
if __name__ == "__main__":
# Support both serialized and non-serialized plugin approaches
_, methodname = xmlrpclib.loads(sys.argv[1])
- if methodname in ['query_gc']:
- utils.register_plugin_calls(query_gc)
+ if methodname in ['query_gc', 'get_pci_device_details', 'get_pci_type']:
+ utils.register_plugin_calls(query_gc,
+ get_pci_device_details,
+ get_pci_type)
XenAPIPlugin.dispatch(
{"host_data": host_data,