CA-77064: Replace the poorly-named unsafe 'mkdir_safe' with the safer 'mkdir_rec'

This prevented host memory from being recorded correctly on startup

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-77013: Turn the unimplemented SMAPIv1 exception into an SMAPIv2 one

We were matching on this for VDI clone falling back to slow copy, but
the SMAPIv2 layer was intercepting the v1 exception and turning it into
an internal error.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CP-3296: conditionally-compile the new xenguest interface

In the XCP xen patchqueue I've added the export
  XENGUEST_HAS_HVM_BUILD_ARGS
to the patch which backports xen-unstable.hg c/s 7e1fd8012ca3

The new interface should also be present in xen-4.2 onwards so we also
use it if
  __XEN_LATEST_INTERFACE_VERSION__ >= 0x00040200

Hopefully this will compile and work on:
  xen-4.2 (not tested)
  xen-unstable (not tested)
  xen-4.1 (tested, OK)
  XCP with xen-4.1 + backports (tested, OK)

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Merge pull request #545 from djs55/cooper-merge

Split xenopsd from xapi
CA-77236: networkd: reread inventory file before looking up anything

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
CA-76927: make the timeout of networkd's init script longer than that of dhclient

This ensures that the init script does not return an error due to
a slow DHCP process (the timeout of dhclient is 60s).

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
[WHITESPACE] Fix indentation of Xapi.bring_up_management_if function

This-is-only-a-whitespace-change proof:

$ git diff -w HEAD^ | wc -l
0

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
CP-3477: Make xapi listen on all dom0 IP addresses

Xapi now starts listening on all IP addresses when it starts up, and
management is not disabled.

Even though xapi listens on all IP addresses, there is still an interface
appointed as _the_ management interface. Slaves in a pool use the IP address
of this interface to connect the pool master.

It is now no longer needed to rebind the management socket after IP changes.

Changing the management interface with Host.management_reconfigure now starts
the API server in case it was not running, but leaves it alone otherwise.
Besides that, it is only an update of the inventory file, plus an update of the
Host.address field.

Also remove the rewrite-management-interface script, and instead update the
MANAGEMENT_INTERFACE key in inventory file in xapi itself.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Remove unused module Xapi_network_types

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Use HTTP "host" header to decided whether to forward and API call to the master

Since xapi is now listening on all dom0 IPs, API calls coming in on
the HIMN now go through the API server as all other incoming calls.

The different between calls on the HIMN and those coming from outside
is that HIMN calls on a pool slave must be forwarded to the master, while
others do not. We use the HTTP "host" header to distinguish between these
cases.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Clean up HIMN code

Since the HIMN connections are now handled by the main api_server,
there are only two special HIMN things to do: getting an IP address on the
HIMN bridge, and starting a HIMN API server in case management is disabled.

This code has been modified and moved to Xapi_network and Xapi_mgmt_iface.
There is now no longer any need for Xapi_network_real, so remove it.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
networkd: add exception handler to get_carrier function

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
networkd: make Linux bond functions idempotent

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Allow Nm.bring_pif_up (down) even when currently_attached is not false (true)

This is possible, because all functions of networkd are idempotent.

PIF.plug can now be used to sync networkd's internal state, even when
a PIF is already up, to ensure that it come back correctly after a reboot.

Furthermore, it is now no longer necessary to unplug a PIF when changing
a parameter such as the MTU. To change the MTU, set the new value on the
network object, and then do a PIF.plug right away to make it happen.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Remove lines that are redundant since the previous commit

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
CA-73892: networkd: after upgrade, use the old script to bring up NICs

This needs to happen before xapi starts (especially on a pool slave).
Networkd does not have any state yet, because it was not present before
the upgrade. Therefore, it uses the old init script (management-interface)
to initially bring up and configure all interfaces.

When xapi starts up after that, it will sync up with networkd through
the "Best-effort bring up of physical NICs" startup item, in order to
fill networkd's cache.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
On xapi start, also plug PIFs with IP configuration

This ensures that the state of all PIFs that are configured by networkd
when the hosts starts (before xapi) gets updated.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Fix the build
Move xenopsd into PACKAGES.main (not PACKAGES.xcp -- this is for things which are *only* in XCP)
Implements device_id for Windows VM