memset (new, 0, sizeof(struct vx_info));
new->vx_id = xid;
- // INIT_RCU_HEAD(&new->vx_rcu);
INIT_HLIST_NODE(&new->vx_hlist);
atomic_set(&new->vx_usecnt, 0);
atomic_set(&new->vx_tasks, 0);
new->vx_parent = NULL;
new->vx_state = 0;
- new->vx_lock = SPIN_LOCK_UNLOCKED;
init_waitqueue_head(&new->vx_wait);
/* rest of init goes here */
vx_info_init_cvirt(&new->cvirt);
vx_info_init_cacct(&new->cacct);
-
- new->vx_flags = VXF_STATE_SETUP|VXF_STATE_INIT;
+ new->vx_flags = VXF_INIT_SET;
new->vx_bcaps = CAP_INIT_EFF_SET;
new->vx_ccaps = 0;
kfree(vxi);
}
-void __shutdown_vx_info(struct vx_info *vxi)
+static void __shutdown_vx_info(struct vx_info *vxi)
{
struct namespace *namespace;
struct fs_struct *fs;
void free_vx_info(struct vx_info *vxi)
{
/* context shutdown is mandatory */
- // BUG_ON(vxi->vx_state != VXS_SHUTDOWN);
+ BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
BUG_ON(atomic_read(&vxi->vx_usecnt));
BUG_ON(atomic_read(&vxi->vx_tasks));
BUG_ON(vx_info_state(vxi, VXS_HASHED));
- // BUG_ON(!vx_state(vxi, VXS_DEFUNCT));
BUG_ON(vxi->vx_namespace);
BUG_ON(vxi->vx_fs);
vxh_hash_vx_info(vxi);
/* context must not be hashed */
- BUG_ON(vxi->vx_state & VXS_HASHED);
+ BUG_ON(vx_info_state(vxi, VXS_HASHED));
vxi->vx_state |= VXS_HASHED;
head = &vx_info_hash[__hashval(vxi->vx_id)];
"__unhash_vx_info: %p[#%d]", vxi, vxi->vx_id);
vxh_unhash_vx_info(vxi);
- /* maybe warn on that? */
- if (!(vxi->vx_state & VXS_HASHED))
- return;
+ /* context must be hashed */
+ BUG_ON(!vx_info_state(vxi, VXS_HASHED));
vxi->vx_state &= ~VXS_HASHED;
hlist_del(&vxi->vx_hlist);
vxdprintk(VXD_CBIT(xid, 0),
"__lookup_vx_info(#%u): %p[#%u]",
xid, vxi, vxi?vxi->vx_id:0);
- vxh_lookup_vx_info(xid, vxi);
+ vxh_lookup_vx_info(vxi, xid);
return vxi;
}
out_unlock:
spin_unlock(&vx_info_hash_lock);
- vxh_loc_vx_info(id, vxi);
+ vxh_loc_vx_info(vxi, id);
if (new)
__dealloc_vx_info(new);
return vxi;
/* __create_vx_info()
* create the requested context
- * get() it and hash it */
+ * get() and hash it */
static struct vx_info * __create_vx_info(int id)
{
vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
- if (!(new = __alloc_vx_info(id))) {
+ if (!(new = __alloc_vx_info(id)))
return ERR_PTR(-ENOMEM);
- }
/* required to make dynamic xids unique */
spin_lock(&vx_info_hash_lock);
}
new->vx_id = id;
}
- /* existing context requested */
+ /* static context requested */
else if ((vxi = __lookup_vx_info(id))) {
vxdprintk(VXD_CBIT(xid, 0),
"create_vx_info(%d) = %p (already there)", id, vxi);
goto out_unlock;
}
- /* new context requested */
+ /* new context */
vxdprintk(VXD_CBIT(xid, 0),
"create_vx_info(%d) = %p (new)", id, new);
__hash_vx_info(get_vx_info(new));
out_unlock:
spin_unlock(&vx_info_hash_lock);
- vxh_create_vx_info(id, IS_ERR(vxi)?NULL:vxi);
+ vxh_create_vx_info(IS_ERR(vxi)?NULL:vxi, id);
if (new)
__dealloc_vx_info(new);
return vxi;
}
#endif
+
int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
{
struct user_struct *new_user, *old_user;
int vc_ctx_create(uint32_t xid, void __user *data)
{
+ struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
struct vx_info *new_vxi;
int ret;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
+ if (data && copy_from_user (&vc_data, data, sizeof(vc_data)))
+ return -EFAULT;
if ((xid > MAX_S_CONTEXT) && (xid != VX_DYNAMIC_ID))
return -EINVAL;
-
if (xid < 2)
return -EINVAL;
if (IS_ERR(new_vxi))
return PTR_ERR(new_vxi);
+ /* initial flags */
+ new_vxi->vx_flags = vc_data.flagword;
+
vs_state_change(new_vxi, VSC_STARTUP);
ret = new_vxi->vx_id;
vx_migrate_task(current, new_vxi);