master - dbus: fix the systemd service providing the DBus service
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3e31f518690432...
Commit: 3e31f5186904328d7f3fc8eae71cda72715107e7
Parent: 88530b2ef34527eae2bacc86c765fb680f5b6b2b
Author: Vratislav Podzimek <vpodzime(a)redhat.com>
AuthorDate: Thu Feb 25 16:34:41 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Feb 26 10:20:08 2016 +0100
dbus: fix the systemd service providing the DBus service
Correct name is lvm2-lvmdbusd.service not lvmdbusd.service.
This makes the bus-activation (auto-activation) work.
Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
---
WHATS_NEW | 1 +
scripts/com.redhat.lvmdbus1.service.in | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 250f3f1..ecae780 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.144 -
=====================================
+ Fix SystemdService lvm2-lvmdbusd.service name.
Improve support for env LVM_VG_NAME for reference VG name in lvconvert.
Fix regresion when lvresize accepted zero sizes (2.02.141).
Always warn user about PV in use even when pvremove uses --force --force.
diff --git a/scripts/com.redhat.lvmdbus1.service.in b/scripts/com.redhat.lvmdbus1.service.in
index e271b08..5578ed1 100644
--- a/scripts/com.redhat.lvmdbus1.service.in
+++ b/scripts/com.redhat.lvmdbus1.service.in
@@ -2,4 +2,4 @@
Name=com.redhat.lvmdbus1
Exec=@sbindir@/lvmdbusd --udev
User=root
-SystemdService=lvmdbusd.service
+SystemdService=lvm2-lvmdbusd.service
8 years, 2 months
master - pvcreate: fix data alignment error check
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=88530b2ef34527...
Commit: 88530b2ef34527eae2bacc86c765fb680f5b6b2b
Parent: 081359f6cd2ed8224992c91e99617ef576e01488
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 25 16:57:01 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Feb 25 17:02:18 2016 -0600
pvcreate: fix data alignment error check
Make the data_alignment variable 64 bits so it
can hold the invalid command line arg used in
pvreate-usage.sh pvcreate --dataalignment 1e.
On 32 bit arches, the smaller variable wouldn't
hold the invalid value so the error would not
trigger as expected by the test.
---
lib/metadata/metadata-exported.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 03e8572..6b39de4 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -522,8 +522,8 @@ struct vgnameid_list {
*/
struct pv_create_args {
uint64_t size;
- unsigned long data_alignment;
- unsigned long data_alignment_offset;
+ uint64_t data_alignment;
+ uint64_t data_alignment_offset;
uint64_t label_sector;
int pvmetadatacopies;
uint64_t pvmetadatasize;
8 years, 2 months
master - lvmdbusd: Do only 1 refresh for Vg.Change()
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=081359f6cd2ed8...
Commit: 081359f6cd2ed8224992c91e99617ef576e01488
Parent: 26b826ccf59b891a7947d9f7f2bacf8d0a5172a9
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Feb 25 16:34:51 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Feb 25 16:43:56 2016 -0600
lvmdbusd: Do only 1 refresh for Vg.Change()
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
daemons/lvmdbusd/vg.py | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/daemons/lvmdbusd/vg.py b/daemons/lvmdbusd/vg.py
index b39f703..f5b3e45 100644
--- a/daemons/lvmdbusd/vg.py
+++ b/daemons/lvmdbusd/vg.py
@@ -237,10 +237,7 @@ class Vg(AutomatedProperties):
# locals(), ['Variant']).Variant("s", "n")}
if rc == 0:
- dbo.refresh()
-
- if (('activate' in change_options) or ('-a' in change_options)):
- cfg.load()
+ cfg.load()
else:
raise dbus.exceptions.DBusException(
VG_INTERFACE,
8 years, 2 months
master - lvmdbusd testing: Add validatestate.py utility
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=26b826ccf59b89...
Commit: 26b826ccf59b891a7947d9f7f2bacf8d0a5172a9
Parent: 0d620e681fe42d0a1b2a5666677c36753838c6fd
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Feb 25 16:12:53 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Feb 25 16:43:55 2016 -0600
lvmdbusd testing: Add validatestate.py utility
This simple tool calls the Manager.Refresh method on the dbus service
to check and see if the dbus service has the most up to date state.
This is to be used for testing to ensure that event driven updates are
working as planned.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
test/dbus/validatestate.py | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/test/dbus/validatestate.py b/test/dbus/validatestate.py
new file mode 100755
index 0000000..faa2083
--- /dev/null
+++ b/test/dbus/validatestate.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2015-2016 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Simply connects to the dbus service and calls Refresh and ensures that the
+# value returned is zero
+
+import testlib
+import dbus
+from dbus.mainloop.glib import DBusGMainLoop
+import sys
+import os
+
+
+if __name__ == "__main__":
+
+ use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
+
+ if use_session:
+ bus = dbus.SessionBus(mainloop=DBusGMainLoop())
+ else:
+ bus = dbus.SystemBus(mainloop=DBusGMainLoop())
+
+ mgr_proxy = testlib.ClientProxy(bus, testlib.MANAGER_OBJ)
+ sys.exit(mgr_proxy.Manager.Refresh())
8 years, 2 months
master - lvmdbustest.py: Move helper code to testlib.py
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0d620e681fe42d...
Commit: 0d620e681fe42d0a1b2a5666677c36753838c6fd
Parent: f1bc68beb4e493a9c1a52750e99d50f874ca89d9
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Feb 25 16:11:08 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Feb 25 16:43:55 2016 -0600
lvmdbustest.py: Move helper code to testlib.py
This will allow us to re-use in other client programs for testing.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
test/dbus/lvmdbustest.py | 199 +++++-----------------------------------------
test/dbus/testlib.py | 174 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 195 insertions(+), 178 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 92f5d70..4c58552 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -14,35 +14,10 @@ import dbus
from dbus.mainloop.glib import DBusGMainLoop
import unittest
import sys
-import random
-import string
-import functools
import time
import pyudev
import os
-import xml.etree.ElementTree as Et
-from collections import OrderedDict
-
-BUSNAME = "com.redhat.lvmdbus1"
-MANAGER_INT = BUSNAME + '.Manager'
-MANAGER_OBJ = '/' + BUSNAME.replace('.', '/') + 'Manager'
-PV_INT = BUSNAME + ".Pv"
-VG_INT = BUSNAME + ".Vg"
-LV_INT = BUSNAME + ".Lv"
-THINPOOL_INT = BUSNAME + ".ThinPool"
-SNAPSHOT_INT = BUSNAME + ".Snapshot"
-LV_COMMON_INT = BUSNAME + ".LvCommon"
-JOB_INT = BUSNAME + ".Job"
-CACHE_POOL_INT = BUSNAME + ".CachePool"
-CACHE_LV_INT = BUSNAME + ".CachedLv"
-
-THINPOOL_LV_PATH = '/' + THINPOOL_INT.replace('.', '/')
-
-
-def rs(length, suffix, character_set=string.ascii_lowercase):
- return ''.join(random.choice(character_set)
- for _ in range(length)) + suffix
-
+from testlib import *
use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
@@ -52,144 +27,6 @@ else:
bus = dbus.SystemBus(mainloop=DBusGMainLoop())
-def mib(s):
- return 1024 * 1024 * s
-
-
-class DbusIntrospection(object):
- @staticmethod
- def introspect(xml_representation):
- interfaces = {}
-
- root = Et.fromstring(xml_representation)
-
- for c in root:
- if c.tag == "interface":
- in_f = c.attrib['name']
- interfaces[in_f] = \
- dict(methods=OrderedDict(), properties={})
- for nested in c:
- if nested.tag == "method":
- mn = nested.attrib['name']
- interfaces[in_f]['methods'][mn] = OrderedDict()
-
- for arg in nested:
- if arg.tag == 'arg':
- arg_dir = arg.attrib['direction']
- if arg_dir == 'in':
- n = arg.attrib['name']
- else:
- n = None
-
- arg_type = arg.attrib['type']
-
- if n:
- v = dict(
- name=mn,
- a_dir=arg_dir,
- a_type=arg_type)
- interfaces[in_f]['methods'][mn][n] = v
-
- elif nested.tag == 'property':
- pn = nested.attrib['name']
- p_access = nested.attrib['access']
- p_type = nested.attrib['type']
-
- interfaces[in_f]['properties'][pn] = \
- dict(p_access=p_access, p_type=p_type)
- else:
- pass
-
- # print('Interfaces...')
- # for k, v in list(interfaces.items()):
- # print('Interface %s' % k)
- # if v['methods']:
- # for m, args in list(v['methods'].items()):
- # print(' method: %s' % m)
- # for a, aa in args.items():
- # print(' method arg: %s' % (a))
- # if v['properties']:
- # for p, d in list(v['properties'].items()):
- # print(' Property: %s' % (p))
- # print('End interfaces')
-
- return interfaces
-
-
-class RemoteObject(object):
- def _set_props(self, props=None):
- # print 'Fetching properties'
- if not props:
- # prop_fetch = dbus.Interface(self.bus.get_object(
- # BUSNAME, self.object_path), 'org.freedesktop.DBus.Properties')
-
- for i in range(0, 3):
- try:
- prop_fetch = dbus.Interface(self.bus.get_object(
- BUSNAME, self.object_path),
- 'org.freedesktop.DBus.Properties')
- props = prop_fetch.GetAll(self.interface)
- break
- except dbus.exceptions.DBusException as dbe:
- if "GetAll" not in str(dbe):
- raise dbe
- if props:
- for kl, vl in list(props.items()):
- setattr(self, kl, vl)
-
- def __init__(self, specified_bus, object_path, interface, properties=None):
- self.object_path = object_path
- self.interface = interface
- self.bus = specified_bus
-
- self.dbus_method = dbus.Interface(specified_bus.get_object(
- BUSNAME, self.object_path), self.interface)
-
- self._set_props(properties)
-
- def __getattr__(self, item):
- if hasattr(self.dbus_method, item):
- return functools.partial(self._wrapper, item)
- else:
- return functools.partial(self, item)
-
- def _wrapper(self, _method_name, *args, **kwargs):
- return getattr(self.dbus_method, _method_name)(*args, **kwargs)
-
- def update(self):
- self._set_props()
-
-
-class ClientProxy(object):
- @staticmethod
- def _intf_short_name(nm):
- return nm.split('.')[-1:][0]
-
- def __init__(self, specified_bus, object_path, interface=None, props=None):
- i = dbus.Interface(specified_bus.get_object(
- BUSNAME, object_path), 'org.freedesktop.DBus.Introspectable')
- self.intro_spect = DbusIntrospection.introspect(i.Introspect())
-
- for k in self.intro_spect.keys():
- sn = ClientProxy._intf_short_name(k)
- # print('Client proxy has interface: %s %s' % (k, sn))
-
- if interface and interface == k and props is not None:
- ro = RemoteObject(specified_bus, object_path, k, props)
- else:
- ro = RemoteObject(specified_bus, object_path, k)
-
- setattr(self, sn, ro)
-
- self.object_path = object_path
-
- def update(self):
- # Go through all interfaces and update them
- for int_f in self.intro_spect.keys():
- sn = ClientProxy._intf_short_name(int_f)
- getattr(self, sn).update()
-
-
def get_objects():
rc = {MANAGER_INT: [], PV_INT: [], VG_INT: [], LV_INT: [],
THINPOOL_INT: [], JOB_INT: [], SNAPSHOT_INT: [], LV_COMMON_INT: [],
@@ -692,11 +529,12 @@ class TestDbusService(unittest.TestCase):
vg = self._vg_create(pv_paths).Vg
lv = self._create_lv(vg=vg, size=mib(16))
- for size in [
- lv.LvCommon.SizeBytes + 4194304,
- lv.LvCommon.SizeBytes - 4194304,
- lv.LvCommon.SizeBytes + 2048,
- lv.LvCommon.SizeBytes - 2048]:
+ for size in \
+ [
+ lv.LvCommon.SizeBytes + 4194304,
+ lv.LvCommon.SizeBytes - 4194304,
+ lv.LvCommon.SizeBytes + 2048,
+ lv.LvCommon.SizeBytes - 2048]:
pv_in_use = [i[0] for i in lv.LvCommon.Devices]
# Select a PV in the VG that isn't in use
@@ -1052,13 +890,16 @@ class TestDbusService(unittest.TestCase):
mgr = self._manager().Manager
- self.assertEqual(mgr.PvScan(False, True,
- dbus.Array([], 's'),
- dbus.Array([], '(ii)'), -1, {}), '/')
+ self.assertEqual(
+ mgr.PvScan(
+ False, True, dbus.Array([], 's'),
+ dbus.Array([], '(ii)'), -1, {}), '/')
self.assertEqual(self._refresh(), 0)
- self.assertEqual(mgr.PvScan(False, False,
- dbus.Array([], 's'),
- dbus.Array([], '(ii)'), -1, {}), '/')
+ self.assertEqual(
+ mgr.PvScan(
+ False, False,
+ dbus.Array([], 's'),
+ dbus.Array([], '(ii)'), -1, {}), '/')
self.assertEqual(self._refresh(), 0)
block_path = []
@@ -1081,9 +922,11 @@ class TestDbusService(unittest.TestCase):
self.assertEqual(self._refresh(), 0)
- self.assertEqual(mgr.PvScan(False, True,
- dbus.Array([], 's'),
- mm, -1, {}), '/')
+ self.assertEqual(
+ mgr.PvScan(
+ False, True,
+ dbus.Array([], 's'),
+ mm, -1, {}), '/')
self.assertEqual(self._refresh(), 0)
diff --git a/test/dbus/testlib.py b/test/dbus/testlib.py
new file mode 100644
index 0000000..550b0bf
--- /dev/null
+++ b/test/dbus/testlib.py
@@ -0,0 +1,174 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2015-2016 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import string
+import random
+import functools
+import xml.etree.ElementTree as Et
+from collections import OrderedDict
+import dbus
+
+BUSNAME = "com.redhat.lvmdbus1"
+MANAGER_INT = BUSNAME + '.Manager'
+MANAGER_OBJ = '/' + BUSNAME.replace('.', '/') + '/Manager'
+PV_INT = BUSNAME + ".Pv"
+VG_INT = BUSNAME + ".Vg"
+LV_INT = BUSNAME + ".Lv"
+THINPOOL_INT = BUSNAME + ".ThinPool"
+SNAPSHOT_INT = BUSNAME + ".Snapshot"
+LV_COMMON_INT = BUSNAME + ".LvCommon"
+JOB_INT = BUSNAME + ".Job"
+CACHE_POOL_INT = BUSNAME + ".CachePool"
+CACHE_LV_INT = BUSNAME + ".CachedLv"
+
+THINPOOL_LV_PATH = '/' + THINPOOL_INT.replace('.', '/')
+
+
+def rs(length, suffix, character_set=string.ascii_lowercase):
+ return ''.join(random.choice(character_set)
+ for _ in range(length)) + suffix
+
+
+def mib(s):
+ return 1024 * 1024 * s
+
+
+class DbusIntrospection(object):
+ @staticmethod
+ def introspect(xml_representation):
+ interfaces = {}
+
+ root = Et.fromstring(xml_representation)
+
+ for c in root:
+ if c.tag == "interface":
+ in_f = c.attrib['name']
+ interfaces[in_f] = \
+ dict(methods=OrderedDict(), properties={})
+ for nested in c:
+ if nested.tag == "method":
+ mn = nested.attrib['name']
+ interfaces[in_f]['methods'][mn] = OrderedDict()
+
+ for arg in nested:
+ if arg.tag == 'arg':
+ arg_dir = arg.attrib['direction']
+ if arg_dir == 'in':
+ n = arg.attrib['name']
+ else:
+ n = None
+
+ arg_type = arg.attrib['type']
+
+ if n:
+ v = dict(
+ name=mn,
+ a_dir=arg_dir,
+ a_type=arg_type)
+ interfaces[in_f]['methods'][mn][n] = v
+
+ elif nested.tag == 'property':
+ pn = nested.attrib['name']
+ p_access = nested.attrib['access']
+ p_type = nested.attrib['type']
+
+ interfaces[in_f]['properties'][pn] = \
+ dict(p_access=p_access, p_type=p_type)
+ else:
+ pass
+
+ # print('Interfaces...')
+ # for k, v in list(interfaces.items()):
+ # print('Interface %s' % k)
+ # if v['methods']:
+ # for m, args in list(v['methods'].items()):
+ # print(' method: %s' % m)
+ # for a, aa in args.items():
+ # print(' method arg: %s' % (a))
+ # if v['properties']:
+ # for p, d in list(v['properties'].items()):
+ # print(' Property: %s' % (p))
+ # print('End interfaces')
+
+ return interfaces
+
+
+class RemoteObject(object):
+ def _set_props(self, props=None):
+ # print 'Fetching properties'
+ if not props:
+ # prop_fetch = dbus.Interface(self.bus.get_object(
+ # BUSNAME, self.object_path), 'org.freedesktop.DBus.Properties')
+
+ for i in range(0, 3):
+ try:
+ prop_fetch = dbus.Interface(self.bus.get_object(
+ BUSNAME, self.object_path),
+ 'org.freedesktop.DBus.Properties')
+ props = prop_fetch.GetAll(self.interface)
+ break
+ except dbus.exceptions.DBusException as dbe:
+ if "GetAll" not in str(dbe):
+ raise dbe
+ if props:
+ for kl, vl in list(props.items()):
+ setattr(self, kl, vl)
+
+ def __init__(self, specified_bus, object_path, interface, properties=None):
+ self.object_path = object_path
+ self.interface = interface
+ self.bus = specified_bus
+
+ self.dbus_method = dbus.Interface(specified_bus.get_object(
+ BUSNAME, self.object_path), self.interface)
+
+ self._set_props(properties)
+
+ def __getattr__(self, item):
+ if hasattr(self.dbus_method, item):
+ return functools.partial(self._wrapper, item)
+ else:
+ return functools.partial(self, item)
+
+ def _wrapper(self, _method_name, *args, **kwargs):
+ return getattr(self.dbus_method, _method_name)(*args, **kwargs)
+
+ def update(self):
+ self._set_props()
+
+
+class ClientProxy(object):
+ @staticmethod
+ def _intf_short_name(nm):
+ return nm.split('.')[-1:][0]
+
+ def __init__(self, specified_bus, object_path, interface=None, props=None):
+ i = dbus.Interface(specified_bus.get_object(
+ BUSNAME, object_path), 'org.freedesktop.DBus.Introspectable')
+ self.intro_spect = DbusIntrospection.introspect(i.Introspect())
+
+ for k in self.intro_spect.keys():
+ sn = ClientProxy._intf_short_name(k)
+ # print('Client proxy has interface: %s %s' % (k, sn))
+
+ if interface and interface == k and props is not None:
+ ro = RemoteObject(specified_bus, object_path, k, props)
+ else:
+ ro = RemoteObject(specified_bus, object_path, k)
+
+ setattr(self, sn, ro)
+
+ self.object_path = object_path
+
+ def update(self):
+ # Go through all interfaces and update them
+ for int_f in self.intro_spect.keys():
+ sn = ClientProxy._intf_short_name(int_f)
+ getattr(self, sn).update()
8 years, 2 months
master - lvmdbusd: Reduce unnecessary state refreshes
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f1bc68beb4e493...
Commit: f1bc68beb4e493a9c1a52750e99d50f874ca89d9
Parent: 045d086a570d327b00a4a06d139b387d059ade60
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Feb 25 14:57:12 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Feb 25 16:43:55 2016 -0600
lvmdbusd: Reduce unnecessary state refreshes
When we use udev or have lvm call back into the dbus service when a
change occurs, even if that change originated from the dbus service
we end up refreshing the state of the system twice which is not
needed or wanted. This change handles this case by removing any
pending refreshes in the worker queue if the state of the system
was just updated.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
daemons/lvmdbusd/lvmdb.py | 3 +--
daemons/lvmdbusd/main.py | 43 ++++++++++++++++++++++++++++++++++++-------
2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/daemons/lvmdbusd/lvmdb.py b/daemons/lvmdbusd/lvmdb.py
index 46e2099..132bee7 100755
--- a/daemons/lvmdbusd/lvmdb.py
+++ b/daemons/lvmdbusd/lvmdb.py
@@ -272,10 +272,9 @@ class DataStore(object):
:param log Add debug log entry/exit messages
:return: None
"""
-
+ self.num_refreshes += 1
if log:
log_debug("lvmdb - refresh entry")
- self.num_refreshes += 1
# Grab everything first then parse it
_raw_pvs = cmdhandler.pv_retrieve_with_segs()
diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py
index c9211f7..6cabcc4 100644
--- a/daemons/lvmdbusd/main.py
+++ b/daemons/lvmdbusd/main.py
@@ -24,11 +24,11 @@ from .manager import Manager
from .background import background_reaper
import traceback
import queue
-import sys
from . import udevwatch
from .utils import log_debug
import argparse
import os
+from .refresh import handle_external_event, event_complete
class Lvm(objectmanager.ObjectManager):
@@ -36,6 +36,30 @@ class Lvm(objectmanager.ObjectManager):
super(Lvm, self).__init__(object_path, BASE_INTERFACE)
+def _discard_pending_refreshes():
+ # We just handled a refresh, if we have any in the queue they can be
+ # removed because by definition they are older than the refresh we just did.
+ # As we limit the number of refreshes getting into the queue
+ # we should only ever have one to remove.
+ requests = []
+ while not cfg.worker_q.empty():
+ try:
+ r = cfg.worker_q.get(block=False)
+ if r.method != handle_external_event:
+ requests.append(r)
+ else:
+ # Make sure we make this event complete even though it didn't
+ # run, otherwise no other events will get processed
+ event_complete()
+ break
+ except queue.Empty:
+ break
+
+ # Any requests we removed, but did not discard need to be re-queued
+ for r in requests:
+ cfg.worker_q.put(r)
+
+
def process_request():
while cfg.run.value != 0:
try:
@@ -50,16 +74,21 @@ def process_request():
end = cfg.db.num_refreshes
- if end - start > 1:
- log_debug(
- "Inspect method %s for too many refreshes" %
- (str(req.method)))
+ num_refreshes = end - start
+
+ if num_refreshes > 0:
+ _discard_pending_refreshes()
+
+ if num_refreshes > 1:
+ log_debug(
+ "Inspect method %s for too many refreshes" %
+ (str(req.method)))
log_debug("Complete ")
except queue.Empty:
pass
except Exception:
- traceback.print_exc(file=sys.stdout)
- pass
+ st = traceback.format_exc()
+ utils.log_error("process_request exception: \n%s" % st)
def main():
8 years, 2 months
master - pvcreate: fix error from pv_write
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=045d086a570d32...
Commit: 045d086a570d327b00a4a06d139b387d059ade60
Parent: 23a4801dbcc4d351db6c251685e08f3fec30cbdd
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 25 16:38:59 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Feb 25 16:40:24 2016 -0600
pvcreate: fix error from pv_write
After a pv_write() failure, the PV wasn't being skipped.
---
tools/toollib.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 8029030..dd5ece3 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -4452,6 +4452,7 @@ do_command:
if (!pv_write(cmd, pv, 0)) {
log_error("Failed to write physical volume \"%s\"", pv_name);
dm_list_move(&pp->arg_fail, &pd->list);
+ continue;
}
log_print_unless_silent("Physical volume \"%s\" successfully created", pv_name);
8 years, 2 months
master - tests: lvresize with zero arg
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=23a4801dbcc4d3...
Commit: 23a4801dbcc4d351db6c251685e08f3fec30cbdd
Parent: 1a9f743eefbe8d86f6a23838789c21136f02cdcd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 25 21:58:43 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Feb 25 23:30:26 2016 +0100
tests: lvresize with zero arg
---
test/shell/lvresize-usage.sh | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvresize-usage.sh b/test/shell/lvresize-usage.sh
index 13f4e1f..a136147 100644
--- a/test/shell/lvresize-usage.sh
+++ b/test/shell/lvresize-usage.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2007-2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2007-2016 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -18,6 +18,8 @@ aux prepare_vg 2 80
lvcreate -L 10M -n lv -i2 $vg
lvresize -l +4 $vg/lv
+not lvextend -L+0 $vg/lv
+not lvextend -l+0 $vg/lv
lvremove -ff $vg
lvcreate -L 64M -n $lv -i2 $vg
8 years, 2 months
master - cleanup: drop unneeded test
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1a9f743eefbe8d...
Commit: 1a9f743eefbe8d86f6a23838789c21136f02cdcd
Parent: e9b523e3044b83fc1a919f8a07a85d169c7d4d55
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 25 16:51:14 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Feb 25 23:30:25 2016 +0100
cleanup: drop unneeded test
dmfree tests for NULL
---
lib/cache/lvmcache.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index c28460e..b1e53e2 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1177,9 +1177,7 @@ static int _free_vginfo(struct lvmcache_vginfo *vginfo)
vginfo2 = vginfo2->next;
}
- if (vginfo->system_id)
- dm_free(vginfo->system_id);
-
+ dm_free(vginfo->system_id);
dm_free(vginfo->vgname);
dm_free(vginfo->creation_host);
8 years, 2 months
master - cleanup: indent
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e9b523e3044b83...
Commit: e9b523e3044b83fc1a919f8a07a85d169c7d4d55
Parent: 5c29b54d4dbf0a94525172f5526fd5ff7996de48
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 25 16:50:22 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Feb 25 23:30:25 2016 +0100
cleanup: indent
Last update missed to indent params.
---
lib/metadata/pv_manip.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index 48706d1..d38262d 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -757,10 +757,10 @@ static int pvremove_check(struct cmd_context *cmd, const char *name,
if (force_count)
log_warn("WARNING: Wiping physical volume label from "
- "%s%s%s%s", name,
- !is_orphan(pv) ? " of volume group \"" : "",
- pv_vg_name(pv),
- !is_orphan(pv) ? "\"" : "");
+ "%s%s%s%s", name,
+ !is_orphan(pv) ? " of volume group \"" : "",
+ pv_vg_name(pv),
+ !is_orphan(pv) ? "\"" : "");
r = 1;
bad:
8 years, 2 months