From ef278b0c0eefd41d9e78c249881719ba0ce8c467 Mon Sep 17 00:00:00 2001 From: Molly Miller Date: Wed, 16 Oct 2024 12:42:57 +0200 Subject: [PATCH] Write guest properties from KVM environment into agent Allow the guest to detect whether the KVM environment has changed at runtime in combination with the boot-time seed data. --- src/fc/qemu/agent.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/fc/qemu/agent.py b/src/fc/qemu/agent.py index d0ef734..aebcb15 100644 --- a/src/fc/qemu/agent.py +++ b/src/fc/qemu/agent.py @@ -1088,6 +1088,7 @@ def ensure_online_local(self): # reduce the time we're unnecessarily waiting for timeouts. self.ensure_thawed() self.mark_qemu_binary_generation() + self.mark_qemu_guest_properties() def cleanup(self): """Removes various run and tmp files.""" @@ -1102,6 +1103,23 @@ def ensure_thawed(self): except Exception as e: self.log.error("ensure-thawed-failed", reason=str(e)) + def mark_qemu_guest_properties(self): + props = { + "binary_generation": self.binary_generation, + "cpu_model": self.cfg["cpu_model"], + "rbd_pool": self.cfg["rbd_pool"], + } + self.log.info( + "mark-qemu-guest-properties", properties=props, + ) + try: + self.qemu.write_file( + "/run/qemu-guest-properties-current", + (json.dumps(props)).encode("ascii"), + ) + except Exception as e: + self.log.error("mark-qemu-guest-properties", reason=str(e)) + def mark_qemu_binary_generation(self): self.log.info( "mark-qemu-binary-generation", generation=self.binary_generation