From 242c76dfd545d4ddefcabaf4f6994186e51f3ef9 Mon Sep 17 00:00:00 2001 From: Tingting Mao Date: Fri, 30 Aug 2024 04:56:36 -0400 Subject: [PATCH] qdevices: Adapt virtiofsd options Some options are deprecated since the dedicated virtiofsd package since rhel9, while before virtiofsd belongs to qemu package. Signed-off-by: Tingting Mao --- virttest/qemu_devices/qdevices.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/virttest/qemu_devices/qdevices.py b/virttest/qemu_devices/qdevices.py index 8a5d8023e4..77cf9636f3 100644 --- a/virttest/qemu_devices/qdevices.py +++ b/virttest/qemu_devices/qdevices.py @@ -12,6 +12,7 @@ import re import shutil import signal +import subprocess import time import traceback from collections import OrderedDict @@ -2259,11 +2260,26 @@ def _handle_log(self, line): def start_daemon(self): """Start the virtiofs daemon in background.""" - fsd_cmd = "%s --socket-path=%s" % ( - self.get_param("binary"), - self.get_param("sock_path"), + virtiofs_binary = self.get_param("binary") + socket_path = self.get_param("sock_path") + source_dir = self.get_param("source") + + fsd_cmd = f"{virtiofs_binary} --socket-path={socket_path}" + + # capture the capabilities of virtiofsd + result = subprocess.run( + [virtiofs_binary, "--print-capabilities"], universal_newlines=True ) - fsd_cmd += " -o source=%s" % self.get_param("source") + virtiofs_cpblt = json.loads(result.stdout) + + if ( + "features" in virtiofs_cpblt + and "separate-options" in virtiofs_cpblt["features"] + ): + fsd_cmd += f" --shared-dir {source_dir}" + 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")