Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log-level and remove enable_debug_mode param #4017

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions virttest/qemu_devices/qcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3680,14 +3680,14 @@ def fs_define_by_params(self, name, params, bus=None):
)
else:
binary = params.get("fs_binary", "/usr/libexec/virtiofsd")
log_level = params.get("fs_log_level")
extra_options = params.get("fs_binary_extra_options")
enable_debug_mode = params.get("fs_enable_debug_mode", "no") == "yes"
sock_path = os.path.join(
data_dir.get_tmp_dir(),
"-".join((self.vmname, name, "virtiofsd.sock")),
)
vfsd = qdevices.QVirtioFSDev(
name, binary, sock_path, source, extra_options, enable_debug_mode
name, binary, sock_path, source, log_level, extra_options
)
devices.append(vfsd)

Expand Down
31 changes: 23 additions & 8 deletions virttest/qemu_devices/qdevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2226,8 +2226,8 @@ def __init__(
binary,
sock_path,
source,
log_level=None,
extra_options=None,
enable_debug_mode=False,
):
"""
:param aobject: The aobject of virtiofs daemon.
Expand All @@ -2238,19 +2238,19 @@ def __init__(
:type sock_path: str
:param source: The source of virtiofs daemon.
:type source: str
:param log_level: The log level of virtiofs daemon.
:type log_level: str
:param extra_options: The external options of virtiofs daemon.
:type extra_options: str
:param enable_debug_mode: Enable debug mode of virtiofs daemon.
:type enable_debug_mode: bool
"""
super(QVirtioFSDev, self).__init__(
"virtiofs", aobject=aobject, child_bus=QUnixSocketBus(sock_path, aobject)
)
self.set_param("binary", binary)
self.set_param("sock_path", sock_path)
self.set_param("source", source)
self.set_param("log_level", log_level)
self.set_param("extra_options", extra_options)
self.set_param("enable_debug_mode", enable_debug_mode)

def _handle_log(self, line):
"""Handle the log of virtiofs daemon."""
Expand All @@ -2265,6 +2265,9 @@ def start_daemon(self):
virtiofs_binary = self.get_param("binary")
socket_path = self.get_param("sock_path")
source_dir = self.get_param("source")
log_level = self.get_param("log_level")

allowed_log_levels = {"error", "warn", "info", "debug", "trace", "off"}

fsd_cmd = f"{virtiofs_binary} --socket-path={socket_path}"

Expand All @@ -2284,12 +2287,24 @@ def start_daemon(self):
and "separate-options" in virtiofs_cpblt["features"]
):
fsd_cmd += f" --shared-dir {source_dir}"
if log_level in allowed_log_levels:
fsd_cmd += f" --log-level {log_level}"
self.set_param(
"status_active", "Waiting for vhost-user socket connection"
)
else:
raise DeviceError(
f"Only {allowed_log_levels} log levels are supported."
)
else:
fsd_cmd += f" -o source={source_dir}"

if self.get_param("enable_debug_mode") == "on":
fsd_cmd += " -d"
self.set_param("status_active", "Waiting for vhost-user socket connection")
if log_level == "debug":
fsd_cmd += " -d"
self.set_param(
"status_active", "Waiting for vhost-user socket connection"
)
else:
raise DeviceError("Only debug log-level is supported.")

if self.get_param("extra_options"):
fsd_cmd += self.get_param("extra_options")
Expand Down
Loading