aboutsummaryrefslogtreecommitdiff
path: root/hw/qdev-properties.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-02-09 10:07:38 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-02-22 08:31:24 +0100
commit97aa6e9b8f9df37add21d86fac1a9ca6ce7df9b7 (patch)
tree570727fedc786739c2a89fc3e3ab5ec5704b309a /hw/qdev-properties.c
parent768a9ebe188bd0a6172a9a4e64777d21fff7f014 (diff)
qdev: accept hex properties only if prefixed by 0x
Hex properties are an obstacle to removal of old qdev string parsing, but even here we can lay down the foundations for future simplification. In general, they are rarely used and their printed form is more interesting than the parsing. For example you'd usually set isa-serial.index instead of isa-serial.iobase. And luckily our main client, libvirt only cares about few of these, and always sets them with a 0x prefix. So the series stops accepting bare hexadecimal numbers, preparing for making legacy properties read-only in 1.3 or so. The read side will stay as long as "info qtree" is with us. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/qdev-properties.c')
-rw-r--r--hw/qdev-properties.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 0deb378009..a4545f7969 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -164,6 +164,10 @@ static int parse_hex8(DeviceState *dev, Property *prop, const char *str)
uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
char *end;
+ if (str[0] != '0' || str[1] != 'x') {
+ return -EINVAL;
+ }
+
*ptr = strtoul(str, &end, 16);
if ((*end != '\0') || (end == str)) {
return -EINVAL;
@@ -369,6 +373,10 @@ static int parse_hex32(DeviceState *dev, Property *prop, const char *str)
uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
char *end;
+ if (str[0] != '0' || str[1] != 'x') {
+ return -EINVAL;
+ }
+
*ptr = strtoul(str, &end, 16);
if ((*end != '\0') || (end == str)) {
return -EINVAL;
@@ -456,6 +464,10 @@ static int parse_hex64(DeviceState *dev, Property *prop, const char *str)
uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
char *end;
+ if (str[0] != '0' || str[1] != 'x') {
+ return -EINVAL;
+ }
+
*ptr = strtoull(str, &end, 16);
if ((*end != '\0') || (end == str)) {
return -EINVAL;