From nobody Tue Jul 14 21:18:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1783842014; cv=none; d=zohomail.com; s=zohoarc; b=UOctDXL4yP3A7DPd11xttNAh9WV8hnRxsyrQfn7L6AvQlST4z4z+vyQeNN7VGS+LlDBcyKz1oNWG9A7/D8pk+C5ipblMicyQlIfYEI/1ZcgR5x+GUFyIW0UKNptoy7ztcnwzwYqfop24v+CPc4EQll0erSi+Po0vXoIH1Q/suUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783842014; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=JRsQrJyZEXn1fiKzknm9eiHpuZK3VEmOvaqkGlgph1g=; b=CLNKvuS9If9guphTQKJs2TDlXirEn7AlKEI3o4ZPcGEo5T48JO9upbvXTxVQZciEZq+G0potQKUYSPxfUpYmVap5Z3Z/+lELjzxaTXHwWhV6uAYHT4nQbyFbzG/aeOWTue/bYVtEYRoAk6xMjIUCCpVpaBGgHcUQOPjSMVs3XsY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1783842014803889.9585259551307; Sun, 12 Jul 2026 00:40:14 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 870B141D06; Sun, 12 Jul 2026 03:40:13 -0400 (EDT) Received: from [172.19.199.10] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id A82D841C34; Sun, 12 Jul 2026 03:38:23 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 92B5241C61; Sun, 12 Jul 2026 03:37:59 -0400 (EDT) Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 8948241D05 for ; Sun, 12 Jul 2026 03:36:28 -0400 (EDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-c1601d552a8so203367466b.2 for ; Sun, 12 Jul 2026 00:36:28 -0700 (PDT) Received: from tulp.my.domain (2001-1c02-1a15-3000-ee82-4536-a8f2-9e22.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:ee82:4536:a8f2:9e22]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c15cfac0f76sm646490466b.33.2026.07.12.00.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2026 00:36:26 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783841787; x=1784446587; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JRsQrJyZEXn1fiKzknm9eiHpuZK3VEmOvaqkGlgph1g=; b=iLcE8f6pKHwqy8oCUAyZegwUKob90DIF7uYbM/i8nWOanZoDVaL8hp4q2/6JJzTzbD AGm6UaUmcA3PrtNP1sNKHmhRA7YsfSagygzTkj5dT2fPRnS9uD2I9AY911yqbSDH+IjP XWQQ2o3zduNJqdscq6vdC5VStQXxt4V7a9u91KcrjxsZ4IGkI6eGHTbSNs+HsYABVqIE ARfkZWSVqHEUM8kR59mwBk1HOExAclFNwqyRvMns9PNCyX1EwBKo/OufDDQloJg7NYT+ 2bJGuLcSCeZWUzDw49K5nDXNMbFtm4a3HJ+2S8t3ib8Lp3pCwmdC0xqsR6r3X+76pf9E jvMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783841787; x=1784446587; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=JRsQrJyZEXn1fiKzknm9eiHpuZK3VEmOvaqkGlgph1g=; b=Vm+Ehnk82E7MFotzkWiukH2bhgdJVip1TxVJgMGGoZAoFjRG8mEsAdzl8NYoZZ9XNq M4RBN2Z6lrF5jieAdgRI1B+TUAemgV1PzZ1wKV3o1S09+2JTowuf+HPzd+mYYD++7omP Tym5JIFoxVA3aONE1h+5SZkUiX56jbKsclBLkEgi+f0bbb+guYjlfXgMjAOQzt2Ai1cb U4YMEP43W9mVqvRqa3mr8YsF03lM9HPOiU8k5/RgtL5ojIlETNuPmTbV+lDEO5TTVeyu rXCmqnQ44DxhFeLVV5hS1hugZQnIq2rQ7BQCjGNlECvH0ZrIzBJyXgzsIZCfM5hXSENw bptw== X-Gm-Message-State: AOJu0YyyiBjnnCl87WlTjT2O9jbULVGhTcOMKHxdYmX9qo6SnlekJnX3 9xNf9VvSQMRPiy1SNzYvPtJv7MM191zYavFmSNSoWZjykwaFw4a9a/8ddW8ByT3V X-Gm-Gg: AfdE7cmUcldInYiQFtYrFYr5xwI0PMAAuaRwbG4OqEtPPwu1OFb7mXr/MF4xz927q1l HwA2f77Wi3uPwye04jkTZKIxOa0IZ8GaikUs4bYlSPOgt/EBHBWZNV0Y5nmQZYSiWhLn5OF4LRC 3D7X+V+yckKiT/Ug32tQ2xI8moqO/pl8XOPVO0NQ5U0oQ+P2pYui6B8YwrL+hh+bB7MJDiBeWNf yiEhzL1vFzwe2qr5OFm0liz10Qmeq8RK70ebMXYIAAE422pNf5KN/jICD22pqSFy9fsrG0sMNw/ mFi5F8ee7y+x5xJU1LE4j4gJDrC0MSVJjKaICTtVkIFfbnT1iq98jKJv6rtOXjeFamrXrYbQs3m Ss21ZKdFLvH+y0s0TyCIbqNDsyCwTP5yVg0uGwsiR/XM1gMntOAIBOF5c+xO1lnLC9iBJdp0u6O 1EVyIVwzFO16SHkMyRzEWX5f2MqIDPijdi4NF5zo1iERThUOgYGuZ3ywomoRWR9Ckm415UprF7s ynir5GmVpTJ9Musz5CtQOhuzoE= X-Received: by 2002:a17:907:706:b0:c15:d4f8:dade with SMTP id a640c23a62f3a-c161e8e7d15mr193601166b.2.1783841787146; Sun, 12 Jul 2026 00:36:27 -0700 (PDT) From: Roman Bogorodskiy To: devel@lists.libvirt.org Subject: [PATCH 1/3] bhyve: add validation for lifecycle actions Date: Sun, 12 Jul 2026 09:36:06 +0200 Message-ID: <20260712073608.6547-2-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260712073608.6547-1-bogorodskiy@gmail.com> References: <20260712073608.6547-1-bogorodskiy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NR5TULYTM433VZFQKMJLJFXYMSQGUV7P X-Message-ID-Hash: NR5TULYTM433VZFQKMJLJFXYMSQGUV7P X-MailFrom: bogorodskiy@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Roman Bogorodskiy X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783842014979158500 Content-Type: text/plain; charset="utf-8" The bhyve driver currently supports redefining 'onPoweroff' and 'onReboot', and possible actions are 'destroy' and 'restart'. Redefining 'onCrash' is not supported. Validate all these in bhyveDomainDefValidate(). Signed-off-by: Roman Bogorodskiy --- src/bhyve/bhyve_domain.c | 36 ++++++++++++++++++++++++++++++++++++ src/bhyve/bhyve_domain.h | 3 +++ 2 files changed, 39 insertions(+) diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index d5bb22501c..a215e562e7 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -462,6 +462,39 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef = *dev, } =20 =20 +int +bhyveValidateLifecycleAction(virDomainLifecycleAction onPoweroff, + virDomainLifecycleAction onReboot, + virDomainLifecycleAction onCrash) +{ + if ((onPoweroff !=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && + onPoweroff !=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART) || + (onReboot !=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && + onReboot !=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("bhyve driver supports only 'restart' and 'destro= y' actions for 'on_reboot'/'on_poweroff'")); + return -1; + } + + if (onCrash !=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("bhyve driver does not support 'on_crash' actions= other than 'destroy'")); + return -1; + } + + return 0; +} + + +static int +bhyveValidateDomainLifecycleAction(const virDomainDef *def) +{ + return bhyveValidateLifecycleAction(def->onPoweroff, + def->onReboot, + def->onCrash); +} + + static int bhyveDomainDefValidate(const virDomainDef *def, void *opaque G_GNUC_UNUSED, @@ -549,6 +582,9 @@ bhyveDomainDefValidate(const virDomainDef *def, return -1; } =20 + if (bhyveValidateDomainLifecycleAction(def) < 0) + return -1; + if (!def->os.loader) return 0; =20 diff --git a/src/bhyve/bhyve_domain.h b/src/bhyve/bhyve_domain.h index fa7a685d59..c9fa776651 100644 --- a/src/bhyve/bhyve_domain.h +++ b/src/bhyve/bhyve_domain.h @@ -55,3 +55,6 @@ extern virXMLNamespace virBhyveDriverDomainXMLNamespace; int virBhyveDomainObjStartWorker(virDomainObj *dom); void virBhyveDomainObjStopWorker(virDomainObj *dom); int bhyveDomainNamePathsCleanup(const char *name, bool bestEffort); +int bhyveValidateLifecycleAction(virDomainLifecycleAction onPoweroff, + virDomainLifecycleAction onReboot, + virDomainLifecycleAction onCrash); --=20 2.52.0 From nobody Tue Jul 14 21:18:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1783842134; cv=none; d=zohomail.com; s=zohoarc; b=LCkhnPAfiUo4syZN1tIky8dTydVzhTgybD9qcl/UnRyahsAOKvH1BI4+tXSeTBlOmXkeWXigEfS5ICVGIIKQDOSNKOUQ+WwsD2eaColfxHR3L1EQD8FkZterTMqiJWZcv7TexHNJ3vYJ62bzOSeyOwLginbzxrYlStLYydA3zKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783842134; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=/cZO1BHWYWelpxuvwm3vpovDoTUqP59SCUJ1TkDm0uw=; b=XY2/t0s4hPcB1cRRJOW8HagdfhI+d3sYTHHvE9GREApGiQEBW5p2x1HBFUQ1RwkcqTMXEZhgQx0XEIEccHuvOu85kYmtH8xkIQBjjzP2RV3y22AFgGvwHoW4Zmag7+C7s7OtAkY9vcm920b4AeLL7C8ed85DcPkrECWukbAw17M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1783842134739146.18464897630145; Sun, 12 Jul 2026 00:42:14 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 2960341C9A; Sun, 12 Jul 2026 03:42:12 -0400 (EDT) Received: from [172.19.199.10] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 8F65141E66; Sun, 12 Jul 2026 03:38:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 7A70C41BB4; Sun, 12 Jul 2026 03:38:00 -0400 (EDT) Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 08D4A41D86 for ; Sun, 12 Jul 2026 03:36:29 -0400 (EDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-c15ca7a7ca9so216081566b.0 for ; Sun, 12 Jul 2026 00:36:28 -0700 (PDT) Received: from tulp.my.domain (2001-1c02-1a15-3000-ee82-4536-a8f2-9e22.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:ee82:4536:a8f2:9e22]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c15cfac0f76sm646490466b.33.2026.07.12.00.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2026 00:36:27 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783841788; x=1784446588; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/cZO1BHWYWelpxuvwm3vpovDoTUqP59SCUJ1TkDm0uw=; b=szR00yNLAE4beKqT4rDsfGBK90OnIxjmlVIi3bTzEYsNuIFtPQwt4TffLwD9cxYESt 2e7TeJ9OoGaE6+WQVaONDlf0viB3eHQVgY6MG0wnsF6JnzUPGphbqOmdREiH8WoDbWmC 4a1Ivn7HYGwvgZggG4XERJ/EwA1aYB1CMJmXfHX3gf06hgNVPGX3vdenImam5kaGFwhR G8B6mlY3KbKudQ9GybFEXJwnFF+masamOG5QyAkcheD+4Znf/o8JY8zSzMFRo/jIV5Gq qsAU/R7S7Jj/x9cHOp33fSTKFkTJ7BuMtCkZ/dJr0qF5zG1aDNdHgdBXwW9zomgvXzc/ MvGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783841788; x=1784446588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/cZO1BHWYWelpxuvwm3vpovDoTUqP59SCUJ1TkDm0uw=; b=DuLBiNomBjN3tV+ibGgbov+kikqhGX8gusRDJrp6lry2d7Hs5frkxaZQx1jNGK1r+D eJHTFb1xt0Ua1xLmOsAZOQACq8POfzESBf7okzvciQZO/EYegh6RCvxSllp4ngHVCoV7 0kaGxN452lYqSRCVGymgfsWddd7j/BBw9lBCdohFrxC+iSrPI4pqX611/xhCdm9oAnli 2wwL8i9dC/9hI/T1I8YCLefZ2kjYV4kCqljvYGqSvoX4JTtYxVKILrv8dWj8Pyy64aIo sM+uCe2bn0Cvjn3LJFegc065xmZdJuHmKAfmeHAeNgzSc/sdyeyPN+6METyhcZ7i7hPj /HAA== X-Gm-Message-State: AOJu0Yz+nsEYr/lu95JtOh9ZkVan5EHnxLm/Xr+wLAmpm0ueMZ5cB/ux 2EtnLxC8cpBMhv6174OTJIgYH/Eqc/rulGi2TfO9awpOTme91BVR3F5rM/F5QDhr X-Gm-Gg: AfdE7cm9tEToPIoCBtaj5bR4OKFA9rcaJsqzIqHq0A9yhpCE+5bC9jau0EWK0q7tlw0 5paZYaCT9Usfu8z5bJBk023WHrWdJh5fUWfpEJkCgIi93eBr70grbuZHtyVv5uIvvf5XPJ4xKw7 T8vJDoD8IlX2MtqepKNZucyej5kbxd/bQUeEU4Hx22XdcPoW+LuZigG0JH/t0cYpjbvmXIvY6FJ M/QWBRhm7upy2/tWG3fLENDA4hI7OJgoK1JLhkG9KfKVS01aGP5yjuytIYB0zcNf2Ln6QkK1tQB qrlEZHr8zAjuv7FNfGg96NkQILv73D0wwfziqVEdw3Mpu+lVc119zNN4UXIoIDb8UAxECjH1quT iBisUwlzAlYj/3SU4VjP1xB+hjkCEIxm3ZmU7CvTDiaVUy5B3kq0iEF7iwggrkkw6bNkCRU3bmo VmkqZoNQPdBR4bIluBp96KJaCF5tkZJmI7N2xLsNA2IVLt11c9E44M2YRTbXGhEYScKTKw3b4sU hvz0iEHhKZRxzsCRWgLJuQmWUI= X-Received: by 2002:a17:906:9fce:b0:c16:11b2:ae9b with SMTP id a640c23a62f3a-c161e98c3ecmr195973666b.17.1783841787635; Sun, 12 Jul 2026 00:36:27 -0700 (PDT) From: Roman Bogorodskiy To: devel@lists.libvirt.org Subject: [PATCH 2/3] bhyve: monitor: respect on_poweroff / on_reboot settings Date: Sun, 12 Jul 2026 09:36:07 +0200 Message-ID: <20260712073608.6547-3-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260712073608.6547-1-bogorodskiy@gmail.com> References: <20260712073608.6547-1-bogorodskiy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: TPVZNM7VKSOOJXUVQEDMAPM7GMEHGPOY X-Message-ID-Hash: TPVZNM7VKSOOJXUVQEDMAPM7GMEHGPOY X-MailFrom: bogorodskiy@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Roman Bogorodskiy X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783842135344158500 Content-Type: text/plain; charset="utf-8" Currently, the bhyve driver respects domain's on_poweroff and on_reboot settings for when shutdown and reboot are triggered via libvirt API. However, they are not respected when the event is triggered within the guest. Address that by updating monitor to execute the configured action. Signed-off-by: Roman Bogorodskiy --- src/bhyve/bhyve_monitor.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/bhyve/bhyve_monitor.c b/src/bhyve/bhyve_monitor.c index 8cf4b41ca3..3be5ae89ad 100644 --- a/src/bhyve/bhyve_monitor.c +++ b/src/bhyve/bhyve_monitor.c @@ -157,12 +157,24 @@ bhyveMonitorIO(int watch, int kq, int events G_GNUC_U= NUSED, void *opaque) } else if (WIFEXITED(status)) { if (WEXITSTATUS(status) =3D=3D 0 || mon->reboot) { /* 0 - reboot */ - VIR_INFO("Guest %s rebooted; restarting domain.", name); - virBhyveProcessRestart(driver, vm); + if (vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_D= ESTROY || + vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_P= RESERVE) { + VIR_INFO("Guest %s rebooted; domain on_reboot setting = overridden, shutting down.", name); + virBhyveProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHU= TDOWN); + } else { + VIR_INFO("Guest %s rebooted; restarting domain.", name= ); + virBhyveProcessRestart(driver, vm); + } } else if (WEXITSTATUS(status) < 3) { /* 1 - shutdown, 2 - halt, 3 - triple fault. others - erro= r */ - VIR_INFO("Guest %s shut itself down; destroying domain.", = name); - virBhyveProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOW= N); + if (vm->def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION= _RESTART || + vm->def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION= _RESTART_RENAME) { + VIR_INFO("Guest %s shut itself down; domain on_powerof= f setting overridden, attempting reboot.", name); + virBhyveProcessRestart(driver, vm); + } else { + VIR_INFO("Guest %s shut itself down; destroying domain= .", name); + virBhyveProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHU= TDOWN); + } } else { VIR_INFO("Guest %s had an error and exited with status %d;= destroying domain.", name, WEXITSTATUS(status)); --=20 2.52.0 From nobody Tue Jul 14 21:18:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1783842080; cv=none; d=zohomail.com; s=zohoarc; b=awfLzv726OpGRtsv7AcjnVP6owtER+BS2TmxRmD6mVlhHeLeDaqzoxjDqNJL7zu2MejdyDnAv1/PsU0M7zfoKRoAXy4ajsCnmcuCJsp0wzMGZ+ClKnqf22gjXpf4U/BXHZ3UhjdUoix/kaeR72+3/22cEP1CLQ/elJHQzzC4+rc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783842080; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=CCIReg53Dgv+5mB1/wAAqvDatxMZWr6mnsORVEMFRaQ=; b=EEUwplW1R88lZuSiiNKwbQs6l+3lfiwtQuKvv7ZTpxKUa3isa6ukTxRqKwlkuLqjMB9Zi+Zgo1ONphIVFN1F1H6cX8uyqGPI8AM1UK/kZKkhzC1rs1zNh3K0j2QVb/Rau5Cses58NEDEqEN1MexwclhED15Ws01muXzhAfiUfuI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 17838420805943.700524100492771; Sun, 12 Jul 2026 00:41:20 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 4079B3F966; Sun, 12 Jul 2026 03:41:19 -0400 (EDT) Received: from [172.19.199.10] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id B13C241CC6; Sun, 12 Jul 2026 03:38:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 269704184C; Sun, 12 Jul 2026 03:37:59 -0400 (EDT) Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 9E4A841D77 for ; Sun, 12 Jul 2026 03:36:29 -0400 (EDT) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-697bd21fdc2so3666730a12.1 for ; Sun, 12 Jul 2026 00:36:29 -0700 (PDT) Received: from tulp.my.domain (2001-1c02-1a15-3000-ee82-4536-a8f2-9e22.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:ee82:4536:a8f2:9e22]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c15cfac0f76sm646490466b.33.2026.07.12.00.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2026 00:36:27 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783841788; x=1784446588; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CCIReg53Dgv+5mB1/wAAqvDatxMZWr6mnsORVEMFRaQ=; b=gyAW4NfJn3ojCiBkfgZ6TxKnSxov35hUGJcIzEpKT5edm3M26bC8vVFqvZ3kJZ9gI+ tbaMh63s16ERnJErJziWsyIocxLt/TVmu2MqqagvwKGWlJ1s92TPVQoIiGkbMIU0Hkrz Dmaet4uefESCo9M9dqKLZDSTq+gdb5IhFRgk8Hfuw0LwWWwqAMXFs94noQpIem4fi3oR RSCBkwa8xvcooOA/2OZbYFOMdKX+EfeHWQA+T0O0uHnWk3o1AR5tVkzOS3X295Zd3tiW S/FapAES0Hbda9wSq0EXEkhdbFxEUVwa5zd8K1L8WYcerQ8OBl7ZL83ElCPLmel+FSbw BtKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783841788; x=1784446588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=CCIReg53Dgv+5mB1/wAAqvDatxMZWr6mnsORVEMFRaQ=; b=RN+YKAlqiXVcz5C8wuYIwLNirK311ke23EpA9wBVfL5P46i4LXi4xPA2FfVvtit4Pv QXn0F7Lj7N2SXY6h/FLPnBlmkyrNKWvJDpovGNDSLMcOiKmGwy0Ji6zY0l66n24CTp/V fuP0nB+0Fd1YCzaPxl8bQu7U1O03JRjLv8KWLhrY39K/f7/dsZc6a3hLuvrs1BdA8bPy LCeR4+fS9l7dn5pxIFlyb+pkZJgr8/sMNDxcqG4dLEHwaVh1u80Jl87G9aJWt2B4M1ka qGRdc9DJXtYWNnsJNBIHGV3rMcF/DXs8gyZLQPwzRiAAsLVKb86MjR3DwoimYrzPrjmM v9yQ== X-Gm-Message-State: AOJu0YwTVwx+3HEPk/UYCPDv901580XT4iUbndSPKoIwO/9+4N9voGr+ joYPD0GV4XsYx2pVA7itgxpJpf5UmPaUMIA/o8+gkiZIeNos1rmHCJlC//UBjZCQ X-Gm-Gg: AfdE7cm9NQTpvywLWFbsDSE5nzxNQenjc0u0G2fmw//bYAygia82vIbAy/EMVQw+WE6 D78vkOQVTwQI3/DqsnR64q4hPkJVZIpx5V4fTVQp/V8dpLv4A1eyBUtQzuTv6LefAaVMCl8xDmz Fir3gxWNnK7eYtm81QG6mfqskRmt16ER57Y5IF0699eSbOSniK/gAbUabmBFfTH18YlAogfrl4X Aeu+qq6Or7ypXQ7AL17x9DkMmGhRSqfkjxuFnQiKYbR6EugEdjdoEteWPUjaKRNR/N9Q7T3CPVz dmg+BD8tFTuEUunZHb+7lSsUyu6KGudbbIRWZF4rOxd+5yKaCHnY2d1n557Ysst+soRsVoR84Eq SYKnhLYnKrlO0t/IegCKSJBMcPoRNBpm+asf7O7EfFeiO+Zs+YbQc2IQxPj3Ygv4d2CUyxpXmQ1 v7XwQ/Uf0DG/FF5OEzw8bN4zUy+x5i+qS0a8eNqB1qT7F9Cf5olhDc8wUFMoYP8iATChNcceCVl eN/A6IICqBgUkCXrmhuY8SofYI= X-Received: by 2002:a17:907:1c83:b0:c12:a588:4113 with SMTP id a640c23a62f3a-c161e9db968mr207059666b.29.1783841788226; Sun, 12 Jul 2026 00:36:28 -0700 (PDT) From: Roman Bogorodskiy To: devel@lists.libvirt.org Subject: [PATCH 3/3] bhyve: implement virDomainSetLifecycleAction() API Date: Sun, 12 Jul 2026 09:36:08 +0200 Message-ID: <20260712073608.6547-4-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260712073608.6547-1-bogorodskiy@gmail.com> References: <20260712073608.6547-1-bogorodskiy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: AD3JJB2BDDDQZS57OLU4H6FM3DSJDC5K X-Message-ID-Hash: AD3JJB2BDDDQZS57OLU4H6FM3DSJDC5K X-MailFrom: bogorodskiy@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Roman Bogorodskiy X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783842081351158500 Content-Type: text/plain; charset="utf-8" Implement virDomainSetLifecycleAction() API for the bhyve driver. Support both config and live configuration update. Signed-off-by: Roman Bogorodskiy --- src/bhyve/bhyve_driver.c | 110 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 668e46ad37..feeb140ba4 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -2807,6 +2807,115 @@ bhyveDomainRename(virDomainPtr domain, return ret; } =20 +static int +bhyveDomainSetLifecycleActionValidate(virDomainDef *def, + virDomainLifecycle type, + virDomainLifecycleAction action) +{ + virDomainLifecycleAction onPoweroff =3D def->onPoweroff; + virDomainLifecycleAction onReboot =3D def->onReboot; + virDomainLifecycleAction onCrash =3D def->onCrash; + + switch (type) { + case VIR_DOMAIN_LIFECYCLE_POWEROFF: + onPoweroff =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_REBOOT: + onReboot =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_CRASH: + onCrash =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_LAST: + break; + } + + if (bhyveValidateLifecycleAction(onPoweroff, onReboot, onCrash) < 0) + return -1; + + return 0; +} + +static void +bhyveDomainModifyLifecycleAction(virDomainDef *def, + virDomainLifecycle type, + virDomainLifecycleAction action) +{ + switch (type) { + case VIR_DOMAIN_LIFECYCLE_POWEROFF: + def->onPoweroff =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_REBOOT: + def->onReboot =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_CRASH: + def->onCrash =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_LAST: + break; + } +} + +static int +bhyveDomainSetLifecycleAction(virDomainPtr domain, + unsigned int type, + unsigned int action, + unsigned int flags) +{ + struct _bhyveConn *privconn =3D domain->conn->privateData; + virDomainObj *vm =3D NULL; + virDomainDef *def =3D NULL; + virDomainDef *persistentDef =3D NULL; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!virDomainDefLifecycleActionAllowed(type, action)) + goto cleanup; + + if (!(vm =3D bhyveDomObjFromDomain(domain))) + return -1; + + if (virDomainSetLifecycleActionEnsureACL(domain->conn, vm->def) < 0) + goto cleanup; + + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + goto cleanup; + + if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) + goto endjob; + + if ((def && bhyveDomainSetLifecycleActionValidate(def, type, action) <= 0) || + (persistentDef && bhyveDomainSetLifecycleActionValidate(persisten= tDef, type, action) < 0)) + goto endjob; + + if (def) { + bhyveDomainModifyLifecycleAction(def, type, action); + + if (virDomainObjSave(vm, privconn->xmlopt, + BHYVE_STATE_DIR) < 0) + goto endjob; + } + + if (persistentDef) { + bhyveDomainModifyLifecycleAction(persistentDef, type, action); + + if (virDomainDefSave(persistentDef, privconn->xmlopt, + BHYVE_CONFIG_DIR) < 0) + goto endjob; + } + + ret =3D 0; + + endjob: + virDomainObjEndJob(vm); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + static virHypervisorDriver bhyveHypervisorDriver =3D { .name =3D "bhyve", .connectURIProbe =3D bhyveConnectURIProbe, @@ -2885,6 +2994,7 @@ static virHypervisorDriver bhyveHypervisorDriver =3D { .domainAuthorizedSSHKeysGet =3D bhyveDomainAuthorizedSSHKeysGet, /* 12= .6.0 */ .domainAuthorizedSSHKeysSet =3D bhyveDomainAuthorizedSSHKeysSet, /* 12= .6.0 */ .domainRename =3D bhyveDomainRename, /* 12.6.0 */ + .domainSetLifecycleAction =3D bhyveDomainSetLifecycleAction, /* 12.7.0= */ }; =20 =20 --=20 2.52.0