[libvirt] [PATCH] cpu_ppc64: Error out when model tag missing in virsh cpu-compare xml

Nitesh Konkar posted 1 patch 6 years, 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20170918165752.7996-1-niteshkonkar.libvirt@gmail.com
src/cpu/cpu_ppc64.c | 6 ++++++
1 file changed, 6 insertions(+)
[libvirt] [PATCH] cpu_ppc64: Error out when model tag missing in virsh cpu-compare xml
Posted by Nitesh Konkar 6 years, 6 months ago
libvirtd throws unhandled signal 11 on ppc while running
virsh cpu-compare with missing model tag in the xml. This
patch errors out in such situation.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
---
 src/cpu/cpu_ppc64.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index b58e80a..c11ac9f 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -247,6 +247,12 @@ ppc64ModelFromCPU(const virCPUDef *cpu,
 {
     struct ppc64_model *model;
 
+    if (!cpu->model) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("no guest CPU model specified"));
+        return NULL;
+    }
+
     if (!(model = ppc64ModelFind(map, cpu->model))) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unknown CPU model %s"), cpu->model);
-- 
2.9.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] cpu_ppc64: Error out when model tag missing in virsh cpu-compare xml
Posted by Nitesh Konkar 6 years, 6 months ago
Gentle ping.

On Mon, Sep 18, 2017 at 10:27 PM, Nitesh Konkar <
niteshkonkar.libvirt@gmail.com> wrote:

> libvirtd throws unhandled signal 11 on ppc while running
> virsh cpu-compare with missing model tag in the xml. This
> patch errors out in such situation.
>
> Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> ---
>  src/cpu/cpu_ppc64.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
> index b58e80a..c11ac9f 100644
> --- a/src/cpu/cpu_ppc64.c
> +++ b/src/cpu/cpu_ppc64.c
> @@ -247,6 +247,12 @@ ppc64ModelFromCPU(const virCPUDef *cpu,
>  {
>      struct ppc64_model *model;
>
> +    if (!cpu->model) {
> +        virReportError(VIR_ERR_INVALID_ARG, "%s",
> +                       _("no guest CPU model specified"));
> +        return NULL;
> +    }
> +
>      if (!(model = ppc64ModelFind(map, cpu->model))) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("Unknown CPU model %s"), cpu->model);
> --
> 2.9.5
>
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] cpu_ppc64: Error out when model tag missing in virsh cpu-compare xml
Posted by John Ferlan 6 years, 6 months ago

On 09/18/2017 12:57 PM, Nitesh Konkar wrote:
> libvirtd throws unhandled signal 11 on ppc while running
> virsh cpu-compare with missing model tag in the xml. This
> patch errors out in such situation.


You could provide the example XML snippet ...  and as noted below what
the "expectations" are...

> 
> Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> ---
>  src/cpu/cpu_ppc64.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 

I assume since you didn't provide a stack trace, the caller is either
has "cpu->type == VIR_CPU_TYPE_GUEST && cpu->mode ==
VIR_CPU_MODE_CUSTOM" or "cpu->type != VIR_CPU_TYPE_GUEST", right? It's
not the host_model failure.

If so, then the commit message should indicate that "it's expected" that
for specific comparison types that the model was filled in

In the end - just want to make sure that the symptom being fixed isn't
masking a problem of insufficient checking on XML parse for specific types

> diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
> index b58e80a..c11ac9f 100644
> --- a/src/cpu/cpu_ppc64.c
> +++ b/src/cpu/cpu_ppc64.c
> @@ -247,6 +247,12 @@ ppc64ModelFromCPU(const virCPUDef *cpu,
>  {
>      struct ppc64_model *model;
>  
> +    if (!cpu->model) {
> +        virReportError(VIR_ERR_INVALID_ARG, "%s",
> +                       _("no guest CPU model specified"));

or "CPU model not specified"...

The "concern" being that this code is used for multiple purposes
(host_model, cpu->type == GUEST && cpu->model == CUSTOM, and cpu->type
!= GUEST) - so using "guest" could be a misnomer.

John

> +        return NULL;
> +    }
> +
>      if (!(model = ppc64ModelFind(map, cpu->model))) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("Unknown CPU model %s"), cpu->model);
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] cpu_ppc64: Error out when model tag missing in virsh cpu-compare xml
Posted by Jiri Denemark 6 years, 5 months ago
On Mon, Sep 18, 2017 at 22:27:52 +0530, Nitesh Konkar wrote:
> libvirtd throws unhandled signal 11 on ppc while running
> virsh cpu-compare with missing model tag in the xml. This
> patch errors out in such situation.
> 
> Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> ---
>  src/cpu/cpu_ppc64.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
> index b58e80a..c11ac9f 100644
> --- a/src/cpu/cpu_ppc64.c
> +++ b/src/cpu/cpu_ppc64.c
> @@ -247,6 +247,12 @@ ppc64ModelFromCPU(const virCPUDef *cpu,
>  {
>      struct ppc64_model *model;
>  
> +    if (!cpu->model) {
> +        virReportError(VIR_ERR_INVALID_ARG, "%s",
> +                       _("no guest CPU model specified"));
> +        return NULL;
> +    }
> +
>      if (!(model = ppc64ModelFind(map, cpu->model))) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("Unknown CPU model %s"), cpu->model);

ACK and pushed with the removal of "guest" in the error message as
suggested by John.

Thanks,

Jirka

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