root / hw / qdev-properties.c @ 4677d8ed
History | View | Annotate | Download (14.6 kB)
1 | 14b41872 | Gerd Hoffmann | #include "sysemu.h" |
---|---|---|---|
2 | 1503fff3 | Gerd Hoffmann | #include "net.h" |
3 | ee6847d1 | Gerd Hoffmann | #include "qdev.h" |
4 | ee6847d1 | Gerd Hoffmann | |
5 | ee6847d1 | Gerd Hoffmann | void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
|
6 | ee6847d1 | Gerd Hoffmann | { |
7 | ee6847d1 | Gerd Hoffmann | void *ptr = dev;
|
8 | ee6847d1 | Gerd Hoffmann | ptr += prop->offset; |
9 | ee6847d1 | Gerd Hoffmann | return ptr;
|
10 | ee6847d1 | Gerd Hoffmann | } |
11 | ee6847d1 | Gerd Hoffmann | |
12 | c7cc172d | Juan Quintela | /* --- 8bit integer --- */
|
13 | c7cc172d | Juan Quintela | |
14 | c7cc172d | Juan Quintela | static int parse_uint8(DeviceState *dev, Property *prop, const char *str) |
15 | c7cc172d | Juan Quintela | { |
16 | c7cc172d | Juan Quintela | uint8_t *ptr = qdev_get_prop_ptr(dev, prop); |
17 | c7cc172d | Juan Quintela | const char *fmt; |
18 | c7cc172d | Juan Quintela | |
19 | c7cc172d | Juan Quintela | /* accept both hex and decimal */
|
20 | c7cc172d | Juan Quintela | fmt = strncasecmp(str, "0x",2) == 0 ? "%" PRIx8 : "%" PRIu8; |
21 | c7cc172d | Juan Quintela | if (sscanf(str, fmt, ptr) != 1) |
22 | c7cc172d | Juan Quintela | return -1; |
23 | c7cc172d | Juan Quintela | return 0; |
24 | c7cc172d | Juan Quintela | } |
25 | c7cc172d | Juan Quintela | |
26 | c7cc172d | Juan Quintela | static int print_uint8(DeviceState *dev, Property *prop, char *dest, size_t len) |
27 | c7cc172d | Juan Quintela | { |
28 | c7cc172d | Juan Quintela | uint8_t *ptr = qdev_get_prop_ptr(dev, prop); |
29 | c7cc172d | Juan Quintela | return snprintf(dest, len, "%" PRIu8, *ptr); |
30 | c7cc172d | Juan Quintela | } |
31 | c7cc172d | Juan Quintela | |
32 | c7cc172d | Juan Quintela | PropertyInfo qdev_prop_uint8 = { |
33 | c7cc172d | Juan Quintela | .name = "uint8",
|
34 | c7cc172d | Juan Quintela | .type = PROP_TYPE_UINT8, |
35 | c7cc172d | Juan Quintela | .size = sizeof(uint8_t),
|
36 | c7cc172d | Juan Quintela | .parse = parse_uint8, |
37 | c7cc172d | Juan Quintela | .print = print_uint8, |
38 | c7cc172d | Juan Quintela | }; |
39 | c7cc172d | Juan Quintela | |
40 | ee6847d1 | Gerd Hoffmann | /* --- 16bit integer --- */
|
41 | ee6847d1 | Gerd Hoffmann | |
42 | ee6847d1 | Gerd Hoffmann | static int parse_uint16(DeviceState *dev, Property *prop, const char *str) |
43 | ee6847d1 | Gerd Hoffmann | { |
44 | ee6847d1 | Gerd Hoffmann | uint16_t *ptr = qdev_get_prop_ptr(dev, prop); |
45 | ee6847d1 | Gerd Hoffmann | const char *fmt; |
46 | ee6847d1 | Gerd Hoffmann | |
47 | ee6847d1 | Gerd Hoffmann | /* accept both hex and decimal */
|
48 | ee6847d1 | Gerd Hoffmann | fmt = strncasecmp(str, "0x",2) == 0 ? "%" PRIx16 : "%" PRIu16; |
49 | ee6847d1 | Gerd Hoffmann | if (sscanf(str, fmt, ptr) != 1) |
50 | ee6847d1 | Gerd Hoffmann | return -1; |
51 | ee6847d1 | Gerd Hoffmann | return 0; |
52 | ee6847d1 | Gerd Hoffmann | } |
53 | ee6847d1 | Gerd Hoffmann | |
54 | ee6847d1 | Gerd Hoffmann | static int print_uint16(DeviceState *dev, Property *prop, char *dest, size_t len) |
55 | ee6847d1 | Gerd Hoffmann | { |
56 | ee6847d1 | Gerd Hoffmann | uint16_t *ptr = qdev_get_prop_ptr(dev, prop); |
57 | ee6847d1 | Gerd Hoffmann | return snprintf(dest, len, "%" PRIu16, *ptr); |
58 | ee6847d1 | Gerd Hoffmann | } |
59 | ee6847d1 | Gerd Hoffmann | |
60 | ee6847d1 | Gerd Hoffmann | PropertyInfo qdev_prop_uint16 = { |
61 | ee6847d1 | Gerd Hoffmann | .name = "uint16",
|
62 | ee6847d1 | Gerd Hoffmann | .type = PROP_TYPE_UINT16, |
63 | ee6847d1 | Gerd Hoffmann | .size = sizeof(uint16_t),
|
64 | ee6847d1 | Gerd Hoffmann | .parse = parse_uint16, |
65 | ee6847d1 | Gerd Hoffmann | .print = print_uint16, |
66 | ee6847d1 | Gerd Hoffmann | }; |
67 | ee6847d1 | Gerd Hoffmann | |
68 | ee6847d1 | Gerd Hoffmann | /* --- 32bit integer --- */
|
69 | ee6847d1 | Gerd Hoffmann | |
70 | ee6847d1 | Gerd Hoffmann | static int parse_uint32(DeviceState *dev, Property *prop, const char *str) |
71 | ee6847d1 | Gerd Hoffmann | { |
72 | ee6847d1 | Gerd Hoffmann | uint32_t *ptr = qdev_get_prop_ptr(dev, prop); |
73 | ee6847d1 | Gerd Hoffmann | const char *fmt; |
74 | ee6847d1 | Gerd Hoffmann | |
75 | ee6847d1 | Gerd Hoffmann | /* accept both hex and decimal */
|
76 | ee6847d1 | Gerd Hoffmann | fmt = strncasecmp(str, "0x",2) == 0 ? "%" PRIx32 : "%" PRIu32; |
77 | ee6847d1 | Gerd Hoffmann | if (sscanf(str, fmt, ptr) != 1) |
78 | ee6847d1 | Gerd Hoffmann | return -1; |
79 | ee6847d1 | Gerd Hoffmann | return 0; |
80 | ee6847d1 | Gerd Hoffmann | } |
81 | ee6847d1 | Gerd Hoffmann | |
82 | ee6847d1 | Gerd Hoffmann | static int print_uint32(DeviceState *dev, Property *prop, char *dest, size_t len) |
83 | ee6847d1 | Gerd Hoffmann | { |
84 | ee6847d1 | Gerd Hoffmann | uint32_t *ptr = qdev_get_prop_ptr(dev, prop); |
85 | ee6847d1 | Gerd Hoffmann | return snprintf(dest, len, "%" PRIu32, *ptr); |
86 | ee6847d1 | Gerd Hoffmann | } |
87 | ee6847d1 | Gerd Hoffmann | |
88 | ee6847d1 | Gerd Hoffmann | PropertyInfo qdev_prop_uint32 = { |
89 | ee6847d1 | Gerd Hoffmann | .name = "uint32",
|
90 | ee6847d1 | Gerd Hoffmann | .type = PROP_TYPE_UINT32, |
91 | ee6847d1 | Gerd Hoffmann | .size = sizeof(uint32_t),
|
92 | ee6847d1 | Gerd Hoffmann | .parse = parse_uint32, |
93 | ee6847d1 | Gerd Hoffmann | .print = print_uint32, |
94 | ee6847d1 | Gerd Hoffmann | }; |
95 | ee6847d1 | Gerd Hoffmann | |
96 | 316940b0 | Gerd Hoffmann | static int parse_int32(DeviceState *dev, Property *prop, const char *str) |
97 | 316940b0 | Gerd Hoffmann | { |
98 | 316940b0 | Gerd Hoffmann | int32_t *ptr = qdev_get_prop_ptr(dev, prop); |
99 | 316940b0 | Gerd Hoffmann | |
100 | 316940b0 | Gerd Hoffmann | if (sscanf(str, "%" PRId32, ptr) != 1) |
101 | 316940b0 | Gerd Hoffmann | return -1; |
102 | 316940b0 | Gerd Hoffmann | return 0; |
103 | 316940b0 | Gerd Hoffmann | } |
104 | 316940b0 | Gerd Hoffmann | |
105 | 316940b0 | Gerd Hoffmann | static int print_int32(DeviceState *dev, Property *prop, char *dest, size_t len) |
106 | 316940b0 | Gerd Hoffmann | { |
107 | 316940b0 | Gerd Hoffmann | int32_t *ptr = qdev_get_prop_ptr(dev, prop); |
108 | 316940b0 | Gerd Hoffmann | return snprintf(dest, len, "%" PRId32, *ptr); |
109 | 316940b0 | Gerd Hoffmann | } |
110 | 316940b0 | Gerd Hoffmann | |
111 | 316940b0 | Gerd Hoffmann | PropertyInfo qdev_prop_int32 = { |
112 | 316940b0 | Gerd Hoffmann | .name = "int32",
|
113 | 316940b0 | Gerd Hoffmann | .type = PROP_TYPE_INT32, |
114 | 316940b0 | Gerd Hoffmann | .size = sizeof(int32_t),
|
115 | 316940b0 | Gerd Hoffmann | .parse = parse_int32, |
116 | 316940b0 | Gerd Hoffmann | .print = print_int32, |
117 | 316940b0 | Gerd Hoffmann | }; |
118 | 316940b0 | Gerd Hoffmann | |
119 | ee6847d1 | Gerd Hoffmann | /* --- 32bit hex value --- */
|
120 | ee6847d1 | Gerd Hoffmann | |
121 | ee6847d1 | Gerd Hoffmann | static int parse_hex32(DeviceState *dev, Property *prop, const char *str) |
122 | ee6847d1 | Gerd Hoffmann | { |
123 | ee6847d1 | Gerd Hoffmann | uint32_t *ptr = qdev_get_prop_ptr(dev, prop); |
124 | ee6847d1 | Gerd Hoffmann | |
125 | ee6847d1 | Gerd Hoffmann | if (sscanf(str, "%" PRIx32, ptr) != 1) |
126 | ee6847d1 | Gerd Hoffmann | return -1; |
127 | ee6847d1 | Gerd Hoffmann | return 0; |
128 | ee6847d1 | Gerd Hoffmann | } |
129 | ee6847d1 | Gerd Hoffmann | |
130 | ee6847d1 | Gerd Hoffmann | static int print_hex32(DeviceState *dev, Property *prop, char *dest, size_t len) |
131 | ee6847d1 | Gerd Hoffmann | { |
132 | ee6847d1 | Gerd Hoffmann | uint32_t *ptr = qdev_get_prop_ptr(dev, prop); |
133 | ee6847d1 | Gerd Hoffmann | return snprintf(dest, len, "0x%" PRIx32, *ptr); |
134 | ee6847d1 | Gerd Hoffmann | } |
135 | ee6847d1 | Gerd Hoffmann | |
136 | ee6847d1 | Gerd Hoffmann | PropertyInfo qdev_prop_hex32 = { |
137 | ee6847d1 | Gerd Hoffmann | .name = "hex32",
|
138 | ee6847d1 | Gerd Hoffmann | .type = PROP_TYPE_UINT32, |
139 | ee6847d1 | Gerd Hoffmann | .size = sizeof(uint32_t),
|
140 | ee6847d1 | Gerd Hoffmann | .parse = parse_hex32, |
141 | ee6847d1 | Gerd Hoffmann | .print = print_hex32, |
142 | ee6847d1 | Gerd Hoffmann | }; |
143 | ee6847d1 | Gerd Hoffmann | |
144 | 5a053d1f | Blue Swirl | /* --- 64bit integer --- */
|
145 | 5a053d1f | Blue Swirl | |
146 | 5a053d1f | Blue Swirl | static int parse_uint64(DeviceState *dev, Property *prop, const char *str) |
147 | 5a053d1f | Blue Swirl | { |
148 | 5a053d1f | Blue Swirl | uint64_t *ptr = qdev_get_prop_ptr(dev, prop); |
149 | 5a053d1f | Blue Swirl | const char *fmt; |
150 | 5a053d1f | Blue Swirl | |
151 | 5a053d1f | Blue Swirl | /* accept both hex and decimal */
|
152 | 5a053d1f | Blue Swirl | fmt = strncasecmp(str, "0x",2) == 0 ? "%" PRIx64 : "%" PRIu64; |
153 | 5a053d1f | Blue Swirl | if (sscanf(str, fmt, ptr) != 1) |
154 | 5a053d1f | Blue Swirl | return -1; |
155 | 5a053d1f | Blue Swirl | return 0; |
156 | 5a053d1f | Blue Swirl | } |
157 | 5a053d1f | Blue Swirl | |
158 | 5a053d1f | Blue Swirl | static int print_uint64(DeviceState *dev, Property *prop, char *dest, size_t len) |
159 | 5a053d1f | Blue Swirl | { |
160 | 5a053d1f | Blue Swirl | uint64_t *ptr = qdev_get_prop_ptr(dev, prop); |
161 | 5a053d1f | Blue Swirl | return snprintf(dest, len, "%" PRIu64, *ptr); |
162 | 5a053d1f | Blue Swirl | } |
163 | 5a053d1f | Blue Swirl | |
164 | 5a053d1f | Blue Swirl | PropertyInfo qdev_prop_uint64 = { |
165 | 5a053d1f | Blue Swirl | .name = "uint64",
|
166 | 5a053d1f | Blue Swirl | .type = PROP_TYPE_UINT64, |
167 | 5a053d1f | Blue Swirl | .size = sizeof(uint64_t),
|
168 | 5a053d1f | Blue Swirl | .parse = parse_uint64, |
169 | 5a053d1f | Blue Swirl | .print = print_uint64, |
170 | 5a053d1f | Blue Swirl | }; |
171 | 5a053d1f | Blue Swirl | |
172 | 5a053d1f | Blue Swirl | /* --- 64bit hex value --- */
|
173 | 5a053d1f | Blue Swirl | |
174 | 5a053d1f | Blue Swirl | static int parse_hex64(DeviceState *dev, Property *prop, const char *str) |
175 | 5a053d1f | Blue Swirl | { |
176 | 5a053d1f | Blue Swirl | uint64_t *ptr = qdev_get_prop_ptr(dev, prop); |
177 | 5a053d1f | Blue Swirl | |
178 | 5a053d1f | Blue Swirl | if (sscanf(str, "%" PRIx64, ptr) != 1) |
179 | 5a053d1f | Blue Swirl | return -1; |
180 | 5a053d1f | Blue Swirl | return 0; |
181 | 5a053d1f | Blue Swirl | } |
182 | 5a053d1f | Blue Swirl | |
183 | 5a053d1f | Blue Swirl | static int print_hex64(DeviceState *dev, Property *prop, char *dest, size_t len) |
184 | 5a053d1f | Blue Swirl | { |
185 | 5a053d1f | Blue Swirl | uint64_t *ptr = qdev_get_prop_ptr(dev, prop); |
186 | 5a053d1f | Blue Swirl | return snprintf(dest, len, "0x%" PRIx64, *ptr); |
187 | 5a053d1f | Blue Swirl | } |
188 | 5a053d1f | Blue Swirl | |
189 | 5a053d1f | Blue Swirl | PropertyInfo qdev_prop_hex64 = { |
190 | 5a053d1f | Blue Swirl | .name = "hex64",
|
191 | 5a053d1f | Blue Swirl | .type = PROP_TYPE_UINT64, |
192 | 5a053d1f | Blue Swirl | .size = sizeof(uint64_t),
|
193 | 5a053d1f | Blue Swirl | .parse = parse_hex64, |
194 | 5a053d1f | Blue Swirl | .print = print_hex64, |
195 | 5a053d1f | Blue Swirl | }; |
196 | 5a053d1f | Blue Swirl | |
197 | 59419663 | Gerd Hoffmann | /* --- string --- */
|
198 | 59419663 | Gerd Hoffmann | |
199 | 59419663 | Gerd Hoffmann | static int parse_string(DeviceState *dev, Property *prop, const char *str) |
200 | 59419663 | Gerd Hoffmann | { |
201 | 59419663 | Gerd Hoffmann | char **ptr = qdev_get_prop_ptr(dev, prop);
|
202 | 59419663 | Gerd Hoffmann | |
203 | 59419663 | Gerd Hoffmann | if (*ptr)
|
204 | 59419663 | Gerd Hoffmann | qemu_free(*ptr); |
205 | 59419663 | Gerd Hoffmann | *ptr = qemu_strdup(str); |
206 | 59419663 | Gerd Hoffmann | return 0; |
207 | 59419663 | Gerd Hoffmann | } |
208 | 59419663 | Gerd Hoffmann | |
209 | 59419663 | Gerd Hoffmann | static int print_string(DeviceState *dev, Property *prop, char *dest, size_t len) |
210 | 59419663 | Gerd Hoffmann | { |
211 | 59419663 | Gerd Hoffmann | char **ptr = qdev_get_prop_ptr(dev, prop);
|
212 | 59419663 | Gerd Hoffmann | if (!*ptr)
|
213 | 59419663 | Gerd Hoffmann | return snprintf(dest, len, "<null>"); |
214 | 59419663 | Gerd Hoffmann | return snprintf(dest, len, "\"%s\"", *ptr); |
215 | 59419663 | Gerd Hoffmann | } |
216 | 59419663 | Gerd Hoffmann | |
217 | 59419663 | Gerd Hoffmann | PropertyInfo qdev_prop_string = { |
218 | 59419663 | Gerd Hoffmann | .name = "string",
|
219 | 59419663 | Gerd Hoffmann | .type = PROP_TYPE_STRING, |
220 | 59419663 | Gerd Hoffmann | .size = sizeof(char*), |
221 | 59419663 | Gerd Hoffmann | .parse = parse_string, |
222 | 59419663 | Gerd Hoffmann | .print = print_string, |
223 | 59419663 | Gerd Hoffmann | }; |
224 | 59419663 | Gerd Hoffmann | |
225 | 14b41872 | Gerd Hoffmann | /* --- drive --- */
|
226 | 14b41872 | Gerd Hoffmann | |
227 | 14b41872 | Gerd Hoffmann | static int parse_drive(DeviceState *dev, Property *prop, const char *str) |
228 | 14b41872 | Gerd Hoffmann | { |
229 | 14b41872 | Gerd Hoffmann | DriveInfo **ptr = qdev_get_prop_ptr(dev, prop); |
230 | 14b41872 | Gerd Hoffmann | |
231 | 14b41872 | Gerd Hoffmann | *ptr = drive_get_by_id(str); |
232 | 14b41872 | Gerd Hoffmann | if (*ptr == NULL) |
233 | 14b41872 | Gerd Hoffmann | return -1; |
234 | 14b41872 | Gerd Hoffmann | return 0; |
235 | 14b41872 | Gerd Hoffmann | } |
236 | 14b41872 | Gerd Hoffmann | |
237 | 14b41872 | Gerd Hoffmann | static int print_drive(DeviceState *dev, Property *prop, char *dest, size_t len) |
238 | 14b41872 | Gerd Hoffmann | { |
239 | 14b41872 | Gerd Hoffmann | DriveInfo **ptr = qdev_get_prop_ptr(dev, prop); |
240 | 41b5e892 | Gerd Hoffmann | return snprintf(dest, len, "%s", (*ptr) ? (*ptr)->id : "<null>"); |
241 | 14b41872 | Gerd Hoffmann | } |
242 | 14b41872 | Gerd Hoffmann | |
243 | 14b41872 | Gerd Hoffmann | PropertyInfo qdev_prop_drive = { |
244 | 14b41872 | Gerd Hoffmann | .name = "drive",
|
245 | 14b41872 | Gerd Hoffmann | .type = PROP_TYPE_DRIVE, |
246 | 14b41872 | Gerd Hoffmann | .size = sizeof(DriveInfo*),
|
247 | 14b41872 | Gerd Hoffmann | .parse = parse_drive, |
248 | 14b41872 | Gerd Hoffmann | .print = print_drive, |
249 | 14b41872 | Gerd Hoffmann | }; |
250 | 14b41872 | Gerd Hoffmann | |
251 | 313feaab | Gerd Hoffmann | /* --- character device --- */
|
252 | 313feaab | Gerd Hoffmann | |
253 | 06113719 | Gerd Hoffmann | static int parse_chr(DeviceState *dev, Property *prop, const char *str) |
254 | 06113719 | Gerd Hoffmann | { |
255 | 06113719 | Gerd Hoffmann | CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); |
256 | 06113719 | Gerd Hoffmann | |
257 | 06113719 | Gerd Hoffmann | *ptr = qemu_chr_find(str); |
258 | 06113719 | Gerd Hoffmann | if (*ptr == NULL) |
259 | 06113719 | Gerd Hoffmann | return -1; |
260 | 06113719 | Gerd Hoffmann | return 0; |
261 | 06113719 | Gerd Hoffmann | } |
262 | 06113719 | Gerd Hoffmann | |
263 | 313feaab | Gerd Hoffmann | static int print_chr(DeviceState *dev, Property *prop, char *dest, size_t len) |
264 | 313feaab | Gerd Hoffmann | { |
265 | 313feaab | Gerd Hoffmann | CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); |
266 | bc19fcaa | Blue Swirl | |
267 | bc19fcaa | Blue Swirl | if (*ptr && (*ptr)->label) {
|
268 | bc19fcaa | Blue Swirl | return snprintf(dest, len, "%s", (*ptr)->label); |
269 | bc19fcaa | Blue Swirl | } else {
|
270 | bc19fcaa | Blue Swirl | return snprintf(dest, len, "<null>"); |
271 | bc19fcaa | Blue Swirl | } |
272 | 313feaab | Gerd Hoffmann | } |
273 | 313feaab | Gerd Hoffmann | |
274 | 313feaab | Gerd Hoffmann | PropertyInfo qdev_prop_chr = { |
275 | 313feaab | Gerd Hoffmann | .name = "chr",
|
276 | 313feaab | Gerd Hoffmann | .type = PROP_TYPE_CHR, |
277 | 313feaab | Gerd Hoffmann | .size = sizeof(CharDriverState*),
|
278 | 06113719 | Gerd Hoffmann | .parse = parse_chr, |
279 | 313feaab | Gerd Hoffmann | .print = print_chr, |
280 | 313feaab | Gerd Hoffmann | }; |
281 | 313feaab | Gerd Hoffmann | |
282 | 2ef924b4 | Gerd Hoffmann | /* --- netdev device --- */
|
283 | 2ef924b4 | Gerd Hoffmann | |
284 | 2ef924b4 | Gerd Hoffmann | static int parse_netdev(DeviceState *dev, Property *prop, const char *str) |
285 | 2ef924b4 | Gerd Hoffmann | { |
286 | 2ef924b4 | Gerd Hoffmann | VLANClientState **ptr = qdev_get_prop_ptr(dev, prop); |
287 | 2ef924b4 | Gerd Hoffmann | |
288 | 2ef924b4 | Gerd Hoffmann | *ptr = qemu_find_netdev(str); |
289 | 2ef924b4 | Gerd Hoffmann | if (*ptr == NULL) |
290 | 2ef924b4 | Gerd Hoffmann | return -1; |
291 | 2ef924b4 | Gerd Hoffmann | return 0; |
292 | 2ef924b4 | Gerd Hoffmann | } |
293 | 2ef924b4 | Gerd Hoffmann | |
294 | 2ef924b4 | Gerd Hoffmann | static int print_netdev(DeviceState *dev, Property *prop, char *dest, size_t len) |
295 | 2ef924b4 | Gerd Hoffmann | { |
296 | 2ef924b4 | Gerd Hoffmann | VLANClientState **ptr = qdev_get_prop_ptr(dev, prop); |
297 | 2ef924b4 | Gerd Hoffmann | |
298 | 2ef924b4 | Gerd Hoffmann | if (*ptr && (*ptr)->name) {
|
299 | 2ef924b4 | Gerd Hoffmann | return snprintf(dest, len, "%s", (*ptr)->name); |
300 | 2ef924b4 | Gerd Hoffmann | } else {
|
301 | 2ef924b4 | Gerd Hoffmann | return snprintf(dest, len, "<null>"); |
302 | 2ef924b4 | Gerd Hoffmann | } |
303 | 2ef924b4 | Gerd Hoffmann | } |
304 | 2ef924b4 | Gerd Hoffmann | |
305 | 2ef924b4 | Gerd Hoffmann | PropertyInfo qdev_prop_netdev = { |
306 | 2ef924b4 | Gerd Hoffmann | .name = "netdev",
|
307 | 2ef924b4 | Gerd Hoffmann | .type = PROP_TYPE_NETDEV, |
308 | 2ef924b4 | Gerd Hoffmann | .size = sizeof(VLANClientState*),
|
309 | 2ef924b4 | Gerd Hoffmann | .parse = parse_netdev, |
310 | 2ef924b4 | Gerd Hoffmann | .print = print_netdev, |
311 | 2ef924b4 | Gerd Hoffmann | }; |
312 | 2ef924b4 | Gerd Hoffmann | |
313 | 851bec09 | Gerd Hoffmann | /* --- vlan --- */
|
314 | 851bec09 | Gerd Hoffmann | |
315 | 851bec09 | Gerd Hoffmann | static int parse_vlan(DeviceState *dev, Property *prop, const char *str) |
316 | 851bec09 | Gerd Hoffmann | { |
317 | 851bec09 | Gerd Hoffmann | VLANState **ptr = qdev_get_prop_ptr(dev, prop); |
318 | 851bec09 | Gerd Hoffmann | int id;
|
319 | 851bec09 | Gerd Hoffmann | |
320 | 851bec09 | Gerd Hoffmann | if (sscanf(str, "%d", &id) != 1) |
321 | 851bec09 | Gerd Hoffmann | return -1; |
322 | 851bec09 | Gerd Hoffmann | *ptr = qemu_find_vlan(id, 1);
|
323 | 851bec09 | Gerd Hoffmann | if (*ptr == NULL) |
324 | 851bec09 | Gerd Hoffmann | return -1; |
325 | 851bec09 | Gerd Hoffmann | return 0; |
326 | 851bec09 | Gerd Hoffmann | } |
327 | 851bec09 | Gerd Hoffmann | |
328 | 851bec09 | Gerd Hoffmann | static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len) |
329 | 851bec09 | Gerd Hoffmann | { |
330 | 851bec09 | Gerd Hoffmann | VLANState **ptr = qdev_get_prop_ptr(dev, prop); |
331 | 851bec09 | Gerd Hoffmann | |
332 | 851bec09 | Gerd Hoffmann | if (*ptr) {
|
333 | 851bec09 | Gerd Hoffmann | return snprintf(dest, len, "%d", (*ptr)->id); |
334 | 851bec09 | Gerd Hoffmann | } else {
|
335 | 851bec09 | Gerd Hoffmann | return snprintf(dest, len, "<null>"); |
336 | 851bec09 | Gerd Hoffmann | } |
337 | 851bec09 | Gerd Hoffmann | } |
338 | 851bec09 | Gerd Hoffmann | |
339 | 851bec09 | Gerd Hoffmann | PropertyInfo qdev_prop_vlan = { |
340 | 851bec09 | Gerd Hoffmann | .name = "vlan",
|
341 | 851bec09 | Gerd Hoffmann | .type = PROP_TYPE_VLAN, |
342 | 851bec09 | Gerd Hoffmann | .size = sizeof(VLANClientState*),
|
343 | 851bec09 | Gerd Hoffmann | .parse = parse_vlan, |
344 | 851bec09 | Gerd Hoffmann | .print = print_vlan, |
345 | 851bec09 | Gerd Hoffmann | }; |
346 | 851bec09 | Gerd Hoffmann | |
347 | ee6847d1 | Gerd Hoffmann | /* --- pointer --- */
|
348 | ee6847d1 | Gerd Hoffmann | |
349 | ee6847d1 | Gerd Hoffmann | static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len) |
350 | ee6847d1 | Gerd Hoffmann | { |
351 | ee6847d1 | Gerd Hoffmann | void **ptr = qdev_get_prop_ptr(dev, prop);
|
352 | ee6847d1 | Gerd Hoffmann | return snprintf(dest, len, "<%p>", *ptr); |
353 | ee6847d1 | Gerd Hoffmann | } |
354 | ee6847d1 | Gerd Hoffmann | |
355 | ee6847d1 | Gerd Hoffmann | PropertyInfo qdev_prop_ptr = { |
356 | ee6847d1 | Gerd Hoffmann | .name = "ptr",
|
357 | ee6847d1 | Gerd Hoffmann | .type = PROP_TYPE_PTR, |
358 | ee6847d1 | Gerd Hoffmann | .size = sizeof(void*), |
359 | ee6847d1 | Gerd Hoffmann | .print = print_ptr, |
360 | ee6847d1 | Gerd Hoffmann | }; |
361 | ee6847d1 | Gerd Hoffmann | |
362 | ee6847d1 | Gerd Hoffmann | /* --- mac address --- */
|
363 | ee6847d1 | Gerd Hoffmann | |
364 | ee6847d1 | Gerd Hoffmann | /*
|
365 | ee6847d1 | Gerd Hoffmann | * accepted syntax versions:
|
366 | ee6847d1 | Gerd Hoffmann | * 01:02:03:04:05:06
|
367 | ee6847d1 | Gerd Hoffmann | * 01-02-03-04-05-06
|
368 | ee6847d1 | Gerd Hoffmann | */
|
369 | ee6847d1 | Gerd Hoffmann | static int parse_mac(DeviceState *dev, Property *prop, const char *str) |
370 | ee6847d1 | Gerd Hoffmann | { |
371 | 1503fff3 | Gerd Hoffmann | MACAddr *mac = qdev_get_prop_ptr(dev, prop); |
372 | ee6847d1 | Gerd Hoffmann | int i, pos;
|
373 | ee6847d1 | Gerd Hoffmann | char *p;
|
374 | ee6847d1 | Gerd Hoffmann | |
375 | ee6847d1 | Gerd Hoffmann | for (i = 0, pos = 0; i < 6; i++, pos += 3) { |
376 | 88e150a5 | Christoph Egger | if (!qemu_isxdigit(str[pos]))
|
377 | ee6847d1 | Gerd Hoffmann | return -1; |
378 | 88e150a5 | Christoph Egger | if (!qemu_isxdigit(str[pos+1])) |
379 | ee6847d1 | Gerd Hoffmann | return -1; |
380 | 1503fff3 | Gerd Hoffmann | if (i == 5) { |
381 | 1503fff3 | Gerd Hoffmann | if (str[pos+2] != '\0') |
382 | 1503fff3 | Gerd Hoffmann | return -1; |
383 | 1503fff3 | Gerd Hoffmann | } else {
|
384 | 1503fff3 | Gerd Hoffmann | if (str[pos+2] != ':' && str[pos+2] != '-') |
385 | 1503fff3 | Gerd Hoffmann | return -1; |
386 | 1503fff3 | Gerd Hoffmann | } |
387 | 1503fff3 | Gerd Hoffmann | mac->a[i] = strtol(str+pos, &p, 16);
|
388 | ee6847d1 | Gerd Hoffmann | } |
389 | ee6847d1 | Gerd Hoffmann | return 0; |
390 | ee6847d1 | Gerd Hoffmann | } |
391 | ee6847d1 | Gerd Hoffmann | |
392 | ee6847d1 | Gerd Hoffmann | static int print_mac(DeviceState *dev, Property *prop, char *dest, size_t len) |
393 | ee6847d1 | Gerd Hoffmann | { |
394 | 1503fff3 | Gerd Hoffmann | MACAddr *mac = qdev_get_prop_ptr(dev, prop); |
395 | 1503fff3 | Gerd Hoffmann | |
396 | ee6847d1 | Gerd Hoffmann | return snprintf(dest, len, "%02x:%02x:%02x:%02x:%02x:%02x", |
397 | 1503fff3 | Gerd Hoffmann | mac->a[0], mac->a[1], mac->a[2], |
398 | 1503fff3 | Gerd Hoffmann | mac->a[3], mac->a[4], mac->a[5]); |
399 | ee6847d1 | Gerd Hoffmann | } |
400 | ee6847d1 | Gerd Hoffmann | |
401 | ee6847d1 | Gerd Hoffmann | PropertyInfo qdev_prop_macaddr = { |
402 | 1503fff3 | Gerd Hoffmann | .name = "macaddr",
|
403 | ee6847d1 | Gerd Hoffmann | .type = PROP_TYPE_MACADDR, |
404 | 1503fff3 | Gerd Hoffmann | .size = sizeof(MACAddr),
|
405 | ee6847d1 | Gerd Hoffmann | .parse = parse_mac, |
406 | ee6847d1 | Gerd Hoffmann | .print = print_mac, |
407 | ee6847d1 | Gerd Hoffmann | }; |
408 | ee6847d1 | Gerd Hoffmann | |
409 | 05cb5fe4 | Gerd Hoffmann | /* --- pci address --- */
|
410 | 05cb5fe4 | Gerd Hoffmann | |
411 | 05cb5fe4 | Gerd Hoffmann | /*
|
412 | 05cb5fe4 | Gerd Hoffmann | * bus-local address, i.e. "$slot" or "$slot.$fn"
|
413 | 05cb5fe4 | Gerd Hoffmann | */
|
414 | 05cb5fe4 | Gerd Hoffmann | static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str) |
415 | 05cb5fe4 | Gerd Hoffmann | { |
416 | 05cb5fe4 | Gerd Hoffmann | uint32_t *ptr = qdev_get_prop_ptr(dev, prop); |
417 | 05cb5fe4 | Gerd Hoffmann | unsigned int slot, fn, n; |
418 | 05cb5fe4 | Gerd Hoffmann | |
419 | 05cb5fe4 | Gerd Hoffmann | if (sscanf(str, "%x.%x%n", &slot, &fn, &n) != 2) { |
420 | 05cb5fe4 | Gerd Hoffmann | fn = 0;
|
421 | 05cb5fe4 | Gerd Hoffmann | if (sscanf(str, "%x%n", &slot, &n) != 1) { |
422 | 05cb5fe4 | Gerd Hoffmann | return -1; |
423 | 05cb5fe4 | Gerd Hoffmann | } |
424 | 05cb5fe4 | Gerd Hoffmann | } |
425 | 05cb5fe4 | Gerd Hoffmann | if (str[n] != '\0') |
426 | 05cb5fe4 | Gerd Hoffmann | return -1; |
427 | 05cb5fe4 | Gerd Hoffmann | if (fn > 7) |
428 | 05cb5fe4 | Gerd Hoffmann | return -1; |
429 | 05cb5fe4 | Gerd Hoffmann | *ptr = slot << 3 | fn;
|
430 | 05cb5fe4 | Gerd Hoffmann | return 0; |
431 | 05cb5fe4 | Gerd Hoffmann | } |
432 | 05cb5fe4 | Gerd Hoffmann | |
433 | 05cb5fe4 | Gerd Hoffmann | static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest, size_t len) |
434 | 05cb5fe4 | Gerd Hoffmann | { |
435 | 05cb5fe4 | Gerd Hoffmann | uint32_t *ptr = qdev_get_prop_ptr(dev, prop); |
436 | 05cb5fe4 | Gerd Hoffmann | |
437 | 73538c31 | Blue Swirl | if (*ptr == -1) { |
438 | 05cb5fe4 | Gerd Hoffmann | return snprintf(dest, len, "<unset>"); |
439 | 05cb5fe4 | Gerd Hoffmann | } else {
|
440 | 05cb5fe4 | Gerd Hoffmann | return snprintf(dest, len, "%02x.%x", *ptr >> 3, *ptr & 7); |
441 | 05cb5fe4 | Gerd Hoffmann | } |
442 | 05cb5fe4 | Gerd Hoffmann | } |
443 | 05cb5fe4 | Gerd Hoffmann | |
444 | 05cb5fe4 | Gerd Hoffmann | PropertyInfo qdev_prop_pci_devfn = { |
445 | 05cb5fe4 | Gerd Hoffmann | .name = "pci-devfn",
|
446 | 05cb5fe4 | Gerd Hoffmann | .type = PROP_TYPE_UINT32, |
447 | 05cb5fe4 | Gerd Hoffmann | .size = sizeof(uint32_t),
|
448 | 05cb5fe4 | Gerd Hoffmann | .parse = parse_pci_devfn, |
449 | 05cb5fe4 | Gerd Hoffmann | .print = print_pci_devfn, |
450 | 05cb5fe4 | Gerd Hoffmann | }; |
451 | 05cb5fe4 | Gerd Hoffmann | |
452 | ee6847d1 | Gerd Hoffmann | /* --- public helpers --- */
|
453 | ee6847d1 | Gerd Hoffmann | |
454 | ee6847d1 | Gerd Hoffmann | static Property *qdev_prop_walk(Property *props, const char *name) |
455 | ee6847d1 | Gerd Hoffmann | { |
456 | ee6847d1 | Gerd Hoffmann | if (!props)
|
457 | ee6847d1 | Gerd Hoffmann | return NULL; |
458 | ee6847d1 | Gerd Hoffmann | while (props->name) {
|
459 | ee6847d1 | Gerd Hoffmann | if (strcmp(props->name, name) == 0) |
460 | ee6847d1 | Gerd Hoffmann | return props;
|
461 | ee6847d1 | Gerd Hoffmann | props++; |
462 | ee6847d1 | Gerd Hoffmann | } |
463 | ee6847d1 | Gerd Hoffmann | return NULL; |
464 | ee6847d1 | Gerd Hoffmann | } |
465 | ee6847d1 | Gerd Hoffmann | |
466 | ee6847d1 | Gerd Hoffmann | static Property *qdev_prop_find(DeviceState *dev, const char *name) |
467 | ee6847d1 | Gerd Hoffmann | { |
468 | ee6847d1 | Gerd Hoffmann | Property *prop; |
469 | ee6847d1 | Gerd Hoffmann | |
470 | ee6847d1 | Gerd Hoffmann | /* device properties */
|
471 | ee6847d1 | Gerd Hoffmann | prop = qdev_prop_walk(dev->info->props, name); |
472 | ee6847d1 | Gerd Hoffmann | if (prop)
|
473 | ee6847d1 | Gerd Hoffmann | return prop;
|
474 | ee6847d1 | Gerd Hoffmann | |
475 | ee6847d1 | Gerd Hoffmann | /* bus properties */
|
476 | ee6847d1 | Gerd Hoffmann | prop = qdev_prop_walk(dev->parent_bus->info->props, name); |
477 | ee6847d1 | Gerd Hoffmann | if (prop)
|
478 | ee6847d1 | Gerd Hoffmann | return prop;
|
479 | ee6847d1 | Gerd Hoffmann | |
480 | ee6847d1 | Gerd Hoffmann | return NULL; |
481 | ee6847d1 | Gerd Hoffmann | } |
482 | ee6847d1 | Gerd Hoffmann | |
483 | d8ed79ae | Gerd Hoffmann | int qdev_prop_exists(DeviceState *dev, const char *name) |
484 | d8ed79ae | Gerd Hoffmann | { |
485 | d8ed79ae | Gerd Hoffmann | return qdev_prop_find(dev, name) ? true : false; |
486 | d8ed79ae | Gerd Hoffmann | } |
487 | d8ed79ae | Gerd Hoffmann | |
488 | ee6847d1 | Gerd Hoffmann | int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) |
489 | ee6847d1 | Gerd Hoffmann | { |
490 | ee6847d1 | Gerd Hoffmann | Property *prop; |
491 | ee6847d1 | Gerd Hoffmann | |
492 | ee6847d1 | Gerd Hoffmann | prop = qdev_prop_find(dev, name); |
493 | ee6847d1 | Gerd Hoffmann | if (!prop) {
|
494 | ee6847d1 | Gerd Hoffmann | fprintf(stderr, "property \"%s.%s\" not found\n",
|
495 | ee6847d1 | Gerd Hoffmann | dev->info->name, name); |
496 | ee6847d1 | Gerd Hoffmann | return -1; |
497 | ee6847d1 | Gerd Hoffmann | } |
498 | ee6847d1 | Gerd Hoffmann | if (!prop->info->parse) {
|
499 | ee6847d1 | Gerd Hoffmann | fprintf(stderr, "property \"%s.%s\" has no parser\n",
|
500 | ee6847d1 | Gerd Hoffmann | dev->info->name, name); |
501 | ee6847d1 | Gerd Hoffmann | return -1; |
502 | ee6847d1 | Gerd Hoffmann | } |
503 | ee6847d1 | Gerd Hoffmann | return prop->info->parse(dev, prop, value);
|
504 | ee6847d1 | Gerd Hoffmann | } |
505 | ee6847d1 | Gerd Hoffmann | |
506 | ee6847d1 | Gerd Hoffmann | void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type) |
507 | ee6847d1 | Gerd Hoffmann | { |
508 | ee6847d1 | Gerd Hoffmann | Property *prop; |
509 | ee6847d1 | Gerd Hoffmann | void *dst;
|
510 | ee6847d1 | Gerd Hoffmann | |
511 | ee6847d1 | Gerd Hoffmann | prop = qdev_prop_find(dev, name); |
512 | ee6847d1 | Gerd Hoffmann | if (!prop) {
|
513 | ee6847d1 | Gerd Hoffmann | fprintf(stderr, "%s: property \"%s.%s\" not found\n",
|
514 | ee6847d1 | Gerd Hoffmann | __FUNCTION__, dev->info->name, name); |
515 | ee6847d1 | Gerd Hoffmann | abort(); |
516 | ee6847d1 | Gerd Hoffmann | } |
517 | ee6847d1 | Gerd Hoffmann | if (prop->info->type != type) {
|
518 | ee6847d1 | Gerd Hoffmann | fprintf(stderr, "%s: property \"%s.%s\" type mismatch\n",
|
519 | ee6847d1 | Gerd Hoffmann | __FUNCTION__, dev->info->name, name); |
520 | ee6847d1 | Gerd Hoffmann | abort(); |
521 | ee6847d1 | Gerd Hoffmann | } |
522 | ee6847d1 | Gerd Hoffmann | dst = qdev_get_prop_ptr(dev, prop); |
523 | ee6847d1 | Gerd Hoffmann | memcpy(dst, src, prop->info->size); |
524 | ee6847d1 | Gerd Hoffmann | } |
525 | ee6847d1 | Gerd Hoffmann | |
526 | c7cc172d | Juan Quintela | void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value) |
527 | c7cc172d | Juan Quintela | { |
528 | c7cc172d | Juan Quintela | qdev_prop_set(dev, name, &value, PROP_TYPE_UINT8); |
529 | c7cc172d | Juan Quintela | } |
530 | c7cc172d | Juan Quintela | |
531 | ee6847d1 | Gerd Hoffmann | void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value) |
532 | ee6847d1 | Gerd Hoffmann | { |
533 | ee6847d1 | Gerd Hoffmann | qdev_prop_set(dev, name, &value, PROP_TYPE_UINT16); |
534 | ee6847d1 | Gerd Hoffmann | } |
535 | ee6847d1 | Gerd Hoffmann | |
536 | ee6847d1 | Gerd Hoffmann | void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value) |
537 | ee6847d1 | Gerd Hoffmann | { |
538 | ee6847d1 | Gerd Hoffmann | qdev_prop_set(dev, name, &value, PROP_TYPE_UINT32); |
539 | ee6847d1 | Gerd Hoffmann | } |
540 | ee6847d1 | Gerd Hoffmann | |
541 | 316940b0 | Gerd Hoffmann | void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value) |
542 | 316940b0 | Gerd Hoffmann | { |
543 | 316940b0 | Gerd Hoffmann | qdev_prop_set(dev, name, &value, PROP_TYPE_INT32); |
544 | 316940b0 | Gerd Hoffmann | } |
545 | 316940b0 | Gerd Hoffmann | |
546 | 5a053d1f | Blue Swirl | void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value) |
547 | 5a053d1f | Blue Swirl | { |
548 | 5a053d1f | Blue Swirl | qdev_prop_set(dev, name, &value, PROP_TYPE_UINT64); |
549 | 5a053d1f | Blue Swirl | } |
550 | 5a053d1f | Blue Swirl | |
551 | 14b41872 | Gerd Hoffmann | void qdev_prop_set_drive(DeviceState *dev, const char *name, DriveInfo *value) |
552 | 14b41872 | Gerd Hoffmann | { |
553 | 14b41872 | Gerd Hoffmann | qdev_prop_set(dev, name, &value, PROP_TYPE_DRIVE); |
554 | 14b41872 | Gerd Hoffmann | } |
555 | 14b41872 | Gerd Hoffmann | |
556 | 313feaab | Gerd Hoffmann | void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value) |
557 | 313feaab | Gerd Hoffmann | { |
558 | 313feaab | Gerd Hoffmann | qdev_prop_set(dev, name, &value, PROP_TYPE_CHR); |
559 | 313feaab | Gerd Hoffmann | } |
560 | 313feaab | Gerd Hoffmann | |
561 | 2ef924b4 | Gerd Hoffmann | void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value) |
562 | 2ef924b4 | Gerd Hoffmann | { |
563 | 2ef924b4 | Gerd Hoffmann | qdev_prop_set(dev, name, &value, PROP_TYPE_NETDEV); |
564 | 2ef924b4 | Gerd Hoffmann | } |
565 | 2ef924b4 | Gerd Hoffmann | |
566 | 851bec09 | Gerd Hoffmann | void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value) |
567 | 851bec09 | Gerd Hoffmann | { |
568 | 851bec09 | Gerd Hoffmann | qdev_prop_set(dev, name, &value, PROP_TYPE_VLAN); |
569 | 851bec09 | Gerd Hoffmann | } |
570 | 851bec09 | Gerd Hoffmann | |
571 | 1503fff3 | Gerd Hoffmann | void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value) |
572 | 1503fff3 | Gerd Hoffmann | { |
573 | 1503fff3 | Gerd Hoffmann | qdev_prop_set(dev, name, value, PROP_TYPE_MACADDR); |
574 | 1503fff3 | Gerd Hoffmann | } |
575 | 1503fff3 | Gerd Hoffmann | |
576 | ee6847d1 | Gerd Hoffmann | void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value) |
577 | ee6847d1 | Gerd Hoffmann | { |
578 | ee6847d1 | Gerd Hoffmann | qdev_prop_set(dev, name, &value, PROP_TYPE_PTR); |
579 | ee6847d1 | Gerd Hoffmann | } |
580 | ee6847d1 | Gerd Hoffmann | |
581 | ee6847d1 | Gerd Hoffmann | void qdev_prop_set_defaults(DeviceState *dev, Property *props)
|
582 | ee6847d1 | Gerd Hoffmann | { |
583 | ee6847d1 | Gerd Hoffmann | char *dst;
|
584 | ee6847d1 | Gerd Hoffmann | |
585 | ee6847d1 | Gerd Hoffmann | if (!props)
|
586 | ee6847d1 | Gerd Hoffmann | return;
|
587 | ee6847d1 | Gerd Hoffmann | while (props->name) {
|
588 | ee6847d1 | Gerd Hoffmann | if (props->defval) {
|
589 | ee6847d1 | Gerd Hoffmann | dst = qdev_get_prop_ptr(dev, props); |
590 | ee6847d1 | Gerd Hoffmann | memcpy(dst, props->defval, props->info->size); |
591 | ee6847d1 | Gerd Hoffmann | } |
592 | ee6847d1 | Gerd Hoffmann | props++; |
593 | ee6847d1 | Gerd Hoffmann | } |
594 | ee6847d1 | Gerd Hoffmann | } |
595 | ee6847d1 | Gerd Hoffmann | |
596 | b6b61144 | Gerd Hoffmann | static CompatProperty *compat_props;
|
597 | b6b61144 | Gerd Hoffmann | |
598 | b6b61144 | Gerd Hoffmann | void qdev_prop_register_compat(CompatProperty *props)
|
599 | b6b61144 | Gerd Hoffmann | { |
600 | b6b61144 | Gerd Hoffmann | compat_props = props; |
601 | b6b61144 | Gerd Hoffmann | } |
602 | b6b61144 | Gerd Hoffmann | |
603 | b6b61144 | Gerd Hoffmann | void qdev_prop_set_compat(DeviceState *dev)
|
604 | b6b61144 | Gerd Hoffmann | { |
605 | b6b61144 | Gerd Hoffmann | CompatProperty *prop; |
606 | b6b61144 | Gerd Hoffmann | |
607 | b6b61144 | Gerd Hoffmann | if (!compat_props) {
|
608 | b6b61144 | Gerd Hoffmann | return;
|
609 | b6b61144 | Gerd Hoffmann | } |
610 | b6b61144 | Gerd Hoffmann | for (prop = compat_props; prop->driver != NULL; prop++) { |
611 | b6b61144 | Gerd Hoffmann | if (strcmp(dev->info->name, prop->driver) != 0) { |
612 | b6b61144 | Gerd Hoffmann | continue;
|
613 | b6b61144 | Gerd Hoffmann | } |
614 | b6b61144 | Gerd Hoffmann | if (qdev_prop_parse(dev, prop->property, prop->value) != 0) { |
615 | b6b61144 | Gerd Hoffmann | abort(); |
616 | b6b61144 | Gerd Hoffmann | } |
617 | b6b61144 | Gerd Hoffmann | } |
618 | b6b61144 | Gerd Hoffmann | } |