npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sentry0/qemu-hook-manager

v0.3.0-alpha

Published

A simple QEMU hook manager.

Readme

QEMU Hook Manager

QEMU Hook Manager is a CLI tool designed to manage hardware passthrough for QEMU virtual machines easily. It allows users to easily configure and handle various hooks to automate tasks and enhance the functionality of their virtual environments.

For best results, ensure your virtualization CPU extensions are enabled in your BIOS. Feel free to use my notes as a starting point to getting the prerequisite hardware and configurations in place before running this tool. You only need to follow the first three steps and then run this tool to cover the remaining steps.

Features

  • Manage pre-defined hooks for QEMU VMs
  • Automate tasks such as automatic hardware binding
  • Easy configuration and setup
  • Devices displayed grouped by IOMMU group for easy identification of related hardware

Requirements

  • Node 20+
  • virsh
  • QEMU
  • Complete the requisite hardware configuration as described in steps 1-3 here.

Installation

Install with npm i -g @sentry0/qemu-hook-manager.

Local Checkout

To install QEMU Hook Manager, clone the repository and run the setup script:

git clone https://github.com/sentry0/qemu-hook-manager.git
cd qemu-hook-manager
npm install
npm run qemu-hook-manager

Usage

To use QEMU Hook Manager, follow these steps:

  1. Run qemu-hook-manager in your terminal
    • You should be root to have proper access rights to the hook directories
  2. Select your hardware to passthrough Pick Hardware
  3. Select the VMs you want to pass the hardware through to Pick VMs

CLI Switches

You may bypass parts of or the entire guided experience qemu-hook-manager provides by invoking it with appropriate CLI switches.

| Switch | Type | Examples/Notes | |----------------|---------|-----------------------------------------------| | iommuGroups | string | "00:00:0" | | domains | string | "VM1" | | useOwnHooks | string | "yes" or "no" | | hooksDir | string | "/home/me/hooks" (use an absolute path) |

The iommuGroups and domains switches may be specified multiple times in a single command to specify more than one VM or piece of hardware.

For example, if you run the following command, you will skip the guided experience.

qemu-hook-manager --useOwnHooks=no --iommuGroups=07:00.0 --iommuGroups=07:00.1 --domains=My-Awesome-VM --domains=My-Other-Awesome-VM

Assuming that all supplied parameters are valid, the resulting hook structure in /etc/libvirt/hooks would look like this.

/etc/libvirt/hooks/
├── qemu
└── qemu.d
   ├── My-Awesome-VM -> /etc/libvirt/hooks/qemu.d/.qhm-passthrough
   ├── My-Other-Awesome-VM -> /etc/libvirt/hooks/qemu.d/.qhm-passthrough
   └── .qhm-passthrough
       ├── prepare
       │   └── begin
       │       ├── qhm_bind_vfio_00000700.0.sh
       │       └── qhm_bind_vfio_00000700.1.sh
       └── release
           └── end
               ├── qhm_unbind_vfio_00000700.0.sh
               └── qhm_unbind_vfio_00000700.1.sh

Custom Hooks

Adding a custom hook involves creating a folder for your scripts with a specific directory structure and an appropriately named script. You also need to pick the correct QEMU hook and state names. Then, you add your hook and state folders to a directory of your choice and drop your scripts into your state folders.

Directory Structure

Let's examine the built-in hook folder structure. You can construct your hooks using a similar directory structure.

/hooks
├── prepare
│   └── begin
│       └── qhm_bind_vfio_device.sh
└── release
   └── end
       └── qhm_unbind_vfio_device.sh

This example shows that the hooks directory has two subfolders, each named after a QEMU hook name (prepare and release). Each subfolder has a folder named after a QEMU hook state (begin for the prepare hook and end for the release hook). Under the begin and end directories, we have the default scripts.

Script Naming Conventions

You may create hooks for the states you care about by appropriately naming and organizing your folder structure. For example, if you wanted to launch a script at the start of a migration hook, you would make the following directory structure for your script.

/hooks
└── migrate
   └── begin
       └── qhm_<SCRIPT_NAME>_device.sh

Note: More than one script may be added per state.

Replace <SCRIPT_NAME> with a name of your choosing, but keep the "qhr_" prefix and "_device" segment. The "qhr_" prefix is used by qemu-hook-manager to identify it as a script it may manage. The "_device" segment will be replaced with the name of the IOMMU group for your hardware.

All scripts installed on the host system are passed through an environment variable substitution program that replaces any $IOMMU_GROUP_ID occurrences with the IOMMU group of the hardware being passed through. This is how you may reference the IOMMU group from within your scripts.

Available hook names and states include:

Hook|State :-----:|:-----: prepare|begin start|begin started|begin stopped|end release|end migrate|begin restore|begin reconnect|begin attach|begin

Further reading at https://www.libvirt.org/hooks.html#etc-libvirt-hooks-qemu

Development

Running Tests

The project uses Vitest for unit testing.

# Run tests once
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage report
npm run test:coverage

Building

npm run build

Linting & Formatting

npm run lint
npm run check-format
npm run format

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

License

This project is licensed under the BSD 2-Clause License. See the LICENSE file for details.

Contact

For any questions or issues, please open an issue on the GitHub repository.