1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

lvmdbusd: Add --blackboxsize command line argument

Allows the user to override the number of commands that get dumped
to the log when we encounter a lvm error.  Also useful during
development when you don't want to see the blackbox output.
This commit is contained in:
Tony Asleson 2016-11-29 18:01:56 -06:00
parent b0757ac96e
commit 3bc69cb23c
2 changed files with 21 additions and 8 deletions

View File

@ -55,18 +55,19 @@ class LvmExecutionMeta(object):
class LvmFlightRecorder(object):
def __init__(self):
self.queue = collections.deque(maxlen=16)
def __init__(self, size=16):
self.queue = collections.deque(maxlen=size)
def add(self, lvm_exec_meta):
self.queue.append(lvm_exec_meta)
def dump(self):
with cmd_lock:
log_error("LVM dbus flight recorder START")
for c in self.queue:
log_error(str(c))
log_error("LVM dbus flight recorder END")
if len(self.queue):
log_error("LVM dbus flight recorder START")
for c in self.queue:
log_error(str(c))
log_error("LVM dbus flight recorder END")
cfg.blackbox = LvmFlightRecorder()

View File

@ -29,6 +29,7 @@ from .utils import log_debug, log_error
import argparse
import os
import sys
from .cmdhandler import LvmFlightRecorder
class Lvm(objectmanager.ObjectManager):
@ -75,6 +76,12 @@ def main():
help="Use the lvm shell, not fork & exec lvm",
default=False,
dest='use_lvm_shell')
parser.add_argument(
"--blackboxsize",
help="Size of the black box flight recorder, 0 to disable",
default=10,
type=int,
dest='bb_size')
use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
@ -83,6 +90,11 @@ def main():
cfg.args = parser.parse_args()
# We create a flight recorder in cmdhandler too, but we replace it here
# as the user may be specifying a different size. The default one in
# cmdhandler is for when we are running other code with a different main.
cfg.blackbox = LvmFlightRecorder(cfg.args.bb_size)
if cfg.args.use_lvm_shell and not cfg.args.use_json:
log_error("You cannot specify --lvmshell and --nojson")
sys.exit(1)
@ -118,8 +130,8 @@ def main():
# thread that is handling the dbus interface
thread_list.append(threading.Thread(target=process_request))
# Have a single thread handling updating lvm and the dbus model so we don't
# have multiple threads doing this as the same time
# Have a single thread handling updating lvm and the dbus model so we
# don't have multiple threads doing this as the same time
updater = StateUpdate()
thread_list.append(updater.thread)