aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorsos22@labyrinth.cl.cam.ac.uk <sos22@labyrinth.cl.cam.ac.uk>2003-07-04 09:53:43 +0000
committersos22@labyrinth.cl.cam.ac.uk <sos22@labyrinth.cl.cam.ac.uk>2003-07-04 09:53:43 +0000
commit3ec07fa1bee4de5de8dfc362a48c1520dcba722c (patch)
tree8f61ae394a5b4cd20ba1b858753b6413f0c1b1ad /tools
parent4891aa3b412318cbf1f3d4a74eaac53822464762 (diff)
downloadxen-3ec07fa1bee4de5de8dfc362a48c1520dcba722c.tar.gz
xen-3ec07fa1bee4de5de8dfc362a48c1520dcba722c.tar.bz2
xen-3ec07fa1bee4de5de8dfc362a48c1520dcba722c.zip
bitkeeper revision 1.266 (3f054ea7i0rAG6Iai3U1MfAFEUMAMQ)
Numerous bug fixes, and a slightly less perverted /proc interface.
Diffstat (limited to 'tools')
-rw-r--r--tools/internal/Makefile9
-rw-r--r--tools/internal/physdev.h7
-rw-r--r--tools/internal/xi_phys_grant.c8
-rw-r--r--tools/internal/xi_phys_probe.c16
-rw-r--r--tools/internal/xi_phys_revoke.c9
5 files changed, 29 insertions, 20 deletions
diff --git a/tools/internal/Makefile b/tools/internal/Makefile
index 8b50b410e8..8611e297cb 100644
--- a/tools/internal/Makefile
+++ b/tools/internal/Makefile
@@ -6,9 +6,10 @@ XI_DESTROY = xi_destroy
XI_BUILD = xi_build
XI_PHYS_GRANT = xi_phys_grant
XI_PHYS_REVOKE = xi_phys_revoke
+XI_PHYS_PROBE = xi_phys_probe
all: $(XI_CREATE).o $(XI_START).o $(XI_STOP).o $(XI_DESTROY).o $(XI_BUILD).o \
- $(XI_PHYS_GRANT).o $(XI_PHYS_REVOKE).o
+ $(XI_PHYS_GRANT).o $(XI_PHYS_REVOKE).o $(XI_PHYS_PROBE).o
$(CC) -o $(XI_CREATE) $(XI_CREATE).o
$(CC) -o $(XI_BUILD) $(XI_BUILD).o
$(CC) -o $(XI_START) $(XI_START).o
@@ -16,6 +17,7 @@ all: $(XI_CREATE).o $(XI_START).o $(XI_STOP).o $(XI_DESTROY).o $(XI_BUILD).o \
$(CC) -o $(XI_DESTROY) $(XI_DESTROY).o
$(CC) -o $(XI_PHYS_GRANT) $(XI_PHYS_GRANT).o
$(CC) -o $(XI_PHYS_REVOKE) $(XI_PHYS_REVOKE).o
+ $(CC) -o $(XI_PHYS_PROBE) $(XI_PHYS_PROBE).o
$(XI_CREATE).o: $(XI_CREATE).c dom0_defs.h dom0_ops.h hypervisor_defs.h mem_defs.h
$(CC) -c $(XI_CREATE).c
@@ -38,8 +40,11 @@ $(XI_PHYS_GRANT).o: $(XI_PHYS_GRANT).c physdev.h
$(XI_PHYS_REVOKE).o: $(XI_PHYS_REVOKE).c physdev.h
$(CC) -c $(XI_PHYS_REVOKE).c
+$(XI_PHYS_PROBE).o: $(XI_PHYS_PROBE).c physdev.h
+ $(CC) -c $(XI_PHYS_PROBE).c
+
install: all
- cp -a xi_list xi_vifinit xi_helper $(XI_CREATE) $(XI_BUILD) $(XI_START) $(XI_STOP) $(XI_DESTROY) $(XI_PHYSDEV_GRANT) $(XI_PHYS_REVOKE) ../../../install/bin
+ cp -a xi_list xi_vifinit xi_helper $(XI_CREATE) $(XI_BUILD) $(XI_START) $(XI_STOP) $(XI_DESTROY) $(XI_PHYSDEV_GRANT) $(XI_PHYS_REVOKE) $(XI_PHYS_PROBE).o../../../install/bin
chmod 755 ../../../install/bin/xi_list
chmod 755 ../../../install/bin/xi_vifinit
chmod 755 ../../../install/bin/xi_helper
diff --git a/tools/internal/physdev.h b/tools/internal/physdev.h
index 54a0120be1..5a868fe4c7 100644
--- a/tools/internal/physdev.h
+++ b/tools/internal/physdev.h
@@ -1,11 +1,12 @@
#define XEN_BLOCK_PHYSDEV_GRANT 10 /* grant access to range of disk blocks */
-#define XEN_BLOCK_PHYSDEV_REVOKE 11 /* revoke access to range of disk blocks */
-#define XEN_BLOCK_PHYSDEV_PROBE 12 /* probe for a domain's physdev
+#define XEN_BLOCK_PHYSDEV_PROBE 11 /* probe for a domain's physdev
accesses */
+#define PHYSDISK_MODE_R 1
+#define PHYSDISK_MODE_W 2
typedef struct xp_disk
{
- int mode;
+ int mode; /* PHYSDISK_MODEs or 0 for revoke. */
int domain;
unsigned short device;
unsigned long start_sect;
diff --git a/tools/internal/xi_phys_grant.c b/tools/internal/xi_phys_grant.c
index 7912185066..eaf72a80f7 100644
--- a/tools/internal/xi_phys_grant.c
+++ b/tools/internal/xi_phys_grant.c
@@ -9,6 +9,7 @@ int main(int argc, char *argv[])
{
xp_disk_t buf;
int fd;
+ char *strbuf;
if (argc != 6) {
fprintf(stderr, "Usage: xi_physdev_grant <r/rw> <domain> <device> <start sector> <n_sectors>\n");
@@ -25,16 +26,17 @@ int main(int argc, char *argv[])
else if (argv[1][1] == 'w')
buf.mode |= 2;
- buf.domain = atol(argv[2]);
buf.device = atol(argv[3]);
buf.start_sect = atol(argv[4]);
buf.n_sectors = atol(argv[5]);
- fd = open("/proc/xeno/dom0/phd", O_WRONLY);
+ asprintf(&strbuf, "/proc/xeno/dom%s/phd", argv[2]);
+ fd = open(strbuf, O_WRONLY);
if (fd < 0) {
- fprintf(stderr, "Can\'t open /proc/xeno/dom0/phd: %s.\n", strerror(errno));
+ fprintf(stderr, "Can\'t open %s: %s.\n", strbuf, strerror(errno));
return 1;
}
+ free(strbuf);
write(fd, &buf, sizeof(buf));
close(fd);
diff --git a/tools/internal/xi_phys_probe.c b/tools/internal/xi_phys_probe.c
index caa01d3604..f962ce551e 100644
--- a/tools/internal/xi_phys_probe.c
+++ b/tools/internal/xi_phys_probe.c
@@ -11,31 +11,29 @@ int main(int argc, char *argv[])
physdisk_probebuf_t buf;
int fd;
int x;
+ char *strbuf;
if (argc != 2) {
fprintf(stderr, "Usage: xi_phys_probe <domain_nr>\n");
return 1;
}
- fd = open("/proc/xeno/dom0/phd", O_RDONLY);
+ asprintf(&strbuf, "/proc/xeno/dom%s/phd", argv[1]);
+ fd = open(strbuf, O_RDONLY);
if (fd < 0) {
- fprintf(stderr, "Can\'t open /proc/xeno/dom0/phd: %s.\n",
- strerror(errno));
+ fprintf(stderr, "Can\'t open %s: %s.\n", strbuf, strerror(errno));
return 1;
}
+ free(strbuf);
memset(&buf, 0, sizeof(buf));
buf.n_aces = PHYSDISK_MAX_ACES_PER_REQUEST;
- while (buf.n_aces == PHYSDISK_MAX_ACES_PER_REQUEST ||
- buf.n_aces == 0) {
+ do {
buf.n_aces = PHYSDISK_MAX_ACES_PER_REQUEST;
- buf.domain = atol(argv[1]);
read(fd, &buf, sizeof(buf));
if (!buf.n_aces)
break;
- printf("Found %d ACEs\n", buf.n_aces);
-
for (x = 0; x < buf.n_aces; x++) {
printf("%x:[%x,%x) : %x\n", buf.entries[x].device,
buf.entries[x].start_sect,
@@ -43,6 +41,6 @@ int main(int argc, char *argv[])
buf.entries[x].mode);
}
buf.start_ind += buf.n_aces;
- }
+ } while (buf.n_aces == PHYSDISK_MAX_ACES_PER_REQUEST);
return 0;
}
diff --git a/tools/internal/xi_phys_revoke.c b/tools/internal/xi_phys_revoke.c
index b4bf72833b..d4bb083b16 100644
--- a/tools/internal/xi_phys_revoke.c
+++ b/tools/internal/xi_phys_revoke.c
@@ -9,22 +9,25 @@ int main(int argc, char *argv[])
{
xp_disk_t buf;
int fd;
+ char *strbuf;
if (argc != 5) {
fprintf(stderr, "Usage: xi_physdev_revoke <domain> <device> <start sector> <n_sectors>\n");
return 1;
}
- buf.domain = atol(argv[1]);
buf.device = atol(argv[2]);
+ buf.mode = 0;
buf.start_sect = atol(argv[3]);
buf.n_sectors = atol(argv[4]);
- fd = open("/proc/xeno/dom0/phd", O_WRONLY);
+ asprintf(&strbuf, "/proc/xeno/dom%s/phd", argv[1]);
+ fd = open(strbuf, O_WRONLY);
if (fd < 0) {
- fprintf(stderr, "Can\'t open /proc/xeno/dom0/phd: %s.\n", strerror(errno));
+ fprintf(stderr, "Can\'t open %s: %s.\n", strbuf, strerror(errno));
return 1;
}
+ free(strbuf);
write(fd, &buf, sizeof(buf));
close(fd);