| 1 |
=encoding utf8 |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
xen-pv-channel - Xen PV Channels |
| 6 |
|
| 7 |
=head1 DESCRIPTION |
| 8 |
|
| 9 |
A channel is a low-bandwidth private byte stream similar to a serial |
| 10 |
link. Typical uses of channels are |
| 11 |
|
| 12 |
=over |
| 13 |
|
| 14 |
=item 1. |
| 15 |
|
| 16 |
to provide initial configuration information to a VM on boot |
| 17 |
(example use: CloudStack's cloud-early-config service) |
| 18 |
|
| 19 |
|
| 20 |
=item 2. |
| 21 |
|
| 22 |
to signal/query an in-guest agent |
| 23 |
(example use: oVirt's guest agent) |
| 24 |
|
| 25 |
|
| 26 |
=back |
| 27 |
|
| 28 |
Channels are similar to virtio-serial devices and emulated serial links. |
| 29 |
Channels are intended to be used in the implementation of libvirt s |
| 30 |
when running on Xen. |
| 31 |
|
| 32 |
Note: if an application requires a high-bandwidth link then it should use |
| 33 |
vchan instead. |
| 34 |
|
| 35 |
|
| 36 |
=head2 How to use channels: an example |
| 37 |
|
| 38 |
Consider a cloud deployment where VMs are cloned from pre-made templates, |
| 39 |
and customised on first boot by an in-guest agent which sets the IP address, |
| 40 |
hostname, ssh keys etc. To install the system the cloud administrator would |
| 41 |
first: |
| 42 |
|
| 43 |
=over |
| 44 |
|
| 45 |
=item 1. |
| 46 |
|
| 47 |
Install a guest as normal (no channel configuration necessary) |
| 48 |
|
| 49 |
|
| 50 |
=item 2. |
| 51 |
|
| 52 |
Install the in-guest agent specific to the cloud software. This will |
| 53 |
prepare the guest to communicate over the channel, and also prepare |
| 54 |
the guest to be cloned safely (sometimes known as "sysprepping") |
| 55 |
|
| 56 |
|
| 57 |
=item 3. |
| 58 |
|
| 59 |
Shutdown the guest |
| 60 |
|
| 61 |
|
| 62 |
=item 4. |
| 63 |
|
| 64 |
Register the guest as a template with the cloud orchestration software |
| 65 |
|
| 66 |
|
| 67 |
=item 5. |
| 68 |
|
| 69 |
Install the cloud orchestration agent in dom0 |
| 70 |
|
| 71 |
|
| 72 |
=back |
| 73 |
|
| 74 |
At runtime, when a cloud tenant requests that a VM is created from the template, |
| 75 |
the sequence of events would be: (assuming a Linux domU) |
| 76 |
|
| 77 |
=over |
| 78 |
|
| 79 |
=item 1. |
| 80 |
|
| 81 |
A VM is "cloned" from the template |
| 82 |
|
| 83 |
|
| 84 |
=item 2. |
| 85 |
|
| 86 |
A unique Unix domain socket path in dom0 is allocated |
| 87 |
(e.g. /my/cloud/software/talk/to/domain/) |
| 88 |
|
| 89 |
|
| 90 |
=item 3. |
| 91 |
|
| 92 |
Domain configuration is created for the VM, listing the channel |
| 93 |
name expected by the in-guest agent. In xl syntax this would be: |
| 94 |
|
| 95 |
channel = [ "connection=socket, name=org.my.cloud.software.agent.version1, path = /my/cloud/software/talk/to/domain/" ] |
| 96 |
|
| 97 |
=item 4. |
| 98 |
|
| 99 |
The VM is started |
| 100 |
|
| 101 |
|
| 102 |
=item 5. |
| 103 |
|
| 104 |
In dom0 the cloud orchestration agent connects to the Unix domain |
| 105 |
socket, writes a handshake message and waits for a reply |
| 106 |
|
| 107 |
|
| 108 |
=item 6. |
| 109 |
|
| 110 |
Assuming the guest kernel has CONFIG_HVC_XEN_FRONTEND set then the console |
| 111 |
driver will generate a hotplug event |
| 112 |
|
| 113 |
|
| 114 |
=item 7. |
| 115 |
|
| 116 |
A udev rule is activated by the hotplug event. |
| 117 |
|
| 118 |
The udev rule would look something like: |
| 119 |
|
| 120 |
SUBSYSTEM=="xen", DEVPATH=="/devices/console-[0-9]", RUN+="xen-console-setup" |
| 121 |
|
| 122 |
where the "xen-console-setup" script would read the channel name and |
| 123 |
make a symlink in /dev/xen-channel/org.my.cloud.software.agent.version1 |
| 124 |
pointing to /dev/hvcN. N is the same number as the number in "/devices/console-[0-9]". |
| 125 |
In other words, "/devices/console-2" maps to /dev/hvc2. |
| 126 |
|
| 127 |
|
| 128 |
=item 8. |
| 129 |
|
| 130 |
The in-guest agent uses inotify to see the creation of the /dev/xen-channel |
| 131 |
symlink and opens the device. |
| 132 |
|
| 133 |
|
| 134 |
=item 9. |
| 135 |
|
| 136 |
The in-guest agent completes the handshake with the dom0 agent |
| 137 |
|
| 138 |
|
| 139 |
=item 10. |
| 140 |
|
| 141 |
The dom0 agent transmits the unique VM configuration: hostname, IP |
| 142 |
address, ssh keys etc etc |
| 143 |
|
| 144 |
|
| 145 |
=item 11. |
| 146 |
|
| 147 |
The in-guest agent receives the configuration and applies it. |
| 148 |
|
| 149 |
|
| 150 |
=back |
| 151 |
|
| 152 |
Using channels avoids having to use a temporary disk device or network |
| 153 |
connection. |
| 154 |
|
| 155 |
|
| 156 |
=head2 Design recommendations and pitfalls |
| 157 |
|
| 158 |
It's necessary to install channel-specific software (an "agent") into the guest |
| 159 |
before you can use a channel. By default a channel will appear as a device |
| 160 |
which could be mistaken for a serial port or regular console. It is known |
| 161 |
that some software will proactively seek out serial ports and issue AT commands |
| 162 |
at them; make sure such software is disabled! |
| 163 |
|
| 164 |
Since channels are identified by names, application authors must ensure their |
| 165 |
channel names are unique to avoid clashes. We recommend that channel names |
| 166 |
include parts unique to the application such as a domain names. To assist |
| 167 |
prevent clashes we recommend authors add their names to our global channel |
| 168 |
registry at the end of this document. |
| 169 |
|
| 170 |
|
| 171 |
=head2 Limitations |
| 172 |
|
| 173 |
Hotplug and unplug of channels is not currently implemented. |
| 174 |
|
| 175 |
|
| 176 |
=head2 Channel name registry |
| 177 |
|
| 178 |
It is important that channel names are globally unique. To help ensure |
| 179 |
that no-one's name clashes with yours, please add yours to this list. |
| 180 |
|
| 181 |
Key: |
| 182 |
N: Name |
| 183 |
C: Contact |
| 184 |
D: Short description of use, possibly including a URL to your software or API |
| 185 |
|
| 186 |
N: org.xenproject.guest.clipboard.0.1 |
| 187 |
C: David Scott <[email protected]> |
| 188 |
D: Share clipboard data via an in-guest agent. See: |
| 189 |
https://wiki.xenproject.org/wiki/Clipboard_sharing_protocol |