[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v3 2/3] build command line for pci-bridge device of qemu



On 01/10/13 02:04, liguang wrote:
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 04a9512..48b4f46 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -966,13 +966,6 @@ static char *qemuPCIAddressAsString(virDomainDeviceInfoPtr dev)
>  {
>      char *addr;
>  
> -    if (dev->addr.pci.domain != 0 ||
> -        dev->addr.pci.bus != 0) {
> -        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -                       _("Only PCI domain 0 and bus 0 are available"));
> -        return NULL;
> -    }
> -
>      if (virAsprintf(&addr, "%d:%d:%d.%d",
>                      dev->addr.pci.domain,
>                      dev->addr.pci.bus,
> @@ -984,8 +977,24 @@ static char *qemuPCIAddressAsString(virDomainDeviceInfoPtr dev)
>      return addr;
>  }
>  
> +static int qemuPciBridgeSupport(virDomainDefPtr def)
> +{
> +    int i, c = 0;
> +
> +    for (i = 0; i < def->ncontrollers; i++) {
> +        virDomainControllerDefPtr controller = def->controllers[i];
> +
> +        if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE)
> +            c++;
> +    }
>  
> -static int qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
> +    if (c > 1)
> +        return 0;
> +    else
> +        return -1;
> +}
> +
> +static int qemuCollectPCIAddress(virDomainDefPtr def,
>                                   virDomainDeviceDefPtr device,
>                                   virDomainDeviceInfoPtr info,
>                                   void *opaque)
> @@ -1004,6 +1013,20 @@ static int qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
>          return 0;
>      }
>  
> +    if (info->addr.pci.domain != 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Only PCI device addresses with "
> +                         "domain=0 are supported"));
> +        return -1;
> +    }
> +
> +    if (info->addr.pci.bus != 0 && qemuPciBridgeSupport(def) < 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Only PCI device addresses with bus=0 are"
> +                         " supported without pci-bridge support"));
> +        return -1;
> +    }
> +

This would allow any bus number, even if we don't have enough PCI
bridges. It is also not the only place where qemuPCIAddressAsString is
called from and where this needs to be checked.

We also have other functions assuming bus = 0.
qemuDomainPCIAddressGetNextSlot should also take the bridges into
account, for devices without a specified address.

I'll try to post patches dealing with that sometime later this week.

Jan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]