Failure with Windows template
Closed this issue · 10 comments
Hi! I'm trying out this flake to install a tiny11 VM, hopefully with GPU passthrough in the future but starting small. I wrote this file based on the README:
{ NixVirt, ... }:
{
programs.virt-manager.enable = true;
users.users.mat = {
extraGroups = [ "libvirtd" ];
};
virtualisation.libvirt = {
enable = true;
swtpm.enable = true; # needed for Windows 11
connections."qemu:///session".domains = [
{
definition = NixVirt.lib.domain.writeXML (NixVirt.lib.domain.templates.windows
{
name = "Binbows";
uuid = "2c3b3c93-e899-4337-88fc-eefb04f059ef"; # NOTE: randomly generated
memory = { count = 8; unit = "GiB"; };
storage_vol = /var/lib/vm/binbows.qcow2; # NOTE: hope it will create this... size?
nvram_path = /var/lib/vm/binbows.nvram;
virtio_net = true;
virtio_drive = true;
install_virtio = true;
});
}
];
};
}
And I get the following error on rebuild:
restarting sysinit-reactivation.target
the following new units were started: libvirtd.service
warning: the following units failed: nixvirt.service
× nixvirt.service - Configure libvirt objects
Loaded: loaded (/etc/systemd/system/nixvirt.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Thu 2024-08-22 17:32:06 CEST; 47ms ago
Invocation: db11feac067a48dca92ead10c58445a6
Process: 33965 ExecStart=/nix/store/01yv3ihwifma9cqjny0gals0c7nckhvx-unit-script-nixvirt-start/bin/nixvirt-start (code=exited, status=1/FAILURE)
Main PID: 33965 (code=exited, status=1/FAILURE)
IP: 0B in, 0B out
Mem peak: 39.4M
CPU: 201ms
Aug 22 17:32:06 nixos-mat systemd[1]: Starting Configure libvirt objects...
Aug 22 17:32:06 nixos-mat nixvirt-start[33971]: NixVirt: libvirt error: unsupported configuration: TPM version '2.0' is not supported
Aug 22 17:32:06 nixos-mat systemd[1]: nixvirt.service: Main process exited, code=exited, status=1/FAILURE
Aug 22 17:32:06 nixos-mat systemd[1]: nixvirt.service: Failed with result 'exit-code'.
Aug 22 17:32:06 nixos-mat systemd[1]: Failed to start Configure libvirt objects.
> Adding configuration to bootloader
I've tried rebooting to perhaps apply any kernel arguments NixVirt may have added, but no luck. What am I doing wrong?
Is this NixOS or Home Manager?
NixOS
I've reproduced this on my machine. I'll dig in to see what's going wrong. I've seen this message before in any case.
OK, this should be fixed in master. You may or may not need to do sudo systemctl restart libvirtd.service
if NixOS doesn't restart the service.
Thanks for looking into this! Unfortunately I am still getting the same issue:
restarting the following units: polkit.service
the following new units were started: libvirtd.service
warning: the following units failed: nixvirt.service
× nixvirt.service - Configure libvirt objects
Loaded: loaded (/etc/systemd/system/nixvirt.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Fri 2024-08-23 22:11:36 CEST; 150ms ago
Invocation: 2f3632f67e1b4761912af00b9d81d4bd
Process: 571033 ExecStart=/nix/store/88m46yfrssx4zrfa1lmzbihj4284nkm3-unit-script-nixvirt-start/bin/nixvirt-start (code=exited, status=1/FAILURE)
Main PID: 571033 (code=exited, status=1/FAILURE)
IP: 0B in, 0B out
Mem peak: 51.5M
CPU: 675ms
Aug 23 22:11:35 nixos-mat systemd[1]: Starting Configure libvirt objects...
Aug 23 22:11:36 nixos-mat nixvirt-start[571036]: NixVirt: libvirt error: unsupported configuration: TPM version '2.0' is not supported
Aug 23 22:11:36 nixos-mat systemd[1]: nixvirt.service: Main process exited, code=exited, status=1/FAILURE
Aug 23 22:11:36 nixos-mat systemd[1]: nixvirt.service: Failed with result 'exit-code'.
Aug 23 22:11:36 nixos-mat systemd[1]: Failed to start Configure libvirt objects.
> Adding configuration to bootloader
mat@nixos-mat ~/.nix (main)> sudo systemctl restart libvirtd.service
mat@nixos-mat ~/.nix (main)> sudo systemctl restart nixvirt.service
Job for nixvirt.service failed because the control process exited with error code.
See "systemctl status nixvirt.service" and "journalctl -xeu nixvirt.service" for details.
mat@nixos-mat ~/.nix (main) [1]> sudo systemctl status nixvirt.service
× nixvirt.service - Configure libvirt objects
Loaded: loaded (/etc/systemd/system/nixvirt.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Fri 2024-08-23 23:01:22 CEST; 5s ago
Invocation: ec025add34df4273927764dbe4a7538f
Process: 592619 ExecStart=/nix/store/88m46yfrssx4zrfa1lmzbihj4284nkm3-unit-script-nixvirt-start/bin/nixvirt-start (code=exited, status=>
Main PID: 592619 (code=exited, status=1/FAILURE)
IP: 0B in, 0B out
Mem peak: 50.3M
CPU: 250ms
Aug 23 23:01:22 nixos-mat systemd[1]: Starting Configure libvirt objects...
Aug 23 23:01:22 nixos-mat nixvirt-start[592621]: NixVirt: libvirt error: unsupported configuration: TPM version '2.0' is not supported
Aug 23 23:01:22 nixos-mat systemd[1]: nixvirt.service: Main process exited, code=exited, status=1/FAILURE
Aug 23 23:01:22 nixos-mat systemd[1]: nixvirt.service: Failed with result 'exit-code'.
Aug 23 23:01:22 nixos-mat systemd[1]: Failed to start Configure libvirt objects.
Could you try this?
- remove Binbows domain definition
- rebuild NixOS
- restart machine
- add Binbows domain definition
- rebuild NixOS
Same thing still, unfortunately.
I found that adding libvirt.qemu.swtpm.enable = true
myself (based on your changes in d45c4a1) gets it to work. My current config is as follows:
virtualisation = {
libvirtd = {
enable = true;
qemu = {
swtpm.enable = true;
# ovmf = {
# enable = true;
# packages = [pkgs.OVMFFull.fd ];
# };
};
};
# spiceUSBRedirection.enable = true;
libvirt = {
enable = true;
swtpm.enable = true;
connections."qemu:///session".domains = [
{
definition = NixVirt.lib.domain.writeXML (NixVirt.lib.domain.templates.windows
{
name = "Binbows";
uuid = "2c3b3c93-e899-4337-88fc-eefb04f059ef";
memory = { count = 8; unit = "GiB"; };
storage_vol = /var/lib/vm/binbows.qcow2;
nvram_path = /var/lib/vm/binbows.nvram;
virtio_net = true;
virtio_drive = true;
install_virtio = true;
});
}
];
};
};
In that case, are you sure you're using the latest master of NixVirt? You may need to update your lock file.
Ah. my bad! I used flakehub to add NixVirt so I didn't get the latest commit despite updating the lockfile. 😅
I can confirm it works by switching the flake url to track master.