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-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>
Add a function to upgrade old-style hd.. device names

Signed-off-by: John Else <john.else@citrix.com>
CA-146911: Upgrade device names on import to xenopsd

When pushing VM metadata to xenopsd, xapi now uses xvd as the prefix for
HVM as well as PV VBD device names.

VMs migrating from XS 6.2 or earlier will however be using hd as the prefix -
we must upgrade these device names to use xvd on import, otherwise xapi will
push conflicting data to xenopsd, causing xenopsd to attempt to remove the hd*
devices (which will fail if they are attached).

Signed-off-by: John Else <john.else@citrix.com>
Merge pull request #1960 from johnelse/ca-146911-xs64bit

CA-146911: Upgrade device names on import to xenopsd
Merge pull request #1955 from siddharthv/blktap3_rrdp_io

CA-145355: Make xcp-rrdd report all stats exposed by tapdisk3