mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemuBuildDeviceAddressStr: Split out formatting of PCI address
The PCI address case grew massive over time. Split it out into a new function qemuBuildDeviceAddressPCIStr. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3d4f0aba0d
commit
79f872a8d1
@ -321,7 +321,7 @@ qemuVirCommandGetDevSet(virCommand *cmd, int fd)
|
||||
|
||||
|
||||
static int
|
||||
qemuBuildDeviceAddressStr(virBuffer *buf,
|
||||
qemuBuildDeviceAddressPCIStr(virBuffer *buf,
|
||||
const virDomainDef *domainDef,
|
||||
virDomainDeviceInfo *info)
|
||||
{
|
||||
@ -329,13 +329,11 @@ qemuBuildDeviceAddressStr(virBuffer *buf,
|
||||
const char *contAlias = NULL;
|
||||
bool contIsPHB = false;
|
||||
int contTargetIndex = 0;
|
||||
|
||||
switch ((virDomainDeviceAddressType)info->type) {
|
||||
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: {
|
||||
size_t i;
|
||||
|
||||
if (!(devStr = virPCIDeviceAddressAsString(&info->addr.pci)))
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < domainDef->ncontrollers; i++) {
|
||||
virDomainControllerDef *cont = domainDef->controllers[i];
|
||||
|
||||
@ -371,6 +369,7 @@ qemuBuildDeviceAddressStr(virBuffer *buf,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!contAlias) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not find PCI "
|
||||
@ -396,12 +395,30 @@ qemuBuildDeviceAddressStr(virBuffer *buf,
|
||||
virBufferAddLit(buf, ",multifunction=on");
|
||||
else if (info->addr.pci.multi == VIR_TRISTATE_SWITCH_OFF)
|
||||
virBufferAddLit(buf, ",multifunction=off");
|
||||
|
||||
virBufferAsprintf(buf, ",addr=0x%x", info->addr.pci.slot);
|
||||
|
||||
if (info->addr.pci.function != 0)
|
||||
virBufferAsprintf(buf, ".0x%x", info->addr.pci.function);
|
||||
|
||||
if (info->acpiIndex != 0)
|
||||
virBufferAsprintf(buf, ",acpi-index=%u", info->acpiIndex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBuildDeviceAddressStr(virBuffer *buf,
|
||||
const virDomainDef *domainDef,
|
||||
virDomainDeviceInfo *info)
|
||||
{
|
||||
const char *contAlias = NULL;
|
||||
|
||||
switch ((virDomainDeviceAddressType)info->type) {
|
||||
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
|
||||
if (qemuBuildDeviceAddressPCIStr(buf, domainDef, info) < 0)
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB:
|
||||
|
Loading…
Reference in New Issue
Block a user