Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174549744
D60125.id187998.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
D60125.id187998.diff
View Options
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -846,16 +846,26 @@
bool
bhyve_parse_config_option(const char *option)
{
+ bool append = false;
const char *value;
char *path;
value = strchr(option, '=');
- if (value == NULL || value[1] == '\0')
+ if (value == NULL || value[1] == '\0' || value == option)
return (false);
- path = strndup(option, value - option);
+
+ if (value[-1] == '+')
+ append = true;
+
+ path = strndup(option, value - option - (append ? 1 : 0));
if (path == NULL)
err(4, "Failed to allocate memory");
- set_config_value(path, value + 1);
+
+ if (append)
+ append_config_value(path, value + 1);
+ else
+ set_config_value(path, value + 1);
+
free(path);
return (true);
}
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
@@ -124,6 +124,13 @@
void set_config_value_if_unset(const char *const path,
const char *const value);
+/*
+ * Similar to set_config_value but appends value to the existing value,
+ * separated by a comma.
+ */
+void append_config_value(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
@@ -233,6 +233,24 @@
return (NULL);
}
+void
+append_config_value(const char *path, const char *value)
+{
+ const char *old_value = get_raw_config_value(path);
+ char *new_value;
+
+ if (old_value == NULL)
+ new_value = strdup(value);
+ else
+ (void) asprintf(&new_value, "%s,%s", old_value, value);
+
+ if (new_value == NULL)
+ err(4, "Failed to allocate memory");
+
+ set_config_value(path, new_value);
+ free(new_value);
+}
+
static char *
_expand_config_value(const char *value, int depth)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 5, 2:34 AM (8 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40208382
Default Alt Text
D60125.id187998.diff (1 KB)
Attached To
Mode
D60125: bhyve: Config files should be able to append to existing config nodes
Attached
Detach File
Event Timeline
Log In to Comment