@@ -365,6 +365,14 @@ void qdev_prop_set_netdev(DeviceState *dev, const char *name,
value ? value->name : "", name, &error_abort);
}
+void qdev_prop_set_address_space(DeviceState *dev, const char *name,
+ AddressSpace *value)
+{
+ assert(!value || value->name);
+ object_property_set_str(OBJECT(dev),
+ value ? value->name : "", name, &error_abort);
+}
+
void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
{
qdev_prop_set_macaddr(dev, "mac", nd->macaddr.a);
@@ -1176,3 +1176,57 @@ PropertyInfo qdev_prop_size = {
.get = get_size,
.set = set_size,
};
+
+/* --- AddressSpace --- */
+
+static int parse_address_space(DeviceState *dev, const char *name,
+ AddressSpace **ptr)
+{
+ AddressSpace *as = address_space_find_by_name(name);
+ if (as == NULL) {
+ return -ENOENT;
+ }
+ *ptr = as;
+ return 0;
+}
+
+static void get_address_space(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ AddressSpace *as = qdev_get_prop_ptr(DEVICE(obj), opaque);
+ char *p = (char *) (as ? as->name : "");
+
+ visit_type_str(v, &p, name, errp);
+}
+
+static void set_address_space(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ DeviceState *dev = DEVICE(obj);
+ Property *prop = opaque;
+ Error *local_err = NULL;
+ AddressSpace **as = qdev_get_prop_ptr(dev, prop);
+ char *str;
+ int ret;
+
+ if (dev->realized) {
+ qdev_prop_set_after_realize(dev, name, errp);
+ return;
+ }
+
+ visit_type_str(v, &str, name, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ ret = parse_address_space(dev, str, as);
+ error_set_from_qdev_prop_error(errp, ret, dev, prop, str);
+ g_free(str);
+}
+
+PropertyInfo qdev_prop_address_space = {
+ .name = "address_space",
+ .get = get_address_space,
+ .set = set_address_space,
+};
@@ -19,6 +19,7 @@ extern PropertyInfo qdev_prop_size;
extern PropertyInfo qdev_prop_string;
extern PropertyInfo qdev_prop_chr;
extern PropertyInfo qdev_prop_ptr;
+extern PropertyInfo qdev_prop_address_space;
extern PropertyInfo qdev_prop_macaddr;
extern PropertyInfo qdev_prop_losttickpolicy;
extern PropertyInfo qdev_prop_bios_chs_trans;
@@ -141,6 +142,8 @@ extern PropertyInfo qdev_prop_arraylen;
#define DEFINE_PROP_PTR(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
+#define DEFINE_PROP_ADDRESS_SPACE(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_address_space, AddressSpace*)
#define DEFINE_PROP_CHR(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
#define DEFINE_PROP_STRING(_n, _s, _f) \
@@ -177,6 +180,8 @@ void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value);
+void qdev_prop_set_address_space(DeviceState *dev, const char *name,
+ AddressSpace *value);
void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value);
int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT;
@@ -26,4 +26,5 @@ stub-obj-y += uuid.o
stub-obj-y += vm-stop.o
stub-obj-y += vmstate.o
stub-obj-$(CONFIG_WIN32) += fd-register.o
+stub-obj-y += memory.o
stub-obj-y += cpus.o
new file mode 100644
@@ -0,0 +1,6 @@
+#include "exec/address-spaces.h"
+
+AddressSpace *address_space_find_by_name(const char *name)
+{
+ return NULL;
+}