Simple to use ruby interface to libvirt.

Libvirt is located at


  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.


for full API please visit


Connectivity Options

uri = "qemu:///system"              # libvirt running locally
uri = "qemu:/fqdn//system"          # used for QEMU+TLS connection
uri = "qemu+ssh:/[email protected]//system" # used for SSH connection
uri = "qemu+tcp:/fqdn//system"      # used for non secured tcp connection

Establish the connection

conn = Virt.connect(uri)

get the hypervisor

host =

get the list of running guests


get the list of stopped guests


or a simple hash of both


create a new guest{:name => "test123"})
guest.vcpu = 2
guest.volume.size = 10 # in GB

puts guest.mac

guest.shutdown     # initiate a shutdown
guest.poweroff     # forces a shutdown

Many more options exists, make sure checkout the api/tests

list of host bridges

host.interfaces # physical interfaces
host.networks   # virtual / NAT interfaces




Copyright © 2011 Ohad Levy

This program and entire repository is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <>.