virpci, domain_audit: use virPCIDeviceAddressAsString()

There is no need to open code the PCI address string format
when we have a function that does exactly that.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Daniel Henrique Barboza 2021-01-04 09:54:25 -03:00
parent 32c5e43204
commit 03f9c17805
2 changed files with 3 additions and 9 deletions

View File

@ -361,11 +361,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev,
case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS:
switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
address = g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT,
pcisrc->addr.domain,
pcisrc->addr.bus,
pcisrc->addr.slot,
pcisrc->addr.function);
address = virPCIDeviceAddressAsString(&pcisrc->addr);
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
address = g_strdup_printf("%.3d.%.3d", usbsrc->bus, usbsrc->device);

View File

@ -1471,8 +1471,7 @@ virPCIDeviceNew(unsigned int domain,
dev->address.slot = slot;
dev->address.function = function;
dev->name = g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT, domain, bus, slot,
function);
dev->name = virPCIDeviceAddressAsString(&dev->address);
dev->path = g_strdup_printf(PCI_SYSFS "devices/%s/config", dev->name);
@ -1998,8 +1997,7 @@ virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddressPtr addr)
g_autofree char *groupNumStr = NULL;
unsigned int groupNum;
devName = g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT, addr->domain, addr->bus,
addr->slot, addr->function);
devName = virPCIDeviceAddressAsString(addr);
devPath = virPCIFile(devName, "iommu_group");