From 36f855ad256a29ce55316180f0756cd6ffa12d5d Mon Sep 17 00:00:00 2001 From: Stephen Cheng Date: Tue, 30 Sep 2025 16:26:05 +0800 Subject: [PATCH] CA-417888: Check if dracut exists before calling weak_module in dmv.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The install image doesn’t have dracut installed, while dmv.py calls weak_module which indirectly calls dracut when selecting drivers in install enviornment. Signed-off-by: Stephen Cheng --- xcp/dmv.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/xcp/dmv.py b/xcp/dmv.py index 2fa8e8cd..e83a3109 100644 --- a/xcp/dmv.py +++ b/xcp/dmv.py @@ -350,14 +350,16 @@ def create_dmv_symlink(self, name, ver): os.symlink(module_file, tmp_name) os.rename(tmp_name, module_sym) created = True - modules = [module_sym] - input_data = "\n".join(modules) + "\n" - subprocess.run( - ["/usr/sbin/weak-modules", "--no-initramfs", "--add-modules"], - input=input_data, - text=True, - check=True - ) + # weak-modules will call dracut, while no dracut in install image + if os.path.exists("/usr/bin/dracut"): + modules = [module_sym] + input_data = "\n".join(modules) + "\n" + subprocess.run( + ["/usr/sbin/weak-modules", "--no-initramfs", "--add-modules"], + input=input_data, + text=True, + check=True + ) if created: subprocess.run(["/usr/sbin/depmod", "-a"], check=True) uname_r = subprocess.run(["uname", '-r'], stdout=subprocess.PIPE, text=True,