]> xenbits.xensource.com Git - qemu-xen-3.3-testing.git/commitdiff
ioemu-remote: pt_init must take a const direct_pci.
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 18 Jul 2008 14:34:32 +0000 (15:34 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 18 Jul 2008 14:34:32 +0000 (15:34 +0100)
[ Also copes with direct_pci==0 on entry, which was the
  remaining portion of b7eec990223bb8c4b145597af37592103c412542 -iwj ]

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
hw/pass-through.c
hw/pass-through.h
hw/pci.h

index 21576a47776a19cb514058636f7576296837de5f..bacf7ced60f8197dbf19848da2c3e4f89e7d8396 100644 (file)
@@ -689,13 +689,15 @@ int power_off_php_slot(int php_slot)
     return unregister_real_device(php_slot);
 }
 
-int pt_init(PCIBus *e_bus, char *direct_pci)
+int pt_init(PCIBus *e_bus, const char *direct_pci)
 {
     int seg, b, d, f, php_slot = 0;
     struct pt_dev *pt_dev;
     struct pci_access *pci_access;
     char *vslots;
     char slot_str[8];
+    char *direct_pci_head = NULL;
+    char *direct_pci_p = NULL;
 
     /* Initialize libpci */
     pci_access = pci_alloc();
@@ -711,17 +713,20 @@ int pt_init(PCIBus *e_bus, char *direct_pci)
     dpci_infos.pci_access = pci_access;
     dpci_infos.e_bus      = e_bus;
 
-    if ( strlen(direct_pci) == 0 ) {
+    if ( !direct_pci || strlen(direct_pci) == 0 ) {
         return 0;
     }
 
+    if ( !(direct_pci_head = direct_pci_p = strdup(direct_pci)) )
+        return 0;
+
     /* the virtual pci slots of all pass-through devs
      * with hex format: xx;xx...;
      */
     vslots = qemu_mallocz ( strlen(direct_pci) / 3 );
 
     /* Assign given devices to guest */
-    while ( next_bdf(&direct_pci, &seg, &b, &d, &f) )
+    while ( next_bdf(&direct_pci_p, &seg, &b, &d, &f) )
     {
         /* Register real device with the emulated bus */
         pt_dev = register_real_device(e_bus, "DIRECT PCI", PT_VIRT_DEVFN_AUTO,
@@ -729,6 +734,7 @@ int pt_init(PCIBus *e_bus, char *direct_pci)
         if ( pt_dev == NULL )
         {
             PT_LOG("Error: Registration failed (%02x:%02x.%x)\n", b, d, f);
+            free(direct_pci_head);
             return -1;
         }
 
@@ -749,6 +755,7 @@ int pt_init(PCIBus *e_bus, char *direct_pci)
     xenstore_write_vslots(vslots);
 
     qemu_free(vslots);
+    free(direct_pci_head);
 
     /* Success */
     return 0;
index 183ae09944ce2621bf95e9d321deb1e8f9d20d03..522a295d07da24c31f9a6f7834908ad49fdce23a 100644 (file)
@@ -113,7 +113,5 @@ struct pci_config_cf8 {
     };
 };
 
-int pt_init(PCIBus * e_bus, char * direct_pci);
-
 #endif /* __PASSTHROUGH_H__ */
 
index 250c8ab041bb1dbd1e661d234ff5bbfd564fc557..7ee630da88e0a4d7bfb320df5cd518adc627ce16 100644 (file)
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -164,4 +164,7 @@ PCIBus *pci_prep_init(qemu_irq *pic);
 PCIBus *pci_apb_init(target_phys_addr_t special_base, target_phys_addr_t mem_base,
                      qemu_irq *pic);
 
+/* pass-through.c */
+int pt_init(PCIBus *e_bus, const char *direct_pci_opt);
+
 #endif