git: 80d82fca1f0d - main - bhyve: add deprecation warning function

Mark Johnston <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a7b309a.249ed.3f7d5403__19628.9019937225$1786458299$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=80d82fca1f0d741173006021dafb259590f1d1d9

commit 80d82fca1f0d741173006021dafb259590f1d1d9
Author:     Nimish Jain <[email protected]>
AuthorDate: 2026-08-11 14:12:39 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-08-11 14:15:02 +0000

    bhyve: add deprecation warning function
    
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D58636
---
 usr.sbin/bhyve/amd64/bhyverun_machdep.c | 12 ++----------
 usr.sbin/bhyve/bhyverun.c               | 10 ++++++++++
 usr.sbin/bhyve/bhyverun.h               |  1 +
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/usr.sbin/bhyve/amd64/bhyverun_machdep.c b/usr.sbin/bhyve/amd64/bhyverun_machdep.c
index 2c8f825b4a7c..5b23807b30d5 100644
--- a/usr.sbin/bhyve/amd64/bhyverun_machdep.c
+++ b/usr.sbin/bhyve/amd64/bhyverun_machdep.c
@@ -266,16 +266,8 @@ bhyve_optparse(int argc, char **argv)
 	}
 
 	/* Handle backwards compatibility aliases in config options. */
-	if (get_config_value("lpc.bootrom") != NULL &&
-	    get_config_value("bootrom") == NULL) {
-		warnx("lpc.bootrom is deprecated, use '-o bootrom' instead");
-		set_config_value("bootrom", get_config_value("lpc.bootrom"));
-	}
-	if (get_config_value("lpc.bootvars") != NULL &&
-	    get_config_value("bootvars") == NULL) {
-		warnx("lpc.bootvars is deprecated, use '-o bootvars' instead");
-		set_config_value("bootvars", get_config_value("lpc.bootvars"));
-	}
+	bhyve_cfg_warn("lpc.bootrom", "bootrom");
+	bhyve_cfg_warn("lpc.bootvars", "bootvars");
 }
 
 void
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index ace631594544..09605b7c114f 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -242,6 +242,16 @@ out:
 	return (-1);
 }
 
+void
+bhyve_cfg_warn(const char *old, const char *new)
+{
+	if (get_config_value(old) != NULL &&
+	    get_config_value(new) == NULL) {
+		warnx("'%s' is deprecated, use '%s' instead", old, new);
+		set_config_value(new, get_config_value(old));
+	}
+}
+
 static void
 calc_mem_affinity(size_t vm_memsize)
 {
diff --git a/usr.sbin/bhyve/bhyverun.h b/usr.sbin/bhyve/bhyverun.h
index 5e6c81d008b8..a6fddd9f11f8 100644
--- a/usr.sbin/bhyve/bhyverun.h
+++ b/usr.sbin/bhyve/bhyverun.h
@@ -84,6 +84,7 @@ void bhyve_parse_gdb_options(const char *opt);
 int bhyve_pincpu_parse(const char *opt);
 int bhyve_topology_parse(const char *opt);
 int bhyve_numa_parse(const char *opt);
+void bhyve_cfg_warn(const char *old, const char *new);
 
 void bhyve_init_vcpu(struct vcpu *vcpu);
 void bhyve_start_vcpu(struct vcpu *vcpu, bool bsp);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.