mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-31 18:15:25 +00:00
Support startupPolicy for 'volume' disk
"startupPolicy" is only valid for file type storage volume, otherwise it fails on starting the domain.
This commit is contained in:
parent
db94a1d3a0
commit
43404fee37
@ -1467,11 +1467,12 @@
|
||||
0.7.5; <code>type='network'</code> since
|
||||
0.8.7; <code>protocol='iscsi'</code> since 1.0.4;
|
||||
<code>type='volume'</code> since 1.0.5;</span><br/>
|
||||
For a "file" disk type which represents a cdrom or floppy
|
||||
For a "file" or "volume" disk type which represents a cdrom or floppy
|
||||
(the <code>device</code> attribute), it is possible to define
|
||||
policy what to do with the disk if the source file is not accessible.
|
||||
This is done by the <code>startupPolicy</code> attribute, accepting
|
||||
these values:
|
||||
(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:
|
||||
<table class="top_table">
|
||||
<tr>
|
||||
<td> mandatory </td>
|
||||
|
@ -1120,6 +1120,9 @@
|
||||
<attribute name="volume">
|
||||
<ref name="volName"/>
|
||||
</attribute>
|
||||
<optional>
|
||||
<ref name="startupPolicy"/>
|
||||
</optional>
|
||||
</element>
|
||||
</optional>
|
||||
<ref name="diskspec"/>
|
||||
|
@ -4402,6 +4402,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
|
||||
case VIR_DOMAIN_DISK_TYPE_VOLUME:
|
||||
if (virDomainDiskSourcePoolDefParse(cur, def) < 0)
|
||||
goto error;
|
||||
startupPolicy = virXMLPropString(cur, "startupPolicy");
|
||||
break;
|
||||
default:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -13022,9 +13023,13 @@ virDomainDiskSourceDefFormat(virBufferPtr buf,
|
||||
/* Parsing guarantees the def->srcpool->volume cannot be NULL
|
||||
* if def->srcpool->pool is not NULL.
|
||||
*/
|
||||
if (def->srcpool->pool)
|
||||
virBufferAsprintf(buf, " <source pool='%s' volume='%s'/>\n",
|
||||
if (def->srcpool)
|
||||
virBufferAsprintf(buf, " <source pool='%s' volume='%s'",
|
||||
def->srcpool->pool, def->srcpool->volume);
|
||||
if (def->startupPolicy)
|
||||
virBufferEscapeString(buf, " startupPolicy='%s'/>\n", startupPolicy);
|
||||
else
|
||||
virBufferAddLit(buf, "/>\n");
|
||||
break;
|
||||
default:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
|
@ -2703,6 +2703,13 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
|
||||
if (virStorageVolGetInfo(vol, &info) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (def->startupPolicy &&
|
||||
info.type != VIR_STORAGE_VOL_FILE) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("'startupPolicy' is only valid for 'file' type volume"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
switch (info.type) {
|
||||
case VIR_STORAGE_VOL_FILE:
|
||||
case VIR_STORAGE_VOL_BLOCK:
|
||||
|
@ -15,7 +15,7 @@
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='volume' device='cdrom'>
|
||||
<source pool='blk-pool0' volume='blk-pool0-vol0'/>
|
||||
<source pool='blk-pool0' volume='blk-pool0-vol0' startupPolicy='optional'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<readonly/>
|
||||
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
|
||||
|
Loading…
Reference in New Issue
Block a user