Page MenuHomeFreeBSD

D33770.diff
No OneTemporary

D33770.diff

diff --git a/usr.sbin/bhyve/config.h b/usr.sbin/bhyve/config.h
--- a/usr.sbin/bhyve/config.h
+++ b/usr.sbin/bhyve/config.h
@@ -99,12 +99,24 @@
void set_config_value_node(nvlist_t *parent, const char *name,
const char *value);
+/*
+ * Similar to set_config_value_node but only sets value if it's unset yet.
+ */
+void set_config_value_node_if_unset(nvlist_t *const parent,
+ const char *const name, const char *const value);
+
/*
* Similar to set_config_value_node but expects a full path to the
* leaf node.
*/
void set_config_value(const char *path, const char *value);
+/*
+ * Similar to set_config_value but only sets the value if it's unset yet.
+ */
+void set_config_value_if_unset(const char *const path,
+ const char *const value);
+
/* Convenience wrappers for boolean variables. */
bool get_config_bool(const char *path);
bool get_config_bool_node(const nvlist_t *parent, const char *name);
diff --git a/usr.sbin/bhyve/config.c b/usr.sbin/bhyve/config.c
--- a/usr.sbin/bhyve/config.c
+++ b/usr.sbin/bhyve/config.c
@@ -135,6 +135,17 @@
nvlist_add_string(parent, name, value);
}
+void
+set_config_value_node_if_unset(nvlist_t *const parent, const char *const name,
+ const char *const value)
+{
+ if (get_config_value_node(parent, name) != NULL) {
+ return;
+ }
+
+ set_config_value_node(parent, name, value);
+}
+
void
set_config_value(const char *path, const char *value)
{
@@ -167,6 +178,16 @@
set_config_value_node(nvl, name, value);
}
+void
+set_config_value_if_unset(const char *const path, const char *const value)
+{
+ if (get_config_value(path) != NULL) {
+ return;
+ }
+
+ set_config_value(path, value);
+}
+
static const char *
get_raw_config_value(const char *path)
{

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 14, 11:55 PM (9 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14635429
Default Alt Text
D33770.diff (1 KB)

Event Timeline