3 #include "qapi/qmp/qerror.h"
4 #include "sysemu/blockdev.h"
5 #include "hw/block-common.h"
7 #include "qapi/visitor.h"
10 void *qdev_get_prop_ptr(DeviceState
*dev
, Property
*prop
)
17 static void get_enum(Object
*obj
, Visitor
*v
, void *opaque
,
18 const char *name
, Error
**errp
)
20 DeviceState
*dev
= DEVICE(obj
);
21 Property
*prop
= opaque
;
22 int *ptr
= qdev_get_prop_ptr(dev
, prop
);
24 visit_type_enum(v
, ptr
, prop
->info
->enum_table
,
25 prop
->info
->name
, prop
->name
, errp
);
28 static void set_enum(Object
*obj
, Visitor
*v
, void *opaque
,
29 const char *name
, Error
**errp
)
31 DeviceState
*dev
= DEVICE(obj
);
32 Property
*prop
= opaque
;
33 int *ptr
= qdev_get_prop_ptr(dev
, prop
);
35 if (dev
->state
!= DEV_STATE_CREATED
) {
36 error_set(errp
, QERR_PERMISSION_DENIED
);
40 visit_type_enum(v
, ptr
, prop
->info
->enum_table
,
41 prop
->info
->name
, prop
->name
, errp
);
46 static uint32_t qdev_get_prop_mask(Property
*prop
)
48 assert(prop
->info
== &qdev_prop_bit
);
49 return 0x1 << prop
->bitnr
;
52 static void bit_prop_set(DeviceState
*dev
, Property
*props
, bool val
)
54 uint32_t *p
= qdev_get_prop_ptr(dev
, props
);
55 uint32_t mask
= qdev_get_prop_mask(props
);
63 static int print_bit(DeviceState
*dev
, Property
*prop
, char *dest
, size_t len
)
65 uint32_t *p
= qdev_get_prop_ptr(dev
, prop
);
66 return snprintf(dest
, len
, (*p
& qdev_get_prop_mask(prop
)) ? "on" : "off");
69 static void get_bit(Object
*obj
, Visitor
*v
, void *opaque
,
70 const char *name
, Error
**errp
)
72 DeviceState
*dev
= DEVICE(obj
);
73 Property
*prop
= opaque
;
74 uint32_t *p
= qdev_get_prop_ptr(dev
, prop
);
75 bool value
= (*p
& qdev_get_prop_mask(prop
)) != 0;
77 visit_type_bool(v
, &value
, name
, errp
);
80 static void set_bit(Object
*obj
, Visitor
*v
, void *opaque
,
81 const char *name
, Error
**errp
)
83 DeviceState
*dev
= DEVICE(obj
);
84 Property
*prop
= opaque
;
85 Error
*local_err
= NULL
;
88 if (dev
->state
!= DEV_STATE_CREATED
) {
89 error_set(errp
, QERR_PERMISSION_DENIED
);
93 visit_type_bool(v
, &value
, name
, &local_err
);
95 error_propagate(errp
, local_err
);
98 bit_prop_set(dev
, prop
, value
);
101 PropertyInfo qdev_prop_bit
= {
103 .legacy_name
= "on/off",
109 /* --- 8bit integer --- */
111 static void get_uint8(Object
*obj
, Visitor
*v
, void *opaque
,
112 const char *name
, Error
**errp
)
114 DeviceState
*dev
= DEVICE(obj
);
115 Property
*prop
= opaque
;
116 uint8_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
118 visit_type_uint8(v
, ptr
, name
, errp
);
121 static void set_uint8(Object
*obj
, Visitor
*v
, void *opaque
,
122 const char *name
, Error
**errp
)
124 DeviceState
*dev
= DEVICE(obj
);
125 Property
*prop
= opaque
;
126 uint8_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
128 if (dev
->state
!= DEV_STATE_CREATED
) {
129 error_set(errp
, QERR_PERMISSION_DENIED
);
133 visit_type_uint8(v
, ptr
, name
, errp
);
136 PropertyInfo qdev_prop_uint8
= {
142 /* --- 8bit hex value --- */
144 static int parse_hex8(DeviceState
*dev
, Property
*prop
, const char *str
)
146 uint8_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
149 if (str
[0] != '0' || str
[1] != 'x') {
153 *ptr
= strtoul(str
, &end
, 16);
154 if ((*end
!= '\0') || (end
== str
)) {
161 static int print_hex8(DeviceState
*dev
, Property
*prop
, char *dest
, size_t len
)
163 uint8_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
164 return snprintf(dest
, len
, "0x%" PRIx8
, *ptr
);
167 PropertyInfo qdev_prop_hex8
= {
169 .legacy_name
= "hex8",
176 /* --- 16bit integer --- */
178 static void get_uint16(Object
*obj
, Visitor
*v
, void *opaque
,
179 const char *name
, Error
**errp
)
181 DeviceState
*dev
= DEVICE(obj
);
182 Property
*prop
= opaque
;
183 uint16_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
185 visit_type_uint16(v
, ptr
, name
, errp
);
188 static void set_uint16(Object
*obj
, Visitor
*v
, void *opaque
,
189 const char *name
, Error
**errp
)
191 DeviceState
*dev
= DEVICE(obj
);
192 Property
*prop
= opaque
;
193 uint16_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
195 if (dev
->state
!= DEV_STATE_CREATED
) {
196 error_set(errp
, QERR_PERMISSION_DENIED
);
200 visit_type_uint16(v
, ptr
, name
, errp
);
203 PropertyInfo qdev_prop_uint16
= {
209 /* --- 32bit integer --- */
211 static void get_uint32(Object
*obj
, Visitor
*v
, void *opaque
,
212 const char *name
, Error
**errp
)
214 DeviceState
*dev
= DEVICE(obj
);
215 Property
*prop
= opaque
;
216 uint32_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
218 visit_type_uint32(v
, ptr
, name
, errp
);
221 static void set_uint32(Object
*obj
, Visitor
*v
, void *opaque
,
222 const char *name
, Error
**errp
)
224 DeviceState
*dev
= DEVICE(obj
);
225 Property
*prop
= opaque
;
226 uint32_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
228 if (dev
->state
!= DEV_STATE_CREATED
) {
229 error_set(errp
, QERR_PERMISSION_DENIED
);
233 visit_type_uint32(v
, ptr
, name
, errp
);
236 static void get_int32(Object
*obj
, Visitor
*v
, void *opaque
,
237 const char *name
, Error
**errp
)
239 DeviceState
*dev
= DEVICE(obj
);
240 Property
*prop
= opaque
;
241 int32_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
243 visit_type_int32(v
, ptr
, name
, errp
);
246 static void set_int32(Object
*obj
, Visitor
*v
, void *opaque
,
247 const char *name
, Error
**errp
)
249 DeviceState
*dev
= DEVICE(obj
);
250 Property
*prop
= opaque
;
251 int32_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
253 if (dev
->state
!= DEV_STATE_CREATED
) {
254 error_set(errp
, QERR_PERMISSION_DENIED
);
258 visit_type_int32(v
, ptr
, name
, errp
);
261 PropertyInfo qdev_prop_uint32
= {
267 PropertyInfo qdev_prop_int32
= {
273 /* --- 32bit hex value --- */
275 static int parse_hex32(DeviceState
*dev
, Property
*prop
, const char *str
)
277 uint32_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
280 if (str
[0] != '0' || str
[1] != 'x') {
284 *ptr
= strtoul(str
, &end
, 16);
285 if ((*end
!= '\0') || (end
== str
)) {
292 static int print_hex32(DeviceState
*dev
, Property
*prop
, char *dest
, size_t len
)
294 uint32_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
295 return snprintf(dest
, len
, "0x%" PRIx32
, *ptr
);
298 PropertyInfo qdev_prop_hex32
= {
300 .legacy_name
= "hex32",
301 .parse
= parse_hex32
,
302 .print
= print_hex32
,
307 /* --- 64bit integer --- */
309 static void get_uint64(Object
*obj
, Visitor
*v
, void *opaque
,
310 const char *name
, Error
**errp
)
312 DeviceState
*dev
= DEVICE(obj
);
313 Property
*prop
= opaque
;
314 uint64_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
316 visit_type_uint64(v
, ptr
, name
, errp
);
319 static void set_uint64(Object
*obj
, Visitor
*v
, void *opaque
,
320 const char *name
, Error
**errp
)
322 DeviceState
*dev
= DEVICE(obj
);
323 Property
*prop
= opaque
;
324 uint64_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
326 if (dev
->state
!= DEV_STATE_CREATED
) {
327 error_set(errp
, QERR_PERMISSION_DENIED
);
331 visit_type_uint64(v
, ptr
, name
, errp
);
334 PropertyInfo qdev_prop_uint64
= {
340 /* --- 64bit hex value --- */
342 static int parse_hex64(DeviceState
*dev
, Property
*prop
, const char *str
)
344 uint64_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
347 if (str
[0] != '0' || str
[1] != 'x') {
351 *ptr
= strtoull(str
, &end
, 16);
352 if ((*end
!= '\0') || (end
== str
)) {
359 static int print_hex64(DeviceState
*dev
, Property
*prop
, char *dest
, size_t len
)
361 uint64_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
362 return snprintf(dest
, len
, "0x%" PRIx64
, *ptr
);
365 PropertyInfo qdev_prop_hex64
= {
367 .legacy_name
= "hex64",
368 .parse
= parse_hex64
,
369 .print
= print_hex64
,
376 static void release_string(Object
*obj
, const char *name
, void *opaque
)
378 Property
*prop
= opaque
;
379 g_free(*(char **)qdev_get_prop_ptr(DEVICE(obj
), prop
));
382 static int print_string(DeviceState
*dev
, Property
*prop
, char *dest
,
385 char **ptr
= qdev_get_prop_ptr(dev
, prop
);
387 return snprintf(dest
, len
, "<null>");
389 return snprintf(dest
, len
, "\"%s\"", *ptr
);
392 static void get_string(Object
*obj
, Visitor
*v
, void *opaque
,
393 const char *name
, Error
**errp
)
395 DeviceState
*dev
= DEVICE(obj
);
396 Property
*prop
= opaque
;
397 char **ptr
= qdev_get_prop_ptr(dev
, prop
);
400 char *str
= (char *)"";
401 visit_type_str(v
, &str
, name
, errp
);
403 visit_type_str(v
, ptr
, name
, errp
);
407 static void set_string(Object
*obj
, Visitor
*v
, void *opaque
,
408 const char *name
, Error
**errp
)
410 DeviceState
*dev
= DEVICE(obj
);
411 Property
*prop
= opaque
;
412 char **ptr
= qdev_get_prop_ptr(dev
, prop
);
413 Error
*local_err
= NULL
;
416 if (dev
->state
!= DEV_STATE_CREATED
) {
417 error_set(errp
, QERR_PERMISSION_DENIED
);
421 visit_type_str(v
, &str
, name
, &local_err
);
423 error_propagate(errp
, local_err
);
432 PropertyInfo qdev_prop_string
= {
434 .print
= print_string
,
435 .release
= release_string
,
440 /* --- pointer --- */
442 /* Not a proper property, just for dirty hacks. TODO Remove it! */
443 PropertyInfo qdev_prop_ptr
= {
447 /* --- mac address --- */
450 * accepted syntax versions:
454 static void get_mac(Object
*obj
, Visitor
*v
, void *opaque
,
455 const char *name
, Error
**errp
)
457 DeviceState
*dev
= DEVICE(obj
);
458 Property
*prop
= opaque
;
459 MACAddr
*mac
= qdev_get_prop_ptr(dev
, prop
);
460 char buffer
[2 * 6 + 5 + 1];
463 snprintf(buffer
, sizeof(buffer
), "%02x:%02x:%02x:%02x:%02x:%02x",
464 mac
->a
[0], mac
->a
[1], mac
->a
[2],
465 mac
->a
[3], mac
->a
[4], mac
->a
[5]);
467 visit_type_str(v
, &p
, name
, errp
);
470 static void set_mac(Object
*obj
, Visitor
*v
, void *opaque
,
471 const char *name
, Error
**errp
)
473 DeviceState
*dev
= DEVICE(obj
);
474 Property
*prop
= opaque
;
475 MACAddr
*mac
= qdev_get_prop_ptr(dev
, prop
);
476 Error
*local_err
= NULL
;
480 if (dev
->state
!= DEV_STATE_CREATED
) {
481 error_set(errp
, QERR_PERMISSION_DENIED
);
485 visit_type_str(v
, &str
, name
, &local_err
);
487 error_propagate(errp
, local_err
);
491 for (i
= 0, pos
= 0; i
< 6; i
++, pos
+= 3) {
492 if (!qemu_isxdigit(str
[pos
])) {
495 if (!qemu_isxdigit(str
[pos
+1])) {
499 if (str
[pos
+2] != '\0') {
503 if (str
[pos
+2] != ':' && str
[pos
+2] != '-') {
507 mac
->a
[i
] = strtol(str
+pos
, &p
, 16);
513 error_set_from_qdev_prop_error(errp
, EINVAL
, dev
, prop
, str
);
517 PropertyInfo qdev_prop_macaddr
= {
523 /* --- lost tick policy --- */
525 static const char *lost_tick_policy_table
[LOST_TICK_MAX
+1] = {
526 [LOST_TICK_DISCARD
] = "discard",
527 [LOST_TICK_DELAY
] = "delay",
528 [LOST_TICK_MERGE
] = "merge",
529 [LOST_TICK_SLEW
] = "slew",
530 [LOST_TICK_MAX
] = NULL
,
533 QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy
) != sizeof(int));
535 PropertyInfo qdev_prop_losttickpolicy
= {
536 .name
= "LostTickPolicy",
537 .enum_table
= lost_tick_policy_table
,
542 /* --- BIOS CHS translation */
544 static const char *bios_chs_trans_table
[] = {
545 [BIOS_ATA_TRANSLATION_AUTO
] = "auto",
546 [BIOS_ATA_TRANSLATION_NONE
] = "none",
547 [BIOS_ATA_TRANSLATION_LBA
] = "lba",
550 PropertyInfo qdev_prop_bios_chs_trans
= {
551 .name
= "bios-chs-trans",
552 .enum_table
= bios_chs_trans_table
,
557 /* --- pci address --- */
560 * bus-local address, i.e. "$slot" or "$slot.$fn"
562 static void set_pci_devfn(Object
*obj
, Visitor
*v
, void *opaque
,
563 const char *name
, Error
**errp
)
565 DeviceState
*dev
= DEVICE(obj
);
566 Property
*prop
= opaque
;
567 int32_t value
, *ptr
= qdev_get_prop_ptr(dev
, prop
);
568 unsigned int slot
, fn
, n
;
569 Error
*local_err
= NULL
;
572 if (dev
->state
!= DEV_STATE_CREATED
) {
573 error_set(errp
, QERR_PERMISSION_DENIED
);
577 visit_type_str(v
, &str
, name
, &local_err
);
579 error_free(local_err
);
581 visit_type_int32(v
, &value
, name
, &local_err
);
583 error_propagate(errp
, local_err
);
584 } else if (value
< -1 || value
> 255) {
585 error_set(errp
, QERR_INVALID_PARAMETER_VALUE
, name
? name
: "null",
593 if (sscanf(str
, "%x.%x%n", &slot
, &fn
, &n
) != 2) {
595 if (sscanf(str
, "%x%n", &slot
, &n
) != 1) {
599 if (str
[n
] != '\0' || fn
> 7 || slot
> 31) {
602 *ptr
= slot
<< 3 | fn
;
607 error_set_from_qdev_prop_error(errp
, EINVAL
, dev
, prop
, str
);
611 static int print_pci_devfn(DeviceState
*dev
, Property
*prop
, char *dest
,
614 int32_t *ptr
= qdev_get_prop_ptr(dev
, prop
);
617 return snprintf(dest
, len
, "<unset>");
619 return snprintf(dest
, len
, "%02x.%x", *ptr
>> 3, *ptr
& 7);
623 PropertyInfo qdev_prop_pci_devfn
= {
625 .legacy_name
= "pci-devfn",
626 .print
= print_pci_devfn
,
628 .set
= set_pci_devfn
,
631 /* --- blocksize --- */
633 static void set_blocksize(Object
*obj
, Visitor
*v
, void *opaque
,
634 const char *name
, Error
**errp
)
636 DeviceState
*dev
= DEVICE(obj
);
637 Property
*prop
= opaque
;
638 uint16_t value
, *ptr
= qdev_get_prop_ptr(dev
, prop
);
639 Error
*local_err
= NULL
;
640 const int64_t min
= 512;
641 const int64_t max
= 32768;
643 if (dev
->state
!= DEV_STATE_CREATED
) {
644 error_set(errp
, QERR_PERMISSION_DENIED
);
648 visit_type_uint16(v
, &value
, name
, &local_err
);
650 error_propagate(errp
, local_err
);
653 if (value
< min
|| value
> max
) {
654 error_set(errp
, QERR_PROPERTY_VALUE_OUT_OF_RANGE
,
655 dev
->id
?:"", name
, (int64_t)value
, min
, max
);
659 /* We rely on power-of-2 blocksizes for bitmasks */
660 if ((value
& (value
- 1)) != 0) {
661 error_set(errp
, QERR_PROPERTY_VALUE_NOT_POWER_OF_2
,
662 dev
->id
?:"", name
, (int64_t)value
);
669 PropertyInfo qdev_prop_blocksize
= {
672 .set
= set_blocksize
,
675 /* --- pci host address --- */
677 static void get_pci_host_devaddr(Object
*obj
, Visitor
*v
, void *opaque
,
678 const char *name
, Error
**errp
)
680 DeviceState
*dev
= DEVICE(obj
);
681 Property
*prop
= opaque
;
682 PCIHostDeviceAddress
*addr
= qdev_get_prop_ptr(dev
, prop
);
683 char buffer
[] = "xxxx:xx:xx.x";
687 rc
= snprintf(buffer
, sizeof(buffer
), "%04x:%02x:%02x.%d",
688 addr
->domain
, addr
->bus
, addr
->slot
, addr
->function
);
689 assert(rc
== sizeof(buffer
) - 1);
691 visit_type_str(v
, &p
, name
, errp
);
695 * Parse [<domain>:]<bus>:<slot>.<func>
696 * if <domain> is not supplied, it's assumed to be 0.
698 static void set_pci_host_devaddr(Object
*obj
, Visitor
*v
, void *opaque
,
699 const char *name
, Error
**errp
)
701 DeviceState
*dev
= DEVICE(obj
);
702 Property
*prop
= opaque
;
703 PCIHostDeviceAddress
*addr
= qdev_get_prop_ptr(dev
, prop
);
704 Error
*local_err
= NULL
;
708 unsigned long dom
= 0, bus
= 0;
709 unsigned int slot
= 0, func
= 0;
711 if (dev
->state
!= DEV_STATE_CREATED
) {
712 error_set(errp
, QERR_PERMISSION_DENIED
);
716 visit_type_str(v
, &str
, name
, &local_err
);
718 error_propagate(errp
, local_err
);
723 val
= strtoul(p
, &e
, 16);
724 if (e
== p
|| *e
!= ':') {
730 val
= strtoul(p
, &e
, 16);
738 val
= strtoul(p
, &e
, 16);
749 val
= strtoul(p
, &e
, 10);
755 if (dom
> 0xffff || bus
> 0xff || slot
> 0x1f || func
> 7) {
766 addr
->function
= func
;
772 error_set_from_qdev_prop_error(errp
, EINVAL
, dev
, prop
, str
);
776 PropertyInfo qdev_prop_pci_host_devaddr
= {
777 .name
= "pci-host-devaddr",
778 .get
= get_pci_host_devaddr
,
779 .set
= set_pci_host_devaddr
,
782 /* --- public helpers --- */
784 static Property
*qdev_prop_walk(Property
*props
, const char *name
)
789 while (props
->name
) {
790 if (strcmp(props
->name
, name
) == 0) {
798 static Property
*qdev_prop_find(DeviceState
*dev
, const char *name
)
803 /* device properties */
804 class = object_get_class(OBJECT(dev
));
806 prop
= qdev_prop_walk(DEVICE_CLASS(class)->props
, name
);
810 class = object_class_get_parent(class);
811 } while (class != object_class_by_name(TYPE_DEVICE
));
816 void error_set_from_qdev_prop_error(Error
**errp
, int ret
, DeviceState
*dev
,
817 Property
*prop
, const char *value
)
821 error_set(errp
, QERR_PROPERTY_VALUE_IN_USE
,
822 object_get_typename(OBJECT(dev
)), prop
->name
, value
);
826 error_set(errp
, QERR_PROPERTY_VALUE_BAD
,
827 object_get_typename(OBJECT(dev
)), prop
->name
, value
);
830 error_set(errp
, QERR_PROPERTY_VALUE_NOT_FOUND
,
831 object_get_typename(OBJECT(dev
)), prop
->name
, value
);
838 int qdev_prop_parse(DeviceState
*dev
, const char *name
, const char *value
)
843 legacy_name
= g_strdup_printf("legacy-%s", name
);
844 if (object_property_get_type(OBJECT(dev
), legacy_name
, NULL
)) {
845 object_property_parse(OBJECT(dev
), value
, legacy_name
, &err
);
847 object_property_parse(OBJECT(dev
), value
, name
, &err
);
852 qerror_report_err(err
);
859 void qdev_prop_set_bit(DeviceState
*dev
, const char *name
, bool value
)
862 object_property_set_bool(OBJECT(dev
), value
, name
, &errp
);
863 assert_no_error(errp
);
866 void qdev_prop_set_uint8(DeviceState
*dev
, const char *name
, uint8_t value
)
869 object_property_set_int(OBJECT(dev
), value
, name
, &errp
);
870 assert_no_error(errp
);
873 void qdev_prop_set_uint16(DeviceState
*dev
, const char *name
, uint16_t value
)
876 object_property_set_int(OBJECT(dev
), value
, name
, &errp
);
877 assert_no_error(errp
);
880 void qdev_prop_set_uint32(DeviceState
*dev
, const char *name
, uint32_t value
)
883 object_property_set_int(OBJECT(dev
), value
, name
, &errp
);
884 assert_no_error(errp
);
887 void qdev_prop_set_int32(DeviceState
*dev
, const char *name
, int32_t value
)
890 object_property_set_int(OBJECT(dev
), value
, name
, &errp
);
891 assert_no_error(errp
);
894 void qdev_prop_set_uint64(DeviceState
*dev
, const char *name
, uint64_t value
)
897 object_property_set_int(OBJECT(dev
), value
, name
, &errp
);
898 assert_no_error(errp
);
901 void qdev_prop_set_string(DeviceState
*dev
, const char *name
, const char *value
)
904 object_property_set_str(OBJECT(dev
), value
, name
, &errp
);
905 assert_no_error(errp
);
908 void qdev_prop_set_macaddr(DeviceState
*dev
, const char *name
, uint8_t *value
)
911 char str
[2 * 6 + 5 + 1];
912 snprintf(str
, sizeof(str
), "%02x:%02x:%02x:%02x:%02x:%02x",
913 value
[0], value
[1], value
[2], value
[3], value
[4], value
[5]);
915 object_property_set_str(OBJECT(dev
), str
, name
, &errp
);
916 assert_no_error(errp
);
919 void qdev_prop_set_enum(DeviceState
*dev
, const char *name
, int value
)
924 prop
= qdev_prop_find(dev
, name
);
925 object_property_set_str(OBJECT(dev
), prop
->info
->enum_table
[value
],
927 assert_no_error(errp
);
930 void qdev_prop_set_ptr(DeviceState
*dev
, const char *name
, void *value
)
935 prop
= qdev_prop_find(dev
, name
);
936 assert(prop
&& prop
->info
== &qdev_prop_ptr
);
937 ptr
= qdev_get_prop_ptr(dev
, prop
);
941 static QTAILQ_HEAD(, GlobalProperty
) global_props
=
942 QTAILQ_HEAD_INITIALIZER(global_props
);
944 void qdev_prop_register_global(GlobalProperty
*prop
)
946 QTAILQ_INSERT_TAIL(&global_props
, prop
, next
);
949 void qdev_prop_register_global_list(GlobalProperty
*props
)
953 for (i
= 0; props
[i
].driver
!= NULL
; i
++) {
954 qdev_prop_register_global(props
+i
);
958 void qdev_prop_set_globals(DeviceState
*dev
)
960 ObjectClass
*class = object_get_class(OBJECT(dev
));
963 GlobalProperty
*prop
;
964 QTAILQ_FOREACH(prop
, &global_props
, next
) {
965 if (strcmp(object_class_get_name(class), prop
->driver
) != 0) {
968 if (qdev_prop_parse(dev
, prop
->property
, prop
->value
) != 0) {
972 class = object_class_get_parent(class);