All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Vallejo <alejandro.vallejo@cloud.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Alejandro Vallejo <alejandro.vallejo@cloud.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
	Juergen Gross <jgross@suse.org>
Subject: [PATCH v2 4/7] tools: Make init-xenstore-domain use xc_domain_getinfolist()
Date: Fri, 28 Apr 2023 11:41:21 +0100	[thread overview]
Message-ID: <20230428104124.1044-5-alejandro.vallejo@cloud.com> (raw)
In-Reply-To: <20230428104124.1044-1-alejandro.vallejo@cloud.com>

It currently relies on xc_domain_getinfo() returning the next available
domain past "first_domid", which is a feature that will disappear in a
future patch.

Furthermore and while at it, make it so the hypercall tries to fetch information
about more than one domain per hypercall so we can (hopefully) get away with a
single hypercall in a typical system.

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wl@xen.org>
Cc: Juergen Gross <jgross@suse.org>
---
 tools/helpers/init-xenstore-domain.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c
index 0950ba7dc5..e210a2677e 100644
--- a/tools/helpers/init-xenstore-domain.c
+++ b/tools/helpers/init-xenstore-domain.c
@@ -13,6 +13,7 @@
 #include <xentoollog.h>
 #include <libxl.h>
 #include <xen/sys/xenbus_dev.h>
+#include <xen-tools/common-macros.h>
 #include <xen-xsm/flask/flask.h>
 #include <xen/io/xenbus.h>
 
@@ -322,16 +323,19 @@ err:
 
 static int check_domain(xc_interface *xch)
 {
-    xc_dominfo_t info;
+    xc_domaininfo_t info[8];
     uint32_t dom;
     int ret;
 
     dom = 1;
-    while ( (ret = xc_domain_getinfo(xch, dom, 1, &info)) == 1 )
+    while ( (ret = xc_domain_getinfolist(xch, dom, ARRAY_SIZE(info), info)) > 0 )
     {
-        if ( info.xenstore )
-            return 1;
-        dom = info.domid + 1;
+        for ( size_t i = 0; i < ret; i++ )
+        {
+            if ( info[i].flags & XEN_DOMINF_xs_domain )
+                return 1;
+        }
+        dom = info[ret - 1].domain + 1;
     }
     if ( ret < 0 && errno != ESRCH )
     {
-- 
2.34.1



  parent reply	other threads:[~2023-04-28 10:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 10:41 [PATCH v2 0/7] Rationalize usage of xc_domain_getinfo{,list}() Alejandro Vallejo
2023-04-28 10:41 ` [PATCH v2 1/7] tools: Make some callers of xc_domain_getinfo() use xc_domain_getinfolist() Alejandro Vallejo
2023-04-28 12:19   ` Marek Marczykowski-Górecki
2023-04-28 12:21   ` Andrew Cooper
2023-04-28 10:41 ` [PATCH v2 2/7] tools: Create xc_domain_getinfo_single() Alejandro Vallejo
2023-04-28 12:23   ` Andrew Cooper
2023-04-28 10:41 ` [PATCH v2 3/7] tools: Refactor console/io.c to avoid using xc_domain_getinfo() Alejandro Vallejo
2023-04-28 12:33   ` Andrew Cooper
2023-04-28 12:43     ` Andrew Cooper
2023-04-28 12:58     ` Alejandro Vallejo
2023-04-28 10:41 ` Alejandro Vallejo [this message]
2023-04-28 12:40   ` [PATCH v2 4/7] tools: Make init-xenstore-domain use xc_domain_getinfolist() Andrew Cooper
2023-04-28 12:45     ` Alejandro Vallejo
2023-04-28 13:10   ` Andrew Cooper
2023-04-28 10:41 ` [PATCH v2 5/7] tools: Modify single-domid callers of xc_domain_getinfolist() Alejandro Vallejo
2023-04-28 15:22   ` Andrew Cooper
2023-04-28 10:41 ` [PATCH v2 6/7] tools: Use new xc function for some xc_domain_getinfo() calls Alejandro Vallejo
2023-04-28 16:29   ` Andrew Cooper
2023-04-28 10:41 ` [PATCH v2 7/7] domctl: Modify XEN_DOMCTL_getdomaininfo to fail if domid is not found Alejandro Vallejo
2023-04-28 14:05   ` Andrew Cooper

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=20230428104124.1044-5-alejandro.vallejo@cloud.com \
    --to=alejandro.vallejo@cloud.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jgross@suse.org \
    --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.