
The Go code represents it as a boolean for example.
I think our only option is to define a new API
virDomainSetAutostartPolicy()
and make it take an int parameter for which we can define an enum.
The existing API will just have to map new values onto true/false as appropriate. That’s the same conclusion I came to. As with the version numbers, I’ll continue implementing functions within the existing API before I attempt to add anything new to it.
I think it helps to consider the use case where someone might pick to set "Restart if previously active".
Consider if you have 2 hosts, and the same VM config is present on both hosts. You only want the VM running on one host at any point in time. In this case you do *not* want to use "always start" as if both hosts reboot, you'd get two copies of the VM.
"Restart if previously active" solves this scenario by only starting it on the host it was originally running on.
With this in mind, making libvirt treat "restart if previously active" the same as "always start" is a dangerous configuration. The safe option is to consider "restart if previously active" the same as "none".
So I think values 2 and 3 should map to autostart disabled and value 4 to autostart enabled. I hadn’t considered things like high availability setups. I’ll update my code to only treat 4 as enabled.
Thanks! Matt