Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use quay.io qm - kvm #661

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rpm/qm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ install -d %{buildroot}%{_sysconfdir}/containers/containers.conf.d
%if %{enable_qm_mount_bind_kvm}
mkdir -p %{buildroot}%{_sysconfdir}/containers/systemd/qm.container.d
# Add config for qm only - add drop-in file in /etc/containers/systemd/qm.container.d/qm_dropin_mount_bind_kvm.conf
# to nested containers in QM env mount bind it in /dev/kvm
# to QM env mount bind it in /dev/kvm
install -m 644 %{_builddir}/qm-%{version}/etc/containers/systemd/qm.container.d/qm_dropin_mount_bind_kvm.conf %{buildroot}%{_sysconfdir}/containers/systemd/qm.container.d/qm_dropin_mount_bind_kvm.conf
%endif
########################################################
Expand Down
18 changes: 18 additions & 0 deletions subsystems/kvm/ContainerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ContainerFile used to create the image available at quay.io/qm-images/kvm:latest
#
# How to build
# ==================
# podman login quay.io
# use build_kvm_container.sh to build container
# podman push quay.io/qm-images/kvm:latest
FROM fedora-minimal:latest

ENV PASSWORD_FEDORA_USER=fedora

RUN dnf install qemu-system-$(arch) -y \
&& dnf clean all && rm -rf /var/cache/dnf

COPY ./Fedora-Cloud-Base-Generic.qcow2 /var/lib/libvirt/images/

# Set container stay alive
ENTRYPOINT ["/usr/bin/qemu-system-x86_64","-smp","12","-enable-kvm","-m","2G","-machine","q35","-cpu","host","-device","virtio-net-pci,netdev=n0,mac=FE:30:26:a6:91:2d","-netdev","user,id=n0,net=10.0.2.0/24,hostfwd=tcp::2226-:22","-drive","file=/var/lib/libvirt/images/Fedora-Cloud-Base-Generic.qcow2,index=0,media=disk,format=qcow2,if=virtio,snapshot=off","-nographic"]
21 changes: 21 additions & 0 deletions subsystems/kvm/build_kvm_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/bash

# Install required repos
dnf install guestfs-tools \
curl \
perl -y

# Download fedora cloud image
curl -Lo ./Fedora-Cloud-Base-Generic.qcow2 https://download.fedoraproject.org/pub/fedora/linux/releases/41/Cloud/"$(arch)"/images/Fedora-Cloud-Base-Generic-41-1.4."$(arch)".qcow2

# Customize user:pass
export LIBGUESTFS_BACKEND=direct && \
virt-customize -a ./Fedora-Cloud-Base-Generic.qcow2 \
--edit '/etc/ssh/sshd_config: s/#PasswordAuthentication.*/PasswordAuthentication yes/' \
--uninstall cloud-init \
--firstboot-command "useradd -m -s /bin/bash -G wheel fedora" \
--firstboot-command "echo 'fedora:fedora' | chpasswd"

# Container build
podman build -t quay.io/qm-images/kvm:latest -f ContainerFile

9 changes: 9 additions & 0 deletions subsystems/kvm/kvm.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=kvm Container
After=network.target

[Container]
Image=quay.io/qm-images/kvm:latest

[Install]
WantedBy=multi-user.target
Loading