From owner-freebsd-virtualization@FreeBSD.ORG Sun Jun 29 16:44:51 2014 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 844131F5; Sun, 29 Jun 2014 16:44:51 +0000 (UTC) Received: from mail-la0-x236.google.com (mail-la0-x236.google.com [IPv6:2a00:1450:4010:c03::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A02FE2757; Sun, 29 Jun 2014 16:44:50 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id mc6so4274606lab.27 for ; Sun, 29 Jun 2014 09:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=nfEjwxXbx97LaEpMZucxMGzcwxTcfZ93Ga6xAgJMfVo=; b=Br6fCKPneLo04k/gnnyuns+n9UIB4Mls/uigzK9Si9Lclp5d6tl4/QEOHtNNNdL4fJ D1IUC7f5CxtIRqQULPXNp+Bw58l4myAYrYjg9pGbHVrfh5Hr0WTkdSgQhrh8ifM9qOt8 XSdWVlpgsBXAN2SxjLAueCa545KsrqFwWuoZi6pXnOaSDKFCZr8+CxJ82YUgFRlwQonv /rH6yjS6aUFjY9N2GW/7NGHC/DeHgbwkuYLeQu44I6QjBgjYmMUvuL8HPAuv0RP9Mxa0 2kL6VWnZYYyW1A/ho94JGS2Qp332z/AL+ke9wqGkjDdXWaQYERr+e1Fy+R4IG+aOaLSS v2GA== X-Received: by 10.152.20.101 with SMTP id m5mr1650118lae.68.1404060288131; Sun, 29 Jun 2014 09:44:48 -0700 (PDT) Received: from kloomba ([217.65.223.117]) by mx.google.com with ESMTPSA id yr11sm20082607lbb.5.2014.06.29.09.44.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Jun 2014 09:44:47 -0700 (PDT) Sender: Roman Bogorodskiy Date: Sun, 29 Jun 2014 20:41:58 +0400 From: Roman Bogorodskiy To: Craig Rodrigues Subject: Re: py-libvirt problems with bhyve Message-ID: <20140629164157.GA17814@kloomba> References: <20140625180116.GA1304@kloomba> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+QahgC5+KEYLbs62" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Cc: "freebsd-virtualization@freebsd.org" , freebsd-python@freebsd.org X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jun 2014 16:44:51 -0000 --+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 > 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: ', []) > ('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: do the 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--