Re: [PATCHv2 2/5] S390: CPU support for s390(x)

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

 



On 22.06.2012 13:50, Viktor Mihajlovski wrote:
> From: Thang Pham <thang.pham@xxxxxxxxxx>
> 
> Adding CPU encoder/decoder for s390 to avoid runtime error messages.
> 
> Signed-off-by: Thang Pham <thang.pham@xxxxxxxxxx>
> Signed-off-by: Viktor Mihajlovski <mihajlov@xxxxxxxxxxxxxxxxxx>
> ---
>  src/Makefile.am     |    1 +
>  src/cpu/cpu.c       |    2 +
>  src/cpu/cpu_s390x.c |   80 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  src/cpu/cpu_s390x.h |   31 +++++++++++++++++++
>  4 files changed, 114 insertions(+), 0 deletions(-)
>  create mode 100644 src/cpu/cpu_s390x.c
>  create mode 100644 src/cpu/cpu_s390x.h
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index e40909b..b0bd3e8 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -566,6 +566,7 @@ CPU_SOURCES =							\
>  		cpu/cpu.h cpu/cpu.c				\
>  		cpu/cpu_generic.h cpu/cpu_generic.c		\
>  		cpu/cpu_x86.h cpu/cpu_x86.c cpu/cpu_x86_data.h	\
> +		cpu/cpu_s390x.h cpu/cpu_s390x.c 		\
>  		cpu/cpu_map.h cpu/cpu_map.c cpu/cpu_powerpc.h	\
>  		cpu/cpu_powerpc.c
>  
> diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
> index b8ccd24..08cb144 100644
> --- a/src/cpu/cpu.c
> +++ b/src/cpu/cpu.c
> @@ -29,6 +29,7 @@
>  #include "cpu.h"
>  #include "cpu_x86.h"
>  #include "cpu_powerpc.h"
> +#include "cpu_s390x.h"
>  #include "cpu_generic.h"
>  
>  
> @@ -38,6 +39,7 @@
>  static struct cpuArchDriver *drivers[] = {
>      &cpuDriverX86,
>      &cpuDriverPowerPC,
> +    &cpuDriverS390X,
>      /* generic driver must always be the last one */
>      &cpuDriverGeneric
>  };
> diff --git a/src/cpu/cpu_s390x.c b/src/cpu/cpu_s390x.c
> new file mode 100644
> index 0000000..da45433
> --- /dev/null
> +++ b/src/cpu/cpu_s390x.c
> @@ -0,0 +1,80 @@
> +/*
> + * cpu_s390x.c: CPU driver for s390x CPUs
> + *
> + * Copyright IBM Corp. 2012
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
> + *
> + * Authors:
> + *      Thang Pham <thang.pham@xxxxxxxxxx>
> + */
> +
> +#include <config.h>
> +
> +#include "memory.h"
> +#include "cpu.h"
> +
> +
> +#define VIR_FROM_THIS VIR_FROM_CPU
> +
> +static const char *archs[] = { "s390", "s390x" };
> +
> +static union cpuData *
> +s390xNodeData(void)
> +{
> +    union cpuData *data;
> +
> +    if (VIR_ALLOC(data) < 0) {
> +        virReportOOMError();
> +        return NULL;
> +    }
> +
> +    return data;
> +}
> +
> +
> +static int
> +s390xDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
> +              const union cpuData *data ATTRIBUTE_UNUSED,
> +              const char **models ATTRIBUTE_UNUSED,
> +              unsigned int nmodels ATTRIBUTE_UNUSED,
> +              const char *preferred ATTRIBUTE_UNUSED)
> +{
> +        return 0;
> +}

Again indent.

> +
> +static void
> +s390xDataFree(union cpuData *data)
> +{
> +   if (data == NULL)
> +       return;

Useless. VIR_FREE handles this.

> +
> +   VIR_FREE(data);
> +}
> +
> +struct cpuArchDriver cpuDriverS390X = {
> +    .name = "s390x",
> +    .arch = archs,
> +    .narch = ARRAY_CARDINALITY(archs),
> +    .compare    = NULL,
> +    .decode     = s390xDecode,
> +    .encode     = NULL,
> +    .free       = s390xDataFree,
> +    .nodeData   = s390xNodeData,
> +    .guestData  = NULL,
> +    .baseline   = NULL,
> +    .update     = NULL,
> +    .hasFeature = NULL,
> +};
> diff --git a/src/cpu/cpu_s390x.h b/src/cpu/cpu_s390x.h
> new file mode 100644
> index 0000000..f91377f
> --- /dev/null
> +++ b/src/cpu/cpu_s390x.h
> @@ -0,0 +1,31 @@
> +/*
> + * cpu_s390x.c: CPU driver for s390x CPUs
> + *
> + * Copyright IBM Corp. 2012
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
> + *
> + * Authors:
> + *      Thang Pham <thang.pham@xxxxxxxxxx>
> + */
> +
> +#ifndef __VIR_CPU_S390X_H__
> +# define __VIR_CPU_S390X_H__
> +
> +# include "cpu.h"
> +
> +extern struct cpuArchDriver cpuDriverS390X;
> +
> +#endif /* __VIR_CPU_S390X_H__ */
> 


Fixed, renamed to cpu_s390.[ch] and pushed.

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]