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 3 of 6] xl: prevent attempts to remove non-attached p

To: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 3 of 6] xl: prevent attempts to remove non-attached pci pass-through devices
From: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
Date: Mon, 2 Aug 2010 15:58:45 +0100
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Mon, 02 Aug 2010 08:04:32 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1280761122@xxxxxxxxxxxxxxxxxxxxxx>
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>
References: <patchbomb.1280761122@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
 tools/libxl/libxl_pci.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)


# HG changeset patch
# User Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
# Date 1280760101 -3600
# Branch pci-patches-v3
# Node ID a993021324d0c7d23a16290b7a722c2878506c2e
# Parent  d6e7e75ccb48a29eecb895613f017043ae267318
xl: prevent attempts to remove non-attached pci pass-through devices

Signed-off-by: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>

diff -r d6e7e75ccb48 -r a993021324d0 tools/libxl/libxl_pci.c
--- a/tools/libxl/libxl_pci.c   Mon Aug 02 15:40:48 2010 +0100
+++ b/tools/libxl/libxl_pci.c   Mon Aug 02 15:41:41 2010 +0100
@@ -564,12 +564,20 @@ int libxl_device_pci_add(libxl_ctx *ctx,
 
 int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_pci 
*pcidev)
 {
+    libxl_device_pci *assigned;
     char *path;
     char *state;
-    int hvm, rc;
+    int hvm, rc, num;
     int stubdomid = 0;
 
-    /* TODO: check if the device can be detached */
+    if ( !libxl_device_pci_list_assigned(ctx, &assigned, domid, &num) ) {
+        if ( !is_assigned(assigned, num, pcidev->domain,
+                         pcidev->bus, pcidev->dev, pcidev->func) ) {
+            XL_LOG(ctx, XL_LOG_ERROR, "PCI device not attached to this 
domain");
+            return ERROR_INVAL;
+        }
+    }
+
     libxl_device_pci_remove_xenstore(ctx, domid, pcidev);
 
     hvm = is_hvm(ctx, domid);

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