[libvirt PATCH 08/20] qemu: Introduce virQEMUCapsAccelStr

Andrea Bolognani abologna at redhat.com
Fri Jan 21 17:26:59 UTC 2022


On Fri, Jan 21, 2022 at 09:20:42AM -0800, Andrea Bolognani wrote:
> On Fri, Jan 21, 2022 at 04:57:34PM +0000, Daniel P. Berrangé wrote:
> > I'd say we should just directly return the virt types we actually
> > expect to get - the invalid ones will have already been filtered
> > out. ie
> >
> >  virQEMUCapsAccelStr(virDomainVirtType type)
> >  {
> >      if (type == VIR_DOMAIN_VIRT_KVM)
> >          return "kvm";
> >      else
> >          return "tcg";
> >  }
> >
> > that is still easily extended to add hvf and so on, without being
> > misleading about supporting any virt type
>
> The original version works because, as you note, we already make sure
> much earlier[1] that only values that correspond to valid QEMU
> accelerators can be used, but I'm okay with being more explicit.
>
> I'd rather use a switch statement though, that way next time an
> accelerator has to be added there will be fewer spots where we can
> easily forget to add handling for it. Does that sound good?

Actually virQEMUCapsGetAccel() already looks like what you proposed,
and they're close together. Let's go for the simpler version.

-- 
Andrea Bolognani / Red Hat / Virtualization





More information about the libvir-list mailing list