py-libvirt problems with bhyve

Craig Rodrigues rodrigc at FreeBSD.org
Thu Jun 26 19:05:08 UTC 2014


On Wed, Jun 25, 2014 at 11:01 AM, Roman Bogorodskiy <novel at freebsd.org>
wrote:

>   Craig Rodrigues wrote:
>
> >
> > conn = libvirt.openReadOnly(None)
>                               ^^^
>
> I think here the URI should be 'bhyve:///system'.


> Or you could tweak libvirt.conf and assign the bhyve url value to the
> 'uri_default' parameter.
>
> http://libvirt.org/uri.html#URI_default
>
>

Hi

OK, I changed my steps a little bit.
I did the following:

(1)  Set up libvirt, taking Roman's latest port, and configuring bhyve
support:

      http://people.freebsd.org/~rodrigc/libvirt/libvirt-bhyve.html

(2)  Installed the py-libvirt port.


I wrote this code:

import libvirt
import sys

# Note we need to specify the URL here
conn = libvirt.openReadOnly("bhyve:///system")
if conn == None:
    print 'Failed to open connection to the hypervisor'
    sys.exit(1)

try:
    print("All domains: ",conn.listAllDomains())
    print("Defined domains: ", conn.listDefinedDomains())
    #print dir(conn)
    dom0 = conn.lookupByName("bhyve")
except:
    print 'Failed to find the main domain'
    sys.exit(1)

print("Domain 0: id %d running" % (dom0.ID()))
print(dom0.info())



I got this:

('All domains: ', [<libvirt.virDomain object at 0x801f50550>])
('Defined domains: ', ['bhyve'])
Domain 0: id -1 running
('Domain info: ', [5, 2147483L, 0L, 1, 0L])


So that's an improvement.


I started reading this tutorial on libvirt and KVM scripting:

https://www.ibm.com/developerworks/linux/library/os-python-kvm-scripting1/

In that tutorial, they give an example where it is possible
to configure the MAC and IP address of the VM in an XML config file.

Is it possible to do that with libvirt and bhyve?

Thanks.
--
Craig


More information about the freebsd-virtualization mailing list