diff options
author | Glauber de Oliveira Costa <gcosta@redhat.com> | 2008-01-07 08:05:23 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-01-30 06:50:05 -0500 |
commit | e3283fa0cc5c4f9bde52339a40da89297e51b481 (patch) | |
tree | c289c2681d2cedd5ee778a8a754417ab50946d8a /Documentation | |
parent | badb1e04028e3e029ff9447d4aeb162a84ad68c2 (diff) |
lguest: adapt launcher to per-cpuness
This patch makes uses of pread() and pwrite() in lguest launcher
to communicate the vcpu id to the lguest driver. The id is kept in
a thread variable, which means we'll span in the future, vcpus as
threads. But right now, only the infrastructure is out there.
Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/lguest/lguest.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c index 86cac3e622ab..6c8a2386cd50 100644 --- a/Documentation/lguest/lguest.c +++ b/Documentation/lguest/lguest.c | |||
@@ -79,6 +79,9 @@ static void *guest_base; | |||
79 | /* The maximum guest physical address allowed, and maximum possible. */ | 79 | /* The maximum guest physical address allowed, and maximum possible. */ |
80 | static unsigned long guest_limit, guest_max; | 80 | static unsigned long guest_limit, guest_max; |
81 | 81 | ||
82 | /* a per-cpu variable indicating whose vcpu is currently running */ | ||
83 | static unsigned int __thread cpu_id; | ||
84 | |||
82 | /* This is our list of devices. */ | 85 | /* This is our list of devices. */ |
83 | struct device_list | 86 | struct device_list |
84 | { | 87 | { |
@@ -557,7 +560,7 @@ static void wake_parent(int pipefd, int lguest_fd) | |||
557 | else | 560 | else |
558 | FD_CLR(-fd - 1, &devices.infds); | 561 | FD_CLR(-fd - 1, &devices.infds); |
559 | } else /* Send LHREQ_BREAK command. */ | 562 | } else /* Send LHREQ_BREAK command. */ |
560 | write(lguest_fd, args, sizeof(args)); | 563 | pwrite(lguest_fd, args, sizeof(args), cpu_id); |
561 | } | 564 | } |
562 | } | 565 | } |
563 | 566 | ||
@@ -1530,7 +1533,8 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd) | |||
1530 | int readval; | 1533 | int readval; |
1531 | 1534 | ||
1532 | /* We read from the /dev/lguest device to run the Guest. */ | 1535 | /* We read from the /dev/lguest device to run the Guest. */ |
1533 | readval = read(lguest_fd, ¬ify_addr, sizeof(notify_addr)); | 1536 | readval = pread(lguest_fd, ¬ify_addr, |
1537 | sizeof(notify_addr), cpu_id); | ||
1534 | 1538 | ||
1535 | /* One unsigned long means the Guest did HCALL_NOTIFY */ | 1539 | /* One unsigned long means the Guest did HCALL_NOTIFY */ |
1536 | if (readval == sizeof(notify_addr)) { | 1540 | if (readval == sizeof(notify_addr)) { |
@@ -1540,7 +1544,7 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd) | |||
1540 | /* ENOENT means the Guest died. Reading tells us why. */ | 1544 | /* ENOENT means the Guest died. Reading tells us why. */ |
1541 | } else if (errno == ENOENT) { | 1545 | } else if (errno == ENOENT) { |
1542 | char reason[1024] = { 0 }; | 1546 | char reason[1024] = { 0 }; |
1543 | read(lguest_fd, reason, sizeof(reason)-1); | 1547 | pread(lguest_fd, reason, sizeof(reason)-1, cpu_id); |
1544 | errx(1, "%s", reason); | 1548 | errx(1, "%s", reason); |
1545 | /* ERESTART means that we need to reboot the guest */ | 1549 | /* ERESTART means that we need to reboot the guest */ |
1546 | } else if (errno == ERESTART) { | 1550 | } else if (errno == ERESTART) { |
@@ -1550,9 +1554,13 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd) | |||
1550 | } else if (errno != EAGAIN) | 1554 | } else if (errno != EAGAIN) |
1551 | err(1, "Running guest failed"); | 1555 | err(1, "Running guest failed"); |
1552 | 1556 | ||
1557 | /* Only service input on thread for CPU 0. */ | ||
1558 | if (cpu_id != 0) | ||
1559 | continue; | ||
1560 | |||
1553 | /* Service input, then unset the BREAK to release the Waker. */ | 1561 | /* Service input, then unset the BREAK to release the Waker. */ |
1554 | handle_input(lguest_fd); | 1562 | handle_input(lguest_fd); |
1555 | if (write(lguest_fd, args, sizeof(args)) < 0) | 1563 | if (pwrite(lguest_fd, args, sizeof(args), cpu_id) < 0) |
1556 | err(1, "Resetting break"); | 1564 | err(1, "Resetting break"); |
1557 | } | 1565 | } |
1558 | } | 1566 | } |
@@ -1610,6 +1618,7 @@ int main(int argc, char *argv[]) | |||
1610 | devices.lastdev = &devices.dev; | 1618 | devices.lastdev = &devices.dev; |
1611 | devices.next_irq = 1; | 1619 | devices.next_irq = 1; |
1612 | 1620 | ||
1621 | cpu_id = 0; | ||
1613 | /* We need to know how much memory so we can set up the device | 1622 | /* We need to know how much memory so we can set up the device |
1614 | * descriptor and memory pages for the devices as we parse the command | 1623 | * descriptor and memory pages for the devices as we parse the command |
1615 | * line. So we quickly look through the arguments to find the amount | 1624 | * line. So we quickly look through the arguments to find the amount |