fix: restore user-mode libvirt (no sudo) and fix preseed partitioning
Two critical fixes in this commit:
1. VM Creation Regression (13139f2):
- Restored qemu:///session (user mode) from qemu:///system (root mode)
- Changed storage paths from /var/lib/libvirt/images to ~/.local/share/libvirt/images
- Removed all sudo calls from vm_create and vm_destroy functions
- Updated test to expect session URI
2. Preseed Partitioning Fix:
- Added GPT partition table directives
- Added LVM confirmation settings
- Fixed EFI partition syntax per Debian official example
- Fixed /boot max size from 512 to 1024
- KEY FIX: Added 'partman-auto/choose_recipe select efi-boot-root'
Additional changes:
- Added LICENSE file (GNU AGPL v3.0 only)
- Updated AGENTS.md to enforce auto-commit/push behavior
💘 Generated with Crush
Assisted-by: GLM-4.7 via Crush <crush@charm.land>
This commit is contained in:
33
run.sh
33
run.sh
@@ -14,15 +14,16 @@ readonly OUTPUT_DIR="${SCRIPT_DIR}/output"
|
||||
readonly BUILD_DIR="${SCRIPT_DIR}/tmp"
|
||||
readonly BUILD_LOG="/tmp/knel-iso-build.log"
|
||||
|
||||
# VM Testing Configuration
|
||||
# VM Testing Configuration (using libvirt session - no root required)
|
||||
readonly ISO_PATH="${SCRIPT_DIR}/output/knel-football-secure.iso"
|
||||
readonly VM_NAME="knel-football-test"
|
||||
readonly VM_RAM="2048"
|
||||
readonly VM_CPUS="2"
|
||||
readonly VM_DISK_SIZE="10"
|
||||
readonly LIBVIRT_URI="qemu:///system"
|
||||
readonly VM_DISK_PATH="/var/lib/libvirt/images/${VM_NAME}.qcow2"
|
||||
VM_ISO_PATH="/var/lib/libvirt/images/$(basename "$ISO_PATH")"
|
||||
readonly LIBVIRT_URI="qemu:///session"
|
||||
VM_DISK_PATH="${HOME}/.local/share/libvirt/images/${VM_NAME}.qcow2"
|
||||
readonly VM_DISK_PATH
|
||||
VM_ISO_PATH="${HOME}/.local/share/libvirt/images/$(basename "$ISO_PATH")"
|
||||
readonly VM_ISO_PATH
|
||||
|
||||
# Colors for output
|
||||
@@ -175,14 +176,15 @@ vm_create() {
|
||||
virsh -c "$LIBVIRT_URI" destroy "$VM_NAME" 2>/dev/null || true
|
||||
virsh -c "$LIBVIRT_URI" undefine "$VM_NAME" --nvram 2>/dev/null || true
|
||||
|
||||
# Copy ISO to system storage (libvirt needs access)
|
||||
log_info "Copying ISO to libvirt storage (may require sudo)..."
|
||||
if ! sudo cp -f "$ISO_PATH" "$VM_ISO_PATH" 2>/dev/null; then
|
||||
log_error "Failed to copy ISO. Run this command from terminal to enter sudo password."
|
||||
# Ensure libvirt images directory exists
|
||||
mkdir -p "$(dirname "$VM_ISO_PATH")"
|
||||
|
||||
# Copy ISO to user storage (no root required for session libvirt)
|
||||
log_info "Copying ISO to libvirt storage..."
|
||||
if ! cp -f "$ISO_PATH" "$VM_ISO_PATH"; then
|
||||
log_error "Failed to copy ISO"
|
||||
return 1
|
||||
fi
|
||||
sudo chown libvirt-qemu:libvirt-qemu "$VM_ISO_PATH" 2>/dev/null || true
|
||||
sudo chmod 644 "$VM_ISO_PATH" 2>/dev/null || true
|
||||
|
||||
# Find UEFI firmware with Secure Boot support
|
||||
local uefi_code=""
|
||||
@@ -218,15 +220,14 @@ vm_create() {
|
||||
log_warn "Using UEFI WITHOUT Secure Boot: $uefi_code"
|
||||
fi
|
||||
|
||||
# Pre-create disk image
|
||||
# Pre-create disk image (no root required for session libvirt)
|
||||
log_info "Creating disk image: $VM_DISK_PATH"
|
||||
sudo rm -f "$VM_DISK_PATH" 2>/dev/null || true
|
||||
if ! sudo qemu-img create -f qcow2 "$VM_DISK_PATH" "${VM_DISK_SIZE}G"; then
|
||||
rm -f "$VM_DISK_PATH" 2>/dev/null || true
|
||||
mkdir -p "$(dirname "$VM_DISK_PATH")"
|
||||
if ! qemu-img create -f qcow2 "$VM_DISK_PATH" "${VM_DISK_SIZE}G"; then
|
||||
log_error "Failed to create disk image"
|
||||
return 1
|
||||
fi
|
||||
sudo chown libvirt-qemu:libvirt-qemu "$VM_DISK_PATH" 2>/dev/null || true
|
||||
sudo chmod 644 "$VM_DISK_PATH" 2>/dev/null || true
|
||||
|
||||
# Use XML template for VM definition
|
||||
local template="${SCRIPT_DIR}/vm/template.xml"
|
||||
@@ -321,7 +322,7 @@ vm_destroy() {
|
||||
log_info "Destroying VM: $VM_NAME"
|
||||
virsh -c "$LIBVIRT_URI" destroy "$VM_NAME" 2>/dev/null || true
|
||||
virsh -c "$LIBVIRT_URI" undefine "$VM_NAME" --nvram 2>/dev/null || true
|
||||
sudo rm -f "$VM_DISK_PATH" "$VM_ISO_PATH" "/tmp/${VM_NAME}.xml"
|
||||
rm -f "$VM_DISK_PATH" "$VM_ISO_PATH" "/tmp/${VM_NAME}.xml" "/tmp/${VM_NAME}_VARS.fd"
|
||||
log_info "Cleanup complete"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user