From 51f785b87acaf991a5af26c9f2e38111b2de7ab1 Mon Sep 17 00:00:00 2001 From: Andrea Righi Date: Thu, 21 Dec 2023 10:38:03 +0100 Subject: [PATCH] virtme: show virtiofsd warnings only in verbose mode Hide virtiofsd warnings that may confuse users, unless we are running in verbose mode. This fixes issue #51. Signed-off-by: Andrea Righi --- virtme/commands/run.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 155ba36..930fb9e 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -600,8 +600,12 @@ def start(self, path, verbose=True): # Export the whole root fs of the host, do not enable sandbox, otherwise we # would get permission errors. + if not verbose: + stderr = "2>/dev/null" + else: + stderr = "" os.system( - f"{virtiofsd_path} --syslog --socket-path {self.sock} --shared-dir {path} --sandbox none &" + f"{virtiofsd_path} --syslog --socket-path {self.sock} --shared-dir {path} --sandbox none {stderr} &" ) max_attempts = 5 check_duration = 0.1 @@ -613,7 +617,8 @@ def start(self, path, verbose=True): sleep(check_duration) check_duration *= 2 else: - print("virtme-run: failed to start virtiofsd, fallback to 9p") + if verbose: + sys.stderr.write("virtme-run: failed to start virtiofsd, fallback to 9p") return False return True