CA-92154: Handle metrics files larger than 16 KiB

Unix.read doesn't read more than 16 KiB in one go. Hence use Unixext.really_read instead. This is potentially problematic particularly for reading the payload from the metrics file.

Signed-off-by: Jonathan Davies <jonathan.davies@citrix.com>
CA-93559: Change code ordering within force_state_reset.

A VM's power_state and allowed_operations are now updated after its
devices are updated. This makes more sense for clients which are
watching for VM.power_state to become halted.

Signed-off-by: John Else <john.else@citrix.com>
Logging fix.

When we're updating the database value of VBD.currently_attached in
response to a xenopsd event, make sure we log the value we're putting
into the database.

Signed-off-by: John Else <john.else@citrix.com>
Remove an unused function.

This function wasn't being used as far back as George, so I think it's
safe to get rid of it.

Signed-off-by: John Else <john.else@citrix.com>
CA-95060: Keep trying xenopsd->SMAPI calls until they stop throwing ECONNREFUSED.

If xapi is not running, xenopsd should wait indefinitely for it to
return when trying to make SMAPI calls.

Signed-off-by: John Else <john.else@citrix.com>
CA-95060: Move exception No_storage_plugin_for_sr to storage_interface.ml

This makes it easier to catch for SMAPI clients, since it no longer gets
wrapped in a Storage_interface.Internal_error.

Signed-off-by: John Else <john.else@citrix.com>
Whitespace: Xenops_server_xen.Storage.dp_destroy

Signed-off-by: John Else <john.else@citrix.com>
CA-95060: Ignore Storage_interface.No_storage_plugin_for_sr when calling DP.destroy from xenops.

Signed-off-by: John Else <john.else@citrix.com>
CA-89303: A slave without master cannot bring up its management interface.

It should not try to query the DB, since the master is not accessible.

This commit fixes the problem introduces by the fix for CA-87787,
commit: 8d0adadf54911e7b6a645ca1ca2fdb241f65ad3e

Signed-off-by: Jerome Maloberti <jerome.maloberti@citrix.com>
Merge pull request #977 from jeromemaloberti/CA-89303-tampa-lcm

CA-89303: A slave without master cannot bring up its management interface
Merge pull request #976 from jeromemaloberti/CA-95060-tampa-lcm

CA-95060/XOP-228 If a VM shuts down on a slave when xapi is not running, its disks are not deactivated when xapi starts up again
CA-94829: Set the TCP timeout properties on the migration fd

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>

Conflicts:
	ocaml/xenguest/xenguest_main.ml

Signed-off-by: Jerome Maloberti <jerome.maloberti@citrix.com>
Merge pull request #975 from jeromemaloberti/CA-93559-tampa-lcm

CA-93559/XOP-227: Change code ordering within force_state_reset
Merge pull request #981 from jeromemaloberti/CA-94829-tampa-lcm

CA-94829: Set the TCP timeout properties on the migration fd
CA-97023: Preserve VM settings (Optimized for Citrix XenApp)
Merge pull request #982 from jeromemaloberti/CA-97023-tampa-lcm

CA-97023: Preserve VM settings (Optimized for Citrix XenApp)
CA-97883: Wrap the fstat call in an exception handler

We can get an exception when we're fstatting a file that's larger
than is representable in a signed 32-bit integer (ie., 2 gigs).
If this happens, it's clearly not a socket, so don't bother setting
the TCP timeout parameters.

This patch is actually a bit more defensive, and ignores any
exception thrown here.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Merge pull request #990 from jeromemaloberti/CA-97883-tampa-lcm

CA-97883: Wrap the fstat call in an exception handler
CA-98936: Stop xapi from creating files in /tmp every time it gets an update from xenopsd

Signed-off-by: John Else <john.else@citrix.com>
Fix bridge name selection for vswitch mode in scripts/setup-vif-rules
  -        bridge_name = "xenbr%s" % devid
  +        bridge_name = get_bridge_name_vswitch(vif_name)

  Devid is device number for domU (f.e. vif1.15; 15 - devid) and is definitely NOT a
  xenbr number (xenbr0, xenbr1, etc).

Signed-off-by: George Shuklin <george.shuklin@gmail.com>