Re: [PATCH 2/6] conf: new functions to check if PCI address is wanted/present

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

 



On 05/19/2016 01:21 PM, Ján Tomko wrote:
On Wed, May 18, 2016 at 03:23:50PM -0400, Laine Stump wrote:
In order to allow <address type='pci'/> with no other attributes to
mean "I want a PCI address, but any PCI address will do" (just as
having no <address> at all usually indicates), we will need to change
several places in the code from a simple "info->type == (or !=)
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_(PCI|NONE)" into something slightly
more complex, this patch adds to new functions that take a
virDomainDeviceInfoPtr and return true/false depending on 1) whether
the current state of the info indicates that we "want" a PCI address
for this device (virDeviceInfoPCIAddressWanted()) and 2) whether this
device already has a valid PCI address
(virDeviceInfoPCIAddressPresent()).

Both of these functions required the simpler check for whether a pci
address is "empty" (i.e. all of its attributes are 0, which can never
happen in a real PCI address, since slot 0 of bus 0 of domain 0 is
always reserved), so that function is also added.
---
  src/conf/device_conf.h | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)

diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index 46c720d..847564b 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -184,6 +184,27 @@ typedef struct _virDomainDeviceInfo {
  int virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
                                 bool report);
+static inline bool
I think inline keywords are pointless nowadays. Some compilers will
inline the functions even if you don't want them to.

If you remove "inline" from a function defined in a .h file, then it becomes a simple "static bool f()...", which gives you this error when compiling any .c file that includes the .h but doesn't use the function:

In file included from util/virnetdev.h:34:0,
from util/virnetdevveth.c:36:
./conf/device_conf.h:194:1: error: 'virDeviceInfoPCIAddressWanted' defined but not used [-Werror=unused-function] virDeviceInfoPCIAddressWanted(const virDomainDeviceInfo *info) ^


And if you remove both static *and* inline, you get this:

In file included from ./conf/domain_conf.h:48:0,
                 from ./conf/virdomainobjlist.h:28,
                 from util/virclosecallbacks.h:28,
                 from util/virclosecallbacks.c:28:
./conf/device_conf.h:188:1: error: no previous prototype for 'virPCIDeviceAddressIsEmpty' [-Werror=missing-prototypes]
 virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr)
 ^

(and if you disabled that warning and got far enough to link, you could end up with a linker error due to multiple definitions of the same function in multiple .o's).

--
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]