xen-org/xen-api — pull request #504 by jjd27 (2012-03-14 15:12:51+00:00)
Title: CA-67109: Conflate checks for bad power-states

Previously, there were two checks for bad power-states:

1. Look in the "allowed_power_states" table.
2. Checking some constraints over when Suspended is validly allowed for clones and copies.

In the case of cloning or copying a running VM, the first check would fail, giving an error message stating that the power-state should be either Halted or Suspended, as the allowed_power_states table statically listed these two options. However, the second check would add additional constraints, often meaning that Suspended was not a valid power-state.

There are two obvious solutions:

(a) Changing the order of the checks, so that the most specific check is done first.
(b) Factoring the constraints expressed in 2 into 1.

This patch adopts approach (b), since it's nicer to have all of the power-state-checking logic in one place.

Signed-off-by: Jonathan Davies