qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 5/7] add qdev property type "cpu"


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 5/7] add qdev property type "cpu"
Date: Sat, 26 Jun 2010 09:46:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Paolo Bonzini <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]