nixos/vms: Make drives a list (for ordering)
This commit is contained in:
parent
6971048268
commit
128accbade
@ -13,33 +13,31 @@
|
||||
if config.my.build.isDevVM then "00:02.0" else "27:00.0";
|
||||
|
||||
vmLVM = vm: lv: {
|
||||
"${lv}" = {
|
||||
backend = {
|
||||
driver = "host_device";
|
||||
filename = "/dev/ssds/vm-${vm}-${lv}";
|
||||
# It appears this needs to be set on the backend _and_ the format
|
||||
discard = "unmap";
|
||||
};
|
||||
format = {
|
||||
driver = "raw";
|
||||
discard = "unmap";
|
||||
};
|
||||
frontend = "virtio-blk";
|
||||
name = lv;
|
||||
backend = {
|
||||
driver = "host_device";
|
||||
filename = "/dev/ssds/vm-${vm}-${lv}";
|
||||
# It appears this needs to be set on the backend _and_ the format
|
||||
discard = "unmap";
|
||||
};
|
||||
format = {
|
||||
driver = "raw";
|
||||
discard = "unmap";
|
||||
};
|
||||
frontend = "virtio-blk";
|
||||
};
|
||||
|
||||
installerDisk = {
|
||||
installer = {
|
||||
backend = {
|
||||
driver = "file";
|
||||
filename = "${systems.installer.configuration.config.my.buildAs.iso}/iso/nixos-installer-devplayer0.iso";
|
||||
read-only = "on";
|
||||
};
|
||||
format.driver = "raw";
|
||||
frontend = "ide-cd";
|
||||
frontendOpts = {
|
||||
bootindex = 1;
|
||||
};
|
||||
name = "installer";
|
||||
backend = {
|
||||
driver = "file";
|
||||
filename = "${systems.installer.configuration.config.my.buildAs.iso}/iso/nixos-installer-devplayer0.iso";
|
||||
read-only = "on";
|
||||
};
|
||||
format.driver = "raw";
|
||||
frontend = "ide-cd";
|
||||
frontendOpts = {
|
||||
bootindex = 1;
|
||||
};
|
||||
};
|
||||
in
|
||||
@ -58,12 +56,11 @@
|
||||
waitOnline = "no-carrier";
|
||||
mac = "52:54:00:15:1a:53";
|
||||
};
|
||||
drives = mkMerge ([ ] ++ (optionals (!config.my.build.isDevVM) [
|
||||
drives = [ ] ++ (optionals (!config.my.build.isDevVM) [
|
||||
(vmLVM "estuary" "esp")
|
||||
(vmLVM "estuary" "nix")
|
||||
(vmLVM "estuary" "persist")
|
||||
{ esp.frontendOpts.bootindex = 0; }
|
||||
]));
|
||||
]);
|
||||
hostDevices."${wanBDF}" = { };
|
||||
};
|
||||
|
||||
@ -76,29 +73,24 @@
|
||||
memory = 65536;
|
||||
networks.vms.mac = "52:54:00:27:3d:5c";
|
||||
cleanShutdown.timeout = 120;
|
||||
drives = mkMerge ([
|
||||
installerDisk
|
||||
] ++ (optionals (!config.my.build.isDevVM) [
|
||||
drives = [ ] ++ (optionals (!config.my.build.isDevVM) [
|
||||
(vmLVM "shill" "esp")
|
||||
(vmLVM "shill" "nix")
|
||||
(vmLVM "shill" "persist")
|
||||
{
|
||||
esp.frontendOpts.bootindex = 0;
|
||||
|
||||
media = {
|
||||
backend = {
|
||||
driver = "host_device";
|
||||
filename = "/dev/hdds/media";
|
||||
discard = "unmap";
|
||||
};
|
||||
format = {
|
||||
driver = "raw";
|
||||
discard = "unmap";
|
||||
};
|
||||
frontend = "virtio-blk";
|
||||
name = "media";
|
||||
backend = {
|
||||
driver = "host_device";
|
||||
filename = "/dev/hdds/media";
|
||||
discard = "unmap";
|
||||
};
|
||||
format = {
|
||||
driver = "raw";
|
||||
discard = "unmap";
|
||||
};
|
||||
frontend = "virtio-blk";
|
||||
}
|
||||
]));
|
||||
]);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -82,6 +82,7 @@ let
|
||||
|
||||
driveOpts = with lib.types; {
|
||||
options = {
|
||||
name = mkOpt' str null "Drive name.";
|
||||
backend = mkOpt' qemuOpts { } "Backend blockdev options.";
|
||||
|
||||
format = mkOpt' qemuOpts { } "Format blockdev options.";
|
||||
@ -128,7 +129,7 @@ let
|
||||
});
|
||||
default = { };
|
||||
};
|
||||
drives = mkOpt' (attrsOf (submodule driveOpts)) { } "Drives to attach to VM.";
|
||||
drives = mkOpt' (listOf (submodule driveOpts)) { } "Drives to attach to VM.";
|
||||
hostDevices = mkOpt' (attrsOf (submodule hostDevOpts)) { } "Host PCI devices to pass to the VM.";
|
||||
};
|
||||
};
|
||||
@ -170,10 +171,10 @@ let
|
||||
"netdev tap,id=${nn},ifname=${c.ifname},script=no"
|
||||
("device ${c.model},netdev=${nn},mac=${c.mac}" + (extraQEMUOpts c.extraOptions))
|
||||
]) i.networks)) ++
|
||||
(flatten (mapAttrsToList (dn: c: [
|
||||
"blockdev node-name=${dn}-backend,${c.backend}"
|
||||
"blockdev node-name=${dn}-format,${c.formatBackendProp}=${dn}-backend,${c.format}"
|
||||
("device ${c.frontend},id=${dn},drive=${dn}-format" + (extraQEMUOpts c.frontendOpts))
|
||||
(flatten (map (d: [
|
||||
"blockdev node-name=${d.name}-backend,${d.backend}"
|
||||
"blockdev node-name=${d.name}-format,${d.formatBackendProp}=${d.name}-backend,${d.format}"
|
||||
("device ${d.frontend},id=${d.name},drive=${d.name}-format" + (extraQEMUOpts d.frontendOpts))
|
||||
]) i.drives)) ++
|
||||
(map (bdf: "device vfio-pci,host=${bdf}") (attrNames i.hostDevices));
|
||||
args = map (v: "-${v}") flags;
|
||||
|
Loading…
Reference in New Issue
Block a user