[PATCH 3/4] domctl: Provide appropriate error code when VM events are not supported

Milan Djokic posted 4 patches 6 days, 22 hours ago
[PATCH 3/4] domctl: Provide appropriate error code when VM events are not supported
Posted by Milan Djokic 6 days, 22 hours ago
Return -EOPNOTSUPP when XEN_DOMCTL_set_access_required command is invoked
while VM events and monitoring support is disabled.

Signed-off-by: Milan Djokic <milan_djokic@epam.com>
---
 xen/common/domctl.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 159864bc99..5284524b42 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -787,19 +787,22 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
             copyback = true;
         break;
 
-#ifdef CONFIG_VM_EVENT
     case XEN_DOMCTL_set_access_required:
-        if ( unlikely(current->domain == d) ) /* no domain_pause() */
-            ret = -EPERM;
+        if ( !IS_ENABLED(CONFIG_VM_EVENT) )
+            ret = -EOPNOTSUPP;
         else
         {
-            domain_pause(d);
-            arch_p2m_set_access_required(d,
-                op->u.access_required.access_required);
-            domain_unpause(d);
+            if ( unlikely(current->domain == d) ) /* no domain_pause() */
+                ret = -EPERM;
+            else
+            {
+                domain_pause(d);
+                arch_p2m_set_access_required(d,
+                    op->u.access_required.access_required);
+                domain_unpause(d);
+            }
         }
         break;
-#endif
 
     case XEN_DOMCTL_set_virq_handler:
         ret = set_global_virq_handler(d, op->u.set_virq_handler.virq);
-- 
2.43.0
Re: [PATCH 3/4] domctl: Provide appropriate error code when VM events are not supported
Posted by Jan Beulich 4 days, 6 hours ago
On 05.12.2025 21:36, Milan Djokic wrote:
> Return -EOPNOTSUPP when XEN_DOMCTL_set_access_required command is invoked
> while VM events and monitoring support is disabled.

This is more bounded than the pretty wide subject. Taking the subject and
considering there are other VM_EVENT related domctl-s, is this one really
the only one in need of adjustment?

> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -787,19 +787,22 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>              copyback = true;
>          break;
>  
> -#ifdef CONFIG_VM_EVENT
>      case XEN_DOMCTL_set_access_required:
> -        if ( unlikely(current->domain == d) ) /* no domain_pause() */
> -            ret = -EPERM;
> +        if ( !IS_ENABLED(CONFIG_VM_EVENT) )
> +            ret = -EOPNOTSUPP;
>          else

If you convert this to

        else if ( unlikely(current->domain == d) ) /* no domain_pause() */

then ...

>          {
> -            domain_pause(d);
> -            arch_p2m_set_access_required(d,
> -                op->u.access_required.access_required);
> -            domain_unpause(d);
> +            if ( unlikely(current->domain == d) ) /* no domain_pause() */
> +                ret = -EPERM;
> +            else
> +            {
> +                domain_pause(d);
> +                arch_p2m_set_access_required(d,
> +                    op->u.access_required.access_required);
> +                domain_unpause(d);
> +            }

... the need for re-indenting disappears, and we get away with less churn.

Jan
Re: [PATCH 3/4] domctl: Provide appropriate error code when VM events are not supported
Posted by Milan Djokic 3 days, 6 hours ago
On 12/8/25 14:24, Jan Beulich wrote:
> On 05.12.2025 21:36, Milan Djokic wrote:
>> Return -EOPNOTSUPP when XEN_DOMCTL_set_access_required command is invoked
>> while VM events and monitoring support is disabled.
> 
> This is more bounded than the pretty wide subject. Taking the subject and
> considering there are other VM_EVENT related domctl-s, is this one really
> the only one in need of adjustment?
> 

I think that others, like monitor_op and event_op, already return 
-EOPNOTSUPP when CONFIG_VM_EVENT is disabled. I will check this, it 
could be that I missed some commands related to this context.

>> --- a/xen/common/domctl.c
>> +++ b/xen/common/domctl.c
>> @@ -787,19 +787,22 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>>               copyback = true;
>>           break;
>>   
>> -#ifdef CONFIG_VM_EVENT
>>       case XEN_DOMCTL_set_access_required:
>> -        if ( unlikely(current->domain == d) ) /* no domain_pause() */
>> -            ret = -EPERM;
>> +        if ( !IS_ENABLED(CONFIG_VM_EVENT) )
>> +            ret = -EOPNOTSUPP;
>>           else
> 
> If you convert this to
> 
>          else if ( unlikely(current->domain == d) ) /* no domain_pause() */
> 
> then ...
> 
>>           {
>> -            domain_pause(d);
>> -            arch_p2m_set_access_required(d,
>> -                op->u.access_required.access_required);
>> -            domain_unpause(d);
>> +            if ( unlikely(current->domain == d) ) /* no domain_pause() */
>> +                ret = -EPERM;
>> +            else
>> +            {
>> +                domain_pause(d);
>> +                arch_p2m_set_access_required(d,
>> +                    op->u.access_required.access_required);
>> +                domain_unpause(d);
>> +            }
> 
> ... the need for re-indenting disappears, and we get away with less churn.
> 

I’ll do that, thanks.

BR,
Milan