From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Bader Subject: Re: [libvirt] libvirt: [PATCH] libxl: Check for control_d string to decide about dom0 Date: Wed, 12 Mar 2014 13:20:30 +0100 Message-ID: <5320510E.4050406@canonical.com> References: <1394625806-21089-1-git-send-email-stefan.bader@canonical.com> <1394626131.21145.44.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4362494971431415636==" Return-path: In-Reply-To: <1394626131.21145.44.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com To: Ian Campbell Cc: libvir-list@redhat.com, xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============4362494971431415636== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ruVULHnM9mG68sQxJQd20pu5AsDifnLfE" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ruVULHnM9mG68sQxJQd20pu5AsDifnLfE Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12.03.2014 13:08, Ian Campbell wrote: > On Wed, 2014-03-12 at 13:03 +0100, Stefan Bader wrote: >> I have been looking into a bug report (see BugLink) which reported >> libvirt to fail starting inside a Xen guest. Upon further investigatio= n >> I found that some tools that help monitoring Xen guests will mount >> xenfs to /proc/xen. This will create a capabilities files there even >> if the guest is not dom0. However it will return nothing when reading >> from it. >=20 > This seems consistent with the xencommons initscript which does: > # run this script only in dom0: > # no capabilities file in xenlinux domU kernel > # empty capabilities file in pv_ops domU kernel > if test -f /proc/xen/capabilities && \ > ! grep -q "control_d" /proc/xen/capabilities ; then > exit 0 > fi >=20 >> >> Ian, just to sanity check myself. I looked at the xenfs code and to >> me there only seem to be those two outcomes (either "control_d" for >> running in dom0 or notrhing if not). >> >> With the following patch applied, libvirt starts up correctly in >> the normal guests (with xenfs mounted) without initializing libxl. >> And also in dom0 where it still enables the libxl driver (if the >> xl toolstack is selected). >> >> -Stefan >> >> From f11949caca6dfe1a802472a2a6d4fe760115ccc6 Mon Sep 17 00:00:00 2001= >> From: Stefan Bader >> Date: Wed, 12 Mar 2014 11:37:16 +0100 >> Subject: [PATCH] libxl: Check for control_d string to decide about dom= 0 >> >> As soon as any guest mounts xenfs to /proc/xen, there is a capabilitie= s >> file in that directory. However it returns nothing when reading from i= t. >> Change the test to actually check the contents of the file. >> >> BugLink: http://bugs.launchpad.net/bugs/1248025 >> >> Signed-off-by: Stefan Bader >> --- >> src/libxl/libxl_driver.c | 14 ++++++++++++-- >> 1 file changed, 12 insertions(+), 2 deletions(-) >> >> diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c >> index 65d80a2..844e828 100644 >> --- a/src/libxl/libxl_driver.c >> +++ b/src/libxl/libxl_driver.c >> @@ -944,6 +944,7 @@ libxlDriverShouldLoad(bool privileged) >> bool ret =3D false; >> virCommandPtr cmd; >> int status; >> + char *output =3D NULL; >> =20 >> /* Don't load if non-root */ >> if (!privileged) { >> @@ -951,8 +952,17 @@ libxlDriverShouldLoad(bool privileged) >> return ret; >> } >> =20 >> - /* Don't load if not running on a Xen control domain (dom0) */ >> - if (!virFileExists("/proc/xen/capabilities")) { >> + /* >> + * Don't load if not running on a Xen control domain (dom0). It i= s not >> + * sufficient to check for the file to exist as any guest can mou= nt >> + * xenfs to /proc/xen. >> + */ >> + status =3D virFileReadAll("/proc/xen/capabilities", 10. &output);= >=20 > Is this "." supposed to be a ","? Darn, I thought I had fixed that. Unfortunately in the wrong place. Yes, = that should be a ",". Sorry -Stefan >=20 >> + if (status >=3D 0) { >> + status =3D strncmp(output, "control_d", 9); >> + } >> + VIR_FREE(output); >> + if (status) { >> VIR_INFO("No Xen capabilities detected, probably not running = " >> "in a Xen Dom0. Disabling libxenlight driver"); >> =20 >=20 >=20 --ruVULHnM9mG68sQxJQd20pu5AsDifnLfE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCgAGBQJTIFEOAAoJEOhnXe7L7s6jU6MP/0aQ4nH/cXiGkzQ1Cd8ObFNj yLpF/Cj4SoGa8Ongthe13ekRyJPC+wkUGTkuCp3qLz3skDCwBtRtkN7QU3E0xJX0 Cl/cTYdsHibLGIRiKpTiXCgFk/ULJ66LVAYOWnzymfmJnmIKCc1LGGggDIGhu4LI vZkJSjd4ImkwuGRMLxQHlkPSQp1fDpA838s5ecscFGHHLTck5Mvbw/rxyu93Vm8f iltLDgnUOiNbIpp9EOEXEicV61eDEm3WGoqsmlPHRsdMppNIMtpP2xllDFRPfNN0 kYLDMHPG1vwi6eYkToOJipPj109PFOtRwn+/Dyn/ZCviuniqNE3c3/o46pRWQc6T prnSClVcSWXISEgAGNfJ4vIr9iEdNTiwlW/X9rUydxvQlbUCs1AT+q48cehvilGi D6JDG5xPUU7NqsqrHGipA4l3MRfHQZkPVKJ0XpWirQ8sTKDwdyOFCwtLd0hNKlaF h1jXB2741Q2pSOZtQ0pFCrCK+NyFZ0P0EhuHwoMzwRzmYk65YgrPHrCJUANfaVTY jcc++BN9yM++FhBp3HMbWPMIGA3NzJxzJyYXtYe27jF63kqx/28cBxTx7c0yz5Tk Pn+yk/0rKmpI9wyiyNlsBKl2XapwPpVMnK3WmqQWdKVqE5nWJBsJy2sVUkL68MAZ +Ek1VNyr61m0hi6SPMz8 =6GBU -----END PGP SIGNATURE----- --ruVULHnM9mG68sQxJQd20pu5AsDifnLfE-- --===============4362494971431415636== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============4362494971431415636==--