Date: Sun, 29 Jun 2014 20:41:58 +0400 From: Roman Bogorodskiy <novel@FreeBSD.org> To: Craig Rodrigues <rodrigc@FreeBSD.org> Cc: "freebsd-virtualization@freebsd.org" <freebsd-virtualization@freebsd.org>, freebsd-python@freebsd.org Subject: Re: py-libvirt problems with bhyve Message-ID: <20140629164157.GA17814@kloomba> In-Reply-To: <CAG=rPVfN-8uBx-UMF=90jevkP%2BOt=i9OL3=rKCBy9B7mfMqr0w@mail.gmail.com> References: <CAG=rPVdYf%2BaYP72owuaiecKxM7MHoDAioNpMGFJPu1G_S5fUZA@mail.gmail.com> <20140625180116.GA1304@kloomba> <CAG=rPVfN-8uBx-UMF=90jevkP%2BOt=i9OL3=rKCBy9B7mfMqr0w@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--+QahgC5+KEYLbs62 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Craig Rodrigues wrote: > On Wed, Jun 25, 2014 at 11:01 AM, Roman Bogorodskiy <novel@freebsd.org> > wrote: >=20 > > Craig Rodrigues wrote: > > > > > > > > conn =3D libvirt.openReadOnly(None) > > ^^^ > > > > I think here the URI should be 'bhyve:///system'. >=20 >=20 > > Or you could tweak libvirt.conf and assign the bhyve url value to the > > 'uri_default' parameter. > > > > http://libvirt.org/uri.html#URI_default > > > > >=20 > Hi >=20 > OK, I changed my steps a little bit. > I did the following: >=20 > (1) Set up libvirt, taking Roman's latest port, and configuring bhyve > support: >=20 > http://people.freebsd.org/~rodrigc/libvirt/libvirt-bhyve.html >=20 > (2) Installed the py-libvirt port. >=20 >=20 > I wrote this code: >=20 > import libvirt > import sys >=20 > # Note we need to specify the URL here > conn =3D libvirt.openReadOnly("bhyve:///system") > if conn =3D=3D None: > print 'Failed to open connection to the hypervisor' > sys.exit(1) >=20 > try: > print("All domains: ",conn.listAllDomains()) > print("Defined domains: ", conn.listDefinedDomains()) > #print dir(conn) > dom0 =3D conn.lookupByName("bhyve") > except: > print 'Failed to find the main domain' > sys.exit(1) >=20 > print("Domain 0: id %d running" % (dom0.ID())) > print(dom0.info()) >=20 >=20 >=20 > I got this: >=20 > ('All domains: ', [<libvirt.virDomain object at 0x801f50550>]) > ('Defined domains: ', ['bhyve']) > Domain 0: id -1 running > ('Domain info: ', [5, 2147483L, 0L, 1, 0L]) >=20 >=20 > So that's an improvement. >=20 >=20 > I started reading this tutorial on libvirt and KVM scripting: >=20 > https://www.ibm.com/developerworks/linux/library/os-python-kvm-scripting1/ >=20 > 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. >=20 > 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=3D'de:af:de:af:00:03' name=3D'vm-2' ip=3D'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 --+QahgC5+KEYLbs62 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (FreeBSD) iQEcBAEBAgAGBQJTsEHVAAoJEMltX/4IwiJqatkIAKncQVJGMDsaDsftyLaD5SzY S6Osw/egmVt45BxX9xnscLdbjSK7UxIV301O5j2eNL3FPmnLTscxBNWxND4LcAre NT4ocj1WXslfKful4MQu8x1d+ou6uIZkbZ7wUt6SmuSCh6WmGq/qf8kTpn5gbFJZ 1wb+7ZCXP4/AophbfYwS7A5dNwOWm7XQ9VDEC8VB2QBMDTpqOUjdYdboTRh3vdc6 BjNBHQaerYXxqh7v6QtOhDE50EB/Q8OEGz+D43SjtHioVhfruVGvcNEHSbm3YM+v 647ljViV3QARLhqrYLCd66Z77zPLKACFPjMEcYFYFsqBr7Mq0u4fCjn26YOJvwA= =Vamj -----END PGP SIGNATURE----- --+QahgC5+KEYLbs62--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140629164157.GA17814>