All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Julien Grall" <julien@xen.org>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"Tamas K Lengyel" <tamas@tklengyel.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 4/4] tools/misc: Test for fault injection
Date: Wed, 23 Dec 2020 17:41:53 +0100	[thread overview]
Message-ID: <3fe99df6-ea2a-d877-8cb9-a4e7e84589d0@suse.com> (raw)
In-Reply-To: <20201223163442.8840-5-andrew.cooper3@citrix.com>

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


  reply	other threads:[~2020-12-23 16:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23 16:34 [PATCH 0/4] xen: domain-tracked allocations, and fault injection Andrew Cooper
2020-12-23 16:34 ` [PATCH 1/4] xen/dmalloc: Introduce dmalloc() APIs Andrew Cooper
2021-01-05 15:56   ` Jan Beulich
2021-01-13 23:16     ` Andrew Cooper
2021-01-14 10:14       ` Jan Beulich
2021-01-14 15:30         ` Andrew Cooper
2021-01-05 16:01   ` Jan Beulich
2022-12-11 17:24   ` Julien Grall
2020-12-23 16:34 ` [PATCH 2/4] xen/evtchn: Switch to dmalloc Andrew Cooper
2021-01-05 16:09   ` Jan Beulich
2020-12-23 16:34 ` [PATCH 3/4] xen/domctl: Introduce fault_ttl Andrew Cooper
2021-01-05 16:39   ` Jan Beulich
2021-01-13 23:58     ` Andrew Cooper
2020-12-23 16:34 ` [PATCH 4/4] tools/misc: Test for fault injection Andrew Cooper
2020-12-23 16:41   ` Jan Beulich [this message]
2021-01-08  1:49 ` [PATCH 0/4] xen: domain-tracked allocations, and " Stefano Stabellini
2022-12-11 17:21 ` Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3fe99df6-ea2a-d877-8cb9-a4e7e84589d0@suse.com \
    --to=jbeulich@suse.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tamas@tklengyel.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.