Skip to content

Commit

Permalink
Improve instances code (#654)
Browse files Browse the repository at this point in the history
Problem: If an instance is created and removed, one of the base mounted devices remains on the system. Also, a user cannot create a qemu disk from Debian image.

Solution: Remove the useless device from the system and create the two needed script to create Qemu Debian runtimes.
  • Loading branch information
nesitor authored Jul 5, 2024
1 parent 4a9eabd commit 1fedcd7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions runtimes/instance-rootfs/create-debian-11-qemu-disk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -euf

# Variables
ROOTFS_FILENAME="./rootfs.img"
IMAGE_URL="https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2"
IMAGE_NAME="debian-11-genericcloud-amd64.qcow2"

# Cleanup previous run
rm -f "$ROOTFS_FILENAME"

# Download Ubuntu image
echo "Downloading Debian 11 image"
curl -L "$IMAGE_URL" -o "$IMAGE_NAME"

# Rename final file
mv "$IMAGE_NAME" "$ROOTFS_FILENAME"
18 changes: 18 additions & 0 deletions runtimes/instance-rootfs/create-debian-12-qemu-disk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -euf

# Variables
ROOTFS_FILENAME="./rootfs.img"
IMAGE_URL="https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2"
IMAGE_NAME="debian-12-genericcloud-amd64.qcow2"

# Cleanup previous run
rm -f "$ROOTFS_FILENAME"

# Download Ubuntu image
echo "Downloading Debian 12 image"
curl -L "$IMAGE_URL" -o "$IMAGE_NAME"

# Rename final file
mv "$IMAGE_NAME" "$ROOTFS_FILENAME"
1 change: 1 addition & 0 deletions src/aleph/vm/hypervisors/firecracker/microvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ async def teardown(self):
await asyncio.sleep(1)
root_fs = self.mounted_rootfs.name
system(f"dmsetup remove {root_fs}")
system(f"dmsetup remove {root_fs}_base")
if self.use_jailer and Path(self.jailer_path).is_dir():
shutil.rmtree(self.jailer_path)

Expand Down

0 comments on commit 1fedcd7

Please sign in to comment.