From nobody Tue Feb 10 11:55:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1623854630; cv=none; d=zohomail.com; s=zohoarc; b=WIBGWHACMhybrwRbkUD78wpk/kYkYwfp24QJb5Z5OHVnQ/y0/T0JT2T2X2Ywb4clZfr3ZTOMYllz185ik57Tcg3pnWmG5R40+pR0VxIQb6FRIj7h7LQU8Nc0MEOPHsqUskRGw1Jajk0HzlwnpZDzyGKuCF1IOND6AHpGGauoGDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623854630; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=NtHsRqFJ/9j0/O4AKrXX5mo/TDjv7sxBrn2GQynLUM8=; b=m8GMK9scjsTFPFUird9oNnzlpM0Vc/epxbO8+THNjyju8cc/4wEJNUkCK8oGdPXJ2cQGrPG2/SMFaaIGnT8EGtNXA8pSloAF918pGqxwbLQWM6EljCPLEzI2zPqZtk0ygREs4asGOEYIqV9cu8Kd4AKGw83jGIpeRz8AbIo6U2w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1623854630053205.27209274613722; Wed, 16 Jun 2021 07:43:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.143281.264131 (Exim 4.92) (envelope-from ) id 1ltWlQ-0005JS-HL; Wed, 16 Jun 2021 14:43:32 +0000 Received: by outflank-mailman (output) from mailman id 143281.264131; Wed, 16 Jun 2021 14:43:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ltWlQ-0005IK-AI; Wed, 16 Jun 2021 14:43:32 +0000 Received: by outflank-mailman (input) for mailman id 143281; Wed, 16 Jun 2021 14:43:31 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ltWlP-0005Fw-R6 for xen-devel@lists.xenproject.org; Wed, 16 Jun 2021 14:43:31 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ltWlO-0004Cu-NI; Wed, 16 Jun 2021 14:43:30 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltWlO-0007D0-EZ; Wed, 16 Jun 2021 14:43:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=NtHsRqFJ/9j0/O4AKrXX5mo/TDjv7sxBrn2GQynLUM8=; b=qy0Yl7SLc8nebkjHd6dzT+3G1 HiAD+0b2NTEFeji3acrVAe2Er1QrWgZT+SNC8ysP/0aXBk06BVprwuINaQxS5DU09/MfPG9EETbDG YF16eBb8l9f1vbTl9ZM4QszPAkv/KsiPvfk8IZbmzb9ALDwU90mbTVsatqlQiDjC1LXPY=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: raphning@amazon.co.uk, doebel@amazon.de, Julien Grall , Ian Jackson , Wei Liu , Juergen Gross , Julien Grall Subject: [PATCH 02/10] tools/xenstored: Introduce lu_get_connection() and use it Date: Wed, 16 Jun 2021 15:43:16 +0100 Message-Id: <20210616144324.31652-3-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210616144324.31652-1-julien@xen.org> References: <20210616144324.31652-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall At the moment, dump_state_buffered_data() is taking two connections in parameters (one is the connection to dump, the other is the connection used to request LU). The naming doesn't help to distinguish (c vs conn) them and this already lead to several mistake while modifying the function. To remove the confusion, introduce an help lu_get_connection() that will return the connection used to request LU and use it in place of the existing parameter. Signed-off-by: Julien Grall Reviewed-by: Juergen Gross Reviewed-by: Luca Fancellu --- tools/xenstore/xenstored_control.c | 13 ++++++++++++- tools/xenstore/xenstored_control.h | 2 ++ tools/xenstore/xenstored_core.c | 7 +++---- tools/xenstore/xenstored_core.h | 1 - tools/xenstore/xenstored_domain.c | 6 +++--- tools/xenstore/xenstored_domain.h | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tools/xenstore/xenstored_control.c b/tools/xenstore/xenstored_= control.c index 0d57f9f9400d..d08a2b961432 100644 --- a/tools/xenstore/xenstored_control.c +++ b/tools/xenstore/xenstored_control.c @@ -104,6 +104,17 @@ static const char *lu_begin(struct connection *conn) =20 return NULL; } + +struct connection *lu_get_connection(void) +{ + return lu_status ? lu_status->conn : NULL; +} + +#else +struct connection *lu_get_connection(void) +{ + return NULL; +} #endif =20 struct cmd_s { @@ -516,7 +527,7 @@ static const char *lu_dump_state(const void *ctx, struc= t connection *conn) ret =3D dump_state_global(fp); if (ret) goto out; - ret =3D dump_state_connections(fp, conn); + ret =3D dump_state_connections(fp); if (ret) goto out; ret =3D dump_state_special_nodes(fp); diff --git a/tools/xenstore/xenstored_control.h b/tools/xenstore/xenstored_= control.h index aac61f05908f..6842b8d88760 100644 --- a/tools/xenstore/xenstored_control.h +++ b/tools/xenstore/xenstored_control.h @@ -18,3 +18,5 @@ =20 int do_control(struct connection *conn, struct buffered_data *in); void lu_read_state(void); + +struct connection *lu_get_connection(void); diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_cor= e.c index 883a1a582a60..607187361d84 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -2369,14 +2369,13 @@ const char *dump_state_global(FILE *fp) =20 /* Called twice: first with fp =3D=3D NULL to get length, then for writing= data. */ const char *dump_state_buffered_data(FILE *fp, const struct connection *c, - const struct connection *conn, struct xs_state_connection *sc) { unsigned int len =3D 0, used; struct buffered_data *out, *in =3D c->in; bool partial =3D true; =20 - if (in && c !=3D conn) { + if (in && c !=3D lu_get_connection()) { len =3D in->inhdr ? in->used : sizeof(in->hdr); if (fp && fwrite(&in->hdr, len, 1, fp) !=3D 1) return "Dump read data error"; @@ -2416,8 +2415,8 @@ const char *dump_state_buffered_data(FILE *fp, const = struct connection *c, } =20 /* Add "OK" for live-update command. */ - if (c =3D=3D conn) { - struct xsd_sockmsg msg =3D conn->in->hdr.msg; + if (c =3D=3D lu_get_connection()) { + struct xsd_sockmsg msg =3D c->in->hdr.msg; =20 msg.len =3D sizeof("OK"); if (fp && fwrite(&msg, sizeof(msg), 1, fp) !=3D 1) diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_cor= e.h index bb36111ecc56..89ce155e755b 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -269,7 +269,6 @@ void set_tdb_key(const char *name, TDB_DATA *key); =20 const char *dump_state_global(FILE *fp); const char *dump_state_buffered_data(FILE *fp, const struct connection *c, - const struct connection *conn, struct xs_state_connection *sc); const char *dump_state_nodes(FILE *fp, const void *ctx); const char *dump_state_node_perms(FILE *fp, const struct xs_permissions *p= erms, diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index 322b0dbca449..6d8d29cbe41c 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -1183,7 +1183,7 @@ void wrl_apply_debit_trans_commit(struct connection *= conn) wrl_apply_debit_actual(conn->domain); } =20 -const char *dump_state_connections(FILE *fp, struct connection *conn) +const char *dump_state_connections(FILE *fp) { const char *ret =3D NULL; unsigned int conn_id =3D 1; @@ -1209,7 +1209,7 @@ const char *dump_state_connections(FILE *fp, struct c= onnection *conn) sc.spec.socket_fd =3D c->fd; } =20 - ret =3D dump_state_buffered_data(NULL, c, conn, &sc); + ret =3D dump_state_buffered_data(NULL, c, &sc); if (ret) return ret; head.length +=3D sc.data_in_len + sc.data_out_len; @@ -1219,7 +1219,7 @@ const char *dump_state_connections(FILE *fp, struct c= onnection *conn) if (fwrite(&sc, offsetof(struct xs_state_connection, data), 1, fp) !=3D 1) return "Dump connection state error"; - ret =3D dump_state_buffered_data(fp, c, conn, NULL); + ret =3D dump_state_buffered_data(fp, c, NULL); if (ret) return ret; ret =3D dump_state_align(fp); diff --git a/tools/xenstore/xenstored_domain.h b/tools/xenstore/xenstored_d= omain.h index cc5147d7e747..62ee471ea6aa 100644 --- a/tools/xenstore/xenstored_domain.h +++ b/tools/xenstore/xenstored_domain.h @@ -101,7 +101,7 @@ void wrl_log_periodic(struct wrl_timestampt now); void wrl_apply_debit_direct(struct connection *conn); void wrl_apply_debit_trans_commit(struct connection *conn); =20 -const char *dump_state_connections(FILE *fp, struct connection *conn); +const char *dump_state_connections(FILE *fp); const char *dump_state_special_nodes(FILE *fp); =20 void read_state_connection(const void *ctx, const void *state); --=20 2.17.1