Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102554380
D33770.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D33770.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D33770: bhyve: add nvlist functions for setting unset nodes
Attached
Detach File
Event Timeline
Log In to Comment