From 417562a115669cba0dc078730ad673d089f29ea4 Mon Sep 17 00:00:00 2001 From: Molly Miller Date: Fri, 18 Oct 2024 10:51:53 +0200 Subject: [PATCH] Add logging and test coverage for guest tmp volume seeding --- src/fc/qemu/hazmat/volume.py | 14 ++++++++------ src/fc/qemu/tests/vm_test.py | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/fc/qemu/hazmat/volume.py b/src/fc/qemu/hazmat/volume.py index 390f50c..52d081f 100644 --- a/src/fc/qemu/hazmat/volume.py +++ b/src/fc/qemu/hazmat/volume.py @@ -424,16 +424,18 @@ def seed(self, enc, generation): # the ENC data, a separate file allows properties which # are not exposed to guests through ENC to be added in the # future. + properties = {} + properties["binary_generation"] = generation + for key in self.ENC_SEED_PARAMETERS: + if key in enc["parameters"]: + properties[key] = enc["parameters"][key] + self.log.debug("guest-properties", properties=properties) guest_properties = p.join(fc_data, "qemu-guest-properties-booted") with open(guest_properties, "w") as f: - props = {} - props["binary_generation"] = generation - for key in self.ENC_SEED_PARAMETERS: - if key in enc["parameters"]: - props[key] = enc["parameters"][key] - json.dump(props, f) + json.dump(properties, f) # For backwards compatibility with old fc-agent versions, # write the Qemu binary generation into a separate file. + self.log.debug("binary-generation", generation=generation) generation_marker = p.join(fc_data, "qemu-binary-generation-booted") with open(generation_marker, "w") as f: f.write(str(generation) + "\n") diff --git a/src/fc/qemu/tests/vm_test.py b/src/fc/qemu/tests/vm_test.py index 701c6ac..16f6688 100644 --- a/src/fc/qemu/tests/vm_test.py +++ b/src/fc/qemu/tests/vm_test.py @@ -86,6 +86,8 @@ def test_simple_vm_lifecycle_start_stop(vm, patterns): seed machine=simplevm subsystem=ceph volume=rbd.ssd/simplevm.tmp mount args="/dev/rbd/rbd.ssd/simplevm.tmp-part1" "/mnt/rbd/rbd.ssd/simplevm.tmp" machine=simplevm subsystem=ceph volume=rbd.ssd/simplevm.tmp mount machine=simplevm returncode=0 subsystem=ceph volume=rbd.ssd/simplevm.tmp +guest-properties machine=simplevm properties={'binary_generation': 2, 'rbd_pool': 'rbd.ssd'} subsystem=ceph volume=rbd.ssd/simplevm.tmp +binary-generation generation=2 machine=simplevm subsystem=ceph volume=rbd.ssd/simplevm.tmp umount args="/mnt/rbd/rbd.ssd/simplevm.tmp" machine=simplevm subsystem=ceph volume=rbd.ssd/simplevm.tmp umount machine=simplevm returncode=0 subsystem=ceph volume=rbd.ssd/simplevm.tmp rbd args=-c "/etc/ceph/ceph.conf" --id "host1" unmap "/dev/rbd/rbd.ssd/simplevm.tmp" machine=simplevm subsystem=ceph volume=rbd.ssd/simplevm.tmp