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

Re: [PATCH v2] xen: handle domain_shutdown() return values


  • To: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 2 Dec 2026 08:20:05 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID"
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: Mykola Kvach <Mykola_Kvach@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, George Dunlap <gwd@xxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 02 Dec 2026 07:20:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 01.12.2026 21:21, Mykola Kvach wrote:
> On Mon, Nov 23, 2026 at 10:19 AM Jan Beulich <jbeulich@xxxxxxxx> wrote:
>> On 20.11.2026 17:08, Mykola Kvach wrote:
>>> --- a/xen/arch/x86/compat.c
>>> +++ b/xen/arch/x86/compat.c
>>> @@ -39,14 +39,11 @@ long do_sched_op_compat(int cmd, unsigned long arg)
>>>      case SCHEDOP_shutdown:
>>>          TRACE_TIME(TRC_SCHED_SHUTDOWN,
>>>                     current->domain->domain_id, current->vcpu_id, arg);
>>> -        domain_shutdown(current->domain, (u8)arg);
>>> -        break;
>>> +        return domain_shutdown(current->domain, (u8)arg);
>>>
>>>      default:
>>>          return -ENOSYS;
>>>      }
>>> -
>>> -    return 0;
>>>  }
>>
>> I'm not quite sure whether we ought to alter the behavior of this (very)
>> legacy hypercall. The case you mention in the description (shim) post-
>> dates this hypercall's replacement by many years.
> 
> I tested a cancelled suspend through the legacy hypercall with PV32
> and PV64 test guests. Without the shim, both saw 1. With the shim,
> they saw 0 before v2 and 1 with v2. I haven't found a released guest
> that relies on this, so the change is only for consistency: the newer
> sched_op already returns this value in shim mode.
> 
> If you prefer, I can drop this hunk, or limit it to passing through
> the result for SHUTDOWN_suspend.

Well, personally I'd prefer (as said) that this hypercall wouldn't be
altered in behavior. Yet both here and ...

>>> @@ -1750,12 +1754,16 @@ void hvm_triple_fault(void)
>>>      struct vcpu *v = current;
>>>      struct domain *d = v->domain;
>>>      u8 reason = d->arch.hvm.params[HVM_PARAM_TRIPLE_FAULT_REASON];
>>> +    int rc;
>>>
>>>      gprintk(XENLOG_ERR,
>>>              "Triple fault - invoking HVM shutdown action %d\n",
>>>              reason);
>>>      vcpu_show_execution_state(v);
>>> -    domain_shutdown(d, reason);
>>> +    rc = domain_shutdown(d, reason);
>>> +    if ( unlikely(rc < 0) )
>>> +        gprintk(XENLOG_ERR, "Failed to shut down after triple fault: %d\n",
>>> +                rc);
>>>  }
>>
>> Here and ...
>>
>>> --- a/xen/common/sched/core.c
>>> +++ b/xen/common/sched/core.c
>>> @@ -1588,6 +1588,7 @@ static void cf_check domain_watchdog_timeout(void 
>>> *data)
>>>       */
>>>      struct domain *d = _p((unsigned long)data & PAGE_MASK);
>>>      unsigned int id = (unsigned long)data & ~PAGE_MASK;
>>> +    int rc;
>>>
>>>      BUILD_BUG_ON(alignof(*d) < PAGE_SIZE);
>>>
>>> @@ -1595,7 +1596,10 @@ static void cf_check domain_watchdog_timeout(void 
>>> *data)
>>>          return;
>>>
>>>      printk("Watchdog timer %u fired for %pd\n", id, d);
>>> -    domain_shutdown(d, SHUTDOWN_watchdog);
>>> +    rc = domain_shutdown(d, SHUTDOWN_watchdog);
>>> +    if ( unlikely(rc) )
>>> +        printk(XENLOG_G_ERR "Watchdog timer %u failed to shut down %pd: 
>>> %d\n",
>>> +               id, d, rc);
>>>  }
>>
>> ... here I wonder whether we shouldn't go farther than merely logging a
>> message. If the domain can't be "shut down", maybe it should be crashed?
> 
> domain_shutdown() can only fail in PV shim mode, where it forwards the
> request to L0. domain_crash() calls domain_shutdown() with
> SHUTDOWN_crash, which uses the same forwarding. So it would be a retry,
> not a separate fallback.
> 
> For the watchdog, I agree that a failed shutdown can leave the guest
> running. But a crash would make xl use on_crash instead of
> on_watchdog.
> 
> So I'd keep the log. If you still prefer a crash here, I'll add it.

... here other REST maintainers will want to voice an opinion, I think.

Jan



 


Rackspace

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