Craig Rodrigues wrote: > On Wed, Jun 25, 2014 at 11:01 AM, Roman Bogorodskiy <no...@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?
Generally, the dnsmasq related code is the same, so it should work. The script in this example seem to operate only on the network definition file, it misses the actual applying of the changes (or maybe I missed that in the article). I didn't try the script itself, but tried the suggested changes for the network definition, i.e. adding stuff like: <host mac='de:af:de:af:00:03' name='vm-2' ip='192.168.100.3' /> do the <dhcp> section. I did 'net-destroy default', then 'net-edit default', made this change, stopped the dnsmasq and did 'net-start default' (I'm not sure if it's a bug or a feature that dnsmasq didn't stop, need to look closer into that) and rebooted a domain. It seemed to work, it got the configured IP address and the hostname. Roman Bogorodskiy
Description: PGP signature