[libvirt] [PATCH 1/2] Move struct _virPCIDevice definition from virpci.c to virpci.h

Shivaprasad bhat shivaprasadbhat at gmail.com
Wed Jan 14 13:01:11 UTC 2015


Thanks for the comments Michal. I just posted the v2 for review.

Regards.
Shiva

On Mon, Jan 12, 2015 at 2:43 PM, Michal Privoznik <mprivozn at redhat.com> wrote:
> On 04.12.2014 08:27, Shivaprasad G Bhat wrote:
>>
>> The struct members can't be referenced from files including the .h.
>> Moving the definition to .h from .c helps referencing the members. The
>> patch
>> is just the struct definition code movement.
>>
>> Signed-off-by: Shivaprasad G Bhat <sbhat at linux.vnet.ibm.com>
>> ---
>>   src/util/virpci.c |   29 -----------------------------
>>   src/util/virpci.h |   30 ++++++++++++++++++++++++++++++
>>   2 files changed, 30 insertions(+), 29 deletions(-)
>>
>> diff --git a/src/util/virpci.c b/src/util/virpci.c
>> index cd78212..74c5c9b 100644
>> --- a/src/util/virpci.c
>> +++ b/src/util/virpci.c
>> @@ -49,39 +49,10 @@
>>   VIR_LOG_INIT("util.pci");
>>
>>   #define PCI_SYSFS "/sys/bus/pci/"
>> -#define PCI_ID_LEN 10   /* "XXXX XXXX" */
>> -#define PCI_ADDR_LEN 13 /* "XXXX:XX:XX.X" */
>>
>>   VIR_ENUM_IMPL(virPCIELinkSpeed, VIR_PCIE_LINK_SPEED_LAST,
>>                 "", "2.5", "5", "8")
>>
>> -struct _virPCIDevice {
>> -    unsigned int  domain;
>> -    unsigned int  bus;
>> -    unsigned int  slot;
>> -    unsigned int  function;
>> -
>> -    char          name[PCI_ADDR_LEN]; /* domain:bus:slot.function */
>> -    char          id[PCI_ID_LEN];     /* product vendor */
>> -    char          *path;
>> -
>> -    /* The driver:domain which uses the device */
>> -    char          *used_by_drvname;
>> -    char          *used_by_domname;
>> -
>> -    unsigned int  pcie_cap_pos;
>> -    unsigned int  pci_pm_cap_pos;
>> -    bool          has_flr;
>> -    bool          has_pm_reset;
>> -    bool          managed;
>> -    char          *stubDriver;
>> -
>> -    /* used by reattach function */
>> -    bool          unbind_from_stub;
>> -    bool          remove_slot;
>> -    bool          reprobe;
>> -};
>> -
>>   struct _virPCIDeviceList {
>>       virObjectLockable parent;
>>
>> diff --git a/src/util/virpci.h b/src/util/virpci.h
>> index 1ce9821..0612f08 100644
>> --- a/src/util/virpci.h
>> +++ b/src/util/virpci.h
>> @@ -35,6 +35,36 @@ typedef virPCIDeviceAddress *virPCIDeviceAddressPtr;
>>   typedef struct _virPCIDeviceList virPCIDeviceList;
>>   typedef virPCIDeviceList *virPCIDeviceListPtr;
>>
>> +# define PCI_ID_LEN 10   /* "XXXX XXXX" */
>> +# define PCI_ADDR_LEN 13 /* "XXXX:XX:XX.X" */
>> +
>> +struct _virPCIDevice {
>> +    unsigned int  domain;
>> +    unsigned int  bus;
>> +    unsigned int  slot;
>> +    unsigned int  function;
>> +
>> +    char          name[PCI_ADDR_LEN]; /* domain:bus:slot.function */
>> +    char          id[PCI_ID_LEN];     /* product vendor */
>> +    char          *path;
>> +
>> +    /* The driver:domain which uses the device */
>> +    char          *used_by_drvname;
>> +    char          *used_by_domname;
>> +
>> +    unsigned int  pcie_cap_pos;
>> +    unsigned int  pci_pm_cap_pos;
>> +    bool          has_flr;
>> +    bool          has_pm_reset;
>> +    bool          managed;
>> +    char          *stubDriver;
>> +
>> +    /* used by reattach function */
>> +    bool          unbind_from_stub;
>> +    bool          remove_slot;
>> +    bool          reprobe;
>> +};
>> +
>>   struct _virPCIDeviceAddress {
>>       unsigned int domain;
>>       unsigned int bus;
>>
>
> I think instead of exposing the struct we may need getters,
> virPCIDeviceGetDomain(), virPCIDeviceGetBus(), etc.
> Or even better, virPCIdeviceGetAddress() which would return type of
> virPCIDeviceAddress.
>
> Michal




More information about the libvir-list mailing list