policy what to do with the disk if the source file is not accessible.
(NB, <code>startupPolicy</code> is not valid for "volume" disk unless
the specified storage volume is of "file" type). This is done by the
- <code>startupPolicy</code> attribute, accepting these values:
+ <code>startupPolicy</code> attribute (<span class="since">Since 0.9.7</span>),
+ accepting these values:
<table class="top_table">
<tr>
<td> mandatory </td>
<td> drop if missing at any start attempt </td>
</tr>
</table>
- <span class="since">Since 0.9.7</span>
+ <span class="since">Since 1.1.2</span> the <code>startupPolicy</code> is extended
+ to support hard disks besides cdrom and floppy. On guest cold bootup, if a certain disk
+ is not accessible or its disk chain is broken, with startupPolicy 'optional' the guest
+ will drop this disk. This feature doesn't support migration currently.
</dd>
<dt><code>mirror</code></dt>
<dd>
switch (def->type) {
case VIR_DOMAIN_DISK_TYPE_FILE:
source = virXMLPropString(cur, "file");
- startupPolicy = virXMLPropString(cur, "startupPolicy");
break;
case VIR_DOMAIN_DISK_TYPE_BLOCK:
source = virXMLPropString(cur, "dev");
case VIR_DOMAIN_DISK_TYPE_VOLUME:
if (virDomainDiskSourcePoolDefParse(cur, def) < 0)
goto error;
- startupPolicy = virXMLPropString(cur, "startupPolicy");
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
goto error;
}
+ startupPolicy = virXMLPropString(cur, "startupPolicy");
+
/* People sometimes pass a bogus '' source path
when they mean to omit the source element
completely (e.g. CDROM without media). This is
goto error;
}
- if (def->device != VIR_DOMAIN_DISK_DEVICE_CDROM &&
- def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
- virReportError(VIR_ERR_INVALID_ARG,
- _("Setting disk %s is allowed only for "
- "cdrom or floppy"),
+ if (def->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Setting disk %s is not allowed for "
+ "disk of network type"),
startupPolicy);
goto error;
}
+
+ if (def->device != VIR_DOMAIN_DISK_DEVICE_CDROM &&
+ def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
+ val == VIR_DOMAIN_STARTUP_POLICY_REQUISITE) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("Setting disk 'requisite' is allowed only for "
+ "cdrom or floppy"));
+ goto error;
+ }
def->startupPolicy = val;
}
case VIR_DOMAIN_DISK_TYPE_BLOCK:
virBufferEscapeString(buf, " <source dev='%s'",
def->src);
+ if (def->startupPolicy)
+ virBufferEscapeString(buf, " startupPolicy='%s'",
+ startupPolicy);
if (def->nseclabels) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 8);
}
break;
case VIR_DOMAIN_DISK_TYPE_DIR:
- virBufferEscapeString(buf, " <source dir='%s'/>\n",
+ virBufferEscapeString(buf, " <source dir='%s'",
def->src);
+ if (def->startupPolicy)
+ virBufferEscapeString(buf, " startupPolicy='%s'",
+ startupPolicy);
+ virBufferAddLit(buf, "/>\n");
break;
case VIR_DOMAIN_DISK_TYPE_NETWORK:
virBufferAsprintf(buf, " <source protocol='%s'",