Revision 313feaab

b/hw/qdev-properties.c
168 168
    .print = print_drive,
169 169
};
170 170

  
171
/* --- character device --- */
172

  
173
static int print_chr(DeviceState *dev, Property *prop, char *dest, size_t len)
174
{
175
    CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
176
    return snprintf(dest, len, "%s", (*ptr)->label);
177
}
178

  
179
PropertyInfo qdev_prop_chr = {
180
    .name  = "chr",
181
    .type  = PROP_TYPE_CHR,
182
    .size  = sizeof(CharDriverState*),
183
    .print = print_chr,
184
};
185

  
171 186
/* --- pointer --- */
172 187

  
173 188
static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len)
......
357 372
    qdev_prop_set(dev, name, &value, PROP_TYPE_DRIVE);
358 373
}
359 374

  
375
void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value)
376
{
377
    qdev_prop_set(dev, name, &value, PROP_TYPE_CHR);
378
}
379

  
360 380
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
361 381
{
362 382
    qdev_prop_set(dev, name, &value, PROP_TYPE_PTR);
b/hw/qdev.h
4 4
#include "hw.h"
5 5
#include "sysemu.h"
6 6
#include "sys-queue.h"
7
#include "qemu-char.h"
7 8
#include "qemu-option.h"
8 9

  
9 10
typedef struct Property Property;
......
65 66
    PROP_TYPE_TADDR,
66 67
    PROP_TYPE_MACADDR,
67 68
    PROP_TYPE_DRIVE,
69
    PROP_TYPE_CHR,
68 70
    PROP_TYPE_PTR,
69 71
};
70 72

  
......
155 157
extern PropertyInfo qdev_prop_uint64;
156 158
extern PropertyInfo qdev_prop_hex32;
157 159
extern PropertyInfo qdev_prop_hex64;
160
extern PropertyInfo qdev_prop_chr;
158 161
extern PropertyInfo qdev_prop_ptr;
159 162
extern PropertyInfo qdev_prop_macaddr;
160 163
extern PropertyInfo qdev_prop_drive;
......
192 195

  
193 196
#define DEFINE_PROP_PTR(_n, _s, _f)             \
194 197
    DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
198
#define DEFINE_PROP_CHR(_n, _s, _f)             \
199
    DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
195 200
#define DEFINE_PROP_MACADDR(_n, _s, _f)         \
196 201
    DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, uint8_t[6])
197 202

  
......
205 210
void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value);
206 211
void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
207 212
void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
213
void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
208 214
void qdev_prop_set_drive(DeviceState *dev, const char *name, DriveInfo *value);
209 215
/* FIXME: Remove opaque pointer properties.  */
210 216
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);

Also available in: Unified diff