# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1259848322 0
# Node ID 0f35fb4f73d6a2b58786868c9816f68399470e4c
# Parent fcd3fb00d1d59a981fe67a24b77310592de03fc0
grant-tables: do not fail attempts to GNTTABOP_set_version to the current
version.
...even if there are active grants.
This triggers when checkpoint a guest which essentially resumes
without actually having gone through the suspend so the domain is
already latched to v2 inside Xen.
Also return the current actual version on success and failure. Not
terribly useful with only 2 options but is more robust to future
developments.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
xen/common/grant_table.c | 21 ++++++++++++++++-----
xen/include/public/grant_table.h | 2 +-
2 files changed, 17 insertions(+), 6 deletions(-)
diff -r fcd3fb00d1d5 -r 0f35fb4f73d6 xen/common/grant_table.c
--- a/xen/common/grant_table.c Thu Dec 03 13:51:20 2009 +0000
+++ b/xen/common/grant_table.c Thu Dec 03 13:52:02 2009 +0000
@@ -1972,14 +1972,19 @@ gnttab_set_version(XEN_GUEST_HANDLE(gntt
struct domain *d = current->domain;
struct grant_table *gt = d->grant_table;
struct active_grant_entry *act;
- long res = 0;
+ long res;
int i;
if (copy_from_guest(&op, uop, 1))
return -EFAULT;
+ res = -EINVAL;
if (op.version != 1 && op.version != 2)
- return -EINVAL;
+ goto out;
+
+ res = 0;
+ if ( gt->gt_version == op.version )
+ goto out;
spin_lock(>->lock);
/* Make sure that the grant table isn't currently in use when we
@@ -1997,7 +2002,7 @@ gnttab_set_version(XEN_GUEST_HANDLE(gntt
gt->gt_version,
op.version);
res = -EBUSY;
- goto out;
+ goto out_unlock;
}
}
}
@@ -2009,7 +2014,7 @@ gnttab_set_version(XEN_GUEST_HANDLE(gntt
{
res = gnttab_populate_status_frames(d, gt);
if ( res < 0)
- goto out;
+ goto out_unlock;
}
if ( op.version < 2 && gt->gt_version == 2 )
@@ -2025,8 +2030,14 @@ gnttab_set_version(XEN_GUEST_HANDLE(gntt
gt->gt_version = op.version;
+out_unlock:
+ spin_unlock(>->lock);
+
out:
- spin_unlock(>->lock);
+ op.version = gt->gt_version;
+
+ if (copy_to_guest(uop, &op, 1))
+ res = -EFAULT;
return res;
}
diff -r fcd3fb00d1d5 -r 0f35fb4f73d6 xen/include/public/grant_table.h
--- a/xen/include/public/grant_table.h Thu Dec 03 13:51:20 2009 +0000
+++ b/xen/include/public/grant_table.h Thu Dec 03 13:52:02 2009 +0000
@@ -463,7 +463,7 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_and
*/
#define GNTTABOP_set_version 8
struct gnttab_set_version {
- /* IN parameters */
+ /* IN/OUT parameters */
uint32_t version;
};
typedef struct gnttab_set_version gnttab_set_version_t;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|