{ "info": { "author": "Adam Zegelin", "author_email": "adam@zegelin.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", "Topic :: Utilities" ], "description": "=============\nqemu-affinity\n=============\n\n``qemu-affinity`` is a tool to easily pin certain `QEMU `_ threads to select CPU cores.\n\n---------------\nGetting Started\n---------------\n\nInstalling\n==========\n\nThis will install the ``qemu-affinity`` command to ``/usr/local/bin``.\n\nFrom *pip*\n----------\n\n::\n\n\tpip install qemu-affinity\n\nFrom source\n-----------\n\nClone the repo and run::\n\n\tpython setup.py install\n\n\nRequirements\n============\n\n``qemu-affinity`` requires Python 3.\n\n.. note::\n\n\t``qemu-system`` instances must be started with the ``-name ,debug-threads=on`` argument for ``qemu-affinity`` to correctly identify and set the affinity of specific *QEMU* threads.\n\nUsage\n=====\n\n::\n\n\tqemu-affinity qemu-system-pid\n\t\t\t\t [-h] [--dry-run] [-v] [-p [AFFINITY]]\n\t\t\t\t [-q AFFINITY [AFFINITY ...]]\n\t\t\t\t [-k THREAD_AFFINITY [THREAD_AFFINITY ...]]\n\t\t\t\t [-i THREAD_AFFINITY [THREAD_AFFINITY ...]]\n\t\t\t\t [-w THREAD_AFFINITY [THREAD_AFFINITY ...]]\n\t\t\t\t [-t THREAD_AFFINITY [THREAD_AFFINITY ...]]\n\n\nPositional arguments\n--------------------\n\n``qemu-system-pid``\n\tPID of the qemu-system process\n\nOptional arguments\n------------------\n\n``-h, --help``\n\tshow this help message and exit\n``--dry-run``\n\tdon't modify thread affinity values (useful with ``-v``)\n``-v, --verbose``\n\tbe verbose\n``-p AFFINITY``, ``--process-affinity AFFINITY``\n\tset *qemu-system* process affinity (and default for new threads)\n``-q AFFINITY [AFFINITY ...]``, ``--qemu-affinity AFFINITY [AFFINITY ...]``\n\tset *qemu-system* thread affinity (partial name selectors not allowed)\n``-k THREAD_AFFINITY [THREAD_AFFINITY ...]``, ``--kvm-affinity THREAD_AFFINITY [THREAD_AFFINITY ...]``\n\tset KVM (*CPU /KVM*) thread affinity\n``-i THREAD_AFFINITY [THREAD_AFFINITY ...]``, ``--io-affinity THREAD_AFFINITY [THREAD_AFFINITY ...]``\n\tset IO object (*IO *) thread affinity\n``-w THREAD_AFFINITY [THREAD_AFFINITY ...]``, ``--worker-affinity THREAD_AFFINITY [THREAD_AFFINITY ...]``\n\tset qemu worker (*worker*) thread affinity (partial name selectors not allowed, only positional)\n``-t THREAD_AFFINITY [THREAD_AFFINITY ...]``, ``--thread-affinity THREAD_AFFINITY [THREAD_AFFINITY ...]``\n\tset arbitary (**) thread affinity\n\n----\n\n``AFFINITY`` is an *affinity-spec*\n\nand\n\n``THREAD_AFFINITY`` can be one of:\n\n\t* *affinity-spec*\n\t* *selector*\\ ``:``\\ *affinity-spec*\n\n\n\nWhere *affinity-spec* is a CPU number, a range (inclusive) of CPU numbers separated by a\ndash (``-``), or a comma-delimited (``,``) list of CPU numbers or ranges.\n\n\tFor example:\n\n\t\t``0``\n\t\t\tspecifies CPU 0\n\t\t``0,1,2,3``\n\t\t\tspecifies CPU 0, 1, 2 and 3\n\t\t``0-3``\n\t\t\tsame as above\n\t\t``0,2-4,6``\n\t\t\tspecifies CPU 0, 2, 3, 4 and 6\n\n\nand, where *selector* is one of:\n\n\t* ``*``, meaning all threads\n\t* *partial-name* for ``-k`` (*CPU /KVM*) and ``-i`` (*IO *)\n\t* *name* for ``-t``\n\n\nThe first variant, *affinity-spec*, selects threads based on argument position.\n\n\te.g., ``-k 0,4 1,5 2,6 3,7`` pins the first KVM thread to CPUs 0 and 4, the second KVM thread to CPUs 1 and 5, and so on.\n\nThe second variant, *selector*\\ ``:``\\ *affinity-spec*, selects threads by *selector*, which is a partial name or wildcard.\nKVM threads have numeric names (*0*, *1*, *2*, etc.).\nIO threads have user-supplied names (``-object iothread,id=``\\ *name*).\n\n\te.g., ``-k 2:2,6 -i myiothread:7 *:0`` pins KVM thread *2* (aka *CPU 2/KVM*) to CPUs 2 and 6, IO thread *myiothread* (aka *IO myiothread*) to CPU 7, and all remaining IO threads to\n\tCPU 0.\n\nThe two variants can be combined.\n\n\te.g., ``-k 0,4 *:2,6`` pins the first KVM thread to CPUs 0 and 4,\n\t\tand all remaining KVM threads to CPUs 2 and 6.\n\n-----------------\nKnown Limitations\n-----------------\n\n* the built-in help (``qemu-affinity -h``) lists the *qemu-system-pid* argument last in the list which may conflict with multi-argument parameters \n such as ``-q``, ``-k``, ``-i``, ``-w``, and ``-t``.\n\n\tEither specify *qemu-system-pid* at the beginning of the argument list or use ``--`` to separate the multi-argument parameters from the positional parameters.\n\n* ``-t/--thread-affinity`` only applies to the first of multiple threads that share an identical name (such as the QEMU ``worker`` threads).\n\n\t``-t`` is unable to specify different affinities for threads with duplicate names, nor is it able to apply the same affinity value to multiple threads with the same name\n\t(``*`` applies to *all* threads, not just a sub-set).\n\n\te.g. ``-t abc:1 abc:2`` results in an error, and there is no way to set all threads with the name \"abc\" to the same affinity value.\n\n\tAdditionally, there is no way to select the n\\ :sup:`th` thread with the same name.\n\n\te.g. ``-t abc:1`` will always select the 1\\ :sup:`st` thread with the name \"abc\".\n\n------------\nSample Usage\n------------\n\nThe following *systemd.service(5)* starts *QEMU* as a daemon and then pins the 4 KVM threads (one for each emulated CPU core) to host CPUs 2, 3, 4 and 5. IO threads and other QEMU worker threads are pinned\nto host CPUs 0 and 1.\n\nIn this example the host kernel has been configured to isolate cores 2, 3, 4 & 5 so they can be solely utilised by *QEMU*.\\\n\n::\n\n\t[Unit]\n\tDescription=QEMU virtual machine\n\tAfter=network.target netctl@br0.service\n\n\t[Service]\n\tCPUSchedulingPolicy=rr\n\n\tType=forking\n\tPIDFile=/run/qemu_ex.pid\n\n\tEnvironment=QEMU_AUDIO_DRV=pa\n\n\tExecStart=/usr/bin/qemu-system-x86_64 -name example-qemu-machine,debug-threads=on -daemonize -pidfile /run/qemu_ex.pid -monitor unix:/tmp/qemu_ex.sock,server,nowait -smp cores=4,threads=1,sockets=1 ...\n\tExecStartPost=/bin/sh -c 'exec /usr/bin/qemu-affinity $MAINPID -p 0-1 -i *:0-1 -q 0-1 -w *:0-1 -k 2 3 4 5'\n\n\tExecStop=/bin/sh -c 'while test -d /proc/$MAINPID; do /usr/bin/echo system_powerdown | /usr/bin/socat - UNIX-CONNECT:/tmp/qemu_ex.sock; sleep 60; done'\n\tTimeoutStopSec=1m\n\n\t[Install]\n\tWantedBy=multi-user.target\n\n\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://packages.python.org/an_example_pypi_project", "keywords": "qemu affinity", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "qemu-affinity", "package_url": "https://pypi.org/project/qemu-affinity/", "platform": "", "project_url": "https://pypi.org/project/qemu-affinity/", "project_urls": { "Homepage": "http://packages.python.org/an_example_pypi_project" }, "release_url": "https://pypi.org/project/qemu-affinity/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "A tool to easily pin certain QEMU threads to select CPU cores.", "version": "1.0.0" }, "last_serial": 3306571, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "2a1f1144948083b89fc6a232c5759590", "sha256": "042315d0a2b291253a5efbc0fb001e550317b55f470f0c09cfc1abd9c4f62449" }, "downloads": -1, "filename": "qemu_affinity-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2a1f1144948083b89fc6a232c5759590", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10756, "upload_time": "2017-11-05T05:25:42", "url": "https://files.pythonhosted.org/packages/61/a0/466df76d9b26fbd2cc2b919e62073f3ac12749653f1b4a1ad235a1e83ca2/qemu_affinity-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f278f77d531fca6e236f693a0426c0e6", "sha256": "c9cbecc36a2714bd3caaf772909e70e467aa063e8b229a87d976e65f9cde0470" }, "downloads": -1, "filename": "qemu-affinity-1.0.0.tar.gz", "has_sig": false, "md5_digest": "f278f77d531fca6e236f693a0426c0e6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7195, "upload_time": "2017-11-05T05:25:43", "url": "https://files.pythonhosted.org/packages/d8/c2/8081a0a037b4325a47849a61e36889bcd6221cb099ec206d512f175a0413/qemu-affinity-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2a1f1144948083b89fc6a232c5759590", "sha256": "042315d0a2b291253a5efbc0fb001e550317b55f470f0c09cfc1abd9c4f62449" }, "downloads": -1, "filename": "qemu_affinity-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2a1f1144948083b89fc6a232c5759590", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10756, "upload_time": "2017-11-05T05:25:42", "url": "https://files.pythonhosted.org/packages/61/a0/466df76d9b26fbd2cc2b919e62073f3ac12749653f1b4a1ad235a1e83ca2/qemu_affinity-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f278f77d531fca6e236f693a0426c0e6", "sha256": "c9cbecc36a2714bd3caaf772909e70e467aa063e8b229a87d976e65f9cde0470" }, "downloads": -1, "filename": "qemu-affinity-1.0.0.tar.gz", "has_sig": false, "md5_digest": "f278f77d531fca6e236f693a0426c0e6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7195, "upload_time": "2017-11-05T05:25:43", "url": "https://files.pythonhosted.org/packages/d8/c2/8081a0a037b4325a47849a61e36889bcd6221cb099ec206d512f175a0413/qemu-affinity-1.0.0.tar.gz" } ] }