# HG changeset patch
# User awilliam@xxxxxxxxxxx
# Node ID 918ea03857b9bc5e1878507539f721b859d29996
# Parent ba7fca36fbd066129afc17ecfbd514be868ebc38
# Parent 7df4d8cfba3b2fbd12ac1f287ab854ff4b242721
merge with xen-unstable.hg
---
buildconfigs/linux-defconfig_xen_ia64 | 2
buildconfigs/linux-defconfig_xen_x86_32 | 2
buildconfigs/linux-defconfig_xen_x86_64 | 2
tools/examples/init.d/xend | 5
tools/ioemu/hw/ide.c | 31 ++++-
tools/ioemu/keymaps.c | 63 ++++++++++-
tools/ioemu/vnc.c | 32 +++++
tools/ioemu/vnc_keysym.h | 14 ++
tools/libxen/src/xen_common.c | 20 +++
tools/libxen/src/xen_vm.c | 24 ++--
tools/misc/xend | 4
tools/python/xen/xend/XendDomainInfo.py | 6 -
tools/python/xen/xend/server/SrvDaemon.py | 8 +
tools/python/xen/xend/server/SrvServer.py | 134 ++++++++++++++----------
tools/python/xen/xend/server/XMLRPCServer.py | 40 ++++---
tools/xm-test/lib/XmTestLib/XenManagedDomain.py | 5
xen/arch/x86/mm/shadow/common.c | 13 +-
17 files changed, 309 insertions(+), 96 deletions(-)
diff -r ba7fca36fbd0 -r 918ea03857b9 buildconfigs/linux-defconfig_xen_ia64
--- a/buildconfigs/linux-defconfig_xen_ia64 Tue Dec 05 09:44:24 2006 -0700
+++ b/buildconfigs/linux-defconfig_xen_ia64 Tue Dec 05 10:01:15 2006 -0700
@@ -1548,6 +1548,8 @@ CONFIG_XEN_PCIDEV_BACKEND_SLOT=y
# CONFIG_XEN_TPMDEV_BACKEND is not set
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
+CONFIG_XEN_FRAMEBUFFER=y
+CONFIG_XEN_KEYBOARD=y
# CONFIG_XEN_SCRUB_PAGES is not set
CONFIG_XEN_DISABLE_SERIAL=y
CONFIG_XEN_SYSFS=y
diff -r ba7fca36fbd0 -r 918ea03857b9 buildconfigs/linux-defconfig_xen_x86_32
--- a/buildconfigs/linux-defconfig_xen_x86_32 Tue Dec 05 09:44:24 2006 -0700
+++ b/buildconfigs/linux-defconfig_xen_x86_32 Tue Dec 05 10:01:15 2006 -0700
@@ -3034,6 +3034,8 @@ CONFIG_XEN_NETDEV_LOOPBACK=y
# CONFIG_XEN_TPMDEV_BACKEND is not set
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
+CONFIG_XEN_FRAMEBUFFER=y
+CONFIG_XEN_KEYBOARD=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DISABLE_SERIAL=y
CONFIG_XEN_SYSFS=y
diff -r ba7fca36fbd0 -r 918ea03857b9 buildconfigs/linux-defconfig_xen_x86_64
--- a/buildconfigs/linux-defconfig_xen_x86_64 Tue Dec 05 09:44:24 2006 -0700
+++ b/buildconfigs/linux-defconfig_xen_x86_64 Tue Dec 05 10:01:15 2006 -0700
@@ -2866,6 +2866,8 @@ CONFIG_XEN_TPMDEV_BACKEND=m
# CONFIG_XEN_TPMDEV_CLOSE_IF_VTPM_FAILS is not set
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
+CONFIG_XEN_FRAMEBUFFER=y
+CONFIG_XEN_KEYBOARD=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DISABLE_SERIAL=y
CONFIG_XEN_SYSFS=y
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/examples/init.d/xend
--- a/tools/examples/init.d/xend Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/examples/init.d/xend Tue Dec 05 10:01:15 2006 -0700
@@ -36,7 +36,10 @@ case "$1" in
status)
xend status
;;
- restart|reload|force-reload)
+ reload)
+ xend reload
+ ;;
+ restart|force-reload)
xend restart
await_daemons_up
;;
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/ioemu/hw/ide.c
--- a/tools/ioemu/hw/ide.c Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/ioemu/hw/ide.c Tue Dec 05 10:01:15 2006 -0700
@@ -680,7 +680,7 @@ static void ide_sector_read(IDEState *s)
static void ide_sector_read(IDEState *s)
{
int64_t sector_num;
- int ret, n;
+ int n;
s->status = READY_STAT | SEEK_STAT;
s->error = 0; /* not needed by IDE spec, but needed by Windows */
@@ -695,7 +695,11 @@ static void ide_sector_read(IDEState *s)
#endif
if (n > s->req_nb_sectors)
n = s->req_nb_sectors;
- ret = bdrv_read(s->bs, sector_num, s->io_buffer, n);
+ if (bdrv_read(s->bs, sector_num, s->io_buffer, n) != 0) {
+ ide_abort_command(s);
+ ide_set_irq(s);
+ return;
+ }
ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_read);
ide_set_irq(s);
ide_set_sector(s, sector_num + n);
@@ -721,7 +725,11 @@ static int ide_read_dma_cb(IDEState *s,
if (n > MAX_MULT_SECTORS)
n = MAX_MULT_SECTORS;
sector_num = ide_get_sector(s);
- bdrv_read(s->bs, sector_num, s->io_buffer, n);
+ if (bdrv_read(s->bs, sector_num, s->io_buffer, n) != 0) {
+ ide_abort_command(s);
+ ide_set_irq(s);
+ return 0;
+ }
s->io_buffer_index = 0;
s->io_buffer_size = n * 512;
len = s->io_buffer_size;
@@ -767,7 +775,7 @@ static void ide_sector_write(IDEState *s
static void ide_sector_write(IDEState *s)
{
int64_t sector_num;
- int ret, n, n1;
+ int n, n1;
s->status = READY_STAT | SEEK_STAT;
sector_num = ide_get_sector(s);
@@ -777,7 +785,11 @@ static void ide_sector_write(IDEState *s
n = s->nsector;
if (n > s->req_nb_sectors)
n = s->req_nb_sectors;
- ret = bdrv_write(s->bs, sector_num, s->io_buffer, n);
+ if (bdrv_write(s->bs, sector_num, s->io_buffer, n) != 0) {
+ ide_abort_command(s);
+ ide_set_irq(s);
+ return;
+ }
s->nsector -= n;
if (s->nsector == 0) {
/* no more sector to write */
@@ -823,8 +835,13 @@ static int ide_write_dma_cb(IDEState *s,
if (len == 0) {
n = s->io_buffer_size >> 9;
sector_num = ide_get_sector(s);
- bdrv_write(s->bs, sector_num, s->io_buffer,
- s->io_buffer_size >> 9);
+ if (bdrv_write(s->bs, sector_num, s->io_buffer,
+ s->io_buffer_size >> 9) != 0) {
+ ide_abort_command(s);
+ ide_set_irq(s);
+ return 0;
+ }
+
sector_num += n;
ide_set_sector(s, sector_num);
s->nsector -= n;
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/ioemu/keymaps.c
--- a/tools/ioemu/keymaps.c Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/ioemu/keymaps.c Tue Dec 05 10:01:15 2006 -0700
@@ -36,8 +36,10 @@ static int get_keysym(const char *name)
#define MAX_EXTRA_COUNT 256
typedef struct {
uint16_t keysym2keycode[MAX_NORMAL_KEYCODE];
+ int keysym2numlock[MAX_NORMAL_KEYCODE];
struct {
int keysym;
+ int numlock;
uint16_t keycode;
} keysym2keycode_extra[MAX_EXTRA_COUNT];
int extra_count;
@@ -50,6 +52,8 @@ static kbd_layout_t *parse_keyboard_layo
char file_name[1024];
char line[1024];
int len;
+ int *keycode2numlock;
+ int i;
snprintf(file_name, sizeof(file_name),
"%s/keymaps/%s", bios_dir, language);
@@ -63,6 +67,15 @@ static kbd_layout_t *parse_keyboard_layo
"Could not read keymap file: '%s'\n", file_name);
return 0;
}
+
+ /* Allocate a temporary map tracking which keycodes change when numlock is
+ set. Keycodes are 16 bit, so 65536 is safe. */
+ keycode2numlock = malloc(65536 * sizeof(int));
+ if (!keycode2numlock) {
+ perror("Could not read keymap file");
+ return 0;
+ }
+
for(;;) {
if (fgets(line, 1024, f) == NULL)
break;
@@ -86,13 +99,19 @@ static kbd_layout_t *parse_keyboard_layo
if (keysym == 0) {
// fprintf(stderr, "Warning: unknown keysym
%s\n", line);
} else {
- const char *rest = end_of_keysym + 1;
- int keycode = strtol(rest, NULL, 0);
+ char *rest = end_of_keysym + 1;
+ int keycode = strtol(rest, &rest, 0);
+ int numlock = (rest != NULL &&
+ strstr(rest, "numlock") != NULL);
+
+ keycode2numlock[keycode] = numlock;
+
/* if(keycode&0x80)
keycode=(keycode<<8)^0x80e0; */
if (keysym < MAX_NORMAL_KEYCODE) {
//fprintf(stderr,"Setting keysym %s (%d) to
%d\n",line,keysym,keycode);
k->keysym2keycode[keysym] = keycode;
+ k->keysym2numlock[keysym] = numlock;
} else {
if (k->extra_count >= MAX_EXTRA_COUNT) {
fprintf(stderr,
@@ -107,6 +126,8 @@ static kbd_layout_t *parse_keyboard_layo
keysym = keysym;
k->keysym2keycode_extra[k->extra_count].
keycode = keycode;
+ k->keysym2keycode_extra[k->extra_count].
+ numlock = numlock;
k->extra_count++;
}
}
@@ -115,6 +136,22 @@ static kbd_layout_t *parse_keyboard_layo
}
}
fclose(f);
+
+ for (i = 0; i < MAX_NORMAL_KEYCODE; i++) {
+ if (k->keysym2numlock[i] != 1) {
+ k->keysym2numlock[i] = -keycode2numlock[k->keysym2keycode[i]];
+ }
+ }
+
+ for (i = 0; i < k->extra_count; i++) {
+ if (k->keysym2keycode_extra[i].numlock != 1) {
+ k->keysym2keycode_extra[i].numlock =
+ -keycode2numlock[k->keysym2keycode_extra[i].keycode];
+ }
+ }
+
+ free(keycode2numlock);
+
return k;
}
@@ -143,3 +180,25 @@ static int keysym2scancode(void *kbd_lay
}
return 0;
}
+
+/**
+ * Returns 1 if the given keysym requires numlock to be pressed, -1 if it
+ * requires it to be cleared, and 0 otherwise.
+ */
+static int keysym2numlock(void *kbd_layout, int keysym)
+{
+ kbd_layout_t *k = kbd_layout;
+ if (keysym < MAX_NORMAL_KEYCODE) {
+ return k->keysym2numlock[keysym];
+ } else {
+ int i;
+#ifdef XK_ISO_Left_Tab
+ if (keysym == XK_ISO_Left_Tab)
+ keysym = XK_Tab;
+#endif
+ for (i = 0; i < k->extra_count; i++)
+ if (k->keysym2keycode_extra[i].keysym == keysym)
+ return k->keysym2keycode_extra[i].numlock;
+ }
+ return 0;
+}
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/ioemu/vnc.c
--- a/tools/ioemu/vnc.c Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/ioemu/vnc.c Tue Dec 05 10:01:15 2006 -0700
@@ -115,6 +115,7 @@ struct VncState
int ctl_keys; /* Ctrl+Alt starts calibration */
int shift_keys; /* Shift / CapsLock keys */
+ int numlock;
};
#define DIRTY_PIXEL_BITS 64
@@ -854,14 +855,40 @@ static void pointer_event(VncState *vs,
}
}
+static void press_key(VncState *vs, int keycode)
+{
+ kbd_put_keycode(keysym2scancode(vs->kbd_layout, keycode) & 0x7f);
+ kbd_put_keycode(keysym2scancode(vs->kbd_layout, keycode) | 0x80);
+}
+
static void do_key_event(VncState *vs, int down, uint32_t sym)
{
sym &= 0xFFFF;
if (is_graphic_console()) {
int keycode;
+ int numlock;
keycode = keysym2scancode(vs->kbd_layout, sym);
+ numlock = keysym2numlock(vs->kbd_layout, sym);
+
+ /* If the numlock state needs to change then simulate an additional
+ keypress before sending this one. This will happen if the user
+ toggles numlock away from the VNC window.
+ */
+ if (numlock == 1) {
+ if (!vs->numlock) {
+ vs->numlock = 1;
+ press_key(vs, XK_Num_Lock);
+ }
+ }
+ else if (numlock == -1) {
+ if (vs->numlock) {
+ vs->numlock = 0;
+ press_key(vs, XK_Num_Lock);
+ }
+ }
+
if (keycode & 0x80)
kbd_put_keycode(0xe0);
if (down)
@@ -930,6 +957,10 @@ static void do_key_event(VncState *vs, i
case XK_Caps_Lock:
vs->shift_keys ^= 2;
+ break;
+
+ case XK_Num_Lock:
+ vs->numlock = !vs->numlock;
break;
case XK_1 ... XK_9:
@@ -1355,6 +1386,7 @@ int vnc_display_init(DisplayState *ds, i
vs->lsock = -1;
vs->csock = -1;
vs->depth = 4;
+ vs->numlock = 0;
vs->ds = ds;
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/ioemu/vnc_keysym.h
--- a/tools/ioemu/vnc_keysym.h Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/ioemu/vnc_keysym.h Tue Dec 05 10:01:15 2006 -0700
@@ -231,6 +231,19 @@ static name2keysym_t name2keysym[]={
{"Home", 0xff50}, /* XK_Home */
{"End", 0xff57}, /* XK_End */
{"Scroll_Lock", 0xff14}, /* XK_Scroll_Lock */
+{"KP_Home", 0xff95},
+{"KP_Left", 0xff96},
+{"KP_Up", 0xff97},
+{"KP_Right", 0xff98},
+{"KP_Down", 0xff99},
+{"KP_Prior", 0xff9a},
+{"KP_Page_Up", 0xff9a},
+{"KP_Next", 0xff9b},
+{"KP_Page_Down", 0xff9b},
+{"KP_End", 0xff9c},
+{"KP_Begin", 0xff9d},
+{"KP_Insert", 0xff9e},
+{"KP_Delete", 0xff9f},
{"F1", 0xffbe}, /* XK_F1 */
{"F2", 0xffbf}, /* XK_F2 */
{"F3", 0xffc0}, /* XK_F3 */
@@ -258,6 +271,7 @@ static name2keysym_t name2keysym[]={
{"KP_8", 0xffb8}, /* XK_KP_8 */
{"KP_9", 0xffb9}, /* XK_KP_9 */
{"KP_Add", 0xffab}, /* XK_KP_Add */
+{"KP_Separator", 0xffac},/* XK_KP_Separator */
{"KP_Decimal", 0xffae}, /* XK_KP_Decimal */
{"KP_Divide", 0xffaf}, /* XK_KP_Divide */
{"KP_Enter", 0xff8d}, /* XK_KP_Enter */
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/libxen/src/xen_common.c
--- a/tools/libxen/src/xen_common.c Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/libxen/src/xen_common.c Tue Dec 05 10:01:15 2006 -0700
@@ -518,8 +518,14 @@ static void parse_into(xen_session *s, x
xmlChar *string = string_from_value(value_node, "string");
if (string == NULL)
{
+#if PERMISSIVE
+ fprintf(stderr,
+ "Expected an Enum from the server, but didn't get one\n");
+ ((int *)value)[slot] = 0;
+#else
server_error(
s, "Expected an Enum from the server, but didn't get one");
+#endif
}
else
{
@@ -567,8 +573,14 @@ static void parse_into(xen_session *s, x
xmlChar *string = string_from_value(value_node, "boolean");
if (string == NULL)
{
+#if PERMISSIVE
+ fprintf(stderr,
+ "Expected a Bool from the server, but didn't get one\n");
+ ((bool *)value)[slot] = false;
+#else
server_error(
s, "Expected a Bool from the server, but didn't get one");
+#endif
}
else
{
@@ -764,7 +776,6 @@ static void parse_into(xen_session *s, x
cur = cur->next;
}
-#if !PERMISSIVE
/* Check that we've filled all fields. */
for (size_t i = 0; i < member_count; i++)
{
@@ -781,15 +792,20 @@ static void parse_into(xen_session *s, x
if (j == seen_count)
{
+#if PERMISSIVE
+ fprintf(stderr,
+ "Struct did not contain expected field %s.\n",
+ mem->key);
+#else
server_error_2(s,
"Struct did not contain expected field",
mem->key);
free(result);
free(checklist);
return;
+#endif
}
}
-#endif
free(checklist);
((void **)value)[slot] = result;
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/libxen/src/xen_vm.c
--- a/tools/libxen/src/xen_vm.c Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/libxen/src/xen_vm.c Tue Dec 05 10:01:15 2006 -0700
@@ -85,28 +85,28 @@ static const struct_member xen_vm_record
{ .key = "memory_static_min",
.type = &abstract_type_int,
.offset = offsetof(xen_vm_record, memory_static_min) },
- { .key = "vcpus_policy",
+ { .key = "VCPUs_policy",
.type = &abstract_type_string,
.offset = offsetof(xen_vm_record, vcpus_policy) },
- { .key = "vcpus_params",
+ { .key = "VCPUs_params",
.type = &abstract_type_string,
.offset = offsetof(xen_vm_record, vcpus_params) },
- { .key = "vcpus_number",
+ { .key = "VCPUs_number",
.type = &abstract_type_int,
.offset = offsetof(xen_vm_record, vcpus_number) },
- { .key = "vcpus_utilisation",
+ { .key = "VCPUs_utilisation",
.type = &abstract_type_int_float_map,
.offset = offsetof(xen_vm_record, vcpus_utilisation) },
- { .key = "vcpus_features_required",
+ { .key = "VCPUs_features_required",
.type = &xen_cpu_feature_set_abstract_type_,
.offset = offsetof(xen_vm_record, vcpus_features_required) },
- { .key = "vcpus_features_can_use",
+ { .key = "VCPUs_features_can_use",
.type = &xen_cpu_feature_set_abstract_type_,
.offset = offsetof(xen_vm_record, vcpus_features_can_use) },
- { .key = "vcpus_features_force_on",
+ { .key = "VCPUs_features_force_on",
.type = &xen_cpu_feature_set_abstract_type_,
.offset = offsetof(xen_vm_record, vcpus_features_force_on) },
- { .key = "vcpus_features_force_off",
+ { .key = "VCPUs_features_force_off",
.type = &xen_cpu_feature_set_abstract_type_,
.offset = offsetof(xen_vm_record, vcpus_features_force_off) },
{ .key = "actions_after_shutdown",
@@ -1124,7 +1124,7 @@ xen_vm_set_vcpus_policy(xen_session *ses
.u.string_val = policy }
};
- xen_call_(session, "VM.set_vcpus_policy", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.set_VCPUs_policy", param_values, 2, NULL, NULL);
return session->ok;
}
@@ -1140,7 +1140,7 @@ xen_vm_set_vcpus_params(xen_session *ses
.u.string_val = params }
};
- xen_call_(session, "VM.set_vcpus_params", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.set_VCPUs_params", param_values, 2, NULL, NULL);
return session->ok;
}
@@ -1156,7 +1156,7 @@ xen_vm_set_vcpus_features_force_on(xen_s
.u.set_val = (arbitrary_set *)force_on }
};
- xen_call_(session, "VM.set_vcpus_features_force_on", param_values, 2,
NULL, NULL);
+ xen_call_(session, "VM.set_VCPUs_features_force_on", param_values, 2,
NULL, NULL);
return session->ok;
}
@@ -1172,7 +1172,7 @@ xen_vm_set_vcpus_features_force_off(xen_
.u.set_val = (arbitrary_set *)force_off }
};
- xen_call_(session, "VM.set_vcpus_features_force_off", param_values, 2,
NULL, NULL);
+ xen_call_(session, "VM.set_VCPUs_features_force_off", param_values, 2,
NULL, NULL);
return session->ok;
}
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/misc/xend
--- a/tools/misc/xend Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/misc/xend Tue Dec 05 10:01:15 2006 -0700
@@ -109,7 +109,7 @@ def main():
daemon = SrvDaemon.instance()
if not sys.argv[1:]:
- print 'usage: %s {start|stop|restart}' % sys.argv[0]
+ print 'usage: %s {start|stop|reload|restart}' % sys.argv[0]
elif sys.argv[1] == 'start':
if os.uname()[0] != "SunOS":
start_xenstored()
@@ -123,6 +123,8 @@ def main():
return daemon.start(trace=1)
elif sys.argv[1] == 'stop':
return daemon.stop()
+ elif sys.argv[1] == 'reload':
+ return daemon.reloadConfig()
elif sys.argv[1] == 'restart':
start_xenstored()
start_consoled()
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/python/xen/xend/XendDomainInfo.py Tue Dec 05 10:01:15 2006 -0700
@@ -1709,8 +1709,10 @@ class XendDomainInfo:
dom = XendDomain.instance().domain_lookup_nr(name)
if dom and dom.info['uuid'] != self.info['uuid']:
- raise VmError("VM name '%s' already exists as domain %s" %
- (name, str(dom.domid)))
+ raise VmError("VM name '%s' already exists%s" %
+ (name,
+ dom.domid is not None and
+ ("as domain %s" % str(dom.domid)) or ""))
def update(self, info = None, refresh = True):
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/python/xen/xend/server/SrvDaemon.py
--- a/tools/python/xen/xend/server/SrvDaemon.py Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/python/xen/xend/server/SrvDaemon.py Tue Dec 05 10:01:15 2006 -0700
@@ -58,6 +58,14 @@ class Daemon:
if running == 0 and os.path.isfile(XEND_PID_FILE):
os.remove(XEND_PID_FILE)
return running
+
+
+ def reloadConfig(self):
+ """
+ """
+ pid = read_pid(XEND_PID_FILE)
+ if find_process(pid, XEND_PROCESS_NAME):
+ os.kill(pid, signal.SIGHUP)
def status(self):
diff -r ba7fca36fbd0 -r 918ea03857b9 tools/python/xen/xend/server/SrvServer.py
--- a/tools/python/xen/xend/server/SrvServer.py Tue Dec 05 09:44:24 2006 -0700
+++ b/tools/python/xen/xend/server/SrvServer.py Tue Dec 05 10:01:15 2006 -0700
@@ -65,6 +65,7 @@ class XendServers:
def __init__(self):
self.servers = []
self.cleaningUp = False
+ self.reloadingConfig = False
def add(self, server):
self.servers.append(server)
@@ -78,6 +79,11 @@ class XendServers:
except:
pass
+ def reloadConfig(self, signum = 0, frame = None):
+ log.debug("SrvServer.reloadConfig()")
+ self.reloadingConfig = True
+ self.cleanup(signum, frame)
+
def start(self, status):
# Running the network script will spawn another process, which takes
# the status fd with it unless we set FD_CLOEXEC. Failing to do this
@@ -86,61 +92,80 @@ class XendServers:
fcntl.fcntl(status, fcntl.F_SETFD, fcntl.FD_CLOEXEC)
Vifctl.network('start')
- threads = []
- for server in self.servers:
- thread = Thread(target=server.run, name=server.__class__.__name__)
- if isinstance(server, HttpServer):
- thread.setDaemon(True)
- thread.start()
- threads.append(thread)
-
-
- # check for when all threads have initialized themselves and then
- # close the status pipe
-
- threads_left = True
- while threads_left:
- threads_left = False
-
- for server in self.servers:
- if not server.ready:
- threads_left = True
- break
-
- if threads_left:
- time.sleep(.5)
-
- if status:
- status.write('0')
- status.close()
# Prepare to catch SIGTERM (received when 'xend stop' is executed)
# and call each server's cleanup if possible
signal.signal(signal.SIGTERM, self.cleanup)
-
- # Interruptible Thread.join - Python Bug #1167930
- # Replaces: for t in threads: t.join()
- # Reason: The above will cause python signal handlers to be
- # blocked so we're not able to catch SIGTERM in any
- # way for cleanup
- runningThreads = threads
- while len(runningThreads) > 0:
- try:
- for t in threads:
- t.join(1.0)
- runningThreads = [t for t in threads
- if t.isAlive() and not t.isDaemon()]
- if self.cleaningUp and len(runningThreads) > 0:
- log.debug("Waiting for %s." %
- [x.getName() for x in runningThreads])
- except:
- pass
-
-
-def create():
- root = SrvDir()
- root.putChild('xend', SrvRoot())
- servers = XendServers()
+ signal.signal(signal.SIGHUP, self.reloadConfig)
+
+ while True:
+ threads = []
+ for server in self.servers:
+ thread = Thread(target=server.run,
name=server.__class__.__name__)
+ if isinstance(server, HttpServer):
+ thread.setDaemon(True)
+ thread.start()
+ threads.append(thread)
+
+
+ # check for when all threads have initialized themselves and then
+ # close the status pipe
+
+ retryCount = 0
+ threads_left = True
+ while threads_left:
+ threads_left = False
+
+ for server in self.servers:
+ if not server.ready:
+ threads_left = True
+ break
+
+ if threads_left:
+ time.sleep(.5)
+ retryCount += 1
+ if retryCount > 60:
+ for server in self.servers:
+ if not server.ready:
+ log.error("Server " +
+ server.__class__.__name__ +
+ " did not initialise!")
+ break
+
+ if status:
+ status.write('0')
+ status.close()
+ status = None
+
+ # Interruptible Thread.join - Python Bug #1167930
+ # Replaces: for t in threads: t.join()
+ # Reason: The above will cause python signal handlers to be
+ # blocked so we're not able to catch SIGTERM in any
+ # way for cleanup
+ runningThreads = threads
+ while len(runningThreads) > 0:
+ try:
+ for t in threads:
+ t.join(1.0)
+ runningThreads = [t for t in threads
+ if t.isAlive() and not t.isDaemon()]
+ if self.cleaningUp and len(runningThreads) > 0:
+ log.debug("Waiting for %s." %
+ [x.getName() for x in runningThreads])
+ except:
+ pass
+
+ if self.reloadingConfig:
+ log.info("Restarting all servers...")
+ self.cleaningUp = False
+ self.reloadingConfig = False
+ xroot.set_config()
+ self.servers = []
+ _loadConfig(self)
+ else:
+ break
+
+def _loadConfig(servers):
if xroot.get_xend_http_server():
servers.add(HttpServer(root,
xroot.get_xend_address(),
@@ -188,4 +213,11 @@ def create():
if xroot.get_xend_unix_xmlrpc_server():
servers.add(XMLRPCServer(XendAPI.AUTH_PAM))
+
+
+def create():
+ root = SrvDir()
+ root.putChild('xend', SrvRoot())
+ servers = XendServers()
+ _loadConfig(servers)
return servers
diff -r ba7fca36fbd0 -r 918ea03857b9
tools/python/xen/xend/server/XMLRPCServer.py
--- a/tools/python/xen/xend/server/XMLRPCServer.py Tue Dec 05 09:44:24
2006 -0700
+++ b/tools/python/xen/xend/server/XMLRPCServer.py Tue Dec 05 10:01:15
2006 -0700
@@ -16,6 +16,8 @@
# Copyright (C) 2006 XenSource Ltd.
#============================================================================
+import errno
+import socket
import types
import xmlrpclib
from xen.util.xmlrpclib2 import UnixXMLRPCServer, TCPXMLRPCServer
@@ -105,20 +107,25 @@ class XMLRPCServer:
"; authentication has been disabled for this server." or
".")
- if self.use_tcp:
- log.info("Opening TCP XML-RPC server on %s%d%s",
- self.host and '%s:' % self.host or
- 'all interfaces, port ',
- self.port, authmsg)
- self.server = TCPXMLRPCServer((self.host, self.port),
- self.hosts_allowed,
- logRequests = False)
- else:
- log.info("Opening Unix domain socket XML-RPC server on %s%s",
- self.path, authmsg)
- self.server = UnixXMLRPCServer(self.path, self.hosts_allowed,
- logRequests = False)
-
+ try:
+ if self.use_tcp:
+ log.info("Opening TCP XML-RPC server on %s%d%s",
+ self.host and '%s:' % self.host or
+ 'all interfaces, port ',
+ self.port, authmsg)
+ self.server = TCPXMLRPCServer((self.host, self.port),
+ self.hosts_allowed,
+ logRequests = False)
+ else:
+ log.info("Opening Unix domain socket XML-RPC server on %s%s",
+ self.path, authmsg)
+ self.server = UnixXMLRPCServer(self.path, self.hosts_allowed,
+ logRequests = False)
+ except socket.error, exn:
+ log.error('Cannot start server: %s!', exn.args[1])
+ ready = True
+ running = False
+ return
# Register Xen API Functions
# -------------------------------------------------------------------
@@ -177,6 +184,11 @@ class XMLRPCServer:
def cleanup(self):
log.debug("XMLRPCServer.cleanup()")
+ try:
+ self.server.socket.close()
+ except Exception, exn:
+ log.exception(exn)
+ pass
def shutdown(self):
self.running = False
diff -r ba7fca36fbd0 -r 918ea03857b9
tools/xm-test/lib/XmTestLib/XenManagedDomain.py
--- a/tools/xm-test/lib/XmTestLib/XenManagedDomain.py Tue Dec 05 09:44:24
2006 -0700
+++ b/tools/xm-test/lib/XmTestLib/XenManagedDomain.py Tue Dec 05 10:01:15
2006 -0700
@@ -94,12 +94,13 @@ class XenManagedDomain(XenDomain):
#Only support PV for now.
self.type = "PV"
- def start(self, noConsole=False):
+ def start(self, noConsole=False, startpaused=False):
#start the VM
server = self.server
if self.vm_uuid:
try:
- xapi.execute(server.VM.start, self.session, self.vm_uuid)
+ xapi.execute(server.VM.start, self.session, self.vm_uuid,
+ startpaused)
except:
raise DomainError("Could not start domain")
else:
diff -r ba7fca36fbd0 -r 918ea03857b9 xen/arch/x86/mm/shadow/common.c
--- a/xen/arch/x86/mm/shadow/common.c Tue Dec 05 09:44:24 2006 -0700
+++ b/xen/arch/x86/mm/shadow/common.c Tue Dec 05 10:01:15 2006 -0700
@@ -1246,7 +1246,7 @@ sh_gfn_to_mfn_foreign(struct domain *d,
/* Read another domain's p2m entries */
{
mfn_t mfn;
- unsigned long addr = gpfn << PAGE_SHIFT;
+ paddr_t addr = ((paddr_t)gpfn) << PAGE_SHIFT;
l2_pgentry_t *l2e;
l1_pgentry_t *l1e;
@@ -1274,7 +1274,16 @@ sh_gfn_to_mfn_foreign(struct domain *d,
#if CONFIG_PAGING_LEVELS >= 3
{
l3_pgentry_t *l3e = sh_map_domain_page(mfn);
- l3e += l3_table_offset(addr);
+#if CONFIG_PAGING_LEVELS == 3
+ /* On PAE hosts the p2m has eight l3 entries, not four (see
+ * shadow_set_p2m_entry()) so we can't use l3_table_offset.
+ * Instead, just count the number of l3es from zero. It's safe
+ * to do this because we already checked that the gfn is within
+ * the bounds of the p2m. */
+ l3e += (((addr) & VADDR_MASK) >> L3_PAGETABLE_SHIFT);
+#else
+ l3e += l3_table_offset(addr);
+#endif
if ( (l3e_get_flags(*l3e) & _PAGE_PRESENT) == 0 )
{
sh_unmap_domain_page(l3e);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|