Skip to content

Commit 2ce756a

Browse files
author
David Scott
committed
Import/export: improve formatting
Signed-off-by: David Scott <[email protected]>
1 parent 25763e9 commit 2ce756a

File tree

1 file changed

+77
-142
lines changed

1 file changed

+77
-142
lines changed

xen-api/importexport.md

Lines changed: 77 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -7,91 +7,63 @@ VMs can be exported to a file and later imported to any XenServer host. The expo
77

88
The following arguments are passed on the command line:
99

10-
<table>
11-
<col width="28%" />
12-
<col width="68%" />
13-
<thead>
14-
<tr class="header">
15-
<th align="left">Argument</th>
16-
<th align="left">Description</th>
17-
</tr>
18-
</thead>
19-
<tbody>
20-
<tr class="odd">
21-
<td align="left">session_id</td>
22-
<td align="left">the reference of the session being used to authenticate; required only when not using HTTP basic authentication</td>
23-
</tr>
24-
<tr class="even">
25-
<td align="left">task_id</td>
26-
<td align="left">the reference of the task object with which to keep track of the operation; optional, required only if you have created a task object to keep track of the export</td>
27-
</tr>
28-
<tr class="odd">
29-
<td align="left">ref</td>
30-
<td align="left">the reference of the VM; required only if not using the UUID</td>
31-
</tr>
32-
<tr class="even">
33-
<td align="left">uuid</td>
34-
<td align="left">the UUID of the VM; required only if not using the reference</td>
35-
</tr>
36-
</tbody>
37-
</table>
10+
Argument | Description
11+
------------|---------------------------------------------------------
12+
session_id | the reference of the session being used to authenticate; required only when not using HTTP basic authentication
13+
task_id | the reference of the task object with which to keep track of the operation; optional, required only if you have created a task object to keep track of the export
14+
ref | the reference of the VM; required only if not using the UUID
15+
uuid | the UUID of the VM; required only if not using the reference
16+
3817

3918
For example, using the Linux command line tool cURL:
4019

41-
curl http://root:foo@myxenserver1/export?uuid=<vm_uuid> -o <exportfile>
20+
```sh
21+
$ curl http://root:foo@myxenserver1/export?uuid=<vm_uuid> -o <exportfile>
22+
```
4223

4324
will export the specified VM to the file `exportfile`.
4425

4526
To export just the metadata, use the URI `http://server/export_metadata`.
4627

4728
The import protocol is similar, using HTTP(S) PUT. The `session_id` and `task_id` arguments are as for the export. The `ref` and `uuid` are not used; a new reference and uuid will be generated for the VM. There are some additional parameters:
4829

49-
<table>
50-
<col width="28%" />
51-
<col width="68%" />
52-
<thead>
53-
<tr class="header">
54-
<th align="left">Argument</th>
55-
<th align="left">Description</th>
56-
</tr>
57-
</thead>
58-
<tbody>
59-
<tr class="odd">
60-
<td align="left">restore</td>
61-
<td align="left">if <em>true</em>, the import is treated as replacing the original VM - the implication of this currently is that the MAC addresses on the VIFs are exactly as the export was, which will lead to conflicts if the original VM is still being run.</td>
62-
</tr>
63-
<tr class="even">
64-
<td align="left">force</td>
65-
<td align="left">if <em>true</em>, any checksum failures will be ignored (the default is to destroy the VM if a checksum error is detected)</td>
66-
</tr>
67-
<tr class="odd">
68-
<td align="left">sr_id</td>
69-
<td align="left">the reference of an SR into which the VM should be imported. The default behavior is to import into the <em>Pool.default_SR</em>.</td>
70-
</tr>
71-
</tbody>
72-
</table>
30+
Argument | Description
31+
------------|---------------------------------------------------------
32+
restore | if `true`, the import is treated as replacing the original VM - the implication of this currently is that the MAC addresses on the VIFs are exactly as the export was, which will lead to conflicts if the original VM is still being run.
33+
force | if `true`, any checksum failures will be ignored (the default is to destroy the VM if a checksum error is detected)
34+
sr_id | the reference of an SR into which the VM should be imported. The default behavior is to import into the `Pool.default_SR`
7335

7436
For example, again using cURL:
7537

38+
```sh
7639
curl -T <exportfile> http://root:foo@myxenserver2/import
40+
```
7741

