From 622c859b48ea7a1999e348704bb62fbc542684261b4e5e7c648033a62dabe3b1 Mon Sep 17 00:00:00 2001 From: OBS User unknown Date: Sat, 12 Jan 2008 01:32:53 +0000 Subject: [PATCH] OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/xen?expand=0&rev=37 --- 32on64-extra-mem.patch | 2 +- blktap.patch | 4 +- cdrom-removable.patch | 537 ++++-------------- const-callback-arg.patch | 165 ++++++ const-set-trap-table-arg.patch | 49 ++ pv-driver-build.patch | 20 +- qemu-security-etch1.diff | 6 +- svm-lmsl.patch | 18 +- vnc-i18n-keys.diff | 2 +- x86_emulate-eflags.patch | 623 --------------------- x86_emulate.patch | 55 +- xen-3.2-testing-src.tar.bz2 | 4 +- xen-destdir.diff | 7 +- xen-domUloader.diff | 158 +++++- xen-fbback-resize.patch | 144 +++++ xen-hvm-default-bridge.diff | 2 +- xen-warnings.diff | 13 - xen.changes | 5 + xen.spec | 31 +- xenapi-console-protocol.patch | 2 +- xenctx.patch | 163 ++++++ xend-config.diff | 66 ++- xmclone.sh | 995 ++++++++++++++------------------- 23 files changed, 1376 insertions(+), 1695 deletions(-) create mode 100644 const-callback-arg.patch create mode 100644 const-set-trap-table-arg.patch delete mode 100644 x86_emulate-eflags.patch create mode 100644 xen-fbback-resize.patch create mode 100644 xenctx.patch diff --git a/32on64-extra-mem.patch b/32on64-extra-mem.patch index 4c4702a..70cb0da 100644 --- a/32on64-extra-mem.patch +++ b/32on64-extra-mem.patch @@ -2,7 +2,7 @@ Index: xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-3.2-testing.orig/tools/python/xen/xend/XendDomainInfo.py +++ xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1753,7 +1753,7 @@ class XendDomainInfo: +@@ -1758,7 +1758,7 @@ class XendDomainInfo: xc.domain_setmaxmem(self.domid, maxmem) # Make sure there's enough RAM available for the domain diff --git a/blktap.patch b/blktap.patch index aa137d8..78212e7 100644 --- a/blktap.patch +++ b/blktap.patch @@ -5,7 +5,7 @@ Index: xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-3.2-testing.orig/tools/python/xen/xend/XendDomainInfo.py +++ xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -2060,7 +2060,7 @@ class XendDomainInfo: +@@ -2064,7 +2064,7 @@ class XendDomainInfo: (fn, BOOTLOADER_LOOPBACK_DEVICE)) vbd = { @@ -45,7 +45,7 @@ Index: xen-3.2-testing/tools/ioemu/xenstore.c /* read the name of the device */ if (pasprintf(&buf, "%s/dev", bpath) == -1) continue; -@@ -243,6 +251,7 @@ void xenstore_parse_domain_config(int do +@@ -250,6 +258,7 @@ void xenstore_parse_domain_config(int do free(type); free(params); free(dev); diff --git a/cdrom-removable.patch b/cdrom-removable.patch index 683a1aa..06b2af5 100644 --- a/cdrom-removable.patch +++ b/cdrom-removable.patch @@ -1,410 +1,8 @@ -Index: xen-3.1-testing/tools/ioemu/block.c +Index: xen-3.2-testing/tools/python/xen/xend/server/HalDaemon.py =================================================================== ---- xen-3.1-testing.orig/tools/ioemu/block.c 2007-08-13 12:47:26.000000000 -0600 -+++ xen-3.1-testing/tools/ioemu/block.c 2007-08-13 12:48:46.000000000 -0600 -@@ -185,6 +185,13 @@ - uint8_t *buf; - size_t bufsize = 1024; - -+ if ( strcmp(filename, "/dev/cdrom") == 0) { -+ drv = bdrv_find_format("raw"); -+ if (drv != NULL) { -+ return(drv); -+ } -+ } -+ - fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE); - if (fd < 0) { - buf = NULL; -@@ -536,21 +543,11 @@ - return bs->read_only; - } - --int bdrv_is_inserted(BlockDriverState *bs) --{ -- return bs->inserted; --} -- - int bdrv_is_locked(BlockDriverState *bs) - { - return bs->locked; - } - --void bdrv_set_locked(BlockDriverState *bs, int locked) --{ -- bs->locked = locked; --} -- - void bdrv_set_change_cb(BlockDriverState *bs, - void (*change_cb)(void *opaque), void *opaque) - { -@@ -697,8 +694,10 @@ - fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE); - if (fd < 0) { - fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE); -- if (fd < 0) -- return -1; -+ if (fd < 0 && strstart(filename, "/dev/cd", NULL)) -+ fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE | O_NONBLOCK ); -+ if (fd < 0) -+ return -1; - bs->read_only = 1; - } - #ifdef _BSD -@@ -769,8 +768,97 @@ - BDRVRawState *s = bs->opaque; - bs->total_sectors = 0; - close(s->fd); -+ s->fd = -1; -+} -+ -+#include -+#include -+static int raw_is_inserted(BlockDriverState *bs) -+{ -+ BDRVRawState *s = bs->opaque; -+ int ret; -+ -+ switch(bs->removable) { -+ case BDRV_TYPE_CDROM: -+ ret = ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT); -+ if (ret == CDS_DISC_OK) { -+ return 1; -+ } -+ if (ret == -1) { // iso case -+ return 1; -+ } -+ else { -+ return 0; -+ } -+ break; -+ default: -+ return 1; -+ } -+} -+ -+static int raw_media_changed(BlockDriverState *bs) -+{ -+ int ret = 0; -+ -+ switch(bs->removable) { -+ case BDRV_TYPE_CDROM: -+ { -+ if( bs->media_changed == 1 ) -+ { -+ ret = 1; -+ bs->media_changed = 0; -+ } -+ return ret; -+ } -+ default: -+ return -ENOTSUP; -+ } -+} -+ -+ -+static int raw_eject(BlockDriverState *bs, int eject_flag) -+{ -+ char cmd[sizeof(bs->filename) + 32]; -+ -+ switch(bs->removable) { -+ case BDRV_TYPE_CDROM: -+ if (eject_flag) { -+ sprintf(cmd, "eject %s", bs->filename); -+ if (system(cmd) == -1) { -+ perror("CDROMEJECT"); -+ } -+ } else { -+ sprintf(cmd, "eject -t %s", bs->filename); -+ if (system(cmd) == -1) { -+ perror("CDROMCLOSETRAY"); -+ } -+ } -+ break; -+ default: -+ return -ENOTSUP; -+ } -+ return 0; -+} -+ -+static int raw_set_locked(BlockDriverState *bs, int locked) -+{ -+ BDRVRawState *s = bs->opaque; -+ -+ switch(bs->removable) { -+ case BDRV_TYPE_CDROM: -+ if (ioctl (s->fd, CDROM_LOCKDOOR, locked) < 0) { -+ /* Note: an error can happen if the distribution automatically -+ mounts the CD-ROM */ -+ // perror("CDROM_LOCKDOOR"); -+ } -+ break; -+ default: -+ return -ENOTSUP; -+ } -+ return 0; - } - -+ - #ifdef _WIN32 - #include - #include -@@ -850,6 +938,12 @@ - raw_close, - raw_create, - raw_flush, -+ -+ /* removable device support */ -+ .bdrv_is_inserted = raw_is_inserted, -+ .bdrv_media_changed = raw_media_changed, -+ .bdrv_eject = raw_eject, -+ .bdrv_set_locked = raw_set_locked, - }; - - void bdrv_init(void) -@@ -866,3 +960,96 @@ - bdrv_register(&bdrv_vpc); - bdrv_register(&bdrv_vvfat); - } -+ -+/**************************************************************/ -+/* removable device support */ -+ -+/** -+ * Return TRUE if the media is present -+ */ -+int bdrv_is_inserted(BlockDriverState *bs) -+{ -+ BlockDriver *drv = bs->drv; -+ int ret; -+ if (!drv) -+ return 0; -+ if (!drv->bdrv_is_inserted) -+ return 1; -+ ret = drv->bdrv_is_inserted(bs); -+ return ret; -+} -+ -+/** -+ * Return TRUE if the media changed since the last call to this -+ * function. -+ */ -+int bdrv_media_changed(BlockDriverState *bs) -+{ -+ BlockDriver *drv = bs->drv; -+ int ret; -+ -+ if (!drv || !drv->bdrv_media_changed) -+ ret = -ENOTSUP; -+ else -+ ret = drv->bdrv_media_changed(bs); -+ if (ret == -ENOTSUP) -+ ret = bs->media_changed; -+ bs->media_changed = 0; -+ return ret; -+} -+ -+ -+/** -+ * If eject_flag is TRUE, eject the media. Otherwise, close the tray -+ */ -+void bdrv_eject(BlockDriverState *bs, int eject_flag) -+{ -+ -+ int ret = 0; -+ char cmd[sizeof(bs->filename) + 32]; -+ BlockDriver *drv = bs->drv; -+ -+ switch(bs->removable) { -+ case BDRV_TYPE_CDROM: -+ if (eject_flag) { -+ sprintf(cmd, "eject %s", bs->filename); -+ if (system(cmd) == -1) { -+ perror("CDROMEJECT"); -+ ret = -ENOTSUP; -+ } -+ } else { -+ sprintf(cmd, "eject -t %s", bs->filename); -+ if (system(cmd) == -1) { -+ perror("CDROMCLOSETRAY"); -+ ret = -ENOTSUP; -+ } -+ } -+ break; -+ default: -+ if (!drv || !drv->bdrv_eject) { -+ ret = -ENOTSUP; -+ } else { -+ ret = drv->bdrv_eject(bs, eject_flag); -+ } -+ if (ret == -ENOTSUP) { -+ if (eject_flag) -+ bdrv_close(bs); -+ } -+ } -+ //return ret; -+} -+ -+/** -+ * Lock or unlock the media (if it is locked, the user won't be able -+ * to eject it manually). -+ */ -+void bdrv_set_locked(BlockDriverState *bs, int locked) -+{ -+ BlockDriver *drv = bs->drv; -+ -+ bs->locked = locked; -+ if (drv && drv->bdrv_set_locked) { -+ drv->bdrv_set_locked(bs, locked); -+ } -+} -+ -Index: xen-3.1-testing/tools/ioemu/block_int.h -=================================================================== ---- xen-3.1-testing.orig/tools/ioemu/block_int.h 2007-05-17 09:51:09.000000000 -0600 -+++ xen-3.1-testing/tools/ioemu/block_int.h 2007-08-13 12:47:26.000000000 -0600 -@@ -41,6 +41,13 @@ - int nb_sectors, int *pnum); - int (*bdrv_set_key)(BlockDriverState *bs, const char *key); - int (*bdrv_make_empty)(BlockDriverState *bs); -+ -+ /* removable device specific */ -+ int (*bdrv_is_inserted)(BlockDriverState *bs); -+ int (*bdrv_media_changed)(BlockDriverState *bs); -+ int (*bdrv_eject)(BlockDriverState *bs, int eject_flag); -+ int (*bdrv_set_locked)(BlockDriverState *bs, int locked); -+ - struct BlockDriver *next; - }; - -@@ -65,6 +72,7 @@ - char backing_file[1024]; /* if non zero, the image is a diff of - this file image */ - int is_temporary; -+ int media_changed; - - BlockDriverState *backing_hd; - -Index: xen-3.1-testing/tools/ioemu/hw/ide.c -=================================================================== ---- xen-3.1-testing.orig/tools/ioemu/hw/ide.c 2007-05-17 09:51:09.000000000 -0600 -+++ xen-3.1-testing/tools/ioemu/hw/ide.c 2007-08-13 12:47:26.000000000 -0600 -@@ -278,6 +278,7 @@ - #define ASC_ILLEGAL_OPCODE 0x20 - #define ASC_LOGICAL_BLOCK_OOR 0x21 - #define ASC_INV_FIELD_IN_CMD_PACKET 0x24 -+#define ASC_MEDIA_CHANGED 0x28 - #define ASC_MEDIUM_NOT_PRESENT 0x3a - #define ASC_SAVING_PARAMETERS_NOT_SUPPORTED 0x39 - -@@ -393,6 +394,7 @@ - } PCIIDEState; - - #define DMA_MULTI_THREAD -+#undef DMA_MULTI_THREAD - - #ifdef DMA_MULTI_THREAD - -@@ -1341,7 +1343,6 @@ - } else { - ide_atapi_cmd_error(s, SENSE_NOT_READY, - ASC_MEDIUM_NOT_PRESENT); -- xenstore_check_new_media_present(1000); - } - break; - case GPCMD_MODE_SENSE_10: -@@ -1530,7 +1531,10 @@ - - if (eject && !start) { - /* eject the disk */ -- bdrv_close(s->bs); -+ bdrv_eject(s->bs, 1); -+ } else if (eject && start) { -+ /* close the tray */ -+ bdrv_eject(s->bs, 0); - } - ide_atapi_cmd_ok(s); - } -Index: xen-3.1-testing/tools/ioemu/xenstore.c -=================================================================== ---- xen-3.1-testing.orig/tools/ioemu/xenstore.c 2007-05-17 09:51:09.000000000 -0600 -+++ xen-3.1-testing/tools/ioemu/xenstore.c 2007-08-13 12:47:37.000000000 -0600 -@@ -82,7 +82,7 @@ - char **e = NULL; - char *buf = NULL, *path; - char *fpath = NULL, *bpath = NULL, -- *dev = NULL, *params = NULL, *type = NULL; -+ *dev = NULL, *params = NULL, *type = NULL, *media_present = NULL; - int i, is_scsi; - unsigned int len, num, hd_index; - -@@ -170,6 +170,11 @@ - bdrv_set_type_hint(bs_table[hd_index], BDRV_TYPE_CDROM); - if (pasprintf(&buf, "%s/params", bpath) != -1) - xs_watch(xsh, buf, dev); -+ if (pasprintf(&buf, "%s/media-present", bpath) != -1) { -+ free(media_present); -+ media_present = xs_read(xsh, XBT_NULL, buf, &len); -+ xs_watch(xsh, buf, "media_present"); -+ } - } - /* open device now if media present */ - if (params[0]) { -@@ -313,7 +318,7 @@ - - void xenstore_process_event(void *opaque) - { -- char **vec, *image = NULL; -+ char **vec, *image = NULL, *media_present = NULL; - unsigned int len, num, hd_index; - - vec = xs_read_watch(xsh, &num); -@@ -325,6 +330,40 @@ - goto out; - } - -+ if (!strcmp(vec[XS_WATCH_TOKEN], "media_present")) { -+ media_present = xs_read(xsh, XBT_NULL, vec[XS_WATCH_PATH], &len); -+ if (media_present) { -+ BlockDriverState *bs; -+ char *buf = NULL, *cp = NULL, *path = NULL, *dev = NULL; -+ -+ path = strdup(vec[XS_WATCH_PATH]); -+ cp = strstr(path, "media-present"); -+ if (cp){ -+ *(cp-1) = '\0'; -+ pasprintf(&buf, "%s/dev", path); -+ dev = xs_read(xsh, XBT_NULL, buf, &len); -+ if (dev) { -+ bs = bdrv_find(dev); -+ if (!bs) { -+ term_printf("device not found\n"); -+ goto out; -+ } -+ if (strcmp(media_present, "0") == 0 && bs) { -+ bdrv_close(bs); -+ } -+ else if (strcmp(media_present, "1") == 0 && bs != NULL && bs->drv == NULL) { -+ if (bdrv_open(bs, bs->filename, 0 /* snapshot */) < 0) { -+ fprintf(stderr, "qemu: could not open hard disk image '%s'\n", -+ bs->filename); -+ } -+ bs->media_changed = 1; -+ } -+ } -+ } -+ } -+ goto out; -+ } -+ - if (strncmp(vec[XS_WATCH_TOKEN], "hd", 2) || - strlen(vec[XS_WATCH_TOKEN]) != 3) - goto out; -Index: xen-3.1-testing/tools/python/xen/xend/server/HalDaemon.py -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ xen-3.1-testing/tools/python/xen/xend/server/HalDaemon.py 2007-08-13 12:47:26.000000000 -0600 -@@ -0,0 +1,228 @@ +--- /dev/null ++++ xen-3.2-testing/tools/python/xen/xend/server/HalDaemon.py +@@ -0,0 +1,238 @@ +#!/usr/bin/env python +# -*- mode: python; -*- +#============================================================================ @@ -609,8 +207,8 @@ Index: xen-3.1-testing/tools/python/xen/xend/server/HalDaemon.py + vbd_type = value; + if vbd_type is not None and vbd_physical_device is not None and vbd_media is not None : + inode = vbd_physical_device.split(':') -+ imajor = inode[0] -+ iminor = inode[1] ++ imajor = parse_hex(inode[0]) ++ iminor = parse_hex(inode[1]) + log.debug("action:%s major:%s- minor:%s- imajor:%s- iminor:%s- inode: %s", + action,major,minor, imajor, iminor, inode) + if int(imajor) == int(major) and int(iminor) == int(minor): @@ -627,17 +225,27 @@ Index: xen-3.1-testing/tools/python/xen/xend/server/HalDaemon.py + print >>f, "HalDaemon ", fmt % args + f.close() + ++ ++def parse_hex(val): ++ try: ++ if isinstance(val, types.StringTypes): ++ return int(val, 16) ++ else: ++ return val ++ except ValueError: ++ return None ++ +if __name__ == "__main__": + watcher = HalDaemon() + watcher.run() + print 'Falling off end' + + -Index: xen-3.1-testing/tools/python/xen/xend/server/Hald.py +Index: xen-3.2-testing/tools/python/xen/xend/server/Hald.py =================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ xen-3.1-testing/tools/python/xen/xend/server/Hald.py 2007-08-13 12:47:26.000000000 -0600 -@@ -0,0 +1,113 @@ +--- /dev/null ++++ xen-3.2-testing/tools/python/xen/xend/server/Hald.py +@@ -0,0 +1,125 @@ +#============================================================================ +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public @@ -714,6 +322,8 @@ Index: xen-3.1-testing/tools/python/xen/xend/server/Hald.py + pid2 = None + if pid2 == 0: + os.chdir("/") ++ env = os.environ.copy() ++ env['PYTHONPATH'] = self.getpythonpath() + for fd in range(0, 256): + try: + os.close(fd) @@ -722,7 +332,7 @@ Index: xen-3.1-testing/tools/python/xen/xend/server/Hald.py + os.open("/dev/null", os.O_RDWR) + os.dup2(0, 1) + os.dup2(0, 2) -+ os.execvp(prog, args) ++ os.execvpe(prog, args, env) + os._exit(1) + else: + w.write(str(pid2 or 0)) @@ -736,6 +346,16 @@ Index: xen-3.1-testing/tools/python/xen/xend/server/Hald.py + #log.debug( "daemon_pid: %d", daemon_pid ) + return daemon_pid + ++ def getpythonpath(self): ++ str = " " ++ for p in sys.path: ++ if str != " ": ++ str = str + ":" + p ++ else: ++ if str != "": ++ str = p ++ return str ++ + def find(self,path, matchFunc=os.path.isfile): + """Find a module in the sys.path + From web page: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52224 @@ -751,11 +371,11 @@ Index: xen-3.1-testing/tools/python/xen/xend/server/Hald.py + watcher.run() + time.sleep(10) + watcher.shutdown() -Index: xen-3.1-testing/tools/python/xen/xend/server/SrvServer.py +Index: xen-3.2-testing/tools/python/xen/xend/server/SrvServer.py =================================================================== ---- xen-3.1-testing.orig/tools/python/xen/xend/server/SrvServer.py 2007-05-17 09:51:10.000000000 -0600 -+++ xen-3.1-testing/tools/python/xen/xend/server/SrvServer.py 2007-08-13 12:47:26.000000000 -0600 -@@ -57,6 +57,7 @@ +--- xen-3.2-testing.orig/tools/python/xen/xend/server/SrvServer.py ++++ xen-3.2-testing/tools/python/xen/xend/server/SrvServer.py +@@ -56,6 +56,7 @@ from xen.web.SrvDir import SrvDir from SrvRoot import SrvRoot from XMLRPCServer import XMLRPCServer @@ -763,7 +383,7 @@ Index: xen-3.1-testing/tools/python/xen/xend/server/SrvServer.py xoptions = XendOptions.instance() -@@ -248,6 +249,8 @@ +@@ -245,6 +246,8 @@ def _loadConfig(servers, root, reload): if xoptions.get_xend_unix_xmlrpc_server(): servers.add(XMLRPCServer(XendAPI.AUTH_PAM, False)) @@ -772,3 +392,84 @@ Index: xen-3.1-testing/tools/python/xen/xend/server/SrvServer.py def create(): root = SrvDir() +Index: xen-3.2-testing/tools/ioemu/xenstore.c +=================================================================== +--- xen-3.2-testing.orig/tools/ioemu/xenstore.c ++++ xen-3.2-testing/tools/ioemu/xenstore.c +@@ -215,6 +215,13 @@ void xenstore_parse_domain_config(int do + bdrv_set_type_hint(bs_table[hd_index], BDRV_TYPE_CDROM); + if (pasprintf(&buf, "%s/params", bpath) != -1) + xs_watch(xsh, buf, dev); ++ /* if pyhsical put a watch on media-present after creating it */ ++ if (drv && !strcmp(drv, "phy")) { ++ if (pasprintf(&buf, "%s/media-present", bpath) != -1) { ++ xs_write(xsh, XBT_NULL, buf, "1", strlen("1")); ++ xs_watch(xsh, buf, "media-present"); ++ } ++ } + } + /* open device now if media present */ + if (params[0]) { +@@ -416,6 +423,50 @@ void xenstore_record_dm_state(char *stat + free(path); + } + ++void xenstore_process_media_change_event(char **vec) ++{ ++ char *media_present = NULL; ++ unsigned int len; ++ ++ media_present = xs_read(xsh, XBT_NULL, vec[XS_WATCH_PATH], &len); ++ ++ if (media_present) { ++ BlockDriverState *bs; ++ char *buf = NULL, *cp = NULL, *path = NULL, *dev = NULL; ++ ++ path = strdup(vec[XS_WATCH_PATH]); ++ cp = strstr(path, "media-present"); ++ if (cp){ ++ *(cp-1) = '\0'; ++ pasprintf(&buf, "%s/dev", path); ++ dev = xs_read(xsh, XBT_NULL, buf, &len); ++ if (dev) { ++ if ( !strncmp(dev, "xvd", 3)) { ++ memmove(dev, dev+1, strlen(dev)); ++ dev[0] = 'h'; ++ dev[1] = 'd'; ++ } ++ bs = bdrv_find(dev); ++ if (!bs) { ++ term_printf("device not found\n"); ++ return; ++ } ++ if (strcmp(media_present, "0") == 0 && bs) { ++ bdrv_close(bs); ++ } ++ else if (strcmp(media_present, "1") == 0 && ++ bs != NULL && bs->drv == NULL) { ++ if (bdrv_open(bs, bs->filename, 0 /* snapshot */) < 0) { ++ fprintf(logfile, "%s() qemu: could not open cdrom disk '%s'\n", ++ __func__, bs->filename); ++ } ++ bs->media_changed = 1; ++ } ++ } ++ } ++ } ++} ++ + void xenstore_process_event(void *opaque) + { + char **vec, *image = NULL; +@@ -435,6 +486,11 @@ void xenstore_process_event(void *opaque + goto out; + } + ++ if (!strcmp(vec[XS_WATCH_TOKEN], "media-present")) { ++ xenstore_process_media_change_event(vec); ++ goto out; ++ } ++ + if (strncmp(vec[XS_WATCH_TOKEN], "hd", 2) || + strlen(vec[XS_WATCH_TOKEN]) != 3) + goto out; diff --git a/const-callback-arg.patch b/const-callback-arg.patch new file mode 100644 index 0000000..24a3a07 --- /dev/null +++ b/const-callback-arg.patch @@ -0,0 +1,165 @@ +Index: 2008-01-07/xen/arch/ia64/xen/hypercall.c +=================================================================== +--- 2008-01-07.orig/xen/arch/ia64/xen/hypercall.c 2007-12-05 17:13:57.000000000 +0100 ++++ 2008-01-07/xen/arch/ia64/xen/hypercall.c 2008-01-07 12:11:43.000000000 +0100 +@@ -34,9 +34,6 @@ + #include + #include + +-extern long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg); +-extern long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg); +- + static IA64FAULT + xen_hypercall (struct pt_regs *regs) + { +@@ -457,7 +454,7 @@ static long unregister_guest_callback(st + /* First time to add callback to xen/ia64, so let's just stick to + * the newer callback interface. + */ +-long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg) ++long do_callback_op(int cmd, XEN_GUEST_HANDLE(cvoid) arg) + { + long ret; + +Index: 2008-01-07/xen/arch/x86/x86_32/traps.c +=================================================================== +--- 2008-01-07.orig/xen/arch/x86/x86_32/traps.c 2007-11-26 16:57:03.000000000 +0100 ++++ 2008-01-07/xen/arch/x86/x86_32/traps.c 2008-01-07 12:11:43.000000000 +0100 +@@ -419,7 +419,7 @@ static long unregister_guest_callback(st + } + + +-long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg) ++long do_callback_op(int cmd, XEN_GUEST_HANDLE(cvoid) arg) + { + long ret; + +Index: 2008-01-07/xen/arch/x86/x86_64/traps.c +=================================================================== +--- 2008-01-07.orig/xen/arch/x86/x86_64/traps.c 2007-11-02 17:25:58.000000000 +0100 ++++ 2008-01-07/xen/arch/x86/x86_64/traps.c 2008-01-07 12:11:43.000000000 +0100 +@@ -470,7 +470,7 @@ static long unregister_guest_callback(st + } + + +-long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg) ++long do_callback_op(int cmd, XEN_GUEST_HANDLE(cvoid) arg) + { + long ret; + +Index: 2008-01-07/xen/include/asm-x86/guest_access.h +=================================================================== +--- 2008-01-07.orig/xen/include/asm-x86/guest_access.h 2007-12-07 11:51:50.000000000 +0100 ++++ 2008-01-07/xen/include/asm-x86/guest_access.h 2008-01-07 12:11:43.000000000 +0100 +@@ -34,7 +34,8 @@ + */ + #define copy_to_guest_offset(hnd, off, ptr, nr) ({ \ + const typeof(*(ptr)) *_s = (ptr); \ +- char (*_d)[sizeof(*_s)] = (void *)(hnd).p; \ ++ void *_p = (hnd).p; \ ++ char (*_d)[sizeof(*_s)] = _p; \ + ((void)((hnd).p == (ptr))); \ + is_hvm_vcpu(current) ? \ + copy_to_user_hvm(_d+(off), _s, sizeof(*_s)*(nr)) : \ +@@ -82,7 +83,8 @@ + + #define __copy_to_guest_offset(hnd, off, ptr, nr) ({ \ + const typeof(*(ptr)) *_s = (ptr); \ +- char (*_d)[sizeof(*_s)] = (void *)(hnd).p; \ ++ void *_p = (hnd).p; \ ++ char (*_d)[sizeof(*_s)] = _p; \ + ((void)((hnd).p == (ptr))); \ + is_hvm_vcpu(current) ? \ + copy_to_user_hvm(_d+(off), _s, sizeof(*_s)*(nr)) : \ +Index: 2008-01-07/xen/include/public/arch-ia64.h +=================================================================== +--- 2008-01-07.orig/xen/include/public/arch-ia64.h 2008-01-07 12:02:52.000000000 +0100 ++++ 2008-01-07/xen/include/public/arch-ia64.h 2008-01-07 12:11:43.000000000 +0100 +@@ -47,18 +47,7 @@ + #endif + + #ifndef __ASSEMBLY__ +-/* Guest handles for primitive C types. */ +-__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char); +-__DEFINE_XEN_GUEST_HANDLE(uint, unsigned int); +-__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long); +-__DEFINE_XEN_GUEST_HANDLE(u64, unsigned long); +-DEFINE_XEN_GUEST_HANDLE(char); +-DEFINE_XEN_GUEST_HANDLE(int); +-DEFINE_XEN_GUEST_HANDLE(long); +-DEFINE_XEN_GUEST_HANDLE(void); +- + typedef unsigned long xen_pfn_t; +-DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); + #define PRI_xen_pfn "lx" + #endif + +Index: 2008-01-07/xen/include/public/arch-powerpc.h +=================================================================== +--- 2008-01-07.orig/xen/include/public/arch-powerpc.h 2008-01-07 12:02:52.000000000 +0100 ++++ 2008-01-07/xen/include/public/arch-powerpc.h 2008-01-07 12:11:43.000000000 +0100 +@@ -47,17 +47,7 @@ + #endif + + #ifndef __ASSEMBLY__ +-/* Guest handles for primitive C types. */ +-__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char); +-__DEFINE_XEN_GUEST_HANDLE(uint, unsigned int); +-__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long); +-DEFINE_XEN_GUEST_HANDLE(char); +-DEFINE_XEN_GUEST_HANDLE(int); +-DEFINE_XEN_GUEST_HANDLE(long); +-DEFINE_XEN_GUEST_HANDLE(void); +- + typedef unsigned long long xen_pfn_t; +-DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); + #define PRI_xen_pfn "llx" + #endif + +Index: 2008-01-07/xen/include/public/arch-x86/xen.h +=================================================================== +--- 2008-01-07.orig/xen/include/public/arch-x86/xen.h 2008-01-07 12:02:52.000000000 +0100 ++++ 2008-01-07/xen/include/public/arch-x86/xen.h 2008-01-07 12:11:43.000000000 +0100 +@@ -53,17 +53,7 @@ + #endif + + #ifndef __ASSEMBLY__ +-/* Guest handles for primitive C types. */ +-__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char); +-__DEFINE_XEN_GUEST_HANDLE(uint, unsigned int); +-__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long); +-DEFINE_XEN_GUEST_HANDLE(char); +-DEFINE_XEN_GUEST_HANDLE(int); +-DEFINE_XEN_GUEST_HANDLE(long); +-DEFINE_XEN_GUEST_HANDLE(void); +- + typedef unsigned long xen_pfn_t; +-DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); + #define PRI_xen_pfn "lx" + #endif + +Index: 2008-01-07/xen/include/public/xen.h +=================================================================== +--- 2008-01-07.orig/xen/include/public/xen.h 2008-01-07 12:02:52.000000000 +0100 ++++ 2008-01-07/xen/include/public/xen.h 2008-01-07 12:11:43.000000000 +0100 +@@ -39,6 +39,20 @@ + #error "Unsupported architecture" + #endif + ++#ifndef __ASSEMBLY__ ++/* Guest handles for primitive C types. */ ++DEFINE_XEN_GUEST_HANDLE(char); ++__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char); ++DEFINE_XEN_GUEST_HANDLE(int); ++__DEFINE_XEN_GUEST_HANDLE(uint, unsigned int); ++DEFINE_XEN_GUEST_HANDLE(long); ++__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long); ++DEFINE_XEN_GUEST_HANDLE(void); ++__DEFINE_XEN_GUEST_HANDLE(cvoid, const void); ++ ++DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); ++#endif ++ + /* + * HYPERCALLS + */ diff --git a/const-set-trap-table-arg.patch b/const-set-trap-table-arg.patch new file mode 100644 index 0000000..7c18247 --- /dev/null +++ b/const-set-trap-table-arg.patch @@ -0,0 +1,49 @@ +Index: 2008-01-07/xen/arch/x86/traps.c +=================================================================== +--- 2008-01-07.orig/xen/arch/x86/traps.c 2008-01-07 12:02:51.000000000 +0100 ++++ 2008-01-07/xen/arch/x86/traps.c 2008-01-07 12:11:52.000000000 +0100 +@@ -49,6 +49,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -2812,7 +2813,7 @@ long unregister_guest_nmi_callback(void) + return 0; + } + +-long do_set_trap_table(XEN_GUEST_HANDLE(trap_info_t) traps) ++long do_set_trap_table(XEN_GUEST_HANDLE(const_trap_info_t) traps) + { + struct trap_info cur; + struct vcpu *curr = current; +Index: 2008-01-07/xen/include/asm-x86/hypercall.h +=================================================================== +--- 2008-01-07.orig/xen/include/asm-x86/hypercall.h 2007-06-04 08:35:36.000000000 +0200 ++++ 2008-01-07/xen/include/asm-x86/hypercall.h 2008-01-07 12:11:52.000000000 +0100 +@@ -32,9 +32,10 @@ extern long + do_physdev_op_compat( + XEN_GUEST_HANDLE(physdev_op_t) uop); + ++__DEFINE_XEN_GUEST_HANDLE(const_trap_info_t, const trap_info_t); + extern long + do_set_trap_table( +- XEN_GUEST_HANDLE(trap_info_t) traps); ++ XEN_GUEST_HANDLE(const_trap_info_t) traps); + + extern int + do_mmu_update( +Index: 2008-01-07/xen/include/public/arch-x86/xen.h +=================================================================== +--- 2008-01-07.orig/xen/include/public/arch-x86/xen.h 2008-01-07 12:11:43.000000000 +0100 ++++ 2008-01-07/xen/include/public/arch-x86/xen.h 2008-01-07 12:11:52.000000000 +0100 +@@ -98,7 +98,6 @@ struct trap_info { + unsigned long address; /* code offset */ + }; + typedef struct trap_info trap_info_t; +-DEFINE_XEN_GUEST_HANDLE(trap_info_t); + + typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */ + diff --git a/pv-driver-build.patch b/pv-driver-build.patch index 0f0ae02..7c7b4d3 100644 --- a/pv-driver-build.patch +++ b/pv-driver-build.patch @@ -18,7 +18,7 @@ Index: xen-3.2-testing/unmodified_drivers/linux-2.6/mkbuildtree +fi +cd "$(dirname "$0")" + -+if [ -n "$ALT_KMP_OS" -a "$ALT_KMP_OS" == sles10sp1 ]; then ++if [ -n "$ALT_KMP_OS" -a "$ALT_KMP_OS" == other ]; then + XL=$C/linux-2.6-xen-sparse + XEN=$C/linux-2.6-xen-sparse/include/xen fi @@ -28,7 +28,7 @@ Index: xen-3.2-testing/unmodified_drivers/linux-2.6/mkbuildtree + if echo $d | egrep -q netfront; then + ln -sf ${XL}/drivers/xen/netfront/netfront.c netfront + ln -sf ${XL}/drivers/xen/netfront/netfront.h netfront -+ cp -p ../../linux-2.6-xen-sparse/drivers/xen/netfront/accel.c netfront ++ cp -p ../../linux-2.6-xen-sparse/drivers/xen/netfront/accel.c netfront + continue + fi + # END TEMPORARY @@ -44,3 +44,19 @@ Index: xen-3.2-testing/unmodified_drivers/linux-2.6/mkbuildtree # Need to be quite careful here: we don't want the files we link in to # risk overriding the native Linux ones (in particular, system.h must +Index: xen-3.2-testing/unmodified_drivers/linux-2.6/overrides.mk +=================================================================== +--- xen-3.2-testing.orig/unmodified_drivers/linux-2.6/overrides.mk ++++ xen-3.2-testing/unmodified_drivers/linux-2.6/overrides.mk +@@ -4,6 +4,11 @@ + # + # (i.e. we need the native config for things like -mregparm, but + # a Xen kernel to find the right headers) ++ifeq ($(ALT_KMP_OS),other) ++ SPARSEINCLUDE := -I$(M)/../../linux-2.6-xen-sparse/include/xen -I$(M)/../../linux-2.6-xen-sparse/include ++ SPARSEINCLUDE += $(CPPFLAGS) ++ CPPFLAGS = $(SPARSEINCLUDE) ++endif + EXTRA_CFLAGS += -D__XEN_INTERFACE_VERSION__=0x00030205 + EXTRA_CFLAGS += -DCONFIG_XEN_COMPAT=0xffffff + EXTRA_CFLAGS += -I$(M)/include -I$(M)/compat-include -DHAVE_XEN_PLATFORM_COMPAT_H diff --git a/qemu-security-etch1.diff b/qemu-security-etch1.diff index 040b729..f820e2c 100644 --- a/qemu-security-etch1.diff +++ b/qemu-security-etch1.diff @@ -254,7 +254,7 @@ Index: xen-3.2-testing/tools/ioemu/vl.c =================================================================== --- xen-3.2-testing.orig/tools/ioemu/vl.c +++ xen-3.2-testing/tools/ioemu/vl.c -@@ -3584,8 +3584,8 @@ typedef struct NetSocketState { +@@ -3582,8 +3582,8 @@ typedef struct NetSocketState { VLANClientState *vc; int fd; int state; /* 0 = getting length, 1 = getting data */ @@ -265,7 +265,7 @@ Index: xen-3.2-testing/tools/ioemu/vl.c uint8_t buf[4096]; struct sockaddr_in dgram_dst; /* contains inet host and port destination iff connectionless (SOCK_DGRAM) */ } NetSocketState; -@@ -3616,7 +3616,8 @@ static void net_socket_receive_dgram(voi +@@ -3614,7 +3614,8 @@ static void net_socket_receive_dgram(voi static void net_socket_send(void *opaque) { NetSocketState *s = opaque; @@ -275,7 +275,7 @@ Index: xen-3.2-testing/tools/ioemu/vl.c uint8_t buf1[4096]; const uint8_t *buf; -@@ -3655,7 +3656,15 @@ static void net_socket_send(void *opaque +@@ -3653,7 +3654,15 @@ static void net_socket_send(void *opaque l = s->packet_len - s->index; if (l > size) l = size; diff --git a/svm-lmsl.patch b/svm-lmsl.patch index d1a9768..0c1e685 100644 --- a/svm-lmsl.patch +++ b/svm-lmsl.patch @@ -1,7 +1,7 @@ -Index: xen-3.2-testing/xen/arch/x86/hvm/hvm.c +Index: 2008-01-07/xen/arch/x86/hvm/hvm.c =================================================================== ---- xen-3.2-testing.orig/xen/arch/x86/hvm/hvm.c -+++ xen-3.2-testing/xen/arch/x86/hvm/hvm.c +--- 2008-01-07.orig/xen/arch/x86/hvm/hvm.c 2008-01-07 12:02:51.000000000 +0100 ++++ 2008-01-07/xen/arch/x86/hvm/hvm.c 2008-01-07 12:11:59.000000000 +0100 @@ -606,10 +606,11 @@ int hvm_set_efer(uint64_t value) value &= ~EFER_LMA; @@ -15,10 +15,10 @@ Index: xen-3.2-testing/xen/arch/x86/hvm/hvm.c (!cpu_has_ffxsr && (value & EFER_FFXSE)) ) { gdprintk(XENLOG_WARNING, "Trying to set reserved bit in " -Index: xen-3.2-testing/xen/arch/x86/hvm/svm/svm.c +Index: 2008-01-07/xen/arch/x86/hvm/svm/svm.c =================================================================== ---- xen-3.2-testing.orig/xen/arch/x86/hvm/svm/svm.c -+++ xen-3.2-testing/xen/arch/x86/hvm/svm/svm.c +--- 2008-01-07.orig/xen/arch/x86/hvm/svm/svm.c 2008-01-07 12:02:51.000000000 +0100 ++++ 2008-01-07/xen/arch/x86/hvm/svm/svm.c 2008-01-07 12:11:59.000000000 +0100 @@ -53,6 +53,11 @@ u32 svm_feature_flags; @@ -54,10 +54,10 @@ Index: xen-3.2-testing/xen/arch/x86/hvm/svm/svm.c if ( cpu != 0 ) return 1; -Index: xen-3.2-testing/xen/include/asm-x86/hvm/hvm.h +Index: 2008-01-07/xen/include/asm-x86/hvm/hvm.h =================================================================== ---- xen-3.2-testing.orig/xen/include/asm-x86/hvm/hvm.h -+++ xen-3.2-testing/xen/include/asm-x86/hvm/hvm.h +--- 2008-01-07.orig/xen/include/asm-x86/hvm/hvm.h 2008-01-07 12:02:52.000000000 +0100 ++++ 2008-01-07/xen/include/asm-x86/hvm/hvm.h 2008-01-07 12:11:59.000000000 +0100 @@ -127,6 +127,12 @@ struct hvm_function_table { extern struct hvm_function_table hvm_funcs; extern int hvm_enabled; diff --git a/vnc-i18n-keys.diff b/vnc-i18n-keys.diff index 9bd0dfa..88bba68 100644 --- a/vnc-i18n-keys.diff +++ b/vnc-i18n-keys.diff @@ -48,7 +48,7 @@ Index: xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-3.2-testing.orig/tools/python/xen/xend/XendDomainInfo.py +++ xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1524,6 +1524,9 @@ class XendDomainInfo: +@@ -1528,6 +1528,9 @@ class XendDomainInfo: if devclass in XendDevices.valid_devices(): log.info("createDevice: %s : %s" % (devclass, scrub_password(config))) dev_uuid = config.get('uuid') diff --git a/x86_emulate-eflags.patch b/x86_emulate-eflags.patch deleted file mode 100644 index 7200cef..0000000 --- a/x86_emulate-eflags.patch +++ /dev/null @@ -1,623 +0,0 @@ -Index: xen-3.2-testing/xen/arch/x86/x86_emulate.c -=================================================================== ---- xen-3.2-testing.orig/xen/arch/x86/x86_emulate.c -+++ xen-3.2-testing/xen/arch/x86/x86_emulate.c -@@ -280,24 +280,6 @@ struct operand { - #define CR0_PE (1<<0) - #define CR4_TSD (1<<2) - --/* EFLAGS bit definitions. */ --#define EFLG_VIP (1<<20) --#define EFLG_VIF (1<<19) --#define EFLG_AC (1<<18) --#define EFLG_VM (1<<17) --#define EFLG_RF (1<<16) --#define EFLG_NT (1<<14) --#define EFLG_IOPL (3<<12) --#define EFLG_OF (1<<11) --#define EFLG_DF (1<<10) --#define EFLG_IF (1<<9) --#define EFLG_TF (1<<8) --#define EFLG_SF (1<<7) --#define EFLG_ZF (1<<6) --#define EFLG_AF (1<<4) --#define EFLG_PF (1<<2) --#define EFLG_CF (1<<0) -- - /* Exception definitions. */ - #define EXC_DE 0 - #define EXC_DB 1 -@@ -328,7 +310,7 @@ struct operand { - * These EFLAGS bits are restored from saved value during emulation, and - * any changes are written back to the saved value after emulation. - */ --#define EFLAGS_MASK (EFLG_OF|EFLG_SF|EFLG_ZF|EFLG_AF|EFLG_PF|EFLG_CF) -+#define EFLAGS_MASK (EF_OF|EF_SF|EF_ZF|EF_AF|EF_PF|EF_CF) - - /* Before executing instruction: restore necessary bits in EFLAGS. */ - #define _PRE_EFLAGS(_sav, _msk, _tmp) \ -@@ -680,28 +662,28 @@ test_cc( - switch ( (condition & 15) >> 1 ) - { - case 0: /* o */ -- rc |= (flags & EFLG_OF); -+ rc |= (flags & EF_OF); - break; - case 1: /* b/c/nae */ -- rc |= (flags & EFLG_CF); -+ rc |= (flags & EF_CF); - break; - case 2: /* z/e */ -- rc |= (flags & EFLG_ZF); -+ rc |= (flags & EF_ZF); - break; - case 3: /* be/na */ -- rc |= (flags & (EFLG_CF|EFLG_ZF)); -+ rc |= (flags & (EF_CF|EF_ZF)); - break; - case 4: /* s */ -- rc |= (flags & EFLG_SF); -+ rc |= (flags & EF_SF); - break; - case 5: /* p/pe */ -- rc |= (flags & EFLG_PF); -+ rc |= (flags & EF_PF); - break; - case 7: /* le/ng */ -- rc |= (flags & EFLG_ZF); -+ rc |= (flags & EF_ZF); - /* fall through */ - case 6: /* l/nge */ -- rc |= (!(flags & EFLG_SF) != !(flags & EFLG_OF)); -+ rc |= (!(flags & EF_SF) != !(flags & EF_OF)); - break; - } - -@@ -716,7 +698,7 @@ get_cpl( - { - struct segment_register reg; - -- if ( ctxt->regs->eflags & EFLG_VM ) -+ if ( ctxt->regs->eflags & EF_VM ) - return 3; - - if ( (ops->read_segment == NULL) || -@@ -1321,9 +1303,9 @@ x86_emulate( - /* arpl */ - uint16_t src_val = dst.val; - dst = src; -- _regs.eflags &= ~EFLG_ZF; -- _regs.eflags |= ((src_val & 3) > (dst.val & 3)) ? EFLG_ZF : 0; -- if ( _regs.eflags & EFLG_ZF ) -+ _regs.eflags &= ~EF_ZF; -+ _regs.eflags |= ((src_val & 3) > (dst.val & 3)) ? EF_ZF : 0; -+ if ( _regs.eflags & EF_ZF ) - dst.val = (dst.val & ~3) | (src_val & 3); - else - dst.type = OP_NONE; -@@ -1334,27 +1316,27 @@ x86_emulate( - case 0x69: /* imul imm16/32 */ - case 0x6b: /* imul imm8 */ { - unsigned long reg = *(long *)decode_register(modrm_reg, &_regs, 0); -- _regs.eflags &= ~(EFLG_OF|EFLG_CF); -+ _regs.eflags &= ~(EF_OF|EF_CF); - switch ( dst.bytes ) - { - case 2: - dst.val = ((uint32_t)(int16_t)src.val * - (uint32_t)(int16_t)reg); - if ( (int16_t)dst.val != (uint32_t)dst.val ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - break; - #ifdef __x86_64__ - case 4: - dst.val = ((uint64_t)(int32_t)src.val * - (uint64_t)(int32_t)reg); - if ( (int32_t)dst.val != dst.val ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - break; - #endif - default: { - unsigned long m[2] = { src.val, reg }; - if ( imul_dbl(m) ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - dst.val = m[0]; - break; - } -@@ -1538,32 +1520,32 @@ x86_emulate( - dst.type = OP_REG; - dst.reg = (unsigned long *)&_regs.eax; - dst.val = *dst.reg; -- _regs.eflags &= ~(EFLG_OF|EFLG_CF); -+ _regs.eflags &= ~(EF_OF|EF_CF); - switch ( src.bytes ) - { - case 1: - dst.val *= src.val; - if ( (uint8_t)dst.val != (uint16_t)dst.val ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - break; - case 2: - dst.val *= src.val; - if ( (uint16_t)dst.val != (uint32_t)dst.val ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - *(uint16_t *)&_regs.edx = dst.val >> 16; - break; - #ifdef __x86_64__ - case 4: - dst.val *= src.val; - if ( (uint32_t)dst.val != dst.val ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - _regs.edx = (uint32_t)(dst.val >> 32); - break; - #endif - default: { - unsigned long m[2] = { src.val, dst.val }; - if ( mul_dbl(m) ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - _regs.edx = m[1]; - dst.val = m[0]; - break; -@@ -1575,20 +1557,20 @@ x86_emulate( - dst.type = OP_REG; - dst.reg = (unsigned long *)&_regs.eax; - dst.val = *dst.reg; -- _regs.eflags &= ~(EFLG_OF|EFLG_CF); -+ _regs.eflags &= ~(EF_OF|EF_CF); - switch ( src.bytes ) - { - case 1: - dst.val = ((uint16_t)(int8_t)src.val * - (uint16_t)(int8_t)dst.val); - if ( (int8_t)dst.val != (uint16_t)dst.val ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - break; - case 2: - dst.val = ((uint32_t)(int16_t)src.val * - (uint32_t)(int16_t)dst.val); - if ( (int16_t)dst.val != (uint32_t)dst.val ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - *(uint16_t *)&_regs.edx = dst.val >> 16; - break; - #ifdef __x86_64__ -@@ -1596,14 +1578,14 @@ x86_emulate( - dst.val = ((uint64_t)(int32_t)src.val * - (uint64_t)(int32_t)dst.val); - if ( (int32_t)dst.val != dst.val ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - _regs.edx = (uint32_t)(dst.val >> 32); - break; - #endif - default: { - unsigned long m[2] = { src.val, dst.val }; - if ( imul_dbl(m) ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - _regs.edx = m[1]; - dst.val = m[0]; - break; -@@ -1824,10 +1806,10 @@ x86_emulate( - } - - /* Commit shadow register state. */ -- _regs.eflags &= ~EFLG_RF; -+ _regs.eflags &= ~EF_RF; - *ctxt->regs = _regs; - -- if ( (_regs.eflags & EFLG_TF) && -+ if ( (_regs.eflags & EF_TF) && - (rc == X86EMUL_OKAY) && - (ops->inject_hw_exception != NULL) ) - rc = ops->inject_hw_exception(EXC_DB, ctxt) ? : X86EMUL_EXCEPTION; -@@ -1906,21 +1888,21 @@ x86_emulate( - uint8_t al = _regs.eax; - unsigned long eflags = _regs.eflags; - generate_exception_if(mode_64bit(), EXC_UD); -- _regs.eflags &= ~(EFLG_CF|EFLG_AF); -- if ( ((al & 0x0f) > 9) || (eflags & EFLG_AF) ) -+ _regs.eflags &= ~(EF_CF|EF_AF); -+ if ( ((al & 0x0f) > 9) || (eflags & EF_AF) ) - { - *(uint8_t *)&_regs.eax += 6; -- _regs.eflags |= EFLG_AF; -+ _regs.eflags |= EF_AF; - } -- if ( (al > 0x99) || (eflags & EFLG_CF) ) -+ if ( (al > 0x99) || (eflags & EF_CF) ) - { - *(uint8_t *)&_regs.eax += 0x60; -- _regs.eflags |= EFLG_CF; -+ _regs.eflags |= EF_CF; - } -- _regs.eflags &= ~(EFLG_SF|EFLG_ZF|EFLG_PF); -- _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EFLG_ZF : 0; -- _regs.eflags |= (( int8_t)_regs.eax < 0) ? EFLG_SF : 0; -- _regs.eflags |= even_parity(_regs.eax) ? EFLG_PF : 0; -+ _regs.eflags &= ~(EF_SF|EF_ZF|EF_PF); -+ _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EF_ZF : 0; -+ _regs.eflags |= (( int8_t)_regs.eax < 0) ? EF_SF : 0; -+ _regs.eflags |= even_parity(_regs.eax) ? EF_PF : 0; - break; - } - -@@ -1928,35 +1910,35 @@ x86_emulate( - uint8_t al = _regs.eax; - unsigned long eflags = _regs.eflags; - generate_exception_if(mode_64bit(), EXC_UD); -- _regs.eflags &= ~(EFLG_CF|EFLG_AF); -- if ( ((al & 0x0f) > 9) || (eflags & EFLG_AF) ) -+ _regs.eflags &= ~(EF_CF|EF_AF); -+ if ( ((al & 0x0f) > 9) || (eflags & EF_AF) ) - { -- _regs.eflags |= EFLG_AF; -- if ( (al < 6) || (eflags & EFLG_CF) ) -- _regs.eflags |= EFLG_CF; -+ _regs.eflags |= EF_AF; -+ if ( (al < 6) || (eflags & EF_CF) ) -+ _regs.eflags |= EF_CF; - *(uint8_t *)&_regs.eax -= 6; - } -- if ( (al > 0x99) || (eflags & EFLG_CF) ) -+ if ( (al > 0x99) || (eflags & EF_CF) ) - { - *(uint8_t *)&_regs.eax -= 0x60; -- _regs.eflags |= EFLG_CF; -+ _regs.eflags |= EF_CF; - } -- _regs.eflags &= ~(EFLG_SF|EFLG_ZF|EFLG_PF); -- _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EFLG_ZF : 0; -- _regs.eflags |= (( int8_t)_regs.eax < 0) ? EFLG_SF : 0; -- _regs.eflags |= even_parity(_regs.eax) ? EFLG_PF : 0; -+ _regs.eflags &= ~(EF_SF|EF_ZF|EF_PF); -+ _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EF_ZF : 0; -+ _regs.eflags |= (( int8_t)_regs.eax < 0) ? EF_SF : 0; -+ _regs.eflags |= even_parity(_regs.eax) ? EF_PF : 0; - break; - } - - case 0x37: /* aaa */ - case 0x3f: /* aas */ - generate_exception_if(mode_64bit(), EXC_UD); -- _regs.eflags &= ~EFLG_CF; -- if ( ((uint8_t)_regs.eax > 9) || (_regs.eflags & EFLG_AF) ) -+ _regs.eflags &= ~EF_CF; -+ if ( ((uint8_t)_regs.eax > 9) || (_regs.eflags & EF_AF) ) - { - ((uint8_t *)&_regs.eax)[0] += (b == 0x37) ? 6 : -6; - ((uint8_t *)&_regs.eax)[1] += (b == 0x37) ? 1 : -1; -- _regs.eflags |= EFLG_CF | EFLG_AF; -+ _regs.eflags |= EF_CF | EF_AF; - } - ((uint8_t *)&_regs.eax)[0] &= 0x0f; - break; -@@ -2057,7 +2039,7 @@ x86_emulate( - &dst.val, ctxt)) != 0 ) - goto done; - register_address_increment( -- _regs.edi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); -+ _regs.edi, (_regs.eflags & EF_DF) ? -dst.bytes : dst.bytes); - break; - - case 0x6e ... 0x6f: /* outs %esi,%dx */ -@@ -2072,7 +2054,7 @@ x86_emulate( - dst.val, ctxt)) != 0 ) - goto done; - register_address_increment( -- _regs.esi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); -+ _regs.esi, (_regs.eflags & EF_DF) ? -dst.bytes : dst.bytes); - break; - - case 0x70 ... 0x7f: /* jcc (short) */ { -@@ -2149,9 +2131,9 @@ x86_emulate( - goto push; - - case 0x9d: /* popf */ { -- uint32_t mask = EFLG_VIP | EFLG_VIF | EFLG_VM; -+ uint32_t mask = EF_VIP | EF_VIF | EF_VM; - if ( !mode_iopl() ) -- mask |= EFLG_IOPL; -+ mask |= EF_IOPL; - fail_if(ops->write_rflags == NULL); - /* 64-bit mode: POP defaults to a 64-bit operand. */ - if ( mode_64bit() && (op_bytes == 4) ) -@@ -2206,9 +2188,9 @@ x86_emulate( - &dst.val, dst.bytes, ctxt)) != 0 ) - goto done; - register_address_increment( -- _regs.esi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); -+ _regs.esi, (_regs.eflags & EF_DF) ? -dst.bytes : dst.bytes); - register_address_increment( -- _regs.edi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); -+ _regs.edi, (_regs.eflags & EF_DF) ? -dst.bytes : dst.bytes); - break; - - case 0xa6 ... 0xa7: /* cmps */ { -@@ -2221,13 +2203,13 @@ x86_emulate( - &src.val, src.bytes, ctxt)) ) - goto done; - register_address_increment( -- _regs.esi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); -+ _regs.esi, (_regs.eflags & EF_DF) ? -dst.bytes : dst.bytes); - register_address_increment( -- _regs.edi, (_regs.eflags & EFLG_DF) ? -src.bytes : src.bytes); -+ _regs.edi, (_regs.eflags & EF_DF) ? -src.bytes : src.bytes); - /* cmp: dst - src ==> src=*%%edi,dst=*%%esi ==> *%%esi - *%%edi */ - emulate_2op_SrcV("cmp", src, dst, _regs.eflags); -- if ( ((rep_prefix == REPE_PREFIX) && !(_regs.eflags & EFLG_ZF)) || -- ((rep_prefix == REPNE_PREFIX) && (_regs.eflags & EFLG_ZF)) ) -+ if ( ((rep_prefix == REPE_PREFIX) && !(_regs.eflags & EF_ZF)) || -+ ((rep_prefix == REPNE_PREFIX) && (_regs.eflags & EF_ZF)) ) - _regs.eip = next_eip; - break; - } -@@ -2240,7 +2222,7 @@ x86_emulate( - dst.mem.off = truncate_ea(_regs.edi); - dst.val = _regs.eax; - register_address_increment( -- _regs.edi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); -+ _regs.edi, (_regs.eflags & EF_DF) ? -dst.bytes : dst.bytes); - break; - - case 0xac ... 0xad: /* lods */ -@@ -2252,7 +2234,7 @@ x86_emulate( - &dst.val, dst.bytes, ctxt)) != 0 ) - goto done; - register_address_increment( -- _regs.esi, (_regs.eflags & EFLG_DF) ? -dst.bytes : dst.bytes); -+ _regs.esi, (_regs.eflags & EF_DF) ? -dst.bytes : dst.bytes); - break; - - case 0xae ... 0xaf: /* scas */ { -@@ -2264,11 +2246,11 @@ x86_emulate( - &src.val, src.bytes, ctxt)) != 0 ) - goto done; - register_address_increment( -- _regs.edi, (_regs.eflags & EFLG_DF) ? -src.bytes : src.bytes); -+ _regs.edi, (_regs.eflags & EF_DF) ? -src.bytes : src.bytes); - /* cmp: dst - src ==> src=*%%edi,dst=%%eax ==> %%eax - *%%edi */ - emulate_2op_SrcV("cmp", src, dst, _regs.eflags); -- if ( ((rep_prefix == REPE_PREFIX) && !(_regs.eflags & EFLG_ZF)) || -- ((rep_prefix == REPNE_PREFIX) && (_regs.eflags & EFLG_ZF)) ) -+ if ( ((rep_prefix == REPE_PREFIX) && !(_regs.eflags & EF_ZF)) || -+ ((rep_prefix == REPNE_PREFIX) && (_regs.eflags & EF_ZF)) ) - _regs.eip = next_eip; - break; - } -@@ -2369,16 +2351,16 @@ x86_emulate( - - case 0xce: /* into */ - generate_exception_if(mode_64bit(), EXC_UD); -- if ( !(_regs.eflags & EFLG_OF) ) -+ if ( !(_regs.eflags & EF_OF) ) - break; - src.val = EXC_OF; - goto swint; - - case 0xcf: /* iret */ { - unsigned long cs, eip, eflags; -- uint32_t mask = EFLG_VIP | EFLG_VIF | EFLG_VM; -+ uint32_t mask = EF_VIP | EF_VIF | EF_VM; - if ( !mode_iopl() ) -- mask |= EFLG_IOPL; -+ mask |= EF_IOPL; - fail_if(!in_realmode(ctxt, ops)); - fail_if(ops->write_rflags == NULL); - if ( (rc = ops->read(x86_seg_ss, sp_post_inc(op_bytes), -@@ -2407,10 +2389,10 @@ x86_emulate( - generate_exception_if(mode_64bit(), EXC_UD); - generate_exception_if(base == 0, EXC_DE); - *(uint16_t *)&_regs.eax = ((al / base) << 8) | (al % base); -- _regs.eflags &= ~(EFLG_SF|EFLG_ZF|EFLG_PF); -- _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EFLG_ZF : 0; -- _regs.eflags |= (( int8_t)_regs.eax < 0) ? EFLG_SF : 0; -- _regs.eflags |= even_parity(_regs.eax) ? EFLG_PF : 0; -+ _regs.eflags &= ~(EF_SF|EF_ZF|EF_PF); -+ _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EF_ZF : 0; -+ _regs.eflags |= (( int8_t)_regs.eax < 0) ? EF_SF : 0; -+ _regs.eflags |= even_parity(_regs.eax) ? EF_PF : 0; - break; - } - -@@ -2419,16 +2401,16 @@ x86_emulate( - uint16_t ax = _regs.eax; - generate_exception_if(mode_64bit(), EXC_UD); - *(uint16_t *)&_regs.eax = (uint8_t)(ax + ((ax >> 8) * base)); -- _regs.eflags &= ~(EFLG_SF|EFLG_ZF|EFLG_PF); -- _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EFLG_ZF : 0; -- _regs.eflags |= (( int8_t)_regs.eax < 0) ? EFLG_SF : 0; -- _regs.eflags |= even_parity(_regs.eax) ? EFLG_PF : 0; -+ _regs.eflags &= ~(EF_SF|EF_ZF|EF_PF); -+ _regs.eflags |= ((uint8_t)_regs.eax == 0) ? EF_ZF : 0; -+ _regs.eflags |= (( int8_t)_regs.eax < 0) ? EF_SF : 0; -+ _regs.eflags |= even_parity(_regs.eax) ? EF_PF : 0; - break; - } - - case 0xd6: /* salc */ - generate_exception_if(mode_64bit(), EXC_UD); -- *(uint8_t *)&_regs.eax = (_regs.eflags & EFLG_CF) ? 0xff : 0x00; -+ *(uint8_t *)&_regs.eax = (_regs.eflags & EF_CF) ? 0xff : 0x00; - break; - - case 0xd7: /* xlat */ { -@@ -2442,7 +2424,7 @@ x86_emulate( - - case 0xe0 ... 0xe2: /* loop{,z,nz} */ { - int rel = insn_fetch_type(int8_t); -- int do_jmp = !(_regs.eflags & EFLG_ZF); /* loopnz */ -+ int do_jmp = !(_regs.eflags & EF_ZF); /* loopnz */ - if ( b == 0xe1 ) - do_jmp = !do_jmp; /* loopz */ - else if ( b == 0xe2 ) -@@ -2552,34 +2534,34 @@ x86_emulate( - break; - - case 0xf5: /* cmc */ -- _regs.eflags ^= EFLG_CF; -+ _regs.eflags ^= EF_CF; - break; - - case 0xf8: /* clc */ -- _regs.eflags &= ~EFLG_CF; -+ _regs.eflags &= ~EF_CF; - break; - - case 0xf9: /* stc */ -- _regs.eflags |= EFLG_CF; -+ _regs.eflags |= EF_CF; - break; - - case 0xfa: /* cli */ - case 0xfb: /* sti */ - generate_exception_if(!mode_iopl(), EXC_GP); - fail_if(ops->write_rflags == NULL); -- _regs.eflags &= ~EFLG_IF; -+ _regs.eflags &= ~EF_IE; - if ( b == 0xfb ) /* sti */ -- _regs.eflags |= EFLG_IF; -+ _regs.eflags |= EF_IE; - if ( (rc = ops->write_rflags(_regs.eflags, ctxt)) != 0 ) - goto done; - break; - - case 0xfc: /* cld */ -- _regs.eflags &= ~EFLG_DF; -+ _regs.eflags &= ~EF_DF; - break; - - case 0xfd: /* std */ -- _regs.eflags |= EFLG_DF; -+ _regs.eflags |= EF_DF; - break; - } - goto writeback; -@@ -2604,7 +2586,7 @@ x86_emulate( - emulate_2op_SrcV("cmp", src, dst, _regs.eflags); - /* Always write back. The question is: where to? */ - d |= Mov; -- if ( _regs.eflags & EFLG_ZF ) -+ if ( _regs.eflags & EF_ZF ) - { - /* Success: write back to memory. */ - dst.val = src.orig_val; -@@ -2639,14 +2621,14 @@ x86_emulate( - ((dst.orig_val << shift) | - ((src.val >> (width - shift)) & ((1ull << shift) - 1)))); - dst.val = truncate_word(dst.val, dst.bytes); -- _regs.eflags &= ~(EFLG_OF|EFLG_SF|EFLG_ZF|EFLG_PF|EFLG_CF); -+ _regs.eflags &= ~(EF_OF|EF_SF|EF_ZF|EF_PF|EF_CF); - if ( (dst.val >> ((b & 8) ? (shift - 1) : (width - shift))) & 1 ) -- _regs.eflags |= EFLG_CF; -+ _regs.eflags |= EF_CF; - if ( ((dst.val ^ dst.orig_val) >> (width - 1)) & 1 ) -- _regs.eflags |= EFLG_OF; -- _regs.eflags |= ((dst.val >> (width - 1)) & 1) ? EFLG_SF : 0; -- _regs.eflags |= (dst.val == 0) ? EFLG_ZF : 0; -- _regs.eflags |= even_parity(dst.val) ? EFLG_PF : 0; -+ _regs.eflags |= EF_OF; -+ _regs.eflags |= ((dst.val >> (width - 1)) & 1) ? EF_SF : 0; -+ _regs.eflags |= (dst.val == 0) ? EF_ZF : 0; -+ _regs.eflags |= even_parity(dst.val) ? EF_PF : 0; - break; - } - -@@ -2659,27 +2641,27 @@ x86_emulate( - break; - - case 0xaf: /* imul */ -- _regs.eflags &= ~(EFLG_OF|EFLG_CF); -+ _regs.eflags &= ~(EF_OF|EF_CF); - switch ( dst.bytes ) - { - case 2: - dst.val = ((uint32_t)(int16_t)src.val * - (uint32_t)(int16_t)dst.val); - if ( (int16_t)dst.val != (uint32_t)dst.val ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - break; - #ifdef __x86_64__ - case 4: - dst.val = ((uint64_t)(int32_t)src.val * - (uint64_t)(int32_t)dst.val); - if ( (int32_t)dst.val != dst.val ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - break; - #endif - default: { - unsigned long m[2] = { src.val, dst.val }; - if ( imul_dbl(m) ) -- _regs.eflags |= EFLG_OF|EFLG_CF; -+ _regs.eflags |= EF_OF|EF_CF; - dst.val = m[0]; - break; - } -@@ -2710,8 +2692,8 @@ x86_emulate( - asm ( "bsf %2,%0; setz %b1" - : "=r" (dst.val), "=q" (zf) - : "r" (src.val), "1" (0) ); -- _regs.eflags &= ~EFLG_ZF; -- _regs.eflags |= zf ? EFLG_ZF : 0; -+ _regs.eflags &= ~EF_ZF; -+ _regs.eflags |= zf ? EF_ZF : 0; - break; - } - -@@ -2720,8 +2702,8 @@ x86_emulate( - asm ( "bsr %2,%0; setz %b1" - : "=r" (dst.val), "=q" (zf) - : "r" (src.val), "1" (0) ); -- _regs.eflags &= ~EFLG_ZF; -- _regs.eflags |= zf ? EFLG_ZF : 0; -+ _regs.eflags &= ~EF_ZF; -+ _regs.eflags |= zf ? EF_ZF : 0; - break; - } - -@@ -2984,7 +2966,7 @@ x86_emulate( - { - _regs.eax = old_lo; - _regs.edx = old_hi; -- _regs.eflags &= ~EFLG_ZF; -+ _regs.eflags &= ~EF_ZF; - } - else if ( ops->cmpxchg8b == NULL ) - { -@@ -2996,7 +2978,7 @@ x86_emulate( - if ( (rc = ops->cmpxchg8b(ea.mem.seg, ea.mem.off, old_lo, old_hi, - _regs.ebx, _regs.ecx, ctxt)) != 0 ) - goto done; -- _regs.eflags |= EFLG_ZF; -+ _regs.eflags |= EF_ZF; - } - break; - } -@@ -3011,7 +2993,7 @@ x86_emulate( - { - _regs.eax = (uint32_t)(old>>0); - _regs.edx = (uint32_t)(old>>32); -- _regs.eflags &= ~EFLG_ZF; -+ _regs.eflags &= ~EF_ZF; - } - else - { -@@ -3019,7 +3001,7 @@ x86_emulate( - if ( (rc = ops->cmpxchg(ea.mem.seg, ea.mem.off, old, - new, 8, ctxt)) != 0 ) - goto done; -- _regs.eflags |= EFLG_ZF; -+ _regs.eflags |= EF_ZF; - } - break; - } diff --git a/x86_emulate.patch b/x86_emulate.patch index 5d172fc..fe3a2d1 100644 --- a/x86_emulate.patch +++ b/x86_emulate.patch @@ -14,6 +14,8 @@ Index: xen-3.2-testing/xen/arch/x86/mm.c offset, ((u64)old_hi << 32) | old, ((u64)new_hi << 32) | new, 8, 1, container_of(ctxt, struct ptwr_emulate_ctxt, ctxt)); } ++#else ++#define ptwr_emulated_cmpxchg8b NULL +#endif static struct x86_emulate_ops ptwr_emulate_ops = { @@ -22,9 +24,7 @@ Index: xen-3.2-testing/xen/arch/x86/mm.c .write = ptwr_emulated_write, .cmpxchg = ptwr_emulated_cmpxchg, - .cmpxchg8b = ptwr_emulated_cmpxchg8b -+#ifdef __i386__ + .cmpxchg2 = ptwr_emulated_cmpxchg8b -+#endif }; /* Write page fault handler: check if guest is trying to modify a PTE. */ @@ -32,7 +32,7 @@ Index: xen-3.2-testing/xen/arch/x86/mm/shadow/common.c =================================================================== --- xen-3.2-testing.orig/xen/arch/x86/mm/shadow/common.c +++ xen-3.2-testing/xen/arch/x86/mm/shadow/common.c -@@ -252,6 +252,7 @@ hvm_emulate_cmpxchg(enum x86_segment seg +@@ -251,6 +251,7 @@ hvm_emulate_cmpxchg(enum x86_segment seg v, addr, old, new, bytes, sh_ctxt); } @@ -40,10 +40,12 @@ Index: xen-3.2-testing/xen/arch/x86/mm/shadow/common.c static int hvm_emulate_cmpxchg8b(enum x86_segment seg, unsigned long offset, -@@ -275,13 +276,16 @@ hvm_emulate_cmpxchg8b(enum x86_segment s +@@ -274,13 +275,16 @@ hvm_emulate_cmpxchg8b(enum x86_segment s return v->arch.paging.mode->shadow.x86_emulate_cmpxchg8b( v, addr, old_lo, old_hi, new_lo, new_hi, sh_ctxt); } ++#else ++#define hvm_emulate_cmpxchg8b NULL +#endif static struct x86_emulate_ops hvm_shadow_emulator_ops = { @@ -52,13 +54,11 @@ Index: xen-3.2-testing/xen/arch/x86/mm/shadow/common.c .write = hvm_emulate_write, .cmpxchg = hvm_emulate_cmpxchg, - .cmpxchg8b = hvm_emulate_cmpxchg8b, -+#ifdef __i386__ + .cmpxchg2 = hvm_emulate_cmpxchg8b, -+#endif }; static int -@@ -332,6 +336,7 @@ pv_emulate_cmpxchg(enum x86_segment seg, +@@ -331,6 +335,7 @@ pv_emulate_cmpxchg(enum x86_segment seg, v, offset, old, new, bytes, sh_ctxt); } @@ -66,10 +66,12 @@ Index: xen-3.2-testing/xen/arch/x86/mm/shadow/common.c static int pv_emulate_cmpxchg8b(enum x86_segment seg, unsigned long offset, -@@ -347,13 +352,16 @@ pv_emulate_cmpxchg8b(enum x86_segment se +@@ -346,13 +351,16 @@ pv_emulate_cmpxchg8b(enum x86_segment se return v->arch.paging.mode->shadow.x86_emulate_cmpxchg8b( v, offset, old_lo, old_hi, new_lo, new_hi, sh_ctxt); } ++#else ++#define pv_emulate_cmpxchg8b NULL +#endif static struct x86_emulate_ops pv_shadow_emulator_ops = { @@ -78,13 +80,11 @@ Index: xen-3.2-testing/xen/arch/x86/mm/shadow/common.c .write = pv_emulate_write, .cmpxchg = pv_emulate_cmpxchg, - .cmpxchg8b = pv_emulate_cmpxchg8b, -+#ifdef __i386__ + .cmpxchg2 = pv_emulate_cmpxchg8b, -+#endif }; struct x86_emulate_ops *shadow_init_emulation( -@@ -367,7 +375,12 @@ struct x86_emulate_ops *shadow_init_emul +@@ -366,7 +374,12 @@ struct x86_emulate_ops *shadow_init_emul if ( !is_hvm_vcpu(v) ) { @@ -101,7 +101,7 @@ Index: xen-3.2-testing/xen/arch/x86/mm/shadow/multi.c =================================================================== --- xen-3.2-testing.orig/xen/arch/x86/mm/shadow/multi.c +++ xen-3.2-testing/xen/arch/x86/mm/shadow/multi.c -@@ -4230,7 +4230,8 @@ sh_x86_emulate_cmpxchg(struct vcpu *v, u +@@ -4244,7 +4244,8 @@ sh_x86_emulate_cmpxchg(struct vcpu *v, u return rv; } @@ -111,7 +111,7 @@ Index: xen-3.2-testing/xen/arch/x86/mm/shadow/multi.c sh_x86_emulate_cmpxchg8b(struct vcpu *v, unsigned long vaddr, unsigned long old_lo, unsigned long old_hi, unsigned long new_lo, unsigned long new_hi, -@@ -4265,6 +4266,7 @@ sh_x86_emulate_cmpxchg8b(struct vcpu *v, +@@ -4280,6 +4281,7 @@ sh_x86_emulate_cmpxchg8b(struct vcpu *v, shadow_unlock(v->domain); return rv; } @@ -119,7 +119,7 @@ Index: xen-3.2-testing/xen/arch/x86/mm/shadow/multi.c /**************************************************************************/ -@@ -4551,7 +4553,9 @@ struct paging_mode sh_paging_mode = { +@@ -4566,7 +4568,9 @@ struct paging_mode sh_paging_mode = { .shadow.detach_old_tables = sh_detach_old_tables, .shadow.x86_emulate_write = sh_x86_emulate_write, .shadow.x86_emulate_cmpxchg = sh_x86_emulate_cmpxchg, @@ -133,15 +133,20 @@ Index: xen-3.2-testing/xen/arch/x86/x86_emulate.c =================================================================== --- xen-3.2-testing.orig/xen/arch/x86/x86_emulate.c +++ xen-3.2-testing/xen/arch/x86/x86_emulate.c -@@ -30,6 +30,7 @@ +@@ -30,10 +30,11 @@ #include #include #include +#include #undef cmpxchg #undef cpuid ++#undef wbinvd #endif -@@ -2954,58 +2955,63 @@ x86_emulate( +-#undef wbinvd /* Macro'ed in include/asm-x86/system.h */ + #include + + /* Operand sizes: 8-bit operands or specified/overridden size. */ +@@ -2978,58 +2979,63 @@ x86_emulate( src.val = x86_seg_gs; goto pop_seg; @@ -158,7 +163,7 @@ Index: xen-3.2-testing/xen/arch/x86/x86_emulate.c - { - _regs.eax = old_lo; - _regs.edx = old_hi; -- _regs.eflags &= ~EF_ZF; +- _regs.eflags &= ~EFLG_ZF; - } - else if ( ops->cmpxchg8b == NULL ) - { @@ -175,7 +180,7 @@ Index: xen-3.2-testing/xen/arch/x86/x86_emulate.c + + if ( (rc = ops->read(ea.mem.seg, ea.mem.off, &old, 8, ctxt)) != 0 ) goto done; -- _regs.eflags |= EF_ZF; +- _regs.eflags |= EFLG_ZF; - } - break; - } @@ -190,13 +195,13 @@ Index: xen-3.2-testing/xen/arch/x86/x86_emulate.c - { - _regs.eax = (uint32_t)(old>>0); - _regs.edx = (uint32_t)(old>>32); -- _regs.eflags &= ~EF_ZF; +- _regs.eflags &= ~EFLG_ZF; + if ( ((uint32_t)(old>>0) != (uint32_t)_regs.eax) || + ((uint32_t)(old>>32) != (uint32_t)_regs.edx) ) + { + _regs.eax = (uint32_t)(old>>0); + _regs.edx = (uint32_t)(old>>32); -+ _regs.eflags &= ~EF_ZF; ++ _regs.eflags &= ~EFLG_ZF; + } + else + { @@ -204,7 +209,7 @@ Index: xen-3.2-testing/xen/arch/x86/x86_emulate.c + if ( (rc = ops->cmpxchg(ea.mem.seg, ea.mem.off, old, + new, 8, ctxt)) != 0 ) + goto done; -+ _regs.eflags |= EF_ZF; ++ _regs.eflags |= EFLG_ZF; + } } + else if ( !cpu_has_cmpxchg16b ) @@ -222,12 +227,12 @@ Index: xen-3.2-testing/xen/arch/x86/x86_emulate.c + (rc = ops->read(ea.mem.seg, ea.mem.off+sizeof(old_lo), + &old_hi, sizeof(old_lo), ctxt)) ) goto done; -- _regs.eflags |= EF_ZF; +- _regs.eflags |= EFLG_ZF; + if ( (old_lo != _regs.eax) || (old_hi != _regs.edx) ) + { + _regs.eax = old_lo; + _regs.edx = old_hi; -+ _regs.eflags &= ~EF_ZF; ++ _regs.eflags &= ~EFLG_ZF; + } + else if ( ops->cmpxchg2 == NULL ) + { @@ -239,7 +244,7 @@ Index: xen-3.2-testing/xen/arch/x86/x86_emulate.c + if ( (rc = ops->cmpxchg2(ea.mem.seg, ea.mem.off, old_lo, old_hi, + _regs.ebx, _regs.ecx, ctxt)) != 0 ) + goto done; -+ _regs.eflags |= EF_ZF; ++ _regs.eflags |= EFLG_ZF; + } } break; @@ -248,7 +253,7 @@ Index: xen-3.2-testing/xen/arch/x86/x86_emulate.c case 0xc8 ... 0xcf: /* bswap */ dst.type = OP_REG; -@@ -3015,7 +3021,7 @@ x86_emulate( +@@ -3039,7 +3045,7 @@ x86_emulate( { default: /* case 2: */ /* Undefined behaviour. Writes zero on all tested CPUs. */ diff --git a/xen-3.2-testing-src.tar.bz2 b/xen-3.2-testing-src.tar.bz2 index d8836c2..8190c2d 100644 --- a/xen-3.2-testing-src.tar.bz2 +++ b/xen-3.2-testing-src.tar.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7a3b0d72259d820195d38cffac039b8e5daaa99ebc8e80b375242361b53646cb -size 6419511 +oid sha256:b7da7e0b2e35bba8e475d26a062540e83b76868bbcc3d3d3d7d1f447ce685115 +size 6404909 diff --git a/xen-destdir.diff b/xen-destdir.diff index 6a3ed98..00f3a8e 100644 --- a/xen-destdir.diff +++ b/xen-destdir.diff @@ -89,13 +89,12 @@ Index: xen-3.2-testing/tools/examples/Makefile .PHONY: install-configs install-configs: $(XEN_CONFIGS) -@@ -109,9 +97,7 @@ install-udev: +@@ -109,8 +97,7 @@ install-udev: $(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d - for i in $(UDEV_RULES); \ + set -e; for i in $(UDEV_RULES); \ do \ - $(INSTALL_DATA) $$i $(DESTDIR)$(UDEV_RULES_DIR); \ -- ( cd $(DESTDIR)$(UDEV_RULES_DIR)/rules.d ; \ -- ln -sf ../$$i . ) \ +- ln -sf ../$$i $(DESTDIR)$(UDEV_RULES_DIR)/rules.d; \ + $(INSTALL_DATA) $$i $(DESTDIR)$(UDEV_RULES_DIR)/rules.d; \ done diff --git a/xen-domUloader.diff b/xen-domUloader.diff index 69d7813..4959ec1 100644 --- a/xen-domUloader.diff +++ b/xen-domUloader.diff @@ -1,16 +1,117 @@ +Index: xen-3.2-testing/tools/python/xen/util/blkif.py +=================================================================== +--- xen-3.2-testing.orig/tools/python/xen/util/blkif.py ++++ xen-3.2-testing/tools/python/xen/util/blkif.py +@@ -66,23 +66,24 @@ def blkdev_segment(name): + 'type' : 'Disk' } + return val + +-def _parse_uname(uname): +- fn = taptype = None ++def parse_uname(uname): ++ fn = tpy = taptype = None + if uname.find(":") != -1: + (typ, fn) = uname.split(":", 1) + if typ == "phy" and not fn.startswith("/"): + fn = "/dev/%s" %(fn,) + if typ == "tap": + (taptype, fn) = fn.split(":", 1) +- return (fn, taptype) ++ return (fn, (typ, taptype)) ++ return (fn, (typ,taptype)) + + def blkdev_uname_to_file(uname): + """Take a blkdev uname and return the corresponding filename.""" +- return _parse_uname(uname)[0] ++ return parse_uname(uname)[0] + + def blkdev_uname_to_taptype(uname): + """Take a blkdev uname and return the blktap type.""" +- return _parse_uname(uname)[1] ++ return parse_uname(uname)[1][0] + + def mount_mode(name): + mode = None +Index: xen-3.2-testing/tools/python/xen/xend/server/DevController.py +=================================================================== +--- xen-3.2-testing.orig/tools/python/xen/xend/server/DevController.py ++++ xen-3.2-testing/tools/python/xen/xend/server/DevController.py +@@ -561,6 +561,31 @@ class DevController: + return result['status'] + + ++ def waitForFrontend(self, devid): ++ def frontendStatusCallback(statusPath, ev, result): ++ status = xstransact.Read(statusPath) ++ log.debug("frontendStatusCallback %s = %s" % (statusPath, status)) ++ try: ++ status = int(status) ++ if status == xenbusState['Connected']: ++ result['status'] = Connected ++ elif status == xenbusState['Closed']: ++ result['status'] = Error ++ else: ++ raise ++ except: ++ return 1 ++ ev.set() ++ return 0 ++ frontpath = self.frontendPath(devid) ++ statusPath = frontpath + '/state' ++ ev = Event() ++ result = { 'status': Timeout } ++ xswatch(statusPath, frontendStatusCallback, ev, result) ++ ev.wait(5) ++ return result['status'] ++ ++ + def backendPath(self, backdom, devid): + """Construct backend path given the backend domain and device id. + Index: xen-3.2-testing/tools/python/xen/xend/XendBootloader.py =================================================================== --- xen-3.2-testing.orig/tools/python/xen/xend/XendBootloader.py +++ xen-3.2-testing/tools/python/xen/xend/XendBootloader.py -@@ -14,6 +14,7 @@ +@@ -12,8 +12,9 @@ + # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + # - import os, select, errno, stat, signal +-import os, select, errno, stat, signal ++import os, select, errno, stat, signal, time import random +import re import shlex from xen.xend import sxp -@@ -185,3 +186,14 @@ def bootloader_tidy(dom): +@@ -38,8 +39,25 @@ def bootloader(blexec, disk, dom, quiet + msg = "Bootloader isn't executable" + log.error(msg) + raise VmError(msg) +- if not os.access(disk, os.R_OK): +- msg = "Disk isn't accessible" ++ ++ # domUloader requires '--entry=foo' in blargs, which is derived from ++ # 'bootargs' entry in domain configuration file. Ensure it exists ++ # here so a reasonable error message can be returned. ++ if blexec.find('domUloader.py') != -1: ++ if blargs.find('entry') == -1: ++ msg = "domUloader requires specification of bootargs" ++ log.error(msg) ++ raise VmError(msg) ++ ++ avail = False ++ for i in xrange(1, 20): ++ avail = os.access(disk, os.R_OK) ++ if avail: ++ break ++ time.sleep(.05) ++ ++ if not avail: ++ msg = "Disk '%s' isn't accessible" % disk + log.error(msg) + raise VmError(msg) + +@@ -185,3 +203,14 @@ def bootloader_tidy(dom): os.kill(pid, signal.SIGKILL) @@ -29,7 +130,15 @@ Index: xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-3.2-testing.orig/tools/python/xen/xend/XendDomainInfo.py +++ xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -42,7 +42,7 @@ from xen.xend import balloon, sxp, uuid, +@@ -35,14 +35,14 @@ from types import StringTypes + + import xen.lowlevel.xc + from xen.util import asserts +-from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype ++from xen.util.blkif import parse_uname + import xen.util.xsm.xsm as security + + from xen.xend import balloon, sxp, uuid, image, arch, osdep from xen.xend import XendOptions, XendNode, XendConfig from xen.xend.XendConfig import scrub_password @@ -38,7 +147,18 @@ Index: xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py from xen.xend.XendError import XendError, VmError from xen.xend.XendDevices import XendDevices from xen.xend.XendTask import XendTask -@@ -2009,8 +2009,11 @@ class XendDomainInfo: +@@ -1484,6 +1484,10 @@ class XendDomainInfo: + deviceClass, config = self.info['devices'].get(dev_uuid) + self._waitForDevice(deviceClass, config['devid']) + ++ def _waitForDeviceFrontUUID(self, dev_uuid): ++ deviceClass, config = self.info['devices'].get(dev_uuid) ++ self.getDeviceController(deviceClass).waitForFrontend(config['devid']) ++ + def _waitForDevice_destroy(self, deviceClass, devid, backpath): + return self.getDeviceController(deviceClass).waitForDevice_destroy( + devid, backpath) +@@ -2012,8 +2016,11 @@ class XendDomainInfo: blexec = osdep.pygrub_path blcfg = None @@ -52,3 +172,31 @@ Index: xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py if not disks: msg = "Had a bootloader specified, but no disks are bootable" +@@ -2024,13 +2031,10 @@ class XendDomainInfo: + devtype = devinfo[0] + disk = devinfo[1]['uname'] + +- fn = blkdev_uname_to_file(disk) +- taptype = blkdev_uname_to_taptype(disk) +- mounted = devtype == 'tap' and taptype != 'aio' and taptype != 'sync' and not os.stat(fn).st_rdev ++ (fn, types) = parse_uname(disk) ++ mounted = (types[0] not in ('file', 'phy')) + if mounted: +- # This is a file, not a device. pygrub can cope with a +- # file if it's raw, but if it's QCOW or other such formats +- # used through blktap, then we need to mount it first. ++ # This is not a raw file or device, so we need to mount it first. + + log.info("Mounting %s on %s." % + (fn, BOOTLOADER_LOOPBACK_DEVICE)) +@@ -2042,7 +2046,9 @@ class XendDomainInfo: + + from xen.xend import XendDomain + dom0 = XendDomain.instance().privilegedDomain() +- dom0._waitForDeviceUUID(dom0.create_vbd(vbd, disk)) ++ vbd_uuid = dom0.create_vbd(vbd, disk) ++ dom0._waitForDeviceUUID(vbd_uuid) ++ dom0._waitForDeviceFrontUUID(vbd_uuid) + fn = BOOTLOADER_LOOPBACK_DEVICE + + try: diff --git a/xen-fbback-resize.patch b/xen-fbback-resize.patch new file mode 100644 index 0000000..548ab6c --- /dev/null +++ b/xen-fbback-resize.patch @@ -0,0 +1,144 @@ +diff -r 15cfd1f8fa38 tools/ioemu/hw/xenfb.c +--- a/tools/ioemu/hw/xenfb.c Tue Jan 08 16:45:08 2008 +0000 ++++ b/tools/ioemu/hw/xenfb.c Thu Jan 10 12:20:59 2008 -0700 +@@ -78,6 +78,7 @@ static void xenfb_invalidate(void *opaqu + static void xenfb_invalidate(void *opaque); + static void xenfb_screen_dump(void *opaque, const char *name); + static int xenfb_register_console(struct xenfb *xenfb); ++static int xenfb_send_resize(struct xenfb *xenfb, int width, int height); + + /* + * Tables to map from scancode to Linux input layer keycode. +@@ -264,6 +265,9 @@ struct xenfb *xenfb_new(int domid, Displ + xenfb->ds = ds; + xenfb_device_set_domain(&xenfb->fb, domid); + xenfb_device_set_domain(&xenfb->kbd, domid); ++ ++ /* Indicate we have the frame buffer resize feature */ ++ xenfb_xs_printf(xenfb->xsh, xenfb->fb.nodename, "feature-resize", "1"); + + fprintf(stderr, "FB: Waiting for KBD backend creation\n"); + xenfb_wait_for_backend(&xenfb->kbd, xenfb_backend_created_kbd); +@@ -510,6 +514,12 @@ static void xenfb_on_fb_event(struct xen + } + xenfb_guest_copy(xenfb, x, y, w, h); + break; ++ case XENFB_TYPE_RESIZE: ++ xenfb->width = event->resize.width; ++ xenfb->height = event->resize.height; ++ dpy_resize(xenfb->ds, xenfb->width, xenfb->height); ++ xenfb_send_resize(xenfb, xenfb->width, xenfb->height); ++ break; + } + } + mb(); /* ensure we're done with ring contents */ +@@ -601,6 +611,19 @@ static int xenfb_send_motion(struct xenf + event.motion.rel_x = rel_x; + event.motion.rel_y = rel_y; + event.motion.rel_z = rel_z; ++ ++ return xenfb_kbd_event(xenfb, &event); ++} ++ ++/* Send a resize event to kbd driver */ ++static int xenfb_send_resize(struct xenfb *xenfb, int width, int height) ++{ ++ union xenkbd_in_event event; ++ ++ memset(&event, 0, XENKBD_IN_EVENT_SIZE); ++ event.type = XENKBD_TYPE_RESIZE; ++ event.resize.width = width; ++ event.resize.height = height; + + return xenfb_kbd_event(xenfb, &event); + } +diff -r 15cfd1f8fa38 xen/include/public/io/fbif.h +--- a/xen/include/public/io/fbif.h Tue Jan 08 16:45:08 2008 +0000 ++++ b/xen/include/public/io/fbif.h Thu Jan 10 11:00:13 2008 -0700 +@@ -50,12 +50,26 @@ struct xenfb_update + int32_t height; /* rect height */ + }; + ++/* ++ * Framebuffer resize notification event ++ * Capable backend sets feature-resize in xenstore. ++ */ ++#define XENFB_TYPE_RESIZE 3 ++ ++struct xenfb_resize ++{ ++ uint8_t type; /* XENFB_TYPE_RESIZE */ ++ int32_t width; /* frame buffer width in pixels */ ++ int32_t height; /* frame buffer height in pixels */ ++}; ++ + #define XENFB_OUT_EVENT_SIZE 40 + + union xenfb_out_event + { + uint8_t type; + struct xenfb_update update; ++ struct xenfb_resize resize; + char pad[XENFB_OUT_EVENT_SIZE]; + }; + +@@ -109,15 +123,18 @@ struct xenfb_page + * Each directory page holds PAGE_SIZE / sizeof(*pd) + * framebuffer pages, and can thus map up to PAGE_SIZE * + * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and +- * sizeof(unsigned long) == 4, that's 4 Megs. Two directory +- * pages should be enough for a while. ++ * sizeof(unsigned long) == 4 on a 32 bit system that's 4 Megs ++ * sizeof(unsigned long) == 8 on a 64 bit system that's 2 Megs ++ * Will need 3 directory page entries to support a 5MB frame ++ * buffer which is enough for a 1280x1024 display + */ +- unsigned long pd[2]; ++ unsigned long pd[3]; + }; + + /* +- * Wart: xenkbd needs to know resolution. Put it here until a better +- * solution is found, but don't leak it to the backend. ++ * Wart: xenkbd needs to know resolution of initial frame buffer. Put ++ * it here until a better solution is found, but don't leak it to ++ * the backend. + */ + #ifdef __KERNEL__ + #define XENFB_WIDTH 800 +diff -r 15cfd1f8fa38 xen/include/public/io/kbdif.h +--- a/xen/include/public/io/kbdif.h Tue Jan 08 16:45:08 2008 +0000 ++++ b/xen/include/public/io/kbdif.h Thu Jan 10 12:28:09 2008 -0700 +@@ -44,6 +44,11 @@ + * request-abs-update in xenstore. + */ + #define XENKBD_TYPE_POS 4 ++/* ++ * Sent when frame buffer is resized. kbd adjusts absolute ++ * max X and Y axis values in input ptr device. ++ */ ++#define XENKBD_TYPE_RESIZE 5 + + struct xenkbd_motion + { +@@ -68,6 +73,12 @@ struct xenkbd_position + int32_t abs_z; /* absolute Z position (wheel) */ + }; + ++struct xenkbd_resize ++{ ++ uint8_t type; /* XENKBD_TYPE_RESIZE */ ++ int32_t width; /* frame buffer width in pixels */ ++ int32_t height; /* frame buffer height in pixels */ ++}; + #define XENKBD_IN_EVENT_SIZE 40 + + union xenkbd_in_event +@@ -76,6 +87,7 @@ union xenkbd_in_event + struct xenkbd_motion motion; + struct xenkbd_key key; + struct xenkbd_position pos; ++ struct xenkbd_resize resize; + char pad[XENKBD_IN_EVENT_SIZE]; + }; + diff --git a/xen-hvm-default-bridge.diff b/xen-hvm-default-bridge.diff index bb69672..165856d 100644 --- a/xen-hvm-default-bridge.diff +++ b/xen-hvm-default-bridge.diff @@ -25,7 +25,7 @@ Index: xen-3.2-testing/tools/ioemu/vl.c #endif #ifdef __sun__ #define SMBD_COMMAND "/usr/sfw/sbin/smbd" -@@ -4131,10 +4129,10 @@ static int net_client_init(const char *s +@@ -4129,10 +4127,10 @@ static int net_client_init(const char *s if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) { pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT); } diff --git a/xen-warnings.diff b/xen-warnings.diff index c336f19..ada1667 100644 --- a/xen-warnings.diff +++ b/xen-warnings.diff @@ -185,19 +185,6 @@ Index: xen-3.2-testing/tools/xenstore/xsls.c fputs(" (", stdout); for (i = 0; i < nperms; i++) { if (i) -Index: xen-3.2-testing/tools/blktap/drivers/tapaio.c -=================================================================== ---- xen-3.2-testing.orig/tools/blktap/drivers/tapaio.c -+++ xen-3.2-testing/tools/blktap/drivers/tapaio.c -@@ -150,7 +150,7 @@ tap_aio_get_events(tap_aio_context_t *ct - nr_events = io_getevents(ctx->aio_ctx, 1, - ctx->max_aio_events, ctx->aio_events, NULL); - else -- read(ctx->completion_fd[0], &nr_events, sizeof(nr_events)); -+ if (read(ctx->completion_fd[0], &nr_events, sizeof(nr_events))); - - return nr_events; - } Index: xen-3.2-testing/xen/arch/x86/x86_emulate.c =================================================================== --- xen-3.2-testing.orig/xen/arch/x86/x86_emulate.c diff --git a/xen.changes b/xen.changes index c1abb3d..8a9b11e 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Sat Jan 12 00:37:41 CET 2008 - carnold@suse.de + +- Update to xen 3.2 RC5. Changeset 16701 + ------------------------------------------------------------------- Wed Dec 19 16:16:36 MST 2007 - carnold@novell.com diff --git a/xen.spec b/xen.spec index bf2d8f7..5ed22bb 100644 --- a/xen.spec +++ b/xen.spec @@ -1,7 +1,7 @@ # -# spec file for package xen (Version 3.2.0_16646) +# spec file for package xen (Version 3.2.0_16701) # -# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany. # This file and all modifications and additions to the pristine # package are under the same license as the package itself. # @@ -13,7 +13,7 @@ Name: xen %define xvers 3.2 %define xvermaj 3 -%define changeset 16646 +%define changeset 16701 %define xen_build_dir xen-3.2-testing %if %sles_version %define with_kmp 1 @@ -32,7 +32,7 @@ BuildRequires: glibc-32bit glibc-devel-32bit %if %{?with_kmp}0 BuildRequires: kernel-source kernel-syms module-init-tools xorg-x11 %endif -Version: 3.2.0_16646 +Version: 3.2.0_16701 Release: 1 License: GPL v2 only Group: System/Kernel @@ -104,11 +104,14 @@ Patch152: bridge-hostonly.diff Patch153: bridge-vlan.diff Patch154: keymap_nl-be.patch Patch155: svm-cr8-performance.diff +Patch156: xen-fbback-resize.patch # Patches from Jan -Patch240: svm-lmsl.patch -Patch241: x86_emulate-eflags.patch -Patch242: x86_emulate.patch -Patch243: x86-extra-trap-info.patch +Patch240: xenctx.patch +Patch241: const-callback-arg.patch +Patch242: const-set-trap-table-arg.patch +Patch243: svm-lmsl.patch +Patch244: x86_emulate.patch +Patch245: x86-extra-trap-info.patch Patch290: x86_64-syscall-clear-df.patch Patch291: 32on64-extra-mem.patch Patch292: blktap.patch @@ -523,17 +526,20 @@ Authors: %patch141 -p1 %patch142 -p1 %patch143 -p1 -#%patch144 -p1 # Pat, cdrom +%patch144 -p1 %patch150 -p1 #%patch151 -p1 # dump if all goes well with defaulting to network-multinet #%patch152 -p1 # dump if all goes well with defaulting to network-multinet #%patch153 -p1 # dump if all goes well with defaulting to network-multinet %patch154 -p1 #%patch155 -p1 # AMD CR8 Performance - not clean for unstable +%patch156 -p1 %patch240 -p1 %patch241 -p1 %patch242 -p1 %patch243 -p1 +%patch244 -p1 +%patch245 -p1 %patch290 -p1 %patch291 -p1 %patch292 -p1 @@ -624,7 +630,7 @@ done make -C docs install \ DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} \ DOCDIR=%{_defaultdocdir}/xen -for name in COPYING %SOURCE2 %SOURCE3 %SOURCE4 %SOURCE16; do +for name in COPYING %SOURCE2 %SOURCE3 %SOURCE4; do install -m 644 $name $RPM_BUILD_ROOT/%{_defaultdocdir}/xen/ done mkdir -p $RPM_BUILD_ROOT/%{_defaultdocdir}/xen/misc @@ -645,7 +651,7 @@ install -m644 %SOURCE9 %SOURCE10 $RPM_BUILD_ROOT/etc/xen/examples/ install -m644 %SOURCE17 $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.xend # scripts rm $RPM_BUILD_ROOT/etc/xen/scripts/block-*nbd -install -m755 %SOURCE11 %SOURCE12 %SOURCE13 %SOURCE18 %SOURCE19 %SOURCE20 %SOURCE21 $RPM_BUILD_ROOT/etc/xen/scripts/ +install -m755 %SOURCE11 %SOURCE12 %SOURCE13 %SOURCE16 %SOURCE18 %SOURCE19 %SOURCE20 %SOURCE21 $RPM_BUILD_ROOT/etc/xen/scripts/ # logrotate install -m644 -D %SOURCE7 $RPM_BUILD_ROOT/etc/logrotate.d/xen # directories @@ -775,7 +781,6 @@ rm -f $RPM_BUILD_ROOT/%pysite/*.egg-info %{_defaultdocdir}/xen/boot.local.xenU %{_defaultdocdir}/xen/boot.xen %{_defaultdocdir}/xen/misc -%{_defaultdocdir}/xen/xmclone.sh %dir %pysite/xen %pysite/xen/* /usr/lib/xen/boot/domUloader.py @@ -848,6 +853,8 @@ rm -f $RPM_BUILD_ROOT/%pysite/*.egg-info /sbin/ldconfig %changelog +* Sat Jan 12 2008 - carnold@suse.de +- Update to xen 3.2 RC5. Changeset 16701 * Wed Dec 19 2007 - carnold@novell.com - Update to xen 3.2 RC2. Changeset 16646 * Thu Nov 29 2007 - carnold@novell.com diff --git a/xenapi-console-protocol.patch b/xenapi-console-protocol.patch index 7b0319c..6948d8c 100644 --- a/xenapi-console-protocol.patch +++ b/xenapi-console-protocol.patch @@ -2,7 +2,7 @@ Index: xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-3.2-testing.orig/tools/python/xen/xend/XendDomainInfo.py +++ xen-3.2-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -2684,6 +2684,14 @@ class XendDomainInfo: +@@ -2690,6 +2690,14 @@ class XendDomainInfo: if not config.has_key('backend'): config['backend'] = "00000000-0000-0000-0000-000000000000" diff --git a/xenctx.patch b/xenctx.patch new file mode 100644 index 0000000..501020c --- /dev/null +++ b/xenctx.patch @@ -0,0 +1,163 @@ +Index: 2007-12-10/tools/xentrace/xenctx.c +=================================================================== +--- 2007-12-10.orig/tools/xentrace/xenctx.c 2007-11-26 16:57:02.000000000 +0100 ++++ 2007-12-10/tools/xentrace/xenctx.c 2007-12-10 09:19:27.000000000 +0100 +@@ -29,6 +29,7 @@ int xc_handle = 0; + int domid = 0; + int frame_ptrs = 0; + int stack_trace = 0; ++int disp_all = 0; + + #if defined (__i386__) + #if defined (__OpenBSD__) +@@ -243,12 +244,23 @@ void print_flags(uint64_t flags) + { + int i; + +- printf("flags: %08" PRIx64, flags); ++ printf("\nflags: %08" PRIx64, flags); + for (i = 21; i >= 0; i--) { + char *s = flag_values[i][(flags >> i) & 1]; + if (s != NULL) + printf(" %s", s); + } ++ printf("\n"); ++} ++ ++void print_special(unsigned long *regs, const char *name, unsigned int mask) ++{ ++ unsigned int i; ++ ++ printf("\n"); ++ for (i = 0; mask; mask >>= 1, ++i) ++ if (mask & 1) ++ printf("%s%u: " FMT_SIZE_T "\n", name, i, (size_t)regs[i]); + } + #endif + +@@ -257,12 +269,10 @@ void print_ctx(vcpu_guest_context_t *ctx + { + struct cpu_user_regs *regs = &ctx1->user_regs; + +- printf("eip: %08x ", regs->eip); ++ printf("cs:eip: %04x:%08x ", regs->cs, regs->eip); + print_symbol(regs->eip); + print_flags(regs->eflags); +- printf("\n"); +- +- printf("esp: %08x\n", regs->esp); ++ printf("ss:esp: %04x:%08x\n", regs->ss, regs->esp); + + printf("eax: %08x\t", regs->eax); + printf("ebx: %08x\t", regs->ebx); +@@ -273,47 +283,59 @@ void print_ctx(vcpu_guest_context_t *ctx + printf("edi: %08x\t", regs->edi); + printf("ebp: %08x\n", regs->ebp); + +- printf(" cs: %08x\t", regs->cs); +- printf(" ds: %08x\t", regs->ds); +- printf(" fs: %08x\t", regs->fs); +- printf(" gs: %08x\n", regs->gs); ++ printf(" ds: %04x\t", regs->ds); ++ printf(" es: %04x\t", regs->es); ++ printf(" fs: %04x\t", regs->fs); ++ printf(" gs: %04x\n", regs->gs); + ++ if (disp_all) { ++ print_special(ctx1->ctrlreg, "cr", 0x1d); ++ print_special(ctx1->debugreg, "dr", 0xcf); ++ } + } + #elif defined(__x86_64__) + void print_ctx(vcpu_guest_context_t *ctx1) + { + struct cpu_user_regs *regs = &ctx1->user_regs; + +- printf("rip: %08lx ", regs->rip); ++ printf("rip: %016lx ", regs->rip); + print_symbol(regs->rip); + print_flags(regs->rflags); +- printf("\n"); +- printf("rsp: %08lx\n", regs->rsp); +- +- printf("rax: %08lx\t", regs->rax); +- printf("rbx: %08lx\t", regs->rbx); +- printf("rcx: %08lx\t", regs->rcx); +- printf("rdx: %08lx\n", regs->rdx); +- +- printf("rsi: %08lx\t", regs->rsi); +- printf("rdi: %08lx\t", regs->rdi); +- printf("rbp: %08lx\n", regs->rbp); +- +- printf(" r8: %08lx\t", regs->r8); +- printf(" r9: %08lx\t", regs->r9); +- printf("r10: %08lx\t", regs->r10); +- printf("r11: %08lx\n", regs->r11); +- +- printf("r12: %08lx\t", regs->r12); +- printf("r13: %08lx\t", regs->r13); +- printf("r14: %08lx\t", regs->r14); +- printf("r15: %08lx\n", regs->r15); +- +- printf(" cs: %04x\t", regs->cs); +- printf(" ds: %04x\t", regs->ds); +- printf(" fs: %04x\t", regs->fs); +- printf(" gs: %04x\n", regs->gs); ++ printf("rsp: %016lx\n", regs->rsp); + ++ printf("rax: %016lx\t", regs->rax); ++ printf("rcx: %016lx\t", regs->rcx); ++ printf("rdx: %016lx\n", regs->rdx); ++ ++ printf("rbx: %016lx\t", regs->rbx); ++ printf("rsi: %016lx\t", regs->rsi); ++ printf("rdi: %016lx\n", regs->rdi); ++ ++ printf("rbp: %016lx\t", regs->rbp); ++ printf(" r8: %016lx\t", regs->r8); ++ printf(" r9: %016lx\n", regs->r9); ++ ++ printf("r10: %016lx\t", regs->r10); ++ printf("r11: %016lx\t", regs->r11); ++ printf("r12: %016lx\n", regs->r12); ++ ++ printf("r13: %016lx\t", regs->r13); ++ printf("r14: %016lx\t", regs->r14); ++ printf("r15: %016lx\n", regs->r15); ++ ++ printf(" cs: %04x\t", regs->cs); ++ printf(" ss: %04x\t", regs->ss); ++ printf(" ds: %04x\t", regs->ds); ++ printf(" es: %04x\n", regs->es); ++ ++ printf(" fs: %04x @ %016lx\n", regs->fs, ctx1->fs_base); ++ printf(" gs: %04x @ %016lx/%016lx\n", regs->gs, ++ ctx1->gs_base_kernel, ctx1->gs_base_user); ++ ++ if (disp_all) { ++ print_special(ctx1->ctrlreg, "cr", 0x1d); ++ print_special(ctx1->debugreg, "dr", 0xcf); ++ } + } + #elif defined(__ia64__) + +@@ -742,6 +764,8 @@ void usage(void) + #ifdef __ia64__ + printf(" -r LIST, --regs=LIST display more registers.\n"); + printf(" -a --all same as --regs=tlb,cr,ar,br,bk\n"); ++#else ++ printf(" -a --all display more registers\n"); + #endif + } + +@@ -811,6 +835,10 @@ int main(int argc, char **argv) + disp_bank_regs = 1; + disp_tlb = 1; + break; ++#else ++ case 'a': ++ disp_all = 1; ++ break; + #endif + case 'h': + usage(); diff --git a/xend-config.diff b/xend-config.diff index e4b201c..ebce0e7 100644 --- a/xend-config.diff +++ b/xend-config.diff @@ -1,7 +1,7 @@ -Index: xen-3.1-testing/tools/examples/init.d/sysconfig.xendomains +Index: xen-3.2-testing/tools/examples/init.d/sysconfig.xendomains =================================================================== ---- xen-3.1-testing.orig/tools/examples/init.d/sysconfig.xendomains -+++ xen-3.1-testing/tools/examples/init.d/sysconfig.xendomains +--- xen-3.2-testing.orig/tools/examples/init.d/sysconfig.xendomains ++++ xen-3.2-testing/tools/examples/init.d/sysconfig.xendomains @@ -1,4 +1,4 @@ -## Path: System/xen +## Path: System/Virtualization @@ -27,10 +27,10 @@ Index: xen-3.1-testing/tools/examples/init.d/sysconfig.xendomains ## Type: integer ## Default: 300 -Index: xen-3.1-testing/tools/examples/xend-config.sxp +Index: xen-3.2-testing/tools/examples/xend-config.sxp =================================================================== ---- xen-3.1-testing.orig/tools/examples/xend-config.sxp -+++ xen-3.1-testing/tools/examples/xend-config.sxp +--- xen-3.2-testing.orig/tools/examples/xend-config.sxp ++++ xen-3.2-testing/tools/examples/xend-config.sxp @@ -51,16 +51,19 @@ # # (9367 pam '' /etc/xen/xen-api.key /etc/xen/xen-api.crt) @@ -55,3 +55,57 @@ Index: xen-3.1-testing/tools/examples/xend-config.sxp #(xend-unix-path /var/lib/xend/xend-socket) +@@ -138,7 +141,52 @@ + # two fake interfaces per guest domain. To do things like this, write + # yourself a wrapper script, and call network-bridge from it, as appropriate. + # +-(network-script network-bridge) ++#(network-script network-bridge) ++ ++# network-multinet is a replacement for the Xen network-bridge, network-nat ++# and network-route scripts. network-multinet allows for the creation of ++# multiple networks, supporting the following types: ++# ++# ++# bridged: -Networks that contain both a physical network device (ethX) ++# and a virtual network device (vethX) from Dom0. ++# -This is the traditional type of network created in xen by ++# the basic network-bridge script. ++# -VMs on these network(s) appear to be on the real network(s) ++# ++# nohost: -Networks that contain a physical network device but not a ++# virtual network device from Dom0. ++# -These can be used to allow virtual machines to communicate ++# with the outside world but not with Dom0. ++# (Usefull if you want to isolate traffic away from Dom0) ++# ++# hostonly: -Networks that contain only a virtual network device (vethX) ++# from Dom0. ++# -This type of network will allow VMs connected to it to ++# access only Dom0 and other VMs connected to the network. ++# -This type of network is similiar to a VMware "HOST ONLY" ++# network. ++# ++# nat: -Networks that contain only a virtual network device (vethX) ++# from Dom0. ++# -This type of network will allow VMs connected to it to access ++# Dom0,the "outside world" via NAT and other VMs connected to it. ++# -This type of network is similiar to a VMware "NAT" network. ++# ++# routed: -Networks that contain only a virtual network device (vethX) ++# from Dom0. ++# -This type of network will allow VMs connected to it to access ++# Dom0,the "outside world" via routing through Dom0 and other VMs ++# connected to it. ++# ++# empty: -Networks that do not contain any physical or virtual network ++# devices from Dom0. ++# -These can be used to allow VMs in DomUs to communicate only ++# with other DomUs and not Dom0. ++# ++# See /etc/xen/scripts/network-multinet for more details. ++# ++(network-script network-multinet) + + # The script used to control virtual interfaces. This can be overridden on a + # per-vif basis when creating a domain or a configuring a new vif. The diff --git a/xmclone.sh b/xmclone.sh index 8d6a597..3124f75 100644 --- a/xmclone.sh +++ b/xmclone.sh @@ -1,29 +1,14 @@ -#! /bin/bash +#!/bin/bash +################################################################################ +# xmclone by Bob Brandt # +# based on XenClone by Glen Davis # +# Clone a SLES10 domU # +################################################################################ -# Script to clone Xen Dom-Us. -# Based on XenClone by Glen Davis; rewritten by Bob Brandt. -# Further extended and restructured by Manfred Hollstein. -# Copyright (C) 2007 Manfred Hollstein, SUSE / Novell Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 -# USA. - -# -# Defaults -# -VERSION=0.4.3 +################################################################################ +# Defaults # +# # +VERSION=0.3.1 XEN_CONFIGS=/etc/xen/vm/ XEN_BASE=/var/lib/xen/images/ SOURCE= @@ -32,407 +17,262 @@ DUPLICATE=0 HOSTNAME= IP= MAC= -PART=2 -DOMU_IS_FILE_BASED= -DOMU_ROOTDEV= -FORCE=no +################################################################################ -# -# Subroutines used in this script -# - -# Display the usage information for this script -function usage () +################################################################################ +# Subroutines used in this script # +# # +# Display the usage information for this script # +usage() { - cat << EOF -Usage: ${0##*/} [-h|--help] [-v|--version] [--force] [-c dir] [-b dir] [-d] - [-n hostname] [-i address] [-m address] - [-p number-of-root-partition-within-domU] - [-t target-device] - SourcedomU NewdomU - -Clones a domU, and gives a new Host name, MAC address and possibly IP address. -Once finished the new domU should boot without any additional configuration. -Currently works with single NIC, and basic bridge setup. Tested with cloning -a SLES10 install created from the SLES10 YaST Xen module. - - -h, --help Display this help message. - -v, --version Display the version of this program. - --force Silently overwrite files when destination already exists. - -c Xen configuration directory which defaults to: - $XEN_CONFIGS - -b Xen image base directory which defaults to: - $XEN_BASE - -d Duplicate only, do not modify attributes. - -n Hostname to be used, if not specified the NewdomU name - will be used. - -i IP address to be used, if not specified the IP address - will not be changed. - -m MAC address to be used, if not specified a psuedo-random - address will be used based on the ip address with the - format: 00:16:3e:BB:CC:DD - Where BB,CC,DD are the Hex octals of the IP address. - -p This script assumes that the second partition on any - writable disk of the domU to be cloned holds the root - file system in which attributes have to be changed. - If this is not the case for you, you can specify the - partition number using this flag. - -t If the SourcedomU uses a block device for its root/ - boot directory, you need to specify the new block - device for NewdomU. - -From XENSource Networking WIKI (http://wiki.xensource.com/xenwiki/XenNetworking) -Virtualised network interfaces in domains are given Ethernet MAC addresses. When -choosing MAC addresses to use, ensure you choose a unicast address. That is, one -with the low bit of the first octet set to zero. For example, an address -starting aa: is OK but ab: is not. -It is best to keep to the range of addresses declared to be "locally assigned" -(rather than allocated globally to hardware vendors). These have the second -lowest bit set to one in the first octet. For example, aa: is OK, a8: isn't. - -Exit status is 0 if OK, 1 if minor problems, 2 if serious trouble. -EOF + echo -e "\nUsage: ${0##*/} [-h|?|--help] [-v|--version] [-c dir] [-b dir] [-d]" + echo -e " [-n hostname] [-i address] [-m address]" + echo -e " SourcedomU NewdomU\n" + echo -e "Clones a domU, and gives a new Host name, MAC address and possibly IP address." + echo -e "Once finished the new domU should boot without any additional configuration." + echo -e "Currently works with single NIC, and basic bridge setup. Tested with cloning" + echo -e "a SLES10 install created from the SLES10 YaST Xen module.\n" + echo -e " -h, -?, --help Display this help message." + echo -e " -v, --version Display the version of this program." + echo -e " -c XEN configuration directory which defaults to:" + echo -e " $XEN_CONFIGS" + echo -e " -b XEN image base directory which defaults to:" + echo -e " $XEN_BASE" + echo -e " -d Only Duplicate, do not modify attributes." + echo -e " -n Hostname to be used, if not specified the NewdomU name" + echo -e " will be used." + echo -e " -i IP address to be used, if not specified the IP address" + echo -e " will not be changed." + echo -e " -m MAC address to be used, if not specified a psuedo-random" + echo -e " address will be used based on the ip address with the" + echo -e " format: 00:16:AA:BB:CC:DD" + echo -e " Where AA,BB,CC,DD are the Hex octals of the IP address." + echo -e "From XENSource Networking WIKI (http://wiki.xensource.com/xenwiki/XenNetworking)" + echo -e "Virtualised network interfaces in domains are given Ethernet MAC addresses. When" + echo -e "choosing MAC addresses to use, ensure you choose a unicast address. That is, one" + echo -e "with the low bit of the first octet set to zero. For example, an address" + echo -e "starting aa: is OK but ab: is not." + echo -e 'It is best to keep to the range of addresses declared to be "locally assigned"' + echo -e "(rather than allocated globally to hardware vendors). These have the second" + echo -e "lowest bit set to one in the first octet. For example, aa: is OK, a8: isn't.\n" + echo -e "Exit status is 0 if OK, 1 if minor problems, 2 if serious trouble.\n" } - -# Display the version information for this script -function version () +# Display the version information for this script # +version() { - cat << EOF -${0##*/} (Xen VM clone utility) $VERSION -${0##*/} comes with ABSOLUTELY NO WARRANTY. -This is free software, and you are welcome to redistribute it under the terms -of the GNU General Public License . - -Written by Manfred Hollstein, based on work by Glen Davis and Bob Brandt. -EOF + echo -e "${0##*/} (XEN vm clone utility) $VERSION" + echo -e "This is free software. You may redistribute copies of it under the terms of" + echo -e "the GNU General Public License ." + echo -e "There is NO WARRANTY, to the extent permitted by law.\n" + echo -e "Written by Bob Brandt, based on work by Glen Davis." } - -# Find/Replace text within a file -function replace () +# Find/Replace text within a file # +replace() { - sed -i -e "s!$1!$2!g" "$3" -} - -# -# Find the first entry that names a writable image or device, assuming -# the Dom-U is going to boot from it: -# -function get_first_writable_image () -{ - local i - - for i in $@ - do - case $i in - # Match the first entry like "'phy:/dev/md0,xvda,w'," - *",w'," ) - # Strip off the leading "'" character: - i="${i#*\'}" - # Strip off the final trailing "'," - echo "${i%*\',}" - return - ;; - esac - done -} - -# -# Extract just the protocol and the file/device name part from a disk entry: -# -function extract_proto_and_filename () -{ - echo "$1" | cut -d, -f1 + sed -i -e "s/$1/$2/g" "$3" } +################################################################################ -# -# Make sure this script is run by the superuser root -# -if [ `id -u` -ne 0 ] -then - echo "You must be root to run this script!" >&2 +################################################################################ +# Make sure the user is root # +# # +if [ `id -u` -ne 0 ]; then + echo -e "You must be root to run this script!\n" exit 1 fi +################################################################################ -# -# Process the parameters -# -# Must look for double -- arguments before calling getopts -# -if [ "$1" = "--version" ] -then +################################################################################ +# Process the parameters # +# # +# Must look for double -- arguments before getopts +if [ "$1" = "--version" ]; then version exit 0 fi -if [ "$1" = "--help" ] -then +if [ "$1" = "--help" ]; then usage exit 0 fi -if [ "$1" = "--force" ] -then - FORCE=yes - shift -fi -while getopts ":b:c:dhi:m:n:p:t:v" opt -do +while getopts ":hvc:b:dn:i:m:" opt; do case $opt in - b ) - XEN_BASE=$OPTARG - ;; - c ) - XEN_CONFIGS=$OPTARG - ;; - d ) - DUPLICATE=1 - ;; - h ) - usage - exit 1 - ;; - i ) - IP=$OPTARG - ;; - m ) - MAC=$OPTARG - ;; - n ) - HOSTNAME=$OPTARG - ;; - p ) - PART=$OPTARG - ;; - t ) - DOMU_ROOTDEV=$OPTARG - ;; - v ) - version - exit 0 - ;; + h | \? ) + usage + exit 0;; + v ) + version + exit 0;; + c ) XEN_CONFIGS=$OPTARG;; + b ) XEN_BASE=$OPTARG;; + d ) DUPLICATE=1;; + n ) HOSTNAME=$OPTARG;; + i ) IP=$OPTARG;; + m ) MAC=$OPTARG;; esac done shift $(($OPTIND-1)) -if [ $# -ne 2 ] -then - echo "Illegal number of arguments passed!" >&2 - echo "" >&2 - usage - exit 1 -fi - SOURCE=$1 DESTINATION=$2 +################################################################################ -# -# Verify the Source and Destination parameters -# -# The source and destination should be relative directory names without -# trailing /'s. If the source does have a full path, use that path as the -# value for XEN_BASE. Otherwise remove all but the last part of the path -# for both source and destination -# +################################################################################ +# Verify the Source and Destination parameters # +# # +# The source and destination should be relative directory names without trailing /'s +# If the source does have a full path, use that path as the XEN_BASE +# Otherwise remove all but the last part of the path for both source and destination SOURCEDIR=${SOURCE%/*} SOURCEBASE=${SOURCE##*/} -if [ "$SOURCEDIR" != "$SOURCEBASE" ] -then +if [ "$SOURCEDIR" != "$SOURCEBASE" ]; then XEN_BASE=$SOURCEDIR"/" SOURCE=$SOURCEBASE fi SOURCE=${SOURCE##*/} DESTINATION=${DESTINATION##*/} +################################################################################ -# -# Verify the Xen Config and Source parameters -# -# Verify the validity of each argument, ask the user if there is a problem -while [ ! -d "$XEN_CONFIGS" ] -do - cat << EOF >&2 -$XEN_CONFIGS either does not exist or is not a directory. -Please enter a valid directory. -EOF - read -e -p "Xen Configuration Directory? " XEN_CONFIGS +################################################################################ +# Verify the XEN Config and Source parameters # +# # +# Directories should have a / after them # +if [ "$XEN_CONFIGS" != "" ]; then + XEN_CONFIGS="${XEN_CONFIGS%/}/" +fi +if [ "$XEN_BASE" != "" ]; then + XEN_BASE="${XEN_BASE%/}/" +fi +# Verify the validity of each argument ask the user if there is a problem +while [ ! -d "$XEN_CONFIGS" ]; do + echo -e "\nThe $XEN_CONFIGS directory does not exist. Please enter a valid directory." + read -p "XEN Configuration Directory? " XEN_CONFIGS done -while [ ! -d "$XEN_BASE" ] -do - cat << EOF >&2 -$XEN_BASE either does not exist or is not a directory. -Please enter a valid directory. -EOF - read -e -p "Xen Image Base Directory? " XEN_BASE +while [ ! -d "$XEN_BASE" ]; do + echo -e "\nThe $XEN_BASE directory does not exist. Please enter a valid directory." + read -p "XEN Image Base Directory? " XEN_BASE done - -# -# Directories should have a / after them -# -[ "$XEN_CONFIGS" != "" ] && XEN_CONFIGS="${XEN_CONFIGS%/}/" -[ "$XEN_BASE" != "" ] && XEN_BASE="${XEN_BASE%/}/" +################################################################################ -# -# Verify that actual image and configuration file exist -# -while : -do - if [ ! -f "$XEN_CONFIGS$SOURCE" ] - then - echo "The $XEN_CONFIGS$SOURCE file does not exist." >&2 - echo "Please select a valid file." >&2 +################################################################################ +# Verify that actual image and configuration file exist # +# # +while [ ! -d "$XEN_BASE$SOURCE" ] || [ ! -f "$XEN_CONFIGS$SOURCE" ]; do + if [ ! -d "$XEN_BASE$SOURCE" ]; then + echo -e "The directory $XEN_BASE$SOURCE is invalid, please select another." FILES= - for FILE in `ls $XEN_CONFIGS` - do - # If the entry is a file - [ -f "$XEN_CONFIGS$FILE" ] && - FILES="$FILES $XEN_CONFIGS$FILE" - done - if [ -z "$FILES" ] - then - echo "There are no suitable files beneath $XEN_CONFIGS" >&2 - exit 1 - fi - echo "Files beneath $XEN_CONFIGS" - select FILE in $FILES - do - if [ -f "$FILE" ] - then - SOURCE=${FILE##*/} - break - fi - echo "Invalid Selection." >&2 - done - else - # - # Figure out what type of image we're using: - # - BOOTENTRY=$(get_first_writable_image $(sed -n -e 's,^disk[ ]*=[ ]*\[\(.*\)\],\1,p' "$XEN_CONFIGS$SOURCE")) - case "$BOOTENTRY" in - phy:* ) - DOMU_IS_FILE_BASED=no - ;; - file:* | \ - tap:aio:* ) - DOMU_IS_FILE_BASED=yes - ;; - * ) - echo "Don't know how to deal with the boot protocol/device you appear to be using: $BOOTENTRY" >&2 - echo "These are the ones this script supports: \"phy:*\", \"file:*\", \"tap:aio:*\"" >&2 - exit 1 - ;; - esac - fi + tmpFILES=`ls $XEN_BASE` - - if [ ${DOMU_IS_FILE_BASED} = yes ] - then - if [ ! -d "$XEN_BASE$SOURCE" ] - then - echo "The directory $XEN_BASE$SOURCE is invalid." >&2 - echo "Please select another one." >&2 - FILES= - for FILE in `ls $XEN_BASE` - do - # If the entry is a directory and - # it is not empty - [ -d "$XEN_BASE$FILE" ] && - [ "`ls $XEN_BASE$FILE`" != "" ] && - FILES="$FILES $XEN_BASE$FILE" - done - if [ -z "$FILES" ] - then - echo "There are no suitable directories beneath $XEN_BASE" >&2 - exit 1 + for FILE in $tmpFILES; do + # If the Entry is a Directory + if [ -d "$XEN_BASE$FILE" ]; then + # And if that Directory is not empty + if [ "`ls $XEN_BASE$FILE`" != "" ]; then + FILES="$FILES $XEN_BASE$FILE" + fi fi - echo "Directories beneath $XEN_BASE" - select FILE in $FILES - do - if [ -d "$FILE" ] - then + done + if [ "$FILES" = "" ]; then + echo -e "There are no directories beneath $XEN_BASE" + exit 1 + else + echo -e "Directories beneath $XEN_BASE" + select FILE in $FILES; do + if [ "$FILE" ]; then SOURCE=${FILE##*/} break + else + echo -e "Invalid Selection." fi - echo "Invalid Selection." >&2 done - continue fi - break + fi - else # DomU is using some block device - while [ ! -b "${DOMU_ROOTDEV}" ] || [ ! -w "${DOMU_ROOTDEV}" ] - do - read -e -p "You need to specify a valid block device for the new target DomU: " DOMU_ROOTDEV + if [ ! -f "$XEN_CONFIGS$SOURCE" ]; then + echo -e "\nThe $XEN_CONFIGS$SOURCE file does not exist. Please select a valid file." + FILES= + tmpFILES=`ls $XEN_CONFIGS` + + for FILE in $tmpFILES; do + # If the Entry is a File + if [ -f "$XEN_CONFIGS$FILE" ]; then + FILES="$FILES $XEN_CONFIGS$FILE" + fi done - break - - fi -done -BOOTIMAGE="$(echo $BOOTENTRY | awk -F : '{ print $NF }' | sed -e 's:,[^,]*,[^,]*$::')" - - -# -# Verify that the destination location does not already have an image or -# config file -# -while [ -z "$DESTINATION" ] -do - echo "You have not specified a Destination." >&2 - read -e -p "New Destination? " DESTINATION -done -while : -do - if [ -f "$XEN_CONFIGS$DESTINATION" ] && [ $FORCE = no ] - then - echo "The target configuration file $XEN_CONFIGS$DESTINATION already exists!" >&2 - read -e -p "Please select a new Destination? " DESTINATION - fi - if [ ${DOMU_IS_FILE_BASED} = yes ] - then - if [ -d "$XEN_BASE$DESTINATION" ] && [ $FORCE = no ] - then - echo "The target image location $XEN_BASE$DESTINATION already exists!" >&2 - read -p "Please select a new Destination? " DESTINATION - continue + if [ "$FILES" = "" ]; then + echo -e "There are no files beneath $XEN_CONFIGS" + exit 1 + else + echo -e "Files beneath $XEN_CONFIGS" + select FILE in $FILES; do + if [ "$FILE" ]; then + SOURCE=${FILE##*/} + break + else + echo -e "Invalid Selection." + fi + done fi fi - break +done +################################################################################ + + +################################################################################ +# That the destination location does not already have a image or config file # +# # +while [ "$DESTINATION" == "" ]; do + echo -e "\nYou have not specified a Destination." + read -p "New Destination? " DESTINATION done - -# -# Verify the network parameters (if Duplicate Only was not selected) -# -if [ $DUPLICATE -eq 0 ] -then - if [ -z "$HOSTNAME" ] - then - echo "You have not entered a host name. If you wish to, enter one now." >&2 - read -p "New host name? (Default: $DESTINATION) " HOSTNAME +while [ -d "$XEN_BASE$DESTINATION" ] || [ -f "$XEN_CONFIGS$DESTINATION" ]; do + if [ -d "$XEN_BASE$DESTINATION" ]; then + echo -e "The image location $XEN_BASE$DESTINATION already exists!" + read -p "Please select a new Destination? " DESTINATION fi - [ -z "$HOSTNAME" ] && HOSTNAME=$DESTINATION + if [ -f "$XEN_CONFIGS$DESTINATION" ]; then + echo -e "The configuration file $XEN_CONFIGS$DESTINATION already exists!" + read -p "Please select a new Destination? " DESTINATION + fi +done +################################################################################ - if [ -z "$IP" ] - then - echo "You have not specified an IP Address. If you wish to change the IP address, enter one now." + +################################################################################ +# Verify the network parameters (if Duplicate Only was not selected) # +# # +if [ "$DUPLICATE" == "0" ]; then + if [ "$HOSTNAME" == "" ]; then + echo -e "\nYou have not entered a Host Name. If you wish to, enter one now." + read -p "New Host Name? (Default: $DESTINATION) " HOSTNAME + fi + if [ "$HOSTNAME" == "" ]; then + HOSTNAME=$DESTINATION + fi + + if [ "$IP" == "" ]; then + echo -e "\nYou have not specified an IP Address. If you wish to change the IP address, enter one now." read -p "New IP Address? " IP fi - while [ -n "$IP" ] && [ "${IP/*.*.*.*/ok}" != "ok" ] - do - echo "The IP Address you specified is invalid. If you wish, enter a new one now." + while [ "$IP" != "" ] && [ "${IP/*.*.*.*/ok}" != "ok" ]; do + echo -e "\nThe IP Address you specified is invalid. If you wish, enter a new one now." read -p "New IP Address? " IP - [ -z "$IP" ] && break + if [ "$IP" == "" ]; then + break + fi done - if [ -z "$MAC" ] - then + if [ "$MAC" == "" ]; then newMAC="" newMACtext="(format 01:23:45:67:89:AB)" # If the IP Address is specified and the MAC isn't, generate one. - if [ -n "$IP" ] - then + if [ "$IP" != "" ]; then octal1=${IP%%.*} IP=${IP#*.} octal2=${IP%%.*} @@ -440,269 +280,290 @@ then octal3=${IP%%.*} octal4=${IP#*.} IP="$octal1.$octal2.$octal3.$octal4" - octal1="00"`echo $octal1 16 o p | dc | tr '[:upper:]' '[:lower:]'` - octal2="00"`echo $octal2 16 o p | dc | tr '[:upper:]' '[:lower:]'` - octal3="00"`echo $octal3 16 o p | dc | tr '[:upper:]' '[:lower:]'` - octal4="00"`echo $octal4 16 o p | dc | tr '[:upper:]' '[:lower:]'` - newMAC="00:16:3e:"${octal2:(-2)}":"${octal3:(-2)}":"${octal4:(-2)} + octal1="00"`echo $octal1 16 o p | dc` + octal2="00"`echo $octal2 16 o p | dc` + octal3="00"`echo $octal3 16 o p | dc` + octal4="00"`echo $octal4 16 o p | dc` + newMAC="00:16:"${octal1:(-2)}":"${octal2:(-2)}":"${octal3:(-2)}":"${octal4:(-2)} newMACtext="(default $newMAC)" fi - echo "You have not specified a MAC Address. If you wish to change the MAC address, enter one now." + echo -e "\nYou have not specified a MAC Address. If you wish to change the MAC address, enter one now." read -p "New MAC Address? $newMACtext " MAC - [ -z "$MAC" ] && MAC=$newMAC + if [ "$MAC" == "" ]; then + MAC=$newMAC + fi fi - - while [ "$MAC" != "" ] && [ "${MAC/[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]/ok}" != "ok" ] - do - echo "The MAC Address you specified is invalid. If you wish, enter a new one now." - read -p "New MAC Address? (format 01:23:45:67:89:AB) " MAC - [ -z "$MAC" ] && break + + while [ "$MAC" != "" ] && [ "${MAC/[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]/ok}" != "ok" ]; do + echo -e "\nThe MAC Address you specified is invalid. If you wish, enter a new one now." + read -p "New MAC Address? (format 01:23:45:67:89:AB) " MAC + if [ "$MAC" == "" ]; then + break + fi done else HOSTNAME= IP= MAC= fi +################################################################################ -# -# Make sure that the source VM is not running -# +################################################################################ +# Make sure that the source VM is not running # +# # xmid=`xm domid "$SOURCE" 2>/dev/null` -if [ $? -eq 0 ] && [ -n "$xmid" ] && [ -z "${xmid//[[:digit:]]/}" ] -then - echo "domU $SOURCE is currently running on Xen, please shutdown before cloning." >&2 - echo "The command \"xm shutdown $xmid -w\" will shutdown the domU" >&2 +if [ $? -eq 0 ] && [ -n "$xmid" ] && [ -z "${xmid//[[:digit:]]/}" ] ; then + echo -e "domU $SOURCE is currently running on Xen, please shutdown before cloning." + echo -e "The command \"xm shutdown $xmid -w\" will shutdown the domU" exit 1 fi +################################################################################ -# -# Copy the Xen Config file -# +################################################################################ +# Copy the XEN Config file # +# # SOURCECONFIG="$XEN_CONFIGS$SOURCE" DESTCONFIG="$XEN_CONFIGS$DESTINATION" -echo "Copying Configuration files" +echo -e "Copying Configuration files" if ! cp -fv "$SOURCECONFIG" "$DESTCONFIG" then - echo "The Config file $SOURCECONFIG could not be copied to $DESTCONFIG" >&2 + echo -e "The Config file $SOURCECONFIG was unable to be copied to $DESTCONFIG" exit 1 fi +################################################################################ -# -# Edit newly copied configuration file -# -echo "Editing config file ($DESTCONFIG), correcting the new domU Name." +################################################################################ +# Edit newly copied configuration file # +# # +echo -e "Editing config file ($DESTCONFIG), correcting the new domU Name." if ! replace "$SOURCE" "$DESTINATION" "$DESTCONFIG" then - echo "Unable to change the domU name in $DESTCONFIG from $SOURCE to $DESTINATION" >&2 + echo -e "Unable to change the domU name in $DESTCONFIG from $SOURCE to $DESTINATION" exit 1 fi -if [ $DUPLICATE -eq 0 ] -then - oldUUID=`grep "^uuid[ ]*=.*$" $DESTCONFIG` - if [ x"${oldUUID}" = x ] - then - echo 'uuid="'`uuidgen`'"' >> $DESTCONFIG - else - sed -i -e 's,^uuid[ ]*=.*$,uuid="'`uuidgen`'",' $DESTCONFIG - fi -fi - -if [ $DUPLICATE -eq 0 ] && [ -n "$MAC" ] -then +if [ "$DUPLICATE" == "0" ] && [ "$MAC" != "" ]; then # Get the vif line in the config file - oldMAC=`grep "vif[ ]*=[ ]*" $DESTCONFIG` + oldMAC=`grep "vif = " $DESTCONFIG` # extract everything between the square brackets oldMAC=${oldMAC#*[} oldMAC=${oldMAC%*]} - # using the single quotes as delimiters, get the second field - # (this script can only deal with one adapter!) + # using the single quotes as delimiters, get the second field (this script can only deal with one adapter!) oldMAC=`echo "$oldMAC" | cut -f2 -d\'` # remove the mac= from the beginning oldMAC=${oldMAC#mac=*} if ! replace "$oldMAC" "$MAC" "$DESTCONFIG" then - echo "Unable to change the MAC address in $DESTCONFIG from ($oldMAC) to ($MAC)" >&2 + echo -e "Unable to change the MAC address in $DESTCONFIG from ($oldMAC) to ($MAC)" exit 1 fi fi +################################################################################ -# -# Create and Copy image directory -# - -if [ $DOMU_IS_FILE_BASED = yes ] +################################################################################ +# Create and Copy image directory # +# # +SOURCEXEN="$XEN_BASE$SOURCE/" +DESTXEN="$XEN_BASE$DESTINATION/" +echo -e "Creating the new image directory $DESTXEN" +if ! mkdir -pv --mode=775 "$DESTXEN" then - SOURCEXEN="$XEN_BASE$SOURCE/" - DESTXEN="$XEN_BASE$DESTINATION/" - echo "Creating the new image directory $DESTXEN" - if ! mkdir -pv --mode=755 "$DESTXEN" - then - echo "Unable to create the directory $DESTXEN" >&2 - exit 1 - fi - echo "Copying complete image. (This may take a few minutes!)" + echo -e "Unable to create the directory $DESTXEN" + exit 1 +fi +echo -e "Copying complete image. (This may take a few minutes!)" - tar -C $SOURCEXEN -cSf - --exclude=lost+found `cd $SOURCEXEN; echo *` \ - | tar -C $DESTXEN -xvBSpf - - if [ $? -ne 0 ] +if ! cp -fv $SOURCEXEN* $DESTXEN +then + echo -e "Unable to copy the images from $SOURCEXEN to $DESTXEN" + exit 1 +fi +################################################################################ + + +# The rest of the document only applies if we are change the values within the image +if [ "$DUPLICATE" == "0" ] && [ "$MAC" != "" ]; then + ############################################################################ + # Mount the newly copied image file # + # # + # Find a temporary directory name + tmpdir="/mnt/xentmp" + declare -i a=0 + while [ -d "$tmpdir$a" ]; do + a=a+1 + done + tmpdir="$tmpdir$a" + if ! mkdir -pv "$tmpdir" then - echo "Unable to copy the images from $SOURCEXEN to $DESTXEN" >&2 + echo -e "Unable to create $tmpdir Directory." exit 1 fi -else # Deal with block devices - if [ $DUPLICATE -eq 0 ] + + # Get the vif line in the config file + DISKIMAGE=`grep "disk = " $DESTCONFIG` + # extract everything between the square brackets + DISKIMAGE=${DISKIMAGE#*[} + DISKIMAGE=${DISKIMAGE%*]} + # extract the first entry that is a file + DISKIMAGE=${DISKIMAGE#*file:*} + # remove the end of the entry + DISKIMAGE=${DISKIMAGE%,w*} + # using the comma as delimiter, get the second field (this script assumes that the first file entry is the boot disk!) + DISKIMAGE=`echo "$DISKIMAGE" | cut -f2 -d\,` + + # Get the vif line in the config file + PARTITION=`grep "bootentry = " $DESTCONFIG` + # using the single quotes as delimiters, extract the data + PARTITION=`echo "$PARTITION" | cut -f2 -d\'` + # using the comma as delimiter, extra the boot partition information + PARTITION=`echo "$PARTITION" | cut -f1 -d\,` + PARTITION=${PARTITION%:*} + PARTITION=${PARTITION#$DISKIMAGE*} + + if ! lomount -diskimage "$DESTXEN$DISKIMAGE" -partition $PARTITION "$tmpdir" then - echo "Editing config file ($DESTCONFIG), correcting the new domU root device name." - if ! replace ":$BOOTIMAGE," ":$DOMU_ROOTDEV," "$DESTCONFIG" + echo -e "Unable to mount newly copied image $DESTXEN$DISKIMAGE at $tmpdir" + exit 1 + fi + ############################################################################ + + + ############################################################################ + # Change the Network Configuration in the mounted image file # + # # + sleep 1 + pushd "$tmpdir" + if [ "$MAC" != "" ]; then + echo -e "Changing the Network configuration in the newly copied image." + cd "$tmpdir/etc/sysconfig/network/" + sleep 1 + # Make a backup of the old eth config files in ./othether directory + if mkdir -pv ./oldether/ then - echo "Unable to change the domU root device name in $DESTCONFIG from $BOOTIMAGE to $DOMU_ROOTDEV" >&2 + cp -fv ifcfg-eth* ./oldether/ + fi + + # Find the ifcfg-ethMACADDRESS file in the newly copied image + ETH0=`ls | grep ifcfg-eth | cut -f1` + if [ "$ETH0" = "" ]; then + echo -e "Unable to find ethernet file in image file" + exit 1 + fi + # Rename the file to ifcfg-eth0 (if it has not already been done. + # Then delete all the other config files + if [ "$ETH0" != "ifcfg-eth0" ]; then + if mv -f "$ETH0" ifcfg-eth0 + then + rm -fv ifcfg-eth-id* + fi + fi + + # Make sure that the ifcfg-eth0 file exists, since everything depends on it! + if [ ! -f "ifcfg-eth0" ]; then + echo -e "Unable to create /etc/sysconfig/network/ifcfg-eth0 file!" + exit 1 + fi + + # The 30-net_persistent_names.rules file controls which interface to use. + # Be removing the SUBSYSTEM line, we force the system to recreate it. + cd "$tmpdir/etc/udev/rules.d/" + cp -fv 30-net_persistent_names.rules 30-net_persistent_names.rules.old + grep -v SUBSYSTEM 30-net_persistent_names.rules > 30-net_persistent_names.rules.tmp + if ! mv -f 30-net_persistent_names.rules.tmp 30-net_persistent_names.rules + then + echo -e "Unable to modify the /etc/udev/rules.d/30-net_persistent_names.rules file." exit 1 fi fi - echo "Copying from source block device ($BOOTIMAGE) to the new target device ($DOMU_ROOTDEV)" - echo "(This may take a few minutes!)" - if ! dd if=$BOOTIMAGE of=$DOMU_ROOTDEV - then - echo "Failed to copy from $BOOTIMAGE to $DOMU_ROOTDEV" >&2 - exit 1 + ############################################################################ + + + ############################################################################ + # Change the IP Address in the mounted image file # + # # + if [ "$IP" != "" ]; then + + echo -e "Modify the IP Address of the new domU." + cd "$tmpdir/etc/sysconfig/network/" + sleep 1 + + # Make sure that the ifcfg-eth0 file exists, since everything depends on it! + if [ ! -f "ifcfg-eth0" ]; then + echo -e "Unable to find /etc/sysconfig/network/ifcfg-eth0 file!" + exit 1 + fi + + # Make a copy every line of the ifcfg-eth0 file except the IPADDR line. + grep -v IPADDR ifcfg-eth0 > ifcfg-eth0.xentmp + sleep 1 + + # Then add a new IPADDR line with the new IP address + echo 'IPADDR="'$IP'"' >> ifcfg-eth0.xentmp + sleep 1 + + if ! mv ifcfg-eth0.xentmp ifcfg-eth0 + then + echo -e "unable to modify the IP address in /etc/sysconfig/network/ifcfg-eth0" + exit 1 + fi + fi + ############################################################################ + + + ############################################################################ + # Change the HOSTNAME and hosts files in the mounted image file # + # # + if [ "$HOSTNAME" != "" ]; then + echo -e "Changing HOSTNAME file to $HOSTNAME." + cd "$tmpdir/etc" + # using the period as a delimter, select the first column for the hostname + oldHOSTNAME=`cat "$tmpdir/etc/HOSTNAME" | cut -f1 -d\.` + sleep 1 + + if ! replace "$oldHOSTNAME" "$HOSTNAME" "HOSTNAME" + then + echo -e "Unable to change the HOSTNAME from $oldHOSTNAME to $HOSTNAME" + exit 1 + fi + FQDN=`cat HOSTNAME` + + echo -e "Changing hosts file." + + cp -fv hosts hosts.old + if grep -v $oldHOSTNAME hosts > hosts.xentmp + then + echo "$IP\t$FQDN\t$HOSTNAME" >> hosts.xentmp + fi + + if [ ! -f hosts.xentmp ]; then + echo -e "Unable to change the hosts file" + exit 1 + fi + if ! mv -f hosts.xentmp hosts + then + echo -e "Unable to change the hosts file" + exit 1 + fi + fi + ############################################################################ + + + ############################################################################ + # Umount image file and remove temporary directory # + # # + popd > /dev/null + sleep 1 + umount "$tmpdir" + sleep 1 + rm -r "$tmpdir" + ############################################################################ fi - -# -# The rest of the script only applies if we are actually making changes within -# the image -# -if [ $DUPLICATE -eq 0 ] -then - # - # Create a temporary directory name - # - tmpdir=$(mktemp -d) - if [ $? -ne 0 ] - then - echo "Unable to create temporary directory $tmpdir." >&2 - exit 1 - fi - - if [ $DOMU_IS_FILE_BASED = yes ] - then - set -- $(echo $DESTXEN*) - else - set -- $(echo $DOMU_ROOTDEV) - fi - - for DISKIMAGE - do - # Silently ignore any directories (lost+found comes to mind): - [ -d $DISKIMAGE ] && continue - - # - # Mount the newly copied image file - # - echo -n "Trying to mount partition $PART of $DISKIMAGE ... " - lomount -diskimage "$DISKIMAGE" -partition $PART "$tmpdir" \ - || continue - echo "succeeded." - - pushd "$tmpdir" > /dev/null - - # - # Change the Network Configuration in the mounted image file - # - if [ -n "$MAC" ] - then - if [ -d etc/sysconfig/network/ ] - then - echo "Changing the Network configuration in the newly copied image." - pushd "etc/sysconfig/network/" > /dev/null - # Find the ifcfg-ethMACADDRESS file in the - # newly copied image - ETH0=`ls | grep ifcfg-eth | cut -f1` - if [ -z "$ETH0" ] - then - echo "Unable to find ethernet file in image file" 2>&1 - cd /tmp; umount "$tmpdir"; rmdir "$tmpdir" - exit 1 - fi - mv -f "$ETH0" ifcfg-eth-id-$MAC - popd > /dev/null - fi - - if [ -d etc/udev/rules.d/ ] - then - # The 30-net_persistent_names.rules file - # controls which interface to use. - # By removing the SUBSYSTEM== lines, we force - # the system to recreate it. - pushd "etc/udev/rules.d/" > /dev/null - sed -i -e "/SUBSYSTEM==/d" \ - 30-net_persistent_names.rules - popd > /dev/null - fi - fi - - # - # Change the IP Address in the mounted image file - # - if [ -n "$IP" ] - then - if [ -d etc/sysconfig/network/ ] - then - echo "Modify the IP Address of the new domU." - - pushd "etc/sysconfig/network/" > /dev/null - sed -i -e "s,^IPADDR=.*$,IPADDR=$IP," \ - ifcfg-eth-id-$MAC - popd > /dev/null - fi - fi - - # - # Change the HOSTNAME and hosts files in the mounted image file - # - if [ -n "$HOSTNAME" ] - then - if [ -d "etc/" ] - then - echo "Changing HOSTNAME file to $HOSTNAME." - - pushd "etc/" > /dev/null - # using the period as a delimiter, select the - # first entry for the hostname - oldHOSTNAME=`cut -f1 -d\. HOSTNAME` - if ! replace "$oldHOSTNAME" "$HOSTNAME" "HOSTNAME" - then - echo "Unable to change the HOSTNAME from $oldHOSTNAME to $HOSTNAME" >&2 - cd /tmp; umount "$tmpdir"; rmdir "$tmpdir" - exit 1 - fi - FQDN=`cat HOSTNAME` - - # Add entries for the new domU to /etc/hosts, - # if it doesn't already include them: - if ! egrep -q "[[:space:]]$FQDN[^[:alnum:]]" \ - hosts - then - echo "Changing hosts file." - echo -e "$IP\t$FQDN $HOSTNAME" >> hosts - fi - popd > /dev/null - fi - fi - - popd > /dev/null - umount "$tmpdir" - done - - rmdir "$tmpdir" -fi - -echo "Clone is complete. domU $DESTCONFIG is ready to start!" +echo -e "Clone is complete. domU $DESTCONFIG is ready to start!" exit 0