From nobody Fri Dec 19 20:16:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629816338; cv=none; d=zohomail.com; s=zohoarc; b=EZx5inw/wEo6BL5FXyRo7cxmZM0OCnQlNP2GhMh3L/Rqngoq4gHoqLg0JQylHS7aEe6JsjIATi9US/tnT6wXpCM85dst85Dc0H6sLmsnLKhsxnR1Lr6IYMUkNG7QdV1o8tTxl/Meaej24RYoF3l5iFVlf69DtXKmTfHuTj+osOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629816338; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=O+/uYdH8o50KncDo1PiEYG6pGzRKABiV5NagLvqY4mY=; b=NAwB4tJqIPBfeD1Z7L8U4/WbZeDHD5i1kIjsm/YwrCrigIBlTPqIelawT0RX9UzrVtuJumldaYcAs02DaUDUbVytp6jSahIHkbjwNh5z0/j1MjzpBmQAyNRRyoE/qn71hwkdMTrjDZO4Pmc8F2PxxzoM5kPYzrjpvJzb0Jbgp4U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1629816338069703.9612594982902; Tue, 24 Aug 2021 07:45:38 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-102-KHx3Ea8aMaSgahnVamVAMQ-1; Tue, 24 Aug 2021 10:45:35 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07789838E82; Tue, 24 Aug 2021 14:45:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D08CF1036D27; Tue, 24 Aug 2021 14:45:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 732CF4A70C; Tue, 24 Aug 2021 14:45:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17OEjREk005656 for ; Tue, 24 Aug 2021 10:45:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id B959E1ABD7; Tue, 24 Aug 2021 14:45:27 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17D4E17D4E for ; Tue, 24 Aug 2021 14:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629816337; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=O+/uYdH8o50KncDo1PiEYG6pGzRKABiV5NagLvqY4mY=; b=PSC5uh613daDBrOCdHiaAawHP4eNzcU5MWMeqHvd87BJuiYDYxjivuCGNQJkVteSyRpbtE vq3x272b8+95AWMY/FxVDL35EYGF2aTZegy/1vujhpzZTKUzNCsOK9f9YqqaZllfyc6XyS AiSFyPcsDU3Lipq6g3t5bkzupTvy9P4= X-MC-Unique: KHx3Ea8aMaSgahnVamVAMQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/22] qemu: Honor 'restart' action for 'on_poweroff' Date: Tue, 24 Aug 2021 16:44:29 +0200 Message-Id: <1c2b7c4e6395a528e3b3f8a7091efb8c30d20a5a.1629816141.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629816339398100001 Content-Type: text/plain; charset="utf-8" We simply terminate qemu instead of issuing a reset as the semantics of the setting dictate. Fix it by handling it identically to 'fake reboot'. We need to forbid the combination of 'onReboot' -> 'destroy' and 'onPoweroff' -> reboot though as the handling would be hairy and it honetly makes no sense. Signed-off-by: Peter Krempa --- docs/formatdomain.rst | 3 ++- src/qemu/qemu_process.c | 6 ++++-- src/qemu/qemu_validate.c | 9 +++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index a894a51c00..1f3136b3f2 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1747,7 +1747,8 @@ Each of these states allow for the same four possible= actions. supported by the libxl hypervisor driver.) QEMU/KVM supports the ``on_poweroff`` and ``on_reboot`` events handling the -``destroy`` and ``restart`` actions. +``destroy`` and ``restart`` actions, but the combiatnion of ``on_poweroff`= ` set +to ``restart`` and ``on_reboot`` set to ``destroy`` is forbidden. The ``on_crash`` event supports these additional actions :since:`since 0.8= .4` . diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 77da9992f4..5958a48182 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -543,7 +543,8 @@ qemuProcessShutdownOrReboot(virQEMUDriver *driver, { qemuDomainObjPrivate *priv =3D vm->privateData; - if (priv->fakeReboot) { + if (priv->fakeReboot || + vm->def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART) { g_autofree char *name =3D g_strdup_printf("reboot-%s", vm->def->na= me); virThread th; @@ -619,7 +620,8 @@ qemuProcessHandleShutdown(qemuMonitor *mon G_GNUC_UNUSE= D, /* In case of fake reboot qemu shutdown state is transient so don't * change domain state nor send events. */ - if (!priv->fakeReboot) { + if (!priv->fakeReboot || + vm->def->onPoweroff !=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART) { VIR_DEBUG("Transitioned guest %s to shutdown state", vm->def->name); virDomainObjSetState(vm, diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index d27c3b6c6c..8906aa52d9 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1089,6 +1089,15 @@ qemuValidateLifecycleAction(virDomainLifecycleAction= onPoweroff, return -1; } + /* the qemu driver can't meaningfully handle + * onPoweroff -> reboot + onReboot -> destroy */ + if (onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART && + onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("qemu driver doesn't support 'onReboot' set to 'd= estroy and 'onPoweroff' set to 'reboot'")); + return -1; + } + return 0; } --=20 2.31.1