From 52e83c953b46ca7df0012ef792db661c10967d05 Mon Sep 17 00:00:00 2001 From: NorthSky <53655849+RyrieNorth@users.noreply.github.com> Date: Thu, 13 Aug 2026 04:40:26 +0800 Subject: [PATCH] Refactor change_permission method for KVM permission --- cli/src/device/emulator.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cli/src/device/emulator.py b/cli/src/device/emulator.py index 224f5d774..44580e9cd 100644 --- a/cli/src/device/emulator.py +++ b/cli/src/device/emulator.py @@ -164,15 +164,14 @@ def create(self) -> None: def change_permission(self) -> None: kvm_path = "/dev/kvm" - if os.path.exists(kvm_path): - cmds = (f"sudo chown 1300:1301 {kvm_path}", - "sudo sed -i '1d' /etc/passwd") - for c in cmds: - subprocess.check_call(c, shell=True) - self.logger.info("KVM permission is granted!") - else: + if not os.path.exists(kvm_path): raise RuntimeError("/dev/kvm cannot be found!") - + subprocess.check_call( + f"sudo chown 1300:1301 {kvm_path}", + shell=True + ) + self.logger.info("KVM permission is granted!") + def deploy(self): self.logger.info(f"Deploying the {self.device_type}")