Re: [PATCH] cpu: Fail when CPU type cannot be detected from XML

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

 



On Mon, Jul 12, 2010 at 05:49:53PM +0200, Jiri Denemark wrote:
> When autodetecting whether XML describes guest or host CPU, the presence
> of <arch> element is checked. If it's present, we treat the XML as host
> CPU definition. Which is right, since guest CPU definitions do not
> contain <arch> element. However, if at the same time the root <cpu>
> element contains `match' attribute, we would silently ignore it and
> still treat the XML as host CPU. We should rather refuse such invalid
> XML.
> ---
>  src/conf/cpu_conf.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
> index d9aa69c..35bcce8 100644
> --- a/src/conf/cpu_conf.c
> +++ b/src/conf/cpu_conf.c
> @@ -130,9 +130,15 @@ virCPUDefParseXML(const xmlNodePtr node,
>      }
>  
>      if (mode == VIR_CPU_TYPE_AUTO) {
> -        if (virXPathBoolean("boolean(./arch)", ctxt))
> +        if (virXPathBoolean("boolean(./arch)", ctxt)) {
> +            if (virXPathBoolean("boolean(./@match)", ctxt)) {
> +                virCPUReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                        _("'arch' element element cannot be used inside 'cpu'"
> +                          " element with 'match' attribute'"));
> +                goto error;
> +            }
>              def->type = VIR_CPU_TYPE_HOST;
> -        else
> +        } else
>              def->type = VIR_CPU_TYPE_GUEST;
>      } else
>          def->type = mode;

  except since it's user provided data, we should use error
  VIR_ERR_XML_ERROR instead of VIR_ERR_INTERNAL_ERROR,

ACK, once that is fixed

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
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]