On 11/11/2015 02:27 PM, Eduardo Habkost wrote: > Instead of requiring a separate function for each VGA interface, > just enumerate the corresponding class names on struct > VGAInterfaceInfo. > > Signed-off-by: Eduardo Habkost <[email protected]> > --- > vl.c | 70 > +++++++++++++++++++++++--------------------------------------------- > 1 file changed, 23 insertions(+), 47 deletions(-) >
> [VGA_CG3] = {
> .opt_name = "cg3",
> .name = "CG3 framebuffer",
> - .available = cg3_vga_available,
> + .class_names = { "cgthree" },
> },
> [VGA_XENFB] = {
> .opt_name = "xenfb",
> },
> };
>
> +static bool vga_interface_available(VGAInterfaceType t)
> +{
> + VGAInterfaceInfo *ti = &vga_interfaces[t];
> +
> + assert(t < VGA_TYPE_MAX);
> + return !ti->class_names[0] ||
> + object_class_by_name(ti->class_names[0]) ||
> + object_class_by_name(ti->class_names[1]);
Does the correct thing when ti->class_names[1] is NULL (but I had to look).
Reviewed-by: Eric Blake <[email protected]>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
