[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 2/4] tools/ocaml/libs/xc: add binding to xc_evtchn_status


  • To: Edwin Torok <edvin.torok@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Fri, 2 Dec 2022 11:43:05 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ov+dUSP7/wgxQhDdCQltZYKiswcTZExdjyQekQCHrY4=; b=lTpg6GsN6cDJLTSm9lkHU4w7O+RzaRRJgt7P6lG6jyGK5JKze/AH7+rZUbrSGWNq4SJ5ieusZKSN3K75dYx2wpI4f2omWgdrt9TEi5xchY/ijkqj6BHIL8vBRqjjx1e0F1oJi7U7Ga8gDS33sIfny/omQxyBD5XegCAduA5f07WG1IbDGKQQQrjTO2alSjYhDhfwqdvtdSizy8iI0F8ppUY/3F5cjRbOL4qSKQ012fUF4s9wBVN2ipX2c5NqasCIRWv54TmFcpD74FXgE6b1m0VD9Tnx1iODIctABWUAKPBpZpLyV1NhaHT7jevlUCe49yTlMmv9qMiHcaH25Ldexw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CcSNv58n3W9/P2T8hOdiuqtMcHVQ/6HHlHjsswVQhr5LiQQ+3fkB/fvV5Hl4kIAgmC3YdLuPs0TvlLt+/TG3OS6CKEUnt7eW8tyeTYYW4OC6dW0f5+SIaewcHXEVYR3z64mK0mAcuemNOolFq3sTlYDy4ERmWj87Ot6swvaJ9Fy7l0Pc2Daa6rlBds7whDudymDaubJQSGTOkuIKlerRgAHaSg3GvpEMyp4cIypa+LE4XWb6HQWGQkFDCutGVK3gXy9YpAoaegjxLeR9XVpp7MnU8BkHl9s6sEsPyAnAdNL5WiFU/CE9UzEDuzE0iFnFruL92h2A8DbYKqudxIyodw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Christian Lindig <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Fri, 02 Dec 2022 11:43:12 +0000
  • Ironport-data: A9a23:GuWkoaMH8S9R18fvrR2ElsFynXyQoLVcMsEvi/4bfWQNrUohhDQDn 2MeCGiDPq3fYWekKtBwaI3noUsH7ZWEx4JrGQto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQA+KmU4YoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGj9SuvzrRC9H5qyo4mpC5gZmP5ingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0udqHUh0+ OQiEQlOXgyGi+Ls4pe2U8A506zPLOGzVG8ekldJ6GiDSNMZG9XESaiM4sJE1jAtgMwIBezZe 8cSdTtoalLHfgFLPVAUTpk5mY9EhFGmK2Ee9A3T+/Rxvza7IA9ZidABNPL8fNCQSNoTtUGfv m/cpEzyAw0ANczZwj2Amp6prr+Sx32rCN1MfFG+3rlIrFOL2y8iMzwLeGCJiqKipRW9B90Kf iT4/QJr98De7neDXtT7GhG1vnOAlhodQMZLVf037hmXzajZ6BrfAXILJhZNYcIrnNU7Tjsr0 hmOhdyBLSNrmK2YTzSa7Lj8kN+pES0cLGtHYDBeSwIAuoPnuNtr0kyJSct/GqmoiNGzASv33 z2BsCk5gfMUkNIP0KK4u1vAhlpAu6T0c+L83S2PNkrN0++zTNfNi1CAgbQD0ct9EQ==
  • Ironport-hdrordr: A9a23:bxsJt6A59Ttaf2LlHemJ55DYdb4zR+YMi2TDtnoQdfUxSKelfq +V8sjzuSWE7Qr5O0tOpTnjAsi9qBrnnPYejOUs1NGZLXDbUQOTXeZfBKTZsl/d8kbFh4pgPM lbAtJDIey1IV9mjdvrpCmUeuxQveVuu8iT9IHjJgxWPGJXgnhbnn9E49CgYzZLeDU=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZBj2LflDJ6btqj0G8mw5XievwQq5aef4A
  • Thread-topic: [PATCH v2 2/4] tools/ocaml/libs/xc: add binding to xc_evtchn_status

On 02/12/2022 10:55, Edwin Török wrote:
> diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c 
> b/tools/ocaml/libs/xc/xenctrl_stubs.c
> index d30585f21c..a492ea17fd 100644
> --- a/tools/ocaml/libs/xc/xenctrl_stubs.c
> +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
> @@ -641,6 +645,69 @@ CAMLprim value stub_xc_evtchn_reset(value xch, value 
> domid)
>      CAMLreturn(Val_unit);
>  }
>  
> +CAMLprim value stub_xc_evtchn_status(value xch, value domid, value port)
> +{
> +    CAMLparam3(xch, domid, port);
> +    CAMLlocal4(result, result_status, stat, interdomain);
> +    xc_evtchn_status_t status = {
> +        .dom = _D(domid),
> +        .port = Int_val(port),
> +    };
> +    int rc;
> +
> +    caml_enter_blocking_section();
> +    rc = xc_evtchn_status(_H(xch), &status);
> +    caml_leave_blocking_section();
> +
> +    if ( rc < 0 )
> +        failwith_xc(_H(xch));
> +
> +    if ( status.status == EVTCHNSTAT_closed )
> +        CAMLreturn(Val_none);
> +
> +    switch ( status.status )
> +    {

The EVTCHNSTAT_closed wants to be a case here, otherwise it's really
weird to read from a C point of view.

It would be fine to have a comment like this:

case EVTCHNSTAT_closed:
    CAMLreturn(Val_none); /* Early exit, no allocations needed. */

to help identify more clearly that this a bit of a special case.

> +    case EVTCHNSTAT_unbound:
> +        stat = caml_alloc(1, 0); /* 1st non-constant constructor */
> +        Store_field(stat, 0, Val_int(status.u.unbound.dom));
> +        break;
> +
> +    case EVTCHNSTAT_interdomain:
> +        interdomain = caml_alloc_tuple(2);
> +        Store_field(interdomain, 0, Val_int(status.u.interdomain.dom));
> +        Store_field(interdomain, 1, Val_int(status.u.interdomain.port));
> +        stat = caml_alloc(1, 1); /*  2nd non-constant constructor */
> +        Store_field(stat, 0, interdomain);
> +        break;

Newline here.

> +    case EVTCHNSTAT_pirq:
> +        stat = caml_alloc(1, 2); /* 3rd non-constant constructor */
> +        Store_field(stat, 0, Val_int(status.u.pirq));
> +        break;
> +
> +    case EVTCHNSTAT_virq:
> +        stat = caml_alloc(1, 3); /* 4th non-constant constructor */
> +        Store_field(stat, 0, Val_int(status.u.virq));
> +        break;
> +
> +    case EVTCHNSTAT_ipi:
> +        stat = Val_int(0); /* 1st constant constructor */
> +        break;
> +
> +    default:
> +        caml_failwith("Unknown evtchn status");
> +
> +    }
> +    result_status = caml_alloc_tuple(2);
> +    Store_field(result_status, 0, Val_int(status.vcpu));
> +    Store_field(result_status, 1, stat);
> +
> +    /* caml_alloc_some is missing in older versions of OCaml
> +     */

I'd just drop this comment.  It's going to be many many years before
Ocaml 4.12 drops off the bottom of the support list, so this observation
is unactionable.

All 3 of these are trivial to fix on commit, so Reviewed-by: Andrew
Cooper <andrew.cooper3@xxxxxxxxxx> otherwise.

~Andrew

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.