Dan Kenigsberg has uploaded a new change for review.
Change subject: sriov hook: allow VFs with nonzero pci domain
......................................................................
sriov hook: allow VFs with nonzero pci domain
This patch is the smallest change needed to expose a host nic with non-zero pci
domain to a guest.
The hook does a questionable detour via libvirt in order to extract the pci
address of the specified nic. This begs for simplification in a follow up patch.
Change-Id: Ie2b75134a7f6bdb10f8d808b4dcda6856befe705
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm_hooks/sriov/before_vm_start.py
1 file changed, 9 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/28162/1
diff --git a/vdsm_hooks/sriov/before_vm_start.py b/vdsm_hooks/sriov/before_vm_start.py
index c23797b..e3b1de1 100755
--- a/vdsm_hooks/sriov/before_vm_start.py
+++ b/vdsm_hooks/sriov/before_vm_start.py
@@ -26,7 +26,7 @@
def getDeviceDetails(addr):
''' investigate device by its address and return
- [bus, slot, function] list
+ [domain, bus, slot, function] list
'''
connection = libvirtconnection.get(None)
@@ -34,6 +34,8 @@
devXml = minidom.parseString(nodeDevice.XMLDesc(0))
+ domain = hex(int(
+ devXml.getElementsByTagName('domain')[0].firstChild.nodeValue))
bus = hex(int(devXml.getElementsByTagName('bus')[0].firstChild.nodeValue))
slot = hex(int(
devXml.getElementsByTagName('slot')[0]
@@ -45,10 +47,10 @@
sys.stderr.write('sriov: bus=%s slot=%s function=%s\n' %
(bus, slot, function))
- return (bus, slot, function)
+ return (domain, bus, slot, function)
-def createSriovElement(domxml, bus, slot, function):
+def createSriovElement(domxml, domain, bus, slot, function):
'''
create host device element for libvirt domain xml:
@@ -69,7 +71,7 @@
address = domxml.createElement('address')
address.setAttribute('type', 'pci')
- address.setAttribute('domain', '0')
+ address.setAttribute('domain', domain)
address.setAttribute('bus', bus)
address.setAttribute('slot', slot)
address.setAttribute('function', function)
@@ -139,9 +141,10 @@
devpath = os.path.realpath(SYS_NIC_PATH % nic + '/device')
addr = getPciAddress(devpath)
- bus, slot, function = getDeviceDetails(addr)
+ domain, bus, slot, function = getDeviceDetails(addr)
- interface = createSriovElement(domxml, bus, slot, function)
+ interface = createSriovElement(
+ domxml, domain, bus, slot, function)
sys.stderr.write('sriov: VF %s xml: %s\n' %
(nic, interface.toxml()))
--
To view, visit
http://gerrit.ovirt.org/28162
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2b75134a7f6bdb10f8d808b4dcda6856befe705
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>