mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: Move more PCI functions out of device_conf
Functions that deal with virPCIDeviceAddress exclusively belong to util/virpci. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
16858439de
commit
679895eb5d
@ -160,59 +160,6 @@ virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
|
|
||||||
bool report)
|
|
||||||
{
|
|
||||||
if (addr->domain > 0xFFFF) {
|
|
||||||
if (report)
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid PCI address domain='0x%x', "
|
|
||||||
"must be <= 0xFFFF"),
|
|
||||||
addr->domain);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (addr->bus > 0xFF) {
|
|
||||||
if (report)
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid PCI address bus='0x%x', "
|
|
||||||
"must be <= 0xFF"),
|
|
||||||
addr->bus);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (addr->slot > 0x1F) {
|
|
||||||
if (report)
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid PCI address slot='0x%x', "
|
|
||||||
"must be <= 0x1F"),
|
|
||||||
addr->slot);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (addr->function > 7) {
|
|
||||||
if (report)
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("Invalid PCI address function=0x%x, "
|
|
||||||
"must be <= 7"),
|
|
||||||
addr->function);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (virPCIDeviceAddressIsEmpty(addr)) {
|
|
||||||
if (report)
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("Invalid PCI address 0000:00:00, at least "
|
|
||||||
"one of domain, bus, or slot must be > 0"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr)
|
|
||||||
{
|
|
||||||
return !(addr->domain || addr->bus || addr->slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
virDeviceInfoPCIAddressIsWanted(const virDomainDeviceInfo *info)
|
virDeviceInfoPCIAddressIsWanted(const virDomainDeviceInfo *info)
|
||||||
{
|
{
|
||||||
@ -309,19 +256,6 @@ virPCIDeviceAddressFormat(virBufferPtr buf,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1,
|
|
||||||
virPCIDeviceAddress *addr2)
|
|
||||||
{
|
|
||||||
if (addr1->domain == addr2->domain &&
|
|
||||||
addr1->bus == addr2->bus &&
|
|
||||||
addr1->slot == addr2->slot &&
|
|
||||||
addr1->function == addr2->function) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr)
|
virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr)
|
||||||
{
|
{
|
||||||
|
@ -191,10 +191,6 @@ bool virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a,
|
|||||||
bool virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
|
bool virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
|
||||||
int type);
|
int type);
|
||||||
|
|
||||||
bool virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
|
|
||||||
bool report);
|
|
||||||
bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr);
|
|
||||||
|
|
||||||
bool virDeviceInfoPCIAddressIsWanted(const virDomainDeviceInfo *info);
|
bool virDeviceInfoPCIAddressIsWanted(const virDomainDeviceInfo *info);
|
||||||
bool virDeviceInfoPCIAddressIsPresent(const virDomainDeviceInfo *info);
|
bool virDeviceInfoPCIAddressIsPresent(const virDomainDeviceInfo *info);
|
||||||
|
|
||||||
@ -205,9 +201,6 @@ int virPCIDeviceAddressFormat(virBufferPtr buf,
|
|||||||
virPCIDeviceAddress addr,
|
virPCIDeviceAddress addr,
|
||||||
bool includeTypeInAddr);
|
bool includeTypeInAddr);
|
||||||
|
|
||||||
bool virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1,
|
|
||||||
virPCIDeviceAddress *addr2);
|
|
||||||
|
|
||||||
bool virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr);
|
bool virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr);
|
||||||
int virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
|
int virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
|
||||||
virDomainDeviceCCWAddressPtr addr);
|
virDomainDeviceCCWAddressPtr addr);
|
||||||
|
@ -108,10 +108,7 @@ virDomainDeviceUSBAddressParseXML;
|
|||||||
virDomainDeviceVirtioSerialAddressParseXML;
|
virDomainDeviceVirtioSerialAddressParseXML;
|
||||||
virInterfaceLinkFormat;
|
virInterfaceLinkFormat;
|
||||||
virInterfaceLinkParseXML;
|
virInterfaceLinkParseXML;
|
||||||
virPCIDeviceAddressEqual;
|
|
||||||
virPCIDeviceAddressFormat;
|
virPCIDeviceAddressFormat;
|
||||||
virPCIDeviceAddressIsEmpty;
|
|
||||||
virPCIDeviceAddressIsValid;
|
|
||||||
virPCIDeviceAddressParseXML;
|
virPCIDeviceAddressParseXML;
|
||||||
|
|
||||||
|
|
||||||
@ -2498,10 +2495,13 @@ virObjectUnref;
|
|||||||
|
|
||||||
# util/virpci.h
|
# util/virpci.h
|
||||||
virPCIDeviceAddressAsString;
|
virPCIDeviceAddressAsString;
|
||||||
|
virPCIDeviceAddressEqual;
|
||||||
virPCIDeviceAddressGetIOMMUGroupAddresses;
|
virPCIDeviceAddressGetIOMMUGroupAddresses;
|
||||||
virPCIDeviceAddressGetIOMMUGroupNum;
|
virPCIDeviceAddressGetIOMMUGroupNum;
|
||||||
virPCIDeviceAddressGetSysfsFile;
|
virPCIDeviceAddressGetSysfsFile;
|
||||||
virPCIDeviceAddressIOMMUGroupIterate;
|
virPCIDeviceAddressIOMMUGroupIterate;
|
||||||
|
virPCIDeviceAddressIsEmpty;
|
||||||
|
virPCIDeviceAddressIsValid;
|
||||||
virPCIDeviceAddressParse;
|
virPCIDeviceAddressParse;
|
||||||
virPCIDeviceCopy;
|
virPCIDeviceCopy;
|
||||||
virPCIDeviceDetach;
|
virPCIDeviceDetach;
|
||||||
|
@ -1668,6 +1668,71 @@ virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name)
|
|||||||
return id_str;
|
return id_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
|
||||||
|
bool report)
|
||||||
|
{
|
||||||
|
if (addr->domain > 0xFFFF) {
|
||||||
|
if (report)
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("Invalid PCI address domain='0x%x', "
|
||||||
|
"must be <= 0xFFFF"),
|
||||||
|
addr->domain);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (addr->bus > 0xFF) {
|
||||||
|
if (report)
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("Invalid PCI address bus='0x%x', "
|
||||||
|
"must be <= 0xFF"),
|
||||||
|
addr->bus);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (addr->slot > 0x1F) {
|
||||||
|
if (report)
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("Invalid PCI address slot='0x%x', "
|
||||||
|
"must be <= 0x1F"),
|
||||||
|
addr->slot);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (addr->function > 7) {
|
||||||
|
if (report)
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("Invalid PCI address function=0x%x, "
|
||||||
|
"must be <= 7"),
|
||||||
|
addr->function);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (virPCIDeviceAddressIsEmpty(addr)) {
|
||||||
|
if (report)
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("Invalid PCI address 0000:00:00, at least "
|
||||||
|
"one of domain, bus, or slot must be > 0"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr)
|
||||||
|
{
|
||||||
|
return !(addr->domain || addr->bus || addr->slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1,
|
||||||
|
virPCIDeviceAddress *addr2)
|
||||||
|
{
|
||||||
|
if (addr1->domain == addr2->domain &&
|
||||||
|
addr1->bus == addr2->bus &&
|
||||||
|
addr1->slot == addr2->slot &&
|
||||||
|
addr1->function == addr2->function) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr)
|
virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr)
|
||||||
{
|
{
|
||||||
|
@ -218,6 +218,13 @@ int virPCIGetSysfsFile(char *virPCIDeviceName,
|
|||||||
char **pci_sysfs_device_link)
|
char **pci_sysfs_device_link)
|
||||||
ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
|
|
||||||
|
bool virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
|
||||||
|
bool report);
|
||||||
|
bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr);
|
||||||
|
|
||||||
|
bool virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1,
|
||||||
|
virPCIDeviceAddress *addr2);
|
||||||
|
|
||||||
char *virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr)
|
char *virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr)
|
||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user