def METHOD_NAME(test, params, env):
    """
    Test passt backend interface hotplug and hotunplug
    """
    libvirt_version.is_libvirt_feature_supported(params)
    root = 'root_user' == params.get('user_type', '')
    if root:
        vm_name = params.get('main_vm')
        vm = env.get_vm(vm_name)
        virsh_ins = virsh
        log_dir = params.get('log_dir')
        user_id = params.get('user_id')
    else:
        vm_name = params.get('unpr_vm_name')
        test_user = params.get('test_user', '')
        test_passwd = params.get('test_passwd', '')
        user_id = passt.get_user_id(test_user)
        unpr_vm_args = {
            'username': params.get('username'),
            'password': params.get('password'),
        }
        vm = libvirt_unprivileged.get_unprivileged_vm(vm_name, test_user,
                                                      test_passwd,
                                                      **unpr_vm_args)
        uri = f'qemu+ssh://{test_user}@localhost/session'
        virsh_ins = virsh.VirshPersistent(uri=uri)
        host_session = aexpect.ShellSession('su')
        remote.VMManager.set_ssh_auth(host_session, 'localhost', test_user,
                                      test_passwd)
        host_session.close()
    scenario = params.get('scenario')
    virsh_uri = params.get('virsh_uri')
    add_iface = 'yes' == params.get('add_iface', 'no')
    host_ip = utils_net.get_host_ip_address(ip_ver='ipv4')
    host_ip_v6 = utils_net.get_host_ip_address(ip_ver='ipv6')
    iface_attrs = eval(params.get('iface_attrs'))
    params['socket_dir'] = socket_dir = eval(params.get('socket_dir'))
    params['proc_checks'] = proc_checks = eval(params.get('proc_checks', '{}'))
    vm_iface = params.get('vm_iface', 'eno1')
    mtu = params.get('mtu')
    outside_ip = params.get('outside_ip')
    host_iface = params.get('host_iface')
    host_iface = host_iface if host_iface else utils_net.get_net_if(
        state="UP")[0]
    log_file = f'/run/user/{user_id}/passt.log'
    iface_attrs['backend']['logFile'] = log_file
    iface_attrs['source']['dev'] = host_iface
    vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name,
                                                   virsh_instance=virsh_ins)
    bkxml = vmxml.copy()
    selinux_status = passt.ensure_selinux_enforcing()
    passt.check_socat_installed()
    firewalld = service.Factory.create_service("firewalld")
    try:
        if root:
            passt.make_log_dir(user_id, log_dir)
        vmxml.del_device('interface', by_tag=True)
        iface_device = libvirt_vmxml.create_vm_device_by_type('interface',
                                                              iface_attrs)
        LOG.debug(f'iface_device: {iface_device}')
        if add_iface:
            vmxml.add_device(iface_device)
        vmxml.sync(virsh_instance=virsh_ins)
        vm.start()
        if 'attach' in scenario:
            virsh_ins.attach_device(vm_name, iface_device.xml, **VIRSH_ARGS)
            LOG.debug(virsh_ins.dumpxml(vm_name).stdout_text)
            vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name,
                                                  virsh_instance=virsh_ins)
            iface_after_at = vmxml.get_devices(device_type='interface')[0]
            LOG.debug(f'iface device after detach: {iface_after_at}')
            iface_after_at.del_mac_address()
            iface_after_at.del_address()
            if iface_after_at != iface_device:
                test.fail('iface xml changed after attach')
            mac = vm.get_virsh_mac_address()
            check_mac_in_domiflist(vm_name, mac, virsh_ins, test)
            passt.check_proc_info(params, log_file, mac)
            #   check the passt log
            if not os.path.exists(log_file):
                test.fail(f'Logfile of passt "{log_file}" not created')
            session = vm.wait_for_serial_login(timeout=60)
            passt.check_vm_ip(iface_attrs, session, host_iface)
            passt.check_vm_mtu(session, vm_iface, mtu)
            passt.check_default_gw(session)
            passt.check_nameserver(session)
            ips = {
                'outside_ip': outside_ip,
                'host_public_ip': host_ip,
            }
            network_base.ping_check(params, ips, session, force_ipv4=True)
            firewalld.stop()
            LOG.debug(f'Service status of firewalld: {firewalld.status()}')
            passt.check_connection(vm, vm_iface,
                                   ['TCP4', 'TCP6', 'UDP4', 'UDP6'])
            if 'portForwards' in iface_attrs:
                passt.check_portforward(vm, host_ip, params)
        if 'detach' not in scenario:
            vm.destroy()
            passt.check_passt_pid_not_exist()
            if os.listdir(socket_dir):
                test.fail(f'Socket dir is not empty: {os.listdir(socket_dir)}')
        else:
            vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name,
                                                  virsh_instance=virsh_ins)
            LOG.debug(f'vmxml before detach:\n{vmxml}')
            iface_to_detach = vmxml.get_devices('interface')[0]
            mac = iface_to_detach.mac_address
            virsh.detach_device(vm_name, iface_to_detach.xml,
                                wait_for_event=True, event_timeout=15,
                                uri=virsh_uri, **VIRSH_ARGS)
            vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name,
                                                  virsh_instance=virsh_ins)
            LOG.debug(f'vmxml after detach: {vmxml}')
            iface_after_detach = vmxml.get_devices('interface')
            if iface_after_detach:
                test.fail('Interface should be detached from vm, but it can '
                          'still be found in vmxml')
            check_mac_in_domiflist(vm_name, mac, virsh_ins, test, expect=False)
            passt.check_passt_pid_not_exist()
    finally:
        firewalld.start()
        vm.destroy()
        bkxml.sync(virsh_instance=virsh_ins)
        if root:
            shutil.rmtree(log_dir)
        else:
            del virsh_ins
        utils_selinux.set_status(selinux_status)