Page MenuHomeFreeBSD

D60125.diff
No OneTemporary

D60125.diff

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

Mime Type
text/plain
Expires
Mon, Oct 5, 3:27 AM (9 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40208382
Default Alt Text
D60125.diff (1 KB)

Event Timeline