Skip to content

Instantly share code, notes, and snippets.

@mentha
mentha / Containerfile
Last active May 2, 2024 14:30
launch android x86 iso in qemu
FROM fedora
RUN --mount=type=cache,dst=/var/cache/dnf/ \
sed -e '$ainstall_weak_deps=False' -e '$akeepcache=True' -i /etc/dnf/dnf.conf && \
dnf install -y \
android-tools \
e2fsprogs \
novnc \
p7zip-plugins \
python3 \
@mentha
mentha / PKGBUILD
Last active December 19, 2023 12:50
btrfs dedupe and backup scripts
pkgname=btrfsmaint
pkgver=0.20231218.0
pkgrel=1
pkgdesc='extra btrfs maintenance and backup tools'
arch=(any)
license=(Unlicense)
depends=(
borg
btrfs-progs
@mentha
mentha / 0001-nss-return-success-when-host-is-found-but-no-data-av.patch
Created July 10, 2023 07:11
patch for libvirt-nss 9.3.0, fixing issues where guest names resolving to hosts on other networks when the application prefers ipv6
From 18c1445c291ecab84700f6806ff90b4151586e96 Mon Sep 17 00:00:00 2001
From: Jiang XueQian <jiangxueqian@gmail.com>
Date: Mon, 10 Jul 2023 15:06:59 +0800
Subject: [PATCH] nss: return success when host is found but no data available
---
tools/nss/libvirt_nss.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
@mentha
mentha / cacheproxy.py
Last active August 4, 2023 13:20
caching http proxy
#!/usr/bin/env python3
from argparse import Action, ArgumentParser
from contextlib import suppress
from fcntl import flock, LOCK_SH
from glob import glob
from signal import signal, SIGHUP, SIGINT, SIGTERM
from tempfile import TemporaryDirectory
import json
import os
@mentha
mentha / dnf-autoupdate-boot.service.in
Created June 22, 2023 12:26
auto system update with dnf
[Unit]
Before=getty-pre.target
Before=multi-user.target graphical.target
[Service]
Type=oneshot
ExecStart=@libexec@/dnf-autoupdate-boot.sh
StandardInput=tty
StandardOutput=tty
StandardError=tty
@mentha
mentha / PKGBUILD
Last active September 16, 2023 11:19
reboot by kexec
pkgname=kexec-reboot
pkgver=0.20230916.0
pkgrel=1
pkgdesc='reboot by kexec'
arch=(any)
license=(Unlicense)
depends=(
systemd
python
@mentha
mentha / PKGBUILD
Last active September 16, 2023 11:19
suspend kvm guests before host sleep
pkgname=virtsleep
pkgver=0.20230916.0
pkgrel=1
pkgdesc='suspend libvirt guests before host sleeps'
arch=(any)
license=(Unlicense)
depends=(
libvirt-python
python
@mentha
mentha / virt-createvfio
Last active April 10, 2023 14:22
run libvirt kvm guests with vfio pci passthrough
#!/usr/bin/env python3
from argparse import ArgumentParser
from contextlib import suppress
from dataclasses import dataclass
from fnmatch import fnmatch
from functools import cached_property
from select import select
from signal import SIGHUP, SIGINT, SIGTERM, SIG_IGN, signal
from traceback import format_exc
@mentha
mentha / PKGBUILD
Last active September 16, 2023 11:19
trim virtual machine disk images
pkgname=virttrim
pkgver=0.20230916.0
pkgrel=1
pkgdesc='trim libvirt disk images automatically'
arch=(any)
license=(Unlicense)
depends=(
guestfs-tools
libvirt-python
@mentha
mentha / dir2iso.py
Last active February 26, 2023 09:08
create iso image
#!/usr/bin/env python3
from argparse import ArgumentParser
import os
import subprocess as sp
a = ArgumentParser(description='Generate ISO image')
a.add_argument('dir', help='image root')
a.add_argument('--output', '-o', default='-', help='xorriso output, stdout by default')
a.add_argument('--volid', '-v', help='iso volume id, directory name by default')