Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Extending Red Hat Enterprise Virtualization with Vdsm hooks

 

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

Share:

    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

    • Storage considerations for OpenShift Virtualization

    • Upgrade from OpenShift Service Mesh 2.6 to 3.0 with Kiali

    • EE Builder with Ansible Automation Platform on OpenShift

    • How to debug confidential containers securely

    • Announcing self-service access to Red Hat Enterprise Linux for Business Developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    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
    © 2025 Red Hat

    Red Hat legal and privacy links

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

    Report a website issue