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

[PATCH v4 06/24] xen/domctl: consolidate domain.c with MGMT_HYPERCALLS


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Fri, 21 Nov 2025 18:57:43 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org 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=igofeiLvOI2W8jum6hpl+MDDJaVYQ3ySBjvbKhyR/NY=; b=DpbZ2Xa5pE4Nmod+8kCkVAXSXAkO8hA6s4uglFeuCCc5OhuJARW8gKMn2RUIDAx8G1NRLfqKPDCqrh1nKhuDziGU5AAPe4/qycqtnDkBbCTSImJXbnpxzvq9/943t3FHtfkJiaiMWNO33+RpE5XN8f0a47eY8efpR0ZLYxR3cnef6ahaLRMfmP5Qk60VHyhegGXiYunAxhAZkEYbbdpdg7Jkpeo5M1/3CBZ+ZyjULT1cws2NG6cIPb1AbilSte54XbEvnNwGwejpau9rFGsrgMDJbtCJ+XRV4XP72NZh+Q7EFrwHEGs5BjYfX/Dd4k3tIhW2mDI8r1tuxx25iJwTmg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nr4I0SUGm+PIpXxucBhOrlwRKHcEbUermOaMdC9SCVKLY6ghjctC5D5Wy/DVIRvQtzUMGz7rRzvJgso8cJ40b/zPO1sw1xLBwHO5IR2UwBh9ATdEhpma3/kz/7wCc+on8MLU7xHgu4vy8QB5LArzsJx+11kN03SkaKzm7UTK27iiW8DQX+Sf0r98uXtUqzcnKf5Rl1uvDLA346iN6eTDORGHTM6kDWvIKQhYPcS9gQfB85nnB9NHnxgznJLFd4DQ7e7OuRJN+5i4G50wRpu+XBjbLaYGfmsG57hWjl6NsHlaO1y2h7phwL7QeAZp7xaajXr934AP/WjzGuPtjYHzow==
  • Cc: <ray.huang@xxxxxxx>, <grygorii_strashko@xxxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "Anthony PERARD" <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>
  • Delivery-date: Fri, 21 Nov 2025 10:58:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The following functions, scattered in common/domain.c, and are only referenced
and responsible for domctl-op:
- domain_pause_by_systemcontroller
- domain_resume
- domain_set_node_affinity
So they shall be wrapped with CONFIG_MGMT_HYPERCALLS. Otherwise it will
become unreachable codes when MGMT_HYPERCALLS=n, and hence violating Misra
rule 2.1.
Move them together to avoid scattering #ifdef.

Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
---
v3 - v4:
- combine commit "xen/domctl: wrap domain_pause_by_systemcontroller() with 
MGMT_HYPERCALLS",
"xen/domctl: wrap domain_resume() with CONFIG_MGMT_HYPERCALLS", and
"xen/domctl: wrap domain_set_node_affinity() with CONFIG_MGMT_HYPERCALLS"
---
 xen/common/domain.c | 114 ++++++++++++++++++++++----------------------
 1 file changed, 58 insertions(+), 56 deletions(-)

diff --git a/xen/common/domain.c b/xen/common/domain.c
index 6935b7d5e8..c6b0f931dc 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1115,35 +1115,6 @@ void __init setup_system_domains(void)
 #endif
 }
 
-int domain_set_node_affinity(struct domain *d, const nodemask_t *affinity)
-{
-    /* Being disjoint with the system is just wrong. */
-    if ( !nodes_intersects(*affinity, node_online_map) )
-        return -EINVAL;
-
-    spin_lock(&d->node_affinity_lock);
-
-    /*
-     * Being/becoming explicitly affine to all nodes is not particularly
-     * useful. Let's take it as the `reset node affinity` command.
-     */
-    if ( nodes_full(*affinity) )
-    {
-        d->auto_node_affinity = 1;
-        goto out;
-    }
-
-    d->auto_node_affinity = 0;
-    d->node_affinity = *affinity;
-
-out:
-    spin_unlock(&d->node_affinity_lock);
-
-    domain_update_node_affinity(d);
-
-    return 0;
-}
-
 /* rcu_read_lock(&domlist_read_lock) must be held. */
 static struct domain *domid_to_domain(domid_t dom)
 {
@@ -1361,33 +1332,6 @@ int domain_shutdown(struct domain *d, u8 reason)
     return 0;
 }
 
-void domain_resume(struct domain *d)
-{
-    struct vcpu *v;
-
-    /*
-     * Some code paths assume that shutdown status does not get reset under
-     * their feet (e.g., some assertions make this assumption).
-     */
-    domain_pause(d);
-
-    spin_lock(&d->shutdown_lock);
-
-    d->is_shutting_down = d->is_shut_down = 0;
-    d->shutdown_code = SHUTDOWN_CODE_INVALID;
-
-    for_each_vcpu ( d, v )
-    {
-        if ( v->paused_for_shutdown )
-            vcpu_unpause(v);
-        v->paused_for_shutdown = 0;
-    }
-
-    spin_unlock(&d->shutdown_lock);
-
-    domain_unpause(d);
-}
-
 int vcpu_start_shutdown_deferral(struct vcpu *v)
 {
     if ( v->defer_shutdown )
@@ -1616,10 +1560,68 @@ static int _domain_pause_by_systemcontroller(struct 
domain *d, bool sync)
     return 0;
 }
 
+#ifdef CONFIG_MGMT_HYPERCALLS
+int domain_set_node_affinity(struct domain *d, const nodemask_t *affinity)
+{
+    /* Being disjoint with the system is just wrong. */
+    if ( !nodes_intersects(*affinity, node_online_map) )
+        return -EINVAL;
+
+    spin_lock(&d->node_affinity_lock);
+
+    /*
+     * Being/becoming explicitly affine to all nodes is not particularly
+     * useful. Let's take it as the `reset node affinity` command.
+     */
+    if ( nodes_full(*affinity) )
+    {
+        d->auto_node_affinity = 1;
+        goto out;
+    }
+
+    d->auto_node_affinity = 0;
+    d->node_affinity = *affinity;
+
+out:
+    spin_unlock(&d->node_affinity_lock);
+
+    domain_update_node_affinity(d);
+
+    return 0;
+}
+
+void domain_resume(struct domain *d)
+{
+    struct vcpu *v;
+
+    /*
+     * Some code paths assume that shutdown status does not get reset under
+     * their feet (e.g., some assertions make this assumption).
+     */
+    domain_pause(d);
+
+    spin_lock(&d->shutdown_lock);
+
+    d->is_shutting_down = d->is_shut_down = 0;
+    d->shutdown_code = SHUTDOWN_CODE_INVALID;
+
+    for_each_vcpu ( d, v )
+    {
+        if ( v->paused_for_shutdown )
+            vcpu_unpause(v);
+        v->paused_for_shutdown = 0;
+    }
+
+    spin_unlock(&d->shutdown_lock);
+
+    domain_unpause(d);
+}
+
 int domain_pause_by_systemcontroller(struct domain *d)
 {
     return _domain_pause_by_systemcontroller(d, true /* sync */);
 }
+#endif /* CONFIG_MGMT_HYPERCALLS */
 
 int domain_pause_by_systemcontroller_nosync(struct domain *d)
 {
-- 
2.34.1




 


Rackspace

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