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

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


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Tue, 1 Dec 2026 22:21:27 +0200
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=4rDdBJgA03YkruEo8mDOdb+16/TbF+zZ/OBQ/3GdAMs=; fh=Ai+dBH31GAV4UGnaH59O+lvSNgFAGw7BBNAmYGv65dQ=; b=p5aZBZ9fM7o8p+rzg9mOHi83ASNM4m9LNHoHZA2UaV3xAfP9I7Vg0JVjTPZxM9lXsJ 2hf+IJyBhUMp4WrM0kmWYHGym6gcl1cX47j4BbsD3zE/Eq3Ai29lDi3krStEEInqPMQp BBQrLFwq2yghGTyr8FKL6KrdwxbwyNVQpdjrgKmapzN4U1I2YqAuKPx/Qb4PwAcKTX3k OX54Eak0wGXWjfNNlbGME8l70Jmby+WUSWsoaJrTDZA4C2xh3+xIBonAI2y5C/V+nIWA UNQJAowX5XD3TKqYlMAOhyvEa1TARprKqxmz44jn+10dyFXLPLPKRsBgibzVYNxvAXyk XdmQ==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1796156499; cv=none; d=google.com; s=arc-20260327; b=JJaIrSpn+njRFajuLPby87JkHOldmaBkDSqzIFhfkncBGZfhpaDYMqn7YdlD1SDdEe TYmcoMgnRj3HnrJgERy4VCxqqochUkmn6fW8+UTS/haB3SeIyHMrgKyG5GvC2tTvF1QY BUcCwg+QyRA4/PR0gNuXbM6qyfzWplk0beI9BHBkAXlEB2bFM+xDaTFG5IXixMgT6jUq eLdwLkdgMhcpjNvNr8A5WOh4YkuGEs4VZXSicQCQNuMhFk7wpWgoH/2Ylz55X2ZlGarh 4k/QK/+xQ62+rVG8lx7e3KHNKAL8ZyKb2mQCXSATf8H6SrCVY8iKByetk8uReVz8u6fE KS0Q==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • 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: Tue, 01 Dec 2026 20:21:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Jan,

Thank you for the review.

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.

>
> > @@ -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.

Best regards,
Mykola



 


Rackspace

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