Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory: add case for hugepage mount path #4984

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

nanli1
Copy link
Contributor

@nanli1 nanli1 commented Jun 21, 2023

VIRT-297104: Huge page mount path
Signed-off-by: nanli [email protected]

 avocado run --vt-type libvirt --test-runner=runner --vt-machine-type q35 memory.backing.mount_path

 (1/3) type_specific.io-github-autotest-libvirt.memory.backing.mount_path.default: PASS (61.76 s)
 (2/3) type_specific.io-github-autotest-libvirt.memory.backing.mount_path.disabled: PASS (25.95 s)
 (3/3) type_specific.io-github-autotest-libvirt.memory.backing.mount_path.customized: PASS (29.31 s)

Depend on

@nanli1 nanli1 marked this pull request as draft June 21, 2023 09:29
@nanli1 nanli1 force-pushed the add_case_for_huagepage_mount_path branch 3 times, most recently from b90d766 to 7a95e76 Compare June 21, 2023 12:40
@nanli1 nanli1 force-pushed the add_case_for_huagepage_mount_path branch from 7a95e76 to 4177644 Compare July 18, 2023 02:39
@nanli1 nanli1 marked this pull request as ready for review July 18, 2023 02:40
@nanli1
Copy link
Contributor Author

nanli1 commented Jul 18, 2023

modular_redesign

@nanli1 nanli1 force-pushed the add_case_for_huagepage_mount_path branch from 4177644 to b96985d Compare July 29, 2023 12:56
@nanli1 nanli1 marked this pull request as draft July 30, 2023 03:26
@nanli1 nanli1 marked this pull request as ready for review July 30, 2023 03:27
@nanli1 nanli1 force-pushed the add_case_for_huagepage_mount_path branch from b96985d to ee6dc4b Compare August 16, 2023 06:50
virsh.destroy(vm_name, ignore_status=False)

test.log.info("TEST_STEP13: Restart service")
process.run("systemctl restart %s" % libvirtd.service_name, shell=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For restarting a service, usually we do not use process.run(). Have you tried utils_libvirtd.Libvirtd() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks dzheng, same as #4984 (comment) ,Could check ,thank you

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Contributor

@dzhengfy dzhengfy Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my reply #4984 (comment)

test.log.info("TEST_STEP11: Check mem")
session = vm.wait_for_login()
mem_free = utils_memory.freememtotal(session)
status, stdout = session.cmd_status_output("swapoff -a; memhog %s" % (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try libvirt_memory.consume_vm_freememory()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks , def consume_vm_freememory has a hard code and for memhog %10000k , so I make a enhance by avocado-framework/avocado-vt#3767

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

return

test.log.info("TEST_STEP7: Stop services")
utils_libvirtd.libvirtd_stop()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is already with deprecation warning. Please use utils_libvirtd.libvirtd().stop() instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ,done

process.run("ps -ef | grep qemu | grep prealloc > %s" % out_file,
shell=True)
for item in check_qemu:
libvirt.check_logfile(item, out_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 83 - 86, for checking qemu command line, there is libvirt.check_qemu_cmd_line(), but it only supports to search one pattern a time. Could you consider to reuse it? Or if you could enhance that function to support checking a list of patterns, that will be appreciated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks dzheng, enhance by avocado-framework/avocado-vt#3767

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

if case == "disabled":
return

test.log.info("TEST_STEP3: Start guest guest")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove one 'guest'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


test.log.info("TEST_STEP2: Restart libvirt service")
libvirtd = utils_libvirtd.Libvirtd()
process.run("systemctl restart %s" % libvirtd.service_name, shell=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the reason you do not use libvirtd.restart() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks dzheng, becausedef libvirtd.restart()has invoked result.append(self._wait_for_start()) , it is always checking the virsh list for until service active , however the TEST_STEP1 has modified by the huge page mount path invalid config for some scenarios , which makes the virsh list does not work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I understand.
But I think it is a good time to enhance this function.
For example, we add a new option to disable the checking. When we do not care about the result with wait_for_start=False, it will always return True. And then users need to check the service status using xxx.is_running() by themselves. How about?

def restart(self, reset_failed=True, wait_for_start=True):
    result = []
    for daem_item in self.daemons:
        if reset_failed:
            daem_item.reset_failed()
        if not daem_item.restart():
            return False
        if wait_for_start:
            result.append(self._wait_for_start())
    return all(result)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yingshun @chloerh @chunfuwen What's your opinion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dzhengfy
The restart function expect to work in very simple way since we hope it can return as soon as possible.
Moreover, the return result expect simple as much as we can,otherwise it need upstream code(caller) to handle different return type.
Another alternatives is to override another function if we really find it is more of common use cases

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks all, Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dzhengfy The restart function expect to work in very simple way since we hope it can return as soon as possible. Moreover, the return result expect simple as much as we can,otherwise it need upstream code(caller) to handle different return type. Another alternatives is to override another function if we really find it is more of common use cases

I checked in tp-libvirt for the usage of restart(), and I did not find any caller to use the return value of this function. So I am wondering if we really need this return. Then I value this different return type as low risk. We can add docstring or comment to make the users be aware of this difference when they use this new parameter.

if case != "default":
qemu_obj = libvirt.customize_libvirt_config(
{"hugetlbfs_mount": '"%s"' % hugetlbfs_mount}, "qemu",
restart_libvirt=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the reason you do not use restart_libvirt=True in this function to restart libvirtd daemon?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks dzheng, because we need to restart libvirt as a obvious step in Step2

vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
vmxml.setup_attrs(**vm_attrs)
virsh.define(vmxml.xml, debug=True, ignore_status=False)
test.log.debug("Define xml by :\n%s " % vmxml)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'%' -> ','

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


hp_cfg = test_setup.HugePageConfig(params)
hp_cfg.cleanup()
process.run("mount -t hugetlbfs hugetlbfs %s" % default_path,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use

hp_cfg.hugepage_path =  default_path
hp_cfg.mount_hugepage_fs()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@nanli1 nanli1 force-pushed the add_case_for_huagepage_mount_path branch 2 times, most recently from c24702c to 848336c Compare September 19, 2023 07:44
@dzhengfy dzhengfy added the depend on The PR has dependency on other PRs label Oct 6, 2023

test.log.info("TEST_STEP4: Check the qemu cmd line")
for item in check_qemu:
# libvirt.check_logfile(item, out_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

test.log.info("TEST_STEP4: Check the qemu cmd line")
for item in check_qemu:
# libvirt.check_logfile(item, out_file)
libvirt.check_qemu_cmd_line(item)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With avocado-framework/avocado-vt#3767, we should invoke this function by libvirt.check_qemu_cmd_line(check_qemu) directly because list is supported, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks your reminder,Done

@nanli1 nanli1 force-pushed the add_case_for_huagepage_mount_path branch from 848336c to c45bab7 Compare October 8, 2023 08:00
  VIRT-297104: Huge page mount path
Signed-off-by: nanli <[email protected]>
@nanli1 nanli1 force-pushed the add_case_for_huagepage_mount_path branch from c45bab7 to cf7da46 Compare October 16, 2023 07:53
Copy link
Contributor

@dzhengfy dzhengfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@chunfuwen chunfuwen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@chunfuwen chunfuwen merged commit c133fbd into autotest:master Oct 30, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
depend on The PR has dependency on other PRs modular_redesign
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants