Skip to content

Commit d340eb3

Browse files
committed
Activate LVM thin volumes and bump changelog
1 parent 32b749b commit d340eb3

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

host-agent/backend/storage/lvmthin.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ def __init__(self, vg: str, pool: str, base_name: str, vm_lv: str, image: Path,
1818
self.image = image
1919
self.size_hint = size_hint
2020

21+
def _activate_lv(self, lv: str) -> None:
22+
lv_path = lv if "/" in lv else f"{self.vg}/{lv}"
23+
try:
24+
subprocess.run(["lvchange", "-kn", lv_path], check=True)
25+
subprocess.run(["lvchange", "-ay", lv_path], check=True)
26+
except subprocess.CalledProcessError as e:
27+
raise StorageError(f"Failed to activate LV {lv_path}: {e}") from e
28+
29+
try:
30+
subprocess.run(["udevadm", "settle"], check=True)
31+
except Exception as e:
32+
logger.warning("udevadm settle failed for %s: %s", lv_path, e)
33+
2134
def prepare(self) -> None:
2235
try:
2336
logger.info("Preparing thin snapshot %s/%s from base %s", self.vg, self.vm_lv, self.base_name)
@@ -27,16 +40,18 @@ def prepare(self) -> None:
2740
["lvcreate", "-V", self.size_hint or "1G", "-T", f"{self.vg}/{self.pool}", "-n", self.base_name],
2841
check=True,
2942
)
43+
self._activate_lv(self.base_name)
3044
dev_path = f"/dev/{self.vg}/{self.base_name}"
3145
fstype = detect_fstype_from_image(self.image)
3246
mkfs_device(dev_path, fstype)
3347
# Copy image to base LV
3448
copy_image_to_device(self.image, dev_path)
49+
else:
50+
self._activate_lv(self.base_name)
3551
# 2. Create snapshot for VM
3652
if not lv_exists(self.vg, self.vm_lv):
3753
subprocess.run(["lvcreate", "-s", "-n", self.vm_lv, f"{self.vg}/{self.base_name}"], check=True)
38-
else:
39-
subprocess.run(["lvchange", "-ay", f"{self.vg}/{self.vm_lv}"], check=True)
54+
self._activate_lv(self.vm_lv)
4055
except Exception as e:
4156
raise StorageError(f"Failed to prepare thin volume {self.vg}/{self.vm_lv}: {e}") from e
4257

host-agent/debian/changelog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
firecracker-cloudstack-agent (0.4.0-7) unstable; urgency=medium
2+
3+
* Activate thin LVM base/snapshot volumes immediately after creation so
4+
Firecracker root disks always appear under /dev/<vg>/<lv>.
5+
6+
-- Marco Sinhoreli <msinhore@gmail.com> Thu, 13 Nov 2025 10:26:00 +0000
7+
18
firecracker-cloudstack-agent (0.4.0-6) unstable; urgency=medium
29

310
* Ensure the console endpoint always returns host/port/password by ignoring

0 commit comments

Comments
 (0)