# Utilities for python-based QEMU tests
#
# Copyright 2024 Red Hat, Inc.
#
# Authors:
#  Thomas Huth <thuth@redhat.com>
#
# This work is licensed under the terms of the GNU GPL, version 2 or
# later.  See the COPYING file in the top-level directory.

import os

from qemu.utils import get_info_usernet_hostfwd_port


def get_usernet_hostfwd_port(vm):
    res = vm.cmd('human-monitor-command', command_line='info usernet')
    return get_info_usernet_hostfwd_port(res)

def pow2ceil(x):
    """
    Round up to next power of 2
    """
    return 1 if x == 0 else 2**(x - 1).bit_length()

def file_truncate(path, size):
    if size != os.path.getsize(path):
        with open(path, 'ab+') as fd:
            fd.truncate(size)

def image_pow2ceil_expand(path):
    """
    Expand file size to next power of 2
    """
    size = os.path.getsize(path)
    size_aligned = pow2ceil(size)
    if size != size_aligned:
        with open(path, 'ab+') as fd:
            fd.truncate(size_aligned)
