Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Extending Red Hat Enterprise Virtualization with Vdsm hooks

<p>&nbsp;</p> <quillbot-extension-portal></quillbot-extension-portal>

February 25, 2014
Dan Kenigsberg
Related topics:
Virtualization
Related products:
Red Hat Enterprise Linux

    oVirt is an open source management system for KVM-powered virtual machines. Red Hat Enterprise Virtualization (RHEV) derives from oVirt in the same fashion that Red Hat Enterprise Linux is derived from Fedora. oVirt's (and RHEV's) central management component, called oVirt-Engine, is written in Java and runs on top of JBoss. Engine controls dozens of nodes that may run many dozens of VMs each.

    Besides sounding like an improper innuendo when pronounced by Spanish-speaking people, "Vdsm" is Engine's per-node agent. It's written in python and is responsible to prepare storage and network connectivity for the virtual machine, as well as for tracking the life cycle of the VM.

    When asked to fire up a VM, Vdsm converts Engine's xmlrpc vmCreate command to libvirt's domxml, libvirt converts it to qemu-kvm command line parameters.

    Adding a new feature to RHEV can be an intimidating process: you have to work your way from libvirt up the management stack to Vdsm, Engine, REST-API, and UI. Not every user, customer, or partner can afford to do that.

    For example, if someone wants to let his/her users choose super-duper fancy networking connectivity for their VMs, or to quickly test how a fresh Linux technology integrates with RHEV, we'd like to facilitate this.

    Come Vdsm hooks. Vdsm has several points where it can execute arbitrary scripts, as installed and configured by the local admin. When before a VM is started, right after it was migrated away, or after a hot-plugging of a vNIC has failed ‒ vdsmd's man page (8) lists them all. By far, the most interesting ones are before_vm_start and before_device_create. That's because they serve as a filter between Vdsm and libvirt.

    Their input consists of the libvirt xml description of the VM (or the specific device in device-specific hooks), and a bag of "custom properties", exposed as environment variables. The custom properties are attached to a VM (or to a vNIC profile) in Engine via its REST API or a simple GUI.

    All kinds of before_vm_start hooks exist in the upstream Vdsm repository. The hook named qemucmdline lets users try unsupported arguments to the qemu command line. macspoof allows guests to spoof their MAC address (which is usually prohibited by RHEV, but is required for in-guest bonding or intrusion prevention appliances.)

    I suppose that the best way to show the usefulness of Vdsm hooks is by a recent example. A few weeks ago, a user pinged me on IRC, asking whether RHEV can run VMs on his WiFi-only laptop. My answer was negative: RHEV's network configuration is based on setting up a Linux bridge and connecting it to an external NIC. But in Linux, you cannot connect a WiFi interface to a bridge

    $ sudo brctl addif br0 wlp3s0
    can't add wlp3s0 to bridge br0: Operation not supported

    That's a shame since libvirt supports connecting the Linux bridge to the outer world using
    NAT and an oVirt user named "Dead Horse" had to jump through hoops in order to use it as he explained.

    More recently, Humble Chirammal reported that another user would like to connect RHEV VMs to an OpenVSwitch bridge instead of the standard Linux bridge. Again, that's impossible out-of-the-box, and that's quite easy with libvirt.

    That was the last straw for publishing a new before_device_create Vdsm hook. If you have fancy networking which libvirt supports and oVirt ‒ not yet, define a libvirt
    network named "glitter" on your hosts. And do not forget to install the extnet hook, too. The latter step means dropping an executable under /usr/libexec/vdsm/hooks/before_device_create/50_extnet or installing the vdsm-hook-extnet.rpm that includes it.

    On Engine, define a vNIC profile with a custom property named "extnet", with a value set to "glitter". Attach this profile to a vNIC in your VM, and have it connected to any VM network defined in your cluster (say, the predefined "rhevm" management network). It does not really matter which, since Vdsm with the extnet hook enabled, is going to ignore that part of your request.

    When the VM is started on a host, Vdsm creates the domain xml, to be passed to libvirt. It's <interface> element typically looks like

    <interface type="bridge">
    <address some-bus-and-address/>
    <mac address="52:54:00:59:F5:3F"/>
      <model type="virtio"/>
      <source bridge="rhevm"/>
      <filterref filter="no-mac-spoofing"/>
      <boot order="1"/>
      <driver name="vhost"/>
      <tune>
        <sndbuf>0</sndbuf>
      </tune>
      <bandwidth>
        <inbound average="1000" burst="1024" peak="5000"/>
        <outbound average="128" burst="256"/>
      </bandwidth>
    </interface>

    But then the hook kicks in: it simply replaces the <source bridge="rhevm"/>
    element to <source network="glitter"/> and changes the type of the interface element to <interface type="network"> accordingly. If everything was set as it should have, the traffic of the newly-started VM would now flow through the "glitter" network.

    I hope this post shows how useful Vdsm hooks can be, and how easy it is to write one. You're welcome to email vdsm-devel if you have any questions, comments, or rants.

    Last updated: December 1, 2023

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.