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

li guang lig.fnst at cn.fujitsu.com
Wed Jan 16 08:24:55 UTC 2013


在 2013-01-15二的 09:27 +0000,Daniel P. Berrange写道:
> On Mon, Jan 14, 2013 at 05:23:54PM +0100, Ján Tomko wrote:
> > 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.
> 
> With other types of addresses, we will auto-create the <controller>
> elements if we find the controller does not exist. We should probably
> do the same for PCI. ie if you have bus == 2 and no PCI bridge for
> that bus exists, then add one.

Oh, this amazing feature will remove all the need of 
controller pre-definition in domain's XML file, will it?
could you please give me an already exist example?
just can't find them by a quick search.
Thanks!

> 
> Daniel

-- 
regards!
li guang





More information about the libvir-list mailing list