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-changelog

[Xen-changelog] [xen-unstable] libxl: refactor code which adds per-PCI d

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxl: refactor code which adds per-PCI device backend nodes in xenstore
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Jan 2011 07:59:49 -0800
Delivery-date: Mon, 17 Jan 2011 08:14:35 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1294769805 0
# Node ID 5b8034ce8b8c6d4f5e49d197dc003b4d686a623c
# Parent  fd6239cbac00eeaebca8459244c995fd4710134a
libxl: refactor code which adds per-PCI device backend nodes in xenstore

libxl_create_pci_backend and libxl_device_pci_add_xenstore contains
identical code to setup the per device xenstore nodes in the backend.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/libxl_pci.c |   45 ++++++++++++++++++++-------------------------
 1 files changed, 20 insertions(+), 25 deletions(-)

diff -r fd6239cbac00 -r 5b8034ce8b8c tools/libxl/libxl_pci.c
--- a/tools/libxl/libxl_pci.c   Tue Jan 11 18:16:26 2011 +0000
+++ b/tools/libxl/libxl_pci.c   Tue Jan 11 18:16:45 2011 +0000
@@ -221,6 +221,19 @@ parse_error:
     return ERROR_INVAL;
 }
 
+static void libxl_create_pci_backend_device(libxl__gc *gc, flexarray_t *back, 
int num, libxl_device_pci *pcidev)
+{
+    flexarray_append(back, libxl__sprintf(gc, "key-%d", num));
+    flexarray_append(back, libxl__sprintf(gc, PCI_BDF, pcidev->domain, 
pcidev->bus, pcidev->dev, pcidev->func));
+    flexarray_append(back, libxl__sprintf(gc, "dev-%d", num));
+    flexarray_append(back, libxl__sprintf(gc, PCI_BDF, pcidev->domain, 
pcidev->bus, pcidev->dev, pcidev->func));
+    if (pcidev->vdevfn)
+        flexarray_vappend(back, libxl__sprintf(gc, "vdevfn-%d", num), 
libxl__sprintf(gc, "%x", pcidev->vdevfn), NULL);
+    flexarray_append(back, libxl__sprintf(gc, "opts-%d", num));
+    flexarray_append(back, libxl__sprintf(gc, "msitranslate=%d,power_mgmt=%d", 
pcidev->msitranslate, pcidev->power_mgmt));
+    flexarray_vappend(back, libxl__sprintf(gc, "state-%d", num), 
libxl__sprintf(gc, "%d", 1), NULL);
+}
+
 static int libxl_create_pci_backend(libxl__gc *gc, uint32_t domid, 
libxl_device_pci *pcidev, int num)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -249,20 +262,12 @@ static int libxl_create_pci_backend(libx
     device.kind = DEVICE_PCI;
 
     flexarray_vappend(back, "frontend-id", libxl__sprintf(gc, "%d", domid),
-                     "online", "1", "state", libxl__sprintf(gc, "%d", 1),
-                    "domain", libxl__domid_to_name(gc, domid), NULL);
-    for (i = 0; i < num; i++) {
-        flexarray_append(back, libxl__sprintf(gc, "key-%d", i));
-        flexarray_append(back, libxl__sprintf(gc, PCI_BDF, pcidev->domain, 
pcidev->bus, pcidev->dev, pcidev->func));
-        flexarray_append(back, libxl__sprintf(gc, "dev-%d", i));
-        flexarray_append(back, libxl__sprintf(gc, PCI_BDF, pcidev->domain, 
pcidev->bus, pcidev->dev, pcidev->func));
-        if (pcidev->vdevfn) {
-            flexarray_vappend(back, libxl__sprintf(gc, "vdevfn-%d", i), 
libxl__sprintf(gc, "%x", pcidev->vdevfn), NULL);
-        }
-        flexarray_append(back, libxl__sprintf(gc, "opts-%d", i));
-        flexarray_append(back, libxl__sprintf(gc, 
"msitranslate=%d,power_mgmt=%d", pcidev->msitranslate, pcidev->power_mgmt));
-        flexarray_vappend(back, libxl__sprintf(gc, "state-%d", i), 
libxl__sprintf(gc, "%d", 1), NULL);
-    }
+                      "online", "1", "state", libxl__sprintf(gc, "%d", 1),
+                      "domain", libxl__domid_to_name(gc, domid), NULL);
+
+    for (i = 0; i < num; i++, pcidev++)
+        libxl_create_pci_backend_device(gc, back, i, pcidev);
+
     flexarray_vappend(back, "num_devs", libxl__sprintf(gc, "%d", num));
 
     flexarray_vappend(front,
@@ -305,17 +310,7 @@ static int libxl_device_pci_add_xenstore
 
     LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Adding new pci device to xenstore");
     num = atoi(num_devs);
-    flexarray_append(back, libxl__sprintf(gc, "key-%d", num));
-    flexarray_append(back, libxl__sprintf(gc, PCI_BDF, pcidev->domain, 
pcidev->bus, pcidev->dev, pcidev->func));
-    flexarray_append(back, libxl__sprintf(gc, "dev-%d", num));
-    flexarray_append(back, libxl__sprintf(gc, PCI_BDF, pcidev->domain, 
pcidev->bus, pcidev->dev, pcidev->func));
-    if (pcidev->vdevfn) {
-        flexarray_append(back, libxl__sprintf(gc, "vdevfn-%d", num));
-        flexarray_append(back, libxl__sprintf(gc, "%x", pcidev->vdevfn));
-    }
-    flexarray_append(back, libxl__sprintf(gc, "opts-%d", num));
-    flexarray_append(back, libxl__sprintf(gc, "msitranslate=%d,power_mgmt=%d", 
pcidev->msitranslate, pcidev->power_mgmt));
-    flexarray_vappend(back, libxl__sprintf(gc, "state-%d", num), 
libxl__sprintf(gc, "%d", 1), NULL);
+    libxl_create_pci_backend_device(gc, back, num, pcidev);
     flexarray_vappend(back, "num_devs", libxl__sprintf(gc, "%d", num + 1), 
NULL);
     flexarray_vappend(back, "state", libxl__sprintf(gc, "%d", 7), NULL);
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxl: refactor code which adds per-PCI device backend nodes in xenstore, Xen patchbot-unstable <=