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

Re: [libvirt] [PATCH] Add domain type checking



On Sat, Jul 09, 2011 at 03:38:32PM +0200, Matthias Bolte wrote:
> 2011/7/8 Eric Blake <eblake redhat com>:
> > On 07/08/2011 02:13 AM, Matthias Bolte wrote:
> >> The drivers were accepting domain configs without checking if those
> >> were actually meant for them. For example the LXC driver happily
> >> accepts configs with type QEMU.
> >>
> >> For convenience add an optional check for the domain type for the
> >> virDomainDefParse* functions. It's optional because in some places
> >> virDomainDefParse* is used to parse a config without caring about
> >> it's type. Also the QEMU driver has to accept 4 different types and
> >> does this checking own it's own.
> >
> > Can we factor the 4 QEMU types back into the common method?  Do this by
> > treating expectedType as a bitmask:
[...]
> @@ -5836,6 +5842,13 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
>      }
>      VIR_FREE(tmp);
>  
> +    if (((1 << def->virtType) & expectedVirtTypes) == 0) {
> +        virDomainReportError(VIR_ERR_INTERNAL_ERROR,
> +                             _("unexpected domain type %s"),
> +                             virDomainVirtTypeToString(def->virtType));
> +        goto error;
> +    }
> +

  Looks fine, ACK

My only regret here is that we can't really suggest the value expected
because QEmu accepts more than one, but for other drivers we should be
able to provide what type is expected.
Anyway the main error here is when people use qemu instead of kvm and
end up with a non-accelerated guest and there is nothing we can do there :-\

Daniel

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


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