summaryrefslogtreecommitdiffstats
path: root/qemu/hw/core/qdev-properties.c
diff options
context:
space:
mode:
authorJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-05-18 13:18:31 +0300
committerJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-05-18 13:42:15 +0300
commit437fd90c0250dee670290f9b714253671a990160 (patch)
treeb871786c360704244a07411c69fb58da9ead4a06 /qemu/hw/core/qdev-properties.c
parent5bbd6fe9b8bab2a93e548c5a53b032d1939eec05 (diff)
These changes are the raw update to qemu-2.6.
Collission happened in the following patches: migration: do cleanup operation after completion(738df5b9) Bug fix.(1750c932f86) kvmclock: add a new function to update env->tsc.(b52baab2) The code provided by the patches was already in the upstreamed version. Change-Id: I3cc11841a6a76ae20887b2e245710199e1ea7f9a Signed-off-by: José Pekkarinen <jose.pekkarinen@nokia.com>
Diffstat (limited to 'qemu/hw/core/qdev-properties.c')
-rw-r--r--qemu/hw/core/qdev-properties.c214
1 files changed, 116 insertions, 98 deletions
diff --git a/qemu/hw/core/qdev-properties.c b/qemu/hw/core/qdev-properties.c
index 04fd80a4d..737d29c63 100644
--- a/qemu/hw/core/qdev-properties.c
+++ b/qemu/hw/core/qdev-properties.c
@@ -1,5 +1,8 @@
+#include "qemu/osdep.h"
#include "net/net.h"
#include "hw/qdev.h"
+#include "qapi/error.h"
+#include "hw/pci/pci.h"
#include "qapi/qmp/qerror.h"
#include "qemu/error-report.h"
#include "sysemu/block-backend.h"
@@ -41,19 +44,18 @@ void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
return ptr;
}
-static void get_enum(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_enum(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
int *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_enum(v, ptr, prop->info->enum_table,
- prop->info->name, prop->name, errp);
+ visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp);
}
-static void set_enum(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_enum(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -64,8 +66,7 @@ static void set_enum(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_enum(v, ptr, prop->info->enum_table,
- prop->info->name, prop->name, errp);
+ visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp);
}
/* Bit */
@@ -87,19 +88,19 @@ static void bit_prop_set(DeviceState *dev, Property *props, bool val)
}
}
-static void prop_get_bit(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void prop_get_bit(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
uint32_t *p = qdev_get_prop_ptr(dev, prop);
bool value = (*p & qdev_get_prop_mask(prop)) != 0;
- visit_type_bool(v, &value, name, errp);
+ visit_type_bool(v, name, &value, errp);
}
-static void prop_set_bit(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void prop_set_bit(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -111,7 +112,7 @@ static void prop_set_bit(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_bool(v, &value, name, &local_err);
+ visit_type_bool(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -145,19 +146,19 @@ static void bit64_prop_set(DeviceState *dev, Property *props, bool val)
}
}
-static void prop_get_bit64(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void prop_get_bit64(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
uint64_t *p = qdev_get_prop_ptr(dev, prop);
bool value = (*p & qdev_get_prop_mask64(prop)) != 0;
- visit_type_bool(v, &value, name, errp);
+ visit_type_bool(v, name, &value, errp);
}
-static void prop_set_bit64(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void prop_set_bit64(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -169,7 +170,7 @@ static void prop_set_bit64(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_bool(v, &value, name, &local_err);
+ visit_type_bool(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -186,18 +187,18 @@ PropertyInfo qdev_prop_bit64 = {
/* --- bool --- */
-static void get_bool(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_bool(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
bool *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_bool(v, ptr, name, errp);
+ visit_type_bool(v, name, ptr, errp);
}
-static void set_bool(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -208,7 +209,7 @@ static void set_bool(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_bool(v, ptr, name, errp);
+ visit_type_bool(v, name, ptr, errp);
}
PropertyInfo qdev_prop_bool = {
@@ -219,18 +220,18 @@ PropertyInfo qdev_prop_bool = {
/* --- 8bit integer --- */
-static void get_uint8(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_uint8(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_uint8(v, ptr, name, errp);
+ visit_type_uint8(v, name, ptr, errp);
}
-static void set_uint8(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -241,7 +242,7 @@ static void set_uint8(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_uint8(v, ptr, name, errp);
+ visit_type_uint8(v, name, ptr, errp);
}
PropertyInfo qdev_prop_uint8 = {
@@ -252,18 +253,18 @@ PropertyInfo qdev_prop_uint8 = {
/* --- 16bit integer --- */
-static void get_uint16(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_uint16(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
uint16_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_uint16(v, ptr, name, errp);
+ visit_type_uint16(v, name, ptr, errp);
}
-static void set_uint16(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_uint16(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -274,7 +275,7 @@ static void set_uint16(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_uint16(v, ptr, name, errp);
+ visit_type_uint16(v, name, ptr, errp);
}
PropertyInfo qdev_prop_uint16 = {
@@ -285,18 +286,18 @@ PropertyInfo qdev_prop_uint16 = {
/* --- 32bit integer --- */
-static void get_uint32(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_uint32(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_uint32(v, ptr, name, errp);
+ visit_type_uint32(v, name, ptr, errp);
}
-static void set_uint32(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_uint32(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -307,21 +308,21 @@ static void set_uint32(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_uint32(v, ptr, name, errp);
+ visit_type_uint32(v, name, ptr, errp);
}
-static void get_int32(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_int32(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_int32(v, ptr, name, errp);
+ visit_type_int32(v, name, ptr, errp);
}
-static void set_int32(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_int32(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -332,7 +333,7 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_int32(v, ptr, name, errp);
+ visit_type_int32(v, name, ptr, errp);
}
PropertyInfo qdev_prop_uint32 = {
@@ -349,18 +350,18 @@ PropertyInfo qdev_prop_int32 = {
/* --- 64bit integer --- */
-static void get_uint64(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_uint64(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_uint64(v, ptr, name, errp);
+ visit_type_uint64(v, name, ptr, errp);
}
-static void set_uint64(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_uint64(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -371,7 +372,7 @@ static void set_uint64(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_uint64(v, ptr, name, errp);
+ visit_type_uint64(v, name, ptr, errp);
}
PropertyInfo qdev_prop_uint64 = {
@@ -388,8 +389,8 @@ static void release_string(Object *obj, const char *name, void *opaque)
g_free(*(char **)qdev_get_prop_ptr(DEVICE(obj), prop));
}
-static void get_string(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_string(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -397,14 +398,14 @@ static void get_string(Object *obj, Visitor *v, void *opaque,
if (!*ptr) {
char *str = (char *)"";
- visit_type_str(v, &str, name, errp);
+ visit_type_str(v, name, &str, errp);
} else {
- visit_type_str(v, ptr, name, errp);
+ visit_type_str(v, name, ptr, errp);
}
}
-static void set_string(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_string(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -417,14 +418,12 @@ static void set_string(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_str(v, &str, name, &local_err);
+ visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
- if (*ptr) {
- g_free(*ptr);
- }
+ g_free(*ptr);
*ptr = str;
}
@@ -449,8 +448,8 @@ PropertyInfo qdev_prop_ptr = {
* 01:02:03:04:05:06
* 01-02-03-04-05-06
*/
-static void get_mac(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_mac(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -462,11 +461,11 @@ static void get_mac(Object *obj, Visitor *v, void *opaque,
mac->a[0], mac->a[1], mac->a[2],
mac->a[3], mac->a[4], mac->a[5]);
- visit_type_str(v, &p, name, errp);
+ visit_type_str(v, name, &p, errp);
}
-static void set_mac(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -480,7 +479,7 @@ static void set_mac(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_str(v, &str, name, &local_err);
+ visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -519,6 +518,16 @@ PropertyInfo qdev_prop_macaddr = {
.set = set_mac,
};
+/* --- on/off/auto --- */
+
+PropertyInfo qdev_prop_on_off_auto = {
+ .name = "OnOffAuto",
+ .description = "on/off/auto",
+ .enum_table = OnOffAuto_lookup,
+ .get = get_enum,
+ .set = set_enum,
+};
+
/* --- lost tick policy --- */
QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int));
@@ -543,13 +552,24 @@ PropertyInfo qdev_prop_bios_chs_trans = {
.set = set_enum,
};
+/* --- FDC default drive types */
+
+PropertyInfo qdev_prop_fdc_drive_type = {
+ .name = "FdcDriveType",
+ .description = "FDC drive type, "
+ "144/288/120/none/auto",
+ .enum_table = FloppyDriveType_lookup,
+ .get = get_enum,
+ .set = set_enum
+};
+
/* --- pci address --- */
/*
* bus-local address, i.e. "$slot" or "$slot.$fn"
*/
-static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_pci_devfn(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -563,11 +583,11 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_str(v, &str, name, &local_err);
+ visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_free(local_err);
local_err = NULL;
- visit_type_int32(v, &value, name, &local_err);
+ visit_type_int32(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
} else if (value < -1 || value > 255) {
@@ -619,8 +639,8 @@ PropertyInfo qdev_prop_pci_devfn = {
/* --- blocksize --- */
-static void set_blocksize(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_blocksize(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -634,7 +654,7 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_uint16(v, &value, name, &local_err);
+ visit_type_uint16(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -666,8 +686,8 @@ PropertyInfo qdev_prop_blocksize = {
/* --- pci host address --- */
-static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -680,15 +700,15 @@ static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
addr->domain, addr->bus, addr->slot, addr->function);
assert(rc == sizeof(buffer) - 1);
- visit_type_str(v, &p, name, errp);
+ visit_type_str(v, name, &p, errp);
}
/*
* Parse [<domain>:]<bus>:<slot>.<func>
* if <domain> is not supplied, it's assumed to be 0.
*/
-static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
@@ -705,7 +725,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_str(v, &str, name, &local_err);
+ visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -801,8 +821,8 @@ static void array_element_release(Object *obj, const char *name, void *opaque)
g_free(p);
}
-static void set_prop_arraylen(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_prop_arraylen(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
{
/* Setter for the property which defines the length of a
* variable-sized property array. As well as actually setting the
@@ -827,7 +847,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, void *opaque,
name);
return;
}
- visit_type_uint32(v, alenptr, name, &local_err);
+ visit_type_uint32(v, name, alenptr, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -1065,10 +1085,8 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev,
object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
if (err != NULL) {
assert(prop->user_provided);
- error_report("Warning: global %s.%s=%s ignored (%s)",
- prop->driver, prop->property, prop->value,
- error_get_pretty(err));
- error_free(err);
+ error_reportf_err(err, "Warning: global %s.%s=%s ignored: ",
+ prop->driver, prop->property, prop->value);
return;
}
}
@@ -1086,24 +1104,24 @@ void qdev_prop_set_globals(DeviceState *dev)
/* --- 64bit unsigned int 'size' type --- */
-static void get_size(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void get_size(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_size(v, ptr, name, errp);
+ visit_type_size(v, name, ptr, errp);
}
-static void set_size(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static void set_size(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_size(v, ptr, name, errp);
+ visit_type_size(v, name, ptr, errp);
}
PropertyInfo qdev_prop_size = {