formatsecret.html.in 10.2 KB
Newer Older
1 2 3
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
M
Miloslav Trmač 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
  <body>
    <h1>Secret XML format</h1>

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

    <h2><a name="SecretAttributes">Secret XML</a></h2>

    <p>
      Secrets stored by libvirt may have attributes associated with them, using
      the <code>secret</code> element.  The <code>secret</code> element has two
      optional attributes, each with values '<code>yes</code>' and
      '<code>no</code>', and defaulting to '<code>no</code>':
    </p>
    <dl>
      <dt><code>ephemeral</code></dt>
      <dd>This secret must only be kept in memory, never stored persistently.
      </dd>
      <dt><code>private</code></dt>
      <dd>The value of the secret must not be revealed to any caller of libvirt,
        nor to any other node.
      </dd>
    </dl>
    <p>
      The top-level <code>secret</code> element may contain the following
      elements:
    </p>
    <dl>
      <dt><code>uuid</code></dt>
      <dd>
        An unique identifier for this secret (not necessarily in the UUID
        format).  If omitted when defining a new secret, a random UUID is
        generated.
      </dd>
      <dt><code>description</code></dt>
      <dd>A human-readable description of the purpose of the secret.
      </dd>
M
Miloslav Trmač 已提交
40 41
      <dt><code>usage</code></dt>
      <dd>
M
Matthew Booth 已提交
42 43
        Specifies what this secret is used for.  A mandatory
        <code>type</code> attribute specifies the usage category, currently
44 45
        only <code>volume</code>, <code>ceph</code>, and <code>iscsi</code>
        are defined. Specific usage categories are described below.
M
Miloslav Trmač 已提交
46
      </dd>
M
Miloslav Trmač 已提交
47 48
    </dl>

49
    <h3><a name="VolumeUsageType">Usage type "volume"</a></h3>
M
Miloslav Trmač 已提交
50 51

    <p>
52 53 54 55 56 57
      This secret is associated with a volume, whether the format is either
      for a "qcow" or a "luks" encrypted volume. Each volume will have a
      unique secret associated with it and it is safe to delete the
      secret after the volume is deleted. The
      <code>&lt;usage type='volume'&gt;</code> element must contain a
      single <code>volume</code> element that specifies the path of the volume
58 59
      this secret is associated with. For example, create a volume-secret.xml
      file as follows:
M
Miloslav Trmač 已提交
60 61
    </p>

62 63 64 65 66 67 68 69 70 71 72
    <pre>
      &lt;secret ephemeral='no' private='yes'&gt;
         &lt;description&gt;Super secret name of my first puppy&lt;/description&gt;
         &lt;uuid&gt;0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f&lt;/uuid&gt;
         &lt;usage type='volume'&gt;
            &lt;volume&gt;/var/lib/libvirt/images/puppyname.img&lt;/volume&gt;
         &lt;/usage&gt;
      &lt;/secret&gt;
    </pre>

    <p>
73
      Define the secret and set the passphrase as follows:
74 75 76 77 78 79 80 81 82 83 84 85
    </p>
    <pre>
      # virsh secret-define volume-secret.xml
      Secret 0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f created
      #
      # MYSECRET=`printf %s "open sesame" | base64`
      # virsh secret-set-value 0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f $MYSECRET
      Secret value set
      #
    </pre>

    <p>
86 87
      The volume type secret can be supplied in domain XML for a qcow storage
      volume <a href="formatstorageencryption.html">encryption</a> as follows:
88 89 90 91 92 93
    </p>
    <pre>
      &lt;encryption format='qcow'&gt;
        &lt;secret type='passphrase' uuid='0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f'/&gt;
      &lt;/encryption&gt;
    </pre>
