Re: [PATCH] qemu: Take all PHBs into account while calculating memlock limits

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

 



On Fri, 2017-06-30 at 13:56 +0530, Shivaprasad G Bhat wrote:
> -        /* TODO: Detect at runtime once we start using more than just
> -         *       the default PCI Host Bridge */
> -        nPCIHostBridges = 1;
> +        for (i = 0; i < def->ncontrollers; i++) {
> +            if (def->controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_PCI ||
> +                def->controllers[i]->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) {
> +                continue;
> +            }
> +            nPCIHostBridges++;
> +        }

Just to be on the safe side, we should probably make sure the
pci-root controller is actually a PHB by looking at modelName
as well, like:

  for (i = 0; i < def->ncontrollers; i++) {
      virDomainControllerDefPtr cont = def->controllers[i];

      if (cont->type != VIR_DOMAIN_CONTROLLER_TYPE_PCI ||
          cont->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT ||
          cont->opts.pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE) {
          continue;
      }

      nPCIHostBridges++;
  }

Boy, that model name sure is a mouthful[1].

I think we might have enough occurrences of this pattern to
warrant the creation of a virDomainControllerIsPCIHostBridge()
helper function, which you could then use in your patch.

That said, it might be smarter to do so in a follow-up cleanup
commit in order not to invalidate existing Reviewed-by tags.
Laine, what would be your preference?


[1] Except for fingers. Fingerful?
-- 
Andrea Bolognani / Red Hat / Virtualization

--
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]
  Powered by Linux