CA-139501 VM hard_shutdown & hard_reboot must wait for nothing else.

We were already allowing hard_reboot concurrent with a clean_reboot
already in progress, and the same for hard/clean shutdown, but
clean_(shutdown|reboot) would block hard_(reboot|shutdown).

Now the is_allowed_concurrently function allows hard_shutdown
concurrent with anything except itself, and allows hard_reboot
concurrent with anything but itself or hard_shutdown.

Signed-off-by: Thomas Sanders <thomas.sanders@citrix.com>
Whitespace: fix horrible spaces-then-tab-then-spaces indentation.

Signed-off-by: Thomas Sanders <thomas.sanders@citrix.com>
CA-143836: Add VDI.revert to SMAPI

Signed-off-by: John Else <john.else@citrix.com>
CA-143836: Add VDI.revert API call

Signed-off-by: John Else <john.else@citrix.com>
CA-143836: Pass down correct values of is_a_snapshot/snapshot_of

Signed-off-by: John Else <john.else@citrix.com>
CA-143836: Allow VDI.revert operation for cloneable snapshots

Signed-off-by: John Else <john.else@citrix.com>
CA-143836: During VDI.revert, mark leaf with operation `reverting

This mirrors the way allowed_operations are handled for VM.revert.

Signed-off-by: John Else <john.else@citrix.com>
CA-143836: Add vdi_revert to SR allowed_operations

Signed-off-by: John Else <john.else@citrix.com>
CA-143836: Add VDI.revert test to quicktest

Signed-off-by: John Else <john.else@citrix.com>
CA-143836: Use VDI.revert

Signed-off-by: John Else <john.else@citrix.com>
CA-143836: Allow reverting to "live" VDIs

Since we can only revert to snapshot VDIs, the only time this is needed
is when reverting to a checkpoint.

Signed-off-by: John Else <john.else@citrix.com>
unittest: Variable rename and label for clarity

Signed-off-by: John Else <john.else@citrix.com>
unittest: Get VDI record after tinkering with the VDI

This ensures that the up-to-date record is passed to
Xapi_vdi.check_operation_error.

Signed-off-by: John Else <john.else@citrix.com>
CA-143836: Add allowed_operations tests

Test that we...

* can revert to a snapshot.
* can revert to an attached snapshot.
* cannot revert to a leaf VDI.
* cannot revert to an attached leaf.

Signed-off-by: John Else <john.else@citrix.com>
CA-146595: Improve parsing of VM platform flags

We need to be able to use 0 and 1 in (at least) the case of the acpi key.
Before this patch, using 0 and 1 would have both been converted to true when
passed to Xenopsd and therefore wrong arguments could be passed to Qemu when
trying to disable this feature.

This patch makes the 'bool' function a little more lenient on its input rather
than using OCaml's stock bool_of_string. It also introduces a warning message
if the value has been specified incorrectly.

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
xe host-apply-edition: avoid race in error reporting

When host.apply_edition raises a license_checkout_error exception, we look at
the recent alerts (messages) to find out the reason for the failure. We seem to
currently miss such an alert every now and then, possibly due to rounding
errors in the used timestamp.  Make this less likely by subtracting a second.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
xe host-apply-edition: cleanup alert after processing

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
CA-145689: xe host-apply-edition: take into account new v6_license_server_version_obsolete alert

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
CA-145335: Switch to a record based model to create tapdisk3 statistics.

Prior to this patch, we used to return large tupes and process each
element individually to create the datasources. We now use a record to
hold sysfs_stats and another to hold blktap3 stats.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>
CA-145335: Add new datasources exposed by tapdisk3

Prior to XS6.5, a VM's metrics were supplied by xcp-rrdd,
xcp-rrd-iostat, etc... Originally, these metrics were created by reading
counters from `sysfs`. With tapdisk3, we read the statistics exposed
under '/dev/shm' to create these datasources.
The newly exposed counters are:
* vbd_<X>_iowait
* vbd_<X>_inflight
* vbd_<X>_iops_read
* vbd_<X>_iops_write
* vbd_<X>_iops_total
* vbd_<X>_io_throughput_total

Metrics like vbd_<X>_io_throughput_read and vbd_<X>_io_throughput_write
are redundant.

Signed-off-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>