S
Sage Weil 已提交
94

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    <p>
      The volume type secret can be supplied either in volume XML during
      creation of a <a href="formatstorage.html#StorageVol">storage volume</a>
      in order to provide the passphrase to encrypt the volume or in
      domain XML <a href="formatdomain.html#elementsDisks">disk device</a>
      in order to provide the passphrase to decrypt the volume,
      <span class="since">since 2.1.0</span>. An example follows:
    </p>
    <pre>
      # cat luks-secret.xml
      &lt;secret ephemeral='no' private='yes'&gt;
         &lt;description&gt;LUKS Sample Secret&lt;/description&gt;
         &lt;uuid&gt;f52a81b2-424e-490c-823d-6bd4235bc57&lt;/uuid&gt;
         &lt;usage type='volume'&gt;
            &lt;volume&gt;/var/lib/libvirt/images/luks-sample.img&lt;/volume&gt;
         &lt;/usage&gt;
      &lt;/secret&gt;

      # virsh secret-define luks-secret.xml
      Secret f52a81b2-424e-490c-823d-6bd4235bc57 created
      #
      # MYSECRET=`printf %s "letmein" | base64`
      # virsh secret-set-value f52a81b2-424e-490c-823d-6bd4235bc57 $MYSECRET
      Secret value set
      #
    </pre>

122
    <h3><a name="CephUsageType">Usage type "ceph"</a></h3>
S
Sage Weil 已提交
123 124 125 126 127 128
    <p>
      This secret is associated with a Ceph RBD (rados block device).
      The <code>&lt;usage type='ceph'&gt;</code> element must contain
      a single <code>name</code> element that specifies a usage name
      for the secret.  The Ceph secret can then be used by UUID or by
      this usage name via the <code>&lt;auth&gt;</code> element of
129 130
      a <a href="formatdomain.html#elementsDisks">disk device</a> or
      a <a href="formatstorage.html">storage pool (rbd)</a>.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
      <span class="since">Since 0.9.7</span>. The following is an example
      of the steps to be taken.  First create a ceph-secret.xml file:
    </p>

    <pre>
      &lt;secret ephemeral='no' private='yes'&gt;
         &lt;description&gt;CEPH passphrase example&lt;/description&gt;
         &lt;usage type='ceph'&gt;
            &lt;name&gt;ceph_example&lt;/name&gt;
         &lt;/usage&gt;
      &lt;/secret&gt;
    </pre>

    <p>
      Next, use <code>virsh secret-define ceph-secret.xml</code> to define
      the secret and <code>virsh secret-set-value</code> using the generated
      UUID value and a base64 generated secret value in order to define the
      chosen secret pass phrase.
    </p>
    <pre>
      # virsh secret-define ceph-secret.xml
      Secret 1b40a534-8301-45d5-b1aa-11894ebb1735 created
      #
      # virsh secret-list
J
John Ferlan 已提交
155
       UUID                                 Usage
156
      -----------------------------------------------------------
J
John Ferlan 已提交
157
       1b40a534-8301-45d5-b1aa-11894ebb1735 cephx ceph_example
158 159 160 161 162 163 164 165 166 167 168 169 170
      #
      # CEPHPHRASE=`printf %s "pass phrase" | base64`
      # virsh secret-set-value 1b40a534-8301-45d5-b1aa-11894ebb1735 $CEPHPHRASE
      Secret value set

      #
    </pre>

    <p>
      The ceph secret can then be used by UUID or by the
      usage name via the <code>&lt;auth&gt;</code> element in a domain's
      <a href="formatdomain.html#elementsDisks"><code>&lt;disk&gt;</code></a>
      element as follows:
S
Sage Weil 已提交
171
    </p>
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
    <pre>
      &lt;auth username='myname'&gt;
        &lt;secret type='ceph' usage='ceph_example'/&gt;
      &lt;/auth&gt;
    </pre>

    <p>
      As well as the <code>&lt;auth&gt;</code> element in a
      <a href="formatstorage.html">storage pool (rbd)</a>
      <code>&lt;source&gt;</code> element as follows:
    </p>
    <pre>
      &lt;auth type='ceph' username='myname'&gt;
        &lt;secret usage='ceph_example'/&gt;
      &lt;/auth&gt;
    </pre>
