virpci: Allow greater PCI domain value in virPCIDeviceAddressIsValid

There is no restriction on maximum value of PCI domain. In fact,
Linux kernel uses plain atomic inc when assigning PCI domains:

drivers/pci/pci.c:static int pci_get_new_domain_nr(void)
drivers/pci/pci.c-{
drivers/pci/pci.c-      return atomic_inc_return(&__domain_nr);
drivers/pci/pci.c-}

Of course, this function is called only if kernel was compiled
without PCI domain support or ACPI did not provide PCI domain.

However, QEMU still has the same restriction as us: in
set_pci_host_devaddr() QEMU checks if domain isn't greater than
0xffff. But one can argue that that's a QEMU limitation. We still
want to be able to cope with other hypervisors that don't have
this limitation (possibly).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2019-07-30 16:37:20 +02:00
parent 9b332820f3
commit d19c21429f
3 changed files with 3 additions and 3 deletions

View File

@ -324,7 +324,7 @@
</define>
<define name="pciDomain">
<ref name="uint16"/>
<ref name="uint32"/>
</define>
<define name="pciBus">
<ref name="uint8"/>

View File

@ -1668,7 +1668,7 @@ bool
virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
bool report)
{
if (addr->domain > 0xFFFF) {
if (addr->domain > 0xFFFFFFFF) {
if (report)
virReportError(VIR_ERR_XML_ERROR,
_("Invalid PCI address domain='0x%x', "

View File

@ -26,7 +26,7 @@
<interface type='user'>
<mac address='00:11:22:33:44:55'/>
<model type='rtl8139'/>
<address type='pci' domain='0x10000' bus='0x00' slot='0x05' function='0x0'/>
<address type='pci' domain='0x0000' bus='0x100' slot='0x05' function='0x0'/>
</interface>
<memballoon model='none'/>
</devices>