AshleyYakeley / NixVirt

LibVirt domain management for Nix
MIT License
186 stars 19 forks source link

VM reboots with each rebuild #57

Closed afilini closed 1 month ago

afilini commented 1 month ago

Looks similar to #9 but I verified the mac address is not changing. Not sure why this is happening, but at every rebuild (even if the domains config is untouched) all my vms are restarted.

Is that supposed to happen or is it some kind of bug or issue related to my configuration?

AshleyYakeley commented 1 month ago

Could you try with virtualisation.libvirt.verbose = true? It should show the XML diff that makes it think the XML has changed.

afilini commented 1 month ago

Thanks for the quick reply! This is the only difference I see in all my domains (they all use the same configuration):

domain e2c678ac-5ac6-424a-a9a2-b64fd6597264: redefine
domain e2c678ac-5ac6-424a-a9a2-b64fd6597264: changed:
[move, /domain/devices/controller[11], /domain/devices[1], 6]
domain e2c678ac-5ac6-424a-a9a2-b64fd6597264: deactivate

EDIT:

The configuration is split in two parts, I have my list of sets with this format:

rec {
        name = "test-domain";
        uuid = "6ef4c193-7e95-47f5-877f-fa0833aafff9";
        vcpu_count = 2;
        memory = { count = 8; unit = "GiB"; };
        virtio_video = false;
        storage_vol = { pool = "zfs-pool"; volume = "${name}.qcow2"; size = "64G"; };
        active = true;
}

Which is then mapped:

virtualisation.libvirt.domains = map (d: ({
        definition = nixvirt.lib.domain.writeXML (lib.attrsets.recursiveUpdate (nixvirt.lib.domain.templates.linux d)
          {
            devices.interface.source.bridge = "nat-bridge";
            devices.graphics.listen.type = "address";
          } // { vcpu.count = d.vcpu_count; });
        active = d.active;
      }
)) libvirtDomains;
AshleyYakeley commented 1 month ago

OK, this should be fixed now.