Exemplo n.º 1
0
def block_dirty_bitmap_clear(vm, device, name):
    qemu_monitor.get_monitor_function(vm, "block-dirty-bitmap-clear")(device,
                                                                      name)
    count = int(get_bitmap_by_name(vm, device, name)["count"])
    msg = "Count of '%s' in device '%s'" % (name, device)
    msg += "is '%d' not equal '0' after clear it" % count
    assert count == 0, msg
Exemplo n.º 2
0
def block_dirty_bitmap_remove(vm, device, name):
    """Remove bitmaps on the device one by one"""
    qemu_monitor.get_monitor_function(vm, "block-dirty-bitmap-remove")(device,
                                                                       name)
    time.sleep(0.3)
    msg = "Bitmap '%s' in device '%s' still exists!" % (name, device)
    assert get_bitmap_by_name(vm, device, name) is None, msg
Exemplo n.º 3
0
def block_dirty_bitmap_enable(vm, node, name):
    """Enable named block dirty bitmap in the node"""
    func = qemu_monitor.get_monitor_function(vm, "block-dirty-bitmap-enable")
    func(node, name)
    bitmap = get_bitmap_by_name(vm, node, name)
    msg = "block dirty bitmap '%s' is not enabled" % name
    assert bitmap["status"] == "active", msg
Exemplo n.º 4
0
def block_dirty_bitmap_enable(vm, node, name):
    """Enable named block dirty bitmap in the node"""
    func = qemu_monitor.get_monitor_function(vm, "block-dirty-bitmap-enable")
    func(node, name)
    bitmap = get_bitmap_by_name(vm, node, name)
    msg = "block dirty bitmap '%s' is not enabled" % name
    assert (bitmap["recording"] is True), msg
Exemplo n.º 5
0
def blockdev_create(vm, options, job_id=None, wait=True):
    """wrapper for blockdev-create QMP command"""
    if not job_id:
        job_id = "blk_%s" % utils_misc.generate_random_id()
    qemu_monitor.get_monitor_function(vm, "blockdev-create")(job_id, options)
    if wait:

        def wait_func():
            job_info = job_utils.get_job_by_id(vm, job_id)
            if job_info and job_info["status"] == "concluded":
                return True
            return False

        if not utils_misc.wait_for(wait_func, 5, 1):
            return None
    return job_id
Exemplo n.º 6
0
def job_dismiss(vm, job_id):
    """Dismiss block job in the given VM"""
    job = get_job_by_id(vm, job_id)
    msg = "Job '%s' is '%s', only concluded job can dismiss!" % (job_id,
                                                                 job["status"])
    assert job["status"] == "concluded", msg
    func = qemu_monitor.get_monitor_function(vm, "job-dismiss")
    return func(job_id)
Exemplo n.º 7
0
def debug_block_dirty_bitmap_sha256(vm, device, bitmap):
    """
    Get sha256 vaule of bitmap in the device

    :param device: device name
    :param bitmap: bitmap name
    :return: sha256 string or None if bitmap is not exists
    """
    func = qemu_monitor.get_monitor_function(
        vm, "debug-block-dirty-bitmap-sha256")
    return func(device, bitmap).get("sha256")
Exemplo n.º 8
0
 def modify_readonly_bitmaps(self):
     for act in ['block-dirty-bitmap-clear', 'block-dirty-bitmap-remove']:
         f = get_monitor_function(self.main_vm, act)
         try:
             f(self._source_nodes[0], self._bitmaps[0])
         except QMPCmdError as e:
             error_msg = self.params['error_msg'].format(
                 bitmap=self._bitmaps[0])
             if error_msg not in str(e):
                 self.test.fail('Unexpected error: %s' % str(e))
         else:
             self.test.fail('%s succeeded unexpectedly' % act)
Exemplo n.º 9
0
def blockdev_backup(vm, options, wait):
    """
    Live backup block device

    :param vm: VM object
    :param options: dict for blockdev-backup cmd
    :param wait: bool type, wait for backup job finished or not
    """
    event = "BLOCK_JOB_COMPLETED"
    job_id = utils_misc.generate_random_id()
    options.setdefault("job-id", job_id)
    out = qemu_monitor.get_monitor_function(vm, "blockdev-backup")(options)
    wait and wait_for_event(vm.monitor, event)
    return out
Exemplo n.º 10
0
def block_dirty_bitmap_merge(vm, device, bitmaps, target):
    """
    Merge dirty bitmaps in the device to target

    :param vm: VM object
    :param device: device id or node name
    :param bitmaps: source bitmaps
    :param target: target bitmap name
    """
    func = qemu_monitor.get_monitor_function(vm, "block-dirty-bitmap-merge")
    cmd = func.__name__.replace("_", "-")
    logging.debug("Merge %s into %s", bitmaps, target)
    if not cmd.startswith("x-"):
        return func(device, bitmaps, target)
    # handle 'x-block-dirty-bitmap-merge' command
    if len(bitmaps) == 1:
        return func(device, bitmaps[0], target)
    actions = []
    for bitmap in bitmaps:
        data = {"node": device, "src_name": bitmap, "dst_name": target}
        actions.append({"type": cmd, "data": data})
    return vm.monitor.transaction(actions)
Exemplo n.º 11
0
def query_jobs(vm):
    """Get block jobs info list in given VM"""
    func = qemu_monitor.get_monitor_function(vm, "query-jobs")
    return func()
Exemplo n.º 12
0
def query_named_block_nodes(vm):
    """Get all block nodes info of the VM"""
    func = qemu_monitor.get_monitor_function(vm, "query-named-block-nodes")
    return func()
Exemplo n.º 13
0
def blockdev_add(vm, options):
    """wrapper for blockdev-add QMP command"""
    if "node-name" not in options:
        options["node-name"] = utils_misc.generate_random_id()
    qemu_monitor.get_monitor_function(vm, "blockdev-add")(options)
    return options["node-name"]