case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS:
switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
- if (virAsprintfQuiet(&address, "%.4x:%.2x:%.2x.%.1x",
+ if (virAsprintfQuiet(&address,
+ VIR_PCI_DEVICE_ADDRESS_FMT,
pcisrc->addr.domain,
pcisrc->addr.bus,
pcisrc->addr.slot,
if (MACAddrSpecified && PCIAddrSpecified) {
virReportError(VIR_ERR_DEVICE_MISSING,
_("no device matching MAC address %s found on "
- "%.4x:%.2x:%.2x.%.1x"),
+ VIR_PCI_DEVICE_ADDRESS_FMT),
virMacAddrFormat(&net->mac, mac),
net->info.addr.pci.domain,
net->info.addr.pci.bus,
net->info.addr.pci.function);
} else if (PCIAddrSpecified) {
virReportError(VIR_ERR_DEVICE_MISSING,
- _("no device found on %.4x:%.2x:%.2x.%.1x"),
+ _("no device found on " VIR_PCI_DEVICE_ADDRESS_FMT),
net->info.addr.pci.domain,
net->info.addr.pci.bus,
net->info.addr.pci.slot,
src->addr.pci.slot != dst->addr.pci.slot ||
src->addr.pci.function != dst->addr.pci.function) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target device PCI address %04x:%02x:%02x.%02x "
- "does not match source %04x:%02x:%02x.%02x"),
+ _("Target device PCI address " VIR_PCI_DEVICE_ADDRESS_FMT
+ "does not match source " VIR_PCI_DEVICE_ADDRESS_FMT),
dst->addr.pci.domain, dst->addr.pci.bus,
dst->addr.pci.slot, dst->addr.pci.function,
src->addr.pci.domain, src->addr.pci.bus,
if (virDomainHostdevFind(vm->def, hostdev, &found) >= 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
- _("target pci device %.4x:%.2x:%.2x.%.1x already exists"),
+ _("target pci device " VIR_PCI_DEVICE_ADDRESS_FMT
+ " already exists"),
pcisrc->addr.domain, pcisrc->addr.bus,
pcisrc->addr.slot, pcisrc->addr.function);
goto cleanup;
if (libxl_device_pci_add(cfg->ctx, vm->def->id, &pcidev, 0) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("libxenlight failed to attach pci device %.4x:%.2x:%.2x.%.1x"),
+ _("libxenlight failed to attach pci device "
+ VIR_PCI_DEVICE_ADDRESS_FMT),
pcisrc->addr.domain, pcisrc->addr.bus,
pcisrc->addr.slot, pcisrc->addr.function);
goto error;
idx = virDomainHostdevFind(vm->def, hostdev, &detach);
if (idx < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
- _("host pci device %.4x:%.2x:%.2x.%.1x not found"),
+ _("host pci device " VIR_PCI_DEVICE_ADDRESS_FMT
+ " not found"),
pcisrc->addr.domain, pcisrc->addr.bus,
pcisrc->addr.slot, pcisrc->addr.function);
goto cleanup;
if (libxlIsMultiFunctionDevice(vm->def, detach->info)) {
virReportError(VIR_ERR_OPERATION_FAILED,
- _("cannot hot unplug multifunction PCI device: %.4x:%.2x:%.2x.%.1x"),
+ _("cannot hot unplug multifunction PCI device: "
+ VIR_PCI_DEVICE_ADDRESS_FMT),
pcisrc->addr.domain, pcisrc->addr.bus,
pcisrc->addr.slot, pcisrc->addr.function);
goto error;
if (libxl_device_pci_remove(cfg->ctx, vm->def->id, &pcidev, 0) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("libxenlight failed to detach pci device "
- "%.4x:%.2x:%.2x.%.1x"),
+ VIR_PCI_DEVICE_ADDRESS_FMT),
pcisrc->addr.domain, pcisrc->addr.bus,
pcisrc->addr.slot, pcisrc->addr.function);
goto error;
}
virBufferAddLit(&buf, ",host=");
- virBufferAsprintf(&buf, "%.4x:%.2x:%.2x.%.1x",
+ virBufferAsprintf(&buf,
+ VIR_PCI_DEVICE_ADDRESS_FMT,
pcisrc->addr.domain,
pcisrc->addr.bus,
pcisrc->addr.slot,
switch (subsys->type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
virReportError(VIR_ERR_DEVICE_MISSING,
- _("host pci device %.4x:%.2x:%.2x.%.1x not found"),
+ _("host pci device " VIR_PCI_DEVICE_ADDRESS_FMT
+ " not found"),
pcisrc->addr.domain, pcisrc->addr.bus,
pcisrc->addr.slot, pcisrc->addr.function);
break;
if (qemuIsMultiFunctionDevice(vm->def, info)) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("cannot hot unplug %s device with multifunction PCI guest address: "
- "%.4x:%.2x:%.2x.%.1x"),
+ VIR_PCI_DEVICE_ADDRESS_FMT),
virDomainDeviceTypeToString(detach.type),
info->addr.pci.domain, info->addr.pci.bus,
info->addr.pci.slot, info->addr.pci.function);
{
char *str;
- ignore_value(virAsprintf(&str, "%.4x:%.2x:%.2x.%.1x",
+ ignore_value(virAsprintf(&str,
+ VIR_PCI_DEVICE_ADDRESS_FMT,
addr->domain,
addr->bus,
addr->slot,
dev->address.function = function;
if (virAsprintf(&dev->name,
- "%.4x:%.2x:%.2x.%.1x",
+ VIR_PCI_DEVICE_ADDRESS_FMT,
domain, bus, slot, function) < 0)
return NULL;
struct dirent *ent;
int direrr;
- if (virAsprintf(&pcidir, "/sys/bus/pci/devices/%04x:%02x:%02x.%x",
+ if (virAsprintf(&pcidir, "/sys/bus/pci/devices/" VIR_PCI_DEVICE_ADDRESS_FMT,
dev->address.domain, dev->address.bus,
dev->address.slot, dev->address.function) < 0)
goto cleanup;
int direrr;
if (virAsprintf(&groupPath,
- PCI_SYSFS "devices/%04x:%02x:%02x.%x/iommu_group/devices",
+ PCI_SYSFS "devices/" VIR_PCI_DEVICE_ADDRESS_FMT "/iommu_group/devices",
orig->domain, orig->bus, orig->slot, orig->function) < 0)
goto cleanup;
const char *groupNumStr;
unsigned int groupNum;
- if (virAsprintf(&devName, "%.4x:%.2x:%.2x.%.1x", addr->domain,
- addr->bus, addr->slot, addr->function) < 0)
+ if (virAsprintf(&devName,
+ VIR_PCI_DEVICE_ADDRESS_FMT,
+ addr->domain, addr->bus, addr->slot, addr->function) < 0)
return -1;
if (!(devPath = virPCIFile(devName, "iommu_group")))
}
if ((*pf = virPCIGetDeviceAddressFromSysfsLink(device_link))) {
- VIR_DEBUG("PF for VF device '%s': %.4x:%.2x:%.2x.%.1x", vf_sysfs_path,
+ VIR_DEBUG("PF for VF device '%s': " VIR_PCI_DEVICE_ADDRESS_FMT,
+ vf_sysfs_path,
(*pf)->domain, (*pf)->bus, (*pf)->slot, (*pf)->function);
}
char **pci_sysfs_device_link)
{
if (virAsprintf(pci_sysfs_device_link,
- PCI_SYSFS "devices/%04x:%02x:%02x.%x",
+ PCI_SYSFS "devices/" VIR_PCI_DEVICE_ADDRESS_FMT,
addr->domain, addr->bus,
addr->slot, addr->function) < 0)
return -1;
unsigned int fid;
};
+#define VIR_PCI_DEVICE_ADDRESS_FMT "%.4x:%.2x:%.2x.%.1x"
+
struct _virPCIDeviceAddress {
unsigned int domain;
unsigned int bus;