Change in vdsm[master]: create VMs in a bulk
by ahadas@redhat.com
Arik Hadas has uploaded a new change for review.
Change subject: create VMs in a bulk
......................................................................
create VMs in a bulk
Change-Id: Ifd50b9fc694ec7c84b3b39f3d11edb1495842244
Signed-off-by: Arik Hadas <ahadas(a)redhat.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm_api/Bridge.py
M vdsm_api/vdsmapi-schema.json
4 files changed, 38 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/22452/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 44d5817..391dc9a 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1266,6 +1266,11 @@
for v in self._cif.vmContainer.values()
if not vmSet or v.id in vmSet]}
+ def createAll(self, vmsParams):
+ return {'status': doneCode,
+ 'vmList': [VM(v['vmId']).create(v)
+ for v in vmsParams]}
+
# Networking-related functions
def setupNetworks(self, networks, bondings, options):
"""Add a new network to this vds, replacing an old one."""
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 5bcd84c..3078d73 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -214,6 +214,10 @@
vm = API.VM(vmParams['vmId'])
return vm.create(vmParams)
+ def createAll(self, vmsParams):
+ api = API.Global()
+ return api.createAll(vmsParams)
+
def getVMList(self, fullStatus=False, vmList=()):
api = API.Global()
return api.getVMList(fullStatus, vmList)
@@ -814,6 +818,7 @@
def getGlobalMethods(self):
return ((self.vmDestroy, 'destroy'),
(self.vmCreate, 'create'),
+ (self.createAll, 'createAll'),
(self.getVMList, 'list'),
(self.vmPause, 'pause'),
(self.vmCont, 'cont'),
diff --git a/vdsm_api/Bridge.py b/vdsm_api/Bridge.py
index f4d533c..f0b4653 100644
--- a/vdsm_api/Bridge.py
+++ b/vdsm_api/Bridge.py
@@ -232,6 +232,18 @@
return [v['vmId'] for v in ret['vmList']]
+#def Host_createAll_Call(api, args):
+# vmParams = args.get('vmParams', [])
+# return API.Global().createAll(vmParams)
+
+
+#def Host_createAll_Ret(ret):
+# """
+# Just return a list of VM UUIDs
+# """
+# return [v['vmId'] for v in ret['vmList']]
+
+
def StoragePool_getInfo_Ret(ret):
"""
The result contains two data structures which must be merged
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 77ca409..33ef756 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -2941,6 +2941,22 @@
'returns': ['UUID']}
##
+# @Host.createAll:
+#
+# Get information about the current virtual machines.
+#
+# @vmParams: #optional Filter the results by a list of UUIDs
+#
+# Returns:
+# A list of VM UUIDs
+#
+# Since: 4.10.0
+##
+{'command': {'class': 'Host', 'name': 'createAll'},
+ 'data': { '*vmParams': 'VmParameters'},
+ 'returns': 'VmDefinition'}
+
+##
# @Host.ping:
#
# Test connectivity to vdsm.
--
To view, visit http://gerrit.ovirt.org/22452
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd50b9fc694ec7c84b3b39f3d11edb1495842244
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <ahadas(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: utilsTests: Avoiding returning in the middle of the method
by vvolansk@redhat.com
Vered Volansky has uploaded a new change for review.
Change subject: utilsTests: Avoiding returning in the middle of the method
......................................................................
utilsTests: Avoiding returning in the middle of the method
In RollbackContextTest there are some tests which returns in the first
except. This patch avoids that.
Change-Id: I877f65569f4304bdd4160bb9f84facf261e568e8
Signed-off-by: Vered Volansky <vvolansk(a)redhat.com>
---
M tests/utilsTests.py
1 file changed, 7 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/86/22886/1
diff --git a/tests/utilsTests.py b/tests/utilsTests.py
index bf27f30..7ce15dc 100644
--- a/tests/utilsTests.py
+++ b/tests/utilsTests.py
@@ -334,9 +334,8 @@
rollback.prependDefer(self._callDef)
except Exception:
self.assertEquals(self._called, 2)
- return
-
- self.fail("Exception was not raised")
+ else:
+ self.fail("Exception was not raised")
def testFirstException(self):
"""
@@ -353,11 +352,10 @@
rollback.prependDefer(self._callDef)
except RuntimeError:
self.assertEquals(self._called, 3)
- return
except Exception:
self.fail("Wrong exception was raised")
-
- self.fail("Exception was not raised")
+ else:
+ self.fail("Exception was not raised")
def testKeyErrorException(self):
"""
@@ -368,8 +366,8 @@
with utils.RollbackContext():
{}['aKey']
except KeyError:
- return
+ pass
except Exception:
self.fail("Wrong exception was raised")
-
- self.fail("Exception was not raised")
+ else:
+ self.fail("Exception was not raised")
--
To view, visit http://gerrit.ovirt.org/22886
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I877f65569f4304bdd4160bb9f84facf261e568e8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vered Volansky <vvolansk(a)redhat.com>
9 years, 10 months
Change in vdsm[master]: vm: spice support to agent file transfer disable
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: vm: spice support to agent file transfer disable
......................................................................
vm: spice support to agent file transfer disable
Spice has agent based file transfer support.
This option can be disabled in QEMU, and libvirt has support
to pass this flag to the underlying QEMU.
This patch expose this capability in VDSM, in the VM definition,
implementing the VDSM part of bz983019.
The new parameter is optional and enabled by default for backward
compatibility.
No XML changes are produced at all unless the new parameter is
specified.
Change-Id: I8cde372e6bf2f46b2ceac4e8660b5b05f02aaccb
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/vmTests.py
M vdsm/vm.py
M vdsm_api/vdsmapi-schema.json
3 files changed, 40 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/23270/1
diff --git a/tests/vmTests.py b/tests/vmTests.py
index 6215041..2594dc2 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -304,6 +304,20 @@
<channel mode="secure" name="playback"/>
<channel mode="secure" name="record"/>
<channel mode="secure" name="display"/>
+ </graphics>""",
+
+ """
+ <graphics autoport="yes" listen="0" passwd="*****"
+ passwdValidTo="1970-01-01T00:00:01" port="-1"
+ tlsPort="-1" type="spice">
+ <filetransfer enable="no"/>
+ </graphics>""",
+
+ """
+ <graphics autoport="yes" listen="0" passwd="*****"
+ passwdValidTo="1970-01-01T00:00:01" port="-1"
+ tlsPort="-1" type="spice">
+ <channel mode="secure" name="main"/>
</graphics>"""]
spiceChannelXML = """
@@ -317,7 +331,13 @@
{'display': 'qxl', 'displayPort': '-1', 'displaySecurePort': '-1',
'spiceSecureChannels':
- "smain,sinputs,scursor,splayback,srecord,sdisplay"}]
+ "smain,sinputs,scursor,splayback,srecord,sdisplay"},
+
+ {'display': 'qxl', 'displayPort': '-1', 'displaySecurePort': '-1',
+ 'fileTransferEnable': 'false'},
+
+ {'display': 'qxl', 'displayPort': '-1', 'displaySecurePort': '-1',
+ 'fileTransferEnable': 'true', 'spiceSecureChannels': "smain"}]
for vmConf, xml in zip(vmConfs, expectedXMLs):
vmConf.update(self.conf)
diff --git a/vdsm/vm.py b/vdsm/vm.py
index bd5f6d5..ed11d82 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -1186,6 +1186,12 @@
<channel type='spicevmc'>
<target type='virtio' name='com.redhat.spice.0'/>
</channel>
+
+ or
+
+ <graphics autoport="yes" port="5910" tlsPort="5890" type="spice">
+ <filetransfer enable='no'/>
+ </graphics>
"""
graphicsAttrs = {'port': self.conf['displayPort'], 'autoport': 'yes'}
if self.conf['display'] == 'vnc':
@@ -1208,6 +1214,10 @@
graphics.appendChildWithArgs('channel', name=channel[1:],
mode='secure')
+ if not utils.tobool(self.conf.get('fileTransferEnable', True)):
+ filetransfer = XMLElement('filetransfer', enable='no')
+ graphics.appendChild(filetransfer)
+
vmc = XMLElement('channel', type='spicevmc')
vmc.appendChildWithArgs('target', type='virtio',
name='com.redhat.spice.0')
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 564180a..3b258b2 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -2804,6 +2804,10 @@
#
# @emulatedMachine: #optional The machine specification being emulated
#
+# @fileTransferEnable: #optional Specify if file transfer is enabled.
+# Currently relevant for @qxl devices only.
+# (new in version 4.14.0)
+#
# @keyboardLayout: #optional The keyboard layout string (eg. 'en-us')
#
# @kvmEnable: Indicates if KVM hardware acceleration is enabled
@@ -2854,10 +2858,11 @@
'*cpuType': 'str', '*custom': 'StringMap', '*devices': ['VmDevice'],
'display': 'VmDisplayType', 'displayIp': 'str',
'displayPort': 'int', 'displaySecurePort': 'int',
- '*emulatedMachine': 'str', '*keyboardLayout': 'str',
- 'kvmEnable': 'bool', '*maxVCpus': 'uint', 'memSize': 'uint',
- 'memGuaranteedSize': 'uint', 'nicModel': 'str', 'nice': 'int',
- '*pauseCode': 'str', 'pid': 'uint', 'smp': 'uint', '*smpCoresPerSocket': 'uint',
+ '*emulatedMachine': 'str', '*fileTransferEnable': 'bool',
+ '*keyboardLayout': 'str', 'kvmEnable': 'bool',
+ '*maxVCpus': 'uint', 'memSize': 'uint', 'memGuaranteedSize': 'uint',
+ 'nicModel': 'str', 'nice': 'int', '*pauseCode': 'str', 'pid': 'uint',
+ 'smp': 'uint', '*smpCoresPerSocket': 'uint',
'*smpThreadsPerCore': 'uint', 'status': 'VmStatus',
'timeOffset': 'uint', 'transparentHugePages': 'bool',
'vmId': 'UUID', 'vmName': 'str', 'vmType': 'VmType',
--
To view, visit http://gerrit.ovirt.org/23270
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8cde372e6bf2f46b2ceac4e8660b5b05f02aaccb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
9 years, 10 months
Change in vdsm[master]: Add hostusbdirect hook to vdsm_hooks.
by lyarwood@redhat.com
Lee Yarwood has uploaded a new change for review.
Change subject: Add hostusbdirect hook to vdsm_hooks.
......................................................................
Add hostusbdirect hook to vdsm_hooks.
This is a slight variation of the hostusb hook. This version uses the bus and
device IDs to attach host USB device to the guest using the following libvirt XML :
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<address bus='001' device='003'/>
</source>
</hostdev>
In the future this could be merged with the hostusb hook.
Change-Id: I00b4b03993cd7290462b0e17457892b23dd41b31
Signed-off-by: Lee Yarwood <lyarwood(a)redhat.com>
---
M configure.ac
M vdsm.spec.in
M vdsm_hooks/Makefile.am
A vdsm_hooks/hostusbdirect/Makefile.am
A vdsm_hooks/hostusbdirect/README
A vdsm_hooks/hostusbdirect/after_vm_destroy.py
A vdsm_hooks/hostusbdirect/before_vm_migrate_source.py
A vdsm_hooks/hostusbdirect/before_vm_start.py
A vdsm_hooks/hostusbdirect/sudoers.vdsm_hook_hostusbdirect
9 files changed, 262 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/28/17428/1
diff --git a/configure.ac b/configure.ac
index 0ccca95..39e31f0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -225,6 +225,7 @@
vdsm_hooks/fileinject/Makefile
vdsm_hooks/floppy/Makefile
vdsm_hooks/hostusb/Makefile
+ vdsm_hooks/hostusbdirect/Makefile
vdsm_hooks/hugepages/Makefile
vdsm_hooks/isolatedprivatevlan/Makefile
vdsm_hooks/macspoof/Makefile
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 235d1db..c1b9431 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -389,6 +389,15 @@
Hook is getting vendor and product id of USB device
disconnect it from host and attach it to VM
+%package hook-hostusb-direct
+Summary: Allow attaching USB device from host by bus and device ids.
+BuildArch: noarch
+Requires: usbutils
+
+%description hook-hostusb-direct
+Hook is getting bus and device id of USB device
+disconnect it from host and attach it to VM
+
%package hook-hugepages
Summary: Huge pages enable user to handle VM with 2048KB page files.
BuildArch: noarch
diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am
index 8a8d594..fb4052b 100644
--- a/vdsm_hooks/Makefile.am
+++ b/vdsm_hooks/Makefile.am
@@ -30,6 +30,7 @@
fileinject \
floppy \
hostusb \
+ hostusbdirect \
hugepages \
isolatedprivatevlan \
macspoof \
diff --git a/vdsm_hooks/hostusbdirect/Makefile.am b/vdsm_hooks/hostusbdirect/Makefile.am
new file mode 100644
index 0000000..9d0cdbc
--- /dev/null
+++ b/vdsm_hooks/hostusbdirect/Makefile.am
@@ -0,0 +1,52 @@
+#
+# Copyright 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+EXTRA_DIST = \
+ after_vm_destroy.py \
+ before_vm_migrate_source.py \
+ before_vm_start.py \
+ sudoers.vdsm_hook_hostusbdirect
+
+install-data-hook:
+ chmod 440 $(DESTDIR)$(sysconfdir)/sudoers.d/50_vdsm_hook_hostusbdirect
+
+install-data-local: install-data-sudoers
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_vm_start
+ $(INSTALL_SCRIPT) $(srcdir)/before_vm_start.py \
+ $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_hostusbdirect
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_vm_destroy
+ $(INSTALL_SCRIPT) $(srcdir)/after_vm_destroy.py \
+ $(DESTDIR)$(vdsmhooksdir)/after_vm_destroy/50_hostusbdirect
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_vm_migrate_source
+ $(INSTALL_SCRIPT) $(srcdir)/before_vm_migrate_source.py \
+ $(DESTDIR)$(vdsmhooksdir)/before_vm_migrate_source/50_hostusbdirect
+
+uninstall-local: uninstall-data-sudoers
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_hostusbdirect
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/after_vm_destroy/50_hostusbdirect
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/before_vm_migrate_source/50_hostusbdirect
+
+install-data-sudoers:
+ $(MKDIR_P) $(DESTDIR)$(sysconfdir)/sudoers.d
+ $(INSTALL_DATA) $(srcdir)/sudoers.vdsm_hook_hostusbdirect \
+ $(DESTDIR)$(sysconfdir)/sudoers.d/50_vdsm_hook_hostusbdirect
+
+uninstall-data-sudoers:
+ $(RM) $(DESTDIR)$(sysconfdir)/sudoers.d/50_vdsm_hook_hostusbdirect
diff --git a/vdsm_hooks/hostusbdirect/README b/vdsm_hooks/hostusbdirect/README
new file mode 100644
index 0000000..297c559
--- /dev/null
+++ b/vdsm_hooks/hostusbdirect/README
@@ -0,0 +1,18 @@
+host usb hook direct
+====================
+add hosts usb device/s to VM using bus and device ids:
+
+<hostdev mode='subsystem' type='usb'>
+ <source>
+ <address bus='001' device='003'/>
+ </source>
+</hostdev>
+
+syntax:
+ hostusbdirect=001:003&001:002
+ i.e.
+ hostusb=bus:device (can add more then one with '&' separator)
+
+Note:
+ The VM must be pinned to host and this hook will
+ fail any migration attempt.
diff --git a/vdsm_hooks/hostusbdirect/after_vm_destroy.py b/vdsm_hooks/hostusbdirect/after_vm_destroy.py
new file mode 100755
index 0000000..3882347
--- /dev/null
+++ b/vdsm_hooks/hostusbdirect/after_vm_destroy.py
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+
+import os
+import sys
+import traceback
+
+import hooking
+
+'''
+after_vm_destroy:
+return the original owner of the usb device
+'''
+
+HOOK_HOSTUSB_PATH = '/var/run/vdsm/hooks/hostusbdirect-permissions'
+
+
+def get_owner(devpath):
+ uid = pid = -1
+ content = ''
+
+ if not os.path.isfile(HOOK_HOSTUSB_PATH):
+ return uid, pid
+
+ f = file(HOOK_HOSTUSB_PATH, 'r')
+ for line in f:
+ if len(line) > 0 and line.split(':')[0] == devpath:
+ entry = line.split(':')
+ uid = entry[1]
+ pid = entry[2]
+ elif len(line) > 0:
+ content += line + '\n'
+
+ f.close()
+ if uid != -1:
+ f = file(HOOK_HOSTUSB_PATH, 'w')
+ f.writelines(content)
+ f.close()
+
+ return uid, pid
+
+
+def chown(bus, device):
+ devpath = '/dev/bus/usb/' + bus + '/' + device
+ uid, gid = get_owner(devpath)
+
+ owner = str(uid) + ':' + str(gid)
+ command = ['/bin/chown', owner, devpath]
+ retcode, out, err = hooking.execCmd(command, sudo=True, raw=True)
+ if retcode != 0:
+ sys.stderr.write('hostusbdirect: error chown %s to %s, err = %s\n' %
+ (devpath, owner, err))
+ sys.exit(2)
+
+
+if 'hostusbdirect' in os.environ:
+ try:
+ for usb in os.environ['hostusbdirect'].split('&'):
+ bus, device = usb.split(':')
+ chown(bus, device)
+
+ except:
+ sys.stderr.write('hostusb after_vm_destroy: [unexpected error]: %s\n' %
+ traceback.format_exc())
+ sys.exit(2)
diff --git a/vdsm_hooks/hostusbdirect/before_vm_migrate_source.py b/vdsm_hooks/hostusbdirect/before_vm_migrate_source.py
new file mode 100755
index 0000000..43a2eca
--- /dev/null
+++ b/vdsm_hooks/hostusbdirect/before_vm_migrate_source.py
@@ -0,0 +1,8 @@
+#!/usr/bin/python
+
+import os
+import sys
+
+if 'hostusbdirect' in os.environ:
+ sys.stderr.write("hostusbdirect: can't migrate VM with host usb devices\n")
+ sys.exit(2)
diff --git a/vdsm_hooks/hostusbdirect/before_vm_start.py b/vdsm_hooks/hostusbdirect/before_vm_start.py
new file mode 100755
index 0000000..57307aa
--- /dev/null
+++ b/vdsm_hooks/hostusbdirect/before_vm_start.py
@@ -0,0 +1,108 @@
+#!/usr/bin/python
+
+import os
+import sys
+import grp
+import pwd
+import traceback
+
+import hooking
+
+'''
+host usb hook direct
+====================
+
+syntax:
+ hostusbdirect=001:001&001:002
+ i.e.
+ hostusbdirect=bus:device (can add more then one with '&' separator)
+
+Note:
+ The VM must be pinned to host and this hook will
+ fail any migration attempt.
+'''
+
+HOOK_HOSTUSB_PATH = '/var/run/vdsm/hooks/hostusbdirect-permissions'
+
+
+def log_dev_owner(devpath, user, group):
+ entry = devpath + ":" + str(user) + ":" + str(group)
+
+ if not os.path.isdir(os.path.dirname(HOOK_HOSTUSB_PATH)):
+ os.mkdir(os.path.dirname(HOOK_HOSTUSB_PATH))
+
+ if os.path.isfile(HOOK_HOSTUSB_PATH):
+ f = file(HOOK_HOSTUSB_PATH, 'r')
+ for line in f:
+ if entry == line:
+ f.close()
+ return
+
+ f = file(HOOK_HOSTUSB_PATH, 'a')
+ f.writelines(entry)
+ f.close()
+
+
+def chown(bus, device):
+
+ devpath = '/dev/bus/usb/' + bus + '/' + device
+ stat = os.stat(devpath)
+
+ group = grp.getgrnam('qemu')
+ gid = group.gr_gid
+ user = pwd.getpwnam('qemu')
+ uid = user.pw_uid
+
+ owner = str(uid) + ':' + str(gid)
+ command = ['/bin/chown', owner, devpath]
+ retcode, out, err = hooking.execCmd(command, sudo=True, raw=True)
+ if retcode != 0:
+ sys.stderr.write('hostusbdirect: error chown %s to %s, err = %s\n' %
+ (devpath, owner, err))
+ sys.exit(2)
+
+ log_dev_owner(devpath, stat.st_uid, stat.st_gid)
+
+
+def add_devices(domxml, devices):
+ domain = domxml.getElementsByTagName('devices')[0]
+
+ for device in devices:
+ # Add the following for each device :
+ #<hostdev mode='subsystem' type='usb' managed='yes'>
+ # <source>
+ # <address bus='001' device='003'/>
+ # </source>
+ #</hostdev>
+
+ hostdev = domxml.createElement('hostdev')
+ hostdev.setAttribute('mode', 'subsystem')
+ hostdev.setAttribute('type', 'usb')
+ hostdev.setAttribute('managed', 'yes')
+
+ source = domxml.createElement('source')
+ hostdev.appendChild(source)
+
+ address = domxml.createElement('address')
+ address.setAttribute('bus', device['bus'])
+ address.setAttribute('device', device['device'])
+ source.appendChild(address)
+
+ domain.appendChild(hostdev)
+
+if 'usbhostdirect' in os.environ:
+ try:
+ domxml = hooking.read_domxml()
+ devices = []
+
+ for usb in os.environ['usbhostdirect'].split('&'):
+ bus, device = usb.split(':')
+ chown(bus, device)
+ devices.append({'bus': bus, 'device': device})
+
+ add_devices(domxml, devices)
+ hooking.write_domxml(domxml)
+ except:
+ sys.stderr.write('hostusbdirect: [unexpected error]: %s\n' %
+ traceback.format_exc())
+ sys.exit(2)
diff --git a/vdsm_hooks/hostusbdirect/sudoers.vdsm_hook_hostusbdirect b/vdsm_hooks/hostusbdirect/sudoers.vdsm_hook_hostusbdirect
new file mode 100644
index 0000000..cba601d
--- /dev/null
+++ b/vdsm_hooks/hostusbdirect/sudoers.vdsm_hook_hostusbdirect
@@ -0,0 +1 @@
+vdsm ALL=(ALL) NOPASSWD: /bin/chown
--
To view, visit http://gerrit.ovirt.org/17428
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I00b4b03993cd7290462b0e17457892b23dd41b31
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Lee Yarwood <lyarwood(a)redhat.com>
9 years, 10 months
Change in vdsm[master]: utils
by laravot@redhat.com
Liron Ar has uploaded a new change for review.
Change subject: utils
......................................................................
utils
Change-Id: Icbd049360a02ae98fa21756dc734c1da8ac3d11a
Signed-off-by: Liron Aravot <laravot(a)redhat.com>
---
M lib/vdsm/utils.py
1 file changed, 26 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/30/23130/1
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index d593a73..e39a245 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -52,6 +52,7 @@
import threading
import time
import zombiereaper
+import inspect
from cpopen import CPopen
from . import constants
@@ -643,6 +644,31 @@
return False
+def traced(on=""):
+
+ def func_decorator(func, log):
+ def wrapper(self, *a, **kw):
+ log.debug("executing %s with a= %s,kw= %s", func.func_name, a, kw)
+ return func(self, *a, **kw)
+ return wrapper
+
+ def decorator(cls):
+ log = logging.getLogger(on)
+ log.debug("aasd")
+ for name in dir(cls):
+ value = getattr(cls, name)
+ log.debug(name)
+ log.debug(type(value))
+
+ if inspect.ismethod(value):
+ setattr(cls, name, func_decorator(value, log))
+ log.debug("name = %s , value = %s was wrapped", name, value)
+
+ return cls
+
+ return decorator
+
+
def _getAllMacs():
# (
--
To view, visit http://gerrit.ovirt.org/23130
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icbd049360a02ae98fa21756dc734c1da8ac3d11a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Liron Ar <laravot(a)redhat.com>
9 years, 10 months
Change in vdsm[master]: [WIP] Implement a process to do dangerous IO in C
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: [WIP] Implement a process to do dangerous IO in C
......................................................................
[WIP] Implement a process to do dangerous IO in C
This replaces the process pool with a process that can serve multiple
requests written in C.
This implementation is much more scalable and lightweight. Should solve
bugs related to running out of helpers, logging getting suck, python
forking deadlocking, running out of memory and other things as well.
The communication between VDSM and the IOProcess is done with json
objects.
The IOProcess starts with 3 thread:
1. requestReader - reads requests from the pipe, builds a DOM
representation of it and queues it up for handling
2. responseWriter - gets response DOMs from the queue converts them to a
JSON string and send it over the pipe
3. requestHandler - pops requests from the queue and provisions threads
for handling them. Currently we I just allocate a new thread per
request. If there is ever a need to have a thread pool this is where
the load balancing is going to sit.
Each request gets the are as a JsonNode and returns a response that is a
JsonNode as well. Most exported functions are pretty trivial and are a
good example on how to write new ones.
Unlink the ProcessPoolHelper, high level commands sit of the OopWrapper
and are run from the client side instead of being implemented in C on
the IOProcess side.
Change-Id: Ie4664d5330debbe38ba33b74ebb586ac42913b4a
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M configure.ac
M tests/Makefile.am
A tests/ioprocessTests.py
A tests/outOfProcessTests.py
D tests/processPoolTests.py
M vdsm.spec.in
M vdsm/constants.py.in
M vdsm/storage/Makefile.am
M vdsm/storage/fileSD.py
M vdsm/storage/fileUtils.py
M vdsm/storage/fileVolume.py
A vdsm/storage/ioprocess.py
A vdsm/storage/ioprocess/.gitignore
A vdsm/storage/ioprocess/Makefile.am
A vdsm/storage/ioprocess/exported-functions.c
A vdsm/storage/ioprocess/exported-functions.h
A vdsm/storage/ioprocess/ioprocess.c
A vdsm/storage/ioprocess/json-dom-generator.c
A vdsm/storage/ioprocess/json-dom-generator.h
A vdsm/storage/ioprocess/json-dom-parser.c
A vdsm/storage/ioprocess/json-dom-parser.h
A vdsm/storage/ioprocess/json-dom.c
A vdsm/storage/ioprocess/json-dom.h
M vdsm/storage/misc.py
M vdsm/storage/nfsSD.py
M vdsm/storage/outOfProcess.py
D vdsm/storage/processPool.py
M vdsm/storage/sd.py
M vdsm/storage/sp.py
M vdsm/storage/task.py
30 files changed, 3,018 insertions(+), 666 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/46/3946/1
--
To view, visit http://gerrit.ovirt.org/3946
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie4664d5330debbe38ba33b74ebb586ac42913b4a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
9 years, 10 months
Change in vdsm[master]: Avoid calling restorecon on a nonexistent dir.
by mtayer@redhat.com
mooli tayer has uploaded a new change for review.
Change subject: Avoid calling restorecon on a nonexistent dir.
......................................................................
Avoid calling restorecon on a nonexistent dir.
/var/log/core is only created when vdsm service goes up.
If vdsm never ran on the machine we might get:
restorecon: lstat(/var/log/core) failed: No such file or directory
Change-Id: Id7246b4947c0cdb52093c5fe0f60a690d72b1236
Signed-off-by: Mooli Tayer <mtayer(a)redhat.com>
---
M init/vdsmd_init_common.sh.in
M vdsm.spec.in
2 files changed, 4 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/11/22211/1
diff --git a/init/vdsmd_init_common.sh.in b/init/vdsmd_init_common.sh.in
index 4b7d079..cc010fe 100644
--- a/init/vdsmd_init_common.sh.in
+++ b/init/vdsmd_init_common.sh.in
@@ -112,14 +112,6 @@
"@CHOWN_PATH@" @METADATAUSER@:@METADATAGROUP@ "${_DOM_METADATA_BACKUP_DIR}" > /dev/null 2>&1
}
-_mk_core_path() {
- local core_path=/var/log/core
- if ! [ -d "${core_path}" ]; then
- @MKDIR_P@ "${core_path}" > /dev/null 2>&1
- fi
- "@CHMOD_PATH@" a+tw "${core_path}" > /dev/null 2>&1
-}
-
_mk_run_path() {
local run_path
@@ -133,7 +125,6 @@
task_mkdirs(){
_mk_data_center
- _mk_core_path
_mk_dom_backup
_mk_run_path
"@CHMOD_PATH@" 1777 /dev/shm
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 7ee0218..a63e415 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -590,6 +590,10 @@
install -Dm 0644 vdsm/limits.conf \
%{buildroot}/etc/security/limits.d/99-vdsm.conf
+# This is not commonplace, but we want /var/log/core to be a world-writable
+# dropbox for core dumps
+install -dDm 1777 %{buildroot}%{_localstatedir}/log/core
+
%if 0%{?with_systemd}
install -Dm 0755 init/systemd/systemd-vdsmd %{buildroot}/lib/systemd/systemd-vdsmd
install -Dm 0644 init/systemd/vdsmd.service %{buildroot}%{_unitdir}/vdsmd.service
@@ -615,10 +619,6 @@
%endif
%if 0%{?rhel}
-# This is not commonplace, but we want /var/log/core to be a world-writable
-# dropbox for core dumps
-install -dDm 1777 %{buildroot}%{_localstatedir}/log/core
-%else
# Install the configuration sample
install -Dm 0644 lib/vdsm/vdsm.conf.sample \
%{buildroot}%{_sysconfdir}/vdsm/vdsm.conf
--
To view, visit http://gerrit.ovirt.org/22211
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id7246b4947c0cdb52093c5fe0f60a690d72b1236
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: mooli tayer <mtayer(a)redhat.com>
9 years, 10 months
Change in vdsm[master]: generate quemu-kvm coredumps using abrt
by mtayer@redhat.com
mooli tayer has uploaded a new change for review.
Change subject: generate quemu-kvm coredumps using abrt
......................................................................
generate quemu-kvm coredumps using abrt
Change-Id: I1acb287cdfcc9b8c05569fe1fc01e88957309ff9
Signed-off-by: Mooli Tayer <mtayer(a)redhat.com>
---
M init/vdsmd_init_common.sh.in
M vdsm.spec.in
2 files changed, 1 insertion(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/51/20751/1
diff --git a/init/vdsmd_init_common.sh.in b/init/vdsmd_init_common.sh.in
index 43a86ef..6a55818 100644
--- a/init/vdsmd_init_common.sh.in
+++ b/init/vdsmd_init_common.sh.in
@@ -25,11 +25,6 @@
task_configure_coredump() {
local conf_file="@CONFDIR(a)/vdsm.conf"
local getconfitem="@VDSMDIR@/get-conf-item"
-
- if "${getconfitem}" "${conf_file}" vars core_dump_enable false |
- tr A-Z a-z | grep -q true; then
- echo "/var/log/core/core.%p.%t.dump" > /proc/sys/kernel/core_pattern
- fi
}
task_run_init_hooks(){
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 34bdc2d..fd8023c 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -107,6 +107,7 @@
Requires: libguestfs-tools-c
Requires: %{name}-xmlrpc = %{version}-%{release}
Requires: mom >= 0.3.2-3
+Requires: abrt-addon-ccpp
%ifarch x86_64
Requires: python-dmidecode
--
To view, visit http://gerrit.ovirt.org/20751
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1acb287cdfcc9b8c05569fe1fc01e88957309ff9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: mooli tayer <mtayer(a)redhat.com>
9 years, 10 months
Change in vdsm[ovirt-3.3]: vm: Decrease log spam for expected errors
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: vm: Decrease log spam for expected errors
......................................................................
vm: Decrease log spam for expected errors
Getting a libvirt error is not exceptional event that requires logging
an exception. This patch log such error as errors instead of exception.
Change-Id: I8405f74a0a17e8c3b330bd6110e58f900c38f7c3
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/vm.py
1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/22576/1
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 2d0cece..2732298 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -521,6 +521,9 @@
vmDrive.apparentsize, capacity, alloc, physical)
self._vm.extendDriveVolume(vmDrive)
+ except libvirt.libvirtError as e:
+ self._log.error("%s/%s: %s", vmDrive.domainID,
+ vmDrive.volumeID, e)
except Exception:
self._log.exception("%s/%s", vmDrive.domainID,
vmDrive.volumeID)
--
To view, visit http://gerrit.ovirt.org/22576
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8405f74a0a17e8c3b330bd6110e58f900c38f7c3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
9 years, 10 months
Change in vdsm[master]: Rescan FC when rescanning for new multipath devices
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: Rescan FC when rescanning for new multipath devices
......................................................................
Rescan FC when rescanning for new multipath devices
Change-Id: Idec939222676a24452e8825b36db68839bfd2bbc
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M lib/vdsm/utils.py
M tests/utilsTests.py
M vdsm/storage/Makefile.am
A vdsm/storage/fc.py
M vdsm/storage/multipath.py
5 files changed, 61 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/39/19539/1
diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index f06cad2..e273514 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -793,6 +793,24 @@
return functools.partial(self.__call__, obj)
+def tee_async(data, outputFiles=[], append=False):
+ cmd = ["tee"]
+ if append:
+ cmd.append("--append")
+
+ cmd.extend(outputFiles)
+ proc = execCmd(cmd, sync=False)
+ proc.stdin.write(data)
+
+ def parser(rc, out, err):
+ if rc != 0:
+ raise OSError(-1, err)
+
+ return out
+
+ return AsyncProcessOperation(proc, parser)
+
+
def validateMinimalKeySet(dictionary, reqParams):
if not all(key in dictionary for key in reqParams):
raise ValueError
diff --git a/tests/utilsTests.py b/tests/utilsTests.py
index 656c121..5b83ec0 100644
--- a/tests/utilsTests.py
+++ b/tests/utilsTests.py
@@ -18,11 +18,14 @@
# Refer to the README and COPYING files for full details of the license
#
import errno
+import time
+import tempfile
+import shutil
+import os
from testrunner import VdsmTestCase as TestCaseBase
from vdsm import utils
from storage import misc
-import time
class RetryTests(TestCaseBase):
@@ -63,6 +66,33 @@
sproc.wait()
+class TeeTests(TestCaseBase):
+ def setUp(self):
+ self.dir = tempfile.mkdtemp()
+
+ def tearDown(self):
+ shutil.rmtree(self.dir)
+
+ def test(self):
+ d = self.dir
+ n = 10
+ files = []
+ for i in range(n):
+ files.append(os.path.join(d, "%d.tmp" % i))
+
+ data = "hello"
+ res = utils.tee_async(data, files).result()
+ self.assertEquals((data, None), res)
+ for fname in files:
+ with open(fname, "r") as f:
+ self.assertEquals(data, f.read())
+
+ def testError(self):
+ res, err = utils.tee_async("hello", ["/"]).result()
+ self.assertEquals(res, None)
+ self.assertNotEquals(err, None)
+
+
class CommandPathTests(TestCaseBase):
def testExisting(self):
cp = utils.CommandPath('sh', 'utter nonsense', '/bin/sh')
diff --git a/vdsm/storage/Makefile.am b/vdsm/storage/Makefile.am
index 2d3e9a6..a367c9b 100644
--- a/vdsm/storage/Makefile.am
+++ b/vdsm/storage/Makefile.am
@@ -33,6 +33,7 @@
fileSD.py \
fileUtils.py \
fileVolume.py \
+ fc.py \
fuser.py \
glusterSD.py \
glusterVolume.py \
diff --git a/vdsm/storage/fc.py b/vdsm/storage/fc.py
new file mode 100644
index 0000000..96aa710
--- /dev/null
+++ b/vdsm/storage/fc.py
@@ -0,0 +1,8 @@
+from glob import glob
+from vdsm import utils
+
+
+def rescan():
+ """Issue command to discover new ports if the fc driver supports it"""
+ # Use tee to make sure we don't do that IO directly
+ utils.tee_async("1", glob("/sys/class/fc_host/host*/issue_lip"))
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index 6d6fcbd..076bfca 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -36,6 +36,7 @@
import iscsi
import supervdsm
import devicemapper
+import fc
import storage_exception as se
@@ -106,7 +107,8 @@
Should only be called from hsm._rescanDevices()
"""
- # First ask iSCSI to rescan all its sessions
+ # First ask fc and iSCSI to rescan all of their sessions
+ fc.rescan()
iscsi.rescan()
# Now let multipath daemon pick up new devices
--
To view, visit http://gerrit.ovirt.org/19539
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idec939222676a24452e8825b36db68839bfd2bbc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
9 years, 10 months