def get_bitmaps_info(self):
     out = []
     for idx, bitmap in enumerate(self.bitmaps):
         info = block_dirty_bitmap.get_bitmap_by_name(
             self.main_vm, self.source_images[idx], bitmap)
         out.append(info)
     return out
 def check_bitmap_status(self, status):
     bitmap = get_bitmap_by_name(self.main_vm, self._source_nodes[0],
                                 self._bitmaps[0])
     if bitmap is None:
         self.test.fail('Failed to get bitmap %s' % self._bitmaps[0])
     elif status != bitmap.get('status'):
         self.test.fail('bitmap status changed')
示例#3
0
 def check_bitmaps_count_gt_zero(self):
     """active bitmap's count should be greater than 0 after file writing"""
     bitmaps_info = list(
         map(lambda n, b: get_bitmap_by_name(self.main_vm, n, b),
             self._source_nodes, self._bitmaps))
     if not all(list(map(lambda b: b and b['count'] > 0, bitmaps_info))):
         self.test.fail('bitmaps count should be greater than 0')
示例#4
0
 def check_bitmap_info(self):
     bitmap = block_bitmap.get_bitmap_by_name(self.main_vm,
                                              self._top_device,
                                              self.bitmap_name)
     if bitmap:
         count = bitmap["count"]
         return count
示例#5
0
 def check_bitmap_count_gt_zero(self):
     """count of bitmaps should be 0"""
     bitmaps = list(
         map(lambda n, b: get_bitmap_by_name(self.main_vm, n, b),
             self._source_nodes, self._bitmaps))
     if not all(list(map(lambda b: b and b['count'] > 0, bitmaps))):
         self.test.fail('bitmap count should be greater than 0.')
    def remove_bitmap_with_qmp_cmd(self):
        """Removing an inconsistent bitmap should succeed"""

        block_dirty_bitmap_remove(self.main_vm, self._source_nodes[0],
                                  self._bitmaps[0])
        bitmap = get_bitmap_by_name(self.main_vm, self._source_nodes[0],
                                    self._bitmaps[0])
        if bitmap is not None:
            self.test.fail('Failed to remove bitmap %s' % self._bitmaps[0])
 def check_bitmaps(self):
     for idx, bitmap in enumerate(self._bitmaps):
         info = block_dirty_bitmap.get_bitmap_by_name(
             self.main_vm, self._source_nodes[idx], bitmap)
         if info:
             if info["count"] <= 0:
                 self.test.fail("count in bitmap must be greater than 0")
         else:
             self.test.fail("Failed to find bitmap %s" % bitmap)
    def disable_bitmaps(self):
        for idx, bitmap in enumerate(self.bitmaps):
            # disable function has already checked if the bitmap was disabled
            block_dirty_bitmap.block_dirty_bitmap_disable(
                self.main_vm, self.source_images[idx], bitmap)

            # record the count of the bitmap
            info = block_dirty_bitmap.get_bitmap_by_name(
                self.main_vm, self.source_images[idx], bitmap)
            self.bitmap_counts[info['name']] = info['count']
示例#9
0
    def check_bitmaps(self, node_name, bitmap_name):
        bitmap = block_dirty_bitmap.get_bitmap_by_name(self.main_vm, node_name,
                                                       bitmap_name)
        # check if bitmap exists
        if bitmap is None:
            self.test.fail('Failed to get bitmap')

        # check if bitmap is persistent
        if not bitmap['persistent']:
            self.test.fail('Bitmap should be persistent')
示例#10
0
 def check_bitmap_field(self, **args):
     bitmap = get_bitmap_by_name(self.main_vm, self._source_nodes[0],
                                 self._bitmaps[0])
     if bitmap is None:
         self.test.fail('Failed to get bitmap %s' % self._bitmaps[0])
     else:
         for key, value in args.items():
             if value != bitmap[key]:
                 self.test.fail('bitmap field %s is not correct: '
                                'expected %s, got %s' %
                                (key, value, bitmap[key]))
示例#11
0
 def check_disabled_bitmaps(self):
     """count of bitmaps should be 0"""
     bitmaps = list(
         map(lambda n, b: get_bitmap_by_name(self.main_vm, n, b),
             self._source_nodes, self._bitmaps))
     if not all(
             list(
                 map(
                     lambda b: b and b['status'] == 'disabled' and b[
                         'count'] == 0, bitmaps))):
         self.test.fail('disabled bitmaps changed.')
