Re: [PATCH RFC] auto-create pci-bridge controller info

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

 



在 2013-01-21一的 12:11 +0000,Daniel P. Berrange写道:
> On Mon, Jan 21, 2013 at 02:04:00PM +0800, liguang wrote:
> > if some devices specify a pci bus number that
> > haven't been defined by a pci-bridge controller
> > then fill the required correct controller info
> > silently.
> > it based on previous add pci-bridge support patches,
> > https://www.redhat.com/archives/libvir-list/2013-January/msg00577.html
> > 
> > Signed-off-by: liguang <lig.fnst@xxxxxxxxxxxxxx>
> > ---
> >  src/conf/domain_conf.c |   57 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 files changed, 57 insertions(+), 0 deletions(-)
> > 
> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > index 8ebe77d..988e4f2 100644
> > --- a/src/conf/domain_conf.c
> > +++ b/src/conf/domain_conf.c
> > @@ -11756,6 +11756,60 @@ virDomainDefMaybeAddSmartcardController(virDomainDefPtr def)
> >  }
> >  
> >  
> > +static int
> > +virDomainDefMaybeAddPcibridgeController(virDomainDefPtr def)
> > +{
> > +    int i, idx = 0;
> > +
> > +    for (i = 0; i < def->nnets; i++) {
> > +        if (def->nets[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
> > +            continue;
> > +        idx = def->nets[i]->info.addr.pci.bus;
> > +        if (virDomainDefMaybeAddController(def,
> > +                                           VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE,
> > +                                           idx) < 0)
> > +            return -1;
> > +    }
> > +
> > +    for (i = 0; i < def->nsounds; i++) {
> > +        if (def->sounds[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
> > +            continue;
> > +        idx = def->sounds[i]->info.addr.pci.bus;
> > +        if (virDomainDefMaybeAddController(def,
> > +                                           VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE,
> > +                                           idx) < 0)
> > +            return -1;
> > +    }
> > +
> > +    for (i = 0; i < def->nvideos; i++) {
> > +        if (def->videos[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
> > +            continue;
> > +        idx = def->videos[i]->info.addr.pci.bus;
> > +        if (virDomainDefMaybeAddController(def,
> > +                                           VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE,
> > +                                           idx) < 0)
> > +            return -1;
> > +    }
> > +
> > +    if (def->watchdog->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
> > +        idx = def->watchdog->info.addr.pci.bus;
> > +
> > +    if (virDomainDefMaybeAddController(def,
> > +                                       VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE,
> > +                                       idx) < 0)
> > +        return -1;
> > +
> > +    if (def->memballoon->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
> > +        idx = def->memballoon->info.addr.pci.bus;
> > +
> > +    if (virDomainDefMaybeAddController(def,
> > +                                       VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE,
> > +                                       idx) < 0)
> > +        return -1;
> > +
> > +    return 0;
> > +}
> > +
> 
> You're missing quite a few device types here - 'disks' (eg virtio-blk uses
> PCI addresses), 'controllers' (eg USB controllers use PCI addresses),
> hostdevs (eg PCI host device passthrough), fss (virtio-9p filesystem uses
> PCI addresses).

Thanks! will fix like following

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 988e4f2..b0da5b4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11791,6 +11791,46 @@
virDomainDefMaybeAddPcibridgeController(virDomainDefPtr def)
             return -1;
     }
 
+    for (i = 0; i < def->ncontrollers; i++) {
+        if (def->controllers[i]->info.type !=
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+            continue;
+        idx = def->controllers[i]->info.addr.pci.bus;
+        if (virDomainDefMaybeAddController(def,
+
VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE,
+                                           idx) < 0)
+            return -1;
+    }
+
+    for (i = 0; i < def->nfss; i++) {
+        if (def->fss[i]->info.type !=
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+            continue;
+        idx = def->fss[i]->info.addr.pci.bus;
+        if (virDomainDefMaybeAddController(def,
+
VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE,
+                                           idx) < 0)
+            return -1;
+    }
+
+    for (i = 0; i < def->nhostdevs; i++) {
+        if (def->hostdevs[i]->info->type !=
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+            continue;
+        idx = def->hostdevs[i]->info->addr.pci.bus;
+        if (virDomainDefMaybeAddController(def,
+
VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE,
+                                           idx) < 0)
+            return -1;
+    }
+
+    for (i = 0; i < def->ndisks; i++) {
+        if (def->disks[i]->info.type !=
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+            continue;
+        idx = def->disks[i]->info.addr.pci.bus;
+        if (virDomainDefMaybeAddController(def,
+
VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE,
+                                           idx) < 0)
+            return -1;
+    }
+
     if (def->watchdog->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
         idx = def->watchdog->info.addr.pci.bus;


> 
> Regards,
> Daniel

-- 
regards!
li guang


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]