Exemple #1
0
def test_set_threshold():
    vm = FakeVM()
    mon = thinp.VolumeMonitor(vm, vm.log)
    vda = make_drive(vm.log, index=0, iface='virtio')
    vm.drives.append(vda)

    apparentsize = 4 * GiB
    chunk_size = config.getint("irs", "volume_utilization_chunk_mb") * MiB
    free = (100 - config.getint("irs", "volume_utilization_percent")) / 100
    threshold = chunk_size * free

    # TODO: Use public API.
    mon._set_threshold(vda, apparentsize, 1)
    expected = apparentsize - threshold
    assert vm._dom.thresholds == [('vda[1]', expected)]
Exemple #2
0
    def _base_needs_extend(self, drive, job, base_info):
        """
        Return True, new_size if base needs to be extended, otherwise False,
        None.

        The returned size is always correct for internal merge, but for active
        layer merge it is only an estimate. In the worst case the merge may
        fail with ENOSPC and the user will have to retry the merge.
        """
        if not drive.chunked or base_info['format'] != 'COW':
            log.debug(
                "Base volume does not support extending "
                "job=%s drive=%s volume=%s", job.id, job.drive, job.base)
            return False, None

        current_size = int(base_info["apparentsize"])
        max_size = drive.getMaxVolumeSize(int(base_info["capacity"]))

        # Size can be bigger than maximum value due to rounding to LVM extent
        # size (128 MiB).
        if current_size >= max_size:
            log.debug(
                "Base volume is already extended to maximum size "
                "job=%s drive=%s volume=%s size=%s", job.id, job.drive,
                job.base, base_info["apparentsize"])
            return False, None

        # Measure the required base size for this merge, based on the current
        # allocation in top. This measurement is racy, since the guest may
        # write data to top after the measure.
        measure = self._vm.measure(drive.domainID,
                                   drive.imageID,
                                   job.top,
                                   base_info["format"],
                                   baseID=job.base)

        # Consider the required size and possible bitmaps. Since some of the
        # bitmaps already exist in base, this allocates more space than needed,
        # but bitmaps are small so this is good enough.
        required_size = measure["required"] + measure.get("bitmaps", 0)

        if job.active_commit:
            # For active layer merge, add one chunk of free space to avoid
            # pausing during extend, or right after extend completes. This is
            # a heuristic, we cannot prevent pausing during merge without
            # monitoring the volume.
            chunk_size = config.getint("irs",
                                       "volume_utilization_chunk_mb") * MiB
            if required_size + chunk_size > current_size:
                return True, required_size + chunk_size
        else:
            # For internal merge, we don't need any free space.
            if required_size > current_size:
                return True, required_size

        return False, None
Exemple #3
0
 def _command(self):
     cmd = [EXT_KVM_2_OVIRT,
            '--uri', self._uri,
            '--bufsize',
            str(config.getint('v2v', 'kvm2ovirt_buffer_size'))]
     if self._username is not None:
         cmd.extend([
             '--username', self._username,
             '--password-file', self._passwd_file])
     src, fmt = self._source_images()
     cmd.append('--source')
     cmd.extend(src)
     cmd.append('--dest')
     cmd.extend(self._dest_images())
     cmd.append('--storage-type')
     cmd.extend(fmt)
     cmd.append('--vm-name')
     cmd.append(self._vminfo['vmName'])
     return cmd
Exemple #4
0
 def _command(self):
     cmd = [EXT_KVM_2_OVIRT,
            '--uri', self._uri,
            '--bufsize',
            str(config.getint('v2v', 'kvm2ovirt_buffer_size'))]
     if self._username is not None:
         cmd.extend([
             '--username', self._username,
             '--password-file', self._passwd_file])
     src, fmt = self._source_images()
     cmd.append('--source')
     cmd.extend(src)
     cmd.append('--dest')
     cmd.extend(self._dest_images())
     cmd.append('--storage-type')
     cmd.extend(fmt)
     cmd.append('--vm-name')
     cmd.append(self._vminfo['vmName'])
     cmd.append('--allocation')
     # Per API schema, Engine is supposed to send an uppercase value
     cmd.append(self._vminfo.get('allocation', 'sparse').lower())
     return cmd
Exemple #5
0
Fichier : v2v.py Projet : nirs/vdsm
 def _command(self):
     cmd = [EXT_KVM_2_OVIRT,
            '--uri', self._uri,
            '--bufsize',
            str(config.getint('v2v', 'kvm2ovirt_buffer_size'))]
     if self._username is not None:
         cmd.extend([
             '--username', self._username,
             '--password-file', self._passwd_file])
     src, fmt = self._source_images()
     cmd.append('--source')
     cmd.extend(src)
     cmd.append('--dest')
     cmd.extend(self._dest_images())
     cmd.append('--storage-type')
     cmd.extend(fmt)
     cmd.append('--vm-name')
     cmd.append(self._vminfo['vmName'])
     cmd.append('--allocation')
     # Per API schema, Engine is supposed to send an uppercase value
     cmd.append(self._vminfo.get('allocation', 'sparse').lower())
     return cmd
Exemple #6
0
def chunk_size():
    return config.getint("irs", "volume_utilization_chunk_mb") * MiB