All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Guyader <jean.guyader@eu.citrix.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] ioemu-remote: fix pt_init
Date: Wed, 16 Jul 2008 17:18:54 +0100	[thread overview]
Message-ID: <487E1F6E.2050205@eu.citrix.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 129 bytes --]


ioemu-remote: pt_init must take a const direct_pci.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>

-- 
Jean Guyader

[-- Attachment #2: ioemu-remote_direct_pci_const.patch --]
[-- Type: text/plain, Size: 2503 bytes --]

diff --git a/hw/pass-through.c b/hw/pass-through.c
index bddc203..abe0376 100644
--- a/hw/pass-through.c
+++ b/hw/pass-through.c
@@ -691,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();
@@ -713,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,
@@ -731,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;
         }
 
@@ -751,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;
diff --git a/hw/pass-through.h b/hw/pass-through.h
index ffd87ef..4f5d88a 100644
--- a/hw/pass-through.h
+++ b/hw/pass-through.h
@@ -112,7 +112,5 @@ struct pci_config_cf8 {
     };
 };
 
-int pt_init(PCIBus * e_bus, char * direct_pci);
-
 #endif /* __PASSTHROUGH_H__ */
 
diff --git a/hw/pci.h b/hw/pci.h
index 250c8ab..a855de8 100644
--- 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

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2008-07-16 16:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=487E1F6E.2050205@eu.citrix.com \
    --to=jean.guyader@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.