WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [patch] qemu-xen: hot-plug PCI devices at boot-time

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [patch] qemu-xen: hot-plug PCI devices at boot-time
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Fri, 29 May 2009 16:56:40 +1000
Cc: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>, Edwin Zhai <edwin.zhai@xxxxxxxxx>
Delivery-date: Thu, 28 May 2009 23:58:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.18 (2008-05-17)
Currently there are two interfaces to pass-through PCI devices:
1. A method driven through per-device xenstore entries that is used at boot-time
2. An event-based method used for hot-plug.

This seems somewhat redundant and makes extending the code cumbersome
and prone to error - often the change needs to be made twice, in
two different ways.

This patch removes support for the boot-time protocol from qemu-xen.

There is a companion patch for xend which uses the hot-plug protocol
at boot time.

Cc: Edwin Zhai <edwin.zhai@xxxxxxxxx>
Cc: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

--- 

 hw/pass-through.c |   61 +----------------------------------------------------
 hw/pc.c           |   11 +++------
 hw/pci.h          |    2 -
 vl.c              |    3 --
 xenstore.c        |   58 --------------------------------------------------
 5 files changed, 7 insertions(+), 128 deletions(-)

Index: ioemu-remote/hw/pass-through.c
===================================================================
--- ioemu-remote.orig/hw/pass-through.c 2009-05-29 16:39:06.000000000 +1000
+++ ioemu-remote/hw/pass-through.c      2009-05-29 16:44:24.000000000 +1000
@@ -4035,16 +4035,9 @@ int power_off_php_slot(int php_slot)
     return unregister_real_device(php_slot);
 }
 
