aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/core/machine.c39
-rw-r--r--scripts/coverity-model.c17
-rw-r--r--tests/test-qemu-opts.c3
-rw-r--r--tests/test-qobject-output-visitor.c6
-rw-r--r--util/oslib-posix.c14
5 files changed, 65 insertions, 14 deletions
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 0699750336..0d92672203 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -585,11 +585,31 @@ static void machine_class_finalize(ObjectClass *klass, void *data)
g_free(mc->name);
}
+static void register_compat_prop(const char *driver,
+ const char *property,
+ const char *value)
+{
+ GlobalProperty *p = g_new0(GlobalProperty, 1);
+ /* Machine compat_props must never cause errors: */
+ p->errp = &error_abort;
+ p->driver = driver;
+ p->property = property;
+ p->value = value;
+ qdev_prop_register_global(p);
+}
+
+static void machine_register_compat_for_subclass(ObjectClass *oc, void *opaque)
+{
+ GlobalProperty *p = opaque;
+ register_compat_prop(object_class_get_name(oc), p->property, p->value);
+}
+
void machine_register_compat_props(MachineState *machine)
{
MachineClass *mc = MACHINE_GET_CLASS(machine);
int i;
GlobalProperty *p;
+ ObjectClass *oc;
if (!mc->compat_props) {
return;
@@ -597,9 +617,22 @@ void machine_register_compat_props(MachineState *machine)
for (i = 0; i < mc->compat_props->len; i++) {
p = g_array_index(mc->compat_props, GlobalProperty *, i);
- /* Machine compat_props must never cause errors: */
- p->errp = &error_abort;
- qdev_prop_register_global(p);
+ oc = object_class_by_name(p->driver);
+ if (oc && object_class_is_abstract(oc)) {
+ /* temporary hack to make sure we do not override
+ * globals set explicitly on -global: if an abstract class
+ * is on compat_props, register globals for all its
+ * non-abstract subtypes instead.
+ *
+ * This doesn't solve the problem for cases where
+ * a non-abstract typename mentioned on compat_props
+ * has subclasses, like spapr-pci-host-bridge.
+ */
+ object_class_foreach(machine_register_compat_for_subclass,
+ p->driver, false, p);
+ } else {
+ register_compat_prop(p->driver, p->property, p->value);
+ }
}
}
diff --git a/scripts/coverity-model.c b/scripts/coverity-model.c
index ee5bf9d078..c702804f41 100644
--- a/scripts/coverity-model.c
+++ b/scripts/coverity-model.c
@@ -67,18 +67,27 @@ static void __bufread(uint8_t *buf, ssize_t len)
int last = buf[len-1];
}
-MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
- uint8_t *buf, int len, bool is_write)
+MemTxResult address_space_read(AddressSpace *as, hwaddr addr,
+ MemTxAttrs attrs,
+ uint8_t *buf, int len)
{
MemTxResult result;
-
// TODO: investigate impact of treating reads as producing
// tainted data, with __coverity_tainted_data_argument__(buf).
- if (is_write) __bufread(buf, len); else __bufwrite(buf, len);
+ __bufwrite(buf, len);
+ return result;
+}
+MemTxResult address_space_write(AddressSpace *as, hwaddr addr,
+ MemTxAttrs attrs,
+ const uint8_t *buf, int len)
+{
+ MemTxResult result;
+ __bufread(buf, len);
return result;
}
+
/* Tainting */
typedef struct {} name2keysym_t;
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index f6310b34f1..0ad74b464f 100644
--- a/tests/test-qemu-opts.c
+++ b/tests/test-qemu-opts.c
@@ -93,8 +93,7 @@ static void test_find_unknown_opts(void)
/* should not return anything, we don't have an "unknown" option */
list = qemu_find_opts_err("unknown", &err);
g_assert(list == NULL);
- g_assert(err);
- error_free(err);
+ error_free_or_abort(&err);
}
static void test_qemu_find_opts(void)
diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
index 500b452d98..c213fceeb3 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -145,8 +145,7 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data,
for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
err = NULL;
visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err);
- g_assert(err);
- error_free(err);
+ error_free_or_abort(&err);
visitor_reset(data);
}
}
@@ -244,8 +243,7 @@ static void test_visitor_out_struct_errors(TestOutputVisitorData *data,
u.has_enum1 = true;
u.enum1 = bad_values[i];
visit_type_UserDefOne(data->ov, "unused", &pu, &err);
- g_assert(err);
- error_free(err);
+ error_free_or_abort(&err);
visitor_reset(data);
}
}
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 956f66ab4a..94d81b9ec0 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -361,7 +361,19 @@ static void *do_touch_pages(void *arg)
memset_thread_failed = true;
} else {
for (i = 0; i < numpages; i++) {
- memset(addr, 0, 1);
+ /*
+ * Read & write back the same value, so we don't
+ * corrupt existing user/app data that might be
+ * stored.
+ *
+ * 'volatile' to stop compiler optimizing this away
+ * to a no-op
+ *
+ * TODO: get a better solution from kernel so we
+ * don't need to write at all so we don't cause
+ * wear on the storage backing the region...
+ */
+ *(volatile char *)addr = *addr;
addr += hpagesize;
}
}