[CFE-2203] Fails to detect Xen DomU running on FreeBSD Created: 21/Nov/15  Updated: 13/Nov/17  Resolved: 13/Nov/17

Status: Done
Project: CFEngine Community
Component/s: Environment Detection
Affects Version/s: None
Fix Version/s: 3.12.0, 3.10.3

Type: Bug Priority: High
Reporter: Franz Bettag Assignee: jimis (Dimitrios Apostolou)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Other (details)
Steps to reproduce: Not provided


CFEngine does not recognize running on a FreeBSD Xen domU. At least the xen_dom_* classes are not being set.

It is also really weird that you list old platforms like AIX and HP-UX as Bug-Platform, but not major Operating Systems like FreeBSD that run CFEngine for ages.

Comment by Franz Bettag [ 21/Nov/15 ]

The workaround for now is the following:

"xen_domu_hv" string => execresult("/sbin/sysctl -n kern.vm_guest", "noshell");

"xen_domu_hv" expression => strcmp("$(xen_domu_hv)", "xen");

Comment by Nick Anderson [ 21/Nov/15 ]

Here is a blind stab at an acceptance test. Can you enumerate the classes that you expected to be defined?

bundle agent test_meta
string => "Test that the agent can detect a xen domU and defines the
appropriate hard class.";

bundle agent check
string => "!freebsd",
meta =>

{ "redmine7734" };

string => "freebsd",
meta => { "redmine7734" }


"kern_vm_guest" string => execresult("/sbin/sysctl -n kern.vm_guest", "noshell");

slist => classesmatching("xen_domu_hv", "source=agent");

int => length(xen_domu_hv_hardclasses);

expression => strcmp("$(kern_vm_guest)", "xen"),
comment => "We see if we can manually detect xen_domu_hv condition";

expression => isgreaterthan($(count_xen_domu_hv_hardclasses), 0),
comment => "We see if there was a hard class defined for xen_domu_hv";

"ok" and =>

{ "xen_domu_hv_hardclass", "kern_vm_guest_xen_domu_hv" }

"ok" expression => "!(xen_domu_hv_hardclass|kern_vm_guest_xen_domu_hv)";
"fail" expression => "(xen_domu_hv_hardclass.!kern_vm_guest_xen_domu_hv)|(!xen_domu_hv_hardclass.kern_vm_guest_xen_domu_hv)

"$(this.promise_filename) Pass";
"$(this.promise_filename) FAIL";


Comment by Franz Bettag [ 21/Nov/15 ]

R: check.cf FAIL <- i hope that was what you where looking for

Comment by Nick Anderson [ 22/Nov/15 ]

Yeah I expected it to fail on your system, it really only tests that the class "xen_domu_hv" is a defined hard class from the agent. Where there any other classes that you expected it to set on your system?

Comment by Franz Bettag [ 23/Nov/15 ]

Nope. We only have FreeBSD HV DomUs or Physical hosts, thus i am not expecting anything else.

Comment by Steven Kreuzer [ 21/Nov/16 ]

Franz Bettag I have a patch out to the sysutils/cfengine39 package in the FreeBSD ports tree which addresses this issue. Would you mind testing it out and letting me know if it addresses the issues you are seeing? https://reviews.freebsd.org/D8607

Comment by Steven Kreuzer [ 01/Aug/17 ]

I just opened a pull request which should address this issue. If possible, can you help me test https://github.com/cfengine/core/pull/2896


Comment by jimis (Dimitrios Apostolou) [ 31/Oct/17 ]

This has been merged, the fix will be in 3.12, so closing ticket. Thanks!

EDIT: This patch has been in master long enough with no issue, so I just cherry-picked it into 3.10.3!

Generated at Sun Jan 20 03:42:08 PST 2019 using Jira 7.12.3#712004-sha1:5ef91d760d7124da5ebec5c16a948a4a807698df.