ixdotai/qemu-ceph

By ixdotai

Updated over 3 years ago

An image with QEMU and CEPH tools

Image

3.0K

Pipeline StatusDocker StarsDocker PullsDocker Image Version (latest)Docker Image Size (latest)Gitlab Project

docker-qemu-ceph

A docker image, based on registry.gitlab.com/ix.ai/qemu:5.1.0, with added CEPH common tools

Multi-arch build: linux/amd64, linux/arm64, linux/arm/v7

Usage

Note: Make sure to read the README.md in ix.ai/docker-qemu>! All the environment variables are supported.

In addition, this image allows you to:

  • automatically create a clone of an RBD snapshot on startup
  • automatically trash the clone on stop

The following additional environment variables are implemented:

  • CEPH_CLIENT_ID - the client id for authentication (default: admin)
  • CEPH_SNAP - the snapshot to use as a base for the image (example: rbd/alpine@original)
  • CEPH_CLONE - the name of the new clone (example: rbd/alpine-test)
  • CEPH_TRASH_CLONE - set to 0 it will skip the trash command on exit (default: 1)
  • CEPH_TRASH_CLONE_IF_EXISTS - set to 1 it will trash an existing clone on startup (default: 0)
  • CEPH_IGNORE_CLONE_EXISTS - set to 1 it will re-use an existing clone (default: 0)
  • CEPH_SKIP_CREATE_CLONE - set to 1 it will not create a clone at startup (default: 0)

Note: With registry.gitlab.com/ix.ai/qemu:v0.2.0 a new variable called QEMU_NO_QMP was introduced. This variable is ignored by this image.

Example

Warning: Modify the command below to suit your needs!

Assumptions:

  • you have created a ceph pool (example: ceph osd pool create rbd 64)
  • you have initialised the ceph pool (example: rbd pool init rbd)
  • you have created the user qemu with access to the pool (example: ceph auth caps client.qemu mon "profile rbd" osd "profile rbd pool=rbd")
  • you have already created an image with the name alpine (and installed something bootable)
  • you have already made a snapshot with the name alpine@3.12

Bonus: Mount a folder (example: /folder), from the host, through docker, in the VM, as FAT. You can put, for example, scripts there.

CEPH_CLONE="rbd/alpine-test-044" docker run --rm --it \
    -v /etc/ceph/ceph.client.qemu.keyring:/etc/ceph/ceph.client.qemu.keyring:ro \
    -v /etc/ceph/ceph.conf:/etc/ceph/ceph.conf:ro \
    -v /folder:/folder:rw \
    -e CEPH_CLIENT_ID="qemu" \
    -e CEPH_SNAP="rbd/alpine@3.12" \
    -e CEPH_CLONE="${CEPH_CLONE}" \
    --device /dev/kvm \
    --device /dev/urandom \
    registry.gitlab.com/ix.ai/qemu-ceph:latest \
      -enable-kvm \
      -smp 2 \
      -m 4096 \
      -device virtio-scsi-pci \
      -drive format=rbd,file=rbd:${CEPH_CLONE}:id=qemu,id=drive1,cache=writeback,if=none \
      -device driver=scsi-hd,drive=drive1,discard_granularity=512 \
      -drive file=fat:rw:/folder,id=drive2,if=none \
      -device driver=scsi-hd,drive=drive2 \
      -netdev user,hostfwd=tcp::22-:22,id=net \
      -device virtio-net-pci,netdev=net \
      -vnc :0 \
      -no-user-config \
      -cpu max \
      -object rng-random,filename=/dev/urandom,id=rng0 \
      -usb \
      -device usb-tablet,id=input0 \
      -nodefaults \
      -vga virtio \
      -machine type=q35,accel=kvm \
      -k de
Starting the image in bash (bypass the entrypoint)
docker run --rm --it \
    -v /etc/ceph/ceph.client.qemu.keyring:/etc/ceph/ceph.client.qemu.keyring:ro \
    -v /etc/ceph/ceph.conf:/etc/ceph/ceph.conf:ro \
    -v /folder:/folder:rw \
    --device /dev/kvm \
    --device /dev/urandom \
    --entrypoint "" \
    registry.gitlab.com/ix.ai/qemu-ceph:latest \
      bash

Image Tags

The following tag formats are used by this docker image:

Immutable tags:
  • v0.0.5-5.1.0-octopus - the git tag, the QEMU version, the CEPH version
  • v0.0.5 - the git tag
  • Tags starting with master or dev, are development tags
Updated tags:
  • 5.1.0-octopus - the QEMU version, the CEPH version
  • 5.1.0 - the QEMU version
  • 5.1 - shorter QEMU version
  • 5 - shortest QEMU version
  • latest

Resources

Docker Pull Command

docker pull ixdotai/qemu-ceph