]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
qemu: Make sure qemu/VM exit status take priority
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 11 Apr 2024 08:11:51 +0000 (10:11 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 11 Apr 2024 08:42:19 +0000 (10:42 +0200)
In spawn(), if an exception is raised by the context manager block,
we'll let it take priority over any exception we raise in spawn()
itself. Let's make use of this to make sure the qemu/VM exit code
always takes priority by raising the CalledProcessError from within
the qemu spawn() block.

We also let any qemu error take precedence over any EXIT_STATUS error.

mkosi/qemu.py

index e32b3b48512cc559865db150cc9573bea5254a5e..f54ebcf16fabd4942ce56c8c2bbec8ff2d9db790 100644 (file)
@@ -1100,8 +1100,8 @@ def run_qemu(args: Args, config: Config) -> None:
             )
             register_machine(config, qemu.pid, fname)
 
-    if status := int(notifications.get("EXIT_STATUS", 0)):
-        raise subprocess.CalledProcessError(status, cmdline)
+            if qemu.wait() == 0 and (status := int(notifications.get("EXIT_STATUS", 0))):
+                raise subprocess.CalledProcessError(status, cmdline)
 
 
 def run_ssh(args: Args, config: Config) -> None: