formatstorage.html.in 20.1 KB
Newer Older
1 2 3 4
<html>
  <body>
    <h1>Storage pool and volume XML format</h1>

5
    <ul id="toc"></ul>
6

7 8 9 10 11 12 13 14 15
    <h2><a name="StoragePool">Storage pool XML</a></h2>

    <p>
      Although all storage pool backends share the same public APIs and
      XML format, they have varying levels of capabilities. Some may
      allow creation of volumes, others may only allow use of pre-existing
      volumes. Some may have constraints on volume size, or placement.
    </p>
    <p>
16
      The top level tag for a storage pool document is 'pool'. It has
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
      a single attribute <code>type</code>, which is one of <code>dir</code>,
      <code>fs</code>,<code>netfs</code>,<code>disk</code>,<code>iscsi</code>,
      <code>logical</code>. This corresponds to the storage backend drivers
      listed further along in this document.
      The storage pool XML format is available <span class="since">since 0.4.1</span>
    </p>
    <h3><a name="StoragePoolFirst">General metadata</a></h3>

    <pre>
      &lt;pool type="iscsi"&gt;
        &lt;name&gt;virtimages&lt;/name&gt;
        &lt;uuid&gt;3e3fce45-4f53-4fa7-bb32-11f34168b82b&lt;/uuid&gt;
        &lt;allocation&gt;10000000&lt;/allocation&gt;
        &lt;capacity&gt;50000000&lt;/capacity&gt;
        &lt;available&gt;40000000&lt;/available&gt;
        ...</pre>

    <dl>
      <dt><code>name</code></dt>
      <dd>Providing a name for the pool which is unique to the host.
M
Matthew Booth 已提交
37
        This is mandatory when defining a pool. <span class="since">Since 0.4.1</span></dd>
38 39
      <dt><code>uuid</code></dt>
      <dd>Providing an identifier for the pool which is globally unique.
M
Matthew Booth 已提交
40 41
        This is optional when defining a pool, a UUID will be generated if
        omitted. <span class="since">Since 0.4.1</span></dd>
42 43
      <dt><code>allocation</code></dt>
      <dd>Providing the total storage allocation for the pool. This may
M
Matthew Booth 已提交
44 45 46
        be larger than the sum of the allocation of all volumes due to
        metadata overhead. This value is in bytes. This is not applicable
        when creating a pool. <span class="since">Since 0.4.1</span></dd>
47 48
      <dt><code>capacity</code></dt>
      <dd>Providing the total storage capacity for the pool. Due to
M
Matthew Booth 已提交
49 50 51
        underlying device constraints it may not be possible to use the
        full capacity for storage volumes. This value is in bytes. This
        is not applicable when creating a pool. <span class="since">Since 0.4.1</span></dd>
52 53
      <dt><code>available</code></dt>
      <dd>Providing the free space available for allocating new volumes
M
Matthew Booth 已提交
54 55 56 57
        in the pool. Due to underlying device constraints it may not be
        possible to allocate the entire free space to a single volume.
        This value is in bytes. This is not applicable when creating a
        pool. <span class="since">Since 0.4.1</span></dd>
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    </dl>

    <h3><a name="StoragePoolSource">Source elements</a></h3>

    <p>
      A single <code>source</code> element is contained within the top level
      <code>pool</code> element. This tag is used to describe the source of
      the storage pool. It can contain the following child elements:
    </p>

    <pre>
        ...
        &lt;source&gt;
          &lt;host name="iscsi.example.com"/&gt;
          &lt;device path="demo-target"/&gt;
73
          &lt;vendor name="Acme"/&gt;
P
Philipp Hahn 已提交
74
          &lt;product name="model"/&gt;
75
        &lt;/source&gt;
M
Matthew Booth 已提交
76
        ...</pre>
77 78 79 80

    <dl>
      <dt><code>device</code></dt>
      <dd>Provides the source for pools backed by physical devices.
M
Matthew Booth 已提交
81 82 83
        May be repeated multiple times depending on backend driver. Contains
        a single attribute <code>path</code> which is the fully qualified
        path to the block device node. <span class="since">Since 0.4.1</span></dd>
84 85
      <dt><code>directory</code></dt>
      <dd>Provides the source for pools backed by directories. May
M
Matthew Booth 已提交
86
        only occur once. Contains a single attribute <code>path</code>
87
        which is the fully qualified path to the backing directory.
M
Matthew Booth 已提交
88
        <span class="since">Since 0.4.1</span></dd>
