[libvirt] [PATCH] Add domain type checking

Matthias Bolte matthias.bolte at googlemail.com
Mon Jul 11 16:16:11 UTC 2011


2011/7/11 Daniel Veillard <veillard at redhat.com>:
> On Sat, Jul 09, 2011 at 03:38:32PM +0200, Matthias Bolte wrote:
>> 2011/7/8 Eric Blake <eblake at 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.

Yes, we can do that even for QEMU. See attached diff between v2 and v3
for easier review.

> 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 :-\

Yes, because the user might do this on purpose and not by accident.

-- 
Matthias Bolte
http://photron.blogspot.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: expected_virt_types_check_error_reporting.patch
Type: text/x-patch
Size: 2308 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110711/515ea653/attachment-0001.bin>


More information about the libvir-list mailing list