[Ovirt-devel] [PATCH] Adding NIC details to ovirt identify stage.

Daniel P. Berrange berrange at redhat.com
Fri Jul 11 19:46:43 UTC 2008


On Fri, Jul 11, 2008 at 03:28:50PM -0400, Darryl L. Pierce wrote:
> This patch includes submitting to the server the MAC address and bandwidth, as
> determined via HAL, for each physical NIC in the machine. 


> +int get_cpu_info(void)
> +{
> +    int result = 1;
> +    FILE* inputfd;
> +    t_cpu_info* current = NULL;
> +
> +    if(( inputfd = fopen("/proc/cpuinfo","rb")) != NULL)

This is just plain wrong if running on Xen. This is why we provide
the virNodeGetInfo API in libvirt, which knows whether to ask
/proc/cpuinfo, or whether to query the hypervisor for the real info

> +    {
> +        VERBOSE("Parsing CPU information\n");
> +        do
> +        {
> +            char buffer[255];
> +            char label[BUFFER_LENGTH];
> +            char value[BUFFER_LENGTH];
> +
> +            fgets(buffer, 255, inputfd);
> +            if(strlen(buffer) > 0) buffer[strlen(buffer) - 1] = '\0';
> +
> +            get_label_and_value(buffer,
> +                                label,BUFFER_LENGTH,
> +                                value,BUFFER_LENGTH);
> +
> +            DEBUG("label=\"%s\", value=\"%s\"\n", label, value);
> +
> +            if(strlen(label))
> +            {
> +                if(!strcmp(label,"processor"))
> +                {
> +                    VERBOSE("Starting new CPU\n");
> +
> +                    t_cpu_info* last = current;
> +
> +                    current = create_cpu_info();
> +                    if(last != NULL)
> +                    {
> +                        last->next = current;
> +                    }
> +                    else
> +                    {
> +                        cpu_info = current;
> +                    }
> +
> +                    COPY_VALUE_TO_BUFFER(value,current->cpu_num,BUFFER_LENGTH);
> +                }
> +                else
> +                if(!strcmp(label,"core id"))
> +                {
> +                    COPY_VALUE_TO_BUFFER(value,current->core_num,BUFFER_LENGTH);
> +                }

This data is useless/wrong on Xen.

> +                else
> +                if(!strcmp(label,"cpu cores"))
> +                {
> +                    COPY_VALUE_TO_BUFFER(value,current->number_of_cores,BUFFER_LENGTH);
> +                }

This data is useless/wrong on Xen.

> +                else
> +                if(!strcmp(label,"vendor_id"))
> +                {
> +                    COPY_VALUE_TO_BUFFER(value,current->vendor,BUFFER_LENGTH);
> +                }

> +                else
> +                if(!strcmp(label,"model"))
> +                {
> +                    COPY_VALUE_TO_BUFFER(value,current->model,BUFFER_LENGTH);
> +                }
> +                else
> +                if(!strcmp(label,"cpu family"))
> +                {
> +                    COPY_VALUE_TO_BUFFER(value,current->family,BUFFER_LENGTH);
> +                }
> +                else
> +                if(!strcmp(label,"cpuid level"))
> +                {
> +                    COPY_VALUE_TO_BUFFER(value,current->cpuid_level,BUFFER_LENGTH);
> +                }
> +                else
> +                if(!strcmp(label,"cpu MHz"))
> +                {
> +                    COPY_VALUE_TO_BUFFER(value,current->speed,BUFFER_LENGTH);
> +                }
> +                else

This data is useless/wrong if CPU frequency scaling is
active - it is active by default

> +                if(!strcmp(label,"cache size"))
> +                {
> +                    COPY_VALUE_TO_BUFFER(value,current->cache,BUFFER_LENGTH);
> +                }
> +                else
> +                if(!strcmp(label,"flags"))
> +                {
> +                    COPY_VALUE_TO_BUFFER(value,current->flags,BUFFER_LENGTH);
> +                }

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the ovirt-devel mailing list