89 90 91 92 93
      <dt><code>adapter</code></dt>
      <dd>Provides the source for pools backed by SCSI adapters. May
        only occur once. Contains a single attribute <code>name</code>
        which is the SCSI adapter name (ex. "host1").
        <span class="since">Since 0.6.2</span></dd>
94 95
      <dt><code>host</code></dt>
      <dd>Provides the source for pools backed by storage from a
M
Matthew Booth 已提交
96 97 98 99 100
        remote server. Will be used in combination with a <code>directory</code>
        or <code>device</code> element. Contains an attribute <code>name</code>
        which is the hostname or IP address of the server. May optionally
        contain a <code>port</code> attribute for the protocol specific
        port number. <span class="since">Since 0.4.1</span></dd>
101 102
      <dt><code>name</code></dt>
      <dd>Provides the source for pools backed by storage from a
M
Matthew Booth 已提交
103
        named element (e.g., a logical volume group name).
104
        Contains a string identifier.
M
Matthew Booth 已提交
105
        <span class="since">Since 0.4.5</span></dd>
106 107
      <dt><code>format</code></dt>
      <dd>Provides information about the format of the pool. This
M
Matthew Booth 已提交
108 109 110 111 112
        contains a single attribute <code>type</code> whose value is
        backend specific. This is typically used to indicate filesystem
        type, or network filesystem type, or partition table type, or
        LVM metadata type. All drivers are required to have a default
        value for this, so it is optional. <span class="since">Since 0.4.1</span></dd>
113 114 115 116 117 118 119 120 121 122

      <dt><code>vendor</code></dt>
      <dd>Provides optional information about the vendor of the
        storage device. This contains a single
        attribute <code>name</code> whose value is backend
        specific. <span class="since">Since 0.8.4</span></dd>
      <dt><code>product</code></dt>
      <dd>Provides an optional product name of the storage device.
        This contains a single attribute <code>name</code> whose value
        is backend specific.  <span class="since">Since 0.8.4</span></dd>
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
    </dl>

    <h3><a name="StoragePoolTarget">Target elements</a></h3>

    <p>
      A single <code>target</code> element is contained within the top level
      <code>pool</code> element. This tag is used to describe the mapping of
      the storage pool into the host filesystem. It can contain the following
      child elements:
    </p>

    <pre>
        ...
        &lt;target&gt;
          &lt;path&gt;/dev/disk/by-path&lt;/path&gt;
          &lt;permissions&gt;
139 140
            &lt;owner&gt;107&lt;/owner&gt;
            &lt;group&gt;107&lt;/group&gt;
141 142 143
            &lt;mode&gt;0744&lt;/mode&gt;
            &lt;label&gt;virt_image_t&lt;/label&gt;
          &lt;/permissions&gt;
144 145 146 147 148
          &lt;timestamps&gt;
            &lt;atime&gt;1341933637.273190990&lt;/atime&gt;
            &lt;mtime&gt;1341930622.047245868&lt;/mtime&gt;
            &lt;ctime&gt;1341930622.047245868&lt;/ctime&gt;
          &lt;/timestamps&gt;
149 150 151
          &lt;encryption type='...'&gt;
            ...
          &lt;/encryption&gt;
152 153 154 155 156 157
        &lt;/target&gt;
      &lt;/pool&gt;</pre>

    <dl>
      <dt><code>path</code></dt>
      <dd>Provides the location at which the pool will be mapped into
