Debian Codegraph @

docs/misc/console.txt

raw
1 Xen PV Console notes
2 ------------------------------------------------------------------------
3 Stefano Stabellini
4 [email protected]
5
6
7 Xen traditionally provided a single pv console to pv guests, storing the
8 relevant information in xenstore under /local/domain/$DOMID/console.
9
10 Now many years after the introduction of the pv console we have
11 multiple pv consoles support for pv and hvm guests; multiple pv
12 console backends (qemu and xenconsoled, see limitations below) and
13 emulated serial cards too.
14
15 This document tries to describe how the whole system works and how the
16 different components interact with each other.
17
18 The first PV console path in xenstore remains:
19
20 /local/domain/$DOMID/console
21
22 The virtual UART console path in xenstore is defined as:
23
24 /local/domain/$DOMID/vuart/0
25
26 The vuart console provides access to a virtual SBSA UART on ARM systems.
27 To enable vuart the following line has to be added to the guest configuration
28 file:
29
30 vuart = "sbsa_uart"
31
32 In Linux you can select the virtual SBSA UART by using the "ttyAMA0"
33 console instead of "hvc0".
34
35 The other PV consoles follow the conventional xenstore device path and
36 live in:
37
38 /local/domain/$DOMID/device/console/$DEVID.
39
40 PV consoles have
41 * (optional) string names;
42 * 'connection' information describing to what they should be
43 connected; and
44 * a 'type' indicating which daemon should process the data.
45
46 We call a PV console with a name a "channel", in reference to the libvirt
47 concept with the same name and purpose. The file "channels.txt" describes
48 how to use channels and includes a registry of well-known channel names.
49
50 If the PV console has a name (i.e. it is a "channel") then the name
51 is written to the frontend directory:
52
53 name = <name>
54
55 If the PV console has no name (i.e. it is a regular console) then the "name"
56 key is omitted.
57
58 The toolstack writes 'connection' information in the xenstore backend in
59 the keys
60 * connection: either 'pty' or 'socket'
61 * path: only present if connection = 'socket', the path of the socket to
62 glue the channel to
63
64 An artifact of the current implementation, the toolstack will write an
65 extra backend key
66 * output: an identifier only meaningful for qemu/xenconsoled
67
68 If the toolstack wants the console to be connected to a pty, it will write
69 to the backend:
70
71 connection = pty
72 output = pty
73
74 The backend will write the pty device name to the "tty" node in the
75 console frontend.
76
77 For the PV console the tty node is added at
78
79 /local/domain/$DOMID/console/tty
80
81 For the virtual UART console the tty node is added at
82
83 /local/domain/$DOMID/vuart/0/tty
84
85 If the toolstack wants a listening Unix domain socket to be created at path
86 <path>, a connection accepted and data proxied to the console, it will write:
87
88 connection = socket
89 path = <path>
90 output = chardev:<some internal identifier>
91
92 where chardev:<some internal identifier> matches a qemu character device
93 configured on the qemu command-line.
94
95 The backend implementation daemon chosen for a particular console is specified
96 by the toolstack in the "type" node in the xenstore frontend.
97 For example:
98
99 # xenstore-read /local/domain/26/console/1/type
100 ioemu
101
102 The supported values are only xenconsoled or ioemu; xenconsoled has
103 several limitations: it can only be used for the first PV or virtual UART
104 console and it can only connect to a pty.
105
106 Emulated serials are provided by qemu-dm only to hvm guests; the number
107 of emulated serials depends on how many "-serial" command line options
108 are given to qemu. The output of a serial is specified as argument to
109 the -serial command line option to qemu. Qemu writes the tty name to
110 xenstore in the following path:
111
112 /local/domain/$DOMID/serial/$SERIAL_NUM/tty
113
114 xenconsole is the tool to connect to a PV or virtual UART console or an
115 emulated serial that has a pty as output. Xenconsole takes a domid as
116 parameter plus an optional console type (pv for PV consoles, vuart for
117 virtual UART or serial for emulated serials) and console number.
118 Depending on the type and console number, xenconsole will look for the tty
119 node in different xenstore paths, as described above. If the user doesn't
120 specify the console type xenconsole will try to guess: if the guest is a pv
121 guest it defaults to PV console, if the guest is an hvm guest it defaults to
122 emulated serial.
123
124 By default xl creates a pv console for hvm guests, plus an emulated
125 serial if the user specified 'serial = "pty"' in the VM config file.
126 Considering that xenconsole defaults to emulated serials for hvm guests,
127 executing xl create -c "domain" causes xenconsole to attach to the
128 emulated serial tty. This is most probably what the user wanted because
129 currently no bootloaders support xen pv consoles so the only way to
130 interact with a bootloader like grub over a console is to use the
131 emulated serial.
132 However the pv console is still easy to use with Linux PV on HVM guests:
133 the user just need to pass "console=hvc0" to the kernel command line and
134 then execute "xl console -t pv <domain>" to connect to it.
135
136 When using stubdoms the serial cards are still emulated by qemu (this
137 time running in the stubdom), the number of serial cards and where the
138 output goes is still specified using qemu command line options.
139 The difference is that for each emulated serial card there must be a pv
140 console connection between the stubdom and dom0 to export the serial
141 output from the stubdom to dom0. The pv console backend for stubdom's pv
142 consoles is always ioemu because multiple pv consoles support is a
143 requirement in this case, considering that minios has its own pv console
144 too. In order to simplify the setup when using stubdoms the hvm guest
145 can only have one pv console with xenstored as backend (the stubdom
146 could provide pv console backends to the hvm guest but then it would
147 need another pv console connection for each console backend to export
148 the pty to dom0).
149
150 The xenconsole program supports a very simple protocol to notify parent about
151 its readiness. If xenconsole (the client) is exec'ed and has been given a fd
152 (normally the write end of a pipe) via --start-notify-fd option, it will
153 write 0x00 to that fd after connecting to the guest but before entering the
154 event loop. Parent can read from the read end of the fd to know the status.