Revision 19572932

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,
......
646 657
    HV_USB_MOUSE: '',
647 658
    HV_MIGRATION_PORT: 8102,
648 659
    HV_USE_LOCALTIME: False,
660
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
649 661
    },
650 662
  HT_FAKE: {
651 663
    },
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+)',
......
312 314
      if_val = ',if=virtio'
313 315
    else:
314 316
      if_val = ',if=%s' % disk_type
317
    # Cache mode
318
    disk_cache = hvp[constants.HV_DISK_CACHE]
319
    if disk_cache != constants.HT_CACHE_DEFAULT:
320
      cache_val = ",cache=%s" % disk_cache
321
    else:
322
      cache_val = ""
315 323
    for cfdev, dev_path in block_devices:
316 324
      if cfdev.mode != constants.DISK_RDWR:
317 325
        raise errors.HypervisorError("Instance has read-only disks which"
......
325 333
      else:
326 334
        boot_val = ''
327 335

  
328
      drive_val = 'file=%s,format=raw%s%s' % (dev_path, if_val, boot_val)
336
      drive_val = 'file=%s,format=raw%s%s%s' % (dev_path, if_val, boot_val,
337
                                                cache_val)
329 338
      kvm_cmd.extend(['-drive', drive_val])
330 339

  
331 340
    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