1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvmdbusd: Move arg. setup/checking to function

This commit is contained in:
Tony Asleson 2022-08-08 20:44:32 -05:00
parent 3eb19c4b7a
commit 1a4384979c
2 changed files with 26 additions and 15 deletions

View File

@ -25,7 +25,7 @@ from .manager import Manager
import traceback import traceback
import queue import queue
from . import udevwatch from . import udevwatch
from .utils import log_debug, log_error from .utils import log_debug, log_error, log_msg
import argparse import argparse
import os import os
import sys import sys
@ -81,9 +81,7 @@ def install_signal_handlers():
log_error("GLib.unix_signal_[add|add_full] are NOT available!") log_error("GLib.unix_signal_[add|add_full] are NOT available!")
def main(): def process_args():
start = time.time()
# Add simple command line handling
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument(
"--udev", action='store_true', "--udev", action='store_true',
@ -110,14 +108,9 @@ def main():
type=check_bb_size, type=check_bb_size,
dest='bb_size') dest='bb_size')
use_session = os.getenv('LVMDBUSD_USE_SESSION', False) args = parser.parse_args()
# Ensure that we get consistent output for parsing stdout/stderr if not args.use_json:
os.environ["LC_ALL"] = "C"
cfg.args = parser.parse_args()
if not cfg.args.use_json:
log_error("Daemon no longer supports lvm without JSON support, exiting!") log_error("Daemon no longer supports lvm without JSON support, exiting!")
sys.exit(1) sys.exit(1)
else: else:
@ -125,6 +118,24 @@ def main():
log_error("Un-supported version of LVM, daemon requires JSON output, exiting!") log_error("Un-supported version of LVM, daemon requires JSON output, exiting!")
sys.exit(1) sys.exit(1)
# Add udev watching
if args.use_udev:
# Make sure this msg ends up in the journal, so we know
log_msg('Utilizing udev to trigger updates')
return args
def main():
start = time.time()
use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
# Ensure that we get consistent output for parsing stdout/stderr
os.environ["LC_ALL"] = "C"
# Add simple command line handling
cfg.args = process_args()
cfg.create_request_entry = RequestEntry cfg.create_request_entry = RequestEntry
# We create a flight recorder in cmdhandler too, but we replace it here # We create a flight recorder in cmdhandler too, but we replace it here
@ -178,10 +189,6 @@ def main():
thread.damon = True thread.damon = True
thread.start() thread.start()
# Add udev watching
if cfg.args.use_udev:
log_debug('Utilizing udev to trigger updates')
# In all cases we are going to monitor for udev until we get an # In all cases we are going to monitor for udev until we get an
# ExternalEvent. In the case where we get an external event and the user # ExternalEvent. In the case where we get an external event and the user
# didn't specify --udev we will stop monitoring udev # didn't specify --udev we will stop monitoring udev

View File

@ -313,6 +313,10 @@ def log_error(msg, *attributes):
_common_log(msg, *attributes) _common_log(msg, *attributes)
def log_msg(msg, *attributes):
_common_log(msg, *attributes)
def dump_threads_stackframe(): def dump_threads_stackframe():
ident_to_name = {} ident_to_name = {}