coreos / ignition

First boot installer and configuration tool

Home Page:https://coreos.github.io/ignition/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Hyper-V

bgilbert opened this issue · comments

Hyper-V has Hyper-V Integration Services for host-guest communication. It's possible to write a custom service, but that requires a host-side process to connect to a socket. But there's also a key-value service (documentation).

The key-value service does work on Linux, with a helper daemon shipped with the kernel source. Unlike the other hypervisors we support, the daemon appears to take the passive role; it connects and listens for get/set commands, maintaining a set of binary blob files in /var.

In principle, we can emulate the daemon: connect to the hypervisor socket, wait for a SET command for the correct key, then close the socket and continue. If we don't get the Ignition config in the initial set of keys, assume there isn't one. This involves a timeout, which isn't ideal, but the scope of the timeout is much more constrained than "all hardware detection has completed" as would be needed for a config drive.

The kernel headers give the appearance of a 2 KiB limit on the value size, which a) is cramped but sufficient for our purposes, and b) may not be a real limit in the wire protocol; we should test this.

Proposed next steps:

  • Try to get a custom key/value pair into the guest using hv_kvp_daemon
  • Try stopping the daemon, removing its data files, restarting it, and seeing whether the data is restored. This verifies that the host service doesn't require data persistence in the guest. If it did, Ignition's use of the K-V protocol would interfere with any hv_kvp_daemon instance run later in the real root.
  • Implement K-V socket in Ignition
  • Determine the maximum value size we can receive

coreos/fedora-coreos-tracker#251 discusses Hyper-V support in FCOS.

Just to make this explicit: an Ignition implementation can't be directly adapted from hv_kvp_daemon.c because the latter is GPLv2 and Ignition is Apache.

It appears that KVP values are limited to 1K characters (2K bytes in UTF-16). In OOB discussion we concluded that the least-worst approach was to support concatenating multiple keys together. OSes can document a PowerShell script that takes an Ignition config, chunks it, and sets the appropriate KVP keys.

Open questions:

  • How should the KVP keys be named/structured?
  • Is the Hyper-V socket interface accessible to non-root users or in a container?
  • Does the guest have an API to delete the host's KVP keys? (I assume no.)
  • Are the KVP keys deleted in the host (in the registry etc.) if the VM is deleted?

This was achieved by #1555 and other related PR's