<devices>
<disk type='file' snapshot='external'>
<driver name="tap" type="aio" cache="default"/>
- <source file='/var/lib/xen/images/fv0'/>
+ <source file='/var/lib/xen/images/fv0'/ startupPolicy='optional'>
<target dev='hda' bus='ide'/>
<boot order='2'/>
<encryption type='...'>
"network", the <code>source</code> may have zero or
more <code>host</code> sub-elements used to specify the hosts
to connect.
- <span class="since">Since 0.0.3</span></dd>
+ <span class="since">Since 0.0.3</span>
+ For "file" disk type which represents cdrom or floppy
+ (the <code>device</code> attribute) it is possible to define
+ policy what to do with disk if source is not accessible.
+ This is done by <code>startupPolicy</code> attribute accepting
+ these values:
+ <table class="top_table">
+ <tr>
+ <td> mandatory </td>
+ <td> fail if missing for any reason (the default) </td>
+ </tr>
+ <tr>
+ <td> requisite </td>
+ <td> fail if missing on boot up,
+ drop if missing on migrate/restore/revert </td>
+ </tr>
+ <tr>
+ <td> optional </td>
+ <td> drop if missing at any start attempt </td>
+ </tr>
+ </table>
+ <span class="since">Since 0.9.7</span>
+ </dd>
<dt><code>target</code></dt>
<dd>The <code>target</code> element controls the bus / device
under which the disk is exposed to the guest
</interleave>
</element>
</define>
+
+ <define name="startupPolicy">
+ <attribute name="startupPolicy">
+ <choice>
+ <value>mandatory</value>
+ <value>requisite</value>
+ <value>optional</value>
+ </choice>
+ </attribute>
+ </define>
+
<!--
A disk description can be either of type file or block
The name of the attribute on the source element depends on the type
<interleave>
<optional>
<element name="source">
- <attribute name="file">
- <ref name="absFilePath"/>
- </attribute>
+ <optional>
+ <attribute name="file">
+ <ref name="absFilePath"/>
+ </attribute>
+ </optional>
+ <optional>
+ <ref name="startupPolicy"/>
+ </optional>
<empty/>
</element>
</optional>
"preferred",
"interleave");
+VIR_ENUM_IMPL(virDomainStartupPolicy, VIR_DOMAIN_STARTUP_POLICY_LAST,
+ "default",
+ "mandatory",
+ "requisite",
+ "optional");
+
#define virDomainReportError(code, ...) \
virReportErrorHelper(VIR_FROM_DOMAIN, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
char *devaddr = NULL;
virStorageEncryptionPtr encryption = NULL;
char *serial = NULL;
+ char *startupPolicy = NULL;
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
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");
goto error;
}
+ if (startupPolicy) {
+ int i;
+
+ if ((i = virDomainStartupPolicyTypeFromString(startupPolicy)) < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown startupPolicy value '%s'"),
+ startupPolicy);
+ goto error;
+ }
+
+ if (def->device != VIR_DOMAIN_DISK_DEVICE_CDROM &&
+ def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
+ virDomainReportError(VIR_ERR_INVALID_ARG,
+ _("Setting disk %s is allowed only for "
+ "cdrom or floppy"),
+ startupPolicy);
+ goto error;
+ }
+ def->startupPolicy = i;
+ }
+
def->src = source;
source = NULL;
def->dst = target;
VIR_FREE(devaddr);
VIR_FREE(serial);
virStorageEncryptionFree(encryption);
+ VIR_FREE(startupPolicy);
return def;
const char *iomode = virDomainDiskIoTypeToString(def->iomode);
const char *ioeventfd = virDomainIoEventFdTypeToString(def->ioeventfd);
const char *event_idx = virDomainVirtioEventIdxTypeToString(def->event_idx);
+ const char *startupPolicy = virDomainStartupPolicyTypeToString(def->startupPolicy);
if (!type) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
virBufferAsprintf(buf, "/>\n");
}
- if (def->src || def->nhosts > 0) {
+ if (def->src || def->nhosts > 0 ||
+ def->startupPolicy) {
switch (def->type) {
case VIR_DOMAIN_DISK_TYPE_FILE:
- virBufferEscapeString(buf, " <source file='%s'/>\n",
- def->src);
+ virBufferAsprintf(buf," <source");
+ if (def->src)
+ virBufferEscapeString(buf, " file='%s'", def->src);
+ if (def->startupPolicy)
+ virBufferEscapeString(buf, " startupPolicy='%s'",
+ startupPolicy);
+ virBufferAsprintf(buf, "/>\n");
break;
case VIR_DOMAIN_DISK_TYPE_BLOCK:
virBufferEscapeString(buf, " <source dev='%s'/>\n",
VIR_DOMAIN_DISK_SNAPSHOT = VIR_DOMAIN_LAST,
};
+enum virDomainStartupPolicy {
+ VIR_DOMAIN_STARTUP_POLICY_DEFAULT = 0,
+ VIR_DOMAIN_STARTUP_POLICY_MANDATORY,
+ VIR_DOMAIN_STARTUP_POLICY_REQUISITE,
+ VIR_DOMAIN_STARTUP_POLICY_OPTIONAL,
+
+ VIR_DOMAIN_STARTUP_POLICY_LAST
+};
+
/* Stores the virtual disk configuration */
typedef struct _virDomainDiskDef virDomainDiskDef;
typedef virDomainDiskDef *virDomainDiskDefPtr;
int ioeventfd;
int event_idx;
int snapshot; /* enum virDomainDiskSnapshot */
+ int startupPolicy; /* enum virDomainStartupPolicy */
unsigned int readonly : 1;
unsigned int shared : 1;
unsigned int transient : 1;
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)
+VIR_ENUM_DECL(virDomainStartupPolicy)
#endif /* __DOMAIN_CONF_H */
virDomainSoundDefFree;
virDomainSoundModelTypeFromString;
virDomainSoundModelTypeToString;
+virDomainStartupPolicyTypeFromString;
+virDomainStartupPolicyTypeToString;
virDomainStateReasonFromString;
virDomainStateReasonToString;
virDomainStateTypeFromString;
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <target dev='hdc' bus='ide'/>
+ <source startupPolicy='optional'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>