def METHOD_NAME(test, vmxml, **kwargs):
    """
    Config libvirt VM XML to influence how virtual memory pages are backed
    by host pages.
    :param vmxml: VMXML instance
    :param kwargs: Function keywords
    :return: Corresponding feature flag in qem cmdline
    """
    # Both 'nosharepages' and 'locked' are supported since 1.0.6
    if not libvirt_version.version_compare(1, 0, 6):
        test.cancel("Element is not supported in current"
                    " libvirt version")
    qemu_flags = []
    no_sharepages = "yes" == kwargs.get("nosharepages", "no")
    locked = "yes" == kwargs.get("locked", "no")
    if no_sharepages:
        # On RHEL6, the flag is 'redhat-disable-KSM'
        # On RHEL7 & Fedora, the flag is 'mem-merge=off'
        qemu_flags.append(['mem-merge=off', 'redhat-disable-KSM'])
    if locked:
        if not libvirt_version.version_compare(5, 3, 0):
            qemu_flags.append("mlock=on")
        else:
            qemu_flags.append("mem-lock=on")
        memtune_xml = vm_xml.VMMemTuneXML()
        memtune_xml.hard_limit = vmxml.max_mem * 4
        vmxml.memtune = memtune_xml
        vmxml.sync()
    try:
        vm_xml.VMXML.set_memoryBacking_tag(vmxml.vm_name,
                                           hpgs=False,
                                           nosp=no_sharepages,
                                           locked=locked)
        logging.debug("xml updated to %s", vmxml.xmltreefile)
    except Exception as detail:
        logging.error("Update VM XML fail: %s", detail)
    return qemu_flags