On 23.12.2020 17:34, Andrew Cooper wrote: > --- /dev/null > +++ b/tools/misc/xen-fault-ttl.c > @@ -0,0 +1,56 @@ > +#include <stdio.h> > +#include <err.h> > +#include <string.h> > +#include <errno.h> > + > +#include <xenctrl.h> > + > +int main(int argc, char **argv) > +{ > + int rc; > + xc_interface *xch = xc_interface_open(NULL, NULL, 0); > + > + if ( !xch ) > + err(1, "xc_interface_open"); > + > + struct xen_domctl_createdomain create = { > + .fault_ttl = 1, > + .flags = (XEN_DOMCTL_CDF_hvm | > + XEN_DOMCTL_CDF_hap), > + .max_vcpus = 1, > + .max_evtchn_port = -1, > + .max_grant_frames = 64, > + .max_maptrack_frames = 1024, > + .arch = { > + .emulation_flags = XEN_X86_EMU_LAPIC, > + }, > + }; > + uint32_t domid = 0; > + > + for ( rc = 1; rc && errno == ENOMEM; create.fault_ttl++ ) > + rc = xc_domain_create(xch, &domid, &create);
The very first time you get here, how does errno end up being set to ENOMEM? To me do { create.fault_ttl++; rc = xc_domain_create(xch, &domid, &create); } while ( rc && errno == ENOMEM ); would seem more natural (and also avoid the somewhat odd "rc = 1"). Jan