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

Re: [PATCH 4/6] tools/libxs: Track whether we're using a socket or file


  • To: Jürgen Groß <jgross@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Tue, 23 Jul 2024 09:40:56 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ir6ivoKbjG2ShFOVatRVaHGKi7y0x55A9x5bEqif6r0=; b=daVN16DL6tGu+Nr2RL5zMXc04gBhwMMejYeuRIr5FkxLhrNyI4r2ZkxIZ1UgEnTe28CJocW8o8GBXXPiWV5ZRS9wmkzTGKsWN97IBWrBG++axhRL+LFATpigNEYmizB5jreP/YRVfEfA/de06dB/G/SIWulxAGaicpUO/cun/fUDCB/chGfyKWKJPnIkeYxyhb+cZUrdWqW6ClqhTAMHoDIV+nrYQzypj/ExJ8y172aQU1Tg4fnnhd5uMG4xUPByTGNPQjd5wEJv5cXjlDNGZZ3wa1+fRKmXiVVER37NJrfMWAQsK6cwa584nu6XGfo7cIoLSJISquyV/9mkUrigOA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qHU7s1o4bdW389Q3hqtTDyRdZ/w+6f76QxDwozczer+eg7VDBfNm8pvKGz5errx/L5r1Ip01qyail8iyEUVvjrQPmUZkn7yWN2woQQUs3YkyNzFf2Z4ggkxFYLiomED7AZx5PuloHYXgj1lLdAYb5GFFO8GCNFwblyhJ26ahqCeIeaOedGWbidQumSodvZsy1jcwgFw549juH5CcvCdKGgkJyt7BuHFakbhfG1WjOtQk5durgADB26gIBU/94o95LvUQMQLB7jXbCJnma8k2C4j4fC8l3tbDph1tg6rEgMMtrfxJMGIrrK6rFoMdHhkj/y5PrPOug1wiIVJyS4dzSg==
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Tue, 23 Jul 2024 14:04:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2024-07-23 08:08, Jürgen Groß wrote:
On 23.07.24 14:07, Andrew Cooper wrote:
On 23/07/2024 10:33 am, Jürgen Groß wrote:
On 18.07.24 18:48, Andrew Cooper wrote:
It will determine whether to use writev() or sendmsg().

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Anthony PERARD <anthony.perard@xxxxxxxxxx>
CC: Juergen Gross <jgross@xxxxxxxx>
---
   tools/libs/store/xs.c | 5 +++++
   1 file changed, 5 insertions(+)

diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
index 96ea2b192924..f4edeb05f03b 100644
--- a/tools/libs/store/xs.c
+++ b/tools/libs/store/xs.c
@@ -65,6 +65,9 @@ struct xs_stored_msg {
   struct xs_handle {
       /* Communications channel to xenstore daemon. */
       int fd;
+
+    bool is_socket; /* is @fd a file or socket? */
+
       Xentoolcore__Active_Handle tc_ah; /* for restrict */
         /*
@@ -305,6 +308,8 @@ static struct xs_handle *get_handle(const char
*connect_to)
       if (h->fd == -1)
           goto err;
   +    h->is_socket = S_ISSOCK(buf.st_mode);
+
       XEN_TAILQ_INIT(&h->reply_list);
       XEN_TAILQ_INIT(&h->watch_list);

I'd prefer to set h->is_socket above the current

     if (S_ISSOCK(buf.st_mode))

and then use h->is_socket in this if instead.

With that:

Reviewed-by: Juergen Gross <jgross@xxxxxxxx>

To confirm, you mean like this?

@@ -297,7 +300,9 @@ static struct xs_handle *get_handle(const char
*connect_to)
         if (stat(connect_to, &buf) != 0)
                 goto err;
-       if (S_ISSOCK(buf.st_mode))
+       h->is_socket = S_ISSOCK(buf.st_mode);
+
+       if (h->is_socket)
                 h->fd = get_socket(connect_to);
         else
                 h->fd = get_dev(connect_to);


Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>



 


Rackspace

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