7842
will import the VM to the default SR on the server.
7943

8044
> **Note**
8145
>
82-
> Note that if no default SR has been set, and no sr\_uuid is specified, the error message "DEFAULT\_SR\_NOT\_FOUND" is returned.
46+
> Note that if no default SR has been set, and no `sr_uuid` is specified, the error message `DEFAULT_SR_NOT_FOUND` is returned.
8347
8448
Another example:
8549

86-
curl -T <exportfile> http://root:foo@myxenserver2/import?sr_id=<opaque_ref_of_sr>
50+
```sh
51+
curl -T <exportfile> http://root:foo@myxenserver2/import?sr_id=<ref_of_sr>
52+
```
8753

8854
will import the VM to the specified SR on the server.
8955

9056
To import just the metadata, use the URI `http://server/import_metadata`
9157

92-
### Xen Virtual Appliance (XVA) VM Import Format
58+
Legacy VM Import Format
59+
=======================
60+
61+
This section describes the legacy VM import/export format and is for historical
62+
interest only. It should be updated to describe the current format, see
63+
[issue 64](https://github.com/xapi-project/xapi-project.github.io/issues/64)
64+
9365

94-
XenServer supports a human-readable legacy VM input format called XVA. This section describes the syntax and structure of XVA.
66+
Xapi supports a human-readable legacy VM input format called XVA. This section describes the syntax and structure of XVA.
9567

9668
An XVA consists of a directory containing XML metadata and a set of disk images. A VM represented by an XVA is not intended to be directly executable. Data within an XVA package is compressed and intended for either archiving on permanent storage or for being transmitted to a VM server - such as a XenServer host - where it can be decompressed and executed.
9769

@@ -119,63 +91,85 @@ The following terms will be used in the rest of the chapter:
11991

12092
The "ova.xml" file contains the following elements:
12193

94+
```xml
12295
<appliance version="0.1">
96+
```
12397

12498
The number in the attribute "version" indicates the version of this specification to which the XVA is constructed; in this case version 0.1. Inside the \<appliance\> there is exactly one \<vm\>: (in the OVA specification, multiple \<vm\>s are permitted)
12599

100+
```xml
126101
<vm name="name">
102+
```
127103

128-
Each \<vm\> element describes one VM. The "name" attribute is for future internal use only and must be unique within the ova.xml file. The "name" attribute is permitted to be any valid UTF-8 string. Inside each \<vm\> tag are the following compulsory elements:
104+
Each `<vm>` element describes one VM. The "name" attribute is for future internal use only and must be unique within the ova.xml file. The "name" attribute is permitted to be any valid UTF-8 string. Inside each \<vm\> tag are the following compulsory elements:
129105

106+
```xml
130107
<label>... text ... </label>
108+
```
131109

132110
A short name for the VM to be displayed in a UI.
133111

112+
```xml
134113
<shortdesc> ... description ... </shortdesc>
114+
```
135115

136-
A description for the VM to be displayed in the UI. Note that for both \<label\> and \<shortdesc\> contents, leading and trailing whitespace will be ignored.
116+
A description for the VM to be displayed in the UI. Note that for both `<label>` and `<shortdesc>` contents, leading and trailing whitespace will be ignored.
137117

118+
```xml
138119
<config mem_set="268435456" vcpus="1"/>
120+
```
139121

140-
The `<config>` element has attributes which describe the amount of memory in bytes (mem\_set) and number of CPUs (VCPUs) the VM should have.
122+
The `<config>` element has attributes which describe the amount of memory in bytes (`mem_set`) and number of CPUs (VCPUs) the VM should have.
141123

142-
Each `<vm>` has zero or more \<vbd\> elements representing block devices which look like the following:
124+
Each `<vm>` has zero or more `<vbd>` elements representing block devices which look like the following:
143125

126+
```xml
144127
<vbd device="sda" function="root" mode="w" vdi="vdi_sda"/>
128+
```
145129

146130
The attributes have the following meanings:
147131

148-
device
149-
name of the physical device to expose to the VM. For linux guests we use "sd[a-z]" and for windows guests we use "hd[a-d]".
150-
151-
function
152-
if marked as "root", this disk will be used to boot the guest. (NB this does not imply the existence of the Linux root i.e. / filesystem) Only one device should be marked as "root". See Section 3.4 describing VM booting. Any other string is ignored.
153-
154-
mode
155-
either "w" or "ro" if the device is to be read/write or read-only
156-
157-
vdi
158-
the name of the disk image (represented by a \<vdi\> element) to which this block device is connected
132+
* `device`: name of the physical device to expose to the VM. For linux guests
133+
we use "sd[a-z]" and for windows guests we use "hd[a-d]".
134+
* `function`: if marked as "root", this disk will be used to boot the guest.
135+
(NB this does not imply the existence of the Linux root i.e. / filesystem)
136+
Only one device should be marked as "root". See Section 3.4 describing VM
137+
booting. Any other string is ignored.
138+
* `mode`: either "w" or "ro" if the device is to be read/write or read-only
139+
* `vdi`: the name of the disk image (represented by a `<vdi>` element) to which
140+
this block device is connected
159141

160-
Each \<vm\> may have an optional \<hacks\> section like the following: \<hacks is\_hvm="false" kernel\_boot\_cmdline="root=/dev/sda1 ro"/\> The \<hacks\> element is present in the XVA files generated by XenServer but will be removed in future. The attribute "is\_hvm" is either "true" or "false", depending on whether the VM should be booted in HVM or not. The "kernel\_boot\_cmdline" contains additional kernel commandline arguments when booting a guest using pygrub.
142+
Each `<vm>` may have an optional `<hacks>` section like the following:
161143

162-
In addition to a \<vm\> element, the \<appliance\> will contain zero or more \<vdi\> elements like the following:
144+
```xml
145+
<hacks is_hvm="false" kernel_boot_cmdline="root=/dev/sda1 ro"/>
146+
```
163147

164-
<vdi name="vdi_sda" size="5368709120" source="file://sda"
165-
type="dir-gzipped-chunks">
148+
The `<hacks>` element will be removed in future. The attribute `is_hvm` is
149+
either `true` or `false`, depending on whether the VM should be booted in HVM or not.
150+
The `kernel_boot_cmdline` contains additional kernel commandline arguments when
151+
booting a guest using pygrub.
166152

167-
Each \<vdi\> corresponds to a disk image. The attributes have the following meanings:
153+
In addition to a `<vm>` element, the `<appliance>` will contain zero or more
154+
`<vdi>` elements like the following:
168155

169-
- name: name of the VDI, referenced by the vdi attribute of \<vbd\> elements. Any valid UTF-8 string is permitted.
156+
```xml
157+
<vdi name="vdi_sda" size="5368709120" source="file://sda" type="dir-gzipped-chunks">
158+
```
170159

171-
- size: size of the required image in bytes
160+
Each `<vdi>` corresponds to a disk image. The attributes have the following meanings:
172161

173-
- source: a URI describing where to find the data for the image, only file:// URIs are currently permitted and must describe paths relative to the directory containing the ova.xml
174-
175-
- type: describes the format of the disk data (see Section 3.3)
162+
* `name`: name of the VDI, referenced by the vdi attribute of `<vbd>`elements.
163+
Any valid UTF-8 string is permitted.
164+
* `size`: size of the required image in bytes
165+
* `source`: a URI describing where to find the data for the image, only
166+
file:// URIs are currently permitted and must describe paths relative to the
167+
directory containing the ova.xml
168+
* `type`: describes the format of the disk data
176169

177170
A single disk image encoding is specified in which has type "dir-gzipped-chunks": Each image is represented by a directory containing a sequence of files as follows:
178171

172+
```sh
179173
-rw-r--r-- 1 dscott xendev 458286013 Sep 18 09:51 chunk000000000.gz
180174
-rw-r--r-- 1 dscott xendev 422271283 Sep 18 09:52 chunk000000001.gz
181175
-rw-r--r-- 1 dscott xendev 395914244 Sep 18 09:53 chunk000000002.gz
@@ -185,69 +179,10 @@ A single disk image encoding is specified in which has type "dir-gzipped-chunks"
185179
-rw-r--r-- 1 dscott xendev 971976 Sep 18 09:53 chunk000000006.gz
186180
-rw-r--r-- 1 dscott xendev 971976 Sep 18 09:53 chunk000000007.gz
187181
-rw-r--r-- 1 dscott xendev 573930 Sep 18 09:53 chunk000000008.gz
182+
```
188183

189184
Each file (named "chunk-XXXXXXXXX.gz") is a gzipped file containing exactly 1e9 bytes (1GB, not 1GiB) of raw block data. The small size was chosen to be safely under the maximum file size limits of several filesystems. If the files are gunzipped and then concatenated together, the original image is recovered.
190185

191-
XenServer provides two mechanisms for booting a VM: (i) using a paravirtualized kernel extracted through pygrub; and (ii) using HVM. The current implementation uses the "is\_hvm" flag within the \<hacks\> section to decide which mechanism to use.
192-
193-
This rest of this section describes a very simple Debian VM packaged as an XVA. The VM has two disks, one with size 5120MiB and used for the root filesystem and used to boot the guest using pygrub and the other of size 512MiB which is used for swap. The VM has 512MiB of memory and uses one virtual CPU.
194-
195-
At the topmost level the simple Debian VM is represented by a single directory:
196-
197-
$ ls -l
198-
total 4
199-
drwxr-xr-x 3 dscott xendev 4096 Oct 24 09:42 very simple Debian VM
200-
201-
Inside the main XVA directory are two sub-directories - one per disk - and the single file: ova.xml:
202-
203-
$ ls -l very\ simple\ Debian\ VM/
204-
total 8
205-
-rw-r--r-- 1 dscott xendev 1016 Oct 24 09:42 ova.xml
206-
drwxr-xr-x 2 dscott xendev 4096 Oct 24 09:42 sda
207-
drwxr-xr-x 2 dscott xendev 4096 Oct 24 09:53 sdb
208-
209-
Inside each disk sub-directory are a set of files, each file contains 1GB of raw disk block data compressed using gzip:
210-
211-
$ ls -l very\ simple\ Debian\ VM/sda/
212-
total 2053480
213-
-rw-r--r-- 1 dscott xendev 202121645 Oct 24 09:43 chunk-000000000.gz
214-
-rw-r--r-- 1 dscott xendev 332739042 Oct 24 09:45 chunk-000000001.gz
215-
-rw-r--r-- 1 dscott xendev 401299288 Oct 24 09:48 chunk-000000002.gz
216-
-rw-r--r-- 1 dscott xendev 389585534 Oct 24 09:50 chunk-000000003.gz
217-
-rw-r--r-- 1 dscott xendev 624567877 Oct 24 09:53 chunk-000000004.gz
218-
-rw-r--r-- 1 dscott xendev 150351797 Oct 24 09:54 chunk-000000005.gz
219-
220-
$ ls -l very\ simple\ Debian\ VM/sdb
221-
total 516
222-
-rw-r--r-- 1 dscott xendev 521937 Oct 24 09:54 chunk-000000000.gz
223-
224-
The example simple Debian VM would have an XVA file like the following:
225-
226-
<?xml version="1.0" ?>
227-
<appliance version="0.1">
228-
<vm name="vm">
229-
<label>
230-
very simple Debian VM
231-
</label>
232-
<shortdesc>
233-
the description field can contain any valid UTF-8
234-
</shortdesc>
235-
<config mem_set="536870912" vcpus="1"/>
236-
<hacks is_hvm="false" kernel_boot_cmdline="root=/dev/sda1 ro ">
237-
<!--This section is temporary and will be ignored in future. Attribute
238-
is_hvm ("true" or "false") indicates whether the VM will be booted in HVM mode. In
239-
future this will be autodetected. Attribute kernel_boot_cmdline contains the kernel
240-
commandline for the case where a proper grub menu.lst is not present. In future
241-
booting shall only use pygrub.-->
242-
</hacks>
243-
<vbd device="sda" function="root" mode="w" vdi="vdi_sda"/>
244-
<vbd device="sdb" function="swap" mode="w" vdi="vdi_sdb"/>
245-
</vm>
246-
<vdi name="vdi_sda" size="5368709120" source="file://sda" type="dir-gzippedchunks"/>
247-
<vdi name="vdi_sdb" size="536870912" source="file://sdb" type="dir-gzippedchunks"/>
248-
</appliance>
249-
250-
251186
Because the import and export of VMs can take some time to complete, an
252187
asynchronous HTTP interface to the import and export operations is
253188
provided. To perform an export using the XenServer API, construct

0 commit comments

Comments
 (0)