S
Sage Weil 已提交
188

189
    <h3><a name="iSCSIUsageType">Usage type "iscsi"</a></h3>
190 191 192 193 194

    <p>
      This secret is associated with an iSCSI target for CHAP authentication.
      The <code>&lt;usage type='iscsi'&gt;</code> element must contain
      a single <code>target</code> element that specifies a usage name
195
      for the secret. The iSCSI secret can then be used by UUID or by
196
      this usage name via the <code>&lt;auth&gt;</code> element of
197 198
      a <a href="formatdomain.html#elementsDisks">disk device</a> or
      a <a href="formatstorage.html">storage pool (iscsi)</a>.
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
      <span class="since">Since 1.0.4</span>. The following is an example
      of the XML that may be used to generate a secret for iSCSI CHAP
      authentication. Assume the following sample entry in an iSCSI
      authentication file:
    </p>
      <pre>
      &lt;target iqn.2013-07.com.example:iscsi-pool&gt;
      backing-store /home/tgtd/iscsi-pool/disk1
      backing-store /home/tgtd/iscsi-pool/disk2
      incominguser myname mysecret
      &lt;/target&gt;
      </pre>
    <p>
      Define an iscsi-secret.xml file to describe the secret. Use the
      <code>incominguser</code> username used in your iSCSI authentication
      configuration file as the value for the <code>username</code> attribute.
      The <code>description</code> attribute should contain configuration
      specific data. The <code>target</code> name may be any name of your
      choosing to be used as the <code>usage</code> when used in the pool
      or disk XML description.
219
    </p>
M
Miloslav Trmač 已提交
220 221
    <pre>
      &lt;secret ephemeral='no' private='yes'&gt;
222 223 224
         &lt;description&gt;Passphrase for the iSCSI example.com server&lt;/description&gt;
         &lt;usage type='iscsi'&gt;
            &lt;target&gt;libvirtiscsi&lt;/target&gt;
M
Miloslav Trmač 已提交
225
         &lt;/usage&gt;
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
      &lt;/secret&gt;
    </pre>

    <p>
      Next, use <code>virsh secret-define iscsi-secret.xml</code> to define
      the secret and <code>virsh secret-set-value</code> using the generated
      UUID value and a base64 generated secret value in order to define the
      chosen secret pass phrase.  The pass phrase must match the password
      used in the iSCSI authentication configuration file.
    </p>
    <pre>
      # virsh secret-define secret.xml
      Secret c4dbe20b-b1a3-4ac1-b6e6-2ac97852ebb6 created

      # virsh secret-list
J
John Ferlan 已提交
241
       UUID                                 Usage
242
      -----------------------------------------------------------
J
John Ferlan 已提交
243
       c4dbe20b-b1a3-4ac1-b6e6-2ac97852ebb6 iscsi libvirtiscsi
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272

      # MYSECRET=`printf %s "mysecret" | base64`
      # virsh secret-set-value c4dbe20b-b1a3-4ac1-b6e6-2ac97852ebb6 $MYSECRET
      Secret value set
      #
    </pre>

    <p>
      The iSCSI secret can then be used by UUID or by the
      usage name via the <code>&lt;auth&gt;</code> element in a domain's
      <a href="formatdomain.html#elementsDisks"><code>&lt;disk&gt;</code></a>
      element as follows:
    </p>
    <pre>
      &lt;auth username='myname'&gt;
        &lt;secret type='iscsi' usage='libvirtiscsi'/&gt;
      &lt;/auth&gt;
    </pre>

    <p>
      As well as the <code>&lt;auth&gt;</code> element in a
      <a href="formatstorage.html">storage pool (iscsi)</a>
      <code>&lt;source&gt;</code> element as follows:
    </p>
    <pre>
      &lt;auth type='chap' username='myname'&gt;
        &lt;secret usage='libvirtiscsi'/&gt;
      &lt;/auth&gt;
    </pre>
273

M
Miloslav Trmač 已提交
274 275
  </body>
</html>