示例#12
0
    def get_record_counts_of_bitmap(self, name):
        """
        Get record counts of bitmap in the device

        :param name: bitmap name
        :return: record counts
        :rtype: int
        """
        bitmap = block_dirty_bitmap.get_bitmap_by_name(self.vm, self.device,
                                                       name)
        return bitmap["count"] if bitmap else -1
    def _get_bitmap_count(self):
        # let's wait some time to sync bitmap count, for on ppc the count
        # failed to be synced immediately after creating a new file
        sleep(10)

        bm = get_bitmap_by_name(self.main_vm, self._source_nodes[0],
                                self._bitmaps[0])
        if bm:
            if bm.get("count", 0) <= 0:
                self.test.fail("Count of bitmap should be greater than 0")
            return bm["count"]
        else:
            self.test.fail("Failed to get bitmap")
示例#14
0
def blockdev_backup(vm, source, target, **extra_options):
    cmd, arguments = blockdev_backup_qmp_cmd(source, target, **extra_options)
    timeout = int(extra_options.pop("timeout", 600))
    if "bitmap" in arguments:
        info = block_bitmap.get_bitmap_by_name(vm, source, arguments["bitmap"])
        assert info, "Bitmap '%s' not exists in device '%s'" % (
            arguments["bitmap"], source)
        auto_disable_bitmap = extra_options.pop("auto_disable_bitmap", True)
        if auto_disable_bitmap and info.get("status") != "disabled":
            block_bitmap.block_dirty_bitmap_disable(vm, source,
                                                    arguments["bitmap"])
    vm.monitor.cmd(cmd, arguments)
    job_id = arguments.get("job-id", source)
    job_utils.wait_until_block_job_completed(vm, job_id, timeout)
示例#15
0
 def check_bitmap_existed(self):
     """
     bitmap should exist after vm reboot.
     No need compare bitmap count with the original, for an
     active bitmap's count can be changed after reboot
     """
     bitmaps = list(
         map(lambda n, b: get_bitmap_by_name(self.main_vm, n, b),
             self._source_nodes, self._bitmaps))
     if not all(
             list(
                 map(
                     lambda b: b and b['status'] == 'active' and b['count']
                     >= 0, bitmaps))):
         self.test.fail('bitmap should still exist after vm crash.')
示例#16
0
def incremental_backup(vm, node, target, bitmap=None, wait=True):
    """
    Do incremental backup with bitmap

    :param vm: VM object
    :param node: device ID or node-name
    :param target: target device node-name or ID
    :param wait: wait for backup job finished or not
    """
    options = {"device": node, "target": target, "sync": "incremental"}
    if bitmap:
        options["bitmap"] = bitmap
        info = block_bitmap.get_bitmap_by_name(vm, node, bitmap)
        assert info, "Bitmap '%s' not exists in device '%s'" % (bitmap, node)
        if info["status"] != "disabled":
            block_bitmap.block_dirty_bitmap_disable(vm, node, bitmap)
    return blockdev_backup(vm, options, wait)
示例#17
0
 def check_bitmap_after_migration(self):
     bitmap = get_bitmap_by_name(self.main_vm, self._source_nodes[0],
                                 self._bitmaps[0])
     if self._bitmap_debugged:
         if bitmap is None:
             self.test.fail('No persistent bitmap was found '
                            'after migration')
         if bitmap.get('status') != 'disabled':
             self.test.fail('Persistent bitmap was not disabled '
                            'after migration')
         v = debug_block_dirty_bitmap_sha256(self.main_vm,
                                             self._source_nodes[0],
                                             self._bitmaps[0])
         if self._bitmap_sha256 != v:
             self.test.fail('Persistent bitmap sha256 changed '
                            'after migration')
     else:
         if bitmap is not None:
             self.test.fail('Got non-persistent bitmap unexpectedly '
                            'after migration')
示例#18
0
 def _get_bitmaps(self):
     return list(
         map(lambda n, b: get_bitmap_by_name(self.main_vm, n, b),
             self._source_nodes, self._bitmaps))
示例#19
0
 def check_image_bitmap_with_qmp_cmd(self):
     bitmap = get_bitmap_by_name(self.main_vm, self._source_nodes[0],
                                 self._max_len_name)
     if bitmap is None:
         self.test.fail('Failed to get bitmap with query-block')