Skip to content

Commit

Permalink
lguest: make write() operation smp aware
Browse files Browse the repository at this point in the history
This patch makes the write() file operation smp aware. Which means, receiving
the vcpu_id value through the offset parameter, and being well aware to which
vcpu we're talking to.

Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Glauber de Oliveira Costa authored and Rusty Russell committed Jan 30, 2008
1 parent d0953d4 commit 7ea07a1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/lguest/lguest_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,21 @@ static ssize_t write(struct file *file, const char __user *in,
struct lguest *lg = file->private_data;
const unsigned long __user *input = (const unsigned long __user *)in;
unsigned long req;
struct lg_cpu *cpu;
unsigned int cpu_id = *off;

if (get_user(req, input) != 0)
return -EFAULT;
input++;

/* If you haven't initialized, you must do that first. */
if (req != LHREQ_INITIALIZE && !lg)
return -EINVAL;
if (req != LHREQ_INITIALIZE) {
if (!lg || (cpu_id >= lg->nr_cpus))
return -EINVAL;
cpu = &lg->cpus[cpu_id];
if (!cpu)
return -EINVAL;
}

/* Once the Guest is dead, all you can do is read() why it died. */
if (lg && lg->dead)
Expand Down

0 comments on commit 7ea07a1

Please sign in to comment.