-int pt_init(PCIBus *e_bus, const char *direct_pci)
+int pt_init(PCIBus *e_bus)
 {
-    int seg, b, d, f, s, status = -1;
-    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;
-    char *opt;
 
     /* Initialize libpci */
     pci_access = pci_alloc();
@@ -4060,56 +4053,6 @@ int pt_init(PCIBus *e_bus, const char *d
     dpci_infos.pci_access = pci_access;
     dpci_infos.e_bus      = e_bus;
 
-    if ( !direct_pci || strlen(direct_pci) == 0 ) {
-        return 0;
-    }
-
-    if ( !(direct_pci_head = direct_pci_p = strdup(direct_pci)) )
-        return 0;
-
-    /* The minimal format of direct_pci: xxxx:xx:xx.x-xxxx:xx:xx.x-... It may
-     * be even longer considering the per-device opts(see the parsing for
-     * '/local/domain/0/backend/pci/XX/YY/opts-ZZ' in
-     * xenstore_parse_domain_config().
-     *
-     * The format of vslots(virtual pci slots of all pass-through devs):
-     * 0xXX;0xXX;... (see the code below).
-     *
-     * We're sure the length of direct_pci is bigger than that of vslots.
-     */
-    vslots = qemu_mallocz(strlen(direct_pci) + 1);
-    if ( vslots == NULL )
-    {
-        status = -1;
-        goto err;
-    }
-
-    /* Assign given devices to guest */
-    while ( next_bdf(&direct_pci_p, &seg, &b, &d, &f, &opt, &s) )
-    {
-        /* Register real device with the emulated bus */
-        pt_dev = register_real_device(e_bus, "DIRECT PCI", s,
-            b, d, f, PT_MACHINE_IRQ_AUTO, pci_access, opt);
-        if ( pt_dev == NULL )
-        {
-            PT_LOG("Error: Registration failed (%02x:%02x.%x)\n", b, d, f);
-            goto err;
-        }
-
-        /* Record the virtual slot info */
-        sprintf(slot_str, "0x%02x;", PCI_SLOT(pt_dev->dev.devfn));
-
-        strcat(vslots, slot_str);
-    }
-
-    /* Write virtual slots info to xenstore for Control panel use */
-    xenstore_write_vslots(vslots);
-
-    status = 0;
-err:
-    qemu_free(vslots);
-    free(direct_pci_head);
-
-    return status;
+    return 0;
 }
 
Index: ioemu-remote/hw/pc.c
===================================================================
--- ioemu-remote.orig/hw/pc.c   2009-05-29 16:39:06.000000000 +1000
+++ ioemu-remote/hw/pc.c        2009-05-29 16:44:24.000000000 +1000
@@ -787,8 +787,7 @@ static void pc_init1(ram_addr_t ram_size
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename,
-                     int pci_enabled, const char *cpu_model,
-                    const char *direct_pci)
+                     int pci_enabled, const char *cpu_model)
 {
     char buf[1024];
     int ret, linux_boot, i;
@@ -1017,7 +1016,7 @@ vga_bios_error:
      */
     if ( pci_enabled )
     {
-        rc = pt_init(pci_bus, direct_pci); 
+        rc = pt_init(pci_bus);
         if ( rc < 0 )
         {
             fprintf(logfile, "Error: Initialization failed for pass-through 
devices\n");
@@ -1205,8 +1204,7 @@ static void pc_init_pci(ram_addr_t ram_s
 {
     pc_init1(ram_size, vga_ram_size, boot_device,
              kernel_filename, kernel_cmdline,
-             initrd_filename, 1, cpu_model,
-             direct_pci);
+             initrd_filename, 1, cpu_model);
 }
 
 static void pc_init_isa(ram_addr_t ram_size, int vga_ram_size,
@@ -1219,8 +1217,7 @@ static void pc_init_isa(ram_addr_t ram_s
 {
     pc_init1(ram_size, vga_ram_size, boot_device,
              kernel_filename, kernel_cmdline,
-             initrd_filename, 0, cpu_model,
-             direct_pci);
+             initrd_filename, 0, cpu_model);
 }
 
 /* set CMOS shutdown status register (index 0xF) as S3_resume(0xFE)
Index: ioemu-remote/hw/pci.h
===================================================================
--- ioemu-remote.orig/hw/pci.h  2009-05-29 16:39:06.000000000 +1000
+++ ioemu-remote/hw/pci.h       2009-05-29 16:44:24.000000000 +1000
@@ -337,6 +337,6 @@ PCIBus *sh_pci_register_bus(pci_set_irq_
                             qemu_irq *pic, int devfn_min, int nirq);
 
 /* pass-through.c */
-int pt_init(PCIBus *e_bus, const char *direct_pci_opt);
+int pt_init(PCIBus *e_bus);
 
 #endif
Index: ioemu-remote/vl.c
===================================================================
--- ioemu-remote.orig/vl.c      2009-05-29 16:39:06.000000000 +1000
+++ ioemu-remote/vl.c   2009-05-29 16:44:24.000000000 +1000
@@ -5829,9 +5829,6 @@ int main(int argc, char **argv, char **e
         }
     }
 
-    if (strlen(direct_pci_str) > 0)
-        direct_pci = direct_pci_str;
-
     machine->init(ram_size, vga_ram_size, boot_devices,
                   kernel_filename, kernel_cmdline, initrd_filename, cpu_model,
                  direct_pci);
Index: ioemu-remote/xenstore.c
===================================================================
--- ioemu-remote.orig/xenstore.c        2009-05-29 16:39:06.000000000 +1000
+++ ioemu-remote/xenstore.c     2009-05-29 16:44:24.000000000 +1000
@@ -301,10 +301,8 @@ static const char *xenstore_get_guest_uu
     return already_computed;
 }
 
-#define DIRECT_PCI_STR_LEN 512
 #define PT_PCI_MSITRANSLATE_DEFAULT 1
 #define PT_PCI_POWER_MANAGEMENT_DEFAULT 0
-char direct_pci_str[DIRECT_PCI_STR_LEN];
 int direct_pci_msitranslate;
 int direct_pci_power_mgmt;
 void xenstore_parse_domain_config(int hvm_domid)
@@ -566,62 +564,6 @@ void xenstore_parse_domain_config(int hv
         goto out;
     num = atoi(params);
 
-    for ( i = 0; i < num; i++ ) {
-        if (pasprintf(&buf, "/local/domain/0/backend/pci/%u/%u/dev-%d",
-                    hvm_domid, pci_devid, i) != -1) {
-            free(dev);
-            dev = xs_read(xsh, XBT_NULL, buf, &len);
-
-            if ( strlen(dev) + strlen(direct_pci_str) > DIRECT_PCI_STR_LEN - 
1) {
-                fprintf(stderr, "qemu: too many pci pass-through devices\n");
-                memset(direct_pci_str, 0, DIRECT_PCI_STR_LEN);
-                goto out;
-            }
-
-
-            /* append to direct_pci_str */
-            if ( !dev )
-                continue;
-
-            strcat(direct_pci_str, dev);
-
-            if (pasprintf(&buf, "/local/domain/0/backend/pci/%u/%u/vslot-%d",
-                          hvm_domid, pci_devid, i) != -1) {
-                free(dev);
-                dev = xs_read(xsh, XBT_NULL, buf, &len);
-            }
-            if ( dev ) {
-                if (strlen(dev) + strlen(direct_pci_str) >
-                    DIRECT_PCI_STR_LEN - 2) {
-                    fprintf(stderr, "qemu: too many pci pass-through "
-                            "devices\n");
-                    memset(direct_pci_str, 0, DIRECT_PCI_STR_LEN);
-                    goto out;
-                }
-                strcat(direct_pci_str, "@");
-                strcat(direct_pci_str, dev);
-            }
-
-
-            if (pasprintf(&buf, "/local/domain/0/backend/pci/%u/%u/opts-%d",
-                          hvm_domid, pci_devid, i) != -1) {
-                free(dev);
-                dev = xs_read(xsh, XBT_NULL, buf, &len);
-            }
-            if ( dev ) {
-                if ( strlen(dev) + strlen(direct_pci_str) > DIRECT_PCI_STR_LEN 
- 2) {
-                    fprintf(stderr, "qemu: too many pci pass-through 
devices\n");
-                    memset(direct_pci_str, 0, DIRECT_PCI_STR_LEN);
-                    goto out;
-                }
-                strcat(direct_pci_str, ",");
-                strcat(direct_pci_str, dev);
-            }
-
-            strcat(direct_pci_str, "-");
-        }
-    }
-
     /* get the pci pass-through parameter */
     if (pasprintf(&buf, "/local/domain/0/backend/pci/%u/%u/msitranslate",
                   hvm_domid, pci_devid) != -1)

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