|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] xen: restore GNTTABOP_dump_table
This operation was dropped long time ago, but I found it quite helpful
for debugging purposes. This re-implementation uses the code already
present in gnttab_usage_print and adds the maptrack-table dump.
Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxx>
---
xen/common/grant_table.c | 83 ++++++++++++++++++++++++++++++++++++++---
xen/include/xen/grant_table.h | 3 +
2 files changed, 80 insertions(+), 6 deletions(-)
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index c8e342b..a5de9c6 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -1393,6 +1393,40 @@ gnttab_setup_table(
return 0;
}
+static long
+gnttab_dump_table(
+ XEN_GUEST_HANDLE(gnttab_dump_table_t) uop, unsigned int count)
+{
+ struct gnttab_dump_table op;
+ struct domain *d;
+
+ if ( !IS_PRIV(current->domain) )
+ return -EPERM;
+
+ if ( unlikely(copy_from_guest(&op, uop, sizeof(op)) != 0) )
+ {
+ gdprintk(XENLOG_INFO, "Fault while reading gnttab_dump_table_t.\n");
+ return -EFAULT;
+ }
+
+ d = gt_lock_target_domain_by_id(op.dom);
+ if ( IS_ERR(d) )
+ {
+ op.status = PTR_ERR(d);
+ goto out;
+ }
+
+ gnttab_usage_print(d, 1);
+
+ rcu_unlock_domain(d);
+
+out:
+ if ( unlikely(copy_to_guest(uop, &op, 1)) )
+ return -EFAULT;
+
+ return 0;
+}
+
static long
gnttab_query_size(
XEN_GUEST_HANDLE(gnttab_query_size_t) uop, unsigned int count)
@@ -2495,6 +2529,12 @@ do_grant_table_op(
ASSERT(rc <= 0);
break;
}
+ case GNTTABOP_dump_table:
+ {
+ rc = gnttab_dump_table(guest_handle_cast(uop, gnttab_dump_table_t),
+ count);
+ break;
+ }
case GNTTABOP_transfer:
{
XEN_GUEST_HANDLE(gnttab_transfer_t) transfer =
@@ -2796,7 +2836,7 @@ grant_table_destroy(
d->grant_table = NULL;
}
-void gnttab_usage_print(struct domain *rd)
+void gnttab_usage_print(struct domain *rd, int print_maptrack)
{
int first = 1;
grant_ref_t ref;
@@ -2808,7 +2848,7 @@ void gnttab_usage_print(struct domain *rd)
spin_lock(>->lock);
if ( gt->gt_version == 0 )
- goto out;
+ goto out_grant;
for ( ref = 0; ref != nr_grant_entries(gt); ref++ )
{
@@ -2853,12 +2893,43 @@ void gnttab_usage_print(struct domain *rd)
sha->domid, frame, status);
}
- out:
- spin_unlock(>->lock);
-
+out_grant:
if ( first )
printk("grant-table for remote domain:%5d ... "
"no active grant table entries\n", rd->domain_id);
+
+ if ( !print_maptrack )
+ goto out;
+
+ first = 1;
+
+ printk(" -------- maptrack --------\n");
+ printk("[ref] domid gnt flags\n");
+
+ for ( ref = 0; ref != gt->maptrack_limit; ref++ )
+ {
+ struct grant_mapping *maptrack = &maptrack_entry(gt, ref);
+
+ if ( maptrack->flags ) {
+
+ if ( first )
+ {
+ printk("maptrack-table for remote domain:%5d\n",
+ rd->domain_id);
+ first = 0;
+ }
+ /* [ddd] ddddd 0xXXXXXXXX 0xXX */
+ printk("[%3d] %5d 0x%08x 0x%02x\n",
+ ref, maptrack->domid, maptrack->ref, maptrack->flags);
+ }
+ }
+
+ if ( first )
+ printk("maptrack-table for remote domain:%5d ... "
+ "no active maptrack table entries\n", rd->domain_id);
+
+ out:
+ spin_unlock(>->lock);
}
static void gnttab_usage_print_all(unsigned char key)
@@ -2866,7 +2937,7 @@ static void gnttab_usage_print_all(unsigned char key)
struct domain *d;
printk("%s [ key '%c' pressed\n", __FUNCTION__, key);
for_each_domain ( d )
- gnttab_usage_print(d);
+ gnttab_usage_print(d, 0);
printk("%s ] done\n", __FUNCTION__);
}
diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h
index 0820da1..34a8304 100644
--- a/xen/include/xen/grant_table.h
+++ b/xen/include/xen/grant_table.h
@@ -111,6 +111,9 @@ gnttab_release_mappings(
int
gnttab_grow_table(struct domain *d, unsigned int req_nr_frames);
+/* Print grant table for given domain. */
+void gnttab_usage_print(struct domain *rd, int print_maptrack);
+
/* Number of grant table frames. Caller must hold d's grant table lock. */
static inline unsigned int nr_grant_frames(struct grant_table *gt)
{
--
1.7.7.5 (Apple Git-26)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |