From 6b2373aee1eb920acc6413c26fb506556cb90b4b Mon Sep 17 00:00:00 2001 From: illustris Date: Sat, 27 Apr 2024 18:34:18 +0530 Subject: [PATCH 1/4] nixos/proxmox-image: remove raw image from hydra-build-products --- nixos/modules/virtualisation/proxmox-image.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/proxmox-image.nix b/nixos/modules/virtualisation/proxmox-image.nix index 6349bcef99e6..8c08cdc5d7bf 100644 --- a/nixos/modules/virtualisation/proxmox-image.nix +++ b/nixos/modules/virtualisation/proxmox-image.nix @@ -262,7 +262,7 @@ with lib; mv "vzdump-qemu-${cfg.filenameSuffix}.vma.zst" $out/ mkdir -p $out/nix-support - echo "file vma $out/vzdump-qemu-${cfg.filenameSuffix}.vma.zst" >> $out/nix-support/hydra-build-products + echo "file vma $out/vzdump-qemu-${cfg.filenameSuffix}.vma.zst" > $out/nix-support/hydra-build-products ''; inherit (cfg.qemuConf) additionalSpace diskSize bootSize; format = "raw"; From b90b63db929dc454aee85ef5d7ec5b484a576ef8 Mon Sep 17 00:00:00 2001 From: illustris Date: Sat, 27 Apr 2024 22:43:09 +0530 Subject: [PATCH 2/4] nixos/proxmox-image: qemu: 7.2.1 -> 8.1.5 --- .../modules/virtualisation/proxmox-image.nix | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/nixos/modules/virtualisation/proxmox-image.nix b/nixos/modules/virtualisation/proxmox-image.nix index 8c08cdc5d7bf..f43b3df7af30 100644 --- a/nixos/modules/virtualisation/proxmox-image.nix +++ b/nixos/modules/virtualisation/proxmox-image.nix @@ -216,37 +216,21 @@ with lib; seccompSupport = false; guestAgentSupport = false; }).overrideAttrs ( super: rec { - - version = "7.2.1"; + # Check https://github.com/proxmox/pve-qemu/tree/master for the version + # of qemu and patch to use + version = "8.1.5"; src = pkgs.fetchurl { - url= "https://download.qemu.org/qemu-${version}.tar.xz"; - sha256 = "sha256-jIVpms+dekOl/immTN1WNwsMLRrQdLr3CYqCTReq1zs="; + url = "https://download.qemu.org/qemu-${version}.tar.xz"; + hash = "sha256-l2Ox7+xP1JeWtQgNCINRLXDLY4nq1lxmHMNoalIjKJY="; }; patches = [ # Proxmox' VMA tool is published as a particular patch upon QEMU - (pkgs.fetchpatch { - url = - let - rev = "abb04bb6272c1202ca9face0827917552b9d06f6"; - path = "debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch"; - in "https://git.proxmox.com/?p=pve-qemu.git;a=blob_plain;hb=${rev};f=${path}"; - hash = "sha256-3d0HHdvaExCry6zcULnziYnWIAnn24vECkI4sjj2BMg="; - }) - - # Proxmox' VMA tool uses O_DIRECT which fails on tmpfs - # Filed to upstream issue tracker: https://bugzilla.proxmox.com/show_bug.cgi?id=4710 - (pkgs.writeText "inline.patch" '' - --- a/vma-writer.c 2023-05-01 15:11:13.361341177 +0200 - +++ b/vma-writer.c 2023-05-01 15:10:51.785293129 +0200 - @@ -306,7 +306,7 @@ - /* try to use O_NONBLOCK */ - fcntl(vmaw->fd, F_SETFL, fcntl(vmaw->fd, F_GETFL)|O_NONBLOCK); - } else { - - oflags = O_NONBLOCK|O_DIRECT|O_WRONLY|O_EXCL; - + oflags = O_NONBLOCK|O_WRONLY|O_EXCL; - vmaw->fd = qemu_create(filename, oflags, 0644, errp); - } - '') + "${pkgs.fetchFromGitHub { + owner = "proxmox"; + repo = "pve-qemu"; + rev = "71dd2d48f9122e60e4c0a8480122a27aab15dc70"; + hash = "sha256-Q8AxNv4geDdlbVIWphRO5P3ESo0SGgvUpVPmPJzubJM="; + }}/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch" ]; buildInputs = super.buildInputs ++ [ pkgs.libuuid ]; From fe35866a2e23e737ce9ae253bbb5c148ccf10778 Mon Sep 17 00:00:00 2001 From: illustris Date: Sat, 27 Apr 2024 23:34:50 +0530 Subject: [PATCH 3/4] nixos/proxmox-image: add cloud init disk and use cloud-init by default --- .../modules/virtualisation/proxmox-image.nix | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/proxmox-image.nix b/nixos/modules/virtualisation/proxmox-image.nix index f43b3df7af30..00c39f255447 100644 --- a/nixos/modules/virtualisation/proxmox-image.nix +++ b/nixos/modules/virtualisation/proxmox-image.nix @@ -158,6 +158,31 @@ with lib; any specific VMID. ''; }; + cloudInit = { + enable = mkOption { + type = types.bool; + default = true; + description = '' + Whether the VM should accept cloud init configurations from PVE. + ''; + }; + defaultStorage = mkOption { + default = "local-lvm"; + example = "tank"; + type = types.str; + description = '' + Default storage name for cloud init drive. + ''; + }; + device = mkOption { + default = "ide2"; + example = "scsi0"; + type = types.str; + description = '' + Bus/device to which the cloud init drive is attached. + ''; + }; + }; }; config = let @@ -282,6 +307,20 @@ with lib; fsType = "vfat"; }; - services.qemuGuest.enable = lib.mkDefault true; + networking = mkIf cfg.cloudInit.enable { + hostName = mkForce ""; + useDHCP = false; + }; + + services = { + cloud-init = mkIf cfg.cloudInit.enable { + enable = true; + network.enable = true; + }; + sshd.enable = mkDefault true; + qemuGuest.enable = true; + }; + + proxmox.qemuExtraConf.${cfg.cloudInit.device} = "${cfg.cloudInit.defaultStorage}:vm-9999-cloudinit,media=cdrom"; }; } From 523f157dba0a1eec1a42090fcd5bc58b71593fbd Mon Sep 17 00:00:00 2001 From: illustris Date: Mon, 29 Apr 2024 11:01:45 +0530 Subject: [PATCH 4/4] nixos/proxmox-image: change scsi controller model to upstream default --- nixos/modules/virtualisation/proxmox-image.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/proxmox-image.nix b/nixos/modules/virtualisation/proxmox-image.nix index 00c39f255447..01ad86c08cd7 100644 --- a/nixos/modules/virtualisation/proxmox-image.nix +++ b/nixos/modules/virtualisation/proxmox-image.nix @@ -16,7 +16,7 @@ with lib; }; scsihw = mkOption { type = types.str; - default = "virtio-scsi-pci"; + default = "virtio-scsi-single"; example = "lsi"; description = '' SCSI controller type. Must be one of the supported values given in