vhost.c (6e9041c6ddd6cbdc61d87bcaca8ca7bb17c28377) | vhost.c (05c05351943cc03bf5c77e86953b24ae6fb21368) |
---|---|
1/* Copyright (C) 2009 Red Hat, Inc. 2 * Copyright (C) 2006 Rusty Russell IBM Corporation 3 * 4 * Author: Michael S. Tsirkin <mst@redhat.com> 5 * 6 * Inspiration, some code, and most witty comments come from 7 * Documentation/virtual/lguest/lguest.c, by Rusty Russell 8 * --- 330 unchanged lines hidden (view full) --- 339 attach.owner = current; 340 vhost_work_init(&attach.work, vhost_attach_cgroups_work); 341 vhost_work_queue(dev, &attach.work); 342 vhost_work_flush(dev, &attach.work); 343 return attach.ret; 344} 345 346/* Caller should have device mutex */ | 1/* Copyright (C) 2009 Red Hat, Inc. 2 * Copyright (C) 2006 Rusty Russell IBM Corporation 3 * 4 * Author: Michael S. Tsirkin <mst@redhat.com> 5 * 6 * Inspiration, some code, and most witty comments come from 7 * Documentation/virtual/lguest/lguest.c, by Rusty Russell 8 * --- 330 unchanged lines hidden (view full) --- 339 attach.owner = current; 340 vhost_work_init(&attach.work, vhost_attach_cgroups_work); 341 vhost_work_queue(dev, &attach.work); 342 vhost_work_flush(dev, &attach.work); 343 return attach.ret; 344} 345 346/* Caller should have device mutex */ |
347bool vhost_dev_has_owner(struct vhost_dev *dev) 348{ 349 return dev->mm; 350} 351 352/* Caller should have device mutex */ |
|
347long vhost_dev_set_owner(struct vhost_dev *dev) 348{ 349 struct task_struct *worker; 350 int err; 351 352 /* Is there an owner already? */ | 353long vhost_dev_set_owner(struct vhost_dev *dev) 354{ 355 struct task_struct *worker; 356 int err; 357 358 /* Is there an owner already? */ |
353 if (dev->mm) { | 359 if (vhost_dev_has_owner(dev)) { |
354 err = -EBUSY; 355 goto err_mm; 356 } 357 358 /* No owner, become one */ 359 dev->mm = get_task_mm(current); 360 worker = kthread_create(vhost_worker, dev, "vhost-%d", current->pid); 361 if (IS_ERR(worker)) { --- 1168 unchanged lines hidden --- | 360 err = -EBUSY; 361 goto err_mm; 362 } 363 364 /* No owner, become one */ 365 dev->mm = get_task_mm(current); 366 worker = kthread_create(vhost_worker, dev, "vhost-%d", current->pid); 367 if (IS_ERR(worker)) { --- 1168 unchanged lines hidden --- |