M
Matthew Booth 已提交
158 159 160 161 162 163 164 165 166
        the local filesystem namespace. For a filesystem/directory based
        pool it will be the name of the directory in which volumes will
        be created. For device based pools it will be the name of the directory in which
        devices nodes exist. For the latter <code>/dev/</code> may seem
        like the logical choice, however, devices nodes there are not
        guaranteed stable across reboots, since they are allocated on
        demand. It is preferable to use a stable location such as one
        of the <code>/dev/disk/by-{path,id,uuid,label</code> locations.
        <span class="since">Since 0.4.1</span>
167 168 169
      </dd>
      <dt><code>permissions</code></dt>
      <dd>Provides information about the default permissions to use
M
Matthew Booth 已提交
170 171 172 173 174 175 176 177 178
        when creating volumes. This is currently only useful for directory
        or filesystem based pools, where the volumes allocated are simple
        files. For pools where the volumes are device nodes, the hotplug
        scripts determine permissions. It contains 4 child elements. The
        <code>mode</code> element contains the octal permission set. The
        <code>owner</code> element contains the numeric user ID. The <code>group</code>
        element contains the numeric group ID. The <code>label</code> element
        contains the MAC (eg SELinux) label string.
        <span class="since">Since 0.4.1</span>
179
      </dd>
180 181 182 183 184 185 186 187 188 189 190 191 192
      <dt><code>timestamps</code></dt>
      <dd>Provides timing information about the volume. Up to four
        sub-elements are present,
        where <code>atime</code>, <code>btime</code>, <code>ctime</code>
        and <code>mtime</code> hold the access, birth, change and
        modification time of the volume, where known. The used time
        format is &lt;seconds&gt;.&lt;nanoseconds&gt; since the
        beginning of the epoch (1 Jan 1970). If nanosecond resolution
        is 0 or otherwise unsupported by the host OS or filesystem,
        then the nanoseconds part is omitted.  This is a readonly
        attribute and is ignored when creating a volume.
        <span class="since">Since 0.10.0</span>
      </dd>
193 194 195 196 197
      <dt><code>encryption</code></dt>
      <dd>If present, specifies how the volume is encrypted.  See
        the <a href="formatstorageencryption.html">Storage Encryption</a> page
        for more information.
      </dd>
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
    </dl>

    <h3><a name="StoragePoolExtents">Device extents</a></h3>

    <p>
      If a storage pool exposes information about its underlying
      placement / allocation scheme, the <code>device</code> element
      within the <code>source</code> element may contain information
      about its available extents. Some pools have a constraint that
      a volume must be allocated entirely within a single constraint
      (eg disk partition pools). Thus the extent information allows an
      application to determine the maximum possible size for a new
      volume
    </p>
    <p>
      For storage pools supporting extent information, within each
      <code>device</code> element there will be zero or more <code>freeExtent</code>
      elements. Each of these elements contains two attributes, <code>start</code>
      and <code>end</code> which provide the boundaries of the extent on the
      device, measured in bytes.  <span class="since">Since 0.4.1</span>
    </p>

    <h2><a name="StorageVol">Storage volume XML</a></h2>
    <p>
      A storage volume will be either a file or a device node.
      The storage volume XML format is available <span class="since">since 0.4.1</span>
    </p>

    <h3><a name="StorageVolFirst">General metadata</a></h3>

    <pre>
229
      &lt;volume&gt;
M
Matthew Booth 已提交
230 231
        &lt;name&gt;sparse.img&lt;/name&gt;
        &lt;key&gt;/var/lib/xen/images/sparse.img&lt;/key&gt;
232
        &lt;allocation&gt;0&lt;/allocation&gt;
M
Matthew Booth 已提交
233
        &lt;capacity unit="T"&gt;1&lt;/capacity&gt;
234 235 236 237 238
        ...</pre>

    <dl>
      <dt><code>name</code></dt>
      <dd>Providing a name for the volume which is unique to the pool.
M
Matthew Booth 已提交
239
        This is mandatory when defining a volume.  <span class="since">Since 0.4.1</span></dd>
240 241
      <dt><code>key</code></dt>
      <dd>Providing an identifier for the volume which is globally unique.
242
          This cannot be set when creating a volume: it is always generated.
243
        <span class="since">Since 0.4.1</span></dd>
244 245
      <dt><code>allocation</code></dt>
      <dd>Providing the total storage allocation for the volume. This
M
Matthew Booth 已提交
246 247 248 249 250 251 252
        may be smaller than the logical capacity if the volume is sparsely
        allocated. It may also be larger than the logical capacity if the
        volume has substantial metadata overhead. This value is in bytes.
        If omitted when creating a volume, the volume will be fully
        allocated at time of creation. If set to a value smaller than the
        capacity, the pool has the <strong>option</strong> of deciding
        to sparsely allocate a volume. It does not have to honour requests
253 254 255 256 257
        for sparse allocation though. Different types of pools may treat
        sparse volumes differently. For example, the <code>logical</code>
        pool will not automatically expand volume's allocation when it
        gets full; the user is responsible for doing that or configuring
        dmeventd to do so automatically.<br/>
258
        <br/>
259
        By default this is specified in bytes, but an optional attribute
260
        <code>unit</code> can be specified to adjust the passed value.
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
        Values can be: 'B' or 'bytes' for bytes, 'KB' (kilobytes,
        10<sup>3</sup> or 1000 bytes), 'K' or 'KiB' (kibibytes,
        2<sup>10</sup> or 1024 bytes), 'MB' (megabytes, 10<sup>6</sup>
        or 1,000,000 bytes), 'M' or 'MiB' (mebibytes, 2<sup>20</sup>
        or 1,048,576 bytes), 'GB' (gigabytes, 10<sup>9</sup> or
        1,000,000,000 bytes), 'G' or 'GiB' (gibibytes, 2<sup>30</sup>
        or 1,073,741,824 bytes), 'TB' (terabytes, 10<sup>12</sup> or
        1,000,000,000,000 bytes), 'T' or 'TiB' (tebibytes,
        2<sup>40</sup> or 1,099,511,627,776 bytes), 'PB' (petabytes,
        10<sup>15</sup> or 1,000,000,000,000,000 bytes), 'P' or 'PiB'
        (pebibytes, 2<sup>50</sup> or 1,125,899,906,842,624 bytes),
        'EB' (exabytes, 10<sup>18</sup> or 1,000,000,000,000,000,000
        bytes), or 'E' or 'EiB' (exbibytes, 2<sup>60</sup> or
        1,152,921,504,606,846,976 bytes).  <span class="since">Since
        0.4.1, multi-character <code>unit</code> since
        0.9.11</span></dd>
277 278
      <dt><code>capacity</code></dt>
      <dd>Providing the logical capacity for the volume. This value is
279 280 281
        in bytes by default, but a <code>unit</code> attribute can be
        specified with the same semantics as for <code>allocation</code>
        This is compulsory when creating a volume.
M
Matthew Booth 已提交
282
        <span class="since">Since 0.4.1</span></dd>
283 284
      <dt><code>source</code></dt>
      <dd>Provides information about the underlying storage allocation
M
Matthew Booth 已提交
285 286
        of the volume. This may not be available for some pool types.
        <span class="since">Since 0.4.1</span></dd>
287 288
      <dt><code>target</code></dt>
      <dd>Provides information about the representation of the volume
M
Matthew Booth 已提交
289
        on the local host. <span class="since">Since 0.4.1</span></dd>
290 291 292 293 294 295 296 297 298 299 300 301 302
    </dl>

    <h3><a name="StorageVolTarget">Target elements</a></h3>

    <p>
      A single <code>target</code> element is contained within the top level
      <code>volume</code> element. This tag is used to describe the mapping of
      the storage volume into the host filesystem. It can contain the following
      child elements:
    </p>

    <pre>
        ...
M
Matthew Booth 已提交
303
        &lt;target&gt;
304
          &lt;path&gt;/var/lib/virt/images/sparse.img&lt;/path&gt;
305
          &lt;format type='qcow2'/&gt;
306
          &lt;permissions&gt;
307 308
            &lt;owner&gt;107&lt;/owner&gt;
            &lt;group&gt;107&lt;/group&gt;
309 310 311
            &lt;mode&gt;0744&lt;/mode&gt;
            &lt;label&gt;virt_image_t&lt;/label&gt;
          &lt;/permissions&gt;
M
Matthew Booth 已提交
312
        &lt;/target&gt;</pre>
313 314 315

    <dl>
      <dt><code>path</code></dt>
316
      <dd>Provides the location at which the volume can be accessed on
M
Matthew Booth 已提交
317 318 319
        the local filesystem, as an absolute path. This is a readonly
        attribute, so shouldn't be specified when creating a volume.
        <span class="since">Since 0.4.1</span></dd>
320 321
      <dt><code>format</code></dt>
      <dd>Provides information about the pool specific volume format.
M
Matthew Booth 已提交
322 323 324 325 326
        For disk pools it will provide the partition type. For filesystem
        or directory pools it will provide the file format type, eg cow,
        qcow, vmdk, raw. If omitted when creating a volume, the pool's
        default format will be used. The actual format is specified via
        the <code>type</code> attribute. Consult the pool-specific docs for
327
        the list of valid values. <span class="since">Since 0.4.1</span></dd>
328 329
      <dt><code>permissions</code></dt>
      <dd>Provides information about the default permissions to use
M
Matthew Booth 已提交
330 331 332 333 334 335 336 337 338
        when creating volumes. This is currently only useful for directory
        or filesystem based pools, where the volumes allocated are simple
        files. For pools where the volumes are device nodes, the hotplug
        scripts determine permissions. It contains 4 child elements. The
        <code>mode</code> element contains the octal permission set. The
        <code>owner</code> element contains the numeric user ID. The <code>group</code>
        element contains the numeric group ID. The <code>label</code> element
        contains the MAC (eg SELinux) label string.
        <span class="since">Since 0.4.1</span>
339 340 341
      </dd>
    </dl>

342 343 344 345 346 347 348 349 350 351 352 353 354
    <h3><a name="StorageVolBacking">Backing store elements</a></h3>

    <p>
      A single <code>backingStore</code> element is contained within the top level
      <code>volume</code> element. This tag is used to describe the optional copy
      on write, backing store for the storage volume. It can contain the following
      child elements:
    </p>

    <pre>
        ...
        &lt;backingStore&gt;
          &lt;path&gt;/var/lib/virt/images/master.img&lt;/path&gt;
355
          &lt;format type='raw'/&gt;
356
          &lt;permissions&gt;
357 358
            &lt;owner&gt;107&lt;/owner&gt;
            &lt;group&gt;107&lt;/group&gt;
359 360 361 362 363 364 365 366 367
            &lt;mode&gt;0744&lt;/mode&gt;
            &lt;label&gt;virt_image_t&lt;/label&gt;
          &lt;/permissions&gt;
        &lt;/backingStore&gt;
      &lt;/volume&gt;</pre>

    <dl>
      <dt><code>path</code></dt>
      <dd>Provides the location at which the backing store can be accessed on
M
Matthew Booth 已提交
368
        the local filesystem, as an absolute path. If omitted, there is no
369
        backing store for this volume.
M
Matthew Booth 已提交
370
        <span class="since">Since 0.6.0</span></dd>
371 372
      <dt><code>format</code></dt>
      <dd>Provides information about the pool specific backing store format.
M
Matthew Booth 已提交
373 374
        For disk pools it will provide the partition type. For filesystem
        or directory pools it will provide the file format type, eg cow,
375 376
        qcow, vmdk, raw. The actual format is specified via the type attribute.
        Consult the pool-specific docs for the list of valid
377 378 379 380 381 382
        values. Most file formats require a backing store of the same format,
        however, the qcow2 format allows a different backing store format.
        <span class="since">Since 0.6.0</span></dd>
      <dt><code>permissions</code></dt>
      <dd>Provides information about the permissions of the backing file.
        It contains 4 child elements. The
M
Matthew Booth 已提交
383 384 385 386 387
        <code>mode</code> element contains the octal permission set. The
        <code>owner</code> element contains the numeric user ID. The <code>group</code>
        element contains the numeric group ID. The <code>label</code> element
        contains the MAC (eg SELinux) label string.
        <span class="since">Since 0.6.0</span>
388 389 390
      </dd>
    </dl>

391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
    <h2><a name="examples">Example configuration</a></h2>

    <p>
      Here are a couple of examples, for a more complete set demonstrating
      every type of storage pool, consult the <a href="storage.html">storage driver page</a>
    </p>

    <h3><a name="exampleFile">File based storage pool</a></h3>

    <pre>
      &lt;pool type="dir"&gt;
        &lt;name&gt;virtimages&lt;/name&gt;
        &lt;target&gt;
          &lt;path&gt;/var/lib/virt/images&lt;/path&gt;
        &lt;/target&gt;
      &lt;/pool&gt;</pre>

    <h3><a name="exampleISCSI">iSCSI based storage pool</a></h3>

    <pre>
      &lt;pool type="iscsi"&gt;
        &lt;name&gt;virtimages&lt;/name&gt;
        &lt;source&gt;
          &lt;host name="iscsi.example.com"/&gt;
          &lt;device path="demo-target"/&gt;
        &lt;/source&gt;
        &lt;target&gt;
          &lt;path&gt;/dev/disk/by-path&lt;/path&gt;
        &lt;/target&gt;
      &lt;/pool&gt;</pre>

    <h3><a name="exampleVol">Storage volume</a></h3>

    <pre>
425
      &lt;volume&gt;
M
Matthew Booth 已提交
426 427 428 429
        &lt;name&gt;sparse.img&lt;/name&gt;
        &lt;allocation&gt;0&lt;/allocation&gt;
        &lt;capacity unit="T"&gt;1&lt;/capacity&gt;
        &lt;target&gt;
430 431
          &lt;path&gt;/var/lib/virt/images/sparse.img&lt;/path&gt;
          &lt;permissions&gt;
432 433
            &lt;owner&gt;107&lt;/owner&gt;
            &lt;group&gt;107&lt;/group&gt;
434 435 436
            &lt;mode&gt;0744&lt;/mode&gt;
            &lt;label&gt;virt_image_t&lt;/label&gt;
          &lt;/permissions&gt;
M
Matthew Booth 已提交
437
        &lt;/target&gt;
438
      &lt;/volume&gt;</pre>
439 440
  </body>
</html>