aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/ioemu/Makefile22
-rw-r--r--tools/ioemu/pc-bios/Makefile24
-rw-r--r--tools/ioemu/pc-bios/README13
-rw-r--r--tools/ioemu/pc-bios/bios.binbin65536 -> 0 bytes
-rw-r--r--tools/ioemu/pc-bios/bios.diff162
-rw-r--r--tools/ioemu/pc-bios/linux_boot.S29
-rw-r--r--tools/ioemu/pc-bios/linux_boot.binbin512 -> 0 bytes
-rw-r--r--tools/ioemu/pc-bios/ppc_rom.binbin524288 -> 0 bytes
-rw-r--r--tools/ioemu/pc-bios/proll.binbin56856 -> 0 bytes
-rw-r--r--tools/ioemu/pc-bios/proll.patch50
-rw-r--r--tools/ioemu/pc-bios/vgabios-cirrus.binbin30868 -> 0 bytes
-rw-r--r--tools/ioemu/pc-bios/vgabios.binbin31533 -> 0 bytes
-rw-r--r--tools/python/xen/lowlevel/xs/xs.c6
-rw-r--r--tools/python/xen/lowlevel/xu/xu.c1
-rw-r--r--tools/xenstore/Makefile3
-rw-r--r--tools/xenstore/fake_libxc.c2
-rw-r--r--tools/xenstore/xenstored_core.c34
-rw-r--r--tools/xenstore/xenstored_core.h3
-rw-r--r--tools/xenstore/xenstored_domain.c3
-rw-r--r--tools/xenstore/xenstored_test.h2
-rw-r--r--tools/xenstore/xs.c14
-rw-r--r--tools/xenstore/xs_lib.c8
-rw-r--r--tools/xenstore/xs_lib.h8
-rw-r--r--tools/xenstore/xs_random.c8
-rw-r--r--tools/xenstore/xs_test.c8
25 files changed, 58 insertions, 342 deletions
diff --git a/tools/ioemu/Makefile b/tools/ioemu/Makefile
index 502413fc8a..d99da37ef4 100644
--- a/tools/ioemu/Makefile
+++ b/tools/ioemu/Makefile
@@ -51,23 +51,9 @@ common de-ch es fo fr-ca hu ja mk nl-be pt sl tr
install: all
mkdir -p "$(bindir)"
-ifndef CONFIG_WIN32
-# install -m 755 -s $(TOOLS) "$(bindir)"
-endif
mkdir -p "$(DESTDIR)/$(datadir)"
- install -m 644 pc-bios/bios.bin pc-bios/vgabios.bin \
- pc-bios/vgabios-cirrus.bin \
- pc-bios/ppc_rom.bin \
- pc-bios/proll.bin \
- pc-bios/linux_boot.bin "$(DESTDIR)/$(datadir)"
- #mkdir -p "$(DESTDIR)/$(docdir)"
- #install -m 644 qemu-doc.html qemu-tech.html "$(DESTDIR)/$(docdir)"
-ifndef CONFIG_WIN32
- #mkdir -p "$(DESTDIR)/$(mandir)/man1"
- #install qemu.1 qemu-mkcow.1 "$(DESTDIR)/$(mandir)/man1"
mkdir -p "$(DESTDIR)/$(datadir)/keymaps"
install -m 644 $(addprefix keymaps/,$(KEYMAPS)) "$(DESTDIR)/$(datadir)/keymaps"
-endif
for d in $(TARGET_DIRS); do \
$(MAKE) -C $$d $@ || exit 1 ; \
done
@@ -105,14 +91,6 @@ tarbin:
$(DESTDIR)/$(bindir)/qemu-arm \
$(DESTDIR)/$(bindir)/qemu-sparc \
$(DESTDIR)/$(bindir)/qemu-ppc \
- $(DESTDIR)/$(datadir)/bios.bin \
- $(DESTDIR)/$(datadir)/vgabios.bin \
- $(DESTDIR)/$(datadir)/vgabios-cirrus.bin \
- $(DESTDIR)/$(datadir)/ppc_rom.bin \
- $(DESTDIR)/$(datadir)/proll.bin \
- $(DESTDIR)/$(datadir)/linux_boot.bin \
- $(DESTDIR)/$(docdir)/qemu-doc.html \
- $(DESTDIR)/$(docdir)/qemu-tech.html \
$(DESTDIR)/$(mandir)/man1/qemu.1 $(DESTDIR)/$(mandir)/man1/qemu-mkcow.1 )
ifneq ($(wildcard .depend),)
diff --git a/tools/ioemu/pc-bios/Makefile b/tools/ioemu/pc-bios/Makefile
deleted file mode 100644
index 7ae0ff02a0..0000000000
--- a/tools/ioemu/pc-bios/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# NOTE: only compilable with x86 cross compile tools
-#
-include ../config-host.mak
-
-DEFINES=
-
-TARGETS=
-ifeq ($(ARCH),i386)
-TARGETS+=linux_boot.bin
-endif
-
-all: $(TARGETS)
-
-linux_boot.bin: linux_boot.o
- ld --oformat binary -Ttext 0 -o $@ $<
- chmod a-x $@
-
-%.o: %.S
- $(CC) $(DEFINES) -c -o $@ $<
-
-clean:
- rm -f $(TARGETS) *.o *~
-
diff --git a/tools/ioemu/pc-bios/README b/tools/ioemu/pc-bios/README
deleted file mode 100644
index a10a9f0dfa..0000000000
--- a/tools/ioemu/pc-bios/README
+++ /dev/null
@@ -1,13 +0,0 @@
-- The PC BIOS comes from the Bochs project
- (http://bochs.sourceforge.net/). A patch from bios.diff was applied.
-
-- The VGA BIOS and the Cirrus VGA BIOS come from the LGPL VGA bios
- project (http://www.nongnu.org/vgabios/).
-
-- The PowerPC Open Hack'Ware Open Firmware Compatible BIOS is
- available at http://site.voila.fr/jmayer/OpenHackWare/index.htm.
-
-- Proll is a GPL'd boot PROM for Sparc JavaStations
- (http://people.redhat.com/zaitcev/linux/).
- Applying proll.patch allows circumventing some bugs and enables
- faster kernel load through a hack.
diff --git a/tools/ioemu/pc-bios/bios.bin b/tools/ioemu/pc-bios/bios.bin
deleted file mode 100644
index fe9816e0a7..0000000000
--- a/tools/ioemu/pc-bios/bios.bin
+++ /dev/null
Binary files differ
diff --git a/tools/ioemu/pc-bios/bios.diff b/tools/ioemu/pc-bios/bios.diff
deleted file mode 100644
index 7850769642..0000000000
--- a/tools/ioemu/pc-bios/bios.diff
+++ /dev/null
@@ -1,162 +0,0 @@
-Index: rombios.c
-===================================================================
-RCS file: /cvsroot/bochs/bochs/bios/rombios.c,v
-retrieving revision 1.110
-diff -u -w -r1.110 rombios.c
---- rombios.c 31 May 2004 13:11:27 -0000 1.110
-+++ rombios.c 7 Oct 2004 21:23:50 -0000
-@@ -137,6 +137,7 @@
- #define DEBUG_INT16 0
- #define DEBUG_INT1A 0
- #define DEBUG_INT74 0
-+#define DEBUG_APM 0
-
- #define BX_CPU 3
- #define BX_USE_PS2_MOUSE 1
-@@ -145,6 +146,7 @@
- #define BX_SUPPORT_FLOPPY 1
- #define BX_FLOPPY_ON_CNT 37 // 2 seconds
- #define BX_PCIBIOS 1
-+#define BX_APM 1
-
- #define BX_USE_ATADRV 1
- #define BX_ELTORITO_BOOT 1
-@@ -230,17 +232,6 @@
- out dx,ax
- MEND
-
--MACRO HALT2
-- ;; the HALT macro is called with the line number of the HALT call.
-- ;; The line number is then sent to the PANIC_PORT, causing Bochs/Plex
-- ;; to print a BX_PANIC message. This will normally halt the simulation
-- ;; with a message such as "BIOS panic at rombios.c, line 4091".
-- ;; However, users can choose to make panics non-fatal and continue.
-- mov dx,#PANIC_PORT2
-- mov ax,#?1
-- out dx,ax
--MEND
--
- MACRO JMP_AP
- db 0xea
- dw ?2
-@@ -1543,15 +1534,12 @@
- }
-
- if (action & BIOS_PRINTF_HALT) {
-- // freeze in a busy loop. If I do a HLT instruction, then in versions
-- // 1.3.pre1 and earlier, it will panic without ever updating the VGA
-- // display, so the panic message will not be visible. By waiting
-- // forever, you are certain to see the panic message on screen.
-- // After a few more versions have passed, we can turn this back into
-- // a halt or something.
-- // do {} while (1);
-+ // freeze in a busy loop.
- ASM_START
-- HALT2(__LINE__)
-+ cli
-+ halt2_loop:
-+ hlt
-+ jmp halt2_loop
- ASM_END
- }
- }
-@@ -5412,8 +5400,8 @@
- case 0x03: SET_BL( 0x06 ); break;
- }
-
-- DI = 0xefc7;
-- ES = 0xf000;
-+ DI = read_word(0x00, 0x1e*4); // INT vector 0x1E
-+ ES = read_word(0x00, 0x1e*4+2);
- goto int13_success;
- break;
-
-@@ -6984,8 +6972,8 @@
- }
-
- /* set es & di to point to 11 byte diskette param table in ROM */
-- DI = 0xefc7;
-- ES = 0xf000;
-+ DI = read_word(0x00, 0x1e*4); // INT vector 0x1E
-+ ES = read_word(0x00, 0x1e*4+2);
- CLEAR_CF(); // success
- /* disk status not changed upon success */
- return;
-@@ -7880,7 +7868,7 @@
- mov al, #0x02
- out #0x0a, al ;; clear DMA-1 channel 2 mask bit
-
-- SET_INT_VECTOR(0x1E, #0xF000, #diskette_param_table)
-+ SET_INT_VECTOR(0x1E, #0xF000, #diskette_param_table2)
- SET_INT_VECTOR(0x40, #0xF000, #int13_diskette)
- SET_INT_VECTOR(0x0E, #0xF000, #int0e_handler) ;; IRQ 6
-
-@@ -8344,6 +8332,19 @@
- pop ax
- iret
-
-+
-+;--------------------
-+#if BX_APM
-+use32 386
-+#define APM_PROT32
-+#include "apmbios.S"
-+use16 386
-+
-+#define APM_REAL
-+#include "apmbios.S"
-+
-+#endif
-+
- ;--------------------
- #if BX_PCIBIOS
- use32 386
-@@ -9515,6 +9516,26 @@
- pop ds
- iret
-
-+diskette_param_table2:
-+;; New diskette parameter table adding 3 parameters from IBM
-+;; Since no provisions are made for multiple drive types, most
-+;; values in this table are ignored. I set parameters for 1.44M
-+;; floppy here
-+db 0xAF
-+db 0x02 ;; head load time 0000001, DMA used
-+db 0x25
-+db 0x02
-+db 18
-+db 0x1B
-+db 0xFF
-+db 0x6C
-+db 0xF6
-+db 0x0F
-+db 0x08
-+db 79 ;; maximum track
-+db 0 ;; data transfer rate
-+db 4 ;; drive type in cmos
-+
- .org 0xf045 ; INT 10 Functions 0-Fh Entry Point
- HALT(__LINE__)
- iret
-@@ -9560,6 +9581,10 @@
- .org 0xf859 ; INT 15h System Services Entry Point
- int15_handler:
- pushf
-+#if BX_APM
-+ cmp ah, #0x53
-+ je apm_call
-+#endif
- push ds
- push es
- pushad
-@@ -9570,6 +9595,10 @@
- popf
- //JMPL(iret_modify_cf)
- jmp iret_modify_cf
-+#if BX_APM
-+apm_call:
-+ jmp _apmreal_entry
-+#endif
-
- ;; Protected mode IDT descriptor
- ;;
diff --git a/tools/ioemu/pc-bios/linux_boot.S b/tools/ioemu/pc-bios/linux_boot.S
deleted file mode 100644
index 22fcd4be80..0000000000
--- a/tools/ioemu/pc-bios/linux_boot.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * QEMU Boot sector to launch a preloaded Linux kernel
- * Copyright (c) 2004 Fabrice Bellard
- */
-
-#define LOAD_SEG 0x9000
-
-.code16
-.text
- .globl _start
-
-_start:
- cli
- cld
- mov $LOAD_SEG, %ax
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %fs
- mov %ax, %gs
- mov %ax, %ss
- mov $0x8ffe, %sp
- ljmp $LOAD_SEG + 0x20, $0
-
-1:
- .fill 510 - (1b - _start), 1, 0
-
- /* boot sector signature */
- .byte 0x55
- .byte 0xaa
diff --git a/tools/ioemu/pc-bios/linux_boot.bin b/tools/ioemu/pc-bios/linux_boot.bin
deleted file mode 100644
index 80f7b5fee1..0000000000
--- a/tools/ioemu/pc-bios/linux_boot.bin
+++ /dev/null
Binary files differ
diff --git a/tools/ioemu/pc-bios/ppc_rom.bin b/tools/ioemu/pc-bios/ppc_rom.bin
deleted file mode 100644
index d882dee3e3..0000000000
--- a/tools/ioemu/pc-bios/ppc_rom.bin
+++ /dev/null
Binary files differ
diff --git a/tools/ioemu/pc-bios/proll.bin b/tools/ioemu/pc-bios/proll.bin
deleted file mode 100644
index 0489cc245f..0000000000
--- a/tools/ioemu/pc-bios/proll.bin
+++ /dev/null
Binary files differ
diff --git a/tools/ioemu/pc-bios/proll.patch b/tools/ioemu/pc-bios/proll.patch
deleted file mode 100644
index b0860e26f4..0000000000
--- a/tools/ioemu/pc-bios/proll.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-diff -ru proll_18.orig/mrcoffee/main.c proll_18/mrcoffee/main.c
---- proll_18.orig/mrcoffee/main.c 2002-09-13 16:16:59.000000000 +0200
-+++ proll_18/mrcoffee/main.c 2004-09-26 11:52:23.000000000 +0200
-@@ -101,6 +101,7 @@
- le_probe();
- init_net();
-
-+#ifdef ORIG
- #if 0 /* RARP */
- if (rarp() != 0) fatal();
- /* printrarp(); */
-@@ -117,13 +118,20 @@
- xtoa(myipaddr, fname, 8);
- if (load(boot_rec.bp_siaddr, fname) != 0) fatal();
- #endif
-+#endif
-
- romvec = init_openprom(bb.nbanks, bb.bankv, hiphybas);
-
- printk("Memory used: virt 0x%x:0x%x[%dK] iomap 0x%x:0x%x\n",
- PROLBASE, (int)cmem.curp, ((unsigned) cmem.curp - PROLBASE)/1024,
- (int)cio.start, (int)cio.curp);
-+#ifdef ORIG
- set_timeout(5); while (!chk_timeout()) { } /* P3: let me read */
-+#else
-+ printk("loading kernel:");
-+ i = ld_bypass(0x20000000);
-+ printk(" done, size %d\n", i);
-+#endif
-
- {
- void (*entry)(void *, int) = (void (*)(void*, int)) LOADBASE;
-diff -ru proll_18.orig/mrcoffee/openprom.c proll_18/mrcoffee/openprom.c
---- proll_18.orig/mrcoffee/openprom.c 2002-09-13 16:17:03.000000000 +0200
-+++ proll_18/mrcoffee/openprom.c 2004-09-21 21:27:16.000000000 +0200
-@@ -144,10 +144,14 @@
- };
-
- static int cpu_nctx = NCTX_SWIFT;
-+static int cpu_cache_line_size = 0x20;
-+static int cpu_cache_nlines = 0x200;
- static struct property propv_cpu[] = {
- {"name", "STP1012PGA", sizeof("STP1012PGA") },
- {"device_type", "cpu", 4 },
- {"mmu-nctx", (char*)&cpu_nctx, sizeof(int)},
-+ {"cache-line-size", (char*)&cpu_cache_line_size, sizeof(int)},
-+ {"cache-nlines", (char*)&cpu_cache_nlines, sizeof(int)},
- {NULL, NULL, -1}
- };
-
diff --git a/tools/ioemu/pc-bios/vgabios-cirrus.bin b/tools/ioemu/pc-bios/vgabios-cirrus.bin
deleted file mode 100644
index 4e3c829545..0000000000
--- a/tools/ioemu/pc-bios/vgabios-cirrus.bin
+++ /dev/null
Binary files differ
diff --git a/tools/ioemu/pc-bios/vgabios.bin b/tools/ioemu/pc-bios/vgabios.bin
deleted file mode 100644
index ed31b12b13..0000000000
--- a/tools/ioemu/pc-bios/vgabios.bin
+++ /dev/null
Binary files differ
diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/xs/xs.c
index 98d7826809..6ecddc6fd4 100644
--- a/tools/python/xen/lowlevel/xs/xs.c
+++ b/tools/python/xen/lowlevel/xs/xs.c
@@ -85,7 +85,7 @@ static PyObject *xspy_read(PyObject *self, PyObject *args, PyObject *kwds)
struct xs_handle *xh = xshandle(self);
char *xsval = NULL;
- int xsval_n = 0;
+ unsigned int xsval_n = 0;
PyObject *val = NULL;
if (!xh)
@@ -134,7 +134,7 @@ static PyObject *xspy_ls(PyObject *self, PyObject *args, PyObject *kwds)
struct xs_handle *xh = xshandle(self);
PyObject *val = NULL;
char **xsval = NULL;
- int xsval_n = 0;
+ unsigned int xsval_n = 0;
int i;
if (!xh)
@@ -183,7 +183,7 @@ static PyObject *xspy_get_permissions(PyObject *self, PyObject *args,
struct xs_handle *xh = xshandle(self);
PyObject *val = NULL;
struct xs_permissions *perms;
- int perms_n = 0;
+ unsigned int perms_n = 0;
int i;
if (!xh)
diff --git a/tools/python/xen/lowlevel/xu/xu.c b/tools/python/xen/lowlevel/xu/xu.c
index 359cb71a2d..65660ba6dc 100644
--- a/tools/python/xen/lowlevel/xu/xu.c
+++ b/tools/python/xen/lowlevel/xu/xu.c
@@ -908,7 +908,6 @@ static PyObject *xu_message_new(PyObject *self, PyObject *args)
break;
case TYPE(CMSG_MEM_REQUEST, CMSG_MEM_REQUEST_SET):
P2C(mem_request_t, target, u32);
- P2C(mem_request_t, status, u32);
break;
case TYPE(CMSG_USBIF_FE, CMSG_USBIF_FE_INTERFACE_STATUS_CHANGED):
P2C(usbif_fe_interface_status_changed_t, status, u32);
diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
index b5511aea3c..408078efba 100644
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -92,8 +92,11 @@ install: xenstored libxenstore.a
$(INSTALL_DIR) -p $(DESTDIR)/var/run/xenstored
$(INSTALL_DIR) -p $(DESTDIR)/var/lib/xenstored
$(INSTALL_DIR) -p $(DESTDIR)/usr/sbin
+ $(INSTALL_DIR) -p $(DESTDIR)/usr/include
$(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin
$(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
$(INSTALL_DATA) libxenstore.a $(DESTDIR)/usr/$(LIBDIR)
+ $(INSTALL_DATA) xs.h $(DESTDIR)/usr/include
+ $(INSTALL_DATA) xs_lib.h $(DESTDIR)/usr/include
-include $(PROG_DEP)
diff --git a/tools/xenstore/fake_libxc.c b/tools/xenstore/fake_libxc.c
index decfb4001d..50e1db717c 100644
--- a/tools/xenstore/fake_libxc.c
+++ b/tools/xenstore/fake_libxc.c
@@ -71,7 +71,7 @@ int xc_interface_open(void)
return fd;
memset(page, 0, sizeof(page));
- if (!write_all(fd, page, sizeof(page)))
+ if (!xs_write_all(fd, page, sizeof(page)))
barf_perror("Failed to write /tmp/xcmap page");
return fd;
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index 9d15848463..1df00f37b4 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -81,7 +81,7 @@ bool test_write_all(int fd, void *contents, unsigned int len)
errno = ENOSPC;
return false;
}
- return write_all(fd, contents, len);
+ return xs_write_all(fd, contents, len);
}
int test_mkdir(const char *dir, int perms);
@@ -443,9 +443,9 @@ static struct xs_permissions *get_perms(struct transaction *transaction,
if (!strings)
return NULL;
- *num = count_strings(strings, size);
+ *num = xs_count_strings(strings, size);
ret = talloc_array(node, struct xs_permissions, *num);
- if (!strings_to_perms(ret, *num, strings))
+ if (!xs_strings_to_perms(ret, *num, strings))
corrupt(NULL, "Permissions corrupt for %s", node);
return ret;
@@ -460,7 +460,7 @@ static char *perms_to_strings(const char *node,
char buffer[MAX_STRLEN(domid_t) + 1];
for (*len = 0, i = 0; i < num; i++) {
- if (!perm_to_string(&perms[i], buffer))
+ if (!xs_perm_to_string(&perms[i], buffer))
return NULL;
strings = talloc_realloc(node, strings, char,
@@ -506,7 +506,7 @@ static char *tempfile(const char *path, void *contents, unsigned int len)
if (!fd)
return NULL;
talloc_set_destructor(tmppath, destroy_path);
- if (!write_all(*fd, contents, len))
+ if (!xs_write_all(*fd, contents, len))
return NULL;
return tmppath;
@@ -617,7 +617,7 @@ bool check_node_perms(struct connection *conn, const char *node,
return false;
}
- if (!conn->write && (perm & XS_PERM_WRITE)) {
+ if (!conn->can_write && (perm & XS_PERM_WRITE)) {
errno = EROFS;
return false;
}
@@ -721,14 +721,14 @@ static bool new_directory(struct connection *conn,
permstr = perms_to_strings(dir, &perms, 1, &len);
fd = talloc_open(node_permfile(conn->transaction, node),
O_WRONLY|O_CREAT|O_EXCL, 0640);
- if (!fd || !write_all(*fd, permstr, len))
+ if (!fd || !xs_write_all(*fd, permstr, len))
return false;
if (data) {
char *datapath = node_datafile(conn->transaction, node);
fd = talloc_open(datapath, O_WRONLY|O_CREAT|O_EXCL, 0640);
- if (!fd || !write_all(*fd, data, datalen))
+ if (!fd || !xs_write_all(*fd, data, datalen))
return false;
}
@@ -878,7 +878,7 @@ static bool do_set_perms(struct connection *conn, struct buffered_data *in)
char *node;
struct xs_permissions *perms;
- num = count_strings(in->buffer, in->used);
+ num = xs_count_strings(in->buffer, in->used);
if (num < 2)
return send_error(conn, EINVAL);
@@ -898,7 +898,7 @@ static bool do_set_perms(struct connection *conn, struct buffered_data *in)
return send_error(conn, errno);
perms = talloc_array(node, struct xs_permissions, num);
- if (!strings_to_perms(perms, num, in->buffer))
+ if (!xs_strings_to_perms(perms, num, in->buffer))
return send_error(conn, errno);
if (!set_perms(conn->transaction, node, perms, num))
@@ -938,6 +938,12 @@ static bool process_message(struct connection *conn, struct buffered_data *in)
return do_set_perms(conn, in);
case XS_SHUTDOWN:
+ /* FIXME: Implement gentle shutdown too. */
+ /* Only tools can do this. */
+ if (conn->id != 0)
+ return send_error(conn, EACCES);
+ if (!conn->can_write)
+ return send_error(conn, EROFS);
send_ack(conn, XS_SHUTDOWN);
/* Everything hangs off auto-free context, freed at exit. */
exit(0);
@@ -1137,6 +1143,7 @@ struct connection *new_connection(connwritefn_t *write, connreadfn_t *read)
new->transaction = NULL;
new->write = write;
new->read = read;
+ new->can_write = true;
talloc_set_fail_handler(out_of_mem, &talloc_fail);
if (setjmp(talloc_fail)) {
@@ -1170,10 +1177,11 @@ static void accept_connection(int sock, bool canwrite)
if (fd < 0)
return;
- conn = new_connection(canwrite ? writefd : NULL, readfd);
- if (conn)
+ conn = new_connection(writefd, readfd);
+ if (conn) {
conn->fd = fd;
- else
+ conn->can_write = canwrite;
+ } else
close(fd);
}
diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h
index fe6eec8f72..0d0ebcaae0 100644
--- a/tools/xenstore/xenstored_core.h
+++ b/tools/xenstore/xenstored_core.h
@@ -56,6 +56,9 @@ struct connection
/* Are we blocked waiting for a transaction to end? Contains node. */
char *blocked;
+ /* Is this a read-only connection? */
+ bool can_write;
+
/* Our current event. If all used, we're waiting for ack. */
struct watch_event *event;
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index bcc0a64967..a6f69ddf5b 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -268,6 +268,9 @@ bool do_introduce(struct connection *conn, struct buffered_data *in)
if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec))
return send_error(conn, EINVAL);
+ if (!conn->can_write)
+ return send_error(conn, EROFS);
+
/* Hang domain off "in" until we're finished. */
domain = talloc(in, struct domain);
domain->domid = atoi(vec[0]);
diff --git a/tools/xenstore/xenstored_test.h b/tools/xenstore/xenstored_test.h
index f173a5ca91..cf607cf2e0 100644
--- a/tools/xenstore/xenstored_test.h
+++ b/tools/xenstore/xenstored_test.h
@@ -21,7 +21,7 @@
#ifdef TESTING
bool test_write_all(int fd, void *contents, unsigned int len);
-#define write_all test_write_all
+#define xs_write_all test_write_all
int test_mkdir(const char *dir, int perms);
#define mkdir test_mkdir
diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
index d5058abfb3..d6e41380f9 100644
--- a/tools/xenstore/xs.c
+++ b/tools/xenstore/xs.c
@@ -118,7 +118,7 @@ static bool read_all(int fd, void *data, unsigned int len)
#ifdef XSTEST
#define read_all read_all_choice
-#define write_all write_all_choice
+#define xs_write_all write_all_choice
#endif
static int get_error(const char *errorstring)
@@ -179,11 +179,11 @@ static void *xs_talkv(struct xs_handle *h, enum xsd_sockmsg_type type,
ignorepipe.sa_flags = 0;
sigaction(SIGPIPE, &ignorepipe, &oldact);
- if (!write_all(h->fd, &msg, sizeof(msg)))
+ if (!xs_write_all(h->fd, &msg, sizeof(msg)))
goto fail;
for (i = 0; i < num_vecs; i++)
- if (!write_all(h->fd, iovec[i].iov_base, iovec[i].iov_len))
+ if (!xs_write_all(h->fd, iovec[i].iov_base, iovec[i].iov_len))
goto fail;
/* Watches can have fired before reply comes: daemon detects
@@ -253,7 +253,7 @@ char **xs_directory(struct xs_handle *h, const char *path, unsigned int *num)
return NULL;
/* Count the strings. */
- *num = count_strings(strings, len);
+ *num = xs_count_strings(strings, len);
/* Transfer to one big alloc for easy freeing. */
ret = malloc(*num * sizeof(char *) + len);
@@ -342,7 +342,7 @@ struct xs_permissions *xs_get_permissions(struct xs_handle *h,
return NULL;
/* Count the strings: each one perms then domid. */
- *num = count_strings(strings, len);
+ *num = xs_count_strings(strings, len);
/* Transfer to one big alloc for easy freeing. */
ret = malloc(*num * sizeof(struct xs_permissions));
@@ -351,7 +351,7 @@ struct xs_permissions *xs_get_permissions(struct xs_handle *h,
return NULL;
}
- if (!strings_to_perms(ret, *num, strings)) {
+ if (!xs_strings_to_perms(ret, *num, strings)) {
free_no_errno(ret);
ret = NULL;
}
@@ -376,7 +376,7 @@ bool xs_set_permissions(struct xs_handle *h, const char *path,
for (i = 0; i < num_perms; i++) {
char buffer[MAX_STRLEN(domid_t)+1];
- if (!perm_to_string(&perms[i], buffer))
+ if (!xs_perm_to_string(&perms[i], buffer))
goto unwind;
iov[i+1].iov_base = strdup(buffer);
diff --git a/tools/xenstore/xs_lib.c b/tools/xenstore/xs_lib.c
index 8630eaffce..3f4f4b0899 100644
--- a/tools/xenstore/xs_lib.c
+++ b/tools/xenstore/xs_lib.c
@@ -48,7 +48,7 @@ const char *xs_daemon_transactions(void)
}
/* Simple routines for writing to sockets, etc. */
-bool write_all(int fd, const void *data, unsigned int len)
+bool xs_write_all(int fd, const void *data, unsigned int len)
{
while (len) {
int done;
@@ -66,7 +66,7 @@ bool write_all(int fd, const void *data, unsigned int len)
}
/* Convert strings to permissions. False if a problem. */
-bool strings_to_perms(struct xs_permissions *perms, unsigned int num,
+bool xs_strings_to_perms(struct xs_permissions *perms, unsigned int num,
const char *strings)
{
const char *p;
@@ -104,7 +104,7 @@ bool strings_to_perms(struct xs_permissions *perms, unsigned int num,
}
/* Convert permissions to a string (up to len MAX_STRLEN(domid_t)+1). */
-bool perm_to_string(const struct xs_permissions *perm, char *buffer)
+bool xs_perm_to_string(const struct xs_permissions *perm, char *buffer)
{
switch (perm->perms) {
case XS_PERM_WRITE:
@@ -128,7 +128,7 @@ bool perm_to_string(const struct xs_permissions *perm, char *buffer)
}
/* Given a string and a length, count how many strings (nul terms). */
-unsigned int count_strings(const char *strings, unsigned int len)
+unsigned int xs_count_strings(const char *strings, unsigned int len)
{
unsigned int num;
const char *p;
diff --git a/tools/xenstore/xs_lib.h b/tools/xenstore/xs_lib.h
index a946ab0b19..76ea9b67fe 100644
--- a/tools/xenstore/xs_lib.h
+++ b/tools/xenstore/xs_lib.h
@@ -48,16 +48,16 @@ const char *xs_daemon_store(void);
const char *xs_daemon_transactions(void);
/* Simple write function: loops for you. */
-bool write_all(int fd, const void *data, unsigned int len);
+bool xs_write_all(int fd, const void *data, unsigned int len);
/* Convert strings to permissions. False if a problem. */
-bool strings_to_perms(struct xs_permissions *perms, unsigned int num,
+bool xs_strings_to_perms(struct xs_permissions *perms, unsigned int num,
const char *strings);
/* Convert permissions to a string (up to len MAX_STRLEN(domid_t)+1). */
-bool perm_to_string(const struct xs_permissions *perm, char *buffer);
+bool xs_perm_to_string(const struct xs_permissions *perm, char *buffer);
/* Given a string and a length, count how many strings (nul terms). */
-unsigned int count_strings(const char *strings, unsigned int len);
+unsigned int xs_count_strings(const char *strings, unsigned int len);
#endif /* _XS_LIB_H */
diff --git a/tools/xenstore/xs_random.c b/tools/xenstore/xs_random.c
index ef5d44d0b0..675cc89093 100644
--- a/tools/xenstore/xs_random.c
+++ b/tools/xenstore/xs_random.c
@@ -223,10 +223,10 @@ static struct xs_permissions *file_get_perms(struct file_ops_info *info,
release_file(perms, size);
return ret;
}
- *num = count_strings(perms, size);
+ *num = xs_count_strings(perms, size);
ret = new_array(struct xs_permissions, *num);
- if (!strings_to_perms(ret, *num, perms))
+ if (!xs_strings_to_perms(ret, *num, perms))
barf("Reading permissions from %s", permfile);
release_file(perms, size);
return ret;
@@ -267,7 +267,7 @@ static bool file_set_perms(struct file_ops_info *info,
for (i = 0; i < num; i++) {
char buffer[100];
- if (!perm_to_string(&perms[i], buffer)) {
+ if (!xs_perm_to_string(&perms[i], buffer)) {
int saved_errno = errno;
close(fd);
errno = saved_errno;
@@ -536,7 +536,7 @@ static char *dump_dir(struct ops *ops,
ret = talloc_asprintf_append(ret, "%s%s: ", spacing, dir[i]);
for (j = 0; j < numperms; j++) {
char buffer[100];
- if (!perm_to_string(&perms[j], buffer))
+ if (!xs_perm_to_string(&perms[j], buffer))
barf("perm to string");
ret = talloc_asprintf_append(ret, "%s ", buffer);
}
diff --git a/tools/xenstore/xs_test.c b/tools/xenstore/xs_test.c
index f1e66cbe28..4d769e220d 100644
--- a/tools/xenstore/xs_test.c
+++ b/tools/xenstore/xs_test.c
@@ -153,7 +153,7 @@ static bool write_all_choice(int fd, const void *data, unsigned int len)
{
if (fd == -2)
return write_all_shmem(fd, data, len);
- return write_all(fd, data, len);
+ return xs_write_all(fd, data, len);
}
/* We want access to internal functions. */
@@ -176,11 +176,11 @@ static void __attribute__((noreturn)) usage(void)
" watch <path> <prio>\n"
" waitwatch\n"
" ackwatch\n"
- " unwatch <path>\n"
+ " unwatch <path> <token>\n"
" close\n"
" start <node>\n"
" abort\n"
- " introduce <domid> <mfn> <eventchn>\n"
+ " introduce <domid> <mfn> <eventchn> <path>\n"
" commit\n"
" sleep <seconds>\n"
" dump\n");
@@ -491,7 +491,7 @@ static void dump_dir(unsigned int handle,
printf("%s%s: ", spacing, dir[i]);
for (j = 0; j < numperms; j++) {
char buffer[100];
- if (!perm_to_string(&perms[j], buffer))
+ if (!xs_perm_to_string(&perms[j], buffer))
barf("perm to string");
printf("%s ", buffer);
}