Revision ea0f3d7a

b/lib/constants.py
391 391
HV_INIT_SCRIPT = "init_script"
392 392
HV_MIGRATION_PORT = "migration_port"
393 393
HV_USE_LOCALTIME = "use_localtime"
394
HV_DISK_CACHE = "disk_cache"
394 395

  
395 396
HVS_PARAMETER_TYPES = {
396 397
  HV_BOOT_ORDER: VTYPE_STRING,
......
417 418
  HV_INIT_SCRIPT: VTYPE_STRING,
418 419
  HV_MIGRATION_PORT: VTYPE_INT,
419 420
  HV_USE_LOCALTIME: VTYPE_BOOL,
421
  HV_DISK_CACHE: VTYPE_STRING,
420 422
  }
421 423

  
422 424
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
......
491 493
HT_DISK_MTD = "mtd"
492 494
HT_DISK_PFLASH = "pflash"
493 495

  
496
HT_CACHE_DEFAULT = "default"
497
HT_CACHE_NONE = "none"
498
HT_CACHE_WTHROUGH = "writethrough"
499
HT_CACHE_WBACK = "writeback"
500
HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT,
501
                                  HT_CACHE_NONE,
502
                                  HT_CACHE_WTHROUGH,
503
                                  HT_CACHE_WBACK])
504

  
494 505
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
495 506
HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
496 507
                                     HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
......
645 656
    HV_USB_MOUSE: '',
646 657
    HV_MIGRATION_PORT: 8102,
647 658
    HV_USE_LOCALTIME: False,
659
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
648 660
    },
649 661
  HT_FAKE: {
650 662
    },
b/lib/hypervisor/hv_kvm.py
74 74
      hv_base.ParamInSet(False, constants.HT_KVM_VALID_MOUSE_TYPES),
75 75
    constants.HV_MIGRATION_PORT: hv_base.NET_PORT_CHECK,
76 76
    constants.HV_USE_LOCALTIME: hv_base.NO_CHECK,
77
    constants.HV_DISK_CACHE:
78
      hv_base.ParamInSet(True, constants.HT_VALID_CACHE_TYPES),
77 79
    }
78 80

  
79 81
  _MIGRATION_STATUS_RE = re.compile('Migration\s+status:\s+(\w+)',
......
310 312
      if_val = ',if=virtio'
311 313
    else:
312 314
      if_val = ',if=%s' % disk_type
315
    # Cache mode
316
    disk_cache = hvp[constants.HV_DISK_CACHE]
317
    if disk_cache != constants.HT_CACHE_DEFAULT:
318
      cache_val = ",cache=%s" % disk_cache
319
    else:
320
      cache_val = ""
313 321
    for cfdev, dev_path in block_devices:
314 322
      if cfdev.mode != constants.DISK_RDWR:
315 323
        raise errors.HypervisorError("Instance has read-only disks which"
......
323 331
      else:
324 332
        boot_val = ''
325 333

  
326
      drive_val = 'file=%s,format=raw%s%s' % (dev_path, if_val, boot_val)
334
      drive_val = 'file=%s,format=raw%s%s%s' % (dev_path, if_val, boot_val,
335
                                                cache_val)
327 336
      kvm_cmd.extend(['-drive', drive_val])
328 337

  
329 338
    iso_image = hvp[constants.HV_CDROM_IMAGE_PATH]
b/man/gnt-instance.sgml
521 521
              </listitem>
522 522
            </varlistentry>
523 523

  
524
            <varlistentry>
525
              <term>disk_cache</term>
526
              <listitem>
527
                <simpara>Valid for the KVM hypervisor.</simpara>
528

  
529
                <simpara>The disk cache mode. It can be either
530
                <userinput>default</userinput> to not pass any cache
531
                option to KVM, or one of the KVM cache modes: none
532
                (for direct I/O), writethrough (to use the host cache
533
                but report completion to the guest only when the host
534
                has commited the changes to disk) or writeback (to use
535
                the host cache and report completion as soon as the
536
                data is in the host cache). Note that there are
537
                special considerations for the cache mode depending on
538
                version of KVM used and disk type (always raw file
539
                under Ganeti), please refer to the KVM documentation
540
                for more details.
541
                </simpara>
542
              </listitem>
543
            </varlistentry>
544

  
524 545
          </variablelist>
525 546

  
526 547
        </para>

Also available in: Unified diff