diff --git a/25861-x86-early-fixmap.patch b/25861-x86-early-fixmap.patch deleted file mode 100644 index ffbc89c..0000000 --- a/25861-x86-early-fixmap.patch +++ /dev/null @@ -1,234 +0,0 @@ -# HG changeset patch -# User Jan Beulich -# Date 1347371120 -7200 -# Node ID 51c2d7c83cbc2a0357ce112a463f91d354dcdba9 -# Parent e4cb8411161043c726f699252cc761e77853e820 -x86: allow early use of fixmaps - -As a prerequisite for adding an EHCI debug port based console -implementation, set up the page tables needed for (a sub-portion of) -the fixmaps together with other boot time page table construction. - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser - -Index: xen-4.2.2-testing/xen/arch/x86/boot/head.S -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/boot/head.S -+++ xen-4.2.2-testing/xen/arch/x86/boot/head.S -@@ -3,6 +3,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -136,6 +137,9 @@ __start: - add $8,%edx - add $(1< - #include - #include -+#define __ASSEMBLY__ /* avoid pulling in ACPI stuff (conflicts with EFI) */ -+#include -+#undef __ASSEMBLY__ - #include - #include - #include -@@ -1123,14 +1126,19 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY - slot &= L2_PAGETABLE_ENTRIES - 1; - l2_bootmap[slot] = l2e_from_paddr(addr, __PAGE_HYPERVISOR|_PAGE_PSE); - } -+ /* Initialise L2 fixmap page directory entry. */ -+ l2_fixmap[l2_table_offset(FIXADDR_TOP - 1)] = -+ l2e_from_paddr((UINTN)l1_fixmap, __PAGE_HYPERVISOR); - /* Initialise L3 identity-map page directory entries. */ - for ( i = 0; i < ARRAY_SIZE(l2_identmap) / L2_PAGETABLE_ENTRIES; ++i ) - l3_identmap[i] = l3e_from_paddr((UINTN)(l2_identmap + - i * L2_PAGETABLE_ENTRIES), - __PAGE_HYPERVISOR); -- /* Initialise L3 xen-map page directory entry. */ -+ /* Initialise L3 xen-map and fixmap page directory entries. */ - l3_xenmap[l3_table_offset(XEN_VIRT_START)] = - l3e_from_paddr((UINTN)l2_xenmap, __PAGE_HYPERVISOR); -+ l3_xenmap[l3_table_offset(FIXADDR_TOP - 1)] = -+ l3e_from_paddr((UINTN)l2_fixmap, __PAGE_HYPERVISOR); - /* Initialise L3 boot-map page directory entries. */ - l3_bootmap[l3_table_offset(xen_phys_start)] = - l3e_from_paddr((UINTN)l2_bootmap, __PAGE_HYPERVISOR); -Index: xen-4.2.2-testing/xen/arch/x86/mm.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/mm.c -+++ xen-4.2.2-testing/xen/arch/x86/mm.c -@@ -131,6 +131,10 @@ - l1_pgentry_t __attribute__ ((__section__ (".bss.page_aligned"))) - l1_identmap[L1_PAGETABLE_ENTRIES]; - -+/* Mapping of the fixmap space needed early. */ -+l1_pgentry_t __attribute__ ((__section__ (".bss.page_aligned"))) -+ l1_fixmap[L1_PAGETABLE_ENTRIES]; -+ - #define MEM_LOG(_f, _a...) gdprintk(XENLOG_WARNING , _f "\n" , ## _a) - - /* -Index: xen-4.2.2-testing/xen/arch/x86/x86_64/mm.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/x86_64/mm.c -+++ xen-4.2.2-testing/xen/arch/x86/x86_64/mm.c -@@ -65,6 +65,10 @@ l3_pgentry_t __attribute__ ((__section__ - l2_pgentry_t __attribute__ ((__section__ (".bss.page_aligned"))) - l2_xenmap[L2_PAGETABLE_ENTRIES]; - -+/* Enough page directories to map the early fixmap space. */ -+l2_pgentry_t __attribute__ ((__section__ (".bss.page_aligned"))) -+ l2_fixmap[L2_PAGETABLE_ENTRIES]; -+ - /* Enough page directories to map into the bottom 1GB. */ - l3_pgentry_t __attribute__ ((__section__ (".bss.page_aligned"))) - l3_bootmap[L3_PAGETABLE_ENTRIES]; -Index: xen-4.2.2-testing/xen/include/asm-x86/config.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/config.h -+++ xen-4.2.2-testing/xen/include/asm-x86/config.h -@@ -317,7 +317,7 @@ extern unsigned char boot_edid_info[128] - #define MACHPHYS_MBYTES 16 /* 1 MB needed per 1 GB memory */ - #define FRAMETABLE_MBYTES (MACHPHYS_MBYTES * 6) - --#define IOREMAP_VIRT_END 0UL -+#define IOREMAP_VIRT_END _AC(0,UL) - #define IOREMAP_VIRT_START (IOREMAP_VIRT_END - (IOREMAP_MBYTES<<20)) - #define DIRECTMAP_VIRT_END IOREMAP_VIRT_START - #define DIRECTMAP_VIRT_START (DIRECTMAP_VIRT_END - (DIRECTMAP_MBYTES<<20)) -Index: xen-4.2.2-testing/xen/include/asm-x86/fixmap.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/fixmap.h -+++ xen-4.2.2-testing/xen/include/asm-x86/fixmap.h -@@ -13,12 +13,17 @@ - #define _ASM_FIXMAP_H - - #include -+#include -+ -+#define FIXADDR_TOP (IOREMAP_VIRT_END - PAGE_SIZE) -+ -+#ifndef __ASSEMBLY__ -+ - #include - #include - #include - #include - #include --#include - #include - #include - #include -@@ -68,7 +73,6 @@ enum fixed_addresses { - __end_of_fixed_addresses - }; - --#define FIXADDR_TOP (IOREMAP_VIRT_END - PAGE_SIZE) - #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) - #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) - -@@ -92,4 +96,6 @@ static inline unsigned long virt_to_fix( - return __virt_to_fix(vaddr); - } - -+#endif /* __ASSEMBLY__ */ -+ - #endif -Index: xen-4.2.2-testing/xen/include/asm-x86/page.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/page.h -+++ xen-4.2.2-testing/xen/include/asm-x86/page.h -@@ -1,6 +1,8 @@ - #ifndef __X86_PAGE_H__ - #define __X86_PAGE_H__ - -+#include -+ - /* - * It is important that the masks are signed quantities. This ensures that - * the compiler sign-extends a 32-bit mask to 64 bits if that is required. -@@ -306,13 +308,15 @@ extern l2_pgentry_t idle_pg_table_l2[ - extern l2_pgentry_t *compat_idle_pg_table_l2; - extern unsigned int m2p_compat_vstart; - extern l2_pgentry_t l2_xenmap[L2_PAGETABLE_ENTRIES], -+ l2_fixmap[L2_PAGETABLE_ENTRIES], - l2_bootmap[L2_PAGETABLE_ENTRIES]; - extern l3_pgentry_t l3_xenmap[L3_PAGETABLE_ENTRIES], - l3_identmap[L3_PAGETABLE_ENTRIES], - l3_bootmap[L3_PAGETABLE_ENTRIES]; - #endif - extern l2_pgentry_t l2_identmap[4*L2_PAGETABLE_ENTRIES]; --extern l1_pgentry_t l1_identmap[L1_PAGETABLE_ENTRIES]; -+extern l1_pgentry_t l1_identmap[L1_PAGETABLE_ENTRIES], -+ l1_fixmap[L1_PAGETABLE_ENTRIES]; - void paging_init(void); - void setup_idle_pagetable(void); - #endif /* !defined(__ASSEMBLY__) */ -Index: xen-4.2.2-testing/xen/include/xen/const.h -=================================================================== ---- /dev/null -+++ xen-4.2.2-testing/xen/include/xen/const.h -@@ -0,0 +1,24 @@ -+/* const.h: Macros for dealing with constants. */ -+ -+#ifndef __XEN_CONST_H__ -+#define __XEN_CONST_H__ -+ -+/* Some constant macros are used in both assembler and -+ * C code. Therefore we cannot annotate them always with -+ * 'UL' and other type specifiers unilaterally. We -+ * use the following macros to deal with this. -+ * -+ * Similarly, _AT() will cast an expression with a type in C, but -+ * leave it unchanged in asm. -+ */ -+ -+#ifdef __ASSEMBLY__ -+#define _AC(X,Y) X -+#define _AT(T,X) X -+#else -+#define __AC(X,Y) (X##Y) -+#define _AC(X,Y) __AC(X,Y) -+#define _AT(T,X) ((T)(X)) -+#endif -+ -+#endif /* __XEN_CONST_H__ */ diff --git a/25862-sercon-non-com.patch b/25862-sercon-non-com.patch deleted file mode 100644 index 5b0c9d5..0000000 --- a/25862-sercon-non-com.patch +++ /dev/null @@ -1,144 +0,0 @@ -# HG changeset patch -# User Jan Beulich -# Date 1347371236 -7200 -# Node ID 776a23fa0e938e4cf3307fc2e3b3f1a9488a5927 -# Parent 51c2d7c83cbc2a0357ce112a463f91d354dcdba9 -console: prepare for non-COMn port support - -Widen SERHND_IDX (and use it where needed), introduce a flush low level -driver method, and remove unnecessary peeking of the common code at the -(driver specific) serial port identification string in the "console=" -command line option value. - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser - ---- a/xen/arch/x86/smpboot.c -+++ b/xen/arch/x86/smpboot.c -@@ -1017,7 +1017,7 @@ void __init smp_intr_init(void) - * Also ensure serial interrupts are high priority. We do not - * want them to be blocked by unacknowledged guest-bound interrupts. - */ -- for ( seridx = 0; seridx < 2; seridx++ ) -+ for ( seridx = 0; seridx <= SERHND_IDX; seridx++ ) - { - if ( (irq = serial_irq(seridx)) < 0 ) - continue; ---- a/xen/drivers/char/console.c -+++ b/xen/drivers/char/console.c -@@ -539,6 +539,7 @@ void printk(const char *fmt, ...) - void __init console_init_preirq(void) - { - char *p; -+ int sh; - - serial_init_preirq(); - -@@ -551,8 +552,9 @@ void __init console_init_preirq(void) - vga_init(); - else if ( !strncmp(p, "none", 4) ) - continue; -- else if ( strncmp(p, "com", 3) || -- (sercon_handle = serial_parse_handle(p)) == -1 ) -+ else if ( (sh = serial_parse_handle(p)) >= 0 ) -+ sercon_handle = sh; -+ else - { - char *q = strchr(p, ','); - if ( q != NULL ) ---- a/xen/drivers/char/serial.c -+++ b/xen/drivers/char/serial.c -@@ -22,9 +22,11 @@ size_param("serial_tx_buffer", serial_tx - #define mask_serial_rxbuf_idx(_i) ((_i)&(serial_rxbufsz-1)) - #define mask_serial_txbuf_idx(_i) ((_i)&(serial_txbufsz-1)) - --static struct serial_port com[2] = { -- { .rx_lock = SPIN_LOCK_UNLOCKED, .tx_lock = SPIN_LOCK_UNLOCKED }, -- { .rx_lock = SPIN_LOCK_UNLOCKED, .tx_lock = SPIN_LOCK_UNLOCKED } -+static struct serial_port com[SERHND_IDX + 1] = { -+ [0 ... SERHND_IDX] = { -+ .rx_lock = SPIN_LOCK_UNLOCKED, -+ .tx_lock = SPIN_LOCK_UNLOCKED -+ } - }; - - void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs) -@@ -81,6 +83,8 @@ void serial_tx_interrupt(struct serial_p - port->driver->putc( - port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]); - } -+ if ( i && port->driver->flush ) -+ port->driver->flush(port); - } - - spin_unlock(&port->tx_lock); -@@ -175,6 +179,9 @@ void serial_putc(int handle, char c) - - __serial_putc(port, c); - -+ if ( port->driver->flush ) -+ port->driver->flush(port); -+ - spin_unlock_irqrestore(&port->tx_lock, flags); - } - -@@ -206,6 +213,9 @@ void serial_puts(int handle, const char - __serial_putc(port, c); - } - -+ if ( port->driver->flush ) -+ port->driver->flush(port); -+ - spin_unlock_irqrestore(&port->tx_lock, flags); - } - -@@ -261,10 +271,10 @@ int __init serial_parse_handle(char *con - switch ( conf[3] ) - { - case '1': -- handle = 0; -+ handle = SERHND_COM1; - break; - case '2': -- handle = 1; -+ handle = SERHND_COM2; - break; - default: - goto fail; -@@ -365,6 +375,8 @@ void serial_start_sync(int handle) - port->driver->putc( - port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]); - } -+ if ( port->driver->flush ) -+ port->driver->flush(port); - } - - spin_unlock_irqrestore(&port->tx_lock, flags); ---- a/xen/include/xen/serial.h -+++ b/xen/include/xen/serial.h -@@ -60,6 +60,8 @@ struct uart_driver { - int (*tx_empty)(struct serial_port *); - /* Put a character onto the serial line. */ - void (*putc)(struct serial_port *, char); -+ /* Flush accumulated characters. */ -+ void (*flush)(struct serial_port *); - /* Get a character from the serial line: returns 0 if none available. */ - int (*getc)(struct serial_port *, char *); - /* Get IRQ number for this port's serial line: returns -1 if none. */ -@@ -67,10 +69,12 @@ struct uart_driver { - }; - - /* 'Serial handles' are composed from the following fields. */ --#define SERHND_IDX (1<<0) /* COM1 or COM2? */ --#define SERHND_HI (1<<1) /* Mux/demux each transferred char by MSB. */ --#define SERHND_LO (1<<2) /* Ditto, except that the MSB is cleared. */ --#define SERHND_COOKED (1<<3) /* Newline/carriage-return translation? */ -+#define SERHND_IDX (3<<0) /* COM1 or COM2? */ -+# define SERHND_COM1 (0<<0) -+# define SERHND_COM2 (1<<0) -+#define SERHND_HI (1<<2) /* Mux/demux each transferred char by MSB. */ -+#define SERHND_LO (1<<3) /* Ditto, except that the MSB is cleared. */ -+#define SERHND_COOKED (1<<4) /* Newline/carriage-return translation? */ - - /* Two-stage initialisation (before/after IRQ-subsystem initialisation). */ - void serial_init_preirq(void); diff --git a/25863-sercon-ehci-dbgp.patch b/25863-sercon-ehci-dbgp.patch deleted file mode 100644 index 301bfc0..0000000 --- a/25863-sercon-ehci-dbgp.patch +++ /dev/null @@ -1,1798 +0,0 @@ -# HG changeset patch -# User Jan Beulich -# Date 1347371392 -7200 -# Node ID 0d0c55a1975db9c6cac2e9259b5ebea7a7bdbaec -# Parent 776a23fa0e938e4cf3307fc2e3b3f1a9488a5927 -console: add EHCI debug port based serial console - -Low level hardware interface pieces adapted from Linux. - -For setup information, see Linux'es Documentation/x86/earlyprintk.txt -and/or http://www.coreboot.org/EHCI_Debug_Port. - -Signed-off-by: Jan Beulich -Reviewed-by: Konrad Rzeszutek Wilk -Acked-by: Keir Fraser - -Index: xen-4.2.2-testing/docs/misc/xen-command-line.markdown -=================================================================== ---- xen-4.2.2-testing.orig/docs/misc/xen-command-line.markdown -+++ xen-4.2.2-testing/docs/misc/xen-command-line.markdown -@@ -244,7 +244,7 @@ A typical setup for most situations migh - Specify the size of the console ring buffer. - - ### console --> `= List of [ vga | com1[H,L] | com2[H,L] | none ]` -+> `= List of [ vga | com1[H,L] | com2[H,L] | dbgp | none ]` - - > Default: `console=com1,vga` - -@@ -260,6 +260,8 @@ the converse; transmitted and received c - cleared. This allows a single port to be shared by two subsystems - (e.g. console and debugger). - -+`dbgp` indicates that Xen should use a USB debug port. -+ - `none` indicates that Xen should not use a console. This option only - makes sense on its own. - -@@ -352,6 +354,12 @@ combination with the `low_crashinfo` com - ### credit2\_load\_window\_shift - > `= ` - -+### dbgp -+> `= ehci[ | @pci:. ]` -+ -+Specify the USB controller to use, either by instance number (when going -+over the PCI busses sequentially) or by PCI device (must be on segment 0). -+ - ### debug\_stack\_lines - > `= ` - -Index: xen-4.2.2-testing/xen/arch/x86/Rules.mk -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/Rules.mk -+++ xen-4.2.2-testing/xen/arch/x86/Rules.mk -@@ -7,6 +7,7 @@ HAS_CPUFREQ := y - HAS_PCI := y - HAS_PASSTHROUGH := y - HAS_NS16550 := y -+HAS_EHCI := y - HAS_KEXEC := y - HAS_GDBSX := y - xenoprof := y -Index: xen-4.2.2-testing/xen/arch/x86/physdev.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/physdev.c -+++ xen-4.2.2-testing/xen/arch/x86/physdev.c -@@ -8,6 +8,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -734,6 +735,19 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H - - break; - } -+ -+ case PHYSDEVOP_dbgp_op: { -+ struct physdev_dbgp_op op; -+ -+ if ( !IS_PRIV(v->domain) ) -+ ret = -EPERM; -+ else if ( copy_from_guest(&op, arg, 1) ) -+ ret = -EFAULT; -+ else -+ ret = dbgp_op(&op); -+ break; -+ } -+ - default: - ret = -ENOSYS; - break; -Index: xen-4.2.2-testing/xen/arch/x86/setup.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/setup.c -+++ xen-4.2.2-testing/xen/arch/x86/setup.c -@@ -606,6 +606,7 @@ void __init __start_xen(unsigned long mb - ns16550.io_base = 0x2f8; - ns16550.irq = 3; - ns16550_init(1, &ns16550); -+ ehci_dbgp_init(); - console_init_preirq(); - - printk("Bootloader: %s\n", loader); -Index: xen-4.2.2-testing/xen/drivers/char/Makefile -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/char/Makefile -+++ xen-4.2.2-testing/xen/drivers/char/Makefile -@@ -1,4 +1,5 @@ - obj-y += console.o - obj-$(HAS_NS16550) += ns16550.o - obj-$(HAS_PL011) += pl011.o -+obj-$(HAS_EHCI) += ehci-dbgp.o - obj-y += serial.o -Index: xen-4.2.2-testing/xen/drivers/char/ehci-dbgp.c -=================================================================== ---- /dev/null -+++ xen-4.2.2-testing/xen/drivers/char/ehci-dbgp.c -@@ -0,0 +1,1577 @@ -+/* -+ * Standalone EHCI USB debug driver -+ * -+ * Hardware interface code based on the respective early console driver in -+ * Linux; see the Linux source for authorship and copyrights. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+/* #define DBGP_DEBUG */ -+ -+/* EHCI register interface, corresponds to EHCI Revision 0.95 specification */ -+ -+/* Section 2.2 Host Controller Capability Registers */ -+struct ehci_caps { -+ /* -+ * These fields are specified as 8 and 16 bit registers, -+ * but some hosts can't perform 8 or 16 bit PCI accesses. -+ * some hosts treat caplength and hciversion as parts of a 32-bit -+ * register, others treat them as two separate registers, this -+ * affects the memory map for big endian controllers. -+ */ -+ u32 hc_capbase; -+#define HC_LENGTH(p) (0x00ff & (p)) /* bits 7:0 / offset 0x00 */ -+#define HC_VERSION(p) (0xffff & ((p) >> 16)) /* bits 31:16 / offset 0x02 */ -+ -+ u32 hcs_params; /* HCSPARAMS - offset 0x04 */ -+#define HCS_DEBUG_PORT(p) (((p) >> 20) & 0xf) /* bits 23:20, debug port? */ -+#define HCS_INDICATOR(p) ((p) & (1 << 16)) /* true: has port indicators */ -+#define HCS_N_CC(p) (((p) >> 12) & 0xf) /* bits 15:12, #companion HCs */ -+#define HCS_N_PCC(p) (((p) >> 8) & 0xf) /* bits 11:8, ports per CC */ -+#define HCS_PORTROUTED(p) ((p) & (1 << 7)) /* true: port routing */ -+#define HCS_PPC(p) ((p) & (1 << 4)) /* true: port power control */ -+#define HCS_N_PORTS(p) (((p) >> 0) & 0xf) /* bits 3:0, ports on HC */ -+ -+ u32 hcc_params; /* HCCPARAMS - offset 0x08 */ -+/* EHCI 1.1 addendum */ -+#define HCC_32FRAME_PERIODIC_LIST(p) ((p) & (1 << 19)) -+#define HCC_PER_PORT_CHANGE_EVENT(p) ((p) & (1 << 18)) -+#define HCC_LPM(p) ((p) & (1 << 17)) -+#define HCC_HW_PREFETCH(p) ((p) & (1 << 16)) -+#define HCC_EXT_CAPS(p) (((p) >> 8) & 0xff) /* for pci extended caps */ -+#define HCC_ISOC_CACHE(p) ((p) & (1 << 7)) /* true: can cache isoc frame */ -+#define HCC_ISOC_THRES(p) (((p) >> 4) & 0x7) /* bits 6:4, uframes cached */ -+#define HCC_CANPARK(p) ((p) & (1 << 2)) /* true: can park on async qh */ -+#define HCC_PGM_FRAMELISTLEN(p) ((p) & (1 << 1)) /* true: periodic_size changes */ -+#define HCC_64BIT_ADDR(p) ((p) & 1) /* true: can use 64-bit addr */ -+ -+ u8 portroute[8]; /* nibbles for routing - offset 0x0C */ -+}; -+ -+/* Section 2.3 Host Controller Operational Registers */ -+struct ehci_regs { -+ /* USBCMD: offset 0x00 */ -+ u32 command; -+ -+/* EHCI 1.1 addendum */ -+#define CMD_HIRD (0xf << 24) /* host initiated resume duration */ -+#define CMD_PPCEE (1 << 15) /* per port change event enable */ -+#define CMD_FSP (1 << 14) /* fully synchronized prefetch */ -+#define CMD_ASPE (1 << 13) /* async schedule prefetch enable */ -+#define CMD_PSPE (1 << 12) /* periodic schedule prefetch enable */ -+/* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */ -+#define CMD_PARK (1 << 11) /* enable "park" on async qh */ -+#define CMD_PARK_CNT(c) (((c) >> 8) & 3) /* how many transfers to park for */ -+#define CMD_LRESET (1 << 7) /* partial reset (no ports, etc) */ -+#define CMD_IAAD (1 << 6) /* "doorbell" interrupt async advance */ -+#define CMD_ASE (1 << 5) /* async schedule enable */ -+#define CMD_PSE (1 << 4) /* periodic schedule enable */ -+/* 3:2 is periodic frame list size */ -+#define CMD_RESET (1 << 1) /* reset HC not bus */ -+#define CMD_RUN (1 << 0) /* start/stop HC */ -+ -+ /* USBSTS: offset 0x04 */ -+ u32 status; -+#define STS_PPCE_MASK (0xff << 16) /* Per-Port change event 1-16 */ -+#define STS_ASS (1 << 15) /* Async Schedule Status */ -+#define STS_PSS (1 << 14) /* Periodic Schedule Status */ -+#define STS_RECL (1 << 13) /* Reclamation */ -+#define STS_HALT (1 << 12) /* Not running (any reason) */ -+/* some bits reserved */ -+ /* these STS_* flags are also intr_enable bits (USBINTR) */ -+#define STS_IAA (1 << 5) /* Interrupted on async advance */ -+#define STS_FATAL (1 << 4) /* such as some PCI access errors */ -+#define STS_FLR (1 << 3) /* frame list rolled over */ -+#define STS_PCD (1 << 2) /* port change detect */ -+#define STS_ERR (1 << 1) /* "error" completion (overflow, ...) */ -+#define STS_INT (1 << 0) /* "normal" completion (short, ...) */ -+ -+ /* USBINTR: offset 0x08 */ -+ u32 intr_enable; -+ -+ /* FRINDEX: offset 0x0C */ -+ u32 frame_index; /* current microframe number */ -+ /* CTRLDSSEGMENT: offset 0x10 */ -+ u32 segment; /* address bits 63:32 if needed */ -+ /* PERIODICLISTBASE: offset 0x14 */ -+ u32 frame_list; /* points to periodic list */ -+ /* ASYNCLISTADDR: offset 0x18 */ -+ u32 async_next; /* address of next async queue head */ -+ -+ u32 reserved[9]; -+ -+ /* CONFIGFLAG: offset 0x40 */ -+ u32 configured_flag; -+#define FLAG_CF (1 << 0) /* true: we'll support "high speed" */ -+ -+ /* PORTSC: offset 0x44 */ -+ u32 port_status[0]; /* up to N_PORTS */ -+/* EHCI 1.1 addendum */ -+#define PORTSC_SUSPEND_STS_ACK 0 -+#define PORTSC_SUSPEND_STS_NYET 1 -+#define PORTSC_SUSPEND_STS_STALL 2 -+#define PORTSC_SUSPEND_STS_ERR 3 -+ -+#define PORT_DEV_ADDR (0x7f << 25) /* device address */ -+#define PORT_SSTS (0x3 << 23) /* suspend status */ -+/* 31:23 reserved */ -+#define PORT_WKOC_E (1 << 22) /* wake on overcurrent (enable) */ -+#define PORT_WKDISC_E (1 << 21) /* wake on disconnect (enable) */ -+#define PORT_WKCONN_E (1 << 20) /* wake on connect (enable) */ -+/* 19:16 for port testing */ -+#define PORT_TEST(x) (((x) & 0xf) << 16) /* Port Test Control */ -+#define PORT_TEST_PKT PORT_TEST(0x4) /* Port Test Control - packet test */ -+#define PORT_TEST_FORCE PORT_TEST(0x5) /* Port Test Control - force enable */ -+#define PORT_LED_OFF (0 << 14) -+#define PORT_LED_AMBER (1 << 14) -+#define PORT_LED_GREEN (2 << 14) -+#define PORT_LED_MASK (3 << 14) -+#define PORT_OWNER (1 << 13) /* true: companion hc owns this port */ -+#define PORT_POWER (1 << 12) /* true: has power (see PPC) */ -+#define PORT_USB11(x) (((x) & (3 << 10)) == (1 << 10)) /* USB 1.1 device */ -+/* 11:10 for detecting lowspeed devices (reset vs release ownership) */ -+/* 9 reserved */ -+#define PORT_LPM (1 << 9) /* LPM transaction */ -+#define PORT_RESET (1 << 8) /* reset port */ -+#define PORT_SUSPEND (1 << 7) /* suspend port */ -+#define PORT_RESUME (1 << 6) /* resume it */ -+#define PORT_OCC (1 << 5) /* over current change */ -+#define PORT_OC (1 << 4) /* over current active */ -+#define PORT_PEC (1 << 3) /* port enable change */ -+#define PORT_PE (1 << 2) /* port enable */ -+#define PORT_CSC (1 << 1) /* connect status change */ -+#define PORT_CONNECT (1 << 0) /* device connected */ -+#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) -+}; -+ -+/* -+ * Appendix C, Debug port ... intended for use with special "debug devices" -+ * that can help if there's no serial console. (nonstandard enumeration.) -+ */ -+struct ehci_dbg_port { -+ u32 control; -+#define DBGP_OWNER (1 << 30) -+#define DBGP_ENABLED (1 << 28) -+#define DBGP_DONE (1 << 16) -+#define DBGP_INUSE (1 << 10) -+#define DBGP_ERRCODE(x) (((x) >> 7) & 0x07) -+# define DBGP_ERR_BAD 1 -+# define DBGP_ERR_SIGNAL 2 -+#define DBGP_ERROR (1 << 6) -+#define DBGP_GO (1 << 5) -+#define DBGP_OUT (1 << 4) -+#define DBGP_LEN (0xf << 0) -+#define DBGP_CLAIM (DBGP_OWNER | DBGP_ENABLED | DBGP_INUSE) -+ u32 pids; -+#define DBGP_PID_GET(x) (((x) >> 16) & 0xff) -+#define DBGP_PID_SET(data, tok) (((data) << 8) | (tok)) -+ u32 data03; -+ u32 data47; -+ u32 address; -+#define DBGP_EPADDR(dev, ep) (((dev) << 8) | (ep)) -+}; -+ -+/* CONTROL REQUEST SUPPORT */ -+ -+/* -+ * USB directions -+ * -+ * This bit flag is used in endpoint descriptors' bEndpointAddress field. -+ * It's also one of three fields in control requests bRequestType. -+ */ -+#define USB_DIR_OUT 0 /* to device */ -+#define USB_DIR_IN 0x80 /* to host */ -+ -+/* -+ * USB types, the second of three bRequestType fields -+ */ -+#define USB_TYPE_MASK (0x03 << 5) -+#define USB_TYPE_STANDARD (0x00 << 5) -+#define USB_TYPE_CLASS (0x01 << 5) -+#define USB_TYPE_VENDOR (0x02 << 5) -+#define USB_TYPE_RESERVED (0x03 << 5) -+ -+/* -+ * USB recipients, the third of three bRequestType fields -+ */ -+#define USB_RECIP_MASK 0x1f -+#define USB_RECIP_DEVICE 0x00 -+#define USB_RECIP_INTERFACE 0x01 -+#define USB_RECIP_ENDPOINT 0x02 -+#define USB_RECIP_OTHER 0x03 -+/* From Wireless USB 1.0 */ -+#define USB_RECIP_PORT 0x04 -+#define USB_RECIP_RPIPE 0x05 -+ -+/* -+ * Standard requests, for the bRequest field of a SETUP packet. -+ * -+ * These are qualified by the bRequestType field, so that for example -+ * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved -+ * by a GET_STATUS request. -+ */ -+#define USB_REQ_GET_STATUS 0x00 -+#define USB_REQ_CLEAR_FEATURE 0x01 -+#define USB_REQ_SET_FEATURE 0x03 -+#define USB_REQ_SET_ADDRESS 0x05 -+#define USB_REQ_GET_DESCRIPTOR 0x06 -+#define USB_REQ_SET_DESCRIPTOR 0x07 -+#define USB_REQ_GET_CONFIGURATION 0x08 -+#define USB_REQ_SET_CONFIGURATION 0x09 -+#define USB_REQ_GET_INTERFACE 0x0A -+#define USB_REQ_SET_INTERFACE 0x0B -+#define USB_REQ_SYNCH_FRAME 0x0C -+ -+#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ -+ -+/** -+ * struct usb_ctrlrequest - SETUP data for a USB device control request -+ * @bRequestType: matches the USB bmRequestType field -+ * @bRequest: matches the USB bRequest field -+ * @wValue: matches the USB wValue field (le16 byte order) -+ * @wIndex: matches the USB wIndex field (le16 byte order) -+ * @wLength: matches the USB wLength field (le16 byte order) -+ * -+ * This structure is used to send control requests to a USB device. It matches -+ * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the -+ * USB spec for a fuller description of the different fields, and what they are -+ * used for. -+ * -+ * Note that the driver for any interface can issue control requests. -+ * For most devices, interfaces don't coordinate with each other, so -+ * such requests may be made at any time. -+ */ -+struct usb_ctrlrequest { -+ u8 bRequestType; -+ u8 bRequest; -+ __le16 wValue; -+ __le16 wIndex; -+ __le16 wLength; -+} __attribute__ ((packed)); -+ -+/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */ -+ -+#define USB_DT_DEBUG 0x0a -+ -+struct usb_debug_descriptor { -+ u8 bLength; -+ u8 bDescriptorType; -+ /* bulk endpoints with 8 byte maxpacket */ -+ u8 bDebugInEndpoint; -+ u8 bDebugOutEndpoint; -+} __attribute__((packed)); -+ -+#define USB_DEBUG_DEVNUM 127 -+ -+/* -+ * USB Packet IDs (PIDs) -+ */ -+ -+/* token */ -+#define USB_PID_OUT 0xe1 -+#define USB_PID_IN 0x69 -+#define USB_PID_SOF 0xa5 -+#define USB_PID_SETUP 0x2d -+/* handshake */ -+#define USB_PID_ACK 0xd2 -+#define USB_PID_NAK 0x5a -+#define USB_PID_STALL 0x1e -+#define USB_PID_NYET 0x96 -+/* data */ -+#define USB_PID_DATA0 0xc3 -+#define USB_PID_DATA1 0x4b -+#define USB_PID_DATA2 0x87 -+#define USB_PID_MDATA 0x0f -+/* Special */ -+#define USB_PID_PREAMBLE 0x3c -+#define USB_PID_ERR 0x3c -+#define USB_PID_SPLIT 0x78 -+#define USB_PID_PING 0xb4 -+#define USB_PID_UNDEF_0 0xf0 -+ -+#define PCI_CLASS_SERIAL_USB_EHCI 0x0c0320 -+#define PCI_CAP_ID_EHCI_DEBUG 0x0a -+ -+#define HUB_ROOT_RESET_TIME 50 /* times are in msec */ -+#define HUB_SHORT_RESET_TIME 10 -+#define HUB_LONG_RESET_TIME 200 -+#define HUB_RESET_TIMEOUT 500 -+ -+#define DBGP_MAX_PACKET 8 -+#define DBGP_LOOPS 1000 -+#define DBGP_TIMEOUT (250 * 1000) /* us */ -+#define DBGP_CHECK_INTERVAL 100 /* us */ -+/* This one can be set arbitrarily - only affects input responsiveness: */ -+#define DBGP_IDLE_INTERVAL 100 /* ms */ -+ -+struct ehci_dbgp { -+ struct ehci_dbg_port __iomem *ehci_debug; -+ enum dbgp_state { -+ dbgp_idle, -+ dbgp_out, -+ dbgp_in, -+ dbgp_ctrl, -+ dbgp_unsafe /* cannot use debug device during EHCI reset */ -+ } state; -+ unsigned int phys_port; -+ struct { -+ unsigned int endpoint; -+ unsigned int chunk; -+ char buf[DBGP_MAX_PACKET]; -+ } out, in; -+ unsigned long timeout; -+ struct timer timer; -+ spinlock_t *lock; -+ bool_t reset_run; -+ u8 bus, slot, func, bar; -+ u16 pci_cr; -+ u32 bar_val; -+ unsigned int cap; -+ struct ehci_regs __iomem *ehci_regs; -+ struct ehci_caps __iomem *ehci_caps; -+}; -+ -+static int ehci_dbgp_external_startup(struct ehci_dbgp *); -+ -+static void ehci_dbgp_status(struct ehci_dbgp *dbgp, const char *str) -+{ -+#ifdef DBGP_DEBUG -+#define dbgp_printk printk -+ if ( !dbgp->ehci_debug ) -+ return; -+ dbgp_printk("dbgp: %s\n", str); -+ dbgp_printk(" debug control: %08x\n", readl(&dbgp->ehci_debug->control)); -+ dbgp_printk(" EHCI cmd : %08x\n", readl(&dbgp->ehci_regs->command)); -+ dbgp_printk(" EHCI conf flg: %08x\n", -+ readl(&dbgp->ehci_regs->configured_flag)); -+ dbgp_printk(" EHCI status : %08x\n", readl(&dbgp->ehci_regs->status)); -+ dbgp_printk(" EHCI portsc : %08x\n", -+ readl(&dbgp->ehci_regs->port_status[dbgp->phys_port - 1])); -+#endif -+} -+ -+#ifndef DBGP_DEBUG -+static inline __attribute__ ((format (printf, 1, 2))) void -+dbgp_printk(const char *fmt, ...) { } -+#endif -+ -+static inline u32 dbgp_len_update(u32 x, u32 len) -+{ -+ return (x & ~DBGP_LEN) | (len & DBGP_LEN) | DBGP_OUT; -+} -+ -+static inline u32 dbgp_pid_write_update(u32 x, u32 tok) -+{ -+ static u8 data0 = USB_PID_DATA1; -+ -+ data0 ^= USB_PID_DATA0 ^ USB_PID_DATA1; -+ return (x & 0xffff0000) | (data0 << 8) | (tok & 0xff); -+} -+ -+static inline u32 dbgp_pid_read_update(u32 x, u32 tok) -+{ -+ return (x & 0xffffff00) | (tok & 0xff); -+} -+ -+static inline void dbgp_set_data(struct ehci_dbg_port __iomem *ehci_debug, -+ const void *buf, unsigned int size) -+{ -+ const unsigned char *bytes = buf; -+ u32 lo = 0, hi = 0; -+ unsigned int i; -+ -+ for ( i = 0; i < 4 && i < size; i++ ) -+ lo |= bytes[i] << (8 * i); -+ for ( ; i < 8 && i < size; i++ ) -+ hi |= bytes[i] << (8 * (i - 4)); -+ writel(lo, &ehci_debug->data03); -+ writel(hi, &ehci_debug->data47); -+} -+ -+static inline void dbgp_get_data(struct ehci_dbg_port __iomem *ehci_debug, -+ void *buf, int size) -+{ -+ unsigned char *bytes = buf; -+ u32 lo = readl(&ehci_debug->data03); -+ u32 hi = readl(&ehci_debug->data47); -+ unsigned int i; -+ -+ for ( i = 0; i < 4 && i < size; i++ ) -+ bytes[i] = (lo >> (8 * i)) & 0xff; -+ for ( ; i < 8 && i < size; i++ ) -+ bytes[i] = (hi >> (8 * (i - 4))) & 0xff; -+} -+ -+static void dbgp_issue_command(struct ehci_dbgp *dbgp, u32 ctrl, -+ enum dbgp_state state) -+{ -+ u32 cmd = readl(&dbgp->ehci_regs->command); -+ -+ if ( unlikely(!(cmd & CMD_RUN)) ) -+ { -+ /* -+ * If the EHCI controller is not in the run state do extended -+ * checks to see if ACPI or some other initialization also -+ * reset the EHCI debug port. -+ */ -+ u32 ctrl = readl(&dbgp->ehci_debug->control); -+ -+ if ( ctrl & DBGP_ENABLED ) -+ { -+ cmd |= CMD_RUN; -+ writel(cmd, &dbgp->ehci_regs->command); -+ dbgp->reset_run = 1; -+ } -+ else if ( dbgp->state != dbgp_unsafe ) -+ { -+ dbgp->state = dbgp_unsafe; -+ ehci_dbgp_external_startup(dbgp); -+ } -+ } -+ -+ writel(ctrl | DBGP_GO, &dbgp->ehci_debug->control); -+ dbgp->timeout = DBGP_TIMEOUT; -+ if ( dbgp->state != dbgp_unsafe ) -+ dbgp->state = state; -+} -+ -+static int dbgp_check_for_completion(struct ehci_dbgp *dbgp, -+ unsigned int interval, u8 *ppid) -+{ -+ u32 ctrl; -+ int ret; -+ -+ if ( dbgp->state == dbgp_idle ) -+ return 0; -+ -+ ctrl = readl(&dbgp->ehci_debug->control) & ~DBGP_GO; -+ if ( !(ctrl & DBGP_DONE) ) -+ { -+ if ( dbgp->timeout > interval ) -+ dbgp->timeout -= interval; -+ else if ( interval ) -+ { -+ /* See the timeout related comment in dbgp_wait_until_done(). */ -+ dbgp->state = dbgp_unsafe; -+ dbgp->timeout = 0; -+ } -+ return -DBGP_TIMEOUT; -+ } -+ -+ if ( ctrl & DBGP_ERROR ) -+ { -+ ret = -DBGP_ERRCODE(ctrl); -+ if ( ret == -DBGP_ERR_BAD && dbgp->timeout > interval ) -+ ctrl |= DBGP_GO; -+ } -+ else -+ { -+ u8 pid = DBGP_PID_GET(readl(&dbgp->ehci_debug->pids)); -+ -+ ret = ctrl & DBGP_LEN; -+ if ( ppid ) -+ *ppid = pid; -+ else if ( dbgp->state == dbgp_in ) -+ { -+ dbgp_get_data(dbgp->ehci_debug, dbgp->in.buf, ret); -+ dbgp->in.chunk = ret; -+ } -+ else if ( pid == USB_PID_NAK && dbgp->timeout > interval ) -+ ctrl |= DBGP_GO; -+ } -+ -+ writel(ctrl, &dbgp->ehci_debug->control); -+ if ( ctrl & DBGP_GO ) -+ { -+ dbgp->timeout -= interval; -+ return -DBGP_TIMEOUT; -+ } -+ -+ if ( unlikely(dbgp->reset_run) ) -+ { -+ writel(readl(&dbgp->ehci_regs->command) & ~CMD_RUN, -+ &dbgp->ehci_regs->command); -+ dbgp->reset_run = 0; -+ } -+ -+ if ( dbgp->state != dbgp_unsafe ) -+ dbgp->state = dbgp_idle; -+ -+ return ret; -+} -+ -+static int dbgp_wait_until_complete(struct ehci_dbgp *dbgp, u8 *ppid) -+{ -+ unsigned int loop = DBGP_TIMEOUT; -+ int ret; -+ -+ do { -+ ret = dbgp_check_for_completion(dbgp, 0, ppid); -+ if ( ret != -DBGP_TIMEOUT ) -+ break; -+ udelay(1); -+ } while ( --loop ); -+ -+ if ( !ppid && !loop ) -+ dbgp->state = dbgp_unsafe; -+ -+ return ret; -+} -+ -+static inline void dbgp_mdelay(unsigned int ms) -+{ -+ while ( ms-- ) -+ { -+ unsigned int i; -+ -+ for ( i = 0; i < 1000; i++ ) -+ outb(0x1, 0x80); -+ } -+} -+ -+static void dbgp_breathe(void) -+{ -+ /* Sleep to give the debug port a chance to breathe. */ -+ dbgp_mdelay(1); -+} -+ -+static int dbgp_wait_until_done(struct ehci_dbgp *dbgp, u32 ctrl, -+ unsigned int loop) -+{ -+ int ret; -+ -+ dbgp->timeout = 0; -+ -+ for ( ; ; writel(ctrl | DBGP_GO, &dbgp->ehci_debug->control) ) -+ { -+ u8 pid; -+ -+ ret = dbgp_wait_until_complete(dbgp, &pid); -+ if ( ret < 0 ) -+ { -+ /* -+ * A -DBGP_TIMEOUT failure here means the device has failed, -+ * perhaps because it was unplugged, in which case we do not -+ * want to hang the system so the dbgp will be marked as unsafe -+ * to use. EHCI reset is the only way to recover if you unplug -+ * the dbgp device. -+ */ -+ if ( ret == -DBGP_TIMEOUT ) -+ dbgp->state = dbgp_unsafe; -+ if ( ret != -DBGP_ERR_BAD || !--loop ) -+ break; -+ } -+ else -+ { -+ /* -+ * If the port is getting full or it has dropped data -+ * start pacing ourselves, not necessary but it's friendly. -+ */ -+ if ( pid == USB_PID_NAK || pid == USB_PID_NYET ) -+ dbgp_breathe(); -+ -+ /* If we got a NACK, reissue the transmission. */ -+ if ( pid != USB_PID_NAK || !--loop ) -+ break; -+ } -+ } -+ -+ return ret; -+} -+ -+static int dbgp_bulk_write(struct ehci_dbgp *dbgp, -+ unsigned int devnum, unsigned int endpoint, -+ const void *bytes, unsigned int size, u32 *pctrl) -+{ -+ u32 addr, pids, ctrl; -+ -+ if ( size > DBGP_MAX_PACKET ) -+ return -EINVAL; -+ -+ addr = DBGP_EPADDR(devnum, endpoint); -+ pids = dbgp_pid_write_update(readl(&dbgp->ehci_debug->pids), USB_PID_OUT); -+ ctrl = dbgp_len_update(readl(&dbgp->ehci_debug->control), size); -+ if ( pctrl ) -+ *pctrl = ctrl; -+ -+ dbgp_set_data(dbgp->ehci_debug, bytes, size); -+ writel(addr, &dbgp->ehci_debug->address); -+ writel(pids, &dbgp->ehci_debug->pids); -+ dbgp_issue_command(dbgp, ctrl, dbgp_out); -+ -+ return 0; -+} -+ -+static int dbgp_bulk_read(struct ehci_dbgp *dbgp, -+ unsigned int devnum, unsigned int endpoint, -+ unsigned int size, u32 *pctrl) -+{ -+ u32 addr, pids, ctrl; -+ -+ if ( size > DBGP_MAX_PACKET ) -+ return -EINVAL; -+ -+ addr = DBGP_EPADDR(devnum, endpoint); -+ pids = dbgp_pid_read_update(readl(&dbgp->ehci_debug->pids), USB_PID_IN); -+ ctrl = readl(&dbgp->ehci_debug->control) & ~DBGP_OUT; -+ -+ writel(addr, &dbgp->ehci_debug->address); -+ writel(pids, &dbgp->ehci_debug->pids); -+ if ( likely(!pctrl) ) -+ dbgp_issue_command(dbgp, ctrl, dbgp_in); -+ else -+ dbgp_issue_command(dbgp, *pctrl = ctrl, dbgp_ctrl); -+ -+ return 0; -+} -+ -+static int dbgp_control_msg(struct ehci_dbgp *dbgp, unsigned int devnum, -+ int requesttype, int request, int value, -+ int index, void *data, unsigned int size) -+{ -+ u32 addr, pids, ctrl; -+ struct usb_ctrlrequest req; -+ bool_t read = (requesttype & USB_DIR_IN) != 0; -+ int ret; -+ -+ if ( size > (read ? DBGP_MAX_PACKET : 0) ) -+ return -EINVAL; -+ -+ /* Compute the control message */ -+ req.bRequestType = requesttype; -+ req.bRequest = request; -+ req.wValue = cpu_to_le16(value); -+ req.wIndex = cpu_to_le16(index); -+ req.wLength = cpu_to_le16(size); -+ -+ pids = DBGP_PID_SET(USB_PID_DATA0, USB_PID_SETUP); -+ addr = DBGP_EPADDR(devnum, 0); -+ ctrl = dbgp_len_update(readl(&dbgp->ehci_debug->control), sizeof(req)); -+ -+ /* Send the setup message */ -+ dbgp_set_data(dbgp->ehci_debug, &req, sizeof(req)); -+ writel(addr, &dbgp->ehci_debug->address); -+ writel(pids, &dbgp->ehci_debug->pids); -+ dbgp_issue_command(dbgp, ctrl, dbgp_ctrl); -+ ret = dbgp_wait_until_done(dbgp, ctrl, DBGP_LOOPS); -+ if ( ret < 0 ) -+ return ret; -+ -+ /* Read the result */ -+ ret = dbgp_bulk_read(dbgp, devnum, 0, size, &ctrl); -+ if ( !ret ) -+ ret = dbgp_wait_until_done(dbgp, ctrl, DBGP_LOOPS); -+ if ( ret > 0 ) -+ { -+ if ( size > ret ) -+ size = ret; -+ dbgp_get_data(dbgp->ehci_debug, data, size); -+ } -+ -+ return ret; -+} -+ -+static unsigned int __init __find_dbgp(u8 bus, u8 slot, u8 func) -+{ -+ u32 class = pci_conf_read32(0, bus, slot, func, PCI_CLASS_REVISION); -+ -+ if ( (class >> 8) != PCI_CLASS_SERIAL_USB_EHCI ) -+ return 0; -+ -+ return pci_find_cap_offset(0, bus, slot, func, PCI_CAP_ID_EHCI_DEBUG); -+} -+ -+static unsigned int __init find_dbgp(struct ehci_dbgp *dbgp, -+ unsigned int ehci_num) -+{ -+ unsigned int bus, slot, func; -+ -+ for ( bus = 0; bus < 256; bus++ ) -+ { -+ for ( slot = 0; slot < 32; slot++ ) -+ { -+ for ( func = 0; func < 8; func++ ) -+ { -+ unsigned int cap; -+ -+ if ( !pci_device_detect(0, bus, slot, func) ) -+ { -+ if ( !func ) -+ break; -+ continue; -+ } -+ -+ cap = __find_dbgp(bus, slot, func); -+ if ( !cap || ehci_num-- ) -+ { -+ if ( !func && !(pci_conf_read8(0, bus, slot, func, -+ PCI_HEADER_TYPE) & 0x80) ) -+ break; -+ continue; -+ } -+ -+ dbgp->bus = bus; -+ dbgp->slot = slot; -+ dbgp->func = func; -+ return cap; -+ } -+ } -+ } -+ -+ return 0; -+} -+ -+static int ehci_dbgp_startup(struct ehci_dbgp *dbgp) -+{ -+ u32 ctrl, cmd, status; -+ unsigned int loop; -+ -+ /* Claim ownership, but do not enable yet */ -+ ctrl = readl(&dbgp->ehci_debug->control); -+ ctrl |= DBGP_OWNER; -+ ctrl &= ~(DBGP_ENABLED | DBGP_INUSE); -+ writel(ctrl, &dbgp->ehci_debug->control); -+ udelay(1); -+ -+ ehci_dbgp_status(dbgp, "EHCI startup"); -+ /* Start the EHCI. */ -+ cmd = readl(&dbgp->ehci_regs->command); -+ cmd &= ~(CMD_LRESET | CMD_IAAD | CMD_PSE | CMD_ASE | CMD_RESET); -+ cmd |= CMD_RUN; -+ writel(cmd, &dbgp->ehci_regs->command); -+ -+ /* Ensure everything is routed to the EHCI */ -+ writel(FLAG_CF, &dbgp->ehci_regs->configured_flag); -+ -+ /* Wait until the controller is no longer halted. */ -+ loop = 1000; -+ do { -+ status = readl(&dbgp->ehci_regs->status); -+ if ( !(status & STS_HALT) ) -+ break; -+ udelay(1); -+ } while ( --loop ); -+ -+ if ( !loop ) -+ { -+ dbgp_printk("EHCI cannot be started\n"); -+ return -ENODEV; -+ } -+ dbgp_printk("EHCI started\n"); -+ -+ return 0; -+} -+ -+static int ehci_dbgp_controller_reset(struct ehci_dbgp *dbgp) -+{ -+ unsigned int loop = 250 * 1000; -+ u32 cmd; -+ -+ /* Reset the EHCI controller */ -+ cmd = readl(&dbgp->ehci_regs->command); -+ cmd |= CMD_RESET; -+ writel(cmd, &dbgp->ehci_regs->command); -+ do { -+ cmd = readl(&dbgp->ehci_regs->command); -+ } while ( (cmd & CMD_RESET) && --loop ); -+ -+ if ( !loop ) -+ { -+ dbgp_printk("cannot reset EHCI\n"); -+ return -1; -+ } -+ ehci_dbgp_status(dbgp, "ehci reset done"); -+ -+ return 0; -+} -+ -+static int ehci_reset_port(struct ehci_dbgp *dbgp, unsigned int port) -+{ -+ u32 portsc, delay_time, delay; -+ -+ ehci_dbgp_status(dbgp, "reset port"); -+ /* Reset the USB debug port. */ -+ portsc = readl(&dbgp->ehci_regs->port_status[port - 1]); -+ portsc &= ~PORT_PE; -+ portsc |= PORT_RESET; -+ writel(portsc, &dbgp->ehci_regs->port_status[port - 1]); -+ -+ delay = HUB_ROOT_RESET_TIME; -+ for ( delay_time = 0; delay_time < HUB_RESET_TIMEOUT; -+ delay_time += delay ) -+ { -+ dbgp_mdelay(delay); -+ portsc = readl(&dbgp->ehci_regs->port_status[port - 1]); -+ if (!(portsc & PORT_RESET)) -+ break; -+ } -+ -+ if ( portsc & PORT_RESET ) -+ { -+ /* force reset to complete */ -+ unsigned int loop = 100 * 1000; -+ -+ writel(portsc & ~(PORT_RWC_BITS | PORT_RESET), -+ &dbgp->ehci_regs->port_status[port - 1]); -+ do { -+ udelay(1); -+ portsc = readl(&dbgp->ehci_regs->port_status[port-1]); -+ } while ( (portsc & PORT_RESET) && --loop ); -+ } -+ -+ /* Device went away? */ -+ if ( !(portsc & PORT_CONNECT) ) -+ return -ENOTCONN; -+ -+ /* bomb out completely if something weird happened */ -+ if ( portsc & PORT_CSC ) -+ return -EINVAL; -+ -+ /* If we've finished resetting, then break out of the loop */ -+ if ( !(portsc & PORT_RESET) && (portsc & PORT_PE) ) -+ return 0; -+ -+ return -EBUSY; -+} -+ -+static int ehci_wait_for_port(struct ehci_dbgp *dbgp, unsigned int port) -+{ -+ u32 status; -+ unsigned int reps; -+ -+ for ( reps = 0; reps < 300; reps++ ) -+ { -+ status = readl(&dbgp->ehci_regs->status); -+ if ( status & STS_PCD ) -+ break; -+ dbgp_mdelay(1); -+ } -+ -+ return ehci_reset_port(dbgp, port) == 0 ? 0 : -ENOTCONN; -+} -+ -+/* Return 0 on success -+ * Return -ENODEV for any general failure -+ * Return -EIO if wait for port fails -+ */ -+static int ehci_dbgp_external_startup(struct ehci_dbgp *dbgp) -+{ -+ unsigned int devnum; -+ struct usb_debug_descriptor dbgp_desc; -+ int ret; -+ u32 ctrl, portsc, cmd; -+ unsigned int dbg_port = dbgp->phys_port; -+ unsigned int tries = 3; -+ unsigned int reset_port_tries = 1; -+ bool_t try_hard_once = 1; -+ -+try_port_reset_again: -+ ret = ehci_dbgp_startup(dbgp); -+ if ( ret ) -+ return ret; -+ -+ /* Wait for a device to show up in the debug port */ -+ ret = ehci_wait_for_port(dbgp, dbg_port); -+ if ( ret < 0 ) -+ { -+ portsc = readl(&dbgp->ehci_regs->port_status[dbg_port - 1]); -+ if ( !(portsc & PORT_CONNECT) && try_hard_once ) -+ { -+ /* -+ * Last ditch effort to try to force enable the debug device by -+ * using the packet test EHCI command to try and wake it up. -+ */ -+ try_hard_once = 0; -+ cmd = readl(&dbgp->ehci_regs->command); -+ cmd &= ~CMD_RUN; -+ writel(cmd, &dbgp->ehci_regs->command); -+ portsc = readl(&dbgp->ehci_regs->port_status[dbg_port - 1]); -+ portsc |= PORT_TEST_PKT; -+ writel(portsc, &dbgp->ehci_regs->port_status[dbg_port - 1]); -+ ehci_dbgp_status(dbgp, "Trying to force debug port online"); -+ mdelay(50); -+ ehci_dbgp_controller_reset(dbgp); -+ goto try_port_reset_again; -+ } -+ else if ( reset_port_tries-- ) -+ goto try_port_reset_again; -+ dbgp_printk("no device found in debug port\n"); -+ return -EIO; -+ } -+ ehci_dbgp_status(dbgp, "wait for port done"); -+ -+ /* Enable the debug port */ -+ ctrl = readl(&dbgp->ehci_debug->control); -+ ctrl |= DBGP_CLAIM; -+ writel(ctrl, &dbgp->ehci_debug->control); -+ ctrl = readl(&dbgp->ehci_debug->control); -+ if ( (ctrl & DBGP_CLAIM) != DBGP_CLAIM ) -+ { -+ dbgp_printk("no device in debug port\n"); -+ writel(ctrl & ~DBGP_CLAIM, &dbgp->ehci_debug->control); -+ return -ENODEV; -+ } -+ ehci_dbgp_status(dbgp, "debug port enabled"); -+ -+ /* Completely transfer the debug device to the debug controller */ -+ portsc = readl(&dbgp->ehci_regs->port_status[dbg_port - 1]); -+ portsc &= ~PORT_PE; -+ writel(portsc, &dbgp->ehci_regs->port_status[dbg_port - 1]); -+ -+ dbgp_mdelay(100); -+ -+try_again: -+ /* Find the debug device and make it device number 127 */ -+ for ( devnum = 0; devnum <= 127; devnum++ ) -+ { -+ ret = dbgp_control_msg(dbgp, devnum, -+ USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE, -+ USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0, -+ &dbgp_desc, sizeof(dbgp_desc)); -+ if ( ret > 0 ) -+ break; -+ } -+ if ( devnum > 127 ) -+ { -+ dbgp_printk("could not find attached debug device\n"); -+ goto err; -+ } -+ if ( ret < 0 ) -+ { -+ dbgp_printk("attached device is not a debug device\n"); -+ goto err; -+ } -+ dbgp->out.endpoint = dbgp_desc.bDebugOutEndpoint; -+ dbgp->in.endpoint = dbgp_desc.bDebugInEndpoint; -+ -+ /* Move the device to 127 if it isn't already there. */ -+ if ( devnum != USB_DEBUG_DEVNUM ) -+ { -+ ret = dbgp_control_msg(dbgp, devnum, -+ USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, -+ USB_REQ_SET_ADDRESS, USB_DEBUG_DEVNUM, 0, NULL, 0); -+ if ( ret < 0 ) -+ { -+ dbgp_printk("could not move attached device to %d\n", -+ USB_DEBUG_DEVNUM); -+ goto err; -+ } -+ devnum = USB_DEBUG_DEVNUM; -+ dbgp_printk("debug device renamed to 127\n"); -+ } -+ -+ /* Enable the debug interface */ -+ ret = dbgp_control_msg(dbgp, USB_DEBUG_DEVNUM, -+ USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, -+ USB_REQ_SET_FEATURE, USB_DEVICE_DEBUG_MODE, -+ 0, NULL, 0); -+ if ( ret < 0 ) -+ { -+ dbgp_printk("could not enable the debug device\n"); -+ goto err; -+ } -+ dbgp_printk("debug interface enabled\n"); -+ -+ /* Perform a small write to get the even/odd data state in sync. */ -+ ret = dbgp_bulk_write(dbgp, USB_DEBUG_DEVNUM, dbgp->out.endpoint, -+ "\n", 1, &ctrl); -+ if ( !ret ) -+ ret = dbgp_wait_until_done(dbgp, ctrl, DBGP_LOOPS); -+ if ( ret < 0 ) -+ { -+ dbgp_printk("dbgp_bulk_write failed: %d\n", ret); -+ goto err; -+ } -+ dbgp_printk("small write done\n"); -+ dbgp->state = dbgp_idle; -+ -+ return 0; -+err: -+ if ( tries-- ) -+ goto try_again; -+ return -ENODEV; -+} -+ -+typedef void (*set_debug_port_t)(struct ehci_dbgp *, unsigned int); -+ -+static void default_set_debug_port(struct ehci_dbgp *dbgp, unsigned int port) -+{ -+} -+ -+static set_debug_port_t __read_mostly set_debug_port = default_set_debug_port; -+ -+static void nvidia_set_debug_port(struct ehci_dbgp *dbgp, unsigned int port) -+{ -+ u32 dword = pci_conf_read32(0, dbgp->bus, dbgp->slot, dbgp->func, 0x74); -+ -+ dword &= ~(0x0f << 12); -+ dword |= (port & 0x0f) << 12; -+ pci_conf_write32(0, dbgp->bus, dbgp->slot, dbgp->func, 0x74, dword); -+ dbgp_printk("set debug port to %u\n", port); -+} -+ -+static void __init detect_set_debug_port(struct ehci_dbgp *dbgp) -+{ -+ if ( pci_conf_read16(0, dbgp->bus, dbgp->slot, dbgp->func, -+ PCI_VENDOR_ID) == 0x10de ) -+ { -+ dbgp_printk("using nvidia set_debug_port\n"); -+ set_debug_port = nvidia_set_debug_port; -+ } -+} -+ -+/* -+ * The code in ehci_dbgp_bios_handoff() is derived from the USB PCI -+ * quirk initialization in Linux. -+ */ -+#define EHCI_USBLEGSUP_BIOS (1 << 16) /* BIOS semaphore */ -+#define EHCI_USBLEGCTLSTS 4 /* legacy control/status */ -+static void ehci_dbgp_bios_handoff(struct ehci_dbgp *dbgp, u32 hcc_params) -+{ -+ u32 cap; -+ unsigned int offset = HCC_EXT_CAPS(hcc_params); -+ int msec; -+ -+ if ( !offset ) -+ return; -+ -+ cap = pci_conf_read32(0, dbgp->bus, dbgp->slot, dbgp->func, offset); -+ dbgp_printk("dbgp: EHCI BIOS state %08x\n", cap); -+ -+ if ( (cap & 0xff) == 1 && (cap & EHCI_USBLEGSUP_BIOS) ) -+ { -+ dbgp_printk("dbgp: BIOS handoff\n"); -+ pci_conf_write8(0, dbgp->bus, dbgp->slot, dbgp->func, offset + 3, 1); -+ } -+ -+ /* if boot firmware now owns EHCI, spin till it hands it over. */ -+ msec = 1000; -+ while ( (cap & EHCI_USBLEGSUP_BIOS) && (msec > 0) ) -+ { -+ mdelay(10); -+ msec -= 10; -+ cap = pci_conf_read32(0, dbgp->bus, dbgp->slot, dbgp->func, offset); -+ } -+ -+ if ( cap & EHCI_USBLEGSUP_BIOS ) -+ { -+ /* well, possibly buggy BIOS... try to shut it down, -+ * and hope nothing goes too wrong */ -+ dbgp_printk("dbgp: BIOS handoff failed: %08x\n", cap); -+ pci_conf_write8(0, dbgp->bus, dbgp->slot, dbgp->func, offset + 2, 0); -+ } -+ -+ /* just in case, always disable EHCI SMIs */ -+ pci_conf_write8(0, dbgp->bus, dbgp->slot, dbgp->func, -+ offset + EHCI_USBLEGCTLSTS, 0); -+} -+ -+static int ehci_dbgp_setup(struct ehci_dbgp *dbgp) -+{ -+ u32 ctrl, portsc, hcs_params; -+ unsigned int i, debug_port, new_debug_port = 0, n_ports; -+ unsigned int port_map_tried, playtimes = 3; -+ int ret; -+ -+ ehci_dbgp_bios_handoff(dbgp, readl(&dbgp->ehci_caps->hcc_params)); -+ -+try_next_time: -+ port_map_tried = 0; -+ -+try_next_port: -+ -+ hcs_params = readl(&dbgp->ehci_caps->hcs_params); -+ debug_port = HCS_DEBUG_PORT(hcs_params); -+ dbgp->phys_port = debug_port; -+ n_ports = HCS_N_PORTS(hcs_params); -+ -+ dbgp_printk("debug_port: %u\n", debug_port); -+ dbgp_printk("n_ports: %u\n", n_ports); -+ ehci_dbgp_status(dbgp, ""); -+ -+ for ( i = 1; i <= n_ports; i++ ) -+ { -+ portsc = readl(&dbgp->ehci_regs->port_status[i-1]); -+ dbgp_printk("portstatus%d: %08x\n", i, portsc); -+ } -+ -+ if ( port_map_tried && (new_debug_port != debug_port) ) -+ { -+ if ( --playtimes ) -+ { -+ set_debug_port(dbgp, new_debug_port); -+ goto try_next_time; -+ } -+ return -1; -+ } -+ -+ /* Only reset the controller if it is not already in the -+ * configured state */ -+ if ( readl(&dbgp->ehci_regs->configured_flag) & FLAG_CF ) -+ ehci_dbgp_status(dbgp, "ehci skip - already configured"); -+ else if ( ehci_dbgp_controller_reset(dbgp) != 0 ) -+ return -1; -+ -+ ret = ehci_dbgp_external_startup(dbgp); -+ if (ret == -EIO) -+ goto next_debug_port; -+ -+ if ( ret < 0 ) -+ { -+ /* Things didn't work so remove my claim */ -+ ctrl = readl(&dbgp->ehci_debug->control); -+ ctrl &= ~(DBGP_CLAIM | DBGP_OUT); -+ writel(ctrl, &dbgp->ehci_debug->control); -+ return -1; -+ } -+ -+ return 0; -+ -+next_debug_port: -+ port_map_tried |= 1 << (debug_port - 1); -+ new_debug_port = (debug_port % n_ports) + 1; -+ if ( port_map_tried != ((1 << n_ports) - 1) ) -+ { -+ set_debug_port(dbgp, new_debug_port); -+ goto try_next_port; -+ } -+ if ( --playtimes ) -+ { -+ set_debug_port(dbgp, new_debug_port); -+ goto try_next_time; -+ } -+ -+ return -1; -+} -+ -+static inline void _ehci_dbgp_flush(struct ehci_dbgp *dbgp) -+{ -+ if ( dbgp_bulk_write(dbgp, USB_DEBUG_DEVNUM, dbgp->out.endpoint, -+ dbgp->out.buf, dbgp->out.chunk, NULL) ) -+ BUG(); -+ dbgp->out.chunk = 0; -+} -+ -+static void ehci_dbgp_flush(struct serial_port *port) -+{ -+ struct ehci_dbgp *dbgp = port->uart; -+ s_time_t goal; -+ -+ if ( !dbgp->out.chunk || !dbgp->ehci_debug || dbgp->state == dbgp_unsafe ) -+ return; -+ -+ if ( dbgp->state == dbgp_idle || !port->sync ) -+ dbgp_check_for_completion(dbgp, 1, NULL); -+ else -+ dbgp_wait_until_complete(dbgp, NULL); -+ -+ if ( dbgp->state == dbgp_idle ) -+ { -+ _ehci_dbgp_flush(dbgp); -+ -+ if ( port->sync ) -+ { -+ dbgp_wait_until_complete(dbgp, NULL); -+ return; -+ } -+ } -+ -+ goal = NOW() + MICROSECS(DBGP_CHECK_INTERVAL); -+ if ( dbgp->timer.expires > goal ) -+ set_timer(&dbgp->timer, goal); -+} -+ -+static void ehci_dbgp_putc(struct serial_port *port, char c) -+{ -+ struct ehci_dbgp *dbgp = port->uart; -+ -+ if ( unlikely(dbgp->out.chunk >= DBGP_MAX_PACKET) ) -+ return; -+ -+ dbgp->out.buf[dbgp->out.chunk++] = c; -+ -+ if ( dbgp->out.chunk == DBGP_MAX_PACKET ) -+ ehci_dbgp_flush(port); -+} -+ -+static int ehci_dbgp_tx_empty(struct serial_port *port) -+{ -+ struct ehci_dbgp *dbgp = port->uart; -+ -+ if ( unlikely(!dbgp->ehci_debug) || unlikely(dbgp->state == dbgp_unsafe) ) -+ return port->sync || port->tx_log_everything || !port->txbuf; -+ -+ if ( dbgp->out.chunk == DBGP_MAX_PACKET ) -+ ehci_dbgp_flush(port); -+ else -+ dbgp_check_for_completion(dbgp, 1, NULL); -+ -+ if ( dbgp->state != dbgp_idle && dbgp->out.chunk >= DBGP_MAX_PACKET ) -+ return 0; -+ -+ port->tx_fifo_size = DBGP_MAX_PACKET - dbgp->out.chunk; -+ if ( dbgp->state == dbgp_idle ) -+ port->tx_fifo_size += DBGP_MAX_PACKET; -+ -+ return 1; -+} -+ -+static int ehci_dbgp_getc(struct serial_port *port, char *pc) -+{ -+ struct ehci_dbgp *dbgp = port->uart; -+ -+ if ( !dbgp->in.chunk ) -+ return 0; -+ -+ *pc = *dbgp->in.buf; -+ if ( --dbgp->in.chunk ) -+ memmove(dbgp->in.buf, dbgp->in.buf + 1, dbgp->in.chunk); -+ -+ return 1; -+} -+ -+/* Safe: ehci_dbgp_poll() runs as timer handler, so not reentrant. */ -+static struct serial_port *poll_port; -+ -+static void _ehci_dbgp_poll(struct cpu_user_regs *regs) -+{ -+ struct serial_port *port = poll_port; -+ struct ehci_dbgp *dbgp = port->uart; -+ unsigned long flags; -+ unsigned int timeout = MICROSECS(DBGP_CHECK_INTERVAL); -+ bool_t empty = 0; -+ -+ if ( !dbgp->ehci_debug ) -+ return; -+ -+ if ( spin_trylock_irqsave(&port->tx_lock, flags) ) -+ { -+ if ( dbgp->state != dbgp_unsafe ) -+ dbgp_check_for_completion(dbgp, DBGP_CHECK_INTERVAL, NULL); -+ if ( dbgp->state == dbgp_idle && dbgp->out.chunk ) -+ _ehci_dbgp_flush(dbgp); -+ if ( dbgp->state == dbgp_idle || dbgp->out.chunk < DBGP_MAX_PACKET ) -+ empty = 1; -+ spin_unlock_irqrestore(&port->tx_lock, flags); -+ } -+ -+ if ( dbgp->in.chunk ) -+ serial_rx_interrupt(port, regs); -+ -+ if ( empty ) -+ serial_tx_interrupt(port, regs); -+ -+ if ( spin_trylock_irqsave(&port->tx_lock, flags) ) -+ { -+ if ( dbgp->state == dbgp_idle && !dbgp->in.chunk && -+ !dbgp->out.chunk && port->txbufp == port->txbufc ) -+ { -+ if ( dbgp_bulk_read(dbgp, USB_DEBUG_DEVNUM, dbgp->in.endpoint, -+ DBGP_MAX_PACKET, NULL) ) -+ BUG(); -+ timeout = MILLISECS(DBGP_IDLE_INTERVAL); -+ } -+ spin_unlock_irqrestore(&port->tx_lock, flags); -+ } -+ -+ set_timer(&dbgp->timer, NOW() + timeout); -+} -+ -+static void ehci_dbgp_poll(void *data) -+{ -+ poll_port = data; -+#ifdef run_in_exception_handler -+ run_in_exception_handler(_ehci_dbgp_poll); -+#else -+ _ehci_dbgp_poll(guest_cpu_user_regs()); -+#endif -+} -+ -+static bool_t ehci_dbgp_setup_preirq(struct ehci_dbgp *dbgp) -+{ -+ if ( !ehci_dbgp_setup(dbgp) ) -+ return 1; -+ -+ dbgp_printk("ehci_dbgp_setup failed\n"); -+ dbgp->ehci_debug = NULL; -+ return 0; -+} -+ -+static void __init ehci_dbgp_init_preirq(struct serial_port *port) -+{ -+ struct ehci_dbgp *dbgp = port->uart; -+ u32 debug_port, offset; -+ void __iomem *ehci_bar; -+ -+ debug_port = pci_conf_read32(0, dbgp->bus, dbgp->slot, dbgp->func, -+ dbgp->cap); -+ offset = (debug_port >> 16) & 0xfff; -+ -+ /* double check if the mem space is enabled */ -+ dbgp->pci_cr = pci_conf_read8(0, dbgp->bus, dbgp->slot, dbgp->func, -+ PCI_COMMAND); -+ if ( !(dbgp->pci_cr & PCI_COMMAND_MEMORY) ) -+ { -+ dbgp->pci_cr |= PCI_COMMAND_MEMORY; -+ pci_conf_write16(0, dbgp->bus, dbgp->slot, dbgp->func, PCI_COMMAND, -+ dbgp->pci_cr); -+ dbgp_printk("MMIO for EHCI enabled\n"); -+ } -+ -+ /* -+ * FIXME I don't have the bar size so just guess PAGE_SIZE is more -+ * than enough. 1k is the biggest that was seen. -+ */ -+ set_fixmap_nocache(FIX_EHCI_DBGP, dbgp->bar_val); -+ ehci_bar = (void __iomem *)fix_to_virt(FIX_EHCI_DBGP); -+ ehci_bar += dbgp->bar_val & ~PAGE_MASK; -+ dbgp_printk("ehci_bar: %p\n", ehci_bar); -+ -+ dbgp->ehci_caps = ehci_bar; -+ dbgp->ehci_regs = ehci_bar + -+ HC_LENGTH(readl(&dbgp->ehci_caps->hc_capbase)); -+ dbgp->ehci_debug = ehci_bar + offset; -+ -+ detect_set_debug_port(dbgp); -+ -+ if ( ehci_dbgp_setup_preirq(dbgp) ) -+ ehci_dbgp_status(dbgp, "ehci_dbgp_init_preirq complete"); -+ -+ port->tx_fifo_size = DBGP_MAX_PACKET; -+ dbgp->lock = &port->tx_lock; -+} -+ -+static void ehci_dbgp_setup_postirq(struct ehci_dbgp *dbgp) -+{ -+ set_timer(&dbgp->timer, NOW() + MILLISECS(1)); -+} -+ -+static void __init ehci_dbgp_init_postirq(struct serial_port *port) -+{ -+ struct ehci_dbgp *dbgp = port->uart; -+ -+ if ( !dbgp->ehci_debug ) -+ return; -+ -+ serial_async_transmit(port); -+ -+ init_timer(&dbgp->timer, ehci_dbgp_poll, port, 0); -+ -+ ehci_dbgp_setup_postirq(dbgp); -+} -+ -+static int ehci_dbgp_check_release(struct ehci_dbgp *dbgp) -+{ -+ struct ehci_dbg_port __iomem *ehci_debug = dbgp->ehci_debug; -+ u32 ctrl; -+ unsigned int i; -+ -+ if ( !ehci_debug ) -+ return 0; -+ -+ for ( i = 0; i < DBGP_MAX_PACKET; ++i ) -+ if ( dbgp->out.buf[i] ) -+ return 1; -+ -+ /* -+ * This means the console is not initialized, or should get shutdown -+ * so as to allow for reuse of the USB device, which means it is time -+ * to shutdown the USB debug port. -+ */ -+ printk(XENLOG_INFO "Releasing EHCI debug port at %02x:%02x.%u\n", -+ dbgp->bus, dbgp->slot, dbgp->func); -+ -+ kill_timer(&dbgp->timer); -+ dbgp->ehci_debug = NULL; -+ -+ ctrl = readl(&ehci_debug->control); -+ if ( ctrl & DBGP_ENABLED ) -+ { -+ ctrl &= ~DBGP_CLAIM; -+ writel(ctrl, &ehci_debug->control); -+ } -+ -+ return 0; -+} -+ -+static void __init ehci_dbgp_endboot(struct serial_port *port) -+{ -+ ehci_dbgp_check_release(port->uart); -+} -+ -+static void ehci_dbgp_suspend(struct serial_port *port) -+{ -+ struct ehci_dbgp *dbgp = port->uart; -+ -+ if ( !dbgp->ehci_debug ) -+ return; -+ -+ stop_timer(&dbgp->timer); -+ dbgp->timer.expires = 0; -+ -+ dbgp->pci_cr = pci_conf_read16(0, dbgp->bus, dbgp->slot, dbgp->func, -+ PCI_COMMAND); -+ -+ dbgp->state = dbgp_unsafe; -+} -+ -+static void ehci_dbgp_resume(struct serial_port *port) -+{ -+ struct ehci_dbgp *dbgp = port->uart; -+ -+ if ( !dbgp->ehci_debug ) -+ return; -+ -+ pci_conf_write32(0, dbgp->bus, dbgp->slot, dbgp->func, dbgp->bar, -+ dbgp->bar_val); -+ pci_conf_write16(0, dbgp->bus, dbgp->slot, dbgp->func, -+ PCI_COMMAND, dbgp->pci_cr); -+ -+ ehci_dbgp_setup_preirq(dbgp); -+ ehci_dbgp_setup_postirq(dbgp); -+} -+ -+static struct uart_driver __read_mostly ehci_dbgp_driver = { -+ .init_preirq = ehci_dbgp_init_preirq, -+ .init_postirq = ehci_dbgp_init_postirq, -+ .endboot = ehci_dbgp_endboot, -+ .suspend = ehci_dbgp_suspend, -+ .resume = ehci_dbgp_resume, -+ .tx_empty = ehci_dbgp_tx_empty, -+ .putc = ehci_dbgp_putc, -+ .flush = ehci_dbgp_flush, -+ .getc = ehci_dbgp_getc -+}; -+ -+static struct ehci_dbgp ehci_dbgp = { .state = dbgp_unsafe, .phys_port = 1 }; -+ -+static char __initdata opt_dbgp[30]; -+string_param("dbgp", opt_dbgp); -+ -+void __init ehci_dbgp_init(void) -+{ -+ struct ehci_dbgp *dbgp = &ehci_dbgp; -+ u32 debug_port, offset, bar_val; -+ const char *e; -+ -+ if ( strncmp(opt_dbgp, "ehci", 4) ) -+ return; -+ -+ if ( isdigit(opt_dbgp[4]) || !opt_dbgp[4] ) -+ { -+ unsigned int num = 0; -+ -+ if ( opt_dbgp[4] ) -+ simple_strtoul(opt_dbgp + 4, &e, 10); -+ -+ dbgp->cap = find_dbgp(dbgp, num); -+ if ( !dbgp->cap ) -+ return; -+ -+ dbgp_printk("Found EHCI debug port on %02x:%02x.%u\n", -+ dbgp->bus, dbgp->slot, dbgp->func); -+ } -+ else if ( strncmp(opt_dbgp + 4, "@pci", 4) == 0 ) -+ { -+ unsigned long val = simple_strtoul(opt_dbgp + 8, &e, 16); -+ -+ dbgp->bus = val; -+ if ( dbgp->bus != val || *e != ':' ) -+ return; -+ -+ val = simple_strtoul(e + 1, &e, 16); -+ if ( PCI_SLOT(PCI_DEVFN(val, 0)) != val || *e != '.' ) -+ return; -+ dbgp->slot = val; -+ -+ val = simple_strtoul(e + 1, &e, 16); -+ if ( PCI_FUNC(PCI_DEVFN(0, val)) != val || *e ) -+ return; -+ dbgp->func = val; -+ -+ if ( !pci_device_detect(0, dbgp->bus, dbgp->slot, dbgp->func) ) -+ return; -+ -+ dbgp->cap = __find_dbgp(dbgp->bus, dbgp->slot, dbgp->func); -+ if ( !dbgp->cap ) -+ return; -+ -+ dbgp_printk("Using EHCI debug port on %02x:%02x.%u\n", -+ dbgp->bus, dbgp->slot, dbgp->func); -+ } -+ else -+ return; -+ -+ debug_port = pci_conf_read32(0, dbgp->bus, dbgp->slot, dbgp->func, -+ dbgp->cap); -+ dbgp->bar = (debug_port >> 29) & 0x7; -+ dbgp->bar = ((dbgp->bar - 1) * 4) + PCI_BASE_ADDRESS_0; -+ offset = (debug_port >> 16) & 0xfff; -+ dbgp_printk("bar: %02x offset: %03x\n", dbgp->bar, offset); -+ if ( dbgp->bar < PCI_BASE_ADDRESS_0 || dbgp->bar > PCI_BASE_ADDRESS_5 ) -+ { -+ dbgp_printk("unsupported/invalid bar\n"); -+ return; -+ } -+ -+ dbgp->bar_val = bar_val = pci_conf_read32(0, dbgp->bus, dbgp->slot, -+ dbgp->func, dbgp->bar); -+ dbgp_printk("bar_val: %08x\n", bar_val); -+ if ( bar_val & ~PCI_BASE_ADDRESS_MEM_MASK ) -+ { -+ dbgp_printk("only simple 32-bit MMIO BARs supported\n"); -+ return; -+ } -+ bar_val &= PCI_BASE_ADDRESS_MEM_MASK; -+ if ( !bar_val || !(bar_val + (bar_val & -bar_val)) ) -+ { -+ dbgp_printk("firmware initialization of MMIO BAR required\n"); -+ return; -+ } -+ -+ serial_register_uart(SERHND_DBGP, &ehci_dbgp_driver, dbgp); -+} -+ -+int dbgp_op(const struct physdev_dbgp_op *op) -+{ -+ if ( !ehci_dbgp.ehci_debug ) -+ return 0; -+ -+ switch ( op->bus ) -+ { -+ case PHYSDEVOP_DBGP_BUS_UNKNOWN: -+ break; -+ case PHYSDEVOP_DBGP_BUS_PCI: -+ if ( op->u.pci.seg || ehci_dbgp.bus != op->u.pci.bus || -+ PCI_DEVFN(ehci_dbgp.slot, ehci_dbgp.func) != op->u.pci.devfn ) -+ default: -+ return 0; -+ break; -+ } -+ -+ switch ( op->op ) -+ { -+ case PHYSDEVOP_DBGP_RESET_PREPARE: -+ spin_lock_irq(ehci_dbgp.lock); -+ ehci_dbgp.state = dbgp_unsafe; -+ dbgp_wait_until_complete(&ehci_dbgp, NULL); -+ spin_unlock_irq(ehci_dbgp.lock); -+ -+ return ehci_dbgp_check_release(&ehci_dbgp); -+ -+ case PHYSDEVOP_DBGP_RESET_DONE: -+ return ehci_dbgp_external_startup(&ehci_dbgp) ?: 1; -+ } -+ -+ return -ENOSYS; -+} -Index: xen-4.2.2-testing/xen/drivers/char/serial.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/char/serial.c -+++ xen-4.2.2-testing/xen/drivers/char/serial.c -@@ -265,6 +265,14 @@ int __init serial_parse_handle(char *con - { - int handle; - -+ if ( !strncmp(conf, "dbgp", 4) && (!conf[4] || conf[4] == ',') ) -+ { -+ if ( !com[SERHND_DBGP].driver ) -+ goto fail; -+ -+ return SERHND_DBGP | SERHND_COOKED; -+ } -+ - if ( strncmp(conf, "com", 3) ) - goto fail; - -Index: xen-4.2.2-testing/xen/include/asm-x86/fixmap.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/fixmap.h -+++ xen-4.2.2-testing/xen/include/asm-x86/fixmap.h -@@ -36,7 +36,15 @@ - * from the end of virtual memory backwards. - */ - enum fixed_addresses { -- FIX_RESERVED, /* Index 0 is reserved since fix_to_virt(0) > FIXADDR_TOP. */ -+ /* Index 0 is reserved since fix_to_virt(0) == FIXADDR_TOP. */ -+ FIX_RESERVED, -+ /* -+ * Indexes using the page tables set up before entering __start_xen() -+ * must be among the first (L1_PAGETABLE_ENTRIES - 1) entries. -+ * These are generally those needed by the various console drivers. -+ */ -+ FIX_EHCI_DBGP, -+ /* Everything else should go further down. */ - #ifdef __i386__ - FIX_PAE_HIGHMEM_0, - FIX_PAE_HIGHMEM_END = FIX_PAE_HIGHMEM_0 + NR_CPUS-1, -Index: xen-4.2.2-testing/xen/include/public/physdev.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/public/physdev.h -+++ xen-4.2.2-testing/xen/include/public/physdev.h -@@ -318,6 +318,24 @@ struct physdev_pci_device { - typedef struct physdev_pci_device physdev_pci_device_t; - DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_t); - -+#define PHYSDEVOP_DBGP_RESET_PREPARE 1 -+#define PHYSDEVOP_DBGP_RESET_DONE 2 -+ -+#define PHYSDEVOP_DBGP_BUS_UNKNOWN 0 -+#define PHYSDEVOP_DBGP_BUS_PCI 1 -+ -+#define PHYSDEVOP_dbgp_op 29 -+struct physdev_dbgp_op { -+ /* IN */ -+ uint8_t op; -+ uint8_t bus; -+ union { -+ struct physdev_pci_device pci; -+ } u; -+}; -+typedef struct physdev_dbgp_op physdev_dbgp_op_t; -+DEFINE_XEN_GUEST_HANDLE(physdev_dbgp_op_t); -+ - /* - * Notify that some PIRQ-bound event channels have been unmasked. - * ** This command is obsolete since interface version 0x00030202 and is ** -Index: xen-4.2.2-testing/xen/include/xen/serial.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/serial.h -+++ xen-4.2.2-testing/xen/include/xen/serial.h -@@ -69,9 +69,10 @@ struct uart_driver { - }; - - /* 'Serial handles' are composed from the following fields. */ --#define SERHND_IDX (3<<0) /* COM1 or COM2? */ -+#define SERHND_IDX (3<<0) /* COM1, COM2, or DBGP? */ - # define SERHND_COM1 (0<<0) - # define SERHND_COM2 (1<<0) -+# define SERHND_DBGP (2<<0) - #define SERHND_HI (1<<2) /* Mux/demux each transferred char by MSB. */ - #define SERHND_LO (1<<3) /* Ditto, except that the MSB is cleared. */ - #define SERHND_COOKED (1<<4) /* Newline/carriage-return translation? */ -@@ -142,9 +143,13 @@ struct ns16550_defaults { - unsigned long io_base; /* default io_base address */ - }; - void ns16550_init(int index, struct ns16550_defaults *defaults); -+void ehci_dbgp_init(void); - - void pl011_init(int index, unsigned long register_base_address); - -+struct physdev_dbgp_op; -+int dbgp_op(const struct physdev_dbgp_op *); -+ - /* Baud rate was pre-configured before invoking the UART driver. */ - #define BAUD_AUTO (-1) - diff --git a/25864-sercon-unused.patch b/25864-sercon-unused.patch deleted file mode 100644 index 9830025..0000000 --- a/25864-sercon-unused.patch +++ /dev/null @@ -1,142 +0,0 @@ -# HG changeset patch -# User Jan Beulich -# Date 1347371512 -7200 -# Node ID e1380b5311ccee14eb47d7badb75339933d42249 -# Parent 0d0c55a1975db9c6cac2e9259b5ebea7a7bdbaec -serial: avoid fully initializing unused consoles - -Defer calling the drivers' post-IRQ initialization functions (generally -doing allocation of transmit buffers) until it is known that the -respective console is actually going to be used. - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser - ---- a/xen/drivers/char/ehci-dbgp.c -+++ b/xen/drivers/char/ehci-dbgp.c -@@ -1391,7 +1391,8 @@ static int ehci_dbgp_check_release(struc - printk(XENLOG_INFO "Releasing EHCI debug port at %02x:%02x.%u\n", - dbgp->bus, dbgp->slot, dbgp->func); - -- kill_timer(&dbgp->timer); -+ if ( dbgp->timer.function ) -+ kill_timer(&dbgp->timer); - dbgp->ehci_debug = NULL; - - ctrl = readl(&ehci_debug->control); ---- a/xen/drivers/char/serial.c -+++ b/xen/drivers/char/serial.c -@@ -29,6 +29,8 @@ static struct serial_port com[SERHND_IDX - } - }; - -+static bool_t __read_mostly post_irq; -+ - void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs) - { - char c; -@@ -263,14 +265,12 @@ char serial_getc(int handle) - - int __init serial_parse_handle(char *conf) - { -- int handle; -+ int handle, flags = 0; - - if ( !strncmp(conf, "dbgp", 4) && (!conf[4] || conf[4] == ',') ) - { -- if ( !com[SERHND_DBGP].driver ) -- goto fail; -- -- return SERHND_DBGP | SERHND_COOKED; -+ handle = SERHND_DBGP; -+ goto common; - } - - if ( strncmp(conf, "com", 3) ) -@@ -288,17 +288,25 @@ int __init serial_parse_handle(char *con - goto fail; - } - -- if ( !com[handle].driver ) -- goto fail; -- - if ( conf[4] == 'H' ) -- handle |= SERHND_HI; -+ flags |= SERHND_HI; - else if ( conf[4] == 'L' ) -- handle |= SERHND_LO; -+ flags |= SERHND_LO; - -- handle |= SERHND_COOKED; -+ common: -+ if ( !com[handle].driver ) -+ goto fail; -+ -+ if ( !post_irq ) -+ com[handle].state = serial_parsed; -+ else if ( com[handle].state != serial_initialized ) -+ { -+ if ( com[handle].driver->init_postirq ) -+ com[handle].driver->init_postirq(&com[handle]); -+ com[handle].state = serial_initialized; -+ } - -- return handle; -+ return handle | flags | SERHND_COOKED; - - fail: - return -1; -@@ -450,8 +458,13 @@ void __init serial_init_postirq(void) - { - int i; - for ( i = 0; i < ARRAY_SIZE(com); i++ ) -- if ( com[i].driver && com[i].driver->init_postirq ) -- com[i].driver->init_postirq(&com[i]); -+ if ( com[i].state == serial_parsed ) -+ { -+ if ( com[i].driver->init_postirq ) -+ com[i].driver->init_postirq(&com[i]); -+ com[i].state = serial_initialized; -+ } -+ post_irq = 1; - } - - void __init serial_endboot(void) -@@ -475,7 +488,7 @@ void serial_suspend(void) - { - int i; - for ( i = 0; i < ARRAY_SIZE(com); i++ ) -- if ( com[i].driver && com[i].driver->suspend ) -+ if ( com[i].state == serial_initialized && com[i].driver->suspend ) - com[i].driver->suspend(&com[i]); - } - -@@ -483,7 +496,7 @@ void serial_resume(void) - { - int i; - for ( i = 0; i < ARRAY_SIZE(com); i++ ) -- if ( com[i].driver && com[i].driver->resume ) -+ if ( com[i].state == serial_initialized && com[i].driver->resume ) - com[i].driver->resume(&com[i]); - } - ---- a/xen/include/xen/serial.h -+++ b/xen/include/xen/serial.h -@@ -25,10 +25,17 @@ extern unsigned int serial_txbufsz; - - struct uart_driver; - -+enum serial_port_state { -+ serial_unused, -+ serial_parsed, -+ serial_initialized -+}; -+ - struct serial_port { - /* Uart-driver parameters. */ - struct uart_driver *driver; - void *uart; -+ enum serial_port_state state; - /* Number of characters the port can hold for transmit. */ - int tx_fifo_size; - /* Transmit data buffer (interrupt-driven uart). */ diff --git a/25866-sercon-ns16550-pci-irq.patch b/25866-sercon-ns16550-pci-irq.patch deleted file mode 100644 index 8856988..0000000 --- a/25866-sercon-ns16550-pci-irq.patch +++ /dev/null @@ -1,56 +0,0 @@ -# HG changeset patch -# User Jan Beulich -# Date 1347371733 -7200 -# Node ID ee12dc357fbecbb0517798f395d14bf1764c6766 -# Parent 5fb5b3b70e34ef278d06aff27878b4b8e6d9145f -ns16550: PCI initialization adjustments - -Besides single-port serial cards, also accept multi-port ones and such -providing mixed functionality (e.g. also having a parallel port). - -Reading PCI_INTERRUPT_PIN before ACPI gets enabled generally produces -an incorrect IRQ (below 16, whereas after enabling ACPI it frequently -would end up at a higher one), so this is useful (almost) only when a -system already boots in ACPI mode. - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser - ---- a/xen/drivers/char/ns16550.c -+++ b/xen/drivers/char/ns16550.c -@@ -449,7 +449,6 @@ static int __init check_existence(struct - static int - pci_uart_config (struct ns16550 *uart, int skip_amt, int bar_idx) - { -- uint16_t class; - uint32_t bar, len; - int b, d, f; - -@@ -460,9 +459,15 @@ pci_uart_config (struct ns16550 *uart, i - { - for ( f = 0; f < 0x8; f++ ) - { -- class = pci_conf_read16(0, b, d, f, PCI_CLASS_DEVICE); -- if ( class != 0x700 ) -+ switch ( pci_conf_read16(0, b, d, f, PCI_CLASS_DEVICE) ) -+ { -+ case 0x0700: /* single port serial */ -+ case 0x0702: /* multi port serial */ -+ case 0x0780: /* other (e.g serial+parallel) */ -+ break; -+ default: - continue; -+ } - - bar = pci_conf_read32(0, b, d, f, - PCI_BASE_ADDRESS_0 + bar_idx*4); -@@ -485,7 +490,8 @@ pci_uart_config (struct ns16550 *uart, i - uart->bar = bar; - uart->bar_idx = bar_idx; - uart->io_base = bar & 0xfffe; -- uart->irq = 0; -+ uart->irq = pci_conf_read8(0, b, d, f, PCI_INTERRUPT_PIN) ? -+ pci_conf_read8(0, b, d, f, PCI_INTERRUPT_LINE) : 0; - - return 0; - } diff --git a/25867-sercon-ns16550-parse.patch b/25867-sercon-ns16550-parse.patch deleted file mode 100644 index 9bd872c..0000000 --- a/25867-sercon-ns16550-parse.patch +++ /dev/null @@ -1,100 +0,0 @@ -# HG changeset patch -# User Jan Beulich -# Date 1347371805 -7200 -# Node ID b22f184e1a3cac03abeed92ec4b74235fd0881f4 -# Parent ee12dc357fbecbb0517798f395d14bf1764c6766 -ns16550: command line parsing adjustments - -Allow intermediate parts of the command line options to be absent -(expressed by two immediately succeeding commas). - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser - ---- a/docs/misc/xen-command-line.markdown -+++ b/docs/misc/xen-command-line.markdown -@@ -199,7 +199,7 @@ If set, override Xen's calculation of th - If set, override Xen's default choice for the platform timer. - - ### com1,com2 --> `= [/][,DPS[,[,[,[,]]]] | pci | amt ] ` -+> `= [/][,[DPS][,[|pci|amt][,[][,[][,[]]]]]]` - - Both option `com1` and `com2` follow the same format. - ---- a/xen/drivers/char/ns16550.c -+++ b/xen/drivers/char/ns16550.c -@@ -536,26 +536,23 @@ static void __init ns16550_parse_port_co - else if ( (baud = simple_strtoul(conf, &conf, 10)) != 0 ) - uart->baud = baud; - -- if ( *conf == '/') -+ if ( *conf == '/' ) - { - conf++; - uart->clock_hz = simple_strtoul(conf, &conf, 0) << 4; - } - -- if ( *conf != ',' ) -- goto config_parsed; -- conf++; -- -- uart->data_bits = simple_strtoul(conf, &conf, 10); -+ if ( *conf == ',' && *++conf != ',' ) -+ { -+ uart->data_bits = simple_strtoul(conf, &conf, 10); - -- uart->parity = parse_parity_char(*conf); -- conf++; -+ uart->parity = parse_parity_char(*conf); - -- uart->stop_bits = simple_strtoul(conf, &conf, 10); -+ uart->stop_bits = simple_strtoul(conf + 1, &conf, 10); -+ } - -- if ( *conf == ',' ) -+ if ( *conf == ',' && *++conf != ',' ) - { -- conf++; - if ( strncmp(conf, "pci", 3) == 0 ) - { - if ( pci_uart_config(uart, 1/* skip AMT */, uart - ns16550_com) ) -@@ -572,24 +569,21 @@ static void __init ns16550_parse_port_co - { - uart->io_base = simple_strtoul(conf, &conf, 0); - } -+ } - -- if ( *conf == ',' ) -- { -- conf++; -- uart->irq = simple_strtoul(conf, &conf, 10); -- if ( *conf == ',' ) -- { -- conf++; -- uart->ps_bdf_enable = 1; -- parse_pci_bdf(&conf, &uart->ps_bdf[0]); -- if ( *conf == ',' ) -- { -- conf++; -- uart->pb_bdf_enable = 1; -- parse_pci_bdf(&conf, &uart->pb_bdf[0]); -- } -- } -- } -+ if ( *conf == ',' && *++conf != ',' ) -+ uart->irq = simple_strtol(conf, &conf, 10); -+ -+ if ( *conf == ',' && *++conf != ',' ) -+ { -+ uart->ps_bdf_enable = 1; -+ parse_pci_bdf(&conf, &uart->ps_bdf[0]); -+ } -+ -+ if ( *conf == ',' && *++conf != ',' ) -+ { -+ uart->pb_bdf_enable = 1; -+ parse_pci_bdf(&conf, &uart->pb_bdf[0]); - } - - config_parsed: diff --git a/25874-x86-EFI-chain-cfg.patch b/25874-x86-EFI-chain-cfg.patch deleted file mode 100644 index 7eb1dc8..0000000 --- a/25874-x86-EFI-chain-cfg.patch +++ /dev/null @@ -1,70 +0,0 @@ -# HG changeset patch -# User Jan Beulich -# Date 1347437974 -7200 -# Node ID 8c0aa97d529a55de2ab96be1a5a6e9ed6a9c6bf0 -# Parent ac8f4afccd6c6786a3fd5691e8b0c9b38c47e994 -x86-64/EFI: allow chaining of config files - -Namely when making use the CONFIG_XEN_COMPAT_* options in the legacy -Linux kernels, newer kernels may not be compatible with older -hypervisors, so trying to boot such a combination makes little sense. -Booting older kernels on newer hypervisors, however, has to always -work. - -With the way xen.efi looks for its configuration file, allowing -individual configuration files to refer only to compatible kernels, -and referring from an older- to a newer-hypervisor one (the kernels -of which will, as said, necessarily be compatible with the older -hypervisor) allows to greatly reduce redundancy at least in -development environments where one frequently wants multiple -hypervisors and kernles to be installed in parallel. - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser - ---- a/docs/misc/efi.markdown -+++ b/docs/misc/efi.markdown -@@ -75,6 +75,13 @@ Specifies an XSM module to load. - - Specifies a CPU microcode blob to load. - -+###`chain=` -+ -+Specifies an alternate configuration file to use in case the specified section -+(and in particular its `kernel=` setting) can't be found in the default (or -+specified) configuration file. This is only meaningful in the [global] section -+and really not meant to be used together with the `-cfg=` command line option. -+ - Filenames must be specified relative to the location of the EFI binary. - - Extra options to be passed to Xen can also be specified on the command line, ---- a/xen/arch/x86/efi/boot.c -+++ b/xen/arch/x86/efi/boot.c -@@ -797,7 +797,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY - else - section.s = get_value(&cfg, "global", "default"); - -- name.s = get_value(&cfg, section.s, "kernel"); -+ for ( ; ; ) -+ { -+ name.s = get_value(&cfg, section.s, "kernel"); -+ if ( name.s ) -+ break; -+ name.s = get_value(&cfg, "global", "chain"); -+ if ( !name.s ) -+ break; -+ efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size)); -+ cfg.addr = 0; -+ if ( !read_file(dir_handle, s2w(&name), &cfg) ) -+ { -+ PrintStr(L"Chained configuration file '"); -+ PrintStr(name.w); -+ efi_bs->FreePool(name.w); -+ blexit(L"'not found\r\n"); -+ } -+ pre_parse(&cfg); -+ efi_bs->FreePool(name.w); -+ } - if ( !name.s ) - blexit(L"No Dom0 kernel image specified\r\n"); - split_value(name.s); diff --git a/25909-xenpm-consistent.patch b/25909-xenpm-consistent.patch deleted file mode 100644 index b096a5e..0000000 --- a/25909-xenpm-consistent.patch +++ /dev/null @@ -1,630 +0,0 @@ -References: bnc#780401 - -# HG changeset patch -# User Jan Beulich -# Date 1347869399 -7200 -# Node ID 51408c3528030309e8f064bf6a3c96b37de7dc96 -# Parent 12fa949b90603f057d458e370284471412afb0ba -xenpm: make argument parsing and error handling more consistent - -Specifically, what values are or aren't accepted as CPU identifier, and -how the values get interpreted should be consistent across sub-commands -(intended behavior now: non-negative values are okay, and along with -omitting the argument, specifying "all" will also be accepted). - -For error handling, error messages should get consistently issued to -stderr, and the tool should now (hopefully) produce an exit code of -zero only in the (partial) success case (there may still be a small -number of questionable cases). - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser - ---- a/tools/misc/xenpm.c -+++ b/tools/misc/xenpm.c -@@ -36,7 +36,7 @@ - #define CPUFREQ_TURBO_ENABLED 1 - - static xc_interface *xc_handle; --static int max_cpu_nr; -+static unsigned int max_cpu_nr; - - /* help message */ - void show_help(void) -@@ -77,6 +77,33 @@ void help_func(int argc, char *argv[]) - show_help(); - } - -+static void parse_cpuid(const char *arg, int *cpuid) -+{ -+ if ( sscanf(arg, "%d", cpuid) != 1 || *cpuid < 0 ) -+ { -+ if ( strcasecmp(arg, "all") ) -+ { -+ fprintf(stderr, "Invalid CPU identifier: '%s'\n", arg); -+ exit(EINVAL); -+ } -+ *cpuid = -1; -+ } -+} -+ -+static void parse_cpuid_and_int(int argc, char *argv[], -+ int *cpuid, int *val, const char *what) -+{ -+ if ( argc > 1 ) -+ parse_cpuid(argv[0], cpuid); -+ -+ if ( argc == 0 || sscanf(argv[argc > 1], "%d", val) != 1 ) -+ { -+ fprintf(stderr, argc ? "Invalid %s '%s'\n" : "Missing %s\n", -+ what, argv[argc > 1]); -+ exit(EINVAL); -+ } -+} -+ - static void print_cxstat(int cpuid, struct xc_cx_stat *cxstat) - { - int i; -@@ -166,7 +193,8 @@ static int show_cxstat_by_cpuid(xc_inter - if ( ret ) - { - if ( ret == -ENODEV ) -- printf("Either xen cpuidle is disabled or no valid information is registered!\n"); -+ fprintf(stderr, -+ "Either Xen cpuidle is disabled or no valid information is registered!\n"); - return ret; - } - -@@ -181,11 +209,8 @@ void cxstat_func(int argc, char *argv[]) - { - int cpuid = -1; - -- if ( argc > 0 && sscanf(argv[0], "%d", &cpuid) != 1 ) -- cpuid = -1; -- -- if ( cpuid >= max_cpu_nr ) -- cpuid = -1; -+ if ( argc > 0 ) -+ parse_cpuid(argv[0], &cpuid); - - show_max_cstate(xc_handle); - -@@ -294,11 +319,8 @@ void pxstat_func(int argc, char *argv[]) - { - int cpuid = -1; - -- if ( argc > 0 && sscanf(argv[0], "%d", &cpuid) != 1 ) -- cpuid = -1; -- -- if ( cpuid >= max_cpu_nr ) -- cpuid = -1; -+ if ( argc > 0 ) -+ parse_cpuid(argv[0], &cpuid); - - if ( cpuid < 0 ) - { -@@ -338,10 +360,10 @@ static void signal_int_handler(int signo - goto out; - } - -- if ( gettimeofday(&tv, NULL) == -1 ) -+ if ( gettimeofday(&tv, NULL) ) - { - fprintf(stderr, "failed to get timeofday\n"); -- goto out ; -+ goto out; - } - usec_end = tv.tv_sec * 1000000UL + tv.tv_usec; - -@@ -541,7 +563,7 @@ void start_gather_func(int argc, char *a - printf("Timeout set to %d seconds\n", timeout); - } - -- if ( gettimeofday(&tv, NULL) == -1 ) -+ if ( gettimeofday(&tv, NULL) ) - { - fprintf(stderr, "failed to get timeofday\n"); - return ; -@@ -766,11 +788,8 @@ void cpufreq_para_func(int argc, char *a - { - int cpuid = -1; - -- if ( argc > 0 && sscanf(argv[0], "%d", &cpuid) != 1 ) -- cpuid = -1; -- -- if ( cpuid >= max_cpu_nr ) -- cpuid = -1; -+ if ( argc > 0 ) -+ parse_cpuid(argv[0], &cpuid); - - if ( cpuid < 0 ) - { -@@ -788,26 +807,22 @@ void scaling_max_freq_func(int argc, cha - { - int cpuid = -1, freq = -1; - -- if ( (argc >= 2 && (sscanf(argv[1], "%d", &freq) != 1 || -- sscanf(argv[0], "%d", &cpuid) != 1)) || -- (argc == 1 && sscanf(argv[0], "%d", &freq) != 1 ) || -- argc == 0 ) -- { -- fprintf(stderr, "failed to set scaling max freq\n"); -- return ; -- } -+ parse_cpuid_and_int(argc, argv, &cpuid, &freq, "frequency"); - - if ( cpuid < 0 ) - { - int i; - for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_para(xc_handle, i, SCALING_MAX_FREQ, freq) ) -- fprintf(stderr, "[CPU%d] failed to set scaling max freq\n", i); -+ fprintf(stderr, -+ "[CPU%d] failed to set scaling max freq (%d - %s)\n", -+ i, errno, strerror(errno)); - } - else - { - if ( xc_set_cpufreq_para(xc_handle, cpuid, SCALING_MAX_FREQ, freq) ) -- fprintf(stderr, "failed to set scaling max freq\n"); -+ fprintf(stderr, "failed to set scaling max freq (%d - %s)\n", -+ errno, strerror(errno)); - } - } - -@@ -815,26 +830,22 @@ void scaling_min_freq_func(int argc, cha - { - int cpuid = -1, freq = -1; - -- if ( (argc >= 2 && (sscanf(argv[1], "%d", &freq) != 1 || -- sscanf(argv[0], "%d", &cpuid) != 1) ) || -- (argc == 1 && sscanf(argv[0], "%d", &freq) != 1 ) || -- argc == 0 ) -- { -- fprintf(stderr, "failed to set scaling min freq\n"); -- return ; -- } -+ parse_cpuid_and_int(argc, argv, &cpuid, &freq, "frequency"); - - if ( cpuid < 0 ) - { - int i; - for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_para(xc_handle, i, SCALING_MIN_FREQ, freq) ) -- fprintf(stderr, "[CPU%d] failed to set scaling min freq\n", i); -+ fprintf(stderr, -+ "[CPU%d] failed to set scaling min freq (%d - %s)\n", -+ i, errno, strerror(errno)); - } - else - { - if ( xc_set_cpufreq_para(xc_handle, cpuid, SCALING_MIN_FREQ, freq) ) -- fprintf(stderr, "failed to set scaling min freq\n"); -+ fprintf(stderr, "failed to set scaling min freq (%d - %s)\n", -+ errno, strerror(errno)); - } - } - -@@ -842,26 +853,22 @@ void scaling_speed_func(int argc, char * - { - int cpuid = -1, speed = -1; - -- if ( (argc >= 2 && (sscanf(argv[1], "%d", &speed) != 1 || -- sscanf(argv[0], "%d", &cpuid) != 1) ) || -- (argc == 1 && sscanf(argv[0], "%d", &speed) != 1 ) || -- argc == 0 ) -- { -- fprintf(stderr, "failed to set scaling speed\n"); -- return ; -- } -+ parse_cpuid_and_int(argc, argv, &cpuid, &speed, "speed"); - - if ( cpuid < 0 ) - { - int i; - for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_para(xc_handle, i, SCALING_SETSPEED, speed) ) -- fprintf(stderr, "[CPU%d] failed to set scaling speed\n", i); -+ fprintf(stderr, -+ "[CPU%d] failed to set scaling speed (%d - %s)\n", -+ i, errno, strerror(errno)); - } - else - { - if ( xc_set_cpufreq_para(xc_handle, cpuid, SCALING_SETSPEED, speed) ) -- fprintf(stderr, "failed to set scaling speed\n"); -+ fprintf(stderr, "failed to set scaling speed (%d - %s)\n", -+ errno, strerror(errno)); - } - } - -@@ -869,14 +876,7 @@ void scaling_sampling_rate_func(int argc - { - int cpuid = -1, rate = -1; - -- if ( (argc >= 2 && (sscanf(argv[1], "%d", &rate) != 1 || -- sscanf(argv[0], "%d", &cpuid) != 1) ) || -- (argc == 1 && sscanf(argv[0], "%d", &rate) != 1 ) || -- argc == 0 ) -- { -- fprintf(stderr, "failed to set scaling sampling rate\n"); -- return ; -- } -+ parse_cpuid_and_int(argc, argv, &cpuid, &rate, "rate"); - - if ( cpuid < 0 ) - { -@@ -884,12 +884,14 @@ void scaling_sampling_rate_func(int argc - for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_para(xc_handle, i, SAMPLING_RATE, rate) ) - fprintf(stderr, -- "[CPU%d] failed to set scaling sampling rate\n", i); -+ "[CPU%d] failed to set scaling sampling rate (%d - %s)\n", -+ i, errno, strerror(errno)); - } - else - { - if ( xc_set_cpufreq_para(xc_handle, cpuid, SAMPLING_RATE, rate) ) -- fprintf(stderr, "failed to set scaling sampling rate\n"); -+ fprintf(stderr, "failed to set scaling sampling rate (%d - %s)\n", -+ errno, strerror(errno)); - } - } - -@@ -897,14 +899,7 @@ void scaling_up_threshold_func(int argc, - { - int cpuid = -1, threshold = -1; - -- if ( (argc >= 2 && (sscanf(argv[1], "%d", &threshold) != 1 || -- sscanf(argv[0], "%d", &cpuid) != 1) ) || -- (argc == 1 && sscanf(argv[0], "%d", &threshold) != 1 ) || -- argc == 0 ) -- { -- fprintf(stderr, "failed to set up scaling threshold\n"); -- return ; -- } -+ parse_cpuid_and_int(argc, argv, &cpuid, &threshold, "threshold"); - - if ( cpuid < 0 ) - { -@@ -912,57 +907,49 @@ void scaling_up_threshold_func(int argc, - for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_para(xc_handle, i, UP_THRESHOLD, threshold) ) - fprintf(stderr, -- "[CPU%d] failed to set up scaling threshold\n", i); -+ "[CPU%d] failed to set up scaling threshold (%d - %s)\n", -+ i, errno, strerror(errno)); - } - else - { - if ( xc_set_cpufreq_para(xc_handle, cpuid, UP_THRESHOLD, threshold) ) -- fprintf(stderr, "failed to set up scaling threshold\n"); -+ fprintf(stderr, "failed to set up scaling threshold (%d - %s)\n", -+ errno, strerror(errno)); - } - } - - void scaling_governor_func(int argc, char *argv[]) - { - int cpuid = -1; -- char *name = NULL; -+ char *name; - - if ( argc >= 2 ) - { -- name = strdup(argv[1]); -- if ( name == NULL ) -- goto out; -- if ( sscanf(argv[0], "%d", &cpuid) != 1 ) -- { -- free(name); -- goto out; -- } -+ parse_cpuid(argv[0], &cpuid); -+ name = argv[1]; - } - else if ( argc > 0 ) -+ name = argv[0]; -+ else - { -- name = strdup(argv[0]); -- if ( name == NULL ) -- goto out; -+ fprintf(stderr, "Missing argument(s)\n"); -+ exit(EINVAL); - } -- else -- goto out; - - if ( cpuid < 0 ) - { - int i; - for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_gov(xc_handle, i, name) ) -- fprintf(stderr, "[CPU%d] failed to set governor name\n", i); -+ fprintf(stderr, "[CPU%d] failed to set governor name (%d - %s)\n", -+ i, errno, strerror(errno)); - } - else - { - if ( xc_set_cpufreq_gov(xc_handle, cpuid, name) ) -- fprintf(stderr, "failed to set governor name\n"); -+ fprintf(stderr, "failed to set governor name (%d - %s)\n", -+ errno, strerror(errno)); - } -- -- free(name); -- return ; --out: -- fprintf(stderr, "failed to set governor name\n"); - } - - void cpu_topology_func(int argc, char *argv[]) -@@ -971,7 +958,7 @@ void cpu_topology_func(int argc, char *a - DECLARE_HYPERCALL_BUFFER(uint32_t, cpu_to_socket); - DECLARE_HYPERCALL_BUFFER(uint32_t, cpu_to_node); - xc_topologyinfo_t info = { 0 }; -- int i; -+ int i, rc = ENOMEM; - - cpu_to_core = xc_hypercall_buffer_alloc(xc_handle, cpu_to_core, sizeof(*cpu_to_core) * MAX_NR_CPU); - cpu_to_socket = xc_hypercall_buffer_alloc(xc_handle, cpu_to_socket, sizeof(*cpu_to_socket) * MAX_NR_CPU); -@@ -990,7 +977,9 @@ void cpu_topology_func(int argc, char *a - - if ( xc_topologyinfo(xc_handle, &info) ) - { -- printf("Can not get Xen CPU topology: %d\n", errno); -+ rc = errno; -+ fprintf(stderr, "Cannot get Xen CPU topology (%d - %s)\n", -+ errno, strerror(errno)); - goto out; - } - -@@ -1005,116 +994,95 @@ void cpu_topology_func(int argc, char *a - printf("CPU%d\t %d\t %d\t %d\n", - i, cpu_to_core[i], cpu_to_socket[i], cpu_to_node[i]); - } -+ rc = 0; - out: - xc_hypercall_buffer_free(xc_handle, cpu_to_core); - xc_hypercall_buffer_free(xc_handle, cpu_to_socket); - xc_hypercall_buffer_free(xc_handle, cpu_to_node); -+ if ( rc ) -+ exit(rc); - } - - void set_sched_smt_func(int argc, char *argv[]) - { -- int value, rc; -+ int value; - -- if (argc != 1){ -- show_help(); -- exit(-1); -+ if ( argc != 1 ) { -+ fprintf(stderr, "Missing or invalid argument(s)\n"); -+ exit(EINVAL); - } - -- if ( !strncmp(argv[0], "disable", sizeof("disable")) ) -- { -+ if ( !strcasecmp(argv[0], "disable") ) - value = 0; -- } -- else if ( !strncmp(argv[0], "enable", sizeof("enable")) ) -- { -+ else if ( !strcasecmp(argv[0], "enable") ) - value = 1; -- } - else - { -- show_help(); -- exit(-1); -+ fprintf(stderr, "Invalid argument: %s\n", argv[0]); -+ exit(EINVAL); - } - -- rc = xc_set_sched_opt_smt(xc_handle, value); -- printf("%s sched_smt_power_savings %s\n", argv[0], -- rc? "failed":"succeeded" ); -- -- return; -+ if ( !xc_set_sched_opt_smt(xc_handle, value) ) -+ printf("%s sched_smt_power_savings succeeded\n", argv[0]); -+ else -+ fprintf(stderr, "%s sched_smt_power_savings failed (%d - %s)\n", -+ argv[0], errno, strerror(errno)); - } - - void set_vcpu_migration_delay_func(int argc, char *argv[]) - { - int value; -- int rc; -- -- if (argc != 1){ -- show_help(); -- exit(-1); -- } -- -- value = atoi(argv[0]); - -- if (value < 0) -- { -- printf("Please try non-negative vcpu migration delay\n"); -- exit(-1); -+ if ( argc != 1 || (value = atoi(argv[0])) < 0 ) { -+ fprintf(stderr, "Missing or invalid argument(s)\n"); -+ exit(EINVAL); - } - -- rc = xc_set_vcpu_migration_delay(xc_handle, value); -- printf("%s to set vcpu migration delay to %d us\n", -- rc? "Fail":"Succeed", value ); -- -- return; -+ if ( !xc_set_vcpu_migration_delay(xc_handle, value) ) -+ printf("set vcpu migration delay to %d us succeeded\n", value); -+ else -+ fprintf(stderr, "set vcpu migration delay failed (%d - %s)\n", -+ errno, strerror(errno)); - } - - void get_vcpu_migration_delay_func(int argc, char *argv[]) - { - uint32_t value; -- int rc; - -- if (argc != 0){ -- show_help(); -- exit(-1); -- } -+ if ( argc ) -+ fprintf(stderr, "Ignoring argument(s)\n"); - -- rc = xc_get_vcpu_migration_delay(xc_handle, &value); -- if (!rc) -- { -- printf("Schduler vcpu migration delay is %d us\n", value); -- } -+ if ( !xc_get_vcpu_migration_delay(xc_handle, &value) ) -+ printf("Scheduler vcpu migration delay is %d us\n", value); - else -- { -- printf("Failed to get scheduler vcpu migration delay, errno=%d\n", errno); -- } -- -- return; -+ fprintf(stderr, -+ "Failed to get scheduler vcpu migration delay (%d - %s)\n", -+ errno, strerror(errno)); - } - - void set_max_cstate_func(int argc, char *argv[]) - { -- int value, rc; -+ int value; - - if ( argc != 1 || sscanf(argv[0], "%d", &value) != 1 || value < 0 ) - { -- show_help(); -- exit(-1); -+ fprintf(stderr, "Missing or invalid argument(s)\n"); -+ exit(EINVAL); - } - -- rc = xc_set_cpuidle_max_cstate(xc_handle, (uint32_t)value); -- printf("set max_cstate to C%d %s\n", value, -- rc? "failed":"succeeded" ); -- -- return; -+ if ( !xc_set_cpuidle_max_cstate(xc_handle, (uint32_t)value) ) -+ printf("set max_cstate to C%d succeeded\n", value); -+ else -+ fprintf(stderr, "set max_cstate to C%d failed (%d - %s)\n", -+ value, errno, strerror(errno)); - } - - void enable_turbo_mode(int argc, char *argv[]) - { - int cpuid = -1; - -- if ( argc > 0 && sscanf(argv[0], "%d", &cpuid) != 1 ) -- cpuid = -1; -- -- if ( cpuid >= max_cpu_nr ) -- cpuid = -1; -+ if ( argc > 0 ) -+ parse_cpuid(argv[0], &cpuid); - - if ( cpuid < 0 ) - { -@@ -1122,21 +1090,22 @@ void enable_turbo_mode(int argc, char *a - * only make effects on dbs governor */ - int i; - for ( i = 0; i < max_cpu_nr; i++ ) -- xc_enable_turbo(xc_handle, i); -+ if ( xc_enable_turbo(xc_handle, i) ) -+ fprintf(stderr, -+ "[CPU%d] failed to enable turbo mode (%d - %s)\n", -+ i, errno, strerror(errno)); - } -- else -- xc_enable_turbo(xc_handle, cpuid); -+ else if ( xc_enable_turbo(xc_handle, cpuid) ) -+ fprintf(stderr, "failed to enable turbo mode (%d - %s)\n", -+ errno, strerror(errno)); - } - - void disable_turbo_mode(int argc, char *argv[]) - { - int cpuid = -1; - -- if ( argc > 0 && sscanf(argv[0], "%d", &cpuid) != 1 ) -- cpuid = -1; -- -- if ( cpuid >= max_cpu_nr ) -- cpuid = -1; -+ if ( argc > 0 ) -+ parse_cpuid(argv[0], &cpuid); - - if ( cpuid < 0 ) - { -@@ -1144,10 +1113,14 @@ void disable_turbo_mode(int argc, char * - * only make effects on dbs governor */ - int i; - for ( i = 0; i < max_cpu_nr; i++ ) -- xc_disable_turbo(xc_handle, i); -+ if ( xc_disable_turbo(xc_handle, i) ) -+ fprintf(stderr, -+ "[CPU%d] failed to disable turbo mode (%d - %s)\n", -+ i, errno, strerror(errno)); - } -- else -- xc_disable_turbo(xc_handle, cpuid); -+ else if ( xc_disable_turbo(xc_handle, cpuid) ) -+ fprintf(stderr, "failed to disable turbo mode (%d - %s)\n", -+ errno, strerror(errno)); - } - - struct { -@@ -1191,15 +1164,17 @@ int main(int argc, char *argv[]) - if ( !xc_handle ) - { - fprintf(stderr, "failed to get the handler\n"); -- return 0; -+ return EIO; - } - - ret = xc_physinfo(xc_handle, &physinfo); - if ( ret ) - { -- fprintf(stderr, "failed to get the processor information\n"); -+ ret = errno; -+ fprintf(stderr, "failed to get processor information (%d - %s)\n", -+ ret, strerror(ret)); - xc_interface_close(xc_handle); -- return 0; -+ return ret; - } - max_cpu_nr = physinfo.nr_cpus; - -@@ -1214,14 +1189,18 @@ int main(int argc, char *argv[]) - for ( i = 0; i < nr_matches; i++ ) - fprintf(stderr, " %s", main_options[matches_main_options[i]].name); - fprintf(stderr, "\n"); -+ ret = EINVAL; - } - else if ( nr_matches == 1 ) - /* dispatch to the corresponding function handler */ - main_options[matches_main_options[0]].function(argc - 2, argv + 2); - else -+ { - show_help(); -+ ret = EINVAL; -+ } - - xc_interface_close(xc_handle); -- return 0; -+ return ret; - } - diff --git a/25920-x86-APICV-enable.patch b/25920-x86-APICV-enable.patch deleted file mode 100644 index 983e58e..0000000 --- a/25920-x86-APICV-enable.patch +++ /dev/null @@ -1,128 +0,0 @@ -References: FATE#313605 - -# HG changeset patch -# User Jiongxi Li -# Date 1347912248 -3600 -# Node ID ec60de627945f17ec2ce5c14e1224b59403875f7 -# Parent 62de66cec48a1716bb700912da451a26296b8d1e -xen: enable APIC-Register Virtualization - -Add APIC register virtualization support - - APIC read doesn't cause VM-Exit - - APIC write becomes trap-like - -Signed-off-by: Gang Wei -Signed-off-by: Yang Zhang -Signed-off-by: Jiongxi Li - ---- a/xen/arch/x86/hvm/vlapic.c -+++ b/xen/arch/x86/hvm/vlapic.c -@@ -822,6 +822,12 @@ static int vlapic_write(struct vcpu *v, - return rc; - } - -+int vlapic_apicv_write(struct vcpu *v, unsigned int offset) -+{ -+ uint32_t val = vlapic_get_reg(vcpu_vlapic(v), offset); -+ return vlapic_reg_write(v, offset, val); -+} -+ - int hvm_x2apic_msr_write(struct vcpu *v, unsigned int msr, uint64_t msr_content) - { - struct vlapic *vlapic = vcpu_vlapic(v); ---- a/xen/arch/x86/hvm/vmx/vmcs.c -+++ b/xen/arch/x86/hvm/vmx/vmcs.c -@@ -89,6 +89,7 @@ static void __init vmx_display_features( - P(cpu_has_vmx_vnmi, "Virtual NMI"); - P(cpu_has_vmx_msr_bitmap, "MSR direct-access bitmap"); - P(cpu_has_vmx_unrestricted_guest, "Unrestricted Guest"); -+ P(cpu_has_vmx_apic_reg_virt, "APIC Register Virtualization"); - #undef P - - if ( !printed ) -@@ -186,6 +187,14 @@ static int vmx_init_vmcs_config(void) - if ( opt_unrestricted_guest_enabled ) - opt |= SECONDARY_EXEC_UNRESTRICTED_GUEST; - -+ /* -+ * "APIC Register Virtualization" -+ * can be set only when "use TPR shadow" is set -+ */ -+ if ( _vmx_cpu_based_exec_control & CPU_BASED_TPR_SHADOW ) -+ opt |= SECONDARY_EXEC_APIC_REGISTER_VIRT; -+ -+ - _vmx_secondary_exec_control = adjust_vmx_controls( - "Secondary Exec Control", min, opt, - MSR_IA32_VMX_PROCBASED_CTLS2, &mismatch); ---- a/xen/arch/x86/hvm/vmx/vmx.c -+++ b/xen/arch/x86/hvm/vmx/vmx.c -@@ -2279,6 +2279,16 @@ static void vmx_idtv_reinject(unsigned l - } - } - -+static int vmx_handle_apic_write(void) -+{ -+ unsigned long exit_qualification = __vmread(EXIT_QUALIFICATION); -+ unsigned int offset = exit_qualification & 0xfff; -+ -+ ASSERT(cpu_has_vmx_apic_reg_virt); -+ -+ return vlapic_apicv_write(current, offset); -+} -+ - void vmx_vmexit_handler(struct cpu_user_regs *regs) - { - unsigned int exit_reason, idtv_info, intr_info = 0, vector = 0; -@@ -2741,6 +2751,11 @@ void vmx_vmexit_handler(struct cpu_user_ - break; - } - -+ case EXIT_REASON_APIC_WRITE: -+ if ( vmx_handle_apic_write() ) -+ hvm_inject_hw_exception(TRAP_gp_fault, 0); -+ break; -+ - case EXIT_REASON_ACCESS_GDTR_OR_IDTR: - case EXIT_REASON_ACCESS_LDTR_OR_TR: - case EXIT_REASON_VMX_PREEMPTION_TIMER_EXPIRED: ---- a/xen/include/asm-x86/hvm/vlapic.h -+++ b/xen/include/asm-x86/hvm/vlapic.h -@@ -103,6 +103,8 @@ void vlapic_EOI_set(struct vlapic *vlapi - - int vlapic_ipi(struct vlapic *vlapic, uint32_t icr_low, uint32_t icr_high); - -+int vlapic_apicv_write(struct vcpu *v, unsigned int offset); -+ - struct vlapic *vlapic_lowest_prio( - struct domain *d, struct vlapic *source, - int short_hand, uint8_t dest, uint8_t dest_mode); ---- a/xen/include/asm-x86/hvm/vmx/vmcs.h -+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h -@@ -182,6 +182,7 @@ extern u32 vmx_vmentry_control; - #define SECONDARY_EXEC_ENABLE_VPID 0x00000020 - #define SECONDARY_EXEC_WBINVD_EXITING 0x00000040 - #define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080 -+#define SECONDARY_EXEC_APIC_REGISTER_VIRT 0x00000100 - #define SECONDARY_EXEC_PAUSE_LOOP_EXITING 0x00000400 - #define SECONDARY_EXEC_ENABLE_INVPCID 0x00001000 - extern u32 vmx_secondary_exec_control; -@@ -230,6 +231,8 @@ extern bool_t cpu_has_vmx_ins_outs_instr - SECONDARY_EXEC_UNRESTRICTED_GUEST) - #define cpu_has_vmx_ple \ - (vmx_secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) -+#define cpu_has_vmx_apic_reg_virt \ -+ (vmx_secondary_exec_control & SECONDARY_EXEC_APIC_REGISTER_VIRT) - - /* GUEST_INTERRUPTIBILITY_INFO flags. */ - #define VMX_INTR_SHADOW_STI 0x00000001 ---- a/xen/include/asm-x86/hvm/vmx/vmx.h -+++ b/xen/include/asm-x86/hvm/vmx/vmx.h -@@ -129,6 +129,7 @@ void vmx_update_cpu_exec_control(struct - #define EXIT_REASON_INVVPID 53 - #define EXIT_REASON_WBINVD 54 - #define EXIT_REASON_XSETBV 55 -+#define EXIT_REASON_APIC_WRITE 56 - #define EXIT_REASON_INVPCID 58 - - /* diff --git a/25921-x86-APICV-delivery.patch b/25921-x86-APICV-delivery.patch deleted file mode 100644 index e6cc867..0000000 --- a/25921-x86-APICV-delivery.patch +++ /dev/null @@ -1,505 +0,0 @@ -References: FATE#313605 - -# HG changeset patch -# User Jiongxi Li -# Date 1347912311 -3600 -# Node ID 713b8849b11afa05f1dde157a3f5086fa3aaad08 -# Parent ec60de627945f17ec2ce5c14e1224b59403875f7 -xen: enable Virtual-interrupt delivery - -Virtual interrupt delivery avoids Xen to inject vAPIC interrupts -manually, which is fully taken care of by the hardware. This needs -some special awareness into existing interrupr injection path: -For pending interrupt from vLAPIC, instead of direct injection, we may -need update architecture specific indicators before resuming to guest. -Before returning to guest, RVI should be updated if any pending IRRs -EOI exit bitmap controls whether an EOI write should cause VM-Exit. If -set, a trap-like induced EOI VM-Exit is triggered. The approach here -is to manipulate EOI exit bitmap based on value of TMR. Level -triggered irq requires a hook in vLAPIC EOI write, so that vIOAPIC EOI -is triggered and emulated - -Signed-off-by: Gang Wei -Signed-off-by: Yang Zhang -Signed-off-by: Jiongxi Li -Committed-by: Keir Fraser - ---- a/xen/arch/x86/hvm/vlapic.c -+++ b/xen/arch/x86/hvm/vlapic.c -@@ -145,6 +145,9 @@ int vlapic_set_irq(struct vlapic *vlapic - if ( trig ) - vlapic_set_vector(vec, &vlapic->regs->data[APIC_TMR]); - -+ if ( hvm_funcs.update_eoi_exit_bitmap ) -+ hvm_funcs.update_eoi_exit_bitmap(vlapic_vcpu(vlapic), vec ,trig); -+ - /* We may need to wake up target vcpu, besides set pending bit here */ - return !vlapic_test_and_set_irr(vec, vlapic); - } -@@ -410,6 +413,14 @@ void vlapic_EOI_set(struct vlapic *vlapi - hvm_dpci_msi_eoi(current->domain, vector); - } - -+void vlapic_handle_EOI_induced_exit(struct vlapic *vlapic, int vector) -+{ -+ if ( vlapic_test_and_clear_vector(vector, &vlapic->regs->data[APIC_TMR]) ) -+ vioapic_update_EOI(vlapic_domain(vlapic), vector); -+ -+ hvm_dpci_msi_eoi(current->domain, vector); -+} -+ - int vlapic_ipi( - struct vlapic *vlapic, uint32_t icr_low, uint32_t icr_high) - { -@@ -996,6 +1007,14 @@ void vlapic_adjust_i8259_target(struct d - pt_adjust_global_vcpu_target(v); - } - -+int vlapic_virtual_intr_delivery_enabled(void) -+{ -+ if ( hvm_funcs.virtual_intr_delivery_enabled ) -+ return hvm_funcs.virtual_intr_delivery_enabled(); -+ else -+ return 0; -+} -+ - int vlapic_has_pending_irq(struct vcpu *v) - { - struct vlapic *vlapic = vcpu_vlapic(v); -@@ -1008,6 +1027,9 @@ int vlapic_has_pending_irq(struct vcpu * - if ( irr == -1 ) - return -1; - -+ if ( vlapic_virtual_intr_delivery_enabled() ) -+ return irr; -+ - isr = vlapic_find_highest_isr(vlapic); - isr = (isr != -1) ? isr : 0; - if ( (isr & 0xf0) >= (irr & 0xf0) ) -@@ -1020,6 +1042,9 @@ int vlapic_ack_pending_irq(struct vcpu * - { - struct vlapic *vlapic = vcpu_vlapic(v); - -+ if ( vlapic_virtual_intr_delivery_enabled() ) -+ return 1; -+ - vlapic_set_vector(vector, &vlapic->regs->data[APIC_ISR]); - vlapic_clear_irr(vector, vlapic); - ---- a/xen/arch/x86/hvm/vmx/intr.c -+++ b/xen/arch/x86/hvm/vmx/intr.c -@@ -209,6 +209,7 @@ void vmx_intr_assist(void) - struct vcpu *v = current; - unsigned int tpr_threshold = 0; - enum hvm_intblk intblk; -+ int pt_vector = -1; - - /* Block event injection when single step with MTF. */ - if ( unlikely(v->arch.hvm_vcpu.single_step) ) -@@ -219,7 +220,7 @@ void vmx_intr_assist(void) - } - - /* Crank the handle on interrupt state. */ -- pt_update_irq(v); -+ pt_vector = pt_update_irq(v); - - do { - intack = hvm_vcpu_has_pending_irq(v); -@@ -230,16 +231,34 @@ void vmx_intr_assist(void) - goto out; - - intblk = hvm_interrupt_blocked(v, intack); -- if ( intblk == hvm_intblk_tpr ) -+ if ( cpu_has_vmx_virtual_intr_delivery ) -+ { -+ /* Set "Interrupt-window exiting" for ExtINT */ -+ if ( (intblk != hvm_intblk_none) && -+ ( (intack.source == hvm_intsrc_pic) || -+ ( intack.source == hvm_intsrc_vector) ) ) -+ { -+ enable_intr_window(v, intack); -+ goto out; -+ } -+ -+ if ( __vmread(VM_ENTRY_INTR_INFO) & INTR_INFO_VALID_MASK ) -+ { -+ if ( (intack.source == hvm_intsrc_pic) || -+ (intack.source == hvm_intsrc_nmi) || -+ (intack.source == hvm_intsrc_mce) ) -+ enable_intr_window(v, intack); -+ -+ goto out; -+ } -+ } else if ( intblk == hvm_intblk_tpr ) - { - ASSERT(vlapic_enabled(vcpu_vlapic(v))); - ASSERT(intack.source == hvm_intsrc_lapic); - tpr_threshold = intack.vector >> 4; - goto out; -- } -- -- if ( (intblk != hvm_intblk_none) || -- (__vmread(VM_ENTRY_INTR_INFO) & INTR_INFO_VALID_MASK) ) -+ } else if ( (intblk != hvm_intblk_none) || -+ (__vmread(VM_ENTRY_INTR_INFO) & INTR_INFO_VALID_MASK) ) - { - enable_intr_window(v, intack); - goto out; -@@ -256,6 +275,44 @@ void vmx_intr_assist(void) - { - hvm_inject_hw_exception(TRAP_machine_check, HVM_DELIVER_NO_ERROR_CODE); - } -+ else if ( cpu_has_vmx_virtual_intr_delivery && -+ intack.source != hvm_intsrc_pic && -+ intack.source != hvm_intsrc_vector ) -+ { -+ unsigned long status = __vmread(GUEST_INTR_STATUS); -+ -+ /* -+ * Set eoi_exit_bitmap for periodic timer interrup to cause EOI-induced VM -+ * exit, then pending periodic time interrups have the chance to be injected -+ * for compensation -+ */ -+ if (pt_vector != -1) -+ vmx_set_eoi_exit_bitmap(v, pt_vector); -+ -+ /* we need update the RVI field */ -+ status &= ~(unsigned long)0x0FF; -+ status |= (unsigned long)0x0FF & -+ intack.vector; -+ __vmwrite(GUEST_INTR_STATUS, status); -+ if (v->arch.hvm_vmx.eoi_exitmap_changed) { -+#ifdef __i386__ -+#define UPDATE_EOI_EXITMAP(v, e) { \ -+ if (test_and_clear_bit(e, &v->arch.hvm_vmx.eoi_exitmap_changed)) { \ -+ __vmwrite(EOI_EXIT_BITMAP##e, v->arch.hvm_vmx.eoi_exit_bitmap[e]); \ -+ __vmwrite(EOI_EXIT_BITMAP##e##_HIGH, v->arch.hvm_vmx.eoi_exit_bitmap[e] >> 32);}} -+#else -+#define UPDATE_EOI_EXITMAP(v, e) { \ -+ if (test_and_clear_bit(e, &v->arch.hvm_vmx.eoi_exitmap_changed)) { \ -+ __vmwrite(EOI_EXIT_BITMAP##e, v->arch.hvm_vmx.eoi_exit_bitmap[e]);}} -+#endif -+ UPDATE_EOI_EXITMAP(v, 0); -+ UPDATE_EOI_EXITMAP(v, 1); -+ UPDATE_EOI_EXITMAP(v, 2); -+ UPDATE_EOI_EXITMAP(v, 3); -+ } -+ -+ pt_intr_post(v, intack); -+ } - else - { - HVMTRACE_2D(INJ_VIRQ, intack.vector, /*fake=*/ 0); -@@ -265,11 +322,16 @@ void vmx_intr_assist(void) - - /* Is there another IRQ to queue up behind this one? */ - intack = hvm_vcpu_has_pending_irq(v); -- if ( unlikely(intack.source != hvm_intsrc_none) ) -- enable_intr_window(v, intack); -+ if ( !cpu_has_vmx_virtual_intr_delivery || -+ intack.source == hvm_intsrc_pic || -+ intack.source == hvm_intsrc_vector ) -+ { -+ if ( unlikely(intack.source != hvm_intsrc_none) ) -+ enable_intr_window(v, intack); -+ } - - out: -- if ( cpu_has_vmx_tpr_shadow ) -+ if ( !cpu_has_vmx_virtual_intr_delivery && cpu_has_vmx_tpr_shadow ) - __vmwrite(TPR_THRESHOLD, tpr_threshold); - } - ---- a/xen/arch/x86/hvm/vmx/vmcs.c -+++ b/xen/arch/x86/hvm/vmx/vmcs.c -@@ -90,6 +90,7 @@ static void __init vmx_display_features( - P(cpu_has_vmx_msr_bitmap, "MSR direct-access bitmap"); - P(cpu_has_vmx_unrestricted_guest, "Unrestricted Guest"); - P(cpu_has_vmx_apic_reg_virt, "APIC Register Virtualization"); -+ P(cpu_has_vmx_virtual_intr_delivery, "Virtual Interrupt Delivery"); - #undef P - - if ( !printed ) -@@ -188,11 +189,12 @@ static int vmx_init_vmcs_config(void) - opt |= SECONDARY_EXEC_UNRESTRICTED_GUEST; - - /* -- * "APIC Register Virtualization" -+ * "APIC Register Virtualization" and "Virtual Interrupt Delivery" - * can be set only when "use TPR shadow" is set - */ - if ( _vmx_cpu_based_exec_control & CPU_BASED_TPR_SHADOW ) -- opt |= SECONDARY_EXEC_APIC_REGISTER_VIRT; -+ opt |= SECONDARY_EXEC_APIC_REGISTER_VIRT | -+ SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY; - - - _vmx_secondary_exec_control = adjust_vmx_controls( -@@ -787,6 +789,22 @@ static int construct_vmcs(struct vcpu *v - __vmwrite(IO_BITMAP_A, virt_to_maddr((char *)hvm_io_bitmap + 0)); - __vmwrite(IO_BITMAP_B, virt_to_maddr((char *)hvm_io_bitmap + PAGE_SIZE)); - -+ if ( cpu_has_vmx_virtual_intr_delivery ) -+ { -+ /* EOI-exit bitmap */ -+ v->arch.hvm_vmx.eoi_exit_bitmap[0] = (uint64_t)0; -+ __vmwrite(EOI_EXIT_BITMAP0, v->arch.hvm_vmx.eoi_exit_bitmap[0]); -+ v->arch.hvm_vmx.eoi_exit_bitmap[1] = (uint64_t)0; -+ __vmwrite(EOI_EXIT_BITMAP1, v->arch.hvm_vmx.eoi_exit_bitmap[1]); -+ v->arch.hvm_vmx.eoi_exit_bitmap[2] = (uint64_t)0; -+ __vmwrite(EOI_EXIT_BITMAP2, v->arch.hvm_vmx.eoi_exit_bitmap[2]); -+ v->arch.hvm_vmx.eoi_exit_bitmap[3] = (uint64_t)0; -+ __vmwrite(EOI_EXIT_BITMAP3, v->arch.hvm_vmx.eoi_exit_bitmap[3]); -+ -+ /* Initialise Guest Interrupt Status (RVI and SVI) to 0 */ -+ __vmwrite(GUEST_INTR_STATUS, 0); -+ } -+ - /* Host data selectors. */ - __vmwrite(HOST_SS_SELECTOR, __HYPERVISOR_DS); - __vmwrite(HOST_DS_SELECTOR, __HYPERVISOR_DS); -@@ -1028,6 +1046,30 @@ int vmx_add_host_load_msr(u32 msr) - return 0; - } - -+void vmx_set_eoi_exit_bitmap(struct vcpu *v, u8 vector) -+{ -+ int index, offset, changed; -+ -+ index = vector >> 6; -+ offset = vector & 63; -+ changed = !test_and_set_bit(offset, -+ (uint64_t *)&v->arch.hvm_vmx.eoi_exit_bitmap[index]); -+ if (changed) -+ set_bit(index, &v->arch.hvm_vmx.eoi_exitmap_changed); -+} -+ -+void vmx_clear_eoi_exit_bitmap(struct vcpu *v, u8 vector) -+{ -+ int index, offset, changed; -+ -+ index = vector >> 6; -+ offset = vector & 63; -+ changed = test_and_clear_bit(offset, -+ (uint64_t *)&v->arch.hvm_vmx.eoi_exit_bitmap[index]); -+ if (changed) -+ set_bit(index, &v->arch.hvm_vmx.eoi_exitmap_changed); -+} -+ - int vmx_create_vmcs(struct vcpu *v) - { - struct arch_vmx_struct *arch_vmx = &v->arch.hvm_vmx; ---- a/xen/arch/x86/hvm/vmx/vmx.c -+++ b/xen/arch/x86/hvm/vmx/vmx.c -@@ -1507,6 +1507,22 @@ static void vmx_set_info_guest(struct vc - vmx_vmcs_exit(v); - } - -+static void vmx_update_eoi_exit_bitmap(struct vcpu *v, u8 vector, u8 trig) -+{ -+ if ( cpu_has_vmx_virtual_intr_delivery ) -+ { -+ if (trig) -+ vmx_set_eoi_exit_bitmap(v, vector); -+ else -+ vmx_clear_eoi_exit_bitmap(v, vector); -+ } -+} -+ -+static int vmx_virtual_intr_delivery_enabled(void) -+{ -+ return cpu_has_vmx_virtual_intr_delivery; -+} -+ - static struct hvm_function_table __read_mostly vmx_function_table = { - .name = "VMX", - .cpu_up_prepare = vmx_cpu_up_prepare, -@@ -1553,7 +1569,9 @@ static struct hvm_function_table __read_ - .nhvm_vmcx_guest_intercepts_trap = nvmx_intercepts_exception, - .nhvm_vcpu_vmexit_trap = nvmx_vmexit_trap, - .nhvm_intr_blocked = nvmx_intr_blocked, -- .nhvm_domain_relinquish_resources = nvmx_domain_relinquish_resources -+ .nhvm_domain_relinquish_resources = nvmx_domain_relinquish_resources, -+ .update_eoi_exit_bitmap = vmx_update_eoi_exit_bitmap, -+ .virtual_intr_delivery_enabled = vmx_virtual_intr_delivery_enabled - }; - - struct hvm_function_table * __init start_vmx(void) -@@ -2289,6 +2307,17 @@ static int vmx_handle_apic_write(void) - return vlapic_apicv_write(current, offset); - } - -+/* -+ * When "Virtual Interrupt Delivery" is enabled, this function is used -+ * to handle EOI-induced VM exit -+ */ -+void vmx_handle_EOI_induced_exit(struct vlapic *vlapic, int vector) -+{ -+ ASSERT(cpu_has_vmx_virtual_intr_delivery); -+ -+ vlapic_handle_EOI_induced_exit(vlapic, vector); -+} -+ - void vmx_vmexit_handler(struct cpu_user_regs *regs) - { - unsigned int exit_reason, idtv_info, intr_info = 0, vector = 0; -@@ -2689,6 +2718,16 @@ void vmx_vmexit_handler(struct cpu_user_ - hvm_inject_hw_exception(TRAP_gp_fault, 0); - break; - -+ case EXIT_REASON_EOI_INDUCED: -+ { -+ int vector; -+ exit_qualification = __vmread(EXIT_QUALIFICATION); -+ vector = exit_qualification & 0xff; -+ -+ vmx_handle_EOI_induced_exit(vcpu_vlapic(current), vector); -+ break; -+ } -+ - case EXIT_REASON_IO_INSTRUCTION: - exit_qualification = __vmread(EXIT_QUALIFICATION); - if ( exit_qualification & 0x10 ) ---- a/xen/arch/x86/hvm/vpt.c -+++ b/xen/arch/x86/hvm/vpt.c -@@ -212,7 +212,7 @@ static void pt_timer_fn(void *data) - pt_unlock(pt); - } - --void pt_update_irq(struct vcpu *v) -+int pt_update_irq(struct vcpu *v) - { - struct list_head *head = &v->arch.hvm_vcpu.tm_list; - struct periodic_time *pt, *temp, *earliest_pt = NULL; -@@ -245,7 +245,7 @@ void pt_update_irq(struct vcpu *v) - if ( earliest_pt == NULL ) - { - spin_unlock(&v->arch.hvm_vcpu.tm_lock); -- return; -+ return -1; - } - - earliest_pt->irq_issued = 1; -@@ -263,6 +263,17 @@ void pt_update_irq(struct vcpu *v) - hvm_isa_irq_deassert(v->domain, irq); - hvm_isa_irq_assert(v->domain, irq); - } -+ -+ /* -+ * If periodic timer interrut is handled by lapic, its vector in -+ * IRR is returned and used to set eoi_exit_bitmap for virtual -+ * interrupt delivery case. Otherwise return -1 to do nothing. -+ */ -+ if ( vlapic_accept_pic_intr(v) && -+ (&v->domain->arch.hvm_domain)->vpic[0].int_output ) -+ return -1; -+ else -+ return pt_irq_vector(earliest_pt, hvm_intsrc_lapic); - } - - static struct periodic_time *is_pt_irq( ---- a/xen/include/asm-x86/hvm/hvm.h -+++ b/xen/include/asm-x86/hvm/hvm.h -@@ -180,6 +180,10 @@ struct hvm_function_table { - - enum hvm_intblk (*nhvm_intr_blocked)(struct vcpu *v); - void (*nhvm_domain_relinquish_resources)(struct domain *d); -+ -+ /* Virtual interrupt delivery */ -+ void (*update_eoi_exit_bitmap)(struct vcpu *v, u8 vector, u8 trig); -+ int (*virtual_intr_delivery_enabled)(void); - }; - - extern struct hvm_function_table hvm_funcs; ---- a/xen/include/asm-x86/hvm/vlapic.h -+++ b/xen/include/asm-x86/hvm/vlapic.h -@@ -100,6 +100,7 @@ int vlapic_accept_pic_intr(struct vcpu * - void vlapic_adjust_i8259_target(struct domain *d); - - void vlapic_EOI_set(struct vlapic *vlapic); -+void vlapic_handle_EOI_induced_exit(struct vlapic *vlapic, int vector); - - int vlapic_ipi(struct vlapic *vlapic, uint32_t icr_low, uint32_t icr_high); - ---- a/xen/include/asm-x86/hvm/vmx/vmcs.h -+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h -@@ -110,6 +110,9 @@ struct arch_vmx_struct { - unsigned int host_msr_count; - struct vmx_msr_entry *host_msr_area; - -+ uint32_t eoi_exitmap_changed; -+ uint64_t eoi_exit_bitmap[4]; -+ - unsigned long host_cr0; - - /* Is the guest in real mode? */ -@@ -183,6 +186,7 @@ extern u32 vmx_vmentry_control; - #define SECONDARY_EXEC_WBINVD_EXITING 0x00000040 - #define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080 - #define SECONDARY_EXEC_APIC_REGISTER_VIRT 0x00000100 -+#define SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY 0x00000200 - #define SECONDARY_EXEC_PAUSE_LOOP_EXITING 0x00000400 - #define SECONDARY_EXEC_ENABLE_INVPCID 0x00001000 - extern u32 vmx_secondary_exec_control; -@@ -233,6 +237,8 @@ extern bool_t cpu_has_vmx_ins_outs_instr - (vmx_secondary_exec_control & SECONDARY_EXEC_PAUSE_LOOP_EXITING) - #define cpu_has_vmx_apic_reg_virt \ - (vmx_secondary_exec_control & SECONDARY_EXEC_APIC_REGISTER_VIRT) -+#define cpu_has_vmx_virtual_intr_delivery \ -+ (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY) - - /* GUEST_INTERRUPTIBILITY_INFO flags. */ - #define VMX_INTR_SHADOW_STI 0x00000001 -@@ -251,6 +257,7 @@ enum vmcs_field { - GUEST_GS_SELECTOR = 0x0000080a, - GUEST_LDTR_SELECTOR = 0x0000080c, - GUEST_TR_SELECTOR = 0x0000080e, -+ GUEST_INTR_STATUS = 0x00000810, - HOST_ES_SELECTOR = 0x00000c00, - HOST_CS_SELECTOR = 0x00000c02, - HOST_SS_SELECTOR = 0x00000c04, -@@ -278,6 +285,14 @@ enum vmcs_field { - APIC_ACCESS_ADDR_HIGH = 0x00002015, - EPT_POINTER = 0x0000201a, - EPT_POINTER_HIGH = 0x0000201b, -+ EOI_EXIT_BITMAP0 = 0x0000201c, -+ EOI_EXIT_BITMAP0_HIGH = 0x0000201d, -+ EOI_EXIT_BITMAP1 = 0x0000201e, -+ EOI_EXIT_BITMAP1_HIGH = 0x0000201f, -+ EOI_EXIT_BITMAP2 = 0x00002020, -+ EOI_EXIT_BITMAP2_HIGH = 0x00002021, -+ EOI_EXIT_BITMAP3 = 0x00002022, -+ EOI_EXIT_BITMAP3_HIGH = 0x00002023, - GUEST_PHYSICAL_ADDRESS = 0x00002400, - GUEST_PHYSICAL_ADDRESS_HIGH = 0x00002401, - VMCS_LINK_POINTER = 0x00002800, -@@ -398,6 +413,8 @@ int vmx_write_guest_msr(u32 msr, u64 val - int vmx_add_guest_msr(u32 msr); - int vmx_add_host_load_msr(u32 msr); - void vmx_vmcs_switch(struct vmcs_struct *from, struct vmcs_struct *to); -+void vmx_set_eoi_exit_bitmap(struct vcpu *v, u8 vector); -+void vmx_clear_eoi_exit_bitmap(struct vcpu *v, u8 vector); - - #endif /* ASM_X86_HVM_VMX_VMCS_H__ */ - ---- a/xen/include/asm-x86/hvm/vmx/vmx.h -+++ b/xen/include/asm-x86/hvm/vmx/vmx.h -@@ -119,6 +119,7 @@ void vmx_update_cpu_exec_control(struct - #define EXIT_REASON_MCE_DURING_VMENTRY 41 - #define EXIT_REASON_TPR_BELOW_THRESHOLD 43 - #define EXIT_REASON_APIC_ACCESS 44 -+#define EXIT_REASON_EOI_INDUCED 45 - #define EXIT_REASON_ACCESS_GDTR_OR_IDTR 46 - #define EXIT_REASON_ACCESS_LDTR_OR_TR 47 - #define EXIT_REASON_EPT_VIOLATION 48 ---- a/xen/include/asm-x86/hvm/vpt.h -+++ b/xen/include/asm-x86/hvm/vpt.h -@@ -141,7 +141,7 @@ struct pl_time { /* platform time */ - - void pt_save_timer(struct vcpu *v); - void pt_restore_timer(struct vcpu *v); --void pt_update_irq(struct vcpu *v); -+int pt_update_irq(struct vcpu *v); - void pt_intr_post(struct vcpu *v, struct hvm_intack intack); - void pt_migrate(struct vcpu *v); - diff --git a/25922-x86-APICV-x2APIC.patch b/25922-x86-APICV-x2APIC.patch deleted file mode 100644 index 7c0bad8..0000000 --- a/25922-x86-APICV-x2APIC.patch +++ /dev/null @@ -1,128 +0,0 @@ -References: FATE#313605 - -# HG changeset patch -# User Jiongxi Li -# Date 1347912362 -3600 -# Node ID c2578dd96b8318e108fff0f340411135dedaa47d -# Parent 713b8849b11afa05f1dde157a3f5086fa3aaad08 -xen: add virtual x2apic support for apicv - -basically to benefit from apicv, we need clear MSR bitmap for -corresponding x2apic MSRs: - 0x800 - 0x8ff: no read intercept for apicv register virtualization - TPR,EOI,SELF-IPI: no write intercept for virtual interrupt - delivery - -Signed-off-by: Jiongxi Li -Committed-by: Keir Fraser - -Index: xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vmcs.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/hvm/vmx/vmcs.c -+++ xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vmcs.c -@@ -658,7 +658,7 @@ static void vmx_set_host_env(struct vcpu - (unsigned long)&get_cpu_info()->guest_cpu_user_regs.error_code); - } - --void vmx_disable_intercept_for_msr(struct vcpu *v, u32 msr) -+void vmx_disable_intercept_for_msr(struct vcpu *v, u32 msr, int type) - { - unsigned long *msr_bitmap = v->arch.hvm_vmx.msr_bitmap; - -@@ -673,14 +673,18 @@ void vmx_disable_intercept_for_msr(struc - */ - if ( msr <= 0x1fff ) - { -- __clear_bit(msr, msr_bitmap + 0x000/BYTES_PER_LONG); /* read-low */ -- __clear_bit(msr, msr_bitmap + 0x800/BYTES_PER_LONG); /* write-low */ -+ if (type & MSR_TYPE_R) -+ __clear_bit(msr, msr_bitmap + 0x000/BYTES_PER_LONG); /* read-low */ -+ if (type & MSR_TYPE_W) -+ __clear_bit(msr, msr_bitmap + 0x800/BYTES_PER_LONG); /* write-low */ - } - else if ( (msr >= 0xc0000000) && (msr <= 0xc0001fff) ) - { - msr &= 0x1fff; -- __clear_bit(msr, msr_bitmap + 0x400/BYTES_PER_LONG); /* read-high */ -- __clear_bit(msr, msr_bitmap + 0xc00/BYTES_PER_LONG); /* write-high */ -+ if (type & MSR_TYPE_R) -+ __clear_bit(msr, msr_bitmap + 0x400/BYTES_PER_LONG); /* read-high */ -+ if (type & MSR_TYPE_W) -+ __clear_bit(msr, msr_bitmap + 0xc00/BYTES_PER_LONG); /* write-high */ - } - } - -@@ -776,13 +780,25 @@ static int construct_vmcs(struct vcpu *v - v->arch.hvm_vmx.msr_bitmap = msr_bitmap; - __vmwrite(MSR_BITMAP, virt_to_maddr(msr_bitmap)); - -- vmx_disable_intercept_for_msr(v, MSR_FS_BASE); -- vmx_disable_intercept_for_msr(v, MSR_GS_BASE); -- vmx_disable_intercept_for_msr(v, MSR_IA32_SYSENTER_CS); -- vmx_disable_intercept_for_msr(v, MSR_IA32_SYSENTER_ESP); -- vmx_disable_intercept_for_msr(v, MSR_IA32_SYSENTER_EIP); -+ vmx_disable_intercept_for_msr(v, MSR_FS_BASE, MSR_TYPE_R | MSR_TYPE_W); -+ vmx_disable_intercept_for_msr(v, MSR_GS_BASE, MSR_TYPE_R | MSR_TYPE_W); -+ vmx_disable_intercept_for_msr(v, MSR_IA32_SYSENTER_CS, MSR_TYPE_R | MSR_TYPE_W); -+ vmx_disable_intercept_for_msr(v, MSR_IA32_SYSENTER_ESP, MSR_TYPE_R | MSR_TYPE_W); -+ vmx_disable_intercept_for_msr(v, MSR_IA32_SYSENTER_EIP, MSR_TYPE_R | MSR_TYPE_W); - if ( cpu_has_vmx_pat && paging_mode_hap(d) ) -- vmx_disable_intercept_for_msr(v, MSR_IA32_CR_PAT); -+ vmx_disable_intercept_for_msr(v, MSR_IA32_CR_PAT, MSR_TYPE_R | MSR_TYPE_W); -+ if ( cpu_has_vmx_apic_reg_virt ) -+ { -+ int msr; -+ for (msr = MSR_IA32_APICBASE_MSR; msr <= MSR_IA32_APICBASE_MSR + 0xff; msr++) -+ vmx_disable_intercept_for_msr(v, msr, MSR_TYPE_R); -+ } -+ if ( cpu_has_vmx_virtual_intr_delivery ) -+ { -+ vmx_disable_intercept_for_msr(v, MSR_IA32_APICTPR_MSR, MSR_TYPE_W); -+ vmx_disable_intercept_for_msr(v, MSR_IA32_APICEOI_MSR, MSR_TYPE_W); -+ vmx_disable_intercept_for_msr(v, MSR_IA32_APICSELF_MSR, MSR_TYPE_W); -+ } - } - - /* I/O access bitmap. */ -Index: xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vmx.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/hvm/vmx/vmx.c -+++ xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vmx.c -@@ -2041,7 +2041,7 @@ static int vmx_msr_write_intercept(unsig - for ( ; (rc == 0) && lbr->count; lbr++ ) - for ( i = 0; (rc == 0) && (i < lbr->count); i++ ) - if ( (rc = vmx_add_guest_msr(lbr->base + i)) == 0 ) -- vmx_disable_intercept_for_msr(v, lbr->base + i); -+ vmx_disable_intercept_for_msr(v, lbr->base + i, MSR_TYPE_R | MSR_TYPE_W); - } - - if ( (rc < 0) || -Index: xen-4.2.2-testing/xen/include/asm-x86/hvm/vmx/vmcs.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/hvm/vmx/vmcs.h -+++ xen-4.2.2-testing/xen/include/asm-x86/hvm/vmx/vmcs.h -@@ -407,7 +407,9 @@ enum vmcs_field { - - #define VMCS_VPID_WIDTH 16 - --void vmx_disable_intercept_for_msr(struct vcpu *v, u32 msr); -+#define MSR_TYPE_R 1 -+#define MSR_TYPE_W 2 -+void vmx_disable_intercept_for_msr(struct vcpu *v, u32 msr, int type); - int vmx_read_guest_msr(u32 msr, u64 *val); - int vmx_write_guest_msr(u32 msr, u64 val); - int vmx_add_guest_msr(u32 msr); -Index: xen-4.2.2-testing/xen/include/asm-x86/msr-index.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/msr-index.h -+++ xen-4.2.2-testing/xen/include/asm-x86/msr-index.h -@@ -293,6 +293,9 @@ - #define MSR_IA32_APICBASE_ENABLE (1<<11) - #define MSR_IA32_APICBASE_BASE (0xfffff<<12) - #define MSR_IA32_APICBASE_MSR 0x800 -+#define MSR_IA32_APICTPR_MSR 0x808 -+#define MSR_IA32_APICEOI_MSR 0x80b -+#define MSR_IA32_APICSELF_MSR 0x83f - - #define MSR_IA32_UCODE_WRITE 0x00000079 - #define MSR_IA32_UCODE_REV 0x0000008b diff --git a/25952-x86-MMIO-remap-permissions.patch b/25952-x86-MMIO-remap-permissions.patch deleted file mode 100644 index 1fee502..0000000 --- a/25952-x86-MMIO-remap-permissions.patch +++ /dev/null @@ -1,43 +0,0 @@ -# HG changeset patch -# User Daniel De Graaf -# Date 1348653367 -7200 -# Node ID 8278d7d8fa485996f51134c5265fceaf239adf6a -# Parent b83f414ccf7a6e4e077a10bc422cf3f6c7d30566 -x86: check remote MMIO remap permissions - -When a domain is mapping pages from a different pg_owner domain, the -iomem_access checks are currently only applied to the pg_owner domain, -potentially allowing a domain with a more restrictive iomem_access -policy to have the pages mapped into its page tables. To catch this, -also check the owner of the page tables. The current domain does not -need to be checked because the ability to manipulate a domain's page -tables implies full access to the target domain, so checking that -domain's permission is sufficient. - -Signed-off-by: Daniel De Graaf -Committed-by: Jan Beulich - -Index: xen-4.2.2-testing/xen/arch/x86/mm.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/mm.c -+++ xen-4.2.2-testing/xen/arch/x86/mm.c -@@ -884,6 +884,19 @@ get_page_from_l1e( - return -EINVAL; - } - -+ if ( pg_owner != l1e_owner && -+ !iomem_access_permitted(l1e_owner, mfn, mfn) ) -+ { -+ if ( mfn != (PADDR_MASK >> PAGE_SHIFT) ) /* INVALID_MFN? */ -+ { -+ MEM_LOG("Dom%u attempted to map I/O space %08lx in dom%u to dom%u", -+ curr->domain->domain_id, mfn, pg_owner->domain_id, -+ l1e_owner->domain_id); -+ return -EPERM; -+ } -+ return -EINVAL; -+ } -+ - if ( !(l1f & _PAGE_RW) || - !rangeset_contains_singleton(mmio_ro_ranges, mfn) ) - return 0; diff --git a/25957-x86-TSC-adjust-HVM.patch b/25957-x86-TSC-adjust-HVM.patch deleted file mode 100644 index 861e2ad..0000000 --- a/25957-x86-TSC-adjust-HVM.patch +++ /dev/null @@ -1,129 +0,0 @@ -References: FATE#313633 - -# HG changeset patch -# User Liu, Jinsong -# Date 1348654362 -7200 -# Node ID c47ef9592fb39325e33f8406b4bd736cc84482e5 -# Parent 5d63c633a60b9a1d695594f9c17cf933240bec81 -x86: Implement TSC adjust feature for HVM guest - -IA32_TSC_ADJUST MSR is maintained separately for each logical -processor. A logical processor maintains and uses the IA32_TSC_ADJUST -MSR as follows: -1). On RESET, the value of the IA32_TSC_ADJUST MSR is 0; -2). If an execution of WRMSR to the IA32_TIME_STAMP_COUNTER MSR adds - (or subtracts) value X from the TSC, the logical processor also - adds (or subtracts) value X from the IA32_TSC_ADJUST MSR; -3). If an execution of WRMSR to the IA32_TSC_ADJUST MSR adds (or - subtracts) value X from that MSR, the logical processor also adds - (or subtracts) value X from the TSC. - -This patch provides tsc adjust support for hvm guest, with it guest OS -would be happy when sync tsc. - -Signed-off-by: Liu, Jinsong -Committed-by: Jan Beulich - -Index: xen-4.2.2-testing/xen/arch/x86/hvm/hvm.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/hvm/hvm.c -+++ xen-4.2.2-testing/xen/arch/x86/hvm/hvm.c -@@ -244,6 +244,7 @@ int hvm_set_guest_pat(struct vcpu *v, u6 - void hvm_set_guest_tsc(struct vcpu *v, u64 guest_tsc) - { - uint64_t tsc; -+ uint64_t delta_tsc; - - if ( v->domain->arch.vtsc ) - { -@@ -255,10 +256,22 @@ void hvm_set_guest_tsc(struct vcpu *v, u - rdtscll(tsc); - } - -- v->arch.hvm_vcpu.cache_tsc_offset = guest_tsc - tsc; -+ delta_tsc = guest_tsc - tsc; -+ v->arch.hvm_vcpu.msr_tsc_adjust += delta_tsc -+ - v->arch.hvm_vcpu.cache_tsc_offset; -+ v->arch.hvm_vcpu.cache_tsc_offset = delta_tsc; -+ - hvm_funcs.set_tsc_offset(v, v->arch.hvm_vcpu.cache_tsc_offset); - } - -+void hvm_set_guest_tsc_adjust(struct vcpu *v, u64 tsc_adjust) -+{ -+ v->arch.hvm_vcpu.cache_tsc_offset += tsc_adjust -+ - v->arch.hvm_vcpu.msr_tsc_adjust; -+ hvm_funcs.set_tsc_offset(v, v->arch.hvm_vcpu.cache_tsc_offset); -+ v->arch.hvm_vcpu.msr_tsc_adjust = tsc_adjust; -+} -+ - u64 hvm_get_guest_tsc(struct vcpu *v) - { - uint64_t tsc; -@@ -277,6 +290,11 @@ u64 hvm_get_guest_tsc(struct vcpu *v) - return tsc + v->arch.hvm_vcpu.cache_tsc_offset; - } - -+u64 hvm_get_guest_tsc_adjust(struct vcpu *v) -+{ -+ return v->arch.hvm_vcpu.msr_tsc_adjust; -+} -+ - void hvm_migrate_timers(struct vcpu *v) - { - rtc_migrate_timers(v); -@@ -2798,6 +2816,10 @@ int hvm_msr_read_intercept(unsigned int - *msr_content = hvm_get_guest_tsc(v); - break; - -+ case MSR_IA32_TSC_ADJUST: -+ *msr_content = hvm_get_guest_tsc_adjust(v); -+ break; -+ - case MSR_TSC_AUX: - *msr_content = hvm_msr_tsc_aux(v); - break; -@@ -2911,6 +2933,10 @@ int hvm_msr_write_intercept(unsigned int - hvm_set_guest_tsc(v, msr_content); - break; - -+ case MSR_IA32_TSC_ADJUST: -+ hvm_set_guest_tsc_adjust(v, msr_content); -+ break; -+ - case MSR_TSC_AUX: - v->arch.hvm_vcpu.msr_tsc_aux = (uint32_t)msr_content; - if ( cpu_has_rdtscp -@@ -3482,6 +3508,8 @@ void hvm_vcpu_reset_state(struct vcpu *v - v->domain->vcpu[0]->arch.hvm_vcpu.cache_tsc_offset; - hvm_funcs.set_tsc_offset(v, v->arch.hvm_vcpu.cache_tsc_offset); - -+ v->arch.hvm_vcpu.msr_tsc_adjust = 0; -+ - paging_update_paging_modes(v); - - v->arch.flags |= TF_kernel_mode; -Index: xen-4.2.2-testing/xen/include/asm-x86/hvm/vcpu.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/hvm/vcpu.h -+++ xen-4.2.2-testing/xen/include/asm-x86/hvm/vcpu.h -@@ -137,6 +137,7 @@ struct hvm_vcpu { - struct hvm_vcpu_asid n1asid; - - u32 msr_tsc_aux; -+ u64 msr_tsc_adjust; - - /* VPMU */ - struct vpmu_struct vpmu; -Index: xen-4.2.2-testing/xen/include/asm-x86/msr-index.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/msr-index.h -+++ xen-4.2.2-testing/xen/include/asm-x86/msr-index.h -@@ -286,6 +286,7 @@ - #define MSR_IA32_PLATFORM_ID 0x00000017 - #define MSR_IA32_EBL_CR_POWERON 0x0000002a - #define MSR_IA32_EBC_FREQUENCY_ID 0x0000002c -+#define MSR_IA32_TSC_ADJUST 0x0000003b - - #define MSR_IA32_APICBASE 0x0000001b - #define MSR_IA32_APICBASE_BSP (1<<8) diff --git a/25958-x86-TSC-adjust-sr.patch b/25958-x86-TSC-adjust-sr.patch deleted file mode 100644 index 92bca2d..0000000 --- a/25958-x86-TSC-adjust-sr.patch +++ /dev/null @@ -1,104 +0,0 @@ -References: FATE#313633 - -# HG changeset patch -# User Liu, Jinsong -# Date 1348654418 -7200 -# Node ID 56fb977ce6eb4626a02d4a7a34e85009bb8ee3e0 -# Parent c47ef9592fb39325e33f8406b4bd736cc84482e5 -x86: Save/restore TSC adjust during HVM guest migration - -Signed-off-by: Liu, Jinsong -Committed-by: Jan Beulich - ---- a/tools/misc/xen-hvmctx.c -+++ b/tools/misc/xen-hvmctx.c -@@ -390,6 +390,13 @@ static void dump_vmce_vcpu(void) - printf(" VMCE_VCPU: caps %" PRIx64 "\n", p.caps); - } - -+static void dump_tsc_adjust(void) -+{ -+ HVM_SAVE_TYPE(TSC_ADJUST) p; -+ READ(p); -+ printf(" TSC_ADJUST: tsc_adjust %" PRIx64 "\n", p.tsc_adjust); -+} -+ - int main(int argc, char **argv) - { - int entry, domid; -@@ -457,6 +464,7 @@ int main(int argc, char **argv) - case HVM_SAVE_CODE(VIRIDIAN_DOMAIN): dump_viridian_domain(); break; - case HVM_SAVE_CODE(VIRIDIAN_VCPU): dump_viridian_vcpu(); break; - case HVM_SAVE_CODE(VMCE_VCPU): dump_vmce_vcpu(); break; -+ case HVM_SAVE_CODE(TSC_ADJUST): dump_tsc_adjust(); break; - case HVM_SAVE_CODE(END): break; - default: - printf(" ** Don't understand type %u: skipping\n", ---- a/xen/arch/x86/hvm/hvm.c -+++ b/xen/arch/x86/hvm/hvm.c -@@ -610,6 +610,46 @@ void hvm_domain_destroy(struct domain *d - hvm_destroy_cacheattr_region_list(d); - } - -+static int hvm_save_tsc_adjust(struct domain *d, hvm_domain_context_t *h) -+{ -+ struct vcpu *v; -+ struct hvm_tsc_adjust ctxt; -+ int err = 0; -+ -+ for_each_vcpu ( d, v ) -+ { -+ ctxt.tsc_adjust = v->arch.hvm_vcpu.msr_tsc_adjust; -+ err = hvm_save_entry(TSC_ADJUST, v->vcpu_id, h, &ctxt); -+ if ( err ) -+ break; -+ } -+ -+ return err; -+} -+ -+static int hvm_load_tsc_adjust(struct domain *d, hvm_domain_context_t *h) -+{ -+ unsigned int vcpuid = hvm_load_instance(h); -+ struct vcpu *v; -+ struct hvm_tsc_adjust ctxt; -+ -+ if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL ) -+ { -+ dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n", -+ d->domain_id, vcpuid); -+ return -EINVAL; -+ } -+ -+ if ( hvm_load_entry(TSC_ADJUST, h, &ctxt) != 0 ) -+ return -EINVAL; -+ -+ v->arch.hvm_vcpu.msr_tsc_adjust = ctxt.tsc_adjust; -+ return 0; -+} -+ -+HVM_REGISTER_SAVE_RESTORE(TSC_ADJUST, hvm_save_tsc_adjust, -+ hvm_load_tsc_adjust, 1, HVMSR_PER_VCPU); -+ - static int hvm_save_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) - { - struct vcpu *v; ---- a/xen/include/public/arch-x86/hvm/save.h -+++ b/xen/include/public/arch-x86/hvm/save.h -@@ -581,9 +581,15 @@ struct hvm_vmce_vcpu { - - DECLARE_HVM_SAVE_TYPE(VMCE_VCPU, 18, struct hvm_vmce_vcpu); - -+struct hvm_tsc_adjust { -+ uint64_t tsc_adjust; -+}; -+ -+DECLARE_HVM_SAVE_TYPE(TSC_ADJUST, 19, struct hvm_tsc_adjust); -+ - /* - * Largest type-code in use - */ --#define HVM_SAVE_CODE_MAX 18 -+#define HVM_SAVE_CODE_MAX 19 - - #endif /* __XEN_PUBLIC_HVM_SAVE_X86_H__ */ diff --git a/25959-x86-TSC-adjust-expose.patch b/25959-x86-TSC-adjust-expose.patch deleted file mode 100644 index fc0173a..0000000 --- a/25959-x86-TSC-adjust-expose.patch +++ /dev/null @@ -1,39 +0,0 @@ -References: FATE#313633 - -# HG changeset patch -# User Liu, Jinsong -# Date 1348654470 -7200 -# Node ID 3aa66543a51ba77cb73e8c874e2416d065426a22 -# Parent 56fb977ce6eb4626a02d4a7a34e85009bb8ee3e0 -x86: Expose TSC adjust to HVM guest - -Intel latest SDM (17.13.3) release a new MSR CPUID.7.0.EBX[1]=1 -indicates TSC_ADJUST MSR 0x3b is supported. - -This patch expose it to hvm guest. - -Signed-off-by: Liu, Jinsong -Committed-by: Jan Beulich - ---- a/tools/libxc/xc_cpufeature.h -+++ b/tools/libxc/xc_cpufeature.h -@@ -128,6 +128,7 @@ - - /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx) */ - #define X86_FEATURE_FSGSBASE 0 /* {RD,WR}{FS,GS}BASE instructions */ -+#define X86_FEATURE_TSC_ADJUST 1 /* Tsc thread offset */ - #define X86_FEATURE_BMI1 3 /* 1st group bit manipulation extensions */ - #define X86_FEATURE_HLE 4 /* Hardware Lock Elision */ - #define X86_FEATURE_AVX2 5 /* AVX2 instructions */ ---- a/tools/libxc/xc_cpuid_x86.c -+++ b/tools/libxc/xc_cpuid_x86.c -@@ -362,7 +362,8 @@ static void xc_cpuid_hvm_policy( - - case 0x00000007: /* Intel-defined CPU features */ - if ( input[1] == 0 ) { -- regs[1] &= (bitmaskof(X86_FEATURE_BMI1) | -+ regs[1] &= (bitmaskof(X86_FEATURE_TSC_ADJUST) | -+ bitmaskof(X86_FEATURE_BMI1) | - bitmaskof(X86_FEATURE_HLE) | - bitmaskof(X86_FEATURE_AVX2) | - bitmaskof(X86_FEATURE_SMEP) | diff --git a/25975-x86-IvyBridge.patch b/25975-x86-IvyBridge.patch deleted file mode 100644 index 9521b76..0000000 --- a/25975-x86-IvyBridge.patch +++ /dev/null @@ -1,61 +0,0 @@ -# HG changeset patch -# User Jan Beulich -# Date 1349172840 -7200 -# Node ID 87bf99fad7a9f018530d13213f57610621838085 -# Parent 5fbdbf585f5f2ee9a3e3c75a8a9f9f2cc6eda65c -x86/Intel: add further support for Ivy Bridge CPU models - -And some initial Haswell ones at once. - -Signed-off-by: Jan Beulich -Acked-by: "Nakajima, Jun" - -Index: xen-4.2.2-testing/xen/arch/x86/acpi/cpu_idle.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/acpi/cpu_idle.c -+++ xen-4.2.2-testing/xen/arch/x86/acpi/cpu_idle.c -@@ -105,11 +105,15 @@ static void do_get_hw_residencies(void * - - switch ( c->x86_model ) - { -- /* Ivy bridge */ -- case 0x3A: - /* Sandy bridge */ - case 0x2A: - case 0x2D: -+ /* Ivy bridge */ -+ case 0x3A: -+ case 0x3E: -+ /* Haswell */ -+ case 0x3C: -+ case 0x45: - GET_PC2_RES(hw_res->pc2); - GET_CC7_RES(hw_res->cc7); - /* fall through */ -Index: xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vmx.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/hvm/vmx/vmx.c -+++ xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vmx.c -@@ -1825,7 +1825,9 @@ static const struct lbr_info *last_branc - /* Sandy Bridge */ - case 42: case 45: - /* Ivy Bridge */ -- case 58: -+ case 58: case 62: -+ /* Haswell */ -+ case 60: case 69: - return nh_lbr; - break; - /* Atom */ -Index: xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vpmu_core2.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/hvm/vmx/vpmu_core2.c -+++ xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vpmu_core2.c -@@ -747,6 +747,7 @@ int vmx_vpmu_initialise(struct vcpu *v, - case 46: - case 47: - case 58: -+ case 62: - ret = core2_vpmu_initialise(v, vpmu_flags); - if ( !ret ) - vpmu->arch_vpmu_ops = &core2_vpmu_ops; diff --git a/26077-stubdom_fix_compile_errors_in_grub.patch b/26077-stubdom_fix_compile_errors_in_grub.patch deleted file mode 100644 index 44fa2d4..0000000 --- a/26077-stubdom_fix_compile_errors_in_grub.patch +++ /dev/null @@ -1,76 +0,0 @@ -changeset: 26077:33348baecf37 -user: Olaf Hering -date: Thu Oct 18 09:34:59 2012 +0100 -files: stubdom/grub.patches/70compiler_warnings.diff -description: -stubdom: fix compile errors in grub - -Building xen.rpm in SLES11 started to fail due to these compiler -warnings: - -[ 1436s] ../grub-upstream/netboot/fsys_tftp.c:213: warning: operation on 'block' may be undefined -[ 1437s] ../grub-upstream/netboot/main.c:444: warning: operation on 'block' may be undefined - -[ 1234s] E: xen sequence-point ../grub-upstream/netboot/fsys_tftp.c:213 -[ 1234s] E: xen sequence-point ../grub-upstream/netboot/main.c:444 - -The reason for this is that the assignment is done twice: - tp.u.ack.block = ((uint16_t)( (((uint16_t)((block = prevblock)) & (uint16_t)0x00ffU) << 8) | (((uint16_t)((block = prevblock)) & (uint16_t)0xff00U) >> 8))); - -Fix this package build error by adding another patch for grub, which -moves the assignment out of the macro usage. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r 8dcab28b8081 -r 33348baecf37 stubdom/grub.patches/70compiler_warnings.diff ---- /dev/null Thu Jan 01 00:00:00 1970 +0000 -+++ b/stubdom/grub.patches/70compiler_warnings.diff Thu Oct 18 09:34:59 2012 +0100 -@@ -0,0 +1,45 @@ -+[ 1436s] ../grub-upstream/netboot/fsys_tftp.c:213: warning: operation on 'block' may be undefined -+[ 1437s] ../grub-upstream/netboot/main.c:444: warning: operation on 'block' may be undefined -+ -+[ 1234s] E: xen sequence-point ../grub-upstream/netboot/fsys_tftp.c:213 -+[ 1234s] E: xen sequence-point ../grub-upstream/netboot/main.c:444 -+ -+--- -+ netboot/fsys_tftp.c | 5 ++++- -+ netboot/main.c | 5 ++++- -+ 2 files changed, 8 insertions(+), 2 deletions(-) -+ -+Index: grub-0.97/netboot/fsys_tftp.c -+=================================================================== -+--- grub-0.97.orig/netboot/fsys_tftp.c -++++ grub-0.97/netboot/fsys_tftp.c -+@@ -209,8 +209,11 @@ buf_fill (int abort) -+ break; -+ -+ if ((block || bcounter) && (block != prevblock + (unsigned short) 1)) -++ { -++ block = prevblock; -+ /* Block order should be continuous */ -+- tp.u.ack.block = htons (block = prevblock); -++ tp.u.ack.block = htons (block); -++ } -+ -+ /* Should be continuous. */ -+ tp.opcode = abort ? htons (TFTP_ERROR) : htons (TFTP_ACK); -+Index: grub-0.97/netboot/main.c -+=================================================================== -+--- grub-0.97.orig/netboot/main.c -++++ grub-0.97/netboot/main.c -+@@ -440,8 +440,11 @@ tftp (const char *name, int (*fnc) (unsi -+ break; -+ -+ if ((block || bcounter) && (block != prevblock + 1)) -++ { -++ block = prevblock; -+ /* Block order should be continuous */ -+- tp.u.ack.block = htons (block = prevblock); -++ tp.u.ack.block = htons (block); -++ } -+ -+ /* Should be continuous. */ -+ tp.opcode = htons (TFTP_ACK); diff --git a/26078-hotplug-Linux_remove_hotplug_support_rely_on_udev_instead.patch b/26078-hotplug-Linux_remove_hotplug_support_rely_on_udev_instead.patch deleted file mode 100644 index e28461f..0000000 --- a/26078-hotplug-Linux_remove_hotplug_support_rely_on_udev_instead.patch +++ /dev/null @@ -1,187 +0,0 @@ -changeset: 26078:019ca95dfa34 -user: Olaf Hering -date: Thu Oct 18 09:35:00 2012 +0100 -files: Makefile README install.sh tools/hotplug/Linux/Makefile tools/hotplug/Linux/xen-backend.agent -description: -hotplug/Linux: remove hotplug support, rely on udev instead - -Hotplug has been replaced by udev since several years. Remove the -hotplug related files and install udev unconditionally. - -This makes it possible to remove udev from rpm BuildRequires which -reduces the buildtime dependency chain. For openSuSE:Factory it was -done just now: -http://lists.opensuse.org/opensuse-buildservice/2012-10/msg00085.html - -The patch by itself will have no practical impact unless someone -attempts to build and run a Xen dom0 on a really old base system. e.g. -circa SLES9/2007 or earlier - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r 33348baecf37 -r 019ca95dfa34 Makefile ---- a/Makefile Thu Oct 18 09:34:59 2012 +0100 -+++ b/Makefile Thu Oct 18 09:35:00 2012 +0100 -@@ -223,7 +223,6 @@ uninstall: - $(MAKE) -C xen uninstall - rm -rf $(D)$(CONFIG_DIR)/init.d/xendomains $(D)$(CONFIG_DIR)/init.d/xend - rm -rf $(D)$(CONFIG_DIR)/init.d/xencommons $(D)$(CONFIG_DIR)/init.d/xen-watchdog -- rm -rf $(D)$(CONFIG_DIR)/hotplug/xen-backend.agent - rm -f $(D)$(CONFIG_DIR)/udev/rules.d/xen-backend.rules - rm -f $(D)$(CONFIG_DIR)/udev/rules.d/xend.rules - rm -f $(D)$(SYSCONFIG_DIR)/xendomains -diff -r 33348baecf37 -r 019ca95dfa34 README ---- a/README Thu Oct 18 09:34:59 2012 +0100 -+++ b/README Thu Oct 18 09:35:00 2012 +0100 -@@ -54,7 +54,7 @@ provided by your OS distributor: - * pkg-config - * bridge-utils package (/sbin/brctl) - * iproute package (/sbin/ip) -- * hotplug or udev -+ * udev - * GNU bison and GNU flex - * GNU gettext - * 16-bit x86 assembler, loader and compiler (dev86 rpm or bin86 & bcc debs) -@@ -120,9 +120,9 @@ 4. To rebuild an existing tree without m - - make install and make dist differ in that make install does the - right things for your local machine (installing the appropriate -- version of hotplug or udev scripts, for example), but make dist -- includes all versions of those scripts, so that you can copy the dist -- directory to another machine and install from that distribution. -+ version of udev scripts, for example), but make dist includes all -+ versions of those scripts, so that you can copy the dist directory -+ to another machine and install from that distribution. - - Python Runtime Libraries - ======================== -diff -r 33348baecf37 -r 019ca95dfa34 install.sh ---- a/install.sh Thu Oct 18 09:34:59 2012 +0100 -+++ b/install.sh Thu Oct 18 09:35:00 2012 +0100 -@@ -27,20 +27,6 @@ echo "Installing Xen from '$src' to '$ds - echo "Installing Xen from '$src' to '$dst'..." - (cd $src; tar -cf - * ) | tar -C "$tmp" -xf - - --[ -x "$(which udevinfo)" ] && \ -- UDEV_VERSION=$(udevinfo -V | sed -e 's/^[^0-9]* \([0-9]\{1,\}\)[^0-9]\{0,\}/\1/') -- --[ -z "$UDEV_VERSION" -a -x /sbin/udevadm ] && \ -- UDEV_VERSION=$(/sbin/udevadm info -V | awk '{print $NF}') -- --if [ -n "$UDEV_VERSION" ] && [ $UDEV_VERSION -ge 059 ]; then -- echo " - installing for udev-based system" -- rm -rf "$tmp/etc/hotplug" --else -- echo " - installing for hotplug-based system" -- rm -rf "$tmp/etc/udev" --fi -- - echo " - modifying permissions" - chmod -R a+rX "$tmp" - -diff -r 33348baecf37 -r 019ca95dfa34 tools/hotplug/Linux/Makefile ---- a/tools/hotplug/Linux/Makefile Thu Oct 18 09:34:59 2012 +0100 -+++ b/tools/hotplug/Linux/Makefile Thu Oct 18 09:35:00 2012 +0100 -@@ -27,31 +27,8 @@ XEN_SCRIPT_DATA += block-common.sh vtpm- - XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh - XEN_SCRIPT_DATA += vtpm-migration.sh vtpm-impl - --XEN_HOTPLUG_DIR = $(CONFIG_DIR)/hotplug --XEN_HOTPLUG_SCRIPTS = xen-backend.agent -- --UDEVVER = 0 --ifeq ($(shell [ -x /sbin/udevadm ] && echo 1),1) --UDEVVER = $(shell /sbin/udevadm info -V | sed -e 's/^[^0-9]* \([0-9]\{1,\}\)[^0-9]\{0,\}/\1/' ) --endif --ifeq ($(shell [ -x /usr/bin/udevinfo ] && echo 1),1) --UDEVVER = $(shell /usr/bin/udevinfo -V | sed -e 's/^[^0-9]* \([0-9]\{1,\}\)[^0-9]\{0,\}/\1/' ) --endif -- - UDEV_RULES_DIR = $(CONFIG_DIR)/udev - UDEV_RULES = xen-backend.rules xend.rules -- --DI = $(if $(DISTDIR),$(shell readlink -f $(DISTDIR)),) --DE = $(if $(DESTDIR),$(shell readlink -f $(DESTDIR)),) --ifeq ($(findstring $(DI),$(DE)),$(DI)) --HOTPLUGS=install-hotplug install-udev --else --ifeq ($(shell [ $(UDEVVER) -ge 059 ] && echo 1),1) --HOTPLUGS=install-udev --else --HOTPLUGS=install-hotplug --endif --endif - - .PHONY: all - all: -@@ -60,7 +37,7 @@ build: - build: - - .PHONY: install --install: all install-initd install-scripts $(HOTPLUGS) -+install: all install-initd install-scripts install-udev - - # See docs/misc/distro_mapping.txt for INITD_DIR location - .PHONY: install-initd -@@ -87,15 +64,6 @@ install-scripts: - $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \ - done - --.PHONY: install-hotplug --install-hotplug: -- [ -d $(DESTDIR)$(XEN_HOTPLUG_DIR) ] || \ -- $(INSTALL_DIR) $(DESTDIR)$(XEN_HOTPLUG_DIR) -- set -e; for i in $(XEN_HOTPLUG_SCRIPTS); \ -- do \ -- $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_HOTPLUG_DIR); \ -- done -- - .PHONY: install-udev - install-udev: - [ -d $(DESTDIR)$(UDEV_RULES_DIR) ] || \ -diff -r 33348baecf37 -r 019ca95dfa34 tools/hotplug/Linux/xen-backend.agent ---- a/tools/hotplug/Linux/xen-backend.agent Thu Oct 18 09:34:59 2012 +0100 -+++ /dev/null Thu Jan 01 00:00:00 1970 +0000 -@@ -1,39 +0,0 @@ --#! /bin/bash -- --PATH=/etc/xen/scripts:$PATH -- --. /etc/xen/scripts/locking.sh -- --claim_lock xenbus_hotplug_global -- --case "$XENBUS_TYPE" in -- tap) -- /etc/xen/scripts/blktap "$ACTION" -- ;; -- vbd) -- /etc/xen/scripts/block "$ACTION" -- ;; -- vtpm) -- /etc/xen/scripts/vtpm "$ACTION" -- ;; -- vif) -- [ -n "$script" ] && $script "$ACTION" -- ;; -- vscsi) -- /etc/xen/scripts/vscsi "$ACTION" -- ;; --esac -- --case "$ACTION" in -- add) -- ;; -- remove) -- /etc/xen/scripts/xen-hotplug-cleanup -- ;; -- online) -- ;; -- offline) -- ;; --esac -- --release_lock xenbus_hotplug_global diff --git a/26079-hotplug-Linux_close_lockfd_after_lock_attempt.patch b/26079-hotplug-Linux_close_lockfd_after_lock_attempt.patch deleted file mode 100644 index ac44364..0000000 --- a/26079-hotplug-Linux_close_lockfd_after_lock_attempt.patch +++ /dev/null @@ -1,36 +0,0 @@ -changeset: 26079:b3b03536789a -user: Olaf Hering -date: Thu Oct 18 09:35:01 2012 +0100 -files: tools/hotplug/Linux/locking.sh -description: -hotplug/Linux: close lockfd after lock attempt - -When a HVM guest is shutdown some of the 'remove' events can not claim -the lock for some reason. Instead they try to grab the lock in a busy -loop, until udev reaps the xen-hotplug-cleanup helper. -After analyzing the resulting logfile its not obvious what the cause is. -The only explanation is that bash (?) gets confused if the same lockfd -is opened again and again. Closing it in each iteration seem to fix the -issue. - -This was observed with sles11sp2 (bash 3.2) and 4.2 xend. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -[ ijc -- added the comment ] -Committed-by: Ian Campbell - - -diff -r 019ca95dfa34 -r b3b03536789a tools/hotplug/Linux/locking.sh ---- a/tools/hotplug/Linux/locking.sh Thu Oct 18 09:35:00 2012 +0100 -+++ b/tools/hotplug/Linux/locking.sh Thu Oct 18 09:35:01 2012 +0100 -@@ -59,6 +59,9 @@ claim_lock() - print "y\n" if $fd_inum eq $file_inum; - ' "$_lockfile" ) - if [ x$rightfile = xy ]; then break; fi -+ # Some versions of bash appear to be buggy if the same -+ # $_lockfile is opened repeatedly. Close the current fd here. -+ eval "exec $_lockfd<&-" - done - } - diff --git a/26081-stubdom_fix_rpmlint_warning_spurious-executable-perm.patch b/26081-stubdom_fix_rpmlint_warning_spurious-executable-perm.patch deleted file mode 100644 index c0d428b..0000000 --- a/26081-stubdom_fix_rpmlint_warning_spurious-executable-perm.patch +++ /dev/null @@ -1,30 +0,0 @@ -changeset: 26081:02064298ebcb -user: Olaf Hering -date: Thu Oct 18 09:35:03 2012 +0100 -files: stubdom/Makefile -description: -stubdom: fix rpmlint warning spurious-executable-perm - -[ 1758s] xen-tools.x86_64: E: spurious-executable-perm (Badness: 50) /usr/lib/xen/boot/xenstore-stubdom.gz -[ 1758s] The file is installed with executable permissions, but was identified as one -[ 1758s] that probably should not be executable. Verify if the executable bits are -[ 1758s] desired, and remove if not. NOTE: example scripts should be packaged under -[ 1758s] %docdir/examples, which will avoid this warning. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r 25b2f53d2583 -r 02064298ebcb stubdom/Makefile ---- a/stubdom/Makefile Thu Oct 18 09:35:02 2012 +0100 -+++ b/stubdom/Makefile Thu Oct 18 09:35:03 2012 +0100 -@@ -396,7 +396,7 @@ install-grub: pv-grub - - install-xenstore: xenstore-stubdom - $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot" -- $(INSTALL_PROG) mini-os-$(XEN_TARGET_ARCH)-xenstore/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/xenstore-stubdom.gz" -+ $(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-xenstore/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/xenstore-stubdom.gz" - - ####### - # clean diff --git a/26082-blktap2-libvhd_fix_rpmlint_warning_spurious-executable-perm.patch b/26082-blktap2-libvhd_fix_rpmlint_warning_spurious-executable-perm.patch deleted file mode 100644 index 1def328..0000000 --- a/26082-blktap2-libvhd_fix_rpmlint_warning_spurious-executable-perm.patch +++ /dev/null @@ -1,30 +0,0 @@ -changeset: 26082:8cf26ace9ca0 -user: Olaf Hering -date: Thu Oct 18 09:35:03 2012 +0100 -files: tools/blktap2/vhd/lib/Makefile -description: -blktap2/libvhd: fix rpmlint warning spurious-executable-perm - -[ 1758s] xen-devel.x86_64: E: spurious-executable-perm (Badness: 50) /usr/lib64/libvhd.a -[ 1758s] The file is installed with executable permissions, but was identified as one -[ 1758s] that probably should not be executable. Verify if the executable bits are -[ 1758s] desired, and remove if not. NOTE: example scripts should be packaged under -[ 1758s] %docdir/examples, which will avoid this warning. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r 02064298ebcb -r 8cf26ace9ca0 tools/blktap2/vhd/lib/Makefile ---- a/tools/blktap2/vhd/lib/Makefile Thu Oct 18 09:35:03 2012 +0100 -+++ b/tools/blktap2/vhd/lib/Makefile Thu Oct 18 09:35:03 2012 +0100 -@@ -68,7 +68,7 @@ libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR - - install: all - $(INSTALL_DIR) -p $(DESTDIR)$(INST-DIR) -- $(INSTALL_PROG) libvhd.a $(DESTDIR)$(INST-DIR) -+ $(INSTALL_DATA) libvhd.a $(DESTDIR)$(INST-DIR) - $(INSTALL_PROG) libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(DESTDIR)$(INST-DIR) - ln -sf libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(DESTDIR)$(INST-DIR)/libvhd.so.$(LIBVHD-MAJOR) - ln -sf libvhd.so.$(LIBVHD-MAJOR) $(DESTDIR)$(INST-DIR)/libvhd.so diff --git a/26083-blktap_fix_rpmlint_warning_spurious-executable-perm.patch b/26083-blktap_fix_rpmlint_warning_spurious-executable-perm.patch deleted file mode 100644 index 563b5bd..0000000 --- a/26083-blktap_fix_rpmlint_warning_spurious-executable-perm.patch +++ /dev/null @@ -1,51 +0,0 @@ -changeset: 26083:3fbeb019d522 -user: Olaf Hering -date: Thu Oct 18 09:35:04 2012 +0100 -files: tools/blktap/lib/Makefile -description: -blktap: fix rpmlint warning spurious-executable-perm - -[ 1758s] xen-devel.x86_64: E: spurious-executable-perm (Badness: 50) /usr/lib64/libblktap.a -[ 1758s] The file is installed with executable permissions, but was identified as one -[ 1758s] that probably should not be executable. Verify if the executable bits are -[ 1758s] desired, and remove if not. NOTE: example scripts should be packaged under -[ 1758s] %docdir/examples, which will avoid this warning. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r 8cf26ace9ca0 -r 3fbeb019d522 tools/blktap/lib/Makefile ---- a/tools/blktap/lib/Makefile Thu Oct 18 09:35:03 2012 +0100 -+++ b/tools/blktap/lib/Makefile Thu Oct 18 09:35:04 2012 +0100 -@@ -23,23 +23,25 @@ OBJS_PIC = $(SRCS:.c=.opic) - OBJS_PIC = $(SRCS:.c=.opic) - IBINS := - --LIB = libblktap.a libblktap.so.$(MAJOR).$(MINOR) -+LIB = libblktap.a -+LIB_SO = libblktap.so.$(MAJOR).$(MINOR) - - .PHONY: all --all: $(LIB) -+all: $(LIB) $(LIB_SO) - - .PHONY: install - install: all - $(INSTALL_DIR) $(DESTDIR)$(LIBDIR) - $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR) -- $(INSTALL_PROG) $(LIB) $(DESTDIR)$(LIBDIR) -+ $(INSTALL_PROG) $(LIB_SO) $(DESTDIR)$(LIBDIR) -+ $(INSTALL_DATA) $(LIB) $(DESTDIR)$(LIBDIR) - ln -sf libblktap.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libblktap.so.$(MAJOR) - ln -sf libblktap.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libblktap.so - $(INSTALL_DATA) blktaplib.h $(DESTDIR)$(INCLUDEDIR) - - .PHONY: clean - clean: -- rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen TAGS -+ rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) $(LIB_SO) *~ $(DEPS) xen TAGS - - libblktap.so.$(MAJOR).$(MINOR): $(OBJS_PIC) - $(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,$(SONAME) $(SHLIB_LDFLAGS) \ diff --git a/26084-hotplug_install_hotplugpath.sh_as_data_file.patch b/26084-hotplug_install_hotplugpath.sh_as_data_file.patch deleted file mode 100644 index 65d8b9c..0000000 --- a/26084-hotplug_install_hotplugpath.sh_as_data_file.patch +++ /dev/null @@ -1,34 +0,0 @@ -changeset: 26084:fe9a0eb9aaaa -user: Olaf Hering -date: Thu Oct 18 09:35:05 2012 +0100 -files: tools/hotplug/common/Makefile -description: -hotplug: install hotplugpath.sh as data file - -rpmlint complains a script helper which is only sourced: - -[ 1875s] xen-tools.i586: W: script-without-shebang /etc/xen/scripts/hotplugpath.sh -[ 1875s] This text file has executable bits set or is located in a path dedicated for -[ 1875s] executables, but lacks a shebang and cannot thus be executed. If the file is -[ 1875s] meant to be an executable script, add the shebang, otherwise remove the -[ 1875s] executable bits or move the file elsewhere. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r 3fbeb019d522 -r fe9a0eb9aaaa tools/hotplug/common/Makefile ---- a/tools/hotplug/common/Makefile Thu Oct 18 09:35:04 2012 +0100 -+++ b/tools/hotplug/common/Makefile Thu Oct 18 09:35:05 2012 +0100 -@@ -6,8 +6,8 @@ HOTPLUGPATH="hotplugpath.sh" - # OS-independent hotplug scripts go in this directory - - # Xen scripts to go there. --XEN_SCRIPTS = $(HOTPLUGPATH) --XEN_SCRIPT_DATA = -+XEN_SCRIPTS = -+XEN_SCRIPT_DATA = $(HOTPLUGPATH) - - genpath-target = $(call buildmakevars2file,$(HOTPLUGPATH)) - $(eval $(genpath-target)) diff --git a/26085-stubdom_install_stubdompath.sh_as_data_file.patch b/26085-stubdom_install_stubdompath.sh_as_data_file.patch deleted file mode 100644 index 7a3a0c0..0000000 --- a/26085-stubdom_install_stubdompath.sh_as_data_file.patch +++ /dev/null @@ -1,33 +0,0 @@ -changeset: 26085:e32f4301f384 -user: Olaf Hering -date: Thu Oct 18 09:35:06 2012 +0100 -files: stubdom/Makefile -description: -stubdom: install stubdompath.sh as data file - -rpmlint complains a script helper which is only sourced: - -[ 1875s] xen-tools.i586: W: script-without-shebang /usr/lib/xen/bin/stubdompath.sh -[ 1875s] This text file has executable bits set or is located in a path dedicated for -[ 1875s] executables, but lacks a shebang and cannot thus be executed. If the file is -[ 1875s] meant to be an executable script, add the shebang, otherwise remove the -[ 1875s] executable bits or move the file elsewhere. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r fe9a0eb9aaaa -r e32f4301f384 stubdom/Makefile ---- a/stubdom/Makefile Thu Oct 18 09:35:05 2012 +0100 -+++ b/stubdom/Makefile Thu Oct 18 09:35:06 2012 +0100 -@@ -386,7 +386,8 @@ install-readme: - - install-ioemu: ioemu-stubdom - $(INSTALL_DIR) "$(DESTDIR)$(LIBEXEC)" -- $(INSTALL_PROG) stubdompath.sh stubdom-dm "$(DESTDIR)$(LIBEXEC)" -+ $(INSTALL_PROG) stubdom-dm "$(DESTDIR)$(LIBEXEC)" -+ $(INSTALL_DATA) stubdompath.sh "$(DESTDIR)$(LIBEXEC)" - $(INSTALL_DIR) "$(DESTDIR)$(XENFIRMWAREDIR)" - $(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-ioemu/mini-os.gz "$(DESTDIR)$(XENFIRMWAREDIR)/ioemu-stubdom.gz" - diff --git a/26086-hotplug-Linux_correct_sysconfig_tag_in_xendomains.patch b/26086-hotplug-Linux_correct_sysconfig_tag_in_xendomains.patch deleted file mode 100644 index 9257374..0000000 --- a/26086-hotplug-Linux_correct_sysconfig_tag_in_xendomains.patch +++ /dev/null @@ -1,21 +0,0 @@ -changeset: 26086:ba6b1db89ec8 -user: Olaf Hering -date: Thu Oct 18 09:35:07 2012 +0100 -files: tools/hotplug/Linux/init.d/sysconfig.xendomains -description: -hotplug/Linux: correct sysconfig tag in xendomains - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r e32f4301f384 -r ba6b1db89ec8 tools/hotplug/Linux/init.d/sysconfig.xendomains ---- a/tools/hotplug/Linux/init.d/sysconfig.xendomains Thu Oct 18 09:35:06 2012 +0100 -+++ b/tools/hotplug/Linux/init.d/sysconfig.xendomains Thu Oct 18 09:35:07 2012 +0100 -@@ -1,4 +1,4 @@ --## Path: System/xen -+## Path: System/Virtualization - ## Description: xen domain start/stop on boot - ## Type: string - ## Default: diff --git a/26087-hotplug-Linux_install_sysconfig_files_as_data_files.patch b/26087-hotplug-Linux_install_sysconfig_files_as_data_files.patch deleted file mode 100644 index 3aa0626..0000000 --- a/26087-hotplug-Linux_install_sysconfig_files_as_data_files.patch +++ /dev/null @@ -1,36 +0,0 @@ -changeset: 26087:6239ace16749 -user: Olaf Hering -date: Thu Oct 18 09:35:07 2012 +0100 -files: tools/hotplug/Linux/Makefile -description: -hotplug/Linux: install sysconfig files as data files - -rpmlint complains about wrong permissions of config files: - -[ 455s] xen-tools.i586: W: script-without-shebang /var/adm/fillup-templates/sysconfig.xendomains -[ 455s] xen-tools.i586: W: script-without-shebang /var/adm/fillup-templates/sysconfig.xencommons -[ 455s] This text file has executable bits set or is located in a path dedicated for -[ 455s] executables, but lacks a shebang and cannot thus be executed. If the file is -[ 455s] meant to be an executable script, add the shebang, otherwise remove the -[ 455s] executable bits or move the file elsewhere. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r ba6b1db89ec8 -r 6239ace16749 tools/hotplug/Linux/Makefile ---- a/tools/hotplug/Linux/Makefile Thu Oct 18 09:35:07 2012 +0100 -+++ b/tools/hotplug/Linux/Makefile Thu Oct 18 09:35:07 2012 +0100 -@@ -46,9 +46,9 @@ install-initd: - [ -d $(DESTDIR)$(SYSCONFIG_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(SYSCONFIG_DIR) - $(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)$(INITD_DIR) - $(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)$(INITD_DIR) -- $(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xendomains -+ $(INSTALL_DATA) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xendomains - $(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(INITD_DIR) -- $(INSTALL_PROG) $(XENCOMMONS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xencommons -+ $(INSTALL_DATA) $(XENCOMMONS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xencommons - $(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR) - - .PHONY: install-scripts diff --git a/26114-pygrub-list-entries.patch b/26114-pygrub-list-entries.patch deleted file mode 100644 index 3f1444d..0000000 --- a/26114-pygrub-list-entries.patch +++ /dev/null @@ -1,90 +0,0 @@ -# HG changeset patch -# User Charles Arnold -# Date 1351249508 -3600 -# Node ID 6f9e46917eb8771914041b98f714e8f485fca5ef -# Parent 03af0abd2b72dfab3f2e50dd502108de8603f741 -pygrub: Add option to list grub entries - -The argument to "--entry" allows 2 syntaxes, either directly the entry -number in menu.lst, or the whole string behind the "title" key word. -This poses the following issue: - -From Dom0 there is no way to guess the number and, or the complete -title string because this string contains the kernel version, which -will change with a kernel update. - -This patch adds [-l|--list-entries] as an argument to pygrub. - -Signed-off-by: Charles Arnold -Acked-by: Ian Jackson -Committed-by: Ian Jackson - -diff -r 03af0abd2b72 -r 6f9e46917eb8 tools/pygrub/src/pygrub ---- a/tools/pygrub/src/pygrub Fri Oct 26 12:03:12 2012 +0100 -+++ b/tools/pygrub/src/pygrub Fri Oct 26 12:05:08 2012 +0100 -@@ -595,7 +595,17 @@ def run_grub(file, entry, fs, cfg_args): - sel = g.run() - - g = Grub(file, fs) -- if interactive: -+ -+ if list_entries: -+ for i in range(len(g.cf.images)): -+ img = g.cf.images[i] -+ print "title: %s" % img.title -+ print " root: %s" % img.root -+ print " kernel: %s" % img.kernel[1] -+ print " args: %s" % img.args -+ print " initrd: %s" % img.initrd[1] -+ -+ if interactive and not list_entries: - curses.wrapper(run_main) - else: - sel = g.cf.default -@@ -702,7 +712,7 @@ if __name__ == "__main__": - sel = None - - def usage(): -- print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] [-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] [--output-directory=] [--output-format=sxp|simple|simple0] " %(sys.argv[0],) -+ print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] [-l|--list-entries] [-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] [--output-directory=] [--output-format=sxp|simple|simple0] " %(sys.argv[0],) - - def copy_from_image(fs, file_to_read, file_type, output_directory, - not_really): -@@ -736,8 +746,8 @@ if __name__ == "__main__": - dataoff += len(data) - - try: -- opts, args = getopt.gnu_getopt(sys.argv[1:], 'qinh::', -- ["quiet", "interactive", "not-really", "help", -+ opts, args = getopt.gnu_getopt(sys.argv[1:], 'qilnh::', -+ ["quiet", "interactive", "list-entries", "not-really", "help", - "output=", "output-format=", "output-directory=", - "entry=", "kernel=", - "ramdisk=", "args=", "isconfig", "debug"]) -@@ -753,6 +763,7 @@ if __name__ == "__main__": - output = None - entry = None - interactive = True -+ list_entries = False - isconfig = False - debug = False - not_really = False -@@ -771,6 +782,8 @@ if __name__ == "__main__": - interactive = False - elif o in ("-i", "--interactive"): - interactive = True -+ elif o in ("-l", "--list-entries"): -+ list_entries = True - elif o in ("-n", "--not-really"): - not_really = True - elif o in ("-h", "--help"): -@@ -855,6 +868,9 @@ if __name__ == "__main__": - fs = None - continue - -+ if list_entries: -+ sys.exit(0) -+ - # Did looping through partitions find us a kernel? - if not fs: - raise RuntimeError, "Unable to find partition containing kernel" diff --git a/26129-ACPI-BGRT-invalidate.patch b/26129-ACPI-BGRT-invalidate.patch deleted file mode 100644 index 1303c3a..0000000 --- a/26129-ACPI-BGRT-invalidate.patch +++ /dev/null @@ -1,643 +0,0 @@ -# HG changeset patch -# User Jan Beulich -# Date 1352368421 -3600 -# Node ID 92163b114076029842d0f2d1dbfaa445976c71a3 -# Parent aa2074529eb0183257b6f5f29821b0cd6dfd991a -x86/ACPI: invalidate BGRT if necessary - -Since the image pointed to may live in boot services memory (which we -add to the global memory pool long before ACPI tables get looked at), -we should prevent Dom0 from trying to retrieve the image data in that -case. - -The alternatives would be to -- not add boot services memory to the global pool at all, or -- defer adding boot services memory until Dom0 indicates it is safe to - do so, or -- find and parse the BGRT table in xen/arch/x86/efi/boot.c, and avoid - adding that specific region to the E820 table. -None of these are really attractive, and as Xen commonly prints to the -video console anyway (without trying to avoid any regions on the -screen), the invalidation would need to be done conditionally anyway. - -(xen/include/acpi/actbl3.h is a verbatim copy from Linux 3.7-rc4) - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser - ---- a/xen/arch/x86/acpi/boot.c -+++ b/xen/arch/x86/acpi/boot.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -285,6 +286,27 @@ static int __init acpi_parse_hpet(struct - #define acpi_parse_hpet NULL - #endif - -+static int __init acpi_invalidate_bgrt(struct acpi_table_header *table) -+{ -+ struct acpi_table_bgrt *bgrt_tbl = -+ container_of(table, struct acpi_table_bgrt, header); -+ -+ if (table->length < sizeof(*bgrt_tbl)) -+ return -1; -+ -+ if (bgrt_tbl->version == 1 && bgrt_tbl->image_address -+ && !page_is_ram_type(PFN_DOWN(bgrt_tbl->image_address), -+ RAM_TYPE_CONVENTIONAL)) -+ return 0; -+ -+ printk(KERN_INFO PREFIX "BGRT: invalidating v%d image at %#"PRIx64"\n", -+ bgrt_tbl->version, bgrt_tbl->image_address); -+ bgrt_tbl->image_address = 0; -+ bgrt_tbl->status &= ~1; -+ -+ return 0; -+} -+ - #ifdef CONFIG_ACPI_SLEEP - #define acpi_fadt_copy_address(dst, src, len) do { \ - if (fadt->header.revision >= FADT2_REVISION_ID) \ -@@ -833,5 +855,7 @@ int __init acpi_boot_init(void) - - erst_init(); - -+ acpi_table_parse(ACPI_SIG_BGRT, acpi_invalidate_bgrt); -+ - return 0; - } ---- a/xen/include/acpi/actbl.h -+++ b/xen/include/acpi/actbl.h -@@ -314,6 +314,7 @@ enum acpi_prefered_pm_profiles { - - #include - #include -+#include - - /* - * Sizes of the various flavors of FADT. We need to look closely ---- /dev/null -+++ b/xen/include/acpi/actbl3.h -@@ -0,0 +1,557 @@ -+/****************************************************************************** -+ * -+ * Name: actbl3.h - ACPI Table Definitions -+ * -+ *****************************************************************************/ -+ -+/* -+ * Copyright (C) 2000 - 2012, Intel Corp. -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions, and the following disclaimer, -+ * without modification. -+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer -+ * substantially similar to the "NO WARRANTY" disclaimer below -+ * ("Disclaimer") and any redistribution must be conditioned upon -+ * including a substantially similar Disclaimer requirement for further -+ * binary redistribution. -+ * 3. Neither the names of the above-listed copyright holders nor the names -+ * of any contributors may be used to endorse or promote products derived -+ * from this software without specific prior written permission. -+ * -+ * Alternatively, this software may be distributed under the terms of the -+ * GNU General Public License ("GPL") version 2 as published by the Free -+ * Software Foundation. -+ * -+ * NO WARRANTY -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR -+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -+ * POSSIBILITY OF SUCH DAMAGES. -+ */ -+ -+#ifndef __ACTBL3_H__ -+#define __ACTBL3_H__ -+ -+/******************************************************************************* -+ * -+ * Additional ACPI Tables (3) -+ * -+ * These tables are not consumed directly by the ACPICA subsystem, but are -+ * included here to support device drivers and the AML disassembler. -+ * -+ * The tables in this file are fully defined within the ACPI specification. -+ * -+ ******************************************************************************/ -+ -+/* -+ * Values for description table header signatures for tables defined in this -+ * file. Useful because they make it more difficult to inadvertently type in -+ * the wrong signature. -+ */ -+#define ACPI_SIG_BGRT "BGRT" /* Boot Graphics Resource Table */ -+#define ACPI_SIG_DRTM "DRTM" /* Dynamic Root of Trust for Measurement table */ -+#define ACPI_SIG_FPDT "FPDT" /* Firmware Performance Data Table */ -+#define ACPI_SIG_GTDT "GTDT" /* Generic Timer Description Table */ -+#define ACPI_SIG_MPST "MPST" /* Memory Power State Table */ -+#define ACPI_SIG_PCCT "PCCT" /* Platform Communications Channel Table */ -+#define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */ -+#define ACPI_SIG_RASF "RASF" /* RAS Feature table */ -+ -+#define ACPI_SIG_S3PT "S3PT" /* S3 Performance (sub)Table */ -+#define ACPI_SIG_PCCS "PCC" /* PCC Shared Memory Region */ -+ -+/* Reserved table signatures */ -+ -+#define ACPI_SIG_CSRT "CSRT" /* Core System Resources Table */ -+#define ACPI_SIG_MATR "MATR" /* Memory Address Translation Table */ -+#define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */ -+#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */ -+ -+/* -+ * All tables must be byte-packed to match the ACPI specification, since -+ * the tables are provided by the system BIOS. -+ */ -+#pragma pack(1) -+ -+/* -+ * Note: C bitfields are not used for this reason: -+ * -+ * "Bitfields are great and easy to read, but unfortunately the C language -+ * does not specify the layout of bitfields in memory, which means they are -+ * essentially useless for dealing with packed data in on-disk formats or -+ * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me, -+ * this decision was a design error in C. Ritchie could have picked an order -+ * and stuck with it." Norman Ramsey. -+ * See http://stackoverflow.com/a/1053662/41661 -+ */ -+ -+/******************************************************************************* -+ * -+ * BGRT - Boot Graphics Resource Table (ACPI 5.0) -+ * Version 1 -+ * -+ ******************************************************************************/ -+ -+struct acpi_table_bgrt { -+ struct acpi_table_header header; /* Common ACPI table header */ -+ u16 version; -+ u8 status; -+ u8 image_type; -+ u64 image_address; -+ u32 image_offset_x; -+ u32 image_offset_y; -+}; -+ -+/******************************************************************************* -+ * -+ * DRTM - Dynamic Root of Trust for Measurement table -+ * -+ ******************************************************************************/ -+ -+struct acpi_table_drtm { -+ struct acpi_table_header header; /* Common ACPI table header */ -+ u64 entry_base_address; -+ u64 entry_length; -+ u32 entry_address32; -+ u64 entry_address64; -+ u64 exit_address; -+ u64 log_area_address; -+ u32 log_area_length; -+ u64 arch_dependent_address; -+ u32 flags; -+}; -+ -+/* 1) Validated Tables List */ -+ -+struct acpi_drtm_vtl_list { -+ u32 validated_table_list_count; -+}; -+ -+/* 2) Resources List */ -+ -+struct acpi_drtm_resource_list { -+ u32 resource_list_count; -+}; -+ -+/* 3) Platform-specific Identifiers List */ -+ -+struct acpi_drtm_id_list { -+ u32 id_list_count; -+}; -+ -+/******************************************************************************* -+ * -+ * FPDT - Firmware Performance Data Table (ACPI 5.0) -+ * Version 1 -+ * -+ ******************************************************************************/ -+ -+struct acpi_table_fpdt { -+ struct acpi_table_header header; /* Common ACPI table header */ -+}; -+ -+/* FPDT subtable header */ -+ -+struct acpi_fpdt_header { -+ u16 type; -+ u8 length; -+ u8 revision; -+}; -+ -+/* Values for Type field above */ -+ -+enum acpi_fpdt_type { -+ ACPI_FPDT_TYPE_BOOT = 0, -+ ACPI_FPDT_TYPE_S3PERF = 1, -+}; -+ -+/* -+ * FPDT subtables -+ */ -+ -+/* 0: Firmware Basic Boot Performance Record */ -+ -+struct acpi_fpdt_boot { -+ struct acpi_fpdt_header header; -+ u8 reserved[4]; -+ u64 reset_end; -+ u64 load_start; -+ u64 startup_start; -+ u64 exit_services_entry; -+ u64 exit_services_exit; -+}; -+ -+/* 1: S3 Performance Table Pointer Record */ -+ -+struct acpi_fpdt_s3pt_ptr { -+ struct acpi_fpdt_header header; -+ u8 reserved[4]; -+ u64 address; -+}; -+ -+/* -+ * S3PT - S3 Performance Table. This table is pointed to by the -+ * FPDT S3 Pointer Record above. -+ */ -+struct acpi_table_s3pt { -+ u8 signature[4]; /* "S3PT" */ -+ u32 length; -+}; -+ -+/* -+ * S3PT Subtables -+ */ -+struct acpi_s3pt_header { -+ u16 type; -+ u8 length; -+ u8 revision; -+}; -+ -+/* Values for Type field above */ -+ -+enum acpi_s3pt_type { -+ ACPI_S3PT_TYPE_RESUME = 0, -+ ACPI_S3PT_TYPE_SUSPEND = 1, -+}; -+ -+struct acpi_s3pt_resume { -+ struct acpi_s3pt_header header; -+ u32 resume_count; -+ u64 full_resume; -+ u64 average_resume; -+}; -+ -+struct acpi_s3pt_suspend { -+ struct acpi_s3pt_header header; -+ u64 suspend_start; -+ u64 suspend_end; -+}; -+ -+/******************************************************************************* -+ * -+ * GTDT - Generic Timer Description Table (ACPI 5.0) -+ * Version 1 -+ * -+ ******************************************************************************/ -+ -+struct acpi_table_gtdt { -+ struct acpi_table_header header; /* Common ACPI table header */ -+ u64 address; -+ u32 flags; -+ u32 secure_pl1_interrupt; -+ u32 secure_pl1_flags; -+ u32 non_secure_pl1_interrupt; -+ u32 non_secure_pl1_flags; -+ u32 virtual_timer_interrupt; -+ u32 virtual_timer_flags; -+ u32 non_secure_pl2_interrupt; -+ u32 non_secure_pl2_flags; -+}; -+ -+/* Values for Flags field above */ -+ -+#define ACPI_GTDT_MAPPED_BLOCK_PRESENT 1 -+ -+/* Values for all "TimerFlags" fields above */ -+ -+#define ACPI_GTDT_INTERRUPT_MODE 1 -+#define ACPI_GTDT_INTERRUPT_POLARITY 2 -+ -+/******************************************************************************* -+ * -+ * MPST - Memory Power State Table (ACPI 5.0) -+ * Version 1 -+ * -+ ******************************************************************************/ -+ -+#define ACPI_MPST_CHANNEL_INFO \ -+ u16 reserved1; \ -+ u8 channel_id; \ -+ u8 reserved2; \ -+ u16 power_node_count; -+ -+/* Main table */ -+ -+struct acpi_table_mpst { -+ struct acpi_table_header header; /* Common ACPI table header */ -+ ACPI_MPST_CHANNEL_INFO /* Platform Communication Channel */ -+}; -+ -+/* Memory Platform Communication Channel Info */ -+ -+struct acpi_mpst_channel { -+ ACPI_MPST_CHANNEL_INFO /* Platform Communication Channel */ -+}; -+ -+/* Memory Power Node Structure */ -+ -+struct acpi_mpst_power_node { -+ u8 flags; -+ u8 reserved1; -+ u16 node_id; -+ u32 length; -+ u64 range_address; -+ u64 range_length; -+ u8 num_power_states; -+ u8 num_physical_components; -+ u16 reserved2; -+}; -+ -+/* Values for Flags field above */ -+ -+#define ACPI_MPST_ENABLED 1 -+#define ACPI_MPST_POWER_MANAGED 2 -+#define ACPI_MPST_HOT_PLUG_CAPABLE 4 -+ -+/* Memory Power State Structure (follows POWER_NODE above) */ -+ -+struct acpi_mpst_power_state { -+ u8 power_state; -+ u8 info_index; -+}; -+ -+/* Physical Component ID Structure (follows POWER_STATE above) */ -+ -+struct acpi_mpst_component { -+ u16 component_id; -+}; -+ -+/* Memory Power State Characteristics Structure (follows all POWER_NODEs) */ -+ -+struct acpi_mpst_data_hdr { -+ u16 characteristics_count; -+}; -+ -+struct acpi_mpst_power_data { -+ u8 revision; -+ u8 flags; -+ u16 reserved1; -+ u32 average_power; -+ u32 power_saving; -+ u64 exit_latency; -+ u64 reserved2; -+}; -+ -+/* Values for Flags field above */ -+ -+#define ACPI_MPST_PRESERVE 1 -+#define ACPI_MPST_AUTOENTRY 2 -+#define ACPI_MPST_AUTOEXIT 4 -+ -+/* Shared Memory Region (not part of an ACPI table) */ -+ -+struct acpi_mpst_shared { -+ u32 signature; -+ u16 pcc_command; -+ u16 pcc_status; -+ u16 command_register; -+ u16 status_register; -+ u16 power_state_id; -+ u16 power_node_id; -+ u64 energy_consumed; -+ u64 average_power; -+}; -+ -+/******************************************************************************* -+ * -+ * PCCT - Platform Communications Channel Table (ACPI 5.0) -+ * Version 1 -+ * -+ ******************************************************************************/ -+ -+struct acpi_table_pcct { -+ struct acpi_table_header header; /* Common ACPI table header */ -+ u32 flags; -+ u32 latency; -+ u32 reserved; -+}; -+ -+/* Values for Flags field above */ -+ -+#define ACPI_PCCT_DOORBELL 1 -+ -+/* -+ * PCCT subtables -+ */ -+ -+/* 0: Generic Communications Subspace */ -+ -+struct acpi_pcct_subspace { -+ struct acpi_subtable_header header; -+ u8 reserved[6]; -+ u64 base_address; -+ u64 length; -+ struct acpi_generic_address doorbell_register; -+ u64 preserve_mask; -+ u64 write_mask; -+}; -+ -+/* -+ * PCC memory structures (not part of the ACPI table) -+ */ -+ -+/* Shared Memory Region */ -+ -+struct acpi_pcct_shared_memory { -+ u32 signature; -+ u16 command; -+ u16 status; -+}; -+ -+/******************************************************************************* -+ * -+ * PMTT - Platform Memory Topology Table (ACPI 5.0) -+ * Version 1 -+ * -+ ******************************************************************************/ -+ -+struct acpi_table_pmtt { -+ struct acpi_table_header header; /* Common ACPI table header */ -+ u32 reserved; -+}; -+ -+/* Common header for PMTT subtables that follow main table */ -+ -+struct acpi_pmtt_header { -+ u8 type; -+ u8 reserved1; -+ u16 length; -+ u16 flags; -+ u16 reserved2; -+}; -+ -+/* Values for Type field above */ -+ -+#define ACPI_PMTT_TYPE_SOCKET 0 -+#define ACPI_PMTT_TYPE_CONTROLLER 1 -+#define ACPI_PMTT_TYPE_DIMM 2 -+#define ACPI_PMTT_TYPE_RESERVED 3 /* 0x03-0xFF are reserved */ -+ -+/* Values for Flags field above */ -+ -+#define ACPI_PMTT_TOP_LEVEL 0x0001 -+#define ACPI_PMTT_PHYSICAL 0x0002 -+#define ACPI_PMTT_MEMORY_TYPE 0x000C -+ -+/* -+ * PMTT subtables, correspond to Type in struct acpi_pmtt_header -+ */ -+ -+/* 0: Socket Structure */ -+ -+struct acpi_pmtt_socket { -+ struct acpi_pmtt_header header; -+ u16 socket_id; -+ u16 reserved; -+}; -+ -+/* 1: Memory Controller subtable */ -+ -+struct acpi_pmtt_controller { -+ struct acpi_pmtt_header header; -+ u32 read_latency; -+ u32 write_latency; -+ u32 read_bandwidth; -+ u32 write_bandwidth; -+ u16 access_width; -+ u16 alignment; -+ u16 reserved; -+ u16 domain_count; -+}; -+ -+/* 1a: Proximity Domain substructure */ -+ -+struct acpi_pmtt_domain { -+ u32 proximity_domain; -+}; -+ -+/* 2: Physical Component Identifier (DIMM) */ -+ -+struct acpi_pmtt_physical_component { -+ struct acpi_pmtt_header header; -+ u16 component_id; -+ u16 reserved; -+ u32 memory_size; -+ u32 bios_handle; -+}; -+ -+/******************************************************************************* -+ * -+ * RASF - RAS Feature Table (ACPI 5.0) -+ * Version 1 -+ * -+ ******************************************************************************/ -+ -+struct acpi_table_rasf { -+ struct acpi_table_header header; /* Common ACPI table header */ -+ u8 channel_id[12]; -+}; -+ -+/* RASF Platform Communication Channel Shared Memory Region */ -+ -+struct acpi_rasf_shared_memory { -+ u32 signature; -+ u16 command; -+ u16 status; -+ u64 requested_address; -+ u64 requested_length; -+ u64 actual_address; -+ u64 actual_length; -+ u16 flags; -+ u8 speed; -+}; -+ -+/* Masks for Flags and Speed fields above */ -+ -+#define ACPI_RASF_SCRUBBER_RUNNING 1 -+#define ACPI_RASF_SPEED (7<<1) -+ -+/* Channel Commands */ -+ -+enum acpi_rasf_commands { -+ ACPI_RASF_GET_RAS_CAPABILITIES = 1, -+ ACPI_RASF_GET_PATROL_PARAMETERS = 2, -+ ACPI_RASF_START_PATROL_SCRUBBER = 3, -+ ACPI_RASF_STOP_PATROL_SCRUBBER = 4 -+}; -+ -+/* Channel Command flags */ -+ -+#define ACPI_RASF_GENERATE_SCI (1<<15) -+ -+/* Status values */ -+ -+enum acpi_rasf_status { -+ ACPI_RASF_SUCCESS = 0, -+ ACPI_RASF_NOT_VALID = 1, -+ ACPI_RASF_NOT_SUPPORTED = 2, -+ ACPI_RASF_BUSY = 3, -+ ACPI_RASF_FAILED = 4, -+ ACPI_RASF_ABORTED = 5, -+ ACPI_RASF_INVALID_DATA = 6 -+}; -+ -+/* Status flags */ -+ -+#define ACPI_RASF_COMMAND_COMPLETE (1) -+#define ACPI_RASF_SCI_DOORBELL (1<<1) -+#define ACPI_RASF_ERROR (1<<2) -+#define ACPI_RASF_STATUS (0x1F<<3) -+ -+/* Reset to default packing */ -+ -+#pragma pack() -+ -+#endif /* __ACTBL3_H__ */ diff --git a/26133-IOMMU-defer-BM-disable.patch b/26133-IOMMU-defer-BM-disable.patch deleted file mode 100644 index 5674ed9..0000000 --- a/26133-IOMMU-defer-BM-disable.patch +++ /dev/null @@ -1,178 +0,0 @@ -References: bnc#787169 - -# HG changeset patch -# User Jan Beulich -# Date 1352709367 -3600 -# Node ID fdb69dd527cd01a46f87efb380050559dcf12d37 -# Parent 286ef4ced2164f4e9bf52fd0c52248182e69a6e6 -IOMMU: don't immediately disable bus mastering on faults - -Instead, give the owning domain at least a small opportunity of fixing -things up, and allow for rare faults to not bring down the device at -all. - -Signed-off-by: Jan Beulich -Acked-by: Tim Deegan -Acked-by: Dario Faggioli - -Index: xen-4.2.2-testing/xen/drivers/passthrough/amd/iommu_init.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/amd/iommu_init.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/amd/iommu_init.c -@@ -564,7 +564,7 @@ static hw_irq_controller iommu_msi_type - - static void parse_event_log_entry(struct amd_iommu *iommu, u32 entry[]) - { -- u16 domain_id, device_id, bdf, cword; -+ u16 domain_id, device_id, bdf; - u32 code; - u64 *addr; - int count = 0; -@@ -615,18 +615,10 @@ static void parse_event_log_entry(struct - "fault address = 0x%"PRIx64"\n", - event_str[code-1], domain_id, device_id, *addr); - -- /* Tell the device to stop DMAing; we can't rely on the guest to -- * control it for us. */ - for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ ) - if ( get_dma_requestor_id(iommu->seg, bdf) == device_id ) -- { -- cword = pci_conf_read16(iommu->seg, PCI_BUS(bdf), -- PCI_SLOT(bdf), PCI_FUNC(bdf), -- PCI_COMMAND); -- pci_conf_write16(iommu->seg, PCI_BUS(bdf), PCI_SLOT(bdf), -- PCI_FUNC(bdf), PCI_COMMAND, -- cword & ~PCI_COMMAND_MASTER); -- } -+ pci_check_disable_device(iommu->seg, PCI_BUS(bdf), -+ PCI_DEVFN2(bdf)); - } - else - { -Index: xen-4.2.2-testing/xen/drivers/passthrough/iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/iommu.c -@@ -218,6 +218,7 @@ static int device_assigned(u16 seg, u8 b - static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) - { - struct hvm_iommu *hd = domain_hvm_iommu(d); -+ struct pci_dev *pdev; - int rc = 0; - - if ( !iommu_enabled || !hd->platform_ops ) -@@ -231,6 +232,10 @@ static int assign_device(struct domain * - return -EXDEV; - - spin_lock(&pcidevs_lock); -+ pdev = pci_get_pdev(seg, bus, devfn); -+ if ( pdev ) -+ pdev->fault.count = 0; -+ - if ( (rc = hd->platform_ops->assign_device(d, seg, bus, devfn)) ) - goto done; - -@@ -382,6 +387,8 @@ int deassign_device(struct domain *d, u1 - return ret; - } - -+ pdev->fault.count = 0; -+ - if ( !has_arch_pdevs(d) && need_iommu(d) ) - { - d->need_iommu = 0; -Index: xen-4.2.2-testing/xen/drivers/passthrough/pci.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/pci.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/pci.c -@@ -637,6 +637,36 @@ int __init pci_device_detect(u16 seg, u8 - return 1; - } - -+void pci_check_disable_device(u16 seg, u8 bus, u8 devfn) -+{ -+ struct pci_dev *pdev; -+ s_time_t now = NOW(); -+ u16 cword; -+ -+ spin_lock(&pcidevs_lock); -+ pdev = pci_get_pdev(seg, bus, devfn); -+ if ( pdev ) -+ { -+ if ( now < pdev->fault.time || -+ now - pdev->fault.time > MILLISECS(10) ) -+ pdev->fault.count >>= 1; -+ pdev->fault.time = now; -+ if ( ++pdev->fault.count < PT_FAULT_THRESHOLD ) -+ pdev = NULL; -+ } -+ spin_unlock(&pcidevs_lock); -+ -+ if ( !pdev ) -+ return; -+ -+ /* Tell the device to stop DMAing; we can't rely on the guest to -+ * control it for us. */ -+ cword = pci_conf_read16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -+ PCI_COMMAND); -+ pci_conf_write16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -+ PCI_COMMAND, cword & ~PCI_COMMAND_MASTER); -+} -+ - /* - * scan pci devices to add all existed PCI devices to alldevs_list, - * and setup pci hierarchy in array bus2bridge. -Index: xen-4.2.2-testing/xen/drivers/passthrough/vtd/iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/vtd/iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/vtd/iommu.c -@@ -936,7 +936,7 @@ static void __do_iommu_page_fault(struct - while (1) - { - u8 fault_reason; -- u16 source_id, cword; -+ u16 source_id; - u32 data; - u64 guest_addr; - int type; -@@ -969,14 +969,8 @@ static void __do_iommu_page_fault(struct - iommu_page_fault_do_one(iommu, type, fault_reason, - source_id, guest_addr); - -- /* Tell the device to stop DMAing; we can't rely on the guest to -- * control it for us. */ -- cword = pci_conf_read16(iommu->intel->drhd->segment, -- PCI_BUS(source_id), PCI_SLOT(source_id), -- PCI_FUNC(source_id), PCI_COMMAND); -- pci_conf_write16(iommu->intel->drhd->segment, PCI_BUS(source_id), -- PCI_SLOT(source_id), PCI_FUNC(source_id), -- PCI_COMMAND, cword & ~PCI_COMMAND_MASTER); -+ pci_check_disable_device(iommu->intel->drhd->segment, -+ PCI_BUS(source_id), PCI_DEVFN2(source_id)); - - fault_index++; - if ( fault_index > cap_num_fault_regs(iommu->cap) ) -Index: xen-4.2.2-testing/xen/include/xen/pci.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/pci.h -+++ xen-4.2.2-testing/xen/include/xen/pci.h -@@ -65,6 +65,11 @@ struct pci_dev { - const u8 devfn; - struct pci_dev_info info; - struct arch_pci_dev arch; -+ struct { -+ s_time_t time; -+ unsigned int count; -+#define PT_FAULT_THRESHOLD 10 -+ } fault; - u64 vf_rlen[6]; - }; - -@@ -107,6 +112,7 @@ void arch_pci_ro_device(int seg, int bdf - struct pci_dev *pci_get_pdev(int seg, int bus, int devfn); - struct pci_dev *pci_get_pdev_by_domain( - struct domain *, int seg, int bus, int devfn); -+void pci_check_disable_device(u16 seg, u8 bus, u8 devfn); - - uint8_t pci_conf_read8( - unsigned int seg, unsigned int bus, unsigned int dev, unsigned int func, diff --git a/26189-xenstore-chmod.patch b/26189-xenstore-chmod.patch deleted file mode 100644 index 7fe1545..0000000 --- a/26189-xenstore-chmod.patch +++ /dev/null @@ -1,85 +0,0 @@ -# HG changeset patch -# Parent 8b93ac0c93f3fb8a140b4688ba71841ac927d4e3 -xenstore-chmod: handle arbitrary number of perms rather than MAX_PERMS constant - -Constant MAX_PERMS 16 is too small to use in some occasions, e.g. if -there are more than 16 domU(s) on one hypervisor (it's easy to -achieve) and one wants to do xenstore-chmod PATH to all domU(s). So, -remove MAX_PERMS limitation and make it as arbitrary number of perms. - -Signed-off-by: Chunyan Liu -Acked-by: Ian Campbell - -diff -r 8b93ac0c93f3 tools/xenstore/xenstore_client.c ---- a/tools/xenstore/xenstore_client.c Tue Nov 13 11:19:17 2012 +0000 -+++ b/tools/xenstore/xenstore_client.c Mon Nov 26 11:33:38 2012 +0800 -@@ -25,7 +25,6 @@ - #define PATH_SEP '/' - #define MAX_PATH_LEN 256 - --#define MAX_PERMS 16 - - enum mode { - MODE_unknown, -@@ -407,44 +406,41 @@ perform(enum mode mode, int optind, int - output("%s\n", list[i]); - } - free(list); -- optind++; -- break; -- } -- case MODE_ls: { -- do_ls(xsh, argv[optind], 0, prefix); -- optind++; -- break; -+ optind++; -+ break; -+ } -+ case MODE_ls: { -+ do_ls(xsh, argv[optind], 0, prefix); -+ optind++; -+ break; - } - case MODE_chmod: { -- struct xs_permissions perms[MAX_PERMS]; -- int nperms = 0; - /* save path pointer: */ - char *path = argv[optind++]; -- for (; argv[optind]; optind++, nperms++) -+ int nperms = argc - optind; -+ struct xs_permissions perms[nperms]; -+ int i; -+ for (i = 0; argv[optind]; optind++, i++) - { -- if (MAX_PERMS <= nperms) -- errx(1, "Too many permissions specified. " -- "Maximum per invocation is %d.", MAX_PERMS); -- -- perms[nperms].id = atoi(argv[optind]+1); -+ perms[i].id = atoi(argv[optind]+1); - - switch (argv[optind][0]) - { - case 'n': -- perms[nperms].perms = XS_PERM_NONE; -+ perms[i].perms = XS_PERM_NONE; - break; - case 'r': -- perms[nperms].perms = XS_PERM_READ; -+ perms[i].perms = XS_PERM_READ; - break; - case 'w': -- perms[nperms].perms = XS_PERM_WRITE; -+ perms[i].perms = XS_PERM_WRITE; - break; - case 'b': -- perms[nperms].perms = XS_PERM_READ | XS_PERM_WRITE; -+ perms[i].perms = XS_PERM_READ | XS_PERM_WRITE; - break; - default: - errx(1, "Invalid permission specification: '%c'", -- argv[optind][0]); -+ argv[optind][0]); - } - } - diff --git a/26262-x86-EFI-secure-shim.patch b/26262-x86-EFI-secure-shim.patch deleted file mode 100644 index 37c1bad..0000000 --- a/26262-x86-EFI-secure-shim.patch +++ /dev/null @@ -1,62 +0,0 @@ -# HG changeset patch -# User Jan Beulich -# Date 1354884272 -3600 -# Node ID b62bd62b26836fafe19cf41fec194bcf33e2ead6 -# Parent cb542e58da25211843eb79998ea8568ebe9c8056 -x86/EFI: add code interfacing with the secure boot shim - -... to validate the kernel image (which is required to be in PE -format, as is e.g. the case for the Linux bzImage when built with -CONFIG_EFI_STUB). - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser - ---- a/xen/arch/x86/efi/boot.c -+++ b/xen/arch/x86/efi/boot.c -@@ -24,6 +24,18 @@ - #include - #include - -+#define SHIM_LOCK_PROTOCOL_GUID \ -+ { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} } -+ -+typedef EFI_STATUS -+(/* _not_ EFIAPI */ *EFI_SHIM_LOCK_VERIFY) ( -+ IN VOID *Buffer, -+ IN UINT32 Size); -+ -+typedef struct { -+ EFI_SHIM_LOCK_VERIFY Verify; -+} EFI_SHIM_LOCK_PROTOCOL; -+ - extern char start[]; - extern u32 cpuid_ext_features; - -@@ -628,12 +640,14 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY - static EFI_GUID __initdata gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; - static EFI_GUID __initdata bio_guid = BLOCK_IO_PROTOCOL; - static EFI_GUID __initdata devp_guid = DEVICE_PATH_PROTOCOL; -+ static EFI_GUID __initdata shim_lock_guid = SHIM_LOCK_PROTOCOL_GUID; - EFI_LOADED_IMAGE *loaded_image; - EFI_STATUS status; - unsigned int i, argc; - CHAR16 **argv, *file_name, *cfg_file_name = NULL; - UINTN cols, rows, depth, size, map_key, info_size, gop_mode = ~0; - EFI_HANDLE *handles = NULL; -+ EFI_SHIM_LOCK_PROTOCOL *shim_lock; - EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL; - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info; - EFI_FILE_HANDLE dir_handle; -@@ -823,6 +837,11 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY - read_file(dir_handle, s2w(&name), &kernel); - efi_bs->FreePool(name.w); - -+ if ( !EFI_ERROR(efi_bs->LocateProtocol(&shim_lock_guid, NULL, -+ (void **)&shim_lock)) && -+ shim_lock->Verify(kernel.ptr, kernel.size) != EFI_SUCCESS ) -+ blexit(L"Dom0 kernel image could not be verified\r\n"); -+ - name.s = get_value(&cfg, section.s, "ramdisk"); - if ( name.s ) - { diff --git a/26324-IOMMU-assign-params.patch b/26324-IOMMU-assign-params.patch deleted file mode 100644 index b47596c..0000000 --- a/26324-IOMMU-assign-params.patch +++ /dev/null @@ -1,275 +0,0 @@ -References: bnc#787169 - -# HG changeset patch -# User Jan Beulich -# Date 1357559364 -3600 -# Node ID 62dd78a4e3fc9d190840549f13b4d613f2d19c41 -# Parent 64b36dde26bc3c4fc80312cc9eeb0e511f0cf94b -IOMMU: adjust (re)assign operation parameters - -... to use a (struct pci_dev *, devfn) pair. - -Signed-off-by: Jan Beulich -Acked-by: "Zhang, Xiantao" - -Index: xen-4.2.2-testing/xen/drivers/passthrough/amd/pci_amd_iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/amd/pci_amd_iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/amd/pci_amd_iommu.c -@@ -333,34 +333,31 @@ void amd_iommu_disable_domain_device(str - disable_ats_device(iommu->seg, bus, devfn); - } - --static int reassign_device( struct domain *source, struct domain *target, -- u16 seg, u8 bus, u8 devfn) -+static int reassign_device(struct domain *source, struct domain *target, -+ u8 devfn, struct pci_dev *pdev) - { -- struct pci_dev *pdev; - struct amd_iommu *iommu; - int bdf; - struct hvm_iommu *t = domain_hvm_iommu(target); - -- ASSERT(spin_is_locked(&pcidevs_lock)); -- pdev = pci_get_pdev_by_domain(source, seg, bus, devfn); -- if ( !pdev ) -- return -ENODEV; -- -- bdf = PCI_BDF2(bus, devfn); -- iommu = find_iommu_for_device(seg, bdf); -+ bdf = PCI_BDF2(pdev->bus, pdev->devfn); -+ iommu = find_iommu_for_device(pdev->seg, bdf); - if ( !iommu ) - { - AMD_IOMMU_DEBUG("Fail to find iommu." - " %04x:%02x:%x02.%x cannot be assigned to dom%d\n", -- seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -+ pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), - target->domain_id); - return -ENODEV; - } - - amd_iommu_disable_domain_device(source, iommu, bdf); - -- list_move(&pdev->domain_list, &target->arch.pdev_list); -- pdev->domain = target; -+ if ( devfn == pdev->devfn ) -+ { -+ list_move(&pdev->domain_list, &target->arch.pdev_list); -+ pdev->domain = target; -+ } - - /* IO page tables might be destroyed after pci-detach the last device - * In this case, we have to re-allocate root table for next pci-attach.*/ -@@ -369,17 +366,18 @@ static int reassign_device( struct domai - - amd_iommu_setup_domain_device(target, iommu, bdf); - AMD_IOMMU_DEBUG("Re-assign %04x:%02x:%02x.%u from dom%d to dom%d\n", -- seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -+ pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), - source->domain_id, target->domain_id); - - return 0; - } - --static int amd_iommu_assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) -+static int amd_iommu_assign_device(struct domain *d, u8 devfn, -+ struct pci_dev *pdev) - { -- struct ivrs_mappings *ivrs_mappings = get_ivrs_mappings(seg); -- int bdf = (bus << 8) | devfn; -- int req_id = get_dma_requestor_id(seg, bdf); -+ struct ivrs_mappings *ivrs_mappings = get_ivrs_mappings(pdev->seg); -+ int bdf = PCI_BDF2(pdev->bus, devfn); -+ int req_id = get_dma_requestor_id(pdev->seg, bdf); - - if ( ivrs_mappings[req_id].unity_map_enable ) - { -@@ -391,7 +389,7 @@ static int amd_iommu_assign_device(struc - ivrs_mappings[req_id].read_permission); - } - -- return reassign_device(dom0, d, seg, bus, devfn); -+ return reassign_device(dom0, d, devfn, pdev); - } - - static void deallocate_next_page_table(struct page_info* pg, int level) -@@ -456,12 +454,6 @@ static void amd_iommu_domain_destroy(str - amd_iommu_flush_all_pages(d); - } - --static int amd_iommu_return_device( -- struct domain *s, struct domain *t, u16 seg, u8 bus, u8 devfn) --{ -- return reassign_device(s, t, seg, bus, devfn); --} -- - static int amd_iommu_add_device(struct pci_dev *pdev) - { - struct amd_iommu *iommu; -@@ -601,7 +593,7 @@ const struct iommu_ops amd_iommu_ops = { - .teardown = amd_iommu_domain_destroy, - .map_page = amd_iommu_map_page, - .unmap_page = amd_iommu_unmap_page, -- .reassign_device = amd_iommu_return_device, -+ .reassign_device = reassign_device, - .get_device_group_id = amd_iommu_group_id, - .update_ire_from_apic = amd_iommu_ioapic_update_ire, - .update_ire_from_msi = amd_iommu_msi_msg_update_ire, -Index: xen-4.2.2-testing/xen/drivers/passthrough/iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/iommu.c -@@ -232,11 +232,16 @@ static int assign_device(struct domain * - return -EXDEV; - - spin_lock(&pcidevs_lock); -- pdev = pci_get_pdev(seg, bus, devfn); -- if ( pdev ) -- pdev->fault.count = 0; -+ pdev = pci_get_pdev_by_domain(dom0, seg, bus, devfn); -+ if ( !pdev ) -+ { -+ rc = pci_get_pdev(seg, bus, devfn) ? -EBUSY : -ENODEV; -+ goto done; -+ } -+ -+ pdev->fault.count = 0; - -- if ( (rc = hd->platform_ops->assign_device(d, seg, bus, devfn)) ) -+ if ( (rc = hd->platform_ops->assign_device(d, devfn, pdev)) ) - goto done; - - if ( has_arch_pdevs(d) && !need_iommu(d) ) -@@ -367,18 +372,11 @@ int deassign_device(struct domain *d, u1 - return -EINVAL; - - ASSERT(spin_is_locked(&pcidevs_lock)); -- pdev = pci_get_pdev(seg, bus, devfn); -+ pdev = pci_get_pdev_by_domain(d, seg, bus, devfn); - if ( !pdev ) - return -ENODEV; - -- if ( pdev->domain != d ) -- { -- dprintk(XENLOG_ERR VTDPREFIX, -- "d%d: deassign a device not owned\n", d->domain_id); -- return -EINVAL; -- } -- -- ret = hd->platform_ops->reassign_device(d, dom0, seg, bus, devfn); -+ ret = hd->platform_ops->reassign_device(d, dom0, devfn, pdev); - if ( ret ) - { - dprintk(XENLOG_ERR VTDPREFIX, -Index: xen-4.2.2-testing/xen/drivers/passthrough/vtd/iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/vtd/iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/vtd/iommu.c -@@ -1689,17 +1689,10 @@ out: - static int reassign_device_ownership( - struct domain *source, - struct domain *target, -- u16 seg, u8 bus, u8 devfn) -+ u8 devfn, struct pci_dev *pdev) - { -- struct pci_dev *pdev; - int ret; - -- ASSERT(spin_is_locked(&pcidevs_lock)); -- pdev = pci_get_pdev_by_domain(source, seg, bus, devfn); -- -- if (!pdev) -- return -ENODEV; -- - /* - * Devices assigned to untrusted domains (here assumed to be any domU) - * can attempt to send arbitrary LAPIC/MSI messages. We are unprotected -@@ -1708,16 +1701,19 @@ static int reassign_device_ownership( - if ( (target != dom0) && !iommu_intremap ) - untrusted_msi = 1; - -- ret = domain_context_unmap(source, seg, bus, devfn); -+ ret = domain_context_unmap(source, pdev->seg, pdev->bus, devfn); - if ( ret ) - return ret; - -- ret = domain_context_mapping(target, seg, bus, devfn); -+ ret = domain_context_mapping(target, pdev->seg, pdev->bus, devfn); - if ( ret ) - return ret; - -- list_move(&pdev->domain_list, &target->arch.pdev_list); -- pdev->domain = target; -+ if ( devfn == pdev->devfn ) -+ { -+ list_move(&pdev->domain_list, &target->arch.pdev_list); -+ pdev->domain = target; -+ } - - return ret; - } -@@ -2222,36 +2218,26 @@ int __init intel_vtd_setup(void) - } - - static int intel_iommu_assign_device( -- struct domain *d, u16 seg, u8 bus, u8 devfn) -+ struct domain *d, u8 devfn, struct pci_dev *pdev) - { - struct acpi_rmrr_unit *rmrr; - int ret = 0, i; -- struct pci_dev *pdev; -- u16 bdf; -+ u16 bdf, seg; -+ u8 bus; - - if ( list_empty(&acpi_drhd_units) ) - return -ENODEV; - -- ASSERT(spin_is_locked(&pcidevs_lock)); -- pdev = pci_get_pdev(seg, bus, devfn); -- if (!pdev) -- return -ENODEV; -- -- if (pdev->domain != dom0) -- { -- dprintk(XENLOG_ERR VTDPREFIX, -- "IOMMU: assign a assigned device\n"); -- return -EBUSY; -- } -- -- ret = reassign_device_ownership(dom0, d, seg, bus, devfn); -+ ret = reassign_device_ownership(dom0, d, devfn, pdev); - if ( ret ) - goto done; - - /* FIXME: Because USB RMRR conflicts with guest bios region, - * ignore USB RMRR temporarily. - */ -- if ( is_usb_device(seg, bus, devfn) ) -+ seg = pdev->seg; -+ bus = pdev->bus; -+ if ( is_usb_device(seg, bus, pdev->devfn) ) - { - ret = 0; - goto done; -Index: xen-4.2.2-testing/xen/include/xen/iommu.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/iommu.h -+++ xen-4.2.2-testing/xen/include/xen/iommu.h -@@ -123,13 +123,13 @@ struct iommu_ops { - int (*add_device)(struct pci_dev *pdev); - int (*enable_device)(struct pci_dev *pdev); - int (*remove_device)(struct pci_dev *pdev); -- int (*assign_device)(struct domain *d, u16 seg, u8 bus, u8 devfn); -+ int (*assign_device)(struct domain *, u8 devfn, struct pci_dev *); - void (*teardown)(struct domain *d); - int (*map_page)(struct domain *d, unsigned long gfn, unsigned long mfn, - unsigned int flags); - int (*unmap_page)(struct domain *d, unsigned long gfn); - int (*reassign_device)(struct domain *s, struct domain *t, -- u16 seg, u8 bus, u8 devfn); -+ u8 devfn, struct pci_dev *); - int (*get_device_group_id)(u16 seg, u8 bus, u8 devfn); - void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value); - void (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg); diff --git a/26325-IOMMU-add-remove-params.patch b/26325-IOMMU-add-remove-params.patch deleted file mode 100644 index 326125d..0000000 --- a/26325-IOMMU-add-remove-params.patch +++ /dev/null @@ -1,366 +0,0 @@ -References: bnc#787169 - -# HG changeset patch -# User Jan Beulich -# Date 1357559482 -3600 -# Node ID 75cc4943b1ff509c4074800a23ff51d773233b8a -# Parent 62dd78a4e3fc9d190840549f13b4d613f2d19c41 -IOMMU: adjust add/remove operation parameters - -... to use a (struct pci_dev *, devfn) pair. - -Signed-off-by: Jan Beulich -Acked-by: "Zhang, Xiantao" - -Index: xen-4.2.2-testing/xen/drivers/passthrough/amd/pci_amd_iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/amd/pci_amd_iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/amd/pci_amd_iommu.c -@@ -83,14 +83,14 @@ static void disable_translation(u32 *dte - } - - static void amd_iommu_setup_domain_device( -- struct domain *domain, struct amd_iommu *iommu, int bdf) -+ struct domain *domain, struct amd_iommu *iommu, -+ u8 devfn, struct pci_dev *pdev) - { - void *dte; - unsigned long flags; - int req_id, valid = 1; - int dte_i = 0; -- u8 bus = PCI_BUS(bdf); -- u8 devfn = PCI_DEVFN2(bdf); -+ u8 bus = pdev->bus; - - struct hvm_iommu *hd = domain_hvm_iommu(domain); - -@@ -103,7 +103,7 @@ static void amd_iommu_setup_domain_devic - dte_i = 1; - - /* get device-table entry */ -- req_id = get_dma_requestor_id(iommu->seg, bdf); -+ req_id = get_dma_requestor_id(iommu->seg, PCI_BDF2(bus, devfn)); - dte = iommu->dev_table.buffer + (req_id * IOMMU_DEV_TABLE_ENTRY_SIZE); - - spin_lock_irqsave(&iommu->lock, flags); -@@ -115,7 +115,7 @@ static void amd_iommu_setup_domain_devic - (u32 *)dte, page_to_maddr(hd->root_table), hd->domain_id, - hd->paging_mode, valid); - -- if ( pci_ats_device(iommu->seg, bus, devfn) && -+ if ( pci_ats_device(iommu->seg, bus, pdev->devfn) && - iommu_has_cap(iommu, PCI_CAP_IOTLB_SHIFT) ) - iommu_dte_set_iotlb((u32 *)dte, dte_i); - -@@ -132,32 +132,31 @@ static void amd_iommu_setup_domain_devic - - ASSERT(spin_is_locked(&pcidevs_lock)); - -- if ( pci_ats_device(iommu->seg, bus, devfn) && -- !pci_ats_enabled(iommu->seg, bus, devfn) ) -+ if ( pci_ats_device(iommu->seg, bus, pdev->devfn) && -+ !pci_ats_enabled(iommu->seg, bus, pdev->devfn) ) - { -- struct pci_dev *pdev; -+ if ( devfn == pdev->devfn ) -+ enable_ats_device(iommu->seg, bus, devfn); - -- enable_ats_device(iommu->seg, bus, devfn); -- -- ASSERT(spin_is_locked(&pcidevs_lock)); -- pdev = pci_get_pdev(iommu->seg, bus, devfn); -- -- ASSERT( pdev != NULL ); - amd_iommu_flush_iotlb(pdev, INV_IOMMU_ALL_PAGES_ADDRESS, 0); - } - } - --static void __init amd_iommu_setup_dom0_device(struct pci_dev *pdev) -+static int __init amd_iommu_setup_dom0_device(u8 devfn, struct pci_dev *pdev) - { - int bdf = PCI_BDF2(pdev->bus, pdev->devfn); - struct amd_iommu *iommu = find_iommu_for_device(pdev->seg, bdf); - -- if ( likely(iommu != NULL) ) -- amd_iommu_setup_domain_device(pdev->domain, iommu, bdf); -- else -+ if ( unlikely(!iommu) ) -+ { - AMD_IOMMU_DEBUG("No iommu for device %04x:%02x:%02x.%u\n", - pdev->seg, pdev->bus, -- PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); -+ PCI_SLOT(devfn), PCI_FUNC(devfn)); -+ return -ENODEV; -+ } -+ -+ amd_iommu_setup_domain_device(pdev->domain, iommu, devfn, pdev); -+ return 0; - } - - int __init amd_iov_detect(void) -@@ -296,16 +295,16 @@ static void __init amd_iommu_dom0_init(s - } - - void amd_iommu_disable_domain_device(struct domain *domain, -- struct amd_iommu *iommu, int bdf) -+ struct amd_iommu *iommu, -+ u8 devfn, struct pci_dev *pdev) - { - void *dte; - unsigned long flags; - int req_id; -- u8 bus = PCI_BUS(bdf); -- u8 devfn = PCI_DEVFN2(bdf); -+ u8 bus = pdev->bus; - - BUG_ON ( iommu->dev_table.buffer == NULL ); -- req_id = get_dma_requestor_id(iommu->seg, bdf); -+ req_id = get_dma_requestor_id(iommu->seg, PCI_BDF2(bus, devfn)); - dte = iommu->dev_table.buffer + (req_id * IOMMU_DEV_TABLE_ENTRY_SIZE); - - spin_lock_irqsave(&iommu->lock, flags); -@@ -313,7 +312,7 @@ void amd_iommu_disable_domain_device(str - { - disable_translation((u32 *)dte); - -- if ( pci_ats_device(iommu->seg, bus, devfn) && -+ if ( pci_ats_device(iommu->seg, bus, pdev->devfn) && - iommu_has_cap(iommu, PCI_CAP_IOTLB_SHIFT) ) - iommu_dte_set_iotlb((u32 *)dte, 0); - -@@ -328,7 +327,8 @@ void amd_iommu_disable_domain_device(str - - ASSERT(spin_is_locked(&pcidevs_lock)); - -- if ( pci_ats_device(iommu->seg, bus, devfn) && -+ if ( devfn == pdev->devfn && -+ pci_ats_device(iommu->seg, bus, devfn) && - pci_ats_enabled(iommu->seg, bus, devfn) ) - disable_ats_device(iommu->seg, bus, devfn); - } -@@ -351,7 +351,7 @@ static int reassign_device(struct domain - return -ENODEV; - } - -- amd_iommu_disable_domain_device(source, iommu, bdf); -+ amd_iommu_disable_domain_device(source, iommu, devfn, pdev); - - if ( devfn == pdev->devfn ) - { -@@ -364,7 +364,7 @@ static int reassign_device(struct domain - if ( t->root_table == NULL ) - allocate_domain_resources(t); - -- amd_iommu_setup_domain_device(target, iommu, bdf); -+ amd_iommu_setup_domain_device(target, iommu, devfn, pdev); - AMD_IOMMU_DEBUG("Re-assign %04x:%02x:%02x.%u from dom%d to dom%d\n", - pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), - source->domain_id, target->domain_id); -@@ -454,7 +454,7 @@ static void amd_iommu_domain_destroy(str - amd_iommu_flush_all_pages(d); - } - --static int amd_iommu_add_device(struct pci_dev *pdev) -+static int amd_iommu_add_device(u8 devfn, struct pci_dev *pdev) - { - struct amd_iommu *iommu; - u16 bdf; -@@ -467,16 +467,16 @@ static int amd_iommu_add_device(struct p - { - AMD_IOMMU_DEBUG("Fail to find iommu." - " %04x:%02x:%02x.%u cannot be assigned to dom%d\n", -- pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn), -- PCI_FUNC(pdev->devfn), pdev->domain->domain_id); -+ pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -+ pdev->domain->domain_id); - return -ENODEV; - } - -- amd_iommu_setup_domain_device(pdev->domain, iommu, bdf); -+ amd_iommu_setup_domain_device(pdev->domain, iommu, devfn, pdev); - return 0; - } - --static int amd_iommu_remove_device(struct pci_dev *pdev) -+static int amd_iommu_remove_device(u8 devfn, struct pci_dev *pdev) - { - struct amd_iommu *iommu; - u16 bdf; -@@ -489,12 +489,12 @@ static int amd_iommu_remove_device(struc - { - AMD_IOMMU_DEBUG("Fail to find iommu." - " %04x:%02x:%02x.%u cannot be removed from dom%d\n", -- pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn), -- PCI_FUNC(pdev->devfn), pdev->domain->domain_id); -+ pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -+ pdev->domain->domain_id); - return -ENODEV; - } - -- amd_iommu_disable_domain_device(pdev->domain, iommu, bdf); -+ amd_iommu_disable_domain_device(pdev->domain, iommu, devfn, pdev); - return 0; - } - -Index: xen-4.2.2-testing/xen/drivers/passthrough/iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/iommu.c -@@ -167,7 +167,7 @@ int iommu_add_device(struct pci_dev *pde - if ( !iommu_enabled || !hd->platform_ops ) - return 0; - -- return hd->platform_ops->add_device(pdev); -+ return hd->platform_ops->add_device(pdev->devfn, pdev); - } - - int iommu_enable_device(struct pci_dev *pdev) -@@ -197,7 +197,7 @@ int iommu_remove_device(struct pci_dev * - if ( !iommu_enabled || !hd->platform_ops ) - return 0; - -- return hd->platform_ops->remove_device(pdev); -+ return hd->platform_ops->remove_device(pdev->devfn, pdev); - } - - /* -Index: xen-4.2.2-testing/xen/drivers/passthrough/pci.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/pci.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/pci.c -@@ -715,7 +715,7 @@ int __init scan_pci_devices(void) - - struct setup_dom0 { - struct domain *d; -- void (*handler)(struct pci_dev *); -+ int (*handler)(u8 devfn, struct pci_dev *); - }; - - static int __init _setup_dom0_pci_devices(struct pci_seg *pseg, void *arg) -@@ -734,7 +734,7 @@ static int __init _setup_dom0_pci_device - - pdev->domain = ctxt->d; - list_add(&pdev->domain_list, &ctxt->d->arch.pdev_list); -- ctxt->handler(pdev); -+ ctxt->handler(devfn, pdev); - } - } - -@@ -742,7 +742,7 @@ static int __init _setup_dom0_pci_device - } - - void __init setup_dom0_pci_devices( -- struct domain *d, void (*handler)(struct pci_dev *)) -+ struct domain *d, int (*handler)(u8 devfn, struct pci_dev *)) - { - struct setup_dom0 ctxt = { .d = d, .handler = handler }; - -Index: xen-4.2.2-testing/xen/drivers/passthrough/vtd/iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/vtd/iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/vtd/iommu.c -@@ -52,7 +52,7 @@ int nr_iommus; - - static struct tasklet vtd_fault_tasklet; - --static void setup_dom0_device(struct pci_dev *); -+static int setup_dom0_device(u8 devfn, struct pci_dev *); - static void setup_dom0_rmrr(struct domain *d); - - static int domain_iommu_domid(struct domain *d, -@@ -1904,7 +1904,7 @@ static int rmrr_identity_mapping(struct - return 0; - } - --static int intel_iommu_add_device(struct pci_dev *pdev) -+static int intel_iommu_add_device(u8 devfn, struct pci_dev *pdev) - { - struct acpi_rmrr_unit *rmrr; - u16 bdf; -@@ -1915,8 +1915,7 @@ static int intel_iommu_add_device(struct - if ( !pdev->domain ) - return -EINVAL; - -- ret = domain_context_mapping(pdev->domain, pdev->seg, pdev->bus, -- pdev->devfn); -+ ret = domain_context_mapping(pdev->domain, pdev->seg, pdev->bus, devfn); - if ( ret ) - { - dprintk(XENLOG_ERR VTDPREFIX, "d%d: context mapping failed\n", -@@ -1928,7 +1927,7 @@ static int intel_iommu_add_device(struct - { - if ( rmrr->segment == pdev->seg && - PCI_BUS(bdf) == pdev->bus && -- PCI_DEVFN2(bdf) == pdev->devfn ) -+ PCI_DEVFN2(bdf) == devfn ) - { - ret = rmrr_identity_mapping(pdev->domain, rmrr); - if ( ret ) -@@ -1953,7 +1952,7 @@ static int intel_iommu_enable_device(str - return ret >= 0 ? 0 : ret; - } - --static int intel_iommu_remove_device(struct pci_dev *pdev) -+static int intel_iommu_remove_device(u8 devfn, struct pci_dev *pdev) - { - struct acpi_rmrr_unit *rmrr; - u16 bdf; -@@ -1971,19 +1970,22 @@ static int intel_iommu_remove_device(str - { - if ( rmrr->segment == pdev->seg && - PCI_BUS(bdf) == pdev->bus && -- PCI_DEVFN2(bdf) == pdev->devfn ) -+ PCI_DEVFN2(bdf) == devfn ) - return 0; - } - } - -- return domain_context_unmap(pdev->domain, pdev->seg, pdev->bus, -- pdev->devfn); -+ return domain_context_unmap(pdev->domain, pdev->seg, pdev->bus, devfn); - } - --static void __init setup_dom0_device(struct pci_dev *pdev) -+static int __init setup_dom0_device(u8 devfn, struct pci_dev *pdev) - { -- domain_context_mapping(pdev->domain, pdev->seg, pdev->bus, pdev->devfn); -- pci_vtd_quirk(pdev); -+ int err; -+ -+ err = domain_context_mapping(pdev->domain, pdev->seg, pdev->bus, devfn); -+ if ( !err && devfn == pdev->devfn ) -+ pci_vtd_quirk(pdev); -+ return err; - } - - void clear_fault_bits(struct iommu *iommu) -Index: xen-4.2.2-testing/xen/include/xen/iommu.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/iommu.h -+++ xen-4.2.2-testing/xen/include/xen/iommu.h -@@ -120,9 +120,9 @@ bool_t pt_irq_need_timer(uint32_t flags) - struct iommu_ops { - int (*init)(struct domain *d); - void (*dom0_init)(struct domain *d); -- int (*add_device)(struct pci_dev *pdev); -+ int (*add_device)(u8 devfn, struct pci_dev *); - int (*enable_device)(struct pci_dev *pdev); -- int (*remove_device)(struct pci_dev *pdev); -+ int (*remove_device)(u8 devfn, struct pci_dev *); - int (*assign_device)(struct domain *, u8 devfn, struct pci_dev *); - void (*teardown)(struct domain *d); - int (*map_page)(struct domain *d, unsigned long gfn, unsigned long mfn, -Index: xen-4.2.2-testing/xen/include/xen/pci.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/pci.h -+++ xen-4.2.2-testing/xen/include/xen/pci.h -@@ -101,7 +101,8 @@ struct pci_dev *pci_lock_pdev(int seg, i - struct pci_dev *pci_lock_domain_pdev( - struct domain *, int seg, int bus, int devfn); - --void setup_dom0_pci_devices(struct domain *, void (*)(struct pci_dev *)); -+void setup_dom0_pci_devices(struct domain *, -+ int (*)(u8 devfn, struct pci_dev *)); - void pci_release_devices(struct domain *d); - int pci_add_segment(u16 seg); - const unsigned long *pci_get_ro_map(u16 seg); diff --git a/26326-VT-d-context-map-params.patch b/26326-VT-d-context-map-params.patch deleted file mode 100644 index b466a03..0000000 --- a/26326-VT-d-context-map-params.patch +++ /dev/null @@ -1,193 +0,0 @@ -References: bnc#787169 - -# HG changeset patch -# User Jan Beulich -# Date 1357559549 -3600 -# Node ID afb598bd0f5436bea15b7ef842e8ad5c6adefa1a -# Parent 75cc4943b1ff509c4074800a23ff51d773233b8a -VT-d: adjust context map/unmap parameters - -... to use a (struct pci_dev *, devfn) pair. - -Signed-off-by: Jan Beulich -Acked-by: "Zhang, Xiantao" - -Index: xen-4.2.2-testing/xen/drivers/passthrough/vtd/extern.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/vtd/extern.h -+++ xen-4.2.2-testing/xen/drivers/passthrough/vtd/extern.h -@@ -95,7 +95,7 @@ void free_pgtable_maddr(u64 maddr); - void *map_vtd_domain_page(u64 maddr); - void unmap_vtd_domain_page(void *va); - int domain_context_mapping_one(struct domain *domain, struct iommu *iommu, -- u8 bus, u8 devfn); -+ u8 bus, u8 devfn, const struct pci_dev *); - int domain_context_unmap_one(struct domain *domain, struct iommu *iommu, - u8 bus, u8 devfn); - -Index: xen-4.2.2-testing/xen/drivers/passthrough/vtd/iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/vtd/iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/vtd/iommu.c -@@ -1308,7 +1308,7 @@ static void __init intel_iommu_dom0_init - int domain_context_mapping_one( - struct domain *domain, - struct iommu *iommu, -- u8 bus, u8 devfn) -+ u8 bus, u8 devfn, const struct pci_dev *pdev) - { - struct hvm_iommu *hd = domain_hvm_iommu(domain); - struct context_entry *context, *context_entries; -@@ -1325,11 +1325,9 @@ int domain_context_mapping_one( - if ( context_present(*context) ) - { - int res = 0; -- struct pci_dev *pdev = NULL; - -- /* First try to get domain ownership from device structure. If that's -+ /* Try to get domain ownership from device structure. If that's - * not available, try to read it from the context itself. */ -- pdev = pci_get_pdev(seg, bus, devfn); - if ( pdev ) - { - if ( pdev->domain != domain ) -@@ -1448,13 +1446,12 @@ int domain_context_mapping_one( - } - - static int domain_context_mapping( -- struct domain *domain, u16 seg, u8 bus, u8 devfn) -+ struct domain *domain, u8 devfn, const struct pci_dev *pdev) - { - struct acpi_drhd_unit *drhd; - int ret = 0; - u32 type; -- u8 secbus; -- struct pci_dev *pdev = pci_get_pdev(seg, bus, devfn); -+ u8 seg = pdev->seg, bus = pdev->bus, secbus; - - drhd = acpi_find_matched_drhd_unit(pdev); - if ( !drhd ) -@@ -1475,8 +1472,9 @@ static int domain_context_mapping( - dprintk(VTDPREFIX, "d%d:PCIe: map %04x:%02x:%02x.%u\n", - domain->domain_id, seg, bus, - PCI_SLOT(devfn), PCI_FUNC(devfn)); -- ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn); -- if ( !ret && ats_device(pdev, drhd) > 0 ) -+ ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn, -+ pdev); -+ if ( !ret && devfn == pdev->devfn && ats_device(pdev, drhd) > 0 ) - enable_ats_device(seg, bus, devfn); - - break; -@@ -1487,14 +1485,16 @@ static int domain_context_mapping( - domain->domain_id, seg, bus, - PCI_SLOT(devfn), PCI_FUNC(devfn)); - -- ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn); -+ ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn, -+ pdev); - if ( ret ) - break; - - if ( find_upstream_bridge(seg, &bus, &devfn, &secbus) < 1 ) - break; - -- ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn); -+ ret = domain_context_mapping_one(domain, drhd->iommu, bus, devfn, -+ pci_get_pdev(seg, bus, devfn)); - - /* - * Devices behind PCIe-to-PCI/PCIx bridge may generate different -@@ -1503,7 +1503,8 @@ static int domain_context_mapping( - */ - if ( !ret && pdev_type(seg, bus, devfn) == DEV_TYPE_PCIe2PCI_BRIDGE && - (secbus != pdev->bus || pdev->devfn != 0) ) -- ret = domain_context_mapping_one(domain, drhd->iommu, secbus, 0); -+ ret = domain_context_mapping_one(domain, drhd->iommu, secbus, 0, -+ pci_get_pdev(seg, secbus, 0)); - - break; - -@@ -1576,18 +1577,15 @@ int domain_context_unmap_one( - } - - static int domain_context_unmap( -- struct domain *domain, u16 seg, u8 bus, u8 devfn) -+ struct domain *domain, u8 devfn, const struct pci_dev *pdev) - { - struct acpi_drhd_unit *drhd; - struct iommu *iommu; - int ret = 0; - u32 type; -- u8 tmp_bus, tmp_devfn, secbus; -- struct pci_dev *pdev = pci_get_pdev(seg, bus, devfn); -+ u8 seg = pdev->seg, bus = pdev->bus, tmp_bus, tmp_devfn, secbus; - int found = 0; - -- BUG_ON(!pdev); -- - drhd = acpi_find_matched_drhd_unit(pdev); - if ( !drhd ) - return -ENODEV; -@@ -1607,7 +1605,7 @@ static int domain_context_unmap( - domain->domain_id, seg, bus, - PCI_SLOT(devfn), PCI_FUNC(devfn)); - ret = domain_context_unmap_one(domain, iommu, bus, devfn); -- if ( !ret && ats_device(pdev, drhd) > 0 ) -+ if ( !ret && devfn == pdev->devfn && ats_device(pdev, drhd) > 0 ) - disable_ats_device(seg, bus, devfn); - - break; -@@ -1701,11 +1699,11 @@ static int reassign_device_ownership( - if ( (target != dom0) && !iommu_intremap ) - untrusted_msi = 1; - -- ret = domain_context_unmap(source, pdev->seg, pdev->bus, devfn); -+ ret = domain_context_unmap(source, devfn, pdev); - if ( ret ) - return ret; - -- ret = domain_context_mapping(target, pdev->seg, pdev->bus, devfn); -+ ret = domain_context_mapping(target, devfn, pdev); - if ( ret ) - return ret; - -@@ -1915,7 +1913,7 @@ static int intel_iommu_add_device(u8 dev - if ( !pdev->domain ) - return -EINVAL; - -- ret = domain_context_mapping(pdev->domain, pdev->seg, pdev->bus, devfn); -+ ret = domain_context_mapping(pdev->domain, devfn, pdev); - if ( ret ) - { - dprintk(XENLOG_ERR VTDPREFIX, "d%d: context mapping failed\n", -@@ -1975,14 +1973,14 @@ static int intel_iommu_remove_device(u8 - } - } - -- return domain_context_unmap(pdev->domain, pdev->seg, pdev->bus, devfn); -+ return domain_context_unmap(pdev->domain, devfn, pdev); - } - - static int __init setup_dom0_device(u8 devfn, struct pci_dev *pdev) - { - int err; - -- err = domain_context_mapping(pdev->domain, pdev->seg, pdev->bus, devfn); -+ err = domain_context_mapping(pdev->domain, devfn, pdev); - if ( !err && devfn == pdev->devfn ) - pci_vtd_quirk(pdev); - return err; -Index: xen-4.2.2-testing/xen/drivers/passthrough/vtd/quirks.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/vtd/quirks.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/vtd/quirks.c -@@ -319,7 +319,7 @@ static void map_me_phantom_function(stru - /* map or unmap ME phantom function */ - if ( map ) - domain_context_mapping_one(domain, drhd->iommu, 0, -- PCI_DEVFN(dev, 7)); -+ PCI_DEVFN(dev, 7), NULL); - else - domain_context_unmap_one(domain, drhd->iommu, 0, - PCI_DEVFN(dev, 7)); diff --git a/26327-AMD-IOMMU-flush-params.patch b/26327-AMD-IOMMU-flush-params.patch deleted file mode 100644 index 941b34a..0000000 --- a/26327-AMD-IOMMU-flush-params.patch +++ /dev/null @@ -1,84 +0,0 @@ -References: bnc#787169 - -# HG changeset patch -# User Jan Beulich -# Date 1357559599 -3600 -# Node ID 2a2c63f641ee3bda4ad552eb0b3ea479d37590cc -# Parent afb598bd0f5436bea15b7ef842e8ad5c6adefa1a -AMD IOMMU: adjust flush function parameters - -... to use a (struct pci_dev *, devfn) pair. - -Signed-off-by: Jan Beulich -Acked-by: "Zhang, Xiantao" - ---- a/xen/drivers/passthrough/amd/iommu_cmd.c -+++ b/xen/drivers/passthrough/amd/iommu_cmd.c -@@ -287,12 +287,12 @@ void invalidate_iommu_all(struct amd_iom - send_iommu_command(iommu, cmd); - } - --void amd_iommu_flush_iotlb(struct pci_dev *pdev, -+void amd_iommu_flush_iotlb(u8 devfn, const struct pci_dev *pdev, - uint64_t gaddr, unsigned int order) - { - unsigned long flags; - struct amd_iommu *iommu; -- unsigned int bdf, req_id, queueid, maxpend; -+ unsigned int req_id, queueid, maxpend; - struct pci_ats_dev *ats_pdev; - - if ( !ats_enabled ) -@@ -305,8 +305,8 @@ void amd_iommu_flush_iotlb(struct pci_de - if ( !pci_ats_enabled(ats_pdev->seg, ats_pdev->bus, ats_pdev->devfn) ) - return; - -- bdf = PCI_BDF2(ats_pdev->bus, ats_pdev->devfn); -- iommu = find_iommu_for_device(ats_pdev->seg, bdf); -+ iommu = find_iommu_for_device(ats_pdev->seg, -+ PCI_BDF2(ats_pdev->bus, ats_pdev->devfn)); - - if ( !iommu ) - { -@@ -319,7 +319,7 @@ void amd_iommu_flush_iotlb(struct pci_de - if ( !iommu_has_cap(iommu, PCI_CAP_IOTLB_SHIFT) ) - return; - -- req_id = get_dma_requestor_id(iommu->seg, bdf); -+ req_id = get_dma_requestor_id(iommu->seg, PCI_BDF2(ats_pdev->bus, devfn)); - queueid = req_id; - maxpend = ats_pdev->ats_queue_depth & 0xff; - -@@ -339,7 +339,7 @@ static void amd_iommu_flush_all_iotlbs(s - return; - - for_each_pdev( d, pdev ) -- amd_iommu_flush_iotlb(pdev, gaddr, order); -+ amd_iommu_flush_iotlb(pdev->devfn, pdev, gaddr, order); - } - - /* Flush iommu cache after p2m changes. */ ---- a/xen/drivers/passthrough/amd/pci_amd_iommu.c -+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c -@@ -138,7 +138,7 @@ static void amd_iommu_setup_domain_devic - if ( devfn == pdev->devfn ) - enable_ats_device(iommu->seg, bus, devfn); - -- amd_iommu_flush_iotlb(pdev, INV_IOMMU_ALL_PAGES_ADDRESS, 0); -+ amd_iommu_flush_iotlb(devfn, pdev, INV_IOMMU_ALL_PAGES_ADDRESS, 0); - } - } - ---- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h -+++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h -@@ -78,8 +78,8 @@ void iommu_dte_set_guest_cr3(u32 *dte, u - void amd_iommu_flush_all_pages(struct domain *d); - void amd_iommu_flush_pages(struct domain *d, unsigned long gfn, - unsigned int order); --void amd_iommu_flush_iotlb(struct pci_dev *pdev, uint64_t gaddr, -- unsigned int order); -+void amd_iommu_flush_iotlb(u8 devfn, const struct pci_dev *pdev, -+ uint64_t gaddr, unsigned int order); - void amd_iommu_flush_device(struct amd_iommu *iommu, uint16_t bdf); - void amd_iommu_flush_intremap(struct amd_iommu *iommu, uint16_t bdf); - void amd_iommu_flush_all_caches(struct amd_iommu *iommu); diff --git a/26328-IOMMU-pdev-type.patch b/26328-IOMMU-pdev-type.patch deleted file mode 100644 index 6f07298..0000000 --- a/26328-IOMMU-pdev-type.patch +++ /dev/null @@ -1,232 +0,0 @@ -References: bnc#787169 - -# HG changeset patch -# User Jan Beulich -# Date 1357559679 -3600 -# Node ID 11fa145c880ee814aaf56a7f47f47ee3e5560c7c -# Parent 2a2c63f641ee3bda4ad552eb0b3ea479d37590cc -IOMMU/PCI: consolidate pdev_type() and cache its result for a given device - -Add an "unknown" device types as well as one for PCI-to-PCIe bridges -(the latter of which other IOMMU code with or without this patch -doesn't appear to handle properly). - -Make sure we don't mistake a device for which we can't access its -config space as a legacy PCI device (after all we in fact don't know -how to deal with such a device, and hence shouldn't try to). - -Signed-off-by: Jan Beulich -Acked-by: "Zhang, Xiantao" - -Index: xen-4.2.2-testing/xen/drivers/passthrough/pci.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/pci.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/pci.c -@@ -144,7 +144,7 @@ static struct pci_dev *alloc_pdev(struct - spin_lock_init(&pdev->msix_table_lock); - - /* update bus2bridge */ -- switch ( pdev_type(pseg->nr, bus, devfn) ) -+ switch ( pdev->type = pdev_type(pseg->nr, bus, devfn) ) - { - u8 sec_bus, sub_bus; - -@@ -184,7 +184,7 @@ static struct pci_dev *alloc_pdev(struct - static void free_pdev(struct pci_seg *pseg, struct pci_dev *pdev) - { - /* update bus2bridge */ -- switch ( pdev_type(pseg->nr, pdev->bus, pdev->devfn) ) -+ switch ( pdev->type ) - { - u8 dev, func, sec_bus, sub_bus; - -@@ -202,6 +202,9 @@ static void free_pdev(struct pci_seg *ps - pseg->bus2bridge[sec_bus] = pseg->bus2bridge[pdev->bus]; - spin_unlock(&pseg->bus2bridge_lock); - break; -+ -+ default: -+ break; - } - - list_del(&pdev->alldevs_list); -@@ -563,20 +566,30 @@ void pci_release_devices(struct domain * - - #define PCI_CLASS_BRIDGE_PCI 0x0604 - --int pdev_type(u16 seg, u8 bus, u8 devfn) -+enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn) - { - u16 class_device, creg; - u8 d = PCI_SLOT(devfn), f = PCI_FUNC(devfn); - int pos = pci_find_cap_offset(seg, bus, d, f, PCI_CAP_ID_EXP); - - class_device = pci_conf_read16(seg, bus, d, f, PCI_CLASS_DEVICE); -- if ( class_device == PCI_CLASS_BRIDGE_PCI ) -+ switch ( class_device ) - { -+ case PCI_CLASS_BRIDGE_PCI: - if ( !pos ) - return DEV_TYPE_LEGACY_PCI_BRIDGE; - creg = pci_conf_read16(seg, bus, d, f, pos + PCI_EXP_FLAGS); -- return ((creg & PCI_EXP_FLAGS_TYPE) >> 4) == PCI_EXP_TYPE_PCI_BRIDGE ? -- DEV_TYPE_PCIe2PCI_BRIDGE : DEV_TYPE_PCIe_BRIDGE; -+ switch ( (creg & PCI_EXP_FLAGS_TYPE) >> 4 ) -+ { -+ case PCI_EXP_TYPE_PCI_BRIDGE: -+ return DEV_TYPE_PCIe2PCI_BRIDGE; -+ case PCI_EXP_TYPE_PCIE_BRIDGE: -+ return DEV_TYPE_PCI2PCIe_BRIDGE; -+ } -+ return DEV_TYPE_PCIe_BRIDGE; -+ -+ case 0x0000: case 0xffff: -+ return DEV_TYPE_PCI_UNKNOWN; - } - - return pos ? DEV_TYPE_PCIe_ENDPOINT : DEV_TYPE_PCI; -Index: xen-4.2.2-testing/xen/drivers/passthrough/vtd/intremap.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/vtd/intremap.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/vtd/intremap.c -@@ -426,7 +426,6 @@ void io_apic_write_remap_rte( - - static void set_msi_source_id(struct pci_dev *pdev, struct iremap_entry *ire) - { -- int type; - u16 seg; - u8 bus, devfn, secbus; - int ret; -@@ -437,8 +436,7 @@ static void set_msi_source_id(struct pci - seg = pdev->seg; - bus = pdev->bus; - devfn = pdev->devfn; -- type = pdev_type(seg, bus, devfn); -- switch ( type ) -+ switch ( pdev->type ) - { - case DEV_TYPE_PCIe_BRIDGE: - case DEV_TYPE_PCIe2PCI_BRIDGE: -@@ -470,7 +468,7 @@ static void set_msi_source_id(struct pci - default: - dprintk(XENLOG_WARNING VTDPREFIX, - "d%d: unknown(%u): %04x:%02x:%02x.%u\n", -- pdev->domain->domain_id, type, -+ pdev->domain->domain_id, pdev->type, - seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); - break; - } -Index: xen-4.2.2-testing/xen/drivers/passthrough/vtd/iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/vtd/iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/vtd/iommu.c -@@ -1450,7 +1450,6 @@ static int domain_context_mapping( - { - struct acpi_drhd_unit *drhd; - int ret = 0; -- u32 type; - u8 seg = pdev->seg, bus = pdev->bus, secbus; - - drhd = acpi_find_matched_drhd_unit(pdev); -@@ -1459,8 +1458,7 @@ static int domain_context_mapping( - - ASSERT(spin_is_locked(&pcidevs_lock)); - -- type = pdev_type(seg, bus, devfn); -- switch ( type ) -+ switch ( pdev->type ) - { - case DEV_TYPE_PCIe_BRIDGE: - case DEV_TYPE_PCIe2PCI_BRIDGE: -@@ -1510,7 +1508,7 @@ static int domain_context_mapping( - - default: - dprintk(XENLOG_ERR VTDPREFIX, "d%d:unknown(%u): %04x:%02x:%02x.%u\n", -- domain->domain_id, type, -+ domain->domain_id, pdev->type, - seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); - ret = -EINVAL; - break; -@@ -1582,7 +1580,6 @@ static int domain_context_unmap( - struct acpi_drhd_unit *drhd; - struct iommu *iommu; - int ret = 0; -- u32 type; - u8 seg = pdev->seg, bus = pdev->bus, tmp_bus, tmp_devfn, secbus; - int found = 0; - -@@ -1591,8 +1588,7 @@ static int domain_context_unmap( - return -ENODEV; - iommu = drhd->iommu; - -- type = pdev_type(seg, bus, devfn); -- switch ( type ) -+ switch ( pdev->type ) - { - case DEV_TYPE_PCIe_BRIDGE: - case DEV_TYPE_PCIe2PCI_BRIDGE: -@@ -1639,7 +1635,7 @@ static int domain_context_unmap( - - default: - dprintk(XENLOG_ERR VTDPREFIX, "d%d:unknown(%u): %04x:%02x:%02x.%u\n", -- domain->domain_id, type, -+ domain->domain_id, pdev->type, - seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); - ret = -EINVAL; - goto out; -Index: xen-4.2.2-testing/xen/include/xen/pci.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/pci.h -+++ xen-4.2.2-testing/xen/include/xen/pci.h -@@ -63,6 +63,17 @@ struct pci_dev { - const u16 seg; - const u8 bus; - const u8 devfn; -+ -+ enum pdev_type { -+ DEV_TYPE_PCI_UNKNOWN, -+ DEV_TYPE_PCIe_ENDPOINT, -+ DEV_TYPE_PCIe_BRIDGE, // PCIe root port, switch -+ DEV_TYPE_PCIe2PCI_BRIDGE, // PCIe-to-PCI/PCIx bridge -+ DEV_TYPE_PCI2PCIe_BRIDGE, // PCI/PCIx-to-PCIe bridge -+ DEV_TYPE_LEGACY_PCI_BRIDGE, // Legacy PCI bridge -+ DEV_TYPE_PCI, -+ } type; -+ - struct pci_dev_info info; - struct arch_pci_dev arch; - struct { -@@ -84,18 +95,10 @@ struct pci_dev { - - extern spinlock_t pcidevs_lock; - --enum { -- DEV_TYPE_PCIe_ENDPOINT, -- DEV_TYPE_PCIe_BRIDGE, // PCIe root port, switch -- DEV_TYPE_PCIe2PCI_BRIDGE, // PCIe-to-PCI/PCIx bridge -- DEV_TYPE_LEGACY_PCI_BRIDGE, // Legacy PCI bridge -- DEV_TYPE_PCI, --}; -- - bool_t pci_known_segment(u16 seg); - int pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func); - int scan_pci_devices(void); --int pdev_type(u16 seg, u8 bus, u8 devfn); -+enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn); - int find_upstream_bridge(u16 seg, u8 *bus, u8 *devfn, u8 *secbus); - struct pci_dev *pci_lock_pdev(int seg, int bus, int devfn); - struct pci_dev *pci_lock_domain_pdev( -Index: xen-4.2.2-testing/xen/include/xen/pci_regs.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/pci_regs.h -+++ xen-4.2.2-testing/xen/include/xen/pci_regs.h -@@ -371,6 +371,9 @@ - #define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ - #define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ - #define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ -+#define PCI_EXP_TYPE_PCIE_BRIDGE 0x8 /* PCI/PCI-X to PCIE Bridge */ -+#define PCI_EXP_TYPE_RC_END 0x9 /* Root Complex Integrated Endpoint */ -+#define PCI_EXP_TYPE_RC_EC 0xa /* Root Complex Event Collector */ - #define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ - #define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ - #define PCI_EXP_DEVCAP 4 /* Device capabilities */ diff --git a/26329-IOMMU-phantom-dev.patch b/26329-IOMMU-phantom-dev.patch deleted file mode 100644 index 569202b..0000000 --- a/26329-IOMMU-phantom-dev.patch +++ /dev/null @@ -1,377 +0,0 @@ -References: bnc#787169 - -# HG changeset patch -# User Jan Beulich -# Date 1357559742 -3600 -# Node ID c9a01b396cb4eaedef30e9a6ed615115a9f8bfc5 -# Parent 11fa145c880ee814aaf56a7f47f47ee3e5560c7c -IOMMU: add phantom function support - -Apart from generating device context entries for the base function, -all phantom functions also need context entries to be generated for -them. - -In order to distinguish different use cases, a variant of -pci_get_pdev() is being introduced that, even when passed a phantom -function number, would return the underlying actual device. - -Signed-off-by: Jan Beulich -Acked-by: "Zhang, Xiantao" - -Index: xen-4.2.2-testing/xen/drivers/passthrough/amd/iommu_cmd.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/amd/iommu_cmd.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/amd/iommu_cmd.c -@@ -339,7 +339,15 @@ static void amd_iommu_flush_all_iotlbs(s - return; - - for_each_pdev( d, pdev ) -- amd_iommu_flush_iotlb(pdev->devfn, pdev, gaddr, order); -+ { -+ u8 devfn = pdev->devfn; -+ -+ do { -+ amd_iommu_flush_iotlb(devfn, pdev, gaddr, order); -+ devfn += pdev->phantom_stride; -+ } while ( devfn != pdev->devfn && -+ PCI_SLOT(devfn) == PCI_SLOT(pdev->devfn) ); -+ } - } - - /* Flush iommu cache after p2m changes. */ -Index: xen-4.2.2-testing/xen/drivers/passthrough/amd/iommu_init.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/amd/iommu_init.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/amd/iommu_init.c -@@ -692,7 +692,7 @@ void parse_ppr_log_entry(struct amd_iomm - devfn = PCI_DEVFN2(device_id); - - spin_lock(&pcidevs_lock); -- pdev = pci_get_pdev(iommu->seg, bus, devfn); -+ pdev = pci_get_real_pdev(iommu->seg, bus, devfn); - spin_unlock(&pcidevs_lock); - - if ( pdev ) -Index: xen-4.2.2-testing/xen/drivers/passthrough/amd/iommu_map.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/amd/iommu_map.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/amd/iommu_map.c -@@ -612,7 +612,6 @@ static int update_paging_mode(struct dom - for_each_pdev( d, pdev ) - { - bdf = (pdev->bus << 8) | pdev->devfn; -- req_id = get_dma_requestor_id(pdev->seg, bdf); - iommu = find_iommu_for_device(pdev->seg, bdf); - if ( !iommu ) - { -@@ -621,16 +620,21 @@ static int update_paging_mode(struct dom - } - - spin_lock_irqsave(&iommu->lock, flags); -- device_entry = iommu->dev_table.buffer + -- (req_id * IOMMU_DEV_TABLE_ENTRY_SIZE); -+ do { -+ req_id = get_dma_requestor_id(pdev->seg, bdf); -+ device_entry = iommu->dev_table.buffer + -+ (req_id * IOMMU_DEV_TABLE_ENTRY_SIZE); - -- /* valid = 0 only works for dom0 passthrough mode */ -- amd_iommu_set_root_page_table((u32 *)device_entry, -- page_to_maddr(hd->root_table), -- hd->domain_id, -- hd->paging_mode, 1); -+ /* valid = 0 only works for dom0 passthrough mode */ -+ amd_iommu_set_root_page_table((u32 *)device_entry, -+ page_to_maddr(hd->root_table), -+ hd->domain_id, -+ hd->paging_mode, 1); - -- amd_iommu_flush_device(iommu, req_id); -+ amd_iommu_flush_device(iommu, req_id); -+ bdf += pdev->phantom_stride; -+ } while ( PCI_DEVFN2(bdf) != pdev->devfn && -+ PCI_SLOT(bdf) == PCI_SLOT(pdev->devfn) ); - spin_unlock_irqrestore(&iommu->lock, flags); - } - -Index: xen-4.2.2-testing/xen/drivers/passthrough/iommu.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/iommu.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/iommu.c -@@ -157,6 +157,8 @@ void __init iommu_dom0_init(struct domai - int iommu_add_device(struct pci_dev *pdev) - { - struct hvm_iommu *hd; -+ int rc; -+ u8 devfn; - - if ( !pdev->domain ) - return -EINVAL; -@@ -167,7 +169,20 @@ int iommu_add_device(struct pci_dev *pde - if ( !iommu_enabled || !hd->platform_ops ) - return 0; - -- return hd->platform_ops->add_device(pdev->devfn, pdev); -+ rc = hd->platform_ops->add_device(pdev->devfn, pdev); -+ if ( rc || !pdev->phantom_stride ) -+ return rc; -+ -+ for ( devfn = pdev->devfn ; ; ) -+ { -+ devfn += pdev->phantom_stride; -+ if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) -+ return 0; -+ rc = hd->platform_ops->add_device(devfn, pdev); -+ if ( rc ) -+ printk(XENLOG_WARNING "IOMMU: add %04x:%02x:%02x.%u failed (%d)\n", -+ pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), rc); -+ } - } - - int iommu_enable_device(struct pci_dev *pdev) -@@ -190,6 +205,8 @@ int iommu_enable_device(struct pci_dev * - int iommu_remove_device(struct pci_dev *pdev) - { - struct hvm_iommu *hd; -+ u8 devfn; -+ - if ( !pdev->domain ) - return -EINVAL; - -@@ -197,6 +214,22 @@ int iommu_remove_device(struct pci_dev * - if ( !iommu_enabled || !hd->platform_ops ) - return 0; - -+ for ( devfn = pdev->devfn ; pdev->phantom_stride; ) -+ { -+ int rc; -+ -+ devfn += pdev->phantom_stride; -+ if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) -+ break; -+ rc = hd->platform_ops->remove_device(devfn, pdev); -+ if ( !rc ) -+ continue; -+ -+ printk(XENLOG_ERR "IOMMU: remove %04x:%02x:%02x.%u failed (%d)\n", -+ pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), rc); -+ return rc; -+ } -+ - return hd->platform_ops->remove_device(pdev->devfn, pdev); - } - -@@ -244,6 +277,18 @@ static int assign_device(struct domain * - if ( (rc = hd->platform_ops->assign_device(d, devfn, pdev)) ) - goto done; - -+ for ( ; pdev->phantom_stride; rc = 0 ) -+ { -+ devfn += pdev->phantom_stride; -+ if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) -+ break; -+ rc = hd->platform_ops->assign_device(d, devfn, pdev); -+ if ( rc ) -+ printk(XENLOG_G_WARNING "d%d: assign %04x:%02x:%02x.%u failed (%d)\n", -+ d->domain_id, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -+ rc); -+ } -+ - if ( has_arch_pdevs(d) && !need_iommu(d) ) - { - d->need_iommu = 1; -@@ -376,6 +421,21 @@ int deassign_device(struct domain *d, u1 - if ( !pdev ) - return -ENODEV; - -+ while ( pdev->phantom_stride ) -+ { -+ devfn += pdev->phantom_stride; -+ if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) -+ break; -+ ret = hd->platform_ops->reassign_device(d, dom0, devfn, pdev); -+ if ( !ret ) -+ continue; -+ -+ printk(XENLOG_G_ERR "d%d: deassign %04x:%02x:%02x.%u failed (%d)\n", -+ d->domain_id, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), ret); -+ return ret; -+ } -+ -+ devfn = pdev->devfn; - ret = hd->platform_ops->reassign_device(d, dom0, devfn, pdev); - if ( ret ) - { -Index: xen-4.2.2-testing/xen/drivers/passthrough/pci.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/pci.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/pci.c -@@ -146,6 +146,8 @@ static struct pci_dev *alloc_pdev(struct - /* update bus2bridge */ - switch ( pdev->type = pdev_type(pseg->nr, bus, devfn) ) - { -+ int pos; -+ u16 cap; - u8 sec_bus, sub_bus; - - case DEV_TYPE_PCIe_BRIDGE: -@@ -169,6 +171,20 @@ static struct pci_dev *alloc_pdev(struct - break; - - case DEV_TYPE_PCIe_ENDPOINT: -+ pos = pci_find_cap_offset(pseg->nr, bus, PCI_SLOT(devfn), -+ PCI_FUNC(devfn), PCI_CAP_ID_EXP); -+ BUG_ON(!pos); -+ cap = pci_conf_read16(pseg->nr, bus, PCI_SLOT(devfn), -+ PCI_FUNC(devfn), pos + PCI_EXP_DEVCAP); -+ if ( cap & PCI_EXP_DEVCAP_PHANTOM ) -+ { -+ pdev->phantom_stride = 8 >> MASK_EXTR(cap, -+ PCI_EXP_DEVCAP_PHANTOM); -+ if ( PCI_FUNC(devfn) >= pdev->phantom_stride ) -+ pdev->phantom_stride = 0; -+ } -+ break; -+ - case DEV_TYPE_PCI: - break; - -@@ -266,6 +282,27 @@ struct pci_dev *pci_get_pdev(int seg, in - return NULL; - } - -+struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn) -+{ -+ struct pci_dev *pdev; -+ int stride; -+ -+ if ( seg < 0 || bus < 0 || devfn < 0 ) -+ return NULL; -+ -+ for ( pdev = pci_get_pdev(seg, bus, devfn), stride = 4; -+ !pdev && stride; stride >>= 1 ) -+ { -+ if ( !(devfn & (8 - stride)) ) -+ continue; -+ pdev = pci_get_pdev(seg, bus, devfn & ~(8 - stride)); -+ if ( pdev && stride != pdev->phantom_stride ) -+ pdev = NULL; -+ } -+ -+ return pdev; -+} -+ - struct pci_dev *pci_get_pdev_by_domain( - struct domain *d, int seg, int bus, int devfn) - { -@@ -464,8 +501,19 @@ int pci_add_device(u16 seg, u8 bus, u8 d - - out: - spin_unlock(&pcidevs_lock); -- printk(XENLOG_DEBUG "PCI add %s %04x:%02x:%02x.%u\n", pdev_type, -- seg, bus, slot, func); -+ if ( !ret ) -+ { -+ printk(XENLOG_DEBUG "PCI add %s %04x:%02x:%02x.%u\n", pdev_type, -+ seg, bus, slot, func); -+ while ( pdev->phantom_stride ) -+ { -+ func += pdev->phantom_stride; -+ if ( PCI_SLOT(func) ) -+ break; -+ printk(XENLOG_DEBUG "PCI phantom %04x:%02x:%02x.%u\n", -+ seg, bus, slot, func); -+ } -+ } - return ret; - } - -@@ -657,7 +705,7 @@ void pci_check_disable_device(u16 seg, u - u16 cword; - - spin_lock(&pcidevs_lock); -- pdev = pci_get_pdev(seg, bus, devfn); -+ pdev = pci_get_real_pdev(seg, bus, devfn); - if ( pdev ) - { - if ( now < pdev->fault.time || -@@ -674,6 +722,7 @@ void pci_check_disable_device(u16 seg, u - - /* Tell the device to stop DMAing; we can't rely on the guest to - * control it for us. */ -+ devfn = pdev->devfn; - cword = pci_conf_read16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), - PCI_COMMAND); - pci_conf_write16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -@@ -731,6 +780,27 @@ struct setup_dom0 { - int (*handler)(u8 devfn, struct pci_dev *); - }; - -+static void setup_one_dom0_device(const struct setup_dom0 *ctxt, -+ struct pci_dev *pdev) -+{ -+ u8 devfn = pdev->devfn; -+ -+ do { -+ int err = ctxt->handler(devfn, pdev); -+ -+ if ( err ) -+ { -+ printk(XENLOG_ERR "setup %04x:%02x:%02x.%u for d%d failed (%d)\n", -+ pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), -+ ctxt->d->domain_id, err); -+ if ( devfn == pdev->devfn ) -+ return; -+ } -+ devfn += pdev->phantom_stride; -+ } while ( devfn != pdev->devfn && -+ PCI_SLOT(devfn) == PCI_SLOT(pdev->devfn) ); -+} -+ - static int __init _setup_dom0_pci_devices(struct pci_seg *pseg, void *arg) - { - struct setup_dom0 *ctxt = arg; -@@ -747,7 +817,7 @@ static int __init _setup_dom0_pci_device - - pdev->domain = ctxt->d; - list_add(&pdev->domain_list, &ctxt->d->arch.pdev_list); -- ctxt->handler(devfn, pdev); -+ setup_one_dom0_device(ctxt, pdev); - } - } - -Index: xen-4.2.2-testing/xen/include/xen/lib.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/lib.h -+++ xen-4.2.2-testing/xen/include/xen/lib.h -@@ -58,6 +58,9 @@ do { - - #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]) + __must_be_array(x)) - -+#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) -+#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) -+ - #define reserve_bootmem(_p,_l) ((void)0) - - struct domain; -Index: xen-4.2.2-testing/xen/include/xen/pci.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/pci.h -+++ xen-4.2.2-testing/xen/include/xen/pci.h -@@ -64,6 +64,8 @@ struct pci_dev { - const u8 bus; - const u8 devfn; - -+ u8 phantom_stride; -+ - enum pdev_type { - DEV_TYPE_PCI_UNKNOWN, - DEV_TYPE_PCIe_ENDPOINT, -@@ -114,6 +116,7 @@ int pci_remove_device(u16 seg, u8 bus, u - int pci_ro_device(int seg, int bus, int devfn); - void arch_pci_ro_device(int seg, int bdf); - struct pci_dev *pci_get_pdev(int seg, int bus, int devfn); -+struct pci_dev *pci_get_real_pdev(int seg, int bus, int devfn); - struct pci_dev *pci_get_pdev_by_domain( - struct domain *, int seg, int bus, int devfn); - void pci_check_disable_device(u16 seg, u8 bus, u8 devfn); diff --git a/26330-VT-d-phantom-MSI.patch b/26330-VT-d-phantom-MSI.patch deleted file mode 100644 index 05e79bb..0000000 --- a/26330-VT-d-phantom-MSI.patch +++ /dev/null @@ -1,42 +0,0 @@ -References: bnc#787169 - -# HG changeset patch -# User Jan Beulich -# Date 1357559812 -3600 -# Node ID b514b7118958327605e33dd387944832bc8d734a -# Parent c9a01b396cb4eaedef30e9a6ed615115a9f8bfc5 -VT-d: relax source qualifier for MSI of phantom functions - -With ordinary requests allowed to come from phantom functions, the -remapping tables ought to be set up to allow for MSI triggers to come -from other than the "real" device too. - -Signed-off-by: Jan Beulich -Acked-by: "Zhang, Xiantao" - ---- a/xen/drivers/passthrough/vtd/intremap.c -+++ b/xen/drivers/passthrough/vtd/intremap.c -@@ -438,13 +438,22 @@ static void set_msi_source_id(struct pci - devfn = pdev->devfn; - switch ( pdev->type ) - { -+ unsigned int sq; -+ - case DEV_TYPE_PCIe_BRIDGE: - case DEV_TYPE_PCIe2PCI_BRIDGE: - case DEV_TYPE_LEGACY_PCI_BRIDGE: - break; - - case DEV_TYPE_PCIe_ENDPOINT: -- set_ire_sid(ire, SVT_VERIFY_SID_SQ, SQ_ALL_16, PCI_BDF2(bus, devfn)); -+ switch ( pdev->phantom_stride ) -+ { -+ case 1: sq = SQ_13_IGNORE_3; break; -+ case 2: sq = SQ_13_IGNORE_2; break; -+ case 4: sq = SQ_13_IGNORE_1; break; -+ default: sq = SQ_ALL_16; break; -+ } -+ set_ire_sid(ire, SVT_VERIFY_SID_SQ, sq, PCI_BDF2(bus, devfn)); - break; - - case DEV_TYPE_PCI: diff --git a/26331-IOMMU-phantom-dev-quirk.patch b/26331-IOMMU-phantom-dev-quirk.patch deleted file mode 100644 index d46b609..0000000 --- a/26331-IOMMU-phantom-dev-quirk.patch +++ /dev/null @@ -1,112 +0,0 @@ -References: bnc#787169 - -# HG changeset patch -# User Jan Beulich -# Date 1357559889 -3600 -# Node ID 23c4bbc0111dd807561b2c62cbc5798220943a0d -# Parent b514b7118958327605e33dd387944832bc8d734a -IOMMU: add option to specify devices behaving like ones using phantom functions - -At least certain Marvell SATA controllers are known to issue bus master -requests with a non-zero function as origin, despite themselves being -single function devices. - -Signed-off-by: Jan Beulich -Acked-by: "Zhang, Xiantao" - -Index: xen-4.2.2-testing/docs/misc/xen-command-line.markdown -=================================================================== ---- xen-4.2.2-testing.orig/docs/misc/xen-command-line.markdown -+++ xen-4.2.2-testing/docs/misc/xen-command-line.markdown -@@ -679,6 +679,16 @@ Defaults to booting secondary processors - - Default: `on` - -+### pci-phantom -+> `=[:]:,` -+ -+Mark a group of PCI devices as using phantom functions without actually -+advertising so, so the IOMMU can create translation contexts for them. -+ -+All numbers specified must be hexadecimal ones. -+ -+This option can be specified more than once (up to 8 times at present). -+ - ### ple\_gap - > `= ` - -Index: xen-4.2.2-testing/xen/drivers/passthrough/pci.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/drivers/passthrough/pci.c -+++ xen-4.2.2-testing/xen/drivers/passthrough/pci.c -@@ -123,6 +123,49 @@ const unsigned long *pci_get_ro_map(u16 - return pseg ? pseg->ro_map : NULL; - } - -+static struct phantom_dev { -+ u16 seg; -+ u8 bus, slot, stride; -+} phantom_devs[8]; -+static unsigned int nr_phantom_devs; -+ -+static void __init parse_phantom_dev(char *str) { -+ const char *s = str; -+ struct phantom_dev phantom; -+ -+ if ( !s || !*s || nr_phantom_devs >= ARRAY_SIZE(phantom_devs) ) -+ return; -+ -+ phantom.seg = simple_strtol(s, &s, 16); -+ if ( *s != ':' ) -+ return; -+ -+ phantom.bus = simple_strtol(s + 1, &s, 16); -+ if ( *s == ',' ) -+ { -+ phantom.slot = phantom.bus; -+ phantom.bus = phantom.seg; -+ phantom.seg = 0; -+ } -+ else if ( *s == ':' ) -+ phantom.slot = simple_strtol(s + 1, &s, 16); -+ else -+ return; -+ -+ if ( *s != ',' ) -+ return; -+ switch ( phantom.stride = simple_strtol(s + 1, &s, 0) ) -+ { -+ case 1: case 2: case 4: -+ if ( *s ) -+ default: -+ return; -+ } -+ -+ phantom_devs[nr_phantom_devs++] = phantom; -+} -+custom_param("pci-phantom", parse_phantom_dev); -+ - static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn) - { - struct pci_dev *pdev; -@@ -183,6 +226,20 @@ static struct pci_dev *alloc_pdev(struct - if ( PCI_FUNC(devfn) >= pdev->phantom_stride ) - pdev->phantom_stride = 0; - } -+ else -+ { -+ unsigned int i; -+ -+ for ( i = 0; i < nr_phantom_devs; ++i ) -+ if ( phantom_devs[i].seg == pseg->nr && -+ phantom_devs[i].bus == bus && -+ phantom_devs[i].slot == PCI_SLOT(devfn) && -+ phantom_devs[i].stride > PCI_FUNC(devfn) ) -+ { -+ pdev->phantom_stride = phantom_devs[i].stride; -+ break; -+ } -+ } - break; - - case DEV_TYPE_PCI: diff --git a/26341-hvm-firmware-passthrough.patch b/26341-hvm-firmware-passthrough.patch deleted file mode 100644 index 8669b76..0000000 --- a/26341-hvm-firmware-passthrough.patch +++ /dev/null @@ -1,99 +0,0 @@ -fate#313584: pass bios information to XEN HVM guest - -# HG changeset patch -# User Ross Philipson -# Date 1357838188 0 -# Node ID 07bf59a7ce837bd795e2df2f28166cfe41990d3d -# Parent 19fd1237ff0dfa3d97a896d6ed6fbbd33f816a9f -HVM xenstore strings and firmware passthrough header - -Add public HVM definitions header for xenstore strings used in -HVMLOADER. In addition this header describes the use of the firmware -passthrough values set using xenstore. - -Signed-off-by: Ross Philipson -Committed-by: Keir Fraser - -diff -r 19fd1237ff0d -r 07bf59a7ce83 xen/include/public/hvm/hvm_xs_strings.h ---- /dev/null Thu Jan 01 00:00:00 1970 +0000 -+++ b/xen/include/public/hvm/hvm_xs_strings.h Thu Jan 10 17:16:28 2013 +0000 -@@ -0,0 +1,79 @@ -+/****************************************************************************** -+ * hvm/hvm_xs_strings.h -+ * -+ * HVM xenstore strings used in HVMLOADER. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a copy -+ * of this software and associated documentation files (the "Software"), to -+ * deal in the Software without restriction, including without limitation the -+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -+ * sell copies of the Software, and to permit persons to whom the Software is -+ * furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included in -+ * all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -+ * DEALINGS IN THE SOFTWARE. -+ */ -+ -+#ifndef __XEN_PUBLIC_HVM_HVM_XS_STRINGS_H__ -+#define __XEN_PUBLIC_HVM_HVM_XS_STRINGS_H__ -+ -+#define HVM_XS_HVMLOADER "hvmloader" -+#define HVM_XS_BIOS "hvmloader/bios" -+#define HVM_XS_GENERATION_ID_ADDRESS "hvmloader/generation-id-address" -+ -+/* The following values allow additional ACPI tables to be added to the -+ * virtual ACPI BIOS that hvmloader constructs. The values specify the guest -+ * physical address and length of a block of ACPI tables to add. The format of -+ * the block is simply concatenated raw tables (which specify their own length -+ * in the ACPI header). -+ */ -+#define HVM_XS_ACPI_PT_ADDRESS "hvmloader/acpi/address" -+#define HVM_XS_ACPI_PT_LENGTH "hvmloader/acpi/length" -+ -+/* Any number of SMBIOS types can be passed through to an HVM guest using -+ * the following xenstore values. The values specify the guest physical -+ * address and length of a block of SMBIOS structures for hvmloader to use. -+ * The block is formatted in the following way: -+ * -+ * ... -+ * -+ * Each length separator is a 32b integer indicating the length of the next -+ * SMBIOS structure. For DMTF defined types (0 - 121), the passed in struct -+ * will replace the default structure in hvmloader. In addition, any -+ * OEM/vendortypes (128 - 255) will all be added. -+ */ -+#define HVM_XS_SMBIOS_PT_ADDRESS "hvmloader/smbios/address" -+#define HVM_XS_SMBIOS_PT_LENGTH "hvmloader/smbios/length" -+ -+/* Set to 1 to enable SMBIOS default portable battery (type 22) values. */ -+#define HVM_XS_SMBIOS_DEFAULT_BATTERY "hvmloader/smbios/default_battery" -+ -+/* The following xenstore values are used to override some of the default -+ * string values in the SMBIOS table constructed in hvmloader. -+ */ -+#define HVM_XS_BIOS_STRINGS "bios-strings" -+#define HVM_XS_BIOS_VENDOR "bios-strings/bios-vendor" -+#define HVM_XS_BIOS_VERSION "bios-strings/bios-version" -+#define HVM_XS_SYSTEM_MANUFACTURER "bios-strings/system-manufacturer" -+#define HVM_XS_SYSTEM_PRODUCT_NAME "bios-strings/system-product-name" -+#define HVM_XS_SYSTEM_VERSION "bios-strings/system-version" -+#define HVM_XS_SYSTEM_SERIAL_NUMBER "bios-strings/system-serial-number" -+#define HVM_XS_ENCLOSURE_MANUFACTURER "bios-strings/enclosure-manufacturer" -+#define HVM_XS_ENCLOSURE_SERIAL_NUMBER "bios-strings/enclosure-serial-number" -+#define HVM_XS_BATTERY_MANUFACTURER "bios-strings/battery-manufacturer" -+#define HVM_XS_BATTERY_DEVICE_NAME "bios-strings/battery-device-name" -+ -+/* 1 to 99 OEM strings can be set in xenstore using values of the form -+ * below. These strings will be loaded into the SMBIOS type 11 structure. -+ */ -+#define HVM_XS_OEM_STRINGS "bios-strings/oem-%02d" -+ -+#endif /* __XEN_PUBLIC_HVM_HVM_XS_STRINGS_H__ */ diff --git a/26342-hvm-firmware-passthrough.patch b/26342-hvm-firmware-passthrough.patch deleted file mode 100644 index 2297749..0000000 --- a/26342-hvm-firmware-passthrough.patch +++ /dev/null @@ -1,282 +0,0 @@ -fate#313584: pass bios information to XEN HVM guest - -# HG changeset patch -# User Ross Philipson -# Date 1357838241 0 -# Node ID cabf395a6c849cc65e56f1640b18db0c3e0faf5d -# Parent 07bf59a7ce837bd795e2df2f28166cfe41990d3d -HVM firmware passthrough control tools support - -Xen control tools support for loading the firmware passthrough blocks -during domain construction. SMBIOS and ACPI blocks are passed in using -the new xc_hvm_build_args structure. Each block is read and loaded -into the new domain address space behind the HVMLOADER image. The base -address for the two blocks is returned as an out parameter to the -caller via the args structure. - -Signed-off-by: Ross Philipson -Committed-by: Keir Fraser - -diff -r 07bf59a7ce83 -r cabf395a6c84 tools/libxc/xc_hvm_build_arm.c ---- a/tools/libxc/xc_hvm_build_arm.c Thu Jan 10 17:16:28 2013 +0000 -+++ b/tools/libxc/xc_hvm_build_arm.c Thu Jan 10 17:17:21 2013 +0000 -@@ -22,7 +22,7 @@ - #include - - int xc_hvm_build(xc_interface *xch, uint32_t domid, -- const struct xc_hvm_build_args *hvm_args) -+ struct xc_hvm_build_args *hvm_args) - { - errno = ENOSYS; - return -1; -diff -r 07bf59a7ce83 -r cabf395a6c84 tools/libxc/xc_hvm_build_x86.c ---- a/tools/libxc/xc_hvm_build_x86.c Thu Jan 10 17:16:28 2013 +0000 -+++ b/tools/libxc/xc_hvm_build_x86.c Thu Jan 10 17:17:21 2013 +0000 -@@ -49,6 +49,40 @@ - #define NR_SPECIAL_PAGES 8 - #define special_pfn(x) (0xff000u - NR_SPECIAL_PAGES + (x)) - -+static int modules_init(struct xc_hvm_build_args *args, -+ uint64_t vend, struct elf_binary *elf, -+ uint64_t *mstart_out, uint64_t *mend_out) -+{ -+#define MODULE_ALIGN 1UL << 7 -+#define MB_ALIGN 1UL << 20 -+#define MKALIGN(x, a) (((uint64_t)(x) + (a) - 1) & ~(uint64_t)((a) - 1)) -+ uint64_t total_len = 0, offset1 = 0; -+ -+ if ( (args->acpi_module.length == 0)&&(args->smbios_module.length == 0) ) -+ return 0; -+ -+ /* Find the total length for the firmware modules with a reasonable large -+ * alignment size to align each the modules. -+ */ -+ total_len = MKALIGN(args->acpi_module.length, MODULE_ALIGN); -+ offset1 = total_len; -+ total_len += MKALIGN(args->smbios_module.length, MODULE_ALIGN); -+ -+ /* Want to place the modules 1Mb+change behind the loader image. */ -+ *mstart_out = MKALIGN(elf->pend, MB_ALIGN) + (MB_ALIGN); -+ *mend_out = *mstart_out + total_len; -+ -+ if ( *mend_out > vend ) -+ return -1; -+ -+ if ( args->acpi_module.length != 0 ) -+ args->acpi_module.guest_addr_out = *mstart_out; -+ if ( args->smbios_module.length != 0 ) -+ args->smbios_module.guest_addr_out = *mstart_out + offset1; -+ -+ return 0; -+} -+ - static void build_hvm_info(void *hvm_info_page, uint64_t mem_size, - uint64_t mmio_start, uint64_t mmio_size) - { -@@ -86,9 +120,8 @@ static void build_hvm_info(void *hvm_inf - hvm_info->checksum = -sum; - } - --static int loadelfimage( -- xc_interface *xch, -- struct elf_binary *elf, uint32_t dom, unsigned long *parray) -+static int loadelfimage(xc_interface *xch, struct elf_binary *elf, -+ uint32_t dom, unsigned long *parray) - { - privcmd_mmap_entry_t *entries = NULL; - unsigned long pfn_start = elf->pstart >> PAGE_SHIFT; -@@ -126,6 +159,66 @@ static int loadelfimage( - return rc; - } - -+static int loadmodules(xc_interface *xch, -+ struct xc_hvm_build_args *args, -+ uint64_t mstart, uint64_t mend, -+ uint32_t dom, unsigned long *parray) -+{ -+ privcmd_mmap_entry_t *entries = NULL; -+ unsigned long pfn_start; -+ unsigned long pfn_end; -+ size_t pages; -+ uint32_t i; -+ uint8_t *dest; -+ int rc = -1; -+ -+ if ( (mstart == 0)||(mend == 0) ) -+ return 0; -+ -+ pfn_start = (unsigned long)(mstart >> PAGE_SHIFT); -+ pfn_end = (unsigned long)((mend + PAGE_SIZE - 1) >> PAGE_SHIFT); -+ pages = pfn_end - pfn_start; -+ -+ /* Map address space for module list. */ -+ entries = calloc(pages, sizeof(privcmd_mmap_entry_t)); -+ if ( entries == NULL ) -+ goto error_out; -+ -+ for ( i = 0; i < pages; i++ ) -+ entries[i].mfn = parray[(mstart >> PAGE_SHIFT) + i]; -+ -+ dest = xc_map_foreign_ranges( -+ xch, dom, pages << PAGE_SHIFT, PROT_READ | PROT_WRITE, 1 << PAGE_SHIFT, -+ entries, pages); -+ if ( dest == NULL ) -+ goto error_out; -+ -+ /* Zero the range so padding is clear between modules */ -+ memset(dest, 0, pages << PAGE_SHIFT); -+ -+ /* Load modules into range */ -+ if ( args->acpi_module.length != 0 ) -+ { -+ memcpy(dest, -+ args->acpi_module.data, -+ args->acpi_module.length); -+ } -+ if ( args->smbios_module.length != 0 ) -+ { -+ memcpy(dest + (args->smbios_module.guest_addr_out - mstart), -+ args->smbios_module.data, -+ args->smbios_module.length); -+ } -+ -+ munmap(dest, pages << PAGE_SHIFT); -+ rc = 0; -+ -+ error_out: -+ free(entries); -+ -+ return rc; -+} -+ - /* - * Check whether there exists mmio hole in the specified memory range. - * Returns 1 if exists, else returns 0. -@@ -140,7 +233,7 @@ static int check_mmio_hole(uint64_t star - } - - static int setup_guest(xc_interface *xch, -- uint32_t dom, const struct xc_hvm_build_args *args, -+ uint32_t dom, struct xc_hvm_build_args *args, - char *image, unsigned long image_size) - { - xen_pfn_t *page_array = NULL; -@@ -153,6 +246,7 @@ static int setup_guest(xc_interface *xch - uint32_t *ident_pt; - struct elf_binary elf; - uint64_t v_start, v_end; -+ uint64_t m_start = 0, m_end = 0; - int rc; - xen_capabilities_info_t caps; - unsigned long stat_normal_pages = 0, stat_2mb_pages = 0, -@@ -178,11 +272,19 @@ static int setup_guest(xc_interface *xch - goto error_out; - } - -+ if ( modules_init(args, v_end, &elf, &m_start, &m_end) != 0 ) -+ { -+ ERROR("Insufficient space to load modules."); -+ goto error_out; -+ } -+ - IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n" - " Loader: %016"PRIx64"->%016"PRIx64"\n" -+ " Modules: %016"PRIx64"->%016"PRIx64"\n" - " TOTAL: %016"PRIx64"->%016"PRIx64"\n" - " ENTRY ADDRESS: %016"PRIx64"\n", - elf.pstart, elf.pend, -+ m_start, m_end, - v_start, v_end, - elf_uval(&elf, elf.ehdr, e_entry)); - -@@ -337,6 +439,9 @@ static int setup_guest(xc_interface *xch - if ( loadelfimage(xch, &elf, dom, page_array) != 0 ) - goto error_out; - -+ if ( loadmodules(xch, args, m_start, m_end, dom, page_array) != 0 ) -+ goto error_out; -+ - if ( (hvm_info_page = xc_map_foreign_range( - xch, dom, PAGE_SIZE, PROT_READ | PROT_WRITE, - HVM_INFO_PFN)) == NULL ) -@@ -413,7 +518,7 @@ static int setup_guest(xc_interface *xch - * Create a domain for a virtualized Linux, using files/filenames. - */ - int xc_hvm_build(xc_interface *xch, uint32_t domid, -- const struct xc_hvm_build_args *hvm_args) -+ struct xc_hvm_build_args *hvm_args) - { - struct xc_hvm_build_args args = *hvm_args; - void *image; -@@ -441,6 +546,15 @@ int xc_hvm_build(xc_interface *xch, uint - - sts = setup_guest(xch, domid, &args, image, image_size); - -+ if (!sts) -+ { -+ /* Return module load addresses to caller */ -+ hvm_args->acpi_module.guest_addr_out = -+ args.acpi_module.guest_addr_out; -+ hvm_args->smbios_module.guest_addr_out = -+ args.smbios_module.guest_addr_out; -+ } -+ - free(image); - - return sts; -@@ -461,6 +575,7 @@ int xc_hvm_build_target_mem(xc_interface - { - struct xc_hvm_build_args args = {}; - -+ memset(&args, 0, sizeof(struct xc_hvm_build_args)); - args.mem_size = (uint64_t)memsize << 20; - args.mem_target = (uint64_t)target << 20; - args.image_file_name = image_name; -diff -r 07bf59a7ce83 -r cabf395a6c84 tools/libxc/xenguest.h ---- a/tools/libxc/xenguest.h Thu Jan 10 17:16:28 2013 +0000 -+++ b/tools/libxc/xenguest.h Thu Jan 10 17:17:21 2013 +0000 -@@ -211,11 +211,23 @@ int xc_linux_build_mem(xc_interface *xch - unsigned int console_evtchn, - unsigned long *console_mfn); - -+struct xc_hvm_firmware_module { -+ uint8_t *data; -+ uint32_t length; -+ uint64_t guest_addr_out; -+}; -+ - struct xc_hvm_build_args { - uint64_t mem_size; /* Memory size in bytes. */ - uint64_t mem_target; /* Memory target in bytes. */ - uint64_t mmio_size; /* Size of the MMIO hole in bytes. */ - const char *image_file_name; /* File name of the image to load. */ -+ -+ /* Extra ACPI tables passed to HVMLOADER */ -+ struct xc_hvm_firmware_module acpi_module; -+ -+ /* Extra SMBIOS structures passed to HVMLOADER */ -+ struct xc_hvm_firmware_module smbios_module; - }; - - /** -@@ -228,7 +240,7 @@ struct xc_hvm_build_args { - * are optional. - */ - int xc_hvm_build(xc_interface *xch, uint32_t domid, -- const struct xc_hvm_build_args *hvm_args); -+ struct xc_hvm_build_args *hvm_args); - - int xc_hvm_build_target_mem(xc_interface *xch, - uint32_t domid, -diff -r 07bf59a7ce83 -r cabf395a6c84 tools/libxc/xg_private.c ---- a/tools/libxc/xg_private.c Thu Jan 10 17:16:28 2013 +0000 -+++ b/tools/libxc/xg_private.c Thu Jan 10 17:17:21 2013 +0000 -@@ -192,7 +192,7 @@ unsigned long csum_page(void *page) - __attribute__((weak)) - int xc_hvm_build(xc_interface *xch, - uint32_t domid, -- const struct xc_hvm_build_args *hvm_args) -+ struct xc_hvm_build_args *hvm_args) - { - errno = ENOSYS; - return -1; diff --git a/26343-hvm-firmware-passthrough.patch b/26343-hvm-firmware-passthrough.patch deleted file mode 100644 index c3001cd..0000000 --- a/26343-hvm-firmware-passthrough.patch +++ /dev/null @@ -1,645 +0,0 @@ -fate#313584: pass bios information to XEN HVM guest - -# HG changeset patch -# User Ross Philipson -# Date 1357838290 0 -# Node ID a7ce196f40444fafbe8f13b2d80e4885d4321806 -# Parent cabf395a6c849cc65e56f1640b18db0c3e0faf5d -HVM firmware passthrough SMBIOS processing - -Passthrough support for the SMBIOS structures including three new DMTF -defined types and support for OEM defined tables. Passed in SMBIOS -types override the default internal values. Default values can be -enabled for the new type 22 portable battery using a xenstore -flag. All other new DMTF defined and OEM structures will only be added -to the SMBIOS table if passthrough values are present. - -Signed-off-by: Ross Philipson -Committed-by: Keir Fraser - -diff -r cabf395a6c84 -r a7ce196f4044 tools/firmware/hvmloader/smbios.c ---- a/tools/firmware/hvmloader/smbios.c Thu Jan 10 17:17:21 2013 +0000 -+++ b/tools/firmware/hvmloader/smbios.c Thu Jan 10 17:18:10 2013 +0000 -@@ -26,16 +26,38 @@ - #include "smbios_types.h" - #include "util.h" - #include "hypercall.h" -+#include - -+/* SBMIOS handle base values */ -+#define SMBIOS_HANDLE_TYPE0 0x0000 -+#define SMBIOS_HANDLE_TYPE1 0x0100 -+#define SMBIOS_HANDLE_TYPE2 0x0200 -+#define SMBIOS_HANDLE_TYPE3 0x0300 -+#define SMBIOS_HANDLE_TYPE4 0x0400 -+#define SMBIOS_HANDLE_TYPE11 0x0B00 -+#define SMBIOS_HANDLE_TYPE16 0x1000 -+#define SMBIOS_HANDLE_TYPE17 0x1100 -+#define SMBIOS_HANDLE_TYPE19 0x1300 -+#define SMBIOS_HANDLE_TYPE20 0x1400 -+#define SMBIOS_HANDLE_TYPE22 0x1600 -+#define SMBIOS_HANDLE_TYPE32 0x2000 -+#define SMBIOS_HANDLE_TYPE39 0x2700 -+#define SMBIOS_HANDLE_TYPE127 0x7f00 -+ -+static void -+smbios_pt_init(void); -+static void* -+get_smbios_pt_struct(uint8_t type, uint32_t *length_out); -+static void -+get_cpu_manufacturer(char *buf, int len); - static int - write_smbios_tables(void *ep, void *start, - uint32_t vcpus, uint64_t memsize, - uint8_t uuid[16], char *xen_version, - uint32_t xen_major_version, uint32_t xen_minor_version, - unsigned *nr_structs, unsigned *max_struct_size); -- --static void --get_cpu_manufacturer(char *buf, int len); -+static uint64_t -+get_memsize(void); - static void - smbios_entry_point_init(void *start, - uint16_t max_structure_size, -@@ -49,6 +71,8 @@ static void * - smbios_type_1_init(void *start, const char *xen_version, - uint8_t uuid[16]); - static void * -+smbios_type_2_init(void *start); -+static void * - smbios_type_3_init(void *start); - static void * - smbios_type_4_init(void *start, unsigned int cpu_number, -@@ -64,10 +88,73 @@ smbios_type_19_init(void *start, uint32_ - static void * - smbios_type_20_init(void *start, uint32_t memory_size_mb, int instance); - static void * -+smbios_type_22_init(void *start); -+static void * - smbios_type_32_init(void *start); - static void * -+smbios_type_39_init(void *start); -+static void * -+smbios_type_vendor_oem_init(void *start); -+static void * - smbios_type_127_init(void *start); - -+static uint32_t *smbios_pt_addr = NULL; -+static uint32_t smbios_pt_length = 0; -+ -+static void -+smbios_pt_init(void) -+{ -+ const char *s; -+ -+ s = xenstore_read(HVM_XS_SMBIOS_PT_ADDRESS, NULL); -+ if ( s == NULL ) -+ goto reset; -+ -+ smbios_pt_addr = (uint32_t*)(uint32_t)strtoll(s, NULL, 0); -+ if ( smbios_pt_addr == NULL ) -+ goto reset; -+ -+ s = xenstore_read(HVM_XS_SMBIOS_PT_LENGTH, NULL); -+ if ( s == NULL ) -+ goto reset; -+ -+ smbios_pt_length = (uint32_t)strtoll(s, NULL, 0); -+ if ( smbios_pt_length == 0 ) -+ goto reset; -+ -+ return; -+ -+reset: -+ smbios_pt_addr = NULL; -+ smbios_pt_length = 0; -+} -+ -+static void* -+get_smbios_pt_struct(uint8_t type, uint32_t *length_out) -+{ -+ uint32_t *sep = smbios_pt_addr; -+ uint32_t total = 0; -+ uint8_t *ptr; -+ -+ if ( sep == NULL ) -+ return NULL; -+ -+ while ( total < smbios_pt_length ) -+ { -+ ptr = (uint8_t*)(sep + 1); -+ if ( ptr[0] == type ) -+ { -+ *length_out = *sep; -+ return ptr; -+ } -+ -+ total += (*sep + sizeof(uint32_t)); -+ sep = (uint32_t*)(ptr + *sep); -+ } -+ -+ return NULL; -+} -+ - static void - get_cpu_manufacturer(char *buf, int len) - { -@@ -97,6 +184,8 @@ write_smbios_tables(void *ep, void *star - char cpu_manufacturer[15]; - int i, nr_mem_devs; - -+ smbios_pt_init(); -+ - get_cpu_manufacturer(cpu_manufacturer, 15); - - p = (char *)start; -@@ -112,6 +201,7 @@ write_smbios_tables(void *ep, void *star - do_struct(smbios_type_0_init(p, xen_version, xen_major_version, - xen_minor_version)); - do_struct(smbios_type_1_init(p, xen_version, uuid)); -+ do_struct(smbios_type_2_init(p)); - do_struct(smbios_type_3_init(p)); - for ( cpu_num = 1; cpu_num <= vcpus; cpu_num++ ) - do_struct(smbios_type_4_init(p, cpu_num, cpu_manufacturer)); -@@ -130,7 +220,10 @@ write_smbios_tables(void *ep, void *star - do_struct(smbios_type_20_init(p, dev_memsize, i)); - } - -+ do_struct(smbios_type_22_init(p)); - do_struct(smbios_type_32_init(p)); -+ do_struct(smbios_type_39_init(p)); -+ do_struct(smbios_type_vendor_oem_init(p)); - do_struct(smbios_type_127_init(p)); - - #undef do_struct -@@ -289,12 +382,22 @@ smbios_type_0_init(void *start, const ch - struct smbios_type_0 *p = (struct smbios_type_0 *)start; - static const char *smbios_release_date = __SMBIOS_DATE__; - const char *s; -+ void *pts; -+ uint32_t length; -+ -+ pts = get_smbios_pt_struct(0, &length); -+ if ( (pts != NULL)&&(length > 0) ) -+ { -+ memcpy(start, pts, length); -+ p->header.handle = SMBIOS_HANDLE_TYPE0; -+ return (start + length); -+ } - - memset(p, 0, sizeof(*p)); - - p->header.type = 0; - p->header.length = sizeof(struct smbios_type_0); -- p->header.handle = 0; -+ p->header.handle = SMBIOS_HANDLE_TYPE0; - - p->vendor_str = 1; - p->version_str = 2; -@@ -315,11 +418,11 @@ smbios_type_0_init(void *start, const ch - p->embedded_controller_minor = 0xff; - - start += sizeof(struct smbios_type_0); -- s = xenstore_read("bios-strings/bios-vendor", "Xen"); -+ s = xenstore_read(HVM_XS_BIOS_VENDOR, "Xen"); - strcpy((char *)start, s); - start += strlen(s) + 1; - -- s = xenstore_read("bios-strings/bios-version", xen_version); -+ s = xenstore_read(HVM_XS_BIOS_VERSION, xen_version); - strcpy((char *)start, s); - start += strlen(s) + 1; - -@@ -338,12 +441,22 @@ smbios_type_1_init(void *start, const ch - char uuid_str[37]; - struct smbios_type_1 *p = (struct smbios_type_1 *)start; - const char *s; -+ void *pts; -+ uint32_t length; -+ -+ pts = get_smbios_pt_struct(1, &length); -+ if ( (pts != NULL)&&(length > 0) ) -+ { -+ memcpy(start, pts, length); -+ p->header.handle = SMBIOS_HANDLE_TYPE1; -+ return (start + length); -+ } - - memset(p, 0, sizeof(*p)); - - p->header.type = 1; - p->header.length = sizeof(struct smbios_type_1); -- p->header.handle = 0x100; -+ p->header.handle = SMBIOS_HANDLE_TYPE1; - - p->manufacturer_str = 1; - p->product_name_str = 2; -@@ -358,20 +471,20 @@ smbios_type_1_init(void *start, const ch - - start += sizeof(struct smbios_type_1); - -- s = xenstore_read("bios-strings/system-manufacturer", "Xen"); -+ s = xenstore_read(HVM_XS_SYSTEM_MANUFACTURER, "Xen"); - strcpy((char *)start, s); - start += strlen(s) + 1; - -- s = xenstore_read("bios-strings/system-product-name", "HVM domU"); -+ s = xenstore_read(HVM_XS_SYSTEM_PRODUCT_NAME, "HVM domU"); - strcpy((char *)start, s); - start += strlen(s) + 1; - -- s = xenstore_read("bios-strings/system-version", xen_version); -+ s = xenstore_read(HVM_XS_SYSTEM_VERSION, xen_version); - strcpy((char *)start, s); - start += strlen(s) + 1; - - uuid_to_string(uuid_str, uuid); -- s = xenstore_read("bios-strings/system-serial-number", uuid_str); -+ s = xenstore_read(HVM_XS_SYSTEM_SERIAL_NUMBER, uuid_str); - strcpy((char *)start, s); - start += strlen(s) + 1; - -@@ -380,17 +493,58 @@ smbios_type_1_init(void *start, const ch - return start+1; - } - -+/* Type 2 -- System Board */ -+static void * -+smbios_type_2_init(void *start) -+{ -+ struct smbios_type_2 *p = (struct smbios_type_2 *)start; -+ uint8_t *ptr; -+ void *pts; -+ uint32_t length; -+ -+ pts = get_smbios_pt_struct(2, &length); -+ if ( (pts != NULL)&&(length > 0) ) -+ { -+ memcpy(start, pts, length); -+ p->header.handle = SMBIOS_HANDLE_TYPE2; -+ -+ /* Set current chassis handle if present */ -+ if ( p->header.length > 13 ) -+ { -+ ptr = ((uint8_t*)start) + 11; -+ if ( *((uint16_t*)ptr) != 0 ) -+ *((uint16_t*)ptr) = SMBIOS_HANDLE_TYPE3; -+ } -+ -+ return (start + length); -+ } -+ -+ /* Only present when passed in */ -+ return start; -+} -+ - /* Type 3 -- System Enclosure */ - static void * - smbios_type_3_init(void *start) - { - struct smbios_type_3 *p = (struct smbios_type_3 *)start; -+ const char *s; -+ void *pts; -+ uint32_t length; -+ -+ pts = get_smbios_pt_struct(3, &length); -+ if ( (pts != NULL)&&(length > 0) ) -+ { -+ memcpy(start, pts, length); -+ p->header.handle = SMBIOS_HANDLE_TYPE3; -+ return (start + length); -+ } - - memset(p, 0, sizeof(*p)); - - p->header.type = 3; - p->header.length = sizeof(struct smbios_type_3); -- p->header.handle = 0x300; -+ p->header.handle = SMBIOS_HANDLE_TYPE3; - - p->manufacturer_str = 1; - p->type = 0x01; /* other */ -@@ -404,8 +558,19 @@ smbios_type_3_init(void *start) - - start += sizeof(struct smbios_type_3); - -- strcpy((char *)start, "Xen"); -- start += strlen("Xen") + 1; -+ s = xenstore_read(HVM_XS_ENCLOSURE_MANUFACTURER, "Xen"); -+ strcpy((char *)start, s); -+ start += strlen(s) + 1; -+ -+ /* No internal defaults for this if the value is not set */ -+ s = xenstore_read(HVM_XS_ENCLOSURE_SERIAL_NUMBER, NULL); -+ if ( (s != NULL)&&(*s != '\0') ) -+ { -+ strcpy((char *)start, s); -+ start += strlen(s) + 1; -+ p->serial_number_str = 2; -+ } -+ - *((uint8_t *)start) = 0; - return start+1; - } -@@ -423,7 +588,7 @@ smbios_type_4_init( - - p->header.type = 4; - p->header.length = sizeof(struct smbios_type_4); -- p->header.handle = 0x400 + cpu_number; -+ p->header.handle = SMBIOS_HANDLE_TYPE4 + cpu_number; - - p->socket_designation_str = 1; - p->processor_type = 0x03; /* CPU */ -@@ -465,13 +630,23 @@ static void * - smbios_type_11_init(void *start) - { - struct smbios_type_11 *p = (struct smbios_type_11 *)start; -- char path[20] = "bios-strings/oem-XX"; -+ char path[20]; - const char *s; - int i; -+ void *pts; -+ uint32_t length; -+ -+ pts = get_smbios_pt_struct(11, &length); -+ if ( (pts != NULL)&&(length > 0) ) -+ { -+ memcpy(start, pts, length); -+ p->header.handle = SMBIOS_HANDLE_TYPE11; -+ return (start + length); -+ } - - p->header.type = 11; - p->header.length = sizeof(struct smbios_type_11); -- p->header.handle = 0xB00; -+ p->header.handle = SMBIOS_HANDLE_TYPE11; - - p->count = 0; - -@@ -480,8 +655,7 @@ smbios_type_11_init(void *start) - /* Pull out as many oem-* strings we find in xenstore */ - for ( i = 1; i < 100; i++ ) - { -- path[(sizeof path) - 3] = '0' + ((i < 10) ? i : i / 10); -- path[(sizeof path) - 2] = (i < 10) ? '\0' : '0' + (i % 10); -+ snprintf(path, sizeof(path), HVM_XS_OEM_STRINGS, i); - if ( ((s = xenstore_read(path, NULL)) == NULL) || (*s == '\0') ) - break; - strcpy((char *)start, s); -@@ -510,7 +684,7 @@ smbios_type_16_init(void *start, uint32_ - memset(p, 0, sizeof(*p)); - - p->header.type = 16; -- p->header.handle = 0x1000; -+ p->header.handle = SMBIOS_HANDLE_TYPE16; - p->header.length = sizeof(struct smbios_type_16); - - p->location = 0x01; /* other */ -@@ -536,7 +710,7 @@ smbios_type_17_init(void *start, uint32_ - - p->header.type = 17; - p->header.length = sizeof(struct smbios_type_17); -- p->header.handle = 0x1100 + instance; -+ p->header.handle = SMBIOS_HANDLE_TYPE17 + instance; - - p->physical_memory_array_handle = 0x1000; - p->total_width = 64; -@@ -571,7 +745,7 @@ smbios_type_19_init(void *start, uint32_ - - p->header.type = 19; - p->header.length = sizeof(struct smbios_type_19); -- p->header.handle = 0x1300 + instance; -+ p->header.handle = SMBIOS_HANDLE_TYPE19 + instance; - - p->starting_address = instance << 24; - p->ending_address = p->starting_address + (memory_size_mb << 10) - 1; -@@ -593,7 +767,7 @@ smbios_type_20_init(void *start, uint32_ - - p->header.type = 20; - p->header.length = sizeof(struct smbios_type_20); -- p->header.handle = 0x1400 + instance; -+ p->header.handle = SMBIOS_HANDLE_TYPE20 + instance; - - p->starting_address = instance << 24; - p->ending_address = p->starting_address + (memory_size_mb << 10) - 1; -@@ -609,6 +783,71 @@ smbios_type_20_init(void *start, uint32_ - return start+2; - } - -+/* Type 22 -- Portable Battery */ -+static void * -+smbios_type_22_init(void *start) -+{ -+ struct smbios_type_22 *p = (struct smbios_type_22 *)start; -+ static const char *smbios_release_date = __SMBIOS_DATE__; -+ const char *s; -+ void *pts; -+ uint32_t length; -+ -+ pts = get_smbios_pt_struct(22, &length); -+ if ( (pts != NULL)&&(length > 0) ) -+ { -+ memcpy(start, pts, length); -+ p->header.handle = SMBIOS_HANDLE_TYPE22; -+ return (start + length); -+ } -+ -+ s = xenstore_read(HVM_XS_SMBIOS_DEFAULT_BATTERY, "0"); -+ if ( strncmp(s, "1", 1) != 0 ) -+ return start; -+ -+ memset(p, 0, sizeof(*p)); -+ -+ p->header.type = 22; -+ p->header.length = sizeof(struct smbios_type_22); -+ p->header.handle = SMBIOS_HANDLE_TYPE22; -+ -+ p->location_str = 1; -+ p->manufacturer_str = 2; -+ p->manufacturer_date_str = 3; -+ p->serial_number_str = 0; -+ p->device_name_str = 4; -+ p->device_chemistry = 0x2; /* unknown */ -+ p->device_capacity = 0; /* unknown */ -+ p->device_voltage = 0; /* unknown */ -+ p->sbds_version_number = 0; -+ p->max_error = 0xff; /* unknown */ -+ p->sbds_serial_number = 0; -+ p->sbds_manufacturer_date = 0; -+ p->sbds_device_chemistry = 0; -+ p->design_capacity_multiplier = 0; -+ p->oem_specific = 0; -+ -+ start += sizeof(struct smbios_type_22); -+ -+ strcpy((char *)start, "Primary"); -+ start += strlen("Primary") + 1; -+ -+ s = xenstore_read(HVM_XS_BATTERY_MANUFACTURER, "Xen"); -+ strcpy((char *)start, s); -+ start += strlen(s) + 1; -+ -+ strcpy((char *)start, smbios_release_date); -+ start += strlen(smbios_release_date) + 1; -+ -+ s = xenstore_read(HVM_XS_BATTERY_DEVICE_NAME, "XEN-VBAT"); -+ strcpy((char *)start, s); -+ start += strlen(s) + 1; -+ -+ *((uint8_t *)start) = 0; -+ -+ return start+1; -+} -+ - /* Type 32 -- System Boot Information */ - static void * - smbios_type_32_init(void *start) -@@ -619,7 +858,7 @@ smbios_type_32_init(void *start) - - p->header.type = 32; - p->header.length = sizeof(struct smbios_type_32); -- p->header.handle = 0x2000; -+ p->header.handle = SMBIOS_HANDLE_TYPE32; - memset(p->reserved, 0, 6); - p->boot_status = 0; /* no errors detected */ - -@@ -628,6 +867,58 @@ smbios_type_32_init(void *start) - return start+2; - } - -+/* Type 39 -- Power Supply */ -+static void * -+smbios_type_39_init(void *start) -+{ -+ struct smbios_type_39 *p = (struct smbios_type_39 *)start; -+ void *pts; -+ uint32_t length; -+ -+ pts = get_smbios_pt_struct(39, &length); -+ if ( (pts != NULL)&&(length > 0) ) -+ { -+ memcpy(start, pts, length); -+ p->header.handle = SMBIOS_HANDLE_TYPE39; -+ return (start + length); -+ } -+ -+ /* Only present when passed in */ -+ return start; -+} -+ -+static void * -+smbios_type_vendor_oem_init(void *start) -+{ -+ uint32_t *sep = smbios_pt_addr; -+ uint32_t total = 0; -+ uint8_t *ptr; -+ -+ if ( sep == NULL ) -+ return start; -+ -+ while ( total < smbios_pt_length ) -+ { -+ ptr = (uint8_t*)(sep + 1); -+ if ( ptr[0] >= 128 ) -+ { -+ /* Vendor/OEM table, copy it in. Note the handle values cannot -+ * be changed since it is unknown what is in each of these tables -+ * but they could contain handle references to other tables. This -+ * means a slight risk of collision with the tables above but that -+ * would have to be dealt with on a case by case basis. -+ */ -+ memcpy(start, ptr, *sep); -+ start += *sep; -+ } -+ -+ total += (*sep + sizeof(uint32_t)); -+ sep = (uint32_t*)(ptr + *sep); -+ } -+ -+ return start; -+} -+ - /* Type 127 -- End of Table */ - static void * - smbios_type_127_init(void *start) -@@ -638,7 +929,7 @@ smbios_type_127_init(void *start) - - p->header.type = 127; - p->header.length = sizeof(struct smbios_type_127); -- p->header.handle = 0x7f00; -+ p->header.handle = SMBIOS_HANDLE_TYPE127; - - start += sizeof(struct smbios_type_127); - *((uint16_t *)start) = 0; -diff -r cabf395a6c84 -r a7ce196f4044 tools/firmware/hvmloader/smbios_types.h ---- a/tools/firmware/hvmloader/smbios_types.h Thu Jan 10 17:17:21 2013 +0000 -+++ b/tools/firmware/hvmloader/smbios_types.h Thu Jan 10 17:18:10 2013 +0000 -@@ -84,6 +84,15 @@ struct smbios_type_1 { - uint8_t family_str; - } __attribute__ ((packed)); - -+/* SMBIOS type 2 - Base Board Information */ -+struct smbios_type_2 { -+ struct smbios_structure_header header; -+ uint8_t manufacturer_str; -+ uint8_t product_name_str; -+ uint8_t version_str; -+ uint8_t serial_number_str; -+} __attribute__ ((packed)); -+ - /* SMBIOS type 3 - System Enclosure */ - struct smbios_type_3 { - struct smbios_structure_header header; -@@ -173,6 +182,26 @@ struct smbios_type_20 { - uint8_t interleaved_data_depth; - } __attribute__ ((packed)); - -+/* SMBIOS type 22 - Portable battery */ -+struct smbios_type_22 { -+ struct smbios_structure_header header; -+ uint8_t location_str; -+ uint8_t manufacturer_str; -+ uint8_t manufacturer_date_str; -+ uint8_t serial_number_str; -+ uint8_t device_name_str; -+ uint8_t device_chemistry; -+ uint16_t device_capacity; -+ uint16_t device_voltage; -+ uint8_t sbds_version_number; -+ uint8_t max_error; -+ uint16_t sbds_serial_number; -+ uint16_t sbds_manufacturer_date; -+ uint8_t sbds_device_chemistry; -+ uint8_t design_capacity_multiplier; -+ uint32_t oem_specific; -+} __attribute__ ((packed)); -+ - /* SMBIOS type 32 - System Boot Information */ - struct smbios_type_32 { - struct smbios_structure_header header; -@@ -180,6 +209,24 @@ struct smbios_type_32 { - uint8_t boot_status; - } __attribute__ ((packed)); - -+/* SMBIOS type 39 - Power Supply */ -+struct smbios_type_39 { -+ struct smbios_structure_header header; -+ uint8_t power_unit_group; -+ uint8_t location_str; -+ uint8_t device_name_str; -+ uint8_t manufacturer_str; -+ uint8_t serial_number_str; -+ uint8_t asset_tag_number_str; -+ uint8_t model_part_number_str; -+ uint8_t revision_level_str; -+ uint16_t max_capacity; -+ uint16_t characteristics; -+ uint16_t input_voltage_probe_handle; -+ uint16_t cooling_device_handle; -+ uint16_t input_current_probe_handle; -+} __attribute__ ((packed)); -+ - /* SMBIOS type 127 -- End-of-table */ - struct smbios_type_127 { - struct smbios_structure_header header; diff --git a/26344-hvm-firmware-passthrough.patch b/26344-hvm-firmware-passthrough.patch deleted file mode 100644 index e4c8a5b..0000000 --- a/26344-hvm-firmware-passthrough.patch +++ /dev/null @@ -1,101 +0,0 @@ -fate#313584: pass bios information to XEN HVM guest - -# HG changeset patch -# User Ross Philipson -# Date 1357838323 0 -# Node ID b9c38bea15b117552ecb51809779c7cfef82dd44 -# Parent a7ce196f40444fafbe8f13b2d80e4885d4321806 -HVM firmware passthrough ACPI processing - -ACPI table passthrough support allowing additional static tables and -SSDTs (AML code) to be loaded. These additional tables are added at -the end of the secondary table list in the RSDT/XSDT tables. - -Signed-off-by: Ross Philipson -Committed-by: Keir Fraser - -diff -r a7ce196f4044 -r b9c38bea15b1 tools/firmware/hvmloader/acpi/build.c ---- a/tools/firmware/hvmloader/acpi/build.c Thu Jan 10 17:18:10 2013 +0000 -+++ b/tools/firmware/hvmloader/acpi/build.c Thu Jan 10 17:18:43 2013 +0000 -@@ -23,6 +23,9 @@ - #include "ssdt_pm.h" - #include "../config.h" - #include "../util.h" -+#include -+ -+#define ACPI_MAX_SECONDARY_TABLES 16 - - #define align16(sz) (((sz) + 15) & ~15) - #define fixed_strcpy(d, s) strncpy((d), (s), sizeof(d)) -@@ -198,6 +201,52 @@ static struct acpi_20_waet *construct_wa - return waet; - } - -+static int construct_passthrough_tables(unsigned long *table_ptrs, -+ int nr_tables) -+{ -+ const char *s; -+ uint8_t *acpi_pt_addr; -+ uint32_t acpi_pt_length; -+ struct acpi_header *header; -+ int nr_added; -+ int nr_max = (ACPI_MAX_SECONDARY_TABLES - nr_tables - 1); -+ uint32_t total = 0; -+ uint8_t *buffer; -+ -+ s = xenstore_read(HVM_XS_ACPI_PT_ADDRESS, NULL); -+ if ( s == NULL ) -+ return 0; -+ -+ acpi_pt_addr = (uint8_t*)(uint32_t)strtoll(s, NULL, 0); -+ if ( acpi_pt_addr == NULL ) -+ return 0; -+ -+ s = xenstore_read(HVM_XS_ACPI_PT_LENGTH, NULL); -+ if ( s == NULL ) -+ return 0; -+ -+ acpi_pt_length = (uint32_t)strtoll(s, NULL, 0); -+ -+ for ( nr_added = 0; nr_added < nr_max; nr_added++ ) -+ { -+ if ( (acpi_pt_length - total) < sizeof(struct acpi_header) ) -+ break; -+ -+ header = (struct acpi_header*)acpi_pt_addr; -+ -+ buffer = mem_alloc(header->length, 16); -+ if ( buffer == NULL ) -+ break; -+ memcpy(buffer, header, header->length); -+ -+ table_ptrs[nr_tables++] = (unsigned long)buffer; -+ total += header->length; -+ acpi_pt_addr += header->length; -+ } -+ -+ return nr_added; -+} -+ - static int construct_secondary_tables(unsigned long *table_ptrs, - struct acpi_info *info) - { -@@ -293,6 +342,9 @@ static int construct_secondary_tables(un - } - } - -+ /* Load any additional tables passed through. */ -+ nr_tables += construct_passthrough_tables(table_ptrs, nr_tables); -+ - table_ptrs[nr_tables] = 0; - return nr_tables; - } -@@ -327,7 +379,7 @@ void acpi_build_tables(struct acpi_confi - struct acpi_10_fadt *fadt_10; - struct acpi_20_facs *facs; - unsigned char *dsdt; -- unsigned long secondary_tables[16]; -+ unsigned long secondary_tables[ACPI_MAX_SECONDARY_TABLES]; - int nr_secondaries, i; - unsigned long vm_gid_addr; - diff --git a/26369-libxl-devid.patch b/26369-libxl-devid.patch deleted file mode 100644 index 329159f..0000000 --- a/26369-libxl-devid.patch +++ /dev/null @@ -1,103 +0,0 @@ -commit 5420f26507fc5c9853eb1076401a8658d72669da -Author: Jim Fehlig -Date: Fri Jan 11 12:22:26 2013 +0000 - - libxl: Set vfb and vkb devid if not done so by the caller - - Other devices set a sensible devid if the caller has not done so. - Do the same for vfb and vkb. While at it, factor out the common code - used to determine a sensible devid, so it can be used by other - libxl__device_*_add functions. - - Signed-off-by: Jim Fehlig - Acked-by: Ian Campbell - Committed-by: Ian Campbell - -Index: xen-4.2.2-testing/tools/libxl/libxl.c -=================================================================== ---- xen-4.2.2-testing.orig/tools/libxl/libxl.c -+++ xen-4.2.2-testing/tools/libxl/libxl.c -@@ -1710,6 +1710,26 @@ out: - return; - } - -+/* common function to get next device id */ -+static int libxl__device_nextid(libxl__gc *gc, uint32_t domid, char *device) -+{ -+ char *dompath, **l; -+ unsigned int nb; -+ int nextid = -1; -+ -+ if (!(dompath = libxl__xs_get_dompath(gc, domid))) -+ return nextid; -+ -+ l = libxl__xs_directory(gc, XBT_NULL, -+ GCSPRINTF("%s/device/%s", dompath, device), &nb); -+ if (l == NULL || nb == 0) -+ nextid = 0; -+ else -+ nextid = strtoul(l[nb - 1], NULL, 10) + 1; -+ -+ return nextid; -+} -+ - /******************************************************************************/ - - int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk) -@@ -2549,8 +2569,7 @@ void libxl__device_nic_add(libxl__egc *e - flexarray_t *front; - flexarray_t *back; - libxl__device *device; -- char *dompath, **l; -- unsigned int nb, rc; -+ unsigned int rc; - - rc = libxl__device_nic_setdefault(gc, nic, domid); - if (rc) goto out; -@@ -2567,17 +2586,10 @@ void libxl__device_nic_add(libxl__egc *e - } - - if (nic->devid == -1) { -- if (!(dompath = libxl__xs_get_dompath(gc, domid))) { -+ if ((nic->devid = libxl__device_nextid(gc, domid, "vif") < 0)) { - rc = ERROR_FAIL; - goto out_free; - } -- if (!(l = libxl__xs_directory(gc, XBT_NULL, -- libxl__sprintf(gc, "%s/device/vif", dompath), &nb)) || -- nb == 0) { -- nic->devid = 0; -- } else { -- nic->devid = strtoul(l[nb - 1], NULL, 10) + 1; -- } - } - - GCNEW(device); -@@ -2964,6 +2976,13 @@ int libxl__device_vkb_add(libxl__gc *gc, - goto out_free; - } - -+ if (vkb->devid == -1) { -+ if ((vkb->devid = libxl__device_nextid(gc, domid, "vkb") < 0)) { -+ rc = ERROR_FAIL; -+ goto out_free; -+ } -+ } -+ - rc = libxl__device_from_vkb(gc, domid, vkb, &device); - if (rc != 0) goto out_free; - -@@ -3065,6 +3084,13 @@ int libxl__device_vfb_add(libxl__gc *gc, - goto out_free; - } - -+ if (vfb->devid == -1) { -+ if ((vfb->devid = libxl__device_nextid(gc, domid, "vfb") < 0)) { -+ rc = ERROR_FAIL; -+ goto out_free; -+ } -+ } -+ - rc = libxl__device_from_vfb(gc, domid, vfb, &device); - if (rc != 0) goto out_free; - diff --git a/26370-libxc-x86-initial-mapping-fit.patch b/26370-libxc-x86-initial-mapping-fit.patch deleted file mode 100644 index e03fc51..0000000 --- a/26370-libxc-x86-initial-mapping-fit.patch +++ /dev/null @@ -1,59 +0,0 @@ -# HG changeset patch -# User Ian Campbell -# Date 1357906947 0 -# Node ID ba2d73234d73fc0faa027cd9bdfd3ac90642733c -# Parent 84d87ca765be81c215ef3b67d2ed71acfba73553 -libxc: x86: ensure that the initial mapping fits into the guest's memory - -In particular we need to check that adding 512KB of slack and -rounding up to a 4MB boundary do not overflow the guest's memory -allocation. Otherwise we run off the end of the p2m when building the -guest's initial page tables and populate them with garbage. - -Wei noticed this when build tiny (2MB) mini-os domains. - -Reported-by: Wei Liu -Signed-off-by: Ian Campbell -Acked-by: Jan Beulich -Committed-by: Ian Campbell - ---- a/tools/libxc/xc_dom_core.c -+++ b/tools/libxc/xc_dom_core.c -@@ -871,7 +871,8 @@ int xc_dom_build_image(struct xc_dom_ima - goto err; - if ( dom->arch_hooks->count_pgtables ) - { -- dom->arch_hooks->count_pgtables(dom); -+ if ( dom->arch_hooks->count_pgtables(dom) != 0 ) -+ goto err; - if ( (dom->pgtables > 0) && - (xc_dom_alloc_segment(dom, &dom->pgtables_seg, "page tables", 0, - dom->pgtables * page_size) != 0) ) ---- a/tools/libxc/xc_dom_x86.c -+++ b/tools/libxc/xc_dom_x86.c -@@ -82,6 +82,7 @@ static int count_pgtables(struct xc_dom_ - { - int pages, extra_pages; - xen_vaddr_t try_virt_end; -+ xen_pfn_t try_pfn_end; - - extra_pages = dom->alloc_bootstack ? 1 : 0; - extra_pages += dom->extra_pages; -@@ -91,6 +92,17 @@ static int count_pgtables(struct xc_dom_ - { - try_virt_end = round_up(dom->virt_alloc_end + pages * PAGE_SIZE_X86, - bits_to_mask(22)); /* 4MB alignment */ -+ -+ try_pfn_end = (try_virt_end - dom->parms.virt_base) >> PAGE_SHIFT_X86; -+ -+ if ( try_pfn_end > dom->total_pages ) -+ { -+ xc_dom_panic(dom->xch, XC_OUT_OF_MEMORY, -+ "%s: not enough memory for initial mapping (%#"PRIpfn" > %#"PRIpfn")", -+ __FUNCTION__, try_pfn_end, dom->total_pages); -+ return -ENOMEM; -+ } -+ - dom->pg_l4 = - nr_page_tables(dom, dom->parms.virt_base, try_virt_end, l4_bits); - dom->pg_l3 = diff --git a/26372-tools-paths.patch b/26372-tools-paths.patch deleted file mode 100644 index 6bf56d7..0000000 --- a/26372-tools-paths.patch +++ /dev/null @@ -1,56 +0,0 @@ -# HG changeset patch -# User Bamvor Jian Zhang -# Date 1357906948 0 -# Node ID 2ad5792b4274d76ced39515cbd3f84898b181768 -# Parent ba2d73234d73fc0faa027cd9bdfd3ac90642733c -fix wrong path while calling pygrub and libxl-save-helper - -in current xen x86_64, the default libexec directory is /usr/lib/xen/bin, -while the private binder is /usr/lib64/xen/bin. but some commands(pygrub, -libxl-save-helper) located in private binder directory is called from -libexec directory which lead to the following error: -1, for pygrub bootloader: - -libxl: debug: libxl_bootloader.c:429:bootloader_disk_attached_cb: /usr/lib/xen/bin/pygrub doesn't exist, falling back to config path - -2, for libxl-save-helper: - -libxl: cannot execute /usr/lib/xen/bin/libxl-save-helper: No such file or directory -libxl: error: libxl_utils.c:363:libxl_read_exactly: file/stream truncated reading ipc msg header from domain 3 save/restore helper stdout pipe -libxl: error: libxl_exec.c:118:libxl_report_child_exitstatus: domain 3 save/restore helper [10222] exited with error status 255 - -there are two ways to fix above error. the first one is make such command -store in the /usr/lib/xen/bin and /usr/lib64/xen/bin(symbol link to -previous), e.g. qemu-dm. The second way is using private binder dir -instead of libexec dir. e.g. xenconsole. -For these cases, the latter one is suitable. - -Signed-off-by: Bamvor Jian Zhang -Committed-by: Ian Campbell - -Index: xen-4.2.1-testing/tools/libxl/libxl_bootloader.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxl/libxl_bootloader.c -+++ xen-4.2.1-testing/tools/libxl/libxl_bootloader.c -@@ -419,7 +419,7 @@ static void bootloader_disk_attached_cb( - const char *bltmp; - struct stat st; - -- bltmp = libxl__abs_path(gc, bootloader, libxl__libexec_path()); -+ bltmp = libxl__abs_path(gc, bootloader, libxl__private_bindir_path()); - /* Check to see if the file exists in this location; if not, - * fall back to checking the path */ - LOG(DEBUG, "Checking for bootloader in libexec path: %s", bltmp); -Index: xen-4.2.1-testing/tools/libxl/libxl_save_callout.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxl/libxl_save_callout.c -+++ xen-4.2.1-testing/tools/libxl/libxl_save_callout.c -@@ -172,7 +172,7 @@ static void run_helper(libxl__egc *egc, - shs->stdout_what = GCSPRINTF("domain %"PRIu32" save/restore helper" - " stdout pipe", domid); - -- *arg++ = getenv("LIBXL_SAVE_HELPER") ?: LIBEXEC "/" "libxl-save-helper"; -+ *arg++ = getenv("LIBXL_SAVE_HELPER") ?: PRIVATE_BINDIR "/" "libxl-save-helper"; - *arg++ = mode_arg; - const char **stream_fd_arg = arg++; - for (i=0; i -# Date 1358427591 -3600 -# Node ID 76598d4bf61ef0c575deba539ff99078c80e651e -# Parent 0dee85c061addb7124d77c5f6cfe2ea7bc03b760 -x86: handle both NMI kinds if they occur simultaneously - -We shouldn't assume PCI SERR excludes IOCHK. - -Once at it, also remove the doubly redundant range restriction on -"reason" - the variable already is "unsigned char". - -Signed-off-by: Jan Beulich -Acked-by: Andrew Cooper -Acked-by: Keir Fraser - -Index: xen-4.2.2-testing/xen/arch/x86/traps.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/traps.c -+++ xen-4.2.2-testing/xen/arch/x86/traps.c -@@ -3369,10 +3369,10 @@ void do_nmi(struct cpu_user_regs *regs) - reason = inb(0x61); - if ( reason & 0x80 ) - pci_serr_error(regs); -- else if ( reason & 0x40 ) -+ if ( reason & 0x40 ) - io_check_error(regs); -- else if ( !nmi_watchdog ) -- unknown_nmi_error(regs, (unsigned char)(reason&0xff)); -+ if ( !(reason & 0xc0) && !nmi_watchdog ) -+ unknown_nmi_error(regs, reason); - } - } - diff --git a/26418-x86-trampoline-consider-multiboot.patch b/26418-x86-trampoline-consider-multiboot.patch deleted file mode 100644 index 544c3e0..0000000 --- a/26418-x86-trampoline-consider-multiboot.patch +++ /dev/null @@ -1,94 +0,0 @@ -# HG changeset patch -# User Paolo Bonzini -# Date 1358505311 -3600 -# Node ID 3b59a6c3e9b0fb5009bdfff97c8493bb9f0bec54 -# Parent 025f202f3022c30d1ec3b6ffcb72861c43a32cf7 -x86: find a better location for the real-mode trampoline - -On some machines, the location at 0x40e does not point to the beginning -of the EBDA. Rather, it points to the beginning of the BIOS-reserved -area of the EBDA, while the option ROMs place their data below that -segment. - -For this reason, 0x413 is actually a better source than 0x40e to get -the location of the real-mode trampoline. Xen was already using it -as a second source, and this patch keeps that working. However, just -in case, let's also fetch the information from the multiboot structure, -where the boot loader should have placed it. This way we don't -necessarily trust one of the BIOS or the multiboot loader more than -the other. - -Signed-off-by: Paolo Bonzini - -Retain the previous code, thus using the multiboot value only if it's -sane but lower than the BDA computed one. Also use the full 32-bit -mem_lower value and prefer MBI_MEMLIMITS over open coding it (requiring -a slight adjustment to multiboot.h to make its constants actually -usable in assembly code, which previously they were only meant to be). - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser -Committed-by: Jan Beulich - ---- a/xen/arch/x86/boot/head.S -+++ b/xen/arch/x86/boot/head.S -@@ -88,6 +88,20 @@ __start: - movzwl 0x413,%eax /* use base memory size on failure */ - shl $10-4,%eax - 1: -+ /* -+ * Compare the value in the BDA with the information from the -+ * multiboot structure (if available) and use the smallest. -+ */ -+ testb $MBI_MEMLIMITS,(%ebx) -+ jz 2f /* not available? BDA value will be fine */ -+ mov 4(%ebx),%edx -+ cmp $0x100,%edx /* is the multiboot value too small? */ -+ jb 2f /* if so, do not use it */ -+ shl $10-4,%edx -+ cmp %eax,%edx /* compare with BDA value */ -+ cmovb %edx,%eax /* and use the smaller */ -+ -+2: /* Reserve 64kb for the trampoline */ - sub $0x1000,%eax - - /* From arch/x86/smpboot.c: start_eip had better be page-aligned! */ ---- a/xen/include/xen/multiboot.h -+++ b/xen/include/xen/multiboot.h -@@ -18,6 +18,7 @@ - #ifndef __MULTIBOOT_H__ - #define __MULTIBOOT_H__ - -+#include "const.h" - - /* - * Multiboot header structure. -@@ -31,17 +32,17 @@ - /* The magic number passed by a Multiboot-compliant boot loader. */ - #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 - --#define MBI_MEMLIMITS (1u<< 0) --#define MBI_BOOTDEV (1u<< 1) --#define MBI_CMDLINE (1u<< 2) --#define MBI_MODULES (1u<< 3) --#define MBI_AOUT_SYMS (1u<< 4) --#define MBI_ELF_SYMS (1u<< 5) --#define MBI_MEMMAP (1u<< 6) --#define MBI_DRIVES (1u<< 7) --#define MBI_BIOSCONFIG (1u<< 8) --#define MBI_LOADERNAME (1u<< 9) --#define MBI_APM (1u<<10) -+#define MBI_MEMLIMITS (_AC(1,u) << 0) -+#define MBI_BOOTDEV (_AC(1,u) << 1) -+#define MBI_CMDLINE (_AC(1,u) << 2) -+#define MBI_MODULES (_AC(1,u) << 3) -+#define MBI_AOUT_SYMS (_AC(1,u) << 4) -+#define MBI_ELF_SYMS (_AC(1,u) << 5) -+#define MBI_MEMMAP (_AC(1,u) << 6) -+#define MBI_DRIVES (_AC(1,u) << 7) -+#define MBI_BIOSCONFIG (_AC(1,u) << 8) -+#define MBI_LOADERNAME (_AC(1,u) << 9) -+#define MBI_APM (_AC(1,u) << 10) - - #ifndef __ASSEMBLY__ - diff --git a/26532-AMD-IOMMU-phantom-MSI.patch b/26532-AMD-IOMMU-phantom-MSI.patch deleted file mode 100644 index 1d82aad..0000000 --- a/26532-AMD-IOMMU-phantom-MSI.patch +++ /dev/null @@ -1,137 +0,0 @@ -References: bnc#787169 - -# HG changeset patch -# User Jan Beulich -# Date 1360831377 -3600 -# Node ID 788f4551580d476e13ea907e373e58806a32179e -# Parent e68f14b9e73925e9d404e517ba510f73fe472e4e -AMD IOMMU: handle MSI for phantom functions - -With ordinary requests allowed to come from phantom functions, the -remapping tables ought to be set up to also allow for MSI triggers to -come from other than the "real" device too. - -It is not clear to me whether the alias-ID handling also needs -adjustment for this to work properly, or whether firmware can be -expected to properly express this through a device alias range -descriptor (or multiple device alias ones). - -Signed-off-by: Jan Beulich -Acked-by: Ian Campbell - ---- a/xen/drivers/passthrough/amd/iommu_intr.c -+++ b/xen/drivers/passthrough/amd/iommu_intr.c -@@ -284,33 +284,32 @@ void amd_iommu_ioapic_update_ire( - } - - static void update_intremap_entry_from_msi_msg( -- struct amd_iommu *iommu, struct pci_dev *pdev, -- struct msi_desc *msi_desc, struct msi_msg *msg) -+ struct amd_iommu *iommu, u16 bdf, -+ int *remap_index, const struct msi_msg *msg) - { - unsigned long flags; - u32* entry; -- u16 bdf, req_id, alias_id; -+ u16 req_id, alias_id; - u8 delivery_mode, dest, vector, dest_mode; - spinlock_t *lock; - int offset; - -- bdf = (pdev->bus << 8) | pdev->devfn; -- req_id = get_dma_requestor_id(pdev->seg, bdf); -- alias_id = get_intremap_requestor_id(pdev->seg, bdf); -+ req_id = get_dma_requestor_id(iommu->seg, bdf); -+ alias_id = get_intremap_requestor_id(iommu->seg, bdf); - - if ( msg == NULL ) - { - lock = get_intremap_lock(iommu->seg, req_id); - spin_lock_irqsave(lock, flags); -- free_intremap_entry(iommu->seg, req_id, msi_desc->remap_index); -+ free_intremap_entry(iommu->seg, req_id, *remap_index); - spin_unlock_irqrestore(lock, flags); - - if ( ( req_id != alias_id ) && -- get_ivrs_mappings(pdev->seg)[alias_id].intremap_table != NULL ) -+ get_ivrs_mappings(iommu->seg)[alias_id].intremap_table != NULL ) - { - lock = get_intremap_lock(iommu->seg, alias_id); - spin_lock_irqsave(lock, flags); -- free_intremap_entry(iommu->seg, alias_id, msi_desc->remap_index); -+ free_intremap_entry(iommu->seg, alias_id, *remap_index); - spin_unlock_irqrestore(lock, flags); - } - goto done; -@@ -324,7 +323,10 @@ static void update_intremap_entry_from_m - vector = (msg->data >> MSI_DATA_VECTOR_SHIFT) & MSI_DATA_VECTOR_MASK; - dest = (msg->address_lo >> MSI_ADDR_DEST_ID_SHIFT) & 0xff; - offset = get_intremap_offset(vector, delivery_mode); -- msi_desc->remap_index = offset; -+ if ( *remap_index < 0) -+ *remap_index = offset; -+ else -+ BUG_ON(*remap_index != offset); - - entry = (u32*)get_intremap_entry(iommu->seg, req_id, offset); - update_intremap_entry(entry, vector, delivery_mode, dest_mode, dest); -@@ -339,7 +341,7 @@ static void update_intremap_entry_from_m - - lock = get_intremap_lock(iommu->seg, alias_id); - if ( ( req_id != alias_id ) && -- get_ivrs_mappings(pdev->seg)[alias_id].intremap_table != NULL ) -+ get_ivrs_mappings(iommu->seg)[alias_id].intremap_table != NULL ) - { - spin_lock_irqsave(lock, flags); - entry = (u32*)get_intremap_entry(iommu->seg, alias_id, offset); -@@ -362,27 +364,44 @@ void amd_iommu_msi_msg_update_ire( - struct msi_desc *msi_desc, struct msi_msg *msg) - { - struct pci_dev *pdev = msi_desc->dev; -+ int bdf = PCI_BDF2(pdev->bus, pdev->devfn); - struct amd_iommu *iommu = NULL; - - if ( !iommu_intremap ) - return; - -- iommu = find_iommu_for_device(pdev->seg, (pdev->bus << 8) | pdev->devfn); -- -+ iommu = find_iommu_for_device(pdev->seg, bdf); - if ( !iommu ) - { -- AMD_IOMMU_DEBUG("Fail to find iommu for MSI device id = 0x%x\n", -- (pdev->bus << 8) | pdev->devfn); -+ AMD_IOMMU_DEBUG("Fail to find iommu for MSI device id = 0x%x\n", bdf); - return; - } - - if ( msi_desc->remap_index >= 0 ) -- update_intremap_entry_from_msi_msg(iommu, pdev, msi_desc, NULL); -+ { -+ do { -+ update_intremap_entry_from_msi_msg(iommu, bdf, -+ &msi_desc->remap_index, NULL); -+ if ( !pdev || !pdev->phantom_stride ) -+ break; -+ bdf += pdev->phantom_stride; -+ } while ( PCI_SLOT(bdf) == PCI_SLOT(pdev->devfn) ); -+ -+ msi_desc->remap_index = -1; -+ if ( pdev ) -+ bdf = PCI_BDF2(pdev->bus, pdev->devfn); -+ } - - if ( !msg ) - return; - -- update_intremap_entry_from_msi_msg(iommu, pdev, msi_desc, msg); -+ do { -+ update_intremap_entry_from_msi_msg(iommu, bdf, &msi_desc->remap_index, -+ msg); -+ if ( !pdev || !pdev->phantom_stride ) -+ break; -+ bdf += pdev->phantom_stride; -+ } while ( PCI_SLOT(bdf) == PCI_SLOT(pdev->devfn) ); - } - - void amd_iommu_read_msi_from_ire( diff --git a/26547-tools-xc_fix_logic_error_in_stdiostream_progress.patch b/26547-tools-xc_fix_logic_error_in_stdiostream_progress.patch deleted file mode 100644 index 2f78331..0000000 --- a/26547-tools-xc_fix_logic_error_in_stdiostream_progress.patch +++ /dev/null @@ -1,26 +0,0 @@ -changeset: 26547:8285d20a6f5b -user: Olaf Hering -date: Fri Feb 15 13:32:11 2013 +0000 -files: tools/libxc/xtl_logger_stdio.c -description: -tools/xc: fix logic error in stdiostream_progress - -Setting XTL_STDIOSTREAM_HIDE_PROGRESS should disable progress reporting. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r 0141aeb86b79 -r 8285d20a6f5b tools/libxc/xtl_logger_stdio.c ---- a/tools/libxc/xtl_logger_stdio.c Fri Feb 15 13:32:10 2013 +0000 -+++ b/tools/libxc/xtl_logger_stdio.c Fri Feb 15 13:32:11 2013 +0000 -@@ -89,7 +89,7 @@ static void stdiostream_progress(struct - int newpel, extra_erase; - xentoollog_level this_level; - -- if (!(lg->flags & XTL_STDIOSTREAM_HIDE_PROGRESS)) -+ if (lg->flags & XTL_STDIOSTREAM_HIDE_PROGRESS) - return; - - if (percent < lg->progress_last_percent) { diff --git a/26548-tools-xc_handle_tty_output_differently_in_stdiostream_progress.patch b/26548-tools-xc_handle_tty_output_differently_in_stdiostream_progress.patch deleted file mode 100644 index aaf4335..0000000 --- a/26548-tools-xc_handle_tty_output_differently_in_stdiostream_progress.patch +++ /dev/null @@ -1,62 +0,0 @@ -changeset: 26548:e7d9bac5c11d -user: Olaf Hering -date: Fri Feb 15 13:32:11 2013 +0000 -files: tools/libxc/xtl_logger_stdio.c -description: -tools/xc: handle tty output differently in stdiostream_progress - -If the output goes to a tty, rewind the cursor and print everything in a -single line as it was done up to now. If the output goes to a file or -pipe print a newline after each progress output. This will fix logging -of progress messages from xc_save to xend.log. - -To support XTL_STDIOSTREAM_SHOW_PID or XTL_STDIOSTREAM_SHOW_DATE print -the output via vmessage if the output is not a tty. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r 8285d20a6f5b -r e7d9bac5c11d tools/libxc/xtl_logger_stdio.c ---- a/tools/libxc/xtl_logger_stdio.c Fri Feb 15 13:32:11 2013 +0000 -+++ b/tools/libxc/xtl_logger_stdio.c Fri Feb 15 13:32:11 2013 +0000 -@@ -81,6 +81,17 @@ static void stdiostream_vmessage(xentool - fflush(lg->f); - } - -+static void stdiostream_message(struct xentoollog_logger *logger_in, -+ xentoollog_level level, -+ const char *context, -+ const char *format, ...) -+{ -+ va_list al; -+ va_start(al,format); -+ stdiostream_vmessage(logger_in, level, -1, context, format, al); -+ va_end(al); -+} -+ - static void stdiostream_progress(struct xentoollog_logger *logger_in, - const char *context, - const char *doing_what, int percent, -@@ -105,11 +116,18 @@ static void stdiostream_progress(struct - if (this_level < lg->min_level) - return; - -+ lg->progress_last_percent = percent; -+ -+ if (isatty(fileno(lg->f)) <= 0) { -+ stdiostream_message(logger_in, this_level, context, -+ "%s: %lu/%lu %3d%%", -+ doing_what, done, total, percent); -+ return; -+ } -+ - if (lg->progress_erase_len) - putc('\r', lg->f); - -- lg->progress_last_percent = percent; -- - newpel = fprintf(lg->f, "%s%s" "%s: %lu/%lu %3d%%%s", - context?context:"", context?": ":"", - doing_what, done, total, percent, diff --git a/26549-tools-xc_turn_XCFLAGS__into_shifts.patch b/26549-tools-xc_turn_XCFLAGS__into_shifts.patch deleted file mode 100644 index 377ece2..0000000 --- a/26549-tools-xc_turn_XCFLAGS__into_shifts.patch +++ /dev/null @@ -1,36 +0,0 @@ -changeset: 26549:d2991367ecd2 -user: Olaf Hering -date: Fri Feb 15 13:32:12 2013 +0000 -files: tools/libxc/xenguest.h -description: -tools/xc: turn XCFLAGS_* into shifts - -to make it clear that these are bits and to make it easier to use in -xend code. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r e7d9bac5c11d -r d2991367ecd2 tools/libxc/xenguest.h ---- a/tools/libxc/xenguest.h Fri Feb 15 13:32:11 2013 +0000 -+++ b/tools/libxc/xenguest.h Fri Feb 15 13:32:12 2013 +0000 -@@ -23,11 +23,12 @@ - #ifndef XENGUEST_H - #define XENGUEST_H - --#define XCFLAGS_LIVE 1 --#define XCFLAGS_DEBUG 2 --#define XCFLAGS_HVM 4 --#define XCFLAGS_STDVGA 8 --#define XCFLAGS_CHECKPOINT_COMPRESS 16 -+#define XCFLAGS_LIVE (1 << 0) -+#define XCFLAGS_DEBUG (1 << 1) -+#define XCFLAGS_HVM (1 << 2) -+#define XCFLAGS_STDVGA (1 << 3) -+#define XCFLAGS_CHECKPOINT_COMPRESS (1 << 4) -+ - #define X86_64_B_SIZE 64 - #define X86_32_B_SIZE 32 - diff --git a/26550-tools-xc_restore_logging_in_xc_save.patch b/26550-tools-xc_restore_logging_in_xc_save.patch deleted file mode 100644 index 785e8bb..0000000 --- a/26550-tools-xc_restore_logging_in_xc_save.patch +++ /dev/null @@ -1,58 +0,0 @@ -changeset: 26550:e6c373fcb73e -user: Olaf Hering -date: Fri Feb 15 13:32:13 2013 +0000 -files: tools/xcutils/xc_save.c -description: -tools/xc: restore logging in xc_save - -Prior to xen-4.1 the helper xc_save would print some progress during -migration. With the new xc_interface_open API no more messages were -printed because no logger was configured. - -Restore previous behaviour by providing a logger. The progress in -xc_domain_save will be disabled because it generates alot of output and -fills up xend.log quickly. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -diff -r d2991367ecd2 -r e6c373fcb73e tools/xcutils/xc_save.c ---- a/tools/xcutils/xc_save.c Fri Feb 15 13:32:12 2013 +0000 -+++ b/tools/xcutils/xc_save.c Fri Feb 15 13:32:13 2013 +0000 -@@ -166,17 +166,15 @@ static int switch_qemu_logdirty(int domi - int - main(int argc, char **argv) - { -- unsigned int maxit, max_f; -+ unsigned int maxit, max_f, lflags; - int io_fd, ret, port; - struct save_callbacks callbacks; -+ xentoollog_level lvl; -+ xentoollog_logger *l; - - if (argc != 6) - errx(1, "usage: %s iofd domid maxit maxf flags", argv[0]); - -- si.xch = xc_interface_open(0,0,0); -- if (!si.xch) -- errx(1, "failed to open control interface"); -- - io_fd = atoi(argv[1]); - si.domid = atoi(argv[2]); - maxit = atoi(argv[3]); -@@ -185,6 +183,13 @@ main(int argc, char **argv) - - si.suspend_evtchn = -1; - -+ lvl = si.flags & XCFLAGS_DEBUG ? XTL_DEBUG: XTL_DETAIL; -+ lflags = XTL_STDIOSTREAM_HIDE_PROGRESS; -+ l = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr, lvl, lflags); -+ si.xch = xc_interface_open(l, 0, 0); -+ if (!si.xch) -+ errx(1, "failed to open control interface"); -+ - si.xce = xc_evtchn_open(NULL, 0); - if (si.xce == NULL) - warnx("failed to open event channel handle"); diff --git a/26551-tools-xc_log_pid_in_xc_save-xc_restore_output.patch b/26551-tools-xc_log_pid_in_xc_save-xc_restore_output.patch deleted file mode 100644 index 997dd93..0000000 --- a/26551-tools-xc_log_pid_in_xc_save-xc_restore_output.patch +++ /dev/null @@ -1,111 +0,0 @@ -changeset: 26551:48f9436959dd -user: Olaf Hering -date: Fri Feb 15 13:32:13 2013 +0000 -files: tools/libxc/xc_domain_restore.c tools/libxc/xc_domain_save.c tools/xcutils/xc_restore.c tools/xcutils/xc_save.c -description: -tools/xc: log pid in xc_save/xc_restore output - -If several migrations log their output to xend.log its not clear which -line belongs to a which guest. Print entry/exit of xc_save and -xc_restore and also request to print pid with each log call. - -Signed-off-by: Olaf Hering -Acked-by: Ian Campbell -Committed-by: Ian Campbell - - -Index: xen-4.2.1-testing/tools/libxc/xc_domain_restore.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxc/xc_domain_restore.c -+++ xen-4.2.1-testing/tools/libxc/xc_domain_restore.c -@@ -1382,6 +1382,8 @@ int xc_domain_restore(xc_interface *xch, - struct restore_ctx *ctx = &_ctx; - struct domain_info_context *dinfo = &ctx->dinfo; - -+ DPRINTF("%s: starting restore of new domid %u", __func__, dom); -+ - pagebuf_init(&pagebuf); - memset(&tailbuf, 0, sizeof(tailbuf)); - tailbuf.ishvm = hvm; -@@ -1408,7 +1410,7 @@ int xc_domain_restore(xc_interface *xch, - PERROR("read: p2m_size"); - goto out; - } -- DPRINTF("xc_domain_restore start: p2m_size = %lx\n", dinfo->p2m_size); -+ DPRINTF("%s: p2m_size = %lx\n", __func__, dinfo->p2m_size); - - if ( !get_platform_info(xch, dom, - &ctx->max_mfn, &ctx->hvirt_start, &ctx->pt_levels, &dinfo->guest_width) ) -@@ -2215,7 +2217,7 @@ int xc_domain_restore(xc_interface *xch, - - fcntl(io_fd, F_SETFL, orig_io_fd_flags); - -- DPRINTF("Restore exit with rc=%d\n", rc); -+ DPRINTF("Restore exit of domid %u with rc=%d\n", dom, rc); - - return rc; - } -Index: xen-4.2.1-testing/tools/libxc/xc_domain_save.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxc/xc_domain_save.c -+++ xen-4.2.1-testing/tools/libxc/xc_domain_save.c -@@ -897,6 +897,8 @@ int xc_domain_save(xc_interface *xch, in - - int completed = 0; - -+ DPRINTF("%s: starting save of domid %u", __func__, dom); -+ - if ( hvm && !callbacks->switch_qemu_logdirty ) - { - ERROR("No switch_qemu_logdirty callback provided."); -@@ -2112,7 +2114,7 @@ int xc_domain_save(xc_interface *xch, in - free(pfn_err); - free(to_fix); - -- DPRINTF("Save exit rc=%d\n",rc); -+ DPRINTF("Save exit of domid %u with rc=%d\n", dom, rc); - - return !!rc; - } -Index: xen-4.2.1-testing/tools/xcutils/xc_restore.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/xcutils/xc_restore.c -+++ xen-4.2.1-testing/tools/xcutils/xc_restore.c -@@ -19,17 +19,22 @@ int - main(int argc, char **argv) - { - unsigned int domid, store_evtchn, console_evtchn; -- unsigned int hvm, pae, apic; -+ unsigned int hvm, pae, apic, lflags; - xc_interface *xch; - int io_fd, ret; - int superpages; - unsigned long store_mfn, console_mfn; -+ xentoollog_level lvl; -+ xentoollog_logger *l; - - if ( (argc != 8) && (argc != 9) ) - errx(1, "usage: %s iofd domid store_evtchn " - "console_evtchn hvm pae apic [superpages]", argv[0]); - -- xch = xc_interface_open(0,0,0); -+ lvl = XTL_DETAIL; -+ lflags = XTL_STDIOSTREAM_SHOW_PID | XTL_STDIOSTREAM_HIDE_PROGRESS; -+ l = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr, lvl, lflags); -+ xch = xc_interface_open(l, 0, 0); - if ( !xch ) - errx(1, "failed to open control interface"); - -Index: xen-4.2.1-testing/tools/xcutils/xc_save.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/xcutils/xc_save.c -+++ xen-4.2.1-testing/tools/xcutils/xc_save.c -@@ -184,7 +184,7 @@ main(int argc, char **argv) - si.suspend_evtchn = -1; - - lvl = si.flags & XCFLAGS_DEBUG ? XTL_DEBUG: XTL_DETAIL; -- lflags = XTL_STDIOSTREAM_HIDE_PROGRESS; -+ lflags = XTL_STDIOSTREAM_SHOW_PID | XTL_STDIOSTREAM_HIDE_PROGRESS; - l = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr, lvl, lflags); - si.xch = xc_interface_open(l, 0, 0); - if (!si.xch) diff --git a/26554-hvm-firmware-passthrough.patch b/26554-hvm-firmware-passthrough.patch deleted file mode 100644 index 175ddf9..0000000 --- a/26554-hvm-firmware-passthrough.patch +++ /dev/null @@ -1,46 +0,0 @@ -# HG changeset patch -# User Ross Philipson -# Date 1360935136 0 -# Node ID 3124ab7855fd7d4e0f3ea125cb21b60d693e8800 -# Parent 71c15ae0998378b5c117bbd27a48015757685706 -libxl: switch to using the new xc_hvm_build() libxc API. - -Signed-off-by: Ross Philipson -Acked-by: Ian Campbell -Committed-by: Ian Campbell - -Index: xen-4.2.2-testing/tools/libxl/libxl_dom.c -=================================================================== ---- xen-4.2.2-testing.orig/tools/libxl/libxl_dom.c -+++ xen-4.2.2-testing/tools/libxl/libxl_dom.c -@@ -546,17 +546,24 @@ int libxl__build_hvm(libxl__gc *gc, uint - libxl__domain_build_state *state) - { - libxl_ctx *ctx = libxl__gc_owner(gc); -+ struct xc_hvm_build_args args = {}; - int ret, rc = ERROR_FAIL; - const char *firmware = libxl__domain_firmware(gc, info); - - if (!firmware) - goto out; -- ret = xc_hvm_build_target_mem( -- ctx->xch, -- domid, -- (info->max_memkb - info->video_memkb) / 1024, -- (info->target_memkb - info->video_memkb) / 1024, -- firmware); -+ -+ memset(&args, 0, sizeof(struct xc_hvm_build_args)); -+ /* The params from the configuration file are in Mb, which are then -+ * multiplied by 1 Kb. This was then divided off when calling -+ * the old xc_hvm_build_target_mem() which then turned them to bytes. -+ * Do all this in one step here... -+ */ -+ args.mem_size = (uint64_t)(info->max_memkb - info->video_memkb) << 10; -+ args.mem_target = (uint64_t)(info->target_memkb - info->video_memkb) << 10; -+ args.image_file_name = firmware; -+ -+ ret = xc_hvm_build(ctx->xch, domid, &args); - if (ret) { - LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed"); - goto out; diff --git a/26555-hvm-firmware-passthrough.patch b/26555-hvm-firmware-passthrough.patch deleted file mode 100644 index 6b10af2..0000000 --- a/26555-hvm-firmware-passthrough.patch +++ /dev/null @@ -1,314 +0,0 @@ -# HG changeset patch -# User Ross Philipson -# Date 1360935136 0 -# Node ID 17a228e37ec0913ff86b8b5f2d88f1b8e92146f1 -# Parent 3124ab7855fd7d4e0f3ea125cb21b60d693e8800 -libxl: HVM firmware passthrough support - -This patch introduces support for two new parameters in libxl: - -smbios_firmware= -acpi_firmware= - -The changes are primarily in the domain building code where the firmware files -are read and passed to libxc for loading into the new guest. After the domain -building call to libxc, the addresses for the loaded blobs are returned and -written to xenstore. - -LIBXL_HAVE_FIRMWARE_PASSTHROUGH is defined in libxl.h to allow users to -determine if the feature is present. - -This patch also updates the xl.cfg man page with descriptions of the two new -parameters for firmware passthrough. - -Signed-off-by: Ross Philipson -Acked-by: Ian Campbell -Committed-by: Ian Campbell - -Index: xen-4.2.2-testing/docs/man/xl.cfg.pod.5 -=================================================================== ---- xen-4.2.2-testing.orig/docs/man/xl.cfg.pod.5 -+++ xen-4.2.2-testing/docs/man/xl.cfg.pod.5 -@@ -637,6 +637,25 @@ of Xen) within a Xen guest or to support - which uses hardware virtualisation extensions (e.g. Windows XP - compatibility mode on more modern Windows OS). - -+=item B -+ -+Specify a path to a file that contains extra ACPI firmware tables to pass in to -+a guest. The file can contain several tables in their binary AML form -+concatenated together. Each table self describes its length so no additional -+information is needed. These tables will be added to the ACPI table set in the -+guest. Note that existing tables cannot be overridden by this feature. For -+example this cannot be used to override tables like DSDT, FADT, etc. -+ -+=item B -+ -+Specify a path to a file that contains extra SMBIOS firmware structures to pass -+in to a guest. The file can contain a set DMTF predefined structures which will -+override the internal defaults. Not all predefined structures can be overridden, -+only the following types: 0, 1, 2, 3, 11, 22, 39. The file can also contain any -+number of vendor defined SMBIOS structures (type 128 - 255). Since SMBIOS -+structures do not present their overall size, each entry in the file must be -+preceded by a 32b integer indicating the size of the next structure. -+ - =back - - =head3 Guest Virtual Time Controls -Index: xen-4.2.2-testing/tools/libxl/libxl.h -=================================================================== ---- xen-4.2.2-testing.orig/tools/libxl/libxl.h -+++ xen-4.2.2-testing/tools/libxl/libxl.h -@@ -68,6 +68,13 @@ - */ - - /* -+ * LIBXL_HAVE_FIRMWARE_PASSTHROUGH indicates the feature for -+ * passing in SMBIOS and ACPI firmware to HVM guests is present -+ * in the library. -+ */ -+#define LIBXL_HAVE_FIRMWARE_PASSTHROUGH 1 -+ -+/* - * libxl ABI compatibility - * - * The only guarantee which libxl makes regarding ABI compatibility -Index: xen-4.2.2-testing/tools/libxl/libxl_dom.c -=================================================================== ---- xen-4.2.2-testing.orig/tools/libxl/libxl_dom.c -+++ xen-4.2.2-testing/tools/libxl/libxl_dom.c -@@ -22,6 +22,7 @@ - - #include - #include -+#include - - libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid) - { -@@ -514,11 +515,61 @@ static int hvm_build_set_params(xc_inter - return 0; - } - --static const char *libxl__domain_firmware(libxl__gc *gc, -- libxl_domain_build_info *info) -+static int hvm_build_set_xs_values(libxl__gc *gc, -+ uint32_t domid, -+ struct xc_hvm_build_args *args) -+{ -+ char *path = NULL; -+ int ret = 0; -+ -+ if (args->smbios_module.guest_addr_out) { -+ path = GCSPRINTF("/local/domain/%d/"HVM_XS_SMBIOS_PT_ADDRESS, domid); -+ -+ ret = libxl__xs_write(gc, XBT_NULL, path, "0x%"PRIx64, -+ args->smbios_module.guest_addr_out); -+ if (ret) -+ goto err; -+ -+ path = GCSPRINTF("/local/domain/%d/"HVM_XS_SMBIOS_PT_LENGTH, domid); -+ -+ ret = libxl__xs_write(gc, XBT_NULL, path, "0x%x", -+ args->smbios_module.length); -+ if (ret) -+ goto err; -+ } -+ -+ if (args->acpi_module.guest_addr_out) { -+ path = GCSPRINTF("/local/domain/%d/"HVM_XS_ACPI_PT_ADDRESS, domid); -+ -+ ret = libxl__xs_write(gc, XBT_NULL, path, "0x%"PRIx64, -+ args->acpi_module.guest_addr_out); -+ if (ret) -+ goto err; -+ -+ path = GCSPRINTF("/local/domain/%d/"HVM_XS_ACPI_PT_LENGTH, domid); -+ -+ ret = libxl__xs_write(gc, XBT_NULL, path, "0x%x", -+ args->acpi_module.length); -+ if (ret) -+ goto err; -+ } -+ -+ return 0; -+ -+err: -+ LOG(ERROR, "failed to write firmware xenstore value, err: %d", ret); -+ return ret; -+} -+ -+static int libxl__domain_firmware(libxl__gc *gc, -+ libxl_domain_build_info *info, -+ struct xc_hvm_build_args *args) - { - libxl_ctx *ctx = libxl__gc_owner(gc); - const char *firmware; -+ int e, rc = ERROR_FAIL; -+ int datalen = 0; -+ void *data; - - if (info->u.hvm.firmware) - firmware = info->u.hvm.firmware; -@@ -532,13 +583,52 @@ static const char *libxl__domain_firmwar - firmware = "hvmloader"; - break; - default: -- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "invalid device model version %d", -- info->device_model_version); -- return NULL; -+ LOG(ERROR, "invalid device model version %d", -+ info->device_model_version); -+ return ERROR_FAIL; - break; - } - } -- return libxl__abs_path(gc, firmware, libxl__xenfirmwaredir_path()); -+ args->image_file_name = libxl__abs_path(gc, firmware, -+ libxl__xenfirmwaredir_path()); -+ -+ if (info->u.hvm.smbios_firmware) { -+ data = NULL; -+ e = libxl_read_file_contents(ctx, info->u.hvm.smbios_firmware, -+ &data, &datalen); -+ if (e) { -+ LOGEV(ERROR, e, "failed to read SMBIOS firmware file %s", -+ info->u.hvm.smbios_firmware); -+ goto out; -+ } -+ libxl__ptr_add(gc, data); -+ if (datalen) { -+ /* Only accept non-empty files */ -+ args->smbios_module.data = data; -+ args->smbios_module.length = (uint32_t)datalen; -+ } -+ } -+ -+ if (info->u.hvm.acpi_firmware) { -+ data = NULL; -+ e = libxl_read_file_contents(ctx, info->u.hvm.acpi_firmware, -+ &data, &datalen); -+ if (e) { -+ LOGEV(ERROR, e, "failed to read ACPI firmware file %s", -+ info->u.hvm.acpi_firmware); -+ goto out; -+ } -+ libxl__ptr_add(gc, data); -+ if (datalen) { -+ /* Only accept non-empty files */ -+ args->acpi_module.data = data; -+ args->acpi_module.length = (uint32_t)datalen; -+ } -+ } -+ -+ return 0; -+out: -+ return rc; - } - - int libxl__build_hvm(libxl__gc *gc, uint32_t domid, -@@ -548,10 +638,6 @@ int libxl__build_hvm(libxl__gc *gc, uint - libxl_ctx *ctx = libxl__gc_owner(gc); - struct xc_hvm_build_args args = {}; - int ret, rc = ERROR_FAIL; -- const char *firmware = libxl__domain_firmware(gc, info); -- -- if (!firmware) -- goto out; - - memset(&args, 0, sizeof(struct xc_hvm_build_args)); - /* The params from the configuration file are in Mb, which are then -@@ -561,22 +647,34 @@ int libxl__build_hvm(libxl__gc *gc, uint - */ - args.mem_size = (uint64_t)(info->max_memkb - info->video_memkb) << 10; - args.mem_target = (uint64_t)(info->target_memkb - info->video_memkb) << 10; -- args.image_file_name = firmware; -+ -+ if (libxl__domain_firmware(gc, info, &args)) { -+ LOG(ERROR, "initializing domain firmware failed"); -+ goto out; -+ } - - ret = xc_hvm_build(ctx->xch, domid, &args); - if (ret) { -- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed"); -+ LOGEV(ERROR, ret, "hvm building failed"); - goto out; - } -+ - ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port, - &state->store_mfn, state->console_port, - &state->console_mfn, state->store_domid, - state->console_domid); - if (ret) { -- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm build set params failed"); -+ LOGEV(ERROR, ret, "hvm build set params failed"); - goto out; - } -- rc = 0; -+ -+ ret = hvm_build_set_xs_values(gc, domid, &args); -+ if (ret) { -+ LOG(ERROR, "hvm build set xenstore values failed (ret=%d)", ret); -+ goto out; -+ } -+ -+ return 0; - out: - return rc; - } -@@ -638,7 +736,7 @@ int libxl__toolstack_restore(uint32_t do - - memcpy(&count, ptr, sizeof(count)); - ptr += sizeof(count); -- -+ - if (size < sizeof(version) + sizeof(count) + - count * (sizeof(struct libxl__physmap_info))) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "wrong size"); -@@ -852,7 +950,7 @@ static void switch_logdirty_xswatch(libx - rc = libxl__xs_rm_checked(gc, t, lds->ret_path); - if (rc) goto out; - -- rc = libxl__xs_transaction_commit(gc, &t); -+ rc = libxl__xs_transaction_commit(gc, &t); - if (!rc) break; - if (rc<0) goto out; - } -@@ -1324,7 +1422,7 @@ void libxl__xc_domain_save_done(libxl__e - if (type == LIBXL_DOMAIN_TYPE_HVM) { - rc = libxl__domain_suspend_device_model(gc, dss); - if (rc) goto out; -- -+ - libxl__domain_save_device_model(egc, dss, domain_suspend_done); - return; - } -Index: xen-4.2.2-testing/tools/libxl/libxl_types.idl -=================================================================== ---- xen-4.2.2-testing.orig/tools/libxl/libxl_types.idl -+++ xen-4.2.2-testing/tools/libxl/libxl_types.idl -@@ -301,6 +301,8 @@ libxl_domain_build_info = Struct("domain - ("vpt_align", libxl_defbool), - ("timer_mode", libxl_timer_mode), - ("nested_hvm", libxl_defbool), -+ ("smbios_firmware", string), -+ ("acpi_firmware", string), - ("nographic", libxl_defbool), - ("vga", libxl_vga_interface_info), - ("vnc", libxl_vnc_info), -Index: xen-4.2.2-testing/tools/libxl/xl_cmdimpl.c -=================================================================== ---- xen-4.2.2-testing.orig/tools/libxl/xl_cmdimpl.c -+++ xen-4.2.2-testing/tools/libxl/xl_cmdimpl.c -@@ -863,6 +863,11 @@ static void parse_config_data(const char - } - - xlu_cfg_get_defbool(config, "nestedhvm", &b_info->u.hvm.nested_hvm, 0); -+ -+ xlu_cfg_replace_string(config, "smbios_firmware", -+ &b_info->u.hvm.smbios_firmware, 0); -+ xlu_cfg_replace_string(config, "acpi_firmware", -+ &b_info->u.hvm.acpi_firmware, 0); - break; - case LIBXL_DOMAIN_TYPE_PV: - { diff --git a/26556-hvm-firmware-passthrough.patch b/26556-hvm-firmware-passthrough.patch deleted file mode 100644 index 366b731..0000000 --- a/26556-hvm-firmware-passthrough.patch +++ /dev/null @@ -1,320 +0,0 @@ -# HG changeset patch -# User Ross Philipson -# Date 1360935137 0 -# Node ID 6a9549a15108669408123e5e39f52ad09dea1c10 -# Parent 17a228e37ec0913ff86b8b5f2d88f1b8e92146f1 -libxl: Cleanup, use LOG* and GCSPRINTF macro in libxl_dom.c - -Signed-off-by: Ross Philipson -Acked-by: Ian Campbell -Committed-by: Ian Campbell - -Index: xen-4.2.2-testing/tools/libxl/libxl_dom.c -=================================================================== ---- xen-4.2.2-testing.orig/tools/libxl/libxl_dom.c -+++ xen-4.2.2-testing/tools/libxl/libxl_dom.c -@@ -32,8 +32,7 @@ libxl_domain_type libxl__domain_type(lib - - ret = xc_domain_getinfolist(ctx->xch, domid, 1, &info); - if (ret != 1 || info.domain != domid) { -- LIBXL__LOG(CTX, LIBXL__LOG_ERROR, -- "unable to get domain type for domid=%"PRIu32, domid); -+ LOG(ERROR, "unable to get domain type for domid=%"PRIu32, domid); - return LIBXL_DOMAIN_TYPE_INVALID; - } - if (info.flags & XEN_DOMINF_hvm_guest) -@@ -317,20 +316,19 @@ int libxl__build_post(libxl__gc *gc, uin - - ents = libxl__calloc(gc, 12 + (info->max_vcpus * 2) + 2, sizeof(char *)); - ents[0] = "memory/static-max"; -- ents[1] = libxl__sprintf(gc, "%"PRId64, info->max_memkb); -+ ents[1] = GCSPRINTF("%"PRId64, info->max_memkb); - ents[2] = "memory/target"; -- ents[3] = libxl__sprintf(gc, "%"PRId64, -- info->target_memkb - info->video_memkb); -+ ents[3] = GCSPRINTF("%"PRId64, info->target_memkb - info->video_memkb); - ents[4] = "memory/videoram"; -- ents[5] = libxl__sprintf(gc, "%"PRId64, info->video_memkb); -+ ents[5] = GCSPRINTF("%"PRId64, info->video_memkb); - ents[6] = "domid"; -- ents[7] = libxl__sprintf(gc, "%d", domid); -+ ents[7] = GCSPRINTF("%d", domid); - ents[8] = "store/port"; -- ents[9] = libxl__sprintf(gc, "%"PRIu32, state->store_port); -+ ents[9] = GCSPRINTF("%"PRIu32, state->store_port); - ents[10] = "store/ring-ref"; -- ents[11] = libxl__sprintf(gc, "%lu", state->store_mfn); -+ ents[11] = GCSPRINTF("%lu", state->store_mfn); - for (i = 0; i < info->max_vcpus; i++) { -- ents[12+(i*2)] = libxl__sprintf(gc, "cpu/%d/availability", i); -+ ents[12+(i*2)] = GCSPRINTF("cpu/%d/availability", i); - ents[12+(i*2)+1] = libxl_bitmap_test(&info->avail_vcpus, i) - ? "online" : "offline"; - } -@@ -339,7 +337,7 @@ int libxl__build_post(libxl__gc *gc, uin - if (info->type == LIBXL_DOMAIN_TYPE_HVM) { - hvm_ents = libxl__calloc(gc, 3, sizeof(char *)); - hvm_ents[0] = "hvmloader/generation-id-address"; -- hvm_ents[1] = libxl__sprintf(gc, "0x%lx", state->vm_generationid_addr); -+ hvm_ents[1] = GCSPRINTF("0x%lx", state->vm_generationid_addr); - } - - dom_path = libxl__xs_get_dompath(gc, domid); -@@ -347,7 +345,7 @@ int libxl__build_post(libxl__gc *gc, uin - return ERROR_FAIL; - } - -- vm_path = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "%s/vm", dom_path), NULL); -+ vm_path = xs_read(ctx->xsh, XBT_NULL, GCSPRINTF("%s/vm", dom_path), NULL); - retry_transaction: - t = xs_transaction_start(ctx->xsh); - -@@ -378,7 +376,7 @@ int libxl__build_pv(libxl__gc *gc, uint3 - - dom = xc_dom_allocate(ctx->xch, state->pv_cmdline, info->u.pv.features); - if (!dom) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_allocate failed"); -+ LOGE(ERROR, "xc_dom_allocate failed"); - return ERROR_FAIL; - } - -@@ -388,13 +386,13 @@ int libxl__build_pv(libxl__gc *gc, uint3 - state->pv_kernel.data, - state->pv_kernel.size); - if ( ret != 0) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_mem failed"); -+ LOGE(ERROR, "xc_dom_kernel_mem failed"); - goto out; - } - } else { - ret = xc_dom_kernel_file(dom, state->pv_kernel.path); - if ( ret != 0) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_file failed"); -+ LOGE(ERROR, "xc_dom_kernel_file failed"); - goto out; - } - } -@@ -402,12 +400,12 @@ int libxl__build_pv(libxl__gc *gc, uint3 - if ( state->pv_ramdisk.path && strlen(state->pv_ramdisk.path) ) { - if (state->pv_ramdisk.mapped) { - if ( (ret = xc_dom_ramdisk_mem(dom, state->pv_ramdisk.data, state->pv_ramdisk.size)) != 0 ) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_ramdisk_mem failed"); -+ LOGE(ERROR, "xc_dom_ramdisk_mem failed"); - goto out; - } - } else { - if ( (ret = xc_dom_ramdisk_file(dom, state->pv_ramdisk.path)) != 0 ) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_ramdisk_file failed"); -+ LOGE(ERROR, "xc_dom_ramdisk_file failed"); - goto out; - } - } -@@ -420,31 +418,31 @@ int libxl__build_pv(libxl__gc *gc, uint3 - dom->xenstore_domid = state->store_domid; - - if ( (ret = xc_dom_boot_xen_init(dom, ctx->xch, domid)) != 0 ) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_boot_xen_init failed"); -+ LOGE(ERROR, "xc_dom_boot_xen_init failed"); - goto out; - } - if ( (ret = xc_dom_parse_image(dom)) != 0 ) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_parse_image failed"); -+ LOGE(ERROR, "xc_dom_parse_image failed"); - goto out; - } - if ( (ret = xc_dom_mem_init(dom, info->target_memkb / 1024)) != 0 ) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_mem_init failed"); -+ LOGE(ERROR, "xc_dom_mem_init failed"); - goto out; - } - if ( (ret = xc_dom_boot_mem_init(dom)) != 0 ) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_boot_mem_init failed"); -+ LOGE(ERROR, "xc_dom_boot_mem_init failed"); - goto out; - } - if ( (ret = xc_dom_build_image(dom)) != 0 ) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_build_image failed"); -+ LOGE(ERROR, "xc_dom_build_image failed"); - goto out; - } - if ( (ret = xc_dom_boot_image(dom)) != 0 ) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_boot_image failed"); -+ LOGE(ERROR, "xc_dom_boot_image failed"); - goto out; - } - if ( (ret = xc_dom_gnttab_init(dom)) != 0 ) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_gnttab_init failed"); -+ LOGE(ERROR, "xc_dom_gnttab_init failed"); - goto out; - } - -@@ -683,8 +681,7 @@ int libxl__qemu_traditional_cmd(libxl__g - const char *cmd) - { - char *path = NULL; -- path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command", -- domid); -+ path = GCSPRINTF("/local/domain/0/device-model/%d/command", domid); - return libxl__xs_write(gc, XBT_NULL, path, "%s", cmd); - } - -@@ -701,8 +698,7 @@ struct libxl__physmap_info { - static inline char *restore_helper(libxl__gc *gc, uint32_t domid, - uint64_t phys_offset, char *node) - { -- return libxl__sprintf(gc, -- "/local/domain/0/device-model/%d/physmap/%"PRIx64"/%s", -+ return GCSPRINTF("/local/domain/0/device-model/%d/physmap/%"PRIx64"/%s", - domid, phys_offset, node); - } - -@@ -712,7 +708,6 @@ int libxl__toolstack_restore(uint32_t do - libxl__save_helper_state *shs = user; - libxl__domain_create_state *dcs = CONTAINER_OF(shs, *dcs, shs); - STATE_AO_GC(dcs->ao); -- libxl_ctx *ctx = CTX; - int i, ret; - const uint8_t *ptr = buf; - uint32_t count = 0, version = 0; -@@ -722,7 +717,7 @@ int libxl__toolstack_restore(uint32_t do - LOG(DEBUG,"domain=%"PRIu32" toolstack data size=%"PRIu32, domid, size); - - if (size < sizeof(version) + sizeof(count)) { -- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "wrong size"); -+ LOG(ERROR, "wrong size"); - return -1; - } - -@@ -730,7 +725,7 @@ int libxl__toolstack_restore(uint32_t do - ptr += sizeof(version); - - if (version != TOOLSTACK_SAVE_VERSION) { -- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "wrong version"); -+ LOG(ERROR, "wrong version"); - return -1; - } - -@@ -739,7 +734,7 @@ int libxl__toolstack_restore(uint32_t do - - if (size < sizeof(version) + sizeof(count) + - count * (sizeof(struct libxl__physmap_info))) { -- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "wrong size"); -+ LOG(ERROR, "wrong size"); - return -1; - } - -@@ -988,15 +983,13 @@ static void switch_logdirty_done(libxl__ - int libxl__domain_suspend_device_model(libxl__gc *gc, - libxl__domain_suspend_state *dss) - { -- libxl_ctx *ctx = libxl__gc_owner(gc); - int ret = 0; - uint32_t const domid = dss->domid; - const char *const filename = dss->dm_savefile; - - switch (libxl__device_model_version_running(gc, domid)) { - case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: { -- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, -- "Saving device model state to %s", filename); -+ LOG(DEBUG, "Saving device model state to %s", filename); - libxl__qemu_traditional_cmd(gc, domid, "save"); - libxl__wait_for_device_model(gc, domid, "paused", NULL, NULL, NULL); - break; -@@ -1172,8 +1165,7 @@ int libxl__domain_suspend_common_callbac - static inline char *physmap_path(libxl__gc *gc, uint32_t domid, - char *phys_offset, char *node) - { -- return libxl__sprintf(gc, -- "/local/domain/0/device-model/%d/physmap/%s/%s", -+ return GCSPRINTF("/local/domain/0/device-model/%d/physmap/%s/%s", - domid, phys_offset, node); - } - -@@ -1190,7 +1182,7 @@ int libxl__toolstack_save(uint32_t domid - char **entries = NULL; - struct libxl__physmap_info *pi; - -- entries = libxl__xs_directory(gc, 0, libxl__sprintf(gc, -+ entries = libxl__xs_directory(gc, 0, GCSPRINTF( - "/local/domain/0/device-model/%d/physmap", domid), &num); - count = num; - -@@ -1331,7 +1323,7 @@ void libxl__domain_suspend(libxl__egc *e - char *path; - char *addr; - -- path = libxl__sprintf(gc, "%s/hvmloader/generation-id-address", -+ path = GCSPRINTF("%s/hvmloader/generation-id-address", - libxl__xs_get_dompath(gc, domid)); - addr = libxl__xs_read(gc, XBT_NULL, path); - -@@ -1545,10 +1537,7 @@ static void domain_suspend_done(libxl__e - - char *libxl__uuid2string(libxl__gc *gc, const libxl_uuid uuid) - { -- char *s = libxl__sprintf(gc, LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid)); -- if (!s) -- LIBXL__LOG(libxl__gc_owner(gc), LIBXL__LOG_ERROR, "cannot allocate for uuid"); -- return s; -+ return GCSPRINTF(LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid)); - } - - static const char *userdata_path(libxl__gc *gc, uint32_t domid, -@@ -1556,34 +1545,27 @@ static const char *userdata_path(libxl__ - const char *wh) - { - libxl_ctx *ctx = libxl__gc_owner(gc); -- char *path, *uuid_string; -+ char *uuid_string; - libxl_dominfo info; - int rc; - - rc = libxl_domain_info(ctx, &info, domid); - if (rc) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to find domain info" -- " for domain %"PRIu32, domid); -+ LOGE(ERROR, "unable to find domain info for domain %"PRIu32, domid); - return NULL; - } -- uuid_string = libxl__sprintf(gc, LIBXL_UUID_FMT, LIBXL_UUID_BYTES(info.uuid)); -+ uuid_string = GCSPRINTF(LIBXL_UUID_FMT, LIBXL_UUID_BYTES(info.uuid)); - -- path = libxl__sprintf(gc, "/var/lib/xen/" -- "userdata-%s.%u.%s.%s", -- wh, domid, uuid_string, userdata_userid); -- if (!path) -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to allocate for" -- " userdata path"); -- return path; -+ return GCSPRINTF("/var/lib/xen/userdata-%s.%u.%s.%s", -+ wh, domid, uuid_string, userdata_userid); - } - - static int userdata_delete(libxl__gc *gc, const char *path) - { -- libxl_ctx *ctx = libxl__gc_owner(gc); - int r; - r = unlink(path); - if (r) { -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "remove failed for %s", path); -+ LOGE(ERROR, "remove failed for %s", path); - return errno; - } - return 0; -@@ -1591,7 +1573,6 @@ static int userdata_delete(libxl__gc *gc - - void libxl__userdata_destroyall(libxl__gc *gc, uint32_t domid) - { -- libxl_ctx *ctx = libxl__gc_owner(gc); - const char *pattern; - glob_t gl; - int r, i; -@@ -1607,7 +1588,7 @@ void libxl__userdata_destroyall(libxl__g - if (r == GLOB_NOMATCH) - goto out; - if (r) -- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "glob failed for %s", pattern); -+ LOGE(ERROR, "glob failed for %s", pattern); - - for (i=0; i -# Date 1361176078 -3600 -# Node ID 4c3355d776e115f979fd2abc135bb77ba710f0d4 -# Parent 217a4fc4cd46e8de06f2f43eed727838891e9398 -x86/VMX: fix live migration while enabling APICV - -SVI should be restored in case guest is processing virtual interrupt -while saveing a domain state. Otherwise SVI would be missed when -virtual interrupt delivery is enabled. - -Signed-off-by: Jiongxi Li -Acked-by: Eddie Dong -Acked-by: Jun Nakajima -Committed-by: Jan Beulich - ---- a/xen/arch/x86/hvm/vlapic.c -+++ b/xen/arch/x86/hvm/vlapic.c -@@ -1194,6 +1194,9 @@ static int lapic_load_regs(struct domain - if ( hvm_load_entry(LAPIC_REGS, h, s->regs) != 0 ) - return -EINVAL; - -+ if ( hvm_funcs.process_isr ) -+ hvm_funcs.process_isr(vlapic_find_highest_isr(s), v); -+ - vlapic_adjust_i8259_target(d); - lapic_rearm(s); - return 0; ---- a/xen/arch/x86/hvm/vmx/intr.c -+++ b/xen/arch/x86/hvm/vmx/intr.c -@@ -290,8 +290,8 @@ void vmx_intr_assist(void) - vmx_set_eoi_exit_bitmap(v, pt_vector); - - /* we need update the RVI field */ -- status &= ~(unsigned long)0x0FF; -- status |= (unsigned long)0x0FF & -+ status &= ~VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK; -+ status |= VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK & - intack.vector; - __vmwrite(GUEST_INTR_STATUS, status); - if (v->arch.hvm_vmx.eoi_exitmap_changed) { ---- a/xen/arch/x86/hvm/vmx/vmx.c -+++ b/xen/arch/x86/hvm/vmx/vmx.c -@@ -1523,6 +1523,29 @@ static int vmx_virtual_intr_delivery_ena - return cpu_has_vmx_virtual_intr_delivery; - } - -+static void vmx_process_isr(int isr, struct vcpu *v) -+{ -+ unsigned long status; -+ u8 old; -+ -+ if ( !cpu_has_vmx_virtual_intr_delivery ) -+ return; -+ -+ if ( isr < 0 ) -+ isr = 0; -+ -+ vmx_vmcs_enter(v); -+ status = __vmread(GUEST_INTR_STATUS); -+ old = status >> VMX_GUEST_INTR_STATUS_SVI_OFFSET; -+ if ( isr != old ) -+ { -+ status &= VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK; -+ status |= isr << VMX_GUEST_INTR_STATUS_SVI_OFFSET; -+ __vmwrite(GUEST_INTR_STATUS, status); -+ } -+ vmx_vmcs_exit(v); -+} -+ - static struct hvm_function_table __read_mostly vmx_function_table = { - .name = "VMX", - .cpu_up_prepare = vmx_cpu_up_prepare, -@@ -1571,7 +1594,8 @@ static struct hvm_function_table __read_ - .nhvm_intr_blocked = nvmx_intr_blocked, - .nhvm_domain_relinquish_resources = nvmx_domain_relinquish_resources, - .update_eoi_exit_bitmap = vmx_update_eoi_exit_bitmap, -- .virtual_intr_delivery_enabled = vmx_virtual_intr_delivery_enabled -+ .virtual_intr_delivery_enabled = vmx_virtual_intr_delivery_enabled, -+ .process_isr = vmx_process_isr, - }; - - struct hvm_function_table * __init start_vmx(void) ---- a/xen/include/asm-x86/hvm/hvm.h -+++ b/xen/include/asm-x86/hvm/hvm.h -@@ -184,6 +184,7 @@ struct hvm_function_table { - /* Virtual interrupt delivery */ - void (*update_eoi_exit_bitmap)(struct vcpu *v, u8 vector, u8 trig); - int (*virtual_intr_delivery_enabled)(void); -+ void (*process_isr)(int isr, struct vcpu *v); - }; - - extern struct hvm_function_table hvm_funcs; ---- a/xen/include/asm-x86/hvm/vmx/vmcs.h -+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h -@@ -246,6 +246,10 @@ extern bool_t cpu_has_vmx_ins_outs_instr - #define VMX_INTR_SHADOW_SMI 0x00000004 - #define VMX_INTR_SHADOW_NMI 0x00000008 - -+/* Guest interrupt status */ -+#define VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK 0x0FF -+#define VMX_GUEST_INTR_STATUS_SVI_OFFSET 8 -+ - /* VMCS field encodings. */ - enum vmcs_field { - VIRTUAL_PROCESSOR_ID = 0x00000000, diff --git a/26577-x86-APICV-x2APIC.patch b/26577-x86-APICV-x2APIC.patch deleted file mode 100644 index 0abdb53..0000000 --- a/26577-x86-APICV-x2APIC.patch +++ /dev/null @@ -1,248 +0,0 @@ -References: FATE#313605 - -# HG changeset patch -# User Jiongxi Li -# Date 1361176458 -3600 -# Node ID 45d59b822ed187c535b127679e32853b148ed411 -# Parent 4c3355d776e115f979fd2abc135bb77ba710f0d4 -x86/VMX: fix VMCS setting for x2APIC mode guest while enabling APICV - -The "APIC-register virtualization" and "virtual-interrupt deliver" -VM-execution control has no effect on the behavior of RDMSR/WRMSR if -the "virtualize x2APIC mode" VM-execution control is 0. -When guest uses x2APIC mode, we should enable "virtualize x2APIC mode" -for APICV first. - -Signed-off-by: Jiongxi Li -Acked-by: Eddie Dong -Acked-by: Jun Nakajima -Committed-by: Jan Beulich - -Index: xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vmcs.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/hvm/vmx/vmcs.c -+++ xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vmcs.c -@@ -194,7 +194,8 @@ static int vmx_init_vmcs_config(void) - */ - if ( _vmx_cpu_based_exec_control & CPU_BASED_TPR_SHADOW ) - opt |= SECONDARY_EXEC_APIC_REGISTER_VIRT | -- SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY; -+ SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | -+ SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE; - - - _vmx_secondary_exec_control = adjust_vmx_controls( -@@ -673,19 +674,59 @@ void vmx_disable_intercept_for_msr(struc - */ - if ( msr <= 0x1fff ) - { -- if (type & MSR_TYPE_R) -- __clear_bit(msr, msr_bitmap + 0x000/BYTES_PER_LONG); /* read-low */ -- if (type & MSR_TYPE_W) -- __clear_bit(msr, msr_bitmap + 0x800/BYTES_PER_LONG); /* write-low */ -+ if ( type & MSR_TYPE_R ) -+ clear_bit(msr, msr_bitmap + 0x000/BYTES_PER_LONG); /* read-low */ -+ if ( type & MSR_TYPE_W ) -+ clear_bit(msr, msr_bitmap + 0x800/BYTES_PER_LONG); /* write-low */ - } - else if ( (msr >= 0xc0000000) && (msr <= 0xc0001fff) ) - { - msr &= 0x1fff; -- if (type & MSR_TYPE_R) -- __clear_bit(msr, msr_bitmap + 0x400/BYTES_PER_LONG); /* read-high */ -- if (type & MSR_TYPE_W) -- __clear_bit(msr, msr_bitmap + 0xc00/BYTES_PER_LONG); /* write-high */ -+ if ( type & MSR_TYPE_R ) -+ clear_bit(msr, msr_bitmap + 0x400/BYTES_PER_LONG); /* read-high */ -+ if ( type & MSR_TYPE_W ) -+ clear_bit(msr, msr_bitmap + 0xc00/BYTES_PER_LONG); /* write-high */ - } -+ else -+ HVM_DBG_LOG(DBG_LEVEL_0, -+ "msr %x is out of the control range" -+ "0x00000000-0x00001fff and 0xc0000000-0xc0001fff" -+ "RDMSR or WRMSR will cause a VM exit", msr); -+} -+ -+void vmx_enable_intercept_for_msr(struct vcpu *v, u32 msr, int type) -+{ -+ unsigned long *msr_bitmap = v->arch.hvm_vmx.msr_bitmap; -+ -+ /* VMX MSR bitmap supported? */ -+ if ( msr_bitmap == NULL ) -+ return; -+ -+ /* -+ * See Intel PRM Vol. 3, 20.6.9 (MSR-Bitmap Address). Early manuals -+ * have the write-low and read-high bitmap offsets the wrong way round. -+ * We can control MSRs 0x00000000-0x00001fff and 0xc0000000-0xc0001fff. -+ */ -+ if ( msr <= 0x1fff ) -+ { -+ if ( type & MSR_TYPE_R ) -+ set_bit(msr, msr_bitmap + 0x000/BYTES_PER_LONG); /* read-low */ -+ if ( type & MSR_TYPE_W ) -+ set_bit(msr, msr_bitmap + 0x800/BYTES_PER_LONG); /* write-low */ -+ } -+ else if ( (msr >= 0xc0000000) && (msr <= 0xc0001fff) ) -+ { -+ msr &= 0x1fff; -+ if ( type & MSR_TYPE_R ) -+ set_bit(msr, msr_bitmap + 0x400/BYTES_PER_LONG); /* read-high */ -+ if ( type & MSR_TYPE_W ) -+ set_bit(msr, msr_bitmap + 0xc00/BYTES_PER_LONG); /* write-high */ -+ } -+ else -+ HVM_DBG_LOG(DBG_LEVEL_0, -+ "msr %x is out of the control range" -+ "0x00000000-0x00001fff and 0xc0000000-0xc0001fff" -+ "RDMSR or WRMSR will cause a VM exit", msr); - } - - /* -@@ -751,6 +792,10 @@ static int construct_vmcs(struct vcpu *v - vmentry_ctl &= ~VM_ENTRY_LOAD_GUEST_PAT; - } - -+ /* Disable Virtualize x2APIC mode by default. */ -+ v->arch.hvm_vmx.secondary_exec_control &= -+ ~SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE; -+ - /* Do not enable Monitor Trap Flag unless start single step debug */ - v->arch.hvm_vmx.exec_control &= ~CPU_BASED_MONITOR_TRAP_FLAG; - -@@ -787,18 +832,6 @@ static int construct_vmcs(struct vcpu *v - vmx_disable_intercept_for_msr(v, MSR_IA32_SYSENTER_EIP, MSR_TYPE_R | MSR_TYPE_W); - if ( cpu_has_vmx_pat && paging_mode_hap(d) ) - vmx_disable_intercept_for_msr(v, MSR_IA32_CR_PAT, MSR_TYPE_R | MSR_TYPE_W); -- if ( cpu_has_vmx_apic_reg_virt ) -- { -- int msr; -- for (msr = MSR_IA32_APICBASE_MSR; msr <= MSR_IA32_APICBASE_MSR + 0xff; msr++) -- vmx_disable_intercept_for_msr(v, msr, MSR_TYPE_R); -- } -- if ( cpu_has_vmx_virtual_intr_delivery ) -- { -- vmx_disable_intercept_for_msr(v, MSR_IA32_APICTPR_MSR, MSR_TYPE_W); -- vmx_disable_intercept_for_msr(v, MSR_IA32_APICEOI_MSR, MSR_TYPE_W); -- vmx_disable_intercept_for_msr(v, MSR_IA32_APICSELF_MSR, MSR_TYPE_W); -- } - } - - /* I/O access bitmap. */ -Index: xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vmx.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/hvm/vmx/vmx.c -+++ xen-4.2.2-testing/xen/arch/x86/hvm/vmx/vmx.c -@@ -2012,18 +2012,63 @@ static void vmx_install_vlapic_mapping(s - - void vmx_vlapic_msr_changed(struct vcpu *v) - { -+ int virtualize_x2apic_mode; - struct vlapic *vlapic = vcpu_vlapic(v); - -- if ( !cpu_has_vmx_virtualize_apic_accesses ) -+ virtualize_x2apic_mode = ( (cpu_has_vmx_apic_reg_virt || -+ cpu_has_vmx_virtual_intr_delivery) && -+ cpu_has_vmx_virtualize_x2apic_mode ); -+ -+ if ( !cpu_has_vmx_virtualize_apic_accesses && -+ !virtualize_x2apic_mode ) - return; - - vmx_vmcs_enter(v); - v->arch.hvm_vmx.secondary_exec_control &= -- ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; -+ ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | -+ SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE); - if ( !vlapic_hw_disabled(vlapic) && - (vlapic_base_address(vlapic) == APIC_DEFAULT_PHYS_BASE) ) -- v->arch.hvm_vmx.secondary_exec_control |= -- SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; -+ { -+ unsigned int msr; -+ -+ if ( virtualize_x2apic_mode && vlapic_x2apic_mode(vlapic) ) -+ { -+ v->arch.hvm_vmx.secondary_exec_control |= -+ SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE; -+ if ( cpu_has_vmx_apic_reg_virt ) -+ { -+ for ( msr = MSR_IA32_APICBASE_MSR; -+ msr <= MSR_IA32_APICBASE_MSR + 0xff; msr++ ) -+ vmx_disable_intercept_for_msr(v, msr, MSR_TYPE_R); -+ -+ vmx_enable_intercept_for_msr(v, MSR_IA32_APICPPR_MSR, -+ MSR_TYPE_R); -+ vmx_enable_intercept_for_msr(v, MSR_IA32_APICTMICT_MSR, -+ MSR_TYPE_R); -+ vmx_enable_intercept_for_msr(v, MSR_IA32_APICTMCCT_MSR, -+ MSR_TYPE_R); -+ } -+ if ( cpu_has_vmx_virtual_intr_delivery ) -+ { -+ vmx_disable_intercept_for_msr(v, MSR_IA32_APICTPR_MSR, -+ MSR_TYPE_W); -+ vmx_disable_intercept_for_msr(v, MSR_IA32_APICEOI_MSR, -+ MSR_TYPE_W); -+ vmx_disable_intercept_for_msr(v, MSR_IA32_APICSELF_MSR, -+ MSR_TYPE_W); -+ } -+ } -+ else -+ { -+ v->arch.hvm_vmx.secondary_exec_control |= -+ SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; -+ for ( msr = MSR_IA32_APICBASE_MSR; -+ msr <= MSR_IA32_APICBASE_MSR + 0xff; msr++ ) -+ vmx_enable_intercept_for_msr(v, msr, -+ MSR_TYPE_R | MSR_TYPE_W); -+ } -+ } - vmx_update_secondary_exec_control(v); - vmx_vmcs_exit(v); - } -Index: xen-4.2.2-testing/xen/include/asm-x86/hvm/vmx/vmcs.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/hvm/vmx/vmcs.h -+++ xen-4.2.2-testing/xen/include/asm-x86/hvm/vmx/vmcs.h -@@ -182,6 +182,7 @@ extern u32 vmx_vmentry_control; - #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001 - #define SECONDARY_EXEC_ENABLE_EPT 0x00000002 - #define SECONDARY_EXEC_ENABLE_RDTSCP 0x00000008 -+#define SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE 0x00000010 - #define SECONDARY_EXEC_ENABLE_VPID 0x00000020 - #define SECONDARY_EXEC_WBINVD_EXITING 0x00000040 - #define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080 -@@ -239,6 +240,8 @@ extern bool_t cpu_has_vmx_ins_outs_instr - (vmx_secondary_exec_control & SECONDARY_EXEC_APIC_REGISTER_VIRT) - #define cpu_has_vmx_virtual_intr_delivery \ - (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY) -+#define cpu_has_vmx_virtualize_x2apic_mode \ -+ (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE) - - /* GUEST_INTERRUPTIBILITY_INFO flags. */ - #define VMX_INTR_SHADOW_STI 0x00000001 -@@ -414,6 +417,7 @@ enum vmcs_field { - #define MSR_TYPE_R 1 - #define MSR_TYPE_W 2 - void vmx_disable_intercept_for_msr(struct vcpu *v, u32 msr, int type); -+void vmx_enable_intercept_for_msr(struct vcpu *v, u32 msr, int type); - int vmx_read_guest_msr(u32 msr, u64 *val); - int vmx_write_guest_msr(u32 msr, u64 val); - int vmx_add_guest_msr(u32 msr); -Index: xen-4.2.2-testing/xen/include/asm-x86/msr-index.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/msr-index.h -+++ xen-4.2.2-testing/xen/include/asm-x86/msr-index.h -@@ -295,7 +295,10 @@ - #define MSR_IA32_APICBASE_BASE (0xfffff<<12) - #define MSR_IA32_APICBASE_MSR 0x800 - #define MSR_IA32_APICTPR_MSR 0x808 -+#define MSR_IA32_APICPPR_MSR 0x80a - #define MSR_IA32_APICEOI_MSR 0x80b -+#define MSR_IA32_APICTMICT_MSR 0x838 -+#define MSR_IA32_APICTMCCT_MSR 0x839 - #define MSR_IA32_APICSELF_MSR 0x83f - - #define MSR_IA32_UCODE_WRITE 0x00000079 diff --git a/26675-tools-xentoollog_update_tty_detection_in_stdiostream_progress.patch b/26675-tools-xentoollog_update_tty_detection_in_stdiostream_progress.patch deleted file mode 100644 index 667fa84..0000000 --- a/26675-tools-xentoollog_update_tty_detection_in_stdiostream_progress.patch +++ /dev/null @@ -1,43 +0,0 @@ -changeset: 26675:3eb62c576a1a -user: Olaf Hering -date: Wed Feb 27 14:16:36 2013 +0000 -files: tools/libxc/xtl_logger_stdio.c -description: -tools/xentoollog: update tty detection in stdiostream_progress - -As suggested by IanJ: -Check isatty only once to preserve the errno of ->progress users, and to -reduce the noice in strace output. - -Signed-off-by: Olaf Hering -Acked-by: Ian Jackson - - -diff -r 4b25c1e6cfbb -r 3eb62c576a1a tools/libxc/xtl_logger_stdio.c ---- a/tools/libxc/xtl_logger_stdio.c Wed Feb 27 11:16:47 2013 +0000 -+++ b/tools/libxc/xtl_logger_stdio.c Wed Feb 27 14:16:36 2013 +0000 -@@ -35,6 +35,7 @@ struct xentoollog_logger_stdiostream { - xentoollog_level min_level; - unsigned flags; - int progress_erase_len, progress_last_percent; -+ int tty; - }; - - static void progress_erase(xentoollog_logger_stdiostream *lg) { -@@ -118,7 +119,7 @@ static void stdiostream_progress(struct - - lg->progress_last_percent = percent; - -- if (isatty(fileno(lg->f)) <= 0) { -+ if (!lg->tty) { - stdiostream_message(logger_in, this_level, context, - "%s: %lu/%lu %3d%%", - doing_what, done, total, percent); -@@ -166,6 +167,7 @@ xentoollog_logger_stdiostream *xtl_creat - newlogger.f = f; - newlogger.min_level = min_level; - newlogger.flags = flags; -+ newlogger.tty = isatty(fileno(newlogger.f)) > 0; - - if (newlogger.flags & XTL_STDIOSTREAM_SHOW_DATE) tzset(); - diff --git a/26891-x86-S3-Fix-cpu-pool-scheduling-after-suspend-resume.patch b/26891-x86-S3-Fix-cpu-pool-scheduling-after-suspend-resume.patch deleted file mode 100644 index b5ff963..0000000 --- a/26891-x86-S3-Fix-cpu-pool-scheduling-after-suspend-resume.patch +++ /dev/null @@ -1,144 +0,0 @@ -# Commit 9aa356bc9f7533c3cb7f02c823f532532876d444 -# Date 2013-04-19 12:29:01 +0200 -# Author Ben Guthro -# Committer Jan Beulich -x86/S3: Fix cpu pool scheduling after suspend/resume - -This review is another S3 scheduler problem with the system_state -variable introduced with the following changeset: -http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=269f543ea750ed567d18f2e819e5d5ce58eda5c5 - -Specifically, the cpu_callback function that takes the CPU down during -suspend, and back up during resume. We were seeing situations where, -after S3, only CPU0 was in cpupool0. Guest performance suffered -greatly, since all vcpus were only on a single pcpu. Guests under high -CPU load showed the problem much more quickly than an idle guest. - -Removing this if condition forces the CPUs to go through the expected -online/offline state, and be properly scheduled after S3. - -This also includes a necessary partial change proposed earlier by -Tomasz Wroblewski here: -http://lists.xen.org/archives/html/xen-devel/2013-01/msg02206.html - -It should also resolve the issues discussed in this thread: -http://lists.xen.org/archives/html/xen-devel/2012-11/msg01801.html - -Signed-off-by: Ben Guthro -Acked-by: Juergen Gross - ---- a/xen/common/cpupool.c -+++ b/xen/common/cpupool.c -@@ -41,16 +41,28 @@ static struct cpupool *alloc_cpupool_str - { - struct cpupool *c = xzalloc(struct cpupool); - -- if ( c && zalloc_cpumask_var(&c->cpu_valid) ) -- return c; -- xfree(c); -- return NULL; -+ if ( !c || !zalloc_cpumask_var(&c->cpu_valid) ) -+ { -+ xfree(c); -+ c = NULL; -+ } -+ else if ( !zalloc_cpumask_var(&c->cpu_suspended) ) -+ { -+ free_cpumask_var(c->cpu_valid); -+ xfree(c); -+ c = NULL; -+ } -+ -+ return c; - } - - static void free_cpupool_struct(struct cpupool *c) - { - if ( c ) -+ { -+ free_cpumask_var(c->cpu_suspended); - free_cpumask_var(c->cpu_valid); -+ } - xfree(c); - } - -@@ -417,14 +429,32 @@ void cpupool_rm_domain(struct domain *d) - - /* - * called to add a new cpu to pool admin -- * we add a hotplugged cpu to the cpupool0 to be able to add it to dom0 -+ * we add a hotplugged cpu to the cpupool0 to be able to add it to dom0, -+ * unless we are resuming from S3, in which case we put the cpu back -+ * in the cpupool it was in prior to suspend. - */ - static void cpupool_cpu_add(unsigned int cpu) - { - spin_lock(&cpupool_lock); - cpumask_clear_cpu(cpu, &cpupool_locked_cpus); - cpumask_set_cpu(cpu, &cpupool_free_cpus); -- cpupool_assign_cpu_locked(cpupool0, cpu); -+ -+ if ( system_state == SYS_STATE_resume ) -+ { -+ struct cpupool **c; -+ -+ for_each_cpupool(c) -+ { -+ if ( cpumask_test_cpu(cpu, (*c)->cpu_suspended ) ) -+ { -+ cpupool_assign_cpu_locked(*c, cpu); -+ cpumask_clear_cpu(cpu, (*c)->cpu_suspended); -+ } -+ } -+ } -+ -+ if ( cpumask_test_cpu(cpu, &cpupool_free_cpus) ) -+ cpupool_assign_cpu_locked(cpupool0, cpu); - spin_unlock(&cpupool_lock); - } - -@@ -436,7 +466,7 @@ static void cpupool_cpu_add(unsigned int - static int cpupool_cpu_remove(unsigned int cpu) - { - int ret = 0; -- -+ - spin_lock(&cpupool_lock); - if ( !cpumask_test_cpu(cpu, cpupool0->cpu_valid)) - ret = -EBUSY; -@@ -633,9 +663,14 @@ static int cpu_callback( - unsigned int cpu = (unsigned long)hcpu; - int rc = 0; - -- if ( (system_state == SYS_STATE_suspend) || -- (system_state == SYS_STATE_resume) ) -- goto out; -+ if ( system_state == SYS_STATE_suspend ) -+ { -+ struct cpupool **c; -+ -+ for_each_cpupool(c) -+ if ( cpumask_test_cpu(cpu, (*c)->cpu_valid ) ) -+ cpumask_set_cpu(cpu, (*c)->cpu_suspended); -+ } - - switch ( action ) - { -@@ -650,7 +685,6 @@ static int cpu_callback( - break; - } - --out: - return !rc ? NOTIFY_DONE : notifier_from_errno(rc); - } - ---- a/xen/include/xen/sched-if.h -+++ b/xen/include/xen/sched-if.h -@@ -199,6 +199,7 @@ struct cpupool - { - int cpupool_id; - cpumask_var_t cpu_valid; /* all cpus assigned to pool */ -+ cpumask_var_t cpu_suspended; /* cpus in S3 that should be in this pool */ - struct cpupool *next; - unsigned int n_dom; - struct scheduler *sched; diff --git a/26902-x86-EFI-pass-boot-services-variable-info-to-runtime-code.patch b/26902-x86-EFI-pass-boot-services-variable-info-to-runtime-code.patch deleted file mode 100644 index cd4d4e6..0000000 --- a/26902-x86-EFI-pass-boot-services-variable-info-to-runtime-code.patch +++ /dev/null @@ -1,142 +0,0 @@ -References: FATE#314499, FATE#314509 - -# Commit 9be8a4447103d92843fcfeaad8be42408c90e9a9 -# Date 2013-04-22 13:58:01 +0200 -# Author Jan Beulich -# Committer Jan Beulich -x86/EFI: pass boot services variable info to runtime code - -EFI variables can be flagged as being accessible only within boot services. -This makes it awkward for us to figure out how much space they use at -runtime. In theory we could figure this out by simply comparing the results -from QueryVariableInfo() to the space used by all of our variables, but -that fails if the platform doesn't garbage collect on every boot. Thankfully, -calling QueryVariableInfo() while still inside boot services gives a more -reliable answer. This patch passes that information from the EFI boot stub -up to the efi platform code. - -Based on a similarly named Linux patch by Matthew Garrett . - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser -Acked-by: George Dunlap - ---- a/xen/arch/x86/efi/boot.c -+++ b/xen/arch/x86/efi/boot.c -@@ -1128,6 +1128,23 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY - if (efi.smbios != EFI_INVALID_TABLE_ADDR) - dmi_efi_get_table((void *)(long)efi.smbios); - -+ /* Get snapshot of variable store parameters. */ -+ status = efi_rs->QueryVariableInfo(EFI_VARIABLE_NON_VOLATILE | -+ EFI_VARIABLE_BOOTSERVICE_ACCESS | -+ EFI_VARIABLE_RUNTIME_ACCESS, -+ &efi_boot_max_var_store_size, -+ &efi_boot_remain_var_store_size, -+ &efi_boot_max_var_size); -+ if ( EFI_ERROR(status) ) -+ { -+ efi_boot_max_var_store_size = 0; -+ efi_boot_remain_var_store_size = 0; -+ efi_boot_max_var_size = status; -+ PrintStr(L"Warning: Could not query variable store: "); -+ DisplayUint(status, 0); -+ PrintStr(newline); -+ } -+ - /* Allocate space for trampoline (in first Mb). */ - cfg.addr = 0x100000; - cfg.size = trampoline_end - trampoline_start; ---- a/xen/arch/x86/efi/efi.h -+++ b/xen/arch/x86/efi/efi.h -@@ -22,5 +22,8 @@ extern void *efi_memmap; - - extern l4_pgentry_t *efi_l4_pgtable; - -+extern UINT64 efi_boot_max_var_store_size, efi_boot_remain_var_store_size, -+ efi_boot_max_var_size; -+ - unsigned long efi_rs_enter(void); - void efi_rs_leave(unsigned long); ---- a/xen/arch/x86/efi/runtime.c -+++ b/xen/arch/x86/efi/runtime.c -@@ -28,6 +28,10 @@ UINTN __read_mostly efi_memmap_size; - UINTN __read_mostly efi_mdesc_size; - void *__read_mostly efi_memmap; - -+UINT64 __read_mostly efi_boot_max_var_store_size; -+UINT64 __read_mostly efi_boot_remain_var_store_size; -+UINT64 __read_mostly efi_boot_max_var_size; -+ - struct efi __read_mostly efi = { - .acpi = EFI_INVALID_TABLE_ADDR, - .acpi20 = EFI_INVALID_TABLE_ADDR, -@@ -446,6 +450,35 @@ int efi_runtime_call(struct xenpf_efi_ru - break; - - case XEN_EFI_query_variable_info: -+ if ( op->misc & ~XEN_EFI_VARINFO_BOOT_SNAPSHOT ) -+ return -EINVAL; -+ -+ if ( op->misc & XEN_EFI_VARINFO_BOOT_SNAPSHOT ) -+ { -+ if ( (op->u.query_variable_info.attr -+ & ~EFI_VARIABLE_APPEND_WRITE) != -+ (EFI_VARIABLE_NON_VOLATILE | -+ EFI_VARIABLE_BOOTSERVICE_ACCESS | -+ EFI_VARIABLE_RUNTIME_ACCESS) ) -+ return -EINVAL; -+ -+ op->u.query_variable_info.max_store_size = -+ efi_boot_max_var_store_size; -+ op->u.query_variable_info.remain_store_size = -+ efi_boot_remain_var_store_size; -+ if ( efi_boot_max_var_store_size ) -+ { -+ op->u.query_variable_info.max_size = efi_boot_max_var_size; -+ status = EFI_SUCCESS; -+ } -+ else -+ { -+ op->u.query_variable_info.max_size = 0; -+ status = efi_boot_max_var_size; -+ } -+ break; -+ } -+ - cr3 = efi_rs_enter(); - if ( (efi_rs->Hdr.Revision >> 16) < 2 ) - { -@@ -462,6 +495,9 @@ int efi_runtime_call(struct xenpf_efi_ru - - case XEN_EFI_query_capsule_capabilities: - case XEN_EFI_update_capsule: -+ if ( op->misc ) -+ return -EINVAL; -+ - cr3 = efi_rs_enter(); - if ( (efi_rs->Hdr.Revision >> 16) < 2 ) - { ---- a/xen/include/efi/efiapi.h -+++ b/xen/include/efi/efiapi.h -@@ -213,6 +213,10 @@ VOID - #define EFI_VARIABLE_NON_VOLATILE 0x00000001 - #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 - #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 -+#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 -+#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010 -+#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020 -+#define EFI_VARIABLE_APPEND_WRITE 0x00000040 - - // Variable size limitation - #define EFI_MAXIMUM_VARIABLE_SIZE 1024 ---- a/xen/include/public/platform.h -+++ b/xen/include/public/platform.h -@@ -184,6 +184,7 @@ struct xenpf_efi_runtime_call { - struct xenpf_efi_guid vendor_guid; - } get_next_variable_name; - -+#define XEN_EFI_VARINFO_BOOT_SNAPSHOT 0x00000001 - struct { - uint32_t attr; - uint64_t max_store_size; diff --git a/26930-x86-EFI-fix-runtime-call-status-for-compat-mode-Dom0.patch b/26930-x86-EFI-fix-runtime-call-status-for-compat-mode-Dom0.patch deleted file mode 100644 index 315e098..0000000 --- a/26930-x86-EFI-fix-runtime-call-status-for-compat-mode-Dom0.patch +++ /dev/null @@ -1,23 +0,0 @@ -# Commit a7ac9597a7fc6ca934957eb78b41e26638281953 -# Date 2013-04-29 11:27:54 +0200 -# Author Jan Beulich -# Committer Jan Beulich -x86/EFI: fix runtime call status for compat mode Dom0 - -The top two bits (indicating error/warning classification) need to -remain the top two bits. - -Signed-off-by: Jan Beulich -Acked-by: Keir Fraser - ---- a/xen/arch/x86/efi/runtime.c -+++ b/xen/arch/x86/efi/runtime.c -@@ -513,7 +513,7 @@ int efi_runtime_call(struct xenpf_efi_ru - #ifndef COMPAT - op->status = status; - #else -- op->status = (status & 0x3fffffff) | (status >> 62); -+ op->status = (status & 0x3fffffff) | ((status >> 32) & 0xc0000000); - #endif - - return rc; diff --git a/32on64-extra-mem.patch b/32on64-extra-mem.patch deleted file mode 100644 index 8b42aa9..0000000 --- a/32on64-extra-mem.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: xen-4.2.2-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -2985,7 +2985,7 @@ class XendDomainInfo: - - self.guest_bitsize = self.image.getBitSize() - # Make sure there's enough RAM available for the domain -- balloon.free(memory + shadow + vtd_mem, self) -+ balloon.free(memory + shadow + vtd_mem + 512, self) - - # Set up the shadow memory - shadow_cur = xc.shadow_mem_control(self.domid, shadow / 1024) diff --git a/CVE-2013-1918-xsa45-1-vcpu-destroy-pagetables-preemptible.patch b/CVE-2013-1918-xsa45-1-vcpu-destroy-pagetables-preemptible.patch deleted file mode 100644 index 8710f96..0000000 --- a/CVE-2013-1918-xsa45-1-vcpu-destroy-pagetables-preemptible.patch +++ /dev/null @@ -1,262 +0,0 @@ -x86: make vcpu_destroy_pagetables() preemptible - -... as it may take significant amounts of time. - -The function, being moved to mm.c as the better home for it anyway, and -to avoid having to make a new helper function there non-static, is -given a "preemptible" parameter temporarily (until, in a subsequent -patch, its other caller is also being made capable of dealing with -preemption). - -This is part of CVE-2013-1918 / XSA-45. - -Signed-off-by: Jan Beulich -Acked-by: Tim Deegan - -Index: xen-4.2.1-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/domain.c -+++ xen-4.2.1-testing/xen/arch/x86/domain.c -@@ -73,8 +73,6 @@ void (*dead_idle) (void) __read_mostly = - static void paravirt_ctxt_switch_from(struct vcpu *v); - static void paravirt_ctxt_switch_to(struct vcpu *v); - --static void vcpu_destroy_pagetables(struct vcpu *v); -- - static void default_idle(void) - { - local_irq_disable(); -@@ -1058,7 +1056,7 @@ void arch_vcpu_reset(struct vcpu *v) - if ( !is_hvm_vcpu(v) ) - { - destroy_gdt(v); -- vcpu_destroy_pagetables(v); -+ vcpu_destroy_pagetables(v, 0); - } - else - { -@@ -2069,63 +2067,6 @@ static int relinquish_memory( - return ret; - } - --static void vcpu_destroy_pagetables(struct vcpu *v) --{ -- struct domain *d = v->domain; -- unsigned long pfn; -- --#ifdef __x86_64__ -- if ( is_pv_32on64_vcpu(v) ) -- { -- pfn = l4e_get_pfn(*(l4_pgentry_t *) -- __va(pagetable_get_paddr(v->arch.guest_table))); -- -- if ( pfn != 0 ) -- { -- if ( paging_mode_refcounts(d) ) -- put_page(mfn_to_page(pfn)); -- else -- put_page_and_type(mfn_to_page(pfn)); -- } -- -- l4e_write( -- (l4_pgentry_t *)__va(pagetable_get_paddr(v->arch.guest_table)), -- l4e_empty()); -- -- v->arch.cr3 = 0; -- return; -- } --#endif -- -- pfn = pagetable_get_pfn(v->arch.guest_table); -- if ( pfn != 0 ) -- { -- if ( paging_mode_refcounts(d) ) -- put_page(mfn_to_page(pfn)); -- else -- put_page_and_type(mfn_to_page(pfn)); -- v->arch.guest_table = pagetable_null(); -- } -- --#ifdef __x86_64__ -- /* Drop ref to guest_table_user (from MMUEXT_NEW_USER_BASEPTR) */ -- pfn = pagetable_get_pfn(v->arch.guest_table_user); -- if ( pfn != 0 ) -- { -- if ( !is_pv_32bit_vcpu(v) ) -- { -- if ( paging_mode_refcounts(d) ) -- put_page(mfn_to_page(pfn)); -- else -- put_page_and_type(mfn_to_page(pfn)); -- } -- v->arch.guest_table_user = pagetable_null(); -- } --#endif -- -- v->arch.cr3 = 0; --} -- - int domain_relinquish_resources(struct domain *d) - { - int ret; -@@ -2143,7 +2084,11 @@ int domain_relinquish_resources(struct d - - /* Drop the in-use references to page-table bases. */ - for_each_vcpu ( d, v ) -- vcpu_destroy_pagetables(v); -+ { -+ ret = vcpu_destroy_pagetables(v, 1); -+ if ( ret ) -+ return ret; -+ } - - if ( !is_hvm_domain(d) ) - { -Index: xen-4.2.1-testing/xen/arch/x86/mm.c -=================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/mm.c -+++ xen-4.2.1-testing/xen/arch/x86/mm.c -@@ -2825,6 +2825,82 @@ static void put_superpage(unsigned long - - #endif - -+static int put_old_guest_table(struct vcpu *v) -+{ -+ int rc; -+ -+ if ( !v->arch.old_guest_table ) -+ return 0; -+ -+ switch ( rc = put_page_and_type_preemptible(v->arch.old_guest_table, 1) ) -+ { -+ case -EINTR: -+ case -EAGAIN: -+ return -EAGAIN; -+ } -+ -+ v->arch.old_guest_table = NULL; -+ -+ return rc; -+} -+ -+int vcpu_destroy_pagetables(struct vcpu *v, bool_t preemptible) -+{ -+ unsigned long mfn = pagetable_get_pfn(v->arch.guest_table); -+ struct page_info *page; -+ int rc = put_old_guest_table(v); -+ -+ if ( rc ) -+ return rc; -+ -+#ifdef __x86_64__ -+ if ( is_pv_32on64_vcpu(v) ) -+ mfn = l4e_get_pfn(*(l4_pgentry_t *)mfn_to_virt(mfn)); -+#endif -+ -+ if ( mfn ) -+ { -+ page = mfn_to_page(mfn); -+ if ( paging_mode_refcounts(v->domain) ) -+ put_page(page); -+ else -+ rc = put_page_and_type_preemptible(page, preemptible); -+ } -+ -+#ifdef __x86_64__ -+ if ( is_pv_32on64_vcpu(v) ) -+ { -+ if ( !rc ) -+ l4e_write( -+ (l4_pgentry_t *)__va(pagetable_get_paddr(v->arch.guest_table)), -+ l4e_empty()); -+ } -+ else -+#endif -+ if ( !rc ) -+ { -+ v->arch.guest_table = pagetable_null(); -+ -+#ifdef __x86_64__ -+ /* Drop ref to guest_table_user (from MMUEXT_NEW_USER_BASEPTR) */ -+ mfn = pagetable_get_pfn(v->arch.guest_table_user); -+ if ( mfn ) -+ { -+ page = mfn_to_page(mfn); -+ if ( paging_mode_refcounts(v->domain) ) -+ put_page(page); -+ else -+ rc = put_page_and_type_preemptible(page, preemptible); -+ } -+ if ( !rc ) -+ v->arch.guest_table_user = pagetable_null(); -+#endif -+ } -+ -+ v->arch.cr3 = 0; -+ -+ return rc; -+} - - int new_guest_cr3(unsigned long mfn) - { -@@ -3011,12 +3087,21 @@ long do_mmuext_op( - unsigned int foreigndom) - { - struct mmuext_op op; -- int rc = 0, i = 0, okay; - unsigned long type; -- unsigned int done = 0; -+ unsigned int i = 0, done = 0; - struct vcpu *curr = current; - struct domain *d = curr->domain; - struct domain *pg_owner; -+ int okay, rc = put_old_guest_table(curr); -+ -+ if ( unlikely(rc) ) -+ { -+ if ( likely(rc == -EAGAIN) ) -+ rc = hypercall_create_continuation( -+ __HYPERVISOR_mmuext_op, "hihi", uops, count, pdone, -+ foreigndom); -+ return rc; -+ } - - if ( unlikely(count & MMU_UPDATE_PREEMPTED) ) - { -Index: xen-4.2.1-testing/xen/arch/x86/x86_64/compat/mm.c -=================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/x86_64/compat/mm.c -+++ xen-4.2.1-testing/xen/arch/x86/x86_64/compat/mm.c -@@ -365,7 +365,7 @@ int compat_mmuext_op(XEN_GUEST_HANDLE(mm - : mcs->call.args[1]; - unsigned int left = arg1 & ~MMU_UPDATE_PREEMPTED; - -- BUG_ON(left == arg1); -+ BUG_ON(left == arg1 && left != i); - BUG_ON(left > count); - guest_handle_add_offset(nat_ops, i - left); - guest_handle_subtract_offset(cmp_uops, left); -Index: xen-4.2.1-testing/xen/include/asm-x86/domain.h -=================================================================== ---- xen-4.2.1-testing.orig/xen/include/asm-x86/domain.h -+++ xen-4.2.1-testing/xen/include/asm-x86/domain.h -@@ -464,6 +464,7 @@ struct arch_vcpu - pagetable_t guest_table_user; /* (MFN) x86/64 user-space pagetable */ - #endif - pagetable_t guest_table; /* (MFN) guest notion of cr3 */ -+ struct page_info *old_guest_table; /* partially destructed pagetable */ - /* guest_table holds a ref to the page, and also a type-count unless - * shadow refcounts are in use */ - pagetable_t shadow_table[4]; /* (MFN) shadow(s) of guest */ -Index: xen-4.2.1-testing/xen/include/asm-x86/mm.h -=================================================================== ---- xen-4.2.1-testing.orig/xen/include/asm-x86/mm.h -+++ xen-4.2.1-testing/xen/include/asm-x86/mm.h -@@ -605,6 +605,7 @@ void audit_domains(void); - int new_guest_cr3(unsigned long pfn); - void make_cr3(struct vcpu *v, unsigned long mfn); - void update_cr3(struct vcpu *v); -+int vcpu_destroy_pagetables(struct vcpu *, bool_t preemptible); - void propagate_page_fault(unsigned long addr, u16 error_code); - void *do_page_walk(struct vcpu *v, unsigned long addr); - diff --git a/CVE-2013-1918-xsa45-2-new-guest-cr3-preemptible.patch b/CVE-2013-1918-xsa45-2-new-guest-cr3-preemptible.patch deleted file mode 100644 index 6174daa..0000000 --- a/CVE-2013-1918-xsa45-2-new-guest-cr3-preemptible.patch +++ /dev/null @@ -1,173 +0,0 @@ -x86: make new_guest_cr3() preemptible - -... as it may take significant amounts of time. - -This is part of CVE-2013-1918 / XSA-45. - -Signed-off-by: Jan Beulich -Acked-by: Tim Deegan - -Index: xen-4.2.1-testing/xen/arch/x86/mm.c -=================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/mm.c -+++ xen-4.2.1-testing/xen/arch/x86/mm.c -@@ -2906,44 +2906,69 @@ int new_guest_cr3(unsigned long mfn) - { - struct vcpu *curr = current; - struct domain *d = curr->domain; -- int okay; -+ int rc; - unsigned long old_base_mfn; - - #ifdef __x86_64__ - if ( is_pv_32on64_domain(d) ) - { -- okay = paging_mode_refcounts(d) -- ? 0 /* Old code was broken, but what should it be? */ -- : mod_l4_entry( -+ rc = paging_mode_refcounts(d) -+ ? -EINVAL /* Old code was broken, but what should it be? */ -+ : mod_l4_entry( - __va(pagetable_get_paddr(curr->arch.guest_table)), - l4e_from_pfn( - mfn, - (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED)), -- pagetable_get_pfn(curr->arch.guest_table), 0, 0, curr) == 0; -- if ( unlikely(!okay) ) -+ pagetable_get_pfn(curr->arch.guest_table), 0, 1, curr); -+ switch ( rc ) - { -+ case 0: -+ break; -+ case -EINTR: -+ case -EAGAIN: -+ return -EAGAIN; -+ default: - MEM_LOG("Error while installing new compat baseptr %lx", mfn); -- return 0; -+ return rc; - } - - invalidate_shadow_ldt(curr, 0); - write_ptbase(curr); - -- return 1; -+ return 0; - } - #endif -- okay = paging_mode_refcounts(d) -- ? get_page_from_pagenr(mfn, d) -- : !get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d, 0, 0); -- if ( unlikely(!okay) ) -+ rc = put_old_guest_table(curr); -+ if ( unlikely(rc) ) -+ return rc; -+ -+ old_base_mfn = pagetable_get_pfn(curr->arch.guest_table); -+ /* -+ * This is particularly important when getting restarted after the -+ * previous attempt got preempted in the put-old-MFN phase. -+ */ -+ if ( old_base_mfn == mfn ) - { -- MEM_LOG("Error while installing new baseptr %lx", mfn); -+ write_ptbase(curr); - return 0; - } - -- invalidate_shadow_ldt(curr, 0); -+ rc = paging_mode_refcounts(d) -+ ? (get_page_from_pagenr(mfn, d) ? 0 : -EINVAL) -+ : get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d, 0, 1); -+ switch ( rc ) -+ { -+ case 0: -+ break; -+ case -EINTR: -+ case -EAGAIN: -+ return -EAGAIN; -+ default: -+ MEM_LOG("Error while installing new baseptr %lx", mfn); -+ return rc; -+ } - -- old_base_mfn = pagetable_get_pfn(curr->arch.guest_table); -+ invalidate_shadow_ldt(curr, 0); - - curr->arch.guest_table = pagetable_from_pfn(mfn); - update_cr3(curr); -@@ -2952,13 +2977,25 @@ int new_guest_cr3(unsigned long mfn) - - if ( likely(old_base_mfn != 0) ) - { -+ struct page_info *page = mfn_to_page(old_base_mfn); -+ - if ( paging_mode_refcounts(d) ) -- put_page(mfn_to_page(old_base_mfn)); -+ put_page(page); - else -- put_page_and_type(mfn_to_page(old_base_mfn)); -+ switch ( rc = put_page_and_type_preemptible(page, 1) ) -+ { -+ case -EINTR: -+ rc = -EAGAIN; -+ case -EAGAIN: -+ curr->arch.old_guest_table = page; -+ break; -+ default: -+ BUG_ON(rc); -+ break; -+ } - } - -- return 1; -+ return rc; - } - - static struct domain *get_pg_owner(domid_t domid) -@@ -3256,8 +3293,13 @@ long do_mmuext_op( - } - - case MMUEXT_NEW_BASEPTR: -- okay = (!paging_mode_translate(d) -- && new_guest_cr3(op.arg1.mfn)); -+ if ( paging_mode_translate(d) ) -+ okay = 0; -+ else -+ { -+ rc = new_guest_cr3(op.arg1.mfn); -+ okay = !rc; -+ } - break; - - -Index: xen-4.2.1-testing/xen/arch/x86/traps.c -=================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/traps.c -+++ xen-4.2.1-testing/xen/arch/x86/traps.c -@@ -2407,12 +2407,23 @@ static int emulate_privileged_op(struct - #endif - } - page = get_page_from_gfn(v->domain, gfn, NULL, P2M_ALLOC); -- rc = page ? new_guest_cr3(page_to_mfn(page)) : 0; - if ( page ) -+ { -+ rc = new_guest_cr3(page_to_mfn(page)); - put_page(page); -+ } -+ else -+ rc = -EINVAL; - domain_unlock(v->domain); -- if ( rc == 0 ) /* not okay */ -+ switch ( rc ) -+ { -+ case 0: -+ break; -+ case -EAGAIN: /* retry after preemption */ -+ goto skip; -+ default: /* not okay */ - goto fail; -+ } - break; - } - diff --git a/CVE-2013-1918-xsa45-3-new-user-base-preemptible.patch b/CVE-2013-1918-xsa45-3-new-user-base-preemptible.patch deleted file mode 100644 index 86aac80..0000000 --- a/CVE-2013-1918-xsa45-3-new-user-base-preemptible.patch +++ /dev/null @@ -1,76 +0,0 @@ -x86: make MMUEXT_NEW_USER_BASEPTR preemptible - -... as it may take significant amounts of time. - -This is part of CVE-2013-1918 / XSA-45. - -Signed-off-by: Jan Beulich -Acked-by: Tim Deegan - -Index: xen-4.2.1-testing/xen/arch/x86/mm.c -=================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/mm.c -+++ xen-4.2.1-testing/xen/arch/x86/mm.c -@@ -3313,29 +3313,56 @@ long do_mmuext_op( - break; - } - -+ old_mfn = pagetable_get_pfn(curr->arch.guest_table_user); -+ /* -+ * This is particularly important when getting restarted after the -+ * previous attempt got preempted in the put-old-MFN phase. -+ */ -+ if ( old_mfn == op.arg1.mfn ) -+ break; -+ - if ( op.arg1.mfn != 0 ) - { - if ( paging_mode_refcounts(d) ) - okay = get_page_from_pagenr(op.arg1.mfn, d); - else -- okay = !get_page_and_type_from_pagenr( -- op.arg1.mfn, PGT_root_page_table, d, 0, 0); -+ { -+ rc = get_page_and_type_from_pagenr( -+ op.arg1.mfn, PGT_root_page_table, d, 0, 1); -+ okay = !rc; -+ } - if ( unlikely(!okay) ) - { -- MEM_LOG("Error while installing new mfn %lx", op.arg1.mfn); -+ if ( rc == -EINTR ) -+ rc = -EAGAIN; -+ else if ( rc != -EAGAIN ) -+ MEM_LOG("Error while installing new mfn %lx", -+ op.arg1.mfn); - break; - } - } - -- old_mfn = pagetable_get_pfn(curr->arch.guest_table_user); - curr->arch.guest_table_user = pagetable_from_pfn(op.arg1.mfn); - - if ( old_mfn != 0 ) - { -+ struct page_info *page = mfn_to_page(old_mfn); -+ - if ( paging_mode_refcounts(d) ) -- put_page(mfn_to_page(old_mfn)); -+ put_page(page); - else -- put_page_and_type(mfn_to_page(old_mfn)); -+ switch ( rc = put_page_and_type_preemptible(page, 1) ) -+ { -+ case -EINTR: -+ rc = -EAGAIN; -+ case -EAGAIN: -+ curr->arch.old_guest_table = page; -+ okay = 0; -+ break; -+ default: -+ BUG_ON(rc); -+ break; -+ } - } - - break; diff --git a/CVE-2013-1918-xsa45-4-vcpu-reset-preemptible.patch b/CVE-2013-1918-xsa45-4-vcpu-reset-preemptible.patch deleted file mode 100644 index 592a382..0000000 --- a/CVE-2013-1918-xsa45-4-vcpu-reset-preemptible.patch +++ /dev/null @@ -1,218 +0,0 @@ -x86: make vcpu_reset() preemptible - -... as dropping the old page tables may take significant amounts of -time. - -This is part of CVE-2013-1918 / XSA-45. - -Signed-off-by: Jan Beulich -Acked-by: Tim Deegan - -Index: xen-4.2.2-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/domain.c -+++ xen-4.2.2-testing/xen/arch/x86/domain.c -@@ -1051,17 +1051,16 @@ int arch_set_info_guest( - #undef c - } - --void arch_vcpu_reset(struct vcpu *v) -+int arch_vcpu_reset(struct vcpu *v) - { - if ( !is_hvm_vcpu(v) ) - { - destroy_gdt(v); -- vcpu_destroy_pagetables(v, 0); -- } -- else -- { -- vcpu_end_shutdown_deferral(v); -+ return vcpu_destroy_pagetables(v); - } -+ -+ vcpu_end_shutdown_deferral(v); -+ return 0; - } - - /* -@@ -2085,7 +2084,7 @@ int domain_relinquish_resources(struct d - /* Drop the in-use references to page-table bases. */ - for_each_vcpu ( d, v ) - { -- ret = vcpu_destroy_pagetables(v, 1); -+ ret = vcpu_destroy_pagetables(v); - if ( ret ) - return ret; - } -Index: xen-4.2.2-testing/xen/arch/x86/hvm/hvm.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/hvm/hvm.c -+++ xen-4.2.2-testing/xen/arch/x86/hvm/hvm.c -@@ -3577,8 +3577,11 @@ static void hvm_s3_suspend(struct domain - - for_each_vcpu ( d, v ) - { -+ int rc; -+ - vlapic_reset(vcpu_vlapic(v)); -- vcpu_reset(v); -+ rc = vcpu_reset(v); -+ ASSERT(!rc); - } - - vpic_reset(d); -Index: xen-4.2.2-testing/xen/arch/x86/hvm/vlapic.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/hvm/vlapic.c -+++ xen-4.2.2-testing/xen/arch/x86/hvm/vlapic.c -@@ -255,10 +255,13 @@ static void vlapic_init_sipi_action(unsi - { - case APIC_DM_INIT: { - bool_t fpu_initialised; -+ int rc; -+ - domain_lock(target->domain); - /* Reset necessary VCPU state. This does not include FPU state. */ - fpu_initialised = target->fpu_initialised; -- vcpu_reset(target); -+ rc = vcpu_reset(target); -+ ASSERT(!rc); - target->fpu_initialised = fpu_initialised; - vlapic_reset(vcpu_vlapic(target)); - domain_unlock(target->domain); -Index: xen-4.2.2-testing/xen/arch/x86/mm.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/mm.c -+++ xen-4.2.2-testing/xen/arch/x86/mm.c -@@ -2844,7 +2844,7 @@ static int put_old_guest_table(struct vc - return rc; - } - --int vcpu_destroy_pagetables(struct vcpu *v, bool_t preemptible) -+int vcpu_destroy_pagetables(struct vcpu *v) - { - unsigned long mfn = pagetable_get_pfn(v->arch.guest_table); - struct page_info *page; -@@ -2864,7 +2864,7 @@ int vcpu_destroy_pagetables(struct vcpu - if ( paging_mode_refcounts(v->domain) ) - put_page(page); - else -- rc = put_page_and_type_preemptible(page, preemptible); -+ rc = put_page_and_type_preemptible(page, 1); - } - - #ifdef __x86_64__ -@@ -2890,7 +2890,7 @@ int vcpu_destroy_pagetables(struct vcpu - if ( paging_mode_refcounts(v->domain) ) - put_page(page); - else -- rc = put_page_and_type_preemptible(page, preemptible); -+ rc = put_page_and_type_preemptible(page, 1); - } - if ( !rc ) - v->arch.guest_table_user = pagetable_null(); -Index: xen-4.2.2-testing/xen/common/domain.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/common/domain.c -+++ xen-4.2.2-testing/xen/common/domain.c -@@ -779,14 +779,18 @@ void domain_unpause_by_systemcontroller( - domain_unpause(d); - } - --void vcpu_reset(struct vcpu *v) -+int vcpu_reset(struct vcpu *v) - { - struct domain *d = v->domain; -+ int rc; - - vcpu_pause(v); - domain_lock(d); - -- arch_vcpu_reset(v); -+ set_bit(_VPF_in_reset, &v->pause_flags); -+ rc = arch_vcpu_reset(v); -+ if ( rc ) -+ goto out_unlock; - - set_bit(_VPF_down, &v->pause_flags); - -@@ -802,9 +806,13 @@ void vcpu_reset(struct vcpu *v) - #endif - cpumask_clear(v->cpu_affinity_tmp); - clear_bit(_VPF_blocked, &v->pause_flags); -+ clear_bit(_VPF_in_reset, &v->pause_flags); - -+ out_unlock: - domain_unlock(v->domain); - vcpu_unpause(v); -+ -+ return rc; - } - - -Index: xen-4.2.2-testing/xen/common/domctl.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/common/domctl.c -+++ xen-4.2.2-testing/xen/common/domctl.c -@@ -307,8 +307,10 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc - - if ( guest_handle_is_null(op->u.vcpucontext.ctxt) ) - { -- vcpu_reset(v); -- ret = 0; -+ ret = vcpu_reset(v); -+ if ( ret == -EAGAIN ) -+ ret = hypercall_create_continuation( -+ __HYPERVISOR_domctl, "h", u_domctl); - goto svc_out; - } - -Index: xen-4.2.2-testing/xen/include/asm-x86/mm.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/asm-x86/mm.h -+++ xen-4.2.2-testing/xen/include/asm-x86/mm.h -@@ -605,7 +605,7 @@ void audit_domains(void); - int new_guest_cr3(unsigned long pfn); - void make_cr3(struct vcpu *v, unsigned long mfn); - void update_cr3(struct vcpu *v); --int vcpu_destroy_pagetables(struct vcpu *, bool_t preemptible); -+int vcpu_destroy_pagetables(struct vcpu *); - void propagate_page_fault(unsigned long addr, u16 error_code); - void *do_page_walk(struct vcpu *v, unsigned long addr); - -Index: xen-4.2.2-testing/xen/include/xen/domain.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/domain.h -+++ xen-4.2.2-testing/xen/include/xen/domain.h -@@ -13,7 +13,7 @@ typedef union { - struct vcpu *alloc_vcpu( - struct domain *d, unsigned int vcpu_id, unsigned int cpu_id); - struct vcpu *alloc_dom0_vcpu0(void); --void vcpu_reset(struct vcpu *v); -+int vcpu_reset(struct vcpu *); - - struct xen_domctl_getdomaininfo; - void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info); -@@ -67,7 +67,7 @@ void arch_dump_vcpu_info(struct vcpu *v) - - void arch_dump_domain_info(struct domain *d); - --void arch_vcpu_reset(struct vcpu *v); -+int arch_vcpu_reset(struct vcpu *); - - extern spinlock_t vcpu_alloc_lock; - bool_t domctl_lock_acquire(void); -Index: xen-4.2.2-testing/xen/include/xen/sched.h -=================================================================== ---- xen-4.2.2-testing.orig/xen/include/xen/sched.h -+++ xen-4.2.2-testing/xen/include/xen/sched.h -@@ -644,6 +644,9 @@ static inline struct domain *next_domain - /* VCPU is blocked due to missing mem_sharing ring. */ - #define _VPF_mem_sharing 6 - #define VPF_mem_sharing (1UL<<_VPF_mem_sharing) -+ /* VCPU is being reset. */ -+#define _VPF_in_reset 7 -+#define VPF_in_reset (1UL<<_VPF_in_reset) - - static inline int vcpu_runnable(struct vcpu *v) - { diff --git a/CVE-2013-1918-xsa45-5-set-info-guest-preemptible.patch b/CVE-2013-1918-xsa45-5-set-info-guest-preemptible.patch deleted file mode 100644 index 776c1a6..0000000 --- a/CVE-2013-1918-xsa45-5-set-info-guest-preemptible.patch +++ /dev/null @@ -1,212 +0,0 @@ -x86: make arch_set_info_guest() preemptible - -.. as the root page table validation (and the dropping of an eventual -old one) can require meaningful amounts of time. - -This is part of CVE-2013-1918 / XSA-45. - -Signed-off-by: Jan Beulich -Acked-by: Tim Deegan - -Index: xen-4.2.2-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/arch/x86/domain.c -+++ xen-4.2.2-testing/xen/arch/x86/domain.c -@@ -858,6 +858,9 @@ int arch_set_info_guest( - - if ( !v->is_initialised ) - { -+ if ( !compat && !(flags & VGCF_in_kernel) && !c.nat->ctrlreg[1] ) -+ return -EINVAL; -+ - v->arch.pv_vcpu.ldt_base = c(ldt_base); - v->arch.pv_vcpu.ldt_ents = c(ldt_ents); - } -@@ -955,24 +958,44 @@ int arch_set_info_guest( - if ( rc != 0 ) - return rc; - -+ set_bit(_VPF_in_reset, &v->pause_flags); -+ - if ( !compat ) -- { - cr3_gfn = xen_cr3_to_pfn(c.nat->ctrlreg[3]); -- cr3_page = get_page_from_gfn(d, cr3_gfn, NULL, P2M_ALLOC); -- -- if ( !cr3_page ) -- { -- destroy_gdt(v); -- return -EINVAL; -- } -- if ( !paging_mode_refcounts(d) -- && !get_page_type(cr3_page, PGT_base_page_table) ) -- { -- put_page(cr3_page); -- destroy_gdt(v); -- return -EINVAL; -- } -+#ifdef CONFIG_COMPAT -+ else -+ cr3_gfn = compat_cr3_to_pfn(c.cmp->ctrlreg[3]); -+#endif -+ cr3_page = get_page_from_gfn(d, cr3_gfn, NULL, P2M_ALLOC); - -+ if ( !cr3_page ) -+ rc = -EINVAL; -+ else if ( paging_mode_refcounts(d) ) -+ /* nothing */; -+ else if ( cr3_page == v->arch.old_guest_table ) -+ { -+ v->arch.old_guest_table = NULL; -+ put_page(cr3_page); -+ } -+ else -+ { -+ /* -+ * Since v->arch.guest_table{,_user} are both NULL, this effectively -+ * is just a call to put_old_guest_table(). -+ */ -+ if ( !compat ) -+ rc = vcpu_destroy_pagetables(v); -+ if ( !rc ) -+ rc = get_page_type_preemptible(cr3_page, -+ !compat ? PGT_root_page_table -+ : PGT_l3_page_table); -+ if ( rc == -EINTR ) -+ rc = -EAGAIN; -+ } -+ if ( rc ) -+ /* handled below */; -+ else if ( !compat ) -+ { - v->arch.guest_table = pagetable_from_page(cr3_page); - #ifdef __x86_64__ - if ( c.nat->ctrlreg[1] ) -@@ -980,56 +1003,44 @@ int arch_set_info_guest( - cr3_gfn = xen_cr3_to_pfn(c.nat->ctrlreg[1]); - cr3_page = get_page_from_gfn(d, cr3_gfn, NULL, P2M_ALLOC); - -- if ( !cr3_page || -- (!paging_mode_refcounts(d) -- && !get_page_type(cr3_page, PGT_base_page_table)) ) -+ if ( !cr3_page ) -+ rc = -EINVAL; -+ else if ( !paging_mode_refcounts(d) ) - { -- if (cr3_page) -- put_page(cr3_page); -- cr3_page = pagetable_get_page(v->arch.guest_table); -- v->arch.guest_table = pagetable_null(); -- if ( paging_mode_refcounts(d) ) -- put_page(cr3_page); -- else -- put_page_and_type(cr3_page); -- destroy_gdt(v); -- return -EINVAL; -+ rc = get_page_type_preemptible(cr3_page, PGT_root_page_table); -+ switch ( rc ) -+ { -+ case -EINTR: -+ rc = -EAGAIN; -+ case -EAGAIN: -+ v->arch.old_guest_table = -+ pagetable_get_page(v->arch.guest_table); -+ v->arch.guest_table = pagetable_null(); -+ break; -+ } - } -- -- v->arch.guest_table_user = pagetable_from_page(cr3_page); -- } -- else if ( !(flags & VGCF_in_kernel) ) -- { -- destroy_gdt(v); -- return -EINVAL; -+ if ( !rc ) -+ v->arch.guest_table_user = pagetable_from_page(cr3_page); - } - } - else - { - l4_pgentry_t *l4tab; - -- cr3_gfn = compat_cr3_to_pfn(c.cmp->ctrlreg[3]); -- cr3_page = get_page_from_gfn(d, cr3_gfn, NULL, P2M_ALLOC); -- -- if ( !cr3_page) -- { -- destroy_gdt(v); -- return -EINVAL; -- } -- -- if (!paging_mode_refcounts(d) -- && !get_page_type(cr3_page, PGT_l3_page_table) ) -- { -- put_page(cr3_page); -- destroy_gdt(v); -- return -EINVAL; -- } -- - l4tab = __va(pagetable_get_paddr(v->arch.guest_table)); - *l4tab = l4e_from_pfn(page_to_mfn(cr3_page), - _PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED); - #endif - } -+ if ( rc ) -+ { -+ if ( cr3_page ) -+ put_page(cr3_page); -+ destroy_gdt(v); -+ return rc; -+ } -+ -+ clear_bit(_VPF_in_reset, &v->pause_flags); - - if ( v->vcpu_id == 0 ) - update_domain_wallclock_time(d); -Index: xen-4.2.2-testing/xen/common/compat/domain.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/common/compat/domain.c -+++ xen-4.2.2-testing/xen/common/compat/domain.c -@@ -50,6 +50,10 @@ int compat_vcpu_op(int cmd, int vcpuid, - rc = v->is_initialised ? -EEXIST : arch_set_info_guest(v, cmp_ctxt); - domain_unlock(d); - -+ if ( rc == -EAGAIN ) -+ rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iih", -+ cmd, vcpuid, arg); -+ - xfree(cmp_ctxt); - break; - } -Index: xen-4.2.2-testing/xen/common/domain.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/common/domain.c -+++ xen-4.2.2-testing/xen/common/domain.c -@@ -849,6 +849,11 @@ long do_vcpu_op(int cmd, int vcpuid, XEN - domain_unlock(d); - - free_vcpu_guest_context(ctxt); -+ -+ if ( rc == -EAGAIN ) -+ rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iih", -+ cmd, vcpuid, arg); -+ - break; - - case VCPUOP_up: { -Index: xen-4.2.2-testing/xen/common/domctl.c -=================================================================== ---- xen-4.2.2-testing.orig/xen/common/domctl.c -+++ xen-4.2.2-testing/xen/common/domctl.c -@@ -339,6 +339,10 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc - domain_pause(d); - ret = arch_set_info_guest(v, c); - domain_unpause(d); -+ -+ if ( ret == -EAGAIN ) -+ ret = hypercall_create_continuation( -+ __HYPERVISOR_domctl, "h", u_domctl); - } - - svc_out: diff --git a/CVE-2013-1918-xsa45-6-unpin-preemptible.patch b/CVE-2013-1918-xsa45-6-unpin-preemptible.patch deleted file mode 100644 index d7f7253..0000000 --- a/CVE-2013-1918-xsa45-6-unpin-preemptible.patch +++ /dev/null @@ -1,131 +0,0 @@ -x86: make page table unpinning preemptible - -... as it may take significant amounts of time. - -Since we can't re-invoke the operation in a second attempt, the -continuation logic must be slightly tweaked so that we make sure -do_mmuext_op() gets run one more time even when the preempted unpin -operation was the last one in a batch. - -This is part of CVE-2013-1918 / XSA-45. - -Signed-off-by: Jan Beulich -Acked-by: Tim Deegan - -Index: xen-4.2.1-testing/xen/arch/x86/mm.c -=================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/mm.c -+++ xen-4.2.1-testing/xen/arch/x86/mm.c -@@ -3140,6 +3140,14 @@ long do_mmuext_op( - return rc; - } - -+ if ( unlikely(count == MMU_UPDATE_PREEMPTED) && -+ likely(guest_handle_is_null(uops)) ) -+ { -+ /* See the curr->arch.old_guest_table related -+ * hypercall_create_continuation() below. */ -+ return (int)foreigndom; -+ } -+ - if ( unlikely(count & MMU_UPDATE_PREEMPTED) ) - { - count &= ~MMU_UPDATE_PREEMPTED; -@@ -3163,7 +3171,7 @@ long do_mmuext_op( - - for ( i = 0; i < count; i++ ) - { -- if ( hypercall_preempt_check() ) -+ if ( curr->arch.old_guest_table || hypercall_preempt_check() ) - { - rc = -EAGAIN; - break; -@@ -3283,7 +3291,17 @@ long do_mmuext_op( - break; - } - -- put_page_and_type(page); -+ switch ( rc = put_page_and_type_preemptible(page, 1) ) -+ { -+ case -EINTR: -+ case -EAGAIN: -+ curr->arch.old_guest_table = page; -+ rc = 0; -+ break; -+ default: -+ BUG_ON(rc); -+ break; -+ } - put_page(page); - - /* A page is dirtied when its pin status is cleared. */ -@@ -3604,9 +3622,27 @@ long do_mmuext_op( - } - - if ( rc == -EAGAIN ) -+ { -+ ASSERT(i < count); - rc = hypercall_create_continuation( - __HYPERVISOR_mmuext_op, "hihi", - uops, (count - i) | MMU_UPDATE_PREEMPTED, pdone, foreigndom); -+ } -+ else if ( curr->arch.old_guest_table ) -+ { -+ XEN_GUEST_HANDLE(void) null; -+ -+ ASSERT(rc || i == count); -+ set_xen_guest_handle(null, NULL); -+ /* -+ * In order to have a way to communicate the final return value to -+ * our continuation, we pass this in place of "foreigndom", building -+ * on the fact that this argument isn't needed anymore. -+ */ -+ rc = hypercall_create_continuation( -+ __HYPERVISOR_mmuext_op, "hihi", null, -+ MMU_UPDATE_PREEMPTED, null, rc); -+ } - - put_pg_owner(pg_owner); - -Index: xen-4.2.1-testing/xen/arch/x86/x86_64/compat/mm.c -=================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/x86_64/compat/mm.c -+++ xen-4.2.1-testing/xen/arch/x86/x86_64/compat/mm.c -@@ -268,6 +268,13 @@ int compat_mmuext_op(XEN_GUEST_HANDLE(mm - int rc = 0; - XEN_GUEST_HANDLE(mmuext_op_t) nat_ops; - -+ if ( unlikely(count == MMU_UPDATE_PREEMPTED) && -+ likely(guest_handle_is_null(cmp_uops)) ) -+ { -+ set_xen_guest_handle(nat_ops, NULL); -+ return do_mmuext_op(nat_ops, count, pdone, foreigndom); -+ } -+ - preempt_mask = count & MMU_UPDATE_PREEMPTED; - count ^= preempt_mask; - -@@ -370,12 +377,18 @@ int compat_mmuext_op(XEN_GUEST_HANDLE(mm - guest_handle_add_offset(nat_ops, i - left); - guest_handle_subtract_offset(cmp_uops, left); - left = 1; -- BUG_ON(!hypercall_xlat_continuation(&left, 0x01, nat_ops, cmp_uops)); -- BUG_ON(left != arg1); -- if (!test_bit(_MCSF_in_multicall, &mcs->flags)) -- regs->_ecx += count - i; -+ if ( arg1 != MMU_UPDATE_PREEMPTED ) -+ { -+ BUG_ON(!hypercall_xlat_continuation(&left, 0x01, nat_ops, -+ cmp_uops)); -+ if ( !test_bit(_MCSF_in_multicall, &mcs->flags) ) -+ regs->_ecx += count - i; -+ else -+ mcs->compat_call.args[1] += count - i; -+ } - else -- mcs->compat_call.args[1] += count - i; -+ BUG_ON(hypercall_xlat_continuation(&left, 0)); -+ BUG_ON(left != arg1); - } - else - BUG_ON(err > 0); diff --git a/CVE-2013-1918-xsa45-7-mm-error-paths-preemptible.patch b/CVE-2013-1918-xsa45-7-mm-error-paths-preemptible.patch deleted file mode 100644 index 3ec971c..0000000 --- a/CVE-2013-1918-xsa45-7-mm-error-paths-preemptible.patch +++ /dev/null @@ -1,257 +0,0 @@ -x86: make page table handling error paths preemptible - -... as they may take significant amounts of time. - -This requires cloning the tweaked continuation logic from -do_mmuext_op() to do_mmu_update(). - -Note that in mod_l[34]_entry() a negative "preemptible" value gets -passed to put_page_from_l[34]e() now, telling the callee to store the -respective page in current->arch.old_guest_table (for a hypercall -continuation to pick up), rather than carrying out the put right away. -This is going to be made a little more explicit by a subsequent cleanup -patch. - -This is part of CVE-2013-1918 / XSA-45. - -Signed-off-by: Jan Beulich -Acked-by: Tim Deegan - -Index: xen-4.2.1-testing/xen/arch/x86/mm.c -=================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/mm.c -+++ xen-4.2.1-testing/xen/arch/x86/mm.c -@@ -1258,7 +1258,16 @@ static int put_page_from_l3e(l3_pgentry_ - #endif - - if ( unlikely(partial > 0) ) -+ { -+ ASSERT(preemptible >= 0); - return __put_page_type(l3e_get_page(l3e), preemptible); -+ } -+ -+ if ( preemptible < 0 ) -+ { -+ current->arch.old_guest_table = l3e_get_page(l3e); -+ return 0; -+ } - - return put_page_and_type_preemptible(l3e_get_page(l3e), preemptible); - } -@@ -1271,7 +1280,17 @@ static int put_page_from_l4e(l4_pgentry_ - (l4e_get_pfn(l4e) != pfn) ) - { - if ( unlikely(partial > 0) ) -+ { -+ ASSERT(preemptible >= 0); - return __put_page_type(l4e_get_page(l4e), preemptible); -+ } -+ -+ if ( preemptible < 0 ) -+ { -+ current->arch.old_guest_table = l4e_get_page(l4e); -+ return 0; -+ } -+ - return put_page_and_type_preemptible(l4e_get_page(l4e), preemptible); - } - return 1; -@@ -1566,12 +1585,17 @@ static int alloc_l3_table(struct page_in - if ( rc < 0 && rc != -EAGAIN && rc != -EINTR ) - { - MEM_LOG("Failure in alloc_l3_table: entry %d", i); -+ if ( i ) -+ { -+ page->nr_validated_ptes = i; -+ page->partial_pte = 0; -+ current->arch.old_guest_table = page; -+ } - while ( i-- > 0 ) - { - if ( !is_guest_l3_slot(i) ) - continue; - unadjust_guest_l3e(pl3e[i], d); -- put_page_from_l3e(pl3e[i], pfn, 0, 0); - } - } - -@@ -1601,22 +1625,24 @@ static int alloc_l4_table(struct page_in - page->nr_validated_ptes = i; - page->partial_pte = partial ?: 1; - } -- else if ( rc == -EINTR ) -+ else if ( rc < 0 ) - { -+ if ( rc != -EINTR ) -+ MEM_LOG("Failure in alloc_l4_table: entry %d", i); - if ( i ) - { - page->nr_validated_ptes = i; - page->partial_pte = 0; -- rc = -EAGAIN; -+ if ( rc == -EINTR ) -+ rc = -EAGAIN; -+ else -+ { -+ if ( current->arch.old_guest_table ) -+ page->nr_validated_ptes++; -+ current->arch.old_guest_table = page; -+ } - } - } -- else if ( rc < 0 ) -- { -- MEM_LOG("Failure in alloc_l4_table: entry %d", i); -- while ( i-- > 0 ) -- if ( is_guest_l4_slot(d, i) ) -- put_page_from_l4e(pl4e[i], pfn, 0, 0); -- } - if ( rc < 0 ) - return rc; - -@@ -2064,7 +2090,7 @@ static int mod_l3_entry(l3_pgentry_t *pl - pae_flush_pgd(pfn, pgentry_ptr_to_slot(pl3e), nl3e); - } - -- put_page_from_l3e(ol3e, pfn, 0, 0); -+ put_page_from_l3e(ol3e, pfn, 0, -preemptible); - return rc; - } - -@@ -2127,7 +2153,7 @@ static int mod_l4_entry(l4_pgentry_t *pl - return -EFAULT; - } - -- put_page_from_l4e(ol4e, pfn, 0, 0); -+ put_page_from_l4e(ol4e, pfn, 0, -preemptible); - return rc; - } - -@@ -2285,7 +2311,15 @@ static int alloc_page_type(struct page_i - PRtype_info ": caf=%08lx taf=%" PRtype_info, - page_to_mfn(page), get_gpfn_from_mfn(page_to_mfn(page)), - type, page->count_info, page->u.inuse.type_info); -- page->u.inuse.type_info = 0; -+ if ( page != current->arch.old_guest_table ) -+ page->u.inuse.type_info = 0; -+ else -+ { -+ ASSERT((page->u.inuse.type_info & -+ (PGT_count_mask | PGT_validated)) == 1); -+ get_page_light(page); -+ page->u.inuse.type_info |= PGT_partial; -+ } - } - else - { -@@ -3235,21 +3269,17 @@ long do_mmuext_op( - } - - if ( (rc = xsm_memory_pin_page(d, pg_owner, page)) != 0 ) -- { -- put_page_and_type(page); - okay = 0; -- break; -- } -- -- if ( unlikely(test_and_set_bit(_PGT_pinned, -- &page->u.inuse.type_info)) ) -+ else if ( unlikely(test_and_set_bit(_PGT_pinned, -+ &page->u.inuse.type_info)) ) - { - MEM_LOG("Mfn %lx already pinned", page_to_mfn(page)); -- put_page_and_type(page); - okay = 0; -- break; - } - -+ if ( unlikely(!okay) ) -+ goto pin_drop; -+ - /* A page is dirtied when its pin status is set. */ - paging_mark_dirty(pg_owner, page_to_mfn(page)); - -@@ -3263,7 +3293,13 @@ long do_mmuext_op( - &page->u.inuse.type_info)); - spin_unlock(&pg_owner->page_alloc_lock); - if ( drop_ref ) -- put_page_and_type(page); -+ { -+ pin_drop: -+ if ( type == PGT_l1_page_table ) -+ put_page_and_type(page); -+ else -+ curr->arch.old_guest_table = page; -+ } - } - - break; -@@ -3669,11 +3705,28 @@ long do_mmu_update( - void *va; - unsigned long gpfn, gmfn, mfn; - struct page_info *page; -- int rc = 0, i = 0; -- unsigned int cmd, done = 0, pt_dom; -- struct vcpu *v = current; -+ unsigned int cmd, i = 0, done = 0, pt_dom; -+ struct vcpu *curr = current, *v = curr; - struct domain *d = v->domain, *pt_owner = d, *pg_owner; - struct domain_mmap_cache mapcache; -+ int rc = put_old_guest_table(curr); -+ -+ if ( unlikely(rc) ) -+ { -+ if ( likely(rc == -EAGAIN) ) -+ rc = hypercall_create_continuation( -+ __HYPERVISOR_mmu_update, "hihi", ureqs, count, pdone, -+ foreigndom); -+ return rc; -+ } -+ -+ if ( unlikely(count == MMU_UPDATE_PREEMPTED) && -+ likely(guest_handle_is_null(ureqs)) ) -+ { -+ /* See the curr->arch.old_guest_table related -+ * hypercall_create_continuation() below. */ -+ return (int)foreigndom; -+ } - - if ( unlikely(count & MMU_UPDATE_PREEMPTED) ) - { -@@ -3722,7 +3775,7 @@ long do_mmu_update( - - for ( i = 0; i < count; i++ ) - { -- if ( hypercall_preempt_check() ) -+ if ( curr->arch.old_guest_table || hypercall_preempt_check() ) - { - rc = -EAGAIN; - break; -@@ -3903,9 +3956,27 @@ long do_mmu_update( - } - - if ( rc == -EAGAIN ) -+ { -+ ASSERT(i < count); - rc = hypercall_create_continuation( - __HYPERVISOR_mmu_update, "hihi", - ureqs, (count - i) | MMU_UPDATE_PREEMPTED, pdone, foreigndom); -+ } -+ else if ( curr->arch.old_guest_table ) -+ { -+ XEN_GUEST_HANDLE(void) null; -+ -+ ASSERT(rc || i == count); -+ set_xen_guest_handle(null, NULL); -+ /* -+ * In order to have a way to communicate the final return value to -+ * our continuation, we pass this in place of "foreigndom", building -+ * on the fact that this argument isn't needed anymore. -+ */ -+ rc = hypercall_create_continuation( -+ __HYPERVISOR_mmu_update, "hihi", null, -+ MMU_UPDATE_PREEMPTED, null, rc); -+ } - - put_pg_owner(pg_owner); - diff --git a/CVE-2013-1918-xsa45-followup.patch b/CVE-2013-1918-xsa45-followup.patch deleted file mode 100644 index 2e13e7b..0000000 --- a/CVE-2013-1918-xsa45-followup.patch +++ /dev/null @@ -1,406 +0,0 @@ -x86: cleanup after making various page table manipulation operations preemptible - -This drops the "preemptible" parameters from various functions where -now they can't (or shouldn't, validated by assertions) be run in non- -preemptible mode anymore, to prove that manipulations of at least L3 -and L4 page tables and page table entries are now always preemptible, -i.e. the earlier patches actually fulfill their purpose of fixing the -resulting security issue. - -Signed-off-by: Jan Beulich -Acked-by: Tim Deegan - ---- a/xen/arch/x86/domain.c -+++ b/xen/arch/x86/domain.c -@@ -1986,7 +1986,7 @@ static int relinquish_memory( - } - - if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) ) -- ret = put_page_and_type_preemptible(page, 1); -+ ret = put_page_and_type_preemptible(page); - switch ( ret ) - { - case 0: ---- a/xen/arch/x86/mm.c -+++ b/xen/arch/x86/mm.c -@@ -1044,7 +1044,7 @@ get_page_from_l2e( - define_get_linear_pagetable(l3); - static int - get_page_from_l3e( -- l3_pgentry_t l3e, unsigned long pfn, struct domain *d, int partial, int preemptible) -+ l3_pgentry_t l3e, unsigned long pfn, struct domain *d, int partial) - { - int rc; - -@@ -1058,7 +1058,7 @@ get_page_from_l3e( - } - - rc = get_page_and_type_from_pagenr( -- l3e_get_pfn(l3e), PGT_l2_page_table, d, partial, preemptible); -+ l3e_get_pfn(l3e), PGT_l2_page_table, d, partial, 1); - if ( unlikely(rc == -EINVAL) && get_l3_linear_pagetable(l3e, pfn, d) ) - rc = 0; - -@@ -1069,7 +1069,7 @@ get_page_from_l3e( - define_get_linear_pagetable(l4); - static int - get_page_from_l4e( -- l4_pgentry_t l4e, unsigned long pfn, struct domain *d, int partial, int preemptible) -+ l4_pgentry_t l4e, unsigned long pfn, struct domain *d, int partial) - { - int rc; - -@@ -1083,7 +1083,7 @@ get_page_from_l4e( - } - - rc = get_page_and_type_from_pagenr( -- l4e_get_pfn(l4e), PGT_l3_page_table, d, partial, preemptible); -+ l4e_get_pfn(l4e), PGT_l3_page_table, d, partial, 1); - if ( unlikely(rc == -EINVAL) && get_l4_linear_pagetable(l4e, pfn, d) ) - rc = 0; - -@@ -1237,8 +1237,10 @@ static int put_page_from_l2e(l2_pgentry_ - static int __put_page_type(struct page_info *, int preemptible); - - static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, -- int partial, int preemptible) -+ int partial, bool_t defer) - { -+ struct page_info *pg; -+ - if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || (l3e_get_pfn(l3e) == pfn) ) - return 1; - -@@ -1257,41 +1259,45 @@ static int put_page_from_l3e(l3_pgentry_ - } - #endif - -+ pg = l3e_get_page(l3e); -+ - if ( unlikely(partial > 0) ) - { -- ASSERT(preemptible >= 0); -- return __put_page_type(l3e_get_page(l3e), preemptible); -+ ASSERT(!defer); -+ return __put_page_type(pg, 1); - } - -- if ( preemptible < 0 ) -+ if ( defer ) - { -- current->arch.old_guest_table = l3e_get_page(l3e); -+ current->arch.old_guest_table = pg; - return 0; - } - -- return put_page_and_type_preemptible(l3e_get_page(l3e), preemptible); -+ return put_page_and_type_preemptible(pg); - } - - #if CONFIG_PAGING_LEVELS >= 4 - static int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, -- int partial, int preemptible) -+ int partial, bool_t defer) - { - if ( (l4e_get_flags(l4e) & _PAGE_PRESENT) && - (l4e_get_pfn(l4e) != pfn) ) - { -+ struct page_info *pg = l4e_get_page(l4e); -+ - if ( unlikely(partial > 0) ) - { -- ASSERT(preemptible >= 0); -- return __put_page_type(l4e_get_page(l4e), preemptible); -+ ASSERT(!defer); -+ return __put_page_type(pg, 1); - } - -- if ( preemptible < 0 ) -+ if ( defer ) - { -- current->arch.old_guest_table = l4e_get_page(l4e); -+ current->arch.old_guest_table = pg; - return 0; - } - -- return put_page_and_type_preemptible(l4e_get_page(l4e), preemptible); -+ return put_page_and_type_preemptible(pg); - } - return 1; - } -@@ -1509,7 +1515,7 @@ static int alloc_l2_table(struct page_in - return rc > 0 ? 0 : rc; - } - --static int alloc_l3_table(struct page_info *page, int preemptible) -+static int alloc_l3_table(struct page_info *page) - { - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); -@@ -1556,11 +1562,10 @@ static int alloc_l3_table(struct page_in - rc = get_page_and_type_from_pagenr(l3e_get_pfn(pl3e[i]), - PGT_l2_page_table | - PGT_pae_xen_l2, -- d, partial, preemptible); -+ d, partial, 1); - } - else if ( !is_guest_l3_slot(i) || -- (rc = get_page_from_l3e(pl3e[i], pfn, d, -- partial, preemptible)) > 0 ) -+ (rc = get_page_from_l3e(pl3e[i], pfn, d, partial)) > 0 ) - continue; - - if ( rc == -EAGAIN ) -@@ -1604,7 +1609,7 @@ static int alloc_l3_table(struct page_in - } - - #if CONFIG_PAGING_LEVELS >= 4 --static int alloc_l4_table(struct page_info *page, int preemptible) -+static int alloc_l4_table(struct page_info *page) - { - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); -@@ -1616,8 +1621,7 @@ static int alloc_l4_table(struct page_in - i++, partial = 0 ) - { - if ( !is_guest_l4_slot(d, i) || -- (rc = get_page_from_l4e(pl4e[i], pfn, d, -- partial, preemptible)) > 0 ) -+ (rc = get_page_from_l4e(pl4e[i], pfn, d, partial)) > 0 ) - continue; - - if ( rc == -EAGAIN ) -@@ -1662,7 +1666,7 @@ static int alloc_l4_table(struct page_in - return rc > 0 ? 0 : rc; - } - #else --#define alloc_l4_table(page, preemptible) (-EINVAL) -+#define alloc_l4_table(page) (-EINVAL) - #endif - - -@@ -1714,7 +1718,7 @@ static int free_l2_table(struct page_inf - return err; - } - --static int free_l3_table(struct page_info *page, int preemptible) -+static int free_l3_table(struct page_info *page) - { - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); -@@ -1727,7 +1731,7 @@ static int free_l3_table(struct page_inf - do { - if ( is_guest_l3_slot(i) ) - { -- rc = put_page_from_l3e(pl3e[i], pfn, partial, preemptible); -+ rc = put_page_from_l3e(pl3e[i], pfn, partial, 0); - if ( rc < 0 ) - break; - partial = 0; -@@ -1754,7 +1758,7 @@ static int free_l3_table(struct page_inf - } - - #if CONFIG_PAGING_LEVELS >= 4 --static int free_l4_table(struct page_info *page, int preemptible) -+static int free_l4_table(struct page_info *page) - { - struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); -@@ -1764,7 +1768,7 @@ static int free_l4_table(struct page_inf - - do { - if ( is_guest_l4_slot(d, i) ) -- rc = put_page_from_l4e(pl4e[i], pfn, partial, preemptible); -+ rc = put_page_from_l4e(pl4e[i], pfn, partial, 0); - if ( rc < 0 ) - break; - partial = 0; -@@ -1784,7 +1788,7 @@ static int free_l4_table(struct page_inf - return rc > 0 ? 0 : rc; - } - #else --#define free_l4_table(page, preemptible) (-EINVAL) -+#define free_l4_table(page) (-EINVAL) - #endif - - int page_lock(struct page_info *page) -@@ -2023,7 +2027,6 @@ static int mod_l3_entry(l3_pgentry_t *pl - l3_pgentry_t nl3e, - unsigned long pfn, - int preserve_ad, -- int preemptible, - struct vcpu *vcpu) - { - l3_pgentry_t ol3e; -@@ -2063,7 +2066,7 @@ static int mod_l3_entry(l3_pgentry_t *pl - return rc ? 0 : -EFAULT; - } - -- rc = get_page_from_l3e(nl3e, pfn, d, 0, preemptible); -+ rc = get_page_from_l3e(nl3e, pfn, d, 0); - if ( unlikely(rc < 0) ) - return rc; - rc = 0; -@@ -2090,7 +2093,7 @@ static int mod_l3_entry(l3_pgentry_t *pl - pae_flush_pgd(pfn, pgentry_ptr_to_slot(pl3e), nl3e); - } - -- put_page_from_l3e(ol3e, pfn, 0, -preemptible); -+ put_page_from_l3e(ol3e, pfn, 0, 1); - return rc; - } - -@@ -2101,7 +2104,6 @@ static int mod_l4_entry(l4_pgentry_t *pl - l4_pgentry_t nl4e, - unsigned long pfn, - int preserve_ad, -- int preemptible, - struct vcpu *vcpu) - { - struct domain *d = vcpu->domain; -@@ -2134,7 +2136,7 @@ static int mod_l4_entry(l4_pgentry_t *pl - return rc ? 0 : -EFAULT; - } - -- rc = get_page_from_l4e(nl4e, pfn, d, 0, preemptible); -+ rc = get_page_from_l4e(nl4e, pfn, d, 0); - if ( unlikely(rc < 0) ) - return rc; - rc = 0; -@@ -2153,7 +2155,7 @@ static int mod_l4_entry(l4_pgentry_t *pl - return -EFAULT; - } - -- put_page_from_l4e(ol4e, pfn, 0, -preemptible); -+ put_page_from_l4e(ol4e, pfn, 0, 1); - return rc; - } - -@@ -2275,10 +2277,12 @@ static int alloc_page_type(struct page_i - rc = alloc_l2_table(page, type, preemptible); - break; - case PGT_l3_page_table: -- rc = alloc_l3_table(page, preemptible); -+ ASSERT(preemptible); -+ rc = alloc_l3_table(page); - break; - case PGT_l4_page_table: -- rc = alloc_l4_table(page, preemptible); -+ ASSERT(preemptible); -+ rc = alloc_l4_table(page); - break; - case PGT_seg_desc_page: - rc = alloc_segdesc_page(page); -@@ -2372,10 +2376,12 @@ int free_page_type(struct page_info *pag - if ( !(type & PGT_partial) ) - page->nr_validated_ptes = L3_PAGETABLE_ENTRIES; - #endif -- rc = free_l3_table(page, preemptible); -+ ASSERT(preemptible); -+ rc = free_l3_table(page); - break; - case PGT_l4_page_table: -- rc = free_l4_table(page, preemptible); -+ ASSERT(preemptible); -+ rc = free_l4_table(page); - break; - default: - MEM_LOG("type %lx pfn %lx\n", type, page_to_mfn(page)); -@@ -2866,7 +2872,7 @@ static int put_old_guest_table(struct vc - if ( !v->arch.old_guest_table ) - return 0; - -- switch ( rc = put_page_and_type_preemptible(v->arch.old_guest_table, 1) ) -+ switch ( rc = put_page_and_type_preemptible(v->arch.old_guest_table) ) - { - case -EINTR: - case -EAGAIN: -@@ -2898,7 +2904,7 @@ int vcpu_destroy_pagetables(struct vcpu - if ( paging_mode_refcounts(v->domain) ) - put_page(page); - else -- rc = put_page_and_type_preemptible(page, 1); -+ rc = put_page_and_type_preemptible(page); - } - - #ifdef __x86_64__ -@@ -2924,7 +2930,7 @@ int vcpu_destroy_pagetables(struct vcpu - if ( paging_mode_refcounts(v->domain) ) - put_page(page); - else -- rc = put_page_and_type_preemptible(page, 1); -+ rc = put_page_and_type_preemptible(page); - } - if ( !rc ) - v->arch.guest_table_user = pagetable_null(); -@@ -2953,7 +2959,7 @@ int new_guest_cr3(unsigned long mfn) - l4e_from_pfn( - mfn, - (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED)), -- pagetable_get_pfn(curr->arch.guest_table), 0, 1, curr); -+ pagetable_get_pfn(curr->arch.guest_table), 0, curr); - switch ( rc ) - { - case 0: -@@ -3016,7 +3022,7 @@ int new_guest_cr3(unsigned long mfn) - if ( paging_mode_refcounts(d) ) - put_page(page); - else -- switch ( rc = put_page_and_type_preemptible(page, 1) ) -+ switch ( rc = put_page_and_type_preemptible(page) ) - { - case -EINTR: - rc = -EAGAIN; -@@ -3327,7 +3333,7 @@ long do_mmuext_op( - break; - } - -- switch ( rc = put_page_and_type_preemptible(page, 1) ) -+ switch ( rc = put_page_and_type_preemptible(page) ) - { - case -EINTR: - case -EAGAIN: -@@ -3405,7 +3411,7 @@ long do_mmuext_op( - if ( paging_mode_refcounts(d) ) - put_page(page); - else -- switch ( rc = put_page_and_type_preemptible(page, 1) ) -+ switch ( rc = put_page_and_type_preemptible(page) ) - { - case -EINTR: - rc = -EAGAIN; -@@ -3882,12 +3888,12 @@ long do_mmu_update( - break; - case PGT_l3_page_table: - rc = mod_l3_entry(va, l3e_from_intpte(req.val), mfn, -- cmd == MMU_PT_UPDATE_PRESERVE_AD, 1, v); -+ cmd == MMU_PT_UPDATE_PRESERVE_AD, v); - break; - #if CONFIG_PAGING_LEVELS >= 4 - case PGT_l4_page_table: - rc = mod_l4_entry(va, l4e_from_intpte(req.val), mfn, -- cmd == MMU_PT_UPDATE_PRESERVE_AD, 1, v); -+ cmd == MMU_PT_UPDATE_PRESERVE_AD, v); - break; - #endif - case PGT_writable_page: ---- a/xen/include/asm-x86/mm.h -+++ b/xen/include/asm-x86/mm.h -@@ -384,15 +384,10 @@ static inline void put_page_and_type(str - put_page(page); - } - --static inline int put_page_and_type_preemptible(struct page_info *page, -- int preemptible) -+static inline int put_page_and_type_preemptible(struct page_info *page) - { -- int rc = 0; -+ int rc = put_page_type_preemptible(page); - -- if ( preemptible ) -- rc = put_page_type_preemptible(page); -- else -- put_page_type(page); - if ( likely(rc == 0) ) - put_page(page); - return rc; diff --git a/CVE-2013-1922-xsa48.patch b/CVE-2013-1922-xsa48.patch deleted file mode 100644 index 9a6b923..0000000 --- a/CVE-2013-1922-xsa48.patch +++ /dev/null @@ -1,112 +0,0 @@ -References: bnc#81???? CVE-2013-1922 XSA-48 - -Add -f FMT / --format FMT arg to qemu-nbd - -From: "Daniel P. Berrange" - -Currently the qemu-nbd program will auto-detect the format of -any disk it is given. This behaviour is known to be insecure. -For example, if qemu-nbd initially exposes a 'raw' file to an -unprivileged app, and that app runs - - 'qemu-img create -f qcow2 -o backing_file=/etc/shadow /dev/nbd0' - -then the next time the app is started, the qemu-nbd will now -detect it as a 'qcow2' file and expose /etc/shadow to the -unprivileged app. - -The only way to avoid this is to explicitly tell qemu-nbd what -disk format to use on the command line, completely disabling -auto-detection. This patch adds a '-f' / '--format' arg for -this purpose, mirroring what is already available via qemu-img -and qemu commands. - - qemu-nbd --format raw -p 9000 evil.img - -will now always use raw, regardless of what format 'evil.img' -looks like it contains - -Signed-off-by: Daniel P. Berrange -[Use errx, not err. - Paolo] -Signed-off-by: Paolo Bonzini -Signed-off-by: Stefano Stabellini - -[ This is a security issue, CVE-2013-1922 / XSA-48. ] - ---- a/tools/qemu-xen-dir-remote/qemu-nbd.c -+++ b/tools/qemu-xen-dir-remote/qemu-nbd.c -@@ -247,6 +247,7 @@ out: - int main(int argc, char **argv) - { - BlockDriverState *bs; -+ BlockDriver *drv; - off_t dev_offset = 0; - off_t offset = 0; - uint32_t nbdflags = 0; -@@ -256,7 +257,7 @@ int main(int argc, char **argv) - struct sockaddr_in addr; - socklen_t addr_len = sizeof(addr); - off_t fd_size; -- const char *sopt = "hVb:o:p:rsnP:c:dvk:e:t"; -+ const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:t"; - struct option lopt[] = { - { "help", 0, NULL, 'h' }, - { "version", 0, NULL, 'V' }, -@@ -271,6 +272,7 @@ int main(int argc, char **argv) - { "snapshot", 0, NULL, 's' }, - { "nocache", 0, NULL, 'n' }, - { "shared", 1, NULL, 'e' }, -+ { "format", 1, NULL, 'f' }, - { "persistent", 0, NULL, 't' }, - { "verbose", 0, NULL, 'v' }, - { NULL, 0, NULL, 0 } -@@ -292,6 +294,7 @@ int main(int argc, char **argv) - int max_fd; - int persistent = 0; - pthread_t client_thread; -+ const char *fmt = NULL; - - /* The client thread uses SIGTERM to interrupt the server. A signal - * handler ensures that "qemu-nbd -v -c" exits with a nice status code. -@@ -368,6 +371,9 @@ int main(int argc, char **argv) - errx(EXIT_FAILURE, "Shared device number must be greater than 0\n"); - } - break; -+ case 'f': -+ fmt = optarg; -+ break; - case 't': - persistent = 1; - break; -@@ -478,9 +484,19 @@ int main(int argc, char **argv) - bdrv_init(); - atexit(bdrv_close_all); - -+ if (fmt) { -+ drv = bdrv_find_format(fmt); -+ if (!drv) { -+ errx(EXIT_FAILURE, "Unknown file format '%s'", fmt); -+ } -+ } else { -+ drv = NULL; -+ } -+ - bs = bdrv_new("hda"); - srcpath = argv[optind]; -- if ((ret = bdrv_open(bs, srcpath, flags, NULL)) < 0) { -+ ret = bdrv_open(bs, srcpath, flags, drv); -+ if (ret < 0) { - errno = -ret; - err(EXIT_FAILURE, "Failed to bdrv_open '%s'", argv[optind]); - } ---- a/tools/qemu-xen-dir-remote/qemu-nbd.texi -+++ b/tools/qemu-xen-dir-remote/qemu-nbd.texi -@@ -36,6 +36,8 @@ Export Qemu disk image using NBD protoco - disconnect the specified device - @item -e, --shared=@var{num} - device can be shared by @var{num} clients (default @samp{1}) -+@item -f, --format=@var{fmt} -+ force block driver for format @var{fmt} instead of auto-detecting - @item -t, --persistent - don't exit on the last connection - @item -v, --verbose diff --git a/CVE-2013-1952-xsa49.patch b/CVE-2013-1952-xsa49.patch deleted file mode 100644 index 5a0ef69..0000000 --- a/CVE-2013-1952-xsa49.patch +++ /dev/null @@ -1,57 +0,0 @@ -References: bnc#8161663 CVE-2013-1952 XSA-49 - -VT-d: don't permit SVT_NO_VERIFY entries for known device types - -Only in cases where we don't know what to do we should leave the IRTE -blank (suppressing all validation), but we should always log a warning -in those cases (as being insecure). - -This is CVE-2013-1952 / XSA-49. - -Signed-off-by: Jan Beulich -Acked-by: "Zhang, Xiantao" - -Index: xen-4.2.1-testing/xen/drivers/passthrough/vtd/intremap.c -=================================================================== ---- xen-4.2.1-testing.orig/xen/drivers/passthrough/vtd/intremap.c -+++ xen-4.2.1-testing/xen/drivers/passthrough/vtd/intremap.c -@@ -440,12 +440,9 @@ static void set_msi_source_id(struct pci - { - unsigned int sq; - -+ case DEV_TYPE_PCIe_ENDPOINT: - case DEV_TYPE_PCIe_BRIDGE: - case DEV_TYPE_PCIe2PCI_BRIDGE: -- case DEV_TYPE_LEGACY_PCI_BRIDGE: -- break; -- -- case DEV_TYPE_PCIe_ENDPOINT: - switch ( pdev->phantom_stride ) - { - case 1: sq = SQ_13_IGNORE_3; break; -@@ -457,6 +454,8 @@ static void set_msi_source_id(struct pci - break; - - case DEV_TYPE_PCI: -+ case DEV_TYPE_LEGACY_PCI_BRIDGE: -+ case DEV_TYPE_PCI2PCIe_BRIDGE: - ret = find_upstream_bridge(seg, &bus, &devfn, &secbus); - if ( ret == 0 ) /* integrated PCI device */ - { -@@ -468,10 +467,15 @@ static void set_msi_source_id(struct pci - if ( pdev_type(seg, bus, devfn) == DEV_TYPE_PCIe2PCI_BRIDGE ) - set_ire_sid(ire, SVT_VERIFY_BUS, SQ_ALL_16, - (bus << 8) | pdev->bus); -- else if ( pdev_type(seg, bus, devfn) == DEV_TYPE_LEGACY_PCI_BRIDGE ) -+ else - set_ire_sid(ire, SVT_VERIFY_SID_SQ, SQ_ALL_16, - PCI_BDF2(bus, devfn)); - } -+ else -+ dprintk(XENLOG_WARNING VTDPREFIX, -+ "d%d: no upstream bridge for %04x:%02x:%02x.%u\n", -+ pdev->domain->domain_id, -+ seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); - break; - - default: diff --git a/VNC-Support-for-ExtendedKeyEvent-client-message.patch b/VNC-Support-for-ExtendedKeyEvent-client-message.patch deleted file mode 100644 index 3cf1c65..0000000 --- a/VNC-Support-for-ExtendedKeyEvent-client-message.patch +++ /dev/null @@ -1,157 +0,0 @@ -From 9ca313aa0824f2d350a7a6c9b1ef6c47e0408f1d Mon Sep 17 00:00:00 2001 -From: aliguori -Date: Sat, 23 Aug 2008 23:27:37 +0000 -Subject: [PATCH] VNC: Support for ExtendedKeyEvent client message - -This patch adds support for the ExtendedKeyEvent client message. This message -allows a client to send raw scan codes directly to the server. If the client -and server are using the same keymap, then it's unnecessary to use the '-k' -option with QEMU when this extension is supported. - -This is extension is currently only implemented by gtk-vnc based clients -(gvncviewer, virt-manager, vinagre, etc.). - -Signed-off-by: Anthony Liguori - - - -git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5076 c046a42c-6fe2-441c-8c8c-71466251a162 ---- - vnc.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- - 1 files changed, 50 insertions(+), 9 deletions(-) - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vnc.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/vnc.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vnc.c -@@ -1285,35 +1285,22 @@ static void press_key_altgr_down(VncStat - } - } - --static void do_key_event(VncState *vs, int down, uint32_t sym) -+static void do_key_event(VncState *vs, int down, int keycode, int sym, int shift) - { -- int keycode; - int shift_keys = 0; -- int shift = 0; - int keypad = 0; - int altgr = 0; - int altgr_keys = 0; - - if (is_graphic_console()) { -- if (sym >= 'A' && sym <= 'Z') { -- sym = sym - 'A' + 'a'; -- shift = 1; -- } -- else { -+ if (!shift) - shift = keysym_is_shift(vs->kbd_layout, sym & 0xFFFF); -- } - - altgr = keysym_is_altgr(vs->kbd_layout, sym & 0xFFFF); - } - shift_keys = vs->modifiers_state[0x2a] | vs->modifiers_state[0x36]; - altgr_keys = vs->modifiers_state[0xb8]; - -- keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF); -- if (keycode == 0) { -- fprintf(stderr, "Key lost : keysym=0x%x(%d)\n", sym, sym); -- return; -- } -- - /* QEMU console switch */ - switch(keycode) { - case 0x2a: /* Left Shift */ -@@ -1445,7 +1432,25 @@ static void do_key_event(VncState *vs, i - - static void key_event(VncState *vs, int down, uint32_t sym) - { -- do_key_event(vs, down, sym); -+ int keycode; -+ int shift = 0; -+ -+ if (sym >= 'A' && sym <= 'Z' && is_graphic_console()) { -+ sym = sym - 'A' + 'a'; -+ shift = 1; -+ } -+ keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF); -+ do_key_event(vs, down, keycode, sym, shift); -+} -+ -+static void ext_key_event(VncState *vs, int down, -+ uint32_t sym, uint16_t keycode) -+{ -+ /* if the user specifies a keyboard layout, always use it */ -+ if (keyboard_layout) -+ key_event(vs, down, sym); -+ else -+ do_key_event(vs, down, keycode, sym, 0); - } - - static void framebuffer_set_updated(VncState *vs, int x, int y, int w, int h) -@@ -1534,6 +1539,15 @@ static void framebuffer_update_request(V - qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock)); - } - -+static void send_ext_key_event_ack(VncState *vs) -+{ -+ vnc_write_u8(vs, 0); -+ vnc_write_u8(vs, 0); -+ vnc_write_u16(vs, 1); -+ vnc_framebuffer_update(vs, 0, 0, ds_get_width(vs->ds), ds_get_height(vs->ds), -258); -+ vnc_flush(vs); -+} -+ - static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) - { - int i; -@@ -1562,6 +1576,9 @@ static void set_encodings(VncState *vs, - case -257: - vs->has_pointer_type_change = 1; - break; -+ case -258: -+ send_ext_key_event_ack(vs); -+ break; - case 0x574D5669: - vs->has_WMVi = 1; - default: -@@ -1774,6 +1791,24 @@ static int protocol_client_msg(VncState - - client_cut_text(vs, read_u32(data, 4), (char *)(data + 8)); - break; -+ case 255: -+ if (len == 1) -+ return 2; -+ -+ switch (read_u8(data, 1)) { -+ case 0: -+ if (len == 2) -+ return 12; -+ -+ ext_key_event(vs, read_u16(data, 2), -+ read_u32(data, 4), read_u32(data, 8)); -+ break; -+ default: -+ printf("Msg: %d\n", read_u16(data, 0)); -+ vnc_client_error(vs); -+ break; -+ } -+ break; - default: - printf("Msg: %d\n", data[0]); - vnc_client_error(vs); -@@ -2445,10 +2480,11 @@ void vnc_display_init(DisplayState *ds) - - vs->ds = ds; - -- if (!keyboard_layout) -- keyboard_layout = "en-us"; -+ if (keyboard_layout) -+ vs->kbd_layout = init_keyboard_layout(keyboard_layout); -+ else -+ vs->kbd_layout = init_keyboard_layout("en-us"); - -- vs->kbd_layout = init_keyboard_layout(keyboard_layout); - if (!vs->kbd_layout) - exit(1); - vs->modifiers_state[0x45] = 1; /* NumLock on - on boot */ diff --git a/altgr_2.patch b/altgr_2.patch deleted file mode 100644 index f320c37..0000000 --- a/altgr_2.patch +++ /dev/null @@ -1,45 +0,0 @@ -When access domU from Windows VNC client, spanish keyboard altgr key -doesn't work. According to log info, we found that the keycodes passed -from vncclient to qemu vncserver have something wrong. When altgr and "2" -pressed, keycodes vncserver receives are: -ALT_R down, -CTRL_L down, -CTRL_L up, -ATL_R up, -"2" down, -"2" up, -... -Since when send "2" down, there is no altgr modifier, the char displayed -on screen will be "2" but not "@". - -To solve this problem, there is another patch applied by upstream which -sends an additional altgr modifier before "2" down in the above case. -It works well when domU is windows, but on sles10 sp3 domU, sometimes it -display "@" and sometimes it still displays "2", especially when press -altgr+2 continuously. - -For the sles10 sp3 domU problem, maybe because there are two many alt_r (same -keycode as altgr on "es") up and down events and the domU OS couldn't handle -it well. - -To furtherly solve this problem, I write this patch, when vncserver -is "es" and receives a alt_r keysym (this is already abnormal since "es" has -no alt_r), then treat the alt_r as alt_l. This can avoid too many altgr -keycodes up and down events and make sure the intentionally added altgr keycode can take effect. - -Signed-off by Chunyan Liu (cyliu@novell.com) - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vnc.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/vnc.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vnc.c -@@ -1440,6 +1440,9 @@ static void key_event(VncState *vs, int - int keycode; - int shift = 0; - -+ if ( sym == 0xffea && keyboard_layout && !strcmp(keyboard_layout,"es") ) -+ sym = 0xffe9; -+ - if (sym >= 'A' && sym <= 'Z' && is_graphic_console()) { - sym = sym - 'A' + 'a'; - shift = 1; diff --git a/bdrv_default_rwflag.patch b/bdrv_default_rwflag.patch deleted file mode 100644 index c94a69f..0000000 --- a/bdrv_default_rwflag.patch +++ /dev/null @@ -1,32 +0,0 @@ -Subject: modify default read/write flag in bdrv_init. -Signed-off by Chunyan Liu - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vl.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/vl.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vl.c -@@ -2627,6 +2627,8 @@ int drive_init(struct drive_opt *arg, in - strncpy(drives_table[nb_drives].serial, serial, sizeof(serial)); - nb_drives++; - -+ bdrv_flags = BDRV_O_RDWR; -+ - switch(type) { - case IF_IDE: - case IF_XEN: -@@ -2640,6 +2642,7 @@ int drive_init(struct drive_opt *arg, in - break; - case MEDIA_CDROM: - bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM); -+ bdrv_flags &= ~BDRV_O_RDWR; - break; - } - break; -@@ -2660,7 +2663,6 @@ int drive_init(struct drive_opt *arg, in - } - if (!file[0]) - return -2; -- bdrv_flags = 0; - if (snapshot) { - bdrv_flags |= BDRV_O_SNAPSHOT; - cache = 2; /* always use write-back with snapshot */ diff --git a/bdrv_open2_fix_flags.patch b/bdrv_open2_fix_flags.patch deleted file mode 100644 index e3fc2e6..0000000 --- a/bdrv_open2_fix_flags.patch +++ /dev/null @@ -1,129 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/block.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/block.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/block.c -@@ -350,7 +350,7 @@ int bdrv_file_open(BlockDriverState **pb - - int bdrv_open(BlockDriverState *bs, const char *filename, int flags) - { -- return bdrv_open2(bs, filename, flags, NULL); -+ return bdrv_open2(bs, filename, flags|BDRV_O_RDWR, NULL); - } - - int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, -@@ -419,12 +419,13 @@ int bdrv_open2(BlockDriverState *bs, con - } - bs->drv = drv; - bs->opaque = qemu_mallocz(drv->instance_size); -- /* Note: for compatibility, we open disk image files as RDWR, and -- RDONLY as fallback */ - if (!(flags & BDRV_O_FILE)) -- open_flags = (flags & BDRV_O_ACCESS) | (flags & BDRV_O_CACHE_MASK); -+ open_flags = flags; - else - open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); -+ if (!(open_flags & BDRV_O_RDWR)) -+ bs->read_only = 1; -+ - ret = drv->bdrv_open(bs, filename, open_flags); - if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) { - ret = drv->bdrv_open(bs, filename, open_flags & ~BDRV_O_RDWR); -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/usb-msd.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/usb-msd.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/usb-msd.c -@@ -551,7 +551,7 @@ USBDevice *usb_msd_init(const char *file - s = qemu_mallocz(sizeof(MSDState)); - - bdrv = bdrv_new("usb"); -- if (bdrv_open2(bdrv, filename, 0, drv) < 0) -+ if (bdrv_open2(bdrv, filename, BDRV_O_RDWR, drv) < 0) - goto fail; - s->bs = bdrv; - *pbs = bdrv; -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-img.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/qemu-img.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-img.c -@@ -32,7 +32,7 @@ - #endif - - /* Default to cache=writeback as data integrity is not important for qemu-tcg. */ --#define BRDV_O_FLAGS BDRV_O_CACHE_WB -+#define BDRV_O_FLAGS BDRV_O_CACHE_WB - - static void QEMU_NORETURN error(const char *fmt, ...) - { -@@ -185,7 +185,7 @@ static int read_password(char *buf, int - #endif - - static BlockDriverState *bdrv_new_open(const char *filename, -- const char *fmt) -+ const char *fmt, int flags) - { - BlockDriverState *bs; - BlockDriver *drv; -@@ -201,7 +201,7 @@ static BlockDriverState *bdrv_new_open(c - } else { - drv = &bdrv_raw; - } -- if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { -+ if (bdrv_open2(bs, filename, flags, drv) < 0) { - error("Could not open '%s'", filename); - } - if (bdrv_is_encrypted(bs)) { -@@ -253,7 +253,7 @@ static int img_create(int argc, char **a - size = 0; - if (base_filename) { - BlockDriverState *bs; -- bs = bdrv_new_open(base_filename, NULL); -+ bs = bdrv_new_open(base_filename, NULL, BDRV_O_RDWR); - bdrv_get_geometry(bs, &size); - size *= 512; - bdrv_delete(bs); -@@ -332,7 +332,7 @@ static int img_commit(int argc, char **a - } else { - drv = NULL; - } -- if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { -+ if (bdrv_open2(bs, filename, BDRV_O_RDWR, drv) < 0) { - error("Could not open '%s'", filename); - } - ret = bdrv_commit(bs); -@@ -455,7 +455,8 @@ static int img_convert(int argc, char ** - - total_sectors = 0; - for (bs_i = 0; bs_i < bs_n; bs_i++) { -- bs[bs_i] = bdrv_new_open(argv[optind + bs_i], fmt); -+ bs[bs_i] = bdrv_new_open(argv[optind + bs_i], fmt, -+ BDRV_O_CACHE_WB|BDRV_O_RDONLY); - if (!bs[bs_i]) - error("Could not open '%s'", argv[optind + bs_i]); - bdrv_get_geometry(bs[bs_i], &bs_sectors); -@@ -483,7 +484,7 @@ static int img_convert(int argc, char ** - } - } - -- out_bs = bdrv_new_open(out_filename, out_fmt); -+ out_bs = bdrv_new_open(out_filename, out_fmt, BDRV_O_CACHE_WB|BDRV_O_RDWR); - - bs_i = 0; - bs_offset = 0; -@@ -706,7 +707,7 @@ static int img_info(int argc, char **arg - } else { - drv = NULL; - } -- if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { -+ if (bdrv_open2(bs, filename, BDRV_O_FLAGS|BDRV_O_RDWR, drv) < 0) { - error("Could not open '%s'", filename); - } - bdrv_get_format(bs, fmt_name, sizeof(fmt_name)); -@@ -810,7 +811,7 @@ static void img_snapshot(int argc, char - if (!bs) - error("Not enough memory"); - -- if (bdrv_open2(bs, filename, 0, NULL) < 0) { -+ if (bdrv_open2(bs, filename, BDRV_O_RDWR, NULL) < 0) { - error("Could not open '%s'", filename); - } - diff --git a/bdrv_open2_flags_2.patch b/bdrv_open2_flags_2.patch deleted file mode 100644 index dbf5c29..0000000 --- a/bdrv_open2_flags_2.patch +++ /dev/null @@ -1,72 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -@@ -225,6 +225,7 @@ static int open_disk(struct td_state *s, - BlockDriver* drv; - char* devname; - static int devnumber = 0; -+ int flags = readonly ? BDRV_O_RDONLY : BDRV_O_RDWR; - int i; - - DPRINTF("Opening %s as blktap%d\n", path, devnumber); -@@ -247,7 +248,7 @@ static int open_disk(struct td_state *s, - DPRINTF("%s driver specified\n", drv ? drv->format_name : "No"); - - /* Open the image */ -- if (bdrv_open2(bs, path, 0, drv) != 0) { -+ if (bdrv_open2(bs, path, flags, drv) != 0) { - fprintf(stderr, "Could not open image file %s\n", path); - return -ENOMEM; - } -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/xenstore.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -@@ -133,7 +133,8 @@ static void insert_media(void *opaque) - else - format = &bdrv_raw; - -- bdrv_open2(bs, media_filename[i], 0, format); -+ /* Temporary BDRV_O_RDWR */ -+ bdrv_open2(bs, media_filename[i], BDRV_O_RDWR, format); - #ifdef CONFIG_STUBDOM - { - char *buf, *backend, *params_path, *params; -@@ -508,7 +509,8 @@ void xenstore_parse_domain_config(int hv - } - - for (i = 0; i < num; i++) { -- format = NULL; /* don't know what the format is yet */ -+ flags = 0; -+ format = NULL; /* don't know what the format is yet */ - /* read the backend path */ - xenstore_get_backend_path(&bpath, "vbd", danger_path, hvm_domid, e_danger[i]); - if (bpath == NULL) -@@ -594,6 +596,17 @@ void xenstore_parse_domain_config(int hv - format = &bdrv_raw; - } - -+ /* read the mode of the device */ -+ if (pasprintf(&buf, "%s/mode", bpath) == -1) -+ continue; -+ free(mode); -+ mode = xs_read(xsh, XBT_NULL, buf, &len); -+ -+ if (!strcmp(mode, "r") || !strcmp(mode, "ro")) -+ flags |= BDRV_O_RDONLY; -+ if (!strcmp(mode, "w") || !strcmp(mode, "rw")) -+ flags |= BDRV_O_RDWR; -+ - #if 0 - /* Phantom VBDs are disabled because the use of paths - * from guest-controlled areas in xenstore is unsafe. -@@ -661,7 +674,7 @@ void xenstore_parse_domain_config(int hv - #ifdef CONFIG_STUBDOM - if (pasprintf(&danger_buf, "%s/device/vbd/%s", danger_path, e_danger[i]) == -1) - continue; -- if (bdrv_open2(bs, danger_buf, BDRV_O_CACHE_WB /* snapshot and write-back */, &bdrv_raw) == 0) { -+ if (bdrv_open2(bs, danger_buf, flags|BDRV_O_CACHE_WB /* snapshot and write-back */, &bdrv_raw) == 0) { - if (pasprintf(&buf, "%s/params", bpath) == -1) - continue; - free(params); diff --git a/blktap-disable-debug-printf.patch b/blktap-disable-debug-printf.patch deleted file mode 100644 index 8c29bef..0000000 --- a/blktap-disable-debug-printf.patch +++ /dev/null @@ -1,27 +0,0 @@ -Index: xen-4.2.0-testing/tools/blktap/drivers/blktapctrl.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/blktap/drivers/blktapctrl.c -+++ xen-4.2.0-testing/tools/blktap/drivers/blktapctrl.c -@@ -61,6 +61,9 @@ - #include "list.h" - #include "xs_api.h" /* for xs_fire_next_watch() */ - -+#undef DPRINTF -+#define DPRINTF(_f, _a...) ((void)0) -+ - #define PIDFILE "/var/run/blktapctrl.pid" - - #define NUM_POLL_FDS 2 -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -@@ -46,7 +46,7 @@ - #define BLKTAP_CTRL_DIR "/var/run/tap" - - /* If enabled, print debug messages to stderr */ --#if 1 -+#if 0 - #define DPRINTF(_f, _a...) fprintf(stderr, __FILE__ ":%d: " _f, __LINE__, ##_a) - #else - #define DPRINTF(_f, _a...) ((void)0) diff --git a/blktap-pv-cdrom.patch b/blktap-pv-cdrom.patch index f4345af..3e8ab2f 100644 --- a/blktap-pv-cdrom.patch +++ b/blktap-pv-cdrom.patch @@ -4,15 +4,14 @@ tools/blktap/drivers/tapdisk.c | 16 tools/blktap/drivers/tapdisk.h | 16 tools/blktap/lib/blktaplib.h | 1 - tools/python/xen/xend/server/BlktapController.py | 1 xen/include/public/io/blkif.h | 2 xen/include/public/io/cdromif.h | 122 ++++ - 8 files changed, 726 insertions(+), 3 deletions(-) + 7 files changed, 726 insertions(+), 3 deletions(-) -Index: xen-4.2.1-testing/tools/blktap/drivers/Makefile +Index: xen-4.3.0-testing/tools/blktap/drivers/Makefile =================================================================== ---- xen-4.2.1-testing.orig/tools/blktap/drivers/Makefile -+++ xen-4.2.1-testing/tools/blktap/drivers/Makefile +--- xen-4.3.0-testing.orig/tools/blktap/drivers/Makefile ++++ xen-4.3.0-testing/tools/blktap/drivers/Makefile @@ -38,8 +38,9 @@ endif CFLAGS += $(PTHREAD_CFLAGS) LDFLAGS += $(PTHREAD_LDFLAGS) @@ -33,10 +32,10 @@ Index: xen-4.2.1-testing/tools/blktap/drivers/Makefile BLK-OBJS-y += aes.o BLK-OBJS-y += tapaio.o BLK-OBJS-$(CONFIG_Linux) += blk_linux.o -Index: xen-4.2.1-testing/tools/blktap/drivers/block-cdrom.c +Index: xen-4.3.0-testing/tools/blktap/drivers/block-cdrom.c =================================================================== --- /dev/null -+++ xen-4.2.1-testing/tools/blktap/drivers/block-cdrom.c ++++ xen-4.3.0-testing/tools/blktap/drivers/block-cdrom.c @@ -0,0 +1,568 @@ +/* block-cdrom.c + * @@ -606,10 +605,10 @@ Index: xen-4.2.1-testing/tools/blktap/drivers/block-cdrom.c + .td_get_parent_id = tdcdrom_get_parent_id, + .td_validate_parent = tdcdrom_validate_parent +}; -Index: xen-4.2.1-testing/tools/blktap/drivers/tapdisk.c +Index: xen-4.3.0-testing/tools/blktap/drivers/tapdisk.c =================================================================== ---- xen-4.2.1-testing.orig/tools/blktap/drivers/tapdisk.c -+++ xen-4.2.1-testing/tools/blktap/drivers/tapdisk.c +--- xen-4.3.0-testing.orig/tools/blktap/drivers/tapdisk.c ++++ xen-4.3.0-testing/tools/blktap/drivers/tapdisk.c @@ -735,6 +735,22 @@ static void get_io_request(struct td_sta goto out; } @@ -633,10 +632,10 @@ Index: xen-4.2.1-testing/tools/blktap/drivers/tapdisk.c default: DPRINTF("Unknown block operation\n"); break; -Index: xen-4.2.1-testing/tools/blktap/drivers/tapdisk.h +Index: xen-4.3.0-testing/tools/blktap/drivers/tapdisk.h =================================================================== ---- xen-4.2.1-testing.orig/tools/blktap/drivers/tapdisk.h -+++ xen-4.2.1-testing/tools/blktap/drivers/tapdisk.h +--- xen-4.3.0-testing.orig/tools/blktap/drivers/tapdisk.h ++++ xen-4.3.0-testing/tools/blktap/drivers/tapdisk.h @@ -137,6 +137,9 @@ struct tap_disk { int (*td_get_parent_id) (struct disk_driver *dd, struct disk_id *id); int (*td_validate_parent)(struct disk_driver *dd, @@ -681,10 +680,10 @@ Index: xen-4.2.1-testing/tools/blktap/drivers/tapdisk.h }; typedef struct driver_list_entry { -Index: xen-4.2.1-testing/tools/blktap/lib/blktaplib.h +Index: xen-4.3.0-testing/tools/blktap/lib/blktaplib.h =================================================================== ---- xen-4.2.1-testing.orig/tools/blktap/lib/blktaplib.h -+++ xen-4.2.1-testing/tools/blktap/lib/blktaplib.h +--- xen-4.3.0-testing.orig/tools/blktap/lib/blktaplib.h ++++ xen-4.3.0-testing/tools/blktap/lib/blktaplib.h @@ -219,6 +219,7 @@ typedef struct msg_pid { #define DISK_TYPE_RAM 3 #define DISK_TYPE_QCOW 4 @@ -693,23 +692,11 @@ Index: xen-4.2.1-testing/tools/blktap/lib/blktaplib.h /* xenstore/xenbus: */ #define DOMNAME "Domain-0" -Index: xen-4.2.1-testing/tools/python/xen/xend/server/BlktapController.py +Index: xen-4.3.0-testing/xen/include/public/io/blkif.h =================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/server/BlktapController.py -+++ xen-4.2.1-testing/tools/python/xen/xend/server/BlktapController.py -@@ -15,6 +15,7 @@ blktap1_disk_types = [ - 'ram', - 'qcow', - 'qcow2', -+ 'cdrom', - 'ioemu', - ] - -Index: xen-4.2.1-testing/xen/include/public/io/blkif.h -=================================================================== ---- xen-4.2.1-testing.orig/xen/include/public/io/blkif.h -+++ xen-4.2.1-testing/xen/include/public/io/blkif.h -@@ -379,7 +379,7 @@ +--- xen-4.3.0-testing.orig/xen/include/public/io/blkif.h ++++ xen-4.3.0-testing/xen/include/public/io/blkif.h +@@ -439,7 +439,7 @@ * Used in SLES sources for device specific command packet * contained within the request. Reserved for that purpose. */ @@ -718,10 +705,10 @@ Index: xen-4.2.1-testing/xen/include/public/io/blkif.h /* * Indicate to the backend device that a region of storage is no longer in * use, and may be discarded at any time without impact to the client. If -Index: xen-4.2.1-testing/xen/include/public/io/cdromif.h +Index: xen-4.3.0-testing/xen/include/public/io/cdromif.h =================================================================== --- /dev/null -+++ xen-4.2.1-testing/xen/include/public/io/cdromif.h ++++ xen-4.3.0-testing/xen/include/public/io/cdromif.h @@ -0,0 +1,122 @@ +/****************************************************************************** + * cdromif.h diff --git a/blktap.patch b/blktap.patch deleted file mode 100644 index a9603c2..0000000 --- a/blktap.patch +++ /dev/null @@ -1,55 +0,0 @@ -bug #239173 -bug #242953 - -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -3317,7 +3317,7 @@ class XendDomainInfo: - (fn, BOOTLOADER_LOOPBACK_DEVICE)) - - vbd = { -- 'mode': 'RO', -+ 'mode': 'RW', - 'device': BOOTLOADER_LOOPBACK_DEVICE, - } - -Index: xen-4.2.1-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/qemu-xen-traditional-dir-remote/xenstore.c -+++ xen-4.2.1-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -@@ -447,9 +447,9 @@ void xenstore_parse_domain_config(int hv - { - char **e_danger = NULL; - char *buf = NULL; -- char *fpath = NULL, *bpath = NULL, -+ char *fpath = NULL, *bpath = NULL, *btype = NULL, - *dev = NULL, *params = NULL, *drv = NULL; -- int i, ret; -+ int i, ret, is_tap; - unsigned int len, num, hd_index, pci_devid = 0; - BlockDriverState *bs; - BlockDriver *format; -@@ -486,6 +486,14 @@ void xenstore_parse_domain_config(int hv - e_danger[i]); - if (bpath == NULL) - continue; -+ /* check to see if type is tap or not */ -+ if (pasprintf(&buf, "%s/type", bpath) == -1) -+ continue; -+ free(btype); -+ btype = xs_read(xsh, XBT_NULL, buf, &len); -+ if (btype == NULL) -+ continue; -+ is_tap = !strncmp(btype, "tap", 3); - /* read the name of the device */ - if (pasprintf(&buf, "%s/dev", bpath) == -1) - continue; -@@ -777,6 +785,7 @@ void xenstore_parse_domain_config(int hv - free(mode); - free(params); - free(dev); -+ free(btype); - free(bpath); - free(buf); - free(danger_buf); diff --git a/blktap-close-fifos.patch b/blktapctrl-close-fifos.patch similarity index 100% rename from blktap-close-fifos.patch rename to blktapctrl-close-fifos.patch diff --git a/blktapctrl-disable-debug-printf.patch b/blktapctrl-disable-debug-printf.patch new file mode 100644 index 0000000..0ccd379 --- /dev/null +++ b/blktapctrl-disable-debug-printf.patch @@ -0,0 +1,14 @@ +Index: xen-4.2.0-testing/tools/blktap/drivers/blktapctrl.c +=================================================================== +--- xen-4.2.0-testing.orig/tools/blktap/drivers/blktapctrl.c ++++ xen-4.2.0-testing/tools/blktap/drivers/blktapctrl.c +@@ -61,6 +61,9 @@ + #include "list.h" + #include "xs_api.h" /* for xs_fire_next_watch() */ + ++#undef DPRINTF ++#define DPRINTF(_f, _a...) ((void)0) ++ + #define PIDFILE "/var/run/blktapctrl.pid" + + #define NUM_POLL_FDS 2 diff --git a/block-dmmd b/block-dmmd index 7ce5d83..c386392 100644 --- a/block-dmmd +++ b/block-dmmd @@ -93,21 +93,36 @@ function deactivate_md() function activate_lvm() { - # First scan for PVs and VGs; we may then have to activate the VG - # first, but can ignore errors: -# /sbin/pvscan || : -# /sbin/vgscan --mknodes || : -# /sbin/vgchange -ay ${1%/*} || : - /sbin/lvchange -ay $1 - if [ $? -eq 0 ]; then - return 0 + local run_timeout=90 + local parsed_timeout + local end_time + + # Parse device-create-timeout from /etc/xen/xend-config.sxp + # If not set, use default timeout of 90s + parsed_timeout=$(grep -v "^[ \t]*#.*" /etc/xen/xend-config.sxp|sed -n 's/(device-create-timeout \+\([0-9]\+\))/\1/p') + if [ ! -z $parsed_timeout ]; then + run_timeout=$((${parsed_timeout}*9/10)) fi + + end_time=$(($(date +%s)+${run_timeout})) + while true; do + /sbin/lvchange -aey $1 + if [ $? -eq 0 -a -e $1 ]; then + return 0 + fi + + sleep 0.1 + if [ $(date +%s) -ge ${end_time} ]; then + log err "Failed to activate $1 within ${run_timeout} seconds" + return 1 + fi + done return 1 } function deactivate_lvm() { - /sbin/lvchange -an $1 + /sbin/lvchange -aen $1 if [ $? -eq 0 ]; then # We may have to deactivate the VG now, but can ignore errors: # /sbin/vgchange -an ${1%/*} || : diff --git a/bridge-bonding.diff b/bridge-bonding.patch similarity index 100% rename from bridge-bonding.diff rename to bridge-bonding.patch diff --git a/bridge-vlan.diff b/bridge-vlan.patch similarity index 100% rename from bridge-vlan.diff rename to bridge-vlan.patch diff --git a/build-tapdisk-ioemu.patch b/build-tapdisk-ioemu.patch deleted file mode 100644 index 5e31357..0000000 --- a/build-tapdisk-ioemu.patch +++ /dev/null @@ -1,140 +0,0 @@ -From f1ebeae7802a5775422004f62630c42e46dcf664 Mon Sep 17 00:00:00 2001 -From: Kevin Wolf -Date: Tue, 10 Mar 2009 16:32:40 +0100 -Subject: [PATCH 3/6] ioemu: Build tapdisk-ioemu binary - -When changing away from the old ioemu, changes in the Makefiles -resulted in tapdisk-ioemu appearing there, but actually not -being built. This patch re-enables the build of tapdisk-ioemu. - -Signed-off-by: Kevin Wolf ---- - Makefile | 22 +++++++++++++++------- - configure | 2 +- - qemu-tool.c | 2 +- - tapdisk-ioemu.c | 17 ----------------- - 4 files changed, 17 insertions(+), 26 deletions(-) - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/Makefile -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile -@@ -46,14 +46,6 @@ $(filter %-user,$(SUBDIR_RULES)): libqem - - recurse-all: $(SUBDIR_RULES) - --CPPFLAGS += -I$(XEN_ROOT)/tools/libxc --CPPFLAGS += -I$(XEN_ROOT)/tools/blktap/lib --CPPFLAGS += -I$(XEN_ROOT)/tools/xenstore --CPPFLAGS += -I$(XEN_ROOT)/tools/include -- --tapdisk-ioemu: tapdisk-ioemu.c cutils.c block.c block-raw.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c block-qcow2.c hw/xen_blktap.c osdep.c -- $(CC) -DQEMU_TOOL $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS) -- - ####################################################################### - # BLOCK_OBJS is code used by both qemu system emulation and qemu-img - -@@ -72,6 +64,21 @@ endif - BLOCK_OBJS += block-raw-posix.o - endif - -+####################################################################### -+# tapdisk-ioemu -+ -+hw/tapdisk-xen_blktap.o: hw/xen_blktap.c -+ $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_IMG -DQEMU_TOOL -c -o $@ $< -+tapdisk-ioemu.o: tapdisk-ioemu.c -+ $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_IMG -DQEMU_TOOL -c -o $@ $< -+ -+tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/libxc -+tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/blktap/lib -+tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/xenstore -+tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/include -+tapdisk-ioemu: tapdisk-ioemu.o $(BLOCK_OBJS) qemu-tool.o hw/tapdisk-xen_blktap.o -+ $(CC) $(LDFLAGS) -o $@ $^ -lz $(LIBS) -+ - ###################################################################### - # libqemu_common.a: Target independent part of system emulation. The - # long term path is to suppress *all* target specific code in case of -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/configure -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/configure -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/configure -@@ -1511,7 +1511,7 @@ bsd) - ;; - esac - --tools= -+tools="tapdisk-ioemu" - if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then - tools="qemu-img\$(EXESUF) $tools" - if [ "$linux" = "yes" ] ; then -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-tool.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/qemu-tool.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-tool.c -@@ -68,7 +68,7 @@ void qemu_bh_delete(QEMUBH *bh) - qemu_free(bh); - } - --int qemu_set_fd_handler2(int fd, -+int __attribute__((weak)) qemu_set_fd_handler2(int fd, - IOCanRWHandler *fd_read_poll, - IOHandler *fd_read, - IOHandler *fd_write, -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c -@@ -12,34 +12,12 @@ - - extern void qemu_aio_init(void); - extern void qemu_aio_poll(void); --extern void bdrv_init(void); -- --extern void *qemu_mallocz(size_t size); --extern void qemu_free(void *ptr); - - extern void *fd_start; - - int domid = 0; - FILE* logfile; - --void term_printf(const char *fmt, ...) --{ -- va_list ap; -- va_start(ap, fmt); -- vprintf(fmt, ap); -- va_end(ap); --} -- --void term_print_filename(const char *filename) --{ -- term_printf(filename); --} -- -- --typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); --typedef int IOCanRWHandler(void *opaque); --typedef void IOHandler(void *opaque); -- - typedef struct IOHandlerRecord { - int fd; - IOCanRWHandler *fd_read_poll; -@@ -103,7 +81,6 @@ int main(void) - logfile = stderr; - - bdrv_init(); -- qemu_aio_init(); - init_blktap(); - - /* Daemonize */ -@@ -115,8 +92,6 @@ int main(void) - * completed aio operations. - */ - while (1) { -- qemu_aio_poll(); -- - max_fd = -1; - FD_ZERO(&rfds); - for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) diff --git a/capslock_enable.patch b/capslock_enable.patch deleted file mode 100644 index 796c79c..0000000 --- a/capslock_enable.patch +++ /dev/null @@ -1,16 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vnc.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/vnc.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vnc.c -@@ -1329,6 +1329,11 @@ static void do_key_event(VncState *vs, i - } - break; - case 0x3a: /* CapsLock */ -+ if(!down){ -+ vs->modifiers_state[keycode] ^= 1; -+ kbd_put_keycode(keycode | 0x80); -+ } -+ return; - case 0x45: /* NumLock */ - if (down) { - kbd_put_keycode(keycode & 0x7f); diff --git a/cdrom-removable.patch b/cdrom-removable.patch deleted file mode 100644 index 2bfd107..0000000 --- a/cdrom-removable.patch +++ /dev/null @@ -1,496 +0,0 @@ -Index: xen-4.2.0-testing/tools/python/xen/xend/server/HalDaemon.py -=================================================================== ---- /dev/null -+++ xen-4.2.0-testing/tools/python/xen/xend/server/HalDaemon.py -@@ -0,0 +1,243 @@ -+#!/usr/bin/env python -+# -*- mode: python; -*- -+#============================================================================ -+# 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 -+# License as published by the Free Software Foundation. -+# -+# This library 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 -+# Lesser General Public License for more details. -+# -+# You should have received a copy of the GNU Lesser General Public -+# License along with this library; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+#============================================================================ -+# Copyright (C) 2007 Pat Campbell -+# Copyright (C) 2007 Novell Inc. -+#============================================================================ -+ -+"""hald (Hardware Abstraction Layer Daemon) watcher for Xen management -+ of removable block device media. -+ -+""" -+ -+import gobject -+import dbus -+import dbus.glib -+import os -+import types -+import sys -+import signal -+import traceback -+from xen.xend.xenstore.xstransact import xstransact, complete -+from xen.xend.xenstore.xsutil import xshandle -+from xen.xend import PrettyPrint -+from xen.xend import XendLogging -+from xen.xend.XendLogging import log -+ -+DEVICE_TYPES = ['vbd', 'tap'] -+ -+class HalDaemon: -+ """The Hald block device watcher for XEN -+ """ -+ -+ """Default path to the log file. """ -+ logfile_default = "/var/log/xen/hald.log" -+ -+ """Default level of information to be logged.""" -+ loglevel_default = 'INFO' -+ -+ -+ def __init__(self): -+ -+ XendLogging.init(self.logfile_default, self.loglevel_default) -+ log.debug( "%s", "__init__") -+ -+ self.udi_dict = {} -+ self.debug = 0 -+ self.dbpath = "/local/domain/0/backend" -+ self.bus = dbus.SystemBus() -+ self.hal_manager_obj = self.bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/Manager') -+ self.hal_manager = dbus.Interface( self.hal_manager_obj, 'org.freedesktop.Hal.Manager') -+ self.gatherBlockDevices() -+ self.registerDeviceCallbacks() -+ -+ def run(self): -+ log.debug( "%s", "In new run" ); -+ try: -+ self.mainloop = gobject.MainLoop() -+ self.mainloop.run() -+ except KeyboardInterrupt, ex: -+ log.debug('Keyboard exception handler: %s', ex ) -+ self.mainloop.quit() -+ except Exception, ex: -+ log.debug('Generic exception handler: %s', ex ) -+ self.mainloop.quit() -+ -+ def __del__(self): -+ log.debug( "%s", "In del " ); -+ self.unRegisterDeviceCallbacks() -+ self.mainloop.quit() -+ -+ def shutdown(self): -+ log.debug( "%s", "In shutdown now " ); -+ self.unRegisterDeviceCallbacks() -+ self.mainloop.quit() -+ -+ def stop(self): -+ log.debug( "%s", "In stop now " ); -+ self.unRegisterDeviceCallbacks() -+ self.mainloop.quit() -+ -+ def gatherBlockDevices(self): -+ -+ # Get all the current devices from hal and save in a dictionary -+ try: -+ device_names = self.hal_manager.GetAllDevices() -+ i = 0; -+ for name in device_names: -+ #log.debug("device name, device=%s",name) -+ dev_obj = self.bus.get_object ('org.freedesktop.Hal', name) -+ dev = dbus.Interface (dev_obj, 'org.freedesktop.Hal.Device') -+ dev_properties = dev_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") -+ if dev_properties.has_key('block.device'): -+ dev_str = dev_properties['block.device'] -+ dev_major = dev_properties['block.major'] -+ dev_minor = dev_properties['block.minor'] -+ udi_info = {} -+ udi_info['device'] = dev_str -+ udi_info['major'] = dev_major -+ udi_info['minor'] = dev_minor -+ udi_info['udi'] = name -+ self.udi_dict[i] = udi_info -+ i = i + 1 -+ except Exception, ex: -+ print >>sys.stderr, 'Exception gathering block devices:', ex -+ log.warn("Exception gathering block devices (%s)",ex) -+ -+ # -+ def registerDeviceCallbacks(self): -+ # setup the callbacks for when the gdl changes -+ self.hal_manager.connect_to_signal('DeviceAdded', self.device_added_callback) -+ self.hal_manager.connect_to_signal('DeviceRemoved', self.device_removed_callback) -+ -+ # -+ def unRegisterDeviceCallbacks(self): -+ # setup the callbacks for when the gdl changes -+ self.hal_manager.remove_signal_receiver(self.device_added_callback,'DeviceAdded') -+ self.hal_manager.remove_signal_receiver(self.device_removed_callback,'DeviceRemoved') -+ -+ # -+ def device_removed_callback(self,udi): -+ log.debug('UDI %s was removed',udi) -+ self.show_dict(self.udi_dict) -+ for key in self.udi_dict: -+ udi_info = self.udi_dict[key] -+ if udi_info['udi'] == udi: -+ device = udi_info['device'] -+ major = udi_info['major'] -+ minor = udi_info['minor'] -+ self.change_xenstore( "remove", device, major, minor) -+ -+ # Adds device to dictionary if not already there -+ def device_added_callback(self,udi): -+ log.debug('UDI %s was added', udi) -+ self.show_dict(self.udi_dict) -+ dev_obj = self.bus.get_object ('org.freedesktop.Hal', udi) -+ dev = dbus.Interface (dev_obj, 'org.freedesktop.Hal.Device') -+ device = dev.GetProperty ('block.device') -+ major = dev.GetProperty ('block.major') -+ minor = dev.GetProperty ('block.minor') -+ udi_info = {} -+ udi_info['device'] = device -+ udi_info['major'] = major -+ udi_info['minor'] = minor -+ udi_info['udi'] = udi -+ already = 0 -+ cnt = 0; -+ for key in self.udi_dict: -+ info = self.udi_dict[key] -+ if info['udi'] == udi: -+ already = 1 -+ break -+ cnt = cnt + 1 -+ if already == 0: -+ self.udi_dict[cnt] = udi_info; -+ log.debug('UDI %s was added, device:%s major:%s minor:%s index:%d\n', udi, device, major, minor, cnt) -+ self.change_xenstore( "add", device, major, minor) -+ -+ # Debug helper, shows dictionary contents -+ def show_dict(self,dict=None): -+ if self.debug == 0 : -+ return -+ if dict == None : -+ dict = self.udi_dict -+ for key in dict: -+ log.debug('udi_info %s udi_info:%s',key,dict[key]) -+ -+ # Set or clear xenstore media-present depending on the action argument -+ # for every vbd that has this block device -+ def change_xenstore(self,action, device, major, minor): -+ for type in DEVICE_TYPES: -+ path = self.dbpath + '/' + type -+ domains = xstransact.List(path) -+ log.debug('domains: %s', domains) -+ for domain in domains: # for each domain -+ devices = xstransact.List( path + '/' + domain) -+ log.debug('devices: %s',devices) -+ for device in devices: # for each vbd device -+ str = device.split('/') -+ vbd_type = None; -+ vbd_physical_device = None -+ vbd_media = None -+ vbd_device_path = path + '/' + domain + '/' + device -+ listing = xstransact.List(vbd_device_path) -+ for entry in listing: # for each entry -+ item = path + '/' + entry -+ value = xstransact.Read( vbd_device_path + '/' + entry) -+ log.debug('%s=%s',item,value) -+ if item.find('media-present') != -1: -+ vbd_media = item; -+ vbd_media_path = item -+ if item.find('physical-device') != -1: -+ vbd_physical_device = value; -+ if item.find('type') != -1: -+ 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 = 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): -+ if action == "add": -+ xs_dict = {'media': "1"} -+ xstransact.Write(vbd_device_path, 'media-present', "1" ) -+ log.debug("wrote xenstore media-present 1 path:%s",vbd_media_path) -+ else: -+ xstransact.Write(vbd_device_path, 'media-present', "0" ) -+ log.debug("wrote xenstore media 0 path:%s",vbd_media_path) -+ -+def mylog( fmt, *args): -+ f = open('/tmp/haldaemon.log', 'a') -+ 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-4.2.0-testing/tools/python/xen/xend/server/Hald.py -=================================================================== ---- /dev/null -+++ xen-4.2.0-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 -+# License as published by the Free Software Foundation. -+# -+# This library 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 -+# Lesser General Public License for more details. -+# -+# You should have received a copy of the GNU Lesser General Public -+# License along with this library; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+#============================================================================ -+# Copyright (C) 2007 Pat Campbell -+# Copyright (C) 2007 Novell Inc. -+#============================================================================ -+ -+import errno -+import types -+import os -+import sys -+import time -+import signal -+from traceback import print_exc -+ -+from xen.xend.XendLogging import log -+ -+class Hald: -+ def __init__(self): -+ self.ready = False -+ self.running = True -+ -+ def run(self): -+ """Starts the HalDaemon process -+ """ -+ self.ready = True -+ try: -+ myfile = self.find("xen/xend/server/HalDaemon.py") -+ args = (["python", myfile ]) -+ self.pid = self.daemonize("python", args ) -+ #log.debug( "%s %s pid:%d", "Hald.py starting ", args, self.pid ) -+ except: -+ self.pid = -1 -+ log.debug("Unable to start HalDaemon process") -+ -+ def shutdown(self): -+ """Shutdown the HalDaemon process -+ """ -+ log.debug("%s pid:%d", "Hald.shutdown()", self.pid) -+ self.running = False -+ self.ready = False -+ if self.pid != -1: -+ try: -+ os.kill(self.pid, signal.SIGINT) -+ except: -+ print_exc() -+ -+ def daemonize(self,prog, args): -+ """Runs a program as a daemon with the list of arguments. Returns the PID -+ of the daemonized program, or returns 0 on error. -+ Copied from xm/create.py instead of importing to reduce coupling -+ """ -+ r, w = os.pipe() -+ pid = os.fork() -+ -+ if pid == 0: -+ os.close(r) -+ w = os.fdopen(w, 'w') -+ os.setsid() -+ try: -+ pid2 = os.fork() -+ except: -+ 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) -+ except: -+ pass -+ os.open("/dev/null", os.O_RDWR) -+ os.dup2(0, 1) -+ os.dup2(0, 2) -+ os.execvpe(prog, args, env) -+ os._exit(1) -+ else: -+ w.write(str(pid2 or 0)) -+ w.close() -+ os._exit(0) -+ os.close(w) -+ r = os.fdopen(r) -+ daemon_pid = int(r.read()) -+ r.close() -+ os.waitpid(pid, 0) -+ #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 -+ """ -+ for dirname in sys.path: -+ candidate = os.path.join(dirname, path) -+ if matchFunc(candidate): -+ return candidate -+ raise Error("Can't find file %s" % path) -+ -+if __name__ == "__main__": -+ watcher = Hald() -+ watcher.run() -+ time.sleep(10) -+ watcher.shutdown() -Index: xen-4.2.0-testing/tools/python/xen/xend/server/SrvServer.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/server/SrvServer.py -+++ xen-4.2.0-testing/tools/python/xen/xend/server/SrvServer.py -@@ -57,6 +57,7 @@ from xen.web.SrvDir import SrvDir - - from SrvRoot import SrvRoot - from XMLRPCServer import XMLRPCServer -+from xen.xend.server.Hald import Hald - - xoptions = XendOptions.instance() - -@@ -252,6 +253,8 @@ def _loadConfig(servers, root, reload): - if xoptions.get_xend_unix_xmlrpc_server(): - servers.add(XMLRPCServer(XendAPI.AUTH_PAM, False)) - -+ servers.add(Hald()) -+ - - def create(): - root = SrvDir() -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/xenstore.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -@@ -18,6 +18,7 @@ - #include "exec-all.h" - #include "sysemu.h" - -+#include "console.h" - #include "hw.h" - #include "pci.h" - #include "qemu-timer.h" -@@ -595,6 +596,21 @@ void xenstore_parse_domain_config(int hv - #endif - - bs = bdrv_new(dev); -+ -+ /* if cdrom physical put a watch on media-present */ -+ if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) { -+ if (drv && !strcmp(drv, "phy")) { -+ if (pasprintf(&buf, "%s/media-present", bpath) != -1) { -+ if (bdrv_is_inserted(bs)) -+ xs_write(xsh, XBT_NULL, buf, "1", strlen("1")); -+ else { -+ xs_write(xsh, XBT_NULL, buf, "0", strlen("0")); -+ } -+ xs_watch(xsh, buf, "media-present"); -+ } -+ } -+ } -+ - /* check if it is a cdrom */ - if (danger_type && !strcmp(danger_type, "cdrom")) { - bdrv_set_type_hint(bs, BDRV_TYPE_CDROM); -@@ -1030,6 +1046,50 @@ static void xenstore_process_vcpu_set_ev - return; - } - -+static 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, *offset, *bpath = NULL, *buf = NULL, *drv = NULL, *image = NULL; -@@ -1065,6 +1125,11 @@ void xenstore_process_event(void *opaque - xenstore_watch_callbacks[i].cb(vec[XS_WATCH_TOKEN], - xenstore_watch_callbacks[i].opaque); - -+ if (!strcmp(vec[XS_WATCH_TOKEN], "media-present")) { -+ xenstore_process_media_change_event(vec); -+ goto out; -+ } -+ - hd_index = drive_name_to_index(vec[XS_WATCH_TOKEN]); - if (hd_index == -1) { - fprintf(stderr,"medium change watch on `%s' -" diff --git a/change-vnc-passwd.patch b/change-vnc-passwd.patch deleted file mode 100644 index 65bab24..0000000 --- a/change-vnc-passwd.patch +++ /dev/null @@ -1,157 +0,0 @@ -Add support of change-vnc-password while vm is running. - -Signed-off-by: Chunyan Liu - -Index: xen-4.2.1-testing/tools/qemu-xen-traditional-dir-remote/vl.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/qemu-xen-traditional-dir-remote/vl.c -+++ xen-4.2.1-testing/tools/qemu-xen-traditional-dir-remote/vl.c -@@ -200,7 +200,7 @@ DriveInfo drives_table[MAX_DRIVES+1]; - int nb_drives; - enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; - int vga_ram_size; --static DisplayState *display_state; -+DisplayState *display_state; - int nographic; - static int curses; - static int sdl; -Index: xen-4.2.1-testing/tools/qemu-xen-traditional-dir-remote/vnc.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/qemu-xen-traditional-dir-remote/vnc.c -+++ xen-4.2.1-testing/tools/qemu-xen-traditional-dir-remote/vnc.c -@@ -2627,6 +2627,7 @@ int vnc_display_password(DisplayState *d - if (password && password[0]) { - if (!(vs->password = qemu_strdup(password))) - return -1; -+ vs->auth = VNC_AUTH_VNC; - } - - return 0; -Index: xen-4.2.1-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/qemu-xen-traditional-dir-remote/xenstore.c -+++ xen-4.2.1-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -@@ -24,6 +24,7 @@ - #include "qemu-timer.h" - #include "qemu-xen.h" - -+extern DisplayState *display_state; - struct xs_handle *xsh = NULL; - static char *media_filename[MAX_DRIVES+1]; - static QEMUTimer *insert_timer = NULL; -@@ -939,6 +940,19 @@ static void xenstore_process_dm_command_ - } else if (!strncmp(command, "continue", len)) { - fprintf(logfile, "dm-command: continue after state save\n"); - xen_pause_requested = 0; -+ } else if (!strncmp(command, "chgvncpasswd", len)) { -+ fprintf(logfile, "dm-command: change vnc passwd\n"); -+ if (pasprintf(&path, -+ "/local/domain/0/backend/vfb/%u/0/vncpasswd", domid) == -1) { -+ fprintf(logfile, "out of memory reading dm command parameter\n"); -+ goto out; -+ } -+ par = xs_read(xsh, XBT_NULL, path, &len); -+ if (!par) -+ goto out; -+ if (vnc_display_password(display_state, par) == 0) -+ xenstore_record_dm_state("vncpasswdchged"); -+ free(par); - } else if (!strncmp(command, "usb-add", len)) { - fprintf(logfile, "dm-command: usb-add a usb device\n"); - if (pasprintf(&path, -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1506,6 +1506,20 @@ class XendDomainInfo: - target = max_target - self.setMemoryTarget(target) - -+ def chgvncpasswd(self, passwd): -+ if self._stateGet() != DOM_STATE_HALTED: -+ path = '/local/domain/0/backend/vfb/%u/0/' % self.getDomid() -+ xstransact.Write(path, 'vncpasswd', passwd) -+ self.image.signalDeviceModel("chgvncpasswd", "vncpasswdchged") -+ -+ for dev_uuid, (dev_type, dev_info) in self.info['devices'].items(): -+ if dev_type == 'vfb': -+ dev_info['vncpasswd'] = passwd -+ dev_info['other_config']['vncpasswd'] = passwd -+ self.info.device_update(dev_uuid, cfg_xenapi = dev_info) -+ break -+ xen.xend.XendDomain.instance().managed_config_save(self) -+ - def setMemoryTarget(self, target): - """Set the memory target of this domain. - @param target: In MiB. -Index: xen-4.2.1-testing/tools/python/xen/xend/server/XMLRPCServer.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/server/XMLRPCServer.py -+++ xen-4.2.1-testing/tools/python/xen/xend/server/XMLRPCServer.py -@@ -95,7 +95,7 @@ methods = ['device_create', 'device_conf - 'destroyDevice','getDeviceSxprs', - 'setMemoryTarget', 'setName', 'setVCpuCount', 'shutdown', - 'send_sysrq', 'getVCPUInfo', 'waitForDevices', -- 'getRestartCount', 'getBlockDeviceClass'] -+ 'getRestartCount', 'getBlockDeviceClass', 'chgvncpasswd'] - - exclude = ['domain_create', 'domain_restore'] - -Index: xen-4.2.1-testing/tools/python/xen/xm/main.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xm/main.py -+++ xen-4.2.1-testing/tools/python/xen/xm/main.py -@@ -21,6 +21,7 @@ - - """Grand unified management application for Xen. - """ -+import getpass - import atexit - import cmd - import os -@@ -281,6 +282,9 @@ SUBCOMMAND_HELP = { - 'getenforce' : ('', 'Returns the current enforcing mode for the Flask XSM module (Enforcing,Permissive)'), - 'setenforce' : ('[ (Enforcing|1) | (Permissive|0) ]', - 'Modifies the current enforcing mode for the Flask XSM module'), -+ #change vnc password -+ 'change-vnc-passwd' : ('',\ -+ 'Change vnc password'), - } - - SUBCOMMAND_OPTIONS = { -@@ -406,6 +410,7 @@ common_commands = [ - "usb-del", - "domstate", - "vcpu-set", -+ "change-vnc-passwd", - ] - - domain_commands = [ -@@ -443,6 +448,7 @@ domain_commands = [ - "vcpu-list", - "vcpu-pin", - "vcpu-set", -+ "change-vnc-passwd", - ] - - host_commands = [ -@@ -3806,6 +3812,10 @@ def xm_cpupool_migrate(args): - else: - server.xend.cpu_pool.migrate(domname, poolname) - -+def xm_chgvncpasswd(args): -+ arg_check(args, "change-vnc-passwd", 1) -+ pwd = getpass.getpass("Enter new password: ") -+ server.xend.domain.chgvncpasswd(args[0], pwd) - - commands = { - "shell": xm_shell, -@@ -3914,6 +3924,8 @@ commands = { - "usb-del": xm_usb_del, - #domstate - "domstate": xm_domstate, -+ #change vnc password: -+ "change-vnc-passwd": xm_chgvncpasswd, - } - - ## The commands supported by a separate argument parser in xend.xm. diff --git a/change_home_server.patch b/change_home_server.patch deleted file mode 100644 index 185007c..0000000 --- a/change_home_server.patch +++ /dev/null @@ -1,16 +0,0 @@ -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -3155,6 +3155,11 @@ class XendDomainInfo: - self._cleanup_phantom_devs(paths) - self._cleanupVm() - -+ if "change_home_server" in self.info: -+ chs = self.info["change_home_server"] -+ if (type(chs) is str and chs == "False") or \ -+ (type(chs) is bool and chs is False): -+ self.setChangeHomeServer(None) - if ("transient" in self.info["other_config"] and \ - bool(self.info["other_config"]["transient"])) or \ - ("change_home_server" in self.info and \ diff --git a/check_device_status.patch b/check_device_status.patch deleted file mode 100644 index be4ef5b..0000000 --- a/check_device_status.patch +++ /dev/null @@ -1,56 +0,0 @@ -Improve check_device_status to handle HA cases - -In HA environment, sometimes xenstore status has changed but ev.wait() cannot -get the signal, it will wait until timeout, thus incorrect device status is -returned. To fix this problem, we do not depend on ev.wait() result, but read -xenstore directly to get correct device status. - -Index: xen-4.2.0-testing/tools/python/xen/xend/server/DevController.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/server/DevController.py -+++ xen-4.2.0-testing/tools/python/xen/xend/server/DevController.py -@@ -149,7 +149,10 @@ class DevController: - (status, err) = self.waitForBackend(devid) - - if status == Timeout: -- self.destroyDevice(devid, False) -+ #Clean timeout backend resource -+ dev = self.convertToDeviceNumber(devid) -+ self.writeBackend(dev, HOTPLUG_STATUS_NODE, HOTPLUG_STATUS_ERROR) -+ self.destroyDevice(devid, True) - raise VmError("Device %s (%s) could not be connected. " - "Hotplug scripts not working." % - (devid, self.deviceClass)) -@@ -554,7 +557,17 @@ class DevController: - - xswatch(statusPath, hotplugStatusCallback, ev, result) - -- ev.wait(DEVICE_CREATE_TIMEOUT) -+ for i in range(1, 50): -+ ev.wait(DEVICE_CREATE_TIMEOUT/50) -+ status = xstransact.Read(statusPath) -+ if status is not None: -+ if status == HOTPLUG_STATUS_ERROR: -+ result['status'] = Error -+ elif status == HOTPLUG_STATUS_BUSY: -+ result['status'] = Busy -+ else: -+ result['status'] = Connected -+ break - - err = xstransact.Read(backpath, HOTPLUG_ERROR_NODE) - -@@ -571,7 +584,12 @@ class DevController: - - xswatch(statusPath, deviceDestroyCallback, ev, result) - -- ev.wait(DEVICE_DESTROY_TIMEOUT) -+ for i in range(1, 50): -+ ev.wait(DEVICE_DESTROY_TIMEOUT/50) -+ status = xstransact.Read(statusPath) -+ if status is None: -+ result['status'] = Disconnected -+ break - - return result['status'] - diff --git a/checkpoint-rename.patch b/checkpoint-rename.patch deleted file mode 100644 index fbabdaa..0000000 --- a/checkpoint-rename.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendCheckpoint.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -@@ -188,7 +188,7 @@ def save(fd, dominfo, network, live, dst - dominfo.destroy() - dominfo.testDeviceComplete() - try: -- dominfo.setName(domain_name, False) -+ dominfo.setName(domain_name) - except VmError: - # Ignore this. The name conflict (hopefully) arises because we - # are doing localhost migration; if we are doing a suspend of a diff --git a/del_usb_xend_entry.patch b/del_usb_xend_entry.patch deleted file mode 100644 index 9da77dc..0000000 --- a/del_usb_xend_entry.patch +++ /dev/null @@ -1,22 +0,0 @@ -Index: xen-4.2.0-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.0-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1298,8 +1298,15 @@ class XendDomainInfo: - frontpath = self.getDeviceController(deviceClass).frontendPath(dev) - backpath = xstransact.Read(frontpath, "backend") - thread.start_new_thread(self.getDeviceController(deviceClass).finishDeviceCleanup, (backpath, path)) -- -- rc = self.getDeviceController(deviceClass).destroyDevice(devid, force) -+ if deviceClass =='vusb': -+ dev = self.getDeviceController(deviceClass).convertToDeviceNumber(devid) -+ state = self.getDeviceController(deviceClass).readBackend(dev, 'state') -+ if state == '1': -+ rc = self.getDeviceController(deviceClass).destroyDevice(devid, True) -+ else: -+ rc = self.getDeviceController(deviceClass).destroyDevice(devid, force) -+ else: -+ rc = self.getDeviceController(deviceClass).destroyDevice(devid, force) - if not force and rm_cfg: - # The backend path, other than the device itself, - # has to be passed because its accompanied frontend diff --git a/disable-wget-check.patch b/disable-wget-check.patch new file mode 100644 index 0000000..6b00056 --- /dev/null +++ b/disable-wget-check.patch @@ -0,0 +1,340 @@ +Index: xen-4.3.0-testing/tools/configure +=================================================================== +--- xen-4.3.0-testing.orig/tools/configure ++++ xen-4.3.0-testing/tools/configure +@@ -605,9 +605,6 @@ libgcrypt + EXTFS_LIBS + system_aio + zlib +-FETCHER +-FTP +-WGET + glib_LIBS + glib_CFLAGS + PKG_CONFIG_LIBDIR +@@ -7068,104 +7065,104 @@ $as_echo "yes" >&6; } + fi + + # Extract the first word of "wget", so it can be a program name with args. +-set dummy wget; ac_word=$2 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +-$as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_path_WGET+set}" = set; then : +- $as_echo_n "(cached) " >&6 +-else +- case $WGET in +- [\\/]* | ?:[\\/]*) +- ac_cv_path_WGET="$WGET" # Let the user override the test with a path. +- ;; +- *) +- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +-for as_dir in $PATH +-do +- IFS=$as_save_IFS +- test -z "$as_dir" && as_dir=. +- for ac_exec_ext in '' $ac_executable_extensions; do +- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then +- ac_cv_path_WGET="$as_dir/$ac_word$ac_exec_ext" +- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 +- break 2 +- fi +-done +- done +-IFS=$as_save_IFS +- +- test -z "$ac_cv_path_WGET" && ac_cv_path_WGET="no" +- ;; +-esac +-fi +-WGET=$ac_cv_path_WGET +-if test -n "$WGET"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WGET" >&5 +-$as_echo "$WGET" >&6; } +-else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +-fi +- +- +-if test x"$WGET" != x"no"; then : +- +- FETCHER="$WGET -c -O" +- +-else +- +- # Extract the first word of "ftp", so it can be a program name with args. +-set dummy ftp; ac_word=$2 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +-$as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_path_FTP+set}" = set; then : +- $as_echo_n "(cached) " >&6 +-else +- case $FTP in +- [\\/]* | ?:[\\/]*) +- ac_cv_path_FTP="$FTP" # Let the user override the test with a path. +- ;; +- *) +- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +-for as_dir in $PATH +-do +- IFS=$as_save_IFS +- test -z "$as_dir" && as_dir=. +- for ac_exec_ext in '' $ac_executable_extensions; do +- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then +- ac_cv_path_FTP="$as_dir/$ac_word$ac_exec_ext" +- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 +- break 2 +- fi +-done +- done +-IFS=$as_save_IFS +- +- test -z "$ac_cv_path_FTP" && ac_cv_path_FTP="no" +- ;; +-esac +-fi +-FTP=$ac_cv_path_FTP +-if test -n "$FTP"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FTP" >&5 +-$as_echo "$FTP" >&6; } +-else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +-fi +- +- +- if test x"$FTP" != x"no"; then : +- +- FETCHER="$FTP -o" +- +-else +- +- as_fn_error $? "cannot find wget or ftp" "$LINENO" 5 +- +-fi +- +-fi ++#set dummy wget; ac_word=$2 ++#{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++#$as_echo_n "checking for $ac_word... " >&6; } ++#if test "${ac_cv_path_WGET+set}" = set; then : ++# $as_echo_n "(cached) " >&6 ++#else ++# case $WGET in ++# [\\/]* | ?:[\\/]*) ++# ac_cv_path_WGET="$WGET" # Let the user override the test with a path. ++# ;; ++# *) ++# as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++#for as_dir in $PATH ++#do ++# IFS=$as_save_IFS ++# test -z "$as_dir" && as_dir=. ++# for ac_exec_ext in '' $ac_executable_extensions; do ++# if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++# ac_cv_path_WGET="$as_dir/$ac_word$ac_exec_ext" ++# $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++# break 2 ++# fi ++#done ++# done ++#IFS=$as_save_IFS ++# ++# test -z "$ac_cv_path_WGET" && ac_cv_path_WGET="no" ++# ;; ++#esac ++#fi ++#WGET=$ac_cv_path_WGET ++#if test -n "$WGET"; then ++# { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WGET" >&5 ++#$as_echo "$WGET" >&6; } ++#else ++# { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++#$as_echo "no" >&6; } ++#fi ++# ++# ++#if test x"$WGET" != x"no"; then : ++# ++# FETCHER="$WGET -c -O" ++# ++#else ++# ++# # Extract the first word of "ftp", so it can be a program name with args. ++#set dummy ftp; ac_word=$2 ++#{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++#$as_echo_n "checking for $ac_word... " >&6; } ++#if test "${ac_cv_path_FTP+set}" = set; then : ++# $as_echo_n "(cached) " >&6 ++#else ++# case $FTP in ++# [\\/]* | ?:[\\/]*) ++# ac_cv_path_FTP="$FTP" # Let the user override the test with a path. ++# ;; ++# *) ++# as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++#for as_dir in $PATH ++#do ++# IFS=$as_save_IFS ++# test -z "$as_dir" && as_dir=. ++# for ac_exec_ext in '' $ac_executable_extensions; do ++# if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++# ac_cv_path_FTP="$as_dir/$ac_word$ac_exec_ext" ++# $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++# break 2 ++# fi ++#done ++# done ++#IFS=$as_save_IFS ++# ++# test -z "$ac_cv_path_FTP" && ac_cv_path_FTP="no" ++# ;; ++#esac ++#fi ++#FTP=$ac_cv_path_FTP ++#if test -n "$FTP"; then ++# { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FTP" >&5 ++#$as_echo "$FTP" >&6; } ++#else ++# { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++#$as_echo "no" >&6; } ++#fi ++# ++# ++# if test x"$FTP" != x"no"; then : ++# ++# FETCHER="$FTP -o" ++# ++#else ++# ++# as_fn_error $? "cannot find wget or ftp" "$LINENO" 5 ++# ++#fi ++# ++#fi + + + +Index: xen-4.3.0-testing/stubdom/configure +=================================================================== +--- xen-4.3.0-testing.orig/stubdom/configure ++++ xen-4.3.0-testing/stubdom/configure +@@ -593,7 +593,6 @@ CPPFLAGS + LDFLAGS + CFLAGS + CC +-WGET + CMAKE + extfiles + debug +@@ -657,7 +656,6 @@ enable_extfiles + host_alias + target_alias + CMAKE +-WGET + CC + CFLAGS + LDFLAGS +@@ -1299,7 +1297,6 @@ Optional Features: + + Some influential environment variables: + CMAKE Path to the cmake program +- WGET Path to wget program + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a +@@ -3079,50 +3076,50 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCR + test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + # Extract the first word of "wget", so it can be a program name with args. +-set dummy wget; ac_word=$2 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +-$as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_path_WGET+set}" = set; then : +- $as_echo_n "(cached) " >&6 +-else +- case $WGET in +- [\\/]* | ?:[\\/]*) +- ac_cv_path_WGET="$WGET" # Let the user override the test with a path. +- ;; +- *) +- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +-for as_dir in $PATH +-do +- IFS=$as_save_IFS +- test -z "$as_dir" && as_dir=. +- for ac_exec_ext in '' $ac_executable_extensions; do +- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then +- ac_cv_path_WGET="$as_dir/$ac_word$ac_exec_ext" +- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 +- break 2 +- fi +-done +- done +-IFS=$as_save_IFS +- +- test -z "$ac_cv_path_WGET" && ac_cv_path_WGET="no" +- ;; +-esac +-fi +-WGET=$ac_cv_path_WGET +-if test -n "$WGET"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WGET" >&5 +-$as_echo "$WGET" >&6; } +-else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +-fi +- +- +-if test x"${WGET}" = x"no" +-then +- as_fn_error $? "Unable to find wget, please install wget" "$LINENO" 5 +-fi ++#set dummy wget; ac_word=$2 ++#{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++#$as_echo_n "checking for $ac_word... " >&6; } ++#if test "${ac_cv_path_WGET+set}" = set; then : ++# $as_echo_n "(cached) " >&6 ++#else ++# case $WGET in ++# [\\/]* | ?:[\\/]*) ++# ac_cv_path_WGET="$WGET" # Let the user override the test with a path. ++# ;; ++# *) ++# as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++#for as_dir in $PATH ++#do ++# IFS=$as_save_IFS ++# test -z "$as_dir" && as_dir=. ++# for ac_exec_ext in '' $ac_executable_extensions; do ++# if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++# ac_cv_path_WGET="$as_dir/$ac_word$ac_exec_ext" ++# $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++# break 2 ++# fi ++#done ++# done ++#IFS=$as_save_IFS ++# ++# test -z "$ac_cv_path_WGET" && ac_cv_path_WGET="no" ++# ;; ++#esac ++#fi ++#WGET=$ac_cv_path_WGET ++#if test -n "$WGET"; then ++# { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WGET" >&5 ++#$as_echo "$WGET" >&6; } ++#else ++# { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++#$as_echo "no" >&6; } ++#fi ++# ++# ++#if test x"${WGET}" = x"no" ++#then ++# as_fn_error $? "Unable to find wget, please install wget" "$LINENO" 5 ++#fi + + # Checks for programs that depend on a feature + diff --git a/disable_emulated_device.diff b/disable_emulated_device.patch similarity index 100% rename from disable_emulated_device.diff rename to disable_emulated_device.patch diff --git a/domu-usb-controller.patch b/domu-usb-controller.patch deleted file mode 100644 index 0e70ba5..0000000 --- a/domu-usb-controller.patch +++ /dev/null @@ -1,20 +0,0 @@ -Index: xen-4.2.0-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-4.2.0-testing/tools/python/xen/xend/XendConfig.py -@@ -1875,7 +1875,14 @@ class XendConfig(dict): - ports = sxp.child(dev_sxp, 'port') - for port in ports[1:]: - try: -- num, bus = port -+ # When ['port' ['1','']] is saved into sxp file, it will become (port (1 )) -+ # If using this sxp file, here variable "port" will be port=1, -+ # we should process it, otherwise, it will report error. -+ if len(port) == 1: -+ num = port[0] -+ bus = "" -+ else: -+ num, bus = port - dev_config['port-%i' % int(num)] = str(bus) - except TypeError: - pass diff --git a/hv_extid_compatibility.patch b/hv_extid_compatibility.patch deleted file mode 100644 index 28bfa4d..0000000 --- a/hv_extid_compatibility.patch +++ /dev/null @@ -1,68 +0,0 @@ -Index: xen-4.2.1-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendConfig.py -@@ -161,6 +161,7 @@ XENAPI_PLATFORM_CFG_TYPES = { - 'nographic': int, - 'nomigrate': int, - 'pae' : int, -+ 'extid': int, - 'rtc_timeoffset': int, - 'parallel': str, - 'serial': str, -@@ -523,6 +524,8 @@ class XendConfig(dict): - self['platform']['acpi_firmware'] = "" - if 'timer_mode' not in self['platform']: - self['platform']['timer_mode'] = 1 -+ if 'extid' in self['platform'] and int(self['platform']['extid']) == 1: -+ self['platform']['viridian'] = 1 - if 'viridian' not in self['platform']: - self['platform']['viridian'] = 0 - if 'rtc_timeoffset' not in self['platform']: -Index: xen-4.2.1-testing/tools/python/xen/xend/image.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/image.py -+++ xen-4.2.1-testing/tools/python/xen/xend/image.py -@@ -830,6 +830,7 @@ class HVMImageHandler(ImageHandler): - - self.apic = int(vmConfig['platform'].get('apic', 0)) - self.acpi = int(vmConfig['platform'].get('acpi', 0)) -+ self.extid = int(vmConfig['platform'].get('extid', 0)) - self.guest_os_type = vmConfig['platform'].get('guest_os_type') - self.memory_sharing = int(vmConfig['memory_sharing']) - try: -Index: xen-4.2.1-testing/tools/python/xen/xm/create.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xm/create.py -+++ xen-4.2.1-testing/tools/python/xen/xm/create.py -@@ -242,6 +242,10 @@ gopts.var('viridian', val='VIRIDIAN', - use="""Expose Viridian interface to x86 HVM guest? - (Default is 0).""") - -+gopts.var('extid', val='EXTID', -+ fn=set_int, default=0, -+ use="Specify extention ID for a HVM domain.") -+ - gopts.var('acpi', val='ACPI', - fn=set_int, default=1, - use="Disable or enable ACPI of HVM domain.") -@@ -1120,7 +1124,7 @@ def configure_hvm(config_image, vals): - 'timer_mode', - 'usb', 'usbdevice', - 'vcpus', 'vnc', 'vncconsole', 'vncdisplay', 'vnclisten', -- 'vncunused', 'viridian', 'vpt_align', -+ 'vncunused', 'vpt_align', - 'watchdog', 'watchdog_action', - 'xauthority', 'xen_extended_power_mgmt', 'xen_platform_pci', - 'memory_sharing' ] -@@ -1130,6 +1134,10 @@ def configure_hvm(config_image, vals): - config_image.append([a, vals.__dict__[a]]) - if vals.vncpasswd is not None: - config_image.append(['vncpasswd', vals.vncpasswd]) -+ if vals.extid and vals.extid == 1: -+ config_image.append(['viridian', vals.extid]) -+ elif vals.viridian: -+ config_image.append(['viridian', vals.viridian]) - - - def make_config(vals): diff --git a/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch b/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch deleted file mode 100644 index 99e520b..0000000 --- a/ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch +++ /dev/null @@ -1,32 +0,0 @@ -qcow2 corruption: Fix alloc_cluster_link_l2 (Kevin Wolf) - -This patch fixes a qcow2 corruption bug introduced in SVN Rev 5861. L2 tables -are big endian, so entries must be converted before being passed to functions. - -This bug is easy to trigger. The following script will create and destroy a -qcow2 image (the header is gone after three loop iterations): - - #!/bin/bash - qemu-img create -f qcow2 test.qcow 1M - for i in $(seq 1 10); do - qemu-system-x86_64 -hda test.qcow -monitor stdio > /dev/null 2>&1 < - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/block-qcow2.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/block-qcow2.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/block-qcow2.c -@@ -916,7 +916,7 @@ static int alloc_cluster_link_l2(BlockDr - goto err; - - for (i = 0; i < j; i++) -- free_any_clusters(bs, old_cluster[i], 1); -+ free_any_clusters(bs, be64_to_cpu(old_cluster[i]) & ~QCOW_OFLAG_COPIED, 1); - - ret = 0; - err: diff --git a/ioemu-bdrv-open-CACHE_WB.patch b/ioemu-bdrv-open-CACHE_WB.patch deleted file mode 100644 index 136a971..0000000 --- a/ioemu-bdrv-open-CACHE_WB.patch +++ /dev/null @@ -1,18 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -@@ -247,8 +247,11 @@ static int open_disk(struct td_state *s, - drv = blktap_drivers[i].drv; - DPRINTF("%s driver specified\n", drv ? drv->format_name : "No"); - -- /* Open the image */ -- if (bdrv_open2(bs, path, flags, drv) != 0) { -+ /* Open the image -+ * Use BDRV_O_CACHE_WB for write-through caching, -+ * no flags for write-back caching -+ */ -+ if (bdrv_open2(bs, path, flags|BDRV_O_CACHE_WB, drv) != 0) { - fprintf(stderr, "Could not open image file %s\n", path); - return -ENOMEM; - } diff --git a/ioemu-blktap-barriers.patch b/ioemu-blktap-barriers.patch deleted file mode 100644 index 6019138..0000000 --- a/ioemu-blktap-barriers.patch +++ /dev/null @@ -1,73 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -@@ -360,6 +360,15 @@ static void qemu_send_responses(void* op - } - - /** -+ * Callback function for AIO flush -+ */ -+static void qemu_flush_response(void* opaque, int ret) { -+ if (ret != 0) { -+ DPRINTF("aio_flush: ret = %d (%s)\n", ret, strerror(-ret)); -+ } -+} -+ -+/** - * Callback function for the IO message pipe. Reads requests from the ring - * and processes them (call qemu read/write functions). - * -@@ -378,6 +387,7 @@ static void handle_blktap_iomsg(void* pr - blkif_t *blkif = s->blkif; - tapdev_info_t *info = s->ring_info; - int page_size = getpagesize(); -+ int sync; - - struct aiocb_info *aiocb_info; - -@@ -410,7 +420,7 @@ static void handle_blktap_iomsg(void* pr - - /* Don't allow writes on readonly devices */ - if ((s->flags & TD_RDONLY) && -- (req->operation == BLKIF_OP_WRITE)) { -+ (req->operation != BLKIF_OP_READ)) { - blkif->pending_list[idx].status = BLKIF_RSP_ERROR; - goto send_response; - } -@@ -431,7 +441,7 @@ static void handle_blktap_iomsg(void* pr - DPRINTF("Sector request failed:\n"); - DPRINTF("%s request, idx [%d,%d] size [%llu], " - "sector [%llu,%llu]\n", -- (req->operation == BLKIF_OP_WRITE ? -+ (req->operation != BLKIF_OP_READ ? - "WRITE" : "READ"), - idx,i, - (long long unsigned) -@@ -444,8 +454,14 @@ static void handle_blktap_iomsg(void* pr - - blkif->pending_list[idx].secs_pending += nsects; - -- switch (req->operation) -+ sync = 0; -+ switch (req->operation) - { -+ case BLKIF_OP_WRITE_BARRIER: -+ sync = 1; -+ bdrv_aio_flush(s->bs, qemu_flush_response, NULL); -+ /* fall through */ -+ - case BLKIF_OP_WRITE: - aiocb_info = malloc(sizeof(*aiocb_info)); - -@@ -465,6 +481,10 @@ static void handle_blktap_iomsg(void* pr - DPRINTF("ERROR: bdrv_write() == NULL\n"); - goto send_response; - } -+ -+ if (sync) -+ bdrv_aio_flush(s->bs, qemu_flush_response, NULL); -+ - break; - - case BLKIF_OP_READ: diff --git a/ioemu-blktap-fv-init.patch b/ioemu-blktap-fv-init.patch deleted file mode 100644 index 5217502..0000000 --- a/ioemu-blktap-fv-init.patch +++ /dev/null @@ -1,24 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_machine_fv.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_machine_fv.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_machine_fv.c -@@ -270,6 +270,7 @@ void qemu_invalidate_entry(uint8_t *buff - - #endif /* defined(MAPCACHE) */ - -+extern void init_blktap(void); - - static void xen_init_fv(ram_addr_t ram_size, int vga_ram_size, - const char *boot_device, -@@ -295,6 +296,11 @@ static void xen_init_fv(ram_addr_t ram_s - } - #endif - -+#ifndef CONFIG_STUBDOM -+ /* Initialize tapdisk client */ -+ init_blktap(); -+#endif -+ - #ifdef CONFIG_STUBDOM /* the hvmop is not supported on older hypervisors */ - xc_set_hvm_param(xc_handle, domid, HVM_PARAM_DM_DOMAIN, DOMID_SELF); - #endif diff --git a/ioemu-blktap-image-format.patch b/ioemu-blktap-image-format.patch deleted file mode 100644 index 933416f..0000000 --- a/ioemu-blktap-image-format.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 5ac882a6d7499e4a36103db071203bf4d1ddfe1f Mon Sep 17 00:00:00 2001 -From: Kevin Wolf -Date: Tue, 10 Mar 2009 16:26:45 +0100 -Subject: [PATCH 2/6] ioemu: Use the image format sent by blktapctrl - -Currently the blktap backend in ioemu lets qemu guess which format an -image is in. This was a security problem and the blktap backend -doesn't work any more since this was fixed in qemu. - -This patch changes ioemu to respect the format it gets from blktapctrl. - -Signed-off-by: Kevin Wolf ---- - hw/xen_blktap.c | 22 +++++++++++++++++++--- - hw/xen_blktap.h | 14 ++++++++++++++ - 2 files changed, 33 insertions(+), 3 deletions(-) - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -@@ -218,9 +218,10 @@ static int map_new_dev(struct td_state * - return -1; - } - --static int open_disk(struct td_state *s, char *path, int readonly) -+static int open_disk(struct td_state *s, char *path, int driver, int readonly) - { - BlockDriverState* bs; -+ BlockDriver* drv; - char* devname; - static int devnumber = 0; - int i; -@@ -230,7 +231,22 @@ static int open_disk(struct td_state *s, - bs = bdrv_new(devname); - free(devname); - -- if (bdrv_open(bs, path, 0) != 0) { -+ /* Search for disk driver */ -+ for (i = 0; blktap_drivers[i].idnum >= 0; i++) { -+ if (blktap_drivers[i].idnum == driver) -+ break; -+ } -+ -+ if (blktap_drivers[i].idnum < 0) { -+ fprintf(stderr, "Could not find image format id %d\n", driver); -+ return -ENOMEM; -+ } -+ -+ drv = blktap_drivers[i].drv; -+ DPRINTF("%s driver specified\n", drv ? drv->format_name : "No"); -+ -+ /* Open the image */ -+ if (bdrv_open2(bs, path, 0, drv) != 0) { - fprintf(stderr, "Could not open image file %s\n", path); - return -ENOMEM; - } -@@ -521,7 +537,7 @@ static void handle_blktap_ctrlmsg(void* - s = state_init(); - - /*Open file*/ -- if (s == NULL || open_disk(s, path, msg->readonly)) { -+ if (s == NULL || open_disk(s, path, msg->drivertype, msg->readonly)) { - msglen = sizeof(msg_hdr_t); - msg->type = CTLMSG_IMG_FAIL; - msg->len = msglen; -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.h -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.h -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.h -@@ -52,4 +52,18 @@ typedef struct fd_list_entry { - - int init_blktap(void); - -+typedef struct disk_info { -+ int idnum; -+ struct BlockDriver *drv; -+} disk_info_t; -+ -+static disk_info_t blktap_drivers[] = { -+ { DISK_TYPE_AIO, &bdrv_raw }, -+ { DISK_TYPE_SYNC, &bdrv_raw }, -+ { DISK_TYPE_VMDK, &bdrv_vmdk }, -+ { DISK_TYPE_QCOW, &bdrv_qcow }, -+ { DISK_TYPE_QCOW2, &bdrv_qcow2 }, -+ { -1, NULL } -+}; -+ - #endif /*XEN_BLKTAP_H_*/ diff --git a/ioemu-blktap-zero-size.patch b/ioemu-blktap-zero-size.patch deleted file mode 100644 index a4877fc..0000000 --- a/ioemu-blktap-zero-size.patch +++ /dev/null @@ -1,44 +0,0 @@ -From cb982fd919a52ff86f01025d0f92225bc7b2a956 Mon Sep 17 00:00:00 2001 -From: Kevin Wolf -Date: Tue, 10 Mar 2009 16:44:31 +0100 -Subject: [PATCH 5/6] ioemu: Fail on too small blktap disks - -The blktap infrastructure doesn't seems to be able to cope with images -that are smaller than a sector, it produced hangs for me. Such an -image isn't really useful anyway, so just fail gracefully. - -Signed-off-by: Kevin Wolf ---- - hw/xen_blktap.c | 6 ++++++ - 1 files changed, 6 insertions(+), 0 deletions(-) - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -@@ -256,6 +256,12 @@ static int open_disk(struct td_state *s, - s->size = bs->total_sectors; - s->sector_size = 512; - -+ if (s->size == 0) { -+ fprintf(stderr, "Error: Disk image %s is too small\n", -+ path); -+ return -ENOMEM; -+ } -+ - s->info = ((s->flags & TD_RDONLY) ? VDISK_READONLY : 0); - - #ifndef QEMU_TOOL -Index: xen-4.2.0-testing/tools/python/xen/xend/server/DevController.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/server/DevController.py -+++ xen-4.2.0-testing/tools/python/xen/xend/server/DevController.py -@@ -155,7 +155,7 @@ class DevController: - (devid, self.deviceClass)) - - elif status == Error: -- self.destroyDevice(devid, False) -+ self.destroyDevice(devid, True) - if err is None: - raise VmError("Device %s (%s) could not be connected. " - "Backend device not found." % diff --git a/ioemu-debuginfo.patch b/ioemu-debuginfo.patch deleted file mode 100644 index ab35dbe..0000000 --- a/ioemu-debuginfo.patch +++ /dev/null @@ -1,26 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/Makefile -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile -@@ -243,7 +243,7 @@ endif - install: all $(if $(BUILD_DOCS),install-doc) - mkdir -p "$(DESTDIR)$(bindir)" - ifneq ($(TOOLS),) -- $(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)" -+ $(INSTALL) -m 755 $(TOOLS) "$(DESTDIR)$(bindir)" - endif - ifneq ($(BLOBS),) - mkdir -p "$(DESTDIR)$(datadir)" -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile.target -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/Makefile.target -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile.target -@@ -755,7 +755,7 @@ clean: - - install: all install-hook - ifneq ($(PROGS),) -- $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)" -+ $(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)" - endif - - # Include automatically generated dependency files diff --git a/ioemu-disable-emulated-ide-if-pv.patch b/ioemu-disable-emulated-ide-if-pv.patch deleted file mode 100644 index 4aa9cef..0000000 --- a/ioemu-disable-emulated-ide-if-pv.patch +++ /dev/null @@ -1,76 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-xen.h -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/qemu-xen.h -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-xen.h -@@ -1,6 +1,8 @@ - #ifndef QEMU_XEN_H - #define QEMU_XEN_H - -+#include "hw/boards.h" -+ - /* vl.c */ - extern int restore; - extern int vga_ram_size; -@@ -65,7 +67,7 @@ void handle_buffered_pio(void); - /* xenstore.c */ - void xenstore_init(void); - uint32_t xenstore_read_target(void); --void xenstore_parse_domain_config(int domid); -+void xenstore_parse_domain_config(int domid, QEMUMachine *machine); - int xenstore_parse_disable_pf_config(void); - int xenstore_fd(void); - void xenstore_process_event(void *opaque); -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vl.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/vl.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vl.c -@@ -5862,9 +5862,9 @@ int main(int argc, char **argv, char **e - if ((msg = xenbus_read(XBT_NIL, "domid", &domid_s))) - fprintf(stderr,"Can not read our own domid: %s\n", msg); - else -- xenstore_parse_domain_config(atoi(domid_s)); -+ xenstore_parse_domain_config(atoi(domid_s), machine); - #else -- xenstore_parse_domain_config(domid); -+ xenstore_parse_domain_config(domid, machine); - #endif /* CONFIG_STUBDOM */ - } - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/xenstore.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -@@ -445,7 +445,7 @@ void xenstore_init(void) - } - } - --void xenstore_parse_domain_config(int hvm_domid) -+void xenstore_parse_domain_config(int hvm_domid, QEMUMachine *machine) - { - char **e_danger = NULL; - char *buf = NULL; -@@ -739,11 +739,19 @@ void xenstore_parse_domain_config(int hv - - #endif - -- drives_table[nb_drives].bdrv = bs; -- drives_table[nb_drives].used = 1; -- media_filename[nb_drives] = strdup(bs->filename); -- nb_drives++; -- -+ if (machine == &xenfv_machine) { -+ drives_table[nb_drives].bdrv = bs; -+ drives_table[nb_drives].used = 1; -+#ifdef CONFIG_STUBDOM -+ media_filename[nb_drives] = strdup(danger_buf); -+#else -+ media_filename[nb_drives] = strdup(bs->filename); -+#endif -+ nb_drives++; -+ } else { -+ qemu_aio_flush(); -+ bdrv_close(bs); -+ } - } - - #ifdef CONFIG_STUBDOM diff --git a/ioemu-disable-scsi.patch b/ioemu-disable-scsi.patch deleted file mode 100644 index bfdc8ed..0000000 --- a/ioemu-disable-scsi.patch +++ /dev/null @@ -1,80 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c -@@ -359,6 +359,8 @@ static void platform_ioport_write(void * - case 4: - fprintf(logfile, "Disconnect IDE hard disk...\n"); - ide_unplug_harddisks(); -+ fprintf(logfile, "Disconnect SCSI hard disk...\n"); -+ pci_unplug_scsi(); - fprintf(logfile, "Disconnect netifs...\n"); - pci_unplug_netifs(); - fprintf(logfile, "Shutdown taps...\n"); -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-xen.h -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/qemu-xen.h -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-xen.h -@@ -47,6 +47,7 @@ void unset_vram_mapping(void *opaque); - #endif - - void pci_unplug_netifs(void); -+void pci_unplug_scsi(void); - void destroy_hvm_domain(void); - void unregister_iomem(target_phys_addr_t start); - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pci.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/pci.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pci.c -@@ -871,6 +871,50 @@ void pci_unplug_netifs(void) - } - } - -+void pci_unplug_scsi(void) -+{ -+ PCIBus *bus; -+ PCIDevice *dev; -+ PCIIORegion *region; -+ int x; -+ int i; -+ -+ /* We only support one PCI bus */ -+ for (bus = first_bus; bus; bus = NULL) { -+ for (x = 0; x < 256; x++) { -+ dev = bus->devices[x]; -+ if (dev && -+ dev->config[0xa] == 0 && -+ dev->config[0xb] == 1 -+#ifdef CONFIG_PASSTHROUGH -+ && test_pci_devfn(x) != 1 -+#endif -+ ) { -+ /* Found a scsi disk. Remove it from the bus. Note that -+ we don't free it here, since there could still be -+ references to it floating around. There are only -+ ever one or two structures leaked, and it's not -+ worth finding them all. */ -+ bus->devices[x] = NULL; -+ for (i = 0; i < PCI_NUM_REGIONS; i++) { -+ region = &dev->io_regions[i]; -+ if (region->addr == (uint32_t)-1 || -+ region->size == 0) -+ continue; -+ fprintf(logfile, "region type %d at [%x,%x).\n", -+ region->type, region->addr, -+ region->addr+region->size); -+ if (region->type == PCI_ADDRESS_SPACE_IO) { -+ isa_unassign_ioport(region->addr, region->size); -+ } else if (region->type == PCI_ADDRESS_SPACE_MEM) { -+ unregister_iomem(region->addr); -+ } -+ } -+ } -+ } -+ } -+} -+ - typedef struct { - PCIDevice dev; - PCIBus *bus; diff --git a/ioemu-vnc-resize.patch b/ioemu-vnc-resize.patch deleted file mode 100644 index cf8f327..0000000 --- a/ioemu-vnc-resize.patch +++ /dev/null @@ -1,30 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vnc.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/vnc.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vnc.c -@@ -1751,6 +1751,25 @@ static int protocol_client_msg(VncState - } - - set_encodings(vs, (int32_t *)(data + 4), limit); -+ -+ /* -+ * The initialization of a VNC connection can race with xenfb changing -+ * the resolution. This happens when the VNC connection is already -+ * established, but the client has not yet advertised has_resize, so it -+ * won't get notified of the switch. -+ * -+ * Therefore we resend the resolution as soon as the client has sent its -+ * encodings. -+ */ -+ if (vs->has_resize) { -+ /* Resize the VNC window */ -+ vnc_write_u8(vs, 0); /* msg id */ -+ vnc_write_u8(vs, 0); -+ vnc_write_u16(vs, 1); /* number of rects */ -+ vnc_framebuffer_update(vs, 0, 0, vs->serverds.width, vs->serverds.height, -223); -+ -+ vnc_flush(vs); -+ } - break; - case 3: - if (len == 1) diff --git a/ioemu-watchdog-ib700-timer.patch b/ioemu-watchdog-ib700-timer.patch deleted file mode 100644 index de0e813..0000000 --- a/ioemu-watchdog-ib700-timer.patch +++ /dev/null @@ -1,34 +0,0 @@ - -Subject: qdev: convert watchdogs -From: Markus Armbruster armbru@redhat.com Fri Aug 21 10:31:34 2009 +0200 -Date: Thu Aug 27 20:35:24 2009 -0500: -Git: 09aaa1602f9381c0e0fb539390b1793e51bdfc7b - -* THIS IS ONLY THE BUG FIX PART OF THE UPSTREAM PATCH * - -Fixes ib700 not to use vm_clock before it is initialized: in -wdt_ib700_init(), called from register_watchdogs(), which runs before -init_timers(). The bug made ib700_write_enable_reg() crash in -qemu_del_timer(). - -Signed-off-by: Markus Armbruster -Signed-off-by: Anthony Liguori - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/wdt_ib700.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/wdt_ib700.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/wdt_ib700.c -@@ -93,6 +93,7 @@ static int ib700_load(QEMUFile *f, void - /* Create and initialize a virtual IB700 during PC creation. */ - static void ib700_pc_init(PCIBus *unused) - { -+ timer = qemu_new_timer(vm_clock, ib700_timer_expired, NULL); - register_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, NULL); - - register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, NULL); -@@ -108,5 +109,4 @@ static WatchdogTimerModel model = { - void wdt_ib700_init(void) - { - watchdog_add_model(&model); -- timer = qemu_new_timer(vm_clock, ib700_timer_expired, NULL); - } diff --git a/ioemu-watchdog-linkage.patch b/ioemu-watchdog-linkage.patch deleted file mode 100644 index eedd81b..0000000 --- a/ioemu-watchdog-linkage.patch +++ /dev/null @@ -1,72 +0,0 @@ - -Subject: Move watchdog, watchdog_action, give them internal linkage -From: Markus Armbruster armbru@redhat.com Fri Aug 21 10:31:32 2009 +0200 -Date: Thu Aug 27 20:30:23 2009 -0500: -Git: 88b3be201acf64e0bd19782bebd533901c951c87 - -Signed-off-by: Markus Armbruster -Signed-off-by: Anthony Liguori - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/watchdog.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.c -@@ -26,6 +26,16 @@ - #include "sysemu.h" - #include "hw/watchdog.h" - -+/* Possible values for action parameter. */ -+#define WDT_RESET 1 /* Hard reset. */ -+#define WDT_SHUTDOWN 2 /* Shutdown. */ -+#define WDT_POWEROFF 3 /* Quit. */ -+#define WDT_PAUSE 4 /* Pause. */ -+#define WDT_DEBUG 5 /* Prints a message and continues running. */ -+#define WDT_NONE 6 /* Do nothing. */ -+ -+static WatchdogTimerModel *watchdog; -+static int watchdog_action = WDT_RESET; - static LIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list; - - void watchdog_add_model(WatchdogTimerModel *model) -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.h -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/watchdog.h -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.h -@@ -27,13 +27,6 @@ - extern void wdt_i6300esb_init(void); - extern void wdt_ib700_init(void); - --/* Possible values for action parameter. */ --#define WDT_RESET 1 /* Hard reset. */ --#define WDT_SHUTDOWN 2 /* Shutdown. */ --#define WDT_POWEROFF 3 /* Quit. */ --#define WDT_PAUSE 4 /* Pause. */ --#define WDT_DEBUG 5 /* Prints a message and continues running. */ --#define WDT_NONE 6 /* Do nothing. */ - - struct WatchdogTimerModel { - LIST_ENTRY(WatchdogTimerModel) entry; -@@ -50,10 +43,6 @@ struct WatchdogTimerModel { - }; - typedef struct WatchdogTimerModel WatchdogTimerModel; - --/* in vl.c */ --extern WatchdogTimerModel *watchdog; --extern int watchdog_action; -- - /* in hw/watchdog.c */ - extern int select_watchdog(const char *p); - extern int select_watchdog_action(const char *action); -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vl.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/vl.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vl.c -@@ -250,8 +250,6 @@ int no_shutdown = 0; - int cursor_hide = 1; - int graphic_rotate = 0; - int daemonize = 0; --WatchdogTimerModel *watchdog = NULL; --int watchdog_action = WDT_RESET; - const char *option_rom[MAX_OPTION_ROMS]; - int nb_option_roms; - int semihosting_enabled = 0; diff --git a/ioemu-watchdog-support.patch b/ioemu-watchdog-support.patch deleted file mode 100644 index 7bb5266..0000000 --- a/ioemu-watchdog-support.patch +++ /dev/null @@ -1,963 +0,0 @@ - -Subject: Hardware watchdog -From: Richard W.M. Jones rjones@redhat.com Sat Apr 25 13:56:19 2009 +0100 -Date: Fri May 1 09:44:11 2009 -0500: -Git: 9dd986ccf68f142aaafe543d80cf877716d91d4e - -Here is an updated hardware watchdog patch, which should fix -everything that was raised about the previous version ... - -Signed-off-by: Richard W.M. Jones -Signed-off-by: Anthony Liguori - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile.target -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/Makefile.target -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile.target -@@ -580,6 +580,10 @@ OBJS += e1000.o - # Serial mouse - OBJS += msmouse.o - -+# Generic watchdog support and some watchdog devices -+OBJS += watchdog.o -+OBJS += wdt_ib700.o wdt_i6300esb.o -+ - ifeq ($(TARGET_BASE_ARCH), i386) - # Hardware support - ifdef CONFIG_AUDIO -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pc.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/pc.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pc.c -@@ -41,6 +41,7 @@ - #include "virtio-balloon.h" - #include "virtio-console.h" - #include "hpet_emul.h" -+#include "watchdog.h" - - #ifdef CONFIG_PASSTHROUGH - #include "pass-through.h" -@@ -1050,6 +1051,8 @@ vga_bios_error: - } - } - -+ watchdog_pc_init(pci_bus); -+ - for(i = 0; i < nb_nics; i++) { - NICInfo *nd = &nd_table[i]; - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.c -=================================================================== ---- /dev/null -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.c -@@ -0,0 +1,136 @@ -+/* -+ * Virtual hardware watchdog. -+ * -+ * Copyright (C) 2009 Red Hat 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 (at your option) 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. -+ * -+ * By Richard W.M. Jones (rjones@redhat.com). -+ */ -+ -+#include "qemu-common.h" -+#include "sys-queue.h" -+#include "sysemu.h" -+#include "hw/watchdog.h" -+ -+static LIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list; -+ -+void watchdog_add_model(WatchdogTimerModel *model) -+{ -+ LIST_INSERT_HEAD(&watchdog_list, model, entry); -+} -+ -+/* Returns: -+ * 0 = continue -+ * 1 = exit program with error -+ * 2 = exit program without error -+ */ -+int select_watchdog(const char *p) -+{ -+ WatchdogTimerModel *model; -+ -+ if (watchdog) { -+ fprintf(stderr, -+ "qemu: only one watchdog option may be given\n"); -+ return 1; -+ } -+ -+ /* -watchdog ? lists available devices and exits cleanly. */ -+ if (strcmp(p, "?") == 0) { -+ LIST_FOREACH(model, &watchdog_list, entry) { -+ fprintf(stderr, "\t%s\t%s\n", -+ model->wdt_name, model->wdt_description); -+ } -+ return 2; -+ } -+ -+ LIST_FOREACH(model, &watchdog_list, entry) { -+ if (strcasecmp(model->wdt_name, p) == 0) { -+ watchdog = model; -+ return 0; -+ } -+ } -+ -+ fprintf(stderr, "Unknown -watchdog device. Supported devices are:\n"); -+ LIST_FOREACH(model, &watchdog_list, entry) { -+ fprintf(stderr, "\t%s\t%s\n", -+ model->wdt_name, model->wdt_description); -+ } -+ return 1; -+} -+ -+int select_watchdog_action(const char *p) -+{ -+ if (strcasecmp(p, "reset") == 0) -+ watchdog_action = WDT_RESET; -+ else if (strcasecmp(p, "shutdown") == 0) -+ watchdog_action = WDT_SHUTDOWN; -+ else if (strcasecmp(p, "poweroff") == 0) -+ watchdog_action = WDT_POWEROFF; -+ else if (strcasecmp(p, "pause") == 0) -+ watchdog_action = WDT_PAUSE; -+ else if (strcasecmp(p, "debug") == 0) -+ watchdog_action = WDT_DEBUG; -+ else if (strcasecmp(p, "none") == 0) -+ watchdog_action = WDT_NONE; -+ else -+ return -1; -+ -+ return 0; -+} -+ -+/* This actually performs the "action" once a watchdog has expired, -+ * ie. reboot, shutdown, exit, etc. -+ */ -+void watchdog_perform_action(void) -+{ -+ switch(watchdog_action) { -+ case WDT_RESET: /* same as 'system_reset' in monitor */ -+ qemu_system_reset_request(); -+ break; -+ -+ case WDT_SHUTDOWN: /* same as 'system_powerdown' in monitor */ -+ qemu_system_powerdown_request(); -+ break; -+ -+ case WDT_POWEROFF: /* same as 'quit' command in monitor */ -+ exit(0); -+ break; -+ -+ case WDT_PAUSE: /* same as 'stop' command in monitor */ -+ vm_stop(0); -+ break; -+ -+ case WDT_DEBUG: -+ fprintf(stderr, "watchdog: timer fired\n"); -+ break; -+ -+ case WDT_NONE: -+ break; -+ } -+} -+ -+void watchdog_pc_init(PCIBus *pci_bus) -+{ -+ if (watchdog) -+ watchdog->wdt_pc_init(pci_bus); -+} -+ -+void register_watchdogs(void) -+{ -+ wdt_ib700_init(); -+ wdt_i6300esb_init(); -+} -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.h -=================================================================== ---- /dev/null -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.h -@@ -0,0 +1,65 @@ -+/* -+ * Virtual hardware watchdog. -+ * -+ * Copyright (C) 2009 Red Hat 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 (at your option) 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. -+ * -+ * By Richard W.M. Jones (rjones@redhat.com). -+ */ -+ -+#ifndef QEMU_WATCHDOG_H -+#define QEMU_WATCHDOG_H -+ -+extern void wdt_i6300esb_init(void); -+extern void wdt_ib700_init(void); -+ -+/* Possible values for action parameter. */ -+#define WDT_RESET 1 /* Hard reset. */ -+#define WDT_SHUTDOWN 2 /* Shutdown. */ -+#define WDT_POWEROFF 3 /* Quit. */ -+#define WDT_PAUSE 4 /* Pause. */ -+#define WDT_DEBUG 5 /* Prints a message and continues running. */ -+#define WDT_NONE 6 /* Do nothing. */ -+ -+struct WatchdogTimerModel { -+ LIST_ENTRY(WatchdogTimerModel) entry; -+ -+ /* Short name of the device - used to select it on the command line. */ -+ const char *wdt_name; -+ /* Longer description (eg. manufacturer and full model number). */ -+ const char *wdt_description; -+ -+ /* This callback should create/register the device. It is called -+ * indirectly from hw/pc.c when the virtual PC is being set up. -+ */ -+ void (*wdt_pc_init)(PCIBus *pci_bus); -+}; -+typedef struct WatchdogTimerModel WatchdogTimerModel; -+ -+/* in vl.c */ -+extern WatchdogTimerModel *watchdog; -+extern int watchdog_action; -+ -+/* in hw/watchdog.c */ -+extern int select_watchdog(const char *p); -+extern int select_watchdog_action(const char *action); -+extern void watchdog_add_model(WatchdogTimerModel *model); -+extern void watchdog_perform_action(void); -+extern void watchdog_pc_init(PCIBus *pci_bus); -+extern void register_watchdogs(void); -+ -+#endif /* QEMU_WATCHDOG_H */ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/wdt_i6300esb.c -=================================================================== ---- /dev/null -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/wdt_i6300esb.c -@@ -0,0 +1,470 @@ -+/* -+ * Virtual hardware watchdog. -+ * -+ * Copyright (C) 2009 Red Hat 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 (at your option) 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. -+ * -+ * By Richard W.M. Jones (rjones@redhat.com). -+ */ -+ -+#include -+ -+#include "qemu-common.h" -+#include "qemu-timer.h" -+#include "watchdog.h" -+#include "hw.h" -+#include "isa.h" -+#include "pc.h" -+#include "pci.h" -+ -+/*#define I6300ESB_DEBUG 1*/ -+ -+#ifdef I6300ESB_DEBUG -+#define i6300esb_debug(fs,...) \ -+ fprintf(stderr,"i6300esb: %s: "fs,__func__,##__VA_ARGS__) -+#else -+#define i6300esb_debug(fs,...) -+#endif -+ -+#ifndef PCI_DEVICE_ID_INTEL_ESB_9 -+#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab -+#endif -+ -+/* PCI configuration registers */ -+#define ESB_CONFIG_REG 0x60 /* Config register */ -+#define ESB_LOCK_REG 0x68 /* WDT lock register */ -+ -+/* Memory mapped registers (offset from base address) */ -+#define ESB_TIMER1_REG 0x00 /* Timer1 value after each reset */ -+#define ESB_TIMER2_REG 0x04 /* Timer2 value after each reset */ -+#define ESB_GINTSR_REG 0x08 /* General Interrupt Status Register */ -+#define ESB_RELOAD_REG 0x0c /* Reload register */ -+ -+/* Lock register bits */ -+#define ESB_WDT_FUNC (0x01 << 2) /* Watchdog functionality */ -+#define ESB_WDT_ENABLE (0x01 << 1) /* Enable WDT */ -+#define ESB_WDT_LOCK (0x01 << 0) /* Lock (nowayout) */ -+ -+/* Config register bits */ -+#define ESB_WDT_REBOOT (0x01 << 5) /* Enable reboot on timeout */ -+#define ESB_WDT_FREQ (0x01 << 2) /* Decrement frequency */ -+#define ESB_WDT_INTTYPE (0x11 << 0) /* Interrupt type on timer1 timeout */ -+ -+/* Reload register bits */ -+#define ESB_WDT_RELOAD (0x01 << 8) /* prevent timeout */ -+ -+/* Magic constants */ -+#define ESB_UNLOCK1 0x80 /* Step 1 to unlock reset registers */ -+#define ESB_UNLOCK2 0x86 /* Step 2 to unlock reset registers */ -+ -+/* Device state. */ -+struct I6300State { -+ PCIDevice dev; /* PCI device state, must be first field. */ -+ -+ int reboot_enabled; /* "Reboot" on timer expiry. The real action -+ * performed depends on the -watchdog-action -+ * param passed on QEMU command line. -+ */ -+ int clock_scale; /* Clock scale. */ -+#define CLOCK_SCALE_1KHZ 0 -+#define CLOCK_SCALE_1MHZ 1 -+ -+ int int_type; /* Interrupt type generated. */ -+#define INT_TYPE_IRQ 0 /* APIC 1, INT 10 */ -+#define INT_TYPE_SMI 2 -+#define INT_TYPE_DISABLED 3 -+ -+ int free_run; /* If true, reload timer on expiry. */ -+ int locked; /* If true, enabled field cannot be changed. */ -+ int enabled; /* If true, watchdog is enabled. */ -+ -+ QEMUTimer *timer; /* The actual watchdog timer. */ -+ -+ uint32_t timer1_preload; /* Values preloaded into timer1, timer2. */ -+ uint32_t timer2_preload; -+ int stage; /* Stage (1 or 2). */ -+ -+ int unlock_state; /* Guest writes 0x80, 0x86 to unlock the -+ * registers, and we transition through -+ * states 0 -> 1 -> 2 when this happens. -+ */ -+ -+ int previous_reboot_flag; /* If the watchdog caused the previous -+ * reboot, this flag will be set. -+ */ -+}; -+ -+typedef struct I6300State I6300State; -+ -+/* This function is called when the watchdog has either been enabled -+ * (hence it starts counting down) or has been keep-alived. -+ */ -+static void i6300esb_restart_timer(I6300State *d, int stage) -+{ -+ int64_t timeout; -+ -+ if (!d->enabled) -+ return; -+ -+ d->stage = stage; -+ -+ if (d->stage <= 1) -+ timeout = d->timer1_preload; -+ else -+ timeout = d->timer2_preload; -+ -+ if (d->clock_scale == CLOCK_SCALE_1KHZ) -+ timeout <<= 15; -+ else -+ timeout <<= 5; -+ -+ /* Get the timeout in units of ticks_per_sec. */ -+ timeout = ticks_per_sec * timeout / 33000000; -+ -+ i6300esb_debug("stage %d, timeout %" PRIi64 "\n", d->stage, timeout); -+ -+ qemu_mod_timer(d->timer, qemu_get_clock(vm_clock) + timeout); -+} -+ -+/* This is called when the guest disables the watchdog. */ -+static void i6300esb_disable_timer(I6300State *d) -+{ -+ i6300esb_debug("timer disabled\n"); -+ -+ qemu_del_timer(d->timer); -+} -+ -+static void i6300esb_reset(I6300State *d) -+{ -+ /* XXX We should probably reset other parts of the state here, -+ * but we should also reset our state on general machine reset -+ * too. For now just disable the timer so it doesn't fire -+ * again after the reboot. -+ */ -+ i6300esb_disable_timer(d); -+} -+ -+/* This function is called when the watchdog expires. Note that -+ * the hardware has two timers, and so expiry happens in two stages. -+ * If d->stage == 1 then we perform the first stage action (usually, -+ * sending an interrupt) and then restart the timer again for the -+ * second stage. If the second stage expires then the watchdog -+ * really has run out. -+ */ -+static void i6300esb_timer_expired(void *vp) -+{ -+ I6300State *d = (I6300State *) vp; -+ -+ i6300esb_debug("stage %d\n", d->stage); -+ -+ if (d->stage == 1) { -+ /* What to do at the end of stage 1? */ -+ switch (d->int_type) { -+ case INT_TYPE_IRQ: -+ fprintf(stderr, "i6300esb_timer_expired: I would send APIC 1 INT 10 here if I knew how (XXX)\n"); -+ break; -+ case INT_TYPE_SMI: -+ fprintf(stderr, "i6300esb_timer_expired: I would send SMI here if I knew how (XXX)\n"); -+ break; -+ } -+ -+ /* Start the second stage. */ -+ i6300esb_restart_timer(d, 2); -+ } else { -+ /* Second stage expired, reboot for real. */ -+ if (d->reboot_enabled) { -+ d->previous_reboot_flag = 1; -+ watchdog_perform_action(); /* This reboots, exits, etc */ -+ i6300esb_reset(d); -+ } -+ -+ /* In "free running mode" we start stage 1 again. */ -+ if (d->free_run) -+ i6300esb_restart_timer(d, 1); -+ } -+} -+ -+static void i6300esb_config_write(PCIDevice *dev, uint32_t addr, -+ uint32_t data, int len) -+{ -+ I6300State *d = (I6300State *) dev; -+ int old; -+ -+ i6300esb_debug("addr = %x, data = %x, len = %d\n", addr, data, len); -+ -+ if (addr == ESB_CONFIG_REG && len == 2) { -+ d->reboot_enabled = (data & ESB_WDT_REBOOT) == 0; -+ d->clock_scale = -+ (data & ESB_WDT_FREQ) != 0 ? CLOCK_SCALE_1MHZ : CLOCK_SCALE_1KHZ; -+ d->int_type = (data & ESB_WDT_INTTYPE); -+ } else if (addr == ESB_LOCK_REG && len == 1) { -+ if (!d->locked) { -+ d->locked = (data & ESB_WDT_LOCK) != 0; -+ d->free_run = (data & ESB_WDT_FUNC) != 0; -+ old = d->enabled; -+ d->enabled = (data & ESB_WDT_ENABLE) != 0; -+ if (!old && d->enabled) /* Enabled transitioned from 0 -> 1 */ -+ i6300esb_restart_timer(d, 1); -+ else if (!d->enabled) -+ i6300esb_disable_timer(d); -+ } -+ } else { -+ pci_default_write_config(dev, addr, data, len); -+ } -+} -+ -+static uint32_t i6300esb_config_read(PCIDevice *dev, uint32_t addr, int len) -+{ -+ I6300State *d = (I6300State *) dev; -+ uint32_t data; -+ -+ i6300esb_debug ("addr = %x, len = %d\n", addr, len); -+ -+ if (addr == ESB_CONFIG_REG && len == 2) { -+ data = -+ (d->reboot_enabled ? 0 : ESB_WDT_REBOOT) | -+ (d->clock_scale == CLOCK_SCALE_1MHZ ? ESB_WDT_FREQ : 0) | -+ d->int_type; -+ return data; -+ } else if (addr == ESB_LOCK_REG && len == 1) { -+ data = -+ (d->free_run ? ESB_WDT_FUNC : 0) | -+ (d->locked ? ESB_WDT_LOCK : 0) | -+ (d->enabled ? ESB_WDT_ENABLE : 0); -+ return data; -+ } else { -+ return pci_default_read_config(dev, addr, len); -+ } -+} -+ -+static uint32_t i6300esb_mem_readb(void *vp, target_phys_addr_t addr) -+{ -+ i6300esb_debug ("addr = %x\n", (int) addr); -+ -+ return 0; -+} -+ -+static uint32_t i6300esb_mem_readw(void *vp, target_phys_addr_t addr) -+{ -+ uint32_t data = 0; -+ I6300State *d = (I6300State *) vp; -+ -+ i6300esb_debug("addr = %x\n", (int) addr); -+ -+ if (addr == 0xc) { -+ /* The previous reboot flag is really bit 9, but there is -+ * a bug in the Linux driver where it thinks it's bit 12. -+ * Set both. -+ */ -+ data = d->previous_reboot_flag ? 0x1200 : 0; -+ } -+ -+ return data; -+} -+ -+static uint32_t i6300esb_mem_readl(void *vp, target_phys_addr_t addr) -+{ -+ i6300esb_debug("addr = %x\n", (int) addr); -+ -+ return 0; -+} -+ -+static void i6300esb_mem_writeb(void *vp, target_phys_addr_t addr, uint32_t val) -+{ -+ I6300State *d = (I6300State *) vp; -+ -+ i6300esb_debug("addr = %x, val = %x\n", (int) addr, val); -+ -+ if (addr == 0xc && val == 0x80) -+ d->unlock_state = 1; -+ else if (addr == 0xc && val == 0x86 && d->unlock_state == 1) -+ d->unlock_state = 2; -+} -+ -+static void i6300esb_mem_writew(void *vp, target_phys_addr_t addr, uint32_t val) -+{ -+ I6300State *d = (I6300State *) vp; -+ -+ i6300esb_debug("addr = %x, val = %x\n", (int) addr, val); -+ -+ if (addr == 0xc && val == 0x80) -+ d->unlock_state = 1; -+ else if (addr == 0xc && val == 0x86 && d->unlock_state == 1) -+ d->unlock_state = 2; -+ else { -+ if (d->unlock_state == 2) { -+ if (addr == 0xc) { -+ if ((val & 0x100) != 0) -+ /* This is the "ping" from the userspace watchdog in -+ * the guest ... -+ */ -+ i6300esb_restart_timer(d, 1); -+ -+ /* Setting bit 9 resets the previous reboot flag. -+ * There's a bug in the Linux driver where it sets -+ * bit 12 instead. -+ */ -+ if ((val & 0x200) != 0 || (val & 0x1000) != 0) { -+ d->previous_reboot_flag = 0; -+ } -+ } -+ -+ d->unlock_state = 0; -+ } -+ } -+} -+ -+static void i6300esb_mem_writel(void *vp, target_phys_addr_t addr, uint32_t val) -+{ -+ I6300State *d = (I6300State *) vp; -+ -+ i6300esb_debug ("addr = %x, val = %x\n", (int) addr, val); -+ -+ if (addr == 0xc && val == 0x80) -+ d->unlock_state = 1; -+ else if (addr == 0xc && val == 0x86 && d->unlock_state == 1) -+ d->unlock_state = 2; -+ else { -+ if (d->unlock_state == 2) { -+ if (addr == 0) -+ d->timer1_preload = val & 0xfffff; -+ else if (addr == 4) -+ d->timer2_preload = val & 0xfffff; -+ -+ d->unlock_state = 0; -+ } -+ } -+} -+ -+static void i6300esb_map(PCIDevice *dev, int region_num, -+ uint32_t addr, uint32_t size, int type) -+{ -+ static CPUReadMemoryFunc *mem_read[3] = { -+ i6300esb_mem_readb, -+ i6300esb_mem_readw, -+ i6300esb_mem_readl, -+ }; -+ static CPUWriteMemoryFunc *mem_write[3] = { -+ i6300esb_mem_writeb, -+ i6300esb_mem_writew, -+ i6300esb_mem_writel, -+ }; -+ I6300State *d = (I6300State *) dev; -+ int io_mem; -+ -+ i6300esb_debug("addr = %x, size = %x, type = %d\n", addr, size, type); -+ -+ io_mem = cpu_register_io_memory (0, mem_read, mem_write, d); -+ cpu_register_physical_memory (addr, 0x10, io_mem); -+ /* qemu_register_coalesced_mmio (addr, 0x10); ? */ -+} -+ -+static void i6300esb_save(QEMUFile *f, void *vp) -+{ -+ I6300State *d = (I6300State *) vp; -+ -+ pci_device_save(&d->dev, f); -+ qemu_put_be32(f, d->reboot_enabled); -+ qemu_put_be32(f, d->clock_scale); -+ qemu_put_be32(f, d->int_type); -+ qemu_put_be32(f, d->free_run); -+ qemu_put_be32(f, d->locked); -+ qemu_put_be32(f, d->enabled); -+ qemu_put_timer(f, d->timer); -+ qemu_put_be32(f, d->timer1_preload); -+ qemu_put_be32(f, d->timer2_preload); -+ qemu_put_be32(f, d->stage); -+ qemu_put_be32(f, d->unlock_state); -+ qemu_put_be32(f, d->previous_reboot_flag); -+} -+ -+static int i6300esb_load(QEMUFile *f, void *vp, int version) -+{ -+ I6300State *d = (I6300State *) vp; -+ -+ if (version != sizeof (I6300State)) -+ return -EINVAL; -+ -+ pci_device_load(&d->dev, f); -+ d->reboot_enabled = qemu_get_be32(f); -+ d->clock_scale = qemu_get_be32(f); -+ d->int_type = qemu_get_be32(f); -+ d->free_run = qemu_get_be32(f); -+ d->locked = qemu_get_be32(f); -+ d->enabled = qemu_get_be32(f); -+ qemu_get_timer(f, d->timer); -+ d->timer1_preload = qemu_get_be32(f); -+ d->timer2_preload = qemu_get_be32(f); -+ d->stage = qemu_get_be32(f); -+ d->unlock_state = qemu_get_be32(f); -+ d->previous_reboot_flag = qemu_get_be32(f); -+ -+ return 0; -+} -+ -+/* Create and initialize a virtual Intel 6300ESB during PC creation. */ -+static void i6300esb_pc_init(PCIBus *pci_bus) -+{ -+ I6300State *d; -+ uint8_t *pci_conf; -+ -+ if (!pci_bus) { -+ fprintf(stderr, "wdt_i6300esb: no PCI bus in this machine\n"); -+ return; -+ } -+ -+ d = (I6300State *) -+ pci_register_device (pci_bus, "i6300esb_wdt", sizeof (I6300State), -+ -1, -+ i6300esb_config_read, i6300esb_config_write); -+ -+ d->reboot_enabled = 1; -+ d->clock_scale = CLOCK_SCALE_1KHZ; -+ d->int_type = INT_TYPE_IRQ; -+ d->free_run = 0; -+ d->locked = 0; -+ d->enabled = 0; -+ d->timer = qemu_new_timer(vm_clock, i6300esb_timer_expired, d); -+ d->timer1_preload = 0xfffff; -+ d->timer2_preload = 0xfffff; -+ d->stage = 1; -+ d->unlock_state = 0; -+ d->previous_reboot_flag = 0; -+ -+ pci_conf = d->dev.config; -+ pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); -+ pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_ESB_9); -+ pci_config_set_class(pci_conf, PCI_CLASS_SYSTEM_OTHER); -+ pci_conf[0x0e] = 0x00; -+ -+ pci_register_io_region(&d->dev, 0, 0x10, -+ PCI_ADDRESS_SPACE_MEM, i6300esb_map); -+ -+ register_savevm("i6300esb_wdt", -1, sizeof(I6300State), -+ i6300esb_save, i6300esb_load, d); -+} -+ -+static WatchdogTimerModel model = { -+ .wdt_name = "i6300esb", -+ .wdt_description = "Intel 6300ESB", -+ .wdt_pc_init = i6300esb_pc_init, -+}; -+ -+void wdt_i6300esb_init(void) -+{ -+ watchdog_add_model(&model); -+} -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/wdt_ib700.c -=================================================================== ---- /dev/null -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/wdt_ib700.c -@@ -0,0 +1,112 @@ -+/* -+ * Virtual hardware watchdog. -+ * -+ * Copyright (C) 2009 Red Hat 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 (at your option) 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. -+ * -+ * By Richard W.M. Jones (rjones@redhat.com). -+ */ -+ -+#include "qemu-common.h" -+#include "qemu-timer.h" -+#include "watchdog.h" -+#include "hw.h" -+#include "isa.h" -+#include "pc.h" -+ -+/*#define IB700_DEBUG 1*/ -+ -+#ifdef IB700_DEBUG -+#define ib700_debug(fs,...) \ -+ fprintf(stderr,"ib700: %s: "fs,__func__,##__VA_ARGS__) -+#else -+#define ib700_debug(fs,...) -+#endif -+ -+/* This is the timer. We use a global here because the watchdog -+ * code ensures there is only one watchdog (it is located at a fixed, -+ * unchangable IO port, so there could only ever be one anyway). -+ */ -+static QEMUTimer *timer = NULL; -+ -+/* A write to this register enables the timer. */ -+static void ib700_write_enable_reg(void *vp, uint32_t addr, uint32_t data) -+{ -+ static int time_map[] = { -+ 30, 28, 26, 24, 22, 20, 18, 16, -+ 14, 12, 10, 8, 6, 4, 2, 0 -+ }; -+ int64 timeout; -+ -+ ib700_debug("addr = %x, data = %x\n", addr, data); -+ -+ timeout = (int64_t) time_map[data & 0xF] * ticks_per_sec; -+ qemu_mod_timer(timer, qemu_get_clock (vm_clock) + timeout); -+} -+ -+/* A write (of any value) to this register disables the timer. */ -+static void ib700_write_disable_reg(void *vp, uint32_t addr, uint32_t data) -+{ -+ ib700_debug("addr = %x, data = %x\n", addr, data); -+ -+ qemu_del_timer(timer); -+} -+ -+/* This is called when the watchdog expires. */ -+static void ib700_timer_expired(void *vp) -+{ -+ ib700_debug("watchdog expired\n"); -+ -+ watchdog_perform_action(); -+ qemu_del_timer(timer); -+} -+ -+static void ib700_save(QEMUFile *f, void *vp) -+{ -+ qemu_put_timer(f, timer); -+} -+ -+static int ib700_load(QEMUFile *f, void *vp, int version) -+{ -+ if (version != 0) -+ return -EINVAL; -+ -+ qemu_get_timer(f, timer); -+ -+ return 0; -+} -+ -+/* Create and initialize a virtual IB700 during PC creation. */ -+static void ib700_pc_init(PCIBus *unused) -+{ -+ register_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, NULL); -+ -+ register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, NULL); -+ register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, NULL); -+} -+ -+static WatchdogTimerModel model = { -+ .wdt_name = "ib700", -+ .wdt_description = "iBASE 700", -+ .wdt_pc_init = ib700_pc_init, -+}; -+ -+void wdt_ib700_init(void) -+{ -+ watchdog_add_model(&model); -+ timer = qemu_new_timer(vm_clock, ib700_timer_expired, NULL); -+} -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/monitor.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/monitor.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/monitor.c -@@ -26,6 +26,7 @@ - #include "hw/pcmcia.h" - #include "hw/pc.h" - #include "hw/pci.h" -+#include "hw/watchdog.h" - #include "gdbstub.h" - #include "net.h" - #include "qemu-char.h" -@@ -531,6 +532,13 @@ static void do_gdbserver(const char *por - } - #endif - -+static void do_watchdog_action(const char *action) -+{ -+ if (select_watchdog_action(action) == -1) { -+ qemu_printf("Unknown watchdog action '%s'\n", action); -+ } -+} -+ - static void term_printc(int c) - { - term_printf("'"); -@@ -1605,6 +1613,8 @@ static const term_cmd_t term_cmds[] = { - "target", "request VM to change it's memory allocation (in MB)" }, - { "set_link", "ss", do_set_link, - "name [up|down]", "change the link status of a network adapter" }, -+ { "watchdog_action", "s", do_watchdog_action, -+ "[reset|shutdown|poweroff|pause|debug|none]", "change watchdog action" }, - { "cpu_set", "is", do_cpu_set_nr, - "cpu [online|offline]", "change cpu state" }, - { NULL, NULL, }, -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vl.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/vl.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/vl.c -@@ -30,6 +30,7 @@ - #include "hw/isa.h" - #include "hw/baum.h" - #include "hw/bt.h" -+#include "hw/watchdog.h" - #include "net.h" - #include "console.h" - #include "sysemu.h" -@@ -249,6 +250,8 @@ int no_shutdown = 0; - int cursor_hide = 1; - int graphic_rotate = 0; - int daemonize = 0; -+WatchdogTimerModel *watchdog = NULL; -+int watchdog_action = WDT_RESET; - const char *option_rom[MAX_OPTION_ROMS]; - int nb_option_roms; - int semihosting_enabled = 0; -@@ -4177,6 +4180,10 @@ static void help(int exitcode) - "-startdate select initial date of the clock\n" - "-icount [N|auto]\n" - " enable virtual instruction counter with 2^N clock ticks per instruction\n" -+ "-watchdog i6300esb|ib700\n" -+ " enable virtual hardware watchdog [default=none]\n" -+ "-watchdog-action reset|shutdown|poweroff|pause|debug|none\n" -+ " action when watchdog fires [default=reset]\n" - "-echr chr set terminal escape character instead of ctrl-a\n" - "-virtioconsole c\n" - " set virtio console\n" -@@ -4324,6 +4331,8 @@ enum { - QEMU_OPTION_localtime, - QEMU_OPTION_startdate, - QEMU_OPTION_icount, -+ QEMU_OPTION_watchdog, -+ QEMU_OPTION_watchdog_action, - QEMU_OPTION_echr, - QEMU_OPTION_virtiocon, - QEMU_OPTION_show_cursor, -@@ -4450,6 +4459,8 @@ static const QEMUOption qemu_options[] = - { "localtime", 0, QEMU_OPTION_localtime }, - { "startdate", HAS_ARG, QEMU_OPTION_startdate }, - { "icount", HAS_ARG, QEMU_OPTION_icount }, -+ { "watchdog", HAS_ARG, QEMU_OPTION_watchdog }, -+ { "watchdog-action", HAS_ARG, QEMU_OPTION_watchdog_action }, - { "echr", HAS_ARG, QEMU_OPTION_echr }, - { "virtioconsole", HAS_ARG, QEMU_OPTION_virtiocon }, - { "show-cursor", 0, QEMU_OPTION_show_cursor }, -@@ -4951,6 +4962,8 @@ int main(int argc, char **argv, char **e - tb_size = 0; - autostart= 1; - -+ register_watchdogs(); -+ - optind = 1; - for(;;) { - if (optind >= argc) -@@ -5325,6 +5338,17 @@ int main(int argc, char **argv, char **e - serial_devices[serial_device_index] = optarg; - serial_device_index++; - break; -+ case QEMU_OPTION_watchdog: -+ i = select_watchdog(optarg); -+ if (i > 0) -+ exit (i == 1 ? 1 : 0); -+ break; -+ case QEMU_OPTION_watchdog_action: -+ if (select_watchdog_action(optarg) == -1) { -+ fprintf(stderr, "Unknown -watchdog-action parameter\n"); -+ exit(1); -+ } -+ break; - case QEMU_OPTION_virtiocon: - if (virtio_console_index >= MAX_VIRTIO_CONSOLES) { - fprintf(stderr, "qemu: too many virtio consoles\n"); diff --git a/kernel-boot-hvm.patch b/kernel-boot-hvm.patch deleted file mode 100644 index 969f4c5..0000000 --- a/kernel-boot-hvm.patch +++ /dev/null @@ -1,245 +0,0 @@ -Direct kernel boot to HVM guests has regression from xen-3.3 to xen-4.0. -Foreport this feature to latest qemu-xen. Make a fake boot sector with given -kernel and initrd, which could be accessed by hvmloader. - -Signed-off-by: Chunyan Liu - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/block.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/block.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/block.c -@@ -596,6 +596,16 @@ int bdrv_read(BlockDriverState *bs, int6 - - if (bdrv_check_request(bs, sector_num, nb_sectors)) - return -EIO; -+ -+ if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { -+ memcpy(buf, bs->boot_sector_data, 512); -+ sector_num++; -+ nb_sectors--; -+ buf += 512; -+ if (nb_sectors == 0) -+ return 0; -+ } -+ - if (drv->bdrv_pread) { - int ret, len; - len = nb_sectors * 512; -@@ -631,6 +641,10 @@ int bdrv_write(BlockDriverState *bs, int - if (bdrv_check_request(bs, sector_num, nb_sectors)) - return -EIO; - -+ if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { -+ memcpy(bs->boot_sector_data, buf, 512); -+ } -+ - if (drv->bdrv_pwrite) { - int ret, len, count = 0; - len = nb_sectors * 512; -@@ -934,6 +948,16 @@ void bdrv_guess_geometry(BlockDriverStat - } - } - -+/* force a given boot sector. */ -+void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size) -+{ -+ bs->boot_sector_enabled = 1; -+ if (size > 512) -+ size = 512; -+ memcpy(bs->boot_sector_data, data, size); -+ memset(bs->boot_sector_data + size, 0, 512 - size); -+} -+ - void bdrv_set_geometry_hint(BlockDriverState *bs, - int cyls, int heads, int secs) - { -@@ -1464,6 +1488,14 @@ BlockDriverAIOCB *bdrv_aio_read(BlockDri - if (bdrv_check_request(bs, sector_num, nb_sectors)) - return NULL; - -+ /* XXX: we assume that nb_sectors == 0 is suppored by the async read */ -+ if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { -+ memcpy(buf, bs->boot_sector_data, 512); -+ sector_num++; -+ nb_sectors--; -+ buf += 512; -+ } -+ - ret = drv->bdrv_aio_read(bs, sector_num, buf, nb_sectors, cb, opaque); - - if (ret) { -@@ -1489,6 +1521,10 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDr - if (bdrv_check_request(bs, sector_num, nb_sectors)) - return NULL; - -+ if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { -+ memcpy(bs->boot_sector_data, buf, 512); -+ } -+ - ret = drv->bdrv_aio_write(bs, sector_num, buf, nb_sectors, cb, opaque); - - if (ret) { -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/block_int.h -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/block_int.h -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/block_int.h -@@ -122,6 +122,9 @@ struct BlockDriverState { - BlockDriver *drv; /* NULL means no media */ - void *opaque; - -+ int boot_sector_enabled; -+ uint8_t boot_sector_data[512]; -+ - char filename[1024]; - char backing_file[1024]; /* if non zero, the image is a diff of - this file image */ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pc.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/pc.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pc.c -@@ -474,45 +474,28 @@ static void bochs_bios_init(void) - - /* Generate an initial boot sector which sets state and jump to - a specified vector */ --static void generate_bootsect(uint8_t *option_rom, -- uint32_t gpr[8], uint16_t segs[6], uint16_t ip) -+static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip) - { -- uint8_t rom[512], *p, *reloc; -- uint8_t sum; -+ uint8_t bootsect[512], *p; - int i; -+ int hda; -+ -+ hda = drive_get_index(IF_IDE, 0, 0); -+ if (hda == -1) { -+ fprintf(stderr, "A disk image must be given for 'hda' when booting " -+ "a Linux kernel\n(if you really don't want it, use /dev/zero)\n"); -+ exit(1); -+ } -+ memset(bootsect, 0, sizeof(bootsect)); - -- memset(rom, 0, sizeof(rom)); -- -- p = rom; -- /* Make sure we have an option rom signature */ -- *p++ = 0x55; -- *p++ = 0xaa; -- -- /* ROM size in sectors*/ -- *p++ = 1; -- -- /* Hook int19 */ -- -- *p++ = 0x50; /* push ax */ -- *p++ = 0x1e; /* push ds */ -- *p++ = 0x31; *p++ = 0xc0; /* xor ax, ax */ -- *p++ = 0x8e; *p++ = 0xd8; /* mov ax, ds */ -- -- *p++ = 0xc7; *p++ = 0x06; /* movvw _start,0x64 */ -- *p++ = 0x64; *p++ = 0x00; -- reloc = p; -- *p++ = 0x00; *p++ = 0x00; -- -- *p++ = 0x8c; *p++ = 0x0e; /* mov cs,0x66 */ -- *p++ = 0x66; *p++ = 0x00; -- -- *p++ = 0x1f; /* pop ds */ -- *p++ = 0x58; /* pop ax */ -- *p++ = 0xcb; /* lret */ -- -- /* Actual code */ -- *reloc = (p - rom); -+ /* Copy the MSDOS partition table if possible */ -+ bdrv_read(drives_table[hda].bdrv, 0, bootsect, 1); -+ /* Make sure we have a partition signature */ -+ bootsect[510] = 0x55; -+ bootsect[511] = 0xaa; - -+ /* Actual code */ -+ p = bootsect; - *p++ = 0xfa; /* CLI */ - *p++ = 0xfc; /* CLD */ - -@@ -542,13 +525,7 @@ static void generate_bootsect(uint8_t *o - *p++ = segs[1]; /* CS */ - *p++ = segs[1] >> 8; - -- /* sign rom */ -- sum = 0; -- for (i = 0; i < (sizeof(rom) - 1); i++) -- sum += rom[i]; -- rom[sizeof(rom) - 1] = -sum; -- -- memcpy(option_rom, rom, sizeof(rom)); -+ bdrv_set_boot_sector(drives_table[hda].bdrv, bootsect, sizeof(bootsect)); - } - - static long get_file_size(FILE *f) -@@ -565,8 +542,7 @@ static long get_file_size(FILE *f) - return size; - } - --static void load_linux(uint8_t *option_rom, -- const char *kernel_filename, -+static void load_linux(const char *kernel_filename, - const char *initrd_filename, - const char *kernel_cmdline) - { -@@ -632,7 +608,9 @@ static void load_linux(uint8_t *option_r - - /* Special pages are placed at end of low RAM: pick an arbitrary one and - * subtract a suitably large amount of padding (64kB) to skip BIOS data. */ -- xc_get_hvm_param(xc_handle, domid, HVM_PARAM_BUFIOREQ_PFN, &end_low_ram); -+ //xc_get_hvm_param(xc_handle, domid, HVM_PARAM_BUFIOREQ_PFN, &end_low_ram); -+ /* BUFIO Page beyond last_pfn, use 0x7ffc instead. Fix ME. */ -+ end_low_ram = 0x7ffc; - end_low_ram = (end_low_ram << 12) - (64*1024); - - /* highest address for loading the initrd */ -@@ -721,7 +699,7 @@ static void load_linux(uint8_t *option_r - memset(gpr, 0, sizeof gpr); - gpr[4] = cmdline_addr-real_addr-16; /* SP (-16 is paranoia) */ - -- generate_bootsect(option_rom, gpr, seg, 0); -+ generate_bootsect(gpr, seg, 0); - #endif - } - -@@ -932,14 +910,6 @@ vga_bios_error: - int size, offset; - - offset = 0; -- if (linux_boot) { -- option_rom_offset = qemu_ram_alloc(TARGET_PAGE_SIZE); -- load_linux(phys_ram_base + option_rom_offset, -- kernel_filename, initrd_filename, kernel_cmdline); -- cpu_register_physical_memory(0xd0000, TARGET_PAGE_SIZE, -- option_rom_offset | IO_MEM_ROM); -- offset = TARGET_PAGE_SIZE; -- } - - for (i = 0; i < nb_option_roms; i++) { - size = get_image_size(option_rom[i]); -@@ -973,6 +943,9 @@ vga_bios_error: - - bochs_bios_init(); - -+ if (linux_boot) -+ load_linux(kernel_filename, initrd_filename, kernel_cmdline); -+ - cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1); - i8259 = i8259_init(cpu_irq[0]); - ferr_irq = i8259[13]; -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/block.h -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/block.h -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/block.h -@@ -82,6 +82,7 @@ int64_t bdrv_getlength(BlockDriverState - void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); - void bdrv_guess_geometry(BlockDriverState *bs, int *pcyls, int *pheads, int *psecs); - int bdrv_commit(BlockDriverState *bs); -+void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size); - /* async block I/O */ - typedef struct BlockDriverAIOCB BlockDriverAIOCB; - typedef void BlockDriverCompletionFunc(void *opaque, int ret); diff --git a/log-guest-console.patch b/log-guest-console.patch deleted file mode 100644 index c6e0ded..0000000 --- a/log-guest-console.patch +++ /dev/null @@ -1,142 +0,0 @@ -Add code to support logging xen-domU console, as what xenconsoled does. Log info -will be saved in /var/log/xen/console/guest-domUname.log. - -Signed-off-by: Chunyan Liu ---- - hw/xen_console.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 files changed, 71 insertions(+), 0 deletions(-) - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_console.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_console.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_console.c -@@ -38,6 +38,8 @@ - #include "qemu-char.h" - #include "xen_backend.h" - -+static int log_guest = 0; -+ - struct buffer { - uint8_t *data; - size_t consumed; -@@ -54,8 +56,24 @@ struct XenConsole { - void *sring; - CharDriverState *chr; - int backlog; -+ int log_fd; - }; - -+static int write_all(int fd, const char* buf, size_t len) -+{ -+ while (len) { -+ ssize_t ret = write(fd, buf, len); -+ if (ret == -1 && errno == EINTR) -+ continue; -+ if (ret < 0) -+ return -1; -+ len -= ret; -+ buf += ret; -+ } -+ -+ return 0; -+} -+ - static void buffer_append(struct XenConsole *con) - { - struct buffer *buffer = &con->buffer; -@@ -83,6 +101,15 @@ static void buffer_append(struct XenCons - intf->out_cons = cons; - xen_be_send_notify(&con->xendev); - -+ if (con->log_fd != -1) { -+ int logret; -+ logret = write_all(con->log_fd, buffer->data + buffer->size - size, size); -+ if (logret < 0) { -+ xen_be_printf(&con->xendev, 1, "Write to log failed on domain %d: %d (%s)\n", -+ con->xendev.dom, errno, strerror(errno)); -+ } -+ } -+ - if (buffer->max_capacity && - buffer->size > buffer->max_capacity) { - /* Discard the middle of the data. */ -@@ -176,6 +203,37 @@ static void xencons_send(struct XenConso - } - } - -+static int create_domain_log(struct XenConsole *con) -+{ -+ char *logfile; -+ char *path, *domname; -+ int fd; -+ const char *logdir = "/var/log/xen/console"; -+ -+ path = xs_get_domain_path(xenstore, con->xendev.dom); -+ domname = xenstore_read_str(path, "name"); -+ free(path); -+ if (!domname) -+ return -1; -+ -+ if (mkdir(logdir, 0755) && errno != EEXIST) -+ { -+ xen_be_printf(&con->xendev, 1, "Directory %s does not exist and fail to create it!", logdir); -+ return -1; -+ } -+ -+ if (asprintf(&logfile, "%s/guest-%s.log", logdir, domname) < 0) -+ return -1; -+ qemu_free(domname); -+ -+ fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644); -+ free(logfile); -+ if (fd == -1) -+ xen_be_printf(&con->xendev, 1, "Failed to open log %s: %d (%s)", logfile, errno, strerror(errno)); -+ -+ return fd; -+} -+ - /* -------------------------------------------------------------------- */ - - static int con_init(struct XenDevice *xendev) -@@ -183,6 +241,7 @@ static int con_init(struct XenDevice *xe - struct XenConsole *con = container_of(xendev, struct XenConsole, xendev); - char *type, *dom, label[32]; - const char *output; -+ char *logenv = NULL; - - /* setup */ - dom = xs_get_domain_path(xenstore, con->xendev.dom); -@@ -209,6 +268,10 @@ static int con_init(struct XenDevice *xe - con->chr = qemu_chr_open(label, output, NULL); - xenstore_store_pv_console_info(con->xendev.dev, con->chr, output); - -+ logenv = getenv("XENCONSOLED_TRACE"); -+ if (logenv != NULL && strlen(logenv) == strlen("guest") && !strcmp(logenv, "guest")) { -+ log_guest = 1; -+ } - return 0; - } - -@@ -246,6 +309,9 @@ static int con_initialise(struct XenDevi - con->xendev.remote_port, - con->xendev.local_port, - con->buffer.max_capacity); -+ con->log_fd = -1; -+ if (log_guest) -+ con->log_fd = create_domain_log(con); - return 0; - } - -@@ -266,6 +332,12 @@ static void con_disconnect(struct XenDev - xc_gnttab_munmap(xendev->gnttabdev, con->sring, 1); - con->sring = NULL; - } -+ -+ if (con->log_fd != -1) { -+ close(con->log_fd); -+ con->log_fd = -1; -+ } -+ - } - - static void con_event(struct XenDevice *xendev) diff --git a/minios-fixups.patch b/minios-fixups.patch index 90f5572..71d9788 100644 --- a/minios-fixups.patch +++ b/minios-fixups.patch @@ -1,8 +1,8 @@ -Index: xen-4.2.0-testing/extras/mini-os/lib/math.c +Index: xen-4.3.0-testing/extras/mini-os/lib/math.c =================================================================== ---- xen-4.2.0-testing.orig/extras/mini-os/lib/math.c -+++ xen-4.2.0-testing/extras/mini-os/lib/math.c -@@ -190,6 +190,7 @@ __qdivrem(u_quad_t uq, u_quad_t vq, u_qu +--- xen-4.3.0-testing.orig/extras/mini-os/lib/math.c ++++ xen-4.3.0-testing/extras/mini-os/lib/math.c +@@ -186,6 +186,7 @@ __qdivrem(u_quad_t uq, u_quad_t vq, u_qu * and thus * m = 4 - n <= 2 */ diff --git a/multi-xvdp.patch b/multi-xvdp.patch deleted file mode 100644 index da1c397..0000000 --- a/multi-xvdp.patch +++ /dev/null @@ -1,78 +0,0 @@ -Allow multiple bootloader loopback devices - -Starting several domains concurrently can fail due to using a single -bootloader loopback device. This patch creates a list of bootloader -loopback devices so more than one instance of bootloader can be run -concurrently. - -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -74,7 +74,7 @@ from xen.xend.XendPSCSI import XendPSCSI - from xen.xend.XendDSCSI import XendDSCSI, XendDSCSI_HBA - - MIGRATE_TIMEOUT = 30.0 --BOOTLOADER_LOOPBACK_DEVICE = '/dev/xvdp' -+BOOTLOADER_LOOPBACK_DEVICES = ['/dev/xvd' + chr(x) for x in range(ord('z'), ord('d'), -1)] - - xc = xen.lowlevel.xc.xc() - xoptions = XendOptions.instance() -@@ -3324,33 +3324,38 @@ class XendDomainInfo: - # 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. -- -- log.info("Mounting %s on %s." % -- (fn, BOOTLOADER_LOOPBACK_DEVICE)) -- -- vbd = { -- 'mode': 'RW', -- 'device': BOOTLOADER_LOOPBACK_DEVICE, -- } -- -- from xen.xend import XendDomain -- dom0 = XendDomain.instance().privilegedDomain() -- mounted_vbd_uuid = dom0.create_vbd(vbd, disk); -- vbd_uuid = dom0.create_vbd(vbd, disk) -- dom0._waitForDeviceFrontUUID(vbd_uuid) -- fn = BOOTLOADER_LOOPBACK_DEVICE -- -+ # Try all possible loopback_devices -+ for loopback_device in BOOTLOADER_LOOPBACK_DEVICES: -+ log.info("Mounting %s on %s." % (fn, loopback_device)) -+ vbd = { 'mode' : 'RW', 'device' : loopback_device, } -+ try: -+ from xen.xend import XendDomain -+ dom0 = XendDomain.instance().privilegedDomain() -+ mounted_vbd_uuid = dom0.create_vbd(vbd, disk) -+ dom0._waitForDeviceFrontUUID(mounted_vbd_uuid) -+ fn = loopback_device -+ break -+ except VmError, e: -+ if str(e).find('already connected.') != -1: -+ continue -+ elif str(e).find('isn\'t accessible') != -1: -+ dom0.destroyDevice('vbd', loopback_device, force = True, rm_cfg = True) -+ continue -+ else: -+ raise -+ else: -+ raise - try: - blcfg = bootloader(blexec, fn, self, False, - bootloader_args, kernel, ramdisk, args) - finally: - if mounted: - log.info("Unmounting %s from %s." % -- (fn, BOOTLOADER_LOOPBACK_DEVICE)) -+ (fn, loopback_device)) - if devtype in ['tap', 'tap2']: -- dom0.destroyDevice('tap', BOOTLOADER_LOOPBACK_DEVICE, rm_cfg = True) -+ dom0.destroyDevice('tap', loopback_device, rm_cfg = True) - else: -- dom0.destroyDevice('vbd', BOOTLOADER_LOOPBACK_DEVICE, rm_cfg = True) -+ dom0.destroyDevice('vbd', loopback_device, rm_cfg = True) - if blcfg is None: - msg = "Had a bootloader specified, but can't find disk" - log.error(msg) diff --git a/pvdrv_emulation_control.patch b/pvdrv_emulation_control.patch deleted file mode 100644 index 92044e0..0000000 --- a/pvdrv_emulation_control.patch +++ /dev/null @@ -1,24 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c -@@ -365,6 +365,19 @@ static void platform_ioport_write(void * - net_tap_shutdown_all(); - fprintf(logfile, "Done.\n"); - break; -+ case 8: -+ if (val ==1 ) { -+ fprintf(logfile, "Disconnect IDE hard disk...\n"); -+ ide_unplug_harddisks(); -+ fprintf(logfile, "Done.\n"); -+ } else if (val == 2) { -+ fprintf(logfile, "Disconnect netifs...\n"); -+ pci_unplug_netifs(); -+ fprintf(logfile, "Shutdown taps...\n"); -+ net_tap_shutdown_all(); -+ fprintf(logfile, "Done.\n"); -+ } -+ break; - default: - fprintf(logfile, "Write to bad port %x (base %x) on evtchn device.\n", - addr, ioport_base); diff --git a/qemu-dm-segfault.patch b/qemu-dm-segfault.patch deleted file mode 100644 index 307a881..0000000 --- a/qemu-dm-segfault.patch +++ /dev/null @@ -1,85 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/ide.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/ide.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/ide.c -@@ -935,8 +935,9 @@ static inline void ide_dma_submit_check( - - static inline void ide_set_irq(IDEState *s) - { -- BMDMAState *bm = s->bmdma; -- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ -+ BMDMAState *bm; -+ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ -+ bm = s->bmdma; - if (!(s->cmd & IDE_CMD_DISABLE_IRQ)) { - if (bm) { - bm->status |= BM_STATUS_INT; -@@ -1224,14 +1225,14 @@ static void ide_read_dma_cb(void *opaque - int n; - int64_t sector_num; - -+ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ -+ - if (ret < 0) { - dma_buf_commit(s, 1); - ide_dma_error(s); - return; - } - -- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ -- - n = s->io_buffer_size >> 9; - sector_num = ide_get_sector(s); - if (n > 0) { -@@ -1335,6 +1336,8 @@ static void ide_write_flush_cb(void *opa - BMDMAState *bm = opaque; - IDEState *s = bm->ide_if; - -+ if (!s) return; /* yikes */ -+ - if (ret != 0) { - ide_dma_error(s); - return; -@@ -1366,13 +1369,13 @@ static void ide_write_dma_cb(void *opaqu - int n; - int64_t sector_num; - -+ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ -+ - if (ret < 0) { - if (ide_handle_write_error(s, -ret, BM_STATUS_DMA_RETRY)) - return; - } - -- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ -- - n = s->io_buffer_size >> 9; - sector_num = ide_get_sector(s); - if (n > 0) { -@@ -1429,7 +1432,7 @@ static void ide_flush_cb(void *opaque, i - { - IDEState *s = opaque; - -- if (!s->bs) return; /* ouch! (see below) */ -+ if (!s || !s->bs) return; /* ouch! (see below) */ - - if (ret) { - /* We are completely doomed. The IDE spec does not permit us -@@ -1686,7 +1689,7 @@ static void ide_atapi_cmd_read_dma_cb(vo - IDEState *s = bm->ide_if; - int data_offset, n; - -- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ -+ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ - - if (ret < 0) { - ide_atapi_io_error(s, ret); -@@ -2365,7 +2368,7 @@ static void cdrom_change_cb(void *opaque - IDEState *s = opaque; - uint64_t nb_sectors; - -- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ -+ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ - - bdrv_get_geometry(s->bs, &nb_sectors); - s->nb_sectors = nb_sectors; diff --git a/qemu-security-etch1.diff b/qemu-security-etch1.diff deleted file mode 100644 index e01992f..0000000 --- a/qemu-security-etch1.diff +++ /dev/null @@ -1,38 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/ne2000.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/ne2000.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/ne2000.c -@@ -218,7 +218,7 @@ static int ne2000_can_receive(void *opaq - NE2000State *s = opaque; - - if (s->cmd & E8390_STOP) -- return 1; -+ return 0; - return !ne2000_buffer_full(s); - } - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pc.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/pc.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pc.c -@@ -413,7 +413,8 @@ static void bochs_bios_write(void *opaqu - case 0x400: - case 0x401: - fprintf(stderr, "BIOS panic at rombios.c, line %d\n", val); -- exit(1); -+ /* according to documentation, these can be safely ignored */ -+ break; - case 0x402: - case 0x403: - #ifdef DEBUG_BIOS -@@ -436,8 +437,9 @@ static void bochs_bios_write(void *opaqu - /* LGPL'ed VGA BIOS messages */ - case 0x501: - case 0x502: -+ /* according to documentation, these can be safely ignored */ - fprintf(stderr, "VGA BIOS panic, line %d\n", val); -- exit(1); -+ break; - case 0x500: - case 0x503: - #ifdef DEBUG_BIOS diff --git a/qemu-xen-dir-remote.tar.bz2 b/qemu-xen-dir-remote.tar.bz2 index 999ab50..fc87760 100644 --- a/qemu-xen-dir-remote.tar.bz2 +++ b/qemu-xen-dir-remote.tar.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:69625c1ca61f7569d998c66d9e89d37635e6427d045e0e7566309cdab96c965e -size 5069776 +oid sha256:e0274df823f5f8b3efd9529ba7634ae70d3642c10e32b503ee9ac9904ed68ea7 +size 6032848 diff --git a/qemu-xen-traditional-dir-remote.tar.bz2 b/qemu-xen-traditional-dir-remote.tar.bz2 index a6e54f5..10cf4aa 100644 --- a/qemu-xen-traditional-dir-remote.tar.bz2 +++ b/qemu-xen-traditional-dir-remote.tar.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fd580bf099a4b8c4ab0ca680874f71fa2abc902076f47c1fea7ee961e9a2f196 -size 3187212 +oid sha256:559ea5b51a122b06e23f7fdd4b86c06093cabece5b41db8fae642073d4a50de7 +size 3212662 diff --git a/seabios-dir-remote.tar.bz2 b/seabios-dir-remote.tar.bz2 index e714d2a..94fb3f3 100644 --- a/seabios-dir-remote.tar.bz2 +++ b/seabios-dir-remote.tar.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:880675bae5305039066c25101305a7854d6d336980ba00dbbbe005a4c23e7126 -size 356438 +oid sha256:aea571bbe3202a9907489d171cb69d55b7b706b7875374e71958e05509cd5348 +size 365866 diff --git a/serial-split.patch b/serial-split.patch deleted file mode 100644 index c2f7d21..0000000 --- a/serial-split.patch +++ /dev/null @@ -1,452 +0,0 @@ -Index: xen-4.2.0-testing/tools/misc/serial-split/Makefile -=================================================================== ---- /dev/null -+++ xen-4.2.0-testing/tools/misc/serial-split/Makefile -@@ -0,0 +1,20 @@ -+CC ?= gcc -+CFLAGS ?= -Wall -Os -+CFILES = $(wildcard *.c) -+OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) -+TARGET = serial-split -+ -+all: $(TARGET) -+ -+install: all -+ install -d $(DESTDIR)/usr/bin -+ install -s $(TARGET) $(DESTDIR)/usr/bin/ -+ -+clean: -+ rm *.o $(TARGET) *~ -+ -+$(TARGET): $(OBJS) -+ $(CC) $(CFLAGS) -o $@ $^ -+ -+%.o: %.c Makefile -+ $(CC) $(CFLAGS) -c -o $@ $< -Index: xen-4.2.0-testing/tools/misc/serial-split/serial-split.c -=================================================================== ---- /dev/null -+++ xen-4.2.0-testing/tools/misc/serial-split/serial-split.c -@@ -0,0 +1,422 @@ -+/* -+ * serial-split.c -+ * pdb / console splitter -+ * -+ * Copyright 2005 Charles Coffing -+ * -+ * 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 (at your option) 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. -+ * -+ */ -+ -+/* -+ * Typical setup: -+ * -+ * Development box Xen box -+ * ...-----+ +-----... -+ * +---------+ | | -+ * | gdb | | | -+ * | |\ high | | -+ * +---------+ \ | | -+ * \+-----------+ | serial | +------------------+ -+ * | splitter |------------| Xen | -+ * /+-----------+ | | | - pdb (com1H)| -+ * +---------+ / | | | - printk (com1) | -+ * | console |/ low | | +------------------+ -+ * | viewer | | | -+ * +---------+ | | -+ * ...-----+ +-----... -+ */ -+ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+const unsigned int DefaultLowPort = 12010; -+const unsigned int DefaultBaud = 115200; -+const char DefaultSerialDevice[] = "/dev/ttyS0"; -+ -+#define DEBUG 0 -+#define MAX(a,b) ((a)<(b)?(b):(a)) -+ -+ -+static int cook_baud(int baud) -+{ -+ int cooked_baud = 0; -+ switch (baud) -+ { -+ case 50: cooked_baud = B50; break; -+ case 75: cooked_baud = B75; break; -+ case 110: cooked_baud = B110; break; -+ case 134: cooked_baud = B134; break; -+ case 150: cooked_baud = B150; break; -+ case 200: cooked_baud = B200; break; -+ case 300: cooked_baud = B300; break; -+ case 600: cooked_baud = B600; break; -+ case 1200: cooked_baud = B1200; break; -+ case 1800: cooked_baud = B1800; break; -+ case 2400: cooked_baud = B2400; break; -+ case 4800: cooked_baud = B4800; break; -+ case 9600: cooked_baud = B9600; break; -+ case 19200: cooked_baud = B19200; break; -+ case 38400: cooked_baud = B38400; break; -+ case 57600: cooked_baud = B57600; break; -+ case 115200: cooked_baud = B115200; break; -+ } -+ return cooked_baud; -+} -+ -+ -+static int start_listener(unsigned short port) -+{ -+ int fd; -+ struct sockaddr_in sin; -+ int on = 1; -+ -+ if ((fd = socket (AF_INET, SOCK_STREAM, 0)) < 0) -+ { -+ perror("socket"); -+ goto out1; -+ } -+ -+ setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)); -+ -+ memset(&sin, 0, sizeof(sin)); -+ sin.sin_family = AF_INET; -+ sin.sin_port = htons (port); -+ sin.sin_addr.s_addr = INADDR_ANY; -+ if (bind(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) -+ { -+ perror("bind"); -+ goto out2; -+ } -+ -+ if (listen(fd, 1) < 0) -+ { -+ perror("listen"); -+ goto out2; -+ } -+ -+ fprintf(stderr, "Listening on port %d\n", port); -+ -+ return fd; -+ -+out2: -+ close(fd); -+out1: -+ return -1; -+} -+ -+ -+static int accept_conn(int fd) -+{ -+ int on = 1; -+ int new_fd; -+ struct sockaddr_in from; -+ socklen_t fromlen = sizeof(from); -+ -+ new_fd = accept(fd, (struct sockaddr *)&from, &fromlen); -+ if (new_fd < 0) -+ perror("accept"); -+ ioctl(new_fd, FIONBIO, &on); -+ -+ fprintf(stderr, "Accepted connection on %d\n", new_fd); -+ -+ return new_fd; -+} -+ -+ -+static void close_conn(int * fd) -+{ -+ shutdown(*fd, 2); -+ close(*fd); -+ *fd = -1; -+} -+ -+ -+static int receive_data(int * fd, char * buf, ssize_t max_bytes, int * poll) -+{ -+ ssize_t bytes; -+ if ((bytes = read(*fd, buf, max_bytes)) < 0) -+ { -+ perror("read"); -+ *poll = 1; -+ return 0; -+ } -+ else if (bytes == 0) -+ { -+ close_conn(fd); -+ *poll = 0; -+ return 0; -+ } -+ else -+ { -+ if (bytes == max_bytes) -+ *poll = 1; -+ else -+ *poll = 0; -+#if DEBUG -+ { -+ ssize_t i; -+ fprintf(stderr, "Received %d bytes on %d:\n", bytes, *fd); -+ for (i = 0; i < bytes; ++ i) -+ { -+ if ((i & 0xf) == 0) -+ printf(" "); -+ printf("%02x", buf[i] & 0xff); -+ if (((i+1) & 0xf) == 0 || i + 1 == bytes) -+ printf("\n"); -+ else -+ printf(" "); -+ } -+ } -+#endif -+ return bytes; -+ } -+} -+ -+ -+static void set_high_bit(char * buf, size_t bytes) -+{ -+ size_t i; -+ for(i = 0; i < bytes; ++ i) -+ buf[i] |= 0x80; -+} -+ -+ -+static void clear_high_bit(char * buf, size_t bytes) -+{ -+ size_t i; -+ for(i = 0; i < bytes; ++ i) -+ buf[i] &= 0x7f; -+} -+ -+ -+static int open_serial(char const * serial_dev, int baud) -+{ -+ struct termios newsertio; -+ int serial_fd; -+ memset(&newsertio, 0, sizeof(newsertio)); -+ -+ if ((serial_fd = open(serial_dev, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) -+ { -+ perror(serial_dev); -+ return -1; -+ } -+ -+ newsertio.c_cflag = baud | CS8 | CLOCAL | CREAD; -+ newsertio.c_iflag = IGNBRK | IGNPAR; /* raw input */ -+ newsertio.c_oflag = 0; /* raw output */ -+ newsertio.c_lflag = 0; /* no echo, no signals */ -+ newsertio.c_cc[VMIN] = 1; -+ newsertio.c_cc[VTIME] = 0; -+ tcflush(serial_fd, TCIFLUSH); -+ tcsetattr(serial_fd, TCSANOW, &newsertio); -+ -+ fprintf(stderr, "Listening on %s\n", serial_dev); -+ -+ return serial_fd; -+} -+ -+ -+static void main_loop(int serial_fd, int low_listener, int high_listener) -+{ -+ fd_set rdfds; -+ int low_poll = 0, high_poll = 0, serial_poll = 0; -+ int low_fd = -1, high_fd = -1; -+ -+ while(1) -+ { -+ char buf[1024]; -+ ssize_t bytes; -+ int max; -+ -+ FD_ZERO(&rdfds); -+ FD_SET(low_fd < 0 ? low_listener : low_fd, &rdfds); -+ FD_SET(high_fd < 0 ? high_listener : high_fd, &rdfds); -+ FD_SET(serial_fd, &rdfds); -+ -+ max = MAX(low_fd, low_listener); -+ max = MAX(max, high_fd); -+ max = MAX(max, high_listener); -+ max = MAX(max, serial_fd); -+ -+ if (select(max + 1, &rdfds, NULL, NULL, NULL) < 0) -+ { -+ perror("select"); -+ continue; -+ } -+ -+ if (FD_ISSET(low_listener, &rdfds)) -+ { -+ assert(low_fd < 0); -+ low_fd = accept_conn(low_listener); -+ } -+ -+ if (FD_ISSET(high_listener, &rdfds)) -+ { -+ assert(high_fd < 0); -+ high_fd = accept_conn(high_listener); -+ } -+ -+ if (low_poll || (low_fd >= 0 && FD_ISSET(low_fd, &rdfds))) -+ { -+ if ((bytes = receive_data(&low_fd, &buf[0], sizeof(buf), -+ &low_poll)) > 0) -+ { -+ clear_high_bit(&buf[0], bytes); -+ if (write(serial_fd, &buf[0], bytes) < 0) -+ perror("write"); -+ } -+ } -+ -+ if (high_poll || (high_fd >= 0 && FD_ISSET(high_fd, &rdfds))) -+ { -+ if ((bytes = receive_data(&high_fd, &buf[0], sizeof(buf), -+ &high_poll)) > 0) -+ { -+ set_high_bit(&buf[0], bytes); -+ if (write(serial_fd, &buf[0], bytes) < 0) -+ perror("write"); -+ } -+ } -+ -+ if (serial_poll || FD_ISSET(serial_fd, &rdfds)) -+ { -+ if ((bytes = receive_data(&serial_fd, &buf[0], sizeof(buf), -+ &serial_poll)) > 0) -+ { -+ ssize_t i; -+ for (i = 0; i < bytes; ++ i) -+ { -+ if (buf[i] & 0x80) -+ { -+ if (high_fd >= 0) -+ { -+ buf[i] &= 0x7f; -+ if ((write(high_fd, &buf[i], 1)) < 0) -+ { -+ perror("write"); -+ close_conn(&high_fd); -+ high_poll = 0; -+ } -+ } -+ } -+ else -+ { -+ if (low_fd >= 0) -+ { -+ if ((write(low_fd, &buf[i], 1)) < 0) -+ { -+ perror("write"); -+ close_conn(&low_fd); -+ low_poll = 0; -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+} -+ -+ -+static void usage() -+{ -+ printf( -+"Description:\n" -+" Splits the serial port between two TCP ports. Bytes read from the\n" -+" serial port will be delivered to one of the two TCP ports (high or\n" -+" low) depending on whether the high bit is set. Bytes written to the\n" -+" TCP ports will be forwarded to the serial port; the high bit will be\n" -+" set or cleared to denote the source.\n" -+"Usage:\n" -+" serial-split [-d] [-b]\n" -+" [-l] [-h]\n" -+"Parameters:\n" -+" -d Defaults to %s.\n" -+" -b Baud rate of the serial port. Defaults to %d.\n" -+" Also assumes 8N1.\n" -+" -l Low TCP port. Defaults to %d, or one less than\n" -+" the high port.\n" -+" -h High TCP port. Defaults to %d, or one more than\n" -+" the low port.\n", -+DefaultSerialDevice, DefaultBaud, DefaultLowPort, DefaultLowPort + 1); -+ -+ exit(1); -+} -+ -+ -+int main(int argc, char **argv) -+{ -+ int cooked_baud = cook_baud(DefaultBaud); -+ char const * serial_dev = DefaultSerialDevice; -+ int low_port = -1, high_port = -1; -+ int serial_fd, low_listener, high_listener; -+ -+ while ( --argc != 0 ) -+ { -+ char *p = argv[argc]; -+ if ( *(p++) != '-' ) -+ usage(); -+ switch (*(p++)) -+ { -+ case 'b': -+ if ( (cooked_baud = cook_baud(atoi(p))) == 0 ) -+ { -+ fprintf(stderr, "Bad baud rate\n"); -+ exit(1); -+ } -+ break; -+ case 'd': -+ serial_dev = p; -+ break; -+ case 'l': -+ if ((low_port = atoi(p)) <= 0) -+ usage(); -+ break; -+ case 'h': -+ if ((high_port = atoi(p)) <= 0) -+ usage(); -+ break; -+ default: -+ usage(); -+ } -+ } -+ -+ if (low_port == -1 && high_port == -1) -+ low_port = DefaultLowPort; -+ if (low_port == -1) -+ low_port = high_port - 1; -+ if (high_port == -1) -+ high_port = low_port + 1; -+ -+ if ((serial_fd = open_serial(serial_dev, cooked_baud)) < 0 || -+ (low_listener = start_listener(low_port)) < 0 || -+ (high_listener = start_listener(high_port)) < 0) -+ exit(1); -+ -+ main_loop(serial_fd, low_listener, high_listener); -+ -+ return 0; -+} -+ diff --git a/stubdom.tar.bz2 b/stubdom.tar.bz2 index 916379f..a69d255 100644 --- a/stubdom.tar.bz2 +++ b/stubdom.tar.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:29f4dfad9cd69740193eaaf302c9608ee85759280235516533d3ee1f40819e1e -size 13995441 +oid sha256:96339e810d23134d84ed306a42c24d8d648a6e6815808b9a5f418de073f56e01 +size 17477089 diff --git a/supported_module.diff b/supported_module.patch similarity index 100% rename from supported_module.diff rename to supported_module.patch diff --git a/tapdisk-ioemu-logfile.patch b/tapdisk-ioemu-logfile.patch deleted file mode 100644 index 8960a33..0000000 --- a/tapdisk-ioemu-logfile.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 903a145f3eace5e3ae914f0335ab6c4e33635d2f Mon Sep 17 00:00:00 2001 -From: Kevin Wolf -Date: Tue, 10 Mar 2009 16:36:23 +0100 -Subject: [PATCH 4/6] tapdisk-ioemu: Write messages to a logfile - -Typically, tapdisk-ioemu runs as a daemon and messages to stderr are -simply lost. Write them to a logfile instead. - -Signed-off-by: Kevin Wolf ---- - tapdisk-ioemu.c | 19 +++++++++++++------ - 1 files changed, 13 insertions(+), 6 deletions(-) - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c -@@ -78,15 +78,22 @@ int main(void) - struct timeval tv; - void *old_fd_start = NULL; - -- logfile = stderr; -- -+ /* Daemonize */ -+ if (fork() != 0) -+ exit(0); -+ - bdrv_init(); - init_blktap(); - -- /* Daemonize */ -- if (fork() != 0) -- exit(0); -- -+ logfile = fopen("/var/log/xen/tapdisk-ioemu.log", "a"); -+ if (logfile) { -+ setbuf(logfile, NULL); -+ fclose(stderr); -+ stderr = logfile; -+ } else { -+ logfile = stderr; -+ } -+ - /* - * Main loop: Pass events to the corrsponding handlers and check for - * completed aio operations. diff --git a/tapdisk-ioemu-shutdown-fix.patch b/tapdisk-ioemu-shutdown-fix.patch deleted file mode 100644 index 428806f..0000000 --- a/tapdisk-ioemu-shutdown-fix.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 9062564d79cb45029403cc998b48410e42ead924 Mon Sep 17 00:00:00 2001 -From: Kevin Wolf -Date: Tue, 10 Mar 2009 16:45:44 +0100 -Subject: [PATCH 6/6] tapdisk-ioemu: Fix shutdown condition - -Even when opening the only image a tapdisk-ioemu instance is -responsible for fails, it can't immediately shut down. blktapctrl -still wants to communicate with tapdisk-ioemu and close the disk. - -This patch changes tapdisk-ioemu to count the connections to -blktapctrl rather than the number of opened disk images. - -Signed-off-by: Kevin Wolf ---- - hw/xen_blktap.c | 5 ++++- - tapdisk-ioemu.c | 13 ++++++++++--- - 2 files changed, 14 insertions(+), 4 deletions(-) - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c -@@ -65,6 +65,7 @@ int read_fd; - int write_fd; - - static pid_t process; -+int connected_disks = 0; - fd_list_entry_t *fd_start = NULL; - - static void handle_blktap_iomsg(void* private); -@@ -541,6 +542,7 @@ static void handle_blktap_ctrlmsg(void* - - /* Allocate the disk structs */ - s = state_init(); -+ connected_disks++; - - /*Open file*/ - if (s == NULL || open_disk(s, path, msg->drivertype, msg->readonly)) { -@@ -591,7 +593,8 @@ static void handle_blktap_ctrlmsg(void* - case CTLMSG_CLOSE: - s = get_state(msg->cookie); - if (s) unmap_disk(s); -- break; -+ connected_disks--; -+ break; - - case CTLMSG_PID: - memset(buf, 0x00, MSG_SIZE); -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c -@@ -14,6 +14,7 @@ extern void qemu_aio_init(void); - extern void qemu_aio_poll(void); - - extern void *fd_start; -+extern int connected_disks; - - int domid = 0; - FILE* logfile; -@@ -76,7 +77,7 @@ int main(void) - int max_fd; - fd_set rfds; - struct timeval tv; -- void *old_fd_start = NULL; -+ int old_connected_disks = 0; - - /* Daemonize */ - if (fork() != 0) -@@ -128,11 +129,17 @@ int main(void) - pioh = &ioh->next; - } - -+ if (old_connected_disks != connected_disks) -+ fprintf(stderr, "connected disks: %d => %d\n", -+ old_connected_disks, connected_disks); -+ - /* Exit when the last image has been closed */ -- if (old_fd_start != NULL && fd_start == NULL) -+ if (old_connected_disks != 0 && connected_disks == 0) { -+ fprintf(stderr, "Last image is closed, exiting.\n"); - exit(0); -+ } - -- old_fd_start = fd_start; -+ old_connected_disks = connected_disks; - } - return 0; - } diff --git a/tmp-initscript-modprobe.patch b/tmp-initscript-modprobe.patch index a1617b2..d90b8a9 100644 --- a/tmp-initscript-modprobe.patch +++ b/tmp-initscript-modprobe.patch @@ -1,8 +1,8 @@ -Index: xen-4.2.1-testing/tools/hotplug/Linux/init.d/xencommons +Index: xen-4.3.0-testing/tools/hotplug/Linux/init.d/xencommons =================================================================== ---- xen-4.2.1-testing.orig/tools/hotplug/Linux/init.d/xencommons -+++ xen-4.2.1-testing/tools/hotplug/Linux/init.d/xencommons -@@ -54,21 +54,27 @@ do_start () { +--- xen-4.3.0-testing.orig/tools/hotplug/Linux/init.d/xencommons ++++ xen-4.3.0-testing/tools/hotplug/Linux/init.d/xencommons +@@ -57,21 +57,27 @@ do_start () { local time=0 local timeout=30 @@ -44,4 +44,4 @@ Index: xen-4.2.1-testing/tools/hotplug/Linux/init.d/xencommons + modprobe nbd max_part=8 2>/dev/null || true mkdir -p /var/run/xen - if ! `xenstore-read -s / >/dev/null 2>&1` + if ! `${BINDIR}/xenstore-read -s / >/dev/null 2>&1` diff --git a/tmp_build.patch b/tmp_build.patch index ba14373..a3e2ee5 100644 --- a/tmp_build.patch +++ b/tmp_build.patch @@ -1,8 +1,8 @@ -Index: xen-4.2.0-testing/tools/xenstore/Makefile +Index: xen-4.3.0-testing/tools/xenstore/Makefile =================================================================== ---- xen-4.2.0-testing.orig/tools/xenstore/Makefile -+++ xen-4.2.0-testing/tools/xenstore/Makefile -@@ -72,6 +72,7 @@ $(CLIENTS_DOMU): xenstore +--- xen-4.3.0-testing.orig/tools/xenstore/Makefile ++++ xen-4.3.0-testing/tools/xenstore/Makefile +@@ -75,6 +75,7 @@ $(CLIENTS_DOMU): xenstore xenstore: xenstore_client.o $(LIBXENSTORE) $(CC) $(LDFLAGS) $< $(LDLIBS_libxenstore) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS) @@ -10,7 +10,7 @@ Index: xen-4.2.0-testing/tools/xenstore/Makefile xenstore-control: xenstore_control.o $(LIBXENSTORE) $(CC) $(LDFLAGS) $< $(LDLIBS_libxenstore) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS) -@@ -121,10 +122,11 @@ install: all +@@ -124,10 +125,11 @@ install: all $(INSTALL_PROG) xenstore-control $(DESTDIR)$(BINDIR) $(INSTALL_PROG) xenstore $(DESTDIR)$(BINDIR) set -e ; for c in $(CLIENTS) ; do \ diff --git a/tools-watchdog-support.patch b/tools-watchdog-support.patch deleted file mode 100644 index 4950814..0000000 --- a/tools-watchdog-support.patch +++ /dev/null @@ -1,140 +0,0 @@ -Index: xen-4.2.2-testing/tools/python/xen/xm/create.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xm/create.py -+++ xen-4.2.2-testing/tools/python/xen/xm/create.py -@@ -535,6 +535,21 @@ gopts.var('usbdevice', val='NAME', - fn=set_value, default='', - use="Name of USB device to add?") - -+gopts.var('watchdog', val='NAME', -+ fn=set_value, default='', -+ use="Watchdog device to use. May be ib700 or i6300esb") -+ -+gopts.var('watchdog_action', val='reset|shutdown|poweroff|pause|none|dump', -+ fn=set_value, default="reset", -+ use="""Action when watchdog timer expires: -+ - reset: Default, forcefully reset the guest; -+ - shutdown: Gracefully shutdown the guest (not recommended); -+ - poweroff: Forcefully power off the guest; -+ - pause: Pause the guest; -+ - none: Do nothing; -+ - dump: Automatically dump the guest; -+ """) -+ - gopts.var('description', val='NAME', - fn=set_value, default='', - use="Description of a domain") -@@ -1097,6 +1112,7 @@ def configure_hvm(config_image, vals): - 'usb', 'usbdevice', - 'vcpus', 'vnc', 'vncconsole', 'vncdisplay', 'vnclisten', - 'vncunused', 'viridian', 'vpt_align', -+ 'watchdog', 'watchdog_action', - 'xauthority', 'xen_extended_power_mgmt', 'xen_platform_pci', - 'memory_sharing' ] - -Index: xen-4.2.2-testing/tools/python/xen/xm/xenapi_create.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xm/xenapi_create.py -+++ xen-4.2.2-testing/tools/python/xen/xm/xenapi_create.py -@@ -1113,7 +1113,9 @@ class sxp2xml: - 'xen_platform_pci', - 'tsc_mode' - 'description', -- 'nomigrate' -+ 'nomigrate', -+ 'watchdog', -+ 'watchdog_action' - ] - - platform_configs = [] -Index: xen-4.2.2-testing/tools/python/xen/xend/image.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/image.py -+++ xen-4.2.2-testing/tools/python/xen/xend/image.py -@@ -855,7 +855,8 @@ class HVMImageHandler(ImageHandler): - - dmargs = [ 'boot', 'fda', 'fdb', 'soundhw', - 'localtime', 'serial', 'stdvga', 'isa', -- 'acpi', 'usb', 'usbdevice', 'gfx_passthru' ] -+ 'acpi', 'usb', 'usbdevice', 'gfx_passthru', -+ 'watchdog', 'watchdog_action' ] - - for a in dmargs: - v = vmConfig['platform'].get(a) -@@ -863,6 +864,7 @@ class HVMImageHandler(ImageHandler): - # python doesn't allow '-' in variable names - if a == 'stdvga': a = 'std-vga' - if a == 'keymap': a = 'k' -+ if a == 'watchdog_action': a = 'watchdog-action' - - # Handle booleans gracefully - if a in ['localtime', 'std-vga', 'isa', 'usb', 'acpi']: -Index: xen-4.2.2-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendConfig.py -@@ -192,6 +192,8 @@ XENAPI_PLATFORM_CFG_TYPES = { - 'xen_platform_pci': int, - "gfx_passthru": int, - 'oos' : int, -+ 'watchdog': str, -+ 'watchdog_action': str, - } - - # Xen API console 'other_config' keys. -Index: xen-4.2.2-testing/tools/libxl/libxl_dm.c -=================================================================== ---- xen-4.2.2-testing.orig/tools/libxl/libxl_dm.c -+++ xen-4.2.2-testing/tools/libxl/libxl_dm.c -@@ -196,6 +196,12 @@ static char ** libxl__build_device_model - "-usbdevice", b_info->u.hvm.usbdevice, NULL); - } - } -+ if (b_info->u.hvm.watchdog || b_info->u.hvm.watchdog_action) { -+ flexarray_append(dm_args, "-watchdog"); -+ if (b_info->u.hvm.watchdog_action) { -+ flexarray_vappend(dm_args, "-watchdog-action", b_info->u.hvm.watchdog_action, NULL); -+ } -+ } - if (b_info->u.hvm.soundhw) { - flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL); - } -@@ -455,6 +461,12 @@ static char ** libxl__build_device_model - "-usbdevice", b_info->u.hvm.usbdevice, NULL); - } - } -+ if (b_info->u.hvm.watchdog || b_info->u.hvm.watchdog_action) { -+ flexarray_append(dm_args, "-watchdog"); -+ if (b_info->u.hvm.watchdog_action) { -+ flexarray_vappend(dm_args, "-watchdog-action", b_info->u.hvm.watchdog_action, NULL); -+ } -+ } - if (b_info->u.hvm.soundhw) { - flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL); - } -Index: xen-4.2.2-testing/tools/libxl/libxl_types.idl -=================================================================== ---- xen-4.2.2-testing.orig/tools/libxl/libxl_types.idl -+++ xen-4.2.2-testing/tools/libxl/libxl_types.idl -@@ -322,6 +322,8 @@ libxl_domain_build_info = Struct("domain - ("usbdevice", string), - ("soundhw", string), - ("xen_platform_pci", libxl_defbool), -+ ("watchdog", string), -+ ("watchdog_action", string), - ])), - ("pv", Struct(None, [("kernel", string), - ("slack_memkb", MemKB), -Index: xen-4.2.2-testing/tools/libxl/xl_cmdimpl.c -=================================================================== ---- xen-4.2.2-testing.orig/tools/libxl/xl_cmdimpl.c -+++ xen-4.2.2-testing/tools/libxl/xl_cmdimpl.c -@@ -1417,6 +1417,8 @@ skip_vfb: - xlu_cfg_replace_string (config, "soundhw", &b_info->u.hvm.soundhw, 0); - xlu_cfg_get_defbool(config, "xen_platform_pci", - &b_info->u.hvm.xen_platform_pci, 0); -+ xlu_cfg_replace_string (config, "watchdog", &b_info->u.hvm.watchdog, 0); -+ xlu_cfg_replace_string (config, "watchdog_action", &b_info->u.hvm.watchdog_action, 0); - } - - xlu_cfg_destroy(config); diff --git a/udev-rules.patch b/udev-rules.patch index 86f5db7..b74aefe 100644 --- a/udev-rules.patch +++ b/udev-rules.patch @@ -1,8 +1,8 @@ -Index: xen-4.2.0-testing/tools/hotplug/Linux/xen-backend.rules +Index: xen-4.3.0-testing/tools/hotplug/Linux/xen-backend.rules =================================================================== ---- xen-4.2.0-testing.orig/tools/hotplug/Linux/xen-backend.rules -+++ xen-4.2.0-testing/tools/hotplug/Linux/xen-backend.rules -@@ -13,4 +13,5 @@ KERNEL=="blktap-control", NAME="xen/blkt +--- xen-4.3.0-testing.orig/tools/hotplug/Linux/xen-backend.rules ++++ xen-4.3.0-testing/tools/hotplug/Linux/xen-backend.rules +@@ -12,4 +12,5 @@ KERNEL=="blktap-control", NAME="xen/blkt KERNEL=="gntdev", NAME="xen/%k", MODE="0600" KERNEL=="pci_iomul", NAME="xen/%k", MODE="0600" KERNEL=="tapdev[a-z]*", NAME="xen/blktap-2/tapdev%m", MODE="0600" diff --git a/usb-list.patch b/usb-list.patch deleted file mode 100644 index ce95242..0000000 --- a/usb-list.patch +++ /dev/null @@ -1,45 +0,0 @@ -"usb-hc-create" does not check usb-ver parameter. It allows 2/2.0/2.0usb/2.0aaa. While low level -driver doing hc create, it gets an integer by vssanf %d from usb-ver string, so there is no problem. -But 2/2.0/2.0usb/2.0aaa will be saved into VM config. - -After that, while doing "usb-list", it cannot handle "2.0/2.0usb/2.0aaa" and will cause error: -Idx BE state usb-ver BE-path -Error: Invalid argument. -Usage: xm usb-list - -This patch is to let "usb-list" handle all usb-ver cases as low level driver does and won't cause error. - -About this problem, I've submitted two patches to upstream before, but got no response. Information -could be referred to: - http://www.gossamer-threads.com/lists/xen/devel/178406?search_string=usb-list;#178406 - http://www.gossamer-threads.com/lists/xen/devel/181021?search_string=usb-list;#181021 - - -Index: xen-4.2.0-testing/tools/python/xen/xm/main.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xm/main.py -+++ xen-4.2.0-testing/tools/python/xen/xm/main.py -@@ -2629,10 +2629,22 @@ def xm_usb_list(args): - ni = parse_dev_info(x[1]) - ni['idx'] = int(x[0]) - usbver = sxp.child_value(x[1], 'usb-ver') -+ -+ substr = re.search("^\d{1,}", usbver) -+ if substr: -+ usbver = substr.group() -+ else: -+ print "Unknown usb-ver" -+ continue -+ - if int(usbver) == 1: - ni['usb-ver'] = 'USB1.1' -- else: -+ elif int(usbver) == 2: - ni['usb-ver'] = 'USB2.0' -+ else: -+ print "Unknown usb-ver" -+ continue -+ - print "%(idx)-3d %(backend-id)-3d %(state)-5d %(usb-ver)-7s %(be-path)-30s " % ni - - ports = sxp.child(x[1], 'port') diff --git a/vif-route-ifup.patch b/vif-route-ifup.patch deleted file mode 100644 index e0dec05..0000000 --- a/vif-route-ifup.patch +++ /dev/null @@ -1,89 +0,0 @@ ---- - tools/examples/xend-config.sxp | 20 ++++++++++++++++++++ - tools/hotplug/Linux/Makefile | 2 +- - tools/hotplug/Linux/vif-route-ifup | 34 ++++++++++++++++++++++++++++++++++ - 3 files changed, 55 insertions(+), 1 deletion(-) - -Index: xen-4.2.0-testing/tools/examples/xend-config.sxp -=================================================================== ---- xen-4.2.0-testing.orig/tools/examples/xend-config.sxp -+++ xen-4.2.0-testing/tools/examples/xend-config.sxp -@@ -200,6 +200,26 @@ - #(network-script network-route) - #(vif-script vif-route) - -+# SuSE users note: -+# If using a routed network configuration it is advised to NOT use -+# network-route and vif-route scripts but instead use sysconfig scripts -+# in dom0 and vif-route-ifup script to "connect" the domU vif to dom0. -+# Since this configuration requires a vif sysconfig script in dom0, a static -+# vif name must be used. E.g. in dom0 the vif sysconfig script -+# (/etc/sysconfig/network/ifcfg-xen1.0) may contain -+# -+# NAME='XEN vm 1 virtual interface 0' -+# BOOTPROTO='static' -+# STARTMODE='hotplug' -+# ... -+# -+# The corresponding domain vif configuration would contain e.g. -+# vif=[ 'mac=00:16:3e:aa:bb:cc,script=vif-route-ifup,vifname=xen1.0', ] -+# -+# If the vif-route-ifup script will be used for all domains, it can be -+# set here as the default vif script, alleviating the need for -+# 'script=' in domain vif configuration. -+#(vif-script vif-route-ifup) - - ## Use the following if network traffic is routed with NAT, as an alternative - # to the settings for bridged networking given above. -Index: xen-4.2.0-testing/tools/hotplug/Linux/Makefile -=================================================================== ---- xen-4.2.0-testing.orig/tools/hotplug/Linux/Makefile -+++ xen-4.2.0-testing/tools/hotplug/Linux/Makefile -@@ -11,7 +11,7 @@ XENCOMMONS_SYSCONFIG = init.d/sysconfig. - - # Xen script dir and scripts to go there. - XEN_SCRIPTS = network-bridge vif-bridge --XEN_SCRIPTS += network-route vif-route -+XEN_SCRIPTS += network-route vif-route vif-route-ifup - XEN_SCRIPTS += network-nat vif-nat - XEN_SCRIPTS += vif2 - XEN_SCRIPTS += vif-setup -Index: xen-4.2.0-testing/tools/hotplug/Linux/vif-route-ifup -=================================================================== ---- /dev/null -+++ xen-4.2.0-testing/tools/hotplug/Linux/vif-route-ifup -@@ -0,0 +1,34 @@ -+#!/bin/bash -+#============================================================================ -+# /etc/xen/vif-route-ifup -+# -+# Script for configuring a vif in routed mode. -+# The hotplugging system will call this script if it is specified either in -+# the device configuration given to Xend, or the default Xend configuration -+# in /etc/xen/xend-config.sxp. If the script is specified in neither of those -+# places, then vif-bridge is the default. -+# -+# Usage: -+# vif-route-ifup (add|remove|online|offline) -+# -+# Environment vars: -+# dev vif interface name (required). -+#============================================================================ -+ -+dir=$(dirname "$0") -+. "$dir/vif-common.sh" -+ -+case "$command" in -+ online) -+ ifup ${dev} -+ ;; -+ offline) -+ do_without_error ifdown ${dev} -+ ;; -+esac -+ -+log debug "Successful vif-route-ifup $command for ${dev}." -+if [ "$command" = "online" ] -+then -+ success -+fi diff --git a/x86-cpufreq-report.patch b/x86-cpufreq-report.patch index 17666d6..38c0cec 100644 --- a/x86-cpufreq-report.patch +++ b/x86-cpufreq-report.patch @@ -1,7 +1,7 @@ -Index: xen-4.2.1-testing/xen/arch/x86/platform_hypercall.c +Index: xen-4.3.0-testing/xen/arch/x86/platform_hypercall.c =================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/platform_hypercall.c -+++ xen-4.2.1-testing/xen/arch/x86/platform_hypercall.c +--- xen-4.3.0-testing.orig/xen/arch/x86/platform_hypercall.c ++++ xen-4.3.0-testing/xen/arch/x86/platform_hypercall.c @@ -25,7 +25,7 @@ #include #include @@ -11,7 +11,7 @@ Index: xen-4.2.1-testing/xen/arch/x86/platform_hypercall.c #include #include #include -@@ -639,6 +639,41 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe +@@ -597,6 +597,41 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PA } break; @@ -53,11 +53,11 @@ Index: xen-4.2.1-testing/xen/arch/x86/platform_hypercall.c default: ret = -ENOSYS; break; -Index: xen-4.2.1-testing/xen/include/public/platform.h +Index: xen-4.3.0-testing/xen/include/public/platform.h =================================================================== ---- xen-4.2.1-testing.orig/xen/include/public/platform.h -+++ xen-4.2.1-testing/xen/include/public/platform.h -@@ -505,6 +505,16 @@ struct xenpf_core_parking { +--- xen-4.3.0-testing.orig/xen/include/public/platform.h ++++ xen-4.3.0-testing/xen/include/public/platform.h +@@ -527,6 +527,16 @@ struct xenpf_core_parking { typedef struct xenpf_core_parking xenpf_core_parking_t; DEFINE_XEN_GUEST_HANDLE(xenpf_core_parking_t); @@ -74,7 +74,7 @@ Index: xen-4.2.1-testing/xen/include/public/platform.h /* * ` enum neg_errnoval * ` HYPERVISOR_platform_op(const struct xen_platform_op*); -@@ -531,6 +541,7 @@ struct xen_platform_op { +@@ -553,6 +563,7 @@ struct xen_platform_op { struct xenpf_cpu_hotadd cpu_add; struct xenpf_mem_hotadd mem_add; struct xenpf_core_parking core_parking; diff --git a/x86-dom-print.patch b/x86-dom-print.patch index 4bb3348..63002ff 100644 --- a/x86-dom-print.patch +++ b/x86-dom-print.patch @@ -1,8 +1,8 @@ -Index: xen-4.2.1-testing/xen/arch/x86/domain.c +Index: xen-4.3.0-testing/xen/arch/x86/domain.c =================================================================== ---- xen-4.2.1-testing.orig/xen/arch/x86/domain.c -+++ xen-4.2.1-testing/xen/arch/x86/domain.c -@@ -152,15 +152,30 @@ void dump_pageframe_info(struct domain * +--- xen-4.3.0-testing.orig/xen/arch/x86/domain.c ++++ xen-4.3.0-testing/xen/arch/x86/domain.c +@@ -151,15 +151,30 @@ void dump_pageframe_info(struct domain * printk("Memory pages belonging to domain %u:\n", d->domain_id); diff --git a/x86-extra-trap-info.patch b/x86-extra-trap-info.patch index 15396a0..86d6056 100644 --- a/x86-extra-trap-info.patch +++ b/x86-extra-trap-info.patch @@ -1,19 +1,8 @@ ---- a/xen/arch/x86/x86_32/entry.S -+++ b/xen/arch/x86/x86_32/entry.S -@@ -410,8 +410,10 @@ UNLIKELY_END(bounce_vm86_3) - _ASM_EXTABLE(.Lft24, domain_crash_synchronous) - _ASM_EXTABLE(.Lft25, domain_crash_synchronous) - -+.section .rodata, "a", @progbits - domain_crash_synchronous_string: - .asciz "domain_crash_sync called from entry.S (%lx)\n" -+.previous - - domain_crash_synchronous: - pushl $domain_crash_synchronous_string ---- a/xen/arch/x86/x86_64/entry.S -+++ b/xen/arch/x86/x86_64/entry.S -@@ -435,22 +435,35 @@ UNLIKELY_END(bounce_failsafe) +Index: xen-4.3.0-testing/xen/arch/x86/x86_64/entry.S +=================================================================== +--- xen-4.3.0-testing.orig/xen/arch/x86/x86_64/entry.S ++++ xen-4.3.0-testing/xen/arch/x86/x86_64/entry.S +@@ -433,22 +433,35 @@ UNLIKELY_END(bounce_failsafe) jz domain_crash_synchronous movq %rax,UREGS_rip+8(%rsp) ret @@ -60,4 +49,4 @@ + call show_page_walk ENTRY(domain_crash_synchronous) # Get out of the guest-save area of the stack. - GET_CPUINFO_FIELD(CPUINFO_guest_cpu_user_regs,%rax) + GET_STACK_BASE(%rax) diff --git a/x86-ioapic-ack-default.patch b/x86-ioapic-ack-default.patch index 56e8e98..a42145a 100644 --- a/x86-ioapic-ack-default.patch +++ b/x86-ioapic-ack-default.patch @@ -1,10 +1,10 @@ Change default IO-APIC ack mode for single IO-APIC systems to old-style. -Index: xen-4.2.0-testing/xen/arch/x86/io_apic.c +Index: xen-4.3.0-testing/xen/arch/x86/io_apic.c =================================================================== ---- xen-4.2.0-testing.orig/xen/arch/x86/io_apic.c -+++ xen-4.2.0-testing/xen/arch/x86/io_apic.c -@@ -2012,7 +2012,10 @@ void __init setup_IO_APIC(void) +--- xen-4.3.0-testing.orig/xen/arch/x86/io_apic.c ++++ xen-4.3.0-testing/xen/arch/x86/io_apic.c +@@ -2026,7 +2026,10 @@ void __init setup_IO_APIC(void) io_apic_irqs = ~PIC_IRQS; printk("ENABLING IO-APIC IRQs\n"); @@ -14,5 +14,5 @@ Index: xen-4.2.0-testing/xen/arch/x86/io_apic.c + printk(" -> Using %s ACK method\n", ioapic_ack_new ? "new" : "old"); + } - /* - * Set up IO-APIC IRQ routing. + if (ioapic_ack_new) { + ioapic_level_type.ack = irq_complete_move; diff --git a/xen-4.2.2-testing-src.tar.bz2 b/xen-4.2.2-testing-src.tar.bz2 deleted file mode 100644 index e130e12..0000000 --- a/xen-4.2.2-testing-src.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5a1330a97a32997a5b60fe642b9d6260d2c153f02a1d6d77d9752a3de3e20619 -size 4856809 diff --git a/xen-4.3.0-testing-src.tar.bz2 b/xen-4.3.0-testing-src.tar.bz2 new file mode 100644 index 0000000..296f2d1 --- /dev/null +++ b/xen-4.3.0-testing-src.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f533b1a6f62ca0a72b6da75c49e913fbe2e280e94cb2c0ad2d4dc96f3a42c08b +size 4352158 diff --git a/xen-api-auth.patch b/xen-api-auth.patch deleted file mode 100644 index 381442d..0000000 --- a/xen-api-auth.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: xen-4.2.0-testing/tools/python/xen/xend/XendAuthSessions.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/XendAuthSessions.py -+++ xen-4.2.0-testing/tools/python/xen/xend/XendAuthSessions.py -@@ -84,7 +84,7 @@ class XendAuthSessions: - # if PAM doesn't exist, let's ignore it - return False - -- pam_auth.start("login") -+ pam_auth.start("xen-api") - pam_auth.set_item(PAM.PAM_USER, username) - - def _pam_conv(auth, query_list, user_data = None): diff --git a/xen-changeset.diff b/xen-changeset.patch similarity index 69% rename from xen-changeset.diff rename to xen-changeset.patch index 0d45a67..45a3cb7 100644 --- a/xen-changeset.diff +++ b/xen-changeset.patch @@ -1,13 +1,13 @@ -Index: xen-4.2.0-testing/xen/Makefile +Index: xen-4.3.0-testing/xen/Makefile =================================================================== ---- xen-4.2.0-testing.orig/xen/Makefile -+++ xen-4.2.0-testing/xen/Makefile +--- xen-4.3.0-testing.orig/xen/Makefile ++++ xen-4.3.0-testing/xen/Makefile @@ -1,3 +1,4 @@ +export XEN_CHANGESET = unavailable # This is the correct place to edit the build version. # All other places this is stored (eg. compile.h) should be autogenerated. export XEN_VERSION = 4 -@@ -112,7 +113,7 @@ delete-unfresh-files: +@@ -116,7 +117,7 @@ delete-unfresh-files: @rm -f $@1 $@2 # compile.h contains dynamic build info. Rebuilt on every 'make' invocation. @@ -16,12 +16,12 @@ Index: xen-4.2.0-testing/xen/Makefile @sed -e 's/@@date@@/$(shell LC_ALL=C date)/g' \ -e 's/@@time@@/$(shell LC_ALL=C date +%T)/g' \ -e 's/@@whoami@@/$(XEN_WHOAMI)/g' \ -@@ -122,10 +123,9 @@ include/xen/compile.h: include/xen/compi +@@ -126,10 +127,9 @@ include/xen/compile.h: include/xen/compi -e 's/@@version@@/$(XEN_VERSION)/g' \ -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \ -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \ -- -e 's!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || echo "unavailable") 2>/dev/null)!g' \ -+ -e 's!@@changeset@@!$(XEN_CHANGESET)!g' \ +- -e 's!@@changeset@@!$(shell tools/scmversion $(XEN_ROOT) || echo "unavailable")!g' \ ++ -e 's!@@changeset@@!$(XEN_CHANGESET)!g' \ < include/xen/compile.h.in > $@.new - @grep \" .banner >> $@.new - @grep -v \" .banner diff --git a/xen-cpupool-xl-config-format.patch b/xen-cpupool-xl-config-format.patch deleted file mode 100644 index 25e1159..0000000 --- a/xen-cpupool-xl-config-format.patch +++ /dev/null @@ -1,25 +0,0 @@ -Index: xen-4.2.0-testing/tools/python/xen/xm/cpupool.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xm/cpupool.py -+++ xen-4.2.0-testing/tools/python/xen/xm/cpupool.py -@@ -157,9 +157,17 @@ def make_cpus_config(cfg_cpus): - # ["0,2","1,3"] -> [[0,2],[1,3]] - # ["0-3,^1","1-4,^2"] -> [[0,2,3],[1,3,4]] - try: -- for c in cfg_cpus: -- cpus = cnv(c) -- cpus_list.append(cpus) -+ cpus_str = "" -+ list_len = len(cfg_cpus) -+ n = 0 -+ while n < list_len: -+ if type(cfg_cpus[n]) != str: -+ raise SyntaxError('cpus = %s' % cfg_cpus) -+ cpus_str += cfg_cpus[n] -+ n += 1 -+ if n < list_len: -+ cpus_str += ', ' -+ cpus_list = cnv(cpus_str) - except ValueError, e: - raise err('cpus = %s: %s' % (cfg_cpus, e)) - else: diff --git a/xen-destdir.diff b/xen-destdir.patch similarity index 82% rename from xen-destdir.diff rename to xen-destdir.patch index 8a94d02..b67a850 100644 --- a/xen-destdir.diff +++ b/xen-destdir.patch @@ -1,7 +1,7 @@ -Index: xen-4.2.0-testing/tools/xenstore/Makefile +Index: xen-4.3.0-testing/tools/xenstore/Makefile =================================================================== ---- xen-4.2.0-testing.orig/tools/xenstore/Makefile -+++ xen-4.2.0-testing/tools/xenstore/Makefile +--- xen-4.3.0-testing.orig/tools/xenstore/Makefile ++++ xen-4.3.0-testing/tools/xenstore/Makefile @@ -10,6 +10,7 @@ CFLAGS += $(CFLAGS_libxenctrl) CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod @@ -10,7 +10,7 @@ Index: xen-4.2.0-testing/tools/xenstore/Makefile XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o -@@ -38,7 +39,7 @@ endif +@@ -41,7 +42,7 @@ endif all: $(ALL_TARGETS) .PHONY: clients @@ -19,7 +19,7 @@ Index: xen-4.2.0-testing/tools/xenstore/Makefile ifeq ($(CONFIG_SunOS),y) xenstored_probes.h: xenstored_probes.d -@@ -66,6 +67,9 @@ xenstored.a: $(XENSTORED_OBJS) +@@ -69,6 +70,9 @@ xenstored.a: $(XENSTORED_OBJS) $(CLIENTS): xenstore ln -f xenstore $@ @@ -29,7 +29,7 @@ Index: xen-4.2.0-testing/tools/xenstore/Makefile xenstore: xenstore_client.o $(LIBXENSTORE) $(CC) $(LDFLAGS) $< $(LDLIBS_libxenstore) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS) -@@ -93,7 +97,7 @@ clean: +@@ -96,7 +100,7 @@ clean: rm -f *.a *.o *.opic *.so* xenstored_probes.h rm -f xenstored xs_random xs_stress xs_crashme rm -f xs_tdb_dump xenstore-control init-xenstore-domain @@ -38,7 +38,7 @@ Index: xen-4.2.0-testing/tools/xenstore/Makefile $(RM) $(DEPS) .PHONY: TAGS -@@ -110,6 +114,7 @@ install: all +@@ -113,6 +117,7 @@ install: all $(INSTALL_DIR) $(DESTDIR)$(SBINDIR) $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR) $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)/xenstore-compat @@ -46,7 +46,7 @@ Index: xen-4.2.0-testing/tools/xenstore/Makefile $(INSTALL_DIR) $(DESTDIR)/var/run/xenstored $(INSTALL_DIR) $(DESTDIR)/var/lib/xenstored $(INSTALL_PROG) xenstored $(DESTDIR)$(SBINDIR) -@@ -118,6 +123,9 @@ install: all +@@ -121,6 +126,9 @@ install: all set -e ; for c in $(CLIENTS) ; do \ ln -f $(DESTDIR)$(BINDIR)/xenstore $(DESTDIR)$(BINDIR)/$${c} ; \ done @@ -56,10 +56,10 @@ Index: xen-4.2.0-testing/tools/xenstore/Makefile $(INSTALL_DIR) $(DESTDIR)$(LIBDIR) $(INSTALL_PROG) libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR) ln -sf libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libxenstore.so.$(MAJOR) -Index: xen-4.2.0-testing/tools/hotplug/Linux/Makefile +Index: xen-4.3.0-testing/tools/hotplug/Linux/Makefile =================================================================== ---- xen-4.2.0-testing.orig/tools/hotplug/Linux/Makefile -+++ xen-4.2.0-testing/tools/hotplug/Linux/Makefile +--- xen-4.3.0-testing.orig/tools/hotplug/Linux/Makefile ++++ xen-4.3.0-testing/tools/hotplug/Linux/Makefile @@ -43,12 +43,12 @@ install: all install-initd install-scrip .PHONY: install-initd install-initd: @@ -76,21 +76,21 @@ Index: xen-4.2.0-testing/tools/hotplug/Linux/Makefile $(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR) .PHONY: install-scripts -Index: xen-4.2.0-testing/tools/firmware/etherboot/Makefile +Index: xen-4.3.0-testing/tools/firmware/etherboot/Makefile =================================================================== ---- xen-4.2.0-testing.orig/tools/firmware/etherboot/Makefile -+++ xen-4.2.0-testing/tools/firmware/etherboot/Makefile +--- xen-4.3.0-testing.orig/tools/firmware/etherboot/Makefile ++++ xen-4.3.0-testing/tools/firmware/etherboot/Makefile @@ -28,12 +28,12 @@ all: $(ROMS) $(MAKE) -C $D/src bin/$(*F).rom $T: -- if ! wget -O _$T $(IPXE_TARBALL_URL); then \ +- if ! $(FETCHER) _$T $(IPXE_TARBALL_URL); then \ - $(GIT) clone $(IPXE_GIT_URL) $D.git; \ - (cd $D.git && $(GIT) archive --format=tar --prefix=$D/ \ - $(IPXE_GIT_TAG) | gzip >../_$T); \ - rm -rf $D.git; \ - fi -+ #if ! wget -O _$T $(IPXE_TARBALL_URL); then \ ++ #if ! $(FETCHER) _$T $(IPXE_TARBALL_URL); then \ + # $(GIT) clone $(IPXE_GIT_URL) $D.git; \ + # (cd $D.git && $(GIT) archive --format=tar --prefix=$D/ \ + # $(IPXE_GIT_TAG) | gzip >../_$T); \ diff --git a/xen-disable-qemu-monitor.diff b/xen-disable-qemu-monitor.diff deleted file mode 100644 index e1b2ab0..0000000 --- a/xen-disable-qemu-monitor.diff +++ /dev/null @@ -1,70 +0,0 @@ -CVE-2007-0998 - remote compromise of dom0 - -Rather than completely disabling QEMU's console (which would remove -the "sendkey" command, among other useful things), remove all console -commands that can read/write dom0's state. - - -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/monitor.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/monitor.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/monitor.c -@@ -1497,6 +1497,7 @@ static const term_cmd_t term_cmds[] = { - "device|all", "commit changes to the disk images (if -snapshot is used) or backing files" }, - { "info", "s?", do_info, - "subcommand", "show various information about the system state" }, -+#ifdef CONFIG_TRUSTED_CLIENT - { "q|quit", "", do_quit, - "", "quit the emulator" }, - { "eject", "-fB", do_eject, -@@ -1509,6 +1510,7 @@ static const term_cmd_t term_cmds[] = { - "filename", "output logs to 'filename'" }, - { "log", "s", do_log, - "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" }, -+#endif - { "savevm", "s?", do_savevm, - "tag|id", "save a VM snapshot. If no tag or id are provided, a new snapshot is created" }, - { "loadvm", "s", do_loadvm, -@@ -1538,8 +1540,10 @@ static const term_cmd_t term_cmds[] = { - "", "reset the system" }, - { "system_powerdown", "", do_system_powerdown, - "", "send system power down event" }, -+#ifdef CONFIG_TRUSTED_CLIENT - { "sum", "ii", do_sum, - "addr size", "compute the checksum of a memory region" }, -+#endif - { "usb_add", "s", do_usb_add, - "device", "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')" }, - { "usb_del", "s", do_usb_del, -@@ -1558,6 +1562,7 @@ static const term_cmd_t term_cmds[] = { - "state", "change mouse button state (1=L, 2=M, 4=R)" }, - { "mouse_set", "i", do_mouse_set, - "index", "set which mouse device receives events" }, -+#ifdef CONFIG_TRUSTED_CLIENT - #ifdef HAS_AUDIO - { "wavcapture", "si?i?i?", do_wav_capture, - "path [frequency bits channels]", -@@ -1565,6 +1570,7 @@ static const term_cmd_t term_cmds[] = { - #endif - { "stopcapture", "i", do_stop_capture, - "capture index", "stop capture" }, -+#endif - { "memsave", "lis", do_memory_save, - "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", }, - { "pmemsave", "lis", do_physical_memory_save, -@@ -1646,6 +1652,7 @@ static const term_cmd_t info_cmds[] = { - "", "show KVM information", }, - { "usb", "", usb_info, - "", "show guest USB devices", }, -+#ifdef CONFIG_TRUSTED_CLIENT - { "usbhost", "", usb_host_info, - "", "show host USB devices", }, - { "profile", "", do_info_profile, -@@ -1677,6 +1684,7 @@ static const term_cmd_t info_cmds[] = { - { "migrate", "", do_info_migrate, "", "show migration status" }, - { "balloon", "", do_info_balloon, - "", "show balloon information" }, -+#endif - { NULL, NULL, }, - }; - diff --git a/xen-domUloader.diff b/xen-domUloader.diff deleted file mode 100644 index b81e57b..0000000 --- a/xen-domUloader.diff +++ /dev/null @@ -1,117 +0,0 @@ -Index: xen-4.2.1-testing/tools/python/xen/xend/server/DevController.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/server/DevController.py -+++ xen-4.2.1-testing/tools/python/xen/xend/server/DevController.py -@@ -592,6 +592,31 @@ class DevController: - return (Missing, None) - - -+ 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-4.2.1-testing/tools/python/xen/xend/XendBootloader.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendBootloader.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendBootloader.py -@@ -12,7 +12,7 @@ - # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - # - --import os, select, errno, stat, signal, tty -+import os, select, errno, stat, signal, tty, time - import random - import shlex - from xen.xend import sxp -@@ -38,8 +38,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, 500): -+ avail = os.access(disk, os.R_OK) -+ if avail: -+ break -+ time.sleep(.1) -+ -+ if not avail: -+ msg = "Disk '%s' isn't accessible" % disk - log.error(msg) - raise VmError(msg) - -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -2349,6 +2349,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) -@@ -3299,7 +3303,8 @@ class XendDomainInfo: - from xen.xend import XendDomain - dom0 = XendDomain.instance().privilegedDomain() - mounted_vbd_uuid = dom0.create_vbd(vbd, disk); -- dom0._waitForDeviceUUID(mounted_vbd_uuid) -+ vbd_uuid = dom0.create_vbd(vbd, disk) -+ dom0._waitForDeviceFrontUUID(vbd_uuid) - fn = BOOTLOADER_LOOPBACK_DEVICE - - try: -@@ -3309,10 +3314,10 @@ class XendDomainInfo: - if mounted: - log.info("Unmounting %s from %s." % - (fn, BOOTLOADER_LOOPBACK_DEVICE)) -- _, vbd_info = dom0.info['devices'][mounted_vbd_uuid] -- dom0.destroyDevice(dom0.getBlockDeviceClass(vbd_info['devid']), -- BOOTLOADER_LOOPBACK_DEVICE, force = True) -- -+ if devtype in ['tap', 'tap2']: -+ dom0.destroyDevice('tap', BOOTLOADER_LOOPBACK_DEVICE, rm_cfg = True) -+ else: -+ dom0.destroyDevice('vbd', BOOTLOADER_LOOPBACK_DEVICE, rm_cfg = True) - if blcfg is None: - msg = "Had a bootloader specified, but can't find disk" - log.error(msg) diff --git a/xen-fixme-doc.diff b/xen-fixme-doc.diff deleted file mode 100644 index d6ef07d..0000000 --- a/xen-fixme-doc.diff +++ /dev/null @@ -1,82 +0,0 @@ -Index: xen-4.2.0-testing/docs/man/xmdomain.cfg.pod.5 -=================================================================== ---- xen-4.2.0-testing.orig/docs/man/xmdomain.cfg.pod.5 -+++ xen-4.2.0-testing/docs/man/xmdomain.cfg.pod.5 -@@ -333,16 +333,10 @@ at hda1, which is the root filesystem. - - =item I - --FIXME: write me -- - =item I - --FIXME: write me -- - =item I - --FIXME: write me -- - =back - - =head1 SEE ALSO -Index: xen-4.2.0-testing/docs/man/xm.pod.1 -=================================================================== ---- xen-4.2.0-testing.orig/docs/man/xm.pod.1 -+++ xen-4.2.0-testing/docs/man/xm.pod.1 -@@ -299,7 +299,8 @@ scheduling by the Xen hypervisor. - - =item B - --FIXME: Why would you ever see this state? -+The guest has requested to be shutdown, rebooted or suspended, and the -+domain is in the process of being destroyed in response. - - =item B - -@@ -312,8 +313,6 @@ restart on crash. See L f - The domain is in process of dying, but hasn't completely shutdown or - crashed. - --FIXME: Is this right? -- - =back - - B -@@ -737,8 +736,6 @@ Xen ships with a number of domain schedu - time with the B parameter on the Xen command line. By - default B is used for scheduling. - --FIXME: we really need a scheduler expert to write up this section. -- - =over 4 - - =item B [ B<-d> I [ B<-w>[B<=>I] | B<-c>[B<=>I] ] ] -@@ -788,8 +785,6 @@ The normal EDF scheduling usage in nanos - - The normal EDF scheduling usage in nanoseconds - --FIXME: these are lame, should explain more. -- - =item I - - Scaled period if domain is doing heavy I/O. -@@ -939,9 +934,6 @@ the default setting in xend-config.sxp f - - Passes the specified IP Address to the adapter on creation. - --FIXME: this currently appears to be B. I'm not sure under what --circumstances this should actually work. -- - =item BI - - The MAC address that the domain will see on its Ethernet device. If -@@ -967,9 +959,6 @@ Removes the network device from the doma - I is the virtual interface device number within the domain - (i.e. the 3 in vif22.3). - --FIXME: this is currently B. Network devices aren't completely --removed from domain 0. -- - =item B [B<-l>|B<--long>]> I - - List virtual network interfaces for a domain. The returned output is diff --git a/xen-glibc217.patch b/xen-glibc217.patch deleted file mode 100644 index eb1fd0a..0000000 --- a/xen-glibc217.patch +++ /dev/null @@ -1,12 +0,0 @@ -Index: xen-4.2.0-testing/tools/debugger/gdbsx/xg/xg_main.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/debugger/gdbsx/xg/xg_main.c -+++ xen-4.2.0-testing/tools/debugger/gdbsx/xg/xg_main.c -@@ -34,6 +34,7 @@ - * XGTRC(): generic trace utility - */ - -+#include - #include - #include - #include diff --git a/xen-hvm-default-bridge.diff b/xen-hvm-default-bridge.diff deleted file mode 100644 index 638ac77..0000000 --- a/xen-hvm-default-bridge.diff +++ /dev/null @@ -1,106 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/net.h -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/net.h -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/net.h -@@ -107,8 +107,8 @@ void net_host_device_add(const char *dev - void net_host_device_remove(int vlan_id, const char *device); - - #ifndef DEFAULT_NETWORK_SCRIPT --#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" --#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" -+#define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup" -+#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/xen/qemu-ifdown" - #endif - #ifdef __sun__ - #define SMBD_COMMAND "/usr/sfw/sbin/smbd" -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/net.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/net.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/net.c -@@ -1759,9 +1759,10 @@ int net_client_init(const char *device, - } - if (get_param_value(script_arg, sizeof(script_arg), "scriptarg", p) == 0 && - get_param_value(script_arg, sizeof(script_arg), "bridge", p) == 0) { /* deprecated; for xend compatibility */ -- pstrcpy(script_arg, sizeof(script_arg), ""); -+ ret = net_tap_init(vlan, device, name, ifname, setup_script, NULL, NULL); -+ } else { -+ ret = net_tap_init(vlan, device, name, ifname, setup_script, down_script, script_arg); - } -- ret = net_tap_init(vlan, device, name, ifname, setup_script, down_script, script_arg); - } - } else - #endif -Index: xen-4.2.0-testing/tools/python/xen/xend/image.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/image.py -+++ xen-4.2.0-testing/tools/python/xen/xend/image.py -@@ -912,11 +912,13 @@ class HVMImageHandler(ImageHandler): - mac = devinfo.get('mac') - if mac is None: - raise VmError("MAC address not specified or generated.") -- bridge = devinfo.get('bridge', 'xenbr0') -+ bridge = devinfo.get('bridge', None) - model = devinfo.get('model', 'rtl8139') - ret.append("-net") -- ret.append("nic,vlan=%d,macaddr=%s,model=%s" % -- (nics, mac, model)) -+ net = "nic,vlan=%d,macaddr=%s,model=%s" % (nics, mac, model) -+ if bridge: -+ net += ",bridge=%s" % bridge -+ ret.append(net) - vifname = "vif%d.%d-emu" % (self.vm.getDomid(), nics-1) - ret.append("-net") - if osdep.tapif_script is not None: -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/i386-dm/qemu-ifup-Linux -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/i386-dm/qemu-ifup-Linux -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/i386-dm/qemu-ifup-Linux -@@ -1,36 +1,22 @@ - #!/bin/sh - --#. /etc/rc.d/init.d/functions --#ulimit -c unlimited -- - echo 'config qemu network with xen bridge for ' $* - -+# If bridge is not specified, try device with default route. - bridge=$2 -+if [ -z "$bridge" ]; then -+ bridge=$(ip route list | awk '/^default / { print $NF }') -+fi - --# --# Old style bridge setup with netloop, used to have a bridge name --# of xenbrX, enslaving pethX and vif0.X, and then configuring --# eth0. --# --# New style bridge setup does not use netloop, so the bridge name --# is ethX and the physical device is enslaved pethX --# --# So if... --# --# - User asks for xenbrX --# - AND xenbrX doesn't exist --# - AND there is a ethX device which is a bridge --# --# ..then we translate xenbrX to ethX --# --# This lets old config files work without modification --# --if [ ! -e "/sys/class/net/$bridge" ] && [ -z "${bridge##xenbr*}" ] -+# Exit if $bridge is not a bridge. Exit with 0 status -+# so qemu-dm process is not terminated. No networking in -+# vm is bad but not catastrophic. The vm could still run -+# cpu and disk IO workloads. -+# Include an useful error message in qemu-dm log file. -+if [ ! -e "/sys/class/net/${bridge}/bridge" ] - then -- if [ -e "/sys/class/net/eth${bridge#xenbr}/bridge" ] -- then -- bridge="eth${bridge#xenbr}" -- fi -+ echo "WARNING! ${bridge} is not a bridge. qemu-ifup exiting. VM may not have a functioning networking stack." -+ exit 0 - fi - - ifconfig $1 0.0.0.0 up diff --git a/xen-hvm-default-pae.diff b/xen-hvm-default-pae.diff deleted file mode 100644 index 94d69c6..0000000 --- a/xen-hvm-default-pae.diff +++ /dev/null @@ -1,15 +0,0 @@ -PAE must be on for 64-on-64 to work at all. - -Index: xen-4.2.0-testing/tools/python/xen/xend/image.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/image.py -+++ xen-4.2.0-testing/tools/python/xen/xend/image.py -@@ -1038,7 +1038,7 @@ class X86_HVM_ImageHandler(HVMImageHandl - - def configure(self, vmConfig): - HVMImageHandler.configure(self, vmConfig) -- self.pae = int(vmConfig['platform'].get('pae', 0)) -+ self.pae = int(vmConfig['platform'].get('pae', 1)) - self.vramsize = int(vmConfig['platform'].get('videoram',4)) * 1024 - - def buildDomain(self): diff --git a/xen-ioemu-hvm-pv-support.diff b/xen-ioemu-hvm-pv-support.diff deleted file mode 100644 index 4152667..0000000 --- a/xen-ioemu-hvm-pv-support.diff +++ /dev/null @@ -1,65 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c -@@ -30,6 +30,8 @@ - #include "qemu-xen.h" - #include "net.h" - #include "xen_platform.h" -+#include "sysemu.h" -+#include - - #include - #include -@@ -335,11 +337,51 @@ static void xen_platform_ioport_writeb(v - } - } - -+static uint32_t ioport_base; -+ -+static void platform_ioport_write(void *opaque, uint32_t addr, uint32_t val) -+{ -+ DECLARE_DOMCTL; -+ int rc; -+ -+ if (val == 0) -+ qemu_invalidate_map_cache(); -+ -+ switch (addr - ioport_base) { -+ case 0: -+ fprintf(logfile, "Init hypercall page %x, addr %x.\n", val, addr); -+ domctl.domain = (domid_t)domid; -+ domctl.u.hypercall_init.gmfn = val; -+ domctl.cmd = XEN_DOMCTL_hypercall_init; -+ rc = xc_domctl(xc_handle, &domctl); -+ fprintf(logfile, "result -> %d.\n", rc); -+ break; -+ case 4: -+ fprintf(logfile, "Disconnect IDE hard disk...\n"); -+ ide_unplug_harddisks(); -+ fprintf(logfile, "Disconnect netifs...\n"); -+ pci_unplug_netifs(); -+ fprintf(logfile, "Shutdown taps...\n"); -+ net_tap_shutdown_all(); -+ fprintf(logfile, "Done.\n"); -+ break; -+ default: -+ fprintf(logfile, "Write to bad port %x (base %x) on evtchn device.\n", -+ addr, ioport_base); -+ break; -+ } -+} -+ - static void platform_ioport_map(PCIDevice *pci_dev, int region_num, uint32_t addr, uint32_t size, int type) - { -+ ioport_base = addr; -+ -+ register_ioport_write(addr, 16, 4, platform_ioport_write, NULL); -+/* - PCIXenPlatformState *d = (PCIXenPlatformState *)pci_dev; - register_ioport_write(addr, size, 1, xen_platform_ioport_writeb, d); - register_ioport_read(addr, size, 1, xen_platform_ioport_readb, d); -+*/ - } - - static uint32_t platform_mmio_read(void *opaque, target_phys_addr_t addr) diff --git a/xen-managed-pci-device.patch b/xen-managed-pci-device.patch deleted file mode 100644 index 26ba7c1..0000000 --- a/xen-managed-pci-device.patch +++ /dev/null @@ -1,336 +0,0 @@ -pci passthrough: handle managed pci devices - -Handle managed pci devices for libvirt usage. If a pci device is set -"managed=1", it will be made assignable (unbound from original driver and bind -to pcistub driver) before vm start and reattach to original driver after vm -shut off. - -FATE#313570 - -Note: This patch was rejected upstream since xend is deprecated. See the -following thread for details - -http://lists.xen.org/archives/html/xen-devel/2013-01/msg01145.html - -Signed-off-by: Chunyan Liu - -Index: xen-4.2.1-testing/tools/python/xen/util/pci.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/util/pci.py -+++ xen-4.2.1-testing/tools/python/xen/util/pci.py -@@ -20,6 +20,8 @@ from xen.xend import sxp - from xen.xend.XendConstants import AUTO_PHP_SLOT - from xen.xend.XendSXPDev import dev_dict_to_sxp - from xen.xend.XendLogging import log -+from xen.xend.xenstore.xstransact import xstransact -+from xen.xend.XendError import XendError - - # for 2.3 compatibility - try: -@@ -27,9 +29,11 @@ try: - except NameError: - from sets import Set as set - -+XS_PCIBACK_PATH = '/xm/pciback' - PROC_PCI_PATH = '/proc/bus/pci/devices' - PROC_PCI_NUM_RESOURCES = 7 - -+SYSFS_PCI_DRVS_PATH = 'bus/pci/drivers' - SYSFS_PCI_DEVS_PATH = '/bus/pci/devices' - SYSFS_PCI_DEV_RESOURCE_PATH = '/resource' - SYSFS_PCI_DEV_CONFIG_PATH = '/config' -@@ -161,7 +165,7 @@ def PCI_BDF(domain, bus, slot, func): - - def check_pci_opts(opts): - def f((k, v)): -- if k not in ['msitranslate', 'power_mgmt'] or \ -+ if k not in ['msitranslate', 'power_mgmt', 'managed'] or \ - not v.lower() in ['0', '1', 'yes', 'no']: - raise PciDeviceParseError('Invalid pci option %s=%s: ' % (k, v)) - -@@ -427,6 +431,9 @@ def __pci_dict_to_fmt_str(fmt, dev): - def pci_dict_to_bdf_str(dev): - return __pci_dict_to_fmt_str('%04x:%02x:%02x.%01x', dev) - -+def pci_dict_to_xs_bdf_str(dev): -+ return __pci_dict_to_fmt_str('%04x-%02x-%02x-%01x', dev) -+ - def pci_dict_to_xc_str(dev): - return __pci_dict_to_fmt_str('0x%x, 0x%x, 0x%x, 0x%x', dev) - -@@ -560,6 +567,115 @@ def find_all_assignable_devices(): - dev_list = dev_list + [dev] - return dev_list - -+def pci_assignable_add(dev): -+ '''detach pci device from driver that we need to unbind from and rebind -+ to pciback driver, then it can be assigned to guest. -+ ''' -+ sysfs_mnt = find_sysfs_mnt() -+ pcidev_path = sysfs_mnt + SYSFS_PCI_DEVS_PATH -+ pciback_path = sysfs_mnt + SYSFS_PCIBACK_PATH -+ -+ # See if the device exists -+ pci_bdf = pci_dict_to_bdf_str(dev) -+ path = pcidev_path + '/' + pci_bdf -+ if not os.path.exists(path): -+ log.debug("Pci device %s doesn't exist" % pci_bdf) -+ return -1 -+ -+ # Check to see if it's already assigned to pciback -+ path = pciback_path + '/' + pci_bdf -+ if os.path.exists(path): -+ log.debug("Pci device %s is already assigned to pciback" % pci_bdf) -+ return 0 -+ -+ # Check to see if there's already a driver that we need to unbind from -+ path = pcidev_path + '/' + pci_bdf + '/driver' -+ drv_path = None -+ if os.path.exists(path): -+ drv_path = os.path.realpath(path).replace(" ", "\ ") -+ cmd = 'echo %s > %s/unbind' % (pci_bdf, drv_path) -+ if os.system(cmd): -+ log.debug("Couldn't unbind device") -+ return -1; -+ -+ # Store driver_path for rebinding to dom0 -+ if drv_path is not None: -+ xs_pci_bdf = pci_dict_to_xs_bdf_str(dev) -+ path = XS_PCIBACK_PATH + '/' + xs_pci_bdf -+ xstransact.Mkdir(path) -+ xstransact.Write(path, 'driver_path', drv_path) -+ else: -+ log.debug("Not bound to a driver, will not be rebound") -+ -+ # Bind to pciback -+ try: -+ # Scan through /sys/.../pciback/slots looking for pcidev's BDF -+ slots = os.popen('cat %s/slots' % pciback_path).read() -+ if re.search(pci_bdf, slots) is None: -+ # write bdf to new_slot -+ cmd = 'echo %s > %s/new_slot' % (pci_bdf, pciback_path) -+ if os.system(cmd): -+ raise XendError("Couldn't add device to pciback new_slot") -+ -+ # Bind to pciback -+ cmd = 'echo %s > %s/bind' % (pci_bdf, pciback_path) -+ if os.system(cmd): -+ raise XendError("Couldn't bind device to pciback") -+ except XendError: -+ # rebind to original driver -+ if drv_path is not None: -+ log.debug("Rebind to original driver") -+ cmd = 'echo %s > %s/bind' % (pci_bdf, drv_path) -+ if os.system(cmd): -+ log.debug("Failed to rebind") -+ return -1 -+ -+ return 0 -+ -+def pci_assignable_remove(dev): -+ '''unbind pci device from pciback, and rebind to host pci driver where it -+ was detached from in pci-assignable-add. -+ ''' -+ sysfs_mnt = find_sysfs_mnt() -+ pcidrv_path = sysfs_mnt + SYSFS_PCI_DRVS_PATH -+ pciback_path = sysfs_mnt + SYSFS_PCIBACK_PATH -+ pci_bdf = pci_dict_to_bdf_str(dev) -+ -+ # Unbind from pciback -+ path = pciback_path + '/' + pci_bdf -+ if os.path.exists(path): -+ # unbind -+ cmd = 'echo %s > %s/unbind' % (pci_bdf, pciback_path) -+ if os.system(cmd): -+ log.debug("Couldn't unbind device to pciback") -+ return -1 -+ -+ # remove slots if necessary -+ slots = os.popen('cat %s/slots' % pciback_path).read() -+ if re.search(pci_bdf, slots): -+ # write bdf to remove_slot -+ cmd = 'echo %s > %s/remove_slot' % (pci_bdf, pciback_path) -+ if os.system(cmd): -+ log.debug("Couldn't remove pciback slot") -+ return -1 -+ else: -+ log.debug("Not bound to pciback") -+ -+ # Rebind if necessary -+ xs_pci_bdf = pci_dict_to_xs_bdf_str(dev) -+ path = XS_PCIBACK_PATH + '/' + xs_pci_bdf -+ drv_path = xstransact.Read(path, 'driver_path') -+ if drv_path: -+ cmd = 'echo %s > %s/bind' % (pci_bdf, drv_path) -+ if os.system(cmd): -+ log.debug("Couldn't rebind to driver %s" % drv_path) -+ return -1 -+ xstransact.Remove(path) -+ else: -+ log.debug("Counldn't find path for original driver. Not rebinding") -+ -+ return 0 -+ - def transform_list(target, src): - ''' src: its element is pci string (Format: xxxx:xx:xx.x). - target: its element is pci string, or a list of pci string. -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -303,7 +303,8 @@ def dom_get(dom): - return None - - from xen.xend.server.pciif import parse_pci_name, PciDevice,\ -- get_assigned_pci_devices, get_all_assigned_pci_devices -+ get_assigned_pci_devices, get_all_assigned_pci_devices,\ -+ prepare_host_pci_devices, reattach_host_pci_devices - - - def do_FLR(domid, is_hvm): -@@ -317,6 +318,20 @@ def do_FLR(domid, is_hvm): - "parse it's resources - "+str(e)) - dev.do_FLR(is_hvm, xoptions.get_pci_dev_assign_strict_check()) - -+def prepare_domain_pci_devices(domconfig): -+ ordered_refs = domconfig.ordered_device_refs() -+ for dev_uuid in ordered_refs: -+ devclass, devconfig = domconfig['devices'][dev_uuid] -+ if devclass == 'pci': -+ prepare_host_pci_devices(devconfig) -+ -+def reattach_domain_pci_devices(domconfig): -+ ordered_refs = domconfig.ordered_device_refs() -+ for dev_uuid in ordered_refs: -+ devclass, devconfig = domconfig['devices'][dev_uuid] -+ if devclass == 'pci': -+ reattach_host_pci_devices(devconfig) -+ - class XendDomainInfo: - """An object represents a domain. - -@@ -470,6 +485,7 @@ class XendDomainInfo: - - if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, XEN_API_VM_POWER_STATE_SUSPENDED, XEN_API_VM_POWER_STATE_CRASHED): - try: -+ prepare_domain_pci_devices(self.info); - XendTask.log_progress(0, 30, self._constructDomain) - XendTask.log_progress(31, 60, self._initDomain) - -@@ -496,6 +512,7 @@ class XendDomainInfo: - state = self._stateGet() - if state in (DOM_STATE_SUSPENDED, DOM_STATE_HALTED): - try: -+ prepare_domain_pci_devices(self.info) - self._constructDomain() - - try: -@@ -712,6 +729,8 @@ class XendDomainInfo: - the device. - """ - -+ if self.domid is None: -+ return - self.iommu_check_pod_mode() - - # Test whether the devices can be assigned -@@ -851,6 +870,9 @@ class XendDomainInfo: - - if self.domid is not None: - try: -+ if dev_type == 'pci': -+ prepare_host_pci_devices(dev_config_dict) -+ - dev_config_dict['devid'] = devid = \ - self._createDevice(dev_type, dev_config_dict) - if dev_type == 'tap2': -@@ -864,6 +886,7 @@ class XendDomainInfo: - if dev_type == 'pci': - for dev in dev_config_dict['devs']: - XendAPIStore.deregister(dev['uuid'], 'DPCI') -+ reattach_host_pci_devices(dev_config_dict) - elif dev_type == 'vscsi': - for dev in dev_config_dict['devs']: - XendAPIStore.deregister(dev['uuid'], 'DSCSI') -@@ -908,6 +931,10 @@ class XendDomainInfo: - dev_config = pci_convert_sxp_to_dict(dev_sxp) - dev = dev_config['devs'][0] - -+ # For attach only. For boot, prepare work has been done already in earlier stage. -+ if self.domid is not None and pci_state == 'Initialising' and pci_sub_state != 'Booting': -+ prepare_host_pci_devices(dev_config) -+ - stubdomid = self.getStubdomDomid() - # Do HVM specific processing - if self.info.is_hvm(): -@@ -984,6 +1010,9 @@ class XendDomainInfo: - new_dev_sxp = dev_control.configuration(devid) - self.info.device_update(dev_uuid, new_dev_sxp) - -+ if pci_state == 'Closing': -+ reattach_host_pci_devices(dev_config) -+ - # If there is no device left, destroy pci and remove config. - if num_devs == 0: - if self.info.is_hvm(): -@@ -3170,6 +3199,7 @@ class XendDomainInfo: - log.debug("%s KiB need to add to Memory pool" %self.alloc_mem) - MemoryPool.instance().increase_memory(self.alloc_mem) - -+ reattach_domain_pci_devices(self.info) - self._cleanup_phantom_devs(paths) - self._cleanupVm() - -Index: xen-4.2.1-testing/tools/python/xen/xend/server/pciif.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/server/pciif.py -+++ xen-4.2.1-testing/tools/python/xen/xend/server/pciif.py -@@ -86,6 +86,48 @@ def get_all_assigned_pci_devices(domid = - pci_str_list = pci_str_list + get_assigned_pci_devices(int(d)) - return pci_str_list - -+def reattach_host_pci_devices(devconfig): -+ pci_dev_list = devconfig.get('devs', []) -+ for pci_dev in pci_dev_list: -+ managed = 0 -+ pci_opts_config = pci_dev.get('opts', []) -+ for opt in pci_opts_config: -+ if opt[0] == 'managed': -+ managed = opt[1] -+ if managed: -+ if pci_assignable_remove(pci_dev) != 0: -+ raise VmError('pci_assignable_remove failed') -+ -+def detach_host_pci_devices(devconfig): -+ pci_dev_list = devconfig.get('devs', []) -+ reattach = 0 -+ for pci_dev in pci_dev_list: -+ managed = 0 -+ pci_opts_config = pci_dev.get('opts', []) -+ for opt in pci_opts_config: -+ if opt[0] == 'managed': -+ managed = opt[1] -+ if managed: -+ if pci_assignable_add(pci_dev) != 0: -+ log.debug('pci_assignable_add failed') -+ reattach = 1 -+ break -+ -+ if reattach: -+ reattach_host_pci_devices(devconfig) -+ raise VmError('detach_host_pci_devices failed') -+ -+def prepare_host_pci_devices(devconfig): -+ # Test whether the device used by other domain -+ pci_dev_list = devconfig.get('devs', []) -+ for pci_dev in pci_dev_list: -+ pci_name = pci_dict_to_bdf_str(pci_dev) -+ if pci_name in get_all_assigned_pci_devices(): -+ raise VmError("failed to assign device %s that has" -+ " already been assigned to other domain." % pci_name) -+ # Detach 'managed' devices -+ detach_host_pci_devices(devconfig) -+ - class PciController(DevController): - - def __init__(self, vm): diff --git a/xen-max-free-mem.diff b/xen-max-free-mem.diff deleted file mode 100644 index 734578d..0000000 --- a/xen-max-free-mem.diff +++ /dev/null @@ -1,148 +0,0 @@ -Index: xen-4.2.1-testing/tools/python/xen/xend/XendNode.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendNode.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendNode.py -@@ -949,11 +949,35 @@ class XendNode: - - info['cpu_mhz'] = info['cpu_khz'] / 1000 - -- # physinfo is in KiB, need it in MiB -- info['total_memory'] = info['total_memory'] / 1024 -- info['free_memory'] = info['free_memory'] / 1024 -+ configured_floor = xendoptions().get_dom0_min_mem() * 1024 -+ from xen.xend import balloon -+ try: -+ kernel_floor = balloon.get_dom0_min_target() -+ except: -+ kernel_floor = 0 -+ dom0_min_mem = max(configured_floor, kernel_floor) -+ dom0_mem = balloon.get_dom0_current_alloc() -+ extra_mem = 0 -+ if dom0_min_mem > 0 and dom0_mem > dom0_min_mem: -+ extra_mem = dom0_mem - dom0_min_mem -+ info['free_memory'] = info['free_memory'] + info['scrub_memory'] -+ info['max_free_memory'] = info['free_memory'] + extra_mem - info['free_cpus'] = len(XendCPUPool.unbound_cpus()) - -+ # Convert KiB to MiB, rounding down to be conservative -+ info['total_memory'] = info['total_memory'] / 1024 -+ info['free_memory'] = info['free_memory'] / 1024 -+ info['max_free_memory'] = info['max_free_memory'] / 1024 -+ -+ # FIXME: These are hard-coded to be the inverse of the getXenMemory -+ # functions in image.py. Find a cleaner way. -+ info['max_para_memory'] = info['max_free_memory'] - 4 -+ if info['max_para_memory'] < 0: -+ info['max_para_memory'] = 0 -+ info['max_hvm_memory'] = int((info['max_free_memory']-12) * (1-2.4/1024)) -+ if info['max_hvm_memory'] < 0: -+ info['max_hvm_memory'] = 0 -+ - ITEM_ORDER = ['nr_cpus', - 'nr_nodes', - 'cores_per_socket', -@@ -964,6 +988,9 @@ class XendNode: - 'total_memory', - 'free_memory', - 'free_cpus', -+ 'max_free_memory', -+ 'max_para_memory', -+ 'max_hvm_memory', - ] - - if show_numa != 0: -Index: xen-4.2.1-testing/tools/python/xen/xend/balloon.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/balloon.py -+++ xen-4.2.1-testing/tools/python/xen/xend/balloon.py -@@ -43,6 +43,8 @@ SLEEP_TIME_GROWTH = 0.1 - # label actually shown in the PROC_XEN_BALLOON file. - #labels = { 'current' : 'Current allocation', - # 'target' : 'Requested target', -+# 'min-target' : 'Minimum target', -+# 'max-target' : 'Maximum target', - # 'low-balloon' : 'Low-mem balloon', - # 'high-balloon' : 'High-mem balloon', - # 'limit' : 'Xen hard limit' } -@@ -69,6 +71,23 @@ def get_dom0_target_alloc(): - raise VmError('Failed to query target memory allocation of dom0.') - return kb - -+def get_dom0_min_target(): -+ """Returns the minimum amount of memory (in KiB) that dom0 will accept.""" -+ -+ kb = _get_proc_balloon('min-target') -+ if kb == None: -+ raise VmError('Failed to query minimum target memory allocation of dom0.') -+ return kb -+ -+def get_dom0_max_target(): -+ """Returns the maximum amount of memory (in KiB) that is potentially -+ visible to dom0.""" -+ -+ kb = _get_proc_balloon('max-target') -+ if kb == None: -+ raise VmError('Failed to query maximum target memory allocation of dom0.') -+ return kb -+ - def free(need_mem, dominfo): - """Balloon out memory from the privileged domain so that there is the - specified required amount (in KiB) free. -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1475,6 +1475,27 @@ class XendDomainInfo: - self.info['abort_if_busy'] = str(abort_if_busy) - self.info['log_save_progress'] = str(log_save_progress) - -+ def capAndSetMemoryTarget(self, target): -+ """Potentially lowers the requested target to the largest possible -+ value (i.e., caps it), and then sets the memory target of this domain -+ to that value. -+ @param target in MiB. -+ """ -+ max_target = 0 -+ if self.domid == 0: -+ try: -+ from balloon import get_dom0_max_target -+ max_target = get_dom0_max_target() / 1024 -+ except: -+ # It's nice to cap the max at sane values, but harmless to set -+ # them high. Carry on. -+ pass -+ if max_target and target > max_target: -+ log.debug("Requested memory target %d MiB; maximum reasonable is %d MiB.", -+ target, max_target) -+ target = max_target -+ self.setMemoryTarget(target) -+ - def setMemoryTarget(self, target): - """Set the memory target of this domain. - @param target: In MiB. -Index: xen-4.2.1-testing/tools/python/xen/xend/server/SrvDomain.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/server/SrvDomain.py -+++ xen-4.2.1-testing/tools/python/xen/xend/server/SrvDomain.py -@@ -187,7 +187,7 @@ class SrvDomain(SrvDir): - - - def op_mem_target_set(self, _, req): -- return self.call(self.dom.setMemoryTarget, -+ return self.call(self.dom.capAndSetMemoryTarget, - [['target', 'int']], - req) - -Index: xen-4.2.1-testing/tools/python/xen/xend/osdep.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/osdep.py -+++ xen-4.2.1-testing/tools/python/xen/xend/osdep.py -@@ -42,6 +42,8 @@ def _linux_balloon_stat_proc(label): - - xend2linux_labels = { 'current' : 'Current allocation', - 'target' : 'Requested target', -+ 'min-target' : 'Minimum target', -+ 'max-target' : 'Maximum target', - 'low-balloon' : 'Low-mem balloon', - 'high-balloon' : 'High-mem balloon', - 'limit' : 'Xen hard limit' } diff --git a/xen-migration-bridge-check.patch b/xen-migration-bridge-check.patch deleted file mode 100644 index e049c25..0000000 --- a/xen-migration-bridge-check.patch +++ /dev/null @@ -1,29 +0,0 @@ -bnc#757525 - -Index: xen-4.2.0-testing/tools/python/xen/xend/server/netif.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/server/netif.py -+++ xen-4.2.0-testing/tools/python/xen/xend/server/netif.py -@@ -23,6 +23,7 @@ - import os - import random - import re -+import commands - - from xen.xend import XendOptions, sxp - from xen.xend.server.DevController import DevController -@@ -101,6 +102,14 @@ class NetifController(DevController): - def __init__(self, vm): - DevController.__init__(self, vm) - -+ def createDevice(self, config): -+ bridge = config.get('bridge') -+ if bridge is not None: -+ bridge_result = commands.getstatusoutput("/sbin/ifconfig %s" % bridge) -+ if bridge_result[0] != 0: -+ raise VmError('Network bridge does not exist: %s' % bridge) -+ DevController.createDevice(self, config) -+ - def getDeviceDetails(self, config): - """@see DevController.getDeviceDetails""" - diff --git a/xen-minimum-restart-time.patch b/xen-minimum-restart-time.patch deleted file mode 100644 index 2de06a0..0000000 --- a/xen-minimum-restart-time.patch +++ /dev/null @@ -1,15 +0,0 @@ -References: bnc#661298 - -Index: xen-4.2.0-testing/tools/python/xen/xend/XendConstants.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/XendConstants.py -+++ xen-4.2.0-testing/tools/python/xen/xend/XendConstants.py -@@ -94,7 +94,7 @@ DOM_STATES_OLD = [ - SHUTDOWN_TIMEOUT = (60.0 * 5) - - """Minimum time between domain restarts in seconds.""" --MINIMUM_RESTART_TIME = 60 -+MINIMUM_RESTART_TIME = 10 - - RESTART_IN_PROGRESS = 'xend/restart_in_progress' - DUMPCORE_IN_PROGRESS = 'xend/dumpcore_in_progress' diff --git a/xen-no-dummy-nfs-ip.diff b/xen-no-dummy-nfs-ip.diff deleted file mode 100644 index b22b2bc..0000000 --- a/xen-no-dummy-nfs-ip.diff +++ /dev/null @@ -1,15 +0,0 @@ -Index: xen-4.2.0-testing/tools/python/xen/xm/create.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xm/create.py -+++ xen-4.2.0-testing/tools/python/xen/xm/create.py -@@ -1342,9 +1342,8 @@ def preprocess_access_control(vals): - - def preprocess_ip(vals): - if vals.ip or vals.dhcp != 'off': -- dummy_nfs_server = '127.0.255.255' - ip = (vals.ip -- + ':' + (vals.nfs_server or dummy_nfs_server) -+ + ':' + (vals.nfs_server or '') - + ':' + vals.gateway - + ':' + vals.netmask - + ':' + vals.hostname diff --git a/xen-paths.diff b/xen-paths.diff deleted file mode 100644 index 448fe18..0000000 --- a/xen-paths.diff +++ /dev/null @@ -1,69 +0,0 @@ -Index: xen-4.2.0-testing/tools/python/xen/xm/create.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xm/create.py -+++ xen-4.2.0-testing/tools/python/xen/xm/create.py -@@ -73,7 +73,7 @@ gopts.opt('quiet', short='q', - use="Quiet.") - - gopts.opt('path', val='PATH', -- fn=set_value, default='.:' + auxbin.xen_configdir(), -+ fn=set_value, default='.:' + auxbin.xen_configdir() + "/vm", - use="Search path for configuration scripts. " - "The value of PATH is a colon-separated directory list.") - -Index: xen-4.2.0-testing/docs/man/xm.pod.1 -=================================================================== ---- xen-4.2.0-testing.orig/docs/man/xm.pod.1 -+++ xen-4.2.0-testing/docs/man/xm.pod.1 -@@ -79,7 +79,7 @@ in the config file. See L - format, and possible options used in either the configfile or for I. - - I can either be an absolute path to a file, or a relative --path to a file located in /etc/xen. -+path to a file located in /etc/xen/vm. - - Create will return B as the domain is started. This B mean the guest OS in the domain has actually booted, or is -@@ -160,7 +160,7 @@ B - - xm create Fedora4 - --This creates a domain with the file /etc/xen/Fedora4, and returns as -+This creates a domain with the file /etc/xen/vm/Fedora4, and returns as - soon as it is run. - - =item I -Index: xen-4.2.0-testing/docs/man/xmdomain.cfg.pod.5 -=================================================================== ---- xen-4.2.0-testing.orig/docs/man/xmdomain.cfg.pod.5 -+++ xen-4.2.0-testing/docs/man/xmdomain.cfg.pod.5 -@@ -4,9 +4,9 @@ xmdomain.cfg - xm domain config file for - - =head1 SYNOPSIS - -- /etc/xen/myxendomain -- /etc/xen/myxendomain2 -- /etc/xen/auto/myxenautostarted -+ /etc/xen/auto/ -+ /etc/xen/examples/ -+ /etc/xen/vm/ - - =head1 DESCRIPTION - -@@ -14,14 +14,14 @@ The B(1) program uses python executa - domains to create from scratch. Each of these config files needs to - contain a number of required options, and may specify many more. - --Domain configuration files live in /etc/xen by default, if you store -+Domain configuration files live in /etc/xen/vm by default. If you store - config files anywhere else the full path to the config file must be - specified in the I command. - - /etc/xen/auto is a special case. Domain config files in that - directory will be started automatically at system boot if the - xendomain init script is enabled. The contents of /etc/xen/auto --should be symlinks to files in /etc/xen to allow I to be -+should be symlinks to files in /etc/xen/vm to allow I to be - used without full paths. - - Options are specified by I statements in the diff --git a/xen-qemu-iscsi-fix.patch b/xen-qemu-iscsi-fix.patch deleted file mode 100644 index e5782c9..0000000 --- a/xen-qemu-iscsi-fix.patch +++ /dev/null @@ -1,76 +0,0 @@ -Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -=================================================================== ---- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/xenstore.c -+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -@@ -449,7 +449,7 @@ void xenstore_parse_domain_config(int hv - char *buf = NULL; - char *fpath = NULL, *bpath = NULL, *btype = NULL, - *dev = NULL, *params = NULL, *drv = NULL; -- int i, ret, is_tap; -+ int i, j, ret, is_tap; - unsigned int len, num, hd_index, pci_devid = 0; - BlockDriverState *bs; - BlockDriver *format; -@@ -533,12 +533,7 @@ void xenstore_parse_domain_config(int hv - continue; - free(danger_type); - danger_type = xs_read(xsh, XBT_NULL, danger_buf, &len); -- if (pasprintf(&buf, "%s/params", bpath) == -1) -- continue; -- free(params); -- params = xs_read(xsh, XBT_NULL, buf, &len); -- if (params == NULL) -- continue; -+ - /* read the name of the device */ - if (pasprintf(&buf, "%s/type", bpath) == -1) - continue; -@@ -546,6 +541,35 @@ void xenstore_parse_domain_config(int hv - drv = xs_read(xsh, XBT_NULL, buf, &len); - if (drv == NULL) - continue; -+ -+ free(params); -+ if (!strcmp(drv,"iscsi") || !strcmp(drv, "npiv") || -+ !strcmp(drv,"dmmd")) { -+ if (pasprintf(&buf, "%s/node", bpath) == -1) -+ continue; -+ -+ /* wait for block-[iscsi|npiv|dmmd] script to complete and populate the -+ * node entry. try 30 times (30 secs) */ -+ for (j = 0; j < 30; j++) { -+ params = xs_read(xsh, XBT_NULL, buf, &len); -+ if (params != NULL) -+ break; -+ sleep(1); -+ } -+ if (params == NULL) { -+ fprintf(stderr, "qemu: %s device not found -- timed out \n", drv); -+ continue; -+ } -+ } -+ else -+ { -+ if (pasprintf(&buf, "%s/params", bpath) == -1) -+ continue; -+ params = xs_read(xsh, XBT_NULL, buf, &len); -+ if (params == NULL) -+ continue; -+ } -+ - /* Obtain blktap sub-type prefix */ - if ((!strcmp(drv, "tap") || !strcmp(drv, "qdisk")) && params[0]) { - char *offset = strchr(params, ':'); -@@ -663,6 +687,12 @@ void xenstore_parse_domain_config(int hv - format = &bdrv_host_device; - else - format = &bdrv_raw; -+ } else if (!strcmp(drv,"iscsi")) { -+ format = &bdrv_raw; -+ } else if (!strcmp(drv,"npiv")) { -+ format = &bdrv_raw; -+ } else if (!strcmp(drv,"dmmd")) { -+ format = &bdrv_raw; - } else { - format = bdrv_find_format(drv); - if (!format) { diff --git a/xen-xm-top-needs-root.diff b/xen-xm-top-needs-root.diff deleted file mode 100644 index 763fe5e..0000000 --- a/xen-xm-top-needs-root.diff +++ /dev/null @@ -1,18 +0,0 @@ -From: Charles Coffing -Upstream: no - -Index: xen-4.2.0-testing/tools/python/xen/xm/main.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xm/main.py -+++ xen-4.2.0-testing/tools/python/xen/xm/main.py -@@ -2201,6 +2201,10 @@ def xm_debug_keys(args): - def xm_top(args): - arg_check(args, "top", 0) - -+ # A hack to get a clear error message if ran as non-root -+ if os.geteuid() != 0: -+ raise IOError() -+ - os.system('xentop') - - def xm_dmesg(args): diff --git a/xen-xmexample-vti.diff b/xen-xmexample-vti.patch similarity index 100% rename from xen-xmexample-vti.diff rename to xen-xmexample-vti.patch diff --git a/xen-xmexample.diff b/xen-xmexample.patch similarity index 86% rename from xen-xmexample.diff rename to xen-xmexample.patch index e3715b2..f757eec 100644 --- a/xen-xmexample.diff +++ b/xen-xmexample.patch @@ -1,9 +1,9 @@ Change various example paths in the config files to match SUSE. -Index: xen-4.2.0-testing/tools/examples/xmexample1 +Index: xen-4.3.0-testing/tools/examples/xmexample1 =================================================================== ---- xen-4.2.0-testing.orig/tools/examples/xmexample1 -+++ xen-4.2.0-testing/tools/examples/xmexample1 +--- xen-4.3.0-testing.orig/tools/examples/xmexample1 ++++ xen-4.3.0-testing/tools/examples/xmexample1 @@ -7,11 +7,17 @@ #============================================================================ @@ -41,7 +41,7 @@ Index: xen-4.2.0-testing/tools/examples/xmexample1 vif = [ '' ] -@@ -131,7 +137,7 @@ disk = [ 'phy:hda1,hda1,w' ] +@@ -117,7 +123,7 @@ disk = [ 'phy:hda1,hda1,w' ] #hostname= "vm%d" % vmid # Set root device. @@ -50,7 +50,7 @@ Index: xen-4.2.0-testing/tools/examples/xmexample1 # Root device for nfs. #root = "/dev/nfs" -@@ -140,8 +146,8 @@ root = "/dev/hda1 ro" +@@ -126,8 +132,8 @@ root = "/dev/hda1 ro" # Root directory on the nfs server. #nfs_root = '/full/path/to/root/directory' @@ -61,10 +61,10 @@ Index: xen-4.2.0-testing/tools/examples/xmexample1 #---------------------------------------------------------------------------- # Configure the behaviour when a domain exits. There are three 'reasons' -Index: xen-4.2.0-testing/tools/examples/xmexample2 +Index: xen-4.3.0-testing/tools/examples/xmexample2 =================================================================== ---- xen-4.2.0-testing.orig/tools/examples/xmexample2 -+++ xen-4.2.0-testing/tools/examples/xmexample2 +--- xen-4.3.0-testing.orig/tools/examples/xmexample2 ++++ xen-4.3.0-testing/tools/examples/xmexample2 @@ -35,11 +35,17 @@ xm_vars.var('vmid', xm_vars.check() @@ -102,7 +102,7 @@ Index: xen-4.2.0-testing/tools/examples/xmexample2 vif = [ '' ] -@@ -167,7 +173,7 @@ disk = [ 'phy:sda%d,sda1,w' % (7+vmid), +@@ -153,7 +159,7 @@ disk = [ 'phy:sda%d,sda1,w' % (7+vmid), #hostname= "vm%d" % vmid # Set root device. @@ -111,7 +111,7 @@ Index: xen-4.2.0-testing/tools/examples/xmexample2 # Root device for nfs. #root = "/dev/nfs" -@@ -176,8 +182,8 @@ root = "/dev/sda1 ro" +@@ -162,8 +168,8 @@ root = "/dev/sda1 ro" # Root directory on the nfs server. #nfs_root = '/full/path/to/root/directory' @@ -122,10 +122,10 @@ Index: xen-4.2.0-testing/tools/examples/xmexample2 #---------------------------------------------------------------------------- # Configure the behaviour when a domain exits. There are three 'reasons' -Index: xen-4.2.0-testing/tools/examples/xmexample3 +Index: xen-4.3.0-testing/tools/examples/xmexample3 =================================================================== ---- xen-4.2.0-testing.orig/tools/examples/xmexample3 -+++ xen-4.2.0-testing/tools/examples/xmexample3 +--- xen-4.3.0-testing.orig/tools/examples/xmexample3 ++++ xen-4.3.0-testing/tools/examples/xmexample3 @@ -35,11 +35,17 @@ xm_vars.var('vmid', xm_vars.check() @@ -148,10 +148,10 @@ Index: xen-4.2.0-testing/tools/examples/xmexample3 # The domain build function. Default is 'linux'. #builder='linux' -Index: xen-4.2.0-testing/tools/examples/xmexample.hvm +Index: xen-4.3.0-testing/tools/examples/xmexample.hvm =================================================================== ---- xen-4.2.0-testing.orig/tools/examples/xmexample.hvm -+++ xen-4.2.0-testing/tools/examples/xmexample.hvm +--- xen-4.3.0-testing.orig/tools/examples/xmexample.hvm ++++ xen-4.3.0-testing/tools/examples/xmexample.hvm @@ -64,11 +64,26 @@ name = "ExampleHVMDomain" #cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 #cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 @@ -193,10 +193,10 @@ Index: xen-4.2.0-testing/tools/examples/xmexample.hvm #---------------------------------------------------------------------------- # Configure the behaviour when a domain exits. There are three 'reasons' -Index: xen-4.2.0-testing/docs/man/xmdomain.cfg.pod.5 +Index: xen-4.3.0-testing/docs/man/xmdomain.cfg.pod.5 =================================================================== ---- xen-4.2.0-testing.orig/docs/man/xmdomain.cfg.pod.5 -+++ xen-4.2.0-testing/docs/man/xmdomain.cfg.pod.5 +--- xen-4.3.0-testing.orig/docs/man/xmdomain.cfg.pod.5 ++++ xen-4.3.0-testing/docs/man/xmdomain.cfg.pod.5 @@ -38,13 +38,13 @@ file. The kernel image for the domain. The format of the parameter is the @@ -232,10 +232,10 @@ Index: xen-4.2.0-testing/docs/man/xmdomain.cfg.pod.5 at hda1, which is the root filesystem. =item I -Index: xen-4.2.0-testing/docs/man/xm.pod.1 +Index: xen-4.3.0-testing/docs/man/xm.pod.1 =================================================================== ---- xen-4.2.0-testing.orig/docs/man/xm.pod.1 -+++ xen-4.2.0-testing/docs/man/xm.pod.1 +--- xen-4.3.0-testing.orig/docs/man/xm.pod.1 ++++ xen-4.3.0-testing/docs/man/xm.pod.1 @@ -165,8 +165,8 @@ soon as it is run. =item I @@ -247,10 +247,10 @@ Index: xen-4.2.0-testing/docs/man/xm.pod.1 name=ramdisk vif='' vcpus=1 \ memory=64 root=/dev/ram0 -Index: xen-4.2.0-testing/tools/examples/xmexample.hvm-stubdom +Index: xen-4.3.0-testing/tools/examples/xmexample.hvm-stubdom =================================================================== ---- xen-4.2.0-testing.orig/tools/examples/xmexample.hvm-stubdom -+++ xen-4.2.0-testing/tools/examples/xmexample.hvm-stubdom +--- xen-4.3.0-testing.orig/tools/examples/xmexample.hvm-stubdom ++++ xen-4.3.0-testing/tools/examples/xmexample.hvm-stubdom @@ -55,11 +55,26 @@ name = "xmexample.hvm" #cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 #cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 @@ -283,10 +283,10 @@ Index: xen-4.2.0-testing/tools/examples/xmexample.hvm-stubdom #---------------------------------------------------------------------------- # Define the disk devices you want the domain to have access to, and -Index: xen-4.2.0-testing/tools/examples/xmexample.pv-grub +Index: xen-4.3.0-testing/tools/examples/xmexample.pv-grub =================================================================== ---- xen-4.2.0-testing.orig/tools/examples/xmexample.pv-grub -+++ xen-4.2.0-testing/tools/examples/xmexample.pv-grub +--- xen-4.3.0-testing.orig/tools/examples/xmexample.pv-grub ++++ xen-4.3.0-testing/tools/examples/xmexample.pv-grub @@ -53,11 +53,11 @@ name = "ExampleDomain" # # or optionally override backend, bridge, ip, mac, script, type, or vifname: @@ -301,10 +301,10 @@ Index: xen-4.2.0-testing/tools/examples/xmexample.pv-grub vif = [ '' ] -Index: xen-4.2.0-testing/tools/examples/xmexample.vti +Index: xen-4.3.0-testing/tools/examples/xmexample.vti =================================================================== ---- xen-4.2.0-testing.orig/tools/examples/xmexample.vti -+++ xen-4.2.0-testing/tools/examples/xmexample.vti +--- xen-4.3.0-testing.orig/tools/examples/xmexample.vti ++++ xen-4.3.0-testing/tools/examples/xmexample.vti @@ -40,11 +40,26 @@ name = "ExampleVTIDomain" # In Windows OS, smaller size shows better performance. #vhpt = 23 @@ -337,10 +337,10 @@ Index: xen-4.2.0-testing/tools/examples/xmexample.vti #---------------------------------------------------------------------------- # Define the disk devices you want the domain to have access to, and -Index: xen-4.2.0-testing/docs/man/xl.pod.1 +Index: xen-4.3.0-testing/docs/man/xl.pod.1 =================================================================== ---- xen-4.2.0-testing.orig/docs/man/xl.pod.1 -+++ xen-4.2.0-testing/docs/man/xl.pod.1 +--- xen-4.3.0-testing.orig/docs/man/xl.pod.1 ++++ xen-4.3.0-testing/docs/man/xl.pod.1 @@ -12,7 +12,8 @@ The B program is the new tool for ma domains. The program can be used to create, pause, and shutdown domains. It can also be used to list current domains, enable or pin diff --git a/xen.changes b/xen.changes index 593f075..f5464da 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,39 @@ +------------------------------------------------------------------- +Fri May 31 09:40:59 MDT 2013 - carnold@suse.com + +- bnc#801663 - performance of mirror lvm unsuitable for production + block-dmmd + +------------------------------------------------------------------- +Thu May 30 18:45:40 MDT 2013 - carnold@suse.com + +- Update to Xen 4.3.0-rc2 + +------------------------------------------------------------------- +Wed May 15 13:45:50 MDT 2013 - carnold@suse.com + +- Consolidate all xend and traditional qemu patches into one patch + file. Rename '.diff' patches to '.patch' and reoder others. + xend-traditional-qemu.patch + +------------------------------------------------------------------- +Tue May 14 15:36:04 MDT 2013 - carnold@suse.com + +- Create a xend-tools package for the legacy xend toolstack files + +------------------------------------------------------------------- +Mon May 13 16:02:52 MDT 2013 - carnold@suse.com + +- Update to Xen 4.3.0-rc1 c/s 27068 + +------------------------------------------------------------------- +Tue May 7 11:46:29 MDT 2013 - carnold@suse.com + +- bnc#818183 - VUL-0: xen: CVE-2013-2007: XSA-51: qga set umask + 0077 when daemonizing + CVE-2013-2007-xsa51-1.patch + CVE-2013-2007-xsa51-2.patch + ------------------------------------------------------------------- Mon May 6 15:52:03 CEST 2013 - ohering@suse.de @@ -15,6 +51,13 @@ Sun May 5 16:20:30 CEST 2013 - ohering@suse.de - bnc#802221 - fix xenpaging readd xenpaging.qemu.flush-cache.patch +------------------------------------------------------------------- +Thu May 2 09:11:33 MDT 2013 - carnold@suse.com + +- bnc#808269 - Fully Virtualized Windows VM install is failed on + Ivy Bridge platforms with Xen kernel + 26754-hvm-Improve-APIC-INIT-SIPI-emulation.patch + ------------------------------------------------------------------- Tue Apr 30 09:15:26 MDT 2013 - carnold@suse.com diff --git a/xen.migrate.tools-libxc_print_stats_if_migration_is_aborted.patch b/xen.migrate.tools-libxc_print_stats_if_migration_is_aborted.patch deleted file mode 100644 index 75baeaf..0000000 --- a/xen.migrate.tools-libxc_print_stats_if_migration_is_aborted.patch +++ /dev/null @@ -1,25 +0,0 @@ -user: Olaf Hering -date: Thu Mar 28 15:36:07 2013 +0100 -files: tools/libxc/xc_domain_save.c -description: -tools/libxc: print stats if migration is aborted - -Signed-off-by: Olaf Hering - - ---- - tools/libxc/xc_domain_save.c | 1 + - 1 file changed, 1 insertion(+) - -Index: xen-4.2.1-testing/tools/libxc/xc_domain_save.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxc/xc_domain_save.c -+++ xen-4.2.1-testing/tools/libxc/xc_domain_save.c -@@ -1536,6 +1536,7 @@ int xc_domain_save(xc_interface *xch, in - ERROR("Live migration aborted, as requested. (guest too busy?)" - " total_sent %lu iter %d, max_iters %u max_factor %u", - total_sent, iter, max_iters, max_factor); -+ print_stats(xch, dom, sent_this_iter, &time_stats, &shadow_stats, 1); - rc = 1; - goto out; - } diff --git a/xen.migrate.tools-xc_document_printf_calls_in_xc_restore.patch b/xen.migrate.tools-xc_document_printf_calls_in_xc_restore.patch deleted file mode 100644 index 544abcd..0000000 --- a/xen.migrate.tools-xc_document_printf_calls_in_xc_restore.patch +++ /dev/null @@ -1,20 +0,0 @@ -user: Olaf Hering -date: Wed Mar 06 16:42:02 2013 +0100 -files: tools/xcutils/xc_restore.c -description: -tools/xc: document printf calls in xc_restore - -Signed-off-by: Olaf Hering - - -diff -r e5ae0e680b5c -r 49b90990442a tools/xcutils/xc_restore.c ---- a/tools/xcutils/xc_restore.c -+++ b/tools/xcutils/xc_restore.c -@@ -56,6 +56,7 @@ main(int argc, char **argv) - - if ( ret == 0 ) - { -+ /* xend expects this output, part of protocol */ - printf("store-mfn %li\n", store_mfn); - if ( !hvm ) - printf("console-mfn %li\n", console_mfn); diff --git a/xen.migrate.tools-xc_print_messages_from_xc_save_with_xc_report.patch b/xen.migrate.tools-xc_print_messages_from_xc_save_with_xc_report.patch deleted file mode 100644 index 6a900ed..0000000 --- a/xen.migrate.tools-xc_print_messages_from_xc_save_with_xc_report.patch +++ /dev/null @@ -1,178 +0,0 @@ -user: Olaf Hering -date: Wed Mar 06 16:32:08 2013 +0100 -files: tools/libxc/xc_private.h tools/xcutils/xc_save.c -description: -tools/xc: print messages from xc_save with xc_report - -Make use of xc_report in xc_save to log also pid if some error occoured. - -Signed-off-by: Olaf Hering - - -diff -r 7af4246a6e1c -r e5ae0e680b5c tools/libxc/xc_private.h ---- a/tools/libxc/xc_private.h -+++ b/tools/libxc/xc_private.h -@@ -119,6 +119,7 @@ void xc_report_progress_step(xc_interfac - - /* anamorphic macros: struct xc_interface *xch must be in scope */ - -+#define WPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_WARN,0, _f , ## _a) - #define IPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_INFO,0, _f , ## _a) - #define DPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_DETAIL,0, _f , ## _a) - #define DBGPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_DEBUG,0, _f , ## _a) -diff -r 7af4246a6e1c -r e5ae0e680b5c tools/xcutils/xc_save.c ---- a/tools/xcutils/xc_save.c -+++ b/tools/xcutils/xc_save.c -@@ -7,6 +7,7 @@ - * - */ - -+#include - #include - #include - #include -@@ -19,6 +20,7 @@ - #include - #include - -+#include - #include - #include - #include -@@ -51,16 +53,17 @@ static int compat_suspend(void) - * receive the acknowledgement from the subscribe event channel. */ - static int evtchn_suspend(void) - { -+ xc_interface *xch = si.xch; - int rc; - - rc = xc_evtchn_notify(si.xce, si.suspend_evtchn); - if (rc < 0) { -- warnx("failed to notify suspend request channel: %d", rc); -+ WPRINTF("failed to notify suspend request channel: %d", rc); - return 0; - } - -- if (xc_await_suspend(si.xch, si.xce, si.suspend_evtchn) < 0) { -- warnx("suspend failed"); -+ if (xc_await_suspend(xch, si.xce, si.suspend_evtchn) < 0) { -+ WPRINTF("suspend failed"); - return 0; - } - -@@ -104,20 +107,27 @@ static int suspend(void* data) - - static int switch_qemu_logdirty(int domid, unsigned int enable, void *data) - { -+ xc_interface *xch = si.xch; - struct xs_handle *xs; - char *path, *p, *ret_str, *cmd_str, **watch; - unsigned int len; - struct timeval tv; - fd_set fdset; - -- if ((xs = xs_daemon_open()) == NULL) -- errx(1, "Couldn't contact xenstore"); -- if (!(path = strdup("/local/domain/0/device-model/"))) -- errx(1, "can't get domain path in store"); -+ if ((xs = xs_daemon_open()) == NULL) { -+ PERROR("Couldn't contact xenstore"); -+ exit(1); -+ } -+ if (!(path = strdup("/local/domain/0/device-model/"))) { -+ PERROR("can't get domain path in store"); -+ exit(1); -+ } - if (!(path = realloc(path, strlen(path) - + 10 -- + strlen("/logdirty/cmd") + 1))) -- errx(1, "no memory for constructing xenstore path"); -+ + strlen("/logdirty/cmd") + 1))) { -+ PERROR("no memory for constructing xenstore path"); -+ exit(1); -+ } - snprintf(path + strlen(path), 11, "%i", domid); - strcat(path, "/logdirty/"); - p = path + strlen(path); -@@ -126,16 +136,22 @@ static int switch_qemu_logdirty(int domi - /* Watch for qemu's return value */ - strcpy(p, "ret"); - if (!xs_watch(xs, path, "qemu-logdirty-ret")) -- errx(1, "can't set watch in store (%s)\n", path); -+ { -+ ERROR("can't set watch in store (%s)\n", path); -+ exit(1); -+ } - -- if (!(cmd_str = strdup( enable == 0 ? "disable" : "enable"))) -- errx(1, "can't get logdirty cmd path in store"); -+ if (!(cmd_str = strdup( enable == 0 ? "disable" : "enable"))) { -+ PERROR("can't get logdirty cmd path in store"); -+ exit(1); -+ } - - /* Tell qemu that we want it to start logging dirty page to Xen */ - strcpy(p, "cmd"); -- if (!xs_write(xs, XBT_NULL, path, cmd_str, strlen(cmd_str))) -- errx(1, "can't write to store path (%s)\n", -- path); -+ if (!xs_write(xs, XBT_NULL, path, cmd_str, strlen(cmd_str))) { -+ PERROR("can't write to store path (%s)\n", path); -+ exit(1); -+ } - - /* Wait a while for qemu to signal that it has service logdirty command */ - read_again: -@@ -144,8 +160,10 @@ static int switch_qemu_logdirty(int domi - FD_ZERO(&fdset); - FD_SET(xs_fileno(xs), &fdset); - -- if ((select(xs_fileno(xs) + 1, &fdset, NULL, NULL, &tv)) != 1) -- errx(1, "timed out waiting for qemu logdirty response.\n"); -+ if ((select(xs_fileno(xs) + 1, &fdset, NULL, NULL, &tv)) != 1) { -+ PERROR("timed out waiting for qemu logdirty response.\n"); -+ exit(1); -+ } - - watch = xs_read_watch(xs, &len); - free(watch); -@@ -166,6 +184,7 @@ static int switch_qemu_logdirty(int domi - int - main(int argc, char **argv) - { -+ xc_interface *xch; - unsigned int maxit, max_f, lflags; - int io_fd, ret, port; - struct save_callbacks callbacks; -@@ -186,26 +205,26 @@ main(int argc, char **argv) - lvl = si.flags & XCFLAGS_DEBUG ? XTL_DEBUG: XTL_DETAIL; - lflags = XTL_STDIOSTREAM_SHOW_PID | XTL_STDIOSTREAM_HIDE_PROGRESS; - l = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr, lvl, lflags); -- si.xch = xc_interface_open(l, 0, 0); -+ xch = si.xch = xc_interface_open(l, 0, 0); - if (!si.xch) -- errx(1, "failed to open control interface"); -+ errx(1, "[%lu] failed to open control interface", (unsigned long)getpid()); - - si.xce = xc_evtchn_open(NULL, 0); - if (si.xce == NULL) -- warnx("failed to open event channel handle"); -+ WPRINTF("failed to open event channel handle"); - else - { - port = xs_suspend_evtchn_port(si.domid); - - if (port < 0) -- warnx("failed to get the suspend evtchn port\n"); -+ WPRINTF("failed to get the suspend evtchn port\n"); - else - { - si.suspend_evtchn = - xc_suspend_evtchn_init(si.xch, si.xce, si.domid, port); - - if (si.suspend_evtchn < 0) -- warnx("suspend event channel initialization failed, " -+ WPRINTF("suspend event channel initialization failed, " - "using slow path"); - } - } diff --git a/xen.migrate.tools-xc_rework_xc_save.cswitch_qemu_logdirty.patch b/xen.migrate.tools-xc_rework_xc_save.cswitch_qemu_logdirty.patch deleted file mode 100644 index 84da9dd..0000000 --- a/xen.migrate.tools-xc_rework_xc_save.cswitch_qemu_logdirty.patch +++ /dev/null @@ -1,136 +0,0 @@ -user: Olaf Hering -date: Wed Mar 06 17:05:10 2013 +0100 -files: tools/xcutils/xc_save.c -description: -tools/xc: rework xc_save.c:switch_qemu_logdirty - -Rework code in switch_qemu_logdirty, fix also memleak. - -Signed-off-by: Olaf Hering - - -diff -r 49b90990442a -r 1ea501d60264 tools/xcutils/xc_save.c ---- a/tools/xcutils/xc_save.c -+++ b/tools/xcutils/xc_save.c -@@ -7,6 +7,7 @@ - * - */ - -+#define _GNU_SOURCE - #include - #include - #include -@@ -109,8 +110,10 @@ static int switch_qemu_logdirty(int domi - { - xc_interface *xch = si.xch; - struct xs_handle *xs; -- char *path, *p, *ret_str, *cmd_str, **watch; -+ char *path, *dir_p, *ret_str, **watch; -+ const char *cmd_str; - unsigned int len; -+ int ret, again; - struct timeval tv; - fd_set fdset; - -@@ -118,65 +121,56 @@ static int switch_qemu_logdirty(int domi - PERROR("Couldn't contact xenstore"); - exit(1); - } -- if (!(path = strdup("/local/domain/0/device-model/"))) { -- PERROR("can't get domain path in store"); -+ -+ ret = asprintf(&path, "/local/domain/0/device-model/%i/logdirty/ret", domid); -+ if (ret < 0) { -+ ERROR("Couldn't construct xenstore path"); - exit(1); - } -- if (!(path = realloc(path, strlen(path) -- + 10 -- + strlen("/logdirty/cmd") + 1))) { -- PERROR("no memory for constructing xenstore path"); -- exit(1); -- } -- snprintf(path + strlen(path), 11, "%i", domid); -- strcat(path, "/logdirty/"); -- p = path + strlen(path); -- -+ /* Pointer to directory */ -+ dir_p = path + ret - 3; - - /* Watch for qemu's return value */ -- strcpy(p, "ret"); -- if (!xs_watch(xs, path, "qemu-logdirty-ret")) -- { -- ERROR("can't set watch in store (%s)\n", path); -+ if (!xs_watch(xs, path, "qemu-logdirty-ret")) { -+ PERROR("can't set watch in store (%s)", path); - exit(1); - } - -- if (!(cmd_str = strdup( enable == 0 ? "disable" : "enable"))) { -- PERROR("can't get logdirty cmd path in store"); -+ cmd_str = enable ? "enable" : "disable"; -+ -+ /* Tell qemu that we want it to start logging dirty pages to Xen */ -+ strcpy(dir_p, "cmd"); -+ if (!xs_write(xs, XBT_NULL, path, cmd_str, strlen(cmd_str))) { -+ PERROR("can't write to store path (%s)", path); - exit(1); - } - -- /* Tell qemu that we want it to start logging dirty page to Xen */ -- strcpy(p, "cmd"); -- if (!xs_write(xs, XBT_NULL, path, cmd_str, strlen(cmd_str))) { -- PERROR("can't write to store path (%s)\n", path); -- exit(1); -- } -+ /* Restore initial path */ -+ strcpy(dir_p, "ret"); -+ /* Wait a while for qemu to signal that it has serviced logdirty command */ -+ do { -+ tv.tv_sec = 5; -+ tv.tv_usec = 0; -+ FD_ZERO(&fdset); -+ FD_SET(xs_fileno(xs), &fdset); -+ errno = 0; - -- /* Wait a while for qemu to signal that it has service logdirty command */ -- read_again: -- tv.tv_sec = 5; -- tv.tv_usec = 0; -- FD_ZERO(&fdset); -- FD_SET(xs_fileno(xs), &fdset); -- -- if ((select(xs_fileno(xs) + 1, &fdset, NULL, NULL, &tv)) != 1) { -- PERROR("timed out waiting for qemu logdirty response.\n"); -- exit(1); -- } -- -- watch = xs_read_watch(xs, &len); -- free(watch); -- -- strcpy(p, "ret"); -- ret_str = xs_read(xs, XBT_NULL, path, &len); -- if (ret_str == NULL || strcmp(ret_str, cmd_str)) -+ if ((select(xs_fileno(xs) + 1, &fdset, NULL, NULL, &tv)) != 1) { -+ PERROR("timed out waiting for qemu logdirty response."); -+ exit(1); -+ } -+ -+ watch = xs_read_watch(xs, &len); -+ free(watch); -+ -+ ret_str = xs_read(xs, XBT_NULL, path, &len); -+ again = ret_str == NULL || strcmp(ret_str, cmd_str); -+ WPRINTF("Got '%s' from logdirty%s.\n", ret_str, again ? ", retrying" : ""); -+ free(ret_str); - /* Watch fired but value is not yet right */ -- goto read_again; -+ } while (again); - - free(path); -- free(cmd_str); -- free(ret_str); - - return 0; - } diff --git a/xen.migrate.tools-xend_move_assert_to_exception_block.patch b/xen.migrate.tools-xend_move_assert_to_exception_block.patch deleted file mode 100644 index 2fbc591..0000000 --- a/xen.migrate.tools-xend_move_assert_to_exception_block.patch +++ /dev/null @@ -1,43 +0,0 @@ -user: Olaf Hering -date: Thu Mar 28 15:36:02 2013 +0100 -files: tools/python/xen/xend/XendCheckpoint.py -description: -tools/xend: move assert to exception block - -The two assert in restore trigger sometimes after hundreds of -migrations. If they trigger the destination host will not destroy the -newly created, still empty guest. After a second migration attempt to -this host there will be two guets with the same name and uuid. This -situation is poorly handled by the xm tools. -With this change the guest will be destroyed. - -Signed-off-by: Olaf Hering - ---- - tools/python/xen/xend/XendCheckpoint.py | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -Index: xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendCheckpoint.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -@@ -262,9 +262,6 @@ def restore(xd, fd, dominfo = None, paus - store_port = dominfo.getStorePort() - console_port = dominfo.getConsolePort() - -- assert store_port -- assert console_port -- - # if hvm, pass mem size to calculate the store_mfn - if is_hvm: - apic = int(dominfo.info['platform'].get('apic', 0)) -@@ -276,6 +273,9 @@ def restore(xd, fd, dominfo = None, paus - pae = 0 - - try: -+ assert store_port -+ assert console_port -+ - restore_image = image.create(dominfo, dominfo.info) - memory = restore_image.getRequiredAvailableMemory( - dominfo.info['memory_dynamic_max'] / 1024) diff --git a/xen.migrate.tools_add_xm_migrate_--log_progress_option.patch b/xen.migrate.tools_add_xm_migrate_--log_progress_option.patch deleted file mode 100644 index d7a9426..0000000 --- a/xen.migrate.tools_add_xm_migrate_--log_progress_option.patch +++ /dev/null @@ -1,138 +0,0 @@ -user: Olaf Hering -date: Wed Mar 06 17:05:15 2013 +0100 -files: tools/libxc/xenguest.h tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/migrate.py tools/xcutils/xc_save.c -description: -tools: add xm migrate --log_progress option - -xc_domain_save does print progress messages. These verbose messages are -disabled per default to avoid flood in xend.log. Sometimes it is helpful -to see progress when migrating large and busy guests. So add a new -option to xm migrate to actually enable the printing of progress -messsages. - -xl migrate is not modified with this change because it does not use the -stdio logger. - -Signed-off-by: Olaf Hering - - -diff -r 29c66a248f5b -r d8ef4a83760f tools/libxc/xenguest.h ---- a/tools/libxc/xenguest.h -+++ b/tools/libxc/xenguest.h -@@ -29,6 +29,7 @@ - #define XCFLAGS_STDVGA (1 << 3) - #define XCFLAGS_CHECKPOINT_COMPRESS (1 << 4) - #define XCFLAGS_DOMSAVE_ABORT_IF_BUSY (1 << 5) -+#define XCFLAGS_PROGRESS (1 << 6) - - #define X86_64_B_SIZE 64 - #define X86_32_B_SIZE 32 -diff -r 29c66a248f5b -r d8ef4a83760f tools/python/xen/xend/XendCheckpoint.py ---- a/tools/python/xen/xend/XendCheckpoint.py -+++ b/tools/python/xen/xend/XendCheckpoint.py -@@ -121,16 +121,19 @@ def save(fd, dominfo, network, live, dst - max_iters = dominfo.info.get('max_iters', "0") - max_factor = dominfo.info.get('max_factor', "0") - abort_if_busy = dominfo.info.get('abort_if_busy', "0") -+ log_save_progress = dominfo.info.get('log_save_progress', "0") - if max_iters == "None": - max_iters = "0" - if max_factor == "None": - max_factor = "0" - if abort_if_busy == "None": - abort_if_busy = "0" -+ if log_save_progress == "None": -+ log_save_progress = "0" - cmd = [xen.util.auxbin.pathTo(XC_SAVE), str(fd), - str(dominfo.getDomid()), - max_iters, max_factor, -- str( int(live) | (int(hvm) << 2) | (int(abort_if_busy) << 5) ) ] -+ str( int(live) | (int(hvm) << 2) | (int(abort_if_busy) << 5) | (int(log_save_progress) << 6) ) ] - log.debug("[xc_save]: %s", string.join(cmd)) - - def saveInputHandler(line, tochild): -diff -r 29c66a248f5b -r d8ef4a83760f tools/python/xen/xend/XendDomain.py ---- a/tools/python/xen/xend/XendDomain.py -+++ b/tools/python/xen/xend/XendDomain.py -@@ -1832,17 +1832,18 @@ class XendDomain: - log.exception(ex) - raise XendError(str(ex)) - -- def domain_migrate_constraints_set(self, domid, max_iters, max_factor, abort_if_busy): -+ def domain_migrate_constraints_set(self, domid, max_iters, max_factor, abort_if_busy, log_save_progress): - """Set the Migrate Constraints of this domain. - @param domid: Domain ID or Name - @param max_iters: Number of iterations before final suspend - @param max_factor: Max amount of memory to transfer before final suspend - @param abort_if_busy: Abort migration instead of doing final suspend -+ @param log_save_progress: Log progress of migrate to xend.log - """ - dominfo = self.domain_lookup_nr(domid) - if not dominfo: - raise XendInvalidDomain(str(domid)) -- dominfo.setMigrateConstraints(max_iters, max_factor, abort_if_busy) -+ dominfo.setMigrateConstraints(max_iters, max_factor, abort_if_busy, log_save_progress) - - def domain_maxmem_set(self, domid, mem): - """Set the memory limit for a domain. -diff -r 29c66a248f5b -r d8ef4a83760f tools/python/xen/xend/XendDomainInfo.py ---- a/tools/python/xen/xend/XendDomainInfo.py -+++ b/tools/python/xen/xend/XendDomainInfo.py -@@ -1459,17 +1459,19 @@ class XendDomainInfo: - pci_conf = self.info['devices'][dev_uuid][1] - return map(pci_dict_to_bdf_str, pci_conf['devs']) - -- def setMigrateConstraints(self, max_iters, max_factor, abort_if_busy): -+ def setMigrateConstraints(self, max_iters, max_factor, abort_if_busy, log_save_progress): - """Set the Migrate Constraints of this domain. - @param max_iters: Number of iterations before final suspend - @param max_factor: Max amount of memory to transfer before final suspend - @param abort_if_busy: Abort migration instead of doing final suspend -+ @param log_save_progress: Log progress of migrate to xend.log - """ - log.debug("Setting migration constraints of domain %s (%s) to '%s' '%s' '%s'.", - self.info['name_label'], str(self.domid), max_iters, max_factor, abort_if_busy) - self.info['max_iters'] = str(max_iters) - self.info['max_factor'] = str(max_factor) - self.info['abort_if_busy'] = str(abort_if_busy) -+ self.info['log_save_progress'] = str(log_save_progress) - - def setMemoryTarget(self, target): - """Set the memory target of this domain. -diff -r 29c66a248f5b -r d8ef4a83760f tools/python/xen/xm/migrate.py ---- a/tools/python/xen/xm/migrate.py -+++ b/tools/python/xen/xm/migrate.py -@@ -67,6 +67,10 @@ gopts.opt('abort_if_busy', short='A', - fn=set_true, default=0, - use="Abort migration instead of doing final suspend.") - -+gopts.opt('log_progress', -+ fn=set_true, default=0, -+ use="Log progress of migration to xend.log") -+ - def help(): - return str(gopts) - -@@ -95,7 +99,8 @@ def main(argv): - server.xend.domain.migrate_constraints_set(dom, - opts.vals.max_iters, - opts.vals.max_factor, -- opts.vals.abort_if_busy) -+ opts.vals.abort_if_busy, -+ opts.vals.log_progress) - server.xend.domain.migrate(dom, dst, opts.vals.live, - opts.vals.port, - opts.vals.node, -diff -r 29c66a248f5b -r d8ef4a83760f tools/xcutils/xc_save.c ---- a/tools/xcutils/xc_save.c -+++ b/tools/xcutils/xc_save.c -@@ -197,7 +197,8 @@ main(int argc, char **argv) - si.suspend_evtchn = -1; - - lvl = si.flags & XCFLAGS_DEBUG ? XTL_DEBUG: XTL_DETAIL; -- lflags = XTL_STDIOSTREAM_SHOW_PID | XTL_STDIOSTREAM_HIDE_PROGRESS; -+ lflags = XTL_STDIOSTREAM_SHOW_PID; -+ lflags |= si.flags & XCFLAGS_PROGRESS ? 0 : XTL_STDIOSTREAM_HIDE_PROGRESS; - l = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr, lvl, lflags); - xch = si.xch = xc_interface_open(l, 0, 0); - if (!si.xch) diff --git a/xen.migrate.tools_set_migration_constraints_from_cmdline.patch b/xen.migrate.tools_set_migration_constraints_from_cmdline.patch deleted file mode 100644 index 44dd5a8..0000000 --- a/xen.migrate.tools_set_migration_constraints_from_cmdline.patch +++ /dev/null @@ -1,232 +0,0 @@ -user: Olaf Hering -date: Wed Mar 06 17:05:14 2013 +0100 -files: docs/man/xl.pod.1 tools/libxc/xc_domain_save.c tools/libxc/xenguest.h tools/libxl/Makefile tools/libxl/libxl.c tools/libxl/libxl.h tools/libxl/libxl_dom.c tools/libxl/libxl_internal.h tools/libxl/libxl_save_callout.c tools/libxl/xl_cmdimpl.c tools/libxl/xl_cmdtable.c tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/migrate.py -description: -tools: set migration constraints from cmdline - -Add new options to xm/xl migrate to control the process of migration. -The intention is to optionally abort the migration if it takes too long -to migrate a busy guest due to the high number of dirty pages. Currently -the guest is suspended to transfer the remaining dirty pages. This -transfer can take too long, which can confuse the guest if its suspended -for too long. - --M Number of iterations before final suspend (default: 30) ---max_iters - --m Max amount of memory to transfer before final suspend (default: 3*RAM) ---max_factor - --A Abort migration instead of doing final suspend. ---abort_if_busy - - - -The changes to libxl change the API, handle LIBXL_API_VERSION == 0x040200. - -TODO: - eventually add also --min_remaining (default value 50) in a seperate patch - -v6: - - update the LIBXL_API_VERSION handling for libxl_domain_suspend - change it to an inline function if LIBXL_API_VERSION is defined to 4.2.0 - - rename libxl_save_properties to libxl_domain_suspend_properties - - rename ->xlflags to ->flags within that struct - -v5: - - adjust libxl_domain_suspend prototype, move flags, max_iters, - max_factor into a new, optional struct libxl_save_properties - - rename XCFLAGS_DOMSAVE_NOSUSPEND to XCFLAGS_DOMSAVE_ABORT_IF_BUSY - - rename LIBXL_SUSPEND_NO_FINAL_SUSPEND to LIBXL_SUSPEND_ABORT_IF_BUSY - - rename variables no_suspend to abort_if_busy - - rename option -N/--no_suspend to -A/--abort_if_busy - - update xl.1, extend description of -A option - -v4: - - update default for no_suspend from None to 0 in XendCheckpoint.py:save - - update logoutput in setMigrateConstraints - - change xm migrate defaults from None to 0 - - add new options to xl.1 - - fix syntax error in XendDomain.py:domain_migrate_constraints_set - - fix xm migrate -N option name to match xl migrate - -v3: - - move logic errors in libxl__domain_suspend and fixed help text in - cmd_table to separate patches - - fix syntax error in XendCheckpoint.py - - really pass max_iters and max_factor in libxl__xc_domain_save - - make libxl_domain_suspend_0x040200 declaration globally visible - - bump libxenlight.so SONAME from 2.0 to 2.1 due to changed - libxl_domain_suspend - -v2: - - use LIBXL_API_VERSION and define libxl_domain_suspend_0x040200 - - fix logic error in min_reached check in xc_domain_save - - add longopts - - update --help text - - correct description of migrate --help text - -Signed-off-by: Olaf Hering - - ---- - tools/libxc/xc_domain_save.c | 13 ++++++++++++- - tools/libxc/xenguest.h | 1 + - tools/python/xen/xend/XendCheckpoint.py | 14 ++++++++++++-- - tools/python/xen/xend/XendDomain.py | 12 ++++++++++++ - tools/python/xen/xend/XendDomainInfo.py | 12 ++++++++++++ - tools/python/xen/xm/migrate.py | 16 ++++++++++++++++ - 6 files changed, 65 insertions(+), 3 deletions(-) - -Index: xen-4.2.1-testing/tools/libxc/xc_domain_save.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxc/xc_domain_save.c -+++ xen-4.2.1-testing/tools/libxc/xc_domain_save.c -@@ -813,6 +813,7 @@ int xc_domain_save(xc_interface *xch, in - int rc = 1, frc, i, j, last_iter = 0, iter = 0; - int live = (flags & XCFLAGS_LIVE); - int debug = (flags & XCFLAGS_DEBUG); -+ int abort_if_busy = (flags & XCFLAGS_DOMSAVE_ABORT_IF_BUSY); - int superpages = !!hvm; - int race = 0, sent_last_iter, skip_this_iter = 0; - unsigned int sent_this_iter = 0; -@@ -1525,10 +1526,20 @@ int xc_domain_save(xc_interface *xch, in - - if ( live ) - { -+ int min_reached = sent_this_iter + skip_this_iter < 50; - if ( (iter >= max_iters) || -- (sent_this_iter+skip_this_iter < 50) || -+ min_reached || - (total_sent > dinfo->p2m_size*max_factor) ) - { -+ if ( !min_reached && abort_if_busy ) -+ { -+ ERROR("Live migration aborted, as requested. (guest too busy?)" -+ " total_sent %lu iter %d, max_iters %u max_factor %u", -+ total_sent, iter, max_iters, max_factor); -+ rc = 1; -+ goto out; -+ } -+ - DPRINTF("Start last iteration\n"); - last_iter = 1; - -Index: xen-4.2.1-testing/tools/libxc/xenguest.h -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxc/xenguest.h -+++ xen-4.2.1-testing/tools/libxc/xenguest.h -@@ -28,6 +28,7 @@ - #define XCFLAGS_HVM (1 << 2) - #define XCFLAGS_STDVGA (1 << 3) - #define XCFLAGS_CHECKPOINT_COMPRESS (1 << 4) -+#define XCFLAGS_DOMSAVE_ABORT_IF_BUSY (1 << 5) - - #define X86_64_B_SIZE 64 - #define X86_32_B_SIZE 32 -Index: xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendCheckpoint.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -@@ -118,9 +118,19 @@ def save(fd, dominfo, network, live, dst - # enabled. Passing "0" simply uses the defaults compiled into - # libxenguest; see the comments and/or code in xc_linux_save() for - # more information. -+ max_iters = dominfo.info.get('max_iters', "0") -+ max_factor = dominfo.info.get('max_factor', "0") -+ abort_if_busy = dominfo.info.get('abort_if_busy', "0") -+ if max_iters == "None": -+ max_iters = "0" -+ if max_factor == "None": -+ max_factor = "0" -+ if abort_if_busy == "None": -+ abort_if_busy = "0" - cmd = [xen.util.auxbin.pathTo(XC_SAVE), str(fd), -- str(dominfo.getDomid()), "0", "0", -- str(int(live) | (int(hvm) << 2)) ] -+ str(dominfo.getDomid()), -+ max_iters, max_factor, -+ str( int(live) | (int(hvm) << 2) | (int(abort_if_busy) << 5) ) ] - log.debug("[xc_save]: %s", string.join(cmd)) - - def saveInputHandler(line, tochild): -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomain.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomain.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomain.py -@@ -1832,6 +1832,18 @@ class XendDomain: - log.exception(ex) - raise XendError(str(ex)) - -+ def domain_migrate_constraints_set(self, domid, max_iters, max_factor, abort_if_busy): -+ """Set the Migrate Constraints of this domain. -+ @param domid: Domain ID or Name -+ @param max_iters: Number of iterations before final suspend -+ @param max_factor: Max amount of memory to transfer before final suspend -+ @param abort_if_busy: Abort migration instead of doing final suspend -+ """ -+ dominfo = self.domain_lookup_nr(domid) -+ if not dominfo: -+ raise XendInvalidDomain(str(domid)) -+ dominfo.setMigrateConstraints(max_iters, max_factor, abort_if_busy) -+ - def domain_maxmem_set(self, domid, mem): - """Set the memory limit for a domain. - -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1459,6 +1459,18 @@ class XendDomainInfo: - pci_conf = self.info['devices'][dev_uuid][1] - return map(pci_dict_to_bdf_str, pci_conf['devs']) - -+ def setMigrateConstraints(self, max_iters, max_factor, abort_if_busy): -+ """Set the Migrate Constraints of this domain. -+ @param max_iters: Number of iterations before final suspend -+ @param max_factor: Max amount of memory to transfer before final suspend -+ @param abort_if_busy: Abort migration instead of doing final suspend -+ """ -+ log.debug("Setting migration constraints of domain %s (%s) to '%s' '%s' '%s'.", -+ self.info['name_label'], str(self.domid), max_iters, max_factor, abort_if_busy) -+ self.info['max_iters'] = str(max_iters) -+ self.info['max_factor'] = str(max_factor) -+ self.info['abort_if_busy'] = str(abort_if_busy) -+ - def setMemoryTarget(self, target): - """Set the memory target of this domain. - @param target: In MiB. -Index: xen-4.2.1-testing/tools/python/xen/xm/migrate.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xm/migrate.py -+++ xen-4.2.1-testing/tools/python/xen/xm/migrate.py -@@ -55,6 +55,18 @@ gopts.opt('change_home_server', short='c - fn=set_true, default=0, - use="Change home server for managed domains.") - -+gopts.opt('max_iters', val='max_iters', -+ fn=set_int, default=0, -+ use="Number of iterations before final suspend (default: 30).") -+ -+gopts.opt('max_factor', val='max_factor', -+ fn=set_int, default=0, -+ use="Max amount of memory to transfer before final suspend (default: 3*RAM).") -+ -+gopts.opt('abort_if_busy', -+ fn=set_true, default=0, -+ use="Abort migration instead of doing final suspend.") -+ - def help(): - return str(gopts) - -@@ -80,6 +92,10 @@ def main(argv): - server.xenapi.VM.migrate(vm_ref, dst, bool(opts.vals.live), - other_config) - else: -+ server.xend.domain.migrate_constraints_set(dom, -+ opts.vals.max_iters, -+ opts.vals.max_factor, -+ opts.vals.abort_if_busy) - server.xend.domain.migrate(dom, dst, opts.vals.live, - opts.vals.port, - opts.vals.node, diff --git a/xen.migrate.tools_set_number_of_dirty_pages_during_migration.patch b/xen.migrate.tools_set_number_of_dirty_pages_during_migration.patch deleted file mode 100644 index 4631775..0000000 --- a/xen.migrate.tools_set_number_of_dirty_pages_during_migration.patch +++ /dev/null @@ -1,283 +0,0 @@ -user: Olaf Hering -date: Thu Mar 28 15:42:14 2013 +0100 -files: docs/man/xl.pod.1 tools/libxc/Makefile tools/libxc/xc_domain_save.c tools/libxc/xc_nomigrate.c tools/libxc/xenguest.h tools/libxl/libxl.c tools/libxl/libxl.h tools/libxl/libxl_internal.h tools/libxl/libxl_save_callout.c tools/libxl/libxl_save_helper.c tools/libxl/xl_cmdimpl.c tools/libxl/xl_cmdtable.c tools/python/xen/lowlevel/checkpoint/libcheckpoint.c tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/migrate.py tools/xcutils/xc_save.c -description: -tools: set number of dirty pages during migration - -If a guest is really busy it will not reach the low number of remaining -50 dirty pages for the final suspend. As a result the guest is either -suspendend for a long time during the final transfer, or if the number -of iterations is increased the migration will take a long time. - -Add a new option xm/xl migrate --min_remaing to increase the -default from command line. The default of 50 is 200kb, which is -appearently an arbitrary number. With todays network speeds a larger -block of memory can be transfered quickly without causing too much -suspension time. This knob gives the admin the chance to adapt the -suspension time to the given workload. - -The existing default of 50 pages is not altered by this change. - -Signed-off-by: Olaf Hering - - ---- - tools/libxc/ia64/xc_ia64_linux_save.c | 2 +- - tools/libxc/xc_domain_save.c | 6 ++++-- - tools/libxc/xc_nomigrate.c | 2 +- - tools/libxc/xenguest.h | 2 +- - tools/libxl/libxl_save_helper.c | 2 +- - tools/python/xen/lowlevel/checkpoint/libcheckpoint.c | 2 +- - tools/python/xen/xend/XendCheckpoint.py | 5 ++++- - tools/python/xen/xend/XendDomain.py | 5 +++-- - tools/python/xen/xend/XendDomainInfo.py | 8 +++++--- - tools/python/xen/xm/migrate.py | 5 +++++ - tools/xcutils/xc_save.c | 11 ++++++----- - 11 files changed, 32 insertions(+), 18 deletions(-) - -Index: xen-4.2.1-testing/tools/libxc/ia64/xc_ia64_linux_save.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxc/ia64/xc_ia64_linux_save.c -+++ xen-4.2.1-testing/tools/libxc/ia64/xc_ia64_linux_save.c -@@ -381,7 +381,7 @@ out: - - int - xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters, -- uint32_t max_factor, uint32_t flags, -+ uint32_t max_factor, uint32_t min_remaining, uint32_t flags, - struct save_callbacks* callbacks, int hvm, - unsigned long vm_generationid_addr) - { -Index: xen-4.2.1-testing/tools/libxc/xc_domain_save.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxc/xc_domain_save.c -+++ xen-4.2.1-testing/tools/libxc/xc_domain_save.c -@@ -43,6 +43,7 @@ - */ - #define DEF_MAX_ITERS 29 /* limit us to 30 times round loop */ - #define DEF_MAX_FACTOR 3 /* never send more than 3x p2m_size */ -+#define DEF_MIN_REMAINING 50 /* low water mark of dirty pages */ - - struct save_ctx { - unsigned long hvirt_start; /* virtual starting address of the hypervisor */ -@@ -803,7 +804,7 @@ static int save_tsc_info(xc_interface *x - } - - int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters, -- uint32_t max_factor, uint32_t flags, -+ uint32_t max_factor, uint32_t min_remaining, uint32_t flags, - struct save_callbacks* callbacks, int hvm, - unsigned long vm_generationid_addr) - { -@@ -914,6 +915,7 @@ int xc_domain_save(xc_interface *xch, in - /* If no explicit control parameters given, use defaults */ - max_iters = max_iters ? : DEF_MAX_ITERS; - max_factor = max_factor ? : DEF_MAX_FACTOR; -+ min_remaining = min_remaining ? : DEF_MIN_REMAINING; - - if ( !get_platform_info(xch, dom, - &ctx->max_mfn, &ctx->hvirt_start, &ctx->pt_levels, &dinfo->guest_width) ) -@@ -1526,7 +1528,7 @@ int xc_domain_save(xc_interface *xch, in - - if ( live ) - { -- int min_reached = sent_this_iter + skip_this_iter < 50; -+ int min_reached = sent_this_iter + skip_this_iter < min_remaining; - if ( (iter >= max_iters) || - min_reached || - (total_sent > dinfo->p2m_size*max_factor) ) -Index: xen-4.2.1-testing/tools/libxc/xc_nomigrate.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxc/xc_nomigrate.c -+++ xen-4.2.1-testing/tools/libxc/xc_nomigrate.c -@@ -22,7 +22,7 @@ - #include - - int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters, -- uint32_t max_factor, uint32_t flags, -+ uint32_t max_factor, uint32_t min_remaining, uint32_t flags, - struct save_callbacks* callbacks, int hvm, - unsigned long vm_generationid_addr) - { -Index: xen-4.2.1-testing/tools/libxc/xenguest.h -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxc/xenguest.h -+++ xen-4.2.1-testing/tools/libxc/xenguest.h -@@ -87,7 +87,7 @@ struct save_callbacks { - * @return 0 on success, -1 on failure - */ - int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iters, -- uint32_t max_factor, uint32_t flags /* XCFLAGS_xxx */, -+ uint32_t max_factor, uint32_t min_remaining, uint32_t flags /* XCFLAGS_xxx */, - struct save_callbacks* callbacks, int hvm, - unsigned long vm_generationid_addr); - -Index: xen-4.2.1-testing/tools/libxl/libxl_save_helper.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/libxl/libxl_save_helper.c -+++ xen-4.2.1-testing/tools/libxl/libxl_save_helper.c -@@ -235,7 +235,7 @@ int main(int argc, char **argv) - helper_setcallbacks_save(&helper_save_callbacks, cbflags); - - startup("save"); -- r = xc_domain_save(xch, io_fd, dom, max_iters, max_factor, flags, -+ r = xc_domain_save(xch, io_fd, dom, max_iters, max_factor, 0, flags, - &helper_save_callbacks, hvm, genidad); - complete(r); - -Index: xen-4.2.1-testing/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c -+++ xen-4.2.1-testing/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c -@@ -206,7 +206,7 @@ int checkpoint_start(checkpoint_state* s - - callbacks->switch_qemu_logdirty = noop_switch_logdirty; - -- rc = xc_domain_save(s->xch, fd, s->domid, 0, 0, flags, callbacks, hvm, -+ rc = xc_domain_save(s->xch, fd, s->domid, 0, 0, 0, flags, callbacks, hvm, - vm_generationid_addr); - - if (hvm) -Index: xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendCheckpoint.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -@@ -120,19 +120,22 @@ def save(fd, dominfo, network, live, dst - # more information. - max_iters = dominfo.info.get('max_iters', "0") - max_factor = dominfo.info.get('max_factor', "0") -+ min_remaining = dominfo.info.get('min_remaining', "0") - abort_if_busy = dominfo.info.get('abort_if_busy', "0") - log_save_progress = dominfo.info.get('log_save_progress', "0") - if max_iters == "None": - max_iters = "0" - if max_factor == "None": - max_factor = "0" -+ if min_remaining == "None": -+ min_remaining = "0" - if abort_if_busy == "None": - abort_if_busy = "0" - if log_save_progress == "None": - log_save_progress = "0" - cmd = [xen.util.auxbin.pathTo(XC_SAVE), str(fd), - str(dominfo.getDomid()), -- max_iters, max_factor, -+ max_iters, max_factor, min_remaining, - str( int(live) | (int(hvm) << 2) | (int(abort_if_busy) << 5) | (int(log_save_progress) << 6) ) ] - log.debug("[xc_save]: %s", string.join(cmd)) - -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomain.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomain.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomain.py -@@ -1832,18 +1832,19 @@ class XendDomain: - log.exception(ex) - raise XendError(str(ex)) - -- def domain_migrate_constraints_set(self, domid, max_iters, max_factor, abort_if_busy, log_save_progress): -+ def domain_migrate_constraints_set(self, domid, max_iters, max_factor, min_remaining, abort_if_busy, log_save_progress): - """Set the Migrate Constraints of this domain. - @param domid: Domain ID or Name - @param max_iters: Number of iterations before final suspend - @param max_factor: Max amount of memory to transfer before final suspend -+ @param min_remaining: Number of dirty pages before final suspend - @param abort_if_busy: Abort migration instead of doing final suspend - @param log_save_progress: Log progress of migrate to xend.log - """ - dominfo = self.domain_lookup_nr(domid) - if not dominfo: - raise XendInvalidDomain(str(domid)) -- dominfo.setMigrateConstraints(max_iters, max_factor, abort_if_busy, log_save_progress) -+ dominfo.setMigrateConstraints(max_iters, max_factor, min_remaining, abort_if_busy, log_save_progress) - - def domain_maxmem_set(self, domid, mem): - """Set the memory limit for a domain. -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1459,17 +1459,19 @@ class XendDomainInfo: - pci_conf = self.info['devices'][dev_uuid][1] - return map(pci_dict_to_bdf_str, pci_conf['devs']) - -- def setMigrateConstraints(self, max_iters, max_factor, abort_if_busy, log_save_progress): -+ def setMigrateConstraints(self, max_iters, max_factor, min_remaining, abort_if_busy, log_save_progress): - """Set the Migrate Constraints of this domain. - @param max_iters: Number of iterations before final suspend - @param max_factor: Max amount of memory to transfer before final suspend -+ @param min_remaining: Number of dirty pages before final suspend - @param abort_if_busy: Abort migration instead of doing final suspend - @param log_save_progress: Log progress of migrate to xend.log - """ -- log.debug("Setting migration constraints of domain %s (%s) to '%s' '%s' '%s'.", -- self.info['name_label'], str(self.domid), max_iters, max_factor, abort_if_busy) -+ log.debug("Setting migration constraints of domain %s (%s) to '%s' '%s' '%s' '%s'.", -+ self.info['name_label'], str(self.domid), max_iters, max_factor, min_remaining, abort_if_busy) - self.info['max_iters'] = str(max_iters) - self.info['max_factor'] = str(max_factor) -+ self.info['min_remaining'] = str(min_remaining) - self.info['abort_if_busy'] = str(abort_if_busy) - self.info['log_save_progress'] = str(log_save_progress) - -Index: xen-4.2.1-testing/tools/python/xen/xm/migrate.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xm/migrate.py -+++ xen-4.2.1-testing/tools/python/xen/xm/migrate.py -@@ -63,6 +63,10 @@ gopts.opt('max_factor', val='max_factor' - fn=set_int, default=0, - use="Max amount of memory to transfer before final suspend (default: 3*RAM).") - -+gopts.opt('min_remaining', val='min_remaining', -+ fn=set_int, default=0, -+ use="Number of dirty pages before final suspend (default: 50).") -+ - gopts.opt('abort_if_busy', - fn=set_true, default=0, - use="Abort migration instead of doing final suspend.") -@@ -99,6 +103,7 @@ def main(argv): - server.xend.domain.migrate_constraints_set(dom, - opts.vals.max_iters, - opts.vals.max_factor, -+ opts.vals.min_remaining, - opts.vals.abort_if_busy, - opts.vals.log_progress) - server.xend.domain.migrate(dom, dst, opts.vals.live, -Index: xen-4.2.1-testing/tools/xcutils/xc_save.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/xcutils/xc_save.c -+++ xen-4.2.1-testing/tools/xcutils/xc_save.c -@@ -179,20 +179,21 @@ int - main(int argc, char **argv) - { - xc_interface *xch; -- unsigned int maxit, max_f, lflags; -+ unsigned int maxit, max_f, min_r, lflags; - int io_fd, ret, port; - struct save_callbacks callbacks; - xentoollog_level lvl; - xentoollog_logger *l; - -- if (argc != 6) -- errx(1, "usage: %s iofd domid maxit maxf flags", argv[0]); -+ if (argc != 7) -+ errx(1, "usage: %s iofd domid maxit maxf minr flags", argv[0]); - - io_fd = atoi(argv[1]); - si.domid = atoi(argv[2]); - maxit = atoi(argv[3]); - max_f = atoi(argv[4]); -- si.flags = atoi(argv[5]); -+ min_r = atoi(argv[5]); -+ si.flags = atoi(argv[6]); - - si.suspend_evtchn = -1; - -@@ -226,7 +227,7 @@ main(int argc, char **argv) - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.suspend = suspend; - callbacks.switch_qemu_logdirty = switch_qemu_logdirty; -- ret = xc_domain_save(si.xch, io_fd, si.domid, maxit, max_f, si.flags, -+ ret = xc_domain_save(si.xch, io_fd, si.domid, maxit, max_f, min_r, si.flags, - &callbacks, !!(si.flags & XCFLAGS_HVM), 0); - - if (si.suspend_evtchn > 0) diff --git a/xen.spec b/xen.spec index 03e8321..8a3601c 100644 --- a/xen.spec +++ b/xen.spec @@ -18,11 +18,11 @@ Name: xen ExclusiveArch: %ix86 x86_64 -%define xvers 4.2 +%define xvers 4.3 %define xvermaj 4 -%define changeset 26064 -%define xen_build_dir xen-4.2.2-testing -%define with_kmp 1 +%define changeset 27068 +%define xen_build_dir xen-4.3.0-testing +%define with_kmp 0 %define with_stubdom 1 # EFI requires gcc46 or newer # its available in 12.1 or >= sles11sp2 @@ -37,8 +37,8 @@ ExclusiveArch: %ix86 x86_64 %define with_dom0_support 0 %endif %define _fwdefdir /etc/sysconfig/SuSEfirewall2.d/services -%if %suse_version > 1140 -%define with_xend 1 +%if %suse_version >= 1230 +%define with_xend 0 %else %define with_xend 1 %endif @@ -54,6 +54,7 @@ BuildRequires: graphviz BuildRequires: latex2html BuildRequires: libbz2-devel BuildRequires: libjpeg-devel +BuildRequires: libpixman-1-0-devel BuildRequires: libuuid-devel BuildRequires: libxml2-devel BuildRequires: libyajl-devel @@ -119,13 +120,13 @@ BuildRequires: xorg-x11 BuildRequires: lndir %endif %endif -Version: 4.2.2_01 +Version: 4.3.0_02 Release: 0 PreReq: %insserv_prereq %fillup_prereq Summary: Xen Virtualization: Hypervisor (aka VMM aka Microkernel) License: GPL-2.0+ Group: System/Kernel -Source0: xen-4.2.2-testing-src.tar.bz2 +Source0: xen-4.3.0-testing-src.tar.bz2 Source1: stubdom.tar.bz2 Source2: qemu-xen-traditional-dir-remote.tar.bz2 Source3: qemu-xen-dir-remote.tar.bz2 @@ -169,208 +170,50 @@ Source99: baselibs.conf # http://xenbits.xensource.com/ext/xenalyze Source20000: xenalyze.hg.tar.bz2 # Upstream patches -Patch25861: 25861-x86-early-fixmap.patch -Patch25862: 25862-sercon-non-com.patch -Patch25863: 25863-sercon-ehci-dbgp.patch -Patch25864: 25864-sercon-unused.patch -Patch25866: 25866-sercon-ns16550-pci-irq.patch -Patch25867: 25867-sercon-ns16550-parse.patch -Patch25874: 25874-x86-EFI-chain-cfg.patch -Patch25909: 25909-xenpm-consistent.patch -Patch25920: 25920-x86-APICV-enable.patch -Patch25921: 25921-x86-APICV-delivery.patch -Patch25922: 25922-x86-APICV-x2APIC.patch -Patch25952: 25952-x86-MMIO-remap-permissions.patch -Patch25957: 25957-x86-TSC-adjust-HVM.patch -Patch25958: 25958-x86-TSC-adjust-sr.patch -Patch25959: 25959-x86-TSC-adjust-expose.patch -Patch25975: 25975-x86-IvyBridge.patch -Patch26077: 26077-stubdom_fix_compile_errors_in_grub.patch -Patch26078: 26078-hotplug-Linux_remove_hotplug_support_rely_on_udev_instead.patch -Patch26079: 26079-hotplug-Linux_close_lockfd_after_lock_attempt.patch -Patch26081: 26081-stubdom_fix_rpmlint_warning_spurious-executable-perm.patch -Patch26082: 26082-blktap2-libvhd_fix_rpmlint_warning_spurious-executable-perm.patch -Patch26083: 26083-blktap_fix_rpmlint_warning_spurious-executable-perm.patch -Patch26084: 26084-hotplug_install_hotplugpath.sh_as_data_file.patch -Patch26085: 26085-stubdom_install_stubdompath.sh_as_data_file.patch -Patch26086: 26086-hotplug-Linux_correct_sysconfig_tag_in_xendomains.patch -Patch26087: 26087-hotplug-Linux_install_sysconfig_files_as_data_files.patch -Patch26114: 26114-pygrub-list-entries.patch -Patch26129: 26129-ACPI-BGRT-invalidate.patch -Patch26133: 26133-IOMMU-defer-BM-disable.patch -Patch26189: 26189-xenstore-chmod.patch -Patch26262: 26262-x86-EFI-secure-shim.patch -Patch26324: 26324-IOMMU-assign-params.patch -Patch26325: 26325-IOMMU-add-remove-params.patch -Patch26326: 26326-VT-d-context-map-params.patch -Patch26327: 26327-AMD-IOMMU-flush-params.patch -Patch26328: 26328-IOMMU-pdev-type.patch -Patch26329: 26329-IOMMU-phantom-dev.patch -Patch26330: 26330-VT-d-phantom-MSI.patch -Patch26331: 26331-IOMMU-phantom-dev-quirk.patch -Patch26341: 26341-hvm-firmware-passthrough.patch -Patch26342: 26342-hvm-firmware-passthrough.patch -Patch26343: 26343-hvm-firmware-passthrough.patch -Patch26344: 26344-hvm-firmware-passthrough.patch -Patch26369: 26369-libxl-devid.patch -Patch26370: 26370-libxc-x86-initial-mapping-fit.patch -Patch26372: 26372-tools-paths.patch -Patch26404: 26404-x86-forward-both-NMI-kinds.patch -Patch26418: 26418-x86-trampoline-consider-multiboot.patch -Patch26532: 26532-AMD-IOMMU-phantom-MSI.patch -Patch26547: 26547-tools-xc_fix_logic_error_in_stdiostream_progress.patch -Patch26548: 26548-tools-xc_handle_tty_output_differently_in_stdiostream_progress.patch -Patch26549: 26549-tools-xc_turn_XCFLAGS__into_shifts.patch -Patch26550: 26550-tools-xc_restore_logging_in_xc_save.patch -Patch26551: 26551-tools-xc_log_pid_in_xc_save-xc_restore_output.patch -Patch26554: 26554-hvm-firmware-passthrough.patch -Patch26555: 26555-hvm-firmware-passthrough.patch -Patch26556: 26556-hvm-firmware-passthrough.patch -Patch26576: 26576-x86-APICV-migration.patch -Patch26577: 26577-x86-APICV-x2APIC.patch -Patch26675: 26675-tools-xentoollog_update_tty_detection_in_stdiostream_progress.patch -Patch26891: 26891-x86-S3-Fix-cpu-pool-scheduling-after-suspend-resume.patch -Patch26902: 26902-x86-EFI-pass-boot-services-variable-info-to-runtime-code.patch -Patch26930: 26930-x86-EFI-fix-runtime-call-status-for-compat-mode-Dom0.patch -Patch4501: CVE-2013-1918-xsa45-1-vcpu-destroy-pagetables-preemptible.patch -Patch4502: CVE-2013-1918-xsa45-2-new-guest-cr3-preemptible.patch -Patch4503: CVE-2013-1918-xsa45-3-new-user-base-preemptible.patch -Patch4504: CVE-2013-1918-xsa45-4-vcpu-reset-preemptible.patch -Patch4505: CVE-2013-1918-xsa45-5-set-info-guest-preemptible.patch -Patch4506: CVE-2013-1918-xsa45-6-unpin-preemptible.patch -Patch4507: CVE-2013-1918-xsa45-7-mm-error-paths-preemptible.patch -Patch4508: CVE-2013-1918-xsa45-followup.patch -Patch48: CVE-2013-1922-xsa48.patch -Patch49: CVE-2013-1952-xsa49.patch -Patch88: xen.migrate.tools-xc_print_messages_from_xc_save_with_xc_report.patch -Patch89: xen.migrate.tools-xc_document_printf_calls_in_xc_restore.patch -Patch90: xen.migrate.tools-xc_rework_xc_save.cswitch_qemu_logdirty.patch -Patch91: xen.migrate.tools_set_migration_constraints_from_cmdline.patch -Patch92: xen.migrate.tools_add_xm_migrate_--log_progress_option.patch -Patch93: xen.migrate.tools-xend_move_assert_to_exception_block.patch -Patch94: xen.migrate.tools-libxc_print_stats_if_migration_is_aborted.patch -Patch95: xen.migrate.tools_set_number_of_dirty_pages_during_migration.patch # Upstream qemu patches -Patch100: VNC-Support-for-ExtendedKeyEvent-client-message.patch # Our patches -Patch301: xend-config.diff -Patch302: xen-destdir.diff -Patch304: xen-changeset.diff -Patch305: xen-paths.diff -Patch306: xen-xmexample.diff -Patch307: xen-xmexample-vti.diff -Patch310: xen-fixme-doc.diff -Patch311: xen-domUloader.diff -Patch312: xen-no-dummy-nfs-ip.diff -Patch313: serial-split.patch -Patch314: xen-xm-top-needs-root.diff -Patch315: xen-max-free-mem.diff -Patch322: bridge-opensuse.patch -Patch323: bridge-vlan.diff -Patch324: bridge-bonding.diff -Patch325: bridge-record-creation.patch -Patch327: udev-rules.patch -Patch328: vif-route-ifup.patch -Patch329: network-nat-open-SuSEfirewall2-FORWARD.patch -Patch340: xen-hvm-default-bridge.diff -Patch341: xen-hvm-default-pae.diff -Patch342: libxen_permissive.patch -Patch343: xenapi-console-protocol.patch -Patch344: xen-disable-qemu-monitor.diff -Patch345: qemu-security-etch1.diff -Patch350: cdrom-removable.patch -Patch351: xend-core-dump-loc.diff -Patch352: blktap.patch -Patch353: xen-api-auth.patch -Patch354: xen-qemu-iscsi-fix.patch -Patch355: ioemu-vnc-resize.patch -Patch356: ioemu-debuginfo.patch -Patch357: vif-bridge-no-iptables.patch -Patch358: xenconsole-no-multiple-connections.patch +Patch301: xen-destdir.patch +Patch302: xen-changeset.patch +Patch303: xen-xmexample.patch +Patch304: xen-xmexample-vti.patch +Patch310: bridge-opensuse.patch +Patch311: bridge-vlan.patch +Patch312: bridge-bonding.patch +Patch313: bridge-record-creation.patch +Patch314: vif-bridge-no-iptables.patch +Patch315: vif-bridge-tap-fix.patch +Patch320: network-nat-open-SuSEfirewall2-FORWARD.patch +Patch321: udev-rules.patch +Patch322: libxen_permissive.patch +Patch323: xenconsole-no-multiple-connections.patch # Needs to go upstream -Patch370: checkpoint-rename.patch -Patch371: xm-save-check-file.patch -Patch372: xm-create-xflag.patch -Patch373: xend-sysconfig.patch -Patch374: domu-usb-controller.patch -Patch375: usb-list.patch -Patch376: xend-devid-or-name.patch -Patch377: suspend_evtchn_lock.patch -Patch378: log-guest-console.patch -Patch379: xend-migration-domname-fix.patch -Patch380: xm-create-maxmem.patch -Patch381: vif-bridge-tap-fix.patch -Patch382: xend-cpuid.patch -# ioemu part of blktap patch series -Patch410: ioemu-blktap-fv-init.patch -Patch411: ioemu-blktap-image-format.patch -Patch412: build-tapdisk-ioemu.patch -Patch413: tapdisk-ioemu-logfile.patch -Patch414: ioemu-blktap-zero-size.patch -Patch415: tapdisk-ioemu-shutdown-fix.patch -Patch420: blktapctrl-default-to-ioemu.patch -Patch421: ioemu-blktap-barriers.patch +Patch330: xend-sysconfig.patch +Patch331: suspend_evtchn_lock.patch +Patch332: xenpaging.doc.patch # Other bug fixes or features -Patch423: bdrv_open2_fix_flags.patch -Patch424: bdrv_open2_flags_2.patch -Patch425: ioemu-bdrv-open-CACHE_WB.patch -Patch426: ioemu-7615-qcow2-fix-alloc_cluster_link_l2.patch -Patch427: xen-ioemu-hvm-pv-support.diff -Patch428: qemu-dm-segfault.patch -Patch429: hibernate.patch -Patch430: del_usb_xend_entry.patch -Patch431: capslock_enable.patch -Patch433: multi-xvdp.patch -Patch434: check_device_status.patch -Patch435: change_home_server.patch -Patch436: altgr_2.patch -Patch438: stdvga-cache.patch -Patch439: minios-fixups.patch -Patch440: bdrv_default_rwflag.patch -Patch442: xen-minimum-restart-time.patch -Patch446: xend-disable-internal-logrotate.patch -Patch447: xend-config-enable-dump-comment.patch -Patch448: change-vnc-passwd.patch -Patch449: kernel-boot-hvm.patch -Patch450: ioemu-watchdog-support.patch -Patch451: ioemu-watchdog-linkage.patch -Patch452: ioemu-watchdog-ib700-timer.patch -Patch453: tools-watchdog-support.patch -Patch454: xend-console-port-restore.patch -Patch456: xend-vcpu-affinity-fix.patch -Patch457: xen-cpupool-xl-config-format.patch -Patch458: ipxe-enable-nics.patch -Patch459: blktap-close-fifos.patch -Patch460: blktap-disable-debug-printf.patch -Patch461: xen-migration-bridge-check.patch -Patch462: pygrub-netware-xnloader.patch -Patch463: xen-managed-pci-device.patch -Patch464: xend-hvm-firmware-passthrough.patch -Patch465: xend-cpuinfo-model-name.patch -Patch466: xen-glibc217.patch -# Jim's domain lock patch -Patch480: xend-domain-lock.patch -Patch481: xend-domain-lock-sfex.patch +Patch350: hibernate.patch +Patch351: stdvga-cache.patch +Patch352: minios-fixups.patch +Patch353: ipxe-enable-nics.patch +Patch354: pygrub-netware-xnloader.patch +Patch360: blktapctrl-close-fifos.patch +Patch361: blktapctrl-default-to-ioemu.patch +Patch362: blktapctrl-disable-debug-printf.patch +Patch363: blktap-pv-cdrom.patch # Hypervisor and PV driver Patches -Patch500: 32on64-extra-mem.patch Patch501: x86-ioapic-ack-default.patch Patch502: x86-cpufreq-report.patch Patch503: x86-dom-print.patch -Patch504: pvdrv-import-shared-info.patch -Patch505: x86-extra-trap-info.patch -Patch506: pvdrv_emulation_control.patch -Patch507: blktap-pv-cdrom.patch -Patch511: supported_module.diff -Patch512: magic_ioport_compat.patch -Patch513: xen.sles11sp1.fate311487.xen_platform_pci.dmistring.patch -Patch650: disable_emulated_device.diff -Patch651: ioemu-disable-scsi.patch -Patch652: ioemu-disable-emulated-ide-if-pv.patch -Patch700: hv_extid_compatibility.patch -Patch800: xenpaging.autostart.patch -Patch801: xenpaging.doc.patch -Patch802: xenpaging.qemu.flush-cache.patch -# Build patch +Patch504: x86-extra-trap-info.patch +Patch520: supported_module.patch +Patch521: pvdrv-import-shared-info.patch +Patch522: magic_ioport_compat.patch +Patch523: xen.sles11sp1.fate311487.xen_platform_pci.dmistring.patch +Patch524: disable_emulated_device.patch +# Legacy Xend and Qemu patches +Patch800: xend-traditional-qemu.patch +# Build patches +Patch99997: disable-wget-check.patch Patch99998: tmp-initscript-modprobe.patch Patch99999: tmp_build.patch Url: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/ @@ -437,7 +280,6 @@ Authors: %package libs Summary: Xen Virtualization: Libraries Group: System/Kernel -#Requires: xen = %{version} %description libs Xen is a virtual machine monitor for x86 that supports execution of @@ -499,6 +341,7 @@ Requires: xen-libs = %{version} # subpackage existed in 10.3 Provides: xen-tools-ioemu = %{version} Obsoletes: xen-tools-ioemu < %{version} +Conflicts: libvirt < 1.0.5 %description tools Xen is a virtual machine monitor for x86 that supports execution of @@ -541,6 +384,35 @@ In addition to this package you need to install kernel-xen and xen to use Xen. +Authors: +-------- + Ian Pratt + + +%package xend-tools +Summary: Xen Virtualization: Control tools for domain 0 +Group: System/Kernel +Requires: python +Requires: python-curses +Requires: python-lxml +Requires: python-openssl +Requires: python-pam +Requires: python-xml +Requires: xen-tools +Conflicts: libvirt < 1.0.5 + +%description xend-tools +Xen is a virtual machine monitor for x86 that supports execution of +multiple guest operating systems with unprecedented levels of +performance and resource isolation. + +This sub-package contains the control tools that allow you to start, +stop, migrate, and manage virtual machines using the legacy xend +toolstack. + +In addition to this package you need to install kernel-xen and xen to +use Xen. + Authors: -------- @@ -708,202 +580,45 @@ Authors %setup -q -n %xen_build_dir -a 1 -a 2 -a 3 -a 4 -a 5 -a 20000 tar xfj %{SOURCE6} -C $RPM_BUILD_DIR/%{xen_build_dir}/tools # Upstream patches -%patch25861 -p1 -%patch25862 -p1 -%patch25863 -p1 -%patch25864 -p1 -%patch25866 -p1 -%patch25867 -p1 -%patch25874 -p1 -%patch25909 -p1 -%patch25920 -p1 -%patch25921 -p1 -%patch25922 -p1 -%patch25952 -p1 -%patch25957 -p1 -%patch25958 -p1 -%patch25959 -p1 -%patch25975 -p1 -%patch26077 -p1 -%patch26078 -p1 -%patch26079 -p1 -%patch26081 -p1 -%patch26082 -p1 -%patch26083 -p1 -%patch26084 -p1 -%patch26085 -p1 -%patch26086 -p1 -%patch26087 -p1 -%patch26114 -p1 -%patch26129 -p1 -%patch26133 -p1 -%patch26189 -p1 -%patch26262 -p1 -%patch26324 -p1 -%patch26325 -p1 -%patch26326 -p1 -%patch26327 -p1 -%patch26328 -p1 -%patch26329 -p1 -%patch26330 -p1 -%patch26331 -p1 -%patch26341 -p1 -%patch26342 -p1 -%patch26343 -p1 -%patch26344 -p1 -%patch26369 -p1 -%patch26370 -p1 -%patch26372 -p1 -%patch26404 -p1 -%patch26418 -p1 -%patch26532 -p1 -%patch26547 -p1 -%patch26548 -p1 -%patch26549 -p1 -%patch26550 -p1 -%patch26551 -p1 -%patch26554 -p1 -%patch26555 -p1 -%patch26556 -p1 -%patch26576 -p1 -%patch26577 -p1 -%patch26675 -p1 -%patch26891 -p1 -%patch26902 -p1 -%patch26930 -p1 -%patch4501 -p1 -%patch4502 -p1 -%patch4503 -p1 -%patch4504 -p1 -%patch4505 -p1 -%patch4506 -p1 -%patch4507 -p1 -%patch4508 -p1 -%patch48 -p1 -%patch49 -p1 -%patch88 -p1 -%patch89 -p1 -%patch90 -p1 -%patch91 -p1 -%patch92 -p1 -%patch93 -p1 -%patch94 -p1 -%patch95 -p1 # Qemu -%patch100 -p1 # Our patches %patch301 -p1 %patch302 -p1 +%patch303 -p1 %patch304 -p1 -%patch305 -p1 -%patch306 -p1 -%patch307 -p1 %patch310 -p1 %patch311 -p1 %patch312 -p1 %patch313 -p1 %patch314 -p1 %patch315 -p1 +%patch320 -p1 +%patch321 -p1 %patch322 -p1 %patch323 -p1 -%patch324 -p1 -%patch325 -p1 -%patch327 -p1 -%patch328 -p1 -%patch329 -p1 -%patch340 -p1 -%patch341 -p1 -%patch342 -p1 -%patch343 -p1 -%patch344 -p1 -%patch345 -p1 +%patch330 -p1 +%patch331 -p1 +%patch332 -p1 %patch350 -p1 %patch351 -p1 %patch352 -p1 %patch353 -p1 %patch354 -p1 -%patch355 -p1 -%patch356 -p1 -%patch357 -p1 -%patch358 -p1 -%patch370 -p1 -%patch371 -p1 -%patch372 -p1 -%patch373 -p1 -%patch374 -p1 -%patch375 -p1 -%patch376 -p1 -%patch377 -p1 -%patch378 -p1 -%patch379 -p1 -%patch380 -p1 -%patch381 -p1 -%patch382 -p1 -%patch410 -p1 -%patch411 -p1 -%patch412 -p1 -%patch413 -p1 -%patch414 -p1 -%patch415 -p1 -%patch420 -p1 -%patch421 -p1 -%patch423 -p1 -%patch424 -p1 -%patch425 -p1 -%patch426 -p1 -%patch427 -p1 -%patch428 -p1 -%patch429 -p1 -%patch430 -p1 -%patch431 -p1 -%patch433 -p1 -%patch434 -p1 -%patch435 -p1 -%patch436 -p1 -%patch438 -p1 -%patch439 -p1 -%patch440 -p1 -%patch442 -p1 -%patch446 -p1 -%patch447 -p1 -%patch448 -p1 -%patch449 -p1 -%patch450 -p1 -%patch451 -p1 -%patch452 -p1 -%patch453 -p1 -%patch454 -p1 -%patch456 -p1 -%patch457 -p1 -%patch458 -p1 -%patch459 -p1 -%patch460 -p1 -%patch461 -p1 -%patch462 -p1 -%patch463 -p1 -%patch464 -p1 -%patch465 -p1 -%patch466 -p1 -%patch480 -p1 -%patch481 -p1 -%patch500 -p1 +%patch360 -p1 +%patch361 -p1 +%patch362 -p1 +%patch363 -p1 %patch501 -p1 %patch502 -p1 %patch503 -p1 %patch504 -p1 -%patch505 -p1 -%patch506 -p1 -%patch507 -p1 -%patch511 -p1 -%patch512 -p1 -%patch513 -p1 -%patch650 -p1 -%patch651 -p1 -%patch652 -p1 -%patch700 -p1 +%patch520 -p1 +%patch521 -p1 +%patch522 -p1 +%patch523 -p1 +%patch524 -p1 %patch800 -p1 -%patch801 -p1 -%patch802 -p1 +%patch99997 -p1 %patch99998 -p1 %patch99999 -p1 # tools/qemu-xen-traditional-dir-remote/configure ./tools/qemu-xen-dir-remote/configure use @@ -1001,8 +716,6 @@ export XEN_PYTHON_NATIVE_INSTALL=1 make -C tools install \ DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} %{?_smp_mflags} rm -f $RPM_BUILD_ROOT/usr/sbin/{qcow-create,img2qcow,qcow2raw} -make -C tools/misc/serial-split install \ - DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} %{?_smp_mflags} %ifarch x86_64 mkdir -p $RPM_BUILD_ROOT/${_libdir}/xen/bin/ ln -s /usr/lib/xen/bin/qemu-dm $RPM_BUILD_ROOT/%{_libdir}/xen/bin/qemu-dm @@ -1017,8 +730,6 @@ cp -avL xenalyze.hg/dump-raw $RPM_BUILD_ROOT/%{_bindir}/xenalyze.dump-raw cp -avL xenalyze.hg/xenalyze $RPM_BUILD_ROOT/%{_bindir} %else make -C tools install DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} %{?_smp_mflags} -make -C tools/misc/serial-split install \ - DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} %{?_smp_mflags} %endif # PV driver modules %if %{?with_kmp}0 @@ -1130,12 +841,16 @@ rm -f $RPM_BUILD_ROOT/%{_datadir}/doc/packages/xen/html/hypercall/.deps rm -rf $RPM_BUILD_ROOT/%{_defaultdocdir}/xen/ps rm -rf $RPM_BUILD_ROOT/usr/share/xen/man/man1/qemu/qemu* rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-ppc -rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-sparc32 -rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-sparc64 rm -f $RPM_BUILD_ROOT/usr/share/qemu-xen/openbios-ppc +rm -f $RPM_BUILD_ROOT/usr/share/qemu-xen/qemu/openbios-ppc +rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-sparc32 rm -f $RPM_BUILD_ROOT/usr/share/qemu-xen/openbios-sparc32 +rm -f $RPM_BUILD_ROOT/usr/share/qemu-xen/qemu/openbios-sparc32 +rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-sparc64 rm -f $RPM_BUILD_ROOT/usr/share/qemu-xen/openbios-sparc64 +rm -f $RPM_BUILD_ROOT/usr/share/qemu-xen/qemu/openbios-sparc64 rm -f $RPM_BUILD_ROOT/usr/share/qemu-xen/palcode-clipper +rm -f $RPM_BUILD_ROOT/usr/share/qemu-xen/qemu/palcode-clipper rm -f $RPM_BUILD_ROOT/usr/sbin/netfix rm -f $RPM_BUILD_ROOT/%{_libdir}/python%{pyver}/site-packages/*.egg-info rm -rf $RPM_BUILD_ROOT/html @@ -1154,6 +869,8 @@ rm -f $RPM_BUILD_ROOT/usr/local/share/man/man1/qemu-img.1 rm -f $RPM_BUILD_ROOT/usr/local/share/man/man8/qemu-nbd.8 rm -f $RPM_BUILD_ROOT/usr/local/share/doc/qemu/qemu-doc.html rm -f $RPM_BUILD_ROOT/usr/local/share/doc/qemu/qemu-tech.html +rm -f $RPM_BUILD_ROOT/usr/etc/qemu/target-x86_64.conf +rm -f $RPM_BUILD_ROOT/usr/libexec/qemu-bridge-helper #install firewall definitions format is described here: #/usr/share/SuSEfirewall2/services/TEMPLATE mkdir -p $RPM_BUILD_ROOT/%{_fwdefdir} @@ -1234,12 +951,9 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/xencons /usr/sbin/flask-get-bool /usr/sbin/flask-label-pci /usr/sbin/flask-set-bool -/usr/sbin/rcxend -/usr/sbin/rcxendomains /usr/sbin/rcpciback /usr/sbin/tapdisk /usr/sbin/xen* -/usr/sbin/xm /usr/sbin/xsview /usr/sbin/gtracestat /usr/sbin/gtraceview @@ -1260,7 +974,6 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/xencons /usr/lib/xen %endif %{_mandir}/man1/*.1.gz -%{_mandir}/man5/*.5.gz %{_mandir}/man8/*.8.gz /var/adm/fillup-templates/* %dir /var/lib/xen @@ -1268,10 +981,6 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/xencons %dir %attr(700,root,root) /var/lib/xen/save %dir %attr(700,root,root) /var/lib/xen/dump %dir %attr(700,root,root) /var/lib/xen/xenpaging -%dir /var/lib/xen/xend-db -%dir /var/lib/xen/xend-db/domain -%dir /var/lib/xen/xend-db/migrate -%dir /var/lib/xen/xend-db/vnet %dir /var/lib/xenstored %dir /var/log/xen %dir /var/log/xen/console @@ -1285,8 +994,6 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/xencons %config /etc/xen/cpupool /etc/xen/README* %config /etc/xen/vm -%config(noreplace) /etc/xen/*.sxp -%config(noreplace) /etc/xen/*.xml %config(noreplace) /etc/xen/xenapiusers %config(noreplace) /etc/xen/xl.conf %config /etc/pam.d/xen-api @@ -1295,7 +1002,6 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/xencons %dir /etc/udev %dir /etc/udev/rules.d /etc/udev/rules.d/40-xen.rules -/etc/udev/rules.d/40-xend.rules /etc/sysconfig/network/scripts/xen-updown.sh /etc/sysconfig/network/if-up.d/xen /etc/sysconfig/network/if-down.d/xen @@ -1306,8 +1012,10 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/xencons %{_defaultdocdir}/xen/boot.local.xenU %{_defaultdocdir}/xen/boot.xen %{_defaultdocdir}/xen/misc -%dir %{_libdir}/python%{pyver}/site-packages/xen %dir %{_libdir}/python%{pyver}/site-packages/grub +%dir %{_libdir}/python%{pyver}/site-packages/xen +%dir %{_libdir}/python%{pyver}/site-packages/xen/lowlevel +%dir %{_libdir}/python%{pyver}/site-packages/xen/xsview %dir %{_datadir}/qemu-xen %dir %{_datadir}/xen %dir %{_datadir}/xen/man @@ -1319,13 +1027,42 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/xencons %{_datadir}/xen/qemu/* %{_datadir}/xen/man/man1/* %{_datadir}/xen/man/man8/* -%{_libdir}/python%{pyver}/site-packages/xen/* %{_libdir}/python%{pyver}/site-packages/grub/* +%{_libdir}/python%{pyver}/site-packages/xen/__init__* +%{_libdir}/python%{pyver}/site-packages/xen/lowlevel/* +%{_libdir}/python%{pyver}/site-packages/xen/xsview/* %{_libdir}/python%{pyver}/site-packages/fsimage.so %{_libdir}/python%{pyver}/site-packages/xnloader.py -%config %{_fwdefdir}/xend-relocation-server %endif +%files xend-tools +%defattr(-,root,root) +%{_mandir}/man5/*.5.gz +/etc/udev/rules.d/40-xend.rules +/usr/sbin/rcxendomains +/usr/sbin/rcxend +/usr/sbin/xm +%dir %attr(700,root,root) /etc/xen +%dir /var/lib/xen/xend-db +%dir /var/lib/xen/xend-db/domain +%dir /var/lib/xen/xend-db/migrate +%dir /var/lib/xen/xend-db/vnet +%dir %{_libdir}/python%{pyver}/site-packages/xen/remus +%dir %{_libdir}/python%{pyver}/site-packages/xen/sv +%dir %{_libdir}/python%{pyver}/site-packages/xen/util +%dir %{_libdir}/python%{pyver}/site-packages/xen/xend +%dir %{_libdir}/python%{pyver}/site-packages/xen/xm +%dir %{_libdir}/python%{pyver}/site-packages/xen/web +%config(noreplace) /etc/xen/*.sxp +%config(noreplace) /etc/xen/*.xml +%{_libdir}/python%{pyver}/site-packages/xen/remus/* +%{_libdir}/python%{pyver}/site-packages/xen/sv/* +%{_libdir}/python%{pyver}/site-packages/xen/util/* +%{_libdir}/python%{pyver}/site-packages/xen/xend/* +%{_libdir}/python%{pyver}/site-packages/xen/xm/* +%{_libdir}/python%{pyver}/site-packages/xen/web/* +%config %{_fwdefdir}/xend-relocation-server + %files tools-domU %defattr(-,root,root) /usr/bin/xen-detect @@ -1334,7 +1071,6 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/xencons %files devel %defattr(-,root,root) -%{_bindir}/serial-split %{_libdir}/*.a %{_libdir}/*.so /usr/include/* @@ -1348,7 +1084,7 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/xencons %files doc-pdf %defattr(-,root,root) -%{_defaultdocdir}/xen/pdf +#%{_defaultdocdir}/xen/pdf %endif %if %{?with_dom0_support}0 diff --git a/xenapi-console-protocol.patch b/xenapi-console-protocol.patch deleted file mode 100644 index 219d982..0000000 --- a/xenapi-console-protocol.patch +++ /dev/null @@ -1,19 +0,0 @@ -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -3956,6 +3956,14 @@ class XendDomainInfo: - if not config.has_key('backend'): - config['backend'] = "00000000-0000-0000-0000-000000000000" - -+ if dev_class == 'console': -+ if not config.has_key('protocol'): -+ con_type = config.get('type', '') -+ if con_type == 'vnc': -+ config['protocol'] = 'rfb' -+ elif con_type == 'sdl': -+ config['protocol'] = 'rdp' -+ - return config - - def get_dev_property(self, dev_class, dev_uuid, field): diff --git a/xend-config-enable-dump-comment.patch b/xend-config-enable-dump-comment.patch deleted file mode 100644 index 24e243a..0000000 --- a/xend-config-enable-dump-comment.patch +++ /dev/null @@ -1,20 +0,0 @@ -bnc#684305 - ---- - tools/examples/xend-config.sxp | 3 +++ - 1 file changed, 3 insertions(+) - -Index: xen-4.2.0-testing/tools/examples/xend-config.sxp -=================================================================== ---- xen-4.2.0-testing.orig/tools/examples/xend-config.sxp -+++ xen-4.2.0-testing/tools/examples/xend-config.sxp -@@ -250,6 +250,9 @@ - (dom0-cpus 0) - - # Whether to enable core-dumps when domains crash. -+# This setting overrides the per-domain dump value 'on_crash' and causes a -+# core dump on all crashed domains. For finer grain control, it is best to -+# disable this setting (which is default) and use the per-domain controls. - #(enable-dump no) - - # The tool used for initiating virtual TPM migration diff --git a/xend-config.diff b/xend-config.diff deleted file mode 100644 index 18bcead..0000000 --- a/xend-config.diff +++ /dev/null @@ -1,54 +0,0 @@ -Index: xen-4.2.0-testing/tools/hotplug/Linux/init.d/sysconfig.xendomains -=================================================================== ---- xen-4.2.0-testing.orig/tools/hotplug/Linux/init.d/sysconfig.xendomains -+++ xen-4.2.0-testing/tools/hotplug/Linux/init.d/sysconfig.xendomains -@@ -98,7 +98,6 @@ XENDOMAINS_RESTORE=true - # Note that the script tries to be clever if both RESTORE and AUTO are - # set: It will first restore saved domains and then only start domains - # in AUTO which are not running yet. --# Note that the name matching is somewhat fuzzy. - # - XENDOMAINS_AUTO=/etc/xen/auto - -Index: xen-4.2.0-testing/tools/examples/xend-config.sxp -=================================================================== ---- xen-4.2.0-testing.orig/tools/examples/xend-config.sxp -+++ xen-4.2.0-testing/tools/examples/xend-config.sxp -@@ -58,11 +58,12 @@ - - - #(xend-http-server no) --#(xend-unix-server no) -+(xend-unix-server yes) - #(xend-tcp-xmlrpc-server no) - #(xend-unix-xmlrpc-server yes) -+# Only enable xend-relocation-server on trusted networks as it lacks -+# encryption and authentication. - #(xend-relocation-server no) --(xend-relocation-server yes) - #(xend-relocation-ssl-server no) - #(xend-udev-event-server no) - -@@ -170,7 +171,12 @@ - # 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) -+# SuSE users note: -+# On openSUSE >= 11.1 and SLES >= 11, networks should be configured using -+# native platform tool - YaST. vif-bridge and qemu-ifup can be used to -+# connect vifs to the YaST-managed networks. -+#(network-script network-bridge) -+(network-script ) - - # 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 -@@ -203,7 +209,7 @@ - # dom0-min-mem is the lowest permissible memory level (in MB) for dom0. - # This is a minimum both for auto-ballooning (as enabled by - # enable-dom0-ballooning below) and for xm mem-set when applied to dom0. --(dom0-min-mem 196) -+(dom0-min-mem 512) - - # Whether to enable auto-ballooning of dom0 to allow domUs to be created. - # If enable-dom0-ballooning = no, dom0 will never balloon out. diff --git a/xend-console-port-restore.patch b/xend-console-port-restore.patch deleted file mode 100644 index 63d3082..0000000 --- a/xend-console-port-restore.patch +++ /dev/null @@ -1,40 +0,0 @@ -Pass console_port to completeRestore() so that console/port is written to -xenstore. See bnc#706574 - -From: Chunyan Liu - -Index: xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendCheckpoint.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -@@ -345,8 +345,7 @@ def restore(xd, fd, dominfo = None, paus - restore_image.setCpuid() - - # xc_restore will wait for source to close connection -- -- dominfo.completeRestore(handler.store_mfn, handler.console_mfn) -+ dominfo.completeRestore(handler.store_mfn, handler.console_mfn, console_port) - - # - # We shouldn't hold the domains_lock over a waitForDevices -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -3078,7 +3078,7 @@ class XendDomainInfo: - # TODO: recategorise - called from XendCheckpoint - # - -- def completeRestore(self, store_mfn, console_mfn): -+ def completeRestore(self, store_mfn, console_mfn, console_port): - - log.debug("XendDomainInfo.completeRestore") - -@@ -3089,6 +3089,7 @@ class XendDomainInfo: - self.image = image.create(self, self.info) - if self.image: - self.image.createDeviceModel(True) -+ self.console_port = console_port - self._storeDomDetails() - self._registerWatches() - self.refreshShutdown() diff --git a/xend-core-dump-loc.diff b/xend-core-dump-loc.diff deleted file mode 100644 index 48a8372..0000000 --- a/xend-core-dump-loc.diff +++ /dev/null @@ -1,13 +0,0 @@ -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -2320,7 +2320,7 @@ class XendDomainInfo: - # To prohibit directory traversal - based_name = os.path.basename(self.info['name_label']) - -- coredir = "/var/xen/dump/%s" % (based_name) -+ coredir = "/var/lib/xen/dump/%s" % (based_name) - if not os.path.exists(coredir): - try: - mkdir.parents(coredir, stat.S_IRWXU) diff --git a/xend-cpuid.patch b/xend-cpuid.patch deleted file mode 100644 index 4bf4b93..0000000 --- a/xend-cpuid.patch +++ /dev/null @@ -1,26 +0,0 @@ -Only add cpuid and cpuid_check to sexpr once - -When converting a XendConfig object to sexpr, cpuid and cpuid_check -were being emitted twice in the resulting sexpr. The first conversion -writes incorrect sexpr, causing parsing of the sexpr to fail when xend -is restarted and domain sexpr files in /var/lib/xend/domains/ -are read and parsed. - -This patch skips the first conversion, and uses only the custom -cpuid{_check} conversion methods called later. It is not pretty, but -is the least invasive fix in this complex code. -Index: xen-4.2.0-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-4.2.0-testing/tools/python/xen/xend/XendConfig.py -@@ -1126,6 +1126,10 @@ class XendConfig(dict): - else: - for name, typ in XENAPI_CFG_TYPES.items(): - if name in self and self[name] not in (None, []): -+ # Skip cpuid and cpuid_check. Custom conversion -+ # methods for these are called below. -+ if name in ("cpuid", "cpuid_check"): -+ continue - if typ == dict: - s = self[name].items() - elif typ == list: diff --git a/xend-cpuinfo-model-name.patch b/xend-cpuinfo-model-name.patch deleted file mode 100644 index 248f577..0000000 --- a/xend-cpuinfo-model-name.patch +++ /dev/null @@ -1,24 +0,0 @@ -References: bnc#814709 -For cpus that contain additional ':' characters in their name - -Index: xen-4.2.1-testing/tools/python/xen/xend/osdep.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/osdep.py -+++ xen-4.2.1-testing/tools/python/xen/xend/osdep.py -@@ -143,10 +143,14 @@ def _linux_get_cpuinfo(): - d = {} - for line in f: - keyvalue = line.split(':') -- if len(keyvalue) != 2: -+ if len(keyvalue) < 2: - continue - key = keyvalue[0].strip() -- val = keyvalue[1].strip() -+ for i in range(1, len(keyvalue)): -+ if i == 1: -+ val = keyvalue[i].lstrip() -+ else: -+ val = val + ":" + keyvalue[i] - if key == 'processor': - if p != -1: - cpuinfo[p] = d diff --git a/xend-devid-or-name.patch b/xend-devid-or-name.patch deleted file mode 100644 index a57a4b7..0000000 --- a/xend-devid-or-name.patch +++ /dev/null @@ -1,27 +0,0 @@ -# HG changeset patch -# User Jim Fehlig -# Date 1284948067 21600 -# Node ID 4674ad11feef87a6a57b99313966e0e121588e1c -# Parent 5393151a737b023476f4e571effc547e758cf8c8 -xend: Fix device_configure - -The semantics of XendDomainInfo.py:device_configure() changed with xen upstream -c/s 19610. Previously this method would take a devid in actual id *or* name -form, e.g. it would accept '5632' or 'hdc'. This patch restores that behavior. - - Signed-off-by: Jim Fehlig - -Index: xen-4.2.0-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.0-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1203,6 +1203,9 @@ class XendDomainInfo: - except ValueError: - pass - devid = dev_control.convertToDeviceNumber(dev) -+ else: -+ # devid could be a name, e.g. hdc -+ devid = dev_control.convertToDeviceNumber(devid) - dev_info = self._getDeviceInfo_vbd(devid) - if dev_info is None: - raise VmError("Device %s not connected" % devid) diff --git a/xend-disable-internal-logrotate.patch b/xend-disable-internal-logrotate.patch deleted file mode 100644 index 32560e3..0000000 --- a/xend-disable-internal-logrotate.patch +++ /dev/null @@ -1,20 +0,0 @@ -Disable internal logging and enable the logrotate.conf from the xen package. -This allows larger xend.log files - ---- - tools/python/xen/xend/XendLogging.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -Index: xen-4.2.0-testing/tools/python/xen/xend/XendLogging.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/XendLogging.py -+++ xen-4.2.0-testing/tools/python/xen/xend/XendLogging.py -@@ -76,7 +76,7 @@ if 'TRACE' not in logging.__dict__: - log = logging.getLogger("xend") - - --MAX_BYTES = 1 << 20 # 1MB -+MAX_BYTES = 0 - BACKUP_COUNT = 5 - - STDERR_FORMAT = "[%(name)s] %(levelname)s (%(module)s:%(lineno)d) %(message)s" diff --git a/xend-domain-lock-sfex.patch b/xend-domain-lock-sfex.patch deleted file mode 100644 index 16bc204..0000000 --- a/xend-domain-lock-sfex.patch +++ /dev/null @@ -1,351 +0,0 @@ -Index: xen-4.2.2-testing/tools/examples/xend-config.sxp -=================================================================== ---- xen-4.2.2-testing.orig/tools/examples/xend-config.sxp -+++ xen-4.2.2-testing/tools/examples/xend-config.sxp -@@ -357,7 +357,7 @@ - # path // - # Return 0 on success, non-zero on error. - # --# lock-util [-s] path" -+# lock-util [-s] -i path" - # -s Lock status. If lock is acquired, print any contents - # on stdout and return 0. Return non-zero if lock is - # available. -@@ -383,6 +383,11 @@ - # - #(xend-domain-lock-utility domain-lock) - -+# Some locking mechanism provide cluster wide locking service like sfex. -+# And that requires a shared locking device. -+#(xend-domain-lock-utility domain-lock-sfex) -+#(xend-domain-lock-device "/dev/iwmvg/hbdevice") -+ - # If we have a very big scsi device configuration, start of xend is slow, - # because xend scans all the device paths to build its internal PSCSI device - # list. If we need only a few devices for assigning to a guest, we can reduce -Index: xen-4.2.2-testing/tools/hotplug/Linux/Makefile -=================================================================== ---- xen-4.2.2-testing.orig/tools/hotplug/Linux/Makefile -+++ xen-4.2.2-testing/tools/hotplug/Linux/Makefile -@@ -23,6 +23,7 @@ XEN_SCRIPTS += xen-hotplug-cleanup - XEN_SCRIPTS += external-device-migrate - XEN_SCRIPTS += vscsi - XEN_SCRIPTS += domain-lock vm-monitor -+XEN_SCRIPTS += domain-lock-sfex - XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh - XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh - XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh -Index: xen-4.2.2-testing/tools/hotplug/Linux/domain-lock -=================================================================== ---- xen-4.2.2-testing.orig/tools/hotplug/Linux/domain-lock -+++ xen-4.2.2-testing/tools/hotplug/Linux/domain-lock -@@ -4,7 +4,7 @@ basedir=$(dirname "$0") - - usage() { - echo "usage: domain-lock [-l|-u] -n -i -p path" -- echo "usage: domain-lock [-s] path" -+ echo "usage: domain-lock [-s] -i path" - echo "" - echo "-l lock" - echo "-u unlock" -Index: xen-4.2.2-testing/tools/hotplug/Linux/domain-lock-sfex -=================================================================== ---- /dev/null -+++ xen-4.2.2-testing/tools/hotplug/Linux/domain-lock-sfex -@@ -0,0 +1,166 @@ -+#!/bin/bash -+ -+# pre-condition -+# 1. device is ready: logical volume activated if used -+# 2. device already initialized -+# 3. index is assigned correctly -+ -+#error code: -+# 0: success -+# 1: error -+ -+if [ `uname -m` = "x86_64" ]; then -+ SFEX_DAEMON=/usr/lib64/heartbeat/sfex_daemon -+else -+ SFEX_DAEMON=/usr/lib/heartbeat/sfex_daemon -+fi -+SFEX_INIT=/usr/sbin/sfex_init -+COLLISION_TIMEOUT=1 -+LOCK_TIMEOUT=3 -+MONITOR_INTERVAL=2 -+LOCAL_LOCK_FILE=/var/lock/sfex -+ -+usage() { -+ echo "usage: domain-lock-sfex [-l|-u|-s] -i -x " -+ echo "" -+ echo "-l lock" -+ echo "-u unlock" -+ echo "-s status (default)" -+ echo "-i Virtual Machine Id or UUID" -+ echo "-x SFEX device which used for sfex lock" -+ exit 1 -+} -+ -+get_lock_host() { -+ local rscname=$1 -+ local device=$2 -+ r=`$SFEX_DAEMON -s -u $rscname $device` -+ echo $r -+} -+ -+get_status() { -+ local rscname=$1 -+ if /usr/bin/pgrep -f "$SFEX_DAEMON .* ${rscname} " > /dev/null 2>&1; then -+ return 0 -+ else -+ return 1 -+ fi -+} -+ -+acquire_lock() { -+ local rscname=$1 -+ local device=$2 -+ get_status $rscname -+ ## We assume xend will take care to avoid starting same VM twice on the same machine. -+ if [ $? -eq 0 ]; then -+ return 0 -+ fi -+ $SFEX_DAEMON -c $COLLISION_TIMEOUT -t $LOCK_TIMEOUT -m $MONITOR_INTERVAL -u $rscname $device -+ rc=$? -+ if [ $rc -ne 0 ]; then -+ return $rc -+ fi -+ sleep 4 -+ get_status $rscname -+ if [ $? -eq 0 ]; then -+ return 0 -+ fi -+ return 1 -+} -+ -+# release has to success -+release_lock(){ -+ local rscname=$1 -+ -+ ## If the lock is already released -+ get_status $rscname -+ if [ $? -ne 0 ]; then -+ return 0 -+ fi -+ -+ pid=`/usr/bin/pgrep -f "$SFEX_DAEMON .* ${rscname} "` -+ /bin/kill $pid -+ -+ count=0 -+ while [ $count -lt 10 ] -+ do -+ get_status $rscname -+ if [ $? -eq 1 ]; then -+ return 0 -+ fi -+ count=`expr $count + 1` -+ sleep 1 -+ done -+ -+ /bin/kill -9 $pid -+ while : -+ do -+ get_status $rscname -+ if [ $? -eq 1 ]; then -+ break; -+ fi -+ sleep 1 -+ done -+ -+ return 0 -+} -+ -+mode="status" -+ -+while getopts ":lusn:i:p:x:" opt; do -+case $opt in -+l ) -+mode="lock" -+;; -+u ) -+mode="unlock" -+;; -+s ) -+mode="status" -+;; -+n ) -+vm_name=$OPTARG -+;; -+i ) -+vm_uuid=$OPTARG -+;; -+p ) -+vm_host=$OPTARG -+;; -+x ) -+vm_sfex_device=$OPTARG -+;; -+\? ) -+usage -+;; -+esac -+done -+ -+shift $(($OPTIND - 1)) -+[ -z $vm_uuid ] && usage -+[ -z $vm_sfex_device ] && usage -+ -+case $mode in -+lock ) -+ ( -+ flock -x 200 -+ acquire_lock $vm_uuid $vm_sfex_device -+ rc=$? -+ flock -u 200 -+ exit $rc -+ ) 200>$LOCAL_LOCK_FILE-$vm_uuid -+;; -+unlock ) -+ ( -+ flock -x 200 -+ release_lock $vm_uuid -+ rc=$? -+ flock -u 200 -+ exit $rc -+ ) 200>$LOCAL_LOCK_FILE-$vm_uuid -+;; -+status ) -+ get_lock_host $vm_uuid $vm_sfex_device -+;; -+esac -+ -Index: xen-4.2.2-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -4573,8 +4573,14 @@ class XendDomainInfo: - - # Return name of host contained in lock file. - def get_lock_host(self, path): -- fin = os.popen(xoptions.get_xend_domain_lock_utility() + \ -- ' -s ' + path, 'r') -+ lock_cmd = '%s -s -i %s ' % \ -+ (xoptions.get_xend_domain_lock_utility(), \ -+ self.info['uuid']) -+ lock_dev = xoptions.get_xend_domain_lock_device() -+ if lock_dev: -+ lock_cmd += '-x %d ' % lock_dev -+ lock_cmd += path -+ fin = os.popen(lock_cmd, 'r') - hostname = "unknown" - - try: -@@ -4596,6 +4602,16 @@ class XendDomainInfo: - path = xoptions.get_xend_domain_lock_path() - path = os.path.join(path, self.get_uuid()) - -+ lock_cmd = '%s -l -p %s -n %s -i %s ' % \ -+ (xoptions.get_xend_domain_lock_utility(), \ -+ XendNode.instance().get_name(), \ -+ self.info['name_label'], \ -+ self.info['uuid']) -+ lock_dev = xoptions.get_xend_domain_lock_device() -+ if lock_dev: -+ lock_cmd += '-x %d ' % lock_dev -+ lock_cmd += path -+ - try: - if not os.path.exists(path): - mkdir.parents(path, stat.S_IRWXU) -@@ -4603,12 +4619,7 @@ class XendDomainInfo: - log.exception("%s could not be created." % path) - raise XendError("%s could not be created." % path) - -- status = os.system('%s -l -p %s -n %s -i %s %s' % \ -- (xoptions.get_xend_domain_lock_utility(), \ -- XendNode.instance().get_name(), \ -- self.info['name_label'], \ -- self.info['uuid'], \ -- path)) -+ status = os.system(lock_cmd) >> 8 - if status != 0: - log.debug("Failed to aqcuire lock: status = %d" % status) - raise XendError("The VM is locked and appears to be running on host %s." % self.get_lock_host(path)) -@@ -4625,12 +4636,18 @@ class XendDomainInfo: - - path = xoptions.get_xend_domain_lock_path() - path = os.path.join(path, self.get_uuid()) -- status = os.system('%s -u -p %s -n %s -i %s %s' % \ -- (xoptions.get_xend_domain_lock_utility(), \ -- XendNode.instance().get_name(), \ -- dom_name, \ -- self.info['uuid'], \ -- path)) -+ -+ lock_cmd = '%s -u -p %s -n %s -i %s ' % \ -+ (xoptions.get_xend_domain_lock_utility(), \ -+ XendNode.instance().get_name(), \ -+ dom_name, \ -+ self.info['uuid']) -+ lock_dev = xoptions.get_xend_domain_lock_device() -+ if lock_dev: -+ lock_cmd += '-x %d ' % lock_dev -+ lock_cmd += path -+ -+ status = os.system(lock_cmd) >> 8 - if status != 0: - log.exception("Failed to release lock: status = %s" % status) - try: -Index: xen-4.2.2-testing/tools/python/xen/xend/XendNode.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendNode.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendNode.py -@@ -162,6 +162,7 @@ class XendNode: - - self._init_cpu_pools() - -+ self._init_lock_devices() - - def _init_networks(self): - # Initialise networks -@@ -382,6 +383,17 @@ class XendNode: - XendCPUPool.recreate_active_pools() - - -+ def _init_lock_devices(self): -+ if xendoptions().get_xend_domain_lock(): -+ if xendoptions().get_xend_domain_lock_utility().endswith("domain-lock-sfex"): -+ lock_device = xendoptions().get_xend_domain_lock_device() -+ if not lock_device: -+ raise XendError("The block device for sfex is not properly configured") -+ status = os.system("lvchange -ay %s" % lock_device) >> 8 -+ if status != 0: -+ raise XendError("The block device for sfex could not be initialized") -+ -+ - def add_network(self, interface): - # TODO - log.debug("add_network(): Not implemented.") -Index: xen-4.2.2-testing/tools/python/xen/xend/XendOptions.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendOptions.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendOptions.py -@@ -164,6 +164,9 @@ class XendOptions: - """Default script to acquire/release domain lock""" - xend_domain_lock_utility = auxbin.scripts_dir() + "/domain-lock" - -+ """Default block device for lock service""" -+ xend_domain_lock_device = "" -+ - - def __init__(self): - self.configure() -@@ -430,6 +433,8 @@ class XendOptions: - else: - return self.xend_domain_lock_utility - -+ def get_xend_domain_lock_device(self): -+ return self.get_config_string('xend-domain-lock-device', self.xend_domain_lock_device) - - def get_vnc_tls(self): - return self.get_config_string('vnc-tls', self.xend_vnc_tls) diff --git a/xend-domain-lock.patch b/xend-domain-lock.patch deleted file mode 100644 index cb4a103..0000000 --- a/xend-domain-lock.patch +++ /dev/null @@ -1,406 +0,0 @@ ---- - tools/examples/xend-config.sxp | 59 ++++++++++++++++++++++ - tools/hotplug/Linux/Makefile | 1 - tools/hotplug/Linux/domain-lock | 83 ++++++++++++++++++++++++++++++++ - tools/hotplug/Linux/vm-monitor | 41 +++++++++++++++ - tools/python/xen/xend/XendCheckpoint.py | 3 + - tools/python/xen/xend/XendDomainInfo.py | 74 ++++++++++++++++++++++++++++ - tools/python/xen/xend/XendOptions.py | 29 +++++++++++ - 7 files changed, 290 insertions(+) - -Index: xen-4.2.2-testing/tools/examples/xend-config.sxp -=================================================================== ---- xen-4.2.2-testing.orig/tools/examples/xend-config.sxp -+++ xen-4.2.2-testing/tools/examples/xend-config.sxp -@@ -324,6 +324,65 @@ - # device assignment could really work properly even after we do this. - #(pci-passthrough-strict-check yes) - -+# Domain Locking -+# In a multihost environment, domain locking provides a simple mechanism that -+# prevents simultaneously running a domain on more than one host. -+# -+# If enabled, xend will execute a external lock utility (defined below) -+# on each domain start and stop event. Disabled by default. Set to yes -+# to enable domain locking. -+# -+#(xend-domain-lock no) -+ -+# Path where domain lock is stored if xend-domain-lock is enabled. -+# Note: This path must be accessible to all VM Servers participating -+# in domain locking, e.g. by specifying a shared mount point. -+# Lock is placed in //. -+# Default is /var/lib/xen/images/vm_locks/ -+# -+#(xend-domain-lock-path /var/lib/images/vm_locks) -+ -+# External locking utility called by xend for acquiring/releasing -+# domain lock. By default /etc/xen/scripts/domain-lock will be used -+# if xend-domain-lock is set to yes. Set to path of custom locking -+# utility to override the default. -+# -+# Synopsis of lock-util: -+# lock-util [-l|-u] -n -i -p path" -+# -l Acquire (create) lock -+# -u Remove lock -+# -n vm-name Name of domain -+# -i vm-id Id or UUID of domain -+# -p phy-host Name of physical host (dom0) -+# path // -+# Return 0 on success, non-zero on error. -+# -+# lock-util [-s] path" -+# -s Lock status. If lock is acquired, print any contents -+# on stdout and return 0. Return non-zero if lock is -+# available. -+# path // -+# If lock is acquired, print any contents on stdout and return 0. -+# Return non-zero if lock is available. -+# -+# Default lock-util behavior: -+# On domain start event, domain-lock will create and flock(1) -+# ///lock. Every two seconds it -+# will write , , , and to the lock. -+# is running counter. -+# On domain stop event, domain-lock will unlock and remove -+# ///lock. -+# -+# Note: If xend-domain-lock-path is a cluster-unaware file system, -+# administrator intervention may be required to remove stale -+# locks. Consider two hosts using NFS for xend-domain-lock-path -+# when HostA, running vm1, crashes. HostB could not acquire a -+# lock for vm1 since the NFS server holds an exclusive lock -+# acquired by HostA. The lock file must be manually removed -+# before starting vm1 on HostB. -+# -+#(xend-domain-lock-utility domain-lock) -+ - # If we have a very big scsi device configuration, start of xend is slow, - # because xend scans all the device paths to build its internal PSCSI device - # list. If we need only a few devices for assigning to a guest, we can reduce -Index: xen-4.2.2-testing/tools/hotplug/Linux/Makefile -=================================================================== ---- xen-4.2.2-testing.orig/tools/hotplug/Linux/Makefile -+++ xen-4.2.2-testing/tools/hotplug/Linux/Makefile -@@ -22,6 +22,7 @@ XEN_SCRIPTS += vtpm vtpm-delete - XEN_SCRIPTS += xen-hotplug-cleanup - XEN_SCRIPTS += external-device-migrate - XEN_SCRIPTS += vscsi -+XEN_SCRIPTS += domain-lock vm-monitor - XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh - XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh - XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh -Index: xen-4.2.2-testing/tools/hotplug/Linux/domain-lock -=================================================================== ---- /dev/null -+++ xen-4.2.2-testing/tools/hotplug/Linux/domain-lock -@@ -0,0 +1,83 @@ -+#!/bin/bash -+ -+basedir=$(dirname "$0") -+ -+usage() { -+ echo "usage: domain-lock [-l|-u] -n -i -p path" -+ echo "usage: domain-lock [-s] path" -+ echo "" -+ echo "-l lock" -+ echo "-u unlock" -+ echo "-s status (default)" -+ echo "-n Virtual Machine name" -+ echo "-i Virtual Machine Id or UUID" -+ echo "-p Virtual Machine Server (physical host) name" -+ echo "path A per-VM, unique location where external lock will be managed" -+ exit 1 -+} -+ -+remove_lock(){ -+ local path=$1/lock -+ local name=$2 -+ -+ pid=`ps -efwww | grep vm-monitor | grep $name | awk '{print $2}'` -+ if [ -n "$pid" ]; then -+ kill $pid -+ rm -f $path -+ fi -+} -+ -+get_status(){ -+ local path=$1/lock -+ [ -f $path ] || exit 1 -+ -+ rc=`flock -xn $path /bin/true` -+ cat $path -+ exit $rc -+} -+ -+mode="status" -+ -+while getopts ":lusn:i:p:" opt; do -+ case $opt in -+ l ) -+ mode="lock" -+ ;; -+ u ) -+ mode="unlock" -+ ;; -+ s ) -+ mode="status" -+ ;; -+ p ) -+ vm_host=$OPTARG -+ ;; -+ n ) -+ vm_name=$OPTARG -+ ;; -+ i ) -+ vm_uuid=$OPTARG -+ ;; -+ \? ) -+ usage -+ ;; -+ esac -+done -+ -+shift $(($OPTIND - 1)) -+vm_path=$1 -+ -+case $mode in -+ lock ) -+ [ -z "$vm_path" ] || [ -z "$vm_name" ] || [ -z "$vm_uuid" ] || [ -z "$vm_host" ] && usage -+ $basedir/set-lock $vm_path $vm_name $vm_uuid $vm_host -+ ;; -+ unlock ) -+ [ -z "$vm_path" ] || [ -z "$vm_name" ] || [ -z "$vm_uuid" ] || [ -z "$vm_host" ] && usage -+ remove_lock $vm_path $vm_name $vm_uuid $vm_host -+ ;; -+ status ) -+ [ -z "$vm_path" ] && usage -+ get_status $vm_path -+ ;; -+esac -Index: xen-4.2.2-testing/tools/hotplug/Linux/vm-monitor -=================================================================== ---- /dev/null -+++ xen-4.2.2-testing/tools/hotplug/Linux/vm-monitor -@@ -0,0 +1,41 @@ -+#!/bin/bash -+ -+basedir=$(dirname "$0") -+HA_TICK=2 -+ -+monitor() { -+ local path=$1 -+ local name=$2 -+ local uuid=$3 -+ local host=$4 -+ local count=0 -+ path=$path/lock -+ -+ while : -+ do -+ echo "name=$name uuid=$uuid host=$host count=$count" > $path -+ count=$(($count+1)) -+ sleep $HA_TICK -+ done& -+} -+ -+create_lock() { -+ local path=$1/lock -+ local rc=0 -+ -+ [ -f $path ] || touch $path -+ flock -x -w $HA_TICK $path $basedir/vm-monitor $* -+ rc=$? -+ if [ $rc -eq 1 ]; then -+ echo `cat $path` -+ exit 1 -+ else -+ exit $rc -+ fi -+} -+ -+if [ $0 = "$basedir/set-lock" ]; then -+ create_lock $* -+elif [ $0 = "$basedir/vm-monitor" ]; then -+ monitor $* -+fi -Index: xen-4.2.2-testing/tools/python/xen/xend/XendCheckpoint.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendCheckpoint.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendCheckpoint.py -@@ -139,6 +139,11 @@ def save(fd, dominfo, network, live, dst - str( int(live) | (int(hvm) << 2) | (int(abort_if_busy) << 5) | (int(log_save_progress) << 6) ) ] - log.debug("[xc_save]: %s", string.join(cmd)) - -+ # It is safe to release the domain lock at this point if not -+ # checkpointing -+ if checkpoint == False: -+ dominfo.release_running_lock(domain_name) -+ - def saveInputHandler(line, tochild): - log.debug("In saveInputHandler %s", line) - if line == "suspend": -@@ -203,6 +208,9 @@ def save(fd, dominfo, network, live, dst - log.exception("Save failed on domain %s (%s) - resuming.", domain_name, - dominfo.getDomid()) - dominfo.resumeDomain() -+ # Reacquire the domain lock -+ if checkpoint == False: -+ dominfo.acquire_running_lock() - - try: - dominfo.setName(domain_name) -@@ -369,6 +377,7 @@ def restore(xd, fd, dominfo = None, paus - if not paused: - dominfo.unpause() - -+ dominfo.acquire_running_lock() - return dominfo - except Exception, exn: - dominfo.destroy() -Index: xen-4.2.2-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -486,6 +486,7 @@ class XendDomainInfo: - if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, XEN_API_VM_POWER_STATE_SUSPENDED, XEN_API_VM_POWER_STATE_CRASHED): - try: - prepare_domain_pci_devices(self.info); -+ self.acquire_running_lock(); - XendTask.log_progress(0, 30, self._constructDomain) - XendTask.log_progress(31, 60, self._initDomain) - -@@ -3056,6 +3057,11 @@ class XendDomainInfo: - - self._stateSet(DOM_STATE_HALTED) - self.domid = None # Do not push into _stateSet()! -+ -+ try: -+ self.release_running_lock() -+ except: -+ log.exception("Failed to release domain lock.") - finally: - self.refresh_shutdown_lock.release() - -@@ -4565,6 +4571,74 @@ class XendDomainInfo: - def has_device(self, dev_class, dev_uuid): - return (dev_uuid in self.info['%s_refs' % dev_class.lower()]) - -+ # Return name of host contained in lock file. -+ def get_lock_host(self, path): -+ fin = os.popen(xoptions.get_xend_domain_lock_utility() + \ -+ ' -s ' + path, 'r') -+ hostname = "unknown" -+ -+ try: -+ tokens = fin.readline().split() -+ for token in tokens: -+ item = token.split('=') -+ if item[0] == 'host': -+ hostname = item[1] -+ return hostname -+ finally: -+ fin.close() -+ -+ # Acquire a lock for the domain. No-op if domain locking is turned off. -+ def acquire_running_lock(self): -+ if not xoptions.get_xend_domain_lock(): -+ return -+ -+ log.debug("Acquiring lock for domain %s" % self.info['name_label']) -+ path = xoptions.get_xend_domain_lock_path() -+ path = os.path.join(path, self.get_uuid()) -+ -+ try: -+ if not os.path.exists(path): -+ mkdir.parents(path, stat.S_IRWXU) -+ except: -+ log.exception("%s could not be created." % path) -+ raise XendError("%s could not be created." % path) -+ -+ status = os.system('%s -l -p %s -n %s -i %s %s' % \ -+ (xoptions.get_xend_domain_lock_utility(), \ -+ XendNode.instance().get_name(), \ -+ self.info['name_label'], \ -+ self.info['uuid'], \ -+ path)) -+ if status != 0: -+ log.debug("Failed to aqcuire lock: status = %d" % status) -+ raise XendError("The VM is locked and appears to be running on host %s." % self.get_lock_host(path)) -+ -+ # Release lock for domain. No-op if domain locking is turned off. -+ def release_running_lock(self, name = None): -+ if not xoptions.get_xend_domain_lock(): -+ return -+ -+ dom_name = self.info['name_label'] -+ if name: -+ dom_name = name -+ log.debug("Releasing lock for domain %s" % dom_name) -+ -+ path = xoptions.get_xend_domain_lock_path() -+ path = os.path.join(path, self.get_uuid()) -+ status = os.system('%s -u -p %s -n %s -i %s %s' % \ -+ (xoptions.get_xend_domain_lock_utility(), \ -+ XendNode.instance().get_name(), \ -+ dom_name, \ -+ self.info['uuid'], \ -+ path)) -+ if status != 0: -+ log.exception("Failed to release lock: status = %s" % status) -+ try: -+ if len(os.listdir(path)) == 0: -+ shutil.rmtree(path) -+ except: -+ log.exception("Failed to remove unmanaged directory %s." % path) -+ - def __str__(self): - return '' % \ - (str(self.domid), self.info['name_label'], -Index: xen-4.2.2-testing/tools/python/xen/xend/XendOptions.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendOptions.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendOptions.py -@@ -154,6 +154,17 @@ class XendOptions: - use loose check automatically if necessary.""" - pci_dev_assign_strict_check_default = True - -+ """Default for the flag indicating whether xend should create -+ a lock file for domains when they are started.""" -+ xend_domain_lock = 'no' -+ -+ """Default domain lock storage path.""" -+ xend_domain_lock_path_default = '/var/lib/xen/images/vm_locks' -+ -+ """Default script to acquire/release domain lock""" -+ xend_domain_lock_utility = auxbin.scripts_dir() + "/domain-lock" -+ -+ - def __init__(self): - self.configure() - -@@ -401,6 +412,24 @@ class XendOptions: - else: - return None - -+ def get_xend_domain_lock(self): -+ """Get the flag indicating whether xend should create a lock file -+ for domains when they are started.""" -+ return self.get_config_bool("xend-domain-lock", self.xend_domain_lock) -+ -+ def get_xend_domain_lock_path(self): -+ """ Get the path for domain lock storage -+ """ -+ return self.get_config_string("xend-domain-lock-path", self.xend_domain_lock_path_default) -+ -+ def get_xend_domain_lock_utility(self): -+ s = self.get_config_string('xend-domain-lock-utility') -+ -+ if s: -+ return os.path.join(auxbin.scripts_dir(), s) -+ else: -+ return self.xend_domain_lock_utility -+ - - def get_vnc_tls(self): - return self.get_config_string('vnc-tls', self.xend_vnc_tls) diff --git a/xend-hvm-firmware-passthrough.patch b/xend-hvm-firmware-passthrough.patch deleted file mode 100644 index 30680b7..0000000 --- a/xend-hvm-firmware-passthrough.patch +++ /dev/null @@ -1,277 +0,0 @@ -fate#313584: pass bios information to XEN HVM guest - -Index: xen-4.2.1-testing/tools/python/xen/xm/create.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xm/create.py -+++ xen-4.2.1-testing/tools/python/xen/xm/create.py -@@ -491,6 +491,14 @@ gopts.var('nfs_root', val="PATH", - fn=set_value, default=None, - use="Set the path of the root NFS directory.") - -+gopts.var('smbios_firmware', val='FILE', -+ fn=set_value, default=None, -+ use="Path to a file that contains extra SMBIOS firmware structures.") -+ -+gopts.var('acpi_firmware', val='FILE', -+ fn=set_value, default=None, -+ use="Path to a file that contains extra ACPI firmware tables.") -+ - gopts.var('device_model', val='FILE', - fn=set_value, default=None, - use="Path to device model program.") -@@ -1097,6 +1105,7 @@ def configure_hvm(config_image, vals): - 'boot', - 'cpuid', 'cpuid_check', - 'device_model', 'display', -+ 'smbios_firmware', 'acpi_firmware', - 'fda', 'fdb', - 'gfx_passthru', 'guest_os_type', - 'hap', 'hpet', -Index: xen-4.2.1-testing/tools/python/xen/xm/xenapi_create.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xm/xenapi_create.py -+++ xen-4.2.1-testing/tools/python/xen/xm/xenapi_create.py -@@ -1086,6 +1086,8 @@ class sxp2xml: - 'apic', - 'boot', - 'device_model', -+ 'smbios_firmware', -+ 'acpi_firmware', - 'loader', - 'fda', - 'fdb', -Index: xen-4.2.1-testing/tools/python/xen/xend/image.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/image.py -+++ xen-4.2.1-testing/tools/python/xen/xend/image.py -@@ -17,7 +17,7 @@ - #============================================================================ - - --import os, os.path, string -+import os, os.path, string, struct, stat - import re - import math - import time -@@ -123,6 +123,8 @@ class ImageHandler: - - self.device_model = vmConfig['platform'].get('device_model') - -+ self.smbios_firmware =(str(vmConfig['platform'].get('smbios_firmware'))) -+ self.acpi_firmware =(str(vmConfig['platform'].get('acpi_firmware'))) - self.display = vmConfig['platform'].get('display') - self.xauthority = vmConfig['platform'].get('xauthority') - self.vncconsole = int(vmConfig['platform'].get('vncconsole', 0)) -@@ -945,6 +947,38 @@ class HVMImageHandler(ImageHandler): - self.vm.getDomid() ]) - return args - -+ def _readFirmwareFile(self, filename): -+ # Sanity check -+ if filename is None or filename.strip() == "": -+ size = struct.pack('i', int(0)) -+ return size + "" -+ -+ log.debug("Reading firmware file %s", filename) -+ # Open -+ try: -+ fd = os.open(filename, os.O_RDONLY) -+ except Exception, e: -+ raise VmError('Unable to open firmware file %s' % filename) -+ -+ # Validate file size -+ statinfo = os.fstat(fd) -+ if statinfo.st_size == 0 or statinfo.st_size > sys.maxint: -+ os.close(fd) -+ raise VmError('Firmware file %s is an invalid size' % filename) -+ if not stat.S_ISREG(statinfo.st_mode): -+ os.close(fd) -+ raise VmError('Firmware file %s is an invalid file type' % filename) -+ size = struct.pack('i', statinfo.st_size) -+ -+ # Read entire file -+ try: -+ buf = os.read(fd, statinfo.st_size) -+ except Exception, e: -+ os.close(fd) -+ raise VmError('Failed reading firmware file %s' % filename) -+ os.close(fd) -+ return size+buf -+ - def buildDomain(self): - store_evtchn = self.vm.getStorePort() - -@@ -960,6 +994,8 @@ class HVMImageHandler(ImageHandler): - log.debug("vcpu_avail = %li", self.vm.getVCpuAvail()) - log.debug("acpi = %d", self.acpi) - log.debug("apic = %d", self.apic) -+ log.debug("smbios_firmware= %s", self.smbios_firmware) -+ log.debug("acpi_firmware = %s", self.acpi_firmware) - - rc = xc.hvm_build(domid = self.vm.getDomid(), - image = self.loader, -@@ -968,7 +1004,9 @@ class HVMImageHandler(ImageHandler): - vcpus = self.vm.getVCpuCount(), - vcpu_avail = self.vm.getVCpuAvail(), - acpi = self.acpi, -- apic = self.apic) -+ apic = self.apic, -+ smbios_firmware= self._readFirmwareFile(self.smbios_firmware), -+ acpi_firmware = self._readFirmwareFile(self.acpi_firmware)) - rc['notes'] = { 'SUSPEND_CANCEL': 1 } - - rc['store_mfn'] = xc.hvm_get_param(self.vm.getDomid(), -Index: xen-4.2.1-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendConfig.py -@@ -147,6 +147,8 @@ XENAPI_PLATFORM_CFG_TYPES = { - 'apic': int, - 'boot': str, - 'device_model': str, -+ 'smbios_firmware': str, -+ 'acpi_firmware': str, - 'loader': str, - 'display' : str, - 'fda': str, -@@ -515,6 +517,10 @@ class XendConfig(dict): - self['platform']['nomigrate'] = 0 - - if self.is_hvm(): -+ if 'smbios_firmware' not in self['platform']: -+ self['platform']['smbios_firmware'] = "" -+ if 'acpi_firmware' not in self['platform']: -+ self['platform']['acpi_firmware'] = "" - if 'timer_mode' not in self['platform']: - self['platform']['timer_mode'] = 1 - if 'viridian' not in self['platform']: -Index: xen-4.2.1-testing/tools/python/xen/lowlevel/xc/xc.c -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/lowlevel/xc/xc.c -+++ xen-4.2.1-testing/tools/python/xen/lowlevel/xc/xc.c -@@ -942,18 +942,23 @@ static PyObject *pyxc_hvm_build(XcObject - struct hvm_info_table *va_hvm; - uint8_t *va_map, sum; - #endif -- int i; -- char *image; -+ int i, datalen; -+ char *image, *smbios_str, *acpi_str; - int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1; -+ PyObject *acpi_firmware = NULL; -+ PyObject *smbios_firmware = NULL; - PyObject *vcpu_avail_handle = NULL; - uint8_t vcpu_avail[(HVM_MAX_VCPUS + 7)/8]; -+ struct xc_hvm_build_args hvm_args = {}; - - static char *kwd_list[] = { "domid", - "memsize", "image", "target", "vcpus", -- "vcpu_avail", "acpi", "apic", NULL }; -- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiOii", kwd_list, -+ "vcpu_avail", "acpi", "apic", -+ "smbios_firmware", "acpi_firmware", NULL }; -+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiOiiOO", kwd_list, - &dom, &memsize, &image, &target, &vcpus, -- &vcpu_avail_handle, &acpi, &apic) ) -+ &vcpu_avail_handle, &acpi, -+ &apic, &smbios_firmware, &acpi_firmware) ) - return NULL; - - memset(vcpu_avail, 0, sizeof(vcpu_avail)); -@@ -984,8 +989,38 @@ static PyObject *pyxc_hvm_build(XcObject - if ( target == -1 ) - target = memsize; - -- if ( xc_hvm_build_target_mem(self->xc_handle, dom, memsize, -- target, image) != 0 ) -+ memset(&hvm_args, 0, sizeof(struct xc_hvm_build_args)); -+ hvm_args.mem_size = (uint64_t)memsize << 20; -+ hvm_args.mem_target = (uint64_t)target << 20; -+ hvm_args.image_file_name = image; -+ -+ if ( PyString_Check(smbios_firmware ) ) -+ { -+ smbios_str = PyString_AsString(smbios_firmware); -+ if ( smbios_str ) -+ { -+ datalen = *(int *)smbios_str; -+ if ( datalen ) { -+ hvm_args.smbios_module.data = &((uint8_t *)smbios_str)[4]; -+ hvm_args.smbios_module.length = (uint32_t)datalen; -+ } -+ } -+ } -+ -+ if ( PyString_Check(acpi_firmware ) ) -+ { -+ acpi_str = PyString_AsString(acpi_firmware); -+ if (acpi_str) -+ { -+ datalen = *(int *)acpi_str; -+ if ( datalen ) { -+ hvm_args.acpi_module.data = &((uint8_t *)acpi_str)[4]; -+ hvm_args.acpi_module.length = (uint32_t)datalen; -+ } -+ } -+ } -+ -+ if ( xc_hvm_build(self->xc_handle, dom, &hvm_args) != 0 ) - return pyxc_error_to_exception(self->xc_handle); - - #if !defined(__ia64__) -Index: xen-4.2.1-testing/docs/man/xmdomain.cfg.pod.5 -=================================================================== ---- xen-4.2.1-testing.orig/docs/man/xmdomain.cfg.pod.5 -+++ xen-4.2.1-testing/docs/man/xmdomain.cfg.pod.5 -@@ -243,6 +243,25 @@ this the xen kernel must be compiled wit - - This defaults to 1, meaning running the domain as a UP. - -+=item B -+ -+Specify a path to a file that contains extra ACPI firmware tables to pass in to -+a guest. The file can contain several tables in their binary AML form -+concatenated together. Each table self describes its length so no additional -+information is needed. These tables will be added to the ACPI table set in the -+guest. Note that existing tables cannot be overridden by this feature. For -+example this cannot be used to override tables like DSDT, FADT, etc. -+ -+=item B -+ -+Specify a path to a file that contains extra SMBIOS firmware structures to pass -+in to a guest. The file can contain a set DMTF predefined structures which will -+override the internal defaults. Not all predefined structures can be overridden, -+only the following types: 0, 1, 2, 3, 11, 22, 39. The file can also contain any -+number of vendor defined SMBIOS structures (type 128 - 255). Since SMBIOS -+structures do not present their overall size, each entry in the file must be -+preceded by a 32b integer indicating the size of the next structure. -+ - =back - - =head1 DOMAIN SHUTDOWN OPTIONS -Index: xen-4.2.1-testing/tools/python/README.sxpcfg -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/README.sxpcfg -+++ xen-4.2.1-testing/tools/python/README.sxpcfg -@@ -51,6 +51,8 @@ image - - vncunused - (HVM) - - device_model -+ - smbios_firmware -+ - acpi_firmware - - display - - xauthority - - vncconsole -Index: xen-4.2.1-testing/tools/python/README.XendConfig -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/README.XendConfig -+++ xen-4.2.1-testing/tools/python/README.XendConfig -@@ -120,6 +120,8 @@ otherConfig - image.vncdisplay - image.vncunused - image.hvm.device_model -+ image.hvm.smbios_firmware -+ image.hvm.apci_firmware - image.hvm.display - image.hvm.xauthority - image.hvm.vncconsole diff --git a/xend-migration-domname-fix.patch b/xend-migration-domname-fix.patch deleted file mode 100644 index 4cefe25..0000000 --- a/xend-migration-domname-fix.patch +++ /dev/null @@ -1,35 +0,0 @@ -setName() writes the new name to xenstore/Dompath too, so that those read -domname from xenstore (like 'virsh list') could get correct value. -2nd hunk prevents writing xenstore if not "checkpoint", otherwise, vm -destroyed but there is still VM entry in xenstore. - -Signed-off-by: Chunyan Liu -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1963,6 +1963,8 @@ class XendDomainInfo: - self.info['name_label'] = name - if to_store: - self.storeVm("name", name) -+ if self.dompath: -+ self.storeDom("name", name) - - def getName(self): - return self.info['name_label'] -Index: xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendCheckpoint.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendCheckpoint.py -@@ -188,7 +188,10 @@ def save(fd, dominfo, network, live, dst - dominfo.destroy() - dominfo.testDeviceComplete() - try: -- dominfo.setName(domain_name) -+ if checkpoint: -+ dominfo.setName(domain_name) -+ else: -+ dominfo.setName(domain_name, False) - except VmError: - # Ignore this. The name conflict (hopefully) arises because we - # are doing localhost migration; if we are doing a suspend of a diff --git a/xend-traditional-qemu.patch b/xend-traditional-qemu.patch new file mode 100644 index 0000000..be8ceff --- /dev/null +++ b/xend-traditional-qemu.patch @@ -0,0 +1,6058 @@ +From 9ca313aa0824f2d350a7a6c9b1ef6c47e0408f1d Mon Sep 17 00:00:00 2001 +From: aliguori +Date: Sat, 23 Aug 2008 23:27:37 +0000 +Subject: [PATCH] VNC: Support for ExtendedKeyEvent client message + +This patch adds support for the ExtendedKeyEvent client message. This message +allows a client to send raw scan codes directly to the server. If the client +and server are using the same keymap, then it's unnecessary to use the '-k' +option with QEMU when this extension is supported. + +This is extension is currently only implemented by gtk-vnc based clients +(gvncviewer, virt-manager, vinagre, etc.). + +Signed-off-by: Anthony Liguori + + + +git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5076 c046a42c-6fe2-441c-8c8c-71466251a162 +--- + vnc.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- + 1 files changed, 50 insertions(+), 9 deletions(-) + +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/vnc.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/vnc.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/vnc.c +@@ -1285,35 +1285,22 @@ static void press_key_altgr_down(VncStat + } + } + +-static void do_key_event(VncState *vs, int down, uint32_t sym) ++static void do_key_event(VncState *vs, int down, int keycode, int sym, int shift) + { +- int keycode; + int shift_keys = 0; +- int shift = 0; + int keypad = 0; + int altgr = 0; + int altgr_keys = 0; + + if (is_graphic_console()) { +- if (sym >= 'A' && sym <= 'Z') { +- sym = sym - 'A' + 'a'; +- shift = 1; +- } +- else { ++ if (!shift) + shift = keysym_is_shift(vs->kbd_layout, sym & 0xFFFF); +- } + + altgr = keysym_is_altgr(vs->kbd_layout, sym & 0xFFFF); + } + shift_keys = vs->modifiers_state[0x2a] | vs->modifiers_state[0x36]; + altgr_keys = vs->modifiers_state[0xb8]; + +- keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF); +- if (keycode == 0) { +- fprintf(stderr, "Key lost : keysym=0x%x(%d)\n", sym, sym); +- return; +- } +- + /* QEMU console switch */ + switch(keycode) { + case 0x2a: /* Left Shift */ +@@ -1342,6 +1329,11 @@ static void do_key_event(VncState *vs, i + } + break; + case 0x3a: /* CapsLock */ ++ if(!down){ ++ vs->modifiers_state[keycode] ^= 1; ++ kbd_put_keycode(keycode | 0x80); ++ } ++ return; + case 0x45: /* NumLock */ + if (down) { + kbd_put_keycode(keycode & 0x7f); +@@ -1445,7 +1437,28 @@ static void do_key_event(VncState *vs, i + + static void key_event(VncState *vs, int down, uint32_t sym) + { +- do_key_event(vs, down, sym); ++ int keycode; ++ int shift = 0; ++ ++ if ( sym == 0xffea && keyboard_layout && !strcmp(keyboard_layout,"es") ) ++ sym = 0xffe9; ++ ++ if (sym >= 'A' && sym <= 'Z' && is_graphic_console()) { ++ sym = sym - 'A' + 'a'; ++ shift = 1; ++ } ++ keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF); ++ do_key_event(vs, down, keycode, sym, shift); ++} ++ ++static void ext_key_event(VncState *vs, int down, ++ uint32_t sym, uint16_t keycode) ++{ ++ /* if the user specifies a keyboard layout, always use it */ ++ if (keyboard_layout) ++ key_event(vs, down, sym); ++ else ++ do_key_event(vs, down, keycode, sym, 0); + } + + static void framebuffer_set_updated(VncState *vs, int x, int y, int w, int h) +@@ -1534,6 +1547,15 @@ static void framebuffer_update_request(V + qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock)); + } + ++static void send_ext_key_event_ack(VncState *vs) ++{ ++ vnc_write_u8(vs, 0); ++ vnc_write_u8(vs, 0); ++ vnc_write_u16(vs, 1); ++ vnc_framebuffer_update(vs, 0, 0, ds_get_width(vs->ds), ds_get_height(vs->ds), -258); ++ vnc_flush(vs); ++} ++ + static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) + { + int i; +@@ -1562,6 +1584,9 @@ static void set_encodings(VncState *vs, + case -257: + vs->has_pointer_type_change = 1; + break; ++ case -258: ++ send_ext_key_event_ack(vs); ++ break; + case 0x574D5669: + vs->has_WMVi = 1; + default: +@@ -1734,6 +1759,25 @@ static int protocol_client_msg(VncState + } + + set_encodings(vs, (int32_t *)(data + 4), limit); ++ ++ /* ++ * The initialization of a VNC connection can race with xenfb changing ++ * the resolution. This happens when the VNC connection is already ++ * established, but the client has not yet advertised has_resize, so it ++ * won't get notified of the switch. ++ * ++ * Therefore we resend the resolution as soon as the client has sent its ++ * encodings. ++ */ ++ if (vs->has_resize) { ++ /* Resize the VNC window */ ++ vnc_write_u8(vs, 0); /* msg id */ ++ vnc_write_u8(vs, 0); ++ vnc_write_u16(vs, 1); /* number of rects */ ++ vnc_framebuffer_update(vs, 0, 0, vs->serverds.width, vs->serverds.height, -223); ++ ++ vnc_flush(vs); ++ } + break; + case 3: + if (len == 1) +@@ -1774,6 +1818,24 @@ static int protocol_client_msg(VncState + + client_cut_text(vs, read_u32(data, 4), (char *)(data + 8)); + break; ++ case 255: ++ if (len == 1) ++ return 2; ++ ++ switch (read_u8(data, 1)) { ++ case 0: ++ if (len == 2) ++ return 12; ++ ++ ext_key_event(vs, read_u16(data, 2), ++ read_u32(data, 4), read_u32(data, 8)); ++ break; ++ default: ++ printf("Msg: %d\n", read_u16(data, 0)); ++ vnc_client_error(vs); ++ break; ++ } ++ break; + default: + printf("Msg: %d\n", data[0]); + vnc_client_error(vs); +@@ -2445,10 +2507,11 @@ void vnc_display_init(DisplayState *ds) + + vs->ds = ds; + +- if (!keyboard_layout) +- keyboard_layout = "en-us"; ++ if (keyboard_layout) ++ vs->kbd_layout = init_keyboard_layout(keyboard_layout); ++ else ++ vs->kbd_layout = init_keyboard_layout("en-us"); + +- vs->kbd_layout = init_keyboard_layout(keyboard_layout); + if (!vs->kbd_layout) + exit(1); + vs->modifiers_state[0x45] = 1; /* NumLock on - on boot */ +@@ -2564,6 +2627,7 @@ int vnc_display_password(DisplayState *d + if (password && password[0]) { + if (!(vs->password = qemu_strdup(password))) + return -1; ++ vs->auth = VNC_AUTH_VNC; + } + + return 0; +Index: xen-4.3.0-testing/tools/hotplug/Linux/init.d/sysconfig.xendomains +=================================================================== +--- xen-4.3.0-testing.orig/tools/hotplug/Linux/init.d/sysconfig.xendomains ++++ xen-4.3.0-testing/tools/hotplug/Linux/init.d/sysconfig.xendomains +@@ -98,7 +98,6 @@ XENDOMAINS_RESTORE=true + # Note that the script tries to be clever if both RESTORE and AUTO are + # set: It will first restore saved domains and then only start domains + # in AUTO which are not running yet. +-# Note that the name matching is somewhat fuzzy. + # + XENDOMAINS_AUTO=/etc/xen/auto + +Index: xen-4.3.0-testing/tools/examples/xend-config.sxp +=================================================================== +--- xen-4.3.0-testing.orig/tools/examples/xend-config.sxp ++++ xen-4.3.0-testing/tools/examples/xend-config.sxp +@@ -58,11 +58,12 @@ + + + #(xend-http-server no) +-#(xend-unix-server no) ++(xend-unix-server yes) + #(xend-tcp-xmlrpc-server no) + #(xend-unix-xmlrpc-server yes) ++# Only enable xend-relocation-server on trusted networks as it lacks ++# encryption and authentication. + #(xend-relocation-server no) +-(xend-relocation-server yes) + #(xend-relocation-ssl-server no) + #(xend-udev-event-server no) + +@@ -170,7 +171,12 @@ + # 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) ++# SuSE users note: ++# On openSUSE >= 11.1 and SLES >= 11, networks should be configured using ++# native platform tool - YaST. vif-bridge and qemu-ifup can be used to ++# connect vifs to the YaST-managed networks. ++#(network-script network-bridge) ++(network-script ) + + # 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 +@@ -194,6 +200,26 @@ + #(network-script network-route) + #(vif-script vif-route) + ++# SuSE users note: ++# If using a routed network configuration it is advised to NOT use ++# network-route and vif-route scripts but instead use sysconfig scripts ++# in dom0 and vif-route-ifup script to "connect" the domU vif to dom0. ++# Since this configuration requires a vif sysconfig script in dom0, a static ++# vif name must be used. E.g. in dom0 the vif sysconfig script ++# (/etc/sysconfig/network/ifcfg-xen1.0) may contain ++# ++# NAME='XEN vm 1 virtual interface 0' ++# BOOTPROTO='static' ++# STARTMODE='hotplug' ++# ... ++# ++# The corresponding domain vif configuration would contain e.g. ++# vif=[ 'mac=00:16:3e:aa:bb:cc,script=vif-route-ifup,vifname=xen1.0', ] ++# ++# If the vif-route-ifup script will be used for all domains, it can be ++# set here as the default vif script, alleviating the need for ++# 'script=' in domain vif configuration. ++#(vif-script vif-route-ifup) + + ## Use the following if network traffic is routed with NAT, as an alternative + # to the settings for bridged networking given above. +@@ -203,7 +229,7 @@ + # dom0-min-mem is the lowest permissible memory level (in MB) for dom0. + # This is a minimum both for auto-ballooning (as enabled by + # enable-dom0-ballooning below) and for xm mem-set when applied to dom0. +-(dom0-min-mem 196) ++(dom0-min-mem 512) + + # Whether to enable auto-ballooning of dom0 to allow domUs to be created. + # If enable-dom0-ballooning = no, dom0 will never balloon out. +@@ -224,6 +250,9 @@ + (dom0-cpus 0) + + # Whether to enable core-dumps when domains crash. ++# This setting overrides the per-domain dump value 'on_crash' and causes a ++# core dump on all crashed domains. For finer grain control, it is best to ++# disable this setting (which is default) and use the per-domain controls. + #(enable-dump no) + + # The tool used for initiating virtual TPM migration +@@ -295,6 +324,70 @@ + # device assignment could really work properly even after we do this. + #(pci-passthrough-strict-check yes) + ++# Domain Locking ++# In a multihost environment, domain locking provides a simple mechanism that ++# prevents simultaneously running a domain on more than one host. ++# ++# If enabled, xend will execute a external lock utility (defined below) ++# on each domain start and stop event. Disabled by default. Set to yes ++# to enable domain locking. ++# ++#(xend-domain-lock no) ++ ++# Path where domain lock is stored if xend-domain-lock is enabled. ++# Note: This path must be accessible to all VM Servers participating ++# in domain locking, e.g. by specifying a shared mount point. ++# Lock is placed in //. ++# Default is /var/lib/xen/images/vm_locks/ ++# ++#(xend-domain-lock-path /var/lib/images/vm_locks) ++ ++# External locking utility called by xend for acquiring/releasing ++# domain lock. By default /etc/xen/scripts/domain-lock will be used ++# if xend-domain-lock is set to yes. Set to path of custom locking ++# utility to override the default. ++# ++# Synopsis of lock-util: ++# lock-util [-l|-u] -n -i -p path" ++# -l Acquire (create) lock ++# -u Remove lock ++# -n vm-name Name of domain ++# -i vm-id Id or UUID of domain ++# -p phy-host Name of physical host (dom0) ++# path // ++# Return 0 on success, non-zero on error. ++# ++# lock-util [-s] -i path" ++# -s Lock status. If lock is acquired, print any contents ++# on stdout and return 0. Return non-zero if lock is ++# available. ++# path // ++# If lock is acquired, print any contents on stdout and return 0. ++# Return non-zero if lock is available. ++# ++# Default lock-util behavior: ++# On domain start event, domain-lock will create and flock(1) ++# ///lock. Every two seconds it ++# will write , , , and to the lock. ++# is running counter. ++# On domain stop event, domain-lock will unlock and remove ++# ///lock. ++# ++# Note: If xend-domain-lock-path is a cluster-unaware file system, ++# administrator intervention may be required to remove stale ++# locks. Consider two hosts using NFS for xend-domain-lock-path ++# when HostA, running vm1, crashes. HostB could not acquire a ++# lock for vm1 since the NFS server holds an exclusive lock ++# acquired by HostA. The lock file must be manually removed ++# before starting vm1 on HostB. ++# ++#(xend-domain-lock-utility domain-lock) ++ ++# Some locking mechanism provide cluster wide locking service like sfex. ++# And that requires a shared locking device. ++#(xend-domain-lock-utility domain-lock-sfex) ++#(xend-domain-lock-device "/dev/iwmvg/hbdevice") ++ + # If we have a very big scsi device configuration, start of xend is slow, + # because xend scans all the device paths to build its internal PSCSI device + # list. If we need only a few devices for assigning to a guest, we can reduce +Index: xen-4.3.0-testing/tools/python/xen/xm/create.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xm/create.py ++++ xen-4.3.0-testing/tools/python/xen/xm/create.py +@@ -36,7 +36,7 @@ from xen.xend.server.DevConstants import + from xen.util import blkif + from xen.util import vscsi_util + import xen.util.xsm.xsm as security +-from xen.xm.main import serverType, SERVER_XEN_API, get_single_vm ++from xen.xm.main import serverType, SERVER_XEN_API, SERVER_LEGACY_XMLRPC, get_single_vm + from xen.util import utils, auxbin + from xen.util.pci import dev_dict_to_sxp, \ + parse_pci_name_extended, PciDeviceParseError +@@ -73,7 +73,7 @@ gopts.opt('quiet', short='q', + use="Quiet.") + + gopts.opt('path', val='PATH', +- fn=set_value, default='.:' + auxbin.xen_configdir(), ++ fn=set_value, default='.:' + auxbin.xen_configdir() + "/vm", + use="Search path for configuration scripts. " + "The value of PATH is a colon-separated directory list.") + +@@ -242,6 +242,10 @@ gopts.var('viridian', val='VIRIDIAN', + use="""Expose Viridian interface to x86 HVM guest? + (Default is 0).""") + ++gopts.var('extid', val='EXTID', ++ fn=set_int, default=0, ++ use="Specify extention ID for a HVM domain.") ++ + gopts.var('acpi', val='ACPI', + fn=set_int, default=1, + use="Disable or enable ACPI of HVM domain.") +@@ -473,6 +477,26 @@ gopts.var('nfs_root', val="PATH", + fn=set_value, default=None, + use="Set the path of the root NFS directory.") + ++gopts.var('smbios_firmware', val='FILE', ++ fn=set_value, default=None, ++ use="Path to a file that contains extra SMBIOS firmware structures.") ++ ++gopts.var('acpi_firmware', val='FILE', ++ fn=set_value, default=None, ++ use="Path to a file that contains extra ACPI firmware tables.") ++ ++gopts.var('actmem', val='NUM', ++ fn=set_value, default='0', ++ use="Number of pages to swap.") ++ ++gopts.var('xenpaging_file', val='PATH', ++ fn=set_value, default=None, ++ use="pagefile to use (optional)") ++ ++gopts.var('xenpaging_extra', val='string1,string2', ++ fn=append_value, default=[], ++ use="additional args for xenpaging (optional)") ++ + gopts.var('device_model', val='FILE', + fn=set_value, default=None, + use="Path to device model program.") +@@ -517,6 +541,21 @@ gopts.var('usbdevice', val='NAME', + fn=set_value, default='', + use="Name of USB device to add?") + ++gopts.var('watchdog', val='NAME', ++ fn=set_value, default='', ++ use="Watchdog device to use. May be ib700 or i6300esb") ++ ++gopts.var('watchdog_action', val='reset|shutdown|poweroff|pause|none|dump', ++ fn=set_value, default="reset", ++ use="""Action when watchdog timer expires: ++ - reset: Default, forcefully reset the guest; ++ - shutdown: Gracefully shutdown the guest (not recommended); ++ - poweroff: Forcefully power off the guest; ++ - pause: Pause the guest; ++ - none: Do nothing; ++ - dump: Automatically dump the guest; ++ """) ++ + gopts.var('description', val='NAME', + fn=set_value, default='', + use="Description of a domain") +@@ -1032,7 +1071,11 @@ def configure_hvm(config_image, vals): + args = [ 'acpi', 'apic', + 'boot', + 'cpuid', 'cpuid_check', ++ 'actmem', ++ 'xenpaging_file', ++ 'xenpaging_extra', + 'device_model', 'display', ++ 'smbios_firmware', 'acpi_firmware', + 'fda', 'fdb', + 'gfx_passthru', 'guest_os_type', + 'hap', 'hpet', +@@ -1047,7 +1090,8 @@ def configure_hvm(config_image, vals): + 'timer_mode', + 'usb', 'usbdevice', + 'vcpus', 'vnc', 'vncconsole', 'vncdisplay', 'vnclisten', +- 'vncunused', 'viridian', 'vpt_align', ++ 'vncunused', 'vpt_align', ++ 'watchdog', 'watchdog_action', + 'xauthority', 'xen_extended_power_mgmt', 'xen_platform_pci', + 'memory_sharing' ] + +@@ -1056,6 +1100,10 @@ def configure_hvm(config_image, vals): + config_image.append([a, vals.__dict__[a]]) + if vals.vncpasswd is not None: + config_image.append(['vncpasswd', vals.vncpasswd]) ++ if vals.extid and vals.extid == 1: ++ config_image.append(['viridian', vals.extid]) ++ elif vals.viridian: ++ config_image.append(['viridian', vals.viridian]) + + + def make_config(vals): +@@ -1274,9 +1322,8 @@ def preprocess_access_control(vals): + + def preprocess_ip(vals): + if vals.ip or vals.dhcp != 'off': +- dummy_nfs_server = '127.0.255.255' + ip = (vals.ip +- + ':' + (vals.nfs_server or dummy_nfs_server) ++ + ':' + (vals.nfs_server or '') + + ':' + vals.gateway + + ':' + vals.netmask + + ':' + vals.hostname +@@ -1465,7 +1512,7 @@ def main(argv): + except IOError, exn: + raise OptionError("Cannot read file %s: %s" % (config, exn[1])) + +- if serverType == SERVER_XEN_API: ++ if serverType == SERVER_XEN_API or serverType == SERVER_LEGACY_XMLRPC: + from xen.xm.xenapi_create import sxp2xml + sxp2xml_inst = sxp2xml() + doc = sxp2xml_inst.convert_sxp_to_xml(config, transient=True) +@@ -1473,7 +1520,7 @@ def main(argv): + if opts.vals.dryrun and not opts.is_xml: + SXPPrettyPrint.prettyprint(config) + +- if opts.vals.xmldryrun and serverType == SERVER_XEN_API: ++ if opts.vals.xmldryrun: + print doc.toprettyxml() + + if opts.vals.dryrun or opts.vals.xmldryrun: +Index: xen-4.3.0-testing/docs/man/xm.pod.1 +=================================================================== +--- xen-4.3.0-testing.orig/docs/man/xm.pod.1 ++++ xen-4.3.0-testing/docs/man/xm.pod.1 +@@ -79,7 +79,7 @@ in the config file. See L + format, and possible options used in either the configfile or for I. + + I can either be an absolute path to a file, or a relative +-path to a file located in /etc/xen. ++path to a file located in /etc/xen/vm. + + Create will return B as the domain is started. This B mean the guest OS in the domain has actually booted, or is +@@ -160,7 +160,7 @@ B + + xm create Fedora4 + +-This creates a domain with the file /etc/xen/Fedora4, and returns as ++This creates a domain with the file /etc/xen/vm/Fedora4, and returns as + soon as it is run. + + =item I +@@ -299,7 +299,8 @@ scheduling by the Xen hypervisor. + + =item B + +-FIXME: Why would you ever see this state? ++The guest has requested to be shutdown, rebooted or suspended, and the ++domain is in the process of being destroyed in response. + + =item B + +@@ -312,8 +313,6 @@ restart on crash. See L f + The domain is in process of dying, but hasn't completely shutdown or + crashed. + +-FIXME: Is this right? +- + =back + + B +@@ -737,8 +736,6 @@ Xen ships with a number of domain schedu + time with the B parameter on the Xen command line. By + default B is used for scheduling. + +-FIXME: we really need a scheduler expert to write up this section. +- + =over 4 + + =item B [ B<-d> I [ B<-w>[B<=>I] | B<-c>[B<=>I] ] ] +@@ -788,8 +785,6 @@ The normal EDF scheduling usage in nanos + + The normal EDF scheduling usage in nanoseconds + +-FIXME: these are lame, should explain more. +- + =item I + + Scaled period if domain is doing heavy I/O. +@@ -939,9 +934,6 @@ the default setting in xend-config.sxp f + + Passes the specified IP Address to the adapter on creation. + +-FIXME: this currently appears to be B. I'm not sure under what +-circumstances this should actually work. +- + =item BI + + The MAC address that the domain will see on its Ethernet device. If +@@ -967,9 +959,6 @@ Removes the network device from the doma + I is the virtual interface device number within the domain + (i.e. the 3 in vif22.3). + +-FIXME: this is currently B. Network devices aren't completely +-removed from domain 0. +- + =item B [B<-l>|B<--long>]> I + + List virtual network interfaces for a domain. The returned output is +Index: xen-4.3.0-testing/docs/man/xmdomain.cfg.pod.5 +=================================================================== +--- xen-4.3.0-testing.orig/docs/man/xmdomain.cfg.pod.5 ++++ xen-4.3.0-testing/docs/man/xmdomain.cfg.pod.5 +@@ -4,9 +4,9 @@ xmdomain.cfg - xm domain config file for + + =head1 SYNOPSIS + +- /etc/xen/myxendomain +- /etc/xen/myxendomain2 +- /etc/xen/auto/myxenautostarted ++ /etc/xen/auto/ ++ /etc/xen/examples/ ++ /etc/xen/vm/ + + =head1 DESCRIPTION + +@@ -14,14 +14,14 @@ The B(1) program uses python executa + domains to create from scratch. Each of these config files needs to + contain a number of required options, and may specify many more. + +-Domain configuration files live in /etc/xen by default, if you store ++Domain configuration files live in /etc/xen/vm by default. If you store + config files anywhere else the full path to the config file must be + specified in the I command. + + /etc/xen/auto is a special case. Domain config files in that + directory will be started automatically at system boot if the + xendomain init script is enabled. The contents of /etc/xen/auto +-should be symlinks to files in /etc/xen to allow I to be ++should be symlinks to files in /etc/xen/vm to allow I to be + used without full paths. + + Options are specified by I statements in the +@@ -243,6 +243,25 @@ this the xen kernel must be compiled wit + + This defaults to 1, meaning running the domain as a UP. + ++=item B ++ ++Specify a path to a file that contains extra ACPI firmware tables to pass in to ++a guest. The file can contain several tables in their binary AML form ++concatenated together. Each table self describes its length so no additional ++information is needed. These tables will be added to the ACPI table set in the ++guest. Note that existing tables cannot be overridden by this feature. For ++example this cannot be used to override tables like DSDT, FADT, etc. ++ ++=item B ++ ++Specify a path to a file that contains extra SMBIOS firmware structures to pass ++in to a guest. The file can contain a set DMTF predefined structures which will ++override the internal defaults. Not all predefined structures can be overridden, ++only the following types: 0, 1, 2, 3, 11, 22, 39. The file can also contain any ++number of vendor defined SMBIOS structures (type 128 - 255). Since SMBIOS ++structures do not present their overall size, each entry in the file must be ++preceded by a 32b integer indicating the size of the next structure. ++ + =back + + =head1 DOMAIN SHUTDOWN OPTIONS +@@ -333,16 +352,10 @@ at hda1, which is the root filesystem. + + =item I + +-FIXME: write me +- + =item I + +-FIXME: write me +- + =item I + +-FIXME: write me +- + =back + + =head1 SEE ALSO +Index: xen-4.3.0-testing/tools/python/xen/xend/server/DevController.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/server/DevController.py ++++ xen-4.3.0-testing/tools/python/xen/xend/server/DevController.py +@@ -149,13 +149,16 @@ class DevController: + (status, err) = self.waitForBackend(devid) + + if status == Timeout: +- self.destroyDevice(devid, False) ++ #Clean timeout backend resource ++ dev = self.convertToDeviceNumber(devid) ++ self.writeBackend(dev, HOTPLUG_STATUS_NODE, HOTPLUG_STATUS_ERROR) ++ self.destroyDevice(devid, True) + raise VmError("Device %s (%s) could not be connected. " + "Hotplug scripts not working." % + (devid, self.deviceClass)) + + elif status == Error: +- self.destroyDevice(devid, False) ++ self.destroyDevice(devid, True) + if err is None: + raise VmError("Device %s (%s) could not be connected. " + "Backend device not found." % +@@ -554,7 +557,17 @@ class DevController: + + xswatch(statusPath, hotplugStatusCallback, ev, result) + +- ev.wait(DEVICE_CREATE_TIMEOUT) ++ for i in range(1, 50): ++ ev.wait(DEVICE_CREATE_TIMEOUT/50) ++ status = xstransact.Read(statusPath) ++ if status is not None: ++ if status == HOTPLUG_STATUS_ERROR: ++ result['status'] = Error ++ elif status == HOTPLUG_STATUS_BUSY: ++ result['status'] = Busy ++ else: ++ result['status'] = Connected ++ break + + err = xstransact.Read(backpath, HOTPLUG_ERROR_NODE) + +@@ -571,7 +584,12 @@ class DevController: + + xswatch(statusPath, deviceDestroyCallback, ev, result) + +- ev.wait(DEVICE_DESTROY_TIMEOUT) ++ for i in range(1, 50): ++ ev.wait(DEVICE_DESTROY_TIMEOUT/50) ++ status = xstransact.Read(statusPath) ++ if status is None: ++ result['status'] = Disconnected ++ break + + return result['status'] + +@@ -592,6 +610,31 @@ class DevController: + return (Missing, None) + + ++ 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-4.3.0-testing/tools/python/xen/xend/XendBootloader.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendBootloader.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendBootloader.py +@@ -12,7 +12,7 @@ + # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + # + +-import os, select, errno, stat, signal, tty ++import os, select, errno, stat, signal, tty, time + import random + import shlex + from xen.xend import sxp +@@ -38,8 +38,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, 500): ++ avail = os.access(disk, os.R_OK) ++ if avail: ++ break ++ time.sleep(.1) ++ ++ if not avail: ++ msg = "Disk '%s' isn't accessible" % disk + log.error(msg) + raise VmError(msg) + +Index: xen-4.3.0-testing/tools/python/xen/xend/XendDomainInfo.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -74,7 +74,7 @@ from xen.xend.XendPSCSI import XendPSCSI + from xen.xend.XendDSCSI import XendDSCSI, XendDSCSI_HBA + + MIGRATE_TIMEOUT = 30.0 +-BOOTLOADER_LOOPBACK_DEVICE = '/dev/xvdp' ++BOOTLOADER_LOOPBACK_DEVICES = ['/dev/xvd' + chr(x) for x in range(ord('z'), ord('d'), -1)] + + xc = xen.lowlevel.xc.xc() + xoptions = XendOptions.instance() +@@ -303,7 +303,8 @@ def dom_get(dom): + return None + + from xen.xend.server.pciif import parse_pci_name, PciDevice,\ +- get_assigned_pci_devices, get_all_assigned_pci_devices ++ get_assigned_pci_devices, get_all_assigned_pci_devices,\ ++ prepare_host_pci_devices, reattach_host_pci_devices + + + def do_FLR(domid, is_hvm): +@@ -317,6 +318,20 @@ def do_FLR(domid, is_hvm): + "parse it's resources - "+str(e)) + dev.do_FLR(is_hvm, xoptions.get_pci_dev_assign_strict_check()) + ++def prepare_domain_pci_devices(domconfig): ++ ordered_refs = domconfig.ordered_device_refs() ++ for dev_uuid in ordered_refs: ++ devclass, devconfig = domconfig['devices'][dev_uuid] ++ if devclass == 'pci': ++ prepare_host_pci_devices(devconfig) ++ ++def reattach_domain_pci_devices(domconfig): ++ ordered_refs = domconfig.ordered_device_refs() ++ for dev_uuid in ordered_refs: ++ devclass, devconfig = domconfig['devices'][dev_uuid] ++ if devclass == 'pci': ++ reattach_host_pci_devices(devconfig) ++ + class XendDomainInfo: + """An object represents a domain. + +@@ -470,6 +485,8 @@ class XendDomainInfo: + + if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, XEN_API_VM_POWER_STATE_SUSPENDED, XEN_API_VM_POWER_STATE_CRASHED): + try: ++ prepare_domain_pci_devices(self.info); ++ self.acquire_running_lock(); + XendTask.log_progress(0, 30, self._constructDomain) + XendTask.log_progress(31, 60, self._initDomain) + +@@ -496,6 +513,7 @@ class XendDomainInfo: + state = self._stateGet() + if state in (DOM_STATE_SUSPENDED, DOM_STATE_HALTED): + try: ++ prepare_domain_pci_devices(self.info) + self._constructDomain() + + try: +@@ -712,6 +730,8 @@ class XendDomainInfo: + the device. + """ + ++ if self.domid is None: ++ return + self.iommu_check_pod_mode() + + # Test whether the devices can be assigned +@@ -851,6 +871,9 @@ class XendDomainInfo: + + if self.domid is not None: + try: ++ if dev_type == 'pci': ++ prepare_host_pci_devices(dev_config_dict) ++ + dev_config_dict['devid'] = devid = \ + self._createDevice(dev_type, dev_config_dict) + if dev_type == 'tap2': +@@ -864,6 +887,7 @@ class XendDomainInfo: + if dev_type == 'pci': + for dev in dev_config_dict['devs']: + XendAPIStore.deregister(dev['uuid'], 'DPCI') ++ reattach_host_pci_devices(dev_config_dict) + elif dev_type == 'vscsi': + for dev in dev_config_dict['devs']: + XendAPIStore.deregister(dev['uuid'], 'DSCSI') +@@ -908,6 +932,10 @@ class XendDomainInfo: + dev_config = pci_convert_sxp_to_dict(dev_sxp) + dev = dev_config['devs'][0] + ++ # For attach only. For boot, prepare work has been done already in earlier stage. ++ if self.domid is not None and pci_state == 'Initialising' and pci_sub_state != 'Booting': ++ prepare_host_pci_devices(dev_config) ++ + stubdomid = self.getStubdomDomid() + # Do HVM specific processing + if self.info.is_hvm(): +@@ -984,6 +1012,9 @@ class XendDomainInfo: + new_dev_sxp = dev_control.configuration(devid) + self.info.device_update(dev_uuid, new_dev_sxp) + ++ if pci_state == 'Closing': ++ reattach_host_pci_devices(dev_config) ++ + # If there is no device left, destroy pci and remove config. + if num_devs == 0: + if self.info.is_hvm(): +@@ -1203,6 +1234,9 @@ class XendDomainInfo: + except ValueError: + pass + devid = dev_control.convertToDeviceNumber(dev) ++ else: ++ # devid could be a name, e.g. hdc ++ devid = dev_control.convertToDeviceNumber(devid) + dev_info = self._getDeviceInfo_vbd(devid) + if dev_info is None: + raise VmError("Device %s not connected" % devid) +@@ -1295,8 +1329,15 @@ class XendDomainInfo: + frontpath = self.getDeviceController(deviceClass).frontendPath(dev) + backpath = xstransact.Read(frontpath, "backend") + thread.start_new_thread(self.getDeviceController(deviceClass).finishDeviceCleanup, (backpath, path)) +- +- rc = self.getDeviceController(deviceClass).destroyDevice(devid, force) ++ if deviceClass =='vusb': ++ dev = self.getDeviceController(deviceClass).convertToDeviceNumber(devid) ++ state = self.getDeviceController(deviceClass).readBackend(dev, 'state') ++ if state == '1': ++ rc = self.getDeviceController(deviceClass).destroyDevice(devid, True) ++ else: ++ rc = self.getDeviceController(deviceClass).destroyDevice(devid, force) ++ else: ++ rc = self.getDeviceController(deviceClass).destroyDevice(devid, force) + if not force and rm_cfg: + # The backend path, other than the device itself, + # has to be passed because its accompanied frontend +@@ -1459,6 +1500,52 @@ class XendDomainInfo: + pci_conf = self.info['devices'][dev_uuid][1] + return map(pci_dict_to_bdf_str, pci_conf['devs']) + ++ def capAndSetMemoryTarget(self, target): ++ """Potentially lowers the requested target to the largest possible ++ value (i.e., caps it), and then sets the memory target of this domain ++ to that value. ++ @param target in MiB. ++ """ ++ max_target = 0 ++ if self.domid == 0: ++ try: ++ from balloon import get_dom0_max_target ++ max_target = get_dom0_max_target() / 1024 ++ except: ++ # It's nice to cap the max at sane values, but harmless to set ++ # them high. Carry on. ++ pass ++ if max_target and target > max_target: ++ log.debug("Requested memory target %d MiB; maximum reasonable is %d MiB.", ++ target, max_target) ++ target = max_target ++ self.setMemoryTarget(target) ++ ++ def chgvncpasswd(self, passwd): ++ if self._stateGet() != DOM_STATE_HALTED: ++ path = '/local/domain/0/backend/vfb/%u/0/' % self.getDomid() ++ xstransact.Write(path, 'vncpasswd', passwd) ++ self.image.signalDeviceModel("chgvncpasswd", "vncpasswdchged") ++ ++ for dev_uuid, (dev_type, dev_info) in self.info['devices'].items(): ++ if dev_type == 'vfb': ++ dev_info['vncpasswd'] = passwd ++ dev_info['other_config']['vncpasswd'] = passwd ++ self.info.device_update(dev_uuid, cfg_xenapi = dev_info) ++ break ++ xen.xend.XendDomain.instance().managed_config_save(self) ++ ++ def setSwapTarget(self, target): ++ """Set the swap target of this domain. ++ @param target: In MiB. ++ """ ++ log.debug("Setting swap target of domain %s (%s) to %d MiB.", ++ self.info['name_label'], str(self.domid), target) ++ ++ if self.domid > 0: ++ self.storeDom("memory/target-tot_pages", target * 1024) ++ self.info['platform']['actmem'] = str(target) ++ + def setMemoryTarget(self, target): + """Set the memory target of this domain. + @param target: In MiB. +@@ -1923,6 +2010,8 @@ class XendDomainInfo: + self.info['name_label'] = name + if to_store: + self.storeVm("name", name) ++ if self.dompath: ++ self.storeDom("name", name) + + def getName(self): + return self.info['name_label'] +@@ -2247,6 +2336,8 @@ class XendDomainInfo: + self.info['name_label'], self.domid, self.info['uuid'], + new_name, new_uuid) + self._unwatchVm() ++ if self.image: ++ self.image.destroyXenPaging() + self._releaseDevices() + # Remove existing vm node in xenstore + self._removeVm() +@@ -2283,7 +2374,7 @@ class XendDomainInfo: + # To prohibit directory traversal + based_name = os.path.basename(self.info['name_label']) + +- coredir = "/var/xen/dump/%s" % (based_name) ++ coredir = "/var/lib/xen/dump/%s" % (based_name) + if not os.path.exists(coredir): + try: + mkdir.parents(coredir, stat.S_IRWXU) +@@ -2333,6 +2424,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) +@@ -2734,7 +2829,10 @@ class XendDomainInfo: + from xen.xend import XendDomain + doms = XendDomain.instance().list('all') + for dom in filter (lambda d: d.domid != self.domid, doms): +- cpuinfo = dom.getVCPUInfo() ++ try: ++ cpuinfo = dom.getVCPUInfo() ++ except: ++ continue + for vcpu in sxp.children(cpuinfo, 'vcpu'): + if sxp.child_value(vcpu, 'online') == 0: continue + cpumap = list(sxp.child_value(vcpu,'cpumap')) +@@ -2884,7 +2982,7 @@ class XendDomainInfo: + + self.guest_bitsize = self.image.getBitSize() + # Make sure there's enough RAM available for the domain +- balloon.free(memory + shadow + vtd_mem, self) ++ balloon.free(memory + shadow + vtd_mem + 512, self) + + # Set up the shadow memory + shadow_cur = xc.shadow_mem_control(self.domid, shadow / 1024) +@@ -2919,6 +3017,9 @@ class XendDomainInfo: + + self._createDevices() + ++ if self.image: ++ self.image.createXenPaging() ++ + self.image.cleanupTmpImages() + + self.info['start_time'] = time.time() +@@ -2943,6 +3044,8 @@ class XendDomainInfo: + self.refresh_shutdown_lock.acquire() + try: + self.unwatchShutdown() ++ if self.image: ++ self.image.destroyXenPaging() + self._releaseDevices() + bootloader_tidy(self) + +@@ -2956,6 +3059,11 @@ class XendDomainInfo: + + self._stateSet(DOM_STATE_HALTED) + self.domid = None # Do not push into _stateSet()! ++ ++ try: ++ self.release_running_lock() ++ except: ++ log.exception("Failed to release domain lock.") + finally: + self.refresh_shutdown_lock.release() + +@@ -3011,7 +3119,7 @@ class XendDomainInfo: + # TODO: recategorise - called from XendCheckpoint + # + +- def completeRestore(self, store_mfn, console_mfn): ++ def completeRestore(self, store_mfn, console_mfn, console_port): + + log.debug("XendDomainInfo.completeRestore") + +@@ -3022,6 +3130,8 @@ class XendDomainInfo: + self.image = image.create(self, self.info) + if self.image: + self.image.createDeviceModel(True) ++ self.image.createXenPaging() ++ self.console_port = console_port + self._storeDomDetails() + self._registerWatches() + self.refreshShutdown() +@@ -3099,9 +3209,15 @@ class XendDomainInfo: + log.debug("%s KiB need to add to Memory pool" %self.alloc_mem) + MemoryPool.instance().increase_memory(self.alloc_mem) + ++ reattach_domain_pci_devices(self.info) + self._cleanup_phantom_devs(paths) + self._cleanupVm() + ++ if "change_home_server" in self.info: ++ chs = self.info["change_home_server"] ++ if (type(chs) is str and chs == "False") or \ ++ (type(chs) is bool and chs is False): ++ self.setChangeHomeServer(None) + if ("transient" in self.info["other_config"] and \ + bool(self.info["other_config"]["transient"])) or \ + ("change_home_server" in self.info and \ +@@ -3157,6 +3273,8 @@ class XendDomainInfo: + # could also fetch a parsed note from xenstore + fast = self.info.get_notes().get('SUSPEND_CANCEL') and 1 or 0 + if not fast: ++ if self.image: ++ self.image.destroyXenPaging() + self._releaseDevices() + self.testDeviceComplete() + self.testvifsComplete() +@@ -3172,6 +3290,8 @@ class XendDomainInfo: + self._storeDomDetails() + + self._createDevices() ++ if self.image: ++ self.image.createXenPaging() + log.debug("XendDomainInfo.resumeDomain: devices created") + + xc.domain_resume(self.domid, fast) +@@ -3271,32 +3391,38 @@ class XendDomainInfo: + # 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. +- +- log.info("Mounting %s on %s." % +- (fn, BOOTLOADER_LOOPBACK_DEVICE)) +- +- vbd = { +- 'mode': 'RO', +- 'device': BOOTLOADER_LOOPBACK_DEVICE, +- } +- +- from xen.xend import XendDomain +- dom0 = XendDomain.instance().privilegedDomain() +- mounted_vbd_uuid = dom0.create_vbd(vbd, disk); +- dom0._waitForDeviceUUID(mounted_vbd_uuid) +- fn = BOOTLOADER_LOOPBACK_DEVICE +- ++ # Try all possible loopback_devices ++ for loopback_device in BOOTLOADER_LOOPBACK_DEVICES: ++ log.info("Mounting %s on %s." % (fn, loopback_device)) ++ vbd = { 'mode' : 'RW', 'device' : loopback_device, } ++ try: ++ from xen.xend import XendDomain ++ dom0 = XendDomain.instance().privilegedDomain() ++ mounted_vbd_uuid = dom0.create_vbd(vbd, disk) ++ dom0._waitForDeviceFrontUUID(mounted_vbd_uuid) ++ fn = loopback_device ++ break ++ except VmError, e: ++ if str(e).find('already connected.') != -1: ++ continue ++ elif str(e).find('isn\'t accessible') != -1: ++ dom0.destroyDevice('vbd', loopback_device, force = True, rm_cfg = True) ++ continue ++ else: ++ raise ++ else: ++ raise + try: + blcfg = bootloader(blexec, fn, self, False, + bootloader_args, kernel, ramdisk, args) + finally: + if mounted: + log.info("Unmounting %s from %s." % +- (fn, BOOTLOADER_LOOPBACK_DEVICE)) +- _, vbd_info = dom0.info['devices'][mounted_vbd_uuid] +- dom0.destroyDevice(dom0.getBlockDeviceClass(vbd_info['devid']), +- BOOTLOADER_LOOPBACK_DEVICE, force = True) +- ++ (fn, loopback_device)) ++ if devtype in ['tap', 'tap2']: ++ dom0.destroyDevice('tap', loopback_device, rm_cfg = True) ++ else: ++ dom0.destroyDevice('vbd', loopback_device, rm_cfg = True) + if blcfg is None: + msg = "Had a bootloader specified, but can't find disk" + log.error(msg) +@@ -3908,6 +4034,14 @@ class XendDomainInfo: + else: + config['mode'] = 'RW' + ++ if dev_class == 'console': ++ if not config.has_key('protocol'): ++ con_type = config.get('type', '') ++ if con_type == 'vnc': ++ config['protocol'] = 'rfb' ++ elif con_type == 'sdl': ++ config['protocol'] = 'rdp' ++ + return config + + def get_dev_property(self, dev_class, dev_uuid, field): +@@ -4415,6 +4549,91 @@ class XendDomainInfo: + def has_device(self, dev_class, dev_uuid): + return (dev_uuid in self.info['%s_refs' % dev_class.lower()]) + ++ # Return name of host contained in lock file. ++ def get_lock_host(self, path): ++ lock_cmd = '%s -s -i %s ' % \ ++ (xoptions.get_xend_domain_lock_utility(), \ ++ self.info['uuid']) ++ lock_dev = xoptions.get_xend_domain_lock_device() ++ if lock_dev: ++ lock_cmd += '-x %d ' % lock_dev ++ lock_cmd += path ++ fin = os.popen(lock_cmd, 'r') ++ hostname = "unknown" ++ ++ try: ++ tokens = fin.readline().split() ++ for token in tokens: ++ item = token.split('=') ++ if item[0] == 'host': ++ hostname = item[1] ++ return hostname ++ finally: ++ fin.close() ++ ++ # Acquire a lock for the domain. No-op if domain locking is turned off. ++ def acquire_running_lock(self): ++ if not xoptions.get_xend_domain_lock(): ++ return ++ ++ log.debug("Acquiring lock for domain %s" % self.info['name_label']) ++ path = xoptions.get_xend_domain_lock_path() ++ path = os.path.join(path, self.get_uuid()) ++ ++ lock_cmd = '%s -l -p %s -n %s -i %s ' % \ ++ (xoptions.get_xend_domain_lock_utility(), \ ++ XendNode.instance().get_name(), \ ++ self.info['name_label'], \ ++ self.info['uuid']) ++ lock_dev = xoptions.get_xend_domain_lock_device() ++ if lock_dev: ++ lock_cmd += '-x %d ' % lock_dev ++ lock_cmd += path ++ ++ try: ++ if not os.path.exists(path): ++ mkdir.parents(path, stat.S_IRWXU) ++ except: ++ log.exception("%s could not be created." % path) ++ raise XendError("%s could not be created." % path) ++ ++ status = os.system(lock_cmd) >> 8 ++ if status != 0: ++ log.debug("Failed to aqcuire lock: status = %d" % status) ++ raise XendError("The VM is locked and appears to be running on host %s." % self.get_lock_host(path)) ++ ++ # Release lock for domain. No-op if domain locking is turned off. ++ def release_running_lock(self, name = None): ++ if not xoptions.get_xend_domain_lock(): ++ return ++ ++ dom_name = self.info['name_label'] ++ if name: ++ dom_name = name ++ log.debug("Releasing lock for domain %s" % dom_name) ++ ++ path = xoptions.get_xend_domain_lock_path() ++ path = os.path.join(path, self.get_uuid()) ++ ++ lock_cmd = '%s -u -p %s -n %s -i %s ' % \ ++ (xoptions.get_xend_domain_lock_utility(), \ ++ XendNode.instance().get_name(), \ ++ dom_name, \ ++ self.info['uuid']) ++ lock_dev = xoptions.get_xend_domain_lock_device() ++ if lock_dev: ++ lock_cmd += '-x %d ' % lock_dev ++ lock_cmd += path ++ ++ status = os.system(lock_cmd) >> 8 ++ if status != 0: ++ log.exception("Failed to release lock: status = %s" % status) ++ try: ++ if len(os.listdir(path)) == 0: ++ shutil.rmtree(path) ++ except: ++ log.exception("Failed to remove unmanaged directory %s." % path) ++ + def __str__(self): + return '' % \ + (str(self.domid), self.info['name_label'], +Index: xen-4.3.0-testing/tools/python/xen/xm/main.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xm/main.py ++++ xen-4.3.0-testing/tools/python/xen/xm/main.py +@@ -21,6 +21,7 @@ + + """Grand unified management application for Xen. + """ ++import getpass + import atexit + import cmd + import os +@@ -114,6 +115,8 @@ SUBCOMMAND_HELP = { + 'Set the maximum amount reservation for a domain.'), + 'mem-set' : (' ', + 'Set the current memory usage for a domain.'), ++ 'mem-swap-target' : (' ', ++ 'Set the memory usage for a domain.'), + 'migrate' : (' ', + 'Migrate a domain to another machine.'), + 'pause' : ('', 'Pause execution of a domain.'), +@@ -121,7 +124,7 @@ SUBCOMMAND_HELP = { + 'reset' : ('', 'Reset a domain.'), + 'restore' : (' [-p]', + 'Restore a domain from a saved state.'), +- 'save' : ('[-c] ', ++ 'save' : ('[-c|-f] ', + 'Save a domain state to restore later.'), + 'shutdown' : (' [-waRH]', 'Shutdown a domain.'), + 'top' : ('', 'Monitor a host and the domains in real time.'), +@@ -280,6 +283,9 @@ SUBCOMMAND_HELP = { + 'getenforce' : ('', 'Returns the current enforcing mode for the Flask XSM module (Enforcing,Permissive)'), + 'setenforce' : ('[ (Enforcing|1) | (Permissive|0) ]', + 'Modifies the current enforcing mode for the Flask XSM module'), ++ #change vnc password ++ 'change-vnc-passwd' : ('',\ ++ 'Change vnc password'), + } + + SUBCOMMAND_OPTIONS = { +@@ -341,6 +347,7 @@ SUBCOMMAND_OPTIONS = { + ), + 'save': ( + ('-c', '--checkpoint', 'Leave domain running after creating snapshot'), ++ ('-f', '--force', 'Force to overwrite exist file'), + ), + 'restore': ( + ('-p', '--paused', 'Do not unpause domain after restoring it'), +@@ -404,6 +411,7 @@ common_commands = [ + "usb-del", + "domstate", + "vcpu-set", ++ "change-vnc-passwd", + ] + + domain_commands = [ +@@ -441,6 +449,7 @@ domain_commands = [ + "vcpu-list", + "vcpu-pin", + "vcpu-set", ++ "change-vnc-passwd", + ] + + host_commands = [ +@@ -862,18 +871,21 @@ def xm_event_monitor(args): + + def xm_save(args): + +- arg_check(args, "save", 2, 3) ++ arg_check(args, "save", 2, 4) + + try: +- (options, params) = getopt.gnu_getopt(args, 'c', ['checkpoint']) ++ (options, params) = getopt.gnu_getopt(args, 'cf', ['checkpoint', 'force']) + except getopt.GetoptError, opterr: + err(opterr) + usage('save') + + checkpoint = False ++ force = False + for (k, v) in options: + if k in ['-c', '--checkpoint']: + checkpoint = True ++ if k in ['-f', '--force']: ++ force = True + + if len(params) != 2: + err("Wrong number of parameters") +@@ -887,9 +899,9 @@ def xm_save(args): + sys.exit(1) + + if serverType == SERVER_XEN_API: +- server.xenapi.VM.save(get_single_vm(dom), savefile, checkpoint) ++ server.xenapi.VM.save(get_single_vm(dom), savefile, checkpoint, force) + else: +- server.xend.domain.save(dom, savefile, checkpoint) ++ server.xend.domain.save(dom, savefile, checkpoint, force) + + def xm_restore(args): + arg_check(args, "restore", 1, 2) +@@ -1580,6 +1592,17 @@ def xm_mem_set(args): + mem_target = int_unit(args[1], 'm') + server.xend.domain.setMemoryTarget(dom, mem_target) + ++def xm_mem_swap_target(args): ++ arg_check(args, "mem-swap-target", 2) ++ ++ dom = args[0] ++ ++ if serverType == SERVER_XEN_API: ++ err("xenapi not supported") ++ else: ++ swap_target = int_unit(args[1], 'm') ++ server.xend.domain.swaptarget_set(dom, swap_target) ++ + def xm_usb_add(args): + arg_check(args, "usb-add", 2) + server.xend.domain.usb_add(args[0],args[1]) +@@ -2199,6 +2222,10 @@ def xm_debug_keys(args): + def xm_top(args): + arg_check(args, "top", 0) + ++ # A hack to get a clear error message if ran as non-root ++ if os.geteuid() != 0: ++ raise IOError() ++ + os.system('xentop') + + def xm_dmesg(args): +@@ -2586,10 +2613,22 @@ def xm_usb_list(args): + ni = parse_dev_info(x[1]) + ni['idx'] = int(x[0]) + usbver = sxp.child_value(x[1], 'usb-ver') ++ ++ substr = re.search("^\d{1,}", usbver) ++ if substr: ++ usbver = substr.group() ++ else: ++ print "Unknown usb-ver" ++ continue ++ + if int(usbver) == 1: + ni['usb-ver'] = 'USB1.1' +- else: ++ elif int(usbver) == 2: + ni['usb-ver'] = 'USB2.0' ++ else: ++ print "Unknown usb-ver" ++ continue ++ + print "%(idx)-3d %(backend-id)-3d %(state)-5d %(usb-ver)-7s %(be-path)-30s " % ni + + ports = sxp.child(x[1], 'port') +@@ -3751,6 +3790,10 @@ def xm_cpupool_migrate(args): + else: + server.xend.cpu_pool.migrate(domname, poolname) + ++def xm_chgvncpasswd(args): ++ arg_check(args, "change-vnc-passwd", 1) ++ pwd = getpass.getpass("Enter new password: ") ++ server.xend.domain.chgvncpasswd(args[0], pwd) + + commands = { + "shell": xm_shell, +@@ -3782,6 +3825,7 @@ commands = { + # memory commands + "mem-max": xm_mem_max, + "mem-set": xm_mem_set, ++ "mem-swap-target": xm_mem_swap_target, + # cpu commands + "vcpu-pin": xm_vcpu_pin, + "vcpu-list": xm_vcpu_list, +@@ -3857,6 +3901,8 @@ commands = { + "usb-del": xm_usb_del, + #domstate + "domstate": xm_domstate, ++ #change vnc password: ++ "change-vnc-passwd": xm_chgvncpasswd, + } + + ## The commands supported by a separate argument parser in xend.xm. +Index: xen-4.3.0-testing/tools/python/xen/xend/XendNode.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendNode.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendNode.py +@@ -162,6 +162,7 @@ class XendNode: + + self._init_cpu_pools() + ++ self._init_lock_devices() + + def _init_networks(self): + # Initialise networks +@@ -382,6 +383,17 @@ class XendNode: + XendCPUPool.recreate_active_pools() + + ++ def _init_lock_devices(self): ++ if xendoptions().get_xend_domain_lock(): ++ if xendoptions().get_xend_domain_lock_utility().endswith("domain-lock-sfex"): ++ lock_device = xendoptions().get_xend_domain_lock_device() ++ if not lock_device: ++ raise XendError("The block device for sfex is not properly configured") ++ status = os.system("lvchange -ay %s" % lock_device) >> 8 ++ if status != 0: ++ raise XendError("The block device for sfex could not be initialized") ++ ++ + def add_network(self, interface): + # TODO + log.debug("add_network(): Not implemented.") +@@ -949,11 +961,35 @@ class XendNode: + + info['cpu_mhz'] = info['cpu_khz'] / 1000 + +- # physinfo is in KiB, need it in MiB +- info['total_memory'] = info['total_memory'] / 1024 +- info['free_memory'] = info['free_memory'] / 1024 ++ configured_floor = xendoptions().get_dom0_min_mem() * 1024 ++ from xen.xend import balloon ++ try: ++ kernel_floor = balloon.get_dom0_min_target() ++ except: ++ kernel_floor = 0 ++ dom0_min_mem = max(configured_floor, kernel_floor) ++ dom0_mem = balloon.get_dom0_current_alloc() ++ extra_mem = 0 ++ if dom0_min_mem > 0 and dom0_mem > dom0_min_mem: ++ extra_mem = dom0_mem - dom0_min_mem ++ info['free_memory'] = info['free_memory'] + info['scrub_memory'] ++ info['max_free_memory'] = info['free_memory'] + extra_mem + info['free_cpus'] = len(XendCPUPool.unbound_cpus()) + ++ # Convert KiB to MiB, rounding down to be conservative ++ info['total_memory'] = info['total_memory'] / 1024 ++ info['free_memory'] = info['free_memory'] / 1024 ++ info['max_free_memory'] = info['max_free_memory'] / 1024 ++ ++ # FIXME: These are hard-coded to be the inverse of the getXenMemory ++ # functions in image.py. Find a cleaner way. ++ info['max_para_memory'] = info['max_free_memory'] - 4 ++ if info['max_para_memory'] < 0: ++ info['max_para_memory'] = 0 ++ info['max_hvm_memory'] = int((info['max_free_memory']-12) * (1-2.4/1024)) ++ if info['max_hvm_memory'] < 0: ++ info['max_hvm_memory'] = 0 ++ + ITEM_ORDER = ['nr_cpus', + 'nr_nodes', + 'cores_per_socket', +@@ -964,6 +1000,9 @@ class XendNode: + 'total_memory', + 'free_memory', + 'free_cpus', ++ 'max_free_memory', ++ 'max_para_memory', ++ 'max_hvm_memory', + ] + + if show_numa != 0: +Index: xen-4.3.0-testing/tools/python/xen/xend/balloon.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/balloon.py ++++ xen-4.3.0-testing/tools/python/xen/xend/balloon.py +@@ -43,6 +43,8 @@ SLEEP_TIME_GROWTH = 0.1 + # label actually shown in the PROC_XEN_BALLOON file. + #labels = { 'current' : 'Current allocation', + # 'target' : 'Requested target', ++# 'min-target' : 'Minimum target', ++# 'max-target' : 'Maximum target', + # 'low-balloon' : 'Low-mem balloon', + # 'high-balloon' : 'High-mem balloon', + # 'limit' : 'Xen hard limit' } +@@ -69,6 +71,23 @@ def get_dom0_target_alloc(): + raise VmError('Failed to query target memory allocation of dom0.') + return kb + ++def get_dom0_min_target(): ++ """Returns the minimum amount of memory (in KiB) that dom0 will accept.""" ++ ++ kb = _get_proc_balloon('min-target') ++ if kb == None: ++ raise VmError('Failed to query minimum target memory allocation of dom0.') ++ return kb ++ ++def get_dom0_max_target(): ++ """Returns the maximum amount of memory (in KiB) that is potentially ++ visible to dom0.""" ++ ++ kb = _get_proc_balloon('max-target') ++ if kb == None: ++ raise VmError('Failed to query maximum target memory allocation of dom0.') ++ return kb ++ + def free(need_mem, dominfo): + """Balloon out memory from the privileged domain so that there is the + specified required amount (in KiB) free. +Index: xen-4.3.0-testing/tools/python/xen/xend/server/SrvDomain.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/server/SrvDomain.py ++++ xen-4.3.0-testing/tools/python/xen/xend/server/SrvDomain.py +@@ -187,7 +187,7 @@ class SrvDomain(SrvDir): + + + def op_mem_target_set(self, _, req): +- return self.call(self.dom.setMemoryTarget, ++ return self.call(self.dom.capAndSetMemoryTarget, + [['target', 'int']], + req) + +Index: xen-4.3.0-testing/tools/python/xen/xend/osdep.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/osdep.py ++++ xen-4.3.0-testing/tools/python/xen/xend/osdep.py +@@ -42,6 +42,8 @@ def _linux_balloon_stat_proc(label): + + xend2linux_labels = { 'current' : 'Current allocation', + 'target' : 'Requested target', ++ 'min-target' : 'Minimum target', ++ 'max-target' : 'Maximum target', + 'low-balloon' : 'Low-mem balloon', + 'high-balloon' : 'High-mem balloon', + 'limit' : 'Xen hard limit' } +@@ -141,10 +143,14 @@ def _linux_get_cpuinfo(): + d = {} + for line in f: + keyvalue = line.split(':') +- if len(keyvalue) != 2: ++ if len(keyvalue) < 2: + continue + key = keyvalue[0].strip() +- val = keyvalue[1].strip() ++ for i in range(1, len(keyvalue)): ++ if i == 1: ++ val = keyvalue[i].lstrip() ++ else: ++ val = val + ":" + keyvalue[i] + if key == 'processor': + if p != -1: + cpuinfo[p] = d +Index: xen-4.3.0-testing/tools/hotplug/Linux/Makefile +=================================================================== +--- xen-4.3.0-testing.orig/tools/hotplug/Linux/Makefile ++++ xen-4.3.0-testing/tools/hotplug/Linux/Makefile +@@ -11,7 +11,7 @@ XENCOMMONS_SYSCONFIG = init.d/sysconfig. + + # Xen script dir and scripts to go there. + XEN_SCRIPTS = network-bridge vif-bridge +-XEN_SCRIPTS += network-route vif-route ++XEN_SCRIPTS += network-route vif-route vif-route-ifup + XEN_SCRIPTS += network-nat vif-nat + XEN_SCRIPTS += vif-openvswitch + XEN_SCRIPTS += vif2 +@@ -23,6 +23,8 @@ XEN_SCRIPTS += xen-hotplug-cleanup + XEN_SCRIPTS += external-device-migrate + XEN_SCRIPTS += vscsi + XEN_SCRIPTS += block-iscsi ++XEN_SCRIPTS += domain-lock vm-monitor ++XEN_SCRIPTS += domain-lock-sfex + XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh + XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh + XEN_SCRIPT_DATA += block-common.sh +Index: xen-4.3.0-testing/tools/hotplug/Linux/vif-route-ifup +=================================================================== +--- /dev/null ++++ xen-4.3.0-testing/tools/hotplug/Linux/vif-route-ifup +@@ -0,0 +1,34 @@ ++#!/bin/bash ++#============================================================================ ++# /etc/xen/vif-route-ifup ++# ++# Script for configuring a vif in routed mode. ++# The hotplugging system will call this script if it is specified either in ++# the device configuration given to Xend, or the default Xend configuration ++# in /etc/xen/xend-config.sxp. If the script is specified in neither of those ++# places, then vif-bridge is the default. ++# ++# Usage: ++# vif-route-ifup (add|remove|online|offline) ++# ++# Environment vars: ++# dev vif interface name (required). ++#============================================================================ ++ ++dir=$(dirname "$0") ++. "$dir/vif-common.sh" ++ ++case "$command" in ++ online) ++ ifup ${dev} ++ ;; ++ offline) ++ do_without_error ifdown ${dev} ++ ;; ++esac ++ ++log debug "Successful vif-route-ifup $command for ${dev}." ++if [ "$command" = "online" ] ++then ++ success ++fi +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/net.h +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/net.h ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/net.h +@@ -107,8 +107,8 @@ void net_host_device_add(const char *dev + void net_host_device_remove(int vlan_id, const char *device); + + #ifndef DEFAULT_NETWORK_SCRIPT +-#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" +-#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" ++#define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup" ++#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/xen/qemu-ifdown" + #endif + #ifdef __sun__ + #define SMBD_COMMAND "/usr/sfw/sbin/smbd" +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/net.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/net.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/net.c +@@ -1759,9 +1759,10 @@ int net_client_init(const char *device, + } + if (get_param_value(script_arg, sizeof(script_arg), "scriptarg", p) == 0 && + get_param_value(script_arg, sizeof(script_arg), "bridge", p) == 0) { /* deprecated; for xend compatibility */ +- pstrcpy(script_arg, sizeof(script_arg), ""); ++ ret = net_tap_init(vlan, device, name, ifname, setup_script, NULL, NULL); ++ } else { ++ ret = net_tap_init(vlan, device, name, ifname, setup_script, down_script, script_arg); + } +- ret = net_tap_init(vlan, device, name, ifname, setup_script, down_script, script_arg); + } + } else + #endif +Index: xen-4.3.0-testing/tools/python/xen/xend/image.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/image.py ++++ xen-4.3.0-testing/tools/python/xen/xend/image.py +@@ -17,7 +17,7 @@ + #============================================================================ + + +-import os, os.path, string ++import os, os.path, string, struct, stat + import re + import math + import time +@@ -122,7 +122,13 @@ class ImageHandler: + self.vm.permissionsVm("image/cmdline", { 'dom': self.vm.getDomid(), 'read': True } ) + + self.device_model = vmConfig['platform'].get('device_model') ++ self.actmem = str(vmConfig['platform'].get('actmem')) ++ self.xenpaging_file = str(vmConfig['platform'].get('xenpaging_file')) ++ self.xenpaging_extra = vmConfig['platform'].get('xenpaging_extra') ++ self.xenpaging_pid = None + ++ self.smbios_firmware =(str(vmConfig['platform'].get('smbios_firmware'))) ++ self.acpi_firmware =(str(vmConfig['platform'].get('acpi_firmware'))) + self.display = vmConfig['platform'].get('display') + self.xauthority = vmConfig['platform'].get('xauthority') + self.vncconsole = int(vmConfig['platform'].get('vncconsole', 0)) +@@ -392,6 +398,87 @@ class ImageHandler: + sentinel_fifos_inuse[sentinel_path_fifo] = 1 + self.sentinel_path_fifo = sentinel_path_fifo + ++ def createXenPaging(self): ++ if not self.vm.info.is_hvm(): ++ return ++ if self.actmem == "0": ++ return ++ if self.xenpaging_pid: ++ return ++ xenpaging_bin = auxbin.pathTo("xenpaging") ++ args = [xenpaging_bin] ++ args = args + ([ "-f", "/var/lib/xen/xenpaging/%s.%d.paging" % (str(self.vm.info['name_label']), self.vm.getDomid())]) ++ if self.xenpaging_extra: ++ args = args + (self.xenpaging_extra) ++ args = args + ([ "-d", "%d" % self.vm.getDomid()]) ++ self.xenpaging_logfile = "/var/log/xen/xenpaging-%s.log" % str(self.vm.info['name_label']) ++ logfile_mode = os.O_WRONLY|os.O_CREAT|os.O_APPEND|os.O_TRUNC ++ null = os.open("/dev/null", os.O_RDONLY) ++ try: ++ os.unlink(self.xenpaging_logfile) ++ except: ++ pass ++ logfd = os.open(self.xenpaging_logfile, logfile_mode, 0644) ++ sys.stderr.flush() ++ contract = osdep.prefork("%s:%d" % (self.vm.getName(), self.vm.getDomid())) ++ xenpaging_pid = os.fork() ++ if xenpaging_pid == 0: #child ++ try: ++ osdep.postfork(contract) ++ os.dup2(null, 0) ++ os.dup2(logfd, 1) ++ os.dup2(logfd, 2) ++ try: ++ env = dict(os.environ) ++ log.info("starting %s" % args) ++ os.execve(xenpaging_bin, args, env) ++ except Exception, e: ++ log.warn('failed to execute xenpaging: %s' % utils.exception_string(e)) ++ os._exit(126) ++ except: ++ log.warn("starting xenpaging failed") ++ os._exit(127) ++ else: ++ osdep.postfork(contract, abandon=True) ++ self.xenpaging_pid = xenpaging_pid ++ os.close(null) ++ os.close(logfd) ++ self.vm.storeDom("xenpaging/xenpaging-pid", self.xenpaging_pid) ++ self.vm.storeDom("memory/target-tot_pages", int(self.actmem) * 1024) ++ ++ def destroyXenPaging(self): ++ if self.actmem == "0": ++ return ++ if self.xenpaging_pid: ++ try: ++ os.kill(self.xenpaging_pid, signal.SIGHUP) ++ except OSError, exn: ++ log.exception(exn) ++ for i in xrange(100): ++ try: ++ (p, rv) = os.waitpid(self.xenpaging_pid, os.WNOHANG) ++ if p == self.xenpaging_pid: ++ break ++ except OSError: ++ # This is expected if Xend has been restarted within ++ # the life of this domain. In this case, we can kill ++ # the process, but we can't wait for it because it's ++ # not our child. We continue this loop, and after it is ++ # terminated make really sure the process is going away ++ # (SIGKILL). ++ pass ++ time.sleep(0.1) ++ else: ++ log.warning("xenpaging %d took more than 10s " ++ "to terminate: sending SIGKILL" % self.xenpaging_pid) ++ try: ++ os.kill(self.xenpaging_pid, signal.SIGKILL) ++ os.waitpid(self.xenpaging_pid, 0) ++ except OSError: ++ # This happens if the process doesn't exist. ++ pass ++ self.xenpaging_pid = None ++ + def createDeviceModel(self, restore = False): + if self.device_model is None: + return +@@ -828,6 +915,7 @@ class HVMImageHandler(ImageHandler): + + self.apic = int(vmConfig['platform'].get('apic', 0)) + self.acpi = int(vmConfig['platform'].get('acpi', 0)) ++ self.extid = int(vmConfig['platform'].get('extid', 0)) + self.guest_os_type = vmConfig['platform'].get('guest_os_type') + self.memory_sharing = int(vmConfig['memory_sharing']) + try: +@@ -855,7 +943,8 @@ class HVMImageHandler(ImageHandler): + + dmargs = [ 'boot', 'fda', 'fdb', 'soundhw', + 'localtime', 'serial', 'stdvga', 'isa', +- 'acpi', 'usb', 'usbdevice', 'gfx_passthru' ] ++ 'acpi', 'usb', 'usbdevice', 'gfx_passthru', ++ 'watchdog', 'watchdog_action' ] + + for a in dmargs: + v = vmConfig['platform'].get(a) +@@ -863,6 +952,7 @@ class HVMImageHandler(ImageHandler): + # python doesn't allow '-' in variable names + if a == 'stdvga': a = 'std-vga' + if a == 'keymap': a = 'k' ++ if a == 'watchdog_action': a = 'watchdog-action' + + # Handle booleans gracefully + if a in ['localtime', 'std-vga', 'isa', 'usb', 'acpi']: +@@ -912,11 +1002,13 @@ class HVMImageHandler(ImageHandler): + mac = devinfo.get('mac') + if mac is None: + raise VmError("MAC address not specified or generated.") +- bridge = devinfo.get('bridge', 'xenbr0') ++ bridge = devinfo.get('bridge', None) + model = devinfo.get('model', 'rtl8139') + ret.append("-net") +- ret.append("nic,vlan=%d,macaddr=%s,model=%s" % +- (nics, mac, model)) ++ net = "nic,vlan=%d,macaddr=%s,model=%s" % (nics, mac, model) ++ if bridge: ++ net += ",bridge=%s" % bridge ++ ret.append(net) + vifname = "vif%d.%d-emu" % (self.vm.getDomid(), nics-1) + ret.append("-net") + if osdep.tapif_script is not None: +@@ -941,6 +1033,38 @@ class HVMImageHandler(ImageHandler): + self.vm.getDomid() ]) + return args + ++ def _readFirmwareFile(self, filename): ++ # Sanity check ++ if filename is None or filename.strip() == "": ++ size = struct.pack('i', int(0)) ++ return size + "" ++ ++ log.debug("Reading firmware file %s", filename) ++ # Open ++ try: ++ fd = os.open(filename, os.O_RDONLY) ++ except Exception, e: ++ raise VmError('Unable to open firmware file %s' % filename) ++ ++ # Validate file size ++ statinfo = os.fstat(fd) ++ if statinfo.st_size == 0 or statinfo.st_size > sys.maxint: ++ os.close(fd) ++ raise VmError('Firmware file %s is an invalid size' % filename) ++ if not stat.S_ISREG(statinfo.st_mode): ++ os.close(fd) ++ raise VmError('Firmware file %s is an invalid file type' % filename) ++ size = struct.pack('i', statinfo.st_size) ++ ++ # Read entire file ++ try: ++ buf = os.read(fd, statinfo.st_size) ++ except Exception, e: ++ os.close(fd) ++ raise VmError('Failed reading firmware file %s' % filename) ++ os.close(fd) ++ return size+buf ++ + def buildDomain(self): + store_evtchn = self.vm.getStorePort() + +@@ -956,6 +1080,8 @@ class HVMImageHandler(ImageHandler): + log.debug("vcpu_avail = %li", self.vm.getVCpuAvail()) + log.debug("acpi = %d", self.acpi) + log.debug("apic = %d", self.apic) ++ log.debug("smbios_firmware= %s", self.smbios_firmware) ++ log.debug("acpi_firmware = %s", self.acpi_firmware) + + rc = xc.hvm_build(domid = self.vm.getDomid(), + image = self.loader, +@@ -964,7 +1090,9 @@ class HVMImageHandler(ImageHandler): + vcpus = self.vm.getVCpuCount(), + vcpu_avail = self.vm.getVCpuAvail(), + acpi = self.acpi, +- apic = self.apic) ++ apic = self.apic, ++ smbios_firmware= self._readFirmwareFile(self.smbios_firmware), ++ acpi_firmware = self._readFirmwareFile(self.acpi_firmware)) + rc['notes'] = { 'SUSPEND_CANCEL': 1 } + + rc['store_mfn'] = xc.hvm_get_param(self.vm.getDomid(), +@@ -1036,7 +1164,7 @@ class X86_HVM_ImageHandler(HVMImageHandl + + def configure(self, vmConfig): + HVMImageHandler.configure(self, vmConfig) +- self.pae = int(vmConfig['platform'].get('pae', 0)) ++ self.pae = int(vmConfig['platform'].get('pae', 1)) + self.vramsize = int(vmConfig['platform'].get('videoram',4)) * 1024 + + def buildDomain(self): +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/i386-dm/qemu-ifup-Linux +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/i386-dm/qemu-ifup-Linux ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/i386-dm/qemu-ifup-Linux +@@ -1,36 +1,22 @@ + #!/bin/sh + +-#. /etc/rc.d/init.d/functions +-#ulimit -c unlimited +- + echo 'config qemu network with xen bridge for ' $* + ++# If bridge is not specified, try device with default route. + bridge=$2 ++if [ -z "$bridge" ]; then ++ bridge=$(ip route list | awk '/^default / { print $NF }') ++fi + +-# +-# Old style bridge setup with netloop, used to have a bridge name +-# of xenbrX, enslaving pethX and vif0.X, and then configuring +-# eth0. +-# +-# New style bridge setup does not use netloop, so the bridge name +-# is ethX and the physical device is enslaved pethX +-# +-# So if... +-# +-# - User asks for xenbrX +-# - AND xenbrX doesn't exist +-# - AND there is a ethX device which is a bridge +-# +-# ..then we translate xenbrX to ethX +-# +-# This lets old config files work without modification +-# +-if [ ! -e "/sys/class/net/$bridge" ] && [ -z "${bridge##xenbr*}" ] ++# Exit if $bridge is not a bridge. Exit with 0 status ++# so qemu-dm process is not terminated. No networking in ++# vm is bad but not catastrophic. The vm could still run ++# cpu and disk IO workloads. ++# Include an useful error message in qemu-dm log file. ++if [ ! -e "/sys/class/net/${bridge}/bridge" ] + then +- if [ -e "/sys/class/net/eth${bridge#xenbr}/bridge" ] +- then +- bridge="eth${bridge#xenbr}" +- fi ++ echo "WARNING! ${bridge} is not a bridge. qemu-ifup exiting. VM may not have a functioning networking stack." ++ exit 0 + fi + + ifconfig $1 0.0.0.0 up +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/monitor.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/monitor.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/monitor.c +@@ -26,6 +26,7 @@ + #include "hw/pcmcia.h" + #include "hw/pc.h" + #include "hw/pci.h" ++#include "hw/watchdog.h" + #include "gdbstub.h" + #include "net.h" + #include "qemu-char.h" +@@ -531,6 +532,13 @@ static void do_gdbserver(const char *por + } + #endif + ++static void do_watchdog_action(const char *action) ++{ ++ if (select_watchdog_action(action) == -1) { ++ qemu_printf("Unknown watchdog action '%s'\n", action); ++ } ++} ++ + static void term_printc(int c) + { + term_printf("'"); +@@ -1497,6 +1505,7 @@ static const term_cmd_t term_cmds[] = { + "device|all", "commit changes to the disk images (if -snapshot is used) or backing files" }, + { "info", "s?", do_info, + "subcommand", "show various information about the system state" }, ++#ifdef CONFIG_TRUSTED_CLIENT + { "q|quit", "", do_quit, + "", "quit the emulator" }, + { "eject", "-fB", do_eject, +@@ -1509,6 +1518,7 @@ static const term_cmd_t term_cmds[] = { + "filename", "output logs to 'filename'" }, + { "log", "s", do_log, + "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" }, ++#endif + { "savevm", "s?", do_savevm, + "tag|id", "save a VM snapshot. If no tag or id are provided, a new snapshot is created" }, + { "loadvm", "s", do_loadvm, +@@ -1538,8 +1548,10 @@ static const term_cmd_t term_cmds[] = { + "", "reset the system" }, + { "system_powerdown", "", do_system_powerdown, + "", "send system power down event" }, ++#ifdef CONFIG_TRUSTED_CLIENT + { "sum", "ii", do_sum, + "addr size", "compute the checksum of a memory region" }, ++#endif + { "usb_add", "s", do_usb_add, + "device", "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')" }, + { "usb_del", "s", do_usb_del, +@@ -1558,6 +1570,7 @@ static const term_cmd_t term_cmds[] = { + "state", "change mouse button state (1=L, 2=M, 4=R)" }, + { "mouse_set", "i", do_mouse_set, + "index", "set which mouse device receives events" }, ++#ifdef CONFIG_TRUSTED_CLIENT + #ifdef HAS_AUDIO + { "wavcapture", "si?i?i?", do_wav_capture, + "path [frequency bits channels]", +@@ -1565,6 +1578,7 @@ static const term_cmd_t term_cmds[] = { + #endif + { "stopcapture", "i", do_stop_capture, + "capture index", "stop capture" }, ++#endif + { "memsave", "lis", do_memory_save, + "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", }, + { "pmemsave", "lis", do_physical_memory_save, +@@ -1599,6 +1613,8 @@ static const term_cmd_t term_cmds[] = { + "target", "request VM to change it's memory allocation (in MB)" }, + { "set_link", "ss", do_set_link, + "name [up|down]", "change the link status of a network adapter" }, ++ { "watchdog_action", "s", do_watchdog_action, ++ "[reset|shutdown|poweroff|pause|debug|none]", "change watchdog action" }, + { "cpu_set", "is", do_cpu_set_nr, + "cpu [online|offline]", "change cpu state" }, + { NULL, NULL, }, +@@ -1646,6 +1662,7 @@ static const term_cmd_t info_cmds[] = { + "", "show KVM information", }, + { "usb", "", usb_info, + "", "show guest USB devices", }, ++#ifdef CONFIG_TRUSTED_CLIENT + { "usbhost", "", usb_host_info, + "", "show host USB devices", }, + { "profile", "", do_info_profile, +@@ -1677,6 +1694,7 @@ static const term_cmd_t info_cmds[] = { + { "migrate", "", do_info_migrate, "", "show migration status" }, + { "balloon", "", do_info_balloon, + "", "show balloon information" }, ++#endif + { NULL, NULL, }, + }; + +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/ne2000.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/ne2000.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/ne2000.c +@@ -218,7 +218,7 @@ static int ne2000_can_receive(void *opaq + NE2000State *s = opaque; + + if (s->cmd & E8390_STOP) +- return 1; ++ return 0; + return !ne2000_buffer_full(s); + } + +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pc.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/pc.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pc.c +@@ -41,6 +41,7 @@ + #include "virtio-balloon.h" + #include "virtio-console.h" + #include "hpet_emul.h" ++#include "watchdog.h" + + #ifdef CONFIG_PASSTHROUGH + #include "pass-through.h" +@@ -413,7 +414,8 @@ static void bochs_bios_write(void *opaqu + case 0x400: + case 0x401: + fprintf(stderr, "BIOS panic at rombios.c, line %d\n", val); +- exit(1); ++ /* according to documentation, these can be safely ignored */ ++ break; + case 0x402: + case 0x403: + #ifdef DEBUG_BIOS +@@ -436,8 +438,9 @@ static void bochs_bios_write(void *opaqu + /* LGPL'ed VGA BIOS messages */ + case 0x501: + case 0x502: ++ /* according to documentation, these can be safely ignored */ + fprintf(stderr, "VGA BIOS panic, line %d\n", val); +- exit(1); ++ break; + case 0x500: + case 0x503: + #ifdef DEBUG_BIOS +@@ -472,45 +475,28 @@ static void bochs_bios_init(void) + + /* Generate an initial boot sector which sets state and jump to + a specified vector */ +-static void generate_bootsect(uint8_t *option_rom, +- uint32_t gpr[8], uint16_t segs[6], uint16_t ip) ++static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip) + { +- uint8_t rom[512], *p, *reloc; +- uint8_t sum; ++ uint8_t bootsect[512], *p; + int i; ++ int hda; + +- memset(rom, 0, sizeof(rom)); ++ hda = drive_get_index(IF_IDE, 0, 0); ++ if (hda == -1) { ++ fprintf(stderr, "A disk image must be given for 'hda' when booting " ++ "a Linux kernel\n(if you really don't want it, use /dev/zero)\n"); ++ exit(1); ++ } ++ memset(bootsect, 0, sizeof(bootsect)); + +- p = rom; +- /* Make sure we have an option rom signature */ +- *p++ = 0x55; +- *p++ = 0xaa; +- +- /* ROM size in sectors*/ +- *p++ = 1; +- +- /* Hook int19 */ +- +- *p++ = 0x50; /* push ax */ +- *p++ = 0x1e; /* push ds */ +- *p++ = 0x31; *p++ = 0xc0; /* xor ax, ax */ +- *p++ = 0x8e; *p++ = 0xd8; /* mov ax, ds */ +- +- *p++ = 0xc7; *p++ = 0x06; /* movvw _start,0x64 */ +- *p++ = 0x64; *p++ = 0x00; +- reloc = p; +- *p++ = 0x00; *p++ = 0x00; +- +- *p++ = 0x8c; *p++ = 0x0e; /* mov cs,0x66 */ +- *p++ = 0x66; *p++ = 0x00; +- +- *p++ = 0x1f; /* pop ds */ +- *p++ = 0x58; /* pop ax */ +- *p++ = 0xcb; /* lret */ +- +- /* Actual code */ +- *reloc = (p - rom); ++ /* Copy the MSDOS partition table if possible */ ++ bdrv_read(drives_table[hda].bdrv, 0, bootsect, 1); ++ /* Make sure we have a partition signature */ ++ bootsect[510] = 0x55; ++ bootsect[511] = 0xaa; + ++ /* Actual code */ ++ p = bootsect; + *p++ = 0xfa; /* CLI */ + *p++ = 0xfc; /* CLD */ + +@@ -540,13 +526,7 @@ static void generate_bootsect(uint8_t *o + *p++ = segs[1]; /* CS */ + *p++ = segs[1] >> 8; + +- /* sign rom */ +- sum = 0; +- for (i = 0; i < (sizeof(rom) - 1); i++) +- sum += rom[i]; +- rom[sizeof(rom) - 1] = -sum; +- +- memcpy(option_rom, rom, sizeof(rom)); ++ bdrv_set_boot_sector(drives_table[hda].bdrv, bootsect, sizeof(bootsect)); + } + + static long get_file_size(FILE *f) +@@ -563,8 +543,7 @@ static long get_file_size(FILE *f) + return size; + } + +-static void load_linux(uint8_t *option_rom, +- const char *kernel_filename, ++static void load_linux(const char *kernel_filename, + const char *initrd_filename, + const char *kernel_cmdline) + { +@@ -630,7 +609,9 @@ static void load_linux(uint8_t *option_r + + /* Special pages are placed at end of low RAM: pick an arbitrary one and + * subtract a suitably large amount of padding (64kB) to skip BIOS data. */ +- xc_get_hvm_param(xc_handle, domid, HVM_PARAM_BUFIOREQ_PFN, &end_low_ram); ++ //xc_get_hvm_param(xc_handle, domid, HVM_PARAM_BUFIOREQ_PFN, &end_low_ram); ++ /* BUFIO Page beyond last_pfn, use 0x7ffc instead. Fix ME. */ ++ end_low_ram = 0x7ffc; + end_low_ram = (end_low_ram << 12) - (64*1024); + + /* highest address for loading the initrd */ +@@ -719,7 +700,7 @@ static void load_linux(uint8_t *option_r + memset(gpr, 0, sizeof gpr); + gpr[4] = cmdline_addr-real_addr-16; /* SP (-16 is paranoia) */ + +- generate_bootsect(option_rom, gpr, seg, 0); ++ generate_bootsect(gpr, seg, 0); + #endif + } + +@@ -930,14 +911,6 @@ vga_bios_error: + int size, offset; + + offset = 0; +- if (linux_boot) { +- option_rom_offset = qemu_ram_alloc(TARGET_PAGE_SIZE); +- load_linux(phys_ram_base + option_rom_offset, +- kernel_filename, initrd_filename, kernel_cmdline); +- cpu_register_physical_memory(0xd0000, TARGET_PAGE_SIZE, +- option_rom_offset | IO_MEM_ROM); +- offset = TARGET_PAGE_SIZE; +- } + + for (i = 0; i < nb_option_roms; i++) { + size = get_image_size(option_rom[i]); +@@ -971,6 +944,9 @@ vga_bios_error: + + bochs_bios_init(); + ++ if (linux_boot) ++ load_linux(kernel_filename, initrd_filename, kernel_cmdline); ++ + cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1); + i8259 = i8259_init(cpu_irq[0]); + ferr_irq = i8259[13]; +@@ -1075,6 +1051,8 @@ vga_bios_error: + } + } + ++ watchdog_pc_init(pci_bus); ++ + for(i = 0; i < nb_nics; i++) { + NICInfo *nd = &nd_table[i]; + +Index: xen-4.3.0-testing/tools/python/xen/xend/server/HalDaemon.py +=================================================================== +--- /dev/null ++++ xen-4.3.0-testing/tools/python/xen/xend/server/HalDaemon.py +@@ -0,0 +1,243 @@ ++#!/usr/bin/env python ++# -*- mode: python; -*- ++#============================================================================ ++# 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 ++# License as published by the Free Software Foundation. ++# ++# This library 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 ++# Lesser General Public License for more details. ++# ++# You should have received a copy of the GNU Lesser General Public ++# License along with this library; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++#============================================================================ ++# Copyright (C) 2007 Pat Campbell ++# Copyright (C) 2007 Novell Inc. ++#============================================================================ ++ ++"""hald (Hardware Abstraction Layer Daemon) watcher for Xen management ++ of removable block device media. ++ ++""" ++ ++import gobject ++import dbus ++import dbus.glib ++import os ++import types ++import sys ++import signal ++import traceback ++from xen.xend.xenstore.xstransact import xstransact, complete ++from xen.xend.xenstore.xsutil import xshandle ++from xen.xend import PrettyPrint ++from xen.xend import XendLogging ++from xen.xend.XendLogging import log ++ ++DEVICE_TYPES = ['vbd', 'tap'] ++ ++class HalDaemon: ++ """The Hald block device watcher for XEN ++ """ ++ ++ """Default path to the log file. """ ++ logfile_default = "/var/log/xen/hald.log" ++ ++ """Default level of information to be logged.""" ++ loglevel_default = 'INFO' ++ ++ ++ def __init__(self): ++ ++ XendLogging.init(self.logfile_default, self.loglevel_default) ++ log.debug( "%s", "__init__") ++ ++ self.udi_dict = {} ++ self.debug = 0 ++ self.dbpath = "/local/domain/0/backend" ++ self.bus = dbus.SystemBus() ++ self.hal_manager_obj = self.bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/Manager') ++ self.hal_manager = dbus.Interface( self.hal_manager_obj, 'org.freedesktop.Hal.Manager') ++ self.gatherBlockDevices() ++ self.registerDeviceCallbacks() ++ ++ def run(self): ++ log.debug( "%s", "In new run" ); ++ try: ++ self.mainloop = gobject.MainLoop() ++ self.mainloop.run() ++ except KeyboardInterrupt, ex: ++ log.debug('Keyboard exception handler: %s', ex ) ++ self.mainloop.quit() ++ except Exception, ex: ++ log.debug('Generic exception handler: %s', ex ) ++ self.mainloop.quit() ++ ++ def __del__(self): ++ log.debug( "%s", "In del " ); ++ self.unRegisterDeviceCallbacks() ++ self.mainloop.quit() ++ ++ def shutdown(self): ++ log.debug( "%s", "In shutdown now " ); ++ self.unRegisterDeviceCallbacks() ++ self.mainloop.quit() ++ ++ def stop(self): ++ log.debug( "%s", "In stop now " ); ++ self.unRegisterDeviceCallbacks() ++ self.mainloop.quit() ++ ++ def gatherBlockDevices(self): ++ ++ # Get all the current devices from hal and save in a dictionary ++ try: ++ device_names = self.hal_manager.GetAllDevices() ++ i = 0; ++ for name in device_names: ++ #log.debug("device name, device=%s",name) ++ dev_obj = self.bus.get_object ('org.freedesktop.Hal', name) ++ dev = dbus.Interface (dev_obj, 'org.freedesktop.Hal.Device') ++ dev_properties = dev_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device") ++ if dev_properties.has_key('block.device'): ++ dev_str = dev_properties['block.device'] ++ dev_major = dev_properties['block.major'] ++ dev_minor = dev_properties['block.minor'] ++ udi_info = {} ++ udi_info['device'] = dev_str ++ udi_info['major'] = dev_major ++ udi_info['minor'] = dev_minor ++ udi_info['udi'] = name ++ self.udi_dict[i] = udi_info ++ i = i + 1 ++ except Exception, ex: ++ print >>sys.stderr, 'Exception gathering block devices:', ex ++ log.warn("Exception gathering block devices (%s)",ex) ++ ++ # ++ def registerDeviceCallbacks(self): ++ # setup the callbacks for when the gdl changes ++ self.hal_manager.connect_to_signal('DeviceAdded', self.device_added_callback) ++ self.hal_manager.connect_to_signal('DeviceRemoved', self.device_removed_callback) ++ ++ # ++ def unRegisterDeviceCallbacks(self): ++ # setup the callbacks for when the gdl changes ++ self.hal_manager.remove_signal_receiver(self.device_added_callback,'DeviceAdded') ++ self.hal_manager.remove_signal_receiver(self.device_removed_callback,'DeviceRemoved') ++ ++ # ++ def device_removed_callback(self,udi): ++ log.debug('UDI %s was removed',udi) ++ self.show_dict(self.udi_dict) ++ for key in self.udi_dict: ++ udi_info = self.udi_dict[key] ++ if udi_info['udi'] == udi: ++ device = udi_info['device'] ++ major = udi_info['major'] ++ minor = udi_info['minor'] ++ self.change_xenstore( "remove", device, major, minor) ++ ++ # Adds device to dictionary if not already there ++ def device_added_callback(self,udi): ++ log.debug('UDI %s was added', udi) ++ self.show_dict(self.udi_dict) ++ dev_obj = self.bus.get_object ('org.freedesktop.Hal', udi) ++ dev = dbus.Interface (dev_obj, 'org.freedesktop.Hal.Device') ++ device = dev.GetProperty ('block.device') ++ major = dev.GetProperty ('block.major') ++ minor = dev.GetProperty ('block.minor') ++ udi_info = {} ++ udi_info['device'] = device ++ udi_info['major'] = major ++ udi_info['minor'] = minor ++ udi_info['udi'] = udi ++ already = 0 ++ cnt = 0; ++ for key in self.udi_dict: ++ info = self.udi_dict[key] ++ if info['udi'] == udi: ++ already = 1 ++ break ++ cnt = cnt + 1 ++ if already == 0: ++ self.udi_dict[cnt] = udi_info; ++ log.debug('UDI %s was added, device:%s major:%s minor:%s index:%d\n', udi, device, major, minor, cnt) ++ self.change_xenstore( "add", device, major, minor) ++ ++ # Debug helper, shows dictionary contents ++ def show_dict(self,dict=None): ++ if self.debug == 0 : ++ return ++ if dict == None : ++ dict = self.udi_dict ++ for key in dict: ++ log.debug('udi_info %s udi_info:%s',key,dict[key]) ++ ++ # Set or clear xenstore media-present depending on the action argument ++ # for every vbd that has this block device ++ def change_xenstore(self,action, device, major, minor): ++ for type in DEVICE_TYPES: ++ path = self.dbpath + '/' + type ++ domains = xstransact.List(path) ++ log.debug('domains: %s', domains) ++ for domain in domains: # for each domain ++ devices = xstransact.List( path + '/' + domain) ++ log.debug('devices: %s',devices) ++ for device in devices: # for each vbd device ++ str = device.split('/') ++ vbd_type = None; ++ vbd_physical_device = None ++ vbd_media = None ++ vbd_device_path = path + '/' + domain + '/' + device ++ listing = xstransact.List(vbd_device_path) ++ for entry in listing: # for each entry ++ item = path + '/' + entry ++ value = xstransact.Read( vbd_device_path + '/' + entry) ++ log.debug('%s=%s',item,value) ++ if item.find('media-present') != -1: ++ vbd_media = item; ++ vbd_media_path = item ++ if item.find('physical-device') != -1: ++ vbd_physical_device = value; ++ if item.find('type') != -1: ++ 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 = 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): ++ if action == "add": ++ xs_dict = {'media': "1"} ++ xstransact.Write(vbd_device_path, 'media-present', "1" ) ++ log.debug("wrote xenstore media-present 1 path:%s",vbd_media_path) ++ else: ++ xstransact.Write(vbd_device_path, 'media-present', "0" ) ++ log.debug("wrote xenstore media 0 path:%s",vbd_media_path) ++ ++def mylog( fmt, *args): ++ f = open('/tmp/haldaemon.log', 'a') ++ 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-4.3.0-testing/tools/python/xen/xend/server/Hald.py +=================================================================== +--- /dev/null ++++ xen-4.3.0-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 ++# License as published by the Free Software Foundation. ++# ++# This library 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 ++# Lesser General Public License for more details. ++# ++# You should have received a copy of the GNU Lesser General Public ++# License along with this library; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++#============================================================================ ++# Copyright (C) 2007 Pat Campbell ++# Copyright (C) 2007 Novell Inc. ++#============================================================================ ++ ++import errno ++import types ++import os ++import sys ++import time ++import signal ++from traceback import print_exc ++ ++from xen.xend.XendLogging import log ++ ++class Hald: ++ def __init__(self): ++ self.ready = False ++ self.running = True ++ ++ def run(self): ++ """Starts the HalDaemon process ++ """ ++ self.ready = True ++ try: ++ myfile = self.find("xen/xend/server/HalDaemon.py") ++ args = (["python", myfile ]) ++ self.pid = self.daemonize("python", args ) ++ #log.debug( "%s %s pid:%d", "Hald.py starting ", args, self.pid ) ++ except: ++ self.pid = -1 ++ log.debug("Unable to start HalDaemon process") ++ ++ def shutdown(self): ++ """Shutdown the HalDaemon process ++ """ ++ log.debug("%s pid:%d", "Hald.shutdown()", self.pid) ++ self.running = False ++ self.ready = False ++ if self.pid != -1: ++ try: ++ os.kill(self.pid, signal.SIGINT) ++ except: ++ print_exc() ++ ++ def daemonize(self,prog, args): ++ """Runs a program as a daemon with the list of arguments. Returns the PID ++ of the daemonized program, or returns 0 on error. ++ Copied from xm/create.py instead of importing to reduce coupling ++ """ ++ r, w = os.pipe() ++ pid = os.fork() ++ ++ if pid == 0: ++ os.close(r) ++ w = os.fdopen(w, 'w') ++ os.setsid() ++ try: ++ pid2 = os.fork() ++ except: ++ 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) ++ except: ++ pass ++ os.open("/dev/null", os.O_RDWR) ++ os.dup2(0, 1) ++ os.dup2(0, 2) ++ os.execvpe(prog, args, env) ++ os._exit(1) ++ else: ++ w.write(str(pid2 or 0)) ++ w.close() ++ os._exit(0) ++ os.close(w) ++ r = os.fdopen(r) ++ daemon_pid = int(r.read()) ++ r.close() ++ os.waitpid(pid, 0) ++ #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 ++ """ ++ for dirname in sys.path: ++ candidate = os.path.join(dirname, path) ++ if matchFunc(candidate): ++ return candidate ++ raise Error("Can't find file %s" % path) ++ ++if __name__ == "__main__": ++ watcher = Hald() ++ watcher.run() ++ time.sleep(10) ++ watcher.shutdown() +Index: xen-4.3.0-testing/tools/python/xen/xend/server/SrvServer.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/server/SrvServer.py ++++ xen-4.3.0-testing/tools/python/xen/xend/server/SrvServer.py +@@ -57,6 +57,7 @@ from xen.web.SrvDir import SrvDir + + from SrvRoot import SrvRoot + from XMLRPCServer import XMLRPCServer ++from xen.xend.server.Hald import Hald + + xoptions = XendOptions.instance() + +@@ -252,6 +253,8 @@ def _loadConfig(servers, root, reload): + if xoptions.get_xend_unix_xmlrpc_server(): + servers.add(XMLRPCServer(XendAPI.AUTH_PAM, False)) + ++ servers.add(Hald()) ++ + + def create(): + root = SrvDir() +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/xenstore.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c +@@ -18,12 +18,14 @@ + #include "exec-all.h" + #include "sysemu.h" + ++#include "console.h" + #include "hw.h" + #include "pci.h" + #include "qemu-timer.h" + #include "qemu-xen.h" + #include "xen_backend.h" + ++extern DisplayState *display_state; + struct xs_handle *xsh = NULL; + static char *media_filename[MAX_DRIVES+1]; + static QEMUTimer *insert_timer = NULL; +@@ -133,7 +135,8 @@ static void insert_media(void *opaque) + else + format = &bdrv_raw; + +- bdrv_open2(bs, media_filename[i], 0, format); ++ /* Temporary BDRV_O_RDWR */ ++ bdrv_open2(bs, media_filename[i], BDRV_O_RDWR, format); + #ifdef CONFIG_STUBDOM + { + char *buf, *backend, *params_path, *params; +@@ -443,13 +446,13 @@ void xenstore_init(void) + } + } + +-void xenstore_parse_domain_config(int hvm_domid) ++void xenstore_parse_domain_config(int hvm_domid, QEMUMachine *machine) + { + char **e_danger = NULL; + char *buf = NULL; +- char *fpath = NULL, *bpath = NULL, ++ char *fpath = NULL, *bpath = NULL, *btype = NULL, + *dev = NULL, *params = NULL, *drv = NULL; +- int i, ret; ++ int i, j, ret, is_tap; + unsigned int len, num, hd_index, pci_devid = 0; + BlockDriverState *bs; + BlockDriver *format; +@@ -486,6 +489,14 @@ void xenstore_parse_domain_config(int hv + e_danger[i]); + if (bpath == NULL) + continue; ++ /* check to see if type is tap or not */ ++ if (pasprintf(&buf, "%s/type", bpath) == -1) ++ continue; ++ free(btype); ++ btype = xs_read(xsh, XBT_NULL, buf, &len); ++ if (btype == NULL) ++ continue; ++ is_tap = !strncmp(btype, "tap", 3); + /* read the name of the device */ + if (pasprintf(&buf, "%s/dev", bpath) == -1) + continue; +@@ -500,7 +511,8 @@ void xenstore_parse_domain_config(int hv + } + + for (i = 0; i < num; i++) { +- format = NULL; /* don't know what the format is yet */ ++ flags = 0; ++ format = NULL; /* don't know what the format is yet */ + /* read the backend path */ + xenstore_get_backend_path(&bpath, "vbd", danger_path, hvm_domid, e_danger[i]); + if (bpath == NULL) +@@ -525,12 +537,7 @@ void xenstore_parse_domain_config(int hv + continue; + free(danger_type); + danger_type = xs_read(xsh, XBT_NULL, danger_buf, &len); +- if (pasprintf(&buf, "%s/params", bpath) == -1) +- continue; +- free(params); +- params = xs_read(xsh, XBT_NULL, buf, &len); +- if (params == NULL) +- continue; ++ + /* read the name of the device */ + if (pasprintf(&buf, "%s/type", bpath) == -1) + continue; +@@ -538,6 +545,35 @@ void xenstore_parse_domain_config(int hv + drv = xs_read(xsh, XBT_NULL, buf, &len); + if (drv == NULL) + continue; ++ ++ free(params); ++ if (!strcmp(drv,"iscsi") || !strcmp(drv, "npiv") || ++ !strcmp(drv,"dmmd")) { ++ if (pasprintf(&buf, "%s/node", bpath) == -1) ++ continue; ++ ++ /* wait for block-[iscsi|npiv|dmmd] script to complete and populate the ++ * node entry. try 30 times (30 secs) */ ++ for (j = 0; j < 30; j++) { ++ params = xs_read(xsh, XBT_NULL, buf, &len); ++ if (params != NULL) ++ break; ++ sleep(1); ++ } ++ if (params == NULL) { ++ fprintf(stderr, "qemu: %s device not found -- timed out \n", drv); ++ continue; ++ } ++ } ++ else ++ { ++ if (pasprintf(&buf, "%s/params", bpath) == -1) ++ continue; ++ params = xs_read(xsh, XBT_NULL, buf, &len); ++ if (params == NULL) ++ continue; ++ } ++ + /* Obtain blktap sub-type prefix */ + if ((!strcmp(drv, "tap") || !strcmp(drv, "qdisk")) && params[0]) { + char *offset = strchr(params, ':'); +@@ -562,6 +598,17 @@ void xenstore_parse_domain_config(int hv + format = &bdrv_raw; + } + ++ /* read the mode of the device */ ++ if (pasprintf(&buf, "%s/mode", bpath) == -1) ++ continue; ++ free(mode); ++ mode = xs_read(xsh, XBT_NULL, buf, &len); ++ ++ if (!strcmp(mode, "r") || !strcmp(mode, "ro")) ++ flags |= BDRV_O_RDONLY; ++ if (!strcmp(mode, "w") || !strcmp(mode, "rw")) ++ flags |= BDRV_O_RDWR; ++ + #if 0 + /* Phantom VBDs are disabled because the use of paths + * from guest-controlled areas in xenstore is unsafe. +@@ -596,6 +643,21 @@ void xenstore_parse_domain_config(int hv + #endif + + bs = bdrv_new(dev); ++ ++ /* if cdrom physical put a watch on media-present */ ++ if (bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM) { ++ if (drv && !strcmp(drv, "phy")) { ++ if (pasprintf(&buf, "%s/media-present", bpath) != -1) { ++ if (bdrv_is_inserted(bs)) ++ xs_write(xsh, XBT_NULL, buf, "1", strlen("1")); ++ else { ++ xs_write(xsh, XBT_NULL, buf, "0", strlen("0")); ++ } ++ xs_watch(xsh, buf, "media-present"); ++ } ++ } ++ } ++ + /* check if it is a cdrom */ + if (danger_type && !strcmp(danger_type, "cdrom")) { + bdrv_set_type_hint(bs, BDRV_TYPE_CDROM); +@@ -614,7 +676,7 @@ void xenstore_parse_domain_config(int hv + #ifdef CONFIG_STUBDOM + if (pasprintf(&danger_buf, "%s/device/vbd/%s", danger_path, e_danger[i]) == -1) + continue; +- if (bdrv_open2(bs, danger_buf, BDRV_O_CACHE_WB /* snapshot and write-back */, &bdrv_raw) == 0) { ++ if (bdrv_open2(bs, danger_buf, flags|BDRV_O_CACHE_WB /* snapshot and write-back */, &bdrv_raw) == 0) { + if (pasprintf(&buf, "%s/params", bpath) == -1) + continue; + free(params); +@@ -640,6 +702,12 @@ void xenstore_parse_domain_config(int hv + format = &bdrv_host_device; + else + format = &bdrv_raw; ++ } else if (!strcmp(drv,"iscsi")) { ++ format = &bdrv_raw; ++ } else if (!strcmp(drv,"npiv")) { ++ format = &bdrv_raw; ++ } else if (!strcmp(drv,"dmmd")) { ++ format = &bdrv_raw; + } else { + format = bdrv_find_format(drv); + if (!format) { +@@ -672,11 +740,19 @@ void xenstore_parse_domain_config(int hv + + #endif + +- drives_table[nb_drives].bdrv = bs; +- drives_table[nb_drives].used = 1; +- media_filename[nb_drives] = strdup(bs->filename); +- nb_drives++; +- ++ if (machine == &xenfv_machine) { ++ drives_table[nb_drives].bdrv = bs; ++ drives_table[nb_drives].used = 1; ++#ifdef CONFIG_STUBDOM ++ media_filename[nb_drives] = strdup(danger_buf); ++#else ++ media_filename[nb_drives] = strdup(bs->filename); ++#endif ++ nb_drives++; ++ } else { ++ qemu_aio_flush(); ++ bdrv_close(bs); ++ } + } + + #ifdef CONFIG_STUBDOM +@@ -762,6 +838,7 @@ void xenstore_parse_domain_config(int hv + free(mode); + free(params); + free(dev); ++ free(btype); + free(bpath); + free(buf); + free(danger_buf); +@@ -872,6 +949,19 @@ static void xenstore_process_dm_command_ + } else if (!strncmp(command, "continue", len)) { + fprintf(logfile, "dm-command: continue after state save\n"); + xen_pause_requested = 0; ++ } else if (!strncmp(command, "chgvncpasswd", len)) { ++ fprintf(logfile, "dm-command: change vnc passwd\n"); ++ if (pasprintf(&path, ++ "/local/domain/0/backend/vfb/%u/0/vncpasswd", domid) == -1) { ++ fprintf(logfile, "out of memory reading dm command parameter\n"); ++ goto out; ++ } ++ par = xs_read(xsh, XBT_NULL, path, &len); ++ if (!par) ++ goto out; ++ if (vnc_display_password(display_state, par) == 0) ++ xenstore_record_dm_state("vncpasswdchged"); ++ free(par); + } else if (!strncmp(command, "usb-add", len)) { + fprintf(logfile, "dm-command: usb-add a usb device\n"); + if (pasprintf(&path, +@@ -930,6 +1020,9 @@ static void xenstore_process_dm_command_ + do_pci_add(par); + free(par); + #endif ++ } else if (!strncmp(command, "flush-cache", len)) { ++ fprintf(logfile, "dm-command: flush caches\n"); ++ qemu_invalidate_map_cache(); + } else { + fprintf(logfile, "dm-command: unknown command\"%*s\"\n", len, command); + } +@@ -1086,6 +1179,50 @@ static void xenstore_process_vcpu_set_ev + return; + } + ++static 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, *offset, *bpath = NULL, *buf = NULL, *drv = NULL, *image = NULL; +@@ -1121,6 +1258,11 @@ void xenstore_process_event(void *opaque + xenstore_watch_callbacks[i].cb(vec[XS_WATCH_TOKEN], + xenstore_watch_callbacks[i].opaque); + ++ if (!strcmp(vec[XS_WATCH_TOKEN], "media-present")) { ++ xenstore_process_media_change_event(vec); ++ goto out; ++ } ++ + hd_index = drive_name_to_index(vec[XS_WATCH_TOKEN]); + if (hd_index == -1) { + fprintf(stderr,"medium change watch on `%s' -" +Index: xen-4.3.0-testing/tools/python/xen/xend/XendAuthSessions.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendAuthSessions.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendAuthSessions.py +@@ -84,7 +84,7 @@ class XendAuthSessions: + # if PAM doesn't exist, let's ignore it + return False + +- pam_auth.start("login") ++ pam_auth.start("xen-api") + pam_auth.set_item(PAM.PAM_USER, username) + + def _pam_conv(auth, query_list, user_data = None): +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/Makefile ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile +@@ -46,14 +46,6 @@ $(filter %-user,$(SUBDIR_RULES)): libqem + + recurse-all: $(SUBDIR_RULES) + +-CPPFLAGS += -I$(XEN_ROOT)/tools/libxc +-CPPFLAGS += -I$(XEN_ROOT)/tools/blktap/lib +-CPPFLAGS += -I$(XEN_ROOT)/tools/xenstore +-CPPFLAGS += -I$(XEN_ROOT)/tools/include +- +-tapdisk-ioemu: tapdisk-ioemu.c cutils.c block.c block-raw.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c block-qcow2.c hw/xen_blktap.c osdep.c +- $(CC) -DQEMU_TOOL $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS) +- + ####################################################################### + # BLOCK_OBJS is code used by both qemu system emulation and qemu-img + +@@ -72,6 +64,21 @@ endif + BLOCK_OBJS += block-raw-posix.o + endif + ++####################################################################### ++# tapdisk-ioemu ++ ++hw/tapdisk-xen_blktap.o: hw/xen_blktap.c ++ $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_IMG -DQEMU_TOOL -c -o $@ $< ++tapdisk-ioemu.o: tapdisk-ioemu.c ++ $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_IMG -DQEMU_TOOL -c -o $@ $< ++ ++tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/libxc ++tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/blktap/lib ++tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/xenstore ++tapdisk-ioemu: CPPFLAGS += -I$(XEN_ROOT)/tools/include ++tapdisk-ioemu: tapdisk-ioemu.o $(BLOCK_OBJS) qemu-tool.o hw/tapdisk-xen_blktap.o ++ $(CC) $(LDFLAGS) -o $@ $^ -lz $(LIBS) ++ + ###################################################################### + # libqemu_common.a: Target independent part of system emulation. The + # long term path is to suppress *all* target specific code in case of +@@ -243,7 +250,7 @@ endif + install: all $(if $(BUILD_DOCS),install-doc) + mkdir -p "$(DESTDIR)$(bindir)" + ifneq ($(TOOLS),) +- $(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)" ++ $(INSTALL) -m 755 $(TOOLS) "$(DESTDIR)$(bindir)" + endif + ifneq ($(BLOBS),) + mkdir -p "$(DESTDIR)$(datadir)" +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile.target +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/Makefile.target ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/Makefile.target +@@ -580,6 +580,10 @@ OBJS += e1000.o + # Serial mouse + OBJS += msmouse.o + ++# Generic watchdog support and some watchdog devices ++OBJS += watchdog.o ++OBJS += wdt_ib700.o wdt_i6300esb.o ++ + ifeq ($(TARGET_BASE_ARCH), i386) + # Hardware support + ifdef CONFIG_AUDIO +@@ -755,7 +759,7 @@ clean: + + install: all install-hook + ifneq ($(PROGS),) +- $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)" ++ $(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)" + endif + + # Include automatically generated dependency files +Index: xen-4.3.0-testing/tools/python/xen/xend/XendCheckpoint.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendCheckpoint.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendCheckpoint.py +@@ -123,6 +123,11 @@ def save(fd, dominfo, network, live, dst + str(int(live) | (int(hvm) << 2)) ] + log.debug("[xc_save]: %s", string.join(cmd)) + ++ # It is safe to release the domain lock at this point if not ++ # checkpointing ++ if checkpoint == False: ++ dominfo.release_running_lock(domain_name) ++ + def saveInputHandler(line, tochild): + log.debug("In saveInputHandler %s", line) + if line == "suspend": +@@ -172,7 +177,10 @@ def save(fd, dominfo, network, live, dst + dominfo.destroy() + dominfo.testDeviceComplete() + try: +- dominfo.setName(domain_name, False) ++ if checkpoint: ++ dominfo.setName(domain_name) ++ else: ++ dominfo.setName(domain_name, False) + except VmError: + # Ignore this. The name conflict (hopefully) arises because we + # are doing localhost migration; if we are doing a suspend of a +@@ -184,6 +192,9 @@ def save(fd, dominfo, network, live, dst + log.exception("Save failed on domain %s (%s) - resuming.", domain_name, + dominfo.getDomid()) + dominfo.resumeDomain() ++ # Reacquire the domain lock ++ if checkpoint == False: ++ dominfo.acquire_running_lock() + + try: + dominfo.setName(domain_name) +@@ -326,8 +337,7 @@ def restore(xd, fd, dominfo = None, paus + restore_image.setCpuid() + + # xc_restore will wait for source to close connection +- +- dominfo.completeRestore(handler.store_mfn, handler.console_mfn) ++ dominfo.completeRestore(handler.store_mfn, handler.console_mfn, console_port) + + # + # We shouldn't hold the domains_lock over a waitForDevices +@@ -351,6 +361,7 @@ def restore(xd, fd, dominfo = None, paus + if not paused: + dominfo.unpause() + ++ dominfo.acquire_running_lock() + return dominfo + except Exception, exn: + dominfo.destroy() +Index: xen-4.3.0-testing/tools/python/xen/xend/XendAPI.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendAPI.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendAPI.py +@@ -1941,10 +1941,10 @@ class XendAPI(object): + bool(live), port, node, ssl, bool(chs)) + return xen_api_success_void() + +- def VM_save(self, _, vm_ref, dest, checkpoint): ++ def VM_save(self, _, vm_ref, dest, checkpoint, force): + xendom = XendDomain.instance() + xeninfo = xendom.get_vm_by_uuid(vm_ref) +- xendom.domain_save(xeninfo.getDomid(), dest, checkpoint) ++ xendom.domain_save(xeninfo.getDomid(), dest, checkpoint, force) + return xen_api_success_void() + + def VM_restore(self, _, src, paused): +Index: xen-4.3.0-testing/tools/python/xen/xend/XendDomain.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendDomain.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendDomain.py +@@ -1505,7 +1505,7 @@ class XendDomain: + pass + sock.close() + +- def domain_save(self, domid, dst, checkpoint=False): ++ def domain_save(self, domid, dst, checkpoint=False, force=False): + """Start saving a domain to file. + + @param domid: Domain ID or Name +@@ -1521,6 +1521,9 @@ class XendDomain: + if not dominfo: + raise XendInvalidDomain(str(domid)) + ++ if os.access(dst, os.F_OK) and not force: ++ raise XendError("Save file:%s exist!\n" % dst) ++ + if dominfo.getDomid() == DOM0_ID: + raise XendError("Cannot save privileged domain %s" % str(domid)) + if dominfo._stateGet() != DOM_STATE_RUNNING: +@@ -1832,6 +1835,21 @@ class XendDomain: + log.exception(ex) + raise XendError(str(ex)) + ++ def domain_swaptarget_set(self, domid, mem): ++ """Set the memory limit for a domain. ++ ++ @param domid: Domain ID or Name ++ @type domid: int or string. ++ @param mem: memory limit (in MiB) ++ @type mem: int ++ @raise XendError: fail to set memory ++ @rtype: 0 ++ """ ++ dominfo = self.domain_lookup_nr(domid) ++ if not dominfo: ++ raise XendInvalidDomain(str(domid)) ++ dominfo.setSwapTarget(mem) ++ + def domain_maxmem_set(self, domid, mem): + """Set the memory limit for a domain. + +Index: xen-4.3.0-testing/tools/python/xen/xend/XendAPIConstants.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendAPIConstants.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendAPIConstants.py +@@ -45,8 +45,10 @@ XEN_API_ON_NORMAL_EXIT = [ + XEN_API_ON_CRASH_BEHAVIOUR = [ + 'destroy', + 'coredump_and_destroy', ++ 'coredump_destroy', + 'restart', + 'coredump_and_restart', ++ 'coredump_restart', + 'preserve', + 'rename_restart' + ] +Index: xen-4.3.0-testing/tools/python/xen/xend/XendConfig.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendConfig.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendConfig.py +@@ -147,6 +147,11 @@ XENAPI_PLATFORM_CFG_TYPES = { + 'apic': int, + 'boot': str, + 'device_model': str, ++ 'actmem': str, ++ 'xenpaging_file': str, ++ 'xenpaging_extra': str, ++ 'smbios_firmware': str, ++ 'acpi_firmware': str, + 'loader': str, + 'display' : str, + 'fda': str, +@@ -159,6 +164,7 @@ XENAPI_PLATFORM_CFG_TYPES = { + 'nographic': int, + 'nomigrate': int, + 'pae' : int, ++ 'extid': int, + 'rtc_timeoffset': int, + 'parallel': str, + 'serial': str, +@@ -192,6 +198,8 @@ XENAPI_PLATFORM_CFG_TYPES = { + 'xen_platform_pci': int, + "gfx_passthru": int, + 'oos' : int, ++ 'watchdog': str, ++ 'watchdog_action': str, + } + + # Xen API console 'other_config' keys. +@@ -512,8 +520,20 @@ class XendConfig(dict): + self['platform']['nomigrate'] = 0 + + if self.is_hvm(): ++ if 'actmem' not in self['platform']: ++ self['platform']['actmem'] = "0" ++ if 'xenpaging_file' not in self['platform']: ++ self['platform']['xenpaging_file'] = "" ++ if 'xenpaging_extra' not in self['platform']: ++ self['platform']['xenpaging_extra'] = [] ++ if 'smbios_firmware' not in self['platform']: ++ self['platform']['smbios_firmware'] = "" ++ if 'acpi_firmware' not in self['platform']: ++ self['platform']['acpi_firmware'] = "" + if 'timer_mode' not in self['platform']: + self['platform']['timer_mode'] = 1 ++ if 'extid' in self['platform'] and int(self['platform']['extid']) == 1: ++ self['platform']['viridian'] = 1 + if 'viridian' not in self['platform']: + self['platform']['viridian'] = 0 + if 'rtc_timeoffset' not in self['platform']: +@@ -1865,7 +1885,14 @@ class XendConfig(dict): + ports = sxp.child(dev_sxp, 'port') + for port in ports[1:]: + try: +- num, bus = port ++ # When ['port' ['1','']] is saved into sxp file, it will become (port (1 )) ++ # If using this sxp file, here variable "port" will be port=1, ++ # we should process it, otherwise, it will report error. ++ if len(port) == 1: ++ num = port[0] ++ bus = "" ++ else: ++ num, bus = port + dev_config['port-%i' % int(num)] = str(bus) + except TypeError: + pass +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_console.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_console.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_console.c +@@ -38,6 +38,8 @@ + #include "qemu-char.h" + #include "xen_backend.h" + ++static int log_guest = 0; ++ + struct buffer { + uint8_t *data; + size_t consumed; +@@ -54,8 +56,24 @@ struct XenConsole { + void *sring; + CharDriverState *chr; + int backlog; ++ int log_fd; + }; + ++static int write_all(int fd, const char* buf, size_t len) ++{ ++ while (len) { ++ ssize_t ret = write(fd, buf, len); ++ if (ret == -1 && errno == EINTR) ++ continue; ++ if (ret < 0) ++ return -1; ++ len -= ret; ++ buf += ret; ++ } ++ ++ return 0; ++} ++ + static void buffer_append(struct XenConsole *con) + { + struct buffer *buffer = &con->buffer; +@@ -83,6 +101,15 @@ static void buffer_append(struct XenCons + intf->out_cons = cons; + xen_be_send_notify(&con->xendev); + ++ if (con->log_fd != -1) { ++ int logret; ++ logret = write_all(con->log_fd, buffer->data + buffer->size - size, size); ++ if (logret < 0) { ++ xen_be_printf(&con->xendev, 1, "Write to log failed on domain %d: %d (%s)\n", ++ con->xendev.dom, errno, strerror(errno)); ++ } ++ } ++ + if (buffer->max_capacity && + buffer->size > buffer->max_capacity) { + /* Discard the middle of the data. */ +@@ -176,6 +203,37 @@ static void xencons_send(struct XenConso + } + } + ++static int create_domain_log(struct XenConsole *con) ++{ ++ char *logfile; ++ char *path, *domname; ++ int fd; ++ const char *logdir = "/var/log/xen/console"; ++ ++ path = xs_get_domain_path(xenstore, con->xendev.dom); ++ domname = xenstore_read_str(path, "name"); ++ free(path); ++ if (!domname) ++ return -1; ++ ++ if (mkdir(logdir, 0755) && errno != EEXIST) ++ { ++ xen_be_printf(&con->xendev, 1, "Directory %s does not exist and fail to create it!", logdir); ++ return -1; ++ } ++ ++ if (asprintf(&logfile, "%s/guest-%s.log", logdir, domname) < 0) ++ return -1; ++ qemu_free(domname); ++ ++ fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644); ++ free(logfile); ++ if (fd == -1) ++ xen_be_printf(&con->xendev, 1, "Failed to open log %s: %d (%s)", logfile, errno, strerror(errno)); ++ ++ return fd; ++} ++ + /* -------------------------------------------------------------------- */ + + static int con_init(struct XenDevice *xendev) +@@ -183,6 +241,7 @@ static int con_init(struct XenDevice *xe + struct XenConsole *con = container_of(xendev, struct XenConsole, xendev); + char *type, *dom, label[32]; + const char *output; ++ char *logenv = NULL; + + /* setup */ + dom = xs_get_domain_path(xenstore, con->xendev.dom); +@@ -209,6 +268,10 @@ static int con_init(struct XenDevice *xe + con->chr = qemu_chr_open(label, output, NULL); + xenstore_store_pv_console_info(con->xendev.dev, con->chr, output); + ++ logenv = getenv("XENCONSOLED_TRACE"); ++ if (logenv != NULL && strlen(logenv) == strlen("guest") && !strcmp(logenv, "guest")) { ++ log_guest = 1; ++ } + return 0; + } + +@@ -246,6 +309,9 @@ static int con_initialise(struct XenDevi + con->xendev.remote_port, + con->xendev.local_port, + con->buffer.max_capacity); ++ con->log_fd = -1; ++ if (log_guest) ++ con->log_fd = create_domain_log(con); + return 0; + } + +@@ -266,6 +332,12 @@ static void con_disconnect(struct XenDev + xc_gnttab_munmap(xendev->gnttabdev, con->sring, 1); + con->sring = NULL; + } ++ ++ if (con->log_fd != -1) { ++ close(con->log_fd); ++ con->log_fd = -1; ++ } ++ + } + + static void con_event(struct XenDevice *xendev) +Index: xen-4.3.0-testing/tools/python/xen/xm/xenapi_create.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xm/xenapi_create.py ++++ xen-4.3.0-testing/tools/python/xen/xm/xenapi_create.py +@@ -740,7 +740,7 @@ class sxp2xml: + + if get_child_by_name(config, "maxmem"): + memory.attributes["static_max"] = \ +- str(int(get_child_by_name(config, "maxmem")*1024*1024)) ++ str(int(get_child_by_name(config, "maxmem"))*1024*1024) + + vm.appendChild(memory) + +@@ -1046,7 +1046,12 @@ class sxp2xml: + 'acpi', + 'apic', + 'boot', ++ 'actmem', ++ 'xenpaging_file', ++ 'xenpaging_extra', + 'device_model', ++ 'smbios_firmware', ++ 'acpi_firmware', + 'loader', + 'fda', + 'fdb', +@@ -1074,7 +1079,9 @@ class sxp2xml: + 'xen_platform_pci', + 'tsc_mode' + 'description', +- 'nomigrate' ++ 'nomigrate', ++ 'watchdog', ++ 'watchdog_action' + ] + + platform_configs = [] +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_machine_fv.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_machine_fv.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_machine_fv.c +@@ -270,6 +270,7 @@ void qemu_invalidate_entry(uint8_t *buff + + #endif /* defined(MAPCACHE) */ + ++extern void init_blktap(void); + + static void xen_init_fv(ram_addr_t ram_size, int vga_ram_size, + const char *boot_device, +@@ -295,6 +296,11 @@ static void xen_init_fv(ram_addr_t ram_s + } + #endif + ++#ifndef CONFIG_STUBDOM ++ /* Initialize tapdisk client */ ++ init_blktap(); ++#endif ++ + #ifdef CONFIG_STUBDOM /* the hvmop is not supported on older hypervisors */ + xc_set_hvm_param(xc_handle, domid, HVM_PARAM_DM_DOMAIN, DOMID_SELF); + #endif +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.c +@@ -46,7 +46,7 @@ + #define BLKTAP_CTRL_DIR "/var/run/tap" + + /* If enabled, print debug messages to stderr */ +-#if 1 ++#if 0 + #define DPRINTF(_f, _a...) fprintf(stderr, __FILE__ ":%d: " _f, __LINE__, ##_a) + #else + #define DPRINTF(_f, _a...) ((void)0) +@@ -65,6 +65,7 @@ int read_fd; + int write_fd; + + static pid_t process; ++int connected_disks = 0; + fd_list_entry_t *fd_start = NULL; + + static void handle_blktap_iomsg(void* private); +@@ -218,11 +219,13 @@ static int map_new_dev(struct td_state * + return -1; + } + +-static int open_disk(struct td_state *s, char *path, int readonly) ++static int open_disk(struct td_state *s, char *path, int driver, int readonly) + { + BlockDriverState* bs; ++ BlockDriver* drv; + char* devname; + static int devnumber = 0; ++ int flags = readonly ? BDRV_O_RDONLY : BDRV_O_RDWR; + int i; + + DPRINTF("Opening %s as blktap%d\n", path, devnumber); +@@ -230,7 +233,25 @@ static int open_disk(struct td_state *s, + bs = bdrv_new(devname); + free(devname); + +- if (bdrv_open(bs, path, 0) != 0) { ++ /* Search for disk driver */ ++ for (i = 0; blktap_drivers[i].idnum >= 0; i++) { ++ if (blktap_drivers[i].idnum == driver) ++ break; ++ } ++ ++ if (blktap_drivers[i].idnum < 0) { ++ fprintf(stderr, "Could not find image format id %d\n", driver); ++ return -ENOMEM; ++ } ++ ++ drv = blktap_drivers[i].drv; ++ DPRINTF("%s driver specified\n", drv ? drv->format_name : "No"); ++ ++ /* Open the image ++ * Use BDRV_O_CACHE_WB for write-through caching, ++ * no flags for write-back caching ++ */ ++ if (bdrv_open2(bs, path, flags|BDRV_O_CACHE_WB, drv) != 0) { + fprintf(stderr, "Could not open image file %s\n", path); + return -ENOMEM; + } +@@ -240,6 +261,12 @@ static int open_disk(struct td_state *s, + s->size = bs->total_sectors; + s->sector_size = 512; + ++ if (s->size == 0) { ++ fprintf(stderr, "Error: Disk image %s is too small\n", ++ path); ++ return -ENOMEM; ++ } ++ + s->info = ((s->flags & TD_RDONLY) ? VDISK_READONLY : 0); + + #ifndef QEMU_TOOL +@@ -337,6 +364,15 @@ static void qemu_send_responses(void* op + } + + /** ++ * Callback function for AIO flush ++ */ ++static void qemu_flush_response(void* opaque, int ret) { ++ if (ret != 0) { ++ DPRINTF("aio_flush: ret = %d (%s)\n", ret, strerror(-ret)); ++ } ++} ++ ++/** + * Callback function for the IO message pipe. Reads requests from the ring + * and processes them (call qemu read/write functions). + * +@@ -355,6 +391,7 @@ static void handle_blktap_iomsg(void* pr + blkif_t *blkif = s->blkif; + tapdev_info_t *info = s->ring_info; + int page_size = getpagesize(); ++ int sync; + + struct aiocb_info *aiocb_info; + +@@ -387,7 +424,7 @@ static void handle_blktap_iomsg(void* pr + + /* Don't allow writes on readonly devices */ + if ((s->flags & TD_RDONLY) && +- (req->operation == BLKIF_OP_WRITE)) { ++ (req->operation != BLKIF_OP_READ)) { + blkif->pending_list[idx].status = BLKIF_RSP_ERROR; + goto send_response; + } +@@ -408,7 +445,7 @@ static void handle_blktap_iomsg(void* pr + DPRINTF("Sector request failed:\n"); + DPRINTF("%s request, idx [%d,%d] size [%llu], " + "sector [%llu,%llu]\n", +- (req->operation == BLKIF_OP_WRITE ? ++ (req->operation != BLKIF_OP_READ ? + "WRITE" : "READ"), + idx,i, + (long long unsigned) +@@ -421,8 +458,14 @@ static void handle_blktap_iomsg(void* pr + + blkif->pending_list[idx].secs_pending += nsects; + +- switch (req->operation) ++ sync = 0; ++ switch (req->operation) + { ++ case BLKIF_OP_WRITE_BARRIER: ++ sync = 1; ++ bdrv_aio_flush(s->bs, qemu_flush_response, NULL); ++ /* fall through */ ++ + case BLKIF_OP_WRITE: + aiocb_info = malloc(sizeof(*aiocb_info)); + +@@ -442,6 +485,10 @@ static void handle_blktap_iomsg(void* pr + DPRINTF("ERROR: bdrv_write() == NULL\n"); + goto send_response; + } ++ ++ if (sync) ++ bdrv_aio_flush(s->bs, qemu_flush_response, NULL); ++ + break; + + case BLKIF_OP_READ: +@@ -519,9 +566,10 @@ static void handle_blktap_ctrlmsg(void* + + /* Allocate the disk structs */ + s = state_init(); ++ connected_disks++; + + /*Open file*/ +- if (s == NULL || open_disk(s, path, msg->readonly)) { ++ if (s == NULL || open_disk(s, path, msg->drivertype, msg->readonly)) { + msglen = sizeof(msg_hdr_t); + msg->type = CTLMSG_IMG_FAIL; + msg->len = msglen; +@@ -569,7 +617,8 @@ static void handle_blktap_ctrlmsg(void* + case CTLMSG_CLOSE: + s = get_state(msg->cookie); + if (s) unmap_disk(s); +- break; ++ connected_disks--; ++ break; + + case CTLMSG_PID: + memset(buf, 0x00, MSG_SIZE); +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.h +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.h ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_blktap.h +@@ -52,4 +52,18 @@ typedef struct fd_list_entry { + + int init_blktap(void); + ++typedef struct disk_info { ++ int idnum; ++ struct BlockDriver *drv; ++} disk_info_t; ++ ++static disk_info_t blktap_drivers[] = { ++ { DISK_TYPE_AIO, &bdrv_raw }, ++ { DISK_TYPE_SYNC, &bdrv_raw }, ++ { DISK_TYPE_VMDK, &bdrv_vmdk }, ++ { DISK_TYPE_QCOW, &bdrv_qcow }, ++ { DISK_TYPE_QCOW2, &bdrv_qcow2 }, ++ { -1, NULL } ++}; ++ + #endif /*XEN_BLKTAP_H_*/ +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/configure +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/configure ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/configure +@@ -1511,7 +1511,7 @@ bsd) + ;; + esac + +-tools= ++tools="tapdisk-ioemu" + if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then + tools="qemu-img\$(EXESUF) $tools" + if [ "$linux" = "yes" ] ; then +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-tool.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/qemu-tool.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-tool.c +@@ -68,7 +68,7 @@ void qemu_bh_delete(QEMUBH *bh) + qemu_free(bh); + } + +-int qemu_set_fd_handler2(int fd, ++int __attribute__((weak)) qemu_set_fd_handler2(int fd, + IOCanRWHandler *fd_read_poll, + IOHandler *fd_read, + IOHandler *fd_write, +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/tapdisk-ioemu.c +@@ -12,34 +12,13 @@ + + extern void qemu_aio_init(void); + extern void qemu_aio_poll(void); +-extern void bdrv_init(void); +- +-extern void *qemu_mallocz(size_t size); +-extern void qemu_free(void *ptr); + + extern void *fd_start; ++extern int connected_disks; + + int domid = 0; + FILE* logfile; + +-void term_printf(const char *fmt, ...) +-{ +- va_list ap; +- va_start(ap, fmt); +- vprintf(fmt, ap); +- va_end(ap); +-} +- +-void term_print_filename(const char *filename) +-{ +- term_printf(filename); +-} +- +- +-typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); +-typedef int IOCanRWHandler(void *opaque); +-typedef void IOHandler(void *opaque); +- + typedef struct IOHandlerRecord { + int fd; + IOCanRWHandler *fd_read_poll; +@@ -98,25 +77,29 @@ int main(void) + int max_fd; + fd_set rfds; + struct timeval tv; +- void *old_fd_start = NULL; ++ int old_connected_disks = 0; ++ ++ /* Daemonize */ ++ if (fork() != 0) ++ exit(0); + +- logfile = stderr; +- + bdrv_init(); +- qemu_aio_init(); + init_blktap(); + +- /* Daemonize */ +- if (fork() != 0) +- exit(0); +- ++ logfile = fopen("/var/log/xen/tapdisk-ioemu.log", "a"); ++ if (logfile) { ++ setbuf(logfile, NULL); ++ fclose(stderr); ++ stderr = logfile; ++ } else { ++ logfile = stderr; ++ } ++ + /* + * Main loop: Pass events to the corrsponding handlers and check for + * completed aio operations. + */ + while (1) { +- qemu_aio_poll(); +- + max_fd = -1; + FD_ZERO(&rfds); + for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) +@@ -146,11 +129,17 @@ int main(void) + pioh = &ioh->next; + } + ++ if (old_connected_disks != connected_disks) ++ fprintf(stderr, "connected disks: %d => %d\n", ++ old_connected_disks, connected_disks); ++ + /* Exit when the last image has been closed */ +- if (old_fd_start != NULL && fd_start == NULL) ++ if (old_connected_disks != 0 && connected_disks == 0) { ++ fprintf(stderr, "Last image is closed, exiting.\n"); + exit(0); ++ } + +- old_fd_start = fd_start; ++ old_connected_disks = connected_disks; + } + return 0; + } +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/block.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/block.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/block.c +@@ -350,7 +350,7 @@ int bdrv_file_open(BlockDriverState **pb + + int bdrv_open(BlockDriverState *bs, const char *filename, int flags) + { +- return bdrv_open2(bs, filename, flags, NULL); ++ return bdrv_open2(bs, filename, flags|BDRV_O_RDWR, NULL); + } + + int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, +@@ -419,12 +419,13 @@ int bdrv_open2(BlockDriverState *bs, con + } + bs->drv = drv; + bs->opaque = qemu_mallocz(drv->instance_size); +- /* Note: for compatibility, we open disk image files as RDWR, and +- RDONLY as fallback */ + if (!(flags & BDRV_O_FILE)) +- open_flags = (flags & BDRV_O_ACCESS) | (flags & BDRV_O_CACHE_MASK); ++ open_flags = flags; + else + open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); ++ if (!(open_flags & BDRV_O_RDWR)) ++ bs->read_only = 1; ++ + ret = drv->bdrv_open(bs, filename, open_flags); + if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) { + ret = drv->bdrv_open(bs, filename, open_flags & ~BDRV_O_RDWR); +@@ -595,6 +596,16 @@ int bdrv_read(BlockDriverState *bs, int6 + + if (bdrv_check_request(bs, sector_num, nb_sectors)) + return -EIO; ++ ++ if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { ++ memcpy(buf, bs->boot_sector_data, 512); ++ sector_num++; ++ nb_sectors--; ++ buf += 512; ++ if (nb_sectors == 0) ++ return 0; ++ } ++ + if (drv->bdrv_pread) { + int ret, len; + len = nb_sectors * 512; +@@ -630,6 +641,10 @@ int bdrv_write(BlockDriverState *bs, int + if (bdrv_check_request(bs, sector_num, nb_sectors)) + return -EIO; + ++ if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { ++ memcpy(bs->boot_sector_data, buf, 512); ++ } ++ + if (drv->bdrv_pwrite) { + int ret, len, count = 0; + len = nb_sectors * 512; +@@ -933,6 +948,16 @@ void bdrv_guess_geometry(BlockDriverStat + } + } + ++/* force a given boot sector. */ ++void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size) ++{ ++ bs->boot_sector_enabled = 1; ++ if (size > 512) ++ size = 512; ++ memcpy(bs->boot_sector_data, data, size); ++ memset(bs->boot_sector_data + size, 0, 512 - size); ++} ++ + void bdrv_set_geometry_hint(BlockDriverState *bs, + int cyls, int heads, int secs) + { +@@ -1463,6 +1488,14 @@ BlockDriverAIOCB *bdrv_aio_read(BlockDri + if (bdrv_check_request(bs, sector_num, nb_sectors)) + return NULL; + ++ /* XXX: we assume that nb_sectors == 0 is suppored by the async read */ ++ if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { ++ memcpy(buf, bs->boot_sector_data, 512); ++ sector_num++; ++ nb_sectors--; ++ buf += 512; ++ } ++ + ret = drv->bdrv_aio_read(bs, sector_num, buf, nb_sectors, cb, opaque); + + if (ret) { +@@ -1488,6 +1521,10 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDr + if (bdrv_check_request(bs, sector_num, nb_sectors)) + return NULL; + ++ if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { ++ memcpy(bs->boot_sector_data, buf, 512); ++ } ++ + ret = drv->bdrv_aio_write(bs, sector_num, buf, nb_sectors, cb, opaque); + + if (ret) { +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/usb-msd.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/usb-msd.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/usb-msd.c +@@ -551,7 +551,7 @@ USBDevice *usb_msd_init(const char *file + s = qemu_mallocz(sizeof(MSDState)); + + bdrv = bdrv_new("usb"); +- if (bdrv_open2(bdrv, filename, 0, drv) < 0) ++ if (bdrv_open2(bdrv, filename, BDRV_O_RDWR, drv) < 0) + goto fail; + s->bs = bdrv; + *pbs = bdrv; +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-img.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/qemu-img.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-img.c +@@ -32,7 +32,7 @@ + #endif + + /* Default to cache=writeback as data integrity is not important for qemu-tcg. */ +-#define BRDV_O_FLAGS BDRV_O_CACHE_WB ++#define BDRV_O_FLAGS BDRV_O_CACHE_WB + + static void QEMU_NORETURN error(const char *fmt, ...) + { +@@ -185,7 +185,7 @@ static int read_password(char *buf, int + #endif + + static BlockDriverState *bdrv_new_open(const char *filename, +- const char *fmt) ++ const char *fmt, int flags) + { + BlockDriverState *bs; + BlockDriver *drv; +@@ -201,7 +201,7 @@ static BlockDriverState *bdrv_new_open(c + } else { + drv = &bdrv_raw; + } +- if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { ++ if (bdrv_open2(bs, filename, flags, drv) < 0) { + error("Could not open '%s'", filename); + } + if (bdrv_is_encrypted(bs)) { +@@ -253,7 +253,7 @@ static int img_create(int argc, char **a + size = 0; + if (base_filename) { + BlockDriverState *bs; +- bs = bdrv_new_open(base_filename, NULL); ++ bs = bdrv_new_open(base_filename, NULL, BDRV_O_RDWR); + bdrv_get_geometry(bs, &size); + size *= 512; + bdrv_delete(bs); +@@ -332,7 +332,7 @@ static int img_commit(int argc, char **a + } else { + drv = NULL; + } +- if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { ++ if (bdrv_open2(bs, filename, BDRV_O_RDWR, drv) < 0) { + error("Could not open '%s'", filename); + } + ret = bdrv_commit(bs); +@@ -455,7 +455,8 @@ static int img_convert(int argc, char ** + + total_sectors = 0; + for (bs_i = 0; bs_i < bs_n; bs_i++) { +- bs[bs_i] = bdrv_new_open(argv[optind + bs_i], fmt); ++ bs[bs_i] = bdrv_new_open(argv[optind + bs_i], fmt, ++ BDRV_O_CACHE_WB|BDRV_O_RDONLY); + if (!bs[bs_i]) + error("Could not open '%s'", argv[optind + bs_i]); + bdrv_get_geometry(bs[bs_i], &bs_sectors); +@@ -483,7 +484,7 @@ static int img_convert(int argc, char ** + } + } + +- out_bs = bdrv_new_open(out_filename, out_fmt); ++ out_bs = bdrv_new_open(out_filename, out_fmt, BDRV_O_CACHE_WB|BDRV_O_RDWR); + + bs_i = 0; + bs_offset = 0; +@@ -706,7 +707,7 @@ static int img_info(int argc, char **arg + } else { + drv = NULL; + } +- if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { ++ if (bdrv_open2(bs, filename, BDRV_O_FLAGS|BDRV_O_RDWR, drv) < 0) { + error("Could not open '%s'", filename); + } + bdrv_get_format(bs, fmt_name, sizeof(fmt_name)); +@@ -810,7 +811,7 @@ static void img_snapshot(int argc, char + if (!bs) + error("Not enough memory"); + +- if (bdrv_open2(bs, filename, 0, NULL) < 0) { ++ if (bdrv_open2(bs, filename, BDRV_O_RDWR, NULL) < 0) { + error("Could not open '%s'", filename); + } + +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/block-qcow2.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/block-qcow2.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/block-qcow2.c +@@ -916,7 +916,7 @@ static int alloc_cluster_link_l2(BlockDr + goto err; + + for (i = 0; i < j; i++) +- free_any_clusters(bs, old_cluster[i], 1); ++ free_any_clusters(bs, be64_to_cpu(old_cluster[i]) & ~QCOW_OFLAG_COPIED, 1); + + ret = 0; + err: +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_platform.c +@@ -30,6 +30,8 @@ + #include "qemu-xen.h" + #include "net.h" + #include "xen_platform.h" ++#include "sysemu.h" ++#include + + #include + #include +@@ -335,11 +337,66 @@ static void xen_platform_ioport_writeb(v + } + } + ++static uint32_t ioport_base; ++ ++static void platform_ioport_write(void *opaque, uint32_t addr, uint32_t val) ++{ ++ DECLARE_DOMCTL; ++ int rc; ++ ++ if (val == 0) ++ qemu_invalidate_map_cache(); ++ ++ switch (addr - ioport_base) { ++ case 0: ++ fprintf(logfile, "Init hypercall page %x, addr %x.\n", val, addr); ++ domctl.domain = (domid_t)domid; ++ domctl.u.hypercall_init.gmfn = val; ++ domctl.cmd = XEN_DOMCTL_hypercall_init; ++ rc = xc_domctl(xc_handle, &domctl); ++ fprintf(logfile, "result -> %d.\n", rc); ++ break; ++ case 4: ++ fprintf(logfile, "Disconnect IDE hard disk...\n"); ++ ide_unplug_harddisks(); ++ fprintf(logfile, "Disconnect SCSI hard disk...\n"); ++ pci_unplug_scsi(); ++ fprintf(logfile, "Disconnect netifs...\n"); ++ pci_unplug_netifs(); ++ fprintf(logfile, "Shutdown taps...\n"); ++ net_tap_shutdown_all(); ++ fprintf(logfile, "Done.\n"); ++ break; ++ case 8: ++ if (val ==1 ) { ++ fprintf(logfile, "Disconnect IDE hard disk...\n"); ++ ide_unplug_harddisks(); ++ fprintf(logfile, "Done.\n"); ++ } else if (val == 2) { ++ fprintf(logfile, "Disconnect netifs...\n"); ++ pci_unplug_netifs(); ++ fprintf(logfile, "Shutdown taps...\n"); ++ net_tap_shutdown_all(); ++ fprintf(logfile, "Done.\n"); ++ } ++ break; ++ default: ++ fprintf(logfile, "Write to bad port %x (base %x) on evtchn device.\n", ++ addr, ioport_base); ++ break; ++ } ++} ++ + static void platform_ioport_map(PCIDevice *pci_dev, int region_num, uint32_t addr, uint32_t size, int type) + { ++ ioport_base = addr; ++ ++ register_ioport_write(addr, 16, 4, platform_ioport_write, NULL); ++/* + PCIXenPlatformState *d = (PCIXenPlatformState *)pci_dev; + register_ioport_write(addr, size, 1, xen_platform_ioport_writeb, d); + register_ioport_read(addr, size, 1, xen_platform_ioport_readb, d); ++*/ + } + + static uint32_t platform_mmio_read(void *opaque, target_phys_addr_t addr) +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/ide.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/ide.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/ide.c +@@ -935,8 +935,9 @@ static inline void ide_dma_submit_check( + + static inline void ide_set_irq(IDEState *s) + { +- BMDMAState *bm = s->bmdma; +- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ ++ BMDMAState *bm; ++ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ ++ bm = s->bmdma; + if (!(s->cmd & IDE_CMD_DISABLE_IRQ)) { + if (bm) { + bm->status |= BM_STATUS_INT; +@@ -1224,14 +1225,14 @@ static void ide_read_dma_cb(void *opaque + int n; + int64_t sector_num; + ++ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ ++ + if (ret < 0) { + dma_buf_commit(s, 1); + ide_dma_error(s); + return; + } + +- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ +- + n = s->io_buffer_size >> 9; + sector_num = ide_get_sector(s); + if (n > 0) { +@@ -1335,6 +1336,8 @@ static void ide_write_flush_cb(void *opa + BMDMAState *bm = opaque; + IDEState *s = bm->ide_if; + ++ if (!s) return; /* yikes */ ++ + if (ret != 0) { + ide_dma_error(s); + return; +@@ -1366,13 +1369,13 @@ static void ide_write_dma_cb(void *opaqu + int n; + int64_t sector_num; + ++ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ ++ + if (ret < 0) { + if (ide_handle_write_error(s, -ret, BM_STATUS_DMA_RETRY)) + return; + } + +- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ +- + n = s->io_buffer_size >> 9; + sector_num = ide_get_sector(s); + if (n > 0) { +@@ -1429,7 +1432,7 @@ static void ide_flush_cb(void *opaque, i + { + IDEState *s = opaque; + +- if (!s->bs) return; /* ouch! (see below) */ ++ if (!s || !s->bs) return; /* ouch! (see below) */ + + if (ret) { + /* We are completely doomed. The IDE spec does not permit us +@@ -1686,7 +1689,7 @@ static void ide_atapi_cmd_read_dma_cb(vo + IDEState *s = bm->ide_if; + int data_offset, n; + +- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ ++ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ + + if (ret < 0) { + ide_atapi_io_error(s, ret); +@@ -2365,7 +2368,7 @@ static void cdrom_change_cb(void *opaque + IDEState *s = opaque; + uint64_t nb_sectors; + +- if (!s->bs) return; /* ouch! (see ide_flush_cb) */ ++ if (!s || !s->bs) return; /* ouch! (see ide_flush_cb) */ + + bdrv_get_geometry(s->bs, &nb_sectors); + s->nb_sectors = nb_sectors; +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/vl.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/vl.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/vl.c +@@ -30,6 +30,7 @@ + #include "hw/isa.h" + #include "hw/baum.h" + #include "hw/bt.h" ++#include "hw/watchdog.h" + #include "net.h" + #include "console.h" + #include "sysemu.h" +@@ -200,7 +201,7 @@ DriveInfo drives_table[MAX_DRIVES+1]; + int nb_drives; + enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; + int vga_ram_size; +-static DisplayState *display_state; ++DisplayState *display_state; + int nographic; + static int curses; + static int sdl; +@@ -2627,6 +2628,8 @@ int drive_init(struct drive_opt *arg, in + strncpy(drives_table[nb_drives].serial, serial, sizeof(serial)); + nb_drives++; + ++ bdrv_flags = BDRV_O_RDWR; ++ + switch(type) { + case IF_IDE: + case IF_XEN: +@@ -2640,6 +2643,7 @@ int drive_init(struct drive_opt *arg, in + break; + case MEDIA_CDROM: + bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM); ++ bdrv_flags &= ~BDRV_O_RDWR; + break; + } + break; +@@ -2660,7 +2664,6 @@ int drive_init(struct drive_opt *arg, in + } + if (!file[0]) + return -2; +- bdrv_flags = 0; + if (snapshot) { + bdrv_flags |= BDRV_O_SNAPSHOT; + cache = 2; /* always use write-back with snapshot */ +@@ -4175,6 +4178,10 @@ static void help(int exitcode) + "-startdate select initial date of the clock\n" + "-icount [N|auto]\n" + " enable virtual instruction counter with 2^N clock ticks per instruction\n" ++ "-watchdog i6300esb|ib700\n" ++ " enable virtual hardware watchdog [default=none]\n" ++ "-watchdog-action reset|shutdown|poweroff|pause|debug|none\n" ++ " action when watchdog fires [default=reset]\n" + "-echr chr set terminal escape character instead of ctrl-a\n" + "-virtioconsole c\n" + " set virtio console\n" +@@ -4322,6 +4329,8 @@ enum { + QEMU_OPTION_localtime, + QEMU_OPTION_startdate, + QEMU_OPTION_icount, ++ QEMU_OPTION_watchdog, ++ QEMU_OPTION_watchdog_action, + QEMU_OPTION_echr, + QEMU_OPTION_virtiocon, + QEMU_OPTION_show_cursor, +@@ -4448,6 +4457,8 @@ static const QEMUOption qemu_options[] = + { "localtime", 0, QEMU_OPTION_localtime }, + { "startdate", HAS_ARG, QEMU_OPTION_startdate }, + { "icount", HAS_ARG, QEMU_OPTION_icount }, ++ { "watchdog", HAS_ARG, QEMU_OPTION_watchdog }, ++ { "watchdog-action", HAS_ARG, QEMU_OPTION_watchdog_action }, + { "echr", HAS_ARG, QEMU_OPTION_echr }, + { "virtioconsole", HAS_ARG, QEMU_OPTION_virtiocon }, + { "show-cursor", 0, QEMU_OPTION_show_cursor }, +@@ -4949,6 +4960,8 @@ int main(int argc, char **argv, char **e + tb_size = 0; + autostart= 1; + ++ register_watchdogs(); ++ + optind = 1; + for(;;) { + if (optind >= argc) +@@ -5323,6 +5336,17 @@ int main(int argc, char **argv, char **e + serial_devices[serial_device_index] = optarg; + serial_device_index++; + break; ++ case QEMU_OPTION_watchdog: ++ i = select_watchdog(optarg); ++ if (i > 0) ++ exit (i == 1 ? 1 : 0); ++ break; ++ case QEMU_OPTION_watchdog_action: ++ if (select_watchdog_action(optarg) == -1) { ++ fprintf(stderr, "Unknown -watchdog-action parameter\n"); ++ exit(1); ++ } ++ break; + case QEMU_OPTION_virtiocon: + if (virtio_console_index >= MAX_VIRTIO_CONSOLES) { + fprintf(stderr, "qemu: too many virtio consoles\n"); +@@ -5838,9 +5862,9 @@ int main(int argc, char **argv, char **e + if ((msg = xenbus_read(XBT_NIL, "domid", &domid_s))) + fprintf(stderr,"Can not read our own domid: %s\n", msg); + else +- xenstore_parse_domain_config(atoi(domid_s)); ++ xenstore_parse_domain_config(atoi(domid_s), machine); + #else +- xenstore_parse_domain_config(domid); ++ xenstore_parse_domain_config(domid, machine); + #endif /* CONFIG_STUBDOM */ + } + +Index: xen-4.3.0-testing/tools/python/xen/xend/XendConstants.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendConstants.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendConstants.py +@@ -94,7 +94,7 @@ DOM_STATES_OLD = [ + SHUTDOWN_TIMEOUT = (60.0 * 5) + + """Minimum time between domain restarts in seconds.""" +-MINIMUM_RESTART_TIME = 60 ++MINIMUM_RESTART_TIME = 10 + + RESTART_IN_PROGRESS = 'xend/restart_in_progress' + DUMPCORE_IN_PROGRESS = 'xend/dumpcore_in_progress' +Index: xen-4.3.0-testing/tools/python/xen/xend/XendLogging.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendLogging.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendLogging.py +@@ -76,7 +76,7 @@ if 'TRACE' not in logging.__dict__: + log = logging.getLogger("xend") + + +-MAX_BYTES = 1 << 20 # 1MB ++MAX_BYTES = 0 + BACKUP_COUNT = 5 + + STDERR_FORMAT = "[%(name)s] %(levelname)s (%(module)s:%(lineno)d) %(message)s" +Index: xen-4.3.0-testing/tools/python/xen/xend/server/XMLRPCServer.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/server/XMLRPCServer.py ++++ xen-4.3.0-testing/tools/python/xen/xend/server/XMLRPCServer.py +@@ -95,7 +95,7 @@ methods = ['device_create', 'device_conf + 'destroyDevice','getDeviceSxprs', + 'setMemoryTarget', 'setName', 'setVCpuCount', 'shutdown', + 'send_sysrq', 'getVCPUInfo', 'waitForDevices', +- 'getRestartCount', 'getBlockDeviceClass'] ++ 'getRestartCount', 'getBlockDeviceClass', 'chgvncpasswd'] + + exclude = ['domain_create', 'domain_restore'] + +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/block_int.h +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/block_int.h ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/block_int.h +@@ -122,6 +122,9 @@ struct BlockDriverState { + BlockDriver *drv; /* NULL means no media */ + void *opaque; + ++ int boot_sector_enabled; ++ uint8_t boot_sector_data[512]; ++ + char filename[1024]; + char backing_file[1024]; /* if non zero, the image is a diff of + this file image */ +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/block.h +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/block.h ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/block.h +@@ -82,6 +82,7 @@ int64_t bdrv_getlength(BlockDriverState + void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); + void bdrv_guess_geometry(BlockDriverState *bs, int *pcyls, int *pheads, int *psecs); + int bdrv_commit(BlockDriverState *bs); ++void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size); + /* async block I/O */ + typedef struct BlockDriverAIOCB BlockDriverAIOCB; + typedef void BlockDriverCompletionFunc(void *opaque, int ret); +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.c +=================================================================== +--- /dev/null ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.c +@@ -0,0 +1,146 @@ ++/* ++ * Virtual hardware watchdog. ++ * ++ * Copyright (C) 2009 Red Hat 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 (at your option) 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. ++ * ++ * By Richard W.M. Jones (rjones@redhat.com). ++ */ ++ ++#include "qemu-common.h" ++#include "sys-queue.h" ++#include "sysemu.h" ++#include "hw/watchdog.h" ++ ++/* Possible values for action parameter. */ ++#define WDT_RESET 1 /* Hard reset. */ ++#define WDT_SHUTDOWN 2 /* Shutdown. */ ++#define WDT_POWEROFF 3 /* Quit. */ ++#define WDT_PAUSE 4 /* Pause. */ ++#define WDT_DEBUG 5 /* Prints a message and continues running. */ ++#define WDT_NONE 6 /* Do nothing. */ ++ ++static WatchdogTimerModel *watchdog; ++static int watchdog_action = WDT_RESET; ++static LIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list; ++ ++void watchdog_add_model(WatchdogTimerModel *model) ++{ ++ LIST_INSERT_HEAD(&watchdog_list, model, entry); ++} ++ ++/* Returns: ++ * 0 = continue ++ * 1 = exit program with error ++ * 2 = exit program without error ++ */ ++int select_watchdog(const char *p) ++{ ++ WatchdogTimerModel *model; ++ ++ if (watchdog) { ++ fprintf(stderr, ++ "qemu: only one watchdog option may be given\n"); ++ return 1; ++ } ++ ++ /* -watchdog ? lists available devices and exits cleanly. */ ++ if (strcmp(p, "?") == 0) { ++ LIST_FOREACH(model, &watchdog_list, entry) { ++ fprintf(stderr, "\t%s\t%s\n", ++ model->wdt_name, model->wdt_description); ++ } ++ return 2; ++ } ++ ++ LIST_FOREACH(model, &watchdog_list, entry) { ++ if (strcasecmp(model->wdt_name, p) == 0) { ++ watchdog = model; ++ return 0; ++ } ++ } ++ ++ fprintf(stderr, "Unknown -watchdog device. Supported devices are:\n"); ++ LIST_FOREACH(model, &watchdog_list, entry) { ++ fprintf(stderr, "\t%s\t%s\n", ++ model->wdt_name, model->wdt_description); ++ } ++ return 1; ++} ++ ++int select_watchdog_action(const char *p) ++{ ++ if (strcasecmp(p, "reset") == 0) ++ watchdog_action = WDT_RESET; ++ else if (strcasecmp(p, "shutdown") == 0) ++ watchdog_action = WDT_SHUTDOWN; ++ else if (strcasecmp(p, "poweroff") == 0) ++ watchdog_action = WDT_POWEROFF; ++ else if (strcasecmp(p, "pause") == 0) ++ watchdog_action = WDT_PAUSE; ++ else if (strcasecmp(p, "debug") == 0) ++ watchdog_action = WDT_DEBUG; ++ else if (strcasecmp(p, "none") == 0) ++ watchdog_action = WDT_NONE; ++ else ++ return -1; ++ ++ return 0; ++} ++ ++/* This actually performs the "action" once a watchdog has expired, ++ * ie. reboot, shutdown, exit, etc. ++ */ ++void watchdog_perform_action(void) ++{ ++ switch(watchdog_action) { ++ case WDT_RESET: /* same as 'system_reset' in monitor */ ++ qemu_system_reset_request(); ++ break; ++ ++ case WDT_SHUTDOWN: /* same as 'system_powerdown' in monitor */ ++ qemu_system_powerdown_request(); ++ break; ++ ++ case WDT_POWEROFF: /* same as 'quit' command in monitor */ ++ exit(0); ++ break; ++ ++ case WDT_PAUSE: /* same as 'stop' command in monitor */ ++ vm_stop(0); ++ break; ++ ++ case WDT_DEBUG: ++ fprintf(stderr, "watchdog: timer fired\n"); ++ break; ++ ++ case WDT_NONE: ++ break; ++ } ++} ++ ++void watchdog_pc_init(PCIBus *pci_bus) ++{ ++ if (watchdog) ++ watchdog->wdt_pc_init(pci_bus); ++} ++ ++void register_watchdogs(void) ++{ ++ wdt_ib700_init(); ++ wdt_i6300esb_init(); ++} +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.h +=================================================================== +--- /dev/null ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/watchdog.h +@@ -0,0 +1,54 @@ ++/* ++ * Virtual hardware watchdog. ++ * ++ * Copyright (C) 2009 Red Hat 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 (at your option) 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. ++ * ++ * By Richard W.M. Jones (rjones@redhat.com). ++ */ ++ ++#ifndef QEMU_WATCHDOG_H ++#define QEMU_WATCHDOG_H ++ ++extern void wdt_i6300esb_init(void); ++extern void wdt_ib700_init(void); ++ ++ ++struct WatchdogTimerModel { ++ LIST_ENTRY(WatchdogTimerModel) entry; ++ ++ /* Short name of the device - used to select it on the command line. */ ++ const char *wdt_name; ++ /* Longer description (eg. manufacturer and full model number). */ ++ const char *wdt_description; ++ ++ /* This callback should create/register the device. It is called ++ * indirectly from hw/pc.c when the virtual PC is being set up. ++ */ ++ void (*wdt_pc_init)(PCIBus *pci_bus); ++}; ++typedef struct WatchdogTimerModel WatchdogTimerModel; ++ ++/* in hw/watchdog.c */ ++extern int select_watchdog(const char *p); ++extern int select_watchdog_action(const char *action); ++extern void watchdog_add_model(WatchdogTimerModel *model); ++extern void watchdog_perform_action(void); ++extern void watchdog_pc_init(PCIBus *pci_bus); ++extern void register_watchdogs(void); ++ ++#endif /* QEMU_WATCHDOG_H */ +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/wdt_i6300esb.c +=================================================================== +--- /dev/null ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/wdt_i6300esb.c +@@ -0,0 +1,470 @@ ++/* ++ * Virtual hardware watchdog. ++ * ++ * Copyright (C) 2009 Red Hat 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 (at your option) 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. ++ * ++ * By Richard W.M. Jones (rjones@redhat.com). ++ */ ++ ++#include ++ ++#include "qemu-common.h" ++#include "qemu-timer.h" ++#include "watchdog.h" ++#include "hw.h" ++#include "isa.h" ++#include "pc.h" ++#include "pci.h" ++ ++/*#define I6300ESB_DEBUG 1*/ ++ ++#ifdef I6300ESB_DEBUG ++#define i6300esb_debug(fs,...) \ ++ fprintf(stderr,"i6300esb: %s: "fs,__func__,##__VA_ARGS__) ++#else ++#define i6300esb_debug(fs,...) ++#endif ++ ++#ifndef PCI_DEVICE_ID_INTEL_ESB_9 ++#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab ++#endif ++ ++/* PCI configuration registers */ ++#define ESB_CONFIG_REG 0x60 /* Config register */ ++#define ESB_LOCK_REG 0x68 /* WDT lock register */ ++ ++/* Memory mapped registers (offset from base address) */ ++#define ESB_TIMER1_REG 0x00 /* Timer1 value after each reset */ ++#define ESB_TIMER2_REG 0x04 /* Timer2 value after each reset */ ++#define ESB_GINTSR_REG 0x08 /* General Interrupt Status Register */ ++#define ESB_RELOAD_REG 0x0c /* Reload register */ ++ ++/* Lock register bits */ ++#define ESB_WDT_FUNC (0x01 << 2) /* Watchdog functionality */ ++#define ESB_WDT_ENABLE (0x01 << 1) /* Enable WDT */ ++#define ESB_WDT_LOCK (0x01 << 0) /* Lock (nowayout) */ ++ ++/* Config register bits */ ++#define ESB_WDT_REBOOT (0x01 << 5) /* Enable reboot on timeout */ ++#define ESB_WDT_FREQ (0x01 << 2) /* Decrement frequency */ ++#define ESB_WDT_INTTYPE (0x11 << 0) /* Interrupt type on timer1 timeout */ ++ ++/* Reload register bits */ ++#define ESB_WDT_RELOAD (0x01 << 8) /* prevent timeout */ ++ ++/* Magic constants */ ++#define ESB_UNLOCK1 0x80 /* Step 1 to unlock reset registers */ ++#define ESB_UNLOCK2 0x86 /* Step 2 to unlock reset registers */ ++ ++/* Device state. */ ++struct I6300State { ++ PCIDevice dev; /* PCI device state, must be first field. */ ++ ++ int reboot_enabled; /* "Reboot" on timer expiry. The real action ++ * performed depends on the -watchdog-action ++ * param passed on QEMU command line. ++ */ ++ int clock_scale; /* Clock scale. */ ++#define CLOCK_SCALE_1KHZ 0 ++#define CLOCK_SCALE_1MHZ 1 ++ ++ int int_type; /* Interrupt type generated. */ ++#define INT_TYPE_IRQ 0 /* APIC 1, INT 10 */ ++#define INT_TYPE_SMI 2 ++#define INT_TYPE_DISABLED 3 ++ ++ int free_run; /* If true, reload timer on expiry. */ ++ int locked; /* If true, enabled field cannot be changed. */ ++ int enabled; /* If true, watchdog is enabled. */ ++ ++ QEMUTimer *timer; /* The actual watchdog timer. */ ++ ++ uint32_t timer1_preload; /* Values preloaded into timer1, timer2. */ ++ uint32_t timer2_preload; ++ int stage; /* Stage (1 or 2). */ ++ ++ int unlock_state; /* Guest writes 0x80, 0x86 to unlock the ++ * registers, and we transition through ++ * states 0 -> 1 -> 2 when this happens. ++ */ ++ ++ int previous_reboot_flag; /* If the watchdog caused the previous ++ * reboot, this flag will be set. ++ */ ++}; ++ ++typedef struct I6300State I6300State; ++ ++/* This function is called when the watchdog has either been enabled ++ * (hence it starts counting down) or has been keep-alived. ++ */ ++static void i6300esb_restart_timer(I6300State *d, int stage) ++{ ++ int64_t timeout; ++ ++ if (!d->enabled) ++ return; ++ ++ d->stage = stage; ++ ++ if (d->stage <= 1) ++ timeout = d->timer1_preload; ++ else ++ timeout = d->timer2_preload; ++ ++ if (d->clock_scale == CLOCK_SCALE_1KHZ) ++ timeout <<= 15; ++ else ++ timeout <<= 5; ++ ++ /* Get the timeout in units of ticks_per_sec. */ ++ timeout = ticks_per_sec * timeout / 33000000; ++ ++ i6300esb_debug("stage %d, timeout %" PRIi64 "\n", d->stage, timeout); ++ ++ qemu_mod_timer(d->timer, qemu_get_clock(vm_clock) + timeout); ++} ++ ++/* This is called when the guest disables the watchdog. */ ++static void i6300esb_disable_timer(I6300State *d) ++{ ++ i6300esb_debug("timer disabled\n"); ++ ++ qemu_del_timer(d->timer); ++} ++ ++static void i6300esb_reset(I6300State *d) ++{ ++ /* XXX We should probably reset other parts of the state here, ++ * but we should also reset our state on general machine reset ++ * too. For now just disable the timer so it doesn't fire ++ * again after the reboot. ++ */ ++ i6300esb_disable_timer(d); ++} ++ ++/* This function is called when the watchdog expires. Note that ++ * the hardware has two timers, and so expiry happens in two stages. ++ * If d->stage == 1 then we perform the first stage action (usually, ++ * sending an interrupt) and then restart the timer again for the ++ * second stage. If the second stage expires then the watchdog ++ * really has run out. ++ */ ++static void i6300esb_timer_expired(void *vp) ++{ ++ I6300State *d = (I6300State *) vp; ++ ++ i6300esb_debug("stage %d\n", d->stage); ++ ++ if (d->stage == 1) { ++ /* What to do at the end of stage 1? */ ++ switch (d->int_type) { ++ case INT_TYPE_IRQ: ++ fprintf(stderr, "i6300esb_timer_expired: I would send APIC 1 INT 10 here if I knew how (XXX)\n"); ++ break; ++ case INT_TYPE_SMI: ++ fprintf(stderr, "i6300esb_timer_expired: I would send SMI here if I knew how (XXX)\n"); ++ break; ++ } ++ ++ /* Start the second stage. */ ++ i6300esb_restart_timer(d, 2); ++ } else { ++ /* Second stage expired, reboot for real. */ ++ if (d->reboot_enabled) { ++ d->previous_reboot_flag = 1; ++ watchdog_perform_action(); /* This reboots, exits, etc */ ++ i6300esb_reset(d); ++ } ++ ++ /* In "free running mode" we start stage 1 again. */ ++ if (d->free_run) ++ i6300esb_restart_timer(d, 1); ++ } ++} ++ ++static void i6300esb_config_write(PCIDevice *dev, uint32_t addr, ++ uint32_t data, int len) ++{ ++ I6300State *d = (I6300State *) dev; ++ int old; ++ ++ i6300esb_debug("addr = %x, data = %x, len = %d\n", addr, data, len); ++ ++ if (addr == ESB_CONFIG_REG && len == 2) { ++ d->reboot_enabled = (data & ESB_WDT_REBOOT) == 0; ++ d->clock_scale = ++ (data & ESB_WDT_FREQ) != 0 ? CLOCK_SCALE_1MHZ : CLOCK_SCALE_1KHZ; ++ d->int_type = (data & ESB_WDT_INTTYPE); ++ } else if (addr == ESB_LOCK_REG && len == 1) { ++ if (!d->locked) { ++ d->locked = (data & ESB_WDT_LOCK) != 0; ++ d->free_run = (data & ESB_WDT_FUNC) != 0; ++ old = d->enabled; ++ d->enabled = (data & ESB_WDT_ENABLE) != 0; ++ if (!old && d->enabled) /* Enabled transitioned from 0 -> 1 */ ++ i6300esb_restart_timer(d, 1); ++ else if (!d->enabled) ++ i6300esb_disable_timer(d); ++ } ++ } else { ++ pci_default_write_config(dev, addr, data, len); ++ } ++} ++ ++static uint32_t i6300esb_config_read(PCIDevice *dev, uint32_t addr, int len) ++{ ++ I6300State *d = (I6300State *) dev; ++ uint32_t data; ++ ++ i6300esb_debug ("addr = %x, len = %d\n", addr, len); ++ ++ if (addr == ESB_CONFIG_REG && len == 2) { ++ data = ++ (d->reboot_enabled ? 0 : ESB_WDT_REBOOT) | ++ (d->clock_scale == CLOCK_SCALE_1MHZ ? ESB_WDT_FREQ : 0) | ++ d->int_type; ++ return data; ++ } else if (addr == ESB_LOCK_REG && len == 1) { ++ data = ++ (d->free_run ? ESB_WDT_FUNC : 0) | ++ (d->locked ? ESB_WDT_LOCK : 0) | ++ (d->enabled ? ESB_WDT_ENABLE : 0); ++ return data; ++ } else { ++ return pci_default_read_config(dev, addr, len); ++ } ++} ++ ++static uint32_t i6300esb_mem_readb(void *vp, target_phys_addr_t addr) ++{ ++ i6300esb_debug ("addr = %x\n", (int) addr); ++ ++ return 0; ++} ++ ++static uint32_t i6300esb_mem_readw(void *vp, target_phys_addr_t addr) ++{ ++ uint32_t data = 0; ++ I6300State *d = (I6300State *) vp; ++ ++ i6300esb_debug("addr = %x\n", (int) addr); ++ ++ if (addr == 0xc) { ++ /* The previous reboot flag is really bit 9, but there is ++ * a bug in the Linux driver where it thinks it's bit 12. ++ * Set both. ++ */ ++ data = d->previous_reboot_flag ? 0x1200 : 0; ++ } ++ ++ return data; ++} ++ ++static uint32_t i6300esb_mem_readl(void *vp, target_phys_addr_t addr) ++{ ++ i6300esb_debug("addr = %x\n", (int) addr); ++ ++ return 0; ++} ++ ++static void i6300esb_mem_writeb(void *vp, target_phys_addr_t addr, uint32_t val) ++{ ++ I6300State *d = (I6300State *) vp; ++ ++ i6300esb_debug("addr = %x, val = %x\n", (int) addr, val); ++ ++ if (addr == 0xc && val == 0x80) ++ d->unlock_state = 1; ++ else if (addr == 0xc && val == 0x86 && d->unlock_state == 1) ++ d->unlock_state = 2; ++} ++ ++static void i6300esb_mem_writew(void *vp, target_phys_addr_t addr, uint32_t val) ++{ ++ I6300State *d = (I6300State *) vp; ++ ++ i6300esb_debug("addr = %x, val = %x\n", (int) addr, val); ++ ++ if (addr == 0xc && val == 0x80) ++ d->unlock_state = 1; ++ else if (addr == 0xc && val == 0x86 && d->unlock_state == 1) ++ d->unlock_state = 2; ++ else { ++ if (d->unlock_state == 2) { ++ if (addr == 0xc) { ++ if ((val & 0x100) != 0) ++ /* This is the "ping" from the userspace watchdog in ++ * the guest ... ++ */ ++ i6300esb_restart_timer(d, 1); ++ ++ /* Setting bit 9 resets the previous reboot flag. ++ * There's a bug in the Linux driver where it sets ++ * bit 12 instead. ++ */ ++ if ((val & 0x200) != 0 || (val & 0x1000) != 0) { ++ d->previous_reboot_flag = 0; ++ } ++ } ++ ++ d->unlock_state = 0; ++ } ++ } ++} ++ ++static void i6300esb_mem_writel(void *vp, target_phys_addr_t addr, uint32_t val) ++{ ++ I6300State *d = (I6300State *) vp; ++ ++ i6300esb_debug ("addr = %x, val = %x\n", (int) addr, val); ++ ++ if (addr == 0xc && val == 0x80) ++ d->unlock_state = 1; ++ else if (addr == 0xc && val == 0x86 && d->unlock_state == 1) ++ d->unlock_state = 2; ++ else { ++ if (d->unlock_state == 2) { ++ if (addr == 0) ++ d->timer1_preload = val & 0xfffff; ++ else if (addr == 4) ++ d->timer2_preload = val & 0xfffff; ++ ++ d->unlock_state = 0; ++ } ++ } ++} ++ ++static void i6300esb_map(PCIDevice *dev, int region_num, ++ uint32_t addr, uint32_t size, int type) ++{ ++ static CPUReadMemoryFunc *mem_read[3] = { ++ i6300esb_mem_readb, ++ i6300esb_mem_readw, ++ i6300esb_mem_readl, ++ }; ++ static CPUWriteMemoryFunc *mem_write[3] = { ++ i6300esb_mem_writeb, ++ i6300esb_mem_writew, ++ i6300esb_mem_writel, ++ }; ++ I6300State *d = (I6300State *) dev; ++ int io_mem; ++ ++ i6300esb_debug("addr = %x, size = %x, type = %d\n", addr, size, type); ++ ++ io_mem = cpu_register_io_memory (0, mem_read, mem_write, d); ++ cpu_register_physical_memory (addr, 0x10, io_mem); ++ /* qemu_register_coalesced_mmio (addr, 0x10); ? */ ++} ++ ++static void i6300esb_save(QEMUFile *f, void *vp) ++{ ++ I6300State *d = (I6300State *) vp; ++ ++ pci_device_save(&d->dev, f); ++ qemu_put_be32(f, d->reboot_enabled); ++ qemu_put_be32(f, d->clock_scale); ++ qemu_put_be32(f, d->int_type); ++ qemu_put_be32(f, d->free_run); ++ qemu_put_be32(f, d->locked); ++ qemu_put_be32(f, d->enabled); ++ qemu_put_timer(f, d->timer); ++ qemu_put_be32(f, d->timer1_preload); ++ qemu_put_be32(f, d->timer2_preload); ++ qemu_put_be32(f, d->stage); ++ qemu_put_be32(f, d->unlock_state); ++ qemu_put_be32(f, d->previous_reboot_flag); ++} ++ ++static int i6300esb_load(QEMUFile *f, void *vp, int version) ++{ ++ I6300State *d = (I6300State *) vp; ++ ++ if (version != sizeof (I6300State)) ++ return -EINVAL; ++ ++ pci_device_load(&d->dev, f); ++ d->reboot_enabled = qemu_get_be32(f); ++ d->clock_scale = qemu_get_be32(f); ++ d->int_type = qemu_get_be32(f); ++ d->free_run = qemu_get_be32(f); ++ d->locked = qemu_get_be32(f); ++ d->enabled = qemu_get_be32(f); ++ qemu_get_timer(f, d->timer); ++ d->timer1_preload = qemu_get_be32(f); ++ d->timer2_preload = qemu_get_be32(f); ++ d->stage = qemu_get_be32(f); ++ d->unlock_state = qemu_get_be32(f); ++ d->previous_reboot_flag = qemu_get_be32(f); ++ ++ return 0; ++} ++ ++/* Create and initialize a virtual Intel 6300ESB during PC creation. */ ++static void i6300esb_pc_init(PCIBus *pci_bus) ++{ ++ I6300State *d; ++ uint8_t *pci_conf; ++ ++ if (!pci_bus) { ++ fprintf(stderr, "wdt_i6300esb: no PCI bus in this machine\n"); ++ return; ++ } ++ ++ d = (I6300State *) ++ pci_register_device (pci_bus, "i6300esb_wdt", sizeof (I6300State), ++ -1, ++ i6300esb_config_read, i6300esb_config_write); ++ ++ d->reboot_enabled = 1; ++ d->clock_scale = CLOCK_SCALE_1KHZ; ++ d->int_type = INT_TYPE_IRQ; ++ d->free_run = 0; ++ d->locked = 0; ++ d->enabled = 0; ++ d->timer = qemu_new_timer(vm_clock, i6300esb_timer_expired, d); ++ d->timer1_preload = 0xfffff; ++ d->timer2_preload = 0xfffff; ++ d->stage = 1; ++ d->unlock_state = 0; ++ d->previous_reboot_flag = 0; ++ ++ pci_conf = d->dev.config; ++ pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); ++ pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_ESB_9); ++ pci_config_set_class(pci_conf, PCI_CLASS_SYSTEM_OTHER); ++ pci_conf[0x0e] = 0x00; ++ ++ pci_register_io_region(&d->dev, 0, 0x10, ++ PCI_ADDRESS_SPACE_MEM, i6300esb_map); ++ ++ register_savevm("i6300esb_wdt", -1, sizeof(I6300State), ++ i6300esb_save, i6300esb_load, d); ++} ++ ++static WatchdogTimerModel model = { ++ .wdt_name = "i6300esb", ++ .wdt_description = "Intel 6300ESB", ++ .wdt_pc_init = i6300esb_pc_init, ++}; ++ ++void wdt_i6300esb_init(void) ++{ ++ watchdog_add_model(&model); ++} +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/wdt_ib700.c +=================================================================== +--- /dev/null ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/wdt_ib700.c +@@ -0,0 +1,112 @@ ++/* ++ * Virtual hardware watchdog. ++ * ++ * Copyright (C) 2009 Red Hat 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 (at your option) 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. ++ * ++ * By Richard W.M. Jones (rjones@redhat.com). ++ */ ++ ++#include "qemu-common.h" ++#include "qemu-timer.h" ++#include "watchdog.h" ++#include "hw.h" ++#include "isa.h" ++#include "pc.h" ++ ++/*#define IB700_DEBUG 1*/ ++ ++#ifdef IB700_DEBUG ++#define ib700_debug(fs,...) \ ++ fprintf(stderr,"ib700: %s: "fs,__func__,##__VA_ARGS__) ++#else ++#define ib700_debug(fs,...) ++#endif ++ ++/* This is the timer. We use a global here because the watchdog ++ * code ensures there is only one watchdog (it is located at a fixed, ++ * unchangable IO port, so there could only ever be one anyway). ++ */ ++static QEMUTimer *timer = NULL; ++ ++/* A write to this register enables the timer. */ ++static void ib700_write_enable_reg(void *vp, uint32_t addr, uint32_t data) ++{ ++ static int time_map[] = { ++ 30, 28, 26, 24, 22, 20, 18, 16, ++ 14, 12, 10, 8, 6, 4, 2, 0 ++ }; ++ int64 timeout; ++ ++ ib700_debug("addr = %x, data = %x\n", addr, data); ++ ++ timeout = (int64_t) time_map[data & 0xF] * ticks_per_sec; ++ qemu_mod_timer(timer, qemu_get_clock (vm_clock) + timeout); ++} ++ ++/* A write (of any value) to this register disables the timer. */ ++static void ib700_write_disable_reg(void *vp, uint32_t addr, uint32_t data) ++{ ++ ib700_debug("addr = %x, data = %x\n", addr, data); ++ ++ qemu_del_timer(timer); ++} ++ ++/* This is called when the watchdog expires. */ ++static void ib700_timer_expired(void *vp) ++{ ++ ib700_debug("watchdog expired\n"); ++ ++ watchdog_perform_action(); ++ qemu_del_timer(timer); ++} ++ ++static void ib700_save(QEMUFile *f, void *vp) ++{ ++ qemu_put_timer(f, timer); ++} ++ ++static int ib700_load(QEMUFile *f, void *vp, int version) ++{ ++ if (version != 0) ++ return -EINVAL; ++ ++ qemu_get_timer(f, timer); ++ ++ return 0; ++} ++ ++/* Create and initialize a virtual IB700 during PC creation. */ ++static void ib700_pc_init(PCIBus *unused) ++{ ++ timer = qemu_new_timer(vm_clock, ib700_timer_expired, NULL); ++ register_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, NULL); ++ ++ register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, NULL); ++ register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, NULL); ++} ++ ++static WatchdogTimerModel model = { ++ .wdt_name = "ib700", ++ .wdt_description = "iBASE 700", ++ .wdt_pc_init = ib700_pc_init, ++}; ++ ++void wdt_ib700_init(void) ++{ ++ watchdog_add_model(&model); ++} +Index: xen-4.3.0-testing/tools/libxl/libxl_dm.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/libxl/libxl_dm.c ++++ xen-4.3.0-testing/tools/libxl/libxl_dm.c +@@ -222,6 +222,12 @@ static char ** libxl__build_device_model + } + } + } ++ if (b_info->u.hvm.watchdog || b_info->u.hvm.watchdog_action) { ++ flexarray_append(dm_args, "-watchdog"); ++ if (b_info->u.hvm.watchdog_action) { ++ flexarray_vappend(dm_args, "-watchdog-action", b_info->u.hvm.watchdog_action, NULL); ++ } ++ } + if (b_info->u.hvm.soundhw) { + flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL); + } +@@ -520,6 +526,12 @@ static char ** libxl__build_device_model + } + } + } ++ if (b_info->u.hvm.watchdog || b_info->u.hvm.watchdog_action) { ++ flexarray_append(dm_args, "-watchdog"); ++ if (b_info->u.hvm.watchdog_action) { ++ flexarray_vappend(dm_args, "-watchdog-action", b_info->u.hvm.watchdog_action, NULL); ++ } ++ } + if (b_info->u.hvm.soundhw) { + flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL); + } +Index: xen-4.3.0-testing/tools/libxl/libxl_types.idl +=================================================================== +--- xen-4.3.0-testing.orig/tools/libxl/libxl_types.idl ++++ xen-4.3.0-testing/tools/libxl/libxl_types.idl +@@ -333,6 +333,8 @@ libxl_domain_build_info = Struct("domain + ("soundhw", string), + ("xen_platform_pci", libxl_defbool), + ("usbdevice_list", libxl_string_list), ++ ("watchdog", string), ++ ("watchdog_action", string), + ])), + ("pv", Struct(None, [("kernel", string), + ("slack_memkb", MemKB), +Index: xen-4.3.0-testing/tools/libxl/xl_cmdimpl.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/libxl/xl_cmdimpl.c ++++ xen-4.3.0-testing/tools/libxl/xl_cmdimpl.c +@@ -1518,6 +1518,8 @@ skip_vfb: + xlu_cfg_replace_string (config, "soundhw", &b_info->u.hvm.soundhw, 0); + xlu_cfg_get_defbool(config, "xen_platform_pci", + &b_info->u.hvm.xen_platform_pci, 0); ++ xlu_cfg_replace_string (config, "watchdog", &b_info->u.hvm.watchdog, 0); ++ xlu_cfg_replace_string (config, "watchdog_action", &b_info->u.hvm.watchdog_action, 0); + + if(b_info->u.hvm.vnc.listen + && b_info->u.hvm.vnc.display +Index: xen-4.3.0-testing/tools/python/xen/xm/cpupool.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xm/cpupool.py ++++ xen-4.3.0-testing/tools/python/xen/xm/cpupool.py +@@ -157,9 +157,17 @@ def make_cpus_config(cfg_cpus): + # ["0,2","1,3"] -> [[0,2],[1,3]] + # ["0-3,^1","1-4,^2"] -> [[0,2,3],[1,3,4]] + try: +- for c in cfg_cpus: +- cpus = cnv(c) +- cpus_list.append(cpus) ++ cpus_str = "" ++ list_len = len(cfg_cpus) ++ n = 0 ++ while n < list_len: ++ if type(cfg_cpus[n]) != str: ++ raise SyntaxError('cpus = %s' % cfg_cpus) ++ cpus_str += cfg_cpus[n] ++ n += 1 ++ if n < list_len: ++ cpus_str += ', ' ++ cpus_list = cnv(cpus_str) + except ValueError, e: + raise err('cpus = %s: %s' % (cfg_cpus, e)) + else: +Index: xen-4.3.0-testing/tools/python/xen/xend/server/netif.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/server/netif.py ++++ xen-4.3.0-testing/tools/python/xen/xend/server/netif.py +@@ -23,6 +23,7 @@ + import os + import random + import re ++import commands + + from xen.xend import XendOptions, sxp + from xen.xend.server.DevController import DevController +@@ -101,6 +102,14 @@ class NetifController(DevController): + def __init__(self, vm): + DevController.__init__(self, vm) + ++ def createDevice(self, config): ++ bridge = config.get('bridge') ++ if bridge is not None: ++ bridge_result = commands.getstatusoutput("/sbin/ifconfig %s" % bridge) ++ if bridge_result[0] != 0: ++ raise VmError('Network bridge does not exist: %s' % bridge) ++ DevController.createDevice(self, config) ++ + def getDeviceDetails(self, config): + """@see DevController.getDeviceDetails""" + +Index: xen-4.3.0-testing/tools/python/xen/util/pci.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/util/pci.py ++++ xen-4.3.0-testing/tools/python/xen/util/pci.py +@@ -20,6 +20,8 @@ from xen.xend import sxp + from xen.xend.XendConstants import AUTO_PHP_SLOT + from xen.xend.XendSXPDev import dev_dict_to_sxp + from xen.xend.XendLogging import log ++from xen.xend.xenstore.xstransact import xstransact ++from xen.xend.XendError import XendError + + # for 2.3 compatibility + try: +@@ -27,9 +29,11 @@ try: + except NameError: + from sets import Set as set + ++XS_PCIBACK_PATH = '/xm/pciback' + PROC_PCI_PATH = '/proc/bus/pci/devices' + PROC_PCI_NUM_RESOURCES = 7 + ++SYSFS_PCI_DRVS_PATH = 'bus/pci/drivers' + SYSFS_PCI_DEVS_PATH = '/bus/pci/devices' + SYSFS_PCI_DEV_RESOURCE_PATH = '/resource' + SYSFS_PCI_DEV_CONFIG_PATH = '/config' +@@ -161,7 +165,7 @@ def PCI_BDF(domain, bus, slot, func): + + def check_pci_opts(opts): + def f((k, v)): +- if k not in ['msitranslate', 'power_mgmt'] or \ ++ if k not in ['msitranslate', 'power_mgmt', 'managed'] or \ + not v.lower() in ['0', '1', 'yes', 'no']: + raise PciDeviceParseError('Invalid pci option %s=%s: ' % (k, v)) + +@@ -427,6 +431,9 @@ def __pci_dict_to_fmt_str(fmt, dev): + def pci_dict_to_bdf_str(dev): + return __pci_dict_to_fmt_str('%04x:%02x:%02x.%01x', dev) + ++def pci_dict_to_xs_bdf_str(dev): ++ return __pci_dict_to_fmt_str('%04x-%02x-%02x-%01x', dev) ++ + def pci_dict_to_xc_str(dev): + return __pci_dict_to_fmt_str('0x%x, 0x%x, 0x%x, 0x%x', dev) + +@@ -560,6 +567,115 @@ def find_all_assignable_devices(): + dev_list = dev_list + [dev] + return dev_list + ++def pci_assignable_add(dev): ++ '''detach pci device from driver that we need to unbind from and rebind ++ to pciback driver, then it can be assigned to guest. ++ ''' ++ sysfs_mnt = find_sysfs_mnt() ++ pcidev_path = sysfs_mnt + SYSFS_PCI_DEVS_PATH ++ pciback_path = sysfs_mnt + SYSFS_PCIBACK_PATH ++ ++ # See if the device exists ++ pci_bdf = pci_dict_to_bdf_str(dev) ++ path = pcidev_path + '/' + pci_bdf ++ if not os.path.exists(path): ++ log.debug("Pci device %s doesn't exist" % pci_bdf) ++ return -1 ++ ++ # Check to see if it's already assigned to pciback ++ path = pciback_path + '/' + pci_bdf ++ if os.path.exists(path): ++ log.debug("Pci device %s is already assigned to pciback" % pci_bdf) ++ return 0 ++ ++ # Check to see if there's already a driver that we need to unbind from ++ path = pcidev_path + '/' + pci_bdf + '/driver' ++ drv_path = None ++ if os.path.exists(path): ++ drv_path = os.path.realpath(path).replace(" ", "\ ") ++ cmd = 'echo %s > %s/unbind' % (pci_bdf, drv_path) ++ if os.system(cmd): ++ log.debug("Couldn't unbind device") ++ return -1; ++ ++ # Store driver_path for rebinding to dom0 ++ if drv_path is not None: ++ xs_pci_bdf = pci_dict_to_xs_bdf_str(dev) ++ path = XS_PCIBACK_PATH + '/' + xs_pci_bdf ++ xstransact.Mkdir(path) ++ xstransact.Write(path, 'driver_path', drv_path) ++ else: ++ log.debug("Not bound to a driver, will not be rebound") ++ ++ # Bind to pciback ++ try: ++ # Scan through /sys/.../pciback/slots looking for pcidev's BDF ++ slots = os.popen('cat %s/slots' % pciback_path).read() ++ if re.search(pci_bdf, slots) is None: ++ # write bdf to new_slot ++ cmd = 'echo %s > %s/new_slot' % (pci_bdf, pciback_path) ++ if os.system(cmd): ++ raise XendError("Couldn't add device to pciback new_slot") ++ ++ # Bind to pciback ++ cmd = 'echo %s > %s/bind' % (pci_bdf, pciback_path) ++ if os.system(cmd): ++ raise XendError("Couldn't bind device to pciback") ++ except XendError: ++ # rebind to original driver ++ if drv_path is not None: ++ log.debug("Rebind to original driver") ++ cmd = 'echo %s > %s/bind' % (pci_bdf, drv_path) ++ if os.system(cmd): ++ log.debug("Failed to rebind") ++ return -1 ++ ++ return 0 ++ ++def pci_assignable_remove(dev): ++ '''unbind pci device from pciback, and rebind to host pci driver where it ++ was detached from in pci-assignable-add. ++ ''' ++ sysfs_mnt = find_sysfs_mnt() ++ pcidrv_path = sysfs_mnt + SYSFS_PCI_DRVS_PATH ++ pciback_path = sysfs_mnt + SYSFS_PCIBACK_PATH ++ pci_bdf = pci_dict_to_bdf_str(dev) ++ ++ # Unbind from pciback ++ path = pciback_path + '/' + pci_bdf ++ if os.path.exists(path): ++ # unbind ++ cmd = 'echo %s > %s/unbind' % (pci_bdf, pciback_path) ++ if os.system(cmd): ++ log.debug("Couldn't unbind device to pciback") ++ return -1 ++ ++ # remove slots if necessary ++ slots = os.popen('cat %s/slots' % pciback_path).read() ++ if re.search(pci_bdf, slots): ++ # write bdf to remove_slot ++ cmd = 'echo %s > %s/remove_slot' % (pci_bdf, pciback_path) ++ if os.system(cmd): ++ log.debug("Couldn't remove pciback slot") ++ return -1 ++ else: ++ log.debug("Not bound to pciback") ++ ++ # Rebind if necessary ++ xs_pci_bdf = pci_dict_to_xs_bdf_str(dev) ++ path = XS_PCIBACK_PATH + '/' + xs_pci_bdf ++ drv_path = xstransact.Read(path, 'driver_path') ++ if drv_path: ++ cmd = 'echo %s > %s/bind' % (pci_bdf, drv_path) ++ if os.system(cmd): ++ log.debug("Couldn't rebind to driver %s" % drv_path) ++ return -1 ++ xstransact.Remove(path) ++ else: ++ log.debug("Counldn't find path for original driver. Not rebinding") ++ ++ return 0 ++ + def transform_list(target, src): + ''' src: its element is pci string (Format: xxxx:xx:xx.x). + target: its element is pci string, or a list of pci string. +Index: xen-4.3.0-testing/tools/python/xen/xend/server/pciif.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/server/pciif.py ++++ xen-4.3.0-testing/tools/python/xen/xend/server/pciif.py +@@ -86,6 +86,48 @@ def get_all_assigned_pci_devices(domid = + pci_str_list = pci_str_list + get_assigned_pci_devices(int(d)) + return pci_str_list + ++def reattach_host_pci_devices(devconfig): ++ pci_dev_list = devconfig.get('devs', []) ++ for pci_dev in pci_dev_list: ++ managed = 0 ++ pci_opts_config = pci_dev.get('opts', []) ++ for opt in pci_opts_config: ++ if opt[0] == 'managed': ++ managed = opt[1] ++ if managed: ++ if pci_assignable_remove(pci_dev) != 0: ++ raise VmError('pci_assignable_remove failed') ++ ++def detach_host_pci_devices(devconfig): ++ pci_dev_list = devconfig.get('devs', []) ++ reattach = 0 ++ for pci_dev in pci_dev_list: ++ managed = 0 ++ pci_opts_config = pci_dev.get('opts', []) ++ for opt in pci_opts_config: ++ if opt[0] == 'managed': ++ managed = opt[1] ++ if managed: ++ if pci_assignable_add(pci_dev) != 0: ++ log.debug('pci_assignable_add failed') ++ reattach = 1 ++ break ++ ++ if reattach: ++ reattach_host_pci_devices(devconfig) ++ raise VmError('detach_host_pci_devices failed') ++ ++def prepare_host_pci_devices(devconfig): ++ # Test whether the device used by other domain ++ pci_dev_list = devconfig.get('devs', []) ++ for pci_dev in pci_dev_list: ++ pci_name = pci_dict_to_bdf_str(pci_dev) ++ if pci_name in get_all_assigned_pci_devices(): ++ raise VmError("failed to assign device %s that has" ++ " already been assigned to other domain." % pci_name) ++ # Detach 'managed' devices ++ detach_host_pci_devices(devconfig) ++ + class PciController(DevController): + + def __init__(self, vm): +Index: xen-4.3.0-testing/tools/python/xen/lowlevel/xc/xc.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/lowlevel/xc/xc.c ++++ xen-4.3.0-testing/tools/python/xen/lowlevel/xc/xc.c +@@ -942,18 +942,23 @@ static PyObject *pyxc_hvm_build(XcObject + struct hvm_info_table *va_hvm; + uint8_t *va_map, sum; + #endif +- int i; +- char *image; ++ int i, datalen; ++ char *image, *smbios_str, *acpi_str; + int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1; ++ PyObject *acpi_firmware = NULL; ++ PyObject *smbios_firmware = NULL; + PyObject *vcpu_avail_handle = NULL; + uint8_t vcpu_avail[(HVM_MAX_VCPUS + 7)/8]; ++ struct xc_hvm_build_args hvm_args = {}; + + static char *kwd_list[] = { "domid", + "memsize", "image", "target", "vcpus", +- "vcpu_avail", "acpi", "apic", NULL }; +- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiOii", kwd_list, ++ "vcpu_avail", "acpi", "apic", ++ "smbios_firmware", "acpi_firmware", NULL }; ++ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiOiiOO", kwd_list, + &dom, &memsize, &image, &target, &vcpus, +- &vcpu_avail_handle, &acpi, &apic) ) ++ &vcpu_avail_handle, &acpi, ++ &apic, &smbios_firmware, &acpi_firmware) ) + return NULL; + + memset(vcpu_avail, 0, sizeof(vcpu_avail)); +@@ -984,8 +989,38 @@ static PyObject *pyxc_hvm_build(XcObject + if ( target == -1 ) + target = memsize; + +- if ( xc_hvm_build_target_mem(self->xc_handle, dom, memsize, +- target, image) != 0 ) ++ memset(&hvm_args, 0, sizeof(struct xc_hvm_build_args)); ++ hvm_args.mem_size = (uint64_t)memsize << 20; ++ hvm_args.mem_target = (uint64_t)target << 20; ++ hvm_args.image_file_name = image; ++ ++ if ( PyString_Check(smbios_firmware ) ) ++ { ++ smbios_str = PyString_AsString(smbios_firmware); ++ if ( smbios_str ) ++ { ++ datalen = *(int *)smbios_str; ++ if ( datalen ) { ++ hvm_args.smbios_module.data = &((uint8_t *)smbios_str)[4]; ++ hvm_args.smbios_module.length = (uint32_t)datalen; ++ } ++ } ++ } ++ ++ if ( PyString_Check(acpi_firmware ) ) ++ { ++ acpi_str = PyString_AsString(acpi_firmware); ++ if (acpi_str) ++ { ++ datalen = *(int *)acpi_str; ++ if ( datalen ) { ++ hvm_args.acpi_module.data = &((uint8_t *)acpi_str)[4]; ++ hvm_args.acpi_module.length = (uint32_t)datalen; ++ } ++ } ++ } ++ ++ if ( xc_hvm_build(self->xc_handle, dom, &hvm_args) != 0 ) + return pyxc_error_to_exception(self->xc_handle); + + #if !defined(__ia64__) +Index: xen-4.3.0-testing/tools/python/README.sxpcfg +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/README.sxpcfg ++++ xen-4.3.0-testing/tools/python/README.sxpcfg +@@ -51,6 +51,11 @@ image + - vncunused + (HVM) + - device_model ++ - actmem ++ - xenpaging_file ++ - xenpaging_extra ++ - smbios_firmware ++ - acpi_firmware + - display + - xauthority + - vncconsole +Index: xen-4.3.0-testing/tools/python/README.XendConfig +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/README.XendConfig ++++ xen-4.3.0-testing/tools/python/README.XendConfig +@@ -118,6 +118,11 @@ otherConfig + image.vncdisplay + image.vncunused + image.hvm.device_model ++ image.hvm.actmem ++ image.hvm.xenpaging_file ++ image.hvm.xenpaging_extra ++ image.hvm.smbios_firmware ++ image.hvm.apci_firmware + image.hvm.display + image.hvm.xauthority + image.hvm.vncconsole +Index: xen-4.3.0-testing/tools/hotplug/Linux/domain-lock +=================================================================== +--- /dev/null ++++ xen-4.3.0-testing/tools/hotplug/Linux/domain-lock +@@ -0,0 +1,83 @@ ++#!/bin/bash ++ ++basedir=$(dirname "$0") ++ ++usage() { ++ echo "usage: domain-lock [-l|-u] -n -i -p path" ++ echo "usage: domain-lock [-s] -i path" ++ echo "" ++ echo "-l lock" ++ echo "-u unlock" ++ echo "-s status (default)" ++ echo "-n Virtual Machine name" ++ echo "-i Virtual Machine Id or UUID" ++ echo "-p Virtual Machine Server (physical host) name" ++ echo "path A per-VM, unique location where external lock will be managed" ++ exit 1 ++} ++ ++remove_lock(){ ++ local path=$1/lock ++ local name=$2 ++ ++ pid=`ps -efwww | grep vm-monitor | grep $name | awk '{print $2}'` ++ if [ -n "$pid" ]; then ++ kill $pid ++ rm -f $path ++ fi ++} ++ ++get_status(){ ++ local path=$1/lock ++ [ -f $path ] || exit 1 ++ ++ rc=`flock -xn $path /bin/true` ++ cat $path ++ exit $rc ++} ++ ++mode="status" ++ ++while getopts ":lusn:i:p:" opt; do ++ case $opt in ++ l ) ++ mode="lock" ++ ;; ++ u ) ++ mode="unlock" ++ ;; ++ s ) ++ mode="status" ++ ;; ++ p ) ++ vm_host=$OPTARG ++ ;; ++ n ) ++ vm_name=$OPTARG ++ ;; ++ i ) ++ vm_uuid=$OPTARG ++ ;; ++ \? ) ++ usage ++ ;; ++ esac ++done ++ ++shift $(($OPTIND - 1)) ++vm_path=$1 ++ ++case $mode in ++ lock ) ++ [ -z "$vm_path" ] || [ -z "$vm_name" ] || [ -z "$vm_uuid" ] || [ -z "$vm_host" ] && usage ++ $basedir/set-lock $vm_path $vm_name $vm_uuid $vm_host ++ ;; ++ unlock ) ++ [ -z "$vm_path" ] || [ -z "$vm_name" ] || [ -z "$vm_uuid" ] || [ -z "$vm_host" ] && usage ++ remove_lock $vm_path $vm_name $vm_uuid $vm_host ++ ;; ++ status ) ++ [ -z "$vm_path" ] && usage ++ get_status $vm_path ++ ;; ++esac +Index: xen-4.3.0-testing/tools/hotplug/Linux/vm-monitor +=================================================================== +--- /dev/null ++++ xen-4.3.0-testing/tools/hotplug/Linux/vm-monitor +@@ -0,0 +1,41 @@ ++#!/bin/bash ++ ++basedir=$(dirname "$0") ++HA_TICK=2 ++ ++monitor() { ++ local path=$1 ++ local name=$2 ++ local uuid=$3 ++ local host=$4 ++ local count=0 ++ path=$path/lock ++ ++ while : ++ do ++ echo "name=$name uuid=$uuid host=$host count=$count" > $path ++ count=$(($count+1)) ++ sleep $HA_TICK ++ done& ++} ++ ++create_lock() { ++ local path=$1/lock ++ local rc=0 ++ ++ [ -f $path ] || touch $path ++ flock -x -w $HA_TICK $path $basedir/vm-monitor $* ++ rc=$? ++ if [ $rc -eq 1 ]; then ++ echo `cat $path` ++ exit 1 ++ else ++ exit $rc ++ fi ++} ++ ++if [ $0 = "$basedir/set-lock" ]; then ++ create_lock $* ++elif [ $0 = "$basedir/vm-monitor" ]; then ++ monitor $* ++fi +Index: xen-4.3.0-testing/tools/python/xen/xend/XendOptions.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/XendOptions.py ++++ xen-4.3.0-testing/tools/python/xen/xend/XendOptions.py +@@ -154,6 +154,20 @@ class XendOptions: + use loose check automatically if necessary.""" + pci_dev_assign_strict_check_default = True + ++ """Default for the flag indicating whether xend should create ++ a lock file for domains when they are started.""" ++ xend_domain_lock = 'no' ++ ++ """Default domain lock storage path.""" ++ xend_domain_lock_path_default = '/var/lib/xen/images/vm_locks' ++ ++ """Default script to acquire/release domain lock""" ++ xend_domain_lock_utility = auxbin.scripts_dir() + "/domain-lock" ++ ++ """Default block device for lock service""" ++ xend_domain_lock_device = "" ++ ++ + def __init__(self): + self.configure() + +@@ -401,6 +415,26 @@ class XendOptions: + else: + return None + ++ def get_xend_domain_lock(self): ++ """Get the flag indicating whether xend should create a lock file ++ for domains when they are started.""" ++ return self.get_config_bool("xend-domain-lock", self.xend_domain_lock) ++ ++ def get_xend_domain_lock_path(self): ++ """ Get the path for domain lock storage ++ """ ++ return self.get_config_string("xend-domain-lock-path", self.xend_domain_lock_path_default) ++ ++ def get_xend_domain_lock_utility(self): ++ s = self.get_config_string('xend-domain-lock-utility') ++ ++ if s: ++ return os.path.join(auxbin.scripts_dir(), s) ++ else: ++ return self.xend_domain_lock_utility ++ ++ def get_xend_domain_lock_device(self): ++ return self.get_config_string('xend-domain-lock-device', self.xend_domain_lock_device) + + def get_vnc_tls(self): + return self.get_config_string('vnc-tls', self.xend_vnc_tls) +Index: xen-4.3.0-testing/tools/hotplug/Linux/domain-lock-sfex +=================================================================== +--- /dev/null ++++ xen-4.3.0-testing/tools/hotplug/Linux/domain-lock-sfex +@@ -0,0 +1,166 @@ ++#!/bin/bash ++ ++# pre-condition ++# 1. device is ready: logical volume activated if used ++# 2. device already initialized ++# 3. index is assigned correctly ++ ++#error code: ++# 0: success ++# 1: error ++ ++if [ `uname -m` = "x86_64" ]; then ++ SFEX_DAEMON=/usr/lib64/heartbeat/sfex_daemon ++else ++ SFEX_DAEMON=/usr/lib/heartbeat/sfex_daemon ++fi ++SFEX_INIT=/usr/sbin/sfex_init ++COLLISION_TIMEOUT=1 ++LOCK_TIMEOUT=3 ++MONITOR_INTERVAL=2 ++LOCAL_LOCK_FILE=/var/lock/sfex ++ ++usage() { ++ echo "usage: domain-lock-sfex [-l|-u|-s] -i -x " ++ echo "" ++ echo "-l lock" ++ echo "-u unlock" ++ echo "-s status (default)" ++ echo "-i Virtual Machine Id or UUID" ++ echo "-x SFEX device which used for sfex lock" ++ exit 1 ++} ++ ++get_lock_host() { ++ local rscname=$1 ++ local device=$2 ++ r=`$SFEX_DAEMON -s -u $rscname $device` ++ echo $r ++} ++ ++get_status() { ++ local rscname=$1 ++ if /usr/bin/pgrep -f "$SFEX_DAEMON .* ${rscname} " > /dev/null 2>&1; then ++ return 0 ++ else ++ return 1 ++ fi ++} ++ ++acquire_lock() { ++ local rscname=$1 ++ local device=$2 ++ get_status $rscname ++ ## We assume xend will take care to avoid starting same VM twice on the same machine. ++ if [ $? -eq 0 ]; then ++ return 0 ++ fi ++ $SFEX_DAEMON -c $COLLISION_TIMEOUT -t $LOCK_TIMEOUT -m $MONITOR_INTERVAL -u $rscname $device ++ rc=$? ++ if [ $rc -ne 0 ]; then ++ return $rc ++ fi ++ sleep 4 ++ get_status $rscname ++ if [ $? -eq 0 ]; then ++ return 0 ++ fi ++ return 1 ++} ++ ++# release has to success ++release_lock(){ ++ local rscname=$1 ++ ++ ## If the lock is already released ++ get_status $rscname ++ if [ $? -ne 0 ]; then ++ return 0 ++ fi ++ ++ pid=`/usr/bin/pgrep -f "$SFEX_DAEMON .* ${rscname} "` ++ /bin/kill $pid ++ ++ count=0 ++ while [ $count -lt 10 ] ++ do ++ get_status $rscname ++ if [ $? -eq 1 ]; then ++ return 0 ++ fi ++ count=`expr $count + 1` ++ sleep 1 ++ done ++ ++ /bin/kill -9 $pid ++ while : ++ do ++ get_status $rscname ++ if [ $? -eq 1 ]; then ++ break; ++ fi ++ sleep 1 ++ done ++ ++ return 0 ++} ++ ++mode="status" ++ ++while getopts ":lusn:i:p:x:" opt; do ++case $opt in ++l ) ++mode="lock" ++;; ++u ) ++mode="unlock" ++;; ++s ) ++mode="status" ++;; ++n ) ++vm_name=$OPTARG ++;; ++i ) ++vm_uuid=$OPTARG ++;; ++p ) ++vm_host=$OPTARG ++;; ++x ) ++vm_sfex_device=$OPTARG ++;; ++\? ) ++usage ++;; ++esac ++done ++ ++shift $(($OPTIND - 1)) ++[ -z $vm_uuid ] && usage ++[ -z $vm_sfex_device ] && usage ++ ++case $mode in ++lock ) ++ ( ++ flock -x 200 ++ acquire_lock $vm_uuid $vm_sfex_device ++ rc=$? ++ flock -u 200 ++ exit $rc ++ ) 200>$LOCAL_LOCK_FILE-$vm_uuid ++;; ++unlock ) ++ ( ++ flock -x 200 ++ release_lock $vm_uuid ++ rc=$? ++ flock -u 200 ++ exit $rc ++ ) 200>$LOCAL_LOCK_FILE-$vm_uuid ++;; ++status ) ++ get_lock_host $vm_uuid $vm_sfex_device ++;; ++esac ++ +Index: xen-4.3.0-testing/tools/python/xen/xend/server/BlktapController.py +=================================================================== +--- xen-4.3.0-testing.orig/tools/python/xen/xend/server/BlktapController.py ++++ xen-4.3.0-testing/tools/python/xen/xend/server/BlktapController.py +@@ -15,6 +15,7 @@ blktap1_disk_types = [ + 'ram', + 'qcow', + 'qcow2', ++ 'cdrom', + 'ioemu', + ] + +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-xen.h +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/qemu-xen.h ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/qemu-xen.h +@@ -1,6 +1,8 @@ + #ifndef QEMU_XEN_H + #define QEMU_XEN_H + ++#include "hw/boards.h" ++ + /* vl.c */ + extern int restore; + extern int vga_ram_size; +@@ -47,6 +49,7 @@ void unset_vram_mapping(void *opaque); + #endif + + void pci_unplug_netifs(void); ++void pci_unplug_scsi(void); + void destroy_hvm_domain(void); + void unregister_iomem(target_phys_addr_t start); + +@@ -64,7 +67,7 @@ void handle_buffered_pio(void); + /* xenstore.c */ + void xenstore_init(void); + uint32_t xenstore_read_target(void); +-void xenstore_parse_domain_config(int domid); ++void xenstore_parse_domain_config(int domid, QEMUMachine *machine); + int xenstore_parse_disable_pf_config(void); + int xenstore_fd(void); + void xenstore_process_event(void *opaque); +Index: xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pci.c +=================================================================== +--- xen-4.3.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/pci.c ++++ xen-4.3.0-testing/tools/qemu-xen-traditional-dir-remote/hw/pci.c +@@ -871,6 +871,50 @@ void pci_unplug_netifs(void) + } + } + ++void pci_unplug_scsi(void) ++{ ++ PCIBus *bus; ++ PCIDevice *dev; ++ PCIIORegion *region; ++ int x; ++ int i; ++ ++ /* We only support one PCI bus */ ++ for (bus = first_bus; bus; bus = NULL) { ++ for (x = 0; x < 256; x++) { ++ dev = bus->devices[x]; ++ if (dev && ++ dev->config[0xa] == 0 && ++ dev->config[0xb] == 1 ++#ifdef CONFIG_PASSTHROUGH ++ && test_pci_devfn(x) != 1 ++#endif ++ ) { ++ /* Found a scsi disk. Remove it from the bus. Note that ++ we don't free it here, since there could still be ++ references to it floating around. There are only ++ ever one or two structures leaked, and it's not ++ worth finding them all. */ ++ bus->devices[x] = NULL; ++ for (i = 0; i < PCI_NUM_REGIONS; i++) { ++ region = &dev->io_regions[i]; ++ if (region->addr == (uint32_t)-1 || ++ region->size == 0) ++ continue; ++ fprintf(logfile, "region type %d at [%x,%x).\n", ++ region->type, region->addr, ++ region->addr+region->size); ++ if (region->type == PCI_ADDRESS_SPACE_IO) { ++ isa_unassign_ioport(region->addr, region->size); ++ } else if (region->type == PCI_ADDRESS_SPACE_MEM) { ++ unregister_iomem(region->addr); ++ } ++ } ++ } ++ } ++ } ++} ++ + typedef struct { + PCIDevice dev; + PCIBus *bus; +Index: xen-4.3.0-testing/tools/examples/xmexample.hvm +=================================================================== +--- xen-4.3.0-testing.orig/tools/examples/xmexample.hvm ++++ xen-4.3.0-testing/tools/examples/xmexample.hvm +@@ -142,6 +142,15 @@ disk = [ 'file:/var/lib/xen/images/disk. + # Device Model to be used + device_model = 'qemu-dm' + ++# the amount of memory in MiB for the guest ++#actmem=42 ++ ++# Optional: guest page file ++#xenpaging_file="/var/lib/xen/xenpaging/..paging" ++ ++# Optional: extra cmdline options for xenpaging ++#xenpaging_extra=[ 'string', 'string' ] ++ + #----------------------------------------------------------------------------- + # boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d) + # default: hard disk, cd-rom, floppy diff --git a/xend-vcpu-affinity-fix.patch b/xend-vcpu-affinity-fix.patch deleted file mode 100644 index 7d280f7..0000000 --- a/xend-vcpu-affinity-fix.patch +++ /dev/null @@ -1,16 +0,0 @@ -Index: xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.1-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -2801,7 +2801,10 @@ class XendDomainInfo: - from xen.xend import XendDomain - doms = XendDomain.instance().list('all') - for dom in filter (lambda d: d.domid != self.domid, doms): -- cpuinfo = dom.getVCPUInfo() -+ try: -+ cpuinfo = dom.getVCPUInfo() -+ except: -+ continue - for vcpu in sxp.children(cpuinfo, 'vcpu'): - if sxp.child_value(vcpu, 'online') == 0: continue - cpumap = list(sxp.child_value(vcpu,'cpumap')) diff --git a/xenpaging.autostart.patch b/xenpaging.autostart.patch deleted file mode 100644 index 6fca3de..0000000 --- a/xenpaging.autostart.patch +++ /dev/null @@ -1,413 +0,0 @@ -# HG changeset patch -# Parent 659ee31faec91ac543578db7c9b2849fb7367419 - -xenpaging: xend: start xenpaging via config option - -Start xenpaging via config option. - -TODO: add libxl support -TODO: parse config values like 42K, 42M, 42G, 42% - -Signed-off-by: Olaf Hering - ---- -v5: - use actmem=, xenpaging_file=, xenpaging_extra= - add xm mem-swap-target - -v4: - add config option for pagefile directory - add config option to enable debug - add config option to set policy mru_size - fail if chdir fails - force self.xenpaging* variables to be strings because a xm new may turn some - of them into type int and later os.execve fails with a TypeError - -v3: - decouple create/destroycreateXenPaging from _create/_removeDevices - init xenpaging variable to 0 if xenpaging is not in config file to - avoid string None coming from sxp file - -v2: - unlink logfile instead of truncating it. - allows hardlinking for further inspection - ---- - tools/examples/xmexample.hvm | 9 +++ - tools/python/README.XendConfig | 3 + - tools/python/README.sxpcfg | 3 + - tools/python/xen/xend/XendConfig.py | 9 +++ - tools/python/xen/xend/XendDomain.py | 15 +++++ - tools/python/xen/xend/XendDomainInfo.py | 23 ++++++++ - tools/python/xen/xend/image.py | 85 ++++++++++++++++++++++++++++++++ - tools/python/xen/xm/create.py | 15 +++++ - tools/python/xen/xm/main.py | 14 +++++ - tools/python/xen/xm/xenapi_create.py | 3 + - 10 files changed, 179 insertions(+) - -Index: xen-4.2.2-testing/tools/examples/xmexample.hvm -=================================================================== ---- xen-4.2.2-testing.orig/tools/examples/xmexample.hvm -+++ xen-4.2.2-testing/tools/examples/xmexample.hvm -@@ -142,6 +142,15 @@ disk = [ 'file:/var/lib/xen/images/disk. - # Device Model to be used - device_model = 'qemu-dm' - -+# the amount of memory in MiB for the guest -+#actmem=42 -+ -+# Optional: guest page file -+#xenpaging_file="/var/lib/xen/xenpaging/..paging" -+ -+# Optional: extra cmdline options for xenpaging -+#xenpaging_extra=[ 'string', 'string' ] -+ - #----------------------------------------------------------------------------- - # boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d) - # default: hard disk, cd-rom, floppy -Index: xen-4.2.2-testing/tools/python/README.XendConfig -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/README.XendConfig -+++ xen-4.2.2-testing/tools/python/README.XendConfig -@@ -120,6 +120,9 @@ otherConfig - image.vncdisplay - image.vncunused - image.hvm.device_model -+ image.hvm.actmem -+ image.hvm.xenpaging_file -+ image.hvm.xenpaging_extra - image.hvm.smbios_firmware - image.hvm.apci_firmware - image.hvm.display -Index: xen-4.2.2-testing/tools/python/README.sxpcfg -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/README.sxpcfg -+++ xen-4.2.2-testing/tools/python/README.sxpcfg -@@ -51,6 +51,9 @@ image - - vncunused - (HVM) - - device_model -+ - actmem -+ - xenpaging_file -+ - xenpaging_extra - - smbios_firmware - - acpi_firmware - - display -Index: xen-4.2.2-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendConfig.py -@@ -147,6 +147,9 @@ XENAPI_PLATFORM_CFG_TYPES = { - 'apic': int, - 'boot': str, - 'device_model': str, -+ 'actmem': str, -+ 'xenpaging_file': str, -+ 'xenpaging_extra': str, - 'smbios_firmware': str, - 'acpi_firmware': str, - 'loader': str, -@@ -518,6 +521,12 @@ class XendConfig(dict): - self['platform']['nomigrate'] = 0 - - if self.is_hvm(): -+ if 'actmem' not in self['platform']: -+ self['platform']['actmem'] = "0" -+ if 'xenpaging_file' not in self['platform']: -+ self['platform']['xenpaging_file'] = "" -+ if 'xenpaging_extra' not in self['platform']: -+ self['platform']['xenpaging_extra'] = [] - if 'smbios_firmware' not in self['platform']: - self['platform']['smbios_firmware'] = "" - if 'acpi_firmware' not in self['platform']: -Index: xen-4.2.2-testing/tools/python/xen/xend/XendDomain.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendDomain.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendDomain.py -@@ -1849,6 +1849,21 @@ class XendDomain: - raise XendInvalidDomain(str(domid)) - dominfo.setMigrateConstraints(max_iters, max_factor, min_remaining, abort_if_busy, log_save_progress) - -+ def domain_swaptarget_set(self, domid, mem): -+ """Set the memory limit for a domain. -+ -+ @param domid: Domain ID or Name -+ @type domid: int or string. -+ @param mem: memory limit (in MiB) -+ @type mem: int -+ @raise XendError: fail to set memory -+ @rtype: 0 -+ """ -+ dominfo = self.domain_lookup_nr(domid) -+ if not dominfo: -+ raise XendInvalidDomain(str(domid)) -+ dominfo.setSwapTarget(mem) -+ - def domain_maxmem_set(self, domid, mem): - """Set the memory limit for a domain. - -Index: xen-4.2.2-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-4.2.2-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1551,6 +1551,17 @@ class XendDomainInfo: - break - xen.xend.XendDomain.instance().managed_config_save(self) - -+ def setSwapTarget(self, target): -+ """Set the swap target of this domain. -+ @param target: In MiB. -+ """ -+ log.debug("Setting swap target of domain %s (%s) to %d MiB.", -+ self.info['name_label'], str(self.domid), target) -+ -+ if self.domid > 0: -+ self.storeDom("memory/target-tot_pages", target * 1024) -+ self.info['platform']['actmem'] = str(target) -+ - def setMemoryTarget(self, target): - """Set the memory target of this domain. - @param target: In MiB. -@@ -2341,6 +2352,8 @@ class XendDomainInfo: - self.info['name_label'], self.domid, self.info['uuid'], - new_name, new_uuid) - self._unwatchVm() -+ if self.image: -+ self.image.destroyXenPaging() - self._releaseDevices() - # Remove existing vm node in xenstore - self._removeVm() -@@ -3020,6 +3033,9 @@ class XendDomainInfo: - - self._createDevices() - -+ if self.image: -+ self.image.createXenPaging() -+ - self.image.cleanupTmpImages() - - self.info['start_time'] = time.time() -@@ -3044,6 +3060,8 @@ class XendDomainInfo: - self.refresh_shutdown_lock.acquire() - try: - self.unwatchShutdown() -+ if self.image: -+ self.image.destroyXenPaging() - self._releaseDevices() - bootloader_tidy(self) - -@@ -3128,6 +3146,7 @@ class XendDomainInfo: - self.image = image.create(self, self.info) - if self.image: - self.image.createDeviceModel(True) -+ self.image.createXenPaging() - self.console_port = console_port - self._storeDomDetails() - self._registerWatches() -@@ -3270,6 +3289,8 @@ class XendDomainInfo: - # could also fetch a parsed note from xenstore - fast = self.info.get_notes().get('SUSPEND_CANCEL') and 1 or 0 - if not fast: -+ if self.image: -+ self.image.destroyXenPaging() - self._releaseDevices() - self.testDeviceComplete() - self.testvifsComplete() -@@ -3285,6 +3306,8 @@ class XendDomainInfo: - self._storeDomDetails() - - self._createDevices() -+ if self.image: -+ self.image.createXenPaging() - log.debug("XendDomainInfo.resumeDomain: devices created") - - xc.domain_resume(self.domid, fast) -Index: xen-4.2.2-testing/tools/python/xen/xend/image.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xend/image.py -+++ xen-4.2.2-testing/tools/python/xen/xend/image.py -@@ -122,6 +122,10 @@ class ImageHandler: - self.vm.permissionsVm("image/cmdline", { 'dom': self.vm.getDomid(), 'read': True } ) - - self.device_model = vmConfig['platform'].get('device_model') -+ self.actmem = str(vmConfig['platform'].get('actmem')) -+ self.xenpaging_file = str(vmConfig['platform'].get('xenpaging_file')) -+ self.xenpaging_extra = vmConfig['platform'].get('xenpaging_extra') -+ self.xenpaging_pid = None - - self.smbios_firmware =(str(vmConfig['platform'].get('smbios_firmware'))) - self.acpi_firmware =(str(vmConfig['platform'].get('acpi_firmware'))) -@@ -394,6 +398,87 @@ class ImageHandler: - sentinel_fifos_inuse[sentinel_path_fifo] = 1 - self.sentinel_path_fifo = sentinel_path_fifo - -+ def createXenPaging(self): -+ if not self.vm.info.is_hvm(): -+ return -+ if self.actmem == "0": -+ return -+ if self.xenpaging_pid: -+ return -+ xenpaging_bin = auxbin.pathTo("xenpaging") -+ args = [xenpaging_bin] -+ args = args + ([ "-f", "/var/lib/xen/xenpaging/%s.%d.paging" % (str(self.vm.info['name_label']), self.vm.getDomid())]) -+ if self.xenpaging_extra: -+ args = args + (self.xenpaging_extra) -+ args = args + ([ "-d", "%d" % self.vm.getDomid()]) -+ self.xenpaging_logfile = "/var/log/xen/xenpaging-%s.log" % str(self.vm.info['name_label']) -+ logfile_mode = os.O_WRONLY|os.O_CREAT|os.O_APPEND|os.O_TRUNC -+ null = os.open("/dev/null", os.O_RDONLY) -+ try: -+ os.unlink(self.xenpaging_logfile) -+ except: -+ pass -+ logfd = os.open(self.xenpaging_logfile, logfile_mode, 0644) -+ sys.stderr.flush() -+ contract = osdep.prefork("%s:%d" % (self.vm.getName(), self.vm.getDomid())) -+ xenpaging_pid = os.fork() -+ if xenpaging_pid == 0: #child -+ try: -+ osdep.postfork(contract) -+ os.dup2(null, 0) -+ os.dup2(logfd, 1) -+ os.dup2(logfd, 2) -+ try: -+ env = dict(os.environ) -+ log.info("starting %s" % args) -+ os.execve(xenpaging_bin, args, env) -+ except Exception, e: -+ log.warn('failed to execute xenpaging: %s' % utils.exception_string(e)) -+ os._exit(126) -+ except: -+ log.warn("starting xenpaging failed") -+ os._exit(127) -+ else: -+ osdep.postfork(contract, abandon=True) -+ self.xenpaging_pid = xenpaging_pid -+ os.close(null) -+ os.close(logfd) -+ self.vm.storeDom("xenpaging/xenpaging-pid", self.xenpaging_pid) -+ self.vm.storeDom("memory/target-tot_pages", int(self.actmem) * 1024) -+ -+ def destroyXenPaging(self): -+ if self.actmem == "0": -+ return -+ if self.xenpaging_pid: -+ try: -+ os.kill(self.xenpaging_pid, signal.SIGHUP) -+ except OSError, exn: -+ log.exception(exn) -+ for i in xrange(100): -+ try: -+ (p, rv) = os.waitpid(self.xenpaging_pid, os.WNOHANG) -+ if p == self.xenpaging_pid: -+ break -+ except OSError: -+ # This is expected if Xend has been restarted within -+ # the life of this domain. In this case, we can kill -+ # the process, but we can't wait for it because it's -+ # not our child. We continue this loop, and after it is -+ # terminated make really sure the process is going away -+ # (SIGKILL). -+ pass -+ time.sleep(0.1) -+ else: -+ log.warning("xenpaging %d took more than 10s " -+ "to terminate: sending SIGKILL" % self.xenpaging_pid) -+ try: -+ os.kill(self.xenpaging_pid, signal.SIGKILL) -+ os.waitpid(self.xenpaging_pid, 0) -+ except OSError: -+ # This happens if the process doesn't exist. -+ pass -+ self.xenpaging_pid = None -+ - def createDeviceModel(self, restore = False): - if self.device_model is None: - return -Index: xen-4.2.2-testing/tools/python/xen/xm/create.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xm/create.py -+++ xen-4.2.2-testing/tools/python/xen/xm/create.py -@@ -503,6 +503,18 @@ gopts.var('acpi_firmware', val='FILE', - fn=set_value, default=None, - use="Path to a file that contains extra ACPI firmware tables.") - -+gopts.var('actmem', val='NUM', -+ fn=set_value, default='0', -+ use="Number of pages to swap.") -+ -+gopts.var('xenpaging_file', val='PATH', -+ fn=set_value, default=None, -+ use="pagefile to use (optional)") -+ -+gopts.var('xenpaging_extra', val='string1,string2', -+ fn=append_value, default=[], -+ use="additional args for xenpaging (optional)") -+ - gopts.var('device_model', val='FILE', - fn=set_value, default=None, - use="Path to device model program.") -@@ -1108,6 +1120,9 @@ def configure_hvm(config_image, vals): - args = [ 'acpi', 'apic', - 'boot', - 'cpuid', 'cpuid_check', -+ 'actmem', -+ 'xenpaging_file', -+ 'xenpaging_extra', - 'device_model', 'display', - 'smbios_firmware', 'acpi_firmware', - 'fda', 'fdb', -Index: xen-4.2.2-testing/tools/python/xen/xm/main.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xm/main.py -+++ xen-4.2.2-testing/tools/python/xen/xm/main.py -@@ -115,6 +115,8 @@ SUBCOMMAND_HELP = { - 'Set the maximum amount reservation for a domain.'), - 'mem-set' : (' ', - 'Set the current memory usage for a domain.'), -+ 'mem-swap-target' : (' ', -+ 'Set the memory usage for a domain.'), - 'migrate' : (' ', - 'Migrate a domain to another machine.'), - 'pause' : ('', 'Pause execution of a domain.'), -@@ -1592,6 +1594,17 @@ def xm_mem_set(args): - mem_target = int_unit(args[1], 'm') - server.xend.domain.setMemoryTarget(dom, mem_target) - -+def xm_mem_swap_target(args): -+ arg_check(args, "mem-swap-target", 2) -+ -+ dom = args[0] -+ -+ if serverType == SERVER_XEN_API: -+ err("xenapi not supported") -+ else: -+ swap_target = int_unit(args[1], 'm') -+ server.xend.domain.swaptarget_set(dom, swap_target) -+ - def xm_usb_add(args): - arg_check(args, "usb-add", 2) - server.xend.domain.usb_add(args[0],args[1]) -@@ -3847,6 +3860,7 @@ commands = { - # memory commands - "mem-max": xm_mem_max, - "mem-set": xm_mem_set, -+ "mem-swap-target": xm_mem_swap_target, - # cpu commands - "vcpu-pin": xm_vcpu_pin, - "vcpu-list": xm_vcpu_list, -Index: xen-4.2.2-testing/tools/python/xen/xm/xenapi_create.py -=================================================================== ---- xen-4.2.2-testing.orig/tools/python/xen/xm/xenapi_create.py -+++ xen-4.2.2-testing/tools/python/xen/xm/xenapi_create.py -@@ -1085,6 +1085,9 @@ class sxp2xml: - 'acpi', - 'apic', - 'boot', -+ 'actmem', -+ 'xenpaging_file', -+ 'xenpaging_extra', - 'device_model', - 'smbios_firmware', - 'acpi_firmware', diff --git a/xenpaging.qemu.flush-cache.patch b/xenpaging.qemu.flush-cache.patch deleted file mode 100644 index 55dbb6f..0000000 --- a/xenpaging.qemu.flush-cache.patch +++ /dev/null @@ -1,31 +0,0 @@ -Subject: xenpaging/qemu-dm: add command to flush buffer cache. - -Add support for a xenstore dm command to flush qemu's buffer cache. - -qemu will just keep mapping pages and not release them, which causes problems -for the memory pager (since the page is mapped, it won't get paged out). When -the pager has trouble finding a page to page out, it asks qemu to flush its -buffer, which releases all the page mappings. This makes it possible to find -pages to swap out agian. - -Already-Signed-off-by: Patrick Colp -Signed-off-by: Olaf Hering - ---- - tools/qemu-xen-traditional-dir-remote/xenstore.c | 3 +++ - 1 file changed, 3 insertions(+) - -Index: xen-4.2.2-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -=================================================================== ---- xen-4.2.2-testing.orig/tools/qemu-xen-traditional-dir-remote/xenstore.c -+++ xen-4.2.2-testing/tools/qemu-xen-traditional-dir-remote/xenstore.c -@@ -1019,6 +1019,9 @@ static void xenstore_process_dm_command_ - do_pci_add(par); - free(par); - #endif -+ } else if (!strncmp(command, "flush-cache", len)) { -+ fprintf(logfile, "dm-command: flush caches\n"); -+ qemu_invalidate_map_cache(); - } else { - fprintf(logfile, "dm-command: unknown command\"%*s\"\n", len, command); - } diff --git a/xm-create-maxmem.patch b/xm-create-maxmem.patch deleted file mode 100644 index 2fde154..0000000 --- a/xm-create-maxmem.patch +++ /dev/null @@ -1,19 +0,0 @@ -Cast maxmem to int before computation - -Reported in L3 bnc#732782 - - From: Dario Abatianni - -Index: xen-4.2.0-testing/tools/python/xen/xm/xenapi_create.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xm/xenapi_create.py -+++ xen-4.2.0-testing/tools/python/xen/xm/xenapi_create.py -@@ -764,7 +764,7 @@ class sxp2xml: - - if get_child_by_name(config, "maxmem"): - memory.attributes["static_max"] = \ -- str(int(get_child_by_name(config, "maxmem")*1024*1024)) -+ str(int(get_child_by_name(config, "maxmem"))*1024*1024) - - vm.appendChild(memory) - diff --git a/xm-create-xflag.patch b/xm-create-xflag.patch deleted file mode 100644 index 1cbb474..0000000 --- a/xm-create-xflag.patch +++ /dev/null @@ -1,46 +0,0 @@ -Index: xen-4.2.0-testing/tools/python/xen/xm/create.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xm/create.py -+++ xen-4.2.0-testing/tools/python/xen/xm/create.py -@@ -36,7 +36,7 @@ from xen.xend.server.DevConstants import - from xen.util import blkif - from xen.util import vscsi_util - import xen.util.xsm.xsm as security --from xen.xm.main import serverType, SERVER_XEN_API, get_single_vm -+from xen.xm.main import serverType, SERVER_XEN_API, SERVER_LEGACY_XMLRPC, get_single_vm - from xen.util import utils, auxbin - from xen.util.pci import dev_dict_to_sxp, \ - parse_pci_name_extended, PciDeviceParseError -@@ -1533,7 +1533,7 @@ def main(argv): - except IOError, exn: - raise OptionError("Cannot read file %s: %s" % (config, exn[1])) - -- if serverType == SERVER_XEN_API: -+ if serverType == SERVER_XEN_API or serverType == SERVER_LEGACY_XMLRPC: - from xen.xm.xenapi_create import sxp2xml - sxp2xml_inst = sxp2xml() - doc = sxp2xml_inst.convert_sxp_to_xml(config, transient=True) -@@ -1541,7 +1541,7 @@ def main(argv): - if opts.vals.dryrun and not opts.is_xml: - SXPPrettyPrint.prettyprint(config) - -- if opts.vals.xmldryrun and serverType == SERVER_XEN_API: -+ if opts.vals.xmldryrun: - print doc.toprettyxml() - - if opts.vals.dryrun or opts.vals.xmldryrun: -Index: xen-4.2.0-testing/tools/python/xen/xend/XendAPIConstants.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/XendAPIConstants.py -+++ xen-4.2.0-testing/tools/python/xen/xend/XendAPIConstants.py -@@ -45,8 +45,10 @@ XEN_API_ON_NORMAL_EXIT = [ - XEN_API_ON_CRASH_BEHAVIOUR = [ - 'destroy', - 'coredump_and_destroy', -+ 'coredump_destroy', - 'restart', - 'coredump_and_restart', -+ 'coredump_restart', - 'preserve', - 'rename_restart' - ] diff --git a/xm-save-check-file.patch b/xm-save-check-file.patch deleted file mode 100644 index 67db2e2..0000000 --- a/xm-save-check-file.patch +++ /dev/null @@ -1,97 +0,0 @@ -Index: xen-4.2.0-testing/tools/python/xen/xend/XendAPI.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/XendAPI.py -+++ xen-4.2.0-testing/tools/python/xen/xend/XendAPI.py -@@ -1959,10 +1959,10 @@ class XendAPI(object): - bool(live), port, node, ssl, bool(chs)) - return xen_api_success_void() - -- def VM_save(self, _, vm_ref, dest, checkpoint): -+ def VM_save(self, _, vm_ref, dest, checkpoint, force): - xendom = XendDomain.instance() - xeninfo = xendom.get_vm_by_uuid(vm_ref) -- xendom.domain_save(xeninfo.getDomid(), dest, checkpoint) -+ xendom.domain_save(xeninfo.getDomid(), dest, checkpoint, force) - return xen_api_success_void() - - def VM_restore(self, _, src, paused): -Index: xen-4.2.0-testing/tools/python/xen/xend/XendDomain.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xend/XendDomain.py -+++ xen-4.2.0-testing/tools/python/xen/xend/XendDomain.py -@@ -1505,7 +1505,7 @@ class XendDomain: - pass - sock.close() - -- def domain_save(self, domid, dst, checkpoint=False): -+ def domain_save(self, domid, dst, checkpoint=False, force=False): - """Start saving a domain to file. - - @param domid: Domain ID or Name -@@ -1521,6 +1521,9 @@ class XendDomain: - if not dominfo: - raise XendInvalidDomain(str(domid)) - -+ if os.access(dst, os.F_OK) and not force: -+ raise XendError("Save file:%s exist!\n" % dst) -+ - if dominfo.getDomid() == DOM0_ID: - raise XendError("Cannot save privileged domain %s" % str(domid)) - if dominfo._stateGet() != DOM_STATE_RUNNING: -Index: xen-4.2.0-testing/tools/python/xen/xm/main.py -=================================================================== ---- xen-4.2.0-testing.orig/tools/python/xen/xm/main.py -+++ xen-4.2.0-testing/tools/python/xen/xm/main.py -@@ -121,7 +121,7 @@ SUBCOMMAND_HELP = { - 'reset' : ('', 'Reset a domain.'), - 'restore' : (' [-p]', - 'Restore a domain from a saved state.'), -- 'save' : ('[-c] ', -+ 'save' : ('[-c|-f] ', - 'Save a domain state to restore later.'), - 'shutdown' : (' [-waRH]', 'Shutdown a domain.'), - 'top' : ('', 'Monitor a host and the domains in real time.'), -@@ -342,6 +342,7 @@ SUBCOMMAND_OPTIONS = { - ), - 'save': ( - ('-c', '--checkpoint', 'Leave domain running after creating snapshot'), -+ ('-f', '--force', 'Force to overwrite exist file'), - ), - 'restore': ( - ('-p', '--paused', 'Do not unpause domain after restoring it'), -@@ -864,18 +865,21 @@ def xm_event_monitor(args): - - def xm_save(args): - -- arg_check(args, "save", 2, 3) -+ arg_check(args, "save", 2, 4) - - try: -- (options, params) = getopt.gnu_getopt(args, 'c', ['checkpoint']) -+ (options, params) = getopt.gnu_getopt(args, 'cf', ['checkpoint', 'force']) - except getopt.GetoptError, opterr: - err(opterr) - usage('save') - - checkpoint = False -+ force = False - for (k, v) in options: - if k in ['-c', '--checkpoint']: - checkpoint = True -+ if k in ['-f', '--force']: -+ force = True - - if len(params) != 2: - err("Wrong number of parameters") -@@ -889,9 +893,9 @@ def xm_save(args): - sys.exit(1) - - if serverType == SERVER_XEN_API: -- server.xenapi.VM.save(get_single_vm(dom), savefile, checkpoint) -+ server.xenapi.VM.save(get_single_vm(dom), savefile, checkpoint, force) - else: -- server.xend.domain.save(dom, savefile, checkpoint) -+ server.xend.domain.save(dom, savefile, checkpoint, force) - - def xm_restore(args): - arg_check(args, "restore", 1, 2)