Imported Upstream version 1.2.4
[archive/platform/upstream/libvirt.git] / docs / uri.html.in
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4   <body>
5     <h1 >Connection URIs</h1>
6
7     <ul id="toc"></ul>
8     <p>
9 Since libvirt supports many different kinds of virtualization
10 (often referred to as "drivers" or "hypervisors"), we need a
11 way to be able to specify which driver a connection refers to.
12 Additionally we may want to refer to a driver on a remote
13 machine over the network.
14 </p>
15     <p>
16 To this end, libvirt uses URIs as used on the Web and as defined in <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>. This page
17 documents libvirt URIs.
18 </p>
19     <h2><a name="URI_libvirt">Specifying URIs to libvirt</a></h2>
20
21     <p>
22 The URI is passed as the <code>name</code> parameter to <a href="html/libvirt-libvirt.html#virConnectOpen"><code>virConnectOpen</code></a> or <a href="html/libvirt-libvirt.html#virConnectOpenReadOnly"><code>virConnectOpenReadOnly</code></a>.  For example:
23 </p>
24     <pre>
25 virConnectPtr conn = virConnectOpenReadOnly (<b>"test:///default"</b>);
26 </pre>
27     <h2>
28       <a name="URI_config">Configuring URI aliases</a>
29     </h2>
30
31     <p>
32 To simplify life for administrators, it is possible to setup URI aliases in a
33 libvirt client configuration file. The configuration file is <code>/etc/libvirt/libvirt.conf</code>
34 for the root user, or <code>$XDG_CONFIG_HOME/libvirt/libvirt.conf</code> for any unprivileged user.
35 In this file, the following syntax can be used to setup aliases
36     </p>
37
38 <pre>
39 uri_aliases = [
40   "hail=qemu+ssh://root@hail.cloud.example.com/system",
41   "sleet=qemu+ssh://root@sleet.cloud.example.com/system",
42 ]
43 </pre>
44
45 <p>
46   A URI alias should be a string made up from the characters
47   <code>a-Z, 0-9, _, -</code>. Following the <code>=</code>
48   can be any libvirt URI string, including arbitrary URI parameters.
49   URI aliases will apply to any application opening a libvirt
50   connection, unless it has explicitly passed the <code>VIR_CONNECT_NO_ALIASES</code>
51   parameter to <code>virConnectOpenAuth</code>. If the passed in
52   URI contains characters outside the allowed alias character
53   set, no alias lookup will be attempted.
54 </p>
55
56     <h2><a name="URI_default">Default URI choice</a></h2>
57
58     <p>
59 If the URI passed to <code>virConnectOpen*</code> is NULL, then libvirt will use the following
60 logic to determine what URI to use.
61 </p>
62
63     <ol>
64       <li>The environment variable <code>LIBVIRT_DEFAULT_URI</code></li>
65       <li>The client configuration file <code>uri_default</code> parameter</li>
66       <li>Probe each hypervisor in turn until one that works is found</li>
67     </ol>
68
69     <h2>
70       <a name="URI_virsh">Specifying URIs to virsh, virt-manager and virt-install</a>
71     </h2>
72     <p>
73 In virsh use the <code>-c</code> or <code>--connect</code> option:
74 </p>
75     <pre>
76 virsh <b>-c test:///default</b> list
77 </pre>
78     <p>
79 If virsh finds the environment variable
80 <code>VIRSH_DEFAULT_CONNECT_URI</code> set, it will try this URI by
81 default. Use of this environment variable is, however, deprecated
82 now that libvirt supports <code>LIBVIRT_DEFAULT_URI</code> itself.
83 </p>
84     <p>
85 When using the interactive virsh shell, you can also use the
86 <code>connect</code> <i>URI</i> command to reconnect to another
87 hypervisor.
88 </p>
89     <p>
90 In virt-manager use the <code>-c</code> or <code>--connect=</code><i>URI</i> option:
91 </p>
92     <pre>
93 virt-manager <b>-c test:///default</b>
94 </pre>
95     <p>
96 In virt-install use the <code>--connect=</code><i>URI</i> option:
97 </p>
98     <pre>
99 virt-install <b>--connect=test:///default</b> <i>[other options]</i>
100 </pre>
101     <h2>
102       <a name="URI_xen">xen:/// URI</a>
103     </h2>
104     <p>
105       <i>This section describes a feature which is new in libvirt &gt;
106 0.2.3.  For libvirt &#x2264; 0.2.3 use <a href="#URI_legacy_xen"><code>"xen"</code></a>.</i>
107     </p>
108     <p>
109 To access a Xen hypervisor running on the local machine
110 use the URI <code>xen:///</code>.
111 </p>
112     <h2>
113       <a name="URI_qemu">qemu:///... QEMU and KVM URIs</a>
114     </h2>
115     <p>
116 To use QEMU support in libvirt you must be running the
117 <code>libvirtd</code> daemon (named <code>libvirt_qemud</code>
118 in releases prior to 0.3.0).  The purpose of this
119 daemon is to manage qemu instances.
120 </p>
121     <p>
122 The <code>libvirtd</code> daemon should be started by the
123 init scripts when the machine boots. It should appear as
124 a process <code>libvirtd --daemon</code> running as root
125 in the background and will handle qemu instances on behalf
126 of all users of the machine (among other things). </p>
127     <p>
128 So to connect to the daemon, one of two different URIs is used:
129 </p>
130     <ul>
131       <li><code>qemu:///system</code> connects to a system mode daemon. </li>
132       <li><code>qemu:///session</code> connects to a session mode daemon. </li>
133     </ul>
134     <p>
135 (If you do <code>libvirtd --help</code>, the daemon will print
136 out the paths of the Unix domain socket(s) that it listens on in
137 the various different modes).
138 </p>
139     <p>
140 KVM URIs are identical.  You select between qemu, qemu accelerated and
141 KVM guests in the <a href="format.html#KVM1">guest XML as described
142 here</a>.
143 </p>
144     <h2>
145       <a name="URI_remote">Remote URIs</a>
146     </h2>
147     <p>
148 Remote URIs are formed by taking ordinary local URIs and adding a
149 hostname and/or transport name. As a special case, using a URI
150 scheme of 'remote', will tell the remote libvirtd server to probe
151 for the optimal hypervisor driver. This is equivalent to passing
152 a NULL URI for a local connection. For example:
153 </p>
154     <table class="top_table">
155       <tr>
156         <th> Local URI </th>
157         <th> Remote URI </th>
158         <th> Meaning </th>
159       </tr>
160       <tr>
161         <td>
162           <code>xen:///</code>
163         </td>
164         <td>
165           <code>xen://oirase/</code>
166         </td>
167         <td> Connect to the Xen hypervisor running on host <code>oirase</code>
168   using TLS. </td>
169       </tr>
170       <tr>
171         <td>
172           <code>NULL</code>
173         </td>
174         <td>
175           <code>remote://oirase/</code>
176         </td>
177         <td> Connect to the "default" hypervisor running on host <code>oirase</code>
178   using TLS. </td>
179       </tr>
180       <tr>
181         <td>
182           <code>xen:///</code>
183         </td>
184         <td>
185           <code>xen+ssh://oirase/</code>
186         </td>
187         <td> Connect to the Xen hypervisor running on host <code>oirase</code>
188   by going over an <code>ssh</code> connection. </td>
189       </tr>
190       <tr>
191         <td>
192           <code>test:///default</code>
193         </td>
194         <td>
195           <code>test+tcp://oirase/default</code>
196         </td>
197         <td> Connect to the test driver on host <code>oirase</code>
198   using an unsecured TCP connection. </td>
199       </tr>
200     </table>
201     <p>
202 Remote URIs in libvirt offer a rich syntax and many features.
203 We refer you to <a href="remote.html#Remote_URI_reference">the libvirt
204 remote URI reference</a> and <a href="remote.html">full documentation
205 for libvirt remote support</a>.
206 </p>
207     <h2>
208       <a name="URI_test">test:///... Test URIs</a>
209     </h2>
210     <p>
211 The test driver is a dummy hypervisor for test purposes.
212 The URIs supported are:
213 </p>
214     <ul>
215       <li><code>test:///default</code> connects to a default set of
216 host definitions built into the driver. </li>
217       <li><code>test:///path/to/host/definitions</code> connects to
218 a set of host definitions held in the named file.
219 </li>
220     </ul>
221     <h2>
222       <a name="URI_legacy">Other &amp; legacy URI formats</a>
223     </h2>
224     <h3>
225       <a name="URI_NULL">NULL and empty string URIs</a>
226     </h3>
227     <p>
228 Libvirt allows you to pass a <code>NULL</code> pointer to
229 <code>virConnectOpen*</code>.  Empty string (<code>""</code>) acts in
230 the same way.  Traditionally this has meant
231 <q>connect to the local Xen hypervisor</q>.  However in future this
232 may change to mean <q>connect to the best available hypervisor</q>.
233 </p>
234     <p>
235 The theory is that if, for example, Xen is unavailable but the
236 machine is running an OpenVZ kernel, then we should not try to
237 connect to the Xen hypervisor since that is obviously the wrong
238 thing to do.
239 </p>
240     <p>
241 In any case applications linked to libvirt can continue to pass
242 <code>NULL</code> as a default choice, but should always allow the
243 user to override the URI, either by constructing one or by allowing
244 the user to type a URI in directly (if that is appropriate).  If your
245 application wishes to connect specifically to a Xen hypervisor, then
246 for future proofing it should choose a full <a href="#URI_xen"><code>xen:///</code> URI</a>.
247 </p>
248     <h3>
249       <a name="URI_file">File paths (xend-unix-server)</a>
250     </h3>
251     <p>
252 If XenD is running and configured in <code>/etc/xen/xend-config.sxp</code>:
253 </p>
254     <pre>
255 (xend-unix-server yes)
256 </pre>
257     <p>
258 then it listens on a Unix domain socket, usually at
259 <code>/var/lib/xend/xend-socket</code>.  You may pass a different path
260 using a file URI such as:
261 </p>
262     <pre>
263 virsh -c ///var/run/xend/xend-socket
264 </pre>
265     <h3>
266       <a name="URI_http">Legacy: <code>http://...</code> (xend-http-server)</a>
267     </h3>
268     <p>
269 If XenD is running and configured in <code>/etc/xen/xend-config.sxp</code>:
270
271 </p>
272     <pre>
273 (xend-http-server yes)
274 </pre>
275     <p>
276 then it listens on TCP port 8000.  libvirt allows you to
277 try to connect to xend running on remote machines by passing
278 <code>http://<i>hostname</i>[:<i>port</i>]/</code>, for example:
279
280 </p>
281     <pre>
282 virsh -c http://oirase/ list
283 </pre>
284     <p>
285 This method is unencrypted and insecure and is definitely not
286 recommended for production use.  Instead use <a href="remote.html">libvirt's remote support</a>.
287 </p>
288     <p>
289 Notes:
290 </p>
291     <ol>
292       <li> The HTTP client does not fully support IPv6. </li>
293       <li> Many features do not work as expected across HTTP connections, in
294  particular, <a href="html/libvirt-libvirt.html#virConnectGetCapabilities">virConnectGetCapabilities</a>.
295  The <a href="remote.html">remote support</a> however does work
296  correctly. </li>
297       <li> XenD's new-style XMLRPC interface is not supported by
298  libvirt, only the old-style sexpr interface known in the Xen
299  documentation as "unix server" or "http server".</li>
300     </ol>
301     <h3>
302       <a name="URI_legacy_xen">Legacy: <code>"xen"</code></a>
303     </h3>
304     <p>
305 Another legacy URI is to specify name as the string
306 <code>"xen"</code>.  This will continue to refer to the Xen
307 hypervisor.  However you should prefer a full <a href="#URI_xen"><code>xen:///</code> URI</a> in all future code.
308 </p>
309     <h3>
310       <a name="URI_legacy_proxy">Legacy: Xen proxy</a>
311     </h3>
312     <p>
313 Libvirt continues to support connections to a separately running Xen
314 proxy daemon.  This provides a way to allow non-root users to make a
315 safe (read-only) subset of queries to the hypervisor.
316 </p>
317     <p>
318 There is no specific "Xen proxy" URI.  However if a Xen URI of any of
319 the ordinary or legacy forms is used (eg. <code>NULL</code>,
320 <code>""</code>, <code>"xen"</code>, ...) which fails, <i>and</i> the
321 user is not root, <i>and</i> the Xen proxy socket can be connected to
322 (<code>/tmp/libvirt_proxy_conn</code>), then libvirt will use a proxy
323 connection.
324 </p>
325     <p>
326 You should consider using <a href="remote.html">libvirt remote support</a>
327 in future. <span class="since">Since 0.8.6</span> libvirt doesn't contain
328 the Xen proxy anymore and you should use libvirtd instead.
329 </p>
330   </body>
331 </html>