HV_INIT_SCRIPT = "init_script"
HV_MIGRATION_PORT = "migration_port"
HV_USE_LOCALTIME = "use_localtime"
+HV_DISK_CACHE = "disk_cache"
HVS_PARAMETER_TYPES = {
HV_BOOT_ORDER: VTYPE_STRING,
HV_INIT_SCRIPT: VTYPE_STRING,
HV_MIGRATION_PORT: VTYPE_INT,
HV_USE_LOCALTIME: VTYPE_BOOL,
+ HV_DISK_CACHE: VTYPE_STRING,
}
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
HT_DISK_MTD = "mtd"
HT_DISK_PFLASH = "pflash"
+HT_CACHE_DEFAULT = "default"
+HT_CACHE_NONE = "none"
+HT_CACHE_WTHROUGH = "writethrough"
+HT_CACHE_WBACK = "writeback"
+HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT,
+ HT_CACHE_NONE,
+ HT_CACHE_WTHROUGH,
+ HT_CACHE_WBACK])
+
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
HV_USB_MOUSE: '',
HV_MIGRATION_PORT: 8102,
HV_USE_LOCALTIME: False,
+ HV_DISK_CACHE: HT_CACHE_DEFAULT,
},
HT_FAKE: {
},
hv_base.ParamInSet(False, constants.HT_KVM_VALID_MOUSE_TYPES),
constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK,
constants.HV_USE_LOCALTIME: hv_base.NO_CHECK,
+ constants.HV_DISK_CACHE:
+ hv_base.ParamInSet(True, constants.HT_VALID_CACHE_TYPES),
}
_MIGRATION_STATUS_RE = re.compile('Migration\s+status:\s+(\w+)',
if_val = ',if=virtio'
else:
if_val = ',if=%s' % disk_type
+ # Cache mode
+ disk_cache = hvp[constants.HV_DISK_CACHE]
+ if disk_cache != constants.HT_CACHE_DEFAULT:
+ cache_val = ",cache=%s" % disk_cache
+ else:
+ cache_val = ""
for cfdev, dev_path in block_devices:
if cfdev.mode != constants.DISK_RDWR:
raise errors.HypervisorError("Instance has read-only disks which"
else:
boot_val = ''
- drive_val = 'file=%s,format=raw%s%s' % (dev_path, if_val, boot_val)
+ drive_val = 'file=%s,format=raw%s%s%s' % (dev_path, if_val, boot_val,
+ cache_val)
kvm_cmd.extend(['-drive', drive_val])
iso_image = hvp[constants.HV_CDROM_IMAGE_PATH]
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>disk_cache</term>
+ <listitem>
+ <simpara>Valid for the KVM hypervisor.</simpara>
+
+ <simpara>The disk cache mode. It can be either
+ <userinput>default</userinput> to not pass any cache
+ option to KVM, or one of the KVM cache modes: none
+ (for direct I/O), writethrough (to use the host cache
+ but report completion to the guest only when the host
+ has commited the changes to disk) or writeback (to use
+ the host cache and report completion as soon as the
+ data is in the host cache). Note that there are
+ special considerations for the cache mode depending on
+ version of KVM used and disk type (always raw file
+ under Ganeti), please refer to the KVM documentation
+ for more details.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</para>