aboutsummaryrefslogtreecommitdiff
path: root/hw/core
diff options
context:
space:
mode:
Diffstat (limited to 'hw/core')
-rw-r--r--hw/core/qdev-properties-system.c30
-rw-r--r--hw/core/qdev-properties.c17
2 files changed, 44 insertions, 3 deletions
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 9aa8049..3f84309 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -25,6 +25,28 @@
#include "sysemu/iothread.h"
#include "sysemu/tpm_backend.h"
+static bool check_prop_still_unset(DeviceState *dev, const char *name,
+ const void *old_val, const char *new_val,
+ Error **errp)
+{
+ const GlobalProperty *prop = qdev_find_global_prop(dev, name);
+
+ if (!old_val) {
+ return true;
+ }
+
+ if (prop) {
+ error_setg(errp, "-global %s.%s=... conflicts with %s=%s",
+ prop->driver, prop->property, name, new_val);
+ } else {
+ /* Error message is vague, but a better one would be hard */
+ error_setg(errp, "%s=%s conflicts, and override is not implemented",
+ name, new_val);
+ }
+ return false;
+}
+
+
/* --- drive --- */
static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
@@ -299,14 +321,16 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
}
for (i = 0; i < queues; i++) {
-
if (peers[i]->peer) {
err = -EEXIST;
goto out;
}
- if (ncs[i]) {
- err = -EINVAL;
+ /*
+ * TODO Should this really be an error? If no, the old value
+ * needs to be released before we store the new one.
+ */
+ if (!check_prop_still_unset(dev, name, ncs[i], str, errp)) {
goto out;
}
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index ead35d7..71f8aca 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1246,6 +1246,23 @@ void qdev_prop_register_global(GlobalProperty *prop)
g_ptr_array_add(global_props(), prop);
}
+const GlobalProperty *qdev_find_global_prop(DeviceState *dev,
+ const char *name)
+{
+ GPtrArray *props = global_props();
+ const GlobalProperty *p;
+ int i;
+
+ for (i = 0; i < props->len; i++) {
+ p = g_ptr_array_index(props, i);
+ if (object_dynamic_cast(OBJECT(dev), p->driver)
+ && !strcmp(p->property, name)) {
+ return p;
+ }
+ }
+ return NULL;
+}
+
int qdev_prop_check_globals(void)
{
int i, ret = 0;