Paolo Bonzini <pbonz...@redhat.com> writes:

[...]
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index 5a8739d..2759c83 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -1,6 +1,7 @@
>  #include "net.h"
>  #include "qdev.h"
>  #include "qerror.h"
> +#include "cpus.h"
>  
>  void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
>  {
> @@ -281,6 +282,44 @@ PropertyInfo qdev_prop_string = {
>      .free  = free_string,
>  };
>  
> +/* --- cpu --- */
> +
> +static int parse_cpu(DeviceState *dev, Property *prop, const char *str)
> +{
> +    CPUState **ptr = qdev_get_prop_ptr(dev, prop);
> +    char *end;
> +    int id;
> +
> +    if (!*str)
> +        return -ENOENT;
> +
> +    id = strtol (str, &end, 0);
> +    if (*end)
> +        return -ENOENT;
> +
> +    *ptr = cpu_get_by_id(id);
> +    if (*ptr == NULL)
> +        return -ENOENT;
> +    return 0;
> +}
> +
> +static int print_cpu(DeviceState *dev, Property *prop, char *dest, size_t 
> len)
> +{
> +    CPUState **ptr = qdev_get_prop_ptr(dev, prop);
> +    if (*ptr)
> +        return snprintf(dest, len, "CPU #%d", cpu_get_id(*ptr));
> +    else
> +     return snprintf(dest, len, "CPU #<null>");
> +}

Hmm.  Parse method doesn't accept output of the print method.  Not so
nice.  Is the "CPU #" decoration essential?

Oh, and beware of the Secret Tab Police.

[...]

Reply via email to