Change in vdsm[master]: concurrent: Add support for target function kwargs
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: concurrent: Add support for target function kwargs
......................................................................
concurrent: Add support for target function kwargs
Turns out we pass kwargs to some threads, so we must support this
syntax.
Change-Id: I5bcc24686279f9511baa83e64ac186533513cbd3
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/concurrent.py
M tests/concurrentTests.py
2 files changed, 19 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/45470/1
diff --git a/lib/vdsm/concurrent.py b/lib/vdsm/concurrent.py
index 5a9df85..6de35c7 100644
--- a/lib/vdsm/concurrent.py
+++ b/lib/vdsm/concurrent.py
@@ -151,7 +151,7 @@
return results
-def thread(func, args=(), name=None, daemon=True, logger=None):
+def thread(func, args=(), kwargs=None, name=None, daemon=True, logger=None):
"""
Create a thread for runnning func with args.
@@ -161,6 +161,8 @@
args Arguments to pass to func
+ kwargs Keyword arguments to pass to func
+
name If set, set thread name.
daemon If True, create a daemon thread.
@@ -168,9 +170,12 @@
logger If set, unhandled exception will be logged on this logger.
Otherwise the root logger will be used.
"""
+ if kwargs is None:
+ kwargs = {}
+
@utils.traceback(on=logger)
def run():
- return func(*args)
+ return func(*args, **kwargs)
thread = threading.Thread(target=run, name=name)
thread.daemon = daemon
diff --git a/tests/concurrentTests.py b/tests/concurrentTests.py
index 62ca833..d6c212a 100644
--- a/tests/concurrentTests.py
+++ b/tests/concurrentTests.py
@@ -229,3 +229,15 @@
t.start()
t.join()
self.assertEqual((1, 2, 3), self.args)
+
+ def test_pass_kwargs(self):
+ self.kwargs = ()
+
+ def run(**kwargs):
+ self.kwargs = kwargs
+
+ kwargs = {'a': 1, 'b': 2}
+ t = concurrent.thread(run, kwargs=kwargs)
+ t.start()
+ t.join()
+ self.assertEqual(kwargs, self.kwargs)
--
To view, visit https://gerrit.ovirt.org/45470
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5bcc24686279f9511baa83e64ac186533513cbd3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: spec: conflict with plain QEMU
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: spec: conflict with plain QEMU
......................................................................
spec: conflict with plain QEMU
The only stack supported by VDSM is
VDSM - libvirt - qemu-kvm{ev,rhev}
Multiple qemu versions are not supported, yet some
users managed to install them.
This triggers a bug in the caps.getEmulatedMachines()
function.
We will improve that function in a future patch to
make it more robust, but first we should enforce
the recommended configuration.
NOTE: this patch is relevant for RPM systems only,
where there is distinction between qemu and qemu-kvm.
Debian-based system do not have this split, so
the misconfiguration is not possible.
https://bugzilla.redhat.com/1239258
Change-Id: Ib0cbc400f2a6711bc014d67931a4136c871bdd46
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm.spec.in
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/45323/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 72e7df6..777b832 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -210,6 +210,7 @@
Requires: qemu-kvm >= 2:2.0.0-1
Requires: qemu-img >= 2:2.0.0-1
%endif # rhel
+Conflicts: qemu
# GlusterFS client-side RPMs needed for Gluster SD
%if 0%{?with_gluster}
--
To view, visit https://gerrit.ovirt.org/45323
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib0cbc400f2a6711bc014d67931a4136c871bdd46
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: hostdev: add udev rules for USB devices
by Martin Polednik
Martin Polednik has posted comments on this change.
Change subject: hostdev: add udev rules for USB devices
......................................................................
Patch Set 8:
(1 comment)
https://gerrit.ovirt.org/#/c/44679/8/vdsm/supervdsmServer
File vdsm/supervdsmServer:
Line 398:
Line 399: self.udevTriggerUSB(bus, device)
Line 400:
Line 401: @logDecorator
Line 402: def releaseAppropriateUSBDevice(self, bus, device):
> See my comments about this in older version of this patch.
Addressed in https://gerrit.ovirt.org/#/c/45420/
Line 403: rule_file = _UDEV_RULE_FILE_NAME_USB % (bus, device)
Line 404:
Line 405: rule = ('SUBSYSTEM=="usb", ATTRS{{busnum}}=="{}", '
Line 406: 'ATTRS{{devnum}}=="{}", '
--
To view, visit https://gerrit.ovirt.org/44679
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I1f72f63186187254cd4aded0a2e6c396001ca28b
Gerrit-PatchSet: 8
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Michal Skrivanek <michal.skrivanek(a)redhat.com>
Gerrit-Reviewer: Michal Skrivanek <mskrivan(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-HasComments: Yes
8 years, 7 months
Change in vdsm[master]: hostdev: add udev rules for USB devices
by automation@ovirt.org
automation(a)ovirt.org has posted comments on this change.
Change subject: hostdev: add udev rules for USB devices
......................................................................
Patch Set 10:
* Update tracker::IGNORE, no Bug-Url found
* Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url.
* Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
--
To view, visit https://gerrit.ovirt.org/44679
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I1f72f63186187254cd4aded0a2e6c396001ca28b
Gerrit-PatchSet: 10
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Michal Skrivanek <michal.skrivanek(a)redhat.com>
Gerrit-Reviewer: Michal Skrivanek <mskrivan(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-HasComments: No
8 years, 7 months
Change in vdsm[master]: supervdsm: rename appropriateDevice to appropriateMultipathD...
by Martin Polednik
Martin Polednik has uploaded a new change for review.
Change subject: supervdsm: rename appropriateDevice to appropriateMultipathDevice
......................................................................
supervdsm: rename appropriateDevice to appropriateMultipathDevice
The appropriateDevice method inside supervdsm is inappropriately named
as it is only used for multipath devices. This patch specializes the
name so it is possible to write more of these specialized methods
with correct specific names.
Change-Id: I8014dbfa333bc637914080082c6c186ed39594af
Signed-off-by: Martin Polednik <mpolednik(a)redhat.com>
---
M vdsm/storage/hsm.py
M vdsm/supervdsmServer
2 files changed, 4 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/20/45420/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index cfee89f..2ab7b20 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3150,7 +3150,7 @@
Warning: Internal use only.
"""
- supervdsm.getProxy().appropriateDevice(guid, thiefId)
+ supervdsm.getProxy().appropriateMultipathDevice(guid, thiefId)
supervdsm.getProxy().udevTriggerMultipath(guid)
devPath = os.path.join(devicemapper.DMPATH_PREFIX, guid)
utils.retry(partial(fileUtils.validateQemuReadable, devPath),
@@ -3169,7 +3169,7 @@
"""
Warning: Internal use only.
"""
- fails = supervdsm.getProxy().rmAppropriateRules(thiefId)
+ fails = supervdsm.getProxy().rmAppropriateMultipathRules(thiefId)
if fails:
self.log.error("Failed to remove the following rules: %s", fails)
diff --git a/vdsm/supervdsmServer b/vdsm/supervdsmServer
index d431ac2..3d64843 100755
--- a/vdsm/supervdsmServer
+++ b/vdsm/supervdsmServer
@@ -290,7 +290,7 @@
'out %s\nerr %s' % (e.out, e.err))
@logDecorator
- def appropriateDevice(self, guid, thiefId):
+ def appropriateMultipathDevice(self, guid, thiefId):
ruleFile = _UDEV_RULE_FILE_NAME % (guid, thiefId)
# WARNING: we cannot use USER, GROUP and MODE since using any of them
# will change the selinux label to the default, causing vms to pause.
@@ -302,7 +302,7 @@
rf.write(rule)
@logDecorator
- def rmAppropriateRules(self, thiefId):
+ def rmAppropriateMultipathRules(self, thiefId):
re_apprDevRule = "^" + _UDEV_RULE_FILE_PREFIX + ".*?-" + thiefId + \
_UDEV_RULE_FILE_EXT + "$"
rules = [os.path.join(_UDEV_RULE_FILE_DIR, r) for r in
--
To view, visit https://gerrit.ovirt.org/45420
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8014dbfa333bc637914080082c6c186ed39594af
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: supervdsm: move udevadm methods to udevadm module
by Martin Polednik
Martin Polednik has uploaded a new change for review.
Change subject: supervdsm: move udevadm methods to udevadm module
......................................................................
supervdsm: move udevadm methods to udevadm module
udevadm module already exists, so there is no reason to keep the
method logic in supervdsm.
Change-Id: Ie2b72b580e77872068ae6357410d940a83626b05
Signed-off-by: Martin Polednik <mpolednik(a)redhat.com>
---
M lib/vdsm/udevadm.py
M vdsm/supervdsmServer
2 files changed, 52 insertions(+), 42 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/08/44808/1
diff --git a/lib/vdsm/udevadm.py b/lib/vdsm/udevadm.py
index 2e9bdc2..9c58075 100644
--- a/lib/vdsm/udevadm.py
+++ b/lib/vdsm/udevadm.py
@@ -19,10 +19,14 @@
#
from __future__ import absolute_import
+import errno
import logging
from . import utils
+from vdsm.constants import EXT_UDEVADM
+
_UDEVADM = utils.CommandPath("udevadm", "/sbin/udevadm", "/usr/sbin/udevadm")
+_UDEV_WITH_RELOAD_VERSION = 181
class Error(Exception):
@@ -61,6 +65,50 @@
logging.error("%s", e)
+def trigger(attr_matches=(), property_matches=()):
+ _reload()
+ cmd = [EXT_UDEVADM, 'trigger', '--verbose', '--action', 'change']
+
+ for name, value in property_matches:
+ cmd.append('--property-match={}={}'.format(name, value))
+
+ for name, value in attr_matches:
+ cmd.append('--property-match={}={}'.format(name, value))
+
+ rc, out, err = utils.execCmd(cmd)
+ if rc:
+ raise OSError(errno.EINVAL, 'Could not trigger change '
+ 'out %s\nerr %s' % (out, err))
+
+
+def _reload():
+ if _has_reload():
+ reload = "--reload"
+ else:
+ reload = "--reload-rules"
+ cmd = [EXT_UDEVADM, 'control', reload]
+ rc, out, err = utils.execCmd(cmd)
+ if rc:
+ logging.error("Udevadm reload-rules command failed rc=%s, "
+ "out=\"%s\", err=\"%s\"", rc, out, err)
+ raise OSError(errno.EINVAL, "Could not reload rules")
+
+
+(a)utils.memoized
+def _version():
+ cmd = [EXT_UDEVADM, '--version']
+ rc, out, err = utils.execCmd(cmd)
+ if rc:
+ logging.error("Udevadm version command failed rc=%s, "
+ "out=\"%s\", err=\"%s\"", rc, out, err)
+ raise RuntimeError("Could not get udev version number")
+ return int(out[0])
+
+
+def _has_reload():
+ return _version() > _UDEV_WITH_RELOAD_VERSION
+
+
def _run_command(args):
cmd = [_UDEVADM.cmd]
cmd.extend(args)
diff --git a/vdsm/supervdsmServer b/vdsm/supervdsmServer
index 57b7b4d..17f12f3 100755
--- a/vdsm/supervdsmServer
+++ b/vdsm/supervdsmServer
@@ -35,6 +35,7 @@
from vdsm.infra import zombiereaper
from caps import Architecture
+from vdsm import udevadm
import numaUtils
LOG_CONF_PATH = "/etc/vdsm/svdsm.logger.conf"
@@ -73,7 +74,7 @@
from storage import multipath
from storage.fileUtils import chown, resolveGid, resolveUid
from storage.fileUtils import validateAccess as _validateAccess
-from vdsm.constants import METADATA_GROUP, EXT_CHOWN, EXT_UDEVADM, \
+from vdsm.constants import METADATA_GROUP, EXT_CHOWN, \
DISKIMAGE_USER, DISKIMAGE_GROUP, \
P_LIBVIRT_VMCHANNELS, P_OVIRT_VMCONSOLES, \
VDSM_USER, QEMU_PROCESS_USER, QEMU_PROCESS_GROUP
@@ -119,8 +120,6 @@
class _SuperVdsm(object):
-
- UDEV_WITH_RELOAD_VERSION = 181
log = logging.getLogger("SuperVdsm.ServerCallback")
@@ -283,20 +282,8 @@
return setSafeNetworkConfig()
@logDecorator
- def udevTrigger(self, attr_matches=(), property_matches=()):
- self.__udevReloadRules()
- cmd = [EXT_UDEVADM, 'trigger', '--verbose', '--action', 'change']
-
- for name, value in property_matches:
- cmd.append('--property-match={}={}'.format(name, value))
-
- for name, value in attr_matches:
- cmd.append('--property-match={}={}'.format(name, value))
-
- rc, out, err = utils.execCmd(cmd)
- if rc:
- raise OSError(errno.EINVAL, 'Could not trigger change '
- 'out %s\nerr %s' % (out, err))
+ def udevTrigger(self, *args, **kwargs):
+ udevadm.trigger(*args, **kwargs)
@logDecorator
def appropriateDevice(self, guid, thiefId):
@@ -453,31 +440,6 @@
@logDecorator
def set_rp_filter_strict(self, dev):
sysctl.set_rp_filter_strict(dev)
-
- def __udevReloadRules(self):
- if self.__udevOperationReload():
- reload = "--reload"
- else:
- reload = "--reload-rules"
- cmd = [EXT_UDEVADM, 'control', reload]
- rc, out, err = utils.execCmd(cmd)
- if rc:
- self.log.error("Udevadm reload-rules command failed rc=%s, "
- "out=\"%s\", err=\"%s\"", rc, out, err)
- raise OSError(errno.EINVAL, "Could not reload rules")
-
- @utils.memoized
- def __udevVersion(self):
- cmd = [EXT_UDEVADM, '--version']
- rc, out, err = utils.execCmd(cmd)
- if rc:
- self.log.error("Udevadm version command failed rc=%s, "
- " out=\"%s\", err=\"%s\"", rc, out, err)
- raise RuntimeError("Could not get udev version number")
- return int(out[0])
-
- def __udevOperationReload(self):
- return self.__udevVersion() > self.UDEV_WITH_RELOAD_VERSION
def terminate(signo, frame):
--
To view, visit https://gerrit.ovirt.org/44808
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2b72b580e77872068ae6357410d940a83626b05
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: virt: remove duplicate connection in hostdevTests
by Martin Polednik
Martin Polednik has uploaded a new change for review.
Change subject: virt: remove duplicate connection in hostdevTests
......................................................................
virt: remove duplicate connection in hostdevTests
hostdevTests included a fake Connection, similar to the one in
vmfakelib. This patch creates new decorator, that is able to inject
devices without needing another Connection and without having to hack
the vmfakelib connection.
Change-Id: I936766c8fd4c87175dcc3987d7ae5c64ff5675ea
Signed-off-by: Martin Polednik <mpolednik(a)redhat.com>
---
M tests/hostdevTests.py
M tests/vmfakelib.py
2 files changed, 33 insertions(+), 17 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/46/40946/1
diff --git a/tests/hostdevTests.py b/tests/hostdevTests.py
index 6cf7b78..94e06cd 100644
--- a/tests/hostdevTests.py
+++ b/tests/hostdevTests.py
@@ -204,22 +204,6 @@
{'params': DEVICES_PARSED['usb_1_1']}}}
-class Connection(fake.Connection):
-
- def __init__(self, *args):
- self._virNodeDevices = []
-
- for device in _PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES:
- self._virNodeDevices.append(
- fake.Connection.nodeDeviceLookupByName(device))
-
- def listAllDevices(self, flags=0):
- return self._virNodeDevices
-
- def nodeDeviceLookupByName(self, device_xml_filename):
- return fake.Connection.nodeDeviceLookupByName(device_xml_filename)
-
-
def _fake_totalvfs(device_name):
if device_name == 'pci_0000_05_00_1':
return 7
@@ -228,7 +212,7 @@
@expandPermutations
-@MonkeyClass(libvirtconnection, 'get', Connection)
+@MonkeyClass(libvirtconnection, 'get', fake.Connection)
@MonkeyClass(hostdev, '_sriov_totalvfs', _fake_totalvfs)
@MonkeyClass(hooks, 'after_hostdev_list_by_caps', lambda json: json)
class HostdevTests(TestCaseBase):
@@ -265,6 +249,7 @@
self.assertEquals(_NET_DEVICE_PARSED, deviceXML)
+ @fake.set_device_pool(_PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES)
def testGetDevicesFromLibvirt(self):
libvirt_devices = hostdev._get_devices_from_libvirt()
@@ -274,6 +259,7 @@
len(_USB_DEVICES) +
len(_SCSI_DEVICES))
+ @fake.set_device_pool(_PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES)
@permutations([[''], [('pci',)], [('usb_device',)],
[('pci', 'usb_device')]])
def testListByCaps(self, caps):
diff --git a/tests/vmfakelib.py b/tests/vmfakelib.py
index a77d15e..9c15325 100644
--- a/tests/vmfakelib.py
+++ b/tests/vmfakelib.py
@@ -20,6 +20,7 @@
#
from contextlib import contextmanager
+from functools import wraps
import logging
import os
import threading
@@ -49,6 +50,9 @@
def listAllNetworks(self, *args):
return []
+ def listAllDevices(self, flags=0):
+ pass
+
@staticmethod
def nodeDeviceLookupByName(name):
"""
@@ -71,6 +75,32 @@
return VirNodeDeviceStub(device_xml)
+def set_device_pool(devices):
+ """
+ Decorator to inject new listAllDevices method, that will return
+ VirNodeDeviceStubs from device names specified in the argument.
+ """
+ def decorator(func):
+ @wraps(func)
+ def wrapper(*args, **kwargs):
+ vir_node_devices = []
+
+ for device in devices:
+ vir_node_devices.append(
+ Connection.nodeDeviceLookupByName(device)
+ )
+
+ def listAllDevices(_, flags=0):
+ return vir_node_devices
+
+ with MonkeyPatchScope(
+ [(libvirtconnection.get, 'listAllDevices', listAllDevices)]
+ ):
+ return func(*args, **kwargs)
+ return wrapper
+ return decorator
+
+
class ClientIF(clientIF.clientIF):
def __init__(self):
# the bare minimum initialization for our test needs.
--
To view, visit https://gerrit.ovirt.org/40946
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I936766c8fd4c87175dcc3987d7ae5c64ff5675ea
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: vdsm: expose release call to engine and via vdsClient
by Martin Polednik
Martin Polednik has uploaded a new change for review.
Change subject: vdsm: expose release call to engine and via vdsClient
......................................................................
vdsm: expose release call to engine and via vdsClient
Release would, in ideal world, always be called when VM dies.
Exposing this verbs gives users tool to force release if series
of events lead to situation that should never occur(tm).
Change-Id: I920ae8b5c82134f09a12e56a529fa3d30fd7ab53
Signed-off-by: Martin Polednik <mpolednik(a)redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/rpc/BindingXMLRPC.py
3 files changed, 17 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/94/32394/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index 783afa6..85d00cd 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -521,6 +521,10 @@
def do_getAllVmStats(self, args):
return self.ExecAndExit(self.s.getAllVmStats())
+ def hostdevRelease(self, args):
+ device_name = args[0]
+ return self.ExecAndExit(self.s.hostdevRelease(device_name))
+
def desktopLogin(self, args):
vmId, domain, user, password = tuple(args[:4])
if len(args) > 4:
@@ -2149,6 +2153,10 @@
('',
'Get Statistics info for all existing VMs'
)),
+ 'hostdevRelease': (serv.do_hostdevRelease,
+ ('<deviceName>',
+ 'Release specified device from any VMs on the host'
+ )),
'getVGList': (serv.getVGList,
('storageType',
'List of all VGs.'
diff --git a/vdsm/API.py b/vdsm/API.py
index 8da6030..6269d72 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1296,6 +1296,10 @@
devices = hostdev.list_by_caps(self._cif.vmContainer, caps)
return {'status': doneCode, 'deviceList': devices}
+ def hostdevRelease(self, device_name):
+ hostdev.release(device_name)
+ return {'status': doneCode}
+
def getStats(self):
"""
Report host statistics.
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index 4c1ef20..bdd0886 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -487,6 +487,10 @@
api = API.Global()
return api.hostdevListByCaps(caps)
+ def hostdevRelease(self, device_name):
+ api = API.Global()
+ return api.hostdevRelease(device_name)
+
def vmGetIoTunePolicy(self, vmId):
vm = API.VM(vmId)
return vm.getIoTunePolicy()
@@ -1004,6 +1008,7 @@
(self.vmGetStats, 'getVmStats'),
(self.getAllVmStats, 'getAllVmStats'),
(self.hostdevListByCaps, 'hostdevListByCaps'),
+ (self.hostdevRelease, 'hostdevRelease'),
(self.vmMigrationCreate, 'migrationCreate'),
(self.vmDesktopLogin, 'desktopLogin'),
(self.vmDesktopLogoff, 'desktopLogoff'),
--
To view, visit http://gerrit.ovirt.org/32394
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I920ae8b5c82134f09a12e56a529fa3d30fd7ab53
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: vdsm hostdev: add support for USB devices
by mpoledni@redhat.com
Martin Polednik has uploaded a new change for review.
Change subject: vdsm hostdev: add support for USB devices
......................................................................
vdsm hostdev: add support for USB devices
Libvirt allows passthrough of USB devices (not busses) - this patch
exposes the functionality in vdsm
Change-Id: Iac74e7537d56bcb940ef07a4654d45cbcdbb1fb0
Signed-off-by: Martin Polednik <mpoledni(a)redhat.com>
---
M vdsm/caps.py
M vdsm/rpc/vdsmapi-schema.json
M vdsm/virt/vm.py
3 files changed, 71 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/54/29054/1
diff --git a/vdsm/caps.py b/vdsm/caps.py
index d937d4e..8c16af6 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -530,7 +530,12 @@
# back that we could use to uniquely identify and initiate a device
continue
- if capability in ('pci',):
+ if capability in ('pci', 'usb_device'):
+ # Libvirt only allows to attach USB device with capability 'usb',
+ # but the bus identifies itself as 'usb' while device as
+ # 'usb_device'
+ if dev['capability'] == 'usb_device':
+ dev['capability'] = 'usb'
devices.append(dev)
return devices
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 921f3d4..ac10144 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -3156,33 +3156,55 @@
'specParams': 'VmRngDeviceSpecParams'}}
##
+# @StartupPolicy:
+#
+# Possible policies for startup with device
+#
+# @mandatory: fail if missing for any reason (the default)
+#
+# @requisite: fail if missing on boot up, drop if missing
+# on migrate/restore/revert
+#
+# @optional: drop if missing at any start attempt
+#
+# Since: 4.16.0
+##
+{'enum': 'StartupPolicy', 'data': ['mandatory', 'requisite', 'optional']}
+
+##
# @HostDeviceCapability:
#
# Properties of a host device.
#
# @pci: PCI device
#
+# @usb: USB device
+#
# Since: 4.16.0
##
-{'enum': 'HostDeviceCapability', 'data': ['pci']}
+{'enum': 'HostDeviceCapability', 'data': ['pci', 'usb']}
##
# @HostDeviceSpecParams:
#
# Properties of a host device.
#
-# @bootorder: #optional If specified, this device is part of the boot
-# sequence at the specified position
+# @bootorder: #optional If specified, this device is part of the boot
+# sequence at the specified position (for @pci and @usb)
#
-# @bar: #optional ROM visibility in the guest's memory map (for @pci)
+# @bar: #optional ROM visibility in the guest's
+# memory map (for @pci)
#
-# @file: #optional Binary file to be used as device's ROM (for @pci)
+# @file: #optional Binary file to be used as device's ROM (for @pci)
+#
+# @startupPolicy: #optional Possible boot handling with attached device
+# (for @usb)
#
# Since: 4.16.0
##
{'type': 'HostDeviceSpecParams',
- 'data': {'*bootorder': 'int', '*bar': 'bool',
- '*file': 'str'}}
+ 'data': {'*bootorder': 'int', '*bar': 'bool', '*file': 'str',
+ '*startupPolicy': 'StartupPolicy'}}
##
# @HostDevice:
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 6143cfa..6a6978e 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1631,13 +1631,16 @@
self.log.debug('Detaching hostdev %s', self.name)
self._node.dettach()
- def getPciAddr(self):
+ def _parsecaps(self):
capsxml = _domParseStr(self._node.XMLDesc(0)).childNodes[0]
self.log.debug('Got nodeDevice XML:\n%s',
capsxml.toprettyxml(encoding='utf-8'))
- capsxml = capsxml.getElementsByTagName('capability')[0]
+ return capsxml.getElementsByTagName('capability')[0]
+
+ def getPciAddr(self):
+ capsxml = self._parsecaps()
domain = capsxml.getElementsByTagName('domain')[0]. \
firstChild.nodeValue
bus = capsxml.getElementsByTagName('bus')[0].firstChild.nodeValue
@@ -1646,6 +1649,26 @@
self.log.debug('PCI device %s at address {domain: %s bus: %s '
'slot: %s}', self.name, domain, bus, slot)
return {'domain': domain, 'bus': bus, 'slot': slot}
+
+ def getUsbAddr(self):
+ capsxml = self._parsecaps()
+ addr = {}
+
+ addr['bus'] = capsxml.getElementsByTagName('bus')[0].firstChild. \
+ nodeValue
+ addr['device'] = capsxml.getElementsByTagName('device')[0]. \
+ firstChild.nodeValue
+ # TODO: handle nonexistant product_id and vendor_id by not adding them
+ # to addr
+ addr['product_id'] = capsxml.getElementsByTagName('product')[0].\
+ getAttribute('id')
+ addr['vendor_id'] = capsxml.getElementsByTagName('vendor')[0].\
+ getAttribute('id')
+
+ self.log.debug('USB device %s {product: %s, vendor: %s} at address '
+ '{bus: %s device: %s}', self.name, addr['product_id'],
+ addr['vendor_id'], addr['bus'], addr['device'])
+ return addr
def getXML(self):
"""
@@ -1683,6 +1706,17 @@
rom.setAttrs(**romAttrs)
+ elif self.capability == 'usb_device':
+ addr = self.getPciAddr()
+ try:
+ source.appendChildWithArgs('vendor', None, addr['vendor'])
+ source.appendChildWithArgs('vendor', None, addr['product'])
+ except:
+ source.appendChildWithArgs('address', None, **addr)
+
+ if 'startupPolicy' in self.specParams:
+ source.setAttrs(startupPolicy=self.specParams['startupPolicy'])
+
return hostdev
--
To view, visit http://gerrit.ovirt.org/29054
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iac74e7537d56bcb940ef07a4654d45cbcdbb1fb0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoledni(a)redhat.com>
8 years, 7 months
Change in vdsm[master]: vdsm hostdev: add support for SCSI devices
by mpoledni@redhat.com
Martin Polednik has uploaded a new change for review.
Change subject: vdsm hostdev: add support for SCSI devices
......................................................................
vdsm hostdev: add support for SCSI devices
Libvirt allows passthrough of SCSI devices - this patch
exposes the functionality in vdsm
Change-Id: Ia953bcd5eda1b97235a8dd2f5f9593d8f302e5d6
Signed-off-by: Martin Polednik <mpoledni(a)redhat.com>
---
M vdsm/caps.py
M vdsm/rpc/vdsmapi-schema.json
M vdsm/virt/vm.py
3 files changed, 51 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/58/29058/1
diff --git a/vdsm/caps.py b/vdsm/caps.py
index 8c16af6..6112763 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -530,7 +530,7 @@
# back that we could use to uniquely identify and initiate a device
continue
- if capability in ('pci', 'usb_device'):
+ if capability in ('pci', 'usb_device', 'scsi'):
# Libvirt only allows to attach USB device with capability 'usb',
# but the bus identifies itself as 'usb' while device as
# 'usb_device'
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index ac10144..52f20c1 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -3180,9 +3180,11 @@
#
# @usb: USB device
#
+# @scsi: SCSI device
+#
# Since: 4.16.0
##
-{'enum': 'HostDeviceCapability', 'data': ['pci', 'usb']}
+{'enum': 'HostDeviceCapability', 'data': ['pci', 'usb', 'scsi']}
##
# @HostDeviceSpecParams:
@@ -3200,11 +3202,18 @@
# @startupPolicy: #optional Possible boot handling with attached device
# (for @usb)
#
+# @readonly #optional If present, indicates that the device is read
+# only (for @scsi)
+#
+# @shareable #optional If present, this indicates the device is
+# expected to be shared between domains (for @scsi)
+#
# Since: 4.16.0
##
{'type': 'HostDeviceSpecParams',
'data': {'*bootorder': 'int', '*bar': 'bool', '*file': 'str',
- '*startupPolicy': 'StartupPolicy'}}
+ '*startupPolicy': 'StartupPolicy', '*shareable': 'bool',
+ '*readonly*': 'bool'}}
##
# @HostDevice:
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 6a6978e..3cb2eb9 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1670,6 +1670,33 @@
addr['vendor_id'], addr['bus'], addr['device'])
return addr
+ def getScsiAddr(self):
+ capsxml = self._parsecaps()
+ addr = {}
+
+ addr['type'] = 'scsi'
+ addr['bus'] = capsxml.getElementsByTagName('bus')[0].firstChild. \
+ nodeValue
+ addr['target'] = capsxml.getElementsByTagName('target')[0]. \
+ firstChild.nodeValue
+ addr['unit'] = capsxml.getElementsByTagName('lun')[0]. \
+ firstChild.nodeValue
+
+ self.log.debug('SCSI device %s at address '
+ '{bus: %s, target: %s, unit: %s}',
+ self.name, addr['bus'], addr['target'], addr['unit'],
+ addr['device'])
+ return addr
+
+ def getScsiAdapter(self):
+ capsxml = self._parsecaps()
+
+ adapter = 'scsi_host{}'.format(
+ capsxml.getElementsByTagName('host')[0].firstChild.nodeValue)
+
+ self.log.debug('SCSI device %s adapter %s', self.name, adapter)
+ return adapter
+
def getXML(self):
"""
Create domxml for a hostdev device.
@@ -1717,6 +1744,18 @@
if 'startupPolicy' in self.specParams:
source.setAttrs(startupPolicy=self.specParams['startupPolicy'])
+ elif self.capability == 'scsi':
+ source.appendChildWithArgs('address', None,
+ **self.getScsiHost())
+ source.appendChildWithArgs('adapter', None,
+ **self.getScsiAdapter())
+
+ if 'readonly' in self.specParams:
+ hostdev.appendChild('readonly')
+
+ if 'shareable' in self.specParams:
+ hostdev.appendChild('shareable')
+
return hostdev
--
To view, visit http://gerrit.ovirt.org/29058
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia953bcd5eda1b97235a8dd2f5f9593d8f302e5d6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoledni(a)redhat.com>
8 years, 7 months