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

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

 



在 2013-01-16三的 09:26 +0000,Daniel P. Berrange写道:
> On Wed, Jan 16, 2013 at 04:24:55PM +0800, li guang wrote:
> > 在 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:
> > > > 
> > > > 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.
> 
> Take a look at the  virDomainDefAddImplicitControllers method in
> domain_conf.c
> 
> Regards,
> Daniel

Hi, Daniel
do you like following changes:

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;
+}
+
 /*
  * Based on the declared <address/> info for any devices,
  * add necessary drive controllers which are not already present
@@ -11790,6 +11844,9 @@ int
virDomainDefAddImplicitControllers(virDomainDefPtr def)
     if (virDomainDefMaybeAddSmartcardController(def) < 0)
         return -1;
 
+    if (virDomainDefMaybeAddPcibridgeController(def) < 0)
+        return -1;
+
     return 0;
 }
 
-- 
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]