1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

conf: add startupPolicy attribute for harddisk

Add startupPolicy attribute for harddisk with type "file",
"block" and "dir". 'requisite' is not supported currently for
harddisk.
This commit is contained in:
Guannan Ren 2013-07-31 15:51:44 +08:00
parent 06844ccbaa
commit 93319da42c
3 changed files with 35 additions and 10 deletions

View File

@ -1620,7 +1620,8 @@
policy what to do with the disk if the source file is not accessible. 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 (NB, <code>startupPolicy</code> is not valid for "volume" disk unless
the specified storage volume is of "file" type). This is done by the 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"> <table class="top_table">
<tr> <tr>
<td> mandatory </td> <td> mandatory </td>
@ -1636,7 +1637,10 @@
<td> drop if missing at any start attempt </td> <td> drop if missing at any start attempt </td>
</tr> </tr>
</table> </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> </dd>
<dt><code>mirror</code></dt> <dt><code>mirror</code></dt>
<dd> <dd>

View File

@ -1123,6 +1123,9 @@
<attribute name="dev"> <attribute name="dev">
<ref name="absFilePath"/> <ref name="absFilePath"/>
</attribute> </attribute>
<optional>
<ref name="startupPolicy"/>
</optional>
<optional> <optional>
<ref name='devSeclabel'/> <ref name='devSeclabel'/>
</optional> </optional>
@ -1141,6 +1144,9 @@
<attribute name="dir"> <attribute name="dir">
<ref name="absFilePath"/> <ref name="absFilePath"/>
</attribute> </attribute>
<optional>
<ref name="startupPolicy"/>
</optional>
<empty/> <empty/>
</element> </element>
</optional> </optional>

View File

@ -4796,7 +4796,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
switch (def->type) { switch (def->type) {
case VIR_DOMAIN_DISK_TYPE_FILE: case VIR_DOMAIN_DISK_TYPE_FILE:
source = virXMLPropString(cur, "file"); source = virXMLPropString(cur, "file");
startupPolicy = virXMLPropString(cur, "startupPolicy");
break; break;
case VIR_DOMAIN_DISK_TYPE_BLOCK: case VIR_DOMAIN_DISK_TYPE_BLOCK:
source = virXMLPropString(cur, "dev"); source = virXMLPropString(cur, "dev");
@ -4883,7 +4882,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
case VIR_DOMAIN_DISK_TYPE_VOLUME: case VIR_DOMAIN_DISK_TYPE_VOLUME:
if (virDomainDiskSourcePoolDefParse(cur, def) < 0) if (virDomainDiskSourcePoolDefParse(cur, def) < 0)
goto error; goto error;
startupPolicy = virXMLPropString(cur, "startupPolicy");
break; break;
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -4892,6 +4890,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error; goto error;
} }
startupPolicy = virXMLPropString(cur, "startupPolicy");
/* People sometimes pass a bogus '' source path /* People sometimes pass a bogus '' source path
when they mean to omit the source element when they mean to omit the source element
completely (e.g. CDROM without media). This is completely (e.g. CDROM without media). This is
@ -5464,14 +5464,22 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error; goto error;
} }
if (def->device != VIR_DOMAIN_DISK_DEVICE_CDROM && if (def->type == VIR_DOMAIN_DISK_TYPE_NETWORK) {
def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) { virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_INVALID_ARG, _("Setting disk %s is not allowed for "
_("Setting disk %s is allowed only for " "disk of network type"),
"cdrom or floppy"),
startupPolicy); startupPolicy);
goto error; 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; def->startupPolicy = val;
} }
@ -14121,6 +14129,9 @@ virDomainDiskSourceDefFormat(virBufferPtr buf,
case VIR_DOMAIN_DISK_TYPE_BLOCK: case VIR_DOMAIN_DISK_TYPE_BLOCK:
virBufferEscapeString(buf, " <source dev='%s'", virBufferEscapeString(buf, " <source dev='%s'",
def->src); def->src);
if (def->startupPolicy)
virBufferEscapeString(buf, " startupPolicy='%s'",
startupPolicy);
if (def->nseclabels) { if (def->nseclabels) {
virBufferAddLit(buf, ">\n"); virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 8); virBufferAdjustIndent(buf, 8);
@ -14133,8 +14144,12 @@ virDomainDiskSourceDefFormat(virBufferPtr buf,
} }
break; break;
case VIR_DOMAIN_DISK_TYPE_DIR: case VIR_DOMAIN_DISK_TYPE_DIR:
virBufferEscapeString(buf, " <source dir='%s'/>\n", virBufferEscapeString(buf, " <source dir='%s'",
def->src); def->src);
if (def->startupPolicy)
virBufferEscapeString(buf, " startupPolicy='%s'",
startupPolicy);
virBufferAddLit(buf, "/>\n");
break; break;
case VIR_DOMAIN_DISK_TYPE_NETWORK: case VIR_DOMAIN_DISK_TYPE_NETWORK:
virBufferAsprintf(buf, " <source protocol='%s'", virBufferAsprintf(buf, " <source protocol='%s'",