From nobody Mon Sep 21 12:43:44 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