Esempio n. 1
0
    def test_at_iface_and_memory(dev_type):
        """
        hotplug an interface and memory devices

        1) Start vm and check the default locked memory
        2) Hotplug an interface and check the locked memory
        3) Hotplug 2 memory devices and check the locked memory
        4) Hot-unplug a memory device and check the locked memory

        :param dev_type: interface type
        """
        vm.start()
        vm.wait_for_serial_login(timeout=240).close()
        expr_memlock = 67108864
        if not check_soft_memlock(expr_memlock):
            test.fail("Unalbe to get correct default!")

        interface_base.attach_iface_device(vm_name, dev_type, params)

        new_vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)
        # MEMLOCK value is guest memory + 1G(for the passthrough device)
        expr_memlock = normalize_mem_size(
            new_vmxml.get_current_mem(),
            new_vmxml.get_current_mem_unit()) + 1073741824
        if not check_soft_memlock(expr_memlock):
            test.fail("Unalbe to get correct MEMLOCK after VM startup!")

        logging.info("Hotplug memory devices.")
        for mem_attrs in ['mem_dict1', 'mem_dict2']:
            mem_dict = eval(params.get(mem_attrs, '{}'))
            memxml = Memory()
            memxml.setup_attrs(**mem_dict)
            virsh.attach_device(vm_name, memxml.xml, **VIRSH_ARGS)
            expr_memlock += normalize_mem_size(
                mem_dict['target']['size'], mem_dict['target']['size_unit'])
            if not check_soft_memlock(expr_memlock):
                test.fail("Unalbe to get correct MEMLOCK after attaching a "
                          "memory device!")

        logging.info("Detach a memory device and check memlock.")
        memxml = vm_xml.VMXML.new_from_dumpxml(vm_name).get_devices('memory')[-1]
        cmd_result = virsh.detach_device(vm_name, memxml.xml,
                                         wait_for_event=True,
                                         debug=True)
        if cmd_result.exit_status:
            libvirt.check_result(cmd_result, 'unplug of device was rejected')
            if not check_soft_memlock(expr_memlock):
                test.fail("Detaching mem failed, MEMLOCK should not change!")
        else:
            if not check_soft_memlock(expr_memlock):
                test.fail("Unalbe to get correct MEMLOCK after detaching a "
                          "memory device!")
Esempio n. 2
0
    def test_vdpa():
        """
        Hotplug/unplug vDPA type interface

        1) Start the vm, hotplug the interface
        2) Login to the vm and check the network function
        3) Hot-unplug the interface
        """
        vm.start()
        vm_session = vm.wait_for_serial_login(timeout=240)

        br_name = None
        if test_target == "mellanox":
            br_name = test_obj.br_name
        for _i in range(eval(params.get('repeat_times', '1'))):
            interface_base.attach_iface_device(vm_name, dev_type, params)
            vdpa_base.check_vdpa_conn(vm_session, test_target, br_name)
            interface_base.detach_iface_device(vm_name, dev_type)