xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* issues getting more than 16M ram to be used without oopsing. 1.2 and 1.3-unstable
@ 2004-04-03 21:53  3% Brian Wolfe
  0 siblings, 0 replies; 200+ results
From: Brian Wolfe @ 2004-04-03 21:53 UTC (permalink / raw)
  To: Xen-devel

First off, I'd like to say that Xen looks very promising.

I have been trying to get xen to run on my machine for the last 4 days
with only marginal sucess.

I think I am having a hardware compatibility issue. I have tried the
pre-compiled 1.2 tarball, and the nightly build tarball. Neither will work
if I attempt to use more than 16MB of ram  (dom0_mem=16384 works,
dom0_mem=16385 crashes)

I'm getting varying addresses for the xenolinux kernel oopses. Of course,
this takes out the xen core kernel since dom0 is dying.

If I boot with dom0_mem=16384, I can get a dom0 up and running. I can use
it sucesfully with no errors, glitches, etc. I can compile on it (albeit
painfully slowly due to swaping), so I know the core is stable.

This is what I get if I try to launch a xen 1.2 dom1 instance.

vhost1:~# xc_dom_create -Dip=10.10.10.162;vmid=1
Segmentation fault

DOM0: Unable to handle kernel paging request at virtual address ecdc6944
DOM0:  printing eip:
DOM0: c000538e
DOM0: *pde=00000000(00000000)
DOM0: Oops: 0000
DOM0: CPU:    0
DOM0: EIP:    0819:[<c000538e>]    Not tainted
DOM0: EFLAGS: 00211297
DOM0: eax: ecdc6940   ebx: c1032348   ecx: fbff9000   edx: c036de3c
DOM0: esi: ffffffff   edi: c036de3c   ebp: ecdc6940   esp: c036de28
DOM0: ds: 0821   es: 0821   ss: 0821
DOM0: Process python (pid: 238, stackpage=c036d000)<1>
DOM0: Stack: c0019d48 c1032348 c036c000 c0019f8b c107e0a4 00000001
c036c000 ecdc6940
DOM0:        00000000 c1032348 0000007f 000000cd c107e0a4 c001a00a
c1032348 c001b671
DOM0:        c03778f4 0000007f c107e0a4 000000cd c0377840 c03778f4
c0454640 c0e31860
DOM0: Call Trace: [<c0019d48>] [<c0019f8b>] [<c001a00a>] [<c001b671>]
[<c0016ea0>]
DOM0:    [<c0016cf8>] [<c00170fc>] [<c0074b48>] [<c00310d9>] [<c003ceca>]
[<c0033df5>]
DOM0:    [<c003114d>] [<c006ea20>]
DOM0:
DOM0:  <1>Unable to handle kernel paging request at virtual address ecdc6940
DOM0:  printing eip:
DOM0: c0019efc
DOM0: *pde=00000000(00000000)
DOM0: Oops: 0000
DOM0: CPU:    0
DOM0: EIP:    0819:[<c0019efc>]    Not tainted
DOM0: EFLAGS: 00211286
DOM0: eax: c1032348   ebx: c0112518   ecx: 00000020   edx: ffffffff
DOM0: esi: ecdc6940   edi: 00001000   ebp: c0122e20   esp: c01eff4c
DOM0: ds: 0821   es: 0821   ss: 0821
DOM0: Process rpciod (pid: 7, stackpage=c01ef000)<1>
DOM0: Stack: c0123480 c1032348 c0058d3c c0377840 c0122ec4 c01fd518
c0bb5264 c0122f30
DOM0:        00000000 00000008 c0122e20 c01ee000 00000001 c00ea9ef
c0122e20 00000000
DOM0:        c01effbc 00000000 c036c000 00dcb000 00000008 c01367e8
c01ee000 00000001
DOM0: Call Trace: [<c0058d3c>] [<c00ea9ef>] [<c00eab8b>] [<c00eb181>]
[<c00eb0d0>]
DOM0:    [<c006c94e>] [<c00eb0d0>]
DOM0:

8-P
This is what I am getting when I boot 1.3-nightly (as of 4-3-2004), It
dies on the IDE chipset detection. (i'll list the machine info at the end
of this message.)

(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found: 'GUEST_OS=linux,GUEST_VER=2.4,XEN_VER=1.3'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  02800000->02995810
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->03d94000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0000000->c01c97c4
(XEN)  Init. ramdisk: c01ca000->c01ca000
(XEN)  Phys-Mach map: c01ca000->c01ce650
(XEN)  Page tables:   c01cf000->c01d1000
(XEN)  Start info:    c01d1000->c01d2000
(XEN)  Boot stack:    c01d2000->c01d3000
(XEN)  TOTAL:         c0000000->c0400000
(XEN)  ENTRY ADDRESS: c0000000
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input
to Xen).
(XEN) Give DOM0 read access to all PCI devices
Linux version 2.4.25-xen (xenod@labyrinth.cl.cam.ac.uk) (gcc version 3.2.2
20030222 (Red
Hat Linux 3.2.2-5)) #2 Sat Apr 3 03:53:46 BST 2004
(XEN) spurious 8259A interrupt: IRQ7.
On node 0 totalpages: 4500
zone(0): 4096 pages.
zone(1): 404 pages.
zone(2): 0 pages.
Kernel command line: /xenolinux-1.3.gz root=/dev/nfs
nfsroot=10.10.10.161:/xen/dom0 rw ip
=10.10.10.160::10.10.10.1:255.255.255.0:vhost1:eth0:off console=xencons0
ignorebiostables
 noacpi
Initializing CPU#0
Xen reported: 1852.117 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 18507.36 BogoMIPS
Memory: 15916k/18000k available (1292k kernel code, 2084k reserved, 246k
data, 60k init,
0k highmem)
Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 512K (64 bytes/line)
CPU: AMD Athlon(tm) XP 2500+ stepping 00
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed
Successfully installed virtual firewall/router interface
Starting Xen Balloon driver
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
Partition check:
 hda: hda1 hda2 hda3
Skipping partition check on cdrom /dev/hdb
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 512 bind 1024)
IP-Config: Complete:
      device=eth0, addr=10.10.10.160, mask=255.255.255.0, gw=10.10.10.1,
     host=vhost1, domain=, nis-domain=(none),
     bootserver=255.255.255.255, rootserver=10.10.10.161, rootpath=
ip_conntrack version 2.1 (125 buckets, 1000 max) - 292 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
Looking up port of RPC 100003/2 on 10.10.10.161
(XEN) *pde = 0027a063
(XEN)  *pte = 00000000
(XEN) CPU:    0
(XEN) EIP:    0808:[<fc531b5b>]
(XEN) EFLAGS: 00211217
(XEN) eax: fffa004e   ebx: 0000d010   ecx: 0000000f   edx: 0000d010
(XEN) esi: fc6ac120   edi: fffa0012   ebp: fc681140   esp: fc503ec0
(XEN) ds: 0810   es: 0810   fs: 0810   gs: 0810   ss: 0810
(XEN) Stack trace from ESP=fc503ec0:
(XEN) 00000051 00000020 00201096 003e5562 0000d018 0000003c 0000d000 fc681000
(XEN)        00000000 0000e011 00000020 [fc531360] fc681000 fc62be40
00000001 00201016
(XEN)        00000011 00000001 00000000 00000000 0000d00e 0000d000
fc681140 fc67ca20
(XEN)        00000000 00000011 fc62f640 [fc5e2424] 00000011 fc681000
fc503f60 fc629cc0
(XEN)        1173b3af fc67ca20 00000000 fc629cc0 00000000 fc629cc0
00000000 [fc5df4e0]
(XEN)        fc629cc0 00000000 00001ffc 00000000 fc629cc0 00000000
00000000 00000810
(XEN)        00000810 00000810 00000810 ffffff11 [fc5e7f2c] 00000808
00201246 c0182000
(XEN)        c0182000 [fc513385] fc503fb8 00000001 fc69c040 [fc5e7eb0]
00000001 d21bbb00
(XEN)        98e34b00 c0182000 c0182000 c0182000 00000008 00000821
00000821 00000821
(XEN)        00000821 00000008 c00abd25 00000819 00201246 c0183fd8
00000821 fc629cc0

****************************************
CPU0 FATAL PAGE FAULT
[error_code=00000002]
Faulting linear address might be fffa0012
Aieee! CPU0 is toast...
****************************************

Reboot in five seconds...


Now, this machine has been used for aprox 5 months now without any
glitches or oopses. So i'm 99.9999% certain that the hardware is good.

I'm using an NFS root since the ide is only in pio mode (and to eliminate
it's use toher than to boot the kernels).

Any insights?

If necessary for debuging, I can provide access to the hardware via serial
console. :)

Thanks for any help yall can give!

====== My standard CPU and system info from running stock bf24 kernel from
Debian 3.0r2=====




processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 6
model           : 10
model name      : AMD Athlon(tm) XP 2500+
stepping        : 0
cpu MHz         : 1852.080
cache size      : 512 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36
 mmx fxsr sse syscall mmxext 3dnowext 3dnow
bogomips        : 3696.23

vhost1:/proc# free
             total       used       free     shared    buffers     cached
Mem:        900080      34680     865400          0       2152      21544
-/+ buffers/cache:      10984     889096
Swap:       499960          0     499960

Disk /dev/hda: 60.0 GB, 60022480896 bytes
16 heads, 63 sectors/track, 116301 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1         496      249952+  83  Linux
/dev/hda2             497        1488      499968   82  Linux swap
/dev/hda3            1489        9425     4000248   83  Linux
v
vhost1:~# cat /proc/interrupts
           CPU0
  0:     139522    IO-APIC-edge  timer
  1:          2    IO-APIC-edge  keyboard
  2:          0          XT-PIC  cascade
  4:        351    IO-APIC-edge  serial
  8:          4    IO-APIC-edge  rtc
 14:      53292    IO-APIC-edge  ide0
 17:         20   IO-APIC-level  eth1
 23:         11   IO-APIC-level  eth0
NMI:          0
LOC:     139463
ERR:          0
MIS:          0

vhost1:~# cat /proc/ioports
0000-001f : dma1
0020-003f : pic1
0040-005f : timer
0060-006f : keyboard
0070-007f : rtc
0080-008f : dma page reg
00a0-00bf : pic2
00c0-00df : dma2
00f0-00ff : fpu
01f0-01f7 : ide0
03c0-03df : vga+
03f6-03f6 : ide0
03f8-03ff : serial(set)
0cf8-0cff : PCI conf1
d000-d01f : 3Com Corporation 3c595 100BaseTX [Vortex]
  d000-d01f : 00:09.0
e000-e00f : VIA Technologies, Inc. Bus Master IDE
e400-e4ff : VIA Technologies, Inc. Ethernet Controller
  e400-e4ff : via-rhine

vhost1:/proc# cat iomem
00000000-0009f7ff : System RAM
0009f800-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000f0000-000fffff : System ROM
00100000-3feeffff : System RAM
  00100000-002bdc69 : Kernel code
  002bdc6a-00347183 : Kernel data
3fef0000-3fef2fff : ACPI Non-volatile Storage
3fef3000-3fefffff : ACPI Tables
d0000000-d7ffffff : PCI device 1106:3189 (VIA Technologies, Inc.)
d8000000-d9ffffff : PCI Bus #01
  d8000000-d9ffffff : nVidia Corporation Riva TnT2 [NV5]
da000000-dbffffff : PCI Bus #01
  da000000-daffffff : nVidia Corporation Riva TnT2 [NV5]
dd001000-dd0010ff : VIA Technologies, Inc. Ethernet Controller
  dd001000-dd0010ff : via-rhine
fec00000-fec00fff : reserved
fee00000-fee00fff : reserved
ffff0000-ffffffff : reserved

vhost1:~# uname -a
Linux vhost1 2.4.18-bf2.4 #1 Son Apr 14 09:53:28 CEST 2002 i686 GNU/Linux

Debian - Unstable. (updated 4-2-2004)


--- dmesg from debian bootup for reference info.---
Linux version 2.4.18-bf2.4 (root@zombie) (gcc version 2.95.4 20011002
(Debian pr
erelease)) #1 Son Apr 14 09:53:28 CEST 2002
BIOS-provided physical RAM map:
 BIOS-e820: 0000000000000000 - 000000000009f800 (usable)
 BIOS-e820: 000000000009f800 - 00000000000a0000 (reserved)
 BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
 BIOS-e820: 0000000000100000 - 000000003fef0000 (usable)
 BIOS-e820: 000000003fef0000 - 000000003fef3000 (ACPI NVS)
 BIOS-e820: 000000003fef3000 - 000000003ff00000 (ACPI data)
 BIOS-e820: 00000000fec00000 - 00000000fec01000 (reserved)
 BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
 BIOS-e820: 00000000ffff0000 - 0000000100000000 (reserved)
Warning only 896MB will be used.
Use a HIGHMEM enabled kernel.
found SMP MP-table at 000f60c0
hm, page 000f6000 reserved twice.
hm, page 000f7000 reserved twice.
hm, page 000f0000 reserved twice.
hm, page 000f1000 reserved twice.
On node 0 totalpages: 229376
zone(0): 4096 pages.
zone(1): 225280 pages.
zone(2): 0 pages.
Intel MultiProcessor Specification v1.4
    Virtual Wire compatibility mode.
OEM ID: OEM00000 Product ID: PROD00000000 APIC at: 0xFEE00000
Processor #0 Pentium(tm) Pro APIC version 17
I/O APIC #2 Version 17 at 0xFEC00000.
Processors: 1
Kernel command line: root=/dev/hda3 ro  console=ttyS0,115200,8n1
Initializing CPU#0
Detected 1852.080 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 3696.23 BogoMIPS
Memory: 899800k/917504k available (1783k kernel code, 17316k reserved,
549k data
, 280k init, 0k highmem)
Dentry-cache hash table entries: 131072 (order: 8, 1048576 bytes)
Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
Mount-cache hash table entries: 16384 (order: 5, 131072 bytes)
Buffer-cache hash table entries: 65536 (order: 6, 262144 bytes)
Page-cache hash table entries: 262144 (order: 8, 1048576 bytes)
CPU: Before vendor init, caps: 0383fbff c1c3fbff 00000000, vendor = 2
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 512K (64 bytes/line)
CPU: After vendor init, caps: 0383fbff c1c3fbff 00000000 00000000
Intel machine check architecture supported.
Intel machine check reporting enabled on CPU#0.
CPU:     After generic, caps: 0383fbff c1c3fbff 00000000 00000000
CPU:             Common caps: 0383fbff c1c3fbff 00000000 00000000
CPU: AMD Athlon(tm) XP 2500+ stepping 00
Enabling fast FPU save and restore... done.
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... OK.
Checking for popad bug... OK.
POSIX conformance testing by UNIFIX
enabled ExtINT on CPU#0
ESR value before enabling vector: 00000000
ESR value after enabling vector: 00000000
ENABLING IO-APIC IRQs
Setting 2 in the phys_id_present_map
...changing IO-APIC physical APIC ID to 2 ... ok.
init IO_APIC IRQs
 IO-APIC (apicid-pin) 2-0, 2-10, 2-11, 2-16, 2-18, 2-19, 2-20, 2-21, 2-22
not co
nnected.
..TIMER: vector=0x31 pin1=2 pin2=0
number of MP IRQ sources: 16.
number of IO-APIC #2 registers: 24.
testing the IO APIC.......................

IO APIC #2......
.... register #00: 02000000
.......    : physical APIC id: 02
.... register #01: 00178003
.......     : max redirection entries: 0017
.......     : PRQ implemented: 1
.......     : IO APIC version: 0003
 WARNING: unexpected IO-APIC, please mail
          to linux-smp@vger.kernel.org
.... IRQ redirection table:
 NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:
 00 000 00  1    0    0   0   0    0    0    00
 01 001 01  0    0    0   0   0    1    1    39
 02 001 01  0    0    0   0   0    1    1    31
 03 001 01  0    0    0   0   0    1    1    41
 04 001 01  0    0    0   0   0    1    1    49
 05 001 01  0    0    0   0   0    1    1    51
 06 001 01  0    0    0   0   0    1    1    59
 07 001 01  0    0    0   0   0    1    1    61
 08 001 01  0    0    0   0   0    1    1    69
 09 001 01  0    0    0   0   0    1    1    71
 0a 000 00  1    0    0   0   0    0    0    00
 0b 000 00  1    0    0   0   0    0    0    00
 0c 001 01  0    0    0   0   0    1    1    79
 0d 001 01  0    0    0   0   0    1    1    81
 0e 001 01  0    0    0   0   0    1    1    89
 0f 001 01  0    0    0   0   0    1    1    91
 10 000 00  1    0    0   0   0    0    0    00
 11 001 01  1    1    0   1   0    1    1    99
 12 000 00  1    0    0   0   0    0    0    00
 13 000 00  1    0    0   0   0    0    0    00
 14 000 00  1    0    0   0   0    0    0    00
 15 000 00  1    0    0   0   0    0    0    00
 16 000 00  1    0    0   0   0    0    0    00
 17 001 01  1    1    0   1   0    1    1    A1
IRQ to pin mappings:
IRQ0 -> 0:2
IRQ1 -> 0:1
IRQ3 -> 0:3
IRQ4 -> 0:4
IRQ5 -> 0:5
IRQ6 -> 0:6
IRQ7 -> 0:7
IRQ8 -> 0:8
IRQ9 -> 0:9
IRQ12 -> 0:12
IRQ13 -> 0:13
IRQ14 -> 0:14
IRQ15 -> 0:15
IRQ17 -> 0:17
IRQ23 -> 0:23
.................................... done.
Using local APIC timer interrupts.
calibrating APIC timer ...
..... CPU clock speed is 1851.9610 MHz.
..... host bus clock speed is 336.7201 MHz.
cpu: 0, clocks: 3367201, slice: 1683600
CPU0<T0:3367200,T1:1683600,D:0,S:1683600,C:3367201>
mtrr: v1.40 (20010327) Richard Gooch (rgooch@atnf.csiro.au)
mtrr: detected mtrr type: Intel
PCI: PCI BIOS revision 2.10 entry at 0xfb8d0, last bus=1
PCI: Using configuration type 1
PCI: Probing PCI hardware
Unknown bridge resource 0: assuming transparent
PCI: Using IRQ router VIA [1106/3177] at 00:11.0
PCI->APIC IRQ transform: (B0,I9,P0) -> 17
PCI->APIC IRQ transform: (B0,I18,P0) -> 23
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
VFS: Diskquotas version dquot_6.4.0 initialized
Journalled Block Device driver loaded
vga16fb: initializing
vga16fb: mapped to 0xc00a0000
Console: switching to colour frame buffer device 80x30
fb0: VGA16 VGA frame buffer device
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
Serial driver version 5.05c (2001-07-08) with MANY_PORTS SHARE_IRQ
SERIAL_PCI en
abled
ttyS00 at 0x03f8 (irq = 4) is a 16550A
Real Time Clock Driver v1.10e
block: 128 slots per queue, batch=32
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Uniform Multi-Platform E-IDE driver Revision: 6.31
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
VP_IDE: IDE controller on PCI bus 00 dev 89
PCI: No IRQ known for interrupt pin A of device 00:11.1. Probably buggy MP
table
.
VP_IDE: chipset revision 6
VP_IDE: not 100% native mode: will probe irqs later
VP_IDE: Unknown VIA SouthBridge, contact Vojtech Pavlik <vojtech@suse.cz>
hda: ST360021A, ATA DISK drive
hdb: TOSHIBA CD-ROM XM-5602B, ATAPI CD/DVD-ROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide0: probed IRQ 14 failed, using default.
hda: 117231408 sectors (60022 MB) w/2048KiB Cache, CHS=7297/255/63
hdb: ATAPI 8X CD-ROM drive, 256kB Cache
Uniform CD-ROM driver Revision: 3.12
ide-floppy driver 0.97.sv
Partition check:
 hda: hda1 hda2 hda3
floppy0: no floppy controllers found
Loading I2O Core - (c) Copyright 1999 Red Hat Software
I2O configuration manager v 0.04.
  (C) Copyright 1999 Red Hat Software
loop: loaded (max 8 devices)
Compaq CISS Driver (v 2.4.5)
HDLC support module revision 1.02 for Linux 2.4
Cronyx Ltd, Synchronous PPP and CISCO HDLC (c) 1994
Linux port (c) 1998 Building Number Three Ltd & Jan "Yenya" Kasprzak.
ide-floppy driver 0.97.sv
Promise Fasttrak(tm) Softwareraid driver 0.03beta: No raid array found
Highpoint HPT370 Softwareraid driver for linux version 0.01
No raid array found
SCSI subsystem driver Revision: 1.00
Red Hat/Adaptec aacraid driver, Apr 14 2002
DC390: 0 adapters found
3ware Storage Controller device driver for Linux v1.02.00.016.
3w-xxxx: No cards with valid units found.
request_module[scsi_hostadapter]: Root fs not mounted
request_module[scsi_hostadapter]: Root fs not mounted
i2o_scsi.c: Version 0.0.1
  chain_pool: 0 bytes @ c1e0ecc0
  (512 byte buffers X 4 can_queue X 0 i2o controllers)
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP, IGMP
IP: routing cache hash table of 8192 buckets, 64Kbytes
TCP: Hash tables configured (established 262144 bind 65536)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
kjournald starting.  Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.
Freeing unused kernel memory: 280k freed
Adding Swap: 499960k swap-space (priority -1)
EXT3 FS 2.4-0.9.17, 10 Jan 2002 on ide0(3,3), internal journal
via-rhine.c:v1.10-LK1.1.13  Nov-17-2001  Written by Donald Becker
  http://www.scyld.com/network/via-rhine.html
eth0: VIA VT6102 Rhine-II at 0xe400, 00:50:8d:4f:33:d7, IRQ 23.
eth0: MII PHY found at address 1, status 0x786d advertising 05e1 Link 45e1.
3c59x: Donald Becker and others. www.scyld.com/network/vortex.html
00:09.0: 3Com PCI 3c595 Vortex 100baseTx at 0xd000. Vers LK1.1.16
00:09.0: Overriding PCI latency timer (CFLT) setting of 32, new value is 248.
eth0: Setting full-duplex based on MII #1 link partner capability of 45e1.



-- 
Brian Wolfe           | Phone 1-(214)-764-1204
President,            | Email  brianw@terrabox.com
TerraBox.com Inc.     |


pub  1024D/73C5A2DF 2003-03-18 Brian Wolfe <brianw@terrabox.com>
     Key fingerprint = 050E 5E3C CF65 4C1E A183  F48F E3E3 5B22 73C5 A2DF
sub  1024g/BB87A3DD 2003-03-18





-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[relevance 3%]

* Re: issues getting more than 16M ram to be used without oopsing. 1.2 and 1.3-unstable
  @ 2004-04-05 17:29  3%   ` Brian Wolfe
  0 siblings, 0 replies; 200+ results
From: Brian Wolfe @ 2004-04-05 17:29 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 2867 bytes --]

Heh, I know what you mean on the VIA boards. I almost always have an issue
booting > 3 month old kernels on them. 8-P I spose I could look at via as
a "enforced upgrade" system. ;)

*nod* I'd tried the noacpi, ignorebiostables, etc. All of the usual tricks
on the xenolinux.gz kernel image as well to no avail pror to harassing
yall. :) I think my friend Adam was feeling a bit abused as a Xen suport
route as well. *grin*

Things are getting a LITTLE bit futher on the bootup. :) Any chance the
IDE , USB, and/or ethernet interfaces are doign something funky?

Here is the lspci -vv and Linux 2.6.4 compiled for K7 and HIGHMEM4G if you
need the raw info. I disabled USB, firewire etc, basicly anything that
wasn't needed for a server setup. Striped scsi out as much as possible as
well (i'm a minimalist on server kernels).

I have attached a copy of the serial console log from booting with
dom0_mem=1800 vs dom0_mem=1600 noacpi ignorebiostables for reference.
I have also attached a log of lspci -vv and the kernel boot log for 2.6.4
+HIGHMEM4G and the screen from memtest86+ 3.0

 If you need ANYTHING to help, please don't hesitate to let me know
directly. The hardware and my time are at you and other xen developers
command. :)


-- 
Brian Wolfe           | Phone 1-(214)-764-1204
President,            | Email  brianw@terrabox.com
TerraBox.com Inc.     |


pub  1024D/73C5A2DF 2003-03-18 Brian Wolfe <brianw@terrabox.com>
     Key fingerprint = 050E 5E3C CF65 4C1E A183  F48F E3E3 5B22 73C5 A2DF
sub  1024g/BB87A3DD 2003-03-18


Keir Fraser said:
>> > > Maybe Xen pokes around in different ways/areas than the linux kernel
>> did
>> > > and has found some bad ram and/or APIC  flaw that I just never ran
>> into
>> > > with Linux by sheer chance.
>> >
>> > Okay, I'll take a look at what changes there have been to IO-APIC and
>> > ACPI code up to Linux 2.4.25 -- certainly the most recent 2.4 kernel
>> > matches your IO-APIC version and doesn't print the 'unexpected
>> > IO-APIC' message.
>> >
>> > Perhaps there is some 'quirk' fix that we are missing -- VIA boards
>> > usually need a few of those (the general opinion of VIA boards among
>> > Linux kernel developers is pretty low, I think :-).
>>
>> I've pushed updates from latest Linux 2.4 into Xen. If you don't want
>> to download the source repository and build it yourself, suitable Xen
>> and Xenolinux images are available here:
>>  http://www.cl.cam.ac.uk/~kaf24/xen.gz
>>  http://www.cl.cam.ac.uk/~kaf24/xenolinux.gz
>
> Another couple of things to try:
>  1. Specify 'noacpi' and/or 'ignorebiostables' on Xen's command line.
>     This will cause parsing of some configuration tables to be skipped
>     -- which may help if the BIOS is buggy.
>  2. Let us know more hardware details (e.g. VIA chipset version). It
>  would be useful to see the output of lspci ('lspci -vv').
>
>  -- Keir
>

[-- Attachment #2: xen-kenf.log --]
[-- Type: application/octet-stream, Size: 42285 bytes --]

Press any key to continue.

    GNU GRUB  version 0.94  (638K lower / 1046464K upper memory)

+-------------------------------------------------------------------------+||||||||||||||||||||||||+-------------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press enter to boot the selected OS, 'e' to edit the
      commands before booting, or 'c' for a command-line.  Debian GNU/Linux, kernel 2.4.18-bf2.4                                    Debian GNU/Linux, kernel 2.4.18-bf2.4 (recovery mode)                    Custom 2.6.4 HIGHMEM4G for xen debug                                     Xen-1.2                                                                  Xen-1.3                                                                  Memory Test x86+                                                         Memory Test x86+ 3.0 - Serial Console                                                                                                                                                                                                                                                                                                                                                                                                                 The highlighted entry will be booted automatically in 10 seconds.    The highlighted entry will be booted automatically in 9 seconds.    The highlighted entry will be booted automatically in 8 seconds.    The highlighted entry will be booted automatically in 7 seconds.    The highlighted entry will be booted automatically in 6 seconds.                                                                         Debian GNU/Linux, kernel 2.4.18-bf2.4                                    Debian GNU/Linux, kernel 2.4.18-bf2.4 (recovery mode)                    Debian GNU/Linux, kernel 2.4.18-bf2.4 (recovery mode)                    Custom 2.6.4 HIGHMEM4G for xen debug                                     Custom 2.6.4 HIGHMEM4G for xen debug                                     Xen-1.2                                                                 
    GNU GRUB  version 0.94  (638K lower / 1046464K upper memory)

+-------------------------------------------------------------------------+||||||||||||||||||||||||+-------------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press 'b' to boot, 'e' to edit the selected command in the
      boot sequence, 'c' for a command-line, 'o' to open a new line
      after ('O' for before) the selected line, 'd' to remove the
      selected line, or escape to go back to the main menu.  root  (hd0,0)                                                            kernel /xen.gz dom0_mem=18000 ser_baud=115200 noht watchdog              module /xenolinux.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw >                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     root  (hd0,0)                                                            kernel /xen.gz dom0_mem=18000 ser_baud=115200 noht watchdog              [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.  ESC at any time exits. ]

grub edit> kernel /xen.gz dom0_mem=18000 ser_baud=115200 noht watchdog          ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog   ser_baud=115200 noht watchdog  n ser_baud=115200 noht watchdog o ser_baud=115200 noht watchdog a ser_baud=115200 noht watchdog c ser_baud=115200 noht watchdog p ser_baud=115200 noht watchdog i ser_baud=115200 noht watchdog  noacpi ser_baud=115200 noht watchdog   noacpi ser_baud=115200 noht watchdog   noacpi ser_baud=115200 noht watchdog  - noacpi ser_baud=115200 noht watchdog k noacpi ser_baud=115200 noht watchdog e noacpi ser_baud=115200 noht watchdog n noacpi ser_baud=115200 noht watchdog f noacpi ser_baud=115200 noht watchdog .gz  noacpi ser_baud=115200 noht watchdog 

    GNU GRUB  version 0.94  (638K lower / 1046464K upper memory)

+-------------------------------------------------------------------------+||||||||||||||||||||||||+-------------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press 'b' to boot, 'e' to edit the selected command in the
      boot sequence, 'c' for a command-line, 'o' to open a new line
      after ('O' for before) the selected line, 'd' to remove the
      selected line, or escape to go back to the main menu.  root  (hd0,0)                                                            kernel /xen-kenf.gz  noacpi ser_baud=115200 noht watchdog                module /xenolinux.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw >                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     kernel /xen-kenf.gz  noacpi ser_baud=115200 noht watchdog                module /xenolinux.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw >   [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.  ESC at any time exits. ]

<ff console=xencons0                                                            noacpi<xen/dom0 rw ip=10.10.10.160::10.10.10.1:255.255.255.0:vhost1:eth0:off console>grub edit> module /xenolinux.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 r> root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw> root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw > root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw i>- root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw >k root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw>enf.gz  root=/dev/nfs nfsroot=10.10.10.161:/xen/>

    GNU GRUB  version 0.94  (638K lower / 1046464K upper memory)

+-------------------------------------------------------------------------+||||||||||||||||||||||||+-------------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press 'b' to boot, 'e' to edit the selected command in the
      boot sequence, 'c' for a command-line, 'o' to open a new line
      after ('O' for before) the selected line, 'd' to remove the
      selected line, or escape to go back to the main menu.  root  (hd0,0)                                                            kernel /xen-kenf.gz  noacpi ser_baud=115200 noht watchdog                module /xenolinux-kenf.gz  root=/dev/nfs nfsroot=10.10.10.161:/xen/do>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Booting command-list

root  (hd0,0)
 Filesystem type is ext2fs, partition type 0x83
kernel /xen-kenf.gz  noacpi ser_baud=115200 noht watchdog 
   [Multiboot-elf, <0x100000:0x134348:0x0>, <0x236000:0x2053c:0x22404>, shtab=0
x2791e0, entry=0x100000]
module /xenolinux-kenf.gz  root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw ip=1
0.10.10.160::10.10.10.1:255.255.255.0:vhost1:eth0:off console=xencons0 noacpi
   [Multiboot-module @ 0x27a000, 0x195810 bytes]

 __  __            _   _____        _                _ 
 \ \/ /___ _ __   / | |___ /     __| | _____   _____| |
  \  // _ \ '_ \  | |   |_ \ __ / _` |/ _ \ \ / / _ \ |
  /  \  __/ | | | | |_ ___) |__| (_| |  __/\ V /  __/ |
 /_/\_\___|_| |_| |_(_)____/    \__,_|\___| \_/ \___|_|
                                                       
 http://www.cl.cam.ac.uk/netos/xen
 University of Cambridge Computer Laboratory

 Xen version 1.3-devel (kaf24@cl.cam.ac.uk) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) Mon Apr 5 14:18:14 BST 2004

(XEN) **WARNING**: Xen option 'ser_baud=' is deprecated! Use 'com1=' instead.
(XEN) Initialised 1022MB memory on a 1022MB machine
(XEN) Xen heap size is 13853KB
(XEN) Initialising Xen allocator with 13MB memory
(XEN) Reading BIOS drive-info tables at 0xf95f0 and 0xfe819
(XEN) CPU0: Before vendor init, caps: 0383fbff c1c3fbff 00000000, vendor = 2
(XEN) CPU caps: 0383fbff c1c3fbff 00000000 00000000
(XEN) found SMP MP-table at 000f60c0
(XEN) Memory Reservation 0xf60c0, 4096 bytes
(XEN) Memory Reservation 0xf0c00, 4096 bytes
(XEN) Intel MultiProcessor Specification v1.4
(XEN)     Virtual Wire compatibility mode.
(XEN) OEM ID: OEM00000 Product ID: PROD00000000 APIC at: 0xFEE00000
(XEN) Processor #0 Pentium(tm) Pro APIC version 17
(XEN) I/O APIC #2 Version 17 at 0xFEC00000.
(XEN) Enabling APIC mode: Flat.	Using 1 I/O APICs
(XEN) Processors: 1
(XEN) Initialising domains
(XEN) Initialising schedulers
(XEN) Using scheduler: Borrowed Virtual Time (bvt)
(XEN) Initializing CPU#0
(XEN) Detected 1852.068 MHz processor.
(XEN) CPU0: Before vendor init, caps: 0383fbff c1c3fbff 00000000, vendor = 2
(XEN) CPU caps: 0383fbff c1c3fbff 00000000 00000000
(XEN) CPU0 booted
(XEN) enabled ExtINT on CPU#0
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) Error: only one processor found.
(XEN) ENABLING IO-APIC IRQs
(XEN) Setting 2 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 2 ... ok.
(XEN) init IO_APIC IRQs
(XEN)  IO-APIC (apicid-pin) 2-0, 2-10, 2-11, 2-16, 2-18, 2-19, 2-20, 2-21, 2-22 not connected.
(XEN) ..TIMER: vector=0x41 pin1=2 pin2=0
(XEN) number of MP IRQ sources: 16.
(XEN) number of IO-APIC #2 registers: 24.
(XEN) testing the IO APIC.......................
(XEN) 
(XEN) IO APIC #2......
(XEN) .... register #00: 02000000
(XEN) .......    : physical APIC id: 02
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178003
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0003
(XEN) An unexpected IO-APIC was found. If this kernel release is less than
(XEN) three months old please report this to linux-smp@vger.kernel.org
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:   
(XEN)  00 000 00  1    0    0   0   0    0    0    00
(XEN)  01 001 01  0    0    0   0   0    1    1    49
(XEN)  02 001 01  0    0    0   0   0    1    1    41
(XEN)  03 001 01  0    0    0   0   0    1    1    51
(XEN)  04 001 01  0    0    0   0   0    1    1    59
(XEN)  05 001 01  0    0    0   0   0    1    1    61
(XEN)  06 001 01  0    0    0   0   0    1    1    69
(XEN)  07 001 01  0    0    0   0   0    1    1    71
(XEN)  08 001 01  0    0    0   0   0    1    1    79
(XEN)  09 001 01  0    0    0   0   0    1    1    81
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 001 01  0    0    0   0   0    1    1    89
(XEN)  0d 001 01  0    0    0   0   0    1    1    91
(XEN)  0e 001 01  0    0    0   0   0    1    1    99
(XEN)  0f 001 01  0    0    0   0   0    1    1    A1
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 001 01  1    1    0   1   0    1    1    A9
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 001 01  1    1    0   1   0    1    1    B1
(XEN) IRQ to pin mappings:
(XEN) IRQ0 -> 0:2
(XEN) IRQ1 -> 0:1
(XEN) IRQ3 -> 0:3
(XEN) IRQ4 -> 0:4
(XEN) IRQ5 -> 0:5
(XEN) IRQ6 -> 0:6
(XEN) IRQ7 -> 0:7
(XEN) IRQ8 -> 0:8
(XEN) IRQ9 -> 0:9
(XEN) IRQ12 -> 0:12
(XEN) IRQ13 -> 0:13
(XEN) IRQ14 -> 0:14
(XEN) IRQ15 -> 0:15
(XEN) IRQ17 -> 0:17
(XEN) IRQ23 -> 0:23
(XEN) .................................... done.
(XEN) Using local APIC timer interrupts.
(XEN) Calibrating APIC timer for CPU0...
(XEN) ..... CPU speed is 1852.1029 MHz.
(XEN) ..... Bus speed is 336.7459 MHz.
(XEN) ..... bus_scale = 0x000158E5
(XEN) ACT: Initialising Accurate timers
(XEN) Time init:
(XEN) .... System Time: 12135488ns
(XEN) .... cpu_freq:    00000000:6E645258
(XEN) .... scale:       00000001:14729A53
(XEN) .... Wall Clock:  1081185662s 0us
(XEN) Start schedulers
(XEN) Testing NMI watchdog --- CPU#0 okay. 
(XEN) PCI: PCI BIOS revision 2.10 entry at 0xfb8d0, last bus=1
(XEN) PCI: Using configuration type 1
(XEN) PCI: Probing PCI hardware
(XEN) PCI: Probing PCI hardware (bus 00)
(XEN) PCI: Using IRQ router VIA [1106/3177] at 00:11.0
(XEN) PCI->APIC IRQ transform: (B0,I9,P0) -> 17
(XEN) PCI->APIC IRQ transform: (B0,I18,P0) -> 23
(XEN) 3c59x: Donald Becker and others. www.scyld.com/network/vortex.html
(XEN) 00:09.0: 3Com PCI 3c595 Vortex 100baseTx at 0xd000. Vers LK1.1.16
(XEN) 00:09.0: Overriding PCI latency timer (CFLT) setting of 32, new value is 248.
(XEN) Uniform Multi-Platform E-IDE driver Revision: 6.31
(XEN) ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
(XEN) VP_IDE: IDE controller on PCI bus 00 dev 89
(XEN) VP_IDE: detected chipset, but driver not compiled in!
(XEN) VP_IDE: chipset revision 6
(XEN) VP_IDE: not 100% native mode: will probe irqs later
(XEN)     ide0: BM-DMA at 0xe000-0xe007, BIOS settings: hda:DMA, hdb:DMA
(XEN)     ide1: BM-DMA at 0xe008-0xe00f, BIOS settings: hdc:pio, hdd:pio
(XEN) hda: ST360021A, ATA DISK drive
(XEN) hdb: TOSHIBA CD-ROM XM-5602B, ATAPI CD/DVD-ROM drive
(XEN) ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
(XEN) hdb: ATAPI 8X CD-ROM drive, 256kB Cache
(XEN) Uniform CD-ROM driver Revision: 3.12
(XEN) hda: 117231408 sectors (60022 MB) w/2048KiB Cache, CHS=7297/255/63 PIO (slow!)
(XEN) SCSI subsystem driver Revision: 1.00
(XEN) Red Hat/Adaptec aacraid driver (1.1.2 Apr  5 2004 14:19:02)
(XEN) Device eth0 opened and ready for use.
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found: 'GUEST_OS=linux,GUEST_VER=2.4,XEN_VER=1.3'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  02800000->02995810
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->03ba0000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0000000->c01c97c4
(XEN)  Init. ramdisk: c01ca000->c01ca000
(XEN)  Phys-Mach map: c01ca000->c01cde80
(XEN)  Page tables:   c01ce000->c01d0000
(XEN)  Start info:    c01d0000->c01d1000
(XEN)  Boot stack:    c01d1000->c01d2000
(XEN)  TOTAL:         c0000000->c0400000
(XEN)  ENTRY ADDRESS: c0000000
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen).
(XEN) Give DOM0 read access to all PCI devices
Linux version 2.4.25-xen (kaf24@scramble.cl.cam.ac.uk) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 Mon Apr 5 13:31:10 BST 2004
On node 0 totalpages: 4000
zone(0): 4000 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: /xenolinux-kenf.gz  root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw ip=10.10.10.160::10.10.10.1:255.255.255.0:vhost1:eth0:off console=xencons0 noacpi
Initializing CPU#0
Xen reported: 1852.068 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 18507.36 BogoMIPS
Memory: 13944k/16000k available (1292k kernel code, 2056k reserved, 246k data, 60k init, 0k highmem)
Dentry cache hash table entries: 2048 (order: 2, 16384 bytes)
Inode cache hash table entries: 1024 (order: 1, 8192 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 4096 (order: 2, 16384 bytes)
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 512K (64 bytes/line)
CPU: AMD Athlon(tm) XP 2500+ stepping 00
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed
Successfully installed virtual firewall/router interface
Starting Xen Balloon driver
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
keyboard: Timeout - AT keyboard not present?(ed)
keyboard: Timeout - AT keyboard not present?(f4)
Partition check:
 hda: hda1 hda2 hda3
Skipping partition check on cdrom /dev/hdb
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 512 bind 1024)
IP-Config: Complete:
      device=eth0, addr=10.10.10.160, mask=255.255.255.0, gw=10.10.10.1,
     host=vhost1, domain=, nis-domain=(none),
     bootserver=255.255.255.255, rootserver=10.10.10.161, rootpath=
ip_conntrack version 2.1 (125 buckets, 1000 max) - 292 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
Looking up port of RPC 100003/2 on 10.10.10.161
(XEN) *pde = 0027d063
(XEN)  *pte = 00000000
(XEN) CPU:    0
(XEN) EIP:    0808:[<fc531feb>]      
(XEN) EFLAGS: 00211217
(XEN) eax: fffa004e   ebx: 0000d010   ecx: 0000000f   edx: 0000d010
(XEN) esi: fc6b0120   edi: fffa0012   ebp: fc685140   esp: fc503ec0
(XEN) ds: 0810   es: 0810   fs: 0810   gs: 0810   ss: 0810
(XEN) Stack trace from ESP=fc503ec0:
(XEN) 00000051 00000020 00201096 00028215 0000d018 0000003c 0000d000 fc685000 
(XEN)        00000000 0000e011 00000020 [fc5317f0] fc685000 fc62cac0 00000001 00201016 
(XEN)        00000011 00000001 00201016 00000000 0000d00e 0000d000 fc685140 fc680a20 
(XEN)        00000000 00000011 fc6302c0 [fc5e2974] 00000011 fc685000 fc503f60 fc62a940 
(XEN)        f43df318 00000000 fc680a20 fc62a940 00000000 fc62a940 00000000 [fc5df800] 
(XEN)        fc62a940 00000000 00001ffc 00000000 fc62a940 00000000 00000000 00000810 
(XEN)        00000810 00000810 00000810 ffffff11 [fc5e865c] 00000808 00201246 c0182000 
(XEN)        c0182000 [fc513455] fc503fb8 00000003 fc6a0040 [fc5e85e0] 00000001 258f0880 
(XEN)        ec569880 c0182000 c0182000 c0182000 00000008 00000821 00000821 00000821 
(XEN)        00000821 00000008 c00abd25 00000819 00201246 c0183fd8 00000821 fc62a940 

****************************************
CPU0 FATAL PAGE FAULT
[error_code=00000002]
Faulting linear address might be fffa0012
Aieee! CPU0 is toast...
****************************************

Reboot in five seconds...
Press any key to continue.
Press any key to continue.

    GNU GRUB  version 0.94  (638K lower / 1046464K upper memory)

+-------------------------------------------------------------------------+||||||||||||||||||||||||+-------------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press enter to boot the selected OS, 'e' to edit the
      commands before booting, or 'c' for a command-line.  Debian GNU/Linux, kernel 2.4.18-bf2.4                                    Debian GNU/Linux, kernel 2.4.18-bf2.4 (recovery mode)                    Custom 2.6.4 HIGHMEM4G for xen debug                                     Xen-1.2                                                                  Xen-1.3                                                                  Memory Test x86+                                                         Memory Test x86+ 3.0 - Serial Console                                                                                                                                                                                                                                                                                                                                                                                                                 The highlighted entry will be booted automatically in 10 seconds.                                                                         Debian GNU/Linux, kernel 2.4.18-bf2.4                                    Debian GNU/Linux, kernel 2.4.18-bf2.4 (recovery mode)                    Debian GNU/Linux, kernel 2.4.18-bf2.4 (recovery mode)                    Custom 2.6.4 HIGHMEM4G for xen debug                                     Custom 2.6.4 HIGHMEM4G for xen debug                                     Xen-1.2                                                                 
    GNU GRUB  version 0.94  (638K lower / 1046464K upper memory)

+-------------------------------------------------------------------------+||||||||||||||||||||||||+-------------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press 'b' to boot, 'e' to edit the selected command in the
      boot sequence, 'c' for a command-line, 'o' to open a new line
      after ('O' for before) the selected line, 'd' to remove the
      selected line, or escape to go back to the main menu.  root  (hd0,0)                                                            kernel /xen.gz dom0_mem=18000 ser_baud=115200 noht watchdog              module /xenolinux.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw >                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     root  (hd0,0)                                                            kernel /xen.gz dom0_mem=18000 ser_baud=115200 noht watchdog              [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.  ESC at any time exits. ]

grub edit> kernel /xen.gz dom0_mem=18000 ser_baud=115200 noht watchdog         000 ser_baud=115200 noht watchdog  6000 ser_baud=115200 noht watchdog -.gz dom0_mem=16000 ser_baud=115200 noht watchdog k.gz dom0_mem=16000 ser_baud=115200 noht watchdog e.gz dom0_mem=16000 ser_baud=115200 noht watchdog n.gz dom0_mem=16000 ser_baud=115200 noht watchdog f.gz dom0_mem=16000 ser_baud=115200 noht watchdog 

    GNU GRUB  version 0.94  (638K lower / 1046464K upper memory)

+-------------------------------------------------------------------------+||||||||||||||||||||||||+-------------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press 'b' to boot, 'e' to edit the selected command in the
      boot sequence, 'c' for a command-line, 'o' to open a new line
      after ('O' for before) the selected line, 'd' to remove the
      selected line, or escape to go back to the main menu.  root  (hd0,0)                                                            kernel /xen-kenf.gz dom0_mem=16000 ser_baud=115200 noht watchdog         module /xenolinux.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw >                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     kernel /xen-kenf.gz dom0_mem=16000 ser_baud=115200 noht watchdog         module /xenolinux.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw >   [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.  ESC at any time exits. ]

<ff console=xencons0                                                            noacpi ignoreboi  iostables

    GNU GRUB  version 0.94  (638K lower / 1046464K upper memory)

+-------------------------------------------------------------------------+||||||||||||||||||||||||+-------------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press 'b' to boot, 'e' to edit the selected command in the
      boot sequence, 'c' for a command-line, 'o' to open a new line
      after ('O' for before) the selected line, 'd' to remove the
      selected line, or escape to go back to the main menu.  root  (hd0,0)                                                            kernel /xen-kenf.gz dom0_mem=16000 ser_baud=115200 noht watchdog         module /xenolinux.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw >                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.  ESC at any time exits. ]

<ff console=xencons0 noacpi ignorebiostables                                   <xen/dom0 rw ip=10.10.10.160::10.10.10.1:255.255.255.0:vhost1:eth0:off console>grub edit> module /xenolinux.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 r>-.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 >k.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0>e.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom>n.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/do>f.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/d>

    GNU GRUB  version 0.94  (638K lower / 1046464K upper memory)

+-------------------------------------------------------------------------+||||||||||||||||||||||||+-------------------------------------------------------------------------+
      Use the ^ and v keys to select which entry is highlighted.
      Press 'b' to boot, 'e' to edit the selected command in the
      boot sequence, 'c' for a command-line, 'o' to open a new line
      after ('O' for before) the selected line, 'd' to remove the
      selected line, or escape to go back to the main menu.  root  (hd0,0)                                                            kernel /xen-kenf.gz dom0_mem=16000 ser_baud=115200 noht watchdog         module /xenolinux-kenf.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Booting command-list

root  (hd0,0)
 Filesystem type is ext2fs, partition type 0x83
kernel /xen-kenf.gz dom0_mem=16000 ser_baud=115200 noht watchdog 
   [Multiboot-elf, <0x100000:0x134348:0x0>, <0x236000:0x2053c:0x22404>, shtab=0
x2791e0, entry=0x100000]
module /xenolinux-kenf.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw ip=10
.10.10.160::10.10.10.1:255.255.255.0:vhost1:eth0:off console=xencons0 noacpi ig
norebiostables
   [Multiboot-module @ 0x27a000, 0x195810 bytes]

 __  __            _   _____        _                _ 
 \ \/ /___ _ __   / | |___ /     __| | _____   _____| |
  \  // _ \ '_ \  | |   |_ \ __ / _` |/ _ \ \ / / _ \ |
  /  \  __/ | | | | |_ ___) |__| (_| |  __/\ V /  __/ |
 /_/\_\___|_| |_| |_(_)____/    \__,_|\___| \_/ \___|_|
                                                       
 http://www.cl.cam.ac.uk/netos/xen
 University of Cambridge Computer Laboratory

 Xen version 1.3-devel (kaf24@cl.cam.ac.uk) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) Mon Apr 5 14:18:14 BST 2004

(XEN) **WARNING**: Xen option 'ser_baud=' is deprecated! Use 'com1=' instead.
(XEN) Initialised 1022MB memory on a 1022MB machine
(XEN) Xen heap size is 13853KB
(XEN) Initialising Xen allocator with 13MB memory
(XEN) Reading BIOS drive-info tables at 0xf95f0 and 0xfe819
(XEN) CPU0: Before vendor init, caps: 0383fbff c1c3fbff 00000000, vendor = 2
(XEN) CPU caps: 0383fbff c1c3fbff 00000000 00000000
(XEN) found SMP MP-table at 000f60c0
(XEN) Memory Reservation 0xf60c0, 4096 bytes
(XEN) Memory Reservation 0xf0c00, 4096 bytes
(XEN) ACPI: RSDP (v000 KT600                                     ) @ 0x000f7ac0
(XEN) ACPI: RSDT (v001 KT600  AWRDACPI 0x42302e31 AWRD 0x00000000) @ 0x3fef3000
(XEN) ACPI: FADT (v001 KT600  AWRDACPI 0x42302e31 AWRD 0x00000000) @ 0x3fef3040
(XEN) ACPI: MADT (v001 KT600  AWRDACPI 0x42302e31 AWRD 0x00000000) @ 0x3fef7a00
(XEN) ACPI: DSDT (v001 KT600  AWRDACPI 0x00001000 MSFT 0x0100000e) @ 0x00000000
(XEN) ACPI: Local APIC address 0xfee00000
(XEN) ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
(XEN) Processor #0 Pentium(tm) Pro APIC version 16
(XEN) ACPI: LAPIC_NMI (acpi_id[0x00] high edge lint[0x1])
(XEN) Using ACPI for processor (LAPIC) configuration information
(XEN) Intel MultiProcessor Specification v1.4
(XEN)     Virtual Wire compatibility mode.
(XEN) OEM ID: OEM00000 Product ID: PROD00000000 APIC at: 0xFEE00000
(XEN) I/O APIC #2 Version 17 at 0xFEC00000.
(XEN) Enabling APIC mode: Flat.	Using 1 I/O APICs
(XEN) Processors: 1
(XEN) Initialising domains
(XEN) Initialising schedulers
(XEN) Using scheduler: Borrowed Virtual Time (bvt)
(XEN) Initializing CPU#0
(XEN) Detected 1852.069 MHz processor.
(XEN) CPU0: Before vendor init, caps: 0383fbff c1c3fbff 00000000, vendor = 2
(XEN) CPU caps: 0383fbff c1c3fbff 00000000 00000000
(XEN) CPU0 booted
(XEN) enabled ExtINT on CPU#0
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) Error: only one processor found.
(XEN) ENABLING IO-APIC IRQs
(XEN) Setting 2 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 2 ... ok.
(XEN) init IO_APIC IRQs
(XEN)  IO-APIC (apicid-pin) 2-0, 2-10, 2-11, 2-16, 2-18, 2-19, 2-20, 2-21, 2-22 not connected.
(XEN) ..TIMER: vector=0x41 pin1=2 pin2=0
(XEN) number of MP IRQ sources: 16.
(XEN) number of IO-APIC #2 registers: 24.
(XEN) testing the IO APIC.......................
(XEN) 
(XEN) IO APIC #2......
(XEN) .... register #00: 02000000
(XEN) .......    : physical APIC id: 02
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178003
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0003
(XEN) An unexpected IO-APIC was found. If this kernel release is less than
(XEN) three months old please report this to linux-smp@vger.kernel.org
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:   
(XEN)  00 000 00  1    0    0   0   0    0    0    00
(XEN)  01 001 01  0    0    0   0   0    1    1    49
(XEN)  02 001 01  0    0    0   0   0    1    1    41
(XEN)  03 001 01  0    0    0   0   0    1    1    51
(XEN)  04 001 01  0    0    0   0   0    1    1    59
(XEN)  05 001 01  0    0    0   0   0    1    1    61
(XEN)  06 001 01  0    0    0   0   0    1    1    69
(XEN)  07 001 01  0    0    0   0   0    1    1    71
(XEN)  08 001 01  0    0    0   0   0    1    1    79
(XEN)  09 001 01  0    0    0   0   0    1    1    81
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 001 01  0    0    0   0   0    1    1    89
(XEN)  0d 001 01  0    0    0   0   0    1    1    91
(XEN)  0e 001 01  0    0    0   0   0    1    1    99
(XEN)  0f 001 01  0    0    0   0   0    1    1    A1
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 001 01  1    1    0   1   0    1    1    A9
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 001 01  1    1    0   1   0    1    1    B1
(XEN) IRQ to pin mappings:
(XEN) IRQ0 -> 0:2
(XEN) IRQ1 -> 0:1
(XEN) IRQ3 -> 0:3
(XEN) IRQ4 -> 0:4
(XEN) IRQ5 -> 0:5
(XEN) IRQ6 -> 0:6
(XEN) IRQ7 -> 0:7
(XEN) IRQ8 -> 0:8
(XEN) IRQ9 -> 0:9
(XEN) IRQ12 -> 0:12
(XEN) IRQ13 -> 0:13
(XEN) IRQ14 -> 0:14
(XEN) IRQ15 -> 0:15
(XEN) IRQ17 -> 0:17
(XEN) IRQ23 -> 0:23
(XEN) .................................... done.
(XEN) Using local APIC timer interrupts.
(XEN) Calibrating APIC timer for CPU0...
(XEN) ..... CPU speed is 1852.1029 MHz.
(XEN) ..... Bus speed is 336.7459 MHz.
(XEN) ..... bus_scale = 0x000158E5
(XEN) ACT: Initialising Accurate timers
(XEN) Time init:
(XEN) .... System Time: 12132070ns
(XEN) .... cpu_freq:    00000000:6E6456A4
(XEN) .... scale:       00000001:14728F91
(XEN) .... Wall Clock:  1081185749s 0us
(XEN) Start schedulers
(XEN) Testing NMI watchdog --- CPU#0 okay. 
(XEN) PCI: PCI BIOS revision 2.10 entry at 0xfb8d0, last bus=1
(XEN) PCI: Using configuration type 1
(XEN) PCI: Probing PCI hardware
(XEN) PCI: Probing PCI hardware (bus 00)
(XEN) PCI: Using IRQ router VIA [1106/3177] at 00:11.0
(XEN) PCI->APIC IRQ transform: (B0,I9,P0) -> 17
(XEN) PCI->APIC IRQ transform: (B0,I18,P0) -> 23
(XEN) 3c59x: Donald Becker and others. www.scyld.com/network/vortex.html
(XEN) 00:09.0: 3Com PCI 3c595 Vortex 100baseTx at 0xd000. Vers LK1.1.16
(XEN) 00:09.0: Overriding PCI latency timer (CFLT) setting of 32, new value is 248.
(XEN) Uniform Multi-Platform E-IDE driver Revision: 6.31
(XEN) ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
(XEN) VP_IDE: IDE controller on PCI bus 00 dev 89
(XEN) VP_IDE: detected chipset, but driver not compiled in!
(XEN) VP_IDE: chipset revision 6
(XEN) VP_IDE: not 100% native mode: will probe irqs later
(XEN)     ide0: BM-DMA at 0xe000-0xe007, BIOS settings: hda:DMA, hdb:DMA
(XEN)     ide1: BM-DMA at 0xe008-0xe00f, BIOS settings: hdc:pio, hdd:pio
(XEN) hda: ST360021A, ATA DISK drive
(XEN) hdb: TOSHIBA CD-ROM XM-5602B, ATAPI CD/DVD-ROM drive
(XEN) ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
(XEN) hdb: ATAPI 8X CD-ROM drive, 256kB Cache
(XEN) Uniform CD-ROM driver Revision: 3.12
(XEN) hda: 117231408 sectors (60022 MB) w/2048KiB Cache, CHS=7297/255/63 PIO (slow!)
(XEN) SCSI subsystem driver Revision: 1.00
(XEN) Red Hat/Adaptec aacraid driver (1.1.2 Apr  5 2004 14:19:02)
(XEN) Device eth0 opened and ready for use.
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found: 'GUEST_OS=linux,GUEST_VER=2.4,XEN_VER=1.3'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  02800000->02995810
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->03ba0000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0000000->c01c97c4
(XEN)  Init. ramdisk: c01ca000->c01ca000
(XEN)  Phys-Mach map: c01ca000->c01cde80
(XEN)  Page tables:   c01ce000->c01d0000
(XEN)  Start info:    c01d0000->c01d1000
(XEN)  Boot stack:    c01d1000->c01d2000
(XEN)  TOTAL:         c0000000->c0400000
(XEN)  ENTRY ADDRESS: c0000000
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen).
(XEN) Give DOM0 read access to all PCI devices
Linux version 2.4.25-xen (kaf24@scramble.cl.cam.ac.uk) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 Mon Apr 5 13:31:10 BST 2004
On node 0 totalpages: 4000
zone(0): 4000 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: /xenolinux-kenf.gz root=/dev/nfs nfsroot=10.10.10.161:/xen/dom0 rw ip=10.10.10.160::10.10.10.1:255.255.255.0:vhost1:eth0:off console=xencons0 noacpi ignorebiostables
Initializing CPU#0
Xen reported: 1852.069 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 18507.36 BogoMIPS
Memory: 13944k/16000k available (1292k kernel code, 2056k reserved, 246k data, 60k init, 0k highmem)
Dentry cache hash table entries: 2048 (order: 2, 16384 bytes)
Inode cache hash table entries: 1024 (order: 1, 8192 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 4096 (order: 2, 16384 bytes)
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 512K (64 bytes/line)
CPU: AMD Athlon(tm) XP 2500+ stepping 00
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed
Successfully installed virtual firewall/router interface
Starting Xen Balloon driver
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
Partition check:
 hda:<4>keyboard: Timeout - AT keyboard not present?(ed)
keyboard: Timeout - AT keyboard not present?(f4)
 hda1 hda2 hda3
Skipping partition check on cdrom /dev/hdb
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 512 bind 1024)
IP-Config: Complete:
      device=eth0, addr=10.10.10.160, mask=255.255.255.0, gw=10.10.10.1,
     host=vhost1, domain=, nis-domain=(none),
     bootserver=255.255.255.255, rootserver=10.10.10.161, rootpath=
ip_conntrack version 2.1 (125 buckets, 1000 max) - 292 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
Looking up port of RPC 100003/2 on 10.10.10.161
(XEN) *pde = 0027d063
(XEN)  *pte = 00000000
(XEN) CPU:    0
(XEN) EIP:    0808:[<fc531feb>]      
(XEN) EFLAGS: 00211217
(XEN) eax: fffa004e   ebx: 0000d010   ecx: 0000000f   edx: 0000d010
(XEN) esi: fc6b0120   edi: fffa0012   ebp: fc685140   esp: fc503ec0
(XEN) ds: 0810   es: 0810   fs: 0810   gs: 0810   ss: 0810
(XEN) Stack trace from ESP=fc503ec0:
(XEN) 00000051 00000020 007f6846 00000000 0000d018 0000003c 0000d000 fc685000 
(XEN)        00000000 0000e011 00000020 [fc5317f0] fc685000 fc62cac0 00000001 00201016 
(XEN)        00000011 00000001 00201016 00000000 0000d00e 0000d000 fc685140 fc680a20 
(XEN)        00000000 00000011 fc6302c0 [fc5e2974] 00000011 fc685000 fc503f60 fc62a940 
(XEN)        2c2a7cd8 00000000 fc680a20 fc62a940 00000000 fc62a940 00000000 [fc5df800] 
(XEN)        fc62a940 00000000 00001ffc 00000000 fc62a940 00000000 00000000 00000810 
(XEN)        00000810 00000810 00000810 ffffff11 [fc5e865c] 00000808 00201246 c0182000 
(XEN)        c0182000 [fc513455] fc503fb8 00000003 fc6a0040 [fc5e85e0] 00000001 258f0880 
(XEN)        ec569880 c0182000 c0182000 c0182000 00000008 00000821 00000821 00000821 
(XEN)        00000821 00000008 c00abd25 00000819 00201246 c0183fd8 00000821 fc62a940 

****************************************
CPU0 FATAL PAGE FAULT
[error_code=00000002]
Faulting linear address might be fffa0012
Aieee! CPU0 is toast...
****************************************

Reboot in five seconds...

[-- Attachment #3: lspci-vv.log --]
[-- Type: application/octet-stream, Size: 5297 bytes --]

vhost1:/usr/src/xen/ken_fraser# lspci -vv        
00:00.0 Host bridge: VIA Technologies, Inc. VT8377 [KT400 AGP] Host Bridge (rev 80)
        Subsystem: ABIT Computer Corp.: Unknown device 140f
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
        Status: Cap+ 66Mhz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort+ >SERR- <PERR-
        Latency: 8
        Region 0: Memory at d0000000 (32-bit, prefetchable) [size=128M]
        Capabilities: [80] AGP version 3.5
                Status: RQ=32 Iso- ArqSz=0 Cal=2 SBA+ ITACoh- GART64- HTrans- 64bit- FW+ AGP3- Rate=x1,x2,x4
                Command: RQ=1 ArqSz=0 Cal=0 SBA- AGP- GART64- 64bit- FW- Rate=<none>
        Capabilities: [c0] Power Management version 2
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:01.0 PCI bridge: VIA Technologies, Inc. VT8237 PCI Bridge (prog-if 00 [Normal decode])
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B-
        Status: Cap+ 66Mhz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort+ >SERR- <PERR-
        Latency: 0
        Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
        Memory behind bridge: da000000-dbffffff
        Prefetchable memory behind bridge: d8000000-d9ffffff
        BridgeCtl: Parity- SERR- NoISA+ VGA+ MAbort- >Reset- FastB2B-
        Capabilities: [80] Power Management version 2
                Flags: PMEClk- DSI- D1+ D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:09.0 Ethernet controller: 3Com Corporation 3c595 100BaseTX [Vortex]
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
        Status: Cap- 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
        Latency: 248 (750ns min, 2000ns max)
        Interrupt: pin A routed to IRQ 17
        Region 0: I/O ports at d000 [size=32]
        Expansion ROM at <unassigned> [disabled] [size=64K]

00:11.0 ISA bridge: VIA Technologies, Inc. VT8235 ISA Bridge
        Subsystem: ABIT Computer Corp.: Unknown device 140f
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping+ SERR- FastB2B-
        Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
        Latency: 0
        Capabilities: [c0] Power Management version 2
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:11.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT8233/A/C/VT8235 PIPC Bus Master IDE (rev 0
6) (prog-if 8a [Master SecP PriP])
        Subsystem: ABIT Computer Corp.: Unknown device 140f
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
        Status: Cap+ 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
        Latency: 32
        Interrupt: pin A routed to IRQ 20
        Region 4: I/O ports at e000 [size=16]
        Capabilities: [c0] Power Management version 2
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:12.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 74)
        Subsystem: ABIT Computer Corp.: Unknown device 140f
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
        Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
        Latency: 32 (750ns min, 2000ns max), Cache Line Size: 0x08 (32 bytes)
        Interrupt: pin A routed to IRQ 23
        Region 0: I/O ports at e400 [size=256]
        Region 1: Memory at dd001000 (32-bit, non-prefetchable) [size=256]
        Capabilities: [40] Power Management version 2
                Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
                Status: D0 PME-Enable- DSel=0 DScale=0 PME-

01:00.0 VGA compatible controller: nVidia Corporation NV5 [RIVA TNT2/TNT2 Pro] (rev 15) (prog-if 00 [VGA])
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
        Status: Cap+ 66Mhz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
        Latency: 32 (1250ns min, 250ns max)
        Interrupt: pin A routed to IRQ 16
        Region 0: Memory at da000000 (32-bit, non-prefetchable) [size=16M]
        Region 1: Memory at d8000000 (32-bit, prefetchable) [size=32M]
        Expansion ROM at <unassigned> [disabled] [size=64K]
        Capabilities: [60] Power Management version 1
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [44] AGP version 2.0
                Status: RQ=32 Iso- ArqSz=0 Cal=0 SBA+ ITACoh- GART64- HTrans- 64bit- FW- AGP3- Rate=x1,x2,x4
                Command: RQ=1 ArqSz=0 Cal=0 SBA- AGP- GART64- 64bit- FW- Rate=<none>

[-- Attachment #4: 2.6.4-highmem4g.boot.log --]
[-- Type: application/octet-stream, Size: 10736 bytes --]


Linux version 2.6.4-tbc-srv (root@vhost1) (gcc version 3.2.3 (Debian)) #1 SMP Sun Apr 4 14:54:58 CDT 2004
BIOS-provided physical RAM map:                                                                          
 BIOS-e820: 0000000000000000 - 000000000009f800 (usable)
 BIOS-e820: 000000000009f800 - 00000000000a0000 (reserved)
 BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
 BIOS-e820: 0000000000100000 - 000000003fef0000 (usable)  
 BIOS-e820: 000000003fef0000 - 000000003fef3000 (ACPI NVS)
 BIOS-e820: 000000003fef3000 - 000000003ff00000 (ACPI data)
 BIOS-e820: 00000000fec00000 - 00000000fec01000 (reserved) 
 BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
 BIOS-e820: 00000000ffff0000 - 0000000100000000 (reserved)
126MB HIGHMEM available.                                  
896MB LOWMEM available. 
found SMP MP-table at 000f60c0
On node 0 totalpages: 261872  
  DMA zone: 4096 pages, LIFO batch:1
  Normal zone: 225280 pages, LIFO batch:16
  HighMem zone: 32496 pages, LIFO batch:7 
DMI 2.2 present.                         
ACPI: RSDP (v000 KT600                                     ) @ 0x000f7ac0
ACPI: RSDT (v001 KT600  AWRDACPI 0x42302e31 AWRD 0x00000000) @ 0x3fef3000
ACPI: FADT (v001 KT600  AWRDACPI 0x42302e31 AWRD 0x00000000) @ 0x3fef3040
ACPI: MADT (v001 KT600  AWRDACPI 0x42302e31 AWRD 0x00000000) @ 0x3fef7a00
ACPI: DSDT (v001 KT600  AWRDACPI 0x00001000 MSFT 0x0100000e) @ 0x00000000
ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)                       
Processor #0 6:10 APIC version 16                 
ACPI: LAPIC_NMI (acpi_id[0x00] high edge lint[0x1])
ACPI: IOAPIC (id[0x02] address[0xfec00000] global_irq_base[0x0])
IOAPIC[0]: Assigned apic_id 2                                   
IOAPIC[0]: apic_id 2, version 3, address 0xfec00000, IRQ 0-23
ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)     
ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 dfl dfl)
Enabling APIC mode:  Flat.  Using 1 I/O APICs           
Using ACPI (MADT) for SMP configuration information
Built 1 zonelists                                  
Kernel command line: root=/dev/hda3 ro console=ttyS0,115200,8n1 devfs=nomount
Initializing CPU#0                                                           
PID hash table entries: 4096 (order 12: 32768 bytes)
Detected 1852.193 MHz processor.                    
Using tsc for high-res timesource
Console: colour VGA+ 80x25       
Memory: 1031284k/1047488k available (3060k kernel code, 15308k reserved, 1136k data, 204k init, 129984k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.                                    
Calibrating delay loop... 3645.44 BogoMIPS                                  
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)  
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)    
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 512K (64 bytes/line)                              
Intel machine check architecture supported.
Intel machine check reporting enabled on CPU#0.
Enabling fast FPU save and restore... done.    
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... OK.                    
POSIX conformance testing by UNIFIX
CPU0: AMD Athlon(tm) XP 2500+ stepping 00
per-CPU timeslice cutoff: 1462.37 usecs. 
task migration cache decay timeout: 2 msecs.
enabled ExtINT on CPU#0                     
ESR value before enabling vector: 00000000
ESR value after enabling vector: 00000000 
Total of 1 processors activated (3645.44 BogoMIPS).
ENABLING IO-APIC IRQs                              
..TIMER: vector=0x31 pin1=2 pin2=-1
Using local APIC timer interrupts. 
calibrating APIC timer ...        
..... CPU clock speed is 1851.0764 MHz.
..... host bus clock speed is 336.0684 MHz.
Brought up 1 CPUs                          
NET: Registered protocol family 16
PCI: PCI BIOS revision 2.10 entry at 0xfb8d0, last bus=1
PCI: Using configuration type 1                         
mtrr: v2.0 (20020519)          
ACPI: Subsystem revision 20040220
ACPI: Interpreter enabled        
ACPI: Using IOAPIC for interrupt routing
ACPI: PCI Root Bridge [PCI0] (00:00)    
PCI: Probing PCI hardware (bus 00)  
ACPI: PCI Interrupt Link [LNKA] (IRQs 3 4 6 7 10 *11 12)
ACPI: PCI Interrupt Link [LNKB] (IRQs 3 4 6 7 *10 11 12)
ACPI: PCI Interrupt Link [LNKC] (IRQs 3 4 6 7 10 11 12) 
ACPI: PCI Interrupt Link [LNKD] (IRQs 3 4 6 7 10 11 12)
ACPI: PCI Interrupt Link [LNKE] (IRQs 3 4 6 7 10 11 12)
ACPI: PCI Interrupt Link [LNKF] (IRQs 3 4 6 7 10 11 12)
ACPI: PCI Interrupt Link [LNK0] (IRQs 3 4 6 7 10 11 12)
ACPI: PCI Interrupt Link [LNK1] (IRQs 3 4 6 7 10 11 12)
ACPI: PCI Interrupt Link [ALKA] (IRQs 20)              
ACPI: PCI Interrupt Link [ALKB] (IRQs 21)
ACPI: PCI Interrupt Link [ALKC] (IRQs 22)
ACPI: PCI Interrupt Link [ALKD] (IRQs 23)
ACPI: Power Resource [PFAN] (off)        
Linux Plug and Play Support v0.97 (c) Adam Belay
SCSI subsystem initialized                      
_CRS returns NULL! Using IRQ 21 fordevice (PCI Interrupt Link [ALKB]).
ACPI: PCI Interrupt Link [ALKB] enabled at IRQ 21                     
_CRS returns NULL! Using IRQ 20 fordevice (PCI Interrupt Link [ALKA]).
ACPI: PCI Interrupt Link [ALKA] enabled at IRQ 20                     
_CRS returns NULL! Using IRQ 22 fordevice (PCI Interrupt Link [ALKC]).
ACPI: PCI Interrupt Link [ALKC] enabled at IRQ 22                     
_CRS returns NULL! Using IRQ 23 fordevice (PCI Interrupt Link [ALKD]).
ACPI: PCI Interrupt Link [ALKD] enabled at IRQ 23                     
testing the IO APIC.......................       
.................................... done.
PCI: Using ACPI for IRQ routing           
PCI: if you experience problems, try using option 'pci=noacpi' or even 'acpi=off'
Machine check exception polling timer started.                                   
Total HugeTLB memory allocated, 0             
ikconfig 0.7 with /proc/config*  
highmem bounce pool size: 64 pages
VFS: Disk quotas dquot_6.5.1      
devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x0                              
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
udf: registering filesystem                             
Initializing Cryptographic API
ACPI: Power Button (FF) [PWRF]
ACPI: Sleep Button (CM) [SLPB]
ACPI: Fan [FAN] (off)         
ACPI: Processor [CPU0] (supports C1 C2)
ACPI: Thermal Zone [THRM] (44 C)       
Real Time Clock Driver v1.12    
Serial: 8250/16550 driver $Revision: 1.90 $ 8 ports, IRQ sharing enabled
ÿttyS0 at I/O 0x3f8 (irq = 4) is a 16550A                               
Using anticipatory io scheduler          
floppy0: no floppy controllers found
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)                                         
nbd: registered device at major 43
3c59x: Donald Becker and others. www.scyld.com/network/vortex.html
0000:00:09.0: 3Com PCI 3c595 Vortex 100baseTx at 0xd000. Vers LK1.1.19
0000:00:09.0: Overriding PCI latency timer (CFLT) setting of 32, new value is 248.
pcnet32.c:v1.28 02.20.2004 tsbogend@alpha.franken.de                              
e100: Intel(R) PRO/100 Network Driver, 3.0.16       
e100: Copyright(c) 1999-2004 Intel Corporation
ThunderLAN driver v1.15                       
TLAN: 0 devices installed, PCI: 0  EISA: 0
via-rhine.c:v1.10-LK1.1.19-2.5  July-12-2003  Written by Donald Becker
  http://www.scyld.com/network/via-rhine.html                         
eth1: VIA VT6102 Rhine-II at 0xdd001000, 00:50:8d:4f:33:d7, IRQ 23.
eth1: MII PHY found at address 1, status 0x786d advertising 05e1 Link 45e1.
dmfe: Davicom DM9xxx net driver, version 1.36.4 (2002-01-17)               
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2    
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
VP_IDE: IDE controller at PCI slot 0000:00:11.1                            
VP_IDE: chipset revision 6                     
VP_IDE: not 100% native mode: will probe irqs later
VP_IDE: VIA vt8235 (rev 00) IDE UDMA133 controller on pci0000:00:11.1
    ide0: BM-DMA at 0xe000-0xe007, BIOS settings: hda:DMA, hdb:DMA   
    ide1: BM-DMA at 0xe008-0xe00f, BIOS settings: hdc:pio, hdd:pio
hda: ST360021A, ATA DISK drive                                    
hdb: TOSHIBA CD-ROM XM-5602B, ATAPI CD/DVD-ROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14                 
hda: max request size: 128KiB      
hda: 117231408 sectors (60022 MB) w/2048KiB Cache, CHS=65535/16/63, UDMA(100)
 /dev/ide/host0/bus0/target0/lun0: p1 p2 p3                                  
hdb: ATAPI 8X CD-ROM drive, 256kB Cache, DMA
Uniform CD-ROM driver Revision: 3.20        
mice: PS/2 mouse device common for all mice
serio: i8042 AUX port at 0x60,0x64 irq 12  
serio: i8042 KBD port at 0x60,0x64 irq 1 
input: AT Translated Set 2 keyboard on isa0060/serio0
md: linear personality registered as nr 1            
md: raid0 personality registered as nr 2 
md: raid1 personality registered as nr 3
md: raid5 personality registered as nr 4
raid5: measuring checksumming speed     
   8regs     :  2480.000 MB/sec    
   8regs_prefetch:  2540.000 MB/sec
   32regs    :  2000.000 MB/sec    
   32regs_prefetch:  1796.000 MB/sec
   pIII_sse  :  4920.000 MB/sec     
   pII_mmx   :  4932.000 MB/sec
   p5_mmx    :  6596.000 MB/sec
raid5: using function: pIII_sse (4920.000 MB/sec)
md: md driver 0.90.0 MAX_MD_DEVS=256, MD_SB_DISKS=27
device-mapper: 4.0.0-ioctl (2003-06-04) initialised: dm@uk.sistina.com
oprofile: using NMI interrupt.                                        
NET: Registered protocol family 2
IP: routing cache hash table of 8192 buckets, 64Kbytes
TCP: Hash tables configured (established 262144 bind 65536)
ip_conntrack version 2.1 (8183 buckets, 65464 max) - 300 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team                                
ipt_recent v0.3.1: Stephen Frost <sfrost@snowman.net>.  http://snowman.net/projects/ipt_recent/
arp_tables: (C) 2002 David S. Miller                                                           
NET: Registered protocol family 1   
NET: Registered protocol family 17
BIOS EDD facility v0.12 2004-Jan-26, 1 devices found
Please report your BIOS at http://linux.dell.com/edd/results.html
ACPI: (supports S0 S1 S3 S4 S5)                                  
md: Autodetecting RAID arrays. 
md: autorun ...               
md: ... autorun DONE.
kjournald starting.  Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.      
Freeing unused kernel memory: 204k freed     
INIT: version 2.85 booting              

^ permalink raw reply	[relevance 3%]

* Assertion '__task_on_runqueue(prev)' failed, line 458, file schedule.c
@ 2004-05-31 20:11  3% Kip Macy
  0 siblings, 0 replies; 200+ results
From: Kip Macy @ 2004-05-31 20:11 UTC (permalink / raw)
  To: Keir.Fraser; +Cc: xen-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2795 bytes --]

I'm using stock gcc3.3.2 as included with the Fedora Core 2 pre-release.
Everything works fine for me with a build from May 15th.  I'm compiling
with nodev and debug enabled.



Xen reported: 1603.664 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 3348.88 BogoMIPS
Memory: 256148k/262144k available (1698k kernel code, 5996k reserved,
357k data, 264k init, 0k highmem)
Dentry cache hash table entries: 32768 (order: 6, 262144 bytes)
Inode cache hash table entries: 16384 (order: 5, 131072 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 16384 (order: 4, 65536 bytes)
Page-cache hash table entries: 65536 (order: 6, 262144 bytes)
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 1024K (64 bytes/line)
CPU: AMD Opteron(tm) Processor 242 stepping 01
POSIX conformance testing by UNIFIX
PCI: Probing PCI hardware
PCI: Probing PCI hardware (bus 00)
PCI: Probing PCI hardware (bus 01)
PCI: Probing PCI hardware (bus 02)
PCI: Probing PCI hardware (bus 03)
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed
Successfully installed virtual firewall/router interface
Starting Xen Balloon driver
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
keyboard: Timeout - AT keyboard not present?(ed)
keyboard: Timeout - AT keyboard not present?(f4)
Floppy drive(s): fd0 is 1.44M
(XEN) Assertion '__task_on_runqueue(prev)' failed, line 458, file
schedule.cCPU:    0
(XEN) EIP:    0808:[<fc516410>]
(XEN) EFLAGS: 00211046
(XEN) eax: 00000000   ebx: c19a7ccb   ecx: 0000004b   edx: 0000004c
(XEN) esi: 00000001   edi: fc534108   ebp: fc590d40   esp: fc503f38
(XEN) ds: 0810   es: 0810   fs: 0810   gs: 0810   ss: 0810
(XEN) Stack trace from ESP=fc503f38:
(XEN) fc530d00 fc534113 000001ca fc534108 00000000 c0202000 c0203fbc 00000000
(XEN)        00000000 00000000 00000000 00000000 fc596000 fc590db8 c00b50a7 00000000
(XEN)        00000000 03f6002c 00201292 fc590d40 00000000 00000008 c0202000 [fc515f55]
(XEN)        fc590d40 c0203f40 c1366000 fc590d40 c0202000 fc590d40 c0202000 [fc521d75]
(XEN)        00000001 52dab700 bfa18180 c0202000 00000008 c0202000 00000008 00000821
(XEN)        00000821 00000821 00000821 00000008 c00b3178 00000819 00201246 c0203fd8
(XEN)        00000821 fc590d40
(XEN) Call Trace from ESP=fc503f38: [<fc515f55>] [<fc521d75>]


This corresponds to
ret_from_hypervisor_call
do_sched_op
__enter_scheduler

Any suggestions as to what I'm doing wrong? I'm using the exact same
config that worked previously.

Thanks.


					-Kip

[-- Attachment #2: Type: TEXT/PLAIN, Size: 17265 bytes --]

#
# Automatically generated by make menuconfig: don't edit
#
CONFIG_XEN=y
CONFIG_X86=y
CONFIG_ISA=y
# CONFIG_SBUS is not set
CONFIG_UID16=y

#
# Xen
#
CONFIG_XEN_PRIVILEGED_GUEST=y
CONFIG_XEN_NEWIO=y
CONFIG_XEN_PHYSDEV_ACCESS=y
CONFIG_NO_IDLE_HZ=y

#
# Code maturity level options
#
# CONFIG_EXPERIMENTAL is not set

#
# Loadable module support
#
CONFIG_MODULES=y
CONFIG_MODVERSIONS=y
CONFIG_KMOD=y

#
# Processor type and features
#
# CONFIG_M686 is not set
# CONFIG_MPENTIUMIII is not set
# CONFIG_MPENTIUM4 is not set
CONFIG_MK7=y
# CONFIG_MK8 is not set
# CONFIG_MVIAC3_2 is not set
CONFIG_X86_WP_WORKS_OK=y
CONFIG_X86_INVLPG=y
CONFIG_X86_CMPXCHG=y
CONFIG_X86_XADD=y
CONFIG_X86_BSWAP=y
CONFIG_X86_POPAD_OK=y
# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_X86_GOOD_APIC=y
CONFIG_X86_PGE=y
CONFIG_X86_USE_PPRO_CHECKSUM=y
CONFIG_X86_TSC=y
CONFIG_X86_L1_CACHE_SHIFT=6
CONFIG_X86_USE_3DNOW=y
CONFIG_NOHIGHMEM=y
# CONFIG_HIGHMEM4G is not set
CONFIG_FORCE_MAX_ZONEORDER=12

#
# General setup
#
CONFIG_NET=y
CONFIG_PCI=y
CONFIG_PCI_NAMES=y
# CONFIG_HOTPLUG is not set
# CONFIG_PCMCIA is not set
# CONFIG_HOTPLUG_PCI is not set
CONFIG_SYSVIPC=y
# CONFIG_BSD_PROCESS_ACCT is not set
CONFIG_SYSCTL=y
CONFIG_KCORE_ELF=y
# CONFIG_KCORE_AOUT is not set
CONFIG_BINFMT_AOUT=y
CONFIG_BINFMT_ELF=y
# CONFIG_BINFMT_MISC is not set
# CONFIG_OOM_KILLER is not set

#
# Memory Technology Devices (MTD)
#
# CONFIG_MTD is not set

#
# Parallel port support
#
# CONFIG_PARPORT is not set

#
# Plug and Play configuration
#
# CONFIG_PNP is not set
# CONFIG_ISAPNP is not set

#
# Block devices
#
CONFIG_BLK_DEV_FD=y
# CONFIG_BLK_DEV_XD is not set
# CONFIG_PARIDE is not set
# CONFIG_BLK_CPQ_DA is not set
# CONFIG_BLK_CPQ_CISS_DA is not set
# CONFIG_CISS_SCSI_TAPE is not set
# CONFIG_CISS_MONITOR_THREAD is not set
# CONFIG_BLK_DEV_DAC960 is not set
# CONFIG_BLK_DEV_UMEM is not set
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_NBD=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=4096
CONFIG_BLK_DEV_INITRD=y
# CONFIG_BLK_STATS is not set

#
# Multi-device support (RAID and LVM)
#
# CONFIG_MD is not set
# CONFIG_BLK_DEV_MD is not set
# CONFIG_MD_LINEAR is not set
# CONFIG_MD_RAID0 is not set
# CONFIG_MD_RAID1 is not set
# CONFIG_MD_RAID5 is not set
# CONFIG_MD_MULTIPATH is not set
# CONFIG_BLK_DEV_LVM is not set

#
# Networking options
#
CONFIG_PACKET=y
CONFIG_PACKET_MMAP=y
# CONFIG_NETLINK_DEV is not set
CONFIG_NETFILTER=y
# CONFIG_NETFILTER_DEBUG is not set
CONFIG_FILTER=y
CONFIG_UNIX=y
CONFIG_INET=y
# CONFIG_IP_MULTICAST is not set
# CONFIG_IP_ADVANCED_ROUTER is not set
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
# CONFIG_IP_PNP_BOOTP is not set
# CONFIG_IP_PNP_RARP is not set
# CONFIG_NET_IPIP is not set
# CONFIG_NET_IPGRE is not set
# CONFIG_INET_ECN is not set
# CONFIG_SYN_COOKIES is not set

#
#   IP: Netfilter Configuration
#
CONFIG_IP_NF_CONNTRACK=y
CONFIG_IP_NF_FTP=y
# CONFIG_IP_NF_AMANDA is not set
CONFIG_IP_NF_TFTP=y
CONFIG_IP_NF_IRC=y
CONFIG_IP_NF_IPTABLES=y
# CONFIG_IP_NF_MATCH_LIMIT is not set
# CONFIG_IP_NF_MATCH_MAC is not set
# CONFIG_IP_NF_MATCH_PKTTYPE is not set
# CONFIG_IP_NF_MATCH_MARK is not set
# CONFIG_IP_NF_MATCH_MULTIPORT is not set
# CONFIG_IP_NF_MATCH_TOS is not set
# CONFIG_IP_NF_MATCH_RECENT is not set
# CONFIG_IP_NF_MATCH_ECN is not set
# CONFIG_IP_NF_MATCH_DSCP is not set
# CONFIG_IP_NF_MATCH_AH_ESP is not set
# CONFIG_IP_NF_MATCH_LENGTH is not set
# CONFIG_IP_NF_MATCH_TTL is not set
# CONFIG_IP_NF_MATCH_TCPMSS is not set
# CONFIG_IP_NF_MATCH_HELPER is not set
CONFIG_IP_NF_MATCH_STATE=y
CONFIG_IP_NF_MATCH_CONNTRACK=y
CONFIG_IP_NF_FILTER=y
CONFIG_IP_NF_TARGET_REJECT=y
CONFIG_IP_NF_NAT=y
CONFIG_IP_NF_NAT_NEEDED=y
CONFIG_IP_NF_TARGET_MASQUERADE=y
CONFIG_IP_NF_TARGET_REDIRECT=y
# CONFIG_IP_NF_NAT_LOCAL is not set
CONFIG_IP_NF_NAT_IRC=y
CONFIG_IP_NF_NAT_FTP=y
CONFIG_IP_NF_NAT_TFTP=y
# CONFIG_IP_NF_MANGLE is not set
CONFIG_IP_NF_TARGET_LOG=y
CONFIG_IP_NF_TARGET_ULOG=y
# CONFIG_IP_NF_TARGET_TCPMSS is not set
# CONFIG_IP_NF_ARPTABLES is not set

#
#   IP: Virtual Server Configuration
#
# CONFIG_IP_VS is not set
# CONFIG_VLAN_8021Q is not set
# CONFIG_IPX is not set
# CONFIG_ATALK is not set

#
# Appletalk devices
#
# CONFIG_DEV_APPLETALK is not set
# CONFIG_DECNET is not set
CONFIG_BRIDGE=y

#
# QoS and/or fair queueing
#
# CONFIG_NET_SCHED is not set

#
# Network testing
#
# CONFIG_NET_PKTGEN is not set

#
# ATA/IDE/MFM/RLL support
#
CONFIG_IDE=y

#
# IDE, ATA and ATAPI Block devices
#
CONFIG_BLK_DEV_IDE=y
# CONFIG_BLK_DEV_HD_IDE is not set
# CONFIG_BLK_DEV_HD is not set
CONFIG_BLK_DEV_IDEDISK=y
CONFIG_IDEDISK_MULTI_MODE=y
CONFIG_IDEDISK_STROKE=y
# CONFIG_BLK_DEV_IDECS is not set
CONFIG_BLK_DEV_IDECD=y
# CONFIG_BLK_DEV_IDETAPE is not set
# CONFIG_BLK_DEV_IDEFLOPPY is not set
# CONFIG_BLK_DEV_IDESCSI is not set
# CONFIG_IDE_TASK_IOCTL is not set
# CONFIG_BLK_DEV_CMD640 is not set
# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
# CONFIG_BLK_DEV_ISAPNP is not set
CONFIG_BLK_DEV_IDEPCI=y
CONFIG_BLK_DEV_GENERIC=y
CONFIG_IDEPCI_SHARE_IRQ=y
CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
CONFIG_IDEDMA_PCI_AUTO=y
# CONFIG_IDEDMA_ONLYDISK is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_PCI_WIP is not set
# CONFIG_BLK_DEV_ADMA100 is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_BLK_DEV_ALI15X3 is not set
# CONFIG_WDC_ALI15X3 is not set
CONFIG_BLK_DEV_AMD74XX=y
CONFIG_AMD74XX_OVERRIDE=y
# CONFIG_BLK_DEV_ATIIXP is not set
# CONFIG_BLK_DEV_CMD64X is not set
# CONFIG_BLK_DEV_TRIFLEX is not set
# CONFIG_BLK_DEV_CY82C693 is not set
# CONFIG_BLK_DEV_CS5530 is not set
# CONFIG_BLK_DEV_HPT34X is not set
# CONFIG_HPT34X_AUTODMA is not set
# CONFIG_BLK_DEV_HPT366 is not set
# CONFIG_BLK_DEV_PIIX is not set
# CONFIG_BLK_DEV_NS87415 is not set
# CONFIG_BLK_DEV_OPTI621 is not set
# CONFIG_BLK_DEV_PDC202XX_OLD is not set
# CONFIG_PDC202XX_BURST is not set
# CONFIG_BLK_DEV_PDC202XX_NEW is not set
# CONFIG_BLK_DEV_RZ1000 is not set
# CONFIG_BLK_DEV_SC1200 is not set
# CONFIG_BLK_DEV_SVWKS is not set
# CONFIG_BLK_DEV_SIIMAGE is not set
# CONFIG_BLK_DEV_SIS5513 is not set
# CONFIG_BLK_DEV_SLC90E66 is not set
# CONFIG_BLK_DEV_TRM290 is not set
# CONFIG_BLK_DEV_VIA82CXXX is not set
# CONFIG_IDE_CHIPSETS is not set
CONFIG_IDEDMA_AUTO=y
# CONFIG_IDEDMA_IVB is not set
# CONFIG_DMA_NONPCI is not set
# CONFIG_BLK_DEV_ATARAID is not set
# CONFIG_BLK_DEV_ATARAID_PDC is not set
# CONFIG_BLK_DEV_ATARAID_HPT is not set
# CONFIG_BLK_DEV_ATARAID_MEDLEY is not set
# CONFIG_BLK_DEV_ATARAID_SII is not set

#
# SCSI support
#
CONFIG_SCSI=y
CONFIG_BLK_DEV_SD=y
CONFIG_SD_EXTRA_DEVS=40
CONFIG_CHR_DEV_ST=y
# CONFIG_CHR_DEV_OSST is not set
# CONFIG_BLK_DEV_SR is not set
CONFIG_CHR_DEV_SG=y
# CONFIG_SCSI_DEBUG_QUEUES is not set
CONFIG_SCSI_MULTI_LUN=y
# CONFIG_SCSI_CONSTANTS is not set
# CONFIG_SCSI_LOGGING is not set

#
# SCSI low-level drivers
#
# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
# CONFIG_SCSI_7000FASST is not set
# CONFIG_SCSI_ACARD is not set
# CONFIG_SCSI_AHA152X is not set
# CONFIG_SCSI_AHA1542 is not set
# CONFIG_SCSI_AHA1740 is not set
# CONFIG_SCSI_AIC7XXX is not set
# CONFIG_SCSI_AIC79XX is not set
# CONFIG_SCSI_AIC7XXX_OLD is not set
# CONFIG_SCSI_DPT_I2O is not set
# CONFIG_SCSI_ADVANSYS is not set
# CONFIG_SCSI_IN2000 is not set
# CONFIG_SCSI_AM53C974 is not set
# CONFIG_SCSI_MEGARAID is not set
# CONFIG_SCSI_MEGARAID2 is not set
# CONFIG_SCSI_BUSLOGIC is not set
# CONFIG_SCSI_CPQFCTS is not set
# CONFIG_SCSI_DMX3191D is not set
# CONFIG_SCSI_DTC3280 is not set
# CONFIG_SCSI_EATA is not set
# CONFIG_SCSI_EATA_DMA is not set
# CONFIG_SCSI_EATA_PIO is not set
# CONFIG_SCSI_FUTURE_DOMAIN is not set
# CONFIG_SCSI_GDTH is not set
# CONFIG_SCSI_GENERIC_NCR5380 is not set
# CONFIG_SCSI_IPS is not set
# CONFIG_SCSI_INITIO is not set
# CONFIG_SCSI_INIA100 is not set
# CONFIG_SCSI_NCR53C406A is not set
# CONFIG_SCSI_NCR53C7xx is not set
# CONFIG_SCSI_SYM53C8XX_2 is not set
# CONFIG_SCSI_NCR53C8XX is not set
# CONFIG_SCSI_SYM53C8XX is not set
# CONFIG_SCSI_PAS16 is not set
# CONFIG_SCSI_PCI2000 is not set
# CONFIG_SCSI_PCI2220I is not set
# CONFIG_SCSI_PSI240I is not set
# CONFIG_SCSI_QLOGIC_FAS is not set
# CONFIG_SCSI_QLOGIC_ISP is not set
# CONFIG_SCSI_QLOGIC_FC is not set
# CONFIG_SCSI_QLOGIC_1280 is not set
# CONFIG_SCSI_SEAGATE is not set
# CONFIG_SCSI_SIM710 is not set
# CONFIG_SCSI_SYM53C416 is not set
# CONFIG_SCSI_DC390T is not set
# CONFIG_SCSI_T128 is not set
# CONFIG_SCSI_U14_34F is not set
# CONFIG_SCSI_ULTRASTOR is not set
# CONFIG_SCSI_NSP32 is not set

#
# Fusion MPT device support
#
# CONFIG_FUSION is not set
# CONFIG_FUSION_BOOT is not set
# CONFIG_FUSION_ISENSE is not set
# CONFIG_FUSION_CTL is not set
# CONFIG_FUSION_LAN is not set

#
# I2O device support
#
# CONFIG_I2O is not set
# CONFIG_I2O_PCI is not set
# CONFIG_I2O_BLOCK is not set
# CONFIG_I2O_LAN is not set
# CONFIG_I2O_SCSI is not set
# CONFIG_I2O_PROC is not set

#
# Network device support
#
CONFIG_NETDEVICES=y

#
# ARCnet devices
#
# CONFIG_ARCNET is not set
# CONFIG_DUMMY is not set
# CONFIG_BONDING is not set
# CONFIG_EQUALIZER is not set
# CONFIG_TUN is not set

#
# Ethernet (10 or 100Mbit)
#
# CONFIG_NET_ETHERNET is not set

#
# Ethernet (1000 Mbit)
#
# CONFIG_ACENIC is not set
# CONFIG_DL2K is not set
CONFIG_E1000=y
CONFIG_E1000_NAPI=y
# CONFIG_MYRI_SBUS is not set
# CONFIG_NS83820 is not set
# CONFIG_HAMACHI is not set
# CONFIG_YELLOWFIN is not set
# CONFIG_R8169 is not set
# CONFIG_SK98LIN is not set
CONFIG_TIGON3=y
# CONFIG_FDDI is not set
# CONFIG_PLIP is not set
# CONFIG_PPP is not set
# CONFIG_SLIP is not set

#
# Wireless LAN (non-hamradio)
#
# CONFIG_NET_RADIO is not set

#
# Token Ring devices
#
# CONFIG_TR is not set
# CONFIG_NET_FC is not set

#
# Wan interfaces
#
# CONFIG_WAN is not set

#
# Amateur Radio support
#
# CONFIG_HAMRADIO is not set

#
# IrDA (infrared) support
#
# CONFIG_IRDA is not set

#
# ISDN subsystem
#
# CONFIG_ISDN is not set

#
# Old CD-ROM drivers (not SCSI, not IDE)
#
# CONFIG_CD_NO_IDESCSI is not set

#
# Input core support
#
# CONFIG_INPUT is not set
# CONFIG_INPUT_KEYBDEV is not set
# CONFIG_INPUT_MOUSEDEV is not set
# CONFIG_INPUT_JOYDEV is not set
# CONFIG_INPUT_EVDEV is not set
# CONFIG_INPUT_UINPUT is not set

#
# Character devices
#
CONFIG_VT=y
CONFIG_VT_CONSOLE=y
# CONFIG_SERIAL is not set
# CONFIG_SERIAL_EXTENDED is not set
# CONFIG_SERIAL_NONSTANDARD is not set
CONFIG_UNIX98_PTYS=y
CONFIG_UNIX98_PTY_COUNT=256

#
# I2C support
#
# CONFIG_I2C is not set

#
# Mice
#
# CONFIG_BUSMOUSE is not set
CONFIG_MOUSE=y
CONFIG_PSMOUSE=y
# CONFIG_82C710_MOUSE is not set
# CONFIG_PC110_PAD is not set
# CONFIG_MK712_MOUSE is not set

#
# Joysticks
#
# CONFIG_INPUT_GAMEPORT is not set
# CONFIG_QIC02_TAPE is not set
# CONFIG_IPMI_HANDLER is not set
# CONFIG_IPMI_PANIC_EVENT is not set
# CONFIG_IPMI_DEVICE_INTERFACE is not set
# CONFIG_IPMI_KCS is not set
# CONFIG_IPMI_WATCHDOG is not set

#
# Watchdog Cards
#
# CONFIG_WATCHDOG is not set
# CONFIG_SCx200 is not set
# CONFIG_SCx200_GPIO is not set
# CONFIG_AMD_RNG is not set
# CONFIG_INTEL_RNG is not set
# CONFIG_HW_RANDOM is not set
# CONFIG_AMD_PM768 is not set
# CONFIG_NVRAM is not set
# CONFIG_RTC is not set
# CONFIG_DTLK is not set
# CONFIG_R3964 is not set
# CONFIG_APPLICOM is not set

#
# Ftape, the floppy tape device driver
#
# CONFIG_FTAPE is not set
# CONFIG_AGP is not set

#
# Direct Rendering Manager (XFree86 DRI support)
#
# CONFIG_DRM is not set
# CONFIG_MWAVE is not set
# CONFIG_OBMOUSE is not set

#
# Multimedia devices
#
# CONFIG_VIDEO_DEV is not set

#
# File systems
#
# CONFIG_QUOTA is not set
# CONFIG_QFMT_V2 is not set
CONFIG_AUTOFS_FS=y
CONFIG_AUTOFS4_FS=y
# CONFIG_REISERFS_FS is not set
# CONFIG_REISERFS_CHECK is not set
# CONFIG_REISERFS_PROC_INFO is not set
# CONFIG_ADFS_FS is not set
# CONFIG_ADFS_FS_RW is not set
# CONFIG_AFFS_FS is not set
# CONFIG_HFS_FS is not set
# CONFIG_HFSPLUS_FS is not set
# CONFIG_BEFS_FS is not set
# CONFIG_BEFS_DEBUG is not set
# CONFIG_BFS_FS is not set
CONFIG_EXT3_FS=y
CONFIG_JBD=y
# CONFIG_JBD_DEBUG is not set
CONFIG_FAT_FS=y
CONFIG_MSDOS_FS=y
CONFIG_UMSDOS_FS=y
CONFIG_VFAT_FS=y
# CONFIG_EFS_FS is not set
# CONFIG_JFFS_FS is not set
# CONFIG_JFFS2_FS is not set
# CONFIG_CRAMFS is not set
CONFIG_TMPFS=y
CONFIG_RAMFS=y
CONFIG_ISO9660_FS=y
CONFIG_JOLIET=y
CONFIG_ZISOFS=y
# CONFIG_JFS_FS is not set
# CONFIG_JFS_DEBUG is not set
# CONFIG_JFS_STATISTICS is not set
# CONFIG_MINIX_FS is not set
# CONFIG_VXFS_FS is not set
# CONFIG_NTFS_FS is not set
# CONFIG_NTFS_RW is not set
# CONFIG_HPFS_FS is not set
CONFIG_PROC_FS=y
# CONFIG_DEVFS_FS is not set
# CONFIG_DEVFS_MOUNT is not set
# CONFIG_DEVFS_DEBUG is not set
CONFIG_DEVPTS_FS=y
# CONFIG_QNX4FS_FS is not set
# CONFIG_QNX4FS_RW is not set
# CONFIG_ROMFS_FS is not set
CONFIG_EXT2_FS=y
# CONFIG_SYSV_FS is not set
# CONFIG_UDF_FS is not set
# CONFIG_UDF_RW is not set
CONFIG_UFS_FS=y
# CONFIG_UFS_FS_WRITE is not set
# CONFIG_XFS_FS is not set
# CONFIG_XFS_QUOTA is not set
# CONFIG_XFS_RT is not set
# CONFIG_XFS_TRACE is not set
# CONFIG_XFS_DEBUG is not set

#
# Network File Systems
#
# CONFIG_CODA_FS is not set
# CONFIG_INTERMEZZO_FS is not set
CONFIG_NFS_FS=y
CONFIG_NFS_V3=y
# CONFIG_NFS_DIRECTIO is not set
CONFIG_ROOT_NFS=y
CONFIG_NFSD=y
CONFIG_NFSD_V3=y
# CONFIG_NFSD_TCP is not set
CONFIG_SUNRPC=y
CONFIG_LOCKD=y
CONFIG_LOCKD_V4=y
# CONFIG_SMB_FS is not set
# CONFIG_NCP_FS is not set
# CONFIG_NCPFS_PACKET_SIGNING is not set
# CONFIG_NCPFS_IOCTL_LOCKING is not set
# CONFIG_NCPFS_STRONG is not set
# CONFIG_NCPFS_NFS_NS is not set
# CONFIG_NCPFS_OS2_NS is not set
# CONFIG_NCPFS_SMALLDOS is not set
# CONFIG_NCPFS_NLS is not set
# CONFIG_NCPFS_EXTRAS is not set
CONFIG_ZISOFS_FS=y

#
# Partition Types
#
CONFIG_PARTITION_ADVANCED=y
# CONFIG_ACORN_PARTITION is not set
# CONFIG_OSF_PARTITION is not set
# CONFIG_AMIGA_PARTITION is not set
# CONFIG_ATARI_PARTITION is not set
# CONFIG_MAC_PARTITION is not set
CONFIG_MSDOS_PARTITION=y
# CONFIG_BSD_DISKLABEL is not set
# CONFIG_MINIX_SUBPARTITION is not set
# CONFIG_SOLARIS_X86_PARTITION is not set
# CONFIG_UNIXWARE_DISKLABEL is not set
# CONFIG_LDM_PARTITION is not set
# CONFIG_SGI_PARTITION is not set
# CONFIG_ULTRIX_PARTITION is not set
# CONFIG_SUN_PARTITION is not set
# CONFIG_EFI_PARTITION is not set
# CONFIG_SMB_NLS is not set
CONFIG_NLS=y

#
# Native Language Support
#
CONFIG_NLS_DEFAULT="iso8559-1"
# CONFIG_NLS_CODEPAGE_437 is not set
# CONFIG_NLS_CODEPAGE_737 is not set
# CONFIG_NLS_CODEPAGE_775 is not set
# CONFIG_NLS_CODEPAGE_850 is not set
# CONFIG_NLS_CODEPAGE_852 is not set
# CONFIG_NLS_CODEPAGE_855 is not set
# CONFIG_NLS_CODEPAGE_857 is not set
# CONFIG_NLS_CODEPAGE_860 is not set
# CONFIG_NLS_CODEPAGE_861 is not set
# CONFIG_NLS_CODEPAGE_862 is not set
# CONFIG_NLS_CODEPAGE_863 is not set
# CONFIG_NLS_CODEPAGE_864 is not set
# CONFIG_NLS_CODEPAGE_865 is not set
# CONFIG_NLS_CODEPAGE_866 is not set
# CONFIG_NLS_CODEPAGE_869 is not set
# CONFIG_NLS_CODEPAGE_936 is not set
# CONFIG_NLS_CODEPAGE_950 is not set
# CONFIG_NLS_CODEPAGE_932 is not set
# CONFIG_NLS_CODEPAGE_949 is not set
# CONFIG_NLS_CODEPAGE_874 is not set
# CONFIG_NLS_ISO8859_8 is not set
# CONFIG_NLS_CODEPAGE_1250 is not set
# CONFIG_NLS_CODEPAGE_1251 is not set
CONFIG_NLS_ISO8859_1=y
# CONFIG_NLS_ISO8859_2 is not set
# CONFIG_NLS_ISO8859_3 is not set
# CONFIG_NLS_ISO8859_4 is not set
# CONFIG_NLS_ISO8859_5 is not set
# CONFIG_NLS_ISO8859_6 is not set
# CONFIG_NLS_ISO8859_7 is not set
# CONFIG_NLS_ISO8859_9 is not set
# CONFIG_NLS_ISO8859_13 is not set
# CONFIG_NLS_ISO8859_14 is not set
# CONFIG_NLS_ISO8859_15 is not set
# CONFIG_NLS_KOI8_R is not set
# CONFIG_NLS_KOI8_U is not set
# CONFIG_NLS_UTF8 is not set

#
# Console drivers
#
CONFIG_XEN_CONSOLE=y
CONFIG_VGA_CONSOLE=y
CONFIG_DUMMY_CONSOLE=y
# CONFIG_VIDEO_SELECT is not set

#
# Sound
#
# CONFIG_SOUND is not set

#
# USB support
#
# CONFIG_USB is not set

#
# Support for USB gadgets
#
# CONFIG_USB_GADGET is not set

#
# Bluetooth support
#
# CONFIG_BLUEZ is not set

#
# Kernel hacking
#
CONFIG_DEBUG_KERNEL=y
# CONFIG_DEBUG_STACKOVERFLOW is not set
# CONFIG_DEBUG_HIGHMEM is not set
# CONFIG_DEBUG_SLAB is not set
# CONFIG_DEBUG_IOVIRT is not set
# CONFIG_MAGIC_SYSRQ is not set
# CONFIG_DEBUG_SPINLOCK is not set
# CONFIG_DEBUG_BUGVERBOSE is not set
CONFIG_KALLSYMS=y
# CONFIG_FRAME_POINTER is not set
CONFIG_LOG_BUF_SHIFT=0

#
# Cryptographic options
#
# CONFIG_CRYPTO is not set

#
# Library routines
#
# CONFIG_CRC32 is not set
CONFIG_ZLIB_INFLATE=y
# CONFIG_ZLIB_DEFLATE is not set

^ permalink raw reply	[relevance 3%]

* Re: Error creating block interface
  @ 2004-06-11 16:34  5%   ` Jody Belka
  0 siblings, 0 replies; 200+ results
From: Jody Belka @ 2004-06-11 16:34 UTC (permalink / raw)
  To: Ian Pratt; +Cc: xen-devel

On Fri, Jun 11, 2004 at 05:07:11PM +0100, Ian Pratt wrote:
> For the next couple of days, you're probably better off using a
> revision before Tuesday e.g. 1.941. 
> "bk clone -r1.941 bk://xen.bkbits.net/xeno-unstable.bk"

Ok, i promise i'll try this out on a kernel built from that
revision, but in the mean time:

After switching to standard paritions for the time being
(i'll get evms - which i used to use before the rebuild
anyway - up and running once i've got all this figured
out), my VM is now starting ok, and i'm getting console
output via TCP. however...

************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.4.26-xen (knew@artemis) (gcc version 3.3.3 (Debian 20040401)) #5 Fri Jun 11 00:15:20 CEST 2004
On node 0 totalpages: 16384                                                                                   
zone(0): 4096 pages.       
zone(1): 12288 pages.
zone(2): 0 pages.    
Kernel command line:   
Initializing CPU#0     
Xen reported: 1300.055 MHz processor.
Calibrating delay loop... 9830.40 BogoMIPS
Memory: 62240k/65536k available (1526k kernel code, 3296k reserved, 335k data, 244k init, 0k highmem)
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)                                        
Inode cache hash table entries: 4096 (order: 3, 32768 bytes) 
Mount cache hash table entries: 512 (order: 0, 4096 bytes)  
Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes) 
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 64K (64 bytes/line)                               
CPU: AMD Duron(tm) processor stepping 01
POSIX conformance testing by UNIFIX     
PCI: Probing PCI hardware          
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket                         
Starting kswapd               
VFS: Disk quotas vdquot_6.5.1
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.                         
Xen virtual console successfully installed
Starting Xen Balloon driver               
pty: 256 Unix98 ptys configured
Serial driver version 5.05c (2001-07-08) with MANY_PORTS SHARE_IRQ SERIAL_PCI enabled
general protection fault: 0000                                                       
CPU:    0                     
EIP:    0819:[<c00e2992>]    Not tainted
EFLAGS: 00010206                        
eax: c10e5ef4   ebx: c02101b8   ecx: c10b6000   edx: 000003f9
esi: c01c6d00   edi: 00000000   ebp: c10e5ef4   esp: c10e5ed8
ds: 0821   es: 0821   ss: 0821                               
Process swapper (pid: 1, stackpage=c10e5000)<1>
Stack: c00e762f c10e5ef4 00000001 79622036 29736574 00000000 000002ac 00005301 
       000003f8 c00cd229 10000040 00000000 c01c6d00 c02192e5 00000056 00000000 
       c0008f71 c01c5560 c02192e5 00000056 c10e5f88 ffffffff c0188788 c00504bd 
Call Trace: [<c00e762f>] [<c00cd229>] [<c0008f71>] [<c00504bd>] [<c0050327>]   
   [<c002155d>] [<c000e506>] [<c0003880>] [<c00c177b>] [<c0003870>]          
	                                                                     
 <0>Kernel panic: Attempted to kill init!
 <0>Rebooting in 1 seconds..             
************ REMOTE CONSOLE EXITED *****************

Any ideas?

Thanks in advance,

-- 
Jody Belka
knew (at) pimb (dot) org


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504

^ permalink raw reply	[relevance 5%]

* Re: Re: almost working
  @ 2004-07-04 14:41  3%   ` Jody Belka
  0 siblings, 0 replies; 200+ results
From: Jody Belka @ 2004-07-04 14:41 UTC (permalink / raw)
  To: Ian Pratt; +Cc: Keir Fraser, xen-devel

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

On Fri, Jul 02, 2004 at 04:21:32PM +0100, Ian Pratt wrote:
> So: you started a domain, halted it, and it correctly
> disappeared. You then issued the same xm create command to
> recreate it and it failed to come up.
> 
> Odd. Any error output from xend or xm?

Having just upgraded to r1056 i'm getting this now myself.
I'm including screenlogs from the xend tracing, and the
operations that caused it. It happens every time, without
fail.

-- 
Jody Belka
knew (at) pimb (dot) org

[-- Attachment #2: screenlog: commands --]
[-- Type: text/plain, Size: 10691 bytes --]

^[]0;root@iris: /home/jmb\aroot@iris:~# sudo reboot\b\b\b\b\b\b\b\b\b\b\b^[[5Preboot\b\b\b\b\b\b^[[4Pls\b\brm screenlog.1\b0\b\b\b\b\b\b\b\b\b\b\b\b\b\bls^[[K\b\bcat screenlog.1\rroot@iris:~# ^[[1@less screenlog.1\b0\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bs^[[K\b\bscreen -L sudo bash\rroot@iris:~# ^[[3Pxend trace_start\b\b\b\b\b\b\b\b\b\b\b^[[7Pstop\b\b\b\b\b\b\b\b\brm trace \b\b\b\b\b\b\b\b\bxm create -f eos -c\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b^[[7Pdestroy 3\b\b\b\b\b\b\b\b\b^[[5Plist\b\b\b\bcreate -f eos -c\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b^[[7Pdestroy 2\b\b\b\b\b\b\b\b\b^[[5Plist\b\b\b\bcreate -f eos -c\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\blist^[[K\b\b\b\bcreate -f eos -c\rroot@iris:~# ^[[7@screen xm create -f eos -c\rroot@iris:~# xm list^[[K\b\b\b\b\b\b\bcd /etc/xen/machines/\rroot@iris:~# xend trace_start &> trace; tail -f trace\rroot@iris:~# ^[[19Pcd /etc/xen/machines/
^[]0;root@iris: /etc/xen/machines\aroot@iris:/etc/xen/machines# xm list
Dom  Name             Mem(MB)  CPU  State  Time(s)
0    Domain-0              55    0  r----     40.3
^[]0;root@iris: /etc/xen/machines\aroot@iris:/etc/xen/machines# xm cre\aate -f xe\b \b\b \be\aos -c
Started domain 1, console on port 9601
************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.4.26-xenU (jmb@iris) (gcc version 2.95.4 20011002 (Debian prerelease)) #7 Sun Jul 4 01:59:27 CEST 2004
\rOn node 0 totalpages: 4096
\rzone(0): 4096 pages.
\rzone(1): 0 pages.
\rzone(2): 0 pages.
\rKernel command line:  ip=:::::eth0:off root=/dev/hda1 ro
\rInitializing CPU#0
\rXen reported: 1300.100 MHz processor.
\rCalibrating delay loop... 1287.78 BogoMIPS
\rMemory: 14524k/16384k available (1059k kernel code, 1860k reserved, 287k data, 44k init, 0k highmem)
\rDentry cache hash table entries: 2048 (order: 2, 16384 bytes)
\rInode cache hash table entries: 1024 (order: 1, 8192 bytes)
\rMount cache hash table entries: 512 (order: 0, 4096 bytes)
\rBuffer cache hash table entries: 1024 (order: 0, 4096 bytes)
\rPage-cache hash table entries: 4096 (order: 2, 16384 bytes)
\rCPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
\rCPU: L2 Cache: 64K (64 bytes/line)
\rCPU: AMD Duron(tm) processor stepping 01
\rPOSIX conformance testing by UNIFIX
\rLinux NET4.0 for Linux 2.4
\rBased upon Swansea University Computer Society NET3.039
\rInitializing RT netlink socket
\rStarting kswapd
\rJournalled Block Device driver loaded
\rEvent-channel device installed.
\rXen virtual console successfully installed as tty
\rStarting Xen Balloon driver
\rpty: 256 Unix98 ptys configured
\rInitialising Xen virtual block device
\rRAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
\rloop: loaded (max 8 devices)
\rInitialising Xen virtual ethernet frontend driver<6>NET4: Linux TCP/IP 1.0 for NET4.0
\rIP Protocols: ICMP, UDP, TCP
\rIP: routing cache hash table of 512 buckets, 4Kbytes
\rTCP: Hash tables configured (established 1024 bind 1024)
\rip_conntrack version 2.1 (128 buckets, 1024 max) - 288 bytes per conntrack
\rip_tables: (C) 2000-2002 Netfilter core team
\ript_recent v0.3.1: Stephen Frost <sfrost@snowman.net>.  http://snowman.net/projects/ipt_recent/
\rarp_tables: (C) 2002 David S. Miller
\rNET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
\rkjournald starting.  Commit interval 5 seconds
\rEXT3-fs: mounted filesystem with ordered data mode.
\rVFS: Mounted root (ext3 filesystem) readonly.
\rFreeing unused kernel memory: 44k freed
\rmodprobe: modprobe: cannot create /var/log/ksymoops/20040704.log Read-only file system
modprobe: modprobe: Can't locate module char-major-4
modprobe: modprobe: cannot create /var/log/ksymoops/20040704.log Read-only file system
\rINIT: version 2.84 booting
Activating swap.
Adding Swap: 16372k swap-space (priority -1)
\rChecking root file system...
fsck 1.27 (8-Mar-2002)
eos-root: clean, 18206/53248 files, 172868/212991 blocks
EXT3 FS 2.4-0.9.19, 19 August 2002 on hd(3,1), internal journal
\rSystem time was Sun Jul  4 14:21:41 UTC 2004.
Setting the System Clock using the Hardware Clock as reference...
modprobe: modprobe: Can't locate module char-major-10-135
hwclock is unable to get I/O port access:  the iopl(3) call failed.
modprobe: modprobe: Can't locate module char-major-10-135
System Clock set. System local time is now Sun Jul  4 14:21:41 UTC 2004.
Calculating module dependencies... done.
Loading modules: 
Checking all file systems...
fsck 1.27 (8-Mar-2002)
eos-dnsdata: clean, 11/4096 files, 1564/16383 blocks
Setting kernel variables.
Mounting local filesystems...
kjournald starting.  Commit interval 5 seconds
\rEXT3 FS 2.4-0.9.19, 19 August 2002 on hd(3,65), internal journal
\rEXT3-fs: mounted filesystem with ordered data mode.
\r/dev/hdb1 on /etc/dns type ext3 (rw)
Cleaning: /etc/network/ifstate.
Setting up IP spoofing protection: rp_filter.
Configuring network interfaces: done.

Setting the System Clock using the Hardware Clock as reference...
modprobe: modprobe: Can't locate module char-major-10-135
hwclock is unable to get I/O port access:  the iopl(3) call failed.
System Clock set. Local time: Sun Jul  4 16:21:42 CEST 2004

Cleaning: /tmp /var/lock /var/run.
Initializing random number generator... done.
\rINIT: Entering runlevel: 2
Starting system log daemon: syslogd.
Starting kernel log daemon: klogd.
Starting OpenBSD Secure Shell server: sshd.
Starting periodic command scheduler: cron.

Debian GNU/Linux 3.0 eos tty1

eos login: root
Password: 
Last login: Sun Jul  4 16:08:36 2004 on tty1
Linux eos 2.4.26-xenU #7 Sun Jul 4 01:59:27 CEST 2004 i686 unknown

Most of the programs included with the Debian GNU/Linux system are
freely redistributable; the exact distribution terms for each program
are described in the individual files in /usr/share/doc/*/copyright

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
eos:~# halt
\a
Broadcast message from root (tty1) (Sun Jul  4 16:23:36 2004):

\rThe system is going down for system halt NOW!\r\rINIT: Sending processes the TERM signal
eos:~# \rINIT: Sending processes the KILL signal
Stopping periodic command scheduler: cron.
Stopping OpenBSD Secure Shell server: sshd.
Saving the System Clock time to the Hardware Clock...
hwclock is unable to get I/O port access:  the iopl(3) call failed.
Hardware Clock updated to Sun Jul  4 16:23:42 CEST 2004.
Stopping kernel log daemon: klogd.
Stopping system log daemon: syslogd.
Sending all processes the TERM signal... done.
Sending all processes the KILL signal... done.
Saving random seed... done.
Unmounting remote filesystems... done.
Deconfiguring network interfaces: done.
Deactivating swap... done.
Unmounting local filesystems... done.
Power down.

************ REMOTE CONSOLE EXITED *****************
^[]0;root@iris: /etc/xen/machines\aroot@iris:/etc/xen/machines# xm list
Dom  Name             Mem(MB)  CPU  State  Time(s)
0    Domain-0              55    0  r----     45.9
^[]0;root@iris: /etc/xen/machines\aroot@iris:/etc/xen/machines# xm list\b\b\b\bcreate -f eos -c
Traceback (most recent call last):
  File "/usr/sbin/xm", line 6, in ?
    main.main(sys.argv)
  File "/usr/lib/python2.2/site-packages/xen/xm/main.py", line 448, in main
    xm.main(args)
  File "/usr/lib/python2.2/site-packages/xen/xm/main.py", line 79, in main
    p.main(args[1:])
  File "/usr/lib/python2.2/site-packages/xen/xm/main.py", line 153, in main
    create.main(args)
  File "/usr/lib/python2.2/site-packages/xen/xm/create.py", line 365, in main
    (d, c) = make_domain(opts, config)
  File "/usr/lib/python2.2/site-packages/xen/xm/create.py", line 334, in make_domain
    dominfo = server.xend_domain_create(config)
  File "/usr/lib/python2.2/site-packages/xen/xend/XendClient.py", line 184, in xend_domain_create
    {'op'      : 'create',
  File "/usr/lib/python2.2/site-packages/xen/xend/XendClient.py", line 128, in xend_call
    return xend_request(url, "POST", data)
  File "/usr/lib/python2.2/site-packages/xen/xend/XendClient.py", line 102, in xend_request
    resp = conn.getresponse()
  File "/usr/lib/python2.2/httplib.py", line 595, in getresponse
    response.begin()
  File "/usr/lib/python2.2/httplib.py", line 119, in begin
    line = self.fp.readline()
KeyboardInterrupt
^[]0;root@iris: /etc/xen/machines\aroot@iris:/etc/xen/machines# xm create -f eos -c\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\blist^[[K
Dom  Name             Mem(MB)  CPU  State  Time(s)
0    Domain-0              55    0  r----     46.7
2    eos - dns             16    0  --p--      0.0
^[]0;root@iris: /etc/xen/machines\aroot@iris:/etc/xen/machines# xm list\b \b\b \b\b \b\b \bdestroy 2
Traceback (most recent call last):
  File "/usr/sbin/xm", line 6, in ?
    main.main(sys.argv)
  File "/usr/lib/python2.2/site-packages/xen/xm/main.py", line 448, in main
    xm.main(args)
  File "/usr/lib/python2.2/site-packages/xen/xm/main.py", line 79, in main
    p.main(args[1:])
  File "/usr/lib/python2.2/site-packages/xen/xm/main.py", line 267, in main
    server.xend_domain_destroy(dom)
  File "/usr/lib/python2.2/site-packages/xen/xend/XendClient.py", line 204, in xend_domain_destroy
    {'op'      : 'destroy'})
  File "/usr/lib/python2.2/site-packages/xen/xend/XendClient.py", line 128, in xend_call
    return xend_request(url, "POST", data)
  File "/usr/lib/python2.2/site-packages/xen/xend/XendClient.py", line 108, in xend_request
    raise RuntimeError(resp.reason)
RuntimeError: Internal Server Error
^[]0;root@iris: /etc/xen/machines\aroot@iris:/etc/xen/machines# xm destroy 2\b\b\b\b\b\b\b\b\b^[[5Plist\b\b\b\bcreate -f eos -c
Traceback (most recent call last):
  File "/usr/sbin/xm", line 6, in ?
    main.main(sys.argv)
  File "/usr/lib/python2.2/site-packages/xen/xm/main.py", line 448, in main
    xm.main(args)
  File "/usr/lib/python2.2/site-packages/xen/xm/main.py", line 79, in main
    p.main(args[1:])
  File "/usr/lib/python2.2/site-packages/xen/xm/main.py", line 153, in main
    create.main(args)
  File "/usr/lib/python2.2/site-packages/xen/xm/create.py", line 365, in main
    (d, c) = make_domain(opts, config)
  File "/usr/lib/python2.2/site-packages/xen/xm/create.py", line 334, in make_domain
    dominfo = server.xend_domain_create(config)
  File "/usr/lib/python2.2/site-packages/xen/xend/XendClient.py", line 184, in xend_domain_create
    {'op'      : 'create',
  File "/usr/lib/python2.2/site-packages/xen/xend/XendClient.py", line 128, in xend_call
    return xend_request(url, "POST", data)
  File "/usr/lib/python2.2/site-packages/xen/xend/XendClient.py", line 108, in xend_request
    raise RuntimeError(resp.reason)
RuntimeError: Internal Server Error
^[]0;root@iris: /etc/xen/machines\aroot@iris:/etc/xen/machines# 

[-- Attachment #3: screenlog: xend tracing --]
[-- Type: text/plain, Size: 14141 bytes --]

^[]0;root@iris: /home/jmb\aroot@iris:~# sudo reboot\b\b\b\b\b\b\b\b\b\b\b^[[5Preboot\b\b\b\b\b\b^[[4Pls\b\brm screenlog.1\b0\b\b\b\b\b\b\b\b\b\b\b\b\b\bls^[[K\b\bcat screenlog.1\rroot@iris:~# ^[[1@less screenlog.1\b0\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bs^[[K\b\bscreen -L sudo bash\rroot@iris:~# ^[[3Pxend trace_start\b\b\b\b\b\b\b\b\b\b\b^[[7Pstop\b\b\b\b\b\b\b\b\brm trace \b\b\b\b\b\b\b\b\bxend stop
^[]0;root@iris: /home/jmb\aroot@iris:~# xend stop\b\b\b\b\b\b\b\b\bsudo reboot\b\b\b\b\b\b\b\b\b\b\b^[[5Preboot\b\b\b\b\b\b^[[4Pls\b\brm screenlog.1\b0\b\b\b\b\b\b\b\b\b\b\b\b\b\bls^[[K\b\bcat screenlog.1\rroot@iris:~# ^[[1@less screenlog.1\b0\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bs^[[K\b\bscreen -L sudo bash\rroot@iris:~# ^[[3Pxend trace_start\b\b\b\b\b\b\b\b\b\b\b^[[7Pstop\b\b\b\btrace_start
^[]0;root@iris: /home/jmb\aroot@iris:~# brctl addbr nbe-br
device nbe-br already exists; can't create bridge with the same name
brctl sethello nbe-br 0
brctl setfd nbe-br 0
brctl stp nbe-br off
Interface not found: eth0
initial_refresh>
db dom= ['domain', ['id', '0'], ['name', 'Domain-0'], ['memory', '55']]
xc dom= {'cpu_time': 39919403308L, 'name': 'Domain-0', 'dying': 0, 'dom': 0, 'maxmem_kb': 65536, 'paused': 0, 'crashed': 0, 'running': 1, 'shutdown_reason': 0, 'shutdown': 0, 'mem_kb': 56320, 'cpu': 0, 'blocked': 0}
dom= 0 config= ['domain', ['id', '0'], ['name', 'Domain-0'], ['memory', '55']]
dom= 0 new
XendDomain>reap>
XendDomain>reap<
XendDomain>initial_refresh> doms:
dom domain id=0 name=Domain-0 memory=55
EVENT> xend.start 0
00\b \b\b \b\a\a0\b \bXendDomain>reap>
XendDomain>reap<
config: (vm (name 'eos - dns') (memory '16') (cpu '-1') (image (linux (kernel /boot/xen/xenU-2.4.26) (ip :::::eth0:off) (root '/dev/hda1 ro'))) (device (vbd (uname phy:/dev/evms/machines/eos/root) (dev hda1) (mode w))) (device (vbd (uname phy:/dev/evms/machines/eos/swap) (dev hda2) (mode w))) (device (vbd (uname phy:/dev/evms/machines/eos/dnsdata) (dev hdb1) (mode w))) (device (vif)))
vm_create>
create_domain> linux /boot/xen/xenU-2.4.26
create-domain> init_domain...
init_domain> 16 eos - dns -1
create_domain> dom= 1
build_domain> linux 1 /boot/xen/xenU-2.4.26  ip=:::::eth0:off root=/dev/hda1 ro 
VIRTUAL MEMORY ARRANGEMENT:
 Loaded kernel: c0000000->c0198a58
 Init. ramdisk: c0199000->c0199000
 Phys-Mach map: c0199000->c019d000
 Page tables:   c019d000->c019f000
 Start info:    c019f000->c01a0000
 Boot stack:    c01a0000->c01a1000
 TOTAL:         c0000000->c0400000
 ENTRY ADDRESS: c0000000
vm_create<
EVENT> xend.console.create [12, 1, 9601]
>create_devices
blkif_dev_create> 1 769 w {'device': 65034, 'type': 'Disk', 'start_sector': 0L, 'nr_sectors': 425982L}
blkif_dev_create> 1 770 w {'device': 65036, 'type': 'Disk', 'start_sector': 0L, 'nr_sectors': 32766L}
<create_devices
_vm_configure1> made devices...
_vm_configure1<
brctl addif nbe-br vif1.0
vm_dev_vif> created <xen.xend.server.netif.NetDev instance at 0x84e4664>
blkif_dev_create> 1 833 w {'device': 65032, 'type': 'Disk', 'start_sector': 0L, 'nr_sectors': 32766L}
_vm_configure1> cbok [(1, <xen.xend.server.blkif.BlkifController instance at 0x84df5c4>), (1, 0), (1, 0), (1, 0)]
>callback _vm_configure2...
_vm_configure2> cbok []
<_vm_configure2
vm_create> cbok domain id=1 name=eos - dns memory=16 console=12 image=/boot/xen/xenU-2.4.26
EVENT> xend.domain.created 1
EVENT> xend.domain.unpause 1
EVENT> xend.console.connect [12, '127.0.0.1', 1028]
responseReceived> No handler: Message type blkif_fe_interface_status_changed_t 2:0 <xen.xend.server.blkif.BlkifController instance at 0x84df5c4>
recv_fe_interface_connect>
(blkif (dom '1') (evtchn '13' '4'))
responseReceived> No handler: Message type blkif_fe_interface_status_changed_t 2:0 <xen.xend.server.blkif.BlkifController instance at 0x84df5c4>
responseReceived> No handler: Message type netif_fe_interface_status_changed_t 4:0 <xen.xend.server.netif.NetifController instance at 0x84e59a4>
responseReceived> No handler: Message type netif_fe_interface_status_changed_t 4:0 <xen.xend.server.netif.NetifController instance at 0x84e59a4>
VirqClient.virqReceived> 4
XendDomain> virq 4
XendDomain>reap>
XendDomain>reap> died id= 1 {'cpu_time': 1301179463L, 'name': 'eos - dns', 'dying': 0, 'dom': 1, 'maxmem_kb': 16384, 'paused': 0, 'crashed': 0, 'running': 0, 'shutdown_reason': 0, 'shutdown': 1, 'mem_kb': 15604, 'cpu': 0, 'blocked': 0}
cleanup> 1
release_devices> 1
release_vifs> 1
NetifController>destroy> dom= 1
NetDev>destroy> vif= 0
(netdev (vif 0) (mac aa:0:0:51:9d:7) (evtchn '14' '5'))
brctl delif nbe-br vif1.0
release_vbds> 1
BlkifController>destroy> dom= 1
>BlkifController>send_be_disconnect> dom= 1
BlkifController>lostChannel> dom= 1
NetifController>lostChannel> dom= 1
XendDomain>reap<
EVENT> xend.virq 4
EVENT> xend.domain.destroy 1
responseReceived> No handler: Message type netif_be_disconnect_t 3:3 <xen.xend.server.netif.NetifControllerFactory instance at 0x84477ec>
responseReceived> No handler: Message type blkif_be_disconnect_t 1:3 <xen.xend.server.blkif.BlkifControllerFactory instance at 0x842db24>
EVENT> xend.console.disconnect [12, '127.0.0.1', 1028]
XendDomain>reap>
XendDomain>reap<
EVENT> xend.domain.died 1
config: (vm (name 'eos - dns') (memory '16') (cpu '-1') (image (linux (kernel /boot/xen/xenU-2.4.26) (ip :::::eth0:off) (root '/dev/hda1 ro'))) (device (vbd (uname phy:/dev/evms/machines/eos/root) (dev hda1) (mode w))) (device (vbd (uname phy:/dev/evms/machines/eos/swap) (dev hda2) (mode w))) (device (vbd (uname phy:/dev/evms/machines/eos/dnsdata) (dev hdb1) (mode w))) (device (vif)))
vm_create>
create_domain> linux /boot/xen/xenU-2.4.26
create-domain> init_domain...
init_domain> 16 eos - dns -1
create_domain> dom= 2
build_domain> linux 2 /boot/xen/xenU-2.4.26  ip=:::::eth0:off root=/dev/hda1 ro 
VIRTUAL MEMORY ARRANGEMENT:
 Loaded kernel: c0000000->c0198a58
 Init. ramdisk: c0199000->c0199000
 Phys-Mach map: c0199000->c019d000
 Page tables:   c019d000->c019f000
 Start info:    c019f000->c01a0000
 Boot stack:    c01a0000->c01a1000
 TOTAL:         c0000000->c0400000
 ENTRY ADDRESS: c0000000
vm_create<
EVENT> xend.console.create [15, 2, 9602]
Traceback (most recent call last):
  File "/usr/lib/python2.2/site-packages/twisted/internet/pollreactor.py", line 145, in doPoll
    log.callWithLogger(selectable, _drdw, selectable, fd, event, POLLIN, POLLOUT, log)
  File "/usr/lib/python2.2/site-packages/twisted/python/log.py", line 65, in callWithLogger
    callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib/python2.2/site-packages/twisted/python/log.py", line 52, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib/python2.2/site-packages/twisted/python/context.py", line 43, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/lib/python2.2/site-packages/twisted/internet/pollreactor.py", line 160, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/lib/python2.2/site-packages/xen/xend/server/SrvDaemon.py", line 252, in doRead
    self.protocol.notificationReceived(notification)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/SrvDaemon.py", line 176, in notificationReceived
    channel.notificationReceived()
  File "/usr/lib/python2.2/site-packages/xen/xend/server/channel.py", line 132, in notificationReceived
    self.handleNotification()
  File "/usr/lib/python2.2/site-packages/xen/xend/server/channel.py", line 296, in handleNotification
    work += self.handleResponses()
  File "/usr/lib/python2.2/site-packages/xen/xend/server/channel.py", line 331, in handleResponses
    self.responseReceived(msg)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/channel.py", line 339, in responseReceived
    dev.responseReceived(msg, ty, subty)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/controller.py", line 30, in responseReceived
    method(msg, 0)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/blkif.py", line 93, in recv_be_create
    self.callDeferred(blkif)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/controller.py", line 118, in callDeferred
    d.callback(*args)
  File "/usr/lib/python2.2/site-packages/twisted/internet/defer.py", line 252, in callback
    self._startRunCallbacks(result)
  File "/usr/lib/python2.2/site-packages/twisted/internet/defer.py", line 299, in _startRunCallbacks
    raise AlreadyCalledError
twisted.internet.defer.AlreadyCalledError: 
Unhandled error in Deferred:
Failure: twisted.internet.defer.TimeoutError: Callback timed out
XendDomain>reap>
XendDomain>reap<
EVENT> xend.domain.created 2
cleanup> 2
release_devices> 2
release_vifs> 2
release_vbds> 2
BlkifController>destroy> dom= 2
>BlkifController>send_be_disconnect> dom= 2
BlkifController>lostChannel> dom= 2
Traceback (most recent call last):
  File "/usr/lib/python2.2/site-packages/twisted/protocols/basic.py", line 229, in dataReceived
    return self.rawDataReceived(data)
  File "/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 1015, in rawDataReceived
    self.allContentReceived()
  File "/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 1006, in allContentReceived
    req.requestReceived(command, path, version)
  File "/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 557, in requestReceived
    self.process()
--- <exception caught here> ---
  File "/usr/lib/python2.2/site-packages/twisted/web/server.py", line 165, in process
    self.render(resrc)
  File "/usr/lib/python2.2/site-packages/twisted/web/server.py", line 172, in render
    body = resrc.render(self)
  File "/usr/lib/python2.2/site-packages/twisted/web/resource.py", line 201, in render
    return m(request)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/SrvDomain.py", line 155, in render_POST
    return self.perform(req)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/SrvBase.py", line 98, in perform
    val = op_method(op, req)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/SrvDomain.py", line 36, in op_destroy
    val = self.xd.domain_destroy(self.dom.id)
  File "/usr/lib/python2.2/site-packages/xen/xend/XendDomain.py", line 292, in domain_destroy
    val = dominfo.destroy()
  File "/usr/lib/python2.2/site-packages/xen/xend/XendDomainInfo.py", line 518, in destroy
    return self.destroy_domain()
  File "/usr/lib/python2.2/site-packages/xen/xend/XendDomainInfo.py", line 528, in destroy_domain
    chan.close()
  File "/usr/lib/python2.2/site-packages/xen/xend/server/channel.py", line 243, in close
    self.factory.channelClosed(self)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/channel.py", line 92, in channelClosed
    self.delChannel(channel.idx)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/channel.py", line 46, in delChannel
    self.notifier.unbind(idx)
exceptions.IOError: [Errno 14] Bad address
EVENT> xend.domain.destroy 2
config: (vm (name 'eos - dns') (memory '16') (cpu '-1') (image (linux (kernel /boot/xen/xenU-2.4.26) (ip :::::eth0:off) (root '/dev/hda1 ro'))) (device (vbd (uname phy:/dev/evms/machines/eos/root) (dev hda1) (mode w))) (device (vbd (uname phy:/dev/evms/machines/eos/swap) (dev hda2) (mode w))) (device (vbd (uname phy:/dev/evms/machines/eos/dnsdata) (dev hdb1) (mode w))) (device (vif)))
vm_create>
create_domain> linux /boot/xen/xenU-2.4.26
create-domain> init_domain...
init_domain> 16 eos - dns -1
create_domain> dom= 3
cleanup> 3
release_devices> 3
release_vifs> 3
release_vbds> 3
Traceback (most recent call last):
  File "/usr/lib/python2.2/site-packages/twisted/protocols/basic.py", line 229, in dataReceived
    return self.rawDataReceived(data)
  File "/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 1015, in rawDataReceived
    self.allContentReceived()
  File "/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 1006, in allContentReceived
    req.requestReceived(command, path, version)
  File "/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 557, in requestReceived
    self.process()
--- <exception caught here> ---
  File "/usr/lib/python2.2/site-packages/twisted/web/server.py", line 165, in process
    self.render(resrc)
  File "/usr/lib/python2.2/site-packages/twisted/web/server.py", line 172, in render
    body = resrc.render(self)
  File "/usr/lib/python2.2/site-packages/twisted/web/resource.py", line 201, in render
    return m(request)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/SrvDomainDir.py", line 99, in render_POST
    return self.perform(req)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/SrvBase.py", line 98, in perform
    val = op_method(op, req)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/SrvDomainDir.py", line 59, in op_create
    deferred = self.xd.domain_create(config)
  File "/usr/lib/python2.2/site-packages/xen/xend/XendDomain.py", line 231, in domain_create
    deferred = XendDomainInfo.vm_create(config)
  File "/usr/lib/python2.2/site-packages/xen/xend/XendDomainInfo.py", line 275, in vm_create
    return vm.construct(config)
  File "/usr/lib/python2.2/site-packages/xen/xend/XendDomainInfo.py", line 445, in construct
    self.destroy()
  File "/usr/lib/python2.2/site-packages/xen/xend/XendDomainInfo.py", line 518, in destroy
    return self.destroy_domain()
  File "/usr/lib/python2.2/site-packages/xen/xend/XendDomainInfo.py", line 528, in destroy_domain
    chan.close()
  File "/usr/lib/python2.2/site-packages/xen/xend/server/channel.py", line 243, in close
    self.factory.channelClosed(self)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/channel.py", line 92, in channelClosed
    self.delChannel(channel.idx)
  File "/usr/lib/python2.2/site-packages/xen/xend/server/channel.py", line 46, in delChannel
    self.notifier.unbind(idx)
exceptions.IOError: [Errno 14] Bad address

^[]0;root@iris: /home/jmb\aroot@iris:~# exit

^ permalink raw reply	[relevance 3%]

* Re: Xen, gridcluster, boot with red hat ent 3
  @ 2004-07-05  9:08  4% ` Rune Johan Andresen
  0 siblings, 0 replies; 200+ results
From: Rune Johan Andresen @ 2004-07-05  9:08 UTC (permalink / raw)
  To: Ian Pratt; +Cc: xen-devel, Rune Johan Andresen

Hi,

The bootup is:

  http://www.cl.cam.ac.uk/netos/xen
  University of Cambridge Computer Laboratory

  Xen version 1.3-devel (root@cern.ch) (gcc version 3.2.3 20030502 (Red 
Hat Linux
  3.2.3-34)) Sun Jul 4 15:11:40 CEST 2004

(XEN) Initialised 255MB memory (65
(XEN) .... Wall Clock:  1089024669s 40000us
(XEN) PCI: PCI BIOS revision 2.10 entry at 0x
(XEN) PCI: Using configuration type 1
(XEN) PCI: Probing PCI hardware
(XEN) PCI: Probing PCI hardware (bus 00)
(XEN) PCI: Ignoring BAR0-3 of IDE controller 00:1f.1
(XEN) Transparent bridge - PCI device 8086:244e
(XEN) PCI: Using IRQ router PIIX/ICH [8086/24c0] at 00:1f.0
(XEN) PCI: Found IRQ 9 for device 00:1f.1
(XEN) PCI: Sharing IRQ 9 with 00:1d.2
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found: 'GUEST_OS=linux,GUEST_VER=2.4,XEN_VER=1.3'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  0280000
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->0ac00000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0000000->c02e5f04
(XEN)  Init. ramdisk: c02e6000->c02e6000
(XEN)  Phys-Mach map: c02e6000->c0306000
(XEN)  Page tables:   c0306000->c0308000
(XEN)  Start info:    c0308000->c0309000
(XEN)  Boot stack:    c0309000->c030a000
(XEN)  TOTAL:         c0000000->c0400000
(XEN)  ENTRY ADDRESS: c0000000
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch 
input to Xen
).
Linux version 2.4.26-xen0 (root@pb-s-513-1-26-5-2.cern.ch) (gcc version 
3.2.3 20
030502 (Red Hat Linux 3.2.3-34)) #1 Sun Jul 4 15:21:44 CEST 2004
On node 0 totalpages: 32768
zone(0): 4096 pages.
zone(1): 28672 pages.
zone(2): 0 pages.
Kernel command line: /vmlinuz-2.4.26-xen0 root=/dev/hda2 ro 
console=ttyS0
Initializing CPU#0
Xen reported: 2400.143 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 23959.96 BogoMIPS
Memory: 126416k/131072k available (1956k kernel code, 4656k reserved, 
590k data,
  112k init, 0k highmem)
Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
Inode cache hash table entries: 8192 (order: 4, 65536 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 8192 (order: 3, 32768 bytes)
Page-cache hash table entries: 32768 (order: 5, 131072 bytes)
CPU: L1 I cache: 12K, L1 D cache: 8K
CPU: L2 cache: 512K
CPU: Intel(R) Pentium(R) 4 CPU 2.40GHz stepping 04
POSIX conformance testing by UNIFIX
PCI: Probing PCI hardware
PCI: Probing PCI hardware (bus 00)
PCI: Probing PCI hardware (bus 01)
PCI: Probing PCI hardware (bus 02)
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed as ttyS
Starting Xen Balloon driver
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
Intel(R) PRO/1000 Network Driver - version 5.2.30.1-k1
Copyright (c) 1999-2004 Intel Corporation.
pcnet32.c:v1.28 02.20.2004 tsbogend@alpha.franken.de
Intel(R) PRO/100 Network Driver - version 2.3.38-k1
Copyright (c) 2004 Intel Corporation

(XEN) PCI: Found IRQ 11 for device 02:08.0
PCI: Obtained IRQ 11 for device 02:08.0
e100: selftest timeout
e100: Failed to initialize, instance #0
Uniform Multi-Platform E-IDE dri
ide: Assuming 33MHz system bus speed for PIO modes; override with 
idebus=xx
ICH4: IDE controller at PCI slot 00:1f.1
(XEN) PCI: Found IRQ 9 for device 00:1f.1
(XEN) PCI: Sharing IRQ 9 with 00:1d.2
PCI: Enabling device 00:1f.1 (0005 -> 0007)
PCI: Obtained IRQ 9 for device 00:1f.1
ICH4: chipset revision 1
ICH4: not 100% native mode: will probe irqs later
     ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:DMA, hdb:pio
     ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:DMA, hdd:pio
hda: C/H/S=0/0/0 from BIOS i
hda: WDC WD400JB-00ENA0, ATA DISK drive
hdc: SAMSUNG DVD-ROM SD-616Q, ATAPI CD/DVD-ROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide1 at 0x170-0x177,0x376 on irq 15
hda: attached ide-disk driver.
hda: host protected area => 1
hda: 78165360 sectors (40021 MB) w/8192KiB Cache, CHS=77545/16/63, 
UDMA(100)
hdc: attached ide-cdrom driver.
hdc: ATAPI 48X DVD-ROM drive, 512kB Cache, UDMA(33)
Uniform CD-ROM driver Revision: 3.12
Partition check:
  hda: [PTBL] [4865/255/63] hda1 hda2 hda3
SCSI subsystem driver Revision: 1.00
Red Hat/Adaptec aacraid driver (1.1-3 Jul  4 2004 15:22:02)
megaraid: v1.18k (Release Date: Thu Aug 28 10:05:11 EDT 2003)
megaraid: no BIOS enabled.
scsi0 : SCSI host adapter emulation for IDE ATAPI devices
Initialising Xen netif backend
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 1024 buckets, 8Kbytes
TCP: Hash tables configured (established 8192 bind 16384)
ip_conntrack version 2.1 (1024 buckets, 8192 max) - 288 bytes per 
conntrack
ip_tables: (C) 2000-2002 Netfilter core team
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NET4: Ethernet Bridge 008 for NET4.0
Bridge firewalling registered
kjournald starting.  Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.
Freeing unused kernel memory: 112k freed

(And halt, but the keyboard fuctions, even the screen turns off for 
saving after a few minutes, so i think there are just some serial
output problems, but have a hard time figure out why - this functions 
on Debian Sid, but behaves like this on Ref Hat Ent 3..)

The grub config is:


title xen ....
	kernel /xen.gz dom0_mem=131072 com1=115200,8n1 noht
	module /vmlinuz-2.4.26-xen0 root=/dev/hda2 ro console=ttyS0

(using serial output - on THE PC box i use tty0 - without it it only 
boots until (XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times 
to switch input to Xen
  )

Thank you!

regards
Rune J.A






On Jul 2, 2004, at 5:06 PM, Ian Pratt wrote:

>
>> The Red Hat Ent 3 is pretty old, but the glibc is compiled for i686 
>> and
>> the Xen kernel is compiled for the the right cpu, so the traditional
>> error are checked out. The system is not halting either, but seems to
>> go in an eternal loop. The keyboard works, but I cannot ping or ssh 
>> the
>> OS..
>
> Is this output coming over as serial line?
>
> You need "com1=115200,8n1" on the Xen grub line and
> "console=ttyS0" on the xenlinux command line.
>
> Can you post the grub config and all the serial output.
>
> Thanks,
> Ian
>
>
>> I have tried the sysreq option, where sysreq p gives:
>>
>> PID: 1, comm		init
>> EIP: 0819[<00ae870>] CPU: 0 EFLAGS: 00201217 Not tainted
>>
>>
>> the last Bootlines gives:
>>
>>
>> hdc: attached ude-cdrom driver
>> hdc: ATAPO 48X DVD-ROM drive, 512kB Cache, UDMA(33)
>> Uniform CD-ROM driver Revision:  3.12
>> Partition check:
>>    hda: [PTBL] [4865/255/63] hda1 hda2 hda3
>> SCSI subsystem driver Revision: 1.00
>> Red Hat/Adaptec aacraid driver (1.1-3 Jul 1 2004 14:08:39)
>> megaraid: v1.18k
>> megaraid: no BIOS enabled
>> scsi0 : SCSI host adapter emulation for IDE ATAPI devices
>> Initialiising Xen netif backend
>> NET4: Linux TCP/IP 1.0 for NET4.0
>> IP Protocols: ICMP, UDP, TCP
>> IP: routing cache hash table of 1024 buckets, 8Kbytes
>> TCP: Hash tables configured (established 8192 bind 16384)
>> ip_conntrack version 2.1 (1024 buckets, 8192 max) - 288 bytes per
>> conntrack
>> ip_tables: (C) 2000-2002 Netfilter core team
>> NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
>> Bridge firewalling registered
>> kjournald starting. Commit interval 5 seconds
>> EXT3-fs: mounted filesystem with ordered data mode.
>> VFS: Mounted root (ext3 filesystem) readonly.
>> Freeing unused kernel memory: 112k freed
>>
>> All help aprecciated :-)
>>
>> Regards
>> Rune J.Andresen
>>
>>
>>
>> -------------------------------------------------------
>> This SF.Net email sponsored by Black Hat Briefings & Training.
>> Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
>> digital self defense, top technical experts, no vendor pitches,
>> unmatched networking opportunities. Visit www.blackhat.com
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/xen-devel
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by Black Hat Briefings & Training.
> Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
> digital self defense, top technical experts, no vendor pitches,
> unmatched networking opportunities. Visit www.blackhat.com
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xen-devel



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com

^ permalink raw reply	[relevance 4%]

* Re: lvm
  @ 2004-07-14 16:44  4%     ` Derek Glidden
  0 siblings, 0 replies; 200+ results
From: Derek Glidden @ 2004-07-14 16:44 UTC (permalink / raw)
  To: xen-devel


On Jul 14, 2004, at 4:47 AM, Christian Limpach wrote:

> I don't think you'd want to export an LVM logical volume as a
> whole-disk to another doain since then you won't have the ability
> to resize the partitions in that whole-disk.  I expect that would
> have been the reason why one would use LVM in the first place.

It's exactly why I would like to use LVM.  And XFS resizes very nicely 
with LVMs.  It also gives you the ability to create up to 256 LVs on a 
single Volume Group, as opposed to the I think 16 partition limit if 
you DOS-like partition a physical disk.  And you get things like 
snapshotting and migration of LVs between volume groups/physical disks 
that are really nice.  And it can ride on top of the software RAID 
layer for those of us out here with cheap IDE subsystems, so you make a 
single RAID1 or RAID5 and LVM-partition that into as many volumes as 
you need, instead of having to make a zillion RAID devices.  so yeah, 
LVM is nice for tossing lots of VMs around on a single machine.  :)

And I was going to post some more questions about it today because I'm 
not able to get the domain to recognize the exported LVs.  (Is there a 
xen-users list or something so I don't have to bog up the -dev list 
with noob user questions?  Or are those just as well posted here 
anyway?)

I've currently created LVs with LVM2 for swap and root for the new 
domain and changed the xmdefaults file to point to these partitions:

disk = [ 'phy:/dev/vg_pool/lv_vm0%d_swap,hda1,w' % (vmid),
          'phy:/dev/vg_pool/lv_vm0%d_root,hda2,w' % (vmid) ]

root = /dev/hda2

lv_vm01_root already has a filesystem created on it with gentoo already 
installed, ready for the new domain to boot right up.  But the new 
domain comes up and doesn't find the root volume.  The status messages 
seem to indicate that the LVs are getting exported correctly, but 
either I've built my xenU kernel wrong and/or I just don't know what 
I'm doing, since it doesn't seem to see any block devices at all.  
(Probably I should be exporting them as something other than hda1/2 ?)

I haven't gone back and simply fdisk'ed the drive to try to export 
"normal" partitions to the new domain; I've kind of picked a "hard" way 
to do it right off the bat I guess.  I'm hoping I just have the syntax 
wrong.  (Is there another type than "phy" ?)   I dug through the python 
for "xm" but didn't see anything that screamed out at any "right" way 
to do it.

(FYI and FWIW - this is a spare IDE dual-celeron machine I built from 
stuff scrounged out of old servers, not anything fancy with iSCSI or 
anything like that.  I work for a hosting/consulting company who 
currently have somewhere on the order of 1000 UML-based virtual-hosts 
deployed all over the place.  I'm mostly learning Xen for myself 
because I need to deploy a couple new servers of my own to replace my 
aging mail/web server and want to start off using UML or Xen to deploy 
everything as VMs and prefer the Xen approach, but I'd also like to try 
to push at least a few Xen servers into work to compare against the UML 
machines.  UML has a lot of mindshare right now though from the amount 
of work we've put in to support/maintain it, but I personally think the 
Xen approach is a lot cleaner/easier to maintain than UML, and live 
migration would be a huge bonus.)

# xm create -n -c vmid=1 dhcp=on
Using config file /etc/xen/xmdefaults

(vm
     (name 'This is VM 1')
     (memory '64')
     (cpu '1')
     (image
         (linux
             (kernel /boot/bzImage-2.4.26-xenU)
             (ip :::::eth0:on)
             (root '/dev/hda2 ro')
         )
     )
     (device (vbd (uname phy:/dev/vg_pool/lv_vm01_swap) (dev hda1) (mode 
w)))
     (device (vbd (uname phy:/dev/vg_pool/lv_vm01_root) (dev hda2) (mode 
w)))
     (device (vif (mac aa:0:0:1c:c8:7)))

# xm create -c vmid=1 dhcp=on

Started domain 28, console on port 9628
************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.4.26-xeno-xenU (root@vargas) (gcc version 3.3.3 
20040412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)) #9 Tue Jul 13 
22:54:03 EDT 2004
On node 0 totalpages: 16384
zone(0): 4096 pages.
zone(1): 12288 pages.
zone(2): 0 pages.
Kernel command line:  ip=:::::eth0:on root=/dev/hda2 ro
Initializing CPU#0
Xen reported: 451.031 MHz processor.
Calibrating delay loop... 4508.87 BogoMIPS
Memory: 62828k/65536k available (1368k kernel code, 2708k reserved, 
165k data, 44k init, 0k highmem)
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: L2 cache: 128K
CPU: Intel Celeron (Mendocino) stepping 05
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
devfs: v1.12c (20020818) Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x1
SGI XFS with no debug enabled
Event-channel device installed.
Xen virtual console successfully installed as tty
Starting Xen Balloon driver
pty: 2048 Unix98 ptys configured
Initialising Xen virtual block device
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Initializing Cryptographic API
Initialising Xen virtual ethernet frontend driver<6>NET4: Linux TCP/IP 
1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP, IGMP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
Linux IP multicast router 0.06 plus PIM-SM
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
VFS: Cannot open root device "hda2" or 03:02
Please append a correct "root=" boot option
Kernel panic: VFS: Unable to mount root fs on 03:02
  <0>Rebooting in 1 seconds..
************ REMOTE CONSOLE EXITED *****************


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"We all enter this world in the    | Support Electronic Freedom
same way: naked; screaming; soaked |        http://www.eff.org/
in blood. But if you live your     |  http://www.anti-dmca.org/
life right, that kind of thing     |---------------------------
doesn't have to stop there." -- Dana Gould



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com

^ permalink raw reply	[relevance 4%]

* /proc/xen/memory_target patch
@ 2004-07-16 19:33  7% David Becker
  0 siblings, 0 replies; 200+ results
From: David Becker @ 2004-07-16 19:33 UTC (permalink / raw)
  To: xen-devel


This patch to the balloon driver eliminates the need for a user-space
program to slosh memory between domains and xen.   This uses a proc
file at /proc/xen/memory_target.  When read it reports memory the domain
owns in bytes.   Writing a new value to the memory_target proc file
will cause the domain to exchange memory with xen to reach the target.
A xenolinux domain cannot grow bigger than it was when created.
Must be done by root.

Target requests are made in bytes, or with a k m or g suffix.  The
request is parsed with the same function that parses the mem= boottime
kernel param.

Memory sizes in bytes are internally truncated to pages.  Minimum change
is PAGE_SIZE (4k).

	dragonfly:~# cat /proc/xen/memory_target 
	134217728l
	dragonfly:~# echo 50m > /proc/xen/memory_target 
	Relinquish 78MB to xen. Domain now has 50MB
	dragonfly:~# echo 100m > /proc/xen/memory_target 
	Reclaim 50MB from xen. Domain now has 100MB
	dragonfly:~# cat /proc/xen/memory_target 
	104857600l

Daivd

(btw, updating twisted to 1.3 solved my console problems)




*** xeno-unstable.bk/linux-2.4.26-xen-sparse/arch/xen/drivers/balloon/balloon.c	Tue Jul  6 15:09:30 2004
--- obj-unstable/xeno-unstable.bk/linux-2.4.26-xen-sparse/arch/xen/drivers/balloon/balloon.c	Fri Jul 16 15:12:11 2004
***************
*** 39,44 ****
--- 39,45 ----
  
  static struct proc_dir_entry *balloon_pde;
  unsigned long credit;
+ static unsigned long current_pages, max_pages;
  
  static inline pte_t *get_ptep(unsigned long addr)
  {
***************
*** 221,270 ****
      return ret;
  }
  
  static int balloon_write(struct file *file, const char *buffer,
                           u_long count, void *data)
  {
!     user_balloon_op_t bop;
  
      /* Only admin can play with the balloon :) */
      if ( !capable(CAP_SYS_ADMIN) )
          return -EPERM;
  
!     if ( copy_from_user(&bop, buffer, sizeof(bop)) )
          return -EFAULT;
  
!     switch ( bop.op )
!     {
!     case USER_INFLATE_BALLOON:
!         if ( inflate_balloon(bop.size) < bop.size )
!             return -EAGAIN;
!         break;
!         
!     case USER_DEFLATE_BALLOON:
!         deflate_balloon(bop.size);
!         break;
  
!     default:
!         printk("Unknown command to balloon driver.");
!         return -EFAULT;
      }
  
!     return sizeof(bop);
  }
  
  static int __init init_module(void)
  {
      printk(KERN_ALERT "Starting Xen Balloon driver\n");
  
!     credit = 0;
! 
!     if ( (balloon_pde = create_xen_proc_entry("balloon", 0600)) == NULL )
      {
          printk(KERN_ALERT "Unable to create balloon driver proc entry!");
          return -1;
      }
  
      balloon_pde->write_proc = balloon_write;
  
      return 0;
  }
--- 222,307 ----
      return ret;
  }
  
+ #define PAGE_TO_MB_SHIFT 8
+ 
  static int balloon_write(struct file *file, const char *buffer,
                           u_long count, void *data)
  {
!     char memstring[64], *endchar;
!     int len, i, pages;
!     unsigned long long target;
  
      /* Only admin can play with the balloon :) */
      if ( !capable(CAP_SYS_ADMIN) )
          return -EPERM;
  
!     if (count>sizeof memstring) {
! 	    return -EFBIG;
!     }
! 
!     len = strnlen_user(buffer, count);
!     if (len==0) return -EBADMSG;
!     if (len==1) return 1; /* input starts with a NUL char */
!     if ( strncpy_from_user(memstring, buffer, len) < 0)
          return -EFAULT;
  
!     endchar = memstring;
!     for(i=0; i<len; ++i,++endchar) {
! 	    if ('0'>memstring[i] || memstring[i]>'9') break;
!     }
!     if (i==0) return -EBADMSG;
  
!     target = memparse(memstring,&endchar);
!     pages = target >> PAGE_SHIFT;
! 
!     if (pages < current_pages) {
! 	    int change = inflate_balloon(current_pages-pages);
! 	    if (change<0) return change;
! 
! 	    current_pages -= change;
!     	    printk("Relinquish %dMB to xen. Domain now has %dMB\n",
! 		    change>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT);
      }
+     else if (pages > current_pages) {
+ 	    int change = deflate_balloon(min(pages,max_pages) - current_pages);
+ 	    if (change<0) return change;
  
! 	    current_pages += change;
!     	    printk("Reclaim %dMB from xen. Domain now has %dMB\n",
! 		    change>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT);
!     }
! 
!     return len;
! }
! 
! 
! static int balloon_read(char *page, char **start, off_t off,
! 	  int count, int *eof, void *data)
! {
! 	int len;
! 	len = sprintf(page,"%ul\n",current_pages<<PAGE_SHIFT);
! 
! 	if (len <= off+count) *eof = 1;
! 	*start = page + off;
! 	len -= off;
! 	if (len>count) len = count;
! 	if (len<0) len = 0;
! 	return len;
  }
  
  static int __init init_module(void)
  {
      printk(KERN_ALERT "Starting Xen Balloon driver\n");
  
!     max_pages = current_pages = start_info.nr_pages;
!     if ( (balloon_pde = create_xen_proc_entry("memory_target", 0644)) == NULL )
      {
          printk(KERN_ALERT "Unable to create balloon driver proc entry!");
          return -1;
      }
  
      balloon_pde->write_proc = balloon_write;
+     balloon_pde->read_proc = balloon_read;
  
      return 0;
  }


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click

^ permalink raw reply	[relevance 7%]

* Re: desperate for help on netwrok of xen
  @ 2004-07-29 10:33  4% ` Yan Li
  0 siblings, 0 replies; 200+ results
From: Yan Li @ 2004-07-29 10:33 UTC (permalink / raw)
  To: Steven Hand; +Cc: xen-devel

e100 works fine in regular linux, and actually I tried in another machine
with e100, just the same problem.

and the second machine with 2 NICs also works fine in regular machine, using
eth1.

And here's the msg from dmesg and XendDmesg.py. This is for the machine only
with e100.

---------------
Linux version 2.4.26-xen0  (gcc version 3.3.2 20031022 (Red Hat Linux
3.3.2-1)) #3 Wed Jul 14 14:54:34 EDT 2004
On node 0 totalpages: 32768
zone(0): 4096 pages.
zone(1): 28672 pages.
zone(2): 0 pages.
Kernel command line: /vmlinuz-2.4.26-xen0 root=/dev/hda3 ro console=tty0 3
Initializing CPU#0
Xen reported: 1595.203 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 15938.35 BogoMIPS
Memory: 125996k/131072k available (2242k kernel code, 5076k reserved, 697k
data, 116k init, 0k highmem)
Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
Inode cache hash table entries: 8192 (order: 4, 65536 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 8192 (order: 3, 32768 bytes)
Page-cache hash table entries: 32768 (order: 5, 131072 bytes)
CPU: Before vendor init, caps: 3febfbff 00000000 00000000, vendor = 0
CPU: L1 I cache: 12K, L1 D cache: 8K
CPU: L2 cache: 256K
CPU: After vendor init, caps: 3febfbff 00000000 00000000 00000000
CPU:     After generic, caps: 3febfbff 00000000 00000000 00000000
CPU:             Common caps: 3febfbff 00000000 00000000 00000000
CPU: Intel(R) Pentium(R) 4 CPU 1.60GHz stepping 02
POSIX conformance testing by UNIFIX
PCI: Probing PCI hardware
PCI: Probing PCI hardware (bus 00)
PCI: Probing PCI hardware (bus 01)
PCI: Probing PCI hardware (bus 02)
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed as ttyS
Starting Xen Balloon driver
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
Intel(R) PRO/1000 Network Driver - version 5.2.30.1-k1
Copyright (c) 1999-2004 Intel Corporation.
pcnet32.c:v1.28 02.20.2004 tsbogend@alpha.franken.de
Intel(R) PRO/100 Network Driver - version 2.3.38-k1
Copyright (c) 2004 Intel Corporation

PCI: Obtained IRQ 11 for device 02:0a.0
e100: selftest timeout
e100: Failed to initialize, instance #0
Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
ICH2: IDE controller at PCI slot 00:1f.1
ICH2: chipset revision 4
ICH2: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:DMA, hdb:pio
    ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:DMA, hdd:pio
hda: C/H/S=0/0/0 from BIOS ignored
hda: MAXTOR 6L040J2, ATA DISK drive
hdc: AOPEN 16XDVD-ROM/AMH 20011108, ATAPI CD/DVD-ROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide1 at 0x170-0x177,0x376 on irq 15
hda: attached ide-disk driver.
hda: host protected area => 1
hda: 78177792 sectors (40027 MB) w/1818KiB Cache, CHS=77557/16/63, UDMA(33)
hdc: attached ide-cdrom driver.
hdc: ATAPI 48X DVD-ROM drive, 512kB Cache, UDMA(33)
Uniform CD-ROM driver Revision: 3.12
Partition check:
 hda: [PTBL] [4866/255/63] hda1 hda2 hda3 hda4 < hda5 >
SCSI subsystem driver Revision: 1.00
Red Hat/Adaptec aacraid driver (1.1-3 Jul 14 2004 14:49:49)
megaraid: v1.18k (Release Date: Thu Aug 28 10:05:11 EDT 2003)
megaraid: no BIOS enabled.
scsi0 : SCSI host adapter emulation for IDE ATAPI devices
Initialising Xen netif backend
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 1024 buckets, 8Kbytes
TCP: Hash tables configured (established 8192 bind 16384)
ip_conntrack version 2.1 (1024 buckets, 8192 max) - 288 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NET4: Ethernet Bridge 008 for NET4.0
Bridge firewalling registered
kjournald starting.  Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.
Freeing unused kernel memory: 116k freed
EXT3 FS 2.4-0.9.19, 19 August 2002 on ide0(3,3), internal journal
Adding Swap: 522072k swap-space (priority -1)
kjournald starting.  Commit interval 5 seconds
EXT3 FS 2.4-0.9.19, 19 August 2002 on ide0(3,2), internal journal
EXT3-fs: mounted filesystem with ordered data mode.
ioperm not fully supported - set iopl to 3
ioperm not fully supported - set iopl to 3
ioperm not fully supported - set iopl to 3
ioperm not fully supported - set iopl to 3

-----------------
 __  __            _   _____        _                _
 \ \/ /___ _ __   / | |___ /     __| | _____   _____| |
  \  // _ \ '_ \  | |   |_ \ __ / _` |/ _ \ \ / / _ \ |
  /  \  __/ | | | | |_ ___) |__| (_| |  __/\ V /  __/ |
 /_/\_\___|_| |_| |_(_)____/    \__,_|\___| \_/ \___|_|

 http://www.cl.cam.ac.uk/netos/xen
 University of Cambridge Computer Laboratory

 Xen version 1.3-devel  (gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1))
Wed Jul 14 14:55:27 EDT 2004

(XEN) Initialised 255MB memory (65472 pages) on a 255MB machine
(XEN) Xen heap size is 10823KB
(XEN) CPU0: Before vendor init, caps: 3febfbff 00000000 00000000, vendor = 0
(XEN) CPU caps: 2febfbff 00000000 00000000 00000000
(XEN) Using scheduler: Borrowed Virtual Time (bvt)
(XEN) Initializing CPU#0
(XEN) Detected 1595.203 MHz processor.
(XEN) Found and enabled local APIC!
(XEN) CPU0: Before vendor init, caps: 3febfbff 00000000 00000000, vendor = 0
(XEN) CPU caps: 2febfbff 00000000 00000000 00000000
(XEN) CPU0 booted
(XEN) SMP motherboard not detected.
(XEN) enabled ExtINT on CPU#0
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) Using local APIC timer interrupts.
(XEN) Calibrating APIC timer for CPU0...
(XEN) ..... CPU speed is 1595.1718 MHz.
(XEN) ..... Bus speed is 99.6981 MHz.
(XEN) ..... bus_scale = 0x00006617
(XEN) Time init:
(XEN) .... System Time: 20001858ns
(XEN) .... cpu_freq:    00000000:5F14E010
(XEN) .... scale:       00000001:40F65066
(XEN) .... Wall Clock:  1091069944s 40000us
(XEN) PCI: PCI BIOS revision 2.10 entry at 0xfda95, last bus=2
(XEN) PCI: Using configuration type 1
(XEN) PCI: Probing PCI hardware
(XEN) PCI: Probing PCI hardware (bus 00)
(XEN) Transparent bridge - PCI device 8086:244e
(XEN) PCI: Using IRQ router PIIX/ICH [8086/2440] at 00:1f.0
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found:
'GUEST_OS=linux,GUEST_VER=2.4,XEN_VER=1.3,VIRT_BASE=0xC0000000'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  02800000->02b028fc
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->0ac00000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0100000->c044e988
(XEN)  Init. ramdisk: c044f000->c044f000
(XEN)  Phys-Mach map: c044f000->c046f000
(XEN)  Page tables:   c046f000->c0472000
(XEN)  Start info:    c0472000->c0473000
(XEN)  Boot stack:    c0473000->c0474000
(XEN)  TOTAL:         c0000000->c0800000
(XEN)  ENTRY ADDRESS: c0100000
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to
Xen).
(XEN) PCI: Found IRQ 11 for device 02:0a.0

----------------


Thanks,
Yan

----- Original Message ----- 
From: "Steven Hand" <Steven.Hand@cl.cam.ac.uk>
To: "Yan Li" <yan_li00@hotmail.com>
Cc: <xen-devel@lists.sourceforge.net>
Sent: Thursday, July 29, 2004 2:21 AM
Subject: Re: [Xen-devel] desperate for help on netwrok of xen


>
> > I've asked about eth0, but now I'm really desperate.
> >
> > -first, I built xen-unstable on a machine with NIC e100, but there's no
> > eth0, ifconfig only shows loopback. And I'm sure in the .config file
> > 'CONFIG_E100=y'.
>
> Can you post the output from booting xen and domain 0 (xenlinux)? You
> might also like to check if the e100 is found and operates correctly
> under regular linux...
>
> cheers,
>
> S.
>
>


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click

^ permalink raw reply	[relevance 4%]

* high memory manipulation patch
@ 2004-08-06 16:41  6% David Becker
  0 siblings, 0 replies; 200+ results
From: David Becker @ 2004-08-06 16:41 UTC (permalink / raw)
  To: xen-devel


This patch adds support for high memory to /proc/xen/memory_target,
and it restores the mem= linux boot parameter.  This is for 2.4.26 only.
I haven't looked at 2.6 yet.  (remmeber that CONFIG_HIGHMEM
is not on by default in the xen0 and xenU configs)
I have racks of 2g and 4g machines, hence my interest.

The 'mem=' param tells linux the maximum amount of memory it can use.
The feature originated for hosts where the normal mem detection mechanisms
failed.   These days its main use in stock linux is to artificially
constrain how much memory linux uses for testing low memory systems.

With this patch, mem= now means the max memory linux could ever use.
When a domain is created with less than that the mem= value, linux will
behave as though that 'missing' memory is 'allocated'.   To give the
domain more memory, first run setdomainmaxmem in Dom-0 to raise Xen's
limit, then write the new total to /proc/xen/memory_target in the
domain.   When mem= is not explicitly set, it defaults to the 
boottime size of the domain.

This is useful in order to create domains at times when the memory resources
the new domain could use in the future are currently in use by other domains.

Hopefully an xm god can replace the setdomainmaxmem script with a new
maxmem argument to xm create.

This bit illustrates booting dom-1 with 100m and growing it to 2g:

     dom-0# xm create name=dom-1 memory=100 extra='-b mem=2g'
     dom-0# setdomainmaxmem 1 2g

then in domain 1,
     dom-1# mount /proc
     dom-1# grep Mem[TF] /proc/meminfo
     MemTotal:      2097152 kB
     MemFree:         57352 kB
     dom-1# echo 2g > /proc/xen/memory_target 
     Granted 1948MB new mem by xen. Domain now has 2048MB
     dom-1# grep Mem[TF] /proc/meminfo
     MemTotal:      2097152 kB
     MemFree:       2052104 kB

David



===== linux-2.4.26-xen-sparse/arch/xen/drivers/balloon/balloon.c 1.18 vs edited =====
*** /tmp/balloon.c-1.18-11013	Mon Aug  2 10:57:36 2004
--- edited/linux-2.4.26-xen-sparse/arch/xen/drivers/balloon/balloon.c	Fri Aug  6 11:13:24 2004
***************
*** 17,22 ****
--- 17,24 ----
  #include <linux/mman.h>
  #include <linux/smp_lock.h>
  #include <linux/pagemap.h>
+ #include <linux/bootmem.h>
+ #include <linux/highmem.h>
  #include <linux/vmalloc.h>
  
  #include <asm/hypervisor.h>
***************
*** 39,45 ****
  
  static struct proc_dir_entry *balloon_pde;
  unsigned long credit;
! static unsigned long current_pages, max_pages;
  
  static inline pte_t *get_ptep(unsigned long addr)
  {
--- 41,47 ----
  
  static struct proc_dir_entry *balloon_pde;
  unsigned long credit;
! static unsigned long current_pages, most_seen_pages;
  
  static inline pte_t *get_ptep(unsigned long addr)
  {
***************
*** 69,109 ****
      parray = (unsigned long *)vmalloc(num_pages * sizeof(unsigned long));
      if ( parray == NULL )
      {
!         printk("inflate_balloon: Unable to vmalloc parray\n");
!         return 0;
      }
  
      currp = parray;
  
!     for ( i = 0; i < num_pages; i++ )
      {
!         /* NB. Should be GFP_ATOMIC for a less aggressive inflation. */
!         vaddr = __get_free_page(GFP_KERNEL);
  
          /* If allocation fails then free all reserved pages. */
!         if ( vaddr == 0 )
          {
!             printk("Unable to inflate balloon by %ld, only %ld pages free.",
                     num_pages, i);
              currp = parray;
!             for(j = 0; j < i; j++){
!                 free_page(*currp++);
              }
              goto cleanup;
          }
  
!         *currp++ = vaddr;
      }
  
  
!     currp = parray;
!     for ( i = 0; i < num_pages; i++ )
      {
!         curraddr = *currp;
!         *currp = virt_to_machine(*currp) >> PAGE_SHIFT;
!         queue_l1_entry_update(get_ptep(curraddr), 0);
!         phys_to_machine_mapping[__pa(curraddr) >> PAGE_SHIFT] = DEAD;
!         currp++;
      }
  
      XEN_flush_page_update_queue();
--- 71,113 ----
      parray = (unsigned long *)vmalloc(num_pages * sizeof(unsigned long));
      if ( parray == NULL )
      {
!         printk(KERN_ERR "inflate_balloon: Unable to vmalloc parray\n");
!         return -EFAULT;
      }
  
      currp = parray;
  
!     for ( i = 0; i < num_pages; i++, currp++ )
      {
! 	struct page *page = alloc_page(GFP_HIGHUSER);
! 	unsigned long pfn =  page - mem_map;
  
          /* If allocation fails then free all reserved pages. */
!         if ( page == 0 )
          {
!             printk(KERN_ERR "Unable to inflate balloon by %ld, only %ld pages free.",
                     num_pages, i);
              currp = parray;
!             for(j = 0; j < i; j++, ++currp){
!                 __free_page((struct page *) (mem_map + *currp));
              }
+ 	    ret = -EFAULT;
              goto cleanup;
          }
  
!         *currp = pfn;
      }
  
  
!     for ( i = 0, currp = parray; i < num_pages; i++, currp++ )
      {
! 	unsigned long mfn = phys_to_machine_mapping[*currp];
!         curraddr = page_address(mem_map + *currp);
! 	if (curraddr)
!             queue_l1_entry_update(get_ptep(curraddr), 0);
! 
!         phys_to_machine_mapping[*currp] = DEAD;
!         *currp = mfn;
      }
  
      XEN_flush_page_update_queue();
***************
*** 112,118 ****
                                  parray, num_pages, 0);
      if ( unlikely(ret != num_pages) )
      {
!         printk("Unable to inflate balloon, error %lx\n", ret);
          goto cleanup;
      }
  
--- 116,122 ----
                                  parray, num_pages, 0);
      if ( unlikely(ret != num_pages) )
      {
!         printk(KERN_ERR "Unable to inflate balloon, error %lx\n", ret);
          goto cleanup;
      }
  
***************
*** 130,136 ****
   * phys->machine mapping table looking for DEAD entries and populates
   * them.
   */
! static unsigned long process_new_pages(unsigned long * parray, 
                                         unsigned long num)
  {
      /* currently, this function is rather simplistic as 
--- 134,140 ----
   * phys->machine mapping table looking for DEAD entries and populates
   * them.
   */
! static unsigned long process_returned_pages(unsigned long * parray, 
                                         unsigned long num)
  {
      /* currently, this function is rather simplistic as 
***************
*** 140,146 ****
       * incorporated here.
       */
       
!     unsigned long tot_pages = start_info.nr_pages;   
      unsigned long * curr = parray;
      unsigned long num_installed;
      unsigned long i;
--- 144,150 ----
       * incorporated here.
       */
       
!     unsigned long tot_pages = most_seen_pages;   
      unsigned long * curr = parray;
      unsigned long num_installed;
      unsigned long i;
***************
*** 152,180 ****
          {
              phys_to_machine_mapping[i] = *curr;
              queue_machphys_update(*curr, i);
!             queue_l1_entry_update(
                  get_ptep((unsigned long)__va(i << PAGE_SHIFT)),
                  ((*curr) << PAGE_SHIFT) | pgprot_val(PAGE_KERNEL));
  
!             *curr = (unsigned long)__va(i << PAGE_SHIFT);
              curr++;
              num_installed++;
          }
      }
  
-     /*
-      * This is tricky (and will also change for machine addrs that 
-      * are mapped to not previously released addresses). We free pages
-      * that were allocated by get_free_page (the mappings are different 
-      * now, of course).
-      */
-     curr = parray;
-     for ( i = 0; i < num_installed; i++ )
-     {
-         free_page(*curr);
-         curr++;
-     }
- 
      return num_installed;
  }
  
--- 156,173 ----
          {
              phys_to_machine_mapping[i] = *curr;
              queue_machphys_update(*curr, i);
! 	    if (i<max_low_pfn)
!               queue_l1_entry_update(
                  get_ptep((unsigned long)__va(i << PAGE_SHIFT)),
                  ((*curr) << PAGE_SHIFT) | pgprot_val(PAGE_KERNEL));
  
!             __free_page(mem_map + i);
! 
              curr++;
              num_installed++;
          }
      }
  
      return num_installed;
  }
  
***************
*** 185,198 ****
  
      if ( num_pages > credit )
      {
!         printk("Can not allocate more pages than previously released.\n");
          return -EAGAIN;
      }
  
      parray = (unsigned long *)vmalloc(num_pages * sizeof(unsigned long));
      if ( parray == NULL )
      {
!         printk("inflate_balloon: Unable to vmalloc parray\n");
          return 0;
      }
  
--- 178,192 ----
  
      if ( num_pages > credit )
      {
!         printk(KERN_ERR "deflate_balloon: %d pages > %d credit.\n",
! 			num_pages, credit);
          return -EAGAIN;
      }
  
      parray = (unsigned long *)vmalloc(num_pages * sizeof(unsigned long));
      if ( parray == NULL )
      {
!         printk(KERN_ERR "deflate_balloon: Unable to vmalloc parray\n");
          return 0;
      }
  
***************
*** 202,215 ****
                                  parray, num_pages, 0);
      if ( unlikely(ret != num_pages) )
      {
!         printk("Unable to deflate balloon, error %lx\n", ret);
          goto cleanup;
      }
  
!     if ( (ret = process_new_pages(parray, num_pages)) < num_pages )
      {
!         printk("Unable to deflate balloon by specified %lx pages, only %lx.\n",
!                num_pages, ret);
          goto cleanup;
      }
  
--- 196,211 ----
                                  parray, num_pages, 0);
      if ( unlikely(ret != num_pages) )
      {
!         printk(KERN_ERR "deflate_balloon: xen increase_reservation err %lx\n",
! 			ret);
          goto cleanup;
      }
  
!     if ( (ret = process_returned_pages(parray, num_pages)) < num_pages )
      {
!         printk(KERN_WARNING
! 	   "deflate_balloon: restored only %lx of %lx pages.\n",
!            ret, num_pages);
          goto cleanup;
      }
  
***************
*** 224,243 ****
  
  #define PAGE_TO_MB_SHIFT 8
  
  static int balloon_write(struct file *file, const char *buffer,
                           u_long count, void *data)
  {
      char memstring[64], *endchar;
      int len, i;
!     unsigned long pages;
!     unsigned long long target;
  
      /* Only admin can play with the balloon :) */
      if ( !capable(CAP_SYS_ADMIN) )
          return -EPERM;
  
      if (count>sizeof memstring) {
! 	    return -EFBIG;
      }
  
      len = strnlen_user(buffer, count);
--- 220,389 ----
  
  #define PAGE_TO_MB_SHIFT 8
  
+ /*
+  * pagetable_extend() mimics pagetable_init() from arch/xen/mm/init.c 
+  * The loops do go through all of low memory (ZONE_NORMAL).  The
+  * old pages have _PAGE_PRESENT set and so get skipped.
+  * If low memory is not full, the new pages are used to fill it, going
+  * from cur_low_pfn to low_pfn.   high memory is not direct mapped so
+  * no extension is needed for new high memory.
+  */
+ 
+ static void pagetable_extend (int cur_low_pfn, int newpages)
+ {
+     unsigned long vaddr, end;
+     pgd_t *kpgd, *pgd, *pgd_base;
+     int i, j, k;
+     pmd_t *kpmd, *pmd;
+     pte_t *kpte, *pte, *pte_base;
+     int low_pfn = min(cur_low_pfn+newpages,(int)max_low_pfn);
+ 
+     /*
+      * This can be zero as well - no problem, in that case we exit
+      * the loops anyway due to the PTRS_PER_* conditions.
+      */
+     end = (unsigned long)__va(low_pfn*PAGE_SIZE);
+ 
+     pgd_base = init_mm.pgd;
+     i = __pgd_offset(PAGE_OFFSET);
+     pgd = pgd_base + i;
+ 
+     for (; i < PTRS_PER_PGD; pgd++, i++) {
+         vaddr = i*PGDIR_SIZE;
+         if (end && (vaddr >= end))
+             break;
+         pmd = (pmd_t *)pgd;
+         for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
+             vaddr = i*PGDIR_SIZE + j*PMD_SIZE;
+             if (end && (vaddr >= end))
+                 break;
+ 
+             /* Filled in for us already? */
+             if ( pmd_val(*pmd) & _PAGE_PRESENT )
+                 continue;
+ 
+             pte_base = pte = (pte_t *) __get_free_page(GFP_KERNEL);
+ 
+             for (k = 0; k < PTRS_PER_PTE; pte++, k++) {
+                 vaddr = i*PGDIR_SIZE + j*PMD_SIZE + k*PAGE_SIZE;
+                 if (end && (vaddr >= end))
+                     break;
+                 *pte = mk_pte_phys(__pa(vaddr), PAGE_KERNEL);
+             }
+             kpgd = pgd_offset_k((unsigned long)pte_base);
+             kpmd = pmd_offset(kpgd, (unsigned long)pte_base);
+             kpte = pte_offset(kpmd, (unsigned long)pte_base);
+             queue_l1_entry_update(kpte,
+                                   (*(unsigned long *)kpte)&~_PAGE_RW);
+             set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte_base)));
+             XEN_flush_page_update_queue();
+         }
+     }
+ }
+ 
+ /*
+  * claim_new_pages() asks xen to increase this domain's memory  reservation
+  * and return a list of the new pages of memory.  This new pages are
+  * added to the free list of the memory manager.
+  *
+  * Available RAM does not normally change while Linux runs.  To make this work,
+  * the linux mem= boottime command line param must say how big memory could
+  * possibly grow.  Then setup_arch() in arch/xen/kernel/setup.c
+  * sets max_pfn, max_low_pfn and the zones according to
+  * this max memory size.   The page tables themselves can only be
+  * extended after xen has assigned new pages to this domain.
+  */
+ 
+ static unsigned long
+ claim_new_pages(unsigned long num_pages)
+ {
+     unsigned long new_page_cnt, pfn;
+     unsigned long * parray, *curr;
+ 
+     if (most_seen_pages+num_pages> max_pfn)
+         num_pages = max_pfn-most_seen_pages;
+     if (num_pages==0) return 0;
+ 
+     parray = (unsigned long *)vmalloc(num_pages * sizeof(unsigned long));
+     if ( parray == NULL )
+     {
+         printk(KERN_ERR "claim_new_pages: Unable to vmalloc parray\n");
+         return 0;
+     }
+ 
+     XEN_flush_page_update_queue();
+     new_page_cnt = HYPERVISOR_dom_mem_op(MEMOP_increase_reservation, 
+                                 parray, num_pages, 0);
+     if (new_page_cnt != num_pages)
+     {
+         printk(KERN_WARNING
+             "claim_new_pages: xen granted only %lu of %lu requested pages\n",
+             new_page_cnt, num_pages);
+ 
+ 	/* XXX
+ 	 * avoid xen lockup when user forgot to setdomainmaxmem.  xen
+ 	 * usually can dribble out a few pages and then hangs
+ 	 */
+ 	if (new_page_cnt < 1000) {
+             printk(KERN_WARNING "Remember to use setdomainmaxmem\n");
+ 	    HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation, 
+                                 parray, new_page_cnt, 0);
+             return -EFAULT;
+ 	}
+     }
+     memcpy(phys_to_machine_mapping+most_seen_pages, parray,
+             new_page_cnt * sizeof(unsigned long));
+ 
+     pagetable_extend(most_seen_pages,new_page_cnt);
+ 
+     for (pfn = most_seen_pages, curr = parray;
+ 	    pfn < most_seen_pages+new_page_cnt;
+             pfn++, curr++ )
+     {
+         struct page *page = mem_map + pfn;
+ 
+ #ifndef CONFIG_HIGHMEM
+ 	if (pfn>=max_low_pfn) {
+             printk(KERN_WARNING "Warning only %ldMB will be used.\n",
+                pfn>>PAGE_TO_MB_SHIFT);
+             printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
+ 	    break;
+ 	}
+ #endif
+ 	queue_machphys_update(*curr, pfn);
+ 	XEN_flush_page_update_queue();
+ 	if (pfn<max_low_pfn)  {
+ 		queue_l1_entry_update(get_ptep((unsigned long)__va(pfn << PAGE_SHIFT)),
+ 			((*curr) << PAGE_SHIFT) | pgprot_val(PAGE_KERNEL));
+ 		XEN_flush_page_update_queue();
+ 		}
+ 
+         /* this next bit mimics arch/xen/mm/init.c:one_highpage_init() */
+         ClearPageReserved(page);
+         if (pfn>=max_low_pfn) set_bit(PG_highmem, &page->flags);
+         set_page_count(page, 1);
+         __free_page(page);
+     }
+ 
+     vfree(parray);
+ 
+     return new_page_cnt;
+ }
+ 
  static int balloon_write(struct file *file, const char *buffer,
                           u_long count, void *data)
  {
      char memstring[64], *endchar;
      int len, i;
!     unsigned long target;
!     unsigned long long targetbytes;
  
      /* Only admin can play with the balloon :) */
      if ( !capable(CAP_SYS_ADMIN) )
          return -EPERM;
  
      if (count>sizeof memstring) {
!         return -EFBIG;
      }
  
      len = strnlen_user(buffer, count);
***************
*** 248,300 ****
  
      endchar = memstring;
      for(i=0; i<len; ++i,++endchar) {
! 	    if ('0'>memstring[i] || memstring[i]>'9') break;
      }
      if (i==0) return -EBADMSG;
  
!     target = memparse(memstring,&endchar);
!     pages = target >> PAGE_SHIFT;
  
!     if (pages < current_pages) {
! 	    int change = inflate_balloon(current_pages-pages);
! 	    if (change<0) return change;
! 
! 	    current_pages -= change;
!     	    printk("Relinquish %dMB to xen. Domain now has %ldMB\n",
! 		    change>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT);
!     }
!     else if (pages > current_pages) {
! 	    int change = deflate_balloon(min(pages,max_pages) - current_pages);
! 	    if (change<0) return change;
! 
! 	    current_pages += change;
!     	    printk("Reclaim %dMB from xen. Domain now has %ldMB\n",
! 		    change>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT);
      }
  
      return len;
  }
  
  
  static int balloon_read(char *page, char **start, off_t off,
! 	  int count, int *eof, void *data)
  {
! 	int len;
! 	len = sprintf(page,"%lu\n",current_pages<<PAGE_SHIFT);
  
! 	if (len <= off+count) *eof = 1;
! 	*start = page + off;
! 	len -= off;
! 	if (len>count) len = count;
! 	if (len<0) len = 0;
! 	return len;
  }
  
  static int __init init_module(void)
  {
      printk(KERN_ALERT "Starting Xen Balloon driver\n");
  
!     max_pages = current_pages = start_info.nr_pages;
      if ( (balloon_pde = create_xen_proc_entry("memory_target", 0644)) == NULL )
      {
          printk(KERN_ALERT "Unable to create balloon driver proc entry!");
--- 394,459 ----
  
      endchar = memstring;
      for(i=0; i<len; ++i,++endchar) {
!         if ('0'>memstring[i] || memstring[i]>'9') break;
      }
      if (i==0) return -EBADMSG;
  
!     targetbytes = memparse(memstring,&endchar);
!     target = targetbytes >> PAGE_SHIFT;
! 
!     if (target < current_pages) {
!         int change = inflate_balloon(current_pages-target);
!         if (change<=0) return change;
! 
!         current_pages -= change;
!         printk(KERN_INFO "Relinquish %dMB to xen. Domain now has %luMB\n",
!             change>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT);
!     }
!     else if (target > current_pages) {
!         int change, reclaim = min(target,most_seen_pages) - current_pages;
! 
!         if (reclaim) {
!             change = deflate_balloon( reclaim);
!             if (change<=0) return change;
!             current_pages += change;
!             printk(KERN_INFO "Reclaim %dMB from xen. Domain now has %luMB\n",
!                 change>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT);
!         }
  
!         if (most_seen_pages<target) {
!             int growth = claim_new_pages(target-most_seen_pages);
! 	    if (growth<=0) return growth;
!             most_seen_pages += growth;
!             current_pages += growth;
!             printk(KERN_INFO "Granted %dMB new mem by xen. Domain now has %luMB\n",
!                 growth>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT);
!         }
      }
  
+ 
      return len;
  }
  
  
  static int balloon_read(char *page, char **start, off_t off,
!       int count, int *eof, void *data)
  {
!     int len;
!     len = sprintf(page,"%lu\n",current_pages<<PAGE_SHIFT);
  
!     if (len <= off+count) *eof = 1;
!     *start = page + off;
!     len -= off;
!     if (len>count) len = count;
!     if (len<0) len = 0;
!     return len;
  }
  
  static int __init init_module(void)
  {
      printk(KERN_ALERT "Starting Xen Balloon driver\n");
  
!     most_seen_pages = current_pages = min(start_info.nr_pages,max_pfn);
      if ( (balloon_pde = create_xen_proc_entry("memory_target", 0644)) == NULL )
      {
          printk(KERN_ALERT "Unable to create balloon driver proc entry!");
***************
*** 303,308 ****
--- 462,478 ----
  
      balloon_pde->write_proc = balloon_write;
      balloon_pde->read_proc = balloon_read;
+ 
+     /* 
+      * make a new phys map if mem= says xen can give us memory  to grow
+      */
+     if (max_pfn > start_info.nr_pages) {
+         extern unsigned long *phys_to_machine_mapping;
+         unsigned long *newmap;
+         newmap = (unsigned long *)vmalloc(max_pfn * sizeof(unsigned long));
+         phys_to_machine_mapping = memcpy(newmap, phys_to_machine_mapping,
+             start_info.nr_pages * sizeof(unsigned long));
+     }
  
      return 0;
  }
===== linux-2.4.26-xen-sparse/arch/xen/kernel/setup.c 1.51 vs edited =====
*** /tmp/setup.c-1.51-11013	Wed Jul 14 10:26:02 2004
--- edited/linux-2.4.26-xen-sparse/arch/xen/kernel/setup.c	Fri Aug  6 10:55:06 2004
***************
*** 120,129 ****
  static char command_line[COMMAND_LINE_SIZE];
  char saved_command_line[COMMAND_LINE_SIZE];
  
! static void __init parse_mem_cmdline (char ** cmdline_p)
  {
      char c = ' ', *to = command_line, *from = saved_command_line;
      int len = 0;
  
      /* Save unparsed command line copy for /proc/cmdline */
      memcpy(saved_command_line, start_info.cmd_line, COMMAND_LINE_SIZE);
--- 120,134 ----
  static char command_line[COMMAND_LINE_SIZE];
  char saved_command_line[COMMAND_LINE_SIZE];
  
! /* parse_mem_cmdline()
!  * returns the value of the mem= boot param converted to pages or 0
!  */ 
! static int __init parse_mem_cmdline (char ** cmdline_p)
  {
      char c = ' ', *to = command_line, *from = saved_command_line;
      int len = 0;
+     unsigned long long bytes;
+     int mem_param = 0;
  
      /* Save unparsed command line copy for /proc/cmdline */
      memcpy(saved_command_line, start_info.cmd_line, COMMAND_LINE_SIZE);
***************
*** 145,152 ****
              } else if (!memcmp(from+4, "exactmap", 8)) {
                  from += 8+4;
              } else {
!                 (void)memparse(from+4, &from);
!                 if (*from == '@')
                      (void)memparse(from+1, &from);
              }
          }
--- 150,158 ----
              } else if (!memcmp(from+4, "exactmap", 8)) {
                  from += 8+4;
              } else {
!                 bytes = memparse(from+4, &from);
!                 mem_param = bytes>>PAGE_SHIFT;
! 		if (*from == '@')
                      (void)memparse(from+1, &from);
              }
          }
***************
*** 160,165 ****
--- 166,173 ----
      }
      *to = '\0';
      *cmdline_p = command_line;
+ 
+     return mem_param;
  }
  
  /*
***************
*** 194,200 ****
  
  void __init setup_arch(char **cmdline_p)
  {
!     unsigned long bootmap_size, start_pfn, max_low_pfn;
  
      extern void hypervisor_callback(void);
      extern void failsafe_callback(void);
--- 202,210 ----
  
  void __init setup_arch(char **cmdline_p)
  {
!     unsigned long bootmap_size, start_pfn, lmax_low_pfn;
!     int mem_param;  /* user specified memory size in pages */
!     int boot_pfn;   /* low pages available for bootmem */
  
      extern void hypervisor_callback(void);
      extern void failsafe_callback(void);
***************
*** 252,258 ****
      init_mm.end_data = (unsigned long) &_edata;
      init_mm.brk = (unsigned long) &_end;
  
!     parse_mem_cmdline(cmdline_p);
  
  #define PFN_UP(x)	(((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
  #define PFN_DOWN(x)	((x) >> PAGE_SHIFT)
--- 262,277 ----
      init_mm.end_data = (unsigned long) &_edata;
      init_mm.brk = (unsigned long) &_end;
  
!     /* The mem= kernel command line param overrides the detected amount
!      * of memory.   For xenolinux, if this override is larger than detected
!      * memory, then boot using only detected memory and make provisions to
!      * use all of the override value.   The hypervisor can give this
!      * domain more memory later on and it will be added to the free
!      * lists at that time.   See claim_new_pages() in
!      * arch/xen/drivers/balloon/balloon.c
!      */
!     mem_param = parse_mem_cmdline(cmdline_p);
!     if (!mem_param) mem_param = start_info.nr_pages;
  
  #define PFN_UP(x)	(((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
  #define PFN_DOWN(x)	((x) >> PAGE_SHIFT)
***************
*** 269,277 ****
      /*
       * Determine low and high memory ranges:
       */
!     max_low_pfn = max_pfn = start_info.nr_pages;
!     if (max_low_pfn > MAXMEM_PFN) {
!         max_low_pfn = MAXMEM_PFN;
  #ifndef CONFIG_HIGHMEM
          /* Maximum memory usable is what is directly addressable */
          printk(KERN_WARNING "Warning only %ldMB will be used.\n",
--- 288,296 ----
      /*
       * Determine low and high memory ranges:
       */
!     lmax_low_pfn = max_pfn = mem_param;
!     if (lmax_low_pfn > MAXMEM_PFN) {
!         lmax_low_pfn = MAXMEM_PFN;
  #ifndef CONFIG_HIGHMEM
          /* Maximum memory usable is what is directly addressable */
          printk(KERN_WARNING "Warning only %ldMB will be used.\n",
***************
*** 314,324 ****
       * bootstrap page table. We are guaranteed to get >=512kB unused 'padding'
       * for our own use after all bootstrap elements (see hypervisor-if.h).
       */
!     bootmap_size = init_bootmem(start_pfn, max_low_pfn);
!     free_bootmem(0, PFN_PHYS(max_low_pfn));
      reserve_bootmem(__pa(&_stext), 
                      PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE-1 - 
                      __pa(&_stext));
  
  #ifdef CONFIG_BLK_DEV_INITRD
      if ( start_info.mod_start != 0 )
--- 333,351 ----
       * bootstrap page table. We are guaranteed to get >=512kB unused 'padding'
       * for our own use after all bootstrap elements (see hypervisor-if.h).
       */
!     boot_pfn = min((int)start_info.nr_pages,lmax_low_pfn);
!     bootmap_size = init_bootmem(start_pfn,boot_pfn);
!     free_bootmem(0, PFN_PHYS(boot_pfn));
      reserve_bootmem(__pa(&_stext), 
                      PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE-1 - 
                      __pa(&_stext));
+ 
+     /* init_bootmem() set the global max_low_pfn to boot_pfn.  Now max_low_pfn 
+      * can be set to the override value.
+      */
+     max_low_pfn = lmax_low_pfn;
+ 
+ 
  
  #ifdef CONFIG_BLK_DEV_INITRD
      if ( start_info.mod_start != 0 )
===== linux-2.4.26-xen-sparse/arch/xen/mm/init.c 1.20 vs edited =====
*** /tmp/init.c-1.20-11013	Wed Jun  9 11:46:56 2004
--- edited/linux-2.4.26-xen-sparse/arch/xen/mm/init.c	Thu Aug  5 17:00:28 2004
***************
*** 219,229 ****
      pmd_t *kpmd, *pmd;
      pte_t *kpte, *pte, *pte_base;
  
      /*
       * This can be zero as well - no problem, in that case we exit
       * the loops anyway due to the PTRS_PER_* conditions.
       */
!     end = (unsigned long)__va(max_low_pfn*PAGE_SIZE);
  
      pgd_base = init_mm.pgd;
      i = __pgd_offset(PAGE_OFFSET);
--- 219,235 ----
      pmd_t *kpmd, *pmd;
      pte_t *kpte, *pte, *pte_base;
  
+     /* create tables only for boot_pfn frames.  max_low_pfn may be sized for
+      * pages yet to be allocated from the hypervisor, or it may be set
+      * to override the start_info amount of memory
+      */
+     int boot_pfn = min(start_info.nr_pages,max_low_pfn);
+ 
      /*
       * This can be zero as well - no problem, in that case we exit
       * the loops anyway due to the PTRS_PER_* conditions.
       */
!     end = (unsigned long)__va(boot_pfn *PAGE_SIZE);
  
      pgd_base = init_mm.pgd;
      i = __pgd_offset(PAGE_OFFSET);
***************
*** 308,314 ****
      pagetable_init();
  
      zone_sizes_init();
- 
      /* Switch to the real shared_info page, and clear the dummy page. */
      set_fixmap(FIX_SHARED_INFO, start_info.shared_info);
      HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
--- 314,319 ----
***************
*** 368,378 ****
  #endif
      int reservedpages, pfn;
  
      /* this will put all low memory onto the freelists */
      totalram_pages += free_all_bootmem();
  
      reservedpages = 0;
!     for (pfn = 0; pfn < max_low_pfn; pfn++) {
          /*
           * Only count reserved RAM pages
           */
--- 373,390 ----
  #endif
      int reservedpages, pfn;
  
+     /* add only boot_pfn pages of low memory to free list.
+      * max_low_pfn may be sized for
+      * pages yet to be allocated from the hypervisor, or it may be set
+      * to override the start_info amount of memory
+      */
+     int boot_pfn = min(start_info.nr_pages,max_low_pfn);
+ 
      /* this will put all low memory onto the freelists */
      totalram_pages += free_all_bootmem();
  
      reservedpages = 0;
!     for (pfn = 0; pfn < boot_pfn ; pfn++) {
          /*
           * Only count reserved RAM pages
           */
***************
*** 380,386 ****
              reservedpages++;
      }
  #ifdef CONFIG_HIGHMEM
!     for (pfn = highend_pfn-1; pfn >= highstart_pfn; pfn--)
          one_highpage_init((struct page *) (mem_map + pfn), pfn, bad_ppro);
      totalram_pages += totalhigh_pages;
  #endif
--- 392,398 ----
              reservedpages++;
      }
  #ifdef CONFIG_HIGHMEM
!     for (pfn = start_info.nr_pages-1; pfn >= highstart_pfn; pfn--)
          one_highpage_init((struct page *) (mem_map + pfn), pfn, bad_ppro);
      totalram_pages += totalhigh_pages;
  #endif
***************
*** 460,470 ****
  
  void si_meminfo(struct sysinfo *val)
  {
!     val->totalram = totalram_pages;
      val->sharedram = 0;
      val->freeram = nr_free_pages();
      val->bufferram = atomic_read(&buffermem_pages);
!     val->totalhigh = totalhigh_pages;
      val->freehigh = nr_free_highpages();
      val->mem_unit = PAGE_SIZE;
      return;
--- 472,482 ----
  
  void si_meminfo(struct sysinfo *val)
  {
!     val->totalram = max_pfn;
      val->sharedram = 0;
      val->freeram = nr_free_pages();
      val->bufferram = atomic_read(&buffermem_pages);
!     val->totalhigh = max_pfn-max_low_pfn;
      val->freehigh = nr_free_highpages();
      val->mem_unit = PAGE_SIZE;
      return;
*** /dev/null	Tue Jul 13 09:55:35 2004
--- setdomainmaxmem	Fri Aug  6 11:40:20 2004
***************
*** 0 ****
--- 1,34 ----
+ #!/usr/bin/env perl
+ 
+ use strict;
+ require "sys/ioctl.ph";
+ 
+ sub SIZEOF_HYPERCALL () { 24; }
+ sub STRUCT_PRIVCMD_HYPERCALL () {"L P";}
+ sub IOCTL_PRIVCMD_HYPERCALL ()
+         { &_IOC( &_IOC_NONE, ord('P'), 0, SIZEOF_HYPERCALL );}
+ sub __HYPERVISOR_dom0_op () {7;}
+ sub DOM0_INTERFACE_VERSION () {0xaaaa0010;}
+ sub DOM0_SETDOMAINMAXMEM () {28;}
+ sub STRUCT_DOM0_OP_PREFIX () {"L L";}
+ sub STRUCT_SETDOMAINMAXMEM () {STRUCT_DOM0_OP_PREFIX."L x4 L";}
+ sub XEN_PRIVCMD () {"/proc/xen/privcmd";}
+ 
+ sub setdomainmaxmem($$) {
+     my ($domain,$bytes) = @_;
+     my $msg = pack(STRUCT_SETDOMAINMAXMEM,DOM0_SETDOMAINMAXMEM,
+         DOM0_INTERFACE_VERSION,  $domain, $bytes);
+     my $cmd = pack(STRUCT_PRIVCMD_HYPERCALL,__HYPERVISOR_dom0_op,$msg);
+     open(XEN,XEN_PRIVCMD) or die "$!\n";
+     ioctl(XEN, IOCTL_PRIVCMD_HYPERCALL, $cmd) or die "ioctl: $!";
+     close XEN;
+ }
+ 
+ my ($bytes,$suffix) = $ARGV[1] =~ m/(^\d+)([mMkKgG])/;
+ $bytes<<=10 if $suffix =~ m/[kK]/;
+ $bytes<<=20 if $suffix =~ m/[mM]/;
+ $bytes<<=30 if $suffix =~ m/[gG]/;
+ 
+ printf "set domain $ARGV[0] to $bytes\n";
+ setdomainmaxmem($ARGV[0],$bytes);
+ 


-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com

^ permalink raw reply	[relevance 6%]

* Unknown boot option
@ 2004-08-08  2:58  4% Daisaku Watanabe
  0 siblings, 0 replies; 200+ results
From: Daisaku Watanabe @ 2004-08-08  2:58 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 2045 bytes --]

folks,

I'm trying to satrtup xen-unstable with linux kernel-2.6.7
but seems I need little bit more luck.

[Symptom]
 - got kernel pacnic in the boot process.
   It says
     ..(snip)
     > Kernel command line: /xen/vmlinuz-2.6.7-xen0 root=/dev/sda3 ro console=tty0 console=ttyS0
     > Unknown boot option `/xen/vmlinuz-2.6.7-xen0': ignoring
     > Initializing CPU#0
     > ...(snip)
     > ICH6: not 100% native mode: will probe irqs later
     > ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:DMA, hdb:DMA
     > ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:pio, hdd:pio
     > invalid operand: 0000 [#1]
     > PREEMPT 
     > Modules linked in:
     > CPU:    0
     > EIP:    0061:[<c010e20d>]    Not tainted
     > EFLAGS: 00211246   (2.6.7-xen0) 
     > EIP is at mwait_idle+0x31/0x67
     > eax: c03d4008   ebx: c03d4008   ecx: 00000000   edx: 00000000
     > esi: c03d4000   edi: c04456e0   ebp: 00000000   esp: c03d5fc8
     > ds: 007b   es: 007b   ss: 0069
     > Process swapper (pid: 0, threadinfo=c03d4000 task=c0376ec0)
     > Stack: 00000000 c03d4000 c0499200 c010e1d3 c03d4000 c03d6682 c0376ec0 00000000 
     > c0434f58 00000021 c03d63df c0445d00 00020800 c010009b 
     > Call Trace:
     > c03d5fc8: [<c010e1d3>] cpu_idle+0x2c/0x35
     > c03d5fd0: [<c03d6682>] start_kernel+0x16c/0x197
     > c03d5fe4: [<c03d63df>] unknown_bootoption+0x0/0x110
     >
     > Code: 0f 01 c8 8b 46 08 a8 08 75 0c 89 c8 0f 01 c9 8b 46 08 a8 08 
     > <0>Kernel panic: Attempted to kill the idle task!
     > In idle task - not syncing

 I attatched full boot log as "xen-2.0-k267.log".

 - kernel 2.4.26 looks OK. Please refer attached file "xen-2.0_k2426_boot.log".
 - Xen DemoCD v1.2 works fine as well.


[I did]
 - use vanilla 2.4.26, 2.6.7 kernels
 - make world
 - make linux26
 to create all xen, -xen0, -xenU kernels

 - xen-unatable was pulled yesterday (7th Aug).
 - add boot option "ignorebiostables", "noacpi" but no help


Any advice to step forward would be very appreciated.
Thanks very much.

Best regards,
Daisaku 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xen-2.0-k267.log --]
[-- Type: text/x-log; name="xen-2.0-k267.log", Size: 8823 bytes --]

 __  __            _   _____        _                _ 
 \ \/ /___ _ __   / | |___ /     __| | _____   _____| |
  \  // _ \ '_ \  | |   |_ \ __ / _` |/ _ \ \ / / _ \ |
  /  \  __/ | | | | |_ ___) |__| (_| |  __/\ V /  __/ |
 /_/\_\___|_| |_| |_(_)____/    \__,_|\___| \_/ \___|_|
                                                       
 http://www.cl.cam.ac.uk/netos/xen
 University of Cambridge Computer Laboratory

 Xen version 1.3-devel (dwata@honeypie.net) (gcc ¥Ð¡¼¥¸¥ç¥ó 3.3.3 20040412 (Gent
oo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)) 2004ǯ 8·î 7Æü ÅÚÍËÆü 11:24:55 JST

(XEN) Initialised 503MB memory (128976 pages) on a 503MB machine
(XEN) Xen heap size is 10668KB
(XEN) CPU0: Before vendor init, caps: bfebfbff 00000000 00000000, vendor = 0
(XEN) CPU#0: Physical ID: 0, Logical ID: 0
(XEN) CPU caps: bfebfbff 00000000 00000000 00000000
(XEN) found SMP MP-table at 000ff780
(XEN) Memory Reservation 0xff780, 4096 bytes
(XEN) Memory Reservation 0xfbf00, 4096 bytes
(XEN) ACPI: RSDP (v000 ACPIAM                                    ) @ 0x000f8800
(XEN) ACPI: RSDT (v001 A M I  OEMRSDT  0x07000414 MSFT 0x00000097) @ 0x1f7d0000
(XEN) ACPI: FADT (v002 A M I  OEMFACP  0x07000414 MSFT 0x00000097) @ 0x1f7d0200
(XEN) ACPI: MADT (v001 A M I  OEMAPIC  0x07000414 MSFT 0x00000097) @ 0x1f7d0390
(XEN) ACPI: OEMB (v001 A M I  AMI_OEM  0x07000414 MSFT 0x00000097) @ 0x1f7de040
(XEN) ACPI: MCFG (v001 A M I  OEMMCFG  0x07000414 MSFT 0x00000097) @ 0x1f7d42a0
(XEN) ACPI: DSDT (v001  0AAAA 0AAAA000 0x00000000 INTL 0x02002026) @ 0x00000000
(XEN) ACPI: Local APIC address 0xfee00000
(XEN) ACPI: LAPIC (acpi_id[0x01] lapic_id[0x00] enabled)
(XEN) Processor #0 Unknown CPU [15:3] APIC version 20
(XEN) ACPI: LAPIC (acpi_id[0x02] lapic_id[0x01] enabled)
(XEN) Processor #1 Unknown CPU [15:3] APIC version 20
(XEN) Using ACPI for processor (LAPIC) configuration information
(XEN) Intel MultiProcessor Specification v1.4
(XEN)     Virtual Wire compatibility mode.
(XEN) OEM ID: TEMPLATE Product ID: ETEMPLATE    APIC at: 0xFEE00000
(XEN) I/O APIC #2 Version 32 at 0xFEC00000.
(XEN) Enabling APIC mode: Flat.	Using 1 I/O APICs
(XEN) Processors: 2
(XEN) Using scheduler: Borrowed Virtual Time (bvt)
(XEN) Initializing CPU#0
(XEN) Detected 2800.239 MHz processor.
(XEN) CPU0: Before vendor init, caps: bfebfbff 00000000 00000000, vendor = 0
(XEN) CPU#0: Physical ID: 0, Logical ID: 0
(XEN) CPU caps: bfebfbff 00000000 00000000 00000000
(XEN) CPU0 booted
(XEN) enabled ExtINT on CPU#0
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) Booting processor 1/1 eip 90000
(XEN) Initializing CPU#1
(XEN) masked ExtINT on CPU#1
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) CPU1: Before vendor init, caps: bfebfbff 00000000 00000000, vendor = 0
(XEN) CPU#1: Physical ID: 0, Logical ID: 1
(XEN) CPU caps: bfebfbff 00000000 00000000 00000000
(XEN) CPU1 has booted.
(XEN) Total of 2 processors activated.
(XEN) ENABLING IO-APIC IRQs
(XEN) Setting 2 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 2 ... ok.
(XEN) init IO_APIC IRQs
(XEN) ..TIMER: vector=0x41 pin1=2 pin2=0
(XEN) Using local APIC timer interrupts.
(XEN) Calibrating APIC timer for CPU0...
(XEN) ..... CPU speed is 2800.2091 MHz.
(XEN) ..... Bus speed is 200.0148 MHz.
(XEN) ..... bus_scale = 0x0000CCD7
(XEN) checking TSC synchronization across CPUs: passed.
(XEN) Time init:
(XEN) .... System Time: 20001299ns
(XEN) .... cpu_freq:    00000000:A6E84210
(XEN) .... scale:       00000001:6DAEDCC8
(XEN) .... Wall Clock:  1091929202s 150000us
(XEN) PCI: PCI BIOS revision 2.10 entry at 0xf0031, last bus=2
(XEN) PCI: Using configuration type 1
(XEN) PCI: Probing PCI hardware
(XEN) PCI: Probing PCI hardware (bus 00)
(XEN) PCI: Ignoring BAR0-3 of IDE controller 00:1f.1
(XEN) Transparent bridge - PCI device 8086:244e
(XEN) PCI: Discovered primary peer bus 01 [IRQ]
(XEN) PCI: Discovered primary peer bus ff [IRQ]
(XEN) PCI: Using IRQ router default [8086/2640] at 00:1f.0
(XEN) PCI->APIC IRQ transform: (B0,I2,P0) -> 16
(XEN) PCI->APIC IRQ transform: (B0,I27,P0) -> 16
(XEN) PCI->APIC IRQ transform: (B0,I29,P0) -> 23
(XEN) PCI->APIC IRQ transform: (B0,I29,P1) -> 19
(XEN) PCI->APIC IRQ transform: (B0,I29,P2) -> 18
(XEN) PCI->APIC IRQ transform: (B0,I29,P3) -> 16
(XEN) PCI->APIC IRQ transform: (B0,I29,P0) -> 23
(XEN) PCI->APIC IRQ transform: (B0,I31,P0) -> 18
(XEN) PCI->APIC IRQ transform: (B0,I31,P1) -> 19
(XEN) PCI->APIC IRQ transform: (B0,I31,P1) -> 19
(XEN) PCI->APIC IRQ transform: (B2,I4,P0) -> 20
(XEN) PCI->APIC IRQ transform: (B2,I6,P0) -> 21
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found: 'GUEST_OS=linux,GUEST_VER=2.6,XEN_VER=1.3'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  02800000->02b4c1fc
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->0ac00000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0100000->c04753a4
(XEN)  Init. ramdisk: c0476000->c0476000
(XEN)  Phys-Mach map: c0476000->c0496000
(XEN)  Page tables:   c0496000->c0499000
(XEN)  Start info:    c0499000->c049a000
(XEN)  Boot stack:    c049a000->c049b000
(XEN)  TOTAL:         c0100000->c0800000
(XEN)  ENTRY ADDRESS: c0100000
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen
).
Linux version 2.6.7-xen0 (dwata@thrones.honeypie.net) (gcc ????? 3.3.3 20040412 
(Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)) #1 Sat Aug 7 09:36:02 JST 2004
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000008000000 (usable)
128MB LOWMEM available.
On node 0 totalpages: 32768
  DMA zone: 4096 pages, LIFO batch:1
  Normal zone: 28672 pages, LIFO batch:7
  HighMem zone: 0 pages, LIFO batch:1
DMI not present.
Built 1 zonelists
Kernel command line: /xen/vmlinuz-2.6.7-xen0 root=/dev/sda3 ro console=tty0 cons
ole=ttyS0
Unknown boot option `/xen/vmlinuz-2.6.7-xen0': ignoring
Initializing CPU#0
PID hash table entries: 1024 (order 10: 8192 bytes)
Xen reported: 2800.239 MHz processor.
Using tsc for high-res timesource
Console: colour VGA+ 80x25
Memory: 125988k/131072k available (2186k kernel code, 4900k reserved, 704k data,
 432k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Calibrating delay loop... 5596.77 BogoMIPS
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
monitor/mwait feature present.
using mwait in idle threads.
CPU: Trace cache: 12K uops, L1 D cache: 16K
CPU: L2 cache: 1024K
CPU: Intel(R) Pentium(R) 4 CPU 2.80GHz stepping 04
Enabling fast FPU save and restore... done.
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... disabled
NET: Registered protocol family 16
PCI: Using configuration type Xen
SCSI subsystem initialized
PCI: Probing PCI hardware
PCI: Probing PCI hardware (bus 00)
PCI: Probing PCI hardware (bus 02)
PCI: Probing PCI hardware
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
Intel(R) PRO/1000 Network Driver - version 5.2.52-k4
Copyright (c) 1999-2004 Intel Corporation.
pcnet32.c:v1.30c 05.25.2004 tsbogend@alpha.franken.de
e100: Intel(R) PRO/100 Network Driver, 3.0.18
e100: Copyright(c) 1999-2004 Intel Corporation
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
ICH6: IDE controller at PCI slot 0000:00:1f.1
PCI: Obtained IRQ 18 for device 0000:00:1f.1
ICH6: chipset revision 3
ICH6: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:DMA, hdb:DMA
    ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:pio, hdd:pio
invalid operand: 0000 [#1]
PREEMPT 
Modules linked in:
CPU:    0
EIP:    0061:[<c010e20d>]    Not tainted
EFLAGS: 00211246   (2.6.7-xen0) 
EIP is at mwait_idle+0x31/0x67
eax: c03d4008   ebx: c03d4008   ecx: 00000000   edx: 00000000
esi: c03d4000   edi: c04456e0   ebp: 00000000   esp: c03d5fc8
ds: 007b   es: 007b   ss: 0069
Process swapper (pid: 0, threadinfo=c03d4000 task=c0376ec0)
Stack: 00000000 c03d4000 c0499200 c010e1d3 c03d4000 c03d6682 c0376ec0 00000000 
       c0434f58 00000021 c03d63df c0445d00 00020800 c010009b 
Call Trace:
 c03d5fc8: [<c010e1d3>] cpu_idle+0x2c/0x35
 c03d5fd0: [<c03d6682>] start_kernel+0x16c/0x197
 c03d5fe4: [<c03d63df>] unknown_bootoption+0x0/0x110

Code: 0f 01 c8 8b 46 08 a8 08 75 0c 89 c8 0f 01 c9 8b 46 08 a8 08 
 <0>Kernel panic: Attempted to kill the idle task!
In idle task - not syncing
 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: xen-2.0_k2426_boot.log --]
[-- Type: text/x-log; name="xen-2.0_k2426_boot.log", Size: 6700 bytes --]

 __  __            _   _____        _                _ 
 \ \/ /___ _ __   / | |___ /     __| | _____   _____| |
  \  // _ \ '_ \  | |   |_ \ __ / _` |/ _ \ \ / / _ \ |
  /  \  __/ | | | | |_ ___) |__| (_| |  __/\ V /  __/ |
 /_/\_\___|_| |_| |_(_)____/    \__,_|\___| \_/ \___|_|
                                                       
 http://www.cl.cam.ac.uk/netos/xen
 University of Cambridge Computer Laboratory

 Xen version 1.3-devel (dwata@honeypie.net) (gcc ¥Ð¡¼¥¸¥ç¥ó 3.3.3 20040412 (Gent
oo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)) 2004ǯ 8·î 7Æü ÅÚÍËÆü 11:24:55 JST

(XEN) Initialised 503MB memory (128976 pages) on a 503MB machine
(XEN) Xen heap size is 10668KB
(XEN) CPU0: Before vendor init, caps: bfebfbff 00000000 00000000, vendor = 0
(XEN) CPU#0: Physical ID: 0, Logical ID: 0
(XEN) CPU caps: bfebfbff 00000000 00000000 00000000
(XEN) Using scheduler: Borrowed Virtual Time (bvt)
(XEN) Initializing CPU#0
(XEN) Detected 2800.231 MHz processor.
(XEN) Found and enabled local APIC!
(XEN) enabled ExtINT on CPU#0
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) Using local APIC timer interrupts.
(XEN) Calibrating APIC timer for CPU0...
(XEN) ..... CPU speed is 2800.0730 MHz.
(XEN) ..... Bus speed is 200.0051 MHz.
(XEN) ..... bus_scale = 0x0000CCD7
(XEN) Time init:
(XEN) .... System Time: 12145214ns
(XEN) .... cpu_freq:    00000000:A6E823FC
(XEN) .... scale:       00000001:6DAF1EAE
(XEN) .... Wall Clock:  1091959503s 30000us
(XEN) PCI: PCI BIOS revision 2.10 entry at 0xf0031, last bus=2
(XEN) PCI: Using configuration type 1
(XEN) PCI: Probing PCI hardware
(XEN) PCI: Probing PCI hardware (bus 00)
(XEN) PCI: Ignoring BAR0-3 of IDE controller 00:1f.1
(XEN) Transparent bridge - PCI device 8086:244e
(XEN) PCI: Discovered primary peer bus 01 [IRQ]
(XEN) PCI: Discovered primary peer bus ff [IRQ]
(XEN) PCI: Using IRQ router default [8086/2640] at 00:1f.0
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found: 'GUEST_OS=linux,GUEST_VER=2.4,XEN_VER=1.3,VIRT_BASE=
0xC0000000'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  02800000->02b018fc
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->0ac00000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0100000->c044e9ec
(XEN)  Init. ramdisk: c044f000->c044f000
(XEN)  Phys-Mach map: c044f000->c046f000
(XEN)  Page tables:   c046f000->c0472000
(XEN)  Start info:    c0472000->c0473000
(XEN)  Boot stack:    c0473000->c0474000
(XEN)  TOTAL:         c0000000->c0800000
(XEN)  ENTRY ADDRESS: c0100000
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen
).
Linux version 2.4.26-xen0 (dwata@thrones.honeypie.net) (gcc ¥Ð¡¼¥¸¥ç¥ó 3.3.3 200
40412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)) #4 2004ǯ 8·î 7Æü ÅÚÍËÆü 
11:24:44 JST
On node 0 totalpages: 32768
zone(0): 4096 pages.
zone(1): 28672 pages.
zone(2): 0 pages.
Kernel command line: /xen/vmlinuz-2.4.26-xen0 root=/dev/sda3 ro console=tty0 con
sole=ttyS0
Initializing CPU#0
Xen reported: 2800.231 MHz processor.
Console: colour VGA+ 80x25
Linux version 2.4.26-xen0 (dwata@thrones.honeypie.net) (gcc ¥Ð¡¼¥¸¥ç¥ó 3.3.3 200
40412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)) #4 2004ǯ 8·î 7Æü ÅÚÍËÆü 
11:24:44 JST
On node 0 totalpages: 32768
zone(0): 4096 pages.
zone(1): 28672 pages.
zone(2): 0 pages.
Kernel command line: /xen/vmlinuz-2.4.26-xen0 root=/dev/sda3 ro console=tty0 con
sole=ttyS0
Initializing CPU#0
Xen reported: 2800.231 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 5596.77 BogoMIPS
Memory: 125996k/131072k available (2271k kernel code, 5076k reserved, 666k data,
 116k init, 0k highmem)
Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
Inode cache hash table entries: 8192 (order: 4, 65536 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 8192 (order: 3, 32768 bytes)
Page-cache hash table entries: 32768 (order: 5, 131072 bytes)
CPU: L1 I cache: 12K, L1 D cache: 0K
CPU: L2 cache: 1024K
CPU: Intel(R) Pentium(R) 4 CPU 2.80GHz stepping 04
POSIX conformance testing by UNIFIX
PCI: Probing PCI hardware
PCI: Probing PCI hardware (bus 00)
PCI: Probing PCI hardware (bus 02)
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed as ttyS
Starting Xen Balloon driver
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
Intel(R) PRO/1000 Network Driver - version 5.2.30.1-k1
Copyright (c) 1999-2004 Intel Corporation.
pcnet32.c:v1.28 02.20.2004 tsbogend@alpha.franken.de
Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
ICH6: IDE controller at PCI slot 00:1f.1
PCI: No IRQ known for interrupt pin A of device 00:1f.1.
ICH6: chipset revision 3
ICH6: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:DMA, hdb:DMA
    ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:pio, hdd:pio
hda: C/H/S=0/0/0 from BIOS ignored
hda: HL-DT-ST DVDRAM GSA-4120B, ATAPI CD/DVD-ROM drive
hdb: WDC WD400AB-32BVA0, ATA DISK drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
hdb: attached ide-disk driver.
hdb: host protected area => 1
hdb: 78165360 sectors (40021 MB) w/2048KiB Cache, CHS=77545/16/63, UDMA(33)
hda: attached ide-cdrom driver.
hda: ATAPI 40X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache, UDMA(33)
Uniform CD-ROM driver Revision: 3.12
Partition check:
 hdb: [PTBL] [4865/255/63] hdb1 hdb2 hdb3 hdb4
SCSI subsystem driver Revision: 1.00
Red Hat/Adaptec aacraid driver (1.1-3 Aug  7 2004 10:36:48)
megaraid: v1.18k (Release Date: Thu Aug 28 10:05:11 EDT 2003)
megaraid: no BIOS enabled.
scsi0 : SCSI host adapter emulation for IDE ATAPI devices
Initializing Cryptographic API
Initialising Xen netif backend
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 1024 buckets, 8Kbytes
TCP: Hash tables configured (established 8192 bind 16384)
ip_conntrack version 2.1 (1024 buckets, 8192 max) - 288 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NET4: Ethernet Bridge 008 for NET4.0
Bridge firewalling registered
(snip)

^ permalink raw reply	[relevance 4%]

* Re: Problems booting with 3ware Controllers
  @ 2004-08-10 23:47  3%         ` Sven Kretzschmar
    0 siblings, 1 reply; 200+ results
From: Sven Kretzschmar @ 2004-08-10 23:47 UTC (permalink / raw)
  To: Christian.Limpach; +Cc: Keir.Fraser, xen-devel


Yes, the highmen probs have been gone now.
I have also compiled xen with debug=y option, but have
not seen any additonal messages from Xen during
boot process (I used another machine with miniterm via
serial crossover to monitor Xen's messages during boot).

However, when I try to compile the 3ware driver as a module,
I get the following error when compiling both the 2.4 and 2.6
kernels (when doing make modules or modules_install, I don't
remember exactly):
Unresolved symbols in ...../3w-xxxx.o
depmod:   force_evtchn_callback

looks like a missing EXPORT_SYMBOL statement, but I am
not sure if this has anything to do with my problems when
booting with the 3ware drivers compiled into the kernel; I think
it hasn't ...

Sorry for the missing dmesg, I try to send it tomorrow.
It gets until the point where it says "...found 3ware controler"
or something alike.
Also, from an earlier email of mine:
"During boot, the boot process of the newly installed kernel
showed that it recognizes the two 3ware Controllers, but then reports the
following errors:
3w-xxxx: scsi0: Unit #0: Command(c7f92b00) timed out, resetting card.
3w-xxxx: scsi0: Unit #0: Command(c7f92b00) timed out, resetting card.
3w-xxxx: scsi0: Reset succeeded.

Then it freezes and nothing more happens.
"

OK, I attached now the output while booting with TW_DEBUG=1.
Caveat: It's from the 2.4. Xenolinux, because that compiled quicker :-/
Don't pay too much attention at that part:
"3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits."
...because it also shows up when booting a vanilla 2.4.26 kernel
(successfully !), but without the endless loop.
BTW: How can I catch the output of a normal 2.4.26 kernel via
serial line ? What kernel options do I have to set exactly ?
I tried "com1=115200,8n1 console=ttyS0" like with xenolinux,
but it did not work ?

Tomorrow I will also try to boot only with one 3ware controller;
currently, there are 2 controllers connected to the machine.
And I will send you the output of a 2.6. kernel, if still necessary
(Sorry for the long post)

 HTH,
    Sven

Output catched via miniterm:

__  __            _   _____        _                _
 \ \/ /___ _ __   / | |___ /     __| | _____   _____| |
  \  // _ \ '_ \  | |   |_ \ __ / _` |/ _ \ \ / / _ \ |
  /  \  __/ | | | | |_ ___) |__| (_| |  __/\ V /  __/ |
 /_/\_\___|_| |_| |_(_)____/    \__,_|\___| \_/ \___|_|

 http://www.cl.cam.ac.uk/netos/xen
 University of Cambridge Computer Laboratory

 Xen version 1.3-devel (root@local) (gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)) Wed Aug 11 00:46:15 CEST 2004

(XEN) Initialised 1023MB memory (262128 pages) on a 1023MB machine
(XEN) Xen heap size is 10604KB
(XEN) CPU0: Before vendor init, caps: bfebfbff 00000000 00000000, vendor = 0
(XEN) CPU#0: Hyper-Threading is disabled
(XEN) CPU caps: bfebfbff 00000000 00000000 00000000
(XEN) found SMP MP-table at 000ff780
(XEN) Memory Reservation 0xff780, 4096 bytes
(XEN) Memory Reservation 0xf9500, 4096 bytes
(XEN) ACPI: RSDP (v000 ACPIAM                                    ) @ 0x000f4fa0
(XEN) ACPI: RSDT (v001 A M I  OEMRSDT  0x02000304 MSFT 0x00000097) @ 0x3fff0000
(XEN) ACPI: FADT (v002 A M I  OEMFACP  0x02000304 MSFT 0x00000097) @ 0x3fff0200
(XEN) ACPI: MADT (v001 A M I  OEMAPIC  0x02000304 MSFT 0x00000097) @ 0x3fff0300
(XEN) ACPI: OEMB (v001 A M I  OEMBIOS  0x02000304 MSFT 0x00000097) @ 0x3ffff040
(XEN) ACPI: DSDT (v001  0ABBP 0ABBP000 0x00000000 INTL 0x02002026) @ 0x00000000
(XEN) ACPI: Local APIC address 0xfee00000
(XEN) ACPI: LAPIC (acpi_id[0x01] lapic_id[0x00] enabled)
(XEN) Processor #0 Pentium 4(tm) XEON(tm) APIC version 20
(XEN) ACPI: LAPIC (acpi_id[0x02] lapic_id[0x06] enabled)
(XEN) Processor #6 Pentium 4(tm) XEON(tm) APIC version 20
(XEN) ACPI: LAPIC (acpi_id[0x03] lapic_id[0x82] disabled)
(XEN) Processor #130 invalid (max 16)
(XEN) ACPI: LAPIC (acpi_id[0x04] lapic_id[0x83] disabled)
(XEN) Processor #131 invalid (max 16)
(XEN) Using ACPI for processor (LAPIC) configuration information
(XEN) Intel MultiProcessor Specification v1.4
(XEN)     Virtual Wire compatibility mode.
(XEN) OEM ID: INTEL    Product ID: KingsCanyonC APIC at: 0xFEE00000
(XEN) I/O APIC #7 Version 32 at 0xFEC00000.
(XEN) I/O APIC #8 Version 32 at 0xFEC80000.
(XEN) I/O APIC #9 Version 32 at 0xFEC80400.
(XEN) I/O APIC #10 Version 32 at 0xFEC81000.
(XEN) I/O APIC #11 Version 32 at 0xFEC81400.
(XEN) Enabling APIC mode: Flat.	Using 5 I/O APICs
(XEN) Processors: 2
(XEN) Using scheduler: Borrowed Virtual Time (bvt)
(XEN) Initializing CPU#0
(XEN) Detected 2665.991 MHz processor.
(XEN) CPU0: Before vendor init, caps: bfebfbff 00000000 00000000, vendor = 0
(XEN) CPU#0: Hyper-Threading is disabled
(XEN) CPU caps: bfebfbff 00000000 00000000 00000000
(XEN) CPU0 booted
(XEN) enabled ExtINT on CPU#0
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) Booting processor 1/6 eip 90000
(XEN) Initializing CPU#1
(XEN) masked ExtINT on CPU#1
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) CPU1: Before vendor init, caps: bfebfbff 00000000 00000000, vendor = 0
(XEN) CPU#1: Hyper-Threading is disabled
(XEN) CPU caps: bfebfbff 00000000 00000000 00000000
(XEN) CPU1 has booted.
(XEN) Total of 2 processors activated.
(XEN) ENABLING IO-APIC IRQs
(XEN) Setting 7 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 7 ... ok.
(XEN) Setting 8 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 8 ... ok.
(XEN) Setting 9 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 9 ... ok.
(XEN) Setting 10 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 10 ... ok.
(XEN) Setting 11 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 11 ... ok.
(XEN) init IO_APIC IRQs
(XEN) ..TIMER: vector=0x41 pin1=2 pin2=0
(XEN) number of MP IRQ sources: 23.
(XEN) number of IO-APIC #7 registers: 24.
(XEN) number of IO-APIC #8 registers: 24.
(XEN) number of IO-APIC #9 registers: 24.
(XEN) number of IO-APIC #10 registers: 24.
(XEN) number of IO-APIC #11 registers: 24.
(XEN) testing the IO APIC.......................
(XEN)
(XEN) IO APIC #7......
(XEN) .... register #00: 07000000
(XEN) .......    : physical APIC id: 07
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 00000000
(XEN) .......     : arbitration: 00
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:
(XEN)  00 000 00  1    0    0   0   0    0    0    00
(XEN)  01 003 03  0    0    0   0   0    1    1    49
(XEN)  02 003 03  0    0    0   0   0    1    1    41
(XEN)  03 003 03  0    0    0   0   0    1    1    51
(XEN)  04 003 03  0    0    0   0   0    1    1    59
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 003 03  0    0    0   0   0    1    1    61
(XEN)  07 003 03  0    0    0   0   0    1    1    69
(XEN)  08 003 03  0    0    0   0   0    1    1    71
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 003 03  0    0    0   0   0    1    1    79
(XEN)  0d 003 03  0    0    0   0   0    1    1    81
(XEN)  0e 003 03  0    0    0   0   0    1    1    89
(XEN)  0f 003 03  0    0    0   0   0    1    1    91
(XEN)  10 003 03  1    1    0   1   0    1    1    99
(XEN)  11 003 03  1    1    0   1   0    1    1    A1
(XEN)  12 003 03  1    1    0   1   0    1    1    A9
(XEN)  13 003 03  1    1    0   1   0    1    1    B1
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN)
(XEN) IO APIC #8......
(XEN) .... register #00: 08000000
(XEN) .......    : physical APIC id: 08
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 08000000
(XEN) .......     : arbitration: 08
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:
(XEN)  00 003 03  1    1    0   1   0    1    1    B9
(XEN)  01 000 00  1    0    0   0   0    0    0    00
(XEN)  02 000 00  1    0    0   0   0    0    0    00
(XEN)  03 000 00  1    0    0   0   0    0    0    00
(XEN)  04 000 00  1    0    0   0   0    0    0    00
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 000 00  1    0    0   0   0    0    0    00
(XEN)  07 000 00  1    0    0   0   0    0    0    00
(XEN)  08 000 00  1    0    0   0   0    0    0    00
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 000 00  1    0    0   0   0    0    0    00
(XEN)  0d 000 00  1    0    0   0   0    0    0    00
(XEN)  0e 000 00  1    0    0   0   0    0    0    00
(XEN)  0f 000 00  1    0    0   0   0    0    0    00
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN)
(XEN) IO APIC #9......
(XEN) .... register #00: 09000000
(XEN) .......    : physical APIC id: 09
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 09000000
(XEN) .......     : arbitration: 09
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:
(XEN)  00 003 03  1    1    0   1   0    1    1    C1
(XEN)  01 003 03  1    1    0   1   0    1    1    C9
(XEN)  02 000 00  1    0    0   0   0    0    0    00
(XEN)  03 000 00  1    0    0   0   0    0    0    00
(XEN)  04 000 00  1    0    0   0   0    0    0    00
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 000 00  1    0    0   0   0    0    0    00
(XEN)  07 000 00  1    0    0   0   0    0    0    00
(XEN)  08 000 00  1    0    0   0   0    0    0    00
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 000 00  1    0    0   0   0    0    0    00
(XEN)  0d 000 00  1    0    0   0   0    0    0    00
(XEN)  0e 000 00  1    0    0   0   0    0    0    00
(XEN)  0f 000 00  1    0    0   0   0    0    0    00
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN)
(XEN) IO APIC #10......
(XEN) .... register #00: 0A000000
(XEN) .......    : physical APIC id: 0A
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 0A000000
(XEN) .......     : arbitration: 0A
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:
(XEN)  00 003 03  1    1    0   1   0    1    1    D1
(XEN)  01 000 00  1    0    0   0   0    0    0    00
(XEN)  02 000 00  1    0    0   0   0    0    0    00
(XEN)  03 000 00  1    0    0   0   0    0    0    00
(XEN)  04 000 00  1    0    0   0   0    0    0    00
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 000 00  1    0    0   0   0    0    0    00
(XEN)  07 000 00  1    0    0   0   0    0    0    00
(XEN)  08 000 00  1    0    0   0   0    0    0    00
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 000 00  1    0    0   0   0    0    0    00
(XEN)  0d 000 00  1    0    0   0   0    0    0    00
(XEN)  0e 000 00  1    0    0   0   0    0    0    00
(XEN)  0f 000 00  1    0    0   0   0    0    0    00
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN)
(XEN) IO APIC #11......
(XEN) .... register #00: 0B000000
(XEN) .......    : physical APIC id: 0B
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 0B000000
(XEN) .......     : arbitration: 0B
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:
(XEN)  00 003 03  1    1    0   1   0    1    1    D9
(XEN)  01 000 00  1    0    0   0   0    0    0    00
(XEN)  02 000 00  1    0    0   0   0    0    0    00
(XEN)  03 000 00  1    0    0   0   0    0    0    00
(XEN)  04 000 00  1    0    0   0   0    0    0    00
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 000 00  1    0    0   0   0    0    0    00
(XEN)  07 000 00  1    0    0   0   0    0    0    00
(XEN)  08 000 00  1    0    0   0   0    0    0    00
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 000 00  1    0    0   0   0    0    0    00
(XEN)  0d 000 00  1    0    0   0   0    0    0    00
(XEN)  0e 000 00  1    0    0   0   0    0    0    00
(XEN)  0f 000 00  1    0    0   0   0    0    0    00
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN) IRQ to pin mappings:
(XEN) IRQ0 -> 0:2
(XEN) IRQ1 -> 0:1
(XEN) IRQ3 -> 0:3
(XEN) IRQ4 -> 0:4
(XEN) IRQ6 -> 0:6
(XEN) IRQ7 -> 0:7
(XEN) IRQ8 -> 0:8
(XEN) IRQ12 -> 0:12
(XEN) IRQ13 -> 0:13
(XEN) IRQ14 -> 0:14
(XEN) IRQ15 -> 0:15
(XEN) IRQ16 -> 0:16
(XEN) IRQ17 -> 0:17
(XEN) IRQ18 -> 0:18
(XEN) IRQ19 -> 0:19
(XEN) IRQ24 -> 1:0
(XEN) IRQ48 -> 2:0
(XEN) IRQ49 -> 2:1
(XEN) IRQ72 -> 3:0
(XEN) IRQ96 -> 4:0
(XEN) .................................... done.
(XEN) Using local APIC timer interrupts.
(XEN) Calibrating APIC timer for CPU0...
(XEN) ..... CPU speed is 2665.8724 MHz.
(XEN) ..... Bus speed is 133.2935 MHz.
(XEN) ..... bus_scale = 0x0000887F
(XEN) checking TSC synchronization across CPUs: passed.
(XEN) Time init:
(XEN) .... System Time: 11475493ns
(XEN) .... cpu_freq:    00000000:9EE7CBD0
(XEN) .... scale:       00000001:8018E8DF
(XEN) .... Wall Clock:  1092181194s 30000us
(XEN) PCI: PCI BIOS revision 2.10 entry at 0xf0031, last bus=7
(XEN) PCI: Using configuration type 1
(XEN) PCI: Probing PCI hardware
(XEN) PCI: Probing PCI hardware (bus 00)
(XEN) PCI: Ignoring BAR0-3 of IDE controller 00:1f.1
(XEN) Transparent bridge - PCI device 8086:244e
(XEN) PCI: Using IRQ router PIIX/ICH [8086/2480] at 00:1f.0
(XEN) PCI->APIC IRQ transform: (B0,I29,P0) -> 16
(XEN) PCI->APIC IRQ transform: (B0,I31,P0) -> 18
(XEN) PCI->APIC IRQ transform: (B0,I31,P1) -> 17
(XEN) PCI->APIC IRQ transform: (B7,I1,P0) -> 48
(XEN) PCI->APIC IRQ transform: (B7,I1,P1) -> 49
(XEN) PCI->APIC IRQ transform: (B6,I3,P0) -> 24
(XEN) PCI->APIC IRQ transform: (B4,I3,P0) -> 96
(XEN) PCI->APIC IRQ transform: (B3,I3,P0) -> 72
(XEN) PCI->APIC IRQ transform: (B1,I1,P0) -> 19
(XEN) PCI->APIC IRQ transform: (B1,I2,P0) -> 18
(XEN) PCI->APIC IRQ transform: (B1,I3,P0) -> 18
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found: 'GUEST_OS=linux,GUEST_VER=2.4,XEN_VER=1.3,VIRT_BASE=0xC0000000'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  02800000->02a878fc
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->0ac00000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0100000->c03cdc0c
(XEN)  Init. ramdisk: c03ce000->c03ce000
(XEN)  Phys-Mach map: c03ce000->c03ee000
(XEN)  Page tables:   c03ee000->c03f1000
(XEN)  Start info:    c03f1000->c03f2000
(XEN)  Boot stack:    c03f2000->c03f3000
(XEN)  TOTAL:         c0000000->c0800000
(XEN)  ENTRY ADDRESS: c0100000
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen).
(XEN) Give DOM0 read access to all PCI devices
Linux version 2.4.26-xen0 (root@filer11.local) (gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)) #4 Wed Aug 11 01:19:07 CEST 2004
On node 0 totalpages: 32768
zone(0): 4096 pages.
zone(1): 28672 pages.
zone(2): 0 pages.
Kernel command line: /boot/vmlinuz-2.4.26-xen0 ro root=/dev/sda1 console=ttyS0
Initializing CPU#0
Xen reported: 2665.991 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 5321.52 BogoMIPS
Memory: 126504k/131072k available (1892k kernel code, 4568k reserved, 578k data, 96k init, 0k highmem)
Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
Inode cache hash table entries: 8192 (order: 4, 65536 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 8192 (order: 3, 32768 bytes)
Page-cache hash table entries: 32768 (order: 5, 131072 bytes)
CPU: L1 I cache: 12K, L1 D cache: 8K
CPU: L2 cache: 512K
CPU: Intel(R) Xeon(TM) CPU 2.66GHz stepping 05
POSIX conformance testing by UNIFIX
PCI: Probing PCI hardware
PCI: Probing PCI hardware (bus 00)
PCI: Probing PCI hardware (bus 01)
PCI: Probing PCI hardware (bus 02)
PCI: Probing PCI hardware (bus 03)
PCI: Probing PCI hardware (bus 04)
PCI: Probing PCI hardware (bus 05)
PCI: Probing PCI hardware (bus 06)
PCI: Probing PCI hardware (bus 07)
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed as ttyS
Starting Xen Balloon driver
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
Intel(R) PRO/1000 Network Driver - version 5.2.30.1-k1
Copyright (c) 1999-2004 Intel Corporation.
PCI: Obtained IRQ 48 for device 07:01.0
eth0: Intel(R) PRO/1000 Network Connection
PCI: Obtained IRQ 49 for device 07:01.1
eth1: Intel(R) PRO/1000 Network Connection
pcnet32.c:v1.28 02.20.2004 tsbogend@alpha.franken.de
Intel(R) PRO/100 Network Driver - version 2.3.38-k1
Copyright (c) 2004 Intel Corporation

PCI: Obtained IRQ 19 for device 01:01.0
e100: eth2: Intel(R) PRO/100 Network Connection
  Hardware receive checksums enabled

Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
ICH3: IDE controller at PCI slot 00:1f.1
PCI: Enabling device 00:1f.1 (0005 -> 0007)
PCI: Obtained IRQ 18 for device 00:1f.1
ICH3: chipset revision 2
ICH3: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:pio, hdb:pio
    ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:pio, hdd:pio
hdb: TEAC CD-552E, ATAPI CD/DVD-ROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
hdb: attached ide-cdrom driver.
hdb: ATAPI 52X CD-ROM drive, 128kB Cache, UDMA(33)
Uniform CD-ROM driver Revision: 3.12
SCSI subsystem driver Revision: 1.00
scsi0 : SCSI host adapter emulation for IDE ATAPI devices
3w-xxxx: tw_scsi_detect()
3ware Storage Controller device driver for Linux v1.02.00.037.
3w-xxxx: tw_findcards()
PCI: Obtained IRQ 72 for device 03:03.0
3w-xxxx: tw_initialize_device_extension()
3w-xxxx: tw_allocate_memory()
3w-xxxx: tw_allocate_memory()
3w-xxxx: tw_aen_drain_queue()
3w-xxxx: tw_check_bits(): No expected bits (0x13005002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: AEN: INFO: AEN queue empty.
3w-xxxx: tw_initialize_units()
3w-xxxx: tw_initialize_units(): Unit 0 found.
3w-xxxx: Found unit 0 to be a raid5 unit.
3w-xxxx: tw_initconnection()
scsi1 : Found a 3ware Storage Controller at 0xb800, IRQ: 72, P-chip: 1.3
3w-xxxx: tw_setup_irq()
3w-xxxx: tw_interrupt()
PCI: Obtained IRQ 96 for device 04:03.0
3w-xxxx: tw_initialize_device_extension()
3w-xxxx: tw_allocate_memory()
3w-xxxx: tw_allocate_memory()
3w-xxxx: tw_aen_drain_queue()
3w-xxxx: tw_check_bits(): No expected bits (0x13005002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
.....
.....endless loop
.....

*********** REPLY SEPARATOR  ***********

On 10.08.2004 at 20:42 Christian Limpach wrote:

>On Tue, Aug 10, 2004 at 12:16:21AM +0200, Sven Kretzschmar wrote:
>> Ok, here are the outputs:
>>
>> 1.) the config diffs (I can not garantee any more that this is an
>orginal .config,
>>      because I now already tried some things to make it perhaps work...,
>however it's still
>>      CONFIG_NOHIGHMEM=y ?!):
>
>The failure you showed can only occur with a kernel with CONFIG_HIGHMEM
>enabled.  In any case, highmem should now work on 2.6.
>
>Re the 3ware problems:
>Could you build a 2.6 dom0 kernel with #define TW_DEBUG added before
>the dprintk macro gets defined around line 248 (the file is
>linux-2.6.7-xen0/drivers/scsi/3w-xxxx.h), like this:
>#define TW_DEBUG 1
>#ifdef TW_DEBUG
>#define dprintk(msg...) printk(msg)
>#else
>#define dprintk(msg...) do { } while(0)
>#endif
>
>Also, does the boot get to the point where it prints a line like:
>Found a 3ware Storage Controller...
>I couldn't find a mail from you which included dmesg output of a failed
>2.6 boot, please include all the output from Xen and from dom0 when
>you boot with TW_DEBUG enabled.
>
>    christian





-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285

^ permalink raw reply	[relevance 3%]

* Re: Problems booting with 3ware Controllers
  @ 2004-08-11 17:40  3%             ` Sven Kretzschmar
  0 siblings, 0 replies; 200+ results
From: Sven Kretzschmar @ 2004-08-11 17:40 UTC (permalink / raw)
  To: Christian.Limpach; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 2238 bytes --]

Sorry for cutting the dump too early :-(

Attached is the complete dump, that I did yesterday.
I will also start now with only 1 controler and send 
this dump too (and I will dump many more lines this time...)

Sven


*********** REPLY SEPARATOR  ***********

On 11.08.2004 at 09:51 Christian Limpach wrote:

>On Wed, Aug 11, 2004 at 01:47:11AM +0200, Sven Kretzschmar wrote:
>> Unresolved symbols in ...../3w-xxxx.o
>> depmod:   force_evtchn_callback
>> 
>> looks like a missing EXPORT_SYMBOL statement, but I am
>> not sure if this has anything to do with my problems when
>> booting with the 3ware drivers compiled into the kernel; I think
>> it hasn't ...
>
>Keir has fixed this.
>
>> OK, I attached now the output while booting with TW_DEBUG=1.
>> Caveat: It's from the 2.4. Xenolinux, because that compiled quicker :-/
>> Don't pay too much attention at that part:
>> "3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
>> 3w-xxxx: tw_poll_status(): Unexpected bits."
>> ...because it also shows up when booting a vanilla 2.4.26 kernel
>> (successfully !), but without the endless loop.
>
>Are you sure it gets into an endless loop?  Because you indicated
>earlier that it does find both cards, so it should find the 2nd
>card after a long stream of tw_check_bits/tw_poll_status messages.
>Because the interesting part will be after it found both cards and
>tries to use them...  At least PCI setup und interrupt routing
>looks allright.
>
>> BTW: How can I catch the output of a normal 2.4.26 kernel via
>> serial line ? What kernel options do I have to set exactly ?
>> I tried "com1=115200,8n1 console=ttyS0" like with xenolinux,
>> but it did not work ?
>
>You need to enable the serial drivers (on by default) and there's
>a console on serial line just next to it.  The syntax for the
>command line is: console=ttyS0,115200n8
>I don't know if a com1= option is supported...
>
>> Tomorrow I will also try to boot only with one 3ware controller;
>> currently, there are 2 controllers connected to the machine.
>> And I will send you the output of a 2.6. kernel, if still necessary
>
>Please try to get the output after the endless loop or confirm that
>it doesn't find the 2nd card without TW_DEBUG set.
>
>    christian



[-- Attachment #2: bootdump.txt --]
[-- Type: text/plain, Size: 86140 bytes --]

 __  __            _   _____        _                _ 
 \ \/ /___ _ __   / | |___ /     __| | _____   _____| |
  \  // _ \ '_ \  | |   |_ \ __ / _` |/ _ \ \ / / _ \ |
  /  \  __/ | | | | |_ ___) |__| (_| |  __/\ V /  __/ |
 /_/\_\___|_| |_| |_(_)____/    \__,_|\___| \_/ \___|_|
                                                       
 http://www.cl.cam.ac.uk/netos/xen
 University of Cambridge Computer Laboratory

 Xen version 1.3-devel (root@local) (gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)) Wed Aug 11 00:46:15 CEST 2004

(XEN) Initialised 1023MB memory (262128 pages) on a 1023MB machine
(XEN) Xen heap size is 10604KB
(XEN) CPU0: Before vendor init, caps: bfebfbff 00000000 00000000, vendor = 0
(XEN) CPU#0: Hyper-Threading is disabled
(XEN) CPU caps: bfebfbff 00000000 00000000 00000000
(XEN) found SMP MP-table at 000ff780
(XEN) Memory Reservation 0xff780, 4096 bytes
(XEN) Memory Reservation 0xf9500, 4096 bytes
(XEN) ACPI: RSDP (v000 ACPIAM                                    ) @ 0x000f4fa0
(XEN) ACPI: RSDT (v001 A M I  OEMRSDT  0x02000304 MSFT 0x00000097) @ 0x3fff0000
(XEN) ACPI: FADT (v002 A M I  OEMFACP  0x02000304 MSFT 0x00000097) @ 0x3fff0200
(XEN) ACPI: MADT (v001 A M I  OEMAPIC  0x02000304 MSFT 0x00000097) @ 0x3fff0300
(XEN) ACPI: OEMB (v001 A M I  OEMBIOS  0x02000304 MSFT 0x00000097) @ 0x3ffff040
(XEN) ACPI: DSDT (v001  0ABBP 0ABBP000 0x00000000 INTL 0x02002026) @ 0x00000000
(XEN) ACPI: Local APIC address 0xfee00000
(XEN) ACPI: LAPIC (acpi_id[0x01] lapic_id[0x00] enabled)
(XEN) Processor #0 Pentium 4(tm) XEON(tm) APIC version 20
(XEN) ACPI: LAPIC (acpi_id[0x02] lapic_id[0x06] enabled)
(XEN) Processor #6 Pentium 4(tm) XEON(tm) APIC version 20
(XEN) ACPI: LAPIC (acpi_id[0x03] lapic_id[0x82] disabled)
(XEN) Processor #130 invalid (max 16)
(XEN) ACPI: LAPIC (acpi_id[0x04] lapic_id[0x83] disabled)
(XEN) Processor #131 invalid (max 16)
(XEN) Using ACPI for processor (LAPIC) configuration information
(XEN) Intel MultiProcessor Specification v1.4
(XEN)     Virtual Wire compatibility mode.
(XEN) OEM ID: INTEL    Product ID: KingsCanyonC APIC at: 0xFEE00000
(XEN) I/O APIC #7 Version 32 at 0xFEC00000.
(XEN) I/O APIC #8 Version 32 at 0xFEC80000.
(XEN) I/O APIC #9 Version 32 at 0xFEC80400.
(XEN) I/O APIC #10 Version 32 at 0xFEC81000.
(XEN) I/O APIC #11 Version 32 at 0xFEC81400.
(XEN) Enabling APIC mode: Flat.	Using 5 I/O APICs
(XEN) Processors: 2
(XEN) Using scheduler: Borrowed Virtual Time (bvt)
(XEN) Initializing CPU#0
(XEN) Detected 2665.991 MHz processor.
(XEN) CPU0: Before vendor init, caps: bfebfbff 00000000 00000000, vendor = 0
(XEN) CPU#0: Hyper-Threading is disabled
(XEN) CPU caps: bfebfbff 00000000 00000000 00000000
(XEN) CPU0 booted
(XEN) enabled ExtINT on CPU#0
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) Booting processor 1/6 eip 90000
(XEN) Initializing CPU#1
(XEN) masked ExtINT on CPU#1
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) CPU1: Before vendor init, caps: bfebfbff 00000000 00000000, vendor = 0
(XEN) CPU#1: Hyper-Threading is disabled
(XEN) CPU caps: bfebfbff 00000000 00000000 00000000
(XEN) CPU1 has booted.
(XEN) Total of 2 processors activated.
(XEN) ENABLING IO-APIC IRQs
(XEN) Setting 7 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 7 ... ok.
(XEN) Setting 8 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 8 ... ok.
(XEN) Setting 9 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 9 ... ok.
(XEN) Setting 10 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 10 ... ok.
(XEN) Setting 11 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 11 ... ok.
(XEN) init IO_APIC IRQs
(XEN) ..TIMER: vector=0x41 pin1=2 pin2=0
(XEN) number of MP IRQ sources: 23.
(XEN) number of IO-APIC #7 registers: 24.
(XEN) number of IO-APIC #8 registers: 24.
(XEN) number of IO-APIC #9 registers: 24.
(XEN) number of IO-APIC #10 registers: 24.
(XEN) number of IO-APIC #11 registers: 24.
(XEN) testing the IO APIC.......................
(XEN) 
(XEN) IO APIC #7......
(XEN) .... register #00: 07000000
(XEN) .......    : physical APIC id: 07
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 00000000
(XEN) .......     : arbitration: 00
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:   
(XEN)  00 000 00  1    0    0   0   0    0    0    00
(XEN)  01 003 03  0    0    0   0   0    1    1    49
(XEN)  02 003 03  0    0    0   0   0    1    1    41
(XEN)  03 003 03  0    0    0   0   0    1    1    51
(XEN)  04 003 03  0    0    0   0   0    1    1    59
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 003 03  0    0    0   0   0    1    1    61
(XEN)  07 003 03  0    0    0   0   0    1    1    69
(XEN)  08 003 03  0    0    0   0   0    1    1    71
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 003 03  0    0    0   0   0    1    1    79
(XEN)  0d 003 03  0    0    0   0   0    1    1    81
(XEN)  0e 003 03  0    0    0   0   0    1    1    89
(XEN)  0f 003 03  0    0    0   0   0    1    1    91
(XEN)  10 003 03  1    1    0   1   0    1    1    99
(XEN)  11 003 03  1    1    0   1   0    1    1    A1
(XEN)  12 003 03  1    1    0   1   0    1    1    A9
(XEN)  13 003 03  1    1    0   1   0    1    1    B1
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN) 
(XEN) IO APIC #8......
(XEN) .... register #00: 08000000
(XEN) .......    : physical APIC id: 08
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 08000000
(XEN) .......     : arbitration: 08
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:   
(XEN)  00 003 03  1    1    0   1   0    1    1    B9
(XEN)  01 000 00  1    0    0   0   0    0    0    00
(XEN)  02 000 00  1    0    0   0   0    0    0    00
(XEN)  03 000 00  1    0    0   0   0    0    0    00
(XEN)  04 000 00  1    0    0   0   0    0    0    00
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 000 00  1    0    0   0   0    0    0    00
(XEN)  07 000 00  1    0    0   0   0    0    0    00
(XEN)  08 000 00  1    0    0   0   0    0    0    00
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 000 00  1    0    0   0   0    0    0    00
(XEN)  0d 000 00  1    0    0   0   0    0    0    00
(XEN)  0e 000 00  1    0    0   0   0    0    0    00
(XEN)  0f 000 00  1    0    0   0   0    0    0    00
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN) 
(XEN) IO APIC #9......
(XEN) .... register #00: 09000000
(XEN) .......    : physical APIC id: 09
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 09000000
(XEN) .......     : arbitration: 09
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:   
(XEN)  00 003 03  1    1    0   1   0    1    1    C1
(XEN)  01 003 03  1    1    0   1   0    1    1    C9
(XEN)  02 000 00  1    0    0   0   0    0    0    00
(XEN)  03 000 00  1    0    0   0   0    0    0    00
(XEN)  04 000 00  1    0    0   0   0    0    0    00
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 000 00  1    0    0   0   0    0    0    00
(XEN)  07 000 00  1    0    0   0   0    0    0    00
(XEN)  08 000 00  1    0    0   0   0    0    0    00
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 000 00  1    0    0   0   0    0    0    00
(XEN)  0d 000 00  1    0    0   0   0    0    0    00
(XEN)  0e 000 00  1    0    0   0   0    0    0    00
(XEN)  0f 000 00  1    0    0   0   0    0    0    00
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN) 
(XEN) IO APIC #10......
(XEN) .... register #00: 0A000000
(XEN) .......    : physical APIC id: 0A
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 0A000000
(XEN) .......     : arbitration: 0A
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:   
(XEN)  00 003 03  1    1    0   1   0    1    1    D1
(XEN)  01 000 00  1    0    0   0   0    0    0    00
(XEN)  02 000 00  1    0    0   0   0    0    0    00
(XEN)  03 000 00  1    0    0   0   0    0    0    00
(XEN)  04 000 00  1    0    0   0   0    0    0    00
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 000 00  1    0    0   0   0    0    0    00
(XEN)  07 000 00  1    0    0   0   0    0    0    00
(XEN)  08 000 00  1    0    0   0   0    0    0    00
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 000 00  1    0    0   0   0    0    0    00
(XEN)  0d 000 00  1    0    0   0   0    0    0    00
(XEN)  0e 000 00  1    0    0   0   0    0    0    00
(XEN)  0f 000 00  1    0    0   0   0    0    0    00
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN) 
(XEN) IO APIC #11......
(XEN) .... register #00: 0B000000
(XEN) .......    : physical APIC id: 0B
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 0B000000
(XEN) .......     : arbitration: 0B
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:   
(XEN)  00 003 03  1    1    0   1   0    1    1    D9
(XEN)  01 000 00  1    0    0   0   0    0    0    00
(XEN)  02 000 00  1    0    0   0   0    0    0    00
(XEN)  03 000 00  1    0    0   0   0    0    0    00
(XEN)  04 000 00  1    0    0   0   0    0    0    00
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 000 00  1    0    0   0   0    0    0    00
(XEN)  07 000 00  1    0    0   0   0    0    0    00
(XEN)  08 000 00  1    0    0   0   0    0    0    00
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 000 00  1    0    0   0   0    0    0    00
(XEN)  0d 000 00  1    0    0   0   0    0    0    00
(XEN)  0e 000 00  1    0    0   0   0    0    0    00
(XEN)  0f 000 00  1    0    0   0   0    0    0    00
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN) IRQ to pin mappings:
(XEN) IRQ0 -> 0:2
(XEN) IRQ1 -> 0:1
(XEN) IRQ3 -> 0:3
(XEN) IRQ4 -> 0:4
(XEN) IRQ6 -> 0:6
(XEN) IRQ7 -> 0:7
(XEN) IRQ8 -> 0:8
(XEN) IRQ12 -> 0:12
(XEN) IRQ13 -> 0:13
(XEN) IRQ14 -> 0:14
(XEN) IRQ15 -> 0:15
(XEN) IRQ16 -> 0:16
(XEN) IRQ17 -> 0:17
(XEN) IRQ18 -> 0:18
(XEN) IRQ19 -> 0:19
(XEN) IRQ24 -> 1:0
(XEN) IRQ48 -> 2:0
(XEN) IRQ49 -> 2:1
(XEN) IRQ72 -> 3:0
(XEN) IRQ96 -> 4:0
(XEN) .................................... done.
(XEN) Using local APIC timer interrupts.
(XEN) Calibrating APIC timer for CPU0...
(XEN) ..... CPU speed is 2665.8724 MHz.
(XEN) ..... Bus speed is 133.2935 MHz.
(XEN) ..... bus_scale = 0x0000887F
(XEN) checking TSC synchronization across CPUs: passed.
(XEN) Time init:
(XEN) .... System Time: 11475493ns
(XEN) .... cpu_freq:    00000000:9EE7CBD0
(XEN) .... scale:       00000001:8018E8DF
(XEN) .... Wall Clock:  1092181194s 30000us
(XEN) PCI: PCI BIOS revision 2.10 entry at 0xf0031, last bus=7
(XEN) PCI: Using configuration type 1
(XEN) PCI: Probing PCI hardware
(XEN) PCI: Probing PCI hardware (bus 00)
(XEN) PCI: Ignoring BAR0-3 of IDE controller 00:1f.1
(XEN) Transparent bridge - PCI device 8086:244e
(XEN) PCI: Using IRQ router PIIX/ICH [8086/2480] at 00:1f.0
(XEN) PCI->APIC IRQ transform: (B0,I29,P0) -> 16
(XEN) PCI->APIC IRQ transform: (B0,I31,P0) -> 18
(XEN) PCI->APIC IRQ transform: (B0,I31,P1) -> 17
(XEN) PCI->APIC IRQ transform: (B7,I1,P0) -> 48
(XEN) PCI->APIC IRQ transform: (B7,I1,P1) -> 49
(XEN) PCI->APIC IRQ transform: (B6,I3,P0) -> 24
(XEN) PCI->APIC IRQ transform: (B4,I3,P0) -> 96
(XEN) PCI->APIC IRQ transform: (B3,I3,P0) -> 72
(XEN) PCI->APIC IRQ transform: (B1,I1,P0) -> 19
(XEN) PCI->APIC IRQ transform: (B1,I2,P0) -> 18
(XEN) PCI->APIC IRQ transform: (B1,I3,P0) -> 18
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found: 'GUEST_OS=linux,GUEST_VER=2.4,XEN_VER=1.3,VIRT_BASE=0xC0000000'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  02800000->02a878fc
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->0ac00000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0100000->c03cdc0c
(XEN)  Init. ramdisk: c03ce000->c03ce000
(XEN)  Phys-Mach map: c03ce000->c03ee000
(XEN)  Page tables:   c03ee000->c03f1000
(XEN)  Start info:    c03f1000->c03f2000
(XEN)  Boot stack:    c03f2000->c03f3000
(XEN)  TOTAL:         c0000000->c0800000
(XEN)  ENTRY ADDRESS: c0100000
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen).
(XEN) Give DOM0 read access to all PCI devices
Linux version 2.4.26-xen0 (root@filer11.local) (gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)) #4 Wed Aug 11 01:19:07 CEST 2004
On node 0 totalpages: 32768
zone(0): 4096 pages.
zone(1): 28672 pages.
zone(2): 0 pages.
Kernel command line: /boot/vmlinuz-2.4.26-xen0 ro root=/dev/sda1 console=ttyS0
Initializing CPU#0
Xen reported: 2665.991 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 5321.52 BogoMIPS
Memory: 126504k/131072k available (1892k kernel code, 4568k reserved, 578k data, 96k init, 0k highmem)
Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
Inode cache hash table entries: 8192 (order: 4, 65536 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 8192 (order: 3, 32768 bytes)
Page-cache hash table entries: 32768 (order: 5, 131072 bytes)
CPU: L1 I cache: 12K, L1 D cache: 8K
CPU: L2 cache: 512K
CPU: Intel(R) Xeon(TM) CPU 2.66GHz stepping 05
POSIX conformance testing by UNIFIX
PCI: Probing PCI hardware
PCI: Probing PCI hardware (bus 00)
PCI: Probing PCI hardware (bus 01)
PCI: Probing PCI hardware (bus 02)
PCI: Probing PCI hardware (bus 03)
PCI: Probing PCI hardware (bus 04)
PCI: Probing PCI hardware (bus 05)
PCI: Probing PCI hardware (bus 06)
PCI: Probing PCI hardware (bus 07)
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed as ttyS
Starting Xen Balloon driver
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
Intel(R) PRO/1000 Network Driver - version 5.2.30.1-k1
Copyright (c) 1999-2004 Intel Corporation.
PCI: Obtained IRQ 48 for device 07:01.0
eth0: Intel(R) PRO/1000 Network Connection
PCI: Obtained IRQ 49 for device 07:01.1
eth1: Intel(R) PRO/1000 Network Connection
pcnet32.c:v1.28 02.20.2004 tsbogend@alpha.franken.de
Intel(R) PRO/100 Network Driver - version 2.3.38-k1
Copyright (c) 2004 Intel Corporation

PCI: Obtained IRQ 19 for device 01:01.0
e100: eth2: Intel(R) PRO/100 Network Connection
  Hardware receive checksums enabled

Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
ICH3: IDE controller at PCI slot 00:1f.1
PCI: Enabling device 00:1f.1 (0005 -> 0007)
PCI: Obtained IRQ 18 for device 00:1f.1
ICH3: chipset revision 2
ICH3: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:pio, hdb:pio
    ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:pio, hdd:pio
hdb: TEAC CD-552E, ATAPI CD/DVD-ROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
hdb: attached ide-cdrom driver.
hdb: ATAPI 52X CD-ROM drive, 128kB Cache, UDMA(33)
Uniform CD-ROM driver Revision: 3.12
SCSI subsystem driver Revision: 1.00
scsi0 : SCSI host adapter emulation for IDE ATAPI devices
3w-xxxx: tw_scsi_detect()
3ware Storage Controller device driver for Linux v1.02.00.037.
3w-xxxx: tw_findcards()
PCI: Obtained IRQ 72 for device 03:03.0
3w-xxxx: tw_initialize_device_extension()
3w-xxxx: tw_allocate_memory()
3w-xxxx: tw_allocate_memory()
3w-xxxx: tw_aen_drain_queue()
3w-xxxx: tw_check_bits(): No expected bits (0x13005002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: AEN: INFO: AEN queue empty.
3w-xxxx: tw_initialize_units()
3w-xxxx: tw_initialize_units(): Unit 0 found.
3w-xxxx: Found unit 0 to be a raid5 unit.
3w-xxxx: tw_initconnection()
scsi1 : Found a 3ware Storage Controller at 0xb800, IRQ: 72, P-chip: 1.3
3w-xxxx: tw_setup_irq()
3w-xxxx: tw_interrupt()
PCI: Obtained IRQ 96 for device 04:03.0
3w-xxxx: tw_initialize_device_extension()
3w-xxxx: tw_allocate_memory()
3w-xxxx: tw_allocate_memory()
3w-xxxx: tw_aen_drain_queue()
3w-xxxx: tw_check_bits(): No expected bits (0x13005002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: AEN: INFO: AEN queue empty.
3w-xxxx: tw_initialize_units()
3w-xxxx: tw_initialize_units(): Unit 0 found.
3w-xxxx: tw_initconnection()
scsi2 : Found a 3ware Storage Controller at 0xc800, IRQ: 96, P-chip: 1.3
3w-xxxx: tw_setup_irq()
3w-xxxx: tw_interrupt()
scsi1 : 3ware Storage Controller
scsi2 : 3ware Storage Controller
3w-xxxx: tw_scsi_queue()
3w-xxxx: tw_state_request_start()
3w-xxxx: tw_state_request_start(): id = 0.
3w-xxxx: tw_scsi_queue(): caught INQUIRY.
3w-xxxx: tw_scsiop_inquiry()
3w-xxxx: tw_post_command_packet()
3w-xxxx: tw_scsi_eh_abort()
3w-xxxx: scsi1: Unit #0: Command (c1371000) timed out, resetting card.
3w-xxxx: tw_reset_device_extension()
3w-xxxx: tw_aen_drain_queue()
3w-xxxx: tw_check_bits(): No expected bits (0x13001002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: AEN: INFO: AEN queue empty.
3w-xxxx: tw_initconnection()
3w-xxxx: tw_unamp_scsi_data()
3w-xxxx: tw_scsi_queue()
3w-xxxx: tw_state_request_start()
3w-xxxx: tw_state_request_start(): id = 0.
3w-xxxx: tw_scsi_queue(): caught TEST_UNIT_READY.
3w-xxxx: tw_scsiop_test_unit_ready()
3w-xxxx: tw_post_command_packet()
3w-xxxx: tw_scsi_eh_abort()
3w-xxxx: scsi1: Unit #0: Command (c1371000) timed out, resetting card.
3w-xxxx: tw_reset_device_extension()
3w-xxxx: tw_aen_drain_queue()
3w-xxxx: tw_check_bits(): No expected bits (0x13001002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025000).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: tw_check_bits(): No expected bits (0x13025002).
3w-xxxx: tw_poll_status(): Unexpected bits.
3w-xxxx: tw_decode_bits()
3w-xxxx: AEN: INFO: AEN queue empty.
3w-xxxx: tw_initconnection()
3w-xxxx: tw_unamp_scsi_data()
3w-xxxx: tw_scsi_eh_reset()

** ctrl-b quits miniterm **

^ permalink raw reply	[relevance 3%]

* Xen unprivileged domain not booting
@ 2004-08-20 22:21  4% Will Andrews
  0 siblings, 0 replies; 200+ results
From: Will Andrews @ 2004-08-20 22:21 UTC (permalink / raw)
  To: xen-devel

Hello,

I am using the Xen 1.3 development sources, from the tarball on
the website.  I was able to build and boot linux-2.4.26-xen0 as
Domain 0 on the beater box.  However, I am unable to boot the
unprivileged domain using a separate partition for its root
filesystem.  Both Domain 0 and Domain 1 are using Debian.

I downloaded the xeno-unstable-src.tgz tarball on August 12th.  I
can try a newer version if anyone thinks that will help.

Here's the dmesg & error I'm seeing while attempting to boot
the unprivileged domain (same error with the xenU kernel):

Linux version 2.4.26-xen0 (root@experiment-07) (gcc version 3.3.4 (Debian 1:3.3.4-6sarge1)) #5 Tue Aug 17 17:13:07 EST 2004
On node 0 totalpages: 24576                
zone(0): 4096 pages.       
zone(1): 20480 pages.
zone(2): 0 pages.    
Kernel command line:  ip=dhcp root=/dev/xda1 ro 4 root=/dev/xda1 ro
Initializing CPU#0                                                 
Xen reported: 547.629 MHz processor.
Calibrating delay loop... 837.22 BogoMIPS
Memory: 93572k/98304k available (2290k kernel code, 4732k reserved, 721k data, 104k init, 0k highmem)
Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
Inode cache hash table entries: 8192 (order: 4, 65536 bytes)   
Mount cache hash table entries: 512 (order: 0, 4096 bytes)  
Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 32768 (order: 5, 131072 bytes)
CPU: L1 I cache: 16K, L1 D cache: 16K                        
CPU: L2 cache: 512K                  
CPU: Intel Pentium III (Katmai) stepping 03
POSIX conformance testing by UNIFIX        
PCI: Probing PCI hardware          
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket                         
Starting kswapd               
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.                         
Xen virtual console successfully installed as tty
Starting Xen Balloon driver                      
pty: 256 Unix98 ptys configured
Initialising Xen virtual block device
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)                                         
Intel(R) PRO/1000 Network Driver - version 5.2.30.1-k1
Copyright (c) 1999-2004 Intel Corporation.            
pcnet32.c:v1.28 02.20.2004 tsbogend@alpha.franken.de
Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
hda: C/H/S=0/0/0 from BIOS ignored                                         
hdb: C/H/S=0/0/0 from BIOS ignored
SCSI subsystem driver Revision: 1.00
Red Hat/Adaptec aacraid driver (1.1-3 Aug 17 2004 15:57:49)
megaraid: v1.18k (Release Date: Thu Aug 28 10:05:11 EDT 2003)
megaraid: no BIOS enabled.                                   
scsi0 : SCSI host adapter emulation for IDE ATAPI devices
LVM version 1.0.8(17/11/2003)                            
Initializing Cryptographic API
Initialising Xen virtual ethernet frontend driver<6>NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 8192 bind 16384)
ip_conntrack version 2.1 (768 buckets, 6144 max) - 288 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team                              
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NET4: Ethernet Bridge 008 for NET4.0               
Bridge firewalling registered       
Can't write to read-only device 0d:01
kjournald starting.  Commit interval 5 seconds
Can't write to read-only device 0d:01         
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.      
Freeing unused kernel memory: 104k freed     
INIT: version 2.86 booting              
Activating swap.
Checking root file system...
fsck 1.35 (28-Feb-2004)
/dev/xda1: clean, 14724/915712 files, 82579/1831410 blocks
Error writing block 520 (Attempt to write block from filesystem resulted in short write).  

/dev/xda1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
        (i.e., without -a or -p options)
Error writing block 520 (Attempt to write block from filesystem resulted in short write).  
/dev/xda1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
        (i.e., without -a or -p options)

fsck failed.  Please repair manually and reboot.  Please note
that the root file system is currently mounted read-only.  To
remount it read-write:

   # mount -n -o remount,rw /

CONTROL-D will exit from this shell and REBOOT the system.

Press enter for maintenance
(or type Control-D to continue): 

I checked the filesystem statistics it provided in Domain 0 and
it appears to be close, but not quite the exact same number of
files (including directories and other special files as "files").
Since I've never seen this error before, I really have no idea
what to do.

Regards,
-- 
wca
Purdue University Rosen Center for Advanced Computing
Office: MATH G135 @ Purdue - http://www.itap.purdue.edu/rcs/
NB: crypt.rcs.purdue.edu has retired recently, please use
    andrewsw@crypt.rcac.purdue.edu for all future contact.


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285

^ permalink raw reply	[relevance 4%]

* Problems with virtual disks in DomU
@ 2004-08-25 11:49  5% Stephen Childs
  0 siblings, 0 replies; 200+ results
From: Stephen Childs @ 2004-08-25 11:49 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1298 bytes --]

Hi,

I am trying to move from Xen 1.2 to the latest revision of Xen and I'm 
having problems accessing virtual block devices from DomU. The machine is a 
Dell PowerEdge 1750 (I had to compile Fusion MPT support into Dom0, but it 
all seems to work fine now).

If I export /dev/sdb to domain U as /dev/sdb read-write (i.e. disk = [ 
'phy:sdb,sdb,w' ]), then DomU doesn't seem to see the disk at all; I get the 
following error:

Initialising Xen virtual block device
Partition check:
  sdb:<6>Timeout connecting block device driver!

If I export the root and swap partitions explicitly (i.e. /dev/sdb1 and 
/dev/sdb3) then things get a bit further but then fsck of the root 
filesystem fails. (The filesystem is a RH7.2 image which fscks and mounts 
fine in Dom0).

I have attached my domain config file and the bootlogs for both cases. I 
have trawled through the docs and the list archive but can't seem to find 
anything relevant. It's quite likely that I'm missing something about the 
transition to Xen 2.0 but I can't quite see what!

Stephen

-- 
Dr. Stephen Childs,
Researcher, EGEE Project,         phone:                    +353-1-6081720
Computer Architecture Group,      email:       Stephen.Childs at cs.tcd.ie
Trinity College Dublin, Ireland   web: http://www.cs.tcd.ie/Stephen.Childs

[-- Attachment #2: bootlog_with_partitions --]
[-- Type: text/plain, Size: 3635 bytes --]

Linux version 2.4.27-xenU (childss@frascati.cs.tcd.ie) (gcc version 3.3.3 200404
12 (Red Hat Linux 3.3.3-7)) #1 Wed Aug 25 11:13:40 IST 2004
On node 0 totalpages: 16384
zone(0): 4096 pages.
zone(1): 12288 pages.
zone(2): 0 pages.
Kernel command line:  ip=192.168.0.144:1.2.3.4:192.168.0.254:::eth0: root=/dev/s
db1 ro  4
Initializing CPU#0
Xen reported: 2387.144 MHz processor.
Calibrating delay loop... 2510.02 BogoMIPS
Memory: 62840k/65536k available (1304k kernel code, 2696k reserved, 234k data, 5
6k init, 0k highmem)
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
CPU: L1 I cache: 12K, L1 D cache: 8K
CPU: L2 cache: 512K
CPU: Intel(R) Xeon(TM) CPU 2.40GHz stepping 09
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed as tty
Starting Xen Balloon driver
pty: 256 Unix98 ptys configured
Initialising Xen virtual block device
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
SCSI subsystem driver Revision: 1.00
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
Initialising Xen virtual ethernet frontend driver.
Netfront recovered tx=0 rxfree=0
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
IP-Config: Guessing netmask 255.255.255.0
IP-Config: Complete:
      device=eth0, addr=192.168.0.144, mask=255.255.255.0, gw=192.168.0.254,
     host=192.168.0.144, domain=, nis-domain=(none),
     bootserver=1.2.3.4, rootserver=1.2.3.4, rootpath=
ip_conntrack version 2.1 (512 buckets, 4096 max) - 288 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
VFS: Mounted root (ext2 filesystem) readonly.
Freeing unused kernel memory: 56k freed
modprobe: modprobe: Can't open dependencies file /lib/modules/2.4.27-xenU/module
s.dep (No such file or directory)
INIT: version 2.78 booting
                        Welcome to Red Hat Linux
                Press 'I' to enter interactive startup.
Mounting proc filesystem:  [  OK  ]
Configuring kernel parameters:  [  OK  ]
Setting clock : Wed Aug 25 07:31:19 EDT 2004 [  OK  ]
Activating swap partitions:  [  OK  ]
Setting hostname redhat72.goober.org:  [  OK  ]
modprobe: Can't open dependencies file /lib/modules/2.4.27-xenU/modules.dep (No 
such file or directory)
Checking root filesystem
fsck.ext2/: 
The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

[/sbin/fsck.ext2 (1) -- /] fsck.ext2 -a / 
: Is a directory while trying to open /
[FAILED]

*** An error occurred during the file system check.
*** Dropping you to a shell; the system will reboot
*** when you leave the shell.
Give root password for maintenance
(or type Control-D for normal startup): 


[-- Attachment #3: bootlog_with_wholedisk --]
[-- Type: text/plain, Size: 2204 bytes --]

Linux version 2.4.27-xenU (childss@frascati.cs.tcd.ie) (gcc version 3.3.3 200404
12 (Red Hat Linux 3.3.3-7)) #1 Wed Aug 25 11:13:40 IST 2004
On node 0 totalpages: 16384
zone(0): 4096 pages.
zone(1): 12288 pages.
zone(2): 0 pages.
Kernel command line:  ip=192.168.0.144:1.2.3.4:192.168.0.254:::eth0: root=/dev/s
db1 ro  4
Initializing CPU#0
Xen reported: 2387.144 MHz processor.
Calibrating delay loop... 4757.91 BogoMIPS
Memory: 62840k/65536k available (1304k kernel code, 2696k reserved, 234k data, 5
6k init, 0k highmem)
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
CPU: L1 I cache: 12K, L1 D cache: 8K
CPU: L2 cache: 512K
CPU: Intel(R) Xeon(TM) CPU 2.40GHz stepping 09
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed as tty
Starting Xen Balloon driver
pty: 256 Unix98 ptys configured
Initialising Xen virtual block device
Partition check:
 sdb:<6>Timeout connecting block device driver!
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
SCSI subsystem driver Revision: 1.00
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
Initialising Xen virtual ethernet frontend driver.
[XEN] Failed to connect all virtual interfaces: err=-100
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
IP-Config: Device `eth0' not found.
ip_conntrack version 2.1 (512 buckets, 4096 max) - 288 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.


[-- Attachment #4: xen2_domain_config --]
[-- Type: text/plain, Size: 399 bytes --]

# Kernel image file.
kernel = "/boot/vmlinuz-2.4.27-xenU"

# Initial memory allocation (in megabytes) for the new domain.
memory = 64

dhcp=""
ip="192.168.0.144"
gateway="192.168.0.254"

# A name for your domain. All domains must have different names.
name = "Xen1"

disk = [ 'phy:sdb,sdb,w' ]
#disk = [ 'phy:sdb1,sdb1,w', 'phy:sdb3,sdb3,w' ]

# Set root device.
root = "/dev/sdb1 ro"
extra = " 4"


^ permalink raw reply	[relevance 5%]

* Re: problem creating a new domain
  @ 2004-10-19 21:34  5%   ` Sanjay Kumar
  2004-10-20 14:54  0%     ` Matthieu PATOU
  0 siblings, 1 reply; 200+ results
From: Sanjay Kumar @ 2004-10-19 21:34 UTC (permalink / raw)
  To: maw48; +Cc: xen-devel

Hi Mark,
I switched to Xen2.0 with linux 2.4.27 kernel for dom0

now I create the virtual disk in the same way as I described below.

now when I try to boot another domain i see problems with DHCP. below are
the logs

Using config file "/etc/xen/dom1".
Started domain ExampleDomain, console on port 9609
************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.4.27-xenU (root@andrea) (gcc version 3.1.1) #3 Tue Oct 19
13:56:24 EDT 2004
On node 0 totalpages: 16384
zone(0): 4096 pages.
zone(1): 12288 pages.
zone(2): 0 pages.
Kernel command line:  ip=:1.2.3.4::::eth0:dhcp root=/dev/hda1 ro 4
Initializing CPU#0
Xen reported: 2193.379 MHz processor.
Calibrating delay loop... 4404.01 BogoMIPS
Memory: 62768k/65536k available (1341k kernel code, 2768k reserved, 267k
data, 60k init, 0k highmem)
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
CPU: L1 I cache: 12K, L1 D cache: 8K
CPU: L2 cache: 512K
CPU: Intel(R) Pentium(R) 4 CPU 2.20GHz stepping 04
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed as tty
Starting Xen Balloon driver
pty: 256 Unix98 ptys configured
[XEN] Initialising virtual block device driver
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
SCSI subsystem driver Revision: 1.00
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
[XEN] Initialising virtual ethernet driver.
[XEN] Netfront recovered tx=0 rxfree=0
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
Sending DHCP requests .......  timed out

Here Sending DHCP requests keep timing out and it keeps retrying. so boot
doesn't proceed beyond this point.

Can anybody please let me know what I might be doing wrong.

Thanks,
Sanjay


----------------------------------
http://www.cc.gatech.edu/~ksanjay/

On Mon, 18 Oct 2004, M.A. Williamson wrote:

> > Hi Folks,
> > I am using xen1.2.
> > I create the disk image as described in the Xen2.0 user manual chapter 5.
>
> Sorry but that won't work :-(
>
> Xen 1.2 can only export sections of physical disks (e.g. partitions, whole
> disks, or Xen Virtual Disks) to other domains. If you want to store
> filesystems in disk files, you should move to Xen 2.0-beta (soon to be Xen
> 2.0-release).
>
> The nearest you can get on Xen 1.2 is to create a Virtual Disk and then use
> that. Tying yourself to 1.2 is probably not a good idea though - Virtual
> Disks aren't supported by 2.0. We'd certainly prefer people to move to 2.0
> now - it's stable and virtually release-ready and has a whole load of new
> features, improved tools and better hardware support.
>
> A good way to install a new domain's filesystem is using debootstrap (as
> described in the appendix of the manual).
>
> Let us know how you get on.
>
> HTH,
> Mark
>
> > #dd if=/dev/zero of=vm1disk         bs=1k seek=6144k  count=1
> > #losetup /dev/loop1 vm1disk
> > #mkfs -t ext3 /dev/loop1
> > #mount /dev/loop1 /mnt
> >
> > #cp -ax /<directory>/  /mnt/         /* I do this instead of copying the
> > whole / directory because I don't want some of the directories in Dom 1 */
> >
> > I modify /mnt/etc/fstab to put /dev/sda1 to root
> >
> > # umount /dev/loop1
> >
> > then I put this line in /etc/xc/defaults (I used a copy of it called
> > dom1)
> >
> > vbd_list = [ ('phy:loop1','sda1','w' ) ]
> >
> >
> > After this I try to create the dom1 by saying but I get an error.
> >
> > #xc_dom_create.py   -D vmid=1 -f dom1
> > Parsing config file 'dom1'
> > VM image           : "/boot/xenolinux.gz"
> > VM ramdisk         : ""
> > VM memory (MB)     : "64"
> > VM IP address(es)  : "130.207.98.36; 169.254.1.1"
> > VM block device(s) : "phy:loop1,sda1,w"
> > VM cmdline         :
> > "ip=130.207.98.36:169.254.1.0:130.207.98.1:255.255.255.0::eth0:off
> > root=/dev/sda1 ro 4 VMID=1 usr=/dev/sda6"
> > Error looking up phy:loop1
> >
> >
> > Can someone please help me with this error?
> >
> > Thanks,
> > Sanjay
> >
> >
> >
> >
> >
> > ------------------------------------------------------- This SF.net
> > email is sponsored by: IT Product Guide on ITManagersJournal Use IT
> > products in your business? Tell us what you think of them. Give us Your
> > Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
> > http://productguide.itmanagersjournal.com/guidepromo.tmpl
> > _______________________________________________ Xen-devel mailing list
> > Xen-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/xen-devel
>


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl

^ permalink raw reply	[relevance 5%]

* Re: problem creating a new domain
  2004-10-19 21:34  5%   ` Sanjay Kumar
@ 2004-10-20 14:54  0%     ` Matthieu PATOU
  2004-10-20 19:27  0%       ` Sanjay Kumar
  0 siblings, 1 reply; 200+ results
From: Matthieu PATOU @ 2004-10-20 14:54 UTC (permalink / raw)
  To: Sanjay Kumar; +Cc: xen-devel

add the parameter (ip "off") in your domain configuration file 
it will add the parameter ip=off on the kernel boot line and so everything
will be ok

mat
On October 19, 11:34 pm Sanjay Kumar <ksanjay@cc.gatech.edu> wrote:
> Hi Mark,
> I switched to Xen2.0 with linux 2.4.27 kernel for dom0
>
> now I create the virtual disk in the same way as I described below.
>
> now when I try to boot another domain i see problems with DHCP. below are
> the logs
>
> Using config file "/etc/xen/dom1".
> Started domain ExampleDomain, console on port 9609
> ************ REMOTE CONSOLE: CTRL-] TO QUIT ********
> Linux version 2.4.27-xenU (root@andrea) (gcc version 3.1.1) #3 Tue Oct 19
> 13:56:24 EDT 2004
> On node 0 totalpages: 16384
> zone(0): 4096 pages.
> zone(1): 12288 pages.
> zone(2): 0 pages.
> Kernel command line:  ip=:1.2.3.4::::eth0:dhcp root=/dev/hda1 ro 4
> Initializing CPU#0
> Xen reported: 2193.379 MHz processor.
> Calibrating delay loop... 4404.01 BogoMIPS
> Memory: 62768k/65536k available (1341k kernel code, 2768k reserved, 267k
> data, 60k init, 0k highmem)
> Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
> Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
> Mount cache hash table entries: 512 (order: 0, 4096 bytes)
> Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
> Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
> CPU: L1 I cache: 12K, L1 D cache: 8K
> CPU: L2 cache: 512K
> CPU: Intel(R) Pentium(R) 4 CPU 2.20GHz stepping 04
> POSIX conformance testing by UNIFIX
> Linux NET4.0 for Linux 2.4
> Based upon Swansea University Computer Society NET3.039
> Initializing RT netlink socket
> Starting kswapd
> Journalled Block Device driver loaded
> Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
> Event-channel device installed.
> Xen virtual console successfully installed as tty
> Starting Xen Balloon driver
> pty: 256 Unix98 ptys configured
> [XEN] Initialising virtual block device driver
> RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
> loop: loaded (max 8 devices)
> SCSI subsystem driver Revision: 1.00
> kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
> kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
> [XEN] Initialising virtual ethernet driver.
> [XEN] Netfront recovered tx=0 rxfree=0
> NET4: Linux TCP/IP 1.0 for NET4.0
> IP Protocols: ICMP, UDP, TCP
> IP: routing cache hash table of 512 buckets, 4Kbytes
> TCP: Hash tables configured (established 4096 bind 8192)
> Sending DHCP requests .......  timed out
>
> Here Sending DHCP requests keep timing out and it keeps retrying. so boot
> doesn't proceed beyond this point.
>
> Can anybody please let me know what I might be doing wrong.
>
> Thanks,
> Sanjay
>
>
> ----------------------------------
> http://www.cc.gatech.edu/~ksanjay/
>
> On Mon, 18 Oct 2004, M.A. Williamson wrote:
>
> > >  Hi Folks,
> > >  I am using xen1.2.
> > >  I create the disk image as described in the Xen2.0 user manual
> > chapter 5.
> >  Sorry but that won't work :-(
> >
> >  Xen 1.2 can only export sections of physical disks (e.g. partitions,
> >  whole disks, or Xen Virtual Disks) to other domains. If you want to
> >  store filesystems in disk files, you should move to Xen 2.0-beta
> >  (soon to be Xen 2.0-release).
> >
> >  The nearest you can get on Xen 1.2 is to create a Virtual Disk and
> >  then use that. Tying yourself to 1.2 is probably not a good idea
> >  though - Virtual Disks aren't supported by 2.0. We'd certainly prefer
> >  people to move to 2.0 now - it's stable and virtually release-ready
> >  and has a whole load of new features, improved tools and better
> > hardware support.
> >  A good way to install a new domain's filesystem is using debootstrap
> >  (as described in the appendix of the manual).
> >
> >  Let us know how you get on.
> >
> >  HTH,
> >  Mark
> >
> > >  #dd if=/dev/zero of=vm1disk         bs=1k seek=6144k  count=1
> > >  #losetup /dev/loop1 vm1disk
> > >  #mkfs -t ext3 /dev/loop1
> > >  #mount /dev/loop1 /mnt
> > >
> > >  #cp -ax /<directory>/  /mnt/         /* I do this instead of
> > >  copying the whole / directory because I don't want some of the
> > > directories in Dom 1 */
> > >  I modify /mnt/etc/fstab to put /dev/sda1 to root
> > >
> > >  # umount /dev/loop1
> > >
> > >  then I put this line in /etc/xc/defaults (I used a copy of it called
> > >  dom1)
> > >
> > >  vbd_list = [ ('phy:loop1','sda1','w' ) ]
> > >
> > >
> > >  After this I try to create the dom1 by saying but I get an error.
> > >
> > >  #xc_dom_create.py   -D vmid=1 -f dom1
> > >  Parsing config file 'dom1'
> > >  VM image           : "/boot/xenolinux.gz"
> > >  VM ramdisk         : ""
> > >  VM memory (MB)     : "64"
> > >  VM IP address(es)  : "130.207.98.36; 169.254.1.1"
> > >  VM block device(s) : "phy:loop1,sda1,w"
> > >  VM cmdline         :
> > >  "ip=130.207.98.36:169.254.1.0:130.207.98.1:255.255.255.0::eth0:off
> > >  root=/dev/sda1 ro 4 VMID=1 usr=/dev/sda6"
> > >  Error looking up phy:loop1
> > >
> > >
> > >  Can someone please help me with this error?
> > >
> > >  Thanks,
> > >  Sanjay
> > >
> > >
> > >
> > >
> > >
> > >  ------------------------------------------------------- This SF.net
> > >  email is sponsored by: IT Product Guide on ITManagersJournal Use IT
> > >  products in your business? Tell us what you think of them. Give us
> > >  Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find
> > >  out more http://productguide.itmanagersjournal.com/guidepromo.tmpl
> > >  _______________________________________________ Xen-devel mailing
> > >  list Xen-devel@lists.sourceforge.net
> > >  https://lists.sourceforge.net/lists/listinfo/xen-devel
> >
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
> Use IT products in your business? Tell us what you think of them. Give us
> Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out
> more http://productguide.itmanagersjournal.com/guidepromo.tmpl
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xen-devel
>


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl

^ permalink raw reply	[relevance 0%]

* Re: problem creating a new domain
  2004-10-20 14:54  0%     ` Matthieu PATOU
@ 2004-10-20 19:27  0%       ` Sanjay Kumar
  2004-10-20 21:12  0%         ` Matthieu PATOU
  0 siblings, 1 reply; 200+ results
From: Sanjay Kumar @ 2004-10-20 19:27 UTC (permalink / raw)
  To: Matthieu PATOU; +Cc: xen-devel

Hi Matthieu,
Will this ip="off" option disable the network connection?
When I tried to boot new domain with the ip="off" option,
the DHCP problem went away and it reported that various devices (e.g. NIC,
Graphics card etc.) have been removed from the system (I am using the same
disk image as dom0 but with xenU kernel).
further down the boot processes, some of my network services (e.g
NFS) don't work.

any ideas?


----------------------------------
http://www.cc.gatech.edu/~ksanjay/

On Wed, 20 Oct 2004, Matthieu PATOU wrote:

> add the parameter (ip "off") in your domain configuration file
> it will add the parameter ip=off on the kernel boot line and so everything
> will be ok
> mat
> On October 19, 11:34 pm Sanjay Kumar <ksanjay@cc.gatech.edu> wrote:
> > Hi Mark,
> > I switched to Xen2.0 with linux 2.4.27 kernel for dom0
> >
> > now I create the virtual disk in the same way as I described below.
> >
> > now when I try to boot another domain i see problems with DHCP. below are
> > the logs
> >
> > Using config file "/etc/xen/dom1".
> > Started domain ExampleDomain, console on port 9609
> > ************ REMOTE CONSOLE: CTRL-] TO QUIT ********
> > Linux version 2.4.27-xenU (root@andrea) (gcc version 3.1.1) #3 Tue Oct 19
> > 13:56:24 EDT 2004
> > On node 0 totalpages: 16384
> > zone(0): 4096 pages.
> > zone(1): 12288 pages.
> > zone(2): 0 pages.
> > Kernel command line:  ip=:1.2.3.4::::eth0:dhcp root=/dev/hda1 ro 4
> > Initializing CPU#0
> > Xen reported: 2193.379 MHz processor.
> > Calibrating delay loop... 4404.01 BogoMIPS
> > Memory: 62768k/65536k available (1341k kernel code, 2768k reserved, 267k
> > data, 60k init, 0k highmem)
> > Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
> > Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
> > Mount cache hash table entries: 512 (order: 0, 4096 bytes)
> > Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
> > Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
> > CPU: L1 I cache: 12K, L1 D cache: 8K
> > CPU: L2 cache: 512K
> > CPU: Intel(R) Pentium(R) 4 CPU 2.20GHz stepping 04
> > POSIX conformance testing by UNIFIX
> > Linux NET4.0 for Linux 2.4
> > Based upon Swansea University Computer Society NET3.039
> > Initializing RT netlink socket
> > Starting kswapd
> > Journalled Block Device driver loaded
> > Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
> > Event-channel device installed.
> > Xen virtual console successfully installed as tty
> > Starting Xen Balloon driver
> > pty: 256 Unix98 ptys configured
> > [XEN] Initialising virtual block device driver
> > RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
> > loop: loaded (max 8 devices)
> > SCSI subsystem driver Revision: 1.00
> > kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
> > kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
> > [XEN] Initialising virtual ethernet driver.
> > [XEN] Netfront recovered tx=0 rxfree=0
> > NET4: Linux TCP/IP 1.0 for NET4.0
> > IP Protocols: ICMP, UDP, TCP
> > IP: routing cache hash table of 512 buckets, 4Kbytes
> > TCP: Hash tables configured (established 4096 bind 8192)
> > Sending DHCP requests .......  timed out
> >
> > Here Sending DHCP requests keep timing out and it keeps retrying. so boot
> > doesn't proceed beyond this point.
> >
> > Can anybody please let me know what I might be doing wrong.
> >
> > Thanks,
> > Sanjay
> >
> >
> > ----------------------------------
> > http://www.cc.gatech.edu/~ksanjay/
> >
> > On Mon, 18 Oct 2004, M.A. Williamson wrote:
> >
> > > >  Hi Folks,
> > > >  I am using xen1.2.
> > > >  I create the disk image as described in the Xen2.0 user manual
> > > chapter 5.
> > >  Sorry but that won't work :-(
> > >
> > >  Xen 1.2 can only export sections of physical disks (e.g. partitions,
> > >  whole disks, or Xen Virtual Disks) to other domains. If you want to
> > >  store filesystems in disk files, you should move to Xen 2.0-beta
> > >  (soon to be Xen 2.0-release).
> > >
> > >  The nearest you can get on Xen 1.2 is to create a Virtual Disk and
> > >  then use that. Tying yourself to 1.2 is probably not a good idea
> > >  though - Virtual Disks aren't supported by 2.0. We'd certainly prefer
> > >  people to move to 2.0 now - it's stable and virtually release-ready
> > >  and has a whole load of new features, improved tools and better
> > > hardware support.
> > >  A good way to install a new domain's filesystem is using debootstrap
> > >  (as described in the appendix of the manual).
> > >
> > >  Let us know how you get on.
> > >
> > >  HTH,
> > >  Mark
> > >
> > > >  #dd if=/dev/zero of=vm1disk         bs=1k seek=6144k  count=1
> > > >  #losetup /dev/loop1 vm1disk
> > > >  #mkfs -t ext3 /dev/loop1
> > > >  #mount /dev/loop1 /mnt
> > > >
> > > >  #cp -ax /<directory>/  /mnt/         /* I do this instead of
> > > >  copying the whole / directory because I don't want some of the
> > > > directories in Dom 1 */
> > > >  I modify /mnt/etc/fstab to put /dev/sda1 to root
> > > >
> > > >  # umount /dev/loop1
> > > >
> > > >  then I put this line in /etc/xc/defaults (I used a copy of it called
> > > >  dom1)
> > > >
> > > >  vbd_list = [ ('phy:loop1','sda1','w' ) ]
> > > >
> > > >
> > > >  After this I try to create the dom1 by saying but I get an error.
> > > >
> > > >  #xc_dom_create.py   -D vmid=1 -f dom1
> > > >  Parsing config file 'dom1'
> > > >  VM image           : "/boot/xenolinux.gz"
> > > >  VM ramdisk         : ""
> > > >  VM memory (MB)     : "64"
> > > >  VM IP address(es)  : "130.207.98.36; 169.254.1.1"
> > > >  VM block device(s) : "phy:loop1,sda1,w"
> > > >  VM cmdline         :
> > > >  "ip=130.207.98.36:169.254.1.0:130.207.98.1:255.255.255.0::eth0:off
> > > >  root=/dev/sda1 ro 4 VMID=1 usr=/dev/sda6"
> > > >  Error looking up phy:loop1
> > > >
> > > >
> > > >  Can someone please help me with this error?
> > > >
> > > >  Thanks,
> > > >  Sanjay
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >  ------------------------------------------------------- This SF.net
> > > >  email is sponsored by: IT Product Guide on ITManagersJournal Use IT
> > > >  products in your business? Tell us what you think of them. Give us
> > > >  Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find
> > > >  out more http://productguide.itmanagersjournal.com/guidepromo.tmpl
> > > >  _______________________________________________ Xen-devel mailing
> > > >  list Xen-devel@lists.sourceforge.net
> > > >  https://lists.sourceforge.net/lists/listinfo/xen-devel
> > >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
> > Use IT products in your business? Tell us what you think of them. Give us
> > Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out
> > more http://productguide.itmanagersjournal.com/guidepromo.tmpl
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/xen-devel
> >
>


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl

^ permalink raw reply	[relevance 0%]

* Re: problem creating a new domain
  2004-10-20 19:27  0%       ` Sanjay Kumar
@ 2004-10-20 21:12  0%         ` Matthieu PATOU
  0 siblings, 0 replies; 200+ results
From: Matthieu PATOU @ 2004-10-20 21:12 UTC (permalink / raw)
  To: Sanjay Kumar; +Cc: xen-devel, mat

Why do you mean by "have been removed" ?
I use a lightweight kernel for xenU so it might be why i don't see message
about device removed....

Have you try to connect to the domain console ? (xm console <domain_name>) ?
If so can you check your network configuration ... what are the network
service messages ? 

Is your ip not duplicated ?
for your information my kernel command line is the following ... and
everything is ok ...


Kernel command line:  ip=off root=/dev/hdb1 ro

Mat
On October 20, 9:27 pm Sanjay Kumar <ksanjay@cc.gatech.edu> wrote:
> Hi Matthieu,
> Will this ip="off" option disable the network connection?
> When I tried to boot new domain with the ip="off" option,
> the DHCP problem went away and it reported that various devices (e.g.
> NIC, Graphics card etc.) have been removed from the system (I am using
> the same disk image as dom0 but with xenU kernel).
> further down the boot processes, some of my network services (e.g
> NFS) don't work.
>
> any ideas?
>
>
> ----------------------------------
> http://www.cc.gatech.edu/~ksanjay/
>
> On Wed, 20 Oct 2004, Matthieu PATOU wrote:
>
> >  add the parameter (ip "off") in your domain configuration file
> >  it will add the parameter ip=off on the kernel boot line and so
> >  everything will be ok
> >  mat
> >  On October 19, 11:34 pm Sanjay Kumar <ksanjay@cc.gatech.edu> wrote:
> > >  Hi Mark,
> > >  I switched to Xen2.0 with linux 2.4.27 kernel for dom0
> > >
> > >  now I create the virtual disk in the same way as I described below.
> > >
> > >  now when I try to boot another domain i see problems with DHCP.
> > >  below are the logs
> > >
> > >  Using config file "/etc/xen/dom1".
> > >  Started domain ExampleDomain, console on port 9609
> > >  ************ REMOTE CONSOLE: CTRL-] TO QUIT ********
> > >  Linux version 2.4.27-xenU (root@andrea) (gcc version 3.1.1) #3 Tue
> > >  Oct 19 13:56:24 EDT 2004
> > >  On node 0 totalpages: 16384
> > >  zone(0): 4096 pages.
> > >  zone(1): 12288 pages.
> > >  zone(2): 0 pages.
> > >  Kernel command line:  ip=:1.2.3.4::::eth0:dhcp root=/dev/hda1 ro 4
> > >  Initializing CPU#0
> > >  Xen reported: 2193.379 MHz processor.
> > >  Calibrating delay loop... 4404.01 BogoMIPS
> > >  Memory: 62768k/65536k available (1341k kernel code, 2768k reserved,
> > >  267k data, 60k init, 0k highmem)
> > >  Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
> > >  Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
> > >  Mount cache hash table entries: 512 (order: 0, 4096 bytes)
> > >  Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
> > >  Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
> > >  CPU: L1 I cache: 12K, L1 D cache: 8K
> > >  CPU: L2 cache: 512K
> > >  CPU: Intel(R) Pentium(R) 4 CPU 2.20GHz stepping 04
> > >  POSIX conformance testing by UNIFIX
> > >  Linux NET4.0 for Linux 2.4
> > >  Based upon Swansea University Computer Society NET3.039
> > >  Initializing RT netlink socket
> > >  Starting kswapd
> > >  Journalled Block Device driver loaded
> > >  Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
> > >  Event-channel device installed.
> > >  Xen virtual console successfully installed as tty
> > >  Starting Xen Balloon driver
> > >  pty: 256 Unix98 ptys configured
> > >  [XEN] Initialising virtual block device driver
> > >  RAMDISK driver initialized: 16 RAM disks of 4096K size 1024
> > >  blocksize loop: loaded (max 8 devices)
> > >  SCSI subsystem driver Revision: 1.00
> > >  kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno =
> > >  2 kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno
> > >  = 2 [XEN] Initialising virtual ethernet driver.
> > >  [XEN] Netfront recovered tx=0 rxfree=0
> > >  NET4: Linux TCP/IP 1.0 for NET4.0
> > >  IP Protocols: ICMP, UDP, TCP
> > >  IP: routing cache hash table of 512 buckets, 4Kbytes
> > >  TCP: Hash tables configured (established 4096 bind 8192)
> > >  Sending DHCP requests .......  timed out
> > >
> > >  Here Sending DHCP requests keep timing out and it keeps retrying.
> > >  so boot doesn't proceed beyond this point.
> > >
> > >  Can anybody please let me know what I might be doing wrong.
> > >
> > >  Thanks,
> > >  Sanjay
> > >
> > >
> > >  ----------------------------------
> > >  http://www.cc.gatech.edu/~ksanjay/
> > >
> > >  On Mon, 18 Oct 2004, M.A. Williamson wrote:
> > >
> > > > >   Hi Folks,
> > > > >   I am using xen1.2.
> > > > >   I create the disk image as described in the Xen2.0 user manual
> > > >  chapter 5.
> > > >   Sorry but that won't work :-(
> > > >
> > > >   Xen 1.2 can only export sections of physical disks (e.g.
> > > >   partitions, whole disks, or Xen Virtual Disks) to other domains.
> > > >   If you want to store filesystems in disk files, you should move
> > > >   to Xen 2.0-beta (soon to be Xen 2.0-release).
> > > >
> > > >   The nearest you can get on Xen 1.2 is to create a Virtual Disk
> > > >   and then use that. Tying yourself to 1.2 is probably not a good
> > > >   idea though - Virtual Disks aren't supported by 2.0. We'd
> > > >   certainly prefer people to move to 2.0 now - it's stable and
> > > >   virtually release-ready and has a whole load of new features,
> > > >  improved tools and better hardware support.
> > > >   A good way to install a new domain's filesystem is using
> > > >   debootstrap (as described in the appendix of the manual).
> > > >
> > > >   Let us know how you get on.
> > > >
> > > >   HTH,
> > > >   Mark
> > > >
> > > > >   #dd if=/dev/zero of=vm1disk         bs=1k seek=6144k  count=1
> > > > >   #losetup /dev/loop1 vm1disk
> > > > >   #mkfs -t ext3 /dev/loop1
> > > > >   #mount /dev/loop1 /mnt
> > > > >
> > > > >   #cp -ax /<directory>/  /mnt/         /* I do this instead of
> > > > >   copying the whole / directory because I don't want some of the
> > > > >  directories in Dom 1 */
> > > > >   I modify /mnt/etc/fstab to put /dev/sda1 to root
> > > > >
> > > > >   # umount /dev/loop1
> > > > >
> > > > >   then I put this line in /etc/xc/defaults (I used a copy of it
> > > > >   called dom1)
> > > > >
> > > > >   vbd_list = [ ('phy:loop1','sda1','w' ) ]
> > > > >
> > > > >
> > > > >   After this I try to create the dom1 by saying but I get an
> > > > > error.
> > > > >   #xc_dom_create.py   -D vmid=1 -f dom1
> > > > >   Parsing config file 'dom1'
> > > > >   VM image           : "/boot/xenolinux.gz"
> > > > >   VM ramdisk         : ""
> > > > >   VM memory (MB)     : "64"
> > > > >   VM IP address(es)  : "130.207.98.36; 169.254.1.1"
> > > > >   VM block device(s) : "phy:loop1,sda1,w"
> > > > >   VM cmdline         :
> > > > >   "ip=130.207.98.36:169.254.1.0:130.207.98.1:255.255.255.0::eth0:
> > > > > off
> > > > >   root=/dev/sda1 ro 4 VMID=1 usr=/dev/sda6"
> > > > >   Error looking up phy:loop1
> > > > >
> > > > >
> > > > >   Can someone please help me with this error?
> > > > >
> > > > >   Thanks,
> > > > >   Sanjay
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >   ------------------------------------------------------- This
> > > > >   SF.net email is sponsored by: IT Product Guide on
> > > > >   ITManagersJournal Use IT products in your business? Tell us
> > > > >   what you think of them. Give us Your Opinions, Get Free
> > > > >   ThinkGeek Gift Certificates! Click to find out more
> > > > >   http://productguide.itmanagersjournal.com/guidepromo.tmpl
> > > > >   _______________________________________________ Xen-devel
> > > > >   mailing list Xen-devel@lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/xen-devel
> > >
> > >
> > >  -------------------------------------------------------
> > >  This SF.net email is sponsored by: IT Product Guide on
> > >  ITManagersJournal Use IT products in your business? Tell us what
> > >  you think of them. Give us Your Opinions, Get Free ThinkGeek Gift
> > >  Certificates! Click to find out more http://productguide.itmanagersj
> > > ournal.com/guidepromo.tmpl
> > >  _______________________________________________
> > >  Xen-devel mailing list
> > >  Xen-devel@lists.sourceforge.net
> > >  https://lists.sourceforge.net/lists/listinfo/xen-devel
> > >
> >
>


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl

^ permalink raw reply	[relevance 0%]

* xen2.0 building error
@ 2004-11-10  6:44  7% yi yang
  2004-11-10  7:13  0% ` Niraj Tolia
  2004-11-10 11:11  0% ` Steven Hand
  0 siblings, 2 replies; 200+ results
From: yi yang @ 2004-11-10  6:44 UTC (permalink / raw)
  To: xen-devel

Hi,

I have downloaded the latest xen2.0 release, but I cant finish
building it. Here is the console dump:(by the way, I am using my lab
machine to download the whole files, and then transfer them to my own
machine, so the files should be complete.  since if my domain is
localhost, it seems I cant download the whole files.)
[yangyi@localhost xen-2.0.bk]$make
......
......
drivers/xen/balloon/balloon.c: In function `balloon_read':
drivers/xen/balloon/balloon.c:612: warning: ignoring return value of
`copy_to_user', declared with attribute warn_unused_result
 LD      drivers/xen/balloon/built-in.o
 CC      drivers/xen/blkfront/blkfront.o
drivers/xen/blkfront/blkfront.c: In function `blkif_queue_request':
drivers/xen/blkfront/blkfront.c:109: sorry, unimplemented: inlining
failed in call to 'translate_req_to_pfn': function body not available
drivers/xen/blkfront/blkfront.c:342: sorry, unimplemented: called from here
make[5]: *** [drivers/xen/blkfront/blkfront.o] Error 1
make[4]: *** [drivers/xen/blkfront] Error 2
make[3]: *** [drivers/xen] Error 2
make[2]: *** [drivers] Error 2
make[2]: Leaving directory `/home/yangyi/xen-2.0.bk/linux-2.6.9-xenU'
make[1]: *** [build] Error 2
make[1]: Leaving directory `/home/yangyi/xen-2.0.bk'
make: *** [kernels] Error 2
[yangyi@localhost xen-2.0.bk]$

Any Suggestions?

Thanks a lot!

Yi


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click

^ permalink raw reply	[relevance 7%]

* Re: xen2.0 building error
  2004-11-10  6:44  7% xen2.0 building error yi yang
@ 2004-11-10  7:13  0% ` Niraj Tolia
  2004-11-10 11:11  0% ` Steven Hand
  1 sibling, 0 replies; 200+ results
From: Niraj Tolia @ 2004-11-10  7:13 UTC (permalink / raw)
  To: yi yang; +Cc: xen-devel

Are you using GCC 3.4? This patch from a previous email might help.
<http://zaynar.demon.co.uk/misc2/blkfront.patch>.

Niraj

--
http://www.cs.cmu.edu/~ntolia


On Wed, 10 Nov 2004 01:44:00 -0500, yi yang <yangyiyy@gmail.com> wrote:
> Hi,
> 
> I have downloaded the latest xen2.0 release, but I cant finish
> building it. Here is the console dump:(by the way, I am using my lab
> machine to download the whole files, and then transfer them to my own
> machine, so the files should be complete.  since if my domain is
> localhost, it seems I cant download the whole files.)
> [yangyi@localhost xen-2.0.bk]$make
> ......
> ......
> drivers/xen/balloon/balloon.c: In function `balloon_read':
> drivers/xen/balloon/balloon.c:612: warning: ignoring return value of
> `copy_to_user', declared with attribute warn_unused_result
>  LD      drivers/xen/balloon/built-in.o
>  CC      drivers/xen/blkfront/blkfront.o
> drivers/xen/blkfront/blkfront.c: In function `blkif_queue_request':
> drivers/xen/blkfront/blkfront.c:109: sorry, unimplemented: inlining
> failed in call to 'translate_req_to_pfn': function body not available
> drivers/xen/blkfront/blkfront.c:342: sorry, unimplemented: called from here
> make[5]: *** [drivers/xen/blkfront/blkfront.o] Error 1
> make[4]: *** [drivers/xen/blkfront] Error 2
> make[3]: *** [drivers/xen] Error 2
> make[2]: *** [drivers] Error 2
> make[2]: Leaving directory `/home/yangyi/xen-2.0.bk/linux-2.6.9-xenU'
> make[1]: *** [build] Error 2
> make[1]: Leaving directory `/home/yangyi/xen-2.0.bk'
> make: *** [kernels] Error 2
> [yangyi@localhost xen-2.0.bk]$
> 
> Any Suggestions?
> 
> Thanks a lot!
> 
> Yi
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Sybase ASE Linux Express Edition - download now for FREE
> LinuxWorld Reader's Choice Award Winner for best database on Linux.
> http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xen-devel
> 


-- 
http://www.cs.cmu.edu/~ntolia


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click

^ permalink raw reply	[relevance 0%]

* Re: xen2.0 building error
  2004-11-10  6:44  7% xen2.0 building error yi yang
  2004-11-10  7:13  0% ` Niraj Tolia
@ 2004-11-10 11:11  0% ` Steven Hand
  1 sibling, 0 replies; 200+ results
From: Steven Hand @ 2004-11-10 11:11 UTC (permalink / raw)
  To: yi yang; +Cc: xen-devel, Steven.Hand


>I have downloaded the latest xen2.0 release, but I cant finish
>building it. Here is the console dump:(by the way, I am using my lab
>machine to download the whole files, and then transfer them to my own
>machine, so the files should be complete.  since if my domain is
>localhost, it seems I cant download the whole files.)
>[yangyi@localhost xen-2.0.bk]$make
>......
>......
>drivers/xen/balloon/balloon.c: In function `balloon_read':
>drivers/xen/balloon/balloon.c:612: warning: ignoring return value of
>`copy_to_user', declared with attribute warn_unused_result
> LD      drivers/xen/balloon/built-in.o
> CC      drivers/xen/blkfront/blkfront.o
>drivers/xen/blkfront/blkfront.c: In function `blkif_queue_request':
>drivers/xen/blkfront/blkfront.c:109: sorry, unimplemented: inlining
>failed in call to 'translate_req_to_pfn': function body not available
>drivers/xen/blkfront/blkfront.c:342: sorry, unimplemented: called from here
>make[5]: *** [drivers/xen/blkfront/blkfront.o] Error 1
>make[4]: *** [drivers/xen/blkfront] Error 2
>make[3]: *** [drivers/xen] Error 2
>make[2]: *** [drivers] Error 2
>make[2]: Leaving directory `/home/yangyi/xen-2.0.bk/linux-2.6.9-xenU'
>make[1]: *** [build] Error 2
>make[1]: Leaving directory `/home/yangyi/xen-2.0.bk'
>make: *** [kernels] Error 2
>[yangyi@localhost xen-2.0.bk]$
>
>Any Suggestions?

What's the platform you're building on? In particular, what version 
of gcc are you using?

cheers,

S.



-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click

^ permalink raw reply	[relevance 0%]

* Re: etherbridge bottleneck
  @ 2004-11-15 16:01  3% ` David Becker
  0 siblings, 0 replies; 200+ results
From: David Becker @ 2004-11-15 16:01 UTC (permalink / raw)
  To: Ian Pratt; +Cc: xen-devel


" We have no problem getting 900Mb/s in/out of xenU's and the wire on our
" 2.4GHz Xeon systems (regardless of whether using uniprocessor, SMP or
" hyperthreading).

Hmmm, I'm certainly having a problem getting over 500Mbps into xenU.

I ran another set of tests, this time between two
identical Dell 1650s, (one 1.4GHz PIII, 2GB ram, e1000 NICs) directly
connected to a Catalyst 4005. 

Running a 10sec iperf run, I got these bandwidths:
Stock linux-2.4.25 (no patches or network tuning)
	941 Mbps stock -> stock  (identical speed both directions)
	941 Mbps stock -> stock

Running 2.4.27-xen0 on xen-2.0 before starting xend or the network script:
	894 Mbps xen0 -> stock 
	622 Mbps stock -> xen0 

After starting xend, which brought up the bridge:
	734 Mbps xen0 -> stock 
	524 Mbps stock -> xen0

After starting one xenU, xen0 was a touch slower:
	729 Mbps xen0 -> stock 
	515 Mbps stock -> xen0

	530 Mbps xenU -> stock 
	470 Mbps stock -> xenU
	427 Mbps xenU -> xen0
        253 Mbps xen0 -> xenU

After taking the vif off the bridge 
with 'brctl delif xen-br0 vif1.0':
	463 Mbps xenU -> xen0
	312 Mbps xen0 -> xenU



Here is a full acount of boot messages, etc:



+++++++++++++++++++++++++
Stock linux boot messages
+++++++++++++++++++++++++
Linux version 2.4.25-smp (becker@growl) (gcc version 3.3.3 20040125 (prerelease) (Debian)) #1 SMP Sat Feb 28 19:56:32 EST 2004
BIOS-provided physical RAM map:               
 BIOS-e820: 0000000000000000 - 00000000000a0000 (usable)
 BIOS-e820: 0000000000100000 - 000000007fff0000 (usable)
 BIOS-e820: 000000007fff0000 - 000000007fffec00 (ACPI data)
 BIOS-e820: 000000007fffec00 - 000000007ffff000 (reserved) 
 BIOS-e820: 00000000fec00000 - 00000000fec10000 (reserved)
 BIOS-e820: 00000000fee00000 - 00000000fee10000 (reserved)
 BIOS-e820: 00000000fff00000 - 0000000100000000 (reserved)
1151MB HIGHMEM available.                                 
896MB LOWMEM available.  
found SMP MP-table at 000fe710
hm, page 000fe000 reserved twice.
hm, page 000ff000 reserved twice.
hm, page 000f0000 reserved twice.
On node 0 totalpages: 524272     
zone(0): 4096 pages.        
zone(1): 225280 pages.
zone(2): 294896 pages.
ACPI: RSDP (v000 DELL                                      ) @ 0x000fdc60
ACPI: RSDT (v001 DELL   PE1650   0x00000001 MSFT 0x0100000a) @ 0x000fdc74
ACPI: FADT (v001 DELL   PE1650   0x00000001 MSFT 0x0100000a) @ 0x000fdca4
ACPI: MADT (v001 DELL   PE1650   0x00000001 MSFT 0x0100000a) @ 0x000fdd18
ACPI: SPCR (v001 DELL   PE1650   0x00000001 MSFT 0x0100000a) @ 0x000fdd82
ACPI: DSDT (v001 DELL   PE1650   0x00000001 MSFT 0x0100000a) @ 0x00000000
ACPI: Local APIC address 0xfee00000                                      
ACPI: LAPIC (acpi_id[0x01] lapic_id[0x00] enabled)
Processor #0 Pentium(tm) Pro APIC version 17      
ACPI: LAPIC (acpi_id[0x02] lapic_id[0x01] disabled)
ACPI: LAPIC_NMI (acpi_id[0x01] high edge lint[0x1])
ACPI: LAPIC_NMI (acpi_id[0x02] high edge lint[0x1])
ACPI: IOAPIC (id[0x01] address[0xfec00000] global_irq_base[0x0])
IOAPIC[0]: Assigned apic_id 1                                   
IOAPIC[0]: apic_id 1, version 17, address 0xfec00000, IRQ 0-15
ACPI: IOAPIC (id[0x02] address[0xfec01000] global_irq_base[0x10])
IOAPIC[1]: Assigned apic_id 2                                    
IOAPIC[1]: apic_id 2, version 17, address 0xfec01000, IRQ 16-31
ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high edge)   
ACPI BALANCE SET                                            
Using ACPI (MADT) for SMP configuration information
Kernel command line: ip=172.16.4.183:::255.255.252.0:rack099-xen:eth0:off root=/dev/sda1 console=tty0 console=ttyS0 -b
Initializing CPU#0                    
Detected 1396.496 MHz processor.
Console: colour VGA+ 80x25      
Calibrating delay loop... 2785.28 BogoMIPS
Memory: 2068540k/2097088k available (2125k kernel code, 28164k reserved, 689k data, 364k init, 1179584k highmem)
Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
Inode cache hash table entries: 131072 (order: 8, 1048576 bytes) 
Mount cache hash table entries: 512 (order: 0, 4096 bytes)      
Buffer cache hash table entries: 131072 (order: 7, 524288 bytes)
Page-cache hash table entries: 524288 (order: 9, 2097152 bytes) 
CPU: L1 I cache: 16K, L1 D cache: 16K                          
CPU: L2 cache: 512K                  
Intel machine check architecture supported.
Intel machine check reporting enabled on CPU#0.
Enabling fast FPU save and restore... done.    
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... OK.                    
POSIX conformance testing by UNIFIX
mtrr: v1.40 (20010327) Richard Gooch (rgooch@atnf.csiro.au)
mtrr: detected mtrr type: Intel                            
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: L2 cache: 512K                  
Intel machine check reporting enabled on CPU#0.
CPU0: Intel(R) Pentium(R) III CPU family      1400MHz stepping 01
per-CPU timeslice cutoff: 1462.55 usecs.                         
enabled ExtINT on CPU#0                 
ESR value before enabling vector: 00000000
ESR value after enabling vector: 00000000 
Error: only one processor found.         
ENABLING IO-APIC IRQs           
..TIMER: vector=0x31 pin1=-1 pin2=0
...trying to set up timer (IRQ0) through the 8259A ... 
..... (found pin 0) ...works.                          
Using local APIC timer interrupts.
calibrating APIC timer ...        
..... CPU clock speed is 1396.4558 MHz.
..... host bus clock speed is 132.9956 MHz.
cpu: 0, clocks: 1329956, slice: 664978     
CPU0<T0:1329952,T1:664960,D:14,S:664978,C:1329956>
Waiting on wait_init_idle (map = 0x0)             
All processors have done init_idle   
ACPI: Subsystem revision 20040116 
PCI: PCI BIOS revision 2.10 entry at 0xfc6ce, last bus=2
PCI: Using configuration type 1                         
ACPI: Interpreter enabled      
ACPI: Using IOAPIC for interrupt routing
ACPI: System [ACPI] (supports S0 S4 S5) 
ACPI: PCI Root Bridge [PCI0] (00:00)   
PCI: Probing PCI hardware (bus 00)  
PCI: Ignoring BAR0-3 of IDE controller 00:0f.1
ACPI: PCI Root Bridge [PCI1] (00:01)          
PCI: Probing PCI hardware (bus 01)  
ACPI: PCI Root Bridge [PCI2] (00:02)
PCI: Probing PCI hardware (bus 02)  
ACPI: PCI Interrupt Link [LNKA] (IRQs 3 4 *5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKB] (IRQs 3 4 5 6 *7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKC] (IRQs *3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKD] (IRQs 3 4 5 6 *7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKE] (IRQs 3 4 5 6 7 9 11 12 14) 
ACPI: PCI Interrupt Link [LNKF] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKG] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKH] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKI] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKJ] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKK] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKL] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKM] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKN] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKO] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LNKP] (IRQs 3 4 5 6 7 9 11 12 14)
ACPI: PCI Interrupt Link [LUSB] (IRQs 3 4 5 6 7 *11 12 14) 
PCI: Probing PCI hardware                                 
ACPI: PCI Interrupt Link [LUSB] enabled at IRQ 11
testing the IO APIC.......................       
                                          

.................................... done.
PCI: Using ACPI for IRQ routing           
PCI: if you experience problems, try using option 'pci=noacpi' or even 'acpi=off'
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket                         
Starting kswapd               
allocated 32 pages and 32 bhs reserved for the highmem bounces
Journalled Block Device driver loaded                         
Detected PS/2 Mouse Port.            
pty: 256 Unix98 ptys configured
keyboard: Timeout - AT keyboard not present?(ed)
keyboard: Timeout - AT keyboard not present?(f4)
Serial driver version 5.05c (2001-07-08) with MANY_PORTS SHARE_IRQ SERIAL_PCI enabled
ttyS00 at 0x03f8 (irq = 4) is a 16550A
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Intel(R) PRO/1000 Network Driver - version 5.2.20-k1                 
Copyright (c) 1999-2003 Intel Corporation.          
eth0: Intel(R) PRO/1000 Network Connection
eth1: Intel(R) PRO/1000 Network Connection
pcnet32.c:v1.27a 10.02.2002 tsbogend@alpha.franken.de
Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
SvrWks CSB5: IDE controller at PCI slot 00:0f.1                            
SvrWks CSB5: chipset revision 147              
SvrWks CSB5: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0x08b0-0x08b7, BIOS settings: hda:DMA, hdb:pio
    ide1: BM-DMA at 0x08b8-0x08bf, BIOS settings: hdc:pio, hdd:pio
hda: SAMSUNG CD-ROM SN-124, ATAPI CD/DVD-ROM drive                
hda: Disabling (U)DMA for SAMSUNG CD-ROM SN-124   
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14            
SCSI subsystem driver Revision: 1.00
scsi0 : Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev 6.2.36
        <Adaptec aic7899 Ultra160 SCSI adapter>                 
        aic7899: Ultra160 Wide Channel A, SCSI Id=7, 32/253 SCBs
                                                                
scsi1 : Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev 6.2.36
        <Adaptec aic7899 Ultra160 SCSI adapter>                 
        aic7899: Ultra160 Wide Channel B, SCSI Id=7, 32/253 SCBs
                                                                
blk: queue f7ba6818, I/O limit 4095Mb (mask 0xffffffff)
(scsi0:A:0): 160.000MB/s transfers (80.000MHz DT, offset 100, 16bit)
  Vendor: HITACHI   Model: DK32DJ-18MC       Rev: D4D4              
  Type:   Direct-Access                      ANSI SCSI revision: 03
blk: queue f7ba6618, I/O limit 4095Mb (mask 0xffffffff)            
  Vendor: PE/PV     Model: 1x3 SCSI BP       Rev: 0.28 
  Type:   Processor                          ANSI SCSI revision: 02
blk: queue f7ba6e18, I/O limit 4095Mb (mask 0xffffffff)            
scsi0:A:0:0: Tagged Queuing enabled.  Depth 253        
megaraid: v2.10.1 (Release Date: Wed Dec  3 15:34:42 EST 2003)
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0       
SCSI device sda: 35566478 512-byte hdwr sectors (18210 MB)
Partition check:                                          
 sda: sda1 sda2 sda3
Fusion MPT base driver 2.05.11.03
Copyright (c) 1999-2003 LSI Logic Corporation
mptbase: 0 MPT adapters found, 0 installed.  
Fusion MPT SCSI Host driver 2.05.11.03     
NET4: Linux TCP/IP 1.0 for NET4.0     
IP Protocols: ICMP, UDP, TCP, IGMP
IP: routing cache hash table of 16384 buckets, 128Kbytes
TCP: Hash tables configured (established 262144 bind 65536)
e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex           
IP-Config: Complete:                            
      device=eth0, addr=172.16.4.183, mask=255.255.252.0, gw=255.255.255.255,
     host=rack099-xen, domain=, nis-domain=(none),                           
     bootserver=255.255.255.255, rootserver=255.255.255.255, rootpath=
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.                   
EXT3-fs: INFO: recovery required on readonly filesystem.
EXT3-fs: write access will be enabled during recovery.  
kjournald starting.  Commit interval 5 seconds        
EXT3-fs: recovery complete.                   
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.      
Freeing unused kernel memory: 364k freed     
INIT: version 2.86 booting              

+++++++++++++++++++++++++

+++++++++++++++++++++++++
Xen boot messages
+++++++++++++++++++++++++
kernel /boot/xen.gz dom0_mem=40000 com1=9600,8n1
   [Multiboot-elf, <0x100000:0x3d3d0:0x35170>, shtab=0x173078, entry=0x100000]
module /boot/vmlinuz-2.4.27-xen0 ip=172.16.4.183:::255.255.252.0:rack099-xen:et
h0:off root=/dev/sda1 console=tty0 console=ttyS0
   [Multiboot-module @ 0x174000, 0x3068fc bytes]
boot
 __  __            ____    ___  
 \ \/ /___ _ __   |___ \  / _ \ 
  \  // _ \ '_ \    __) || | | |
  /  \  __/ | | |  / __/ | |_| |
 /_/\_\___|_| |_| |_____(_)___/ 
                                
 http://www.cl.cam.ac.uk/netos/xen
 University of Cambridge Computer Laboratory

 Xen version 2.0 (becker@cs.duke.edu) (gcc version 3.3.4 (Debian 1:3.3.4-6sarge1)) Wed Nov 10 11:15:00 EST 2004
 Latest ChangeSet: information unavailable

(XEN) Initialised 2047MB memory (524272 pages) on a 2047MB machine
(XEN) Xen heap size is 10740KB
(XEN) CPU0: Before vendor init, caps: 0383fbff 00000000 00000000, vendor = 0
(XEN) CPU caps: 0383fbff 00000000 00000000 00000000
(XEN) found SMP MP-table at 000fe710
(XEN) Memory Reservation 0xfe710, 4096 bytes
(XEN) Memory Reservation 0xf0000, 4096 bytes
(XEN) ACPI: RSDP (v000 DELL                                      ) @ 0x000fdc60
(XEN) ACPI: RSDT (v001 DELL   PE1650   0x00000001 MSFT 0x0100000a) @ 0x000fdc74
(XEN) ACPI: FADT (v001 DELL   PE1650   0x00000001 MSFT 0x0100000a) @ 0x000fdca4
(XEN) ACPI: MADT (v001 DELL   PE1650   0x00000001 MSFT 0x0100000a) @ 0x000fdd18
(XEN) ACPI: SPCR (v001 DELL   PE1650   0x00000001 MSFT 0x0100000a) @ 0x000fdd82
(XEN) ACPI: DSDT (v001 DELL   PE1650   0x00000001 MSFT 0x0100000a) @ 0x00000000
(XEN) ACPI: Local APIC address 0xfee00000
(XEN) ACPI: LAPIC (acpi_id[0x01] lapic_id[0x00] enabled)
(XEN) Processor #0 Pentium(tm) Pro APIC version 17
(XEN) ACPI: LAPIC (acpi_id[0x02] lapic_id[0x01] disabled)
(XEN) ACPI: LAPIC_NMI (acpi_id[0x01] high edge lint[0x1])
(XEN) ACPI: LAPIC_NMI (acpi_id[0x02] high edge lint[0x1])
(XEN) Using ACPI for processor (LAPIC) configuration information
(XEN) Intel MultiProcessor Specification v1.4
(XEN)     Virtual Wire compatibility mode.
(XEN) OEM ID: DELL     Product ID: PE 011B      APIC at: 0xFEE00000
(XEN) I/O APIC #1 Version 17 at 0xFEC00000.
(XEN) I/O APIC #2 Version 17 at 0xFEC01000.
(XEN) Enabling APIC mode: Flat. Using 2 I/O APICs
(XEN) Processors: 1
(XEN) Using scheduler: Borrowed Virtual Time (bvt)
(XEN) Initializing CPU#0
(XEN) Detected 1396.476 MHz processor.
(XEN) CPU0: Before vendor init, caps: 0383fbff 00000000 00000000, vendor = 0
(XEN) CPU caps: 0383fbff 00000000 00000000 00000000
(XEN) CPU0 booted
(XEN) enabled ExtINT on CPU#0
(XEN) ESR value before enabling vector: 00000000
(XEN) ESR value after enabling vector: 00000000
(XEN) Error: only one processor found.
(XEN) ENABLING IO-APIC IRQs
(XEN) Setting 1 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 1 ... ok.
(XEN) Setting 2 in the phys_id_present_map
(XEN) ...changing IO-APIC physical APIC ID to 2 ... ok.
(XEN) init IO_APIC IRQs
(XEN) ..TIMER: vector=0x41 pin1=2 pin2=0
(XEN) ..MP-BIOS bug: 8254 timer not connected to IO-APIC
(XEN) ...trying to set up timer (IRQ0) through the 8259A ... 
(XEN) ..... (found pin 0) ...works.
(XEN) Using local APIC timer interrupts.
(XEN) Calibrating APIC timer for CPU0...
(XEN) ..... CPU speed is 1396.4537 MHz.
(XEN) ..... Bus speed is 132.9955 MHz.
(XEN) ..... bus_scale = 0x00008830
(XEN) Time init:
(XEN) .... System Time: 20000234ns
(XEN) .... cpu_freq:    00000000:533C8BD0
(XEN) .... scale:       00000001:6EA30E07
(XEN) .... Wall Clock:  1100530888s 190000us
(XEN) PCI: PCI BIOS revision 2.10 entry at 0xfc6ce, last bus=2
(XEN) PCI: Using configuration type 1
(XEN) PCI: Probing PCI hardware
(XEN) PCI: Probing PCI hardware (bus 00)
(XEN) PCI: Ignoring BAR0-3 of IDE controller 00:0f.1
(XEN) PCI: Discovered primary peer bus 01 [IRQ]
(XEN) PCI: Discovered primary peer bus 02 [IRQ]
(XEN) PCI: Using IRQ router ServerWorks [1166/0201] at 00:0f.0
(XEN) PCI->APIC IRQ transform: (B1,I2,P0) -> 17
(XEN) PCI->APIC IRQ transform: (B1,I4,P0) -> 16
(XEN) PCI->APIC IRQ transform: (B1,I6,P0) -> 18
(XEN) PCI->APIC IRQ transform: (B1,I6,P1) -> 19
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found: 'GUEST_OS=linux,GUEST_VER=2.4,XEN_VER=2.0,VIRT_BASE=0xC0000000'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  02800000->02b068fc
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->05310000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0100000->c0453e34
(XEN)  Init. ramdisk: c0454000->c0454000
(XEN)  Phys-Mach map: c0454000->c045dc40
(XEN)  Page tables:   c045e000->c0461000
(XEN)  Start info:    c0461000->c0462000
(XEN)  Boot stack:    c0462000->c0463000
(XEN)  TOTAL:         c0000000->c0800000
(XEN)  ENTRY ADDRESS: c0100000
(XEN) Scrubbing DOM0 RAM: .done.
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen).
(XEN) Scrubbing Free RAM: .....................done.

+++++++++++++++++++++++++

+++++++++++++++++++++++++
Xen-0 boot messages
+++++++++++++++++++++++++
Linux version 2.4.27-xen0 (becker@pant) (gcc version 3.3.4 (Debian 1:3.3.4-6sarge1)) #3 Wed Nov 10 11:29:37 EST 2004
On node 0 totalpages: 10000
zone(0): 4096 pages.
zone(1): 5904 pages.
zone(2): 0 pages.
Kernel command line: ip=172.16.4.183:::255.255.252.0:rack099-xen:eth0:off root=/dev/sda1 console=tty0 console=ttyS0
Initializing CPU#0
Xen reported: 1396.476 MHz processor.
Console: colour VGA+ 80x25
Linux version 2.4.27-xen0 (becker@pant) (gcc version 3.3.4 (Debian 1:3.3.4-6sarge1)) #3 Wed Nov 10 11:29:37 EST 2004
On node 0 totalpages: 10000
zone(0): 4096 pages.
zone(1): 5904 pages.
zone(2): 0 pages.
Kernel command line: ip=172.16.4.183:::255.255.252.0:rack099-xen:eth0:off root=/dev/sda1 console=tty0 console=ttyS0
Initializing CPU#0
Xen reported: 1396.476 MHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 2791.83 BogoMIPS
Memory: 36056k/40000k available (2245k kernel code, 3944k reserved, 716k data, 112k init, 0k highmem)
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: L2 cache: 512K
CPU: Intel(R) Pentium(R) III CPU family      1400MHz stepping 01
POSIX conformance testing by UNIFIX
PCI: Probing PCI hardware
PCI: Probing PCI hardware (bus 00)
PCI: Probing PCI hardware (bus 01)
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Event-channel device installed.
Xen virtual console successfully installed as ttyS
Starting Xen Balloon driver
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
keyboard: Timeout - AT keyboard not present?(ed)
keyboard: Timeout - AT keyboard not present?(f4)
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
Intel(R) PRO/1000 Network Driver - version 5.2.52-k3
Copyright (c) 1999-2004 Intel Corporation.
PCI: Obtained IRQ 17 for device 01:02.0
e1000: eth0: e1000_probe: Intel(R) PRO/1000 Network Connection
PCI: Obtained IRQ 16 for device 01:04.0
e1000: eth1: e1000_probe: Intel(R) PRO/1000 Network Connection
pcnet32.c:v1.30c 05.25.2004 tsbogend@alpha.franken.de
Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
SvrWks CSB5: IDE controller at PCI slot 00:0f.1
SvrWks CSB5: chipset revision 147
SvrWks CSB5: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0x08b0-0x08b7, BIOS settings: hda:DMA, hdb:pio
    ide1: BM-DMA at 0x08b8-0x08bf, BIOS settings: hdc:pio, hdd:pio
hda: SAMSUNG CD-ROM SN-124, ATAPI CD/DVD-ROM drive
hda: Disabling (U)DMA for SAMSUNG CD-ROM SN-124
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
hda: attached ide-cdrom driver.
hda: ATAPI 24X CD-ROM drive, 128kB Cache
Uniform CD-ROM driver Revision: 3.12
SCSI subsystem driver Revision: 1.00
Red Hat/Adaptec aacraid driver (1.1-3 Nov 10 2004 11:29:04)
PCI: Obtained IRQ 18 for device 01:06.0
PCI: Obtained IRQ 19 for device 01:06.1
scsi0 : Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev 6.2.36
        <Adaptec aic7899 Ultra160 SCSI adapter>
        aic7899: Ultra160 Wide Channel A, SCSI Id=7, 32/253 SCBs

scsi1 : Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev 6.2.36
        <Adaptec aic7899 Ultra160 SCSI adapter>
        aic7899: Ultra160 Wide Channel B, SCSI Id=7, 32/253 SCBs

(scsi0:A:0): 160.000MB/s transfers (80.000MHz DT, offset 100, 16bit)
  Vendor: HITACHI   Model: DK32DJ-18MC       Rev: D4D4
  Type:   Direct-Access                      ANSI SCSI revision: 03
  Vendor: PE/PV     Model: 1x3 SCSI BP       Rev: 0.28
  Type:   Processor                          ANSI SCSI revision: 02
scsi0:A:0:0: Tagged Queuing enabled.  Depth 32
megaraid: v1.18k (Release Date: Thu Aug 28 10:05:11 EDT 2003)
megaraid: no BIOS enabled.
scsi2 : SCSI host adapter emulation for IDE ATAPI devices
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
SCSI device sda: 35566478 512-byte hdwr sectors (18210 MB)
Partition check:
 sda: sda1 sda2 sda3
Attached scsi generic sg1 at scsi0, channel 0, id 6, lun 0,  type 3
Initializing Cryptographic API
Initialising Xen netif backend
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 4096)
e1000: eth0: e1000_watchdog: NIC Link is Up 1000 Mbps Full Duplex
IP-Config: Complete:
      device=eth0, addr=172.16.4.183, mask=255.255.252.0, gw=255.255.255.255,
     host=rack099-xen, domain=, nis-domain=(none),
     bootserver=255.255.255.255, rootserver=255.255.255.255, rootpath=
ip_tables: (C) 2000-2002 Netfilter core team
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NET4: Ethernet Bridge 008 for NET4.0
Bridge firewalling registered
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
All bugs added by David S. Miller <davem@redhat.com>
kjournald starting.  Commit interval 5 seconds
EXT3 FS 2.4-0.9.19, 19 August 2002 on sd(8,1), internal journal
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem).
Freeing unused kernel memory: 112k freed
INIT: version 2.86 booting

+++++++++++++++++++++++++

+++++++++++++++++++++++++
xm messages
+++++++++++++++++++++++++
# xm info
system                 : Linux
host                   : rack099-xen
release                : 2.4.27-xen0
version                : #3 Wed Nov 10 11:29:37 EST 2004
machine                : i686
cores                  : 1
hyperthreads_per_core  : 1
cpu_mhz                : 1396
memory                 : 2047
free_memory            : 1485
rack099-xen:~# xm info
system                 : Linux
host                   : rack099-xen
release                : 2.4.27-xen0
version                : #3 Wed Nov 10 11:29:37 EST 2004
machine                : i686
cores                  : 1
hyperthreads_per_core  : 1
cpu_mhz                : 1396
memory                 : 2047
free_memory            : 1485
# xm list
Name              Id  Mem(MB)  CPU  State  Time(s)  Console
Domain-0           0       34    0  r----    174.5        
grant              1      499    0  -b---     53.5    9601

+++++++++++++++++++++++++

+++++++++++++++++++++++++
iperfrun  stock to stock
+++++++++++++++++++++++++
# iperf -c 172.16.7.3
------------------------------------------------------------
Client connecting to 172.16.7.3, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  5] local 172.16.4.183 port 32812 connected with 172.16.7.3 port 5001
[ ID] Interval       Transfer     Bandwidth
[  5]  0.0-10.0 sec  1.10 GBytes   941 Mbits/sec


+++++++++++++++++++++++++


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

^ permalink raw reply	[relevance 3%]

* Virtual ethernet driver.
@ 2004-11-25 22:57  5% Lukasz Grzelak
  0 siblings, 0 replies; 200+ results
From: Lukasz Grzelak @ 2004-11-25 22:57 UTC (permalink / raw)
  To: xen-devel

Hello,

I trying to run XEN 2.0 (2.4.27, 2.4.28, 2.6.9) on gentoo 2004.3.

When i boot guest domain i get this:

anubis xen # xm create -f ttylinux -c

Using config file "ttylinux".
Started domain ttylinux, console on port 9601
************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.4.28-xenU (root@anubis) (gcc version 3.3.3 20040217 
(Gentoo Linux 3.3.3, propolice-3.3-7)) #3 Thu Nov 25 22:05:31 CET 2004
On node 0 totalpages: 16384
zone(0): 4096 pages.
zone(1): 12288 pages.
zone(2): 0 pages.
Kernel command line:  ip=192.168.244.15:1.2.3.4::::eth0:off root=/dev/sda1 
ro
Initializing CPU#0
Xen reported: 1064.625 MHz processor.
Calibrating delay loop... 2116.81 BogoMIPS
Memory: 61792k/65536k available (2231k kernel code, 3744k reserved, 342k 
data, 64k init, 0k highmem)
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: Intel Pentium III (Coppermine) stepping 0a
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
VFS: Disk quotas vdquot_6.5.1
Journalled Block Device driver loaded
devfs: v1.12c (20020818) Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x0
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
SGI XFS with realtime, tracing, debug enabled
SGI XFS Quota Management subsystem
Event-channel device installed.
Xen virtual console successfully installed as tty
Starting Xen Balloon driver
pty: 256 Unix98 ptys configured
[XEN] Initialising virtual block device driver
[XEN] Timeout connecting block device driver!
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
SCSI subsystem driver Revision: 1.00
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
kmod: failed to exec /sbin/modprobe -s -k scsi_hostadapter, errno = 2
[XEN] Initialising virtual ethernet driver.


It stop here, and dont go :/



Regards,

Lukasz Grzelak
------------------------------------------------------
iTk - info@itk.pl - http://www.itk.pl - +48 91 8137012


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

^ permalink raw reply	[relevance 5%]

* Re: Virtual ethernet driver.
       [not found]     <E1CXsIv-0003AL-00@mx10.web.de>
@ 2004-11-27 21:31  4% ` Bjoern Sessler
  0 siblings, 0 replies; 200+ results
From: Bjoern Sessler @ 2004-11-27 21:31 UTC (permalink / raw)
  To: xen-devel

>>>>Perhaps start xend with 'xend trace_start' and then see if
>>>>xend.log can shed any light.
>>>
>>>Xend work fine i thing i have broken kernel or system.
>>
>>Have you used your own kernel config? You haven't disabled
>>CONFIG_XEN_NETDEV_FRONTEND have you?
>>
>>What happens if you use our binary install?
> 
> 
> The same, I tryed xen-2.0-install (2.4.27 and 2.4.9). Meaby gentoo 2004.3 
> dont work correctly ?

i start believe the same... with same kernel ttylinux now boots, network 
is ok, rtc-errors (...) of course. with my cloned gentoo xen0 system 
this happens (xen 2.0.1 source, but similar with bin-version):

Linux version 2.6.9-xenU (root@vm0) (gcc version 3.3.4 20040623 (Gentoo 
Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)) #2 Sat Nov 27 17:36:31 GMT 2004
BIOS-provided physical RAM map:
  Xen: 0000000000000000 - 0000000004000000 (usable)
64MB LOWMEM available.
DMI not present.
Built 1 zonelists
Kernel command line: 
ip=192.168.1.101:1.2.3.4:192.168.1.1:255.255.255.0::eth0:off 
root=/dev/hda1 ro 3
Initializing CPU#0
PID hash table entries: 512 (order: 9, 8192 bytes)
Xen reported: 1357.516 MHz processor.
Using tsc for high-res timesource
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 62004k/65536k available (1768k kernel code, 3492k reserved, 478k 
data, 112k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 256K (64 bytes/line)
CPU: AMD Athlon(tm)  stepping 00
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... disabled
NET: Registered protocol family 16
Initializing Cryptographic API
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Xen virtual console successfully installed as tty
Event-channel device installed.
Starting Xen Balloon driver
xen_blk: Initialising virtual block device driver
Using anticipatory io scheduler
Unable to handle kernel NULL pointer dereference at virtual address 00000008
  printing eip:
c0185116
*pde = ma 00000000 pa 55555000
  [<c0185203>] sysfs_create_dir+0x40/0x73

  [<c0185203>] sysfs_create_dir+0x40/0x73

  [<c0200779>] create_dir+0x1f/0x4b

  [<c0200c6d>] kobject_add+0x93/0xdd

  [<c0200cdf>] kobject_register+0x28/0x59

  [<c021da17>] blk_register_queue+0x96/0xc0

  [<c02283dc>] xlvbd_get_gendisk+0x19d/0x1bb

  [<c0228462>] xlvbd_init_device+0x68/0xdc

  [<c022853b>] xlvbd_init+0x65/0x98

  [<c0227d1e>] blkif_connect+0xae/0xc2

  [<c0227459>] blkif_int+0x0/0x19a

  [<c0227eaa>] blkif_ctrlif_rx+0x36/0x38

  [<c0108a56>] __ctrl_if_rxmsg_deferred+0x4a/0x59

  [<c012b8ae>] worker_thread+0x1ea/0x2e0

  [<c0108a0c>] __ctrl_if_rxmsg_deferred+0x0/0x59

  [<c0118cae>] default_wake_function+0x0/0x12

  [<c0118cae>] default_wake_function+0x0/0x12

  [<c012b6c4>] worker_thread+0x0/0x2e0

  [<c012f8e9>] kthread+0xa5/0xab

  [<c012f844>] kthread+0x0/0xab

  [<c010ed7d>] kernel_thread_helper+0x5/0xb

Oops: 0000 [#1]
PREEMPT
Modules linked in:
CPU:    0
EIP:    0061:[<c0185116>]    Not tainted VLI
EFLAGS: 00010292   (2.6.9-xenU)
EIP is at create_dir+0x17/0x9a
eax: c10ebe48   ebx: c118ce3c   ecx: 00000000   edx: c118ce40
esi: 00000000   edi: c10ebe48   ebp: c10dec00   esp: c10ebe1c
ds: 007b   es: 007b   ss: 0069
Process events/0 (pid: 3, threadinfo=c10ea000 task=c10d9020)
Stack: c10afe2c c02fbaf0 c0185203 c118ce3c c118ce3c c10afe2c c0185203 
c118ce3c
        00000000 c118ce40 c10ebe48 00000000 00000000 c0200779 c118ce3c 
c118ce3c
        ffffffea c0200c6d c118ce3c fffffffd c118ce3c ffffffea c118ce3c 
c0200cdf
Call Trace:
  [<c0185203>] sysfs_create_dir+0x40/0x73

  [<c0185203>] sysfs_create_dir+0x40/0x73

  [<c0200779>] create_dir+0x1f/0x4b

  [<c0200c6d>] kobject_add+0x93/0xdd

  [<c0200cdf>] kobject_register+0x28/0x59

  [<c021da17>] blk_register_queue+0x96/0xc0

  [<c02283dc>] xlvbd_get_gendisk+0x19d/0x1bb

  [<c0228462>] xlvbd_init_device+0x68/0xdc

  [<c022853b>] xlvbd_init+0x65/0x98

  [<c0227d1e>] blkif_connect+0xae/0xc2

  [<c0227459>] blkif_int+0x0/0x19a

  [<c0227eaa>] blkif_ctrlif_rx+0x36/0x38

  [<c0108a56>] __ctrl_if_rxmsg_deferred+0x4a/0x59

  [<c012b8ae>] worker_thread+0x1ea/0x2e0

  [<c0108a0c>] __ctrl_if_rxmsg_deferred+0x0/0x59

  [<c0118cae>] default_wake_function+0x0/0x12

  [<c0118cae>] default_wake_function+0x0/0x12

  [<c012b6c4>] worker_thread+0x0/0x2e0

  [<c012f8e9>] kthread+0xa5/0xab

  [<c012f844>] kthread+0x0/0xab

  [<c010ed7d>] kernel_thread_helper+0x5/0xb

Code: 2f 2f c0 c7 80 88 00 00 00 e0 2e 2f c0 83 40 24 01 31 c0 c3 83 ec 
18 89 74 24 10 89 7c 24 14 89 5c 24 0c 8b 74 24 20 8b 7c 24 28 <8b> 46 
08 8d 48 68 ff 48 68 0f 88 c3 03 00 00 89 34 24 8b 44 24
  <6>xen_net: Initialising virtual ethernet driver.
xen_net: Failed to connect all virtual interfaces: err=-100
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
IPv4 over IPv4 tunneling driver
GRE over IPv4 tunneling driver
ip_conntrack version 2.1 (512 buckets, 4096 max) - 332 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
ipt_recent v0.3.1: Stephen Frost <sfrost@snowman.net>. 
http://snowman.net/projects/ipt_recent/
arp_tables: (C) 2002 David S. Miller
NET: Registered protocol family 1
NET: Registered protocol family 17
NET: Registered protocol family 15
IP-Config: Device `eth0' not found.

--- hangs ---

my xend.log (xend trace_start) says the following:

[2004-11-27 22:03:23 xend] INFO (SrvDaemon:607) Xend Daemon started
[2004-11-27 22:03:23 xend] INFO (XendRoot:91) EVENT> xend.start 0
[2004-11-27 22:03:36 xend] DEBUG (XendDomainInfo:720) init_domain> 
Created domain=5 name=vm101 memory=64
[2004-11-27 22:03:36 xend] INFO (console:92) Created console id=13 
domain=5 port=9605
[2004-11-27 22:03:36 xend] DEBUG (XendDomainInfo:1102) Creating vbd 
dom=5 uname=phy:vg1/vm101
[2004-11-27 22:03:36 xend] DEBUG (blkif:146) Connecting blkif 
<BlkifBackendInterface 5 0>
[2004-11-27 22:03:36 xend] DEBUG (XendDomainInfo:1102) Creating vbd 
dom=5 uname=phy:vg1/vm101-swap
[2004-11-27 22:03:36 xend] DEBUG (blkif:146) Connecting blkif 
<BlkifBackendInterface 5 0>
[2004-11-27 22:03:36 xend] DEBUG (XendDomainInfo:1102) Creating vbd 
dom=5 uname=phy:sdb7
[2004-11-27 22:03:36 xend] DEBUG (blkif:146) Connecting blkif 
<BlkifBackendInterface 5 0>
[2004-11-27 22:03:36 xend] DEBUG (XendDomainInfo:1102) Creating vbd 
dom=5 uname=phy:sdc5
[2004-11-27 22:03:36 xend] DEBUG (blkif:146) Connecting blkif 
<BlkifBackendInterface 5 0>
[2004-11-27 22:03:36 xend] DEBUG (XendDomainInfo:1079) Creating vif 
dom=5 vif=0 mac=aa:00:00:57:6a:d7
[2004-11-27 22:03:36 xend] INFO (XendRoot:91) EVENT> xend.console.create 
[13, 5, 9605]
[2004-11-27 22:03:37 xend] INFO (XendRoot:91) EVENT> xend.domain.create 
['vm101', '5']
[2004-11-27 22:03:37 xend] INFO (XendRoot:91) EVENT> xend.domain.unpause 
['vm101', '5']
[2004-11-27 22:03:37 xend] DEBUG (blkif:192) Connecting blkif to event 
channel <BlkifBackendInterface 5 0> ports=19:3
[2004-11-27 22:03:55 xend] INFO (console:42) Console connected 13 
127.0.0.1 32794
[2004-11-27 22:03:55 xend] INFO (XendRoot:91) EVENT> 
xend.console.connect [13, '127.0.0.1', 32794]

any hints? what's going wrong here? what's other than in older gentoo? 
it wasn't a problem like that to get xeno-unstable or 1.2 to work on 
older versions. devfs replaced with udev now.

Thanks,

Björn



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

^ permalink raw reply	[relevance 4%]

* Kernel panic - not syncing : Question from Xen newbie
@ 2004-12-02  7:04  5% Mukund Srinivasan
  0 siblings, 0 replies; 200+ results
From: Mukund Srinivasan @ 2004-12-02  7:04 UTC (permalink / raw)
  To: xen-devel

Hi

I'm new to Xen and just installed using the instructions from the website. I'm
having Fedora Core Linux distribution. The CPU is a Intel P4 2.4 GHz processor.
Xen installation on dom0 works properly. Then, I want to create a new domain
using the simple example shown in the Xen documentation website. I'm getting a
kernel panic error, and can't figure out how to proceed. I've gone over the
mailing list archive, but could'nt find a solution for this. Any pointer or help
is greatly appreciated.

Here's the ouput when I try to create a new domain:

----BEGIN----

# xm create -c /etc/xen/xmexample1 vmid=1
Using config file "/etc/xen/xmexample1".
Started domain ExampleDomain, console on port 9612
************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.6.9-xenU (root@overlay1.netlab.cs.umn.edu) (gcc version 3.3.3
20040412 (Red Hat Linux 3.3.3-7)) #1 Wed Dec 1 23:57:09 CST 2004
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000004000000 (usable)
64MB LOWMEM available.
DMI not present.
Built 1 zonelists
Kernel command line:  root=/dev/hda3 ro 4
Initializing CPU#0
PID hash table entries: 512 (order: 9, 8192 bytes)
Xen reported: 2386.624 MHz processor.
Using tsc for high-res timesource
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 62508k/65536k available (1553k kernel code, 2988k reserved, 432k data,
92k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: Trace cache: 12K uops, L1 D cache: 8K
CPU: L2 cache: 512K
CPU: Intel(R) Pentium(R) 4 CPU 2.40GHz stepping 07
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... disabled
NET: Registered protocol family 16
Initializing Cryptographic API
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Xen virtual console successfully installed as tty
Event-channel device installed.
Starting Xen Balloon driver
xen_blk: Initialising virtual block device driver
Using anticipatory io scheduler
xen_net: Initialising virtual ethernet driver.
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
NET: Registered protocol family 1
NET: Registered protocol family 17
[XEN:vbd_update:drivers/xen/blkfront/blkfront.c:194] >
[XEN:vbd_update:drivers/xen/blkfront/blkfront.c:195] <
[XEN:vbd_update:drivers/xen/blkfront/blkfront.c:194] >
[XEN:vbd_update:drivers/xen/blkfront/blkfront.c:195] <
[XEN:vbd_update:drivers/xen/blkfront/blkfront.c:194] >
[XEN:vbd_update:drivers/xen/blkfront/blkfront.c:195] <
ioctl 00005310 not supported by Xen blkdev
[XEN:vbd_update:drivers/xen/blkfront/blkfront.c:194] >
[XEN:vbd_update:drivers/xen/blkfront/blkfront.c:195] <
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(3,3)
 <0>Rebooting in 1 seconds..

----END----

Thanks.
Mukund



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

^ permalink raw reply	[relevance 5%]

* Revised balloon driver
@ 2004-12-02 16:45  6% Keir Fraser
  2004-12-08 15:45  0% ` Mat
  2004-12-10  3:15  0% ` Paul Larson
  0 siblings, 2 replies; 200+ results
From: Keir Fraser @ 2004-12-02 16:45 UTC (permalink / raw)
  To: xen-devel


I've checked in a large number of changes to the balloon driver to the
2.0-testing and unstable trees. There should now be rather fewer bugs
and the balloon will play more nicely with other device drivers (by
which I mean it is less likely to crash the VM).

To see balloon info: cat /proc/xen/balloon
(I'm happy to receive feedback on the layout/contents. I confused
myself with it while testing so I guess it may not be very intuitive
right now :-).

To set memory target: echo <memsz> >/proc/xen/balloon
(<memsz> is e.g., 300M, 2G, whatever).

NOTE: If you set the memory target too low it is still very easy to
kill your VM (on 2.6 the OOM killer gets activated). I'm not sure how
avoidable this is -- for now you'll just have to exercise caution when
reducing the target below a few 10's of MBs.

 -- Keir


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

^ permalink raw reply	[relevance 6%]

* Re: Revised balloon driver
  2004-12-02 16:45  6% Revised balloon driver Keir Fraser
@ 2004-12-08 15:45  0% ` Mat
  2004-12-09 17:17  5%   ` Keir Fraser
  2004-12-10  3:15  0% ` Paul Larson
  1 sibling, 1 reply; 200+ results
From: Mat @ 2004-12-08 15:45 UTC (permalink / raw)
  To: xen-devel

Hi
i'm willing to test it, i think i'm in xen 2.0 and not 2.0-testing.
Is there an easy way to migrate ?
To use the ballon driver, what is needed apart compiling the driver in xen0
and xenU kernel ?

Is there a documentation ?
Couple of weeks ago i've seen a message stating that in order to be able to
shrink/unshrink memory size you have to pass a parameter at xenU kernel at
boot time . What is this parameter, have i misunderstood ?

Mat
On December 2, 5:45 pm Keir Fraser <Keir.Fraser@cl.cam.ac.uk> wrote:
>
> I've checked in a large number of changes to the balloon driver to the
> 2.0-testing and unstable trees. There should now be rather fewer bugs
> and the balloon will play more nicely with other device drivers (by
> which I mean it is less likely to crash the VM).
>
> To see balloon info: cat /proc/xen/balloon
> (I'm happy to receive feedback on the layout/contents. I confused
> myself with it while testing so I guess it may not be very intuitive
> right now :-).
>
> To set memory target: echo <memsz> >/proc/xen/balloon
> (<memsz> is e.g., 300M, 2G, whatever).
>
> NOTE: If you set the memory target too low it is still very easy to
> kill your VM (on 2.6 the OOM killer gets activated). I'm not sure how
> avoidable this is -- for now you'll just have to exercise caution when
> reducing the target below a few 10's of MBs.
>
>  -- Keir
>


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

^ permalink raw reply	[relevance 0%]

* Xen 2.0 and VIA Samuel 2 stepping 03
@ 2004-12-08 23:01  4% Adam Sulmicki
  0 siblings, 0 replies; 200+ results
From: Adam Sulmicki @ 2004-12-08 23:01 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1054 bytes --]


Hello,
 	I have attached a patch wich adds support for 4kb pages
 	to xen 2.0 proper.

 	(No changes were required from xen 2.0-beta. Apprently mixing
 	xenolinux from one release and xen kernel from another release is
 	a no-no. Other than that there were no problems. Thanks to Rupert
 	Schlick for helping to nail it down. The "noacpi" parameter
 	does not seem to be mandatory. Finally removed a bit uneeded
 	code from patch).

 	I have also attached sample output of booting xen and linux-dom0
 	on VIA  Samuel 2 stepping 03.

 	All in all, patch has been booted with xen 2.0 on:
 		* my via based system
 		* my pentium 3
 		* Rupert Schlick's via system

 	In order to repeat this you need:
 	1) get 2.0 release. You could do something like this
 		bk clone bk://xen.bkbits.net/xen-2.0.bk

 	2) apply attached patch, ex
 		patch -p1 < ../xen-20r.4kb-diff

 	How is the VIA Samuel 2 stepping 03 different from normal cpu?

 	1) lack of 4mb page support
 	2) lack of support for Conditional Move (CMOV) instruction
 	3) lack of ACPI support

Adam

[-- Attachment #2: Type: TEXT/PLAIN, Size: 4406 bytes --]

===== xen/arch/x86/Rules.mk 1.32 vs edited =====
--- 1.32/xen/arch/x86/Rules.mk	2004-11-17 06:43:29 -07:00
+++ edited/xen/arch/x86/Rules.mk	2004-12-07 14:16:40 -07:00
@@ -23,7 +23,7 @@ CFLAGS  += $(call test-gcc-flag,-fno-sta
 CFLAGS  += $(call test-gcc-flag,-fno-stack-protector-all)
 
 ifeq ($(TARGET_SUBARCH),x86_32)
-CFLAGS  += -m32 -march=i686
+CFLAGS  += -m32 -march=i586
 LDFLAGS := --oformat elf32-i386 
 endif
 
===== xen/arch/x86/setup.c 1.64 vs edited =====
--- 1.64/xen/arch/x86/setup.c	2004-10-21 11:11:29 -06:00
+++ edited/xen/arch/x86/setup.c	2004-12-07 14:16:40 -07:00
@@ -32,7 +32,7 @@ struct cpuinfo_x86 boot_cpu_data = { 0, 
 #if defined(__x86_64__)
 unsigned long mmu_cr4_features = X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE;
 #else
-unsigned long mmu_cr4_features = X86_CR4_PSE | X86_CR4_PGE;
+unsigned long mmu_cr4_features = X86_CR4_PGE;
 #endif
 EXPORT_SYMBOL(mmu_cr4_features);
 
===== xen/arch/x86/boot/x86_32.S 1.27 vs edited =====
--- 1.27/xen/arch/x86/boot/x86_32.S	2004-10-31 02:56:31 -07:00
+++ edited/xen/arch/x86/boot/x86_32.S	2004-12-08 09:25:21 -07:00
@@ -100,19 +100,29 @@ __start:
         xor     %eax,%eax
         rep     stosb
 
-        /* Initialize low and high mappings of all memory with 4MB pages */
-        mov     $idle_pg_table-__PAGE_OFFSET,%edi
-        mov     $0x1e3,%eax                  /* PRESENT+RW+A+D+4MB+GLOBAL */
-1:      mov     %eax,__PAGE_OFFSET>>20(%edi) /* high mapping */
+        /* Initialize low and high mappings of all memory */
+        /* build Page Table with 4kb pages */	
+        mov     $idle_pg_table_four-__PAGE_OFFSET,%edi
+        mov     $0x23,%eax                   /* PRESENT+RW+A */
+1:      mov     %eax,__PAGE_OFFSET>>10(%edi) /* high mapping */
         stosl                                /* low mapping */
-        add     $(1<<L2_PAGETABLE_SHIFT),%eax
-        cmp     $DIRECTMAP_PHYS_END+0x1e3,%eax
+        add     $(1<<L1_PAGETABLE_SHIFT),%eax
+        cmp     $DIRECTMAP_PHYS_END+0x23,%eax
         jne     1b
 1:      stosl   /* low mappings cover as much physmem as possible */
-        add     $(1<<L2_PAGETABLE_SHIFT),%eax
-        cmp     $__HYPERVISOR_VIRT_START+0x1e3,%eax
+        add     $(1<<L1_PAGETABLE_SHIFT),%eax
+        cmp     $__HYPERVISOR_VIRT_START+0x23,%eax
         jne     1b
-        
+
+	/* build Page Directory */
+        mov     $idle_pg_table-__PAGE_OFFSET,%edi
+        mov     $0x23,%eax                   /* PRESENT+RW+A */
+        add     $idle_pg_table_four-__PAGE_OFFSET,%eax
+1:      stosl
+        add     $(1<<L1_PAGETABLE_SHIFT),%eax
+        cmp     $idle_pg_table-__PAGE_OFFSET+0x1000-20,%edi
+        jne     1b
+
         /* Initialise IDT with simple error defaults. */
         lea     ignore_int,%edx
         mov     $(__HYPERVISOR_CS << 16),%eax
@@ -216,5 +226,7 @@ ENTRY(idle_pg_table) # Initial page dire
         .org 0x2000
 ENTRY(cpu0_stack)    # Initial stack is 8kB
         .org 0x4000
+ENTRY(idle_pg_table_four) # Initial page entries (4mb total)
+	.org 0x4000 + 4*1024*1024
 ENTRY(stext)
 ENTRY(_stext)
===== xen/arch/x86/x86_32/mm.c 1.48 vs edited =====
--- 1.48/xen/arch/x86/x86_32/mm.c	2004-11-13 10:32:42 -07:00
+++ edited/xen/arch/x86/x86_32/mm.c	2004-12-07 14:16:41 -07:00
@@ -57,13 +57,6 @@ void __set_fixmap(enum fixed_addresses i
 void __init paging_init(void)
 {
     void *ioremap_pt;
-    int i;
-
-    /* Idle page table 1:1 maps the first part of physical memory. */
-    for ( i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ )
-        idle_pg_table[i] = 
-            mk_l2_pgentry((i << L2_PAGETABLE_SHIFT) | 
-                          __PAGE_HYPERVISOR | _PAGE_PSE);
 
     /* Create page table for ioremap(). */
     ioremap_pt = (void *)alloc_xenheap_page();
===== xen/include/asm-x86/page.h 1.22 vs edited =====
--- 1.22/xen/include/asm-x86/page.h	2004-10-27 10:20:30 -06:00
+++ edited/xen/include/asm-x86/page.h	2004-12-07 14:16:42 -07:00
@@ -131,6 +131,7 @@ typedef struct { unsigned long pt_lo; } 
 #define va_to_l1mfn(_va) (l2_pgentry_val(linear_l2_table[_va>>L2_PAGETABLE_SHIFT]) >> PAGE_SHIFT)
 
 extern l2_pgentry_t idle_pg_table[ENTRIES_PER_L2_PAGETABLE];
+extern l2_pgentry_t idle_pg_table_four[ENTRIES_PER_L2_PAGETABLE*ENTRIES_PER_L2_PAGETABLE];
 extern void paging_init(void);
 
 /* Flush global pages as well. */

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Type: TEXT/PLAIN; charset=X-UNKNOWN; name="4kb-xen20release.log", Size: 6174 bytes --]

VFS: Mounted root (nfs filesystem) readonly.
Freeing unused kernel memory: 100k freed

sh-2.05b# mount /proc

sh-2.05b# cat /usr/src/cm/k-r
/sbin/kexec --load /usr/src/cm/xen/xen-2.0.bk/xen/xen --type=multiboot-x86 \
		--command-line="dom0_mem=65536 com1=19200,8n1 console=com1" \
                --module="/usr/src/cm/xen/xen-2.0.bk/dist/install/boot/vmlinuz-2.6.9-i586-xen0-full root=/dev/hda1 console=ttyS0,19200 xencons=ttyS" 

sh-2.05b# source /usr/src/cm/k-r
kexec_load succeeded (multiboot-x86)

sh-2.05b# /sbin/kexec -e
Starting new kernel
 __  __            ____    ___  
 \ \/ /___ _ __   |___ \  / _ \ 
  \  // _ \ '_ \    __) || | | |
  /  \  __/ | | |  / __/ | |_| |
 /_/\_\___|_| |_| |_____(_)___/ 
                                
 http://www.cl.cam.ac.uk/netos/xen
 University of Cambridge Computer Laboratory

 Xen version 2.0 (root@ccstar.lanl.gov) (gcc version 3.3.3 (SuSE Linux)) Wed Dec 8 08:34:05 MST 2004
 Latest ChangeSet: 2004/11/17 16:10:36 1.1591 419b77fc7lOGZy3pNuKwE_AZuDPPuQ

(XEN) Initialised 256MB memory (65536 pages) on a 256MB machine
(XEN) Xen heap size is 6704KB
(XEN) CPU0: Before vendor init, caps: 00803135 80803135 00000000, vendor = 5
(XEN) CPU caps: 00803135 80803135 00000000 00000000
(XEN) Using scheduler: Borrowed Virtual Time (bvt)
(XEN) Initializing CPU#0
(XEN) Detected 533.363 MHz processor.
(XEN) No local APIC present or hardware disabled
(XEN) CPU0: Before vendor init, caps: 00803135 80803135 00000000, vendor = 5
(XEN) CPU caps: 00803135 80803135 00000000 00000000
(XEN) CPU0 booted
(XEN) SMP motherboard not detected.
(XEN) Local APIC not detected. Using dummy APIC emulation.
(XEN) Time init:
(XEN) .... System Time: 20001972ns
(XEN) .... cpu_freq:    00000000:1FCA7A64
(XEN) .... scale:       00000001:DFF91897
(XEN) .... Wall Clock:  1102573179s 60000us
(XEN) PCI: Using configuration type 1
(XEN) PCI: Probing PCI hardware
(XEN) PCI: Probing PCI hardware (bus 00)
(XEN) PCI: Using IRQ router VIA [1106/8231] at 00:11.0
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Xen-ELF header found: 'GUEST_OS=linux,GUEST_VER=2.6,XEN_VER=2.0,VIRT_BASE=0xC0000000,LOADER=generic,PT_MODE_WRITABLE'
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Kernel image:  02800000->02a5217c
(XEN)  Initrd image:  00000000->00000000
(XEN)  Dom0 alloc.:   02c00000->06c00000
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: c0100000->c037dfa8
(XEN)  Init. ramdisk: c037e000->c037e000
(XEN)  Phys-Mach map: c037e000->c038e000
(XEN)  Page tables:   c038e000->c0391000
(XEN)  Start info:    c0391000->c0392000
(XEN)  Boot stack:    c0392000->c0393000
(XEN)  TOTAL:         c0000000->c0800000
(XEN)  ENTRY ADDRESS: c0100000
(XEN) Scrubbing DOM0 RAM: .done.
(XEN) Scrubbing Free RAM: ...done.
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen).
Linux version 2.6.9-xen0 (root@redbull) (gcc version 3.3.3 (SuSE Linux)) #1 Wed Dec 8 07:57:59 MST 2004
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000004000000 (usable)
64MB LOWMEM available.
DMI not present.
Built 1 zonelists
Kernel command line: root=/dev/hda1 console=ttyS0,19200 xencons=ttyS
Initializing CPU#0
PID hash table entries: 512 (order: 9, 8192 bytes)
Xen reported: 533.363 MHz processor.
Using tsc for high-res timesource
Console: colour VGA+ 80x25
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 62176k/65536k available (1557k kernel code, 3324k reserved, 673k data, 116k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: L1 I Cache: 64K (32 bytes/line), D cache 64K (32 bytes/line)
CPU: L2 Cache: 64K (32 bytes/line)
CPU: Centaur VIA Samuel 2 stepping 03
Checking 'hlt' instruction... disabled
NET: Registered protocol family 16
PCI: Using configuration type Xen
PCI: Probing PCI hardware
PCI: Probing PCI hardware (bus 00)
PCI: Probing PCI hardware
Initializing Cryptographic API
vesafb: probe of vesafb0 failed with error -6
i8042.c: Can't read CTR while initializing i8042.
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
Xen virtual console successfully installed as ttyS
Event-channel device installed.
Starting Xen Balloon driver
Initialising Xen netif backend
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
VP_IDE: IDE controller at PCI slot 0000:00:11.1
VP_IDE: chipset revision 6
VP_IDE: not 100% native mode: will probe irqs later
VP_IDE: VIA vt8231 (rev 10) IDE UDMA100 controller on pci0000:00:11.1
    ide0: BM-DMA at 0x1c40-0x1c47, BIOS settings: hda:pio, hdb:pio
    ide1: BM-DMA at 0x1c48-0x1c4f, BIOS settings: hdc:pio, hdd:pio
hda: STI Flash 6.2.0, CFA DISK drive
hda: set_drive_speed_status: status=0x51 { DriveReady SeekComplete Error }
hda: set_drive_speed_status: error=0x04 { DriveStatusError }
ide0: Drive 0 didn't accept speed setting. Oh, well.
Using anticipatory io scheduler
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
hda: max request size: 128KiB
hda: 125184 sectors (64 MB) w/1KiB Cache, CHS=978/4/32
 hda: hda1
mice: PS/2 mouse device common for all mice
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
NET: Registered protocol family 1
NET: Registered protocol family 17
Bridge firewalling registered
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
All bugs added by David S. Miller <davem@redhat.com>
 hda: hda1
 hda: hda1
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem).
Freeing unused kernel memory: 116k freed
Warning: unable to open an initial console.
Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
 <0>Rebooting in 1 seconds..(XEN) Domain 0 shutdown: rebooting machine.
\ø

LinuxBIOS-1.1.6.0Fallback Wed Mar 24 14:39:17 MST 2004 starting...

^ permalink raw reply	[relevance 4%]

* Re: Revised balloon driver
  2004-12-08 15:45  0% ` Mat
@ 2004-12-09 17:17  5%   ` Keir Fraser
  0 siblings, 0 replies; 200+ results
From: Keir Fraser @ 2004-12-09 17:17 UTC (permalink / raw)
  To: Mat; +Cc: xen-devel

> Hi
> i'm willing to test it, i think i'm in xen 2.0 and not 2.0-testing.
> Is there an easy way to migrate ?

Just build the xen-2.0-testing tree instead of xen-2.0.

> To use the ballon driver, what is needed apart compiling the driver in xen0
> and xenU kernel ?

It is always built-in -- you don't need to configure anything.

> Is there a documentation ?

No. :-)  To use from within the domain, just 
 # echo <memsize> >/proc/xen/balloon.

> Couple of weeks ago i've seen a message stating that in order to be able to
> shrink/unshrink memory size you have to pass a parameter at xenU kernel at
> boot time . What is this parameter, have i misunderstood ?

If you want to be able to grow a domain's memory allocation to greater
than its initial allocation, you need to add a "mem=<maxmemsz>" boot
parameter to the guest OS. If you only want to grow/shrink within the
bounds of the initial allocation then you don't need to do this.

 -- Keir

> Mat
> On December 2, 5:45 pm Keir Fraser <Keir.Fraser@cl.cam.ac.uk> wrote:
> >
> > I've checked in a large number of changes to the balloon driver to the
> > 2.0-testing and unstable trees. There should now be rather fewer bugs
> > and the balloon will play more nicely with other device drivers (by
> > which I mean it is less likely to crash the VM).
> >
> > To see balloon info: cat /proc/xen/balloon
> > (I'm happy to receive feedback on the layout/contents. I confused
> > myself with it while testing so I guess it may not be very intuitive
> > right now :-).
> >
> > To set memory target: echo <memsz> >/proc/xen/balloon
> > (<memsz> is e.g., 300M, 2G, whatever).
> >
> > NOTE: If you set the memory target too low it is still very easy to
> > kill your VM (on 2.6 the OOM killer gets activated). I'm not sure how
> > avoidable this is -- for now you'll just have to exercise caution when
> > reducing the target below a few 10's of MBs.
> >
> >  -- Keir
> >
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now. 
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xen-devel



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

^ permalink raw reply	[relevance 5%]

* Re: Revised balloon driver
  2004-12-02 16:45  6% Revised balloon driver Keir Fraser
  2004-12-08 15:45  0% ` Mat
@ 2004-12-10  3:15  0% ` Paul Larson
  1 sibling, 0 replies; 200+ results
From: Paul Larson @ 2004-12-10  3:15 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel

On Thu, 2004-12-02 at 10:45, Keir Fraser wrote:
> To set memory target: echo <memsz> >/proc/xen/balloon
> (<memsz> is e.g., 300M, 2G, whatever).
Might be nice to make sure the user actually specifies M, G, etc.  I
tried echoing 60000 and forgot the K the first time.  It fails pretty
spectacularly when it tries to reduce the memory to 60000 bytes as I'm
sure you know. :)  On the other hand, if you want users to be able to
give just a number and assume bytes, how about checking the number they
provide against the amount of memory currently in use to see if it's
likely to cause trouble? Or are there other issues here?

Another thing I noticed...
xen1:/proc/xen# free
             total       used       free     shared    buffers     cached
Mem:         62612      32148      30464          0       1848       7908
-/+ buffers/cache:      22392      40220
Swap:       262136          0     262136
xen1:/proc/xen# echo 50M > balloon
xen1:/proc/xen# cat balloon
Current allocation:    51200 kB
Requested target:      51200 kB
Low-mem balloon:       14336 kB
High-mem balloon:          0 kB
Xen hard limit:          ??? kB
xen1:/proc/xen# free
             total       used       free     shared    buffers     cached
Mem:         62612      42356      20256          0       1848       7908
-/+ buffers/cache:      32600      30012
Swap:       262136          0     262136

Shouldn't free get adjusted as well?

Thanks,
Paul Larson



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

^ permalink raw reply	[relevance 0%]

* Installing Fedora Core 2 inside an unprivileged domain
@ 2004-12-12  5:32  4% John L Griffin
  0 siblings, 0 replies; 200+ results
From: John L Griffin @ 2004-12-12  5:32 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 5739 bytes --]

I am attempting to install Red Hat Fedora Core 2, inside an
unprivileged Xen domain, using the FC2 distribution DVD.

Ian discusses some options for doing this in a message from 2004-11-07
[ http://sourceforge.net/mailarchive/message.php?msg_id=9983779 ].
I'm developing the "alternative approach" he discusses in the message.
I've made some progress:

  1. Create a sparse file (see section 5.2 of Xen user's manual):

       dd if=/dev/zero of=fc2-install.img bs=1k seek=8388607 count=1

  2. Acquire the DVD ISO image (FC2-i386-DVD.iso, in my case), and
     save it to a file locally.  Mount the image as a loopback device,
     copy the file "initrd.img" from the DVD image, unmount the image:

       mkdir /mnt/loop
       mount -oloop,ro FC2-i386-DVD.iso /mnt/loop
       cp /mnt/loop/isolinux/initrd.img .
       umount /mnt/loop

  3. Create a configuration file; the important fields to modify are
     "ramdisk" (should point to initrd.img from above), "disk", and
     "root".  Here are the entries I used:

       kernel  = "/boot/vmlinuz-2.6.9-xenU"
       ramdisk = "/fc2-install/initrd.img"
       memory  = 128
       name    = "fc2-install"
       disk    = [ 'file:/fc2-install/fc2-install.img,hda1,w',
                   'file:/fc2-install/FC2-i386-DVD.iso,hdb1,r' ]
       root    = "/dev/hdb1 ro ramdisk_size=8192 init=isolinux.bin"

  4. Start the unprivileged domain.

       xend start
       xm create fc2-install.xen -c

The unprivileged domain starts, Linux starts to boot correctly, and a
"Welcome to Fedora Core" message appears.  But, then a prompt asks "Do
you have a driver disk?".  When I say "no", it asks what type of media
contains the packages to be installed (Local CDROM, Hard drive, NFS
image, FTP, HTTP), but selecting any of them brings up a "No driver
found" prompt: "Unable to find any devices of the type needed for this
installation type.  Would you like to manually select your driver or
use a driver disk?"

And that's where I'm currently stuck.  None of the listed drivers for
either disk-based or network-based installs appear to work.  My theory
is that the initial boot is successful because Xen is loading the
ramdisk, but in the next stage the installer can't find drivers for
either the VBD or virtual network interface.  (See boot messages
below.)

But this inability to find the drivers seems odd, since I expect the
drivers for both to be compiled into the xenU kernel.  (Could the
installer somehow be switching over to the kernel image on the DVD?)

So, any ideas on what to try to overcome this?  Rebuild the initrd
image?  Create a driver disk?  Something much simpler?

------------------------------------------------------------------------

Following are the boot messages for the unprivileged domain:

Using config file "fc2-install.xen".--------------------+
Started domain fc2-install, console on port 9622
************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.6.9-xenU (root@flash.watson.ibm.com) (gcc version 3.3.3 
20040412 (Red Hat Linux 3.3.3-7)) #2 Sat Dec 11 15:47:54 EST 2004
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000008000000 (usable)
128MB LOWMEM available.en elements  | <Space> selects | <F12> next screen
DMI not present.
Built 1 zonelists
Kernel command line:  ip=:1.2.3.4::::eth0:dhcp root=/dev/sdb1 ro 
ramdisk_size=8192 init=isolinux.bin
Initializing CPU#0
PID hash table entries: 1024 (order: 10, 16384 bytes)
Xen reported: 3066.835 MHz processor.
Using tsc for high-res timesource
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 120216k/131072k available (1596k kernel code, 10792k reserved, 
446k data, 96k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... 
Ok.
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: Trace cache: 12K uops, L1 D cache: 8K
CPU: L2 cache: 512K
CPU: Intel(R) Xeon(TM) CPU 3.06GHz stepping 09
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... disabled
checking if image is initramfs...it isn't (ungzip failed); looks like an 
initrd
Freeing initrd memory: 7000k freed
NET: Registered protocol family 16
SCSI subsystem initialized
Initializing Cryptographic API
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
Xen virtual console successfully installed as tty
Event-channel device installed.
Starting Xen Balloon driver
xen_blk: Initialising virtual block device driver
Using anticipatory io scheduler
xen_net: Initialising virtual ethernet driver.
register_blkdev: cannot get major 8 for sd
NET: Registered protocol family 2
IP: routing cache hash table of 1024 buckets, 8Kbytes
TCP: Hash tables configured (established 8192 bind 16384)
NET: Registered protocol family 1
NET: Registered protocol family 17
IP-Config: Incomplete network configuration information.
RAMDISK: ext2 filesystem found at block 0
RAMDISK: Loading 7000KiB [1 disk] into ram disk... done.
VFS: Mounted root (ext2 filesystem).
[9;0][8]Greetings.
anaconda installer init version 10.0 starting
mounting /proc filesystem... done
mounting /dev/pts (unix98 pty) filesystem... done
mounting /sys filesystem... done
anaconda installer init version 10.0 using a serial console
remember, cereal is an important part of a nutritionally balanced 
breakfast.
 
trying to remount root filesystem read write... done
mounting /tmp as ramfs... done
running install...
running /sbin/loader

[then the "Do you have a driver disk?" screen.]

-- 
Dr. John Linwood Griffin
Research Staff Member, Secure Systems Department
IBM T.J. Watson Research Center, Hawthorne, New York, USA
JLG@us.ibm.com, http://www.research.ibm.com/people/j/jlg/

[-- Attachment #2: Type: text/html, Size: 11086 bytes --]

^ permalink raw reply	[relevance 4%]

* Oops on NULL pointer with three disks mapped in to dom1
@ 2004-12-17 22:49  4% Ryan Harper
  0 siblings, 0 replies; 200+ results
From: Ryan Harper @ 2004-12-17 22:49 UTC (permalink / raw)
  To: xen-devel

I've been trying to run the debian netboot iso inside an unpriviledged
domain.  In doing so, I mapped in a physical partition, the initrd, and
the iso with the following values:

disk = [ 'phy:/dev/hda7,hda1,w',
         'file:/tmp/initrd26,hdb1,r',
         'file:/tmp/sarge-i386-netinst.iso,hdc1,r' ]

When trying to boot this configuration, the kernel takes a dive when
initializing the virtual block device driver.  If I take out any one of the
three, the VBD initializes fine.  Anyone seen this?

Thanks,

Ryan Harper

Linux version 2.6.9-xenU (xenod@labyrinth.cl.cam.ac.uk) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 Wed Nov 17 22:29:37 GMT 2004
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000004000000 (usable)
64MB LOWMEM available.
DMI not present.
Built 1 zonelists
Kernel command line:  root=/dev/hdb1 ro vga=normal ramdisk_size=10240 devfs=mount,dall rw --
Initializing CPU#0
PID hash table entries: 512 (order: 9, 8192 bytes)
Xen reported: 448.066 MHz processor.
Using tsc for high-res timesource
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 52492k/65536k available (1596k kernel code, 13004k reserved, 466k data, 92k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: L2 cache: 512K
CPU: Intel Pentium II (Deschutes) stepping 02
Checking 'hlt' instruction... disabled
checking if image is initramfs...it isn't (ungzip failed); looks like an initrd
Freeing initrd memory: 9952k freed
NET: Registered protocol family 16
Initializing Cryptographic API
RAMDISK driver initialized: 16 RAM disks of 10240K size 1024 blocksize
Xen virtual console successfully installed as tty
Event-channel device installed.
Starting Xen Balloon driver
xen_blk: Initialising virtual block device driver
Using anticipatory io scheduler
Unable to handle kernel NULL pointer dereference at virtual address 00000008
 printing eip:
c0188672
*pde = ma 00000000 pa 55555000
 [<c0188761>] sysfs_create_dir+0x40/0x73

 [<c0188761>] sysfs_create_dir+0x40/0x73

 [<c0202e89>] create_dir+0x1f/0x4b

 [<c0203390>] kobject_add+0x93/0xdd

 [<c02033fd>] kobject_register+0x23/0x5b

 [<c0226d6a>] do_blkif_request+0x0/0xd4

 [<c021d179>] blk_register_queue+0x95/0xc0

 [<c0227ea2>] xlvbd_get_gendisk+0x19d/0x1bb

 [<c0227f34>] xlvbd_init_device+0x74/0x100

 [<c0228025>] xlvbd_init+0x65/0x98

 [<c02277cf>] blkif_connect+0xaf/0xc3

 [<c0226e3e>] blkif_int+0x0/0x19b

 [<c0227962>] blkif_ctrlif_rx+0x36/0x38

 [<c0108b96>] __ctrl_if_rxmsg_deferred+0x4a/0x59

 [<c012c801>] worker_thread+0x22b/0x32f

 [<c0108b4c>] __ctrl_if_rxmsg_deferred+0x0/0x59

 [<c011945e>] default_wake_function+0x0/0x12

 [<c011945e>] default_wake_function+0x0/0x12

 [<c012c5d6>] worker_thread+0x0/0x32f

 [<c0130925>] kthread+0xa5/0xab

 [<c0130880>] kthread+0x0/0xab

 [<c010f1c1>] kernel_thread_helper+0x5/0xb

Oops: 0000 [#1] 
PREEMPT
Modules linked in:
CPU:    0
EIP:    0061:[<c0188672>]    Not tainted VLI
EFLAGS: 00010296   (2.6.9-xenU)
EIP is at create_dir+0x17/0x9c
eax: c10ebe38   ebx: c3b46e3c   ecx: 00000000   edx: c3b46e40
esi: 00000000   edi: c10ebe38   ebp: c10dec00   esp: c10ebe0c
ds: 007b   es: 007b   ss: 0069
Process events/0 (pid: 3, threadinfo=c10ea000 task=c10d9020)
Stack: c10afe2c c02d28d0 c0188761 c3b46e3c c3b46e3c c10afe2c c0188761 c3b46e3c
       00000000 c3b46e40 c10ebe38 00000000 00000000 c0202e89 c3b46e3c c3b46e3c
       c3b46e3c c0203390 c3b46e3c fffffffd c3b46ce0 c3b46e3c c3b46e3c c02033fd
Call Trace:
 [<c0188761>] sysfs_create_dir+0x40/0x73

 [<c0188761>] sysfs_create_dir+0x40/0x73

 [<c0202e89>] create_dir+0x1f/0x4b

 [<c0203390>] kobject_add+0x93/0xdd

 [<c02033fd>] kobject_register+0x23/0x5b

 [<c0226d6a>] do_blkif_request+0x0/0xd4

 [<c021d179>] blk_register_queue+0x95/0xc0

 [<c0227ea2>] xlvbd_get_gendisk+0x19d/0x1bb

 [<c0227f34>] xlvbd_init_device+0x74/0x100

 [<c0228025>] xlvbd_init+0x65/0x98

 [<c02277cf>] blkif_connect+0xaf/0xc3

 [<c0226e3e>] blkif_int+0x0/0x19b

 [<c0227962>] blkif_ctrlif_rx+0x36/0x38

 [<c0108b96>] __ctrl_if_rxmsg_deferred+0x4a/0x59

 [<c012c801>] worker_thread+0x22b/0x32f

 [<c0108b4c>] __ctrl_if_rxmsg_deferred+0x0/0x59

 [<c011945e>] default_wake_function+0x0/0x12

 [<c011945e>] default_wake_function+0x0/0x12

 [<c012c5d6>] worker_thread+0x0/0x32f

 [<c0130925>] kthread+0xa5/0xab

 [<c0130880>] kthread+0x0/0xab

 [<c010f1c1>] kernel_thread_helper+0x5/0xb

Code: 9f 2c c0 c7 80 88 00 00 00 c0 9e 2c c0 83 40 24 01 31 c0 c3 83 ec 18 89 74 24 10 89 7c 24 14 89 5c 24 0c 8b 74 24 20 8b 7c 24 28 <8b> 46 08 8d 48 68 ff 48 68 0f 88 d9 03 00 00 8b 44 24 24 89 34
 <6>xen_net: Initialising virtual ethernet driver.
xen_net: Failed to connect all virtual interfaces: err=-100
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
NET: Registered protocol family 1
NET: Registered protocol family 17

<kernel stops here>


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

^ permalink raw reply	[relevance 4%]

* Re: Kernel panic - not syncing: Attempted to kill init!
  @ 2004-12-20 16:08  4% ` David F Barrera
  0 siblings, 0 replies; 200+ results
From: David F Barrera @ 2004-12-20 16:08 UTC (permalink / raw)
  To: xen-devel

Ian,

Thanks for the reply and the suggestions. Some details about my setup:
/dev/hdc3  is where xen0 is running
/dev/hdc1 --  another partition that actually has a copy of RHEL 4  Beta 
2 installed (working OS)
/etc/fstab:
# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/hdc3               /                       ext2    defaults        1 1
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
/dev/hdc2               swap                    swap    defaults        0 0
/dev/hda                /media/cdrom            auto    
pamconsole,ro,exec,noauto,managed 0 0
~

The config file that I am using:

# Kernel image file.
kernel = "/boot/vmlinuz-2.6.9-xenU"
# Optional ramdisk.
ramdisk = "/boot/initrd-2.6.9-xenU.img"
# The domain build function. Default is 'linux'.
builder='linux'
# Initial memory allocation (in megabytes) for the new domain.
memory = 64
# A name for your domain. All domains must have different names.
name = "test1"
# disk = [ 'phy:hda1,hda1,r' ]
disk = [ 'phy:hdc1,hdc1,w' ]
# Set if you want dhcp to allocate the IP address.
dhcp="dhcp"
# Set root device.
root = "/dev/hdc1 ro/"
# Sets runlevel 4.
extra = "4"
#============================================================================
~


Ian Pratt wrote:

>>Derrick,
>>
>>I rebuilt the xenU kernel, with the devfs support disabled, and it makes 
>>no difference. It behaves in the same manner as the pre-built kernel 
>>that's included with the binary pack.  I am at a loss. I've been able to 
>>boot a kernel under xen on a SuSE Linux 9.0 machine, so I've had a 
>>little experience with this:-) 
>>    
>>
>
>David, earlier in the boot messages do you see the hdc1 partition
>being found when the partition check happens?
>  
>
This is the entire log:

Linux version 2.6.9-xenU (root@dyn95394184.austin.ibm.com) (gcc version 
3.4.2 20041017 (Red Hat 3.4.2-6.fc3)) #1 Fri Dec 17 15:50:10 CST 2004
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000004000000 (usable)
64MB LOWMEM available.
DMI not present.
Built 1 zonelists
Kernel command line:  ip=:1.2.3.4::::eth0:dhcp root=/dev/hdc1 ro/ 4
Initializing CPU#0
PID hash table entries: 512 (order: 9, 8192 bytes)
Xen reported: 866.697 MHz processor.
Using tsc for high-res timesource
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 61900k/65536k available (1569k kernel code, 3596k reserved, 429k 
data, 92k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: L2 cache: 256K
CPU: Intel Pentium III (Coppermine) stepping 06
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... disabled
checking if image is initramfs... it is
Freeing initrd memory: 600k freed
NET: Registered protocol family 16
Initializing Cryptographic API
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Xen virtual console successfully installed as tty
Event-channel device installed.
Starting Xen Balloon driver
xen_blk: Initialising virtual block device driver
Using anticipatory io scheduler
xen_net: Initialising virtual ethernet driver.
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
NET: Registered protocol family 1
NET: Registered protocol family 17
IP-Config: Incomplete network configuration information.
Freeing unused kernel memory: 92k freed
Red Hat nash version 4.1.18 starting
Mounted /proc filesystem
Mounting sysfs
Creating /dev
Starting udev
Creating root device
Mounting root filesystem
mount: error 6 mounting ext2
mount: error 2 mounting none
Switching to new root
switchroot: mount failed: 22
umount /initrd/dev failed: 2
Kernel panic - not syncing: Attempted to kill init!
 <0>Rebooting in 1 seconds..


>You'll need to export the partition 'rw' eventually, but that's
>not your current problem.
>  
>
Right. Already tried it.

>You might like to try exporting it as 'sda1' or something to see
>if that helps. Not sure why it would, but I've heard folklore
>along these lines. 
>  
>
I had tried that (and hda1) before, but sda1 I get an error, too:
[root@dyn95394184 xen]# xm create -c test1 vmid=1
Using config file "test1".
Error: Error creating domain: vbd: Device not found: sda1

>Adding some more debugging to the linuxrc nash script might shed
>some light on the problem. 
>  
>
I need to find out how to do this first...

>Also, what happens if you skip the initrd and try booting
>directly off the disk. I doubt there's anything in the initrd you
>need.
>  
>
I had tried it, also.  I get a VFS error if I don't use an initrd

VFS: Cannot open root device "hdc1" or unknown-block(2,0)
Please append a correct "root=" boot option
Kernel panic - not syncing: VFS: Unable to mount root fs on 
unknown-block(2,0)
 <0>Rebooting in 1 seconds..


>Ian
>
> 
>  
>
>>Freeing unused kernel memory: 92k freed
>>Red Hat nash version 4.1.18 starting
>>Mounted /proc filesystem
>>Mounting sysfs
>>Creating /dev
>>Starting udev
>>Creating root device
>>Mounting root filesystem
>>mount: error 6 mounting ext3
>>mount: error 2 mounting none
>>Switching to new root
>>switchroot: mount failed: 22
>>umount /initrd/dev failed: 2
>>Kernel panic - not syncing: Attempted to kill init!
>> <0>Rebooting in 1 seconds..
>>
>>
>>David Barrera
>>
>>
>>Derrik Pates wrote:
>>
>>    
>>
>>>David F Barrera wrote:
>>>
>>>      
>>>
>>>>The distro I am using is  RHEL 4 Beta 2 (Red Hat Enterprise Linux 
>>>>Desktop release 3.90 (Nahant)
>>>>        
>>>>
>>>      
>>>
>>>>/dev/hdc1               /                       ext2    
>>>>defaults        1 1
>>>>        
>>>>
>>>      
>>>
>>>>LABEL=SWAP-hdc2         swap                    swap    
>>>>defaults        0 0
>>>>/dev/hda                /media/cdrom            auto    
>>>>pamconsole,fscontext=system_u:object_r:removable_t,ro,exec,noauto,managed 
>>>>0 0
>>>>        
>>>>
>>>      
>>>
>>>># disk = [ 'phy:hda1,hda1,r' ]
>>>>disk = [ 'phy:hdc1,hdc1,r' ]
>>>>        
>>>>
>>>Well, the configuration of the virtual disk looks correct; the swap 
>>>might disagree with it, but that shouldn't appear until later in the 
>>>boot process. Perhaps it's an interaction with devfs? Do you have 
>>>devfs enabled in your xenU (unprivileged domain) kernel? This gave me 
>>>fits when I first began using Xen, mostly because it seems that the 
>>>xenU prebuilt kernel that's included with the binary pack has devfs 
>>>support enabled, and this breaks things. The only other possibility I 
>>>can think of is that you need to change the block-device import to 
>>>read-write.
>>>
>>>      
>>>
>>-------------------------------------------------------
>>SF email is sponsored by - The IT Product Guide
>>Read honest & candid reviews on hundreds of IT Products from real users.
>>Discover which products truly live up to the hype. Start reading now. 
>>http://productguide.itmanagersjournal.com/
>>_______________________________________________
>>Xen-devel mailing list
>>Xen-devel@lists.sourceforge.net
>>https://lists.sourceforge.net/lists/listinfo/xen-devel
>>    
>>
>
>
>
>-------------------------------------------------------
>SF email is sponsored by - The IT Product Guide
>Read honest & candid reviews on hundreds of IT Products from real users.
>Discover which products truly live up to the hype. Start reading now. 
>http://productguide.itmanagersjournal.com/
>_______________________________________________
>Xen-devel mailing list
>Xen-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/xen-devel
>
>  
>


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

^ permalink raw reply	[relevance 4%]

* Re: xen 2.0 testing idle_loop -and -03
  @ 2004-12-22 17:42  5% ` Keir Fraser
  2004-12-22 18:25  0%   ` Adam Sulmicki
  0 siblings, 1 reply; 200+ results
From: Keir Fraser @ 2004-12-22 17:42 UTC (permalink / raw)
  To: Adam Sulmicki; +Cc: Keir Fraser, xen dev

> >> 1) extreme slowness
> >
> > Is this in DOM0 or some other domain? If it looks like I/O slowness,
> > have any network or disc microbenchmarks (e.g., net/disc bandwidth or
> > latency) got much worse?
> 
> dom0, i tried to compile kernel and it was like 10-100 times slower... but 
> I got impression that it was because the disk was heavily trashing.. it 
> seemed like the 45 out of the 65mb disappeared somewhere, and the 
> remainining 15 was just not enough to compile kernel (in fact oom-killer 
> killed my sshd twice).

'cat /proc/xen/balloon' will tell you how much memory your domain has.
You'll see the current allocation is somewhat less than the 'requested
target'. This is because the backend I/O drivers steal some kernel
address space and the RAM that was mapped in that space is freed back
to Xen. I wouldn't expect the current allocation to be more than maybe
6MB lower than the 64MB target though.

Also, what does 'cat /proc/meminfo' look like?

> >> 2) won't boot on p3 with compiled for for cyrix
> >
> > Has that ever worked? I did recently fix a problem with
> > CONFIG_X86_USE_3DNOW, so were you testing a very up to date version of
> > the repository? If you are totally stuck send me your .config and I
> > can build and test.
> 
> yeah, it worked just fine on xen 2.0 release. I could compile kernel with 
> CONFIG_MCYRIXIII and then run the same kernel on both P3 and via (with 
> some special patches). This time the kernel bombed on P3 (have not tried 
> it on via).
> 
> the repository was as of yesterday.

I'll try building with CYRIXIII selected. If that works for me then I
guess it must be something else in your config.

 -- Keir


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

^ permalink raw reply	[relevance 5%]

* Re: xen 2.0 testing idle_loop -and -03
  2004-12-22 17:42  5% ` Keir Fraser
@ 2004-12-22 18:25  0%   ` Adam Sulmicki
  0 siblings, 0 replies; 200+ results
From: Adam Sulmicki @ 2004-12-22 18:25 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen dev

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1540 bytes --]


>>>> 1) extreme slowness

> 'cat /proc/xen/balloon' will tell you how much memory your domain has.
> You'll see the current allocation is somewhat less than the 'requested
> target'. This is because the backend I/O drivers steal some kernel
> address space and the RAM that was mapped in that space is freed back
> to Xen. I wouldn't expect the current allocation to be more than maybe
> 6MB lower than the 64MB target though.
>
> Also, what does 'cat /proc/meminfo' look like?

attached meminfo, balloon and output of both, all of them right after 
starting dom0

also attached outout of dmesg which shows oom-killer in action (already!) 
as well as output of "echo m > /proc/sysrq-trigger"

>>>> 2) won't boot on p3 with compiled for for cyrix
>>>
>>> Has that ever worked? I did recently fix a problem with
>>> CONFIG_X86_USE_3DNOW, so were you testing a very up to date version of
>>> the repository? If you are totally stuck send me your .config and I
>>> can build and test.
>>
>> yeah, it worked just fine on xen 2.0 release. I could compile kernel with
>> CONFIG_MCYRIXIII and then run the same kernel on both P3 and via (with
>> some special patches). This time the kernel bombed on P3 (have not tried
>> it on via).
>>
>> the repository was as of yesterday.
>
> I'll try building with CYRIXIII selected. If that works for me then I
> guess it must be something else in your config.

FWIW, I just d/l pristine tree and used almost default config (except the 
cyrix setting) just especially to see if it is somethin with my config.

[-- Attachment #2: Type: TEXT/PLAIN, Size: 165 bytes --]

Current allocation:    60416 kB
Requested target:      65536 kB
Low-mem balloon:           0 kB
High-mem balloon:          0 kB
Xen hard limit:          ??? kB

[-- Attachment #3: Type: TEXT/PLAIN, Size: 594 bytes --]

MemTotal:        60992 kB
MemFree:         10000 kB
Buffers:          1208 kB
Cached:           8020 kB
SwapCached:       1468 kB
Active:           7416 kB
Inactive:         5048 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:        60992 kB
LowFree:         10000 kB
SwapTotal:      257032 kB
SwapFree:       254328 kB
Dirty:               4 kB
Writeback:           0 kB
Mapped:           4912 kB
Slab:            32912 kB
Committed_AS:    11344 kB
PageTables:        328 kB
VmallocTotal:   908256 kB
VmallocUsed:       216 kB
VmallocChunk:   908036 kB

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: Type: TEXT/PLAIN; charset=X-UNKNOWN; name=t1, Size: 4598 bytes --]

^[[H^[[2J^[[?7l^[[m\x0ftop - 04:45:12 up 3 min,  1 user,  load average: 3.29, 3.03, 1.27^[[m\x0f^[[39;49m^[[K
Tasks:^[[m\x0f^[[39;49m^[[1m  34 ^[[m\x0f^[[39;49mtotal,^[[m\x0f^[[39;49m^[[1m   1 ^[[m\x0f^[[39;49mrunning,^[[m\x0f^[[39;49m^[[1m  33 ^[[m\x0f^[[39;49msleeping,^[[m\x0f^[[39;49m^[[1m   0 ^[[m\x0f^[[39;49mstopped,^[[m\x0f^[[39;49m^[[1m   0 ^[[m\x0f^[[39;49mzombie^[[m\x0f^[[39;49m^[[K
Cpu(s):^[[m\x0f^[[39;49m^[[1m  5.5% ^[[m\x0f^[[39;49mus,^[[m\x0f^[[39;49m^[[1m 12.9% ^[[m\x0f^[[39;49msy,^[[m\x0f^[[39;49m^[[1m  0.0% ^[[m\x0f^[[39;49mni,^[[m\x0f^[[39;49m^[[1m 59.7% ^[[m\x0f^[[39;49mid,^[[m\x0f^[[39;49m^[[1m 21.6% ^[[m\x0f^[[39;49mwa,^[[m\x0f^[[39;49m^[[1m  0.0% ^[[m\x0f^[[39;49mhi,^[[m\x0f^[[39;49m^[[1m  0.4% ^[[m\x0f^[[39;49msi^[[m\x0f^[[39;49m^[[K
Mem: ^[[m\x0f^[[39;49m^[[1m    60992k ^[[m\x0f^[[39;49mtotal,^[[m\x0f^[[39;49m^[[1m    51888k ^[[m\x0f^[[39;49mused,^[[m\x0f^[[39;49m^[[1m     9104k ^[[m\x0f^[[39;49mfree,^[[m\x0f^[[39;49m^[[1m     1304k ^[[m\x0f^[[39;49mbuffers^[[m\x0f^[[39;49m^[[K
Swap:^[[m\x0f^[[39;49m^[[1m   257032k ^[[m\x0f^[[39;49mtotal,^[[m\x0f^[[39;49m^[[1m     2700k ^[[m\x0f^[[39;49mused,^[[m\x0f^[[39;49m^[[1m   254332k ^[[m\x0f^[[39;49mfree,^[[m\x0f^[[39;49m^[[1m     8312k ^[[m\x0f^[[39;49mcached^[[m\x0f^[[39;49m^[[K
^[[6;1H
^[[7m  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            ^[[m\x0f^[[39;49m^[[K
^[[m\x0f    1 root      16   0   588   68  444 S  0.0  0.1   0:02.12 init               ^[[m\x0f^[[39;49m^[[K
^[[m\x0f    2 root      34  19     0    0    0 S  0.0  0.0   0:00.39 ksoftirqd/0        ^[[m\x0f^[[39;49m^[[K
^[[m\x0f    3 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 events/0           ^[[m\x0f^[[39;49m^[[K
^[[m\x0f    4 root       5 -10     0    0    0 S  0.0  0.0   0:00.06 khelper            ^[[m\x0f^[[39;49m^[[K
^[[m\x0f    5 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 kblockd/0          ^[[m\x0f^[[39;49m^[[K
^[[m\x0f   35 root      15   0     0    0    0 S  0.0  0.0   0:00.01 pdflush            ^[[m\x0f^[[39;49m^[[K
^[[m\x0f   37 root       7 -10     0    0    0 S  0.0  0.0   0:00.00 aio/0              ^[[m\x0f^[[39;49m^[[K
^[[m\x0f   36 root      15   0     0    0    0 S  0.0  0.0   0:01.14 kswapd0            ^[[m\x0f^[[39;49m^[[K
^[[m\x0f  619 root      21   0     0    0    0 S  0.0  0.0   0:00.00 kseriod            ^[[m\x0f^[[39;49m^[[K
^[[m\x0f  651 root      20   0     0    0    0 S  0.0  0.0   0:00.00 xenblkd            ^[[m\x0f^[[39;49m^[[K
^[[m\x0f  658 root       6 -10     0    0    0 S  0.0  0.0   0:00.00 ata/0              ^[[m\x0f^[[39;49m^[[K
^[[m\x0f  665 root       6 -10     0    0    0 S  0.0  0.0   0:00.00 kmirrord/0         ^[[m\x0f^[[39;49m^[[K
^[[m\x0f  667 root      15   0     0    0    0 S  0.0  0.0   0:00.14 kjournald          ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2039 root      16   0  1392    0 1192 S  0.0  0.0   0:00.00 hwscand            ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2312 root      16   0  1420  180 1252 S  0.0  0.3   0:02.59 syslogd            ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2319 root      16   0  2256  288 1356 S  0.0  0.5   0:00.13 klogd              ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2378 root      18   0  1384    0 1228 S  0.0  0.0   0:00.00 resmgrd            ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2438 root      16   0  4624  536 4252 S  0.0  0.9   0:00.26 sshd               ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2467 root      18   0  1572    0 1384 S  0.0  0.0   0:00.00 rpc.mountd         ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2484 root      16   0  1568  172 1392 S  0.0  0.3   0:00.00 cron               ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2494 root      18   0  1552    0 1380 S  0.0  0.0   0:00.00 mingetty           ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2495 root      18   0  1552    0 1380 S  0.0  0.0   0:00.00 mingetty           ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2496 root      18   0  1552    0 1380 S  0.0  0.0   0:00.07 mingetty           ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2497 root      18   0  1552    0 1380 S  0.0  0.0   0:00.07 mingetty           ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2498 root      18   0  1552    0 1380 S  0.0  0.0   0:00.07 mingetty           ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2499 root      18   0  1552    0 1380 S  0.0  0.0   0:00.04 mingetty           ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2500 root      17   0  1356    0 1196 S  0.0  0.0   0:00.05 agetty             ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 2927 root      15   0     0    0    0 S  0.0  0.0   0:00.00 pdflush            ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 3050 root      16   0  7632 1808 4460 S  0.0  3.0   0:00.02 sshd               ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 3052 sulmicki  16   0  7780 1932 4460 S  0.0  3.2   0:00.02 sshd               ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 3057 sulmicki  16   0  4260 1844 3412 S  0.0  3.0   0:00.05 bash               ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 3077 root      17   0  3464 1236 2848 S  0.0  2.0   0:00.01 su                 ^[[m\x0f^[[39;49m^[[K
^[[m\x0f 3082 root      16   0  3892 1852 3412 S  0.0  3.0   0:00.12 bash               ^[[m\x0f^[[39;49m^[[K
^[[m\x0f^[[1m 3121 root      15   0  1928  928 1712 R  0.0  1.5   0:00.01 top                ^[[m\x0f^[[39;49m^[[K
^[[J^[[6;1H^[[K^[[70;1H^[[?12l^[[?25h^[[?7h

[-- Attachment #5: Type: TEXT/PLAIN, Size: 8800 bytes --]

Linux version 2.6.9-xen0 (root@redbull) (gcc version 3.3.3 (SuSE Linux)) #4 Tue Dec 21 15:18:49 MST 2004
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000004000000 (usable)
64MB LOWMEM available.
On node 0 totalpages: 16384
  DMA zone: 16384 pages, LIFO batch:4
  Normal zone: 0 pages, LIFO batch:1
  HighMem zone: 0 pages, LIFO batch:1
DMI not present.
Built 1 zonelists
Kernel command line: root=/dev/hda1 console=tty0 console=ttyS0 debug
Initializing CPU#0
PID hash table entries: 512 (order: 9, 8192 bytes)
Xen reported: 865.949 MHz processor.
Using tsc for high-res timesource
Console: colour VGA+ 80x25
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 60496k/65536k available (2702k kernel code, 4944k reserved, 832k data, 400k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Calibrating delay loop... 1730.15 BogoMIPS (lpj=8650752)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: After generic identify, caps: 0383fbff 00000000 00000000 00000000
CPU: After vendor identify, caps:  0383fbff 00000000 00000000 00000000
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: L2 cache: 512K
CPU: After all inits, caps:        0383dbf1 00000000 00000000 00000040
CPU: Intel(R) Pentium(R) III Mobile CPU       866MHz stepping 01
Enabling fast FPU save and restore... done.
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... disabled
NET: Registered protocol family 16
PCI: Using configuration type Xen
xen_mem: Initialising balloon driver.
SCSI subsystem initialized
PCI: Probing PCI hardware
PCI: Probing PCI hardware (bus 00)
PCI: Probing PCI hardware (bus 01)
PCI: Probing PCI hardware (bus 02)
PCI: Probing PCI hardware
Initializing Cryptographic API
serio: i8042 AUX port at 0x60,0x64 irq 12
serio: i8042 KBD port at 0x60,0x64 irq 1
Using anticipatory io scheduler
Floppy drive(s): fd0 is 1.44M
floppy0: no floppy controllers found
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
HP CISS Driver (v 2.6.2)
Intel(R) PRO/1000 Network Driver - version 5.3.19-k2
Copyright (c) 1999-2004 Intel Corporation.
pcnet32.c:v1.30i 06.28.2004 tsbogend@alpha.franken.de
e100: Intel(R) PRO/100 Network Driver, 3.0.27-k2-NAPI
e100: Copyright(c) 1999-2004 Intel Corporation
PCI: Obtained IRQ 10 for device 0000:02:08.0
e100: eth0: e100_probe: addr 0xc0200000, irq 10, MAC addr 00:D0:59:33:6E:E0
Xen virtual console successfully installed as ttyS
Event-channel device installed.
Initialising Xen netif backend
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
ICH3M: IDE controller at PCI slot 0000:00:1f.1
PCI: Enabling device 0000:00:1f.1 (0005 -> 0007)
PCI: Obtained IRQ 11 for device 0000:00:1f.1
ICH3M: chipset revision 1
ICH3M: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0x1860-0x1867, BIOS settings: hda:DMA, hdb:pio
    ide1: BM-DMA at 0x1868-0x186f, BIOS settings: hdc:DMA, hdd:pio
Probing IDE interface ide0...
hda: IC25N020ATCX04-0, ATA DISK drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
Probing IDE interface ide1...
hdc: LG CD-ROM CRN-8245B, ATAPI CD/DVD-ROM drive
ide1 at 0x170-0x177,0x376 on irq 15
Probing IDE interface ide2...
ide2: Wait for ready failed before probe !
Probing IDE interface ide3...
ide3: Wait for ready failed before probe !
Probing IDE interface ide4...
ide4: Wait for ready failed before probe !
Probing IDE interface ide5...
ide5: Wait for ready failed before probe !
hda: max request size: 128KiB
hda: 39070080 sectors (20003 MB) w/1768KiB Cache, CHS=38760/16/63, UDMA(100)
hda: cache flushes not supported
 hda: hda1 hda2
hdc: ATAPI 24X CD-ROM drive, 128kB Cache, UDMA(33)
Uniform CD-ROM driver Revision: 3.20
Red Hat/Adaptec aacraid driver (1.1.2-lk2 Dec 21 2004)
3ware Storage Controller device driver for Linux v1.26.00.039.
3w-xxxx: No cards found.
libata version 1.02 loaded.
mice: PS/2 mouse device common for all mice
input: AT Translated Set 2 keyboard on isa0060/serio0
input: PS/2 Generic Mouse on isa0060/serio1
md: raid0 personality registered as nr 2
md: raid1 personality registered as nr 3
md: raid5 personality registered as nr 4
raid5: automatically using best checksumming function: pIII_sse
   pIII_sse  :  1254.400 MB/sec
raid5: using function: pIII_sse (1254.400 MB/sec)
md: md driver 0.90.0 MAX_MD_DEVS=256, MD_SB_DISKS=27
device-mapper: 4.1.0-ioctl (2003-12-10) initialised: dm@uk.sistina.com
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
NET: Registered protocol family 1
NET: Registered protocol family 17
Bridge firewalling registered
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
kjournald starting.  Commit interval 5 seconds
EXT3 FS on hda1, internal journal
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem).
Freeing unused kernel memory: 400k freed
EXT3 (no)acl options not supported
EXT3 (no)acl options not supported
EXT3 FS on hda1, internal journal
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
Adding 257032k swap on /dev/hda2.  Priority:42 extents:1
pcmcia_core: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
pcmcia_core: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
yenta_socket: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
pcmcia_core: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
ds: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
e100: eth0: e100_watchdog: link up, 100Mbps, full-duplex
pcmcia_core: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
yenta_socket: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
pcmcia_core: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
yenta_socket: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
exportfs: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
nfsd: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
exportfs: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
nfsd: version magic '2.6.9-xen0 preempt CYRIXIII gcc-3.3' should be '2.6.9-xen0 preempt PENTIUM4 gcc-3.3'
oom-killer: gfp_mask=0x1d2
DMA per-cpu:
cpu 0 hot: low 8, high 24, batch 4
cpu 0 cold: low 0, high 8, batch 4
Normal per-cpu: empty
HighMem per-cpu: empty

Free pages:        2016kB (0kB HighMem)
Active:3 inactive:2495 dirty:2 writeback:2179 unstable:0 free:504 slab:10589 mapped:317 pagetables:611
DMA free:2016kB min:256kB low:512kB high:768kB active:12kB inactive:9980kB present:65536kB
protections[]: 0 0 0
Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB
protections[]: 0 0 0
HighMem free:0kB min:128kB low:256kB high:384kB active:0kB inactive:0kB present:0kB
protections[]: 0 0 0
DMA: 298*4kB 69*8kB 5*16kB 0*32kB 1*64kB 1*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 2016kB
Normal: empty
HighMem: empty
Swap cache: add 5097, delete 2902, find 1213/1298, race 0+0
Out of Memory: Killed process 2377 (portmap).
SysRq : Show Memory
Mem-info:
DMA per-cpu:
cpu 0 hot: low 8, high 24, batch 4
cpu 0 cold: low 0, high 8, batch 4
Normal per-cpu: empty
HighMem per-cpu: empty

Free pages:        5272kB (0kB HighMem)
Active:2420 inactive:1473 dirty:1 writeback:0 unstable:0 free:1318 slab:8621 mapped:1220 pagetables:79
DMA free:5272kB min:256kB low:512kB high:768kB active:9680kB inactive:5892kB present:65536kB
protections[]: 0 0 0
Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB
protections[]: 0 0 0
HighMem free:0kB min:128kB low:256kB high:384kB active:0kB inactive:0kB present:0kB
protections[]: 0 0 0
DMA: 48*4kB 37*8kB 245*16kB 21*32kB 1*64kB 1*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 5272kB
Normal: empty
HighMem: empty
Swap cache: add 11470, delete 11088, find 4705/6038, race 1+1
Free swap:       254332kB
16384 pages of RAM
0 pages of HIGHMEM
1136 reserved pages
2318 pages shared
382 pages swap cached

^ permalink raw reply	[relevance 0%]

* can't start domU via NFS
@ 2004-12-30 15:35  5% Anatoly Asviyan
  0 siblings, 0 replies; 200+ results
From: Anatoly Asviyan @ 2004-12-30 15:35 UTC (permalink / raw)
  To: xen-devel

	hi all
I have Xen-2.0 setup with dom0 starting from local disk.
I need to start domU from NFS
The NFS server works - both local and remote clients can use it.
But not domU :-(

Here is my config
======= /etc/xen/ttylinux-1 =========
kernel = "/boot/vmlinuz-2.6.9-xenU"
memory = 64
name = "ttylinux-1"
nics=1
ip = "192.168.1.1"
netmask="255.255.0.0"
gateway="192.168.1.123"
root = "/dev/nfs"
nfs_server = "192.168.1.123"
nfs_root   = '/tmp/nfsexport/ttylinux-1'
extra = "4"
======================================

domU starts booting and hangs at mounting its root via NFS


========= boot log ==============
Using config file "ttylinux-1".
Started domain ttylinux-1, console on port 9611
************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.6.9-xenU (xenod@labyrinth.cl.cam.ac.uk) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 Wed Nov 17 22:29:37 GMT 2004
BIOS-provided physical RAM map:                             
 Xen: 0000000000000000 - 0000000004000000 (usable)
64MB LOWMEM available.                            
DMI not present.      
Built 1 zonelists
Kernel command line:  ip=192.168.1.1:192.168.1.123:192.168.1.123:255.255.0.0::eth0:off root=/dev/nfs 
nfsroot=192.168.1.123:/tmp/nfsexport/ttylinux-1 4
Initializing CPU#0                                                    
PID hash table entries: 512 (order: 9, 8192 bytes)
Xen reported: 2791.178 MHz processor.             
Using tsc for high-res timesource    
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)  
Memory: 62436k/65536k available (1596k kernel code, 3060k reserved, 466k data, 92k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)                  
CPU: Trace cache: 12K uops, L1 D cache: 8K                
CPU: L2 cache: 512K                       
CPU: Intel(R) Xeon(TM) CPU 2.80GHz stepping 09
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... disabled               
NET: Registered protocol family 16    
Initializing Cryptographic API    
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Xen virtual console successfully installed as tty                    
Event-channel device installed.                  
Starting Xen Balloon driver    
xen_blk: Initialising virtual block device driver
xen_blk: Timeout connecting to device!           
xen_net: Initialising virtual ethernet driver.
NET: Registered protocol family 2             
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 8192)
NET: Registered protocol family 1                       
NET: Registered protocol family 17
IP-Config: Complete:              
      device=eth0, addr=192.168.1.1, mask=255.255.0.0, gw=192.168.1.123,
     host=192.168.1.1, domain=, nis-domain=(none),                      
     bootserver=192.168.1.123, rootserver=192.168.1.123, rootpath=
Looking up port of RPC 100003/2 on 192.168.1.123                  
portmap: server 192.168.1.123 not responding, timed out
Root-NFS: Unable to get nfsd port number from server, using default
Looking up port of RPC 100005/1 on 192.168.1.123                   
portmap: server 192.168.1.123 not responding, timed out
Root-NFS: Unable to get mountd port number from server, using default
mount: server 192.168.1.123 not responding, timed out                
Root-NFS: Server returned error -5 while mounting /tmp/nfsexport/ttylinux-1
VFS: Unable to mount root fs via NFS, trying floppy.                       
VFS: Cannot open root device "nfs" or unknown-block(2,0)
Please append a correct "root=" boot option             
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
 <0>Rebooting in 1 seconds..

-- 
Regards, Anatoly


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt

^ permalink raw reply	[relevance 5%]

* [PATCH] arch/xen pudding
@ 2005-01-07  5:02  7% Rik van Riel
  0 siblings, 0 replies; 200+ results
From: Rik van Riel @ 2005-01-07  5:02 UTC (permalink / raw)
  To: xen-devel

This patch adds the 'pud' level to Xen page table handling, making
it compile with the 4 level page table code that's in the latest 
2.6 kernel tree.  This will be needed once Xen moves to 2.6.11.

The only uglies are overriding pmd_val and __pmd, but the code is
now using the asm-generic headers.

This corresponds to the upstream changesets:
 	nickpiggin@yahoo.com.au[torvalds]|ChangeSet|20050101220015|18900
 	ak@suse.de[torvalds]|ChangeSet|20050101220139|54188

Signed-off-by: Rik van Riel <riel@redhat.com>

--- linux-2.6.10/arch/xen/i386/kernel/pci-dma.c.pudding	2005-01-06 17:29:29.000000000 -0500
+++ linux-2.6.10/arch/xen/i386/kernel/pci-dma.c	2005-01-06 17:30:26.000000000 -0500
@@ -36,6 +36,7 @@
  	 * hypercalls reduced.
  	 */
  	pgd_t         *pgd; 
+	pud_t         *pud;
  	pmd_t         *pmd;
  	pte_t         *pte;
  	unsigned long  pfn, i, flags;
@@ -47,7 +48,8 @@
  	/* 1. Zap current PTEs, giving away the underlying pages. */
  	for (i = 0; i < (1<<order); i++) {
  		pgd = pgd_offset_k(   (vstart + (i*PAGE_SIZE)));
-		pmd = pmd_offset(pgd, (vstart + (i*PAGE_SIZE)));
+		pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
+		pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
  		pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE)));
  		pfn = pte->pte_low >> PAGE_SHIFT;
  		queue_l1_entry_update(pte, 0);
@@ -63,7 +65,8 @@
  	/* 3. Map the new extent in place of old pages. */
  	for (i = 0; i < (1<<order); i++) {
  		pgd = pgd_offset_k(   (vstart + (i*PAGE_SIZE)));
-		pmd = pmd_offset(pgd, (vstart + (i*PAGE_SIZE)));
+		pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
+		pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
  		pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE)));
  		queue_l1_entry_update(
  			pte, ((pfn+i)<<PAGE_SHIFT)|__PAGE_KERNEL);
--- linux-2.6.10/arch/xen/i386/mm/fault.c.pudding	2005-01-06 13:30:00.000000000 -0500
+++ linux-2.6.10/arch/xen/i386/mm/fault.c	2005-01-06 13:33:03.000000000 -0500
@@ -527,6 +527,7 @@
  		 */
  		int index = pgd_index(address);
  		pgd_t *pgd, *pgd_k;
+		pud_t *pud, *pud_k;
  		pmd_t *pmd, *pmd_k;
  		pte_t *pte_k;

@@ -538,11 +539,17 @@

  		/*
  		 * set_pgd(pgd, *pgd_k); here would be useless on PAE
-		 * and redundant with the set_pmd() on non-PAE.
+		 * and redundant with the set_pmd() on non-PAE. As would
+		 * set_pud.
  		 */

-		pmd = pmd_offset(pgd, address);
-		pmd_k = pmd_offset(pgd_k, address);
+		pud = pud_offset(pgd, address);
+		pud_k = pud_offset(pgd_k, address);
+		if (!pud_present(*pud_k))
+			goto no_context;
+
+		pmd = pmd_offset(pud, address);
+		pmd_k = pmd_offset(pud_k, address);
  		if (!pmd_present(*pmd_k))
  			goto no_context;
  		set_pmd(pmd, *pmd_k);
--- linux-2.6.10/arch/xen/i386/mm/init.c.pudding	2005-01-06 13:33:17.000000000 -0500
+++ linux-2.6.10/arch/xen/i386/mm/init.c	2005-01-06 13:39:13.000000000 -0500
@@ -55,15 +55,18 @@
   */
  static pmd_t * __init one_md_table_init(pgd_t *pgd)
  {
+	pud_t *pud;
  	pmd_t *pmd_table;

  #ifdef CONFIG_X86_PAE
  	pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
  	set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
-	if (pmd_table != pmd_offset(pgd, 0)) 
+	pud = pud_offset(pgd, 0);
+	if (pmd_table != pud_offset(pud, 0))
  		BUG();
  #else
-	pmd_table = pmd_offset(pgd, 0);
+	pud = pud_offset(pgd, 0);
+	pmd_table = pmd_offset(pud, 0);
  #endif

  	return pmd_table;
@@ -102,6 +105,7 @@
  static void __init page_table_range_init (unsigned long start, unsigned long end, pgd_t *pgd_base)
  {
  	pgd_t *pgd;
+	pud_t *pud;
  	pmd_t *pmd;
  	int pgd_idx, pmd_idx;
  	unsigned long vaddr;
@@ -114,8 +118,8 @@
  	for ( ; (pgd_idx < PTRS_PER_PGD_NO_HV) && (vaddr != end); pgd++, pgd_idx++) {
  		if (pgd_none(*pgd))
  			one_md_table_init(pgd);
-
-		pmd = pmd_offset(pgd, vaddr);
+		pud = pud_offset(pgd, vaddr);
+		pmd = pmd_offset(pud, vaddr);
  		for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end); pmd++, pmd_idx++) {
  			if (pmd_none(*pmd))
  				one_page_table_init(pmd);
@@ -249,7 +253,7 @@
  EXPORT_SYMBOL(kmap_pte);

  #define kmap_get_fixmap_pte(vaddr)					\
-	pte_offset_kernel(pmd_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr))
+	pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)), (vaddr))

  void __init kmap_init(void)
  {
@@ -265,6 +269,7 @@
  void __init permanent_kmaps_init(pgd_t *pgd_base)
  {
  	pgd_t *pgd;
+	pud_t *pud;
  	pmd_t *pmd;
  	pte_t *pte;
  	unsigned long vaddr;
@@ -273,7 +278,8 @@
  	page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);

  	pgd = swapper_pg_dir + pgd_index(vaddr);
-	pmd = pmd_offset(pgd, vaddr);
+	pud = pud_offset(pgd, vaddr);
+	pmd = pmd_offset(pud, vaddr);
  	pte = pte_offset_kernel(pmd, vaddr);
  	pkmap_page_table = pte;
  }
--- linux-2.6.10/arch/xen/i386/mm/ioremap.c.pudding	2005-01-06 13:39:18.000000000 -0500
+++ linux-2.6.10/arch/xen/i386/mm/ioremap.c	2005-01-06 13:43:13.000000000 -0500
@@ -357,7 +357,11 @@
  		BUG();
  	spin_lock(&mm->page_table_lock);
  	do {
-		pmd_t *pmd = pmd_alloc(mm, dir, address);
+		pud_t *pud = pud_alloc(mm, dir, address);
+		pmd_t *pmd;
+		if (!pud)
+			return -ENOMEM;
+		pmd = pmd_alloc(mm, pud, address);
  		if (!pmd)
  			return -ENOMEM;
  		direct_remap_area_pmd(mm, pmd, address, end - address, &v);
--- linux-2.6.10/arch/xen/i386/mm/pageattr.c.pudding	2005-01-06 13:43:22.000000000 -0500
+++ linux-2.6.10/arch/xen/i386/mm/pageattr.c	2005-01-06 13:48:57.000000000 -0500
@@ -20,10 +20,14 @@
  pte_t *lookup_address(unsigned long address)
  {
  	pgd_t *pgd = pgd_offset_k(address); 
+	pud_t *pud;
  	pmd_t *pmd;
  	if (pgd_none(*pgd))
  		return NULL;
-	pmd = pmd_offset(pgd, address); 
+	pud = pud_offset(pgd, address);
+	if (pud_none(*pud))
+		return NULL;
+	pmd = pmd_offset(pud, address);
  	if (pmd_none(*pmd))
  		return NULL;
  	if (pmd_large(*pmd))
@@ -77,9 +81,11 @@
  	spin_lock_irqsave(&pgd_lock, flags);
  	for (page = pgd_list; page; page = (struct page *)page->index) {
  		pgd_t *pgd;
+		pud_t *pud;
  		pmd_t *pmd;
  		pgd = (pgd_t *)page_address(page) + pgd_index(address);
-		pmd = pmd_offset(pgd, address);
+		pud = pud_offset(pgd, address);
+		pmd = pmd_offset(pud, address);
  		set_pte_atomic((pte_t *)pmd, pte);
  	}
  	spin_unlock_irqrestore(&pgd_lock, flags);
@@ -92,7 +98,7 @@
  static inline void revert_page(struct page *kpte_page, unsigned long address)
  {
  	pte_t *linear = (pte_t *) 
-		pmd_offset(pgd_offset(&init_mm, address), address);
+		pmd_offset(pud_offset(pgd_offset(&init_mm, address), address), address);
  	set_pmd_pte(linear,  address,
  		    pfn_pte((__pa(address) & LARGE_PAGE_MASK) >> PAGE_SHIFT,
  			    PAGE_KERNEL_LARGE));
--- linux-2.6.10/arch/xen/i386/mm/pgtable.c.pudding	2005-01-06 13:49:09.000000000 -0500
+++ linux-2.6.10/arch/xen/i386/mm/pgtable.c	2005-01-06 20:56:28.000000000 -0500
@@ -65,6 +65,7 @@
  static void set_pte_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
  {
  	pgd_t *pgd;
+	pud_t *pud;
  	pmd_t *pmd;
  	pte_t *pte;

@@ -73,7 +74,12 @@
  		BUG();
  		return;
  	}
-	pmd = pmd_offset(pgd, vaddr);
+	pud = pud_offset(pgd, vaddr);
+	if (pud_none(*pud)) {
+		BUG();
+		return;
+	}
+	pmd = pmd_offset(pud, vaddr);
  	if (pmd_none(*pmd)) {
  		BUG();
  		return;
@@ -97,6 +103,7 @@
  			   pgprot_t flags)
  {
  	pgd_t *pgd;
+	pud_t *pud;
  	pmd_t *pmd;
  	pte_t *pte;

@@ -105,7 +112,12 @@
  		BUG();
  		return;
  	}
-	pmd = pmd_offset(pgd, vaddr);
+	pud = pud_offset(pgd, vaddr);
+	if (pud_none(*pud)) {
+		BUG();
+		return;
+	}
+	pmd = pmd_offset(pud, vaddr);
  	if (pmd_none(*pmd)) {
  		BUG();
  		return;
@@ -130,6 +142,7 @@
  void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
  {
  	pgd_t *pgd;
+	pud_t *pud;
  	pmd_t *pmd;

  	if (vaddr & (PMD_SIZE-1)) {		/* vaddr is misaligned */
@@ -145,7 +158,8 @@
  		printk ("set_pmd_pfn: pgd_none\n");
  		return; /* BUG(); */
  	}
-	pmd = pmd_offset(pgd, vaddr);
+	pud = pud_offset(pgd, vaddr);
+	pmd = pmd_offset(pud, vaddr);
  	set_pmd(pmd, pfn_pmd(pfn, flags));
  	/*
  	 * It's enough to flush this one mapping.
@@ -364,7 +378,8 @@
  void make_lowmem_page_readonly(void *va)
  {
  	pgd_t *pgd = pgd_offset_k((unsigned long)va);
-	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
+	pud_t *pud = pud_offset(pgd, (unsigned long)va);
+	pmd_t *pmd = pmd_offset(pud, (unsigned long)va);
  	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
  	queue_l1_entry_update(pte, (*(unsigned long *)pte)&~_PAGE_RW);
  }
@@ -372,7 +387,8 @@
  void make_lowmem_page_writable(void *va)
  {
  	pgd_t *pgd = pgd_offset_k((unsigned long)va);
-	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
+	pud_t *pud = pud_offset(pgd, (unsigned long)va);
+	pmd_t *pmd = pmd_offset(pud, (unsigned long)va);
  	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
  	queue_l1_entry_update(pte, (*(unsigned long *)pte)|_PAGE_RW);
  }
@@ -380,7 +396,8 @@
  void make_page_readonly(void *va)
  {
  	pgd_t *pgd = pgd_offset_k((unsigned long)va);
-	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
+	pud_t *pud = pud_offset(pgd, (unsigned long)va);
+	pmd_t *pmd = pmd_offset(pud, (unsigned long)va);
  	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
  	queue_l1_entry_update(pte, (*(unsigned long *)pte)&~_PAGE_RW);
  	if ( (unsigned long)va >= (unsigned long)high_memory )
@@ -397,7 +414,8 @@
  void make_page_writable(void *va)
  {
  	pgd_t *pgd = pgd_offset_k((unsigned long)va);
-	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
+	pud_t *pud = pud_offset(pgd, (unsigned long)va);
+	pmd_t *pmd = pmd_offset(pud, (unsigned long)va);
  	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
  	queue_l1_entry_update(pte, (*(unsigned long *)pte)|_PAGE_RW);
  	if ( (unsigned long)va >= (unsigned long)high_memory )
--- linux-2.6.10/arch/xen/i386/mm/hypervisor.c.pudding	2005-01-06 20:56:58.000000000 -0500
+++ linux-2.6.10/arch/xen/i386/mm/hypervisor.c	2005-01-06 20:57:30.000000000 -0500
@@ -427,6 +427,7 @@
  unsigned long allocate_empty_lowmem_region(unsigned long pages)
  {
      pgd_t         *pgd; 
+    pud_t         *pud;
      pmd_t         *pmd;
      pte_t         *pte;
      unsigned long *pfn_array;
@@ -447,7 +448,8 @@
      for ( i = 0; i < (1<<order); i++ )
      {
          pgd = pgd_offset_k(   (vstart + (i*PAGE_SIZE)));
-        pmd = pmd_offset(pgd, (vstart + (i*PAGE_SIZE)));
+        pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
+        pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
          pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE)));
          pfn_array[i] = pte->pte_low >> PAGE_SHIFT;
          queue_l1_entry_update(pte, 0);
--- linux-2.6.10/include/asm-xen/asm-i386/pgalloc.h.pudding	2005-01-06 14:03:01.000000000 -0500
+++ linux-2.6.10/include/asm-xen/asm-i386/pgalloc.h	2005-01-06 16:15:26.000000000 -0500
@@ -21,7 +21,6 @@
  /*
   * Allocate and free page tables.
   */
-
  extern pgd_t *pgd_alloc(struct mm_struct *);
  extern void pgd_free(pgd_t *pgd);

@@ -39,16 +38,15 @@

  #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))

+#ifdef CONFIG_PAE
  /*
- * allocating and freeing a pmd is trivial: the 1-entry pmd is
- * inside the pgd, so has no extra memory associated with it.
- * (In the PAE case we free the pmds as part of the pgd.)
+ * In the PAE case we free the pmds as part of the pgd.
   */
-
  #define pmd_alloc_one(mm, addr)		({ BUG(); ((pmd_t *)2); })
  #define pmd_free(x)			do { } while (0)
  #define __pmd_free_tlb(tlb,x)		do { } while (0)
-#define pgd_populate(mm, pmd, pte)	BUG()
+#define pud_populate(mm, pmd, pte)	BUG()
+#endif

  #define check_pgt_cache()	do { } while (0)

--- linux-2.6.10/include/asm-xen/asm-i386/pgtable-2level.h.pudding	2005-01-06 14:22:37.000000000 -0500
+++ linux-2.6.10/include/asm-xen/asm-i386/pgtable-2level.h	2005-01-06 17:16:32.000000000 -0500
@@ -1,24 +1,14 @@
  #ifndef _I386_PGTABLE_2LEVEL_H
  #define _I386_PGTABLE_2LEVEL_H

+#include <asm-generic/pgtable-nopmd.h>
+
  #define pte_ERROR(e) \
  	printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low)
-#define pmd_ERROR(e) \
-	printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
  #define pgd_ERROR(e) \
  	printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))

  /*
- * The "pgd_xxx()" functions here are trivial for a folded two-level
- * setup: the pgd is never bad, and a pmd always exists (as it's folded
- * into the pgd entry)
- */
-static inline int pgd_none(pgd_t pgd)		{ return 0; }
-static inline int pgd_bad(pgd_t pgd)		{ return 0; }
-static inline int pgd_present(pgd_t pgd)	{ return 1; }
-#define pgd_clear(xp)				do { } while (0)
-
-/*
   * Certain architectures need to do special things when PTEs
   * within a page table are directly modified.  Thus, the following
   * hook is made available.
@@ -43,16 +33,7 @@
   * (pmds are folded into pgds so this doesn't get actually called,
   * but the define is needed for a generic inline function.)
   */
-#define set_pmd(pmdptr, pmdval) xen_l2_entry_update((pmdptr), (pmdval).pmd)
-#define set_pgd(pgdptr, pgdval) ((void)0)
-
-#define pgd_page(pgd) \
-((unsigned long) __va(pgd_val(pgd) & PAGE_MASK))
-
-static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
-{
-	return (pmd_t *) dir;
-}
+#define set_pmd(pmdptr, pmdval) xen_l2_entry_update((pmdptr), pud_val((pmdval).pud))

  /*
   * A note on implementation of this atomic 'get-and-clear' operation.
@@ -110,6 +91,9 @@
  #define pfn_pte_ma(pfn, prot)	__pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
  #define pfn_pmd(pfn, prot)	__pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))

+#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
+#define pmd_page_kernel(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
+
  /*
   * All present user pages are user-executable:
   */
--- linux-2.6.10/include/asm-xen/asm-i386/page.h.pudding	2005-01-06 15:35:33.000000000 -0500
+++ linux-2.6.10/include/asm-xen/asm-i386/page.h	2005-01-06 17:02:20.000000000 -0500
@@ -85,7 +85,6 @@
  #define HPAGE_SHIFT	21
  #else
  typedef struct { unsigned long pte_low; } pte_t;
-typedef struct { unsigned long pmd; } pmd_t;
  typedef struct { unsigned long pgd; } pgd_t;
  typedef struct { unsigned long pgprot; } pgprot_t;
  #define boot_pte_t pte_t /* or would you rather have a typedef */
@@ -93,6 +92,7 @@
  			 (x).pte_low)
  #define pte_val_ma(x)	((x).pte_low)
  #define HPAGE_SHIFT	22
+#include <asm-generic/pgtable-nopmd.h>
  #endif
  #define PTE_MASK	PAGE_MASK

@@ -103,15 +103,19 @@
  #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
  #endif

+#define pgd_val(x)	((x).pgd)
+#define pgprot_val(x)	((x).pgprot)
+#define __pgd(x)	((pgd_t) { (x) } )
+#define __pgprot(x)	((pgprot_t) { (x) } )

+/* Yes, this is ugly... */
+#undef pmd_val
  static inline unsigned long pmd_val(pmd_t x)
  {
-	unsigned long ret = x.pmd;
+	unsigned long ret = pud_val(x.pud);
  	if (ret) ret = machine_to_phys(ret);
  	return ret;
  }
-#define pgd_val(x)	({ BUG(); (unsigned long)0; })
-#define pgprot_val(x)	((x).pgprot)

  static inline pte_t __pte(unsigned long x)
  {
@@ -119,13 +123,12 @@
  	return ((pte_t) { (x) });
  }
  #define __pte_ma(x)	((pte_t) { (x) } )
+#undef __pmd
  static inline pmd_t __pmd(unsigned long x)
  {
  	if ((x & 1)) x = phys_to_machine(x);
-	return ((pmd_t) { (x) });
+	return ((pmd_t) { __pud(x) });
  }
-#define __pgd(x)	({ BUG(); (pgprot_t) { 0 }; })
-#define __pgprot(x)	((pgprot_t) { (x) } )

  #endif /* !__ASSEMBLY__ */

--- linux-2.6.10/include/asm-xen/asm-i386/pgtable.h.pudding	2005-01-06 15:13:47.000000000 -0500
+++ linux-2.6.10/include/asm-xen/asm-i386/pgtable.h	2005-01-06 17:28:48.032819846 -0500
@@ -54,12 +54,12 @@
   */
  #ifdef CONFIG_X86_PAE
  # include <asm/pgtable-3level-defs.h>
+# define PMD_SIZE	(1UL << PMD_SHIFT)
+# define PMD_MASK	(~(PMD_SIZE-1))
  #else
  # include <asm/pgtable-2level-defs.h>
  #endif

-#define PMD_SIZE	(1UL << PMD_SHIFT)
-#define PMD_MASK	(~(PMD_SIZE-1))
  #define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
  #define PGDIR_MASK	(~(PGDIR_SIZE-1))

@@ -316,18 +316,11 @@

  #define page_pte(page) page_pte_prot(page, __pgprot(0))

-#define pmd_page_kernel(pmd) \
-((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
-
  #define pmd_clear(xp)	do {					\
  	set_pmd(xp, __pmd(0));					\
  	xen_flush_page_update_queue();				\
  } while (0)

-#ifndef CONFIG_DISCONTIGMEM
-#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
-#endif /* !CONFIG_DISCONTIGMEM */
-
  #define pmd_large(pmd) \
  	((pmd_val(pmd) & (_PAGE_PSE|_PAGE_PRESENT)) == (_PAGE_PSE|_PAGE_PRESENT))

@@ -338,6 +331,7 @@
   * control the given virtual address
   */
  #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
+#define pgd_index_k(addr) pgd_index(addr)

  /*
   * pgd_offset() returns a (pgd_t *)
@@ -463,7 +457,8 @@
  #define arbitrary_virt_to_machine(__va)					\
  ({									\
  	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
-	pmd_t *__pmd = pmd_offset(__pgd, (unsigned long)(__va));	\
+	pud_t *__pud = pud_offset(__pgd, (unsigned long)(__va));	\
+	pmd_t *__pmd = pmd_offset(__pud, (unsigned long)(__va));	\
  	pte_t *__pte = pte_offset_kernel(__pmd, (unsigned long)(__va));	\
  	unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK;	\
  	__pa | ((unsigned long)(__va) & (PAGE_SIZE-1));			\
--- linux-2.6.10/drivers/xen/balloon/balloon.c.pudding	2005-01-06 21:35:01.000000000 -0500
+++ linux-2.6.10/drivers/xen/balloon/balloon.c	2005-01-06 21:35:43.000000000 -0500
@@ -137,12 +137,16 @@
  static inline pte_t *get_ptep(unsigned long addr)
  {
      pgd_t *pgd;
+    pud_t *pud;
      pmd_t *pmd;

      pgd = pgd_offset_k(addr);
      if ( pgd_none(*pgd) || pgd_bad(*pgd) ) BUG();

-    pmd = pmd_offset(pgd, addr);
+    pud = pud_offset(pgd, addr);
+    if ( pud_none(*pud) || pud_bad(*pud) ) BUG();
+
+    pmd = pmd_offset(pud, addr);
      if ( pmd_none(*pmd) || pmd_bad(*pmd) ) BUG();

      return pte_offset_kernel(pmd, addr);
--- linux-2.6.10/include/asm-xen/asm-i386/pgtable-2level-defs.h.pudding	2005-01-06 21:55:46.420330906 -0500
+++ linux-2.6.10/include/asm-xen/asm-i386/pgtable-2level-defs.h	2005-01-06 21:55:54.515000937 -0500
@@ -9,13 +9,6 @@
  #define PTRS_PER_PGD	1024
  #define PTRS_PER_PGD_NO_HV	(HYPERVISOR_VIRT_START >> PGDIR_SHIFT)

-/*
- * the i386 is two-level, so we don't really have any
- * PMD directory physically.
- */
-#define PMD_SHIFT	22
-#define PTRS_PER_PMD	1
-
  #define PTRS_PER_PTE	1024

  #endif /* _I386_PGTABLE_2LEVEL_DEFS_H */


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt

^ permalink raw reply	[relevance 7%]

* Cannot start domU from NFS
@ 2005-01-07  7:37  5% Nauzad Sadry
    0 siblings, 1 reply; 200+ results
From: Nauzad Sadry @ 2005-01-07  7:37 UTC (permalink / raw)
  To: xen-devel

Hello everyone
I have Xen-2.0.1 setup with dom0 starting from local disk.
I need to start domU from NFS
The NFS server works - both local and remote clients can use it.
But not domU 

Here is my config
======= /etc/xen/vm_config_nfs =========
kernel = "/boot/vmlinuz-2.6.9-xenU"
ramdisk = "/boot/initrd-fc3.img"
memory = 128
name = "VM-1"
nics=3
dhcp="dhcp"
root = "/dev/nfs"
nfs_server = "192.168.1.123"
nfs_root   = '/xen_nfs/root'
extra = "4 enforcing=0"
======================================

domU starts booting and hangs at mounting its root 

Here is the boot log

Using config file "/etc/xen/vm_config_nfs".
Started domain VM-1, console on port 9608
************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.6.9-xenU (xenod@labyrinth.cl.cam.ac.uk) (
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 We
d Nov 17 22:29:37 GMT 2004
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000008000000 (usable)
128MB LOWMEM available.
DMI not present.
Built 1 zonelists
Kernel command line:  ip=:192.168.123.123:::VM-1:eth0:dhcp
root=/dev/nfs nfsroot=192.168.123.123:/xen_nfs/root 3 VMID=1
enforcing=0
Initializing CPU#0
PID hash table entries: 1024 (order: 10, 16384 bytes)
Xen reported: 1793.416 MHz processor.
Using tsc for high-res timesource
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 126148k/131072k available (1596k kernel code, 4860k reserved,
466k data, 92k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 1024K (64 bytes/line)
CPU: AMD Opteron(tm) Processor 244 stepping 08
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... disabled
checking if image is initramfs... it is
Freeing initrd memory: 1061k freed
NET: Registered protocol family 16
Initializing Cryptographic API
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Xen virtual console successfully installed as tty
Event-channel device installed.
Starting Xen Balloon driver
xen_blk: Initialising virtual block device driver
xen_blk: Timeout connecting to device!
xen_net: Initialising virtual ethernet driver.
NET: Registered protocol family 2
IP: routing cache hash table of 1024 buckets, 8Kbytes
TCP: Hash tables configured (established 8192 bind 16384)
NET: Registered protocol family 1
NET: Registered protocol family 17
IP-Config: Incomplete network configuration information.
Freeing unused kernel memory: 92k freed
Red Hat nash version 4.1.18 starting
Mounted /proc filesystem
Mounting sysfs
Creating /dev
Starting udev
Creating root device
Mounting root filesystem
mount: error 6 mounting ext3
mount: error 2 mounting none
Switching to new root
switchroot: mount failed: 22
umount /initrd/dev failed: 2
Kernel panic - not syncing: Attempted to kill init!
 <0>Rebooting in 1 seconds..Linux version 2.6.9-xenU (xen


On my NFS export, the etc/fstab is as follows
/xen_nfs/root        /                           ext3    defaults        1 1
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                    proc    defaults        0 0
none                    /dev/shm              tmpfs   defaults        0 0
/dev/hda5             swap                    swap    defaults        0 0
/dev/cdrom           /mnt/cdrom           udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0                /mnt/floppy           auto    noauto,owner,kudzu 0 0

Help will be really appreciated 

Thanks

Nauzad


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt

^ permalink raw reply	[relevance 5%]

* Re: Cannot start domU from NFS
  @ 2005-01-09  0:42  4%   ` Nauzad Sadry
  2005-01-11  2:25  0%     ` Nauzad Sadry
  0 siblings, 1 reply; 200+ results
From: Nauzad Sadry @ 2005-01-09  0:42 UTC (permalink / raw)
  To: Christian Limpach; +Cc: xen-devel

Hi Christian

Thanks for the reply, but your sugesstions did not work .. i am still
failing at the same point. It is somehow not able to mount the root
file system.

1. Do I need to have "/dev/nfs" as an existing device in the target
(domain 0)system
2. Are there any daemons or services that I need running on my domain0
before attempting to create domain1
3. When you say use static IP configuration, I presume this means setting 
    ip="<address> in the xen config file.
4. After completing IP config I believe it should use contact the NFS
bootserver, but i do not see any such commands in the boot log.

Please help me if something is wrong in my configuration

FYR, here is the boot log

************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.6.9-xenU (xenod@labyrinth.cl.cam.ac.uk) (gcc
version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 Wed Nov 17
 22:29:37 GMT 2004
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000008000000 (usable)
128MB LOWMEM available.
DMI not present.
Built 1 zonelists
Kernel command line:  ip=192.168.123.145:192.168.123.200:192.
168.123.254:255.255.255.0:VM-3:eth0:off root=/dev/nfs nfsroot
=192.168.123.200:/xen_nfs/tmp 3 VMID=3 enforcing=0
Initializing CPU#0
PID hash table entries: 1024 (order: 10, 16384 bytes)
Xen reported: 1793.261 MHz processor.
Using tsc for high-res timesource
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 126148k/131072k available (1596k kernel code, 4860k reserved,
466k data, 92k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 1024K (64 bytes/line)
CPU: AMD Opteron(tm) Processor 244 stepping 08
Enabling unmasked SIMD FPU exception support... done.
Checking 'hlt' instruction... disabled
checking if image is initramfs... it is
Freeing initrd memory: 1061k freed
NET: Registered protocol family 16
Initializing Cryptographic API
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Xen virtual console successfully installed as tty
Event-channel device installed.
Starting Xen Balloon driver
xen_blk: Initialising virtual block device driver
xen_blk: Timeout connecting to device!
xen_net: Initialising virtual ethernet driver.
NET: Registered protocol family 2
IP: routing cache hash table of 1024 buckets, 8Kbytes
TCP: Hash tables configured (established 8192 bind 16384)
NET: Registered protocol family 1
NET: Registered protocol family 17
IP-Config: Complete:
      device=eth0, addr=192.168.123.145, mask=255.255.255.0,
gw=192.168.123.254, host=VM-3, domain=, nis-domain=(none),
     bootserver=192.168.123.200, rootserver=192.168.123.200,
rootpath=
Freeing unused kernel memory: 92k freed
Red Hat nash version 4.1.18 starting
Mounted /proc filesystem
Mounting sysfs
Creating /dev
Starting udev
Creating root device
Mounting root filesystem
mount: error 6 mounting ext3
mount: error 2 mounting none
Switching to new root
switchroot: mount failed: 22
umount /initrd/dev failed: 2
Kernel panic - not syncing: Attempted to kill init!



On Fri, 7 Jan 2005 10:01:19 +0000, Christian Limpach
<Christian.Limpach@cl.cam.ac.uk> wrote:
> On Thu, Jan 06, 2005 at 11:37:09PM -0800, Nauzad Sadry wrote:
> > Hello everyone
> > I have Xen-2.0.1 setup with dom0 starting from local disk.
> > I need to start domU from NFS
> > The NFS server works - both local and remote clients can use it.
> > But not domU
> > 
> > Here is the boot log
> >
> > IP-Config: Incomplete network configuration information.
> 
> Try booting with a static IP configuration.  For dhcp you will need to
> build your own xenU kernel since the one we provide doesn't have dhcp
> client support compiled in.  Alternatively you could use our xen0 kernel
> which has dhcp client support compiled in.
> 
> > On my NFS export, the etc/fstab is as follows
> > /xen_nfs/root        /                           ext3    defaults        1 1
> > none                    /dev/pts                devpts  gid=5,mode=620  0 0
> > none                    /proc                    proc    defaults        0 0
> > none                    /dev/shm              tmpfs   defaults        0 0
> > /dev/hda5             swap                    swap    defaults        0 0
> > /dev/cdrom           /mnt/cdrom           udf,iso9660 noauto,owner,kudzu,ro 0 0
> > /dev/fd0                /mnt/floppy           auto    noauto,owner,kudzu 0 0
> 
> Unless you're exporting a block device to the domain as hda5, this will
> fail when swap gets enabled.  Also, your entry for the root fs is not
> correct.  The 1st field should be of the form server:/path/to/root --
> I usually use IP addresses, a hostname might work, certainly if it's
> defined in /etc/hosts.  The filesystem type needs to be nfs, not ext3.
> Also the dump frequency and fsck pass number fields should both be 0.
> 
>    christian
> 
>


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt

^ permalink raw reply	[relevance 4%]

* Re: Cannot start domU from NFS
  2005-01-09  0:42  4%   ` Nauzad Sadry
@ 2005-01-11  2:25  0%     ` Nauzad Sadry
  0 siblings, 0 replies; 200+ results
From: Nauzad Sadry @ 2005-01-11  2:25 UTC (permalink / raw)
  To: Christian Limpach; +Cc: xen-devel

Hello guys

I was able to sucessfully start domU using NFS. I had to disable the
ramdisk (=initrd-fc3.img) in the vm configuration file. The ramdisk
was preventing domain0 from using NFS to mounting the root

Thanks for your help

Nauzad

On Sat, 8 Jan 2005 16:42:21 -0800, Nauzad Sadry <nauzad@gmail.com> wrote:
> Hi Christian
> 
> Thanks for the reply, but your sugesstions did not work .. i am still
> failing at the same point. It is somehow not able to mount the root
> file system.
> 
> 1. Do I need to have "/dev/nfs" as an existing device in the target
> (domain 0)system
> 2. Are there any daemons or services that I need running on my domain0
> before attempting to create domain1
> 3. When you say use static IP configuration, I presume this means setting
>    ip="<address> in the xen config file.
> 4. After completing IP config I believe it should use contact the NFS
> bootserver, but i do not see any such commands in the boot log.
> 
> Please help me if something is wrong in my configuration
> 
> FYR, here is the boot log
> 
> ************ REMOTE CONSOLE: CTRL-] TO QUIT ********
> Linux version 2.6.9-xenU (xenod@labyrinth.cl.cam.ac.uk) (gcc
> version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 Wed Nov 17
> 22:29:37 GMT 2004
> BIOS-provided physical RAM map:
> Xen: 0000000000000000 - 0000000008000000 (usable)
> 128MB LOWMEM available.
> DMI not present.
> Built 1 zonelists
> Kernel command line:  ip=192.168.123.145:192.168.123.200:192.
> 168.123.254:255.255.255.0:VM-3:eth0:off root=/dev/nfs nfsroot
> =192.168.123.200:/xen_nfs/tmp 3 VMID=3 enforcing=0
> Initializing CPU#0
> PID hash table entries: 1024 (order: 10, 16384 bytes)
> Xen reported: 1793.261 MHz processor.
> Using tsc for high-res timesource
> Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
> Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
> Memory: 126148k/131072k available (1596k kernel code, 4860k reserved,
> 466k data, 92k init, 0k highmem)
> Checking if this processor honours the WP bit even in supervisor mode... Ok.
> Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
> CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
> CPU: L2 Cache: 1024K (64 bytes/line)
> CPU: AMD Opteron(tm) Processor 244 stepping 08
> Enabling unmasked SIMD FPU exception support... done.
> Checking 'hlt' instruction... disabled
> checking if image is initramfs... it is
> Freeing initrd memory: 1061k freed
> NET: Registered protocol family 16
> Initializing Cryptographic API
> RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
> Xen virtual console successfully installed as tty
> Event-channel device installed.
> Starting Xen Balloon driver
> xen_blk: Initialising virtual block device driver
> xen_blk: Timeout connecting to device!
> xen_net: Initialising virtual ethernet driver.
> NET: Registered protocol family 2
> IP: routing cache hash table of 1024 buckets, 8Kbytes
> TCP: Hash tables configured (established 8192 bind 16384)
> NET: Registered protocol family 1
> NET: Registered protocol family 17
> IP-Config: Complete:
>      device=eth0, addr=192.168.123.145, mask=255.255.255.0,
> gw=192.168.123.254, host=VM-3, domain=, nis-domain=(none),
>     bootserver=192.168.123.200, rootserver=192.168.123.200,
> rootpath=
> Freeing unused kernel memory: 92k freed
> Red Hat nash version 4.1.18 starting
> Mounted /proc filesystem
> Mounting sysfs
> Creating /dev
> Starting udev
> Creating root device
> Mounting root filesystem
> mount: error 6 mounting ext3
> mount: error 2 mounting none
> Switching to new root
> switchroot: mount failed: 22
> umount /initrd/dev failed: 2
> Kernel panic - not syncing: Attempted to kill init!
> 
> On Fri, 7 Jan 2005 10:01:19 +0000, Christian Limpach
> <Christian.Limpach@cl.cam.ac.uk> wrote:
> > On Thu, Jan 06, 2005 at 11:37:09PM -0800, Nauzad Sadry wrote:
> > > Hello everyone
> > > I have Xen-2.0.1 setup with dom0 starting from local disk.
> > > I need to start domU from NFS
> > > The NFS server works - both local and remote clients can use it.
> > > But not domU
> > >
> > > Here is the boot log
> > >
> > > IP-Config: Incomplete network configuration information.
> >
> > Try booting with a static IP configuration.  For dhcp you will need to
> > build your own xenU kernel since the one we provide doesn't have dhcp
> > client support compiled in.  Alternatively you could use our xen0 kernel
> > which has dhcp client support compiled in.
> >
> > > On my NFS export, the etc/fstab is as follows
> > > /xen_nfs/root        /                           ext3    defaults        1 1
> > > none                    /dev/pts                devpts  gid=5,mode=620  0 0
> > > none                    /proc                    proc    defaults        0 0
> > > none                    /dev/shm              tmpfs   defaults        0 0
> > > /dev/hda5             swap                    swap    defaults        0 0
> > > /dev/cdrom           /mnt/cdrom           udf,iso9660 noauto,owner,kudzu,ro 0 0
> > > /dev/fd0                /mnt/floppy           auto    noauto,owner,kudzu 0 0
> >
> > Unless you're exporting a block device to the domain as hda5, this will
> > fail when swap gets enabled.  Also, your entry for the root fs is not
> > correct.  The 1st field should be of the form server:/path/to/root --
> > I usually use IP addresses, a hostname might work, certainly if it's
> > defined in /etc/hosts.  The filesystem type needs to be nfs, not ext3.
> > Also the dump frequency and fsck pass number fields should both be 0.
> >
> >    christian
> >
> >
>


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt

^ permalink raw reply	[relevance 0%]

* Re: Re: Xen kernel issue
  @ 2005-01-31  4:57  7%     ` Travis Newman
  0 siblings, 0 replies; 200+ results
From: Travis Newman @ 2005-01-31  4:57 UTC (permalink / raw)
  To: xen-devel


> The above should work.  You mentioned in an earlier post that you'd done a 
> make xconfig in the Linux directory - if you do that, you'll need to copy out 
> the .config file to the path I mentioned above.  Otherwise it'll get 
> overwritten (by the file that happens to be at that path) when you make 
> dist / world.

Another thing throwing me for a loop is that whenever I do manage to 
config the kernel and start building it (when I have made the changes I 
want to it) It gives me the following error, but this error does NOT 
come up if I don't change the default config.

   CC      drivers/xen/balloon/balloon.o
drivers/xen/balloon/balloon.c: In function `balloon_process':
drivers/xen/balloon/balloon.c:209: error: `phys_to_machine_mapping' 
undeclared (first use in this function)
drivers/xen/balloon/balloon.c:209: error: (Each undeclared identifier is 
reported only once
drivers/xen/balloon/balloon.c:209: error: for each function it appears in.)
drivers/xen/balloon/balloon.c:209: error: `INVALID_P2M_ENTRY' undeclared 
(first use in this function)
drivers/xen/balloon/balloon.c:253: warning: implicit declaration of 
function `scrub_pages'
make[3]: *** [drivers/xen/balloon/balloon.o] Error 1
make[2]: *** [drivers/xen/balloon] Error 2
make[1]: *** [drivers/xen] Error 2
make: *** [drivers] Error 2

So again, I am out of ideas... I can't use the default config because of 
a lack of features, but I can't change it because of errors... Unless 
there's something I'm missing somewhere (Which there very well may be) 
or something about my system is screwy.

So any help or pre-built kernels anyone wants to provide will be greatly 
appreciated :)


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl

^ permalink raw reply	[relevance 7%]

* RE: Re: Xen kernel issue
@ 2005-01-31  8:00  0% Ian Pratt
  0 siblings, 0 replies; 200+ results
From: Ian Pratt @ 2005-01-31  8:00 UTC (permalink / raw)
  To: Travis Newman, xen-devel

Please post a diff between a config that works and one that doesn't.

My suspicion is that you might be trying to enable CONFIG_HIGHMEM64G
which won't work -- CONFIG_HIGHMEM4G is the largest physical memory
currently supported.

Ian 

> -----Original Message-----
> From: xen-devel-admin@lists.sourceforge.net 
> [mailto:xen-devel-admin@lists.sourceforge.net] On Behalf Of 
> Travis Newman
> Sent: 31 January 2005 04:57
> To: xen-devel@lists.sourceforge.net
> Subject: Re: [Xen-devel] Re: Xen kernel issue
> 
> 
> > The above should work.  You mentioned in an earlier post 
> that you'd done a 
> > make xconfig in the Linux directory - if you do that, 
> you'll need to copy out 
> > the .config file to the path I mentioned above.  Otherwise 
> it'll get 
> > overwritten (by the file that happens to be at that path) 
> when you make 
> > dist / world.
> 
> Another thing throwing me for a loop is that whenever I do manage to 
> config the kernel and start building it (when I have made the 
> changes I 
> want to it) It gives me the following error, but this error does NOT 
> come up if I don't change the default config.
> 
>    CC      drivers/xen/balloon/balloon.o
> drivers/xen/balloon/balloon.c: In function `balloon_process':
> drivers/xen/balloon/balloon.c:209: error: `phys_to_machine_mapping' 
> undeclared (first use in this function)
> drivers/xen/balloon/balloon.c:209: error: (Each undeclared 
> identifier is 
> reported only once
> drivers/xen/balloon/balloon.c:209: error: for each function 
> it appears in.)
> drivers/xen/balloon/balloon.c:209: error: `INVALID_P2M_ENTRY' 
> undeclared 
> (first use in this function)
> drivers/xen/balloon/balloon.c:253: warning: implicit declaration of 
> function `scrub_pages'
> make[3]: *** [drivers/xen/balloon/balloon.o] Error 1
> make[2]: *** [drivers/xen/balloon] Error 2
> make[1]: *** [drivers/xen] Error 2
> make: *** [drivers] Error 2
> 
> So again, I am out of ideas... I can't use the default config 
> because of 
> a lack of features, but I can't change it because of errors... Unless 
> there's something I'm missing somewhere (Which there very 
> well may be) 
> or something about my system is screwy.
> 
> So any help or pre-built kernels anyone wants to provide will 
> be greatly 
> appreciated :)
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive 
> Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xen-devel
> 


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl

^ permalink raw reply	[relevance 0%]

* RFC: Creation of virtual bus, hook-up of Xen devices
@ 2005-02-01 20:30  5% Jeremy Katz
  0 siblings, 0 replies; 200+ results
From: Jeremy Katz @ 2005-02-01 20:30 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]

For many purposes on a Linux system, it is required to have devices
export themselves via the device infrastructure (exposed via sysfs) to
allow for reasonable user-space probing and discovery of available
devices.  This is especially useful/necessary for things like installing
to guest systems.

The attached patch is a first pass at starting to get something along
these lines for Xen devices to hook into.  Provided sysfs bits
are /sys/bus/x/devices/netN for each xen_net device
and /sys/bus/x/drivers/xen_{net,blk} as points for the xen_net and
xen_blk drivers.  I haven't actually really hooked up the xen_blk
devices yet as I think that getting some of the base infrastructure
committed first will make that a little better.  Also, there's
definitely more that can be done in terms of cleaning up netfront to
better take advantage of the fact that there's a struct device
associated with each net_device instead of keeping track of all of the
generic bits in the net_private struct.

Comments? 

Jeremy

[-- Attachment #2: xen-xbus.patch --]
[-- Type: text/x-patch, Size: 14994 bytes --]

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/02/01 13:57:41-05:00 katzj@redhat.com 
#   Hook up netfront devices to x bus.
# 
# linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c
#   2005/02/01 13:57:39-05:00 katzj@redhat.com +41 -27
#   Register netfront device with virtual bus.  Hook everything up so that
#   network devices show up under /sys/bus/x/devices with driver links, etc
# 
# ChangeSet
#   2005/02/01 13:56:13-05:00 katzj@redhat.com 
#   Register block frontend with xbus
# 
# linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c
#   2005/02/01 13:56:12-05:00 katzj@redhat.com +10 -1
#   Basic registration with xbus
# 
# ChangeSet
#   2005/02/01 13:53:31-05:00 katzj@redhat.com 
#   First pass at creating xbus virtual bus for Xen devices to sit 
#   on.  Heavily inspired by the vio code for ppc64. 
#   
#   Lets devices appear under /sys/bus/x 
# 
# linux-2.6.10-xen-sparse/include/asm-xen/xbus.h
#   2005/02/01 13:53:22-05:00 katzj@redhat.com +45 -0
# 
# linux-2.6.10-xen-sparse/arch/xen/kernel/xbus.c
#   2005/02/01 13:53:22-05:00 katzj@redhat.com +201 -0
# 
# linux-2.6.10-xen-sparse/include/asm-xen/xbus.h
#   2005/02/01 13:53:22-05:00 katzj@redhat.com +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-katzj/linux-2.6.10-xen-sparse/include/asm-xen/xbus.h
# 
# linux-2.6.10-xen-sparse/arch/xen/kernel/xbus.c
#   2005/02/01 13:53:22-05:00 katzj@redhat.com +0 -0
#   BitKeeper file /home/katzj/cvs/xen/xen-katzj/linux-2.6.10-xen-sparse/arch/xen/kernel/xbus.c
# 
# linux-2.6.10-xen-sparse/arch/xen/kernel/Makefile
#   2005/02/01 13:53:22-05:00 katzj@redhat.com +1 -1
#   Add build of xbus
# 
diff -Nru a/linux-2.6.10-xen-sparse/arch/xen/kernel/Makefile b/linux-2.6.10-xen-sparse/arch/xen/kernel/Makefile
--- a/linux-2.6.10-xen-sparse/arch/xen/kernel/Makefile	2005-02-01 14:50:53 -05:00
+++ b/linux-2.6.10-xen-sparse/arch/xen/kernel/Makefile	2005-02-01 14:50:53 -05:00
@@ -12,4 +12,4 @@
 extra-y += vmlinux.lds
 
 obj-y	:= ctrl_if.o evtchn.o fixup.o reboot.o xen_proc.o \
-           gnttab.o skbuff.o devmem.o smp.o
+           gnttab.o skbuff.o devmem.o smp.o xbus.o
diff -Nru a/linux-2.6.10-xen-sparse/arch/xen/kernel/xbus.c b/linux-2.6.10-xen-sparse/arch/xen/kernel/xbus.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/linux-2.6.10-xen-sparse/arch/xen/kernel/xbus.c	2005-02-01 14:50:53 -05:00
@@ -0,0 +1,201 @@
+/*
+ * X IO Bus for Xen
+ *
+ *  Heavily based on arch/ppc64/kernel/vio.c
+ *
+ *    Copyright (c) 2005 Red Hat, Inc.
+ *     Jeremy Katz <katzj@redhat.com>
+ *
+ *      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.
+ */
+
+#include <linux/init.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/kobject.h>
+#include <linux/device.h>
+#include <asm-xen/xbus.h>
+#include <asm-xen/ctrl_if.h>
+#include <asm-xen/xen-public/io/domain_controller.h>
+
+static struct xdev *xbus_dev;
+
+static int xbus_probe(struct device *dev)
+{
+    struct xdev *xdev = to_xdev(dev);
+    struct xdriver *xdrv = to_xdriver(dev->driver);
+
+    if (!xdrv->probe)
+        return -ENODEV;
+
+    /* match the device */
+    return xdrv->probe(xdev, xdev->type);
+}
+
+static int xbus_match(struct device *dev, struct device_driver *drv)
+{
+    const struct xdev *xdev = to_xdev(dev);
+    struct xdriver *xdrv = to_xdriver(drv);
+
+    return !strcmp(xdrv->type, xdev->type);
+}
+
+/**
+ * x_register_driver: - Register a new driver
+ * @drv:	The xdriver structure to be registered.
+ */
+int x_register_driver(struct xdriver *xdrv)
+{
+    printk(KERN_DEBUG "%s: driver %s registering\n", __FUNCTION__,
+           xdrv->name);
+
+    /* fill in 'struct driver' fields */
+    xdrv->driver.name = xdrv->name;
+    xdrv->driver.bus = &xbus_type;
+    xdrv->driver.probe = &xbus_probe;
+    xdrv->driver.remove = NULL;
+    
+    return driver_register(&xdrv->driver);
+}
+EXPORT_SYMBOL(x_register_driver);
+
+static void __devinit xdev_release(struct device *dev)
+{
+    kfree(to_xdev(dev));
+}
+
+void __devinit x_unregister_device(struct xdev *dev)
+{
+    device_unregister(&dev->dev);
+}
+EXPORT_SYMBOL(x_unregister_device);
+
+static struct xdev *__init x_register_device (char *type, unsigned int handle) {
+    struct xdev *dev;
+    int err;
+
+    dev = kmalloc(sizeof(struct xdev), GFP_KERNEL);
+    if (!dev)
+        return NULL;
+    memset(dev, 0, sizeof(struct xdev));
+
+    snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%s%d", type, handle);
+    dev->name = dev->dev.bus_id;
+    dev->type = type;
+    dev->handle = handle;
+
+    /* init generic struct fields */
+    dev->dev.parent = &xbus_dev->dev;
+    dev->dev.bus = &xbus_type;
+    dev->dev.release = xdev_release;
+
+    /* register with device framework */
+    if ((err = device_register(&dev->dev))) {
+        printk(KERN_ERR "%s: failed to register device %s: %d\n",
+               __FUNCTION__, dev->dev.bus_id, err);
+        return NULL;
+    }
+    
+    return dev;
+}
+
+static int num_intfs = 0;
+
+static void count_netif_rxmsg_handler(ctrl_msg_t *msg, unsigned long id)
+{
+    if (msg->subtype == CMSG_NETIF_FE_INTERFACE_STATUS) {
+        netif_fe_interface_status_t *n;
+
+        n = (netif_fe_interface_status_t *) &msg->msg[0];
+        x_register_device("net", n->handle);
+        num_intfs++;
+    } 
+    msg->length = 0;
+    ctrl_if_send_response(msg);
+}
+
+/**
+ * xunregister_driver - Remove registration of driver.
+ * @driver:	The xdriver struct to be removed form registration
+ */
+void x_unregister_driver(struct xdriver *xdrv)
+{
+	driver_unregister(&xdrv->driver);
+}
+EXPORT_SYMBOL(x_unregister_driver);
+
+/* FIXME: this is ugly in that we have to do the netif specific bits
+ * in what should be generic code.  
+ */
+static void register_net_devs(void)
+{
+    int err;
+    ctrl_msg_t cmsg = {
+        .type = CMSG_NETIF_FE,
+        .subtype = CMSG_NETIF_FE_DRIVER_STATUS,
+        .length = sizeof(netif_fe_driver_status_t)
+    };
+    int i;
+    netif_fe_driver_status_t *msg = (void*)cmsg.msg;
+    msg->status = (NETIF_DRIVER_STATUS_UP);
+    
+    (void)ctrl_if_register_receiver(CMSG_NETIF_FE, count_netif_rxmsg_handler,
+                                    CALLBACK_IN_BLOCKING_CONTEXT);
+    
+    
+    err = ctrl_if_send_message_block(&cmsg, NULL, 0, 
+                                     TASK_UNINTERRUPTIBLE);
+    if (!err) {
+        for (i=0; i < 5; i++) {
+            set_current_state(TASK_INTERRUPTIBLE);
+            schedule_timeout(10);
+        }
+    }
+                
+    ctrl_if_unregister_receiver(CMSG_NETIF_FE, count_netif_rxmsg_handler);
+    msg->status = (NETIF_DRIVER_STATUS_DOWN);
+    err = ctrl_if_send_message_block(&cmsg, NULL, 0, 
+                                     TASK_UNINTERRUPTIBLE);
+
+}
+
+static int __init xbus_init(void)
+{
+    int err = 0;
+
+    err = bus_register(&xbus_type);
+    if (err) {
+        printk(KERN_ERR "failed to register x bus\n");
+        return err;
+    }
+
+    xbus_dev = kmalloc(sizeof(struct xdev), GFP_KERNEL);
+    if (!xbus_dev)
+        return 1;
+    memset(xbus_dev, 0, sizeof(struct xdev));
+    strcpy(xbus_dev->dev.bus_id, "x");
+    
+    err = device_register(&xbus_dev->dev);
+    if (err) {
+        printk(KERN_WARNING "%s: device_register returned %i\n", 
+               __FUNCTION__, err);
+        kfree(xbus_dev);
+        return err;
+    }
+    
+    register_net_devs();
+    
+    return 0;
+}
+
+__initcall(xbus_init);
+
+struct bus_type xbus_type = {
+    .name = "x",
+    .match = &xbus_match,
+};
+
+EXPORT_SYMBOL(xbus_type);
diff -Nru a/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c b/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c	2005-02-01 14:50:53 -05:00
+++ b/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c	2005-02-01 14:50:53 -05:00
@@ -46,6 +46,7 @@
 #include <scsi/scsi.h>
 #include <asm-xen/ctrl_if.h>
 #include <asm-xen/evtchn.h>
+#include <asm-xen/xbus.h>
 
 typedef unsigned char byte; /* from linux/ide.h */
 
@@ -1350,6 +1351,14 @@
     return err;
 }
 
+static char blkfront_driver_name[] = "xen_blk";
+static char blkfront_driver_type[] = "blk";
+
+static struct xdriver xen_blkfront_driver = {
+    .name        = (char *)blkfront_driver_name,
+    .type = blkfront_driver_type,
+};
+
 int __init xlblk_init(void)
 {
     int i;
@@ -1370,7 +1379,7 @@
 
     wait_for_blkif();
 
-    return 0;
+    return x_register_driver(&xen_blkfront_driver);    
 }
 
 void blkdev_suspend(void)
diff -Nru a/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c b/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c	2005-02-01 14:50:53 -05:00
+++ b/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c	2005-02-01 14:50:53 -05:00
@@ -46,6 +46,7 @@
 #include <asm-xen/ctrl_if.h>
 #include <asm-xen/xen-public/io/netif.h>
 #include <asm-xen/balloon.h>
+#include <asm-xen/xbus.h>
 #include <asm/page.h>
 
 #include <net/arp.h>
@@ -93,7 +94,8 @@
 struct net_private
 {
     struct list_head list;
-    struct net_device *dev;
+    struct net_device *netdev;
+    struct device *dev;
 
     struct net_device_stats stats;
     NETIF_RING_IDX rx_resp_cons, tx_resp_cons;
@@ -175,7 +177,7 @@
     {
         np = list_entry(ent, struct net_private, list);
         if ( np->handle == handle )
-            return np->dev;
+            return np->netdev;
     }
     return NULL;
 }
@@ -710,7 +712,7 @@
 {
     struct net_private *np = netdev_priv(dev);
     np->user_state = UST_CLOSED;
-    netif_stop_queue(np->dev);
+    netif_stop_queue(dev);
     return 0;
 }
 
@@ -856,14 +858,14 @@
     /* Stop old i/f to prevent errors whilst we rebuild the state. */
     spin_lock_irq(&np->tx_lock);
     spin_lock(&np->rx_lock);
-    netif_stop_queue(np->dev);
+    netif_stop_queue(np->netdev);
     /* np->backend_state = BEST_DISCONNECTED; */
     spin_unlock(&np->rx_lock);
     spin_unlock_irq(&np->tx_lock);
     
     /* Free resources. */
     if(np->tx != NULL){
-        free_irq(np->irq, np->dev);
+        free_irq(np->irq, np->netdev);
         unbind_evtchn_from_irq(np->evtchn);
         free_page((unsigned long)np->tx);
         free_page((unsigned long)np->rx);
@@ -936,7 +938,7 @@
 vif_connect(
     struct net_private *np, netif_fe_interface_status_t *status)
 {
-    struct net_device *dev = np->dev;
+    struct net_device *dev = np->netdev;
     memcpy(dev->dev_addr, status->mac, ETH_ALEN);
     network_connect(dev, status);
     np->evtchn = status->evtchn;
@@ -953,7 +955,7 @@
  * @param val return parameter for created device
  * @return 0 on success, error code otherwise
  */
-static int create_netdev(int handle, struct net_device **val)
+static struct net_device * __init create_netdev(int handle, struct device *xdev)
 {
     int i, err = 0;
     struct net_device *dev = NULL;
@@ -995,15 +997,16 @@
         printk(KERN_WARNING "%s> register_netdev err=%d\n", __FUNCTION__, err);
         goto exit;
     }
-    np->dev = dev;
+    np->dev = xdev;
+    np->netdev = dev;
+    SET_MODULE_OWNER(dev);
+    SET_NETDEV_DEV(dev, xdev);
     list_add(&np->list, &dev_list);
 
   exit:
     if ( (err != 0) && (dev != NULL ) )
         kfree(dev);
-    else if ( val != NULL )
-        *val = dev;
-    return err;
+    return dev;
 }
 
 /* Get the target interface for a status message.
@@ -1036,13 +1039,6 @@
     if ( status->status == NETIF_INTERFACE_STATUS_CHANGED )
         goto exit;
 
-    /* It's a new interface in a good state - create it. */
-    DPRINTK("> create device...\n");
-    if ( (err = create_netdev(status->handle, &dev)) != 0 )
-        goto exit;
-
-    netctrl.interface_n++;
-
   exit:
     if ( np != NULL )
         *np = ((dev && !err) ? netdev_priv(dev) : NULL);
@@ -1056,8 +1052,8 @@
     int err = 0;
     struct net_private *np = NULL;
     
-    DPRINTK("> status=%s handle=%d\n",
-            status_name[status->status], status->handle);
+    DPRINTK("> status=%s handle=%d evtchn=%d\n",
+            status_name[status->status], status->handle, status->evtchn);
 
     if ( (err = target_vif(status, &np)) != 0 )
     {
@@ -1277,7 +1273,7 @@
     list_for_each ( ent, &dev_list )
     {
         np = list_entry(ent, struct net_private, list);
-        if ( np->dev == dev )
+        if ( np->netdev == dev )
             (void)send_fake_arp(dev);
     }
         
@@ -1291,6 +1287,28 @@
     .priority       = 0
 };
 
+static int xen_net_probe(struct xdev *xdev, const char * id) {
+    struct net_device *dev;
+    dev = create_netdev(xdev->handle, &xdev->dev);
+    if (dev == NULL) {
+        /* should remove the device here */
+        return 1;
+    } 
+
+    netctrl.interface_n++;
+    return 0;
+}
+
+static char netfront_driver_name[] = "xen_net";
+static char netfront_driver_type[] = "net";
+
+static struct xdriver xen_netfront_driver = {
+    .name        = (char *)netfront_driver_name,
+    .type = netfront_driver_type,
+    .probe = xen_net_probe,
+};
+
+
 static int __init netif_init(void)
 {
     int err = 0;
@@ -1306,18 +1324,14 @@
     (void)ctrl_if_register_receiver(CMSG_NETIF_FE, netif_ctrlif_rx,
                                     CALLBACK_IN_BLOCKING_CONTEXT);
     send_driver_status(1);
-    err = probe_interfaces();
-    if ( err )
-        ctrl_if_unregister_receiver(CMSG_NETIF_FE, netif_ctrlif_rx);
 
-    DPRINTK("< err=%d\n", err);
-    return err;
+    return x_register_driver(&xen_netfront_driver);
 }
 
 static void vif_suspend(struct net_private *np)
 {
     /* Avoid having tx/rx stuff happen until we're ready. */
-    free_irq(np->irq, np->dev);
+    free_irq(np->irq, np->netdev);
     unbind_evtchn_from_irq(np->evtchn);
 }
 
diff -Nru a/linux-2.6.10-xen-sparse/include/asm-xen/xbus.h b/linux-2.6.10-xen-sparse/include/asm-xen/xbus.h
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/linux-2.6.10-xen-sparse/include/asm-xen/xbus.h	2005-02-01 14:50:53 -05:00
@@ -0,0 +1,45 @@
+#ifndef _ASM_XBUS_H
+#define _ASM_XBUS_H
+
+#include <linux/config.h>
+#include <linux/device.h>
+
+struct xdev {
+    char * name;
+    char * type;
+
+    unsigned int irq;
+    unsigned int evtchn;
+    unsigned int handle;
+
+    struct device dev;
+};
+
+struct xdriver {
+    char * name;
+    char * type;
+    int (*probe) (struct xdev *dev, const char * id);
+    int (*remove) (struct xdev *dev);
+    unsigned long driver_data;
+
+    struct device_driver driver;
+};
+
+
+extern struct bus_type xbus_type;
+
+int xregister_driver(struct xdriver *xdrv);
+
+static inline struct xdev *to_xdev(struct device *dev)
+{
+	return container_of(dev, struct xdev, dev);
+}
+
+static inline struct xdriver *to_xdriver(struct device_driver *drv)
+{
+	return container_of(drv, struct xdriver, driver);
+}
+
+
+
+#endif

^ permalink raw reply	[relevance 5%]

* [PATCH 2/2] netfront skb padding
       [not found]     ` <200502081924.40908.jdmason@us.ibm.com>
@ 2005-02-09  1:58  6%   ` Jon Mason
  0 siblings, 0 replies; 200+ results
From: Jon Mason @ 2005-02-09  1:58 UTC (permalink / raw)
  To: Xen Mailing List

It appears that when alloc'ing a skb, it is bring padded by an arbitrarily 
(and excessive) long value.  The value for this padding really only needs to 
be 24.  24 = 14 for the ethernet header + 2 for the cache alignment + 4 for 
the CRC + 4 for the VLAN flags.

Tested on Xen 2.0.3 and linux 2.6.10 kernel.

Signed-off-by: Jon Mason <jdmason@us.ibm.com>
---

--- drivers/xen/netfront/netfront.c.new 2005-02-08 19:09:31.368834000 -0600
+++ drivers/xen/netfront/netfront.c 2005-02-08 19:09:24.738834000 -0600
@@ -50,6 +50,8 @@
 #include <asm-xen/balloon.h>
 #include <asm/page.h>
 
+#define NETFRONT_VERSION "1.1"
+
 #ifndef __GFP_NOWARN
 #define __GFP_NOWARN 0
 #endif
@@ -62,8 +64,11 @@
         skb_shinfo(_skb)->frag_list = NULL;           \
     } while (0)
 
-/* Allow headroom on each rx pkt for Ethernet header, alignment padding, ... */
-#define RX_HEADROOM 200
+/* 
+ * Allow headroom on each rx pkt for Ethernet header, alignment padding, 
+ * CRC, and VLAN 
+ */
+#define RX_HEADROOM ETH_HLEN + NET_IP_ALIGN + 8 
 
 /*
  * If the backend driver is pipelining transmit requests then we can be very
@@ -1248,7 +1253,8 @@ static int __init netif_init(void)
     if (xen_start_info.flags & SIF_INITDOMAIN)
         return 0;
 
-    IPRINTK("Initialising virtual ethernet driver.\n");
+    IPRINTK("Initialising virtual ethernet driver, version %s\n", 
+      NETFRONT_VERSION);
     INIT_LIST_HEAD(&dev_list);
     (void)register_inetaddr_notifier(&notifier_inetdev);
     netctrl_init();


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[relevance 6%]

* RE: [PATCH 2/2] netfront skb padding
@ 2005-02-09  2:12  0% Ian Pratt
  2005-02-09 17:17  0% ` Jon Mason
  0 siblings, 1 reply; 200+ results
From: Ian Pratt @ 2005-02-09  2:12 UTC (permalink / raw)
  To: Jon Mason, Xen Mailing List; +Cc: ian.pratt

 
> It appears that when alloc'ing a skb, it is bring padded by 
> an arbitrarily 
> (and excessive) long value.  The value for this padding 
> really only needs to 
> be 24.  24 = 14 for the ethernet header + 2 for the cache 
> alignment + 4 for 
> the CRC + 4 for the VLAN flags.

Given that we're allocating page sized buffers the current situation
doesn't cost us anything.

Infact, what happens if the packet gets encapsulated e.g. by etherip
etc? Is Linux smart enough to be able to put the extra headers on
in-place if there is enough head room?

If so, the current situation is positively better.

Ian

> Tested on Xen 2.0.3 and linux 2.6.10 kernel.
> 
> Signed-off-by: Jon Mason <jdmason@us.ibm.com>
> ---
> 
> --- drivers/xen/netfront/netfront.c.new 2005-02-08 
> 19:09:31.368834000 -0600
> +++ drivers/xen/netfront/netfront.c 2005-02-08 
> 19:09:24.738834000 -0600
> @@ -50,6 +50,8 @@
>  #include <asm-xen/balloon.h>
>  #include <asm/page.h>
>  
> +#define NETFRONT_VERSION "1.1"
> +
>  #ifndef __GFP_NOWARN
>  #define __GFP_NOWARN 0
>  #endif
> @@ -62,8 +64,11 @@
>          skb_shinfo(_skb)->frag_list = NULL;           \
>      } while (0)
>  
> -/* Allow headroom on each rx pkt for Ethernet header, 
> alignment padding, ... */
> -#define RX_HEADROOM 200
> +/* 
> + * Allow headroom on each rx pkt for Ethernet header, 
> alignment padding, 
> + * CRC, and VLAN 
> + */
> +#define RX_HEADROOM ETH_HLEN + NET_IP_ALIGN + 8 
>  
>  /*
>   * If the backend driver is pipelining transmit requests 
> then we can be very
> @@ -1248,7 +1253,8 @@ static int __init netif_init(void)
>      if (xen_start_info.flags & SIF_INITDOMAIN)
>          return 0;
>  
> -    IPRINTK("Initialising virtual ethernet driver.\n");
> +    IPRINTK("Initialising virtual ethernet driver, version %s\n", 
> +      NETFRONT_VERSION);
>      INIT_LIST_HEAD(&dev_list);
>      (void)register_inetaddr_notifier(&notifier_inetdev);
>      netctrl_init();
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from 
> real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xen-devel
> 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id\x14396&op=click

^ permalink raw reply	[relevance 0%]

* Re: Balloon driver
  @ 2005-02-09 12:53  5% ` Mark Williamson
  2005-02-10 22:24  0%   ` Matthieu PATOU
  2005-02-13 15:29  0%   ` Jan Kundrát
  0 siblings, 2 replies; 200+ results
From: Mark Williamson @ 2005-02-09 12:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Jean-Eric Cuendet

> I heard about the balloon driver but can't find doc on it...
> What's that?

It allows a domain to give some of its memory back to Xen.  This makes its 
memory footprint smaller.  The memory can then be used for other domains.  
The memory can be reclaimed later so domains can also grow.

To use the driver:
* In a domain, "cat <memory target> > /proc/xen/balloon"
* In domain zero use "xm balloon <dom> <memory target>

> Is there doc about it?

It's described in the user manual.

Cheers,
Mark


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[relevance 5%]

* Re: [PATCH 2/2] netfront skb padding
  2005-02-09  2:12  0% [PATCH 2/2] netfront skb padding Ian Pratt
@ 2005-02-09 17:17  0% ` Jon Mason
  0 siblings, 0 replies; 200+ results
From: Jon Mason @ 2005-02-09 17:17 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Pratt, ian.pratt

On Tuesday 08 February 2005 08:12 pm, Ian Pratt wrote:
> 
> > It appears that when alloc'ing a skb, it is bring padded by 
> > an arbitrarily 
> > (and excessive) long value.  The value for this padding 
> > really only needs to 
> > be 24.  24 = 14 for the ethernet header + 2 for the cache 
> > alignment + 4 for 
> > the CRC + 4 for the VLAN flags.
> 
> Given that we're allocating page sized buffers the current situation
> doesn't cost us anything.

Unless it starts using larger packets, e.g. Jumbo Frames (hint hint).  Then
the unnecessary room can be a problem, as the unnecessary pad could cause the
unnecessary allocation of an extra page.

> Infact, what happens if the packet gets encapsulated e.g. by etherip
> etc? Is Linux smart enough to be able to put the extra headers on
> in-place if there is enough head room?

I would assume that they would have to be there.

> If so, the current situation is positively better.
> 
> Ian
> 
> > Tested on Xen 2.0.3 and linux 2.6.10 kernel.
> > 
> > Signed-off-by: Jon Mason <jdmason@us.ibm.com>
> > ---
> > 
> > --- drivers/xen/netfront/netfront.c.new 2005-02-08 
> > 19:09:31.368834000 -0600
> > +++ drivers/xen/netfront/netfront.c 2005-02-08 
> > 19:09:24.738834000 -0600
> > @@ -50,6 +50,8 @@
> >  #include <asm-xen/balloon.h>
> >  #include <asm/page.h>
> >  
> > +#define NETFRONT_VERSION "1.1"
> > +
> >  #ifndef __GFP_NOWARN
> >  #define __GFP_NOWARN 0
> >  #endif
> > @@ -62,8 +64,11 @@
> >          skb_shinfo(_skb)->frag_list = NULL;           \
> >      } while (0)
> >  
> > -/* Allow headroom on each rx pkt for Ethernet header, 
> > alignment padding, ... */
> > -#define RX_HEADROOM 200
> > +/* 
> > + * Allow headroom on each rx pkt for Ethernet header, 
> > alignment padding, 
> > + * CRC, and VLAN 
> > + */
> > +#define RX_HEADROOM ETH_HLEN + NET_IP_ALIGN + 8 
> >  
> >  /*
> >   * If the backend driver is pipelining transmit requests 
> > then we can be very
> > @@ -1248,7 +1253,8 @@ static int __init netif_init(void)
> >      if (xen_start_info.flags & SIF_INITDOMAIN)
> >          return 0;
> >  
> > -    IPRINTK("Initialising virtual ethernet driver.\n");
> > +    IPRINTK("Initialising virtual ethernet driver, version %s\n", 
> > +      NETFRONT_VERSION);
> >      INIT_LIST_HEAD(&dev_list);
> >      (void)register_inetaddr_notifier(&notifier_inetdev);
> >      netctrl_init();
> > 
> > 
> > -------------------------------------------------------
> > SF email is sponsored by - The IT Product Guide
> > Read honest & candid reviews on hundreds of IT Products from 
> > real users.
> > Discover which products truly live up to the hype. Start reading now.
> > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/xen-devel
> > 
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_ide95&alloc_id\x14396&op=Click
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xen-devel
> 
> 

-- 
Jon Mason
jdmason@us.ibm.com


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[relevance 0%]

* [PATCH 1/2] netfront coding style clean-up (trivial)
         [not found]     ` <200502081924.40908.jdmason@us.ibm.com>
@ 2005-02-09 17:20  4% ` Jon Mason
  1 sibling, 0 replies; 200+ results
From: Jon Mason @ 2005-02-09 17:20 UTC (permalink / raw)
  To: Xen Mailing List

[-- Attachment #1: Type: text/plain, Size: 269 bytes --]

Resending, as it appears that the original didn't go out.


-----
My attempt at conforming netfront.c to the Linux Coding Style (according to 
Documentation/CodingStyle).

Patch attached (as it appears my spacing is off).

Signed-off-by: Jon Mason <jdmason@us.ibm.com>

[-- Attachment #2: netfront-1.patch --]
[-- Type: text/x-diff, Size: 23726 bytes --]

--- drivers/xen/netfront/netfront.c.orig	2005-02-08 16:17:59.000000000 -0600
+++ drivers/xen/netfront/netfront.c	2005-02-08 19:03:27.038834000 -0600
@@ -41,6 +41,8 @@
 #include <linux/bitops.h>
 #include <net/sock.h>
 #include <net/pkt_sched.h>
+#include <net/arp.h>
+#include <net/route.h>
 #include <asm/io.h>
 #include <asm-xen/evtchn.h>
 #include <asm-xen/ctrl_if.h>
@@ -48,11 +50,6 @@
 #include <asm-xen/balloon.h>
 #include <asm/page.h>
 
-#include <net/arp.h>
-#include <net/route.h>
-
-#define DEBUG 0
-
 #ifndef __GFP_NOWARN
 #define __GFP_NOWARN 0
 #endif
@@ -63,7 +60,7 @@
         atomic_set(&(skb_shinfo(_skb)->dataref), 1);  \
         skb_shinfo(_skb)->nr_frags = 0;               \
         skb_shinfo(_skb)->frag_list = NULL;           \
-    } while ( 0 )
+    } while (0)
 
 /* Allow headroom on each rx pkt for Ethernet header, alignment padding, ... */
 #define RX_HEADROOM 200
@@ -171,10 +168,9 @@ static struct net_device *find_dev_by_ha
 {
     struct list_head *ent;
     struct net_private *np;
-    list_for_each ( ent, &dev_list )
-    {
+    list_for_each (ent, &dev_list) {
         np = list_entry(ent, struct net_private, list);
-        if ( np->handle == handle )
+        if (np->handle == handle)
             return np->dev;
     }
     return NULL;
@@ -203,7 +199,7 @@ static void netctrl_init(void)
  */
 static int netctrl_err(int err)
 {
-    if ( (err < 0) && !netctrl.err )
+    if ((err < 0) && !netctrl.err)
         netctrl.err = err;
     return netctrl.err;
 }
@@ -216,9 +212,9 @@ static int netctrl_connected(void)
 {
     int ok;
 
-    if ( netctrl.err )
+    if (netctrl.err)
         ok = netctrl.err;
-    else if ( netctrl.up == NETIF_DRIVER_STATUS_UP )
+    else if (netctrl.up == NETIF_DRIVER_STATUS_UP)
         ok = (netctrl.connected_n == netctrl.interface_n);
     else
         ok = 0;
@@ -266,14 +262,14 @@ static int send_fake_arp(struct net_devi
     src_ip = inet_select_addr(dev, dst_ip, RT_SCOPE_LINK);
 
     /* No IP? Then nothing to do. */
-    if ( src_ip == 0 )
+    if (src_ip == 0)
         return 0;
 
     skb = arp_create(ARPOP_REPLY, ETH_P_ARP,
                      dst_ip, dev, src_ip,
                      /*dst_hw*/ NULL, /*src_hw*/ NULL, 
                      /*target_hw*/ dev->dev_addr);
-    if ( skb == NULL )
+    if (skb == NULL)
         return -ENOMEM;
 
     return dev_queue_xmit(skb);
@@ -302,15 +298,14 @@ static void network_tx_buf_gc(struct net
     struct net_private *np = netdev_priv(dev);
     struct sk_buff *skb;
 
-    if ( np->backend_state != BEST_CONNECTED )
+    if (np->backend_state != BEST_CONNECTED)
         return;
 
     do {
         prod = np->tx->resp_prod;
         rmb(); /* Ensure we see responses up to 'rp'. */
 
-        for ( i = np->tx_resp_cons; i != prod; i++ )
-        {
+        for (i = np->tx_resp_cons; i != prod; i++) {
             id  = np->tx->ring[MASK_NETIF_TX_IDX(i)].resp.id;
             skb = np->tx_skbs[id];
             ADD_ID_TO_FREELIST(np->tx_skbs, id);
@@ -330,14 +325,11 @@ static void network_tx_buf_gc(struct net
         np->tx->event = 
             prod + ((np->tx->req_prod - prod) >> 1) + 1;
         mb();
-    }
-    while ( prod != np->tx->resp_prod );
+    } while (prod != np->tx->resp_prod);
 
-    if ( np->tx_full && 
-         ((np->tx->req_prod - prod) < NETIF_TX_RING_SIZE) )
-    {
+    if (np->tx_full && ((np->tx->req_prod - prod) < NETIF_TX_RING_SIZE)) {
         np->tx_full = 0;
-        if ( np->user_state == UST_OPEN )
+        if (np->user_state == UST_OPEN)
             netif_wake_queue(dev);
     }
 }
@@ -351,7 +343,7 @@ static void network_alloc_rx_buffers(str
     int i, batch_target;
     NETIF_RING_IDX req_prod = np->rx->req_prod;
 
-    if ( unlikely(np->backend_state != BEST_CONNECTED) )
+    if (unlikely(np->backend_state != BEST_CONNECTED))
         return;
 
     /*
@@ -361,20 +353,18 @@ static void network_alloc_rx_buffers(str
      * ourself and for other kernel subsystems.
      */
     batch_target = np->rx_target - (req_prod - np->rx_resp_cons);
-    for ( i = skb_queue_len(&np->rx_batch); i < batch_target; i++ )
-    {
-        if ( unlikely((skb = alloc_xen_skb(dev->mtu + RX_HEADROOM)) == NULL) )
+    for (i = skb_queue_len(&np->rx_batch); i < batch_target; i++) {
+        if (unlikely((skb = alloc_xen_skb(dev->mtu + RX_HEADROOM)) == NULL))
             break;
         __skb_queue_tail(&np->rx_batch, skb);
     }
 
     /* Is the batch large enough to be worthwhile? */
-    if ( i < (np->rx_target/2)  )
+    if (i < (np->rx_target/2))
         return;
 
-    for ( i = 0; ; i++ )
-    {
-        if ( (skb = __skb_dequeue(&np->rx_batch)) == NULL )
+    for (i = 0; ; i++) {
+        if ((skb = __skb_dequeue(&np->rx_batch)) == NULL)
             break;
 
         skb->dev = dev;
@@ -421,15 +411,15 @@ static void network_alloc_rx_buffers(str
     (void)HYPERVISOR_multicall(rx_mcl, i+1);
 
     /* Check return status of HYPERVISOR_dom_mem_op(). */
-    if ( unlikely(rx_mcl[i].args[5] != i) )
+    if (unlikely(rx_mcl[i].args[5] != i))
         panic("Unable to reduce memory reservation\n");
 
     /* Above is a suitable barrier to ensure backend will see requests. */
     np->rx->req_prod = req_prod + i;
 
     /* Adjust our floating fill target if we risked running out of buffers. */
-    if ( ((req_prod - np->rx->resp_prod) < (np->rx_target / 4)) &&
-         ((np->rx_target *= 2) > RX_MAX_TARGET) )
+    if (((req_prod - np->rx->resp_prod) < (np->rx_target / 4)) &&
+         ((np->rx_target *= 2) > RX_MAX_TARGET))
         np->rx_target = RX_MAX_TARGET;
 }
 
@@ -441,18 +431,16 @@ static int network_start_xmit(struct sk_
     netif_tx_request_t *tx;
     NETIF_RING_IDX i;
 
-    if ( unlikely(np->tx_full) )
-    {
+    if (unlikely(np->tx_full)) {
         printk(KERN_ALERT "%s: full queue wasn't stopped!\n", dev->name);
         netif_stop_queue(dev);
         goto drop;
     }
 
-    if ( unlikely((((unsigned long)skb->data & ~PAGE_MASK) + skb->len) >=
-                  PAGE_SIZE) )
-    {
+    if (unlikely((((unsigned long)skb->data & ~PAGE_MASK) + skb->len) >=
+                  PAGE_SIZE)) {
         struct sk_buff *nskb;
-        if ( unlikely((nskb = alloc_xen_skb(skb->len)) == NULL) )
+        if (unlikely((nskb = alloc_xen_skb(skb->len)) == NULL))
             goto drop;
         skb_put(nskb, skb->len);
         memcpy(nskb->data, skb->data, skb->len);
@@ -463,8 +451,7 @@ static int network_start_xmit(struct sk_
     
     spin_lock_irq(&np->tx_lock);
 
-    if ( np->backend_state != BEST_CONNECTED )
-    {
+    if (np->backend_state != BEST_CONNECTED) {
         spin_unlock_irq(&np->tx_lock);
         goto drop;
     }
@@ -485,8 +472,7 @@ static int network_start_xmit(struct sk_
 
     network_tx_buf_gc(dev);
 
-    if ( (i - np->tx_resp_cons) == (NETIF_TX_RING_SIZE - 1) )
-    {
+    if ((i - np->tx_resp_cons) == (NETIF_TX_RING_SIZE - 1)) {
         np->tx_full = 1;
         netif_stop_queue(dev);
     }
@@ -498,7 +484,7 @@ static int network_start_xmit(struct sk_
 
     /* Only notify Xen if we really have to. */
     mb();
-    if ( np->tx->TX_TEST_IDX == i )
+    if (np->tx->TX_TEST_IDX == i)
         notify_via_evtchn(np->evtchn);
 
     return 0;
@@ -509,7 +495,6 @@ static int network_start_xmit(struct sk_
     return 0;
 }
 
-
 static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs)
 {
     struct net_device *dev = dev_id;
@@ -520,8 +505,7 @@ static irqreturn_t netif_int(int irq, vo
     network_tx_buf_gc(dev);
     spin_unlock_irqrestore(&np->tx_lock, flags);
 
-    if ( (np->rx_resp_cons != np->rx->resp_prod) &&
-         (np->user_state == UST_OPEN) )
+    if ((np->rx_resp_cons != np->rx->resp_prod) && (np->user_state == UST_OPEN))
         netif_rx_schedule(dev);
 
     return IRQ_HANDLED;
@@ -542,33 +526,30 @@ static int netif_poll(struct net_device 
 
     spin_lock(&np->rx_lock);
 
-    if ( np->backend_state != BEST_CONNECTED )
-    {
+    if (np->backend_state != BEST_CONNECTED) {
         spin_unlock(&np->rx_lock);
         return 0;
     }
 
     skb_queue_head_init(&rxq);
 
-    if ( (budget = *pbudget) > dev->quota )
+    if ((budget = *pbudget) > dev->quota)
         budget = dev->quota;
 
     rp = np->rx->resp_prod;
     rmb(); /* Ensure we see queued responses up to 'rp'. */
 
-    for ( i = np->rx_resp_cons, work_done = 0; 
-          (i != rp) && (work_done < budget); 
-          i++, work_done++ )
-    {
+    for (i = np->rx_resp_cons, work_done = 0; 
+		    (i != rp) && (work_done < budget);
+		    i++, work_done++) {
         rx = &np->rx->ring[MASK_NETIF_RX_IDX(i)].resp;
 
         /*
          * An error here is very odd. Usually indicates a backend bug,
          * low-memory condition, or that we didn't have reservation headroom.
          */
-        if ( unlikely(rx->status <= 0) )
-        {
-            if ( net_ratelimit() )
+        if (unlikely(rx->status <= 0)) {
+            if (net_ratelimit())
                 printk(KERN_WARNING "Bad rx buffer (memory squeeze?).\n");
             np->rx->ring[MASK_NETIF_RX_IDX(np->rx->req_prod)].req.id = rx->id;
             wmb();
@@ -608,8 +589,7 @@ static int netif_poll(struct net_device 
     balloon_update_driver_allowance(-work_done);
 
     /* Do all the remapping work, and M->P updates, in one big hypercall. */
-    if ( likely((mcl - rx_mcl) != 0) )
-    {
+    if (likely((mcl - rx_mcl) != 0)) {
         mcl->op = __HYPERVISOR_mmu_update;
         mcl->args[0] = (unsigned long)rx_mmu;
         mcl->args[1] = mmu - rx_mmu;
@@ -618,33 +598,29 @@ static int netif_poll(struct net_device 
         (void)HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl);
     }
 
-    while ( (skb = __skb_dequeue(&rxq)) != NULL )
-    {
+    while ((skb = __skb_dequeue(&rxq)) != NULL) {
         /*
          * Enough room in skbuff for the data we were passed? Also, Linux 
          * expects at least 16 bytes headroom in each receive buffer.
          */
-        if ( unlikely(skb->tail > skb->end) ||
-             unlikely((skb->data - skb->head) < 16) )
-        {
+        if (unlikely(skb->tail > skb->end) || 
+			unlikely((skb->data - skb->head) < 16)) {
             nskb = NULL;
 
             /* Only copy the packet if it fits in the current MTU. */
-            if ( skb->len <= (dev->mtu + ETH_HLEN) )
-            {
-                if ( (skb->tail > skb->end) && net_ratelimit() )
+            if (skb->len <= (dev->mtu + ETH_HLEN)) {
+                if ((skb->tail > skb->end) && net_ratelimit())
                     printk(KERN_INFO "Received packet needs %d bytes more "
                            "headroom.\n", skb->tail - skb->end);
 
-                if ( (nskb = alloc_xen_skb(skb->len + 2)) != NULL )
-                {
+                if ((nskb = alloc_xen_skb(skb->len + 2)) != NULL) {
                     skb_reserve(nskb, 2);
                     skb_put(nskb, skb->len);
                     memcpy(nskb->data, skb->data, skb->len);
                     nskb->dev = skb->dev;
                 }
             }
-            else if ( net_ratelimit() )
+            else if (net_ratelimit())
                 printk(KERN_INFO "Received packet too big for MTU "
                        "(%d > %d)\n", skb->len - ETH_HLEN, dev->mtu);
 
@@ -655,7 +631,7 @@ static int netif_poll(struct net_device 
             dev_kfree_skb(skb);
 
             /* Switch old for new, if we copied the buffer. */
-            if ( (skb = nskb) == NULL )
+            if ((skb = nskb) == NULL)
                 continue;
         }
         
@@ -674,8 +650,8 @@ static int netif_poll(struct net_device 
 
     /* If we get a callback with very few responses, reduce fill target. */
     /* NB. Note exponential increase, linear decrease. */
-    if ( ((np->rx->req_prod - np->rx->resp_prod) > ((3*np->rx_target) / 4)) &&
-         (--np->rx_target < RX_MIN_TARGET) )
+    if (((np->rx->req_prod - np->rx->resp_prod) > ((3*np->rx_target) / 4)) &&
+         (--np->rx_target < RX_MIN_TARGET))
         np->rx_target = RX_MIN_TARGET;
 
     network_alloc_rx_buffers(dev);
@@ -683,16 +659,14 @@ static int netif_poll(struct net_device 
     *pbudget   -= work_done;
     dev->quota -= work_done;
 
-    if ( work_done < budget )
-    {
+    if (work_done < budget) {
         local_irq_save(flags);
 
         np->rx->event = i + 1;
     
         /* Deal with hypervisor racing our resetting of rx_event. */
         mb();
-        if ( np->rx->resp_prod == i )
-        {
+        if (np->rx->resp_prod == i) {
             __netif_rx_complete(dev);
             more_to_do = 0;
         }
@@ -755,10 +729,8 @@ static void network_connect(struct net_d
      * to avoid this but maybe it doesn't matter so much given the
      * interface has been down.
      */
-    for ( requeue_idx = 0, i = 1; i <= NETIF_TX_RING_SIZE; i++ )
-    {
-            if ( (unsigned long)np->tx_skbs[i] >= __PAGE_OFFSET )
-            {
+    for (requeue_idx = 0, i = 1; i <= NETIF_TX_RING_SIZE; i++) {
+            if ((unsigned long)np->tx_skbs[i] >= __PAGE_OFFSET) {
                 struct sk_buff *skb = np->tx_skbs[i];
                 
                 tx = &np->tx->ring[requeue_idx++].req;
@@ -775,8 +747,8 @@ static void network_connect(struct net_d
     np->tx->req_prod = requeue_idx;
 
     /* Rebuild the RX buffer freelist and the RX ring itself. */
-    for ( requeue_idx = 0, i = 1; i <= NETIF_RX_RING_SIZE; i++ )
-        if ( (unsigned long)np->rx_skbs[i] >= __PAGE_OFFSET )
+    for (requeue_idx = 0, i = 1; i <= NETIF_RX_RING_SIZE; i++)
+        if ((unsigned long)np->rx_skbs[i] >= __PAGE_OFFSET)
             np->rx->ring[requeue_idx++].req.id = i;
     wmb();                
     np->rx->req_prod = requeue_idx;
@@ -791,7 +763,7 @@ static void network_connect(struct net_d
     notify_via_evtchn(status->evtchn);  
     network_tx_buf_gc(dev);
 
-    if ( np->user_state == UST_OPEN )
+    if (np->user_state == UST_OPEN)
         netif_start_queue(dev);
 
     spin_unlock(&np->rx_lock);
@@ -917,9 +889,7 @@ static void vif_disconnect(struct net_pr
  * is initiated by a special "RESET" message - disconnect could
  * just mean we're not allowed to use this interface any more.
  */
-static void 
-vif_reset(
-    struct net_private *np)
+static void vif_reset(struct net_private *np)
 {
     IPRINTK("Attempting to reconnect network interface: handle=%u\n",
             np->handle);    
@@ -932,9 +902,8 @@ vif_reset(
  * Sets the mac and event channel from the message.
  * Binds the irq to the event channel.
  */
-static void
-vif_connect(
-    struct net_private *np, netif_fe_interface_status_t *status)
+static void 
+vif_connect(struct net_private *np, netif_fe_interface_status_t *status)
 {
     struct net_device *dev = np->dev;
     memcpy(dev->dev_addr, status->mac, ETH_ALEN);
@@ -959,8 +928,7 @@ static int create_netdev(int handle, str
     struct net_device *dev = NULL;
     struct net_private *np = NULL;
 
-    if ( (dev = alloc_etherdev(sizeof(struct net_private))) == NULL )
-    {
+    if ((dev = alloc_etherdev(sizeof(struct net_private))) == NULL) {
         printk(KERN_WARNING "%s> alloc_etherdev failed.\n", __FUNCTION__);
         err = -ENOMEM;
         goto exit;
@@ -978,9 +946,9 @@ static int create_netdev(int handle, str
     np->rx_target = RX_MIN_TARGET;
 
     /* Initialise {tx,rx}_skbs to be a free chain containing every entry. */
-    for ( i = 0; i <= NETIF_TX_RING_SIZE; i++ )
+    for (i = 0; i <= NETIF_TX_RING_SIZE; i++)
         np->tx_skbs[i] = (void *)(i+1);
-    for ( i = 0; i <= NETIF_RX_RING_SIZE; i++ )
+    for (i = 0; i <= NETIF_RX_RING_SIZE; i++)
         np->rx_skbs[i] = (void *)(i+1);
 
     dev->open            = network_open;
@@ -990,8 +958,7 @@ static int create_netdev(int handle, str
     dev->poll            = netif_poll;
     dev->weight          = 64;
     
-    if ( (err = register_netdev(dev)) != 0 )
-    {
+    if ((err = register_netdev(dev)) != 0) {
         printk(KERN_WARNING "%s> register_netdev err=%d\n", __FUNCTION__, err);
         goto exit;
     }
@@ -999,9 +966,9 @@ static int create_netdev(int handle, str
     list_add(&np->list, &dev_list);
 
   exit:
-    if ( (err != 0) && (dev != NULL ) )
+    if ((err != 0) && (dev != NULL ))
         kfree(dev);
-    else if ( val != NULL )
+    else if (val != NULL)
         *val = dev;
     return err;
 }
@@ -1015,36 +982,34 @@ static int create_netdev(int handle, str
  * @return 0 on success, error code otherwise
  */
 static int 
-target_vif(
-    netif_fe_interface_status_t *status, struct net_private **np)
+target_vif(netif_fe_interface_status_t *status, struct net_private **np)
 {
     int err = 0;
     struct net_device *dev;
 
     DPRINTK("> handle=%d\n", status->handle);
-    if ( status->handle < 0 )
-    {
+    if (status->handle < 0) {
         err = -EINVAL;
         goto exit;
     }
 
-    if ( (dev = find_dev_by_handle(status->handle)) != NULL )
+    if ((dev = find_dev_by_handle(status->handle)) != NULL)
         goto exit;
 
-    if ( status->status == NETIF_INTERFACE_STATUS_CLOSED )
+    if (status->status == NETIF_INTERFACE_STATUS_CLOSED)
         goto exit;
-    if ( status->status == NETIF_INTERFACE_STATUS_CHANGED )
+    if (status->status == NETIF_INTERFACE_STATUS_CHANGED)
         goto exit;
 
     /* It's a new interface in a good state - create it. */
     DPRINTK("> create device...\n");
-    if ( (err = create_netdev(status->handle, &dev)) != 0 )
+    if ((err = create_netdev(status->handle, &dev)) != 0)
         goto exit;
 
     netctrl.interface_n++;
 
   exit:
-    if ( np != NULL )
+    if (np != NULL)
         *np = ((dev && !err) ? netdev_priv(dev) : NULL);
     DPRINTK("< err=%d\n", err);
     return err;
@@ -1059,23 +1024,19 @@ static void netif_interface_status(netif
     DPRINTK("> status=%s handle=%d\n",
             status_name[status->status], status->handle);
 
-    if ( (err = target_vif(status, &np)) != 0 )
-    {
+    if ((err = target_vif(status, &np)) != 0) {
         WPRINTK("Invalid netif: handle=%u\n", status->handle);
         return;
     }
 
-    if ( np == NULL )
-    {
+    if (np == NULL) {
         DPRINTK("> no vif\n");
         return;
     }
 
-    switch ( status->status )
-    {
+    switch (status->status) {
     case NETIF_INTERFACE_STATUS_CLOSED:
-        switch ( np->backend_state )
-        {
+        switch (np->backend_state) {
         case BEST_CLOSED:
         case BEST_DISCONNECTED:
         case BEST_CONNECTED:
@@ -1085,8 +1046,7 @@ static void netif_interface_status(netif
         break;
 
     case NETIF_INTERFACE_STATUS_DISCONNECTED:
-        switch ( np->backend_state )
-        {
+        switch (np->backend_state) {
         case BEST_CLOSED:
             vif_disconnect(np);
             break;
@@ -1098,8 +1058,7 @@ static void netif_interface_status(netif
         break;
 
     case NETIF_INTERFACE_STATUS_CONNECTED:
-        switch ( np->backend_state )
-        {
+        switch (np->backend_state) {
         case BEST_CLOSED:
             WPRINTK("Unexpected netif status %s in state %s\n",
                     status_name[status->status],
@@ -1141,20 +1100,17 @@ static void netif_driver_status(netif_fe
 static void netif_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
 {
 
-    switch ( msg->subtype )
-    {
+    switch (msg->subtype) {
     case CMSG_NETIF_FE_INTERFACE_STATUS:
-        if ( msg->length != sizeof(netif_fe_interface_status_t) )
+        if (msg->length != sizeof(netif_fe_interface_status_t))
             goto error;
-        netif_interface_status((netif_fe_interface_status_t *)
-                               &msg->msg[0]);
+        netif_interface_status((netif_fe_interface_status_t *) &msg->msg[0]);
         break;
 
     case CMSG_NETIF_FE_DRIVER_STATUS:
-        if ( msg->length != sizeof(netif_fe_driver_status_t) )
+        if (msg->length != sizeof(netif_fe_driver_status_t))
             goto error;
-        netif_driver_status((netif_fe_driver_status_t *)
-                            &msg->msg[0]);
+        netif_driver_status((netif_fe_driver_status_t *) &msg->msg[0]);
         break;
 
     error:
@@ -1179,8 +1135,7 @@ static int probe_interfaces(void)
 
     DPRINTK(">\n");
 
-    for ( wait_i = 0; wait_i < wait_n; wait_i++)
-    { 
+    for (wait_i = 0; wait_i < wait_n; wait_i++) { 
         DPRINTK("> wait_i=%d\n", wait_i);
         conn = netctrl_connected();
         if(conn) break;
@@ -1190,8 +1145,7 @@ static int probe_interfaces(void)
     }
 
     DPRINTK("> wait finished...\n");
-    if ( conn <= 0 )
-    {
+    if (conn <= 0) {
         err = netctrl_err(-ENETDOWN);
         WPRINTK("Failed to connect all virtual interfaces: err=%d\n", err);
     }
@@ -1223,8 +1177,7 @@ static int probe_interfaces(void)
     DPRINTK(">\n");
 
     netctrl.interface_n = 0;
-    for ( wait_i = 0; wait_i < wait_n; wait_i++ )
-    { 
+    for (wait_i = 0; wait_i < wait_n; wait_i++) { 
         DPRINTK("> wait_i=%d query=%d\n", wait_i, query);
         msg.handle = query;
         memcpy(cmsg.msg, &msg, sizeof(msg));
@@ -1236,7 +1189,7 @@ static int probe_interfaces(void)
         DPRINTK("> err=%d\n", err);
         if(err) goto exit;
         DPRINTK("> rmsg=%p msg=%p, reply=%p\n", &rmsg, rmsg.msg, reply);
-        if((int)reply->handle < 0){
+        if((int)reply->handle < 0) {
             // No more interfaces.
             break;
         }
@@ -1246,8 +1199,7 @@ static int probe_interfaces(void)
     }
 
   exit:
-    if ( err )
-    {
+    if (err) {
         err = netctrl_err(-ENETDOWN);
         WPRINTK("Connecting virtual network interfaces failed: err=%d\n", err);
     }
@@ -1262,22 +1214,20 @@ static int probe_interfaces(void)
  * We use this notifier to send out a fake ARP reply to reset switches and
  * router ARP caches when an IP interface is brought up on a VIF.
  */
-static int inetdev_notify(struct notifier_block *this, 
-                          unsigned long event, 
-                          void *ptr)
+static int 
+inetdev_notify(struct notifier_block *this, unsigned long event, void *ptr)
 {
     struct in_ifaddr  *ifa = (struct in_ifaddr *)ptr; 
     struct net_device *dev = ifa->ifa_dev->dev;
     struct list_head  *ent;
     struct net_private *np;
 
-    if ( event != NETDEV_UP )
+    if (event != NETDEV_UP)
         goto out;
 
-    list_for_each ( ent, &dev_list )
-    {
+    list_for_each (ent, &dev_list) {
         np = list_entry(ent, struct net_private, list);
-        if ( np->dev == dev )
+        if (np->dev == dev)
             (void)send_fake_arp(dev);
     }
         
@@ -1295,7 +1245,7 @@ static int __init netif_init(void)
 {
     int err = 0;
 
-    if ( xen_start_info.flags & SIF_INITDOMAIN )
+    if (xen_start_info.flags & SIF_INITDOMAIN)
         return 0;
 
     IPRINTK("Initialising virtual ethernet driver.\n");
@@ -1306,7 +1256,7 @@ static int __init netif_init(void)
                                     CALLBACK_IN_BLOCKING_CONTEXT);
     send_driver_status(1);
     err = probe_interfaces();
-    if ( err )
+    if (err)
         ctrl_if_unregister_receiver(CMSG_NETIF_FE, netif_ctrlif_rx);
 
     DPRINTK("< err=%d\n", err);
@@ -1338,8 +1288,7 @@ void netif_suspend(void)
     struct list_head *ent;
     struct net_private *np;
     
-    list_for_each ( ent, &dev_list )
-    {
+    list_for_each (ent, &dev_list) {
         np = list_entry(ent, struct net_private, list);
         vif_suspend(np);
     }
@@ -1350,8 +1299,7 @@ void netif_resume(void)
     struct list_head *ent;
     struct net_private *np;
 
-    list_for_each ( ent, &dev_list )
-    {
+    list_for_each (ent, &dev_list) {
         np = list_entry(ent, struct net_private, list);
         vif_resume(np);
     }

^ permalink raw reply	[relevance 4%]

* Re: Balloon driver
  2005-02-09 12:53  5% ` Mark Williamson
@ 2005-02-10 22:24  0%   ` Matthieu PATOU
  2005-02-13 15:29  0%   ` Jan Kundrát
  1 sibling, 0 replies; 200+ results
From: Matthieu PATOU @ 2005-02-10 22:24 UTC (permalink / raw)
  To: xen-devel


> > I heard about the balloon driver but can't find doc on it...
> > What's that?
> 
> It allows a domain to give some of its memory back to Xen.  This makes its 
> memory footprint smaller.  The memory can then be used for other domains.  
> The memory can be reclaimed later so domains can also grow.
> 
> To use the driver:
> * In a domain, "cat <memory target> > /proc/xen/balloon"
> * In domain zero use "xm balloon <dom> <memory target>
is it also avalaible to dom0, i mean does dom0 can also reduce/grow his memory ?


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[relevance 0%]

* Re: Balloon driver
  2005-02-13 15:29  0%   ` Jan Kundrát
@ 2005-02-13 15:26  0%     ` Mark Williamson
  0 siblings, 0 replies; 200+ results
From: Mark Williamson @ 2005-02-13 15:26 UTC (permalink / raw)
  To: Jan Kundrát; +Cc: Mark Williamson, xen-devel, Jean-Eric Cuendet

> Mark Williamson wrote:
> > * In a domain, "cat <memory target> > /proc/xen/balloon"
>
> Did you mean `echo`? ;-)

Oops, yes I did.  Guess I need to plug the coffee line back in!

Cheers,
Mark


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[relevance 0%]

* Re: Balloon driver
  2005-02-09 12:53  5% ` Mark Williamson
  2005-02-10 22:24  0%   ` Matthieu PATOU
@ 2005-02-13 15:29  0%   ` Jan Kundrát
  2005-02-13 15:26  0%     ` Mark Williamson
  1 sibling, 1 reply; 200+ results
From: Jan Kundrát @ 2005-02-13 15:29 UTC (permalink / raw)
  To: Mark Williamson; +Cc: xen-devel, Jean-Eric Cuendet

Mark Williamson wrote:
> * In a domain, "cat <memory target> > /proc/xen/balloon"

Did you mean `echo`? ;-)

-jkt

-- 
cd /local/pub && more beer > /dev/mouth


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[relevance 0%]

* DOM0 memory allocation
@ 2005-02-25 18:40  5% Keir Fraser
  0 siblings, 0 replies; 200+ results
From: Keir Fraser @ 2005-02-25 18:40 UTC (permalink / raw)
  To: xen-devel


In the unstable tree the default memory allocation for DOM0 is now
*all* available memory (rather than the somewhat underwhelming
previous default of 16MB).

This ought to be a much more useful default, but you must remember to
'balloon down' DOM0's memory reservation before creating new domains!
The interface file is /proc/xen/balloon.

 -- Keir


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[relevance 5%]

* RE: DOM0 memory allocation
@ 2005-02-26 18:47  0% Ian Pratt
  0 siblings, 0 replies; 200+ results
From: Ian Pratt @ 2005-02-26 18:47 UTC (permalink / raw)
  To: Keir Fraser, xen-devel; +Cc: ian.pratt

 

> In the unstable tree the default memory allocation for DOM0 is now
> *all* available memory (rather than the somewhat underwhelming
> previous default of 16MB).
> 
> This ought to be a much more useful default, but you must remember to
> 'balloon down' DOM0's memory reservation before creating new domains!
> The interface file is /proc/xen/balloon.

As well as the allocation for the domain, make sure you give Xen some
slack to play with when you begin starting domains. Xen's per-domain
memory requirements are normally very small (32KB), but when you start a
live-migration of a domain Xen will need memory to store shadow page
tables for the duration of the migration.

We really need to update the tools to autmoatically balloon down domain
0 and leave some approprite slack for Xen (e.g. maybe 16MB total for the
system by default). Volunteers? 

We also need to audit Xen's out of memory paths to make sure they're
handled appropriately. (The forthcoming shadow mode checkin should
handle that path rather better).

Ian



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id\x14396&op=click

^ permalink raw reply	[relevance 0%]

* Error compiling balloon.c - nightly testing tarball 1/3/05
@ 2005-03-01 21:51  6% Jerome Brown
  0 siblings, 0 replies; 200+ results
From: Jerome Brown @ 2005-03-01 21:51 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]

When compiling a 2.6.10-xen0 kernel I get the following error:

  CC      drivers/xen/balloon/balloon.o
drivers/xen/balloon/balloon.c: In function `balloon_process':
drivers/xen/balloon/balloon.c:209: error: `phys_to_machine_mapping'
undeclared (first use in this function)
drivers/xen/balloon/balloon.c:209: error: (Each undeclared identifier is
reported only once
drivers/xen/balloon/balloon.c:209: error: for each function it appears in.)
drivers/xen/balloon/balloon.c:209: error: `INVALID_P2M_ENTRY' undeclared
(first use in this function)
drivers/xen/balloon/balloon.c:253: warning: implicit declaration of
function `scrub_pages'
make[3]: *** [drivers/xen/balloon/balloon.o] Error 1
make[2]: *** [drivers/xen/balloon] Error 2
make[1]: *** [drivers/xen] Error 2
make: *** [drivers] Error 2

Attached is my .config file

Thanks in advance

-- 
Jerome Brown
Technology Architect
Hub.Net

P: +64  3 961-5116
M: +64 29 453 7663
F: +64  3 961-5129
E: jerome@hub.net.nz
W: http://www.hub.net.nz/
O: Level 4, 818 Colombo St, Christchurch, New Zealand
S: PO Box 1879, Christchurch, New Zealand

[-- Attachment #2: .config --]
[-- Type: text/plain, Size: 25114 bytes --]

#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.10-xen0
# Wed Mar  2 08:58:18 2005
#
CONFIG_XEN=y
CONFIG_ARCH_XEN=y
CONFIG_NO_IDLE_HZ=y

#
# XEN
#
CONFIG_XEN_PRIVILEGED_GUEST=y
CONFIG_XEN_PHYSDEV_ACCESS=y
CONFIG_XEN_BLKDEV_BACKEND=y
CONFIG_XEN_NETDEV_BACKEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
# CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
CONFIG_XEN_WRITABLE_PAGETABLES=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_X86=y
# CONFIG_X86_64 is not set
CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y

#
# Code maturity level options
#
CONFIG_EXPERIMENTAL=y
# CONFIG_CLEAN_COMPILE is not set
CONFIG_BROKEN=y
CONFIG_BROKEN_ON_SMP=y
CONFIG_LOCK_KERNEL=y

#
# General setup
#
CONFIG_LOCALVERSION=""
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
# CONFIG_POSIX_MQUEUE is not set
# CONFIG_BSD_PROCESS_ACCT is not set
CONFIG_SYSCTL=y
# CONFIG_AUDIT is not set
CONFIG_LOG_BUF_SHIFT=14
CONFIG_HOTPLUG=y
CONFIG_KOBJECT_UEVENT=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_EMBEDDED=y
# CONFIG_KALLSYMS is not set
CONFIG_FUTEX=y
CONFIG_EPOLL=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_SHMEM=y
CONFIG_CC_ALIGN_FUNCTIONS=0
CONFIG_CC_ALIGN_LABELS=0
CONFIG_CC_ALIGN_LOOPS=0
CONFIG_CC_ALIGN_JUMPS=0
# CONFIG_TINY_SHMEM is not set

#
# Loadable module support
#
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
# CONFIG_MODULE_FORCE_UNLOAD is not set
CONFIG_OBSOLETE_MODPARM=y
# CONFIG_MODVERSIONS is not set
# CONFIG_MODULE_SRCVERSION_ALL is not set
CONFIG_KMOD=y

#
# X86 Processor Configuration
#
CONFIG_XENARCH="i386"
CONFIG_MMU=y
CONFIG_UID16=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_IOMAP=y
# CONFIG_M386 is not set
# CONFIG_M486 is not set
# CONFIG_M586 is not set
# CONFIG_M586TSC is not set
# CONFIG_M586MMX is not set
# CONFIG_M686 is not set
# CONFIG_MPENTIUMII is not set
# CONFIG_MPENTIUMIII is not set
# CONFIG_MPENTIUMM is not set
# CONFIG_MPENTIUM4 is not set
# CONFIG_MK6 is not set
CONFIG_MK7=y
# CONFIG_MK8 is not set
# CONFIG_MCRUSOE is not set
# CONFIG_MEFFICEON is not set
# CONFIG_MWINCHIPC6 is not set
# CONFIG_MWINCHIP2 is not set
# CONFIG_MWINCHIP3D is not set
# CONFIG_MCYRIXIII is not set
# CONFIG_MVIAC3_2 is not set
# CONFIG_X86_GENERIC is not set
CONFIG_X86_CMPXCHG=y
CONFIG_X86_XADD=y
CONFIG_X86_L1_CACHE_SHIFT=6
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_X86_WP_WORKS_OK=y
CONFIG_X86_INVLPG=y
CONFIG_X86_BSWAP=y
CONFIG_X86_POPAD_OK=y
CONFIG_X86_GOOD_APIC=y
CONFIG_X86_INTEL_USERCOPY=y
CONFIG_X86_USE_PPRO_CHECKSUM=y
CONFIG_X86_USE_3DNOW=y
# CONFIG_HPET_TIMER is not set
# CONFIG_HPET_EMULATE_RTC is not set
# CONFIG_SMP is not set
CONFIG_PREEMPT=y
# CONFIG_MICROCODE is not set
CONFIG_X86_CPUID=y

#
# Firmware Drivers
#
# CONFIG_EDD is not set
CONFIG_NOHIGHMEM=y
# CONFIG_HIGHMEM4G is not set
CONFIG_MTRR=y
CONFIG_HAVE_DEC_LOCK=y
# CONFIG_REGPARM is not set

#
# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
#
CONFIG_PCI=y
CONFIG_PCI_DIRECT=y
CONFIG_PCI_LEGACY_PROC=y
# CONFIG_PCI_NAMES is not set
# CONFIG_ISA is not set
# CONFIG_MCA is not set
# CONFIG_SCx200 is not set

#
# PCCARD (PCMCIA/CardBus) support
#
# CONFIG_PCCARD is not set

#
# PC-card bridges
#

#
# PCI Hotplug Support
#
# CONFIG_HOTPLUG_PCI is not set

#
# Kernel hacking
#
# CONFIG_DEBUG_KERNEL is not set
CONFIG_EARLY_PRINTK=y
# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
# CONFIG_FRAME_POINTER is not set
CONFIG_4KSTACKS=y
CONFIG_GENERIC_HARDIRQS=y
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_X86_BIOS_REBOOT=y

#
# Executable file formats
#
CONFIG_BINFMT_ELF=y
# CONFIG_BINFMT_AOUT is not set
# CONFIG_BINFMT_MISC is not set

#
# Device Drivers
#

#
# Generic Driver Options
#
# CONFIG_STANDALONE is not set
CONFIG_PREVENT_FIRMWARE_BUILD=y
# CONFIG_FW_LOADER is not set

#
# Memory Technology Devices (MTD)
#
# CONFIG_MTD is not set

#
# Parallel port support
#
# CONFIG_PARPORT is not set

#
# Plug and Play support
#

#
# Block devices
#
CONFIG_BLK_DEV_FD=y
# CONFIG_BLK_CPQ_DA is not set
# CONFIG_BLK_CPQ_CISS_DA is not set
# CONFIG_BLK_DEV_DAC960 is not set
# CONFIG_BLK_DEV_UMEM is not set
CONFIG_BLK_DEV_LOOP=y
# CONFIG_BLK_DEV_CRYPTOLOOP is not set
# CONFIG_BLK_DEV_NBD is not set
# CONFIG_BLK_DEV_SX8 is not set
# CONFIG_BLK_DEV_UB is not set
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=4096
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=""
# CONFIG_LBD is not set
# CONFIG_CDROM_PKTCDVD is not set

#
# IO Schedulers
#
CONFIG_IOSCHED_NOOP=y
CONFIG_IOSCHED_AS=y
CONFIG_IOSCHED_DEADLINE=y
CONFIG_IOSCHED_CFQ=y

#
# ATA/ATAPI/MFM/RLL support
#
CONFIG_IDE=y
CONFIG_BLK_DEV_IDE=y

#
# Please see Documentation/ide.txt for help/info on IDE drives
#
# CONFIG_BLK_DEV_IDE_SATA is not set
# CONFIG_BLK_DEV_HD_IDE is not set
CONFIG_BLK_DEV_IDEDISK=y
# CONFIG_IDEDISK_MULTI_MODE is not set
CONFIG_BLK_DEV_IDECD=y
# CONFIG_BLK_DEV_IDETAPE is not set
# CONFIG_BLK_DEV_IDEFLOPPY is not set
# CONFIG_BLK_DEV_IDESCSI is not set
# CONFIG_IDE_TASK_IOCTL is not set

#
# IDE chipset support/bugfixes
#
CONFIG_IDE_GENERIC=y
# CONFIG_BLK_DEV_CMD640 is not set
CONFIG_BLK_DEV_IDEPCI=y
# CONFIG_IDEPCI_SHARE_IRQ is not set
# CONFIG_BLK_DEV_OFFBOARD is not set
CONFIG_BLK_DEV_GENERIC=y
# CONFIG_BLK_DEV_OPTI621 is not set
# CONFIG_BLK_DEV_RZ1000 is not set
CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
CONFIG_IDEDMA_PCI_AUTO=y
# CONFIG_IDEDMA_ONLYDISK is not set
# CONFIG_BLK_DEV_AEC62XX is not set
# CONFIG_BLK_DEV_ALI15X3 is not set
# CONFIG_BLK_DEV_AMD74XX is not set
# CONFIG_BLK_DEV_ATIIXP is not set
# CONFIG_BLK_DEV_CMD64X is not set
# CONFIG_BLK_DEV_TRIFLEX is not set
# CONFIG_BLK_DEV_CY82C693 is not set
# CONFIG_BLK_DEV_CS5520 is not set
# CONFIG_BLK_DEV_CS5530 is not set
# CONFIG_BLK_DEV_HPT34X is not set
# CONFIG_BLK_DEV_HPT366 is not set
# CONFIG_BLK_DEV_SC1200 is not set
# CONFIG_BLK_DEV_PIIX is not set
# CONFIG_BLK_DEV_NS87415 is not set
# CONFIG_BLK_DEV_PDC202XX_OLD is not set
# CONFIG_BLK_DEV_PDC202XX_NEW is not set
# CONFIG_BLK_DEV_SVWKS is not set
# CONFIG_BLK_DEV_SIIMAGE is not set
# CONFIG_BLK_DEV_SIS5513 is not set
# CONFIG_BLK_DEV_SLC90E66 is not set
# CONFIG_BLK_DEV_TRM290 is not set
CONFIG_BLK_DEV_VIA82CXXX=y
# CONFIG_IDE_ARM is not set
CONFIG_BLK_DEV_IDEDMA=y
# CONFIG_IDEDMA_IVB is not set
CONFIG_IDEDMA_AUTO=y
# CONFIG_BLK_DEV_HD is not set

#
# SCSI device support
#
CONFIG_SCSI=m
CONFIG_SCSI_PROC_FS=y

#
# SCSI support type (disk, tape, CD-ROM)
#
CONFIG_BLK_DEV_SD=m
# CONFIG_CHR_DEV_ST is not set
# CONFIG_CHR_DEV_OSST is not set
# CONFIG_BLK_DEV_SR is not set
# CONFIG_CHR_DEV_SG is not set

#
# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
#
# CONFIG_SCSI_MULTI_LUN is not set
# CONFIG_SCSI_CONSTANTS is not set
# CONFIG_SCSI_LOGGING is not set

#
# SCSI Transport Attributes
#
# CONFIG_SCSI_SPI_ATTRS is not set
# CONFIG_SCSI_FC_ATTRS is not set

#
# SCSI low-level drivers
#
CONFIG_BLK_DEV_3W_XXXX_RAID=m
# CONFIG_SCSI_3W_9XXX is not set
# CONFIG_SCSI_ACARD is not set
CONFIG_SCSI_AACRAID=m
CONFIG_SCSI_AIC7XXX=m
CONFIG_AIC7XXX_CMDS_PER_DEVICE=32
CONFIG_AIC7XXX_RESET_DELAY_MS=15000
CONFIG_AIC7XXX_DEBUG_ENABLE=y
CONFIG_AIC7XXX_DEBUG_MASK=0
CONFIG_AIC7XXX_REG_PRETTY_PRINT=y
# CONFIG_SCSI_AIC7XXX_OLD is not set
CONFIG_SCSI_AIC79XX=m
CONFIG_AIC79XX_CMDS_PER_DEVICE=32
CONFIG_AIC79XX_RESET_DELAY_MS=15000
# CONFIG_AIC79XX_ENABLE_RD_STRM is not set
CONFIG_AIC79XX_DEBUG_ENABLE=y
CONFIG_AIC79XX_DEBUG_MASK=0
CONFIG_AIC79XX_REG_PRETTY_PRINT=y
# CONFIG_SCSI_DPT_I2O is not set
# CONFIG_SCSI_ADVANSYS is not set
# CONFIG_MEGARAID_NEWGEN is not set
# CONFIG_MEGARAID_LEGACY is not set
CONFIG_SCSI_SATA=y
# CONFIG_SCSI_SATA_AHCI is not set
# CONFIG_SCSI_SATA_SVW is not set
CONFIG_SCSI_ATA_PIIX=y
# CONFIG_SCSI_SATA_NV is not set
CONFIG_SCSI_SATA_PROMISE=y
CONFIG_SCSI_SATA_SX4=y
CONFIG_SCSI_SATA_SIL=y
# CONFIG_SCSI_SATA_SIS is not set
# CONFIG_SCSI_SATA_ULI is not set
# CONFIG_SCSI_SATA_VIA is not set
# CONFIG_SCSI_SATA_VITESSE is not set
CONFIG_SCSI_BUSLOGIC=m
# CONFIG_SCSI_OMIT_FLASHPOINT is not set
# CONFIG_SCSI_CPQFCTS is not set
# CONFIG_SCSI_DMX3191D is not set
# CONFIG_SCSI_EATA is not set
# CONFIG_SCSI_EATA_PIO is not set
# CONFIG_SCSI_FUTURE_DOMAIN is not set
# CONFIG_SCSI_GDTH is not set
# CONFIG_SCSI_IPS is not set
# CONFIG_SCSI_INITIO is not set
# CONFIG_SCSI_INIA100 is not set
# CONFIG_SCSI_SYM53C8XX_2 is not set
# CONFIG_SCSI_IPR is not set
# CONFIG_SCSI_PCI2000 is not set
# CONFIG_SCSI_PCI2220I is not set
# CONFIG_SCSI_QLOGIC_ISP is not set
# CONFIG_SCSI_QLOGIC_FC is not set
# CONFIG_SCSI_QLOGIC_1280 is not set
CONFIG_SCSI_QLA2XXX=m
# CONFIG_SCSI_QLA21XX is not set
# CONFIG_SCSI_QLA22XX is not set
# CONFIG_SCSI_QLA2300 is not set
# CONFIG_SCSI_QLA2322 is not set
# CONFIG_SCSI_QLA6312 is not set
# CONFIG_SCSI_QLA6322 is not set
# CONFIG_SCSI_DC395x is not set
# CONFIG_SCSI_DC390T is not set
# CONFIG_SCSI_NSP32 is not set
# CONFIG_SCSI_DEBUG is not set

#
# Multi-device support (RAID and LVM)
#
CONFIG_MD=y
CONFIG_BLK_DEV_MD=y
# CONFIG_MD_LINEAR is not set
CONFIG_MD_RAID0=y
CONFIG_MD_RAID1=y
# CONFIG_MD_RAID10 is not set
# CONFIG_MD_RAID5 is not set
# CONFIG_MD_RAID6 is not set
# CONFIG_MD_MULTIPATH is not set
# CONFIG_MD_FAULTY is not set
CONFIG_BLK_DEV_DM=y
# CONFIG_DM_CRYPT is not set
CONFIG_DM_SNAPSHOT=y
CONFIG_DM_MIRROR=y
# CONFIG_DM_ZERO is not set

#
# Fusion MPT device support
#
# CONFIG_FUSION is not set

#
# IEEE 1394 (FireWire) support
#
CONFIG_IEEE1394=m

#
# Subsystem Options
#
# CONFIG_IEEE1394_VERBOSEDEBUG is not set
# CONFIG_IEEE1394_OUI_DB is not set
# CONFIG_IEEE1394_EXTRA_CONFIG_ROMS is not set

#
# Device Drivers
#

#
# Texas Instruments PCILynx requires I2C
#
CONFIG_IEEE1394_OHCI1394=m

#
# Protocol Drivers
#
CONFIG_IEEE1394_VIDEO1394=m
# CONFIG_IEEE1394_SBP2 is not set
# CONFIG_IEEE1394_ETH1394 is not set
CONFIG_IEEE1394_DV1394=m
CONFIG_IEEE1394_RAWIO=m
# CONFIG_IEEE1394_CMP is not set

#
# I2O device support
#
# CONFIG_I2O is not set

#
# Networking support
#
CONFIG_NET=y

#
# Networking options
#
CONFIG_PACKET=y
# CONFIG_PACKET_MMAP is not set
# CONFIG_NETLINK_DEV is not set
CONFIG_UNIX=y
# CONFIG_NET_KEY is not set
CONFIG_INET=y
# CONFIG_IP_MULTICAST is not set
# CONFIG_IP_ADVANCED_ROUTER is not set
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
# CONFIG_IP_PNP_BOOTP is not set
# CONFIG_IP_PNP_RARP is not set
# CONFIG_NET_IPIP is not set
# CONFIG_NET_IPGRE is not set
# CONFIG_ARPD is not set
# CONFIG_SYN_COOKIES is not set
# CONFIG_INET_AH is not set
# CONFIG_INET_ESP is not set
# CONFIG_INET_IPCOMP is not set
# CONFIG_INET_TUNNEL is not set
CONFIG_IP_TCPDIAG=y
CONFIG_IP_TCPDIAG_IPV6=y

#
# IP: Virtual Server Configuration
#
# CONFIG_IP_VS is not set
CONFIG_IPV6=y
# CONFIG_IPV6_PRIVACY is not set
# CONFIG_INET6_AH is not set
# CONFIG_INET6_ESP is not set
# CONFIG_INET6_IPCOMP is not set
# CONFIG_INET6_TUNNEL is not set
# CONFIG_IPV6_TUNNEL is not set
CONFIG_NETFILTER=y
# CONFIG_NETFILTER_DEBUG is not set
CONFIG_BRIDGE_NETFILTER=y

#
# IP: Netfilter Configuration
#
CONFIG_IP_NF_CONNTRACK=m
CONFIG_IP_NF_CT_ACCT=y
# CONFIG_IP_NF_CONNTRACK_MARK is not set
# CONFIG_IP_NF_CT_PROTO_SCTP is not set
CONFIG_IP_NF_FTP=m
# CONFIG_IP_NF_IRC is not set
# CONFIG_IP_NF_TFTP is not set
# CONFIG_IP_NF_AMANDA is not set
# CONFIG_IP_NF_QUEUE is not set
CONFIG_IP_NF_IPTABLES=m
# CONFIG_IP_NF_MATCH_LIMIT is not set
CONFIG_IP_NF_MATCH_IPRANGE=m
# CONFIG_IP_NF_MATCH_MAC is not set
# CONFIG_IP_NF_MATCH_PKTTYPE is not set
# CONFIG_IP_NF_MATCH_MARK is not set
# CONFIG_IP_NF_MATCH_MULTIPORT is not set
# CONFIG_IP_NF_MATCH_TOS is not set
# CONFIG_IP_NF_MATCH_RECENT is not set
# CONFIG_IP_NF_MATCH_ECN is not set
# CONFIG_IP_NF_MATCH_DSCP is not set
# CONFIG_IP_NF_MATCH_AH_ESP is not set
# CONFIG_IP_NF_MATCH_LENGTH is not set
# CONFIG_IP_NF_MATCH_TTL is not set
# CONFIG_IP_NF_MATCH_TCPMSS is not set
# CONFIG_IP_NF_MATCH_HELPER is not set
# CONFIG_IP_NF_MATCH_STATE is not set
# CONFIG_IP_NF_MATCH_CONNTRACK is not set
# CONFIG_IP_NF_MATCH_OWNER is not set
# CONFIG_IP_NF_MATCH_PHYSDEV is not set
# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
# CONFIG_IP_NF_MATCH_REALM is not set
# CONFIG_IP_NF_MATCH_SCTP is not set
# CONFIG_IP_NF_MATCH_COMMENT is not set
# CONFIG_IP_NF_MATCH_HASHLIMIT is not set
CONFIG_IP_NF_FILTER=m
CONFIG_IP_NF_TARGET_REJECT=m
# CONFIG_IP_NF_TARGET_LOG is not set
# CONFIG_IP_NF_TARGET_ULOG is not set
# CONFIG_IP_NF_TARGET_TCPMSS is not set
CONFIG_IP_NF_NAT=m
CONFIG_IP_NF_NAT_NEEDED=y
CONFIG_IP_NF_TARGET_MASQUERADE=m
# CONFIG_IP_NF_TARGET_REDIRECT is not set
# CONFIG_IP_NF_TARGET_NETMAP is not set
# CONFIG_IP_NF_TARGET_SAME is not set
# CONFIG_IP_NF_NAT_LOCAL is not set
# CONFIG_IP_NF_NAT_SNMP_BASIC is not set
CONFIG_IP_NF_NAT_FTP=m
# CONFIG_IP_NF_MANGLE is not set
# CONFIG_IP_NF_RAW is not set
# CONFIG_IP_NF_ARPTABLES is not set
# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
# CONFIG_IP_NF_COMPAT_IPFWADM is not set

#
# IPv6: Netfilter Configuration
#
# CONFIG_IP6_NF_QUEUE is not set
# CONFIG_IP6_NF_IPTABLES is not set

#
# Bridge: Netfilter Configuration
#
# CONFIG_BRIDGE_NF_EBTABLES is not set

#
# SCTP Configuration (EXPERIMENTAL)
#
# CONFIG_IP_SCTP is not set
# CONFIG_ATM is not set
CONFIG_BRIDGE=y
# CONFIG_VLAN_8021Q is not set
# CONFIG_DECNET is not set
# CONFIG_LLC2 is not set
# CONFIG_IPX is not set
# CONFIG_ATALK is not set
# CONFIG_X25 is not set
# CONFIG_LAPB is not set
# CONFIG_NET_DIVERT is not set
# CONFIG_ECONET is not set
# CONFIG_WAN_ROUTER is not set

#
# QoS and/or fair queueing
#
# CONFIG_NET_SCHED is not set
# CONFIG_NET_CLS_ROUTE is not set

#
# Network testing
#
# CONFIG_NET_PKTGEN is not set
# CONFIG_NETPOLL is not set
# CONFIG_NET_POLL_CONTROLLER is not set
# CONFIG_HAMRADIO is not set
# CONFIG_IRDA is not set
# CONFIG_BT is not set
CONFIG_NETDEVICES=y
# CONFIG_DUMMY is not set
# CONFIG_BONDING is not set
# CONFIG_EQUALIZER is not set
# CONFIG_TUN is not set

#
# ARCnet devices
#
# CONFIG_ARCNET is not set

#
# Ethernet (10 or 100Mbit)
#
CONFIG_NET_ETHERNET=y
CONFIG_MII=y
# CONFIG_HAPPYMEAL is not set
# CONFIG_SUNGEM is not set
# CONFIG_NET_VENDOR_3COM is not set

#
# Tulip family network device support
#
CONFIG_NET_TULIP=y
# CONFIG_DE2104X is not set
CONFIG_TULIP=y
# CONFIG_TULIP_MWI is not set
# CONFIG_TULIP_MMIO is not set
# CONFIG_TULIP_NAPI is not set
# CONFIG_DE4X5 is not set
# CONFIG_WINBOND_840 is not set
# CONFIG_DM9102 is not set
# CONFIG_HP100 is not set
CONFIG_NET_PCI=y
# CONFIG_PCNET32 is not set
# CONFIG_AMD8111_ETH is not set
# CONFIG_ADAPTEC_STARFIRE is not set
# CONFIG_B44 is not set
# CONFIG_FORCEDETH is not set
# CONFIG_DGRS is not set
# CONFIG_EEPRO100 is not set
# CONFIG_E100 is not set
# CONFIG_FEALNX is not set
# CONFIG_NATSEMI is not set
# CONFIG_NE2K_PCI is not set
# CONFIG_8139CP is not set
CONFIG_8139TOO=y
CONFIG_8139TOO_PIO=y
# CONFIG_8139TOO_TUNE_TWISTER is not set
# CONFIG_8139TOO_8129 is not set
# CONFIG_8139_OLD_RX_RESET is not set
# CONFIG_SIS900 is not set
# CONFIG_EPIC100 is not set
# CONFIG_SUNDANCE is not set
# CONFIG_TLAN is not set
# CONFIG_VIA_RHINE is not set

#
# Ethernet (1000 Mbit)
#
CONFIG_ACENIC=y
# CONFIG_ACENIC_OMIT_TIGON_I is not set
# CONFIG_DL2K is not set
CONFIG_E1000=y
# CONFIG_E1000_NAPI is not set
# CONFIG_NS83820 is not set
# CONFIG_HAMACHI is not set
# CONFIG_YELLOWFIN is not set
# CONFIG_R8169 is not set
# CONFIG_SK98LIN is not set
# CONFIG_VIA_VELOCITY is not set
CONFIG_TIGON3=y

#
# Ethernet (10000 Mbit)
#
# CONFIG_IXGB is not set
# CONFIG_S2IO is not set

#
# Token Ring devices
#
# CONFIG_TR is not set

#
# Wireless LAN (non-hamradio)
#
# CONFIG_NET_RADIO is not set

#
# Wan interfaces
#
# CONFIG_WAN is not set
# CONFIG_FDDI is not set
# CONFIG_HIPPI is not set
# CONFIG_PPP is not set
# CONFIG_SLIP is not set
# CONFIG_NET_FC is not set
CONFIG_SHAPER=y
# CONFIG_NETCONSOLE is not set

#
# ISDN subsystem
#
# CONFIG_ISDN is not set

#
# Telephony Support
#
# CONFIG_PHONE is not set

#
# Input device support
#
CONFIG_INPUT=y

#
# Userland interfaces
#
CONFIG_INPUT_MOUSEDEV=y
CONFIG_INPUT_MOUSEDEV_PSAUX=y
CONFIG_INPUT_MOUSEDEV_SCREEN_X=1280
CONFIG_INPUT_MOUSEDEV_SCREEN_Y=1024
# CONFIG_INPUT_JOYDEV is not set
# CONFIG_INPUT_TSDEV is not set
# CONFIG_INPUT_EVDEV is not set
# CONFIG_INPUT_EVBUG is not set

#
# Input I/O drivers
#
# CONFIG_GAMEPORT is not set
CONFIG_SOUND_GAMEPORT=y
# CONFIG_SERIO is not set
# CONFIG_SERIO_I8042 is not set

#
# Input Device Drivers
#
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_INPUT_JOYSTICK is not set
# CONFIG_INPUT_TOUCHSCREEN is not set
# CONFIG_INPUT_MISC is not set

#
# Character devices
#
CONFIG_VT=y
CONFIG_VT_CONSOLE=y
CONFIG_HW_CONSOLE=y
# CONFIG_SERIAL_NONSTANDARD is not set

#
# Serial drivers
#
# CONFIG_SERIAL_8250 is not set

#
# Non-8250 serial port support
#
CONFIG_UNIX98_PTYS=y
# CONFIG_LEGACY_PTYS is not set

#
# IPMI
#
# CONFIG_IPMI_HANDLER is not set

#
# Watchdog Cards
#
# CONFIG_WATCHDOG is not set
# CONFIG_HW_RANDOM is not set
# CONFIG_NVRAM is not set
CONFIG_RTC=y
# CONFIG_DTLK is not set
# CONFIG_R3964 is not set
# CONFIG_APPLICOM is not set
# CONFIG_SONYPI is not set

#
# Ftape, the floppy tape device driver
#
# CONFIG_FTAPE is not set
CONFIG_AGP=y
# CONFIG_AGP_ALI is not set
# CONFIG_AGP_ATI is not set
# CONFIG_AGP_AMD is not set
# CONFIG_AGP_AMD64 is not set
# CONFIG_AGP_INTEL is not set
# CONFIG_AGP_INTEL_MCH is not set
# CONFIG_AGP_NVIDIA is not set
# CONFIG_AGP_SIS is not set
# CONFIG_AGP_SWORKS is not set
CONFIG_AGP_VIA=y
# CONFIG_AGP_EFFICEON is not set
# CONFIG_DRM is not set
# CONFIG_DRM_I830 is not set
# CONFIG_DRM_I915 is not set
# CONFIG_MWAVE is not set
# CONFIG_RAW_DRIVER is not set
# CONFIG_HANGCHECK_TIMER is not set

#
# I2C support
#
# CONFIG_I2C is not set

#
# Dallas's 1-wire bus
#
# CONFIG_W1 is not set

#
# Misc devices
#
# CONFIG_IBM_ASM is not set

#
# Multimedia devices
#
# CONFIG_VIDEO_DEV is not set

#
# Digital Video Broadcasting Devices
#
# CONFIG_DVB is not set

#
# Graphics support
#
# CONFIG_FB is not set
# CONFIG_VIDEO_SELECT is not set

#
# Console display driver support
#
CONFIG_VGA_CONSOLE=y
CONFIG_DUMMY_CONSOLE=y

#
# Sound
#
# CONFIG_SOUND is not set

#
# USB support
#
CONFIG_USB=y
# CONFIG_USB_DEBUG is not set

#
# Miscellaneous USB options
#
CONFIG_USB_DEVICEFS=y
# CONFIG_USB_BANDWIDTH is not set
# CONFIG_USB_DYNAMIC_MINORS is not set
# CONFIG_USB_OTG is not set
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB_ARCH_HAS_OHCI=y

#
# USB Host Controller Drivers
#
CONFIG_USB_EHCI_HCD=y
# CONFIG_USB_EHCI_SPLIT_ISO is not set
# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
# CONFIG_USB_OHCI_HCD is not set
CONFIG_USB_UHCI_HCD=y
# CONFIG_USB_SL811_HCD is not set

#
# USB Device Class drivers
#
# CONFIG_USB_BLUETOOTH_TTY is not set
# CONFIG_USB_ACM is not set
CONFIG_USB_PRINTER=y

#
# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
#
CONFIG_USB_STORAGE=m
# CONFIG_USB_STORAGE_DEBUG is not set
CONFIG_USB_STORAGE_RW_DETECT=y
# CONFIG_USB_STORAGE_DATAFAB is not set
# CONFIG_USB_STORAGE_FREECOM is not set
# CONFIG_USB_STORAGE_ISD200 is not set
# CONFIG_USB_STORAGE_DPCM is not set
# CONFIG_USB_STORAGE_HP8200e is not set
# CONFIG_USB_STORAGE_SDDR09 is not set
# CONFIG_USB_STORAGE_SDDR55 is not set
# CONFIG_USB_STORAGE_JUMPSHOT is not set

#
# USB Input Devices
#
CONFIG_USB_HID=y
CONFIG_USB_HIDINPUT=y
# CONFIG_HID_FF is not set
# CONFIG_USB_HIDDEV is not set
# CONFIG_USB_AIPTEK is not set
# CONFIG_USB_WACOM is not set
# CONFIG_USB_KBTAB is not set
# CONFIG_USB_POWERMATE is not set
# CONFIG_USB_MTOUCH is not set
# CONFIG_USB_EGALAX is not set
# CONFIG_USB_XPAD is not set
# CONFIG_USB_ATI_REMOTE is not set

#
# USB Imaging devices
#
# CONFIG_USB_MDC800 is not set
# CONFIG_USB_MICROTEK is not set
# CONFIG_USB_HPUSBSCSI is not set

#
# USB Multimedia devices
#
# CONFIG_USB_DABUSB is not set

#
# Video4Linux support is needed for USB Multimedia device support
#

#
# USB Network Adapters
#
# CONFIG_USB_CATC is not set
# CONFIG_USB_KAWETH is not set
# CONFIG_USB_PEGASUS is not set
# CONFIG_USB_RTL8150 is not set
# CONFIG_USB_USBNET is not set

#
# USB port drivers
#

#
# USB Serial Converter support
#
# CONFIG_USB_SERIAL is not set

#
# USB Miscellaneous drivers
#
# CONFIG_USB_EMI62 is not set
# CONFIG_USB_EMI26 is not set
# CONFIG_USB_TIGL is not set
# CONFIG_USB_AUERSWALD is not set
# CONFIG_USB_RIO500 is not set
# CONFIG_USB_LEGOTOWER is not set
# CONFIG_USB_LCD is not set
# CONFIG_USB_LED is not set
# CONFIG_USB_CYTHERM is not set
# CONFIG_USB_PHIDGETKIT is not set
# CONFIG_USB_PHIDGETSERVO is not set
# CONFIG_USB_TEST is not set

#
# USB ATM/DSL drivers
#

#
# USB Gadget Support
#
# CONFIG_USB_GADGET is not set

#
# File systems
#
CONFIG_EXT2_FS=y
# CONFIG_EXT2_FS_XATTR is not set
# CONFIG_EXT3_FS is not set
# CONFIG_JBD is not set
CONFIG_REISERFS_FS=y
# CONFIG_REISERFS_CHECK is not set
# CONFIG_REISERFS_PROC_INFO is not set
# CONFIG_REISERFS_FS_XATTR is not set
# CONFIG_JFS_FS is not set
CONFIG_XFS_FS=y
# CONFIG_XFS_RT is not set
CONFIG_XFS_QUOTA=y
# CONFIG_XFS_SECURITY is not set
# CONFIG_XFS_POSIX_ACL is not set
# CONFIG_MINIX_FS is not set
# CONFIG_ROMFS_FS is not set
CONFIG_QUOTA=y
# CONFIG_QFMT_V1 is not set
CONFIG_QFMT_V2=y
CONFIG_QUOTACTL=y
CONFIG_DNOTIFY=y
# CONFIG_AUTOFS_FS is not set
# CONFIG_AUTOFS4_FS is not set

#
# CD-ROM/DVD Filesystems
#
CONFIG_ISO9660_FS=y
CONFIG_JOLIET=y
CONFIG_ZISOFS=y
CONFIG_ZISOFS_FS=y
# CONFIG_UDF_FS is not set

#
# DOS/FAT/NT Filesystems
#
CONFIG_FAT_FS=m
CONFIG_MSDOS_FS=m
CONFIG_VFAT_FS=m
CONFIG_FAT_DEFAULT_CODEPAGE=437
CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
# CONFIG_NTFS_FS is not set

#
# Pseudo filesystems
#
CONFIG_PROC_FS=y
CONFIG_PROC_KCORE=y
CONFIG_SYSFS=y
# CONFIG_DEVFS_FS is not set
# CONFIG_DEVPTS_FS_XATTR is not set
CONFIG_TMPFS=y
# CONFIG_TMPFS_XATTR is not set
# CONFIG_HUGETLBFS is not set
# CONFIG_HUGETLB_PAGE is not set
CONFIG_RAMFS=y

#
# Miscellaneous filesystems
#
# CONFIG_ADFS_FS is not set
# CONFIG_AFFS_FS is not set
# CONFIG_HFS_FS is not set
# CONFIG_HFSPLUS_FS is not set
# CONFIG_BEFS_FS is not set
# CONFIG_BFS_FS is not set
# CONFIG_EFS_FS is not set
# CONFIG_CRAMFS is not set
# CONFIG_VXFS_FS is not set
# CONFIG_HPFS_FS is not set
# CONFIG_QNX4FS_FS is not set
# CONFIG_SYSV_FS is not set
# CONFIG_UFS_FS is not set

#
# Network File Systems
#
CONFIG_NFS_FS=y
CONFIG_NFS_V3=y
# CONFIG_NFS_V4 is not set
# CONFIG_NFS_DIRECTIO is not set
CONFIG_NFSD=m
CONFIG_NFSD_V3=y
# CONFIG_NFSD_V4 is not set
CONFIG_NFSD_TCP=y
# CONFIG_ROOT_NFS is not set
CONFIG_LOCKD=y
CONFIG_LOCKD_V4=y
CONFIG_EXPORTFS=m
CONFIG_SUNRPC=y
# CONFIG_RPCSEC_GSS_KRB5 is not set
# CONFIG_RPCSEC_GSS_SPKM3 is not set
CONFIG_SMB_FS=y
# CONFIG_SMB_NLS_DEFAULT is not set
CONFIG_CIFS=y
# CONFIG_CIFS_STATS is not set
# CONFIG_CIFS_XATTR is not set
# CONFIG_CIFS_EXPERIMENTAL is not set
# CONFIG_NCP_FS is not set
# CONFIG_CODA_FS is not set
# CONFIG_AFS_FS is not set

#
# Partition Types
#
# CONFIG_PARTITION_ADVANCED is not set
CONFIG_MSDOS_PARTITION=y

#
# Native Language Support
#
CONFIG_NLS=y
CONFIG_NLS_DEFAULT="UTF-8"
CONFIG_NLS_CODEPAGE_437=y
# CONFIG_NLS_CODEPAGE_737 is not set
# CONFIG_NLS_CODEPAGE_775 is not set
# CONFIG_NLS_CODEPAGE_850 is not set
# CONFIG_NLS_CODEPAGE_852 is not set
# CONFIG_NLS_CODEPAGE_855 is not set
# CONFIG_NLS_CODEPAGE_857 is not set
# CONFIG_NLS_CODEPAGE_860 is not set
# CONFIG_NLS_CODEPAGE_861 is not set
# CONFIG_NLS_CODEPAGE_862 is not set
# CONFIG_NLS_CODEPAGE_863 is not set
# CONFIG_NLS_CODEPAGE_864 is not set
# CONFIG_NLS_CODEPAGE_865 is not set
# CONFIG_NLS_CODEPAGE_866 is not set
# CONFIG_NLS_CODEPAGE_869 is not set
# CONFIG_NLS_CODEPAGE_936 is not set
# CONFIG_NLS_CODEPAGE_950 is not set
# CONFIG_NLS_CODEPAGE_932 is not set
# CONFIG_NLS_CODEPAGE_949 is not set
# CONFIG_NLS_CODEPAGE_874 is not set
# CONFIG_NLS_ISO8859_8 is not set
# CONFIG_NLS_CODEPAGE_1250 is not set
# CONFIG_NLS_CODEPAGE_1251 is not set
# CONFIG_NLS_ASCII is not set
CONFIG_NLS_ISO8859_1=y
# CONFIG_NLS_ISO8859_2 is not set
# CONFIG_NLS_ISO8859_3 is not set
# CONFIG_NLS_ISO8859_4 is not set
# CONFIG_NLS_ISO8859_5 is not set
# CONFIG_NLS_ISO8859_6 is not set
# CONFIG_NLS_ISO8859_7 is not set
# CONFIG_NLS_ISO8859_9 is not set
# CONFIG_NLS_ISO8859_13 is not set
# CONFIG_NLS_ISO8859_14 is not set
# CONFIG_NLS_ISO8859_15 is not set
# CONFIG_NLS_KOI8_R is not set
# CONFIG_NLS_KOI8_U is not set
CONFIG_NLS_UTF8=y

#
# Security options
#
# CONFIG_KEYS is not set
# CONFIG_SECURITY is not set

#
# Cryptographic options
#
CONFIG_CRYPTO=y
CONFIG_CRYPTO_HMAC=y
# CONFIG_CRYPTO_NULL is not set
# CONFIG_CRYPTO_MD4 is not set
CONFIG_CRYPTO_MD5=m
CONFIG_CRYPTO_SHA1=m
# CONFIG_CRYPTO_SHA256 is not set
# CONFIG_CRYPTO_SHA512 is not set
# CONFIG_CRYPTO_WP512 is not set
CONFIG_CRYPTO_DES=m
# CONFIG_CRYPTO_BLOWFISH is not set
# CONFIG_CRYPTO_TWOFISH is not set
# CONFIG_CRYPTO_SERPENT is not set
# CONFIG_CRYPTO_AES_586 is not set
# CONFIG_CRYPTO_CAST5 is not set
# CONFIG_CRYPTO_CAST6 is not set
# CONFIG_CRYPTO_TEA is not set
# CONFIG_CRYPTO_ARC4 is not set
# CONFIG_CRYPTO_KHAZAD is not set
# CONFIG_CRYPTO_ANUBIS is not set
# CONFIG_CRYPTO_DEFLATE is not set
# CONFIG_CRYPTO_MICHAEL_MIC is not set
CONFIG_CRYPTO_CRC32C=m
# CONFIG_CRYPTO_TEST is not set

#
# Library routines
#
# CONFIG_CRC_CCITT is not set
CONFIG_CRC32=y
CONFIG_LIBCRC32C=y
CONFIG_ZLIB_INFLATE=y

^ permalink raw reply	[relevance 6%]

* compile error "drivers/xen/balloon/
@ 2005-03-08  9:48 12% Filip Sergeys
  2005-03-08 11:05  5% ` Vincent Hanquez
  0 siblings, 1 reply; 200+ results
From: Filip Sergeys @ 2005-03-08  9:48 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1766 bytes --]

I first installed the binary tarball, it works fine, the machine boots
and runs. However want to change a few things in the kernel (support for
ACL's, USB, ...); so I installed the source tarball from
http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/xen-2.0.4-src.tgz

This is the sequence of commands

untar xen-2.0.4-src.tgz
make world
copy the /boot/config-2.6.10-xen0 from the binary install to
linux-2.6.10-xen0/.config
make ARCH=xen xconfig
change the parameters I need
make

then this error occurs:

CC      drivers/xen/balloon/balloon.o
drivers/xen/balloon/balloon.c: In function `balloon_process':
drivers/xen/balloon/balloon.c:209: error: `phys_to_machine_mapping'
undeclared (first use in this function)
drivers/xen/balloon/balloon.c:209: error: (Each undeclared identifier is
reported only once
drivers/xen/balloon/balloon.c:209: error: for each function it appears
in.)
drivers/xen/balloon/balloon.c:209: error: `INVALID_P2M_ENTRY' undeclared
(first use in this function)
drivers/xen/balloon/balloon.c:253: warning: implicit declaration of
function `scrub_pages'
make[3]: *** [drivers/xen/balloon/balloon.o] Error 1
make[2]: *** [drivers/xen/balloon] Error 2
make[1]: *** [drivers/xen] Error 2
make: *** [drivers] Error 2

I also tried to compile from the original config-2.6.10-xen0 file
without changing anything but the same error occurs.
"Xen balloon driver - enables returning/claiming memory to/from Xen" ;
is it safe to turn off and how? Or is there a better solution?

Thanx in advance,

Filip Sergeys.


-- 
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
* System Engineer, Verzekeringen NV *
* www.verzekeringen.be              *
* Oostkaai 23 B-2170 Merksem        *
* 03/6416673 - 0477/340942          *
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

[-- Attachment #2: Type: text/html, Size: 2379 bytes --]

^ permalink raw reply	[relevance 12%]

* Re: compile error "drivers/xen/balloon/
  2005-03-08  9:48 12% compile error "drivers/xen/balloon/ Filip Sergeys
@ 2005-03-08 11:05  5% ` Vincent Hanquez
  0 siblings, 0 replies; 200+ results
From: Vincent Hanquez @ 2005-03-08 11:05 UTC (permalink / raw)
  To: Filip Sergeys; +Cc: xen-devel

On Tue, Mar 08, 2005 at 10:48:44AM +0100, Filip Sergeys wrote:
> untar xen-2.0.4-src.tgz
> make world
> copy the /boot/config-2.6.10-xen0 from the binary install to
> linux-2.6.10-xen0/.config
> make ARCH=xen xconfig
> change the parameters I need
> make

this is 'make ARCH=xen' here

-- 
Vincent Hanquez


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[relevance 5%]

* [PATCH] Eliminate kernel version checks from i386/kernel/pci-dma.c
@ 2005-04-15 21:28  6% Chris Wright
  0 siblings, 0 replies; 200+ results
From: Chris Wright @ 2005-04-15 21:28 UTC (permalink / raw)
  To: xen-devel

Eliminate kernel version checks from i386/kernel/pci-dma.c as a trivial
first pass cleanup towards merging.

Signed-off-by: Chris Wright <chrisw@osdl.org>
---

 linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c |   29 -----------------
 1 files changed, 29 deletions(-)

===== arch/xen/i386/kernel/pci-dma.c 1.20 vs edited =====
--- 1.20/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c	2005-04-04 08:38:39 -07:00
+++ edited/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c	2005-04-15 11:11:09 -07:00
@@ -14,14 +14,7 @@
 #include <linux/version.h>
 #include <asm/io.h>
 #include <asm-xen/balloon.h>
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 #include <asm/tlbflush.h>
-#else
-#define pte_offset_kernel pte_offset
-#define pud_t pgd_t
-#define pud_offset(d, va) d
-#endif
 
 struct dma_coherent_mem {
 	void		*virt_base;
@@ -85,24 +78,13 @@ xen_contig_memory(unsigned long vstart, 
 	balloon_unlock(flags);
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-			   dma_addr_t *dma_handle)
-#else
 void *dma_alloc_coherent(struct device *dev, size_t size,
 			   dma_addr_t *dma_handle, int gfp)
-#endif
 {
 	void *ret;
 	unsigned int order = get_order(size);
 	unsigned long vstart;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-	int gfp = GFP_ATOMIC;
-
-	if (hwdev == NULL || ((u32)hwdev->dma_mask < 0xffffffff))
-		gfp |= GFP_DMA;
-#else
 	struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
 
 	/* ignore region specifiers */
@@ -123,7 +105,6 @@ void *dma_alloc_coherent(struct device *
 
 	if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
 		gfp |= GFP_DMA;
-#endif
 
 	vstart = __get_free_pages(gfp, order);
 	ret = (void *)vstart;
@@ -138,14 +119,6 @@ void *dma_alloc_coherent(struct device *
 	return ret;
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
-			 void *vaddr, dma_addr_t dma_handle)
-{
-	free_pages((unsigned long)vaddr, get_order(size));
-}
-#else
-
 void dma_free_coherent(struct device *dev, size_t size,
 			 void *vaddr, dma_addr_t dma_handle)
 {
@@ -236,5 +209,3 @@ void *dma_mark_declared_memory_occupied(
 	return mem->virt_base + (pos << PAGE_SHIFT);
 }
 EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
-
-#endif

^ permalink raw reply	[relevance 6%]

* [PATCH] Eliminate kernel version checks from x86_64/kernel/pci-dma.c
@ 2005-04-15 21:30  6% Chris Wright
  0 siblings, 0 replies; 200+ results
From: Chris Wright @ 2005-04-15 21:30 UTC (permalink / raw)
  To: xen-devel

Eliminate kernel version checks from x86_64/kernel/pci-dma.c as a trivial
first pass cleanup towards merging.

Signed-off-by: Chris Wright <chrisw@osdl.org>
---

 linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c |   27 ---------------
 1 files changed, 27 deletions(-)

===== linux-2.6.11-xen-sparse/arch/x86_64/kernel/pci-dma.c 1.3 vs edited =====
--- 1.3/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c	2005-04-06 01:37:08 -07:00
+++ edited/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c	2005-04-15 11:13:20 -07:00
@@ -10,12 +10,6 @@
 #include <asm/io.h>
 #include <asm-xen/balloon.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-#define pte_offset_kernel pte_offset
-#define pud_t pgd_t
-#define pud_offset(d, va) d
-#endif
-
 /* Map a set of buffers described by scatterlist in streaming
  * mode for DMA.  This is the scatter-gather version of the
  * above pci_map_single interface.  Here the scatter gather list
@@ -125,24 +119,13 @@ xen_contig_memory(unsigned long vstart, 
         balloon_unlock(flags);
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-			   dma_addr_t *dma_handle)
-#else
 void *dma_alloc_coherent(struct device *dev, size_t size,
 			   dma_addr_t *dma_handle, unsigned gfp)
-#endif
 {
 	void *ret;
 	unsigned int order = get_order(size);
 	unsigned long vstart;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-	int gfp = GFP_ATOMIC;
-
-	if (hwdev == NULL || ((u32)hwdev->dma_mask < 0xffffffff))
-		gfp |= GFP_DMA;
-#else
 	struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
 
 	/* ignore region specifiers */
@@ -163,7 +146,6 @@ void *dma_alloc_coherent(struct device *
 
 	if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
 		gfp |= GFP_DMA;
-#endif
 
 	vstart = __get_free_pages(gfp, order);
 	ret = (void *)vstart;
@@ -179,14 +161,6 @@ void *dma_alloc_coherent(struct device *
 }
 EXPORT_SYMBOL(dma_alloc_coherent);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
-			 void *vaddr, dma_addr_t dma_handle)
-{
-	free_pages((unsigned long)vaddr, get_order(size));
-}
-#else
-
 void dma_free_coherent(struct device *dev, size_t size,
 			 void *vaddr, dma_addr_t dma_handle)
 {
@@ -279,5 +253,4 @@ void *dma_mark_declared_memory_occupied(
 	return mem->virt_base + (pos << PAGE_SHIFT);
 }
 EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
-#endif
 #endif

^ permalink raw reply	[relevance 6%]

* [PATCH] Network Checksum Removal
@ 2005-05-20 23:30  4% Jon Mason
  0 siblings, 0 replies; 200+ results
From: Jon Mason @ 2005-05-20 23:30 UTC (permalink / raw)
  To: Xen-devel

Currently in Xen, interdomain communication needlessly wastes CPU cycles
calculating and verifying TCP/UDP checksums.  This is unnecessary, as
the possibility of packet corruption between domains is miniscule (and
can be detected in memory via ECC).  Also, domU's are unable to take
advantage of any adapter hardware checksum offload capabilities when
transmitting packets outside of the system.

This patch removes the inter-xen network checksums by using the existing
Linux hardware checksum offload infrastructure.  This decreased the
changes needed by this patch, and enabled me to easily use hardware
checksum on the physical
devices.

Here is how the traffic flow now works (generically):
Traffic generated by dom0 will not do the TCP/UDP checksums and will
notify domU this via the csum bit in netif_rx_response_t.  domU will
check for the csum bit on each incoming packet, and if not enabled it
will verify the checksum.

Traffic generated externally, if rx hardware checksum is available and
enabled, then dom0 will notify domU that it is unnecessary to validate
this checksum (providing the checksum is valid) by enabling the csum
bit.  If domU is not notified that it is unnecessary to vaildate the 
checksum, then domU will do it.

Traffic generated by domU will not do the TCP/UDP checksums and will
notify dom0 this via the csim bit in netif_tx_request_t.  dom0 will
check for the csum bit on each incoming packet, and if enabled it will
calculate the necessary bits for hardware checksum offload (skb->csum, 
which is the offset to insert the checksum).  It also sets
skb->ip_summed = CHECKSUM_UNNECESSARY;
skb->flags |= SKB_FDW_NO_CSUM;

ip_summed is set in the case that the packet is destined for dom0, which
will prevent dom0 from checking the TCP/UDP checksum.  Unfortunately,
this flag is stomped on by both routing and bridging.  So I added a new
skb field and a new flag, SKB_FDW_NO_CSUM.  This field is checked on
transmission and corrects the fields that have been modified by the
bridging/routing code.  Once these fields have been corrected, the
adapter (if tx csum able) or stack (via skb_checksum_help()) will
calculate the TCP/UDP checksum.

Performance:
I ran the following test cases with netperf3 TCP_STREAM, and get the
following boosts (using bridging):
domU->dom0		500Mbps
dom0->domU              10Mbps
domU->remote host       none
domU->domU		70Mbps
Note: I have a small bridging patch which increases dom0 throughput.  I
am in the process of having it accepted into the Linux kernel.

I currently do not have CPU utilization numbers (where the real boost of
this patch would be), and I do not have throughput numbers for
routing/nat.


Also, I added the ability to enable/disable checksum offload via the
ethtool command.  

Signed-off-by: Jon Mason <jdmason@us.ibm.com>

--- ../xen-unstable-pristine/xen/include/public/io/netif.h	2005-05-04 22:20:10.000000000 -0500
+++ xen/include/public/io/netif.h	2005-05-18 12:05:41.000000000 -0500
@@ -12,7 +12,8 @@
 typedef struct {
     memory_t addr;   /*  0: Machine address of packet.  */
     MEMORY_PADDING;
-    u16      id;     /*  8: Echoed in response message. */
+    u16      csum:1;
+    u16      id:15;     /*  8: Echoed in response message. */
     u16      size;   /* 10: Packet size in bytes.       */
 } PACKED netif_tx_request_t; /* 12 bytes */
 
@@ -29,7 +30,8 @@ typedef struct {
 typedef struct {
     memory_t addr;   /*  0: Machine address of packet.              */
     MEMORY_PADDING;
-    u16      id;     /*  8:  */
+    u16      csum:1;
+    u16      id:15;     /*  8:  */
     s16      status; /* 10: -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
 } PACKED netif_rx_response_t; /* 12 bytes */
 
--- ../xen-unstable-pristine/linux-2.6.11-xen-sparse/drivers/xen/netback/netback.c	2005-05-04 22:20:01.000000000 -0500
+++ linux-2.6.11-xen-sparse/drivers/xen/netback/netback.c	2005-05-19 13:25:50.000000000 -0500
@@ -13,6 +13,9 @@
 #include "common.h"
 #include <asm-xen/balloon.h>
 #include <asm-xen/evtchn.h>
+#include <net/ip.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 #include <linux/delay.h>
@@ -154,10 +157,14 @@ int netif_be_start_xmit(struct sk_buff *
         __skb_put(nskb, skb->len);
         (void)skb_copy_bits(skb, -hlen, nskb->data - hlen, skb->len + hlen);
         nskb->dev = skb->dev;
+	nskb->ip_summed = skb->ip_summed;
         dev_kfree_skb(skb);
         skb = nskb;
     }
 
+    if (skb->ip_summed > 0)
+	netif->rx->ring[MASK_NETIF_RX_IDX(netif->rx_resp_prod)].resp.csum = 1;
+	
     netif->rx_req_cons++;
     netif_get(netif);
 
@@ -646,6 +653,18 @@ static void net_tx_action(unsigned long 
         skb->dev      = netif->dev;
         skb->protocol = eth_type_trans(skb, skb->dev);
 
+	skb->csum = 0;
+	if (txreq.csum) {
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
+		skb->flags |= SKB_FDW_NO_CSUM;
+		skb->nh.iph = (struct iphdr *) skb->data;
+		if (skb->nh.iph->protocol == IPPROTO_TCP)
+			skb->csum = offsetof(struct tcphdr, check);
+		if (skb->nh.iph->protocol == IPPROTO_UDP)
+			skb->csum = offsetof(struct udphdr, check);
+	} else
+		skb->ip_summed = CHECKSUM_NONE;
+
         netif->stats.rx_bytes += txreq.size;
         netif->stats.rx_packets++;
 
--- ../xen-unstable-pristine/linux-2.6.11-xen-sparse/drivers/xen/netback/interface.c	2005-05-04 22:20:09.000000000 -0500
+++ linux-2.6.11-xen-sparse/drivers/xen/netback/interface.c	2005-05-20 10:36:14.000000000 -0500
@@ -159,6 +159,7 @@ void netif_create(netif_be_create_t *cre
     dev->get_stats       = netif_be_get_stats;
     dev->open            = net_open;
     dev->stop            = net_close;
+    dev->features        = NETIF_F_NO_CSUM;
 
     /* Disable queuing. */
     dev->tx_queue_len = 0;
--- ../xen-unstable-pristine/linux-2.6.11-xen-sparse/drivers/xen/netfront/netfront.c	2005-05-04 22:20:11.000000000 -0500
+++ linux-2.6.11-xen-sparse/drivers/xen/netfront/netfront.c	2005-05-20 13:15:39.000000000 -0500
@@ -40,6 +40,7 @@
 #include <linux/init.h>
 #include <linux/bitops.h>
 #include <linux/proc_fs.h>
+#include <linux/ethtool.h>
 #include <net/sock.h>
 #include <net/pkt_sched.h>
 #include <net/arp.h>
@@ -287,6 +288,11 @@ static int send_fake_arp(struct net_devi
     return dev_queue_xmit(skb);
 }
 
+static struct ethtool_ops network_ethtool_ops = {
+	.get_tx_csum = ethtool_op_get_tx_csum,
+	.set_tx_csum = ethtool_op_set_tx_csum,
+};
+
 static int network_open(struct net_device *dev)
 {
     struct net_private *np = netdev_priv(dev);
@@ -472,6 +478,7 @@ static int network_start_xmit(struct sk_
     tx->id   = id;
     tx->addr = virt_to_machine(skb->data);
     tx->size = skb->len;
+    tx->csum = (skb->ip_summed) ? 1 : 0;
 
     wmb(); /* Ensure that backend will see the request. */
     np->tx->req_prod = i + 1;
@@ -572,6 +579,9 @@ static int netif_poll(struct net_device 
         skb->len  = rx->status;
         skb->tail = skb->data + skb->len;
 
+	if (rx->csum)
+		skb->ip_summed = CHECKSUM_UNNECESSARY;
+		
         np->stats.rx_packets++;
         np->stats.rx_bytes += rx->status;
 
@@ -966,7 +976,9 @@ static int create_netdev(int handle, str
     dev->get_stats       = network_get_stats;
     dev->poll            = netif_poll;
     dev->weight          = 64;
-    
+    dev->features 	 = NETIF_F_IP_CSUM;
+    SET_ETHTOOL_OPS(dev, &network_ethtool_ops);
+
     if ((err = register_netdev(dev)) != 0) {
         printk(KERN_WARNING "%s> register_netdev err=%d\n", __FUNCTION__, err);
         goto exit;
--- ../xen-unstable-pristine/linux-2.6.11-xen0/include/linux/skbuff.h	2005-03-02 01:38:38.000000000 -0600
+++ linux-2.6.11-xen0/include/linux/skbuff.h	2005-05-18 12:05:41.000000000 -0500
@@ -37,6 +37,10 @@
 #define CHECKSUM_HW 1
 #define CHECKSUM_UNNECESSARY 2
 
+#define SKB_CLONED	1
+#define SKB_NOHDR	2
+#define SKB_FDW_NO_CSUM	4
+
 #define SKB_DATA_ALIGN(X)	(((X) + (SMP_CACHE_BYTES - 1)) & \
 				 ~(SMP_CACHE_BYTES - 1))
 #define SKB_MAX_ORDER(X, ORDER)	(((PAGE_SIZE << (ORDER)) - (X) - \
@@ -238,7 +242,7 @@ struct sk_buff {
 				mac_len,
 				csum;
 	unsigned char		local_df,
-				cloned,
+				flags,
 				pkt_type,
 				ip_summed;
 	__u32			priority;
@@ -370,7 +374,7 @@ static inline void kfree_skb(struct sk_b
  */
 static inline int skb_cloned(const struct sk_buff *skb)
 {
-	return skb->cloned && atomic_read(&skb_shinfo(skb)->dataref) != 1;
+	return (skb->flags & SKB_CLONED) && atomic_read(&skb_shinfo(skb)->dataref) != 1;
 }
 
 /**
--- ../xen-unstable-pristine/linux-2.6.11-xen0/net/core/skbuff.c	2005-03-02 01:38:17.000000000 -0600
+++ linux-2.6.11-xen0/net/core/skbuff.c	2005-05-18 12:05:41.000000000 -0500
@@ -240,7 +240,7 @@ static void skb_clone_fraglist(struct sk
 
 void skb_release_data(struct sk_buff *skb)
 {
-	if (!skb->cloned ||
+	if (!(skb->flags & SKB_CLONED) ||
 	    atomic_dec_and_test(&(skb_shinfo(skb)->dataref))) {
 		if (skb_shinfo(skb)->nr_frags) {
 			int i;
@@ -352,7 +352,7 @@ struct sk_buff *skb_clone(struct sk_buff
 	C(data_len);
 	C(csum);
 	C(local_df);
-	n->cloned = 1;
+	n->flags = skb->flags | SKB_CLONED;
 	C(pkt_type);
 	C(ip_summed);
 	C(priority);
@@ -395,7 +395,7 @@ struct sk_buff *skb_clone(struct sk_buff
 	C(end);
 
 	atomic_inc(&(skb_shinfo(skb)->dataref));
-	skb->cloned = 1;
+	skb->flags |= SKB_CLONED;
 
 	return n;
 }
@@ -603,7 +603,7 @@ int pskb_expand_head(struct sk_buff *skb
 	skb->mac.raw += off;
 	skb->h.raw   += off;
 	skb->nh.raw  += off;
-	skb->cloned   = 0;
+	skb->flags    &= SKB_CLONED;
 	atomic_set(&skb_shinfo(skb)->dataref, 1);
 	return 0;
 
--- ../xen-unstable-pristine/linux-2.6.11-xen0/net/core/dev.c	2005-03-02 01:38:09.000000000 -0600
+++ linux-2.6.11-xen0/net/core/dev.c	2005-05-20 10:20:36.000000000 -0500
@@ -98,6 +98,7 @@
 #include <linux/stat.h>
 #include <linux/if_bridge.h>
 #include <linux/divert.h>
+#include <net/ip.h> 
 #include <net/dst.h>
 #include <net/pkt_sched.h>
 #include <net/checksum.h>
@@ -1182,7 +1183,7 @@ int __skb_linearize(struct sk_buff *skb,
 	skb->data    += offset;
 
 	/* We are no longer a clone, even if we were. */
-	skb->cloned    = 0;
+	skb->flags    &= ~SKB_CLONED;
 
 	skb->tail     += skb->data_len;
 	skb->data_len  = 0;
@@ -1236,6 +1237,15 @@ int dev_queue_xmit(struct sk_buff *skb)
 	    __skb_linearize(skb, GFP_ATOMIC))
 		goto out_kfree_skb;
 
+	/* If packet is forwarded to a device that needs a checksum and not 
+	 * checksummed, correct the pointers and enable checksumming in the 
+	 * next function.
+	 */
+	if (skb->flags & SKB_FDW_NO_CSUM) {
+		skb->ip_summed = CHECKSUM_HW;
+		skb->h.raw = (void *)skb->nh.iph + (skb->nh.iph->ihl * 4);
+	}
+
 	/* If packet is not checksummed and device does not support
 	 * checksumming for this protocol, complete checksumming here.
 	 */

^ permalink raw reply	[relevance 4%]

* PATCH: Full shadow translate mode domUs
@ 2005-06-04 22:57 10% George Washington Dunlap III
  0 siblings, 0 replies; 200+ results
From: George Washington Dunlap III @ 2005-06-04 22:57 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1025 bytes --]

This patch will allow the execution of domains in full shadow-translate 
mode.  It adds a new builder, "linuxtranslate", which will build the 
domain assuming a fully translated domU (pfns starting at 0 and going up 
incrementally).

To use it:
  1) enable CONFIG_XEN_SHADOW_MODE and CONFIG_XEN_SHADOW_TRANSLATE_MODE in 
the domU build config
  2) in the xen config file, add the following line
    build="linuxtranslate"

Note that at present, shadow translate mode does not yet support grant 
tables, so for now this will only work with a ramdisk.

Peace,
  -George

+-------------------+----------------------------------------
| dunlapg@umich.edu | http://www-personal.umich.edu/~dunlapg 
+-------------------+----------------------------------------
|  Who could move a mountain, who could love their enemy?
|  Who could rejoice in pain, and turn the other cheek?
|	- Rich Mullins, "Surely God is With Us"
+------------------------------------------------------------
| Outlaw Junk Email! Support HR 1748 (www.cauce.org)

[-- Attachment #2: Type: TEXT/PLAIN, Size: 62082 bytes --]

diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/cpu/common.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/cpu/common.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/cpu/common.c	2005-05-16 13:05:03.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/cpu/common.c	2005-05-16 13:55:06.000000000 -0400
@@ -554,7 +554,7 @@
 
 void __init cpu_gdt_init(struct Xgt_desc_struct *gdt_descr)
 {
-	unsigned long frames[gdt_descr->size >> PAGE_SHIFT];
+	unsigned long frames[(gdt_descr->size >> PAGE_SHIFT)+1];
 	unsigned long va;
 	int f;
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c	2005-06-04 18:14:40.000000000 -0400
@@ -109,11 +109,13 @@
 		retval = copy_ldt(&mm->context, &old_mm->context);
 		up(&old_mm->context.sem);
 	}
+#ifndef CONFIG_XEN_SHADOW_MODE
 	if (retval == 0) {
 		spin_lock(&mm_unpinned_lock);
 		list_add(&mm->context.unpinned, &mm_unpinned);
 		spin_unlock(&mm_unpinned_lock);
 	}
+#endif
 	return retval;
 }
 
@@ -134,11 +136,13 @@
 			kfree(mm->context.ldt);
 		mm->context.size = 0;
 	}
+#ifndef CONFIG_XEN_SHADOW_MODE
 	if (!mm->context.pinned) {
 		spin_lock(&mm_unpinned_lock);
 		list_del(&mm->context.unpinned);
 		spin_unlock(&mm_unpinned_lock);
 	}
+#endif
 }
 
 static int read_ldt(void __user * ptr, unsigned long bytecount)
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c	2005-05-16 13:05:03.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c	2005-05-16 13:55:06.000000000 -0400
@@ -27,6 +27,7 @@
 static void
 xen_contig_memory(unsigned long vstart, unsigned int order)
 {
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 	/*
 	 * Ensure multi-page extents are contiguous in machine memory.
 	 * This code could be cleaned up some, and the number of
@@ -69,6 +70,7 @@
 	flush_tlb_all();
 
 	balloon_unlock(flags);
+#endif /* ! CONFIG_XEN_SHADOW_TRANSLATE_MODE */
 }
 
 void *dma_alloc_coherent(struct device *dev, size_t size,
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c	2005-05-16 13:05:03.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c	2005-05-16 13:55:06.000000000 -0400
@@ -360,8 +360,10 @@
 shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
 EXPORT_SYMBOL(HYPERVISOR_shared_info);
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 unsigned int *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
 EXPORT_SYMBOL(phys_to_machine_mapping);
+#endif
 
 /* Raw start-of-day parameters from the hypervisor. */
 union xen_start_info_union xen_start_info_union;
@@ -1156,7 +1158,9 @@
 	}
 #endif
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 	phys_to_machine_mapping = (unsigned int *)xen_start_info.mfn_list;
+#endif
 
 	return max_low_pfn;
 }
@@ -1509,6 +1513,7 @@
 	find_smp_config();
 #endif
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 	/* Make sure we have a correctly sized P->M table. */
 	if (max_pfn != xen_start_info.nr_pages) {
 		phys_to_machine_mapping = alloc_bootmem_low_pages(
@@ -1545,7 +1550,7 @@
 	}
 	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
 	     virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
-
+#endif /* ! CONFIG_XEN_SHADOW_TRANSLATE_MODE */
 
 	/*
 	 * NOTE: at this point the bootmem allocator is fully available.
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	2005-06-01 15:08:44.000000000 -0400
@@ -408,6 +408,7 @@
 }
 #endif /* CONFIG_XEN_SHADOW_MODE */
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 LIST_HEAD(mm_unpinned);
 DEFINE_SPINLOCK(mm_unpinned_lock);
 
@@ -454,6 +455,7 @@
 	}
 }
 
+
 void mm_pin(struct mm_struct *mm)
 {
     spin_lock(&mm->page_table_lock);
@@ -521,3 +523,4 @@
     if ( mm->context.pinned && (atomic_read(&mm->mm_count) == 1) )
         mm_unpin(mm);
 }
+#endif /* CONFIG_XEN_SHADOW_MODE */
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/Kconfig xeno-ft/linux-2.6.11-xen-sparse/arch/xen/Kconfig
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/Kconfig	2005-05-16 13:05:03.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/Kconfig	2005-05-16 13:55:06.000000000 -0400
@@ -124,11 +124,19 @@
 	  space.  Odds are that you want to say N here.
 
 config XEN_SHADOW_MODE
-	bool "Fake shadow mode"
+	bool "Build linux to use Xen's shadow mode support"
 	default n
-    help
-      fakes out a shadow mode kernel
+	help
+	  Builds a xenolinux that expects Xen's shadow mode support to be
+          enabled.
 
+config XEN_SHADOW_TRANSLATE_MODE
+	bool "Build linux to use Xen's shadow translate mode support"
+	depends on XEN_SHADOW_MODE
+	default n
+	help
+	  Builds a xenolinux that expects Xen's shadow translate mode support
+	  to be enabled.
 
 config XEN_SCRUB_PAGES
 	bool "Scrub memory before freeing it to Xen"
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c	2005-06-04 18:14:40.000000000 -0400
@@ -93,7 +93,9 @@
     extern void time_suspend(void);
     extern void time_resume(void);
     extern unsigned long max_pfn;
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
     extern unsigned int *pfn_to_mfn_frame_list;
+#endif
 
     suspend_record = (suspend_record_t *)__get_free_page(GFP_KERNEL);
     if ( suspend_record == NULL )
@@ -139,6 +141,7 @@
 
     memset(empty_zero_page, 0, PAGE_SIZE);
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
     for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
     {
         pfn_to_mfn_frame_list[j] = 
@@ -146,7 +149,7 @@
     }
     HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
         virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
-
+#endif /* ! CONFIG_XEN_SHADOW_TRANSLATE_MODE */
     gnttab_resume();
 
     irq_resume();
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c xeno-ft/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c	2005-04-13 05:44:49.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c	2005-05-16 13:06:46.000000000 -0400
@@ -197,12 +197,14 @@
                 BUG();
 
             pfn = page - mem_map;
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
             if ( phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY )
                 BUG();
 
             /* Update P->M and M->P tables. */
             phys_to_machine_mapping[pfn] = mfn_list[i];
             xen_machphys_update(mfn_list[i], pfn);
+#endif
             
             /* Link back into the page tables if it's not a highmem page. */
             if ( pfn < max_low_pfn )
@@ -239,7 +241,11 @@
             }
 
             pfn = page - mem_map;
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
             mfn_list[i] = phys_to_machine_mapping[pfn];
+#else
+            mfn_list[i] = pfn;
+#endif
 
             if ( !PageHighMem(page) )
             {
@@ -266,7 +272,9 @@
         for ( i = 0; i < debt; i++ )
         {
             pfn = mfn_to_pfn(mfn_list[i]);
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
             phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
+#endif
             balloon_append(pfn_to_page(pfn));
         }
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h
--- xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h	2005-06-01 14:17:39.000000000 -0400
@@ -41,9 +41,15 @@
 		: : "r" (0) );
 }
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 extern void mm_pin(struct mm_struct *mm);
 extern void mm_unpin(struct mm_struct *mm);
 void mm_pin_all(void);
+#else
+#define mm_pin(_mm) ((void)0)
+#define mm_unpin(_mm) ((void)0)
+#define mm_pin_all() ((void)0)
+#endif
 
 static inline void switch_mm(struct mm_struct *prev,
 			     struct mm_struct *next,
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h
--- xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h	2005-06-01 15:15:30.000000000 -0400
@@ -16,6 +16,7 @@
 	struct list_head unpinned;
 } mm_context_t;
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 extern struct list_head mm_unpinned;
 extern spinlock_t mm_unpinned_lock;
 
@@ -23,4 +24,6 @@
 extern void _arch_exit_mmap(struct mm_struct *mm);
 #define arch_exit_mmap(_mm) _arch_exit_mmap(_mm)
 
+#endif /* CONFIG_XEN_SHADOW_MODE */
+
 #endif
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h
--- xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h	2005-05-31 08:28:29.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h	2005-05-31 08:43:13.000000000 -0400
@@ -58,9 +58,15 @@
 #define copy_user_page(to, from, vaddr, pg)	copy_page(to, from)
 
 /**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 extern unsigned int *phys_to_machine_mapping;
-#define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
-#define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
+#ifdef CONFIG_XEN_SHADOW_MODE
+# define pfn_to_mfn(_pfn) ((unsigned long)(_pfn))
+# define mfn_to_pfn(_mfn) ((unsigned long)(_mfn))
+#else
+# define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
+# define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
+#endif
 static inline unsigned long phys_to_machine(unsigned long phys)
 {
 	unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
@@ -73,6 +79,12 @@
 	phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
 	return phys;
 }
+#else /* CONFIG_XEN_SHADOW_TRANSLATE_MODE */
+#define pfn_to_mfn(_pfn)       (_pfn)
+#define mfn_to_pfn(_mfn)       (_mfn)
+#define phys_to_machine(_phys) (_phys)
+#define machine_to_phys(_mach) (_mach)
+#endif /* CONFIG_XEN_SHADOW_TRANSLATE_MODE */
 
 /*
  * These are used to make use of C type-checking..
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/libxc/Makefile xeno-ft/tools/libxc/Makefile
--- xen-unstable.latest/tools/libxc/Makefile	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/tools/libxc/Makefile	2005-06-04 18:14:41.000000000 -0400
@@ -20,6 +20,7 @@
 SRCS     += xc_evtchn.c
 SRCS     += xc_gnttab.c
 SRCS     += xc_linux_build.c
+SRCS     += xc_linuxtranslate_build.c
 SRCS     += xc_plan9_build.c
 SRCS     += xc_linux_restore.c
 SRCS     += xc_linux_save.c
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/libxc/xc_evtchn.c xeno-ft/tools/libxc/xc_evtchn.c
--- xen-unstable.latest/tools/libxc/xc_evtchn.c	2005-04-13 05:44:49.000000000 -0400
+++ xeno-ft/tools/libxc/xc_evtchn.c	2005-05-16 13:06:46.000000000 -0400
@@ -40,6 +40,7 @@
 
     op.cmd = EVTCHNOP_alloc_unbound;
     op.u.alloc_unbound.dom = (domid_t)dom;
+    op.u.alloc_unbound.port = *port;
    
     if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
     {
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/libxc/xc.h xeno-ft/tools/libxc/xc.h
--- xen-unstable.latest/tools/libxc/xc.h	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/tools/libxc/xc.h	2005-06-04 18:14:41.000000000 -0400
@@ -254,6 +254,15 @@
                    unsigned long flags,
                    unsigned int vcpus);
 
+int xc_linuxtranslate_build(int xc_handle,
+                   u32 domid,
+                   const char *image_name,
+                   const char *ramdisk_name,
+                   const char *cmdline,
+                   unsigned int control_evtchn,
+                   unsigned long flags,
+                   unsigned int vcpus);
+
 int
 xc_plan9_build (int xc_handle,
                 u32 domid, 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/libxc/xc_linuxtranslate_build.c xeno-ft/tools/libxc/xc_linuxtranslate_build.c
--- xen-unstable.latest/tools/libxc/xc_linuxtranslate_build.c	1969-12-31 19:00:00.000000000 -0500
+++ xeno-ft/tools/libxc/xc_linuxtranslate_build.c	2005-06-04 18:05:18.000000000 -0400
@@ -0,0 +1,796 @@
+/******************************************************************************
+ * xc_linuxtranslate_build.c
+ * Derived from xc_linux_build.c
+ */
+
+#include "xc_private.h"
+#define ELFSIZE 32
+#include "xc_elf.h"
+#include <stdlib.h>
+#include <zlib.h>
+
+#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
+#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
+
+#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
+#define round_pgdown(_p)  ((_p)&PAGE_MASK)
+
+struct domain_setup_info
+{
+    unsigned long v_start;
+    unsigned long v_end;
+    unsigned long v_kernstart;
+    unsigned long v_kernend;
+    unsigned long v_kernentry;
+
+    unsigned int  load_symtab;
+    unsigned long symtab_addr;
+    unsigned long symtab_len;
+};
+
+static int
+parseelfimage(
+    char *elfbase, unsigned long elfsize, struct domain_setup_info *dsi);
+static int
+loadelfimage(
+    char *elfbase, int xch, u32 dom, unsigned long *parray,
+    struct domain_setup_info *dsi);
+static int
+loadelfsymtab(
+    char *elfbase, int xch, u32 dom, unsigned long *parray,
+    struct domain_setup_info *dsi);
+
+static int setup_guest(int xc_handle,
+                         u32 dom,
+                         char *image, unsigned long image_size,
+                         gzFile initrd_gfd, unsigned long initrd_len,
+                         unsigned long nr_pages,
+                         unsigned long *pvsi, unsigned long *pvke,
+                         vcpu_guest_context_t *ctxt,
+                         const char *cmdline,
+                         unsigned long shared_info_frame,
+                         unsigned int control_evtchn,
+                         unsigned long flags,
+                         unsigned int vcpus)
+{
+    l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
+    l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
+    unsigned long *page_array = NULL;
+    unsigned long ml2tab, pl2tab;
+    unsigned long ml1tab, pl1tab;
+    unsigned long mfn, pfn;
+    unsigned long count, i;
+    start_info_t *start_info;
+    shared_info_t *shared_info;
+    mmu_t *mmu = NULL;
+    int rc;
+
+    unsigned long nr_pt_pages;
+    unsigned long ppt_alloc;
+    unsigned long *physmap, *physmap_e, physmap_pfn;
+
+    struct domain_setup_info dsi;
+    unsigned long vinitrd_start;
+    unsigned long vinitrd_end;
+    unsigned long vphysmap_start;
+    unsigned long vphysmap_end;
+    unsigned long vstartinfo_start;
+    unsigned long vstartinfo_end;
+    unsigned long vstack_start;
+    unsigned long vstack_end;
+    unsigned long vpt_start;
+    unsigned long vpt_end;
+    unsigned long v_end;
+    unsigned long pshared_info;
+
+    memset(&dsi, 0, sizeof(struct domain_setup_info));
+
+    rc = parseelfimage(image, image_size, &dsi);
+    if ( rc != 0 )
+        goto error_out;
+
+    if ( (dsi.v_start & (PAGE_SIZE-1)) != 0 )
+    {
+        PERROR("Guest OS must load to a page boundary.\n");
+        goto error_out;
+    }
+
+    /* Untranslated guests are given the mfn of the shared_info frame, and
+     * they are expected to map it.  We need to allocate a pfn to map the
+     * mfn into; so we steal a page from the end.  We don't need to put
+     * it in a page table, we just need to have a p2m and m2p for it... */
+    pshared_info = nr_pages;
+
+    /*
+     * Why do we need this? The number of page-table frames depends on the 
+     * size of the bootstrap address space. But the size of the address space 
+     * depends on the number of page-table frames (since each one is mapped 
+     * read-only). We have a pair of simultaneous equations in two unknowns, 
+     * which we solve by exhaustive search.
+     */
+    vinitrd_start    = round_pgup(dsi.v_end);
+    vinitrd_end      = vinitrd_start + initrd_len;
+    vphysmap_start   = round_pgup(vinitrd_end);
+    vphysmap_end     = vphysmap_start + ((nr_pages+1) * sizeof(unsigned long));
+    vpt_start        = round_pgup(vphysmap_end);
+    for ( nr_pt_pages = 2; ; nr_pt_pages++ )
+    {
+        vpt_end          = vpt_start + (nr_pt_pages * PAGE_SIZE);
+        vstartinfo_start = vpt_end;
+        vstartinfo_end   = vstartinfo_start + PAGE_SIZE;
+        vstack_start     = vstartinfo_end;
+        vstack_end       = vstack_start + PAGE_SIZE;
+        v_end            = (vstack_end + (1<<22)-1) & ~((1<<22)-1);
+        if ( (v_end - vstack_end) < (512 << 10) )
+            v_end += 1 << 22; /* Add extra 4MB to get >= 512kB padding. */
+        if ( (((v_end - dsi.v_start + ((1<<L2_PAGETABLE_SHIFT)-1)) >> 
+               L2_PAGETABLE_SHIFT) + 1) <= nr_pt_pages )
+            break;
+    }
+
+    printf("VIRTUAL MEMORY ARRANGEMENT:\n"
+           " Loaded kernel: %08lx->%08lx\n"
+           " Init. ramdisk: %08lx->%08lx\n"
+           " Phys-Mach map: %08lx->%08lx\n"
+           " Page tables:   %08lx->%08lx\n"
+           " Start info:    %08lx->%08lx\n"
+           " Boot stack:    %08lx->%08lx\n"
+           " TOTAL:         %08lx->%08lx\n",
+           dsi.v_kernstart, dsi.v_kernend, 
+           vinitrd_start, vinitrd_end,
+           vphysmap_start, vphysmap_end,
+           vpt_start, vpt_end,
+           vstartinfo_start, vstartinfo_end,
+           vstack_start, vstack_end,
+           dsi.v_start, v_end);
+    printf(" ENTRY ADDRESS: %08lx\n", dsi.v_kernentry);
+
+    if ( (v_end - dsi.v_start) > (nr_pages * PAGE_SIZE) )
+    {
+        printf("Initial guest OS requires too much space\n"
+               "(%luMB is greater than %luMB limit)\n",
+               (v_end-dsi.v_start)>>20, (nr_pages<<PAGE_SHIFT)>>20);
+        goto error_out;
+    }
+
+    if ( (page_array = malloc((nr_pages+1) * sizeof(unsigned long))) == NULL )
+    {
+        PERROR("Could not allocate memory");
+        goto error_out;
+    }
+
+
+    if ( xc_get_pfn_list(xc_handle, dom, page_array, nr_pages) != nr_pages )
+    {
+        PERROR("Could not get the page frame list");
+        goto error_out;
+    }
+
+    fprintf(stderr, "setup_guest: loadelfimage\n");
+    loadelfimage(image, xc_handle, dom, page_array, &dsi);
+
+    /* Load the initial ramdisk image. */
+    if ( initrd_len != 0 )
+    {
+	fprintf(stderr, "setup_guest: xc_copy_to_domain_page (pre-for)\n");
+        for ( i = (vinitrd_start - dsi.v_start); 
+              i < (vinitrd_end - dsi.v_start); i += PAGE_SIZE )
+        {
+            char page[PAGE_SIZE];
+            if ( gzread(initrd_gfd, page, PAGE_SIZE) == -1 )
+            {
+                PERROR("Error reading initrd image, could not");
+                goto error_out;
+            }
+            xc_copy_to_domain_page(xc_handle, dom,
+                                page_array[i>>PAGE_SHIFT], page);
+        }
+    }
+
+    fprintf(stderr, "setup_guest: init_mmu_updates\n");
+    if ( (mmu = init_mmu_updates(xc_handle, dom)) == NULL )
+        goto error_out;
+
+    /* First allocate page for page dir. */
+    ppt_alloc = (vpt_start - dsi.v_start) >> PAGE_SHIFT;
+    //l2tab = page_array[ppt_alloc++] << PAGE_SHIFT;
+    pl2tab = ppt_alloc++;
+    ml2tab = page_array[pl2tab];
+    //ctxt->pt_base = l2tab;
+    ctxt->pt_base = ml2tab << PAGE_SHIFT;
+
+    /* Initialise the page tables. */
+    fprintf(stderr, "setup_guest: Initializing l2 table pfn %lx mfn %lx\n",
+    			pl2tab, ml2tab);
+    if ( (vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 
+                                        PROT_READ|PROT_WRITE, 
+					ml2tab)) == NULL )
+        goto error_out;
+    memset(vl2tab, 0, PAGE_SIZE);
+    vl2e = &vl2tab[l2_table_offset(dsi.v_start)];
+    fprintf(stderr, " v_start %lx l2_table_offset %lx\n", 
+    			dsi.v_start,
+			l2_table_offset(dsi.v_start));
+    for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ )
+    {    
+        if ( ((unsigned long)vl1e & (PAGE_SIZE-1)) == 0 )
+        {
+	    //l1tab = page_array[ppt_alloc++] << PAGE_SHIFT;
+	    pl1tab = ppt_alloc++;
+	    ml1tab = page_array[pl1tab];
+	    fprintf(stderr, " allocating new l1 page; pfn %lx, mfn %lx\n",
+	    			pl1tab, ml1tab);
+            if ( vl1tab != NULL )
+                munmap(vl1tab, PAGE_SIZE);
+            if ( (vl1tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
+                                                PROT_READ|PROT_WRITE,
+						ml1tab)) == NULL )
+            {
+                munmap(vl2tab, PAGE_SIZE);
+                goto error_out;
+            }
+            memset(vl1tab, 0, PAGE_SIZE);
+            vl1e = &vl1tab[l1_table_offset(dsi.v_start + (count<<PAGE_SHIFT))];
+            *vl2e++ = (pl1tab << PAGE_SHIFT )| L2_PROT;
+        }
+
+	pfn=count;
+	mfn=page_array[pfn];
+
+        *vl1e = (pfn << PAGE_SHIFT) | L1_PROT;
+	fprintf(stderr, " %lx:%lx\n", dsi.v_start + (count << PAGE_SHIFT), *vl1e);
+
+        vl1e++;
+    }
+    munmap(vl1tab, PAGE_SIZE);
+    munmap(vl2tab, PAGE_SIZE);
+
+    /* Write the phys->machine and machine->phys table entries. */
+    physmap_pfn = (vphysmap_start - dsi.v_start) >> PAGE_SHIFT;
+    physmap = physmap_e = xc_map_foreign_range(
+        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+        page_array[physmap_pfn++]);
+    for ( count = 0; count < nr_pages; count++ )
+    {
+	pfn = count;
+	mfn = page_array[count];
+        if ( add_mmu_update(xc_handle, mmu,
+                            (mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, 
+			    pfn) )
+        {
+            munmap(physmap, PAGE_SIZE);
+            goto error_out;
+        }
+        *physmap_e++ = pfn;
+        if ( ((unsigned long)physmap_e & (PAGE_SIZE-1)) == 0 )
+        {
+            munmap(physmap, PAGE_SIZE);
+            physmap = physmap_e = xc_map_foreign_range(
+                xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+                page_array[physmap_pfn++]);
+        }
+    }
+
+    if(xc_shadow_control(xc_handle, 
+    				dom, 
+				DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE,
+				NULL,
+				0,
+				NULL)<0) {
+	PERROR("Could not enable full translate mode!");
+	goto error_out;
+    } 
+
+    /* Translate the shared_info page.  (we allocated enough for nr_pages+1.) */
+    mfn = shared_info_frame;
+    pfn = pshared_info;
+    if( add_mmu_update(xc_handle, mmu, 
+		   (mfn<<PAGE_SHIFT)|MMU_MACHPHYS_UPDATE,
+		   pfn)) {
+	munmap(physmap, PAGE_SIZE);
+	goto error_out;
+    }
+    *physmap_e++ = pfn;
+
+    /* If you do anything after here, make sure to see if you need to
+     * go on to the next page. */
+    munmap(physmap, PAGE_SIZE);
+    
+    /*
+     * Pin down l2tab addr as page dir page - causes hypervisor to provide
+     * correct protection for the page
+     */ 
+    if ( pin_table(xc_handle, 
+    			MMUEXT_PIN_L2_TABLE, 
+			ml2tab,
+			dom) )
+        goto error_out;
+
+    start_info = xc_map_foreign_range(
+        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+        page_array[(vstartinfo_start-dsi.v_start)>>PAGE_SHIFT]);
+
+    memset(start_info, 0, sizeof(*start_info));
+    start_info->nr_pages     = nr_pages;
+    start_info->shared_info  = pshared_info << PAGE_SHIFT;
+    start_info->flags        = flags;
+    start_info->pt_base      = vpt_start;
+    start_info->nr_pt_frames = nr_pt_pages;
+    start_info->mfn_list     = vphysmap_start;
+    start_info->domain_controller_evtchn = control_evtchn;
+    if ( initrd_len != 0 )
+    {
+        start_info->mod_start    = vinitrd_start;
+        start_info->mod_len      = initrd_len;
+    }
+    strncpy((char *)start_info->cmd_line, cmdline, MAX_CMDLINE);
+    start_info->cmd_line[MAX_CMDLINE-1] = '\0';
+    munmap(start_info, PAGE_SIZE);
+
+    /* shared_info page starts its life empty. */
+    shared_info = xc_map_foreign_range(
+        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
+    memset(shared_info, 0, sizeof(shared_info_t));
+    /* Mask all upcalls... */
+    for ( i = 0; i < MAX_VIRT_CPUS; i++ )
+        shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
+
+    shared_info->n_vcpu = vcpus;
+    printf(" VCPUS:         %d\n", shared_info->n_vcpu);
+
+    munmap(shared_info, PAGE_SIZE);
+
+    fprintf(stderr, "setup_guest: finish_mmu_updates\n");
+    /* Send the page update requests down to the hypervisor. */
+    if ( finish_mmu_updates(xc_handle, mmu) )
+        goto error_out;
+
+    free(mmu);
+    free(page_array);
+
+    *pvsi = vstartinfo_start;
+    *pvke = dsi.v_kernentry;
+
+    fprintf(stderr, "setup_guest: done!");
+    return 0;
+
+ error_out:
+    if ( mmu != NULL )
+        free(mmu);
+    if ( page_array != NULL )
+        free(page_array);
+    return -1;
+}
+
+int xc_linuxtranslate_build(int xc_handle,
+                   u32 domid,
+                   const char *image_name,
+                   const char *ramdisk_name,
+                   const char *cmdline,
+                   unsigned int control_evtchn,
+                   unsigned long flags,
+                   unsigned int vcpus)
+{
+    dom0_op_t launch_op, op;
+    int initrd_fd = -1;
+    gzFile initrd_gfd = NULL;
+    int rc, i;
+    vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
+    unsigned long nr_pages;
+    char         *image = NULL;
+    unsigned long image_size, initrd_size=0;
+    unsigned long vstartinfo_start, vkern_entry;
+
+    if ( (nr_pages = xc_get_tot_pages(xc_handle, domid)) < 0 )
+    {
+        PERROR("Could not find total pages for domain");
+        goto error_out;
+    }
+
+    if ( (image = xc_read_kernel_image(image_name, &image_size)) == NULL )
+        goto error_out;
+
+    if ( (ramdisk_name != NULL) && (strlen(ramdisk_name) != 0) )
+    {
+        if ( (initrd_fd = open(ramdisk_name, O_RDONLY)) < 0 )
+        {
+            PERROR("Could not open the initial ramdisk image");
+            goto error_out;
+        }
+
+        initrd_size = xc_get_filesz(initrd_fd);
+
+        if ( (initrd_gfd = gzdopen(initrd_fd, "rb")) == NULL )
+        {
+            PERROR("Could not allocate decompression state for initrd");
+            goto error_out;
+        }
+    }
+
+    if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
+    {   
+        PERROR("Unable to mlock ctxt");
+        return 1;
+    }
+
+    op.cmd = DOM0_GETDOMAININFO;
+    op.u.getdomaininfo.domain = (domid_t)domid;
+    if ( (do_dom0_op(xc_handle, &op) < 0) || 
+         ((u16)op.u.getdomaininfo.domain != domid) )
+    {
+        PERROR("Could not get info on domain");
+        goto error_out;
+    }
+
+    if ( xc_domain_get_vcpu_context(xc_handle, domid, 0, ctxt) )
+    {
+        PERROR("Could not get vcpu context");
+        goto error_out;
+    }
+
+    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
+         (ctxt->pt_base != 0) )
+    {
+        ERROR("Domain is already constructed");
+        goto error_out;
+    }
+
+    if ( setup_guest(xc_handle, domid, image, image_size, 
+                       initrd_gfd, initrd_size, nr_pages, 
+                       &vstartinfo_start, &vkern_entry,
+                       ctxt, cmdline,
+                       op.u.getdomaininfo.shared_info_frame,
+                       control_evtchn, flags, vcpus) < 0 )
+    {
+        ERROR("Error constructing guest OS");
+        goto error_out;
+    }
+
+    if ( initrd_fd >= 0 )
+        close(initrd_fd);
+    if ( initrd_gfd )
+        gzclose(initrd_gfd);
+    if ( image != NULL )
+        free(image);
+
+    ctxt->flags = 0;
+
+    /*
+     * Initial register values:
+     *  DS,ES,FS,GS = FLAT_KERNEL_DS
+     *       CS:EIP = FLAT_KERNEL_CS:start_pc
+     *       SS:ESP = FLAT_KERNEL_DS:start_stack
+     *          ESI = start_info
+     *  [EAX,EBX,ECX,EDX,EDI,EBP are zero]
+     *       EFLAGS = IF | 2 (bit 1 is reserved and should always be 1)
+     */
+    ctxt->user_regs.ds = FLAT_KERNEL_DS;
+    ctxt->user_regs.es = FLAT_KERNEL_DS;
+    ctxt->user_regs.fs = FLAT_KERNEL_DS;
+    ctxt->user_regs.gs = FLAT_KERNEL_DS;
+    ctxt->user_regs.ss = FLAT_KERNEL_DS;
+    ctxt->user_regs.cs = FLAT_KERNEL_CS;
+    ctxt->user_regs.eip = vkern_entry;
+    ctxt->user_regs.esp = vstartinfo_start + 2*PAGE_SIZE;
+    ctxt->user_regs.esi = vstartinfo_start;
+    ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */
+
+    /* FPU is set up to default initial state. */
+    memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
+
+    /* Virtual IDT is empty at start-of-day. */
+    for ( i = 0; i < 256; i++ )
+    {
+        ctxt->trap_ctxt[i].vector = i;
+        ctxt->trap_ctxt[i].cs     = FLAT_KERNEL_CS;
+    }
+
+    /* No LDT. */
+    ctxt->ldt_ents = 0;
+    
+    /* Use the default Xen-provided GDT. */
+    ctxt->gdt_ents = 0;
+
+    /* Ring 1 stack is the initial stack. */
+    ctxt->kernel_ss = FLAT_KERNEL_DS;
+    ctxt->kernel_sp = vstartinfo_start + 2*PAGE_SIZE;
+
+    /* No debugging. */
+    memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg));
+
+    /* No callback handlers. */
+#if defined(__i386__)
+    ctxt->event_callback_cs     = FLAT_KERNEL_CS;
+    ctxt->event_callback_eip    = 0;
+    ctxt->failsafe_callback_cs  = FLAT_KERNEL_CS;
+    ctxt->failsafe_callback_eip = 0;
+#elif defined(__x86_64__)
+    ctxt->event_callback_eip    = 0;
+    ctxt->failsafe_callback_eip = 0;
+    ctxt->syscall_callback_eip  = 0;
+#endif
+
+    memset( &launch_op, 0, sizeof(launch_op) );
+
+    launch_op.u.setdomaininfo.domain = (domid_t)domid;
+    launch_op.u.setdomaininfo.vcpu   = 0;
+    launch_op.u.setdomaininfo.ctxt   = ctxt;
+
+    launch_op.cmd = DOM0_SETDOMAININFO;
+    rc = do_dom0_op(xc_handle, &launch_op);
+    
+    return rc;
+
+ error_out:
+    if ( initrd_gfd != NULL )
+        gzclose(initrd_gfd);
+    else if ( initrd_fd >= 0 )
+        close(initrd_fd);
+    if ( image != NULL )
+        free(image);
+
+    return -1;
+}
+
+static inline int is_loadable_phdr(Elf_Phdr *phdr)
+{
+    return ((phdr->p_type == PT_LOAD) &&
+            ((phdr->p_flags & (PF_W|PF_X)) != 0));
+}
+
+static int parseelfimage(char *elfbase, 
+                         unsigned long elfsize,
+                         struct domain_setup_info *dsi)
+{
+    Elf_Ehdr *ehdr = (Elf_Ehdr *)elfbase;
+    Elf_Phdr *phdr;
+    Elf_Shdr *shdr;
+    unsigned long kernstart = ~0UL, kernend=0UL;
+    char *shstrtab, *guestinfo=NULL, *p;
+    int h;
+
+    if ( !IS_ELF(*ehdr) )
+    {
+        ERROR("Kernel image does not have an ELF header.");
+        return -EINVAL;
+    }
+
+    if ( (ehdr->e_phoff + (ehdr->e_phnum * ehdr->e_phentsize)) > elfsize )
+    {
+        ERROR("ELF program headers extend beyond end of image.");
+        return -EINVAL;
+    }
+
+    if ( (ehdr->e_shoff + (ehdr->e_shnum * ehdr->e_shentsize)) > elfsize )
+    {
+        ERROR("ELF section headers extend beyond end of image.");
+        return -EINVAL;
+    }
+
+    /* Find the section-header strings table. */
+    if ( ehdr->e_shstrndx == SHN_UNDEF )
+    {
+        ERROR("ELF image has no section-header strings table (shstrtab).");
+        return -EINVAL;
+    }
+    shdr = (Elf_Shdr *)(elfbase + ehdr->e_shoff + 
+                        (ehdr->e_shstrndx*ehdr->e_shentsize));
+    shstrtab = elfbase + shdr->sh_offset;
+    
+    /* Find the special '__xen_guest' section and check its contents. */
+    for ( h = 0; h < ehdr->e_shnum; h++ )
+    {
+        shdr = (Elf_Shdr *)(elfbase + ehdr->e_shoff + (h*ehdr->e_shentsize));
+        if ( strcmp(&shstrtab[shdr->sh_name], "__xen_guest") != 0 )
+            continue;
+
+        guestinfo = elfbase + shdr->sh_offset;
+
+        if ( (strstr(guestinfo, "LOADER=generic") == NULL) &&
+             (strstr(guestinfo, "GUEST_OS=linux") == NULL) )
+        {
+            ERROR("Will only load images built for the generic loader "
+                  "or Linux images");
+            ERROR("Actually saw: '%s'", guestinfo);
+            return -EINVAL;
+        }
+
+        if ( (strstr(guestinfo, "XEN_VER=3.0") == NULL) )
+        {
+            ERROR("Will only load images built for Xen v3.0");
+            ERROR("Actually saw: '%s'", guestinfo);
+            return -EINVAL;
+        }
+
+        break;
+    }
+    if ( guestinfo == NULL )
+    {
+        ERROR("Not a Xen-ELF image: '__xen_guest' section not found.");
+        return -EINVAL;
+    }
+
+    for ( h = 0; h < ehdr->e_phnum; h++ ) 
+    {
+        phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
+        if ( !is_loadable_phdr(phdr) )
+            continue;
+        if ( phdr->p_paddr < kernstart )
+            kernstart = phdr->p_paddr;
+        if ( (phdr->p_paddr + phdr->p_memsz) > kernend )
+            kernend = phdr->p_paddr + phdr->p_memsz;
+    }
+
+    if ( (kernstart > kernend) || 
+         (ehdr->e_entry < kernstart) || 
+         (ehdr->e_entry > kernend) )
+    {
+        ERROR("Malformed ELF image.");
+        return -EINVAL;
+    }
+
+    dsi->v_start = kernstart;
+    if ( (p = strstr(guestinfo, "VIRT_BASE=")) != NULL )
+        dsi->v_start = strtoul(p+10, &p, 0);
+
+    if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
+        dsi->load_symtab = 1;
+
+    dsi->v_kernstart = kernstart;
+    dsi->v_kernend   = kernend;
+    dsi->v_kernentry = ehdr->e_entry;
+    dsi->v_end       = dsi->v_kernend;
+
+    loadelfsymtab(elfbase, 0, 0, NULL, dsi);
+
+    return 0;
+}
+
+static int
+loadelfimage(
+    char *elfbase, int xch, u32 dom, unsigned long *parray,
+    struct domain_setup_info *dsi)
+{
+    Elf_Ehdr *ehdr = (Elf_Ehdr *)elfbase;
+    Elf_Phdr *phdr;
+    int h;
+
+    char         *va;
+    unsigned long pa, done, chunksz;
+
+    for ( h = 0; h < ehdr->e_phnum; h++ ) 
+    {
+        phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
+        if ( !is_loadable_phdr(phdr) )
+            continue;
+        
+        for ( done = 0; done < phdr->p_filesz; done += chunksz )
+        {
+            pa = (phdr->p_paddr + done) - dsi->v_start;
+            va = xc_map_foreign_range(
+                xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]);
+            chunksz = phdr->p_filesz - done;
+            if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) )
+                chunksz = PAGE_SIZE - (pa & (PAGE_SIZE-1));
+            memcpy(va + (pa & (PAGE_SIZE-1)),
+                   elfbase + phdr->p_offset + done, chunksz);
+            munmap(va, PAGE_SIZE);
+        }
+
+        for ( ; done < phdr->p_memsz; done += chunksz )
+        {
+            pa = (phdr->p_paddr + done) - dsi->v_start;
+            va = xc_map_foreign_range(
+                xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]);
+            chunksz = phdr->p_memsz - done;
+            if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) )
+                chunksz = PAGE_SIZE - (pa & (PAGE_SIZE-1));
+            memset(va + (pa & (PAGE_SIZE-1)), 0, chunksz);
+            munmap(va, PAGE_SIZE);
+        }
+    }
+
+    loadelfsymtab(elfbase, xch, dom, parray, dsi);
+
+    return 0;
+}
+
+#define ELFROUND (ELFSIZE / 8)
+
+static int
+loadelfsymtab(
+    char *elfbase, int xch, u32 dom, unsigned long *parray,
+    struct domain_setup_info *dsi)
+{
+    Elf_Ehdr *ehdr = (Elf_Ehdr *)elfbase, *sym_ehdr;
+    Elf_Shdr *shdr;
+    unsigned long maxva, symva;
+    char *p;
+    int h, i;
+
+    if ( !dsi->load_symtab )
+        return 0;
+
+    p = malloc(sizeof(int) + sizeof(Elf_Ehdr) +
+               ehdr->e_shnum * sizeof(Elf_Shdr));
+    if (p == NULL)
+        return 0;
+
+    maxva = (dsi->v_kernend + ELFROUND - 1) & ~(ELFROUND - 1);
+    symva = maxva;
+    maxva += sizeof(int);
+    dsi->symtab_addr = maxva;
+    dsi->symtab_len = 0;
+    maxva += sizeof(Elf_Ehdr) + ehdr->e_shnum * sizeof(Elf_Shdr);
+    maxva = (maxva + ELFROUND - 1) & ~(ELFROUND - 1);
+
+    shdr = (Elf_Shdr *)(p + sizeof(int) + sizeof(Elf_Ehdr));
+    memcpy(shdr, elfbase + ehdr->e_shoff, ehdr->e_shnum * sizeof(Elf_Shdr));
+
+    for ( h = 0; h < ehdr->e_shnum; h++ ) 
+    {
+        if ( shdr[h].sh_type == SHT_STRTAB )
+        {
+            /* Look for a strtab @i linked to symtab @h. */
+            for ( i = 0; i < ehdr->e_shnum; i++ )
+                if ( (shdr[i].sh_type == SHT_SYMTAB) &&
+                     (shdr[i].sh_link == h) )
+                    break;
+            /* Skip symtab @h if we found no corresponding strtab @i. */
+            if ( i == ehdr->e_shnum )
+            {
+                shdr[h].sh_offset = 0;
+                continue;
+            }
+        }
+
+        if ( (shdr[h].sh_type == SHT_STRTAB) ||
+             (shdr[h].sh_type == SHT_SYMTAB) )
+        {
+            if ( parray != NULL )
+                xc_map_memcpy(maxva, elfbase + shdr[h].sh_offset, shdr[h].sh_size,
+                           xch, dom, parray, dsi->v_start);
+
+            /* Mangled to be based on ELF header location. */
+            shdr[h].sh_offset = maxva - dsi->symtab_addr;
+
+            dsi->symtab_len += shdr[h].sh_size;
+            maxva += shdr[h].sh_size;
+            maxva = (maxva + ELFROUND - 1) & ~(ELFROUND - 1);
+        }
+
+        shdr[h].sh_name = 0;  /* Name is NULL. */
+    }
+
+    if ( dsi->symtab_len == 0 )
+    {
+        dsi->symtab_addr = 0;
+        goto out;
+    }
+
+    if ( parray != NULL )
+    {
+        *(int *)p = maxva - dsi->symtab_addr;
+        sym_ehdr = (Elf_Ehdr *)(p + sizeof(int));
+        memcpy(sym_ehdr, ehdr, sizeof(Elf_Ehdr));
+        sym_ehdr->e_phoff = 0;
+        sym_ehdr->e_shoff = sizeof(Elf_Ehdr);
+        sym_ehdr->e_phentsize = 0;
+        sym_ehdr->e_phnum = 0;
+        sym_ehdr->e_shstrndx = SHN_UNDEF;
+
+        /* Copy total length, crafted ELF header and section header table */
+        xc_map_memcpy(symva, p, sizeof(int) + sizeof(Elf_Ehdr) +
+                   ehdr->e_shnum * sizeof(Elf_Shdr), xch, dom, parray,
+                   dsi->v_start);
+    }
+
+    dsi->symtab_len = maxva - dsi->symtab_addr;
+    dsi->v_end = round_pgup(maxva);
+
+ out:
+    if ( p != NULL )
+        free(p);
+
+    return 0;
+}
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/python/xen/lowlevel/xc/xc.c xeno-ft/tools/python/xen/lowlevel/xc/xc.c
--- xen-unstable.latest/tools/python/xen/lowlevel/xc/xc.c	2005-05-31 08:28:29.000000000 -0400
+++ xeno-ft/tools/python/xen/lowlevel/xc/xc.c	2005-06-04 17:00:20.000000000 -0400
@@ -280,6 +280,33 @@
     return zero;
 }
 
+static PyObject *pyxc_linuxtranslate_build(PyObject *self,
+                                  PyObject *args,
+                                  PyObject *kwds)
+{
+    XcObject *xc = (XcObject *)self;
+
+    u32   dom;
+    char *image, *ramdisk = NULL, *cmdline = "";
+    int   control_evtchn, flags = 0, vcpus = 1;
+
+    static char *kwd_list[] = { "dom", "control_evtchn", 
+                                "image", "ramdisk", "cmdline", "flags", "vcpus",
+                                NULL };
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|ssii", kwd_list, 
+                                      &dom, &control_evtchn, 
+                                      &image, &ramdisk, &cmdline, &flags, &vcpus) )
+        return NULL;
+
+    if ( xc_linuxtranslate_build(xc->xc_handle, dom, image,
+                        ramdisk, cmdline, control_evtchn, flags, vcpus) != 0 )
+        return PyErr_SetFromErrno(xc_error);
+    
+    Py_INCREF(zero);
+    return zero;
+}
+
 static PyObject *pyxc_plan9_build(PyObject *self,
                                   PyObject *args,
                                   PyObject *kwds)
@@ -922,6 +949,17 @@
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
+    { "linuxtranslate_build", 
+      (PyCFunction)pyxc_linuxtranslate_build, 
+      METH_VARARGS | METH_KEYWORDS, "\n"
+      "Build a new shadow-translated Linux guest OS.\n"
+      " dom     [int]:      Identifier of domain to build into.\n"
+      " image   [str]:      Name of kernel image file. May be gzipped.\n"
+      " ramdisk [str, n/a]: Name of ramdisk file, if any.\n"
+      " cmdline [str, n/a]: Kernel parameters, if any.\n\n"
+      " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
+      "Returns: [int] 0 on success; -1 on error.\n" },
+
     { "plan9_build",
       (PyCFunction)pyxc_plan9_build,
       METH_VARARGS | METH_KEYWORDS, "\n"
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/python/xen/xend/XendDomainInfo.py xeno-ft/tools/python/xen/xend/XendDomainInfo.py
--- xen-unstable.latest/tools/python/xen/xend/XendDomainInfo.py	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft/tools/python/xen/xend/XendDomainInfo.py	2005-06-04 17:09:24.000000000 -0400
@@ -1114,6 +1114,30 @@
     vm.create_domain("linux", kernel, ramdisk, cmdline)
     return vm
 
+def vm_image_linuxtranslate(vm, image):
+    """Create a VM for a shaodw translate linux image.
+
+    @param name:      vm name
+    @param memory:    vm memory
+    @param image:     image config
+    @return: vm
+    """
+    kernel = sxp.child_value(image, "kernel")
+    cmdline = ""
+    ip = sxp.child_value(image, "ip", None)
+    if ip:
+        cmdline += " ip=" + ip
+    root = sxp.child_value(image, "root")
+    if root:
+        cmdline += " root=" + root
+    args = sxp.child_value(image, "args")
+    if args:
+        cmdline += " " + args
+    ramdisk = sxp.child_value(image, "ramdisk", '')
+    log.debug("creating translated linux domain with cmdline: %s" %(cmdline,))
+    vm.create_domain("linuxtranslate", kernel, ramdisk, cmdline)
+    return vm
+
 def vm_image_plan9(vm, image):
     """Create a VM for a Plan 9 image.
 
@@ -1197,6 +1221,7 @@
 #============================================================================
 # Register image handlers.
 add_image_handler('linux', vm_image_linux)
+add_image_handler('linuxtranslate', vm_image_linuxtranslate)
 add_image_handler('plan9', vm_image_plan9)
 add_image_handler('vmx',   vm_image_vmx)
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/arch/x86/mm.c xeno-ft/xen/arch/x86/mm.c
--- xen-unstable.latest/xen/arch/x86/mm.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/xen/arch/x86/mm.c	2005-06-04 18:14:41.000000000 -0400
@@ -446,7 +446,8 @@
 
     if ( unlikely(l1e_get_flags(l1e) & L1_DISALLOW_MASK) )
     {
-        MEM_LOG("Bad L1 flags %x\n", l1e_get_flags(l1e) & L1_DISALLOW_MASK);
+        MEM_LOG("Bad L1 flags %x (%lx)\n", l1e_get_flags(l1e) & L1_DISALLOW_MASK,
+			(unsigned long)l1e_get_intpte(l1e));
         return 0;
     }
 
@@ -1695,6 +1696,8 @@
             break;
 
         case MMUEXT_NEW_BASEPTR:
+            if ( shadow_mode_translate(d) )
+                op.mfn = __gpfn_to_mfn(d, op.mfn);
             okay = new_guest_cr3(op.mfn);
             percpu_info[cpu].deferred_ops &= ~DOP_FLUSH_TLB;
             break;
@@ -1807,6 +1810,9 @@
                 okay = 0;
                 break;
             }
+
+            if ( shadow_mode_translate(d) )
+                BUG(); // not supported yet, need to think about this.
             
             e = percpu_info[cpu].foreign;
             if ( unlikely(e == NULL) )
@@ -2431,6 +2437,7 @@
 {
     int nr_pages = (entries + 511) / 512;
     unsigned long frames[16];
+    struct domain* d = current->domain;
     long ret;
 
     if ( copy_from_user(frames, frame_list, nr_pages * sizeof(unsigned long)) )
@@ -2438,6 +2445,18 @@
 
     LOCK_BIGLOCK(current->domain);
 
+    if(shadow_mode_translate(d)) {
+    	int i;
+	unsigned long mfn;
+	shadow_lock(d);
+	for(i=0; i<nr_pages; i++) {
+		mfn = __gpfn_to_mfn(d, frames[i]);
+		printk(" do_set_gdt: pfn %lx to mfn %lx\n", frames[i], mfn);
+		frames[i]=mfn;
+	}
+	shadow_unlock(d);
+    }
+
     if ( (ret = set_gdt(current, frames, entries)) == 0 )
         local_flush_tlb();
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/arch/x86/shadow.c xeno-ft/xen/arch/x86/shadow.c
--- xen-unstable.latest/xen/arch/x86/shadow.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/xen/arch/x86/shadow.c	2005-06-04 18:41:58.000000000 -0400
@@ -632,17 +632,55 @@
             continue;
 
         count = 0;
-        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next )
-            if ( MFN_PINNED(x->smfn) )
-                count++;
+
+        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next ) {
+	    /* Skip entries that are writable_pred) */
+	    switch(x->gpfn_and_flags & PGT_type_mask){
+		case PGT_l1_shadow:
+		case PGT_l2_shadow:
+		case PGT_l3_shadow:
+		case PGT_l4_shadow:
+		case PGT_hl2_shadow:
+		    if ( MFN_PINNED(x->smfn) )
+			count++;
+		    break;
+		case PGT_snapshot:
+		case PGT_writable_pred:
+		    printk(" SKIPPING type %lx\n", 
+		    	x->gpfn_and_flags & PGT_type_mask);
+		    break;
+		default:
+		    BUG();
+
+	    }
+	}
+
         if ( !count )
             continue;
 
         mfn_list = xmalloc_array(unsigned long, count);
         count = 0;
-        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next )
-            if ( MFN_PINNED(x->smfn) )
-                mfn_list[count++] = x->smfn;
+        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next ) {
+	    /* Skip entries that are writable_pred) */
+	    switch(x->gpfn_and_flags & PGT_type_mask){
+		case PGT_l1_shadow:
+		case PGT_l2_shadow:
+		case PGT_l3_shadow:
+		case PGT_l4_shadow:
+		case PGT_hl2_shadow:
+		    if ( MFN_PINNED(x->smfn) )
+			mfn_list[count++] = x->smfn;
+		    break;
+		case PGT_snapshot:
+		case PGT_writable_pred:
+		    printk(" SKIPPING type %lx\n", 
+		    	x->gpfn_and_flags & PGT_type_mask);
+		    break;
+		default:
+		    BUG();
+
+	    }
+	}
 
         while ( count )
         {
@@ -773,6 +811,9 @@
     unsigned long va = pfn << PAGE_SHIFT;
 
     ASSERT( phystab );
+    ASSERT(shadow_lock_is_acquired(d));
+
+    l2 = map_domain_mem_with_cache(phystab, l2cache);
 
     l2 = map_domain_mem_with_cache(phystab, l2cache);
     l2e = l2[l2_table_offset(va)];
@@ -851,6 +892,9 @@
         list_ent = page->list.next;
     }
 
+    unmap_domain_mem_cache(&l2cache);
+    unmap_domain_mem_cache(&l1cache);
+
     destroy_map_domain_mem_cache(&l2cache);
     destroy_map_domain_mem_cache(&l1cache);
 
@@ -1366,7 +1410,7 @@
     case DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE:
         free_shadow_pages(d);
         rc = __shadow_mode_enable(
-            d, d->arch.shadow_mode|SHM_enable|SHM_refcounts|SHM_translate);
+            d, d->arch.shadow_mode|SHM_enable|SHM_refcounts|SHM_translate|SHM_write_all);
         break;
 
     default:
@@ -1420,7 +1464,7 @@
     unmap_domain_mem(l1);
 
 #if 0
-    printk("gpfn_to_mfn_foreign(d->id=%d, gpfn=%lx) => %lx phystab=%lx l2e=%lx l1tab=%lx, l1e=%lx\n",
+    printk("gpfn_to_mfn_foreign(d->domain_id=%d, gpfn=%lx) => %lx phystab=%lx l2e=%lx l1tab=%lx, l1e=%lx\n",
            d->domain_id, gpfn, l1_pgentry_val(l1e) >> PAGE_SHIFT, phystab, l2e, l1tab, l1e);
 #endif
 
@@ -1677,6 +1721,7 @@
     shadow_lock(d);
 
     __shadow_sync_va(v, va);
+    SH_VVLOG("shadow_invlpg va=%lx", va);
 
     // XXX mafetter: will need to think about 4MB pages...
 
@@ -2053,7 +2098,11 @@
         while ( count )
         {
             count--;
+	    /* Delete_shadow_status does a shadow_audit(), so we need to
+	     * keep accurate count of writable_pte_predictions to keep it
+	     * happy. */
             delete_shadow_status(d, gpfn_list[count], 0, PGT_writable_pred);
+	    perfc_decr(writable_pte_predictions);
         }
 
         xfree(gpfn_list);
@@ -2580,6 +2629,8 @@
      * STEP 2. Check the guest PTE.
      */
     __guest_get_l2e(v, va, &gpde);
+    SH_VVLOG("shadow_fault: gpde (0x%lx | 0x%lx)",
+    		(unsigned long)l2e_get_pfn(gpde), (unsigned long)l2e_get_flags(gpde));
     if ( unlikely(!(l2e_get_flags(gpde) & _PAGE_PRESENT)) )
     {
         SH_VVLOG("shadow_fault - EXIT: L1 not present");
@@ -2595,7 +2646,7 @@
     if ( unlikely(!(l1e_get_flags(gpte) & _PAGE_PRESENT)) )
     {
         SH_VVLOG("shadow_fault - EXIT: gpte not present (%" PRIpte ")",
-                 l1e_get_intpte(gpte));
+                 (unsigned long)l1e_get_intpte(gpte));
         perfc_incrc(shadow_fault_bail_pte_not_present);
         goto fail;
     }
@@ -2607,19 +2658,11 @@
 
         if ( unlikely(!(l1e_get_flags(gpte) & _PAGE_RW)) )
         {
-            if ( shadow_mode_page_writable(d, l1e_get_pfn(gpte)) )
-            {
-                allow_writes = 1;
-                l1e_add_flags(gpte, _PAGE_RW);
-            }
-            else
-            {
                 /* Write fault on a read-only mapping. */
                 SH_VVLOG("shadow_fault - EXIT: wr fault on RO page (%" PRIpte ")", 
-                         l1e_get_intpte(gpte));
+                         (unsigned long)l1e_get_intpte(gpte));
                 perfc_incrc(shadow_fault_bail_ro_mapping);
                 goto fail;
-            }
         }
 
         if ( !l1pte_write_fault(v, &gpte, &spte, va) )
@@ -2693,7 +2736,7 @@
     if ( sl1mfn )
     {
         SH_VVLOG("shadow_l1_normal_pt_update pa=%p, gpte=%" PRIpte,
-                 (void *)pa, l1e_get_intpte(gpte));
+                 (void *)pa, (unsigned long)l1e_get_intpte(gpte));
         l1pte_propagate_from_guest(current->domain, gpte, &spte);
 
         spl1e = map_domain_mem_with_cache(sl1mfn << PAGE_SHIFT, cache);
@@ -2718,7 +2761,7 @@
     if ( sl2mfn )
     {
         SH_VVLOG("shadow_l2_normal_pt_update pa=%p, gpde=%" PRIpte,
-                 (void *)pa, l2e_get_intpte(gpde));
+                 (void *)pa, (unsigned long)l2e_get_intpte(gpde));
         spl2e = map_domain_mem_with_cache(sl2mfn << PAGE_SHIFT, cache);
         validate_pde_change(d, gpde,
                             &spl2e[(pa & ~PAGE_MASK) / sizeof(l2_pgentry_t)]);
@@ -2764,8 +2807,9 @@
     // just everything involved in getting to this L1 (i.e. we need
     // linear_pg_table[l1_linear_offset(va)] to be in sync)...
     //
+    SH_VVLOG("shadow_do_update_va_maping va=%lx, val=%lx)",
+                 va, (unsigned long)l1e_get_intpte(val));
     __shadow_sync_va(v, va);
-
     l1pte_propagate_from_guest(d, val, &spte);
     shadow_set_l1e(va, spte, 0);
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/common/event_channel.c xeno-ft/xen/common/event_channel.c
--- xen-unstable.latest/xen/common/event_channel.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/xen/common/event_channel.c	2005-06-04 18:29:10.000000000 -0400
@@ -61,15 +61,28 @@
 {
     struct evtchn *chn;
     struct domain *d = current->domain;
-    int            port;
+    int            port = alloc->port;
+    int		   dom = alloc->dom;
 
     spin_lock(&d->evtchn_lock);
 
-    if ( (port = get_free_port(d)) >= 0 )
-    {
+    if ( dom == DOMID_SELF )
+        dom = current->domain->domain_id;
+
+    if( port == 0 ) 
+	port = get_free_port(d);
+    else if( port > 0 && port < MAX_EVTCHNS)  {
+    	chn = evtchn_from_port(d, port);
+	if(chn->state != ECS_FREE)
+	    port = -EBUSY;
+    } else {
+	port=-EINVAL;
+    }
+
+    if( port > 0 ) {
         chn = evtchn_from_port(d, port);
         chn->state = ECS_UNBOUND;
-        chn->u.unbound.remote_domid = alloc->dom;
+        chn->u.unbound.remote_domid = dom;
     }
 
     spin_unlock(&d->evtchn_lock);
@@ -81,6 +94,22 @@
     return 0;
 }
 
+/* Allocate a port in domain d, and return its number. */
+int evtchn_alloc_port(struct domain *d)
+{
+    struct evtchn *chn;
+    int r;
+
+    spin_lock(&d->evtchn_lock);
+    r = get_free_port(d);
+    if (r >= 0) {
+    	chn = evtchn_from_port(d, r);
+	chn->state = ECS_UNBOUND;
+        chn->u.unbound.remote_domid = d->domain_id;
+    }
+    spin_unlock(&d->evtchn_lock);
+    return r;
+}
 
 static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind)
 {
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/include/asm-x86/shadow.h xeno-ft/xen/include/asm-x86/shadow.h
--- xen-unstable.latest/xen/include/asm-x86/shadow.h	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/xen/include/asm-x86/shadow.h	2005-06-04 18:44:27.000000000 -0400
@@ -399,7 +399,7 @@
     {
         perfc_incrc(shadow_get_page_fail);
         FSH_LOG("%s failed to get ref l1e=%" PRIpte "\n",
-                __func__, l1e_get_intpte(l1e));
+                __func__, (unsigned long)l1e_get_intpte(l1e));
     }
 
     return res;
@@ -740,7 +740,7 @@
     spte = l1e_from_pfn(gmfn, l1e_get_flags(gpte) & ~_PAGE_GLOBAL);
 
     SH_VVLOG("l1pte_write_fault: updating spte=0x%" PRIpte " gpte=0x%" PRIpte,
-             l1e_get_intpte(spte), l1e_get_intpte(gpte));
+             (unsigned long)l1e_get_intpte(spte), (unsigned long)l1e_get_intpte(gpte));
 
     if ( shadow_mode_log_dirty(d) )
         __mark_dirty(d, gmfn);
@@ -779,7 +779,7 @@
     }
 
     SH_VVLOG("l1pte_read_fault: updating spte=0x%" PRIpte " gpte=0x%" PRIpte,
-             l1e_get_intpte(spte), l1e_get_intpte(gpte));
+             (unsigned long)l1e_get_intpte(spte), (unsigned long)l1e_get_intpte(gpte));
     *gpte_p = gpte;
     *spte_p = spte;
 
@@ -811,7 +811,9 @@
 
     if ( l1e_get_intpte(spte) || l1e_get_intpte(gpte) )
         SH_VVVLOG("%s: gpte=%" PRIpte ", new spte=%" PRIpte,
-                  __func__, l1e_get_intpte(gpte), l1e_get_intpte(spte));
+                  __func__, 
+		  (unsigned long)l1e_get_intpte(gpte), 
+		  (unsigned long)l1e_get_intpte(spte));
 
     *spte_p = spte;
 }
@@ -845,7 +847,7 @@
 
     if ( l1e_get_intpte(hl2e) || l2e_get_intpte(gpde) )
         SH_VVLOG("%s: gpde=%" PRIpte " hl2e=%" PRIpte, __func__,
-                 l2e_get_intpte(gpde), l1e_get_intpte(hl2e));
+                 (unsigned long)l2e_get_intpte(gpde), (unsigned long)l1e_get_intpte(hl2e));
 
     *hl2e_p = hl2e;
 }
@@ -874,7 +876,7 @@
 
     if ( l2e_get_intpte(spde) || l2e_get_intpte(gpde) )
         SH_VVLOG("%s: gpde=%" PRIpte ", new spde=%" PRIpte, __func__,
-                 l2e_get_intpte(gpde), l2e_get_intpte(spde));
+                 (unsigned long)l2e_get_intpte(gpde), (unsigned long)l2e_get_intpte(spde));
 
     *spde_p = spde;
 }
@@ -1038,6 +1040,21 @@
 {
     int live = 0, free = 0, j = 0, abs;
     struct shadow_status *a;
+    int live_shadow_l1_pages,
+        live_shadow_l2_pages,
+        live_shadow_l3_pages,
+        live_shadow_l4_pages,
+        live_hl2_table_pages,
+        live_snapshot_pages,
+        live_writable_pte_predictions;
+
+    live_shadow_l1_pages=
+        live_shadow_l2_pages=
+        live_shadow_l3_pages=
+        live_shadow_l4_pages=
+        live_hl2_table_pages=
+        live_snapshot_pages=
+        live_writable_pte_predictions=0;
 
     for ( j = 0; j < shadow_ht_buckets; j++ )
     {
@@ -1045,11 +1062,37 @@
         if ( a->gpfn_and_flags )
         {
             live++;
+	    switch(a->gpfn_and_flags & PGT_type_mask) {
+	       	case PGT_l1_shadow:
+		    live_shadow_l1_pages++;
+	    	    break;
+	       	case PGT_l2_shadow:
+		    live_shadow_l2_pages++;
+	    	    break;
+	       	case PGT_l3_shadow:
+		    live_shadow_l3_pages++;
+	    	    break;
+	       	case PGT_l4_shadow:
+		    live_shadow_l4_pages++;
+	    	    break;
+	       	case PGT_hl2_shadow:
+		    live_hl2_table_pages++;
+	    	    break;
+	       	case PGT_snapshot:
+		    live_snapshot_pages++;
+	    	    break;
+	       	case PGT_writable_pred:
+		    live_writable_pte_predictions++;
+	    	    break;
+	       	default:
+	    		BUG();
+	    }
             ASSERT(a->smfn);
         }
         else
             ASSERT(!a->next);
 
+
         a = a->next;
         while ( a && (live < 9999) )
         { 
@@ -1060,6 +1103,31 @@
                        live, a->gpfn_and_flags, a->smfn, a->next);
                 BUG();
             }
+	    switch(a->gpfn_and_flags & PGT_type_mask) {
+	       	case PGT_l1_shadow:
+		    live_shadow_l1_pages++;
+	    	    break;
+	       	case PGT_l2_shadow:
+		    live_shadow_l2_pages++;
+	    	    break;
+	       	case PGT_l3_shadow:
+		    live_shadow_l3_pages++;
+	    	    break;
+	       	case PGT_l4_shadow:
+		    live_shadow_l4_pages++;
+	    	    break;
+	       	case PGT_hl2_shadow:
+		    live_hl2_table_pages++;
+	    	    break;
+	       	case PGT_snapshot:
+		    live_snapshot_pages++;
+	    	    break;
+	       	case PGT_writable_pred:
+		    live_writable_pte_predictions++;
+	    	    break;
+	       	default:
+	    		BUG();
+	    }
             ASSERT(a->smfn);
             a = a->next; 
         }
@@ -1085,13 +1153,21 @@
 #ifdef PERF_COUNTERS
     if ( (abs < -1) || (abs > 1) )
     {
-        printk("live=%d free=%d l1=%d l2=%d hl2=%d snapshot=%d writable_ptes=%d\n",
+        printk("live=%d free=%d l1=%d l2=%d hl2=%d snapshot=%d writable_pred=%d\n",
                live, free,
                perfc_value(shadow_l1_pages),
                perfc_value(shadow_l2_pages),
                perfc_value(hl2_table_pages),
                perfc_value(snapshot_pages),
                perfc_value(writable_pte_predictions));
+        printk("counted: l1=%d l2=%d l3=%d l4=%d hl2=%d snapshot=%d writable_pred=%d\n",
+               live_shadow_l1_pages,
+               live_shadow_l2_pages,
+               live_shadow_l3_pages,
+               live_shadow_l4_pages,
+               live_hl2_table_pages,
+               live_snapshot_pages,
+               live_writable_pte_predictions);
         BUG();
     }
 #endif
@@ -1194,7 +1270,7 @@
 #ifndef NDEBUG
         if ( ___shadow_status(d, gpfn, stype) != 0 )
         {
-            printk("d->id=%d gpfn=%lx gmfn=%lx stype=%lx c=%x t=%x "
+            printk("d->domain_id=%d gpfn=%lx gmfn=%lx stype=%lx c=%x t=%x "
                    "mfn_out_of_sync(gmfn)=%d mfn_is_page_table(gmfn)=%d\n",
                    d->domain_id, gpfn, gmfn, stype,
                    frame_table[gmfn].count_info,
@@ -1441,7 +1517,8 @@
             if ( stype != PGT_writable_pred )
                 BUG(); // we should never replace entries into the hash table
             x->smfn = smfn;
-            put_page(pfn_to_page(gmfn)); // already had a ref...
+            if ( stype != PGT_writable_pred )
+                put_page(pfn_to_page(gmfn)); // already had a ref...
             goto done;
         }
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/include/asm-x86/x86_32/domain_page.h xeno-ft/xen/include/asm-x86/x86_32/domain_page.h
--- xen-unstable.latest/xen/include/asm-x86/x86_32/domain_page.h	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/xen/include/asm-x86/x86_32/domain_page.h	2005-06-04 18:14:41.000000000 -0400
@@ -77,4 +77,16 @@
     }
 }
 
+#define MAP_DOM_MEM_CACHE_INIT { .pa = 0 }
+
+static inline void
+unmap_domain_mem_cache(struct map_dom_mem_cache *cache)
+{
+    if ( likely(cache != NULL) && likely(cache->pa) )
+    {
+        unmap_domain_mem(cache->va);
+        cache->pa = 0;
+    }
+}
+
 #endif /* __ASM_DOMAIN_PAGE_H__ */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 10%]

* [PATCH] Full shadow translate mode (round 2)
@ 2005-06-06 21:41 11% George Washington Dunlap III
  0 siblings, 0 replies; 200+ results
From: George Washington Dunlap III @ 2005-06-06 21:41 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1126 bytes --]

OK, here's round two.  I divided the patches up into three parts:

  hypervisor: fixes to the hypervisor (mostly shadow.c) so that it knows 
how to handle fully translated guests properly.

  builder: adds the "linuxtranslate" builder, which will build a full 
translated domains. (Updated since yesterday to more closely parallel the 
normal linux builder.)

  domU: adds "CONFIG_XEN_SHADOW_MODE" option, which allows a domU to run in 
full translate mode.  This basically disables access to the m2p table, and 
disables the mm_pin optimizations. (Not compatible yet, not sure why.)

Each of these patches should be able to be applied independently.

Peace,
  -George

+-------------------+----------------------------------------
| dunlapg@umich.edu | http://www-personal.umich.edu/~dunlapg 
+-------------------+----------------------------------------
|  Who could move a mountain, who could love their enemy?
|  Who could rejoice in pain, and turn the other cheek?
|	- Rich Mullins, "Surely God is With Us"
+------------------------------------------------------------
| Outlaw Junk Email! Support HR 1748 (www.cauce.org)

[-- Attachment #2: Type: TEXT/PLAIN, Size: 11703 bytes --]

diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/arch/x86/mm.c xeno-ft/xen/arch/x86/mm.c
--- xen-unstable.latest/xen/arch/x86/mm.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/xen/arch/x86/mm.c	2005-06-06 11:07:01.000000000 -0400
@@ -1695,6 +1695,8 @@
             break;
 
         case MMUEXT_NEW_BASEPTR:
+            if ( shadow_mode_translate(d) )
+                op.mfn = __gpfn_to_mfn(d, op.mfn);
             okay = new_guest_cr3(op.mfn);
             percpu_info[cpu].deferred_ops &= ~DOP_FLUSH_TLB;
             break;
@@ -1807,6 +1809,9 @@
                 okay = 0;
                 break;
             }
+
+            if ( shadow_mode_translate(d) )
+                BUG(); // not supported yet, need to think about this.
             
             e = percpu_info[cpu].foreign;
             if ( unlikely(e == NULL) )
@@ -2431,6 +2436,7 @@
 {
     int nr_pages = (entries + 511) / 512;
     unsigned long frames[16];
+    struct domain* d = current->domain;
     long ret;
 
     if ( copy_from_user(frames, frame_list, nr_pages * sizeof(unsigned long)) )
@@ -2438,6 +2444,18 @@
 
     LOCK_BIGLOCK(current->domain);
 
+    if(shadow_mode_translate(d)) {
+    	int i;
+	unsigned long mfn;
+	shadow_lock(d);
+	for(i=0; i<nr_pages; i++) {
+		mfn = __gpfn_to_mfn(d, frames[i]);
+		printk(" do_set_gdt: pfn %lx to mfn %lx\n", frames[i], mfn);
+		frames[i]=mfn;
+	}
+	shadow_unlock(d);
+    }
+
     if ( (ret = set_gdt(current, frames, entries)) == 0 )
         local_flush_tlb();
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/arch/x86/shadow.c xeno-ft/xen/arch/x86/shadow.c
--- xen-unstable.latest/xen/arch/x86/shadow.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/xen/arch/x86/shadow.c	2005-06-06 17:28:48.000000000 -0400
@@ -632,17 +632,55 @@
             continue;
 
         count = 0;
-        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next )
-            if ( MFN_PINNED(x->smfn) )
-                count++;
+
+        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next ) {
+	    /* Skip entries that are writable_pred) */
+	    switch(x->gpfn_and_flags & PGT_type_mask){
+		case PGT_l1_shadow:
+		case PGT_l2_shadow:
+		case PGT_l3_shadow:
+		case PGT_l4_shadow:
+		case PGT_hl2_shadow:
+		    if ( MFN_PINNED(x->smfn) )
+			count++;
+		    break;
+		case PGT_snapshot:
+		case PGT_writable_pred:
+		    printk(" SKIPPING type %lx\n", 
+		    	x->gpfn_and_flags & PGT_type_mask);
+		    break;
+		default:
+		    BUG();
+
+	    }
+	}
+
         if ( !count )
             continue;
 
         mfn_list = xmalloc_array(unsigned long, count);
         count = 0;
-        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next )
-            if ( MFN_PINNED(x->smfn) )
-                mfn_list[count++] = x->smfn;
+        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next ) {
+	    /* Skip entries that are writable_pred) */
+	    switch(x->gpfn_and_flags & PGT_type_mask){
+		case PGT_l1_shadow:
+		case PGT_l2_shadow:
+		case PGT_l3_shadow:
+		case PGT_l4_shadow:
+		case PGT_hl2_shadow:
+		    if ( MFN_PINNED(x->smfn) )
+			mfn_list[count++] = x->smfn;
+		    break;
+		case PGT_snapshot:
+		case PGT_writable_pred:
+		    printk(" SKIPPING type %lx\n", 
+		    	x->gpfn_and_flags & PGT_type_mask);
+		    break;
+		default:
+		    BUG();
+
+	    }
+	}
 
         while ( count )
         {
@@ -773,6 +811,9 @@
     unsigned long va = pfn << PAGE_SHIFT;
 
     ASSERT( phystab );
+    ASSERT(shadow_lock_is_acquired(d));
+
+    l2 = map_domain_mem_with_cache(phystab, l2cache);
 
     l2 = map_domain_mem_with_cache(phystab, l2cache);
     l2e = l2[l2_table_offset(va)];
@@ -1366,7 +1407,7 @@
     case DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE:
         free_shadow_pages(d);
         rc = __shadow_mode_enable(
-            d, d->arch.shadow_mode|SHM_enable|SHM_refcounts|SHM_translate);
+            d, d->arch.shadow_mode|SHM_enable|SHM_refcounts|SHM_translate|SHM_write_all);
         break;
 
     default:
@@ -1420,7 +1461,7 @@
     unmap_domain_mem(l1);
 
 #if 0
-    printk("gpfn_to_mfn_foreign(d->id=%d, gpfn=%lx) => %lx phystab=%lx l2e=%lx l1tab=%lx, l1e=%lx\n",
+    printk("gpfn_to_mfn_foreign(d->domain_id=%d, gpfn=%lx) => %lx phystab=%lx l2e=%lx l1tab=%lx, l1e=%lx\n",
            d->domain_id, gpfn, l1_pgentry_val(l1e) >> PAGE_SHIFT, phystab, l2e, l1tab, l1e);
 #endif
 
@@ -1677,6 +1718,7 @@
     shadow_lock(d);
 
     __shadow_sync_va(v, va);
+    SH_VVLOG("shadow_invlpg va=%lx", va);
 
     // XXX mafetter: will need to think about 4MB pages...
 
@@ -2053,7 +2095,11 @@
         while ( count )
         {
             count--;
+	    /* Delete_shadow_status does a shadow_audit(), so we need to
+	     * keep accurate count of writable_pte_predictions to keep it
+	     * happy. */
             delete_shadow_status(d, gpfn_list[count], 0, PGT_writable_pred);
+	    perfc_decr(writable_pte_predictions);
         }
 
         xfree(gpfn_list);
@@ -2580,6 +2626,7 @@
      * STEP 2. Check the guest PTE.
      */
     __guest_get_l2e(v, va, &gpde);
+    SH_VVLOG("shadow_fault: gpde=%" PRIpte, l2e_get_intpte(gpde));
     if ( unlikely(!(l2e_get_flags(gpde) & _PAGE_PRESENT)) )
     {
         SH_VVLOG("shadow_fault - EXIT: L1 not present");
@@ -2607,19 +2654,11 @@
 
         if ( unlikely(!(l1e_get_flags(gpte) & _PAGE_RW)) )
         {
-            if ( shadow_mode_page_writable(d, l1e_get_pfn(gpte)) )
-            {
-                allow_writes = 1;
-                l1e_add_flags(gpte, _PAGE_RW);
-            }
-            else
-            {
                 /* Write fault on a read-only mapping. */
                 SH_VVLOG("shadow_fault - EXIT: wr fault on RO page (%" PRIpte ")", 
                          l1e_get_intpte(gpte));
                 perfc_incrc(shadow_fault_bail_ro_mapping);
                 goto fail;
-            }
         }
 
         if ( !l1pte_write_fault(v, &gpte, &spte, va) )
@@ -2764,8 +2803,9 @@
     // just everything involved in getting to this L1 (i.e. we need
     // linear_pg_table[l1_linear_offset(va)] to be in sync)...
     //
+    SH_VVLOG("shadow_do_update_va_maping va=%lx, val=%" PRIpte ")",
+                 va, l1e_get_intpte(val));
     __shadow_sync_va(v, va);
-
     l1pte_propagate_from_guest(d, val, &spte);
     shadow_set_l1e(va, spte, 0);
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/include/asm-x86/shadow.h xeno-ft/xen/include/asm-x86/shadow.h
--- xen-unstable.latest/xen/include/asm-x86/shadow.h	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/xen/include/asm-x86/shadow.h	2005-06-06 11:06:17.000000000 -0400
@@ -1038,6 +1038,21 @@
 {
     int live = 0, free = 0, j = 0, abs;
     struct shadow_status *a;
+    int live_shadow_l1_pages,
+        live_shadow_l2_pages,
+        live_shadow_l3_pages,
+        live_shadow_l4_pages,
+        live_hl2_table_pages,
+        live_snapshot_pages,
+        live_writable_pte_predictions;
+
+    live_shadow_l1_pages=
+        live_shadow_l2_pages=
+        live_shadow_l3_pages=
+        live_shadow_l4_pages=
+        live_hl2_table_pages=
+        live_snapshot_pages=
+        live_writable_pte_predictions=0;
 
     for ( j = 0; j < shadow_ht_buckets; j++ )
     {
@@ -1045,11 +1060,37 @@
         if ( a->gpfn_and_flags )
         {
             live++;
+	    switch(a->gpfn_and_flags & PGT_type_mask) {
+	       	case PGT_l1_shadow:
+		    live_shadow_l1_pages++;
+	    	    break;
+	       	case PGT_l2_shadow:
+		    live_shadow_l2_pages++;
+	    	    break;
+	       	case PGT_l3_shadow:
+		    live_shadow_l3_pages++;
+	    	    break;
+	       	case PGT_l4_shadow:
+		    live_shadow_l4_pages++;
+	    	    break;
+	       	case PGT_hl2_shadow:
+		    live_hl2_table_pages++;
+	    	    break;
+	       	case PGT_snapshot:
+		    live_snapshot_pages++;
+	    	    break;
+	       	case PGT_writable_pred:
+		    live_writable_pte_predictions++;
+	    	    break;
+	       	default:
+	    		BUG();
+	    }
             ASSERT(a->smfn);
         }
         else
             ASSERT(!a->next);
 
+
         a = a->next;
         while ( a && (live < 9999) )
         { 
@@ -1060,6 +1101,31 @@
                        live, a->gpfn_and_flags, a->smfn, a->next);
                 BUG();
             }
+	    switch(a->gpfn_and_flags & PGT_type_mask) {
+	       	case PGT_l1_shadow:
+		    live_shadow_l1_pages++;
+	    	    break;
+	       	case PGT_l2_shadow:
+		    live_shadow_l2_pages++;
+	    	    break;
+	       	case PGT_l3_shadow:
+		    live_shadow_l3_pages++;
+	    	    break;
+	       	case PGT_l4_shadow:
+		    live_shadow_l4_pages++;
+	    	    break;
+	       	case PGT_hl2_shadow:
+		    live_hl2_table_pages++;
+	    	    break;
+	       	case PGT_snapshot:
+		    live_snapshot_pages++;
+	    	    break;
+	       	case PGT_writable_pred:
+		    live_writable_pte_predictions++;
+	    	    break;
+	       	default:
+	    		BUG();
+	    }
             ASSERT(a->smfn);
             a = a->next; 
         }
@@ -1085,13 +1151,21 @@
 #ifdef PERF_COUNTERS
     if ( (abs < -1) || (abs > 1) )
     {
-        printk("live=%d free=%d l1=%d l2=%d hl2=%d snapshot=%d writable_ptes=%d\n",
+        printk("live=%d free=%d l1=%d l2=%d hl2=%d snapshot=%d writable_pred=%d\n",
                live, free,
                perfc_value(shadow_l1_pages),
                perfc_value(shadow_l2_pages),
                perfc_value(hl2_table_pages),
                perfc_value(snapshot_pages),
                perfc_value(writable_pte_predictions));
+        printk("counted: l1=%d l2=%d l3=%d l4=%d hl2=%d snapshot=%d writable_pred=%d\n",
+               live_shadow_l1_pages,
+               live_shadow_l2_pages,
+               live_shadow_l3_pages,
+               live_shadow_l4_pages,
+               live_hl2_table_pages,
+               live_snapshot_pages,
+               live_writable_pte_predictions);
         BUG();
     }
 #endif
@@ -1194,7 +1268,7 @@
 #ifndef NDEBUG
         if ( ___shadow_status(d, gpfn, stype) != 0 )
         {
-            printk("d->id=%d gpfn=%lx gmfn=%lx stype=%lx c=%x t=%x "
+            printk("d->domain_id=%d gpfn=%lx gmfn=%lx stype=%lx c=%x t=%x "
                    "mfn_out_of_sync(gmfn)=%d mfn_is_page_table(gmfn)=%d\n",
                    d->domain_id, gpfn, gmfn, stype,
                    frame_table[gmfn].count_info,
@@ -1441,7 +1515,8 @@
             if ( stype != PGT_writable_pred )
                 BUG(); // we should never replace entries into the hash table
             x->smfn = smfn;
-            put_page(pfn_to_page(gmfn)); // already had a ref...
+            if ( stype != PGT_writable_pred )
+                put_page(pfn_to_page(gmfn)); // already had a ref...
             goto done;
         }
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/include/asm-x86/x86_32/domain_page.h xeno-ft/xen/include/asm-x86/x86_32/domain_page.h
--- xen-unstable.latest/xen/include/asm-x86/x86_32/domain_page.h	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/xen/include/asm-x86/x86_32/domain_page.h	2005-06-06 16:56:18.000000000 -0400
@@ -63,7 +63,6 @@
 unmap_domain_mem_with_cache(void *va, struct map_dom_mem_cache *cache)
 {
     ASSERT(cache != NULL);
-    unmap_domain_mem(va);
 }
 
 static inline void
@@ -76,5 +75,4 @@
         cache->pa = 0;
     }
 }
-
 #endif /* __ASM_DOMAIN_PAGE_H__ */

[-- Attachment #3: Type: TEXT/PLAIN, Size: 23339 bytes --]

diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/libxc/Makefile xeno-ft/tools/libxc/Makefile
--- xen-unstable.latest/tools/libxc/Makefile	2005-06-06 08:50:14.000000000 -0400
+++ xeno-ft/tools/libxc/Makefile	2005-06-06 09:44:25.000000000 -0400
@@ -22,6 +22,7 @@
 SRCS     += xc_load_bin.c
 SRCS     += xc_load_elf.c
 SRCS     += xc_linux_build.c
+SRCS     += xc_linuxtranslate_build.c
 SRCS     += xc_plan9_build.c
 SRCS     += xc_linux_restore.c
 SRCS     += xc_linux_save.c
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/libxc/xc.h xeno-ft/tools/libxc/xc.h
--- xen-unstable.latest/tools/libxc/xc.h	2005-06-06 08:50:14.000000000 -0400
+++ xeno-ft/tools/libxc/xc.h	2005-06-06 09:44:25.000000000 -0400
@@ -254,6 +254,15 @@
                    unsigned long flags,
                    unsigned int vcpus);
 
+int xc_linuxtranslate_build(int xc_handle,
+                   u32 domid,
+                   const char *image_name,
+                   const char *ramdisk_name,
+                   const char *cmdline,
+                   unsigned int control_evtchn,
+                   unsigned long flags,
+                   unsigned int vcpus);
+
 int
 xc_plan9_build (int xc_handle,
                 u32 domid, 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/libxc/xc_linuxtranslate_build.c xeno-ft/tools/libxc/xc_linuxtranslate_build.c
--- xen-unstable.latest/tools/libxc/xc_linuxtranslate_build.c	1969-12-31 19:00:00.000000000 -0500
+++ xeno-ft/tools/libxc/xc_linuxtranslate_build.c	2005-06-06 10:46:28.000000000 -0400
@@ -0,0 +1,519 @@
+/******************************************************************************
+ * xc_linuxtranslate_build.c
+ * Derived from xc_linux_build.c
+ */
+
+#include "xc_private.h"
+#define ELFSIZE 32
+#include "xc_elf.h"
+#include <stdlib.h>
+#include <zlib.h>
+
+#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
+#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
+
+#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
+#define round_pgdown(_p)  ((_p)&PAGE_MASK)
+
+static int probeimageformat(char *image,
+                            unsigned long image_size,
+                            struct load_funcs *load_funcs)
+{
+    if ( probe_elf(image, image_size, load_funcs) &&
+         probe_bin(image, image_size, load_funcs) )
+    {
+        ERROR( "Unrecognized image format" );
+        return -EINVAL;
+    }
+
+    return 0;
+}
+
+static int setup_guest(int xc_handle,
+                         u32 dom,
+                         char *image, unsigned long image_size,
+                         gzFile initrd_gfd, unsigned long initrd_len,
+                         unsigned long nr_pages,
+                         unsigned long *pvsi, unsigned long *pvke,
+                         vcpu_guest_context_t *ctxt,
+                         const char *cmdline,
+                         unsigned long shared_info_frame,
+                         unsigned int control_evtchn,
+                         unsigned long flags,
+                         unsigned int vcpus)
+{
+    l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
+    l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
+    unsigned long *page_array = NULL;
+    unsigned long ml2tab, pl2tab;
+    unsigned long ml1tab, pl1tab;
+    unsigned long mfn, pfn;
+    unsigned long count, i;
+    start_info_t *start_info;
+    shared_info_t *shared_info;
+    mmu_t *mmu = NULL;
+    int rc;
+
+    unsigned long nr_pt_pages;
+    unsigned long ppt_alloc;
+    unsigned long *physmap, *physmap_e, physmap_pfn;
+
+    struct load_funcs load_funcs;
+    struct domain_setup_info dsi;
+    unsigned long vinitrd_start;
+    unsigned long vinitrd_end;
+    unsigned long vphysmap_start;
+    unsigned long vphysmap_end;
+    unsigned long vstartinfo_start;
+    unsigned long vstartinfo_end;
+    unsigned long vstack_start;
+    unsigned long vstack_end;
+    unsigned long vpt_start;
+    unsigned long vpt_end;
+    unsigned long v_end;
+    unsigned long pshared_info;
+
+    rc = probeimageformat(image, image_size, &load_funcs);
+    if ( rc != 0 )
+        goto error_out;
+
+    memset(&dsi, 0, sizeof(struct domain_setup_info));
+
+    rc = (load_funcs.parseimage)(image, image_size, &dsi);
+    if ( rc != 0 )
+        goto error_out;
+
+    if ( (dsi.v_start & (PAGE_SIZE-1)) != 0 )
+    {
+        PERROR("Guest OS must load to a page boundary.\n");
+        goto error_out;
+    }
+
+    /* Untranslated guests are given the mfn of the shared_info frame, and
+     * they are expected to map it.  We need to allocate a pfn to map the
+     * mfn into; so we steal a page from the end.  We don't need to put
+     * it in a page table, we just need to have a p2m and m2p for it... */
+    pshared_info = nr_pages;
+
+    /*
+     * Why do we need this? The number of page-table frames depends on the 
+     * size of the bootstrap address space. But the size of the address space 
+     * depends on the number of page-table frames (since each one is mapped 
+     * read-only). We have a pair of simultaneous equations in two unknowns, 
+     * which we solve by exhaustive search.
+     */
+    vinitrd_start    = round_pgup(dsi.v_end);
+    vinitrd_end      = vinitrd_start + initrd_len;
+    vphysmap_start   = round_pgup(vinitrd_end);
+    vphysmap_end     = vphysmap_start + ((nr_pages+1) * sizeof(unsigned long));
+    vpt_start        = round_pgup(vphysmap_end);
+    for ( nr_pt_pages = 2; ; nr_pt_pages++ )
+    {
+        vpt_end          = vpt_start + (nr_pt_pages * PAGE_SIZE);
+        vstartinfo_start = vpt_end;
+        vstartinfo_end   = vstartinfo_start + PAGE_SIZE;
+        vstack_start     = vstartinfo_end;
+        vstack_end       = vstack_start + PAGE_SIZE;
+        v_end            = (vstack_end + (1<<22)-1) & ~((1<<22)-1);
+        if ( (v_end - vstack_end) < (512 << 10) )
+            v_end += 1 << 22; /* Add extra 4MB to get >= 512kB padding. */
+        if ( (((v_end - dsi.v_start + ((1<<L2_PAGETABLE_SHIFT)-1)) >> 
+               L2_PAGETABLE_SHIFT) + 1) <= nr_pt_pages )
+            break;
+    }
+
+    printf("VIRTUAL MEMORY ARRANGEMENT:\n"
+           " Loaded kernel: %08lx->%08lx\n"
+           " Init. ramdisk: %08lx->%08lx\n"
+           " Phys-Mach map: %08lx->%08lx\n"
+           " Page tables:   %08lx->%08lx\n"
+           " Start info:    %08lx->%08lx\n"
+           " Boot stack:    %08lx->%08lx\n"
+           " TOTAL:         %08lx->%08lx\n",
+           dsi.v_kernstart, dsi.v_kernend, 
+           vinitrd_start, vinitrd_end,
+           vphysmap_start, vphysmap_end,
+           vpt_start, vpt_end,
+           vstartinfo_start, vstartinfo_end,
+           vstack_start, vstack_end,
+           dsi.v_start, v_end);
+    printf(" ENTRY ADDRESS: %08lx\n", dsi.v_kernentry);
+
+    if ( (v_end - dsi.v_start) > (nr_pages * PAGE_SIZE) )
+    {
+        printf("Initial guest OS requires too much space\n"
+               "(%luMB is greater than %luMB limit)\n",
+               (v_end-dsi.v_start)>>20, (nr_pages<<PAGE_SHIFT)>>20);
+        goto error_out;
+    }
+
+    if ( (page_array = malloc((nr_pages+1) * sizeof(unsigned long))) == NULL )
+    {
+        PERROR("Could not allocate memory");
+        goto error_out;
+    }
+
+
+    if ( xc_get_pfn_list(xc_handle, dom, page_array, nr_pages) != nr_pages )
+    {
+        PERROR("Could not get the page frame list");
+        goto error_out;
+    }
+
+    (load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array, &dsi);
+
+    /* Load the initial ramdisk image. */
+    if ( initrd_len != 0 )
+    {
+        for ( i = (vinitrd_start - dsi.v_start); 
+              i < (vinitrd_end - dsi.v_start); i += PAGE_SIZE )
+        {
+            char page[PAGE_SIZE];
+            if ( gzread(initrd_gfd, page, PAGE_SIZE) == -1 )
+            {
+                PERROR("Error reading initrd image, could not");
+                goto error_out;
+            }
+            xc_copy_to_domain_page(xc_handle, dom,
+                                page_array[i>>PAGE_SHIFT], page);
+        }
+    }
+
+    if ( (mmu = init_mmu_updates(xc_handle, dom)) == NULL )
+        goto error_out;
+
+    /* First allocate page for page dir. */
+    ppt_alloc = (vpt_start - dsi.v_start) >> PAGE_SHIFT;
+    pl2tab = ppt_alloc++;
+    ml2tab = page_array[pl2tab];
+    ctxt->pt_base = ml2tab << PAGE_SHIFT;
+
+    /* Initialise the page tables. */
+    if ( (vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 
+                                        PROT_READ|PROT_WRITE, 
+					ml2tab)) == NULL )
+        goto error_out;
+    memset(vl2tab, 0, PAGE_SIZE);
+    vl2e = &vl2tab[l2_table_offset(dsi.v_start)];
+    fprintf(stderr, " v_start %lx l2_table_offset %lx\n", 
+    			dsi.v_start,
+			l2_table_offset(dsi.v_start));
+    for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ )
+    {    
+        if ( ((unsigned long)vl1e & (PAGE_SIZE-1)) == 0 )
+        {
+	    pl1tab = ppt_alloc++;
+	    ml1tab = page_array[pl1tab];
+	    fprintf(stderr, " allocating new l1 page; pfn %lx, mfn %lx\n",
+	    			pl1tab, ml1tab);
+            if ( vl1tab != NULL )
+                munmap(vl1tab, PAGE_SIZE);
+            if ( (vl1tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
+                                                PROT_READ|PROT_WRITE,
+						ml1tab)) == NULL )
+            {
+                munmap(vl2tab, PAGE_SIZE);
+                goto error_out;
+            }
+            memset(vl1tab, 0, PAGE_SIZE);
+            vl1e = &vl1tab[l1_table_offset(dsi.v_start + (count<<PAGE_SHIFT))];
+            *vl2e++ = (pl1tab << PAGE_SHIFT )| L2_PROT;
+        }
+
+	pfn=count;
+	mfn=page_array[pfn];
+
+        *vl1e = (pfn << PAGE_SHIFT) | L1_PROT;
+	fprintf(stderr, " %lx:%lx\n", dsi.v_start + (count << PAGE_SHIFT), *vl1e);
+
+        vl1e++;
+    }
+    munmap(vl1tab, PAGE_SIZE);
+    munmap(vl2tab, PAGE_SIZE);
+
+    /* Write the phys->machine and machine->phys table entries. */
+    physmap_pfn = (vphysmap_start - dsi.v_start) >> PAGE_SHIFT;
+    physmap = physmap_e = xc_map_foreign_range(
+        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+        page_array[physmap_pfn++]);
+    for ( count = 0; count < nr_pages; count++ )
+    {
+	pfn = count;
+	mfn = page_array[count];
+        if ( add_mmu_update(xc_handle, mmu,
+                            (mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, 
+			    pfn) )
+        {
+            munmap(physmap, PAGE_SIZE);
+            goto error_out;
+        }
+        *physmap_e++ = pfn;
+        if ( ((unsigned long)physmap_e & (PAGE_SIZE-1)) == 0 )
+        {
+            munmap(physmap, PAGE_SIZE);
+            physmap = physmap_e = xc_map_foreign_range(
+                xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+                page_array[physmap_pfn++]);
+        }
+    }
+
+    if(xc_shadow_control(xc_handle, 
+    				dom, 
+				DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE,
+				NULL,
+				0,
+				NULL)<0) {
+	PERROR("Could not enable full translate mode!");
+	goto error_out;
+    } 
+
+    /* Translate the shared_info page.  (we allocated enough for nr_pages+1.) */
+    mfn = shared_info_frame;
+    pfn = pshared_info;
+    if( add_mmu_update(xc_handle, mmu, 
+		   (mfn<<PAGE_SHIFT)|MMU_MACHPHYS_UPDATE,
+		   pfn)) {
+	munmap(physmap, PAGE_SIZE);
+	goto error_out;
+    }
+    *physmap_e++ = pfn;
+
+    /* If you do anything after here, make sure to see if you need to
+     * go on to the next page. */
+    munmap(physmap, PAGE_SIZE);
+    
+    /*
+     * Pin down l2tab addr as page dir page - causes hypervisor to provide
+     * correct protection for the page
+     */ 
+    if ( pin_table(xc_handle, 
+    			MMUEXT_PIN_L2_TABLE, 
+			ml2tab,
+			dom) )
+        goto error_out;
+
+    start_info = xc_map_foreign_range(
+        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+        page_array[(vstartinfo_start-dsi.v_start)>>PAGE_SHIFT]);
+
+    memset(start_info, 0, sizeof(*start_info));
+    start_info->nr_pages     = nr_pages;
+    start_info->shared_info  = pshared_info << PAGE_SHIFT;
+    start_info->flags        = flags;
+    start_info->pt_base      = vpt_start;
+    start_info->nr_pt_frames = nr_pt_pages;
+    start_info->mfn_list     = vphysmap_start;
+    start_info->domain_controller_evtchn = control_evtchn;
+    if ( initrd_len != 0 )
+    {
+        start_info->mod_start    = vinitrd_start;
+        start_info->mod_len      = initrd_len;
+    }
+    strncpy((char *)start_info->cmd_line, cmdline, MAX_CMDLINE);
+    start_info->cmd_line[MAX_CMDLINE-1] = '\0';
+    munmap(start_info, PAGE_SIZE);
+
+    /* shared_info page starts its life empty. */
+    shared_info = xc_map_foreign_range(
+        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
+    memset(shared_info, 0, sizeof(shared_info_t));
+    /* Mask all upcalls... */
+    for ( i = 0; i < MAX_VIRT_CPUS; i++ )
+        shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
+
+    shared_info->n_vcpu = vcpus;
+    printf(" VCPUS:         %d\n", shared_info->n_vcpu);
+
+    munmap(shared_info, PAGE_SIZE);
+
+    fprintf(stderr, "setup_guest: finish_mmu_updates\n");
+    /* Send the page update requests down to the hypervisor. */
+    if ( finish_mmu_updates(xc_handle, mmu) )
+        goto error_out;
+
+    free(mmu);
+    free(page_array);
+
+    *pvsi = vstartinfo_start;
+    *pvke = dsi.v_kernentry;
+
+    fprintf(stderr, "setup_guest: done!");
+    return 0;
+
+ error_out:
+    if ( mmu != NULL )
+        free(mmu);
+    if ( page_array != NULL )
+        free(page_array);
+    return -1;
+}
+
+int xc_linuxtranslate_build(int xc_handle,
+                   u32 domid,
+                   const char *image_name,
+                   const char *ramdisk_name,
+                   const char *cmdline,
+                   unsigned int control_evtchn,
+                   unsigned long flags,
+                   unsigned int vcpus)
+{
+    dom0_op_t launch_op, op;
+    int initrd_fd = -1;
+    gzFile initrd_gfd = NULL;
+    int rc, i;
+    vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
+    unsigned long nr_pages;
+    char         *image = NULL;
+    unsigned long image_size, initrd_size=0;
+    unsigned long vstartinfo_start, vkern_entry;
+
+    if ( (nr_pages = xc_get_tot_pages(xc_handle, domid)) < 0 )
+    {
+        PERROR("Could not find total pages for domain");
+        goto error_out;
+    }
+
+    if ( (image = xc_read_kernel_image(image_name, &image_size)) == NULL )
+        goto error_out;
+
+    if ( (ramdisk_name != NULL) && (strlen(ramdisk_name) != 0) )
+    {
+        if ( (initrd_fd = open(ramdisk_name, O_RDONLY)) < 0 )
+        {
+            PERROR("Could not open the initial ramdisk image");
+            goto error_out;
+        }
+
+        initrd_size = xc_get_filesz(initrd_fd);
+
+        if ( (initrd_gfd = gzdopen(initrd_fd, "rb")) == NULL )
+        {
+            PERROR("Could not allocate decompression state for initrd");
+            goto error_out;
+        }
+    }
+
+    if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
+    {   
+        PERROR("Unable to mlock ctxt");
+        return 1;
+    }
+
+    op.cmd = DOM0_GETDOMAININFO;
+    op.u.getdomaininfo.domain = (domid_t)domid;
+    if ( (do_dom0_op(xc_handle, &op) < 0) || 
+         ((u16)op.u.getdomaininfo.domain != domid) )
+    {
+        PERROR("Could not get info on domain");
+        goto error_out;
+    }
+
+    if ( xc_domain_get_vcpu_context(xc_handle, domid, 0, ctxt) )
+    {
+        PERROR("Could not get vcpu context");
+        goto error_out;
+    }
+
+    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
+         (ctxt->pt_base != 0) )
+    {
+        ERROR("Domain is already constructed");
+        goto error_out;
+    }
+
+    if ( setup_guest(xc_handle, domid, image, image_size, 
+                       initrd_gfd, initrd_size, nr_pages, 
+                       &vstartinfo_start, &vkern_entry,
+                       ctxt, cmdline,
+                       op.u.getdomaininfo.shared_info_frame,
+                       control_evtchn, flags, vcpus) < 0 )
+    {
+        ERROR("Error constructing guest OS");
+        goto error_out;
+    }
+
+    if ( initrd_fd >= 0 )
+        close(initrd_fd);
+    if ( initrd_gfd )
+        gzclose(initrd_gfd);
+    if ( image != NULL )
+        free(image);
+
+    ctxt->flags = 0;
+
+    /*
+     * Initial register values:
+     *  DS,ES,FS,GS = FLAT_KERNEL_DS
+     *       CS:EIP = FLAT_KERNEL_CS:start_pc
+     *       SS:ESP = FLAT_KERNEL_DS:start_stack
+     *          ESI = start_info
+     *  [EAX,EBX,ECX,EDX,EDI,EBP are zero]
+     *       EFLAGS = IF | 2 (bit 1 is reserved and should always be 1)
+     */
+    ctxt->user_regs.ds = FLAT_KERNEL_DS;
+    ctxt->user_regs.es = FLAT_KERNEL_DS;
+    ctxt->user_regs.fs = FLAT_KERNEL_DS;
+    ctxt->user_regs.gs = FLAT_KERNEL_DS;
+    ctxt->user_regs.ss = FLAT_KERNEL_DS;
+    ctxt->user_regs.cs = FLAT_KERNEL_CS;
+    ctxt->user_regs.eip = vkern_entry;
+    ctxt->user_regs.esp = vstartinfo_start + 2*PAGE_SIZE;
+    ctxt->user_regs.esi = vstartinfo_start;
+    ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */
+
+    /* FPU is set up to default initial state. */
+    memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
+
+    /* Virtual IDT is empty at start-of-day. */
+    for ( i = 0; i < 256; i++ )
+    {
+        ctxt->trap_ctxt[i].vector = i;
+        ctxt->trap_ctxt[i].cs     = FLAT_KERNEL_CS;
+    }
+
+    /* No LDT. */
+    ctxt->ldt_ents = 0;
+    
+    /* Use the default Xen-provided GDT. */
+    ctxt->gdt_ents = 0;
+
+    /* Ring 1 stack is the initial stack. */
+    ctxt->kernel_ss = FLAT_KERNEL_DS;
+    ctxt->kernel_sp = vstartinfo_start + 2*PAGE_SIZE;
+
+    /* No debugging. */
+    memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg));
+
+    /* No callback handlers. */
+#if defined(__i386__)
+    ctxt->event_callback_cs     = FLAT_KERNEL_CS;
+    ctxt->event_callback_eip    = 0;
+    ctxt->failsafe_callback_cs  = FLAT_KERNEL_CS;
+    ctxt->failsafe_callback_eip = 0;
+#elif defined(__x86_64__)
+    ctxt->event_callback_eip    = 0;
+    ctxt->failsafe_callback_eip = 0;
+    ctxt->syscall_callback_eip  = 0;
+#endif
+
+    memset( &launch_op, 0, sizeof(launch_op) );
+
+    launch_op.u.setdomaininfo.domain = (domid_t)domid;
+    launch_op.u.setdomaininfo.vcpu   = 0;
+    launch_op.u.setdomaininfo.ctxt   = ctxt;
+
+    launch_op.cmd = DOM0_SETDOMAININFO;
+    rc = do_dom0_op(xc_handle, &launch_op);
+    
+    return rc;
+
+ error_out:
+    if ( initrd_gfd != NULL )
+        gzclose(initrd_gfd);
+    else if ( initrd_fd >= 0 )
+        close(initrd_fd);
+    if ( image != NULL )
+        free(image);
+
+    return -1;
+}
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/python/xen/lowlevel/xc/xc.c xeno-ft/tools/python/xen/lowlevel/xc/xc.c
--- xen-unstable.latest/tools/python/xen/lowlevel/xc/xc.c	2005-06-06 08:50:14.000000000 -0400
+++ xeno-ft/tools/python/xen/lowlevel/xc/xc.c	2005-06-06 09:44:25.000000000 -0400
@@ -280,6 +280,33 @@
     return zero;
 }
 
+static PyObject *pyxc_linuxtranslate_build(PyObject *self,
+                                  PyObject *args,
+                                  PyObject *kwds)
+{
+    XcObject *xc = (XcObject *)self;
+
+    u32   dom;
+    char *image, *ramdisk = NULL, *cmdline = "";
+    int   control_evtchn, flags = 0, vcpus = 1;
+
+    static char *kwd_list[] = { "dom", "control_evtchn", 
+                                "image", "ramdisk", "cmdline", "flags", "vcpus",
+                                NULL };
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|ssii", kwd_list, 
+                                      &dom, &control_evtchn, 
+                                      &image, &ramdisk, &cmdline, &flags, &vcpus) )
+        return NULL;
+
+    if ( xc_linuxtranslate_build(xc->xc_handle, dom, image,
+                        ramdisk, cmdline, control_evtchn, flags, vcpus) != 0 )
+        return PyErr_SetFromErrno(xc_error);
+    
+    Py_INCREF(zero);
+    return zero;
+}
+
 static PyObject *pyxc_plan9_build(PyObject *self,
                                   PyObject *args,
                                   PyObject *kwds)
@@ -924,6 +951,17 @@
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
+    { "linuxtranslate_build", 
+      (PyCFunction)pyxc_linuxtranslate_build, 
+      METH_VARARGS | METH_KEYWORDS, "\n"
+      "Build a new shadow-translated Linux guest OS.\n"
+      " dom     [int]:      Identifier of domain to build into.\n"
+      " image   [str]:      Name of kernel image file. May be gzipped.\n"
+      " ramdisk [str, n/a]: Name of ramdisk file, if any.\n"
+      " cmdline [str, n/a]: Kernel parameters, if any.\n\n"
+      " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
+      "Returns: [int] 0 on success; -1 on error.\n" },
+
     { "plan9_build",
       (PyCFunction)pyxc_plan9_build,
       METH_VARARGS | METH_KEYWORDS, "\n"
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/python/xen/xend/XendDomainInfo.py xeno-ft/tools/python/xen/xend/XendDomainInfo.py
--- xen-unstable.latest/tools/python/xen/xend/XendDomainInfo.py	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft/tools/python/xen/xend/XendDomainInfo.py	2005-06-04 17:09:24.000000000 -0400
@@ -1114,6 +1114,30 @@
     vm.create_domain("linux", kernel, ramdisk, cmdline)
     return vm
 
+def vm_image_linuxtranslate(vm, image):
+    """Create a VM for a shaodw translate linux image.
+
+    @param name:      vm name
+    @param memory:    vm memory
+    @param image:     image config
+    @return: vm
+    """
+    kernel = sxp.child_value(image, "kernel")
+    cmdline = ""
+    ip = sxp.child_value(image, "ip", None)
+    if ip:
+        cmdline += " ip=" + ip
+    root = sxp.child_value(image, "root")
+    if root:
+        cmdline += " root=" + root
+    args = sxp.child_value(image, "args")
+    if args:
+        cmdline += " " + args
+    ramdisk = sxp.child_value(image, "ramdisk", '')
+    log.debug("creating translated linux domain with cmdline: %s" %(cmdline,))
+    vm.create_domain("linuxtranslate", kernel, ramdisk, cmdline)
+    return vm
+
 def vm_image_plan9(vm, image):
     """Create a VM for a Plan 9 image.
 
@@ -1197,6 +1221,7 @@
 #============================================================================
 # Register image handlers.
 add_image_handler('linux', vm_image_linux)
+add_image_handler('linuxtranslate', vm_image_linuxtranslate)
 add_image_handler('plan9', vm_image_plan9)
 add_image_handler('vmx',   vm_image_vmx)
 

[-- Attachment #4: Type: TEXT/PLAIN, Size: 10899 bytes --]

diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c	2005-06-04 18:14:40.000000000 -0400
@@ -109,11 +109,13 @@
 		retval = copy_ldt(&mm->context, &old_mm->context);
 		up(&old_mm->context.sem);
 	}
+#ifndef CONFIG_XEN_SHADOW_MODE
 	if (retval == 0) {
 		spin_lock(&mm_unpinned_lock);
 		list_add(&mm->context.unpinned, &mm_unpinned);
 		spin_unlock(&mm_unpinned_lock);
 	}
+#endif
 	return retval;
 }
 
@@ -134,11 +136,13 @@
 			kfree(mm->context.ldt);
 		mm->context.size = 0;
 	}
+#ifndef CONFIG_XEN_SHADOW_MODE
 	if (!mm->context.pinned) {
 		spin_lock(&mm_unpinned_lock);
 		list_del(&mm->context.unpinned);
 		spin_unlock(&mm_unpinned_lock);
 	}
+#endif
 }
 
 static int read_ldt(void __user * ptr, unsigned long bytecount)
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c	2005-05-16 13:05:03.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c	2005-05-16 13:55:06.000000000 -0400
@@ -27,6 +27,7 @@
 static void
 xen_contig_memory(unsigned long vstart, unsigned int order)
 {
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 	/*
 	 * Ensure multi-page extents are contiguous in machine memory.
 	 * This code could be cleaned up some, and the number of
@@ -69,6 +70,7 @@
 	flush_tlb_all();
 
 	balloon_unlock(flags);
+#endif /* ! CONFIG_XEN_SHADOW_TRANSLATE_MODE */
 }
 
 void *dma_alloc_coherent(struct device *dev, size_t size,
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c	2005-05-16 13:05:03.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c	2005-05-16 13:55:06.000000000 -0400
@@ -360,8 +360,10 @@
 shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
 EXPORT_SYMBOL(HYPERVISOR_shared_info);
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 unsigned int *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
 EXPORT_SYMBOL(phys_to_machine_mapping);
+#endif
 
 /* Raw start-of-day parameters from the hypervisor. */
 union xen_start_info_union xen_start_info_union;
@@ -1156,7 +1158,9 @@
 	}
 #endif
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 	phys_to_machine_mapping = (unsigned int *)xen_start_info.mfn_list;
+#endif
 
 	return max_low_pfn;
 }
@@ -1509,6 +1513,7 @@
 	find_smp_config();
 #endif
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 	/* Make sure we have a correctly sized P->M table. */
 	if (max_pfn != xen_start_info.nr_pages) {
 		phys_to_machine_mapping = alloc_bootmem_low_pages(
@@ -1545,7 +1550,7 @@
 	}
 	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
 	     virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
-
+#endif /* ! CONFIG_XEN_SHADOW_TRANSLATE_MODE */
 
 	/*
 	 * NOTE: at this point the bootmem allocator is fully available.
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	2005-06-01 15:08:44.000000000 -0400
@@ -408,6 +408,7 @@
 }
 #endif /* CONFIG_XEN_SHADOW_MODE */
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 LIST_HEAD(mm_unpinned);
 DEFINE_SPINLOCK(mm_unpinned_lock);
 
@@ -454,6 +455,7 @@
 	}
 }
 
+
 void mm_pin(struct mm_struct *mm)
 {
     spin_lock(&mm->page_table_lock);
@@ -521,3 +523,4 @@
     if ( mm->context.pinned && (atomic_read(&mm->mm_count) == 1) )
         mm_unpin(mm);
 }
+#endif /* CONFIG_XEN_SHADOW_MODE */
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/Kconfig xeno-ft/linux-2.6.11-xen-sparse/arch/xen/Kconfig
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/Kconfig	2005-05-16 13:05:03.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/Kconfig	2005-06-06 10:43:06.000000000 -0400
@@ -124,11 +124,21 @@
 	  space.  Odds are that you want to say N here.
 
 config XEN_SHADOW_MODE
-	bool "Fake shadow mode"
+	bool "Build linux to use Xen's shadow mode support (EXPERIMENTAL)"
+	depends on EXPERIMENTAL
 	default n
-    help
-      fakes out a shadow mode kernel
+	help
+	  Builds a xenolinux that expects Xen's shadow mode support to be
+          enabled.
 
+config XEN_SHADOW_TRANSLATE_MODE
+	bool "Build linux to use Xen's shadow translate mode support (EXPERIMENTAL)"
+	depends on EXPERIMENTAL
+	depends on XEN_SHADOW_MODE
+	default n
+	help
+	  Builds a xenolinux that expects Xen's shadow translate mode support
+	  to be enabled.
 
 config XEN_SCRUB_PAGES
 	bool "Scrub memory before freeing it to Xen"
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c xeno-ft/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c	2005-06-04 18:14:40.000000000 -0400
@@ -93,7 +93,9 @@
     extern void time_suspend(void);
     extern void time_resume(void);
     extern unsigned long max_pfn;
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
     extern unsigned int *pfn_to_mfn_frame_list;
+#endif
 
     suspend_record = (suspend_record_t *)__get_free_page(GFP_KERNEL);
     if ( suspend_record == NULL )
@@ -139,6 +141,7 @@
 
     memset(empty_zero_page, 0, PAGE_SIZE);
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
     for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
     {
         pfn_to_mfn_frame_list[j] = 
@@ -146,7 +149,7 @@
     }
     HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
         virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
-
+#endif /* ! CONFIG_XEN_SHADOW_TRANSLATE_MODE */
     gnttab_resume();
 
     irq_resume();
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c xeno-ft/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c	2005-04-13 05:44:49.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c	2005-05-16 13:06:46.000000000 -0400
@@ -197,12 +197,14 @@
                 BUG();
 
             pfn = page - mem_map;
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
             if ( phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY )
                 BUG();
 
             /* Update P->M and M->P tables. */
             phys_to_machine_mapping[pfn] = mfn_list[i];
             xen_machphys_update(mfn_list[i], pfn);
+#endif
             
             /* Link back into the page tables if it's not a highmem page. */
             if ( pfn < max_low_pfn )
@@ -239,7 +241,11 @@
             }
 
             pfn = page - mem_map;
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
             mfn_list[i] = phys_to_machine_mapping[pfn];
+#else
+            mfn_list[i] = pfn;
+#endif
 
             if ( !PageHighMem(page) )
             {
@@ -266,7 +272,9 @@
         for ( i = 0; i < debt; i++ )
         {
             pfn = mfn_to_pfn(mfn_list[i]);
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
             phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
+#endif
             balloon_append(pfn_to_page(pfn));
         }
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h
--- xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h	2005-06-01 14:17:39.000000000 -0400
@@ -41,9 +41,15 @@
 		: : "r" (0) );
 }
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 extern void mm_pin(struct mm_struct *mm);
 extern void mm_unpin(struct mm_struct *mm);
 void mm_pin_all(void);
+#else
+#define mm_pin(_mm) ((void)0)
+#define mm_unpin(_mm) ((void)0)
+#define mm_pin_all() ((void)0)
+#endif
 
 static inline void switch_mm(struct mm_struct *prev,
 			     struct mm_struct *next,
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h
--- xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h	2005-06-01 15:15:30.000000000 -0400
@@ -16,6 +16,7 @@
 	struct list_head unpinned;
 } mm_context_t;
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 extern struct list_head mm_unpinned;
 extern spinlock_t mm_unpinned_lock;
 
@@ -23,4 +24,6 @@
 extern void _arch_exit_mmap(struct mm_struct *mm);
 #define arch_exit_mmap(_mm) _arch_exit_mmap(_mm)
 
+#endif /* CONFIG_XEN_SHADOW_MODE */
+
 #endif
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h
--- xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h	2005-05-31 08:28:29.000000000 -0400
+++ xeno-ft/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h	2005-06-06 16:17:09.000000000 -0400
@@ -58,9 +58,14 @@
 #define copy_user_page(to, from, vaddr, pg)	copy_page(to, from)
 
 /**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
+#ifdef CONFIG_XEN_SHADOW_MODE
+# define pfn_to_mfn(_pfn) ((unsigned long)(_pfn))
+# define mfn_to_pfn(_mfn) ((unsigned long)(_mfn))
+#else
 extern unsigned int *phys_to_machine_mapping;
-#define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
-#define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
+# define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
+# define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
+#endif
 static inline unsigned long phys_to_machine(unsigned long phys)
 {
 	unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);

[-- Attachment #5: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 11%]

* Re: [patch] nx bit shouldn't get set when disabled
  @ 2005-06-09 12:59  3%         ` Scott Parish
  0 siblings, 0 replies; 200+ results
From: Scott Parish @ 2005-06-09 12:59 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel, Nakajima, Jun, Scott Parish

[-- Attachment #1: Type: text/plain, Size: 766 bytes --]

On Wed, Jun 08, 2005 at 10:23:47PM +0100, Keir Fraser wrote:

> I'm not inclined to take patches for xen/x86_64/pci-dma.c anyway: I
> think we can patch the xen/i386 one and share it with xen/x86_64.
> Otherwise we're going to get unnecessary divergence between what
> really ought to be two identical files. (I already did this for
> arch/xen/i386/kernel/time.c, for example.)

The attached patch unifies pci-dma.c and adds the pte_mfn() macro.

The one thing that might need an explanation, there's 4 lines of changes
(walking the page table) that add parentheses. The x86_64 compiler doesn't
seem to like doing unparenthesized math for function arguments.

Boot tested dom0 on x86_64 and x86_32 (non-pae)

sRp

-- 
Scott Parish
Signed-off-by: srparish@us.ibm.com

[-- Attachment #2: unify-pci-dma.c.diff --]
[-- Type: text/plain, Size: 18892 bytes --]

diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c
--- old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c	2005-05-24 17:34:53.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/pci-dma.c	2005-06-09 11:52:51.000000000 +0000
@@ -36,7 +36,7 @@ xen_contig_memory(unsigned long vstart, 
 	pud_t         *pud; 
 	pmd_t         *pmd;
 	pte_t         *pte;
-	unsigned long  pfn, i, flags;
+	unsigned long  mfn, i, flags;
 
 	scrub_pages(vstart, 1 << order);
 
@@ -45,26 +45,26 @@ xen_contig_memory(unsigned long vstart, 
 	/* 1. Zap current PTEs, giving away the underlying pages. */
 	for (i = 0; i < (1<<order); i++) {
 		pgd = pgd_offset_k(vstart + (i*PAGE_SIZE));
-		pud = pud_offset(pgd, vstart + (i*PAGE_SIZE));
-		pmd = pmd_offset(pud, vstart + (i*PAGE_SIZE));
-		pte = pte_offset_kernel(pmd, vstart + (i*PAGE_SIZE));
-		pfn = pte_val_ma(*pte) >> PAGE_SHIFT;
-		HYPERVISOR_update_va_mapping(vstart + (i*PAGE_SIZE),
+		pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
+		pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
+		pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE)));
+		mfn = pte_mfn(*pte);
+		HYPERVISOR_update_va_mapping((vstart + (i*PAGE_SIZE)),
 					     __pte_ma(0), 0);
 		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
-			INVALID_P2M_ENTRY;
+			(u32)INVALID_P2M_ENTRY;
 		if (HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation, 
-					  &pfn, 1, 0) != 1) BUG();
+					  &mfn, 1, 0) != 1) BUG();
 	}
 	/* 2. Get a new contiguous memory extent. */
 	if (HYPERVISOR_dom_mem_op(MEMOP_increase_reservation,
-				  &pfn, 1, order) != 1) BUG();
+				  &mfn, 1, order) != 1) BUG();
 	/* 3. Map the new extent in place of old pages. */
 	for (i = 0; i < (1<<order); i++) {
 		HYPERVISOR_update_va_mapping(vstart + (i*PAGE_SIZE),
-			__pte_ma(((pfn+i)<<PAGE_SHIFT)|__PAGE_KERNEL), 0);
-		xen_machphys_update(pfn+i, (__pa(vstart)>>PAGE_SHIFT)+i);
-		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = pfn+i;
+			__pte_ma(((mfn+i)<<PAGE_SHIFT)|__PAGE_KERNEL), 0);
+		xen_machphys_update(mfn+i, (__pa(vstart)>>PAGE_SHIFT)+i);
+		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn+i;
 	}
 	flush_tlb_all();
 
@@ -123,6 +123,7 @@ void dma_free_coherent(struct device *de
 		free_pages((unsigned long)vaddr, order);
 }
 
+#ifdef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
 int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
 				dma_addr_t device_addr, size_t size, int flags)
 {
@@ -199,3 +200,4 @@ void *dma_mark_declared_memory_occupied(
 	return mem->virt_base + (pos << PAGE_SHIFT);
 }
 EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
+#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c	2005-06-06 16:39:54.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c	2005-06-09 12:38:43.000000000 +0000
@@ -209,7 +209,7 @@ unsigned long allocate_empty_lowmem_regi
         pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
         pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
         pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE))); 
-        pfn_array[i] = pte->pte_low >> PAGE_SHIFT;
+        pfn_array[i] = pte_mfn(*pte);
         HYPERVISOR_update_va_mapping(vstart + (i*PAGE_SIZE), __pte_ma(0), 0);
         phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
             INVALID_P2M_ENTRY;
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/Makefile new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/Makefile
--- old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/Makefile	2005-06-03 01:44:40.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/Makefile	2005-06-09 11:44:20.000000000 +0000
@@ -14,7 +14,7 @@ obj-y	:= process.o signal.o entry.o trap
 c-obj-y	:= semaphore.o i387.o sys_x86_64.o \
 		ptrace.o quirks.o syscall.o bootflag.o
 
-i386-obj-y			:= time.o
+i386-obj-y			:= time.o pci-dma.o
 obj-y				+= ../../i386/kernel/timers/
 
 s-obj-y	:=
@@ -35,7 +35,7 @@ c-obj-$(CONFIG_X86_IO_APIC)	+= genapic.o
 #obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 #obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 #obj-$(CONFIG_GART_IOMMU)	+= pci-gart.o aperture.o
-c-obj-$(CONFIG_DUMMY_IOMMU)	+= pci-nommu.o pci-dma.o
+c-obj-$(CONFIG_DUMMY_IOMMU)	+= pci-nommu.o
 #obj-$(CONFIG_SWIOTLB)		+= swiotlb.o
 obj-$(CONFIG_KPROBES)		+= kprobes.o
 
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c
--- old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c	2005-05-24 17:34:54.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c	1970-01-01 00:00:00.000000000 +0000
@@ -1,256 +0,0 @@
-/*
- * Dynamic DMA mapping support.
- */
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <linux/module.h>
-#include <asm/io.h>
-#include <asm-xen/balloon.h>
-
-/* Map a set of buffers described by scatterlist in streaming
- * mode for DMA.  This is the scatter-gather version of the
- * above pci_map_single interface.  Here the scatter gather list
- * elements are each tagged with the appropriate dma address
- * and length.  They are obtained via sg_dma_{address,length}(SG).
- *
- * NOTE: An implementation may be able to use a smaller number of
- *       DMA address/length pairs than there are SG table elements.
- *       (for example via virtual mapping capabilities)
- *       The routine returns the number of addr/length pairs actually
- *       used, at most nents.
- *
- * Device ownership issues as mentioned above for pci_map_single are
- * the same here.
- */
-int dma_map_sg(struct device *hwdev, struct scatterlist *sg,
-	       int nents, int direction)
-{
-	int i;
-
-	BUG_ON(direction == DMA_NONE);
- 	for (i = 0; i < nents; i++ ) {
-		struct scatterlist *s = &sg[i];
-		BUG_ON(!s->page); 
-		s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
-		s->dma_length = s->length;
-	}
-	return nents;
-}
-
-EXPORT_SYMBOL(dma_map_sg);
-
-/* Unmap a set of streaming mode DMA translations.
- * Again, cpu read rules concerning calls here are the same as for
- * pci_unmap_single() above.
- */
-void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
-		  int nents, int dir)
-{
-	int i;
-	for (i = 0; i < nents; i++) { 
-		struct scatterlist *s = &sg[i];
-		BUG_ON(s->page == NULL); 
-		BUG_ON(s->dma_address == 0); 
-		dma_unmap_single(dev, s->dma_address, s->dma_length, dir);
-	} 
-}
-
-struct dma_coherent_mem {
-	void		*virt_base;
-	u32		device_base;
-	int		size;
-	int		flags;
-	unsigned long	*bitmap;
-};
-
-static void
-xen_contig_memory(unsigned long vstart, unsigned int order)
-{
-	/*
-	 * Ensure multi-page extents are contiguous in machine memory.
-	 * This code could be cleaned up some, and the number of
-	 * hypercalls reduced.
-	 */
-	pgd_t         *pgd; 
-	pud_t         *pud; 
-	pmd_t         *pmd;
-	pte_t         *pte;
-	unsigned long  pfn, i, flags;
-
-	scrub_pages(vstart, 1 << order);
-
-        balloon_lock(flags);
-
-	/* 1. Zap current PTEs, giving away the underlying pages. */
-	for (i = 0; i < (1<<order); i++) {
-                pgd = pgd_offset_k(   (vstart + (i*PAGE_SIZE)));
-		pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
-		pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
-		pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE)));
-		pfn = pte->pte >> PAGE_SHIFT;
-		xen_l1_entry_update(pte, 0);
-		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
-			(u32)INVALID_P2M_ENTRY;
-		if (HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation, 
-					  &pfn, 1, 0) != 1) BUG();
-	}
-	/* 2. Get a new contiguous memory extent. */
-	if (HYPERVISOR_dom_mem_op(MEMOP_increase_reservation,
-				  &pfn, 1, order) != 1) BUG();
-	/* 3. Map the new extent in place of old pages. */
-	for (i = 0; i < (1<<order); i++) {
-		pgd = pgd_offset_k(   (vstart + (i*PAGE_SIZE)));
-		pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
-		pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
-		pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE)));
-		xen_l1_entry_update(
-			pte, ((pfn+i)<<PAGE_SHIFT)|__PAGE_KERNEL);
-		xen_machphys_update(
-			pfn+i, (__pa(vstart)>>PAGE_SHIFT)+i);
-		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
-			pfn+i;
-	}
-	/* Flush updates through and flush the TLB. */
-	xen_tlb_flush();
-
-        balloon_unlock(flags);
-}
-
-void *dma_alloc_coherent(struct device *dev, size_t size,
-			   dma_addr_t *dma_handle, unsigned gfp)
-{
-	void *ret;
-	unsigned int order = get_order(size);
-	unsigned long vstart;
-
-	struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
-
-	/* ignore region specifiers */
-	gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
-
-	if (mem) {
-		int page = bitmap_find_free_region(mem->bitmap, mem->size,
-						     order);
-		if (page >= 0) {
-			*dma_handle = mem->device_base + (page << PAGE_SHIFT);
-			ret = mem->virt_base + (page << PAGE_SHIFT);
-			memset(ret, 0, size);
-			return ret;
-		}
-		if (mem->flags & DMA_MEMORY_EXCLUSIVE)
-			return NULL;
-	}
-
-	if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
-		gfp |= GFP_DMA;
-
-	vstart = __get_free_pages(gfp, order);
-	ret = (void *)vstart;
-	if (ret == NULL)
-		return ret;
-
-	xen_contig_memory(vstart, order);
-
-	memset(ret, 0, size);
-	*dma_handle = virt_to_bus(ret);
-
-	return ret;
-}
-EXPORT_SYMBOL(dma_alloc_coherent);
-
-void dma_free_coherent(struct device *dev, size_t size,
-			 void *vaddr, dma_addr_t dma_handle)
-{
-	struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
-	int order = get_order(size);
-	
-	if (mem && vaddr >= mem->virt_base && vaddr < (mem->virt_base + (mem->size << PAGE_SHIFT))) {
-		int page = (vaddr - mem->virt_base) >> PAGE_SHIFT;
-
-		bitmap_release_region(mem->bitmap, page, order);
-	} else
-		free_pages((unsigned long)vaddr, order);
-}
-EXPORT_SYMBOL(dma_free_coherent);
-
-#if 0
-int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
-				dma_addr_t device_addr, size_t size, int flags)
-{
-	void __iomem *mem_base;
-	int pages = size >> PAGE_SHIFT;
-	int bitmap_size = (pages + 31)/32;
-
-	if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
-		goto out;
-	if (!size)
-		goto out;
-	if (dev->dma_mem)
-		goto out;
-
-	/* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */
-
-	mem_base = ioremap(bus_addr, size);
-	if (!mem_base)
-		goto out;
-
-	dev->dma_mem = kmalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
-	if (!dev->dma_mem)
-		goto out;
-	memset(dev->dma_mem, 0, sizeof(struct dma_coherent_mem));
-	dev->dma_mem->bitmap = kmalloc(bitmap_size, GFP_KERNEL);
-	if (!dev->dma_mem->bitmap)
-		goto free1_out;
-	memset(dev->dma_mem->bitmap, 0, bitmap_size);
-
-	dev->dma_mem->virt_base = mem_base;
-	dev->dma_mem->device_base = device_addr;
-	dev->dma_mem->size = pages;
-	dev->dma_mem->flags = flags;
-
-	if (flags & DMA_MEMORY_MAP)
-		return DMA_MEMORY_MAP;
-
-	return DMA_MEMORY_IO;
-
- free1_out:
-	kfree(dev->dma_mem->bitmap);
- out:
-	return 0;
-}
-EXPORT_SYMBOL(dma_declare_coherent_memory);
-
-void dma_release_declared_memory(struct device *dev)
-{
-	struct dma_coherent_mem *mem = dev->dma_mem;
-	
-	if(!mem)
-		return;
-	dev->dma_mem = NULL;
-	iounmap(mem->virt_base);
-	kfree(mem->bitmap);
-	kfree(mem);
-}
-EXPORT_SYMBOL(dma_release_declared_memory);
-
-void *dma_mark_declared_memory_occupied(struct device *dev,
-					dma_addr_t device_addr, size_t size)
-{
-	struct dma_coherent_mem *mem = dev->dma_mem;
-	int pages = (size + (device_addr & ~PAGE_MASK) + PAGE_SIZE - 1) >> PAGE_SHIFT;
-	int pos, err;
-
-	if (!mem)
-		return ERR_PTR(-EINVAL);
-
-	pos = (device_addr - mem->device_base) >> PAGE_SHIFT;
-	err = bitmap_allocate_region(mem->bitmap, pos, get_order(pages));
-	if (err != 0)
-		return ERR_PTR(err);
-	return mem->virt_base + (pos << PAGE_SHIFT);
-}
-EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
-#endif
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c
--- old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c	2005-05-24 17:34:54.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c	2005-06-09 11:24:34.000000000 +0000
@@ -97,6 +97,9 @@ EXPORT_SYMBOL(copy_to_user);
 EXPORT_SYMBOL(copy_in_user);
 EXPORT_SYMBOL(strnlen_user);
 
+EXPORT_SYMBOL(dma_alloc_coherent);
+EXPORT_SYMBOL(dma_free_coherent);
+
 #ifdef CONFIG_PCI
 EXPORT_SYMBOL(pci_alloc_consistent);
 EXPORT_SYMBOL(pci_free_consistent);
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c
--- old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c	2005-06-06 16:39:54.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c	2005-06-07 20:35:16.000000000 +0000
@@ -256,7 +276,7 @@ unsigned long allocate_empty_lowmem_regi
         pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
         pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
         pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE))); 
-        pfn_array[i] = pte->pte >> PAGE_SHIFT;
+        pfn_array[i] = pte_mfn(*pte);
         xen_l1_entry_update(pte, 0);
         phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
             (u32)INVALID_P2M_ENTRY;
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/init.c new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/init.c
--- old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/init.c	2005-06-02 23:09:31.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/init.c	2005-06-07 15:39:50.000000000 +0000
@@ -395,7 +395,7 @@ unsigned long get_machine_pfn(unsigned l
         pmd_t* pmd = pmd_offset(pud, addr);
         pte_t *pte = pte_offset_kernel(pmd, addr);
         
-        return (pte->pte >> PAGE_SHIFT);
+        return pte_mfn(*pte);
 } 
 
 #define ALIGN_TO_4K __attribute__((section(".data.page_aligned")))
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h new-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h
--- old-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	2005-05-24 17:34:54.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	2005-06-09 12:11:58.000000000 +0000
@@ -46,9 +46,10 @@
  */
 #define INVALID_P2M_ENTRY (~0U)
 #define FOREIGN_FRAME(_m) ((_m) | (1UL<<((sizeof(unsigned long)*8)-1)))
+#define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT)
 #define pte_pfn(_pte)							\
 ({									\
-	unsigned long mfn = (_pte).pte_low >> PAGE_SHIFT;		\
+	unsigned long mfn = pte_mfn(_pte);				\
 	unsigned long pfn = mfn_to_pfn(mfn);				\
 	if ((pfn >= max_mapnr) || (pfn_to_mfn(pfn) != mfn))		\
 		pfn = max_mapnr; /* special: force !pfn_valid() */	\
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/dma-mapping.h new-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/dma-mapping.h
--- old-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/dma-mapping.h	2005-06-06 16:39:51.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/dma-mapping.h	2005-06-09 11:51:36.000000000 +0000
@@ -8,6 +8,7 @@
 
 #include <linux/config.h>
 
+#include <linux/mm.h>
 #include <asm/scatterlist.h>
 #include <asm/io.h>
 #include <asm/swiotlb.h>
@@ -17,7 +18,7 @@ extern dma_addr_t bad_dma_address;
 	(swiotlb ? swiotlb_dma_mapping_error(x) : ((x) == bad_dma_address))
 
 void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
-			 unsigned gfp);
+			 int gfp);
 void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
 			 dma_addr_t dma_handle);
 
@@ -53,6 +56,54 @@ static inline void dma_unmap_single(stru
 		out_of_line_bug();
 	/* Nothing to do */
 }
+
+/* Map a set of buffers described by scatterlist in streaming
+ * mode for DMA.  This is the scatter-gather version of the
+ * above pci_map_single interface.  Here the scatter gather list
+ * elements are each tagged with the appropriate dma address
+ * and length.  They are obtained via sg_dma_{address,length}(SG).
+ *
+ * NOTE: An implementation may be able to use a smaller number of
+ *       DMA address/length pairs than there are SG table elements.
+ *       (for example via virtual mapping capabilities)
+ *       The routine returns the number of addr/length pairs actually
+ *       used, at most nents.
+ *
+ * Device ownership issues as mentioned above for pci_map_single are
+ * the same here.
+ */
+static inline int dma_map_sg(struct device *hwdev, struct scatterlist *sg,
+	       int nents, int direction)
+{
+	int i;
+
+	BUG_ON(direction == DMA_NONE);
+ 	for (i = 0; i < nents; i++ ) {
+		struct scatterlist *s = &sg[i];
+		BUG_ON(!s->page); 
+		s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
+		s->dma_length = s->length;
+	}
+	return nents;
+}
+
+EXPORT_SYMBOL(dma_map_sg);
+
+/* Unmap a set of streaming mode DMA translations.
+ * Again, cpu read rules concerning calls here are the same as for
+ * pci_unmap_single() above.
+ */
+static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
+		  int nents, int dir)
+{
+	int i;
+	for (i = 0; i < nents; i++) { 
+		struct scatterlist *s = &sg[i];
+		BUG_ON(s->page == NULL); 
+		BUG_ON(s->dma_address == 0); 
+		dma_unmap_single(dev, s->dma_address, s->dma_length, dir);
+	} 
+}
 #endif
 
 #define dma_map_page(dev,page,offset,size,dir) \
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h new-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h
--- old-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h	2005-05-28 09:20:36.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h	2005-06-08 02:48:53.000000000 +0000
@@ -277,9 +292,10 @@ static inline unsigned long pud_bad(pud_
  */
 #define INVALID_P2M_ENTRY (~0UL)
 #define FOREIGN_FRAME(_m) ((_m) | (1UL<<((sizeof(unsigned long)*8)-1)))
+#define pte_mfn(_pte) (((_pte).pte & PTE_MASK) >> PAGE_SHIFT)
 #define pte_pfn(_pte)							\
 ({									\
-	unsigned long mfn = (_pte).pte >> PAGE_SHIFT;                   \
+	unsigned long mfn = pte_mfn(_pte);				\
 	unsigned pfn = mfn_to_pfn(mfn);                                 \
 	if ((pfn >= max_mapnr) || (pfn_to_mfn(pfn) != mfn))		\
 		pfn = max_mapnr; /* special: force !pfn_valid() */	\

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 3%]

* Full translate patch, with grant-table blkif support
@ 2005-06-15 19:14 10% George Washington Dunlap III
  0 siblings, 0 replies; 200+ results
From: George Washington Dunlap III @ 2005-06-15 19:14 UTC (permalink / raw)
  To: xen-devel; +Cc: michael.fetterman

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1882 bytes --]

Here's a patch that will allow domains to run in full translate shadow 
mode, using a block driver with grant tables.  (Network drivers in 
translate mode still not implemented.)

More specifically, this patch:
  * Allows a domU to be built with CONFIG_XEN_SHADOW_TRANSLATE_MODE.  This 
basically disables access to the m2p table, takes out some of the 
mm_[un]pin optimizations.  Currently, it also adds back writing to L2 
pagetables.
  * Adds a "linuxtranslate" builder, which will build a linux domain in 
translate mode.
  * Makes some mods to the way the hypervisor handles shadow translate 
mode.  It also adds a new grant table op, "get_shared_mfn", which will 
return the mfn of the first page of the grant table shared area within the 
hypervisor.
  * All references outside a hypervisor to a translated domain's pages must 
be in gpfns, not mfns.  The hypervisor will translate from pfn to mfn for 
the mapping.  To make this easier, certain information is translated 
from mfn to gpfn before the hypervisor gives it to user space.  (For 
example, the shared_info_pfn of the domain_info struct is changed to a 
pfn, so that xcs and friends work without modification.)  Currently, other 
information (such as cr3) is not translated; so if you want to walk a 
translated domain's page tables, you will have to translate the cr3 from 
mfn to pfn before mapping it.

Let us know what you guys think.

Peace,
  -George

+-------------------+----------------------------------------
| dunlapg@umich.edu | http://www-personal.umich.edu/~dunlapg 
+-------------------+----------------------------------------
|  Who could move a mountain, who could love their enemy?
|  Who could rejoice in pain, and turn the other cheek?
|	- Rich Mullins, "Surely God is With Us"
+------------------------------------------------------------
| Outlaw Junk Email! Support HR 1748 (www.cauce.org)

[-- Attachment #2: Type: TEXT/PLAIN, Size: 62234 bytes --]

diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c	2005-06-15 14:46:12.000000000 -0400
@@ -109,11 +109,13 @@
 		retval = copy_ldt(&mm->context, &old_mm->context);
 		up(&old_mm->context.sem);
 	}
+#ifndef CONFIG_XEN_SHADOW_MODE
 	if (retval == 0) {
 		spin_lock(&mm_unpinned_lock);
 		list_add(&mm->context.unpinned, &mm_unpinned);
 		spin_unlock(&mm_unpinned_lock);
 	}
+#endif
 	return retval;
 }
 
@@ -134,11 +136,13 @@
 			kfree(mm->context.ldt);
 		mm->context.size = 0;
 	}
+#ifndef CONFIG_XEN_SHADOW_MODE
 	if (!mm->context.pinned) {
 		spin_lock(&mm_unpinned_lock);
 		list_del(&mm->context.unpinned);
 		spin_unlock(&mm_unpinned_lock);
 	}
+#endif
 }
 
 static int read_ldt(void __user * ptr, unsigned long bytecount)
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c	2005-06-08 12:43:02.000000000 -0400
+++ xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/setup.c	2005-06-15 14:46:12.000000000 -0400
@@ -360,8 +360,10 @@
 shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
 EXPORT_SYMBOL(HYPERVISOR_shared_info);
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 unsigned int *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
 EXPORT_SYMBOL(phys_to_machine_mapping);
+#endif
 
 /* Raw start-of-day parameters from the hypervisor. */
 union xen_start_info_union xen_start_info_union;
@@ -1158,7 +1160,9 @@
 	}
 #endif
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 	phys_to_machine_mapping = (unsigned int *)xen_start_info.mfn_list;
+#endif
 
 	return max_low_pfn;
 }
@@ -1511,6 +1515,7 @@
 	find_smp_config();
 #endif
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
 	/* Make sure we have a correctly sized P->M table. */
 	if (max_pfn != xen_start_info.nr_pages) {
 		phys_to_machine_mapping = alloc_bootmem_low_pages(
@@ -1547,7 +1552,7 @@
 	}
 	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
 	     virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
-
+#endif /* ! CONFIG_XEN_SHADOW_TRANSLATE_MODE */
 
 	/*
 	 * NOTE: at this point the bootmem allocator is fully available.
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c	2005-06-10 09:23:25.000000000 -0400
+++ xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/i386/mm/hypervisor.c	2005-06-15 14:46:43.000000000 -0400
@@ -248,6 +248,7 @@
 
 void xen_contig_memory(unsigned long vstart, unsigned int order)
 {
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
     /*
      * Ensure multi-page extents are contiguous in machine memory. This code 
      * could be cleaned up some, and the number of hypercalls reduced.
@@ -293,6 +294,7 @@
     flush_tlb_all();
 
     balloon_unlock(flags);
+#endif
 }
 
 #ifdef CONFIG_XEN_PHYSDEV_ACCESS
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	2005-06-15 14:46:12.000000000 -0400
@@ -408,6 +408,7 @@
 }
 #endif /* CONFIG_XEN_SHADOW_MODE */
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 LIST_HEAD(mm_unpinned);
 DEFINE_SPINLOCK(mm_unpinned_lock);
 
@@ -454,6 +455,7 @@
 	}
 }
 
+
 void mm_pin(struct mm_struct *mm)
 {
     spin_lock(&mm->page_table_lock);
@@ -521,3 +523,4 @@
     if ( mm->context.pinned && (atomic_read(&mm->mm_count) == 1) )
         mm_unpin(mm);
 }
+#endif /* CONFIG_XEN_SHADOW_MODE */
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/Kconfig xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/Kconfig
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/Kconfig	2005-05-16 13:05:03.000000000 -0400
+++ xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/Kconfig	2005-06-15 14:46:12.000000000 -0400
@@ -124,11 +124,21 @@
 	  space.  Odds are that you want to say N here.
 
 config XEN_SHADOW_MODE
-	bool "Fake shadow mode"
+	bool "Build linux to use Xen's shadow mode support (EXPERIMENTAL)"
+	depends on EXPERIMENTAL
 	default n
-    help
-      fakes out a shadow mode kernel
+	help
+	  Builds a xenolinux that expects Xen's shadow mode support to be
+          enabled.
 
+config XEN_SHADOW_TRANSLATE_MODE
+	bool "Build linux to use Xen's shadow translate mode support (EXPERIMENTAL)"
+	depends on EXPERIMENTAL
+	depends on XEN_SHADOW_MODE
+	default n
+	help
+	  Builds a xenolinux that expects Xen's shadow translate mode support
+	  to be enabled.
 
 config XEN_SCRUB_PAGES
 	bool "Scrub memory before freeing it to Xen"
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c	2005-06-04 18:07:26.000000000 -0400
+++ xeno-ft-clean/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c	2005-06-15 14:46:12.000000000 -0400
@@ -93,7 +93,9 @@
     extern void time_suspend(void);
     extern void time_resume(void);
     extern unsigned long max_pfn;
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
     extern unsigned int *pfn_to_mfn_frame_list;
+#endif
 
     suspend_record = (suspend_record_t *)__get_free_page(GFP_KERNEL);
     if ( suspend_record == NULL )
@@ -139,6 +141,7 @@
 
     memset(empty_zero_page, 0, PAGE_SIZE);
 
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
     for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
     {
         pfn_to_mfn_frame_list[j] = 
@@ -146,7 +149,7 @@
     }
     HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
         virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
-
+#endif /* ! CONFIG_XEN_SHADOW_TRANSLATE_MODE */
     gnttab_resume();
 
     irq_resume();
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c xeno-ft-clean/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c
--- xen-unstable.latest/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c	2005-04-13 05:44:49.000000000 -0400
+++ xeno-ft-clean/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c	2005-06-15 14:46:12.000000000 -0400
@@ -197,12 +197,14 @@
                 BUG();
 
             pfn = page - mem_map;
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
             if ( phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY )
                 BUG();
 
             /* Update P->M and M->P tables. */
             phys_to_machine_mapping[pfn] = mfn_list[i];
             xen_machphys_update(mfn_list[i], pfn);
+#endif
             
             /* Link back into the page tables if it's not a highmem page. */
             if ( pfn < max_low_pfn )
@@ -239,7 +241,11 @@
             }
 
             pfn = page - mem_map;
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
             mfn_list[i] = phys_to_machine_mapping[pfn];
+#else
+            mfn_list[i] = pfn;
+#endif
 
             if ( !PageHighMem(page) )
             {
@@ -266,7 +272,9 @@
         for ( i = 0; i < debt; i++ )
         {
             pfn = mfn_to_pfn(mfn_list[i]);
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE_MODE
             phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
+#endif
             balloon_append(pfn_to_page(pfn));
         }
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h xeno-ft-clean/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h
--- xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft-clean/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h	2005-06-15 14:46:12.000000000 -0400
@@ -41,9 +41,15 @@
 		: : "r" (0) );
 }
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 extern void mm_pin(struct mm_struct *mm);
 extern void mm_unpin(struct mm_struct *mm);
 void mm_pin_all(void);
+#else
+#define mm_pin(_mm) ((void)0)
+#define mm_unpin(_mm) ((void)0)
+#define mm_pin_all() ((void)0)
+#endif
 
 static inline void switch_mm(struct mm_struct *prev,
 			     struct mm_struct *next,
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h xeno-ft-clean/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h
--- xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h	2005-06-01 14:06:28.000000000 -0400
+++ xeno-ft-clean/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h	2005-06-15 14:46:12.000000000 -0400
@@ -16,6 +16,7 @@
 	struct list_head unpinned;
 } mm_context_t;
 
+#ifndef CONFIG_XEN_SHADOW_MODE
 extern struct list_head mm_unpinned;
 extern spinlock_t mm_unpinned_lock;
 
@@ -23,4 +24,6 @@
 extern void _arch_exit_mmap(struct mm_struct *mm);
 #define arch_exit_mmap(_mm) _arch_exit_mmap(_mm)
 
+#endif /* CONFIG_XEN_SHADOW_MODE */
+
 #endif
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h xeno-ft-clean/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h
--- xen-unstable.latest/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h	2005-05-31 08:28:29.000000000 -0400
+++ xeno-ft-clean/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/page.h	2005-06-15 14:46:12.000000000 -0400
@@ -58,9 +58,14 @@
 #define copy_user_page(to, from, vaddr, pg)	copy_page(to, from)
 
 /**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
+#ifdef CONFIG_XEN_SHADOW_MODE
+# define pfn_to_mfn(_pfn) ((unsigned long)(_pfn))
+# define mfn_to_pfn(_mfn) ((unsigned long)(_mfn))
+#else
 extern unsigned int *phys_to_machine_mapping;
-#define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
-#define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
+# define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
+# define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
+#endif
 static inline unsigned long phys_to_machine(unsigned long phys)
 {
 	unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/libxc/Makefile xeno-ft-clean/tools/libxc/Makefile
--- xen-unstable.latest/tools/libxc/Makefile	2005-06-06 08:50:14.000000000 -0400
+++ xeno-ft-clean/tools/libxc/Makefile	2005-06-15 14:46:13.000000000 -0400
@@ -22,6 +22,7 @@
 SRCS     += xc_load_bin.c
 SRCS     += xc_load_elf.c
 SRCS     += xc_linux_build.c
+SRCS     += xc_linuxtranslate_build.c
 SRCS     += xc_plan9_build.c
 SRCS     += xc_linux_restore.c
 SRCS     += xc_linux_save.c
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/libxc/xc.h xeno-ft-clean/tools/libxc/xc.h
--- xen-unstable.latest/tools/libxc/xc.h	2005-06-09 13:29:55.000000000 -0400
+++ xeno-ft-clean/tools/libxc/xc.h	2005-06-15 14:46:13.000000000 -0400
@@ -256,6 +256,17 @@
                    unsigned int store_evtchn,
                    unsigned long *store_mfn);
 
+int xc_linuxtranslate_build(int xc_handle,
+                   u32 domid,
+                   const char *image_name,
+                   const char *ramdisk_name,
+                   const char *cmdline,
+                   unsigned int control_evtchn,
+                   unsigned long flags,
+                   unsigned int vcpus,
+                   unsigned int store_evtchn,
+                   unsigned long *store_mfn);
+
 int
 xc_plan9_build (int xc_handle,
                 u32 domid, 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/libxc/xc_linuxtranslate_build.c xeno-ft-clean/tools/libxc/xc_linuxtranslate_build.c
--- xen-unstable.latest/tools/libxc/xc_linuxtranslate_build.c	1969-12-31 19:00:00.000000000 -0500
+++ xeno-ft-clean/tools/libxc/xc_linuxtranslate_build.c	2005-06-15 14:46:13.000000000 -0400
@@ -0,0 +1,631 @@
+/******************************************************************************
+ * xc_linuxtranslate_build.c
+ * Derived from xc_linux_build.c
+ */
+
+#include "xc_private.h"
+#include <xen/grant_table.h>
+//#include "../../xen/include/public/grant_table.h"
+#define ELFSIZE 32
+#include "xc_elf.h"
+#include <stdlib.h>
+#include <zlib.h>
+
+#if !defined(__i386__)
+# error Linux translate only available in i386 mode!
+#endif
+
+#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
+#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
+
+#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
+#define round_pgdown(_p)  ((_p)&PAGE_MASK)
+
+// **FIXME** Kludge to know the number of grant table frames.  Needs something
+//           more consistant, but the information is currently not exported?
+#define ORDER_GRANT_FRAMES   2
+#define NR_GRANT_FRAMES      (1U << ORDER_GRANT_FRAMES)
+#define NR_GRANT_ENTRIES     (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
+
+// **FIXME** Another shameless cut and paste job...
+static int
+do_gnttab_op( int xc_handle,
+              unsigned long cmd,
+              gnttab_op_t *op,
+              unsigned long count )
+{
+  int ret = -1;
+  privcmd_hypercall_t hypercall;
+
+  hypercall.op     = __HYPERVISOR_grant_table_op;
+  hypercall.arg[0] = cmd;
+  hypercall.arg[1] = (unsigned long)(op);
+  hypercall.arg[2] = count;
+
+  if ( mlock(op, sizeof(*op)) != 0 )
+    {
+      PERROR("Could not lock memory for Xen hypercall");
+      goto out1;
+    }
+
+  if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
+    {
+      printf("do_gnttab_op: hypercall returned error %d\n", ret);
+      goto out2;
+    }
+
+ out2: (void)munlock(op, sizeof(*op));
+ out1: return ret;
+}
+
+static int probeimageformat(char *image,
+                            unsigned long image_size,
+                            struct load_funcs *load_funcs)
+{
+    if ( probe_elf(image, image_size, load_funcs) &&
+         probe_bin(image, image_size, load_funcs) )
+    {
+        ERROR( "Unrecognized image format" );
+        return -EINVAL;
+    }
+
+    return 0;
+}
+
+static int setup_guest(int xc_handle,
+                         u32 dom,
+                         char *image, unsigned long image_size,
+                         gzFile initrd_gfd, unsigned long initrd_len,
+                         unsigned long nr_pages,
+                         unsigned long *pvsi, unsigned long *pvke,
+			 unsigned long *pvss, vcpu_guest_context_t *ctxt,
+                         const char *cmdline,
+                         unsigned long shared_info_frame,
+                         unsigned int control_evtchn,
+                         unsigned long flags,
+                         unsigned int vcpus,
+			 unsigned int store_evtchn, unsigned long *store_mfn)
+{
+    l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
+    l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
+    unsigned long *page_array = NULL;
+    unsigned long ml2tab, pl2tab;
+    unsigned long ml1tab, pl1tab;
+    unsigned long mfn, pfn;
+    unsigned long count, i;
+    start_info_t *start_info;
+    shared_info_t *shared_info;
+    mmu_t *mmu = NULL;
+    int rc;
+
+    unsigned long nr_pt_pages;
+    unsigned long ppt_alloc;
+    unsigned long *physmap, *physmap_e, physmap_pfn;
+
+    struct load_funcs load_funcs;
+    struct domain_setup_info dsi;
+    unsigned long vinitrd_start;
+    unsigned long vinitrd_end;
+    unsigned long vphysmap_start;
+    unsigned long vphysmap_end;
+    unsigned long vstartinfo_start;
+    unsigned long vstartinfo_end;
+    unsigned long vstoreinfo_start;
+    unsigned long vstoreinfo_end;
+    unsigned long vstack_start;
+    unsigned long vstack_end;
+    unsigned long vpt_start;
+    unsigned long vpt_end;
+    unsigned long v_end;
+    unsigned long pshared_info;
+    unsigned long pshared_grant;  // pfn of the shared grant
+
+    rc = probeimageformat(image, image_size, &load_funcs);
+    if ( rc != 0 )
+        goto error_out;
+
+    memset(&dsi, 0, sizeof(struct domain_setup_info));
+
+    rc = (load_funcs.parseimage)(image, image_size, &dsi);
+    if ( rc != 0 )
+        goto error_out;
+
+    if ( (dsi.v_start & (PAGE_SIZE-1)) != 0 )
+    {
+        PERROR("Guest OS must load to a page boundary.\n");
+        goto error_out;
+    }
+
+    /* Untranslated guests are given the mfn of the shared_info frame, and
+     * they are expected to map it.  We need to allocate a pfn to map the
+     * mfn into; so we steal a page from the end.  We don't need to put
+     * it in a page table, we just need to have a p2m and m2p for it... */
+    pshared_info = nr_pages;
+    /* The same for the grant table structure */
+    pshared_grant = nr_pages+1;
+
+    /*
+     * Why do we need this? The number of page-table frames depends on the 
+     * size of the bootstrap address space. But the size of the address space 
+     * depends on the number of page-table frames (since each one is mapped 
+     * read-only). We have a pair of simultaneous equations in two unknowns, 
+     * which we solve by exhaustive search.
+     */
+    vinitrd_start    = round_pgup(dsi.v_end);
+    vinitrd_end      = vinitrd_start + initrd_len;
+    vphysmap_start   = round_pgup(vinitrd_end);
+    vphysmap_end     = vphysmap_start + ((nr_pages+1+NR_GRANT_FRAMES) * sizeof(unsigned long));
+    vpt_start        = round_pgup(vphysmap_end);
+    for ( nr_pt_pages = 2; ; nr_pt_pages++ )
+    {
+        vpt_end          = vpt_start + (nr_pt_pages * PAGE_SIZE);
+        vstartinfo_start = vpt_end;
+        vstartinfo_end   = vstartinfo_start + PAGE_SIZE;
+	/* Place store shared page after startinfo */
+	vstoreinfo_start = vstartinfo_end;
+	vstoreinfo_end   = vstartinfo_end + PAGE_SIZE;
+	vstack_start     = vstoreinfo_end;
+        vstack_end       = vstack_start + PAGE_SIZE;
+        v_end            = (vstack_end + (1UL<<22)-1) & ~((1UL<<22)-1);
+        if ( (v_end - vstack_end) < (512UL << 10) )
+            v_end += 1UL << 22; /* Add extra 4MB to get >= 512kB padding. */
+        if ( (((v_end - dsi.v_start + ((1<<L2_PAGETABLE_SHIFT)-1)) >> 
+               L2_PAGETABLE_SHIFT) + 1) <= nr_pt_pages )
+            break;
+    }
+
+#define _p(a) ((void *) (a))
+
+    printf("VIRTUAL MEMORY ARRANGEMENT:\n"
+           " Loaded kernel: %p->%p\n"
+           " Init. ramdisk: %p->%p\n"
+           " Phys-Mach map: %p->%p\n"
+           " Page tables:   %p->%p\n"
+           " Start info:    %p->%p\n"
+	   " Store page:    %p->%p\n"
+           " Boot stack:    %p->%p\n"
+           " TOTAL:         %p->%p\n",
+           _p(dsi.v_kernstart), _p(dsi.v_kernend), 
+           _p(vinitrd_start), _p(vinitrd_end),
+           _p(vphysmap_start), _p(vphysmap_end),
+           _p(vpt_start), _p(vpt_end),
+           _p(vstartinfo_start), _p(vstartinfo_end),
+           _p(vstoreinfo_start), _p(vstoreinfo_end),
+           _p(vstack_start), _p(vstack_end),
+           _p(dsi.v_start), _p(v_end));
+    printf(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));
+
+    if ( (v_end - dsi.v_start) > (nr_pages * PAGE_SIZE) )
+    {
+        printf("Initial guest OS requires too much space\n"
+               "(%luMB is greater than %luMB limit)\n",
+               (v_end-dsi.v_start)>>20, (nr_pages<<PAGE_SHIFT)>>20);
+        goto error_out;
+    }
+
+    if ( (page_array = malloc((nr_pages+1+NR_GRANT_FRAMES) * sizeof(unsigned long))) == NULL )
+    {
+        PERROR("Could not allocate memory");
+        goto error_out;
+    }
+
+
+    if ( xc_get_pfn_list(xc_handle, dom, page_array, nr_pages) != nr_pages )
+    {
+        PERROR("Could not get the page frame list");
+        goto error_out;
+    }
+
+    (load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array, &dsi);
+
+    /* Load the initial ramdisk image. */
+    if ( initrd_len != 0 )
+    {
+        for ( i = (vinitrd_start - dsi.v_start); 
+              i < (vinitrd_end - dsi.v_start); i += PAGE_SIZE )
+        {
+            char page[PAGE_SIZE];
+            if ( gzread(initrd_gfd, page, PAGE_SIZE) == -1 )
+            {
+                PERROR("Error reading initrd image, could not");
+                goto error_out;
+            }
+            xc_copy_to_domain_page(xc_handle, dom,
+                                page_array[i>>PAGE_SHIFT], page);
+        }
+    }
+
+    if ( (mmu = init_mmu_updates(xc_handle, dom)) == NULL )
+        goto error_out;
+
+    /* First allocate page for page dir. */
+    ppt_alloc = (vpt_start - dsi.v_start) >> PAGE_SHIFT;
+    pl2tab = ppt_alloc++;
+    ml2tab = page_array[pl2tab];
+    ctxt->pt_base = ml2tab << PAGE_SHIFT;
+
+    /* Initialise the page tables. */
+    if ( (vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 
+                                        PROT_READ|PROT_WRITE, 
+					ml2tab)) == NULL )
+        goto error_out;
+    memset(vl2tab, 0, PAGE_SIZE);
+    vl2e = &vl2tab[l2_table_offset(dsi.v_start)];
+    fprintf(stderr, " v_start %lx l2_table_offset %lx\n", 
+    			dsi.v_start,
+			l2_table_offset(dsi.v_start));
+    for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ )
+    {    
+        if ( ((unsigned long)vl1e & (PAGE_SIZE-1)) == 0 )
+        {
+	    pl1tab = ppt_alloc++;
+	    ml1tab = page_array[pl1tab];
+	    fprintf(stderr, " allocating new l1 page; pfn %lx, mfn %lx\n",
+	    			pl1tab, ml1tab);
+            if ( vl1tab != NULL )
+                munmap(vl1tab, PAGE_SIZE);
+            if ( (vl1tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
+                                                PROT_READ|PROT_WRITE,
+						ml1tab)) == NULL )
+            {
+                munmap(vl2tab, PAGE_SIZE);
+                goto error_out;
+            }
+            memset(vl1tab, 0, PAGE_SIZE);
+            vl1e = &vl1tab[l1_table_offset(dsi.v_start + (count<<PAGE_SHIFT))];
+            *vl2e++ = (pl1tab << PAGE_SHIFT )| L2_PROT;
+        }
+
+	pfn=count;
+	mfn=page_array[pfn];
+
+        *vl1e = (pfn << PAGE_SHIFT) | L1_PROT;
+	fprintf(stderr, " %lx:%lx\n", dsi.v_start + (count << PAGE_SHIFT), *vl1e);
+
+        vl1e++;
+    }
+    munmap(vl1tab, PAGE_SIZE);
+    munmap(vl2tab, PAGE_SIZE);
+
+    /* Write the phys->machine and machine->phys table entries. */
+    physmap_pfn = (vphysmap_start - dsi.v_start) >> PAGE_SHIFT;
+    physmap = physmap_e = xc_map_foreign_range(
+        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+        page_array[physmap_pfn++]);
+    for ( count = 0; count < nr_pages; count++ )
+    {
+	pfn = count;
+	mfn = page_array[count];
+        if ( add_mmu_update(xc_handle, mmu,
+                            (mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, 
+			    pfn) )
+        {
+            munmap(physmap, PAGE_SIZE);
+            goto error_out;
+        }
+        *physmap_e++ = pfn;
+        if ( ((unsigned long)physmap_e & (PAGE_SIZE-1)) == 0 )
+        {
+            munmap(physmap, PAGE_SIZE);
+            physmap = physmap_e = xc_map_foreign_range(
+                xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+                page_array[physmap_pfn++]);
+        }
+    }
+
+    if(xc_shadow_control(xc_handle, 
+    				dom, 
+				DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE,
+				NULL,
+				0,
+				NULL)<0) {
+	PERROR("Could not enable full translate mode!");
+	goto error_out;
+    } 
+
+    // Map in shared info page
+    mfn = shared_info_frame;
+    pfn = pshared_info;
+    printf("SHARE: Mapping mfn=%8lx <-> pfn=%8lx\n",mfn,pfn);
+    if( add_mmu_update(xc_handle, mmu,
+		       (mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE,
+		       pfn)) {
+      munmap(physmap, PAGE_SIZE);
+      goto error_out;
+    }
+    *physmap_e++ = pfn;
+    if ( ((unsigned long)physmap_e & (PAGE_SIZE-1)) == 0 ) {
+      munmap(physmap, PAGE_SIZE);
+      physmap = physmap_e = xc_map_foreign_range(
+						 xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+						 physmap_pfn++);
+      //page_array[physmap_pfn++]);
+    }
+    fprintf(stderr, "SHARE: setup_guest: finish_mmu_updates\n");
+    /* Send the page update requests down to the hypervisor. */
+    if ( finish_mmu_updates(xc_handle, mmu) )
+      goto error_out;
+    
+
+    // Map in grant tables
+    gnttab_op_t     op;
+    
+    op.u.setup_table.dom        = (domid_t)dom;
+    rc = do_gnttab_op(xc_handle, GNTTABOP_get_shared_mfn, &op, 1);
+    for (count=0; count < NR_GRANT_FRAMES ;count++) {
+      mfn = op.u.shared_mfn.mfn+count;
+      pfn = pshared_grant+count;
+      printf("GRANT: Mapping mfn=%8lx <-> pfn=%8lx\n",mfn,pfn);
+      if( add_mmu_update(xc_handle, mmu,
+			 (mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE,
+			 pfn)) {
+	munmap(physmap, PAGE_SIZE);
+	goto error_out;
+      }
+      *physmap_e++ = pfn;
+      if ( ((unsigned long)physmap_e & (PAGE_SIZE-1)) == 0 ) {
+	munmap(physmap, PAGE_SIZE);
+	physmap = physmap_e = xc_map_foreign_range(
+						   xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+						   //physmap_pfn++);
+						   page_array[physmap_pfn++]);
+      }
+    }
+    munmap(physmap,PAGE_SIZE);
+    fprintf(stderr, "GRANT: setup_guest: finish_mmu_updates\n");
+    /* Send the page update requests down to the hypervisor. */
+    if ( finish_mmu_updates(xc_handle, mmu) )
+      goto error_out;
+
+
+    /*
+     * Pin down l2tab addr as page dir page - causes hypervisor to provide
+     * correct protection for the page
+     */ 
+    if ( pin_table(xc_handle, 
+    			MMUEXT_PIN_L2_TABLE, 
+			ml2tab,
+			dom) )
+        goto error_out;
+
+    start_info = xc_map_foreign_range(
+        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
+	(vstartinfo_start-dsi.v_start)>>PAGE_SHIFT);
+        //page_array[(vstartinfo_start-dsi.v_start)>>PAGE_SHIFT]);
+
+    memset(start_info, 0, sizeof(*start_info));
+    start_info->nr_pages     = nr_pages;
+    start_info->shared_info  = pshared_info << PAGE_SHIFT;
+    start_info->flags        = flags;
+    start_info->pt_base      = vpt_start;
+    start_info->nr_pt_frames = nr_pt_pages;
+    start_info->mfn_list     = vphysmap_start;
+    start_info->domain_controller_evtchn = control_evtchn;
+    start_info->store_page   = vstoreinfo_start;
+    start_info->store_evtchn = store_evtchn;
+
+    if ( initrd_len != 0 )
+    {
+        start_info->mod_start    = vinitrd_start;
+        start_info->mod_len      = initrd_len;
+    }
+    strncpy((char *)start_info->cmd_line, cmdline, MAX_GUEST_CMDLINE);
+    start_info->cmd_line[MAX_GUEST_CMDLINE-1] = '\0';
+    munmap(start_info, PAGE_SIZE);
+
+    /* Tell our caller where we told domain store page was. */
+    pfn=((vstoreinfo_start-dsi.v_start)>>PAGE_SHIFT);
+    mfn=page_array[pfn];
+    /* XXX -- for now, we give the gpfn; the hypervisor should translate */
+    *store_mfn = pfn;
+
+
+    /* shared_info page starts its life empty. */
+    shared_info = xc_map_foreign_range(
+				       xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, pshared_info);//shared_info_frame);
+    memset(shared_info, 0, sizeof(shared_info_t));
+    /* Mask all upcalls... */
+    for ( i = 0; i < MAX_VIRT_CPUS; i++ )
+        shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
+
+    shared_info->n_vcpu = vcpus;
+    printf(" VCPUS:         %d\n", shared_info->n_vcpu);
+
+    munmap(shared_info, PAGE_SIZE);
+
+    fprintf(stderr, "setup_guest: finish_mmu_updates\n");
+    /* Send the page update requests down to the hypervisor. */
+    if ( finish_mmu_updates(xc_handle, mmu) )
+        goto error_out;
+
+    free(mmu);
+    free(page_array);
+
+    *pvsi = vstartinfo_start;
+    *pvss = vstack_start;
+    *pvke = dsi.v_kernentry;
+
+    fprintf(stderr, "setup_guest: done!");
+    return 0;
+
+ error_out:
+    if ( mmu != NULL )
+        free(mmu);
+    if ( page_array != NULL )
+        free(page_array);
+    return -1;
+}
+
+int xc_linuxtranslate_build(int xc_handle,
+                   u32 domid,
+                   const char *image_name,
+                   const char *ramdisk_name,
+                   const char *cmdline,
+                   unsigned int control_evtchn,
+                   unsigned long flags,
+                   unsigned int vcpus,
+		   unsigned int store_evtchn,
+		   unsigned long *store_mfn)
+{
+    dom0_op_t launch_op, op;
+    int initrd_fd = -1;
+    gzFile initrd_gfd = NULL;
+    int rc, i;
+    vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
+    unsigned long nr_pages;
+    char         *image = NULL;
+    unsigned long image_size, initrd_size=0;
+    unsigned long vstartinfo_start, vkern_entry, vstack_start;
+
+    if ( (nr_pages = xc_get_tot_pages(xc_handle, domid)) < 0 )
+    {
+        PERROR("Could not find total pages for domain");
+        goto error_out;
+    }
+
+    if ( (image = xc_read_kernel_image(image_name, &image_size)) == NULL )
+        goto error_out;
+
+    if ( (ramdisk_name != NULL) && (strlen(ramdisk_name) != 0) )
+    {
+        if ( (initrd_fd = open(ramdisk_name, O_RDONLY)) < 0 )
+        {
+            PERROR("Could not open the initial ramdisk image");
+            goto error_out;
+        }
+
+        initrd_size = xc_get_filesz(initrd_fd);
+
+        if ( (initrd_gfd = gzdopen(initrd_fd, "rb")) == NULL )
+        {
+            PERROR("Could not allocate decompression state for initrd");
+            goto error_out;
+        }
+    }
+
+    if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
+    {   
+        PERROR("Unable to mlock ctxt");
+        return 1;
+    }
+
+    op.cmd = DOM0_GETDOMAININFO;
+    op.u.getdomaininfo.domain = (domid_t)domid;
+    if ( (do_dom0_op(xc_handle, &op) < 0) || 
+         ((u16)op.u.getdomaininfo.domain != domid) )
+    {
+        PERROR("Could not get info on domain");
+        goto error_out;
+    }
+
+    if ( xc_domain_get_vcpu_context(xc_handle, domid, 0, ctxt) )
+    {
+        PERROR("Could not get vcpu context");
+        goto error_out;
+    }
+
+    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
+         (ctxt->pt_base != 0) )
+    {
+        ERROR("Domain is already constructed");
+        goto error_out;
+    }
+
+    if ( setup_guest(xc_handle, domid, image, image_size, 
+                       initrd_gfd, initrd_size, nr_pages, 
+                       &vstartinfo_start, &vkern_entry,
+		       &vstack_start,
+                       ctxt, cmdline,
+                       op.u.getdomaininfo.shared_info_frame,
+                       control_evtchn, flags, vcpus,
+		       store_evtchn, store_mfn) < 0 )
+    {
+        ERROR("Error constructing guest OS");
+        goto error_out;
+    }
+
+    if ( initrd_fd >= 0 )
+        close(initrd_fd);
+    if ( initrd_gfd )
+        gzclose(initrd_gfd);
+    if ( image != NULL )
+        free(image);
+
+    ctxt->flags = 0;
+
+    /*
+     * Initial register values:
+     *  DS,ES,FS,GS = FLAT_KERNEL_DS
+     *       CS:EIP = FLAT_KERNEL_CS:start_pc
+     *       SS:ESP = FLAT_KERNEL_DS:start_stack
+     *          ESI = start_info
+     *  [EAX,EBX,ECX,EDX,EDI,EBP are zero]
+     *       EFLAGS = IF | 2 (bit 1 is reserved and should always be 1)
+     */
+    ctxt->user_regs.ds = FLAT_KERNEL_DS;
+    ctxt->user_regs.es = FLAT_KERNEL_DS;
+    ctxt->user_regs.fs = FLAT_KERNEL_DS;
+    ctxt->user_regs.gs = FLAT_KERNEL_DS;
+    ctxt->user_regs.ss = FLAT_KERNEL_DS;
+    ctxt->user_regs.cs = FLAT_KERNEL_CS;
+    ctxt->user_regs.eip = vkern_entry;
+    ctxt->user_regs.esp = vstack_start + PAGE_SIZE;
+    ctxt->user_regs.esi = vstartinfo_start;
+    ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */
+
+    /* FPU is set up to default initial state. */
+    memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
+
+    /* Virtual IDT is empty at start-of-day. */
+    for ( i = 0; i < 256; i++ )
+    {
+        ctxt->trap_ctxt[i].vector = i;
+        ctxt->trap_ctxt[i].cs     = FLAT_KERNEL_CS;
+    }
+
+    /* No LDT. */
+    ctxt->ldt_ents = 0;
+    
+    /* Use the default Xen-provided GDT. */
+    ctxt->gdt_ents = 0;
+
+    /* Ring 1 stack is the initial stack. */
+    ctxt->kernel_ss = FLAT_KERNEL_DS;
+    ctxt->kernel_sp = vstack_start + PAGE_SIZE;
+
+    /* No debugging. */
+    memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg));
+
+    /* No callback handlers. */
+#if defined(__i386__)
+    ctxt->event_callback_cs     = FLAT_KERNEL_CS;
+    ctxt->event_callback_eip    = 0;
+    ctxt->failsafe_callback_cs  = FLAT_KERNEL_CS;
+    ctxt->failsafe_callback_eip = 0;
+#elif defined(__x86_64__)
+    ctxt->event_callback_eip    = 0;
+    ctxt->failsafe_callback_eip = 0;
+    ctxt->syscall_callback_eip  = 0;
+#endif
+
+    memset( &launch_op, 0, sizeof(launch_op) );
+
+    launch_op.u.setdomaininfo.domain = (domid_t)domid;
+    launch_op.u.setdomaininfo.vcpu   = 0;
+    launch_op.u.setdomaininfo.ctxt   = ctxt;
+
+    launch_op.cmd = DOM0_SETDOMAININFO;
+    rc = do_dom0_op(xc_handle, &launch_op);
+    
+    return rc;
+
+ error_out:
+    if ( initrd_gfd != NULL )
+        gzclose(initrd_gfd);
+    else if ( initrd_fd >= 0 )
+        close(initrd_fd);
+    if ( image != NULL )
+        free(image);
+
+    return -1;
+}
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/python/xen/lowlevel/xc/xc.c xeno-ft-clean/tools/python/xen/lowlevel/xc/xc.c
--- xen-unstable.latest/tools/python/xen/lowlevel/xc/xc.c	2005-06-09 13:29:55.000000000 -0400
+++ xeno-ft-clean/tools/python/xen/lowlevel/xc/xc.c	2005-06-15 14:46:13.000000000 -0400
@@ -284,6 +284,36 @@
     return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
 }
 
+static PyObject *pyxc_linuxtranslate_build(PyObject *self,
+                                  PyObject *args,
+                                  PyObject *kwds)
+{
+    XcObject *xc = (XcObject *)self;
+
+    u32   dom;
+    char *image, *ramdisk = NULL, *cmdline = "";
+    int flags = 0, vcpus = 1;
+    int control_evtchn, store_evtchn;
+    unsigned long store_mfn = 0;
+
+    static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn", 
+                                "image", "ramdisk", "cmdline", "flags",
+				"vcpus", NULL };
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssii", kwd_list,
+                                      &dom, &control_evtchn, &store_evtchn,
+                                      &image, &ramdisk, &cmdline, &flags,
+                                      &vcpus) )
+        return NULL;
+
+    if ( xc_linuxtranslate_build(xc->xc_handle, dom, image,
+                        ramdisk, cmdline, control_evtchn, flags, vcpus,
+                        store_evtchn, &store_mfn) != 0 )
+        return PyErr_SetFromErrno(xc_error);
+    
+    return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
+}
+
 static PyObject *pyxc_plan9_build(PyObject *self,
                                   PyObject *args,
                                   PyObject *kwds)
@@ -929,6 +959,17 @@
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
+    { "linuxtranslate_build", 
+      (PyCFunction)pyxc_linuxtranslate_build, 
+      METH_VARARGS | METH_KEYWORDS, "\n"
+      "Build a new shadow-translated Linux guest OS.\n"
+      " dom     [int]:      Identifier of domain to build into.\n"
+      " image   [str]:      Name of kernel image file. May be gzipped.\n"
+      " ramdisk [str, n/a]: Name of ramdisk file, if any.\n"
+      " cmdline [str, n/a]: Kernel parameters, if any.\n\n"
+      " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
+      "Returns: [int] 0 on success; -1 on error.\n" },
+
     { "plan9_build",
       (PyCFunction)pyxc_plan9_build,
       METH_VARARGS | METH_KEYWORDS, "\n"
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/python/xen/xend/image.py xeno-ft-clean/tools/python/xen/xend/image.py
--- xen-unstable.latest/tools/python/xen/xend/image.py	2005-06-09 13:29:55.000000000 -0400
+++ xeno-ft-clean/tools/python/xen/xend/image.py	2005-06-15 14:46:13.000000000 -0400
@@ -219,6 +219,28 @@
             return 0
         return ret
 
+class LinuxtranslateImageHandler(ImageHandler):
+
+    ostype = "linuxtranslate"
+
+    def buildDomain(self):
+        if self.vm.store_channel:
+            store_evtchn = self.vm.store_channel.port2
+        else:
+            store_evtchn = 0
+        ret = xc.linuxtranslate_build(dom            = self.vm.getDomain(),
+                             image          = self.kernel,
+                             control_evtchn = self.vm.channel.getRemotePort(),
+                             store_evtchn   = store_evtchn,
+                             cmdline        = self.cmdline,
+                             ramdisk        = self.ramdisk,
+                             flags          = self.flags,
+                             vcpus          = self.vm.vcpus)
+        if isinstance(ret, dict):
+            self.vm.store_mfn = ret.get('store_mfn')
+            return 0
+        return ret
+
 class Plan9ImageHandler(ImageHandler):
 
     ostype = "plan9"
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tools/python/xen/xend/XendDomainInfo.py xeno-ft-clean/tools/python/xen/xend/XendDomainInfo.py
--- xen-unstable.latest/tools/python/xen/xend/XendDomainInfo.py	2005-06-09 13:29:55.000000000 -0400
+++ xeno-ft-clean/tools/python/xen/xend/XendDomainInfo.py	2005-06-15 14:46:13.000000000 -0400
@@ -1001,10 +1001,12 @@
      addImageHandlerClass, \
      ImageHandler,         \
      LinuxImageHandler,    \
+     LinuxtranslateImageHandler,    \
      Plan9ImageHandler,    \
      VmxImageHandler
 
 addImageHandlerClass(LinuxImageHandler)
+addImageHandlerClass(LinuxtranslateImageHandler)
 addImageHandlerClass(Plan9ImageHandler)
 addImageHandlerClass(VmxImageHandler)
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/tree_push.sh xeno-ft-clean/tree_push.sh
--- xen-unstable.latest/tree_push.sh	2005-06-15 13:56:32.000000000 -0400
+++ xeno-ft-clean/tree_push.sh	1969-12-31 19:00:00.000000000 -0500
@@ -1,2 +0,0 @@
-#!/bin/sh
-FROM=.  TO=root@covirt6:/home/xeno-unstable ./exclude_rsync.sh
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/arch/x86/mm.c xeno-ft-clean/xen/arch/x86/mm.c
--- xen-unstable.latest/xen/arch/x86/mm.c	2005-06-13 08:30:54.000000000 -0400
+++ xeno-ft-clean/xen/arch/x86/mm.c	2005-06-15 14:48:47.000000000 -0400
@@ -1703,6 +1703,8 @@
             break;
 
         case MMUEXT_NEW_BASEPTR:
+            if ( shadow_mode_translate(d) )
+                op.mfn = __gpfn_to_mfn(d, op.mfn);
             okay = new_guest_cr3(op.mfn);
             percpu_info[cpu].deferred_ops &= ~DOP_FLUSH_TLB;
             break;
@@ -1815,6 +1817,9 @@
                 okay = 0;
                 break;
             }
+
+            if ( shadow_mode_translate(d) )
+                BUG(); // not supported yet, need to think about this.
             
             e = percpu_info[cpu].foreign;
             if ( unlikely(e == NULL) )
@@ -2031,9 +2036,35 @@
                     page, type_info & (PGT_type_mask|PGT_va_mask))) )
                 {
                     l1_pgentry_t l1e;
+                    unsigned long val;
+                    if (unlikely(shadow_mode_translate(FOREIGNDOM) && IS_PRIV(d))) {
+                        unsigned long gpfn2=l1e_get_pfn(l1e_from_intpte(req.val));
+                        unsigned long mode2=req.val & (PAGE_SIZE-1);
+                        unsigned long mfn2  = gpfn_to_mfn_foreign(FOREIGNDOM,gpfn2);
+                        unsigned long mfn2p = __mfn_to_gpfn(FOREIGNDOM,gpfn2);
+                        val = (mfn2<<PAGE_SHIFT) | mode2;
+                        if (mfn2==INVALID_MFN) {
+                            val=req.val;
+                            printk("Invalid MFN!\n");
+                            printk("PGT_l1_page_table: pte(0x%8lx) -> mfn(0x%8lx->0x%8lx->0x%8lx), fdom(%d)(%d) -> dom(%d)(%d)\n",
+                                   mfn,mfn2p,gpfn2,mfn2,
+                                   FOREIGNDOM->domain_id,shadow_mode_translate(FOREIGNDOM),
+                                   d->domain_id,shadow_mode_translate(d));
+                        } else if ((page_get_owner(&frame_table[mfn2])) &&
+                                   foreigndom != page_get_owner(&frame_table[mfn2])->domain_id) {
+                            val=req.val;
+                            printk("Owner mismatch!!\n");
+                            printk("PGT_l1_page_table: pte(0x%8lx) -> mfn(0x%8lx->0x%8lx->0x%8lx), fdom(%d)(%d) -> dom(%d)(%d)\n",
+                                   mfn,mfn2p,gpfn2,mfn2,
+                                   FOREIGNDOM->domain_id,shadow_mode_translate(FOREIGNDOM),
+                                   d->domain_id,shadow_mode_translate(d));
+                        }
+                    } else {
+                        val = req.val;
+                    }
 
                     /* FIXME: doesn't work with PAE */
-                    l1e = l1e_from_intpte(req.val);
+                    l1e = l1e_from_intpte(val);
                     okay = mod_l1_entry(va, l1e);
                     if ( okay && unlikely(shadow_mode_enabled(d)) )
                         shadow_l1_normal_pt_update(d, req.ptr, l1e, &sh_mapcache);
@@ -2102,9 +2133,22 @@
                             shadow_mark_mfn_out_of_sync(v, gpfn, mfn);
                         }
                     }
-
-                    *(unsigned long *)va = req.val;
-                    okay = 1;
+                    if (unlikely(shadow_mode_translate(FOREIGNDOM) && IS_PRIV(d))) {
+                        unsigned long gpfn2=req.val>>PAGE_SHIFT;
+                        unsigned long mode2=req.val & (PAGE_SIZE-1);
+                        unsigned long mfn2 =gpfn_to_mfn_foreign(FOREIGNDOM,gpfn2);
+                        unsigned long val;
+                        val = (mfn2<<PAGE_SHIFT) | mode2;
+                        *(unsigned long *)va = val;
+                        okay=1;
+                        DPRINTK("Mapping pte(0x%8lx) -> mfn(0x%8lx), fdom(%d)(%d) -> dom(%d)(%d)\n",
+                               mfn,mfn2,
+                               FOREIGNDOM->domain_id,shadow_mode_translate(FOREIGNDOM),
+                               d->domain_id,shadow_mode_translate(d));
+                    } else {
+                        *(unsigned long *)va = req.val;
+                        okay = 1;
+                    }
 
                     if ( shadow_mode_enabled(d) )
                         shadow_unlock(d);
@@ -2128,8 +2172,6 @@
             if ( unlikely(shadow_mode_translate(FOREIGNDOM) && IS_PRIV(d)) )
             {
                 shadow_lock(FOREIGNDOM);
-                printk("privileged guest dom%d requests pfn=%lx to map mfn=%lx for dom%d\n",
-                       d->domain_id, gpfn, mfn, FOREIGNDOM->domain_id);
                 set_machinetophys(mfn, gpfn);
                 set_p2m_entry(FOREIGNDOM, gpfn, mfn, &sh_mapcache, &mapcache);
                 okay = 1;
@@ -2440,6 +2482,7 @@
 {
     int nr_pages = (entries + 511) / 512;
     unsigned long frames[16];
+    struct domain* d = current->domain;
     long ret;
 
     if ( copy_from_user(frames, frame_list, nr_pages * sizeof(unsigned long)) )
@@ -2447,6 +2490,18 @@
 
     LOCK_BIGLOCK(current->domain);
 
+    if(shadow_mode_translate(d)) {
+    	int i;
+	unsigned long mfn;
+	shadow_lock(d);
+	for(i=0; i<nr_pages; i++) {
+		mfn = __gpfn_to_mfn(d, frames[i]);
+		printk(" do_set_gdt: pfn %lx to mfn %lx\n", frames[i], mfn);
+		frames[i]=mfn;
+	}
+	shadow_unlock(d);
+    }
+
     if ( (ret = set_gdt(current, frames, entries)) == 0 )
         local_flush_tlb();
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/arch/x86/shadow.c xeno-ft-clean/xen/arch/x86/shadow.c
--- xen-unstable.latest/xen/arch/x86/shadow.c	2005-06-07 09:41:55.000000000 -0400
+++ xeno-ft-clean/xen/arch/x86/shadow.c	2005-06-15 14:46:14.000000000 -0400
@@ -632,17 +632,51 @@
             continue;
 
         count = 0;
-        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next )
-            if ( MFN_PINNED(x->smfn) )
-                count++;
+
+        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next ) {
+	    /* Skip entries that are writable_pred) */
+	    switch(x->gpfn_and_flags & PGT_type_mask){
+		case PGT_l1_shadow:
+		case PGT_l2_shadow:
+		case PGT_l3_shadow:
+		case PGT_l4_shadow:
+		case PGT_hl2_shadow:
+		    if ( MFN_PINNED(x->smfn) )
+			count++;
+		    break;
+		case PGT_snapshot:
+		case PGT_writable_pred:
+		    break;
+		default:
+		    BUG();
+
+	    }
+	}
+
         if ( !count )
             continue;
 
         mfn_list = xmalloc_array(unsigned long, count);
         count = 0;
-        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next )
-            if ( MFN_PINNED(x->smfn) )
-                mfn_list[count++] = x->smfn;
+        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next ) {
+	    /* Skip entries that are writable_pred) */
+	    switch(x->gpfn_and_flags & PGT_type_mask){
+		case PGT_l1_shadow:
+		case PGT_l2_shadow:
+		case PGT_l3_shadow:
+		case PGT_l4_shadow:
+		case PGT_hl2_shadow:
+		    if ( MFN_PINNED(x->smfn) )
+			mfn_list[count++] = x->smfn;
+		    break;
+		case PGT_snapshot:
+		case PGT_writable_pred:
+		    break;
+		default:
+		    BUG();
+
+	    }
+	}
 
         while ( count )
         {
@@ -773,6 +807,7 @@
     unsigned long va = pfn << PAGE_SHIFT;
 
     ASSERT(tabpfn != 0);
+    ASSERT(shadow_lock_is_acquired(d));
 
     l2 = map_domain_page_with_cache(tabpfn, l2cache);
     l2e = l2[l2_table_offset(va)];
@@ -1366,7 +1401,7 @@
     case DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE:
         free_shadow_pages(d);
         rc = __shadow_mode_enable(
-            d, d->arch.shadow_mode|SHM_enable|SHM_refcounts|SHM_translate);
+            d, d->arch.shadow_mode|SHM_enable|SHM_refcounts|SHM_translate|SHM_write_all);
         break;
 
     default:
@@ -1676,6 +1711,7 @@
     shadow_lock(d);
 
     __shadow_sync_va(v, va);
+    SH_VVLOG("shadow_invlpg va=%lx", va);
 
     // XXX mafetter: will need to think about 4MB pages...
 
@@ -2052,7 +2088,11 @@
         while ( count )
         {
             count--;
+	    /* Delete_shadow_status does a shadow_audit(), so we need to
+	     * keep accurate count of writable_pte_predictions to keep it
+	     * happy. */
             delete_shadow_status(d, gpfn_list[count], 0, PGT_writable_pred);
+	    perfc_decr(writable_pte_predictions);
         }
 
         xfree(gpfn_list);
@@ -2581,6 +2621,7 @@
      * STEP 2. Check the guest PTE.
      */
     __guest_get_l2e(v, va, &gpde);
+    SH_VVLOG("shadow_fault: gpde=%" PRIpte, l2e_get_intpte(gpde));
     if ( unlikely(!(l2e_get_flags(gpde) & _PAGE_PRESENT)) )
     {
         SH_VVLOG("shadow_fault - EXIT: L1 not present");
@@ -2608,19 +2649,11 @@
 
         if ( unlikely(!(l1e_get_flags(gpte) & _PAGE_RW)) )
         {
-            if ( shadow_mode_page_writable(d, l1e_get_pfn(gpte)) )
-            {
-                allow_writes = 1;
-                l1e_add_flags(gpte, _PAGE_RW);
-            }
-            else
-            {
                 /* Write fault on a read-only mapping. */
                 SH_VVLOG("shadow_fault - EXIT: wr fault on RO page (%" PRIpte ")", 
                          l1e_get_intpte(gpte));
                 perfc_incrc(shadow_fault_bail_ro_mapping);
                 goto fail;
-            }
         }
 
         if ( !l1pte_write_fault(v, &gpte, &spte, va) )
@@ -2765,8 +2798,9 @@
     // just everything involved in getting to this L1 (i.e. we need
     // linear_pg_table[l1_linear_offset(va)] to be in sync)...
     //
+    SH_VVLOG("shadow_do_update_va_maping va=%lx, val=%" PRIpte ")",
+                 va, l1e_get_intpte(val));
     __shadow_sync_va(v, va);
-
     l1pte_propagate_from_guest(d, val, &spte);
     shadow_set_l1e(va, spte, 0);
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/common/dom0_ops.c xeno-ft-clean/xen/common/dom0_ops.c
--- xen-unstable.latest/xen/common/dom0_ops.c	2005-06-07 09:41:55.000000000 -0400
+++ xeno-ft-clean/xen/common/dom0_ops.c	2005-06-15 14:51:17.000000000 -0400
@@ -17,6 +17,7 @@
 #include <xen/trace.h>
 #include <xen/console.h>
 #include <asm/current.h>
+#include <xen/shadow.h>
 #include <public/dom0_ops.h>
 #include <public/sched_ctl.h>
 
@@ -359,8 +360,15 @@
 
         op->u.getdomaininfo.tot_pages   = d->tot_pages;
         op->u.getdomaininfo.max_pages   = d->max_pages;
-        op->u.getdomaininfo.shared_info_frame = 
-            __pa(d->shared_info) >> PAGE_SHIFT;
+        if (shadow_mode_translate(d)) {  
+	    /* If we are in translate mode, then return addresses in the 
+	     * pfn space. */
+            op->u.getdomaininfo.shared_info_frame =
+                __mfn_to_gpfn(d,__pa(d->shared_info) >> PAGE_SHIFT);
+        } else {
+            op->u.getdomaininfo.shared_info_frame =
+                __pa(d->shared_info) >> PAGE_SHIFT;
+        }
 
         if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
             ret = -EINVAL;
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/common/event_channel.c xeno-ft-clean/xen/common/event_channel.c
--- xen-unstable.latest/xen/common/event_channel.c	2005-06-06 08:50:14.000000000 -0400
+++ xeno-ft-clean/xen/common/event_channel.c	2005-06-15 14:46:14.000000000 -0400
@@ -65,6 +65,10 @@
     struct domain *d = current->domain;
     int            port = alloc->port;
     long           rc = 0;
+    int		   dom = alloc->dom;
+
+    if( dom == DOMID_SELF )
+        dom = current->domain->domain_id;
 
     spin_lock(&d->evtchn_lock);
 
@@ -83,7 +87,7 @@
     {
     case ECS_FREE:
         chn->state = ECS_UNBOUND;
-        chn->u.unbound.remote_domid = alloc->dom;
+        chn->u.unbound.remote_domid = dom;
         break;
 
     case ECS_UNBOUND:
@@ -102,6 +106,22 @@
     return rc;
 }
 
+/* Allocate a port in domain d, and return its number. */
+int evtchn_alloc_port(struct domain *d)
+{
+    struct evtchn *chn;
+    int r;
+
+    spin_lock(&d->evtchn_lock);
+    r = get_free_port(d);
+    if (r >= 0) {
+    	chn = evtchn_from_port(d, r);
+	chn->state = ECS_UNBOUND;
+        chn->u.unbound.remote_domid = d->domain_id;
+    }
+    spin_unlock(&d->evtchn_lock);
+    return r;
+}
 
 static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind)
 {
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/common/grant_table.c xeno-ft-clean/xen/common/grant_table.c
--- xen-unstable.latest/xen/common/grant_table.c	2005-06-09 13:29:56.000000000 -0400
+++ xeno-ft-clean/xen/common/grant_table.c	2005-06-15 14:54:59.000000000 -0400
@@ -694,16 +694,22 @@
     {
         ASSERT(d->grant_table != NULL);
         (void)put_user(GNTST_okay, &uop->status);
-        for ( i = 0; i < op.nr_frames; i++ )
-            (void)put_user(
-                (virt_to_phys(d->grant_table->shared) >> PAGE_SHIFT) + i,
-                &uop->frame_list[i]);
+        for ( i = 0; i < op.nr_frames; i++ ) {
+            if (shadow_mode_translate(d)) {
+                (void)put_user(__mfn_to_gpfn(d, (virt_to_phys(d->grant_table->shared) >> PAGE_SHIFT) + i),
+                               &uop->frame_list[i]);
+            } else {
+                (void)put_user((virt_to_phys(d->grant_table->shared) >> PAGE_SHIFT) + i,
+                               &uop->frame_list[i]);
+            }
+        }
     }
 
     put_domain(d);
     return 0;
 }
 
+
 #if GRANT_DEBUG
 static int
 gnttab_dump_table(gnttab_dump_table_t *uop)
@@ -757,7 +763,8 @@
         {
             DPRINTK("Grant: dom (%hu) SHARED (%d) flags:(%hx) "
                     "dom:(%hu) frame:(%lx)\n",
-                    op.dom, i, sha_copy.flags, sha_copy.domid, sha_copy.frame);
+                    op.dom, i, sha_copy.flags, sha_copy.domid, 
+		    (unsigned long)sha_copy.frame);
         }
     }
 
@@ -797,6 +804,46 @@
 }
 #endif
 
+static long 
+gnttab_get_shared_mfn(
+    gnttab_get_shared_mfn_t *uop, unsigned int count)
+{
+    gnttab_get_shared_mfn_t  op;
+    struct domain        *d;
+
+    if ( count != 1 )
+        return -EINVAL;
+
+    if ( unlikely(copy_from_user(&op, uop, sizeof(op)) != 0) )
+    {
+        DPRINTK("Fault while reading gnttab_setup_table_t.\n");
+        return -EFAULT;
+    }
+
+    if ( op.dom == DOMID_SELF )
+    {
+        op.dom = current->domain->domain_id;
+    }
+    else if ( unlikely(!IS_PRIV(current->domain)) )
+    {
+        (void)put_user(GNTST_permission_denied, &uop->status);
+        return 0;
+    }
+
+    if ( unlikely((d = find_domain_by_id(op.dom)) == NULL) )
+    {
+        DPRINTK("Bad domid %d.\n", op.dom);
+        (void)put_user(GNTST_bad_domain, &uop->status);
+        return 0;
+    }
+
+    ASSERT(d->grant_table != NULL);
+    (void)put_user(virt_to_phys(d->grant_table->shared) >> PAGE_SHIFT, &uop->mfn);
+
+    put_domain(d);
+    return 0;
+}
+
 long 
 do_grant_table_op(
     unsigned int cmd, void *uop, unsigned int count)
@@ -808,6 +855,8 @@
 
     LOCK_BIGLOCK(current->domain);
 
+    DPRINTK("do_grant_table_op(cmd=%u,uop=%p,count=%u)\n",cmd,uop,count);
+
     rc = -EFAULT;
     switch ( cmd )
     {
@@ -831,6 +880,13 @@
         rc = gnttab_dump_table((gnttab_dump_table_t *)uop);
         break;
 #endif
+    case GNTTABOP_get_shared_mfn:
+        if (IS_PRIV(current->domain)) {
+            rc = gnttab_get_shared_mfn((gnttab_get_shared_mfn_t *)uop, count);
+        } else {
+            rc = -ENOSYS;
+        }
+        break;
     default:
         rc = -ENOSYS;
         break;
@@ -869,7 +925,7 @@
 #if GRANT_DEBUG_VERBOSE
     if ( ld->domain_id != 0 )
     {
-        DPRINTK("Foreign unref rd(%d) ld(%d) frm(%x) flgs(%x).\n",
+        DPRINTK("Foreign unref rd(%d) ld(%d) frm(%lx) flgs(%x).\n",
                 rd->domain_id, ld->domain_id, frame, readonly);
     }
 #endif
@@ -1228,6 +1284,7 @@
     void)
 {
     /* Nothing. */
+    DPRINTK("Grant table init\n");
 }
 
 /*
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/include/asm-x86/shadow.h xeno-ft-clean/xen/include/asm-x86/shadow.h
--- xen-unstable.latest/xen/include/asm-x86/shadow.h	2005-06-07 09:41:55.000000000 -0400
+++ xeno-ft-clean/xen/include/asm-x86/shadow.h	2005-06-15 14:46:14.000000000 -0400
@@ -1036,6 +1036,21 @@
 {
     int live = 0, free = 0, j = 0, abs;
     struct shadow_status *a;
+    int live_shadow_l1_pages,
+        live_shadow_l2_pages,
+        live_shadow_l3_pages,
+        live_shadow_l4_pages,
+        live_hl2_table_pages,
+        live_snapshot_pages,
+        live_writable_pte_predictions;
+
+    live_shadow_l1_pages=
+        live_shadow_l2_pages=
+        live_shadow_l3_pages=
+        live_shadow_l4_pages=
+        live_hl2_table_pages=
+        live_snapshot_pages=
+        live_writable_pte_predictions=0;
 
     for ( j = 0; j < shadow_ht_buckets; j++ )
     {
@@ -1043,11 +1058,37 @@
         if ( a->gpfn_and_flags )
         {
             live++;
+	    switch(a->gpfn_and_flags & PGT_type_mask) {
+	       	case PGT_l1_shadow:
+		    live_shadow_l1_pages++;
+	    	    break;
+	       	case PGT_l2_shadow:
+		    live_shadow_l2_pages++;
+	    	    break;
+	       	case PGT_l3_shadow:
+		    live_shadow_l3_pages++;
+	    	    break;
+	       	case PGT_l4_shadow:
+		    live_shadow_l4_pages++;
+	    	    break;
+	       	case PGT_hl2_shadow:
+		    live_hl2_table_pages++;
+	    	    break;
+	       	case PGT_snapshot:
+		    live_snapshot_pages++;
+	    	    break;
+	       	case PGT_writable_pred:
+		    live_writable_pte_predictions++;
+	    	    break;
+	       	default:
+	    		BUG();
+	    }
             ASSERT(a->smfn);
         }
         else
             ASSERT(!a->next);
 
+
         a = a->next;
         while ( a && (live < 9999) )
         { 
@@ -1058,6 +1099,31 @@
                        live, a->gpfn_and_flags, a->smfn, a->next);
                 BUG();
             }
+	    switch(a->gpfn_and_flags & PGT_type_mask) {
+	       	case PGT_l1_shadow:
+		    live_shadow_l1_pages++;
+	    	    break;
+	       	case PGT_l2_shadow:
+		    live_shadow_l2_pages++;
+	    	    break;
+	       	case PGT_l3_shadow:
+		    live_shadow_l3_pages++;
+	    	    break;
+	       	case PGT_l4_shadow:
+		    live_shadow_l4_pages++;
+	    	    break;
+	       	case PGT_hl2_shadow:
+		    live_hl2_table_pages++;
+	    	    break;
+	       	case PGT_snapshot:
+		    live_snapshot_pages++;
+	    	    break;
+	       	case PGT_writable_pred:
+		    live_writable_pte_predictions++;
+	    	    break;
+	       	default:
+	    		BUG();
+	    }
             ASSERT(a->smfn);
             a = a->next; 
         }
@@ -1083,13 +1149,21 @@
 #ifdef PERF_COUNTERS
     if ( (abs < -1) || (abs > 1) )
     {
-        printk("live=%d free=%d l1=%d l2=%d hl2=%d snapshot=%d writable_ptes=%d\n",
+        printk("live=%d free=%d l1=%d l2=%d hl2=%d snapshot=%d writable_pred=%d\n",
                live, free,
                perfc_value(shadow_l1_pages),
                perfc_value(shadow_l2_pages),
                perfc_value(hl2_table_pages),
                perfc_value(snapshot_pages),
                perfc_value(writable_pte_predictions));
+        printk("counted: l1=%d l2=%d l3=%d l4=%d hl2=%d snapshot=%d writable_pred=%d\n",
+               live_shadow_l1_pages,
+               live_shadow_l2_pages,
+               live_shadow_l3_pages,
+               live_shadow_l4_pages,
+               live_hl2_table_pages,
+               live_snapshot_pages,
+               live_writable_pte_predictions);
         BUG();
     }
 #endif
@@ -1192,7 +1266,7 @@
 #ifndef NDEBUG
         if ( ___shadow_status(d, gpfn, stype) != 0 )
         {
-            printk("d->id=%d gpfn=%lx gmfn=%lx stype=%lx c=%x t=%x "
+            printk("d->domain_id=%d gpfn=%lx gmfn=%lx stype=%lx c=%x t=%x "
                    "mfn_out_of_sync(gmfn)=%d mfn_is_page_table(gmfn)=%d\n",
                    d->domain_id, gpfn, gmfn, stype,
                    frame_table[gmfn].count_info,
@@ -1439,7 +1513,8 @@
             if ( stype != PGT_writable_pred )
                 BUG(); // we should never replace entries into the hash table
             x->smfn = smfn;
-            put_page(pfn_to_page(gmfn)); // already had a ref...
+            if ( stype != PGT_writable_pred )
+                put_page(pfn_to_page(gmfn)); // already had a ref...
             goto done;
         }
 
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/include/public/grant_table.h xeno-ft-clean/xen/include/public/grant_table.h
--- xen-unstable.latest/xen/include/public/grant_table.h	2005-04-13 05:44:50.000000000 -0400
+++ xeno-ft-clean/xen/include/public/grant_table.h	2005-06-15 14:46:14.000000000 -0400
@@ -220,6 +220,20 @@
     s16         status;               /* 2: GNTST_* */
 } PACKED gnttab_dump_table_t; /* 4 bytes */
 
+/*
+ * GNTTABOP_get_shared_mfn: Get the start of the shared mfns
+ * of the requested dom to allow the builder to map these pages
+ * into the domU's memory space for full translate mode.
+ */
+#define GNTTABOP_get_shared_mfn       4
+typedef struct {
+    /* IN parameters. */
+    domid_t     dom;                  /*  0 */
+    /* OUT parameters. */
+    s16         status;               /* 2: GNTST_* */
+    u32         mfn;                  /* 4 */
+} PACKED gnttab_get_shared_mfn_t; /* 8 bytes */
+
 
 /*
  * Bitfield values for update_pin_status.flags.
@@ -273,6 +287,7 @@
         gnttab_unmap_grant_ref_t  unmap_grant_ref;
         gnttab_setup_table_t      setup_table;
         gnttab_dump_table_t       dump_table;
+        gnttab_get_shared_mfn_t   shared_mfn;
         u8                        __dummy[24];
     } PACKED u;
 } PACKED gnttab_op_t; /* 32 bytes */
diff -urN --exclude=SCCS --exclude=BitKeeper xen-unstable.latest/xen/include/xen/domain_page.h xeno-ft-clean/xen/include/xen/domain_page.h
--- xen-unstable.latest/xen/include/xen/domain_page.h	2005-06-07 09:41:55.000000000 -0400
+++ xeno-ft-clean/xen/include/xen/domain_page.h	2005-06-15 14:46:14.000000000 -0400
@@ -81,7 +81,6 @@
         cache->flags = 0;
     }
 }
-
 #else /* !CONFIG_DOMAIN_PAGE */
 
 #define map_domain_page(pfn)                phys_to_virt((pfn)<<PAGE_SHIFT)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 10%]

* Balloon driver tests
@ 2005-06-16 21:22  7% Paul Larson
  2005-06-16 22:34  0% ` Kip Macy
  0 siblings, 1 reply; 200+ results
From: Paul Larson @ 2005-06-16 21:22 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1121 bytes --]

Here's a small set of tests I've written for the balloon driver.  I'm 
sure there's more that could be tested, but it's a start.  Can/should 
these go in the tests directory?

Here's a brief description of each and a tarball since it would be 
cumbersome to send them all inline:

balloon01: Test read from /proc/xen/balloon
balloon02: Echo a number higher than current requested allocation to 
/proc/xen/balloon, cat balloon and see that requested target changed.
balloon03: Echo a number lower than current requested allocation to 
/proc/xen/balloon, cat balloon and see that requested target changed.
balloon04: Allocate some memory for the domain, then use 
/proc/xen/balloon to reduce available memory to less than what is allocated
balloon05: Try to give /proc/xen/balloon a value larger than the 
available RAM in the system.
balloon06: Try to give /proc/xen/balloon a value way too low, such as 4k
balloon07: Open /proc/xen/balloon as non-root user, expect -EACCES
balloon08: Write 1 byte to /proc/xen/balloon, expect -EBADMSG
balloon09: Write >64 bytes to /proc/xen/balloon, expect -EFBIG

Thanks,
Paul Larson



[-- Attachment #2: balloon.tgz --]
[-- Type: application/x-compressed, Size: 3271 bytes --]

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 7%]

* Re: Balloon driver tests
  2005-06-16 21:22  7% Balloon driver tests Paul Larson
@ 2005-06-16 22:34  0% ` Kip Macy
  0 siblings, 0 replies; 200+ results
From: Kip Macy @ 2005-06-16 22:34 UTC (permalink / raw)
  To: Paul Larson; +Cc: xen-devel

> sure there's more that could be tested, but it's a start.  Can/should
> these go in the tests directory?
> 
PLEASE.


> Here's a brief description of each and a tarball since it would be
> cumbersome to send them all inline:
> 
> balloon01: Test read from /proc/xen/balloon
> balloon02: Echo a number higher than current requested allocation to
> /proc/xen/balloon, cat balloon and see that requested target changed.
> balloon03: Echo a number lower than current requested allocation to
> /proc/xen/balloon, cat balloon and see that requested target changed.
> balloon04: Allocate some memory for the domain, then use
> /proc/xen/balloon to reduce available memory to less than what is allocated
> balloon05: Try to give /proc/xen/balloon a value larger than the
> available RAM in the system.
> balloon06: Try to give /proc/xen/balloon a value way too low, such as 4k
> balloon07: Open /proc/xen/balloon as non-root user, expect -EACCES
> balloon08: Write 1 byte to /proc/xen/balloon, expect -EBADMSG
> balloon09: Write >64 bytes to /proc/xen/balloon, expect -EFBIG
> 
> Thanks,
> Paul Larson
> 
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
> 
> 
> 
>

^ permalink raw reply	[relevance 0%]

* problem to balloon memory beyond initial allocation
@ 2005-07-10 13:00  7% Xuehai Zhang
  0 siblings, 0 replies; 200+ results
From: Xuehai Zhang @ 2005-07-10 13:00 UTC (permalink / raw)
  To: xen-devel

Hi all,

I did the following experiment to test booting a domU with less memory
than its maximum then growing its memory via balloon driver later. I
followed by the suggestions from:
 http://lists.xensource.com/archives/html/xen-users/2005-04/msg00294.html
 http://lists.xensource.com/archives/html/xen-devel/2005-04/msg00634.html

The xen version I use is 2.0 testing tree wit "Latest ChangeSet:
2005/06/08". Both dom0 and domU kernel version is 2.6.11.11.

The memory allocation with only dom0 running looks as following:

# xm list
Name              Id  Mem(MB)  CPU  State  Time(s)  Console
Domain-0           0      379    0  r----    194.0

# xm info | grep mem
memory                 : 1023
free_memory            : 622

The configuration file for the domU (named vm1) looks like:

[snip]
kernel = "/boot/vmlinuz-2.6.11-xenU"
memory = 128
[snip]
root = "/dev/sda1 ro"
extra = "mem=268435456" #256MB
[snip]

I pass "mem=268435456" to vm1's kernel command line, which will set the
size of mem_map or maxmem to 256MB. However, "memory=128" will only
allocate 128MB memory to vm1 at its creation time.

After vm1 is created, I checked its memory allocation status.

- from vm1 console:

# dmesg | grep mem
Kernel command line:
ip=128.135.164.83:1.2.3.4:128.135.164.65:255.255.255.192::eth0:off
root=/dev/sda1 ro mem=268435456
vmalloc area: d0800000-fbff9000, maxmem 34000000
Memory: 125376k/262144k available (1630k kernel code, 5324k reserved, 440k
data, 112k init, 0k highmem)
xen_mem: Initialising balloon driver.
Freeing unused kernel memory: 112k freed

# cat /proc/xen/balloon
Current allocation:   131072 kB
Requested target:     131072 kB
Low-mem balloon:      131072 kB
High-mem balloon:          0 kB
Xen hard limit:          ??? kB

The "dmesg" output line "Memory: 125376k/262144k available" confirms 128MB
out of 256MB is currently allocated to vm1.

The "/proc/xen/balloon" output line "Low-mem balloon: 131072 kB" shows
(if I understand correctly) there is 128MB unused memory left which can
be added to the existing 128MB allocation. BTW, can anyone explain the
meanings of last three entries, Low-mem balloon, High-mem balloon, and Xen
hard limit? One question I have here is, what is the real maxmem value
(the value we can set with "xm maxmem vm1" command too) for vm1 at this
stage? Is it 128MB (according to Xen users' manual, "Xen associates a
memory size limit with each domain. By default, this is the amount of
memory the domain is originally started with, preventing the domain from
ever growing beyond this size") or 256MB (because we pass "mem=256MB" as
kernel command line)?

- from dom0

# xm list
Name              Id  Mem(MB)  CPU  State  Time(s)  Console
Domain-0           0      379    0  r----    196.5
vm1               12      127    0  -b---      1.0    9612

# xm info | grep mem
memory                 : 1023
free_memory            : 495

Output from dom0 indicates vm1 is allocated 128MB memory.


Next I tried to increase vm1's memory. Because I am not sure if vm1's
maxmem is set to 128MB or 256MB (as discussed above), I ran the "xm
maxmem" command first from dom0.

# xm maxmem vm1 256

When going back to vm1's console to check "/proc/xen/balloon", it keeps
the same:

# cat /proc/xen/balloon
Current allocation:   131072 kB
Requested target:     131072 kB
Low-mem balloon:      131072 kB
High-mem balloon:          0 kB
Xen hard limit:          ??? kB

Then in dom0 I tried to increase vm1's memory to 200MB by running "xm
balloon" command:

# xm balloon vm1 200

# xm list
Name              Id  Mem(MB)  CPU  State  Time(s)  Console
Domain-0           0      379    0  r----    197.4
vm1               12      127    0  -b---      1.0    9612

# xm info | grep mem
memory                 : 1023
free_memory            : 494

Surprisingly, vm1's memory is still 128MB (not 200MB we want to increase
to) and the free memory is still similar as before.

When going back to vm1's console to check "/proc/xen/balloon" again, I
found "Xen hard limit" is set with "128MB" value instead of "???" before.
It seems to me "Xen hard limit" will forbid vm1's memory go beyond 128MB.
The requested target is also changed, which reflects the new memory value
we want to increased to, 200MB.

# cat /proc/xen/balloon
Current allocation:   131044 kB
Requested target:     204800 kB
Low-mem balloon:      131100 kB
High-mem balloon:          0 kB
Xen hard limit:       131044 kB (inc.       28 kB driver headroom)

My above experiment is not very successful. I will appreciate if you can
point out what I did wrong. Thanks in advance!

Xuehai

^ permalink raw reply	[relevance 7%]

* PageReserved ?
@ 2005-07-15 18:26  6% aq
    0 siblings, 1 reply; 200+ results
From: aq @ 2005-07-15 18:26 UTC (permalink / raw)
  To: xen-devel

hello,

here is my ballon information (domU)

#cat /proc/xen/balloon
Current allocation:    51200 kB
Requested target:      71680 kB
Low-mem balloon:           0 kB
High-mem balloon:          0 kB
Xen hard limit:          ??? kB


This looks a little bit strange to me: Low/High-mem is 0K, and that
indicates from 51200K up (Current allocation) to 70MB, all the pages
are reserved, which means I cannot balloon memory (?). Anybody knows
why so much memory are reserved?

Thank you,
aq

^ permalink raw reply	[relevance 6%]

* [patch] balloon doc fix
@ 2005-07-16  1:30  9% aq
  0 siblings, 0 replies; 200+ results
From: aq @ 2005-07-16  1:30 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

This patch fixes a deprecated /proc balloon name in user.tex

Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>



$ diffstat docballon.patch 
 user.tex |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

[-- Attachment #2: docballon.patch --]
[-- Type: application/octet-stream, Size: 840 bytes --]

diff -r a83ac0806d6b docs/src/user.tex
--- a/docs/src/user.tex	Fri Jul 15 13:39:50 2005
+++ b/docs/src/user.tex	Sat Jul 16 10:25:58 2005
@@ -956,11 +956,11 @@
 
 \subsection{Setting memory footprints from within a domain}
 
-The virtual file \path{/proc/xen/memory\_target} allows the owner of a
+The virtual file \path{/proc/xen/balloon} allows the owner of a
 domain to adjust their own memory footprint.  Reading the file
-(e.g. \path{cat /proc/xen/memory\_target}) prints out the current
+(e.g. \path{cat /proc/xen/balloon}) prints out the current
 memory footprint of the domain.  Writing the file
-(e.g. \path{echo new\_target > /proc/xen/memory\_target}) requests
+(e.g. \path{echo new\_target > /proc/xen/balloon}) requests
 that the kernel adjust the domain's memory footprint to a new value.
 
 \subsection{Setting memory limits}

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 9%]

* Re: PageReserved ?
  @ 2005-07-17  7:30  6%   ` aq
  0 siblings, 0 replies; 200+ results
From: aq @ 2005-07-17  7:30 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel

On 7/15/05, Keir Fraser <Keir.Fraser@cl.cam.ac.uk> wrote:
> 
> On 15 Jul 2005, at 19:26, aq wrote:
> 
> > This looks a little bit strange to me: Low/High-mem is 0K, and that
> > indicates from 51200K up (Current allocation) to 70MB, all the pages
> > are reserved, which means I cannot balloon memory (?). Anybody knows
> > why so much memory are reserved?
> 
> Add a 'mem=' line to your kernel command line (e.g., 'mem=100M' should
> work I think). That will ensure the domain makes itself a big enough
> memory map to increase its memory reservation.

I still cannot create the "LowMem". Any suggestion? (I am running
latest -testing tree)

Here is my domain file:
--
kernel = "/boot/vmlinuz-2.6-xenU"
memory = 32
maxmem = 80
name = "tty"
disk = [ 'file:/home/aq/myxen/rootfs.tty,hda1,w' ]
root = "/dev/hda1 ro"
extra = "mem=150"
---

And here is domU's /proc/xen/balloon (immediately after creating domain):

 # cat /proc/xen/balloon 
Current allocation:    32768 kB
Requested target:      32768 kB
Low-mem balloon:           0 kB
High-mem balloon:          0 kB
Xen hard limit:          ??? kB


Thank you,
aq

^ permalink raw reply	[relevance 6%]

* [PATCH] scrub_pages in balloon
@ 2005-07-18  8:45 16% aq
  0 siblings, 0 replies; 200+ results
From: aq @ 2005-07-18  8:45 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 230 bytes --]

This patch makes balloon driver only scrubs page when
CONFIG_XEN_SCRUB_PAGES enabled.


Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>


$ diffstat scrub.patch 
 balloon.c |    2 ++
 1 files changed, 2 insertions(+)

[-- Attachment #2: scrub.patch --]
[-- Type: application/octet-stream, Size: 557 bytes --]

diff -r 722c372fe201 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sat Jul 16 16:45:24 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Jul 18 17:30:46 2005
@@ -244,7 +244,9 @@
             if ( !PageHighMem(page) )
             {
                 v = phys_to_virt(pfn << PAGE_SHIFT);
+#ifdef CONFIG_XEN_SCRUB_PAGES
                 scrub_pages(v, 1);
+#endif
                 HYPERVISOR_update_va_mapping(
                     (unsigned long)v, __pte_ma(0), 0);
             }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 16%]

* Re: lowest limit for balloon?
  @ 2005-07-18 12:38  5% ` Keir Fraser
  2005-07-18 15:44  0%   ` aq
  2005-07-18 15:55  6%   ` Paul Larson
  0 siblings, 2 replies; 200+ results
From: Keir Fraser @ 2005-07-18 12:38 UTC (permalink / raw)
  To: aq; +Cc: xen-devel

It's probably a job for higher-level management tools. Maybe a safety 
catch should be placed on 'xm balloon', but the intra-VM 
/proc/xen/balloon interface is definitely not intended for the casual 
user.

  -- Keir


On 18 Jul 2005, at 11:57, aq wrote:

> urrently there is one problem with balloon: if we specify too little
> memory for a domain, that domain might crash with OOM error. even in
> that case, balloon still happily do what we request. i just
> accidentally balloon dom0 to 0M, and must reboot the machine ;-)
>
> so i guess it is better to enforce a certain limit, so balloon will
> not bring the amount of memory for a domain to be lower than that
> level.
>
> there are few choices to do this:
> - each domain has a configurable option for this (for example:
> balloon-level in domain config file)

^ permalink raw reply	[relevance 5%]

* Re: lowest limit for balloon?
  2005-07-18 12:38  5% ` Keir Fraser
@ 2005-07-18 15:44  0%   ` aq
  2005-07-18 15:55  6%   ` Paul Larson
  1 sibling, 0 replies; 200+ results
From: aq @ 2005-07-18 15:44 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel

On 7/18/05, Keir Fraser <Keir.Fraser@cl.cam.ac.uk> wrote:
> It's probably a job for higher-level management tools. Maybe a safety
> catch should be placed on 'xm balloon', but the intra-VM
> /proc/xen/balloon interface is definitely not intended for the casual
> user.
> 

fine, but how about the balloon level to set the limit? i prefer to
calculate it based on the domain configuration, instead of specifying
it in the domain config file. but that is probably a tough job.

do you have any idea on how to determine the limit ?

regards,
aq

>   -- Keir
> 
> 
> On 18 Jul 2005, at 11:57, aq wrote:
> 
> > urrently there is one problem with balloon: if we specify too little
> > memory for a domain, that domain might crash with OOM error. even in
> > that case, balloon still happily do what we request. i just
> > accidentally balloon dom0 to 0M, and must reboot the machine ;-)
> >
> > so i guess it is better to enforce a certain limit, so balloon will
> > not bring the amount of memory for a domain to be lower than that
> > level.
> >
> > there are few choices to do this:
> > - each domain has a configurable option for this (for example:
> > balloon-level in domain config file)
> 
> 


-- 
regards,
aq

^ permalink raw reply	[relevance 0%]

* Re: lowest limit for balloon?
  2005-07-18 12:38  5% ` Keir Fraser
  2005-07-18 15:44  0%   ` aq
@ 2005-07-18 15:55  6%   ` Paul Larson
  1 sibling, 0 replies; 200+ results
From: Paul Larson @ 2005-07-18 15:55 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 921 bytes --]

On Mon, 2005-07-18 at 13:38 +0100, Keir Fraser wrote:
> It's probably a job for higher-level management tools. Maybe a safety 
> catch should be placed on 'xm balloon', but the intra-VM 
> /proc/xen/balloon interface is definitely not intended for the casual 
> user.
I still think /proc/xen/balloon makes it far too easy to shoot yourself
in the foot, even for the non-casual user.  Simply forgetting to leave
the units off the end of an echo can bring your domain (even dom0) to a
screeching halt.

Such as doing:
echo 200000 > /proc/xen/balloon
instead of:
echo 200000K > /proc/xen/balloon.

I know that it's really difficult to determine how low is too low.
Could I recommend a small interface change though, that would force the
user to always specify units {B,K,M,...}?  That might help a little at
least.

-- 
Thanks,
Paul Larson
plars@linuxtestproject.org
http://www.linuxtestproject.org

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 6%]

* [PATCH] enforce dom0 cpus and balloon out memory
@ 2005-07-29  3:04  8% aq
  0 siblings, 0 replies; 200+ results
From: aq @ 2005-07-29  3:04 UTC (permalink / raw)
  To: xen-devel, Ian Pratt

[-- Attachment #1: Type: text/plain, Size: 984 bytes --]

This patch does 2 jobs:

- Enforce the number of CPUs dom0 will take. See the new variable
"dom0-cpus" in xend-config.sxp (you will want to set this variable to
1 on SMP systems)

- Balloon out dom0 memory when creating domU, if there is not enough
free memory. The lowest level we will balloon out is configured via
the new variable "dom0-min-mem" in xend-config.sxp


I still have a doubt: where to put the code to enforce dom0-cpus. At
the moment I put it into
python/xen/xend/server/SrvDaemon.py, and hopefully that is resonable
enough. Any comment?



Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>



$ diffstat enforce_resource.patch 
 examples/xend-config.sxp            |    8 +++++++
 python/xen/xend/XendRoot.py         |   10 +++++++++
 python/xen/xend/server/SrvDaemon.py |   30 +++++++++++++++++++++++++++-
 python/xen/xm/create.py             |   38 ++++++++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+), 1 deletion(-)

[-- Attachment #2: enforce_resource.patch --]
[-- Type: application/octet-stream, Size: 5375 bytes --]

diff -r 501a70f3ae96 tools/examples/xend-config.sxp
--- a/tools/examples/xend-config.sxp	Thu Jul 28 12:34:45 2005
+++ b/tools/examples/xend-config.sxp	Fri Jul 29 11:55:38 2005
@@ -44,3 +44,11 @@
 # Setup script for enbd-backed block devices
 (block-enbd block-enbd)
 
+# Dom0 will balloon out when needed to free memory for domU.
+# dom0-min-mem is the lowest memory level (in MB) dom0 will get down to.
+# If dom0-min-mem=0, dom0 will never balloon out.
+(dom0-min-mem 0)
+
+# In SMP system, dom0 will use only CPUs in range [1,dom0-cpus]
+# If dom0-cpus = 0, dom0 will take all cpus available
+(dom0-cpus 0)
diff -r 501a70f3ae96 tools/python/xen/xend/XendRoot.py
--- a/tools/python/xen/xend/XendRoot.py	Thu Jul 28 12:34:45 2005
+++ b/tools/python/xen/xend/XendRoot.py	Fri Jul 29 11:55:38 2005
@@ -75,6 +75,10 @@
 
     """Default port xend serves consoles at. """
     console_port_base_default = '9600'
+
+    dom0_min_mem_default = '0'
+
+    dom0_cpus_default = '0'
 
     components = {}
 
@@ -329,6 +333,12 @@
     def get_vif_antispoof(self):
         return self.get_config_bool('vif-antispoof', 'yes')
 
+    def get_dom0_min_mem(self):
+        return self.get_config_int('dom0-min-mem', self.dom0_min_mem_default)
+
+    def get_dom0_cpus(self):
+        return self.get_config_int('dom0-cpus', self.dom0_cpus_default)
+
 def instance():
     """Get an instance of XendRoot.
     Use this instead of the constructor.
diff -r 501a70f3ae96 tools/python/xen/xend/server/SrvDaemon.py
--- a/tools/python/xen/xend/server/SrvDaemon.py	Thu Jul 28 12:34:45 2005
+++ b/tools/python/xen/xend/server/SrvDaemon.py	Fri Jul 29 11:55:38 2005
@@ -5,7 +5,6 @@
 ###########################################################
 
 import os
-import os.path
 import signal
 import sys
 import threading
@@ -16,6 +15,7 @@
 import StringIO
 import traceback
 import time
+import glob
 
 from xen.lowlevel import xu
 
@@ -25,6 +25,7 @@
 from xen.xend.XendError import XendError
 from xen.xend.server import SrvServer
 from xen.xend.XendLogging import log
+from xen.xend import XendRoot; xroot = XendRoot.instance()
 
 import channel
 import controller
@@ -327,6 +328,7 @@
         return self.cleanup(kill=True)
 
     def run(self):
+        _enforce_dom0_cpus()
         try:
             log.info("Xend Daemon started")
             self.createFactories()
@@ -363,6 +365,32 @@
         #sys.exit(rc)
         os._exit(rc)
 
+def _enforce_dom0_cpus():
+    dn = xroot.get_dom0_cpus()
+
+    for d in glob.glob("/sys/devices/system/cpu/cpu*"):
+        cpu = int(os.path.basename(d)[3:])
+        if (dn == 0) or (cpu < dn):
+            v = "1"
+        else:
+            v = "0"
+        try:
+            f = open("%s/online" %d, "r+")
+            c = f.read(1)
+            if (c != v):
+                if v == "0":
+                    log.info("dom0 is trying to give back cpu %d", cpu)
+                else:
+                    log.info("dom0 is trying to take cpu %d", cpu)
+                f.seek(0)
+                f.write(v)
+                f.close()
+                log.info("dom0 successfully enforced cpu %d", cpu)
+            else:
+                f.close()
+        except:
+            pass
+
 def instance():
     global inst
     try:
diff -r 501a70f3ae96 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py	Thu Jul 28 12:34:45 2005
+++ b/tools/python/xen/xm/create.py	Fri Jul 29 11:55:38 2005
@@ -1,4 +1,5 @@
 # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
+# Copyright (C) 2005 Nguyen Anh Quynh <aquynh@gmail.com>
 
 """Domain creation.
 """
@@ -7,10 +8,13 @@
 import sys
 import socket
 
+import xen.lowlevel.xc
+
 from xen.xend import sxp
 from xen.xend import PrettyPrint
 from xen.xend.XendClient import server, XendError
 from xen.xend.XendBootloader import bootloader
+from xen.xend import XendRoot; xroot = XendRoot.instance()
 from xen.util import blkif
 
 from xen.util import console_client
@@ -644,6 +648,36 @@
               % (dom, console_port))
     return (dom, console_port)
 
+def get_dom0_alloc():
+    """Return current allocation memory of dom0 (in MB). Return 0 on error"""
+    PROC_XEN_BALLOON = "/proc/xen/balloon"
+
+    f = open(PROC_XEN_BALLOON, "r")
+    line = f.readline()
+    for x in line.split():
+        for n in x:
+            if not n.isdigit():
+                break
+        else:
+            f.close()
+            return int(x)/1024
+    f.close()
+    return 0
+
+def balloon_out(dom0_min_mem, opts):
+    """Balloon out to get memory for domU, if necessarily"""
+    SLACK = 4
+
+    xc = xen.lowlevel.xc.new()
+    pinfo = xc.physinfo()
+    free_mem = pinfo['free_pages']/256
+    if free_mem < opts.vals.memory + SLACK:
+        need_mem = opts.vals.memory + SLACK - free_mem
+        cur_alloc = get_dom0_alloc()
+        if cur_alloc - need_mem >= dom0_min_mem:
+            server.xend_domain_mem_target_set(0, cur_alloc - need_mem)
+    del xc
+
 def main(argv):
     opts = gopts
     args = opts.parse(argv)
@@ -671,6 +705,10 @@
     if opts.vals.dryrun:
         PrettyPrint.prettyprint(config)
     else:
+        dom0_min_mem = xroot.get_dom0_min_mem()
+        if dom0_min_mem != 0:
+            balloon_out(dom0_min_mem, opts)
+
         (dom, console) = make_domain(opts, config)
         if opts.vals.console_autoconnect:
             path = "/var/lib/xend/console-%s" % console

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 8%]

* [PATCH] rename balloon command
@ 2005-07-29  5:11  8% aq
  0 siblings, 0 replies; 200+ results
From: aq @ 2005-07-29  5:11 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

This patch renames balloon command to "set-mem", so instead of "xm
balloon", we will use "xm set-mem" (as suggested by TODO list)

Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>


# diffstat setmem.patch 
 docs/src/user.tex           |   14 +++++++-------
 tools/python/xen/xm/main.py |    8 ++++----
 2 files changed, 11 insertions(+), 11 deletions(-)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: setmem.patch --]
[-- Type: text/x-patch; name="setmem.patch", Size: 2541 bytes --]

diff -r 501a70f3ae96 docs/src/user.tex
--- a/docs/src/user.tex	Thu Jul 28 12:34:45 2005
+++ b/docs/src/user.tex	Fri Jul 29 14:06:14 2005
@@ -930,12 +930,12 @@
 \subsection{Setting memory footprints from dom0}
 
 The machine administrator can request that a domain alter its memory
-footprint using the \path{xm balloon} command.  For instance, we can
+footprint using the \path{xm set-mem} command.  For instance, we can
 request that our example ttylinux domain reduce its memory footprint
 to 32 megabytes.
 
 \begin{verbatim}
-# xm balloon ttylinux 32
+# xm set-mem ttylinux 32
 \end{verbatim}
 
 We can now see the result of this in the output of \path{xm list}:
@@ -951,16 +951,16 @@
 can restore the domain to its original size using the command line:
 
 \begin{verbatim}
-# xm balloon ttylinux 64
+# xm set-mem ttylinux 64
 \end{verbatim}
 
 \subsection{Setting memory footprints from within a domain}
 
-The virtual file \path{/proc/xen/memory\_target} allows the owner of a
+The virtual file \path{/proc/xen/balloon} allows the owner of a
 domain to adjust their own memory footprint.  Reading the file
-(e.g. \path{cat /proc/xen/memory\_target}) prints out the current
+(e.g. \path{cat /proc/xen/balloon}) prints out the current
 memory footprint of the domain.  Writing the file
-(e.g. \path{echo new\_target > /proc/xen/memory\_target}) requests
+(e.g. \path{echo new\_target > /proc/xen/balloon}) requests
 that the kernel adjust the domain's memory footprint to a new value.
 
 \subsection{Setting memory limits}
@@ -1285,7 +1285,7 @@
 The available commands are as follows:
 
 \begin{description}
-\item[balloon] Request a domain to adjust its memory footprint.
+\item[set-mem] Request a domain to adjust its memory footprint.
 \item[create] Create a new domain.
 \item[destroy] Kill a domain immediately.
 \item[list] List running domains.
diff -r 501a70f3ae96 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py	Thu Jul 28 12:34:45 2005
+++ b/tools/python/xen/xm/main.py	Fri Jul 29 14:06:14 2005
@@ -561,9 +561,9 @@
 
 xm.prog(ProgMaxmem)
 
-class ProgBalloon(Prog):
-    group = 'domain'
-    name  = 'balloon'
+class ProgSetMem(Prog):
+    group = 'domain'
+    name  = 'set-mem'
     info  = """Set the domain's memory footprint using the balloon driver."""
 
     def help(self, args):
@@ -577,7 +577,7 @@
         mem_target = int_unit(args[2], 'm')
         server.xend_domain_mem_target_set(dom, mem_target)
 
-xm.prog(ProgBalloon)
+xm.prog(ProgSetMem)
 
 class ProgVcpuhotplug(Prog):
     group = 'domain'

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 8%]

* [PATCH] Convert balloon driver to xenstore
@ 2005-08-01 17:19 22% Dan Smith
  0 siblings, 0 replies; 200+ results
From: Dan Smith @ 2005-08-01 17:19 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

The attached patch converts the balloon driver and xend to use
xenstore instead of control messages.

Note: Because there is no way to set a watch on a non-existent key,
this patch includes a workaround to account for the fact that dom0's
store keys are not initialized by the tools before it boots.

Signed-off-by: Dan Smith <danms@us.ibm.com>


[-- Attachment #2: balloon.patch --]
[-- Type: text/plain, Size: 9121 bytes --]

diff -r 0db6a59abb95 -r b3ead8c9affb linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Aug  1 10:48:24 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Aug  1 17:03:55 2005
@@ -5,6 +5,7 @@
  *
  * Copyright (c) 2003, B Dragovic
  * Copyright (c) 2003-2004, M Williamson, K Fraser
+ * Copyright (c) 2005 Dan M. Smith, IBM Corporation
  * 
  * This file may be distributed separately from the Linux kernel, or
  * incorporated into other software packages, subject to the following license:
@@ -42,7 +43,6 @@
 #include <linux/vmalloc.h>
 #include <asm-xen/xen_proc.h>
 #include <asm-xen/hypervisor.h>
-#include <asm-xen/ctrl_if.h>
 #include <asm-xen/balloon.h>
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
@@ -50,6 +50,10 @@
 #include <asm/tlb.h>
 #include <linux/list.h>
 
+#include<asm-xen/xenbus.h>
+
+#define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10))
+
 static struct proc_dir_entry *balloon_pde;
 
 static DECLARE_MUTEX(balloon_mutex);
@@ -77,11 +81,17 @@
 static DECLARE_WORK(balloon_worker, balloon_process, NULL);
 static struct timer_list balloon_timer;
 
+/* Flag for dom0 xenstore workaround */
+static int balloon_xenbus_init=0;
+
+/* Init Function */
+void balloon_init_watcher(void);
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 /* Use the private and mapping fields of struct page as a list. */
 #define PAGE_TO_LIST(p) ( (struct list_head *)&p->private )
 #define LIST_TO_PAGE(l) ( list_entry( ((unsigned long *)l),   \
-				      struct page, private ) )
+                                      struct page, private ) )
 #define UNLIST_PAGE(p)  do { list_del(PAGE_TO_LIST(p));       \
                              p->mapping = NULL;               \
                              p->private = 0; } while(0)
@@ -297,25 +307,96 @@
     schedule_work(&balloon_worker);
 }
 
-static void balloon_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
-{
-    switch ( msg->subtype )
-    {
-    case CMSG_MEM_REQUEST_SET:
-    {
-        mem_request_t *req = (mem_request_t *)&msg->msg[0];
-        set_new_target(req->target);
-        req->status = 0;
-    }
-    break;        
-
-    default:
-        msg->length = 0;
-        break;
-    }
-
-    ctrl_if_send_response(msg);
-}
+static struct xenbus_watch xb_watch =
+{
+    .node = "memory"
+};
+
+/* FIXME: This is part of a dom0 sequencing workaround */
+static struct xenbus_watch root_watch =
+{
+    .node = "/"
+};
+
+/* React to a change in the target key */
+static void watch_target(struct xenbus_watch *watch, const char *node)
+{
+    unsigned long new_target;
+    int err;
+
+    if(watch == &root_watch)
+    {
+        /* FIXME: This is part of a dom0 sequencing workaround */
+        if(register_xenbus_watch(&xb_watch) == 0)
+        {
+            /* 
+               We successfully set a watch on memory/target:
+               now we can stop watching root 
+            */
+            unregister_xenbus_watch(&root_watch);
+            balloon_xenbus_init=1;
+        } 
+        else 
+        {
+            return;
+        }
+    }
+
+    err = xenbus_scanf("memory", "target", "%lu", &new_target);
+        
+    if(err != 1) 
+    {
+        IPRINTK("Unable to read memory/target\n");
+        return;
+    } 
+        
+    set_new_target(new_target >> PAGE_SHIFT);
+    
+}
+
+/* 
+   Try to set up our watcher, if not already set
+   
+*/
+void balloon_init_watcher(void) 
+{
+    int err;
+
+    if(!xen_start_info.store_evtchn)
+    {
+        IPRINTK("Delaying watcher init until xenstore is available\n");
+        return;
+    }
+
+    down(&xenbus_lock);
+
+    if(! balloon_xenbus_init) 
+    {
+        err = register_xenbus_watch(&xb_watch);
+        if(err) 
+        {
+            /* BIG FAT FIXME: dom0 sequencing workaround
+             * dom0 can't set a watch on memory/target until
+             * after the tools create it.  So, we have to watch
+             * the whole store until that happens.
+             *
+             * This will go away when we have the ability to watch
+             * non-existant keys
+             */
+            register_xenbus_watch(&root_watch);
+        } 
+        else
+        {
+            IPRINTK("Balloon xenbus watcher initialized\n");
+            balloon_xenbus_init = 1;
+        }
+    }
+
+    up(&xenbus_lock);
+
+}
+
+EXPORT_SYMBOL(balloon_init_watcher);
 
 static int balloon_write(struct file *file, const char __user *buffer,
                          unsigned long count, void *data)
@@ -346,7 +427,6 @@
 {
     int len;
 
-#define K(_p) ((_p)<<(PAGE_SHIFT-10))
     len = sprintf(
         page,
         "Current allocation: %8lu kB\n"
@@ -354,13 +434,14 @@
         "Low-mem balloon:    %8lu kB\n"
         "High-mem balloon:   %8lu kB\n"
         "Xen hard limit:     ",
-        K(current_pages), K(target_pages), K(balloon_low), K(balloon_high));
+        PAGES2KB(current_pages), PAGES2KB(target_pages), 
+        PAGES2KB(balloon_low), PAGES2KB(balloon_high));
 
     if ( hard_limit != ~0UL )
         len += sprintf(
             page + len, 
             "%8lu kB (inc. %8lu kB driver headroom)\n",
-            K(hard_limit), K(driver_pages));
+            PAGES2KB(hard_limit), PAGES2KB(driver_pages));
     else
         len += sprintf(
             page + len,
@@ -396,9 +477,7 @@
 
     balloon_pde->read_proc  = balloon_read;
     balloon_pde->write_proc = balloon_write;
-
-    (void)ctrl_if_register_receiver(CMSG_MEM_REQUEST, balloon_ctrlif_rx, 0);
-
+    
     /* Initialise the balloon with excess memory space. */
     for ( pfn = xen_start_info.nr_pages; pfn < max_pfn; pfn++ )
     {
@@ -406,6 +485,11 @@
         if ( !PageReserved(page) )
             balloon_append(page);
     }
+
+    xb_watch.callback = watch_target;
+    root_watch.callback = watch_target;
+
+    balloon_init_watcher();
 
     return 0;
 }
diff -r 0db6a59abb95 -r b3ead8c9affb linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Aug  1 10:48:24 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Aug  1 17:03:55 2005
@@ -309,6 +309,9 @@
 		return err;
 	}
 
+	/* Initialize non-xenbus drivers */
+	balloon_init_watcher();
+
 	down(&xenbus_lock);
 	/* Enumerate devices in xenstore. */
 	xenbus_probe_devices("device");
diff -r 0db6a59abb95 -r b3ead8c9affb tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py	Mon Aug  1 10:48:24 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Aug  1 17:03:55 2005
@@ -152,6 +152,9 @@
         vm = cls(db)
         vm.construct(config)
         vm.saveToDB(sync=True)
+        # Flush info to xenstore immediately
+        vm.exportToDB()
+
         return vm
 
     create = classmethod(create)
@@ -172,6 +175,7 @@
         log.debug('config=' + prettyprintstring(config))
 
         vm.memory = info['mem_kb']/1024
+        vm.target = info['mem_kb'] * 1024
 
         if config:
             try:
@@ -222,6 +226,7 @@
         DBVar('restart_state', ty='str'),
         DBVar('restart_time',  ty='float'),
         DBVar('restart_count', ty='int'),
+        DBVar('target',        ty='long', path="memory/target"),
         ]
     
     def __init__(self, db):
@@ -239,6 +244,8 @@
         self.memory = None
         self.ssidref = None
         self.image = None
+
+        self.target = None
 
         self.channel = None
         self.store_channel = None
@@ -315,6 +322,7 @@
         self.info = info
         self.memory = self.info['mem_kb'] / 1024
         self.ssidref = self.info['ssidref']
+        self.target = self.info['mem_kb'] * 1024
 
     def state_set(self, state):
         self.state_updated.acquire()
@@ -399,7 +407,8 @@
                 ['id', self.id],
                 ['name', self.name],
                 ['memory', self.memory],
-                ['ssidref', self.ssidref] ]
+                ['ssidref', self.ssidref],
+                ['target', self.target] ]
         if self.uuid:
             sxpr.append(['uuid', self.uuid])
         if self.info:
@@ -536,6 +545,7 @@
         self.memory = int(sxp.child_value(config, 'memory'))
         if self.memory is None:
             raise VmError('missing memory size')
+        self.target = self.memory * (1 << 20)
         self.ssidref = int(sxp.child_value(config, 'ssidref'))
         cpu = sxp.child_value(config, 'cpu')
         if self.recreate and self.id and cpu is not None and int(cpu) >= 0:
@@ -947,11 +957,12 @@
             index[field_name] = field_index + 1
 
     def mem_target_set(self, target):
-        """Set domain memory target in pages.
-        """
-        if self.channel:
-            msg = messages.packMsg('mem_request_t', { 'target' : target * (1 << 8)} )
-            self.channel.writeRequest(msg)
+        """Set domain memory target in bytes.
+        """
+        if target:
+            self.target = target * (1 << 20)
+            # Commit to XenStore immediately
+            self.exportToDB()
 
     def vcpu_hotplug(self, vcpu, state):
         """Disable or enable VCPU in domain.

[-- Attachment #3: Type: text/plain, Size: 88 bytes --]


-- 
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms@us.ibm.com

[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 22%]

* [Patch] allocate_empty_lowmem_region in non-privileged domains
  @ 2005-08-02 15:11 11%       ` Ross McIlroy
  2005-08-02 15:58  0%         ` Mark Williamson
  0 siblings, 1 reply; 200+ results
From: Ross McIlroy @ 2005-08-02 15:11 UTC (permalink / raw)
  To: Mark Williamson; +Cc: cwc22, xen-devel, Ross C Mcilroy

[-- Attachment #1: Type: text/plain, Size: 1905 bytes --]

Below is a patch to the enable allocate_empty_lowmem_region in
on-privileged domains, so that backend drivers can map granted foreign
pages even if they are running in an unprivileged domain. (as per the
"allocate_empty_lowmem_region hypervisor function" thread discussion)

Thanks

Ross


# HG changeset patch
# User rcmcilro@localhost.localdomain
# Node ID b235cde45efbb903d3e0e9626df6a90adde20577
# Parent  2f743309f21afdc6adaef01421da40f7ff1e8b0d
Add allocate_empty_lowmem_region() for unprivileged domains

diff -r 2f743309f21a -r b235cde45efb
linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Tue Aug  2
12:37:37 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Tue Aug  2
13:58:30 2005
@@ -35,6 +35,7 @@
 #include <asm/pgtable.h>
 #include <asm-xen/hypervisor.h>
 #include <asm-xen/balloon.h>
+#include <linux/module.h>
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 #include <linux/percpu.h>
 #include <asm/tlbflush.h>
@@ -312,7 +313,6 @@
     balloon_unlock(flags);
 }
 
-#ifdef CONFIG_XEN_PHYSDEV_ACCESS
 
 unsigned long allocate_empty_lowmem_region(unsigned long pages)
 {
@@ -360,4 +360,4 @@
     return vstart;
 }
 
-#endif /* CONFIG_XEN_PHYSDEV_ACCESS */
+EXPORT_SYMBOL(allocate_empty_lowmem_region);
diff -r 2f743309f21a -r b235cde45efb
linux-2.6-xen-sparse/include/asm-xen/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-xen/hypervisor.h	Tue Aug  2 12:37:37 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/hypervisor.h	Tue Aug  2 13:58:30 2005
@@ -136,10 +136,8 @@
 
 void xen_contig_memory(unsigned long vstart, unsigned int order);
 
-#ifdef CONFIG_XEN_PHYSDEV_ACCESS
 /* Allocate a contiguous empty region of low memory. Return virtual start. */
 unsigned long allocate_empty_lowmem_region(unsigned long pages);
-#endif
 
 #include <asm/hypercall.h>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: allocate_empty_lowmem_region.patch --]
[-- Type: text/x-patch; name="allocate_empty_lowmem_region.patch", Size: 1559 bytes --]

# HG changeset patch
# User rcmcilro@localhost.localdomain
# Node ID b235cde45efbb903d3e0e9626df6a90adde20577
# Parent  2f743309f21afdc6adaef01421da40f7ff1e8b0d
Add allocate_empty_lowmem_region() for unprivileged domains

diff -r 2f743309f21a -r b235cde45efb linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Tue Aug  2 12:37:37 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Tue Aug  2 13:58:30 2005
@@ -35,6 +35,7 @@
 #include <asm/pgtable.h>
 #include <asm-xen/hypervisor.h>
 #include <asm-xen/balloon.h>
+#include <linux/module.h>
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 #include <linux/percpu.h>
 #include <asm/tlbflush.h>
@@ -312,7 +313,6 @@
     balloon_unlock(flags);
 }
 
-#ifdef CONFIG_XEN_PHYSDEV_ACCESS
 
 unsigned long allocate_empty_lowmem_region(unsigned long pages)
 {
@@ -360,4 +360,4 @@
     return vstart;
 }
 
-#endif /* CONFIG_XEN_PHYSDEV_ACCESS */
+EXPORT_SYMBOL(allocate_empty_lowmem_region);
diff -r 2f743309f21a -r b235cde45efb linux-2.6-xen-sparse/include/asm-xen/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-xen/hypervisor.h	Tue Aug  2 12:37:37 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/hypervisor.h	Tue Aug  2 13:58:30 2005
@@ -136,10 +136,8 @@
 
 void xen_contig_memory(unsigned long vstart, unsigned int order);
 
-#ifdef CONFIG_XEN_PHYSDEV_ACCESS
 /* Allocate a contiguous empty region of low memory. Return virtual start. */
 unsigned long allocate_empty_lowmem_region(unsigned long pages);
-#endif
 
 #include <asm/hypercall.h>
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 11%]

* Re: [Patch] allocate_empty_lowmem_region in non-privileged domains
  2005-08-02 15:11 11%       ` [Patch] allocate_empty_lowmem_region in non-privileged domains Ross McIlroy
@ 2005-08-02 15:58  0%         ` Mark Williamson
  0 siblings, 0 replies; 200+ results
From: Mark Williamson @ 2005-08-02 15:58 UTC (permalink / raw)
  To: Ross McIlroy; +Cc: cwc22, xen-devel, Ross C Mcilroy

> Below is a patch to the enable allocate_empty_lowmem_region in
> on-privileged domains, so that backend drivers can map granted foreign
> pages even if they are running in an unprivileged domain. (as per the
> "allocate_empty_lowmem_region hypervisor function" thread discussion)

I see you're adding an export so that it's usable by modules; I think that 
makes sense.  Although the current backends must be statically compiled 
there's no reason not to export this for other backends to use.  Harry tells 
me the 2.6 USB backend is fully modularised, for instance (he also pointed 
out there's no way to deallocate the empty lowmem region on unload, which'll 
need to be addressed at some stage).

I did wonder if we ought to tweak the name if we're exporting to the rest of 
the kernel (e.g. prefix xen_) but I don't think we have a convention for 
that.

Basically, +1 from me.  I like it.

Cheers,
Mark

> Thanks
>
> Ross
>
>
> # HG changeset patch
> # User rcmcilro@localhost.localdomain
> # Node ID b235cde45efbb903d3e0e9626df6a90adde20577
> # Parent  2f743309f21afdc6adaef01421da40f7ff1e8b0d
> Add allocate_empty_lowmem_region() for unprivileged domains
>
> diff -r 2f743309f21a -r b235cde45efb
> linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c
> --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Tue Aug  2
> 12:37:37 2005
> +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Tue Aug  2
> 13:58:30 2005
> @@ -35,6 +35,7 @@
>  #include <asm/pgtable.h>
>  #include <asm-xen/hypervisor.h>
>  #include <asm-xen/balloon.h>
> +#include <linux/module.h>
>  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
>  #include <linux/percpu.h>
>  #include <asm/tlbflush.h>
> @@ -312,7 +313,6 @@
>      balloon_unlock(flags);
>  }
>
> -#ifdef CONFIG_XEN_PHYSDEV_ACCESS
>
>  unsigned long allocate_empty_lowmem_region(unsigned long pages)
>  {
> @@ -360,4 +360,4 @@
>      return vstart;
>  }
>
> -#endif /* CONFIG_XEN_PHYSDEV_ACCESS */
> +EXPORT_SYMBOL(allocate_empty_lowmem_region);
> diff -r 2f743309f21a -r b235cde45efb
> linux-2.6-xen-sparse/include/asm-xen/hypervisor.h
> --- a/linux-2.6-xen-sparse/include/asm-xen/hypervisor.h	Tue Aug  2 12:37:37
> 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/hypervisor.h	Tue Aug  2
> 13:58:30 2005 @@ -136,10 +136,8 @@
>
>  void xen_contig_memory(unsigned long vstart, unsigned int order);
>
> -#ifdef CONFIG_XEN_PHYSDEV_ACCESS
>  /* Allocate a contiguous empty region of low memory. Return virtual start.
> */ unsigned long allocate_empty_lowmem_region(unsigned long pages);
> -#endif
>
>  #include <asm/hypercall.h>

^ permalink raw reply	[relevance 0%]

* Balloon tests
@ 2005-08-05 17:02  7% Paul Larson
  2005-08-05 17:44  6% ` Anthony Liguori
  0 siblings, 1 reply; 200+ results
From: Paul Larson @ 2005-08-05 17:02 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 20294 bytes --]

I've submitted these before, and there were no comments.  Any
suggestions for addition tests on the balloon driver would be
appreciated.  Here it is again as a patch putting them
under /tools/tests/balloon.

-- 
Thanks,
Paul Larson
plars@linuxtestproject.org
http://www.linuxtestproject.org

# HG changeset patch
# User root@bl3-3.ltc.austin.ibm.com
# Node ID fa47e95d40dc1cd96ff54555284efd60bbdd6406
# Parent  b63577ff53a3161ac73b55e0aa87803e76c8bde5
Add simple set of tests for balloon driver

These can be executed individually, or with make check from the balloon
directory.  The ballon06 test is skipped in make check for the time 
being, and has a big warning and 10 second delay when you run it 
standalone since it exposes the system hang bug described in bug #145.

Signed-off-by: Paul Larson <pl@us.ibm.com>

diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/Makefile
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/Makefile	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,27 @@
+CFLAGS=-g -Wall -Werror
+
+PROGS=balloon07 balloon08 balloon09 memsteal
+
+#balloon06 is left out on purpose due to a known, fatal bug
+TESTS=balloon01 balloon02 balloon03 balloon04 balloon05 balloon07 \
+      balloon08 balloon09
+
+all: $(PROGS)
+
+balloon07: balloon07.o
+balloon08: balloon08.o
+balloon09: balloon09.o
+memsteal: memsteal.o
+
+clean:
+	$(RM) *.o $(PROGS)
+
+check: all
+	for test in $(TESTS); do ./$$test; done
+
+%.o: %.c
+	$(CC) -c $(CFLAGS) -o $@ $^
+
+%: %.o
+	$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)
+
diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon01
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/balloon01	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Copyright (c) International Business Machines  Corp., 2005
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+#
+# Test name: balloon01
+# Author: Paul Larson <pl@us.ibm.com>
+# Description: Test read from /proc/xen/balloon
+
+TESTNAME=balloon01
+
+cat /proc/xen/balloon &> /dev/null
+if [ $? == 0 ]
+then
+	echo "$TESTNAME	PASS: read from /proc/xen/balloon"
+else
+	echo "$TESTNAME	FAIL: read from /proc/xen/balloon"
+fi
diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon02
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/balloon02	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+#
+# Copyright (c) International Business Machines  Corp., 2005
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+#
+# Test name: balloon02
+# Author: Paul Larson <pl@us.ibm.com>
+# Description: Echo a number higher than current requested allocation
to 
+#	       /proc/xen/balloon, cat balloon and see that requested 
+#	       target changed.
+
+TESTNAME=balloon02
+
+#Units seem to currently be in kB
+old_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
$3}'`
+
+new_alloc=$(( $old_alloc + 4096 ))
+echo $[new_alloc]K > /proc/xen/balloon
+check_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
$3}'`
+
+#cleanup before checking the value and exiting
+echo $[old_alloc]K > /proc/xen/balloon
+
+if [ $check_alloc == $new_alloc ]
+then
+	echo "$TESTNAME	PASS: Requested allocation increased from $old_alloc"\
+             "kB to $new_alloc kB"
+else
+	echo "$TESTNAME	FAIL: increase Requested allocation by 4k"
+fi
diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon03
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/balloon03	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+#
+# Copyright (c) International Business Machines  Corp., 2005
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+#
+# Test name: balloon03
+# Author: Paul Larson <pl@us.ibm.com>
+# Description: Echo a number lower than current requested allocation
to 
+#	       /proc/xen/balloon, cat balloon and see that requested 
+#	       target changed.
+
+TESTNAME=balloon03
+
+#Units seem to currently be in kB
+old_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
$3}'`
+
+new_alloc=$(( $old_alloc - 4096 ))
+echo $[new_alloc]K > /proc/xen/balloon
+check_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
$3}'`
+
+#cleanup before checking the value and exiting
+echo $[old_alloc]K > /proc/xen/balloon
+
+if [ $check_alloc == $new_alloc ]
+then
+	echo "$TESTNAME	PASS: Requested allocation decreased from $old_alloc"\
+             "kB to $new_alloc kB"
+else
+	echo "$TESTNAME	FAIL: decrease Requested allocation by 4k"
+fi
diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon04
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/balloon04	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+#
+# Copyright (c) International Business Machines  Corp., 2005
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+#
+# Test name: balloon04
+# Author: Paul Larson <pl@us.ibm.com>
+# Description: Allocate some memory for the domain, then use
+#              /proc/xen/balloon to reduce available memory to less
than
+#              what is allocated
+
+TESTNAME=balloon04
+
+old_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
$3}'`
+
+#Allocating 128 MB, reducing memory to 120 MB
+new_alloc=$(( 120 * 1024 ))
+./memsteal 128&
+cpid=$!
+sleep 2
+
+echo $[new_alloc]K > /proc/xen/balloon
+#wait a moment for it to settle
+sleep 3
+echo $[old_alloc]K > /proc/xen/balloon
+kill $cpid
+
+#If you make it this far, the test passed
+echo "$TESTNAME PASS: Requested allocation reduced to $new_alloc kB"
diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon05
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/balloon05	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+#
+# Copyright (c) International Business Machines  Corp., 2005
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+#
+# Test name: balloon05
+# Author: Paul Larson <pl@us.ibm.com>
+# Description: Try to give /proc/xen/balloon a value larger than the 
+#	       available RAM in the system.
+
+TESTNAME=balloon05
+
+#Units seem to currently be in kB
+old_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
$3}'`
+
+#If you have more than 70GB, either change this number or take some of
that 
+#out and send it my way :)
+new_alloc=73400320
+
+echo $[new_alloc]K > /proc/xen/balloon
+check_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
$3}'`
+
+#cleanup before checking the value and exiting
+echo $[old_alloc]K > /proc/xen/balloon
+
+if [ $check_alloc == $new_alloc ]
+then
+	echo "$TESTNAME	PASS: Requested alloc. increased from $old_alloc"\
+             "kB to $new_alloc kB"
+else
+	echo "$TESTNAME	FAIL: increase Requested allocation to 70GB"
+fi
diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon06
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/balloon06	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+#
+# Copyright (c) International Business Machines  Corp., 2005
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+#
+# Test name: balloon06
+# Author: Paul Larson <pl@us.ibm.com>
+# Description: Try to give /proc/xen/balloon a value way too low, such
as 4k
+#
+# Warning: Known to crash at the time this was written
+
+TESTNAME=balloon06
+
+old_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
$3}'`
+new_alloc=4
+
+echo
'**********************************************************************'
+echo '* Warning!!! About to run a test that is known to hang or crash
*'
+echo '* the system! Abort now, echo if you wish, sleeping for 10
seconds.  *'
+echo
'**********************************************************************'
+sleep 10
+
+echo $[new_alloc]K > /proc/xen/balloon
+sleep 3
+echo $[old_alloc]K > /proc/xen/balloon
+echo "$TESTNAME PASS: Requested allocation reduced to $new_alloc kB"
diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon07.c
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/balloon07.c	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,68 @@
+/*
+ *
+ * Copyright (c) International Business Machines  Corp., 2005
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Test name: balloon07
+ * Author: Paul Larson <pl@us.ibm.com>
+ * Description: Open /proc/xen/balloon as non-root user, expect -EACCES
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define TESTNAME "balloon07"
+
+int main(void)
+{
+	int fd;
+	int err;
+	char username[] = "nobody";
+	struct passwd *user;
+
+	user = getpwnam(username);
+
+	if (setreuid(user->pw_uid, user->pw_uid) == -1) {
+		printf("%s FAIL: setreuid(): %s\n",TESTNAME, strerror(errno));
+		exit(1);
+	}
+
+	fd = open("/proc/xen/balloon", O_RDWR);
+	err = errno;
+	if (fd != -1) {
+		printf("%s FAIL: Write to /proc/xen/balloon as non-root "
+		       "user succeeded\n", TESTNAME);
+		close(fd);
+		exit(1);
+	}
+	if (err != 13) {
+		printf("%s FAIL: Write to /proc/xen/balloon as non-root "
+		       "got errno %d, expected 13\n", TESTNAME, err);
+		close(fd);
+		exit(1);
+	}
+	printf("%s PASS: Write to /proc/xen/balloon as non-root user failed "
+	       "with -EACCES\n", TESTNAME);
+	close(fd);
+	exit(0);
+}
+
diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon08.c
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/balloon08.c	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,64 @@
+/*
+ *
+ * Copyright (c) International Business Machines  Corp., 2005
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Test name: balloon08
+ * Author: Paul Larson <pl@us.ibm.com>
+ * Description: Write 1 byte to /proc/xen/balloon, expect -EBADMSG
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define TESTNAME "balloon08"
+
+int main(void)
+{
+	int fd;
+	int ret, err;
+
+	fd = open("/proc/xen/balloon", O_RDWR);
+	if (fd == -1) {
+		printf("%s FAIL: failed to open /proc/xen/balloon, %s\n",
+			TESTNAME, strerror(errno));
+		exit(1);
+	}
+	ret = write(fd, "a", 1);
+	err = errno;
+	if (ret != -1) {
+		printf("%s FAIL: Write 1 byte to /proc/xen/balloon succeeded\n",
+			TESTNAME);
+		close(fd);
+		exit(1);
+	}
+	if (err != 74) {
+		printf("%s FAIL: Write 1 byte got errno %d, expected 74\n",
+			TESTNAME, err);
+		close(fd);
+		exit(1);
+	}
+	printf("%s PASS: Write 1 byte failed with -EBADMSG\n",
+		TESTNAME);
+	close(fd);
+	exit(0);
+}
+
diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon09.c
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/balloon09.c	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,70 @@
+/*
+ *
+ * Copyright (c) International Business Machines  Corp., 2005
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Test name: balloon09
+ * Author: Paul Larson <pl@us.ibm.com>
+ * Description: Write >64 bytes to /proc/xen/balloon, expect -EFBIG
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define TESTNAME "balloon09"
+#define STRSIZE 100
+
+int main(void)
+{
+	int fd;
+	int ret, err, i;
+	char str[STRSIZE];
+
+	for(i=0;i<64;i++) {
+		*(str + i) = 'a';
+	}
+
+	fd = open("/proc/xen/balloon", O_RDWR);
+	if (fd == -1) {
+		printf("%s FAIL: failed to open /proc/xen/balloon, %s\n",
+			TESTNAME, strerror(errno));
+		exit(1);
+	}
+	ret = write(fd, str, sizeof(str));
+	err = errno;
+	if (ret != -1) {
+		printf("%s FAIL: Write 1 byte to /proc/xen/balloon succeeded\n",
+			TESTNAME);
+		close(fd);
+		exit(1);
+	}
+	if (err != 27) {
+		printf("%s FAIL: Write 1 byte got errno %d, expected 27\n",
+			TESTNAME, err);
+		close(fd);
+		exit(1);
+	}
+	printf("%s PASS: Write 1 byte failed with -EFBIG as expected\n",
+		TESTNAME);
+	close(fd);
+	exit(0);
+}
+
diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/memsteal.c
--- /dev/null	Fri Aug  5 14:57:43 2005
+++ b/tools/tests/balloon/memsteal.c	Fri Aug  5 16:57:07 2005
@@ -0,0 +1,52 @@
+/*
+ *
+ * Copyright (c) International Business Machines  Corp., 2005
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Test name: memsteal
+ * Author: Paul Larson <pl@us.ibm.com>
+ * Description: simple memory allocator
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+int main(int argc, char **argv)
+{
+	int i;
+	size_t memsize;
+	char *chunk;
+
+	if (argc != 2) {
+		printf("usage: memsteal [Memory in MB]\n"
+		       "Allocates given amount of memory, touches the pages,\n"
+		       "and waits for a signal to exit.\n\n");
+		exit(1);
+	}
+	memsize = atol(argv[1]) * 1024 * 1024;
+	chunk = mmap(0, memsize, PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+	if (chunk == NULL) {
+		perror("mmap()");
+		exit(1);
+	}
+	for(i=0;i<memsize;i+=4096) {
+		chunk[i]='a';
+	}
+	pause();
+	exit(0);
+}


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 7%]

* RE: Balloon tests
@ 2005-08-05 17:36  5% Ian Pratt
  2005-08-05 19:01  0% ` Vincent Hanquez
  0 siblings, 1 reply; 200+ results
From: Ian Pratt @ 2005-08-05 17:36 UTC (permalink / raw)
  To: Paul Larson, xen-devel

 
> I've submitted these before, and there were no comments.  Any 
> suggestions for addition tests on the balloon driver would be 
> appreciated.  Here it is again as a patch putting them under 
> /tools/tests/balloon.

Unrelated, but are we going to move /proc/xen/balloon to somewhere under
/sys e.g. /sys/xen/mem_target or something?

Ian

 
> --
> Thanks,
> Paul Larson
> plars@linuxtestproject.org
> http://www.linuxtestproject.org
> 
> # HG changeset patch
> # User root@bl3-3.ltc.austin.ibm.com
> # Node ID fa47e95d40dc1cd96ff54555284efd60bbdd6406
> # Parent  b63577ff53a3161ac73b55e0aa87803e76c8bde5
> Add simple set of tests for balloon driver
> 
> These can be executed individually, or with make check from 
> the balloon directory.  The ballon06 test is skipped in make 
> check for the time being, and has a big warning and 10 second 
> delay when you run it standalone since it exposes the system 
> hang bug described in bug #145.
> 
> Signed-off-by: Paul Larson <pl@us.ibm.com>
> 
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/Makefile
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/Makefile	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,27 @@
> +CFLAGS=-g -Wall -Werror
> +
> +PROGS=balloon07 balloon08 balloon09 memsteal
> +
> +#balloon06 is left out on purpose due to a known, fatal bug
> +TESTS=balloon01 balloon02 balloon03 balloon04 balloon05 balloon07 \
> +      balloon08 balloon09
> +
> +all: $(PROGS)
> +
> +balloon07: balloon07.o
> +balloon08: balloon08.o
> +balloon09: balloon09.o
> +memsteal: memsteal.o
> +
> +clean:
> +	$(RM) *.o $(PROGS)
> +
> +check: all
> +	for test in $(TESTS); do ./$$test; done
> +
> +%.o: %.c
> +	$(CC) -c $(CFLAGS) -o $@ $^
> +
> +%: %.o
> +	$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)
> +
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon01
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/balloon01	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,31 @@
> +#!/bin/bash
> +
> +#
> +# Copyright (c) International Business Machines  Corp., 2005 # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> USA
> +#
> +# Test name: balloon01
> +# Author: Paul Larson <pl@us.ibm.com>
> +# Description: Test read from /proc/xen/balloon
> +
> +TESTNAME=balloon01
> +
> +cat /proc/xen/balloon &> /dev/null
> +if [ $? == 0 ]
> +then
> +	echo "$TESTNAME	PASS: read from /proc/xen/balloon"
> +else
> +	echo "$TESTNAME	FAIL: read from /proc/xen/balloon"
> +fi
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon02
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/balloon02	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,43 @@
> +#!/bin/bash
> +
> +#
> +# Copyright (c) International Business Machines  Corp., 2005 # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> USA
> +#
> +# Test name: balloon02
> +# Author: Paul Larson <pl@us.ibm.com>
> +# Description: Echo a number higher than current requested allocation
> to 
> +#	       /proc/xen/balloon, cat balloon and see that requested 
> +#	       target changed.
> +
> +TESTNAME=balloon02
> +
> +#Units seem to currently be in kB
> +old_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
> $3}'`
> +
> +new_alloc=$(( $old_alloc + 4096 ))
> +echo $[new_alloc]K > /proc/xen/balloon
> +check_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' 
> +' '{print
> $3}'`
> +
> +#cleanup before checking the value and exiting echo $[old_alloc]K > 
> +/proc/xen/balloon
> +
> +if [ $check_alloc == $new_alloc ]
> +then
> +	echo "$TESTNAME	PASS: Requested allocation increased 
> from $old_alloc"\
> +             "kB to $new_alloc kB"
> +else
> +	echo "$TESTNAME	FAIL: increase Requested allocation by 4k"
> +fi
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon03
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/balloon03	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,43 @@
> +#!/bin/bash
> +
> +#
> +# Copyright (c) International Business Machines  Corp., 2005 # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> USA
> +#
> +# Test name: balloon03
> +# Author: Paul Larson <pl@us.ibm.com>
> +# Description: Echo a number lower than current requested allocation
> to 
> +#	       /proc/xen/balloon, cat balloon and see that requested 
> +#	       target changed.
> +
> +TESTNAME=balloon03
> +
> +#Units seem to currently be in kB
> +old_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
> $3}'`
> +
> +new_alloc=$(( $old_alloc - 4096 ))
> +echo $[new_alloc]K > /proc/xen/balloon
> +check_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' 
> +' '{print
> $3}'`
> +
> +#cleanup before checking the value and exiting echo $[old_alloc]K > 
> +/proc/xen/balloon
> +
> +if [ $check_alloc == $new_alloc ]
> +then
> +	echo "$TESTNAME	PASS: Requested allocation decreased 
> from $old_alloc"\
> +             "kB to $new_alloc kB"
> +else
> +	echo "$TESTNAME	FAIL: decrease Requested allocation by 4k"
> +fi
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon04
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/balloon04	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,42 @@
> +#!/bin/bash
> +
> +#
> +# Copyright (c) International Business Machines  Corp., 2005 # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> USA
> +#
> +# Test name: balloon04
> +# Author: Paul Larson <pl@us.ibm.com>
> +# Description: Allocate some memory for the domain, then use
> +#              /proc/xen/balloon to reduce available memory to less
> than
> +#              what is allocated
> +
> +TESTNAME=balloon04
> +
> +old_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
> $3}'`
> +
> +#Allocating 128 MB, reducing memory to 120 MB new_alloc=$(( 
> 120 * 1024 
> +)) ./memsteal 128& cpid=$!
> +sleep 2
> +
> +echo $[new_alloc]K > /proc/xen/balloon
> +#wait a moment for it to settle
> +sleep 3
> +echo $[old_alloc]K > /proc/xen/balloon
> +kill $cpid
> +
> +#If you make it this far, the test passed echo "$TESTNAME PASS: 
> +Requested allocation reduced to $new_alloc kB"
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon05
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/balloon05	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,45 @@
> +#!/bin/bash
> +
> +#
> +# Copyright (c) International Business Machines  Corp., 2005 # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> USA
> +#
> +# Test name: balloon05
> +# Author: Paul Larson <pl@us.ibm.com>
> +# Description: Try to give /proc/xen/balloon a value larger than the 
> +#	       available RAM in the system.
> +
> +TESTNAME=balloon05
> +
> +#Units seem to currently be in kB
> +old_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
> $3}'`
> +
> +#If you have more than 70GB, either change this number or 
> take some of
> that 
> +#out and send it my way :)
> +new_alloc=73400320
> +
> +echo $[new_alloc]K > /proc/xen/balloon
> +check_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' 
> +' '{print
> $3}'`
> +
> +#cleanup before checking the value and exiting echo $[old_alloc]K > 
> +/proc/xen/balloon
> +
> +if [ $check_alloc == $new_alloc ]
> +then
> +	echo "$TESTNAME	PASS: Requested alloc. increased from 
> $old_alloc"\
> +             "kB to $new_alloc kB"
> +else
> +	echo "$TESTNAME	FAIL: increase Requested allocation to 70GB"
> +fi
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon06
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/balloon06	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,39 @@
> +#!/bin/bash
> +
> +#
> +# Copyright (c) International Business Machines  Corp., 2005 # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> USA
> +#
> +# Test name: balloon06
> +# Author: Paul Larson <pl@us.ibm.com>
> +# Description: Try to give /proc/xen/balloon a value way too 
> low, such
> as 4k
> +#
> +# Warning: Known to crash at the time this was written
> +
> +TESTNAME=balloon06
> +
> +old_alloc=`cat /proc/xen/balloon |grep Requested |awk -F ' +' '{print
> $3}'`
> +new_alloc=4
> +
> +echo
> '*************************************************************
> *********'
> +echo '* Warning!!! About to run a test that is known to hang or crash
> *'
> +echo '* the system! Abort now, echo if you wish, sleeping for 10
> seconds.  *'
> +echo
> '*************************************************************
> *********'
> +sleep 10
> +
> +echo $[new_alloc]K > /proc/xen/balloon
> +sleep 3
> +echo $[old_alloc]K > /proc/xen/balloon
> +echo "$TESTNAME PASS: Requested allocation reduced to $new_alloc kB"
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon07.c
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/balloon07.c	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,68 @@
> +/*
> + *
> + * Copyright (c) International Business Machines  Corp., 2005
> + * 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., 59 Temple Place, Suite 330, Boston, MA 
> 02111-1307
> USA
> + *
> + * Test name: balloon07
> + * Author: Paul Larson <pl@us.ibm.com>
> + * Description: Open /proc/xen/balloon as non-root user, 
> expect -EACCES 
> + */
> +
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <pwd.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +
> +#define TESTNAME "balloon07"
> +
> +int main(void)
> +{
> +	int fd;
> +	int err;
> +	char username[] = "nobody";
> +	struct passwd *user;
> +
> +	user = getpwnam(username);
> +
> +	if (setreuid(user->pw_uid, user->pw_uid) == -1) {
> +		printf("%s FAIL: setreuid(): %s\n",TESTNAME, 
> strerror(errno));
> +		exit(1);
> +	}
> +
> +	fd = open("/proc/xen/balloon", O_RDWR);
> +	err = errno;
> +	if (fd != -1) {
> +		printf("%s FAIL: Write to /proc/xen/balloon as 
> non-root "
> +		       "user succeeded\n", TESTNAME);
> +		close(fd);
> +		exit(1);
> +	}
> +	if (err != 13) {
> +		printf("%s FAIL: Write to /proc/xen/balloon as 
> non-root "
> +		       "got errno %d, expected 13\n", TESTNAME, err);
> +		close(fd);
> +		exit(1);
> +	}
> +	printf("%s PASS: Write to /proc/xen/balloon as non-root 
> user failed "
> +	       "with -EACCES\n", TESTNAME);
> +	close(fd);
> +	exit(0);
> +}
> +
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon08.c
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/balloon08.c	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,64 @@
> +/*
> + *
> + * Copyright (c) International Business Machines  Corp., 2005
> + * 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., 59 Temple Place, Suite 330, Boston, MA 
> 02111-1307
> USA
> + *
> + * Test name: balloon08
> + * Author: Paul Larson <pl@us.ibm.com>
> + * Description: Write 1 byte to /proc/xen/balloon, expect -EBADMSG */
> +
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +
> +#define TESTNAME "balloon08"
> +
> +int main(void)
> +{
> +	int fd;
> +	int ret, err;
> +
> +	fd = open("/proc/xen/balloon", O_RDWR);
> +	if (fd == -1) {
> +		printf("%s FAIL: failed to open 
> /proc/xen/balloon, %s\n",
> +			TESTNAME, strerror(errno));
> +		exit(1);
> +	}
> +	ret = write(fd, "a", 1);
> +	err = errno;
> +	if (ret != -1) {
> +		printf("%s FAIL: Write 1 byte to 
> /proc/xen/balloon succeeded\n",
> +			TESTNAME);
> +		close(fd);
> +		exit(1);
> +	}
> +	if (err != 74) {
> +		printf("%s FAIL: Write 1 byte got errno %d, 
> expected 74\n",
> +			TESTNAME, err);
> +		close(fd);
> +		exit(1);
> +	}
> +	printf("%s PASS: Write 1 byte failed with -EBADMSG\n",
> +		TESTNAME);
> +	close(fd);
> +	exit(0);
> +}
> +
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/balloon09.c
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/balloon09.c	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,70 @@
> +/*
> + *
> + * Copyright (c) International Business Machines  Corp., 2005
> + * 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., 59 Temple Place, Suite 330, Boston, MA 
> 02111-1307
> USA
> + *
> + * Test name: balloon09
> + * Author: Paul Larson <pl@us.ibm.com>
> + * Description: Write >64 bytes to /proc/xen/balloon, expect 
> -EFBIG */
> +
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +
> +#define TESTNAME "balloon09"
> +#define STRSIZE 100
> +
> +int main(void)
> +{
> +	int fd;
> +	int ret, err, i;
> +	char str[STRSIZE];
> +
> +	for(i=0;i<64;i++) {
> +		*(str + i) = 'a';
> +	}
> +
> +	fd = open("/proc/xen/balloon", O_RDWR);
> +	if (fd == -1) {
> +		printf("%s FAIL: failed to open 
> /proc/xen/balloon, %s\n",
> +			TESTNAME, strerror(errno));
> +		exit(1);
> +	}
> +	ret = write(fd, str, sizeof(str));
> +	err = errno;
> +	if (ret != -1) {
> +		printf("%s FAIL: Write 1 byte to 
> /proc/xen/balloon succeeded\n",
> +			TESTNAME);
> +		close(fd);
> +		exit(1);
> +	}
> +	if (err != 27) {
> +		printf("%s FAIL: Write 1 byte got errno %d, 
> expected 27\n",
> +			TESTNAME, err);
> +		close(fd);
> +		exit(1);
> +	}
> +	printf("%s PASS: Write 1 byte failed with -EFBIG as expected\n",
> +		TESTNAME);
> +	close(fd);
> +	exit(0);
> +}
> +
> diff -r b63577ff53a3 -r fa47e95d40dc tools/tests/balloon/memsteal.c
> --- /dev/null	Fri Aug  5 14:57:43 2005
> +++ b/tools/tests/balloon/memsteal.c	Fri Aug  5 16:57:07 2005
> @@ -0,0 +1,52 @@
> +/*
> + *
> + * Copyright (c) International Business Machines  Corp., 2005
> + * 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., 59 Temple Place, Suite 330, Boston, MA 
> 02111-1307
> USA
> + *
> + * Test name: memsteal
> + * Author: Paul Larson <pl@us.ibm.com>
> + * Description: simple memory allocator */
> +
> +#include <errno.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <unistd.h>
> +#include <sys/mman.h>
> +
> +int main(int argc, char **argv)
> +{
> +	int i;
> +	size_t memsize;
> +	char *chunk;
> +
> +	if (argc != 2) {
> +		printf("usage: memsteal [Memory in MB]\n"
> +		       "Allocates given amount of memory, 
> touches the pages,\n"
> +		       "and waits for a signal to exit.\n\n");
> +		exit(1);
> +	}
> +	memsize = atol(argv[1]) * 1024 * 1024;
> +	chunk = mmap(0, memsize, PROT_WRITE, 
> MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
> +	if (chunk == NULL) {
> +		perror("mmap()");
> +		exit(1);
> +	}
> +	for(i=0;i<memsize;i+=4096) {
> +		chunk[i]='a';
> +	}
> +	pause();
> +	exit(0);
> +}
> 
> 

^ permalink raw reply	[relevance 5%]

* Re: Balloon tests
  2005-08-05 17:02  7% Balloon tests Paul Larson
@ 2005-08-05 17:44  6% ` Anthony Liguori
  0 siblings, 0 replies; 200+ results
From: Anthony Liguori @ 2005-08-05 17:44 UTC (permalink / raw)
  To: Paul Larson; +Cc: xen-devel

Paul Larson wrote:

>I've submitted these before, and there were no comments.  Any
>suggestions for addition tests on the balloon driver would be
>appreciated.  Here it is again as a patch putting them
>under /tools/tests/balloon.
>  
>
Hi Paul,

As you know, I'm a big fan of randomized testing.  A single randomized 
test can take the place of a large number of single function tests.

For something like the balloon driver, I think this would work best in 
concert with a larger test program that actually checked the results of 
ballooning through different mechanism (via /proc/xen/balloon, xm 
set-mem, or writing to the store directly).

The procpipe code I submitted yesterday would be an excellent way to 
coordinate this.  If you'd like, we can take this offline and develop a 
procpipe based balloon testsuite that really stresses all interfaces for 
the balloon driver.

Regards,

Anthony Liguori

>------------------------------------------------------------------------
>
>_______________________________________________
>Xen-devel mailing list
>Xen-devel@lists.xensource.com
>http://lists.xensource.com/xen-devel
>  
>

^ permalink raw reply	[relevance 6%]

* [PATCH 2/2] Move to new notifier structure
@ 2005-08-05 18:55 15% Dan Smith
  0 siblings, 0 replies; 200+ results
From: Dan Smith @ 2005-08-05 18:55 UTC (permalink / raw)
  To: List: Xen Developers

[-- Attachment #1: Type: text/plain, Size: 217 bytes --]


This patch changes the probe notifier, per Rusty's suggestion.  It
also converts the balloon driver to use the notifier structure, and
removes the root-watch workaround.

Signed-off-by: Dan Smith <danms@us.ibm.com>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 2_notifier_change.patch --]
[-- Type: text/x-patch, Size: 7416 bytes --]

diff -r a94ff69a51a3 linux-2.6-xen-sparse/arch/xen/kernel/reboot.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Fri Aug  5 16:04:24 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Fri Aug  5 11:14:02 2005
@@ -314,6 +314,9 @@
 
 static struct notifier_block xenstore_notifier;
 
+/* Setup our watcher
+   NB: Assumes xenbus_lock is held!
+*/
 static int setup_shutdown_watcher(struct notifier_block *notifier,
                                   unsigned long event,
                                   void *data)
@@ -323,12 +326,12 @@
     int err2 = 0;
 #endif
 
-    down(&xenbus_lock);
+    BUG_ON(down_trylock(&xenbus_lock) == 0);
+
     err1 = register_xenbus_watch(&shutdown_watch);
 #ifdef CONFIG_MAGIC_SYSRQ
     err2 = register_xenbus_watch(&sysrq_watch);
 #endif
-    up(&xenbus_lock);
 
     if (err1) {
         printk(KERN_ERR "Failed to set shutdown watcher\n");
@@ -348,11 +351,7 @@
     
     xenstore_notifier.notifier_call = setup_shutdown_watcher;
 
-    if (xen_start_info.store_evtchn) {
-        setup_shutdown_watcher(&xenstore_notifier, 0, NULL);
-    } else {
-        register_xenstore_notifier(&xenstore_notifier);
-    }
+    register_xenstore_notifier(&xenstore_notifier);
     
     return 0;
 }
diff -r a94ff69a51a3 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Aug  5 16:04:24 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Aug  5 11:14:02 2005
@@ -81,9 +81,6 @@
 static DECLARE_WORK(balloon_worker, balloon_process, NULL);
 static struct timer_list balloon_timer;
 
-/* Flag for dom0 xenstore workaround */
-static int balloon_xenbus_init=0;
-
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 /* Use the private and mapping fields of struct page as a list. */
 #define PAGE_TO_LIST(p) ( (struct list_head *)&p->private )
@@ -304,15 +301,9 @@
     schedule_work(&balloon_worker);
 }
 
-static struct xenbus_watch xb_watch =
-{
-    .node = "memory"
-};
-
-/* FIXME: This is part of a dom0 sequencing workaround */
-static struct xenbus_watch root_watch =
-{
-    .node = "/"
+static struct xenbus_watch target_watch =
+{
+    .node = "memory/target"
 };
 
 /* React to a change in the target key */
@@ -320,30 +311,12 @@
 {
     unsigned long new_target;
     int err;
-
-    if(watch == &root_watch)
-    {
-        /* FIXME: This is part of a dom0 sequencing workaround */
-        if(register_xenbus_watch(&xb_watch) == 0)
-        {
-            /* 
-               We successfully set a watch on memory/target:
-               now we can stop watching root 
-            */
-            unregister_xenbus_watch(&root_watch);
-            balloon_xenbus_init=1;
-        } 
-        else 
-        {
-            return;
-        }
-    }
 
     err = xenbus_scanf("memory", "target", "%lu", &new_target);
         
     if(err != 1) 
     {
-        IPRINTK("Unable to read memory/target\n");
+        printk(KERN_ERR "Unable to read memory/target\n");
         return;
     } 
         
@@ -351,40 +324,26 @@
     
 }
 
-/* Init Function - Try to set up our watcher, if not already set. */
-void balloon_init_watcher(void)
+/* Setup our watcher
+   NB: Assumes xenbus_lock is held!
+*/
+int balloon_init_watcher(struct notifier_block *notifier,
+                         unsigned long event,
+                         void *data)
 {
     int err;
 
-    if (!xen_start_info.store_evtchn) {
-        IPRINTK("Delaying watcher init until xenstore is available\n");
-        return;
-    }
-
-    down(&xenbus_lock);
-
-    if (!balloon_xenbus_init) {
-        err = register_xenbus_watch(&xb_watch);
-        if (err) {
-            /* BIG FAT FIXME: dom0 sequencing workaround
-             * dom0 can't set a watch on memory/target until
-             * after the tools create it.  So, we have to watch
-             * the whole store until that happens.
-             *
-             * This will go away when we have the ability to watch
-             * non-existant keys
-             */
-            register_xenbus_watch(&root_watch);
-        } else {
-            IPRINTK("Balloon xenbus watcher initialized\n");
-            balloon_xenbus_init = 1;
-        }
-    }
-
-    up(&xenbus_lock);
-}
-
-EXPORT_SYMBOL(balloon_init_watcher);
+    BUG_ON(down_trylock(&xenbus_lock) == 0);
+
+    err = register_xenbus_watch(&target_watch);
+
+    if (err) {
+        printk(KERN_ERR "Failed to set balloon watcher\n");
+    }
+
+    return NOTIFY_DONE;
+    
+}
 
 static int balloon_write(struct file *file, const char __user *buffer,
                          unsigned long count, void *data)
@@ -439,6 +398,8 @@
     return len;
 }
 
+static struct notifier_block xenstore_notifier;
+
 static int __init balloon_init(void)
 {
     unsigned long pfn;
@@ -474,11 +435,11 @@
             balloon_append(page);
     }
 
-    xb_watch.callback = watch_target;
-    root_watch.callback = watch_target;
-
-    balloon_init_watcher();
-
+    target_watch.callback = watch_target;
+    xenstore_notifier.notifier_call = balloon_init_watcher;
+
+    register_xenstore_notifier(&xenstore_notifier);
+    
     return 0;
 }
 
diff -r a94ff69a51a3 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Aug  5 16:04:24 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Aug  5 11:14:02 2005
@@ -41,9 +41,6 @@
 
 #define streq(a, b) (strcmp((a), (b)) == 0)
 
-/* Protects notifier chain */
-DECLARE_MUTEX(xenstore_control);
-
 static struct notifier_block *xenstore_chain;
 
 /* If something in array of ids matches this device, return it. */
@@ -317,21 +314,27 @@
 
 int register_xenstore_notifier(struct notifier_block *nb)
 {
-	int ret;
-
-	if ((ret = down_interruptible(&xenstore_control)) != 0) 
-		return ret;
-	ret = notifier_chain_register(&xenstore_chain, nb);
-	up(&xenstore_control);
+	int ret = 0;
+
+	down(&xenbus_lock);
+
+	if (xen_start_info.store_evtchn) {
+		ret = nb->notifier_call(nb, 0, NULL);
+	} else {
+		notifier_chain_register(&xenstore_chain, nb);
+	}
+
+	up(&xenbus_lock);
+
 	return ret;
 }
 EXPORT_SYMBOL(register_xenstore_notifier);
 
 void unregister_xenstore_notifier(struct notifier_block *nb)
 {
-	down(&xenstore_control);
+	down(&xenbus_lock);
 	notifier_chain_unregister(&xenstore_chain, nb);
-	up(&xenstore_control);
+	up(&xenbus_lock);
 }
 EXPORT_SYMBOL(unregister_xenstore_notifier);
 
@@ -349,7 +352,10 @@
 		return err;
 	}
 
+	down(&xenbus_lock);
 	err = notifier_call_chain(&xenstore_chain, 0, 0);
+	up(&xenbus_lock);
+
 	if (err == NOTIFY_BAD) {
 		printk("%s: calling xenstore notify chain failed\n",
 		       __FUNCTION__);
@@ -358,9 +364,6 @@
 
 	err = 0;
 
-	/* Initialize non-xenbus drivers */
-	balloon_init_watcher();
-
 	down(&xenbus_lock);
 	/* Enumerate devices in xenstore. */
 	xenbus_probe_devices("device");
diff -r a94ff69a51a3 linux-2.6-xen-sparse/include/asm-xen/balloon.h
--- a/linux-2.6-xen-sparse/include/asm-xen/balloon.h	Fri Aug  5 16:04:24 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/balloon.h	Fri Aug  5 11:14:02 2005
@@ -48,7 +48,4 @@
 #define balloon_lock(__flags)   spin_lock_irqsave(&balloon_lock, __flags)
 #define balloon_unlock(__flags) spin_unlock_irqrestore(&balloon_lock, __flags)
 
-/* Init Function - Try to set up our watcher, if not already set. */
-void balloon_init_watcher(void);
-
 #endif /* __ASM_BALLOON_H__ */

[-- Attachment #3: Type: text/plain, Size: 88 bytes --]


-- 
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms@us.ibm.com

[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 15%]

* Re: Balloon tests
  2005-08-05 17:36  5% Ian Pratt
@ 2005-08-05 19:01  0% ` Vincent Hanquez
  2005-08-05 19:16  0%   ` Chris Wright
  0 siblings, 1 reply; 200+ results
From: Vincent Hanquez @ 2005-08-05 19:01 UTC (permalink / raw)
  To: Ian Pratt; +Cc: Paul Larson, xen-devel

On Fri, Aug 05, 2005 at 06:36:14PM +0100, Ian Pratt wrote:
> > I've submitted these before, and there were no comments.  Any 
> > suggestions for addition tests on the balloon driver would be 
> > appreciated.  Here it is again as a patch putting them under 
> > /tools/tests/balloon.
> 
> Unrelated, but are we going to move /proc/xen/balloon to somewhere under
> /sys e.g. /sys/xen/mem_target or something?

This is mandatory for merging xen drivers to the linux kernel

-- 
Vincent Hanquez

^ permalink raw reply	[relevance 0%]

* Re: Balloon tests
  2005-08-05 19:01  0% ` Vincent Hanquez
@ 2005-08-05 19:16  0%   ` Chris Wright
  0 siblings, 0 replies; 200+ results
From: Chris Wright @ 2005-08-05 19:16 UTC (permalink / raw)
  To: Vincent Hanquez; +Cc: Ian Pratt, Paul Larson, xen-devel

* Vincent Hanquez (vincent.hanquez@cl.cam.ac.uk) wrote:
> On Fri, Aug 05, 2005 at 06:36:14PM +0100, Ian Pratt wrote:
> > > I've submitted these before, and there were no comments.  Any 
> > > suggestions for addition tests on the balloon driver would be 
> > > appreciated.  Here it is again as a patch putting them under 
> > > /tools/tests/balloon.
> > 
> > Unrelated, but are we going to move /proc/xen/balloon to somewhere under
> > /sys e.g. /sys/xen/mem_target or something?
> 
> This is mandatory for merging xen drivers to the linux kernel

Agreed, all the /proc bits need to move.
-chris

^ permalink raw reply	[relevance 0%]

* [RFC] move Xen linux header files
@ 2005-08-05 19:36  6% Chris Wright
    0 siblings, 1 reply; 200+ results
From: Chris Wright @ 2005-08-05 19:36 UTC (permalink / raw)
  To: xen-devel

Move Xen linux headers to more appropriate places.

  include/asm-xen/*.h -> include/xen/*.h
  include/asm-xen/xen-public/*.h -> include/xen/*.h
  include/asm-xen/linux-public/*.h -> include/linux/xen

This is largely automated, builds and runs clean on i386 and x86_64.
It's a simple step towards merging subarch.

I've got a patch I can post, but above description explains it more
succintly than the patch (diffstat below).  Thoughts?

 linux-2.6-xen-sparse/include/asm-xen/balloon.h              |   54 ---
 linux-2.6-xen-sparse/include/asm-xen/ctrl_if.h              |  160 ---------
 linux-2.6-xen-sparse/include/asm-xen/evtchn.h               |  135 --------
 linux-2.6-xen-sparse/include/asm-xen/foreign_page.h         |   30 -
 linux-2.6-xen-sparse/include/asm-xen/gnttab.h               |   72 ----
 linux-2.6-xen-sparse/include/asm-xen/hypervisor.h           |  199 ------------
 linux-2.6-xen-sparse/include/asm-xen/linux-public/privcmd.h |   90 -----
 linux-2.6-xen-sparse/include/asm-xen/linux-public/suspend.h |   43 --
 linux-2.6-xen-sparse/include/asm-xen/queues.h               |   81 ----
 linux-2.6-xen-sparse/include/asm-xen/synch_bitops.h         |    2 
 linux-2.6-xen-sparse/include/asm-xen/xen_proc.h             |   13 
 linux-2.6-xen-sparse/include/asm-xen/xenbus.h               |  127 -------
 linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c      |    2 
 linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S           |    2 
 linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S            |    2 
 linux-2.6-xen-sparse/arch/xen/i386/kernel/io_apic.c         |    4 
 linux-2.6-xen-sparse/arch/xen/i386/kernel/ioport.c          |    2 
 linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c         |    2 
 linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c         |    2 
 linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c           |    4 
 linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c             |    2 
 linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c         |    4 
 linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c            |    2 
 linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c          |    4 
 linux-2.6-xen-sparse/arch/xen/i386/mm/init.c                |    2 
 linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c             |    2 
 linux-2.6-xen-sparse/arch/xen/kernel/Makefile               |    8 
 linux-2.6-xen-sparse/arch/xen/kernel/ctrl_if.c              |    4 
 linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c               |   12 
 linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c               |    8 
 linux-2.6-xen-sparse/arch/xen/kernel/reboot.c               |   12 
 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S         |    2 
 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/io_apic.c       |    4 
 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/ioport.c        |    2 
 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c       |    2 
 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c       |    4 
 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c         |    4 
 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c       |    2 
 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c          |    8 
 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c          |    2 
 linux-2.6-xen-sparse/drivers/xen/blkback/common.h           |   10 
 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c        |    8 
 linux-2.6-xen-sparse/drivers/xen/blkfront/block.h           |    6 
 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.h            |    8 
 linux-2.6-xen-sparse/drivers/xen/blktap/blktap_datapath.c   |    2 
 linux-2.6-xen-sparse/drivers/xen/blktap/blktap_userdev.c    |    2 
 linux-2.6-xen-sparse/drivers/xen/console/console.c          |    8 
 linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c            |    2 
 linux-2.6-xen-sparse/drivers/xen/netback/common.h           |    6 
 linux-2.6-xen-sparse/drivers/xen/netback/netback.c          |    6 
 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c        |   12 
 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c          |    6 
 linux-2.6-xen-sparse/drivers/xen/usbback/common.h           |    6 
 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c        |    2 
 linux-2.6-xen-sparse/drivers/xen/usbfront/xhci.h            |    2 
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c      |    4 
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c      |    6 
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c         |    2 
 linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h      |    2 
 linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h   |    2 
 linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h        |    4 
 linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h     |    2 
 linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h      |    4 
 linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/fixmap.h    |    2 
 linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h |    2 
 linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h      |    4 
 linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h   |    2 
 linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h    |    6 
 linux-2.6-xen-sparse/include/linux/xen/privcmd.h            |   90 +++++
 linux-2.6-xen-sparse/include/linux/xen/suspend.h            |   43 ++
 linux-2.6-xen-sparse/include/xen/balloon.h                  |   54 +++
 linux-2.6-xen-sparse/include/xen/ctrl_if.h                  |  160 +++++++++
 linux-2.6-xen-sparse/include/xen/evtchn.h                   |  135 ++++++++
 linux-2.6-xen-sparse/include/xen/foreign_page.h             |   30 +
 linux-2.6-xen-sparse/include/xen/gnttab.h                   |   72 ++++
 linux-2.6-xen-sparse/include/xen/hypervisor.h               |  199 ++++++++++++
 linux-2.6-xen-sparse/include/xen/queues.h                   |   81 ++++
 linux-2.6-xen-sparse/include/xen/synch_bitops.h             |    2 
 linux-2.6-xen-sparse/include/xen/xen_proc.h                 |   13 
 linux-2.6-xen-sparse/include/xen/xenbus.h                   |  127 +++++++
 linux-2.6-xen-sparse/mkbuildtree                            |    6 
 tools/blktap/Makefile                                       |    2 
 tools/libxc/Makefile                                        |    2 
 tools/security/Makefile                                     |    2 
 84 files changed, 1130 insertions(+), 1132 deletions(-)

^ permalink raw reply	[relevance 6%]

* Re: Re: [RFC] move Xen linux header files
  @ 2005-08-06  0:09 24%   ` Chris Wright
  0 siblings, 0 replies; 200+ results
From: Chris Wright @ 2005-08-06  0:09 UTC (permalink / raw)
  To: Dan Magenheimer; +Cc: xen-devel

* Dan Magenheimer (dan.magenheimer@hp.com) wrote:
> Chris Wright <chrisw <at> osdl.org> writes:
> > 
> > Move Xen linux headers to more appropriate places.
> > 
> >   include/asm-xen/*.h -> include/xen/*.h
> >   include/asm-xen/xen-public/*.h -> include/xen/*.h
> >   include/asm-xen/linux-public/*.h -> include/linux/xen
> 
> Where do any arch-dep headers go?  In the patch I'm
> floating to linux-ia64, they are in, e.g.,
> include/asm-ia64/xen/*.h

include/asm-$ARCH/mach-xen/*.h is where I've put them for i386.

> Also, from the diffstat its hard to see which files are
> coming and going...

I use a script which may be the most succinct way to see the change.
Here's the core of the script:

---
#! /bin/sh
# move Xen headers

mkdir linux-2.6-xen-sparse/include/xen/
mkdir linux-2.6-xen-sparse/include/linux/xen/

mv linux-2.6-xen-sparse/include/asm-xen/*.h linux-2.6-xen-sparse/include/xen/
mv linux-2.6-xen-sparse/include/asm-xen/linux-public/*.h linux-2.6-xen-sparse/include/linux/xen/

rmdir linux-2.6-xen-sparse/include/asm-xen/linux-public/

find linux-2.6-xen-sparse -name \*.[chS] | while read x; do ./edit.pl $x; done
---

edit.pl just updates the #include bits

Below is the patch, it's quite noisy because of the #include fixups.

diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Fri Aug  5 12:04:35 2005
@@ -15,7 +15,7 @@
 #include <asm/apic.h>
 #include <mach_apic.h>
 #endif
-#include <asm-xen/hypervisor.h>
+#include <xen/hypervisor.h>
 
 #include "cpu.h"
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S	Fri Aug  5 12:04:35 2005
@@ -48,7 +48,7 @@
 #include <asm/smp.h>
 #include <asm/page.h>
 #include "irq_vectors.h"
-#include <asm-xen/xen-public/xen.h>
+#include <xen/xen.h>
 
 #define nr_syscalls ((syscall_table_size)/4)
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S	Fri Aug  5 12:04:35 2005
@@ -22,7 +22,7 @@
 #include <asm/segment.h>
 #include <asm/thread_info.h>
 #include <asm/asm_offsets.h>
-#include <asm-xen/xen-public/arch-x86_32.h>
+#include <xen/arch-x86_32.h>
 
 /*
  * References to members of the new_cpu_data structure.
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/io_apic.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/io_apic.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/io_apic.c	Fri Aug  5 12:04:35 2005
@@ -44,8 +44,8 @@
 
 #ifdef CONFIG_XEN
 
-#include <asm-xen/xen-public/xen.h>
-#include <asm-xen/xen-public/physdev.h>
+#include <xen/xen.h>
+#include <xen/physdev.h>
 
 /* Fake i8259 */
 #define make_8259A_irq(_irq)     (io_apic_irqs &= ~(1UL<<(_irq)))
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/ioport.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/ioport.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/ioport.c	Fri Aug  5 12:04:35 2005
@@ -15,7 +15,7 @@
 #include <linux/stddef.h>
 #include <linux/slab.h>
 #include <linux/thread_info.h>
-#include <asm-xen/xen-public/physdev.h>
+#include <xen/physdev.h>
 
 /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
 static void set_bitmap(unsigned long *bitmap, unsigned int base, unsigned int extent, int new_value)
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Fri Aug  5 12:04:35 2005
@@ -13,7 +13,7 @@
 #include <linux/pci.h>
 #include <linux/version.h>
 #include <asm/io.h>
-#include <asm-xen/balloon.h>
+#include <xen/balloon.h>
 #include <asm/tlbflush.h>
 
 struct dma_coherent_mem {
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c	Fri Aug  5 12:04:35 2005
@@ -48,7 +48,7 @@
 #include <asm/i387.h>
 #include <asm/irq.h>
 #include <asm/desc.h>
-#include <asm-xen/xen-public/physdev.h>
+#include <xen/physdev.h>
 #ifdef CONFIG_MATH_EMULATION
 #include <asm/math_emu.h>
 #endif
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Fri Aug  5 12:04:35 2005
@@ -53,8 +53,8 @@
 #include <asm/io_apic.h>
 #include <asm/ist.h>
 #include <asm/io.h>
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/xen-public/physdev.h>
+#include <xen/hypervisor.h>
+#include <xen/physdev.h>
 #include "setup_arch_pre.h"
 #include <bios_ebda.h>
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c	Fri Aug  5 12:04:35 2005
@@ -26,7 +26,7 @@
 #if 0
 #include <mach_apic.h>
 #endif
-#include <asm-xen/evtchn.h>
+#include <xen/evtchn.h>
 
 #define xxprint(msg) HYPERVISOR_console_io(CONSOLEIO_write, strlen(msg), msg)
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c	Fri Aug  5 12:04:35 2005
@@ -62,7 +62,7 @@
 #include <mach_wakecpu.h>
 #include <smpboot_hooks.h>
 
-#include <asm-xen/evtchn.h>
+#include <xen/evtchn.h>
 
 /* Set if we find a B stepping CPU */
 static int __initdata smp_b_stepping;
@@ -1324,7 +1324,7 @@
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-#include <asm-xen/ctrl_if.h>
+#include <xen/ctrl_if.h>
 
 /* hotplug down/up funtion pointer and target vcpu */
 struct vcpu_hotplug_handler_t {
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c	Fri Aug  5 12:04:35 2005
@@ -70,7 +70,7 @@
 
 #include "io_ports.h"
 
-#include <asm-xen/evtchn.h>
+#include <xen/evtchn.h>
 
 extern spinlock_t i8259A_lock;
 int pit_latch_buggy;              /* extern */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Fri Aug  5 12:04:35 2005
@@ -33,8 +33,8 @@
 #include <linux/vmalloc.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/balloon.h>
+#include <xen/hypervisor.h>
+#include <xen/balloon.h>
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 #include <linux/percpu.h>
 #include <asm/tlbflush.h>
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/mm/init.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c	Fri Aug  5 12:04:35 2005
@@ -39,7 +39,7 @@
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
 #include <asm/sections.h>
-#include <asm-xen/hypervisor.h>
+#include <xen/hypervisor.h>
 
 unsigned int __VMALLOC_RESERVE = 128 << 20;
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Aug  5 12:04:35 2005
@@ -24,7 +24,7 @@
 #include <asm/io.h>
 #include <asm/mmu_context.h>
 
-#include <asm-xen/foreign_page.h>
+#include <xen/foreign_page.h>
 
 void show_mem(void)
 {
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/kernel/Makefile
--- a/linux-2.6-xen-sparse/arch/xen/kernel/Makefile	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/Makefile	Fri Aug  5 12:04:35 2005
@@ -4,12 +4,12 @@
 
 XENARCH	:= $(subst ",,$(CONFIG_XENARCH))
 
-CPPFLAGS_vmlinux.lds += -U$(XENARCH)
+#CPPFLAGS_vmlinux.lds += -U$(XENARCH)
 
-$(obj)/vmlinux.lds.S:
-	@ln -fsn $(srctree)/arch/$(XENARCH)/kernel/vmlinux.lds.S $@
+#$(obj)/vmlinux.lds.S:
+#	@ln -fsn $(srctree)/arch/$(XENARCH)/kernel/vmlinux.lds.S $@
 
-extra-y += vmlinux.lds
+#extra-y += vmlinux.lds
 
 obj-y   := ctrl_if.o evtchn.o fixup.o reboot.o gnttab.o devmem.o
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/kernel/ctrl_if.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/ctrl_if.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/ctrl_if.c	Fri Aug  5 12:04:35 2005
@@ -36,8 +36,8 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
-#include <asm-xen/ctrl_if.h>
-#include <asm-xen/evtchn.h>
+#include <xen/ctrl_if.h>
+#include <xen/evtchn.h>
 
 #if 0
 #define DPRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Fri Aug  5 12:04:35 2005
@@ -37,12 +37,12 @@
 #include <asm/atomic.h>
 #include <asm/system.h>
 #include <asm/ptrace.h>
-#include <asm-xen/synch_bitops.h>
-#include <asm-xen/xen-public/event_channel.h>
-#include <asm-xen/xen-public/physdev.h>
-#include <asm-xen/ctrl_if.h>
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/evtchn.h>
+#include <xen/synch_bitops.h>
+#include <xen/event_channel.h>
+#include <xen/physdev.h>
+#include <xen/ctrl_if.h>
+#include <xen/hypervisor.h>
+#include <xen/evtchn.h>
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 EXPORT_SYMBOL(force_evtchn_callback);
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Fri Aug  5 12:04:35 2005
@@ -16,10 +16,10 @@
 #include <asm/pgtable.h>
 #include <asm/fixmap.h>
 #include <asm/uaccess.h>
-#include <asm-xen/xen_proc.h>
-#include <asm-xen/linux-public/privcmd.h>
-#include <asm-xen/gnttab.h>
-#include <asm-xen/synch_bitops.h>
+#include <xen/xen_proc.h>
+#include <linux/xen/privcmd.h>
+#include <xen/gnttab.h>
+#include <xen/synch_bitops.h>
 
 #if 1
 #define ASSERT(_p) \
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/kernel/reboot.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Fri Aug  5 12:04:35 2005
@@ -8,12 +8,12 @@
 #include <linux/sysrq.h>
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
-#include <asm-xen/evtchn.h>
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/xen-public/dom0_ops.h>
-#include <asm-xen/linux-public/suspend.h>
-#include <asm-xen/queues.h>
-#include <asm-xen/xenbus.h>
+#include <xen/evtchn.h>
+#include <xen/hypervisor.h>
+#include <xen/dom0_ops.h>
+#include <linux/xen/suspend.h>
+#include <xen/queues.h>
+#include <xen/xenbus.h>
 
 #define SHUTDOWN_INVALID  -1
 #define SHUTDOWN_POWEROFF  0
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S	Fri Aug  5 12:04:35 2005
@@ -46,7 +46,7 @@
 #include <asm/thread_info.h>
 #include <asm/hw_irq.h>
 #include <asm/errno.h>
-#include <asm-xen/xen-public/arch-x86_64.h>
+#include <xen/arch-x86_64.h>
 
 #include "irq_vectors.h"
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/x86_64/kernel/io_apic.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/io_apic.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/io_apic.c	Fri Aug  5 12:04:35 2005
@@ -80,8 +80,8 @@
 
 #ifdef CONFIG_XEN
 
-#include <asm-xen/xen-public/xen.h>
-#include <asm-xen/xen-public/physdev.h>
+#include <xen/xen.h>
+#include <xen/physdev.h>
 
 /* Fake i8259 */
 #define make_8259A_irq(_irq)     (io_apic_irqs &= ~(1UL<<(_irq)))
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/x86_64/kernel/ioport.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/ioport.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/ioport.c	Fri Aug  5 12:04:35 2005
@@ -16,7 +16,7 @@
 #include <linux/stddef.h>
 #include <linux/slab.h>
 #include <linux/thread_info.h>
-#include <asm-xen/xen-public/physdev.h>
+#include <xen/physdev.h>
 
 /*
  * sys_iopl has to be used when you want to access the IO ports
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c	Fri Aug  5 12:04:35 2005
@@ -8,7 +8,7 @@
 #include <linux/pci.h>
 #include <linux/module.h>
 #include <asm/io.h>
-#include <asm-xen/balloon.h>
+#include <xen/balloon.h>
 
 /* Map a set of buffers described by scatterlist in streaming
  * mode for DMA.  This is the scatter-gather version of the
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c	Fri Aug  5 12:04:35 2005
@@ -49,8 +49,8 @@
 #include <asm/pda.h>
 #include <asm/prctl.h>
 #include <asm/kdebug.h>
-#include <asm-xen/xen-public/dom0_ops.h>
-#include <asm-xen/xen-public/physdev.h>
+#include <xen/dom0_ops.h>
+#include <xen/physdev.h>
 #include <asm/desc.h>
 #include <asm/proto.h>
 #include <asm/hardirq.h>
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Fri Aug  5 12:04:35 2005
@@ -58,9 +58,9 @@
 #include <asm/setup.h>
 #include <asm/mach_apic.h>
 #include <asm/numa.h>
-#include <asm-xen/xen-public/physdev.h>
+#include <xen/physdev.h>
 #include "setup_arch_pre.h"
-#include <asm-xen/hypervisor.h>
+#include <xen/hypervisor.h>
 
 #define PFN_UP(x)       (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
 #define PFN_PHYS(x)     ((x) << PAGE_SHIFT)
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c	Fri Aug  5 12:04:35 2005
@@ -31,7 +31,7 @@
 #include <asm/mman.h>
 #include <asm/numa.h>
 
-#include <asm-xen/hypervisor.h>
+#include <xen/hypervisor.h>
 
 char x86_boot_params[BOOT_PARAM_SIZE] __initdata = {0,};
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Aug  5 12:04:35 2005
@@ -41,16 +41,16 @@
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
 #include <linux/vmalloc.h>
-#include <asm-xen/xen_proc.h>
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/balloon.h>
+#include <xen/xen_proc.h>
+#include <xen/hypervisor.h>
+#include <xen/balloon.h>
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
 #include <asm/tlb.h>
 #include <linux/list.h>
 
-#include<asm-xen/xenbus.h>
+#include<xen/xenbus.h>
 
 #define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10))
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Fri Aug  5 12:04:35 2005
@@ -13,7 +13,7 @@
 
 #include "common.h"
 #ifdef CONFIG_XEN_BLKDEV_GRANT
-#include <asm-xen/xen-public/grant_table.h>
+#include <xen/grant_table.h>
 #endif
 
 /*
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Fri Aug  5 12:04:35 2005
@@ -12,11 +12,11 @@
 #include <asm/io.h>
 #include <asm/setup.h>
 #include <asm/pgalloc.h>
-#include <asm-xen/ctrl_if.h>
-#include <asm-xen/evtchn.h>
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/xen-public/io/blkif.h>
-#include <asm-xen/xen-public/io/ring.h>
+#include <xen/ctrl_if.h>
+#include <xen/evtchn.h>
+#include <xen/hypervisor.h>
+#include <xen/io/blkif.h>
+#include <xen/io/ring.h>
 
 #if 0
 #define ASSERT(_p) \
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Aug  5 12:04:35 2005
@@ -53,11 +53,11 @@
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <scsi/scsi.h>
-#include <asm-xen/ctrl_if.h>
-#include <asm-xen/evtchn.h>
+#include <xen/ctrl_if.h>
+#include <xen/evtchn.h>
 #ifdef CONFIG_XEN_BLKDEV_GRANT
-#include <asm-xen/xen-public/grant_table.h>
-#include <asm-xen/gnttab.h>
+#include <xen/grant_table.h>
+#include <xen/gnttab.h>
 #endif
 
 typedef unsigned char byte; /* from linux/ide.h */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/blkfront/block.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h	Fri Aug  5 12:04:35 2005
@@ -44,9 +44,9 @@
 #include <linux/blkdev.h>
 #include <linux/major.h>
 #include <linux/devfs_fs_kernel.h>
-#include <asm-xen/xen-public/xen.h>
-#include <asm-xen/xen-public/io/blkif.h>
-#include <asm-xen/xen-public/io/ring.h>
+#include <xen/xen.h>
+#include <xen/io/blkif.h>
+#include <xen/io/ring.h>
 #include <asm/io.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/blktap/blktap.h
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.h	Fri Aug  5 12:04:35 2005
@@ -15,15 +15,15 @@
 #include <linux/config.h>
 #include <linux/sched.h>
 #include <linux/interrupt.h>
-#include <asm-xen/ctrl_if.h>
+#include <xen/ctrl_if.h>
 #include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <asm/io.h>
 #include <asm/setup.h>
 #include <asm/pgalloc.h>
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/xen-public/io/blkif.h>
-#include <asm-xen/xen-public/io/ring.h>
+#include <xen/hypervisor.h>
+#include <xen/io/blkif.h>
+#include <xen/io/ring.h>
 
 /* Used to signal to the backend that this is a tap domain. */
 #define BLKTAP_COOKIE 0xbeadfeed
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/blktap/blktap_datapath.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap_datapath.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap_datapath.c	Fri Aug  5 12:04:35 2005
@@ -9,7 +9,7 @@
  */
  
 #include "blktap.h"
-#include <asm-xen/evtchn.h>
+#include <xen/evtchn.h>
 
 /*-----[ The data paths ]-------------------------------------------------*/
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/blktap/blktap_userdev.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap_userdev.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap_userdev.c	Fri Aug  5 12:04:35 2005
@@ -20,7 +20,7 @@
 #include <linux/poll.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
-#include <asm-xen/xen-public/io/blkif.h> /* for control ring. */
+#include <xen/io/blkif.h> /* for control ring. */
 
 #include "blktap.h"
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/console/console.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Fri Aug  5 12:04:35 2005
@@ -48,10 +48,10 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
-#include <asm-xen/xen-public/event_channel.h>
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/evtchn.h>
-#include <asm-xen/ctrl_if.h>
+#include <xen/event_channel.h>
+#include <xen/hypervisor.h>
+#include <xen/evtchn.h>
+#include <xen/ctrl_if.h>
 
 /*
  * Modes:
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c
--- a/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Fri Aug  5 12:04:35 2005
@@ -45,7 +45,7 @@
 #include <linux/irq.h>
 #include <linux/init.h>
 #define XEN_EVTCHN_MASK_OPS
-#include <asm-xen/evtchn.h>
+#include <xen/evtchn.h>
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 #include <linux/devfs_fs_kernel.h>
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/netback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Fri Aug  5 12:04:35 2005
@@ -14,9 +14,9 @@
 #include <linux/in.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
-#include <asm-xen/ctrl_if.h>
-#include <asm-xen/evtchn.h>
-#include <asm-xen/xen-public/io/netif.h>
+#include <xen/ctrl_if.h>
+#include <xen/evtchn.h>
+#include <xen/io/netif.h>
 #include <asm/io.h>
 #include <asm/pgalloc.h>
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Fri Aug  5 12:04:35 2005
@@ -11,15 +11,15 @@
  */
 
 #include "common.h"
-#include <asm-xen/balloon.h>
+#include <xen/balloon.h>
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 #include <linux/delay.h>
 #endif
 
 #if defined(CONFIG_XEN_NETDEV_GRANT_TX) || defined(CONFIG_XEN_NETDEV_GRANT_RX)
-#include <asm-xen/xen-public/grant_table.h>
-#include <asm-xen/gnttab.h>
+#include <xen/grant_table.h>
+#include <xen/gnttab.h>
 #ifdef GRANT_DEBUG
 static void
 dump_packet(int tag, u32 addr, unsigned char *p)
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Aug  5 12:04:35 2005
@@ -47,16 +47,16 @@
 #include <net/route.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
-#include <asm-xen/evtchn.h>
-#include <asm-xen/ctrl_if.h>
-#include <asm-xen/xen-public/io/netif.h>
-#include <asm-xen/balloon.h>
+#include <xen/evtchn.h>
+#include <xen/ctrl_if.h>
+#include <xen/io/netif.h>
+#include <xen/balloon.h>
 #include <asm/page.h>
 #include <asm/uaccess.h>
 
 #if defined(CONFIG_XEN_NETDEV_GRANT_TX) || defined(CONFIG_XEN_NETDEV_GRANT_RX)
-#include <asm-xen/xen-public/grant_table.h>
-#include <asm-xen/gnttab.h>
+#include <xen/grant_table.h>
+#include <xen/gnttab.h>
 #ifdef GRANT_DEBUG
 static void
 dump_packet(int tag, u32 addr, u32 ap)
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Fri Aug  5 12:04:35 2005
@@ -25,9 +25,9 @@
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
 #include <asm/tlb.h>
-#include <asm-xen/linux-public/privcmd.h>
-#include <asm-xen/xen-public/dom0_ops.h>
-#include <asm-xen/xen_proc.h>
+#include <linux/xen/privcmd.h>
+#include <xen/dom0_ops.h>
+#include <xen/xen_proc.h>
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 #define pud_t pgd_t
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/usbback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/usbback/common.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/common.h	Fri Aug  5 12:04:35 2005
@@ -12,10 +12,10 @@
 #include <asm/io.h>
 #include <asm/setup.h>
 #include <asm/pgalloc.h>
-#include <asm-xen/ctrl_if.h>
-#include <asm-xen/hypervisor.h>
+#include <xen/ctrl_if.h>
+#include <xen/hypervisor.h>
 
-#include <asm-xen/xen-public/io/usbif.h>
+#include <xen/io/usbif.h>
 
 #if 0
 #define ASSERT(_p) \
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c	Fri Aug  5 12:04:35 2005
@@ -69,7 +69,7 @@
 
 #include "../../../../../drivers/usb/hcd.h"
 
-#include <asm-xen/xen-public/io/usbif.h>
+#include <xen/io/usbif.h>
 #include <asm/ctrl_if.h>
 #include <asm/xen-public/io/domain_controller.h>
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/usbfront/xhci.h
--- a/linux-2.6-xen-sparse/drivers/xen/usbfront/xhci.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/xhci.h	Fri Aug  5 12:04:35 2005
@@ -15,7 +15,7 @@
 
 #include <linux/list.h>
 #include <linux/usb.h>
-#include <asm-xen/xen-public/io/usbif.h>
+#include <xen/io/usbif.h>
 #include <linux/spinlock.h>
 
 /* xhci_port_t - current known state of a virtual hub ports */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Fri Aug  5 12:04:35 2005
@@ -27,8 +27,8 @@
  * IN THE SOFTWARE.
  */
 
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/evtchn.h>
+#include <xen/hypervisor.h>
+#include <xen/evtchn.h>
 #include <linux/wait.h>
 #include <linux/interrupt.h>
 #include <linux/sched.h>
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Aug  5 12:04:35 2005
@@ -27,9 +27,9 @@
  */
 #define DEBUG
 
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/xenbus.h>
-#include <asm-xen/balloon.h>
+#include <xen/hypervisor.h>
+#include <xen/xenbus.h>
+#include <xen/balloon.h>
 #include <linux/kernel.h>
 #include <linux/err.h>
 #include <linux/string.h>
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Fri Aug  5 12:04:35 2005
@@ -38,7 +38,7 @@
 #include <linux/slab.h>
 #include <linux/fcntl.h>
 #include <linux/kthread.h>
-#include <asm-xen/xenbus.h>
+#include <xen/xenbus.h>
 #include "xenbus_comms.h"
 
 #define streq(a, b) (strcmp((a), (b)) == 0)
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h	Fri Aug  5 12:04:35 2005
@@ -27,7 +27,7 @@
 #include <asm/acpi.h>
 #include <asm/apicdef.h>
 #include <asm/page.h>
-#include <asm-xen/gnttab.h>
+#include <xen/gnttab.h>
 #ifdef CONFIG_HIGHMEM
 #include <linux/threads.h>
 #include <asm/kmap_types.h>
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h	Fri Aug  5 12:04:35 2005
@@ -29,7 +29,7 @@
 
 #ifndef __HYPERCALL_H__
 #define __HYPERCALL_H__
-#include <asm-xen/xen-public/xen.h>
+#include <xen/xen.h>
 
 /*
  * Assembler stubs for hyper-calls.
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Fri Aug  5 12:04:35 2005
@@ -17,8 +17,8 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <asm/bug.h>
-#include <asm-xen/xen-public/xen.h>
-#include <asm-xen/foreign_page.h>
+#include <xen/xen.h>
+#include <xen/foreign_page.h>
 
 #define arch_free_page(_page,_order)			\
 ({	int foreign = PageForeign(_page);		\
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Fri Aug  5 12:04:35 2005
@@ -2,7 +2,7 @@
 #define _I386_PGTABLE_H
 
 #include <linux/config.h>
-#include <asm-xen/hypervisor.h>
+#include <xen/hypervisor.h>
 
 /*
  * The Linux memory management assumes a three-level page table setup. On
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h	Fri Aug  5 12:04:35 2005
@@ -4,10 +4,10 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/bitops.h>
-#include <asm-xen/synch_bitops.h>
+#include <xen/synch_bitops.h>
 #include <asm/segment.h>
 #include <asm/cpufeature.h>
-#include <asm-xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <asm/smp_alt.h>
 
 #ifdef __KERNEL__
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/fixmap.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/fixmap.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/fixmap.h	Fri Aug  5 12:04:35 2005
@@ -14,7 +14,7 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <asm/apicdef.h>
-#include <asm-xen/gnttab.h>
+#include <xen/gnttab.h>
 #include <asm/page.h>
 #include <asm/vsyscall.h>
 #include <asm/vsyscall32.h>
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h	Fri Aug  5 12:04:35 2005
@@ -35,7 +35,7 @@
 
 #ifndef __HYPERCALL_H__
 #define __HYPERCALL_H__
-#include <asm-xen/xen-public/xen.h>
+#include <xen/xen.h>
 
 #define __syscall_clobber "r11","rcx","memory"
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Fri Aug  5 12:04:35 2005
@@ -6,8 +6,8 @@
 #ifndef __ASSEMBLY__
 #include <linux/types.h>
 #endif
-#include <asm-xen/xen-public/xen.h> 
-#include <asm-xen/foreign_page.h>
+#include <xen/xen.h> 
+#include <xen/foreign_page.h>
 
 #define arch_free_page(_page,_order)			\
 ({	int foreign = PageForeign(_page);		\
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h	Fri Aug  5 12:04:35 2005
@@ -16,7 +16,7 @@
 #include <asm/bitops.h>
 #include <linux/threads.h>
 #include <asm/pda.h>
-#include <asm-xen/hypervisor.h>
+#include <xen/hypervisor.h>
 extern pud_t level3_user_pgt[512];
 extern pud_t init_level4_pgt[];
 extern pud_t init_level4_user_pgt[];
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h	Fri Aug  5 12:04:35 2005
@@ -4,9 +4,9 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <asm/segment.h>
-#include <asm-xen/synch_bitops.h>
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/xen-public/arch-x86_64.h>
+#include <xen/synch_bitops.h>
+#include <xen/hypervisor.h>
+#include <xen/arch-x86_64.h>
 
 #ifdef __KERNEL__
 
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/mkbuildtree
--- a/linux-2.6-xen-sparse/mkbuildtree	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/mkbuildtree	Fri Aug  5 12:04:35 2005
@@ -104,8 +104,6 @@
 
 
 # Create links to the shared definitions of the Xen interfaces.
-rm -rf ${AD}/include/asm-xen/xen-public
-mkdir  ${AD}/include/asm-xen/xen-public
-cd     ${AD}/include/asm-xen/xen-public
-relative_lndir ../../../${RS}/../xen/include/public
+cd     ${AD}/include/xen
+relative_lndir ../../${RS}/../xen/include/public
 
diff -r 69b7c9c3a9fd tools/blktap/Makefile
--- a/tools/blktap/Makefile	Fri Aug  5 15:11:46 2005
+++ b/tools/blktap/Makefile	Fri Aug  5 12:04:35 2005
@@ -52,7 +52,7 @@
 	( cd xen/io >/dev/null ; \
 	   ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . )
 	( cd xen/linux >/dev/null ; \
-	  ln -sf ../../$(LINUX_ROOT)/include/asm-xen/linux-public/*.h . )
+	  ln -sf ../../$(LINUX_ROOT)/include/linux/xen/*.h . )
 
 install: all
 	$(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
diff -r 69b7c9c3a9fd tools/libxc/Makefile
--- a/tools/libxc/Makefile	Fri Aug  5 15:11:46 2005
+++ b/tools/libxc/Makefile	Fri Aug  5 12:04:35 2005
@@ -72,7 +72,7 @@
 	( cd xen/io >/dev/null ; \
 	   ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . )
 	( cd xen/linux >/dev/null ; \
-	  ln -sf ../../$(LINUX_ROOT)/include/asm-xen/linux-public/*.h . )
+	  ln -sf ../../$(LINUX_ROOT)/include/linux/xen/*.h . )
 
 install: build
 	[ -d $(DESTDIR)/usr/$(LIBDIR) ] || $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)
diff -r 69b7c9c3a9fd tools/security/Makefile
--- a/tools/security/Makefile	Fri Aug  5 15:11:46 2005
+++ b/tools/security/Makefile	Fri Aug  5 12:04:35 2005
@@ -33,4 +33,4 @@
 	( cd xen/io >/dev/null ; \
 	  ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . )
 	( cd xen/linux >/dev/null ; \
-	  ln -sf ../../$(LINUX_ROOT)/include/asm-xen/linux-public/*.h . )
+	  ln -sf ../../$(LINUX_ROOT)/include/linux/xen/*.h . )
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/linux/xen/privcmd.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/linux/xen/privcmd.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * privcmd.h
+ * 
+ * Interface to /proc/xen/privcmd.
+ * 
+ * Copyright (c) 2003-2004, K A Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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 __PRIVCMD_H__
+#define __PRIVCMD_H__
+
+typedef struct privcmd_hypercall
+{
+    unsigned long op;
+    unsigned long arg[5];
+} privcmd_hypercall_t;
+
+typedef struct privcmd_mmap_entry {
+    unsigned long va;
+    unsigned long mfn;
+    unsigned long npages;
+} privcmd_mmap_entry_t; 
+
+typedef struct privcmd_mmap {
+    int num;
+    domid_t dom; /* target domain */
+    privcmd_mmap_entry_t *entry;
+} privcmd_mmap_t; 
+
+typedef struct privcmd_mmapbatch {
+    int num;     /* number of pages to populate */
+    domid_t dom; /* target domain */
+    unsigned long addr;  /* virtual address */
+    unsigned long *arr; /* array of mfns - top nibble set on err */
+} privcmd_mmapbatch_t; 
+
+typedef struct privcmd_blkmsg
+{
+    unsigned long op;
+    void         *buf;
+    int           buf_size;
+} privcmd_blkmsg_t;
+
+/*
+ * @cmd: IOCTL_PRIVCMD_HYPERCALL
+ * @arg: &privcmd_hypercall_t
+ * Return: Value returned from execution of the specified hypercall.
+ */
+#define IOCTL_PRIVCMD_HYPERCALL         \
+    _IOC(_IOC_NONE, 'P', 0, sizeof(privcmd_hypercall_t))
+
+/*
+ * @cmd: IOCTL_PRIVCMD_INITDOMAIN_EVTCHN
+ * @arg: n/a
+ * Return: Port associated with domain-controller end of control event channel
+ *         for the initial domain.
+ */
+#define IOCTL_PRIVCMD_INITDOMAIN_EVTCHN \
+    _IOC(_IOC_NONE, 'P', 1, 0)
+#define IOCTL_PRIVCMD_MMAP             \
+    _IOC(_IOC_NONE, 'P', 2, sizeof(privcmd_mmap_t))
+#define IOCTL_PRIVCMD_MMAPBATCH             \
+    _IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t))
+#define IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN \
+    _IOC(_IOC_READ, 'P', 4, sizeof(unsigned long))
+#define IOCTL_PRIVCMD_INITDOMAIN_STORE \
+    _IOC(_IOC_READ, 'P', 5, 0)
+
+#endif /* __PRIVCMD_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/linux/xen/suspend.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/linux/xen/suspend.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * suspend.h
+ * 
+ * Copyright (c) 2003-2004, K A Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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 __ASM_XEN_SUSPEND_H__
+#define __ASM_XEN_SUSPEND_H__
+
+typedef struct suspend_record_st {
+    /* To be filled in before resume. */
+    start_info_t resume_info;
+    /*
+     * The number of a machine frame containing, in sequence, the number of
+     * each machine frame that contains PFN -> MFN translation table data.
+     */
+    unsigned long pfn_to_mfn_frame_list;
+    /* Number of entries in the PFN -> MFN translation table. */
+    unsigned long nr_pfns;
+} suspend_record_t;
+
+#endif /* __ASM_XEN_SUSPEND_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/xen/balloon.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/xen/balloon.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * balloon.h
+ *
+ * Xen balloon driver - enables returning/claiming memory to/from Xen.
+ *
+ * Copyright (c) 2003, B Dragovic
+ * Copyright (c) 2003-2004, M Williamson, K Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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 __ASM_BALLOON_H__
+#define __ASM_BALLOON_H__
+
+/*
+ * Inform the balloon driver that it should allow some slop for device-driver
+ * memory activities.
+ */
+extern void balloon_update_driver_allowance(long delta);
+
+/* Give up unmapped pages to the balloon driver. */
+extern void balloon_put_pages(unsigned long *mfn_list, unsigned long nr_mfns);
+
+/*
+ * Prevent the balloon driver from changing the memory reservation during
+ * a driver critical region.
+ */
+extern spinlock_t balloon_lock;
+#define balloon_lock(__flags)   spin_lock_irqsave(&balloon_lock, __flags)
+#define balloon_unlock(__flags) spin_unlock_irqrestore(&balloon_lock, __flags)
+
+/* Init Function - Try to set up our watcher, if not already set. */
+void balloon_init_watcher(void);
+
+#endif /* __ASM_BALLOON_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/xen/ctrl_if.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/xen/ctrl_if.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,160 @@
+/******************************************************************************
+ * ctrl_if.h
+ * 
+ * Management functions for special interface to the domain controller.
+ * 
+ * Copyright (c) 2004, K A Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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 __ASM_XEN__CTRL_IF_H__
+#define __ASM_XEN__CTRL_IF_H__
+
+#include <xen/hypervisor.h>
+#include <xen/queues.h>
+
+typedef control_msg_t ctrl_msg_t;
+
+/*
+ * Callback function type. Called for asynchronous processing of received
+ * request messages, and responses to previously-transmitted request messages.
+ * The parameters are (@msg, @id).
+ *  @msg: Original request/response message (not a copy). The message can be
+ *        modified in-place by the handler (e.g., a response callback can
+ *        turn a request message into a response message in place). The message
+ *        is no longer accessible after the callback handler returns -- if the
+ *        message is required to persist for longer then it must be copied.
+ *  @id:  (Response callbacks only) The 'id' that was specified when the
+ *        original request message was queued for transmission.
+ */
+typedef void (*ctrl_msg_handler_t)(ctrl_msg_t *, unsigned long);
+
+/*
+ * Send @msg to the domain controller. Execute @hnd when a response is
+ * received, passing the response message and the specified @id. This
+ * operation will not block: it will return -EAGAIN if there is no space.
+ * Notes:
+ *  1. The @msg is copied if it is transmitted and so can be freed after this
+ *     function returns.
+ *  2. If @hnd is NULL then no callback is executed.
+ */
+int
+ctrl_if_send_message_noblock(
+    ctrl_msg_t *msg, 
+    ctrl_msg_handler_t hnd,
+    unsigned long id);
+
+/*
+ * Send @msg to the domain controller. Execute @hnd when a response is
+ * received, passing the response message and the specified @id. This
+ * operation will block until the message is sent, or a signal is received
+ * for the calling process (unless @wait_state is TASK_UNINTERRUPTIBLE).
+ * Notes:
+ *  1. The @msg is copied if it is transmitted and so can be freed after this
+ *     function returns.
+ *  2. If @hnd is NULL then no callback is executed.
+ */
+int
+ctrl_if_send_message_block(
+    ctrl_msg_t *msg, 
+    ctrl_msg_handler_t hnd, 
+    unsigned long id, 
+    long wait_state);
+
+/*
+ * Send @msg to the domain controller. Block until the response is received,
+ * and then copy it into the provided buffer, @rmsg.
+ */
+int
+ctrl_if_send_message_and_get_response(
+    ctrl_msg_t *msg,
+    ctrl_msg_t *rmsg,
+    long wait_state);
+
+/*
+ * Request a callback when there is /possibly/ space to immediately send a
+ * message to the domain controller. This function returns 0 if there is
+ * already space to trasnmit a message --- in this case the callback task /may/
+ * still be executed. If this function returns 1 then the callback /will/ be
+ * executed when space becomes available.
+ */
+int
+ctrl_if_enqueue_space_callback(
+    struct tq_struct *task);
+
+/*
+ * Send a response (@msg) to a message from the domain controller. This will 
+ * never block.
+ * Notes:
+ *  1. The @msg is copied and so can be freed after this function returns.
+ *  2. The @msg may be the original request message, modified in-place.
+ */
+void
+ctrl_if_send_response(
+    ctrl_msg_t *msg);
+
+/*
+ * Register a receiver for typed messages from the domain controller. The 
+ * handler (@hnd) is called for every received message of specified @type.
+ * Returns TRUE (non-zero) if the handler was successfully registered.
+ * If CALLBACK_IN_BLOCKING CONTEXT is specified in @flags then callbacks will
+ * occur in a context in which it is safe to yield (i.e., process context).
+ */
+#define CALLBACK_IN_BLOCKING_CONTEXT 1
+int ctrl_if_register_receiver(
+    u8 type, 
+    ctrl_msg_handler_t hnd,
+    unsigned int flags);
+
+/*
+ * Unregister a receiver for typed messages from the domain controller. The 
+ * handler (@hnd) will not be executed after this function returns.
+ */
+void
+ctrl_if_unregister_receiver(
+    u8 type, ctrl_msg_handler_t hnd);
+
+/* Suspend/resume notifications. */
+void ctrl_if_suspend(void);
+void ctrl_if_resume(void);
+
+/* Start-of-day setup. */
+void ctrl_if_init(void);
+
+/*
+ * Returns TRUE if there are no outstanding message requests at the domain
+ * controller. This can be used to ensure that messages have really flushed
+ * through when it is not possible to use the response-callback interface.
+ * WARNING: If other subsystems are using the control interface then this
+ * function might never return TRUE!
+ */
+int ctrl_if_transmitter_empty(void);  /* !! DANGEROUS FUNCTION !! */
+
+/*
+ * Manually discard response messages from the domain controller. 
+ * WARNING: This is usually done automatically -- this function should only
+ * be called when normal interrupt mechanisms are disabled!
+ */
+void ctrl_if_discard_responses(void); /* !! DANGEROUS FUNCTION !! */
+
+#endif /* __ASM_XEN__CONTROL_IF_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/xen/evtchn.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/xen/evtchn.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,135 @@
+/******************************************************************************
+ * evtchn.h
+ * 
+ * Communication via Xen event channels.
+ * Also definitions for the device that demuxes notifications to userspace.
+ * 
+ * Copyright (c) 2004, K A Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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 __ASM_EVTCHN_H__
+#define __ASM_EVTCHN_H__
+
+#include <linux/config.h>
+#include <linux/interrupt.h>
+#include <xen/hypervisor.h>
+#include <asm/ptrace.h>
+#include <xen/synch_bitops.h>
+#include <xen/event_channel.h>
+#include <linux/smp.h>
+
+/*
+ * LOW-LEVEL DEFINITIONS
+ */
+
+/* Dynamically bind a VIRQ source to Linux IRQ space. */
+extern int  bind_virq_to_irq(int virq);
+extern void unbind_virq_from_irq(int virq);
+
+/* Dynamically bind an IPI source to Linux IRQ space. */
+extern int  bind_ipi_to_irq(int ipi);
+extern void unbind_ipi_from_irq(int ipi);
+
+/* Dynamically bind an event-channel port to Linux IRQ space. */
+extern int  bind_evtchn_to_irq(unsigned int evtchn);
+extern void unbind_evtchn_from_irq(unsigned int evtchn);
+
+/*
+ * Dynamically bind an event-channel port to an IRQ-like callback handler.
+ * On some platforms this may not be implemented via the Linux IRQ subsystem.
+ * You *cannot* trust the irq argument passed to the callback handler.
+ */
+extern int  bind_evtchn_to_irqhandler(
+    unsigned int evtchn,
+    irqreturn_t (*handler)(int, void *, struct pt_regs *),
+    unsigned long irqflags,
+    const char *devname,
+    void *dev_id);
+extern void unbind_evtchn_from_irqhandler(unsigned int evtchn, void *dev_id);
+
+extern void irq_suspend(void);
+extern void irq_resume(void);
+
+/* Entry point for notifications into Linux subsystems. */
+asmlinkage void evtchn_do_upcall(struct pt_regs *regs);
+
+/* Entry point for notifications into the userland character device. */
+void evtchn_device_upcall(int port);
+
+static inline void mask_evtchn(int port)
+{
+    shared_info_t *s = HYPERVISOR_shared_info;
+    synch_set_bit(port, &s->evtchn_mask[0]);
+}
+
+static inline void unmask_evtchn(int port)
+{
+    shared_info_t *s = HYPERVISOR_shared_info;
+    vcpu_info_t *vcpu_info = &s->vcpu_data[smp_processor_id()];
+
+    synch_clear_bit(port, &s->evtchn_mask[0]);
+
+    /*
+     * The following is basically the equivalent of 'hw_resend_irq'. Just like
+     * a real IO-APIC we 'lose the interrupt edge' if the channel is masked.
+     */
+    if (  synch_test_bit        (port,    &s->evtchn_pending[0]) && 
+         !synch_test_and_set_bit(port>>5, &vcpu_info->evtchn_pending_sel) )
+    {
+        vcpu_info->evtchn_upcall_pending = 1;
+        if ( !vcpu_info->evtchn_upcall_mask )
+            force_evtchn_callback();
+    }
+}
+
+static inline void clear_evtchn(int port)
+{
+    shared_info_t *s = HYPERVISOR_shared_info;
+    synch_clear_bit(port, &s->evtchn_pending[0]);
+}
+
+static inline int notify_via_evtchn(int port)
+{
+    evtchn_op_t op;
+    op.cmd = EVTCHNOP_send;
+    op.u.send.local_port = port;
+    return HYPERVISOR_event_channel_op(&op);
+}
+
+/*
+ * CHARACTER-DEVICE DEFINITIONS
+ */
+
+/* /dev/xen/evtchn resides at device number major=10, minor=201 */
+#define EVTCHN_MINOR 201
+
+/* /dev/xen/evtchn ioctls: */
+/* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */
+#define EVTCHN_RESET  _IO('E', 1)
+/* EVTCHN_BIND: Bind to teh specified event-channel port. */
+#define EVTCHN_BIND   _IO('E', 2)
+/* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
+#define EVTCHN_UNBIND _IO('E', 3)
+
+#endif /* __ASM_EVTCHN_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/xen/foreign_page.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/xen/foreign_page.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,30 @@
+/******************************************************************************
+ * foreign_page.h
+ * 
+ * Provide a "foreign" page type, that is owned by a foreign allocator and 
+ * not the normal buddy allocator in page_alloc.c
+ * 
+ * Copyright (c) 2004, K A Fraser
+ */
+
+#ifndef __ASM_XEN_FOREIGN_PAGE_H__
+#define __ASM_XEN_FOREIGN_PAGE_H__
+
+#define PG_foreign		PG_arch_1
+
+#define PageForeign(page)	test_bit(PG_foreign, &(page)->flags)
+
+#define SetPageForeign(page, dtor) do {		\
+	set_bit(PG_foreign, &(page)->flags);	\
+	(page)->mapping = (void *)dtor;		\
+} while (0)
+
+#define ClearPageForeign(page) do {		\
+	clear_bit(PG_foreign, &(page)->flags);	\
+	(page)->mapping = NULL;			\
+} while (0)
+
+#define PageForeignDestructor(page)	\
+	( (void (*) (struct page *)) (page)->mapping )
+
+#endif /* __ASM_XEN_FOREIGN_PAGE_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/xen/gnttab.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/xen/gnttab.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * gnttab.h
+ * 
+ * Two sets of functionality:
+ * 1. Granting foreign access to our memory reservation.
+ * 2. Accessing others' memory reservations via grant references.
+ * (i.e., mechanisms for both sender and recipient of grant references)
+ * 
+ * Copyright (c) 2004, K A Fraser
+ * Copyright (c) 2005, Christopher Clark
+ */
+
+#ifndef __ASM_GNTTAB_H__
+#define __ASM_GNTTAB_H__
+
+#include <linux/config.h>
+#include <xen/hypervisor.h>
+#include <xen/grant_table.h>
+
+/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
+#define NR_GRANT_FRAMES 4
+#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
+
+int
+gnttab_grant_foreign_access(
+    domid_t domid, unsigned long frame, int readonly);
+
+void
+gnttab_end_foreign_access(
+    grant_ref_t ref, int readonly);
+
+int
+gnttab_grant_foreign_transfer(
+    domid_t domid, unsigned long pfn);
+
+unsigned long
+gnttab_end_foreign_transfer(
+    grant_ref_t ref);
+
+int
+gnttab_query_foreign_access( 
+    grant_ref_t ref );
+
+/*
+ * operations on reserved batches of grant references
+ */
+int
+gnttab_alloc_grant_references(
+    u16 count, grant_ref_t *pprivate_head, grant_ref_t *private_terminal );
+
+void
+gnttab_free_grant_references(
+    u16 count, grant_ref_t private_head );
+
+int
+gnttab_claim_grant_reference( grant_ref_t *pprivate_head, grant_ref_t terminal
+);
+
+void
+gnttab_release_grant_reference(
+    grant_ref_t *private_head, grant_ref_t release );
+
+void
+gnttab_grant_foreign_access_ref(
+    grant_ref_t ref, domid_t domid, unsigned long frame, int readonly);
+
+void
+gnttab_grant_foreign_transfer_ref(
+    grant_ref_t, domid_t domid, unsigned long pfn);
+
+
+#endif /* __ASM_GNTTAB_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/xen/hypervisor.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/xen/hypervisor.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,199 @@
+/******************************************************************************
+ * hypervisor.h
+ * 
+ * Linux-specific hypervisor handling.
+ * 
+ * Copyright (c) 2002-2004, K A Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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 __HYPERVISOR_H__
+#define __HYPERVISOR_H__
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <xen/xen.h>
+#include <xen/dom0_ops.h>
+#include <xen/io/domain_controller.h>
+#include <asm/ptrace.h>
+#include <asm/page.h>
+#if defined(__i386__)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#  ifdef CONFIG_X86_PAE
+#   include <asm-generic/pgtable-nopud.h>
+#  else
+#   include <asm-generic/pgtable-nopmd.h>
+#  endif
+# else
+#  define pud_t pgd_t
+# endif
+#endif
+
+/* arch/xen/i386/kernel/setup.c */
+union xen_start_info_union
+{
+    start_info_t xen_start_info;
+    char padding[2048];
+};
+extern union xen_start_info_union xen_start_info_union;
+#define xen_start_info (xen_start_info_union.xen_start_info)
+
+/* arch/xen/kernel/evtchn.c */
+/* Force a proper event-channel callback from Xen. */
+void force_evtchn_callback(void);
+
+/* arch/xen/kernel/process.c */
+void xen_cpu_idle (void);
+
+/* arch/xen/i386/kernel/hypervisor.c */
+void do_hypervisor_callback(struct pt_regs *regs);
+
+/* arch/xen/i386/kernel/head.S */
+void lgdt_finish(void);
+
+/* arch/xen/i386/mm/hypervisor.c */
+/*
+ * NB. ptr values should be PHYSICAL, not MACHINE. 'vals' should be already
+ * be MACHINE addresses.
+ */
+
+void xen_pt_switch(unsigned long ptr);
+void xen_new_user_pt(unsigned long ptr); /* x86_64 only */
+void xen_load_gs(unsigned int selector); /* x86_64 only */
+void xen_tlb_flush(void);
+void xen_invlpg(unsigned long ptr);
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+void xen_l1_entry_update(pte_t *ptr, pte_t val);
+void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
+void xen_l3_entry_update(pud_t *ptr, pud_t val); /* x86_64/PAE */
+void xen_l4_entry_update(pgd_t *ptr, pgd_t val); /* x86_64 only */
+void xen_pgd_pin(unsigned long ptr);
+void xen_pgd_unpin(unsigned long ptr);
+void xen_pud_pin(unsigned long ptr); /* x86_64 only */
+void xen_pud_unpin(unsigned long ptr); /* x86_64 only */
+void xen_pmd_pin(unsigned long ptr); /* x86_64 only */
+void xen_pmd_unpin(unsigned long ptr); /* x86_64 only */
+void xen_pte_pin(unsigned long ptr);
+void xen_pte_unpin(unsigned long ptr);
+#else
+#define xen_l1_entry_update(_p, _v) set_pte((_p), (_v))
+#define xen_l2_entry_update(_p, _v) set_pgd((_p), (_v))
+#define xen_pgd_pin(_p)   ((void)0)
+#define xen_pgd_unpin(_p) ((void)0)
+#define xen_pte_pin(_p)   ((void)0)
+#define xen_pte_unpin(_p) ((void)0)
+#endif
+
+void xen_set_ldt(unsigned long ptr, unsigned long bytes);
+void xen_machphys_update(unsigned long mfn, unsigned long pfn);
+
+#ifdef CONFIG_SMP
+#include <linux/cpumask.h>
+void xen_tlb_flush_all(void);
+void xen_invlpg_all(unsigned long ptr);
+void xen_tlb_flush_mask(cpumask_t *mask);
+void xen_invlpg_mask(cpumask_t *mask, unsigned long ptr);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+/* 
+** XXX SMH: 2.4 doesn't have percpu.h (or support SMP guests) so just 
+** include sufficient #defines to allow the below to build. 
+*/
+#define DEFINE_PER_CPU(type, name) \
+    __typeof__(type) per_cpu__##name
+
+#define per_cpu(var, cpu)           (*((void)cpu, &per_cpu__##var))
+#define __get_cpu_var(var)          per_cpu__##var
+#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
+
+#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
+#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
+#endif /* linux < 2.6.0 */
+
+void xen_contig_memory(unsigned long vstart, unsigned int order);
+
+#ifdef CONFIG_XEN_PHYSDEV_ACCESS
+/* Allocate a contiguous empty region of low memory. Return virtual start. */
+unsigned long allocate_empty_lowmem_region(unsigned long pages);
+#endif
+
+#include <asm/hypercall.h>
+
+#if defined(CONFIG_X86_64)
+#define MULTI_UVMFLAGS_INDEX 2
+#define MULTI_UVMDOMID_INDEX 3
+#else
+#define MULTI_UVMFLAGS_INDEX 3
+#define MULTI_UVMDOMID_INDEX 4
+#endif
+
+static inline void
+MULTI_update_va_mapping(
+    multicall_entry_t *mcl, unsigned long va,
+    pte_t new_val, unsigned long flags)
+{
+    mcl->op = __HYPERVISOR_update_va_mapping;
+    mcl->args[0] = va;
+#if defined(CONFIG_X86_64)
+    mcl->args[1] = new_val.pte;
+    mcl->args[2] = flags;
+#elif defined(CONFIG_X86_PAE)
+    mcl->args[1] = new_val.pte_low;
+    mcl->args[2] = new_val.pte_high;
+    mcl->args[3] = flags;
+#else
+    mcl->args[1] = new_val.pte_low;
+    mcl->args[2] = 0;
+    mcl->args[3] = flags;
+#endif
+}
+
+static inline void
+MULTI_update_va_mapping_otherdomain(
+    multicall_entry_t *mcl, unsigned long va,
+    pte_t new_val, unsigned long flags, domid_t domid)
+{
+    mcl->op = __HYPERVISOR_update_va_mapping_otherdomain;
+    mcl->args[0] = va;
+#if defined(CONFIG_X86_64)
+    mcl->args[1] = new_val.pte;
+    mcl->args[2] = flags;
+    mcl->args[3] = domid;
+#elif defined(CONFIG_X86_PAE)
+    mcl->args[1] = new_val.pte_low;
+    mcl->args[2] = new_val.pte_high;
+    mcl->args[3] = flags;
+    mcl->args[4] = domid;
+#else
+    mcl->args[1] = new_val.pte_low;
+    mcl->args[2] = 0;
+    mcl->args[3] = flags;
+    mcl->args[4] = domid;
+#endif
+}
+
+#endif /* __HYPERVISOR_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/xen/queues.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/xen/queues.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,81 @@
+
+/*
+ * Oh dear. Task queues were removed from Linux 2.6 and replaced by work 
+ * queues. Unfortunately the semantics is not the same. With task queues we 
+ * can defer work until a particular event occurs -- this is not
+ * straightforwardly done with work queues (queued work is performed asap, or
+ * after some fixed timeout). Conversely, work queues are a (slightly) neater
+ * way of deferring work to a process context than using task queues in 2.4.
+ * 
+ * This is a bit of a needless reimplementation -- should have just pulled
+ * the code from 2.4, but I tried leveraging work queues to simplify things.
+ * They didn't help. :-(
+ */
+
+#ifndef __QUEUES_H__
+#define __QUEUES_H__
+
+#include <linux/version.h>
+#include <linux/list.h>
+#include <linux/workqueue.h>
+
+struct tq_struct { 
+    void (*fn)(void *);
+    void *arg;
+    struct list_head list;
+    unsigned long pending;
+};
+#define INIT_TQUEUE(_name, _fn, _arg)               \
+    do {                                            \
+        INIT_LIST_HEAD(&(_name)->list);             \
+        (_name)->pending = 0;                       \
+        (_name)->fn = (_fn); (_name)->arg = (_arg); \
+    } while ( 0 )
+#define DECLARE_TQUEUE(_name, _fn, _arg)            \
+    struct tq_struct _name = { (_fn), (_arg), LIST_HEAD_INIT((_name).list), 0 }
+
+typedef struct {
+    struct list_head list;
+    spinlock_t       lock;
+} task_queue;
+#define DECLARE_TASK_QUEUE(_name) \
+    task_queue _name = { LIST_HEAD_INIT((_name).list), SPIN_LOCK_UNLOCKED }
+
+static inline int queue_task(struct tq_struct *tqe, task_queue *tql)
+{
+    unsigned long flags;
+    if ( test_and_set_bit(0, &tqe->pending) )
+        return 0;
+    spin_lock_irqsave(&tql->lock, flags);
+    list_add_tail(&tqe->list, &tql->list);
+    spin_unlock_irqrestore(&tql->lock, flags);
+    return 1;
+}
+
+static inline void run_task_queue(task_queue *tql)
+{
+    struct list_head head, *ent;
+    struct tq_struct *tqe;
+    unsigned long flags;
+    void (*fn)(void *);
+    void *arg;
+
+    spin_lock_irqsave(&tql->lock, flags);
+    list_add(&head, &tql->list);
+    list_del_init(&tql->list);
+    spin_unlock_irqrestore(&tql->lock, flags);
+
+    while ( !list_empty(&head) )
+    {
+        ent = head.next;
+        list_del_init(ent);
+        tqe = list_entry(ent, struct tq_struct, list);
+        fn  = tqe->fn;
+        arg = tqe->arg;
+        wmb();
+        tqe->pending = 0;
+        fn(arg);
+    }
+}
+
+#endif /* __QUEUES_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/xen/synch_bitops.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/xen/synch_bitops.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,2 @@
+
+#include <asm-i386/synch_bitops.h>
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/xen/xen_proc.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/xen/xen_proc.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,13 @@
+
+#ifndef __ASM_XEN_PROC_H__
+#define __ASM_XEN_PROC_H__
+
+#include <linux/config.h>
+#include <linux/proc_fs.h>
+
+extern struct proc_dir_entry *create_xen_proc_entry(
+    const char *name, mode_t mode);
+extern void remove_xen_proc_entry(
+    const char *name);
+
+#endif /* __ASM_XEN_PROC_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/xen/xenbus.h
--- /dev/null	Fri Aug  5 15:11:46 2005
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Fri Aug  5 12:04:35 2005
@@ -0,0 +1,127 @@
+#ifndef _ASM_XEN_XENBUS_H
+#define _ASM_XEN_XENBUS_H
+/******************************************************************************
+ * xenbus.h
+ *
+ * Talks to Xen Store to figure out what devices we have.
+ *
+ * Copyright (C) 2005 Rusty Russell, IBM Corporation
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+#include <linux/device.h>
+#include <linux/notifier.h>
+#include <asm/semaphore.h>
+
+/* A xenbus device. */
+struct xenbus_device {
+	char *devicetype;
+	char *subtype;
+	char *nodename;
+	struct device dev;
+	int has_error;
+	void *data;
+};
+
+static inline struct xenbus_device *to_xenbus_device(struct device *dev)
+{
+	return container_of(dev, struct xenbus_device, dev);
+}
+
+struct xenbus_device_id
+{
+	/* .../device/<device_type>/<identifier> */
+	char devicetype[32]; 	/* General class of device. */
+	char subtype[32];	/* Contents of "subtype" for this device */
+};
+
+/* A xenbus driver. */
+struct xenbus_driver {
+	char *name;
+	struct module *owner;
+	const struct xenbus_device_id *ids;
+	int  (*probe)    (struct xenbus_device * dev,
+			  const struct xenbus_device_id * id);
+	int  (*remove)   (struct xenbus_device * dev);
+	struct device_driver driver;
+};
+
+static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
+{
+	return container_of(drv, struct xenbus_driver, driver);
+}
+
+int xenbus_register_driver(struct xenbus_driver *drv);
+void xenbus_unregister_driver(struct xenbus_driver *drv);
+
+/* Caller must hold this lock to call these functions: it's also held
+ * across watch callbacks. */
+extern struct semaphore xenbus_lock;
+
+char **xenbus_directory(const char *dir, const char *node, unsigned int *num);
+void *xenbus_read(const char *dir, const char *node, unsigned int *len);
+int xenbus_write(const char *dir, const char *node,
+		 const char *string, int createflags);
+int xenbus_mkdir(const char *dir, const char *node);
+int xenbus_exists(const char *dir, const char *node);
+int xenbus_rm(const char *dir, const char *node);
+int xenbus_transaction_start(const char *subtree);
+int xenbus_transaction_end(int abort);
+
+/* Single read and scanf: returns -errno or num scanned if > 0. */
+int xenbus_scanf(const char *dir, const char *node, const char *fmt, ...)
+	__attribute__((format(scanf, 3, 4)));
+
+/* Single printf and write: returns -errno or 0. */
+int xenbus_printf(const char *dir, const char *node, const char *fmt, ...)
+	__attribute__((format(printf, 3, 4)));
+
+/* Generic read function: NULL-terminated triples of name,
+ * sprintf-style type string, and pointer. Returns 0 or errno.*/
+int xenbus_gather(const char *dir, ...);
+
+/* Report a (negative) errno into the store, with explanation. */
+void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt,...);
+
+/* Clear any error. */
+void xenbus_dev_ok(struct xenbus_device *dev);
+
+/* Register callback to watch this node. */
+struct xenbus_watch
+{
+	struct list_head list;
+	char *node;
+	void (*callback)(struct xenbus_watch *, const char *node);
+};
+
+/* notifer routines for when the xenstore comes up */
+int register_xenstore_notifier(struct notifier_block *nb);
+void unregister_xenstore_notifier(struct notifier_block *nb);
+
+int register_xenbus_watch(struct xenbus_watch *watch);
+void unregister_xenbus_watch(struct xenbus_watch *watch);
+
+/* Called from xen core code. */
+void xenbus_suspend(void);
+void xenbus_resume(void);
+
+#endif /* _ASM_XEN_XENBUS_H */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/balloon.h
--- a/linux-2.6-xen-sparse/include/asm-xen/balloon.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,54 +0,0 @@
-/******************************************************************************
- * balloon.h
- *
- * Xen balloon driver - enables returning/claiming memory to/from Xen.
- *
- * Copyright (c) 2003, B Dragovic
- * Copyright (c) 2003-2004, M Williamson, K Fraser
- * 
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (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 __ASM_BALLOON_H__
-#define __ASM_BALLOON_H__
-
-/*
- * Inform the balloon driver that it should allow some slop for device-driver
- * memory activities.
- */
-extern void balloon_update_driver_allowance(long delta);
-
-/* Give up unmapped pages to the balloon driver. */
-extern void balloon_put_pages(unsigned long *mfn_list, unsigned long nr_mfns);
-
-/*
- * Prevent the balloon driver from changing the memory reservation during
- * a driver critical region.
- */
-extern spinlock_t balloon_lock;
-#define balloon_lock(__flags)   spin_lock_irqsave(&balloon_lock, __flags)
-#define balloon_unlock(__flags) spin_unlock_irqrestore(&balloon_lock, __flags)
-
-/* Init Function - Try to set up our watcher, if not already set. */
-void balloon_init_watcher(void);
-
-#endif /* __ASM_BALLOON_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/ctrl_if.h
--- a/linux-2.6-xen-sparse/include/asm-xen/ctrl_if.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,160 +0,0 @@
-/******************************************************************************
- * ctrl_if.h
- * 
- * Management functions for special interface to the domain controller.
- * 
- * Copyright (c) 2004, K A Fraser
- * 
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (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 __ASM_XEN__CTRL_IF_H__
-#define __ASM_XEN__CTRL_IF_H__
-
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/queues.h>
-
-typedef control_msg_t ctrl_msg_t;
-
-/*
- * Callback function type. Called for asynchronous processing of received
- * request messages, and responses to previously-transmitted request messages.
- * The parameters are (@msg, @id).
- *  @msg: Original request/response message (not a copy). The message can be
- *        modified in-place by the handler (e.g., a response callback can
- *        turn a request message into a response message in place). The message
- *        is no longer accessible after the callback handler returns -- if the
- *        message is required to persist for longer then it must be copied.
- *  @id:  (Response callbacks only) The 'id' that was specified when the
- *        original request message was queued for transmission.
- */
-typedef void (*ctrl_msg_handler_t)(ctrl_msg_t *, unsigned long);
-
-/*
- * Send @msg to the domain controller. Execute @hnd when a response is
- * received, passing the response message and the specified @id. This
- * operation will not block: it will return -EAGAIN if there is no space.
- * Notes:
- *  1. The @msg is copied if it is transmitted and so can be freed after this
- *     function returns.
- *  2. If @hnd is NULL then no callback is executed.
- */
-int
-ctrl_if_send_message_noblock(
-    ctrl_msg_t *msg, 
-    ctrl_msg_handler_t hnd,
-    unsigned long id);
-
-/*
- * Send @msg to the domain controller. Execute @hnd when a response is
- * received, passing the response message and the specified @id. This
- * operation will block until the message is sent, or a signal is received
- * for the calling process (unless @wait_state is TASK_UNINTERRUPTIBLE).
- * Notes:
- *  1. The @msg is copied if it is transmitted and so can be freed after this
- *     function returns.
- *  2. If @hnd is NULL then no callback is executed.
- */
-int
-ctrl_if_send_message_block(
-    ctrl_msg_t *msg, 
-    ctrl_msg_handler_t hnd, 
-    unsigned long id, 
-    long wait_state);
-
-/*
- * Send @msg to the domain controller. Block until the response is received,
- * and then copy it into the provided buffer, @rmsg.
- */
-int
-ctrl_if_send_message_and_get_response(
-    ctrl_msg_t *msg,
-    ctrl_msg_t *rmsg,
-    long wait_state);
-
-/*
- * Request a callback when there is /possibly/ space to immediately send a
- * message to the domain controller. This function returns 0 if there is
- * already space to trasnmit a message --- in this case the callback task /may/
- * still be executed. If this function returns 1 then the callback /will/ be
- * executed when space becomes available.
- */
-int
-ctrl_if_enqueue_space_callback(
-    struct tq_struct *task);
-
-/*
- * Send a response (@msg) to a message from the domain controller. This will 
- * never block.
- * Notes:
- *  1. The @msg is copied and so can be freed after this function returns.
- *  2. The @msg may be the original request message, modified in-place.
- */
-void
-ctrl_if_send_response(
-    ctrl_msg_t *msg);
-
-/*
- * Register a receiver for typed messages from the domain controller. The 
- * handler (@hnd) is called for every received message of specified @type.
- * Returns TRUE (non-zero) if the handler was successfully registered.
- * If CALLBACK_IN_BLOCKING CONTEXT is specified in @flags then callbacks will
- * occur in a context in which it is safe to yield (i.e., process context).
- */
-#define CALLBACK_IN_BLOCKING_CONTEXT 1
-int ctrl_if_register_receiver(
-    u8 type, 
-    ctrl_msg_handler_t hnd,
-    unsigned int flags);
-
-/*
- * Unregister a receiver for typed messages from the domain controller. The 
- * handler (@hnd) will not be executed after this function returns.
- */
-void
-ctrl_if_unregister_receiver(
-    u8 type, ctrl_msg_handler_t hnd);
-
-/* Suspend/resume notifications. */
-void ctrl_if_suspend(void);
-void ctrl_if_resume(void);
-
-/* Start-of-day setup. */
-void ctrl_if_init(void);
-
-/*
- * Returns TRUE if there are no outstanding message requests at the domain
- * controller. This can be used to ensure that messages have really flushed
- * through when it is not possible to use the response-callback interface.
- * WARNING: If other subsystems are using the control interface then this
- * function might never return TRUE!
- */
-int ctrl_if_transmitter_empty(void);  /* !! DANGEROUS FUNCTION !! */
-
-/*
- * Manually discard response messages from the domain controller. 
- * WARNING: This is usually done automatically -- this function should only
- * be called when normal interrupt mechanisms are disabled!
- */
-void ctrl_if_discard_responses(void); /* !! DANGEROUS FUNCTION !! */
-
-#endif /* __ASM_XEN__CONTROL_IF_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/evtchn.h
--- a/linux-2.6-xen-sparse/include/asm-xen/evtchn.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,135 +0,0 @@
-/******************************************************************************
- * evtchn.h
- * 
- * Communication via Xen event channels.
- * Also definitions for the device that demuxes notifications to userspace.
- * 
- * Copyright (c) 2004, K A Fraser
- * 
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (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 __ASM_EVTCHN_H__
-#define __ASM_EVTCHN_H__
-
-#include <linux/config.h>
-#include <linux/interrupt.h>
-#include <asm-xen/hypervisor.h>
-#include <asm/ptrace.h>
-#include <asm-xen/synch_bitops.h>
-#include <asm-xen/xen-public/event_channel.h>
-#include <linux/smp.h>
-
-/*
- * LOW-LEVEL DEFINITIONS
- */
-
-/* Dynamically bind a VIRQ source to Linux IRQ space. */
-extern int  bind_virq_to_irq(int virq);
-extern void unbind_virq_from_irq(int virq);
-
-/* Dynamically bind an IPI source to Linux IRQ space. */
-extern int  bind_ipi_to_irq(int ipi);
-extern void unbind_ipi_from_irq(int ipi);
-
-/* Dynamically bind an event-channel port to Linux IRQ space. */
-extern int  bind_evtchn_to_irq(unsigned int evtchn);
-extern void unbind_evtchn_from_irq(unsigned int evtchn);
-
-/*
- * Dynamically bind an event-channel port to an IRQ-like callback handler.
- * On some platforms this may not be implemented via the Linux IRQ subsystem.
- * You *cannot* trust the irq argument passed to the callback handler.
- */
-extern int  bind_evtchn_to_irqhandler(
-    unsigned int evtchn,
-    irqreturn_t (*handler)(int, void *, struct pt_regs *),
-    unsigned long irqflags,
-    const char *devname,
-    void *dev_id);
-extern void unbind_evtchn_from_irqhandler(unsigned int evtchn, void *dev_id);
-
-extern void irq_suspend(void);
-extern void irq_resume(void);
-
-/* Entry point for notifications into Linux subsystems. */
-asmlinkage void evtchn_do_upcall(struct pt_regs *regs);
-
-/* Entry point for notifications into the userland character device. */
-void evtchn_device_upcall(int port);
-
-static inline void mask_evtchn(int port)
-{
-    shared_info_t *s = HYPERVISOR_shared_info;
-    synch_set_bit(port, &s->evtchn_mask[0]);
-}
-
-static inline void unmask_evtchn(int port)
-{
-    shared_info_t *s = HYPERVISOR_shared_info;
-    vcpu_info_t *vcpu_info = &s->vcpu_data[smp_processor_id()];
-
-    synch_clear_bit(port, &s->evtchn_mask[0]);
-
-    /*
-     * The following is basically the equivalent of 'hw_resend_irq'. Just like
-     * a real IO-APIC we 'lose the interrupt edge' if the channel is masked.
-     */
-    if (  synch_test_bit        (port,    &s->evtchn_pending[0]) && 
-         !synch_test_and_set_bit(port>>5, &vcpu_info->evtchn_pending_sel) )
-    {
-        vcpu_info->evtchn_upcall_pending = 1;
-        if ( !vcpu_info->evtchn_upcall_mask )
-            force_evtchn_callback();
-    }
-}
-
-static inline void clear_evtchn(int port)
-{
-    shared_info_t *s = HYPERVISOR_shared_info;
-    synch_clear_bit(port, &s->evtchn_pending[0]);
-}
-
-static inline int notify_via_evtchn(int port)
-{
-    evtchn_op_t op;
-    op.cmd = EVTCHNOP_send;
-    op.u.send.local_port = port;
-    return HYPERVISOR_event_channel_op(&op);
-}
-
-/*
- * CHARACTER-DEVICE DEFINITIONS
- */
-
-/* /dev/xen/evtchn resides at device number major=10, minor=201 */
-#define EVTCHN_MINOR 201
-
-/* /dev/xen/evtchn ioctls: */
-/* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */
-#define EVTCHN_RESET  _IO('E', 1)
-/* EVTCHN_BIND: Bind to teh specified event-channel port. */
-#define EVTCHN_BIND   _IO('E', 2)
-/* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
-#define EVTCHN_UNBIND _IO('E', 3)
-
-#endif /* __ASM_EVTCHN_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/foreign_page.h
--- a/linux-2.6-xen-sparse/include/asm-xen/foreign_page.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,30 +0,0 @@
-/******************************************************************************
- * foreign_page.h
- * 
- * Provide a "foreign" page type, that is owned by a foreign allocator and 
- * not the normal buddy allocator in page_alloc.c
- * 
- * Copyright (c) 2004, K A Fraser
- */
-
-#ifndef __ASM_XEN_FOREIGN_PAGE_H__
-#define __ASM_XEN_FOREIGN_PAGE_H__
-
-#define PG_foreign		PG_arch_1
-
-#define PageForeign(page)	test_bit(PG_foreign, &(page)->flags)
-
-#define SetPageForeign(page, dtor) do {		\
-	set_bit(PG_foreign, &(page)->flags);	\
-	(page)->mapping = (void *)dtor;		\
-} while (0)
-
-#define ClearPageForeign(page) do {		\
-	clear_bit(PG_foreign, &(page)->flags);	\
-	(page)->mapping = NULL;			\
-} while (0)
-
-#define PageForeignDestructor(page)	\
-	( (void (*) (struct page *)) (page)->mapping )
-
-#endif /* __ASM_XEN_FOREIGN_PAGE_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/gnttab.h
--- a/linux-2.6-xen-sparse/include/asm-xen/gnttab.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,72 +0,0 @@
-/******************************************************************************
- * gnttab.h
- * 
- * Two sets of functionality:
- * 1. Granting foreign access to our memory reservation.
- * 2. Accessing others' memory reservations via grant references.
- * (i.e., mechanisms for both sender and recipient of grant references)
- * 
- * Copyright (c) 2004, K A Fraser
- * Copyright (c) 2005, Christopher Clark
- */
-
-#ifndef __ASM_GNTTAB_H__
-#define __ASM_GNTTAB_H__
-
-#include <linux/config.h>
-#include <asm-xen/hypervisor.h>
-#include <asm-xen/xen-public/grant_table.h>
-
-/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
-#define NR_GRANT_FRAMES 4
-#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
-
-int
-gnttab_grant_foreign_access(
-    domid_t domid, unsigned long frame, int readonly);
-
-void
-gnttab_end_foreign_access(
-    grant_ref_t ref, int readonly);
-
-int
-gnttab_grant_foreign_transfer(
-    domid_t domid, unsigned long pfn);
-
-unsigned long
-gnttab_end_foreign_transfer(
-    grant_ref_t ref);
-
-int
-gnttab_query_foreign_access( 
-    grant_ref_t ref );
-
-/*
- * operations on reserved batches of grant references
- */
-int
-gnttab_alloc_grant_references(
-    u16 count, grant_ref_t *pprivate_head, grant_ref_t *private_terminal );
-
-void
-gnttab_free_grant_references(
-    u16 count, grant_ref_t private_head );
-
-int
-gnttab_claim_grant_reference( grant_ref_t *pprivate_head, grant_ref_t terminal
-);
-
-void
-gnttab_release_grant_reference(
-    grant_ref_t *private_head, grant_ref_t release );
-
-void
-gnttab_grant_foreign_access_ref(
-    grant_ref_t ref, domid_t domid, unsigned long frame, int readonly);
-
-void
-gnttab_grant_foreign_transfer_ref(
-    grant_ref_t, domid_t domid, unsigned long pfn);
-
-
-#endif /* __ASM_GNTTAB_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-xen/hypervisor.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,199 +0,0 @@
-/******************************************************************************
- * hypervisor.h
- * 
- * Linux-specific hypervisor handling.
- * 
- * Copyright (c) 2002-2004, K A Fraser
- * 
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (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 __HYPERVISOR_H__
-#define __HYPERVISOR_H__
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/version.h>
-#include <asm-xen/xen-public/xen.h>
-#include <asm-xen/xen-public/dom0_ops.h>
-#include <asm-xen/xen-public/io/domain_controller.h>
-#include <asm/ptrace.h>
-#include <asm/page.h>
-#if defined(__i386__)
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#  ifdef CONFIG_X86_PAE
-#   include <asm-generic/pgtable-nopud.h>
-#  else
-#   include <asm-generic/pgtable-nopmd.h>
-#  endif
-# else
-#  define pud_t pgd_t
-# endif
-#endif
-
-/* arch/xen/i386/kernel/setup.c */
-union xen_start_info_union
-{
-    start_info_t xen_start_info;
-    char padding[2048];
-};
-extern union xen_start_info_union xen_start_info_union;
-#define xen_start_info (xen_start_info_union.xen_start_info)
-
-/* arch/xen/kernel/evtchn.c */
-/* Force a proper event-channel callback from Xen. */
-void force_evtchn_callback(void);
-
-/* arch/xen/kernel/process.c */
-void xen_cpu_idle (void);
-
-/* arch/xen/i386/kernel/hypervisor.c */
-void do_hypervisor_callback(struct pt_regs *regs);
-
-/* arch/xen/i386/kernel/head.S */
-void lgdt_finish(void);
-
-/* arch/xen/i386/mm/hypervisor.c */
-/*
- * NB. ptr values should be PHYSICAL, not MACHINE. 'vals' should be already
- * be MACHINE addresses.
- */
-
-void xen_pt_switch(unsigned long ptr);
-void xen_new_user_pt(unsigned long ptr); /* x86_64 only */
-void xen_load_gs(unsigned int selector); /* x86_64 only */
-void xen_tlb_flush(void);
-void xen_invlpg(unsigned long ptr);
-
-#ifndef CONFIG_XEN_SHADOW_MODE
-void xen_l1_entry_update(pte_t *ptr, pte_t val);
-void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
-void xen_l3_entry_update(pud_t *ptr, pud_t val); /* x86_64/PAE */
-void xen_l4_entry_update(pgd_t *ptr, pgd_t val); /* x86_64 only */
-void xen_pgd_pin(unsigned long ptr);
-void xen_pgd_unpin(unsigned long ptr);
-void xen_pud_pin(unsigned long ptr); /* x86_64 only */
-void xen_pud_unpin(unsigned long ptr); /* x86_64 only */
-void xen_pmd_pin(unsigned long ptr); /* x86_64 only */
-void xen_pmd_unpin(unsigned long ptr); /* x86_64 only */
-void xen_pte_pin(unsigned long ptr);
-void xen_pte_unpin(unsigned long ptr);
-#else
-#define xen_l1_entry_update(_p, _v) set_pte((_p), (_v))
-#define xen_l2_entry_update(_p, _v) set_pgd((_p), (_v))
-#define xen_pgd_pin(_p)   ((void)0)
-#define xen_pgd_unpin(_p) ((void)0)
-#define xen_pte_pin(_p)   ((void)0)
-#define xen_pte_unpin(_p) ((void)0)
-#endif
-
-void xen_set_ldt(unsigned long ptr, unsigned long bytes);
-void xen_machphys_update(unsigned long mfn, unsigned long pfn);
-
-#ifdef CONFIG_SMP
-#include <linux/cpumask.h>
-void xen_tlb_flush_all(void);
-void xen_invlpg_all(unsigned long ptr);
-void xen_tlb_flush_mask(cpumask_t *mask);
-void xen_invlpg_mask(cpumask_t *mask, unsigned long ptr);
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-/* 
-** XXX SMH: 2.4 doesn't have percpu.h (or support SMP guests) so just 
-** include sufficient #defines to allow the below to build. 
-*/
-#define DEFINE_PER_CPU(type, name) \
-    __typeof__(type) per_cpu__##name
-
-#define per_cpu(var, cpu)           (*((void)cpu, &per_cpu__##var))
-#define __get_cpu_var(var)          per_cpu__##var
-#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
-
-#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
-#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
-#endif /* linux < 2.6.0 */
-
-void xen_contig_memory(unsigned long vstart, unsigned int order);
-
-#ifdef CONFIG_XEN_PHYSDEV_ACCESS
-/* Allocate a contiguous empty region of low memory. Return virtual start. */
-unsigned long allocate_empty_lowmem_region(unsigned long pages);
-#endif
-
-#include <asm/hypercall.h>
-
-#if defined(CONFIG_X86_64)
-#define MULTI_UVMFLAGS_INDEX 2
-#define MULTI_UVMDOMID_INDEX 3
-#else
-#define MULTI_UVMFLAGS_INDEX 3
-#define MULTI_UVMDOMID_INDEX 4
-#endif
-
-static inline void
-MULTI_update_va_mapping(
-    multicall_entry_t *mcl, unsigned long va,
-    pte_t new_val, unsigned long flags)
-{
-    mcl->op = __HYPERVISOR_update_va_mapping;
-    mcl->args[0] = va;
-#if defined(CONFIG_X86_64)
-    mcl->args[1] = new_val.pte;
-    mcl->args[2] = flags;
-#elif defined(CONFIG_X86_PAE)
-    mcl->args[1] = new_val.pte_low;
-    mcl->args[2] = new_val.pte_high;
-    mcl->args[3] = flags;
-#else
-    mcl->args[1] = new_val.pte_low;
-    mcl->args[2] = 0;
-    mcl->args[3] = flags;
-#endif
-}
-
-static inline void
-MULTI_update_va_mapping_otherdomain(
-    multicall_entry_t *mcl, unsigned long va,
-    pte_t new_val, unsigned long flags, domid_t domid)
-{
-    mcl->op = __HYPERVISOR_update_va_mapping_otherdomain;
-    mcl->args[0] = va;
-#if defined(CONFIG_X86_64)
-    mcl->args[1] = new_val.pte;
-    mcl->args[2] = flags;
-    mcl->args[3] = domid;
-#elif defined(CONFIG_X86_PAE)
-    mcl->args[1] = new_val.pte_low;
-    mcl->args[2] = new_val.pte_high;
-    mcl->args[3] = flags;
-    mcl->args[4] = domid;
-#else
-    mcl->args[1] = new_val.pte_low;
-    mcl->args[2] = 0;
-    mcl->args[3] = flags;
-    mcl->args[4] = domid;
-#endif
-}
-
-#endif /* __HYPERVISOR_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/linux-public/privcmd.h
--- a/linux-2.6-xen-sparse/include/asm-xen/linux-public/privcmd.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,90 +0,0 @@
-/******************************************************************************
- * privcmd.h
- * 
- * Interface to /proc/xen/privcmd.
- * 
- * Copyright (c) 2003-2004, K A Fraser
- * 
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (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 __PRIVCMD_H__
-#define __PRIVCMD_H__
-
-typedef struct privcmd_hypercall
-{
-    unsigned long op;
-    unsigned long arg[5];
-} privcmd_hypercall_t;
-
-typedef struct privcmd_mmap_entry {
-    unsigned long va;
-    unsigned long mfn;
-    unsigned long npages;
-} privcmd_mmap_entry_t; 
-
-typedef struct privcmd_mmap {
-    int num;
-    domid_t dom; /* target domain */
-    privcmd_mmap_entry_t *entry;
-} privcmd_mmap_t; 
-
-typedef struct privcmd_mmapbatch {
-    int num;     /* number of pages to populate */
-    domid_t dom; /* target domain */
-    unsigned long addr;  /* virtual address */
-    unsigned long *arr; /* array of mfns - top nibble set on err */
-} privcmd_mmapbatch_t; 
-
-typedef struct privcmd_blkmsg
-{
-    unsigned long op;
-    void         *buf;
-    int           buf_size;
-} privcmd_blkmsg_t;
-
-/*
- * @cmd: IOCTL_PRIVCMD_HYPERCALL
- * @arg: &privcmd_hypercall_t
- * Return: Value returned from execution of the specified hypercall.
- */
-#define IOCTL_PRIVCMD_HYPERCALL         \
-    _IOC(_IOC_NONE, 'P', 0, sizeof(privcmd_hypercall_t))
-
-/*
- * @cmd: IOCTL_PRIVCMD_INITDOMAIN_EVTCHN
- * @arg: n/a
- * Return: Port associated with domain-controller end of control event channel
- *         for the initial domain.
- */
-#define IOCTL_PRIVCMD_INITDOMAIN_EVTCHN \
-    _IOC(_IOC_NONE, 'P', 1, 0)
-#define IOCTL_PRIVCMD_MMAP             \
-    _IOC(_IOC_NONE, 'P', 2, sizeof(privcmd_mmap_t))
-#define IOCTL_PRIVCMD_MMAPBATCH             \
-    _IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t))
-#define IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN \
-    _IOC(_IOC_READ, 'P', 4, sizeof(unsigned long))
-#define IOCTL_PRIVCMD_INITDOMAIN_STORE \
-    _IOC(_IOC_READ, 'P', 5, 0)
-
-#endif /* __PRIVCMD_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/linux-public/suspend.h
--- a/linux-2.6-xen-sparse/include/asm-xen/linux-public/suspend.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,43 +0,0 @@
-/******************************************************************************
- * suspend.h
- * 
- * Copyright (c) 2003-2004, K A Fraser
- * 
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (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 __ASM_XEN_SUSPEND_H__
-#define __ASM_XEN_SUSPEND_H__
-
-typedef struct suspend_record_st {
-    /* To be filled in before resume. */
-    start_info_t resume_info;
-    /*
-     * The number of a machine frame containing, in sequence, the number of
-     * each machine frame that contains PFN -> MFN translation table data.
-     */
-    unsigned long pfn_to_mfn_frame_list;
-    /* Number of entries in the PFN -> MFN translation table. */
-    unsigned long nr_pfns;
-} suspend_record_t;
-
-#endif /* __ASM_XEN_SUSPEND_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/queues.h
--- a/linux-2.6-xen-sparse/include/asm-xen/queues.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,81 +0,0 @@
-
-/*
- * Oh dear. Task queues were removed from Linux 2.6 and replaced by work 
- * queues. Unfortunately the semantics is not the same. With task queues we 
- * can defer work until a particular event occurs -- this is not
- * straightforwardly done with work queues (queued work is performed asap, or
- * after some fixed timeout). Conversely, work queues are a (slightly) neater
- * way of deferring work to a process context than using task queues in 2.4.
- * 
- * This is a bit of a needless reimplementation -- should have just pulled
- * the code from 2.4, but I tried leveraging work queues to simplify things.
- * They didn't help. :-(
- */
-
-#ifndef __QUEUES_H__
-#define __QUEUES_H__
-
-#include <linux/version.h>
-#include <linux/list.h>
-#include <linux/workqueue.h>
-
-struct tq_struct { 
-    void (*fn)(void *);
-    void *arg;
-    struct list_head list;
-    unsigned long pending;
-};
-#define INIT_TQUEUE(_name, _fn, _arg)               \
-    do {                                            \
-        INIT_LIST_HEAD(&(_name)->list);             \
-        (_name)->pending = 0;                       \
-        (_name)->fn = (_fn); (_name)->arg = (_arg); \
-    } while ( 0 )
-#define DECLARE_TQUEUE(_name, _fn, _arg)            \
-    struct tq_struct _name = { (_fn), (_arg), LIST_HEAD_INIT((_name).list), 0 }
-
-typedef struct {
-    struct list_head list;
-    spinlock_t       lock;
-} task_queue;
-#define DECLARE_TASK_QUEUE(_name) \
-    task_queue _name = { LIST_HEAD_INIT((_name).list), SPIN_LOCK_UNLOCKED }
-
-static inline int queue_task(struct tq_struct *tqe, task_queue *tql)
-{
-    unsigned long flags;
-    if ( test_and_set_bit(0, &tqe->pending) )
-        return 0;
-    spin_lock_irqsave(&tql->lock, flags);
-    list_add_tail(&tqe->list, &tql->list);
-    spin_unlock_irqrestore(&tql->lock, flags);
-    return 1;
-}
-
-static inline void run_task_queue(task_queue *tql)
-{
-    struct list_head head, *ent;
-    struct tq_struct *tqe;
-    unsigned long flags;
-    void (*fn)(void *);
-    void *arg;
-
-    spin_lock_irqsave(&tql->lock, flags);
-    list_add(&head, &tql->list);
-    list_del_init(&tql->list);
-    spin_unlock_irqrestore(&tql->lock, flags);
-
-    while ( !list_empty(&head) )
-    {
-        ent = head.next;
-        list_del_init(ent);
-        tqe = list_entry(ent, struct tq_struct, list);
-        fn  = tqe->fn;
-        arg = tqe->arg;
-        wmb();
-        tqe->pending = 0;
-        fn(arg);
-    }
-}
-
-#endif /* __QUEUES_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/synch_bitops.h
--- a/linux-2.6-xen-sparse/include/asm-xen/synch_bitops.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,2 +0,0 @@
-
-#include <asm-i386/synch_bitops.h>
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/xen_proc.h
--- a/linux-2.6-xen-sparse/include/asm-xen/xen_proc.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,13 +0,0 @@
-
-#ifndef __ASM_XEN_PROC_H__
-#define __ASM_XEN_PROC_H__
-
-#include <linux/config.h>
-#include <linux/proc_fs.h>
-
-extern struct proc_dir_entry *create_xen_proc_entry(
-    const char *name, mode_t mode);
-extern void remove_xen_proc_entry(
-    const char *name);
-
-#endif /* __ASM_XEN_PROC_H__ */
diff -r 69b7c9c3a9fd linux-2.6-xen-sparse/include/asm-xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Fri Aug  5 15:11:46 2005
+++ /dev/null	Fri Aug  5 12:04:35 2005
@@ -1,127 +0,0 @@
-#ifndef _ASM_XEN_XENBUS_H
-#define _ASM_XEN_XENBUS_H
-/******************************************************************************
- * xenbus.h
- *
- * Talks to Xen Store to figure out what devices we have.
- *
- * Copyright (C) 2005 Rusty Russell, IBM Corporation
- * 
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (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.
- */
-#include <linux/device.h>
-#include <linux/notifier.h>
-#include <asm/semaphore.h>
-
-/* A xenbus device. */
-struct xenbus_device {
-	char *devicetype;
-	char *subtype;
-	char *nodename;
-	struct device dev;
-	int has_error;
-	void *data;
-};
-
-static inline struct xenbus_device *to_xenbus_device(struct device *dev)
-{
-	return container_of(dev, struct xenbus_device, dev);
-}
-
-struct xenbus_device_id
-{
-	/* .../device/<device_type>/<identifier> */
-	char devicetype[32]; 	/* General class of device. */
-	char subtype[32];	/* Contents of "subtype" for this device */
-};
-
-/* A xenbus driver. */
-struct xenbus_driver {
-	char *name;
-	struct module *owner;
-	const struct xenbus_device_id *ids;
-	int  (*probe)    (struct xenbus_device * dev,
-			  const struct xenbus_device_id * id);
-	int  (*remove)   (struct xenbus_device * dev);
-	struct device_driver driver;
-};
-
-static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
-{
-	return container_of(drv, struct xenbus_driver, driver);
-}
-
-int xenbus_register_driver(struct xenbus_driver *drv);
-void xenbus_unregister_driver(struct xenbus_driver *drv);
-
-/* Caller must hold this lock to call these functions: it's also held
- * across watch callbacks. */
-extern struct semaphore xenbus_lock;
-
-char **xenbus_directory(const char *dir, const char *node, unsigned int *num);
-void *xenbus_read(const char *dir, const char *node, unsigned int *len);
-int xenbus_write(const char *dir, const char *node,
-		 const char *string, int createflags);
-int xenbus_mkdir(const char *dir, const char *node);
-int xenbus_exists(const char *dir, const char *node);
-int xenbus_rm(const char *dir, const char *node);
-int xenbus_transaction_start(const char *subtree);
-int xenbus_transaction_end(int abort);
-
-/* Single read and scanf: returns -errno or num scanned if > 0. */
-int xenbus_scanf(const char *dir, const char *node, const char *fmt, ...)
-	__attribute__((format(scanf, 3, 4)));
-
-/* Single printf and write: returns -errno or 0. */
-int xenbus_printf(const char *dir, const char *node, const char *fmt, ...)
-	__attribute__((format(printf, 3, 4)));
-
-/* Generic read function: NULL-terminated triples of name,
- * sprintf-style type string, and pointer. Returns 0 or errno.*/
-int xenbus_gather(const char *dir, ...);
-
-/* Report a (negative) errno into the store, with explanation. */
-void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt,...);
-
-/* Clear any error. */
-void xenbus_dev_ok(struct xenbus_device *dev);
-
-/* Register callback to watch this node. */
-struct xenbus_watch
-{
-	struct list_head list;
-	char *node;
-	void (*callback)(struct xenbus_watch *, const char *node);
-};
-
-/* notifer routines for when the xenstore comes up */
-int register_xenstore_notifier(struct notifier_block *nb);
-void unregister_xenstore_notifier(struct notifier_block *nb);
-
-int register_xenbus_watch(struct xenbus_watch *watch);
-void unregister_xenbus_watch(struct xenbus_watch *watch);
-
-/* Called from xen core code. */
-void xenbus_suspend(void);
-void xenbus_resume(void);
-
-#endif /* _ASM_XEN_XENBUS_H */
> 
> Thanks,
> Dan
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

-- 
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net

^ permalink raw reply	[relevance 24%]

* [PATCH][VT][4/4] Changing phys_to_machine_mapping[] is not implemented on VMX domains
@ 2005-08-11 22:00  7% Arun Sharma
  0 siblings, 0 replies; 200+ results
From: Arun Sharma @ 2005-08-11 22:00 UTC (permalink / raw)
  To: Ian Pratt, Keir Fraser; +Cc: xen-devel

Changing phys_to_machine_mapping[] is not implemented on VMX domains

Make it CONFIG_XEN only for now.

Signed-off-by: Arun Sharma <arun.sharma@intel.com>

--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Aug 10 23:09:53 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Aug 10 16:59:36 2005
@@ -49,6 +49,7 @@
 #include <asm/uaccess.h>
 #include <asm-xen/evtchn.h>
 #include <asm-xen/ctrl_if.h>
+#include <asm-xen/xen-public/grant_table.h>
 #include <asm-xen/xen-public/io/netif.h>
 #include <asm-xen/balloon.h>
 #include <asm/page.h>
@@ -444,9 +445,11 @@
 #endif
         rx_pfn_array[i] = virt_to_machine(skb->head) >> PAGE_SHIFT;
 
+#ifdef CONFIG_XEN
 	/* Remove this page from pseudo phys map before passing back to Xen. */
 	phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
 	    = INVALID_P2M_ENTRY;
+#endif
 
 	MULTI_update_va_mapping(rx_mcl+i, (unsigned long)skb->head,
 				__pte(0), 0);
@@ -678,12 +681,15 @@
 #endif
         mcl++;
 
+#ifdef CONFIG_XEN
         phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = 
 #ifdef CONFIG_XEN_NETDEV_GRANT_RX
             mfn;
 #else
             rx->addr >> PAGE_SHIFT;
 #endif
+#endif
+
 #ifdef GRANT_DEBUG
         printk(KERN_ALERT "#### rx_poll     enqueue vdata=%08x mfn=%08x ref=%04x\n",
                skb->data, mfn, ref);

^ permalink raw reply	[relevance 7%]

* Re: Re: [Xen-changelog] fail domU creation if memory need couldn't be succeed after ballooning out dom0
  @ 2005-08-18 15:51  5% ` Anthony Liguori
  0 siblings, 0 replies; 200+ results
From: Anthony Liguori @ 2005-08-18 15:51 UTC (permalink / raw)
  To: Ian Pratt; +Cc: xen-devel

Ian Pratt wrote:

>>In general, we should try to avoid using timeouts at all 
>>cost.  If we do have to use a timeout, then we should make 
>>sure it's long enough that the timeout is never going to 
>>happen.  It's surprisingly easy to have enough load on your 
>>system such you miss a 2 second timeout.
>>    
>>
>
>Yep, in general I'm all for making timeouts long enough to be visible.
>
>However, this timeout is different: its something we expect may fail (as
>opposed to an internal failure of the tools).
>
Is it really possible to fail?  I just did:

echo 42 > /proc/xen/balloon

On domain-0 and the system crashed.  It would be nice if it actually 
failed but currently the only thing this timeout will do is prevent us 
from working when we could have :-)

How about when we fix the balloon driver, we have it write a node in the 
store that indicates whether the balloon has succeeded or failed and 
then the tools can simply set a watch and wait for something to happen?

Regards,

Anthony Liguori

> We're asking domain 0 to
>try and shrink itself. It may be unable to, in which case trying for a
>few seconds and then failing the domain create seems like a good
>approach. If domain 0 can't page enough stuff out after a second or two,
>its unlikely to succeed without operator intervention (e.g. killing
>something).
>
>2s is perhaps overly short, but I doubt going larger than 5s would
>result in any greater chance of success, and would just anoy users.
>
>Ian
>
>  
>

^ permalink raw reply	[relevance 5%]

* RE: Re: [Xen-changelog] fail domU creation if memory need couldn't be succeed after ballooning out dom0
@ 2005-08-18 16:03  6% Ian Pratt
  0 siblings, 0 replies; 200+ results
From: Ian Pratt @ 2005-08-18 16:03 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: xen-devel

> >However, this timeout is different: its something we expect 
> may fail (as
> >opposed to an internal failure of the tools).
> >
> Is it really possible to fail?  I just did:
> 
> echo 42 > /proc/xen/balloon

Right now, its not, but we can't leave it that way.

The balloon driver is supposed to be hooked into the low memory path
(way before oomkiller runs) so that the domain can try requesting more
memory to avoid crashing.
 
> How about when we fix the balloon driver, we have it write a 
> node in the 
> store that indicates whether the balloon has succeeded or failed and 
> then the tools can simply set a watch and wait for something 
> to happen?

There's not really a concept of the balloon driver failing. It just has
a memory target which its trying to hit, and will potentially fluctuate
around it.

I'm quite happy with the timeout. When we're creating a domain we don't
really care whether the ballon succeeds in hitting its target or not,
just whether there's enough free memory on the domain heap to start the
domain. An entirely different domain could have just exited freeing up
memory.

We should rename /proc/xen/balloon to /proc/sys/xen/mem_target (or
something).

Ian

^ permalink raw reply	[relevance 6%]

* [PATCH] Unallocate function for memory regions created by allocate_empty_lowmem_region
@ 2005-08-22 10:09 16% Ross C Mcilroy
  0 siblings, 0 replies; 200+ results
From: Ross C Mcilroy @ 2005-08-22 10:09 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 4646 bytes --]

Hi,

This patch provides a function which allows a domain to reclaim memory used by the allocate_empty_lowmem_region.  It should allow a module to reclaim any memory which was released to Xen for foreign grant table access.


Thanks 

Ross 



# HG changeset patch
# User rcmcilro@localhost.localdomain
# Node ID a05f92511a995c6ad48e5d508260edc756d4f327
# Parent  7c05931c1d0b82babd600b7e3e712fc06b899ed9
Functions to allow unallocation of memory regions created by allocate_empty_lowmem_region

Signed-of-by: Ross McIlroy <mcilrorc@dcs.gla.ac.uk>

diff -r 7c05931c1d0b -r a05f92511a99 linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c        Thu Aug 18 13:26:50 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c        Mon Aug 22 09:50:48 2005
@@ -452,7 +452,50 @@
        return vstart;
 }

+int unallocate_empty_lowmem_region(unsigned long vstart,
+                                   unsigned long pages)
+{
+       unsigned long *pfn_array;
+       unsigned long  i;
+       unsigned int   order = get_order(pages*PAGE_SIZE);
+       int err;
+
+       if (vstart == 0)
+               return -EINVAL;
+
+       pfn_array = vmalloc((1<<order) * sizeof(*pfn_array));
+       BUG_ON(pfn_array == NULL);
+
+       if (err = balloon_get_pages(pfn_array, 1 << order)) {
+               vfree(pfn_array);
+               return err;
+       }
+
+       for (i = 0; i < (1<<order); i++) {
+#ifdef CONFIG_X86_64
+               xen_l1_entry_update(pfn_array[i],
+                                   (__pa(vstart)>>PAGE_SHIFT)+i);
+#else
+               BUG_ON(HYPERVISOR_update_va_mapping(vstart + (i*PAGE_SIZE),
+                      __pte_ma((pfn_array[i]<<PAGE_SHIFT)|__PAGE_KERNEL), 0));
+#endif
+               xen_machphys_update(pfn_array[i],
+                                   (__pa(vstart)>>PAGE_SHIFT)+i);
+               phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
+                       pfn_array[i];
+       }
+
+       flush_tlb_all();
+
+       vfree(pfn_array);
+
+       free_pages(vstart, order);
+
+       return 0;
+}
+
 EXPORT_SYMBOL(allocate_empty_lowmem_region);
+EXPORT_SYMBOL(unallocate_empty_lowmem_region);

 /*
  * Local variables:
diff -r 7c05931c1d0b -r a05f92511a99 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Thu Aug 18 13:26:50 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Mon Aug 22 09:50:48 2005
@@ -467,5 +467,23 @@
     schedule_work(&balloon_worker);
 }

+int balloon_get_pages(unsigned long *mfn_list, unsigned long nr_mfns)
+{
+    unsigned long flags;
+
+    balloon_lock(flags);
+    if ( HYPERVISOR_dom_mem_op(MEMOP_increase_reservation,
+                               mfn_list, nr_mfns, 0) != nr_mfns ) {
+        WPRINTK("Unable to get memory pages from Balloon Driver");
+       balloon_unlock(flags);
+       return -ENOMEM;
+    }
+    current_pages += nr_mfns; /* non-atomic update */
+    balloon_unlock(flags);
+
+    schedule_work(&balloon_worker);
+}
+
 EXPORT_SYMBOL(balloon_update_driver_allowance);
 EXPORT_SYMBOL(balloon_put_pages);
+EXPORT_SYMBOL(balloon_get_pages);
diff -r 7c05931c1d0b -r a05f92511a99 linux-2.6-xen-sparse/include/asm-xen/balloon.h
--- a/linux-2.6-xen-sparse/include/asm-xen/balloon.h    Thu Aug 18 13:26:50 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/balloon.h    Mon Aug 22 09:50:48 2005
@@ -40,6 +40,9 @@
 /* Give up unmapped pages to the balloon driver. */
 extern void balloon_put_pages(unsigned long *mfn_list, unsigned long nr_mfns);

+/* Get an unmapped pages from the balloon driver. */
+extern int balloon_get_pages(unsigned long *mfn_list, unsigned long nr_mfns);
+
 /*
  * Prevent the balloon driver from changing the memory reservation during
  * a driver critical region.
diff -r 7c05931c1d0b -r a05f92511a99 linux-2.6-xen-sparse/include/asm-xen/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-xen/hypervisor.h Thu Aug 18 13:26:50 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/hypervisor.h Mon Aug 22 09:50:48 2005
@@ -142,6 +142,9 @@
 /* Allocate a contiguous empty region of low memory. Return virtual start. */
 unsigned long allocate_empty_lowmem_region(unsigned long pages);

+/* Unallocate a contiguous empty region of low memory which was previously
+ * allocated by allocate_empty_lowmem_region */
+int unallocate_empty_lowmem_region(unsigned long vstart, unsigned long pages);
 #include <asm/hypercall.h>

 #if defined(CONFIG_X86_64)

[-- Attachment #1.2: Type: text/html, Size: 7996 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 16%]

* [PATCH] balloon_dealloc_empty_page_range
@ 2005-08-22 15:42 16% Ross C Mcilroy
  0 siblings, 0 replies; 200+ results
From: Ross C Mcilroy @ 2005-08-22 15:42 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 3000 bytes --]


Hi Keir,

> This could be implemented much more simply. Add a balloon interface 
> function balloon_dealloc_empty_page_range(struct page *page, long 
> nr_pfns).
> 
> This function can simply iterate over the page range, 
> balloon_append()ing each page. Then kick the balloon worker thread and 
> you're done!
> 
> Call that balloon function direct from your driver(s) (ie., don't 
> bother defining a wrapper function in mm/hypervsior.c). 
> alloc_lowmem_region will probably also get moved to the balloon driver 
> at some point.
> 
>   -- Keir


Yes, your right of course, thats much easier.  The patch below should do what you want.  It seems to work with my drivers fine.

The one problem with this approch is that the alloc_lowmem_region function allocates the smallest 2^x greater than the number of pages requested, therefore you either need to only allocate/dealloc in powers of 2, or remember to deallocate a different amount than was allocated.  

It might be worth having a simple wrapper in hypercall.c/h which deallocates to the nearest power to keep things semantically the same.  E.g.:

void deallocate_empty_lowmem_region(unsigned long vstart,
                                    unsigned long pages)
{
    balloon_dealloc_empty_page_range(virt_to_page((void *) vstart, 
                                     (long) get_order(pages));
}


--------------------


# HG changeset patch
# User rcmcilro@localhost.localdomain
# Node ID 787faafef2543a1cacbf98259a45bc347065b682
# Parent  7c05931c1d0b82babd600b7e3e712fc06b899ed9
balloon_dealloc_empty_page_range

Signed-of-by: Ross McIlroy <mcilrorc@dcs.gla.ac.uk>

diff -r 7c05931c1d0b -r 787faafef254 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Aug 18 13:26:50 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Aug 22 14:07:43 2005
@@ -467,5 +467,18 @@
     schedule_work(&balloon_worker);
 }
 
+void balloon_dealloc_empty_page_range(struct page *page, long nr_pfns)
+{
+    long i;
+
+    for (i=0; i<nr_pfns; i++) {
+	balloon_append(page++);
+    }
+
+    schedule_work(&balloon_worker);
+}
+
 EXPORT_SYMBOL(balloon_update_driver_allowance);
 EXPORT_SYMBOL(balloon_put_pages);
+EXPORT_SYMBOL(balloon_dealloc_empty_page_range);
+
diff -r 7c05931c1d0b -r 787faafef254 linux-2.6-xen-sparse/include/asm-xen/balloon.h
--- a/linux-2.6-xen-sparse/include/asm-xen/balloon.h	Thu Aug 18 13:26:50 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/balloon.h	Mon Aug 22 14:07:43 2005
@@ -40,6 +40,9 @@
 /* Give up unmapped pages to the balloon driver. */
 extern void balloon_put_pages(unsigned long *mfn_list, unsigned long nr_mfns);
 
+/* deallocate an empty page ranges, freeing memory. */
+void balloon_dealloc_empty_page_range(struct page *page, long nr_pfns);
+
 /*
  * Prevent the balloon driver from changing the memory reservation during
  * a driver critical region.



 

[-- Attachment #1.2: Type: text/html, Size: 4439 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 16%]

* x86_32 PAE ballooning is busted
@ 2005-08-23 20:51  4% Jerone Young
  0 siblings, 0 replies; 200+ results
From: Jerone Young @ 2005-08-23 20:51 UTC (permalink / raw)
  To: xen-devel

I have an opteron with 6gig ram running X86-32 with Xen compiled with
PAE enabled. When I do the following to try to ballon down (as xm
ballooning is busted) I get the following:

[root@xen32p32bit ~]# echo $((512*1024*1024)) > /proc/xen/balloon
[root@xen32p32bit ~]# oom-killer: gfp_mask=0xd2
DMA per-cpu:
cpu 0 hot: low 62, high 186, batch 31
cpu 0 cold: low 0, high 62, batch 31
Normal per-cpu: empty
HighMem per-cpu:
cpu 0 hot: low 62, high 186, batch 31
cpu 0 cold: low 0, high 62, batch 31

Free pages:       22944kB (620kB HighMem)
Active:327 inactive:732 dirty:0 writeback:226 unstable:0 free:5736
slab:2181 ma2DMA free:22324kB min:3452kB low:4312kB high:5176kB
active:132kB inactive:112kB slowmem_reserve[]: 0 0 4721
Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB
present:0kB paolowmem_reserve[]: 0 0 37771
HighMem free:620kB min:512kB low:640kB high:768kB active:1176kB
inactive:2816kBolowmem_reserve[]: 0 0 0
DMA: 1*4kB 0*8kB 1*16kB 1*32kB 0*64kB 0*128kB 1*256kB 1*512kB 1*1024kB
0*2048kBBNormal: empty
HighMem: 17*4kB 3*8kB 1*16kB 2*32kB 1*64kB 1*128kB 1*256kB 0*512kB
0*1024kB 0*2BSwap cache: add 3712, delete 3261, find 0/2, race 0+0
Free swap  = 1037432kB
Total swap = 1052248kB
Out of Memory: Killed process 2393 (mDNSResponder).
oom-killer: gfp_mask=0x1d2
DMA per-cpu:
cpu 0 hot: low 62, high 186, batch 31
cpu 0 cold: low 0, high 62, batch 31
Normal per-cpu: empty
HighMem per-cpu:
cpu 0 hot: low 62, high 186, batch 31
cpu 0 cold: low 0, high 62, batch 31

Free pages:       22944kB (620kB HighMem)
Active:306 inactive:282 dirty:0 writeback:0 unstable:0 free:5736
slab:2151 mapp2DMA free:22324kB min:3452kB low:4312kB high:5176kB
active:132kB inactive:112kB slowmem_reserve[]: 0 0 4721
Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB
present:0kB paolowmem_reserve[]: 0 0 37771
HighMem free:620kB min:512kB low:640kB high:768kB active:1092kB
inactive:1016kBslowmem_reserve[]: 0 0 0
DMA: 1*4kB 0*8kB 1*16kB 1*32kB 0*64kB 0*128kB 1*256kB 1*512kB 1*1024kB
0*2048kBBNormal: empty
HighMem: 23*4kB 4*8kB 1*16kB 1*32kB 1*64kB 1*128kB 1*256kB 0*512kB
0*1024kB 0*2BSwap cache: add 3752, delete 3740, find 6/16, race 0+0
Free swap  = 1037432kB
Total swap = 1052248kB
Out of Memory: Killed process 2394 (mDNSResponder).
oom-killer: gfp_mask=0x1d2
DMA per-cpu:
cpu 0 hot: low 62, high 186, batch 31
cpu 0 cold: low 0, high 62, batch 31
Normal per-cpu: empty
HighMem per-cpu:
cpu 0 hot: low 62, high 186, batch 31
cpu 0 cold: low 0, high 62, batch 31

Free pages:       23068kB (744kB HighMem)
Active:271 inactive:285 dirty:0 writeback:0 unstable:0 free:5767
slab:2149 mapp5DMA free:22324kB min:3452kB low:4312kB high:5176kB
active:32kB inactive:120kB pslowmem_reserve[]: 0 0 4721
Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB
present:0kB paolowmem_reserve[]: 0 0 37771
HighMem free:744kB min:512kB low:640kB high:768kB active:1052kB
inactive:1020kBslowmem_reserve[]: 0 0 0
DMA: 1*4kB 0*8kB 1*16kB 1*32kB 0*64kB 0*128kB 1*256kB 1*512kB 1*1024kB
0*2048kBBNormal: empty
HighMem: 44*4kB 3*8kB 2*16kB 2*32kB 1*64kB 1*128kB 1*256kB 0*512kB
0*1024kB 0*2BSwap cache: add 3792, delete 3789, find 7/18, race 0+0
Free swap  = 1037856kB
Total swap = 1052248kB
Out of Memory: Killed process 2480 (sendmail).
oom-killer: gfp_mask=0x1d2
DMA per-cpu:
cpu 0 hot: low 62, high 186, batch 31
cpu 0 cold: low 0, high 62, batch 31
Normal per-cpu: empty
HighMem per-cpu:
cpu 0 hot: low 62, high 186, batch 31
cpu 0 cold: low 0, high 62, batch 31

Free pages:       23068kB (744kB HighMem)
Active:279 inactive:285 dirty:0 writeback:0 unstable:0 free:5767
slab:2148 mapp8DMA free:22324kB min:3452kB low:4312kB high:5176kB
active:32kB inactive:120kB pslowmem_reserve[]: 0 0 4721
Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB
present:0kB paolowmem_reserve[]: 0 0 37771
HighMem free:744kB min:512kB low:640kB high:768kB active:1084kB
inactive:1020kBslowmem_reserve[]: 0 0 0
DMA: 1*4kB 0*8kB 1*16kB 1*32kB 0*64kB 0*128kB 1*256kB 1*512kB 1*1024kB
0*2048kBBNormal: empty
HighMem: 44*4kB 3*8kB 2*16kB 2*32kB 1*64kB 1*128kB 1*256kB 0*512kB
0*1024kB 0*2BSwap cache: add 3800, delete 3789, find 7/19, race 0+0
Free swap  = 1038700kB
Total swap = 1052248kB
Out of Memory: Killed process 2528 (xfs).
oom-killer: gfp_mask=0xd2
DMA per-cpu:
cpu 0 hot: low 62, high 186, batch 31
cpu 0 cold: low 0, high 62, batch 31
Normal per-cpu: empty
HighMem per-cpu:
cpu 0 hot: low 62, high 186, batch 31
cpu 0 cold: low 0, high 62, batch 31

Free pages:       22820kB (496kB HighMem)
Active:274 inactive:261 dirty:0 writeback:0 unstable:0 free:5705
slab:2148 mapp2DMA free:22324kB min:3452kB low:4312kB high:5176kB
active:12kB inactive:24kB prolowmem_reserve[]: 0 0 4721
Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB
present:0kB paolowmem_reserve[]: 0 0 37771
HighMem free:496kB min:512kB low:640kB high:768kB active:1084kB
inactive:1020kBslowmem_reserve[]: 0 0 0
DMA: 1*4kB 0*8kB 1*16kB 1*32kB 0*64kB 0*128kB 1*256kB 1*512kB 1*1024kB
0*2048kBBNormal: empty
HighMem: 0*4kB 0*8kB 1*16kB 1*32kB 1*64kB 1*128kB 1*256kB 0*512kB
0*1024kB 0*20BSwap cache: add 3808, delete 3797, find 7/21, race 0+0
Free swap  = 1039448kB
Total swap = 1052248kB
Out of Memory: Killed process 2847 (python).


-- 
Jerone Young
IBM Linux Technology Center
jyoung5@us.ibm.com
512-838-1157 (T/L: 678-1157)

^ permalink raw reply	[relevance 4%]

* kernel panic doing mem-set
@ 2005-08-31 18:52  5% Patrick O'Rourke
  0 siblings, 0 replies; 200+ results
From: Patrick O'Rourke @ 2005-08-31 18:52 UTC (permalink / raw)
  To: xen-devel

x86_32, no PAE, I see the following when trying to set dom0's memory 
down to 512MB (note: there is a total of 12GB of RAM).  Seems we're 
hitting this statement:

BUG_ON(HYPERVISOR_memory_op(
         XENMEM_decrease_reservation, &reservation) != debt);

Pat

por-xen login: store_evtchn = 10
XENBUS xs_read_watch: 0
ip_tables: (C) 2000-2002 Netfilter core team
kernel BUG at drivers/xen/balloon/balloon.c:277 (balloon_process)!
  [<c02b7854>] balloon_process+0x274/0x460
  [<c01327e1>] worker_thread+0x201/0x3d0
  [<c0387568>] schedule+0x3b8/0x7a0
  [<c02b75e0>] balloon_process+0x0/0x460
  [<c011b8a0>] default_wake_function+0x0/0x20
  [<c011b8a0>] default_wake_function+0x0/0x20
  [<c01325e0>] worker_thread+0x0/0x3d0
  [<c0137aad>] kthread+0xad/0xf0
  [<c0137a00>] kthread+0x0/0xf0
  [<c01079c5>] kernel_thread_helper+0x5/0x10
Kernel panic - not syncing: BUG!

-- 
Patrick O'Rourke
porourke@egenera.com

^ permalink raw reply	[relevance 5%]

* questions about mem-max
@ 2005-08-31 22:12  5% Li Ge
  0 siblings, 0 replies; 200+ results
From: Li Ge @ 2005-08-31 22:12 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 478 bytes --]





I am trying to understand how the command "xm mem-max" works and write some
testcases for it. Here are some confusion I have:

1. Can maximum memory be adjusted for a domain at runtime by using 'xm
mem-max'? Right now, I see that  the max memory change made by 'xm mem-max'
is only recorded by xend. There is no change in /proc/xen/balloon and
/proc/meminfo.

2. If the answer to 1 is no, how to activate the change to the domain?  How
should I verify it?


Thanks a lot,
Li

[-- Attachment #1.2: Type: text/html, Size: 546 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 5%]

* RE: questions about mem-max
@ 2005-08-31 23:11  0% Ian Pratt
  0 siblings, 0 replies; 200+ results
From: Ian Pratt @ 2005-08-31 23:11 UTC (permalink / raw)
  To: Li Ge, xen-devel

> I am trying to understand how the command "xm mem-max" works 
> and write some testcases for it. Here are some confusion I have:
> 
> 1. Can maximum memory be adjusted for a domain at runtime by 
> using 'xm mem-max'? Right now, I see that the max memory 
> change made by 'xm mem-max' is only recorded by xend. There 
> is no change in /proc/xen/balloon and /proc/meminfo.
> 
> 2. If the answer to 1 is no, how to activate the change to 
> the domain? How should I verify it?

max-mem isn't really intended as a user command. It doesn't really
server any purpose in a world with well-behaved VMs. What probably
should happen is that when balloning a domain down in size, xend should
periodically poll the domain's memory usage and set max-mem to be the
current usage plus some small slack. This would prevent a runaway domain
ignoring its memory target and trying to grow its allocation.

Ian 

^ permalink raw reply	[relevance 0%]

* [RFC] Cleaning up /proc/xen
@ 2005-09-08  1:45  6% Anthony Liguori
  2005-09-08  8:09  0% ` NAHieu
  2005-09-08 22:29  0% ` Daniel Stekloff
  0 siblings, 2 replies; 200+ results
From: Anthony Liguori @ 2005-09-08  1:45 UTC (permalink / raw)
  To: xen-devel

Today, in /proc/xen we have:

/proc/xen/balloon  -   displays information about memory allocations and 
allows for ballooning by echoing a byte value into file

/proc/xen/privcmd  -  allows for userspace invocation of hypercalls and 
mapping of other domains memory

/proc/xen/grant   -   allows grant table operations to be accessed from 
userspace

/proc/xen/xenbus  -   allows xenbus to be accessed from userspace (in domUs)

I propose we do the following:

Change /proc/xen/{privcmd,grant,xenbus} to character devices (that use 
random major/minors; we'll always access them by name).  We have a few 
options for /proc/xen/balloon.  We could:

1) Get rid of it completely--not sure it's a good idea but it's been 
suggested since it's redundant (in dom0 at least).
2) Move it to /proc/sys/
3) Move it to /sys/xen

I'm partial to the last option (maybe even /sys/hypervisor/xen--that 
seems to compliment /sys/firmware).

Thoughts?

Regards,

Anthony Liguori

^ permalink raw reply	[relevance 6%]

* RE: [RFC] Cleaning up /proc/xen
@ 2005-09-08  2:26  0% Ian Pratt
  2005-09-08  2:51  0% ` Steven Hand
  0 siblings, 1 reply; 200+ results
From: Ian Pratt @ 2005-09-08  2:26 UTC (permalink / raw)
  To: Anthony Liguori, xen-devel

 
> I propose we do the following:
> 
> Change /proc/xen/{privcmd,grant,xenbus} to character devices 
> (that use random major/minors; we'll always access them by 
> name).  

Is this going to make having udev a requirement? (or would we also mknod
some entries in de as part of an install?)

I guess most distros have had udev for a while.

> We have a few options for /proc/xen/balloon.  We could:

> 1) Get rid of it completely--not sure it's a good idea but 
> it's been suggested since it's redundant (in dom0 at least).
> 2) Move it to /proc/sys/
> 3) Move it to /sys/xen

I can't decide between 2 and 3.

BTW: Anthony, as regards you directory re-organisation patch, should we
be taking the opportunity to add a version prefix e.g.
/usr/lib64/xen-3.0/bin  ?
(also, does your patch use /usr/lib64/xen on x86_64 OK?)

I wander whether /etc/xen/scripts would be better off living under
/usr/lib/xen-3.0/scripts ?

Should the default place to look for config file be /usr/lib/xen-3.0/etc
which is normally soft linked on install to /etc/xen ?

I think the above three changes would enable you to have 3.0 and 2.0
tools installed in both x86_64 and x86_32 flavours all at the same time.

Thanks,
Ian

^ permalink raw reply	[relevance 0%]

* Re: [RFC] Cleaning up /proc/xen
  2005-09-08  2:26  0% Ian Pratt
@ 2005-09-08  2:51  0% ` Steven Hand
  2005-09-08  3:24  0%   ` Anthony Liguori
  0 siblings, 1 reply; 200+ results
From: Steven Hand @ 2005-09-08  2:51 UTC (permalink / raw)
  To: Ian Pratt; +Cc: xen-devel, Steven.Hand


>Is this going to make having udev a requirement? (or would we also mknod
>some entries in de as part of an install?)
>
>I guess most distros have had udev for a while.

Yes - though it'd be good to fix udev start (which takes ages, at least
on redhat root filesystems). 

>> We have a few options for /proc/xen/balloon.  We could:
>
>> 1) Get rid of it completely--not sure it's a good idea but=20
>> it's been suggested since it's redundant (in dom0 at least).
>> 2) Move it to /proc/sys/
>> 3) Move it to /sys/xen
>
>I can't decide between 2 and 3.

There's also 0 = leave it as is.

What's the motivation for this clean-up again? 

>BTW: Anthony, as regards you directory re-organisation patch, should we
>be taking the opportunity to add a version prefix e.g.
>/usr/lib64/xen-3.0/bin  ?
>(also, does your patch use /usr/lib64/xen on x86_64 OK?)
>
>I wander whether /etc/xen/scripts would be better off living under
>/usr/lib/xen-3.0/scripts ?
>
>Should the default place to look for config file be /usr/lib/xen-3.0/etc
>which is normally soft linked on install to /etc/xen ?
>
>I think the above three changes would enable you to have 3.0 and 2.0
>tools installed in both x86_64 and x86_32 flavours all at the same time.

Hmm - how would we get the relevant python bits picked up? 

cheers,

S

^ permalink raw reply	[relevance 0%]

* Re: [RFC] Cleaning up /proc/xen
  2005-09-08  2:51  0% ` Steven Hand
@ 2005-09-08  3:24  0%   ` Anthony Liguori
  0 siblings, 0 replies; 200+ results
From: Anthony Liguori @ 2005-09-08  3:24 UTC (permalink / raw)
  To: Steven Hand; +Cc: Ian Pratt, xen-devel

Steven Hand wrote:

>>Is this going to make having udev a requirement? (or would we also mknod
>>some entries in de as part of an install?)
>>
>>I guess most distros have had udev for a while.
>>    
>>
>
>Yes - though it'd be good to fix udev start (which takes ages, at least
>on redhat root filesystems). 
>  
>
Yes, we already have some troubles here though.  We're relying on 
reserved local-use major/minors for /dev/evtchn.  We need to either 
register official LANA numbers for /dev/evtchn (in which case, we can 
just use some of minors for these other devices), or switch to using 
random major/minors and rely on udev.

We can't just mknod at install time--the majors/minors would be random.  
We'd have to read /proc/modules and attempt to figure out which ones our 
devices were assigned.

For non-udev systems, I think we should just take major/minor parameters 
as module parameters and let the users deal with figuring out what 
reserved numbers to use.

>>>We have a few options for /proc/xen/balloon.  We could:
>>>      
>>>
>>>1) Get rid of it completely--not sure it's a good idea but=20
>>>it's been suggested since it's redundant (in dom0 at least).
>>>2) Move it to /proc/sys/
>>>3) Move it to /sys/xen
>>>      
>>>
>>I can't decide between 2 and 3.
>>    
>>
>
>There's also 0 = leave it as is.
>
>What's the motivation for this clean-up again? 
>  
>
I think the reasoning is that /proc is more or less a deprecated 
interface.  Plus, the {evtchn,grant,xenbus} interfaces are empty files 
that ioctls are done on--there's not really what proc files are meant to do.

Perhaps someone a bit closer to the kernel community can comment more 
definitively.

>>BTW: Anthony, as regards you directory re-organisation patch, should we
>>be taking the opportunity to add a version prefix e.g.
>>/usr/lib64/xen-3.0/bin  ?
>>(also, does your patch use /usr/lib64/xen on x86_64 OK?)
>>    
>>
I'll resubmit making sure to explicitly use /usr/lib64.  Hadn't 
considered that.

I like the idea of versioning.  I'll also include that.

>>I wander whether /etc/xen/scripts would be better off living under
>>/usr/lib/xen-3.0/scripts ?
>>    
>>
I think that makes sense.  Users aren't really supposed to modify them 
right?  They're really more like plugins..

>>Should the default place to look for config file be /usr/lib/xen-3.0/etc
>>which is normally soft linked on install to /etc/xen ?
>>    
>>
That seems a little awkward to me, but not too crazy.  Any one else have 
thoughts?

>>I think the above three changes would enable you to have 3.0 and 2.0
>>tools installed in both x86_64 and x86_32 flavours all at the same time.
>>    
>>
>
>Hmm - how would we get the relevant python bits picked up? 
>  
>
This is a really good point.

We already set the path explicitly in tools/misc/{xend,xm} so that's 
pretty reasonable (we can expose version info to everything else through 
there).  The only problem is how to you install the xend and xm commands 
for 32 and 64 in a single /usr/bin?

I think what we really need to do is have proper prefix support.  That 
would solve the problem completely.  I still think versioning the lib 
directory is a good idea though.

Regards,

Anthony Liguori

>cheers,
>
>S
>
>  
>

^ permalink raw reply	[relevance 0%]

* Re: [RFC] Cleaning up /proc/xen
  2005-09-08  1:45  6% [RFC] Cleaning up /proc/xen Anthony Liguori
@ 2005-09-08  8:09  0% ` NAHieu
  2005-09-08 22:29  0% ` Daniel Stekloff
  1 sibling, 0 replies; 200+ results
From: NAHieu @ 2005-09-08  8:09 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: xen-devel

On 9/8/05, Anthony Liguori <aliguori@us.ibm.com> wrote:
> Today, in /proc/xen we have:
> 
> /proc/xen/balloon  -   displays information about memory allocations and
> allows for ballooning by echoing a byte value into file
> 
> /proc/xen/privcmd  -  allows for userspace invocation of hypercalls and
> mapping of other domains memory
> 
> /proc/xen/grant   -   allows grant table operations to be accessed from
> userspace
> 
> /proc/xen/xenbus  -   allows xenbus to be accessed from userspace (in domUs)
> 
> I propose we do the following:
> 
> Change /proc/xen/{privcmd,grant,xenbus} to character devices (that use
> random major/minors; we'll always access them by name).  We have a few
> options for /proc/xen/balloon.  We could:
> 
> 1) Get rid of it completely--not sure it's a good idea but it's been
> suggested since it's redundant (in dom0 at least).
> 2) Move it to /proc/sys/
> 3) Move it to /sys/xen
> 

The good thing about /proc is that we do not need to register any
major/minor stuffs (which is very annoying), like what we do with
device.

So I vote for moving things to under /sys. But hold on, that would not
be compatible with others OS like *BSD, correct ?


Thanks,
Hieu.

^ permalink raw reply	[relevance 0%]

* Re: [RFC] Cleaning up /proc/xen
  2005-09-08  1:45  6% [RFC] Cleaning up /proc/xen Anthony Liguori
  2005-09-08  8:09  0% ` NAHieu
@ 2005-09-08 22:29  0% ` Daniel Stekloff
  1 sibling, 0 replies; 200+ results
From: Daniel Stekloff @ 2005-09-08 22:29 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: xen-devel

On Wed, 2005-09-07 at 20:45 -0500, Anthony Liguori wrote:
> Today, in /proc/xen we have:
> 
> /proc/xen/balloon  -   displays information about memory allocations and 
> allows for ballooning by echoing a byte value into file
> 
> /proc/xen/privcmd  -  allows for userspace invocation of hypercalls and 
> mapping of other domains memory
> 
> /proc/xen/grant   -   allows grant table operations to be accessed from 
> userspace
> 
> /proc/xen/xenbus  -   allows xenbus to be accessed from userspace (in domUs)
> 
> I propose we do the following:
> 
> Change /proc/xen/{privcmd,grant,xenbus} to character devices (that use 
> random major/minors; we'll always access them by name).  We have a few 
> options for /proc/xen/balloon.  We could:
> 
> 1) Get rid of it completely--not sure it's a good idea but it's been 
> suggested since it's redundant (in dom0 at least).
> 2) Move it to /proc/sys/
> 3) Move it to /sys/xen
> 
> I'm partial to the last option (maybe even /sys/hypervisor/xen--that 
> seems to compliment /sys/firmware).
> 
> Thoughts?


Hi Anthony, 

If you're serious about option 3, it might be a good idea to post to
lkml and cc the sysfs maintainer - Greg KH. He might have some
suggestions.

Thanks,

Dan

^ permalink raw reply	[relevance 0%]

* [PATCH 4/10] (doc) Split user.tex
@ 2005-09-19 23:02 14% Robb Romans
  0 siblings, 0 replies; 200+ results
From: Robb Romans @ 2005-09-19 23:02 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 187 bytes --]

Split user.tex

Signed-off-by: Robb Romans <3r@us.ibm.com>

-- 
Robb Romans                     (512) 838-0419
Linux Commando                  T/L   678-0419
ARS NA5TT
.-- - ..-. ..--..


[-- Attachment #2: 6958-doc-user-domainmgmt.diff --]
[-- Type: text/x-diff, Size: 16180 bytes --]

# HG changeset patch
# User Robb Romans <3r@us.ibm.com>
# Node ID 23470c8ea113a3a55edb9f6d98c16467bdf10c43
# Parent  ab26884b27c96a26f8088b1fcf20074fc81515fb
Separate file for docs/src/user/domain_mgmt.tex

Signed-off-by: Robb Romans <3r@us.ibm.com>

diff -r ab26884b27c9 -r 23470c8ea113 docs/src/user.tex
--- a/docs/src/user.tex	Mon Sep 19 20:07:14 2005
+++ b/docs/src/user.tex	Mon Sep 19 20:26:38 2005
@@ -70,206 +70,9 @@
 %% Chapter Starting Additional Domains  moved to start_addl_dom.tex
 \include{src/user/start_addl_dom}
 
-
-\chapter{Domain Management Tools}
-
-The previous chapter described a simple example of how to configure
-and start a domain.  This chapter summarises the tools available to
-manage running domains.
-
-\section{Command-line Management}
-
-Command line management tasks are also performed using the \path{xm}
-tool.  For online help for the commands available, type:
-\begin{quote}
-\verb_# xm help_
-\end{quote}
-
-You can also type \path{xm help $<$command$>$} for more information 
-on a given command. 
-
-\subsection{Basic Management Commands}
-
-The most important \path{xm} commands are: 
-\begin{quote}
-\verb_# xm list_: Lists all domains running.\\
-\verb_# xm consoles_ : Gives information about the domain consoles.\\
-\verb_# xm console_: Opens a console to a domain (e.g.\
-  \verb_# xm console myVM_
-\end{quote}
-
-\subsection{\tt xm list}
-
-The output of \path{xm list} is in rows of the following format:
-\begin{center}
-{\tt name domid memory cpu state cputime console}
-\end{center}
-
-\begin{quote}
-\begin{description}
-\item[name]  The descriptive name of the virtual machine.
-\item[domid] The number of the domain ID this virtual machine is running in.
-\item[memory] Memory size in megabytes.
-\item[cpu]   The CPU this domain is running on.
-\item[state] Domain state consists of 5 fields:
-  \begin{description}
-  \item[r] running
-  \item[b] blocked
-  \item[p] paused
-  \item[s] shutdown
-  \item[c] crashed
-  \end{description}
-\item[cputime] How much CPU time (in seconds) the domain has used so far.
-\item[console] TCP port accepting connections to the domain's console.
-\end{description}
-\end{quote}
-
-The \path{xm list} command also supports a long output format when the
-\path{-l} switch is used.  This outputs the fulls details of the
-running domains in \xend's SXP configuration format.
-
-For example, suppose the system is running the ttylinux domain as
-described earlier.  The list command should produce output somewhat
-like the following:
-\begin{verbatim}
-# xm list
-Name              Id  Mem(MB)  CPU  State  Time(s)  Console
-Domain-0           0      251    0  r----    172.2        
-ttylinux           5       63    0  -b---      3.0    9605
-\end{verbatim}
-
-Here we can see the details for the ttylinux domain, as well as for
-domain 0 (which, of course, is always running).  Note that the console
-port for the ttylinux domain is 9605.  This can be connected to by TCP
-using a terminal program (e.g. \path{telnet} or, better, 
-\path{xencons}).  The simplest way to connect is to use the \path{xm console}
-command, specifying the domain name or ID.  To connect to the console
-of the ttylinux domain, we could use any of the following: 
-\begin{verbatim}
-# xm console ttylinux
-# xm console 5
-# xencons localhost 9605
-\end{verbatim}
-
-\section{Domain Save and Restore}
-
-The administrator of a Xen system may suspend a virtual machine's
-current state into a disk file in domain 0, allowing it to be resumed
-at a later time.
-
-The ttylinux domain described earlier can be suspended to disk using
-the command:
-\begin{verbatim}
-# xm save ttylinux ttylinux.xen
-\end{verbatim}
-
-This will stop the domain named `ttylinux' and save its current state
-into a file called \path{ttylinux.xen}.
-
-To resume execution of this domain, use the \path{xm restore} command:
-\begin{verbatim}
-# xm restore ttylinux.xen
-\end{verbatim}
-
-This will restore the state of the domain and restart it.  The domain
-will carry on as before and the console may be reconnected using the
-\path{xm console} command, as above.
-
-\section{Live Migration}
-
-Live migration is used to transfer a domain between physical hosts
-whilst that domain continues to perform its usual activities --- from
-the user's perspective, the migration should be imperceptible.
-
-To perform a live migration, both hosts must be running Xen / \xend and
-the destination host must have sufficient resources (e.g. memory
-capacity) to accommodate the domain after the move. Furthermore we
-currently require both source and destination machines to be on the 
-same L2 subnet. 
-
-Currently, there is no support for providing automatic remote access
-to filesystems stored on local disk when a domain is migrated.
-Administrators should choose an appropriate storage solution
-(i.e. SAN, NAS, etc.) to ensure that domain filesystems are also
-available on their destination node. GNBD is a good method for
-exporting a volume from one machine to another. iSCSI can do a similar
-job, but is more complex to set up.
-
-When a domain migrates, it's MAC and IP address move with it, thus it
-is only possible to migrate VMs within the same layer-2 network and IP
-subnet. If the destination node is on a different subnet, the
-administrator would need to manually configure a suitable etherip or
-IP tunnel in the domain 0 of the remote node. 
-
-A domain may be migrated using the \path{xm migrate} command.  To
-live migrate a domain to another machine, we would use
-the command:
-
-\begin{verbatim}
-# xm migrate --live mydomain destination.ournetwork.com
-\end{verbatim}
-
-Without the \path{--live} flag, \xend simply stops the domain and
-copies the memory image over to the new node and restarts it. Since
-domains can have large allocations this can be quite time consuming,
-even on a Gigabit network. With the \path{--live} flag \xend attempts
-to keep the domain running while the migration is in progress,
-resulting in typical `downtimes' of just 60--300ms.
-
-For now it will be necessary to reconnect to the domain's console on
-the new machine using the \path{xm console} command.  If a migrated
-domain has any open network connections then they will be preserved,
-so SSH connections do not have this limitation.
-
-\section{Managing Domain Memory}
-
-XenLinux domains have the ability to relinquish / reclaim machine
-memory at the request of the administrator or the user of the domain.
-
-\subsection{Setting memory footprints from dom0}
-
-The machine administrator can request that a domain alter its memory
-footprint using the \path{xm set-mem} command.  For instance, we can
-request that our example ttylinux domain reduce its memory footprint
-to 32 megabytes.
-
-\begin{verbatim}
-# xm set-mem ttylinux 32
-\end{verbatim}
-
-We can now see the result of this in the output of \path{xm list}:
-
-\begin{verbatim}
-# xm list
-Name              Id  Mem(MB)  CPU  State  Time(s)  Console
-Domain-0           0      251    0  r----    172.2        
-ttylinux           5       31    0  -b---      4.3    9605
-\end{verbatim}
-
-The domain has responded to the request by returning memory to Xen. We
-can restore the domain to its original size using the command line:
-
-\begin{verbatim}
-# xm set-mem ttylinux 64
-\end{verbatim}
-
-\subsection{Setting memory footprints from within a domain}
-
-The virtual file \path{/proc/xen/balloon} allows the owner of a
-domain to adjust their own memory footprint.  Reading the file
-(e.g. \path{cat /proc/xen/balloon}) prints out the current
-memory footprint of the domain.  Writing the file
-(e.g. \path{echo new\_target > /proc/xen/balloon}) requests
-that the kernel adjust the domain's memory footprint to a new value.
-
-\subsection{Setting memory limits}
-
-Xen associates a memory size limit with each domain.  By default, this
-is the amount of memory the domain is originally started with,
-preventing the domain from ever growing beyond this size.  To permit a
-domain to grow beyond its original allocation or to prevent a domain
-you've shrunk from reclaiming the memory it relinquished, use the 
-\path{xm maxmem} command.
+%% Chapter Domain Management Tools moved to domain_mgmt.tex
+\include{src/user/domain_mgmt}
+
 
 \chapter{Domain Filesystem Storage}
 
diff -r ab26884b27c9 -r 23470c8ea113 docs/src/user/domain_mgmt.tex
--- /dev/null	Mon Sep 19 20:07:14 2005
+++ b/docs/src/user/domain_mgmt.tex	Mon Sep 19 20:26:38 2005
@@ -0,0 +1,203 @@
+\chapter{Domain Management Tools}
+
+The previous chapter described a simple example of how to configure
+and start a domain.  This chapter summarises the tools available to
+manage running domains.
+
+
+\section{Command-line Management}
+
+Command line management tasks are also performed using the \path{xm}
+tool.  For online help for the commands available, type:
+\begin{quote}
+  \verb_# xm help_
+\end{quote}
+
+You can also type \path{xm help $<$command$>$} for more information on
+a given command.
+
+\subsection{Basic Management Commands}
+
+The most important \path{xm} commands are:
+\begin{quote}
+  \verb_# xm list_: Lists all domains running.\\
+  \verb_# xm consoles_: Gives information about the domain consoles.\\
+  \verb_# xm console_: Opens a console to a domain (e.g.\
+  \verb_# xm console myVM_)
+\end{quote}
+
+\subsection{\tt xm list}
+
+The output of \path{xm list} is in rows of the following format:
+\begin{center} {\tt name domid memory cpu state cputime console}
+\end{center}
+
+\begin{quote}
+  \begin{description}
+  \item[name] The descriptive name of the virtual machine.
+  \item[domid] The number of the domain ID this virtual machine is
+    running in.
+  \item[memory] Memory size in megabytes.
+  \item[cpu] The CPU this domain is running on.
+  \item[state] Domain state consists of 5 fields:
+    \begin{description}
+    \item[r] running
+    \item[b] blocked
+    \item[p] paused
+    \item[s] shutdown
+    \item[c] crashed
+    \end{description}
+  \item[cputime] How much CPU time (in seconds) the domain has used so
+    far.
+  \item[console] TCP port accepting connections to the domain's
+    console.
+  \end{description}
+\end{quote}
+
+The \path{xm list} command also supports a long output format when the
+\path{-l} switch is used.  This outputs the fulls details of the
+running domains in \xend's SXP configuration format.
+
+For example, suppose the system is running the ttylinux domain as
+described earlier.  The list command should produce output somewhat
+like the following:
+\begin{verbatim}
+# xm list
+Name              Id  Mem(MB)  CPU  State  Time(s)  Console
+Domain-0           0      251    0  r----    172.2        
+ttylinux           5       63    0  -b---      3.0    9605
+\end{verbatim}
+
+Here we can see the details for the ttylinux domain, as well as for
+domain~0 (which, of course, is always running).  Note that the console
+port for the ttylinux domain is 9605.  This can be connected to by TCP
+using a terminal program (e.g. \path{telnet} or, better,
+\path{xencons}).  The simplest way to connect is to use the
+\path{xm~console} command, specifying the domain name or ID.  To
+connect to the console of the ttylinux domain, we could use any of the
+following:
+\begin{verbatim}
+# xm console ttylinux
+# xm console 5
+# xencons localhost 9605
+\end{verbatim}
+
+\section{Domain Save and Restore}
+
+The administrator of a Xen system may suspend a virtual machine's
+current state into a disk file in domain~0, allowing it to be resumed
+at a later time.
+
+The ttylinux domain described earlier can be suspended to disk using
+the command:
+\begin{verbatim}
+# xm save ttylinux ttylinux.xen
+\end{verbatim}
+
+This will stop the domain named `ttylinux' and save its current state
+into a file called \path{ttylinux.xen}.
+
+To resume execution of this domain, use the \path{xm restore} command:
+\begin{verbatim}
+# xm restore ttylinux.xen
+\end{verbatim}
+
+This will restore the state of the domain and restart it.  The domain
+will carry on as before and the console may be reconnected using the
+\path{xm console} command, as above.
+
+\section{Live Migration}
+
+Live migration is used to transfer a domain between physical hosts
+whilst that domain continues to perform its usual activities --- from
+the user's perspective, the migration should be imperceptible.
+
+To perform a live migration, both hosts must be running Xen / \xend\
+and the destination host must have sufficient resources (e.g.\ memory
+capacity) to accommodate the domain after the move. Furthermore we
+currently require both source and destination machines to be on the
+same L2 subnet.
+
+Currently, there is no support for providing automatic remote access
+to filesystems stored on local disk when a domain is migrated.
+Administrators should choose an appropriate storage solution (i.e.\
+SAN, NAS, etc.) to ensure that domain filesystems are also available
+on their destination node. GNBD is a good method for exporting a
+volume from one machine to another. iSCSI can do a similar job, but is
+more complex to set up.
+
+When a domain migrates, it's MAC and IP address move with it, thus it
+is only possible to migrate VMs within the same layer-2 network and IP
+subnet. If the destination node is on a different subnet, the
+administrator would need to manually configure a suitable etherip or
+IP tunnel in the domain~0 of the remote node.
+
+A domain may be migrated using the \path{xm migrate} command.  To live
+migrate a domain to another machine, we would use the command:
+
+\begin{verbatim}
+# xm migrate --live mydomain destination.ournetwork.com
+\end{verbatim}
+
+Without the \path{--live} flag, \xend\ simply stops the domain and
+copies the memory image over to the new node and restarts it. Since
+domains can have large allocations this can be quite time consuming,
+even on a Gigabit network. With the \path{--live} flag \xend\ attempts
+to keep the domain running while the migration is in progress,
+resulting in typical `downtimes' of just 60--300ms.
+
+For now it will be necessary to reconnect to the domain's console on
+the new machine using the \path{xm console} command.  If a migrated
+domain has any open network connections then they will be preserved,
+so SSH connections do not have this limitation.
+
+
+\section{Managing Domain Memory}
+
+XenLinux domains have the ability to relinquish / reclaim machine
+memory at the request of the administrator or the user of the domain.
+
+\subsection{Setting memory footprints from dom0}
+
+The machine administrator can request that a domain alter its memory
+footprint using the \path{xm set-mem} command.  For instance, we can
+request that our example ttylinux domain reduce its memory footprint
+to 32 megabytes.
+
+\begin{verbatim}
+# xm set-mem ttylinux 32
+\end{verbatim}
+
+We can now see the result of this in the output of \path{xm list}:
+
+\begin{verbatim}
+# xm list
+Name              Id  Mem(MB)  CPU  State  Time(s)  Console
+Domain-0           0      251    0  r----    172.2        
+ttylinux           5       31    0  -b---      4.3    9605
+\end{verbatim}
+
+The domain has responded to the request by returning memory to Xen. We
+can restore the domain to its original size using the command line:
+
+\begin{verbatim}
+# xm set-mem ttylinux 64
+\end{verbatim}
+
+\subsection{Setting memory footprints from within a domain}
+
+The virtual file \path{/proc/xen/balloon} allows the owner of a domain
+to adjust their own memory footprint.  Reading the file (e.g.\
+\path{cat /proc/xen/balloon}) prints out the current memory footprint
+of the domain.  Writing the file (e.g.\ \path{echo new\_target >
+  /proc/xen/balloon}) requests that the kernel adjust the domain's
+memory footprint to a new value.
+
+\subsection{Setting memory limits}
+
+Xen associates a memory size limit with each domain.  By default, this
+is the amount of memory the domain is originally started with,
+preventing the domain from ever growing beyond this size.  To permit a
+domain to grow beyond its original allocation or to prevent a domain
+you've shrunk from reclaiming the memory it relinquished, use the
+\path{xm maxmem} command.

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 14%]

* [PATCH 2/2] Update kernel watch API to pass the array of watch arguments to the callback instead of just passing the node.
@ 2005-10-04  4:45 13% Anthony Liguori
  0 siblings, 0 replies; 200+ results
From: Anthony Liguori @ 2005-10-04  4:45 UTC (permalink / raw)
  To: Christian Limpach, Rusty Russell, xen-devel

[-- Attachment #1: Type: text/plain, Size: 244 bytes --]

Update kernel watch API to pass the array of watch arguments to the callback
instead of just passing the node.

This allows us to extend watches to have additional arguments (like domids).

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


[-- Attachment #2: 7163_xs_read_watch.diff --]
[-- Type: text/x-patch, Size: 11348 bytes --]

# HG changeset patch
# User anthony@localhost.localdomain
# Node ID 59fc241f36e5679ac52eec2c01c8f82a736c1567
# Parent  355bc8009bb6cf6be5b0474b84984acf1dda23fb
Update kernel watch API to pass the array of watch arguments to the callback
instead of just passing the node.

This allows us to extend watches to have additional arguments (like domids).

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Oct  3 23:38:00 2005 -0500
@@ -351,7 +351,8 @@
 };
 
 /* React to a change in the target key */
-static void watch_target(struct xenbus_watch *watch, const char *node)
+static void watch_target(struct xenbus_watch *watch,
+			 const char **vec, unsigned int len)
 {
 	unsigned long long new_target;
 	int err;
diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Mon Oct  3 23:38:00 2005 -0500
@@ -55,7 +55,8 @@
 }
 
 /* Front end tells us frame. */
-static void frontend_changed(struct xenbus_watch *watch, const char *node)
+static void frontend_changed(struct xenbus_watch *watch,
+			     const char **vec, unsigned int len)
 {
 	unsigned long ring_ref;
 	unsigned int evtchn;
@@ -64,7 +65,7 @@
 		= container_of(watch, struct backend_info, watch);
 
 	/* If other end is gone, delete ourself. */
-	if (node && !xenbus_exists(be->frontpath, "")) {
+	if (vec && !xenbus_exists(be->frontpath, "")) {
 		device_unregister(&be->dev->dev);
 		return;
 	}
@@ -143,7 +144,8 @@
    We provide event channel and device details to front end.
    Frontend supplies shared frame and event channel.
  */
-static void backend_changed(struct xenbus_watch *watch, const char *node)
+static void backend_changed(struct xenbus_watch *watch,
+			    const char **vec, unsigned int len)
 {
 	int err;
 	char *p;
@@ -195,7 +197,7 @@
 		}
 
 		/* Pass in NULL node to skip exist test. */
-		frontend_changed(&be->watch, NULL);
+		frontend_changed(&be->watch, NULL, 0);
 	}
 }
 
diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Oct  3 23:38:00 2005 -0500
@@ -444,12 +444,16 @@
 	{ "" }
 };
 
-static void watch_for_status(struct xenbus_watch *watch, const char *node)
+static void watch_for_status(struct xenbus_watch *watch,
+			     const char **vec, unsigned int len)
 {
 	struct blkfront_info *info;
 	unsigned int binfo;
 	unsigned long sectors, sector_size;
 	int err;
+	const char *node;
+
+	node = vec[XS_WATCH_PATH];
 
 	info = container_of(watch, struct blkfront_info, watch);
 	node += strlen(watch->node);
@@ -652,8 +656,17 @@
 		return err;
 	}
 
-	/* Call once in case entries already there. */
-	watch_for_status(&info->watch, info->watch.node);
+	{
+		unsigned int len = max(XS_WATCH_PATH, XS_WATCH_TOKEN) + 1;
+		const char *vec[len];
+
+		vec[XS_WATCH_PATH] = info->watch.node;
+		vec[XS_WATCH_TOKEN] = NULL;
+
+		/* Call once in case entries already there. */
+		watch_for_status(&info->watch, vec, len);
+	}
+
 	return 0;
 }
 
diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	Mon Oct  3 23:38:00 2005 -0500
@@ -59,7 +59,8 @@
 }
 
 /* Front end tells us frame. */
-static void frontend_changed(struct xenbus_watch *watch, const char *node)
+static void frontend_changed(struct xenbus_watch *watch,
+			     const char **vec, unsigned int len)
 {
 	unsigned long ring_ref;
 	unsigned int evtchn;
@@ -68,7 +69,7 @@
 		= container_of(watch, struct backend_info, watch);
 
 	/* If other end is gone, delete ourself. */
-	if (node && !xenbus_exists(be->frontpath, "")) {
+	if (vec && !xenbus_exists(be->frontpath, "")) {
 		xenbus_rm(be->dev->nodename, "");
 		device_unregister(&be->dev->dev);
 		return;
@@ -106,7 +107,8 @@
    We provide event channel and device details to front end.
    Frontend supplies shared frame and event channel.
  */
-static void backend_changed(struct xenbus_watch *watch, const char *node)
+static void backend_changed(struct xenbus_watch *watch,
+			    const char **vec, unsigned int len)
 {
 	int err;
 	char *p;
@@ -129,7 +131,7 @@
 		}
 
 		/* Pass in NULL node to skip exist test. */
-		frontend_changed(&be->watch, NULL);
+		frontend_changed(&be->watch, NULL, 0);
 	}
 }
 
diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Mon Oct  3 23:38:00 2005 -0500
@@ -57,7 +57,8 @@
 }
 
 /* Front end tells us frame. */
-static void frontend_changed(struct xenbus_watch *watch, const char *node)
+static void frontend_changed(struct xenbus_watch *watch, 
+			     const char **vec, unsigned int len)
 {
 	unsigned long tx_ring_ref, rx_ring_ref;
 	unsigned int evtchn;
@@ -68,7 +69,7 @@
 	int i;
 
 	/* If other end is gone, delete ourself. */
-	if (node && !xenbus_exists(be->frontpath, "")) {
+	if (vec && !xenbus_exists(be->frontpath, "")) {
 		xenbus_rm(be->dev->nodename, "");
 		device_unregister(&be->dev->dev);
 		return;
@@ -126,7 +127,8 @@
    We provide event channel and device details to front end.
    Frontend supplies shared frame and event channel.
  */
-static void backend_changed(struct xenbus_watch *watch, const char *node)
+static void backend_changed(struct xenbus_watch *watch,
+			    const char **vec, unsigned int len)
 {
 	int err;
 	long int handle;
@@ -163,7 +165,7 @@
 		kobject_hotplug(&dev->dev.kobj, KOBJ_ONLINE);
 
 		/* Pass in NULL node to skip exist test. */
-		frontend_changed(&be->watch, NULL);
+		frontend_changed(&be->watch, NULL, 0);
 	}
 }
 
diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Oct  3 23:38:00 2005 -0500
@@ -966,7 +966,8 @@
 	{ "" }
 };
 
-static void watch_for_status(struct xenbus_watch *watch, const char *node)
+static void watch_for_status(struct xenbus_watch *watch,
+			     const char **vec, unsigned int len)
 {
 }
 
diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Mon Oct  3 23:38:00 2005 -0500
@@ -59,7 +59,8 @@
 }
 
 
-static void frontend_changed(struct xenbus_watch *watch, const char *node)
+static void frontend_changed(struct xenbus_watch *watch,
+			     const char **vec, unsigned int len)
 {
 	unsigned long ringref;
 	unsigned int evtchn;
@@ -69,7 +70,7 @@
 		= container_of(watch, struct backend_info, watch);
 
 	/* If other end is gone, delete ourself. */
-	if (node && !xenbus_exists(be->frontpath, "")) {
+	if (vec && !xenbus_exists(be->frontpath, "")) {
 		xenbus_rm(be->dev->nodename, "");
 		device_unregister(&be->dev->dev);
 		return;
@@ -142,7 +143,8 @@
 }
 
 
-static void backend_changed(struct xenbus_watch *watch, const char *node)
+static void backend_changed(struct xenbus_watch *watch,
+			    const char **vec, unsigned int len)
 {
 	int err;
 	long int instance;
@@ -166,6 +168,9 @@
 	be->instance = instance;
 
 	if (be->tpmif == NULL) {
+		unsigned int len = max(XS_WATCH_PATH, XS_WATCH_TOKEN) + 1;
+		const char *vec[len];
+
 		be->tpmif = tpmif_find(be->frontend_id,
 		                       instance);
 		if (IS_ERR(be->tpmif)) {
@@ -175,8 +180,11 @@
 			return;
 		}
 
+		vec[XS_WATCH_PATH] = be->frontpath;
+		vec[XS_WATCH_TOKEN] = NULL;
+
 		/* Pass in NULL node to skip exist test. */
-		frontend_changed(&be->watch, be->frontpath);
+		frontend_changed(&be->watch, vec, len);
 	}
 }
 
diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Mon Oct  3 23:38:00 2005 -0500
@@ -211,12 +211,14 @@
  XENBUS support code
 **************************************************************/
 
-static void watch_for_status(struct xenbus_watch *watch, const char *node)
+static void watch_for_status(struct xenbus_watch *watch,
+			     const char **vec, unsigned int len)
 {
 	struct tpmfront_info *info;
 	int err;
 	unsigned long ready;
 	struct tpm_private *tp = &my_private;
+	const char *node = vec[XS_WATCH_PATH];
 
 	info = container_of(watch, struct tpmfront_info, watch);
 	node += strlen(watch->node);
diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Oct  3 23:38:00 2005 -0500
@@ -546,14 +546,16 @@
 	kfree(root);
 }
 
-static void frontend_changed(struct xenbus_watch *watch, const char *node)
-{
-	dev_changed(node, &xenbus_frontend);
-}
-
-static void backend_changed(struct xenbus_watch *watch, const char *node)
-{
-	dev_changed(node, &xenbus_backend);
+static void frontend_changed(struct xenbus_watch *watch,
+			     const char **vec, unsigned int len)
+{
+	dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend);
+}
+
+static void backend_changed(struct xenbus_watch *watch,
+			    const char **vec, unsigned int len)
+{
+	dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
 }
 
 /* We watch for devices appearing and vanishing. */
diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Mon Oct  3 23:38:00 2005 -0500
@@ -551,7 +551,7 @@
 				       vec[XS_WATCH_TOKEN], err);
 			w = find_watch(vec[XS_WATCH_TOKEN]);
 			BUG_ON(!w);
-			w->callback(w, vec[XS_WATCH_PATH]);
+			w->callback(w, (const char **)vec, num);
 			kfree(vec);
 		} else if (vec)
 			printk(KERN_WARNING "XENBUS xs_read_watch: %li\n",
diff -r 355bc8009bb6 -r 59fc241f36e5 linux-2.6-xen-sparse/include/asm-xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Mon Oct  3 23:37:48 2005 -0500
+++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h	Mon Oct  3 23:38:00 2005 -0500
@@ -33,6 +33,9 @@
 #include <linux/device.h>
 #include <linux/notifier.h>
 #include <asm/semaphore.h>
+
+/* FIXME there's got to be a better way to get at the XS_WATCH macros */
+#include <asm-xen/linux-public/xenstored.h>
 
 /* A xenbus device. */
 struct xenbus_device {
@@ -113,7 +116,8 @@
 {
 	struct list_head list;
 	char *node;
-	void (*callback)(struct xenbus_watch *, const char *node);
+	void (*callback)(struct xenbus_watch *,
+			 const char **vec, unsigned int len);
 };
 
 /* notifer routines for when the xenstore comes up */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 13%]

* unstable: no ballooning
@ 2005-10-10 10:46 24% Kurt Garloff
  2005-10-12 13:06  6% ` Ewan Mellor
  0 siblings, 1 reply; 200+ results
From: Kurt Garloff @ 2005-10-10 10:46 UTC (permalink / raw)
  To: Xen development list


[-- Attachment #1.1.1: Type: text/plain, Size: 1177 bytes --]

Hi,

when using xm mem-set on current (7278) unstable, you'll see

[2005-10-10 10:25:51 xend] ERROR (SrvBase:87) Request mem_target_set failed.
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/xen/web/SrvBase.py", line 85, in perform
    return op_method(op, req)
  File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvDomain.py", line 132, in op_mem_target_set
    return self.call(self.dom.setMemoryTarget
TypeError: unsubscriptable object

in xend.log.

The fix is trivial, a comma is missing, see (first) attached patch.


HOWEVER, this still does not make balllooning work.
Nobody ever writes to /proc/xen/balloon.

I guess some message should go over xenbus and someone should then 
write to it's balloon file. For dom0, we could do it directly in 
XendDomainInfo.setMemoryTarget(). See attached second patch. It's
a hack and certainly not the right solution.
Who should do it?

Best,
-- 
Kurt Garloff                   <kurt@garloff.de>             [Koeln, DE]
Physics:Plasma modeling <garloff@plasimo.phys.tue.nl> [TU Eindhoven, NL]
Linux: SUSE Labs (Director)    <garloff@suse.de>            [Novell Inc]

[-- Attachment #1.1.2: xen-SrvDomain-typo.diff --]
[-- Type: text/plain, Size: 456 bytes --]

--- xen-unstable/tools/python/xen/xend/server/SrvDomain.py.orig	2005-10-09 21:22:58.000000000 +0200
+++ xen-unstable/tools/python/xen/xend/server/SrvDomain.py	2005-10-10 11:06:50.428679844 +0200
@@ -129,7 +129,7 @@
 
 
     def op_mem_target_set(self, op, req):
-        return self.call(self.dom.setMemoryTarget
+        return self.call(self.dom.setMemoryTarget,
                          [['target', 'int']],
                          req)
 

[-- Attachment #1.1.3: xen-balloon-dom0.diff --]
[-- Type: text/plain, Size: 603 bytes --]

--- xen-unstable/tools/python/xen/xend/XendDomainInfo.py.orig	2005-10-09 21:22:58.000000000 +0200
+++ xen-unstable/tools/python/xen/xend/XendDomainInfo.py	2005-10-10 12:33:45.938319517 +0200
@@ -796,7 +796,10 @@ class XendDomainInfo:
         t = target << 10
         self.info['memory_KiB'] = t
         self.storeDom("memory/target", t)
-
+	# BAD HACK -- this should be done somewhere else !!!
+	if self.domid == 0:
+		balloon = open("/proc/xen/balloon", "w")
+		balloon.write("%iM" % target)
 
     def update(self, info = None):
         """Update with info from xc.domain_getinfo().

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 24%]

* Re: unstable: no ballooning
  2005-10-10 10:46 24% unstable: no ballooning Kurt Garloff
@ 2005-10-12 13:06  6% ` Ewan Mellor
  2005-10-14  8:40  0%   ` Kurt Garloff
  0 siblings, 1 reply; 200+ results
From: Ewan Mellor @ 2005-10-12 13:06 UTC (permalink / raw)
  To: xen-devel; +Cc: Kurt Garloff

On Mon, Oct 10, 2005 at 12:46:39PM +0200, Kurt Garloff wrote:

> Hi,
> 
> when using xm mem-set on current (7278) unstable, you'll see
> 
> [2005-10-10 10:25:51 xend] ERROR (SrvBase:87) Request mem_target_set failed.
> Traceback (most recent call last):
>   File "/usr/lib/python2.4/site-packages/xen/web/SrvBase.py", line 85, in perform
>     return op_method(op, req)
>   File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvDomain.py", line 132, in op_mem_target_set
>     return self.call(self.dom.setMemoryTarget
> TypeError: unsubscriptable object
> 
> in xend.log.
> 
> The fix is trivial, a comma is missing, see (first) attached patch.
> 
> 
> HOWEVER, this still does not make balllooning work.
> Nobody ever writes to /proc/xen/balloon.

Kurt, could you please retest with today's unstable?  I have put your first
patch in (thanks for that) and we have made some changes to the xenstore watch
interface recently, so that may help with the second problem.

The idea is that the memory/target value gets written by Xend, and and the
balloon driver holds a watch on that value in the store.  When the watch
fires, the balloon driver should respond by setting the new target
(drivers/xen/balloon/balloon.c:watch_target).

Watches have been broken in various ways over the last few days, and the bugs
we know about there have now been fixed, so I would be interested to know
whether your bug has been fixed in the process.

Cheers,

Ewan.

^ permalink raw reply	[relevance 6%]

* Re: unstable: no ballooning
  2005-10-12 13:06  6% ` Ewan Mellor
@ 2005-10-14  8:40  0%   ` Kurt Garloff
  2005-10-15  9:26  0%     ` Ewan Mellor
  0 siblings, 1 reply; 200+ results
From: Kurt Garloff @ 2005-10-14  8:40 UTC (permalink / raw)
  To: Ewan Mellor; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 876 bytes --]

Ewan,

On Wed, Oct 12, 2005 at 02:06:13PM +0100, Ewan Mellor wrote:
> Kurt, could you please retest with today's unstable?  I have put your first
> patch in (thanks for that) and we have made some changes to the xenstore watch
> interface recently, so that may help with the second problem.

It seems to work now (tested with 7313), indeed.
Thanks for fixing.

> The idea is that the memory/target value gets written by Xend, and and the
> balloon driver holds a watch on that value in the store.  When the watch
> fires, the balloon driver should respond by setting the new target
> (drivers/xen/balloon/balloon.c:watch_target).

The kernel watches data from a userspace file?
So the kernel understands the tdb/xenstore format?
I wonder whether that's the cleanest way to implement this feature.

Best,
-- 
Kurt Garloff, Director SUSE Labs, Novell Inc.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 0%]

* Re: unstable: no ballooning
  2005-10-14  8:40  0%   ` Kurt Garloff
@ 2005-10-15  9:26  0%     ` Ewan Mellor
  0 siblings, 0 replies; 200+ results
From: Ewan Mellor @ 2005-10-15  9:26 UTC (permalink / raw)
  To: Kurt Garloff, xen-devel

On Fri, Oct 14, 2005 at 10:40:17AM +0200, Kurt Garloff wrote:

> > The idea is that the memory/target value gets written by Xend, and and the
> > balloon driver holds a watch on that value in the store.  When the watch
> > fires, the balloon driver should respond by setting the new target
> > (drivers/xen/balloon/balloon.c:watch_target).
> 
> The kernel watches data from a userspace file?
> So the kernel understands the tdb/xenstore format?
> I wonder whether that's the cleanest way to implement this feature.

It's not a userspace file, as such, but a daemon running in domain 0.  The
daemon isolates domains from the tdb format, exposing a filesystem-style
heirarchical namespace, and maintaining transaction semantics, firing callbacks
when portions of the namespace change, and maintaining an implicit root for
each connection.  It is not necessary for drivers such as the balloon driver
to understand the exact layout of the store, but they do need to know how to
contact the store and the path from the domain's implicit root to the details
in which they are interested.  All changes in domain configuration and state
are handled in this way.

Ewan.

^ permalink raw reply	[relevance 0%]

* [PATCH] kernel /proc information modified for xen mem-set
@ 2005-10-21 11:08 14% Satoshi Uchida
  2005-10-24 17:04  0% ` Vincent Hanquez
  0 siblings, 1 reply; 200+ results
From: Satoshi Uchida @ 2005-10-21 11:08 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1498 bytes --]

Hi.

I interested that memory capacity can be changed.
But, although xen balloon information(/proc/xen/balloon) is modified for
xen mem-set command, 
memory information in domain is not modified.

In actually, MemFree is computed each time, but TotalMem is setup at
boot time.
So, in top command and etc.,  memory used decrease, but memory free
increased.
However, this is not correct, and If anyone see this information, he/she
maybe perplexed.

This patch is reflect TotalMem information.
But, I think that like this solution is not excellent.

Thank you.

from xen_changeset : Wed Oct 19 18:18:30 2005 +0100 7438:fb265175f47c

+++ a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Oct
21 19:51:41 2005
--- b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Oct
21 19:12:33 2005
***************
*** 70,75 ****
--- 70,78 ----
  static unsigned long current_pages;
  static unsigned long target_pages;
  
+ /* VM /proc information for memory */
+ extern unsigned long totalram_pages;
+ 
  /* We may hit the hard limit in Xen. If we do then we remember it. */
  static unsigned long hard_limit;
  
***************
*** 223,228 ****
--- 226,232 ----
  	}
  
  	current_pages += nr_pages;
+ 	totalram_pages = current_pages;
  
   out:
  	balloon_unlock(flags);
***************
*** 295,300 ****
--- 299,305 ----
  		XENMEM_decrease_reservation, &reservation) != nr_pages);
  
  	current_pages -= nr_pages;
+ 	totalram_pages = current_pages;
  
  	balloon_unlock(flags);
  


Satoshi UCHIDA

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 4036 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 14%]

* Re: [PATCH] kernel /proc information modified for xen mem-set
  2005-10-21 11:08 14% [PATCH] kernel /proc information modified for xen mem-set Satoshi Uchida
@ 2005-10-24 17:04  0% ` Vincent Hanquez
  0 siblings, 0 replies; 200+ results
From: Vincent Hanquez @ 2005-10-24 17:04 UTC (permalink / raw)
  To: Satoshi Uchida; +Cc: xen-devel

On Fri, Oct 21, 2005 at 08:08:59PM +0900, Satoshi Uchida wrote:
> I interested that memory capacity can be changed.
> But, although xen balloon information(/proc/xen/balloon) is modified for
> xen mem-set command, 
> memory information in domain is not modified.
> 
> In actually, MemFree is computed each time, but TotalMem is setup at
> boot time.
> So, in top command and etc.,  memory used decrease, but memory free
> increased.
> However, this is not correct, and If anyone see this information, he/she
> maybe perplexed.
> 
> This patch is reflect TotalMem information.
> But, I think that like this solution is not excellent.

its seems fine.

thanks applied.
-- 
Vincent Hanquez

^ permalink raw reply	[relevance 0%]

* [patch] Lets not put statements with side-effects inside BUG_ON()
@ 2005-10-27 10:29 14% Arjan van de Ven
  2005-10-27 17:49  0% ` Kip Macy
  0 siblings, 1 reply; 200+ results
From: Arjan van de Ven @ 2005-10-27 10:29 UTC (permalink / raw)
  To: xen-devel

Hi,

BUG_ON() is a macro very very similar to assert(), and it's a really bad
idea in general to put statements with side-effects inside such a construct
(for example the BUG_ON() could be compiled away for non-debug builds).

The patch below fixes this for the drivers/xen tree.

I chose the general construct to store the respective return values in a
local var instead of an if (...) BUG(); because it looks like most of these
BUG_ON()'s need to be replaced by real error handling when going towards
production releases anyway, and then the local variable is going to be
needed anyway. (and besides the if construct tends to get unreable due to
the unlikely() etc).

Please apply.

Greetings,
   Arjan van de Ven


diff -purN linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	2005-10-26 17:13:26.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	2005-10-27 11:26:28.000000000 +0200
@@ -191,12 +191,13 @@ static int increase_reservation(unsigned
 	rc = HYPERVISOR_memory_op(
 		XENMEM_increase_reservation, &reservation);
 	if (rc < nr_pages) {
+		int ret;
 		/* We hit the Xen hard limit: reprobe. */
 		reservation.extent_start = mfn_list;
 		reservation.nr_extents   = rc;
-		BUG_ON(HYPERVISOR_memory_op(
-			XENMEM_decrease_reservation,
-			&reservation) != rc);
+		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
+				&reservation);
+		BUG_ON(ret != rc);
 		hard_limit = current_pages + rc - driver_pages;
 		goto out;
 	}
@@ -213,11 +214,14 @@ static int increase_reservation(unsigned
 		xen_machphys_update(mfn_list[i], pfn);
             
 		/* Link back into the page tables if not highmem. */
-		if (pfn < max_low_pfn)
-			BUG_ON(HYPERVISOR_update_va_mapping(
+		if (pfn < max_low_pfn) {
+			int ret;
+			ret = HYPERVISOR_update_va_mapping(
 				(unsigned long)__va(pfn << PAGE_SHIFT),
 				pfn_pte_ma(mfn_list[i], PAGE_KERNEL),
-				0));
+				0);
+			BUG_ON(ret);
+		}
 
 		/* Relinquish the page back to the allocator. */
 		ClearPageReserved(page);
@@ -242,6 +246,7 @@ static int decrease_reservation(unsigned
 	struct page   *page;
 	void          *v;
 	int            need_sleep = 0;
+	int ret;
 	struct xen_memory_reservation reservation = {
 		.address_bits = 0,
 		.extent_order = 0,
@@ -268,8 +273,9 @@ static int decrease_reservation(unsigned
 		if (!PageHighMem(page)) {
 			v = phys_to_virt(pfn << PAGE_SHIFT);
 			scrub_pages(v, 1);
-			BUG_ON(HYPERVISOR_update_va_mapping(
-				(unsigned long)v, __pte_ma(0), 0));
+			ret = HYPERVISOR_update_va_mapping(
+				(unsigned long)v, __pte_ma(0), 0);
+			BUG_ON(ret);
 		}
 #ifdef CONFIG_XEN_SCRUB_PAGES
 		else {
@@ -295,8 +301,8 @@ static int decrease_reservation(unsigned
 
 	reservation.extent_start = mfn_list;
 	reservation.nr_extents   = nr_pages;
-	BUG_ON(HYPERVISOR_memory_op(
-		XENMEM_decrease_reservation, &reservation) != nr_pages);
+	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
+	BUG_ON(ret != nr_pages);
 
 	current_pages -= nr_pages;
 	totalram_pages = current_pages;
@@ -501,6 +507,7 @@ static int dealloc_pte_fn(
 	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
 {
 	unsigned long mfn = pte_mfn(*pte);
+	int ret;
 	struct xen_memory_reservation reservation = {
 		.extent_start = &mfn,
 		.nr_extents   = 1,
@@ -510,8 +517,8 @@ static int dealloc_pte_fn(
 	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
 	phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
 		INVALID_P2M_ENTRY;
-	BUG_ON(HYPERVISOR_memory_op(
-		XENMEM_decrease_reservation, &reservation) != 1);
+	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
+	BUG_ON(ret != 1);
 	return 0;
 }
 
@@ -519,6 +526,7 @@ struct page *balloon_alloc_empty_page_ra
 {
 	unsigned long vstart, flags;
 	unsigned int  order = get_order(nr_pages * PAGE_SIZE);
+	int ret;
 
 	vstart = __get_free_pages(GFP_KERNEL, order);
 	if (vstart == 0)
@@ -527,8 +535,9 @@ struct page *balloon_alloc_empty_page_ra
 	scrub_pages(vstart, 1 << order);
 
 	balloon_lock(flags);
-	BUG_ON(generic_page_range(
-		&init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL));
+	ret = generic_page_range(
+		&init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL);
+	BUG_ON(ret);
 	current_pages -= 1UL << order;
 	balloon_unlock(flags);
 
diff -purN linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	2005-10-22 10:12:23.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	2005-10-27 11:16:54.000000000 +0200
@@ -108,6 +108,7 @@ static void fast_flush_area(int idx, int
 	struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	unsigned int i, invcount = 0;
 	u16 handle;
+	int ret;
 
 	for (i = 0; i < nr_pages; i++) {
 		handle = pending_handle(idx, i);
@@ -120,8 +121,9 @@ static void fast_flush_area(int idx, int
 		invcount++;
 	}
 
-	BUG_ON(HYPERVISOR_grant_table_op(
-		GNTTABOP_unmap_grant_ref, unmap, invcount));
+	ret = HYPERVISOR_grant_table_op(
+		GNTTABOP_unmap_grant_ref, unmap, invcount);
+	BUG_ON(ret);
 }
 
 
@@ -338,6 +340,7 @@ static void dispatch_rw_block_io(blkif_t
 	struct bio *bio = NULL, *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	int nbio = 0;
 	request_queue_t *q;
+	int ret;
 
 	/* Check that number of segments is sane. */
 	nseg = req->nr_segments;
@@ -367,8 +370,8 @@ static void dispatch_rw_block_io(blkif_t
 			map[i].flags |= GNTMAP_readonly;
 	}
 
-	BUG_ON(HYPERVISOR_grant_table_op(
-		GNTTABOP_map_grant_ref, map, nseg));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, nseg);
+	BUG_ON(ret);
 
 	for (i = 0; i < nseg; i++) {
 		if (unlikely(map[i].handle < 0)) {
@@ -493,6 +496,7 @@ static int __init blkif_init(void)
 {
 	int i;
 	struct page *page;
+	int ret;
 
 	blkif_interface_init();
 
@@ -509,7 +513,8 @@ static int __init blkif_init(void)
 	spin_lock_init(&blkio_schedule_list_lock);
 	INIT_LIST_HEAD(&blkio_schedule_list);
 
-	BUG_ON(kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES) < 0);
+	ret = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
+	BUG_ON(ret < 0);
 
 	blkif_xenbus_init();
 
diff -purN linux-2.6-xen-sparse/drivers/xen/blkback/interface.c linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	2005-10-22 10:12:24.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	2005-10-27 11:17:29.000000000 +0200
@@ -31,6 +31,7 @@ blkif_t *alloc_blkif(domid_t domid)
 static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
 {
 	struct gnttab_map_grant_ref op;
+	int ret;
 
 	op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
 	op.flags     = GNTMAP_host_map;
@@ -38,8 +39,9 @@ static int map_frontend_page(blkif_t *bl
 	op.dom       = blkif->domid;
 
 	lock_vm_area(blkif->blk_ring_area);
-	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
 	unlock_vm_area(blkif->blk_ring_area);
+	BUG_ON(ret);
 
 	if (op.handle < 0) {
 		DPRINTK(" Grant table operation failure !\n");
@@ -55,14 +57,16 @@ static int map_frontend_page(blkif_t *bl
 static void unmap_frontend_page(blkif_t *blkif)
 {
 	struct gnttab_unmap_grant_ref op;
+	int ret;
 
 	op.host_addr    = (unsigned long)blkif->blk_ring_area->addr;
 	op.handle       = blkif->shmem_handle;
 	op.dev_bus_addr = 0;
 
 	lock_vm_area(blkif->blk_ring_area);
-	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
 	unlock_vm_area(blkif->blk_ring_area);
+	BUG_ON(ret);
 }
 
 int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
diff -purN linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	2005-10-22 10:12:27.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	2005-10-27 11:15:41.000000000 +0200
@@ -305,6 +305,7 @@ static irqreturn_t blkif_int(int irq, vo
 
 	for (i = info->ring.rsp_cons; i != rp; i++) {
 		unsigned long id;
+		int ret;
 
 		bret = RING_GET_RESPONSE(&info->ring, i);
 		id   = bret->id;
@@ -321,9 +322,10 @@ static irqreturn_t blkif_int(int irq, vo
 				DPRINTK("Bad return from blkdev data "
 					"request: %x\n", bret->status);
 
-			BUG_ON(end_that_request_first(
+			ret = end_that_request_first(
 				req, (bret->status == BLKIF_RSP_OKAY),
-				req->hard_nr_sectors));
+				req->hard_nr_sectors);
+			BUG_ON(ret);
 			end_that_request_last(req);
 			break;
 		default:
diff -purN linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	2005-10-22 10:12:30.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	2005-10-27 11:19:42.000000000 +0200
@@ -413,6 +413,7 @@ static void fast_flush_area(int idx, int
 	unsigned int i, op = 0;
 	struct grant_handle_pair *handle;
 	unsigned long ptep;
+	int ret;
 
 	for ( i = 0; i < nr_pages; i++)
 	{
@@ -440,8 +441,8 @@ static void fast_flush_area(int idx, int
 		BLKTAP_INVALIDATE_HANDLE(handle);
 	}
 
-	BUG_ON(HYPERVISOR_grant_table_op(
-		GNTTABOP_unmap_grant_ref, unmap, op));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, op);
+	BUG_ON(ret);
 
 	if (blktap_vma != NULL)
 		zap_page_range(blktap_vma, 
@@ -673,6 +674,7 @@ static void dispatch_rw_block_io(blkif_t
 	struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
 	int op, ret;
 	unsigned int nseg;
+	int retval;
 
 	/* Check that number of segments is sane. */
 	nseg = req->nr_segments;
@@ -740,8 +742,8 @@ static void dispatch_rw_block_io(blkif_t
 		op++;
 	}
 
-	BUG_ON(HYPERVISOR_grant_table_op(
-		GNTTABOP_map_grant_ref, map, op));
+	retval = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
+	BUG_ON(retval);
 
 	op = 0;
 	for (i = 0; i < (req->nr_segments*2); i += 2) {
@@ -877,7 +879,8 @@ static int __init blkif_init(void)
 	spin_lock_init(&blkio_schedule_list_lock);
 	INIT_LIST_HEAD(&blkio_schedule_list);
 
-	BUG_ON(kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES) < 0);
+	i = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
+	BUG_ON(i<0);
 
 	blkif_xenbus_init();
 
diff -purN linux-2.6-xen-sparse/drivers/xen/blktap/interface.c linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	2005-10-22 10:12:31.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	2005-10-27 11:20:19.000000000 +0200
@@ -31,6 +31,7 @@ blkif_t *alloc_blkif(domid_t domid)
 static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
 {
 	struct gnttab_map_grant_ref op;
+	int ret;
 
 	op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
 	op.flags     = GNTMAP_host_map;
@@ -38,8 +39,9 @@ static int map_frontend_page(blkif_t *bl
 	op.dom       = blkif->domid;
 
 	lock_vm_area(blkif->blk_ring_area);
-	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
 	unlock_vm_area(blkif->blk_ring_area);
+	BUG_ON(ret);
 
 	if (op.handle < 0) {
 		DPRINTK(" Grant table operation failure !\n");
@@ -55,14 +57,16 @@ static int map_frontend_page(blkif_t *bl
 static void unmap_frontend_page(blkif_t *blkif)
 {
 	struct gnttab_unmap_grant_ref op;
+	int ret;
 
 	op.host_addr    = (unsigned long)blkif->blk_ring_area->addr;
 	op.handle       = blkif->shmem_handle;
 	op.dev_bus_addr = 0;
 
 	lock_vm_area(blkif->blk_ring_area);
-	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
 	unlock_vm_area(blkif->blk_ring_area);
+	BUG_ON(ret);
 }
 
 int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
diff -purN linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c
--- linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	2005-10-22 10:12:37.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	2005-10-27 11:27:29.000000000 +0200
@@ -282,6 +282,7 @@ static int evtchn_ioctl(struct inode *in
 
 	case IOCTL_EVTCHN_UNBIND: {
 		struct ioctl_evtchn_unbind unbind;
+		int ret;
 
 		rc = -EFAULT;
 		if (copy_from_user(&unbind, (void *)arg, sizeof(unbind)))
@@ -306,7 +307,8 @@ static int evtchn_ioctl(struct inode *in
 
 		op.cmd = EVTCHNOP_close;
 		op.u.close.port = unbind.port;
-		BUG_ON(HYPERVISOR_event_channel_op(&op));
+		ret = HYPERVISOR_event_channel_op(&op);
+		BUG_ON(ret);
 
 		rc = 0;
 		break;
@@ -399,6 +401,7 @@ static int evtchn_release(struct inode *
 
 	for (i = 0; i < NR_EVENT_CHANNELS; i++)
 	{
+		int ret;
 		if (port_user[i] != u)
 			continue;
 
@@ -407,7 +410,8 @@ static int evtchn_release(struct inode *
 
 		op.cmd = EVTCHNOP_close;
 		op.u.close.port = i;
-		BUG_ON(HYPERVISOR_event_channel_op(&op));
+		ret = HYPERVISOR_event_channel_op(&op);
+		BUG_ON(ret);
 	}
 
 	spin_unlock_irq(&port_user_lock);
diff -purN linux-2.6-xen-sparse/drivers/xen/netback/interface.c linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- linux-2.6-xen-sparse/drivers/xen/netback/interface.c	2005-10-22 10:12:38.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/netback/interface.c	2005-10-27 11:10:20.000000000 +0200
@@ -115,6 +115,7 @@ static int map_frontend_pages(
 	netif_t *netif, grant_ref_t tx_ring_ref, grant_ref_t rx_ring_ref)
 {
 	struct gnttab_map_grant_ref op;
+	int ret;
 
 	op.host_addr = (unsigned long)netif->comms_area->addr;
 	op.flags     = GNTMAP_host_map;
@@ -122,8 +123,9 @@ static int map_frontend_pages(
 	op.dom       = netif->domid;
     
 	lock_vm_area(netif->comms_area);
-	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
 	unlock_vm_area(netif->comms_area);
+	BUG_ON(ret);
 
 	if (op.handle < 0) { 
 		DPRINTK(" Gnttab failure mapping tx_ring_ref!\n");
@@ -139,8 +141,9 @@ static int map_frontend_pages(
 	op.dom       = netif->domid;
 
 	lock_vm_area(netif->comms_area);
-	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
 	unlock_vm_area(netif->comms_area);
+	BUG_ON(ret);
 
 	if (op.handle < 0) { 
 		DPRINTK(" Gnttab failure mapping rx_ring_ref!\n");
@@ -156,22 +159,25 @@ static int map_frontend_pages(
 static void unmap_frontend_pages(netif_t *netif)
 {
 	struct gnttab_unmap_grant_ref op;
+	int ret;
 
 	op.host_addr    = (unsigned long)netif->comms_area->addr;
 	op.handle       = netif->tx_shmem_handle;
 	op.dev_bus_addr = 0;
 
 	lock_vm_area(netif->comms_area);
-	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
 	unlock_vm_area(netif->comms_area);
+	BUG_ON(ret);
 
 	op.host_addr    = (unsigned long)netif->comms_area->addr + PAGE_SIZE;
 	op.handle       = netif->rx_shmem_handle;
 	op.dev_bus_addr = 0;
 
 	lock_vm_area(netif->comms_area);
-	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
 	unlock_vm_area(netif->comms_area);
+	BUG_ON(ret);
 }
 
 int netif_map(netif_t *netif, unsigned long tx_ring_ref,
diff -purN linux-2.6-xen-sparse/drivers/xen/netback/netback.c linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- linux-2.6-xen-sparse/drivers/xen/netback/netback.c	2005-10-22 10:12:39.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/netback/netback.c	2005-10-27 11:12:42.000000000 +0200
@@ -112,9 +112,12 @@ static void free_mfn(unsigned long mfn)
 	spin_lock_irqsave(&mfn_lock, flags);
 	if ( alloc_index != MAX_MFN_ALLOC )
 		mfn_list[alloc_index++] = mfn;
-	else
-		BUG_ON(HYPERVISOR_memory_op(XENMEM_decrease_reservation,
-					    &reservation) != 1);
+	else {
+		int ret;
+		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
+					    &reservation);
+		BUG_ON(ret != 1);
+	}
 	spin_unlock_irqrestore(&mfn_lock, flags);
 }
 #endif
@@ -159,13 +162,15 @@ int netif_be_start_xmit(struct sk_buff *
 	 */
 	if (skb_shared(skb) || skb_cloned(skb) || !is_xen_skb(skb)) {
 		int hlen = skb->data - skb->head;
+		int ret;
 		struct sk_buff *nskb = dev_alloc_skb(hlen + skb->len);
 		if ( unlikely(nskb == NULL) )
 			goto drop;
 		skb_reserve(nskb, hlen);
 		__skb_put(nskb, skb->len);
-		BUG_ON(skb_copy_bits(skb, -hlen, nskb->data - hlen,
-				     skb->len + hlen));
+		ret = skb_copy_bits(skb, -hlen, nskb->data - hlen,
+				     skb->len + hlen);
+		BUG_ON(ret);
 		nskb->dev = skb->dev;
 		nskb->proto_csum_valid = skb->proto_csum_valid;
 		dev_kfree_skb(skb);
@@ -218,6 +223,7 @@ static void net_rx_action(unsigned long 
 	struct sk_buff *skb;
 	u16 notify_list[NETIF_RX_RING_SIZE];
 	int notify_nr = 0;
+	int ret;
 
 	skb_queue_head_init(&rxq);
 
@@ -279,7 +285,8 @@ static void net_rx_action(unsigned long 
 	mcl++;
 
 	mcl[-2].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL;
-	BUG_ON(HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl) != 0);
+	ret = HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl);
+	BUG_ON(ret != 0);
 
 	mcl = rx_mcl;
 	if( HYPERVISOR_grant_table_op(GNTTABOP_transfer, grant_rx_op, 
@@ -421,6 +428,7 @@ inline static void net_tx_action_dealloc
 	u16 pending_idx;
 	PEND_RING_IDX dc, dp;
 	netif_t *netif;
+	int ret;
 
 	dc = dealloc_cons;
 	dp = dealloc_prod;
@@ -436,8 +444,9 @@ inline static void net_tx_action_dealloc
 		gop->handle       = grant_tx_ref[pending_idx];
 		gop++;
 	}
-	BUG_ON(HYPERVISOR_grant_table_op(
-		GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops));
+	ret = HYPERVISOR_grant_table_op(
+		GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops);
+	BUG_ON(ret);
 
 	while (dealloc_cons != dp) {
 		pending_idx = dealloc_ring[MASK_PEND_IDX(dealloc_cons++)];
@@ -477,6 +486,7 @@ static void net_tx_action(unsigned long 
 	NETIF_RING_IDX i;
 	gnttab_map_grant_ref_t *mop;
 	unsigned int data_len;
+	int ret;
 
 	if (dealloc_cons != dealloc_prod)
 		net_tx_action_dealloc();
@@ -599,8 +609,9 @@ static void net_tx_action(unsigned long 
 	if (mop == tx_map_ops)
 		return;
 
-	BUG_ON(HYPERVISOR_grant_table_op(
-		GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops));
+	ret = HYPERVISOR_grant_table_op(
+		GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);
+	BUG_ON(ret);
 
 	mop = tx_map_ops;
 	while ((skb = __skb_dequeue(&tx_queue)) != NULL) {
diff -purN linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	2005-10-22 10:13:08.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	2005-10-27 11:28:17.000000000 +0200
@@ -78,6 +78,7 @@ tpmif_find(domid_t domid, long int insta
 static int
 map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
 {
+	int ret;
 	struct gnttab_map_grant_ref op = {
 		.host_addr = (unsigned long)tpmif->tx_area->addr,
 		.flags = GNTMAP_host_map,
@@ -86,8 +87,9 @@ map_frontend_page(tpmif_t *tpmif, unsign
 	};
 
 	lock_vm_area(tpmif->tx_area);
-	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
 	unlock_vm_area(tpmif->tx_area);
+	BUG_ON(ret);
 
 	if (op.handle < 0) {
 		DPRINTK(" Grant table operation failure !\n");
@@ -104,14 +106,16 @@ static void
 unmap_frontend_page(tpmif_t *tpmif)
 {
 	struct gnttab_unmap_grant_ref op;
+	int ret;
 
 	op.host_addr    = (unsigned long)tpmif->tx_area->addr;
 	op.handle       = tpmif->shmem_handle;
 	op.dev_bus_addr = 0;
 
 	lock_vm_area(tpmif->tx_area);
-	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
 	unlock_vm_area(tpmif->tx_area);
+	BUG_ON(ret);
 }
 
 int
diff -purN linux-2.6-xen-sparse/drivers/xen/util.c linux-2.6-xen-sparse/drivers/xen/util.c
--- linux-2.6-xen-sparse/drivers/xen/util.c	2005-10-22 10:13:14.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/util.c	2005-10-27 11:28:49.000000000 +0200
@@ -34,7 +34,9 @@ struct vm_struct *alloc_vm_area(unsigned
 
 void free_vm_area(struct vm_struct *area)
 {
-	BUG_ON(remove_vm_area(area->addr) != area);
+	struct vm_struct *ret;
+	ret = remove_vm_area(area->addr);
+	BUG_ON(ret != area);
 	kfree(area);
 }
 
diff -purN linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	2005-10-22 10:13:18.000000000 +0200
+++ linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	2005-10-27 11:29:33.000000000 +0200
@@ -737,6 +737,7 @@ static int __init xenbus_probe_init(void
 
 		unsigned long page;
 		evtchn_op_t op = { 0 };
+		int ret;
 
 
 		/* Allocate page. */
@@ -757,7 +758,8 @@ static int __init xenbus_probe_init(void
 		op.u.alloc_unbound.dom        = DOMID_SELF;
 		op.u.alloc_unbound.remote_dom = 0; 
 
-		BUG_ON(HYPERVISOR_event_channel_op(&op)); 
+		ret = HYPERVISOR_event_channel_op(&op);
+		BUG_ON(ret); 
 		xen_start_info->store_evtchn = op.u.alloc_unbound.port;
 
 		/* And finally publish the above info in /proc/xen */

^ permalink raw reply	[relevance 14%]

* Re: [patch] Lets not put statements with side-effects inside BUG_ON()
  2005-10-27 10:29 14% [patch] Lets not put statements with side-effects inside BUG_ON() Arjan van de Ven
@ 2005-10-27 17:49  0% ` Kip Macy
  0 siblings, 0 replies; 200+ results
From: Kip Macy @ 2005-10-27 17:49 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 21955 bytes --]

The intention is to panic if an operation that should *never* fail (debug or
release) does in fact fail. It isn't debug scaffolding like an assert.

-Kip


On 10/27/05, Arjan van de Ven <arjanv@redhat.com> wrote:
>
> Hi,
>
> BUG_ON() is a macro very very similar to assert(), and it's a really bad
> idea in general to put statements with side-effects inside such a
> construct
> (for example the BUG_ON() could be compiled away for non-debug builds).
>
> The patch below fixes this for the drivers/xen tree.
>
> I chose the general construct to store the respective return values in a
> local var instead of an if (...) BUG(); because it looks like most of
> these
> BUG_ON()'s need to be replaced by real error handling when going towards
> production releases anyway, and then the local variable is going to be
> needed anyway. (and besides the if construct tends to get unreable due to
> the unlikely() etc).
>
> Please apply.
>
> Greetings,
> Arjan van de Ven
>
>
> diff -purN linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
> linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
> --- linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c 2005-10-26 17:13:
> 26.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c 2005-10-27 11:26:
> 28.000000000 +0200
> @@ -191,12 +191,13 @@ static int increase_reservation(unsigned
> rc = HYPERVISOR_memory_op(
> XENMEM_increase_reservation, &reservation);
> if (rc < nr_pages) {
> + int ret;
> /* We hit the Xen hard limit: reprobe. */
> reservation.extent_start = mfn_list;
> reservation.nr_extents = rc;
> - BUG_ON(HYPERVISOR_memory_op(
> - XENMEM_decrease_reservation,
> - &reservation) != rc);
> + ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
> + &reservation);
> + BUG_ON(ret != rc);
> hard_limit = current_pages + rc - driver_pages;
> goto out;
> }
> @@ -213,11 +214,14 @@ static int increase_reservation(unsigned
> xen_machphys_update(mfn_list[i], pfn);
>
> /* Link back into the page tables if not highmem. */
> - if (pfn < max_low_pfn)
> - BUG_ON(HYPERVISOR_update_va_mapping(
> + if (pfn < max_low_pfn) {
> + int ret;
> + ret = HYPERVISOR_update_va_mapping(
> (unsigned long)__va(pfn << PAGE_SHIFT),
> pfn_pte_ma(mfn_list[i], PAGE_KERNEL),
> - 0));
> + 0);
> + BUG_ON(ret);
> + }
>
> /* Relinquish the page back to the allocator. */
> ClearPageReserved(page);
> @@ -242,6 +246,7 @@ static int decrease_reservation(unsigned
> struct page *page;
> void *v;
> int need_sleep = 0;
> + int ret;
> struct xen_memory_reservation reservation = {
> .address_bits = 0,
> .extent_order = 0,
> @@ -268,8 +273,9 @@ static int decrease_reservation(unsigned
> if (!PageHighMem(page)) {
> v = phys_to_virt(pfn << PAGE_SHIFT);
> scrub_pages(v, 1);
> - BUG_ON(HYPERVISOR_update_va_mapping(
> - (unsigned long)v, __pte_ma(0), 0));
> + ret = HYPERVISOR_update_va_mapping(
> + (unsigned long)v, __pte_ma(0), 0);
> + BUG_ON(ret);
> }
> #ifdef CONFIG_XEN_SCRUB_PAGES
> else {
> @@ -295,8 +301,8 @@ static int decrease_reservation(unsigned
>
> reservation.extent_start = mfn_list;
> reservation.nr_extents = nr_pages;
> - BUG_ON(HYPERVISOR_memory_op(
> - XENMEM_decrease_reservation, &reservation) != nr_pages);
> + ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
> + BUG_ON(ret != nr_pages);
>
> current_pages -= nr_pages;
> totalram_pages = current_pages;
> @@ -501,6 +507,7 @@ static int dealloc_pte_fn(
> pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
> {
> unsigned long mfn = pte_mfn(*pte);
> + int ret;
> struct xen_memory_reservation reservation = {
> .extent_start = &mfn,
> .nr_extents = 1,
> @@ -510,8 +517,8 @@ static int dealloc_pte_fn(
> set_pte_at(&init_mm, addr, pte, __pte_ma(0));
> phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
> INVALID_P2M_ENTRY;
> - BUG_ON(HYPERVISOR_memory_op(
> - XENMEM_decrease_reservation, &reservation) != 1);
> + ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
> + BUG_ON(ret != 1);
> return 0;
> }
>
> @@ -519,6 +526,7 @@ struct page *balloon_alloc_empty_page_ra
> {
> unsigned long vstart, flags;
> unsigned int order = get_order(nr_pages * PAGE_SIZE);
> + int ret;
>
> vstart = __get_free_pages(GFP_KERNEL, order);
> if (vstart == 0)
> @@ -527,8 +535,9 @@ struct page *balloon_alloc_empty_page_ra
> scrub_pages(vstart, 1 << order);
>
> balloon_lock(flags);
> - BUG_ON(generic_page_range(
> - &init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL));
> + ret = generic_page_range(
> + &init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL);
> + BUG_ON(ret);
> current_pages -= 1UL << order;
> balloon_unlock(flags);
>
> diff -purN linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
> linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
> --- linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c 2005-10-22 10:12:
> 23.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c 2005-10-27 11:16:
> 54.000000000 +0200
> @@ -108,6 +108,7 @@ static void fast_flush_area(int idx, int
> struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
> unsigned int i, invcount = 0;
> u16 handle;
> + int ret;
>
> for (i = 0; i < nr_pages; i++) {
> handle = pending_handle(idx, i);
> @@ -120,8 +121,9 @@ static void fast_flush_area(int idx, int
> invcount++;
> }
>
> - BUG_ON(HYPERVISOR_grant_table_op(
> - GNTTABOP_unmap_grant_ref, unmap, invcount));
> + ret = HYPERVISOR_grant_table_op(
> + GNTTABOP_unmap_grant_ref, unmap, invcount);
> + BUG_ON(ret);
> }
>
>
> @@ -338,6 +340,7 @@ static void dispatch_rw_block_io(blkif_t
> struct bio *bio = NULL, *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
> int nbio = 0;
> request_queue_t *q;
> + int ret;
>
> /* Check that number of segments is sane. */
> nseg = req->nr_segments;
> @@ -367,8 +370,8 @@ static void dispatch_rw_block_io(blkif_t
> map[i].flags |= GNTMAP_readonly;
> }
>
> - BUG_ON(HYPERVISOR_grant_table_op(
> - GNTTABOP_map_grant_ref, map, nseg));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, nseg);
> + BUG_ON(ret);
>
> for (i = 0; i < nseg; i++) {
> if (unlikely(map[i].handle < 0)) {
> @@ -493,6 +496,7 @@ static int __init blkif_init(void)
> {
> int i;
> struct page *page;
> + int ret;
>
> blkif_interface_init();
>
> @@ -509,7 +513,8 @@ static int __init blkif_init(void)
> spin_lock_init(&blkio_schedule_list_lock);
> INIT_LIST_HEAD(&blkio_schedule_list);
>
> - BUG_ON(kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES) < 0);
> + ret = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
> + BUG_ON(ret < 0);
>
> blkif_xenbus_init();
>
> diff -purN linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
> linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
> --- linux-2.6-xen-sparse/drivers/xen/blkback/interface.c 2005-10-22 10:12:
> 24.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/blkback/interface.c 2005-10-27 11:17:
> 29.000000000 +0200
> @@ -31,6 +31,7 @@ blkif_t *alloc_blkif(domid_t domid)
> static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
> {
> struct gnttab_map_grant_ref op;
> + int ret;
>
> op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
> op.flags = GNTMAP_host_map;
> @@ -38,8 +39,9 @@ static int map_frontend_page(blkif_t *bl
> op.dom = blkif->domid;
>
> lock_vm_area(blkif->blk_ring_area);
> - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
> unlock_vm_area(blkif->blk_ring_area);
> + BUG_ON(ret);
>
> if (op.handle < 0) {
> DPRINTK(" Grant table operation failure !\n");
> @@ -55,14 +57,16 @@ static int map_frontend_page(blkif_t *bl
> static void unmap_frontend_page(blkif_t *blkif)
> {
> struct gnttab_unmap_grant_ref op;
> + int ret;
>
> op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
> op.handle = blkif->shmem_handle;
> op.dev_bus_addr = 0;
>
> lock_vm_area(blkif->blk_ring_area);
> - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
> unlock_vm_area(blkif->blk_ring_area);
> + BUG_ON(ret);
> }
>
> int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int
> evtchn)
> diff -purN linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
> linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
> --- linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c 2005-10-22 10:12:
> 27.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c 2005-10-27 11:15:
> 41.000000000 +0200
> @@ -305,6 +305,7 @@ static irqreturn_t blkif_int(int irq, vo
>
> for (i = info->ring.rsp_cons; i != rp; i++) {
> unsigned long id;
> + int ret;
>
> bret = RING_GET_RESPONSE(&info->ring, i);
> id = bret->id;
> @@ -321,9 +322,10 @@ static irqreturn_t blkif_int(int irq, vo
> DPRINTK("Bad return from blkdev data "
> "request: %x\n", bret->status);
>
> - BUG_ON(end_that_request_first(
> + ret = end_that_request_first(
> req, (bret->status == BLKIF_RSP_OKAY),
> - req->hard_nr_sectors));
> + req->hard_nr_sectors);
> + BUG_ON(ret);
> end_that_request_last(req);
> break;
> default:
> diff -purN linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
> linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
> --- linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c 2005-10-22 10:12:
> 30.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c 2005-10-27 11:19:
> 42.000000000 +0200
> @@ -413,6 +413,7 @@ static void fast_flush_area(int idx, int
> unsigned int i, op = 0;
> struct grant_handle_pair *handle;
> unsigned long ptep;
> + int ret;
>
> for ( i = 0; i < nr_pages; i++)
> {
> @@ -440,8 +441,8 @@ static void fast_flush_area(int idx, int
> BLKTAP_INVALIDATE_HANDLE(handle);
> }
>
> - BUG_ON(HYPERVISOR_grant_table_op(
> - GNTTABOP_unmap_grant_ref, unmap, op));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, op);
> + BUG_ON(ret);
>
> if (blktap_vma != NULL)
> zap_page_range(blktap_vma,
> @@ -673,6 +674,7 @@ static void dispatch_rw_block_io(blkif_t
> struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
> int op, ret;
> unsigned int nseg;
> + int retval;
>
> /* Check that number of segments is sane. */
> nseg = req->nr_segments;
> @@ -740,8 +742,8 @@ static void dispatch_rw_block_io(blkif_t
> op++;
> }
>
> - BUG_ON(HYPERVISOR_grant_table_op(
> - GNTTABOP_map_grant_ref, map, op));
> + retval = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
> + BUG_ON(retval);
>
> op = 0;
> for (i = 0; i < (req->nr_segments*2); i += 2) {
> @@ -877,7 +879,8 @@ static int __init blkif_init(void)
> spin_lock_init(&blkio_schedule_list_lock);
> INIT_LIST_HEAD(&blkio_schedule_list);
>
> - BUG_ON(kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES) < 0);
> + i = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
> + BUG_ON(i<0);
>
> blkif_xenbus_init();
>
> diff -purN linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
> linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
> --- linux-2.6-xen-sparse/drivers/xen/blktap/interface.c 2005-10-22 10:12:
> 31.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/blktap/interface.c 2005-10-27 11:20:
> 19.000000000 +0200
> @@ -31,6 +31,7 @@ blkif_t *alloc_blkif(domid_t domid)
> static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
> {
> struct gnttab_map_grant_ref op;
> + int ret;
>
> op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
> op.flags = GNTMAP_host_map;
> @@ -38,8 +39,9 @@ static int map_frontend_page(blkif_t *bl
> op.dom = blkif->domid;
>
> lock_vm_area(blkif->blk_ring_area);
> - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
> unlock_vm_area(blkif->blk_ring_area);
> + BUG_ON(ret);
>
> if (op.handle < 0) {
> DPRINTK(" Grant table operation failure !\n");
> @@ -55,14 +57,16 @@ static int map_frontend_page(blkif_t *bl
> static void unmap_frontend_page(blkif_t *blkif)
> {
> struct gnttab_unmap_grant_ref op;
> + int ret;
>
> op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
> op.handle = blkif->shmem_handle;
> op.dev_bus_addr = 0;
>
> lock_vm_area(blkif->blk_ring_area);
> - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
> unlock_vm_area(blkif->blk_ring_area);
> + BUG_ON(ret);
> }
>
> int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int
> evtchn)
> diff -purN linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c
> linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c
> --- linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c 2005-10-22 10:12:
> 37.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c 2005-10-27 11:27:
> 29.000000000 +0200
> @@ -282,6 +282,7 @@ static int evtchn_ioctl(struct inode *in
>
> case IOCTL_EVTCHN_UNBIND: {
> struct ioctl_evtchn_unbind unbind;
> + int ret;
>
> rc = -EFAULT;
> if (copy_from_user(&unbind, (void *)arg, sizeof(unbind)))
> @@ -306,7 +307,8 @@ static int evtchn_ioctl(struct inode *in
>
> op.cmd = EVTCHNOP_close;
> op.u.close.port = unbind.port;
> - BUG_ON(HYPERVISOR_event_channel_op(&op));
> + ret = HYPERVISOR_event_channel_op(&op);
> + BUG_ON(ret);
>
> rc = 0;
> break;
> @@ -399,6 +401,7 @@ static int evtchn_release(struct inode *
>
> for (i = 0; i < NR_EVENT_CHANNELS; i++)
> {
> + int ret;
> if (port_user[i] != u)
> continue;
>
> @@ -407,7 +410,8 @@ static int evtchn_release(struct inode *
>
> op.cmd = EVTCHNOP_close;
> op.u.close.port = i;
> - BUG_ON(HYPERVISOR_event_channel_op(&op));
> + ret = HYPERVISOR_event_channel_op(&op);
> + BUG_ON(ret);
> }
>
> spin_unlock_irq(&port_user_lock);
> diff -purN linux-2.6-xen-sparse/drivers/xen/netback/interface.c
> linux-2.6-xen-sparse/drivers/xen/netback/interface.c
> --- linux-2.6-xen-sparse/drivers/xen/netback/interface.c 2005-10-22 10:12:
> 38.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/netback/interface.c 2005-10-27 11:10:
> 20.000000000 +0200
> @@ -115,6 +115,7 @@ static int map_frontend_pages(
> netif_t *netif, grant_ref_t tx_ring_ref, grant_ref_t rx_ring_ref)
> {
> struct gnttab_map_grant_ref op;
> + int ret;
>
> op.host_addr = (unsigned long)netif->comms_area->addr;
> op.flags = GNTMAP_host_map;
> @@ -122,8 +123,9 @@ static int map_frontend_pages(
> op.dom = netif->domid;
>
> lock_vm_area(netif->comms_area);
> - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
> unlock_vm_area(netif->comms_area);
> + BUG_ON(ret);
>
> if (op.handle < 0) {
> DPRINTK(" Gnttab failure mapping tx_ring_ref!\n");
> @@ -139,8 +141,9 @@ static int map_frontend_pages(
> op.dom = netif->domid;
>
> lock_vm_area(netif->comms_area);
> - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
> unlock_vm_area(netif->comms_area);
> + BUG_ON(ret);
>
> if (op.handle < 0) {
> DPRINTK(" Gnttab failure mapping rx_ring_ref!\n");
> @@ -156,22 +159,25 @@ static int map_frontend_pages(
> static void unmap_frontend_pages(netif_t *netif)
> {
> struct gnttab_unmap_grant_ref op;
> + int ret;
>
> op.host_addr = (unsigned long)netif->comms_area->addr;
> op.handle = netif->tx_shmem_handle;
> op.dev_bus_addr = 0;
>
> lock_vm_area(netif->comms_area);
> - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
> unlock_vm_area(netif->comms_area);
> + BUG_ON(ret);
>
> op.host_addr = (unsigned long)netif->comms_area->addr + PAGE_SIZE;
> op.handle = netif->rx_shmem_handle;
> op.dev_bus_addr = 0;
>
> lock_vm_area(netif->comms_area);
> - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
> unlock_vm_area(netif->comms_area);
> + BUG_ON(ret);
> }
>
> int netif_map(netif_t *netif, unsigned long tx_ring_ref,
> diff -purN linux-2.6-xen-sparse/drivers/xen/netback/netback.c
> linux-2.6-xen-sparse/drivers/xen/netback/netback.c
> --- linux-2.6-xen-sparse/drivers/xen/netback/netback.c 2005-10-22 10:12:
> 39.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/netback/netback.c 2005-10-27 11:12:
> 42.000000000 +0200
> @@ -112,9 +112,12 @@ static void free_mfn(unsigned long mfn)
> spin_lock_irqsave(&mfn_lock, flags);
> if ( alloc_index != MAX_MFN_ALLOC )
> mfn_list[alloc_index++] = mfn;
> - else
> - BUG_ON(HYPERVISOR_memory_op(XENMEM_decrease_reservation,
> - &reservation) != 1);
> + else {
> + int ret;
> + ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
> + &reservation);
> + BUG_ON(ret != 1);
> + }
> spin_unlock_irqrestore(&mfn_lock, flags);
> }
> #endif
> @@ -159,13 +162,15 @@ int netif_be_start_xmit(struct sk_buff *
> */
> if (skb_shared(skb) || skb_cloned(skb) || !is_xen_skb(skb)) {
> int hlen = skb->data - skb->head;
> + int ret;
> struct sk_buff *nskb = dev_alloc_skb(hlen + skb->len);
> if ( unlikely(nskb == NULL) )
> goto drop;
> skb_reserve(nskb, hlen);
> __skb_put(nskb, skb->len);
> - BUG_ON(skb_copy_bits(skb, -hlen, nskb->data - hlen,
> - skb->len + hlen));
> + ret = skb_copy_bits(skb, -hlen, nskb->data - hlen,
> + skb->len + hlen);
> + BUG_ON(ret);
> nskb->dev = skb->dev;
> nskb->proto_csum_valid = skb->proto_csum_valid;
> dev_kfree_skb(skb);
> @@ -218,6 +223,7 @@ static void net_rx_action(unsigned long
> struct sk_buff *skb;
> u16 notify_list[NETIF_RX_RING_SIZE];
> int notify_nr = 0;
> + int ret;
>
> skb_queue_head_init(&rxq);
>
> @@ -279,7 +285,8 @@ static void net_rx_action(unsigned long
> mcl++;
>
> mcl[-2].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL;
> - BUG_ON(HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl) != 0);
> + ret = HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl);
> + BUG_ON(ret != 0);
>
> mcl = rx_mcl;
> if( HYPERVISOR_grant_table_op(GNTTABOP_transfer, grant_rx_op,
> @@ -421,6 +428,7 @@ inline static void net_tx_action_dealloc
> u16 pending_idx;
> PEND_RING_IDX dc, dp;
> netif_t *netif;
> + int ret;
>
> dc = dealloc_cons;
> dp = dealloc_prod;
> @@ -436,8 +444,9 @@ inline static void net_tx_action_dealloc
> gop->handle = grant_tx_ref[pending_idx];
> gop++;
> }
> - BUG_ON(HYPERVISOR_grant_table_op(
> - GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops));
> + ret = HYPERVISOR_grant_table_op(
> + GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops);
> + BUG_ON(ret);
>
> while (dealloc_cons != dp) {
> pending_idx = dealloc_ring[MASK_PEND_IDX(dealloc_cons++)];
> @@ -477,6 +486,7 @@ static void net_tx_action(unsigned long
> NETIF_RING_IDX i;
> gnttab_map_grant_ref_t *mop;
> unsigned int data_len;
> + int ret;
>
> if (dealloc_cons != dealloc_prod)
> net_tx_action_dealloc();
> @@ -599,8 +609,9 @@ static void net_tx_action(unsigned long
> if (mop == tx_map_ops)
> return;
>
> - BUG_ON(HYPERVISOR_grant_table_op(
> - GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops));
> + ret = HYPERVISOR_grant_table_op(
> + GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);
> + BUG_ON(ret);
>
> mop = tx_map_ops;
> while ((skb = __skb_dequeue(&tx_queue)) != NULL) {
> diff -purN linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
> linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
> --- linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c 2005-10-22 10:13:
> 08.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c 2005-10-27 11:28:
> 17.000000000 +0200
> @@ -78,6 +78,7 @@ tpmif_find(domid_t domid, long int insta
> static int
> map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
> {
> + int ret;
> struct gnttab_map_grant_ref op = {
> .host_addr = (unsigned long)tpmif->tx_area->addr,
> .flags = GNTMAP_host_map,
> @@ -86,8 +87,9 @@ map_frontend_page(tpmif_t *tpmif, unsign
> };
>
> lock_vm_area(tpmif->tx_area);
> - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
> unlock_vm_area(tpmif->tx_area);
> + BUG_ON(ret);
>
> if (op.handle < 0) {
> DPRINTK(" Grant table operation failure !\n");
> @@ -104,14 +106,16 @@ static void
> unmap_frontend_page(tpmif_t *tpmif)
> {
> struct gnttab_unmap_grant_ref op;
> + int ret;
>
> op.host_addr = (unsigned long)tpmif->tx_area->addr;
> op.handle = tpmif->shmem_handle;
> op.dev_bus_addr = 0;
>
> lock_vm_area(tpmif->tx_area);
> - BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
> unlock_vm_area(tpmif->tx_area);
> + BUG_ON(ret);
> }
>
> int
> diff -purN linux-2.6-xen-sparse/drivers/xen/util.c linux-2.6-xen-sparse
> /drivers/xen/util.c
> --- linux-2.6-xen-sparse/drivers/xen/util.c 2005-10-22 10:13:14.000000000+0200
> +++ linux-2.6-xen-sparse/drivers/xen/util.c 2005-10-27 11:28:49.000000000+0200
> @@ -34,7 +34,9 @@ struct vm_struct *alloc_vm_area(unsigned
>
> void free_vm_area(struct vm_struct *area)
> {
> - BUG_ON(remove_vm_area(area->addr) != area);
> + struct vm_struct *ret;
> + ret = remove_vm_area(area->addr);
> + BUG_ON(ret != area);
> kfree(area);
> }
>
> diff -purN linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
> linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
> --- linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c 2005-10-22
> 10:13:18.000000000 +0200
> +++ linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c 2005-10-27
> 11:29:33.000000000 +0200
> @@ -737,6 +737,7 @@ static int __init xenbus_probe_init(void
>
> unsigned long page;
> evtchn_op_t op = { 0 };
> + int ret;
>
>
> /* Allocate page. */
> @@ -757,7 +758,8 @@ static int __init xenbus_probe_init(void
> op.u.alloc_unbound.dom = DOMID_SELF;
> op.u.alloc_unbound.remote_dom = 0;
>
> - BUG_ON(HYPERVISOR_event_channel_op(&op));
> + ret = HYPERVISOR_event_channel_op(&op);
> + BUG_ON(ret);
> xen_start_info->store_evtchn = op.u.alloc_unbound.port;
>
> /* And finally publish the above info in /proc/xen */
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
>

[-- Attachment #1.2: Type: text/html, Size: 51484 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 0%]

* [patch] CFQ for xen domains
       [not found]                   ` <efbd0c82d427f99326de12f394c2c90b@cl.cam.ac.uk>
@ 2005-11-09 13:29  3%                 ` Gerd Knorr
  2005-11-15 17:51  3%                   ` Gerd Knorr
  0 siblings, 1 reply; 200+ results
From: Gerd Knorr @ 2005-11-09 13:29 UTC (permalink / raw)
  To: Keir Fraser; +Cc: Ian Pratt, xen-devel, Kurt Garloff, Chris Mason, Jens Axboe

[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]

> Does 'xm save / xm restore' work with this patch (at least as well as it 
> currently does ;-)?

xm save/restore still doesn't work for me, neither with the sparse tree 
nor with the linux-2.6 repository, so I can't try.  I can't see any 
reason why it should become worse with that patch though.

I've resynced the blkback threading patch with the latest sparse tree, 
here we are.  Changes:

   * One thread per blkif.  The I/O scheduler can do a better job that
     way, also you can use ionice on the blkback threads to adjust the
     block I/O priorities for the domain.
   * Various stuff has been moved from global variables into blkif_t.
   * The scary allocation ring for pending_req's is gone and has been
     replaced by a free list.
   * made dispatch_rw_block_io() reentrant.
   * general linux coding style cleanup, at least for the code I've
     touched anyway.
   * number of outstanding requests is runtime-configurable now.
   * made the ia64 #ifdefs smaller and dropped one.  It should still
     work on ia64 in theory, but would be great if the ia64 folks
     can have a look ...

cheers,

   Gerd


[-- Attachment #2: blkback-7.diff --]
[-- Type: text/x-patch, Size: 22872 bytes --]

diff -r abbe3df33774 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Tue Nov  8 17:39:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Wed Nov  9 13:45:37 2005
@@ -12,6 +12,8 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/kthread.h>
+#include <linux/list.h>
 #include <asm-xen/balloon.h>
 #include <asm/hypervisor.h>
 #include "common.h"
@@ -21,26 +23,21 @@
  * pulled from a communication ring are quite likely to end up being part of
  * the same scatter/gather request at the disc.
  * 
- * ** TRY INCREASING 'MAX_PENDING_REQS' IF WRITE SPEEDS SEEM TOO LOW **
+ * ** TRY INCREASING 'blkif_reqs' IF WRITE SPEEDS SEEM TOO LOW **
+ * 
  * This will increase the chances of being able to write whole tracks.
  * 64 should be enough to keep us competitive with Linux.
  */
-#define MAX_PENDING_REQS 64
-#define BATCH_PER_DOMAIN 16
-
-static unsigned long mmap_vstart;
-#define MMAP_PAGES						\
-	(MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
-#ifdef __ia64__
-static void *pending_vaddrs[MMAP_PAGES];
-#define MMAP_VADDR(_idx, _i) \
-	(unsigned long)(pending_vaddrs[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#else
-#define MMAP_VADDR(_req,_seg)						\
-	(mmap_vstart +							\
-	 ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +	\
-	 ((_seg) * PAGE_SIZE))
-#endif
+static int blkif_reqs = 64;
+static int mmap_pages;
+
+static int __init set_blkif_reqs(char *str)
+{
+	get_option(&str, &blkif_reqs);
+	return 1;
+}
+__setup("blkif_reqs=", set_blkif_reqs);
+
 
 /*
  * Each outstanding request that we've passed to the lower device layers has a 
@@ -55,43 +52,38 @@
 	atomic_t       pendcnt;
 	unsigned short operation;
 	int            status;
+	struct list_head free_list;
 } pending_req_t;
 
-/*
- * We can't allocate pending_req's in order, since they may complete out of 
- * order. We therefore maintain an allocation ring. This ring also indicates 
- * when enough work has been passed down -- at that point the allocation ring 
- * will be empty.
- */
-static pending_req_t pending_reqs[MAX_PENDING_REQS];
-static unsigned char pending_ring[MAX_PENDING_REQS];
-static spinlock_t pend_prod_lock = SPIN_LOCK_UNLOCKED;
-/* NB. We use a different index type to differentiate from shared blk rings. */
-typedef unsigned int PEND_RING_IDX;
-#define MASK_PEND_IDX(_i) ((_i)&(MAX_PENDING_REQS-1))
-static PEND_RING_IDX pending_prod, pending_cons;
-#define NR_PENDING_REQS (MAX_PENDING_REQS - pending_prod + pending_cons)
-
-static request_queue_t *plugged_queue;
-static inline void flush_plugged_queue(void)
-{
-	request_queue_t *q = plugged_queue;
-	if (q != NULL) {
-		if ( q->unplug_fn != NULL )
-			q->unplug_fn(q);
-		blk_put_queue(q);
-		plugged_queue = NULL;
-	}
-}
+static pending_req_t *pending_reqs;
+static struct list_head pending_free;
+static spinlock_t pending_free_lock = SPIN_LOCK_UNLOCKED;
+static DECLARE_WAIT_QUEUE_HEAD(pending_free_wq);
+
+#define BLKBACK_INVALID_HANDLE (0xFFFF)
+
+static unsigned long mmap_vstart;
+static unsigned long *pending_vaddrs;
+static u16 *pending_grant_handles;
+
+static inline int vaddr_pagenr(pending_req_t *req, int seg)
+{
+	return (req - pending_reqs) * BLKIF_MAX_SEGMENTS_PER_REQUEST + seg;
+}
+
+static inline unsigned long vaddr(pending_req_t *req, int seg)
+{
+	return pending_vaddrs[vaddr_pagenr(req, seg)];
+}
+
+#define pending_handle(_req, _seg) \
+	(pending_grant_handles[vaddr_pagenr(_req, _seg)])
+
 
 /* When using grant tables to map a frame for device access then the
  * handle returned must be used to unmap the frame. This is needed to
  * drop the ref count on the frame.
  */
-static u16 pending_grant_handles[MMAP_PAGES];
-#define pending_handle(_idx, _i) \
-    (pending_grant_handles[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#define BLKBACK_INVALID_HANDLE (0xFFFF)
 
 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
 /*
@@ -105,26 +97,79 @@
 static inline domid_t ID_TO_DOM(unsigned long id) { return (id >> 16); }
 #endif
 
-static int do_block_io_op(blkif_t *blkif, int max_to_do);
-static void dispatch_rw_block_io(blkif_t *blkif, blkif_request_t *req);
+static int do_block_io_op(blkif_t *blkif);
+static void dispatch_rw_block_io(blkif_t *blkif,
+				 blkif_request_t *req,
+				 pending_req_t *pending_req);
 static void make_response(blkif_t *blkif, unsigned long id, 
                           unsigned short op, int st);
 
-static void fast_flush_area(int idx, int nr_pages)
+/******************************************************************
+ * misc small helpers
+ */
+static pending_req_t* alloc_req(void)
+{
+	pending_req_t *req = NULL;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+	if (!list_empty(&pending_free)) {
+		req = list_entry(pending_free.next, pending_req_t, free_list);
+		list_del(&req->free_list);
+	}
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+	return req;
+}
+
+static void free_req(pending_req_t *req)
+{
+	unsigned long flags;
+	int was_empty;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+	was_empty = list_empty(&pending_free);
+	list_add(&req->free_list, &pending_free);
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+	if (was_empty)
+		wake_up(&pending_free_wq);
+}
+
+static void unplug_queue(blkif_t *blkif)
+{
+	if (NULL == blkif->plug)
+		return;
+	if (blkif->plug->unplug_fn)
+		blkif->plug->unplug_fn(blkif->plug);
+	blk_put_queue(blkif->plug);
+	blkif->plug = NULL;
+}
+
+static void plug_queue(blkif_t *blkif, struct bio *bio)
+{
+	request_queue_t *q = bdev_get_queue(bio->bi_bdev);
+
+	if (q == blkif->plug)
+		return;
+	unplug_queue(blkif);
+	blk_get_queue(q);
+	blkif->plug = q;
+}
+
+static void fast_flush_area(pending_req_t *req)
 {
 	struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	unsigned int i, invcount = 0;
 	u16 handle;
 	int ret;
 
-	for (i = 0; i < nr_pages; i++) {
-		handle = pending_handle(idx, i);
+	for (i = 0; i < req->nr_pages; i++) {
+		handle = pending_handle(req, i);
 		if (handle == BLKBACK_INVALID_HANDLE)
 			continue;
-		unmap[invcount].host_addr    = MMAP_VADDR(idx, i);
+		unmap[invcount].host_addr    = vaddr(req, i);
 		unmap[invcount].dev_bus_addr = 0;
 		unmap[invcount].handle       = handle;
-		pending_handle(idx, i) = BLKBACK_INVALID_HANDLE;
+		pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
 		invcount++;
 	}
 
@@ -133,109 +178,56 @@
 	BUG_ON(ret);
 }
 
-
-/******************************************************************
- * BLOCK-DEVICE SCHEDULER LIST MAINTENANCE
- */
-
-static struct list_head blkio_schedule_list;
-static spinlock_t blkio_schedule_list_lock;
-
-static int __on_blkdev_list(blkif_t *blkif)
-{
-	return blkif->blkdev_list.next != NULL;
-}
-
-static void remove_from_blkdev_list(blkif_t *blkif)
-{
-	unsigned long flags;
-
-	if (!__on_blkdev_list(blkif))
-		return;
-
-	spin_lock_irqsave(&blkio_schedule_list_lock, flags);
-	if (__on_blkdev_list(blkif)) {
-		list_del(&blkif->blkdev_list);
-		blkif->blkdev_list.next = NULL;
-		blkif_put(blkif);
-	}
-	spin_unlock_irqrestore(&blkio_schedule_list_lock, flags);
-}
-
-static void add_to_blkdev_list_tail(blkif_t *blkif)
-{
-	unsigned long flags;
-
-	if (__on_blkdev_list(blkif))
-		return;
-
-	spin_lock_irqsave(&blkio_schedule_list_lock, flags);
-	if (!__on_blkdev_list(blkif) && (blkif->status == CONNECTED)) {
-		list_add_tail(&blkif->blkdev_list, &blkio_schedule_list);
-		blkif_get(blkif);
-	}
-	spin_unlock_irqrestore(&blkio_schedule_list_lock, flags);
-}
-
-
 /******************************************************************
  * SCHEDULER FUNCTIONS
  */
 
-static DECLARE_WAIT_QUEUE_HEAD(blkio_schedule_wait);
-
-static int blkio_schedule(void *arg)
-{
-	DECLARE_WAITQUEUE(wq, current);
-
-	blkif_t          *blkif;
-	struct list_head *ent;
-
-	daemonize("xenblkd");
-
+int blkif_schedule(void *arg)
+{
+	blkif_t          *blkif = arg;
+
+	blkif_get(blkif);
+	printk(KERN_DEBUG "%s: started\n", current->comm);
 	for (;;) {
-		/* Wait for work to do. */
-		add_wait_queue(&blkio_schedule_wait, &wq);
-		set_current_state(TASK_INTERRUPTIBLE);
-		if ( (NR_PENDING_REQS == MAX_PENDING_REQS) || 
-		     list_empty(&blkio_schedule_list) )
-			schedule();
-		__set_current_state(TASK_RUNNING);
-		remove_wait_queue(&blkio_schedule_wait, &wq);
-
-		/* Queue up a batch of requests. */
-		while ((NR_PENDING_REQS < MAX_PENDING_REQS) &&
-		       !list_empty(&blkio_schedule_list)) {
-			ent = blkio_schedule_list.next;
-			blkif = list_entry(ent, blkif_t, blkdev_list);
-			blkif_get(blkif);
-			remove_from_blkdev_list(blkif);
-			if (do_block_io_op(blkif, BATCH_PER_DOMAIN))
-				add_to_blkdev_list_tail(blkif);
-			blkif_put(blkif);
-		}
-
-		/* Push the batch through to disc. */
-		flush_plugged_queue();
-	}
-}
-
-static void maybe_trigger_blkio_schedule(void)
-{
-	/*
-	 * Needed so that two processes, which together make the following
-	 * predicate true, don't both read stale values and evaluate the
-	 * predicate incorrectly. Incredibly unlikely to stall the scheduler
-	 * on x86, but...
-	 */
-	smp_mb();
-
-	if ((NR_PENDING_REQS < (MAX_PENDING_REQS/2)) &&
-	    !list_empty(&blkio_schedule_list))
-		wake_up(&blkio_schedule_wait);
-}
-
-
+		if (!atomic_read(&blkif->io_pending)) {
+			/* Wait for work to do or requests to exit. */
+			if (kthread_should_stop())
+				break;
+			wait_event_interruptible(blkif->wq,
+						 atomic_read(&blkif->io_pending) ||
+						 kthread_should_stop());
+		} else if (list_empty(&pending_free)) {
+			/* Wait for pending_req becoming available. */
+			wait_event_interruptible(pending_free_wq,
+						 !list_empty(&pending_free));
+		}
+
+		/* Schedule I/O */
+		atomic_set(&blkif->io_pending, 0);
+		if (do_block_io_op(blkif))
+			atomic_inc(&blkif->io_pending);
+		unplug_queue(blkif);
+
+#if 0
+		/* Print stats for performance debugging. */
+		if (time_after(jiffies, blkif->st_print)) {
+			printk(KERN_DEBUG "%s: oo %3d  |  rd %4d  |  wr %4d\n",
+			       current->comm, blkif->st_oo_req,
+			       blkif->st_rd_req, blkif->st_wr_req);
+			blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000);
+			blkif->st_rd_req = 0;
+			blkif->st_wr_req = 0;
+			blkif->st_oo_req = 0;
+		}
+#endif
+	}
+
+	/* bye folks, and thanks for all the fish ;) */
+	printk(KERN_DEBUG "%s: exiting\n", current->comm);
+	blkif->xenblkd = NULL;
+	blkif_put(blkif);
+	return 0;
+}
 
 /******************************************************************
  * COMPLETION CALLBACK -- Called as bh->b_end_io()
@@ -243,8 +235,6 @@
 
 static void __end_block_io_op(pending_req_t *pending_req, int uptodate)
 {
-	unsigned long flags;
-
 	/* An error fails the entire request. */
 	if (!uptodate) {
 		DPRINTK("Buffer not up-to-date at end of operation\n");
@@ -252,15 +242,11 @@
 	}
 
 	if (atomic_dec_and_test(&pending_req->pendcnt)) {
-		int pending_idx = pending_req - pending_reqs;
-		fast_flush_area(pending_idx, pending_req->nr_pages);
+		fast_flush_area(pending_req);
 		make_response(pending_req->blkif, pending_req->id,
 			      pending_req->operation, pending_req->status);
 		blkif_put(pending_req->blkif);
-		spin_lock_irqsave(&pend_prod_lock, flags);
-		pending_ring[MASK_PEND_IDX(pending_prod++)] = pending_idx;
-		spin_unlock_irqrestore(&pend_prod_lock, flags);
-		maybe_trigger_blkio_schedule();
+		free_req(pending_req);
 	}
 }
 
@@ -281,8 +267,10 @@
 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
 {
 	blkif_t *blkif = dev_id;
-	add_to_blkdev_list_tail(blkif);
-	maybe_trigger_blkio_schedule();
+
+	atomic_inc(&blkif->io_pending);
+	if (blkif->status == CONNECTED)
+		wake_up(&blkif->wq);
 	return IRQ_HANDLED;
 }
 
@@ -292,10 +280,11 @@
  * DOWNWARD CALLS -- These interface with the block-device layer proper.
  */
 
-static int do_block_io_op(blkif_t *blkif, int max_to_do)
+static int do_block_io_op(blkif_t *blkif)
 {
 	blkif_back_ring_t *blk_ring = &blkif->blk_ring;
 	blkif_request_t *req;
+	pending_req_t *pending_req;
 	RING_IDX i, rp;
 	int more_to_do = 0;
 
@@ -305,24 +294,30 @@
 	for (i = blk_ring->req_cons; 
 	     (i != rp) && !RING_REQUEST_CONS_OVERFLOW(blk_ring, i);
 	     i++) {
-		if ((max_to_do-- == 0) ||
-		    (NR_PENDING_REQS == MAX_PENDING_REQS)) {
+
+		pending_req = alloc_req();
+		if (NULL == pending_req) {
+			blkif->st_oo_req++;
 			more_to_do = 1;
 			break;
 		}
-        
+
 		req = RING_GET_REQUEST(blk_ring, i);
 		switch (req->operation) {
 		case BLKIF_OP_READ:
+			blkif->st_rd_req++;
+			dispatch_rw_block_io(blkif, req, pending_req);
+			break;
 		case BLKIF_OP_WRITE:
-			dispatch_rw_block_io(blkif, req);
+			blkif->st_wr_req++;
+			dispatch_rw_block_io(blkif, req, pending_req);
 			break;
-
 		default:
 			DPRINTK("error: unknown block io operation [%d]\n",
 				req->operation);
 			make_response(blkif, req->id, req->operation,
 				      BLKIF_RSP_ERROR);
+			free_req(pending_req);
 			break;
 		}
 	}
@@ -331,13 +326,13 @@
 	return more_to_do;
 }
 
-static void dispatch_rw_block_io(blkif_t *blkif, blkif_request_t *req)
+static void dispatch_rw_block_io(blkif_t *blkif,
+				 blkif_request_t *req,
+				 pending_req_t *pending_req)
 {
 	extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]); 
 	int operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
 	unsigned long fas = 0;
-	int i, pending_idx = pending_ring[MASK_PEND_IDX(pending_cons)];
-	pending_req_t *pending_req;
 	struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	struct phys_req preq;
 	struct { 
@@ -345,31 +340,35 @@
 	} seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	unsigned int nseg;
 	struct bio *bio = NULL, *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
-	int nbio = 0;
-	request_queue_t *q;
-	int ret, errors = 0;
+	int ret, i, nbio = 0;
 
 	/* Check that number of segments is sane. */
 	nseg = req->nr_segments;
 	if (unlikely(nseg == 0) || 
 	    unlikely(nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) {
 		DPRINTK("Bad number of segments in request (%d)\n", nseg);
-		goto bad_descriptor;
+		goto fail_response;
 	}
 
 	preq.dev           = req->handle;
 	preq.sector_number = req->sector_number;
 	preq.nr_sects      = 0;
 
+	pending_req->blkif     = blkif;
+	pending_req->id        = req->id;
+	pending_req->operation = operation;
+	pending_req->status    = BLKIF_RSP_OKAY;
+	pending_req->nr_pages  = nseg;
+
 	for (i = 0; i < nseg; i++) {
 		fas         = req->frame_and_sects[i];
 		seg[i].nsec = blkif_last_sect(fas) - blkif_first_sect(fas) + 1;
 
 		if (seg[i].nsec <= 0)
-			goto bad_descriptor;
+			goto fail_response;
 		preq.nr_sects += seg[i].nsec;
 
-		map[i].host_addr = MMAP_VADDR(pending_idx, i);
+		map[i].host_addr = vaddr(pending_req, i);
 		map[i].dom = blkif->domid;
 		map[i].ref = blkif_gref_from_fas(fas);
 		map[i].flags = GNTMAP_host_map;
@@ -381,27 +380,23 @@
 	BUG_ON(ret);
 
 	for (i = 0; i < nseg; i++) {
-		if (likely(map[i].handle >= 0)) {
-			pending_handle(pending_idx, i) = map[i].handle;
+		if (unlikely(map[i].handle < 0)) {
+			DPRINTK("invalid buffer -- could not remap it\n");
+			goto fail_flush;
+		}
+
+		pending_handle(pending_req, i) = map[i].handle;
 #ifdef __ia64__
-			MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
+		pending_vaddrs[vaddr_pagenr(req, seg)] =
+			= gnttab_map_vaddr(map[i]);
 #else
-			phys_to_machine_mapping[__pa(MMAP_VADDR(
-				pending_idx, i)) >> PAGE_SHIFT] =
-				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT);
+		phys_to_machine_mapping[__pa(vaddr(
+			pending_req, i)) >> PAGE_SHIFT] =
+			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT);
 #endif
-			fas        = req->frame_and_sects[i];
-			seg[i].buf = map[i].dev_bus_addr | 
-				(blkif_first_sect(fas) << 9);
-		} else {
-			errors++;
-		}
-	}
-
-	if (errors) {
-		DPRINTK("invalid buffer -- could not remap it\n");
-		fast_flush_area(pending_idx, nseg);
-		goto bad_descriptor;
+		fas         = req->frame_and_sects[i];
+		seg[i].buf  = map[i].dev_bus_addr | 
+			(blkif_first_sect(fas) << 9);
 	}
 
 	if (vbd_translate(&preq, blkif, operation) != 0) {
@@ -409,37 +404,25 @@
 			operation == READ ? "read" : "write",
 			preq.sector_number,
 			preq.sector_number + preq.nr_sects, preq.dev); 
-		goto bad_descriptor;
-	}
-
-	pending_req = &pending_reqs[pending_idx];
-	pending_req->blkif     = blkif;
-	pending_req->id        = req->id;
-	pending_req->operation = operation;
-	pending_req->status    = BLKIF_RSP_OKAY;
-	pending_req->nr_pages  = nseg;
+		goto fail_flush;
+	}
 
 	for (i = 0; i < nseg; i++) {
 		if (((int)preq.sector_number|(int)seg[i].nsec) &
 		    ((bdev_hardsect_size(preq.bdev) >> 9) - 1)) {
 			DPRINTK("Misaligned I/O request from domain %d",
 				blkif->domid);
-			goto cleanup_and_fail;
+			goto fail_put_bio;
 		}
 
 		while ((bio == NULL) ||
 		       (bio_add_page(bio,
-				     virt_to_page(MMAP_VADDR(pending_idx, i)),
+				     virt_to_page(vaddr(pending_req, i)),
 				     seg[i].nsec << 9,
 				     seg[i].buf & ~PAGE_MASK) == 0)) {
 			bio = biolist[nbio++] = bio_alloc(GFP_KERNEL, nseg-i);
-			if (unlikely(bio == NULL)) {
-			cleanup_and_fail:
-				for (i = 0; i < (nbio-1); i++)
-					bio_put(biolist[i]);
-				fast_flush_area(pending_idx, nseg);
-				goto bad_descriptor;
-			}
+			if (unlikely(bio == NULL))
+				goto fail_put_bio;
                 
 			bio->bi_bdev    = preq.bdev;
 			bio->bi_private = pending_req;
@@ -450,14 +433,8 @@
 		preq.sector_number += seg[i].nsec;
 	}
 
-	if ((q = bdev_get_queue(bio->bi_bdev)) != plugged_queue) {
-		flush_plugged_queue();
-		blk_get_queue(q);
-		plugged_queue = q;
-	}
-
+	plug_queue(blkif, bio);
 	atomic_set(&pending_req->pendcnt, nbio);
-	pending_cons++;
 	blkif_get(blkif);
 
 	for (i = 0; i < nbio; i++)
@@ -465,8 +442,14 @@
 
 	return;
 
- bad_descriptor:
+ fail_put_bio:
+	for (i = 0; i < (nbio-1); i++)
+		bio_put(biolist[i]);
+ fail_flush:
+	fast_flush_area(pending_req);
+ fail_response:
 	make_response(blkif, req->id, req->operation, BLKIF_RSP_ERROR);
+	free_req(pending_req);
 } 
 
 
@@ -498,56 +481,47 @@
 	notify_remote_via_irq(blkif->irq);
 }
 
-void blkif_deschedule(blkif_t *blkif)
-{
-	remove_from_blkdev_list(blkif);
-}
-
 static int __init blkif_init(void)
 {
+	struct page *page;
 	int i;
-	struct page *page;
-	int ret;
-
-	for (i = 0; i < MMAP_PAGES; i++)
-		pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
-
-	if (xen_init() < 0)
-		return -ENODEV;
+
+	mmap_pages            = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
+	pending_reqs          = kmalloc(sizeof(pending_reqs[0]) *
+					blkif_reqs, GFP_KERNEL);
+	pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
+					mmap_pages, GFP_KERNEL);
+	pending_vaddrs        = kmalloc(sizeof(pending_vaddrs[0]) *
+					mmap_pages, GFP_KERNEL);
+	if (!pending_reqs || !pending_grant_handles || !pending_vaddrs) {
+		printk("%s: out of memory\n", __FUNCTION__);
+		return -1;
+	}
 
 	blkif_interface_init();
-
+	
 #ifdef __ia64__
-    {
 	extern unsigned long alloc_empty_foreign_map_page_range(unsigned long pages);
-	int i;
-
-	mmap_vstart =  alloc_empty_foreign_map_page_range(MMAP_PAGES);
-	printk("Allocated mmap_vstart: 0x%lx\n", mmap_vstart);
-	for(i = 0; i < MMAP_PAGES; i++)
-	    pending_vaddrs[i] = mmap_vstart + (i << PAGE_SHIFT);
-	BUG_ON(mmap_vstart == NULL);
-    }
-#else
-	page = balloon_alloc_empty_page_range(MMAP_PAGES);
+	mmap_vstart = (unsigned long)alloc_empty_foreign_map_page_range(mmap_pages);
+#else /* ! ia64 */
+	page = balloon_alloc_empty_page_range(mmap_pages);
 	BUG_ON(page == NULL);
 	mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
 #endif
-
-	pending_cons = 0;
-	pending_prod = MAX_PENDING_REQS;
+	printk("%s: reqs=%d, pages=%d, mmap_vstart=0x%lx\n",
+	       __FUNCTION__, blkif_reqs, mmap_pages, mmap_vstart);
+	BUG_ON(mmap_vstart == 0);
+	for (i = 0; i < mmap_pages; i++)
+		pending_vaddrs[i] = mmap_vstart + (i << PAGE_SHIFT);
+
+	memset(pending_grant_handles,  BLKBACK_INVALID_HANDLE, mmap_pages);
 	memset(pending_reqs, 0, sizeof(pending_reqs));
-	for (i = 0; i < MAX_PENDING_REQS; i++)
-		pending_ring[i] = i;
+	INIT_LIST_HEAD(&pending_free);
+
+	for (i = 0; i < blkif_reqs; i++)
+		list_add_tail(&pending_reqs[i].free_list, &pending_free);
     
-	spin_lock_init(&blkio_schedule_list_lock);
-	INIT_LIST_HEAD(&blkio_schedule_list);
-
-	ret = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
-	BUG_ON(ret < 0);
-
 	blkif_xenbus_init();
-
 	return 0;
 }
 
diff -r abbe3df33774 linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Tue Nov  8 17:39:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Wed Nov  9 13:45:37 2005
@@ -56,9 +56,19 @@
 	/* Is this a blktap frontend */
 	unsigned int     is_blktap;
 #endif
-	struct list_head blkdev_list;
 	spinlock_t       blk_ring_lock;
 	atomic_t         refcnt;
+
+	wait_queue_head_t   wq;
+	struct task_struct  *xenblkd;
+	atomic_t            io_pending;
+	request_queue_t     *plug;
+
+	/* statistics */
+	unsigned long       st_print;
+	int                 st_rd_req;
+	int                 st_wr_req;
+	int                 st_oo_req;
 
 	struct work_struct free_work;
 
@@ -97,11 +107,10 @@
 
 void blkif_interface_init(void);
 
-void blkif_deschedule(blkif_t *blkif);
-
 void blkif_xenbus_init(void);
 
 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
+int blkif_schedule(void *arg);
 
 #endif /* __BLKIF__BACKEND__COMMON_H__ */
 
diff -r abbe3df33774 linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Tue Nov  8 17:39:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Wed Nov  9 13:45:37 2005
@@ -24,6 +24,8 @@
 	blkif->status = DISCONNECTED;
 	spin_lock_init(&blkif->blk_ring_lock);
 	atomic_set(&blkif->refcnt, 1);
+	init_waitqueue_head(&blkif->wq);
+	blkif->st_print = jiffies;
 
 	return blkif;
 }
diff -r abbe3df33774 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Tue Nov  8 17:39:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Wed Nov  9 13:45:37 2005
@@ -17,6 +17,7 @@
 */
 #include <stdarg.h>
 #include <linux/module.h>
+#include <linux/kthread.h>
 #include <asm-xen/xenbus.h>
 #include "common.h"
 
@@ -46,8 +47,11 @@
 	if (be->watch.node)
 		unregister_xenbus_watch(&be->watch);
 	unregister_xenbus_watch(&be->backend_watch);
-	if (be->blkif)
+	if (be->blkif) {
+		if (be->blkif->xenblkd)
+			kthread_stop(be->blkif->xenblkd);
 		blkif_put(be->blkif);
+	}
 	if (be->frontpath)
 		kfree(be->frontpath);
 	kfree(be);
@@ -198,6 +202,16 @@
 			be->blkif = NULL;
 			xenbus_dev_error(dev, err,
 					 "creating vbd structure");
+			return;
+		}
+
+		be->blkif->xenblkd = kthread_run(blkif_schedule, be->blkif,
+						 "xenblkd %d/%04lx",
+						 be->blkif->domid, be->pdev);
+		if (IS_ERR(be->blkif->xenblkd)) {
+			err = PTR_ERR(be->blkif->xenblkd);
+			be->blkif->xenblkd = NULL;
+			xenbus_dev_error(dev, err, "start xenblkd");
 			return;
 		}
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 3%]

* [PATCH] Abstract writes to phys_to_machine_mapping
@ 2005-11-10 13:11 15% Jacob Gorm Hansen
  0 siblings, 0 replies; 200+ results
From: Jacob Gorm Hansen @ 2005-11-10 13:11 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 863 bytes --]

hi,

for my self-migration patch, I need the ability to trap writes to the
p2m map during migration, because I keep a dictionary mapping mfns to
pfns, which I use for remapping the page tables once I am on the other
side.

The attached patch abstracts writes through an inline function defined
in page.h.

diffstat:
 arch/xen/i386/mm/hypervisor.c   |   14 +++++++-------
 drivers/xen/balloon/balloon.c   |    7 +++----
 drivers/xen/blkback/blkback.c   |    6 +++---
 drivers/xen/blktap/blktap.c     |    4 ++--
 drivers/xen/netback/netback.c   |    8 +++-----
 drivers/xen/netfront/netfront.c |    5 ++---
 drivers/xen/tpmback/tpmback.c   |    6 +++---
 include/asm-xen/asm-i386/page.h |    4 ++++
 8 files changed, 27 insertions(+), 27 deletions(-)

best,
Jacob
--
Save time and bandwidth with EDelta: http://www.diku.dk/~jacobg/edelta/

[-- Attachment #2: abstract_setp2m.patch --]
[-- Type: application/octet-stream, Size: 7582 bytes --]

diff -r 136b2d20dc81 linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Wed Nov  9 15:08:37 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Thu Nov 10 14:05:42 2005
@@ -342,8 +342,8 @@
 		mfn = pte_mfn(*pte);
 		BUG_ON(HYPERVISOR_update_va_mapping(
 			vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
-		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
-			INVALID_P2M_ENTRY;
+		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
+			INVALID_P2M_ENTRY);
 		BUG_ON(HYPERVISOR_memory_op(
 			XENMEM_decrease_reservation, &reservation) != 1);
 	}
@@ -361,7 +361,7 @@
 			vstart + (i*PAGE_SIZE),
 			pfn_pte_ma(mfn+i, PAGE_KERNEL), 0));
 		xen_machphys_update(mfn+i, (__pa(vstart)>>PAGE_SHIFT)+i);
-		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn+i;
+		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn+i);
 	}
 
 	flush_tlb_all();
@@ -383,7 +383,7 @@
 			vstart + (i*PAGE_SIZE),
 			pfn_pte_ma(mfn, PAGE_KERNEL), 0));
 		xen_machphys_update(mfn, (__pa(vstart)>>PAGE_SHIFT)+i);
-		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn;
+		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn);
 	}
 
 	flush_tlb_all();
@@ -422,8 +422,8 @@
 		mfn = pte_mfn(*pte);
 		BUG_ON(HYPERVISOR_update_va_mapping(
 			vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
-		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
-			INVALID_P2M_ENTRY;
+		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
+			INVALID_P2M_ENTRY);
 		BUG_ON(HYPERVISOR_memory_op(
 			XENMEM_decrease_reservation, &reservation) != 1);
 	}
@@ -436,7 +436,7 @@
 			vstart + (i*PAGE_SIZE),
 			pfn_pte_ma(mfn, PAGE_KERNEL), 0));
 		xen_machphys_update(mfn, (__pa(vstart)>>PAGE_SHIFT)+i);
-		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn;
+		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn);
 	}
 
 	flush_tlb_all();
diff -r 136b2d20dc81 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Nov  9 15:08:37 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Nov 10 14:05:42 2005
@@ -210,7 +210,7 @@
 		BUG_ON(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
 
 		/* Update P->M and M->P tables. */
-		phys_to_machine_mapping[pfn] = mfn_list[i];
+		set_phys_to_machine(pfn, mfn_list[i]);
 		xen_machphys_update(mfn_list[i], pfn);
             
 		/* Link back into the page tables if not highmem. */
@@ -295,7 +295,7 @@
 	/* No more mappings: invalidate P2M and add to balloon. */
 	for (i = 0; i < nr_pages; i++) {
 		pfn = mfn_to_pfn(mfn_list[i]);
-		phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
+		set_phys_to_machine(pfn,INVALID_P2M_ENTRY);
 		balloon_append(pfn_to_page(pfn));
 	}
 
@@ -515,8 +515,7 @@
 		.domid        = DOMID_SELF
 	};
 	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
-	phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
-		INVALID_P2M_ENTRY;
+	set_phys_to_machine(__pa(addr) >> PAGE_SHIFT,INVALID_P2M_ENTRY);
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
 	BUG_ON(ret != 1);
 	return 0;
diff -r 136b2d20dc81 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Wed Nov  9 15:08:37 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu Nov 10 14:05:42 2005
@@ -386,9 +386,9 @@
 #ifdef __ia64__
 			MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
 #else
-			phys_to_machine_mapping[__pa(MMAP_VADDR(
-				pending_idx, i)) >> PAGE_SHIFT] =
-				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT);
+			set_phys_to_machine(__pa(MMAP_VADDR(
+				pending_idx, i)) >> PAGE_SHIFT,
+				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT));
 #endif
 			fas        = req->frame_and_sects[i];
 			seg[i].buf = map[i].dev_bus_addr | 
diff -r 136b2d20dc81 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Wed Nov  9 15:08:37 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Nov 10 14:05:42 2005
@@ -777,8 +777,8 @@
 		/* Set the necessary mappings in p2m and in the VM_FOREIGN 
 		 * vm_area_struct to allow user vaddr -> struct page lookups
 		 * to work.  This is needed for direct IO to foreign pages. */
-		phys_to_machine_mapping[__pa(kvaddr) >> PAGE_SHIFT] =
-			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT);
+		set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT,
+				FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
 
 		offset = (uvaddr - blktap_vma->vm_start) >> PAGE_SHIFT;
 		((struct page **)blktap_vma->vm_private_data)[offset] =
diff -r 136b2d20dc81 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Wed Nov  9 15:08:37 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Nov 10 14:05:42 2005
@@ -248,8 +248,7 @@
 		 * Set the new P2M table entry before reassigning the old data
 		 * page. Heed the comment in pgtable-2level.h:pte_page(). :-)
 		 */
-		phys_to_machine_mapping[__pa(skb->data) >> PAGE_SHIFT] =
-			new_mfn;
+		set_phys_to_machine(__pa(skb->data) >> PAGE_SHIFT,new_mfn);
 
 		MULTI_update_va_mapping(mcl, vdata,
 					pfn_pte_ma(new_mfn, PAGE_KERNEL), 0);
@@ -631,9 +630,8 @@
 				pending_idx;
 			continue;
 		}
-		phys_to_machine_mapping[
-			__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT] =
-			FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT);
+		set_phys_to_machine( __pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT,
+			FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT));
 		grant_tx_ref[pending_idx] = mop->handle;
 
 		data_len = (txreq.size > PKT_PROT_LEN) ?
diff -r 136b2d20dc81 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Nov  9 15:08:37 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Nov 10 14:05:42 2005
@@ -342,8 +342,7 @@
 		rx_pfn_array[i] = virt_to_mfn(skb->head);
 
 		/* Remove this page from map before passing back to Xen. */
-		phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
-			= INVALID_P2M_ENTRY;
+		set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
 
 		MULTI_update_va_mapping(rx_mcl+i, (unsigned long)skb->head,
 					__pte(0), 0);
@@ -570,7 +569,7 @@
 					pfn_pte_ma(mfn, PAGE_KERNEL), 0);
 		mcl++;
 
-		phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = mfn;
+		set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT, mfn);
 
 		__skb_queue_tail(&rxq, skb);
 	}
diff -r 136b2d20dc81 linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Wed Nov  9 15:08:37 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Thu Nov 10 14:05:42 2005
@@ -296,9 +296,9 @@
 			DPRINTK(" Grant table operation failure !\n");
 			return 0;
 		}
-		phys_to_machine_mapping[__pa(MMAP_VADDR(tpmif,i)) >>
-					PAGE_SHIFT] =
-			FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT);
+		set_phys_to_machine(__pa(MMAP_VADDR(tpmif,i)) >>
+					PAGE_SHIFT,
+			FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT));
 
 		tocopy = MIN(size - offset, PAGE_SIZE);
 
diff -r 136b2d20dc81 linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Wed Nov  9 15:08:37 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Thu Nov 10 14:05:42 2005
@@ -86,6 +86,10 @@
 	return pfn;
 }
 
+static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
+{
+	phys_to_machine_mapping[pfn] = mfn;
+}
 /* Definitions for machine and pseudophysical addresses. */
 #ifdef CONFIG_X86_PAE
 typedef unsigned long long paddr_t;


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 15%]

* RE: [Xen-ia64-devel] [Patch] gcc3.4 build patch version2
       [not found]     <571ACEFD467F7749BC50E0A98C17CDD802C0699C@pdsmsx403>
@ 2005-11-15  2:04  8% ` takebe_akio
  0 siblings, 0 replies; 200+ results
From: takebe_akio @ 2005-11-15  2:04 UTC (permalink / raw)
  To: Tian, Kevin, xen-ia64-devel, xen-devel; +Cc: takebe_akio

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 4266 bytes --]

>Hi, Akio,
>	Instead of moving trunk back and forth, could you just add a prototype 
>declaration in vmx_vioapic.h to see whether working for you?
>
>Thanks,
>Kevin
>
Hi Kevin, Dan,

Thank you for your advice.
It's very good idea!

I remake a build patch.

But I have one error today.
Was the following error caused by no PMT?

--------------
# LANG=C make kernels
for i in  linux-2.6-xen0   linux-2.6-xenU  ; do make $i-install || exit 1; done
make[1]: Entering directory `/root/xen-ia64-unstable.hg'
make -f buildconfigs/mk.linux-2.6-xen0 build
make[2]: Entering directory `/root/xen-ia64-unstable.hg'
if grep "^CONFIG_MODULES=" linux-2.6.12-xen0/.config ; then \
    make -C linux-2.6.12-xen0 ARCH=ia64 modules ; \
    make -C linux-2.6.12-xen0 ARCH=ia64 INSTALL_MOD_PATH=/root/xen-ia64-unstable.hg/dist/install modules_install ; \
fi
CONFIG_MODULES=y
make[3]: Entering directory `/root/xen-ia64-unstable.hg/linux-2.6.12-xen0'
  CHK     include/linux/version.h
make[4]: `arch/ia64/kernel/asm-offsets.s' is up to date.
  CHK     include/asm-ia64/offsets.h
  Building modules, stage 2.
  MODPOST
make[3]: Leaving directory `/root/xen-ia64-unstable.hg/linux-2.6.12-xen0'
make[3]: Entering directory `/root/xen-ia64-unstable.hg/linux-2.6.12-xen0'
if [ -r System.map -a -x /sbin/depmod ]; then /sbin/depmod -ae -F System.map -b /root/xen-ia64-unstable.hg/dist/install -r 2.6.12.6-xen0xen; fi
make[3]: Leaving directory `/root/xen-ia64-unstable.hg/linux-2.6.12-xen0'
make -C linux-2.6.12-xen0 ARCH=ia64 INSTALL_PATH=/root/xen-ia64-unstable.hg/dist/install install
make[3]: Entering directory `/root/xen-ia64-unstable.hg/linux-2.6.12-xen0'
  CHK     include/linux/version.h
make[4]: `arch/ia64/kernel/asm-offsets.s' is up to date.
  CHK     include/asm-ia64/offsets.h
  CHK     include/linux/compile.h
  UPD     include/linux/compile.h
  CC      init/version.o
  LD      init/built-in.o
  CHK     usr/initramfs_list
  CC      drivers/xen/balloon/balloon.o
drivers/xen/balloon/balloon.c: In function `increase_reservation':
drivers/xen/balloon/balloon.c:191: warning: implicit declaration of function `HYPERVISOR_memory_op'
drivers/xen/balloon/balloon.c:210: error: `phys_to_machine_mapping' undeclared (first use in this function)
drivers/xen/balloon/balloon.c:210: error: (Each undeclared identifier is reported only once
drivers/xen/balloon/balloon.c:210: error: for each function it appears in.)
drivers/xen/balloon/balloon.c:210: error: `INVALID_P2M_ENTRY' undeclared (first use in this function)
drivers/xen/balloon/balloon.c:214: warning: implicit declaration of function `xen_machphys_update'
drivers/xen/balloon/balloon.c:219: warning: implicit declaration of function `HYPERVISOR_update_va_mapping'
drivers/xen/balloon/balloon.c:221: warning: implicit declaration of function `pfn_pte_ma'
drivers/xen/balloon/balloon.c: In function `decrease_reservation':
drivers/xen/balloon/balloon.c:271: error: `phys_to_machine_mapping' undeclared (first use in this function)
drivers/xen/balloon/balloon.c:275: warning: implicit declaration of function `scrub_pages'
drivers/xen/balloon/balloon.c:277: warning: implicit declaration of function `__pte_ma'
drivers/xen/balloon/balloon.c:290: warning: implicit declaration of function `kmap_flush_unused'
drivers/xen/balloon/balloon.c:298: error: `INVALID_P2M_ENTRY' undeclared (first use in this function)
drivers/xen/balloon/balloon.c: In function `dealloc_pte_fn':
drivers/xen/balloon/balloon.c:509: warning: implicit declaration of function `pte_mfn'
drivers/xen/balloon/balloon.c:517: error: incompatible types in assignment
drivers/xen/balloon/balloon.c:518: error: `phys_to_machine_mapping' undeclared (first use in this function)
drivers/xen/balloon/balloon.c:519: error: `INVALID_P2M_ENTRY' undeclared (first use in this function)
make[6]: *** [drivers/xen/balloon/balloon.o] Error 1
make[5]: *** [drivers/xen/balloon] Error 2
make[4]: *** [drivers/xen] Error 2
make[3]: *** [drivers] Error 2
make[3]: Leaving directory `/root/xen-ia64-unstable.hg/linux-2.6.12-xen0'
make[2]: *** [build] Error 2
make[2]: Leaving directory `/root/xen-ia64-unstable.hg'
make[1]: *** [linux-2.6-xen0-install] Error 2
make[1]: Leaving directory `/root/xen-ia64-unstable.hg'
make: *** [install-kernels] Error 1

Best Regards,

Akio Takebe

[-- Attachment #2: gcc34buildv2.patch --]
[-- Type: application/octet-stream, Size: 537 bytes --]

Signed-off-by Akio Takabe <takebe_akio@jp.fujitsu.com>

diff -r 5e142e1f41e6 xen/include/asm-x86/vmx_vioapic.h
--- a/xen/include/asm-x86/vmx_vioapic.h Mon Nov 14 17:41:41 2005
+++ b/xen/include/asm-x86/vmx_vioapic.h Tue Nov 15 10:50:49 2005
@@ -113,6 +113,7 @@
 
 int vmx_vioapic_add_lapic(struct vlapic *vlapic, struct vcpu *v);
 
+void ioapic_update_EOI(struct domain *d, int vector);
 #ifdef VMX_DOMAIN_SAVE_RESTORE
 void ioapic_save(QEMUFile* f, void* opaque);
 int ioapic_load(QEMUFile* f, void* opaque, int version_id);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 8%]

* RE: [Xen-ia64-devel] [Patch] gcc3.4 build patch version2
@ 2005-11-15  2:14  0% Magenheimer, Dan (HP Labs Fort Collins)
  0 siblings, 0 replies; 200+ results
From: Magenheimer, Dan (HP Labs Fort Collins) @ 2005-11-15  2:14 UTC (permalink / raw)
  To: takebe_akio, Tian, Kevin, xen-ia64-devel, xen-devel

> But I have one error today.
> Was the following error caused by no PMT?
>   CC      drivers/xen/balloon/balloon.o
> drivers/xen/balloon/balloon.c: In function `increase_reservation':
> drivers/xen/balloon/balloon.c:191: warning: implicit 
> declaration of function `HYPERVISOR_memory_op'
> drivers/xen/balloon/balloon.c:210: error: 
> `phys_to_machine_mapping' undeclared (first use in this function)

balloon.c has not been ported to ia64 yet and is excluded from
the ia64 build (see -sparse/arch/ia64/xen/drivers/Makefile which gets
copied to -sparse/drivers/xen/Makefile by
-sparse/arch/ia64/xen-mkbuildtree-pre)

^ permalink raw reply	[relevance 0%]

* Re: [patch] CFQ for xen domains
  2005-11-09 13:29  3%                 ` [patch] CFQ for xen domains Gerd Knorr
@ 2005-11-15 17:51  3%                   ` Gerd Knorr
  2005-11-24 11:31  3%                     ` Gerd Knorr
  0 siblings, 1 reply; 200+ results
From: Gerd Knorr @ 2005-11-15 17:51 UTC (permalink / raw)
  To: Gerd Knorr; +Cc: Ian Pratt, xen-devel, Chris Mason, Kurt Garloff, Jens Axboe

[-- Attachment #1: Type: text/plain, Size: 1063 bytes --]

> I've resynced the blkback threading patch with the latest sparse tree, 
> here we are.  Changes:
> 
>   * One thread per blkif.  The I/O scheduler can do a better job that
>     way, also you can use ionice on the blkback threads to adjust the
>     block I/O priorities for the domain.
>   * Various stuff has been moved from global variables into blkif_t.
>   * The scary allocation ring for pending_req's is gone and has been
>     replaced by a free list.
>   * made dispatch_rw_block_io() reentrant.
>   * general linux coding style cleanup, at least for the code I've
>     touched anyway.
>   * number of outstanding requests is runtime-configurable now.
>   * made the ia64 #ifdefs smaller and dropped one.  It should still
>     work on ia64 in theory, but would be great if the ia64 folks
>     can have a look ...

Next version of that patch, with those additional changes:

   * re-added the xen_init() which got lost by mistake (pointed
     out by the ia64 guys).
   * adapted to the driver architecture changes merged recently.

cheers,

   Gerd

[-- Attachment #2: blkback-7793-11.diff --]
[-- Type: text/x-patch, Size: 23348 bytes --]

diff -r 090e44133d40 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Mon Nov 14 17:13:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Tue Nov 15 18:17:26 2005
@@ -12,6 +12,8 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/kthread.h>
+#include <linux/list.h>
 #include <asm-xen/balloon.h>
 #include <asm/hypervisor.h>
 #include "common.h"
@@ -21,26 +23,21 @@
  * pulled from a communication ring are quite likely to end up being part of
  * the same scatter/gather request at the disc.
  * 
- * ** TRY INCREASING 'MAX_PENDING_REQS' IF WRITE SPEEDS SEEM TOO LOW **
+ * ** TRY INCREASING 'blkif_reqs' IF WRITE SPEEDS SEEM TOO LOW **
+ * 
  * This will increase the chances of being able to write whole tracks.
  * 64 should be enough to keep us competitive with Linux.
  */
-#define MAX_PENDING_REQS 64
-#define BATCH_PER_DOMAIN 16
-
-static unsigned long mmap_vstart;
-#define MMAP_PAGES						\
-	(MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
-#ifdef __ia64__
-static void *pending_vaddrs[MMAP_PAGES];
-#define MMAP_VADDR(_idx, _i) \
-	(unsigned long)(pending_vaddrs[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#else
-#define MMAP_VADDR(_req,_seg)						\
-	(mmap_vstart +							\
-	 ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +	\
-	 ((_seg) * PAGE_SIZE))
-#endif
+static int blkif_reqs = 64;
+static int mmap_pages;
+
+static int __init set_blkif_reqs(char *str)
+{
+	get_option(&str, &blkif_reqs);
+	return 1;
+}
+__setup("blkif_reqs=", set_blkif_reqs);
+
 
 /*
  * Each outstanding request that we've passed to the lower device layers has a 
@@ -55,43 +52,38 @@
 	atomic_t       pendcnt;
 	unsigned short operation;
 	int            status;
+	struct list_head free_list;
 } pending_req_t;
 
-/*
- * We can't allocate pending_req's in order, since they may complete out of 
- * order. We therefore maintain an allocation ring. This ring also indicates 
- * when enough work has been passed down -- at that point the allocation ring 
- * will be empty.
- */
-static pending_req_t pending_reqs[MAX_PENDING_REQS];
-static unsigned char pending_ring[MAX_PENDING_REQS];
-static spinlock_t pend_prod_lock = SPIN_LOCK_UNLOCKED;
-/* NB. We use a different index type to differentiate from shared blk rings. */
-typedef unsigned int PEND_RING_IDX;
-#define MASK_PEND_IDX(_i) ((_i)&(MAX_PENDING_REQS-1))
-static PEND_RING_IDX pending_prod, pending_cons;
-#define NR_PENDING_REQS (MAX_PENDING_REQS - pending_prod + pending_cons)
-
-static request_queue_t *plugged_queue;
-static inline void flush_plugged_queue(void)
-{
-	request_queue_t *q = plugged_queue;
-	if (q != NULL) {
-		if ( q->unplug_fn != NULL )
-			q->unplug_fn(q);
-		blk_put_queue(q);
-		plugged_queue = NULL;
-	}
-}
+static pending_req_t *pending_reqs;
+static struct list_head pending_free;
+static spinlock_t pending_free_lock = SPIN_LOCK_UNLOCKED;
+static DECLARE_WAIT_QUEUE_HEAD(pending_free_wq);
+
+#define BLKBACK_INVALID_HANDLE (0xFFFF)
+
+static unsigned long mmap_vstart;
+static unsigned long *pending_vaddrs;
+static u16 *pending_grant_handles;
+
+static inline int vaddr_pagenr(pending_req_t *req, int seg)
+{
+	return (req - pending_reqs) * BLKIF_MAX_SEGMENTS_PER_REQUEST + seg;
+}
+
+static inline unsigned long vaddr(pending_req_t *req, int seg)
+{
+	return pending_vaddrs[vaddr_pagenr(req, seg)];
+}
+
+#define pending_handle(_req, _seg) \
+	(pending_grant_handles[vaddr_pagenr(_req, _seg)])
+
 
 /* When using grant tables to map a frame for device access then the
  * handle returned must be used to unmap the frame. This is needed to
  * drop the ref count on the frame.
  */
-static u16 pending_grant_handles[MMAP_PAGES];
-#define pending_handle(_idx, _i) \
-    (pending_grant_handles[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#define BLKBACK_INVALID_HANDLE (0xFFFF)
 
 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
 /*
@@ -105,26 +97,79 @@
 static inline domid_t ID_TO_DOM(unsigned long id) { return (id >> 16); }
 #endif
 
-static int do_block_io_op(blkif_t *blkif, int max_to_do);
-static void dispatch_rw_block_io(blkif_t *blkif, blkif_request_t *req);
+static int do_block_io_op(blkif_t *blkif);
+static void dispatch_rw_block_io(blkif_t *blkif,
+				 blkif_request_t *req,
+				 pending_req_t *pending_req);
 static void make_response(blkif_t *blkif, unsigned long id, 
                           unsigned short op, int st);
 
-static void fast_flush_area(int idx, int nr_pages)
+/******************************************************************
+ * misc small helpers
+ */
+static pending_req_t* alloc_req(void)
+{
+	pending_req_t *req = NULL;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+	if (!list_empty(&pending_free)) {
+		req = list_entry(pending_free.next, pending_req_t, free_list);
+		list_del(&req->free_list);
+	}
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+	return req;
+}
+
+static void free_req(pending_req_t *req)
+{
+	unsigned long flags;
+	int was_empty;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+	was_empty = list_empty(&pending_free);
+	list_add(&req->free_list, &pending_free);
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+	if (was_empty)
+		wake_up(&pending_free_wq);
+}
+
+static void unplug_queue(blkif_t *blkif)
+{
+	if (NULL == blkif->plug)
+		return;
+	if (blkif->plug->unplug_fn)
+		blkif->plug->unplug_fn(blkif->plug);
+	blk_put_queue(blkif->plug);
+	blkif->plug = NULL;
+}
+
+static void plug_queue(blkif_t *blkif, struct bio *bio)
+{
+	request_queue_t *q = bdev_get_queue(bio->bi_bdev);
+
+	if (q == blkif->plug)
+		return;
+	unplug_queue(blkif);
+	blk_get_queue(q);
+	blkif->plug = q;
+}
+
+static void fast_flush_area(pending_req_t *req)
 {
 	struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	unsigned int i, invcount = 0;
 	u16 handle;
 	int ret;
 
-	for (i = 0; i < nr_pages; i++) {
-		handle = pending_handle(idx, i);
+	for (i = 0; i < req->nr_pages; i++) {
+		handle = pending_handle(req, i);
 		if (handle == BLKBACK_INVALID_HANDLE)
 			continue;
-		unmap[invcount].host_addr    = MMAP_VADDR(idx, i);
+		unmap[invcount].host_addr    = vaddr(req, i);
 		unmap[invcount].dev_bus_addr = 0;
 		unmap[invcount].handle       = handle;
-		pending_handle(idx, i) = BLKBACK_INVALID_HANDLE;
+		pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
 		invcount++;
 	}
 
@@ -133,109 +178,72 @@
 	BUG_ON(ret);
 }
 
-
-/******************************************************************
- * BLOCK-DEVICE SCHEDULER LIST MAINTENANCE
- */
-
-static struct list_head blkio_schedule_list;
-static spinlock_t blkio_schedule_list_lock;
-
-static int __on_blkdev_list(blkif_t *blkif)
-{
-	return blkif->blkdev_list.next != NULL;
-}
-
-static void remove_from_blkdev_list(blkif_t *blkif)
-{
-	unsigned long flags;
-
-	if (!__on_blkdev_list(blkif))
-		return;
-
-	spin_lock_irqsave(&blkio_schedule_list_lock, flags);
-	if (__on_blkdev_list(blkif)) {
-		list_del(&blkif->blkdev_list);
-		blkif->blkdev_list.next = NULL;
-		blkif_put(blkif);
-	}
-	spin_unlock_irqrestore(&blkio_schedule_list_lock, flags);
-}
-
-static void add_to_blkdev_list_tail(blkif_t *blkif)
-{
-	unsigned long flags;
-
-	if (__on_blkdev_list(blkif))
-		return;
-
-	spin_lock_irqsave(&blkio_schedule_list_lock, flags);
-	if (!__on_blkdev_list(blkif) && (blkif->status == CONNECTED)) {
-		list_add_tail(&blkif->blkdev_list, &blkio_schedule_list);
-		blkif_get(blkif);
-	}
-	spin_unlock_irqrestore(&blkio_schedule_list_lock, flags);
-}
-
-
 /******************************************************************
  * SCHEDULER FUNCTIONS
  */
 
-static DECLARE_WAIT_QUEUE_HEAD(blkio_schedule_wait);
-
-static int blkio_schedule(void *arg)
-{
-	DECLARE_WAITQUEUE(wq, current);
-
-	blkif_t          *blkif;
-	struct list_head *ent;
-
-	daemonize("xenblkd");
-
+int blkif_schedule(void *arg)
+{
+	blkif_t          *blkif = arg;
+
+	blkif_get(blkif);
+	printk(KERN_DEBUG "%s: started\n", current->comm);
 	for (;;) {
-		/* Wait for work to do. */
-		add_wait_queue(&blkio_schedule_wait, &wq);
-		set_current_state(TASK_INTERRUPTIBLE);
-		if ( (NR_PENDING_REQS == MAX_PENDING_REQS) || 
-		     list_empty(&blkio_schedule_list) )
-			schedule();
-		__set_current_state(TASK_RUNNING);
-		remove_wait_queue(&blkio_schedule_wait, &wq);
-
-		/* Queue up a batch of requests. */
-		while ((NR_PENDING_REQS < MAX_PENDING_REQS) &&
-		       !list_empty(&blkio_schedule_list)) {
-			ent = blkio_schedule_list.next;
-			blkif = list_entry(ent, blkif_t, blkdev_list);
-			blkif_get(blkif);
-			remove_from_blkdev_list(blkif);
-			if (do_block_io_op(blkif, BATCH_PER_DOMAIN))
-				add_to_blkdev_list_tail(blkif);
-			blkif_put(blkif);
-		}
-
-		/* Push the batch through to disc. */
-		flush_plugged_queue();
-	}
-}
-
-static void maybe_trigger_blkio_schedule(void)
-{
-	/*
-	 * Needed so that two processes, which together make the following
-	 * predicate true, don't both read stale values and evaluate the
-	 * predicate incorrectly. Incredibly unlikely to stall the scheduler
-	 * on x86, but...
-	 */
-	smp_mb();
-
-	if ((NR_PENDING_REQS < (MAX_PENDING_REQS/2)) &&
-	    !list_empty(&blkio_schedule_list))
-		wake_up(&blkio_schedule_wait);
-}
-
-
+		if (kthread_should_stop()) {
+			/* asked to quit? */
+			if (!atomic_read(&blkif->io_pending))
+				break;
+			printk(KERN_DEBUG "%s: I/O pending, delaying exit\n",
+			       current->comm);
+		}
+
+		if (!atomic_read(&blkif->io_pending)) {
+			/* Wait for work to do. */
+			wait_event_interruptible(blkif->wq,
+						 atomic_read(&blkif->io_pending) ||
+						 kthread_should_stop());
+		} else if (list_empty(&pending_free)) {
+			/* Wait for pending_req becoming available. */
+			wait_event_interruptible(pending_free_wq,
+						 !list_empty(&pending_free));
+		}
+
+		if (blkif->status != CONNECTED) {
+			/* make sure we are connected */
+			printk(KERN_DEBUG "%s: not connected (%d pending)\n",
+			       current->comm, atomic_read(&blkif->io_pending));
+			wait_event_interruptible(blkif->wq,
+						 blkif->status != CONNECTED ||
+						 kthread_should_stop());
+			continue;
+		}
+
+		/* Schedule I/O */
+		atomic_set(&blkif->io_pending, 0);
+		if (do_block_io_op(blkif))
+			atomic_inc(&blkif->io_pending);
+		unplug_queue(blkif);
+
+#if 0
+		/* Print stats for performance debugging. */
+		if (time_after(jiffies, blkif->st_print)) {
+			printk(KERN_DEBUG "%s: oo %3d  |  rd %4d  |  wr %4d\n",
+			       current->comm, blkif->st_oo_req,
+			       blkif->st_rd_req, blkif->st_wr_req);
+			blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000);
+			blkif->st_rd_req = 0;
+			blkif->st_wr_req = 0;
+			blkif->st_oo_req = 0;
+		}
+#endif
+	}
+
+	/* bye folks, and thanks for all the fish ;) */
+	printk(KERN_DEBUG "%s: exiting\n", current->comm);
+	blkif->xenblkd = NULL;
+	blkif_put(blkif);
+	return 0;
+}
 
 /******************************************************************
  * COMPLETION CALLBACK -- Called as bh->b_end_io()
@@ -243,8 +251,6 @@
 
 static void __end_block_io_op(pending_req_t *pending_req, int uptodate)
 {
-	unsigned long flags;
-
 	/* An error fails the entire request. */
 	if (!uptodate) {
 		DPRINTK("Buffer not up-to-date at end of operation\n");
@@ -252,15 +258,11 @@
 	}
 
 	if (atomic_dec_and_test(&pending_req->pendcnt)) {
-		int pending_idx = pending_req - pending_reqs;
-		fast_flush_area(pending_idx, pending_req->nr_pages);
+		fast_flush_area(pending_req);
 		make_response(pending_req->blkif, pending_req->id,
 			      pending_req->operation, pending_req->status);
 		blkif_put(pending_req->blkif);
-		spin_lock_irqsave(&pend_prod_lock, flags);
-		pending_ring[MASK_PEND_IDX(pending_prod++)] = pending_idx;
-		spin_unlock_irqrestore(&pend_prod_lock, flags);
-		maybe_trigger_blkio_schedule();
+		free_req(pending_req);
 	}
 }
 
@@ -281,8 +283,9 @@
 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
 {
 	blkif_t *blkif = dev_id;
-	add_to_blkdev_list_tail(blkif);
-	maybe_trigger_blkio_schedule();
+
+	atomic_inc(&blkif->io_pending);
+	wake_up(&blkif->wq);
 	return IRQ_HANDLED;
 }
 
@@ -292,10 +295,11 @@
  * DOWNWARD CALLS -- These interface with the block-device layer proper.
  */
 
-static int do_block_io_op(blkif_t *blkif, int max_to_do)
+static int do_block_io_op(blkif_t *blkif)
 {
 	blkif_back_ring_t *blk_ring = &blkif->blk_ring;
 	blkif_request_t *req;
+	pending_req_t *pending_req;
 	RING_IDX i, rp;
 	int more_to_do = 0;
 
@@ -305,24 +309,30 @@
 	for (i = blk_ring->req_cons; 
 	     (i != rp) && !RING_REQUEST_CONS_OVERFLOW(blk_ring, i);
 	     i++) {
-		if ((max_to_do-- == 0) ||
-		    (NR_PENDING_REQS == MAX_PENDING_REQS)) {
+
+		pending_req = alloc_req();
+		if (NULL == pending_req) {
+			blkif->st_oo_req++;
 			more_to_do = 1;
 			break;
 		}
-        
+
 		req = RING_GET_REQUEST(blk_ring, i);
 		switch (req->operation) {
 		case BLKIF_OP_READ:
+			blkif->st_rd_req++;
+			dispatch_rw_block_io(blkif, req, pending_req);
+			break;
 		case BLKIF_OP_WRITE:
-			dispatch_rw_block_io(blkif, req);
+			blkif->st_wr_req++;
+			dispatch_rw_block_io(blkif, req, pending_req);
 			break;
-
 		default:
 			DPRINTK("error: unknown block io operation [%d]\n",
 				req->operation);
 			make_response(blkif, req->id, req->operation,
 				      BLKIF_RSP_ERROR);
+			free_req(pending_req);
 			break;
 		}
 	}
@@ -331,13 +341,13 @@
 	return more_to_do;
 }
 
-static void dispatch_rw_block_io(blkif_t *blkif, blkif_request_t *req)
+static void dispatch_rw_block_io(blkif_t *blkif,
+				 blkif_request_t *req,
+				 pending_req_t *pending_req)
 {
 	extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]); 
 	int operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
 	unsigned long fas = 0;
-	int i, pending_idx = pending_ring[MASK_PEND_IDX(pending_cons)];
-	pending_req_t *pending_req;
 	struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	struct phys_req preq;
 	struct { 
@@ -345,31 +355,35 @@
 	} seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	unsigned int nseg;
 	struct bio *bio = NULL, *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
-	int nbio = 0;
-	request_queue_t *q;
-	int ret, errors = 0;
+	int ret, i, nbio = 0;
 
 	/* Check that number of segments is sane. */
 	nseg = req->nr_segments;
 	if (unlikely(nseg == 0) || 
 	    unlikely(nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) {
 		DPRINTK("Bad number of segments in request (%d)\n", nseg);
-		goto bad_descriptor;
+		goto fail_response;
 	}
 
 	preq.dev           = req->handle;
 	preq.sector_number = req->sector_number;
 	preq.nr_sects      = 0;
 
+	pending_req->blkif     = blkif;
+	pending_req->id        = req->id;
+	pending_req->operation = operation;
+	pending_req->status    = BLKIF_RSP_OKAY;
+	pending_req->nr_pages  = nseg;
+
 	for (i = 0; i < nseg; i++) {
 		fas         = req->frame_and_sects[i];
 		seg[i].nsec = blkif_last_sect(fas) - blkif_first_sect(fas) + 1;
 
 		if (seg[i].nsec <= 0)
-			goto bad_descriptor;
+			goto fail_response;
 		preq.nr_sects += seg[i].nsec;
 
-		map[i].host_addr = MMAP_VADDR(pending_idx, i);
+		map[i].host_addr = vaddr(pending_req, i);
 		map[i].dom = blkif->domid;
 		map[i].ref = blkif_gref_from_fas(fas);
 		map[i].flags = GNTMAP_host_map;
@@ -381,27 +395,23 @@
 	BUG_ON(ret);
 
 	for (i = 0; i < nseg; i++) {
-		if (likely(map[i].handle >= 0)) {
-			pending_handle(pending_idx, i) = map[i].handle;
+		if (unlikely(map[i].handle < 0)) {
+			DPRINTK("invalid buffer -- could not remap it\n");
+			goto fail_flush;
+		}
+
+		pending_handle(pending_req, i) = map[i].handle;
 #ifdef __ia64__
-			MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
+		pending_vaddrs[vaddr_pagenr(req, seg)] =
+			= gnttab_map_vaddr(map[i]);
 #else
-			set_phys_to_machine(__pa(MMAP_VADDR(
-				pending_idx, i)) >> PAGE_SHIFT,
-				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT));
+		set_phys_to_machine(__pa(vaddr(
+			pending_req, i)) >> PAGE_SHIFT,
+			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
 #endif
-			fas        = req->frame_and_sects[i];
-			seg[i].buf = map[i].dev_bus_addr | 
-				(blkif_first_sect(fas) << 9);
-		} else {
-			errors++;
-		}
-	}
-
-	if (errors) {
-		DPRINTK("invalid buffer -- could not remap it\n");
-		fast_flush_area(pending_idx, nseg);
-		goto bad_descriptor;
+		fas         = req->frame_and_sects[i];
+		seg[i].buf  = map[i].dev_bus_addr | 
+			(blkif_first_sect(fas) << 9);
 	}
 
 	if (vbd_translate(&preq, blkif, operation) != 0) {
@@ -409,37 +419,25 @@
 			operation == READ ? "read" : "write",
 			preq.sector_number,
 			preq.sector_number + preq.nr_sects, preq.dev); 
-		goto bad_descriptor;
-	}
-
-	pending_req = &pending_reqs[pending_idx];
-	pending_req->blkif     = blkif;
-	pending_req->id        = req->id;
-	pending_req->operation = operation;
-	pending_req->status    = BLKIF_RSP_OKAY;
-	pending_req->nr_pages  = nseg;
+		goto fail_flush;
+	}
 
 	for (i = 0; i < nseg; i++) {
 		if (((int)preq.sector_number|(int)seg[i].nsec) &
 		    ((bdev_hardsect_size(preq.bdev) >> 9) - 1)) {
 			DPRINTK("Misaligned I/O request from domain %d",
 				blkif->domid);
-			goto cleanup_and_fail;
+			goto fail_put_bio;
 		}
 
 		while ((bio == NULL) ||
 		       (bio_add_page(bio,
-				     virt_to_page(MMAP_VADDR(pending_idx, i)),
+				     virt_to_page(vaddr(pending_req, i)),
 				     seg[i].nsec << 9,
 				     seg[i].buf & ~PAGE_MASK) == 0)) {
 			bio = biolist[nbio++] = bio_alloc(GFP_KERNEL, nseg-i);
-			if (unlikely(bio == NULL)) {
-			cleanup_and_fail:
-				for (i = 0; i < (nbio-1); i++)
-					bio_put(biolist[i]);
-				fast_flush_area(pending_idx, nseg);
-				goto bad_descriptor;
-			}
+			if (unlikely(bio == NULL))
+				goto fail_put_bio;
                 
 			bio->bi_bdev    = preq.bdev;
 			bio->bi_private = pending_req;
@@ -450,14 +448,8 @@
 		preq.sector_number += seg[i].nsec;
 	}
 
-	if ((q = bdev_get_queue(bio->bi_bdev)) != plugged_queue) {
-		flush_plugged_queue();
-		blk_get_queue(q);
-		plugged_queue = q;
-	}
-
+	plug_queue(blkif, bio);
 	atomic_set(&pending_req->pendcnt, nbio);
-	pending_cons++;
 	blkif_get(blkif);
 
 	for (i = 0; i < nbio; i++)
@@ -465,8 +457,14 @@
 
 	return;
 
- bad_descriptor:
+ fail_put_bio:
+	for (i = 0; i < (nbio-1); i++)
+		bio_put(biolist[i]);
+ fail_flush:
+	fast_flush_area(pending_req);
+ fail_response:
 	make_response(blkif, req->id, req->operation, BLKIF_RSP_ERROR);
+	free_req(pending_req);
 } 
 
 
@@ -498,56 +496,50 @@
 	notify_remote_via_irq(blkif->irq);
 }
 
-void blkif_deschedule(blkif_t *blkif)
-{
-	remove_from_blkdev_list(blkif);
-}
-
 static int __init blkif_init(void)
 {
+	struct page *page;
 	int i;
-	struct page *page;
-	int ret;
-
-	for (i = 0; i < MMAP_PAGES; i++)
-		pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
 
 	if (xen_init() < 0)
 		return -ENODEV;
 
+	mmap_pages            = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
+	pending_reqs          = kmalloc(sizeof(pending_reqs[0]) *
+					blkif_reqs, GFP_KERNEL);
+	pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
+					mmap_pages, GFP_KERNEL);
+	pending_vaddrs        = kmalloc(sizeof(pending_vaddrs[0]) *
+					mmap_pages, GFP_KERNEL);
+	if (!pending_reqs || !pending_grant_handles || !pending_vaddrs) {
+		printk("%s: out of memory\n", __FUNCTION__);
+		return -1;
+	}
+
 	blkif_interface_init();
-
+	
 #ifdef __ia64__
-    {
 	extern unsigned long alloc_empty_foreign_map_page_range(unsigned long pages);
-	int i;
-
-	mmap_vstart =  alloc_empty_foreign_map_page_range(MMAP_PAGES);
-	printk("Allocated mmap_vstart: 0x%lx\n", mmap_vstart);
-	for(i = 0; i < MMAP_PAGES; i++)
-	    pending_vaddrs[i] = mmap_vstart + (i << PAGE_SHIFT);
-	BUG_ON(mmap_vstart == NULL);
-    }
-#else
-	page = balloon_alloc_empty_page_range(MMAP_PAGES);
+	mmap_vstart = (unsigned long)alloc_empty_foreign_map_page_range(mmap_pages);
+#else /* ! ia64 */
+	page = balloon_alloc_empty_page_range(mmap_pages);
 	BUG_ON(page == NULL);
 	mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
 #endif
-
-	pending_cons = 0;
-	pending_prod = MAX_PENDING_REQS;
+	printk("%s: reqs=%d, pages=%d, mmap_vstart=0x%lx\n",
+	       __FUNCTION__, blkif_reqs, mmap_pages, mmap_vstart);
+	BUG_ON(mmap_vstart == 0);
+	for (i = 0; i < mmap_pages; i++)
+		pending_vaddrs[i] = mmap_vstart + (i << PAGE_SHIFT);
+
+	memset(pending_grant_handles,  BLKBACK_INVALID_HANDLE, mmap_pages);
 	memset(pending_reqs, 0, sizeof(pending_reqs));
-	for (i = 0; i < MAX_PENDING_REQS; i++)
-		pending_ring[i] = i;
+	INIT_LIST_HEAD(&pending_free);
+
+	for (i = 0; i < blkif_reqs; i++)
+		list_add_tail(&pending_reqs[i].free_list, &pending_free);
     
-	spin_lock_init(&blkio_schedule_list_lock);
-	INIT_LIST_HEAD(&blkio_schedule_list);
-
-	ret = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
-	BUG_ON(ret < 0);
-
 	blkif_xenbus_init();
-
 	return 0;
 }
 
diff -r 090e44133d40 linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Mon Nov 14 17:13:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Tue Nov 15 18:17:26 2005
@@ -56,9 +56,19 @@
 	/* Is this a blktap frontend */
 	unsigned int     is_blktap;
 #endif
-	struct list_head blkdev_list;
 	spinlock_t       blk_ring_lock;
 	atomic_t         refcnt;
+
+	wait_queue_head_t   wq;
+	struct task_struct  *xenblkd;
+	atomic_t            io_pending;
+	request_queue_t     *plug;
+
+	/* statistics */
+	unsigned long       st_print;
+	int                 st_rd_req;
+	int                 st_wr_req;
+	int                 st_oo_req;
 
 	struct work_struct free_work;
 
@@ -97,11 +107,10 @@
 
 void blkif_interface_init(void);
 
-void blkif_deschedule(blkif_t *blkif);
-
 void blkif_xenbus_init(void);
 
 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
+int blkif_schedule(void *arg);
 
 #endif /* __BLKIF__BACKEND__COMMON_H__ */
 
diff -r 090e44133d40 linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Mon Nov 14 17:13:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Tue Nov 15 18:17:26 2005
@@ -24,6 +24,8 @@
 	blkif->status = DISCONNECTED;
 	spin_lock_init(&blkif->blk_ring_lock);
 	atomic_set(&blkif->refcnt, 1);
+	init_waitqueue_head(&blkif->wq);
+	blkif->st_print = jiffies;
 
 	return blkif;
 }
@@ -113,6 +115,7 @@
 	blkif->irq = bind_evtchn_to_irqhandler(
 		blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
 	blkif->status = CONNECTED;
+	wake_up(&blkif->wq);
 
 	return 0;
 }
diff -r 090e44133d40 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Mon Nov 14 17:13:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Tue Nov 15 18:17:26 2005
@@ -20,6 +20,7 @@
 
 #include <stdarg.h>
 #include <linux/module.h>
+#include <linux/kthread.h>
 #include <asm-xen/xenbus.h>
 #include "common.h"
 
@@ -61,6 +62,8 @@
 		be->backend_watch.node = NULL;
 	}
 	if (be->blkif) {
+		if (be->blkif->xenblkd)
+			kthread_stop(be->blkif->xenblkd);
 		blkif_put(be->blkif);
 		be->blkif = NULL;
 	}
@@ -175,6 +178,16 @@
 			be->pdev = 0L;
 			xenbus_dev_fatal(dev, err,
 					 "creating vbd structure");
+			return;
+		}
+
+		be->blkif->xenblkd = kthread_run(blkif_schedule, be->blkif,
+						 "xenblkd %d/%04lx",
+						 be->blkif->domid, be->pdev);
+		if (IS_ERR(be->blkif->xenblkd)) {
+			err = PTR_ERR(be->blkif->xenblkd);
+			be->blkif->xenblkd = NULL;
+			xenbus_dev_error(dev, err, "start xenblkd");
 			return;
 		}
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 3%]

* [PATCH] move /proc/xen to /proc/sys/xen in xen linux
@ 2005-11-16 15:48 29% Mike D. Day
  0 siblings, 0 replies; 200+ results
From: Mike D. Day @ 2005-11-16 15:48 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 104 bytes --]


-- 

Mike D. Day
STSM and Architect, Open Virtualization
IBM Linux Technology Center
ncmike@us.ibm.com

[-- Attachment #2: proc_xen.diff --]
[-- Type: text/plain, Size: 5075 bytes --]

# HG changeset patch
# User mdday@aksrc.raleigh.ibm.com
# Node ID 133b58ab5a8ff2a5b00a342de402588d0e2fd36b
# Parent  9bf6f907b3ff0261902f06d261f76c1bd12af9f5
Move /proc/xen to /proc/sys/xen

signed-off-by: Mike Day <ncmike@us.ibm.com>

diff -r 9bf6f907b3ff -r 133b58ab5a8f linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Wed Nov 16 10:29:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Wed Nov 16 15:34:49 2005
@@ -442,7 +442,7 @@
 	 *  /proc/xen/grant : used by libxc to access grant tables
 	 */
 	if ((grant_pde = create_xen_proc_entry("grant", 0600)) == NULL) {
-		WPRINTK("Unable to create grant xen proc entry\n");
+		WPRINTK("Unable to create /proc/sys/xen/grant_pde.\n");
 		return -1;
 	}
 
diff -r 9bf6f907b3ff -r 133b58ab5a8f linux-2.6-xen-sparse/arch/xen/kernel/xen_proc.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/xen_proc.c	Wed Nov 16 10:29:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/xen_proc.c	Wed Nov 16 15:34:49 2005
@@ -8,8 +8,9 @@
 struct proc_dir_entry *create_xen_proc_entry(const char *name, mode_t mode)
 {
 	if ( xen_base == NULL )
-		if ( (xen_base = proc_mkdir("xen", &proc_root)) == NULL )
+		if ( (xen_base = proc_mkdir("sys/xen", NULL)) == NULL ) {
 			panic("Couldn't create /proc/xen");
+		}
 	return create_proc_entry(name, mode, xen_base);
 }
 
diff -r 9bf6f907b3ff -r 133b58ab5a8f linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Nov 16 10:29:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Nov 16 15:34:49 2005
@@ -470,7 +470,7 @@
 	balloon_timer.function = balloon_alarm;
     
 	if ((balloon_pde = create_xen_proc_entry("balloon", 0644)) == NULL) {
-		WPRINTK("Unable to create /proc/xen/balloon.\n");
+		WPRINTK("Unable to create /proc/sys/xen/balloon.\n");
 		return -1;
 	}
 
diff -r 9bf6f907b3ff -r 133b58ab5a8f linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Wed Nov 16 10:29:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Wed Nov 16 15:34:49 2005
@@ -38,6 +38,8 @@
 #endif
 
 static struct proc_dir_entry *privcmd_intf;
+#define WPRINTK(fmt, args...) \
+	printk(KERN_WARNING "xen_privcmd: " fmt, ##args)
 
 static int privcmd_ioctl(struct inode *inode, struct file *file,
                          unsigned int cmd, unsigned long data)
@@ -254,10 +256,11 @@
 
 static int __init privcmd_init(void)
 {
-	privcmd_intf = create_xen_proc_entry("privcmd", 0400);
-	if (privcmd_intf != NULL)
-		privcmd_intf->proc_fops = &privcmd_file_ops;
-
+	if ((privcmd_intf = create_xen_proc_entry("privcmd", 0400)) == NULL ) {
+		WPRINTK("Unable to create /proc/sys/xen/privcmd.\n");
+		return -1;	
+	}
+	privcmd_intf->proc_fops = &privcmd_file_ops;
 	return 0;
 }
 
diff -r 9bf6f907b3ff -r 133b58ab5a8f linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Wed Nov 16 10:29:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Wed Nov 16 15:34:49 2005
@@ -44,6 +44,9 @@
 #include <asm-xen/xenbus.h>
 #include <asm-xen/xen_proc.h>
 #include <asm/hypervisor.h>
+
+#define WPRINTK(fmt, args...) \
+	printk(KERN_WARNING "xenbus: " fmt, ##args)
 
 struct xenbus_dev_transaction {
 	struct list_head list;
@@ -221,10 +224,11 @@
 static int __init
 xenbus_dev_init(void)
 {
-	xenbus_dev_intf = create_xen_proc_entry("xenbus", 0400);
-	if (xenbus_dev_intf)
-		xenbus_dev_intf->proc_fops = &xenbus_dev_file_ops;
-
+	if((xenbus_dev_intf = create_xen_proc_entry("xenbus", 0400)) == NULL) {
+		WPRINTK("Unable to create /proc/sys/xen/xenbus.\n");
+		return -1;	
+	}
+	xenbus_dev_intf->proc_fops = &xenbus_dev_file_ops;
 	return 0;
 }
 
diff -r 9bf6f907b3ff -r 133b58ab5a8f linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Wed Nov 16 10:29:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Wed Nov 16 15:34:49 2005
@@ -58,6 +58,8 @@
 extern struct semaphore xenwatch_mutex;
 
 #define streq(a, b) (strcmp((a), (b)) == 0)
+#define WPRINTK(fmt, args...) \
+	printk(KERN_WARNING "xenbus_probe: " fmt, ##args)
 
 static struct notifier_block *xenstore_chain;
 
@@ -964,10 +966,17 @@
 		xen_start_info->store_evtchn = op.u.alloc_unbound.port;
 
 		/* And finally publish the above info in /proc/xen */
-		if((xsd_mfn_intf = create_xen_proc_entry("xsd_mfn", 0400)))
-			xsd_mfn_intf->read_proc = xsd_mfn_read; 
-		if((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)))
-			xsd_port_intf->read_proc = xsd_port_read;
+		if((xsd_mfn_intf = create_xen_proc_entry("xsd_mfn", 0400)) == NULL ) {
+			WPRINTK("Unable to create /proc/sys/xen/xsd_mfn.\n");
+			return -1;	
+		}
+		xsd_mfn_intf->read_proc = xsd_mfn_read; 
+		
+		if((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)) == NULL ) {
+			WPRINTK("Unable to create /proc/sys/xen/xsd_port.\n");
+			return -1;	
+		}
+		xsd_port_intf->read_proc = xsd_port_read;
 	}
 
 	/* Initialize the interface to xenstore. */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 29%]

* [PATCH][2/17] USB virt 2.6 split driver---xenidc buffer resource provider
@ 2005-11-21 13:18  5% harry
  0 siblings, 0 replies; 200+ results
From: harry @ 2005-11-21 13:18 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 186 bytes --]

This patch implements a resource pool for buffer resources used by the
xenidc transport which is in turn used by the USB driver.

Signed-off-by: Harry Butterworth <butterwo@uk.ibm.com>


[-- Attachment #2: p2-xenidc-buffer-resource-provider.patch --]
[-- Type: text/x-patch, Size: 19255 bytes --]

diff -r 7adcceaaf851 -r 1e2c0ff9c46a linux-2.6-xen-sparse/drivers/xen/xenidc/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/xenidc/Makefile	Sun Nov 20 14:53:27 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenidc/Makefile	Sun Nov 20 14:53:55 2005
@@ -3,3 +3,4 @@
 xenidc-objs =
 xenidc-objs += xenidc_callback.o
 xenidc-objs += xenidc_work.o
+xenidc-objs += xenidc_buffer_resource_provider.o
diff -r 7adcceaaf851 -r 1e2c0ff9c46a linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_buffer_resource_provider.c
--- /dev/null	Sun Nov 20 14:53:27 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_buffer_resource_provider.c	Sun Nov 20 14:53:55 2005
@@ -0,0 +1,443 @@
+/*****************************************************************************/
+/* Xen inter-domain communication buffer resource provider.                  */
+/*                                                                           */
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+/*****************************************************************************/
+/* Based on                                                                  */
+/*                                                                           */
+/* arch/xen/drivers/blkback/blkback.c                                        */
+/*                                                                           */
+/* original copyright notice follows...                                      */
+/*****************************************************************************/
+/******************************************************************************
+ * arch/xen/drivers/blkif/backend/main.c
+ * 
+ * Back-end of the driver for virtual block devices. This portion of the
+ * driver exports a 'unified' block-device interface that can be accessed
+ * by any operating system that implements a compatible front end. A 
+ * reference front-end implementation can be found in:
+ *  arch/xen/drivers/blkif/frontend
+ * 
+ * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
+ * Copyright (c) 2005, Christopher Clark
+ */
+
+#include <asm/pgalloc.h>
+#include <linux/spinlock.h>
+#include <asm-xen/balloon.h>
+#include <asm-xen/driver_util.h>
+#include <asm-xen/xenidc_buffer_resource_provider.h>
+#include <linux/errno.h>
+#include <linux/gfp.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/vmalloc.h>
+#include "xenidc_trace.h"
+
+struct xenidc_buffer_resource_provider_struct {
+	spinlock_t lock;
+	xenidc_buffer_resource_list resource_allocation;
+	xenidc_buffer_resource_list free_resources;
+	struct list_head page_list;
+	grant_ref_t grant_ref_pool;
+	struct page *page;
+	unsigned long mmap_vstart;
+	struct list_head empty_page_range_list;
+	struct list_head *empty_page_range_link;
+};
+
+static int xenidc_buffer_resource_provider_init_or_exit
+    (xenidc_buffer_resource_provider * provider, int exit) {
+	trace1("%p", provider);
+
+	{
+		int return_value = 0;
+
+		if (exit) {
+			goto EXIT;
+		}
+
+		spin_lock_init(&provider->lock);
+
+		provider->free_resources = xenidc_buffer_resource_list_null();
+
+		INIT_LIST_HEAD(&provider->page_list);
+
+		{
+			int i;
+
+			for (i = 0; i < provider->resource_allocation.pages;
+			     i++) {
+				void *page =
+				    (void *)__get_free_page(GFP_KERNEL);
+
+				if (page == NULL) {
+					return_value = -ENOMEM;
+
+					goto EXIT_NO_PAGE;
+				}
+
+				xenidc_buffer_resource_provider_free_page
+				    (provider, page);
+			}
+		}
+
+		if (provider->resource_allocation.grant_references != 0) {
+			return_value = gnttab_alloc_grant_references
+			    (provider->resource_allocation.grant_references,
+			     &provider->grant_ref_pool);
+
+			if (return_value != 0) {
+				trace0
+				    ("failed to allocate grant reference pool");
+
+				goto EXIT_NO_GRANT_REF;
+			}
+
+			provider->free_resources.grant_references =
+			    provider->resource_allocation.grant_references;
+		}
+
+		if (provider->resource_allocation.empty_page_ranges != 0) {
+			provider->page = balloon_alloc_empty_page_range
+			    (provider->resource_allocation.empty_page_ranges
+			     *
+			     provider->resource_allocation.
+			     empty_page_range_page_count);
+
+			if (provider->page == NULL) {
+				return_value = -ENOMEM;
+
+				goto EXIT_NO_EMPTY_PAGE_RANGE;
+			}
+
+			provider->mmap_vstart =
+			    (unsigned long)
+			    pfn_to_kaddr(page_to_pfn(provider->page));
+
+			INIT_LIST_HEAD(&provider->empty_page_range_list);
+
+			provider->empty_page_range_link = vmalloc
+			    (sizeof(struct list_head)
+			     * provider->resource_allocation.empty_page_ranges);
+
+			if (provider->empty_page_range_link == NULL) {
+				return_value = -ENOMEM;
+
+				goto EXIT_NO_EMPTY_PAGE_RANGE_LINK;
+			}
+
+			{
+				int i;
+
+				for (i = 0;
+				     i <
+				     provider->resource_allocation.
+				     empty_page_ranges; i++) {
+					struct list_head *link =
+					    &provider->empty_page_range_link[i];
+
+					INIT_LIST_HEAD(link);
+
+					list_add(link,
+						 &provider->
+						 empty_page_range_list);
+				}
+			}
+
+			provider->free_resources.empty_page_ranges =
+			    provider->resource_allocation.empty_page_ranges;
+
+			provider->free_resources.empty_page_range_page_count =
+			    provider->resource_allocation.
+			    empty_page_range_page_count;
+		}
+
+		return 0;
+
+	      EXIT:
+
+		if (provider->resource_allocation.empty_page_ranges != 0) {
+			vfree(provider->empty_page_range_link);
+
+		      EXIT_NO_EMPTY_PAGE_RANGE_LINK:
+
+			balloon_dealloc_empty_page_range
+			    (provider->page,
+			     provider->resource_allocation.empty_page_ranges
+			     *
+			     provider->resource_allocation.
+			     empty_page_range_page_count);
+		}
+
+	      EXIT_NO_EMPTY_PAGE_RANGE:
+
+		if (provider->resource_allocation.grant_references != 0) {
+			gnttab_free_grant_references(provider->grant_ref_pool);
+		}
+
+	      EXIT_NO_GRANT_REF:
+
+	      EXIT_NO_PAGE:
+
+		while (!list_empty(&provider->page_list)) {
+			free_page
+			    ((unsigned long)
+			     xenidc_buffer_resource_provider_allocate_page
+			     (provider)
+			    );
+		}
+
+		return return_value;
+	}
+}
+
+xenidc_buffer_resource_provider *xenidc_allocate_buffer_resource_provider
+    (xenidc_buffer_resource_list resource_allocation) {
+	trace();
+
+	{
+		xenidc_buffer_resource_provider *provider =
+		    (xenidc_buffer_resource_provider *)
+		    vmalloc(sizeof(xenidc_buffer_resource_provider));
+
+		if (provider != NULL) {
+			provider->resource_allocation = resource_allocation;
+
+			if (xenidc_buffer_resource_provider_init_or_exit
+			    (provider, 0)
+			    != 0) {
+				vfree(provider);
+
+				provider = NULL;
+			}
+		}
+
+		return provider;
+	}
+}
+
+void xenidc_free_buffer_resource_provider
+    (xenidc_buffer_resource_provider * provider) {
+	trace();
+
+	(void)xenidc_buffer_resource_provider_init_or_exit(provider, 1);
+
+	vfree(provider);
+}
+
+xenidc_buffer_resource_list
+    xenidc_buffer_resource_provider_query_free_resources
+    (xenidc_buffer_resource_provider * provider) {
+	trace();
+
+	{
+		xenidc_buffer_resource_list list;
+
+		unsigned long flags;
+
+		spin_lock_irqsave(&provider->lock, flags);
+
+		list = provider->free_resources;
+
+		spin_unlock_irqrestore(&provider->lock, flags);
+
+		return list;
+	}
+}
+
+void *xenidc_buffer_resource_provider_allocate_page
+    (xenidc_buffer_resource_provider * provider) {
+	trace();
+
+	{
+		struct list_head *link;
+
+		unsigned long flags;
+
+		spin_lock_irqsave(&provider->lock, flags);
+
+		provider->free_resources.pages--;
+
+		link = provider->page_list.next;
+
+		trace1("%p", link);
+
+		list_del(link);
+
+		spin_unlock_irqrestore(&provider->lock, flags);
+
+		return link;
+	}
+}
+
+void xenidc_buffer_resource_provider_free_page
+    (xenidc_buffer_resource_provider * provider, void *page) {
+	trace1("%p", page);
+
+	{
+		struct list_head *link = page;
+
+		INIT_LIST_HEAD(link);
+
+		{
+			unsigned long flags;
+
+			spin_lock_irqsave(&provider->lock, flags);
+
+			provider->free_resources.pages++;
+
+			list_add(link, &provider->page_list);
+
+			spin_unlock_irqrestore(&provider->lock, flags);
+		}
+	}
+}
+
+grant_ref_t xenidc_buffer_resource_provider_allocate_grant_reference
+    (xenidc_buffer_resource_provider * provider) {
+	trace();
+
+	{
+		grant_ref_t reference;
+
+		{
+			unsigned long flags;
+
+			spin_lock_irqsave(&provider->lock, flags);
+
+			provider->free_resources.grant_references--;
+
+			reference =
+			    gnttab_claim_grant_reference(&provider->
+							 grant_ref_pool);
+
+			spin_unlock_irqrestore(&provider->lock, flags);
+		}
+
+		return reference;
+	}
+}
+
+void xenidc_buffer_resource_provider_free_grant_reference
+    (xenidc_buffer_resource_provider * provider, grant_ref_t reference) {
+	trace();
+
+	{
+		unsigned long flags;
+
+		spin_lock_irqsave(&provider->lock, flags);
+
+		gnttab_release_grant_reference(&provider->grant_ref_pool,
+					       reference);
+
+		provider->free_resources.grant_references++;
+
+		spin_unlock_irqrestore(&provider->lock, flags);
+	}
+}
+
+unsigned long xenidc_buffer_resource_provider_allocate_empty_page_range
+    (xenidc_buffer_resource_provider * provider, unsigned long page_count) {
+	trace();
+
+	{
+		unsigned long page_range;
+
+		{
+			unsigned long flags;
+
+			spin_lock_irqsave(&provider->lock, flags);
+
+			{
+				struct list_head *link =
+				    provider->empty_page_range_list.next;
+
+				list_del_init(link);
+
+				provider->free_resources.empty_page_ranges--;
+
+				page_range =
+				    (provider->mmap_vstart
+				     +
+				     (PAGE_SIZE
+				      *
+				      provider->resource_allocation.
+				      empty_page_range_page_count
+				      *
+				      (((unsigned long)link
+					-
+					(unsigned long)provider->
+					empty_page_range_link)
+				       / sizeof(struct list_head)
+				      )
+				     )
+				    );
+			}
+
+			spin_unlock_irqrestore(&provider->lock, flags);
+		}
+
+		return page_range;
+	}
+}
+
+void xenidc_buffer_resource_provider_free_empty_page_range
+    (xenidc_buffer_resource_provider * provider, unsigned long page_range) {
+	trace();
+
+	{
+		int i = ((page_range - provider->mmap_vstart)
+			 /
+			 (PAGE_SIZE
+			  *
+			  provider->resource_allocation.
+			  empty_page_range_page_count)
+		    );
+
+		unsigned long flags;
+
+		spin_lock_irqsave(&provider->lock, flags);
+
+		list_add
+		    (&provider->empty_page_range_link[i],
+		     &provider->empty_page_range_list);
+
+		provider->free_resources.empty_page_ranges++;
+
+		spin_unlock_irqrestore(&provider->lock, flags);
+	}
+}
+
+void xenidc_buffer_resource_list_trace(xenidc_buffer_resource_list list)
+{
+	trace();
+
+	printk
+	    (KERN_INFO
+	     "xenidc %s: "
+	     "pages:%d; "
+	     "grant_references:%d; "
+	     "empty_page_ranges:%d; "
+	     "empty_page_range_page_count:%d\n",
+	     __PRETTY_FUNCTION__,
+	     list.pages,
+	     list.grant_references,
+	     list.empty_page_ranges, list.empty_page_range_page_count);
+}
diff -r 7adcceaaf851 -r 1e2c0ff9c46a linux-2.6-xen-sparse/include/asm-xen/xenidc_buffer_resource_provider.h
--- /dev/null	Sun Nov 20 14:53:27 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/xenidc_buffer_resource_provider.h	Sun Nov 20 14:53:55 2005
@@ -0,0 +1,138 @@
+/*****************************************************************************/
+/* Xen inter-domain communication buffer resource provider.                  */
+/*                                                                           */
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+/*                                                                           */
+/* The main point of this buffer resource provider code is to make it        */
+/* possible to write some other generic code to manipulate various types of  */
+/* buffers and keep the other code independent of any buffer-type-specific   */
+/* resource management.                                                      */
+/*                                                                           */
+/* The initial implementation of this code provides sets of resources to     */
+/* clients in isolated per-client pools but this code provides a centralised */
+/* point of buffer resource management so it will be easy to implement a     */
+/* more efficient version which maintains isolation for a base set of        */
+/* resources to avoid deadlock and then shares additional resources between  */
+/* clients.                                                                  */
+
+#ifndef __ASM_XEN_XENIDC_BUFFER_RESOURCE_PROVIDER_H__
+#define __ASM_XEN_XENIDC_BUFFER_RESOURCE_PROVIDER_H__
+
+#include <asm/types.h>
+#include <asm-xen/gnttab.h>
+
+/* A xenidc_buffer_resource_list describes a set of resources, sometimes a   */
+/* set of resources required for an operation and sometimes a set of         */
+/* resources available to perform operations.                                */
+
+typedef struct xenidc_buffer_resource_list_struct xenidc_buffer_resource_list;
+
+struct xenidc_buffer_resource_list_struct {
+	u32 pages;
+	u32 grant_references;
+	u32 empty_page_ranges;
+	u32 empty_page_range_page_count;
+};
+
+/* xenidc_buffer_resource_list_null returns a list specifying no resources. */
+
+static inline xenidc_buffer_resource_list xenidc_buffer_resource_list_null(void)
+{
+	xenidc_buffer_resource_list list;
+
+	memset(&list, 0, sizeof(list));
+
+	return list;
+}
+
+/* xenidc_buffer_resource_list_subset_of returns true iff the resource        */
+/* requirements specified by list 'a' are met by the resources available in   */
+/* list 'b'.                                                                  */
+
+static inline int xenidc_buffer_resource_list_subset_of
+    (xenidc_buffer_resource_list * a, xenidc_buffer_resource_list * b) {
+	return ((a->pages <= b->pages)
+		&& (a->grant_references <= b->grant_references)
+		&& (a->empty_page_ranges <= b->empty_page_ranges)
+		&&
+		(a->empty_page_range_page_count <=
+		 b->empty_page_range_page_count)
+	    );
+}
+
+/* xenidc_buffer_resource_list_plus_equals adds the resource requirements     */
+/* specified by list 'b' to the resource requirements specified by list 'a'   */
+/* such that the resulting list 'a' specifies a set of resources sufficient   */
+/* to meet the sum of the requirements of the original 'a' list and 'b' lists.*/
+
+static inline void xenidc_buffer_resource_list_plus_equals
+    (xenidc_buffer_resource_list * a, xenidc_buffer_resource_list * b) {
+	a->pages += b->pages;
+	a->grant_references += b->grant_references;
+	a->empty_page_ranges += b->empty_page_ranges;
+
+	if (b->empty_page_range_page_count > a->empty_page_range_page_count) {
+		a->empty_page_range_page_count = b->empty_page_range_page_count;
+	}
+}
+
+/* Clients allocate a xenidc_buffer_resource_provider to provide themselves   */
+/* with a pool of resources.                                                  */
+
+typedef struct xenidc_buffer_resource_provider_struct
+    xenidc_buffer_resource_provider;
+
+extern xenidc_buffer_resource_provider *xenidc_allocate_buffer_resource_provider
+    (xenidc_buffer_resource_list resource_allocation);
+
+extern void xenidc_free_buffer_resource_provider
+    (xenidc_buffer_resource_provider * provider);
+
+/* Find out what resources are currently free for allocation. */
+
+extern xenidc_buffer_resource_list
+    xenidc_buffer_resource_provider_query_free_resources
+    (xenidc_buffer_resource_provider * provider);
+
+/* Resource-type specific allocate/free functions. */
+
+extern void *xenidc_buffer_resource_provider_allocate_page
+    (xenidc_buffer_resource_provider * provider);
+
+extern void xenidc_buffer_resource_provider_free_page
+    (xenidc_buffer_resource_provider * provider, void *page);
+
+extern grant_ref_t xenidc_buffer_resource_provider_allocate_grant_reference
+    (xenidc_buffer_resource_provider * provider);
+
+extern void xenidc_buffer_resource_provider_free_grant_reference
+    (xenidc_buffer_resource_provider * provider, grant_ref_t reference);
+
+extern unsigned long xenidc_buffer_resource_provider_allocate_empty_page_range
+    (xenidc_buffer_resource_provider * provider, unsigned long page_count);
+
+extern void xenidc_buffer_resource_provider_free_empty_page_range
+    (xenidc_buffer_resource_provider * provider, unsigned long page_range);
+
+/* xenidc_buffer_resource_list_trace is used for debugging and printks a dump */
+/* of the resource list.                                                      */
+
+extern void xenidc_buffer_resource_list_trace(xenidc_buffer_resource_list list);
+
+#endif

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 5%]

* Re: Daily Xen Builds
  @ 2005-11-21 18:24  6% ` David F Barrera
  0 siblings, 0 replies; 200+ results
From: David F Barrera @ 2005-11-21 18:24 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]

xm-test results attached.

On Mon, 2005-11-21 at 12:20, David F Barrera wrote:
> November 21, 2005 using test changeset:
> 
> changeset:   7922:6a666940fa04
> tag:         tip
> parent:      7921:c35a32f96d20
> parent:      7902:715184c81749
> user:        kaf24@firebug.cl.cam.ac.uk
> date:        Sun Nov 20 03:19:38 2005 +0100
> summary:     Merge with xen-ia64-unstable.hg.
>  
> x86_32 (no PAE support)
> 
>        * SLES 9 SP2 on IBM xSeries 235 and 305 (1GB RAM)
>        * Builds and boots without problems
>        * Able to create fully functional guest domains
>        * Ran xm-test on all boxes
>        * Successfully ran LTP and LMBench on Dom0s and DomUs
> 
>        ISSUES:  
>      
> x86_32 (PAE)
> 
>        * SLES 9 SP2, FC3, FC4, and RHEL 4 IBM xSeries 305, 335s and IBM
>        ThinkCentre
>        * Builds and boots without problems
>        * Able to create fully functional guest domains
>        * Ran xm-test on all boxes
>        * Successfully ran LTP and LMBench on Dom0s and guest domains
> 
>        ISSUES:  
> 
> x86_64 (SLES 9 SP2 and FC4 on IBM HS20 Blades)
> 
>        * Builds and boots without problems
>        * Able to create fully functional guest domains
>        * Ran xm-test on all boxes
>        * Successfully ran LTP and LMBench on Dom0s and DomUs
> 
>        ISSUES:  
>         *Bugzilla Bug 258 x86_64 -general protection fault: 0000 [1] 
> 	 (REOPENED)
> 
>        
> ------------------------------------------------------------------------
> 
> ------------------------XM-TEST Results---------------------------------
> 
> SUMMARY:
>             Platform | PASS | FAIL | XPASS | XFAIL |
> ---------------------+------+------+-------+-------+
>               FC3pae |   73 |   20 |     1 |     0 |
> hs20.1.rhel4-x86_32pae |   73 |   20 |     1 |     0 |
>  hs20.1.sles9-x86_64 |   70 |   23 |     1 |     0 |
>  hs20.2.sles9-x86_64 |   71 |   22 |     1 |     0 |
>      hs20.fc4_x86_64 |   70 |   23 |     1 |     0 |
>      x235sles9nonpae |   73 |   20 |     1 |     0 |
>           x305rh4pae |   72 |   20 |     1 |     0 |
>      x305sles9nonpae |   72 |   20 |     1 |     0 |
>           x335fc4pae |   85 |    8 |     1 |     0 |
>     x335sles9_pae4gb |   73 |   20 |     1 |     0 |
>  x460.fc3-x86_64-8gb |   67 |   26 |     0 |     1 |
> 

[-- Attachment #2: FC3pae.report --]
[-- Type: text/plain, Size: 1777 bytes --]

Xm-test execution summary:
  PASS:  73
  FAIL:  20
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #3: hs20.1.rhel4-x86_32pae.report --]
[-- Type: text/plain, Size: 1777 bytes --]

Xm-test execution summary:
  PASS:  73
  FAIL:  20
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #4: hs20.1.sles9-x86_64.report --]
[-- Type: text/plain, Size: 1961 bytes --]

Xm-test execution summary:
  PASS:  70
  FAIL:  23
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 15_create_smallmem_pos 
	 Starting a console with 16 MB failed domain dies immediately!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 04_memset_smallmem_pos 
	 Timed out waiting for console

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_save_basic_pos 
	 save command exited 256 != 0

 FAIL: 01_restore_basic_pos 
	 save command exited 256 != 0

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #5: hs20.2.sles9-x86_64.report --]
[-- Type: text/plain, Size: 1873 bytes --]

Xm-test execution summary:
  PASS:  71
  FAIL:  22
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 04_memset_smallmem_pos 
	 Bug #380 I crashed the console system

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_save_basic_pos 
	 save command exited 256 != 0

 FAIL: 01_restore_basic_pos 
	 save command exited 256 != 0

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #6: hs20.fc4_x86_64.report --]
[-- Type: text/plain, Size: 1961 bytes --]

Xm-test execution summary:
  PASS:  70
  FAIL:  23
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 15_create_smallmem_pos 
	 Starting a console with 16 MB failed domain dies immediately!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 04_memset_smallmem_pos 
	 Timed out waiting for console

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=7)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_save_basic_pos 
	 save command exited 256 != 0

 FAIL: 01_restore_basic_pos 
	 save command exited 256 != 0

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #7: x235sles9nonpae.report --]
[-- Type: text/plain, Size: 1777 bytes --]

Xm-test execution summary:
  PASS:  73
  FAIL:  20
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #8: x305rh4pae.report --]
[-- Type: text/plain, Size: 1777 bytes --]

Xm-test execution summary:
  PASS:  72
  FAIL:  20
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #9: x305sles9nonpae.report --]
[-- Type: text/plain, Size: 1777 bytes --]

Xm-test execution summary:
  PASS:  72
  FAIL:  20
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #10: x335fc4pae.report --]
[-- Type: text/plain, Size: 695 bytes --]

Xm-test execution summary:
  PASS:  85
  FAIL:  8
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 04_block_attach_device_repeatedly_pos 
	Unknown reason

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	Unknown reason

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	Unknown reason

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #11: x335sles9_pae4gb.report --]
[-- Type: text/plain, Size: 1777 bytes --]

Xm-test execution summary:
  PASS:  73
  FAIL:  20
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #12: x460.fc3-x86_64-8gb.report --]
[-- Type: text/plain, Size: 2146 bytes --]

Xm-test execution summary:
  PASS:  67
  FAIL:  26
  XPASS: 0
  XFAIL: 1


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

XFAIL: 13_create_multinic_pos 
	 (1 nics) Failed to create domain

 FAIL: 14_create_blockroot_pos 
	 Failed to create domain

 FAIL: 15_create_smallmem_pos 
	 Starting a console with 16 MB failed domain dies immediately!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 04_memset_smallmem_pos 
	 Timed out waiting for console

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_vcpu-disable_basic_pos 
	 failed to disable VCPU1

 FAIL: 01_save_basic_pos 
	 save command exited 256 != 0

 FAIL: 01_restore_basic_pos 
	 save command exited 256 != 0

 FAIL: 04_restore_withdevices_pos 
	 Failed to create domain

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #13: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 6%]

* [PATCH][2/17] REV 2 USB virt 2.6 split driver---xenidc buffer resource provider
@ 2005-11-23 16:12  5% harry
  0 siblings, 0 replies; 200+ results
From: harry @ 2005-11-23 16:12 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 186 bytes --]

This patch implements a resource pool for buffer resources used by the
xenidc transport which is in turn used by the USB driver.

Signed-off-by: Harry Butterworth <butterwo@uk.ibm.com>


[-- Attachment #2: p2-xenidc-buffer-resource-provider.patch --]
[-- Type: text/x-patch, Size: 19232 bytes --]

diff -r 14b148d759ae -r cf3c717101a8 linux-2.6-xen-sparse/drivers/xen/xenidc/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/xenidc/Makefile	Wed Nov 23 15:08:28 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenidc/Makefile	Wed Nov 23 15:13:22 2005
@@ -3,3 +3,4 @@
 xenidc-objs =
 xenidc-objs += xenidc_callback.o
 xenidc-objs += xenidc_work.o
+xenidc-objs += xenidc_buffer_resource_provider.o
diff -r 14b148d759ae -r cf3c717101a8 linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_buffer_resource_provider.c
--- /dev/null	Wed Nov 23 15:08:28 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenidc/xenidc_buffer_resource_provider.c	Wed Nov 23 15:13:22 2005
@@ -0,0 +1,346 @@
+/*****************************************************************************/
+/* Xen inter-domain communication buffer resource provider.                  */
+/*                                                                           */
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+/*****************************************************************************/
+/* Based on                                                                  */
+/*                                                                           */
+/* arch/xen/drivers/blkback/blkback.c                                        */
+/*                                                                           */
+/* original copyright notice follows...                                      */
+/*****************************************************************************/
+/******************************************************************************
+ * arch/xen/drivers/blkif/backend/main.c
+ * 
+ * Back-end of the driver for virtual block devices. This portion of the
+ * driver exports a 'unified' block-device interface that can be accessed
+ * by any operating system that implements a compatible front end. A 
+ * reference front-end implementation can be found in:
+ *  arch/xen/drivers/blkif/frontend
+ * 
+ * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
+ * Copyright (c) 2005, Christopher Clark
+ */
+
+#include <linux/spinlock.h>
+#include <linux/errno.h>
+#include <linux/gfp.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <asm/pgalloc.h>
+#include <asm-xen/balloon.h>
+#include <asm-xen/driver_util.h>
+#include <asm-xen/xenidc_buffer_resource_provider.h>
+#include "xenidc_trace.h"
+
+struct xenidc_buffer_resource_provider {
+	spinlock_t lock;
+	struct xenidc_buffer_resource_list resources;
+	struct xenidc_buffer_resource_list free_resources;
+	struct list_head page_list;
+	grant_ref_t grant_ref_pool;
+	struct page *page;
+	unsigned long mmap_vstart;
+	struct list_head empty_page_range_list;
+	struct list_head *empty_page_range_link;
+};
+
+static int
+alloc_or_free_pages(struct xenidc_buffer_resource_provider *provider, int free)
+{
+	int return_value = 0;
+	int i;
+	trace_info("%p", provider);
+	if (free)
+		goto exit_path;
+	INIT_LIST_HEAD(&provider->page_list);
+	for (i = 0; i < provider->resources.pages; i++) {
+		void *page = (void *)__get_free_page(GFP_KERNEL);
+		if (page == NULL) {
+			return_value = -ENOMEM;
+			goto exit_path;
+		}
+		xenidc_buffer_resource_provider_free_page(provider, page);
+	}
+	return 0;
+
+ exit_path:
+	while (!list_empty(&provider->page_list)) {
+		free_page(
+		  (unsigned long)xenidc_buffer_resource_provider_allocate_page(
+								provider));
+	}
+	return return_value;
+}
+
+static int
+alloc_or_free_grant_refs(struct xenidc_buffer_resource_provider *provider,
+int free)
+{
+	int return_value = 0;
+	if (provider->resources.grant_references == 0)
+		return 0;
+	if (free)
+		goto exit_path;
+	return_value = gnttab_alloc_grant_references(
+				provider->resources.grant_references,
+				&provider->grant_ref_pool);
+	if (return_value != 0) {
+		trace_info("failed to allocate grant reference pool");
+		goto exit_no_grant_references;
+	}
+	provider->free_resources.grant_references =
+					provider->resources.grant_references;
+	return 0;
+
+ exit_path:
+	gnttab_free_grant_references(provider->grant_ref_pool);
+
+ exit_no_grant_references:
+	return return_value;
+}
+
+static int
+alloc_or_free_page_ranges(struct xenidc_buffer_resource_provider *provider,
+int free)
+{
+	int return_value = 0;
+	int i;
+	if (provider->resources.empty_page_ranges == 0)
+		return 0;
+	if (free)
+		goto exit_path;
+	provider->page = balloon_alloc_empty_page_range(
+			provider->resources.empty_page_ranges *
+			provider->resources.empty_page_range_page_count);
+	if (provider->page == NULL) {
+		return_value = -ENOMEM;
+		goto exit_no_empty_page_range;
+	}
+	provider->mmap_vstart = (unsigned long)pfn_to_kaddr(
+						page_to_pfn(provider->page));
+	INIT_LIST_HEAD(&provider->empty_page_range_list);
+	provider->empty_page_range_link = kmalloc(
+				sizeof(struct list_head) *
+					provider->resources.empty_page_ranges,
+				GFP_KERNEL);
+	if (provider->empty_page_range_link == NULL) {
+		return_value = -ENOMEM;
+		goto exit_no_empty_page_range_link;
+	}
+	for (i = 0; i < provider->resources.empty_page_ranges; i++) {
+		struct list_head *link = &provider->empty_page_range_link[i];
+		INIT_LIST_HEAD(link);
+		list_add(link, &provider->empty_page_range_list);
+	}
+	provider->free_resources.empty_page_ranges =
+	    provider->resources.empty_page_ranges;
+	provider->free_resources.empty_page_range_page_count =
+	    provider->resources.empty_page_range_page_count;
+	return 0;
+ exit_path:
+	kfree(provider->empty_page_range_link);
+ exit_no_empty_page_range_link:
+	balloon_dealloc_empty_page_range(provider->page,
+			provider->resources.empty_page_ranges *
+			provider->resources.empty_page_range_page_count);
+ exit_no_empty_page_range:
+	return return_value;
+}
+
+static int
+xenidc_buffer_resource_provider_init_or_exit(
+struct xenidc_buffer_resource_provider *provider, int exit)
+{
+	int return_value = 0;
+	trace_info("%p", provider);
+	if (exit)
+		goto exit_path;
+	spin_lock_init(&provider->lock);
+	provider->free_resources = xenidc_buffer_resource_list_null();
+	if( ( return_value = alloc_or_free_pages(provider, 0) ) != 0 )
+		goto exit_no_pages;
+	if( ( return_value = alloc_or_free_grant_refs(provider, 0) ) != 0 )
+		goto exit_no_grant_refs;
+	if( ( return_value = alloc_or_free_page_ranges(provider, 0) ) != 0 )
+		goto exit_no_page_ranges;
+	return 0;
+ exit_path:
+	alloc_or_free_page_ranges(provider, 1);
+ exit_no_page_ranges:
+	alloc_or_free_grant_refs(provider, 1);
+ exit_no_grant_refs:
+	alloc_or_free_pages(provider, 1);
+ exit_no_pages:
+	return return_value;
+}
+
+struct xenidc_buffer_resource_provider *
+xenidc_allocate_buffer_resource_provider(
+struct xenidc_buffer_resource_list resources)
+{
+	struct xenidc_buffer_resource_provider *provider;
+	trace();
+	provider = kmalloc(sizeof(struct xenidc_buffer_resource_provider),
+								GFP_KERNEL);
+	if (provider != NULL) {
+		provider->resources = resources;
+		if (xenidc_buffer_resource_provider_init_or_exit(provider, 0)
+		    != 0) {
+			kfree(provider);
+			provider = NULL;
+		}
+	}
+	return provider;
+}
+
+void xenidc_free_buffer_resource_provider(
+struct xenidc_buffer_resource_provider *provider)
+{
+	trace();
+	(void)xenidc_buffer_resource_provider_init_or_exit(provider, 1);
+	vfree(provider);
+}
+
+struct xenidc_buffer_resource_list
+xenidc_buffer_resource_provider_query_free_resources(
+struct xenidc_buffer_resource_provider *provider)
+{
+	struct xenidc_buffer_resource_list list;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&provider->lock, flags);
+	list = provider->free_resources;
+	spin_unlock_irqrestore(&provider->lock, flags);
+	return list;
+}
+
+void *xenidc_buffer_resource_provider_allocate_page(
+struct xenidc_buffer_resource_provider *provider)
+{
+	struct list_head *link;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&provider->lock, flags);
+	provider->free_resources.pages--;
+	link = provider->page_list.next;
+	trace_info("%p", link);
+	list_del(link);
+	spin_unlock_irqrestore(&provider->lock, flags);
+	return link;
+}
+
+void xenidc_buffer_resource_provider_free_page(
+struct xenidc_buffer_resource_provider *provider, void *page)
+{
+	struct list_head *link = page;
+	unsigned long flags;
+	trace_info("%p", page);
+	INIT_LIST_HEAD(link);
+	spin_lock_irqsave(&provider->lock, flags);
+	provider->free_resources.pages++;
+	list_add(link, &provider->page_list);
+	spin_unlock_irqrestore(&provider->lock, flags);
+}
+
+grant_ref_t
+xenidc_buffer_resource_provider_allocate_grant_reference(
+struct xenidc_buffer_resource_provider *provider)
+{
+	grant_ref_t reference;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&provider->lock, flags);
+	provider->free_resources.grant_references--;
+	reference = gnttab_claim_grant_reference(&provider->grant_ref_pool);
+	spin_unlock_irqrestore(&provider->lock, flags);
+	return reference;
+}
+
+void xenidc_buffer_resource_provider_free_grant_reference(
+struct xenidc_buffer_resource_provider *provider, grant_ref_t reference)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&provider->lock, flags);
+	gnttab_release_grant_reference(&provider->grant_ref_pool, reference);
+	provider->free_resources.grant_references++;
+	spin_unlock_irqrestore(&provider->lock, flags);
+}
+
+unsigned long
+xenidc_buffer_resource_provider_allocate_empty_page_range(
+struct xenidc_buffer_resource_provider *provider, unsigned long page_count)
+{
+	unsigned long page_range;
+	unsigned long flags;
+	struct list_head *link;
+	trace();
+	spin_lock_irqsave(&provider->lock, flags);
+	link = provider->empty_page_range_list.next;
+	list_del_init(link);
+	provider->free_resources.empty_page_ranges--;
+	page_range = (provider->mmap_vstart
+		      +
+		      (PAGE_SIZE * provider->resources.
+						empty_page_range_page_count
+		       *
+		       (((unsigned long)link
+			 - (unsigned long)provider->empty_page_range_link)
+			/ sizeof(struct list_head)
+		       )
+		      )
+	    );
+	spin_unlock_irqrestore(&provider->lock, flags);
+	return page_range;
+}
+
+void xenidc_buffer_resource_provider_free_empty_page_range(
+struct xenidc_buffer_resource_provider *provider, unsigned long page_range)
+{
+	int i;
+	unsigned long flags;
+	trace();
+	i = ((page_range - provider->mmap_vstart)
+	     /
+	     (PAGE_SIZE
+	      * provider->resources.empty_page_range_page_count)
+	    );
+	spin_lock_irqsave(&provider->lock, flags);
+	list_add(&provider->empty_page_range_link[i],
+		 &provider->empty_page_range_list);
+	provider->free_resources.empty_page_ranges++;
+	spin_unlock_irqrestore(&provider->lock, flags);
+}
+
+void xenidc_buffer_resource_list_trace(struct xenidc_buffer_resource_list list)
+{
+	trace();
+
+	printk(KERN_INFO
+	       "xenidc %s: "
+	       "pages:%d; "
+	       "grant_references:%d; "
+	       "empty_page_ranges:%d; "
+	       "empty_page_range_page_count:%d\n",
+	       __PRETTY_FUNCTION__,
+	       list.pages,
+	       list.grant_references,
+	       list.empty_page_ranges, list.empty_page_range_page_count);
+}
diff -r 14b148d759ae -r cf3c717101a8 linux-2.6-xen-sparse/include/asm-xen/xenidc_buffer_resource_provider.h
--- /dev/null	Wed Nov 23 15:08:28 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/xenidc_buffer_resource_provider.h	Wed Nov 23 15:13:22 2005
@@ -0,0 +1,144 @@
+/*****************************************************************************/
+/* Xen inter-domain communication buffer resource provider.                  */
+/*                                                                           */
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+/*                                                                           */
+/* The main point of this buffer resource provider code is to make it        */
+/* possible to write some other generic code to manipulate various types of  */
+/* buffers and keep the other code independent of any buffer-type-specific   */
+/* resource management.                                                      */
+/*                                                                           */
+/* The initial implementation of this code provides sets of resources to     */
+/* clients in isolated per-client pools but this code provides a centralised */
+/* point of buffer resource management so it will be easy to implement a     */
+/* more efficient version which maintains isolation for a base set of        */
+/* resources to avoid deadlock and then shares additional resources between  */
+/* clients.                                                                  */
+
+#ifndef __ASM_XEN_XENIDC_BUFFER_RESOURCE_PROVIDER_H__
+#define __ASM_XEN_XENIDC_BUFFER_RESOURCE_PROVIDER_H__
+
+#include <asm/types.h>
+#include <asm-xen/gnttab.h>
+
+/* A xenidc_buffer_resource_list describes a set of resources, sometimes a   */
+/* set of resources required for an operation and sometimes a set of         */
+/* resources available to perform operations.                                */
+
+struct xenidc_buffer_resource_list {
+	u32 pages;
+	u32 grant_references;
+	u32 empty_page_ranges;
+	u32 empty_page_range_page_count;
+};
+
+/* xenidc_buffer_resource_list_null returns a list specifying no resources. */
+
+static inline struct xenidc_buffer_resource_list
+xenidc_buffer_resource_list_null(void)
+{
+	struct xenidc_buffer_resource_list list;
+	memset(&list, 0, sizeof(list));
+	return list;
+}
+
+/* xenidc_buffer_resource_list_subset_of returns true iff the resource       */
+/* requirements specified by list 'a' are met by the resources available in  */
+/* list 'b'.                                                                 */
+
+static inline int
+xenidc_buffer_resource_list_subset_of(struct xenidc_buffer_resource_list *a,
+struct xenidc_buffer_resource_list *b)
+{
+	return ((a->pages <= b->pages)
+		&& (a->grant_references <= b->grant_references)
+		&& (a->empty_page_ranges <= b->empty_page_ranges)
+		&&
+		(a->empty_page_range_page_count <=
+		 b->empty_page_range_page_count)
+	    );
+}
+
+/* xenidc_buffer_resource_list_plus_equals adds the resource requirements    */
+/* specified by list 'b' to the resource requirements specified by list 'a'  */
+/* such that the resulting list 'a' specifies a set of resources sufficient  */
+/* to meet the sum of the requirements of the original 'a' list and 'b'      */
+/* lists.                                                                    */
+static inline void
+xenidc_buffer_resource_list_plus_equals(struct xenidc_buffer_resource_list *a,
+struct xenidc_buffer_resource_list *b)
+{
+	a->pages += b->pages;
+	a->grant_references += b->grant_references;
+	a->empty_page_ranges += b->empty_page_ranges;
+	if (b->empty_page_range_page_count > a->empty_page_range_page_count)
+		a->empty_page_range_page_count =
+						b->empty_page_range_page_count;
+}
+
+/* Clients allocate a xenidc_buffer_resource_provider to provide themselves  */
+/* with a pool of resources.                                                 */
+
+extern struct xenidc_buffer_resource_provider *
+xenidc_allocate_buffer_resource_provider(
+struct xenidc_buffer_resource_list resource_allocation);
+
+extern void
+xenidc_free_buffer_resource_provider(
+struct xenidc_buffer_resource_provider *provider);
+
+/* Find out what resources are currently free for allocation. */
+
+extern struct xenidc_buffer_resource_list
+xenidc_buffer_resource_provider_query_free_resources(
+struct xenidc_buffer_resource_provider *provider);
+
+/* Resource-type specific allocate/free functions. */
+
+extern void *
+xenidc_buffer_resource_provider_allocate_page(
+struct xenidc_buffer_resource_provider *provider);
+
+extern void
+xenidc_buffer_resource_provider_free_page(
+struct xenidc_buffer_resource_provider *provider, void *page);
+
+extern grant_ref_t
+xenidc_buffer_resource_provider_allocate_grant_reference(
+struct xenidc_buffer_resource_provider *provider);
+
+extern void
+xenidc_buffer_resource_provider_free_grant_reference(
+struct xenidc_buffer_resource_provider *provider, grant_ref_t reference);
+
+extern unsigned long
+xenidc_buffer_resource_provider_allocate_empty_page_range(
+struct xenidc_buffer_resource_provider *provider, unsigned long page_count);
+
+extern void
+xenidc_buffer_resource_provider_free_empty_page_range(
+struct xenidc_buffer_resource_provider *provider, unsigned long page_range);
+
+/* xenidc_buffer_resource_list_trace is used for debugging and printks a     */
+/* dump of the resource list.                                                */
+
+extern void
+xenidc_buffer_resource_list_trace(struct xenidc_buffer_resource_list list);
+
+#endif

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 5%]

* Daily Xen Builds
@ 2005-11-23 17:05  3% David F Barrera
  0 siblings, 0 replies; 200+ results
From: David F Barrera @ 2005-11-23 17:05 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 2238 bytes --]

November 23, 2005 using test changeset:

changeset:   7975:b6ebabe4658a
tag:         tip
user:        kaf24@firebug.cl.cam.ac.uk
date:        Wed Nov 23 04:15:18 2005 +0100
summary:     Add -Wdeclaration-after-statement to CFLAGS only if the
 
x86_32 (no PAE support)

       * SLES 9 SP2 on IBM xSeries 235 and 305 (1GB RAM)
       * Builds and boots without problems
       * Able to create fully functional guest domains
       * Ran xm-test on all boxes
       * Successfully ran LTP and LMBench on Dom0s and DomUs

       ISSUES:
   
x86_32 (PAE)

       * SLES 9 SP2, FC3, FC4, and RHEL 4 IBM xSeries 305, 335s and IBM
       ThinkCentre
       * Builds and boots without problems
       * Able to create fully functional guest domains
       * Ran xm-test on all boxes
       * Successfully ran LTP and LMBench on Dom0s and guest domains

       ISSUES:
       * Bugzilla Bug 411  - xend died

x86_64 (SLES 9 SP2 and FC4 on IBM HS20 Blades)

       * Builds and boots without problems
       * Able to create fully functional guest domains
       * Ran xm-test on all boxes
       * Successfully ran LTP and LMBench on Dom0s and DomUs

       ISSUES:
     
------------------------------------------------------------------------

------------------------XM-TEST Results---------------------------------

SUMMARY:
                        Platform | PASS | FAIL | XPASS | XFAIL |
---------------------+------+------+-------+-------+
                         FC3pae |   85 |    8 |     1 |     0 |
hs20.1.rhel4-x86_32pae |   85 |    8 |     1 |     0 |
     hs20.1.sles9-x86_64 |   82 |   11 |     1 |     0 |
     hs20.2.sles9-x86_64 |   71 |   22 |     1 |     0 |
          hs20.fc4_x86_64 |   82 |   11 |     1 |     0 |
                   x305rh4pae |   84 |    8 |     1 |     0 |
           x305sles9nonpae |   84 |    8 |     1 |     0 |
                     335fc4pae |   85 |    8 |     1 |     0 |
         x335sles9_pae4gb |   85 |    8 |     1 |     0 |
    x460.fc3-x86_64-8gb |   83 |   10 |     1 |     0 |
       
-- 
Regards,

David F Barrera
Linux Technology Center
Systems and Technology Group, IBM

"The wisest men follow their own direction. "
                                                        Euripides


[-- Attachment #2: FC3pae.report --]
[-- Type: text/plain, Size: 860 bytes --]

Xm-test execution summary:
  PASS:  85
  FAIL:  8
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_migrate_localhost_pos 
	 Failed to read from console (fd=3)



[-- Attachment #3: hs20.1.rhel4-x86_32pae.report --]
[-- Type: text/plain, Size: 860 bytes --]

Xm-test execution summary:
  PASS:  85
  FAIL:  8
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_migrate_localhost_pos 
	 Failed to read from console (fd=3)



[-- Attachment #4: hs20.1.sles9-x86_64.report --]
[-- Type: text/plain, Size: 1048 bytes --]

Xm-test execution summary:
  PASS:  82
  FAIL:  11
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 15_create_smallmem_pos 
	 Starting a console with 16 MB failed domain dies immediately!

 FAIL: 04_memset_smallmem_pos 
	 Timed out waiting for console

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_save_basic_pos 
	 save command exited 256 != 0

 FAIL: 01_restore_basic_pos 
	 save command exited 256 != 0

 FAIL: 04_restore_withdevices_pos 
	 xm save exited with 256 != 0

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0



[-- Attachment #5: hs20.2.sles9-x86_64.report --]
[-- Type: text/plain, Size: 1950 bytes --]

Xm-test execution summary:
  PASS:  71
  FAIL:  22
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 04_memset_smallmem_pos 
	 Bug #380 I crashed the console system

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_save_basic_pos 
	 save command exited 256 != 0

 FAIL: 01_restore_basic_pos 
	 save command exited 256 != 0

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0



[-- Attachment #6: hs20.fc4_x86_64.report --]
[-- Type: text/plain, Size: 1056 bytes --]

Xm-test execution summary:
  PASS:  82
  FAIL:  11
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 15_create_smallmem_pos 
	 Starting a console with 16 MB failed domain dies immediately!

 FAIL: 04_memset_smallmem_pos 
	 Bug #380 I crashed the console system

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_save_basic_pos 
	 save command exited 256 != 0

 FAIL: 01_restore_basic_pos 
	 save command exited 256 != 0

 FAIL: 04_restore_withdevices_pos 
	 xm save exited with 256 != 0

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0



[-- Attachment #7: x305rh4pae.report --]
[-- Type: text/plain, Size: 860 bytes --]

Xm-test execution summary:
  PASS:  84
  FAIL:  8
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_migrate_localhost_pos 
	 Failed to read from console (fd=3)



[-- Attachment #8: x305sles9nonpae.report --]
[-- Type: text/plain, Size: 860 bytes --]

Xm-test execution summary:
  PASS:  84
  FAIL:  8
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_migrate_localhost_pos 
	 Failed to read from console (fd=3)



[-- Attachment #9: x335fc4pae.report --]
[-- Type: text/plain, Size: 860 bytes --]

Xm-test execution summary:
  PASS:  85
  FAIL:  8
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_migrate_localhost_pos 
	 Failed to read from console (fd=3)



[-- Attachment #10: x335sles9_pae4gb.report --]
[-- Type: text/plain, Size: 860 bytes --]

Xm-test execution summary:
  PASS:  85
  FAIL:  8
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Console didn't respond after 30 secs)

 FAIL: 04_restore_withdevices_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_migrate_localhost_pos 
	 Failed to read from console (fd=3)



[-- Attachment #11: x460.fc3-x86_64-8gb.report --]
[-- Type: text/plain, Size: 957 bytes --]

Xm-test execution summary:
  PASS:  83
  FAIL:  10
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 04_memset_smallmem_pos 
	 Bug #380 I crashed the console system

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_save_basic_pos 
	 save command exited 256 != 0

 FAIL: 01_restore_basic_pos 
	 save command exited 256 != 0

 FAIL: 04_restore_withdevices_pos 
	 xm save exited with 256 != 0

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0



[-- Attachment #12: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 3%]

* [patch] CFQ for xen domains
  2005-11-15 17:51  3%                   ` Gerd Knorr
@ 2005-11-24 11:31  3%                     ` Gerd Knorr
  2005-12-06 15:47  3%                       ` Gerd Knorr
  0 siblings, 1 reply; 200+ results
From: Gerd Knorr @ 2005-11-24 11:31 UTC (permalink / raw)
  To: Gerd Knorr; +Cc: Ian Pratt, xen-devel, Chris Mason, Kurt Garloff, Jens Axboe

[-- Attachment #1: Type: text/plain, Size: 1212 bytes --]

   Hi folks,

New version of the patch, adapted to apply cleanly against latest 
unstable, also debug output is runtime-switchable now, no major changes 
from last version.  I'm running my xen machine all day with that patch, 
without any issues showing up, including working save/restore.  Any 
chance to get it merged?

Full list changes:

   * One thread per blkif.  The I/O scheduler can do a better job that
     way, also you can use ionice on the blkback threads to adjust the
     block I/O priorities for the domain.
   * Various stuff has been moved from global variables into blkif_t.
   * The scary allocation ring for pending_req's is gone and has been
     replaced by a free list.
   * made dispatch_rw_block_io() reentrant.
   * general linux coding style cleanup, at least for the code I've
     touched anyway.
   * number of outstanding requests is runtime-configurable now.
   * made the ia64 #ifdefs smaller and dropped one.  It should still
     work on ia64 in theory, but would be great if the ia64 folks
     can have a look ...
   * re-added the xen_init() which got lost by mistake (pointed
     out by the ia64 guys).
   * runtime-switchable stats and debug output.

cheers,

   Gerd

[-- Attachment #2: blkback-7922-16.diff --]
[-- Type: text/x-patch, Size: 23686 bytes --]

diff -r 6a666940fa04 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Sun Nov 20 09:19:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Mon Nov 21 11:21:46 2005
@@ -12,6 +12,8 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/kthread.h>
+#include <linux/list.h>
 #include <asm-xen/balloon.h>
 #include <asm/hypervisor.h>
 #include "common.h"
@@ -21,26 +23,26 @@
  * pulled from a communication ring are quite likely to end up being part of
  * the same scatter/gather request at the disc.
  * 
- * ** TRY INCREASING 'MAX_PENDING_REQS' IF WRITE SPEEDS SEEM TOO LOW **
+ * ** TRY INCREASING 'blkif_reqs' IF WRITE SPEEDS SEEM TOO LOW **
+ * 
  * This will increase the chances of being able to write whole tracks.
  * 64 should be enough to keep us competitive with Linux.
  */
-#define MAX_PENDING_REQS 64
-#define BATCH_PER_DOMAIN 16
-
-static unsigned long mmap_vstart;
-#define MMAP_PAGES						\
-	(MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
-#ifdef __ia64__
-static void *pending_vaddrs[MMAP_PAGES];
-#define MMAP_VADDR(_idx, _i) \
-	(unsigned long)(pending_vaddrs[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#else
-#define MMAP_VADDR(_req,_seg)						\
-	(mmap_vstart +							\
-	 ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +	\
-	 ((_seg) * PAGE_SIZE))
-#endif
+static int blkif_reqs = 64;
+static int mmap_pages;
+
+static int __init set_blkif_reqs(char *str)
+{
+	get_option(&str, &blkif_reqs);
+	return 1;
+}
+__setup("blkif_reqs=", set_blkif_reqs);
+
+/* runtime-switchable, check /sys/module/blkback/parameters/ ;) */
+static unsigned int log_stats = 0;
+static unsigned int debug_lvl = 0;
+module_param(log_stats, int, 0644);
+module_param(debug_lvl, int, 0644);
 
 /*
  * Each outstanding request that we've passed to the lower device layers has a 
@@ -55,43 +57,38 @@
 	atomic_t       pendcnt;
 	unsigned short operation;
 	int            status;
+	struct list_head free_list;
 } pending_req_t;
 
-/*
- * We can't allocate pending_req's in order, since they may complete out of 
- * order. We therefore maintain an allocation ring. This ring also indicates 
- * when enough work has been passed down -- at that point the allocation ring 
- * will be empty.
- */
-static pending_req_t pending_reqs[MAX_PENDING_REQS];
-static unsigned char pending_ring[MAX_PENDING_REQS];
-static spinlock_t pend_prod_lock = SPIN_LOCK_UNLOCKED;
-/* NB. We use a different index type to differentiate from shared blk rings. */
-typedef unsigned int PEND_RING_IDX;
-#define MASK_PEND_IDX(_i) ((_i)&(MAX_PENDING_REQS-1))
-static PEND_RING_IDX pending_prod, pending_cons;
-#define NR_PENDING_REQS (MAX_PENDING_REQS - pending_prod + pending_cons)
-
-static request_queue_t *plugged_queue;
-static inline void flush_plugged_queue(void)
-{
-	request_queue_t *q = plugged_queue;
-	if (q != NULL) {
-		if ( q->unplug_fn != NULL )
-			q->unplug_fn(q);
-		blk_put_queue(q);
-		plugged_queue = NULL;
-	}
-}
+static pending_req_t *pending_reqs;
+static struct list_head pending_free;
+static spinlock_t pending_free_lock = SPIN_LOCK_UNLOCKED;
+static DECLARE_WAIT_QUEUE_HEAD(pending_free_wq);
+
+#define BLKBACK_INVALID_HANDLE (0xFFFF)
+
+static unsigned long mmap_vstart;
+static unsigned long *pending_vaddrs;
+static u16 *pending_grant_handles;
+
+static inline int vaddr_pagenr(pending_req_t *req, int seg)
+{
+	return (req - pending_reqs) * BLKIF_MAX_SEGMENTS_PER_REQUEST + seg;
+}
+
+static inline unsigned long vaddr(pending_req_t *req, int seg)
+{
+	return pending_vaddrs[vaddr_pagenr(req, seg)];
+}
+
+#define pending_handle(_req, _seg) \
+	(pending_grant_handles[vaddr_pagenr(_req, _seg)])
+
 
 /* When using grant tables to map a frame for device access then the
  * handle returned must be used to unmap the frame. This is needed to
  * drop the ref count on the frame.
  */
-static u16 pending_grant_handles[MMAP_PAGES];
-#define pending_handle(_idx, _i) \
-    (pending_grant_handles[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#define BLKBACK_INVALID_HANDLE (0xFFFF)
 
 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
 /*
@@ -105,26 +102,79 @@
 static inline domid_t ID_TO_DOM(unsigned long id) { return (id >> 16); }
 #endif
 
-static int do_block_io_op(blkif_t *blkif, int max_to_do);
-static void dispatch_rw_block_io(blkif_t *blkif, blkif_request_t *req);
+static int do_block_io_op(blkif_t *blkif);
+static void dispatch_rw_block_io(blkif_t *blkif,
+				 blkif_request_t *req,
+				 pending_req_t *pending_req);
 static void make_response(blkif_t *blkif, unsigned long id, 
                           unsigned short op, int st);
 
-static void fast_flush_area(int idx, int nr_pages)
+/******************************************************************
+ * misc small helpers
+ */
+static pending_req_t* alloc_req(void)
+{
+	pending_req_t *req = NULL;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+	if (!list_empty(&pending_free)) {
+		req = list_entry(pending_free.next, pending_req_t, free_list);
+		list_del(&req->free_list);
+	}
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+	return req;
+}
+
+static void free_req(pending_req_t *req)
+{
+	unsigned long flags;
+	int was_empty;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+	was_empty = list_empty(&pending_free);
+	list_add(&req->free_list, &pending_free);
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+	if (was_empty)
+		wake_up(&pending_free_wq);
+}
+
+static void unplug_queue(blkif_t *blkif)
+{
+	if (NULL == blkif->plug)
+		return;
+	if (blkif->plug->unplug_fn)
+		blkif->plug->unplug_fn(blkif->plug);
+	blk_put_queue(blkif->plug);
+	blkif->plug = NULL;
+}
+
+static void plug_queue(blkif_t *blkif, struct bio *bio)
+{
+	request_queue_t *q = bdev_get_queue(bio->bi_bdev);
+
+	if (q == blkif->plug)
+		return;
+	unplug_queue(blkif);
+	blk_get_queue(q);
+	blkif->plug = q;
+}
+
+static void fast_flush_area(pending_req_t *req)
 {
 	struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	unsigned int i, invcount = 0;
 	u16 handle;
 	int ret;
 
-	for (i = 0; i < nr_pages; i++) {
-		handle = pending_handle(idx, i);
+	for (i = 0; i < req->nr_pages; i++) {
+		handle = pending_handle(req, i);
 		if (handle == BLKBACK_INVALID_HANDLE)
 			continue;
-		unmap[invcount].host_addr    = MMAP_VADDR(idx, i);
+		unmap[invcount].host_addr    = vaddr(req, i);
 		unmap[invcount].dev_bus_addr = 0;
 		unmap[invcount].handle       = handle;
-		pending_handle(idx, i) = BLKBACK_INVALID_HANDLE;
+		pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
 		invcount++;
 	}
 
@@ -133,109 +183,79 @@
 	BUG_ON(ret);
 }
 
-
-/******************************************************************
- * BLOCK-DEVICE SCHEDULER LIST MAINTENANCE
- */
-
-static struct list_head blkio_schedule_list;
-static spinlock_t blkio_schedule_list_lock;
-
-static int __on_blkdev_list(blkif_t *blkif)
-{
-	return blkif->blkdev_list.next != NULL;
-}
-
-static void remove_from_blkdev_list(blkif_t *blkif)
-{
-	unsigned long flags;
-
-	if (!__on_blkdev_list(blkif))
-		return;
-
-	spin_lock_irqsave(&blkio_schedule_list_lock, flags);
-	if (__on_blkdev_list(blkif)) {
-		list_del(&blkif->blkdev_list);
-		blkif->blkdev_list.next = NULL;
-		blkif_put(blkif);
-	}
-	spin_unlock_irqrestore(&blkio_schedule_list_lock, flags);
-}
-
-static void add_to_blkdev_list_tail(blkif_t *blkif)
-{
-	unsigned long flags;
-
-	if (__on_blkdev_list(blkif))
-		return;
-
-	spin_lock_irqsave(&blkio_schedule_list_lock, flags);
-	if (!__on_blkdev_list(blkif) && (blkif->status == CONNECTED)) {
-		list_add_tail(&blkif->blkdev_list, &blkio_schedule_list);
-		blkif_get(blkif);
-	}
-	spin_unlock_irqrestore(&blkio_schedule_list_lock, flags);
-}
-
-
 /******************************************************************
  * SCHEDULER FUNCTIONS
  */
 
-static DECLARE_WAIT_QUEUE_HEAD(blkio_schedule_wait);
-
-static int blkio_schedule(void *arg)
-{
-	DECLARE_WAITQUEUE(wq, current);
-
-	blkif_t          *blkif;
-	struct list_head *ent;
-
-	daemonize("xenblkd");
-
+static void print_stats(blkif_t *blkif)
+{
+	printk(KERN_DEBUG "%s: oo %3d  |  rd %4d  |  wr %4d\n",
+	       current->comm, blkif->st_oo_req,
+	       blkif->st_rd_req, blkif->st_wr_req);
+	blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000);
+	blkif->st_rd_req = 0;
+	blkif->st_wr_req = 0;
+	blkif->st_oo_req = 0;
+}
+
+int blkif_schedule(void *arg)
+{
+	blkif_t          *blkif = arg;
+
+	blkif_get(blkif);
+	if (debug_lvl)
+		printk(KERN_DEBUG "%s: started\n", current->comm);
 	for (;;) {
-		/* Wait for work to do. */
-		add_wait_queue(&blkio_schedule_wait, &wq);
-		set_current_state(TASK_INTERRUPTIBLE);
-		if ( (NR_PENDING_REQS == MAX_PENDING_REQS) || 
-		     list_empty(&blkio_schedule_list) )
-			schedule();
-		__set_current_state(TASK_RUNNING);
-		remove_wait_queue(&blkio_schedule_wait, &wq);
-
-		/* Queue up a batch of requests. */
-		while ((NR_PENDING_REQS < MAX_PENDING_REQS) &&
-		       !list_empty(&blkio_schedule_list)) {
-			ent = blkio_schedule_list.next;
-			blkif = list_entry(ent, blkif_t, blkdev_list);
-			blkif_get(blkif);
-			remove_from_blkdev_list(blkif);
-			if (do_block_io_op(blkif, BATCH_PER_DOMAIN))
-				add_to_blkdev_list_tail(blkif);
-			blkif_put(blkif);
-		}
-
-		/* Push the batch through to disc. */
-		flush_plugged_queue();
-	}
-}
-
-static void maybe_trigger_blkio_schedule(void)
-{
-	/*
-	 * Needed so that two processes, which together make the following
-	 * predicate true, don't both read stale values and evaluate the
-	 * predicate incorrectly. Incredibly unlikely to stall the scheduler
-	 * on x86, but...
-	 */
-	smp_mb();
-
-	if ((NR_PENDING_REQS < (MAX_PENDING_REQS/2)) &&
-	    !list_empty(&blkio_schedule_list))
-		wake_up(&blkio_schedule_wait);
-}
-
-
+		if (kthread_should_stop()) {
+			/* asked to quit? */
+			if (!atomic_read(&blkif->io_pending))
+				break;
+			if (debug_lvl)
+				printk(KERN_DEBUG "%s: I/O pending, delaying exit\n",
+				       current->comm);
+		}
+
+		if (!atomic_read(&blkif->io_pending)) {
+			/* Wait for work to do. */
+			wait_event_interruptible(blkif->wq,
+						 atomic_read(&blkif->io_pending) ||
+						 kthread_should_stop());
+		} else if (list_empty(&pending_free)) {
+			/* Wait for pending_req becoming available. */
+			wait_event_interruptible(pending_free_wq,
+						 !list_empty(&pending_free));
+		}
+
+		if (blkif->status != CONNECTED) {
+			/* make sure we are connected */
+			if (debug_lvl)
+				printk(KERN_DEBUG "%s: not connected (%d pending)\n",
+				       current->comm, atomic_read(&blkif->io_pending));
+			wait_event_interruptible(blkif->wq,
+						 blkif->status != CONNECTED ||
+						 kthread_should_stop());
+			continue;
+		}
+
+		/* Schedule I/O */
+		atomic_set(&blkif->io_pending, 0);
+		if (do_block_io_op(blkif))
+			atomic_inc(&blkif->io_pending);
+		unplug_queue(blkif);
+
+		if (log_stats && time_after(jiffies, blkif->st_print))
+			print_stats(blkif);
+	}
+
+	/* bye folks, and thanks for all the fish ;) */
+	if (log_stats)
+		print_stats(blkif);
+	if (debug_lvl)
+		printk(KERN_DEBUG "%s: exiting\n", current->comm);
+	blkif->xenblkd = NULL;
+	blkif_put(blkif);
+	return 0;
+}
 
 /******************************************************************
  * COMPLETION CALLBACK -- Called as bh->b_end_io()
@@ -243,8 +263,6 @@
 
 static void __end_block_io_op(pending_req_t *pending_req, int uptodate)
 {
-	unsigned long flags;
-
 	/* An error fails the entire request. */
 	if (!uptodate) {
 		DPRINTK("Buffer not up-to-date at end of operation\n");
@@ -252,15 +270,11 @@
 	}
 
 	if (atomic_dec_and_test(&pending_req->pendcnt)) {
-		int pending_idx = pending_req - pending_reqs;
-		fast_flush_area(pending_idx, pending_req->nr_pages);
+		fast_flush_area(pending_req);
 		make_response(pending_req->blkif, pending_req->id,
 			      pending_req->operation, pending_req->status);
 		blkif_put(pending_req->blkif);
-		spin_lock_irqsave(&pend_prod_lock, flags);
-		pending_ring[MASK_PEND_IDX(pending_prod++)] = pending_idx;
-		spin_unlock_irqrestore(&pend_prod_lock, flags);
-		maybe_trigger_blkio_schedule();
+		free_req(pending_req);
 	}
 }
 
@@ -281,8 +295,9 @@
 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
 {
 	blkif_t *blkif = dev_id;
-	add_to_blkdev_list_tail(blkif);
-	maybe_trigger_blkio_schedule();
+
+	atomic_inc(&blkif->io_pending);
+	wake_up(&blkif->wq);
 	return IRQ_HANDLED;
 }
 
@@ -292,10 +307,11 @@
  * DOWNWARD CALLS -- These interface with the block-device layer proper.
  */
 
-static int do_block_io_op(blkif_t *blkif, int max_to_do)
+static int do_block_io_op(blkif_t *blkif)
 {
 	blkif_back_ring_t *blk_ring = &blkif->blk_ring;
 	blkif_request_t *req;
+	pending_req_t *pending_req;
 	RING_IDX i, rp;
 	int more_to_do = 0;
 
@@ -305,24 +321,30 @@
 	for (i = blk_ring->req_cons; 
 	     (i != rp) && !RING_REQUEST_CONS_OVERFLOW(blk_ring, i);
 	     i++) {
-		if ((max_to_do-- == 0) ||
-		    (NR_PENDING_REQS == MAX_PENDING_REQS)) {
+
+		pending_req = alloc_req();
+		if (NULL == pending_req) {
+			blkif->st_oo_req++;
 			more_to_do = 1;
 			break;
 		}
-        
+
 		req = RING_GET_REQUEST(blk_ring, i);
 		switch (req->operation) {
 		case BLKIF_OP_READ:
+			blkif->st_rd_req++;
+			dispatch_rw_block_io(blkif, req, pending_req);
+			break;
 		case BLKIF_OP_WRITE:
-			dispatch_rw_block_io(blkif, req);
+			blkif->st_wr_req++;
+			dispatch_rw_block_io(blkif, req, pending_req);
 			break;
-
 		default:
 			DPRINTK("error: unknown block io operation [%d]\n",
 				req->operation);
 			make_response(blkif, req->id, req->operation,
 				      BLKIF_RSP_ERROR);
+			free_req(pending_req);
 			break;
 		}
 	}
@@ -331,13 +353,13 @@
 	return more_to_do;
 }
 
-static void dispatch_rw_block_io(blkif_t *blkif, blkif_request_t *req)
+static void dispatch_rw_block_io(blkif_t *blkif,
+				 blkif_request_t *req,
+				 pending_req_t *pending_req)
 {
 	extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]); 
 	int operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
 	unsigned long fas = 0;
-	int i, pending_idx = pending_ring[MASK_PEND_IDX(pending_cons)];
-	pending_req_t *pending_req;
 	struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	struct phys_req preq;
 	struct { 
@@ -345,31 +367,35 @@
 	} seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	unsigned int nseg;
 	struct bio *bio = NULL, *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
-	int nbio = 0;
-	request_queue_t *q;
-	int ret, errors = 0;
+	int ret, i, nbio = 0;
 
 	/* Check that number of segments is sane. */
 	nseg = req->nr_segments;
 	if (unlikely(nseg == 0) || 
 	    unlikely(nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) {
 		DPRINTK("Bad number of segments in request (%d)\n", nseg);
-		goto bad_descriptor;
+		goto fail_response;
 	}
 
 	preq.dev           = req->handle;
 	preq.sector_number = req->sector_number;
 	preq.nr_sects      = 0;
 
+	pending_req->blkif     = blkif;
+	pending_req->id        = req->id;
+	pending_req->operation = operation;
+	pending_req->status    = BLKIF_RSP_OKAY;
+	pending_req->nr_pages  = nseg;
+
 	for (i = 0; i < nseg; i++) {
 		fas         = req->frame_and_sects[i];
 		seg[i].nsec = blkif_last_sect(fas) - blkif_first_sect(fas) + 1;
 
 		if (seg[i].nsec <= 0)
-			goto bad_descriptor;
+			goto fail_response;
 		preq.nr_sects += seg[i].nsec;
 
-		map[i].host_addr = MMAP_VADDR(pending_idx, i);
+		map[i].host_addr = vaddr(pending_req, i);
 		map[i].dom = blkif->domid;
 		map[i].ref = blkif_gref_from_fas(fas);
 		map[i].flags = GNTMAP_host_map;
@@ -381,27 +407,23 @@
 	BUG_ON(ret);
 
 	for (i = 0; i < nseg; i++) {
-		if (likely(map[i].handle >= 0)) {
-			pending_handle(pending_idx, i) = map[i].handle;
+		if (unlikely(map[i].handle < 0)) {
+			DPRINTK("invalid buffer -- could not remap it\n");
+			goto fail_flush;
+		}
+
+		pending_handle(pending_req, i) = map[i].handle;
 #ifdef __ia64__
-			MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
+		pending_vaddrs[vaddr_pagenr(req, seg)] =
+			= gnttab_map_vaddr(map[i]);
 #else
-			set_phys_to_machine(__pa(MMAP_VADDR(
-				pending_idx, i)) >> PAGE_SHIFT,
-				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT));
+		set_phys_to_machine(__pa(vaddr(
+			pending_req, i)) >> PAGE_SHIFT,
+			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
 #endif
-			fas        = req->frame_and_sects[i];
-			seg[i].buf = map[i].dev_bus_addr | 
-				(blkif_first_sect(fas) << 9);
-		} else {
-			errors++;
-		}
-	}
-
-	if (errors) {
-		DPRINTK("invalid buffer -- could not remap it\n");
-		fast_flush_area(pending_idx, nseg);
-		goto bad_descriptor;
+		fas         = req->frame_and_sects[i];
+		seg[i].buf  = map[i].dev_bus_addr | 
+			(blkif_first_sect(fas) << 9);
 	}
 
 	if (vbd_translate(&preq, blkif, operation) != 0) {
@@ -409,37 +431,25 @@
 			operation == READ ? "read" : "write",
 			preq.sector_number,
 			preq.sector_number + preq.nr_sects, preq.dev); 
-		goto bad_descriptor;
-	}
-
-	pending_req = &pending_reqs[pending_idx];
-	pending_req->blkif     = blkif;
-	pending_req->id        = req->id;
-	pending_req->operation = operation;
-	pending_req->status    = BLKIF_RSP_OKAY;
-	pending_req->nr_pages  = nseg;
+		goto fail_flush;
+	}
 
 	for (i = 0; i < nseg; i++) {
 		if (((int)preq.sector_number|(int)seg[i].nsec) &
 		    ((bdev_hardsect_size(preq.bdev) >> 9) - 1)) {
 			DPRINTK("Misaligned I/O request from domain %d",
 				blkif->domid);
-			goto cleanup_and_fail;
+			goto fail_put_bio;
 		}
 
 		while ((bio == NULL) ||
 		       (bio_add_page(bio,
-				     virt_to_page(MMAP_VADDR(pending_idx, i)),
+				     virt_to_page(vaddr(pending_req, i)),
 				     seg[i].nsec << 9,
 				     seg[i].buf & ~PAGE_MASK) == 0)) {
 			bio = biolist[nbio++] = bio_alloc(GFP_KERNEL, nseg-i);
-			if (unlikely(bio == NULL)) {
-			cleanup_and_fail:
-				for (i = 0; i < (nbio-1); i++)
-					bio_put(biolist[i]);
-				fast_flush_area(pending_idx, nseg);
-				goto bad_descriptor;
-			}
+			if (unlikely(bio == NULL))
+				goto fail_put_bio;
                 
 			bio->bi_bdev    = preq.bdev;
 			bio->bi_private = pending_req;
@@ -450,14 +460,8 @@
 		preq.sector_number += seg[i].nsec;
 	}
 
-	if ((q = bdev_get_queue(bio->bi_bdev)) != plugged_queue) {
-		flush_plugged_queue();
-		blk_get_queue(q);
-		plugged_queue = q;
-	}
-
+	plug_queue(blkif, bio);
 	atomic_set(&pending_req->pendcnt, nbio);
-	pending_cons++;
 	blkif_get(blkif);
 
 	for (i = 0; i < nbio; i++)
@@ -465,8 +469,14 @@
 
 	return;
 
- bad_descriptor:
+ fail_put_bio:
+	for (i = 0; i < (nbio-1); i++)
+		bio_put(biolist[i]);
+ fail_flush:
+	fast_flush_area(pending_req);
+ fail_response:
 	make_response(blkif, req->id, req->operation, BLKIF_RSP_ERROR);
+	free_req(pending_req);
 } 
 
 
@@ -498,56 +508,50 @@
 	notify_remote_via_irq(blkif->irq);
 }
 
-void blkif_deschedule(blkif_t *blkif)
-{
-	remove_from_blkdev_list(blkif);
-}
-
 static int __init blkif_init(void)
 {
+	struct page *page;
 	int i;
-	struct page *page;
-	int ret;
-
-	for (i = 0; i < MMAP_PAGES; i++)
-		pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
 
 	if (xen_init() < 0)
 		return -ENODEV;
 
+	mmap_pages            = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
+	pending_reqs          = kmalloc(sizeof(pending_reqs[0]) *
+					blkif_reqs, GFP_KERNEL);
+	pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
+					mmap_pages, GFP_KERNEL);
+	pending_vaddrs        = kmalloc(sizeof(pending_vaddrs[0]) *
+					mmap_pages, GFP_KERNEL);
+	if (!pending_reqs || !pending_grant_handles || !pending_vaddrs) {
+		printk("%s: out of memory\n", __FUNCTION__);
+		return -1;
+	}
+
 	blkif_interface_init();
-
+	
 #ifdef __ia64__
-    {
 	extern unsigned long alloc_empty_foreign_map_page_range(unsigned long pages);
-	int i;
-
-	mmap_vstart =  alloc_empty_foreign_map_page_range(MMAP_PAGES);
-	printk("Allocated mmap_vstart: 0x%lx\n", mmap_vstart);
-	for(i = 0; i < MMAP_PAGES; i++)
-	    pending_vaddrs[i] = mmap_vstart + (i << PAGE_SHIFT);
-	BUG_ON(mmap_vstart == NULL);
-    }
-#else
-	page = balloon_alloc_empty_page_range(MMAP_PAGES);
+	mmap_vstart = (unsigned long)alloc_empty_foreign_map_page_range(mmap_pages);
+#else /* ! ia64 */
+	page = balloon_alloc_empty_page_range(mmap_pages);
 	BUG_ON(page == NULL);
 	mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
 #endif
-
-	pending_cons = 0;
-	pending_prod = MAX_PENDING_REQS;
+	printk("%s: reqs=%d, pages=%d, mmap_vstart=0x%lx\n",
+	       __FUNCTION__, blkif_reqs, mmap_pages, mmap_vstart);
+	BUG_ON(mmap_vstart == 0);
+	for (i = 0; i < mmap_pages; i++)
+		pending_vaddrs[i] = mmap_vstart + (i << PAGE_SHIFT);
+
+	memset(pending_grant_handles,  BLKBACK_INVALID_HANDLE, mmap_pages);
 	memset(pending_reqs, 0, sizeof(pending_reqs));
-	for (i = 0; i < MAX_PENDING_REQS; i++)
-		pending_ring[i] = i;
+	INIT_LIST_HEAD(&pending_free);
+
+	for (i = 0; i < blkif_reqs; i++)
+		list_add_tail(&pending_reqs[i].free_list, &pending_free);
     
-	spin_lock_init(&blkio_schedule_list_lock);
-	INIT_LIST_HEAD(&blkio_schedule_list);
-
-	ret = kernel_thread(blkio_schedule, NULL, CLONE_FS | CLONE_FILES);
-	BUG_ON(ret < 0);
-
 	blkif_xenbus_init();
-
 	return 0;
 }
 
diff -r 6a666940fa04 linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Sun Nov 20 09:19:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Mon Nov 21 11:21:46 2005
@@ -56,9 +56,19 @@
 	/* Is this a blktap frontend */
 	unsigned int     is_blktap;
 #endif
-	struct list_head blkdev_list;
 	spinlock_t       blk_ring_lock;
 	atomic_t         refcnt;
+
+	wait_queue_head_t   wq;
+	struct task_struct  *xenblkd;
+	atomic_t            io_pending;
+	request_queue_t     *plug;
+
+	/* statistics */
+	unsigned long       st_print;
+	int                 st_rd_req;
+	int                 st_wr_req;
+	int                 st_oo_req;
 
 	struct work_struct free_work;
 
@@ -97,11 +107,10 @@
 
 void blkif_interface_init(void);
 
-void blkif_deschedule(blkif_t *blkif);
-
 void blkif_xenbus_init(void);
 
 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
+int blkif_schedule(void *arg);
 
 #endif /* __BLKIF__BACKEND__COMMON_H__ */
 
diff -r 6a666940fa04 linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Sun Nov 20 09:19:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Mon Nov 21 11:21:46 2005
@@ -24,6 +24,8 @@
 	blkif->status = DISCONNECTED;
 	spin_lock_init(&blkif->blk_ring_lock);
 	atomic_set(&blkif->refcnt, 1);
+	init_waitqueue_head(&blkif->wq);
+	blkif->st_print = jiffies;
 
 	return blkif;
 }
@@ -113,6 +115,7 @@
 	blkif->irq = bind_evtchn_to_irqhandler(
 		blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
 	blkif->status = CONNECTED;
+	wake_up(&blkif->wq);
 
 	return 0;
 }
diff -r 6a666940fa04 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Sun Nov 20 09:19:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Mon Nov 21 11:21:46 2005
@@ -20,6 +20,7 @@
 
 #include <stdarg.h>
 #include <linux/module.h>
+#include <linux/kthread.h>
 #include <asm-xen/xenbus.h>
 #include "common.h"
 
@@ -61,6 +62,8 @@
 		be->backend_watch.node = NULL;
 	}
 	if (be->blkif) {
+		if (be->blkif->xenblkd)
+			kthread_stop(be->blkif->xenblkd);
 		blkif_put(be->blkif);
 		be->blkif = NULL;
 	}
@@ -175,6 +178,16 @@
 			be->pdev = 0L;
 			xenbus_dev_fatal(dev, err,
 					 "creating vbd structure");
+			return;
+		}
+
+		be->blkif->xenblkd = kthread_run(blkif_schedule, be->blkif,
+						 "xenblkd %d/%04lx",
+						 be->blkif->domid, be->pdev);
+		if (IS_ERR(be->blkif->xenblkd)) {
+			err = PTR_ERR(be->blkif->xenblkd);
+			be->blkif->xenblkd = NULL;
+			xenbus_dev_error(dev, err, "start xenblkd");
 			return;
 		}
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 3%]

* Daily Xen Builds
@ 2005-11-28 20:10  4% David F Barrera
  0 siblings, 0 replies; 200+ results
From: David F Barrera @ 2005-11-28 20:10 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 2144 bytes --]

November 28, 2005 using test changeset:

changeset:   8072:eb1169f92d81
tag:         tip
user:        emellor@leeni.uk.xensource.com
date:        Sun Nov 27 07:09:46 2005 +0000
summary:     Set a console limit, in order to detect runaways.
 
x86_32 (no PAE support)

       * SLES 9 SP2 on IBM xSeries 235 and 305 (1GB RAM)
       * Builds and boots without problems
       * Able to create fully functional guest domains
       * Ran xm-test on all boxes
       * Successfully ran LTP and LMBench on Dom0s and DomUs

       ISSUES:
   
x86_32 (PAE)

       * SLES 9 SP2, FC3, FC4, and RHEL 4 IBM xSeries 305, 335s and IBM
       ThinkCentre
       * Builds and boots without problems
       * Able to create fully functional guest domains
       * Ran xm-test on all boxes
       * Successfully ran LTP and LMBench on Dom0s and guest domains

       ISSUES:
       * Bugzilla Bug 411  - xend died (Testing with Python 2.4.2 now)

x86_64 (SLES 9 SP2 and FC4 on IBM HS20 Blades)

       * Builds and boots without problems
       * Able to create fully functional guest domains
       * Ran xm-test on all boxes
       * Successfully ran LTP and LMBench on Dom0s and DomUs

       ISSUES:
     
------------------------------------------------------------------------

------------------------XM-TEST Results---------------------------------

SUMMARY:
            Platform | PASS | FAIL | XPASS | XFAIL |
---------------------+------+------+-------+-------+
              FC3pae |   99 |    1 |     0 |     1 |
 hs20.1.sles9-x86_64 |   93 |    7 |     0 |     1 |
 hs20.2.sles9-x86_64 |   71 |   22 |     1 |     0 |
     hs20.fc4_x86_64 |   83 |   17 |     0 |     1 |
     x235sles9nonpae |   99 |    1 |     0 |     1 |
          x305rh4pae |   98 |    1 |     0 |     1 |
     x305sles9nonpae |   98 |    1 |     0 |     1 |
          x335fc4pae |   99 |    1 |     0 |     1 |
 x460.fc3-x86_64-8gb |   83 |   17 |     0 |     1 |

       
-- 
Regards,

David F Barrera
Linux Technology Center
Systems and Technology Group, IBM

"The wisest men follow their own direction. "
                                                        Euripides

[-- Attachment #2: FC3pae.report --]
[-- Type: text/plain, Size: 182 bytes --]

Xm-test execution summary:
  PASS:  99
  FAIL:  1
  XPASS: 0
  XFAIL: 1


Details:

XFAIL: 03_network_attach_detach_multiple_pos 
	 Network device is not actually connected to domU


[-- Attachment #3: hs20.1.sles9-x86_64.report --]
[-- Type: text/plain, Size: 650 bytes --]

Xm-test execution summary:
  PASS:  93
  FAIL:  7
  XPASS: 0
  XFAIL: 1


Details:

 FAIL: 05_create_noroot_noram_neg 
	 xm create test05 passed with no root and no ramdisk. Expected result Fail.

 FAIL: 15_create_smallmem_pos 
	 Starting a console with 16 MB failed domain dies immediately!

 FAIL: 04_memset_smallmem_pos 
	 Timed out waiting for console

XFAIL: 03_network_attach_detach_multiple_pos 
	 Network device is not actually connected to domU

 FAIL: 01_vcpu-disable_basic_pos 
	 failed to disable VCPU1

 FAIL: 04_restore_withdevices_pos 
	 Timed out waiting for console

 FAIL: 01_migrate_localhost_pos 
	 Timed out waiting for console


[-- Attachment #4: hs20.2.sles9-x86_64.report --]
[-- Type: text/plain, Size: 1873 bytes --]

Xm-test execution summary:
  PASS:  71
  FAIL:  22
  XPASS: 1
  XFAIL: 0


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 Device is not actually attached to domU

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 01_block-list_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 06_block-list_checkremove_pos 
	 hda1 still shown in block-list after detach!

 FAIL: 01_block-destroy_btblock_pos 
	 block device isn't attached; can't detach!

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

 FAIL: 04_memset_smallmem_pos 
	 Bug #380 I crashed the console system

 FAIL: 01_reboot_basic_pos 
	 Failed to read from console (fd=6)

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 01_unpause_basic_pos 
	 Console didn't respond after 30 secs

 FAIL: 01_save_basic_pos 
	 save command exited 256 != 0

 FAIL: 01_restore_basic_pos 
	 save command exited 256 != 0

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #5: hs20.fc4_x86_64.report --]
[-- Type: text/plain, Size: 1290 bytes --]

Xm-test execution summary:
  PASS:  83
  FAIL:  17
  XPASS: 0
  XFAIL: 1


Details:

 FAIL: 05_create_noroot_noram_neg 
	 xm create test05 passed with no root and no ramdisk. Expected result Fail.

 FAIL: 15_create_smallmem_pos 
	 Starting a console with 16 MB failed domain dies immediately!

 FAIL: 04_memset_smallmem_pos 
	 Bug #145 Ballooning DomU too low caused run-away

 FAIL: 01_network_attach_pos 
	 [Errno 5] Input/output error

 FAIL: 02_network_attach_detach_pos 
	 [Errno 5] Input/output error

XFAIL: 03_network_attach_detach_multiple_pos 
	 [Errno 5] Input/output error

 FAIL: 01_pause_basic_pos 
	 [Errno 5] Input/output error

 FAIL: 01_reboot_basic_pos 
	 [Errno 5] Input/output error

 FAIL: 01_shutdown_basic_pos 
	 [Errno 5] Input/output error

 FAIL: 02_sysrq_sync_pos 
	 [Errno 5] Input/output error

 FAIL: 03_sysrq_withreboot_pos 
	 [Errno 5] Input/output error

 FAIL: 01_unpause_basic_pos 
	 [Errno 5] Input/output error

 FAIL: 01_vcpu-disable_basic_pos 
	 failed to disable VCPU1

 FAIL: 01_save_basic_pos 
	 Command execution time exceeded 30 seconds

 FAIL: 01_restore_basic_pos 
	 Command execution time exceeded 30 seconds

 FAIL: 04_restore_withdevices_pos 
	 [Errno 5] Input/output error

 FAIL: 01_migrate_localhost_pos 
	 [Errno 5] Input/output error


[-- Attachment #6: x235sles9nonpae.report --]
[-- Type: text/plain, Size: 182 bytes --]

Xm-test execution summary:
  PASS:  99
  FAIL:  1
  XPASS: 0
  XFAIL: 1


Details:

XFAIL: 03_network_attach_detach_multiple_pos 
	 Network device is not actually connected to domU


[-- Attachment #7: x305rh4pae.report --]
[-- Type: text/plain, Size: 182 bytes --]

Xm-test execution summary:
  PASS:  98
  FAIL:  1
  XPASS: 0
  XFAIL: 1


Details:

XFAIL: 03_network_attach_detach_multiple_pos 
	 Network device is not actually connected to domU


[-- Attachment #8: x305sles9nonpae.report --]
[-- Type: text/plain, Size: 182 bytes --]

Xm-test execution summary:
  PASS:  98
  FAIL:  1
  XPASS: 0
  XFAIL: 1


Details:

XFAIL: 03_network_attach_detach_multiple_pos 
	 Network device is not actually connected to domU


[-- Attachment #9: x335fc4pae.report --]
[-- Type: text/plain, Size: 182 bytes --]

Xm-test execution summary:
  PASS:  99
  FAIL:  1
  XPASS: 0
  XFAIL: 1


Details:

XFAIL: 03_network_attach_detach_multiple_pos 
	 Network device is not actually connected to domU


[-- Attachment #10: x460.fc3-x86_64-8gb.report --]
[-- Type: text/plain, Size: 1290 bytes --]

Xm-test execution summary:
  PASS:  83
  FAIL:  17
  XPASS: 0
  XFAIL: 1


Details:

 FAIL: 05_create_noroot_noram_neg 
	 xm create test05 passed with no root and no ramdisk. Expected result Fail.

 FAIL: 15_create_smallmem_pos 
	 Starting a console with 16 MB failed domain dies immediately!

 FAIL: 04_memset_smallmem_pos 
	 Bug #145 Ballooning DomU too low caused run-away

 FAIL: 01_network_attach_pos 
	 [Errno 5] Input/output error

 FAIL: 02_network_attach_detach_pos 
	 [Errno 5] Input/output error

XFAIL: 03_network_attach_detach_multiple_pos 
	 [Errno 5] Input/output error

 FAIL: 01_pause_basic_pos 
	 [Errno 5] Input/output error

 FAIL: 01_reboot_basic_pos 
	 [Errno 5] Input/output error

 FAIL: 01_shutdown_basic_pos 
	 [Errno 5] Input/output error

 FAIL: 02_sysrq_sync_pos 
	 [Errno 5] Input/output error

 FAIL: 03_sysrq_withreboot_pos 
	 [Errno 5] Input/output error

 FAIL: 01_unpause_basic_pos 
	 [Errno 5] Input/output error

 FAIL: 01_vcpu-disable_basic_pos 
	 failed to disable VCPU1

 FAIL: 01_save_basic_pos 
	 Command execution time exceeded 30 seconds

 FAIL: 01_restore_basic_pos 
	 Command execution time exceeded 30 seconds

 FAIL: 04_restore_withdevices_pos 
	 [Errno 5] Input/output error

 FAIL: 01_migrate_localhost_pos 
	 [Errno 5] Input/output error


[-- Attachment #11: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 4%]

* Re: [patch] CFQ for xen domains
  2005-11-24 11:31  3%                     ` Gerd Knorr
@ 2005-12-06 15:47  3%                       ` Gerd Knorr
  0 siblings, 0 replies; 200+ results
From: Gerd Knorr @ 2005-12-06 15:47 UTC (permalink / raw)
  To: Gerd Knorr; +Cc: Ian Pratt, xen-devel, Chris Mason, Kurt Garloff, Jens Axboe

[-- Attachment #1: Type: text/plain, Size: 173 bytes --]

Gerd Knorr wrote:
>   Hi folks,
> 
> New version of the patch, adapted to apply cleanly against latest 

One more version, this time against 3.0-final ;)

cheers,

   Gerd


[-- Attachment #2: blkback-8241-18.diff --]
[-- Type: text/x-patch, Size: 24591 bytes --]

diff -r 0255f48b757f linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Sun Dec  4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Tue Dec  6 15:29:06 2005
@@ -12,6 +12,8 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/kthread.h>
+#include <linux/list.h>
 #include <asm-xen/balloon.h>
 #include <asm/hypervisor.h>
 #include "common.h"
@@ -21,26 +23,26 @@
  * pulled from a communication ring are quite likely to end up being part of
  * the same scatter/gather request at the disc.
  * 
- * ** TRY INCREASING 'MAX_PENDING_REQS' IF WRITE SPEEDS SEEM TOO LOW **
+ * ** TRY INCREASING 'blkif_reqs' IF WRITE SPEEDS SEEM TOO LOW **
+ * 
  * This will increase the chances of being able to write whole tracks.
  * 64 should be enough to keep us competitive with Linux.
  */
-#define MAX_PENDING_REQS 64
-#define BATCH_PER_DOMAIN 16
-
-static unsigned long mmap_vstart;
-#define MMAP_PAGES						\
-	(MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
-#ifdef __ia64__
-static void *pending_vaddrs[MMAP_PAGES];
-#define MMAP_VADDR(_idx, _i) \
-	(unsigned long)(pending_vaddrs[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#else
-#define MMAP_VADDR(_req,_seg)						\
-	(mmap_vstart +							\
-	 ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +	\
-	 ((_seg) * PAGE_SIZE))
-#endif
+static int blkif_reqs = 64;
+static int mmap_pages;
+
+static int __init set_blkif_reqs(char *str)
+{
+	get_option(&str, &blkif_reqs);
+	return 1;
+}
+__setup("blkif_reqs=", set_blkif_reqs);
+
+/* runtime-switchable, check /sys/module/blkback/parameters/ ;) */
+static unsigned int log_stats = 0;
+static unsigned int debug_lvl = 0;
+module_param(log_stats, int, 0644);
+module_param(debug_lvl, int, 0644);
 
 /*
  * Each outstanding request that we've passed to the lower device layers has a 
@@ -55,43 +57,38 @@
 	atomic_t       pendcnt;
 	unsigned short operation;
 	int            status;
+	struct list_head free_list;
 } pending_req_t;
 
-/*
- * We can't allocate pending_req's in order, since they may complete out of 
- * order. We therefore maintain an allocation ring. This ring also indicates 
- * when enough work has been passed down -- at that point the allocation ring 
- * will be empty.
- */
-static pending_req_t pending_reqs[MAX_PENDING_REQS];
-static unsigned char pending_ring[MAX_PENDING_REQS];
-static spinlock_t pend_prod_lock = SPIN_LOCK_UNLOCKED;
-/* NB. We use a different index type to differentiate from shared blk rings. */
-typedef unsigned int PEND_RING_IDX;
-#define MASK_PEND_IDX(_i) ((_i)&(MAX_PENDING_REQS-1))
-static PEND_RING_IDX pending_prod, pending_cons;
-#define NR_PENDING_REQS (MAX_PENDING_REQS - pending_prod + pending_cons)
-
-static request_queue_t *plugged_queue;
-static inline void flush_plugged_queue(void)
-{
-	request_queue_t *q = plugged_queue;
-	if (q != NULL) {
-		if ( q->unplug_fn != NULL )
-			q->unplug_fn(q);
-		blk_put_queue(q);
-		plugged_queue = NULL;
-	}
-}
+static pending_req_t *pending_reqs;
+static struct list_head pending_free;
+static spinlock_t pending_free_lock = SPIN_LOCK_UNLOCKED;
+static DECLARE_WAIT_QUEUE_HEAD(pending_free_wq);
+
+#define BLKBACK_INVALID_HANDLE (~0)
+
+static unsigned long mmap_vstart;
+static void **pending_vaddrs;
+static grant_handle_t *pending_grant_handles;
+
+static inline int vaddr_pagenr(pending_req_t *req, int seg)
+{
+	return (req - pending_reqs) * BLKIF_MAX_SEGMENTS_PER_REQUEST + seg;
+}
+
+static inline unsigned long vaddr(pending_req_t *req, int seg)
+{
+	return pending_vaddrs[vaddr_pagenr(req, seg)];
+}
+
+#define pending_handle(_req, _seg) \
+	(pending_grant_handles[vaddr_pagenr(_req, _seg)])
+
 
 /* When using grant tables to map a frame for device access then the
  * handle returned must be used to unmap the frame. This is needed to
  * drop the ref count on the frame.
  */
-static grant_handle_t pending_grant_handles[MMAP_PAGES];
-#define pending_handle(_idx, _i) \
-    (pending_grant_handles[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#define BLKBACK_INVALID_HANDLE (~0)
 
 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
 /*
@@ -105,26 +102,79 @@
 static inline domid_t ID_TO_DOM(unsigned long id) { return (id >> 16); }
 #endif
 
-static int do_block_io_op(blkif_t *blkif, int max_to_do);
-static void dispatch_rw_block_io(blkif_t *blkif, blkif_request_t *req);
+static int do_block_io_op(blkif_t *blkif);
+static void dispatch_rw_block_io(blkif_t *blkif,
+				 blkif_request_t *req,
+				 pending_req_t *pending_req);
 static void make_response(blkif_t *blkif, unsigned long id, 
                           unsigned short op, int st);
 
-static void fast_flush_area(int idx, int nr_pages)
+/******************************************************************
+ * misc small helpers
+ */
+static pending_req_t* alloc_req(void)
+{
+	pending_req_t *req = NULL;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+	if (!list_empty(&pending_free)) {
+		req = list_entry(pending_free.next, pending_req_t, free_list);
+		list_del(&req->free_list);
+	}
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+	return req;
+}
+
+static void free_req(pending_req_t *req)
+{
+	unsigned long flags;
+	int was_empty;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+	was_empty = list_empty(&pending_free);
+	list_add(&req->free_list, &pending_free);
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+	if (was_empty)
+		wake_up(&pending_free_wq);
+}
+
+static void unplug_queue(blkif_t *blkif)
+{
+	if (NULL == blkif->plug)
+		return;
+	if (blkif->plug->unplug_fn)
+		blkif->plug->unplug_fn(blkif->plug);
+	blk_put_queue(blkif->plug);
+	blkif->plug = NULL;
+}
+
+static void plug_queue(blkif_t *blkif, struct bio *bio)
+{
+	request_queue_t *q = bdev_get_queue(bio->bi_bdev);
+
+	if (q == blkif->plug)
+		return;
+	unplug_queue(blkif);
+	blk_get_queue(q);
+	blkif->plug = q;
+}
+
+static void fast_flush_area(pending_req_t *req)
 {
 	struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	unsigned int i, invcount = 0;
 	grant_handle_t handle;
 	int ret;
 
-	for (i = 0; i < nr_pages; i++) {
-		handle = pending_handle(idx, i);
+	for (i = 0; i < req->nr_pages; i++) {
+		handle = pending_handle(req, i);
 		if (handle == BLKBACK_INVALID_HANDLE)
 			continue;
-		unmap[invcount].host_addr    = MMAP_VADDR(idx, i);
+		unmap[invcount].host_addr    = vaddr(req, i);
 		unmap[invcount].dev_bus_addr = 0;
 		unmap[invcount].handle       = handle;
-		pending_handle(idx, i) = BLKBACK_INVALID_HANDLE;
+		pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
 		invcount++;
 	}
 
@@ -133,109 +183,79 @@
 	BUG_ON(ret);
 }
 
-
-/******************************************************************
- * BLOCK-DEVICE SCHEDULER LIST MAINTENANCE
- */
-
-static struct list_head blkio_schedule_list;
-static spinlock_t blkio_schedule_list_lock;
-
-static int __on_blkdev_list(blkif_t *blkif)
-{
-	return blkif->blkdev_list.next != NULL;
-}
-
-static void remove_from_blkdev_list(blkif_t *blkif)
-{
-	unsigned long flags;
-
-	if (!__on_blkdev_list(blkif))
-		return;
-
-	spin_lock_irqsave(&blkio_schedule_list_lock, flags);
-	if (__on_blkdev_list(blkif)) {
-		list_del(&blkif->blkdev_list);
-		blkif->blkdev_list.next = NULL;
-		blkif_put(blkif);
-	}
-	spin_unlock_irqrestore(&blkio_schedule_list_lock, flags);
-}
-
-static void add_to_blkdev_list_tail(blkif_t *blkif)
-{
-	unsigned long flags;
-
-	if (__on_blkdev_list(blkif))
-		return;
-
-	spin_lock_irqsave(&blkio_schedule_list_lock, flags);
-	if (!__on_blkdev_list(blkif) && (blkif->status == CONNECTED)) {
-		list_add_tail(&blkif->blkdev_list, &blkio_schedule_list);
-		blkif_get(blkif);
-	}
-	spin_unlock_irqrestore(&blkio_schedule_list_lock, flags);
-}
-
-
 /******************************************************************
  * SCHEDULER FUNCTIONS
  */
 
-static DECLARE_WAIT_QUEUE_HEAD(blkio_schedule_wait);
-
-static int blkio_schedule(void *arg)
-{
-	DECLARE_WAITQUEUE(wq, current);
-
-	blkif_t          *blkif;
-	struct list_head *ent;
-
-	daemonize("xenblkd");
-
+static void print_stats(blkif_t *blkif)
+{
+	printk(KERN_DEBUG "%s: oo %3d  |  rd %4d  |  wr %4d\n",
+	       current->comm, blkif->st_oo_req,
+	       blkif->st_rd_req, blkif->st_wr_req);
+	blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000);
+	blkif->st_rd_req = 0;
+	blkif->st_wr_req = 0;
+	blkif->st_oo_req = 0;
+}
+
+int blkif_schedule(void *arg)
+{
+	blkif_t          *blkif = arg;
+
+	blkif_get(blkif);
+	if (debug_lvl)
+		printk(KERN_DEBUG "%s: started\n", current->comm);
 	for (;;) {
-		/* Wait for work to do. */
-		add_wait_queue(&blkio_schedule_wait, &wq);
-		set_current_state(TASK_INTERRUPTIBLE);
-		if ( (NR_PENDING_REQS == MAX_PENDING_REQS) || 
-		     list_empty(&blkio_schedule_list) )
-			schedule();
-		__set_current_state(TASK_RUNNING);
-		remove_wait_queue(&blkio_schedule_wait, &wq);
-
-		/* Queue up a batch of requests. */
-		while ((NR_PENDING_REQS < MAX_PENDING_REQS) &&
-		       !list_empty(&blkio_schedule_list)) {
-			ent = blkio_schedule_list.next;
-			blkif = list_entry(ent, blkif_t, blkdev_list);
-			blkif_get(blkif);
-			remove_from_blkdev_list(blkif);
-			if (do_block_io_op(blkif, BATCH_PER_DOMAIN))
-				add_to_blkdev_list_tail(blkif);
-			blkif_put(blkif);
-		}
-
-		/* Push the batch through to disc. */
-		flush_plugged_queue();
-	}
-}
-
-static void maybe_trigger_blkio_schedule(void)
-{
-	/*
-	 * Needed so that two processes, which together make the following
-	 * predicate true, don't both read stale values and evaluate the
-	 * predicate incorrectly. Incredibly unlikely to stall the scheduler
-	 * on x86, but...
-	 */
-	smp_mb();
-
-	if ((NR_PENDING_REQS < (MAX_PENDING_REQS/2)) &&
-	    !list_empty(&blkio_schedule_list))
-		wake_up(&blkio_schedule_wait);
-}
-
-
+		if (kthread_should_stop()) {
+			/* asked to quit? */
+			if (!atomic_read(&blkif->io_pending))
+				break;
+			if (debug_lvl)
+				printk(KERN_DEBUG "%s: I/O pending, delaying exit\n",
+				       current->comm);
+		}
+
+		if (!atomic_read(&blkif->io_pending)) {
+			/* Wait for work to do. */
+			wait_event_interruptible(blkif->wq,
+						 atomic_read(&blkif->io_pending) ||
+						 kthread_should_stop());
+		} else if (list_empty(&pending_free)) {
+			/* Wait for pending_req becoming available. */
+			wait_event_interruptible(pending_free_wq,
+						 !list_empty(&pending_free));
+		}
+
+		if (blkif->status != CONNECTED) {
+			/* make sure we are connected */
+			if (debug_lvl)
+				printk(KERN_DEBUG "%s: not connected (%d pending)\n",
+				       current->comm, atomic_read(&blkif->io_pending));
+			wait_event_interruptible(blkif->wq,
+						 blkif->status != CONNECTED ||
+						 kthread_should_stop());
+			continue;
+		}
+
+		/* Schedule I/O */
+		atomic_set(&blkif->io_pending, 0);
+		if (do_block_io_op(blkif))
+			atomic_inc(&blkif->io_pending);
+		unplug_queue(blkif);
+
+		if (log_stats && time_after(jiffies, blkif->st_print))
+			print_stats(blkif);
+	}
+
+	/* bye folks, and thanks for all the fish ;) */
+	if (log_stats)
+		print_stats(blkif);
+	if (debug_lvl)
+		printk(KERN_DEBUG "%s: exiting\n", current->comm);
+	blkif->xenblkd = NULL;
+	blkif_put(blkif);
+	return 0;
+}
 
 /******************************************************************
  * COMPLETION CALLBACK -- Called as bh->b_end_io()
@@ -243,8 +263,6 @@
 
 static void __end_block_io_op(pending_req_t *pending_req, int uptodate)
 {
-	unsigned long flags;
-
 	/* An error fails the entire request. */
 	if (!uptodate) {
 		DPRINTK("Buffer not up-to-date at end of operation\n");
@@ -252,15 +270,11 @@
 	}
 
 	if (atomic_dec_and_test(&pending_req->pendcnt)) {
-		int pending_idx = pending_req - pending_reqs;
-		fast_flush_area(pending_idx, pending_req->nr_pages);
+		fast_flush_area(pending_req);
 		make_response(pending_req->blkif, pending_req->id,
 			      pending_req->operation, pending_req->status);
 		blkif_put(pending_req->blkif);
-		spin_lock_irqsave(&pend_prod_lock, flags);
-		pending_ring[MASK_PEND_IDX(pending_prod++)] = pending_idx;
-		spin_unlock_irqrestore(&pend_prod_lock, flags);
-		maybe_trigger_blkio_schedule();
+		free_req(pending_req);
 	}
 }
 
@@ -281,8 +295,9 @@
 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
 {
 	blkif_t *blkif = dev_id;
-	add_to_blkdev_list_tail(blkif);
-	maybe_trigger_blkio_schedule();
+
+	atomic_inc(&blkif->io_pending);
+	wake_up(&blkif->wq);
 	return IRQ_HANDLED;
 }
 
@@ -292,10 +307,11 @@
  * DOWNWARD CALLS -- These interface with the block-device layer proper.
  */
 
-static int do_block_io_op(blkif_t *blkif, int max_to_do)
+static int do_block_io_op(blkif_t *blkif)
 {
 	blkif_back_ring_t *blk_ring = &blkif->blk_ring;
 	blkif_request_t *req;
+	pending_req_t *pending_req;
 	RING_IDX rc, rp;
 	int more_to_do = 0;
 
@@ -304,8 +320,10 @@
 	rmb(); /* Ensure we see queued requests up to 'rp'. */
 
 	while ((rc != rp) && !RING_REQUEST_CONS_OVERFLOW(blk_ring, rc)) {
-		if ((max_to_do-- == 0) ||
-		    (NR_PENDING_REQS == MAX_PENDING_REQS)) {
+
+		pending_req = alloc_req();
+		if (NULL == pending_req) {
+			blkif->st_oo_req++;
 			more_to_do = 1;
 			break;
 		}
@@ -315,28 +333,31 @@
 
 		switch (req->operation) {
 		case BLKIF_OP_READ:
+			blkif->st_rd_req++;
+			dispatch_rw_block_io(blkif, req, pending_req);
+			break;
 		case BLKIF_OP_WRITE:
-			dispatch_rw_block_io(blkif, req);
+			blkif->st_wr_req++;
+			dispatch_rw_block_io(blkif, req, pending_req);
 			break;
-
 		default:
 			DPRINTK("error: unknown block io operation [%d]\n",
 				req->operation);
 			make_response(blkif, req->id, req->operation,
 				      BLKIF_RSP_ERROR);
+			free_req(pending_req);
 			break;
 		}
 	}
-
 	return more_to_do;
 }
 
-static void dispatch_rw_block_io(blkif_t *blkif, blkif_request_t *req)
+static void dispatch_rw_block_io(blkif_t *blkif,
+				 blkif_request_t *req,
+				 pending_req_t *pending_req)
 {
 	extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]); 
 	int operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
-	int i, pending_idx = pending_ring[MASK_PEND_IDX(pending_cons)];
-	pending_req_t *pending_req;
 	struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	struct phys_req preq;
 	struct { 
@@ -344,32 +365,36 @@
 	} seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 	unsigned int nseg;
 	struct bio *bio = NULL, *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
-	int nbio = 0;
-	request_queue_t *q;
-	int ret, errors = 0;
+	int ret, i, nbio = 0;
 
 	/* Check that number of segments is sane. */
 	nseg = req->nr_segments;
 	if (unlikely(nseg == 0) || 
 	    unlikely(nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) {
 		DPRINTK("Bad number of segments in request (%d)\n", nseg);
-		goto bad_descriptor;
+		goto fail_response;
 	}
 
 	preq.dev           = req->handle;
 	preq.sector_number = req->sector_number;
 	preq.nr_sects      = 0;
 
+	pending_req->blkif     = blkif;
+	pending_req->id        = req->id;
+	pending_req->operation = operation;
+	pending_req->status    = BLKIF_RSP_OKAY;
+	pending_req->nr_pages  = nseg;
+
 	for (i = 0; i < nseg; i++) {
 		seg[i].nsec = req->seg[i].last_sect -
 			req->seg[i].first_sect + 1;
 
 		if ((req->seg[i].last_sect >= (PAGE_SIZE >> 9)) ||
 		    (seg[i].nsec <= 0))
-			goto bad_descriptor;
+			goto fail_response;
 		preq.nr_sects += seg[i].nsec;
 
-		map[i].host_addr = MMAP_VADDR(pending_idx, i);
+		map[i].host_addr = vaddr(pending_req, i);
 		map[i].dom = blkif->domid;
 		map[i].ref = req->seg[i].gref;
 		map[i].flags = GNTMAP_host_map;
@@ -381,26 +406,22 @@
 	BUG_ON(ret);
 
 	for (i = 0; i < nseg; i++) {
-		if (likely(map[i].status == 0)) {
-			pending_handle(pending_idx, i) = map[i].handle;
+		if (unlikely(map[i].status != 0)) {
+			DPRINTK("invalid buffer -- could not remap it\n");
+			goto fail_flush;
+		}
+
+		pending_handle(pending_req, i) = map[i].handle;
 #ifdef __ia64__
-			MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
+		pending_vaddrs[vaddr_pagenr(req, seg)] =
+			= gnttab_map_vaddr(map[i]);
 #else
-			set_phys_to_machine(__pa(MMAP_VADDR(
-				pending_idx, i)) >> PAGE_SHIFT,
-				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT));
+		set_phys_to_machine(__pa(vaddr(
+			pending_req, i)) >> PAGE_SHIFT,
+			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
 #endif
-			seg[i].buf = map[i].dev_bus_addr |
-				(req->seg[i].first_sect << 9);
-		} else {
-			errors++;
-		}
-	}
-
-	if (errors) {
-		DPRINTK("invalid buffer -- could not remap it\n");
-		fast_flush_area(pending_idx, nseg);
-		goto bad_descriptor;
+		seg[i].buf  = map[i].dev_bus_addr | 
+			(req->seg[i].first_sect << 9);
 	}
 
 	if (vbd_translate(&preq, blkif, operation) != 0) {
@@ -408,37 +429,25 @@
 			operation == READ ? "read" : "write",
 			preq.sector_number,
 			preq.sector_number + preq.nr_sects, preq.dev); 
-		goto bad_descriptor;
-	}
-
-	pending_req = &pending_reqs[pending_idx];
-	pending_req->blkif     = blkif;
-	pending_req->id        = req->id;
-	pending_req->operation = operation;
-	pending_req->status    = BLKIF_RSP_OKAY;
-	pending_req->nr_pages  = nseg;
+		goto fail_flush;
+	}
 
 	for (i = 0; i < nseg; i++) {
 		if (((int)preq.sector_number|(int)seg[i].nsec) &
 		    ((bdev_hardsect_size(preq.bdev) >> 9) - 1)) {
 			DPRINTK("Misaligned I/O request from domain %d",
 				blkif->domid);
-			goto cleanup_and_fail;
+			goto fail_put_bio;
 		}
 
 		while ((bio == NULL) ||
 		       (bio_add_page(bio,
-				     virt_to_page(MMAP_VADDR(pending_idx, i)),
+				     virt_to_page(vaddr(pending_req, i)),
 				     seg[i].nsec << 9,
 				     seg[i].buf & ~PAGE_MASK) == 0)) {
 			bio = biolist[nbio++] = bio_alloc(GFP_KERNEL, nseg-i);
-			if (unlikely(bio == NULL)) {
-			cleanup_and_fail:
-				for (i = 0; i < (nbio-1); i++)
-					bio_put(biolist[i]);
-				fast_flush_area(pending_idx, nseg);
-				goto bad_descriptor;
-			}
+			if (unlikely(bio == NULL))
+				goto fail_put_bio;
                 
 			bio->bi_bdev    = preq.bdev;
 			bio->bi_private = pending_req;
@@ -449,14 +458,8 @@
 		preq.sector_number += seg[i].nsec;
 	}
 
-	if ((q = bdev_get_queue(bio->bi_bdev)) != plugged_queue) {
-		flush_plugged_queue();
-		blk_get_queue(q);
-		plugged_queue = q;
-	}
-
+	plug_queue(blkif, bio);
 	atomic_set(&pending_req->pendcnt, nbio);
-	pending_cons++;
 	blkif_get(blkif);
 
 	for (i = 0; i < nbio; i++)
@@ -464,8 +467,14 @@
 
 	return;
 
- bad_descriptor:
+ fail_put_bio:
+	for (i = 0; i < (nbio-1); i++)
+		bio_put(biolist[i]);
+ fail_flush:
+	fast_flush_area(pending_req);
+ fail_response:
 	make_response(blkif, req->id, req->operation, BLKIF_RSP_ERROR);
+	free_req(pending_req);
 } 
 
 
@@ -481,6 +490,7 @@
 	blkif_response_t *resp;
 	unsigned long     flags;
 	blkif_back_ring_t *blk_ring = &blkif->blk_ring;
+	int more_to_do = 0;
 	int notify;
 
 	spin_lock_irqsave(&blkif->blk_ring_lock, flags);
@@ -499,76 +509,67 @@
 		 * notifications if requests are already in flight (lower
 		 * overheads and promotes batching).
 		 */
-		int more_to_do;
 		RING_FINAL_CHECK_FOR_REQUESTS(blk_ring, more_to_do);
-		if (more_to_do) {
-			add_to_blkdev_list_tail(blkif);
-			maybe_trigger_blkio_schedule();
-		}
-	}
-	else if (!__on_blkdev_list(blkif)
-		 && RING_HAS_UNCONSUMED_REQUESTS(blk_ring)) {
-		/* Keep pulling requests as they become available... */
-		add_to_blkdev_list_tail(blkif);
-		maybe_trigger_blkio_schedule();
-	}
-
+
+	} else if (RING_HAS_UNCONSUMED_REQUESTS(blk_ring)) {
+		more_to_do = 1;
+
+	}
 	spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
 
+	if (more_to_do) {
+		atomic_inc(&blkif->io_pending);
+		wake_up(&blkif->wq);
+	}
 	if (notify)
 		notify_remote_via_irq(blkif->irq);
 }
 
-void blkif_deschedule(blkif_t *blkif)
-{
-	remove_from_blkdev_list(blkif);
-}
-
 static int __init blkif_init(void)
 {
+	struct page *page;
 	int i;
-	struct page *page;
-	int ret;
-
-	for (i = 0; i < MMAP_PAGES; i++)
-		pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
 
 	if (xen_init() < 0)
 		return -ENODEV;
 
+	mmap_pages            = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
+	pending_reqs          = kmalloc(sizeof(pending_reqs[0]) *
+					blkif_reqs, GFP_KERNEL);
+	pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
+					mmap_pages, GFP_KERNEL);
+	pending_vaddrs        = kmalloc(sizeof(pending_vaddrs[0]) *
+					mmap_pages, GFP_KERNEL);
+	if (!pending_reqs || !pending_grant_handles || !pending_vaddrs) {
+		printk("%s: out of memory\n", __FUNCTION__);
+		return -1;
+	}
+
 	blkif_interface_init();
-
+	
 #ifdef __ia64__
-    {
 	extern unsigned long alloc_empty_foreign_map_page_range(unsigned long pages);
-	int i;
-
-	mmap_vstart =  alloc_empty_foreign_map_page_range(MMAP_PAGES);
-	printk("Allocated mmap_vstart: 0x%lx\n", mmap_vstart);
-	for(i = 0; i < MMAP_PAGES; i++)
-	    pending_vaddrs[i] = mmap_vstart + (i << PAGE_SHIFT);
-	BUG_ON(mmap_vstart == NULL);
-    }
-#else
-	page = balloon_alloc_empty_page_range(MMAP_PAGES);
+	mmap_vstart = (unsigned long)alloc_empty_foreign_map_page_range(mmap_pages);
+#else /* ! ia64 */
+	page = balloon_alloc_empty_page_range(mmap_pages);
 	BUG_ON(page == NULL);
 	mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
 #endif
-
-	pending_cons = 0;
-	pending_prod = MAX_PENDING_REQS;
+	printk("%s: reqs=%d, pages=%d, mmap_vstart=0x%lx\n",
+	       __FUNCTION__, blkif_reqs, mmap_pages, mmap_vstart);
+	BUG_ON(mmap_vstart == 0);
+	for (i = 0; i < mmap_pages; i++) {
+		pending_vaddrs[i] = mmap_vstart + (i << PAGE_SHIFT);
+		pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
+	}
+
 	memset(pending_reqs, 0, sizeof(pending_reqs));
-	for (i = 0; i < MAX_PENDING_REQS; i++)
-		pending_ring[i] = i;
+	INIT_LIST_HEAD(&pending_free);
+
+	for (i = 0; i < blkif_reqs; i++)
+		list_add_tail(&pending_reqs[i].free_list, &pending_free);
     
-	spin_lock_init(&blkio_schedule_list_lock);
-	INIT_LIST_HEAD(&blkio_schedule_list);
-
-	ret = kernel_thread(blkio_schedule, NULL, CLONE_FS | CLONE_FILES);
-	BUG_ON(ret < 0);
-
 	blkif_xenbus_init();
-
 	return 0;
 }
 
diff -r 0255f48b757f linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Sun Dec  4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Tue Dec  6 15:29:06 2005
@@ -60,9 +60,19 @@
 	/* Is this a blktap frontend */
 	unsigned int     is_blktap;
 #endif
-	struct list_head blkdev_list;
 	spinlock_t       blk_ring_lock;
 	atomic_t         refcnt;
+
+	wait_queue_head_t   wq;
+	struct task_struct  *xenblkd;
+	atomic_t            io_pending;
+	request_queue_t     *plug;
+
+	/* statistics */
+	unsigned long       st_print;
+	int                 st_rd_req;
+	int                 st_wr_req;
+	int                 st_oo_req;
 
 	struct work_struct free_work;
 
@@ -101,11 +111,10 @@
 
 void blkif_interface_init(void);
 
-void blkif_deschedule(blkif_t *blkif);
-
 void blkif_xenbus_init(void);
 
 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
+int blkif_schedule(void *arg);
 
 void update_blkif_status(blkif_t *blkif); 
 
diff -r 0255f48b757f linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Sun Dec  4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Tue Dec  6 15:29:06 2005
@@ -24,6 +24,8 @@
 	blkif->status = DISCONNECTED;
 	spin_lock_init(&blkif->blk_ring_lock);
 	atomic_set(&blkif->refcnt, 1);
+	init_waitqueue_head(&blkif->wq);
+	blkif->st_print = jiffies;
 
 	return blkif;
 }
@@ -111,6 +113,7 @@
 
 	blkif->irq = bind_evtchn_to_irqhandler(
 		blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
+	wake_up(&blkif->wq);
 
 	/* We're potentially connected now */
 	update_blkif_status(blkif); 
diff -r 0255f48b757f linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Sun Dec  4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Tue Dec  6 15:29:06 2005
@@ -20,6 +20,7 @@
 
 #include <stdarg.h>
 #include <linux/module.h>
+#include <linux/kthread.h>
 #include <asm-xen/xenbus.h>
 #include "common.h"
 
@@ -92,6 +93,8 @@
 	}
 	if (be->blkif) {
 		be->blkif->status = DISCONNECTED; 
+		if (be->blkif->xenblkd)
+			kthread_stop(be->blkif->xenblkd);
 		blkif_put(be->blkif);
 		be->blkif = NULL;
 	}
@@ -217,6 +220,17 @@
 			be->major = 0;
 			be->minor = 0;
 			xenbus_dev_fatal(dev, err, "creating vbd structure");
+			return;
+		}
+
+		be->blkif->xenblkd = kthread_run(blkif_schedule, be->blkif,
+						 "xvd %d %02x:%02x",
+						 be->blkif->domid,
+						 be->major, be->minor);
+		if (IS_ERR(be->blkif->xenblkd)) {
+			err = PTR_ERR(be->blkif->xenblkd);
+			be->blkif->xenblkd = NULL;
+			xenbus_dev_error(dev, err, "start xenblkd");
 			return;
 		}
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 3%]

* [PATCH] Arch-neutral balloon driver
@ 2005-12-07  0:16 16% Magenheimer, Dan (HP Labs Fort Collins)
  2005-12-07 21:13  0% ` Hollis Blanchard
  0 siblings, 1 reply; 200+ results
From: Magenheimer, Dan (HP Labs Fort Collins) @ 2005-12-07  0:16 UTC (permalink / raw)
  To: Xen Mailing List

Attached patch makes the balloon driver arch-neutral
(compiles on ia64... look ma, no #ifdef's!).  Please apply
to xen-unstable.

One change should be eyeballed, line 257 in balloon.c, because
phys_to_machine_mapping[pfn] is not identical to pfn_to_mfn
(different by sign bit, should be OK?)

Signed-off by: Dan Magenheimer <dan.magenheimer@hp.com>

diff -r 0255f48b757f linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sun Dec
4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Tue Dec
6 16:25:53 2005
@@ -192,8 +192,8 @@
 		page = balloon_retrieve();
 		BUG_ON(page == NULL);
 
-		pfn = page - mem_map;
-		BUG_ON(phys_to_machine_mapping[pfn] !=
INVALID_P2M_ENTRY);
+		pfn = page_to_pfn(page);
+		BUG_ON(phys_to_machine_mapping_valid(pfn));
 
 		/* Update P->M and M->P tables. */
 		set_phys_to_machine(pfn, mfn_list[i]);
@@ -253,8 +253,8 @@
 			break;
 		}
 
-		pfn = page - mem_map;
-		mfn_list[i] = phys_to_machine_mapping[pfn];
+		pfn = page_to_pfn(page);
+		mfn_list[i] = pfn_to_mfn(pfn);
 
 		if (!PageHighMem(page)) {
 			v = phys_to_virt(pfn << PAGE_SHIFT);
@@ -444,6 +444,9 @@
 
 	IPRINTK("Initialising balloon driver.\n");
 
+	if (xen_init() < 0)
+		return -1;
+
 	current_pages = min(xen_start_info->nr_pages, max_pfn);
 	target_pages  = current_pages;
 	balloon_low   = 0;
@@ -465,7 +468,7 @@
     
 	/* Initialise the balloon with excess memory space. */
 	for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
-		page = &mem_map[pfn];
+		page = pfn_to_page(pfn);
 		if (!PageReserved(page))
 			balloon_append(page);
 	}
diff -r 0255f48b757f
linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Sun Dec
4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Tue Dec
6 16:25:53 2005
@@ -65,6 +65,8 @@
 extern unsigned long *phys_to_machine_mapping;
 #define pfn_to_mfn(pfn)	\
 (phys_to_machine_mapping[(unsigned int)(pfn)] & ~(1UL<<31))
+#define	phys_to_machine_mapping_valid(pfn) \
+	(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY)
 static inline unsigned long mfn_to_pfn(unsigned long mfn)
 {
 	unsigned long pfn;
diff -r 0255f48b757f
linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h	Sun Dec
4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h	Tue Dec
6 16:25:53 2005
@@ -355,34 +355,27 @@
 #endif
     return 1;
 }
+#endif
 
 static inline int
 HYPERVISOR_update_va_mapping(
     unsigned long va, pte_t new_val, unsigned long flags)
 {
-#if 0
-    int ret;
-    unsigned long ign1, ign2, ign3;
-
-    __asm__ __volatile__ (
-        TRAP_INSTR
-        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
-	: "0" (__HYPERVISOR_update_va_mapping), 
-          "1" (va), "2" ((new_val).pte_low), "3" (flags)
-	: "memory" );
-
-    if ( unlikely(ret < 0) )
-    {
-        printk(KERN_ALERT "Failed update VA mapping: %08lx, %08lx,
%08lx\n",
-               va, (new_val).pte_low, flags);
-        BUG();
-    }
-
-    return ret;
-#endif
-    return 1;
-}
-#endif
+    /* no-op */
+    return 1;
+}
+
+static inline int
+HYPERVISOR_memory_op(
+    unsigned int cmd, void *arg)
+{
+    int ret;
+    __asm__ __volatile__ ( ";; mov r14=%2 ; mov r15=%3 ; mov r2=%1 ;
break 0x1000 ;; mov %0=r8 ;;"
+        : "=r" (ret)
+        : "i" (__HYPERVISOR_console_io), "r"(cmd), "r"(arg)
+        : "r14","r15","r2","r8","memory" );
+    return ret;
+}
 
 static inline int
 HYPERVISOR_event_channel_op(
diff -r 0255f48b757f
linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
Sun Dec  4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
Tue Dec  6 16:25:53 2005
@@ -52,4 +52,19 @@
 #define	mfn_to_pfn(x)	(x)
 #define machine_to_phys_mapping 0
 
+// for drivers/xen/balloon/balloon.c
+#ifdef CONFIG_XEN_SCRUB_PAGES
+#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
+#else
+#define scrub_pages(_p,_n) ((void)0)
+#endif
+#define	pte_mfn(_x)	pte_pfn(_x)
+#define INVALID_P2M_ENTRY	(~0UL)
+#define __pte_ma(_x)	((pte_t) {(_x)})
+#define phys_to_machine_mapping_valid(_x)	(1)
+#define	kmap_flush_unused()	do {} while (0)
+#define set_phys_to_machine(_x,_y)	do {} while (0)
+#define xen_machphys_update(_x,_y)	do {} while (0)
+#define pfn_pte_ma(_x,_y)	__pte_ma(0)
+
 #endif /* __HYPERVISOR_H__ */
diff -r 0255f48b757f
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Sun Dec
4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Tue Dec
6 16:25:53 2005
@@ -67,6 +67,8 @@
 extern unsigned long *phys_to_machine_mapping;
 #define pfn_to_mfn(pfn)	\
 (phys_to_machine_mapping[(unsigned int)(pfn)] & ~(1UL << 63))
+#define	phys_to_machine_mapping_valid(pfn) \
+	(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY)
 static inline unsigned long mfn_to_pfn(unsigned long mfn)
 {
 	unsigned long pfn;

^ permalink raw reply	[relevance 16%]

* RE: [PATCH] Arch-neutral balloon driver
@ 2005-12-07  3:35  0% Tian, Kevin
  0 siblings, 0 replies; 200+ results
From: Tian, Kevin @ 2005-12-07  3:35 UTC (permalink / raw)
  To: Magenheimer, Dan (HP Labs Fort Collins), Xen Mailing List

>From: Magenheimer, Dan
>(HP Labs Fort Collins)
>Sent: 2005年12月7日 8:16
>
>Attached patch makes the balloon driver arch-neutral
>(compiles on ia64... look ma, no #ifdef's!).  Please apply
>to xen-unstable.

One comment is to add a get_phys_to_machine, just like set_phys_to_machine, which may save your time in other similar cases where that translation array is missing on arch like ia64.

>
>One change should be eyeballed, line 257 in balloon.c, because
>phys_to_machine_mapping[pfn] is not identical to pfn_to_mfn
>(different by sign bit, should be OK?)

If all previous foreign mapped pages are correctly handled at destruction, they will go into balloon pool directly instead of buddy system. So Ideally new allocated pages from buddy pool shouldn't have foreign flag set, and then two access ways should be identical. You may add an ASSERT upon this flag there for sanity.

Thanks,
Kevins
>
>Signed-off by: Dan Magenheimer <dan.magenheimer@hp.com>
>
>diff -r 0255f48b757f linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
>--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sun Dec
>4 19:12:00 2005
>+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Tue Dec
>6 16:25:53 2005
>@@ -192,8 +192,8 @@
> 		page = balloon_retrieve();
> 		BUG_ON(page == NULL);
>
>-		pfn = page - mem_map;
>-		BUG_ON(phys_to_machine_mapping[pfn] !=
>INVALID_P2M_ENTRY);
>+		pfn = page_to_pfn(page);
>+		BUG_ON(phys_to_machine_mapping_valid(pfn));
>
> 		/* Update P->M and M->P tables. */
> 		set_phys_to_machine(pfn, mfn_list[i]);
>@@ -253,8 +253,8 @@
> 			break;
> 		}
>
>-		pfn = page - mem_map;
>-		mfn_list[i] = phys_to_machine_mapping[pfn];
>+		pfn = page_to_pfn(page);
>+		mfn_list[i] = pfn_to_mfn(pfn);
>
> 		if (!PageHighMem(page)) {
> 			v = phys_to_virt(pfn << PAGE_SHIFT);
>@@ -444,6 +444,9 @@
>
> 	IPRINTK("Initialising balloon driver.\n");
>
>+	if (xen_init() < 0)
>+		return -1;
>+
> 	current_pages = min(xen_start_info->nr_pages, max_pfn);
> 	target_pages  = current_pages;
> 	balloon_low   = 0;
>@@ -465,7 +468,7 @@
>
> 	/* Initialise the balloon with excess memory space. */
> 	for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
>-		page = &mem_map[pfn];
>+		page = pfn_to_page(pfn);
> 		if (!PageReserved(page))
> 			balloon_append(page);
> 	}
>diff -r 0255f48b757f
>linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h
>--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Sun Dec
>4 19:12:00 2005
>+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Tue Dec
>6 16:25:53 2005
>@@ -65,6 +65,8 @@
> extern unsigned long *phys_to_machine_mapping;
> #define pfn_to_mfn(pfn)	\
> (phys_to_machine_mapping[(unsigned int)(pfn)] & ~(1UL<<31))
>+#define	phys_to_machine_mapping_valid(pfn) \
>+	(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY)
> static inline unsigned long mfn_to_pfn(unsigned long mfn)
> {
> 	unsigned long pfn;
>diff -r 0255f48b757f
>linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h
>--- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h	Sun Dec
>4 19:12:00 2005
>+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h	Tue Dec
>6 16:25:53 2005
>@@ -355,34 +355,27 @@
> #endif
>     return 1;
> }
>+#endif
>
> static inline int
> HYPERVISOR_update_va_mapping(
>     unsigned long va, pte_t new_val, unsigned long flags)
> {
>-#if 0
>-    int ret;
>-    unsigned long ign1, ign2, ign3;
>-
>-    __asm__ __volatile__ (
>-        TRAP_INSTR
>-        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
>-	: "0" (__HYPERVISOR_update_va_mapping),
>-          "1" (va), "2" ((new_val).pte_low), "3" (flags)
>-	: "memory" );
>-
>-    if ( unlikely(ret < 0) )
>-    {
>-        printk(KERN_ALERT "Failed update VA mapping: %08lx, %08lx,
>%08lx\n",
>-               va, (new_val).pte_low, flags);
>-        BUG();
>-    }
>-
>-    return ret;
>-#endif
>-    return 1;
>-}
>-#endif
>+    /* no-op */
>+    return 1;
>+}
>+
>+static inline int
>+HYPERVISOR_memory_op(
>+    unsigned int cmd, void *arg)
>+{
>+    int ret;
>+    __asm__ __volatile__ ( ";; mov r14=%2 ; mov r15=%3 ; mov r2=%1 ;
>break 0x1000 ;; mov %0=r8 ;;"
>+        : "=r" (ret)
>+        : "i" (__HYPERVISOR_console_io), "r"(cmd), "r"(arg)
>+        : "r14","r15","r2","r8","memory" );
>+    return ret;
>+}
>
> static inline int
> HYPERVISOR_event_channel_op(
>diff -r 0255f48b757f
>linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
>--- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
>Sun Dec  4 19:12:00 2005
>+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
>Tue Dec  6 16:25:53 2005
>@@ -52,4 +52,19 @@
> #define	mfn_to_pfn(x)	(x)
> #define machine_to_phys_mapping 0
>
>+// for drivers/xen/balloon/balloon.c
>+#ifdef CONFIG_XEN_SCRUB_PAGES
>+#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
>+#else
>+#define scrub_pages(_p,_n) ((void)0)
>+#endif
>+#define	pte_mfn(_x)	pte_pfn(_x)
>+#define INVALID_P2M_ENTRY	(~0UL)
>+#define __pte_ma(_x)	((pte_t) {(_x)})
>+#define phys_to_machine_mapping_valid(_x)	(1)
>+#define	kmap_flush_unused()	do {} while (0)
>+#define set_phys_to_machine(_x,_y)	do {} while (0)
>+#define xen_machphys_update(_x,_y)	do {} while (0)
>+#define pfn_pte_ma(_x,_y)	__pte_ma(0)
>+
> #endif /* __HYPERVISOR_H__ */
>diff -r 0255f48b757f
>linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h
>--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Sun Dec
>4 19:12:00 2005
>+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Tue Dec
>6 16:25:53 2005
>@@ -67,6 +67,8 @@
> extern unsigned long *phys_to_machine_mapping;
> #define pfn_to_mfn(pfn)	\
> (phys_to_machine_mapping[(unsigned int)(pfn)] & ~(1UL << 63))
>+#define	phys_to_machine_mapping_valid(pfn) \
>+	(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY)
> static inline unsigned long mfn_to_pfn(unsigned long mfn)
> {
> 	unsigned long pfn;
>
>_______________________________________________
>Xen-devel mailing list
>Xen-devel@lists.xensource.com
>http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 0%]

* Re: [PATCH] Arch-neutral balloon driver
  2005-12-07  0:16 16% [PATCH] Arch-neutral balloon driver Magenheimer, Dan (HP Labs Fort Collins)
@ 2005-12-07 21:13  0% ` Hollis Blanchard
  0 siblings, 0 replies; 200+ results
From: Hollis Blanchard @ 2005-12-07 21:13 UTC (permalink / raw)
  To: Magenheimer, Dan (HP Labs Fort Collins); +Cc: Xen Mailing List

On Dec 6, 2005, at 6:16 PM, Magenheimer, Dan (HP Labs Fort Collins)  
wrote:

> Attached patch makes the balloon driver arch-neutral
> (compiles on ia64... look ma, no #ifdef's!).  Please apply
> to xen-unstable.

> diff -r 0255f48b757f linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
> --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sun Dec 4  
> 19:12:00 2005
> +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Tue Dec 6  
> 16:25:53 2005
> @@ -444,6 +444,9 @@
>
>  	IPRINTK("Initialising balloon driver.\n");
>
> +	if (xen_init() < 0)
> +		return -1;
> +
>  	current_pages = min(xen_start_info->nr_pages, max_pfn);
>  	target_pages  = current_pages;
>  	balloon_low   = 0;

I had some suggestions to obviate this "xen_init()" stuff; you can read  
them again at  
http://lists.xensource.com/archives/html/xen-devel/2005-09/ 
msg00881.html . I see that xen_init() was introduced anyways, but I  
would not like to see it spread. Instead let's correct the problem it's  
working around.

> diff -r 0255f48b757f  
> linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
> --- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
> Sun Dec  4 19:12:00 2005
> +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
> Tue Dec  6 16:25:53 2005
> @@ -52,4 +52,19 @@
>  #define	mfn_to_pfn(x)	(x)
>  #define machine_to_phys_mapping 0
>
> +// for drivers/xen/balloon/balloon.c

C++ comment

Other than that this looks ok to me. I think your mailer line-wrapped  
the patch though.

-- 
Hollis Blanchard
IBM Linux Technology Center

^ permalink raw reply	[relevance 0%]

* [PATCH] [XM-TEST] Add support for VMX guests in xm-test
@ 2005-12-07 22:04  2% Daniel Stekloff
  0 siblings, 0 replies; 200+ results
From: Daniel Stekloff @ 2005-12-07 22:04 UTC (permalink / raw)
  To: Xen Mailing List; +Cc: Dan Smith, Yu, Ping Y

[-- Attachment #1: Type: text/plain, Size: 2293 bytes --]


Here's a patch to add initial support for vmx guests in xm-test. This
patch applies to changeset 8272:b215584242c4.

I've run it on both vmx and non-vmx guests. I got the following report
for running with vmx enabled:

Xm-test execution summary:
  PASS:  69
  FAIL:  23
  XPASS: 0
  XFAIL: 1
 
 
Details:
 
 FAIL: 01_block_attach_device_pos
         Device is not actually connected to the domU
 
 FAIL: 02_block_attach_file_device_pos
         Device is not actually connected to the domU
 
 FAIL: 04_block_attach_device_repeatedly_pos
         Device is not actually attached to domU
 
 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos
         Failed to attach block device /proc/partitions does not show
that!
 
 FAIL: 09_block_attach_and_dettach_device_check_data_pos
         Failed to dettach block device /proc/partitions still showing
that!
 
 FAIL: 03_block-list_anotherbd_pos
         Failed to verify that block dev is attached on DomainU
 
 FAIL: 06_block-list_checkremove_pos
         hda1 still shown in block-list after detach!
 
 FAIL: 01_block-destroy_btblock_pos
         domU reported block device still connected!
 
 FAIL: 02_block-destroy_rtblock_pos
         block-detach failed to detach block device
 
 FAIL: 05_block-destroy_byname_pos
        Unknown reason
 
 FAIL: 06_block-destroy_check_list_pos
         block-list does not show that hda1 was removed
 
 FAIL: 11_create_concurrent_pos
         [4] Failed to attach console to 11_create_4
 
 FAIL: 12_create_concurrent_stress_pos
         Timed out waiting for console
 
 FAIL: 13_create_multinic_pos
         (9 nics) Console didn't respond probably crashed!
 
 FAIL: 01_memset_basic_pos
         The DomU command 'cat /proc/xen/balloon' failed.
 
 FAIL: 03_memset_random_pos
         Invalid domU meminfo line
 
 FAIL: 01_network_attach_pos
         Network device is not actually connected to domU
 
 FAIL: 02_network_attach_detach_pos
         Network device is not actually connected to domU
 
XFAIL: 03_network_attach_detach_multiple_pos
         Network device is not actually connected to domU
 
 FAIL: 01_shutdown_basic_pos
         Guest domain failed to shutdown
 
 FAIL: 02_sysrq_sync_pos
         Sync SysRq not delivered
 
 FAIL: 03_sysrq_withreboot_pos
         sysrq failed with 256 != 0


[-- Attachment #2: xm-test-add-vmx.patch --]
[-- Type: text/x-patch, Size: 17867 bytes --]

# HG changeset patch
# User stekloff@elm3b216.beaverton.ibm.com
# Node ID de454801bf1c15385b0a47330b0c8fab460d8625
# Parent  b215584242c43415eccd008b90c812f3d04b398d

Add initial VMX support to xm-test:

1) Added script create_disk_image to make full virt image
2) Changed XenDomain.py to build separate XmTestDomain object
   for vmx guests (this structure will need to be cleaned up)
3) Changed ramdisk Makefile.am to create disk.img if vmx configured

Signed-off-by: Daniel Stekloff <dsteklof@us.ibm.com>

diff -r b215584242c4 -r de454801bf1c tools/xm-test/configure.ac
--- a/tools/xm-test/configure.ac	Wed Dec  7 16:26:07 2005
+++ b/tools/xm-test/configure.ac	Wed Dec  7 21:18:31 2005
@@ -15,13 +15,14 @@
 TENV="PYTHONPATH=$PYTHONPATH:$TESTLIB:/usr/lib/python RD_PATH=$RD_PATH"
 
 AC_ARG_ENABLE(vmx-support,
-	[[  --enable-vmx-support           use block devices instead of ramdisks]],
+	[[  --enable-vmx-support           enable hardware virtual machine assist]],
 	[
 		ENABLE_VMX=True
 	],[
 		ENABLE_VMX=False
 	])
 
+AM_CONDITIONAL(VMX, test x$ENABLE_VMX = xTrue)
 AC_SUBST(ENABLE_VMX)
 
 AC_SUBST(TENV)
diff -r b215584242c4 -r de454801bf1c tools/xm-test/lib/XmTestLib/XenDomain.py
--- a/tools/xm-test/lib/XmTestLib/XenDomain.py	Wed Dec  7 16:26:07 2005
+++ b/tools/xm-test/lib/XmTestLib/XenDomain.py	Wed Dec  7 21:18:31 2005
@@ -23,13 +23,18 @@
 import os
 import re
 import time
-import random
 
 from Xm import *
 from Test import *
 from config import *
 
-BLOCK_ROOT_DEV = "hdd1"
+BLOCK_ROOT_DEV = "hda"
+
+def XmTestDomain(name=None, extraOpts=None, config="/dev/null"):
+    if ENABLE_VMX_SUPPORT:
+        return XmTestVmxDomain(name, extraOpts, config)
+    else:
+        return XmTestPvDomain(name, extraOpts, config)
 
 def getDefaultKernel():
     dom0Ver = commands.getoutput("uname -r");
@@ -77,77 +82,8 @@
             c += " %s=%s" % (k, self.opts[k])
         
         return c
-        
-    def start(self):
-
-        if self.configVals:
-            self.__writeConfig("/tmp/xm-test.conf")
-            self.config = "/tmp/xm-test.conf"
-
-        commandLine = self.__buildCmdLine()
-
-        ret, output = traceCommand(commandLine);
-
-        try:
-            self.domID = self.getId()
-        except:
-            self.domID = -1;
-
-        if ret != 0:
-            raise DomainError("Failed to create domain",
-                              extra=output,
-                              errorcode=ret)
-
-    def stop(self):
-        prog = "xm";
-        cmd = " shutdown ";
-
-        ret, output = traceCommand(prog + cmd + self.opts["name"]);
-
-        return ret;
-
-    def destroy(self):
-        prog = "xm";
-        cmd = " destroy ";
-
-        ret, output = traceCommand(prog + cmd + self.opts["name"]);
-
-        return ret;
-
-    def getName(self):
-        return self.opts["name"];
-
-    def getId(self):
-        return domid(self.getName());
-
-    def configSetVar(self, key, value):
-        if not self.configVals:
-            self.configVals = {}
-
-        self.configVals[key] = value
-
-    def configAddDisk(self, pdev, vdev, acc):
-        if not self.configVals:
-            self.configVals = {}
-
-        if not self.configVals.has_key("disk"):
-            self.configVals["disk"] = []
-
-        self.configVals["disk"].append("%s,%s,%s" % (pdev,vdev,acc))
-
-    def __writeConfig(self, configFileName):
-
-        conf = file(configFileName, "w")
-
-        for k,v in self.configVals.items():
-            print >>conf, "%s = %s" % (k, v)
-
-        conf.close()
-
-
-class XmTestDomain(XenDomain):
-
-    def __getUniqueName(self):
+
+    def getUniqueName(self):
         #
         # We avoid multiple duplicate names
         # here because they stick around in xend
@@ -161,29 +97,162 @@
 
         return name
 
-    def __randomize(self):
-        # Random amount of memory between min and free_memory/2
-        freeMem = int(getInfo("free_memory"))
-        self.defaults["memory"] = random.randint(self.minSafeMem(),
-                                                 freeMem/2)
-        
-        self.defaults["vcpus"] = random.randint(1, 16)
-
-        self.defaults["nics"] = random.randint(0, 8)
-
-        if verbose:
-            print "*** Defaults after randomization:"
-            for k in self.defaults.keys():
-                print "***  %10s : %s" % (k, self.defaults[k])
+    def start(self):
+
+        if self.configVals:
+            self.__writeConfig("/tmp/xm-test.conf")
+            self.config = "/tmp/xm-test.conf"
+
+        commandLine = self.__buildCmdLine()
+
+        ret, output = traceCommand(commandLine);
+
+        try:
+            self.domID = self.getId()
+        except:
+            self.domID = -1;
+
+        if ret != 0:
+            raise DomainError("Failed to create domain",
+                              extra=output,
+                              errorcode=ret)
+
+    def stop(self):
+        prog = "xm";
+        cmd = " shutdown ";
+
+        ret, output = traceCommand(prog + cmd + self.opts["name"]);
+
+        return ret;
+
+    def destroy(self):
+        prog = "xm";
+        cmd = " destroy ";
+
+        ret, output = traceCommand(prog + cmd + self.opts["name"]);
+
+        return ret;
+
+    def getName(self):
+        return self.opts["name"];
+
+    def getId(self):
+        return domid(self.getName());
+
+    def configSetVar(self, key, value):
+        if not self.configVals:
+            self.configVals = {}
+
+        self.configVals[key] = value
+
+    def configAddDisk(self, pdev, vdev, acc):
+        if not self.configVals:
+            self.configVals = {}
+
+        if not self.configVals.has_key("disk"):
+            self.configVals["disk"] = []
+
+        self.configVals["disk"].append("%s,%s,%s" % (pdev,vdev,acc))
+
+    def configAddVif(self, type, mac, bridge):
+        if not self.configVals:
+            self.configVals = {}
+
+        if not self.configVals.has_key("vif"):
+            self.configVals["vif"] = []
+
+        if mac:
+            self.configVals["vif"].append("%s,%s,%s" % (type,mac,bridge))
+        else:
+            self.configVals["vif"].append("%s,%s" % (type,bridge))
+
+    def __writeConfig(self, configFileName):
+
+        conf = file(configFileName, "w")
+
+        for k,v in self.configVals.items():
+            print >>conf, "%s = %s" % (k, v)
+
+        conf.close()
+
+class XmTestVmxDomain(XenDomain):
 
     def __prepareBlockRoot(self, rdpath):
-        image = os.path.abspath(rdpath + "/initrd.img")
-        self.configAddDisk("file:%s" % image, BLOCK_ROOT_DEV, "w")
-        self.defaults["root"] = "/dev/%s" % BLOCK_ROOT_DEV
-        del self.defaults["ramdisk"]
-
-    def __init__(self, name=None, extraOpts=None, config="/dev/null",
-                 random=False):
+        image = os.path.abspath(rdpath + "/disk.img")
+        self.configAddDisk("file:%s" % image, "ioemu:%s" % BLOCK_ROOT_DEV, "w")
+
+    def __prepareVif(self):
+        self.configAddVif("type=ioemu", None, "bridge=xenbr0")
+
+    def __prepareDeviceModel(self):
+        arch = os.uname()[4]
+        if re.search('64', arch):
+            self.configSetVar("device_model", "\"/usr/lib64/xen/bin/qemu-dm\"")
+        else:
+            self.configSetVar("device_model", "\"/usr/lib/xen/bin/qemu-dm\"")
+
+    def __init__(self, name=None, extraOpts=None, config="/dev/null"):
+
+        rdpath = os.environ.get("RD_PATH")
+        if not rdpath:
+            rdpath = "../../ramdisk"
+
+        self.opts = {}
+        self.configVals = {}
+
+        # Defaults
+        self.defaults = {"memory"    : 64,
+                         "vcpus"     : 1,
+                         "nics"      : 0,
+                         "kernel"    : "/usr/lib/xen/boot/vmxloader",
+                         "builder"   : "\'vmx\'",
+                         "name"      : name or self.getUniqueName()
+                         }
+
+        self.domID = None;
+        self.config = config;
+
+        self.__prepareBlockRoot(rdpath)
+	#self.__prepareVif()
+        self.__prepareDeviceModel()
+        #self.configSetVar("boot","\'c\'")
+        self.configSetVar("sdl","0")
+        self.configSetVar("vnc","0")
+        self.configSetVar("vncviewer","0")
+        self.configSetVar("nographic","1")
+        self.configSetVar("serial","\'pty\'")
+
+        # Copy over defaults
+        for key in self.defaults.keys():
+            self.opts[key] = self.defaults[key]
+
+        # Merge in extra options
+        if extraOpts:
+            for key in extraOpts.keys():
+                self.opts[key] = extraOpts[key]
+
+    def start(self):
+        """We know how about how long everyone will need to wait
+        for our disk image to come up, so we do it here as a convenience"""
+
+#        for i in range(0,5):
+#            status, output = traceCommand("xm list")
+
+        XenDomain.start(self)
+        waitForBoot()
+
+    def startNow(self):
+        XenDomain.start(self)
+
+    def getMem(self):
+        return int(self.opts["memory"])
+
+    def minSafeMem(self):
+        return 16
+
+class XmTestPvDomain(XenDomain):
+
+    def __init__(self, name=None, extraOpts=None, config="/dev/null"):
 
         rdpath = os.environ.get("RD_PATH")
         if not rdpath:
@@ -198,19 +267,13 @@
                          "nics"    : 0,
                          "kernel"  : getDefaultKernel(),
                          "root"    : "/dev/ram0",
-                         "name"    : name or self.__getUniqueName(),
+                         "name"    : name or self.getUniqueName(),
                          "ramdisk" : rdpath + "/initrd.img"
                          }
 
         self.domID = None;
         self.config = config;
 
-        if random:
-            self.__randomize()
-
-        if USE_BLKDEV_FOR_ROOT:
-            self.__prepareBlockRoot(rdpath)
-        
         # Copy over defaults
         for key in self.defaults.keys():
             self.opts[key] = self.defaults[key]
diff -r b215584242c4 -r de454801bf1c tools/xm-test/lib/XmTestLib/config.py.in
--- a/tools/xm-test/lib/XmTestLib/config.py.in	Wed Dec  7 16:26:07 2005
+++ b/tools/xm-test/lib/XmTestLib/config.py.in	Wed Dec  7 21:18:31 2005
@@ -1,4 +1,4 @@
 #!/usr/bin/python
 
-USE_BLKDEV_FOR_ROOT = @ENABLE_VMX@
+ENABLE_VMX_SUPPORT = @ENABLE_VMX@
 
diff -r b215584242c4 -r de454801bf1c tools/xm-test/ramdisk/Makefile.am
--- a/tools/xm-test/ramdisk/Makefile.am	Wed Dec  7 16:26:07 2005
+++ b/tools/xm-test/ramdisk/Makefile.am	Wed Dec  7 21:18:31 2005
@@ -9,10 +9,16 @@
 
 BR_ROOT = build_i386/root
 
+VMX_SCRIPT = bin/create_disk_image
+
 XMTEST_MAJ_VER = $(shell echo @PACKAGE_VERSION@ | perl -pe 's/(\d+)\.(\d+)\.\d+/\1.\2/')
 XMTEST_VER_IMG = initrd-$(XMTEST_MAJ_VER).img
 
+if VMX
+all: initrd.img disk.img
+else
 all: initrd.img
+endif
 
 $(BR_TAR):
 	wget $(BR_URL)
@@ -37,6 +43,10 @@
 initrd.img: $(XMTEST_VER_IMG)
 	ln -sf $(XMTEST_VER_IMG) initrd.img
 
+disk.img: $(XMTEST_VER_IMG)
+	chmod a+x $(VMX_SCRIPT)
+	$(VMX_SCRIPT) -r $(XMTEST_VER_IMG) -i disk.img
+
 existing:
 	@[ -f $(XMTEST_VER_IMG) ] && ln -sf $(XMTEST_VER_IMG) initrd.img || \
 	echo Error, $(XMTEST_VER_IMG) not found
@@ -49,3 +59,4 @@
 	rm -f initrd.img
 	rm -f $(BR_TAR)
 	rm -Rf patches make.d
+	rm -f disk.img
diff -r b215584242c4 -r de454801bf1c tools/xm-test/tests/block-list/04_block-list_nodb_pos.py
--- a/tools/xm-test/tests/block-list/04_block-list_nodb_pos.py	Wed Dec  7 16:26:07 2005
+++ b/tools/xm-test/tests/block-list/04_block-list_nodb_pos.py	Wed Dec  7 21:18:31 2005
@@ -21,7 +21,7 @@
 if status != 0:
     FAIL("xm block-list returned bad status, expected 0, status is %i" % status)
 
-if USE_BLKDEV_FOR_ROOT:
+if ENABLE_VMX_SUPPORT:
     SKIP("Using block device for root, so this case does not apply")
 
 if output != "":
diff -r b215584242c4 -r de454801bf1c tools/xm-test/ramdisk/bin/create_disk_image
--- /dev/null	Wed Dec  7 16:26:07 2005
+++ b/tools/xm-test/ramdisk/bin/create_disk_image	Wed Dec  7 21:18:31 2005
@@ -0,0 +1,317 @@
+#!/bin/bash
+###############################################################################
+##
+##  Copyright (C) International Business Machines  Corp., 2005
+##  Author(s):  Daniel Stekloff <dsteklof@us.ibm.com>
+##
+##  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; under version 2 of the License.
+##
+##  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+##
+###############################################################################
+function cleanup()
+{
+	if [ "$LOOPD" ]; then
+		losetup -d $LOOPD
+	fi
+	if [ "$LOOPP" ]; then
+		losetup -d $LOOPP
+	fi
+	if  [ -e "$IMAGE" ]; then
+		rm -f "$IMAGE"
+	fi
+	if  [ -e "$LCONF" ]; then
+		rm -f "$LCONF"
+	fi
+}
+
+function die()
+{
+	cleanup
+	echo "$@"
+	exit 1
+}
+
+function usage()
+{
+	cat << EOU
+Command creates a vmx guest disk image for xm-test. 
+
+Usage: $0 [OPTIONS]
+
+OPTIONS:
+    -i|--image <name>        Image name to create.
+    -k|--kernel <name>       Kernel name to use for disk image.
+    -r|--rootfs <image>      Rootfs image to use for disk image.
+
+EOU
+}
+
+function check_dependencies()
+{
+	which lilo > /dev/null 2>&1
+	if [ $? -ne 0 ]; then
+		die "$PROGNAME requires lilo version 22.7+ to be installed."
+	fi
+	local pass="$( lilo -V | cut -f3 -d " " | awk -F "." '
+		{
+			if ($1 >= 22 && $2 >= 7)
+				print "true"
+			else
+				print "false"
+		}')"
+	if [ $pass = "false" ]; then
+		die "$PROGNAME requires lilo version 22.7+ to be installed."
+	fi
+}
+
+function initialize_globals()
+{
+	PROGNAME="create_disk_image"
+	IMAGE="hvm.img"
+	KERNEL=""
+	LCONF="lilo.conf"
+	LOOPD=""    # Loop device for entire disk image
+	LOOPP=""    # Loop device for ext partition
+	ROOTFS=""
+	MNT="/tmp/$PROGNAME-mnt"
+	SIZE=8192
+	SECTORS=32
+	HEADS=8
+	CYLINDERS=$(($SIZE/$SECTORS/$HEADS*2))
+	BSIZE=$(($SIZE-$SECTORS))
+	OFFSET=$(($SECTORS*512))
+}
+
+function get_options()
+{
+	while [ $# -gt 0 ]; do
+		case $1 in
+			-i|--image)
+				shift
+				IMAGE=${1}
+				shift
+				;;
+			-k|--kernel)
+				shift
+				KERNEL=${1}
+				shift
+				;;
+			-r|--rootfs)
+				shift
+				ROOTFS=${1}
+				shift
+				;;
+			*)
+				usage
+				exit 1
+				;;
+		esac
+	done
+}
+
+function get_loopd()
+{
+	local loop
+
+	for i in `seq 0 7`; do
+		losetup /dev/loop$i > /dev/null 2>&1
+		if [ $? -ne 0 ]; then
+			# found one
+			echo $i
+			return 0
+		fi
+	done
+	die "No free loopback devices."
+}
+
+function losetup_image()
+{
+	local loop=$1
+	shift
+
+	# If offset, then associate with it
+	if [ $# -eq 1 ]; then
+		losetup -o $1 $loop $IMAGE
+	else
+		losetup $loop $IMAGE
+	fi
+
+	if [ $? -ne 0 ]; then
+		die "Failed to losetup $IMAGE to $loop."
+	fi
+
+	echo "Associated $IMAGE with $loop"
+}
+
+function create_disk_image()
+{
+	dd bs=1024 count=$SIZE of=$IMAGE if=/dev/zero
+
+	fdisk -b 512 -C $CYLINDERS -H $HEADS -S $SECTORS "$IMAGE" > /dev/null 2>&1 << EOF
+n
+p
+1
+1
+
+a
+1
+w
+EOF
+}
+
+function makefs_image()
+{
+	mke2fs -N 24 -b 1024 $LOOPP $BSIZE
+
+	if [ $? -ne 0 ]; then
+		die "mke2fs $LOOPP failed."
+	fi
+}
+
+function dd_rootfs_to_image()
+{
+	if [ ! "$ROOTFS" ]; then
+		die "Must specify rootfs image to use."
+	fi
+
+	dd if="$ROOTFS" of="$LOOPP" > /dev/null 2>&1
+	if [ $? -ne 0 ]; then
+		die "Failed to dd $ROOTFS to $LOOPP."
+	fi
+}
+
+function get_kernel()
+{
+	# look in /boot for an existing kernel
+	local -a kernels=( `ls /boot | grep vmlinuz` )
+	local k
+
+	for k in ${kernels[@]}; do
+		case "$k" in
+			*xen*)
+				continue
+				;;
+			*)
+				KERNEL="/boot/$k"
+				echo "Using kernel $KERNEL"
+				break
+				;;
+		esac
+	done
+}
+
+function copy_kernel_to_image()
+{
+	if [ ! "$KERNEL" ]; then
+		get_kernel || die "Couldn't find a kernel to use."
+	fi
+
+	mkdir "$MNT/boot"
+
+	cp "$KERNEL" "$MNT/boot"
+}
+
+function lilo_image()
+{
+	local kernel=`basename $KERNEL`
+
+	(
+	cat <<EOC
+boot=$LOOPD
+delay=10
+geometric
+map=$MNT/boot/map
+disk=$LOOPD
+        bios=0x80
+        sectors=$SECTORS
+        heads=$HEADS
+        cylinders=$CYLINDERS
+        partition=$LOOPP
+                start=$SECTORS
+image=$MNT/boot/$kernel
+	append="root=0301 console=tty0 console=ttyS0"
+#	append="root=0301"
+        label=Linux
+        read-only
+EOC
+	) > "/$MNT/boot/$LCONF"
+}
+
+function install_lilo()
+{
+	lilo -C "$MNT/boot/$LCONF"
+	if [ $? -ne 0 ]; then
+		die "Failed to install $MNT/boot/$LCONF."
+	fi
+}
+
+function add_getty_to_inittab()
+{
+	local itab=$MNT/etc/inittab
+
+	if [ -e "$itab" ]; then
+		echo "# Start getty on serial line" >> $itab
+		echo "S0:12345:respawn:/sbin/getty ttyS0" >> $itab
+	fi
+}
+
+
+# Main starts here
+initialize_globals
+check_dependencies
+
+get_options "$@"
+
+create_disk_image
+
+# Get the first free loop device
+ldev=$(get_loopd)
+LOOPD="/dev/loop$ldev"
+losetup_image $LOOPD
+
+# Now associate where the partition will go
+ldev=$(get_loopd)
+LOOPP="/dev/loop$ldev"
+losetup_image $LOOPP $OFFSET
+
+makefs_image
+
+dd_rootfs_to_image
+
+if [ -e "$MNT" ]; then
+	rm -Rf "$MNT"
+fi
+
+mkdir "$MNT";
+if [ $? -ne 0 ]; then
+	die "Failed to create temporary mount point $MNT."
+fi
+
+mount "$LOOPP" "$MNT";
+if [ $? -ne 0 ]; then
+	die "Failed to mount $LOOPP on $MNT."
+fi
+
+copy_kernel_to_image
+#add_getty_to_inittab
+
+lilo_image
+install_lilo
+
+umount "$MNT"
+rm -Rf "$MNT";
+
+losetup -d $LOOPD
+losetup -d $LOOPP
+
+exit 0

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 2%]

* RE: [PATCH] Arch-neutral balloon driver
@ 2005-12-07 23:05  0% Magenheimer, Dan (HP Labs Fort Collins)
  0 siblings, 0 replies; 200+ results
From: Magenheimer, Dan (HP Labs Fort Collins) @ 2005-12-07 23:05 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: Xen Mailing List

> > +	if (xen_init() < 0)
> > +		return -1;
> > +
> 
> I had some suggestions to obviate this "xen_init()" stuff; 
> you can read them again at  
> http://lists.xensource.com/archives/html/xen-devel/2005-09/ 
> msg00881.html . I see that xen_init() was introduced anyways, but I  
> would not like to see it spread. Instead let's correct the 
> problem it's working around.

While I'm sympathetic to your argument, I'd prefer for xen_init
to be replaced at some point in the future when more major
surgery is done on the drivers.  In the meantime, it has the
advantage that:

1) It has zero impact on Xen/x86.
2) It serves two purposes on Xen/ia64:
   a) ensures that certain xen driver init routines execute
      before other xen driver init routines
   b) returns a no-impact failure if called on a kernel that
      is not running on Xen (is running on bare metal)

It could be argued that we are now "post-3.0", but these are
really just minor cleanups on (pre-)3.0 drivers to get networking
working on Xen/ia64, preferably on 3.0.x.  So I'll be submitting
a patch to add it to netback also.

> > +// for drivers/xen/balloon/balloon.c
> 
> C++ comment

Good point.
 
> Other than that this looks ok to me. I think your mailer 
> line-wrapped  
> the patch though.

Stupid Outlook. :-(  Keir, should I resend as an attachment?

Thanks,
Dan

^ permalink raw reply	[relevance 0%]

* RE: [PATCH] Arch-neutral balloon driver
@ 2005-12-08 14:23 21% Magenheimer, Dan (HP Labs Fort Collins)
  0 siblings, 0 replies; 200+ results
From: Magenheimer, Dan (HP Labs Fort Collins) @ 2005-12-08 14:23 UTC (permalink / raw)
  To: Keir Fraser; +Cc: Xen Mailing List

[-- Attachment #1: Type: text/plain, Size: 247 bytes --]

Resending as an attachment... 

> >> Other than that this looks ok to me. I think your mailer
> >> line-wrapped
> >> the patch though.
> >
> > Stupid Outlook. :-(  Keir, should I resend as an attachment?
> 
> Yes please.
> 
>   -- Keir

[-- Attachment #2: balloon.patch --]
[-- Type: application/octet-stream, Size: 4736 bytes --]

diff -r 0255f48b757f linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sun Dec  4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Tue Dec  6 16:25:53 2005
@@ -192,8 +192,8 @@
 		page = balloon_retrieve();
 		BUG_ON(page == NULL);
 
-		pfn = page - mem_map;
-		BUG_ON(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
+		pfn = page_to_pfn(page);
+		BUG_ON(phys_to_machine_mapping_valid(pfn));
 
 		/* Update P->M and M->P tables. */
 		set_phys_to_machine(pfn, mfn_list[i]);
@@ -253,8 +253,8 @@
 			break;
 		}
 
-		pfn = page - mem_map;
-		mfn_list[i] = phys_to_machine_mapping[pfn];
+		pfn = page_to_pfn(page);
+		mfn_list[i] = pfn_to_mfn(pfn);
 
 		if (!PageHighMem(page)) {
 			v = phys_to_virt(pfn << PAGE_SHIFT);
@@ -444,6 +444,9 @@
 
 	IPRINTK("Initialising balloon driver.\n");
 
+	if (xen_init() < 0)
+		return -1;
+
 	current_pages = min(xen_start_info->nr_pages, max_pfn);
 	target_pages  = current_pages;
 	balloon_low   = 0;
@@ -465,7 +468,7 @@
     
 	/* Initialise the balloon with excess memory space. */
 	for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
-		page = &mem_map[pfn];
+		page = pfn_to_page(pfn);
 		if (!PageReserved(page))
 			balloon_append(page);
 	}
diff -r 0255f48b757f linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Sun Dec  4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Tue Dec  6 16:25:53 2005
@@ -65,6 +65,8 @@
 extern unsigned long *phys_to_machine_mapping;
 #define pfn_to_mfn(pfn)	\
 (phys_to_machine_mapping[(unsigned int)(pfn)] & ~(1UL<<31))
+#define	phys_to_machine_mapping_valid(pfn) \
+	(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY)
 static inline unsigned long mfn_to_pfn(unsigned long mfn)
 {
 	unsigned long pfn;
diff -r 0255f48b757f linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h	Sun Dec  4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h	Tue Dec  6 16:25:53 2005
@@ -355,34 +355,27 @@
 #endif
     return 1;
 }
+#endif
 
 static inline int
 HYPERVISOR_update_va_mapping(
     unsigned long va, pte_t new_val, unsigned long flags)
 {
-#if 0
-    int ret;
-    unsigned long ign1, ign2, ign3;
-
-    __asm__ __volatile__ (
-        TRAP_INSTR
-        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
-	: "0" (__HYPERVISOR_update_va_mapping), 
-          "1" (va), "2" ((new_val).pte_low), "3" (flags)
-	: "memory" );
-
-    if ( unlikely(ret < 0) )
-    {
-        printk(KERN_ALERT "Failed update VA mapping: %08lx, %08lx, %08lx\n",
-               va, (new_val).pte_low, flags);
-        BUG();
-    }
-
-    return ret;
-#endif
-    return 1;
-}
-#endif
+    /* no-op */
+    return 1;
+}
+
+static inline int
+HYPERVISOR_memory_op(
+    unsigned int cmd, void *arg)
+{
+    int ret;
+    __asm__ __volatile__ ( ";; mov r14=%2 ; mov r15=%3 ; mov r2=%1 ; break 0x1000 ;; mov %0=r8 ;;"
+        : "=r" (ret)
+        : "i" (__HYPERVISOR_console_io), "r"(cmd), "r"(arg)
+        : "r14","r15","r2","r8","memory" );
+    return ret;
+}
 
 static inline int
 HYPERVISOR_event_channel_op(
diff -r 0255f48b757f linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h	Sun Dec  4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h	Tue Dec  6 16:25:53 2005
@@ -52,4 +52,19 @@
 #define	mfn_to_pfn(x)	(x)
 #define machine_to_phys_mapping 0
 
+// for drivers/xen/balloon/balloon.c
+#ifdef CONFIG_XEN_SCRUB_PAGES
+#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
+#else
+#define scrub_pages(_p,_n) ((void)0)
+#endif
+#define	pte_mfn(_x)	pte_pfn(_x)
+#define INVALID_P2M_ENTRY	(~0UL)
+#define __pte_ma(_x)	((pte_t) {(_x)})
+#define phys_to_machine_mapping_valid(_x)	(1)
+#define	kmap_flush_unused()	do {} while (0)
+#define set_phys_to_machine(_x,_y)	do {} while (0)
+#define xen_machphys_update(_x,_y)	do {} while (0)
+#define pfn_pte_ma(_x,_y)	__pte_ma(0)
+
 #endif /* __HYPERVISOR_H__ */
diff -r 0255f48b757f linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Sun Dec  4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Tue Dec  6 16:25:53 2005
@@ -67,6 +67,8 @@
 extern unsigned long *phys_to_machine_mapping;
 #define pfn_to_mfn(pfn)	\
 (phys_to_machine_mapping[(unsigned int)(pfn)] & ~(1UL << 63))
+#define	phys_to_machine_mapping_valid(pfn) \
+	(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY)
 static inline unsigned long mfn_to_pfn(unsigned long mfn)
 {
 	unsigned long pfn;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 21%]

* RE: Uses of &frame_table[xfn]
@ 2005-12-23 13:05  6% Magenheimer, Dan (HP Labs Fort Collins)
  2005-12-23 15:27  0% ` Ewan Mellor
  0 siblings, 1 reply; 200+ results
From: Magenheimer, Dan (HP Labs Fort Collins) @ 2005-12-23 13:05 UTC (permalink / raw)
  To: Ewan Mellor; +Cc: Xen Mailing List

> > On a related note, I'm not clear on the relationship between
> > the "memory" variable in xmdefconfig and the two reservation
> > variables needed for ballooning (not sure what they are named,
> > but call them max_reservation and initial_reservation).  Which
> > of these latter correspond to "memory" in xmdefconfig and how
> > does the other get determined?
> 
> For unprivileged guests, Xend sets both the maximum and 
> current reservation to
> the configured "memory" value, when a domain is created.  
> Subsequent calls to
> xm mem-set set the current reservation, and leave the maximum 
> alone.  Calls to
> xm mem-max set the maximum (and reducing the maximum without 
> thought is a good
> way to crash your guest).
> 
> For dom0, the initial values are set from the kernel command 
> line, and the
> current reservation is altered if memory is needed for domain 
> creation,
> migration, etc.

Thanks for the reply.  This is starting to make sense.

With the balloon driver still unimplemented, I have seen
messages (from xend?) that /proc/xen/balloon can't be
opened.  This occurs when I try to create a domain such that
the sum of memory of all launched domains (including dom0)
exceeds the total machine memory on the machine.

So when I get this message, is xend trying to balloon memory
from dom0?  Or is this the point where xend(?) tries
to do the xm mem-set to balloon some memory away from a
domU (and, if so, how does it decide which one(s) to steal
memory from)?

Thanks,
Dan

^ permalink raw reply	[relevance 6%]

* Re: Uses of &frame_table[xfn]
  2005-12-23 13:05  6% Uses of &frame_table[xfn] Magenheimer, Dan (HP Labs Fort Collins)
@ 2005-12-23 15:27  0% ` Ewan Mellor
  0 siblings, 0 replies; 200+ results
From: Ewan Mellor @ 2005-12-23 15:27 UTC (permalink / raw)
  To: Magenheimer, Dan (HP Labs Fort Collins); +Cc: Xen Mailing List

On Fri, Dec 23, 2005 at 05:05:29AM -0800, Magenheimer, Dan (HP Labs Fort Collins) wrote:

> > > On a related note, I'm not clear on the relationship between
> > > the "memory" variable in xmdefconfig and the two reservation
> > > variables needed for ballooning (not sure what they are named,
> > > but call them max_reservation and initial_reservation).  Which
> > > of these latter correspond to "memory" in xmdefconfig and how
> > > does the other get determined?
> > 
> > For unprivileged guests, Xend sets both the maximum and 
> > current reservation to
> > the configured "memory" value, when a domain is created.  
> > Subsequent calls to
> > xm mem-set set the current reservation, and leave the maximum 
> > alone.  Calls to
> > xm mem-max set the maximum (and reducing the maximum without 
> > thought is a good
> > way to crash your guest).
> > 
> > For dom0, the initial values are set from the kernel command 
> > line, and the
> > current reservation is altered if memory is needed for domain 
> > creation,
> > migration, etc.
> 
> Thanks for the reply.  This is starting to make sense.
> 
> With the balloon driver still unimplemented, I have seen
> messages (from xend?) that /proc/xen/balloon can't be
> opened.  This occurs when I try to create a domain such that
> the sum of memory of all launched domains (including dom0)
> exceeds the total machine memory on the machine.
> 
> So when I get this message, is xend trying to balloon memory
> from dom0?  Or is this the point where xend(?) tries
> to do the xm mem-set to balloon some memory away from a
> domU (and, if so, how does it decide which one(s) to steal
> memory from)?

The first of those.  It will balloon dom0 down as far as is necessary, stopping 
at dom0-min-mem, as configured in /etc/xen/xend-config.sxp.  You should see
a message in /var/log/xend.log saying "Balloon: need X MB, free Y MB." when it
does this, and it will try to balloon dom0 to release the difference.

Ewan.

^ permalink raw reply	[relevance 0%]

* Re: Guest-visible phys2mach part of Xen arch-neutral API? was: Uses of &frame_table[xfn]
@ 2006-01-04 15:21  5% Magenheimer, Dan (HP Labs Fort Collins)
  2006-01-04 16:25  0% ` Guest-visible phys2mach part of Xen arch-neutral API? was: [Xen-devel] " Hollis Blanchard
  0 siblings, 1 reply; 200+ results
From: Magenheimer, Dan (HP Labs Fort Collins) @ 2006-01-04 15:21 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: xen-devel

Has Xen/ppc tried to implement the Xen balloon or network
drivers yet?  There appear to be a lot of dependencies
in there on a guest-aware p2m table.

Thanks,
Dan

>From: Hollis Blanchard <hollisb@us.ibm.com>
Subject: Re: Guest-visible phys2mach part of Xen arch-neutral API?
	was:	[Xen-devel] Uses of &frame_table[xfn]
To: xen-devel@lists.xensource.com
Cc: Jimi Xenidis <jimix@watson.ibm.com>
Message-ID: <200601031555.20229.hollisb@us.ibm.com>
Content-Type: text/plain;  charset="iso-8859-1"

On Friday 30 December 2005 13:50, Magenheimer, Dan (HP Labs Fort
Collins) 
wrote:
>
> I think there are two critical questions that are very highly
> related.  To me, the critical question is how many changes
> to a guest are required to run on Xen.  I've argued for a long
> time that paravirtualization changes should be minimized/optimized
> to only those that are absolutely necessary for functionality
> and performance.   DMA-capable domains require either p==m
> or non-trivial changes to the guest.  On x86, non-trivial changes
> to the guest are necessary anyway due to the x86 memory architecture
> so p!=m comes "for free".  This is not necessarily the case
> for non-x86 Xen machines.

For the record, the PowerPC port is not currently using a p2m table in
dom0 
(or any domain for that matter). We are still using the PAPR interface
(IBM's 
enterprise hypervisor ABI) for memory management.

Using Xen terminology, that interface says that domains pass only
physical 
addresses to the hypervisor, and the hypervisor performs the physical to

machine translation.

I think we're not looking to diverge from this interface unless we
absolutely 
have to, and so far (given the maturity of the PPC port) we haven't had
to.

-- 
Hollis Blanchard
IBM Linux Technology Center

^ permalink raw reply	[relevance 5%]

* Re: Guest-visible phys2mach part of Xen arch-neutral API? was: [Xen-devel] Uses of &frame_table[xfn]
  2006-01-04 15:21  5% Guest-visible phys2mach part of Xen arch-neutral API? was: " Magenheimer, Dan (HP Labs Fort Collins)
@ 2006-01-04 16:25  0% ` Hollis Blanchard
  0 siblings, 0 replies; 200+ results
From: Hollis Blanchard @ 2006-01-04 16:25 UTC (permalink / raw)
  To: Magenheimer, Dan (HP Labs Fort Collins); +Cc: xen-devel

On Wednesday 04 January 2006 09:21, Magenheimer, Dan (HP Labs Fort Collins) 
wrote:
> Has Xen/ppc tried to implement the Xen balloon or network
> drivers yet?  There appear to be a lot of dependencies
> in there on a guest-aware p2m table.

Nope, not yet.

-- 
Hollis Blanchard
IBM Linux Technology Center

^ permalink raw reply	[relevance 0%]

* xm-test status report changset 8602:cfa3b96b056d on IA64
@ 2006-01-30  3:38  4% Matsumoto
  2006-01-30  4:44  0% ` Matsumoto
  0 siblings, 1 reply; 200+ results
From: Matsumoto @ 2006-01-30  3:38 UTC (permalink / raw)
  To: xen-devel

Hi, all

I'm trying xm-test on IA64. However, I do not carry out some tests.

test which I did not carry out:
  06_create_mem_neg
  07_create_mem64_pos
  10_create_fastdestroy
  11_create_concurrent_pos
  12_create_concurrent_stress_pos
  15_create_smallmem_pos
  07_destroy_stale_pos

TEST ENVIRONMENT
  Machine          : Tiger4
  Release          : 2.6.12.6-xen0
  Changeset        : 8602:cfa3b96b056d
  Dom0 OS          : RHEL4 U2 (no SMP)
  DomU memory      : 96MB

Xm-test execution summary:
  PASS:  64
  FAIL:  28
  XPASS: 0
  XFAIL: 3


Details:

 FAIL: 01_block_attach_device_pos 
	 Device is not actually connected to the domU

 FAIL: 02_block_attach_file_device_pos 
	 Device is not actually connected to the domU

 FAIL: 04_block_attach_device_repeatedly_pos 
	 xm block attach returned invalid 256 != 0

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 File created was lost or not updated!

 FAIL: 11_block_attach_shared_dom0 
	 Bug #331 Started a DomU with write access to a rw mounted block device

 FAIL: 12_block_attach_shared_domU 
	 Bug #331 Started a DomU with write access to an in-use block device

 FAIL: 01_block-list_pos 
	 Fail to list block device

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

 FAIL: 04_create_conflictname_neg 
	 xm create let me create a duplicate-named domain!

 FAIL: 13_create_multinic_pos 
	 (1 nics) Console didn't respond probably crashed!

 FAIL: 14_create_blockroot_pos 
	 Timed out waiting for console

 FAIL: 01_memset_basic_pos 
	 The DomU command 'cat /proc/xen/balloon' failed.

 FAIL: 03_memset_random_pos 
	 Invalid domU meminfo line

XFAIL: 02_network_local_ping_pos 
	 Timed out waiting for console

XFAIL: 05_network_dom0_ping_pos 
	 Timed out waiting for console

XFAIL: 11_network_domU_ping_pos 
	 Timed out waiting for console

 FAIL: 01_network_attach_pos 
	 xm network-attach returned invalid 256 != 0

 FAIL: 02_network_attach_detach_pos 
	 xm network-attach returned invalid 256 != 0

 FAIL: 03_network_attach_detach_multiple_pos 
	 xm network-attach returned invalid 256 != 0

 FAIL: 01_sedf_multi_pos 
	 [0] xm sedf returned invalid 256 != 0

 FAIL: 01_shutdown_basic_pos 
	 Guest domain failed to shutdown

 FAIL: 02_sysrq_sync_pos 
	 Sync SysRq not delivered

 FAIL: 03_sysrq_withreboot_pos 
	 [Errno 5] Input/output error

 FAIL: 01_save_basic_pos 
	 save command exited 256 != 0

 FAIL: 01_restore_basic_pos 
	 save command exited 256 != 0

 FAIL: 04_restore_withdevices_pos 
	 Timed out waiting for console

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0

Best Regards,

Matsumoto

^ permalink raw reply	[relevance 4%]

* Re: xm-test status report changset 8602:cfa3b96b056d on IA64
  2006-01-30  3:38  4% xm-test status report changset 8602:cfa3b96b056d on IA64 Matsumoto
@ 2006-01-30  4:44  0% ` Matsumoto
  0 siblings, 0 replies; 200+ results
From: Matsumoto @ 2006-01-30  4:44 UTC (permalink / raw)
  To: xen-devel

This xm-test report is a test for the quality assurance on ia64.

On Mon, 30 Jan 2006 12:38:47 +0900
Matsumoto <n_matumoto@soft.fujitsu.com> wrote:

> Hi, all
> 
> I'm trying xm-test on IA64. However, I do not carry out some tests.
> 
> test which I did not carry out:
>   06_create_mem_neg
>   07_create_mem64_pos
>   10_create_fastdestroy
>   11_create_concurrent_pos
>   12_create_concurrent_stress_pos
>   15_create_smallmem_pos
>   07_destroy_stale_pos
> 
> TEST ENVIRONMENT
>   Machine          : Tiger4
>   Release          : 2.6.12.6-xen0
>   Changeset        : 8602:cfa3b96b056d
>   Dom0 OS          : RHEL4 U2 (no SMP)
>   DomU memory      : 96MB
> 
> Xm-test execution summary:
>   PASS:  64
>   FAIL:  28
>   XPASS: 0
>   XFAIL: 3
> 
> 
> Details:
> 
>  FAIL: 01_block_attach_device_pos 
> 	 Device is not actually connected to the domU
> 
>  FAIL: 02_block_attach_file_device_pos 
> 	 Device is not actually connected to the domU
> 
>  FAIL: 04_block_attach_device_repeatedly_pos 
> 	 xm block attach returned invalid 256 != 0
> 
>  FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
> 	 Failed to attach block device /proc/partitions does not show that!
> 
>  FAIL: 09_block_attach_and_dettach_device_check_data_pos 
> 	 File created was lost or not updated!
> 
>  FAIL: 11_block_attach_shared_dom0 
> 	 Bug #331 Started a DomU with write access to a rw mounted block device
> 
>  FAIL: 12_block_attach_shared_domU 
> 	 Bug #331 Started a DomU with write access to an in-use block device
> 
>  FAIL: 01_block-list_pos 
> 	 Fail to list block device
> 
>  FAIL: 05_block-destroy_byname_pos 
> 	 block device isn't attached; can't detach!
> 
>  FAIL: 04_create_conflictname_neg 
> 	 xm create let me create a duplicate-named domain!
> 
>  FAIL: 13_create_multinic_pos 
> 	 (1 nics) Console didn't respond probably crashed!
> 
>  FAIL: 14_create_blockroot_pos 
> 	 Timed out waiting for console
> 
>  FAIL: 01_memset_basic_pos 
> 	 The DomU command 'cat /proc/xen/balloon' failed.
> 
>  FAIL: 03_memset_random_pos 
> 	 Invalid domU meminfo line
> 
> XFAIL: 02_network_local_ping_pos 
> 	 Timed out waiting for console
> 
> XFAIL: 05_network_dom0_ping_pos 
> 	 Timed out waiting for console
> 
> XFAIL: 11_network_domU_ping_pos 
> 	 Timed out waiting for console
> 
>  FAIL: 01_network_attach_pos 
> 	 xm network-attach returned invalid 256 != 0
> 
>  FAIL: 02_network_attach_detach_pos 
> 	 xm network-attach returned invalid 256 != 0
> 
>  FAIL: 03_network_attach_detach_multiple_pos 
> 	 xm network-attach returned invalid 256 != 0
> 
>  FAIL: 01_sedf_multi_pos 
> 	 [0] xm sedf returned invalid 256 != 0
> 
>  FAIL: 01_shutdown_basic_pos 
> 	 Guest domain failed to shutdown
> 
>  FAIL: 02_sysrq_sync_pos 
> 	 Sync SysRq not delivered
> 
>  FAIL: 03_sysrq_withreboot_pos 
> 	 [Errno 5] Input/output error
> 
>  FAIL: 01_save_basic_pos 
> 	 save command exited 256 != 0
> 
>  FAIL: 01_restore_basic_pos 
> 	 save command exited 256 != 0
> 
>  FAIL: 04_restore_withdevices_pos 
> 	 Timed out waiting for console
> 
>  FAIL: 01_migrate_localhost_pos 
> 	 xm migrate returned invalid 256 != 0
> 
> Best Regards,
> 
> Matsumoto
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

-- 
松本 敦彦 <n_matumoto@soft.fujitsu.com>
富士通(株) 沼津工場B6F 基盤ソ事)第1開発部
TEL:055-924-7280(7551-5363)

^ permalink raw reply	[relevance 0%]

* [PATCH] [TPM] Fixes and cleanup
@ 2006-02-21 15:56  5% Stefan Berger
  0 siblings, 0 replies; 200+ results
From: Stefan Berger @ 2006-02-21 15:56 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 217 bytes --]

The attached patch fixes a recently found problem in tpm.c, moves the
vtpm sysfs entry to /sys/device/platform/tpm_vtpm and adds locking in
the vtpm hotplug script.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com> 

[-- Attachment #2: vtpm.diff --]
[-- Type: text/x-patch, Size: 7635 bytes --]

Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm.c
===================================================================
--- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm.c
+++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm.c
@@ -53,7 +53,7 @@ static void timeout_work(void * ptr)
 
 	down(&chip->buffer_mutex);
 	atomic_set(&chip->data_pending, 0);
-	memset(chip->data_buffer, 0, chip->vendor->buffersize);
+	memset(chip->data_buffer, 0, get_chip_buffersize(chip));
 	up(&chip->buffer_mutex);
 }
 
@@ -352,7 +352,7 @@ int tpm_open(struct inode *inode, struct
 
 	spin_unlock(&driver_lock);
 
-	chip->data_buffer = kmalloc(chip->vendor->buffersize * sizeof(u8), GFP_KERNEL);
+	chip->data_buffer = kmalloc(get_chip_buffersize(chip) * sizeof(u8), GFP_KERNEL);
 	if (chip->data_buffer == NULL) {
 		chip->num_opens--;
 		put_device(chip->dev);
@@ -400,8 +400,8 @@ ssize_t tpm_write(struct file *file, con
 
 	down(&chip->buffer_mutex);
 
-	if (in_size > chip->vendor->buffersize)
-		in_size = chip->vendor->buffersize;
+	if (in_size > get_chip_buffersize(chip))
+		in_size = get_chip_buffersize(chip);
 
 	if (copy_from_user
 	    (chip->data_buffer, (void __user *) buf, in_size)) {
@@ -411,7 +411,7 @@ ssize_t tpm_write(struct file *file, con
 
 	/* atomic tpm command send and result receive */
 	out_size = tpm_transmit(chip, chip->data_buffer, 
-	                        chip->vendor->buffersize);
+	                        get_chip_buffersize(chip));
 
 	atomic_set(&chip->data_pending, out_size);
 	atomic_set(&chip->data_position, 0);
@@ -432,8 +432,6 @@ ssize_t tpm_read(struct file * file, cha
 	int ret_size;
 	int pos, pending = 0;
 
-	del_singleshot_timer_sync(&chip->user_read_timer);
-	flush_scheduled_work();
 	ret_size = atomic_read(&chip->data_pending);
 	if (ret_size > 0) {	/* relay data */
 		if (size < ret_size)
@@ -457,6 +455,7 @@ ssize_t tpm_read(struct file * file, cha
 	if ( ret_size <= 0 || pending == 0 ) {
 		atomic_set( &chip->data_pending, 0 );
 		del_singleshot_timer_sync(&chip->user_read_timer);
+		flush_scheduled_work();
 	}
 
 	return ret_size;
Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm.h
===================================================================
--- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm.h
+++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm.h
@@ -101,6 +101,11 @@ static inline void tpm_write_index(int b
 	outb(value & 0xFF, base+1);
 }
 
+static inline u32 get_chip_buffersize(struct tpm_chip *chip)
+{
+	return chip->vendor->buffersize;
+}
+
 extern int tpm_register_hardware(struct device *,
 				 struct tpm_vendor_specific *);
 extern int tpm_open(struct inode *, struct file *);
Index: xen/xen-unstable.hg/tools/examples/vtpm-common.sh
===================================================================
--- xen.orig/xen-unstable.hg/tools/examples/vtpm-common.sh
+++ xen/xen-unstable.hg/tools/examples/vtpm-common.sh
@@ -173,6 +173,7 @@ function validate_entry () {
 	local vmname=$1
 	local inst=$2
 	local res
+
 	res=`cat $VTPMDB |             \
 	     gawk -vvmname=$vmname     \
 	          -vinst=$inst         \
@@ -238,6 +239,9 @@ function vtpm_create_instance () {
 	local res
 	set +e
 	get_create_reason
+
+	claim_lock vtpmdb
+
 	find_instance $domname
 	res=$?
 	if [ $res -eq 0 ]; then
@@ -262,6 +266,9 @@ function vtpm_create_instance () {
 			vtpm_create $instance
 		fi
 	fi
+
+	release_lock vtpmdb
+
 	if [ "$REASON" == "create" ]; then
 		vtpm_reset $instance
 	elif [ "$REASON" == "resume" ]; then
@@ -292,3 +299,5 @@ function vtpm_remove_instance () {
 	fi
 	set -e
 }
+
+
Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
===================================================================
--- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
+++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
@@ -25,6 +25,7 @@
 #include <xen/tpmfe.h>
 #include <linux/device.h>
 #include <linux/interrupt.h>
+#include <linux/platform_device.h>
 #include "tpm.h"
 
 /* read status bits */
@@ -455,9 +456,7 @@ static struct tpm_vendor_specific tpm_xe
 	.buffersize = 64 * 1024,
 };
 
-static struct device tpm_device = {
-	.bus_id = "vtpm",
-};
+static struct platform_device *pdev;
 
 static struct tpmfe_device tpmfe = {
 	.receive = tpm_recv,
@@ -477,23 +476,22 @@ static int __init init_xen(void)
 	 * driver
 	 */
 	if ((rc = tpm_fe_register_receiver(&tpmfe)) < 0) {
-		return rc;
+		goto err_exit;
 	}
 
 	/*
 	 * Register our device with the system.
 	 */
-	if ((rc = device_register(&tpm_device)) < 0) {
-		tpm_fe_unregister_receiver();
-		return rc;
+	pdev = platform_device_register_simple("tpm_vtpm", -1, NULL, 0);
+	if (IS_ERR(pdev)) {
+		rc = PTR_ERR(pdev);
+		goto err_unreg_fe;
 	}
 
 	tpm_xen.buffersize = tpmfe.max_tx_size;
 
-	if ((rc = tpm_register_hardware(&tpm_device, &tpm_xen)) < 0) {
-		device_unregister(&tpm_device);
-		tpm_fe_unregister_receiver();
-		return rc;
+	if ((rc = tpm_register_hardware(&pdev->dev, &tpm_xen)) < 0) {
+		goto err_unreg_pdev;
 	}
 
 	dataex.current_request = NULL;
@@ -508,13 +506,25 @@ static int __init init_xen(void)
 	disconnect_time = jiffies;
 
 	return 0;
+
+
+err_unreg_pdev:
+	platform_device_unregister(pdev);
+err_unreg_fe:
+	tpm_fe_unregister_receiver();
+
+err_exit:
+	return rc;
 }
 
 static void __exit cleanup_xen(void)
 {
-	tpm_remove_hardware(&tpm_device);
-	device_unregister(&tpm_device);
-	tpm_fe_unregister_receiver();
+	struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
+	if (chip) {
+		tpm_remove_hardware(chip->dev);
+		platform_device_unregister(pdev);
+		tpm_fe_unregister_receiver();
+	}
 }
 
 module_init(init_xen);
Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
===================================================================
--- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
+++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
@@ -66,8 +66,6 @@ static int  packet_read_shmem(struct pac
                               u32 left);
 
 
-#define MAX_PENDING_REQS TPMIF_TX_RING_SIZE
-
 #define MIN(x,y)  (x) < (y) ? (x) : (y)
 
 
@@ -973,8 +971,6 @@ static void processing_timeout(unsigned 
 static void tpm_tx_action(unsigned long unused);
 static DECLARE_TASKLET(tpm_tx_tasklet, tpm_tx_action, 0);
 
-#define MAX_PENDING_REQS TPMIF_TX_RING_SIZE
-
 static struct list_head tpm_schedule_list;
 static spinlock_t tpm_schedule_list_lock;
 
Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
===================================================================
--- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
+++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
@@ -14,9 +14,6 @@
 #include "common.h"
 #include <xen/balloon.h>
 
-#define TPMIF_HASHSZ (2 << 5)
-#define TPMIF_HASH(_d,_h) (((int)(_d)^(int)(_h))&(TPMIF_HASHSZ-1))
-
 static kmem_cache_t *tpmif_cachep;
 int num_frontends = 0;
 
Index: xen/xen-unstable.hg/tools/examples/vtpm
===================================================================
--- xen.orig/xen-unstable.hg/tools/examples/vtpm
+++ xen/xen-unstable.hg/tools/examples/vtpm
@@ -3,6 +3,7 @@
 dir=$(dirname "$0")
 . "$dir/vtpm-common.sh"
 
+vtpm_fatal_error=0
 
 case "$command" in
   add)
@@ -19,5 +20,8 @@ case "$command" in
   ;;
 esac
 
-log debug "Successful vTPM operation '$command'."
-success
+if [ $vtpm_fatal_error -eq 0 ]; then
+	log debug "Successful vTPM operation '$command'."
+	success
+fi
+

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 5%]

* [PATCH] USB split driver
@ 2006-03-01 14:51  3% Harry Butterworth
  0 siblings, 0 replies; 200+ results
From: Harry Butterworth @ 2006-03-01 14:51 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 645 bytes --]

Here's a xenidc free version of the USB split driver patch.  I've tested
this patch against a376bab39768 for x86_32 and x86_64.

Changes since the xenidc based version include:

o - Removed xenidc code.
o - Disabled support for building driver as loadable modules.
o - Changed 'path' configuration parameter such that it now includes the
USB bus number and is the same as the string that appears
in /sys/bus/usb/devices.
o - Implemented save-restore support (works for x86_32; base xen
unstable (without my code) doesn't seem to work for x86_64).
o - Now tested on both x86_64 and x86_32.

Signed-off-by: Harry Butterworth <butterwo@uk.ibm.com>

[-- Attachment #2: usb.patch --]
[-- Type: text/x-patch, Size: 406146 bytes --]

diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/Kconfig
--- a/linux-2.6-xen-sparse/drivers/xen/Kconfig	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig	Wed Mar  1 14:34:28 2006
@@ -132,6 +132,28 @@
 	  a failure. The corresponding domain's channel will be closed.
 	  Say Y if you want this feature.
 
+config XEN_USBDEV_BACKEND
+	bool "USB-device backend driver"
+	select USB
+	default y
+	help
+	  The USB-device backend driver allows the kernel to export USB
+	  devices to USB-device frontend drivers running in other domains.
+	  This is not required for USB device access in domain 0 or any domain
+	  given exclusive control over a USB host controller device at the PCI
+	  level.
+	  Say Y if you want to use this kernel to export a USB device to
+	  another domain running a USB-device frontend driver.
+
+config XEN_USBDEV_BACKEND_TRACE
+	bool "USB-device backend driver tracing"
+	depends on XEN_USBDEV_BACKEND
+	default n
+	help
+	  This option causes the driver to output a continual trace of its
+	  activity.
+	  Say N here unless you are trying to debug the driver.
+
 config XEN_BLKDEV_FRONTEND
 	tristate "Block-device frontend driver"
 	depends on XEN
@@ -168,6 +190,29 @@
 	select TCG_XEN
 	help
 	  The TPM-device frontend driver.
+
+config XEN_USBDEV_FRONTEND
+	bool "USB-device frontend driver"
+	select USB
+	default y
+	help
+	  The USB-device frontend driver allows the kernel to access USB
+	  devices exported by a USB-device backend driver running in another
+	  domain.
+	  This is not required for USB device access in domain 0 or any domain
+	  given exclusive control over a USB host controller device at the PCI
+	  level.
+	  Say Y if you want to use a USB-device backend driver to export a USB
+	  device from another domain to the domain which will run this kernel.
+
+config XEN_USBDEV_FRONTEND_TRACE
+	bool "USB-device frontend driver tracing"
+	depends on XEN_USBDEV_FRONTEND
+	default n
+	help
+	  This option causes the driver to output a continual trace of its
+	  activity.
+	  Say N here unless you are trying to debug the driver.
 
 config XEN_SCRUB_PAGES
 	bool "Scrub memory before freeing it to Xen"
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/Makefile	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/Makefile	Wed Mar  1 14:34:28 2006
@@ -13,10 +13,11 @@
 obj-$(CONFIG_XEN_BLKDEV_BACKEND)	+= blkback/
 obj-$(CONFIG_XEN_NETDEV_BACKEND)	+= netback/
 obj-$(CONFIG_XEN_TPMDEV_BACKEND)	+= tpmback/
+obj-$(CONFIG_XEN_USBDEV_BACKEND)	+= usbback/
 obj-$(CONFIG_XEN_BLKDEV_FRONTEND)	+= blkfront/
 obj-$(CONFIG_XEN_NETDEV_FRONTEND)	+= netfront/
 obj-$(CONFIG_XEN_BLKDEV_TAP)    	+= blktap/
 obj-$(CONFIG_XEN_TPMDEV_FRONTEND)	+= tpmfront/
+obj-$(CONFIG_XEN_USBDEV_FRONTEND)	+= usbfront/
 obj-$(CONFIG_XEN_PCIDEV_BACKEND)	+= pciback/
 obj-$(CONFIG_XEN_PCIDEV_FRONTEND)	+= pcifront/
-
diff -r a376bab39768 -r e187d61f5d77 tools/examples/Makefile
--- a/tools/examples/Makefile	Tue Feb 28 21:57:38 2006
+++ b/tools/examples/Makefile	Wed Mar  1 14:34:28 2006
@@ -26,6 +26,7 @@
 XEN_SCRIPTS += network-nat vif-nat
 XEN_SCRIPTS += block
 XEN_SCRIPTS += block-enbd block-nbd
+XEN_SCRIPTS += usb
 XEN_SCRIPTS += vtpm vtpm-delete
 XEN_SCRIPTS += xen-hotplug-cleanup
 XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh
diff -r a376bab39768 -r e187d61f5d77 tools/examples/xen-backend.agent
--- a/tools/examples/xen-backend.agent	Tue Feb 28 21:57:38 2006
+++ b/tools/examples/xen-backend.agent	Wed Mar  1 14:34:28 2006
@@ -3,6 +3,9 @@
 PATH=/etc/xen/scripts:$PATH
 
 case "$XENBUS_TYPE" in
+  usb)
+    /etc/xen/scripts/usb "$ACTION"
+    ;;
   vbd)
     /etc/xen/scripts/block "$ACTION"
     ;;
diff -r a376bab39768 -r e187d61f5d77 tools/examples/xen-backend.rules
--- a/tools/examples/xen-backend.rules	Tue Feb 28 21:57:38 2006
+++ b/tools/examples/xen-backend.rules	Wed Mar  1 14:34:28 2006
@@ -2,4 +2,6 @@
 SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}"
 SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} online"
 SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="offline", RUN+="$env{script} offline"
+SUBSYSTEM=="xen-backend", KERNEL=="usb*", RUN+="/etc/xen/scripts/usb $env{ACTION}"
 SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/etc/xen/scripts/xen-hotplug-cleanup"
+
diff -r a376bab39768 -r e187d61f5d77 tools/examples/xmexample1
--- a/tools/examples/xmexample1	Tue Feb 28 21:57:38 2006
+++ b/tools/examples/xmexample1	Wed Mar  1 14:34:28 2006
@@ -56,6 +56,13 @@
 # and MODE is r for read-only, w for read-write.
 
 disk = [ 'phy:hda1,hda1,w' ]
+
+#----------------------------------------------------------------------------
+# Define USB devices.
+#
+# Specify the USB device path as it appears in /sys/bus/usb/devices in the
+# backend.  This example exports device 3 on bus 1 and device 2 on bus 2.
+#usb = ['path=1-3','path=2-2']
 
 #----------------------------------------------------------------------------
 # Define to which TPM instance the user domain should communicate.
diff -r a376bab39768 -r e187d61f5d77 tools/python/xen/xend/server/usbif.py
--- a/tools/python/xen/xend/server/usbif.py	Tue Feb 28 21:57:38 2006
+++ b/tools/python/xen/xend/server/usbif.py	Wed Mar  1 14:34:28 2006
@@ -22,8 +22,9 @@
 """Support for virtual USB hubs.
 """
 
+from xen.xend import sxp
+
 from xen.xend.server.DevController import DevController
-
 
 class UsbifController(DevController):
     """USB device interface controller. Handles all USB devices
@@ -35,8 +36,28 @@
         """
         DevController.__init__(self, vm)
 
-
-    def getDeviceDetails(self, _):
+    def getDeviceDetails(self, config):
         """@see DevController.getDeviceDetails"""
 
-        return (self.allocateDeviceID(), {}, {})
+        path = sxp.child_value(config, 'path')
+
+        devid = self.allocateDeviceID()
+
+        back  = { 'path'   : path,
+                  'handle' : "%i" % devid }
+
+        front = { 'handle' : "%i" % devid }
+
+        return (devid, back, front)
+
+    def configuration(self, devid):
+        """@see DevController.configuration"""
+
+        result = DevController.configuration(self, devid)
+
+        path = self.readBackend(devid,'path')
+
+        if path:
+            result.append(['path', path])
+
+        return result
diff -r a376bab39768 -r e187d61f5d77 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py	Tue Feb 28 21:57:38 2006
+++ b/tools/python/xen/xm/create.py	Wed Mar  1 14:34:28 2006
@@ -237,6 +237,10 @@
           fn=set_bool, default=0,
           use="Make the domain a network interface backend.")
 
+gopts.var('usbif', val='no|yes',
+          fn=set_bool, default=0,
+          use="Make the domain a USB device backend.")
+
 gopts.var('tpmif', val='no|yes',
           fn=append_value, default=0,
           use="Make the domain a TPM interface backend.")
@@ -261,10 +265,13 @@
          For example '-ioports 02f8-02ff'.
          The option may be repeated to add more than one i/o range.""")
 
-gopts.var('usb', val='PATH',
+gopts.var('usb', val="path=PATH,backend=DOM",
           fn=append_value, default=[],
-          use="""Add a physical USB port to a domain, as specified by the path
-          to that port.  This option may be repeated to add more than one port.""")
+          use="""Map a backend USB port (specified by the backend PATH in the
+          backend domain DOM) to a single-port virtual host controller device
+          in the domain.
+          If backend is not specified the default backend driver domain is
+          used.  This option may be repeated to add more than one port.""")
 
 gopts.var('vif', val="type=TYPE,mac=MAC,bridge=BRIDGE,ip=IPADDR,script=SCRIPT,backend=DOM,vifname=NAME",
           fn=append_value, default=[],
@@ -489,8 +496,13 @@
         config_devs.append(['device', config_ioports])
 
 def configure_usb(config_devs, vals):
-    for path in vals.usb:
-        config_usb = ['usb', ['path', path]]
+    for d in vals.usb:
+        path    = d.get('path')
+        backend = d.get('backend')
+        config_usb = ['usb']
+        config_usb.append(['path', path])
+        if backend:
+            config_usb.append(['backend', backend])
         config_devs.append(['device', config_usb])
 
 def configure_vtpm(config_devs, vals):
@@ -601,6 +613,8 @@
         config.append(['backend', ['blkif']])
     if vals.netif:
         config.append(['backend', ['netif']])
+    if vals.usbif:
+        config.append(['backend', ['usbif']])
     if vals.tpmif:
         config.append(['backend', ['tpmif']])
 
@@ -670,6 +684,22 @@
         ioports.append(hexd)
     vals.ioports = ioports
         
+def preprocess_usb(vals):
+    if not vals.usb: return
+    usb = []
+    for port in vals.usb:
+        d = {}
+        a = port.split(',')
+        for b in a:
+            (k, v) = b.strip().split('=', 1)
+            k = k.strip()
+            v = v.strip()
+            if k not in ['path', 'backend']:
+                err('Invalid usb port specifier: ' + port)
+            d[k] = v
+        usb.append(d)
+    vals.usb = usb
+
 def preprocess_vtpm(vals):
     if not vals.vtpm: return
     vtpms = []
@@ -773,6 +803,7 @@
     preprocess_ioports(vals)
     preprocess_ip(vals)
     preprocess_nfs(vals)
+    preprocess_usb(vals)
     preprocess_vnc(vals)
     preprocess_vtpm(vals)
 
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/Makefile
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/Makefile	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,11 @@
+obj-y = \
+usbback_buffer_resource_provider.o \
+usbback_callback.o                 \
+usbback_device.o                   \
+usbback_gw.o                       \
+usbback_gw_resource.o              \
+usbback_rbr_mapper_pool.o          \
+usbback_resource.o                 \
+usbback_ring_channel.o             \
+usbback_work.o                     \
+usbback_xb_channel.o
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_buffer_resource_provider.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_buffer_resource_provider.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,196 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+/*****************************************************************************/
+/* Based on                                                                  */
+/*                                                                           */
+/* arch/xen/drivers/blkback/blkback.c                                        */
+/*                                                                           */
+/* original copyright notice follows...                                      */
+/*****************************************************************************/
+/******************************************************************************
+ * arch/xen/drivers/blkif/backend/main.c
+ * 
+ * Back-end of the driver for virtual block devices. This portion of the
+ * driver exports a 'unified' block-device interface that can be accessed
+ * by any operating system that implements a compatible front end. A 
+ * reference front-end implementation can be found in:
+ *  arch/xen/drivers/blkif/frontend
+ * 
+ * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
+ * Copyright (c) 2005, Christopher Clark
+ */
+
+#include <linux/spinlock.h>
+#include <linux/errno.h>
+#include <linux/gfp.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <asm/pgalloc.h>
+#include <xen/balloon.h>
+#include <xen/driver_util.h>
+#include "usbback_buffer_resource_provider.h"
+#include "usbback_trace.h"
+
+struct usbback_buffer_rsrc_provider {
+	spinlock_t                       lock;
+	struct usbback_buffer_rsrc_list  rsrcs;
+	struct usbback_buffer_rsrc_list  free_rsrcs;
+	struct page                     *page;
+	unsigned long                    mmap_vstart;
+	struct list_head                 page_range_list;
+	struct list_head                *page_range_link;
+};
+
+static int
+alloc_or_free_page_ranges(struct usbback_buffer_rsrc_provider *provider,
+int free)
+{
+	int return_value = 0;
+	int i;
+	if (provider->rsrcs.page_ranges == 0)
+		return 0;
+	if (free)
+		goto exit_path;
+	provider->page = balloon_alloc_empty_page_range(
+				provider->rsrcs.page_ranges *
+				provider->rsrcs.page_range_page_count);
+	if (provider->page == NULL) {
+		return_value = -ENOMEM;
+		goto exit_no_page_range;
+	}
+	provider->mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(
+							provider->page));
+	INIT_LIST_HEAD(&provider->page_range_list);
+	provider->page_range_link = kmalloc(sizeof(struct list_head) *
+				provider->rsrcs.page_ranges, GFP_KERNEL);
+	if (provider->page_range_link == NULL) {
+		return_value = -ENOMEM;
+		goto exit_no_page_range_link;
+	}
+	for (i = 0; i < provider->rsrcs.page_ranges; i++) {
+		struct list_head *link = &provider->page_range_link[i];
+		INIT_LIST_HEAD(link);
+		list_add(link, &provider->page_range_list);
+	}
+	provider->free_rsrcs.page_ranges = provider->rsrcs.page_ranges;
+	provider->free_rsrcs.page_range_page_count =
+				provider->rsrcs.page_range_page_count;
+	return 0;
+ exit_path:
+	kfree(provider->page_range_link);
+ exit_no_page_range_link:
+	balloon_dealloc_empty_page_range(provider->page,
+			provider->rsrcs.page_ranges *
+			provider->rsrcs.page_range_page_count);
+ exit_no_page_range:
+	return return_value;
+}
+
+static int
+usbback_buffer_rsrc_provider_init_or_exit(
+struct usbback_buffer_rsrc_provider *provider, int exit)
+{
+	int return_value = 0;
+	trace_info("%p", provider);
+	if (exit)
+		goto exit_path;
+	spin_lock_init(&provider->lock);
+	provider->free_rsrcs = usbback_buffer_rsrc_list_null();
+	if( ( return_value = alloc_or_free_page_ranges(provider, 0) ) != 0 )
+		goto exit_no_page_ranges;
+	return 0;
+ exit_path:
+	alloc_or_free_page_ranges(provider, 1);
+ exit_no_page_ranges:
+	return return_value;
+}
+
+struct usbback_buffer_rsrc_provider *
+usbback_allocate_buffer_rsrc_provider(struct usbback_buffer_rsrc_list rsrcs)
+{
+	struct usbback_buffer_rsrc_provider *provider;
+	trace();
+	provider = kmalloc(sizeof(struct usbback_buffer_rsrc_provider),
+								GFP_KERNEL);
+	if (provider != NULL) {
+		provider->rsrcs = rsrcs;
+		if (usbback_buffer_rsrc_provider_init_or_exit(provider, 0)
+		    != 0) {
+			kfree(provider);
+			provider = NULL;
+		}
+	}
+	return provider;
+}
+
+void usbback_free_buffer_rsrc_provider(
+struct usbback_buffer_rsrc_provider *provider)
+{
+	trace();
+	(void)usbback_buffer_rsrc_provider_init_or_exit(provider, 1);
+	kfree(provider);
+}
+
+struct usbback_buffer_rsrc_list
+usbback_buffer_rsrc_provider_query_free_rsrcs(
+struct usbback_buffer_rsrc_provider *provider)
+{
+	struct usbback_buffer_rsrc_list list;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&provider->lock, flags);
+	list = provider->free_rsrcs;
+	spin_unlock_irqrestore(&provider->lock, flags);
+	return list;
+}
+
+unsigned long
+usbback_buffer_rsrc_provider_allocate_page_range(
+struct usbback_buffer_rsrc_provider *provider, unsigned long page_count)
+{
+	unsigned long page_range;
+	unsigned long flags;
+	struct list_head *link;
+	trace();
+	spin_lock_irqsave(&provider->lock, flags);
+	link = provider->page_range_list.next;
+	list_del_init(link);
+	provider->free_rsrcs.page_ranges--;
+	page_range = (provider->mmap_vstart +
+			(PAGE_SIZE * provider->rsrcs.page_range_page_count *
+			(((unsigned long)link -
+				(unsigned long)provider->page_range_link) /
+						sizeof(struct list_head))));
+	spin_unlock_irqrestore(&provider->lock, flags);
+	return page_range;
+}
+
+void usbback_buffer_rsrc_provider_free_page_range(
+struct usbback_buffer_rsrc_provider *provider, unsigned long page_range)
+{
+	int i;
+	unsigned long flags;
+	trace();
+	i = ((page_range - provider->mmap_vstart) / (PAGE_SIZE *
+			provider->rsrcs.page_range_page_count));
+	spin_lock_irqsave(&provider->lock, flags);
+	list_add(&provider->page_range_link[i], &provider->page_range_list);
+	provider->free_rsrcs.page_ranges++;
+	spin_unlock_irqrestore(&provider->lock, flags);
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_buffer_resource_provider.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_buffer_resource_provider.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,77 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_BUFFER_RESOURCE_PROVIDER_H
+#define USBBACK_BUFFER_RESOURCE_PROVIDER_H
+
+#include <linux/string.h>
+#include <asm/types.h>
+#include <xen/gnttab.h>
+
+struct usbback_buffer_rsrc_list {
+	u32 page_ranges;
+	u32 page_range_page_count;
+};
+
+static inline struct usbback_buffer_rsrc_list
+usbback_buffer_rsrc_list_null(void)
+{
+	struct usbback_buffer_rsrc_list list;
+	memset(&list, 0, sizeof(list));
+	return list;
+}
+
+static inline int
+usbback_buffer_rsrc_list_subset_of(struct usbback_buffer_rsrc_list *a,
+struct usbback_buffer_rsrc_list *b)
+{
+	return ((a->page_ranges <= b->page_ranges) &&
+		(a->page_range_page_count <= b->page_range_page_count));
+}
+
+static inline void
+usbback_buffer_rsrc_list_plus_equals(struct usbback_buffer_rsrc_list *a,
+struct usbback_buffer_rsrc_list *b)
+{
+	a->page_ranges += b->page_ranges;
+	if (b->page_range_page_count > a->page_range_page_count)
+		a->page_range_page_count = b->page_range_page_count;
+}
+
+extern struct usbback_buffer_rsrc_provider *
+usbback_allocate_buffer_rsrc_provider(
+struct usbback_buffer_rsrc_list rsrc_allocation);
+
+extern void
+usbback_free_buffer_rsrc_provider(
+struct usbback_buffer_rsrc_provider *provider);
+
+extern struct usbback_buffer_rsrc_list
+usbback_buffer_rsrc_provider_query_free_rsrcs(
+struct usbback_buffer_rsrc_provider *provider);
+
+extern unsigned long
+usbback_buffer_rsrc_provider_allocate_page_range(
+struct usbback_buffer_rsrc_provider *provider, unsigned long page_count);
+
+extern void
+usbback_buffer_rsrc_provider_free_page_range(
+struct usbback_buffer_rsrc_provider *provider, unsigned long page_range);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_callback.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_callback.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,41 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/module.h>
+#include "usbback_callback.h"
+
+void usbback_callback_serialiser_function(void *context)
+{
+	struct usbback_callback_serialiser *serialiser =
+				(struct usbback_callback_serialiser *)context;
+	unsigned long flags;
+
+	spin_lock_irqsave(&serialiser->lock, flags);
+	while (!list_empty(&serialiser->list) && !serialiser->running) {
+		struct usbback_callback *callback =
+			usbback_callback_link_to(serialiser->list.next);
+		list_del_init(usbback_callback_to_link(callback));
+		serialiser->running = 1;
+		spin_unlock_irqrestore(&serialiser->lock, flags);
+		usbback_callback_complete_synchronously(callback);
+		spin_lock_irqsave(&serialiser->lock, flags);
+		serialiser->running = 0;
+	}
+	spin_unlock_irqrestore(&serialiser->lock, flags);
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_callback.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_callback.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,146 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_CALLBACK_H
+#define USBBACK_CALLBACK_H
+
+#include <linux/spinlock.h>
+#include <xen/interface/io/usbif.h>
+#include "usbback_work.h"
+
+static inline usbif_error usbif_error_map_local_to(int error)
+{
+	switch (error) {
+	case 0:
+		return USBIF_ERROR_SUCCESS;
+	case -ENOTCONN:
+		return USBIF_ERROR_DISCONNECT;
+	case -EPROTO:
+		return USBIF_ERROR_INVALID_PROTOCOL;
+	case -EINVAL:
+		return USBIF_ERROR_INVALID_PARAMETER;
+	case -E2BIG:
+		return USBIF_ERROR_TOO_BIG;
+	case -ENODEV:
+		return USBIF_ERROR_NO_DEVICE;
+	case -ECONNRESET:
+		return USBIF_ERROR_UNLINKED;
+	case -EPIPE:
+		return USBIF_ERROR_PIPE;
+	default:
+		return (usbif_error)error;
+	}
+}
+
+struct usbback_callback {
+	struct usbback_work work;
+	usbif_error         error;
+};
+
+typedef void usbback_callback_function(struct usbback_callback *callback);
+
+static inline void
+usbback_callback_init(struct usbback_callback *callback,
+usbback_callback_function *function)
+{
+	usbback_work_init(&callback->work, (void (*)(void *))function,
+								callback);
+	callback->error = USBIF_ERROR_SUCCESS;
+}
+
+static inline struct list_head *
+usbback_callback_to_link(struct usbback_callback *callback)
+{
+	return usbback_work_to_link(&callback->work);
+}
+
+static inline struct usbback_callback *
+usbback_callback_link_to(struct list_head *link)
+{
+	return container_of(usbback_work_link_to(link),
+					struct usbback_callback, work);
+}
+
+static inline void
+usbback_callback_complete(struct usbback_callback *callback, usbif_error error)
+{
+	callback->error = error;
+	usbback_work_schedule(&callback->work);
+}
+
+static inline void
+usbback_callback_success(struct usbback_callback *callback)
+{
+	usbback_callback_complete(callback, 0);
+}
+
+static inline void
+usbback_callback_set_error(struct usbback_callback *callback,
+usbif_error error)
+{
+	callback->error = error;
+}
+
+static inline void
+usbback_callback_complete_synchronously(struct usbback_callback *callback)
+{
+	usbback_work_perform_synchronously(&callback->work);
+}
+
+static inline usbif_error
+usbback_callback_query_error(struct usbback_callback *callback)
+{
+	return callback->error;
+}
+
+struct usbback_callback_serialiser {
+	spinlock_t lock;
+	struct list_head list;
+	struct usbback_work work;
+	int running;
+};
+
+void usbback_callback_serialiser_function(void *context);
+
+#define USBBACK_CALLBACK_SERIALISER_INIT( name ) {			\
+	.lock = SPIN_LOCK_UNLOCKED,					\
+	.list = LIST_HEAD_INIT( name.list ),				\
+	.work = USBBACK_WORK_INIT					\
+		( name.work, usbback_callback_serialiser_function, &name ),\
+	.running = 0							\
+}
+
+#define USBBACK_CALLBACK_SERIALISER( name ) \
+struct usbback_callback_serialiser name =   \
+USBBACK_CALLBACK_SERIALISER_INIT( name )
+
+static inline void
+usbback_callback_serialiser_complete_callback(
+struct usbback_callback_serialiser *serialiser,
+struct usbback_callback *callback, usbif_error error)
+{
+	unsigned long flags;
+	usbback_callback_set_error(callback, error);
+	spin_lock_irqsave(&serialiser->lock, flags);
+	list_add_tail(usbback_callback_to_link(callback), &serialiser->list);
+	spin_unlock_irqrestore(&serialiser->lock, flags);
+	usbback_work_schedule(&serialiser->work);
+}
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_channel.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_channel.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,159 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_CHANNEL_H
+#define USBBACK_CHANNEL_H
+
+#include <xen/interface/io/usbif.h>
+#include "usbback_callback.h"
+
+struct usbback_channel_ibmsg {
+	struct usbback_callback callback;
+	struct usbif_request    request;
+};
+
+static inline struct list_head *
+usbback_channel_ibmsg_to_link(struct usbback_channel_ibmsg *message)
+{
+	return &message->callback.work.link;
+}
+
+static inline struct usbback_callback *
+usbback_channel_ibmsg_to_callback(struct usbback_channel_ibmsg *message)
+{
+	return &message->callback;
+}
+
+static inline struct usbback_channel_ibmsg *
+usbback_channel_ibmsg_callback_to(struct usbback_callback *callback)
+{
+	return container_of(callback, struct usbback_channel_ibmsg, callback);
+}
+
+static inline void
+usbback_channel_ibmsg_init(struct usbback_channel_ibmsg *message,
+usbback_callback_function *callback)
+{
+	usbback_callback_init(usbback_channel_ibmsg_to_callback(message),
+								callback);
+}
+
+struct usbback_channel_obmsg {
+	struct usbback_callback callback;
+	struct usbif_response   response;
+};
+
+static inline struct list_head *
+usbback_channel_obmsg_to_link(struct usbback_channel_obmsg *message)
+{
+	return &message->callback.work.link;
+}
+
+static inline struct usbback_callback *
+usbback_channel_obmsg_to_callback(struct usbback_channel_obmsg *message)
+{
+	return &message->callback;
+}
+
+static inline struct usbback_channel_obmsg *
+usbback_channel_obmsg_callback_to(struct usbback_callback *callback)
+{
+	return container_of(callback, struct usbback_channel_obmsg, callback);
+}
+
+static inline void
+usbback_channel_obmsg_init(struct usbback_channel_obmsg *message,
+usbback_callback_function *callback)
+{
+	usbback_callback_init(usbback_channel_obmsg_to_callback(message),
+								callback);
+}
+
+struct usbback_channel;
+
+typedef void
+usbback_channel_submit_message_function(struct usbback_channel *channel,
+struct usbback_channel_obmsg *message);
+
+typedef void
+usbback_channel_connect_function(void *client_context);
+
+typedef void
+usbback_channel_handle_message_function(void *client_context,
+struct usbback_channel_ibmsg *message);
+
+typedef void
+usbback_channel_disconnect_function(void *client_context,
+struct usbback_callback *callback);
+
+struct usbback_channel {
+	usbback_channel_submit_message_function *submit_message;
+	void                                    *client_context;
+	usbback_channel_connect_function        *connect;
+	usbback_channel_handle_message_function *handle_message;
+	usbback_channel_disconnect_function     *disconnect;
+};
+
+static inline void
+usbback_channel_init(struct usbback_channel *channel,
+usbback_channel_submit_message_function *submit_message )
+{
+	channel->submit_message = submit_message;
+}
+
+static inline void usbback_channel_connect(struct usbback_channel *channel)
+{
+	channel->connect(channel->client_context);
+}
+
+static inline void
+usbback_channel_handle_message(struct usbback_channel *channel,
+struct usbback_channel_ibmsg *message)
+{
+	channel->handle_message(channel->client_context, message);
+}
+
+static inline void
+usbback_channel_disconnect(struct usbback_channel *channel,
+struct usbback_callback *callback)
+{
+	channel->disconnect(channel->client_context, callback);
+}
+
+static inline void
+usbback_channel_install_client(struct usbback_channel *channel,
+void *client_context, usbback_channel_connect_function *connect,
+usbback_channel_handle_message_function *handle_message,
+usbback_channel_disconnect_function *disconnect)
+{
+	channel->client_context = client_context;
+	channel->connect        = connect;
+	channel->handle_message = handle_message;
+	channel->disconnect     = disconnect;
+}
+
+static inline void
+usbback_channel_submit_message(struct usbback_channel *channel,
+struct usbback_channel_obmsg *message)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	channel->submit_message(channel, message);
+}
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_device.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_device.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,839 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Based on                                                                  */
+/*                                                                           */
+/* arch/xen/drivers/usbif/backend/control.c                                  */
+/* arch/xen/drivers/usbif/backend/interface.c                                */
+/* arch/xen/drivers/usbif/backend/main.c                                     */
+/* blkback/xenbus.c                                                          */
+/*                                                                           */
+/* original copyright notices follow...                                      */
+/*****************************************************************************/
+
+/******************************************************************************
+ * arch/xen/drivers/usbif/backend/control.c
+ * 
+ * Routines for interfacing with the control plane.
+ * 
+ * Copyright (c) 2004, Keir Fraser
+ */
+
+/******************************************************************************
+ * arch/xen/drivers/usbif/backend/interface.c
+ * 
+ * USB device interface management.
+ * 
+ * by Mark Williamson, Copyright (c) 2004
+ */
+
+/******************************************************************************
+ * arch/xen/drivers/blkif/backend/interface.c
+ * 
+ * Block-device interface management.
+ * 
+ * Copyright (c) 2004, Keir Fraser
+ */
+
+/******************************************************************************
+ * arch/xen/drivers/usbif/backend/main.c
+ * 
+ * Backend for the Xen virtual USB driver - provides an abstraction of a
+ * USB host controller to the corresponding frontend driver.
+ *
+ * by Mark Williamson
+ * Copyright (c) 2004 Intel Research Cambridge
+ * Copyright (c) 2004, 2005 Mark Williamson
+ *
+ * Based on arch/xen/drivers/blkif/backend/main.c
+ * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
+ */
+
+/*  Xenbus code for blkif backend
+    Copyright (C) 2005 Rusty Russell <rusty@rustcorp.com.au>
+
+    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/rwsem.h>
+#include <linux/usb.h>
+#include <xen/interface/io/usbif.h>
+#include <xen/xenbus.h>
+#include "usbback_device.h"
+#include "usbback_trace.h"
+#include "usbback_xb_channel.h"
+
+static struct usb_driver usbback_device_usb_driver;
+
+static DECLARE_RWSEM(usbback_device_list_sem);
+static LIST_HEAD(usbback_device_list);
+
+typedef enum {
+	usbback_device_state_i,
+	usbback_device_state_i_up,
+	usbback_device_state_i_cn,
+	usbback_device_state_i_up_cn,
+	usbback_device_state_i_up_cn_ud,
+	usbback_device_state_i_up_cn_dn,
+	usbback_device_state_i_up_cn_ud_dn
+} usbback_device_state;
+
+typedef enum {
+	usbback_device_stimulus_up, /* USB probe                  */
+	usbback_device_stimulus_ud, /* USB disconnect             */
+	usbback_device_stimulus_cn, /* Gateway connect            */
+	usbback_device_stimulus_dn, /* Gateway disconnect         */
+	usbback_device_stimulus_rq, /* Tra queued/rsrc freed      */
+	usbback_device_stimulus_ri  /* test_io rsrcs idle (reent) */
+} usbback_device_stimulus;
+
+struct usbback_device {
+	struct xenbus_device      *dev;
+	struct list_head           link;
+	struct usb_device         *usbdev;
+	spinlock_t                 lock;
+	usbback_device_state       state;
+	int                        usbdev_is_connected;
+	int                        enabled;
+	struct list_head           tra_list;
+	struct list_head           free_rsrc_list;
+	unsigned long              rsrcs_out;
+	struct usbback_rsrc        rsrcs[USBIF_QUOTA];
+	struct usbback_callback   *gw_disconnect_callback;
+	int                        usb_disconnect;
+	char                      *path;
+	struct usbback_xb_channel  channel;
+	struct usbback_gw          gw;
+};
+
+static void
+usbback_device_handle_stimulus(struct usbback_device *device,
+usbback_device_stimulus stimulus);
+
+domid_t usbback_device_query_remote_domain(struct usbback_device *device)
+{
+	trace();
+	return device->dev->otherend_id;
+}
+
+struct usb_device *usbback_device_query_usbdev(struct usbback_device *device)
+{
+	trace();
+	return device->usbdev;
+}
+
+static inline struct usbback_device *
+usbback_device_gw_to(struct usbback_gw *gw)
+{
+	return container_of(gw, struct usbback_device, gw);
+}
+
+static int
+usbback_device_probe_usb_device(struct usb_interface *intf,
+const struct usb_device_id *id)
+{
+	int return_value = 0, i;
+	struct usb_device *usbdev = interface_to_usbdev(intf);
+	struct usbback_device *device = NULL, *cur = NULL;
+	trace();
+	dev_info(&usbdev->dev, "probe for %s\n", usbdev->dev.bus_id);
+	down_read(&usbback_device_list_sem);
+	list_for_each_entry(cur, &usbback_device_list, link) {
+		dev_info(&usbdev->dev, "testing path %s\n", cur->path );
+		if (strcmp(cur->path, usbdev->dev.bus_id) == 0) {
+			dev_info(&usbdev->dev, "match found\n" );
+			device = cur;
+			break;
+		} else {
+			dev_info(&usbdev->dev, "does not match\n" );
+		}
+	}
+	if (device == NULL) {
+		dev_info(&usbdev->dev, "no match found\n" );
+		return_value = -ENODEV;
+		goto exit_no_device;
+	}
+	for (i = 0; i < usbdev->actconfig->desc.bNumInterfaces; i++) {
+		struct usb_interface *other_intf = usb_ifnum_to_if(usbdev, i);
+		if (other_intf != intf) {
+			if (usb_interface_claimed(other_intf)) {
+				dev_info(&usbdev->dev,
+						"an interface of the matching "
+						"device is already in use by "
+						"another driver\n");
+				return_value = -EBUSY;
+				goto exit_interface_already_claimed;
+			}
+		}
+	}
+	for (i = 0; i < usbdev->actconfig->desc.bNumInterfaces; i++) {
+		struct usb_interface *other_intf = usb_ifnum_to_if(usbdev, i);
+		if (other_intf != intf) {
+			/* We already checked the interfaces were available. */
+			(void)usb_driver_claim_interface(
+						&usbback_device_usb_driver,
+						other_intf, device);
+		}
+	}
+	usbdev = usb_get_dev(usbdev);
+	usb_set_intfdata(intf, device);
+	spin_lock_irq(&device->lock);
+	device->usbdev_is_connected = 1;
+	device->usbdev = usbdev;
+	usbback_device_handle_stimulus(device, usbback_device_stimulus_up);
+	spin_unlock_irq(&device->lock);
+ exit_interface_already_claimed:
+ exit_no_device:
+	up_read(&usbback_device_list_sem);
+	return return_value;
+}
+
+static void usbback_device_disconnect_usb_device(struct usb_interface *intf)
+{
+	struct usbback_device *device = usb_get_intfdata(intf);
+	trace();
+	/* Protect against reentrant call when we release other interfaces. */
+	if (device != NULL) {
+		struct usb_device *usbdev;
+		int i;
+		spin_lock_irq(&device->lock);
+		device->usbdev_is_connected = 0;
+		device->enabled = 0;
+		device->usb_disconnect = 0;
+		usbback_device_handle_stimulus(device,
+						usbback_device_stimulus_ud);
+		spin_unlock_irq(&device->lock);
+		usbback_work_until(device->usb_disconnect);
+		usbdev = device->usbdev;
+		for (i = 0; i < usbdev->actconfig->desc.bNumInterfaces; i++) {
+			struct usb_interface *other_intf = usb_ifnum_to_if(
+								usbdev, i);
+			if (other_intf != intf) {
+				/* Protect against reentrant call when we    */
+				/* release other interfaces.                 */
+				usb_set_intfdata(other_intf, NULL);
+				usb_driver_release_interface(
+						&usbback_device_usb_driver,
+								other_intf);
+			}
+		}
+		usb_set_intfdata(intf, NULL);
+		usb_put_dev(usbdev);
+	}
+}
+
+static void usbback_device_gw_connect(struct usbback_gw *gw)
+{
+	struct usbback_device *device = usbback_device_gw_to(gw);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	usbback_device_handle_stimulus(device, usbback_device_stimulus_cn);
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+static void
+usbback_device_handle_probe(struct usbback_device *device,
+struct usbback_gw_tra *tra)
+{
+	tra->status.probe.result = device->usbdev_is_connected ?
+					USBIF_PROBE_RESULT_DEVICE_PRESENT :
+					USBIF_PROBE_RESULT_NO_DEVICE;
+	usbback_gw_tra_complete(tra, USBIF_ERROR_SUCCESS);
+}
+
+int usbback_device_reset(struct usbback_device *device)
+{
+	int status = -1;
+	trace();
+	spin_lock_irq(&device->lock);
+	if (device->usbdev_is_connected) {
+		if (device->usbdev->speed == USB_SPEED_LOW) {
+			status = USBIF_RESET_RESULT_LOW_SPEED;
+		} else if (device->usbdev->speed == USB_SPEED_HIGH) {
+			status = USBIF_RESET_RESULT_HIGH_SPEED;
+		} else {
+			status = USBIF_RESET_RESULT_FULL_SPEED;
+		}
+		device->enabled = 1;
+	} else {
+		device->enabled = 0;
+	}
+	spin_unlock_irq(&device->lock);
+	return status;
+}
+
+static void
+usbback_device_handle_reset(struct usbback_device *device,
+struct usbback_gw_tra *tra)
+{
+	usbif_error error = USBIF_ERROR_SUCCESS;
+	int result;
+	trace();
+	result = usbback_device_reset(device);
+	if (result < 0) {
+		error = USBIF_ERROR_NO_DEVICE;
+		goto complete;
+	}
+	tra->status.reset.result = result;
+ complete:
+	usbback_gw_tra_complete(tra, error);
+}
+
+static void
+usbback_device_handle_io(struct usbback_device *device,
+struct usbback_gw_tra *tra)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	list_add_tail(usbback_gw_tra_to_link(tra), &device->tra_list);
+	usbback_device_handle_stimulus(device, usbback_device_stimulus_rq);
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+static void
+usbback_device_handle_unlink(struct usbback_device *device,
+struct usbback_gw_tra *unlink_tra)
+{
+	uint32_t unlink_id = unlink_tra->parameters.unlink.unlink_id;
+	struct usbback_gw_tra *tra = NULL, *temp;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	list_for_each_entry(temp, &device->tra_list, callback.work.link) {
+		if (temp->parameters.io.header.unlink_id == unlink_id) {
+			tra = temp;
+			list_del_init(usbback_gw_tra_to_link(tra));
+			break;
+		}
+	}
+	if (tra == NULL) {
+		int i;
+		for (i = 0; i < USBIF_QUOTA; i++) {
+			struct usbback_rsrc *rsrc = &device->rsrcs[i];
+			if (usbback_rsrc_try_unlink(rsrc, unlink_id))
+				break;
+		}
+	}
+	spin_unlock_irqrestore(&device->lock, flags);
+	if (tra)
+		usbback_gw_tra_complete(tra, USBIF_ERROR_UNLINKED);
+	usbback_gw_tra_complete(unlink_tra, USBIF_ERROR_SUCCESS);
+}
+
+static void
+usbback_device_gw_tra(struct usbback_gw *gw, struct usbback_gw_tra *tra)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbback_device *device = usbback_device_gw_to(gw);
+	switch (tra->parameters.header.tra_type) {
+	case USBIF_TRA_TYPE_PROBE:
+		usbback_device_handle_probe(device, tra);
+		break;
+	case USBIF_TRA_TYPE_RESET:
+		usbback_device_handle_reset(device, tra);
+		break;
+	case USBIF_TRA_TYPE_IO:
+		usbback_device_handle_io(device, tra);
+		break;
+	case USBIF_TRA_TYPE_UNLINK:
+		usbback_device_handle_unlink(device, tra);
+		break;
+	default:
+		usbback_gw_tra_complete(tra, USBIF_ERROR_INVALID_PARAMETER);
+		break;
+	}
+}
+
+static void
+usbback_device_gw_disconnect(struct usbback_gw *gw,
+struct usbback_callback *callback)
+{
+	struct usbback_device *device = usbback_device_gw_to(gw);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	device->gw_disconnect_callback = callback;
+	usbback_device_handle_stimulus(device, usbback_device_stimulus_dn);
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+static void
+usbback_device_invalid_stimulus(struct usbback_device *device,
+usbback_device_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbback: device %p in state %d"
+	     "received invalid stimulus %d", device, device->state, stimulus);
+}
+
+static void usbback_device_purge_io(struct usbback_device *device)
+{
+	int i;
+	trace();
+	while (!list_empty(&device->tra_list)) {
+		struct usbback_gw_tra *tra = list_entry(device->tra_list.next,
+				struct usbback_gw_tra, callback.work.link);
+		list_del_init(usbback_gw_tra_to_link(tra));
+		usbback_gw_tra_complete(tra, USBIF_ERROR_UNLINKED);
+	}
+	for (i = 0; i < USBIF_QUOTA; i++) {
+		struct usbback_rsrc *rsrc = &device->rsrcs[i];
+		usbback_rsrc_flush_tra(rsrc);
+	}
+}
+
+static void usbback_device_test_io(struct usbback_device *device)
+{
+	trace();
+	if (device->rsrcs_out == 0) {
+		usbback_device_handle_stimulus(device,
+						usbback_device_stimulus_ri);
+	}
+}
+
+static void usbback_device_kick_io(struct usbback_device *device)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	trace();
+	while (!list_empty(&device->tra_list) &&
+				!list_empty(&device->free_rsrc_list)) {
+		struct usbback_gw_tra *tra = list_entry(device->tra_list.next,
+				struct usbback_gw_tra, callback.work.link);
+		struct usbback_rsrc *rsrc = list_entry(
+				device->free_rsrc_list.next,
+				struct usbback_rsrc, link);
+		list_del_init(usbback_gw_tra_to_link(tra));
+		list_del_init(&rsrc->link);
+		device->rsrcs_out++;
+		usbback_rsrc_start_io(rsrc, tra);
+	}
+}
+
+void usbback_device_rsrc_completed_io(struct usbback_device *device,
+struct usbback_rsrc *rsrc)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	list_add(&rsrc->link, &device->free_rsrc_list);
+	device->rsrcs_out--;
+	usbback_device_handle_stimulus(device, usbback_device_stimulus_rq);
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+static void
+usbback_device_complete_usb_disconnect(struct usbback_device *device)
+{
+	trace();
+	device->usb_disconnect = 1;
+	usbback_work_wake_up();
+}
+
+static void
+usbback_device_complete_gw_disconnect(struct usbback_device *device)
+{
+	trace();
+	usbback_callback_success(device->gw_disconnect_callback);
+}
+
+static void
+usbback_device_handle_stimulus(struct usbback_device *device,
+usbback_device_stimulus stimulus)
+{
+	trace_info("device %p in state %d received stimulus %d", device,
+						device->state, stimulus);
+	switch (device->state) {
+	case usbback_device_state_i:
+		/* USB disconnected                   */
+		/* Gateway disconnected               */
+		/* I/Os idle                          */
+		/* USB disconnect not outstanding     */
+		/* Gateway disconnect not outstanding */
+		switch (stimulus) {
+		case usbback_device_stimulus_up:
+			device->state = usbback_device_state_i_up;
+			break;
+		case usbback_device_stimulus_cn:
+			device->state = usbback_device_state_i_cn;
+			break;
+		default:
+			usbback_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbback_device_state_i_up:
+		/* USB probed                         */
+		/* Gateway disconnected               */
+		/* I/Os idle                          */
+		/* USB disconnect not outstanding     */
+		/* Gateway disconnect not outstanding */
+		switch (stimulus) {
+		case usbback_device_stimulus_ud:
+			device->state = usbback_device_state_i;
+			usbback_device_complete_usb_disconnect(device);
+			break;
+		case usbback_device_stimulus_cn:
+			device->state = usbback_device_state_i_up_cn;
+			break;
+		default:
+			usbback_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbback_device_state_i_cn:
+		/* USB disconnected                   */
+		/* Gateway connected                  */
+		/* I/Os idle                          */
+		/* USB disconnect not outstanding     */
+		/* Gateway disconnect not outstanding */
+		switch (stimulus) {
+		case usbback_device_stimulus_up:
+			device->state = usbback_device_state_i_up_cn;
+			break;
+		case usbback_device_stimulus_dn:
+			device->state = usbback_device_state_i;
+			usbback_device_complete_gw_disconnect(device);
+			break;
+		case usbback_device_stimulus_rq:
+			usbback_device_purge_io(device);
+			break;
+		default:
+			usbback_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbback_device_state_i_up_cn:
+		/* USB probed                         */
+		/* Gateway connected                  */
+		/* Maybe I/Os in progress             */
+		/* USB disconnect not outstanding     */
+		/* Gateway disconnect not outstanding */
+		switch (stimulus) {
+		case usbback_device_stimulus_ud:
+			device->state = usbback_device_state_i_up_cn_ud;
+			usbback_device_purge_io(device);
+			usbback_device_test_io(device);
+			break;
+		case usbback_device_stimulus_dn:
+			device->state = usbback_device_state_i_up_cn_dn;
+			usbback_device_purge_io(device);
+			usbback_device_test_io(device);
+			break;
+		case usbback_device_stimulus_rq:
+			usbback_device_kick_io(device);
+			break;
+		default:
+			usbback_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbback_device_state_i_up_cn_ud:
+		/* USB disconnecting                  */
+		/* Gateway connected                  */
+		/* I/Os in progress/testing I/Os      */
+		/* USB disconnect outstanding         */
+		/* Gateway disconnect not outstanding */
+		switch (stimulus) {
+		case usbback_device_stimulus_dn:
+			device->state = usbback_device_state_i_up_cn_ud_dn;
+			break;
+		case usbback_device_stimulus_rq:
+			usbback_device_purge_io(device);
+			usbback_device_test_io(device);
+			break;
+		case usbback_device_stimulus_ri:
+			device->state = usbback_device_state_i_cn;
+			usbback_device_complete_usb_disconnect(device);
+			break;
+		default:
+			usbback_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbback_device_state_i_up_cn_dn:
+		/* USB probed                     */
+		/* Gateway disconnecting          */
+		/* I/Os in progress/testing I/Os  */
+		/* USB disconnect not outstanding */
+		/* Gateway disconnect outstanding */
+		switch (stimulus) {
+		case usbback_device_stimulus_ud:
+			device->state = usbback_device_state_i_up_cn_ud_dn;
+			break;
+		case usbback_device_stimulus_rq:
+			usbback_device_purge_io(device);
+			usbback_device_test_io(device);
+			break;
+		case usbback_device_stimulus_ri:
+			device->state = usbback_device_state_i_up;
+			usbback_device_complete_gw_disconnect(device);
+			break;
+		default:
+			usbback_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbback_device_state_i_up_cn_ud_dn:
+		/* USB disconnecting              */
+		/* Gateway disconnecting          */
+		/* I/Os in progress/testing I/Os  */
+		/* USB disconnect outstanding     */
+		/* Gateway disconnect outstanding */
+		switch (stimulus) {
+		case usbback_device_stimulus_rq:
+			usbback_device_purge_io(device);
+			usbback_device_test_io(device);
+			break;
+		case usbback_device_stimulus_ri:
+			device->state = usbback_device_state_i;
+			usbback_device_complete_usb_disconnect(device);
+			usbback_device_complete_gw_disconnect(device);
+			break;
+		default:
+			usbback_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	default:
+		usbback_device_invalid_stimulus(device, stimulus);
+		break;
+	}
+}
+
+static int
+usbback_device_init_or_exit(struct usbback_device *device,
+struct xenbus_device *dev, int exit)
+{
+	xenbus_transaction_t tra;
+	int return_value = 0, i;
+	trace();
+	if (exit)
+		goto exit_path;
+	device->dev = dev;
+	INIT_LIST_HEAD(&device->link);
+	spin_lock_init(&device->lock);
+	device->state = usbback_device_state_i;
+	INIT_LIST_HEAD(&device->tra_list);
+	INIT_LIST_HEAD(&device->free_rsrc_list);
+	for (i = 0; i < USBIF_QUOTA; i++) {
+		struct usbback_rsrc *rsrc = &device->rsrcs[i];
+		return_value = usbback_rsrc_init(rsrc, device);
+		if (return_value != 0)
+			goto exit_no_rsrc;
+		list_add(&rsrc->link, &device->free_rsrc_list);
+	}
+	return_value = usbback_xb_channel_init(&device->channel);
+	if (return_value != 0)
+		goto exit_no_channel;
+	return_value = usbback_gw_init(&device->gw,
+			usbback_xb_channel_to_channel(&device->channel),
+			usbback_device_gw_connect,
+			usbback_device_gw_tra,
+			usbback_device_gw_disconnect);
+	if (return_value != 0)
+		goto exit_no_gw;
+	return_value = xenbus_transaction_start(&tra);
+	if (return_value != 0) {
+		trace_info("Error starting tra.");
+		goto exit_no_tra;
+	}
+	return_value = xenbus_gather(tra, dev->nodename, "path", NULL,
+							&device->path, NULL);
+	(void)xenbus_transaction_end(tra, 1);
+	if (return_value < 0) {
+		trace_info("Failed to gather configuration parameters.");
+		goto exit_no_path;
+	}
+	trace_info("path:%s", device->path);
+	down_write(&usbback_device_list_sem);
+	list_add_tail(&device->link, &usbback_device_list);
+	up_write(&usbback_device_list_sem);
+	bus_rescan_devices(&usb_bus_type);
+	usbback_xb_channel_connect(&device->channel);
+	return 0;
+ exit_path:
+	usbback_xb_channel_disconnect(&device->channel);
+	down_write(&usbback_device_list_sem);
+	list_del_init(&device->link);
+	up_write(&usbback_device_list_sem);
+	spin_lock_irq(&device->lock);
+	if (device->usbdev_is_connected) {
+		usb_get_dev(device->usbdev);
+		spin_unlock_irq(&device->lock);
+		usb_lock_device(device->usbdev);
+		down_write(&usb_bus_type.subsys.rwsem);
+		if (device->usbdev_is_connected)
+			usb_driver_release_interface(
+					&usbback_device_usb_driver,
+					usb_ifnum_to_if(device->usbdev, 0));
+		up_write(&usb_bus_type.subsys.rwsem);
+		usb_unlock_device(device->usbdev);
+		usb_put_dev(device->usbdev);
+		spin_lock_irq(&device->lock);
+	}
+	spin_unlock_irq(&device->lock);
+	kfree(device->path);
+ exit_no_path:
+ exit_no_tra:
+	usbback_gw_exit(&device->gw);
+ exit_no_gw:
+	usbback_xb_channel_exit(&device->channel);
+ exit_no_channel:
+ exit_no_rsrc:
+	while (!list_empty(&device->free_rsrc_list)) {
+		struct usbback_rsrc *rsrc = list_entry(
+					device->free_rsrc_list.next,
+					struct usbback_rsrc, link);
+		list_del_init(&rsrc->link);
+		usbback_rsrc_exit(rsrc);
+	}
+	return return_value;
+}
+
+static int
+usbback_device_init(struct usbback_device *device, struct xenbus_device *dev)
+{
+	trace();
+	return usbback_device_init_or_exit(device, dev, 0);
+}
+
+static void usbback_device_exit(struct usbback_device *device)
+{
+	trace();
+	(void)usbback_device_init_or_exit(device, NULL, 1);
+}
+
+static int
+usbback_device_probe_or_remove_xenbus_device(struct xenbus_device *dev,
+int remove)
+{
+	int return_value = 0;
+	struct usbback_device *device;
+	trace();
+	if (remove)
+		goto remove_path;
+	device = kzalloc(sizeof(*device), GFP_KERNEL);
+	if (device == NULL) {
+		xenbus_dev_error(dev, -ENOMEM, "allocating device structure");
+		return_value = -ENOMEM;
+		goto exit_no_device;
+	}
+	dev->data = device;
+	return_value = usbback_device_init(device, dev);
+	if (return_value != 0)
+		goto exit_no_init;
+	return 0;
+ remove_path:
+	device = dev->data;
+	usbback_device_exit(device);
+ exit_no_init:
+	dev->data = NULL;
+	kfree(device);
+ exit_no_device:
+	return return_value;
+}
+
+static int usbback_device_probe_xenbus_device(struct xenbus_device *dev,
+const struct xenbus_device_id *id)
+{
+	trace();
+	return usbback_device_probe_or_remove_xenbus_device(dev, 0);
+}
+
+static int usbback_device_remove_xenbus_device(struct xenbus_device *dev)
+{
+	trace();
+	return usbback_device_probe_or_remove_xenbus_device(dev, 1);
+}
+
+static void
+usbback_device_frontend_changed(struct xenbus_device *dev, XenbusState state)
+{
+	struct usbback_device *device = dev->data;
+	trace();
+	usbback_xb_channel_frontend_changed(&device->channel, dev, state);
+}
+
+static struct usb_device_id usbback_device_usb_id_table[] = {
+	{.driver_info = 1},	/* Matches all devices. */
+	{}
+};
+
+static struct usb_driver usbback_device_usb_driver = {
+	.name       = "usbback",
+	.probe      = usbback_device_probe_usb_device,
+	.disconnect = usbback_device_disconnect_usb_device,
+	.id_table   = usbback_device_usb_id_table,
+};
+
+static struct xenbus_device_id usbback_device_xenbus_ids[] = {
+	{"usb"},
+	{""}
+};
+
+static struct xenbus_driver usbback_device_xenbus_driver = {
+	.name             = "usb",
+	.owner            = THIS_MODULE,
+	.ids              = usbback_device_xenbus_ids,
+	.probe            = usbback_device_probe_xenbus_device,
+	.remove           = usbback_device_remove_xenbus_device,
+	.otherend_changed = usbback_device_frontend_changed,
+};
+
+static int __init usbback_device_class_init(void)
+{
+	int return_value = 0;
+	trace();
+	return_value = usbback_rsrc_class_init();
+	if (return_value != 0)
+		goto exit_no_rsrc_class;
+	return_value = usb_register(&usbback_device_usb_driver);
+	if (return_value != 0)
+		goto exit_no_usb_register;
+	return_value = xenbus_register_backend(&usbback_device_xenbus_driver);
+	if (return_value != 0)
+		goto exit_no_xenbus_register;
+	return 0;
+ exit_no_xenbus_register:
+	usb_deregister(&usbback_device_usb_driver);
+ exit_no_usb_register:
+	usbback_rsrc_class_exit();
+ exit_no_rsrc_class:
+	return return_value;
+}
+
+__initcall(usbback_device_class_init);
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_device.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_device.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,32 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_DEVICE_H
+#define USBBACK_DEVICE_H
+
+#include "usbback_resource.h"
+
+domid_t usbback_device_query_remote_domain(struct usbback_device *device);
+
+struct usb_device * usbback_device_query_usbdev(struct usbback_device *device);
+
+void usbback_device_rsrc_completed_io(struct usbback_device *device,
+struct usbback_rsrc *rsrc);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_gw.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_gw.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,466 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include "usbback_gw.h"
+#include "usbback_trace.h"
+
+typedef enum {
+	usbback_gw_stimulus_cc, /* Channel connect.                 */
+	usbback_gw_stimulus_cm, /* Channel message.                 */
+	usbback_gw_stimulus_cd, /* Channel disconnect.              */
+	usbback_gw_stimulus_kc, /* Kick channel messages completed. */
+	usbback_gw_stimulus_tc, /* Target rsrc completed.           */
+	usbback_gw_stimulus_ti, /* Target rsrcs idle.               */
+	usbback_gw_stimulus_lc, /* Client connect completed.        */
+	usbback_gw_stimulus_lg, /* Client disconnect called.        */
+	usbback_gw_stimulus_ld, /* Client disconnect completed.     */
+} usbback_gw_stimulus;
+
+static void usbback_gw_handle_stimulus(struct usbback_gw *gw,
+usbback_gw_stimulus stimulus);
+
+static void usbback_gw_channel_connect(void *context)
+{
+	struct usbback_gw *gw = context;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&gw->lock, flags);
+	usbback_gw_handle_stimulus(gw, usbback_gw_stimulus_cc);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbback_gw_handle_channel_message(void *context,
+struct usbback_channel_ibmsg *message)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbback_gw *gw = context;
+	unsigned long flags;
+	spin_lock_irqsave(&gw->lock, flags);
+	list_add_tail(usbback_channel_ibmsg_to_link(message),
+					&gw->channel_message_list);
+	usbback_gw_handle_stimulus(gw,usbback_gw_stimulus_cm);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void
+usbback_gw_channel_disconnect(void *context, struct usbback_callback *callback)
+{
+	struct usbback_gw *gw = context;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&gw->lock, flags);
+	gw->channel_disconnect_callback = callback;
+	usbback_gw_handle_stimulus(gw, usbback_gw_stimulus_cd);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+void usbback_gw_submit_channel_message(struct usbback_gw *gw,
+struct usbback_channel_obmsg *message)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	usbback_channel_submit_message(gw->channel, message);
+}
+
+void usbback_gw_submit_tra_to_client(struct usbback_gw *gw,
+struct usbback_gw_tra *tra)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	gw->handle_tra(gw, tra);
+}
+
+static void usbback_gw_invalid_stimulus(struct usbback_gw *gw,
+usbback_gw_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbback: gw %p in state %d"
+		     "received invalid stimulus %d", gw, gw->state, stimulus);
+}
+
+static void
+usbback_gw_kick_channel_messages(struct usbback_gw *gw)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	if (!gw->kick_channel_messages_out) {
+		gw->kick_channel_messages_out = 1;
+		(void)usbback_work_schedule(&gw->kick_channel_messages_1_work);
+	}
+}
+
+static void usbback_gw_kick_channel_messages_1(void *data)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbback_gw *gw = data;
+	unsigned long flags;
+	spin_lock_irqsave(&gw->lock, flags);
+	while ((!list_empty(&gw->channel_message_list)) &&
+		(!list_empty(&gw->target_rsrc_list))) {
+		usbif_error error = USBIF_ERROR_SUCCESS;
+		struct usbback_channel_ibmsg *message;
+		struct usbback_gw_rsrc *rsrc;
+		message = list_entry(gw->channel_message_list.next,
+					struct usbback_channel_ibmsg,
+					callback.work.link);
+		rsrc = list_entry(gw->target_rsrc_list.next,
+					struct usbback_gw_rsrc,
+					callback.work.link);
+		list_del_init(usbback_channel_ibmsg_to_link(message));
+		list_del_init(usbback_gw_rsrc_to_link(rsrc));
+		gw->target_rsrcs_out++;
+		spin_unlock_irqrestore(&gw->lock, flags);
+		usbback_gw_rsrc_start_tra(rsrc, &message->request);
+		spin_lock_irqsave(&gw->lock, flags);
+		usbback_callback_complete(usbback_channel_ibmsg_to_callback(
+							message), error);
+	}
+	gw->kick_channel_messages_out = 0;
+	usbback_gw_handle_stimulus(gw, usbback_gw_stimulus_kc);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void
+usbback_gw_kick_channel_messages_2(struct usbback_callback *callback)
+{
+	struct usbback_gw_rsrc *rsrc = usbback_gw_rsrc_callback_to(callback);
+	struct usbback_gw *gw = usbback_gw_rsrc_query_gw(rsrc);
+	unsigned long flags;
+	spin_lock_irqsave(&gw->lock, flags);
+	list_add_tail(usbback_gw_rsrc_to_link(rsrc), &gw->target_rsrc_list);
+	if (--gw->target_rsrcs_out != 0) {
+		usbback_gw_handle_stimulus(gw, usbback_gw_stimulus_tc);
+	} else {
+		usbback_gw_handle_stimulus(gw, usbback_gw_stimulus_ti);
+	}
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbback_gw_complete_channel_messages(struct usbback_gw *gw)
+{
+	trace();
+	while (!list_empty(&gw->channel_message_list)) {
+		struct usbback_channel_ibmsg *message = list_entry(
+			gw->channel_message_list.next,
+			struct usbback_channel_ibmsg,
+			callback.work.link);
+		list_del_init(usbback_channel_ibmsg_to_link(message));
+		usbback_callback_success(usbback_channel_ibmsg_to_callback(
+								message));
+	}
+}
+
+static void usbback_gw_connect_client(struct usbback_gw *gw)
+{
+	trace();
+	(void)usbback_work_schedule(&gw->connect_client_1_work);
+}
+
+static void usbback_gw_connect_client_1(void *data)
+{
+	struct usbback_gw *gw = data;
+	unsigned long flags;
+	trace();
+	gw->connect(gw);
+	spin_lock_irqsave(&gw->lock, flags);
+	usbback_gw_handle_stimulus(gw, usbback_gw_stimulus_lc);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbback_gw_disconnect_client(struct usbback_gw *gw)
+{
+	trace();
+	(void)usbback_work_schedule(&gw->disconnect_client_1_work);
+}
+
+static void usbback_gw_disconnect_client_1(void *data)
+{
+	struct usbback_gw *gw = data;
+	unsigned long flags;
+	trace();
+	gw->disconnect(gw, &gw->disconnect_client_2_callback);
+	spin_lock_irqsave(&gw->lock, flags);
+	usbback_gw_handle_stimulus(gw, usbback_gw_stimulus_lg);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbback_gw_disconnect_client_2(struct usbback_callback *callback)
+{
+	struct usbback_gw *gw = container_of(callback, struct usbback_gw,
+						disconnect_client_2_callback);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&gw->lock, flags);
+	usbback_gw_handle_stimulus(gw, usbback_gw_stimulus_ld);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbback_gw_test_target_rsrcs(struct usbback_gw *gw)
+{
+	trace();
+	if (gw->target_rsrcs_out == 0)
+		usbback_gw_handle_stimulus(gw, usbback_gw_stimulus_ti);
+}
+
+static void usbback_gw_complete_channel_disconnect(struct usbback_gw *gw)
+{
+	trace();
+	usbback_callback_success(gw->channel_disconnect_callback);
+}
+
+static int usbback_gw_init_or_exit(struct usbback_gw *gw, int exit)
+{
+	int return_value = 0;
+	u32 i;
+	trace();
+	if (exit)
+		goto exit_path;
+	INIT_LIST_HEAD(&gw->target_rsrc_list);
+	for (i = 0; i < USBIF_QUOTA; i++) {
+		struct usbback_gw_rsrc *rsrc = &gw->target_rsrcs[i];
+		usbback_gw_rsrc_init(rsrc, gw,
+					usbback_gw_kick_channel_messages_2);
+		list_add_tail(usbback_gw_rsrc_to_link(rsrc),
+					&gw->target_rsrc_list);
+	}
+	spin_lock_init(&gw->lock);
+	gw->state = usbback_gw_state_i;
+	INIT_LIST_HEAD(&gw->channel_message_list);
+	usbback_work_init(&gw->kick_channel_messages_1_work,
+			usbback_gw_kick_channel_messages_1, gw);
+	usbback_work_init(&gw->connect_client_1_work,
+			usbback_gw_connect_client_1, gw);
+	usbback_work_init(&gw->disconnect_client_1_work,
+			usbback_gw_disconnect_client_1, gw);
+	usbback_callback_init(&gw->disconnect_client_2_callback,
+			usbback_gw_disconnect_client_2);
+	gw->kick_channel_messages_out = 0;
+	gw->target_rsrcs_out = 0;
+	return 0;
+ exit_path:
+	return return_value;
+}
+
+int usbback_gw_init(struct usbback_gw *gw, struct usbback_channel *channel,
+usbback_gw_connect_function *connect,
+usbback_gw_handle_tra_function *handle_tra,
+usbback_gw_disconnect_function *disconnect)
+{
+	trace();
+	gw->channel = channel;
+	gw->connect = connect;
+	gw->handle_tra = handle_tra;
+	gw->disconnect = disconnect;
+	usbback_channel_install_client(channel, gw,
+					usbback_gw_channel_connect,
+					usbback_gw_handle_channel_message,
+					usbback_gw_channel_disconnect);
+	return usbback_gw_init_or_exit(gw, 0);
+}
+
+void usbback_gw_exit(struct usbback_gw *gw)
+{
+	trace();
+	(void)usbback_gw_init_or_exit(gw, 1);
+}
+
+static void
+usbback_gw_handle_stimulus(struct usbback_gw *gw,
+usbback_gw_stimulus stimulus)
+{
+	switch (gw->state) {
+	case usbback_gw_state_i:
+		/* Channel disconnected.       */
+		/* Client disconnected.        */
+		/* No channel messages queued. */
+		/* Target rsrcs idle.          */
+		/* Not kicking cm.             */
+		switch (stimulus) {
+		case usbback_gw_stimulus_cc:
+			gw->state = usbback_gw_state_i_cc;
+			usbback_gw_connect_client(gw);
+			break;
+		default:
+			usbback_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbback_gw_state_i_cc:
+		/* Channel connected.             */
+		/* Client connecting.             */
+		/* Maybe channel messages queued. */
+		/* Target rsrcs idle.             */
+		/* Not kicking cm.                */
+		switch (stimulus) {
+		case usbback_gw_stimulus_cm:
+			break;
+		case usbback_gw_stimulus_cd:
+			gw->state = usbback_gw_state_i_cc_cd;
+			usbback_gw_complete_channel_messages(gw);
+			break;
+		case usbback_gw_stimulus_lc:
+			gw->state = usbback_gw_state_i_cc_lc;
+			usbback_gw_kick_channel_messages(gw);
+			break;
+		default:
+			usbback_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbback_gw_state_i_cc_cd:
+		/* Channel disconnecting.      */
+		/* Client connecting.          */
+		/* No channel messages queued. */
+		/* Target rsrcs idle.          */
+		/* Not kicking cm.             */
+		switch (stimulus) {
+		case usbback_gw_stimulus_lc:
+			gw->state = usbback_gw_state_i_cc_cd_lc;
+			usbback_gw_disconnect_client(gw);
+			break;
+		default:
+			usbback_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbback_gw_state_i_cc_lc:
+		/* Channel connected.             */
+		/* Client connected.              */
+		/* Maybe channel messages queued. */
+		/* Maybe target rsrcs busy.       */
+		/* Maybe kicking cm.              */
+		switch (stimulus) {
+		case usbback_gw_stimulus_cm:
+			usbback_gw_kick_channel_messages(gw);
+			break;
+		case usbback_gw_stimulus_cd:
+			gw->state = usbback_gw_state_i_cc_lc_cd;
+			usbback_gw_complete_channel_messages(gw);
+			usbback_gw_kick_channel_messages(gw);
+			break;
+		case usbback_gw_stimulus_kc:
+			break;
+		case usbback_gw_stimulus_tc:
+		case usbback_gw_stimulus_ti:
+			usbback_gw_kick_channel_messages(gw);
+			break;
+		default:
+			usbback_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbback_gw_state_i_cc_lc_cd:
+		/* Channel disconnecting.      */
+		/* Client connected.           */
+		/* No channel messages queued. */
+		/* Maybe target rsrcs busy.    */
+		/* Kicking cm.                 */
+		switch (stimulus) {
+		case usbback_gw_stimulus_kc:
+			gw->state = usbback_gw_state_i_cc_cd_lc;
+			usbback_gw_disconnect_client(gw);
+			break;
+		case usbback_gw_stimulus_tc:
+		case usbback_gw_stimulus_ti:
+			break;
+		default:
+			usbback_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbback_gw_state_i_cc_cd_lc:
+		/* Channel disconnecting.      */
+		/* Calling client disconnect.  */
+		/* No channel messages queued. */
+		/* Maybe target rsrcs busy.    */
+		/* Not kicking cm.             */
+		switch (stimulus) {
+		case usbback_gw_stimulus_tc:
+		case usbback_gw_stimulus_ti:
+			break;
+		case usbback_gw_stimulus_lg:
+			gw->state = usbback_gw_state_i_cc_cd_lc_lg;
+			break;
+		case usbback_gw_stimulus_ld:
+			gw->state = usbback_gw_state_i_cc_cd_lc_ld;
+			break;
+		default:
+			usbback_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbback_gw_state_i_cc_cd_lc_lg:
+		/* Channel disconnecting.      */
+		/* Client disconnecting.       */
+		/* No channel messages queued. */
+		/* Maybe target rsrcs busy.    */
+		/* Not kicking cm.             */
+		switch (stimulus) {
+		case usbback_gw_stimulus_tc:
+		case usbback_gw_stimulus_ti:
+			break;
+		case usbback_gw_stimulus_ld:
+			gw->state = usbback_gw_state_i_cc_cd_lc_lg_ld;
+			usbback_gw_test_target_rsrcs(gw);
+			break;
+		default:
+			usbback_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbback_gw_state_i_cc_cd_lc_ld:
+		/* Channel disconnecting.                          */
+		/* Client disconnected but call still in progress. */
+		/* No channel messages queued.                     */
+		/* Maybe target rsrcs busy.                        */
+		/* Not kicking cm.                                 */
+		switch (stimulus) {
+		case usbback_gw_stimulus_tc:
+		case usbback_gw_stimulus_ti:
+			break;
+		case usbback_gw_stimulus_lg:
+			gw->state =
+					usbback_gw_state_i_cc_cd_lc_lg_ld;
+			usbback_gw_test_target_rsrcs(gw);
+			break;
+		default:
+			usbback_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbback_gw_state_i_cc_cd_lc_lg_ld:
+		/* Channel disconnecting.                  */
+		/* Client disconnected.                    */
+		/* No channel messages queued.             */
+		/* Test target rsrcs or target rsrcs busy. */
+		/* Not kicking cm.                         */
+		switch (stimulus) {
+		case usbback_gw_stimulus_tc:
+			break;
+		case usbback_gw_stimulus_ti:
+			gw->state = usbback_gw_state_i;
+			usbback_gw_complete_channel_disconnect(gw);
+			break;
+		default:
+			usbback_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	default:
+		usbback_gw_invalid_stimulus(gw, stimulus);
+		break;
+	}
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_gw.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_gw.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,163 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_GW_H
+#define USBBACK_GW_H
+
+#include <linux/types.h>
+#include <xen/interface/io/usbif.h>
+#include "usbback_callback.h"
+#include "usbback_channel.h"
+
+struct usbback_gw_rsrc;
+
+struct usbback_gw_tra {
+	struct usbback_callback callback;
+	union usbif_parameters  parameters;
+	union usbif_status      status;
+};
+
+static inline struct usbback_callback *
+usbback_gw_tra_to_callback(struct usbback_gw_tra *tra)
+{
+	return &tra->callback;
+}
+
+static inline struct usbback_gw_tra *
+usbback_gw_tra_callback_to(struct usbback_callback *callback)
+{
+	return container_of(callback, struct usbback_gw_tra, callback);
+}
+
+static inline struct list_head *
+usbback_gw_tra_to_link(struct usbback_gw_tra *tra)
+{
+	return usbback_callback_to_link(usbback_gw_tra_to_callback(tra));
+}
+
+static inline struct usbback_gw_tra *
+usbback_gw_tra_link_to(struct list_head *link)
+{
+	return usbback_gw_tra_callback_to(usbback_callback_link_to(link));
+}
+
+static inline void
+usbback_gw_tra_init(struct usbback_gw_tra *tra,
+usbback_callback_function *callback)
+{
+	usbback_callback_init(usbback_gw_tra_to_callback(tra), callback);
+}
+
+static inline void
+usbback_gw_tra_complete(struct usbback_gw_tra *tra, usbif_error error)
+{
+	usbback_callback_complete(usbback_gw_tra_to_callback(tra), error);
+}
+
+static inline
+usbif_error usbback_gw_tra_query_error(struct usbback_gw_tra *tra)
+{
+	return usbback_callback_query_error(usbback_gw_tra_to_callback(tra));
+}
+
+struct usbback_gw_rsrc {
+	struct usbback_callback      callback;
+	struct usbback_gw           *gw;
+	struct usbback_gw_tra        tra;
+	struct usbback_channel_obmsg channel_message;
+};
+
+static inline struct list_head *
+usbback_gw_rsrc_to_link(struct usbback_gw_rsrc *rsrc)
+{
+	return &rsrc->callback.work.link;
+}
+
+static inline struct usbback_gw_rsrc *
+usbback_gw_rsrc_callback_to(struct usbback_callback *callback)
+{
+	return container_of(callback, struct usbback_gw_rsrc, callback);
+}
+
+static inline struct usbback_gw *
+usbback_gw_rsrc_query_gw(struct usbback_gw_rsrc *rsrc)
+{
+	return rsrc->gw;
+}
+
+void
+usbback_gw_rsrc_init(struct usbback_gw_rsrc *rsrc, struct usbback_gw *gw,
+usbback_callback_function callback);
+
+void
+usbback_gw_rsrc_start_tra(struct usbback_gw_rsrc *rsrc,
+struct usbif_request *request);
+
+typedef enum {
+	usbback_gw_state_i,
+	usbback_gw_state_i_cc,
+	usbback_gw_state_i_cc_cd,
+	usbback_gw_state_i_cc_lc,
+	usbback_gw_state_i_cc_lc_cd,
+	usbback_gw_state_i_cc_cd_lc,
+	usbback_gw_state_i_cc_cd_lc_lg,
+	usbback_gw_state_i_cc_cd_lc_ld,
+	usbback_gw_state_i_cc_cd_lc_lg_ld
+} usbback_gw_state;
+
+struct usbback_gw;
+
+typedef void usbback_gw_connect_function(struct usbback_gw *gw);
+
+typedef void
+usbback_gw_handle_tra_function(struct usbback_gw *gw,
+struct usbback_gw_tra *tra);
+
+typedef void
+usbback_gw_disconnect_function(struct usbback_gw *gw,
+struct usbback_callback *callback);
+
+struct usbback_gw {
+	struct usbback_channel         *channel;
+	usbback_gw_connect_function    *connect;
+	usbback_gw_handle_tra_function *handle_tra;
+	usbback_gw_disconnect_function *disconnect;
+	struct list_head                target_rsrc_list;
+	struct usbback_gw_rsrc          target_rsrcs[USBIF_QUOTA];
+	spinlock_t                      lock;
+	usbback_gw_state                state;
+	struct list_head                channel_message_list;
+	struct usbback_work             kick_channel_messages_1_work;
+	struct usbback_work             connect_client_1_work;
+	struct usbback_work             disconnect_client_1_work;
+	struct usbback_callback         disconnect_client_2_callback;
+	int                             kick_channel_messages_out:1;
+	u32                             target_rsrcs_out;
+	struct usbback_callback        *channel_disconnect_callback;
+};
+
+int
+usbback_gw_init(struct usbback_gw *gw, struct usbback_channel *channel,
+usbback_gw_connect_function *connect,
+usbback_gw_handle_tra_function *handle_tra,
+usbback_gw_disconnect_function *disconnect);
+
+extern void usbback_gw_exit(struct usbback_gw *gw);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_gw_resource.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_gw_resource.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,75 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include "usbback_gw.h"
+#include "usbback_trace.h"
+
+void
+usbback_gw_submit_channel_message(struct usbback_gw *gw,
+struct usbback_channel_obmsg *message);
+
+void
+usbback_gw_submit_tra_to_client(struct usbback_gw *gw,
+struct usbback_gw_tra *tra);
+
+void
+usbback_gw_rsrc_start_tra(struct usbback_gw_rsrc *rsrc,
+struct usbif_request *request)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	rsrc->tra.parameters = request->usbif_parameters;
+	memset(&rsrc->tra.status,0, sizeof(rsrc->tra.status));
+	rsrc->channel_message.response.gw_status.id =
+						request->gw_parameters.id;
+	usbback_gw_submit_tra_to_client(rsrc->gw, &rsrc->tra);
+}
+
+static void
+usbback_gw_rsrc_tra_callback(struct usbback_callback *callback)
+{
+	struct usbback_gw_rsrc *rsrc = container_of(
+		usbback_gw_tra_callback_to(callback),
+		struct usbback_gw_rsrc, tra);
+	rsrc->channel_message.response.gw_status.error =
+					usbback_callback_query_error(callback);
+	rsrc->channel_message.response.usbif_status = rsrc->tra.status;
+	usbback_gw_submit_channel_message(rsrc->gw, &rsrc->channel_message);
+}
+
+static void
+usbback_gw_rsrc_channel_message_callback(struct usbback_callback *callback)
+{
+	struct usbback_gw_rsrc *rsrc = container_of(
+				usbback_channel_obmsg_callback_to(callback),
+				struct usbback_gw_rsrc,
+				channel_message);
+	usbback_callback_success(&rsrc->callback);
+}
+
+void
+usbback_gw_rsrc_init(struct usbback_gw_rsrc *rsrc, struct usbback_gw *gw,
+usbback_callback_function callback)
+{
+	trace();
+	usbback_callback_init(&rsrc->callback, callback);
+	rsrc->gw = gw;
+	usbback_gw_tra_init(&rsrc->tra, usbback_gw_rsrc_tra_callback);
+	usbback_channel_obmsg_init(&rsrc->channel_message,
+				usbback_gw_rsrc_channel_message_callback);
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_rbr_mapper_pool.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_rbr_mapper_pool.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,347 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/module.h>
+#include "usbback_rbr_mapper_pool.h"
+#include "usbback_trace.h"
+
+static USBBACK_CALLBACK_SERIALISER(callback_serialiser);
+
+struct usbback_rbr_mapper_pool {
+	struct usbback_buffer_rsrc_list      dedicated_rsrcs;
+	struct usbback_buffer_rsrc_provider *provider;
+	spinlock_t                           lock;
+	struct usbback_buffer_rsrc_list      head_request_rqm;
+	struct list_head                     request_list;
+	int                                  kicking_requests;
+	int                                  head_request_rqm_calculated;
+};
+
+static int usbback_rbr_mapper_pool_calc_rbr_rqm(struct usbif_rbr *rbr,
+struct usbback_buffer_rsrc_list *list)
+{
+	int request_invalid = 0;
+	trace();
+	*list = usbback_buffer_rsrc_list_null();
+	if (rbr->byte_count != 0) {
+		if ((rbr->byte_offset < (USBIF_GRANT_TABLE_REFERENCE_COUNT *
+				PAGE_SIZE)) && (rbr->byte_count <=
+				((USBIF_GRANT_TABLE_REFERENCE_COUNT *
+				PAGE_SIZE) - rbr->byte_offset))) {
+			unsigned long first_page, final_page;
+			list->page_ranges = 1;
+			first_page = rbr->byte_offset / PAGE_SIZE;
+			final_page = (rbr->byte_offset + rbr->byte_count - 1) /
+								PAGE_SIZE;
+			list->page_range_page_count = final_page -
+								first_page + 1;
+		} else {
+			request_invalid = 1;
+		}
+	}
+	return request_invalid;
+}
+
+static int
+usbback_rbr_mapper_pool_calc_rqm(struct usbback_rbr_mapper_request *request,
+struct usbback_buffer_rsrc_list *list)
+{
+	struct usbback_rbr_mapper_element *element;
+	trace();
+	*list = usbback_buffer_rsrc_list_null();
+	list_for_each_entry(element, &request->request_elements, link) {
+		struct usbback_buffer_rsrc_list element_list;
+		if (usbback_rbr_mapper_pool_calc_rbr_rqm(&element->rbr,
+							&element_list) != 0)
+			return 1;
+		usbback_buffer_rsrc_list_plus_equals(list, &element_list);
+	}
+	return 0;
+}
+
+static void
+usbback_rbr_mapper_pool_unmap_rbr(struct usbback_rbr_context *context)
+{
+	struct gnttab_unmap_grant_ref unmap[USBIF_GRANT_TABLE_REFERENCE_COUNT];
+	int i;
+	trace();
+	for (i = 0; i < context->page_count; i++) {
+		unmap[i].host_addr = context->mmap_vaddress + (i * PAGE_SIZE);
+		unmap[i].dev_bus_addr = 0;
+		unmap[i].handle = context->handle[i];
+	}
+	if (context->page_count != 0) {
+		int error = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref,
+						unmap, context->page_count);
+		BUG_ON(error);
+	}
+	for (i = 0; i < context->page_count; i++) {
+		set_phys_to_machine(__pa(context->mmap_vaddress + (i *
+				PAGE_SIZE)) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
+	}
+	if (context->mmap_vaddress != 0)
+		usbback_buffer_rsrc_provider_free_page_range(
+				context->provider, context->mmap_vaddress);
+}
+
+static int
+usbback_rbr_mapper_pool_map_rbr(struct usbif_rbr *rbr, domid_t domain,
+struct usbback_buffer_rsrc_provider *provider, void **mapping,
+int access_flags, struct usbback_rbr_context *context)
+{
+	struct gnttab_map_grant_ref map[USBIF_GRANT_TABLE_REFERENCE_COUNT];
+	unsigned long first_page, final_page, page_count;
+	int i, j, error;
+	uint16_t map_flags = GNTMAP_host_map | (((access_flags &
+		USBBACK_ACCESS_FLAGS_WRITE) == 0) ? GNTMAP_readonly : 0);
+	trace();
+	if (rbr->byte_count == 0) {
+		context->page_count    = 0;
+		context->mmap_vaddress = 0;
+		*mapping               = NULL;
+		return 0;
+	}
+	first_page = rbr->byte_offset / PAGE_SIZE;
+	final_page = (rbr->byte_offset + rbr->byte_count - 1) / PAGE_SIZE;
+	page_count = final_page - first_page + 1;
+	context->provider = provider;
+	context->page_count = page_count;
+	context->mmap_vaddress =
+			usbback_buffer_rsrc_provider_allocate_page_range(
+						provider, page_count);
+	for (i = 0; i < page_count; i++) {
+		map[i].host_addr = context->mmap_vaddress + (i * PAGE_SIZE);
+		map[i].dom       = domain;
+		map[i].ref       = rbr->reference[first_page + i];
+		map[i].flags     = map_flags;
+	}
+	error = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map,
+								page_count);
+	BUG_ON(error);
+	for (i = 0, j = 0; i < page_count; i++) {
+		if (likely(map[i].status == 0)) {
+			context->handle[j] = map[i].handle;
+			set_phys_to_machine(__pa(context->mmap_vaddress +
+							(j * PAGE_SIZE))
+					     >> PAGE_SHIFT,
+					     FOREIGN_FRAME(map[i].dev_bus_addr
+							       >> PAGE_SHIFT));
+			j++;
+		} else {
+			error = 1;
+			context->page_count--;
+		}
+	}
+	if (error) {
+		usbback_rbr_mapper_pool_unmap_rbr(context);
+		return -EINVAL;
+	}
+	*mapping = (void *)(context->mmap_vaddress + (rbr->byte_offset %
+								PAGE_SIZE));
+	return 0;
+}
+
+static void
+usbback_rbr_mapper_pool_service_request(
+struct usbback_rbr_mapper_pool *pool,
+struct usbback_rbr_mapper_request *request)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	int error = 0;
+	struct usbback_rbr_mapper_element *element;
+	trace();
+	list_for_each_entry(element, &request->request_elements, link) {
+		if (!error) {
+			error = usbback_rbr_mapper_pool_map_rbr(&element->rbr,
+					request->domain, pool->provider,
+					&element->mapping,
+					element->access_flags,
+					&element->context);
+			if (!error)
+				element->mapped = 1;
+		} else {
+			element->mapped = 0;
+		}
+	}
+	if (error)
+		goto error_path;
+	usbback_callback_serialiser_complete_callback(&callback_serialiser,
+		usbback_rbr_mapper_request_to_map_callback(request),
+		USBIF_ERROR_SUCCESS);
+	return;
+ error_path:
+	list_for_each_entry(element, &request->request_elements, link) {
+		if (element->mapped)
+			usbback_rbr_mapper_pool_unmap_rbr(&element->context);
+	}
+	usbback_callback_serialiser_complete_callback(&callback_serialiser,
+	     usbback_rbr_mapper_request_to_map_callback(request),
+	     usbif_error_map_local_to(error));
+}
+
+static void usbback_rbr_mapper_pool_kick_requests(
+struct usbback_rbr_mapper_pool *pool)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&pool->lock, flags);
+	while (!pool->kicking_requests && !list_empty(&pool->request_list)) {
+		struct usbback_rbr_mapper_request *request =
+				usbback_rbr_mapper_request_link_to(
+						pool->request_list.next);
+		struct usbback_buffer_rsrc_list free_rsrcs;
+		if (pool->head_request_rqm_calculated)
+			goto skip_calc;
+		if ((usbback_rbr_mapper_pool_calc_rqm(request,
+				&pool->head_request_rqm) != 0) ||
+				!usbback_buffer_rsrc_list_subset_of(
+				&pool->head_request_rqm,
+				&pool->dedicated_rsrcs)) {
+			list_del_init(usbback_rbr_mapper_request_to_link(
+								request));
+			usbback_callback_serialiser_complete_callback(
+				&callback_serialiser,
+				usbback_rbr_mapper_request_to_map_callback(
+								request),
+				USBIF_ERROR_TOO_BIG);
+			continue;
+		}
+		pool->head_request_rqm_calculated = 1;
+	skip_calc:
+		free_rsrcs = usbback_buffer_rsrc_provider_query_free_rsrcs(
+							pool->provider);
+		if (!usbback_buffer_rsrc_list_subset_of(
+				&pool->head_request_rqm, &free_rsrcs))
+			break;
+		list_del_init(usbback_rbr_mapper_request_to_link(request));
+		pool->head_request_rqm_calculated = 0;
+		pool->kicking_requests = 1;
+		spin_unlock_irqrestore(&pool->lock, flags);
+		usbback_rbr_mapper_pool_service_request(pool, request);
+		spin_lock_irqsave(&pool->lock, flags);
+		pool->kicking_requests = 0;
+	}
+	spin_unlock_irqrestore(&pool->lock, flags);
+}
+
+void
+usbback_rbr_mapper_pool_reserve_and_map_rbrs(
+struct usbback_rbr_mapper_pool *pool,
+struct usbback_rbr_mapper_request *request, domid_t domain)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	unsigned long flags;
+	trace();
+	request->pool = pool;
+	request->domain = domain;
+	spin_lock_irqsave(&pool->lock, flags);
+	list_add_tail(usbback_rbr_mapper_request_to_link(request),
+							&pool->request_list);
+	spin_unlock_irqrestore(&pool->lock, flags);
+	usbback_rbr_mapper_pool_kick_requests(pool);
+}
+
+void
+usbback_rbr_mapper_pool_abort_reserve_and_map_rbrs(
+struct usbback_rbr_mapper_request *request, usbif_error error)
+{
+	struct usbback_rbr_mapper_pool *pool = request->pool;
+	struct usbback_rbr_mapper_request *queued_request;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&pool->lock, flags);
+	list_for_each_entry(queued_request, &pool->request_list,
+					map_callback.work.link) {
+		if (request == queued_request) {
+			list_del_init(usbback_rbr_mapper_request_to_link(
+								request));
+			pool->head_request_rqm_calculated = 0;
+			usbback_callback_serialiser_complete_callback(
+				&callback_serialiser,
+				usbback_rbr_mapper_request_to_map_callback(
+							request),
+				error);
+			break;
+		}
+	}
+	spin_unlock_irqrestore(&pool->lock, flags);
+}
+
+void usbback_rbr_mapper_pool_unmap_and_unreserve_rbrs(
+struct usbback_rbr_mapper_request *request)
+{
+	struct usbback_rbr_mapper_element *element;
+	trace();
+	list_for_each_entry(element, &request->request_elements, link) {
+		usbback_rbr_mapper_pool_unmap_rbr(&element->context);
+	}
+	usbback_rbr_mapper_pool_kick_requests(request->pool);
+	usbback_callback_serialiser_complete_callback(&callback_serialiser,
+	     usbback_rbr_mapper_request_to_unmap_callback(request),
+	     USBIF_ERROR_SUCCESS);
+}
+
+static int
+usbback_rbr_mapper_pool_init_or_exit(struct usbback_rbr_mapper_pool *pool,
+int exit)
+{
+	int return_value = 0;
+	trace();
+	if (exit)
+		goto exit;
+	pool->provider = usbback_allocate_buffer_rsrc_provider(
+							pool->dedicated_rsrcs);
+	if (pool->provider == NULL)
+		goto exit_no_provider;
+	spin_lock_init(&pool->lock);
+	INIT_LIST_HEAD(&pool->request_list);
+	pool->kicking_requests = 0;
+	pool->head_request_rqm_calculated = 0;
+	return 0;
+ exit:
+	usbback_free_buffer_rsrc_provider(pool->provider);
+ exit_no_provider:
+	return return_value;
+}
+
+struct usbback_rbr_mapper_pool * usbback_rbr_mapper_pool_allocate(void)
+{
+	struct usbback_rbr_mapper_pool *pool;
+	trace();
+	pool = (struct usbback_rbr_mapper_pool *)kmalloc(sizeof(
+				struct usbback_rbr_mapper_pool),GFP_KERNEL);
+	if (pool != NULL) {
+		pool->dedicated_rsrcs.page_ranges = USBIF_QUOTA;
+		pool->dedicated_rsrcs.page_range_page_count =
+			USBIF_GRANT_TABLE_REFERENCE_COUNT;
+		if (usbback_rbr_mapper_pool_init_or_exit(pool, 0) != 0) {
+			kfree(pool);
+			pool = NULL;
+		}
+	}
+	return pool;
+}
+
+void usbback_rbr_mapper_pool_free(struct usbback_rbr_mapper_pool *pool)
+{
+	trace();
+	(void)usbback_rbr_mapper_pool_init_or_exit(pool, 1);
+	kfree(pool);
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_rbr_mapper_pool.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_rbr_mapper_pool.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,155 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_RBR_MAPPER_POOL_H
+#define USBBACK_RBR_MAPPER_POOL_H
+
+#include "usbback_callback.h"
+#include "usbback_buffer_resource_provider.h"
+
+struct usbback_rbr_mapper_pool;
+
+struct usbback_rbr_mapper_pool *usbback_rbr_mapper_pool_allocate(void);
+
+void usbback_rbr_mapper_pool_free(struct usbback_rbr_mapper_pool *pool);
+
+#define USBBACK_ACCESS_FLAGS_READ  1
+#define USBBACK_ACCESS_FLAGS_WRITE 2
+
+struct usbback_rbr_context {
+	struct usbback_buffer_rsrc_provider *provider;
+	unsigned long                        page_count;
+	unsigned long                        mmap_vaddress;
+	grant_handle_t handle[USBIF_GRANT_TABLE_REFERENCE_COUNT];
+};
+
+struct usbback_rbr_mapper_element {
+	struct list_head            link;
+	struct usbif_rbr            rbr;
+	int                         access_flags;
+	int                         mapped;
+	void                       *mapping;
+	struct usbback_rbr_context  context;
+};
+
+static inline void
+usbback_rbr_mapper_element_init(struct usbback_rbr_mapper_element *element)
+{
+	memset(element, 0, sizeof(*element));
+	INIT_LIST_HEAD(&element->link);
+}
+
+static inline void
+usbback_rbr_mapper_element_set_rbr(struct usbback_rbr_mapper_element *element,
+struct usbif_rbr rbr, int access_flags)
+{
+	element->rbr          = rbr;
+	element->access_flags = access_flags;
+}
+
+static inline void usbback_rbr_mapper_element_ensure_removed(
+struct usbback_rbr_mapper_element *element)
+{
+	list_del_init(&element->link);
+}
+
+struct usbback_rbr_mapper_request {
+	struct usbback_callback         map_callback;
+	struct usbback_callback         unmap_callback;
+	struct usbback_rbr_mapper_pool *pool;
+	domid_t				domain;
+	struct list_head                request_elements;
+};
+
+static inline struct usbback_callback *
+usbback_rbr_mapper_request_to_map_callback(
+struct usbback_rbr_mapper_request *request)
+{
+	return &request->map_callback;
+}
+
+static inline struct usbback_rbr_mapper_request *
+usbback_rbr_mapper_request_map_callback_to(
+struct usbback_callback *callback)
+{
+	return container_of(callback, struct usbback_rbr_mapper_request,
+							map_callback);
+}
+
+static inline struct usbback_callback *
+usbback_rbr_mapper_request_to_unmap_callback(
+struct usbback_rbr_mapper_request *request)
+{
+	return &request->unmap_callback;
+}
+
+static inline struct usbback_rbr_mapper_request *
+usbback_rbr_mapper_request_unmap_callback_to(
+struct usbback_callback *callback)
+{
+	return container_of(callback, struct usbback_rbr_mapper_request,
+							unmap_callback);
+}
+
+static inline struct list_head *
+usbback_rbr_mapper_request_to_link(struct usbback_rbr_mapper_request *request)
+{
+	return usbback_callback_to_link(
+			usbback_rbr_mapper_request_to_map_callback(request));
+}
+
+static inline struct usbback_rbr_mapper_request *
+usbback_rbr_mapper_request_link_to(struct list_head *link)
+{
+	return usbback_rbr_mapper_request_map_callback_to(
+					usbback_callback_link_to(link));
+}
+
+static inline void
+usbback_rbr_mapper_request_init(struct usbback_rbr_mapper_request *request,
+usbback_callback_function *map_callback,
+usbback_callback_function *unmap_callback)
+{
+	usbback_callback_init(&request->map_callback, map_callback);
+	usbback_callback_init(&request->unmap_callback, unmap_callback);
+	INIT_LIST_HEAD(&request->request_elements);
+}
+
+static inline void
+usbback_rbr_mapper_request_add_element(
+struct usbback_rbr_mapper_request *request,
+struct usbback_rbr_mapper_element *element)
+{
+	list_add(&element->link, &request->request_elements);
+}
+
+void
+usbback_rbr_mapper_pool_reserve_and_map_rbrs(
+struct usbback_rbr_mapper_pool *pool,
+struct usbback_rbr_mapper_request *request, domid_t domain);
+
+void
+usbback_rbr_mapper_pool_abort_reserve_and_map_rbrs(
+struct usbback_rbr_mapper_request *request, usbif_error error);
+
+void
+usbback_rbr_mapper_pool_unmap_and_unreserve_rbrs(
+struct usbback_rbr_mapper_request *request);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_resource.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_resource.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,655 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Based on arch/xen/drivers/usbif/backend/main.c, original copyright notice */
+/* follows...                                                                */
+/*****************************************************************************/
+
+/******************************************************************************
+ * arch/xen/drivers/usbif/backend/main.c
+ * 
+ * Backend for the Xen virtual USB driver - provides an abstraction of a
+ * USB host controller to the corresponding frontend driver.
+ *
+ * by Mark Williamson
+ * Copyright (c) 2004 Intel Research Cambridge
+ * Copyright (c) 2004, 2005 Mark Williamson
+ *
+ * Based on arch/xen/drivers/blkif/backend/main.c
+ * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
+ */
+
+#include <linux/usb.h>
+#include <xen/interface/io/usbif.h>
+#include "usbback_device.h"
+#include "usbback_rbr_mapper_pool.h"
+#include "usbback_resource.h"
+#include "usbback_trace.h"
+
+static USBBACK_CALLBACK_SERIALISER(submit_urb_serialiser);
+
+static struct usbback_rbr_mapper_pool *rbr_mapper_pool;
+
+int usbback_rsrc_class_init(void)
+{
+	trace();
+	rbr_mapper_pool = usbback_rbr_mapper_pool_allocate();
+	return (rbr_mapper_pool != NULL) ? 0 : -ENOMEM;
+}
+
+void usbback_rsrc_class_exit(void)
+{
+	trace();
+	usbback_rbr_mapper_pool_free(rbr_mapper_pool);
+}
+
+typedef enum {
+	usbback_rsrc_stimulus_st,	/* Start IO          */
+	usbback_rsrc_stimulus_tu,	/* Try unlink        */
+	usbback_rsrc_stimulus_ms,	/* Map success       */
+	usbback_rsrc_stimulus_mf,	/* Map failure       */
+	usbback_rsrc_stimulus_us,	/* URB submitted     */
+	usbback_rsrc_stimulus_un,	/* URB not submitted */
+	usbback_rsrc_stimulus_uc,	/* URB completed     */
+	usbback_rsrc_stimulus_ul,	/* Unlink completed  */
+} usbback_rsrc_stimulus;
+
+static void
+usbback_rsrc_handle_stimulus(struct usbback_rsrc *rsrc,
+usbback_rsrc_stimulus stimulus);
+
+void
+usbback_rsrc_start_io(struct usbback_rsrc *rsrc, struct usbback_gw_tra *tra)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&rsrc->lock, flags);
+	rsrc->tra_error = USBIF_ERROR_SUCCESS;
+	rsrc->tra = tra;
+	usbback_rsrc_handle_stimulus(rsrc,
+				usbback_rsrc_stimulus_st);
+	spin_unlock_irqrestore(&rsrc->lock, flags);
+}
+
+int usbback_rsrc_try_unlink(struct usbback_rsrc *rsrc, int unlink_id)
+{
+	int return_value = 0;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&rsrc->lock, flags);
+	if ((rsrc->tra != NULL) && (rsrc->tra->parameters.io.header.unlink_id
+							== unlink_id)) {
+		usbback_rsrc_handle_stimulus(rsrc, usbback_rsrc_stimulus_tu);
+		return_value = 1;
+	}
+	spin_unlock_irqrestore(&rsrc->lock, flags);
+	return return_value;
+}
+
+void usbback_rsrc_flush_tra(struct usbback_rsrc *rsrc)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&rsrc->lock, flags);
+	if (rsrc->tra != NULL)
+		usbback_rsrc_handle_stimulus(rsrc, usbback_rsrc_stimulus_tu);
+	spin_unlock_irqrestore(&rsrc->lock, flags);
+}
+
+
+static void usbback_rsrc_invalid_stimulus(struct usbback_rsrc *rsrc,
+usbback_rsrc_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbback: port rsrc %p in state %d received "
+		"invalid stimulus %d", rsrc, rsrc->state, stimulus);
+}
+
+static void usbback_rsrc_map_buffer(struct usbback_rsrc *rsrc)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbif_io_tra_parameters_header *header =
+				&rsrc->tra->parameters.io.header;
+	trace();
+	usbback_rbr_mapper_element_ensure_removed(&rsrc->request_element[0]);
+	usbback_rbr_mapper_element_ensure_removed(&rsrc->request_element[1]);
+	usbback_rbr_mapper_request_add_element(&rsrc->rbr_mapper_request,
+						&rsrc->request_element[0]);
+	usbback_rbr_mapper_element_set_rbr(&rsrc->request_element[0],
+		     header->rbr,
+		     (header->direction == USBIF_IO_TRA_DIRECTION_OUT) ?
+						USBBACK_ACCESS_FLAGS_READ :
+						USBBACK_ACCESS_FLAGS_WRITE);
+	if (header->io_tra_type == USBIF_IO_TRA_TYPE_ISOCHRONOUS) {
+		struct usbif_isochronous_io_tra_parameters *parameters=
+			&rsrc->tra->parameters.io.isochronous;
+		usbback_rbr_mapper_request_add_element(
+					&rsrc->rbr_mapper_request,
+					&rsrc->request_element[1]);
+		usbback_rbr_mapper_element_set_rbr(
+			&rsrc->request_element[1],
+			parameters->schedule_rbr,
+			USBBACK_ACCESS_FLAGS_READ |
+			USBBACK_ACCESS_FLAGS_WRITE);
+	}
+	usbback_rbr_mapper_pool_reserve_and_map_rbrs(rbr_mapper_pool,
+			&rsrc->rbr_mapper_request,
+			usbback_device_query_remote_domain(rsrc->device));
+	return;
+}
+
+static void usbback_rsrc_abort_map(struct usbback_rsrc *rsrc)
+{
+	trace();
+	usbback_rbr_mapper_pool_abort_reserve_and_map_rbrs(
+				&rsrc->rbr_mapper_request,
+				USBIF_ERROR_UNLINKED);
+}
+
+static void usbback_rsrc_map_callback(struct usbback_callback * callback)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbback_rbr_mapper_request *request =
+			usbback_rbr_mapper_request_map_callback_to(
+								callback);
+	struct usbback_rsrc *rsrc = container_of(request,
+			struct usbback_rsrc,
+			rbr_mapper_request);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&rsrc->lock, flags);
+	rsrc->tra_error = usbback_callback_query_error(callback);
+	if (rsrc->tra_error == USBIF_ERROR_SUCCESS) {
+		rsrc->rbrs_mapped = 1;
+		usbback_rsrc_handle_stimulus(rsrc,
+				usbback_rsrc_stimulus_ms);
+	} else {
+		trace_info("failed to map FE buffer");
+		usbback_rsrc_handle_stimulus(rsrc,
+				usbback_rsrc_stimulus_mf);
+	}
+	spin_unlock_irqrestore(&rsrc->lock, flags);
+}
+
+static void usbback_rsrc_submit_urb(struct usbback_rsrc *rsrc)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	trace();
+	usbback_callback_serialiser_complete_callback(&submit_urb_serialiser,
+		&rsrc->submit_urb_1_callback, USBIF_ERROR_SUCCESS);
+}
+
+static void usbback_rsrc_end_io(struct urb *urb, struct pt_regs *regs);
+
+static int check_iso_schedule(struct urb *urb)
+{
+	int i;
+	unsigned long total_length = 0;
+	for (i = 0; i < urb->number_of_packets; i++) {
+		struct usb_iso_packet_descriptor *desc =
+						&urb->iso_frame_desc[i];
+		total_length += desc->length;
+		if ((desc->offset > urb->transfer_buffer_length) ||
+			(desc->length > (urb->transfer_buffer_length -
+							desc->offset)) ||
+			(total_length > urb->transfer_buffer_length))
+			return -EINVAL;
+	}
+	return 0;
+}
+
+static void usbback_rsrc_submit_urb_1(struct usbback_callback * callback)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	static const unsigned int pipe_type[4] = {
+		[USBIF_IO_TRA_TYPE_CONTROL]     = PIPE_CONTROL,
+		[USBIF_IO_TRA_TYPE_BULK]        = PIPE_BULK,
+		[USBIF_IO_TRA_TYPE_INTERRUPT]   = PIPE_INTERRUPT,
+		[USBIF_IO_TRA_TYPE_ISOCHRONOUS] = PIPE_ISOCHRONOUS
+	};
+	struct usbback_rsrc *rsrc = container_of(callback,
+			struct usbback_rsrc, submit_urb_1_callback);
+	union usbif_io_tra_parameters *io_parameters =
+			&rsrc->tra->parameters.io;
+	struct urb *urb = rsrc->urb;
+	struct usb_device * usbdev =
+				usbback_device_query_usbdev(rsrc->device);
+	unsigned int pipe;
+	unsigned long flags;
+	trace();
+	if (io_parameters->header.io_tra_type >= 4) {
+		rsrc->tra_error = USBIF_ERROR_INVALID_PARAMETER;
+		goto protocol_error;
+	}
+	if (io_parameters->header.io_tra_type ==
+					USBIF_IO_TRA_TYPE_CONTROL) {
+		struct usb_ctrlrequest *ctrl = (struct usb_ctrlrequest *)
+						io_parameters->control.setup;
+		if (ctrl->bRequestType == (USB_DIR_OUT | USB_TYPE_STANDARD |
+							USB_RECIP_DEVICE)) {
+			if (ctrl->bRequest == USB_REQ_SET_ADDRESS) {
+				goto handled_special_case;
+			} else if (ctrl->bRequest ==
+						USB_REQ_SET_CONFIGURATION) {
+				/* FIXME: what to do for set configuration? */
+				goto handled_special_case;
+			}
+		}
+	}
+	if (io_parameters->header.direction ==
+					USBIF_IO_TRA_DIRECTION_OUT) {
+		pipe = USB_DIR_OUT;
+	} else {
+		pipe = USB_DIR_IN;
+	}
+	pipe |= (unsigned int)usbdev->devnum << 8;
+	pipe |= (unsigned int)io_parameters->header.endpoint << 15;
+	pipe |= pipe_type[io_parameters->header.io_tra_type] << 30;
+	if (io_parameters->header.io_tra_type ==
+					USBIF_IO_TRA_TYPE_CONTROL) {
+		memcpy(rsrc->setup, io_parameters->control.setup, sizeof(
+							rsrc->setup));
+		usb_fill_control_urb(urb, usbdev, pipe, rsrc->setup,
+				rsrc->request_element[0].mapping,
+				usbif_rbr_query_byte_count(&rsrc->
+						request_element[0].rbr),
+				usbback_rsrc_end_io, rsrc);
+	} else if(io_parameters->header.io_tra_type ==
+					USBIF_IO_TRA_TYPE_BULK) {
+		usb_fill_bulk_urb(urb, usbdev, pipe,
+					rsrc->request_element[0].mapping,
+					usbif_rbr_query_byte_count(
+					&rsrc->request_element[0].rbr),
+					usbback_rsrc_end_io,
+					rsrc);
+	} else if(io_parameters->header.io_tra_type ==
+					USBIF_IO_TRA_TYPE_INTERRUPT) {
+		/* FIXME: hacking the interval like this is a bit unclean. */
+		/* should probably convert back to exponential form for    */
+		/* high speed transfers and then pass the value into       */
+		/* fill_int_urb.                                           */
+		usb_fill_int_urb(urb, usbdev, pipe,
+				rsrc->request_element[0].mapping,
+				usbif_rbr_query_byte_count(&rsrc->
+						request_element[0].rbr),
+				usbback_rsrc_end_io, rsrc,
+				1 /* For the time being... */ );
+		/* ...now set the real value. */
+		urb->interval = io_parameters->interrupt.interval;
+	} else {
+		struct usbif_isochronous_io_schedule_element *schedule_element;
+		struct usbif_isochronous_io_schedule_element aligned_element;
+		int i;
+		/* FIXME: where's usb_fill_isoc_urb ?!? */
+		spin_lock_init(&urb->lock);
+		urb->dev = usbdev;
+		urb->pipe = pipe;
+		urb->transfer_buffer = rsrc->request_element[0].mapping;
+		urb->transfer_buffer_length = usbif_rbr_query_byte_count(
+					&rsrc->request_element[0].rbr);
+		urb->complete = usbback_rsrc_end_io;
+		urb->context = rsrc;
+		urb->number_of_packets =
+				io_parameters->isochronous.packet_count;
+		urb->interval = io_parameters->isochronous.interval;
+		urb->start_frame = 0;
+		urb->transfer_flags |= URB_ISO_ASAP;
+		if (io_parameters->isochronous.packet_count >
+					USBIF_MAX_SCHEDULE_PACKET_COUNT) {
+			rsrc->tra_error = USBIF_ERROR_TOO_BIG;
+			goto schedule_error;
+		}
+		if (usbif_rbr_query_byte_count(&rsrc->request_element[1].
+				rbr) < (io_parameters->isochronous.packet_count
+				* sizeof(struct
+				usbif_isochronous_io_schedule_element))) {
+			rsrc->tra_error =
+						USBIF_ERROR_INVALID_PARAMETER;
+			goto schedule_error;
+		}
+		schedule_element = rsrc->request_element[1].mapping;
+		for (i = 0; i < io_parameters->isochronous.packet_count; i++) {
+			memcpy(&aligned_element, schedule_element++,
+						sizeof(aligned_element));
+			urb->iso_frame_desc[i].offset = aligned_element.offset;
+			urb->iso_frame_desc[i].length = aligned_element.length;
+			urb->iso_frame_desc[i].actual_length = 0;
+			urb->iso_frame_desc[i].status = 0;
+		}
+		if (!check_iso_schedule(urb)) {
+			rsrc->tra_error =
+						USBIF_ERROR_INVALID_PARAMETER;
+			goto schedule_error;
+		}
+	}
+	if (io_parameters->header.flags & USBIF_IO_FLAGS_SHORT_NOT_OK)
+		urb->transfer_flags |= URB_SHORT_NOT_OK;
+	if (io_parameters->header.flags & USBIF_IO_FLAGS_ZERO_PACKET)
+		urb->transfer_flags |= URB_ZERO_PACKET;
+	rsrc->tra_error = usbif_error_map_local_to(usb_submit_urb(
+							urb, GFP_KERNEL));
+	if (rsrc->tra_error != USBIF_ERROR_SUCCESS) {
+		printk(KERN_WARNING "URB %p submission failed.\n", urb);
+		goto urb_error;
+	}
+	spin_lock_irqsave(&rsrc->lock, flags);
+	usbback_rsrc_handle_stimulus(rsrc,
+				usbback_rsrc_stimulus_us);
+	spin_unlock_irqrestore(&rsrc->lock, flags);
+	return;
+ urb_error:
+ schedule_error:
+ handled_special_case:
+ protocol_error:
+	spin_lock_irqsave(&rsrc->lock, flags);
+	usbback_rsrc_handle_stimulus(rsrc,
+				usbback_rsrc_stimulus_un);
+	spin_unlock_irqrestore(&rsrc->lock, flags);
+}
+
+static void usbback_rsrc_end_io(struct urb *urb, struct pt_regs *regs)
+{
+	struct usbback_rsrc *rsrc = urb->context;
+	unsigned long flags;
+	trace();
+	rsrc->tra_error = usbif_error_map_local_to(urb->status);
+	if (rsrc->tra_error != USBIF_ERROR_SUCCESS)
+		printk(KERN_WARNING "URB %p failed. Status %d\n", urb,
+								urb->status);
+	rsrc->tra->status.io.length = urb->actual_length;
+	if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+		struct usbif_isochronous_io_schedule_element *schedule_element
+				= rsrc->request_element[1].mapping;
+		struct usbif_isochronous_io_schedule_element aligned_element;
+		int i;
+		for (i = 0; i < urb->number_of_packets; i++) {
+			aligned_element.length = urb->iso_frame_desc[i].
+								actual_length;
+			aligned_element.error = usbif_error_map_local_to(
+						urb->iso_frame_desc[i].status);
+			memcpy(schedule_element++, &aligned_element,
+						sizeof(*schedule_element));
+		}
+	}
+	spin_lock_irqsave(&rsrc->lock, flags);
+	usbback_rsrc_handle_stimulus(rsrc,
+				usbback_rsrc_stimulus_uc);
+	spin_unlock_irqrestore(&rsrc->lock, flags);
+}
+
+static void usbback_rsrc_unlink_urb(struct usbback_rsrc *rsrc)
+{
+	trace();
+	usb_get_urb(rsrc->urb);
+	(void)usbback_work_schedule(&rsrc->unlink_urb_1_work);
+}
+
+static void usbback_rsrc_unlink_urb_1(void *data)
+{
+	struct usbback_rsrc *rsrc = data;
+	unsigned long flags;
+	trace();
+	usb_unlink_urb(rsrc->urb);
+	usb_put_urb(rsrc->urb);
+	spin_lock_irqsave(&rsrc->lock, flags);
+	usbback_rsrc_handle_stimulus(rsrc,
+				usbback_rsrc_stimulus_ul);
+	spin_unlock_irqrestore(&rsrc->lock, flags);
+}
+
+static void usbback_rsrc_set_unlinked_error(struct usbback_rsrc *rsrc)
+{
+	trace();
+	rsrc->tra_error = USBIF_ERROR_UNLINKED;
+}
+
+static void usbback_rsrc_complete(struct usbback_rsrc *rsrc)
+{
+	trace();
+	rsrc->completing_tra = rsrc->tra;
+	rsrc->tra = NULL;
+	if (rsrc->rbrs_mapped) {
+		rsrc->rbrs_mapped = 0;
+		usbback_rbr_mapper_pool_unmap_and_unreserve_rbrs(
+				&rsrc->rbr_mapper_request);
+	} else {
+		usbback_callback_success(
+			usbback_rbr_mapper_request_to_unmap_callback(
+				&rsrc->rbr_mapper_request));
+	}
+}
+
+static void usbback_rsrc_unmap_callback(struct usbback_callback * callback)
+{
+	struct usbback_rbr_mapper_request *request =
+		usbback_rbr_mapper_request_unmap_callback_to(callback);
+	struct usbback_rsrc *rsrc = container_of(request, struct usbback_rsrc,
+							rbr_mapper_request);
+	trace();
+	usbback_gw_tra_complete(rsrc->completing_tra, rsrc->tra_error);
+	usbback_device_rsrc_completed_io(rsrc->device, rsrc);
+}
+
+int usbback_rsrc_init(struct usbback_rsrc *rsrc, struct usbback_device *device)
+{
+	trace();
+	rsrc->device = device;
+	INIT_LIST_HEAD(&rsrc->link);
+	spin_lock_init(&rsrc->lock);
+	rsrc->state = usbback_rsrc_state_i;
+	rsrc->tra = NULL;
+	usbback_rbr_mapper_element_init(&rsrc->request_element[0]);
+	usbback_rbr_mapper_element_init(&rsrc->request_element[1]);
+	usbback_rbr_mapper_request_init(
+				&rsrc->rbr_mapper_request,
+				usbback_rsrc_map_callback,
+				usbback_rsrc_unmap_callback);
+	rsrc->rbrs_mapped = 0;
+	usbback_callback_init(&rsrc->submit_urb_1_callback,
+			usbback_rsrc_submit_urb_1);
+	usbback_work_init(&rsrc->unlink_urb_1_work,
+			usbback_rsrc_unlink_urb_1, rsrc);
+	rsrc->urb = usb_alloc_urb(USBIF_MAX_SCHEDULE_PACKET_COUNT, GFP_KERNEL);
+	return (rsrc->urb != NULL) ? 0 : -ENOMEM;
+}
+
+void usbback_rsrc_exit(struct usbback_rsrc *rsrc)
+{
+	trace();
+	usb_free_urb(rsrc->urb);
+}
+
+static void usbback_rsrc_handle_stimulus(struct usbback_rsrc *rsrc,
+usbback_rsrc_stimulus stimulus)
+{
+	trace();
+	switch (rsrc->state) {
+	case usbback_rsrc_state_i:
+		/* Idle */
+		switch (stimulus) {
+		case usbback_rsrc_stimulus_st:
+			rsrc->state = usbback_rsrc_state_i_st;
+			usbback_rsrc_map_buffer(rsrc);
+			break;
+		default:
+			usbback_rsrc_invalid_stimulus(rsrc, stimulus);
+			break;
+		}
+		break;
+	case usbback_rsrc_state_i_st:
+		/* Handling request       */
+		/* map_buffer outstanding */
+		switch (stimulus) {
+		case usbback_rsrc_stimulus_tu:
+			rsrc->state = usbback_rsrc_state_i_st_tu;
+			usbback_rsrc_abort_map(rsrc);
+			break;
+		case usbback_rsrc_stimulus_ms:
+			rsrc->state = usbback_rsrc_state_i_st_ms;
+			usbback_rsrc_submit_urb(rsrc);
+			break;
+		case usbback_rsrc_stimulus_mf:
+			rsrc->state = usbback_rsrc_state_i;
+			usbback_rsrc_complete(rsrc);
+			break;
+		default:
+			usbback_rsrc_invalid_stimulus(rsrc, stimulus);
+			break;
+		}
+		break;
+	case usbback_rsrc_state_i_st_tu:
+		/* Handling request       */
+		/* map_buffer outstanding */
+		/* unlinking              */
+		switch (stimulus) {
+		case usbback_rsrc_stimulus_tu:
+			break;
+		case usbback_rsrc_stimulus_ms:
+			rsrc->state = usbback_rsrc_state_i;
+			usbback_rsrc_set_unlinked_error(rsrc);
+			usbback_rsrc_complete(rsrc);
+			break;
+		case usbback_rsrc_stimulus_mf:
+			rsrc->state = usbback_rsrc_state_i;
+			usbback_rsrc_complete(rsrc);
+			break;
+		default:
+			usbback_rsrc_invalid_stimulus
+			    (rsrc, stimulus);
+			break;
+		}
+		break;
+	case usbback_rsrc_state_i_st_ms:
+		/* Handling request       */
+		/* submit_urb outstanding */
+		switch (stimulus) {
+		case usbback_rsrc_stimulus_tu:
+			rsrc->state = usbback_rsrc_state_i_st_ms_tu;
+			break;
+		case usbback_rsrc_stimulus_us:
+			rsrc->state = usbback_rsrc_state_i_st_ms_us;
+			break;
+		case usbback_rsrc_stimulus_un:
+			rsrc->state = usbback_rsrc_state_i;
+			usbback_rsrc_complete(rsrc);
+			break;
+		case usbback_rsrc_stimulus_uc:
+			rsrc->state = usbback_rsrc_state_i_st_ms_uc;
+			break;
+		default:
+			usbback_rsrc_invalid_stimulus(rsrc, stimulus);
+			break;
+		}
+		break;
+	case usbback_rsrc_state_i_st_ms_tu:
+		/* Handling request       */
+		/* submit_urb outstanding */
+		/* unlinking              */
+		switch (stimulus) {
+		case usbback_rsrc_stimulus_tu:
+			break;
+		case usbback_rsrc_stimulus_us:
+			rsrc->state = usbback_rsrc_state_i_st_ms_tu_us;
+			usbback_rsrc_unlink_urb(rsrc);
+			break;
+		case usbback_rsrc_stimulus_un:
+			rsrc->state = usbback_rsrc_state_i;
+			usbback_rsrc_complete(rsrc);
+			break;
+		case usbback_rsrc_stimulus_uc:
+			rsrc->state = usbback_rsrc_state_i_st_ms_uc;
+			break;
+		default:
+			usbback_rsrc_invalid_stimulus(rsrc, stimulus);
+			break;
+		}
+		break;
+	case usbback_rsrc_state_i_st_ms_us:
+		/* Handling request */
+		/* URB submitted    */
+		switch (stimulus) {
+		case usbback_rsrc_stimulus_tu:
+			rsrc->state = usbback_rsrc_state_i_st_ms_tu_us;
+			usbback_rsrc_unlink_urb(rsrc);
+			break;
+		case usbback_rsrc_stimulus_uc:
+			rsrc->state = usbback_rsrc_state_i;
+			usbback_rsrc_complete(rsrc);
+			break;
+		default:
+			usbback_rsrc_invalid_stimulus(rsrc, stimulus);
+			break;
+		}
+		break;
+	case usbback_rsrc_state_i_st_ms_uc:
+		/* Handling request       */
+		/* submit_urb outstanding */
+		/* URB completed          */
+		switch (stimulus) {
+		case usbback_rsrc_stimulus_tu:
+			break;
+		case usbback_rsrc_stimulus_us:
+			rsrc->state = usbback_rsrc_state_i;
+			usbback_rsrc_complete(rsrc);
+			break;
+		default:
+			usbback_rsrc_invalid_stimulus(rsrc, stimulus);
+			break;
+		}
+		break;
+	case usbback_rsrc_state_i_st_ms_tu_us:
+		/* Handling request       */
+		/* URB submitted    */
+		/* unlink_urb outstanding */
+		switch (stimulus) {
+		case usbback_rsrc_stimulus_tu:
+			break;
+		case usbback_rsrc_stimulus_uc:
+		case usbback_rsrc_stimulus_ul:
+			rsrc->state =
+			    usbback_rsrc_state_i_st_ms_tu_us_uc;
+			break;
+		default:
+			usbback_rsrc_invalid_stimulus(rsrc, stimulus);
+			break;
+		}
+		break;
+	case usbback_rsrc_state_i_st_ms_tu_us_uc:
+		/* Handling request                        */
+		/* URB submitted or unlink_urb outstanding */
+		switch (stimulus) {
+		case usbback_rsrc_stimulus_tu:
+			break;
+		case usbback_rsrc_stimulus_uc:
+		case usbback_rsrc_stimulus_ul:
+			rsrc->state = usbback_rsrc_state_i;
+			usbback_rsrc_complete(rsrc);
+			break;
+		default:
+			usbback_rsrc_invalid_stimulus(rsrc, stimulus);
+			break;
+		}
+		break;
+	default:
+		usbback_rsrc_invalid_stimulus(rsrc, stimulus);
+		break;
+	}
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_resource.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_resource.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,75 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_RESOURCE_H
+#define USBBACK_RESOURCE_H
+
+#include "usbback_gw.h"
+#include "usbback_rbr_mapper_pool.h"
+
+int usbback_rsrc_class_init(void);
+
+void usbback_rsrc_class_exit(void);
+
+struct usbback_device;
+struct usbback_rsrc;
+
+int
+usbback_rsrc_init(struct usbback_rsrc *rsrc, struct usbback_device *device);
+
+void usbback_rsrc_exit(struct usbback_rsrc *rsrc);
+
+void
+usbback_rsrc_start_io(struct usbback_rsrc *rsrc, struct usbback_gw_tra *tra);
+
+int usbback_rsrc_try_unlink(struct usbback_rsrc *rsrc, int unlink_id);
+
+void usbback_rsrc_flush_tra(struct usbback_rsrc *rsrc);
+
+typedef enum {
+	usbback_rsrc_state_i,
+	usbback_rsrc_state_i_st,
+	usbback_rsrc_state_i_st_tu,
+	usbback_rsrc_state_i_st_ms,
+	usbback_rsrc_state_i_st_ms_tu,
+	usbback_rsrc_state_i_st_ms_us,
+	usbback_rsrc_state_i_st_ms_uc,
+	usbback_rsrc_state_i_st_ms_tu_us,
+	usbback_rsrc_state_i_st_ms_tu_us_uc
+} usbback_rsrc_state;
+
+struct usbback_rsrc {
+	struct usbback_device             *device;
+	struct list_head                   link;
+	spinlock_t                         lock;
+	usbback_rsrc_state                 state;
+	usbif_error                        tra_error;
+	unsigned long                      tra_status_length;
+	struct usbback_gw_tra             *tra;
+	struct usbback_gw_tra             *completing_tra;
+	struct usbback_rbr_mapper_request  rbr_mapper_request;
+	struct usbback_rbr_mapper_element  request_element[2];
+	int                                rbrs_mapped;
+	struct urb                        *urb;
+	u8                                 setup[8];
+	struct usbback_callback            submit_urb_1_callback;
+	struct usbback_work                unlink_urb_1_work;
+};
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_ring_channel.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_ring_channel.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,760 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* This program is free software; you can redisribute 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 disributed 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/interrupt.h>
+#include <xen/interface/io/usbif.h>
+#include <xen/driver_util.h>
+#include <xen/evtchn.h>
+#include "usbback_ring_channel.h"
+#include "usbback_trace.h"
+
+static inline void
+usbback_ring_channel_rsrc_init(struct usbback_ring_channel_rsrc *rsrc,
+struct usbback_ring_channel *channel, usbback_callback_function *callback)
+{
+	trace();
+	usbback_channel_ibmsg_init(&rsrc->message, callback);
+	rsrc->channel = channel;
+}
+
+static inline struct list_head *
+usbback_ring_channel_rsrc_to_link(struct usbback_ring_channel_rsrc *rsrc)
+{
+	return usbback_channel_ibmsg_to_link(&rsrc->message);
+}
+
+static inline struct usbback_ring_channel_rsrc *
+usbback_ring_channel_rsrc_callback_to(struct usbback_callback *callback)
+{
+	return container_of(usbback_channel_ibmsg_callback_to(callback),
+				struct usbback_ring_channel_rsrc, message);
+}
+
+typedef enum {
+	usbback_ring_channel_stimulus_cn,/* connect request             */
+	usbback_ring_channel_stimulus_mq,/* message queued              */
+	usbback_ring_channel_stimulus_dn,/* disconnect request          */
+	usbback_ring_channel_stimulus_ri,/* ring interrupt              */
+	usbback_ring_channel_stimulus_cs,/* connect successful          */
+	usbback_ring_channel_stimulus_cf,/* connect failed              */
+	usbback_ring_channel_stimulus_cc,/* connect client completed    */
+	usbback_ring_channel_stimulus_dc,/* disconnect client completed */
+	usbback_ring_channel_stimulus_ds,/* disconnect successful       */
+	usbback_ring_channel_stimulus_ks,/* kick send ring completed    */
+	usbback_ring_channel_stimulus_kr,/* kick recv ring completed    */
+	usbback_ring_channel_stimulus_rc,/* rsrc completed              */
+	usbback_ring_channel_stimulus_rf /* rsrc final completion       */
+} usbback_ring_channel_stimulus;
+
+static void
+usbback_ring_channel_handle_stimulus(struct usbback_ring_channel *channel,
+usbback_ring_channel_stimulus stimulus);
+
+void
+usbback_ring_channel_connect(struct usbback_ring_channel *channel,
+struct usbback_ring_channel_connect_request *request)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	channel->current_callback = &request->callback;
+	usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_cn);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbback_ring_channel_submit_message(struct usbback_channel *base_channel,
+struct usbback_channel_obmsg *message)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbback_ring_channel *channel = usbback_ring_channel_channel_to(
+								base_channel);
+	unsigned long flags;
+	spin_lock_irqsave(&channel->lock, flags);
+	list_add_tail(usbback_channel_obmsg_to_link(message),
+					&channel->message_list);
+	usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_mq);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+void
+usbback_ring_channel_disconnect(struct usbback_ring_channel *channel,
+struct usbback_callback *callback)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	channel->current_callback = callback;
+	usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_dn);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static irqreturn_t
+usbback_ring_channel_interrupt(int irq, void *context, struct pt_regs *ptregs)
+{
+	struct usbback_ring_channel *channel = context;
+	unsigned long flags;
+	spin_lock_irqsave(&channel->lock, flags);
+	usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_ri);
+	spin_unlock_irqrestore(&channel->lock, flags);
+	return IRQ_HANDLED;
+}
+
+static void
+usbback_ring_channel_invalid_stimulus(struct usbback_ring_channel *channel,
+usbback_ring_channel_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbback: channel %p in state %d"
+		"received invalid stimulus %d", channel, channel->state,
+		stimulus);
+}
+
+static void
+usbback_ring_channel_do_connect(struct usbback_ring_channel *channel)
+{
+	trace();
+	(void)usbback_work_schedule(&channel->do_connect_1_work);
+}
+
+static void usbback_ring_channel_do_connect_1(void *data)
+{
+	struct usbback_ring_channel *channel = data;
+	struct usbback_ring_channel_connect_request *request =
+			usbback_ring_channel_connect_request_callback_to(
+						channel->current_callback);
+	struct gnttab_map_grant_ref map_op;
+	struct gnttab_unmap_grant_ref unmap_op;
+	evtchn_op_t chn_op;
+	struct usbif_sring *sring;
+	unsigned long flags;
+	trace();
+	memset(&map_op, 0, sizeof(map_op));
+	map_op.host_addr = (unsigned long)channel->ring_area->addr;
+	map_op.flags = GNTMAP_host_map;
+	map_op.dom = request->domain_id;
+	map_op.ref = request->ring_ref;
+	lock_vm_area(channel->ring_area);
+	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &map_op, 1));
+	unlock_vm_area(channel->ring_area);
+	if (map_op.status != 0) {
+		trace_info("failed to map remote page");
+		goto exit_no_mapping;
+	}
+	channel->ring_handle = map_op.handle;
+	/* FIXME: __ia64__ broken here */
+	memset(&chn_op, 0, sizeof(chn_op));
+	chn_op.cmd = EVTCHNOP_bind_interdomain;
+	chn_op.u.bind_interdomain.remote_dom = request->domain_id;
+	chn_op.u.bind_interdomain.remote_port = request->event_channel;
+	if (HYPERVISOR_event_channel_op(&chn_op) != 0) {
+		trace_info("failed to bind to remote event channel");
+		goto exit_no_bind;
+	}
+	channel->event_channel = chn_op.u.bind_interdomain.local_port;
+	sring = (struct usbif_sring *)channel->ring_area->addr;
+	BACK_RING_INIT(&channel->back_ring, sring, PAGE_SIZE);
+	channel->irq = bind_evtchn_to_irqhandler( channel->event_channel,
+			usbback_ring_channel_interrupt, 0, "usbif-backend",
+			channel);
+	if (channel->irq < 0) {
+		trace_info("failed to bind remote irq");
+		goto exit_no_irq;
+	}
+	spin_lock_irqsave(&channel->lock, flags);
+	usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_cs);
+	spin_unlock_irqrestore(&channel->lock, flags);
+	return;
+ exit_no_irq:
+	memset(&chn_op, 0, sizeof(chn_op));
+	chn_op.cmd = EVTCHNOP_close;
+	chn_op.u.close.port = channel->event_channel;
+	BUG_ON(HYPERVISOR_event_channel_op(&chn_op) != 0);
+ exit_no_bind:
+	memset(&unmap_op, 0, sizeof(unmap_op));
+	unmap_op.host_addr = (unsigned long)channel->ring_area->addr;
+	unmap_op.handle = channel->ring_handle;
+	unmap_op.dev_bus_addr = 0;
+	lock_vm_area(channel->ring_area);
+	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &unmap_op,
+									1));
+	unlock_vm_area(channel->ring_area);
+ exit_no_mapping:
+	spin_lock_irqsave(&channel->lock, flags);
+	usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_cf);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbback_ring_channel_connect_client(struct usbback_ring_channel *channel)
+{
+	trace();
+	(void)usbback_work_schedule(&channel->connect_client_1_work);
+}
+
+static void usbback_ring_channel_connect_client_1(void *data)
+{
+	struct usbback_ring_channel *channel = data;
+	unsigned long flags;
+	trace();
+	usbback_channel_connect(&channel->channel);
+	spin_lock_irqsave(&channel->lock, flags);
+	usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_cc);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbback_ring_channel_disconnect_client(struct usbback_ring_channel *channel)
+{
+	trace();
+	(void)usbback_work_schedule(&channel->disconnect_client_1_work);
+}
+
+static void usbback_ring_channel_disconnect_client_1(void *data)
+{
+	struct usbback_ring_channel *channel = data;
+	trace();
+	usbback_channel_disconnect(&channel->channel,
+				&channel->disconnect_client_2_callback);
+}
+
+static void
+usbback_ring_channel_disconnect_client_2(struct usbback_callback *callback)
+{
+	struct usbback_ring_channel *channel = container_of(callback,
+		struct usbback_ring_channel, disconnect_client_2_callback);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_dc);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbback_ring_channel_do_disconnect(struct usbback_ring_channel *channel)
+{
+	trace();
+	(void)usbback_work_schedule(&channel->do_disconnect_1_work);
+}
+
+static void usbback_ring_channel_do_disconnect_1(void *data)
+{
+	struct usbback_ring_channel *channel = data;
+	struct gnttab_unmap_grant_ref op;
+	unsigned long flags;
+	trace();
+	unbind_from_irqhandler(channel->irq, channel);
+	memset(&op, 0, sizeof(op));
+	op.host_addr = (unsigned long)channel->ring_area->addr;
+	op.handle = channel->ring_handle;
+	op.dev_bus_addr = 0;
+	lock_vm_area(channel->ring_area);
+	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
+	unlock_vm_area(channel->ring_area);
+	spin_lock_irqsave(&channel->lock, flags);
+	usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_ds);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbback_ring_channel_kick_recv_ring(struct usbback_ring_channel *channel)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	if (!channel->recv_ring_kick_out) {
+		channel->recv_ring_kick_out = 1;
+		(void)usbback_work_schedule(&channel->kick_recv_ring_1_work);
+	}
+}
+
+static void usbback_ring_channel_kick_recv_ring_1(void *data)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbback_ring_channel *channel = data;
+	unsigned long flags;
+	spin_lock_irqsave(&channel->lock, flags);
+	for (;;) {
+		struct usbif_back_ring *back_ring = &channel->back_ring;
+		int progress = 0;
+		RING_IDX rp, rc;
+		rc = back_ring->req_cons;
+		/* To avoid going idle when there is a waiting request we    */
+		/* need a mb() here to make sure we see any requests which   */
+		/* are new this time around the outer 'for' loop.            */
+		/* FIXME: spin_lock below makes this unnecessary?            */
+		mb();
+		rp = back_ring->sring->req_prod;
+		/* To make sure we see the correct data for the requests     */
+		/* found above we need a rmb() here to force reads to be     */
+                /* after the read of back_ring->sring->req_prod.             */
+		rmb();
+		while (!list_empty(&channel->rsrc_list) && (rc != rp) &&
+				!RING_REQUEST_CONS_OVERFLOW(back_ring, rc)) {
+			struct usbback_ring_channel_rsrc *rsrc;
+			struct usbif_request *request;
+			rsrc = list_entry(channel->rsrc_list.next,
+				struct usbback_ring_channel_rsrc,
+				message.callback.work.link);
+			list_del_init(usbback_ring_channel_rsrc_to_link(rsrc));
+			request = RING_GET_REQUEST(back_ring, rc);
+			rsrc->message.request = *request;
+			back_ring->req_cons = ++rc;
+			channel->rsrcs_out++;
+			spin_unlock_irqrestore(&channel->lock, flags);
+			usbback_channel_handle_message(&channel->channel,
+							&rsrc->message);
+			progress = 1;
+			spin_lock_irqsave(&channel->lock, flags);
+		}
+		if (!progress)
+		{
+			channel->recv_ring_kick_out = 0;
+			usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_kr);
+			break;
+		}
+	}
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbback_ring_channel_kick_recv_ring_2(struct usbback_callback *callback)
+{
+	struct usbback_ring_channel_rsrc *rsrc =
+			usbback_ring_channel_rsrc_callback_to(callback);
+	struct usbback_ring_channel *channel = rsrc->channel;
+	unsigned long flags;
+	if ((usbback_callback_query_error(callback) != USBIF_ERROR_SUCCESS) &&
+					(channel->protocol_error != NULL))
+		channel->protocol_error(channel);
+	spin_lock_irqsave(&channel->lock, flags);
+	list_add_tail(usbback_ring_channel_rsrc_to_link(rsrc),
+							&channel->rsrc_list);
+	if (--channel->rsrcs_out == 0) {
+		usbback_ring_channel_handle_stimulus(channel,
+				usbback_ring_channel_stimulus_rf);
+	} else {
+		usbback_ring_channel_handle_stimulus(channel,
+				usbback_ring_channel_stimulus_rc);
+	}
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbback_ring_channel_kick_send_ring(struct usbback_ring_channel *channel)
+{
+	if (!channel->send_ring_kick_out) {
+		channel->send_ring_kick_out = 1;
+		(void)usbback_work_schedule(&channel->kick_send_ring_1_work);
+	}
+}
+
+static void usbback_ring_channel_kick_send_ring_1(void *data)
+{
+	struct usbback_ring_channel *channel = data;
+	unsigned long flags;
+	spin_lock_irqsave(&channel->lock, flags);
+	for (;;) {
+		struct usbif_back_ring *back_ring = &channel->back_ring;
+		int notify = 0;
+		while (!list_empty(&channel->message_list)) {
+			struct usbback_channel_obmsg *message;
+			struct usbif_response *response;
+			message = list_entry(channel->message_list.next,
+						struct usbback_channel_obmsg,
+						callback.work.link);
+			list_del_init(usbback_channel_obmsg_to_link(message));
+			spin_unlock_irqrestore(&channel->lock, flags);
+			response = RING_GET_RESPONSE(back_ring,
+						back_ring->rsp_prod_pvt);
+			*response = message->response;
+			usbback_callback_success(
+				usbback_channel_obmsg_to_callback(message));
+			back_ring->rsp_prod_pvt++;
+			notify = 1;
+			spin_lock_irqsave(&channel->lock, flags);
+		}
+		if (notify) {
+			spin_unlock_irqrestore(&channel->lock, flags);
+			RING_PUSH_RESPONSES(back_ring);
+			notify_remote_via_irq(channel->irq);
+			spin_lock_irqsave(&channel->lock, flags);
+		} else {
+			channel->send_ring_kick_out = 0;
+			usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_ks);
+			break;
+		}
+	}
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbback_ring_channel_complete_current_callback(
+struct usbback_ring_channel *channel)
+{
+	trace();
+	usbback_callback_success(channel->current_callback);
+}
+
+static void
+usbback_ring_channel_fail_current_callback(
+struct usbback_ring_channel *channel)
+{
+	trace();
+	usbback_callback_complete(channel->current_callback,
+							USBIF_ERROR_FAILURE);
+}
+
+static void
+usbback_ring_channel_fail_out_messages(struct usbback_ring_channel *channel)
+{
+	trace();
+	while (!list_empty(&channel->message_list)) {
+		struct usbback_channel_obmsg *message = list_entry(
+			channel->message_list.next,
+			struct usbback_channel_obmsg,
+			callback.work.link);
+		list_del_init(usbback_channel_obmsg_to_link(message));
+		/* Message completion doesn't guarantee message delivery so  */
+		/* there is no need for an error code here.                  */
+		usbback_callback_success(usbback_channel_obmsg_to_callback(
+								message));
+	}
+}
+
+static void
+usbback_ring_channel_test_rsrcs(struct usbback_ring_channel *channel)
+{
+	trace();
+	if (channel->rsrcs_out == 0) {
+		usbback_ring_channel_handle_stimulus(channel,
+					usbback_ring_channel_stimulus_rf);
+	}
+}
+
+static int
+usbback_ring_channel_init_or_exit(struct usbback_ring_channel *channel,
+int exit)
+{
+	int return_value = 0, i;
+	trace();
+	if (exit)
+		goto exit_path;
+	if ((channel->ring_area = alloc_vm_area(PAGE_SIZE)) == NULL) {
+		trace_info("failed to allocate ring area");
+		return_value = -ENOMEM;
+		goto exit_no_ring_area;
+	}
+	spin_lock_init(&channel->lock);
+	channel->state = usbback_ring_channel_state_i;
+	INIT_LIST_HEAD(&channel->message_list);
+	usbback_work_init(&channel->do_connect_1_work,
+		     usbback_ring_channel_do_connect_1, channel);
+	usbback_work_init(&channel->connect_client_1_work,
+		     usbback_ring_channel_connect_client_1, channel);
+	usbback_work_init(&channel->disconnect_client_1_work,
+		     usbback_ring_channel_disconnect_client_1, channel);
+	usbback_callback_init(&channel->disconnect_client_2_callback,
+		     usbback_ring_channel_disconnect_client_2);
+	usbback_work_init(&channel->do_disconnect_1_work,
+		     usbback_ring_channel_do_disconnect_1, channel);
+	usbback_work_init(&channel->kick_recv_ring_1_work,
+		     usbback_ring_channel_kick_recv_ring_1, channel);
+	usbback_work_init(&channel->kick_send_ring_1_work,
+		     usbback_ring_channel_kick_send_ring_1, channel);
+	INIT_LIST_HEAD(&channel->rsrc_list);
+	for (i = 0; i < USBIF_QUOTA; i++) {
+		struct usbback_ring_channel_rsrc *rsrc = &channel->rsrcs[i];
+		usbback_ring_channel_rsrc_init(rsrc, channel,
+				usbback_ring_channel_kick_recv_ring_2);
+		list_add_tail(usbback_ring_channel_rsrc_to_link(rsrc),
+							&channel->rsrc_list);
+	}
+	channel->recv_ring_kick_out = 0;
+	channel->send_ring_kick_out = 0;
+	channel->rsrcs_out = 0;
+	return 0;
+ exit_path:
+	free_vm_area(channel->ring_area);
+ exit_no_ring_area:
+	return return_value;
+}
+
+int
+usbback_ring_channel_init(struct usbback_ring_channel *channel,
+void (*protocol_error) (struct usbback_ring_channel *channel))
+{
+	trace();
+	usbback_channel_init(&channel->channel,
+					usbback_ring_channel_submit_message);
+	channel->protocol_error = protocol_error;
+	return usbback_ring_channel_init_or_exit(channel, 0);
+}
+
+void usbback_ring_channel_exit(struct usbback_ring_channel *channel)
+{
+	trace();
+	(void)usbback_ring_channel_init_or_exit(channel, 1);
+}
+
+static void usbback_ring_channel_handle_stimulus(
+struct usbback_ring_channel *channel, usbback_ring_channel_stimulus stimulus)
+{
+	switch (channel->state) {
+	case usbback_ring_channel_state_i:
+		/* Client disconnected. */
+		/* No messages queued.  */
+		/* Kick send idle.      */
+		/* Kick recv idle.      */
+		/* Target rsrcs idle.   */
+		/* Ring disconnected.   */
+		switch (stimulus) {
+		case usbback_ring_channel_stimulus_cn:
+			channel->state = usbback_ring_channel_state_i_cn;
+			usbback_ring_channel_do_connect(channel);
+			break;
+		default:
+			usbback_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbback_ring_channel_state_i_cn:
+		/* Interface connecting.   */
+		/* Client disconnected.    */
+		/* No messages queued.     */
+		/* Kick send idle.         */
+		/* Kick recv idle.         */
+		/* Target rsrcs idle.      */
+		/* do connect in progress. */
+		switch (stimulus) {
+		case usbback_ring_channel_stimulus_ri:
+			break;
+		case usbback_ring_channel_stimulus_cs:
+			channel->state = usbback_ring_channel_state_i_cn_cs;
+			usbback_ring_channel_connect_client(channel);
+			break;
+		case usbback_ring_channel_stimulus_cf:
+			channel->state = usbback_ring_channel_state_i;
+			usbback_ring_channel_fail_current_callback(channel);
+			break;
+		default:
+			usbback_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbback_ring_channel_state_i_cn_cs:
+		/* Interface connecting.      */
+		/* Client connecting.         */
+		/* Maybe messages queued.     */
+		/* Kick send idle.            */
+		/* Kick recv idle.            */
+		/* Target rsrcs idle.         */
+		/* Ring connected.            */
+		/* Connect client in progress */
+		switch (stimulus) {
+		case usbback_ring_channel_stimulus_mq:
+		case usbback_ring_channel_stimulus_ri:
+			break;
+		case usbback_ring_channel_stimulus_cc:
+			channel->state =
+				usbback_ring_channel_state_i_cn_cs_cc;
+			usbback_ring_channel_complete_current_callback(
+								channel);
+			usbback_ring_channel_kick_send_ring(channel);
+			usbback_ring_channel_kick_recv_ring(channel);
+			break;
+		default:
+			usbback_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbback_ring_channel_state_i_cn_cs_cc:
+		/* Interface connected.         */
+		/* Client connected.            */
+		/* Maybe messages queued.       */
+		/* Maybe kick send in progress. */
+		/* Maybe kick recv in progress. */
+		/* Maybe target rsrcs busy.     */
+		/* Ring connected.              */
+		switch (stimulus) {
+		case usbback_ring_channel_stimulus_mq:
+			usbback_ring_channel_kick_send_ring(channel);
+			break;
+		case usbback_ring_channel_stimulus_dn:
+			channel->state =
+				usbback_ring_channel_state_i_cn_cs_cc_dn;
+			usbback_ring_channel_kick_send_ring(channel);
+			usbback_ring_channel_kick_recv_ring(channel);
+			break;
+		case usbback_ring_channel_stimulus_ri:
+			usbback_ring_channel_kick_recv_ring(channel);
+			break;
+		case usbback_ring_channel_stimulus_ks:
+		case usbback_ring_channel_stimulus_kr:
+			break;
+		case usbback_ring_channel_stimulus_rc:
+		case usbback_ring_channel_stimulus_rf:
+			usbback_ring_channel_kick_recv_ring(channel);
+			break;
+		default:
+			usbback_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbback_ring_channel_state_i_cn_cs_cc_dn:
+		/* Interface disconnecting. */
+		/* Client connected.        */
+		/* Maybe messages queued.   */
+		/* Kick send in progress.   */
+		/* Kick recv in progress.   */
+		/* Maybe target rsrcs busy. */
+		/* Ring connected.          */
+		switch (stimulus) {
+		case usbback_ring_channel_stimulus_mq:
+		case usbback_ring_channel_stimulus_ri:
+			break;
+		case usbback_ring_channel_stimulus_ks:
+		case usbback_ring_channel_stimulus_kr:
+			channel->state =
+				usbback_ring_channel_state_i_cn_cs_cc_dn_ks;
+			break;
+		case usbback_ring_channel_stimulus_rc:
+		case usbback_ring_channel_stimulus_rf:
+			break;
+		default:
+			usbback_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbback_ring_channel_state_i_cn_cs_cc_dn_ks:
+		/* Interface disconnecting.           */
+		/* Client connected.                  */
+		/* Maybe messages queued.             */
+		/* One of kick send/recv in progress. */
+		/* Maybe target rsrcs busy.           */
+		/* Ring connected.                    */
+		switch (stimulus) {
+		case usbback_ring_channel_stimulus_mq:
+		case usbback_ring_channel_stimulus_ri:
+			break;
+		case usbback_ring_channel_stimulus_ks:
+		case usbback_ring_channel_stimulus_kr:
+			channel->state =
+			    usbback_ring_channel_state_i_cn_cs_cc_dn_ks_kr;
+			usbback_ring_channel_disconnect_client(channel);
+			usbback_ring_channel_fail_out_messages(channel);
+			break;
+		case usbback_ring_channel_stimulus_rc:
+		case usbback_ring_channel_stimulus_rf:
+			break;
+		default:
+			usbback_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbback_ring_channel_state_i_cn_cs_cc_dn_ks_kr:
+		/* Interface disconnecting. */
+		/* Client disconnecting.    */
+		/* No messages queued.      */
+		/* Kick send/recv idle.     */
+		/* Maybe target rsrcs busy. */
+		/* Ring connected.          */
+		switch (stimulus) {
+		case usbback_ring_channel_stimulus_mq:
+			usbback_ring_channel_fail_out_messages(channel);
+			break;
+		case usbback_ring_channel_stimulus_ri:
+			break;
+		case usbback_ring_channel_stimulus_dc:
+			channel->state =
+			    usbback_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc;
+			usbback_ring_channel_test_rsrcs(channel);
+			break;
+		case usbback_ring_channel_stimulus_rc:
+		case usbback_ring_channel_stimulus_rf:
+			break;
+		default:
+			usbback_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbback_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc:
+		/* Interface disconnecting.                */
+		/* Client disconnected.                    */
+		/* No messages queued.                     */
+		/* Kick send/recv idle.                    */
+		/* Testing target rsrcs/ target rsrcs busy */
+		/* Ring connected.                         */
+		switch (stimulus) {
+		case usbback_ring_channel_stimulus_ri:
+		case usbback_ring_channel_stimulus_rc:
+			break;
+		case usbback_ring_channel_stimulus_rf:
+			channel->state =
+			usbback_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc_rf;
+			usbback_ring_channel_do_disconnect(channel);
+			break;
+		default:
+			usbback_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbback_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc_rf:
+		/* Interface disconnecting. */
+		/* Client disconnected.     */
+		/* No messages queued.      */
+		/* Kick send/recv idle.     */
+		/* Target rsrcs idle.       */
+		/* Disconnecting.           */
+		switch (stimulus) {
+		case usbback_ring_channel_stimulus_ri:
+			break;
+		case usbback_ring_channel_stimulus_ds:
+			channel->state = usbback_ring_channel_state_i;
+			usbback_ring_channel_complete_current_callback(
+								channel);
+			break;
+		default:
+			usbback_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	default:
+		usbback_ring_channel_invalid_stimulus(channel, stimulus);
+		break;
+	}
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_ring_channel.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_ring_channel.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,111 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_RING_CHANNEL_H
+#define USBBACK_RING_CHANNEL_H
+
+#include <linux/timer.h>
+#include <xen/evtchn.h>
+#include <xen/gnttab.h>
+#include "usbback_channel.h"
+
+struct usbback_ring_channel;
+
+struct usbback_ring_channel_rsrc {
+	struct usbback_channel_ibmsg  message;
+	struct usbback_ring_channel  *channel;
+};
+
+typedef enum {
+	usbback_ring_channel_state_i,
+	usbback_ring_channel_state_i_cn,
+	usbback_ring_channel_state_i_cn_cs,
+	usbback_ring_channel_state_i_cn_cs_cc,
+	usbback_ring_channel_state_i_cn_cs_cc_dn,
+	usbback_ring_channel_state_i_cn_cs_cc_dn_ks,
+	usbback_ring_channel_state_i_cn_cs_cc_dn_ks_kr,
+	usbback_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc,
+	usbback_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc_rf
+} usbback_ring_channel_state;
+
+struct usbback_ring_channel {
+	struct usbback_channel           channel;
+	void (*protocol_error) (struct usbback_ring_channel *channel);
+	struct vm_struct                *ring_area;
+	spinlock_t                       lock;
+	usbback_ring_channel_state       state;
+	struct list_head                 message_list;
+	struct usbback_work              do_connect_1_work;
+	struct usbback_work              connect_client_1_work;
+	struct usbback_work              disconnect_client_1_work;
+	struct usbback_callback          disconnect_client_2_callback;
+	struct usbback_work              do_disconnect_1_work;
+	struct usbback_work              kick_recv_ring_1_work;
+	struct usbback_work              kick_send_ring_1_work;
+	struct list_head                 rsrc_list;
+	struct usbback_ring_channel_rsrc rsrcs[USBIF_QUOTA];
+	int                              recv_ring_kick_out;
+	int                              send_ring_kick_out;
+	int                              rsrcs_out;
+	struct usbback_callback         *current_callback;
+	grant_handle_t                   ring_handle;
+	unsigned int                     event_channel;
+	int                              irq;
+	struct usbif_back_ring           back_ring;
+};
+
+static inline struct usbback_channel *
+usbback_ring_channel_to_channel(struct usbback_ring_channel *channel)
+{
+	return &channel->channel;
+}
+
+static inline struct usbback_ring_channel *
+usbback_ring_channel_channel_to(struct usbback_channel *channel)
+{
+	return container_of(channel, struct usbback_ring_channel, channel);
+}
+
+int usbback_ring_channel_init(struct usbback_ring_channel *channel,
+void (*protocol_error) (struct usbback_ring_channel *channel));
+
+struct usbback_ring_channel_connect_request {
+	struct usbback_callback callback;
+	domid_t                 domain_id;
+	grant_ref_t             ring_ref;
+	evtchn_port_t           event_channel;
+};
+
+static inline struct usbback_ring_channel_connect_request *
+usbback_ring_channel_connect_request_callback_to(
+struct usbback_callback *callback)
+{
+	return container_of(callback,
+			struct usbback_ring_channel_connect_request,callback);
+}
+
+void usbback_ring_channel_connect(struct usbback_ring_channel *channel,
+struct usbback_ring_channel_connect_request *request);
+
+void usbback_ring_channel_disconnect(struct usbback_ring_channel *channel,
+struct usbback_callback *callback);
+
+void usbback_ring_channel_exit(struct usbback_ring_channel *channel);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_trace.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_trace.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,36 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_TRACE_H
+#define USBBACK_TRACE_H
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+
+#ifdef CONFIG_XEN_USBDEV_BACKEND_TRACE
+
+#define trace_info(format, ...) \
+printk(KERN_INFO "usbback %s: " format "\n", __FUNCTION__, ## __VA_ARGS__)
+#define trace() trace_info("")
+#else
+#define trace_info(format, ...)
+#define trace()
+#endif
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_work.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_work.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,72 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/module.h>
+#include "usbback_work.h"
+
+static void usbback_work_function(void *ignored);
+
+DEFINE_SPINLOCK(usbback_work_list_lock);
+LIST_HEAD(usbback_work_list);
+DECLARE_WORK(usbback_work_work, usbback_work_function, NULL);
+DECLARE_WAIT_QUEUE_HEAD(usbback_work_waitqueue);
+LIST_HEAD(usbback_work_condition);
+
+void usbback_work_wake_up(void)
+{
+	unsigned long flags;
+	spin_lock_irqsave(&usbback_work_list_lock, flags);
+	while (!list_empty(&usbback_work_condition))
+		list_del_init(usbback_work_condition.next);
+	spin_unlock_irqrestore(&usbback_work_list_lock, flags);
+	wake_up(&usbback_work_waitqueue);
+}
+
+int usbback_work_schedule(struct usbback_work *work)
+{
+	int scheduled = 0;
+	unsigned long flags;
+	spin_lock_irqsave(&usbback_work_list_lock, flags);
+	if (list_empty(&work->link)) {
+		list_add_tail(&work->link, &usbback_work_list);
+		scheduled = 1;
+	}
+	spin_unlock_irqrestore(&usbback_work_list_lock, flags);
+	if (scheduled) {
+		usbback_work_wake_up();
+		schedule_work(&usbback_work_work);
+	}
+	return scheduled;
+}
+
+static void usbback_work_function(void *ignored)
+{
+	unsigned long flags;
+	spin_lock_irqsave(&usbback_work_list_lock, flags);
+	while (!list_empty(&usbback_work_list)) {
+		struct usbback_work *work = list_entry(usbback_work_list.next,
+						      struct usbback_work,
+						      link);
+		list_del_init(&work->link);
+		spin_unlock_irqrestore(&usbback_work_list_lock, flags);
+		usbback_work_perform_synchronously(work);
+		spin_lock_irqsave(&usbback_work_list_lock, flags);
+	}
+	spin_unlock_irqrestore(&usbback_work_list_lock, flags);
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_work.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_work.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,104 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_WORK_H
+#define USBBACK_WORK_H
+
+#include <linux/list.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+#include <linux/wait.h>
+#include <linux/workqueue.h>
+
+struct usbback_work {
+	struct list_head   link;
+	void             (*function)(void *context);
+	void              *context;
+};
+
+#define USBBACK_WORK_INIT( name, fn, ctx ) \
+{ .link = LIST_HEAD_INIT( name.link ), .function = fn, .context = ctx }
+
+#define USBBACK_WORK( name, fn, ctx ) \
+struct usbback_work name = USBBACK_WORK_INIT( name, fn, ctx )
+
+static inline void
+usbback_work_init(struct usbback_work *work, void (*function) (void *context),
+void *context)
+{
+	INIT_LIST_HEAD(&work->link);
+	work->function = function;
+	work->context = context;
+}
+
+static inline struct list_head *usbback_work_to_link(struct usbback_work *work)
+{
+	return &work->link;
+}
+
+static inline struct usbback_work *usbback_work_link_to(struct list_head *link)
+{
+	return container_of(link, struct usbback_work, link);
+}
+
+int usbback_work_schedule(struct usbback_work *work);
+
+static inline void
+usbback_work_perform_synchronously(struct usbback_work *work)
+{
+	work->function(work->context);
+}
+
+extern spinlock_t        usbback_work_list_lock;
+extern struct list_head  usbback_work_list;
+extern wait_queue_head_t usbback_work_waitqueue;
+extern struct list_head  usbback_work_condition;
+
+#define usbback_work_until( condition )					      \
+do {									      \
+	unsigned long flags;						      \
+	spin_lock_irqsave(&usbback_work_list_lock, flags);		      \
+	for (;;) {							      \
+		struct list_head link;					      \
+									      \
+		while (!list_empty(&usbback_work_list) && !(condition)) {     \
+			struct usbback_work *work;			      \
+			work = list_entry(usbback_work_list.next,	      \
+						struct usbback_work, link);   \
+			list_del_init(&work->link);			      \
+			spin_unlock_irqrestore(&usbback_work_list_lock,       \
+						flags);                       \
+			usbback_work_perform_synchronously(work);	      \
+			spin_lock_irqsave(&usbback_work_list_lock, flags);    \
+		}							      \
+		if (condition)						      \
+			break;						      \
+		INIT_LIST_HEAD(&link);					      \
+		list_add_tail(&link, &usbback_work_condition);		      \
+		spin_unlock_irqrestore(&usbback_work_list_lock, flags);	      \
+		wait_event(usbback_work_waitqueue, list_empty(&link));	      \
+		spin_lock_irqsave(&usbback_work_list_lock, flags);	      \
+	}								      \
+	spin_unlock_irqrestore(&usbback_work_list_lock, flags);		      \
+}									      \
+while (0)
+
+void usbback_work_wake_up(void);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_xb_channel.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_xb_channel.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,333 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/err.h>
+#include "usbback_xb_channel.h"
+#include "usbback_trace.h"
+
+typedef enum {
+	usbback_xb_channel_stimulus_cn,
+	usbback_xb_channel_stimulus_dn,
+	usbback_xb_channel_stimulus_pe, /* Protocol error.       */
+	usbback_xb_channel_stimulus_fi, /* Frontend initialised. */
+	usbback_xb_channel_stimulus_rs,
+	usbback_xb_channel_stimulus_rf
+} usbback_xb_channel_stimulus;
+
+static void
+usbback_xb_channel_handle_stimulus(struct usbback_xb_channel *channel,
+usbback_xb_channel_stimulus stimulus);
+
+void usbback_xb_channel_connect(struct usbback_xb_channel *channel)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	usbback_xb_channel_handle_stimulus(channel,
+					usbback_xb_channel_stimulus_cn);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+void
+usbback_xb_channel_frontend_initialised(struct usbback_xb_channel *channel,
+struct xenbus_device *dev)
+{
+	unsigned long ring_ref;
+	unsigned int event_channel;
+	unsigned long flags;
+	int error;
+	trace();
+	error = xenbus_gather(XBT_NULL, dev->otherend,
+				"ring-ref", "%lu", &ring_ref,
+				"event-channel", "%u", &event_channel, NULL);
+	spin_lock_irqsave(&channel->lock, flags);
+	if(!error) {
+		channel->domain_id     = dev->otherend_id;
+		channel->ring_ref      = ring_ref;
+		channel->event_channel = event_channel;
+		usbback_xb_channel_handle_stimulus(channel,
+					usbback_xb_channel_stimulus_fi);
+	} else {
+		usbback_xb_channel_handle_stimulus(channel,
+					usbback_xb_channel_stimulus_pe);
+	}
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+void usbback_xb_channel_frontend_changed(struct usbback_xb_channel *channel,
+struct xenbus_device *dev, XenbusState state)
+{
+	trace();
+
+	switch(state) {
+	case XenbusStateUnknown:
+		trace_info( "XenbusStateUnknown" );
+		break;
+	case XenbusStateInitialising:
+		trace_info( "XenbusStateInitialising" );
+		break;
+	case XenbusStateInitWait:
+		trace_info( "XenbusStateInitWait" );
+		break;
+	case XenbusStateInitialised:
+		trace_info( "XenbusStateInitialised" );
+		break;
+	case XenbusStateConnected:
+		trace_info( "XenbusStateConnected" );
+		break;
+	case XenbusStateClosing:
+		trace_info( "XenbusStateClosing" );
+		break;
+	case XenbusStateClosed:
+		trace_info( "XenbusStateClosed" );
+		break;
+	}
+
+	switch(state) {
+	case XenbusStateInitialised:
+		usbback_xb_channel_frontend_initialised(channel, dev);
+		break;
+	case XenbusStateClosed:
+		device_unregister(&dev->dev); /*This is how blkback does it.*/
+		break;
+	default:
+		break;
+	}
+}
+
+static void
+usbback_xb_channel_protocol_error(struct usbback_ring_channel *ring_channel)
+{
+	struct usbback_xb_channel *channel =
+			usbback_xb_channel_ring_channel_to(ring_channel);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	usbback_xb_channel_handle_stimulus(channel,
+					usbback_xb_channel_stimulus_pe);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+void usbback_xb_channel_disconnect(struct usbback_xb_channel *channel)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	channel->disconnected = 0;
+	usbback_xb_channel_handle_stimulus(channel,
+					usbback_xb_channel_stimulus_dn);
+	spin_unlock_irqrestore(&channel->lock, flags);
+	usbback_work_until(channel->disconnected);
+}
+
+static void
+usbback_xb_channel_invalid_stimulus(struct usbback_xb_channel *channel,
+usbback_xb_channel_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbback: xb channel %p in state %d"
+		"received invalid stimulus %d", channel, channel->state,
+								stimulus);
+}
+
+static void usbback_xb_channel_connect_ring(struct usbback_xb_channel *channel)
+{
+	trace();
+	channel->ring_connect.domain_id     = channel->domain_id;
+	channel->ring_connect.ring_ref      = channel->ring_ref;
+	channel->ring_connect.event_channel = channel->event_channel;
+	usbback_ring_channel_connect(&channel->channel,
+						&channel->ring_connect);
+}
+
+static void
+usbback_xb_channel_connect_ring_1(struct usbback_callback *callback)
+{
+	struct usbback_xb_channel *channel = container_of(
+		usbback_ring_channel_connect_request_callback_to(callback),
+		struct usbback_xb_channel, ring_connect);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	if (usbback_callback_query_error(callback) == USBIF_ERROR_SUCCESS) {
+		usbback_xb_channel_handle_stimulus(channel,
+					usbback_xb_channel_stimulus_rs);
+	} else {
+		usbback_xb_channel_handle_stimulus(channel,
+					usbback_xb_channel_stimulus_rf);
+	}
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbback_xb_channel_disconnect_ring(struct usbback_xb_channel *channel)
+{
+	trace();
+	usbback_ring_channel_disconnect(&channel->channel,
+						&channel->ring_disconnect);
+}
+
+static void
+usbback_xb_channel_disconnect_ring_1(struct usbback_callback *callback)
+{
+	struct usbback_xb_channel *channel = container_of(callback,
+		struct usbback_xb_channel, ring_disconnect);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	usbback_xb_channel_handle_stimulus(channel,
+					usbback_xb_channel_stimulus_rs);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbback_xb_channel_complete_disconnect(struct usbback_xb_channel *channel)
+{
+	trace();
+	channel->disconnected = 1;
+	usbback_work_wake_up();
+}
+
+static int
+usbback_xb_channel_init_or_exit(struct usbback_xb_channel *channel, int exit)
+{
+	int return_value = 0;
+	trace();
+	if (exit)
+		goto exit_path;
+	if ((return_value = usbback_ring_channel_init(&channel->channel,
+				usbback_xb_channel_protocol_error)) != 0) {
+		goto exit_no_ring_channel;
+	}
+	spin_lock_init(&channel->lock);
+	channel->state = usbback_xb_channel_state_i;
+	usbback_callback_init(&channel->ring_connect.callback,
+					usbback_xb_channel_connect_ring_1);
+	usbback_callback_init(&channel->ring_disconnect,
+					usbback_xb_channel_disconnect_ring_1);
+	return 0;
+ exit_path:
+	usbback_ring_channel_exit(&channel->channel);
+ exit_no_ring_channel:
+	return return_value;
+}
+
+int usbback_xb_channel_init(struct usbback_xb_channel *channel)
+{
+	trace();
+	return usbback_xb_channel_init_or_exit(channel, 0);
+}
+
+void usbback_xb_channel_exit(struct usbback_xb_channel *channel)
+{
+	trace();
+	(void)usbback_xb_channel_init_or_exit(channel, 1);
+}
+
+static void
+usbback_xb_channel_handle_stimulus(struct usbback_xb_channel *channel,
+usbback_xb_channel_stimulus stimulus) {
+	trace_info("xb channel %p in state %d received stimulus %d", channel,
+						channel->state, stimulus);
+	switch (channel->state) {
+	case usbback_xb_channel_state_i:
+		switch (stimulus) {
+		case usbback_xb_channel_stimulus_cn:
+			channel->state = usbback_xb_channel_state_i_cn;
+			break;
+		default:
+			usbback_xb_channel_invalid_stimulus(channel, stimulus);
+			break;
+		}
+		break;
+	case usbback_xb_channel_state_i_cn:
+		switch (stimulus) {
+		case usbback_xb_channel_stimulus_dn:
+			channel->state = usbback_xb_channel_state_i;
+			usbback_xb_channel_complete_disconnect(channel);
+			break;
+		case usbback_xb_channel_stimulus_fi:
+			channel->state = usbback_xb_channel_state_i_cn_fi;
+			usbback_xb_channel_connect_ring(channel);
+			break;
+		default:
+			usbback_xb_channel_invalid_stimulus(channel, stimulus);
+			break;
+		}
+		break;
+	case usbback_xb_channel_state_i_cn_fi:
+		switch (stimulus) {
+		case usbback_xb_channel_stimulus_dn:
+			channel->state = usbback_xb_channel_state_i_cn_fi_dn;
+			break;
+		case usbback_xb_channel_stimulus_rs:
+			channel->state = usbback_xb_channel_state_i_cn_fi_rs;
+			break;
+		case usbback_xb_channel_stimulus_rf:
+			channel->state = usbback_xb_channel_state_i_cn;
+			break;
+		default:
+			usbback_xb_channel_invalid_stimulus(channel, stimulus);
+			break;
+		}
+		break;
+	case usbback_xb_channel_state_i_cn_fi_dn:
+		switch (stimulus) {
+		case usbback_xb_channel_stimulus_rs:
+			channel->state =
+					usbback_xb_channel_state_i_cn_fi_dn_rs;
+			usbback_xb_channel_disconnect_ring(channel);
+			break;
+		case usbback_xb_channel_stimulus_rf:
+			channel->state = usbback_xb_channel_state_i;
+			usbback_xb_channel_complete_disconnect(channel);
+			break;
+		default:
+			usbback_xb_channel_invalid_stimulus(channel, stimulus);
+			break;
+		}
+		break;
+	case usbback_xb_channel_state_i_cn_fi_rs:
+		switch (stimulus) {
+		case usbback_xb_channel_stimulus_dn:
+			channel->state =
+					usbback_xb_channel_state_i_cn_fi_dn_rs;
+			usbback_xb_channel_disconnect_ring(channel);
+			break;
+		default:
+			usbback_xb_channel_invalid_stimulus(channel, stimulus);
+			break;
+		}
+		break;
+	case usbback_xb_channel_state_i_cn_fi_dn_rs:
+		switch (stimulus) {
+		case usbback_xb_channel_stimulus_rs:
+			channel->state = usbback_xb_channel_state_i;
+			usbback_xb_channel_complete_disconnect(channel);
+			break;
+		default:
+			usbback_xb_channel_invalid_stimulus(channel, stimulus);
+			break;
+		}
+		break;
+	default:
+		usbback_xb_channel_invalid_stimulus(channel, stimulus);
+		break;
+	}
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbback/usbback_xb_channel.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback_xb_channel.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,73 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBBACK_XB_CHANNEL_H
+#define USBBACK_XB_CHANNEL_H
+
+#include <xen/xenbus.h>
+#include "usbback_ring_channel.h"
+
+typedef enum {
+	usbback_xb_channel_state_i,
+	usbback_xb_channel_state_i_cn,
+	usbback_xb_channel_state_i_cn_fi,
+	usbback_xb_channel_state_i_cn_fi_dn,
+	usbback_xb_channel_state_i_cn_fi_rs,
+	usbback_xb_channel_state_i_cn_fi_dn_rs,
+} usbback_xb_channel_state;
+
+struct usbback_xb_channel {
+	struct usbback_ring_channel                 channel;
+	spinlock_t                                  lock;
+	usbback_xb_channel_state                    state;
+	domid_t                                     domain_id;
+	grant_ref_t                                 ring_ref;
+	evtchn_port_t                               event_channel;
+	struct usbback_ring_channel_connect_request ring_connect;
+	struct usbback_callback                     ring_disconnect;
+	int                                         disconnected;
+};
+
+static inline struct usbback_channel *
+usbback_xb_channel_to_channel(struct usbback_xb_channel *channel)
+{
+	return usbback_ring_channel_to_channel(&channel->channel);
+}
+
+static inline struct usbback_xb_channel *
+usbback_xb_channel_ring_channel_to(struct usbback_ring_channel *ring_channel)
+{
+	return container_of(ring_channel, struct usbback_xb_channel, channel);
+}
+
+static inline struct usbback_xb_channel *
+usbback_xb_channel_channel_to(struct usbback_channel *channel)
+{
+	return usbback_xb_channel_ring_channel_to(
+				usbback_ring_channel_channel_to(channel));
+}
+
+void usbback_xb_channel_connect(struct usbback_xb_channel *channel);
+void usbback_xb_channel_frontend_changed(struct usbback_xb_channel *channel,
+struct xenbus_device *dev, XenbusState state);
+void usbback_xb_channel_disconnect(struct usbback_xb_channel *channel);
+int usbback_xb_channel_init(struct usbback_xb_channel *channel);
+void usbback_xb_channel_exit(struct usbback_xb_channel *channel);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/Makefile
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/Makefile	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,15 @@
+obj-$(CONFIG_XEN_USBDEV_FRONTEND) += usbfront.o
+
+usbfront-objs :=                    \
+usbfront_buffer_resource_provider.o \
+usbfront_callback.o                 \
+usbfront_device.o                   \
+usbfront_driver.o                   \
+usbfront_gw.o                       \
+usbfront_gw_resource.o              \
+usbfront_hcd_resource.o             \
+usbfront_module.o                   \
+usbfront_rbr_provider_pool.o        \
+usbfront_ring_channel.o             \
+usbfront_work.o                     \
+usbfront_xb_channel.o
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_buffer_resource_provider.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_buffer_resource_provider.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,173 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+/*****************************************************************************/
+/* Based on                                                                  */
+/*                                                                           */
+/* arch/xen/drivers/blkback/blkback.c                                        */
+/*                                                                           */
+/* original copyright notice follows...                                      */
+/*****************************************************************************/
+/******************************************************************************
+ * arch/xen/drivers/blkif/backend/main.c
+ * 
+ * Back-end of the driver for virtual block devices. This portion of the
+ * driver exports a 'unified' block-device interface that can be accessed
+ * by any operating system that implements a compatible front end. A 
+ * reference front-end implementation can be found in:
+ *  arch/xen/drivers/blkif/frontend
+ * 
+ * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
+ * Copyright (c) 2005, Christopher Clark
+ */
+
+#include <linux/spinlock.h>
+#include <linux/errno.h>
+#include <linux/gfp.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <asm/pgalloc.h>
+#include <xen/balloon.h>
+#include <xen/driver_util.h>
+#include "usbfront_buffer_resource_provider.h"
+#include "usbfront_trace.h"
+
+struct usbfront_buffer_resource_provider {
+	spinlock_t                           lock;
+	struct usbfront_buffer_resource_list resources;
+	struct usbfront_buffer_resource_list free_resources;
+	grant_ref_t                          grant_ref_pool;
+};
+
+static int
+alloc_or_free_grant_refs(struct usbfront_buffer_resource_provider *provider,
+int free)
+{
+	int return_value = 0;
+	if (provider->resources.grant_references == 0)
+		return 0;
+	if (free)
+		goto exit_path;
+	return_value = gnttab_alloc_grant_references(
+				provider->resources.grant_references,
+				&provider->grant_ref_pool);
+	if (return_value != 0)
+		goto exit_no_grant_references;
+	provider->free_resources.grant_references =
+					provider->resources.grant_references;
+	return 0;
+
+ exit_path:
+	gnttab_free_grant_references(provider->grant_ref_pool);
+
+ exit_no_grant_references:
+	return return_value;
+}
+
+static int
+usbfront_buffer_resource_provider_init_or_exit(
+struct usbfront_buffer_resource_provider *provider, int exit)
+{
+	int return_value = 0;
+	trace();
+	if (exit)
+		goto exit_path;
+	spin_lock_init(&provider->lock);
+	provider->free_resources = usbfront_buffer_resource_list_null();
+	if( ( return_value = alloc_or_free_grant_refs(provider, 0) ) != 0 )
+		goto exit_no_grant_refs;
+	return 0;
+ exit_path:
+	alloc_or_free_grant_refs(provider, 1);
+ exit_no_grant_refs:
+	return return_value;
+}
+
+struct usbfront_buffer_resource_provider *
+usbfront_allocate_buffer_resource_provider(
+struct usbfront_buffer_resource_list resources)
+{
+	struct usbfront_buffer_resource_provider *provider;
+	trace();
+	provider = kmalloc(sizeof(struct usbfront_buffer_resource_provider),
+								GFP_KERNEL);
+	if (provider != NULL) {
+		provider->resources = resources;
+		if (usbfront_buffer_resource_provider_init_or_exit(provider, 0)
+		    != 0) {
+			kfree(provider);
+			provider = NULL;
+		}
+	}
+	return provider;
+}
+
+void usbfront_free_buffer_resource_provider(
+struct usbfront_buffer_resource_provider *provider)
+{
+	trace();
+	(void)usbfront_buffer_resource_provider_init_or_exit(provider, 1);
+	kfree(provider);
+}
+
+struct usbfront_buffer_resource_list
+usbfront_buffer_resource_provider_query_free_resources(
+struct usbfront_buffer_resource_provider *provider)
+{
+	struct usbfront_buffer_resource_list list;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&provider->lock, flags);
+	list = provider->free_resources;
+	spin_unlock_irqrestore(&provider->lock, flags);
+	return list;
+}
+
+grant_ref_t
+usbfront_buffer_resource_provider_allocate_grant_reference(
+struct usbfront_buffer_resource_provider *provider)
+{
+	grant_ref_t reference;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&provider->lock, flags);
+	provider->free_resources.grant_references--;
+	reference = gnttab_claim_grant_reference(&provider->grant_ref_pool);
+	spin_unlock_irqrestore(&provider->lock, flags);
+	return reference;
+}
+
+void
+usbfront_buffer_resource_provider_free_grant_reference(
+struct usbfront_buffer_resource_provider *provider, grant_ref_t reference)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&provider->lock, flags);
+	gnttab_release_grant_reference(&provider->grant_ref_pool, reference);
+	provider->free_resources.grant_references++;
+	spin_unlock_irqrestore(&provider->lock, flags);
+}
+
+void
+usbfront_buffer_resource_list_trace(struct usbfront_buffer_resource_list list)
+{
+	trace();
+	printk(KERN_INFO "usbfront %s: grant_references:%d\n",
+		__PRETTY_FUNCTION__, list.grant_references);
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_buffer_resource_provider.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_buffer_resource_provider.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,78 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_BUFFER_RESOURCE_PROVIDER_H
+#define USBFRONT_BUFFER_RESOURCE_PROVIDER_H
+
+#include <linux/string.h>
+#include <asm/types.h>
+#include <xen/gnttab.h>
+
+struct usbfront_buffer_resource_list {
+	u32 grant_references;
+};
+
+static inline struct usbfront_buffer_resource_list
+usbfront_buffer_resource_list_null(void)
+{
+	struct usbfront_buffer_resource_list list;
+	memset(&list, 0, sizeof(list));
+	return list;
+}
+
+static inline int
+usbfront_buffer_resource_list_subset_of(
+struct usbfront_buffer_resource_list *a,
+struct usbfront_buffer_resource_list *b)
+{
+	return a->grant_references <= b->grant_references;
+}
+
+static inline void
+usbfront_buffer_resource_list_plus_equals(
+struct usbfront_buffer_resource_list *a,
+struct usbfront_buffer_resource_list *b)
+{
+	a->grant_references += b->grant_references;
+}
+
+struct usbfront_buffer_resource_provider *
+usbfront_allocate_buffer_resource_provider(
+struct usbfront_buffer_resource_list resource_allocation);
+
+void
+usbfront_free_buffer_resource_provider(
+struct usbfront_buffer_resource_provider *provider);
+
+struct usbfront_buffer_resource_list
+usbfront_buffer_resource_provider_query_free_resources(
+struct usbfront_buffer_resource_provider *provider);
+
+grant_ref_t
+usbfront_buffer_resource_provider_allocate_grant_reference(
+struct usbfront_buffer_resource_provider *provider);
+
+void
+usbfront_buffer_resource_provider_free_grant_reference(
+struct usbfront_buffer_resource_provider *provider, grant_ref_t reference);
+
+void
+usbfront_buffer_resource_list_trace(struct usbfront_buffer_resource_list list);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_callback.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_callback.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,39 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/module.h>
+#include "usbfront_callback.h"
+
+void usbfront_callback_serialiser_function(void *context)
+{
+	struct usbfront_callback_serialiser *serialiser = context;
+	unsigned long flags;
+	spin_lock_irqsave(&serialiser->lock, flags);
+	while (!list_empty(&serialiser->list) && !serialiser->running) {
+		struct usbfront_callback *callback =
+			usbfront_callback_link_to(serialiser->list.next);
+		list_del_init(usbfront_callback_to_link(callback));
+		serialiser->running = 1;
+		spin_unlock_irqrestore(&serialiser->lock, flags);
+		usbfront_callback_complete_synchronously(callback);
+		spin_lock_irqsave(&serialiser->lock, flags);
+		serialiser->running = 0;
+	}
+	spin_unlock_irqrestore(&serialiser->lock, flags);
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_callback.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_callback.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,150 @@
+/*****************************************************************************/
+/* A callback object for use in scheduling completion of asynchronous        */
+/* requests.                                                                 */
+/*                                                                           */
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_CALLBACK_H
+#define USBFRONT_CALLBACK_H
+
+#include <linux/spinlock.h>
+#include <xen/interface/io/usbif.h>
+#include "usbfront_work.h"
+
+static inline int usbif_error_map_to_local(usbif_error error)
+{
+	switch (error) {
+	case USBIF_ERROR_SUCCESS:
+		return 0;
+	case USBIF_ERROR_DISCONNECT:
+		return -ENOTCONN;
+	case USBIF_ERROR_INVALID_PROTOCOL:
+		return -EPROTO;
+	case USBIF_ERROR_INVALID_PARAMETER:
+		return -EINVAL;
+	case USBIF_ERROR_TOO_BIG:
+		return -E2BIG;
+	case USBIF_ERROR_NO_DEVICE:
+		return -ENODEV;
+	case USBIF_ERROR_UNLINKED:
+		return -ECONNRESET;
+	case USBIF_ERROR_PIPE:
+		return -EPIPE;
+	default:
+		return (int)error;
+	}
+}
+
+struct usbfront_callback {
+	struct usbfront_work work;
+	usbif_error error;
+};
+
+typedef void usbfront_callback_function(struct usbfront_callback *callback);
+
+static inline void
+usbfront_callback_init(struct usbfront_callback *callback,
+usbfront_callback_function *function)
+{
+	usbfront_work_init(&callback->work, (void (*)(void *))function,
+								callback);
+	callback->error = USBIF_ERROR_SUCCESS;
+}
+
+static inline struct list_head *
+usbfront_callback_to_link(struct usbfront_callback *callback)
+{
+	return usbfront_work_to_link(&callback->work);
+}
+
+static inline struct usbfront_callback *
+usbfront_callback_link_to(struct list_head *link)
+{
+	return container_of(usbfront_work_link_to(link),
+				struct usbfront_callback, work);
+}
+
+static inline void
+usbfront_callback_complete(struct usbfront_callback *callback,
+usbif_error error)
+{
+	callback->error = error;
+	usbfront_work_schedule(&callback->work);
+}
+
+static inline void
+usbfront_callback_success(struct usbfront_callback *callback)
+{
+	usbfront_callback_complete(callback, 0);
+}
+
+static inline void
+usbfront_callback_set_error(struct usbfront_callback *callback,
+usbif_error error)
+{
+	callback->error = error;
+}
+
+static inline void
+usbfront_callback_complete_synchronously(struct usbfront_callback *callback)
+{
+	usbfront_work_perform_synchronously(&callback->work);
+}
+
+static inline usbif_error
+usbfront_callback_query_error(struct usbfront_callback *callback)
+{
+	return callback->error;
+}
+
+struct usbfront_callback_serialiser {
+	spinlock_t lock;
+	struct list_head list;
+	struct usbfront_work work;
+	int running;
+};
+
+void usbfront_callback_serialiser_function(void *context);
+
+#define USBFRONT_CALLBACK_SERIALISER_INIT( name ) {			\
+	.lock = SPIN_LOCK_UNLOCKED,					\
+	.list = LIST_HEAD_INIT( name.list ),				\
+	.work = USBFRONT_WORK_INIT					\
+		( name.work, usbfront_callback_serialiser_function, &name ),\
+	.running = 0							\
+}
+
+#define USBFRONT_CALLBACK_SERIALISER( name ) \
+struct usbfront_callback_serialiser name =   \
+USBFRONT_CALLBACK_SERIALISER_INIT( name )
+
+static inline void
+usbfront_callback_serialiser_complete_callback(
+struct usbfront_callback_serialiser *serialiser,
+struct usbfront_callback *callback, usbif_error error)
+{
+	unsigned long flags;
+	usbfront_callback_set_error(callback, error);
+	spin_lock_irqsave(&serialiser->lock, flags);
+	list_add_tail(usbfront_callback_to_link(callback), &serialiser->list);
+	spin_unlock_irqrestore(&serialiser->lock, flags);
+	usbfront_work_schedule(&serialiser->work);
+}
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_channel.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_channel.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,159 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_CHANNEL_H
+#define USBFRONT_CHANNEL_H
+
+#include <xen/interface/io/usbif.h>
+#include "usbfront_callback.h"
+
+struct usbfront_channel_ibmsg {
+	struct usbfront_callback callback;
+	struct usbif_response    response;
+};
+
+static inline struct list_head *
+usbfront_channel_ibmsg_to_link(struct usbfront_channel_ibmsg *message)
+{
+	return &message->callback.work.link;
+}
+
+static inline struct usbfront_callback *
+usbfront_channel_ibmsg_to_callback(struct usbfront_channel_ibmsg *message)
+{
+	return &message->callback;
+}
+
+static inline struct usbfront_channel_ibmsg *
+usbfront_channel_ibmsg_callback_to(struct usbfront_callback *callback)
+{
+	return container_of(callback, struct usbfront_channel_ibmsg, callback);
+}
+
+static inline void
+usbfront_channel_ibmsg_init(struct usbfront_channel_ibmsg *message,
+usbfront_callback_function *callback)
+{
+	usbfront_callback_init(usbfront_channel_ibmsg_to_callback(message),
+								callback);
+}
+
+struct usbfront_channel_obmsg {
+	struct usbfront_callback callback;
+	struct usbif_request     request;
+};
+
+static inline struct list_head *
+usbfront_channel_obmsg_to_link(struct usbfront_channel_obmsg *message)
+{
+	return &message->callback.work.link;
+}
+
+static inline struct usbfront_callback *
+usbfront_channel_obmsg_to_callback(struct usbfront_channel_obmsg *message)
+{
+	return &message->callback;
+}
+
+static inline struct usbfront_channel_obmsg *
+usbfront_channel_obmsg_callback_to(struct usbfront_callback *callback)
+{
+	return container_of(callback, struct usbfront_channel_obmsg, callback);
+}
+
+static inline void
+usbfront_channel_obmsg_init(struct usbfront_channel_obmsg *message,
+usbfront_callback_function *callback)
+{
+	usbfront_callback_init(usbfront_channel_obmsg_to_callback(message),
+								callback);
+}
+
+struct usbfront_channel;
+
+typedef void
+usbfront_channel_submit_message_function(struct usbfront_channel *channel,
+struct usbfront_channel_obmsg *message);
+
+typedef void
+usbfront_channel_connect_function(void *client_context);
+
+typedef void
+usbfront_channel_handle_message_function(void *client_context,
+struct usbfront_channel_ibmsg *message);
+
+typedef void
+usbfront_channel_disconnect_function(void *client_context,
+struct usbfront_callback *callback);
+
+struct usbfront_channel {
+	usbfront_channel_submit_message_function *submit_message;
+	void                                     *client_context;
+	usbfront_channel_connect_function        *connect;
+	usbfront_channel_handle_message_function *handle_message;
+	usbfront_channel_disconnect_function     *disconnect;
+};
+
+static inline void
+usbfront_channel_init(struct usbfront_channel *channel,
+usbfront_channel_submit_message_function *submit_message )
+{
+	channel->submit_message = submit_message;
+}
+
+static inline void usbfront_channel_connect(struct usbfront_channel *channel)
+{
+	channel->connect(channel->client_context);
+}
+
+static inline void
+usbfront_channel_handle_message(struct usbfront_channel *channel,
+struct usbfront_channel_ibmsg *message)
+{
+	channel->handle_message(channel->client_context, message);
+}
+
+static inline void
+usbfront_channel_disconnect(struct usbfront_channel *channel,
+struct usbfront_callback *callback)
+{
+	channel->disconnect(channel->client_context, callback);
+}
+
+static inline void
+usbfront_channel_install_client(struct usbfront_channel *channel,
+void *client_context, usbfront_channel_connect_function *connect,
+usbfront_channel_handle_message_function *handle_message,
+usbfront_channel_disconnect_function *disconnect)
+{
+	channel->client_context = client_context;
+	channel->connect        = connect;
+	channel->handle_message = handle_message;
+	channel->disconnect     = disconnect;
+}
+
+static inline void
+usbfront_channel_submit_message(struct usbfront_channel *channel,
+struct usbfront_channel_obmsg *message)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	channel->submit_message(channel, message);
+}
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_device.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_device.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,768 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Based on arch/xen/drivers/usbif/frontend/main.c, original copyright       */
+/* notice follows...                                                         */
+/*****************************************************************************/
+
+/*
+ * Xen Virtual USB Frontend Driver 
+ *
+ * This file contains the first version of the Xen virtual USB hub
+ * that I've managed not to delete by mistake (3rd time lucky!).
+ *
+ * Based on Linux's uhci.c, original copyright notices are displayed
+ * below.  Portions also (c) 2004 Intel Research Cambridge
+ * and (c) 2004, 2005 Mark Williamson
+ *
+ * Contact <mark.williamson@cl.cam.ac.uk> or
+ * <xen-devel@lists.sourceforge.net> regarding this code.
+ *
+ * Still to be (maybe) implemented:
+ * - migration / backend restart support?
+ * - support for building / using as a module
+ */
+
+/*
+ * Universal Host Controller Interface driver for USB.
+ *
+ * Maintainer: Johannes Erdfelt <johannes@erdfelt.com>
+ *
+ * (C) Copyright 1999 Linus Torvalds
+ * (C) Copyright 1999-2002 Johannes Erdfelt, johannes@erdfelt.com
+ * (C) Copyright 1999 Randy Dunlap
+ * (C) Copyright 1999 Georg Acher, acher@in.tum.de
+ * (C) Copyright 1999 Deti Fliegl, deti@fliegl.de
+ * (C) Copyright 1999 Thomas Sailer, sailer@ife.ee.ethz.ch
+ * (C) Copyright 1999 Roman Weissgaerber, weissg@vienna.at
+ * (C) Copyright 2000 Yggdrasil Computing, Inc. (port of new PCI interface
+ *               support from usb-ohci.c by Adam Richter, adam@yggdrasil.com).
+ * (C) Copyright 1999 Gregory P. Smith (from usb-ohci.c)
+ *
+ * Intel documents this fairly well, and as far as I know there
+ * are no royalties or anything like that, but even so there are
+ * people who decided that they want to do the same thing in a
+ * completely different way.
+ *
+ * WARNING! The USB documentation is downright evil. Most of it
+ * is just crap, written by a committee. You're better off ignoring
+ * most of it, the important stuff is:
+ *  - the low-level protocol (fairly simple but lots of small details)
+ *  - working around the horridness of the rest
+ */
+
+/*  Xenbus code for blkif backend
+    Copyright (C) 2005 Rusty Russell <rusty@rustcorp.com.au>
+
+    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include <xen/xenbus.h>
+#include "usbfront_device.h"
+#include "usbfront_driver.h"
+#include "usbfront_xb_channel.h"
+#include "usbfront_trace.h"
+
+typedef enum {
+	usbfront_device_state_i,
+	usbfront_device_state_i_cn,
+	usbfront_device_state_i_cn_dn,
+	usbfront_device_state_i_cn_ps,
+	usbfront_device_state_i_cn_pf,
+	usbfront_device_state_i_cn_dn_ps,
+	usbfront_device_state_i_cn_ps_dn,
+	usbfront_device_state_i_cn_ps_pc,
+	usbfront_device_state_i_cn_ps_dn_rc
+} usbfront_device_state;
+
+typedef enum {
+	usbfront_device_stimulus_cn, /* Gateway connect.        */
+	usbfront_device_stimulus_dn, /* Gateway disconnect.     */
+	usbfront_device_stimulus_ps, /* Probe driver success.   */
+	usbfront_device_stimulus_pf, /* Probe driver failure.   */
+	usbfront_device_stimulus_rc, /* Remove driver complete. */
+	usbfront_device_stimulus_pt, /* Polling tick.           */
+	usbfront_device_stimulus_pc  /* Probe complete.         */
+} usbfront_device_stimulus;
+
+struct usbfront_device {
+	struct xenbus_device         *dev;
+	void                         *drvdata;
+	spinlock_t                    lock;
+	usbfront_device_state         state;
+	struct usbfront_xb_channel    channel;
+	struct usbfront_gw            gw;
+	struct usbfront_callback     *gw_disconnect_callback;
+	int                           port_probe_count;
+	struct usbfront_gw_tra        probe;
+	struct usb_port_status        port_status;
+	struct usbfront_work          probe_driver_1_work;
+	struct usbfront_work          remove_driver_1_work;
+};
+
+static void
+usbfront_device_handle_stimulus(struct usbfront_device *device,
+usbfront_device_stimulus stimulus);
+
+static inline struct usbfront_device *
+usbfront_device_gw_to(struct usbfront_gw *gw)
+{
+	return container_of(gw, struct usbfront_device, gw);
+}
+
+void usbfront_device_set_drvdata(struct usbfront_device *device, void *data)
+{
+	device->drvdata = data;
+}
+
+void *usbfront_device_get_drvdata(struct usbfront_device *device)
+{
+	return device->drvdata;
+}
+
+struct device *usbfront_device_to_dev(struct usbfront_device *device)
+{
+	return &device->dev->dev;
+}
+
+struct usbfront_device *usbfront_device_dev_to(struct device *dev)
+{
+	return to_xenbus_device(dev)->data;
+}
+
+int usbfront_device_query_port_status_changed(struct usbfront_device *device)
+{
+	int changed;
+	unsigned long flags;
+	spin_lock_irqsave(&device->lock, flags);
+	usbfront_device_handle_stimulus(device, usbfront_device_stimulus_pt);
+	changed = (device->port_status.wPortChange != 0);
+	spin_unlock_irqrestore(&device->lock, flags);
+	return changed;
+}
+
+struct usb_port_status
+usbfront_device_query_port_status(struct usbfront_device *device)
+{
+	struct usb_port_status port_status;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	port_status = device->port_status;
+	spin_unlock_irqrestore(&device->lock, flags);
+	return port_status;
+}
+
+void usbfront_device_set_port_power(struct usbfront_device *device)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	device->port_status.wPortStatus |= USB_PORT_STAT_POWER;
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+void usbfront_device_set_port_reset(struct usbfront_device *device)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	device->port_status.wPortStatus |= USB_PORT_STAT_RESET;
+	device->port_status.wPortStatus &= ~USB_PORT_STAT_ENABLE;
+	usbfront_device_handle_stimulus(device, usbfront_device_stimulus_pt);
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+void usbfront_device_clear_port_enable(struct usbfront_device *device)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	device->port_status.wPortStatus &= ~USB_PORT_STAT_ENABLE;
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+void
+usbfront_device_clear_port_connection_change(struct usbfront_device *device)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	device->port_status.wPortChange &= ~USB_PORT_STAT_C_CONNECTION;
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+void usbfront_device_clear_port_reset_change(struct usbfront_device *device)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&device->lock, flags);
+	device->port_status.wPortChange &= ~USB_PORT_STAT_C_RESET;
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+domid_t usbfront_device_query_domain(struct usbfront_device *device)
+{
+	trace();
+	return device->dev->otherend_id;
+}
+
+void usbfront_device_submit_tra(struct usbfront_device *device,
+struct usbfront_gw_tra *tra)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	trace();
+	usbfront_gw_submit_tra(&device->gw, tra);
+}
+
+static void usbfront_device_gw_connect(struct usbfront_gw *gw)
+{
+	struct usbfront_device *device = usbfront_device_gw_to(gw);
+	unsigned long flags;
+	trace();
+	/* Between connect and completion of the disconnect callback we are  */
+	/* allowed to issue tras.                                            */
+	spin_lock_irqsave(&device->lock, flags);
+	usbfront_device_handle_stimulus(device, usbfront_device_stimulus_cn);
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+static void usbfront_device_gw_disconnect(struct usbfront_gw *gw,
+struct usbfront_callback *callback)
+{
+	struct usbfront_device *device = usbfront_device_gw_to(gw);
+	unsigned long flags;
+	trace();
+	/* We must stop issuing tras and complete the callback once  */
+	/* all of the tras we are issuing have completed or failed   */
+	/* back to us.                                               */
+	spin_lock_irqsave(&device->lock, flags);
+	device->gw_disconnect_callback = callback;
+	usbfront_device_handle_stimulus(device, usbfront_device_stimulus_dn);
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+static void usbfront_device_invalid_stimulus(struct usbfront_device *device,
+usbfront_device_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbfront: device %p in state %d received invalid "
+			"stimulus %d\n", device, device->state, stimulus);
+}
+
+static void usbfront_device_probe_driver(struct usbfront_device *device)
+{
+	trace();
+	(void)usbfront_work_schedule(&device->probe_driver_1_work);
+}
+
+static void usbfront_device_probe_driver_1(void *data)
+{
+	struct usbfront_device *device = data;
+	usbfront_device_stimulus stimulus;
+	unsigned long flags;
+	trace();
+	if (usbfront_driver_probe(device) == 0) {
+		stimulus = usbfront_device_stimulus_ps;
+	} else {
+		stimulus = usbfront_device_stimulus_pf;
+	}
+	spin_lock_irqsave(&device->lock, flags);
+	usbfront_device_handle_stimulus(device, stimulus);
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+static void usbfront_device_remove_driver(struct usbfront_device *device)
+{
+	trace();
+	(void)usbfront_work_schedule(&device->remove_driver_1_work);
+}
+
+static void usbfront_device_remove_driver_1(void *data)
+{
+	struct usbfront_device *device = data;
+	unsigned long flags;
+	trace();
+	usbfront_driver_remove(device);
+	spin_lock_irqsave(&device->lock, flags);
+	usbfront_device_handle_stimulus(device, usbfront_device_stimulus_rc);
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+static void usbfront_device_probe_all_ports(struct usbfront_device *device)
+{
+	device->port_probe_count = 1;
+	if ((device->port_status.wPortStatus & USB_PORT_STAT_RESET) !=
+							USB_PORT_STAT_RESET) {
+		device->probe.parameters.header.tra_type =
+						USBIF_TRA_TYPE_PROBE;
+	} else {
+		device->probe.parameters.header.tra_type =
+						USBIF_TRA_TYPE_RESET;
+	}
+	usbfront_gw_submit_tra(&device->gw, &device->probe);
+}
+
+static void
+usbfront_device_probe_all_ports_1(struct usbfront_callback *callback)
+{
+	struct usbfront_device *device = container_of(
+			usbfront_gw_tra_callback_to(callback),
+			struct usbfront_device, probe);
+	unsigned long flags;
+	spin_lock_irqsave(&device->lock, flags);
+	if (device->probe.parameters.header.tra_type ==
+						USBIF_TRA_TYPE_PROBE) {
+		if (usbfront_callback_query_error(callback) ==
+							USBIF_ERROR_SUCCESS) {
+			struct usb_port_status *port_status =
+							&device->port_status;
+			if (device->probe.status.probe.result ==
+					USBIF_PROBE_RESULT_DEVICE_PRESENT) {
+				/* There is a device attached to the port. */
+				if ((port_status->wPortStatus &
+					USB_PORT_STAT_CONNECTION) !=
+						USB_PORT_STAT_CONNECTION) {
+					/* There wasn't a device attached to */
+					/* the port before.                  */
+					port_status->wPortStatus |=
+						USB_PORT_STAT_CONNECTION;
+					port_status->wPortChange |=
+						USB_PORT_STAT_C_CONNECTION;
+				}
+			} else if (device->probe.status.probe.result ==
+						USBIF_PROBE_RESULT_NO_DEVICE) {
+				/* There isn't a device attached to the port.*/
+				if ((port_status->wPortStatus &
+					USB_PORT_STAT_CONNECTION) ==
+						USB_PORT_STAT_CONNECTION) {
+					/* There was a device attached to */
+					/* the port before.               */
+					port_status->wPortStatus &=
+						~USB_PORT_STAT_CONNECTION;
+					port_status->wPortChange |=
+						USB_PORT_STAT_C_CONNECTION;
+				}
+			} else {
+				trace_info("device %p: unexpected result %d "
+					"probing port", device,
+					(int)device->probe.status.probe.
+								result);
+			}
+		} else {
+			trace_info("device %p: error %d probing port",
+				device, usbif_error_map_to_local(
+				usbfront_callback_query_error(callback)));
+		}
+	} else {
+		struct usb_port_status *port_status = &device->port_status;
+		if ((usbfront_callback_query_error(callback) ==
+						USBIF_ERROR_SUCCESS) &&
+				((device->probe.status.reset.result ==
+					USBIF_RESET_RESULT_FULL_SPEED) ||
+				(device->probe.status.reset.result ==
+					USBIF_RESET_RESULT_LOW_SPEED)  ||
+				(device->probe.status.reset.result ==
+					USBIF_RESET_RESULT_HIGH_SPEED))) {
+			if (device->probe.status.reset.result ==
+					    USBIF_RESET_RESULT_LOW_SPEED) {
+				port_status->wPortStatus |=
+						USB_PORT_STAT_LOW_SPEED;
+				port_status->wPortStatus &=
+						~USB_PORT_STAT_HIGH_SPEED;
+			} else if (device->probe.status.reset.result ==
+					USBIF_RESET_RESULT_HIGH_SPEED) {
+				port_status->wPortStatus &=
+						~USB_PORT_STAT_LOW_SPEED;
+				port_status->wPortStatus |=
+						USB_PORT_STAT_HIGH_SPEED;
+			} else {
+				port_status->wPortStatus &=
+						~USB_PORT_STAT_LOW_SPEED;
+				port_status->wPortStatus &=
+						~USB_PORT_STAT_HIGH_SPEED;
+			}
+			port_status->wPortStatus &= ~USB_PORT_STAT_RESET;
+			port_status->wPortStatus |= USB_PORT_STAT_ENABLE;
+			port_status->wPortChange |= USB_PORT_STAT_C_RESET;
+		} else {
+			if (usbfront_callback_query_error(callback) !=
+							USBIF_ERROR_SUCCESS) {
+				printk(KERN_ERR "usbfront: device %p: error %d"
+					" resetting port", device,
+					usbif_error_map_to_local(
+						usbfront_callback_query_error(
+								callback)));
+			} else {
+				trace_info("device %p: unexpected result %d"
+				" resetting port", device,
+				(int)device->probe.status.probe.result);
+			}
+			port_status->wPortStatus &= ~USB_PORT_STAT_LOW_SPEED;
+			port_status->wPortStatus &= ~USB_PORT_STAT_HIGH_SPEED;
+			port_status->wPortStatus &= ~USB_PORT_STAT_RESET;
+			port_status->wPortChange |= USB_PORT_STAT_C_RESET;
+		}
+	}
+
+	if (--device->port_probe_count == 0)
+		usbfront_device_handle_stimulus(device,
+						usbfront_device_stimulus_pc);
+	spin_unlock_irqrestore(&device->lock, flags);
+}
+
+static void
+usbfront_device_disconnect_all_ports(struct usbfront_device *device)
+{
+	struct usb_port_status *port_status = &device->port_status;
+	trace();
+	if ((port_status->wPortStatus & USB_PORT_STAT_CONNECTION) ==
+						USB_PORT_STAT_CONNECTION) {
+		/* There was a device attached to the port before. */
+		port_status->wPortStatus &= ~USB_PORT_STAT_CONNECTION;
+		port_status->wPortChange |= USB_PORT_STAT_C_CONNECTION;
+	}
+}
+
+static void
+usbfront_device_complete_gw_disconnect(struct usbfront_device *device)
+{
+	trace();
+	usbfront_callback_success(device->gw_disconnect_callback);
+}
+
+static int
+usbfront_device_resume_or_suspend(struct usbfront_device *device, int suspend)
+{
+	trace();
+	if (suspend)
+		goto suspend_path;
+	usbfront_xb_channel_connect(&device->channel, device->dev);
+	return 0;
+ suspend_path:
+	usbfront_xb_channel_disconnect(&device->channel);
+	return 0;
+}
+
+static int usbfront_device_init_or_exit(struct usbfront_device *device,
+struct xenbus_device *dev, int exit)
+{
+	int return_value = 0;
+	trace();
+	if (exit)
+		goto exit_path;
+	device->dev = dev;
+	spin_lock_init(&device->lock);
+	device->state = usbfront_device_state_i;
+	usbfront_gw_tra_init(&device->probe,
+				usbfront_device_probe_all_ports_1);
+	usbfront_work_init(&device->probe_driver_1_work,
+				usbfront_device_probe_driver_1, device);
+	usbfront_work_init(&device->remove_driver_1_work,
+				usbfront_device_remove_driver_1, device);
+	return_value = usbfront_xb_channel_init(&device->channel);
+	if (return_value != 0)
+		goto exit_no_channel;
+	return_value = usbfront_gw_init(&device->gw,
+			usbfront_xb_channel_to_channel(&device->channel),
+			usbfront_device_gw_connect,
+			usbfront_device_gw_disconnect,
+			USBIF_QUOTA);
+	if (return_value != 0)
+		goto exit_no_gw;
+	return_value = usbfront_device_resume_or_suspend(device, 0);
+	if (return_value != 0)
+		goto exit_no_resume;
+	return 0;
+ exit_path:
+	(void)usbfront_device_resume_or_suspend(device, 1);
+ exit_no_resume:
+	usbfront_gw_exit(&device->gw);
+ exit_no_gw:
+	usbfront_xb_channel_exit(&device->channel);
+ exit_no_channel:
+	return return_value;
+}
+
+static int
+usbfront_device_init(struct usbfront_device *device, struct xenbus_device *dev)
+{
+	trace();
+	return usbfront_device_init_or_exit(device, dev, 0);
+}
+
+static void usbfront_device_exit(struct usbfront_device *device)
+{
+	trace();
+	(void)usbfront_device_init_or_exit(device, NULL, 1);
+}
+
+static int
+usbfront_device_probe_or_remove(struct xenbus_device *dev, int remove)
+{
+	int return_value = 0;
+	struct usbfront_device *device;
+	trace();
+	if (remove)
+		goto remove_path;
+	device = kzalloc(sizeof(*device), GFP_KERNEL);
+	if (device == NULL) {
+		xenbus_dev_error(dev, -ENOMEM,"allocating FE structure");
+		return_value = -ENOMEM;
+		goto exit_no_device;
+	}
+	dev->data = device;
+	return_value = usbfront_device_init(device, dev);
+	if (return_value != 0)
+		goto exit_init_failed;
+	return 0;
+ remove_path:
+	device = dev->data;
+	usbfront_device_exit(device);
+ exit_init_failed:
+	dev->data = NULL;
+	kfree(device);
+ exit_no_device:
+	return return_value;
+}
+
+static int usbfront_device_probe(struct xenbus_device *dev,
+const struct xenbus_device_id *id)
+{
+	trace();
+	return usbfront_device_probe_or_remove(dev, 0);
+}
+
+static int usbfront_device_remove(struct xenbus_device *dev)
+{
+	trace();
+	return usbfront_device_probe_or_remove(dev, 1);
+}
+
+static int usbfront_device_resume(struct xenbus_device *dev)
+{
+	struct usbfront_device *device = dev->data;
+	trace();
+	(void)usbfront_device_resume_or_suspend(device, 1);
+	return usbfront_device_resume_or_suspend(device, 0);
+}
+
+static void
+usbfront_device_backend_changed(struct xenbus_device *dev, XenbusState state)
+{
+	struct usbfront_device *device = dev->data;
+	trace();
+	usbfront_xb_channel_backend_changed(&device->channel, dev, state);
+}
+
+static struct xenbus_device_id usbfront_device_ids[] = {
+	{"usb"},
+	{""}
+};
+
+static struct xenbus_driver usbfront_device_driver = {
+	.name             = "usb",
+	.owner            = THIS_MODULE,
+	.ids              = usbfront_device_ids,
+	.probe            = usbfront_device_probe,
+	.remove           = usbfront_device_remove,
+	.resume           = usbfront_device_resume,
+	.otherend_changed = usbfront_device_backend_changed,
+};
+
+int usbfront_device_class_init(void)
+{
+	trace();
+	return xenbus_register_frontend(&usbfront_device_driver);
+}
+
+void usbfront_device_class_exit(void)
+{
+	trace();
+	xenbus_unregister_driver(&usbfront_device_driver);
+}
+
+static void usbfront_device_handle_stimulus(struct usbfront_device *device,
+usbfront_device_stimulus stimulus)
+{
+	switch (device->state) {
+	case usbfront_device_state_i:
+		switch (stimulus) {
+		case usbfront_device_stimulus_cn:
+			device->state = usbfront_device_state_i_cn;
+			usbfront_device_probe_driver(device);
+			break;
+		default:
+			usbfront_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbfront_device_state_i_cn:
+		/* Probing driver. */
+		switch (stimulus) {
+		case usbfront_device_stimulus_dn:
+			device->state = usbfront_device_state_i_cn_dn;
+			break;
+		case usbfront_device_stimulus_ps:
+			device->state = usbfront_device_state_i_cn_ps;
+			usbfront_device_probe_all_ports(device);
+			break;
+		case usbfront_device_stimulus_pf:
+			device->state = usbfront_device_state_i_cn_pf;
+			break;
+		case usbfront_device_stimulus_pt:
+			break;
+		default:
+			usbfront_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbfront_device_state_i_cn_dn:
+		/* Probing driver.         */
+		/* Gateway disconnecting. */
+		switch (stimulus) {
+		case usbfront_device_stimulus_ps:
+			device->state = usbfront_device_state_i_cn_dn_ps;
+			usbfront_device_remove_driver(device);
+			break;
+		case usbfront_device_stimulus_pf:
+			device->state = usbfront_device_state_i;
+			usbfront_device_disconnect_all_ports(device);
+			usbfront_device_complete_gw_disconnect(device);
+			break;
+		case usbfront_device_stimulus_pt:
+			break;
+		default:
+			usbfront_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbfront_device_state_i_cn_ps:
+		/* Driver Probed. */
+		/* Polling ports. */
+		switch (stimulus) {
+		case usbfront_device_stimulus_dn:
+			device->state = usbfront_device_state_i_cn_ps_dn;
+			usbfront_device_remove_driver(device);
+			break;
+		case usbfront_device_stimulus_pt:
+			break;
+		case usbfront_device_stimulus_pc:
+			device->state = usbfront_device_state_i_cn_ps_pc;
+			break;
+		default:
+			usbfront_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbfront_device_state_i_cn_pf:
+		/* Driver probe failed. */
+		switch (stimulus) {
+		case usbfront_device_stimulus_dn:
+			device->state = usbfront_device_state_i;
+			usbfront_device_disconnect_all_ports(device);
+			usbfront_device_complete_gw_disconnect(device);
+			break;
+		default:
+			usbfront_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbfront_device_state_i_cn_dn_ps:
+		/* Gateway disconnecting. */
+		/* Removing driver.        */
+		switch (stimulus) {
+		case usbfront_device_stimulus_rc:
+			device->state = usbfront_device_state_i;
+			usbfront_device_disconnect_all_ports(device);
+			usbfront_device_complete_gw_disconnect(device);
+			break;
+		case usbfront_device_stimulus_pt:
+			break;
+		default:
+			usbfront_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbfront_device_state_i_cn_ps_dn:
+		/* Gateway disconnecting. */
+		/* Removing driver.        */
+		/* Polling ports.          */
+		switch (stimulus) {
+		case usbfront_device_stimulus_rc:
+			device->state = usbfront_device_state_i_cn_ps_dn_rc;
+			break;
+		case usbfront_device_stimulus_pt:
+			break;
+		case usbfront_device_stimulus_pc:
+			device->state = usbfront_device_state_i_cn_dn_ps;
+			break;
+		default:
+			usbfront_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbfront_device_state_i_cn_ps_pc:
+		/* Driver Probed. */
+		switch (stimulus) {
+		case usbfront_device_stimulus_dn:
+			device->state = usbfront_device_state_i_cn_dn_ps;
+			usbfront_device_remove_driver(device);
+			break;
+		case usbfront_device_stimulus_pt:
+			device->state = usbfront_device_state_i_cn_ps;
+			usbfront_device_probe_all_ports(device);
+			break;
+		default:
+			usbfront_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	case usbfront_device_state_i_cn_ps_dn_rc:
+		/* Gateway disconnecting. */
+		/* Polling ports.          */
+		switch (stimulus) {
+		case usbfront_device_stimulus_pc:
+			device->state = usbfront_device_state_i;
+			usbfront_device_disconnect_all_ports(device);
+			usbfront_device_complete_gw_disconnect(device);
+			break;
+		default:
+			usbfront_device_invalid_stimulus(device, stimulus);
+			break;
+		}
+		break;
+	default:
+		usbfront_device_invalid_stimulus(device, stimulus);
+		break;
+	}
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_device.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_device.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,51 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_DEVICE_H
+#define USBFRONT_DEVICE_H
+
+#include <linux/device.h>
+#include <linux/usb.h>
+#include <xen/interface/io/usbif.h>
+#include "../../usb/core/hcd.h"
+#include "usbfront_gw.h"
+
+int usbfront_device_class_init(void);
+void usbfront_device_class_exit(void);
+
+struct usbfront_device;
+
+void usbfront_device_set_drvdata(struct usbfront_device *device, void *data);
+void *usbfront_device_get_drvdata(struct usbfront_device *device);
+struct device *usbfront_device_to_dev(struct usbfront_device *device);
+struct usbfront_device *usbfront_device_dev_to(struct device *dev);
+int usbfront_device_query_port_status_changed(struct usbfront_device *device);
+struct usb_port_status
+usbfront_device_query_port_status(struct usbfront_device *device);
+void usbfront_device_set_port_power(struct usbfront_device *device);
+void usbfront_device_set_port_reset(struct usbfront_device *device);
+void usbfront_device_clear_port_enable(struct usbfront_device *device);
+void
+usbfront_device_clear_port_connection_change(struct usbfront_device *device);
+void usbfront_device_clear_port_reset_change(struct usbfront_device *device);
+domid_t usbfront_device_query_domain(struct usbfront_device *device);
+void usbfront_device_submit_tra(struct usbfront_device *device,
+struct usbfront_gw_tra *tra);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_driver.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_driver.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,569 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Based on                                                                  */
+/*                                                                           */
+/* arch/xen/drivers/usbif/frontend/main.c                                    */
+/* pristine-linux-2.6.11/drivers/usb/host/uhci-hcd.c                         */
+/* pristine-linux-2.6.11/drivers/usb/core/hcd-pci.c                          */
+/*                                                                           */
+/* original copyright notices follow...                                      */
+/*****************************************************************************/
+
+/*
+ * Xen Virtual USB Frontend Driver 
+ *
+ * This file contains the first version of the Xen virtual USB hub
+ * that I've managed not to delete by mistake (3rd time lucky!).
+ *
+ * Based on Linux's uhci.c, original copyright notices are displayed
+ * below.  Portions also (c) 2004 Intel Research Cambridge
+ * and (c) 2004, 2005 Mark Williamson
+ *
+ * Contact <mark.williamson@cl.cam.ac.uk> or
+ * <xen-devel@lists.sourceforge.net> regarding this code.
+ *
+ * Still to be (maybe) implemented:
+ * - migration / backend restart support?
+ * - support for building / using as a module
+ */
+
+/*
+ * Universal Host Controller Interface driver for USB.
+ *
+ * Maintainer: Johannes Erdfelt <johannes@erdfelt.com>
+ *
+ * (C) Copyright 1999 Linus Torvalds
+ * (C) Copyright 1999-2002 Johannes Erdfelt, johannes@erdfelt.com
+ * (C) Copyright 1999 Randy Dunlap
+ * (C) Copyright 1999 Georg Acher, acher@in.tum.de
+ * (C) Copyright 1999 Deti Fliegl, deti@fliegl.de
+ * (C) Copyright 1999 Thomas Sailer, sailer@ife.ee.ethz.ch
+ * (C) Copyright 1999 Roman Weissgaerber, weissg@vienna.at
+ * (C) Copyright 2000 Yggdrasil Computing, Inc. (port of new PCI interface
+ *               support from usb-ohci.c by Adam Richter, adam@yggdrasil.com).
+ * (C) Copyright 1999 Gregory P. Smith (from usb-ohci.c)
+ *
+ * Intel documents this fairly well, and as far as I know there
+ * are no royalties or anything like that, but even so there are
+ * people who decided that they want to do the same thing in a
+ * completely different way.
+ *
+ * WARNING! The USB documentation is downright evil. Most of it
+ * is just crap, written by a committee. You're better off ignoring
+ * most of it, the important stuff is:
+ *  - the low-level protocol (fairly simple but lots of small details)
+ *  - working around the horridness of the rest
+ */
+
+/*
+ * Universal Host Controller Interface driver for USB.
+ *
+ * Maintainer: Alan Stern <stern@rowland.harvard.edu>
+ *
+ * (C) Copyright 1999 Linus Torvalds
+ * (C) Copyright 1999-2002 Johannes Erdfelt, johannes@erdfelt.com
+ * (C) Copyright 1999 Randy Dunlap
+ * (C) Copyright 1999 Georg Acher, acher@in.tum.de
+ * (C) Copyright 1999 Deti Fliegl, deti@fliegl.de
+ * (C) Copyright 1999 Thomas Sailer, sailer@ife.ee.ethz.ch
+ * (C) Copyright 1999 Roman Weissgaerber, weissg@vienna.at
+ * (C) Copyright 2000 Yggdrasil Computing, Inc. (port of new PCI interface
+ *               support from usb-ohci.c by Adam Richter, adam@yggdrasil.com).
+ * (C) Copyright 1999 Gregory P. Smith (from usb-ohci.c)
+ * (C) Copyright 2004 Alan Stern, stern@rowland.harvard.edu
+ *
+ * Intel documents this fairly well, and as far as I know there
+ * are no royalties or anything like that, but even so there are
+ * people who decided that they want to do the same thing in a
+ * completely different way.
+ *
+ * WARNING! The USB documentation is downright evil. Most of it
+ * is just crap, written by a committee. You're better off ignoring
+ * most of it, the important stuff is:
+ *  - the low-level protocol (fairly simple but lots of small details)
+ *  - working around the horridness of the rest
+ */
+
+/*
+ * (C) Copyright David Brownell 2000-2002
+ * 
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/device.h>
+#include "usbfront_driver.h"
+#include "usbfront_hcd_resource.h"
+#include "usbfront_sll.h"
+#include "usbfront_trace.h"
+
+typedef enum {
+	usbfront_hcd_state_i
+} usbfront_hcd_state;
+
+typedef enum {
+	usbfront_hcd_stimulus_uq	/* urb enqueue */
+} usbfront_hcd_stimulus;
+
+struct usbfront_hcd {
+	u64 dma_mask;
+	spinlock_t lock;
+	usbfront_hcd_state state;
+	struct usbfront_sll urb_sll;
+	struct list_head free_resource_list;
+	struct usbfront_hcd_resource resources[USBIF_QUOTA];
+};
+
+static void
+usbfront_hcd_handle_stimulus(struct usbfront_hcd *uhcd,
+usbfront_hcd_stimulus stimulus);
+
+static struct usbfront_hcd *usbfront_hcd_hcd_to_uhcd(struct usb_hcd *hcd)
+{
+	return (struct usbfront_hcd *)(hcd->hcd_priv);
+}
+
+static struct usbfront_device *
+usbfront_hcd_hcd_to_usbfront_device(struct usb_hcd *hcd)
+{
+	return usbfront_device_dev_to(hcd_to_bus(hcd)->controller);
+}
+
+void usbfront_hcd_resource_completed(struct usbfront_callback *callback);
+
+static int usbfront_hcd_start(struct usb_hcd *hcd)
+{
+	int return_value = 0;
+	struct usbfront_hcd *uhcd = usbfront_hcd_hcd_to_uhcd(hcd);
+	int i;
+	trace();
+	memset(uhcd, 0, sizeof(*uhcd));
+#if 0
+	/* FIXME: This bit of dma_mask manipulation is to trick the USB hcd  */
+	/* code into giving us buffers allocated using dma_alloc_coherent.   */
+	/* Which is necessary to allow the BE to map them using              */
+	/* dma_map_single.  This is unclean in so many different ways.       */
+
+	uhcd->dma_mask = 0xffffffffffffffffULL;
+	{
+		struct device *dev = usbfront_device_to_dev(
+				usbfront_hcd_hcd_to_usbfront_device(hcd));
+		dev->dma_mask = &uhcd->dma_mask;
+		dev->coherent_dma_mask = uhcd->dma_mask;
+	}
+#endif
+	spin_lock_init(&uhcd->lock);
+	uhcd->state = usbfront_hcd_state_i;
+	usbfront_sll_init(&uhcd->urb_sll);
+	INIT_LIST_HEAD(&uhcd->free_resource_list);
+	for (i = 0; i < USBIF_QUOTA; i++) {
+		struct usbfront_hcd_resource *resource = &uhcd->resources[i];
+		return_value = usbfront_hcd_resource_init(resource,
+				usbfront_hcd_hcd_to_usbfront_device(hcd),
+				i, usbfront_hcd_resource_completed);
+		if (return_value != 0) {
+			trace_info("usbfront_hcd_resource_init failed");
+			goto exit_no_resource;
+		}
+		list_add(usbfront_hcd_resource_to_link(resource),
+						&uhcd->free_resource_list);
+	}
+	hcd->state = HC_STATE_RUNNING;	/* FIXME: breaks encapsulation */
+	return 0;
+ exit_no_resource:
+	while (!list_empty(&uhcd->free_resource_list)) {
+		struct usbfront_hcd_resource *resource = list_entry(
+				uhcd->free_resource_list.next,
+				struct usbfront_hcd_resource,
+				callback.work.link);
+		list_del_init(usbfront_hcd_resource_to_link(resource));
+		usbfront_hcd_resource_exit(resource);
+	}
+	return return_value;
+}
+
+static void usbfront_hcd_stop(struct usb_hcd *hcd)
+{
+	struct usbfront_hcd *uhcd = usbfront_hcd_hcd_to_uhcd(hcd);
+	trace();
+	while (!list_empty(&uhcd->free_resource_list)) {
+		struct usbfront_hcd_resource *resource = list_entry(
+				uhcd->free_resource_list.next,
+				struct usbfront_hcd_resource,
+				callback.work.link);
+		list_del_init(usbfront_hcd_resource_to_link(resource));
+		usbfront_hcd_resource_exit(resource);
+	}
+}
+
+static int usbfront_hcd_get_frame_number(struct usb_hcd *hcd)
+{
+	trace();
+	return 0;
+}
+
+static int
+usbfront_hcd_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *ep,
+struct urb *urb, gfp_t mem_flags)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbfront_hcd *uhcd = usbfront_hcd_hcd_to_uhcd(hcd);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&uhcd->lock, flags);
+	usbfront_slk_init((struct usbfront_slk *)&urb->hcpriv);
+	usbfront_sll_add_last(&uhcd->urb_sll, (struct usbfront_slk *)&urb->
+								hcpriv);
+	usbfront_hcd_handle_stimulus(uhcd, usbfront_hcd_stimulus_uq);
+	spin_unlock_irqrestore(&uhcd->lock, flags);
+	return 0;
+}
+
+static int usbfront_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
+{
+	int dequeued;
+	struct usbfront_hcd *uhcd = usbfront_hcd_hcd_to_uhcd(hcd);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&uhcd->lock, flags);
+	dequeued = usbfront_sll_remove_slk(&uhcd->urb_sll,
+					(struct usbfront_slk *)&urb->hcpriv);
+	spin_unlock_irqrestore(&uhcd->lock, flags);
+	if (dequeued) {
+		urb->hcpriv = 0;
+		urb->actual_length = 0;
+		local_irq_save(flags);
+		usb_hcd_giveback_urb(hcd, urb, 0);
+		local_irq_restore(flags);
+	} else {
+		usbfront_hcd_resource_dequeue_urb(urb);
+	}
+	return 0;
+}
+
+static void
+usbfront_hcd_endpoint_disable(struct usb_hcd *hcd,
+struct usb_host_endpoint *ep)
+{
+	trace();
+}
+
+static int usbfront_hcd_hub_status_data(struct usb_hcd *hcd, char *buf)
+{
+	int changed = 0;
+	struct usbfront_device *device = usbfront_hcd_hcd_to_usbfront_device(
+									hcd);
+	*buf = 0;
+	if (usbfront_device_query_port_status_changed(device)) {
+		*buf   |= 2;
+		changed = 1;
+	}
+	return changed ? 1 : 0;
+}
+
+static int
+usbfront_hcd_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+u16 wIndex, char *buf, u16 wLength)
+{
+	struct usbfront_device *device = usbfront_hcd_hcd_to_usbfront_device(
+									hcd);
+	int return_value = 0;
+	trace();
+	switch (typeReq) {
+	case GetHubStatus:
+		trace_info("GetHubStatus");
+		if ((wValue != 0) || (wIndex != 0) || (wLength != 4))
+			goto error;
+		/* 2 bytes wHubStatus and 2 bytes wHubChange:        */
+		/* Local power supply good, no overcurrect condition */
+		/* No changes.                                       */
+		memset(buf, 0, wLength);
+		break;
+	case GetPortStatus:
+		trace_info("GetPortStatus");
+		if ((wValue != 0) || (wIndex > 1) || (wLength != 4))
+			goto error;
+		{
+			struct usb_port_status port_status =
+				    usbfront_device_query_port_status(device);
+			memcpy(buf, &port_status, wLength);
+		}
+		break;
+	case GetHubDescriptor:
+		trace_info("GetHubDescriptor");
+		{
+			/* bDescLength             */
+			/* bDescriptorType         */
+			/* bNbrPorts               */
+			/* wHubCharacteristics LSB */
+			/* wHubCharacteristics MSB */
+			/* bPwrOn2PwrGood          */
+			/* bHubContrCurrent        */
+			/* DeviceRemovable         */
+			/* PortPwrCtrlMask         */
+			/* See table 11.23.2.1 of the USB 2.0 specification. */
+
+			char descriptor[] = { 0x09, 0x29, 0x00, 0x00, 0x00,
+						0x01, 0x00, 0x00, 0xFF };
+			descriptor[2] = 1;
+			memcpy(buf, &descriptor, min_t(size_t, sizeof(
+							descriptor), wLength));
+		}
+		break;
+	case SetPortFeature:
+		trace_info("SetPortFeature");
+		if (((wIndex & 0x00FF) > 1) || (wLength != 0))
+			goto error;
+		switch (wValue) {
+		case USB_PORT_FEAT_SUSPEND:
+			trace_info("USB_PORT_FEAT_SUSPEND");
+			break;
+		case USB_PORT_FEAT_RESET:
+			trace_info("USB_PORT_FEAT_RESET");
+			usbfront_device_set_port_reset(device);
+			break;
+		case USB_PORT_FEAT_POWER:
+			trace_info("USB_PORT_FEAT_POWER");
+			usbfront_device_set_port_power(device);
+			break;
+		default:
+			trace_info("Unknown:%x", wValue);
+			goto error;
+		}
+		break;
+	case ClearPortFeature:
+		trace_info("ClearPortFeature");
+		if (((wIndex & 0x00FF) > 1) || (wLength != 0))
+			goto error;
+		switch (wValue) {
+		case USB_PORT_FEAT_ENABLE:
+			trace_info("USB_PORT_FEAT_ENABLE");
+			usbfront_device_clear_port_enable(device);
+			break;
+		case USB_PORT_FEAT_SUSPEND:
+			trace_info("USB_PORT_FEAT_SUSPEND");
+			break;
+		case USB_PORT_FEAT_POWER:
+			trace_info("USB_PORT_FEAT_POWER");
+			break;
+		case USB_PORT_FEAT_INDICATOR:
+			trace_info("USB_PORT_FEAT_INDICATOR");
+			break;
+		case USB_PORT_FEAT_C_CONNECTION:
+			trace_info("USB_PORT_C_CONNECTION");
+			usbfront_device_clear_port_connection_change(device);
+			break;
+		case USB_PORT_FEAT_C_RESET:
+			trace_info("USB_PORT_C_RESET");
+			usbfront_device_clear_port_reset_change(device);
+			break;
+		case USB_PORT_FEAT_C_ENABLE:
+			trace_info("USB_PORT_C_ENABLE");
+			break;
+		case USB_PORT_FEAT_C_SUSPEND:
+			trace_info("USB_PORT_C_SUSPEND");
+			break;
+		case USB_PORT_FEAT_C_OVER_CURRENT:
+			trace_info("USB_PORT_C_OVER_CURRENT");
+			break;
+		default:
+			trace_info("Unknown:%x", wValue);
+			goto error;
+		}
+		break;
+	default:
+		trace_info("Unknown:%x", typeReq);
+	error:
+		return_value = -EPIPE;
+	}
+	return return_value;
+}
+
+static int
+usbfront_hcd_start_port_reset(struct usb_hcd *hcd, unsigned port_num)
+{
+	trace();
+	return 0;
+}
+
+static struct hc_driver usbfront_hc_driver = {
+	.description = "usbfront_hc_driver",
+	.product_desc = "Xen USB Front-End Driver",
+	.hcd_priv_size = sizeof(struct usbfront_hcd),
+	/* .irq */
+	.flags = HCD_USB2,
+	/* reset optional. */
+	.start = usbfront_hcd_start,
+	/* suspend optional. */
+	/* resume optional. */
+	.stop = usbfront_hcd_stop,
+	.get_frame_number = usbfront_hcd_get_frame_number,
+	.urb_enqueue = usbfront_hcd_urb_enqueue,
+	.urb_dequeue = usbfront_hcd_urb_dequeue,
+	.endpoint_disable = usbfront_hcd_endpoint_disable,
+	.hub_status_data = usbfront_hcd_hub_status_data,
+	.hub_control = usbfront_hcd_hub_control,
+	/* hub_suspend optional. */
+	/* hub_resume optional. */
+	.start_port_reset = usbfront_hcd_start_port_reset,
+};
+
+static void
+usbfront_hcd_invalid_stimulus(struct usbfront_hcd *uhcd,
+usbfront_hcd_stimulus stimulus);
+
+static void usbfront_hcd_kick_urbs(struct usbfront_hcd *uhcd);
+
+static void
+usbfront_hcd_handle_stimulus(struct usbfront_hcd *uhcd,
+usbfront_hcd_stimulus stimulus)
+{
+	trace_info("uhcd %p in state %d received stimulus %d", uhcd,
+							uhcd->state, stimulus);
+	switch (uhcd->state) {
+	case usbfront_hcd_state_i:
+		switch (stimulus) {
+		case usbfront_hcd_stimulus_uq:
+			usbfront_hcd_kick_urbs(uhcd);
+			break;
+		}
+		break;
+	default:
+		usbfront_hcd_invalid_stimulus(uhcd, stimulus);
+		break;
+	}
+}
+
+static void
+usbfront_hcd_invalid_stimulus(struct usbfront_hcd *uhcd,
+usbfront_hcd_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbfront: hc_driver_uhcd %p in state %d"
+	     "received invalid stimulus %d", uhcd, uhcd->state, stimulus);
+}
+
+static void usbfront_hcd_kick_urbs(struct usbfront_hcd *uhcd)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	trace();
+	while (!usbfront_sll_is_empty(&uhcd->urb_sll) &&
+				!list_empty(&uhcd->free_resource_list)) {
+		struct urb *urb = container_of(
+					(void **)usbfront_sll_remove_first(
+							&uhcd->urb_sll),
+					struct urb, hcpriv);
+		struct usbfront_hcd_resource *resource = list_entry(
+					uhcd->free_resource_list.next,
+					struct usbfront_hcd_resource,
+					callback.work.link);
+		list_del_init(usbfront_hcd_resource_to_link(resource));
+		trace_info("Starting URB");
+		usbfront_hcd_resource_start_urb(resource, urb);
+	}
+}
+
+void usbfront_hcd_resource_completed(struct usbfront_callback * callback)
+{
+	struct usbfront_hcd_resource *resource =
+				usbfront_hcd_resource_callback_to(callback);
+	struct usbfront_hcd *uhcd = usbfront_hcd_hcd_to_uhcd(
+				usbfront_device_get_drvdata(
+				usbfront_hcd_resource_query_device(resource)));
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&uhcd->lock, flags);
+	list_add(usbfront_hcd_resource_to_link(resource),
+						&uhcd->free_resource_list);
+	usbfront_hcd_kick_urbs(uhcd);
+	spin_unlock_irqrestore(&uhcd->lock, flags);
+}
+
+static int
+usbfront_driver_probe_or_remove(struct usbfront_device *device, int remove)
+{
+	int return_value = 0;
+	struct usb_hcd *hcd;
+	trace();
+	if (remove)
+		goto remove_path;
+	if (usb_disabled()) {
+		return_value = -ENODEV;
+		goto exit_no_usb;
+	}
+	if ((hcd = usb_create_hcd(&usbfront_hc_driver,
+			usbfront_device_to_dev(device),
+			usbfront_device_to_dev(device)->bus_id))== NULL) {
+		trace_info("usb_create_hcd failed");
+		return_value = -ENOMEM;
+		goto exit_no_hcd;
+	}
+	usbfront_device_set_drvdata(device, hcd);
+	if ((return_value = usb_add_hcd(hcd, 0, 0)) != 0) {
+		trace_info("usb_add_hcd failed");
+		goto exit_no_add;
+	}
+	return 0;
+ remove_path:
+	hcd = usbfront_device_get_drvdata(device);
+	usb_remove_hcd(hcd);
+ exit_no_add:
+	usb_put_hcd(hcd);
+	usbfront_device_set_drvdata(device, NULL);
+ exit_no_hcd:
+ exit_no_usb:
+	return return_value;
+}
+
+int usbfront_driver_probe(struct usbfront_device *device)
+{
+	trace();
+	return usbfront_driver_probe_or_remove(device, 0);
+}
+
+void usbfront_driver_remove(struct usbfront_device *device)
+{
+	trace();
+	usbfront_driver_probe_or_remove(device, 1);
+}
+
+int usbfront_driver_class_init(void)
+{
+	trace();
+	return usbfront_hcd_resource_class_init();
+}
+
+void usbfront_driver_class_exit(void)
+{
+	trace();
+	usbfront_hcd_resource_class_exit();
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_driver.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_driver.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,30 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_DRIVER_H
+#define USBFRONT_DRIVER_H
+
+#include "usbfront_device.h"
+
+int usbfront_driver_class_init(void);
+void usbfront_driver_class_exit(void);
+int usbfront_driver_probe(struct usbfront_device *device);
+void usbfront_driver_remove(struct usbfront_device *device);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_gw.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_gw.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,503 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include "usbfront_gw.h"
+#include "usbfront_gw_resource.h"
+#include "usbfront_trace.h"
+
+typedef enum {
+	usbfront_gw_stimulus_tq, /* Transaction queued.           */
+	usbfront_gw_stimulus_cc, /* Channel connect.              */
+	usbfront_gw_stimulus_cd, /* Channel disconnect.           */
+	usbfront_gw_stimulus_kt, /* Kick tras completed.          */
+	usbfront_gw_stimulus_ic, /* Initiator resource completed. */
+	usbfront_gw_stimulus_ii, /* Initiator resources idle.     */
+	usbfront_gw_stimulus_lc, /* Client connect completed.     */
+	usbfront_gw_stimulus_lg, /* Client disconnect called.     */
+	usbfront_gw_stimulus_ld, /* Client disconnect completed.  */
+} usbfront_gw_stimulus;
+
+static void
+usbfront_gw_handle_stimulus(struct usbfront_gw *gw,
+usbfront_gw_stimulus stimulus);
+
+void
+usbfront_gw_submit_tra(struct usbfront_gw *gw, struct usbfront_gw_tra *tra)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	unsigned long flags;
+	spin_lock_irqsave(&gw->lock, flags);
+	list_add_tail(usbfront_gw_tra_to_link(tra), &gw->tra_list);
+	usbfront_gw_handle_stimulus(gw, usbfront_gw_stimulus_tq);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbfront_gw_channel_connect(void *context)
+{
+	struct usbfront_gw *gw = context;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&gw->lock, flags);
+	usbfront_gw_handle_stimulus(gw, usbfront_gw_stimulus_cc);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbfront_gw_handle_channel_message(void *context,
+struct usbfront_channel_ibmsg *message)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbfront_gw *gw = context;
+	struct usbfront_gw_resource *resource;
+	usbif_error error = USBIF_ERROR_INVALID_PROTOCOL;
+	if (message->response.gw_status.id >= gw->initiator_quota)
+		goto complete_channel_message;
+	resource = &gw->initiator_resources[message->response.gw_status.id];
+	if (usbfront_gw_resource_handle_response(resource, &message->response)
+									!= 0)
+		goto complete_channel_message;
+	error = USBIF_ERROR_SUCCESS;
+ complete_channel_message:
+	usbfront_callback_complete(usbfront_channel_ibmsg_to_callback(message),
+									error);
+}
+
+static void usbfront_gw_channel_disconnect(void *context,
+struct usbfront_callback *callback)
+{
+	struct usbfront_gw *gw = context;
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&gw->lock, flags);
+	gw->channel_disconnect_callback = callback;
+	usbfront_gw_handle_stimulus(gw, usbfront_gw_stimulus_cd);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+void usbfront_gw_submit_channel_message(struct usbfront_gw *gw,
+struct usbfront_channel_obmsg *message)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	usbfront_channel_submit_message(gw->channel, message);
+}
+
+static void usbfront_gw_invalid_stimulus(struct usbfront_gw *gw,
+usbfront_gw_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbfront: gw %p in state %d"
+		     "received invalid stimulus %d", gw, gw->state, stimulus);
+}
+
+static void usbfront_gw_kick_tras(struct usbfront_gw *gw)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	if (!gw->kick_tras_out) {
+		gw->kick_tras_out = 1;
+		(void)usbfront_work_schedule(&gw->kick_tras_1_work);
+	}
+}
+
+static void usbfront_gw_kick_tras_1(void *data)
+{
+	struct usbfront_gw *gw = data;
+	unsigned long flags;
+	spin_lock_irqsave(&gw->lock, flags);
+	while ((!list_empty(&gw->tra_list)) &&
+			(!list_empty(&gw->initiator_resource_list))) {
+		struct usbfront_gw_tra *tra;
+		struct usbfront_gw_resource *resource;
+		tra = list_entry(gw->tra_list.next,
+				struct usbfront_gw_tra,
+				callback.work.link);
+		resource = list_entry(gw->initiator_resource_list.next,
+				struct usbfront_gw_resource,
+				callback.work.link);
+		list_del_init(usbfront_gw_tra_to_link(tra));
+		list_del_init(usbfront_gw_resource_to_link(resource));
+		gw->initiator_resources_out++;
+		spin_unlock_irqrestore(&gw->lock, flags);
+		usbfront_gw_resource_start(resource, tra);
+		spin_lock_irqsave(&gw->lock, flags);
+	}
+	gw->kick_tras_out = 0;
+	usbfront_gw_handle_stimulus(gw, usbfront_gw_stimulus_kt);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbfront_gw_kick_tras_2(struct usbfront_callback *callback)
+{
+	struct usbfront_gw_resource *resource =
+		usbfront_gw_resource_callback_to(callback);
+	struct usbfront_gw *gw = usbfront_gw_resource_query_gw(resource);
+	unsigned long flags;
+	spin_lock_irqsave(&gw->lock, flags);
+	list_add_tail(usbfront_gw_resource_to_link(resource),
+					&gw->initiator_resource_list);
+	if (--gw->initiator_resources_out != 0) {
+		usbfront_gw_handle_stimulus(gw, usbfront_gw_stimulus_ic);
+	} else {
+		usbfront_gw_handle_stimulus(gw, usbfront_gw_stimulus_ii);
+	}
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbfront_gw_fail_out_tras(struct usbfront_gw *gw)
+{
+	trace();
+	while (!list_empty(&gw->tra_list)) {
+		struct usbfront_gw_tra *tra = list_entry(gw->tra_list.next,
+				struct usbfront_gw_tra,	callback.work.link);
+		list_del_init(usbfront_gw_tra_to_link(tra));
+		usbfront_callback_complete(usbfront_gw_tra_to_callback(tra),
+						USBIF_ERROR_DISCONNECT);
+	}
+}
+
+static void usbfront_gw_connect_client(struct usbfront_gw *gw)
+{
+	trace();
+	(void)usbfront_work_schedule(&gw->connect_client_1_work);
+}
+
+static void usbfront_gw_connect_client_1(void *data)
+{
+	struct usbfront_gw *gw = data;
+	unsigned long flags;
+	trace();
+	gw->connect(gw);
+	spin_lock_irqsave(&gw->lock, flags);
+	usbfront_gw_handle_stimulus(gw, usbfront_gw_stimulus_lc);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbfront_gw_disconnect_client(struct usbfront_gw *gw)
+{
+	trace();
+	(void)usbfront_work_schedule(&gw->disconnect_client_1_work);
+}
+
+static void usbfront_gw_disconnect_client_1(void *data)
+{
+	struct usbfront_gw *gw = data;
+	unsigned long flags;
+	trace();
+	gw->disconnect(gw, &gw->disconnect_client_2_callback);
+	spin_lock_irqsave(&gw->lock, flags);
+	usbfront_gw_handle_stimulus(gw, usbfront_gw_stimulus_lg);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbfront_gw_disconnect_client_2(struct usbfront_callback *callback)
+{
+	struct usbfront_gw *gw = container_of(callback, struct usbfront_gw,
+						disconnect_client_2_callback);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&gw->lock, flags);
+	usbfront_gw_handle_stimulus(gw, usbfront_gw_stimulus_ld);
+	spin_unlock_irqrestore(&gw->lock, flags);
+}
+
+static void usbfront_gw_abort_initiator_resources(struct usbfront_gw *gw)
+{
+	u32 i;
+	trace();
+	for (i = 0; i < gw->initiator_quota; i++)
+		usbfront_gw_resource_abort(&gw->initiator_resources[i],
+						USBIF_ERROR_DISCONNECT);
+}
+
+static void usbfront_gw_test_initiator_resources(struct usbfront_gw *gw)
+{
+	trace();
+	if (gw->initiator_resources_out == 0)
+		usbfront_gw_handle_stimulus(gw, usbfront_gw_stimulus_ii);
+}
+
+static void usbfront_gw_complete_channel_disconnect(struct usbfront_gw *gw)
+{
+	trace();
+	usbfront_callback_success(gw->channel_disconnect_callback);
+}
+
+static int usbfront_gw_init_or_exit(struct usbfront_gw *gw, int exit)
+{
+	int return_value = 0;
+	u32 i;
+	trace();
+	if (exit)
+		goto exit_path;
+	INIT_LIST_HEAD(&gw->initiator_resource_list);
+	if (gw->initiator_quota != 0) {
+		/*FIXME: kmalloc > page size*/
+		gw->initiator_resources = kmalloc(sizeof(
+				struct usbfront_gw_resource) *
+				gw->initiator_quota, GFP_KERNEL);
+		if (gw->initiator_resources == NULL) {
+			return_value = -ENOMEM;
+			goto exit_no_initiator_resources;
+		}
+		for (i = 0; i < gw->initiator_quota; i++) {
+			struct usbfront_gw_resource *resource =
+					&gw->initiator_resources[i];
+			usbfront_gw_resource_init(resource,
+					gw, usbfront_gw_kick_tras_2, i);
+			list_add_tail(usbfront_gw_resource_to_link(resource),
+						&gw->initiator_resource_list);
+		}
+	}
+	spin_lock_init(&gw->lock);
+	gw->state = usbfront_gw_state_i;
+	INIT_LIST_HEAD(&gw->tra_list);
+	usbfront_work_init(&gw->kick_tras_1_work, usbfront_gw_kick_tras_1, gw);
+	usbfront_work_init(&gw->connect_client_1_work,
+					usbfront_gw_connect_client_1, gw);
+	usbfront_work_init(&gw->disconnect_client_1_work,
+					usbfront_gw_disconnect_client_1, gw);
+	usbfront_callback_init(&gw->disconnect_client_2_callback,
+					usbfront_gw_disconnect_client_2);
+	gw->kick_tras_out = 0;
+	gw->initiator_resources_out = 0;
+	return 0;
+ exit_path:
+	if (gw->initiator_quota != 0)
+		kfree(gw->initiator_resources);
+ exit_no_initiator_resources:
+	return return_value;
+}
+
+int
+usbfront_gw_init(struct usbfront_gw *gw,
+struct usbfront_channel *channel, usbfront_gw_connect_function *connect,
+usbfront_gw_disconnect_function *disconnect, u32 initiator_quota)
+{
+	trace();
+	gw->channel = channel;
+	gw->connect = connect;
+	gw->disconnect = disconnect;
+	gw->initiator_quota = initiator_quota;
+	usbfront_channel_install_client(channel, gw,
+				usbfront_gw_channel_connect,
+				usbfront_gw_handle_channel_message,
+				usbfront_gw_channel_disconnect);
+	return usbfront_gw_init_or_exit(gw, 0);
+}
+
+void usbfront_gw_exit(struct usbfront_gw *gw)
+{
+	trace();
+	(void)usbfront_gw_init_or_exit(gw, 1);
+}
+
+static void
+usbfront_gw_handle_stimulus(struct usbfront_gw *gw,
+usbfront_gw_stimulus stimulus)
+{
+	switch (gw->state) {
+	case usbfront_gw_state_i:
+		/* Channel disconnected.     */
+		/* Client disconnected.      */
+		/* No tras queued.           */
+		/* Initiator resources idle. */
+		/* Not kicking tras.         */
+		switch (stimulus) {
+		case usbfront_gw_stimulus_cc:
+			gw->state = usbfront_gw_state_i_cc;
+			usbfront_gw_connect_client(gw);
+			break;
+		default:
+			usbfront_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_state_i_cc:
+		/* Channel connected.        */
+		/* Client connecting.        */
+		/* Maybe tras queued.        */
+		/* Initiator resources idle. */
+		/* Not kicking tras.         */
+		switch (stimulus) {
+		case usbfront_gw_stimulus_tq:
+			break;
+		case usbfront_gw_stimulus_cd:
+			gw->state = usbfront_gw_state_i_cc_cd;
+			break;
+		case usbfront_gw_stimulus_lc:
+			gw->state = usbfront_gw_state_i_cc_lc;
+			usbfront_gw_kick_tras(gw);
+			break;
+		default:
+			usbfront_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_state_i_cc_cd:
+		/* Channel disconnecting.    */
+		/* Client connecting.        */
+		/* Maybe tras queued.        */
+		/* Initiator resources idle. */
+		/* Not kicking tras.         */
+		switch (stimulus) {
+		case usbfront_gw_stimulus_tq:
+			break;
+		case usbfront_gw_stimulus_lc:
+			gw->state = usbfront_gw_state_i_cc_cd_lc;
+			usbfront_gw_disconnect_client(gw);
+			break;
+		default:
+			usbfront_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_state_i_cc_lc:
+		/* Channel connected.              */
+		/* Client connected.               */
+		/* Maybe tras queued.              */
+		/* Maybe initiator resources busy. */
+		/* Maybe kicking tras.             */
+		switch (stimulus) {
+		case usbfront_gw_stimulus_tq:
+			usbfront_gw_kick_tras(gw);
+			break;
+		case usbfront_gw_stimulus_cd:
+			gw->state = usbfront_gw_state_i_cc_lc_cd;
+			usbfront_gw_kick_tras(gw);
+			break;
+		case usbfront_gw_stimulus_kt:
+			break;
+		case usbfront_gw_stimulus_ic:
+		case usbfront_gw_stimulus_ii:
+			usbfront_gw_kick_tras(gw);
+			break;
+		default:
+			usbfront_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_state_i_cc_lc_cd:
+		/* Channel disconnecting.          */
+		/* Client connected.               */
+		/* Maybe tras queued.              */
+		/* Maybe initiator resources busy. */
+		/* Kicking tras.                   */
+		switch (stimulus) {
+		case usbfront_gw_stimulus_tq:
+			break;
+		case usbfront_gw_stimulus_kt:
+			gw->state = usbfront_gw_state_i_cc_cd_lc;
+			usbfront_gw_disconnect_client(gw);
+			break;
+		case usbfront_gw_stimulus_ic:
+		case usbfront_gw_stimulus_ii:
+			break;
+		default:
+			usbfront_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_state_i_cc_cd_lc:
+		/* Channel disconnecting.          */
+		/* Calling client disconnect.      */
+		/* Maybe tras queued.              */
+		/* Maybe initiator resources busy. */
+		/* Not kicking tras.               */
+		switch (stimulus) {
+		case usbfront_gw_stimulus_tq:
+			break;
+		case usbfront_gw_stimulus_ic:
+		case usbfront_gw_stimulus_ii:
+			break;
+		case usbfront_gw_stimulus_lg:
+			gw->state = usbfront_gw_state_i_cc_cd_lc_lg;
+			usbfront_gw_fail_out_tras(gw);
+			usbfront_gw_abort_initiator_resources(gw);
+			break;
+		case usbfront_gw_stimulus_ld:
+			gw->state = usbfront_gw_state_i_cc_cd_lc_ld;
+			break;
+		default:
+			usbfront_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_state_i_cc_cd_lc_lg:
+		/* Channel disconnecting.          */
+		/* Client disconnecting.           */
+		/* No tras queued.                 */
+		/* Maybe initiator resources busy. */
+		/* Not kicking tras.               */
+		switch (stimulus) {
+		case usbfront_gw_stimulus_tq:
+			break;
+		case usbfront_gw_stimulus_ic:
+		case usbfront_gw_stimulus_ii:
+			break;
+		case usbfront_gw_stimulus_ld:
+			gw->state =
+			    usbfront_gw_state_i_cc_cd_lc_lg_ld;
+			usbfront_gw_test_initiator_resources(gw);
+			break;
+		default:
+			usbfront_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_state_i_cc_cd_lc_ld:
+		/* Channel disconnecting.                          */
+		/* Client disconnected but call still in progress. */
+		/* No tras queued.                                 */
+		/* Maybe initiator resources busy.                 */
+		/* Not kicking tras.                               */
+		switch (stimulus) {
+		case usbfront_gw_stimulus_ic:
+		case usbfront_gw_stimulus_ii:
+			break;
+		case usbfront_gw_stimulus_lg:
+			gw->state =
+			    usbfront_gw_state_i_cc_cd_lc_lg_ld;
+			usbfront_gw_test_initiator_resources(gw);
+			break;
+		default:
+			usbfront_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_state_i_cc_cd_lc_lg_ld:
+		/* Channel disconnecting.                                */
+		/* Client disconnected.                                  */
+		/* No tras queued.                                       */
+		/* Test initiator resources or initiator resources busy. */
+		/* Not kicking tras.                                     */
+		switch (stimulus) {
+		case usbfront_gw_stimulus_ic:
+			break;
+		case usbfront_gw_stimulus_ii:
+			gw->state = usbfront_gw_state_i;
+			usbfront_gw_complete_channel_disconnect(gw);
+			break;
+		default:
+			usbfront_gw_invalid_stimulus(gw, stimulus);
+			break;
+		}
+		break;
+	default:
+		usbfront_gw_invalid_stimulus(gw, stimulus);
+		break;
+	}
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_gw.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_gw.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,123 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_GW_H
+#define USBFRONT_GW_H
+
+#include "usbfront_callback.h"
+#include "usbfront_channel.h"
+
+struct usbfront_gw_resource;
+
+struct usbfront_gw_tra {
+	struct usbfront_callback callback;
+	union usbif_parameters   parameters;
+	union usbif_status       status;
+};
+
+static inline struct usbfront_callback *
+usbfront_gw_tra_to_callback(struct usbfront_gw_tra *tra)
+{
+	return &tra->callback;
+}
+
+static inline struct usbfront_gw_tra *
+usbfront_gw_tra_callback_to(struct usbfront_callback *callback)
+{
+	return container_of(callback, struct usbfront_gw_tra, callback);
+}
+
+static inline struct list_head *
+usbfront_gw_tra_to_link(struct usbfront_gw_tra *tra)
+{
+	return usbfront_callback_to_link(usbfront_gw_tra_to_callback(tra));
+}
+
+static inline struct usbfront_gw_tra *
+usbfront_gw_tra_link_to(struct list_head *link)
+{
+	return usbfront_gw_tra_callback_to(usbfront_callback_link_to(link));
+}
+
+static inline void usbfront_gw_tra_init(struct usbfront_gw_tra *tra,
+usbfront_callback_function *callback)
+{
+	usbfront_callback_init(usbfront_gw_tra_to_callback(tra), callback);
+}
+
+static inline void
+usbfront_gw_tra_complete(struct usbfront_gw_tra *tra, usbif_error error)
+{
+	usbfront_callback_complete(usbfront_gw_tra_to_callback(tra), error);
+}
+
+static inline
+usbif_error usbfront_gw_tra_query_error(struct usbfront_gw_tra *tra)
+{
+	return usbfront_callback_query_error(usbfront_gw_tra_to_callback(tra));
+}
+
+typedef enum {
+	usbfront_gw_state_i,
+	usbfront_gw_state_i_cc,
+	usbfront_gw_state_i_cc_cd,
+	usbfront_gw_state_i_cc_lc,
+	usbfront_gw_state_i_cc_lc_cd,
+	usbfront_gw_state_i_cc_cd_lc,
+	usbfront_gw_state_i_cc_cd_lc_lg,
+	usbfront_gw_state_i_cc_cd_lc_ld,
+	usbfront_gw_state_i_cc_cd_lc_lg_ld
+} usbfront_gw_state;
+
+struct usbfront_gw;
+
+typedef void usbfront_gw_connect_function(struct usbfront_gw *gw);
+
+typedef void usbfront_gw_disconnect_function(struct usbfront_gw *gw,
+struct usbfront_callback *callback);
+
+struct usbfront_gw {
+	struct usbfront_channel         *channel;
+	usbfront_gw_connect_function    *connect;
+	usbfront_gw_disconnect_function *disconnect;
+	u32                              initiator_quota;
+	struct list_head                 initiator_resource_list;
+	struct usbfront_gw_resource     *initiator_resources;
+	spinlock_t                       lock;
+	usbfront_gw_state                state;
+	struct list_head                 tra_list;
+	struct usbfront_work             kick_tras_1_work;
+	struct usbfront_work             connect_client_1_work;
+	struct usbfront_work             disconnect_client_1_work;
+	struct usbfront_callback         disconnect_client_2_callback;
+	int                              kick_tras_out;
+	u32                              initiator_resources_out;
+	struct usbfront_callback        *channel_disconnect_callback;
+};
+
+int usbfront_gw_init(struct usbfront_gw *gw,
+struct usbfront_channel *channel, usbfront_gw_connect_function *connect,
+usbfront_gw_disconnect_function *disconnect, u32 initiator_quota);
+
+extern void
+usbfront_gw_submit_tra(struct usbfront_gw *gw, struct usbfront_gw_tra *tra);
+
+extern void usbfront_gw_exit(struct usbfront_gw *gw);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_gw_resource.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_gw_resource.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,211 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include "usbfront_gw_resource.h"
+#include "usbfront_trace.h"
+
+void usbfront_gw_submit_channel_message(struct usbfront_gw *gw,
+struct usbfront_channel_obmsg *message);
+
+static void
+usbfront_gw_resource_handle_stimulus(struct usbfront_gw_resource *resource,
+usbfront_gw_resource_stimulus stimulus);
+
+void usbfront_gw_resource_start(struct usbfront_gw_resource *resource,
+struct usbfront_gw_tra *tra)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	unsigned long flags;
+	resource->tra = tra;
+	resource->error = USBIF_ERROR_SUCCESS;
+	resource->channel_message.request.usbif_parameters =
+						tra->parameters;
+	spin_lock_irqsave(&resource->lock, flags);
+	usbfront_gw_resource_handle_stimulus(resource,
+			usbfront_gw_resource_stimulus_st);
+	spin_unlock_irqrestore(&resource->lock, flags);
+	usbfront_gw_submit_channel_message(resource->gw,
+						&resource->channel_message);
+}
+
+void usbfront_gw_resource_abort(struct usbfront_gw_resource *resource,
+usbif_error error)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&resource->lock, flags);
+	resource->aborted_error = error;
+	usbfront_gw_resource_handle_stimulus(resource,
+			usbfront_gw_resource_stimulus_ab);
+	spin_unlock_irqrestore(&resource->lock, flags);
+}
+
+static void usbfront_gw_resource_channel_message_callback(
+struct usbfront_callback *callback)
+{
+	struct usbfront_gw_resource *resource = container_of(callback,
+			struct usbfront_gw_resource, channel_message.callback);
+	unsigned long flags;
+	spin_lock_irqsave(&resource->lock, flags);
+	usbfront_gw_resource_handle_stimulus(resource,
+					usbfront_gw_resource_stimulus_sc);
+	spin_unlock_irqrestore(&resource->lock, flags);
+}
+
+int usbfront_gw_resource_handle_response(struct usbfront_gw_resource *resource,
+struct usbif_response *response)
+{
+	int return_value = -1;
+	unsigned long flags;
+	spin_lock_irqsave(&resource->lock, flags);
+	if ((resource->state == usbfront_gw_resource_state_i_st)
+		||(resource->state == usbfront_gw_resource_state_i_st_sc)) {
+		resource->tra->status = response->usbif_status;
+		resource->error = response->gw_status.error;
+		usbfront_gw_resource_handle_stimulus(resource,
+					usbfront_gw_resource_stimulus_ts);
+		return_value = 0;
+	}
+	spin_unlock_irqrestore(&resource->lock, flags);
+	return return_value;
+}
+
+
+static void
+usbfront_gw_resource_invalid_stimulus(struct usbfront_gw_resource *resource,
+usbfront_gw_resource_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbfront: gw initiator resource %p in state %d"
+		"received invalid stimulus %d", resource, resource->state,
+								stimulus);
+}
+
+static void
+usbfront_gw_resource_set_aborted(struct usbfront_gw_resource *resource)
+{
+	trace();
+	resource->error = resource->aborted_error;
+}
+
+static void
+usbfront_gw_resource_complete(struct usbfront_gw_resource *resource)
+{
+	usbfront_callback_complete(&resource->tra->callback, resource->error);
+	usbfront_callback_success(&resource->callback);
+}
+
+void usbfront_gw_resource_init(struct usbfront_gw_resource *resource,
+struct usbfront_gw *gw, usbfront_callback_function callback, int id)
+{
+	trace();
+	usbfront_callback_init(&resource->callback, callback);
+	resource->gw = gw;
+	resource->channel_message.request.gw_parameters.id = id;
+	spin_lock_init(&resource->lock);
+	resource->state = usbfront_gw_resource_state_i;
+	usbfront_callback_init(usbfront_channel_obmsg_to_callback(
+				&resource->channel_message),
+				usbfront_gw_resource_channel_message_callback);
+}
+
+static void
+usbfront_gw_resource_handle_stimulus(struct usbfront_gw_resource *resource,
+usbfront_gw_resource_stimulus stimulus)
+{
+	switch (resource->state) {
+	case usbfront_gw_resource_state_i:
+		switch (stimulus) {
+		case usbfront_gw_resource_stimulus_st:
+			resource->state = usbfront_gw_resource_state_i_st;
+			break;
+		case usbfront_gw_resource_stimulus_ab:
+			break;
+		default:
+			usbfront_gw_resource_invalid_stimulus(resource,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_resource_state_i_st:
+		switch (stimulus) {
+		case usbfront_gw_resource_stimulus_ab:
+			resource->state = usbfront_gw_resource_state_i_st_ab;
+			break;
+		case usbfront_gw_resource_stimulus_sc:
+			resource->state = usbfront_gw_resource_state_i_st_sc;
+			break;
+		case usbfront_gw_resource_stimulus_ts:
+			resource->state = usbfront_gw_resource_state_i_st_ts;
+			break;
+		default:
+			usbfront_gw_resource_invalid_stimulus(resource,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_resource_state_i_st_ab:
+		switch (stimulus) {
+		case usbfront_gw_resource_stimulus_sc:
+			resource->state = usbfront_gw_resource_state_i;
+			usbfront_gw_resource_set_aborted(resource);
+			usbfront_gw_resource_complete(resource);
+			break;
+		default:
+			usbfront_gw_resource_invalid_stimulus(resource,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_resource_state_i_st_sc:
+		switch (stimulus) {
+		case usbfront_gw_resource_stimulus_ab:
+			resource->state = usbfront_gw_resource_state_i;
+			usbfront_gw_resource_set_aborted(resource);
+			usbfront_gw_resource_complete(resource);
+			break;
+		case usbfront_gw_resource_stimulus_ts:
+			resource->state = usbfront_gw_resource_state_i;
+			usbfront_gw_resource_complete(resource);
+			break;
+		default:
+			usbfront_gw_resource_invalid_stimulus(resource,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_gw_resource_state_i_st_ts:
+		switch (stimulus) {
+		case usbfront_gw_resource_stimulus_ab:
+			break;
+		case usbfront_gw_resource_stimulus_sc:
+			resource->state = usbfront_gw_resource_state_i;
+			usbfront_gw_resource_complete(resource);
+			break;
+		default:
+			usbfront_gw_resource_invalid_stimulus(resource,
+								stimulus);
+			break;
+		}
+		break;
+	default:
+		usbfront_gw_resource_invalid_stimulus(resource, stimulus);
+		break;
+	}
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_gw_resource.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_gw_resource.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,84 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_GW_RESOURCE_H
+#define USBFRONT_GW_RESOURCE_H
+
+#include <linux/types.h>
+#include <xen/interface/io/usbif.h>
+#include "usbfront_channel.h"
+#include "usbfront_gw.h"
+
+typedef enum {
+	usbfront_gw_resource_state_i,
+	usbfront_gw_resource_state_i_st,
+	usbfront_gw_resource_state_i_st_ab,
+	usbfront_gw_resource_state_i_st_sc,
+	usbfront_gw_resource_state_i_st_ts
+} usbfront_gw_resource_state;
+
+typedef enum {
+	usbfront_gw_resource_stimulus_st,
+	usbfront_gw_resource_stimulus_ab,
+	usbfront_gw_resource_stimulus_sc,
+	usbfront_gw_resource_stimulus_ts,
+} usbfront_gw_resource_stimulus;
+
+struct usbfront_gw_resource {
+	struct usbfront_callback      callback;
+	struct usbfront_gw           *gw;
+	spinlock_t                    lock;
+	usbfront_gw_resource_state    state;
+	struct usbfront_gw_tra       *tra;
+	usbif_error                   aborted_error;
+	usbif_error                   error;
+	struct usbfront_channel_obmsg channel_message;
+};
+
+static inline struct list_head *
+usbfront_gw_resource_to_link(struct usbfront_gw_resource *resource)
+{
+	return &resource->callback.work.link;
+}
+
+static inline struct usbfront_gw_resource *
+usbfront_gw_resource_callback_to(struct usbfront_callback *callback)
+{
+	return container_of(callback, struct usbfront_gw_resource, callback);
+}
+
+static inline struct usbfront_gw *
+usbfront_gw_resource_query_gw(struct usbfront_gw_resource *resource)
+{
+	return resource->gw;
+}
+
+void usbfront_gw_resource_init(struct usbfront_gw_resource *resource,
+struct usbfront_gw *gw, usbfront_callback_function callback, int id);
+
+void usbfront_gw_resource_start(struct usbfront_gw_resource *resource,
+struct usbfront_gw_tra *tra);
+
+void usbfront_gw_resource_abort(struct usbfront_gw_resource *resource,
+usbif_error error);
+
+int usbfront_gw_resource_handle_response(struct usbfront_gw_resource *resource,
+struct usbif_response *response);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_hcd_resource.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_hcd_resource.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,605 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Based on arch/xen/drivers/usbif/frontend/main.c, original copyright       */
+/* notice follows...                                                         */
+/*****************************************************************************/
+
+/*
+ * Xen Virtual USB Frontend Driver 
+ *
+ * This file contains the first version of the Xen virtual USB hub
+ * that I've managed not to delete by mistake (3rd time lucky!).
+ *
+ * Based on Linux's uhci.c, original copyright notices are displayed
+ * below.  Portions also (c) 2004 Intel Research Cambridge
+ * and (c) 2004, 2005 Mark Williamson
+ *
+ * Contact <mark.williamson@cl.cam.ac.uk> or
+ * <xen-devel@lists.sourceforge.net> regarding this code.
+ *
+ * Still to be (maybe) implemented:
+ * - migration / backend restart support?
+ * - support for building / using as a module
+ */
+
+/*
+ * Universal Host Controller Interface driver for USB.
+ *
+ * Maintainer: Johannes Erdfelt <johannes@erdfelt.com>
+ *
+ * (C) Copyright 1999 Linus Torvalds
+ * (C) Copyright 1999-2002 Johannes Erdfelt, johannes@erdfelt.com
+ * (C) Copyright 1999 Randy Dunlap
+ * (C) Copyright 1999 Georg Acher, acher@in.tum.de
+ * (C) Copyright 1999 Deti Fliegl, deti@fliegl.de
+ * (C) Copyright 1999 Thomas Sailer, sailer@ife.ee.ethz.ch
+ * (C) Copyright 1999 Roman Weissgaerber, weissg@vienna.at
+ * (C) Copyright 2000 Yggdrasil Computing, Inc. (port of new PCI interface
+ *               support from usb-ohci.c by Adam Richter, adam@yggdrasil.com).
+ * (C) Copyright 1999 Gregory P. Smith (from usb-ohci.c)
+ *
+ * Intel documents this fairly well, and as far as I know there
+ * are no royalties or anything like that, but even so there are
+ * people who decided that they want to do the same thing in a
+ * completely different way.
+ *
+ * WARNING! The USB documentation is downright evil. Most of it
+ * is just crap, written by a committee. You're better off ignoring
+ * most of it, the important stuff is:
+ *  - the low-level protocol (fairly simple but lots of small details)
+ *  - working around the horridness of the rest
+ */
+
+#include "usbfront_driver.h"
+#include "usbfront_hcd_resource.h"
+#include "usbfront_rbr_provider_pool.h"
+#include "usbfront_trace.h"
+
+struct usbfront_rbr_provider_pool *rbr_provider_pool;
+
+int usbfront_hcd_resource_class_init(void)
+{
+	trace();
+	rbr_provider_pool = usbfront_rbr_provider_pool_allocate();
+	return (rbr_provider_pool != NULL) ? 0 : -ENOMEM;
+}
+
+void usbfront_hcd_resource_class_exit(void)
+{
+	trace();
+	usbfront_rbr_provider_pool_free(rbr_provider_pool);
+}
+
+typedef enum {
+	usbfront_hcd_resource_stimulus_st,	/* Start URB            */
+	usbfront_hcd_resource_stimulus_dq,	/* Dequeue URB          */
+	usbfront_hcd_resource_stimulus_cs,	/* Create RBRs success  */
+	usbfront_hcd_resource_stimulus_cf,	/* Create RBRs failure  */
+	usbfront_hcd_resource_stimulus_tc,	/* Transaction complete */
+	usbfront_hcd_resource_stimulus_rc,	/* Revoke RBRs complete */
+	usbfront_hcd_resource_stimulus_uc,	/* Unlink complete      */
+} usbfront_hcd_resource_stimulus;
+
+static void
+usbfront_hcd_resource_handle_stimulus(struct usbfront_hcd_resource *resource,
+usbfront_hcd_resource_stimulus stimulus);
+
+void usbfront_hcd_resource_start_urb(struct usbfront_hcd_resource *resource,
+struct urb *urb)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	unsigned long flags;
+	trace();
+	urb->hcpriv = resource;
+	spin_lock_irqsave(&resource->lock, flags);
+	resource->urb = urb;
+	usbfront_hcd_resource_handle_stimulus(resource,
+					usbfront_hcd_resource_stimulus_st);
+	spin_unlock_irqrestore(&resource->lock, flags);
+}
+
+static DEFINE_RWLOCK(dequeue_lock);
+
+void usbfront_hcd_resource_dequeue_urb(struct urb *urb)
+{
+	unsigned long flags;
+	trace();
+	write_lock_irqsave(&dequeue_lock, flags);
+	if (urb->hcpriv != NULL) {
+		struct usbfront_hcd_resource *resource =
+				(struct usbfront_hcd_resource *)urb->hcpriv;
+		unsigned long flags2;
+		spin_lock_irqsave(&resource->lock, flags2);
+		usbfront_hcd_resource_handle_stimulus(resource,
+					usbfront_hcd_resource_stimulus_dq);
+		spin_unlock_irqrestore(&resource->lock, flags2);
+	}
+	write_unlock_irqrestore(&dequeue_lock, flags);
+}
+
+
+static void
+usbfront_hcd_resource_invalid_stimulus(struct usbfront_hcd_resource *resource,
+usbfront_hcd_resource_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbfront: hcd resource %p in state %d"
+				"received invalid stimulus %d",
+				resource, resource->state, stimulus);
+}
+
+static void
+usbfront_hcd_resource_create_rbrs(struct usbfront_hcd_resource *resource)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	trace();
+	usbfront_create_rbr_request_element_ensure_removed(
+					&resource->rbr_request_element[0]);
+	usbfront_create_rbr_request_element_ensure_removed(
+					&resource->rbr_request_element[1]);
+	usbfront_create_rbr_request_element_set_buffer(
+			&resource->rbr_request_element[0],
+			resource->urb->transfer_buffer,
+			resource->urb->transfer_buffer_length,
+			usb_pipein(resource->urb->pipe) ?
+					USBFRONT_ACCESS_FLAGS_WRITE :
+					USBFRONT_ACCESS_FLAGS_READ);
+	usbfront_rbr_provider_request_add_element(&resource->rbr_request,
+					&resource->rbr_request_element[0]);
+	if (usb_pipetype(resource->urb->pipe) == PIPE_ISOCHRONOUS) {
+		struct usbif_isochronous_io_schedule_element *element;
+		int i;
+		if (resource->urb->number_of_packets > (PAGE_SIZE /
+			sizeof(struct
+				usbif_isochronous_io_schedule_element)))
+			goto schedule_too_big;
+		element = resource->schedule;
+		for (i = 0; i < resource->urb->number_of_packets; i++) {
+			memset(&element[i], 0, sizeof(element[i]));
+			element[i].offset = resource->urb->iso_frame_desc[i].
+									offset;
+			element[i].length = resource->urb->iso_frame_desc[i].
+									length;
+		}
+		usbfront_create_rbr_request_element_set_buffer(
+			&resource->rbr_request_element[1],
+			resource->schedule,
+			sizeof(struct usbif_isochronous_io_schedule_element) *
+				resource->urb->number_of_packets,
+			USBFRONT_ACCESS_FLAGS_WRITE |
+						USBFRONT_ACCESS_FLAGS_READ);
+		usbfront_rbr_provider_request_add_element(
+					&resource->rbr_request,
+					&resource->rbr_request_element[1]);
+	}
+	usbfront_rbr_provider_pool_reserve_and_create_rbrs(rbr_provider_pool,
+			&resource->rbr_request,
+			usbfront_device_query_domain(resource->device));
+	return;
+      schedule_too_big:
+	usbfront_callback_complete(
+		usbfront_rbr_provider_request_to_create_callback(
+				&resource->rbr_request), USBIF_ERROR_TOO_BIG);
+}
+
+static void
+usbfront_hcd_resource_create_rbrs_1(struct usbfront_callback * callback)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbfront_hcd_resource *resource = container_of(
+		usbfront_rbr_provider_request_create_callback_to(callback),
+		struct usbfront_hcd_resource, rbr_request);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&resource->lock, flags);
+	if (usbfront_callback_query_error(callback) == USBIF_ERROR_SUCCESS) {
+		usbfront_hcd_resource_handle_stimulus(resource,
+					usbfront_hcd_resource_stimulus_cs);
+	} else {
+		usbfront_hcd_resource_handle_stimulus(resource,
+					usbfront_hcd_resource_stimulus_cf);
+	}
+	spin_unlock_irqrestore(&resource->lock, flags);
+}
+
+static void
+usbfront_hcd_resource_abort_create_rbrs(struct usbfront_hcd_resource *resource)
+{
+	trace();
+	usbfront_rbr_provider_pool_abort_reserve_and_create_rbrs(
+			&resource->rbr_request, USBIF_ERROR_UNLINKED);
+}
+
+static void
+usbfront_hcd_resource_set_unlinked_error(
+struct usbfront_hcd_resource *resource)
+{
+	trace();
+	usbfront_callback_set_error(
+		usbfront_rbr_provider_request_to_create_callback(
+			&resource->rbr_request), USBIF_ERROR_UNLINKED);
+}
+
+static void
+usbfront_hcd_resource_submit_tra(
+struct usbfront_hcd_resource *resource)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct urb *urb = resource->urb;
+	union usbif_io_tra_parameters *parameters =
+				&resource->io_tra.parameters.io;
+	trace();
+	memset(parameters, 0, sizeof(*parameters));
+	parameters->header.header.tra_type = USBIF_TRA_TYPE_IO;
+	parameters->header.device_number = usb_pipedevice(urb->pipe);
+	parameters->header.endpoint = usb_pipeendpoint(urb->pipe);
+	parameters->header.direction = usb_pipein(urb->pipe) ?
+					USBIF_IO_TRA_DIRECTION_IN :
+					USBIF_IO_TRA_DIRECTION_OUT;
+	parameters->header.unlink_id = resource->index;
+	if (urb->transfer_flags & URB_SHORT_NOT_OK)
+		parameters->header.flags |= USBIF_IO_FLAGS_SHORT_NOT_OK;
+	if (urb->transfer_flags & URB_ZERO_PACKET)
+		parameters->header.flags |= USBIF_IO_FLAGS_ZERO_PACKET;
+	parameters->header.rbr = usbfront_create_rbr_request_element_query_rbr(
+					&resource->rbr_request_element[0]);
+	if (usb_pipetype(urb->pipe) == PIPE_CONTROL) {
+		parameters->header.io_tra_type =
+					USBIF_IO_TRA_TYPE_CONTROL;
+		memcpy(parameters->control.setup,urb->setup_packet, 8);
+	} else if (usb_pipetype(urb->pipe) == PIPE_BULK) {
+		parameters->header.io_tra_type =
+					USBIF_IO_TRA_TYPE_BULK;
+	} else if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) {
+		parameters->header.io_tra_type =
+					USBIF_IO_TRA_TYPE_INTERRUPT;
+		parameters->interrupt.interval = urb->interval;
+	} else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+		parameters->header.io_tra_type =
+					USBIF_IO_TRA_TYPE_ISOCHRONOUS;
+		parameters->isochronous.interval = urb->interval;
+		parameters->isochronous.schedule_rbr =
+				usbfront_create_rbr_request_element_query_rbr(
+					&resource->rbr_request_element[1]);
+		parameters->isochronous.packet_count = urb->number_of_packets;
+	}
+
+	usbfront_device_submit_tra(resource->device,
+						&resource->io_tra);
+}
+
+static void
+usbfront_hcd_resource_submit_tra_1(struct usbfront_callback *callback)
+{
+	struct usbfront_hcd_resource *resource = container_of(
+			usbfront_gw_tra_callback_to(callback),
+			struct usbfront_hcd_resource, io_tra);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&resource->lock, flags);
+	usbfront_hcd_resource_handle_stimulus(resource,
+					usbfront_hcd_resource_stimulus_tc);
+	spin_unlock_irqrestore(&resource->lock, flags);
+}
+
+static void
+usbfront_hcd_resource_revoke_rbrs(struct usbfront_hcd_resource *resource)
+{
+	trace();
+	usbfront_rbr_provider_pool_revoke_and_unreserve_rbrs(&resource->
+								rbr_request);
+}
+
+static void
+usbfront_hcd_resource_revoke_rbrs_1(struct usbfront_callback *callback)
+{
+	struct usbfront_hcd_resource *resource = container_of(
+		usbfront_rbr_provider_request_revoke_callback_to(callback),
+		struct usbfront_hcd_resource, rbr_request);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&resource->lock, flags);
+	usbfront_hcd_resource_handle_stimulus(resource,
+					usbfront_hcd_resource_stimulus_rc);
+	spin_unlock_irqrestore(&resource->lock, flags);
+}
+
+static void usbfront_hcd_resource_submit_unlink(
+struct usbfront_hcd_resource *resource)
+{
+	struct usbif_unlink_tra_parameters *parameters =
+		&resource->unlink_tra.parameters.unlink;
+	trace();
+	memset(parameters, 0, sizeof(*parameters));
+	parameters->header.tra_type = USBIF_TRA_TYPE_UNLINK;
+	parameters->unlink_id = resource->index;
+	usbfront_device_submit_tra(resource->device,
+						&resource->unlink_tra);
+}
+
+static void
+usbfront_hcd_resource_submit_unlink_1(struct usbfront_callback *callback)
+{
+	struct usbfront_hcd_resource *resource = container_of(
+			usbfront_gw_tra_callback_to(callback),
+			struct usbfront_hcd_resource, unlink_tra);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&resource->lock, flags);
+	usbfront_hcd_resource_handle_stimulus(resource,
+					usbfront_hcd_resource_stimulus_uc);
+	spin_unlock_irqrestore(&resource->lock, flags);
+}
+
+static void
+usbfront_hcd_resource_complete(struct usbfront_hcd_resource *resource)
+{
+	int scheduled;
+	trace();
+	scheduled = usbfront_work_schedule(&resource->complete_1_work);
+}
+
+static void usbfront_hcd_resource_complete_1(void *context)
+{
+	struct usbfront_hcd_resource *resource = context;
+	struct urb *urb = resource->urb;
+	usbif_error error;
+	unsigned long flags;
+	trace();
+	if (((error = usbfront_callback_query_error(
+		usbfront_rbr_provider_request_to_create_callback(
+		&resource->rbr_request))) == USBIF_ERROR_SUCCESS) && ((error =
+		usbfront_callback_query_error(
+		usbfront_rbr_provider_request_to_revoke_callback(
+		&resource->rbr_request))) == USBIF_ERROR_SUCCESS)) {
+		urb->status = usbif_error_map_to_local(
+			usbfront_gw_tra_query_error(&resource->
+							io_tra));
+		urb->actual_length = resource->io_tra.status.io.length;
+		if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+			int i;
+			urb->error_count = 0;
+			for (i = 0; i < urb->number_of_packets; i++) {
+				struct usbif_isochronous_io_schedule_element
+					*schedule = &resource->schedule[i];
+				urb->iso_frame_desc[i].actual_length =
+							schedule->length;
+				urb->iso_frame_desc[i].status =
+					usbif_error_map_to_local(schedule->
+								     error);
+				if (urb->iso_frame_desc[i].status != 0)
+					urb->error_count++;
+			}
+		}
+	} else {
+		urb->status = usbif_error_map_to_local(error);
+		urb->actual_length = 0;
+	}
+	read_lock_irqsave(&dequeue_lock, flags);
+	urb->hcpriv = 0;
+	read_unlock_irqrestore(&dequeue_lock, flags);
+	local_irq_save(flags);
+	usb_hcd_giveback_urb(usbfront_device_get_drvdata(resource->device),
+								urb, NULL);
+	local_irq_restore(flags);
+	usbfront_callback_success(&resource->callback);
+}
+
+static int
+usbfront_hcd_resource_init_or_exit(struct usbfront_hcd_resource *resource,
+struct usbfront_device *device, int index,
+usbfront_callback_function *callback, int exit)
+{
+	int return_value = 0;
+	trace();
+	if (exit)
+		goto exit_path;
+	usbfront_callback_init(&resource->callback, callback);
+	resource->device = device;
+	resource->index = index;
+	resource->schedule = (struct usbif_isochronous_io_schedule_element *)
+						__get_free_page(GFP_KERNEL);
+	if (resource->schedule == NULL) {
+		return_value = -ENOMEM;
+		goto exit_no_schedule;
+	}
+	spin_lock_init(&resource->lock);
+	resource->state = usbfront_hcd_resource_state_i;
+	usbfront_create_rbr_request_element_init(
+					&resource->rbr_request_element[0]);
+	usbfront_create_rbr_request_element_init(
+					&resource->rbr_request_element[1]);
+	usbfront_rbr_provider_request_init(&resource->rbr_request,
+					usbfront_hcd_resource_create_rbrs_1,
+					usbfront_hcd_resource_revoke_rbrs_1);
+	usbfront_gw_tra_init(&resource->io_tra,
+			     usbfront_hcd_resource_submit_tra_1);
+	usbfront_gw_tra_init(&resource->unlink_tra,
+				usbfront_hcd_resource_submit_unlink_1);
+	usbfront_work_init(&resource->complete_1_work,
+				usbfront_hcd_resource_complete_1, resource);
+	return 0;
+ exit_path:
+	free_page((unsigned long)resource->schedule);
+ exit_no_schedule:
+	return return_value;
+}
+
+int
+usbfront_hcd_resource_init(struct usbfront_hcd_resource *resource,
+struct usbfront_device *device, int index,
+usbfront_callback_function *callback)
+{
+	trace();
+	return usbfront_hcd_resource_init_or_exit(resource, device, index,
+								callback, 0);
+}
+
+void usbfront_hcd_resource_exit(struct usbfront_hcd_resource *resource)
+{
+	trace();
+	usbfront_hcd_resource_init_or_exit(resource, NULL, 0, NULL, 1);
+}
+
+static void
+usbfront_hcd_resource_handle_stimulus(struct usbfront_hcd_resource *resource,
+usbfront_hcd_resource_stimulus stimulus)
+{
+	trace();
+	switch (resource->state) {
+	case usbfront_hcd_resource_state_i:
+		/* Initialised.                   */
+		/* Maybe completing previous URB. */
+		switch (stimulus) {
+		case usbfront_hcd_resource_stimulus_st:
+			resource->state = usbfront_hcd_resource_state_i_st;
+			usbfront_hcd_resource_create_rbrs(resource);
+			break;
+			/* A dequeue is possible whilst we are making the    */
+			/* complete response after we have transitioned back */
+			/* to the i state.                                   */
+		case usbfront_hcd_resource_stimulus_dq:
+			break;
+		default:
+			usbfront_hcd_resource_invalid_stimulus(resource,
+							       stimulus);
+			break;
+		}
+		break;
+	case usbfront_hcd_resource_state_i_st:
+		/* Creating RBRs. */
+		switch (stimulus) {
+		case usbfront_hcd_resource_stimulus_dq:
+			resource->state = usbfront_hcd_resource_state_i_st_dq;
+			usbfront_hcd_resource_abort_create_rbrs(resource);
+			break;
+		case usbfront_hcd_resource_stimulus_cs:
+			resource->state = usbfront_hcd_resource_state_i_st_cs;
+			usbfront_hcd_resource_submit_tra(resource);
+			break;
+		case usbfront_hcd_resource_stimulus_cf:
+			resource->state = usbfront_hcd_resource_state_i;
+			usbfront_hcd_resource_complete(resource);
+			break;
+		default:
+			usbfront_hcd_resource_invalid_stimulus(resource,
+							       stimulus);
+			break;
+		}
+		break;
+	case usbfront_hcd_resource_state_i_st_dq:
+		/* Creating RBRs. */
+		/* Dequeue URB.   */
+		switch (stimulus) {
+		case usbfront_hcd_resource_stimulus_dq:
+			break;
+		case usbfront_hcd_resource_stimulus_cs:
+			resource->state =
+			    usbfront_hcd_resource_state_i_st_dq_cs;
+			usbfront_hcd_resource_set_unlinked_error(resource);
+			usbfront_hcd_resource_revoke_rbrs(resource);
+			break;
+		case usbfront_hcd_resource_stimulus_cf:
+			resource->state = usbfront_hcd_resource_state_i;
+			usbfront_hcd_resource_complete(resource);
+			break;
+		default:
+			usbfront_hcd_resource_invalid_stimulus(resource,
+							       stimulus);
+			break;
+		}
+		break;
+	case usbfront_hcd_resource_state_i_st_cs:
+		/* Transaction submitted. */
+		switch (stimulus) {
+		case usbfront_hcd_resource_stimulus_dq:
+			resource->state =
+			    usbfront_hcd_resource_state_i_st_cs_dq;
+			usbfront_hcd_resource_submit_unlink(resource);
+			break;
+		case usbfront_hcd_resource_stimulus_tc:
+			resource->state =
+			    usbfront_hcd_resource_state_i_st_dq_cs;
+			usbfront_hcd_resource_revoke_rbrs(resource);
+			break;
+		default:
+			usbfront_hcd_resource_invalid_stimulus(resource,
+							       stimulus);
+			break;
+		}
+		break;
+	case usbfront_hcd_resource_state_i_st_dq_cs:
+		/* Revoking RBRs.     */
+		/* Maybe Dequeue URB. */
+		switch (stimulus) {
+		case usbfront_hcd_resource_stimulus_dq:
+			break;
+		case usbfront_hcd_resource_stimulus_rc:
+			resource->state = usbfront_hcd_resource_state_i;
+			usbfront_hcd_resource_complete(resource);
+			break;
+		default:
+			usbfront_hcd_resource_invalid_stimulus(resource,
+							       stimulus);
+			break;
+		}
+		break;
+	case usbfront_hcd_resource_state_i_st_cs_dq:
+		/* Transaction submitted. */
+		/* Unlink submitted.      */
+		/* Dequeue URB.           */
+		switch (stimulus) {
+		case usbfront_hcd_resource_stimulus_dq:
+			break;
+		case usbfront_hcd_resource_stimulus_tc:
+		case usbfront_hcd_resource_stimulus_uc:
+			resource->state =
+			    usbfront_hcd_resource_state_i_st_cs_dq_tc;
+			break;
+		default:
+			usbfront_hcd_resource_invalid_stimulus(resource,
+							       stimulus);
+			break;
+		}
+		break;
+	case usbfront_hcd_resource_state_i_st_cs_dq_tc:
+		/* Transaction submitted or Unlink submitted. */
+		/* Dequeue URB.                               */
+		switch (stimulus) {
+		case usbfront_hcd_resource_stimulus_dq:
+			break;
+		case usbfront_hcd_resource_stimulus_tc:
+		case usbfront_hcd_resource_stimulus_uc:
+			resource->state =
+			    usbfront_hcd_resource_state_i_st_dq_cs;
+			usbfront_hcd_resource_revoke_rbrs(resource);
+			break;
+		default:
+			usbfront_hcd_resource_invalid_stimulus(resource,
+							       stimulus);
+			break;
+		}
+		break;
+	default:
+		usbfront_hcd_resource_invalid_stimulus(resource, stimulus);
+		break;
+	}
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_hcd_resource.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_hcd_resource.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,88 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_HCD_RESOURCE_H
+#define USBFRONT_HCD_RESOURCE_H
+
+#include <linux/usb.h>
+#include <linux/list.h>
+#include <asm/atomic.h>
+#include "usbfront_device.h"
+#include "usbfront_rbr_provider_pool.h"
+
+int usbfront_hcd_resource_class_init(void);
+
+void usbfront_hcd_resource_class_exit(void);
+
+typedef enum {
+	usbfront_hcd_resource_state_i,
+	usbfront_hcd_resource_state_i_st,
+	usbfront_hcd_resource_state_i_st_dq,
+	usbfront_hcd_resource_state_i_st_cs,
+	usbfront_hcd_resource_state_i_st_dq_cs,
+	usbfront_hcd_resource_state_i_st_cs_dq,
+	usbfront_hcd_resource_state_i_st_cs_dq_tc
+} usbfront_hcd_resource_state;
+
+struct usbfront_hcd_resource {
+	struct usbfront_callback                      callback;
+	struct usbfront_device                       *device;
+	int                                           index;
+	struct usbif_isochronous_io_schedule_element *schedule;
+	spinlock_t                                    lock;
+	usbfront_hcd_resource_state                   state;
+	struct urb                                   *urb;
+	struct usbfront_create_rbr_request_element    rbr_request_element[2];
+	struct usbfront_rbr_provider_request          rbr_request;
+	struct usbfront_gw_tra                        io_tra;
+	struct usbfront_gw_tra                        unlink_tra;
+	struct usbfront_work                          complete_1_work;
+};
+
+static inline struct list_head *
+usbfront_hcd_resource_to_link(struct usbfront_hcd_resource *resource)
+{
+	return usbfront_callback_to_link(&resource->callback);
+}
+
+static inline struct usbfront_hcd_resource*
+usbfront_hcd_resource_callback_to(struct usbfront_callback *callback)
+{
+	return container_of(callback, struct usbfront_hcd_resource, callback);
+}
+
+static inline struct usbfront_device *
+usbfront_hcd_resource_query_device(struct usbfront_hcd_resource *resource)
+{
+	return resource->device;
+}
+
+int
+usbfront_hcd_resource_init(struct usbfront_hcd_resource *resource,
+struct usbfront_device *device, int index,
+usbfront_callback_function *callback);
+
+void usbfront_hcd_resource_exit(struct usbfront_hcd_resource *resource);
+
+void usbfront_hcd_resource_start_urb(struct usbfront_hcd_resource *resource,
+struct urb *urb);
+
+void usbfront_hcd_resource_dequeue_urb(struct urb *urb);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_module.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_module.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,65 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/module.h>
+#include <linux/usb.h>
+#include "usbfront_device.h"
+#include "usbfront_driver.h"
+#include "usbfront_trace.h"
+
+static int usbfront_module_init_or_exit(int exit)
+{
+	int return_value = 0;
+	trace();
+	if (usb_disabled()) {
+		return_value = -ENODEV;
+		goto exit_no_usb;
+	}
+	if (exit)
+		goto exit_path;
+	if ((return_value = usbfront_driver_class_init()) != 0)
+		goto exit_no_driver_class;
+	if ((return_value = usbfront_device_class_init()) != 0)
+		goto exit_no_device_class;
+	return 0;
+ exit_path:
+	usbfront_device_class_exit();
+ exit_no_device_class:
+	usbfront_driver_class_exit();
+ exit_no_driver_class:
+	exit_no_usb:
+	return return_value;
+}
+
+static int __init usbfront_module_init(void)
+{
+	trace();
+	return usbfront_module_init_or_exit(0);
+}
+
+static void __exit usbfront_module_exit(void)
+{
+	trace();
+	(void)usbfront_module_init_or_exit(1);
+}
+
+module_init(usbfront_module_init);
+module_exit(usbfront_module_exit);
+
+MODULE_LICENSE("GPL");
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_rbr_provider_pool.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_rbr_provider_pool.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,339 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/module.h>
+#include "usbfront_rbr_provider_pool.h"
+#include "usbfront_trace.h"
+
+static USBFRONT_CALLBACK_SERIALISER(callback_serialiser);
+
+struct usbfront_rbr_provider_pool {
+	struct usbfront_buffer_resource_list      dedicated_resources;
+	struct usbfront_buffer_resource_provider *provider;
+	spinlock_t                                lock;
+	struct usbfront_buffer_resource_list      head_request_req;
+	struct list_head                          request_list;
+	int                                       kicking_requests;
+	int                                       head_request_req_calculated;
+};
+
+static int
+usbfront_rbr_provider_pool_init_or_exit(
+struct usbfront_rbr_provider_pool *pool, int exit)
+{
+	int return_value = 0;
+	trace();
+	if (exit)
+		goto exit_path;
+	pool->provider = usbfront_allocate_buffer_resource_provider(
+				pool->dedicated_resources);
+	if (pool->provider == NULL)
+		goto exit_no_provider;
+	spin_lock_init(&pool->lock);
+	INIT_LIST_HEAD(&pool->request_list);
+	pool->kicking_requests = 0;
+	pool->head_request_req_calculated = 0;
+	return 0;
+ exit_path:
+	usbfront_free_buffer_resource_provider(pool->provider);
+ exit_no_provider:
+	return return_value;
+}
+
+struct usbfront_rbr_provider_pool *usbfront_rbr_provider_pool_allocate(void)
+{
+	struct usbfront_rbr_provider_pool *pool;
+	trace();
+	pool = (struct usbfront_rbr_provider_pool *)kmalloc(sizeof(
+			struct usbfront_rbr_provider_pool), GFP_KERNEL);
+	if (pool != NULL) {
+		pool->dedicated_resources.grant_references = USBIF_QUOTA *
+					USBIF_GRANT_TABLE_REFERENCE_COUNT;
+		if (usbfront_rbr_provider_pool_init_or_exit(pool, 0) != 0) {
+			kfree(pool);
+			pool = NULL;
+		}
+	}
+	return pool;
+}
+
+void
+usbfront_rbr_provider_pool_free(struct usbfront_rbr_provider_pool *pool)
+{
+	trace();
+	(void)usbfront_rbr_provider_pool_init_or_exit(pool, 1);
+	kfree(pool);
+}
+
+static void
+usbfront_rbr_provider_pool_kick_requests(
+struct usbfront_rbr_provider_pool *pool);
+
+void
+usbfront_rbr_provider_pool_reserve_and_create_rbrs(
+struct usbfront_rbr_provider_pool *pool,
+struct usbfront_rbr_provider_request *request, domid_t domain)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	unsigned long flags;
+	trace();
+	request->pool = pool;
+	request->domain = domain;
+	spin_lock_irqsave(&pool->lock, flags);
+	list_add_tail(usbfront_rbr_provider_request_to_link(request),
+							&pool->request_list);
+	spin_unlock_irqrestore(&pool->lock, flags);
+	usbfront_rbr_provider_pool_kick_requests(pool);
+}
+
+static int
+usbfront_rbr_provider_pool_calculate_rbr_resources(void *buffer,
+usbif_buffer_byte_count length, struct usbfront_buffer_resource_list *list)
+{
+	unsigned long first_page, final_page;
+	trace();
+	*list = usbfront_buffer_resource_list_null();
+	if (length == 0)
+		return 0;
+	first_page = (((unsigned long)buffer) / PAGE_SIZE);
+	final_page = (((unsigned long)((char *)buffer+length-1))/PAGE_SIZE);
+	list->grant_references = final_page - first_page + 1;
+	return list->grant_references > USBIF_GRANT_TABLE_REFERENCE_COUNT;
+}
+
+static int usbfront_rbr_provider_pool_calc_req(
+struct usbfront_rbr_provider_request *request,
+struct usbfront_buffer_resource_list *list)
+{
+	struct usbfront_create_rbr_request_element *element;
+	trace();
+	*list = usbfront_buffer_resource_list_null();
+	list_for_each_entry(element, &request->request_elements, link) {
+		struct usbfront_buffer_resource_list element_list;
+		if (usbfront_rbr_provider_pool_calculate_rbr_resources(
+			element->buffer, element->length, &element_list) != 0)
+			return 1;
+		usbfront_buffer_resource_list_plus_equals(list, &element_list);
+	}
+	return 0;
+}
+
+static void
+usbfront_rbr_provider_pool_create_rbr(void *buffer,
+usbif_buffer_byte_count length, domid_t domain,
+struct usbfront_buffer_resource_provider *provider, struct usbif_rbr *rbr,
+int access_flags, struct usbfront_rbr_context *context)
+{
+	int i = 0;
+	unsigned long page, final_page;
+	trace();
+	memset(rbr, 0, sizeof(*rbr));
+	if (length == 0) {
+		context->count = 0;
+		return;
+	}
+	context->provider = provider;
+	context->domain_id = domain;
+	page = (unsigned long)buffer & PAGE_MASK;
+	final_page = ((unsigned long)buffer + length - 1) & PAGE_MASK;
+	for (;;) {
+		rbr->reference[i] = context->reference[i] =
+		usbfront_buffer_resource_provider_allocate_grant_reference(
+								provider);
+		gnttab_grant_foreign_access_ref(context->reference[i],
+			context->domain_id, virt_to_mfn(page), ((access_flags &
+			USBFRONT_ACCESS_FLAGS_WRITE) == 0) ? 1 : 0);
+		i++;
+		if (page == final_page)
+			break;
+		page += PAGE_SIZE;
+	}
+	context->count = i;
+	rbr->byte_offset = (unsigned long)buffer & ~PAGE_MASK;
+	rbr->byte_count = length;
+}
+
+static void
+usbfront_rbr_provider_pool_service_request(
+struct usbfront_rbr_provider_pool *pool,
+struct usbfront_rbr_provider_request *request)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbfront_create_rbr_request_element *element;
+	trace();
+	list_for_each_entry(element, &request->request_elements, link) {
+		usbfront_rbr_provider_pool_create_rbr(
+				element->buffer, element->length,
+				request->domain, pool->provider, &element->rbr,
+				element->access_flags, &element->context);
+		element->created = 1;
+	}
+	usbfront_callback_serialiser_complete_callback(&callback_serialiser,
+		usbfront_rbr_provider_request_to_create_callback(request),
+		USBIF_ERROR_SUCCESS);
+}
+
+static void usbfront_rbr_provider_pool_kick_requests(
+struct usbfront_rbr_provider_pool *pool)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&pool->lock, flags);
+	while ((!pool->kicking_requests) && 
+					(!list_empty(&pool->request_list))) {
+		struct usbfront_buffer_resource_list free_resources;
+		struct usbfront_rbr_provider_request *request =
+			usbfront_rbr_provider_request_link_to(
+						pool->request_list.next);
+		if (pool->head_request_req_calculated)
+			goto skip_calc;
+		if ((usbfront_rbr_provider_pool_calc_req(request,
+				&pool->head_request_req) != 0) ||
+				!usbfront_buffer_resource_list_subset_of(
+				&pool->head_request_req,
+				&pool->dedicated_resources)) {
+			list_del_init(usbfront_rbr_provider_request_to_link(
+								request));
+			usbfront_callback_serialiser_complete_callback(
+				&callback_serialiser,
+				usbfront_rbr_provider_request_to_create_callback(
+								request),
+				USBIF_ERROR_TOO_BIG);
+			continue;
+		}
+		pool->head_request_req_calculated = 1;
+	skip_calc:
+		free_resources =
+			usbfront_buffer_resource_provider_query_free_resources(
+							pool->provider);
+		if (!usbfront_buffer_resource_list_subset_of(
+				&pool->head_request_req, &free_resources))
+			break;
+		list_del_init(usbfront_rbr_provider_request_to_link(request));
+		pool->head_request_req_calculated = 0;
+		pool->kicking_requests = 1;
+		spin_unlock_irqrestore(&pool->lock, flags);
+		usbfront_rbr_provider_pool_service_request(pool, request);
+		spin_lock_irqsave(&pool->lock, flags);
+		pool->kicking_requests = 0;
+	}
+	spin_unlock_irqrestore(&pool->lock, flags);
+}
+
+void
+usbfront_rbr_provider_pool_abort_reserve_and_create_rbrs(
+struct usbfront_rbr_provider_request *request, usbif_error error)
+{
+	struct usbfront_rbr_provider_pool *pool = request->pool;
+	unsigned long flags;
+	struct usbfront_rbr_provider_request *queued_request;
+	trace();
+	spin_lock_irqsave(&pool->lock, flags);
+	list_for_each_entry(queued_request, &pool->request_list,
+				create_callback.work.link) {
+		if (request == queued_request) {
+			list_del_init(usbfront_rbr_provider_request_to_link(
+								request));
+			pool->head_request_req_calculated = 0;
+			usbfront_callback_serialiser_complete_callback(
+				&callback_serialiser,
+				usbfront_rbr_provider_request_to_create_callback(
+							request), error);
+			break;
+		}
+	}
+	spin_unlock_irqrestore(&pool->lock, flags);
+}
+
+static void
+usbfront_rbr_provider_pool_retry_revoke_rbr(
+struct usbfront_rbr_context *context)
+{
+	int i = 0,j;
+	trace();
+	while (i != context->count) {
+		if (gnttab_end_foreign_access_ref(context->reference[i], 0)) {
+			usbfront_buffer_resource_provider_free_grant_reference(
+				context->provider, context->reference[i]);
+			for (j = i + 1; j < context->count; j++) {
+				context->reference[j-1] =context->reference[j];
+			}
+			--context->count;
+		} else {
+			i++;
+		}
+	}
+	if (context->count == 0) {
+		usbfront_callback_success(context->callback);
+	} else {
+		printk(KERN_WARNING
+		     "usbfront failed to end foreign "
+		     "access granted to domain id %d.  Retry in 5 seconds.\n",
+		     context->domain_id);
+		init_timer(&context->timer);
+		context->timer.data = (unsigned long)context;
+		context->timer.expires = jiffies + (5*HZ);
+		context->timer.function = (void (*)(unsigned long))
+				usbfront_rbr_provider_pool_retry_revoke_rbr;
+		add_timer(&context->timer);
+	}
+}
+
+static void
+usbfront_rbr_provider_pool_revoke_rbr(struct usbfront_rbr_context *context,
+struct usbfront_callback *callback)
+{
+	trace();
+	context->callback = callback;
+	usbfront_rbr_provider_pool_retry_revoke_rbr(context);
+}
+
+static void
+usbfront_rbr_provider_pool_revoke_and_unreserve_rbrs_1(
+struct usbfront_callback *callback)
+{
+	struct usbfront_rbr_provider_request *request = container_of(callback,
+			struct usbfront_rbr_provider_request,
+			reserved_callback);
+	struct usbfront_create_rbr_request_element *element;
+	trace();
+	list_for_each_entry(element, &request->request_elements, link) {
+		if (element->created) {
+			element->created = 0;
+			usbfront_rbr_provider_pool_revoke_rbr(
+						&element->context, callback);
+			return;
+		}
+	}
+	usbfront_rbr_provider_pool_kick_requests(request->pool);
+	usbfront_callback_serialiser_complete_callback(&callback_serialiser,
+		     usbfront_rbr_provider_request_to_revoke_callback(request),
+							USBIF_ERROR_SUCCESS);
+}
+
+void usbfront_rbr_provider_pool_revoke_and_unreserve_rbrs(
+struct usbfront_rbr_provider_request *request)
+{
+	trace();
+	usbfront_callback_init(&request->reserved_callback,
+		usbfront_rbr_provider_pool_revoke_and_unreserve_rbrs_1);
+	usbfront_rbr_provider_pool_revoke_and_unreserve_rbrs_1(
+		&request->reserved_callback);
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_rbr_provider_pool.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_rbr_provider_pool.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,169 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_RBR_PROVIDER_POOL
+#define USBFRONT_RBR_PROVIDER_POOL
+
+#include <xen/interface/io/usbif.h>
+#include "usbfront_buffer_resource_provider.h"
+#include "usbfront_callback.h"
+
+struct usbfront_rbr_provider_pool;
+
+struct usbfront_rbr_provider_pool *usbfront_rbr_provider_pool_allocate(void);
+
+void usbfront_rbr_provider_pool_free(struct usbfront_rbr_provider_pool *pool);
+
+#define USBFRONT_ACCESS_FLAGS_READ  1
+#define USBFRONT_ACCESS_FLAGS_WRITE 2
+
+struct usbfront_rbr_context {
+	struct usbfront_buffer_resource_provider *provider;
+	struct timer_list                         timer;
+	struct usbfront_callback                 *callback;
+	int                                       domain_id;
+	int                                       count;
+	grant_ref_t reference[USBIF_GRANT_TABLE_REFERENCE_COUNT];
+};
+
+struct usbfront_create_rbr_request_element {
+	struct list_head             link;
+	void                        *buffer;
+	usbif_buffer_byte_count      length;
+	int                          access_flags;
+	struct usbif_rbr             rbr;
+	int                          created;
+	struct usbfront_rbr_context  context;
+};
+
+static inline void usbfront_create_rbr_request_element_init(
+struct usbfront_create_rbr_request_element *element)
+{
+	memset(element, 0, sizeof(*element));
+	INIT_LIST_HEAD(&element->link);
+}
+
+static inline void
+usbfront_create_rbr_request_element_set_buffer(
+struct usbfront_create_rbr_request_element *element, void *buffer,
+usbif_buffer_byte_count length, int access_flags)
+{
+	element->buffer = buffer;
+	element->length = length;
+	element->access_flags = access_flags;
+}
+
+static inline struct usbif_rbr
+usbfront_create_rbr_request_element_query_rbr(
+struct usbfront_create_rbr_request_element *element)
+{
+	return element->rbr;
+}
+
+static inline void
+usbfront_create_rbr_request_element_ensure_removed(
+struct usbfront_create_rbr_request_element *element)
+{
+	list_del_init(&element->link);
+}
+
+struct usbfront_rbr_provider_request {
+	struct usbfront_callback create_callback;
+	struct usbfront_callback revoke_callback;
+	struct usbfront_rbr_provider_pool *pool;
+	domid_t domain;
+	struct list_head request_elements;
+	struct usbfront_callback reserved_callback;
+};
+
+static inline struct usbfront_callback *
+usbfront_rbr_provider_request_to_create_callback(
+struct usbfront_rbr_provider_request *request)
+{
+	return &request->create_callback;
+}
+
+static inline struct usbfront_rbr_provider_request *
+usbfront_rbr_provider_request_create_callback_to(
+struct usbfront_callback * callback)
+{
+	return container_of(callback, struct usbfront_rbr_provider_request,
+							create_callback);
+}
+
+static inline struct usbfront_callback *
+usbfront_rbr_provider_request_to_revoke_callback(
+struct usbfront_rbr_provider_request *request)
+{
+	return &request->revoke_callback;
+}
+
+static inline struct usbfront_rbr_provider_request *
+usbfront_rbr_provider_request_revoke_callback_to(
+struct usbfront_callback * callback)
+{
+	return container_of(callback, struct usbfront_rbr_provider_request,
+							revoke_callback);
+}
+
+static inline struct list_head * usbfront_rbr_provider_request_to_link(
+struct usbfront_rbr_provider_request *request)
+{
+	return usbfront_callback_to_link(
+		usbfront_rbr_provider_request_to_create_callback(request));
+}
+
+static inline struct usbfront_rbr_provider_request *
+usbfront_rbr_provider_request_link_to(struct list_head *link)
+{
+	return usbfront_rbr_provider_request_create_callback_to(
+					usbfront_callback_link_to(link));
+}
+
+static inline void usbfront_rbr_provider_request_init(
+struct usbfront_rbr_provider_request *request,
+usbfront_callback_function *create_callback,
+usbfront_callback_function *revoke_callback)
+{
+	usbfront_callback_init(&request->create_callback, create_callback);
+	usbfront_callback_init(&request->revoke_callback, revoke_callback);
+	INIT_LIST_HEAD(&request->request_elements);
+}
+
+static inline void usbfront_rbr_provider_request_add_element(
+struct usbfront_rbr_provider_request *request,
+struct usbfront_create_rbr_request_element *element)
+{
+	list_add(&element->link, &request->request_elements);
+}
+
+void
+usbfront_rbr_provider_pool_reserve_and_create_rbrs(
+struct usbfront_rbr_provider_pool *pool,
+struct usbfront_rbr_provider_request *request, domid_t domain);
+
+void
+usbfront_rbr_provider_pool_abort_reserve_and_create_rbrs(
+struct usbfront_rbr_provider_request *request, usbif_error error);
+
+void
+usbfront_rbr_provider_pool_revoke_and_unreserve_rbrs(
+struct usbfront_rbr_provider_request *request);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_ring_channel.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_ring_channel.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,744 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* This program is free software; you can redisrfbute 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 disrfbuted 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/interrupt.h>
+#include <xen/interface/io/usbif.h>
+#include <xen/driver_util.h>
+#include <xen/evtchn.h>
+#include "usbfront_ring_channel.h"
+#include "usbfront_trace.h"
+
+static inline void
+usbfront_ring_channel_rsrc_init(struct usbfront_ring_channel_rsrc *rsrc,
+struct usbfront_ring_channel *channel, usbfront_callback_function *callback)
+{
+	trace();
+	usbfront_channel_ibmsg_init(&rsrc->message, callback);
+	rsrc->channel = channel;
+}
+
+static inline struct list_head *
+usbfront_ring_channel_rsrc_to_link(struct usbfront_ring_channel_rsrc *rsrc)
+{
+	return usbfront_channel_ibmsg_to_link(&rsrc->message);
+}
+
+static inline struct usbfront_ring_channel_rsrc *
+usbfront_ring_channel_rsrc_callback_to(struct usbfront_callback *callback)
+{
+	return container_of(usbfront_channel_ibmsg_callback_to(callback),
+				struct usbfront_ring_channel_rsrc, message);
+}
+
+typedef enum {
+	usbfront_ring_channel_stimulus_cn,/* connect request             */
+	usbfront_ring_channel_stimulus_mq,/* message queued              */
+	usbfront_ring_channel_stimulus_dn,/* disconnect request          */
+	usbfront_ring_channel_stimulus_ri,/* ring interrupt              */
+	usbfront_ring_channel_stimulus_cs,/* connect successful          */
+	usbfront_ring_channel_stimulus_cf,/* connect failed              */
+	usbfront_ring_channel_stimulus_cc,/* connect client completed    */
+	usbfront_ring_channel_stimulus_dc,/* disconnect client completed */
+	usbfront_ring_channel_stimulus_ds,/* disconnect successful       */
+	usbfront_ring_channel_stimulus_ks,/* kick send ring completed    */
+	usbfront_ring_channel_stimulus_kr,/* kick recv ring completed    */
+	usbfront_ring_channel_stimulus_rc,/* rsrc completed              */
+	usbfront_ring_channel_stimulus_rf /* rsrc final completion       */
+} usbfront_ring_channel_stimulus;
+
+static void
+usbfront_ring_channel_handle_stimulus(struct usbfront_ring_channel *channel,
+usbfront_ring_channel_stimulus stimulus);
+
+void
+usbfront_ring_channel_connect(struct usbfront_ring_channel *channel,
+struct usbfront_ring_channel_connect_request *request)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	channel->current_callback = &request->callback;
+	usbfront_ring_channel_handle_stimulus(channel,
+					usbfront_ring_channel_stimulus_cn);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbfront_ring_channel_submit_message(struct usbfront_channel *base_channel,
+struct usbfront_channel_obmsg *message)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbfront_ring_channel *channel =
+				usbfront_ring_channel_channel_to(base_channel);
+	unsigned long flags;
+	spin_lock_irqsave(&channel->lock, flags);
+	list_add_tail(usbfront_channel_obmsg_to_link(message),
+					&channel->message_list);
+	usbfront_ring_channel_handle_stimulus(channel,
+					usbfront_ring_channel_stimulus_mq);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+void
+usbfront_ring_channel_disconnect(struct usbfront_ring_channel *channel,
+struct usbfront_callback *callback)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	channel->current_callback = callback;
+	usbfront_ring_channel_handle_stimulus(channel,
+					usbfront_ring_channel_stimulus_dn);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static irqreturn_t
+usbfront_ring_channel_interrupt(int irq, void *context, struct pt_regs *ptregs)
+{
+	struct usbfront_ring_channel *channel = context;
+	unsigned long flags;
+	spin_lock_irqsave(&channel->lock, flags);
+	usbfront_ring_channel_handle_stimulus(channel,
+					usbfront_ring_channel_stimulus_ri);
+	spin_unlock_irqrestore(&channel->lock, flags);
+	return IRQ_HANDLED;
+}
+
+static void
+usbfront_ring_channel_invalid_stimulus(struct usbfront_ring_channel *channel,
+usbfront_ring_channel_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbfront: channel %p in state %d"
+		"received invalid stimulus %d", channel, channel->state,
+		stimulus);
+}
+
+static void
+usbfront_ring_channel_do_connect(struct usbfront_ring_channel *channel)
+{
+	trace();
+	(void)usbfront_work_schedule(&channel->do_connect_1_work);
+}
+
+static void usbfront_ring_channel_do_connect_1(void *data)
+{
+	struct usbfront_ring_channel *channel = data;
+	struct usbfront_ring_channel_connect_request *request =
+		usbfront_ring_channel_connect_request_callback_to(
+						channel->current_callback);
+	evtchn_op_t op = {
+		.cmd                        = EVTCHNOP_alloc_unbound,
+		.u.alloc_unbound.dom        = DOMID_SELF,
+		.u.alloc_unbound.remote_dom = request->domain_id
+	};
+	struct usbif_sring * sring = (struct usbif_sring *)channel->ring;
+	int error;
+	unsigned long flags;
+	trace();
+	SHARED_RING_INIT(sring);
+	FRONT_RING_INIT(&channel->front_ring, sring, PAGE_SIZE);
+	BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
+	channel->event_channel = op.u.alloc_unbound.port;
+	error = bind_evtchn_to_irqhandler(channel->event_channel,
+				usbfront_ring_channel_interrupt,
+				SA_SAMPLE_RANDOM, "usbif", channel);
+	BUG_ON(error < 0);
+	channel->irq = error;
+	channel->ring_ref = gnttab_claim_grant_reference(
+						&channel->grant_ref_pool);
+	channel->domain_id = request->domain_id;
+	gnttab_grant_foreign_access_ref(channel->ring_ref,
+					channel->domain_id,
+					virt_to_mfn(channel->ring),
+					0 /* not read-only */ );
+	request->ring_ref = channel->ring_ref;
+	request->event_channel = channel->event_channel;
+	spin_lock_irqsave(&channel->lock, flags);
+	usbfront_ring_channel_handle_stimulus(channel,
+			usbfront_ring_channel_stimulus_cs);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbfront_ring_channel_connect_client(struct usbfront_ring_channel *channel)
+{
+	trace();
+	(void)usbfront_work_schedule(&channel->connect_client_1_work);
+}
+
+static void usbfront_ring_channel_connect_client_1(void *data)
+{
+	struct usbfront_ring_channel *channel = data;
+	unsigned long flags;
+	trace();
+	usbfront_channel_connect(&channel->channel);
+	spin_lock_irqsave(&channel->lock, flags);
+	usbfront_ring_channel_handle_stimulus(channel,
+					usbfront_ring_channel_stimulus_cc);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbfront_ring_channel_disconnect_client(struct usbfront_ring_channel *channel)
+{
+	trace();
+	(void)usbfront_work_schedule(&channel->disconnect_client_1_work);
+}
+
+static void usbfront_ring_channel_disconnect_client_1(void *data)
+{
+	struct usbfront_ring_channel *channel = data;
+	trace();
+	usbfront_channel_disconnect(&channel->channel,
+				&channel->disconnect_client_2_callback);
+}
+
+static void
+usbfront_ring_channel_disconnect_client_2(struct usbfront_callback *callback)
+{
+	struct usbfront_ring_channel *channel = container_of(callback,
+		struct usbfront_ring_channel, disconnect_client_2_callback);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	usbfront_ring_channel_handle_stimulus(channel,
+					usbfront_ring_channel_stimulus_dc);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbfront_ring_channel_do_disconnect(struct usbfront_ring_channel *channel)
+{
+	trace();
+	(void)usbfront_work_schedule(&channel->do_disconnect_1_work);
+}
+
+static void usbfront_ring_channel_do_disconnect_1(void *data)
+{
+	struct usbfront_ring_channel *channel = data;
+	unsigned long flags;
+	trace();
+	if (gnttab_end_foreign_access_ref(channel->ring_ref, 1)) {
+		gnttab_release_grant_reference(&channel->grant_ref_pool,
+						channel->ring_ref);
+		unbind_from_irqhandler(channel->irq, channel);
+		spin_lock_irqsave(&channel->lock, flags);
+		usbfront_ring_channel_handle_stimulus(channel,
+				     usbfront_ring_channel_stimulus_ds);
+		spin_unlock_irqrestore(&channel->lock, flags);
+	} else {
+		printk(KERN_WARNING
+		     "usbfront_ring_channel failed to end foreign access "
+		     "granted to domain id %d.  Will retry in 5 seconds.\n",
+		     channel->domain_id);
+		init_timer(&channel->timer);
+		channel->timer.data = (unsigned long)channel;
+		channel->timer.expires = jiffies + (5*HZ);
+		channel->timer.function = (void (*)(unsigned long))
+			    usbfront_ring_channel_do_disconnect;
+		add_timer(&channel->timer);
+	}
+}
+
+static void
+usbfront_ring_channel_kick_send_ring(struct usbfront_ring_channel *channel)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	if (!channel->send_ring_kick_out) {
+		channel->send_ring_kick_out = 1;
+		(void)usbfront_work_schedule(&channel->kick_send_ring_1_work);
+	}
+}
+
+static void usbfront_ring_channel_kick_send_ring_1(void *data)
+{
+	/* MUST MAINTAIN RELATIVE REQUEST ORDER ON THE SUBMISSION PATH */
+	struct usbfront_ring_channel *channel = data;
+	unsigned long flags;
+	spin_lock_irqsave(&channel->lock, flags);
+	for (;;) {
+		struct usbif_front_ring *front_ring = &channel->front_ring;
+		int notify = 0;
+		while (!list_empty(&channel->message_list)) {
+			struct usbfront_channel_obmsg *message;
+			struct usbif_request *request;
+			message = list_entry(channel->message_list.next,
+						struct usbfront_channel_obmsg,
+						callback.work.link);
+			list_del_init(usbfront_channel_obmsg_to_link(message));
+			spin_unlock_irqrestore(&channel->lock, flags);
+			request = RING_GET_REQUEST(front_ring,
+						front_ring->req_prod_pvt);
+			*request = message->request;
+			usbfront_callback_success(
+				usbfront_channel_obmsg_to_callback(message));
+			front_ring->req_prod_pvt++;
+			notify = 1;
+			spin_lock_irqsave(&channel->lock, flags);
+		}
+		if (notify) {
+			spin_unlock_irqrestore(&channel->lock, flags);
+			RING_PUSH_REQUESTS(front_ring);
+			notify_remote_via_irq(channel->irq);
+			spin_lock_irqsave(&channel->lock, flags);
+		} else {
+			channel->send_ring_kick_out = 0;
+			usbfront_ring_channel_handle_stimulus(channel,
+					usbfront_ring_channel_stimulus_ks);
+			break;
+		}
+	}
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbfront_ring_channel_kick_recv_ring(struct usbfront_ring_channel *channel)
+{
+	if (!channel->recv_ring_kick_out) {
+		channel->recv_ring_kick_out = 1;
+		(void)usbfront_work_schedule(&channel->kick_recv_ring_1_work);
+	}
+}
+
+static void usbfront_ring_channel_kick_recv_ring_1(void *data)
+{
+	struct usbfront_ring_channel *channel = data;
+	unsigned long flags;
+	spin_lock_irqsave(&channel->lock, flags);
+	for (;;) {
+		struct usbif_front_ring *front_ring = &channel->front_ring;
+		int progress = 0;
+		RING_IDX rp, rc;
+		rc = front_ring->rsp_cons;
+		/* To avoid going idle when there is a waiting response we   */
+		/* need a mb() here to make sure we see any requests which   */
+		/* are new this time around the outer 'for' loop.            */
+		/* FIXME: spin_lock below makes this unnecessary?            */
+		mb();
+		rp = front_ring->sring->rsp_prod;
+		/* To make sure we see the correct data for the requests     */
+		/* found above we need a rmb() here to force reads to be     */
+                /* after the read of front_ring->sring->rsp_prod.            */
+		rmb();
+		/* FIXME: we are trusting sring->rsp_prod here... */
+		while (!list_empty(&channel->rsrc_list) && (rc != rp)) {
+			struct usbfront_ring_channel_rsrc *rsrc;
+			struct usbif_response *response;
+			rsrc = list_entry(channel->rsrc_list.next,
+				struct usbfront_ring_channel_rsrc,
+				message.callback.work.link);
+			list_del_init(usbfront_ring_channel_rsrc_to_link(
+									rsrc));
+			response = RING_GET_RESPONSE(front_ring, rc);
+			rsrc->message.response = *response;
+			front_ring->rsp_cons = ++rc;
+			channel->rsrcs_out++;
+			spin_unlock_irqrestore(&channel->lock, flags);
+			usbfront_channel_handle_message(&channel->channel,
+							&rsrc->message);
+			progress = 1;
+			spin_lock_irqsave(&channel->lock, flags);
+		}
+		if (!progress)
+		{
+			channel->recv_ring_kick_out = 0;
+			usbfront_ring_channel_handle_stimulus(channel,
+					usbfront_ring_channel_stimulus_kr);
+			break;
+		}
+	}
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbfront_ring_channel_kick_recv_ring_2(struct usbfront_callback *callback)
+{
+	struct usbfront_ring_channel_rsrc *rsrc =
+			usbfront_ring_channel_rsrc_callback_to(callback);
+	struct usbfront_ring_channel *channel = rsrc->channel;
+	unsigned long flags;
+	if ((usbfront_callback_query_error(callback) != USBIF_ERROR_SUCCESS)
+					&& (channel->protocol_error != NULL))
+		channel->protocol_error(channel);
+	spin_lock_irqsave(&channel->lock, flags);
+	list_add_tail(usbfront_ring_channel_rsrc_to_link(rsrc),
+							&channel->rsrc_list);
+	if (--channel->rsrcs_out == 0) {
+		usbfront_ring_channel_handle_stimulus(channel,
+				usbfront_ring_channel_stimulus_rf);
+	} else {
+		usbfront_ring_channel_handle_stimulus(channel,
+				usbfront_ring_channel_stimulus_rc);
+	}
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbfront_ring_channel_complete_current_callback(
+struct usbfront_ring_channel *channel)
+{
+	trace();
+	usbfront_callback_success(channel->current_callback);
+}
+
+static void
+usbfront_ring_channel_fail_current_callback(
+struct usbfront_ring_channel *channel)
+{
+	trace();
+	usbfront_callback_complete(channel->current_callback,
+							USBIF_ERROR_FAILURE);
+}
+
+static void
+usbfront_ring_channel_fail_out_messages(struct usbfront_ring_channel *channel)
+{
+	trace();
+	while (!list_empty(&channel->message_list)) {
+		struct usbfront_channel_obmsg *message = list_entry(
+			channel->message_list.next,
+			struct usbfront_channel_obmsg,
+			callback.work.link);
+		list_del_init(usbfront_channel_obmsg_to_link(message));
+		usbfront_callback_success(usbfront_channel_obmsg_to_callback(
+								message));
+	}
+}
+
+static void
+usbfront_ring_channel_test_rsrcs(struct usbfront_ring_channel *channel)
+{
+	trace();
+	if (channel->rsrcs_out == 0) {
+		usbfront_ring_channel_handle_stimulus(channel,
+					usbfront_ring_channel_stimulus_rf);
+	}
+}
+
+static int
+usbfront_ring_channel_init_or_exit(struct usbfront_ring_channel *channel,
+int exit)
+{
+	int return_value = 0, i;
+	trace();
+	if (exit)
+		goto exit_path;
+	channel->ring = (void *)__get_free_page(GFP_KERNEL);
+	if (channel->ring == NULL) {
+		trace_info("failed to allocate ring");
+		return_value = -ENOMEM;
+		goto exit_no_ring;
+	}
+	return_value = gnttab_alloc_grant_references(1,
+						&channel->grant_ref_pool);
+	if (return_value != 0) {
+		trace_info("failed to allocate grant reference pool");
+		goto exit_no_grant_ref;
+	}
+	spin_lock_init(&channel->lock);
+	channel->state = usbfront_ring_channel_state_i;
+	INIT_LIST_HEAD(&channel->message_list);
+	usbfront_work_init(&channel->do_connect_1_work,
+		     usbfront_ring_channel_do_connect_1, channel);
+	usbfront_work_init(&channel->connect_client_1_work,
+		     usbfront_ring_channel_connect_client_1, channel);
+	usbfront_work_init(&channel->disconnect_client_1_work,
+		     usbfront_ring_channel_disconnect_client_1, channel);
+	usbfront_callback_init(&channel->disconnect_client_2_callback,
+		     usbfront_ring_channel_disconnect_client_2);
+	usbfront_work_init(&channel->do_disconnect_1_work,
+		     usbfront_ring_channel_do_disconnect_1, channel);
+	usbfront_work_init(&channel->kick_send_ring_1_work,
+		     usbfront_ring_channel_kick_send_ring_1, channel);
+	usbfront_work_init(&channel->kick_recv_ring_1_work,
+		     usbfront_ring_channel_kick_recv_ring_1, channel);
+	INIT_LIST_HEAD(&channel->rsrc_list);
+	for (i = 0; i < USBIF_QUOTA; i++) {
+		struct usbfront_ring_channel_rsrc *rsrc = &channel->rsrcs[i];
+		usbfront_ring_channel_rsrc_init(rsrc, channel,
+				usbfront_ring_channel_kick_recv_ring_2);
+		list_add_tail(usbfront_ring_channel_rsrc_to_link(rsrc),
+							&channel->rsrc_list);
+	}
+	channel->send_ring_kick_out = 0;
+	channel->recv_ring_kick_out = 0;
+	channel->rsrcs_out = 0;
+	return 0;
+ exit_path:
+	gnttab_free_grant_references(channel->grant_ref_pool);
+ exit_no_grant_ref:
+	free_page((unsigned long)channel->ring);
+ exit_no_ring:
+	return return_value;
+}
+
+int
+usbfront_ring_channel_init(struct usbfront_ring_channel *channel,
+void (*protocol_error) (struct usbfront_ring_channel *channel))
+{
+	trace();
+	usbfront_channel_init(&channel->channel,
+					usbfront_ring_channel_submit_message);
+	channel->protocol_error = protocol_error;
+	return usbfront_ring_channel_init_or_exit(channel, 0);
+}
+
+void usbfront_ring_channel_exit(struct usbfront_ring_channel *channel)
+{
+	trace();
+	(void)usbfront_ring_channel_init_or_exit(channel, 1);
+}
+
+static void usbfront_ring_channel_handle_stimulus(
+struct usbfront_ring_channel *channel,
+usbfront_ring_channel_stimulus stimulus)
+{
+	switch (channel->state) {
+	case usbfront_ring_channel_state_i:
+		/* Client disconnected.   */
+		/* No messages queued.    */
+		/* Kick send idle.        */
+		/* Kick recv idle.        */
+		/* Target rsrcs idle.     */
+		switch (stimulus) {
+		case usbfront_ring_channel_stimulus_cn:
+			channel->state = usbfront_ring_channel_state_i_cn;
+			usbfront_ring_channel_do_connect(channel);
+			break;
+		default:
+			usbfront_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_ring_channel_state_i_cn:
+		/* Interface connecting.   */
+		/* Client disconnected.    */
+		/* No messages queued.     */
+		/* Kick send idle.         */
+		/* Kick recv idle.         */
+		/* Target rsrcs idle.      */
+		/* do connect in progress. */
+		switch (stimulus) {
+		case usbfront_ring_channel_stimulus_ri:
+			break;
+		case usbfront_ring_channel_stimulus_cs:
+			channel->state = usbfront_ring_channel_state_i_cn_cs;
+			usbfront_ring_channel_connect_client(channel);
+			break;
+		case usbfront_ring_channel_stimulus_cf:
+			channel->state = usbfront_ring_channel_state_i;
+			usbfront_ring_channel_fail_current_callback(channel);
+			break;
+		default:
+			usbfront_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_ring_channel_state_i_cn_cs:
+		/* Interface connecting.      */
+		/* Client connecting.         */
+		/* Maybe messages queued.     */
+		/* Kick send idle.            */
+		/* Kick recv idle.            */
+		/* Target rsrcs idle.         */
+		/* Connected.                 */
+		/* Connect client in progress */
+		switch (stimulus) {
+		case usbfront_ring_channel_stimulus_mq:
+		case usbfront_ring_channel_stimulus_ri:
+			break;
+		case usbfront_ring_channel_stimulus_cc:
+			channel->state =
+				usbfront_ring_channel_state_i_cn_cs_cc;
+			usbfront_ring_channel_complete_current_callback(
+								channel);
+			usbfront_ring_channel_kick_send_ring(channel);
+			usbfront_ring_channel_kick_recv_ring(channel);
+			break;
+		default:
+			usbfront_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_ring_channel_state_i_cn_cs_cc:
+		/* Interface connected.         */
+		/* Client connected.            */
+		/* Maybe messages queued.       */
+		/* Maybe kick send in progress. */
+		/* Maybe kick recv in progress. */
+		/* Maybe target rsrcs busy.     */
+		/* Connected.                   */
+		switch (stimulus) {
+		case usbfront_ring_channel_stimulus_mq:
+			usbfront_ring_channel_kick_send_ring(channel);
+			break;
+		case usbfront_ring_channel_stimulus_dn:
+			channel->state =
+				usbfront_ring_channel_state_i_cn_cs_cc_dn;
+			usbfront_ring_channel_kick_send_ring(channel);
+			usbfront_ring_channel_kick_recv_ring(channel);
+			break;
+		case usbfront_ring_channel_stimulus_ri:
+			usbfront_ring_channel_kick_recv_ring(channel);
+			break;
+		case usbfront_ring_channel_stimulus_ks:
+		case usbfront_ring_channel_stimulus_kr:
+			break;
+		case usbfront_ring_channel_stimulus_rc:
+		case usbfront_ring_channel_stimulus_rf:
+			usbfront_ring_channel_kick_recv_ring(channel);
+			break;
+		default:
+			usbfront_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_ring_channel_state_i_cn_cs_cc_dn:
+		/* Interface disconnecting.     */
+		/* Client connected.            */
+		/* Maybe messages queued.       */
+		/* Kick send in progress.       */
+		/* Kick recv in progress.       */
+		/* Maybe target rsrcs busy.     */
+		/* Connected.                   */
+		switch (stimulus) {
+		case usbfront_ring_channel_stimulus_mq:
+		case usbfront_ring_channel_stimulus_ri:
+			break;
+		case usbfront_ring_channel_stimulus_ks:
+		case usbfront_ring_channel_stimulus_kr:
+			channel->state =
+				usbfront_ring_channel_state_i_cn_cs_cc_dn_ks;
+			break;
+		case usbfront_ring_channel_stimulus_rc:
+		case usbfront_ring_channel_stimulus_rf:
+			break;
+		default:
+			usbfront_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_ring_channel_state_i_cn_cs_cc_dn_ks:
+		/* Interface disconnecting.           */
+		/* Client connected.                  */
+		/* Maybe messages queued.             */
+		/* One of kick send/recv in progress. */
+		/* Maybe target rsrcs busy.           */
+		/* Connected.                         */
+		switch (stimulus) {
+		case usbfront_ring_channel_stimulus_mq:
+		case usbfront_ring_channel_stimulus_ri:
+			break;
+		case usbfront_ring_channel_stimulus_ks:
+		case usbfront_ring_channel_stimulus_kr:
+			channel->state =
+			    usbfront_ring_channel_state_i_cn_cs_cc_dn_ks_kr;
+			usbfront_ring_channel_disconnect_client(channel);
+			usbfront_ring_channel_fail_out_messages(channel);
+			break;
+		case usbfront_ring_channel_stimulus_rc:
+		case usbfront_ring_channel_stimulus_rf:
+			break;
+		default:
+			usbfront_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_ring_channel_state_i_cn_cs_cc_dn_ks_kr:
+		/* Interface disconnecting.     */
+		/* Client disconnecting.        */
+		/* No messages queued.          */
+		/* Kick send/recv idle.         */
+		/* Maybe target rsrcs busy.     */
+		/* Connected.                   */
+		switch (stimulus) {
+		case usbfront_ring_channel_stimulus_mq:
+			usbfront_ring_channel_fail_out_messages(channel);
+			break;
+		case usbfront_ring_channel_stimulus_ri:
+			break;
+		case usbfront_ring_channel_stimulus_dc:
+			channel->state =
+			    usbfront_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc;
+			usbfront_ring_channel_test_rsrcs(channel);
+			break;
+		case usbfront_ring_channel_stimulus_rc:
+		case usbfront_ring_channel_stimulus_rf:
+			break;
+		default:
+			usbfront_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc:
+		/* Interface disconnecting.                */
+		/* Client disconnected.                    */
+		/* No messages queued.                     */
+		/* Kick send/recv idle.                    */
+		/* Testing target rsrcs/ target rsrcs busy */
+		/* Connected.                              */
+		switch (stimulus) {
+		case usbfront_ring_channel_stimulus_ri:
+		case usbfront_ring_channel_stimulus_rc:
+			break;
+		case usbfront_ring_channel_stimulus_rf:
+			channel->state =
+			usbfront_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc_rf;
+			usbfront_ring_channel_do_disconnect(channel);
+			break;
+		default:
+			usbfront_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc_rf:
+		/* Interface disconnecting. */
+		/* Client disconnected.     */
+		/* No messages queued.      */
+		/* Kick send/recv idle.     */
+		/* Target rsrcs idle.       */
+		/* Disconnecting.           */
+		switch (stimulus) {
+		case usbfront_ring_channel_stimulus_ri:
+			break;
+		case usbfront_ring_channel_stimulus_ds:
+			channel->state = usbfront_ring_channel_state_i;
+			usbfront_ring_channel_complete_current_callback(
+								channel);
+			break;
+		default:
+			usbfront_ring_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	default:
+		usbfront_ring_channel_invalid_stimulus(channel, stimulus);
+		break;
+	}
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_ring_channel.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_ring_channel.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,114 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_RING_CHANNEL_H
+#define USBFRONT_RING_CHANNEL_H
+
+#include <linux/timer.h>
+#include <xen/gnttab.h>
+#include "usbfront_channel.h"
+
+struct usbfront_ring_channel;
+
+struct usbfront_ring_channel_rsrc {
+	struct usbfront_channel_ibmsg message;
+	struct usbfront_ring_channel *channel;
+};
+
+typedef enum {
+	usbfront_ring_channel_state_i,
+	usbfront_ring_channel_state_i_cn,
+	usbfront_ring_channel_state_i_cn_cs,
+	usbfront_ring_channel_state_i_cn_cs_cc,
+	usbfront_ring_channel_state_i_cn_cs_cc_dn,
+	usbfront_ring_channel_state_i_cn_cs_cc_dn_ks,
+	usbfront_ring_channel_state_i_cn_cs_cc_dn_ks_kr,
+	usbfront_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc,
+	usbfront_ring_channel_state_i_cn_cs_cc_dn_ks_kr_dc_rf
+} usbfront_ring_channel_state;
+
+struct usbfront_ring_channel {
+	struct usbfront_channel           channel;
+	void (*protocol_error) (struct usbfront_ring_channel *channel);
+	void                             *ring;
+	grant_ref_t                       grant_ref_pool;
+	spinlock_t                        lock;
+	usbfront_ring_channel_state       state;
+	struct list_head                  message_list;
+	struct usbfront_work              do_connect_1_work;
+	struct usbfront_work              connect_client_1_work;
+	struct usbfront_work              disconnect_client_1_work;
+	struct usbfront_callback          disconnect_client_2_callback;
+	struct usbfront_work              do_disconnect_1_work;
+	struct usbfront_work              kick_send_ring_1_work;
+	struct usbfront_work              kick_recv_ring_1_work;
+	struct list_head                  rsrc_list;
+	struct usbfront_ring_channel_rsrc rsrcs[USBIF_QUOTA];
+	int                               send_ring_kick_out;
+	int                               recv_ring_kick_out;
+	int                               rsrcs_out;
+	struct usbfront_callback         *current_callback;
+	domid_t                           domain_id;
+	struct timer_list                 timer;
+	unsigned int                      event_channel;
+	grant_ref_t                       ring_ref;
+	int                               irq;
+	struct usbif_front_ring           front_ring;
+};
+
+static inline struct usbfront_channel *
+usbfront_ring_channel_to_channel(struct usbfront_ring_channel *channel)
+{
+	return &channel->channel;
+}
+
+static inline struct usbfront_ring_channel *
+usbfront_ring_channel_channel_to(struct usbfront_channel *channel)
+{
+	return container_of(channel, struct usbfront_ring_channel, channel);
+}
+
+int usbfront_ring_channel_init(struct usbfront_ring_channel *channel,
+void (*protocol_error) (struct usbfront_ring_channel *channel));
+
+struct usbfront_ring_channel_connect_request {
+	struct usbfront_callback callback;
+	domid_t                  domain_id;
+	grant_ref_t              ring_ref;
+	unsigned int             event_channel;
+};
+
+static inline struct usbfront_ring_channel_connect_request *
+usbfront_ring_channel_connect_request_callback_to(
+struct usbfront_callback *callback)
+{
+	return container_of(callback,
+		struct usbfront_ring_channel_connect_request, callback);
+}
+
+void usbfront_ring_channel_connect(struct usbfront_ring_channel *channel,
+struct usbfront_ring_channel_connect_request *request);
+
+void
+usbfront_ring_channel_disconnect(struct usbfront_ring_channel *channel,
+struct usbfront_callback *callback);
+
+void usbfront_ring_channel_exit(struct usbfront_ring_channel *channel);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_sll.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_sll.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,100 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_SLL_H
+#define USBFRONT_SLL_H
+
+struct usbfront_slk {
+	struct usbfront_slk *next;
+};
+
+struct usbfront_sll {
+	struct usbfront_slk *first;
+	struct usbfront_slk *last;
+};
+
+static inline void usbfront_slk_init(struct usbfront_slk *slk)
+{
+	slk->next = slk;
+}
+
+static inline int usbfront_slk_is_singular(struct usbfront_slk *slk)
+{
+	return (slk->next == slk);
+}
+
+static inline void usbfront_sll_init(struct usbfront_sll *sll)
+{
+	sll->first = 0;
+}
+
+static inline int usbfront_sll_is_empty(struct usbfront_sll *sll)
+{
+	return (sll->first == 0);
+}
+
+static inline void
+usbfront_sll_add_last(struct usbfront_sll *sll, struct usbfront_slk *slk)
+{
+	slk->next = 0;
+	if (sll->first != 0) {
+		sll->last->next = slk;
+	} else {
+		sll->first = slk;
+	}
+	sll->last = slk;
+}
+
+static inline struct usbfront_slk *
+usbfront_sll_remove_first(struct usbfront_sll *sll)
+{
+	struct usbfront_slk *slk = sll->first;
+	if (slk != 0) {
+		sll->first = slk->next;
+		slk->next = slk;
+	}
+	return slk;
+}
+
+static inline int
+usbfront_sll_remove_slk(struct usbfront_sll *sll, struct usbfront_slk *slk)
+{
+	struct usbfront_slk *prev_slk = NULL;
+	struct usbfront_slk *next_slk = sll->first;
+	while (next_slk != NULL) {
+		if (next_slk != slk) {
+			prev_slk = next_slk;
+			next_slk = next_slk->next;
+		} else {
+			next_slk = next_slk->next;
+			if (prev_slk != NULL) {
+				prev_slk->next = next_slk;
+			} else {
+				sll->first = next_slk;
+			}
+			if (next_slk == NULL)
+				sll->last = prev_slk;
+			slk->next = slk;
+			return 1;
+		}
+	}
+	return 0;
+}
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_trace.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_trace.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,36 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_TRACE_H
+#define USBFRONT_TRACE_H
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+
+#ifdef CONFIG_XEN_USBDEV_FRONTEND_TRACE
+
+#define trace_info(format, ...) \
+printk(KERN_INFO "usbfront %s: " format "\n", __FUNCTION__, ## __VA_ARGS__)
+#define trace() trace_info("")
+#else
+#define trace_info(format, ...)
+#define trace()
+#endif
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_work.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_work.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,73 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/module.h>
+#include "usbfront_work.h"
+
+static void usbfront_work_function(void *ignored);
+
+DEFINE_SPINLOCK(usbfront_work_list_lock);
+LIST_HEAD(usbfront_work_list);
+DECLARE_WORK(usbfront_work_work, usbfront_work_function, NULL);
+DECLARE_WAIT_QUEUE_HEAD(usbfront_work_waitqueue);
+LIST_HEAD(usbfront_work_condition);
+
+void usbfront_work_wake_up(void)
+{
+	unsigned long flags;
+	spin_lock_irqsave(&usbfront_work_list_lock, flags);
+	while (!list_empty(&usbfront_work_condition))
+		list_del_init(usbfront_work_condition.next);
+	spin_unlock_irqrestore(&usbfront_work_list_lock, flags);
+	wake_up(&usbfront_work_waitqueue);
+}
+
+int usbfront_work_schedule(struct usbfront_work *work)
+{
+	int scheduled = 0;
+	unsigned long flags;
+	spin_lock_irqsave(&usbfront_work_list_lock, flags);
+	if (list_empty(&work->link)) {
+		list_add_tail(&work->link, &usbfront_work_list);
+		scheduled = 1;
+	}
+	spin_unlock_irqrestore(&usbfront_work_list_lock, flags);
+	if (scheduled) {
+		usbfront_work_wake_up();
+		schedule_work(&usbfront_work_work);
+	}
+	return scheduled;
+}
+
+static void usbfront_work_function(void *ignored)
+{
+	unsigned long flags;
+	spin_lock_irqsave(&usbfront_work_list_lock, flags);
+	while (!list_empty(&usbfront_work_list)) {
+		struct usbfront_work *work = list_entry(
+						usbfront_work_list.next,
+						struct usbfront_work,
+						link);
+		list_del_init(&work->link);
+		spin_unlock_irqrestore(&usbfront_work_list_lock, flags);
+		usbfront_work_perform_synchronously(work);
+		spin_lock_irqsave(&usbfront_work_list_lock, flags);
+	}
+	spin_unlock_irqrestore(&usbfront_work_list_lock, flags);
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_work.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_work.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,105 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_WORK_H
+#define USBFRONT_WORK_H
+
+#include <linux/list.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+#include <linux/wait.h>
+#include <linux/workqueue.h>
+
+struct usbfront_work {
+	struct list_head link;
+	void (*function) (void *context);
+	void *context;
+};
+
+#define USBFRONT_WORK_INIT( name, fn, ctx ) \
+{ .link = LIST_HEAD_INIT( name.link ), .function = fn, .context = ctx }
+
+#define USBFRONT_WORK( name, fn, ctx ) \
+struct usbfront_work name = USBFRONT_WORK_INIT( name, fn, ctx )
+
+static inline void
+usbfront_work_init(struct usbfront_work *work, void (*function)(void *context),
+void *context)
+{
+	INIT_LIST_HEAD(&work->link);
+	work->function = function;
+	work->context = context;
+}
+
+static inline
+struct list_head *usbfront_work_to_link(struct usbfront_work *work)
+{
+	return &work->link;
+}
+
+static inline struct usbfront_work *
+usbfront_work_link_to(struct list_head *link)
+{
+	return container_of(link, struct usbfront_work, link);
+}
+
+int usbfront_work_schedule(struct usbfront_work *work);
+
+static inline void
+usbfront_work_perform_synchronously(struct usbfront_work *work)
+{
+	work->function(work->context);
+}
+
+extern spinlock_t        usbfront_work_list_lock;
+extern struct list_head  usbfront_work_list;
+extern wait_queue_head_t usbfront_work_waitqueue;
+extern struct list_head  usbfront_work_condition;
+
+#define usbfront_work_until( condition )				      \
+do {									      \
+	unsigned long flags;						      \
+	spin_lock_irqsave(&usbfront_work_list_lock, flags);		      \
+	for (;;) {							      \
+		struct list_head link;					      \
+		while (!list_empty(&usbfront_work_list) && !(condition)) {    \
+			struct usbfront_work *work;			      \
+			work = list_entry(usbfront_work_list.next,	      \
+						 struct usbfront_work, link); \
+			list_del_init(&work->link);			      \
+			spin_unlock_irqrestore(&usbfront_work_list_lock,      \
+								flags);       \
+			usbfront_work_perform_synchronously(work);	      \
+			spin_lock_irqsave(&usbfront_work_list_lock, flags);   \
+		}							      \
+		if (condition)						      \
+			break;						      \
+		INIT_LIST_HEAD(&link);					      \
+		list_add_tail(&link, &usbfront_work_condition);		      \
+		spin_unlock_irqrestore(&usbfront_work_list_lock, flags);      \
+		wait_event(usbfront_work_waitqueue, list_empty(&link));	      \
+		spin_lock_irqsave(&usbfront_work_list_lock, flags);	      \
+	}								      \
+	spin_unlock_irqrestore(&usbfront_work_list_lock, flags);	      \
+}									      \
+while (0)
+
+void usbfront_work_wake_up(void);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_xb_channel.c
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_xb_channel.c	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,382 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#include <linux/err.h>
+#include "usbfront_xb_channel.h"
+#include "usbfront_trace.h"
+
+typedef enum {
+	usbfront_xb_channel_stimulus_cn,
+	usbfront_xb_channel_stimulus_dn,
+	usbfront_xb_channel_stimulus_pe,
+	usbfront_xb_channel_stimulus_rs,
+	usbfront_xb_channel_stimulus_rf
+} usbfront_xb_channel_stimulus;
+
+static void
+usbfront_xb_channel_handle_stimulus(struct usbfront_xb_channel *channel,
+usbfront_xb_channel_stimulus stimulus);
+
+void usbfront_xb_channel_connect(struct usbfront_xb_channel *channel,
+struct xenbus_device *device)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	channel->device = device;
+	usbfront_xb_channel_handle_stimulus(channel,
+					usbfront_xb_channel_stimulus_cn);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+void usbfront_xb_channel_backend_changed(struct usbfront_xb_channel *channel,
+struct xenbus_device *dev, XenbusState state)
+{
+	trace();
+
+	switch(state) {
+	case XenbusStateUnknown:
+		trace_info( "XenbusStateUnknown" );
+		break;
+	case XenbusStateInitialising:
+		trace_info( "XenbusStateInitialising" );
+		break;
+	case XenbusStateInitWait:
+		trace_info( "XenbusStateInitWait" );
+		break;
+	case XenbusStateInitialised:
+		trace_info( "XenbusStateInitialised" );
+		break;
+	case XenbusStateConnected:
+		trace_info( "XenbusStateConnected" );
+		break;
+	case XenbusStateClosing:
+		trace_info( "XenbusStateClosing" );
+		break;
+	case XenbusStateClosed:
+		trace_info( "XenbusStateClosed" );
+		break;
+	}
+}
+
+static void
+usbfront_xb_channel_protocol_error(struct usbfront_ring_channel *ring_channel)
+{
+	struct usbfront_xb_channel *channel =
+			usbfront_xb_channel_ring_channel_to(ring_channel);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	usbfront_xb_channel_handle_stimulus(channel,
+					usbfront_xb_channel_stimulus_pe);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+void usbfront_xb_channel_disconnect(struct usbfront_xb_channel *channel)
+{
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	channel->disconnected = 0;
+	usbfront_xb_channel_handle_stimulus(channel,
+					usbfront_xb_channel_stimulus_dn);
+	spin_unlock_irqrestore(&channel->lock, flags);
+	usbfront_work_until(channel->disconnected);
+}
+
+static void
+usbfront_xb_channel_invalid_stimulus(struct usbfront_xb_channel *channel,
+usbfront_xb_channel_stimulus stimulus)
+{
+	trace();
+	printk(KERN_ERR "usbfront: xb channel %p in state %d"
+		"received invalid stimulus %d", channel, channel->state,
+								stimulus);
+}
+
+static void
+usbfront_xb_channel_connect_ring(struct usbfront_xb_channel *channel)
+{
+	trace();
+	channel->ring_connect.domain_id = channel->device->otherend_id;
+	usbfront_ring_channel_connect(&channel->channel,
+						&channel->ring_connect);
+}
+
+static void
+usbfront_xb_channel_connect_ring_1(struct usbfront_callback *callback)
+{
+	struct usbfront_xb_channel *channel = container_of(
+		usbfront_ring_channel_connect_request_callback_to(callback),
+		struct usbfront_xb_channel, ring_connect);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	usbfront_xb_channel_handle_stimulus(channel,
+					usbfront_xb_channel_stimulus_rs);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbfront_xb_channel_publish_details(struct usbfront_xb_channel *channel)
+{
+	trace();
+	usbfront_work_schedule(&channel->publish_details_1_work);
+}
+
+static void
+usbfront_xb_channel_publish_details_1(void *data)
+{
+	struct usbfront_xb_channel *channel = data;
+	xenbus_transaction_t transaction;
+	int error;
+	unsigned long flags;
+	trace();
+ again:
+	error = xenbus_transaction_start(&transaction);
+	if (error) {
+		trace_info("error starting transaction");
+		goto transaction_error;
+	}
+	error = xenbus_printf(transaction, channel->device->nodename,
+				"ring-ref", "%u",
+				channel->ring_connect.ring_ref);
+	if (error) {
+		trace_info("error writing ring-ref to store");
+		goto abort_transaction;
+	}
+	error = xenbus_printf(transaction, channel->device->nodename,
+				"event-channel", "%u",
+				channel->ring_connect.event_channel);
+	if (error) {
+		trace_info("error writing event-channel to store");
+		goto abort_transaction;
+	}
+	error = xenbus_switch_state(channel->device, transaction,
+						XenbusStateInitialised);
+	if (error) {
+		trace_info("error switching state");
+		goto abort_transaction;
+	}
+	error = xenbus_transaction_end(transaction, 0);
+	if (error) {
+		if (error == -EAGAIN) {
+			goto again;
+		} else {
+			trace_info("error committing transaction");
+			goto transaction_error;
+		}
+	}
+	spin_lock_irqsave(&channel->lock, flags);
+	usbfront_xb_channel_handle_stimulus(channel,
+					usbfront_xb_channel_stimulus_rs);
+	spin_unlock_irqrestore(&channel->lock, flags);
+	return;
+ abort_transaction:
+	xenbus_transaction_end(transaction, 1);
+ transaction_error:
+	spin_lock_irqsave(&channel->lock, flags);
+	usbfront_xb_channel_handle_stimulus(channel,
+					usbfront_xb_channel_stimulus_rf);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbfront_xb_channel_disconnect_ring(struct usbfront_xb_channel *channel)
+{
+	trace();
+	usbfront_ring_channel_disconnect(&channel->channel,
+						&channel->ring_disconnect);
+}
+
+static void
+usbfront_xb_channel_disconnect_ring_1(struct usbfront_callback *callback)
+{
+	struct usbfront_xb_channel *channel = container_of(callback,
+		struct usbfront_xb_channel, ring_disconnect);
+	unsigned long flags;
+	trace();
+	spin_lock_irqsave(&channel->lock, flags);
+	usbfront_xb_channel_handle_stimulus(channel,
+					usbfront_xb_channel_stimulus_rs);
+	spin_unlock_irqrestore(&channel->lock, flags);
+}
+
+static void
+usbfront_xb_channel_complete_disconnect(struct usbfront_xb_channel *channel)
+{
+	trace();
+	channel->disconnected = 1;
+	usbfront_work_wake_up();
+}
+
+static int
+usbfront_xb_channel_init_or_exit(struct usbfront_xb_channel *channel, int exit)
+{
+	int return_value = 0;
+	trace();
+	if (exit)
+		goto exit_path;
+	if ((return_value = usbfront_ring_channel_init(&channel->channel,
+				usbfront_xb_channel_protocol_error)) != 0) {
+		goto exit_no_ring_channel;
+	}
+	spin_lock_init(&channel->lock);
+	channel->state = usbfront_xb_channel_state_i;
+	usbfront_callback_init(&channel->ring_connect.callback,
+					usbfront_xb_channel_connect_ring_1);
+	usbfront_work_init(&channel->publish_details_1_work,
+					usbfront_xb_channel_publish_details_1,
+					channel);
+	usbfront_callback_init(&channel->ring_disconnect,
+					usbfront_xb_channel_disconnect_ring_1);
+	return 0;
+ exit_path:
+	usbfront_ring_channel_exit(&channel->channel);
+ exit_no_ring_channel:
+	return return_value;
+}
+
+int usbfront_xb_channel_init(struct usbfront_xb_channel *channel)
+{
+	return usbfront_xb_channel_init_or_exit(channel, 0);
+}
+
+void usbfront_xb_channel_exit(struct usbfront_xb_channel *channel)
+{
+	trace();
+	(void)usbfront_xb_channel_init_or_exit(channel, 1);
+}
+
+static void
+usbfront_xb_channel_handle_stimulus(struct usbfront_xb_channel *channel,
+usbfront_xb_channel_stimulus stimulus) {
+	trace_info("xb channel %p in state %d received stimulus %d", channel,
+						channel->state, stimulus);
+	switch (channel->state) {
+	case usbfront_xb_channel_state_i:
+		switch (stimulus) {
+		case usbfront_xb_channel_stimulus_cn:
+			channel->state = usbfront_xb_channel_state_i_cn;
+			usbfront_xb_channel_connect_ring(channel);
+			break;
+		default:
+			usbfront_xb_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_xb_channel_state_i_cn:
+		switch (stimulus) {
+		case usbfront_xb_channel_stimulus_dn:
+			channel->state = usbfront_xb_channel_state_i_cn_dn;
+			break;
+		case usbfront_xb_channel_stimulus_rs:
+			channel->state = usbfront_xb_channel_state_i_cn_rs;
+			usbfront_xb_channel_publish_details(channel);
+			break;
+		default:
+			usbfront_xb_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_xb_channel_state_i_cn_dn:
+		switch (stimulus) {
+		case usbfront_xb_channel_stimulus_rs:
+			channel->state = usbfront_xb_channel_state_i_cn_dn_rs;
+			usbfront_xb_channel_disconnect_ring(channel);
+			break;
+		default:
+			usbfront_xb_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_xb_channel_state_i_cn_rs:
+		switch (stimulus) {
+		case usbfront_xb_channel_stimulus_dn:
+			channel->state = usbfront_xb_channel_state_i_cn_rs_dn;
+			break;
+		case usbfront_xb_channel_stimulus_rs:
+			channel->state = usbfront_xb_channel_state_i_cn_rs_rs;
+			break;
+		case usbfront_xb_channel_stimulus_rf:
+			channel->state = usbfront_xb_channel_state_i_cn_rs_rf;
+			break;
+		default:
+			usbfront_xb_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_xb_channel_state_i_cn_dn_rs:
+		switch (stimulus) {
+		case usbfront_xb_channel_stimulus_rs:
+			channel->state = usbfront_xb_channel_state_i;
+			usbfront_xb_channel_complete_disconnect(channel);
+			break;
+		default:
+			usbfront_xb_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_xb_channel_state_i_cn_rs_dn:
+		switch (stimulus) {
+		case usbfront_xb_channel_stimulus_rs:
+		case usbfront_xb_channel_stimulus_rf:
+			usbfront_xb_channel_disconnect_ring(channel);
+			channel->state = usbfront_xb_channel_state_i_cn_dn_rs;
+			break;
+		default:
+			usbfront_xb_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_xb_channel_state_i_cn_rs_rs:
+		switch (stimulus) {
+		case usbfront_xb_channel_stimulus_dn:
+			usbfront_xb_channel_disconnect_ring(channel);
+			channel->state = usbfront_xb_channel_state_i_cn_dn_rs;
+			break;
+		default:
+			usbfront_xb_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	case usbfront_xb_channel_state_i_cn_rs_rf:
+		switch (stimulus) {
+		case usbfront_xb_channel_stimulus_dn:
+			usbfront_xb_channel_disconnect_ring(channel);
+			channel->state = usbfront_xb_channel_state_i_cn_dn_rs;
+			break;
+		default:
+			usbfront_xb_channel_invalid_stimulus(channel,
+								stimulus);
+			break;
+		}
+		break;
+	default:
+		usbfront_xb_channel_invalid_stimulus(channel, stimulus);
+		break;
+	}
+}
diff -r a376bab39768 -r e187d61f5d77 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_xb_channel.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront_xb_channel.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,75 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef USBFRONT_XB_CHANNEL_H
+#define USBFRONT_XB_CHANNEL_H
+
+#include <xen/xenbus.h>
+#include "usbfront_ring_channel.h"
+
+typedef enum {
+	usbfront_xb_channel_state_i,
+	usbfront_xb_channel_state_i_cn,
+	usbfront_xb_channel_state_i_cn_dn,
+	usbfront_xb_channel_state_i_cn_rs,
+	usbfront_xb_channel_state_i_cn_dn_rs,
+	usbfront_xb_channel_state_i_cn_rs_dn,
+	usbfront_xb_channel_state_i_cn_rs_rs,
+	usbfront_xb_channel_state_i_cn_rs_rf,
+} usbfront_xb_channel_state;
+
+struct usbfront_xb_channel {
+	struct usbfront_ring_channel                 channel;
+	spinlock_t                                   lock;
+	usbfront_xb_channel_state                    state;
+	struct xenbus_device                        *device;
+	struct usbfront_ring_channel_connect_request ring_connect;
+	struct usbfront_work                         publish_details_1_work;
+	struct usbfront_callback                     ring_disconnect;
+	int                                          disconnected;
+};
+
+static inline struct usbfront_channel *
+usbfront_xb_channel_to_channel(struct usbfront_xb_channel *channel)
+{
+	return usbfront_ring_channel_to_channel(&channel->channel);
+}
+
+static inline struct usbfront_xb_channel *
+usbfront_xb_channel_ring_channel_to(struct usbfront_ring_channel *ring_channel)
+{
+	return container_of(ring_channel, struct usbfront_xb_channel, channel);
+}
+
+static inline struct usbfront_xb_channel *
+usbfront_xb_channel_channel_to(struct usbfront_channel *channel)
+{
+	return usbfront_xb_channel_ring_channel_to(
+				usbfront_ring_channel_channel_to(channel));
+}
+
+void usbfront_xb_channel_connect(struct usbfront_xb_channel *channel,
+struct xenbus_device *device);
+void usbfront_xb_channel_backend_changed(struct usbfront_xb_channel *channel,
+struct xenbus_device *dev, XenbusState state);
+void usbfront_xb_channel_disconnect(struct usbfront_xb_channel *channel);
+int usbfront_xb_channel_init(struct usbfront_xb_channel *channel);
+void usbfront_xb_channel_exit(struct usbfront_xb_channel *channel);
+
+#endif
diff -r a376bab39768 -r e187d61f5d77 tools/examples/usb
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/tools/examples/usb	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+dir=$(dirname "$0")
+. "$dir/xen-hotplug-common.sh"
+
+success
diff -r a376bab39768 -r e187d61f5d77 xen/include/public/io/usbif.h
--- /dev/null	Tue Feb 28 21:57:38 2006
+++ b/xen/include/public/io/usbif.h	Wed Mar  1 14:34:28 2006
@@ -0,0 +1,213 @@
+/*****************************************************************************/
+/* Copyright (c) 2005 Harry Butterworth IBM Corporation                      */
+/*                                                                           */
+/* 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.,   */
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                   */
+/*                                                                           */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Based on the previous usbif.h by Mark Williamson and blkif.h, original    */
+/* copyright notice follows...                                               */
+/*****************************************************************************/
+
+/******************************************************************************
+ * usbif.h
+ * 
+ * Unified block-device I/O interface for Xen guest OSes.
+ * 
+ * Copyright (c) 2003-2004, Keir Fraser
+ */
+
+#ifndef USBIF_H
+#define USBIF_H
+
+#include "../xen.h"
+#include "../grant_table.h"
+#include "ring.h"
+
+typedef uint32_t usbif_error;
+
+#define USBIF_ERROR_SUCCESS           (usbif_error)0
+#define USBIF_ERROR_FAILURE           (usbif_error)1
+#define USBIF_ERROR_DISCONNECT        (usbif_error)2
+#define USBIF_ERROR_INVALID_PROTOCOL  (usbif_error)3
+#define USBIF_ERROR_INVALID_PARAMETER (usbif_error)4
+#define USBIF_ERROR_TOO_BIG           (usbif_error)5
+#define USBIF_ERROR_NO_DEVICE         (usbif_error)6
+#define USBIF_ERROR_UNLINKED          (usbif_error)7
+#define USBIF_ERROR_PIPE              (usbif_error)8
+
+#define USBIF_GRANT_TABLE_REFERENCE_COUNT 16
+
+typedef uint32_t usbif_buffer_byte_count;
+
+struct usbif_rbr {
+	grant_ref_t             reference[USBIF_GRANT_TABLE_REFERENCE_COUNT];
+	usbif_buffer_byte_count byte_offset;
+	usbif_buffer_byte_count byte_count;
+};
+
+static inline usbif_buffer_byte_count
+usbif_rbr_query_byte_count(struct usbif_rbr *rbr)
+{
+	return rbr->byte_count;
+}
+
+struct usbif_tra_parameters_header {
+	uint8_t tra_type;
+	uint8_t reserved[7];
+};
+
+#define USBIF_TRA_TYPE_PROBE  0
+#define USBIF_TRA_TYPE_RESET  1
+#define USBIF_TRA_TYPE_IO     2
+#define USBIF_TRA_TYPE_UNLINK 3
+
+struct usbif_probe_tra_parameters {
+	struct usbif_tra_parameters_header header;
+	uint8_t                            reserved[8];
+};
+
+struct usbif_probe_tra_status {
+	uint8_t result;
+	uint8_t reserved[7];
+};
+
+#define USBIF_PROBE_RESULT_NO_DEVICE      0
+#define USBIF_PROBE_RESULT_DEVICE_PRESENT 1
+
+struct usbif_reset_tra_parameters {
+	struct usbif_tra_parameters_header header;
+	uint8_t                            reserved[8];
+};
+
+struct usbif_reset_tra_status {
+	uint8_t result;
+	uint8_t reserved[7];
+};
+
+#define USBIF_RESET_RESULT_FULL_SPEED 0
+#define USBIF_RESET_RESULT_LOW_SPEED  1
+#define USBIF_RESET_RESULT_HIGH_SPEED 2
+
+struct usbif_io_tra_parameters_header {
+	struct usbif_tra_parameters_header header;
+	uint8_t                            io_tra_type;
+	uint8_t                            device_number;
+	uint8_t                            endpoint;
+	uint8_t                            direction;
+	uint32_t                           unlink_id;
+	uint32_t                           flags;
+	uint32_t                           reserved;
+	struct usbif_rbr                   rbr;
+};
+
+#define USBIF_IO_TRA_TYPE_CONTROL     0
+#define USBIF_IO_TRA_TYPE_BULK        1
+#define USBIF_IO_TRA_TYPE_INTERRUPT   2
+#define USBIF_IO_TRA_TYPE_ISOCHRONOUS 3
+
+#define USBIF_IO_TRA_DIRECTION_OUT 0
+#define USBIF_IO_TRA_DIRECTION_IN  1
+
+#define USBIF_IO_FLAGS_SHORT_NOT_OK 0x00000001
+#define USBIF_IO_FLAGS_ZERO_PACKET  0x00000002
+
+struct usbif_control_io_tra_parameters {
+	struct usbif_io_tra_parameters_header header;
+	uint8_t                               setup[8];
+};
+
+struct usbif_bulk_io_tra_parameters {
+	struct usbif_io_tra_parameters_header header;
+};
+
+struct usbif_interrupt_io_tra_parameters {
+	struct usbif_io_tra_parameters_header header;
+	uint32_t                              interval;
+};
+
+struct usbif_isochronous_io_tra_parameters {
+	struct usbif_io_tra_parameters_header header;
+	uint32_t                              interval;
+	uint32_t                              packet_count;
+	struct usbif_rbr                      schedule_rbr;
+};
+
+struct usbif_isochronous_io_schedule_element {
+	usbif_buffer_byte_count offset;   /* IN offset into header's rbr */
+	usbif_buffer_byte_count length;   /* IN = expected, OUT = actual */
+	usbif_error             error;    /* OUT for this packet. */
+};
+
+union usbif_io_tra_parameters {
+	struct usbif_io_tra_parameters_header      header;
+	struct usbif_control_io_tra_parameters     control;
+	struct usbif_bulk_io_tra_parameters        bulk;
+	struct usbif_interrupt_io_tra_parameters   interrupt;
+	struct usbif_isochronous_io_tra_parameters isochronous;
+};
+
+struct usbif_io_tra_status {
+	usbif_buffer_byte_count length;
+};
+
+struct usbif_unlink_tra_parameters {
+	struct usbif_tra_parameters_header header;
+	uint32_t                           unlink_id;
+	uint32_t                           reserved;
+};
+
+struct usbif_ring_gw_parameters_element {
+	uint32_t id;
+};
+
+struct usbif_ring_gw_status_element {
+	uint32_t    id;
+	usbif_error error;
+};
+
+union usbif_parameters {
+	struct usbif_tra_parameters_header header;
+	struct usbif_probe_tra_parameters  probe;
+	struct usbif_reset_tra_parameters  reset;
+	union  usbif_io_tra_parameters     io;
+	struct usbif_unlink_tra_parameters unlink;
+};
+
+union usbif_status {
+	struct usbif_probe_tra_status probe;
+	struct usbif_reset_tra_status reset;
+	struct usbif_io_tra_status    io;
+};
+
+struct usbif_request {
+	struct usbif_ring_gw_parameters_element gw_parameters;
+	union usbif_parameters                  usbif_parameters;
+};
+
+struct usbif_response {
+	struct usbif_ring_gw_status_element gw_status;
+	union usbif_status                  usbif_status;
+};
+
+DEFINE_RING_TYPES(usbif, struct usbif_request, struct usbif_response);
+
+#define USBIF_MAX_SCHEDULE_PACKET_COUNT 64
+
+/* USBIF_QUOTA is constrained by lack of flow control in RING macros. */
+#define USBIF_QUOTA (__RING_SIZE(((struct usbif_sring *)0), PAGE_SIZE) - 1)
+
+#endif

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 3%]

* Re: Re: [PATCH] Xen Guest Kexec
  @ 2006-03-06 14:15  5%                                 ` Gerd Hoffmann
  0 siblings, 0 replies; 200+ results
From: Gerd Hoffmann @ 2006-03-06 14:15 UTC (permalink / raw)
  To: Keir Fraser; +Cc: Ian Pratt, xen-devel, Mark Williamson, Horms

  Hi,

Ok, one of the more intresting issues is p2m map and ballooning, I'm not
sure yet how to address that best.

One problem are the "holes" in guest physical memory created by
ballooning.  The other one is the time gap between loading and booting
the kexec kernel (and the p2m table which may change inbetween).

My first attempt to address that issue by avoiding it
(features="auto_translated_physmap" ;) resulted in this:
kernel BUG at drivers/xen/balloon/balloon.c:216!

For now I have a few questions:

 * Which events can change the p2m map?  I think for domU that is only
   ballooning, right?  For dom0 additionally the backend drivers (when
   mapping foreign pages).  Anything else?
 * Is there some way to rebuild the p2m map from scratch using
   hypercalls?
 * Is there some easy way to "compress" the memory, i.e. move all pages
   to the start of (guest physical) memory?

 * Are unpriviledged domains allowed to do Dom0 ops for DOM_SELF?
   getdomaininfo for example?  Or hypercall_init?

cheers,

  Gerd

-- 
Gerd 'just married' Hoffmann <kraxel@suse.de>
I'm the hacker formerly known as Gerd Knorr.
http://www.suse.de/~kraxel/just-married.jpeg

^ permalink raw reply	[relevance 5%]

* [patch] small fix for memory information
@ 2006-03-08  2:59 15% Satoshi Uchida
  0 siblings, 0 replies; 200+ results
From: Satoshi Uchida @ 2006-03-08  2:59 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 827 bytes --]

Hi.

I found small bug of memory information again.
In recent -unstable, memory information in Guest OSs is difference with actual
memory allocation when using extra mem option.
Totalram_pages in Guest OS became amount of memory written mem option.

However, when using -xen0 kernel, this information became correct information.

This cause is that totalram_pages is not updated in init function,
and by handle increase/decrease reservation functions after init function or not,
totalram_pages becomes correct value or not.
In because that -xen0 kernel is upload many modules, then above functions is handled.
But, In -xenU kernel, not.

This patch is to update totalram_pages at also init function.

However, If it is correct that current_pages is equal to totalram_pages,
should it unify these variables?


Thank you,
UCHIDA

[-- Attachment #2: balloon.c.patch --]
[-- Type: application/octet-stream, Size: 507 bytes --]

diff -r b41ad96f1242 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Tue Mar  7 15:48:36 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Wed Mar  8 11:39:50 2006
@@ -468,6 +468,7 @@
                return -1;
 
        current_pages = min(xen_start_info->nr_pages, max_pfn);
+       totalram_pages = current_pages;
        target_pages  = current_pages;
        balloon_low   = 0;
        balloon_high  = 0;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 15%]

* RE: Grant tables from dom0 userspace?
@ 2006-03-09 23:16  6% King, Steven R
  0 siblings, 0 replies; 200+ results
From: King, Steven R @ 2006-03-09 23:16 UTC (permalink / raw)
  To: Andrew Warfield; +Cc: Cihula, Joseph, Jacob Gorm Hansen, xen-devel Devel

Hi Andrew -- 

> Are there implicit unmapping problems that you thing would remain
unsolved if,
> for instance, there was a vm area destructor early enough to allow the
OS to
> properly unmap active grants?

I'm having a post-unmap balloon driver problem, but could be my fault
(see below).  I'm  not convinced that implicit unmapping is an
unreasonable thing to ask of Xen.  It feels less complex overall to have
Xen deal with this once, rather than N operating system deal with it N
different ways.  I'd be interested to hear arguments here.

> When you say, "others remain," can you provide a little more detail?
I tried to list some in my reply to Keir.

While I've got you on the line... :^)  I'm having two problems right now
with my attempt at implicit unmap.  The hacks let me limp along well
enough to make progress on the code that uses the shared memory, but any
thoughts on further improvements are most welcome.

The implicit unmap code executes when the cleanup_writable_pagetable()
code _PAGE_GNTMAP flag is found in a modified pte.  The backtrace looks
like this:
(XEN)    [<ff13603e>] put_page_from_l1e+0xd0/0x1af
(XEN)    [<ff13a891>] revalidate_l1+0x159/0x168
(XEN)    [<ff13aac1>] ptwr_flush+0x221/0x32f
(XEN)    [<ff13b6a7>] cleanup_writable_pagetable+0x5c/0x7d
(XEN)    [<ff137c20>] do_mmuext_op+0x85/0x8c1
(XEN)    [<ff149e0f>] hypercall+0x8f/0xaf

At this point, the Linux has just squashed the pte.  Xen code knows the
l1e, and I've added a few more bits to the maptrack object to allow me
to find a match from the corresponding pfn.  It's kludgey, because this
only works in the special case where only one map track entity exists
for a given pfn per domain.  This is problem #1.  Ideas?  If we had the
exact address of the pte, there would be no ambiguity in which maptrack
entry owns the mapping.  I nosed around and did not find a way to get
the pte addr, but still hold out hope that it's possible.

Armed with the "correct" maptrack entry, I can do most of the ummapping
work then and there.  Later, I get the "late" vma_close() from the OS
where my guest driver explicitly unmaps to finish the job.

All is well, and I'm back at the guest command prompt.  Problem #2 is
that the balloon driver crashes me if I try to restart my user-level
app.  The dump looks like this:

kernel BUG at drivers/xen/balloon/balloon.c:218!
invalid operand: 0000 [#1]
SMP
Modules linked in:
CPU:    0
EIP:    0061:[<c023d8c4>]    Not tainted VLI
EFLAGS: 00010097   (2.6.14-xenU)
EIP is at increase_reservation+0x1c4/0x230
eax: c1000000   ebx: 0000f377   ecx: c11e6eec   edx: c0042000
esi: 00000004   edi: c11e6ee0   ebp: c038bf18   esp: c038bed8
ds: 007b   es: 007b   ss: 0069
Process events/0 (pid: 5, threadinfo=c038a000 task=c03b3530)
Stack: c11e6e80 c0346d00 00000000 00000000 cf3ac000 cf3ac000 00000004
00000000
       00000000 00007ff0 cf8f5030 c03b3658 00000005 00000004 00000000
c038a000
       c038bf34 c023db8a 00000004 c0132dff 00000000 c03b1c00 c02ff004
c038bfb4
Call Trace:
 [<c010845f>] show_stack+0x7f/0xa0
 [<c0108612>] show_registers+0x162/0x1d0
 [<c0108824>] die+0xf4/0x180
 [<c02adb85>] do_trap+0xb5/0xc0
 [<c0108bec>] do_invalid_op+0xbc/0xd0
 [<c0108127>] error_code+0x2b/0x30
 [<c023db8a>] balloon_process+0x3a/0xb0
 [<c012e05c>] worker_thread+0x19c/0x240
 [<c0132ada>] kthread+0xba/0xc0
 [<c0105f49>] kernel_thread_helper+0x5/0xc
Code: 00 00 00 00 31 d2 89 f8 e8 5a 51 f0 ff ff 45 cc 8b 55 08 39 55 cc
0f 82 6b ff ff ff e9 2b ff ff ff 0f 0b e7 00 3a 92 2d c0 eb cd <0f> 0b
da 00 3a 92 2d c0 e9 76 ff ff ff 0f 0b d7 00 3a 92 2d c0

I haven't pursed this one at all, so it could be the result a dumb
mistake on my part.

-steve


-----Original Message-----
From: xen-devel-bounces@lists.xensource.com
[mailto:xen-devel-bounces@lists.xensource.com] On Behalf Of Andrew
Warfield
Sent: Thursday, March 09, 2006 10:59 AM
To: King, Steven R
Cc: Cihula, Joseph; Jacob Gorm Hansen; xen-devel Devel
Subject: Re: [Xen-devel] Grant tables from dom0 userspace?

Hi Steven,

> I've hacked around many of
> the problems, such as implicit unmapping of grant references, but 
> others remain.  Some of the issues have no resolution in the grant 
> table architecture.

   It would be quite useful to know what specific problems you have
encountered in this effort as insight for future versions of the code.
 The main problem that I have encountered in user-level foreign page
mappings is (as discussed previously) that Linux is a bit hasty in
blowing away user virtual memory areas, and doesn't provide a good
mechanism to safely unmap the pages.  The kernel has all the information
it needs to do the right thing though, and I think this should be
reasonably fixed in the future -- i don't see a compelling reason for
Xen to do extra book-keeping to cover for something that the OS could
just as easily do.  Especially for something like cross-VM mappings,
which don't exist in the non-virtualized system. 
Are there implicit unmapping problems that you thing would remain
unsolved if, for instance, there was a vm area destructor early enough
to allow the OS to properly unmap active grants?

   When you say, "others remain," can you provide a little more detail?

thanks!
a.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 6%]

* [PATCH] clean up parsing of /proc/xen/balloon in xend
@ 2006-03-10  0:19 33% Charles Coffing
  2006-03-10 13:18  5% ` Ewan Mellor
  0 siblings, 1 reply; 200+ results
From: Charles Coffing @ 2006-03-10  0:19 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 834 bytes --]

The attached patch cleans up the parsing of /proc/xen/balloon that
occurs in xend.  Currently, the parsing is hard-coded; it expects that
the desired number is on the first line.  My patch is more robust; it
lets values be retrieved by a label.  It also exposes a few functions to
retrieve the current allocation and the target allocation.

By abstracting this a little better, I'll be able to address a few
other issues in subsequent patches.  Mostly, this allows for better
error checking and guidance for the user.  For example, by exposing
get_dom0_current_alloc(), we can (elsewhere, in a later patch) calculate
how large of a VM could potentially be started.  This is useful, as it
lets simple VM-creation GUIs guide the user towards reasonable memory
values for new VMs.

Signed-off-by:  Charles Coffing <ccoffing@novell.com>


[-- Attachment #2: proc-xen-balloon.diff --]
[-- Type: application/octet-stream, Size: 3013 bytes --]

Index: xen-unstable/tools/python/xen/xend/balloon.py
===================================================================
--- xen-unstable.orig/tools/python/xen/xend/balloon.py
+++ xen-unstable/tools/python/xen/xend/balloon.py
@@ -27,7 +27,8 @@ from XendLogging import log
 from XendError import VmError
 
 
-PROC_XEN_BALLOON = "/proc/xen/balloon"
+PROC_XEN_BALLOON = '/proc/xen/balloon'
+
 BALLOON_OUT_SLACK = 1 # MiB.  We need this because the physinfo details are
                       # rounded.
 RETRY_LIMIT = 10
@@ -39,6 +40,47 @@ RETRY_LIMIT = 10
 # such requirements.
 SLEEP_TIME_GROWTH = 0.1
 
+# A mapping between easy-to-remember labels and the more verbose
+# label actually shown in the PROC_XEN_BALLOON file.
+labels = { 'current'      : 'Current allocation',
+           'target'       : 'Requested target',
+           'low-balloon'  : 'Low-mem balloon',
+           'high-balloon' : 'High-mem balloon',
+           'limit'        : 'Xen hard limit' }
+
+def _get_proc_balloon(label):
+    """Returns the value for the named label.  Returns None if the label was
+       not found or the value was non-numeric."""
+
+    f = file(PROC_XEN_BALLOON, 'r')
+    try:
+        for line in f:
+            keyvalue = line.split(':')
+            if keyvalue[0] == label:
+                values = keyvalue[1].split()
+                if values[0].isdigit():
+                    return int(values[0])
+                else:
+                    return None
+        return None
+    finally:
+        f.close()
+
+def get_dom0_current_alloc():
+    """Returns the current memory allocation (in MiB) of dom0."""
+
+    kb = _get_proc_balloon(labels['current'])
+    if kb == None:
+        raise VmError('Failed to query current memory allocation of dom0.')
+    return kb / 1024
+
+def get_dom0_target_alloc():
+    """Returns the target memory allocation (in MiB) of dom0."""
+
+    kb = _get_proc_balloon(labels['target'])
+    if kb == None:
+        raise VmError('Failed to query target memory allocation of dom0.')
+    return kb / 1024
 
 def free(required):
     """Balloon out memory from the privileged domain so that there is the
@@ -88,7 +130,7 @@ def free(required):
                 log.debug("Balloon: free %d; need %d.", free_mem, need_mem)
 
             if dom0_min_mem > 0:
-                dom0_alloc = _get_dom0_alloc()
+                dom0_alloc = get_dom0_current_alloc()
                 new_alloc = dom0_alloc - (need_mem - free_mem)
 
                 if (new_alloc >= dom0_min_mem and
@@ -121,20 +163,3 @@ def free(required):
 
     finally:
         del xc
-
-
-def _get_dom0_alloc():
-    """Return current allocation memory of dom0 (in MiB). Return 0 on error"""
-
-    f = file(PROC_XEN_BALLOON, 'r')
-    try:
-        line = f.readline()
-        for x in line.split():
-            for n in x:
-                if not n.isdigit():
-                    break
-            else:
-                return int(x) / 1024
-        return 0
-    finally:
-        f.close()
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 33%]

* Re: [PATCH] clean up parsing of /proc/xen/balloon in xend
  2006-03-10  0:19 33% [PATCH] clean up parsing of /proc/xen/balloon in xend Charles Coffing
@ 2006-03-10 13:18  5% ` Ewan Mellor
  0 siblings, 0 replies; 200+ results
From: Ewan Mellor @ 2006-03-10 13:18 UTC (permalink / raw)
  To: Charles Coffing; +Cc: xen-devel

On Thu, Mar 09, 2006 at 07:19:59PM -0500, Charles Coffing wrote:

> The attached patch cleans up the parsing of /proc/xen/balloon that
> occurs in xend.  Currently, the parsing is hard-coded; it expects that
> the desired number is on the first line.  My patch is more robust; it
> lets values be retrieved by a label.  It also exposes a few functions to
> retrieve the current allocation and the target allocation.
> 
> By abstracting this a little better, I'll be able to address a few
> other issues in subsequent patches.  Mostly, this allows for better
> error checking and guidance for the user.  For example, by exposing
> get_dom0_current_alloc(), we can (elsewhere, in a later patch) calculate
> how large of a VM could potentially be started.  This is useful, as it
> lets simple VM-creation GUIs guide the user towards reasonable memory
> values for new VMs.
> 
> Signed-off-by:  Charles Coffing <ccoffing@novell.com>

Applied, thank you.

Ewan.

^ permalink raw reply	[relevance 5%]

* Daily Xen-HVM Builds: cs9197
@ 2006-03-10 17:51  3% Rick Gonzalez
  0 siblings, 0 replies; 200+ results
From: Rick Gonzalez @ 2006-03-10 17:51 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 3212 bytes --]


changeset:   9197:cc303cdf8809
tag:         tip
user:        emellor@leeni.uk.xensource.com
date:        Fri Mar 10 04:05:59 2006 +0100
summary:     The attached patch cleans up the parsing of 
/proc/xen/balloon that


Hardware:  x460

******************** x86_32(no PAE): ***************************

* dom0: SLES9 SP2
* dom0 boots fine
* xend starts without problem
* able to boot multiple HVM domains

ISSUES:

* xm-test does not complete. The system crashes with a CPU panic. I open
    bug #560. There is also bug#520.
* Bug #558 is present.
* Bug #562 is present.

Crash output:

(XEN) ----[ Xen-3.0-unstable    Not tainted ]----
(XEN) CPU:    15
(XEN) EIP:    e008:[<ff13c738>] hlt_timer_fn+0x28/0xd0
(XEN) EFLAGS: 00010286   CONTEXT: hypervisor
(XEN) eax: fff73000   ebx: ffbb2080   ecx: ffb8f000   edx: fff73000
(XEN) esi: 00000000   edi: ffbb2080   ebp: 00000780   esp: ff1eff28
(XEN) cr0: 8005003b   cr3: 00182000
(XEN) ds: e010   es: e010   fs: e010   gs: e010   ss: e010   cs: e008
(XEN) Xen stack trace from esp=ff1eff28:
(XEN)    ff13c560 ffbdaa00 ff13c710 ff111f68 ffbb2080 00000222 ff13d5d7 
00000001
(XEN)    278f368f 00000223 ffbb2080 ff189790 00000780 00000003 00000003 
ff12cc93
(XEN)    ec0324ad 00000222 00000000 ffbdaa00 ffbb2d10 0000000f 00000780 
00000780
(XEN)    0000000f ff1f0080 ffbb2080 ff1114f2 00ef0000 ff11df69 00000780 
ff11df85
(XEN)    c0443120 00000780 ff1effb4 c0413000 c10e0aa0 c010101a 0009fb00 
c0443120
(XEN)    004b8007 00000000 c1070003 c3f6a680 00ef0000 00000000 0000e008 
00000202
(XEN)    0000007b 0000007b 00000000 00000000 0000000f ff1f0080
(XEN) Xen call trace:
(XEN)    [<ff13c738>] hlt_timer_fn+0x28/0xd0
(XEN)    [<ff13c560>] pit_timer_fn+0x0/0xf0
(XEN)    [<ff13c710>] hlt_timer_fn+0x0/0xd0
(XEN)    [<ff111f68>] timer_softirq_action+0x228/0x390
(XEN)    [<ff13d5d7>] hvm_safe_block+0x47/0xd0
(XEN)    [<ff12cc93>] smp_call_function_interrupt+0x23/0x50
(XEN)    [<ff1114f2>] do_softirq+0x32/0x50
(XEN)    [<ff11df69>] idle_loop+0x89/0xb0
(XEN)    [<ff11df85>] idle_loop+0xa5/0xb0
(XEN)
(XEN) Pagetable walk from fff73034:
(XEN)   L2 = 001ce063 55555555
(XEN)    L1 = 00000000 55555555
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 15:
(XEN) CPU15 FATAL PAGE FAULT
(XEN) [error_code=0000]
(XEN) Faulting linear address: fff73034
(XEN) ****************************************



SUMMERY:

N/A

********************** x86_64: *********************************

* dom0: SLES9 SP2
* dom0 boots fine
* xend starts without problem
* able to boot multiple HVM domains

ISSUES:

* Bug# 558 is present
* Bug# 562 is present

SUMMERY:

Xm-test execution summary:
   PASS:  63
   FAIL:  12
   XPASS: 1
   XFAIL: 2


Details:

  FAIL: 11_create_concurrent_pos
          [1] Failed to create domain

  FAIL: 12_create_concurrent_stress_pos
          Failed to start 12_create_concurrent_stress_pos-1142010425

XFAIL: 02_network_local_ping_pos
          ping loopback failed for size 65507. ping eth0 failed for size 
65507.

XFAIL: 11_network_domU_ping_pos
          Failed to create domain

  FAIL: 12_network_domU_tcp_pos
          Failed to create domain

  FAIL: 13_network_domU_udp_pos
          Failed to create domain



regards,







[-- Attachment #2: 031006-cs9197-hvm-64bit.output --]
[-- Type: text/plain, Size: 177066 bytes --]

Making check in ramdisk
make[1]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/ramdisk'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/ramdisk'
Making check in tests
make[1]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests'
Making check in block-create
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-create'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-create'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-create'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    88.7
01_domu_proc-1142010103            1       64     1 -b----     5.4
[dom0] Running `xm destroy 01_domu_proc-1142010103'
*** Finished cleaning domUs
*** Test 01_block_attach_device_pos started at Fri Mar 10 11:02:19 2006 CDT

REASON: Block-attach not supported for HVM domains
SKIP: 01_block_attach_device_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    89.3
*** Finished cleaning domUs
*** Test 02_block_attach_file_device_pos started at Fri Mar 10 11:02:19 2006 CDT

REASON: Block-attach not supported for HVM domains
SKIP: 02_block_attach_file_device_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    89.5
*** Finished cleaning domUs
*** Test 04_block_attach_device_repeatedly_pos started at Fri Mar 10 11:02:19 2006 CDT

REASON: Block-attach not supported for HVM domains
SKIP: 04_block_attach_device_repeatedly_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    89.7
*** Finished cleaning domUs
*** Test 05_block_attach_and_dettach_device_repeatedly_pos started at Fri Mar 10 11:02:19 2006 CDT

REASON: Block-attach not supported for HVM domains
SKIP: 05_block_attach_and_dettach_device_repeatedly_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    89.9
*** Finished cleaning domUs
*** Test 06_block_attach_baddomain_neg started at Fri Mar 10 11:02:19 2006 CDT

REASON: Block-attach not supported for HVM domains
SKIP: 06_block_attach_baddomain_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    90.1
*** Finished cleaning domUs
*** Test 07_block_attach_baddevice_neg started at Fri Mar 10 11:02:20 2006 CDT

REASON: Block-attach not supported for HVM domains
SKIP: 07_block_attach_baddevice_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    90.3
*** Finished cleaning domUs
*** Test 08_block_attach_bad_filedevice_neg started at Fri Mar 10 11:02:20 2006 CDT

REASON: Block-attach not supported for HVM domains
SKIP: 08_block_attach_bad_filedevice_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    90.5
*** Finished cleaning domUs
*** Test 09_block_attach_and_dettach_device_check_data_pos started at Fri Mar 10 11:02:20 2006 CDT

REASON: Block-attach not supported for HVM domains
SKIP: 09_block_attach_and_dettach_device_check_data_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    90.7
*** Finished cleaning domUs
*** Test 11_block_attach_shared_dom0 started at Fri Mar 10 11:02:20 2006 CDT

REASON: Block-attach not supported for HVM domains
SKIP: 11_block_attach_shared_dom0.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    90.9
*** Finished cleaning domUs
*** Test 12_block_attach_shared_domU started at Fri Mar 10 11:02:20 2006 CDT

REASON: Block-attach not supported for HVM domains
SKIP: 12_block_attach_shared_domU.test
=======================
All 0 tests passed
(10 tests were not run)
=======================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-create'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-create'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-create'
Making check in block-list
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-list'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-list'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-list'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    91.1
*** Finished cleaning domUs
*** Test 01_block-list_pos started at Fri Mar 10 11:02:21 2006 CDT

REASON: Block-list not supported for HVM domains
SKIP: 01_block-list_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    91.3
*** Finished cleaning domUs
*** Test 02_block-list_attachbd_pos started at Fri Mar 10 11:02:21 2006 CDT

REASON: Block-list not supported for HVM domains
SKIP: 02_block-list_attachbd_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    91.5
*** Finished cleaning domUs
*** Test 03_block-list_anotherbd_pos started at Fri Mar 10 11:02:21 2006 CDT

REASON: Block-list not supported for HVM domains
SKIP: 03_block-list_anotherbd_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    91.7
*** Finished cleaning domUs
*** Test 04_block-list_nodb_pos started at Fri Mar 10 11:02:21 2006 CDT

REASON: Block-list not supported for HVM domains
SKIP: 04_block-list_nodb_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    91.9
*** Finished cleaning domUs
*** Test 05_block-list_nonexist_neg started at Fri Mar 10 11:02:22 2006 CDT
[dom0] Running `xm block-list 9999'
Error: Domain '9999' not found when running 'xm block-list'
PASS: 05_block-list_nonexist_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    92.2
*** Finished cleaning domUs
*** Test 06_block-list_checkremove_pos started at Fri Mar 10 11:02:22 2006 CDT

REASON: Block-list not supported for HVM domains
SKIP: 06_block-list_checkremove_pos.test
======================
All 1 tests passed
(5 tests were not run)
======================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-list'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-list'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-list'
Making check in block-destroy
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-destroy'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-destroy'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-destroy'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    92.5
*** Finished cleaning domUs
*** Test 01_block-destroy_btblock_pos started at Fri Mar 10 11:02:22 2006 CDT

REASON: Block-detach not supported for HVM domains
SKIP: 01_block-destroy_btblock_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    92.7
*** Finished cleaning domUs
*** Test 02_block-destroy_rtblock_pos started at Fri Mar 10 11:02:22 2006 CDT

REASON: Block-detach not supported for HVM domains
SKIP: 02_block-destroy_rtblock_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    92.8
*** Finished cleaning domUs
*** Test 03_block-destroy_nonexist_neg started at Fri Mar 10 11:02:22 2006 CDT
[dom0] Running `xm block-detach 9999 769'
Error: Domain '9999' not found when running 'xm block-detach'
PASS: 03_block-destroy_nonexist_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    93.5
*** Finished cleaning domUs
*** Test 04_block-destroy_nonattached_neg started at Fri Mar 10 11:02:23 2006 CDT

REASON: Block-detach not supported for HVM domains
SKIP: 04_block-destroy_nonattached_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    93.7
*** Finished cleaning domUs
*** Test 05_block-destroy_byname_pos started at Fri Mar 10 11:02:23 2006 CDT

REASON: Block-detach not supported for HVM domains
SKIP: 05_block-destroy_byname_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    93.9
*** Finished cleaning domUs
*** Test 06_block-destroy_check_list_pos started at Fri Mar 10 11:02:24 2006 CDT

REASON: Block-detach not supported for HVM domains
SKIP: 06_block-destroy_check_list_pos.test
======================
All 1 tests passed
(5 tests were not run)
======================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-destroy'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-destroy'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/block-destroy'
Making check in console
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/console'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/console'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/console'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    94.1
*** Finished cleaning domUs
*** Test 01_console_badopt_neg started at Fri Mar 10 11:02:24 2006 CDT
[dom0] Running `xm console -x'
Error: Not found
PASS: 01_console_badopt_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    94.5
*** Finished cleaning domUs
*** Test 02_console_baddom_neg started at Fri Mar 10 11:02:24 2006 CDT
[dom0] Running `xm console 5000'
Error: Domain '5000' not found when running 'xm console'
[dom0] Running `xm console NON_EXIST'
Error: Domain 'NON_EXIST' not found when running 'xm console'
PASS: 02_console_baddom_neg.test
==================
All 2 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/console'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/console'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/console'
Making check in create
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/create'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/create'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/create'
cp 11_create_concurrent_pos.py 11_create_concurrent_pos.test
chmod +x 11_create_concurrent_pos.test
cp 13_create_multinic_pos.py 13_create_multinic_pos.test
chmod +x 13_create_multinic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----    95.0
*** Finished cleaning domUs
*** Test 01_create_basic_pos started at Fri Mar 10 11:02:25 2006 CDT
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_create_basic_pos-1142010145
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_create_basic_pos-1142010145']
[01_create_basic_pos-1142010145] Sending `input'
[01_create_basic_pos-1142010145] Sending `ls'
[01_create_basic_pos-1142010145] Sending `echo $?'
[dom0] Running `xm shutdown 01_create_basic_pos-1142010145'

PASS: 01_create_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   102.9
*** Finished cleaning domUs
*** Test 02_create_noparm_neg started at Fri Mar 10 11:02:59 2006 CDT
[dom0] Running `xm create'
Error: Cannot open config file "xmdefconfig"
PASS: 02_create_noparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   103.2
*** Finished cleaning domUs
*** Test 03_create_badparm_neg started at Fri Mar 10 11:03:00 2006 CDT
[dom0] Running `xm create -x'
Error: option -x not recognized
PASS: 03_create_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   103.5
*** Finished cleaning domUs
*** Test 04_create_conflictname_neg started at Fri Mar 10 11:03:00 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain default
[dom0] Waiting 20 seconds for domU boot...
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Error: Error creating domain: VM name 'default' already in use by domain 3
[dom0] Running `xm shutdown default'

PASS: 04_create_conflictname_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   110.1
*** Finished cleaning domUs
*** Test 06_create_mem_neg started at Fri Mar 10 11:03:21 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Error: Error creating domain: (14, 'Bad address')
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Error: Error creating domain: The privileged domain did not balloon!
PASS: 06_create_mem_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   111.2
*** Finished cleaning domUs
*** Test 07_create_mem64_pos started at Fri Mar 10 11:03:27 2006 CDT
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_create_mem64_pos-1142010208
[dom0] Waiting 20 seconds for domU boot...
[dom0] Running `xm domid 07_create_mem64_pos-1142010208'
6
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   117.5
07_create_mem64_pos-1142010208     6       64     1 -b----     4.8
[dom0] Running `xm shutdown 07_create_mem64_pos-1142010208'

PASS: 07_create_mem64_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   118.1
*** Finished cleaning domUs
*** Test 08_create_mem128_pos started at Fri Mar 10 11:03:49 2006 CDT
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 08_create_mem128_pos-1142010229
[dom0] Waiting 20 seconds for domU boot...
[dom0] Running `xm domid 08_create_mem128_pos-1142010229'
7
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   124.4
08_create_mem128_pos-1142010229    7      128     1 -b----     4.8
[dom0] Running `xm shutdown 08_create_mem128_pos-1142010229'

PASS: 08_create_mem128_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   125.1
*** Finished cleaning domUs
*** Test 09_create_mem256_pos started at Fri Mar 10 11:04:11 2006 CDT
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 09_create_mem256_pos-1142010251
[dom0] Waiting 20 seconds for domU boot...
[dom0] Running `xm domid 09_create_mem256_pos-1142010251'
8
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   131.6
09_create_mem256_pos-1142010251    8      256     1 -b----     4.8
[dom0] Running `xm shutdown 09_create_mem256_pos-1142010251'

PASS: 09_create_mem256_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   132.6
*** Finished cleaning domUs
*** Test 10_create_fastdestroy started at Fri Mar 10 11:04:33 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

PASS: 10_create_fastdestroy.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   219.5
*** Finished cleaning domUs
*** Test 11_create_concurrent_pos started at Fri Mar 10 11:06:02 2006 CDT
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
*** 315 doms is too many: capping at 16
Watch out!  I'm trying to create 16 DomUs!
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_0
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_0']
[11_create_0] Sending `foo'
[11_create_0] Sending `ls'
[11_create_0] Sending `echo $?'
[0] Started 11_create_0
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Error: Device 768 (vbd) could not be connected.
File /usr/xen/xen-unstable.hg/tools/xm-test/ramdisk/disk.img is loopback-mounted through /dev/loop0,
which is mounted in a guest domain,
and so cannot be mounted now.
Failed to create domain

REASON: [1] Failed to create domain
FAIL: 11_create_concurrent_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   227.3
11_create_0                       59       24     1 -b----     5.4
11_create_1                       60       24     1 --p---     0.0
[dom0] Running `xm destroy 11_create_0'
[dom0] Running `xm destroy 11_create_1'
*** Finished cleaning domUs
*** Test 12_create_concurrent_stress_pos started at Fri Mar 10 11:06:38 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 12_create_concurrent_stress_pos-1142010398
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '12_create_concurrent_stress_pos-1142010398']
[12_create_concurrent_stress_pos-1142010398] Sending `foo'
[0/5] Started 12_create_concurrent_stress_pos-1142010398
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Error: Device 768 (vbd) could not be connected.
File /usr/xen/xen-unstable.hg/tools/xm-test/ramdisk/disk.img is loopback-mounted through /dev/loop0,
which is mounted in a guest domain,
and so cannot be mounted now.
Failed to create domain

REASON: Failed to start 12_create_concurrent_stress_pos-1142010425
FAIL: 12_create_concurrent_stress_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   235.0
12_create_concurrent_stress_pos-1142010398  61       32     1 -b----     5.1
12_create_concurrent_stress_pos-1142010425  62       32     1 --p---     0.0
[dom0] Running `xm destroy 12_create_concurrent_stress_pos-1142010398'
[dom0] Running `xm destroy 12_create_concurrent_stress_pos-1142010425'
*** Finished cleaning domUs
*** Test 13_create_multinic_pos started at Fri Mar 10 11:07:06 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1142010426
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1142010426']
[13_create_multinic_pos-1142010426] Sending `input'
[13_create_multinic_pos-1142010426] Sending `ls'
[13_create_multinic_pos-1142010426] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1142010426'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1142010460
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1142010460']
[13_create_multinic_pos-1142010460] Sending `input'
[13_create_multinic_pos-1142010460] Sending `ls'
[13_create_multinic_pos-1142010460] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1142010460'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1142010494
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1142010494']
[13_create_multinic_pos-1142010494] Sending `input'
[13_create_multinic_pos-1142010494] Sending `ls'
[13_create_multinic_pos-1142010494] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1142010494'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1142010528
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1142010528']
[13_create_multinic_pos-1142010528] Sending `input'
[13_create_multinic_pos-1142010528] Sending `ls'
[13_create_multinic_pos-1142010528] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1142010528'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1142010563
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1142010563']
[13_create_multinic_pos-1142010563] Sending `input'
[13_create_multinic_pos-1142010563] Sending `ls'
[13_create_multinic_pos-1142010563] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1142010563'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1142010597
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1142010597']
[13_create_multinic_pos-1142010597] Sending `input'
[13_create_multinic_pos-1142010597] Sending `ls'
[13_create_multinic_pos-1142010597] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1142010597'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1142010631
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1142010631']
[13_create_multinic_pos-1142010631] Sending `input'
[13_create_multinic_pos-1142010631] Sending `ls'
[13_create_multinic_pos-1142010631] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1142010631'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1142010666
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1142010666']
[13_create_multinic_pos-1142010666] Sending `input'
[13_create_multinic_pos-1142010666] Sending `ls'
[13_create_multinic_pos-1142010666] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1142010666'

PASS: 13_create_multinic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   305.8
*** Finished cleaning domUs
*** Test 14_create_blockroot_pos started at Fri Mar 10 11:11:41 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 14_create_blockroot
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '14_create_blockroot']
[14_create_blockroot] Sending `foo'
[14_create_blockroot] Sending `ls'
[14_create_blockroot] Sending `echo $?'
PASS: 14_create_blockroot_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   313.0
14_create_blockroot               71       64     1 -b----     5.3
[dom0] Running `xm destroy 14_create_blockroot'
*** Finished cleaning domUs
*** Test 15_create_smallmem_pos started at Fri Mar 10 11:12:15 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 15_create_smallmem_pos-1142010735
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '15_create_smallmem_pos-1142010735']
[15_create_smallmem_pos-1142010735] Sending `input'
[15_create_smallmem_pos-1142010735] Sending `ls'
[15_create_smallmem_pos-1142010735] Sending `echo $?'
[dom0] Running `xm destroy 15_create_smallmem_pos-1142010735'

PASS: 15_create_smallmem_pos.test
====================
2 of 14 tests failed
====================
make[4]: *** [check-TESTS] Error 1
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/create'
make[3]: *** [check-am] Error 2
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/create'
make[2]: *** [check-recursive] Error 1
make[2]: Target `check' not remade because of errors.
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/create'
Making check in destroy
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/destroy'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/destroy'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/destroy'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   321.2
*** Finished cleaning domUs
*** Test 01_destroy_basic_pos started at Fri Mar 10 11:12:49 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_destroy_basic_pos-1142010769
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_destroy_basic_pos-1142010769']
[01_destroy_basic_pos-1142010769] Sending `foo'
[01_destroy_basic_pos-1142010769] Sending `ls'
[01_destroy_basic_pos-1142010769] Sending `echo $?'
[dom0] Running `xm destroy 01_destroy_basic_pos-1142010769'

PASS: 01_destroy_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   329.1
*** Finished cleaning domUs
*** Test 02_destroy_noparm_neg started at Fri Mar 10 11:13:23 2006 CDT
[dom0] Running `xm destroy'
Error: 'xm destroy' requires 1 argument.

   destroy <DomId>                  Terminate a domain immediately
PASS: 02_destroy_noparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   329.4
*** Finished cleaning domUs
*** Test 03_destroy_nonexist_neg started at Fri Mar 10 11:13:24 2006 CDT
[dom0] Running `xm destroy -x'
Error: Not found
PASS: 03_destroy_nonexist_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   329.7
*** Finished cleaning domUs
*** Test 04_destroy_badparm_neg started at Fri Mar 10 11:13:24 2006 CDT
[dom0] Running `xm destroy 6666'
Error: Domain '6666' not found when running 'xm destroy'
PASS: 04_destroy_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   330.0
*** Finished cleaning domUs
*** Test 05_destroy_byid_pos started at Fri Mar 10 11:13:24 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 05_destroy_byid_pos-1142010804
[dom0] Waiting 20 seconds for domU boot...
[dom0] Running `xm domid 05_destroy_byid_pos-1142010804'
74
[dom0] Running `xm destroy 74'

PASS: 05_destroy_byid_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   336.6
*** Finished cleaning domUs
*** Test 06_destroy_dom0_neg started at Fri Mar 10 11:13:46 2006 CDT
[dom0] Running `xm destroy 0'
Error: Cannot destroy privileged domain 0
PASS: 06_destroy_dom0_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   337.0
*** Finished cleaning domUs
*** Test 07_destroy_stale_pos started at Fri Mar 10 11:13:46 2006 CDT
Running stale tests (nice mode)
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142010826
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1142010826']
[07_destroy_stale_pos-1142010826] Sending `foo'
[07_destroy_stale_pos-1142010826] Sending `ls'
[07_destroy_stale_pos-1142010826] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1142010826'

[dom0] Running `xm mem-set 07_destroy_stale_pos-1142010826 32'
Error: Domain '07_destroy_stale_pos-1142010826' not found when running 'xm mem-set'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142010860
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1142010860']
[07_destroy_stale_pos-1142010860] Sending `foo'
[07_destroy_stale_pos-1142010860] Sending `ls'
[07_destroy_stale_pos-1142010860] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1142010860'

[dom0] Running `xm pause 07_destroy_stale_pos-1142010860'
Error: Domain '07_destroy_stale_pos-1142010860' not found when running 'xm pause'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142010894
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1142010894']
[07_destroy_stale_pos-1142010894] Sending `foo'
[07_destroy_stale_pos-1142010894] Sending `ls'
[07_destroy_stale_pos-1142010894] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1142010894'

[dom0] Running `xm unpause 07_destroy_stale_pos-1142010894'
Error: Domain '07_destroy_stale_pos-1142010894' not found when running 'xm unpause'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142010928
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1142010928']
[07_destroy_stale_pos-1142010928] Sending `foo'
[07_destroy_stale_pos-1142010928] Sending `ls'
[07_destroy_stale_pos-1142010928] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1142010928'

[dom0] Running `xm reboot 07_destroy_stale_pos-1142010928'
Error: Domain '07_destroy_stale_pos-1142010928' not found when running 'xm reboot'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142010962
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1142010962']
[07_destroy_stale_pos-1142010962] Sending `foo'
[07_destroy_stale_pos-1142010962] Sending `ls'
[07_destroy_stale_pos-1142010962] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1142010962'

[dom0] Running `xm save 07_destroy_stale_pos-1142010962 /tmp/foo'
Error: Domain '07_destroy_stale_pos-1142010962' not found when running 'xm save'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142010996
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1142010996']
[07_destroy_stale_pos-1142010996] Sending `foo'
[07_destroy_stale_pos-1142010996] Sending `ls'
[07_destroy_stale_pos-1142010996] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1142010996'

[dom0] Running `xm block-list 07_destroy_stale_pos-1142010996'
Error: Domain '07_destroy_stale_pos-1142010996' not found when running 'xm block-list'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011030
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1142011030']
[07_destroy_stale_pos-1142011030] Sending `foo'
[07_destroy_stale_pos-1142011030] Sending `ls'
[07_destroy_stale_pos-1142011030] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011030'

[dom0] Running `xm shutdown 07_destroy_stale_pos-1142011030'
Error: Domain '07_destroy_stale_pos-1142011030' not found when running 'xm shutdown'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011064
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1142011064']
[07_destroy_stale_pos-1142011064] Sending `foo'
[07_destroy_stale_pos-1142011064] Sending `ls'
[07_destroy_stale_pos-1142011064] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011064'

[dom0] Running `xm domid 07_destroy_stale_pos-1142011064'
Error: Domain '07_destroy_stale_pos-1142011064' not found when running 'xm domid'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011098
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1142011098']
[07_destroy_stale_pos-1142011098] Sending `foo'
[07_destroy_stale_pos-1142011098] Sending `ls'
[07_destroy_stale_pos-1142011098] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011098'

[dom0] Running `xm domname 07_destroy_stale_pos-1142011098'
Error: Domain '07_destroy_stale_pos-1142011098' not found when running 'xm domname'
Running stale tests (mean mode)
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011132
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011132'

[dom0] Running `xm mem-set 07_destroy_stale_pos-1142011132 32'
Error: Domain '07_destroy_stale_pos-1142011132' not found when running 'xm mem-set'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011134
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011134'

[dom0] Running `xm pause 07_destroy_stale_pos-1142011134'
Error: Domain '07_destroy_stale_pos-1142011134' not found when running 'xm pause'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011136
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011136'

[dom0] Running `xm unpause 07_destroy_stale_pos-1142011136'
Error: Domain '07_destroy_stale_pos-1142011136' not found when running 'xm unpause'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011138
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011138'

[dom0] Running `xm reboot 07_destroy_stale_pos-1142011138'
Error: Domain '07_destroy_stale_pos-1142011138' not found when running 'xm reboot'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011140
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011140'

[dom0] Running `xm save 07_destroy_stale_pos-1142011140 /tmp/foo'
Error: Domain '07_destroy_stale_pos-1142011140' not found when running 'xm save'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011142
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011142'

[dom0] Running `xm block-list 07_destroy_stale_pos-1142011142'
Error: Domain '07_destroy_stale_pos-1142011142' not found when running 'xm block-list'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011144
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011144'

[dom0] Running `xm shutdown 07_destroy_stale_pos-1142011144'
Error: Domain '07_destroy_stale_pos-1142011144' not found when running 'xm shutdown'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011146
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011146'

[dom0] Running `xm domid 07_destroy_stale_pos-1142011146'
Error: Domain '07_destroy_stale_pos-1142011146' not found when running 'xm domid'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1142011148
[dom0] Running `xm destroy 07_destroy_stale_pos-1142011148'

[dom0] Running `xm domname 07_destroy_stale_pos-1142011148'
Error: Domain '07_destroy_stale_pos-1142011148' not found when running 'xm domname'
PASS: 07_destroy_stale_pos.test
==================
All 7 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/destroy'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/destroy'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/destroy'
Making check in dmesg
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/dmesg'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/dmesg'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/dmesg'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   422.4
*** Finished cleaning domUs
*** Test 01_dmesg_basic_pos started at Fri Mar 10 11:19:10 2006 CDT
[dom0] Running `xm dmesg'
 (GUEST: 84) HVM Loader
(XEN) (GUEST: 84) Loading ROMBIOS ...
(XEN) (GUEST: 84) Loading Cirrus VGABIOS ...
(XEN) (GUEST: 84) Loading VMXAssist ...
(XEN) (GUEST: 84) VMX go ...
(XEN) (GUEST: 84) VMXAssist (Mar 10 2006)
(XEN) (GUEST: 84) Memory size 64 MB
(XEN) (GUEST: 84) E820 map:
(XEN) (GUEST: 84) 0000000000000000 - 000000000009F800 (RAM)
(XEN) (GUEST: 84) 000000000009F800 - 00000000000A0000 (Reserved)
(XEN) (GUEST: 84) 00000000000A0000 - 00000000000C0000 (Type 16)
(XEN) (GUEST: 84) 00000000000F0000 - 0000000000100000 (Reserved)
(XEN) (GUEST: 84) 0000000000100000 - 0000000003FFE000 (RAM)
(XEN) (GUEST: 84) 0000000003FFF000 - 0000000004000000 (Type 17)
(XEN) (GUEST: 84) 0000000003FFE000 - 0000000003FFF000 (Type 18)
(XEN) (GUEST: 84) 0000000004000000 - 0000000004003000 (ACPI NVS)
(XEN) (GUEST: 84) 0000000004003000 - 000000000400D000 (ACPI Data)
(XEN) (GUEST: 84) 00000000FEC00000 - 0000000100000000 (Type 16)
(XEN) (GUEST: 84) 
(XEN) (GUEST: 84) Start BIOS ...
(XEN) (GUEST: 84) Starting emulated 16-bit real-mode: ip=F000:FFF0
(XEN) (GUEST: 84)  rombios.c,v 1.138 2005/05/07 15:55:26 vruppert Exp $
(XEN) HVM_PIT: guest freq in cycles=150134573
(XEN) (GUEST: 84) Remapping master: ICW2 0x8 -> 0x20
(XEN) (GUEST: 84) Remapping slave: ICW2 0x70 -> 0x28
(XEN) (GUEST: 84) VGABios $Id: vgabios.c,v 1.61 2005/05/24 16:50:50 vruppert Exp $
(XEN) (GUEST: 84) HVMAssist BIOS, 1 cpu, $Revision: 1.138 $ $Date: 2005/05/07 15:55:26 $
(XEN) (GUEST: 84) 
(XEN) (GUEST: 84) ata0-0: PCHS=64/8/32 translation=none LCHS=64/8/32
(XEN) (GUEST: 84) ata0 master: QEMU HARDDISK ATA-2 Hard-Disk (8 MBytes)
(XEN) (GUEST: 84) ata0  slave: Unknown device
(XEN) (GUEST: 84) ata1 master: QEMU CD-ROM ATAPI-4 CD-Rom/DVD-Rom
(XEN) (GUEST: 84) ata1  slave: Unknown device
(XEN) (GUEST: 84) 
(XEN) (GUEST: 84) Booting from Hard Disk...
(XEN) (GUEST: 85) HVM Loader
(XEN) (GUEST: 85) Loading ROMBIOS ...
(XEN) (GUEST: 85) Loading Cirrus VGABIOS ...
(XEN) (GUEST: 85) Loading VMXAssist ...
(XEN) (GUEST: 85) VMX go ...
(XEN) (GUEST: 85) VMXAssist (Mar 10 2006)
(XEN) (GUEST: 85) Memory size 64 MB
(XEN) (GUEST: 85) E820 map:
(XEN) (GUEST: 85) 0000000000000000 - 000000000009F800 (RAM)
(XEN) (GUEST: 85) 000000000009F800 - 00000000000A0000 (Reserved)
(XEN) (GUEST: 85) 00000000000A0000 - 00000000000C0000 (Type 16)
(XEN) (GUEST: 85) 00000000000F0000 - 0000000000100000 (Reserved)
(XEN) (GUEST: 85) 0000000000100000 - 0000000003FFE000 (RAM)
(XEN) (GUEST: 85) 0000000003FFF000 - 0000000004000000 (Type 17)
(XEN) (GUEST: 85) 0000000003FFE000 - 0000000003FFF000 (Type 18)
(XEN) (GUEST: 85) 0000000004000000 - 0000000004003000 (ACPI NVS)
(XEN) (GUEST: 85) 0000000004003000 - 000000000400D000 (ACPI Data)
(XEN) (GUEST: 85) 00000000FEC00000 - 0000000100000000 (Type 16)
(XEN) (GUEST: 85) 
(XEN) (GUEST: 85) Start BIOS ...
(XEN) (GUEST: 85) Starting emulated 16-bit real-mode: ip=F000:FFF0
(XEN) (GUEST: 85)  rombios.c,v 1.138 2005/05/07 15:55:26 vruppert Exp $
(XEN) HVM_PIT: guest freq in cycles=150134573
(XEN) (GUEST: 85) Remapping master: ICW2 0x8 -> 0x20
(XEN) (GUEST: 85) Remapping slave: ICW2 0x70 -> 0x28
(XEN) (GUEST: 85) VGABios $Id: vgabios.c,v 1.61 2005/05/24 16:50:50 vruppert Exp $
(XEN) (GUEST: 85) HVMAssist BIOS, 1 cpu, $Revision: 1.138 $ $Date: 2005/05/07 15:55:26 $
(XEN) (GUEST: 85) 
(XEN) (GUEST: 85) ata0-0: PCHS=64/8/32 translation=none LCHS=64/8/32
(XEN) (GUEST: 85) ata0 master: QEMU HARDDISK ATA-2 Hard-Disk (8 MBytes)
(XEN) (GUEST: 85) ata0  slave: Unknown device
(XEN) (GUEST: 85) ata1 master: QEMU CD-ROM ATAPI-4 CD-Rom/DVD-Rom
(XEN) (GUEST: 85) ata1  slave: Unknown device
(XEN) (GUEST: 85) 
(XEN) (GUEST: 85) Booting from Hard Disk...
(XEN) (GUEST: 86) HVM Loader
(XEN) (GUEST: 86) Loading ROMBIOS ...
(XEN) (GUEST: 86) Loading Cirrus VGABIOS ...
(XEN) (GUEST: 86) Loading VMXAssist ...
(XEN) (GUEST: 86) VMX go ...
(XEN) (GUEST: 86) VMXAssist (Mar 10 2006)
(XEN) (GUEST: 86) Memory size 64 MB
(XEN) (GUEST: 86) E820 map:
(XEN) (GUEST: 86) 0000000000000000 - 000000000009F800 (RAM)
(XEN) (GUEST: 86) 000000000009F800 - 00000000000A0000 (Reserved)
(XEN) (GUEST: 86) 00000000000A0000 - 00000000000C0000 (Type 16)
(XEN) (GUEST: 86) 00000000000F0000 - 0000000000100000 (Reserved)
(XEN) (GUEST: 86) 0000000000100000 - 0000000003FFE000 (RAM)
(XEN) (GUEST: 86) 0000000003FFF000 - 0000000004000000 (Type 17)
(XEN) (GUEST: 86) 0000000003FFE000 - 0000000003FFF000 (Type 18)
(XEN) (GUEST: 86) 0000000004000000 - 0000000004003000 (ACPI NVS)
(XEN) (GUEST: 86) 0000000004003000 - 000000000400D000 (ACPI Data)
(XEN) (GUEST: 86) 00000000FEC00000 - 0000000100000000 (Type 16)
(XEN) (GUEST: 86) 
(XEN) (GUEST: 86) Start BIOS ...
(XEN) (GUEST: 86) Starting emulated 16-bit real-mode: ip=F000:FFF0
(XEN) (GUEST: 86)  rombios.c,v 1.138 2005/05/07 15:55:26 vruppert Exp $
(XEN) HVM_PIT: guest freq in cycles=150134573
(XEN) (GUEST: 86) Remapping master: ICW2 0x8 -> 0x20
(XEN) (GUEST: 86) Remapping slave: ICW2 0x70 -> 0x28
(XEN) (GUEST: 86) VGABios $Id: vgabios.c,v 1.61 2005/05/24 16:50:50 vruppert Exp $
(XEN) (GUEST: 86) HVMAssist BIOS, 1 cpu, $Revision: 1.138 $ $Date: 2005/05/07 15:55:26 $
(XEN) (GUEST: 86) 
(XEN) (GUEST: 86) ata0-0: PCHS=64/8/32 translation=none LCHS=64/8/32
(XEN) (GUEST: 86) ata0 master: QEMU HARDDISK ATA-2 Hard-Disk (8 MBytes)
(XEN) (GUEST: 86) ata0  slave: Unknown device
(XEN) (GUEST: 86) ata1 master: QEMU CD-ROM ATAPI-4 CD-Rom/DVD-Rom
(XEN) (GUEST: 86) ata1  slave: Unknown device
(XEN) (GUEST: 86) 
(XEN) (GUEST: 86) Booting from Hard Disk...
(XEN) (GUEST: 87) HVM Loader
(XEN) (GUEST: 87) Loading ROMBIOS ...
(XEN) (GUEST: 87) Loading Cirrus VGABIOS ...
(XEN) (GUEST: 87) Loading VMXAssist ...
(XEN) (GUEST: 87) VMX go ...
(XEN) (GUEST: 87) VMXAssist (Mar 10 2006)
(XEN) (GUEST: 87) Memory size 64 MB
(XEN) (GUEST: 87) E820 map:
(XEN) (GUEST: 87) 0000000000000000 - 000000000009F800 (RAM)
(XEN) (GUEST: 87) 000000000009F800 - 00000000000A0000 (Reserved)
(XEN) (GUEST: 87) 00000000000A0000 - 00000000000C0000 (Type 16)
(XEN) (GUEST: 87) 00000000000F0000 - 0000000000100000 (Reserved)
(XEN) (GUEST: 87) 0000000000100000 - 0000000003FFE000 (RAM)
(XEN) (GUEST: 87) 0000000003FFF000 - 0000000004000000 (Type 17)
(XEN) (GUEST: 87) 0000000003FFE000 - 0000000003FFF000 (Type 18)
(XEN) (GUEST: 87) 0000000004000000 - 0000000004003000 (ACPI NVS)
(XEN) (GUEST: 87) 0000000004003000 - 000000000400D000 (ACPI Data)
(XEN) (GUEST: 87) 00000000FEC00000 - 0000000100000000 (Type 16)
(XEN) (GUEST: 87) 
(XEN) (GUEST: 87) Start BIOS ...
(XEN) (GUEST: 87) Starting emulated 16-bit real-mode: ip=F000:FFF0
(XEN) (GUEST: 87)  rombios.c,v 1.138 2005/05/07 15:55:26 vruppert Exp $
(XEN) HVM_PIT: guest freq in cycles=150134573
(XEN) (GUEST: 87) Remapping master: ICW2 0x8 -> 0x20
(XEN) (GUEST: 87) Remapping slave: ICW2 0x70 -> 0x28
(XEN) (GUEST: 87) VGABios $Id: vgabios.c,v 1.61 2005/05/24 16:50:50 vruppert Exp $
(XEN) (GUEST: 87) HVMAssist BIOS, 1 cpu, $Revision: 1.138 $ $Date: 2005/05/07 15:55:26 $
(XEN) (GUEST: 87) 
(XEN) (GUEST: 87) ata0-0: PCHS=64/8/32 translation=none LCHS=64/8/32
(XEN) (GUEST: 87) ata0 master: QEMU HARDDISK ATA-2 Hard-Disk (8 MBytes)
(XEN) (GUEST: 87) ata0  slave: Unknown device
(XEN) (GUEST: 87) ata1 master: QEMU CD-ROM ATAPI-4 CD-Rom/DVD-Rom
(XEN) (GUEST: 87) ata1  slave: Unknown device
(XEN) (GUEST: 87) 
(XEN) (GUEST: 87) Booting from Hard Disk...
(XEN) (GUEST: 88) HVM Loader
(XEN) (GUEST: 88) Loading ROMBIOS ...
(XEN) (GUEST: 88) Loading Cirrus VGABIOS ...
(XEN) (GUEST: 88) Loading VMXAssist ...
(XEN) (GUEST: 88) VMX go ...
(XEN) (GUEST: 88) VMXAssist (Mar 10 2006)
(XEN) (GUEST: 88) Memory size 64 MB
(XEN) (GUEST: 88) E820 map:
(XEN) (GUEST: 88) 0000000000000000 - 000000000009F800 (RAM)
(XEN) (GUEST: 88) 000000000009F800 - 00000000000A0000 (Reserved)
(XEN) (GUEST: 88) 00000000000A0000 - 00000000000C0000 (Type 16)
(XEN) (GUEST: 88) 00000000000F0000 - 0000000000100000 (Reserved)
(XEN) (GUEST: 88) 0000000000100000 - 0000000003FFE000 (RAM)
(XEN) (GUEST: 88) 0000000003FFF000 - 0000000004000000 (Type 17)
(XEN) (GUEST: 88) 0000000003FFE000 - 0000000003FFF000 (Type 18)
(XEN) (GUEST: 88) 0000000004000000 - 0000000004003000 (ACPI NVS)
(XEN) (GUEST: 88) 0000000004003000 - 000000000400D000 (ACPI Data)
(XEN) (GUEST: 88) 00000000FEC00000 - 0000000100000000 (Type 16)
(XEN) (GUEST: 88) 
(XEN) (GUEST: 88) Start BIOS ...
(XEN) (GUEST: 88) Starting emulated 16-bit real-mode: ip=F000:FFF0
(XEN) (GUEST: 88)  rombios.c,v 1.138 2005/05/07 15:55:26 vruppert Exp $
(XEN) HVM_PIT: guest freq in cycles=150134573
(XEN) (GUEST: 88) Remapping master: ICW2 0x8 -> 0x20
(XEN) (GUEST: 88) Remapping slave: ICW2 0x70 -> 0x28
(XEN) (GUEST: 88) VGABios $Id: vgabios.c,v 1.61 2005/05/24 16:50:50 vruppert Exp $
(XEN) (GUEST: 88) HVMAssist BIOS, 1 cpu, $Revision: 1.138 $ $Date: 2005/05/07 15:55:26 $
(XEN) (GUEST: 88) 
(XEN) (GUEST: 88) ata0-0: PCHS=64/8/32 translation=none LCHS=64/8/32
(XEN) (GUEST: 88) ata0 master: QEMU HARDDISK ATA-2 Hard-Disk (8 MBytes)
(XEN) (GUEST: 88) ata0  slave: Unknown device
(XEN) (GUEST: 88) ata1 master: QEMU CD-ROM ATAPI-4 CD-Rom/DVD-Rom
(XEN) (GUEST: 88) ata1  slave: Unknown device
(XEN) (GUEST: 88) 
(XEN) (GUEST: 88) Booting from Hard Disk...
(XEN) (GUEST: 89) HVM Loader
(XEN) (GUEST: 89) Loading ROMBIOS ...
(XEN) (GUEST: 89) Loading Cirrus VGABIOS ...
(XEN) (GUEST: 89) Loading VMXAssist ...
(XEN) (GUEST: 89) VMX go ...
(XEN) (GUEST: 89) VMXAssist (Mar 10 2006)
(XEN) (GUEST: 89) Memory size 64 MB
(XEN) (GUEST: 89) E820 map:
(XEN) (GUEST: 89) 0000000000000000 - 000000000009F800 (RAM)
(XEN) (GUEST: 89) 000000000009F800 - 00000000000A0000 (Reserved)
(XEN) (GUEST: 89) 00000000000A0000 - 00000000000C0000 (Type 16)
(XEN) (GUEST: 89) 00000000000F0000 - 0000000000100000 (Reserved)
(XEN) (GUEST: 89) 0000000000100000 - 0000000003FFE000 (RAM)
(XEN) (GUEST: 89) 0000000003FFF000 - 0000000004000000 (Type 17)
(XEN) (GUEST: 89) 0000000003FFE000 - 0000000003FFF000 (Type 18)
(XEN) (GUEST: 89) 0000000004000000 - 0000000004003000 (ACPI NVS)
(XEN) (GUEST: 89) 0000000004003000 - 000000000400D000 (ACPI Data)
(XEN) (GUEST: 89) 00000000FEC00000 - 0000000100000000 (Type 16)
(XEN) (GUEST: 89) 
(XEN) (GUEST: 89) Start BIOS ...
(XEN) (GUEST: 89) Starting emulated 16-bit real-mode: ip=F000:FFF0
(XEN) (GUEST: 89)  rombios.c,v 1.138 2005/05/07 15:55:26 vruppert Exp $
(XEN) HVM_PIT: guest freq in cycles=150134573
(XEN) (GUEST: 89) Remapping master: ICW2 0x8 -> 0x20
(XEN) (GUEST: 89) Remapping slave: ICW2 0x70 -> 0x28
(XEN) (GUEST: 89) VGABios $Id: vgabios.c,v 1.61 2005/05/24 16:50:50 vruppert Exp $
(XEN) (GUEST: 89) HVMAssist BIOS, 1 cpu, $Revision: 1.138 $ $Date: 2005/05/07 15:55:26 $
(XEN) (GUEST: 89) 
(XEN) (GUEST: 89) ata0-0: PCHS=64/8/32 translation=none LCHS=64/8/32
(XEN) (GUEST: 89) ata0 master: QEMU HARDDISK ATA-2 Hard-Disk (8 MBytes)
(XEN) (GUEST: 89) ata0  slave: Unknown device
(XEN) (GUEST: 89) ata1 master: QEMU CD-ROM ATAPI-4 CD-Rom/DVD-Rom
(XEN) (GUEST: 89) ata1  slave: Unknown device
(XEN) (GUEST: 89) 
(XEN) (GUEST: 89) Booting from Hard Disk...
(XEN) (GUEST: 90) HVM Loader
(XEN) (GUEST: 90) Loading ROMBIOS ...
(XEN) (GUEST: 90) Loading Cirrus VGABIOS ...
(XEN) (GUEST: 90) Loading VMXAssist ...
(XEN) (GUEST: 90) VMX go ...
(XEN) (GUEST: 90) VMXAssist (Mar 10 2006)
(XEN) (GUEST: 90) Memory size 64 MB
(XEN) (GUEST: 90) E820 map:
(XEN) (GUEST: 90) 0000000000000000 - 000000000009F800 (RAM)
(XEN) (GUEST: 90) 000000000009F800 - 00000000000A0000 (Reserved)
(XEN) (GUEST: 90) 00000000000A0000 - 00000000000C0000 (Type 16)
(XEN) (GUEST: 90) 00000000000F0000 - 0000000000100000 (Reserved)
(XEN) (GUEST: 90) 0000000000100000 - 0000000003FFE000 (RAM)
(XEN) (GUEST: 90) 0000000003FFF000 - 0000000004000000 (Type 17)
(XEN) (GUEST: 90) 0000000003FFE000 - 0000000003FFF000 (Type 18)
(XEN) (GUEST: 90) 0000000004000000 - 0000000004003000 (ACPI NVS)
(XEN) (GUEST: 90) 0000000004003000 - 000000000400D000 (ACPI Data)
(XEN) (GUEST: 90) 00000000FEC00000 - 0000000100000000 (Type 16)
(XEN) (GUEST: 90) 
(XEN) (GUEST: 90) Start BIOS ...
(XEN) (GUEST: 90) Starting emulated 16-bit real-mode: ip=F000:FFF0
(XEN) (GUEST: 90)  rombios.c,v 1.138 2005/05/07 15:55:26 vruppert Exp $
(XEN) HVM_PIT: guest freq in cycles=150134573
(XEN) (GUEST: 90) Remapping master: ICW2 0x8 -> 0x20
(XEN) (GUEST: 90) Remapping slave: ICW2 0x70 -> 0x28
(XEN) (GUEST: 90) VGABios $Id: vgabios.c,v 1.61 2005/05/24 16:50:50 vruppert Exp $
(XEN) (GUEST: 90) HVMAssist BIOS, 1 cpu, $Revision: 1.138 $ $Date: 2005/05/07 15:55:26 $
(XEN) (GUEST: 90) 
(XEN) (GUEST: 90) ata0-0: PCHS=64/8/32 translation=none LCHS=64/8/32
(XEN) (GUEST: 90) ata0 master: QEMU HARDDISK ATA-2 Hard-Disk (8 MBytes)
(XEN) (GUEST: 90) ata0  slave: Unknown device
(XEN) (GUEST: 90) ata1 master: QEMU CD-ROM ATAPI-4 CD-Rom/DVD-Rom
(XEN) (GUEST: 90) ata1  slave: Unknown device
(XEN) (GUEST: 90) 
(XEN) (GUEST: 90) Booting from Hard Disk...
(XEN) (GUEST: 91) HVM Loader
(XEN) (GUEST: 91) Loading ROMBIOS ...
(XEN) (GUEST: 91) Loading Cirrus VGABIOS ...
(XEN) (GUEST: 91) Loading VMXAssist ...
(XEN) (GUEST: 91) VMX go ...
(XEN) (GUEST: 91) VMXAssist (Mar 10 2006)
(XEN) (GUEST: 91) Memory size 64 MB
(XEN) (GUEST: 91) E820 map:
(XEN) (GUEST: 91) 0000000000000000 - 000000000009F800 (RAM)
(XEN) (GUEST: 91) 000000000009F800 - 00000000000A0000 (Reserved)
(XEN) (GUEST: 91) 00000000000A0000 - 00000000000C0000 (Type 16)
(XEN) (GUEST: 91) 00000000000F0000 - 0000000000100000 (Reserved)
(XEN) (GUEST: 91) 0000000000100000 - 0000000003FFE000 (RAM)
(XEN) (GUEST: 91) 0000000003FFF000 - 0000000004000000 (Type 17)
(XEN) (GUEST: 91) 0000000003FFE000 - 0000000003FFF000 (Type 18)
(XEN) (GUEST: 91) 0000000004000000 - 0000000004003000 (ACPI NVS)
(XEN) (GUEST: 91) 0000000004003000 - 000000000400D000 (ACPI Data)
(XEN) (GUEST: 91) 00000000FEC00000 - 0000000100000000 (Type 16)
(XEN) (GUEST: 91) 
(XEN) (GUEST: 91) Start BIOS ...
(XEN) (GUEST: 91) Starting emulated 16-bit real-mode: ip=F000:FFF0
(XEN) (GUEST: 91)  rombios.c,v 1.138 2005/05/07 15:55:26 vruppert Exp $
(XEN) HVM_PIT: guest freq in cycles=150134573
(XEN) (GUEST: 91) Remapping master: ICW2 0x8 -> 0x20
(XEN) (GUEST: 91) Remapping slave: ICW2 0x70 -> 0x28
(XEN) (GUEST: 91) VGABios $Id: vgabios.c,v 1.61 2005/05/24 16:50:50 vruppert Exp $
(XEN) (GUEST: 91) HVMAssist BIOS, 1 cpu, $Revision: 1.138 $ $Date: 2005/05/07 15:55:26 $
(XEN) (GUEST: 91) 
(XEN) (GUEST: 91) ata0-0: PCHS=64/8/32 translation=none LCHS=64/8/32
(XEN) (GUEST: 91) ata0 master: QEMU HARDDISK ATA-2 Hard-Disk (8 MBytes)
(XEN) (GUEST: 91) ata0  slave: Unknown device
(XEN) (GUEST: 91) ata1 master: QEMU CD-ROM ATAPI-4 CD-Rom/DVD-Rom
(XEN) (GUEST: 91) ata1  slave: Unknown device
(XEN) (GUEST: 91) 
(XEN) (GUEST: 91) Booting from Hard Disk...
(XEN) (GUEST: 92) HVM Loader
(XEN) (GUEST: 92) Loading ROMBIOS ...
(XEN) (GUEST: 92) Loading Cirrus VGABIOS ...
(XEN) (GUEST: 92) Loading VMXAssist ...
(XEN) (GUEST: 92) VMX go ...
(XEN) (GUEST: 92) VMXAssist (Mar 10 2006)
(XEN) (GUEST: 92) Memory size 64 MB
(XEN) (GUEST: 92) E820 map:
(XEN) (GUEST: 92) 0000000000000000 - 000000000009F800 (RAM)
(XEN) (GUEST: 92) 000000000009F800 - 00000000000A0000 (Reserved)
(XEN) (GUEST: 92) 00000000000A0000 - 00000000000C0000 (Type 16)
(XEN) (GUEST: 92) 00000000000F0000 - 0000000000100000 (Reserved)
(XEN) (GUEST: 92) 0000000000100000 - 0000000003FFE000 (RAM)
(XEN) (GUEST: 92) 0000000003FFF000 - 0000000004000000 (Type 17)
(XEN) (GUEST: 92) 0000000003FFE000 - 0000000003FFF000 (Type 18)
(XEN) (GUEST: 92) 0000000004000000 - 0000000004003000 (ACPI NVS)
(XEN) (GUEST: 92) 0000000004003000 - 000000000400D000 (ACPI Data)
(XEN) (GUEST: 92) 00000000FEC00000 - 0000000100000000 (Type 16)
(XEN) (GUEST: 92) 
(XEN) (GUEST: 92) Start BIOS ...
(XEN) (GUEST: 92) Starting emulated 16-bit real-mode: ip=F000:FFF0
(XEN) (GUEST: 92)  rombios.c,v 1.138 2005/05/07 15:55:26 vruppert Exp $
(XEN) HVM_PIT: guest freq in cycles=150134573
(XEN) (GUEST: 92) Remapping master: ICW2 0x8 -> 0x20
(XEN) (GUEST: 92) Remapping slave: ICW2 0x70 -> 0x28
(XEN) (GUEST: 92) VGABios $Id: vgabios.c,v 1.61 2005/05/24 16:50:50 vruppert Exp $
(XEN) (GUEST: 92) HVMAssist BIOS, 1 cpu, $Revision: 1.138 $ $Date: 2005/05/07 15:55:26 $
(XEN) (GUEST: 92) 
(XEN) (GUEST: 92) ata0-0: PCHS=64/8/32 translation=none LCHS=64/8/32
(XEN) (GUEST: 92) ata0 master: QEMU HARDDISK ATA-2 Hard-Disk (8 MBytes)
(XEN) (GUEST: 92) ata0  slave: Unknown device
(XEN) (GUEST: 92) ata1 master: QEMU CD-ROM ATAPI-4 CD-Rom/DVD-Rom
(XEN) (GUEST: 92) ata1  slave: Unknown device
(XEN) (GUEST: 92) 
(XEN) (GUEST: 92) Booting from Hard Disk...

PASS: 01_dmesg_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   422.7
*** Finished cleaning domUs
*** Test 02_dmesg_basic_neg started at Fri Mar 10 11:19:10 2006 CDT
[dom0] Running `xm dmesg -x'
Error: 'xm dmesg' requires 0 argument.

   dmesg [-c|--clear]               Read or clear Xen's message buffer
PASS: 02_dmesg_basic_neg.test
==================
All 2 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/dmesg'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/dmesg'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/dmesg'
Making check in domid
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domid'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domid'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domid'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   423.1
*** Finished cleaning domUs
*** Test 01_domid_basic_pos started at Fri Mar 10 11:19:11 2006 CDT
[dom0] Running `xm domid Domain-0'
0
PASS: 01_domid_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   423.4
*** Finished cleaning domUs
*** Test 02_domid_basic_neg started at Fri Mar 10 11:19:11 2006 CDT
[dom0] Running `xm domid non_existent_domain'
Error: Domain 'non_existent_domain' not found when running 'xm domid'
PASS: 02_domid_basic_neg.test
==================
All 2 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domid'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domid'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domid'
Making check in domname
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domname'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domname'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domname'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   423.8
*** Finished cleaning domUs
*** Test 01_domname_basic_pos started at Fri Mar 10 11:19:11 2006 CDT
[dom0] Running `xm domname 0'
Domain-0
PASS: 01_domname_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   424.1
*** Finished cleaning domUs
*** Test 02_domname_basic_neg started at Fri Mar 10 11:19:12 2006 CDT
[dom0] Running `xm domname 1492'
Error: Domain '1492' not found when running 'xm domname'
PASS: 02_domname_basic_neg.test
==================
All 2 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domname'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domname'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/domname'
Making check in help
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/help'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/help'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/help'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   424.5
*** Finished cleaning domUs
*** Test 01_help_basic_pos started at Fri Mar 10 11:19:12 2006 CDT
[dom0] Running `xm help'
Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm common subcommands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   help                             Display this message
   list [--long] [DomId, ...]       List information about domains
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-set <DomId> <VCPUs>         Set the number of VCPUs for a domain

<DomName> can be substituted for <DomId> in xm subcommands.

For a complete list of subcommands run 'xm help --long'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 01_help_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   424.8
*** Finished cleaning domUs
*** Test 02_help_basic_neg started at Fri Mar 10 11:19:12 2006 CDT
[dom0] Running `xm'
Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm common subcommands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   help                             Display this message
   list [--long] [DomId, ...]       List information about domains
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-set <DomId> <VCPUs>         Set the number of VCPUs for a domain

<DomName> can be substituted for <DomId> in xm subcommands.

For a complete list of subcommands run 'xm help --long'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 02_help_basic_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   425.1
*** Finished cleaning domUs
*** Test 03_help_badparm_neg started at Fri Mar 10 11:19:13 2006 CDT
[dom0] Running `xm -x'
Error: Sub Command -x not found!
Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm common subcommands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   help                             Display this message
   list [--long] [DomId, ...]       List information about domains
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-set <DomId> <VCPUs>         Set the number of VCPUs for a domain

<DomName> can be substituted for <DomId> in xm subcommands.

For a complete list of subcommands run 'xm help --long'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 03_help_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   425.4
*** Finished cleaning domUs
*** Test 04_help_long_pos started at Fri Mar 10 11:19:13 2006 CDT
[dom0] Running `xm help --long'
   Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm full list of subcommands:

  Domain Commands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   domid <DomName>                  Converts a domain name to a domain id
   domname <DomId>                  Convert a domain id to a domain name
   list [--long] [DomId, ...]       List information about domains
   mem-max <DomId> <Mem>            Set maximum memory reservation for a domain
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   rename <DomId> <New Name>        Rename a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   sysrq   <DomId> <letter>         Send a sysrq to a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-list <DomId>                List the VCPUs for a domain (or all domains)
   vcpu-pin <DomId> <VCPU> <CPUs>   Set which cpus a VCPU can use
   vcpu-set <DomId> <VCPUs>         Set the number of VCPUs for a domain

  Xen Host Commands:
   dmesg [-c|--clear]               Read or clear Xen's message buffer
   info                             Get information about the xen host
   log                              Print the xend log
   top                              Monitor system and domains in real-time

  Scheduler Commands:
   sched-bvt <Parameters>           Set Borrowed Virtual Time scheduler
                                    parameters
   sched-bvt-ctxallow <Allow>       Set the BVT scheduler context switch
                                    allowance
   sched-sedf [DOM] [OPTIONS]       Show|Set simple EDF parameters
              -p, --period          Relative deadline(ns).
              -s, --slice           Worst-case execution time(ns) (slice < period).
              -l, --latency         scaled period(ns) in case the domain is doing
                                    heavy I/O.
              -e, --extra           flag (0/1) which controls whether the
                                    domain can run in extra-time
              -w, --weight          mutually exclusive with period/slice and
                                    specifies another way of setting a domain's
                                    cpu period/slice.

  Virtual Device Commands:
   block-attach <DomId> <BackDev> <FrontDev> <Mode>
                [BackDomId]         Create a new virtual block device
   block-detach  <DomId> <DevId>    Destroy a domain's virtual block device,
                                    where <DevId> may either be the device ID
                                    or the device name as mounted in the guest
   block-list <DomId> [--long]      List virtual block devices for a domain
   network-attach  <DomID> [script=<script>] [ip=<ip>] [mac=<mac>]
                           [bridge=<bridge>] [backend=<backDomID>]
                                    Create a new virtual network device 
   network-detach  <DomId> <DevId>  Destroy a domain's virtual network
                                    device, where <DevId> is the device ID.
   network-list <DomId> [--long]    List virtual network interfaces for a domain
   vtpm-list <DomId> [--long]       list virtual TPM devices

  Vnet commands:
   vnet-list [-l|--long]            list vnets
   vnet-create <config>             create a vnet from a config file
   vnet-delete <vnetid>             delete a vnet

<DomName> can be substituted for <DomId> in xm subcommands.

For a short list of subcommands run 'xm help'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 04_help_long_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   425.7
*** Finished cleaning domUs
*** Test 05_help_nonroot_pos started at Fri Mar 10 11:19:13 2006 CDT
[dom0] Running `xm help'
Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm common subcommands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   help                             Display this message
   list [--long] [DomId, ...]       List information about domains
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-set <DomId> <VCPUs>         Set the number of VCPUs for a domain

<DomName> can be substituted for <DomId> in xm subcommands.

For a complete list of subcommands run 'xm help --long'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 05_help_nonroot_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   426.0
*** Finished cleaning domUs
*** Test 06_help_allcmds started at Fri Mar 10 11:19:14 2006 CDT
[dom0] Running `xm help --long'
   Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm full list of subcommands:

  Domain Commands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   domid <DomName>                  Converts a domain name to a domain id
   domname <DomId>                  Convert a domain id to a domain name
   list [--long] [DomId, ...]       List information about domains
   mem-max <DomId> <Mem>            Set maximum memory reservation for a domain
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   rename <DomId> <New Name>        Rename a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   sysrq   <DomId> <letter>         Send a sysrq to a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-list <DomId>                List the VCPUs for a domain (or all domains)
   vcpu-pin <DomId> <VCPU> <CPUs>   Set which cpus a VCPU can use
   vcpu-set <DomId> <VCPUs>         Set the number of VCPUs for a domain

  Xen Host Commands:
   dmesg [-c|--clear]               Read or clear Xen's message buffer
   info                             Get information about the xen host
   log                              Print the xend log
   top                              Monitor system and domains in real-time

  Scheduler Commands:
   sched-bvt <Parameters>           Set Borrowed Virtual Time scheduler
                                    parameters
   sched-bvt-ctxallow <Allow>       Set the BVT scheduler context switch
                                    allowance
   sched-sedf [DOM] [OPTIONS]       Show|Set simple EDF parameters
              -p, --period          Relative deadline(ns).
              -s, --slice           Worst-case execution time(ns) (slice < period).
              -l, --latency         scaled period(ns) in case the domain is doing
                                    heavy I/O.
              -e, --extra           flag (0/1) which controls whether the
                                    domain can run in extra-time
              -w, --weight          mutually exclusive with period/slice and
                                    specifies another way of setting a domain's
                                    cpu period/slice.

  Virtual Device Commands:
   block-attach <DomId> <BackDev> <FrontDev> <Mode>
                [BackDomId]         Create a new virtual block device
   block-detach  <DomId> <DevId>    Destroy a domain's virtual block device,
                                    where <DevId> may either be the device ID
                                    or the device name as mounted in the guest
   block-list <DomId> [--long]      List virtual block devices for a domain
   network-attach  <DomID> [script=<script>] [ip=<ip>] [mac=<mac>]
                           [bridge=<bridge>] [backend=<backDomID>]
                                    Create a new virtual network device 
   network-detach  <DomId> <DevId>  Destroy a domain's virtual network
                                    device, where <DevId> is the device ID.
   network-list <DomId> [--long]    List virtual network interfaces for a domain
   vtpm-list <DomId> [--long]       list virtual TPM devices

  Vnet commands:
   vnet-list [-l|--long]            list vnets
   vnet-create <config>             create a vnet from a config file
   vnet-delete <vnetid>             delete a vnet

<DomName> can be substituted for <DomId> in xm subcommands.

For a short list of subcommands run 'xm help'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 06_help_allcmds.test
==================
All 6 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/help'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/help'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/help'
Making check in info
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/info'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/info'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/info'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   426.3
*** Finished cleaning domUs
*** Test 01_info_basic_pos started at Fri Mar 10 11:19:14 2006 CDT
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
PASS: 01_info_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   426.6
*** Finished cleaning domUs
*** Test 02_info_compiledata_pos started at Fri Mar 10 11:19:14 2006 CDT
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
PASS: 02_info_compiledata_pos.test
==================
All 2 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/info'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/info'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/info'
Making check in list
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/list'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/list'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/list'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   427.1
*** Finished cleaning domUs
*** Test 01_list_basic_pos started at Fri Mar 10 11:19:15 2006 CDT
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   427.4
PASS: 01_list_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   427.7
*** Finished cleaning domUs
*** Test 02_list_badparm_neg started at Fri Mar 10 11:19:15 2006 CDT
[dom0] Running `xm list -x'
Error: option -x not recognized
PASS: 02_list_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   428.0
*** Finished cleaning domUs
*** Test 03_list_nonexist_neg started at Fri Mar 10 11:19:16 2006 CDT
[dom0] Running `xm list 6666'
Error: Domain '6666' not found when running 'xm list'
PASS: 03_list_nonexist_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   428.3
*** Finished cleaning domUs
*** Test 04_list_goodparm_pos started at Fri Mar 10 11:19:16 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 04_list_goodparm_pos-1142011156
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '04_list_goodparm_pos-1142011156']
[dom0] Running `xm list 04_list_goodparm_pos-1142011156'
Name                              ID Mem(MiB) VCPUs State  Time(s)
04_list_goodparm_pos-1142011156   93       64     1 -b----     4.9
[dom0] Running `xm shutdown 04_list_goodparm_pos-1142011156'

PASS: 04_list_goodparm_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   435.3
*** Finished cleaning domUs
*** Test 05_list_long_pos started at Fri Mar 10 11:19:41 2006 CDT
[dom0] Running `xm list --long'
(domain
    (domid 0)
    (uuid 00000000-0000-0000-0000-000000000000)
    (ssidref 0)
    (vcpus 16)
    (vcpu_avail 65535)
    (cpu_weight 1.0)
    (memory 495)
    (maxmem 495)
    (name Domain-0)
    (on_poweroff destroy)
    (on_reboot restart)
    (on_crash restart)
    (state r-----)
    (shutdown_reason poweroff)
    (cpu_time 435.50568834)
    (online_vcpus 1)
)
PASS: 05_list_long_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   435.7
*** Finished cleaning domUs
*** Test 06_list_nonroot started at Fri Mar 10 11:19:41 2006 CDT
[dom0] Running `xm list'
Error: Most commands need root access.  Please try again as root.
PASS: 06_list_nonroot.test
==================
All 6 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/list'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/list'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/list'
Making check in memmax
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memmax'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memmax'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memmax'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   436.1
*** Finished cleaning domUs
*** Test 01_memmax_badparm_neg started at Fri Mar 10 11:19:41 2006 CDT

REASON: Mem-max not supported for HVM domains
SKIP: 01_memmax_badparm_neg.test
======================
All 0 tests passed
(1 tests were not run)
======================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memmax'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memmax'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memmax'
Making check in memset
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memset'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memset'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memset'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   436.3
*** Finished cleaning domUs
*** Test 01_memset_basic_pos started at Fri Mar 10 11:19:42 2006 CDT

REASON: Mem-set not supported for HVM domains
SKIP: 01_memset_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   436.5
*** Finished cleaning domUs
*** Test 02_memset_badparm_neg started at Fri Mar 10 11:19:42 2006 CDT

REASON: Mem-set not supported for HVM domains
SKIP: 02_memset_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   436.7
*** Finished cleaning domUs
*** Test 03_memset_random_pos started at Fri Mar 10 11:19:42 2006 CDT

REASON: Mem-set not supported for HVM domains
SKIP: 03_memset_random_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   436.9
*** Finished cleaning domUs
*** Test 04_memset_smallmem_pos started at Fri Mar 10 11:19:42 2006 CDT

REASON: Mem-set not supported for HVM domains
SKIP: 04_memset_smallmem_pos.test
======================
All 0 tests passed
(4 tests were not run)
======================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memset'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memset'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/memset'
Making check in network
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network'
cp 03_network_local_tcp_pos.py 03_network_local_tcp_pos.test
chmod +x 03_network_local_tcp_pos.test
cp 04_network_local_udp_pos.py 04_network_local_udp_pos.test
chmod +x 04_network_local_udp_pos.test
cp 06_network_dom0_tcp_pos.py 06_network_dom0_tcp_pos.test
chmod +x 06_network_dom0_tcp_pos.test
cp 07_network_dom0_udp_pos.py 07_network_dom0_udp_pos.test
chmod +x 07_network_dom0_udp_pos.test
cp 12_network_domU_tcp_pos.py 12_network_domU_tcp_pos.test
chmod +x 12_network_domU_tcp_pos.test
cp 13_network_domU_udp_pos.py 13_network_domU_udp_pos.test
chmod +x 13_network_domU_udp_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   437.2
*** Finished cleaning domUs
*** Test 02_network_local_ping_pos started at Fri Mar 10 11:19:42 2006 CDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 02_network_local_ping_pos-1142011183
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '02_network_local_ping_pos-1142011183']
[02_network_local_ping_pos-1142011183] Sending `bhs'
[02_network_local_ping_pos-1142011183] Sending `ifconfig lo 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ifconfig eth0 inet 169.254.223.2 netmask 255.255.255.240 up'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 1 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 48 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 64 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 512 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 1440 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 1500 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 1505 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 4096 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 4192 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 32767 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 65507 127.0.0.1'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 1 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 48 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 64 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 512 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 1440 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 1500 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 1505 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 4096 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 4192 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 32767 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'
[02_network_local_ping_pos-1142011183] Sending `ping -q -c 1 -s 65507 169.254.223.2'
[02_network_local_ping_pos-1142011183] Sending `echo $?'

REASON: ping loopback failed for size 65507. ping eth0 failed for size 65507.
XFAIL: 02_network_local_ping_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   462.1
02_network_local_ping_pos-1142011183  94       64     1 -b----    12.5
[dom0] Running `xm destroy 02_network_local_ping_pos-1142011183'
*** Finished cleaning domUs
*** Test 03_network_local_tcp_pos started at Fri Mar 10 11:23:33 2006 CDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 03_network_local_tcp_pos-1142011413
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '03_network_local_tcp_pos-1142011413']
[03_network_local_tcp_pos-1142011413] Sending `bhs'
[03_network_local_tcp_pos-1142011413] Sending `ifconfig lo 127.0.0.1'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `ifconfig eth0 inet 169.254.86.2 netmask 255.255.255.240 up'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 1'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 48'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 64'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 512'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 1440'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 1448'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 1500'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 1505'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 4096'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 4192'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 32767'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 127.0.0.1 -E /dev/urandom -q -c 20 --fast -d 65495'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 1'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 48'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 64'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 512'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 1440'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 1448'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 1500'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 1505'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 4096'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 4192'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 32767'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
[03_network_local_tcp_pos-1142011413] Sending `hping2 169.254.86.2 -E /dev/urandom -q -c 20 --fast -d 65495'
[03_network_local_tcp_pos-1142011413] Sending `echo $?'
PASS: 03_network_local_tcp_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   493.4
03_network_local_tcp_pos-1142011413  95       64     1 -b----    15.9
[dom0] Running `xm destroy 03_network_local_tcp_pos-1142011413'
*** Finished cleaning domUs
*** Test 04_network_local_udp_pos started at Fri Mar 10 11:28:28 2006 CDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 04_network_local_udp_pos-1142011709
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '04_network_local_udp_pos-1142011709']
[04_network_local_udp_pos-1142011709] Sending `bhs'
[04_network_local_udp_pos-1142011709] Sending `ifconfig lo 127.0.0.1'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `ifconfig eth0 inet 169.254.68.2 netmask 255.255.255.240 up'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 1'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 48'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 64'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 512'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 1440'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 1448'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 1500'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 1505'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 4096'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 4192'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 32767'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 --fast -d 65495'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 1'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 48'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 64'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 512'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 1440'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 1448'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 1500'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 1505'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 4096'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 4192'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 32767'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
[04_network_local_udp_pos-1142011709] Sending `hping2 169.254.68.2 -E /dev/urandom -2 -q -c 20 --fast -d 65495'
[04_network_local_udp_pos-1142011709] Sending `echo $?'
PASS: 04_network_local_udp_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   524.9
04_network_local_udp_pos-1142011709  96       64     1 -b----    16.0
[dom0] Running `xm destroy 04_network_local_udp_pos-1142011709'
*** Finished cleaning domUs
*** Test 05_network_dom0_ping_pos started at Fri Mar 10 11:33:28 2006 CDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 05_network_dom0_ping_pos-1142012008
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '05_network_dom0_ping_pos-1142012008']
[05_network_dom0_ping_pos-1142012008] Sending `bhs'
[dom0] Running `ip addr add 169.254.119.1 dev xenbr0'

[dom0] Running `ip route add 169.254.119.0/24 dev xenbr0 scope link'

[05_network_dom0_ping_pos-1142012008] Sending `ifconfig eth0 inet 169.254.119.2 netmask 255.255.255.240 up'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 1 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 48 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 64 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 512 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 1440 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 1500 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 1505 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 4096 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 4192 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 32767 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[05_network_dom0_ping_pos-1142012008] Sending `ping -q -c 1 -s 65507 169.254.119.1'
[05_network_dom0_ping_pos-1142012008] Sending `echo $?'
[dom0] Running `ip addr del 169.254.119.1 dev xenbr0'

XPASS: 05_network_dom0_ping_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   541.0
05_network_dom0_ping_pos-1142012008  97       64     1 -b----     8.7
[dom0] Running `xm destroy 05_network_dom0_ping_pos-1142012008'
*** Finished cleaning domUs
*** Test 06_network_dom0_tcp_pos started at Fri Mar 10 11:35:31 2006 CDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 06_network_dom0_tcp_pos-1142012131
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '06_network_dom0_tcp_pos-1142012131']
[06_network_dom0_tcp_pos-1142012131] Sending `bhs'
[dom0] Running `ip addr add 169.254.173.1 dev xenbr0'

[dom0] Running `ip route add 169.254.173.0/24 dev xenbr0 scope link'

[06_network_dom0_tcp_pos-1142012131] Sending `ifconfig eth0 inet 169.254.173.2 netmask 255.255.255.240 up'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 1'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 48'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 64'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 512'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 1440'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 1500'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 1505'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 4096'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 4192'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 32767'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[06_network_dom0_tcp_pos-1142012131] Sending `hping2 169.254.173.1 -E /dev/urandom -q -c 20 --fast -d 65495'
[06_network_dom0_tcp_pos-1142012131] Sending `echo $?'
[dom0] Running `ip addr del 169.254.173.1 dev xenbr0'

PASS: 06_network_dom0_tcp_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   560.9
06_network_dom0_tcp_pos-1142012131  98       64     1 -b----    10.5
[dom0] Running `xm destroy 06_network_dom0_tcp_pos-1142012131'
*** Finished cleaning domUs
*** Test 07_network_dom0_udp_pos started at Fri Mar 10 11:38:07 2006 CDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_network_dom0_udp_pos-1142012287
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_network_dom0_udp_pos-1142012287']
[07_network_dom0_udp_pos-1142012287] Sending `bhs'
[dom0] Running `ip addr add 169.254.203.1 dev xenbr0'

[dom0] Running `ip route add 169.254.203.0/24 dev xenbr0 scope link'

[07_network_dom0_udp_pos-1142012287] Sending `ifconfig eth0 inet 169.254.203.2 netmask 255.255.255.240 up'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 1'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 48'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 64'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 512'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 1440'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 1500'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 1505'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 4096'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 4192'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 32767'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[07_network_dom0_udp_pos-1142012287] Sending `hping2 169.254.203.1 -E /dev/urandom -2 -q -c 20 --fast -d 65495'
[07_network_dom0_udp_pos-1142012287] Sending `echo $?'
[dom0] Running `ip addr del 169.254.203.1 dev xenbr0'

PASS: 07_network_dom0_udp_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   581.7
07_network_dom0_udp_pos-1142012287  99       64     1 -b----    10.9
[dom0] Running `xm destroy 07_network_dom0_udp_pos-1142012287'
*** Finished cleaning domUs
*** Test 11_network_domU_ping_pos started at Fri Mar 10 11:40:57 2006 CDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_network_domU_ping_pos-1142012457
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_network_domU_ping_pos-1142012457']
[11_network_domU_ping_pos-1142012457] Sending `bhs'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Error: Device 768 (vbd) could not be connected.
File /usr/xen/xen-unstable.hg/tools/xm-test/ramdisk/disk.img is loopback-mounted through /dev/loop0,
which is mounted in a guest domain,
and so cannot be mounted now.
Failed to create test domain because:
Using config file "/tmp/xm-test.conf".
Error: Device 768 (vbd) could not be connected.
File /usr/xen/xen-unstable.hg/tools/xm-test/ramdisk/disk.img is loopback-mounted through /dev/loop0,
which is mounted in a guest domain,
and so cannot be mounted now.

REASON: Failed to create domain
XFAIL: 11_network_domU_ping_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   589.9
11_network_domU_ping_pos-1142012457 100       64     1 -b----     5.1
11_network_domU_ping_pos-1142012484 101       64     1 --p---     0.0
[dom0] Running `xm destroy 11_network_domU_ping_pos-1142012457'
[dom0] Running `xm destroy 11_network_domU_ping_pos-1142012484'
*** Finished cleaning domUs
*** Test 12_network_domU_tcp_pos started at Fri Mar 10 11:41:25 2006 CDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 12_network_domU_tcp_pos-1142012486
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '12_network_domU_tcp_pos-1142012486']
[12_network_domU_tcp_pos-1142012486] Sending `bhs'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Error: Device 768 (vbd) could not be connected.
File /usr/xen/xen-unstable.hg/tools/xm-test/ramdisk/disk.img is loopback-mounted through /dev/loop0,
which is mounted in a guest domain,
and so cannot be mounted now.
Failed to create test domain because:
Using config file "/tmp/xm-test.conf".
Error: Device 768 (vbd) could not be connected.
File /usr/xen/xen-unstable.hg/tools/xm-test/ramdisk/disk.img is loopback-mounted through /dev/loop0,
which is mounted in a guest domain,
and so cannot be mounted now.

REASON: Failed to create domain
FAIL: 12_network_domU_tcp_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   598.5
12_network_domU_tcp_pos-1142012486 102       64     1 -b----     5.1
12_network_domU_tcp_pos-1142012513 103       64     1 --p---     0.0
[dom0] Running `xm destroy 12_network_domU_tcp_pos-1142012486'
[dom0] Running `xm destroy 12_network_domU_tcp_pos-1142012513'
*** Finished cleaning domUs
*** Test 13_network_domU_udp_pos started at Fri Mar 10 11:41:54 2006 CDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_network_domU_udp_pos-1142012514
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_network_domU_udp_pos-1142012514']
[13_network_domU_udp_pos-1142012514] Sending `bhs'
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Error: Device 768 (vbd) could not be connected.
File /usr/xen/xen-unstable.hg/tools/xm-test/ramdisk/disk.img is loopback-mounted through /dev/loop0,
which is mounted in a guest domain,
and so cannot be mounted now.
Failed to create test domain because:
Using config file "/tmp/xm-test.conf".
Error: Device 768 (vbd) could not be connected.
File /usr/xen/xen-unstable.hg/tools/xm-test/ramdisk/disk.img is loopback-mounted through /dev/loop0,
which is mounted in a guest domain,
and so cannot be mounted now.

REASON: Failed to create domain
FAIL: 13_network_domU_udp_pos.test
=============================================================
3 of 9 tests did not behave as expected (1 unexpected passes)
=============================================================
make[4]: *** [check-TESTS] Error 1
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network'
make[3]: *** [check-am] Error 2
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network'
make[2]: *** [check-recursive] Error 1
make[2]: Target `check' not remade because of errors.
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network'
Making check in network-attach
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network-attach'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network-attach'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network-attach'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   607.3
13_network_domU_udp_pos-1142012514 104       64     1 -b----     5.1
13_network_domU_udp_pos-1142012541 105       64     1 --p---     0.0
[dom0] Running `xm destroy 13_network_domU_udp_pos-1142012514'
[dom0] Running `xm destroy 13_network_domU_udp_pos-1142012541'
*** Finished cleaning domUs
*** Test 01_network_attach_pos started at Fri Mar 10 11:42:23 2006 CDT

REASON: Network-attach not supported for HVM domains
SKIP: 01_network_attach_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   608.4
*** Finished cleaning domUs
*** Test 02_network_attach_detach_pos started at Fri Mar 10 11:42:24 2006 CDT

REASON: Network-attach not supported for HVM domains
SKIP: 02_network_attach_detach_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   608.6
*** Finished cleaning domUs
*** Test 03_network_attach_detach_multiple_pos started at Fri Mar 10 11:42:24 2006 CDT

REASON: Network-attach not supported for HVM domains
SKIP: 03_network_attach_detach_multiple_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   608.8
*** Finished cleaning domUs
*** Test 04_network_attach_baddomain_neg started at Fri Mar 10 11:42:24 2006 CDT
[dom0] Running `xm network-attach NOT-EXIST'
Error: Domain 'NOT-EXIST' not found when running 'xm network-attach'
PASS: 04_network_attach_baddomain_neg.test
======================
All 1 tests passed
(3 tests were not run)
======================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network-attach'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network-attach'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/network-attach'
Making check in pause
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/pause'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/pause'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/pause'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   609.2
*** Finished cleaning domUs
*** Test 01_pause_basic_pos started at Fri Mar 10 11:42:25 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_pause_basic_pos-1142012545
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_pause_basic_pos-1142012545']
[01_pause_basic_pos-1142012545] Sending `foo'
[01_pause_basic_pos-1142012545] Sending `ls'
[01_pause_basic_pos-1142012545] Sending `echo $?'
[dom0] Running `xm pause 01_pause_basic_pos-1142012545'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_pause_basic_pos-1142012545']
[01_pause_basic_pos-1142012545] Sending `ls'
[dom0] Running `xm unpause 01_pause_basic_pos-1142012545'

[dom0] Running `xm shutdown 01_pause_basic_pos-1142012545'

PASS: 01_pause_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   620.0
*** Finished cleaning domUs
*** Test 02_pause_badopt_neg started at Fri Mar 10 11:43:35 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 02_pause_badopt_neg-1142012615
[dom0] Waiting 20 seconds for domU boot...
[dom0] Running `xm pause -x 02_pause_badopt_neg-1142012615'
Error: 'xm pause' requires 1 argument.

   pause <DomId>                    Pause execution of a domain
[dom0] Running `xm destroy 02_pause_badopt_neg-1142012615'

PASS: 02_pause_badopt_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   626.5
*** Finished cleaning domUs
*** Test 03_pause_badname_neg started at Fri Mar 10 11:43:56 2006 CDT
[dom0] Running `xm pause NOT-EXIST'
Error: Domain 'NOT-EXIST' not found when running 'xm pause'
PASS: 03_pause_badname_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   626.8
*** Finished cleaning domUs
*** Test 04_pause_badid_neg started at Fri Mar 10 11:43:56 2006 CDT
[dom0] Running `xm pause 1246445'
Error: Domain '1246445' not found when running 'xm pause'
PASS: 04_pause_badid_neg.test
==================
All 4 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/pause'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/pause'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/pause'
Making check in reboot
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/reboot'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/reboot'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/reboot'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   627.2
*** Finished cleaning domUs
*** Test 01_reboot_basic_pos started at Fri Mar 10 11:43:57 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_reboot_basic_pos-1142012637
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_reboot_basic_pos-1142012637']
[dom0] Running `xm reboot 01_reboot_basic_pos-1142012637'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_reboot_basic_pos-1142012637']
[01_reboot_basic_pos-1142012637] Sending `input'
[01_reboot_basic_pos-1142012637] Sending `uptime'
[01_reboot_basic_pos-1142012637] Sending `echo $?'
[dom0] Running `xm destroy 01_reboot_basic_pos-1142012637'

PASS: 01_reboot_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   640.7
*** Finished cleaning domUs
*** Test 02_reboot_badopt_neg started at Fri Mar 10 11:44:49 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 02_reboot_badopt_neg-1142012689
[dom0] Waiting 20 seconds for domU boot...
[dom0] Running `xm reboot -x 02_reboot_badopt_neg-1142012689'
Error: option -x not recognized
[dom0] Running `xm destroy 02_reboot_badopt_neg-1142012689'

PASS: 02_reboot_badopt_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   653.9
*** Finished cleaning domUs
*** Test 03_reboot_badname_neg started at Fri Mar 10 11:45:11 2006 CDT
[dom0] Running `xm reboot NOT-EXIST'
Error: Domain 'NOT-EXIST' not found when running 'xm reboot'
PASS: 03_reboot_badname_neg.test
==================
All 3 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/reboot'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/reboot'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/reboot'
Making check in sedf
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sedf'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sedf'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sedf'
/bin/sh: line 1: ./01_sedf_period_slice_pos.py: Permission denied
FAIL: 01_sedf_period_slice_pos.py
/bin/sh: line 1: ./02_sedf_period_lower_neg.py: Permission denied
FAIL: 02_sedf_period_lower_neg.py
/bin/sh: line 1: ./03_sedf_slice_lower_neg.py: Permission denied
FAIL: 03_sedf_slice_lower_neg.py
/bin/sh: line 1: ./04_sedf_slice_upper_neg.py: Permission denied
FAIL: 04_sedf_slice_upper_neg.py
/bin/sh: line 1: ./05_sedf_extratime_pos.py: Permission denied
FAIL: 05_sedf_extratime_pos.py
/bin/sh: line 1: ./06_sedf_extratime_disable_neg.py: Permission denied
FAIL: 06_sedf_extratime_disable_neg.py
===================
6 of 6 tests failed
===================
make[4]: *** [check-TESTS] Error 1
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sedf'
make[3]: *** [check-am] Error 2
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sedf'
make[2]: *** [check-recursive] Error 1
make[2]: Target `check' not remade because of errors.
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sedf'
Making check in shutdown
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/shutdown'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/shutdown'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/shutdown'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   654.7
*** Finished cleaning domUs
*** Test 01_shutdown_basic_pos started at Fri Mar 10 11:45:12 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_shutdown_basic_pos-1142012712
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_shutdown_basic_pos-1142012712']
[01_shutdown_basic_pos-1142012712] Sending `foo'
[01_shutdown_basic_pos-1142012712] Sending `ls /bin'
[01_shutdown_basic_pos-1142012712] Sending `echo $?'
[dom0] Running `xm shutdown 01_shutdown_basic_pos-1142012712'

[dom0] Running `xm domid 01_shutdown_basic_pos-1142012712'
Error: Domain '01_shutdown_basic_pos-1142012712' not found when running 'xm domid'
PASS: 01_shutdown_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   670.8
*** Finished cleaning domUs
*** Test 02_shutdown_badparm_neg started at Fri Mar 10 11:45:57 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 02_shutdown_badparm_neg-1142012757
[dom0] Waiting 20 seconds for domU boot...
[dom0] Running `xm shutdown -x 02_shutdown_badparm_neg-1142012757'
Error: option -x not recognized
[dom0] Running `xm shutdown 02_shutdown_badparm_neg-1142012757'

PASS: 02_shutdown_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   679.9
*** Finished cleaning domUs
*** Test 03_shutdown_nonexist_neg started at Fri Mar 10 11:46:19 2006 CDT
[dom0] Running `xm shutdown 9999'
Error: Domain '9999' not found when running 'xm shutdown'
PASS: 03_shutdown_nonexist_neg.test
==================
All 3 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/shutdown'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/shutdown'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/shutdown'
Making check in sysrq
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sysrq'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sysrq'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sysrq'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   680.3
*** Finished cleaning domUs
*** Test 01_sysrq_basic_neg started at Fri Mar 10 11:46:20 2006 CDT

REASON: Sysrq not supported for HVM domains
SKIP: 01_sysrq_basic_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   680.5
*** Finished cleaning domUs
*** Test 02_sysrq_sync_pos started at Fri Mar 10 11:46:20 2006 CDT

REASON: Sysrq not supported for HVM domains
SKIP: 02_sysrq_sync_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   680.7
*** Finished cleaning domUs
*** Test 03_sysrq_withreboot_pos started at Fri Mar 10 11:46:20 2006 CDT

REASON: Sysrq not supported for HVM domains
SKIP: 03_sysrq_withreboot_pos.test
======================
All 0 tests passed
(3 tests were not run)
======================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sysrq'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sysrq'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/sysrq'
Making check in unpause
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/unpause'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/unpause'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/unpause'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   680.9
*** Finished cleaning domUs
*** Test 01_unpause_basic_pos started at Fri Mar 10 11:46:21 2006 CDT
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_unpause_basic_pos-1142012781
[dom0] Waiting 20 seconds for domU boot...
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_unpause_basic_pos-1142012781']
[01_unpause_basic_pos-1142012781] Sending `foo'
[01_unpause_basic_pos-1142012781] Sending `ls'
[01_unpause_basic_pos-1142012781] Sending `echo $?'
[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm pause 01_unpause_basic_pos-1142012781'

[dom0] Running `xm unpause 01_unpause_basic_pos-1142012781'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_unpause_basic_pos-1142012781']
[01_unpause_basic_pos-1142012781] Sending `ls'
[01_unpause_basic_pos-1142012781] Sending `echo $?'
[dom0] Running `xm shutdown 01_unpause_basic_pos-1142012781'

PASS: 01_unpause_basic_pos.test
==================
All 1 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/unpause'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/unpause'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/unpause'
Making check in vcpu-disable
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-disable'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-disable'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-disable'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   703.8
*** Finished cleaning domUs
*** Test 01_vcpu-disable_basic_pos started at Fri Mar 10 11:47:19 2006 CDT
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_vcpu-disable_basic_pos-1142012839
[dom0] Waiting 20 seconds for domU boot...
[dom0] Running `xm vcpu-set 01_vcpu-disable_basic_pos-1142012839 1'

[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       4.8  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-list'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       4.8  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
Domain-0                           0     0    0   r--     710.8  any cpu
Domain-0                           0     1    -   --p       0.0  any cpu
Domain-0                           0     2    -   --p       0.0  any cpu
Domain-0                           0     3    -   --p       0.0  any cpu
Domain-0                           0     4    -   --p       0.0  any cpu
Domain-0                           0     5    -   --p       0.0  any cpu
Domain-0                           0     6    -   --p       0.0  any cpu
Domain-0                           0     7    -   --p       0.0  any cpu
Domain-0                           0     8    -   --p       0.0  any cpu
Domain-0                           0     9    -   --p       0.0  any cpu
Domain-0                           0    10    -   --p       0.0  any cpu
Domain-0                           0    11    -   --p       0.0  any cpu
Domain-0                           0    12    -   --p       0.0  any cpu
Domain-0                           0    13    -   --p       0.0  any cpu
Domain-0                           0    14    -   --p       0.0  any cpu
Domain-0                           0    15    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-set 01_vcpu-disable_basic_pos-1142012839 2'

[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       4.9  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       4.9  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       4.9  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       5.0  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       5.0  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       5.1  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       5.1  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       5.1  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   -b-       5.2  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm vcpu-list 01_vcpu-disable_basic_pos-1142012839'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-disable_basic_pos-1142012839 114     0   15   r--       5.2  any cpu
01_vcpu-disable_basic_pos-1142012839 114     1    -   --p       0.0  any cpu
[dom0] Running `xm destroy 01_vcpu-disable_basic_pos-1142012839'

PASS: 01_vcpu-disable_basic_pos.test
==================
All 1 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-disable'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-disable'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-disable'
Making check in vcpu-pin
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-pin'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-pin'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-pin'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   714.2
*** Finished cleaning domUs
*** Test 01_vcpu-pin_basic_pos started at Fri Mar 10 11:47:53 2006 CDT
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_vcpu-pin_basic_pos-1142012873
[dom0] Waiting 20 seconds for domU boot...
[dom0] Running `xm vcpu-pin 01_vcpu-pin_basic_pos-1142012873 0 0'

[dom0] Running `xm vcpu-list 01_vcpu-pin_basic_pos-1142012873'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-pin_basic_pos-1142012873 115     0    0   ---       4.8  0
[dom0] Running `xm vcpu-pin 01_vcpu-pin_basic_pos-1142012873 0 1'

[dom0] Running `xm vcpu-list 01_vcpu-pin_basic_pos-1142012873'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
01_vcpu-pin_basic_pos-1142012873 115     0    1   r--       4.8  1
PASS: 01_vcpu-pin_basic_pos.test
==================
All 1 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-pin'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-pin'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vcpu-pin'
Making check in vtpm
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vtpm'
make[2]: *** No rule to make target `check'.
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/vtpm'
Making check in enforce_dom0_cpus
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/enforce_dom0_cpus'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/enforce_dom0_cpus'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/enforce_dom0_cpus'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   721.3
01_vcpu-pin_basic_pos-1142012873 115       64     1 -b----     4.8
[dom0] Running `xm destroy 01_vcpu-pin_basic_pos-1142012873'
*** Finished cleaning domUs
*** Test 01_enforce_dom0_cpus_basic_pos started at Fri Mar 10 11:48:15 2006 CDT
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `xm info'
system                 : Linux
host                   : vmxdom2
release                : 2.6.16-rc5-xen0
version                : #1 Fri Mar 10 10:28:14 CST 2006
machine                : x86_64
nr_cpus                : 16
nr_nodes               : 1
sockets_per_node       : 4
cores_per_socket       : 2
threads_per_core       : 2
cpu_mhz                : 3002
hw_caps                : bfebfbff:20000800:00000000:00000180:000065bd:00000000:00000001
total_memory           : 8192
free_memory            : 7579
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_64
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Mar 10 04:05:59 2006 +0100 9197:cc303cdf8809
cc_compiler            : gcc version 3.3.3 (SuSE Linux)
cc_compile_by          : root
cc_compile_domain      : ltc.austin.ibm.com
cc_compile_date        : Fri Mar 10 10:49:23 CST 2006
[dom0] Running `sed -e 's,dom0-cpus 0,dom0-cpus 1,' /etc/xen/xend-config.sxp > /tmp/xend-config.sxp'

*** Restarting xend ...
[dom0] Running `/etc/init.d/xend stop'

[dom0] Running `/etc/init.d/xend start'

[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
1
[dom0] Running `xm vcpu-list Domain-0'
Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity
Domain-0                           0     0    0   r--     722.8  any cpu
Domain-0                           0     1    -   --p       0.0  any cpu
Domain-0                           0     2    -   --p       0.0  any cpu
Domain-0                           0     3    -   --p       0.0  any cpu
Domain-0                           0     4    -   --p       0.0  any cpu
Domain-0                           0     5    -   --p       0.0  any cpu
Domain-0                           0     6    -   --p       0.0  any cpu
Domain-0                           0     7    -   --p       0.0  any cpu
Domain-0                           0     8    -   --p       0.0  any cpu
Domain-0                           0     9    -   --p       0.0  any cpu
Domain-0                           0    10    -   --p       0.0  any cpu
Domain-0                           0    11    -   --p       0.0  any cpu
Domain-0                           0    12    -   --p       0.0  any cpu
Domain-0                           0    13    -   --p       0.0  any cpu
Domain-0                           0    14    -   --p       0.0  any cpu
Domain-0                           0    15    -   --p       0.0  any cpu
*** Restarting xend ...
[dom0] Running `/etc/init.d/xend stop'

[dom0] Running `/etc/init.d/xend start'

PASS: 01_enforce_dom0_cpus_basic_pos.test
==================
All 1 tests passed
==================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/enforce_dom0_cpus'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/enforce_dom0_cpus'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/enforce_dom0_cpus'
Making check in save
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/save'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/save'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/save'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   724.2
*** Finished cleaning domUs
*** Test 01_save_basic_pos started at Fri Mar 10 11:48:20 2006 CDT

REASON: Save currently not supported for HVM domains
SKIP: 01_save_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   724.4
*** Finished cleaning domUs
*** Test 02_save_badparm_neg started at Fri Mar 10 11:48:20 2006 CDT

REASON: Save currently not supported for HVM domains
SKIP: 02_save_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   724.6
*** Finished cleaning domUs
*** Test 03_save_bogusfile_neg started at Fri Mar 10 11:48:20 2006 CDT

REASON: Save currently not supported for HVM domains
SKIP: 03_save_bogusfile_neg.test
======================
All 0 tests passed
(3 tests were not run)
======================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/save'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/save'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/save'
Making check in restore
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/restore'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/restore'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/restore'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   724.8
*** Finished cleaning domUs
*** Test 01_restore_basic_pos started at Fri Mar 10 11:48:21 2006 CDT

REASON: Restore currently not supported for HVM domains
SKIP: 01_restore_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   725.0
*** Finished cleaning domUs
*** Test 02_restore_badparm_neg started at Fri Mar 10 11:48:21 2006 CDT

REASON: Restore currently not supported for HVM domains
SKIP: 02_restore_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   725.2
*** Finished cleaning domUs
*** Test 03_restore_badfilename_neg started at Fri Mar 10 11:48:21 2006 CDT

REASON: Restore currently not supported for HVM domains
SKIP: 03_restore_badfilename_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   725.4
*** Finished cleaning domUs
*** Test 04_restore_withdevices_pos started at Fri Mar 10 11:48:21 2006 CDT

REASON: Restore currently not supported for HVM domains
SKIP: 04_restore_withdevices_pos.test
======================
All 0 tests passed
(4 tests were not run)
======================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/restore'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/restore'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/restore'
Making check in migrate
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/migrate'
make[3]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/migrate'
make  check-TESTS
make[4]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/migrate'
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0      495     1 r-----   725.7
*** Finished cleaning domUs
*** Test 01_migrate_localhost_pos started at Fri Mar 10 11:48:21 2006 CDT

REASON: Migrate currently not supported for HVM domains
SKIP: 01_migrate_localhost_pos.test
======================
All 0 tests passed
(1 tests were not run)
======================
make[4]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/migrate'
make[3]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/migrate'
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests/migrate'
make[2]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests'
make[2]: Nothing to be done for `check-am'.
make[2]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests'
make[1]: *** [check-recursive] Error 1
make[1]: Target `check' not remade because of errors.
make[1]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test/tests'
make[1]: Entering directory `/usr/xen/xen-unstable.hg/tools/xm-test'
make[1]: Nothing to be done for `check-am'.
make[1]: Leaving directory `/usr/xen/xen-unstable.hg/tools/xm-test'
make: *** [check-recursive] Error 1
make: Target `check' not remade because of errors.

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 3%]

* Daily Xen Builds
@ 2006-03-10 18:01  4% David F Barrera
  0 siblings, 0 replies; 200+ results
From: David F Barrera @ 2006-03-10 18:01 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1853 bytes --]

March 10, 2006,  using xen-unstable changeset:

changeset:   9197:cc303cdf8809
tag:         tip
user:        emellor@leeni.uk.xensource.com
date:        Fri Mar 10 04:05:59 2006 +0100
summary:     The attached patch cleans up the parsing
of /proc/xen/balloon that


x86_32 (no PAE support)

      * SLES 9 SP2 on IBM xSeries 235 (512MB RAM)
      * Builds and boots without problems
      * Able to create fully functional guest domains
      * Ran xm-test on all boxes

      ISSUES:  

x86_32 (PAE)

      * SLES 9 SP2 and FC4 on IBM xSeries 335s 
      * Builds and boots without problems
      * Able to create fully functional guest domains
      * Ran xm-test on all boxes

      ISSUES:
        * Bugzilla Bug 543    domU: BUG: soft lockup detected on CPU#1!

       
x86_64 (SLES 9 SP2 32-bit on IBM HS20 Blades 8843 41U)

      * Builds and boots without problems
      * Able to create fully functional guest domains
      * Ran xm-test on all boxes

      ISSUES: 
        * Bugzilla Bug 195 - Timer ISR/0: Time went backwards:       
        * Bugzilla Bug 552    xm-test FAIL 01_migrate_localhost_pos...
        * Bugzilla Bug 563    Unable to handle kernel NULL pointer
        dereference at 0000000000000000 RIP:
                
   
--XM-TEST Results--

SUMMARY:
            Platform | PASS | FAIL | XPASS | XFAIL |
---------------------+------+------+-------+-------+
 hs20.1.sles9-x86_64 |   98 |   17 |     0 |     3 |
hs20.rhel4-x86_32pae |  102 |   13 |     0 |     3 |
     x235sles9nonpae |  101 |   14 |     0 |     3 |
          x335fc4pae |  104 |   11 |     0 |     3 |
    x335sles9_pae4gb |  103 |   12 |     0 |     3 |

-- 
Regards,

David F Barrera
Linux Technology Center
Systems and Technology Group, IBM

"The wisest men follow their own direction. "
                                                        Euripides

[-- Attachment #2: hs20.1.sles9-x86_64.report --]
[-- Type: text/plain, Size: 1037 bytes --]

Xm-test execution summary:
  PASS:  98
  FAIL:  17
  XPASS: 0
  XFAIL: 3


Details:

 FAIL: 09_block_attach_and_dettach_device_check_data_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 05_block-destroy_byname_pos 
	 block device isn't attached; can't detach!

XFAIL: 02_network_local_ping_pos 
	 ping loopback failed for size 65507. ping eth0 failed for size 65507.

XFAIL: 05_network_dom0_ping_pos 
	 Ping to dom0 failed for size 65507.

XFAIL: 11_network_domU_ping_pos 
	 Ping failed for size 65507.

 FAIL:  
	Unknown reason

 FAIL: 01_restore_basic_pos 
	 Restored domain is dead (Timed out waiting for console)

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1

 FAIL: 01_migrate_localhost_pos 
	Unknown reason


[-- Attachment #3: hs20.rhel4-x86_32pae.report --]
[-- Type: text/plain, Size: 743 bytes --]

Xm-test execution summary:
  PASS:  102
  FAIL:  13
  XPASS: 0
  XFAIL: 3


Details:

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

XFAIL: 02_network_local_ping_pos 
	 ping loopback failed for size 65507. ping eth0 failed for size 65507.

XFAIL: 05_network_dom0_ping_pos 
	 Ping to dom0 failed for size 65507.

XFAIL: 11_network_domU_ping_pos 
	 Ping failed for size 65507.

 FAIL:  
	Unknown reason

 FAIL: 01_migrate_localhost_pos 
	 xm migrate returned invalid 256 != 0


[-- Attachment #4: x235sles9nonpae.report --]
[-- Type: text/plain, Size: 754 bytes --]

Xm-test execution summary:
  PASS:  101
  FAIL:  14
  XPASS: 0
  XFAIL: 3


Details:

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 02_block-destroy_rtblock_pos 
	 Failed to verify that block dev is attached

 FAIL: 14_create_blockroot_pos 
	 [Errno 5] Input/output error

XFAIL: 02_network_local_ping_pos 
	 ping loopback failed for size 65507. ping eth0 failed for size 65507.

XFAIL: 05_network_dom0_ping_pos 
	 Ping to dom0 failed for size 65507.

XFAIL: 11_network_domU_ping_pos 
	 Ping failed for size 65507.

 FAIL:  
	Unknown reason

 FAIL: 04_restore_withdevices_pos 
	 Unable to mount /dev/hda1


[-- Attachment #5: x335fc4pae.report --]
[-- Type: text/plain, Size: 542 bytes --]

Xm-test execution summary:
  PASS:  104
  FAIL:  11
  XPASS: 0
  XFAIL: 3


Details:

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

XFAIL: 02_network_local_ping_pos 
	 ping loopback failed for size 65507. ping eth0 failed for size 65507.

XFAIL: 05_network_dom0_ping_pos 
	 Ping to dom0 failed for size 65507.

XFAIL: 11_network_domU_ping_pos 
	 Ping failed for size 65507.

 FAIL:  
	Unknown reason


[-- Attachment #6: x335sles9_pae4gb.report --]
[-- Type: text/plain, Size: 670 bytes --]

Xm-test execution summary:
  PASS:  103
  FAIL:  12
  XPASS: 0
  XFAIL: 3


Details:

 FAIL: 05_block_attach_and_dettach_device_repeatedly_pos 
	 Failed to attach block device /proc/partitions does not show that!

 FAIL: 02_block-list_attachbd_pos 
	 Failed to verify that block dev is attached on DomainU

 FAIL: 03_block-list_anotherbd_pos 
	 Failed to verify that block dev is attached on DomainU

XFAIL: 02_network_local_ping_pos 
	 ping loopback failed for size 65507. ping eth0 failed for size 65507.

XFAIL: 05_network_dom0_ping_pos 
	 Ping to dom0 failed for size 65507.

XFAIL: 11_network_domU_ping_pos 
	 Ping failed for size 65507.

 FAIL:  
	Unknown reason


[-- Attachment #7: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 4%]

* [RFC PATCH 34/35] Add the Xen virtual network device driver.
  @ 2006-03-22  6:31  4% ` Chris Wright
  2006-03-22  8:59  0%   ` Arjan van de Ven
  0 siblings, 1 reply; 200+ results
From: Chris Wright @ 2006-03-22  6:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: xen-devel, virtualization, Ian Pratt, Christian Limpach

[-- Attachment #1: 33-netfront --]
[-- Type: text/plain, Size: 46336 bytes --]

The network device frontend driver allows the kernel to access network
devices exported exported by a virtual machine containing a physical
network device driver.

Signed-off-by: Ian Pratt <ian.pratt@xensource.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
 drivers/net/Kconfig             |    2 
 drivers/xen/Kconfig.net         |   14 
 drivers/xen/Makefile            |    3 
 drivers/xen/net_driver_util.c   |   57 +
 drivers/xen/netfront/Makefile   |    4 
 drivers/xen/netfront/netfront.c | 1500 ++++++++++++++++++++++++++++++++++++++++
 include/xen/net_driver_util.h   |   46 +
 7 files changed, 1626 insertions(+)

--- xen-subarch-2.6.orig/drivers/net/Kconfig
+++ xen-subarch-2.6/drivers/net/Kconfig
@@ -2326,6 +2326,8 @@ source "drivers/atm/Kconfig"
 
 source "drivers/s390/net/Kconfig"
 
+source "drivers/xen/Kconfig.net"
+
 config ISERIES_VETH
 	tristate "iSeries Virtual Ethernet driver support"
 	depends on PPC_ISERIES
--- xen-subarch-2.6.orig/drivers/xen/Makefile
+++ xen-subarch-2.6/drivers/xen/Makefile
@@ -1,5 +1,8 @@
 
+obj-y	+= net_driver_util.o
 obj-y	+= util.o
 
 obj-y	+= console/
 obj-y	+= xenbus/
+
+obj-$(CONFIG_XEN_NETDEV_FRONTEND)	+= netfront/
--- /dev/null
+++ xen-subarch-2.6/drivers/xen/Kconfig.net
@@ -0,0 +1,14 @@
+menu "Xen network device drivers"
+        depends on NETDEVICES && XEN
+
+config XEN_NETDEV_FRONTEND
+	tristate "Network-device frontend driver"
+	depends on XEN
+	default y
+	help
+	  The network-device frontend driver allows the kernel to access
+	  network interfaces within another guest OS. Unless you are building a
+	  dedicated device-driver domain, or your master control domain
+	  (domain 0), then you almost certainly want to say Y here.
+
+endmenu
--- /dev/null
+++ xen-subarch-2.6/drivers/xen/net_driver_util.c
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ *
+ * Utility functions for Xen network devices.
+ *
+ * Copyright (c) 2005 XenSource Ltd.
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following
+ * license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this source file (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.
+ */
+
+
+#include <linux/if_ether.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <xen/net_driver_util.h>
+
+
+int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
+{
+	char *s;
+	int i;
+	char *e;
+	char *macstr = xenbus_read(XBT_NULL, dev->nodename, "mac", NULL);
+	if (IS_ERR(macstr))
+		return PTR_ERR(macstr);
+	s = macstr;
+	for (i = 0; i < ETH_ALEN; i++) {
+		mac[i] = simple_strtoul(s, &e, 16);
+		if (s == e || (e[0] != ':' && e[0] != 0)) {
+			kfree(macstr);
+			return -ENOENT;
+		}
+		s = &e[1];
+	}
+	kfree(macstr);
+	return 0;
+}
+EXPORT_SYMBOL(xen_net_read_mac);
--- /dev/null
+++ xen-subarch-2.6/drivers/xen/netfront/Makefile
@@ -0,0 +1,4 @@
+
+obj-$(CONFIG_XEN_NETDEV_FRONTEND)	:= xennet.o
+
+xennet-objs := netfront.o
--- /dev/null
+++ xen-subarch-2.6/drivers/xen/netfront/netfront.c
@@ -0,0 +1,1500 @@
+/******************************************************************************
+ * Virtual network driver for conversing with remote driver backends.
+ * 
+ * Copyright (c) 2002-2005, K A Fraser
+ * Copyright (c) 2005, XenSource Ltd
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/netdevice.h>
+#include <linux/inetdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/init.h>
+#include <linux/bitops.h>
+#include <linux/proc_fs.h>
+#include <linux/ethtool.h>
+#include <linux/in.h>
+#include <net/sock.h>
+#include <net/pkt_sched.h>
+#include <net/arp.h>
+#include <net/route.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <xen/evtchn.h>
+#include <xen/xenbus.h>
+#include <xen/interface/io/netif.h>
+#include <xen/interface/memory.h>
+#ifdef CONFIG_XEN_BALLOON
+#include <xen/balloon.h>
+#endif
+#include <asm/page.h>
+#include <asm/uaccess.h>
+#include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
+#include <xen/net_driver_util.h>
+
+#define GRANT_INVALID_REF	0
+
+#define NET_TX_RING_SIZE __RING_SIZE((struct netif_tx_sring *)0, PAGE_SIZE)
+#define NET_RX_RING_SIZE __RING_SIZE((struct netif_rx_sring *)0, PAGE_SIZE)
+
+#ifndef __GFP_NOWARN
+#define __GFP_NOWARN 0
+#endif
+#define alloc_xen_skb(_l) __dev_alloc_skb((_l), GFP_ATOMIC|__GFP_NOWARN)
+
+#define init_skb_shinfo(_skb)                         \
+    do {                                              \
+        atomic_set(&(skb_shinfo(_skb)->dataref), 1);  \
+        skb_shinfo(_skb)->nr_frags = 0;               \
+        skb_shinfo(_skb)->frag_list = NULL;           \
+    } while (0)
+
+static unsigned long rx_pfn_array[NET_RX_RING_SIZE];
+static struct multicall_entry rx_mcl[NET_RX_RING_SIZE+1];
+static struct mmu_update rx_mmu[NET_RX_RING_SIZE];
+
+struct netfront_info
+{
+	struct list_head list;
+	struct net_device *netdev;
+
+	struct net_device_stats stats;
+	unsigned int tx_full;
+
+	struct netif_tx_front_ring tx;
+	struct netif_rx_front_ring rx;
+
+	spinlock_t   tx_lock;
+	spinlock_t   rx_lock;
+
+	unsigned int handle;
+	unsigned int evtchn, irq;
+
+	/* What is the status of our connection to the remote backend? */
+#define BEST_CLOSED       0
+#define BEST_DISCONNECTED 1
+#define BEST_CONNECTED    2
+	unsigned int backend_state;
+
+	/* Is this interface open or closed (down or up)? */
+#define UST_CLOSED        0
+#define UST_OPEN          1
+	unsigned int user_state;
+
+	/* Receive-ring batched refills. */
+#define RX_MIN_TARGET 8
+#define RX_DFL_MIN_TARGET 64
+#define RX_MAX_TARGET NET_RX_RING_SIZE
+	int rx_min_target, rx_max_target, rx_target;
+	struct sk_buff_head rx_batch;
+
+	struct timer_list rx_refill_timer;
+
+	/*
+	 * {tx,rx}_skbs store outstanding skbuffs. The first entry in each
+	 * array is an index into a chain of free entries.
+	 */
+	struct sk_buff *tx_skbs[NET_TX_RING_SIZE+1];
+	struct sk_buff *rx_skbs[NET_RX_RING_SIZE+1];
+
+	grant_ref_t gref_tx_head;
+	grant_ref_t grant_tx_ref[NET_TX_RING_SIZE + 1];
+	grant_ref_t gref_rx_head;
+	grant_ref_t grant_rx_ref[NET_TX_RING_SIZE + 1];
+
+	struct xenbus_device *xbdev;
+	int tx_ring_ref;
+	int rx_ring_ref;
+	u8 mac[ETH_ALEN];
+};
+
+/* Access macros for acquiring freeing slots in {tx,rx}_skbs[]. */
+#define ADD_ID_TO_FREELIST(_list, _id)			\
+	(_list)[(_id)] = (_list)[0];			\
+	(_list)[0]     = (void *)(unsigned long)(_id);
+#define GET_ID_FROM_FREELIST(_list)				\
+	({ unsigned long _id = (unsigned long)(_list)[0];	\
+	   (_list)[0]  = (_list)[_id];				\
+	   (unsigned short)_id; })
+
+#ifdef DEBUG
+static char *be_state_name[] = {
+	[BEST_CLOSED]       = "closed",
+	[BEST_DISCONNECTED] = "disconnected",
+	[BEST_CONNECTED]    = "connected",
+};
+#endif
+
+#define DPRINTK(fmt, args...) pr_debug("netfront (%s:%d) " fmt, \
+                                       __FUNCTION__, __LINE__, ##args)
+#define IPRINTK(fmt, args...)				\
+	printk(KERN_INFO "netfront: " fmt, ##args)
+#define WPRINTK(fmt, args...)				\
+	printk(KERN_WARNING "netfront: " fmt, ##args)
+
+
+static int talk_to_backend(struct xenbus_device *, struct netfront_info *);
+static int setup_device(struct xenbus_device *, struct netfront_info *);
+static int create_netdev(int, struct xenbus_device *, struct net_device **);
+
+static void netfront_closing(struct xenbus_device *);
+
+static void end_access(int, void *);
+static void netif_disconnect_backend(struct netfront_info *);
+static void close_netdev(struct netfront_info *);
+static void netif_free(struct netfront_info *);
+
+static void show_device(struct netfront_info *);
+
+static void network_connect(struct net_device *);
+static void network_tx_buf_gc(struct net_device *);
+static void network_alloc_rx_buffers(struct net_device *);
+static int send_fake_arp(struct net_device *);
+
+static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs);
+
+#if defined(CONFIG_PROC_FS) && defined(XEN_XENNET_PROC_INTERFACE)
+static int xennet_proc_init(void);
+static int xennet_proc_addif(struct net_device *dev);
+static void xennet_proc_delif(struct net_device *dev);
+#else
+#define xennet_proc_init()  (0)
+#define xennet_proc_addif(d) (0)
+#define xennet_proc_delif(d) ((void)0)
+#endif
+
+
+/**
+ * Entry point to this code when a new device is created.  Allocate the basic
+ * structures and the ring buffers for communication with the backend, and
+ * inform the backend of the appropriate details for those.  Switch to
+ * Connected state.
+ */
+static int netfront_probe(struct xenbus_device *dev,
+			  const struct xenbus_device_id *id)
+{
+	int err;
+	struct net_device *netdev;
+	struct netfront_info *info;
+	unsigned int handle;
+
+	err = xenbus_scanf(XBT_NULL, dev->nodename, "handle", "%u", &handle);
+	if (err != 1) {
+		xenbus_dev_fatal(dev, err, "reading handle");
+		return err;
+	}
+
+	err = create_netdev(handle, dev, &netdev);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "creating netdev");
+		return err;
+	}
+
+	info = netdev_priv(netdev);
+	dev->data = info;
+
+	err = talk_to_backend(dev, info);
+	if (err) {
+		kfree(info);
+		dev->data = NULL;
+		return err;
+	}
+
+	return 0;
+}
+
+
+/**
+ * We are reconnecting to the backend, due to a suspend/resume, or a backend
+ * driver restart.  We tear down our netif structure and recreate it, but
+ * leave the device-layer structures intact so that this is transparent to the
+ * rest of the kernel.
+ */
+static int netfront_resume(struct xenbus_device *dev)
+{
+	struct netfront_info *info = dev->data;
+
+	DPRINTK("%s\n", dev->nodename);
+
+	netif_disconnect_backend(info);
+	return talk_to_backend(dev, info);
+}
+
+
+/* Common code used when first setting up, and when resuming. */
+static int talk_to_backend(struct xenbus_device *dev,
+			   struct netfront_info *info)
+{
+	const char *message;
+	xenbus_transaction_t xbt;
+	int err;
+
+	err = xen_net_read_mac(dev, info->mac);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
+		goto out;
+	}
+
+	/* Create shared ring, alloc event channel. */
+	err = setup_device(dev, info);
+	if (err)
+		goto out;
+
+again:
+	err = xenbus_transaction_start(&xbt);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "starting transaction");
+		goto destroy_ring;
+	}
+
+	err = xenbus_printf(xbt, dev->nodename, "tx-ring-ref","%u",
+			    info->tx_ring_ref);
+	if (err) {
+		message = "writing tx ring-ref";
+		goto abort_transaction;
+	}
+	err = xenbus_printf(xbt, dev->nodename, "rx-ring-ref","%u",
+			    info->rx_ring_ref);
+	if (err) {
+		message = "writing rx ring-ref";
+		goto abort_transaction;
+	}
+	err = xenbus_printf(xbt, dev->nodename,
+			    "event-channel", "%u", info->evtchn);
+	if (err) {
+		message = "writing event-channel";
+		goto abort_transaction;
+	}
+
+	err = xenbus_printf(xbt, dev->nodename,
+			    "state", "%d", XenbusStateConnected);
+	if (err) {
+		message = "writing frontend XenbusStateConnected";
+		goto abort_transaction;
+	}
+
+	err = xenbus_transaction_end(xbt, 0);
+	if (err) {
+		if (err == -EAGAIN)
+			goto again;
+		xenbus_dev_fatal(dev, err, "completing transaction");
+		goto destroy_ring;
+	}
+
+	return 0;
+
+ abort_transaction:
+	xenbus_transaction_end(xbt, 1);
+	xenbus_dev_fatal(dev, err, "%s", message);
+ destroy_ring:
+	netif_free(info);
+ out:
+	return err;
+}
+
+
+static int setup_device(struct xenbus_device *dev, struct netfront_info *info)
+{
+	struct netif_tx_sring *txs;
+	struct netif_rx_sring *rxs;
+	int err;
+	struct net_device *netdev = info->netdev;
+
+	info->tx_ring_ref = GRANT_INVALID_REF;
+	info->rx_ring_ref = GRANT_INVALID_REF;
+	info->rx.sring = NULL;
+	info->tx.sring = NULL;
+	info->irq = 0;
+
+	txs = (struct netif_tx_sring *)get_zeroed_page(GFP_KERNEL);
+	if (!txs) {
+		err = -ENOMEM;
+		xenbus_dev_fatal(dev, err, "allocating tx ring page");
+		goto fail;
+	}
+	rxs = (struct netif_rx_sring *)get_zeroed_page(GFP_KERNEL);
+	if (!rxs) {
+		err = -ENOMEM;
+		xenbus_dev_fatal(dev, err, "allocating rx ring page");
+		free_page((unsigned long)txs);
+		goto fail;
+	}
+	info->backend_state = BEST_DISCONNECTED;
+
+	SHARED_RING_INIT(txs);
+	FRONT_RING_INIT(&info->tx, txs, PAGE_SIZE);
+
+	SHARED_RING_INIT(rxs);
+	FRONT_RING_INIT(&info->rx, rxs, PAGE_SIZE);
+
+	err = xenbus_grant_ring(dev, virt_to_mfn(txs));
+	if (err < 0)
+		goto fail;
+	info->tx_ring_ref = err;
+
+	err = xenbus_grant_ring(dev, virt_to_mfn(rxs));
+	if (err < 0)
+		goto fail;
+	info->rx_ring_ref = err;
+
+	err = xenbus_alloc_evtchn(dev, &info->evtchn);
+	if (err)
+		goto fail;
+
+	memcpy(netdev->dev_addr, info->mac, ETH_ALEN);
+	network_connect(netdev);
+	info->irq = bind_evtchn_to_irqhandler(
+		info->evtchn, netif_int, SA_SAMPLE_RANDOM, netdev->name,
+		netdev);
+	(void)send_fake_arp(netdev);
+	show_device(info);
+
+	return 0;
+
+ fail:
+	netif_free(info);
+	return err;
+}
+
+
+/**
+ * Callback received when the backend's state changes.
+ */
+static void backend_changed(struct xenbus_device *dev,
+			    XenbusState backend_state)
+{
+	DPRINTK("\n");
+
+	switch (backend_state) {
+	case XenbusStateInitialising:
+	case XenbusStateInitWait:
+	case XenbusStateInitialised:
+	case XenbusStateConnected:
+	case XenbusStateUnknown:
+	case XenbusStateClosed:
+		break;
+
+	case XenbusStateClosing:
+		netfront_closing(dev);
+		break;
+	}
+}
+
+
+/** Send a packet on a net device to encourage switches to learn the
+ * MAC. We send a fake ARP request.
+ *
+ * @param dev device
+ * @return 0 on success, error code otherwise
+ */
+static int send_fake_arp(struct net_device *dev)
+{
+	struct sk_buff *skb;
+	u32             src_ip, dst_ip;
+
+	dst_ip = INADDR_BROADCAST;
+	src_ip = inet_select_addr(dev, dst_ip, RT_SCOPE_LINK);
+
+	/* No IP? Then nothing to do. */
+	if (src_ip == 0)
+		return 0;
+
+	skb = arp_create(ARPOP_REPLY, ETH_P_ARP,
+			 dst_ip, dev, src_ip,
+			 /*dst_hw*/ NULL, /*src_hw*/ NULL,
+			 /*target_hw*/ dev->dev_addr);
+	if (skb == NULL)
+		return -ENOMEM;
+
+	return dev_queue_xmit(skb);
+}
+
+
+static int network_open(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+
+	memset(&np->stats, 0, sizeof(np->stats));
+
+	np->user_state = UST_OPEN;
+
+	network_alloc_rx_buffers(dev);
+	np->rx.sring->rsp_event = np->rx.rsp_cons + 1;
+
+	netif_start_queue(dev);
+
+	return 0;
+}
+
+static void network_tx_buf_gc(struct net_device *dev)
+{
+	RING_IDX i, prod;
+	unsigned short id;
+	struct netfront_info *np = netdev_priv(dev);
+	struct sk_buff *skb;
+
+	if (np->backend_state != BEST_CONNECTED)
+		return;
+
+	do {
+		prod = np->tx.sring->rsp_prod;
+		rmb(); /* Ensure we see responses up to 'rp'. */
+
+		for (i = np->tx.rsp_cons; i != prod; i++) {
+			id  = RING_GET_RESPONSE(&np->tx, i)->id;
+			skb = np->tx_skbs[id];
+			if (unlikely(gnttab_query_foreign_access(
+				np->grant_tx_ref[id]) != 0)) {
+				printk(KERN_ALERT "network_tx_buf_gc: warning "
+				       "-- grant still in use by backend "
+				       "domain.\n");
+				goto out;
+			}
+			gnttab_end_foreign_access_ref(
+				np->grant_tx_ref[id], GNTMAP_readonly);
+			gnttab_release_grant_reference(
+				&np->gref_tx_head, np->grant_tx_ref[id]);
+			np->grant_tx_ref[id] = GRANT_INVALID_REF;
+			ADD_ID_TO_FREELIST(np->tx_skbs, id);
+			dev_kfree_skb_irq(skb);
+		}
+
+		np->tx.rsp_cons = prod;
+
+		/*
+		 * Set a new event, then check for race with update of tx_cons.
+		 * Note that it is essential to schedule a callback, no matter
+		 * how few buffers are pending. Even if there is space in the
+		 * transmit ring, higher layers may be blocked because too much
+		 * data is outstanding: in such cases notification from Xen is
+		 * likely to be the only kick that we'll get.
+		 */
+		np->tx.sring->rsp_event =
+			prod + ((np->tx.sring->req_prod - prod) >> 1) + 1;
+		mb();
+	} while (prod != np->tx.sring->rsp_prod);
+
+ out:
+	if (np->tx_full &&
+	    ((np->tx.sring->req_prod - prod) < NET_TX_RING_SIZE)) {
+		np->tx_full = 0;
+		if (np->user_state == UST_OPEN)
+			netif_wake_queue(dev);
+	}
+}
+
+
+static void rx_refill_timeout(unsigned long data)
+{
+	struct net_device *dev = (struct net_device *)data;
+	netif_rx_schedule(dev);
+}
+
+
+static void network_alloc_rx_buffers(struct net_device *dev)
+{
+	unsigned short id;
+	struct netfront_info *np = netdev_priv(dev);
+	struct sk_buff *skb;
+	int i, batch_target;
+	RING_IDX req_prod = np->rx.req_prod_pvt;
+	struct xen_memory_reservation reservation;
+	grant_ref_t ref;
+
+	if (unlikely(np->backend_state != BEST_CONNECTED))
+		return;
+
+	/*
+	 * Allocate skbuffs greedily, even though we batch updates to the
+	 * receive ring. This creates a less bursty demand on the memory
+	 * allocator, so should reduce the chance of failed allocation requests
+	 * both for ourself and for other kernel subsystems.
+	 */
+	batch_target = np->rx_target - (req_prod - np->rx.rsp_cons);
+	for (i = skb_queue_len(&np->rx_batch); i < batch_target; i++) {
+		/*
+		 * Subtract dev_alloc_skb headroom (16 bytes) and shared info
+		 * tailroom then round down to SKB_DATA_ALIGN boundary.
+		 */
+		skb = alloc_xen_skb(
+			((PAGE_SIZE - sizeof(struct skb_shared_info)) &
+			 (-SKB_DATA_ALIGN(1))) - 16);
+		if (skb == NULL) {
+			/* Any skbuffs queued for refill? Force them out. */
+			if (i != 0)
+				goto refill;
+			/* Could not allocate any skbuffs. Try again later. */
+			mod_timer(&np->rx_refill_timer,
+				  jiffies + (HZ/10));
+			return;
+		}
+		__skb_queue_tail(&np->rx_batch, skb);
+	}
+
+	/* Is the batch large enough to be worthwhile? */
+	if (i < (np->rx_target/2))
+		return;
+
+	/* Adjust our fill target if we risked running out of buffers. */
+	if (((req_prod - np->rx.sring->rsp_prod) < (np->rx_target / 4)) &&
+	    ((np->rx_target *= 2) > np->rx_max_target))
+		np->rx_target = np->rx_max_target;
+
+ refill:
+	for (i = 0; ; i++) {
+		if ((skb = __skb_dequeue(&np->rx_batch)) == NULL)
+			break;
+
+		skb->dev = dev;
+
+		id = GET_ID_FROM_FREELIST(np->rx_skbs);
+
+		np->rx_skbs[id] = skb;
+
+		RING_GET_REQUEST(&np->rx, req_prod + i)->id = id;
+		ref = gnttab_claim_grant_reference(&np->gref_rx_head);
+		BUG_ON((signed short)ref < 0);
+		np->grant_rx_ref[id] = ref;
+		gnttab_grant_foreign_transfer_ref(ref,
+						  np->xbdev->otherend_id,
+						  __pa(skb->head) >> PAGE_SHIFT);
+		RING_GET_REQUEST(&np->rx, req_prod + i)->gref = ref;
+		rx_pfn_array[i] = virt_to_mfn(skb->head);
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+			/* Remove this page before passing back to Xen. */
+			set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT,
+					    INVALID_P2M_ENTRY);
+			MULTI_update_va_mapping(rx_mcl+i,
+						(unsigned long)skb->head,
+						__pte(0), 0);
+		}
+#endif
+	}
+
+#ifdef CONFIG_XEN_BALLOON
+	/* Tell the ballon driver what is going on. */
+	balloon_update_driver_allowance(i);
+#endif
+
+	reservation.extent_start = rx_pfn_array;
+	reservation.nr_extents   = i;
+	reservation.extent_order = 0;
+	reservation.address_bits = 0;
+	reservation.domid        = DOMID_SELF;
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+		/* After all PTEs have been zapped, flush the TLB. */
+		rx_mcl[i-1].args[MULTI_UVMFLAGS_INDEX] =
+			UVMF_TLB_FLUSH|UVMF_ALL;
+
+		/* Give away a batch of pages. */
+		rx_mcl[i].op = __HYPERVISOR_memory_op;
+		rx_mcl[i].args[0] = XENMEM_decrease_reservation;
+		rx_mcl[i].args[1] = (unsigned long)&reservation;
+
+		/* Zap PTEs and give away pages in one big multicall. */
+		(void)HYPERVISOR_multicall(rx_mcl, i+1);
+
+		/* Check return status of HYPERVISOR_memory_op(). */
+		if (unlikely(rx_mcl[i].result != i))
+			panic("Unable to reduce memory reservation\n");
+	} else
+#endif
+		if (HYPERVISOR_memory_op(XENMEM_decrease_reservation,
+					 &reservation) != i)
+			panic("Unable to reduce memory reservation\n");
+
+	/* Above is a suitable barrier to ensure backend will see requests. */
+	np->rx.req_prod_pvt = req_prod + i;
+	RING_PUSH_REQUESTS(&np->rx);
+}
+
+
+static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	unsigned short id;
+	struct netfront_info *np = netdev_priv(dev);
+	struct netif_tx_request *tx;
+	RING_IDX i;
+	grant_ref_t ref;
+	unsigned long mfn;
+	int notify;
+
+	if (unlikely(np->tx_full)) {
+		printk(KERN_ALERT "%s: full queue wasn't stopped!\n",
+		       dev->name);
+		netif_stop_queue(dev);
+		goto drop;
+	}
+
+	if (unlikely((((unsigned long)skb->data & ~PAGE_MASK) + skb->len) >=
+		     PAGE_SIZE)) {
+		struct sk_buff *nskb;
+		if (unlikely((nskb = alloc_xen_skb(skb->len)) == NULL))
+			goto drop;
+		skb_put(nskb, skb->len);
+		memcpy(nskb->data, skb->data, skb->len);
+		nskb->dev = skb->dev;
+		dev_kfree_skb(skb);
+		skb = nskb;
+	}
+
+	spin_lock_irq(&np->tx_lock);
+
+	if (np->backend_state != BEST_CONNECTED) {
+		spin_unlock_irq(&np->tx_lock);
+		goto drop;
+	}
+
+	i = np->tx.req_prod_pvt;
+
+	id = GET_ID_FROM_FREELIST(np->tx_skbs);
+	np->tx_skbs[id] = skb;
+
+	tx = RING_GET_REQUEST(&np->tx, i);
+
+	tx->id   = id;
+	ref = gnttab_claim_grant_reference(&np->gref_tx_head);
+	BUG_ON((signed short)ref < 0);
+	mfn = virt_to_mfn(skb->data);
+	gnttab_grant_foreign_access_ref(
+		ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);
+	tx->gref = np->grant_tx_ref[id] = ref;
+	tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
+	tx->size = skb->len;
+	tx->flags = (skb->ip_summed == CHECKSUM_HW) ? NETTXF_csum_blank : 0;
+
+	np->tx.req_prod_pvt = i + 1;
+	RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);
+	if (notify)
+		notify_remote_via_irq(np->irq);
+
+	network_tx_buf_gc(dev);
+
+	if (RING_FULL(&np->tx)) {
+		np->tx_full = 1;
+		netif_stop_queue(dev);
+	}
+
+	spin_unlock_irq(&np->tx_lock);
+
+	np->stats.tx_bytes += skb->len;
+	np->stats.tx_packets++;
+
+	return 0;
+
+ drop:
+	np->stats.tx_dropped++;
+	dev_kfree_skb(skb);
+	return 0;
+}
+
+static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs)
+{
+	struct net_device *dev = dev_id;
+	struct netfront_info *np = netdev_priv(dev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&np->tx_lock, flags);
+	network_tx_buf_gc(dev);
+	spin_unlock_irqrestore(&np->tx_lock, flags);
+
+	if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx) &&
+	    (np->user_state == UST_OPEN))
+		netif_rx_schedule(dev);
+
+	return IRQ_HANDLED;
+}
+
+
+static int netif_poll(struct net_device *dev, int *pbudget)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	struct sk_buff *skb, *nskb;
+	struct netif_rx_response *rx;
+	RING_IDX i, rp;
+	struct mmu_update *mmu = rx_mmu;
+	struct multicall_entry *mcl = rx_mcl;
+	int work_done, budget, more_to_do = 1;
+	struct sk_buff_head rxq;
+	unsigned long flags;
+	unsigned long mfn;
+	grant_ref_t ref;
+
+	spin_lock(&np->rx_lock);
+
+	if (np->backend_state != BEST_CONNECTED) {
+		spin_unlock(&np->rx_lock);
+		return 0;
+	}
+
+	skb_queue_head_init(&rxq);
+
+	if ((budget = *pbudget) > dev->quota)
+		budget = dev->quota;
+	rp = np->rx.sring->rsp_prod;
+	rmb(); /* Ensure we see queued responses up to 'rp'. */
+
+	for (i = np->rx.rsp_cons, work_done = 0;
+	     (i != rp) && (work_done < budget);
+	     i++, work_done++) {
+		rx = RING_GET_RESPONSE(&np->rx, i);
+
+		/*
+                 * This definitely indicates a bug, either in this driver or
+                 * in the backend driver. In future this should flag the bad
+                 * situation to the system controller to reboot the backed.
+                 */
+		if ((ref = np->grant_rx_ref[rx->id]) == GRANT_INVALID_REF) {
+			WPRINTK("Bad rx response id %d.\n", rx->id);
+			work_done--;
+			continue;
+		}
+
+		/* Memory pressure, insufficient buffer headroom, ... */
+		if ((mfn = gnttab_end_foreign_transfer_ref(ref)) == 0) {
+			if (net_ratelimit())
+				WPRINTK("Unfulfilled rx req (id=%d, st=%d).\n",
+					rx->id, rx->status);
+			RING_GET_REQUEST(&np->rx, np->rx.req_prod_pvt)->id =
+				rx->id;
+			RING_GET_REQUEST(&np->rx, np->rx.req_prod_pvt)->gref =
+				ref;
+			np->rx.req_prod_pvt++;
+			RING_PUSH_REQUESTS(&np->rx);
+			work_done--;
+			continue;
+		}
+
+		gnttab_release_grant_reference(&np->gref_rx_head, ref);
+		np->grant_rx_ref[rx->id] = GRANT_INVALID_REF;
+
+		skb = np->rx_skbs[rx->id];
+		ADD_ID_TO_FREELIST(np->rx_skbs, rx->id);
+
+		/* NB. We handle skb overflow later. */
+		skb->data = skb->head + rx->offset;
+		skb->len  = rx->status;
+		skb->tail = skb->data + skb->len;
+
+		if (rx->flags & NETRXF_csum_valid)
+			skb->ip_summed = CHECKSUM_UNNECESSARY;
+
+		np->stats.rx_packets++;
+		np->stats.rx_bytes += rx->status;
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+			/* Remap the page. */
+			MULTI_update_va_mapping(mcl, (unsigned long)skb->head,
+						pfn_pte_ma(mfn, PAGE_KERNEL),
+						0);
+			mcl++;
+			mmu->ptr = ((maddr_t)mfn << PAGE_SHIFT)
+				| MMU_MACHPHYS_UPDATE;
+			mmu->val = __pa(skb->head) >> PAGE_SHIFT;
+			mmu++;
+
+			set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT,
+					    mfn);
+		}
+#endif
+
+		__skb_queue_tail(&rxq, skb);
+	}
+
+#ifdef CONFIG_XEN_BALLOON
+	/* Some pages are no longer absent... */
+	balloon_update_driver_allowance(-work_done);
+#endif
+
+	/* Do all the remapping work, and M2P updates, in one big hypercall. */
+	if (likely((mcl - rx_mcl) != 0)) {
+		mcl->op = __HYPERVISOR_mmu_update;
+		mcl->args[0] = (unsigned long)rx_mmu;
+		mcl->args[1] = mmu - rx_mmu;
+		mcl->args[2] = 0;
+		mcl->args[3] = DOMID_SELF;
+		mcl++;
+		(void)HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl);
+	}
+
+	while ((skb = __skb_dequeue(&rxq)) != NULL) {
+		if (skb->len > (dev->mtu + ETH_HLEN + 4)) {
+			if (net_ratelimit())
+				printk(KERN_INFO "Received packet too big for "
+				       "MTU (%d > %d)\n",
+				       skb->len - ETH_HLEN - 4, dev->mtu);
+			skb->len  = 0;
+			skb->tail = skb->data;
+			init_skb_shinfo(skb);
+			dev_kfree_skb(skb);
+			continue;
+		}
+
+		/*
+		 * Enough room in skbuff for the data we were passed? Also,
+		 * Linux expects at least 16 bytes headroom in each rx buffer.
+		 */
+		if (unlikely(skb->tail > skb->end) ||
+		    unlikely((skb->data - skb->head) < 16)) {
+			if (net_ratelimit()) {
+				if (skb->tail > skb->end)
+					printk(KERN_INFO "Received packet "
+					       "is %zd bytes beyond tail.\n",
+					       skb->tail - skb->end);
+				else
+					printk(KERN_INFO "Received packet "
+					       "is %zd bytes before head.\n",
+					       16 - (skb->data - skb->head));
+			}
+
+			nskb = alloc_xen_skb(skb->len + 2);
+			if (nskb != NULL) {
+				skb_reserve(nskb, 2);
+				skb_put(nskb, skb->len);
+				memcpy(nskb->data, skb->data, skb->len);
+				nskb->dev = skb->dev;
+				nskb->ip_summed = skb->ip_summed;
+			}
+
+			/* Reinitialise and then destroy the old skbuff. */
+			skb->len  = 0;
+			skb->tail = skb->data;
+			init_skb_shinfo(skb);
+			dev_kfree_skb(skb);
+
+			/* Switch old for new, if we copied the buffer. */
+			if ((skb = nskb) == NULL)
+				continue;
+		}
+
+		/* Set the shinfo area, which is hidden behind the data. */
+		init_skb_shinfo(skb);
+		/* Ethernet work: Delayed to here as it peeks the header. */
+		skb->protocol = eth_type_trans(skb, dev);
+
+		/* Pass it up. */
+		netif_receive_skb(skb);
+		dev->last_rx = jiffies;
+	}
+
+	np->rx.rsp_cons = i;
+
+	/* If we get a callback with very few responses, reduce fill target. */
+	/* NB. Note exponential increase, linear decrease. */
+	if (((np->rx.req_prod_pvt - np->rx.sring->rsp_prod) >
+	     ((3*np->rx_target) / 4)) &&
+	    (--np->rx_target < np->rx_min_target))
+		np->rx_target = np->rx_min_target;
+
+	network_alloc_rx_buffers(dev);
+
+	*pbudget   -= work_done;
+	dev->quota -= work_done;
+
+	if (work_done < budget) {
+		local_irq_save(flags);
+
+		RING_FINAL_CHECK_FOR_RESPONSES(&np->rx, more_to_do);
+		if (!more_to_do)
+			__netif_rx_complete(dev);
+
+		local_irq_restore(flags);
+	}
+
+	spin_unlock(&np->rx_lock);
+
+	return more_to_do;
+}
+
+
+static int network_close(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	np->user_state = UST_CLOSED;
+	netif_stop_queue(np->netdev);
+	return 0;
+}
+
+
+static struct net_device_stats *network_get_stats(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	return &np->stats;
+}
+
+static void network_connect(struct net_device *dev)
+{
+	struct netfront_info *np;
+	int i, requeue_idx;
+	struct netif_tx_request *tx;
+	struct sk_buff *skb;
+
+	np = netdev_priv(dev);
+	spin_lock_irq(&np->tx_lock);
+	spin_lock(&np->rx_lock);
+
+	/* Recovery procedure: */
+
+	/* Step 1: Reinitialise variables. */
+	np->tx_full = 0;
+
+	/*
+	 * Step 2: Rebuild the RX and TX ring contents.
+	 * NB. We could just free the queued TX packets now but we hope
+	 * that sending them out might do some good.  We have to rebuild
+	 * the RX ring because some of our pages are currently flipped out
+	 * so we can't just free the RX skbs.
+	 * NB2. Freelist index entries are always going to be less than
+	 *  __PAGE_OFFSET, whereas pointers to skbs will always be equal or
+	 * greater than __PAGE_OFFSET: we use this property to distinguish
+	 * them.
+	 */
+
+	/*
+	 * Rebuild the TX buffer freelist and the TX ring itself.
+	 * NB. This reorders packets.  We could keep more private state
+	 * to avoid this but maybe it doesn't matter so much given the
+	 * interface has been down.
+	 */
+	for (requeue_idx = 0, i = 1; i <= NET_TX_RING_SIZE; i++) {
+		if ((unsigned long)np->tx_skbs[i] < __PAGE_OFFSET)
+			continue;
+
+		skb = np->tx_skbs[i];
+
+		tx = RING_GET_REQUEST(&np->tx, requeue_idx);
+		requeue_idx++;
+
+		tx->id = i;
+		gnttab_grant_foreign_access_ref(
+			np->grant_tx_ref[i], np->xbdev->otherend_id,
+			virt_to_mfn(np->tx_skbs[i]->data),
+			GNTMAP_readonly);
+		tx->gref = np->grant_tx_ref[i];
+		tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
+		tx->size = skb->len;
+		tx->flags = (skb->ip_summed == CHECKSUM_HW) ?
+			NETTXF_csum_blank : 0;
+
+		np->stats.tx_bytes += skb->len;
+		np->stats.tx_packets++;
+	}
+
+	np->tx.req_prod_pvt = requeue_idx;
+	RING_PUSH_REQUESTS(&np->tx);
+
+	/* Rebuild the RX buffer freelist and the RX ring itself. */
+	for (requeue_idx = 0, i = 1; i <= NET_RX_RING_SIZE; i++) {
+		if ((unsigned long)np->rx_skbs[i] < __PAGE_OFFSET)
+			continue;
+		gnttab_grant_foreign_transfer_ref(
+			np->grant_rx_ref[i], np->xbdev->otherend_id,
+			__pa(np->rx_skbs[i]->data) >> PAGE_SHIFT);
+		RING_GET_REQUEST(&np->rx, requeue_idx)->gref =
+			np->grant_rx_ref[i];
+		RING_GET_REQUEST(&np->rx, requeue_idx)->id = i;
+		requeue_idx++;
+	}
+
+	np->rx.req_prod_pvt = requeue_idx;
+	RING_PUSH_REQUESTS(&np->rx);
+
+	/*
+	 * Step 3: All public and private state should now be sane.  Get
+	 * ready to start sending and receiving packets and give the driver
+	 * domain a kick because we've probably just requeued some
+	 * packets.
+	 */
+	np->backend_state = BEST_CONNECTED;
+	notify_remote_via_irq(np->irq);
+	network_tx_buf_gc(dev);
+
+	if (np->user_state == UST_OPEN)
+		netif_start_queue(dev);
+
+	spin_unlock(&np->rx_lock);
+	spin_unlock_irq(&np->tx_lock);
+}
+
+static void show_device(struct netfront_info *np)
+{
+#ifdef DEBUG
+	if (np) {
+		IPRINTK("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\n",
+			np->handle,
+			be_state_name[np->backend_state],
+			np->user_state ? "open" : "closed",
+			np->evtchn,
+			np->tx,
+			np->rx);
+	} else
+		IPRINTK("<vif NULL>\n");
+#endif
+}
+
+static void netif_uninit(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	gnttab_free_grant_references(np->gref_tx_head);
+	gnttab_free_grant_references(np->gref_rx_head);
+}
+
+static struct ethtool_ops network_ethtool_ops =
+{
+	.get_tx_csum = ethtool_op_get_tx_csum,
+	.set_tx_csum = ethtool_op_set_tx_csum,
+};
+
+/** Create a network device.
+ * @param handle device handle
+ * @param val return parameter for created device
+ * @return 0 on success, error code otherwise
+ */
+static int create_netdev(int handle, struct xenbus_device *dev,
+			 struct net_device **val)
+{
+	int i, err = 0;
+	struct net_device *netdev = NULL;
+	struct netfront_info *np = NULL;
+
+	if ((netdev = alloc_etherdev(sizeof(struct netfront_info))) == NULL) {
+		printk(KERN_WARNING "%s> alloc_etherdev failed.\n",
+		       __FUNCTION__);
+		err = -ENOMEM;
+		goto exit;
+	}
+
+	np                = netdev_priv(netdev);
+	np->backend_state = BEST_CLOSED;
+	np->user_state    = UST_CLOSED;
+	np->handle        = handle;
+	np->xbdev         = dev;
+
+	spin_lock_init(&np->tx_lock);
+	spin_lock_init(&np->rx_lock);
+
+	skb_queue_head_init(&np->rx_batch);
+	np->rx_target     = RX_DFL_MIN_TARGET;
+	np->rx_min_target = RX_DFL_MIN_TARGET;
+	np->rx_max_target = RX_MAX_TARGET;
+
+	init_timer(&np->rx_refill_timer);
+	np->rx_refill_timer.data = (unsigned long)netdev;
+	np->rx_refill_timer.function = rx_refill_timeout;
+
+	/* Initialise {tx,rx}_skbs as a free chain containing every entry. */
+	for (i = 0; i <= NET_TX_RING_SIZE; i++) {
+		np->tx_skbs[i] = (void *)((unsigned long) i+1);
+		np->grant_tx_ref[i] = GRANT_INVALID_REF;
+	}
+
+	for (i = 0; i <= NET_RX_RING_SIZE; i++) {
+		np->rx_skbs[i] = (void *)((unsigned long) i+1);
+		np->grant_rx_ref[i] = GRANT_INVALID_REF;
+	}
+
+	/* A grant for every tx ring slot */
+	if (gnttab_alloc_grant_references(NET_TX_RING_SIZE,
+					  &np->gref_tx_head) < 0) {
+		printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n");
+		err = -ENOMEM;
+		goto exit;
+	}
+	/* A grant for every rx ring slot */
+	if (gnttab_alloc_grant_references(NET_RX_RING_SIZE,
+					  &np->gref_rx_head) < 0) {
+		printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
+		gnttab_free_grant_references(np->gref_tx_head);
+		err = -ENOMEM;
+		goto exit;
+	}
+
+	netdev->open            = network_open;
+	netdev->hard_start_xmit = network_start_xmit;
+	netdev->stop            = network_close;
+	netdev->get_stats       = network_get_stats;
+	netdev->poll            = netif_poll;
+	netdev->uninit          = netif_uninit;
+	netdev->weight          = 64;
+	netdev->features        = NETIF_F_IP_CSUM;
+
+	SET_ETHTOOL_OPS(netdev, &network_ethtool_ops);
+	SET_MODULE_OWNER(netdev);
+	SET_NETDEV_DEV(netdev, &dev->dev);
+
+	if ((err = register_netdev(netdev)) != 0) {
+		printk(KERN_WARNING "%s> register_netdev err=%d\n",
+		       __FUNCTION__, err);
+		goto exit_free_grefs;
+	}
+
+	if ((err = xennet_proc_addif(netdev)) != 0) {
+		unregister_netdev(netdev);
+		goto exit_free_grefs;
+	}
+
+	np->netdev = netdev;
+
+ exit:
+	if (err != 0)
+		kfree(netdev);
+	else if (val != NULL)
+		*val = netdev;
+	return err;
+
+ exit_free_grefs:
+	gnttab_free_grant_references(np->gref_tx_head);
+	gnttab_free_grant_references(np->gref_rx_head);
+	goto exit;
+}
+
+/*
+ * We use this notifier to send out a fake ARP reply to reset switches and
+ * router ARP caches when an IP interface is brought up on a VIF.
+ */
+static int
+inetdev_notify(struct notifier_block *this, unsigned long event, void *ptr)
+{
+	struct in_ifaddr  *ifa = (struct in_ifaddr *)ptr;
+	struct net_device *dev = ifa->ifa_dev->dev;
+
+	/* UP event and is it one of our devices? */
+	if (event == NETDEV_UP && dev->open == network_open)
+		(void)send_fake_arp(dev);
+
+	return NOTIFY_DONE;
+}
+
+
+/* ** Close down ** */
+
+
+/**
+ * Handle the change of state of the backend to Closing.  We must delete our
+ * device-layer structures now, to ensure that writes are flushed through to
+ * the backend.  Once is this done, we can switch to Closed in
+ * acknowledgement.
+ */
+static void netfront_closing(struct xenbus_device *dev)
+{
+	struct netfront_info *info = dev->data;
+
+	DPRINTK("netfront_closing: %s removed\n", dev->nodename);
+
+	close_netdev(info);
+
+	xenbus_switch_state(dev, XBT_NULL, XenbusStateClosed);
+}
+
+
+static int netfront_remove(struct xenbus_device *dev)
+{
+	struct netfront_info *info = dev->data;
+
+	DPRINTK("%s\n", dev->nodename);
+
+	netif_disconnect_backend(info);
+	free_netdev(info->netdev);
+
+	return 0;
+}
+
+
+static void close_netdev(struct netfront_info *info)
+{
+	spin_lock_irq(&info->netdev->xmit_lock);
+	netif_stop_queue(info->netdev);
+	spin_unlock_irq(&info->netdev->xmit_lock);
+
+#if defined(CONFIG_PROC_FS) && defined(XEN_XENNET_PROC_INTERFACE)
+	xennet_proc_delif(info->netdev);
+#endif
+
+	del_timer_sync(&info->rx_refill_timer);
+
+	unregister_netdev(info->netdev);
+}
+
+
+static void netif_disconnect_backend(struct netfront_info *info)
+{
+	/* Stop old i/f to prevent errors whilst we rebuild the state. */
+	spin_lock_irq(&info->tx_lock);
+	spin_lock(&info->rx_lock);
+	info->backend_state = BEST_DISCONNECTED;
+	spin_unlock(&info->rx_lock);
+	spin_unlock_irq(&info->tx_lock);
+
+	if (info->irq)
+		unbind_from_irqhandler(info->irq, info->netdev);
+	info->evtchn = info->irq = 0;
+
+	end_access(info->tx_ring_ref, info->tx.sring);
+	end_access(info->rx_ring_ref, info->rx.sring);
+	info->tx_ring_ref = GRANT_INVALID_REF;
+	info->rx_ring_ref = GRANT_INVALID_REF;
+	info->tx.sring = NULL;
+	info->rx.sring = NULL;
+}
+
+
+static void netif_free(struct netfront_info *info)
+{
+	close_netdev(info);
+	netif_disconnect_backend(info);
+	free_netdev(info->netdev);
+}
+
+
+static void end_access(int ref, void *page)
+{
+	if (ref != GRANT_INVALID_REF)
+		gnttab_end_foreign_access(ref, 0, (unsigned long)page);
+}
+
+
+/* ** Driver registration ** */
+
+
+static struct xenbus_device_id netfront_ids[] = {
+	{ "vif" },
+	{ "" }
+};
+
+
+static struct xenbus_driver netfront = {
+	.name = "vif",
+	.owner = THIS_MODULE,
+	.ids = netfront_ids,
+	.probe = netfront_probe,
+	.remove = netfront_remove,
+	.resume = netfront_resume,
+	.otherend_changed = backend_changed,
+};
+
+
+static struct notifier_block notifier_inetdev = {
+	.notifier_call  = inetdev_notify,
+	.next           = NULL,
+	.priority       = 0
+};
+
+static int __init netif_init(void)
+{
+	int err = 0;
+
+	if (xen_start_info->flags & SIF_INITDOMAIN)
+		return 0;
+
+	if ((err = xennet_proc_init()) != 0)
+		return err;
+
+	IPRINTK("Initialising virtual ethernet driver.\n");
+
+	(void)register_inetaddr_notifier(&notifier_inetdev);
+
+	return xenbus_register_frontend(&netfront);
+}
+module_init(netif_init);
+
+
+static void netif_exit(void)
+{
+	unregister_inetaddr_notifier(&notifier_inetdev);
+
+	return xenbus_unregister_driver(&netfront);
+}
+module_exit(netif_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+
+
+/* ** /proc **/
+
+
+#if defined(CONFIG_PROC_FS) && defined(XEN_XENNET_PROC_INTERFACE)
+
+#define TARGET_MIN 0UL
+#define TARGET_MAX 1UL
+#define TARGET_CUR 2UL
+
+static int xennet_proc_read(
+	char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+	struct net_device *dev =
+		(struct net_device *)((unsigned long)data & ~3UL);
+	struct netfront_info *np = netdev_priv(dev);
+	int len = 0, which_target = (long)data & 3;
+
+	switch (which_target) {
+	case TARGET_MIN:
+		len = sprintf(page, "%d\n", np->rx_min_target);
+		break;
+	case TARGET_MAX:
+		len = sprintf(page, "%d\n", np->rx_max_target);
+		break;
+	case TARGET_CUR:
+		len = sprintf(page, "%d\n", np->rx_target);
+		break;
+	}
+
+	*eof = 1;
+	return len;
+}
+
+static int xennet_proc_write(
+	struct file *file, const char __user *buffer,
+	unsigned long count, void *data)
+{
+	struct net_device *dev =
+		(struct net_device *)((unsigned long)data & ~3UL);
+	struct netfront_info *np = netdev_priv(dev);
+	int which_target = (long)data & 3;
+	char string[64];
+	long target;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	if (count <= 1)
+		return -EBADMSG; /* runt */
+	if (count > sizeof(string))
+		return -EFBIG;   /* too long */
+
+	if (copy_from_user(string, buffer, count))
+		return -EFAULT;
+	string[sizeof(string)-1] = '\0';
+
+	target = simple_strtol(string, NULL, 10);
+	if (target < RX_MIN_TARGET)
+		target = RX_MIN_TARGET;
+	if (target > RX_MAX_TARGET)
+		target = RX_MAX_TARGET;
+
+	spin_lock(&np->rx_lock);
+
+	switch (which_target) {
+	case TARGET_MIN:
+		if (target > np->rx_max_target)
+			np->rx_max_target = target;
+		np->rx_min_target = target;
+		if (target > np->rx_target)
+			np->rx_target = target;
+		break;
+	case TARGET_MAX:
+		if (target < np->rx_min_target)
+			np->rx_min_target = target;
+		np->rx_max_target = target;
+		if (target < np->rx_target)
+			np->rx_target = target;
+		break;
+	case TARGET_CUR:
+		break;
+	}
+
+	network_alloc_rx_buffers(dev);
+
+	spin_unlock(&np->rx_lock);
+
+	return count;
+}
+
+static int xennet_proc_init(void)
+{
+	if (proc_mkdir("xen/net", NULL) == NULL)
+		return -ENOMEM;
+	return 0;
+}
+
+static int xennet_proc_addif(struct net_device *dev)
+{
+	struct proc_dir_entry *dir, *min, *max, *cur;
+	char name[30];
+
+	sprintf(name, "xen/net/%s", dev->name);
+
+	dir = proc_mkdir(name, NULL);
+	if (!dir)
+		goto nomem;
+
+	min = create_proc_entry("rxbuf_min", 0644, dir);
+	max = create_proc_entry("rxbuf_max", 0644, dir);
+	cur = create_proc_entry("rxbuf_cur", 0444, dir);
+	if (!min || !max || !cur)
+		goto nomem;
+
+	min->read_proc  = xennet_proc_read;
+	min->write_proc = xennet_proc_write;
+	min->data       = (void *)((unsigned long)dev | TARGET_MIN);
+
+	max->read_proc  = xennet_proc_read;
+	max->write_proc = xennet_proc_write;
+	max->data       = (void *)((unsigned long)dev | TARGET_MAX);
+
+	cur->read_proc  = xennet_proc_read;
+	cur->write_proc = xennet_proc_write;
+	cur->data       = (void *)((unsigned long)dev | TARGET_CUR);
+
+	return 0;
+
+ nomem:
+	xennet_proc_delif(dev);
+	return -ENOMEM;
+}
+
+static void xennet_proc_delif(struct net_device *dev)
+{
+	char name[30];
+
+	sprintf(name, "xen/net/%s/rxbuf_min", dev->name);
+	remove_proc_entry(name, NULL);
+
+	sprintf(name, "xen/net/%s/rxbuf_max", dev->name);
+	remove_proc_entry(name, NULL);
+
+	sprintf(name, "xen/net/%s/rxbuf_cur", dev->name);
+	remove_proc_entry(name, NULL);
+
+	sprintf(name, "xen/net/%s", dev->name);
+	remove_proc_entry(name, NULL);
+}
+
+#endif
--- /dev/null
+++ xen-subarch-2.6/include/xen/net_driver_util.h
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ *
+ * Utility functions for Xen network devices.
+ *
+ * Copyright (c) 2005 XenSource Ltd.
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following
+ * license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this source file (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 _ASM_XEN_NET_DRIVER_UTIL_H
+#define _ASM_XEN_NET_DRIVER_UTIL_H
+
+
+#include <xen/xenbus.h>
+
+
+/**
+ * Read the 'mac' node at the given device's node in the store, and parse that
+ * as colon-separated octets, placing result the given mac array.  mac must be
+ * a preallocated array of length ETH_ALEN (as declared in linux/if_ether.h).
+ * Return 0 on success, or -errno on error.
+ */
+int xen_net_read_mac(struct xenbus_device *dev, u8 mac[]);
+
+
+#endif /* _ASM_XEN_NET_DRIVER_UTIL_H */

--

^ permalink raw reply	[relevance 4%]

* Re: [RFC PATCH 34/35] Add the Xen virtual network device driver.
  2006-03-22  6:31  4% ` [RFC PATCH 34/35] Add the Xen virtual network device driver Chris Wright
@ 2006-03-22  8:59  0%   ` Arjan van de Ven
  0 siblings, 0 replies; 200+ results
From: Arjan van de Ven @ 2006-03-22  8:59 UTC (permalink / raw)
  To: Chris Wright
  Cc: linux-kernel, xen-devel, virtualization, Ian Pratt, Christian Limpach


> +#ifdef CONFIG_XEN_BALLOON
> +#include <xen/balloon.h>
> +#endif

such ifdefs are butt-ugly and should be inside the header at least

> +#ifndef __GFP_NOWARN
> +#define __GFP_NOWARN 0
> +#endif

eehhh why?


> +#define alloc_xen_skb(_l) __dev_alloc_skb((_l), GFP_ATOMIC|__GFP_NOWARN)

why does xen need it's own alloc_skb variant?

> +static unsigned long rx_pfn_array[NET_RX_RING_SIZE];
> +static struct multicall_entry rx_mcl[NET_RX_RING_SIZE+1];
> +static struct mmu_update rx_mmu[NET_RX_RING_SIZE];

does this mean you can only have 1 network interface? that sounds silly


> +
> +/* Access macros for acquiring freeing slots in {tx,rx}_skbs[]. */
> +#define ADD_ID_TO_FREELIST(_list, _id)			\
> +	(_list)[(_id)] = (_list)[0];			\
> +	(_list)[0]     = (void *)(unsigned long)(_id);
> +#define GET_ID_FROM_FREELIST(_list)				\
> +	({ unsigned long _id = (unsigned long)(_list)[0];	\
> +	   (_list)[0]  = (_list)[_id];				\
> +	   (unsigned short)_id; })

these should be inlines at leas

> +
> +/** Send a packet on a net device to encourage switches to learn the
> + * MAC. We send a fake ARP request.

why is this inside a driver?????

> +	if (unlikely((((unsigned long)skb->data & ~PAGE_MASK) + skb->len) >=
> +		     PAGE_SIZE)) {
> +		struct sk_buff *nskb;
> +		if (unlikely((nskb = alloc_xen_skb(skb->len)) == NULL))
> +			goto drop;
> +		skb_put(nskb, skb->len);
> +		memcpy(nskb->data, skb->data, skb->len);
> +		nskb->dev = skb->dev;
> +		dev_kfree_skb(skb);
> +		skb = nskb;
> +	}

hmm this smells fishy

> +
> +static int xennet_proc_read(


why is this device driver adding new own /proc crud ?

^ permalink raw reply	[relevance 0%]

* Growing a para-virtualized domain beyond its initial allocation?
@ 2006-03-30 22:36  6% John Byrne
  2006-03-30 22:45  0% ` Anthony Liguori
  0 siblings, 1 reply; 200+ results
From: John Byrne @ 2006-03-30 22:36 UTC (permalink / raw)
  To: xen-devel



I didn't get any responses on xen-users, so I'll try xen-devel:

This is somewhere between a user and a developer question, depending on
the answers. My tests were on the latest SuSE drop of xen: 3.0.2_09434-0
on i386.

I want to start a domain with a small amount of memory, but have the
potential to give it more if it needs it. (Perhaps after migrating to a
machine with more memory available.)

A simple "xm mem-set" doesn't work like I want, Linux never sees the
memory. Having looked at the balloon driver code, it would seem that
specifying "mem=256M" on the kernel command line and "memory = 128M" and
"maxmem = 256M" in the config file should do the right things, but in
practice it doesn't work. When I try the "xm mem-set 4 256",
/proc/xen/balloon in the guest reports that I have hit the Xen hard
limit. (I haven't yet figured out where this is coming from.)

So, am I on the right track, but there is a bug? Should I be going about
this another way? Is it hopeless? Assuming this works for
para-virtualized domains, is there any hope for doing the same with a
hvm-domain. (I'd guess not, but I'm supposed to ask.)

Thanks,

John Byrne

^ permalink raw reply	[relevance 6%]

* Re: Growing a para-virtualized domain beyond its initial allocation?
  2006-03-30 22:36  6% Growing a para-virtualized domain beyond its initial allocation? John Byrne
@ 2006-03-30 22:45  0% ` Anthony Liguori
  0 siblings, 0 replies; 200+ results
From: Anthony Liguori @ 2006-03-30 22:45 UTC (permalink / raw)
  To: John Byrne; +Cc: xen-devel

John Byrne wrote:
>
>
> I didn't get any responses on xen-users, so I'll try xen-devel:
>
> This is somewhere between a user and a developer question, depending on
> the answers. My tests were on the latest SuSE drop of xen: 3.0.2_09434-0
> on i386.
>
> I want to start a domain with a small amount of memory, but have the
> potential to give it more if it needs it. (Perhaps after migrating to a
> machine with more memory available.)
>
> A simple "xm mem-set" doesn't work like I want, Linux never sees the
> memory. Having looked at the balloon driver code, it would seem that
> specifying "mem=256M" on the kernel command line and "memory = 128M" and
> "maxmem = 256M" in the config file should do the right things, but in
> practice it doesn't work. When I try the "xm mem-set 4 256",
> /proc/xen/balloon in the guest reports that I have hit the Xen hard
> limit. (I haven't yet figured out where this is coming from.)

You ought to be able to set:

memory=128
maxmem=256

In a domain configuration file.  I was poking around with the maxmem 
option the other day and noticed that it wasn't being transmitted in xm 
create (or it at least appeared that way).  I was in the process of 
hunting down another bug so I didn't look too much into it.  If the 
above doesn't give you your desired behavior, you should open a bug in 
bugzilla about it.

Regards,

Anthony Liguori

> So, am I on the right track, but there is a bug? Should I be going about
> this another way? Is it hopeless? Assuming this works for
> para-virtualized domains, is there any hope for doing the same with a
> hvm-domain. (I'd guess not, but I'm supposed to ask.)
>
> Thanks,
>
> John Byrne
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 0%]

* [PATCH] Fix reversed test in balloon.py
@ 2006-03-31 19:26  9% Charles Coffing
  0 siblings, 0 replies; 200+ results
From: Charles Coffing @ 2006-03-31 19:26 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 291 bytes --]

When dom0 fails to balloon enough memory to allow a new domain to start,
an exception is thrown.  The test that decides which exception to throw
is backwards, resulting in strange error messages.  The attached patch
fixes the problem.

Signed-off-by:  Charles Coffing <ccoffing@novell.com>


[-- Attachment #2: xen-balloon.diff --]
[-- Type: application/octet-stream, Size: 614 bytes --]

--- xen-unstable-1/tools/python/xen/xend/balloon.py	2006-03-14 12:50:58.000000000 -0700
+++ xen-unstable-2/tools/python/xen/xend/balloon.py	2006-03-31 11:35:20.000000000 -0700
@@ -152,7 +152,7 @@
                            'I cannot release any more.  I need %d MiB but '
                            'only have %d.') %
                           (need_mem, free_mem))
-        elif new_alloc >= dom0_min_mem:
+        elif new_alloc < dom0_min_mem:
             raise VmError(
                 ('I need %d MiB, but dom0_min_mem is %d and shrinking to '
                  '%d MiB would leave only %d MiB free.') %

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 9%]

* Re: xm info showing too much free ram
  @ 2006-04-03 16:45  4% ` Keir Fraser
  2006-04-03 17:10  0%   ` Ewan Mellor
  0 siblings, 1 reply; 200+ results
From: Keir Fraser @ 2006-04-03 16:45 UTC (permalink / raw)
  To: Hans-Christian Armingeon; +Cc: xen-devel


On 30 Mar 2006, at 19:43, Hans-Christian Armingeon wrote:

> My dom0 has 2g ram allocated, and I have 2.5 G Ram physically in my 
> machine.
> I needed more Ram in domU so I did a

If you don't start your domU with a 'mem=2G' or similar as a boot 
parameter then the domU will be unable to increase its memory 
allocation beyond its initial boot-time allocation. In this case, 'xm 
list' is lying to you -- it tells you what memory target the tools has 
asked the domU to aim for, not what the domU is currently using. :-)

That's my guess anyway -- the free memory reported by 'xm info' is 
definitely the truth, so 'xm list' is lying and that's probably the 
reason why. Take a look in the domU and see what it thinks. Also in the 
domU, look at the contents of /proc/xen/balloon.

  -- Keir

^ permalink raw reply	[relevance 4%]

* Re: xm info showing too much free ram
  2006-04-03 16:45  4% ` Keir Fraser
@ 2006-04-03 17:10  0%   ` Ewan Mellor
  2006-04-04 10:44  0%     ` Hans-Christian Armingeon
  0 siblings, 1 reply; 200+ results
From: Ewan Mellor @ 2006-04-03 17:10 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel, Hans-Christian Armingeon

On Mon, Apr 03, 2006 at 05:45:07PM +0100, Keir Fraser wrote:

> 
> On 30 Mar 2006, at 19:43, Hans-Christian Armingeon wrote:
> 
> >My dom0 has 2g ram allocated, and I have 2.5 G Ram physically in my 
> >machine.
> >I needed more Ram in domU so I did a
> 
> If you don't start your domU with a 'mem=2G' or similar as a boot 
> parameter then the domU will be unable to increase its memory 
> allocation beyond its initial boot-time allocation. In this case, 'xm 
> list' is lying to you -- it tells you what memory target the tools has 
> asked the domU to aim for, not what the domU is currently using. :-)
> 
> That's my guess anyway -- the free memory reported by 'xm info' is 
> definitely the truth, so 'xm list' is lying and that's probably the 
> reason why. Take a look in the domU and see what it thinks. Also in the 
> domU, look at the contents of /proc/xen/balloon.

Yes, that's right -- xm list shows the configured or requested memory, not the
amount it's actually using.  Personally, I'd consider that a bug -- feel free
to file it.

Ewan.

^ permalink raw reply	[relevance 0%]

* Re: xm info showing too much free ram
  2006-04-03 17:10  0%   ` Ewan Mellor
@ 2006-04-04 10:44  0%     ` Hans-Christian Armingeon
  0 siblings, 0 replies; 200+ results
From: Hans-Christian Armingeon @ 2006-04-04 10:44 UTC (permalink / raw)
  To: xen-devel; +Cc: Ewan Mellor

Hello Keir,

is it difficult to fix that?

Maybe this is only a two liner.

Johnny

Am Montag, 3. April 2006 19:10 schrieb Ewan Mellor:
> On Mon, Apr 03, 2006 at 05:45:07PM +0100, Keir Fraser wrote:
> 
> > 
> > On 30 Mar 2006, at 19:43, Hans-Christian Armingeon wrote:
> > 
> > >My dom0 has 2g ram allocated, and I have 2.5 G Ram physically in my 
> > >machine.
> > >I needed more Ram in domU so I did a
> > 
> > If you don't start your domU with a 'mem=2G' or similar as a boot 
> > parameter then the domU will be unable to increase its memory 
> > allocation beyond its initial boot-time allocation. In this case, 'xm 
> > list' is lying to you -- it tells you what memory target the tools has 
> > asked the domU to aim for, not what the domU is currently using. :-)
> > 
> > That's my guess anyway -- the free memory reported by 'xm info' is 
> > definitely the truth, so 'xm list' is lying and that's probably the 
> > reason why. Take a look in the domU and see what it thinks. Also in the 
> > domU, look at the contents of /proc/xen/balloon.
> 
> Yes, that's right -- xm list shows the configured or requested memory, not the
> amount it's actually using.  Personally, I'd consider that a bug -- feel free
> to file it.
> 
> Ewan.
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
> 

-- 
jabber:johnny@wh-netz.de
icq:236971856

^ permalink raw reply	[relevance 0%]

* [PATCH] [BUG 143] [2nd try] Fix checksum errors over IPSec ESP tunnels
@ 2006-04-10 19:59  9% James Dykman
  0 siblings, 0 replies; 200+ results
From: James Dykman @ 2006-04-10 19:59 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 7568 bytes --]

This patch moves the prep for checksum calculations from dev_queue_xmit() 
into netback. The pointers in the skb headerare
set up for all IPv4 TCP/UDP traffic passing through netback, but the 
checksums are not actually calculated until they absolutely
have to be (currently in dev_queue_xmit() and xfrm4_output()).

This removes some xen-specific code from the net/core/dev.c, at the 
expense of some overhead for domU-domU traffic. Also
note that xfrm4_output() has to recalculate skb->h.raw, which gets 
stomped. I have not bothered to track down where this happens;
I think it's a sign that setting up these pointers so far from where they 
will be used is a bit fragile. But, it does work/fix the problem.

Tested on:
changeset:   9533:806d04252761
tag:         tip
user:        kaf24@firebug.cl.cam.ac.uk
date:        Wed Apr  5 05:37:37 2006 +0100
summary:     Fix checksum-offload problems introduced in c/s 9514, due to

With xm-test w/network-route/vif-route, and also with the failing config 
from bug 143.

For reference, the first try: 
http://lists.xensource.com/archives/html/xen-devel/2006-02/msg00162.html
Comments were: 
http://lists.xensource.com/archives/html/xen-devel/2006-03/msg00521.html

Signed-off-by: Jim Dykman <dykman@us.ibm.com>

Jim


diff -r a8b1d4fad72d linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Mon Mar 20 
11:01:32 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Fri Mar 24 
16:45:17 2006
@@ -13,6 +13,9 @@
 #include "common.h"
 #include <xen/balloon.h> 
 #include <xen/interface/memory.h>
+#include <net/ip.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
 
 /*#define NETBE_DEBUG_INTERRUPT*/
 
@@ -451,6 +454,33 @@
        }
 }

+inline static int checksum_setup(struct sk_buff *skb)
+{
+       if (skb->protocol != htons(ETH_P_IP))
+               return -1;
+       skb->nh.raw = skb->data;
+       skb->h.raw = (unsigned char *)skb->nh.iph + 4*skb->nh.iph->ihl;
+       if (skb->h.raw >= skb->tail)
+               return -1;
+       switch (skb->nh.iph->protocol) {
+       case IPPROTO_TCP:
+               skb->csum = offsetof(struct tcphdr, check);
+               break;
+       case IPPROTO_UDP:
+               skb->csum = offsetof(struct udphdr, check); 
+               break;
+       default:
+               if (net_ratelimit())
+                       printk(KERN_ERR "Attempting to checksum a non-"
+                              "TCP/UDP packet, dropping a protocol"
diff -r a8b1d4fad72d linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Mon Mar 20 
11:01:32 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Fri Mar 24 
16:45:17 2006
@@ -13,6 +13,9 @@
 #include "common.h"
 #include <xen/balloon.h> 
 #include <xen/interface/memory.h>
+#include <net/ip.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
 
 /*#define NETBE_DEBUG_INTERRUPT*/
 
@@ -451,6 +454,33 @@
        }
 }

+inline static int checksum_setup(struct sk_buff *skb)
+{
+       if (skb->protocol != htons(ETH_P_IP))
+               return -1;
+       skb->nh.raw = skb->data;
+       skb->h.raw = (unsigned char *)skb->nh.iph + 4*skb->nh.iph->ihl;
+       if (skb->h.raw >= skb->tail)
+               return -1;
+       switch (skb->nh.iph->protocol) {
+       case IPPROTO_TCP:
+               skb->csum = offsetof(struct tcphdr, check);
+               break;
+       case IPPROTO_UDP:
+               skb->csum = offsetof(struct udphdr, check); 
+               break;
+       default:
+               if (net_ratelimit())
+                       printk(KERN_ERR "Attempting to checksum a non-"
+                              "TCP/UDP packet, dropping a protocol"
+                                     " %d packet", 
skb->nh.iph->protocol);
+               return -1;
+       }
+       if ((skb->h.raw + skb->csum + 2) > skb->tail)
+               return -1;
+       return 0;
+}
+
 /* Called after netfront has transmitted */
 static void net_tx_action(unsigned long unused)
 {
@@ -637,6 +667,14 @@
                skb->ip_summed        = CHECKSUM_UNNECESSARY;
                skb->proto_csum_valid = 1;
                skb->proto_csum_blank = !!(txreq.flags & 
NETTXF_csum_blank);
+               if (skb->proto_csum_blank) {
+                       ret = checksum_setup(skb);
+                       if (ret < 0) {
+                               kfree_skb(skb);
+                               mop++;
+                               continue;
+                       }
+               }

                netif->stats.rx_bytes += txreq.size;
                netif->stats.rx_packets++;
diff -r a8b1d4fad72d linux-2.6-xen-sparse/net/core/dev.c
--- a/linux-2.6-xen-sparse/net/core/dev.c       Mon Mar 20 11:01:32 2006
+++ b/linux-2.6-xen-sparse/net/core/dev.c       Fri Mar 24 16:45:17 2006
@@ -116,12 +116,6 @@
 #endif /* CONFIG_NET_RADIO */
 #include <asm/current.h>

-#ifdef CONFIG_XEN
-#include <net/ip.h>
-#include <linux/tcp.h>
-#include <linux/udp.h>
-#endif
-
 /*
  *     The list of packet types we will receive (as opposed to discard)
  *     and the routines to invoke.
@@ -1270,31 +1264,8 @@
        /* If a checksum-deferred packet is forwarded to a device that 
needs a
         * checksum, correct the pointers and force checksumming.
         */
-       if (skb->proto_csum_blank) {
-               if (skb->protocol != htons(ETH_P_IP))
-                       goto out_kfree_skb;
-               skb->h.raw = (unsigned char *)skb->nh.iph + 
4*skb->nh.iph->ihl;
-               if (skb->h.raw >= skb->tail)
-                       goto out_kfree_skb;
-               switch (skb->nh.iph->protocol) {
-               case IPPROTO_TCP:
-                       skb->csum = offsetof(struct tcphdr, check);
-                       break;
-               case IPPROTO_UDP:
-                       skb->csum = offsetof(struct udphdr, check);
-                       break;
-               default:
-                       if (net_ratelimit())
-                               printk(KERN_ERR "Attempting to checksum a 
non-"
-                                      "TCP/UDP packet, dropping a 
protocol"
-                                      " %d packet", 
skb->nh.iph->protocol);
-                       rc = -EPROTO;
-                       goto out_kfree_skb;
-               }
-               if ((skb->h.raw + skb->csum + 2) > skb->tail)
-                       goto out_kfree_skb;
+       if (skb->proto_csum_blank)
                skb->ip_summed = CHECKSUM_HW;
-       }
 #endif

        /* If packet is not checksummed and device does not support
diff -r a8b1d4fad72d patches/linux-2.6.16-rc6/net-csum.patch
--- a/patches/linux-2.6.16/net-csum.patch       Mon Mar 20 11:01:32 2006
+++ b/patches/linux-2.6.16/net-csum.patch       Fri Mar 24 16:45:17 2006
@@ -39,3 +39,18 @@
        *portptr = newport;
        return 1;
  }
+--- ../pristine-linux-2.6.16/net/ipv4/xfrm4_output.c   2006-03-24 
16:17:38.000000000 -0500
++++ ./net/ipv4/xfrm4_output.c  2006-03-24 16:13:24.000000000 -0500
+@@ -103,6 +103,12 @@ static int xfrm4_output_one(struct sk_bu
+       struct xfrm_state *x = dst->xfrm;
+       int err;
+
++      if (skb->proto_csum_blank) {
++              skb->ip_summed = CHECKSUM_HW;
++              skb->proto_csum_blank = 0;
++              skb->h.raw = (unsigned char *)skb->nh.iph + 
4*skb->nh.iph->ihl;
++      }
++
+       if (skb->ip_summed == CHECKSUM_HW) {
+               err = skb_checksum_help(skb, 0);
+               if (err)


[-- Attachment #2: bug143.patch.v2 --]
[-- Type: application/octet-stream, Size: 3993 bytes --]

diff -r a8b1d4fad72d linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Mon Mar 20 11:01:32 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Fri Mar 24 16:45:17 2006
@@ -13,6 +13,9 @@
 #include "common.h"
 #include <xen/balloon.h>
 #include <xen/interface/memory.h>
+#include <net/ip.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
 
 /*#define NETBE_DEBUG_INTERRUPT*/
 
@@ -451,6 +454,33 @@
 	}
 }
 
+inline static int checksum_setup(struct sk_buff *skb)
+{
+	if (skb->protocol != htons(ETH_P_IP))
+		return -1;
+	skb->nh.raw = skb->data;
+	skb->h.raw = (unsigned char *)skb->nh.iph + 4*skb->nh.iph->ihl;
+	if (skb->h.raw >= skb->tail)
+		return -1;
+	switch (skb->nh.iph->protocol) {
+	case IPPROTO_TCP:
+		skb->csum = offsetof(struct tcphdr, check);
+		break;
+	case IPPROTO_UDP:
+		skb->csum = offsetof(struct udphdr, check); 
+		break;
+	default:
+		if (net_ratelimit())
+			printk(KERN_ERR "Attempting to checksum a non-"
+			       "TCP/UDP packet, dropping a protocol"
+                                     " %d packet", skb->nh.iph->protocol);
+		return -1;
+	}
+	if ((skb->h.raw + skb->csum + 2) > skb->tail)
+		return -1;
+	return 0;
+}
+
 /* Called after netfront has transmitted */
 static void net_tx_action(unsigned long unused)
 {
@@ -637,6 +667,14 @@
 		skb->ip_summed        = CHECKSUM_UNNECESSARY;
 		skb->proto_csum_valid = 1;
 		skb->proto_csum_blank = !!(txreq.flags & NETTXF_csum_blank);
+        	if (skb->proto_csum_blank) {
+			ret = checksum_setup(skb);
+			if (ret < 0) {
+				kfree_skb(skb);
+				mop++;
+				continue;
+			}
+		}
 
 		netif->stats.rx_bytes += txreq.size;
 		netif->stats.rx_packets++;
diff -r a8b1d4fad72d linux-2.6-xen-sparse/net/core/dev.c
--- a/linux-2.6-xen-sparse/net/core/dev.c	Mon Mar 20 11:01:32 2006
+++ b/linux-2.6-xen-sparse/net/core/dev.c	Fri Mar 24 16:45:17 2006
@@ -116,12 +116,6 @@
 #endif	/* CONFIG_NET_RADIO */
 #include <asm/current.h>
 
-#ifdef CONFIG_XEN
-#include <net/ip.h>
-#include <linux/tcp.h>
-#include <linux/udp.h>
-#endif
-
 /*
  *	The list of packet types we will receive (as opposed to discard)
  *	and the routines to invoke.
@@ -1270,31 +1264,8 @@
 	/* If a checksum-deferred packet is forwarded to a device that needs a
 	 * checksum, correct the pointers and force checksumming.
 	 */
-	if (skb->proto_csum_blank) {
-		if (skb->protocol != htons(ETH_P_IP))
-			goto out_kfree_skb;
-		skb->h.raw = (unsigned char *)skb->nh.iph + 4*skb->nh.iph->ihl;
-		if (skb->h.raw >= skb->tail)
-			goto out_kfree_skb;
-		switch (skb->nh.iph->protocol) {
-		case IPPROTO_TCP:
-			skb->csum = offsetof(struct tcphdr, check);
-			break;
-		case IPPROTO_UDP:
-			skb->csum = offsetof(struct udphdr, check);
-			break;
-		default:
-			if (net_ratelimit())
-				printk(KERN_ERR "Attempting to checksum a non-"
-				       "TCP/UDP packet, dropping a protocol"
-				       " %d packet", skb->nh.iph->protocol);
-			rc = -EPROTO;
-			goto out_kfree_skb;
-		}
-		if ((skb->h.raw + skb->csum + 2) > skb->tail)
-			goto out_kfree_skb;
+	if (skb->proto_csum_blank)
 		skb->ip_summed = CHECKSUM_HW;
-	}
 #endif
 
 	/* If packet is not checksummed and device does not support
diff -r a8b1d4fad72d patches/linux-2.6.16-rc6/net-csum.patch
--- a/patches/linux-2.6.16/net-csum.patch	Mon Mar 20 11:01:32 2006
+++ b/patches/linux-2.6.16/net-csum.patch	Fri Mar 24 16:45:17 2006
@@ -39,3 +39,18 @@
  	*portptr = newport;
  	return 1;
  }
+--- ../pristine-linux-2.6.16/net/ipv4/xfrm4_output.c	2006-03-24 16:17:38.000000000 -0500
++++ ./net/ipv4/xfrm4_output.c	2006-03-24 16:13:24.000000000 -0500
+@@ -103,6 +103,12 @@ static int xfrm4_output_one(struct sk_bu
+ 	struct xfrm_state *x = dst->xfrm;
+ 	int err;
+ 	
++	if (skb->proto_csum_blank) {
++		skb->ip_summed = CHECKSUM_HW;
++		skb->proto_csum_blank = 0;
++		skb->h.raw = (unsigned char *)skb->nh.iph + 4*skb->nh.iph->ihl;
++	}
++
+ 	if (skb->ip_summed == CHECKSUM_HW) {
+ 		err = skb_checksum_help(skb, 0);
+ 		if (err)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 9%]

* Re: [PATCH 4/6] grantable and address conversion patches
  @ 2006-04-12 13:23  4%         ` Isaku Yamahata
  0 siblings, 0 replies; 200+ results
From: Isaku Yamahata @ 2006-04-12 13:23 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel, xen-ia64-devel

[-- Attachment #1: Type: text/plain, Size: 881 bytes --]


I attached the updated patch.

On Mon, Apr 10, 2006 at 01:47:20PM +0100, Keir Fraser wrote:
> 
> On 10 Apr 2006, at 13:37, Isaku Yamahata wrote:
> 
> >>I'd rather define a function to fill in the entire structure in
> >>gnttab.h.
> >
> >I hope that the attached patch is much more preferable
> >than the previous one.
> >I tested compilation and dom0 boot.
> 
> Is the 'phys' parameter to the new functions ever non-zero?
> 
> Also, the call sites that pass a ptep pose a problem -- the host 
> address should not be __pa()'ed as it's already a machine (or 
> pseudo-phys) address. On mapping you can check for GNTMAP_contains_pte. 
> Perhaps we will need to pass flags to the unmap function too.
> 
>  -- Keir
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
> 

-- 
yamahata

[-- Attachment #2: 9622:139a6a3195c5_gnttab_set_map_op_gnttab_set_unmap_op.patch --]
[-- Type: text/plain, Size: 18166 bytes --]

# HG changeset patch
# User yamahata@valinux.co.jp
# Node ID 139a6a3195c5c61aa08a88112126a3a944bc81b9
# Parent  edefe24d78bd5e6e51bdd002f3ee7721d6dc2ce5
make grant table map/unmap argument, host_addr, feature-specific.
introduce gnttab_set_map_op() and gnttab_set_unmap_op() to initialize.
PATCHNAME: gnttab_set_map_op_gnttab_set_unmap_op

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

diff -r edefe24d78bd -r 139a6a3195c5 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Tue Apr 11 12:51:48 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Wed Apr 12 21:56:47 2006 +0900
@@ -186,9 +186,8 @@ static void fast_flush_area(pending_req_
 		handle = pending_handle(req, i);
 		if (handle == BLKBACK_INVALID_HANDLE)
 			continue;
-		unmap[invcount].host_addr    = vaddr(req, i);
-		unmap[invcount].dev_bus_addr = 0;
-		unmap[invcount].handle       = handle;
+		gnttab_set_unmap_op(&unmap[i], vaddr(req, i), GNTMAP_host_map,
+				    handle);
 		pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
 		invcount++;
 	}
@@ -384,6 +383,8 @@ static void dispatch_rw_block_io(blkif_t
 	pending_req->nr_pages  = nseg;
 
 	for (i = 0; i < nseg; i++) {
+		uint32_t flags;
+
 		seg[i].nsec = req->seg[i].last_sect -
 			req->seg[i].first_sect + 1;
 
@@ -392,12 +393,11 @@ static void dispatch_rw_block_io(blkif_t
 			goto fail_response;
 		preq.nr_sects += seg[i].nsec;
 
-		map[i].host_addr = vaddr(pending_req, i);
-		map[i].dom = blkif->domid;
-		map[i].ref = req->seg[i].gref;
-		map[i].flags = GNTMAP_host_map;
+		flags = GNTMAP_host_map;
 		if ( operation == WRITE )
-			map[i].flags |= GNTMAP_readonly;
+			flags |= GNTMAP_readonly;
+		gnttab_set_map_op(&map[i], vaddr(pending_req, i), flags,
+				  req->seg[i].gref, blkif->domid);
 	}
 
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, nseg);
diff -r edefe24d78bd -r 139a6a3195c5 linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Tue Apr 11 12:51:48 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Wed Apr 12 21:56:47 2006 +0900
@@ -58,10 +58,8 @@ static int map_frontend_page(blkif_t *bl
 	struct gnttab_map_grant_ref op;
 	int ret;
 
-	op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
-	op.flags     = GNTMAP_host_map;
-	op.ref       = shared_page;
-	op.dom       = blkif->domid;
+	gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+			  GNTMAP_host_map, shared_page, blkif->domid);
 
 	lock_vm_area(blkif->blk_ring_area);
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
@@ -90,9 +88,8 @@ static void unmap_frontend_page(blkif_t 
 	struct gnttab_unmap_grant_ref op;
 	int ret;
 
-	op.host_addr    = (unsigned long)blkif->blk_ring_area->addr;
-	op.handle       = blkif->shmem_handle;
-	op.dev_bus_addr = 0;
+	gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+			    GNTMAP_host_map, blkif->shmem_handle);
 
 	lock_vm_area(blkif->blk_ring_area);
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
diff -r edefe24d78bd -r 139a6a3195c5 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Tue Apr 11 12:51:48 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Wed Apr 12 21:56:47 2006 +0900
@@ -418,9 +418,9 @@ static void fast_flush_area(int idx, int
 		if (BLKTAP_INVALID_HANDLE(handle))
 			continue;
 
-		unmap[op].host_addr = MMAP_VADDR(mmap_vstart, idx, i);
-		unmap[op].dev_bus_addr = 0;
-		unmap[op].handle = handle->kernel;
+		gnttab_set_unmap_op(&unmap[op],
+				    MMAP_VADDR(mmap_vstart, idx, i),
+				    GNTMAP_host_map, handle->kernel);
 		op++;
 
 		if (create_lookup_pte_addr(
@@ -430,9 +430,10 @@ static void fast_flush_area(int idx, int
 			DPRINTK("Couldn't get a pte addr!\n");
 			return;
 		}
-		unmap[op].host_addr    = ptep;
-		unmap[op].dev_bus_addr = 0;
-		unmap[op].handle       = handle->user;
+		gnttab_set_unmap_grnat_ref(&unmap[op], ptep,
+					   GNTMAP_host_map |
+					   GNTMAP_application_map |
+					   GNTMAP_contains_pte, handle->user);
 		op++;
             
 		BLKTAP_INVALIDATE_HANDLE(handle);
@@ -703,21 +704,21 @@ static void dispatch_rw_block_io(blkif_t
 		unsigned long uvaddr;
 		unsigned long kvaddr;
 		uint64_t ptep;
+		uint32_t flags;
 
 		uvaddr = MMAP_VADDR(user_vstart, pending_idx, i);
 		kvaddr = MMAP_VADDR(mmap_vstart, pending_idx, i);
 
-		/* Map the remote page to kernel. */
-		map[op].host_addr = kvaddr;
-		map[op].dom   = blkif->domid;
-		map[op].ref   = req->seg[i].gref;
-		map[op].flags = GNTMAP_host_map;
+		flags = GNTMAP_host_map;
 		/* This needs a bit more thought in terms of interposition: 
 		 * If we want to be able to modify pages during write using 
 		 * grant table mappings, the guest will either need to allow 
 		 * it, or we'll need to incur a copy. Bit of an fbufs moment. ;) */
 		if (req->operation == BLKIF_OP_WRITE)
-			map[op].flags |= GNTMAP_readonly;
+			flags |= GNTMAP_readonly;
+		/* Map the remote page to kernel. */
+		gnttab_set_map_op(&map[op], kvaddr, flags, req->seg[i].gref,
+				  blkif->domid);
 		op++;
 
 		/* Now map it to user. */
@@ -728,14 +729,13 @@ static void dispatch_rw_block_io(blkif_t
 			goto bad_descriptor;
 		}
 
-		map[op].host_addr = ptep;
-		map[op].dom       = blkif->domid;
-		map[op].ref       = req->seg[i].gref;
-		map[op].flags     = GNTMAP_host_map | GNTMAP_application_map
+		flags = GNTMAP_host_map | GNTMAP_application_map
 			| GNTMAP_contains_pte;
 		/* Above interposition comment applies here as well. */
 		if (req->operation == BLKIF_OP_WRITE)
-			map[op].flags |= GNTMAP_readonly;
+			flags |= GNTMAP_readonly;
+		gnttab_set_map_op(&map[op], ptep, flags, req->seg[i].gref,
+				  blkif->domid);
 		op++;
 	}
 
diff -r edefe24d78bd -r 139a6a3195c5 linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Tue Apr 11 12:51:48 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Wed Apr 12 21:56:47 2006 +0900
@@ -33,10 +33,8 @@ static int map_frontend_page(blkif_t *bl
 	struct gnttab_map_grant_ref op;
 	int ret;
 
-	op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
-	op.flags     = GNTMAP_host_map;
-	op.ref       = shared_page;
-	op.dom       = blkif->domid;
+	gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+			  GNTMAP_host_map, shared_page, blkif->domid);
 
 	lock_vm_area(blkif->blk_ring_area);
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
@@ -59,9 +57,8 @@ static void unmap_frontend_page(blkif_t 
 	struct gnttab_unmap_grant_ref op;
 	int ret;
 
-	op.host_addr    = (unsigned long)blkif->blk_ring_area->addr;
-	op.handle       = blkif->shmem_handle;
-	op.dev_bus_addr = 0;
+	gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+			    GNTMAP_host_map, blkif->shmem_handle);
 
 	lock_vm_area(blkif->blk_ring_area);
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
diff -r edefe24d78bd -r 139a6a3195c5 linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Tue Apr 11 12:51:48 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Wed Apr 12 21:56:47 2006 +0900
@@ -150,10 +150,8 @@ static int map_frontend_pages(
 	struct gnttab_map_grant_ref op;
 	int ret;
 
-	op.host_addr = (unsigned long)netif->tx_comms_area->addr;
-	op.flags     = GNTMAP_host_map;
-	op.ref       = tx_ring_ref;
-	op.dom       = netif->domid;
+	gnttab_set_map_op(&op, (unsigned long)netif->tx_comms_area->addr,
+			  GNTMAP_host_map, tx_ring_ref, netif->domid);
     
 	lock_vm_area(netif->tx_comms_area);
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
@@ -168,10 +166,8 @@ static int map_frontend_pages(
 	netif->tx_shmem_ref    = tx_ring_ref;
 	netif->tx_shmem_handle = op.handle;
 
-	op.host_addr = (unsigned long)netif->rx_comms_area->addr;
-	op.flags     = GNTMAP_host_map;
-	op.ref       = rx_ring_ref;
-	op.dom       = netif->domid;
+	gnttab_set_map_op(&op, (unsigned long)netif->rx_comms_area->addr,
+			  GNTMAP_host_map, rx_ring_ref, netif->domid);
 
 	lock_vm_area(netif->rx_comms_area);
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
@@ -194,18 +190,16 @@ static void unmap_frontend_pages(netif_t
 	struct gnttab_unmap_grant_ref op;
 	int ret;
 
-	op.host_addr    = (unsigned long)netif->tx_comms_area->addr;
-	op.handle       = netif->tx_shmem_handle;
-	op.dev_bus_addr = 0;
+	gnttab_set_unmap_op(&op, (unsigned long)netif->tx_comms_area->addr,
+			    GNTMAP_host_map, netif->tx_shmem_handle);
 
 	lock_vm_area(netif->tx_comms_area);
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
 	unlock_vm_area(netif->tx_comms_area);
 	BUG_ON(ret);
 
-	op.host_addr    = (unsigned long)netif->rx_comms_area->addr;
-	op.handle       = netif->rx_shmem_handle;
-	op.dev_bus_addr = 0;
+	gnttab_set_unmap_op(&op, (unsigned long)netif->rx_comms_area->addr,
+			    GNTMAP_host_map, netif->rx_shmem_handle);
 
 	lock_vm_area(netif->rx_comms_area);
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
diff -r edefe24d78bd -r 139a6a3195c5 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Apr 11 12:51:48 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Wed Apr 12 21:56:47 2006 +0900
@@ -453,9 +453,9 @@ inline static void net_tx_action_dealloc
 	gop = tx_unmap_ops;
 	while (dc != dp) {
 		pending_idx = dealloc_ring[MASK_PEND_IDX(dc++)];
-		gop->host_addr    = MMAP_VADDR(pending_idx);
-		gop->dev_bus_addr = 0;
-		gop->handle       = grant_tx_handle[pending_idx];
+		gnttab_set_unmap_op(gop, MMAP_VADDR(pending_idx),
+				    GNTMAP_host_map,
+				    grant_tx_handle[pending_idx]);
 		gop++;
 	}
 	ret = HYPERVISOR_grant_table_op(
@@ -579,10 +579,9 @@ static void net_tx_action(unsigned long 
 		/* Packets passed to netif_rx() must have some headroom. */
 		skb_reserve(skb, 16);
 
-		mop->host_addr = MMAP_VADDR(pending_idx);
-		mop->dom       = netif->domid;
-		mop->ref       = txreq.gref;
-		mop->flags     = GNTMAP_host_map | GNTMAP_readonly;
+		gnttab_set_map_op(mop, MMAP_VADDR(pending_idx),
+				  GNTMAP_host_map | GNTMAP_readonly,
+				  txreq.gref, netif->domid);
 		mop++;
 
 		memcpy(&pending_tx_info[pending_idx].req,
diff -r edefe24d78bd -r 139a6a3195c5 linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Tue Apr 11 12:51:48 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Wed Apr 12 21:56:47 2006 +0900
@@ -13,6 +13,7 @@
 
 #include "common.h"
 #include <xen/balloon.h>
+#include <xen/gnttab.h>
 
 static kmem_cache_t *tpmif_cachep;
 int num_frontends = 0;
@@ -72,12 +73,10 @@ static int map_frontend_page(tpmif_t *tp
 static int map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
 {
 	int ret;
-	struct gnttab_map_grant_ref op = {
-		.host_addr = (unsigned long)tpmif->tx_area->addr,
-		.flags = GNTMAP_host_map,
-		.ref = shared_page,
-		.dom = tpmif->domid,
-	};
+	struct gnttab_map_grant_ref op;
+
+	gnttab_set_map_op(&op, (unsigned long)tpmif->tx_area->addr,
+			  GNTMAP_host_map, shared_page, tpmif->domid);
 
 	lock_vm_area(tpmif->tx_area);
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
@@ -100,9 +99,8 @@ static void unmap_frontend_page(tpmif_t 
 	struct gnttab_unmap_grant_ref op;
 	int ret;
 
-	op.host_addr    = (unsigned long)tpmif->tx_area->addr;
-	op.handle       = tpmif->shmem_handle;
-	op.dev_bus_addr = 0;
+	gnttab_set_unmap_op(&op, (unsigned long)tpmif->tx_area->addr,
+			    GNTMAP_host_map, tpmif->shmem_handle);
 
 	lock_vm_area(tpmif->tx_area);
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
diff -r edefe24d78bd -r 139a6a3195c5 linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Tue Apr 11 12:51:48 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Wed Apr 12 21:56:47 2006 +0900
@@ -21,6 +21,7 @@
 #include <asm/uaccess.h>
 #include <xen/xenbus.h>
 #include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
 
 /* local data structures */
 struct data_exchange {
@@ -278,10 +279,8 @@ int _packet_write(struct packet *pak,
 			return 0;
 		}
 
-		map_op.host_addr = MMAP_VADDR(tpmif, i);
-		map_op.flags = GNTMAP_host_map;
-		map_op.ref = tx->ref;
-		map_op.dom = tpmif->domid;
+		gnttab_set_map_op(&map_op, MMAP_VADDR(tpmif, i),
+				  GNTMAP_host_map, tx->ref, tpmif->domid);
 
 		if (unlikely(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
 						       &map_op, 1))) {
@@ -308,9 +307,8 @@ int _packet_write(struct packet *pak,
 		}
 		tx->size = tocopy;
 
-		unmap_op.host_addr = MMAP_VADDR(tpmif, i);
-		unmap_op.handle = handle;
-		unmap_op.dev_bus_addr = 0;
+		gnttab_set_unmap_op(&unmap_op, MMAP_VADDR(tpmif, i),
+				    GNTMAP_host_map, handle);
 
 		if (unlikely
 		    (HYPERVISOR_grant_table_op
@@ -422,10 +420,8 @@ static int packet_read_shmem(struct pack
 
 		tx = &tpmif->tx->ring[i].req;
 
-		map_op.host_addr = MMAP_VADDR(tpmif, i);
-		map_op.flags = GNTMAP_host_map;
-		map_op.ref = tx->ref;
-		map_op.dom = tpmif->domid;
+		gnttab_set_map_op(&map_op, MMAP_VADDR(tpmif, i),
+				  GNTMAP_host_map, tx->ref, tpmif->domid);
 
 		if (unlikely(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
 						       &map_op, 1))) {
@@ -461,9 +457,8 @@ static int packet_read_shmem(struct pack
 			tpmif->domid, buffer[offset], buffer[offset + 1],
 			buffer[offset + 2], buffer[offset + 3]);
 
-		unmap_op.host_addr = MMAP_VADDR(tpmif, i);
-		unmap_op.handle = handle;
-		unmap_op.dev_bus_addr = 0;
+		gnttab_set_unmap_op(&unmap_op, MMAP_VADDR(tpmif, i),
+				    GNTMAP_host_map, handle);
 
 		if (unlikely
 		    (HYPERVISOR_grant_table_op
diff -r edefe24d78bd -r 139a6a3195c5 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c	Tue Apr 11 12:51:48 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c	Wed Apr 12 21:56:47 2006 +0900
@@ -37,11 +37,7 @@
 /* Based on Rusty Russell's skeleton driver's map_page */
 int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
 {
-	struct gnttab_map_grant_ref op = {
-		.flags = GNTMAP_host_map,
-		.ref   = gnt_ref,
-		.dom   = dev->otherend_id,
-	};
+	struct gnttab_map_grant_ref op;
 	struct vm_struct *area;
 
 	*vaddr = NULL;
@@ -50,8 +46,9 @@ int xenbus_map_ring_valloc(struct xenbus
 	if (!area)
 		return -ENOMEM;
 
-	op.host_addr = (unsigned long)area->addr;
-
+	gnttab_set_map_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
+			  gnt_ref, dev->otherend_id);
+	
 	lock_vm_area(area);
 	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
 	unlock_vm_area(area);
@@ -76,13 +73,10 @@ int xenbus_map_ring(struct xenbus_device
 int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
 		   grant_handle_t *handle, void *vaddr)
 {
-	struct gnttab_map_grant_ref op = {
-		.host_addr = (unsigned long)vaddr,
-		.flags     = GNTMAP_host_map,
-		.ref       = gnt_ref,
-		.dom       = dev->otherend_id,
-	};
-
+	struct gnttab_map_grant_ref op;
+	
+	gnttab_set_map_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
+			  gnt_ref, dev->otherend_id);
 	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
 
 	if (op.status != GNTST_okay) {
@@ -101,9 +95,7 @@ int xenbus_unmap_ring_vfree(struct xenbu
 int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
 {
 	struct vm_struct *area;
-	struct gnttab_unmap_grant_ref op = {
-		.host_addr = (unsigned long)vaddr,
-	};
+	struct gnttab_unmap_grant_ref op;
 
 	/* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr)
 	 * method so that we don't have to muck with vmalloc internals here.
@@ -124,7 +116,8 @@ int xenbus_unmap_ring_vfree(struct xenbu
 		return GNTST_bad_virt_addr;
 	}
 
-	op.handle = (grant_handle_t)area->phys_addr;
+	gnttab_set_unmap_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
+			    (grant_handle_t)area->phys_addr);
 
 	lock_vm_area(area);
 	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
@@ -145,11 +138,10 @@ int xenbus_unmap_ring(struct xenbus_devi
 int xenbus_unmap_ring(struct xenbus_device *dev,
 		     grant_handle_t handle, void *vaddr)
 {
-	struct gnttab_unmap_grant_ref op = {
-		.host_addr = (unsigned long)vaddr,
-		.handle    = handle,
-	};
+	struct gnttab_unmap_grant_ref op;
 
+	gnttab_set_unmap_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
+			    handle);
 	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
 
 	if (op.status != GNTST_okay)
diff -r edefe24d78bd -r 139a6a3195c5 linux-2.6-xen-sparse/include/xen/gnttab.h
--- a/linux-2.6-xen-sparse/include/xen/gnttab.h	Tue Apr 11 12:51:48 2006 +0100
+++ b/linux-2.6-xen-sparse/include/xen/gnttab.h	Wed Apr 12 21:56:47 2006 +0900
@@ -40,6 +40,7 @@
 #include <linux/config.h>
 #include <asm/hypervisor.h>
 #include <xen/interface/grant_table.h>
+#include <xen/features.h>
 
 /* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
 #ifdef __ia64__
@@ -113,6 +114,37 @@ int gnttab_suspend(void);
 int gnttab_suspend(void);
 int gnttab_resume(void);
 
+static inline void
+gnttab_set_map_op(struct gnttab_map_grant_ref *map, unsigned long addr,
+		  uint32_t flags, grant_ref_t ref, domid_t domid)
+{
+	if (flags & GNTMAP_contains_pte)
+		map->host_addr = addr;
+	else if (xen_feature(XENFEAT_auto_translated_physmap))
+		map->host_addr = __pa(addr);
+	else
+		map->host_addr = addr;
+
+	map->flags = flags;
+	map->ref = ref;
+	map->dom = domid;
+}
+
+static inline void
+gnttab_set_unmap_op(struct gnttab_unmap_grant_ref *unmap, unsigned long addr,
+		    uint32_t flags, grant_handle_t handle)
+{
+	if (flags & GNTMAP_contains_pte)
+		unmap->host_addr = addr;
+	else if (xen_feature(XENFEAT_auto_translated_physmap))
+		unmap->host_addr = __pa(addr);
+	else
+		unmap->host_addr = addr;
+
+	unmap->handle = handle;
+	unmap->dev_bus_addr = 0;
+}
+
 #endif /* __ASM_GNTTAB_H__ */
 
 /*

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 4%]

* Re: [patch] 32/64-bit hypercall interface revisited
  @ 2006-04-25 20:24 13%       ` Hollis Blanchard
    0 siblings, 1 reply; 200+ results
From: Hollis Blanchard @ 2006-04-25 20:24 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel, xen-ppc-devel

[-- Attachment #1: Type: text/plain, Size: 819 bytes --]

On Tue, 2006-04-25 at 09:01 +0100, Keir Fraser wrote:
> On 24 Apr 2006, at 20:24, Hollis Blanchard wrote:
> 
> > Since the other patch is still undergoing discussion, please commit 
> > this
> > one. As suggested, I've changed the macro names to
> > GET/SET_GUEST_HANDLE().
> 
> This patch will unconditionally use the 'structural' definition of 
> guest handles for tools and kernels as well as Xen, right? Can XenLinux 
> for x86/ia64 still build with this patch, without needing a bunch of 
> GET/SET_GUEST_HANDLE changes?

Sorry, you're right. Attached are three patches: the Xen patch, the
linux-2.6-merge patch, and the linux-2.6-sparse patch.

-- 
Hollis Blanchard
IBM Linux Technology Center


Introduce wrappers to access GUEST_HANDLES in libxc and Linux.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

[-- Attachment #2: xen-handles.diff --]
[-- Type: text/x-patch, Size: 15648 bytes --]

diff -r 56e1802303e5 tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_domain.c	Tue Apr 25 15:17:52 2006 -0500
@@ -171,7 +171,7 @@ int xc_domain_getinfolist(int xc_handle,
     op.cmd = DOM0_GETDOMAININFOLIST;
     op.u.getdomaininfolist.first_domain = first_domain;
     op.u.getdomaininfolist.max_domains  = max_domains;
-    op.u.getdomaininfolist.buffer       = info;
+    SET_GUEST_HANDLE(op.u.getdomaininfolist.buffer, info);
 
     if ( xc_dom0_op(xc_handle, &op) < 0 )
         ret = -1;
@@ -195,7 +195,7 @@ int xc_vcpu_getcontext(int xc_handle,
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (uint16_t)vcpu;
-    op.u.getvcpucontext.ctxt   = ctxt;
+    SET_GUEST_HANDLE(op.u.getvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
@@ -220,7 +220,7 @@ int xc_shadow_control(int xc_handle,
     op.cmd = DOM0_SHADOW_CONTROL;
     op.u.shadow_control.domain = (domid_t)domid;
     op.u.shadow_control.op     = sop;
-    op.u.shadow_control.dirty_bitmap = dirty_bitmap;
+    SET_GUEST_HANDLE(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
     op.u.shadow_control.pages  = pages;
 
     rc = do_dom0_op(xc_handle, &op);
@@ -295,12 +295,12 @@ int xc_domain_memory_increase_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, /* may be NULL */
         .nr_extents   = nr_extents,
         .extent_order = extent_order,  
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_GUEST_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
     if ( err == nr_extents )
@@ -326,12 +326,12 @@ int xc_domain_memory_decrease_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, 
         .nr_extents   = nr_extents,
         .extent_order = extent_order,  
         .address_bits = 0,
         .domid        = domid
     };
+    SET_GUEST_HANDLE(reservation.extent_start, extent_start);
 
     if ( extent_start == NULL )
     {
@@ -364,12 +364,12 @@ int xc_domain_memory_populate_physmap(in
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start,
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_GUEST_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     err = xc_memory_op(xc_handle, XENMEM_populate_physmap, &reservation);
     if ( err == nr_extents )
@@ -395,9 +395,9 @@ int xc_domain_translate_gpfn_list(int xc
     struct xen_translate_gpfn_list op = {
         .domid        = domid,
         .nr_gpfns     = nr_gpfns,
-        .gpfn_list    = gpfn_list,
-        .mfn_list     = mfn_list
     };
+    SET_GUEST_HANDLE(op.gpfn_list, gpfn_list);
+    SET_GUEST_HANDLE(op.mfn_list, mfn_list);
 
     return xc_memory_op(xc_handle, XENMEM_translate_gpfn_list, &op);
 }
@@ -467,7 +467,7 @@ int xc_vcpu_setcontext(int xc_handle,
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = domid;
     op.u.setvcpucontext.vcpu = vcpu;
-    op.u.setvcpucontext.ctxt = ctxt;
+    SET_GUEST_HANDLE(op.u.setvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
diff -r 56e1802303e5 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_hvm_build.c	Tue Apr 25 15:17:52 2006 -0500
@@ -440,7 +440,7 @@ static int xc_hvm_build_internal(int xc_
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
diff -r 56e1802303e5 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_linux_build.c	Tue Apr 25 15:17:52 2006 -0500
@@ -1180,7 +1180,7 @@ static int xc_linux_build_internal(int x
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
diff -r 56e1802303e5 tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_linux_restore.c	Tue Apr 25 15:17:52 2006 -0500
@@ -583,11 +583,11 @@ int xc_linux_restore(int xc_handle, int 
         if (count > 0) {
 
             struct xen_memory_reservation reservation = {
-                .extent_start = pfntab,
                 .nr_extents   = count,
                 .extent_order = 0,
                 .domid        = dom
             };
+            SET_GUEST_HANDLE(reservation.extent_start, pfntab);
 
             if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
                                    &reservation)) != count) { 
@@ -727,7 +727,7 @@ int xc_linux_restore(int xc_handle, int 
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = (domid_t)dom;
     op.u.setvcpucontext.vcpu   = 0;
-    op.u.setvcpucontext.ctxt   = &ctxt;
+    SET_GUEST_HANDLE(op.u.setvcpucontext.ctxt, &ctxt);
     rc = xc_dom0_op(xc_handle, &op);
 
     if (rc != 0) {
diff -r 56e1802303e5 tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_linux_save.c	Tue Apr 25 15:17:52 2006 -0500
@@ -509,16 +509,18 @@ static unsigned long *xc_map_m2p(int xc_
     privcmd_mmap_entry_t *entries; 
     unsigned long m2p_chunks, m2p_size; 
     unsigned long *m2p; 
+    unsigned long *extent_start;
     int i, rc; 
 
     m2p_size   = M2P_SIZE(max_mfn); 
     m2p_chunks = M2P_CHUNKS(max_mfn); 
 
     xmml.max_extents = m2p_chunks;
-    if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) { 
+    if (!(extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
         ERR("failed to allocate space for m2p mfns"); 
         return NULL; 
     } 
+    SET_GUEST_HANDLE(xmml.extent_start, extent_start);
 
     if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
         (xmml.nr_extents != m2p_chunks)) {
@@ -543,7 +545,7 @@ static unsigned long *xc_map_m2p(int xc_
     
     for (i=0; i < m2p_chunks; i++) { 
         entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE)); 
-        entries[i].mfn = xmml.extent_start[i];
+        entries[i].mfn = extent_start[i];
         entries[i].npages = M2P_CHUNK_SIZE >> PAGE_SHIFT;
     }
 
@@ -552,7 +554,7 @@ static unsigned long *xc_map_m2p(int xc_
         return NULL; 
     }
 
-    free(xmml.extent_start);
+    free(extent_start);
     free(entries); 
 
     return m2p; 
diff -r 56e1802303e5 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_misc.c	Tue Apr 25 15:17:52 2006 -0500
@@ -30,7 +30,7 @@ int xc_readconsolering(int xc_handle,
     unsigned int nr_chars = *pnr_chars;
 
     op.cmd = DOM0_READCONSOLE;
-    op.u.readconsole.buffer = buffer;
+    SET_GUEST_HANDLE(op.u.readconsole.buffer, buffer);
     op.u.readconsole.count  = nr_chars;
     op.u.readconsole.clear  = clear;
 
@@ -39,7 +39,7 @@ int xc_readconsolering(int xc_handle,
 
     if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
     {
-        *pbuffer   = op.u.readconsole.buffer;
+        GET_GUEST_HANDLE(*pbuffer, op.u.readconsole.buffer);
         *pnr_chars = op.u.readconsole.count;
     }
 
@@ -91,7 +91,7 @@ int xc_perfc_control(int xc_handle,
 
     op.cmd = DOM0_PERFCCONTROL;
     op.u.perfccontrol.op   = opcode;
-    op.u.perfccontrol.desc = desc;
+    SET_GUEST_HANDLE(op.u.perfccontrol.desc, desc);
 
     rc = do_dom0_op(xc_handle, &op);
 
diff -r 56e1802303e5 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_private.c	Tue Apr 25 15:17:52 2006 -0500
@@ -71,7 +71,7 @@ int xc_get_pfn_type_batch(int xc_handle,
     op.cmd = DOM0_GETPAGEFRAMEINFO2;
     op.u.getpageframeinfo2.domain = (domid_t)dom;
     op.u.getpageframeinfo2.num    = num;
-    op.u.getpageframeinfo2.array  = arr;
+    SET_GUEST_HANDLE(op.u.getpageframeinfo2.array, arr);
     return do_dom0_op(xc_handle, &op);
 }
 
@@ -191,6 +191,9 @@ int xc_memory_op(int xc_handle,
     struct xen_memory_reservation *reservation = arg;
     struct xen_machphys_mfn_list *xmml = arg;
     struct xen_translate_gpfn_list *trans = arg;
+    unsigned long *extent_start;
+    unsigned long *gpfn_list;
+    unsigned long *mfn_list;
     long ret = -EINVAL;
 
     hypercall.op     = __HYPERVISOR_memory_op;
@@ -207,8 +210,9 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( (reservation->extent_start != NULL) &&
-             (mlock(reservation->extent_start,
+        GET_GUEST_HANDLE(extent_start, reservation->extent_start);
+        if ( (extent_start != NULL) &&
+             (mlock(extent_start,
                     reservation->nr_extents * sizeof(unsigned long)) != 0) )
         {
             PERROR("Could not mlock");
@@ -222,7 +226,8 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( mlock(xmml->extent_start,
+        GET_GUEST_HANDLE(extent_start, reservation->extent_start);
+        if ( mlock(extent_start,
                    xmml->max_extents * sizeof(unsigned long)) != 0 )
         {
             PERROR("Could not mlock");
@@ -243,16 +248,18 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( mlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
+        GET_GUEST_HANDLE(gpfn_list, trans->gpfn_list);
+        if ( mlock(gpfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
         {
             PERROR("Could not mlock");
             safe_munlock(trans, sizeof(*trans));
             goto out1;
         }
-        if ( mlock(trans->mfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
-        {
-            PERROR("Could not mlock");
-            safe_munlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long));
+        GET_GUEST_HANDLE(mfn_list, trans->mfn_list);
+        if ( mlock(mfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
+        {
+            PERROR("Could not mlock");
+            safe_munlock(gpfn_list, trans->nr_gpfns * sizeof(long));
             safe_munlock(trans, sizeof(*trans));
             goto out1;
         }
@@ -267,21 +274,25 @@ int xc_memory_op(int xc_handle,
     case XENMEM_decrease_reservation:
     case XENMEM_populate_physmap:
         safe_munlock(reservation, sizeof(*reservation));
-        if ( reservation->extent_start != NULL )
-            safe_munlock(reservation->extent_start,
+        GET_GUEST_HANDLE(extent_start, reservation->extent_start);
+        if ( extent_start != NULL )
+            safe_munlock(extent_start,
                          reservation->nr_extents * sizeof(unsigned long));
         break;
     case XENMEM_machphys_mfn_list:
         safe_munlock(xmml, sizeof(*xmml));
-        safe_munlock(xmml->extent_start,
+        GET_GUEST_HANDLE(extent_start, reservation->extent_start);
+        safe_munlock(extent_start,
                      xmml->max_extents * sizeof(unsigned long));
         break;
     case XENMEM_add_to_physmap:
         safe_munlock(arg, sizeof(struct xen_add_to_physmap));
         break;
     case XENMEM_translate_gpfn_list:
-            safe_munlock(trans->mfn_list, trans->nr_gpfns * sizeof(long));
-            safe_munlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long));
+            GET_GUEST_HANDLE(mfn_list, trans->mfn_list);
+            safe_munlock(mfn_list, trans->nr_gpfns * sizeof(long));
+            GET_GUEST_HANDLE(gpfn_list, trans->gpfn_list);
+            safe_munlock(gpfn_list, trans->nr_gpfns * sizeof(long));
             safe_munlock(trans, sizeof(*trans));
         break;
     }
@@ -317,7 +328,7 @@ int xc_get_pfn_list(int xc_handle,
     op.cmd = DOM0_GETMEMLIST;
     op.u.getmemlist.domain   = (domid_t)domid;
     op.u.getmemlist.max_pfns = max_pfns;
-    op.u.getmemlist.buffer   = pfn_buf;
+    SET_GUEST_HANDLE(op.u.getmemlist.buffer, pfn_buf);
 
 #ifdef VALGRIND
     memset(pfn_buf, 0, max_pfns * sizeof(unsigned long));
diff -r 56e1802303e5 xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h	Wed Apr 12 15:41:55 2006 -0500
+++ b/xen/include/public/arch-ia64.h	Tue Apr 25 15:17:52 2006 -0500
@@ -7,16 +7,13 @@
 #ifndef __HYPERVISOR_IF_IA64_H__
 #define __HYPERVISOR_IF_IA64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
diff -r 56e1802303e5 xen/include/public/arch-x86_32.h
--- a/xen/include/public/arch-x86_32.h	Wed Apr 12 15:41:55 2006 -0500
+++ b/xen/include/public/arch-x86_32.h	Tue Apr 25 15:17:52 2006 -0500
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
diff -r 56e1802303e5 xen/include/public/arch-x86_64.h
--- a/xen/include/public/arch-x86_64.h	Wed Apr 12 15:41:55 2006 -0500
+++ b/xen/include/public/arch-x86_64.h	Tue Apr 25 15:17:52 2006 -0500
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
 #define __XEN_PUBLIC_ARCH_X86_64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */

[-- Attachment #3: xen-handles-linux-merge.diff --]
[-- Type: text/x-patch, Size: 9448 bytes --]

diff -r 3c49a47b866f arch/i386/kernel/microcode-xen.c
--- a/arch/i386/kernel/microcode-xen.c	Mon Mar 27 18:20:10 2006 +0100
+++ b/arch/i386/kernel/microcode-xen.c	Tue Apr 25 13:17:40 2006 -0500
@@ -70,7 +70,7 @@ static int do_microcode_update (void)
 		return err;
 
 	op.cmd = DOM0_MICROCODE;
-	op.u.microcode.data = user_buffer;
+	SET_GUEST_HANDLE(op.u.microcode.data, user_buffer);
 	op.u.microcode.length = user_buffer_size;
 	err = HYPERVISOR_dom0_op(&op);
 
diff -r 3c49a47b866f arch/i386/kernel/setup-xen.c
--- a/arch/i386/kernel/setup-xen.c	Mon Mar 27 18:20:10 2006 +0100
+++ b/arch/i386/kernel/setup-xen.c	Tue Apr 25 13:17:40 2006 -0500
@@ -1371,7 +1371,7 @@ legacy_init_iomem_resources(struct resou
 #ifdef CONFIG_XEN
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
diff -r 3c49a47b866f arch/i386/mm/hypervisor.c
--- a/arch/i386/mm/hypervisor.c	Mon Mar 27 18:20:10 2006 +0100
+++ b/arch/i386/mm/hypervisor.c	Tue Apr 25 13:17:40 2006 -0500
@@ -271,11 +271,11 @@ int xen_create_contiguous_region(
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	/*
 	 * Currently an auto-translated guest will not perform I/O, nor will
@@ -357,11 +357,11 @@ void xen_destroy_contiguous_region(unsig
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return;
diff -r 3c49a47b866f arch/x86_64/kernel/e820-xen.c
--- a/arch/x86_64/kernel/e820-xen.c	Mon Mar 27 18:20:10 2006 +0100
+++ b/arch/x86_64/kernel/e820-xen.c	Tue Apr 25 13:17:40 2006 -0500
@@ -600,7 +600,7 @@ void __init e820_reserve_resources(void)
 
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
diff -r 3c49a47b866f drivers/xen/balloon/balloon.c
--- a/drivers/xen/balloon/balloon.c	Mon Mar 27 18:20:10 2006 +0100
+++ b/drivers/xen/balloon/balloon.c	Tue Apr 25 13:17:40 2006 -0500
@@ -195,14 +195,14 @@ static int increase_reservation(unsigned
 		page = balloon_next_page(page);
 	}
 
-	reservation.extent_start = frame_list;
+	SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	rc = HYPERVISOR_memory_op(
 		XENMEM_populate_physmap, &reservation);
 	if (rc < nr_pages) {
 		int ret;
 		/* We hit the Xen hard limit: reprobe. */
-		reservation.extent_start = frame_list;
+		SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 		reservation.nr_extents   = rc;
 		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
 				&reservation);
@@ -308,7 +308,7 @@ static int decrease_reservation(unsigned
 		balloon_append(pfn_to_page(pfn));
 	}
 
-	reservation.extent_start = frame_list;
+	SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
 	BUG_ON(ret != nr_pages);
@@ -522,11 +522,11 @@ static int dealloc_pte_fn(
 	unsigned long mfn = pte_mfn(*pte);
 	int ret;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &mfn,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &mfn);
 	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
 	set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
diff -r 3c49a47b866f drivers/xen/core/gnttab.c
--- a/drivers/xen/core/gnttab.c	Mon Mar 27 18:20:10 2006 +0100
+++ b/drivers/xen/core/gnttab.c	Tue Apr 25 13:17:40 2006 -0500
@@ -392,7 +392,7 @@ gnttab_resume(void)
 
 	setup.dom        = DOMID_SELF;
 	setup.nr_frames  = NR_GRANT_FRAMES;
-	setup.frame_list = frames;
+	SET_GUEST_HANDLE(setup.frame_list, frames);
 
 	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
 	BUG_ON(rc || setup.status);
diff -r 3c49a47b866f drivers/xen/netback/netback.c
--- a/drivers/xen/netback/netback.c	Mon Mar 27 18:20:10 2006 +0100
+++ b/drivers/xen/netback/netback.c	Tue Apr 25 13:17:40 2006 -0500
@@ -105,11 +105,11 @@ static unsigned long alloc_mfn(void)
 {
 	unsigned long mfn = 0, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = mfn_list,
 		.nr_extents   = MAX_MFN_ALLOC,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, mfn_list);
 	spin_lock_irqsave(&mfn_lock, flags);
 	if ( unlikely(alloc_index == 0) )
 		alloc_index = HYPERVISOR_memory_op(
diff -r 3c49a47b866f drivers/xen/netfront/netfront.c
--- a/drivers/xen/netfront/netfront.c	Mon Mar 27 18:20:10 2006 +0100
+++ b/drivers/xen/netfront/netfront.c	Tue Apr 25 13:17:40 2006 -0500
@@ -610,7 +610,7 @@ static void network_alloc_rx_buffers(str
 	/* Tell the ballon driver what is going on. */
 	balloon_update_driver_allowance(i);
 
-	reservation.extent_start = np->rx_pfn_array;
+	SET_GUEST_HANDLE(reservation.extent_start, np->rx_pfn_array);
 	reservation.nr_extents   = i;
 	reservation.extent_order = 0;
 	reservation.address_bits = 0;
diff -r 3c49a47b866f include/asm-i386/hypercall.h
--- a/include/asm-i386/hypercall.h	Mon Mar 27 18:20:10 2006 +0100
+++ b/include/asm-i386/hypercall.h	Tue Apr 25 13:17:40 2006 -0500
@@ -189,13 +189,14 @@ HYPERVISOR_poll(
 	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
 {
 	struct sched_poll sched_poll = {
-		.ports = ports,
 		.nr_ports = nr_ports,
 		.timeout = jiffies_to_st(timeout)
 	};
-
-	int rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
-
+	int rc;
+
+	SET_GUEST_HANDLE(sched_poll.ports, ports);
+
+	rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
 	if (rc == -ENOSYS)
 		rc = HYPERVISOR_sched_op(SCHEDOP_yield, 0);
 
diff -r 3c49a47b866f include/xen/interface/arch-ia64.h
--- a/include/xen/interface/arch-ia64.h	Mon Mar 27 18:20:10 2006 +0100
+++ b/include/xen/interface/arch-ia64.h	Tue Apr 25 13:17:40 2006 -0500
@@ -7,16 +7,13 @@
 #ifndef __HYPERVISOR_IF_IA64_H__
 #define __HYPERVISOR_IF_IA64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
diff -r 3c49a47b866f include/xen/interface/arch-x86_32.h
--- a/include/xen/interface/arch-x86_32.h	Mon Mar 27 18:20:10 2006 +0100
+++ b/include/xen/interface/arch-x86_32.h	Tue Apr 25 13:17:40 2006 -0500
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
diff -r 3c49a47b866f include/xen/interface/arch-x86_64.h
--- a/include/xen/interface/arch-x86_64.h	Mon Mar 27 18:20:10 2006 +0100
+++ b/include/xen/interface/arch-x86_64.h	Tue Apr 25 13:17:40 2006 -0500
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
 #define __XEN_PUBLIC_ARCH_X86_64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */

[-- Attachment #4: Type: text/x-patch, Size: 7093 bytes --]

diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c	Tue Apr 25 13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c	Tue Apr 25 15:17:37 2006 -0500
@@ -70,7 +70,7 @@ static int do_microcode_update (void)
 		return err;
 
 	op.cmd = DOM0_MICROCODE;
-	op.u.microcode.data = user_buffer;
+	SET_GUEST_HANDLE(op.u.microcode.data, user_buffer);
 	op.u.microcode.length = user_buffer_size;
 	err = HYPERVISOR_dom0_op(&op);
 
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Tue Apr 25 13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Tue Apr 25 15:17:37 2006 -0500
@@ -1368,7 +1368,7 @@ legacy_init_iomem_resources(struct resou
 #ifdef CONFIG_XEN
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	Tue Apr 25 13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	Tue Apr 25 15:17:37 2006 -0500
@@ -271,11 +271,11 @@ int xen_create_contiguous_region(
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	/*
 	 * Currently an auto-translated guest will not perform I/O, nor will
@@ -357,11 +357,11 @@ void xen_destroy_contiguous_region(unsig
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return;
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c	Tue Apr 25 13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c	Tue Apr 25 15:17:37 2006 -0500
@@ -600,7 +600,7 @@ void __init e820_reserve_resources(void)
 
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Tue Apr 25 13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Tue Apr 25 15:17:37 2006 -0500
@@ -195,14 +195,14 @@ static int increase_reservation(unsigned
 		page = balloon_next_page(page);
 	}
 
-	reservation.extent_start = frame_list;
+	SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	rc = HYPERVISOR_memory_op(
 		XENMEM_populate_physmap, &reservation);
 	if (rc < nr_pages) {
 		int ret;
 		/* We hit the Xen hard limit: reprobe. */
-		reservation.extent_start = frame_list;
+		SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 		reservation.nr_extents   = rc;
 		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
 				&reservation);
@@ -308,7 +308,7 @@ static int decrease_reservation(unsigned
 		balloon_append(pfn_to_page(pfn));
 	}
 
-	reservation.extent_start = frame_list;
+	SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
 	BUG_ON(ret != nr_pages);
@@ -522,11 +522,11 @@ static int dealloc_pte_fn(
 	unsigned long mfn = pte_mfn(*pte);
 	int ret;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &mfn,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &mfn);
 	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
 	set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Tue Apr 25 13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Tue Apr 25 15:17:37 2006 -0500
@@ -392,7 +392,7 @@ gnttab_resume(void)
 
 	setup.dom        = DOMID_SELF;
 	setup.nr_frames  = NR_GRANT_FRAMES;
-	setup.frame_list = frames;
+	SET_GUEST_HANDLE(setup.frame_list, frames);
 
 	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
 	if (rc == -ENOSYS)
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Apr 25 13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Apr 25 15:17:37 2006 -0500
@@ -105,11 +105,11 @@ static unsigned long alloc_mfn(void)
 {
 	unsigned long mfn = 0, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = mfn_list,
 		.nr_extents   = MAX_MFN_ALLOC,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, mfn_list);
 	spin_lock_irqsave(&mfn_lock, flags);
 	if ( unlikely(alloc_index == 0) )
 		alloc_index = HYPERVISOR_memory_op(
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Apr 25 13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Apr 25 15:17:37 2006 -0500
@@ -610,7 +610,7 @@ static void network_alloc_rx_buffers(str
 	/* Tell the ballon driver what is going on. */
 	balloon_update_driver_allowance(i);
 
-	reservation.extent_start = np->rx_pfn_array;
+	SET_GUEST_HANDLE(reservation.extent_start, np->rx_pfn_array);
 	reservation.nr_extents   = i;
 	reservation.extent_order = 0;
 	reservation.address_bits = 0;
diff -r 61d8ff110da9 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Tue Apr 25 13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Tue Apr 25 15:17:37 2006 -0500
@@ -163,13 +163,14 @@ HYPERVISOR_poll(
 	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
 {
 	struct sched_poll sched_poll = {
-		.ports = ports,
 		.nr_ports = nr_ports,
 		.timeout = jiffies_to_st(timeout)
 	};
-
-	int rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
-
+    int rc;
+
+	SET_GUEST_HANDLE(sched_poll.ports, ports);
+
+	rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
 	if (rc == -ENOSYS)
 		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
 

[-- Attachment #5: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 13%]

* [PATCH] privcmd_ioctl() clean up for xen/ia64
@ 2006-04-26  3:25  7% Isaku Yamahata
  0 siblings, 0 replies; 200+ results
From: Isaku Yamahata @ 2006-04-26  3:25 UTC (permalink / raw)
  To: xen-devel; +Cc: xen-ia64-devel

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]


introduce xen_arch_privcmd_mmap() to override privcmd_mmap()
This will be defined by xen/ia64 with dom0 vp model.
IOCTL_PRIVCMD_MMAPBATCH clean up.
xen/ia64 with dom0 vp model needs direct_remap_pfn_range() to be called
for IOCTL_PRIVCMD_MMAPBATCH.

-- 
yamahata

[-- Attachment #2: 9745:83baf855f331_xen_arch_privcmd_mmap.patch --]
[-- Type: text/plain, Size: 2851 bytes --]

# HG changeset patch
# User yamahata@valinux.co.jp
# Node ID 83baf855f331951bcd74ffaf6cd83ca3a2c23131
# Parent  1ad06bd6832d478b18b1c1aed9886079c272aeaa
introduce xen_arch_privcmd_mmap() to override privcmd_mmap()
This will be defined by xen/ia64 with dom0 vp model.
IOCTL_PRIVCMD_MMAPBATCH clean up.
xen/ia64 with dom0 vp model needs direct_remap_pfn_range() to be called
for IOCTL_PRIVCMD_MMAPBATCH.
PATCHNAME: xen_arch_privcmd_mmap

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

diff -r 1ad06bd6832d -r 83baf855f331 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Tue Apr 25 18:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Wed Apr 26 12:21:31 2006 +0900
@@ -159,12 +159,14 @@ static int privcmd_ioctl(struct inode *i
 	break;
 
 	case IOCTL_PRIVCMD_MMAPBATCH: {
+#ifndef __ia64__
 		mmu_update_t u;
+		uint64_t ptep;
+#endif
 		privcmd_mmapbatch_t m;
 		struct vm_area_struct *vma = NULL;
 		unsigned long __user *p;
 		unsigned long addr, mfn; 
-		uint64_t ptep;
 		int i;
 
 		if (copy_from_user(&m, udata, sizeof(m))) {
@@ -199,11 +201,9 @@ static int privcmd_ioctl(struct inode *i
 			if (get_user(mfn, p))
 				return -EFAULT;
 #ifdef __ia64__
-			ret = remap_pfn_range(vma,
-					      addr&PAGE_MASK,
-					      mfn,
-					      1<<PAGE_SHIFT,
-					      vma->vm_page_prot);
+			ret = direct_remap_pfn_range(vma, addr & PAGE_MASK,
+						     mfn, 1 << PAGE_SHIFT,
+						     vma->vm_page_prot, m.dom);
 			if (ret < 0)
 			    goto batch_err;
 #else
@@ -246,7 +246,7 @@ static int privcmd_mmap(struct file * fi
 	/* DONTCOPY is essential for Xen as copy_page_range is broken. */
 	vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY;
 
-	return 0;
+	return xen_arch_privcmd_mmap(file, vma);
 }
 
 static struct file_operations privcmd_file_ops = {
diff -r 1ad06bd6832d -r 83baf855f331 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Tue Apr 25 18:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Wed Apr 26 12:21:31 2006 +0900
@@ -117,6 +117,7 @@ u64 jiffies_to_st(unsigned long jiffies)
 #endif
 
 #define xen_init()	(0)
+#define xen_arch_privcmd_mmap(file, vma)	(0)
 
 static inline int
 HYPERVISOR_yield(
diff -r 1ad06bd6832d -r 83baf855f331 linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Tue Apr 25 18:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Wed Apr 26 12:21:31 2006 +0900
@@ -119,6 +119,7 @@ HYPERVISOR_poll(
 #define	pfn_to_mfn(x)	(x)
 #define	mfn_to_pfn(x)	(x)
 #define machine_to_phys_mapping 0
+#define xen_arch_privcmd_mmap(file, vma)	(0)
 
 // for drivers/xen/balloon/balloon.c
 #ifdef CONFIG_XEN_SCRUB_PAGES

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 7%]

* Re: [patch] 32/64-bit hypercall interface revisited
  @ 2006-04-26 21:38  9%           ` Hollis Blanchard
  0 siblings, 0 replies; 200+ results
From: Hollis Blanchard @ 2006-04-26 21:38 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1939 bytes --]

On Wed, 2006-04-26 at 08:50 +0100, Keir Fraser wrote:
> On 25 Apr 2006, at 21:24, Hollis Blanchard wrote:
> 
> >> This patch will unconditionally use the 'structural' definition of
> >> guest handles for tools and kernels as well as Xen, right? Can 
> >> XenLinux
> >> for x86/ia64 still build with this patch, without needing a bunch of
> >> GET/SET_GUEST_HANDLE changes?
> >
> > Sorry, you're right. Attached are three patches: the Xen patch, the
> > linux-2.6-merge patch, and the linux-2.6-sparse patch.
> 
> This looks basically acceptable except....
> 
> Christian suggested providing GET/SET_XEN_GUEST_HANDLE(), for use at 
> least in the Linux patches. These could be defined in xen.h after 
> including arch-foo.h and simply invoke the arch-defined macros.
> 
> Alternatively we could simply change the names of all the macros to 
> ...XEN_GUEST_HANDLE, and use the new names everywhere. I think that 
> would be okay as the names aren't that much longer and they aren't used 
> *that* often outside header files anyway. It'll make the patch a lot 
> bigger, but most of it'll be search-replace. And XEN_GUEST is more 
> informative than GUEST.

Fine with me. I've split the global rename into a separate patch.

> I don't think there's a need to send a patch for the merge tree -- 
> Christian pulls unstable patches into that in a half-automated way.

Ok.

> Also, no need to use GET_GUEST_HANDLE() in the libxc's read_console 
> function. Xen will never update the buffer pointer these days -- it 
> always fills the buffer from the start. When we eventually kill the 
> mlock() crap and implement it properly, I think GET_GUEST_HANDLE() can 
> be killed off entirely.

That's fine, but I would like to avoid changing any behavior with these
patch. If you want to remove that, you're welcome to...

These patches have been compile-tested (Xen, libxc, sparse Linux) on
x86(32).

-- 
Hollis Blanchard
IBM Linux Technology Center

[-- Attachment #2: xen-rename-GUEST-to-XEN_GUEST.diff --]
[-- Type: text/x-patch, Size: 52158 bytes --]

Rename *GUEST_HANDLE to *XEN_GUEST_HANDLE.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

diff -r 1d69cff40b8c xen/arch/ia64/xen/dom0_ops.c
--- a/xen/arch/ia64/xen/dom0_ops.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/ia64/xen/dom0_ops.c	Wed Apr 26 16:11:21 2006 -0500
@@ -20,7 +20,7 @@
 #include <public/sched_ctl.h>
 #include <asm/vmx.h>
 
-long arch_do_dom0_op(dom0_op_t *op, GUEST_HANDLE(dom0_op_t) u_dom0_op)
+long arch_do_dom0_op(dom0_op_t *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
 {
     long ret = 0;
 
diff -r 1d69cff40b8c xen/arch/x86/dom0_ops.c
--- a/xen/arch/x86/dom0_ops.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/x86/dom0_ops.c	Wed Apr 26 16:11:21 2006 -0500
@@ -49,7 +49,7 @@ static void read_msr_for(void *unused)
         (void)rdmsr_safe(msr_addr, msr_lo, msr_hi);
 }
 
-long arch_do_dom0_op(struct dom0_op *op, GUEST_HANDLE(dom0_op_t) u_dom0_op)
+long arch_do_dom0_op(struct dom0_op *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
 {
     long ret = 0;
 
diff -r 1d69cff40b8c xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/x86/domain.c	Wed Apr 26 16:11:21 2006 -0500
@@ -364,7 +364,7 @@ int arch_set_info_guest(
 
 long
 arch_do_vcpu_op(
-    int cmd, struct vcpu *v, GUEST_HANDLE(void) arg)
+    int cmd, struct vcpu *v, XEN_GUEST_HANDLE(void) arg)
 {
     long rc = 0;
 
diff -r 1d69cff40b8c xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/x86/mm.c	Wed Apr 26 16:11:21 2006 -0500
@@ -1757,9 +1757,9 @@ static inline cpumask_t vcpumask_to_pcpu
 }
 
 int do_mmuext_op(
-    GUEST_HANDLE(mmuext_op_t) uops,
+    XEN_GUEST_HANDLE(mmuext_op_t) uops,
     unsigned int count,
-    GUEST_HANDLE(uint) pdone,
+    XEN_GUEST_HANDLE(uint) pdone,
     unsigned int foreigndom)
 {
     struct mmuext_op op;
@@ -2007,9 +2007,9 @@ int do_mmuext_op(
 }
 
 int do_mmu_update(
-    GUEST_HANDLE(mmu_update_t) ureqs,
+    XEN_GUEST_HANDLE(mmu_update_t) ureqs,
     unsigned int count,
-    GUEST_HANDLE(uint) pdone,
+    XEN_GUEST_HANDLE(uint) pdone,
     unsigned int foreigndom)
 {
     struct mmu_update req;
@@ -2708,7 +2708,7 @@ long set_gdt(struct vcpu *v,
 }
 
 
-long do_set_gdt(GUEST_HANDLE(ulong) frame_list, unsigned int entries)
+long do_set_gdt(XEN_GUEST_HANDLE(ulong) frame_list, unsigned int entries)
 {
     int nr_pages = (entries + 511) / 512;
     unsigned long frames[16];
@@ -2812,7 +2812,7 @@ long do_update_descriptor(u64 pa, u64 de
 }
 
 
-long arch_memory_op(int op, GUEST_HANDLE(void) arg)
+long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
     switch ( op )
     {
diff -r 1d69cff40b8c xen/arch/x86/oprofile/xenoprof.c
--- a/xen/arch/x86/oprofile/xenoprof.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/x86/oprofile/xenoprof.c	Wed Apr 26 16:11:21 2006 -0500
@@ -349,7 +349,7 @@ void free_xenoprof_pages(struct domain *
     d->xenoprof = NULL;
 }
 
-int xenoprof_op_init(GUEST_HANDLE(void) arg)
+int xenoprof_op_init(XEN_GUEST_HANDLE(void) arg)
 {
     struct xenoprof_init xenoprof_init;
     int is_primary, num_events;
@@ -410,7 +410,7 @@ int xenoprof_op_init(GUEST_HANDLE(void) 
                    || (op == XENOPROF_release_counters) \
                    || (op == XENOPROF_shutdown))
 
-int do_xenoprof_op(int op, GUEST_HANDLE(void) arg)
+int do_xenoprof_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
     int ret = 0;
 
diff -r 1d69cff40b8c xen/arch/x86/physdev.c
--- a/xen/arch/x86/physdev.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/x86/physdev.c	Wed Apr 26 16:11:21 2006 -0500
@@ -25,7 +25,7 @@ pirq_acktype(
 /*
  * Demuxing hypercall.
  */
-long do_physdev_op(GUEST_HANDLE(physdev_op_t) uop)
+long do_physdev_op(XEN_GUEST_HANDLE(physdev_op_t) uop)
 {
     struct physdev_op op;
     long ret;
diff -r 1d69cff40b8c xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/x86/traps.c	Wed Apr 26 16:11:21 2006 -0500
@@ -1535,7 +1535,7 @@ void __init trap_init(void)
 }
 
 
-long do_set_trap_table(GUEST_HANDLE(trap_info_t) traps)
+long do_set_trap_table(XEN_GUEST_HANDLE(trap_info_t) traps)
 {
     struct trap_info cur;
     struct trap_info *dst = current->arch.guest_context.trap_ctxt;
diff -r 1d69cff40b8c xen/arch/x86/x86_32/mm.c
--- a/xen/arch/x86/x86_32/mm.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/x86/x86_32/mm.c	Wed Apr 26 16:11:21 2006 -0500
@@ -189,7 +189,7 @@ void subarch_init_memory(void)
     }
 }
 
-long subarch_memory_op(int op, GUEST_HANDLE(void) arg)
+long subarch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
     struct xen_machphys_mfn_list xmml;
     unsigned long mfn;
diff -r 1d69cff40b8c xen/arch/x86/x86_32/traps.c
--- a/xen/arch/x86/x86_32/traps.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/x86/x86_32/traps.c	Wed Apr 26 16:11:21 2006 -0500
@@ -387,7 +387,7 @@ static long unregister_guest_callback(st
 }
 
 
-long do_callback_op(int cmd, GUEST_HANDLE(void) arg)
+long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     long ret;
 
diff -r 1d69cff40b8c xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/x86/x86_64/mm.c	Wed Apr 26 16:11:21 2006 -0500
@@ -181,7 +181,7 @@ void subarch_init_memory(void)
     }
 }
 
-long subarch_memory_op(int op, GUEST_HANDLE(void) arg)
+long subarch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
     struct xen_machphys_mfn_list xmml;
     l3_pgentry_t l3e;
diff -r 1d69cff40b8c xen/arch/x86/x86_64/traps.c
--- a/xen/arch/x86/x86_64/traps.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/arch/x86/x86_64/traps.c	Wed Apr 26 16:11:21 2006 -0500
@@ -371,7 +371,7 @@ static long unregister_guest_callback(st
 }
 
 
-long do_callback_op(int cmd, GUEST_HANDLE(void) arg)
+long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     long ret;
 
diff -r 1d69cff40b8c xen/common/acm_ops.c
--- a/xen/common/acm_ops.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/common/acm_ops.c	Wed Apr 26 16:11:21 2006 -0500
@@ -32,7 +32,7 @@
 
 #ifndef ACM_SECURITY
 
-long do_acm_op(GUEST_HANDLE(acm_op_t) u_acm_op)
+long do_acm_op(XEN_GUEST_HANDLE(acm_op_t) u_acm_op)
 {
     return -ENOSYS;
 }
@@ -57,7 +57,7 @@ int acm_authorize_acm_ops(struct domain 
     return 0;
 }
 
-long do_acm_op(GUEST_HANDLE(acm_op_t) u_acm_op)
+long do_acm_op(XEN_GUEST_HANDLE(acm_op_t) u_acm_op)
 {
     long ret = 0;
     struct acm_op curop, *op = &curop;
diff -r 1d69cff40b8c xen/common/dom0_ops.c
--- a/xen/common/dom0_ops.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/common/dom0_ops.c	Wed Apr 26 16:11:21 2006 -0500
@@ -24,7 +24,7 @@
 #include <acm/acm_hooks.h>
 
 extern long arch_do_dom0_op(
-    struct dom0_op *op, GUEST_HANDLE(dom0_op_t) u_dom0_op);
+    struct dom0_op *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op);
 extern void arch_getdomaininfo_ctxt(
     struct vcpu *, struct vcpu_guest_context *);
 
@@ -90,7 +90,7 @@ static void getdomaininfo(struct domain 
     memcpy(info->handle, d->handle, sizeof(xen_domain_handle_t));
 }
 
-long do_dom0_op(GUEST_HANDLE(dom0_op_t) u_dom0_op)
+long do_dom0_op(XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
 {
     long ret = 0;
     struct dom0_op curop, *op = &curop;
diff -r 1d69cff40b8c xen/common/domain.c
--- a/xen/common/domain.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/common/domain.c	Wed Apr 26 16:11:21 2006 -0500
@@ -408,7 +408,7 @@ int boot_vcpu(struct domain *d, int vcpu
     return arch_set_info_guest(v, ctxt);
 }
 
-long do_vcpu_op(int cmd, int vcpuid, GUEST_HANDLE(void) arg)
+long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
 {
     struct domain *d = current->domain;
     struct vcpu *v;
diff -r 1d69cff40b8c xen/common/event_channel.c
--- a/xen/common/event_channel.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/common/event_channel.c	Wed Apr 26 16:11:21 2006 -0500
@@ -683,7 +683,7 @@ static long evtchn_unmask(evtchn_unmask_
 }
 
 
-long do_event_channel_op(GUEST_HANDLE(evtchn_op_t) uop)
+long do_event_channel_op(XEN_GUEST_HANDLE(evtchn_op_t) uop)
 {
     long rc;
     struct evtchn_op op;
diff -r 1d69cff40b8c xen/common/grant_table.c
--- a/xen/common/grant_table.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/common/grant_table.c	Wed Apr 26 16:11:21 2006 -0500
@@ -301,7 +301,7 @@ __gnttab_map_grant_ref(
 
 static long
 gnttab_map_grant_ref(
-    GUEST_HANDLE(gnttab_map_grant_ref_t) uop, unsigned int count)
+    XEN_GUEST_HANDLE(gnttab_map_grant_ref_t) uop, unsigned int count)
 {
     int i;
     struct gnttab_map_grant_ref op;
@@ -438,7 +438,7 @@ __gnttab_unmap_grant_ref(
 
 static long
 gnttab_unmap_grant_ref(
-    GUEST_HANDLE(gnttab_unmap_grant_ref_t) uop, unsigned int count)
+    XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t) uop, unsigned int count)
 {
     int i;
     struct gnttab_unmap_grant_ref op;
@@ -462,7 +462,7 @@ fault:
 
 static long 
 gnttab_setup_table(
-    GUEST_HANDLE(gnttab_setup_table_t) uop, unsigned int count)
+    XEN_GUEST_HANDLE(gnttab_setup_table_t) uop, unsigned int count)
 {
     struct gnttab_setup_table op;
     struct domain *d;
@@ -598,7 +598,7 @@ gnttab_prepare_for_transfer(
 
 static long
 gnttab_transfer(
-    GUEST_HANDLE(gnttab_transfer_t) uop, unsigned int count)
+    XEN_GUEST_HANDLE(gnttab_transfer_t) uop, unsigned int count)
 {
     struct domain *d = current->domain;
     struct domain *e;
@@ -711,7 +711,7 @@ gnttab_transfer(
 
 long
 do_grant_table_op(
-    unsigned int cmd, GUEST_HANDLE(void) uop, unsigned int count)
+    unsigned int cmd, XEN_GUEST_HANDLE(void) uop, unsigned int count)
 {
     long rc;
     struct domain *d = current->domain;
@@ -728,7 +728,7 @@ do_grant_table_op(
     {
     case GNTTABOP_map_grant_ref:
     {
-        GUEST_HANDLE(gnttab_map_grant_ref_t) map =
+        XEN_GUEST_HANDLE(gnttab_map_grant_ref_t) map =
             guest_handle_cast(uop, gnttab_map_grant_ref_t);
         if ( unlikely(!guest_handle_okay(map, count)) )
             goto out;
@@ -737,7 +737,7 @@ do_grant_table_op(
     }
     case GNTTABOP_unmap_grant_ref:
     {
-        GUEST_HANDLE(gnttab_unmap_grant_ref_t) unmap =
+        XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t) unmap =
             guest_handle_cast(uop, gnttab_unmap_grant_ref_t);
         if ( unlikely(!guest_handle_okay(unmap, count)) )
             goto out;
@@ -752,7 +752,7 @@ do_grant_table_op(
     }
     case GNTTABOP_transfer:
     {
-        GUEST_HANDLE(gnttab_transfer_t) transfer =
+        XEN_GUEST_HANDLE(gnttab_transfer_t) transfer =
             guest_handle_cast(uop, gnttab_transfer_t);
         if ( unlikely(!guest_handle_okay(transfer, count)) )
             goto out;
diff -r 1d69cff40b8c xen/common/kernel.c
--- a/xen/common/kernel.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/common/kernel.c	Wed Apr 26 16:11:21 2006 -0500
@@ -118,7 +118,7 @@ void add_taint(unsigned flag)
  * Simple hypercalls.
  */
 
-long do_xen_version(int cmd, GUEST_HANDLE(void) arg)
+long do_xen_version(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     switch ( cmd )
     {
@@ -244,7 +244,7 @@ long unregister_guest_nmi_callback(void)
     return 0;
 }
 
-long do_nmi_op(unsigned int cmd, GUEST_HANDLE(void) arg)
+long do_nmi_op(unsigned int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     struct xennmi_callback cb;
     long rc = 0;
diff -r 1d69cff40b8c xen/common/memory.c
--- a/xen/common/memory.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/common/memory.c	Wed Apr 26 16:11:21 2006 -0500
@@ -31,7 +31,7 @@ static long
 static long
 increase_reservation(
     struct domain *d, 
-    GUEST_HANDLE(ulong) extent_list,
+    XEN_GUEST_HANDLE(ulong) extent_list,
     unsigned int   nr_extents,
     unsigned int   extent_order,
     unsigned int   flags,
@@ -80,7 +80,7 @@ static long
 static long
 populate_physmap(
     struct domain *d, 
-    GUEST_HANDLE(ulong) extent_list,
+    XEN_GUEST_HANDLE(ulong) extent_list,
     unsigned int  nr_extents,
     unsigned int  extent_order,
     unsigned int  flags,
@@ -177,7 +177,7 @@ static long
 static long
 decrease_reservation(
     struct domain *d,
-    GUEST_HANDLE(ulong) extent_list,
+    XEN_GUEST_HANDLE(ulong) extent_list,
     unsigned int   nr_extents,
     unsigned int   extent_order,
     unsigned int   flags,
@@ -211,7 +211,7 @@ decrease_reservation(
 
 static long
 translate_gpfn_list(
-    GUEST_HANDLE(xen_translate_gpfn_list_t) uop, unsigned long *progress)
+    XEN_GUEST_HANDLE(xen_translate_gpfn_list_t) uop, unsigned long *progress)
 {
     struct xen_translate_gpfn_list op;
     unsigned long i, gpfn, mfn;
@@ -270,7 +270,7 @@ translate_gpfn_list(
     return 0;
 }
 
-long do_memory_op(unsigned long cmd, GUEST_HANDLE(void) arg)
+long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE(void) arg)
 {
     struct domain *d;
     int rc, op, flags = 0, preempted = 0;
diff -r 1d69cff40b8c xen/common/multicall.c
--- a/xen/common/multicall.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/common/multicall.c	Wed Apr 26 16:11:21 2006 -0500
@@ -18,7 +18,7 @@ struct mc_state mc_state[NR_CPUS];
 
 long
 do_multicall(
-    GUEST_HANDLE(multicall_entry_t) call_list, unsigned int nr_calls)
+    XEN_GUEST_HANDLE(multicall_entry_t) call_list, unsigned int nr_calls)
 {
     struct mc_state *mcs = &mc_state[smp_processor_id()];
     unsigned int     i;
diff -r 1d69cff40b8c xen/common/perfc.c
--- a/xen/common/perfc.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/common/perfc.c	Wed Apr 26 16:11:21 2006 -0500
@@ -131,7 +131,7 @@ void perfc_reset(unsigned char key)
 
 static dom0_perfc_desc_t perfc_d[NR_PERFCTRS];
 static int               perfc_init = 0;
-static int perfc_copy_info(GUEST_HANDLE(dom0_perfc_desc_t) desc)
+static int perfc_copy_info(XEN_GUEST_HANDLE(dom0_perfc_desc_t) desc)
 {
     unsigned int i, j;
     atomic_t *counters = (atomic_t *)&perfcounters;
diff -r 1d69cff40b8c xen/common/schedule.c
--- a/xen/common/schedule.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/common/schedule.c	Wed Apr 26 16:11:21 2006 -0500
@@ -365,7 +365,7 @@ long do_sched_op_compat(int cmd, unsigne
     return ret;
 }
 
-long do_sched_op(int cmd, GUEST_HANDLE(void) arg)
+long do_sched_op(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     long ret = 0;
 
diff -r 1d69cff40b8c xen/drivers/char/console.c
--- a/xen/drivers/char/console.c	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/drivers/char/console.c	Wed Apr 26 16:11:21 2006 -0500
@@ -221,7 +221,7 @@ static void putchar_console_ring(int c)
         conringc = conringp - CONRING_SIZE;
 }
 
-long read_console_ring(GUEST_HANDLE(char) str, u32 *pcount, int clear)
+long read_console_ring(XEN_GUEST_HANDLE(char) str, u32 *pcount, int clear)
 {
     unsigned int idx, len, max, sofar, c;
     unsigned long flags;
@@ -319,7 +319,7 @@ static void serial_rx(char c, struct cpu
     __serial_rx(c, regs);
 }
 
-static long guest_console_write(GUEST_HANDLE(char) buffer, int count)
+static long guest_console_write(XEN_GUEST_HANDLE(char) buffer, int count)
 {
     char kbuf[128], *kptr;
     int kcount;
@@ -355,7 +355,7 @@ static long guest_console_write(GUEST_HA
     return 0;
 }
 
-long do_console_io(int cmd, int count, GUEST_HANDLE(char) buffer)
+long do_console_io(int cmd, int count, XEN_GUEST_HANDLE(char) buffer)
 {
     long rc;
     unsigned int idx, len;
diff -r 1d69cff40b8c xen/include/asm-ia64/guest_access.h
--- a/xen/include/asm-ia64/guest_access.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/asm-ia64/guest_access.h	Wed Apr 26 16:11:21 2006 -0500
@@ -18,10 +18,10 @@
 /* Cast a guest handle to the specified type of handle. */
 #define guest_handle_cast(hnd, type) ({         \
     type *_x = (hnd).p;                         \
-    (GUEST_HANDLE(type)) { _x };                \
+    (XEN_GUEST_HANDLE(type)) { _x };                \
 })
 
-#define guest_handle_from_ptr(ptr, type) ((GUEST_HANDLE(type)) { (type *)ptr })
+#define guest_handle_from_ptr(ptr, type) ((XEN_GUEST_HANDLE(type)) { (type *)ptr })
 
 /*
  * Copy an array of objects to guest context via a guest handle,
diff -r 1d69cff40b8c xen/include/asm-x86/guest_access.h
--- a/xen/include/asm-x86/guest_access.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/asm-x86/guest_access.h	Wed Apr 26 16:11:21 2006 -0500
@@ -18,7 +18,7 @@
 /* Cast a guest handle to the specified type of handle. */
 #define guest_handle_cast(hnd, type) ({         \
     type *_x = (hnd).p;                         \
-    (GUEST_HANDLE(type)) { _x };                \
+    (XEN_GUEST_HANDLE(type)) { _x };                \
 })
 
 /*
diff -r 1d69cff40b8c xen/include/asm-x86/hypercall.h
--- a/xen/include/asm-x86/hypercall.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/asm-x86/hypercall.h	Wed Apr 26 16:11:21 2006 -0500
@@ -9,18 +9,18 @@
 
 extern long
 do_set_trap_table(
-    GUEST_HANDLE(trap_info_t) traps);
+    XEN_GUEST_HANDLE(trap_info_t) traps);
 
 extern int
 do_mmu_update(
-    GUEST_HANDLE(mmu_update_t) ureqs,
+    XEN_GUEST_HANDLE(mmu_update_t) ureqs,
     unsigned int count,
-    GUEST_HANDLE(uint) pdone,
+    XEN_GUEST_HANDLE(uint) pdone,
     unsigned int foreigndom);
 
 extern long
 do_set_gdt(
-    GUEST_HANDLE(ulong) frame_list,
+    XEN_GUEST_HANDLE(ulong) frame_list,
     unsigned int entries);
 
 extern long
@@ -54,7 +54,7 @@ do_update_va_mapping(
 
 extern long
 do_physdev_op(
-    GUEST_HANDLE(physdev_op_t) uop);
+    XEN_GUEST_HANDLE(physdev_op_t) uop);
 
 extern int
 do_update_va_mapping_otherdomain(
@@ -65,9 +65,9 @@ do_update_va_mapping_otherdomain(
 
 extern int
 do_mmuext_op(
-    GUEST_HANDLE(mmuext_op_t) uops,
+    XEN_GUEST_HANDLE(mmuext_op_t) uops,
     unsigned int count,
-    GUEST_HANDLE(uint) pdone,
+    XEN_GUEST_HANDLE(uint) pdone,
     unsigned int foreigndom);
 
 extern unsigned long
@@ -77,7 +77,7 @@ struct vcpu;
 struct vcpu;
 extern long
 arch_do_vcpu_op(
-    int cmd, struct vcpu *v, GUEST_HANDLE(void) arg);
+    int cmd, struct vcpu *v, XEN_GUEST_HANDLE(void) arg);
 
 #ifdef __x86_64__
 
diff -r 1d69cff40b8c xen/include/asm-x86/mm.h
--- a/xen/include/asm-x86/mm.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/asm-x86/mm.h	Wed Apr 26 16:11:21 2006 -0500
@@ -382,7 +382,7 @@ int __sync_lazy_execstate(void);
 int __sync_lazy_execstate(void);
 
 /* Arch-specific portion of memory_op hypercall. */
-long arch_memory_op(int op, GUEST_HANDLE(void) arg);
-long subarch_memory_op(int op, GUEST_HANDLE(void) arg);
+long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg);
+long subarch_memory_op(int op, XEN_GUEST_HANDLE(void) arg);
 
 #endif /* __ASM_X86_MM_H__ */
diff -r 1d69cff40b8c xen/include/public/acm_ops.h
--- a/xen/include/public/acm_ops.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/acm_ops.h	Wed Apr 26 16:11:21 2006 -0500
@@ -83,7 +83,7 @@ typedef struct acm_op {
         struct acm_getdecision getdecision;
     } u;
 } acm_op_t;
-DEFINE_GUEST_HANDLE(acm_op_t);
+DEFINE_XEN_GUEST_HANDLE(acm_op_t);
 
 #endif                          /* __XEN_PUBLIC_ACM_OPS_H__ */
 
diff -r 1d69cff40b8c xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/arch-ia64.h	Wed Apr 26 16:11:21 2006 -0500
@@ -8,25 +8,25 @@
 #define __HYPERVISOR_IF_IA64_H__
 
 #ifdef __XEN__
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
 #else
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef type * __guest_handle_ ## name
 #endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
-__DEFINE_GUEST_HANDLE(uchar, unsigned char);
-__DEFINE_GUEST_HANDLE(uint,  unsigned int);
-__DEFINE_GUEST_HANDLE(ulong, unsigned long);
-DEFINE_GUEST_HANDLE(char);
-DEFINE_GUEST_HANDLE(int);
-DEFINE_GUEST_HANDLE(long);
-DEFINE_GUEST_HANDLE(void);
+__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
+__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
+__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
+DEFINE_XEN_GUEST_HANDLE(char);
+DEFINE_XEN_GUEST_HANDLE(int);
+DEFINE_XEN_GUEST_HANDLE(long);
+DEFINE_XEN_GUEST_HANDLE(void);
 #endif
 
 /* Maximum number of virtual CPUs in multi-processor guests. */
@@ -320,7 +320,7 @@ typedef struct vcpu_guest_context {
     arch_initrd_info_t initrd;
     char cmdline[IA64_COMMAND_LINE_SIZE];
 } vcpu_guest_context_t;
-DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
+DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
 
 #endif /* !__ASSEMBLY__ */
 
diff -r 1d69cff40b8c xen/include/public/arch-x86_32.h
--- a/xen/include/public/arch-x86_32.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/arch-x86_32.h	Wed Apr 26 16:11:21 2006 -0500
@@ -10,25 +10,25 @@
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
 #ifdef __XEN__
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
 #else
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef type * __guest_handle_ ## name
 #endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
-__DEFINE_GUEST_HANDLE(uchar, unsigned char);
-__DEFINE_GUEST_HANDLE(uint,  unsigned int);
-__DEFINE_GUEST_HANDLE(ulong, unsigned long);
-DEFINE_GUEST_HANDLE(char);
-DEFINE_GUEST_HANDLE(int);
-DEFINE_GUEST_HANDLE(long);
-DEFINE_GUEST_HANDLE(void);
+__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
+__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
+__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
+DEFINE_XEN_GUEST_HANDLE(char);
+DEFINE_XEN_GUEST_HANDLE(int);
+DEFINE_XEN_GUEST_HANDLE(long);
+DEFINE_XEN_GUEST_HANDLE(void);
 #endif
 
 /*
@@ -102,7 +102,7 @@ typedef struct trap_info {
     uint16_t      cs;      /* code selector                                 */
     unsigned long address; /* code offset                                   */
 } trap_info_t;
-DEFINE_GUEST_HANDLE(trap_info_t);
+DEFINE_XEN_GUEST_HANDLE(trap_info_t);
 
 typedef struct cpu_user_regs {
     uint32_t ebx;
@@ -126,7 +126,7 @@ typedef struct cpu_user_regs {
     uint16_t fs, _pad4;
     uint16_t gs, _pad5;
 } cpu_user_regs_t;
-DEFINE_GUEST_HANDLE(cpu_user_regs_t);
+DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
 
 typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
 
@@ -154,7 +154,7 @@ typedef struct vcpu_guest_context {
     unsigned long failsafe_callback_eip;
     unsigned long vm_assist;                /* VMASST_TYPE_* bitmap */
 } vcpu_guest_context_t;
-DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
+DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
 
 typedef struct arch_shared_info {
     unsigned long max_pfn;                  /* max pfn that appears in table */
diff -r 1d69cff40b8c xen/include/public/arch-x86_64.h
--- a/xen/include/public/arch-x86_64.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/arch-x86_64.h	Wed Apr 26 16:11:21 2006 -0500
@@ -10,25 +10,25 @@
 #define __XEN_PUBLIC_ARCH_X86_64_H__
 
 #ifdef __XEN__
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
 #else
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef type * __guest_handle_ ## name
 #endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
-__DEFINE_GUEST_HANDLE(uchar, unsigned char);
-__DEFINE_GUEST_HANDLE(uint,  unsigned int);
-__DEFINE_GUEST_HANDLE(ulong, unsigned long);
-DEFINE_GUEST_HANDLE(char);
-DEFINE_GUEST_HANDLE(int);
-DEFINE_GUEST_HANDLE(long);
-DEFINE_GUEST_HANDLE(void);
+__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
+__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
+__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
+DEFINE_XEN_GUEST_HANDLE(char);
+DEFINE_XEN_GUEST_HANDLE(int);
+DEFINE_XEN_GUEST_HANDLE(long);
+DEFINE_XEN_GUEST_HANDLE(void);
 #endif
 
 /*
@@ -157,7 +157,7 @@ typedef struct trap_info {
     uint16_t      cs;      /* code selector                                 */
     unsigned long address; /* code offset                                   */
 } trap_info_t;
-DEFINE_GUEST_HANDLE(trap_info_t);
+DEFINE_XEN_GUEST_HANDLE(trap_info_t);
 
 #ifdef __GNUC__
 /* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */
@@ -197,7 +197,7 @@ typedef struct cpu_user_regs {
     uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base.     */
     uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */
 } cpu_user_regs_t;
-DEFINE_GUEST_HANDLE(cpu_user_regs_t);
+DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
 
 #undef __DECL_REG
 
@@ -230,7 +230,7 @@ typedef struct vcpu_guest_context {
     uint64_t      gs_base_kernel;
     uint64_t      gs_base_user;
 } vcpu_guest_context_t;
-DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
+DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
 
 typedef struct arch_shared_info {
     unsigned long max_pfn;                  /* max pfn that appears in table */
diff -r 1d69cff40b8c xen/include/public/callback.h
--- a/xen/include/public/callback.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/callback.h	Wed Apr 26 16:11:21 2006 -0500
@@ -36,7 +36,7 @@ typedef struct callback_register {
      int type;
      xen_callback_t address;
 } callback_register_t;
-DEFINE_GUEST_HANDLE(callback_register_t);
+DEFINE_XEN_GUEST_HANDLE(callback_register_t);
 
 /*
  * Unregister a callback.
@@ -48,7 +48,7 @@ typedef struct callback_unregister {
 typedef struct callback_unregister {
      int type;
 } callback_unregister_t;
-DEFINE_GUEST_HANDLE(callback_unregister_t);
+DEFINE_XEN_GUEST_HANDLE(callback_unregister_t);
 
 #endif /* __XEN_PUBLIC_CALLBACK_H__ */
 
diff -r 1d69cff40b8c xen/include/public/dom0_ops.h
--- a/xen/include/public/dom0_ops.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/dom0_ops.h	Wed Apr 26 16:11:21 2006 -0500
@@ -28,21 +28,21 @@ typedef struct dom0_getmemlist {
     /* IN variables. */
     domid_t       domain;
     unsigned long max_pfns;
-    GUEST_HANDLE(ulong) buffer;
+    XEN_GUEST_HANDLE(ulong) buffer;
     /* OUT variables. */
     unsigned long num_pfns;
 } dom0_getmemlist_t;
-DEFINE_GUEST_HANDLE(dom0_getmemlist_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_getmemlist_t);
 
 #define DOM0_SCHEDCTL          6
  /* struct sched_ctl_cmd is from sched-ctl.h   */
 typedef struct sched_ctl_cmd dom0_schedctl_t;
-DEFINE_GUEST_HANDLE(dom0_schedctl_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_schedctl_t);
 
 #define DOM0_ADJUSTDOM         7
 /* struct sched_adjdom_cmd is from sched-ctl.h */
 typedef struct sched_adjdom_cmd dom0_adjustdom_t;
-DEFINE_GUEST_HANDLE(dom0_adjustdom_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_adjustdom_t);
 
 #define DOM0_CREATEDOMAIN      8
 typedef struct dom0_createdomain {
@@ -53,28 +53,28 @@ typedef struct dom0_createdomain {
     /* Identifier for new domain (auto-allocate if zero is specified). */
     domid_t domain;
 } dom0_createdomain_t;
-DEFINE_GUEST_HANDLE(dom0_createdomain_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_createdomain_t);
 
 #define DOM0_DESTROYDOMAIN     9
 typedef struct dom0_destroydomain {
     /* IN variables. */
     domid_t domain;
 } dom0_destroydomain_t;
-DEFINE_GUEST_HANDLE(dom0_destroydomain_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_destroydomain_t);
 
 #define DOM0_PAUSEDOMAIN      10
 typedef struct dom0_pausedomain {
     /* IN parameters. */
     domid_t domain;
 } dom0_pausedomain_t;
-DEFINE_GUEST_HANDLE(dom0_pausedomain_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_pausedomain_t);
 
 #define DOM0_UNPAUSEDOMAIN    11
 typedef struct dom0_unpausedomain {
     /* IN parameters. */
     domid_t domain;
 } dom0_unpausedomain_t;
-DEFINE_GUEST_HANDLE(dom0_unpausedomain_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_unpausedomain_t);
 
 #define DOM0_GETDOMAININFO    12
 typedef struct dom0_getdomaininfo {
@@ -100,7 +100,7 @@ typedef struct dom0_getdomaininfo {
     uint32_t ssidref;
     xen_domain_handle_t handle;
 } dom0_getdomaininfo_t;
-DEFINE_GUEST_HANDLE(dom0_getdomaininfo_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_getdomaininfo_t);
 
 #define DOM0_SETVCPUCONTEXT   13
 typedef struct dom0_setvcpucontext {
@@ -108,9 +108,9 @@ typedef struct dom0_setvcpucontext {
     domid_t               domain;
     uint32_t              vcpu;
     /* IN/OUT parameters */
-    GUEST_HANDLE(vcpu_guest_context_t) ctxt;
+    XEN_GUEST_HANDLE(vcpu_guest_context_t) ctxt;
 } dom0_setvcpucontext_t;
-DEFINE_GUEST_HANDLE(dom0_setvcpucontext_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_setvcpucontext_t);
 
 #define DOM0_MSR              15
 typedef struct dom0_msr {
@@ -124,7 +124,7 @@ typedef struct dom0_msr {
     uint32_t out1;
     uint32_t out2;
 } dom0_msr_t;
-DEFINE_GUEST_HANDLE(dom0_msr_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_msr_t);
 
 /*
  * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
@@ -137,7 +137,7 @@ typedef struct dom0_settime {
     uint32_t nsecs;
     uint64_t system_time;
 } dom0_settime_t;
-DEFINE_GUEST_HANDLE(dom0_settime_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_settime_t);
 
 #define DOM0_GETPAGEFRAMEINFO 18
 #define LTAB_SHIFT 28
@@ -159,7 +159,7 @@ typedef struct dom0_getpageframeinfo {
     /* Is the page PINNED to a type? */
     uint32_t type;         /* see above type defs */
 } dom0_getpageframeinfo_t;
-DEFINE_GUEST_HANDLE(dom0_getpageframeinfo_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_getpageframeinfo_t);
 
 /*
  * Read console content from Xen buffer ring.
@@ -169,10 +169,10 @@ typedef struct dom0_readconsole {
     /* IN variables. */
     uint32_t clear;            /* Non-zero -> clear after reading. */
     /* IN/OUT variables. */
-    GUEST_HANDLE(char) buffer; /* In: Buffer start; Out: Used buffer start */
+    XEN_GUEST_HANDLE(char) buffer; /* In: Buffer start; Out: Used buffer start */
     uint32_t count;            /* In: Buffer size;  Out: Used buffer size  */
 } dom0_readconsole_t;
-DEFINE_GUEST_HANDLE(dom0_readconsole_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_readconsole_t);
 
 /*
  * Set which physical cpus a vcpu can execute on.
@@ -184,7 +184,7 @@ typedef struct dom0_setvcpuaffinity {
     uint32_t  vcpu;
     cpumap_t  cpumap;
 } dom0_setvcpuaffinity_t;
-DEFINE_GUEST_HANDLE(dom0_setvcpuaffinity_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_setvcpuaffinity_t);
 
 /* Get trace buffers machine base address */
 #define DOM0_TBUFCONTROL       21
@@ -204,7 +204,7 @@ typedef struct dom0_tbufcontrol {
     unsigned long buffer_mfn;
     uint32_t size;
 } dom0_tbufcontrol_t;
-DEFINE_GUEST_HANDLE(dom0_tbufcontrol_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_tbufcontrol_t);
 
 /*
  * Get physical information about the host machine
@@ -220,7 +220,7 @@ typedef struct dom0_physinfo {
     unsigned long free_pages;
     uint32_t hw_cap[8];
 } dom0_physinfo_t;
-DEFINE_GUEST_HANDLE(dom0_physinfo_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_physinfo_t);
 
 /*
  * Get the ID of the current scheduler.
@@ -230,7 +230,7 @@ typedef struct dom0_sched_id {
     /* OUT variable */
     uint32_t sched_id;
 } dom0_sched_id_t;
-DEFINE_GUEST_HANDLE(dom0_sched_id_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_sched_id_t);
 
 /*
  * Control shadow pagetables operation
@@ -252,19 +252,19 @@ typedef struct dom0_shadow_control_stats
     uint32_t dirty_net_count;
     uint32_t dirty_block_count;
 } dom0_shadow_control_stats_t;
-DEFINE_GUEST_HANDLE(dom0_shadow_control_stats_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_shadow_control_stats_t);
 
 typedef struct dom0_shadow_control {
     /* IN variables. */
     domid_t        domain;
     uint32_t       op;
-    GUEST_HANDLE(ulong) dirty_bitmap;
+    XEN_GUEST_HANDLE(ulong) dirty_bitmap;
     /* IN/OUT variables. */
     unsigned long  pages;        /* size of buffer, updated with actual size */
     /* OUT variables. */
     dom0_shadow_control_stats_t stats;
 } dom0_shadow_control_t;
-DEFINE_GUEST_HANDLE(dom0_shadow_control_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_shadow_control_t);
 
 #define DOM0_SETDOMAINMAXMEM   28
 typedef struct dom0_setdomainmaxmem {
@@ -272,7 +272,7 @@ typedef struct dom0_setdomainmaxmem {
     domid_t       domain;
     unsigned long max_memkb;
 } dom0_setdomainmaxmem_t;
-DEFINE_GUEST_HANDLE(dom0_setdomainmaxmem_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_setdomainmaxmem_t);
 
 #define DOM0_GETPAGEFRAMEINFO2 29   /* batched interface */
 typedef struct dom0_getpageframeinfo2 {
@@ -280,9 +280,9 @@ typedef struct dom0_getpageframeinfo2 {
     domid_t        domain;
     unsigned long  num;
     /* IN/OUT variables. */
-    GUEST_HANDLE(ulong) array;
+    XEN_GUEST_HANDLE(ulong) array;
 } dom0_getpageframeinfo2_t;
-DEFINE_GUEST_HANDLE(dom0_getpageframeinfo2_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_getpageframeinfo2_t);
 
 /*
  * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
@@ -301,7 +301,7 @@ typedef struct dom0_add_memtype {
     uint32_t      handle;
     uint32_t      reg;
 } dom0_add_memtype_t;
-DEFINE_GUEST_HANDLE(dom0_add_memtype_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_add_memtype_t);
 
 /*
  * Tear down an existing memory-range type. If @handle is remembered then it
@@ -316,7 +316,7 @@ typedef struct dom0_del_memtype {
     uint32_t handle;
     uint32_t reg;
 } dom0_del_memtype_t;
-DEFINE_GUEST_HANDLE(dom0_del_memtype_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_del_memtype_t);
 
 /* Read current type of an MTRR (x86-specific). */
 #define DOM0_READ_MEMTYPE        33
@@ -328,7 +328,7 @@ typedef struct dom0_read_memtype {
     unsigned long nr_mfns;
     uint32_t type;
 } dom0_read_memtype_t;
-DEFINE_GUEST_HANDLE(dom0_read_memtype_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_read_memtype_t);
 
 /* Interface for controlling Xen software performance counters. */
 #define DOM0_PERFCCONTROL        34
@@ -340,23 +340,23 @@ typedef struct dom0_perfc_desc {
     uint32_t     nr_vals;              /* number of values for this counter */
     uint32_t     vals[64];             /* array of values */
 } dom0_perfc_desc_t;
-DEFINE_GUEST_HANDLE(dom0_perfc_desc_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_perfc_desc_t);
 typedef struct dom0_perfccontrol {
     /* IN variables. */
     uint32_t       op;                /*  DOM0_PERFCCONTROL_OP_??? */
     /* OUT variables. */
     uint32_t       nr_counters;       /*  number of counters */
-    GUEST_HANDLE(dom0_perfc_desc_t) desc; /*  counter information (or NULL) */
+    XEN_GUEST_HANDLE(dom0_perfc_desc_t) desc; /*  counter information (or NULL) */
 } dom0_perfccontrol_t;
-DEFINE_GUEST_HANDLE(dom0_perfccontrol_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_perfccontrol_t);
 
 #define DOM0_MICROCODE           35
 typedef struct dom0_microcode {
     /* IN variables. */
-    GUEST_HANDLE(void) data;          /* Pointer to microcode data */
+    XEN_GUEST_HANDLE(void) data;          /* Pointer to microcode data */
     uint32_t length;                  /* Length of microcode data. */
 } dom0_microcode_t;
-DEFINE_GUEST_HANDLE(dom0_microcode_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_microcode_t);
 
 #define DOM0_IOPORT_PERMISSION   36
 typedef struct dom0_ioport_permission {
@@ -365,7 +365,7 @@ typedef struct dom0_ioport_permission {
     uint32_t nr_ports;                /* size of port range */
     uint8_t  allow_access;            /* allow or deny access to range? */
 } dom0_ioport_permission_t;
-DEFINE_GUEST_HANDLE(dom0_ioport_permission_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_ioport_permission_t);
 
 #define DOM0_GETVCPUCONTEXT      37
 typedef struct dom0_getvcpucontext {
@@ -373,9 +373,9 @@ typedef struct dom0_getvcpucontext {
     domid_t  domain;                  /* domain to be affected */
     uint32_t vcpu;                    /* vcpu # */
     /* OUT variables. */
-    GUEST_HANDLE(vcpu_guest_context_t) ctxt;
+    XEN_GUEST_HANDLE(vcpu_guest_context_t) ctxt;
 } dom0_getvcpucontext_t;
-DEFINE_GUEST_HANDLE(dom0_getvcpucontext_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_getvcpucontext_t);
 
 #define DOM0_GETVCPUINFO         43
 typedef struct dom0_getvcpuinfo {
@@ -390,18 +390,18 @@ typedef struct dom0_getvcpuinfo {
     uint32_t cpu;                     /* current mapping   */
     cpumap_t cpumap;                  /* allowable mapping */
 } dom0_getvcpuinfo_t;
-DEFINE_GUEST_HANDLE(dom0_getvcpuinfo_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_getvcpuinfo_t);
 
 #define DOM0_GETDOMAININFOLIST   38
 typedef struct dom0_getdomaininfolist {
     /* IN variables. */
     domid_t               first_domain;
     uint32_t              max_domains;
-    GUEST_HANDLE(dom0_getdomaininfo_t) buffer;
+    XEN_GUEST_HANDLE(dom0_getdomaininfo_t) buffer;
     /* OUT variables. */
     uint32_t              num_domains;
 } dom0_getdomaininfolist_t;
-DEFINE_GUEST_HANDLE(dom0_getdomaininfolist_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_getdomaininfolist_t);
 
 #define DOM0_PLATFORM_QUIRK      39
 #define QUIRK_NOIRQBALANCING      1 /* Do not restrict IO-APIC RTE targets */
@@ -411,7 +411,7 @@ typedef struct dom0_platform_quirk {
     /* IN variables. */
     uint32_t quirk_id;
 } dom0_platform_quirk_t;
-DEFINE_GUEST_HANDLE(dom0_platform_quirk_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_platform_quirk_t);
 
 #define DOM0_PHYSICAL_MEMORY_MAP 40
 typedef struct dom0_memory_map_entry {
@@ -419,36 +419,36 @@ typedef struct dom0_memory_map_entry {
     uint32_t flags; /* reserved */
     uint8_t  is_ram;
 } dom0_memory_map_entry_t;
-DEFINE_GUEST_HANDLE(dom0_memory_map_entry_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_memory_map_entry_t);
 typedef struct dom0_physical_memory_map {
     /* IN variables. */
     uint32_t max_map_entries;
     /* OUT variables. */
     uint32_t nr_map_entries;
-    GUEST_HANDLE(dom0_memory_map_entry_t) memory_map;
+    XEN_GUEST_HANDLE(dom0_memory_map_entry_t) memory_map;
 } dom0_physical_memory_map_t;
-DEFINE_GUEST_HANDLE(dom0_physical_memory_map_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_physical_memory_map_t);
 
 #define DOM0_MAX_VCPUS 41
 typedef struct dom0_max_vcpus {
     domid_t  domain;        /* domain to be affected */
     uint32_t max;           /* maximum number of vcpus */
 } dom0_max_vcpus_t;
-DEFINE_GUEST_HANDLE(dom0_max_vcpus_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_max_vcpus_t);
 
 #define DOM0_SETDOMAINHANDLE 44
 typedef struct dom0_setdomainhandle {
     domid_t domain;
     xen_domain_handle_t handle;
 } dom0_setdomainhandle_t;
-DEFINE_GUEST_HANDLE(dom0_setdomainhandle_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_setdomainhandle_t);
 
 #define DOM0_SETDEBUGGING 45
 typedef struct dom0_setdebugging {
     domid_t domain;
     uint8_t enable;
 } dom0_setdebugging_t;
-DEFINE_GUEST_HANDLE(dom0_setdebugging_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_setdebugging_t);
 
 #define DOM0_IRQ_PERMISSION 46
 typedef struct dom0_irq_permission {
@@ -456,7 +456,7 @@ typedef struct dom0_irq_permission {
     uint8_t pirq;
     uint8_t allow_access;    /* flag to specify enable/disable of IRQ access */
 } dom0_irq_permission_t;
-DEFINE_GUEST_HANDLE(dom0_irq_permission_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_irq_permission_t);
 
 #define DOM0_IOMEM_PERMISSION 47
 typedef struct dom0_iomem_permission {
@@ -465,14 +465,14 @@ typedef struct dom0_iomem_permission {
     unsigned long nr_mfns;    /* number of pages in range (>0) */
     uint8_t allow_access;     /* allow (!0) or deny (0) access to range? */
 } dom0_iomem_permission_t;
-DEFINE_GUEST_HANDLE(dom0_iomem_permission_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_iomem_permission_t);
 
 #define DOM0_HYPERCALL_INIT   48
 typedef struct dom0_hypercall_init {
     domid_t  domain;          /* domain to be affected */
     unsigned long mfn;        /* machine frame to be initialised */
 } dom0_hypercall_init_t;
-DEFINE_GUEST_HANDLE(dom0_hypercall_init_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_hypercall_init_t);
 
 typedef struct dom0_op {
     uint32_t cmd;
@@ -518,7 +518,7 @@ typedef struct dom0_op {
         uint8_t                       pad[128];
     } u;
 } dom0_op_t;
-DEFINE_GUEST_HANDLE(dom0_op_t);
+DEFINE_XEN_GUEST_HANDLE(dom0_op_t);
 
 #endif /* __XEN_PUBLIC_DOM0_OPS_H__ */
 
diff -r 1d69cff40b8c xen/include/public/event_channel.h
--- a/xen/include/public/event_channel.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/event_channel.h	Wed Apr 26 16:11:21 2006 -0500
@@ -10,7 +10,7 @@
 #define __XEN_PUBLIC_EVENT_CHANNEL_H__
 
 typedef uint32_t evtchn_port_t;
-DEFINE_GUEST_HANDLE(evtchn_port_t);
+DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
 
 /*
  * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
@@ -196,7 +196,7 @@ typedef struct evtchn_op {
         evtchn_unmask_t           unmask;
     } u;
 } evtchn_op_t;
-DEFINE_GUEST_HANDLE(evtchn_op_t);
+DEFINE_XEN_GUEST_HANDLE(evtchn_op_t);
 
 #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
 
diff -r 1d69cff40b8c xen/include/public/grant_table.h
--- a/xen/include/public/grant_table.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/grant_table.h	Wed Apr 26 16:11:21 2006 -0500
@@ -167,7 +167,7 @@ typedef struct gnttab_map_grant_ref {
     grant_handle_t handle;
     uint64_t dev_bus_addr;
 } gnttab_map_grant_ref_t;
-DEFINE_GUEST_HANDLE(gnttab_map_grant_ref_t);
+DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t);
 
 /*
  * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
@@ -189,7 +189,7 @@ typedef struct gnttab_unmap_grant_ref {
     /* OUT parameters. */
     int16_t  status;              /* GNTST_* */
 } gnttab_unmap_grant_ref_t;
-DEFINE_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
+DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
 
 /*
  * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
@@ -207,9 +207,9 @@ typedef struct gnttab_setup_table {
     uint32_t nr_frames;
     /* OUT parameters. */
     int16_t  status;              /* GNTST_* */
-    GUEST_HANDLE(ulong) frame_list;
+    XEN_GUEST_HANDLE(ulong) frame_list;
 } gnttab_setup_table_t;
-DEFINE_GUEST_HANDLE(gnttab_setup_table_t);
+DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t);
 
 /*
  * GNTTABOP_dump_table: Dump the contents of the grant table to the
@@ -222,7 +222,7 @@ typedef struct gnttab_dump_table {
     /* OUT parameters. */
     int16_t status;               /* GNTST_* */
 } gnttab_dump_table_t;
-DEFINE_GUEST_HANDLE(gnttab_dump_table_t);
+DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t);
 
 /*
  * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
@@ -241,7 +241,7 @@ typedef struct gnttab_transfer {
     /* OUT parameters. */
     int16_t       status;
 } gnttab_transfer_t;
-DEFINE_GUEST_HANDLE(gnttab_transfer_t);
+DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t);
 
 /*
  * Bitfield values for update_pin_status.flags.
diff -r 1d69cff40b8c xen/include/public/memory.h
--- a/xen/include/public/memory.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/memory.h	Wed Apr 26 16:11:21 2006 -0500
@@ -29,7 +29,7 @@ typedef struct xen_memory_reservation {
      *   OUT: GMFN bases of extents that were allocated
      *   (NB. This command also updates the mach_to_phys translation table)
      */
-    GUEST_HANDLE(ulong) extent_start;
+    XEN_GUEST_HANDLE(ulong) extent_start;
 
     /* Number of extents, and size/alignment of each (2^extent_order pages). */
     unsigned long  nr_extents;
@@ -50,7 +50,7 @@ typedef struct xen_memory_reservation {
     domid_t        domid;
 
 } xen_memory_reservation_t;
-DEFINE_GUEST_HANDLE(xen_memory_reservation_t);
+DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
 
 /*
  * Returns the maximum machine frame number of mapped RAM in this system.
@@ -86,7 +86,7 @@ typedef struct xen_machphys_mfn_list {
      * any large discontiguities in the machine address space, 2MB gaps in
      * the machphys table will be represented by an MFN base of zero.
      */
-    GUEST_HANDLE(ulong) extent_start;
+    XEN_GUEST_HANDLE(ulong) extent_start;
 
     /*
      * Number of extents written to the above array. This will be smaller
@@ -94,7 +94,7 @@ typedef struct xen_machphys_mfn_list {
      */
     unsigned int nr_extents;
 } xen_machphys_mfn_list_t;
-DEFINE_GUEST_HANDLE(xen_machphys_mfn_list_t);
+DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
 
 /*
  * Sets the GPFN at which a particular page appears in the specified guest's
@@ -117,7 +117,7 @@ typedef struct xen_add_to_physmap {
     /* GPFN where the source mapping page should appear. */
     unsigned long gpfn;
 } xen_add_to_physmap_t;
-DEFINE_GUEST_HANDLE(xen_add_to_physmap_t);
+DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
 
 /*
  * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
@@ -132,15 +132,15 @@ typedef struct xen_translate_gpfn_list {
     unsigned long nr_gpfns;
 
     /* List of GPFNs to translate. */
-    GUEST_HANDLE(ulong) gpfn_list;
+    XEN_GUEST_HANDLE(ulong) gpfn_list;
 
     /*
      * Output list to contain MFN translations. May be the same as the input
      * list (in which case each input GPFN is overwritten with the output MFN).
      */
-    GUEST_HANDLE(ulong) mfn_list;
+    XEN_GUEST_HANDLE(ulong) mfn_list;
 } xen_translate_gpfn_list_t;
-DEFINE_GUEST_HANDLE(xen_translate_gpfn_list_t);
+DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
 
 #endif /* __XEN_PUBLIC_MEMORY_H__ */
 
diff -r 1d69cff40b8c xen/include/public/nmi.h
--- a/xen/include/public/nmi.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/nmi.h	Wed Apr 26 16:11:21 2006 -0500
@@ -38,7 +38,7 @@ typedef struct xennmi_callback {
     unsigned long handler_address;
     unsigned long pad;
 } xennmi_callback_t;
-DEFINE_GUEST_HANDLE(xennmi_callback_t);
+DEFINE_XEN_GUEST_HANDLE(xennmi_callback_t);
 
 /*
  * Deregister NMI callback for this (calling) VCPU.
diff -r 1d69cff40b8c xen/include/public/physdev.h
--- a/xen/include/public/physdev.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/physdev.h	Wed Apr 26 16:11:21 2006 -0500
@@ -56,7 +56,7 @@ typedef struct physdev_op {
         physdevop_irq_t                   irq_op;
     } u;
 } physdev_op_t;
-DEFINE_GUEST_HANDLE(physdev_op_t);
+DEFINE_XEN_GUEST_HANDLE(physdev_op_t);
 
 #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
 
diff -r 1d69cff40b8c xen/include/public/sched.h
--- a/xen/include/public/sched.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/sched.h	Wed Apr 26 16:11:21 2006 -0500
@@ -49,7 +49,7 @@ typedef struct sched_shutdown {
 typedef struct sched_shutdown {
     unsigned int reason; /* SHUTDOWN_* */
 } sched_shutdown_t;
-DEFINE_GUEST_HANDLE(sched_shutdown_t);
+DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t);
 
 /*
  * Poll a set of event-channel ports. Return when one or more are pending. An
@@ -58,11 +58,11 @@ DEFINE_GUEST_HANDLE(sched_shutdown_t);
  */
 #define SCHEDOP_poll        3
 typedef struct sched_poll {
-    GUEST_HANDLE(evtchn_port_t) ports;
+    XEN_GUEST_HANDLE(evtchn_port_t) ports;
     unsigned int nr_ports;
     uint64_t timeout;
 } sched_poll_t;
-DEFINE_GUEST_HANDLE(sched_poll_t);
+DEFINE_XEN_GUEST_HANDLE(sched_poll_t);
 
 /*
  * Declare a shutdown for another domain. The main use of this function is
@@ -75,7 +75,7 @@ typedef struct sched_remote_shutdown {
     domid_t domain_id;         /* Remote domain ID */
     unsigned int reason;       /* SHUTDOWN_xxx reason */
 } sched_remote_shutdown_t;
-DEFINE_GUEST_HANDLE(sched_remote_shutdown_t);
+DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t);
 
 /*
  * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
diff -r 1d69cff40b8c xen/include/public/xen.h
--- a/xen/include/public/xen.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/xen.h	Wed Apr 26 16:11:21 2006 -0500
@@ -185,7 +185,7 @@ typedef struct mmuext_op {
         void *vcpumask;
     } arg2;
 } mmuext_op_t;
-DEFINE_GUEST_HANDLE(mmuext_op_t);
+DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
 #endif
 
 /* These are passed as 'flags' to update_va_mapping. They can be ORed. */
@@ -252,7 +252,7 @@ typedef struct mmu_update {
     uint64_t ptr;       /* Machine address of PTE. */
     uint64_t val;       /* New contents of PTE.    */
 } mmu_update_t;
-DEFINE_GUEST_HANDLE(mmu_update_t);
+DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
 
 /*
  * Send an array of these to HYPERVISOR_multicall().
@@ -262,7 +262,7 @@ typedef struct multicall_entry {
     unsigned long op, result;
     unsigned long args[6];
 } multicall_entry_t;
-DEFINE_GUEST_HANDLE(multicall_entry_t);
+DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
 
 /*
  * Event channel endpoints per domain:
diff -r 1d69cff40b8c xen/include/public/xenoprof.h
--- a/xen/include/public/xenoprof.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/public/xenoprof.h	Wed Apr 26 16:11:21 2006 -0500
@@ -52,7 +52,7 @@ typedef struct xenoprof_buf {
     uint64_t lost_samples;
     struct event_log event_log[1];
 } xenoprof_buf_t;
-DEFINE_GUEST_HANDLE(xenoprof_buf_t);
+DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t);
 
 typedef struct xenoprof_init {
     int32_t  max_samples;
@@ -63,7 +63,7 @@ typedef struct xenoprof_init {
     uint64_t buf_maddr;
     char cpu_type[XENOPROF_CPU_TYPE_SIZE];
 } xenoprof_init_t;
-DEFINE_GUEST_HANDLE(xenoprof_init_t);
+DEFINE_XEN_GUEST_HANDLE(xenoprof_init_t);
 
 typedef struct xenoprof_counter {
     uint32_t ind;
@@ -75,7 +75,7 @@ typedef struct xenoprof_counter {
     uint32_t user;
     uint64_t unit_mask;
 } xenoprof_counter_t;
-DEFINE_GUEST_HANDLE(xenoprof_counter_t);
+DEFINE_XEN_GUEST_HANDLE(xenoprof_counter_t);
 
 
 #endif /* __XEN_PUBLIC_XENOPROF_H__ */
diff -r 1d69cff40b8c xen/include/xen/console.h
--- a/xen/include/xen/console.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/xen/console.h	Wed Apr 26 16:11:21 2006 -0500
@@ -14,7 +14,7 @@ extern spinlock_t console_lock;
 
 void set_printk_prefix(const char *prefix);
 
-long read_console_ring(GUEST_HANDLE(char), u32 *, int);
+long read_console_ring(XEN_GUEST_HANDLE(char), u32 *, int);
 
 void init_console(void);
 void console_endboot(int disable_vga);
diff -r 1d69cff40b8c xen/include/xen/hypercall.h
--- a/xen/include/xen/hypercall.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/xen/hypercall.h	Wed Apr 26 16:11:21 2006 -0500
@@ -25,20 +25,20 @@ extern long
 extern long
 do_sched_op(
     int cmd,
-    GUEST_HANDLE(void) arg);
+    XEN_GUEST_HANDLE(void) arg);
 
 extern long
 do_dom0_op(
-    GUEST_HANDLE(dom0_op_t) u_dom0_op);
+    XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op);
 
 extern long
 do_memory_op(
     int cmd,
-    GUEST_HANDLE(void) arg);
+    XEN_GUEST_HANDLE(void) arg);
 
 extern long
 do_multicall(
-    GUEST_HANDLE(multicall_entry_t) call_list,
+    XEN_GUEST_HANDLE(multicall_entry_t) call_list,
     unsigned int nr_calls);
 
 extern long
@@ -47,23 +47,23 @@ do_set_timer_op(
 
 extern long
 do_event_channel_op(
-    GUEST_HANDLE(evtchn_op_t) uop);
+    XEN_GUEST_HANDLE(evtchn_op_t) uop);
 
 extern long
 do_xen_version(
     int cmd,
-    GUEST_HANDLE(void) arg);
+    XEN_GUEST_HANDLE(void) arg);
 
 extern long
 do_console_io(
     int cmd,
     int count,
-    GUEST_HANDLE(char) buffer);
+    XEN_GUEST_HANDLE(char) buffer);
 
 extern long
 do_grant_table_op(
     unsigned int cmd,
-    GUEST_HANDLE(void) uop,
+    XEN_GUEST_HANDLE(void) uop,
     unsigned int count);
 
 extern long
@@ -75,15 +75,15 @@ do_vcpu_op(
 do_vcpu_op(
     int cmd,
     int vcpuid,
-    GUEST_HANDLE(void) arg);
+    XEN_GUEST_HANDLE(void) arg);
 
 extern long
 do_acm_op(
-    GUEST_HANDLE(acm_op_t) u_acm_op);
+    XEN_GUEST_HANDLE(acm_op_t) u_acm_op);
 
 extern long
 do_nmi_op(
     unsigned int cmd,
-    GUEST_HANDLE(void) arg);
+    XEN_GUEST_HANDLE(void) arg);
 
 #endif /* __XEN_HYPERCALL_H__ */
diff -r 1d69cff40b8c xen/include/xen/sched.h
--- a/xen/include/xen/sched.h	Wed Apr 26 17:41:19 2006 +0100
+++ b/xen/include/xen/sched.h	Wed Apr 26 16:11:21 2006 -0500
@@ -316,7 +316,7 @@ void startup_cpu_idle_loop(void);
  * It contains one character per argument as follows:
  *  'i' [unsigned] {char, int}
  *  'l' [unsigned] long
- *  'h' guest handle (GUEST_HANDLE(foo))
+ *  'h' guest handle (XEN_GUEST_HANDLE(foo))
  */
 unsigned long hypercall_create_continuation(
     unsigned int op, const char *format, ...);

[-- Attachment #3: xen-SET_XEN_GUEST_HANDLE.diff --]
[-- Type: text/x-patch, Size: 23157 bytes --]

Wrap all GUEST_HANDLEs in structures, and define SET/GET macros to access them
in Linux and libxc.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

diff -r 96cc994dee76 linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c	Wed Apr 26 16:21:20 2006 -0500
@@ -70,7 +70,7 @@ static int do_microcode_update (void)
 		return err;
 
 	op.cmd = DOM0_MICROCODE;
-	op.u.microcode.data = user_buffer;
+	SET_XEN_GUEST_HANDLE(op.u.microcode.data, user_buffer);
 	op.u.microcode.length = user_buffer_size;
 	err = HYPERVISOR_dom0_op(&op);
 
diff -r 96cc994dee76 linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Wed Apr 26 16:21:20 2006 -0500
@@ -1368,7 +1368,7 @@ legacy_init_iomem_resources(struct resou
 #ifdef CONFIG_XEN
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_XEN_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
diff -r 96cc994dee76 linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	Wed Apr 26 16:21:20 2006 -0500
@@ -271,11 +271,11 @@ int xen_create_contiguous_region(
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	/*
 	 * Currently an auto-translated guest will not perform I/O, nor will
@@ -357,11 +357,11 @@ void xen_destroy_contiguous_region(unsig
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return;
diff -r 96cc994dee76 linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c	Wed Apr 26 16:21:20 2006 -0500
@@ -600,7 +600,7 @@ void __init e820_reserve_resources(void)
 
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_XEN_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
diff -r 96cc994dee76 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Apr 26 16:21:20 2006 -0500
@@ -195,14 +195,14 @@ static int increase_reservation(unsigned
 		page = balloon_next_page(page);
 	}
 
-	reservation.extent_start = frame_list;
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	rc = HYPERVISOR_memory_op(
 		XENMEM_populate_physmap, &reservation);
 	if (rc < nr_pages) {
 		int ret;
 		/* We hit the Xen hard limit: reprobe. */
-		reservation.extent_start = frame_list;
+		SET_XEN_GUEST_HANDLE(reservation.extent_start, frame_list);
 		reservation.nr_extents   = rc;
 		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
 				&reservation);
@@ -308,7 +308,7 @@ static int decrease_reservation(unsigned
 		balloon_append(pfn_to_page(pfn));
 	}
 
-	reservation.extent_start = frame_list;
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
 	BUG_ON(ret != nr_pages);
@@ -522,11 +522,11 @@ static int dealloc_pte_fn(
 	unsigned long mfn = pte_mfn(*pte);
 	int ret;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &mfn,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, &mfn);
 	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
 	set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
diff -r 96cc994dee76 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed Apr 26 16:21:20 2006 -0500
@@ -399,7 +399,7 @@ gnttab_resume(void)
 
 	setup.dom        = DOMID_SELF;
 	setup.nr_frames  = NR_GRANT_FRAMES;
-	setup.frame_list = frames;
+	SET_XEN_GUEST_HANDLE(setup.frame_list, frames);
 
 	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
 	if (rc == -ENOSYS)
diff -r 96cc994dee76 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Wed Apr 26 16:21:20 2006 -0500
@@ -105,11 +105,11 @@ static unsigned long alloc_mfn(void)
 {
 	unsigned long mfn = 0, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = mfn_list,
 		.nr_extents   = MAX_MFN_ALLOC,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, mfn_list);
 	spin_lock_irqsave(&mfn_lock, flags);
 	if ( unlikely(alloc_index == 0) )
 		alloc_index = HYPERVISOR_memory_op(
diff -r 96cc994dee76 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Apr 26 16:21:20 2006 -0500
@@ -607,7 +607,7 @@ static void network_alloc_rx_buffers(str
 	/* Tell the ballon driver what is going on. */
 	balloon_update_driver_allowance(i);
 
-	reservation.extent_start = np->rx_pfn_array;
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, np->rx_pfn_array);
 	reservation.nr_extents   = i;
 	reservation.extent_order = 0;
 	reservation.address_bits = 0;
diff -r 96cc994dee76 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Wed Apr 26 15:54:02 2006 -0500
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Wed Apr 26 16:21:20 2006 -0500
@@ -163,13 +163,14 @@ HYPERVISOR_poll(
 	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
 {
 	struct sched_poll sched_poll = {
-		.ports = ports,
 		.nr_ports = nr_ports,
 		.timeout = jiffies_to_st(timeout)
 	};
-
-	int rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
-
+	int rc;
+
+	SET_XEN_GUEST_HANDLE(sched_poll.ports, ports);
+
+	rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
 	if (rc == -ENOSYS)
 		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
 
diff -r 96cc994dee76 tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/tools/libxc/xc_domain.c	Wed Apr 26 16:21:20 2006 -0500
@@ -171,7 +171,7 @@ int xc_domain_getinfolist(int xc_handle,
     op.cmd = DOM0_GETDOMAININFOLIST;
     op.u.getdomaininfolist.first_domain = first_domain;
     op.u.getdomaininfolist.max_domains  = max_domains;
-    op.u.getdomaininfolist.buffer       = info;
+    SET_XEN_GUEST_HANDLE(op.u.getdomaininfolist.buffer, info);
 
     if ( xc_dom0_op(xc_handle, &op) < 0 )
         ret = -1;
@@ -195,7 +195,7 @@ int xc_vcpu_getcontext(int xc_handle,
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (uint16_t)vcpu;
-    op.u.getvcpucontext.ctxt   = ctxt;
+    SET_XEN_GUEST_HANDLE(op.u.getvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
@@ -220,7 +220,7 @@ int xc_shadow_control(int xc_handle,
     op.cmd = DOM0_SHADOW_CONTROL;
     op.u.shadow_control.domain = (domid_t)domid;
     op.u.shadow_control.op     = sop;
-    op.u.shadow_control.dirty_bitmap = dirty_bitmap;
+    SET_XEN_GUEST_HANDLE(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
     op.u.shadow_control.pages  = pages;
 
     rc = do_dom0_op(xc_handle, &op);
@@ -295,13 +295,15 @@ int xc_domain_memory_increase_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, /* may be NULL */
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = address_bits,
         .domid        = domid
     };
 
+    /* may be NULL */
+    SET_XEN_GUEST_HANDLE(reservation.extent_start, extent_start);
+
     err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
     if ( err == nr_extents )
         return 0;
@@ -326,12 +328,13 @@ int xc_domain_memory_decrease_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start,
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = 0,
         .domid        = domid
     };
+
+    SET_XEN_GUEST_HANDLE(reservation.extent_start, extent_start);
 
     if ( extent_start == NULL )
     {
@@ -364,12 +367,12 @@ int xc_domain_memory_populate_physmap(in
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start,
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_XEN_GUEST_HANDLE(reservation.extent_start, extent_start);
 
     err = xc_memory_op(xc_handle, XENMEM_populate_physmap, &reservation);
     if ( err == nr_extents )
@@ -395,9 +398,9 @@ int xc_domain_translate_gpfn_list(int xc
     struct xen_translate_gpfn_list op = {
         .domid        = domid,
         .nr_gpfns     = nr_gpfns,
-        .gpfn_list    = gpfn_list,
-        .mfn_list     = mfn_list
     };
+    SET_XEN_GUEST_HANDLE(op.gpfn_list, gpfn_list);
+    SET_XEN_GUEST_HANDLE(op.mfn_list, mfn_list);
 
     return xc_memory_op(xc_handle, XENMEM_translate_gpfn_list, &op);
 }
@@ -467,7 +470,7 @@ int xc_vcpu_setcontext(int xc_handle,
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = domid;
     op.u.setvcpucontext.vcpu = vcpu;
-    op.u.setvcpucontext.ctxt = ctxt;
+    SET_XEN_GUEST_HANDLE(op.u.setvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
diff -r 96cc994dee76 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/tools/libxc/xc_hvm_build.c	Wed Apr 26 16:21:20 2006 -0500
@@ -440,7 +440,7 @@ static int xc_hvm_build_internal(int xc_
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_XEN_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
diff -r 96cc994dee76 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/tools/libxc/xc_linux_build.c	Wed Apr 26 16:21:20 2006 -0500
@@ -1180,7 +1180,7 @@ static int xc_linux_build_internal(int x
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_XEN_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
diff -r 96cc994dee76 tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/tools/libxc/xc_linux_restore.c	Wed Apr 26 16:21:20 2006 -0500
@@ -583,11 +583,11 @@ int xc_linux_restore(int xc_handle, int 
         if (count > 0) {
 
             struct xen_memory_reservation reservation = {
-                .extent_start = pfntab,
                 .nr_extents   = count,
                 .extent_order = 0,
                 .domid        = dom
             };
+            SET_XEN_GUEST_HANDLE(reservation.extent_start, pfntab);
 
             if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
                                    &reservation)) != count) {
@@ -727,7 +727,7 @@ int xc_linux_restore(int xc_handle, int 
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = (domid_t)dom;
     op.u.setvcpucontext.vcpu   = 0;
-    op.u.setvcpucontext.ctxt   = &ctxt;
+    SET_XEN_GUEST_HANDLE(op.u.setvcpucontext.ctxt, &ctxt);
     rc = xc_dom0_op(xc_handle, &op);
 
     if (rc != 0) {
diff -r 96cc994dee76 tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/tools/libxc/xc_linux_save.c	Wed Apr 26 16:21:20 2006 -0500
@@ -509,16 +509,18 @@ static unsigned long *xc_map_m2p(int xc_
     privcmd_mmap_entry_t *entries;
     unsigned long m2p_chunks, m2p_size;
     unsigned long *m2p;
+    unsigned long *extent_start;
     int i, rc;
 
     m2p_size   = M2P_SIZE(max_mfn);
     m2p_chunks = M2P_CHUNKS(max_mfn);
 
     xmml.max_extents = m2p_chunks;
-    if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
+    if (!(extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
         ERR("failed to allocate space for m2p mfns");
         return NULL;
     }
+    SET_XEN_GUEST_HANDLE(xmml.extent_start, extent_start);
 
     if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
         (xmml.nr_extents != m2p_chunks)) {
@@ -543,7 +545,7 @@ static unsigned long *xc_map_m2p(int xc_
 
     for (i=0; i < m2p_chunks; i++) {
         entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE));
-        entries[i].mfn = xmml.extent_start[i];
+        entries[i].mfn = extent_start[i];
         entries[i].npages = M2P_CHUNK_SIZE >> PAGE_SHIFT;
     }
 
@@ -552,7 +554,7 @@ static unsigned long *xc_map_m2p(int xc_
         return NULL;
     }
 
-    free(xmml.extent_start);
+    free(extent_start);
     free(entries);
 
     return m2p;
diff -r 96cc994dee76 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/tools/libxc/xc_misc.c	Wed Apr 26 16:21:20 2006 -0500
@@ -30,7 +30,7 @@ int xc_readconsolering(int xc_handle,
     unsigned int nr_chars = *pnr_chars;
 
     op.cmd = DOM0_READCONSOLE;
-    op.u.readconsole.buffer = buffer;
+    SET_XEN_GUEST_HANDLE(op.u.readconsole.buffer, buffer);
     op.u.readconsole.count  = nr_chars;
     op.u.readconsole.clear  = clear;
 
@@ -39,7 +39,7 @@ int xc_readconsolering(int xc_handle,
 
     if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
     {
-        *pbuffer   = op.u.readconsole.buffer;
+        GET_XEN_GUEST_HANDLE(*pbuffer, op.u.readconsole.buffer);
         *pnr_chars = op.u.readconsole.count;
     }
 
@@ -91,7 +91,7 @@ int xc_perfc_control(int xc_handle,
 
     op.cmd = DOM0_PERFCCONTROL;
     op.u.perfccontrol.op   = opcode;
-    op.u.perfccontrol.desc = desc;
+    SET_XEN_GUEST_HANDLE(op.u.perfccontrol.desc, desc);
 
     rc = do_dom0_op(xc_handle, &op);
 
diff -r 96cc994dee76 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c	Wed Apr 26 15:54:02 2006 -0500
+++ b/tools/libxc/xc_private.c	Wed Apr 26 16:21:20 2006 -0500
@@ -71,7 +71,7 @@ int xc_get_pfn_type_batch(int xc_handle,
     op.cmd = DOM0_GETPAGEFRAMEINFO2;
     op.u.getpageframeinfo2.domain = (domid_t)dom;
     op.u.getpageframeinfo2.num    = num;
-    op.u.getpageframeinfo2.array  = arr;
+    SET_XEN_GUEST_HANDLE(op.u.getpageframeinfo2.array, arr);
     return do_dom0_op(xc_handle, &op);
 }
 
@@ -191,6 +191,9 @@ int xc_memory_op(int xc_handle,
     struct xen_memory_reservation *reservation = arg;
     struct xen_machphys_mfn_list *xmml = arg;
     struct xen_translate_gpfn_list *trans = arg;
+    unsigned long *extent_start;
+    unsigned long *gpfn_list;
+    unsigned long *mfn_list;
     long ret = -EINVAL;
 
     hypercall.op     = __HYPERVISOR_memory_op;
@@ -207,8 +210,9 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( (reservation->extent_start != NULL) &&
-             (mlock(reservation->extent_start,
+        GET_XEN_GUEST_HANDLE(extent_start, reservation->extent_start);
+        if ( (extent_start != NULL) &&
+             (mlock(extent_start,
                     reservation->nr_extents * sizeof(unsigned long)) != 0) )
         {
             PERROR("Could not mlock");
@@ -222,7 +226,8 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( mlock(xmml->extent_start,
+        GET_XEN_GUEST_HANDLE(extent_start, reservation->extent_start);
+        if ( mlock(extent_start,
                    xmml->max_extents * sizeof(unsigned long)) != 0 )
         {
             PERROR("Could not mlock");
@@ -243,16 +248,18 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( mlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
+        GET_XEN_GUEST_HANDLE(gpfn_list, trans->gpfn_list);
+        if ( mlock(gpfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
         {
             PERROR("Could not mlock");
             safe_munlock(trans, sizeof(*trans));
             goto out1;
         }
-        if ( mlock(trans->mfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
-        {
-            PERROR("Could not mlock");
-            safe_munlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long));
+        GET_XEN_GUEST_HANDLE(mfn_list, trans->mfn_list);
+        if ( mlock(mfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
+        {
+            PERROR("Could not mlock");
+            safe_munlock(gpfn_list, trans->nr_gpfns * sizeof(long));
             safe_munlock(trans, sizeof(*trans));
             goto out1;
         }
@@ -267,21 +274,25 @@ int xc_memory_op(int xc_handle,
     case XENMEM_decrease_reservation:
     case XENMEM_populate_physmap:
         safe_munlock(reservation, sizeof(*reservation));
-        if ( reservation->extent_start != NULL )
-            safe_munlock(reservation->extent_start,
+        GET_XEN_GUEST_HANDLE(extent_start, reservation->extent_start);
+        if ( extent_start != NULL )
+            safe_munlock(extent_start,
                          reservation->nr_extents * sizeof(unsigned long));
         break;
     case XENMEM_machphys_mfn_list:
         safe_munlock(xmml, sizeof(*xmml));
-        safe_munlock(xmml->extent_start,
+        GET_XEN_GUEST_HANDLE(extent_start, reservation->extent_start);
+        safe_munlock(extent_start,
                      xmml->max_extents * sizeof(unsigned long));
         break;
     case XENMEM_add_to_physmap:
         safe_munlock(arg, sizeof(struct xen_add_to_physmap));
         break;
     case XENMEM_translate_gpfn_list:
-            safe_munlock(trans->mfn_list, trans->nr_gpfns * sizeof(long));
-            safe_munlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long));
+            GET_XEN_GUEST_HANDLE(mfn_list, trans->mfn_list);
+            safe_munlock(mfn_list, trans->nr_gpfns * sizeof(long));
+            GET_XEN_GUEST_HANDLE(gpfn_list, trans->gpfn_list);
+            safe_munlock(gpfn_list, trans->nr_gpfns * sizeof(long));
             safe_munlock(trans, sizeof(*trans));
         break;
     }
@@ -317,7 +328,7 @@ int xc_get_pfn_list(int xc_handle,
     op.cmd = DOM0_GETMEMLIST;
     op.u.getmemlist.domain   = (domid_t)domid;
     op.u.getmemlist.max_pfns = max_pfns;
-    op.u.getmemlist.buffer   = pfn_buf;
+    SET_XEN_GUEST_HANDLE(op.u.getmemlist.buffer, pfn_buf);
 
 #ifdef VALGRIND
     memset(pfn_buf, 0, max_pfns * sizeof(unsigned long));
diff -r 96cc994dee76 xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h	Wed Apr 26 15:54:02 2006 -0500
+++ b/xen/include/public/arch-ia64.h	Wed Apr 26 16:21:20 2006 -0500
@@ -7,16 +7,13 @@
 #ifndef __HYPERVISOR_IF_IA64_H__
 #define __HYPERVISOR_IF_IA64_H__
 
-#ifdef __XEN__
 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
-#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_XEN_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_XEN_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
diff -r 96cc994dee76 xen/include/public/arch-x86_32.h
--- a/xen/include/public/arch-x86_32.h	Wed Apr 26 15:54:02 2006 -0500
+++ b/xen/include/public/arch-x86_32.h	Wed Apr 26 16:21:20 2006 -0500
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
-#ifdef __XEN__
 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
-#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
-#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_XEN_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_XEN_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
diff -r 96cc994dee76 xen/include/public/arch-x86_64.h
--- a/xen/include/public/arch-x86_64.h	Wed Apr 26 15:54:02 2006 -0500
+++ b/xen/include/public/arch-x86_64.h	Wed Apr 26 16:21:20 2006 -0500
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
 #define __XEN_PUBLIC_ARCH_X86_64_H__
 
-#ifdef __XEN__
 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
-#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_XEN_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_XEN_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */

[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 9%]

* [PATCH 1/2] balloon driver: relax BUG_ON() in increasee_reservation()
@ 2006-04-28  6:32 15% Isaku Yamahata
  0 siblings, 0 replies; 200+ results
From: Isaku Yamahata @ 2006-04-28  6:32 UTC (permalink / raw)
  To: xen-devel; +Cc: Isaku Yamahata, xen-ia64-devel

[-- Attachment #1: Type: text/plain, Size: 9 bytes --]


 1 / 2 

[-- Attachment #2: 9878:9a39580dffc0_balloon_driver_relax_bug_on.patch --]
[-- Type: text/plain, Size: 1119 bytes --]

# HG changeset patch
# User yamahata@valinux.co.jp
# Node ID 9a39580dffc0a5f92d18bcd2098b786118ed6a71
# Parent  d3427ce2d019077d34cc05be318be101122f49df
Relax BUG_ON() state ment in increase_reservation() in balloon.c.
When xen_feature(XENFEAT_auto_translated_physmap) = 1,
phys_to_machine_mapping_valid(pfn) always returns true.
Relaxed BUG_ON() for xen_feature(XENFEAT_auto_translated_physmap) = 1 case.
PATCHNAME: balloon_driver_relax_bug_on

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

diff -r d3427ce2d019 -r 9a39580dffc0 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Apr 28 11:10:24 2006 +0900
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Apr 28 15:20:20 2006 +0900
@@ -216,7 +216,8 @@ static int increase_reservation(unsigned
 		BUG_ON(page == NULL);
 
 		pfn = page_to_pfn(page);
-		BUG_ON(phys_to_machine_mapping_valid(pfn));
+		BUG_ON(!xen_feature(XENFEAT_auto_translated_physmap) &&
+		       phys_to_machine_mapping_valid(pfn));
 
 		/* Update P->M and M->P tables. */
 		set_phys_to_machine(pfn, frame_list[i]);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 15%]

* [PATCH 2/2] balloon driver: don't use apply_to_page_range for xenLinux/ia64
@ 2006-04-28  6:32 15% Isaku Yamahata
    0 siblings, 1 reply; 200+ results
From: Isaku Yamahata @ 2006-04-28  6:32 UTC (permalink / raw)
  To: xen-devel; +Cc: Isaku Yamahata, xen-ia64-devel

[-- Attachment #1: Type: text/plain, Size: 9 bytes --]


 2 / 2 

[-- Attachment #2: 9879:b5117df9f8ed_balloon_driver_ia64.patch --]
[-- Type: text/plain, Size: 1973 bytes --]

# HG changeset patch
# User yamahata@valinux.co.jp
# Node ID b5117df9f8edf6eca8ff7dc8be7e7458817707c8
# Parent  9a39580dffc0a5f92d18bcd2098b786118ed6a71
xenLinux/ia64 doesn't use init_mm for ballooned area so that
apply_to_page_range() isn't needed, only XENMEM_decrease_reservation is needed.
PATCHNAME: balloon_driver_ia64

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

diff -r 9a39580dffc0 -r b5117df9f8ed linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Apr 28 15:20:20 2006 +0900
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Apr 28 15:20:25 2006 +0900
@@ -517,6 +517,23 @@ void balloon_update_driver_allowance(lon
 	balloon_unlock(flags);
 }
 
+#ifdef __ia64__
+static int
+balloon_dealloc_range(unsigned long vstart, unsigned int order)
+{
+	int ret;
+	unsigned long gmfn = __pa(vstart) >> PAGE_SHIFT;
+	struct xen_memory_reservation reservation = {
+		.extent_start = &gmfn,
+		.nr_extents   = 1,
+		.extent_order = order,
+		.domid        = DOMID_SELF
+	};
+	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
+	BUG_ON(ret != 1);
+	return 0;
+}
+#else
 static int dealloc_pte_fn(
 	pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
 {
@@ -535,6 +552,14 @@ static int dealloc_pte_fn(
 	return 0;
 }
 
+static int
+balloon_dealloc_range(unsigned long vstart, unsigned int order)
+{
+	return apply_to_page_range(&init_mm, vstart,
+				   PAGE_SIZE << order, dealloc_pte_fn, NULL);
+}
+#endif
+
 struct page *balloon_alloc_empty_page_range(unsigned long nr_pages)
 {
 	unsigned long vstart, flags;
@@ -548,8 +573,7 @@ struct page *balloon_alloc_empty_page_ra
 	scrub_pages(vstart, 1 << order);
 
 	balloon_lock(flags);
-	ret = apply_to_page_range(&init_mm, vstart,
-				  PAGE_SIZE << order, dealloc_pte_fn, NULL);
+	ret = balloon_dealloc_range(vstart, order);
 	BUG_ON(ret);
 	current_pages -= 1UL << order;
 	totalram_pages = current_pages;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 15%]

* Re: [PATCH 2/2] balloon driver: don't use apply_to_page_range for xenLinux/ia64
  @ 2006-04-29  4:36 16%       ` Isaku Yamahata
  0 siblings, 0 replies; 200+ results
From: Isaku Yamahata @ 2006-04-29  4:36 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel, xen-ia64-devel

[-- Attachment #1: Type: text/plain, Size: 901 bytes --]

On Fri, Apr 28, 2006 at 02:57:17PM +0100, Keir Fraser wrote:
> 
> On 28 Apr 2006, at 10:14, Isaku Yamahata wrote:
> 
> >Unfortunately no.
> >Roughly init_mm is only used to map vmalloc area on Linux/ia64.
> >init_mm of Linux/ia64 doesn't map the area of [PAGE_OFFSET, ...].
> >Traversing init_mm with a virtual address of the area
> >gives a zero-filled pte entry.
> >It also populates unnecessary pud/pmd/pte pages.
> >
> >Linux/ia64 resolves faults on the area [PAGE_OFFSET, ...]
> >by tlb insert without init_mm traverse after checking
> >faulted virtual address and its privilege.
> 
> Okay, but the ia64 ifdefs are unfortunate. Your new scheme will work 
> for x86 autotranslated guests too (I'm pretty sure). How about we pick 
> between the two schemes based on the autotranslate feature flag rather 
> than 'ifdef ia64'?

I attached the updated patch.
I only tested on xen/ia64.

-- 
yamahata

[-- Attachment #2: 9890:6c2ab5cfca56.patch --]
[-- Type: text/plain, Size: 1472 bytes --]

# HG changeset patch
# User yamahata@valinux.co.jp
# Node ID 6c2ab5cfca56255320c82a36ebc35ad31d3951d5
# Parent  4f7ee25edd8141b6fa44f385d10cef62e18a2bb9
balloon driver: when autotranslate mode, pages are returned to xen without
traverseing init_mm
This change is needed for xen/ia64 vp model.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

diff -r 4f7ee25edd81 -r 6c2ab5cfca56 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sat Apr 29 13:17:03 2006 +0900
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sat Apr 29 13:19:39 2006 +0900
@@ -548,9 +548,22 @@ struct page *balloon_alloc_empty_page_ra
 	scrub_pages(vstart, 1 << order);
 
 	balloon_lock(flags);
-	ret = apply_to_page_range(&init_mm, vstart,
-				  PAGE_SIZE << order, dealloc_pte_fn, NULL);
-	BUG_ON(ret);
+	if (xen_feature(XENFEAT_auto_translated_physmap)) {
+		unsigned long gmfn = __pa(vstart) >> PAGE_SHIFT;
+		struct xen_memory_reservation reservation = {
+			.nr_extents   = 1,
+			.extent_order = order,
+			.domid        = DOMID_SELF
+		};
+		set_xen_guest_handle(reservation.extent_start, &gmfn);
+		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
+					   &reservation);
+		BUG_ON(ret != 1);
+	} else {
+		ret = apply_to_page_range(&init_mm, vstart, PAGE_SIZE << order,
+					  dealloc_pte_fn, NULL);
+		BUG_ON(ret);
+	}
 	current_pages -= 1UL << order;
 	totalram_pages = current_pages;
 	balloon_unlock(flags);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 16%]

* Re: [PATCH 2/5] [RESEND] changes of common files for xen/ia64 dom0 vp model: privcmd_mmap
  @ 2006-04-29  5:51  6%   ` Isaku Yamahata
  0 siblings, 0 replies; 200+ results
From: Isaku Yamahata @ 2006-04-29  5:51 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel, xen-ia64-devel

[-- Attachment #1: Type: text/plain, Size: 1224 bytes --]


On Fri, Apr 28, 2006 at 02:43:58PM +0100, Keir Fraser wrote:
> 
> On 28 Apr 2006, at 03:52, Isaku Yamahata wrote:
> 
> >introduce xen_arch_privcmd_mmap() to allow xen/ia64 to override 
> >privcmd_mmap()
> >later.
> >xen/ia64 with dom0 vp model also needs direct_remap_pfn_range() to be 
> >called
> >for IOCTL_PRIVCMD_MMAPBATCH.
> >These changes are necessary for xen/ia64 with dom0 vp model.
> 
> Can you describe the use of xen_arch_privcmd_mmap() for ia64? I checked 
> in the other hunks of this patch, but excluded the 
> xen_arch_privcmd_mmap bits for now -- they can go in a separate patch.

It sets its own vma->vm_ops to track mmap/munmap.
When the region is completely unmapped, pages of a foreign domain
are zapped from dom0.

I attached the patch which implements it.
(HYPERVISOR_add_physmap(), HYPERVISOR_zap_physmap() are ia64 specific
hypercalls.)
It can't be applied to xen-unstable.hg nor xen-ia64-unstable.hg
cleanly because it is one of the series patches which is being merged.
The patch will be merged into xen-ia64-unstable.hg in the near future.
(At least I hope so)
I think it can be simplified using PageForeign() and its families.
When I wrote it I did't want to use PG_foreign bit.

-- 
yamahata

[-- Attachment #2: 9780:ffd79e3ceeda_privcmd_direct_remap_pfn_range_linux.patch --]
[-- Type: text/plain, Size: 8850 bytes --]

# HG changeset patch
# User yamahata@valinux.co.jp
# Node ID ffd79e3ceeda444c864e7b14c593d0d3c1d5baa1
# Parent  b2e5392128582c1e508e7a77c67d4f45e0a24986
implemented direct_remap_pfn_range() and xen_arch_privcmd_mmap()
for foreing domain page mapping.
PATCHNAME: privcmd_direct_remap_pfn_range_linux

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

diff -r b2e539212858 -r ffd79e3ceeda linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c	Mon Apr 24 22:28:19 2006 +0900
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c	Mon Apr 24 22:28:21 2006 +0900
@@ -290,3 +290,281 @@ EXPORT_SYMBOL(balloon_update_driver_allo
 
 struct address_space xen_ia64_foreign_dummy_mapping;
 
+///////////////////////////////////////////////////////////////////////////
+// foreign mapping
+
+struct xen_ia64_privcmd_entry {
+	atomic_t	map_count;
+	struct page*	page;
+	unsigned long	mfn;
+};
+
+static void
+xen_ia64_privcmd_init_entry(struct xen_ia64_privcmd_entry* entry)
+{
+	atomic_set(&entry->map_count, 0);
+	entry->page = NULL;
+	entry->mfn = INVALID_MFN;
+}
+
+static int
+xen_ia64_privcmd_entry_mmap(struct vm_area_struct* vma,
+			    unsigned long addr,
+			    struct xen_ia64_privcmd_entry* entry,
+			    unsigned long mfn,
+			    pgprot_t prot,
+			    domid_t domid)
+{
+	int error = 0;
+	struct page* page;
+	unsigned long gpfn;
+
+	BUG_ON((addr & ~PAGE_MASK) != 0);
+	BUG_ON(mfn == INVALID_MFN);
+
+	if (entry->page != NULL) {
+		error = -EBUSY;
+		goto out;
+	}
+	page = alloc_page(GFP_KERNEL);
+	if (page == NULL) {
+		error = -ENOMEM;
+		goto out;
+	}
+	gpfn = page_to_pfn(page);
+
+	error = HYPERVISOR_add_physmap(gpfn, mfn, 0/* prot:XXX */,
+				       domid);
+	if (error != 0) {
+		goto out;
+	}
+
+	prot = vma->vm_page_prot;
+	error = remap_pfn_range(vma, addr, gpfn, 1 << PAGE_SHIFT, prot);
+	if (error != 0) {
+		(void)HYPERVISOR_zap_physmap(gpfn, 0);
+		error = HYPERVISOR_populate_physmap(gpfn, 0, 0);
+		if (error) {
+			BUG();//XXX
+		}
+		__free_page(page);
+	} else {
+		atomic_inc(&entry->map_count);
+		entry->page = page;
+		entry->mfn = mfn;
+	}
+
+out:
+	return error;
+}
+
+static void
+xen_ia64_privcmd_entry_munmap(struct xen_ia64_privcmd_entry* entry)
+{
+	struct page* page = entry->page;
+	unsigned long gpfn = page_to_pfn(page);
+	int error;
+
+	error = HYPERVISOR_zap_physmap(gpfn, 0);
+	if (error) {
+		BUG();//XXX
+	}
+
+	error = HYPERVISOR_populate_physmap(gpfn, 0, 0);
+	if (error) {
+		BUG();//XXX
+	}
+
+	entry->page = NULL;
+	entry->mfn = INVALID_MFN;
+	__free_page(page);
+}
+
+static int
+xen_ia64_privcmd_entry_open(struct xen_ia64_privcmd_entry* entry)
+{
+	if (entry->page != NULL) {
+		atomic_inc(&entry->map_count);
+	} else {
+		BUG_ON(atomic_read(&entry->map_count) != 0);
+	}
+}
+
+static int
+xen_ia64_privcmd_entry_close(struct xen_ia64_privcmd_entry* entry)
+{
+	if (entry->page != NULL && atomic_dec_and_test(&entry->map_count)) {
+		xen_ia64_privcmd_entry_munmap(entry);
+	}
+}
+
+struct xen_ia64_privcmd_file {
+	struct file*			file;
+	atomic_t			map_count;
+	unsigned long			pgoff; // in PAGE_SIZE
+
+	unsigned long			num_entries;
+	struct xen_ia64_privcmd_entry	entries[0];
+};
+
+struct xen_ia64_privcmd_vma {
+	struct xen_ia64_privcmd_file*	file;
+	unsigned long			num_entries;
+	struct xen_ia64_privcmd_entry*	entries;
+};
+
+static void xen_ia64_privcmd_vma_open(struct vm_area_struct* vma);
+static void xen_ia64_privcmd_vma_close(struct vm_area_struct* vma);
+
+struct vm_operations_struct xen_ia64_privcmd_vm_ops = {
+	.open = &xen_ia64_privcmd_vma_open,
+	.close = &xen_ia64_privcmd_vma_close,
+};
+
+static void
+__xen_ia64_privcmd_vma_open(struct vm_area_struct* vma,
+			    struct xen_ia64_privcmd_vma* privcmd_vma)
+{
+	struct xen_ia64_privcmd_file* privcmd_file =
+		(struct xen_ia64_privcmd_file*)vma->vm_file->private_data;
+	unsigned long entry_offset = vma->vm_pgoff - privcmd_file->pgoff;
+	unsigned long num_entries = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+	unsigned long i;
+
+	BUG_ON(entry_offset < 0);
+	BUG_ON(entry_offset + num_entries > privcmd_file->num_entries);
+
+	privcmd_vma->file = privcmd_file;
+	privcmd_vma->num_entries = num_entries;
+	privcmd_vma->entries = &privcmd_file->entries[entry_offset];
+	vma->vm_private_data = privcmd_vma;
+	for (i = 0; i < privcmd_vma->num_entries; i++) {
+		xen_ia64_privcmd_entry_open(&privcmd_vma->entries[i]);
+	}
+
+	vma->vm_private_data = privcmd_vma;
+	vma->vm_ops = &xen_ia64_privcmd_vm_ops;
+}
+
+static void
+xen_ia64_privcmd_vma_open(struct vm_area_struct* vma)
+{
+	struct xen_ia64_privcmd_file* privcmd_file =
+		(struct xen_ia64_privcmd_file*)vma->vm_file->private_data;
+	struct xen_ia64_privcmd_vma* privcmd_vma;
+
+	atomic_inc(&privcmd_file->map_count);
+	// vm_op->open() can't fail.
+	privcmd_vma = kmalloc(sizeof(*privcmd_vma), GFP_KERNEL | __GFP_NOFAIL);
+
+	__xen_ia64_privcmd_vma_open(vma, privcmd_vma);
+}
+
+static void
+xen_ia64_privcmd_vma_close(struct vm_area_struct* vma)
+{
+	struct xen_ia64_privcmd_vma* privcmd_vma =
+		(struct xen_ia64_privcmd_vma*)vma->vm_private_data;
+	struct xen_ia64_privcmd_file* privcmd_file = privcmd_vma->file;
+	unsigned long i;
+
+	for (i = 0; i < privcmd_vma->num_entries; i++) {
+		xen_ia64_privcmd_entry_close(&privcmd_vma->entries[i]);
+	}
+	vma->vm_private_data = NULL;
+	kfree(privcmd_vma);
+
+	if (atomic_dec_and_test(&privcmd_file->map_count)) {
+#if 1
+		for (i = 0; i < privcmd_file->num_entries; i++) {
+			struct xen_ia64_privcmd_entry* entry =
+				&privcmd_vma->entries[i];
+			BUG_ON(atomic_read(&entry->map_count) != 0);
+			BUG_ON(entry->page != NULL);
+		}
+#endif
+		privcmd_file->file->private_data = NULL;
+		kfree(privcmd_file->file->private_data);
+	}
+}
+
+int
+xen_arch_privcmd_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	unsigned long num_entries = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+	struct xen_ia64_privcmd_file* privcmd_file;
+	struct xen_ia64_privcmd_vma* privcmd_vma;
+	unsigned long i;
+	BUG_ON(!running_on_xen);
+
+	if (file->private_data != NULL) {
+		return -EBUSY;
+	}
+
+	privcmd_file = kmalloc(sizeof(*privcmd_file) +
+			       sizeof(privcmd_file->entries[0]) * num_entries,
+			       GFP_KERNEL);
+	if (privcmd_file == NULL) {
+		goto out_enomem0;
+	}
+	privcmd_vma = kmalloc(sizeof(*privcmd_vma), GFP_KERNEL);
+	if (privcmd_vma == NULL) {
+		goto out_enomem1;
+	}
+
+	atomic_set(&privcmd_file->map_count, 1);
+	privcmd_file->num_entries = num_entries;
+	for (i = 0; i < privcmd_file->num_entries; i++) {
+		xen_ia64_privcmd_init_entry(&privcmd_file->entries[i]);
+	}
+	file->private_data = privcmd_file;
+	privcmd_file->file = file;
+	privcmd_file->pgoff = vma->vm_pgoff;
+
+	__xen_ia64_privcmd_vma_open(vma, privcmd_vma);
+	return 0;
+
+out_enomem1:
+	kfree(privcmd_vma);
+out_enomem0:
+	kfree(privcmd_file);
+	return -ENOMEM;
+}
+
+int
+direct_remap_pfn_range(struct vm_area_struct *vma,
+		       unsigned long address,	// process virtual address
+		       unsigned long mfn,	// mfn, mfn + 1, ... mfn + size/PAGE_SIZE
+		       unsigned long size,
+		       pgprot_t prot,
+		       domid_t  domid)		// target domain
+{
+	struct xen_ia64_privcmd_vma* privcmd_vma =
+		(struct xen_ia64_privcmd_vma*)vma->vm_private_data;
+	unsigned long i;
+	unsigned long offset;
+	int error = 0;
+	BUG_ON(!running_on_xen);
+
+#if 0
+	if (prot != vm->vm_page_prot) {
+		return -EINVAL;
+	}
+#endif
+
+	i = 0;
+	for (offset = 0; offset < size; offset += PAGE_SIZE) {
+		struct xen_ia64_privcmd_entry* entry =
+			&privcmd_vma->file->entries[i];
+		error = xen_ia64_privcmd_entry_mmap(vma, (address + offset) & PAGE_MASK, entry, mfn, prot, domid);
+		if (error != 0) {
+			break;
+		}
+
+		i++;
+		mfn++;
+        }
+
+	return error;
+}
+
diff -r b2e539212858 -r ffd79e3ceeda linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Mon Apr 24 22:28:19 2006 +0900
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Mon Apr 24 22:28:21 2006 +0900
@@ -115,12 +115,22 @@ HYPERVISOR_poll(
 }
 
 // for drivers/xen/privcmd/privcmd.c
+#define machine_to_phys_mapping 0
+#ifndef CONFIG_XEN_IA64_DOM0_VP
 #define direct_remap_pfn_range(a,b,c,d,e,f) remap_pfn_range(a,b,c,d,e)
-#define machine_to_phys_mapping 0
 #define xen_arch_privcmd_mmap(file, vma)	(0)
-#ifndef CONFIG_XEN_IA64_DOM0_VP
 #define	pfn_to_mfn(x)	(x)
 #define	mfn_to_pfn(x)	(x)
+#else
+struct vm_area_struct;
+int direct_remap_pfn_range(struct vm_area_struct *vma,
+                           unsigned long address,
+                           unsigned long mfn,
+                           unsigned long size,
+                           pgprot_t prot,
+                           domid_t  domid);
+struct file;
+int xen_arch_privcmd_mmap(struct file *file, struct vm_area_struct *vma);
 #endif
 
 // for drivers/xen/balloon/balloon.c

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 6%]

* [PATCH] [XM-TEST] Fix memset tests when backend drivers are compiled into domU kernel
@ 2006-05-01 14:06 12% James Dykman
  0 siblings, 0 replies; 200+ results
From: James Dykman @ 2006-05-01 14:06 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 3175 bytes --]

Xm-tests 01_memset_basic_pos.test and 03_memset_random_pos.test start 
domUs with 64MB of memory, 
and assume that all of that memory is available in the domU. They then 
perform various xm memset tests
based on the assumed starting conditions.

When netback & blkback are comiled into the domU kernel, they eat about 
5MB. This mismatch will cause
01_memset_basic_pos.test to fail every time. 03_memset_random_pos.test 
will probably fail, but can
pass with some lucky numbers from the random number generator.

This patch changes both tests to read the starting memory allocation from 
the balloon driver in the domU.

Signed-off-by: Jim Dykman <dykman@us.ibm.com>

diff -r e0e68942b205 tools/xm-test/tests/memset/01_memset_basic_pos.py
--- a/tools/xm-test/tests/memset/01_memset_basic_pos.py Fri Apr 28 
16:44:00 2006 +0100
+++ b/tools/xm-test/tests/memset/01_memset_basic_pos.py Mon May  1 
09:50:46 2006 -0400
@@ -44,8 +44,20 @@ except ConsoleError, e:
 except ConsoleError, e:
     FAIL(str(e))

+try:
+    run = console.runCmd("cat /proc/xen/balloon | grep Current");
+except ConsoleError, e:
+    FAIL(str(e))
+
+match = re.match("[^0-9]+([0-9]+)", run["output"])
+if not match:
+    FAIL("Invalid domU meminfo line")
+
+origmem = int(match.group(1)) / 1024
+newmem = origmem - 1
+
 # set mem-set for less than default
-cmd = "xm mem-set %s %i" % (domain.getName(), 63)
+cmd = "xm mem-set %s %i" % (domain.getName(), newmem)
 status, output = traceCommand(cmd)
 if status != 0:
     if verbose:
@@ -55,7 +67,7 @@ if status != 0:

 for i in [1,2,3,4,5,6,7,8,9,10]:
     mem = getDomMem(domain.getName())
-    if mem == 63:
+    if mem == newmem:
         break
     time.sleep(1)

@@ -63,8 +75,8 @@ mem = getDomMem(domain.getName())
 mem = getDomMem(domain.getName())
 if not mem:
     FAIL("Failed to get memory amount for domain %s" % domain.getName())
-elif mem != 63:
-    FAIL("Dom0 failed to verify 63 MB; got %i MB" % mem)
+elif mem != newmem:
+    FAIL("Dom0 failed to verify %i MB; got %i MB" % newmem,mem)

 # verify memory set internally
 try:
@@ -79,7 +91,7 @@ if not m:

 domUmem = int(m.group(1)) / 1024

-if domUmem != 63:
+if domUmem != newmem:
     FAIL("DomU reported incorrect memory amount: %i MB" % (domUmem))

 # quiesce everything
diff -r e0e68942b205 tools/xm-test/tests/memset/03_memset_random_pos.py
--- a/tools/xm-test/tests/memset/03_memset_random_pos.py        Fri Apr 28 
16:44:00 2006 +0100
+++ b/tools/xm-test/tests/memset/03_memset_random_pos.py        Mon May  1 
09:50:46 2006 -0400
@@ -22,14 +22,24 @@ except DomainError, e:
     FAIL(str(e))

 times = random.randint(10,50)
-origmem = domain.config.getOpt("memory")
-currmem = domain.config.getOpt("memory")

 try:
     console = XmConsole(domain.getName())
     console.sendInput("input")
 except ConsoleError, e:
     FAIL(str(e))
+
+try:
+    run = console.runCmd("cat /proc/xen/balloon | grep Current");
+except ConsoleError, e:
+    FAIL(str(e))
+
+match = re.match("[^0-9]+([0-9]+)", run["output"])
+if not match:
+    FAIL("Invalid domU meminfo line")
+
+origmem = int(match.group(1)) / 1024
+currmem = origmem

 for i in range(0,times):
     amt = random.randint(-10,10)



[-- Attachment #2: memset.patch --]
[-- Type: application/octet-stream, Size: 2517 bytes --]

diff -r e0e68942b205 tools/xm-test/tests/memset/01_memset_basic_pos.py
--- a/tools/xm-test/tests/memset/01_memset_basic_pos.py	Fri Apr 28 16:44:00 2006 +0100
+++ b/tools/xm-test/tests/memset/01_memset_basic_pos.py	Mon May  1 09:50:46 2006 -0400
@@ -44,8 +44,20 @@ except ConsoleError, e:
 except ConsoleError, e:
     FAIL(str(e))
     
+try:
+    run = console.runCmd("cat /proc/xen/balloon | grep Current");
+except ConsoleError, e:
+    FAIL(str(e))
+
+match = re.match("[^0-9]+([0-9]+)", run["output"])
+if not match:
+    FAIL("Invalid domU meminfo line")
+        
+origmem = int(match.group(1)) / 1024
+newmem = origmem - 1
+
 # set mem-set for less than default
-cmd = "xm mem-set %s %i" % (domain.getName(), 63)
+cmd = "xm mem-set %s %i" % (domain.getName(), newmem)
 status, output = traceCommand(cmd)
 if status != 0:
     if verbose:
@@ -55,7 +67,7 @@ if status != 0:
 
 for i in [1,2,3,4,5,6,7,8,9,10]:
     mem = getDomMem(domain.getName())
-    if mem == 63:
+    if mem == newmem:
         break
     time.sleep(1)
 
@@ -63,8 +75,8 @@ mem = getDomMem(domain.getName())
 mem = getDomMem(domain.getName())
 if not mem:
     FAIL("Failed to get memory amount for domain %s" % domain.getName())
-elif mem != 63:
-    FAIL("Dom0 failed to verify 63 MB; got %i MB" % mem)
+elif mem != newmem:
+    FAIL("Dom0 failed to verify %i MB; got %i MB" % newmem,mem)
 
 # verify memory set internally
 try:
@@ -79,7 +91,7 @@ if not m:
 
 domUmem = int(m.group(1)) / 1024
 
-if domUmem != 63:
+if domUmem != newmem:
     FAIL("DomU reported incorrect memory amount: %i MB" % (domUmem))
 
 # quiesce everything
diff -r e0e68942b205 tools/xm-test/tests/memset/03_memset_random_pos.py
--- a/tools/xm-test/tests/memset/03_memset_random_pos.py	Fri Apr 28 16:44:00 2006 +0100
+++ b/tools/xm-test/tests/memset/03_memset_random_pos.py	Mon May  1 09:50:46 2006 -0400
@@ -22,14 +22,24 @@ except DomainError, e:
     FAIL(str(e))
 
 times = random.randint(10,50)
-origmem = domain.config.getOpt("memory")
-currmem = domain.config.getOpt("memory")
 
 try:
     console = XmConsole(domain.getName())
     console.sendInput("input")
 except ConsoleError, e:
     FAIL(str(e))
+
+try:
+    run = console.runCmd("cat /proc/xen/balloon | grep Current");
+except ConsoleError, e:
+    FAIL(str(e))
+
+match = re.match("[^0-9]+([0-9]+)", run["output"])
+if not match:
+    FAIL("Invalid domU meminfo line")
+        
+origmem = int(match.group(1)) / 1024
+currmem = origmem
 
 for i in range(0,times):
     amt = random.randint(-10,10)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 12%]

* [RFC PATCH 34/35] Add the Xen virtual network device driver.
  @ 2006-05-09  7:00  4% ` Chris Wright
  0 siblings, 0 replies; 200+ results
From: Chris Wright @ 2006-05-09  7:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: virtualization, xen-devel, Ian Pratt, Christian Limpach, netdev

[-- Attachment #1: netfront --]
[-- Type: text/plain, Size: 46804 bytes --]

The network device frontend driver allows the kernel to access network
devices exported exported by a virtual machine containing a physical
network device driver.

Signed-off-by: Ian Pratt <ian.pratt@xensource.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Cc: netdev@vger.kernel.org
---
TODO:
- drop proc
- more ethtool ops
- s/g support

 drivers/net/Kconfig             |    2 
 drivers/xen/Kconfig.net         |   14 
 drivers/xen/Makefile            |    3 
 drivers/xen/net_driver_util.c   |   58 +
 drivers/xen/netfront/Makefile   |    4 
 drivers/xen/netfront/netfront.c | 1510 ++++++++++++++++++++++++++++++++++++++++
 include/xen/net_driver_util.h   |   48 +
 7 files changed, 1639 insertions(+)

--- linus-2.6.orig/drivers/net/Kconfig
+++ linus-2.6/drivers/net/Kconfig
@@ -2325,6 +2325,8 @@ source "drivers/atm/Kconfig"
 
 source "drivers/s390/net/Kconfig"
 
+source "drivers/xen/Kconfig.net"
+
 config ISERIES_VETH
 	tristate "iSeries Virtual Ethernet driver support"
 	depends on PPC_ISERIES
--- linus-2.6.orig/drivers/xen/Makefile
+++ linus-2.6/drivers/xen/Makefile
@@ -1,7 +1,10 @@
 
+obj-y	+= net_driver_util.o
 obj-y	+= util.o
 
 obj-y	+= core/
 obj-y	+= console/
 obj-y	+= xenbus/
 
+obj-$(CONFIG_XEN_NETDEV_FRONTEND)	+= netfront/
+
--- /dev/null
+++ linus-2.6/drivers/xen/Kconfig.net
@@ -0,0 +1,14 @@
+menu "Xen network device drivers"
+        depends on NETDEVICES && XEN
+
+config XEN_NETDEV_FRONTEND
+	tristate "Network-device frontend driver"
+	depends on XEN
+	default y
+	help
+	  The network-device frontend driver allows the kernel to access
+	  network interfaces within another guest OS. Unless you are building a
+	  dedicated device-driver domain, or your master control domain
+	  (domain 0), then you almost certainly want to say Y here.
+
+endmenu
--- /dev/null
+++ linus-2.6/drivers/xen/net_driver_util.c
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ *
+ * Utility functions for Xen network devices.
+ *
+ * Copyright (c) 2005 XenSource Ltd.
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this source file (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.
+ */
+
+#include <linux/if_ether.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <xen/net_driver_util.h>
+
+
+int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
+{
+	char *s;
+	int i;
+	char *e;
+	char *macstr = xenbus_read(XBT_NULL, dev->nodename, "mac", NULL);
+	if (IS_ERR(macstr))
+		return PTR_ERR(macstr);
+	s = macstr;
+	for (i = 0; i < ETH_ALEN; i++) {
+		mac[i] = simple_strtoul(s, &e, 16);
+		if (s == e || (e[0] != ':' && e[0] != 0)) {
+			kfree(macstr);
+			return -ENOENT;
+		}
+		s = &e[1];
+	}
+	kfree(macstr);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(xen_net_read_mac);
--- /dev/null
+++ linus-2.6/drivers/xen/netfront/Makefile
@@ -0,0 +1,4 @@
+
+obj-$(CONFIG_XEN_NETDEV_FRONTEND)	:= xennet.o
+
+xennet-objs := netfront.o
--- /dev/null
+++ linus-2.6/drivers/xen/netfront/netfront.c
@@ -0,0 +1,1510 @@
+/******************************************************************************
+ * Virtual network driver for conversing with remote driver backends.
+ * 
+ * Copyright (c) 2002-2005, K A Fraser
+ * Copyright (c) 2005, XenSource Ltd
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/netdevice.h>
+#include <linux/inetdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/init.h>
+#include <linux/bitops.h>
+#include <linux/proc_fs.h>
+#include <linux/ethtool.h>
+#include <linux/in.h>
+#include <net/sock.h>
+#include <net/pkt_sched.h>
+#include <net/arp.h>
+#include <net/route.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <xen/evtchn.h>
+#include <xen/xenbus.h>
+#include <xen/interface/io/netif.h>
+#include <xen/interface/memory.h>
+#ifdef CONFIG_XEN_BALLOON
+#include <xen/balloon.h>
+#endif
+#include <asm/page.h>
+#include <asm/uaccess.h>
+#include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
+#include <xen/net_driver_util.h>
+
+#define GRANT_INVALID_REF	0
+
+#define NET_TX_RING_SIZE __RING_SIZE((struct netif_tx_sring *)0, PAGE_SIZE)
+#define NET_RX_RING_SIZE __RING_SIZE((struct netif_rx_sring *)0, PAGE_SIZE)
+
+static inline void init_skb_shinfo(struct sk_buff *skb)
+{
+	atomic_set(&(skb_shinfo(skb)->dataref), 1);
+	skb_shinfo(skb)->nr_frags = 0;
+	skb_shinfo(skb)->frag_list = NULL;
+}
+
+struct netfront_info
+{
+	struct list_head list;
+	struct net_device *netdev;
+
+	struct net_device_stats stats;
+	unsigned int tx_full;
+
+	struct netif_tx_front_ring tx;
+	struct netif_rx_front_ring rx;
+
+	spinlock_t   tx_lock;
+	spinlock_t   rx_lock;
+
+	unsigned int handle;
+	unsigned int evtchn, irq;
+
+	/* What is the status of our connection to the remote backend? */
+#define BEST_CLOSED       0
+#define BEST_DISCONNECTED 1
+#define BEST_CONNECTED    2
+	unsigned int backend_state;
+
+	/* Is this interface open or closed (down or up)? */
+#define UST_CLOSED        0
+#define UST_OPEN          1
+	unsigned int user_state;
+
+	/* Receive-ring batched refills. */
+#define RX_MIN_TARGET 8
+#define RX_DFL_MIN_TARGET 64
+#define RX_MAX_TARGET NET_RX_RING_SIZE
+	int rx_min_target, rx_max_target, rx_target;
+	struct sk_buff_head rx_batch;
+
+	struct timer_list rx_refill_timer;
+
+	/*
+	 * {tx,rx}_skbs store outstanding skbuffs. The first entry in each
+	 * array is an index into a chain of free entries.
+	 */
+	struct sk_buff *tx_skbs[NET_TX_RING_SIZE+1];
+	struct sk_buff *rx_skbs[NET_RX_RING_SIZE+1];
+
+	grant_ref_t gref_tx_head;
+	grant_ref_t grant_tx_ref[NET_TX_RING_SIZE + 1];
+	grant_ref_t gref_rx_head;
+	grant_ref_t grant_rx_ref[NET_TX_RING_SIZE + 1];
+
+	struct xenbus_device *xbdev;
+	int tx_ring_ref;
+	int rx_ring_ref;
+	u8 mac[ETH_ALEN];
+
+	unsigned long rx_pfn_array[NET_RX_RING_SIZE];
+	struct multicall_entry rx_mcl[NET_RX_RING_SIZE+1];
+	struct mmu_update rx_mmu[NET_RX_RING_SIZE];
+};
+
+/*
+ * Access macros for acquiring freeing slots in {tx,rx}_skbs[].
+ */
+
+static inline void add_id_to_freelist(struct sk_buff **list, unsigned short id)
+{
+	list[id] = list[0];
+	list[0]  = (void *)(unsigned long)id;
+}
+
+static inline unsigned short get_id_from_freelist(struct sk_buff **list)
+{
+	unsigned int id = (unsigned int)(unsigned long)list[0];
+	list[0] = list[id];
+	return id;
+}
+
+#ifdef DEBUG
+static char *be_state_name[] = {
+	[BEST_CLOSED]       = "closed",
+	[BEST_DISCONNECTED] = "disconnected",
+	[BEST_CONNECTED]    = "connected",
+};
+#endif
+
+#define DPRINTK(fmt, args...) pr_debug("netfront (%s:%d) " fmt, \
+                                       __FUNCTION__, __LINE__, ##args)
+#define IPRINTK(fmt, args...)				\
+	printk(KERN_INFO "netfront: " fmt, ##args)
+#define WPRINTK(fmt, args...)				\
+	printk(KERN_WARNING "netfront: " fmt, ##args)
+
+
+static int talk_to_backend(struct xenbus_device *, struct netfront_info *);
+static int setup_device(struct xenbus_device *, struct netfront_info *);
+static int create_netdev(int, struct xenbus_device *, struct net_device **);
+
+static void netfront_closing(struct xenbus_device *);
+
+static void end_access(int, void *);
+static void netif_disconnect_backend(struct netfront_info *);
+static void close_netdev(struct netfront_info *);
+static void netif_free(struct netfront_info *);
+
+static void show_device(struct netfront_info *);
+
+static void network_connect(struct net_device *);
+static void network_tx_buf_gc(struct net_device *);
+static void network_alloc_rx_buffers(struct net_device *);
+static int send_fake_arp(struct net_device *);
+
+static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs);
+
+#define XEN_XENNET_PROC_INTERFACE
+#if defined(CONFIG_PROC_FS) && defined(XEN_XENNET_PROC_INTERFACE)
+static int xennet_proc_init(void);
+static int xennet_proc_addif(struct net_device *dev);
+static void xennet_proc_delif(struct net_device *dev);
+#else
+#define xennet_proc_init()  (0)
+#define xennet_proc_addif(d) (0)
+#define xennet_proc_delif(d) ((void)0)
+#endif
+
+
+/**
+ * Entry point to this code when a new device is created.  Allocate the basic
+ * structures and the ring buffers for communication with the backend, and
+ * inform the backend of the appropriate details for those.  Switch to
+ * Connected state.
+ */
+static int netfront_probe(struct xenbus_device *dev,
+			  const struct xenbus_device_id *id)
+{
+	int err;
+	struct net_device *netdev;
+	struct netfront_info *info;
+	unsigned int handle;
+
+	err = xenbus_scanf(XBT_NULL, dev->nodename, "handle", "%u", &handle);
+	if (err != 1) {
+		xenbus_dev_fatal(dev, err, "reading handle");
+		return err;
+	}
+
+	err = create_netdev(handle, dev, &netdev);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "creating netdev");
+		return err;
+	}
+
+	info = netdev_priv(netdev);
+	dev->data = info;
+
+	err = talk_to_backend(dev, info);
+	if (err) {
+		kfree(info);
+		dev->data = NULL;
+		return err;
+	}
+
+	return 0;
+}
+
+
+/**
+ * We are reconnecting to the backend, due to a suspend/resume, or a backend
+ * driver restart.  We tear down our netif structure and recreate it, but
+ * leave the device-layer structures intact so that this is transparent to the
+ * rest of the kernel.
+ */
+static int netfront_resume(struct xenbus_device *dev)
+{
+	struct netfront_info *info = dev->data;
+
+	DPRINTK("%s\n", dev->nodename);
+
+	netif_disconnect_backend(info);
+	return talk_to_backend(dev, info);
+}
+
+
+/* Common code used when first setting up, and when resuming. */
+static int talk_to_backend(struct xenbus_device *dev,
+			   struct netfront_info *info)
+{
+	const char *message;
+	xenbus_transaction_t xbt;
+	int err;
+
+	err = xen_net_read_mac(dev, info->mac);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
+		goto out;
+	}
+
+	/* Create shared ring, alloc event channel. */
+	err = setup_device(dev, info);
+	if (err)
+		goto out;
+
+again:
+	err = xenbus_transaction_start(&xbt);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "starting transaction");
+		goto destroy_ring;
+	}
+
+	err = xenbus_printf(xbt, dev->nodename, "tx-ring-ref","%u",
+			    info->tx_ring_ref);
+	if (err) {
+		message = "writing tx ring-ref";
+		goto abort_transaction;
+	}
+	err = xenbus_printf(xbt, dev->nodename, "rx-ring-ref","%u",
+			    info->rx_ring_ref);
+	if (err) {
+		message = "writing rx ring-ref";
+		goto abort_transaction;
+	}
+	err = xenbus_printf(xbt, dev->nodename,
+			    "event-channel", "%u", info->evtchn);
+	if (err) {
+		message = "writing event-channel";
+		goto abort_transaction;
+	}
+
+	err = xenbus_printf(xbt, dev->nodename,
+			    "state", "%d", XenbusStateConnected);
+	if (err) {
+		message = "writing frontend XenbusStateConnected";
+		goto abort_transaction;
+	}
+
+	err = xenbus_transaction_end(xbt, 0);
+	if (err) {
+		if (err == -EAGAIN)
+			goto again;
+		xenbus_dev_fatal(dev, err, "completing transaction");
+		goto destroy_ring;
+	}
+
+	return 0;
+
+ abort_transaction:
+	xenbus_transaction_end(xbt, 1);
+	xenbus_dev_fatal(dev, err, "%s", message);
+ destroy_ring:
+	netif_free(info);
+ out:
+	return err;
+}
+
+
+static int setup_device(struct xenbus_device *dev, struct netfront_info *info)
+{
+	struct netif_tx_sring *txs;
+	struct netif_rx_sring *rxs;
+	int err;
+	struct net_device *netdev = info->netdev;
+
+	info->tx_ring_ref = GRANT_INVALID_REF;
+	info->rx_ring_ref = GRANT_INVALID_REF;
+	info->rx.sring = NULL;
+	info->tx.sring = NULL;
+	info->irq = 0;
+
+	txs = (struct netif_tx_sring *)get_zeroed_page(GFP_KERNEL);
+	if (!txs) {
+		err = -ENOMEM;
+		xenbus_dev_fatal(dev, err, "allocating tx ring page");
+		goto fail;
+	}
+	rxs = (struct netif_rx_sring *)get_zeroed_page(GFP_KERNEL);
+	if (!rxs) {
+		err = -ENOMEM;
+		xenbus_dev_fatal(dev, err, "allocating rx ring page");
+		free_page((unsigned long)txs);
+		goto fail;
+	}
+	info->backend_state = BEST_DISCONNECTED;
+
+	SHARED_RING_INIT(txs);
+	FRONT_RING_INIT(&info->tx, txs, PAGE_SIZE);
+
+	SHARED_RING_INIT(rxs);
+	FRONT_RING_INIT(&info->rx, rxs, PAGE_SIZE);
+
+	err = xenbus_grant_ring(dev, virt_to_mfn(txs));
+	if (err < 0)
+		goto fail;
+	info->tx_ring_ref = err;
+
+	err = xenbus_grant_ring(dev, virt_to_mfn(rxs));
+	if (err < 0)
+		goto fail;
+	info->rx_ring_ref = err;
+
+	err = xenbus_alloc_evtchn(dev, &info->evtchn);
+	if (err)
+		goto fail;
+
+	memcpy(netdev->dev_addr, info->mac, ETH_ALEN);
+	network_connect(netdev);
+	info->irq = bind_evtchn_to_irqhandler(
+		info->evtchn, netif_int, SA_SAMPLE_RANDOM, netdev->name,
+		netdev);
+	(void)send_fake_arp(netdev);
+	show_device(info);
+
+	return 0;
+
+ fail:
+	netif_free(info);
+	return err;
+}
+
+
+/**
+ * Callback received when the backend's state changes.
+ */
+static void backend_changed(struct xenbus_device *dev,
+			    XenbusState backend_state)
+{
+	DPRINTK("\n");
+
+	switch (backend_state) {
+	case XenbusStateInitialising:
+	case XenbusStateInitWait:
+	case XenbusStateInitialised:
+	case XenbusStateConnected:
+	case XenbusStateUnknown:
+	case XenbusStateClosed:
+		break;
+
+	case XenbusStateClosing:
+		netfront_closing(dev);
+		break;
+	}
+}
+
+
+/** Send a packet on a net device to encourage switches to learn the
+ * MAC. We send a fake ARP request.
+ *
+ * @param dev device
+ * @return 0 on success, error code otherwise
+ */
+static int send_fake_arp(struct net_device *dev)
+{
+	struct sk_buff *skb;
+	u32             src_ip, dst_ip;
+
+	dst_ip = INADDR_BROADCAST;
+	src_ip = inet_select_addr(dev, dst_ip, RT_SCOPE_LINK);
+
+	/* No IP? Then nothing to do. */
+	if (src_ip == 0)
+		return 0;
+
+	skb = arp_create(ARPOP_REPLY, ETH_P_ARP,
+			 dst_ip, dev, src_ip,
+			 /*dst_hw*/ NULL, /*src_hw*/ NULL,
+			 /*target_hw*/ dev->dev_addr);
+	if (skb == NULL)
+		return -ENOMEM;
+
+	return dev_queue_xmit(skb);
+}
+
+
+static int network_open(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+
+	memset(&np->stats, 0, sizeof(np->stats));
+
+	np->user_state = UST_OPEN;
+
+	network_alloc_rx_buffers(dev);
+	np->rx.sring->rsp_event = np->rx.rsp_cons + 1;
+
+	netif_start_queue(dev);
+
+	return 0;
+}
+
+static void network_tx_buf_gc(struct net_device *dev)
+{
+	RING_IDX i, prod;
+	unsigned short id;
+	struct netfront_info *np = netdev_priv(dev);
+	struct sk_buff *skb;
+
+	if (np->backend_state != BEST_CONNECTED)
+		return;
+
+	do {
+		prod = np->tx.sring->rsp_prod;
+		rmb(); /* Ensure we see responses up to 'rp'. */
+
+		for (i = np->tx.rsp_cons; i != prod; i++) {
+			id  = RING_GET_RESPONSE(&np->tx, i)->id;
+			skb = np->tx_skbs[id];
+			if (unlikely(gnttab_query_foreign_access(
+				np->grant_tx_ref[id]) != 0)) {
+				printk(KERN_ALERT "network_tx_buf_gc: warning "
+				       "-- grant still in use by backend "
+				       "domain.\n");
+				goto out;
+			}
+			gnttab_end_foreign_access_ref(
+				np->grant_tx_ref[id], GNTMAP_readonly);
+			gnttab_release_grant_reference(
+				&np->gref_tx_head, np->grant_tx_ref[id]);
+			np->grant_tx_ref[id] = GRANT_INVALID_REF;
+			add_id_to_freelist(np->tx_skbs, id);
+			dev_kfree_skb_irq(skb);
+		}
+
+		np->tx.rsp_cons = prod;
+
+		/*
+		 * Set a new event, then check for race with update of tx_cons.
+		 * Note that it is essential to schedule a callback, no matter
+		 * how few buffers are pending. Even if there is space in the
+		 * transmit ring, higher layers may be blocked because too much
+		 * data is outstanding: in such cases notification from Xen is
+		 * likely to be the only kick that we'll get.
+		 */
+		np->tx.sring->rsp_event =
+			prod + ((np->tx.sring->req_prod - prod) >> 1) + 1;
+		mb();
+	} while (prod != np->tx.sring->rsp_prod);
+
+ out:
+	if (np->tx_full &&
+	    ((np->tx.sring->req_prod - prod) < NET_TX_RING_SIZE)) {
+		np->tx_full = 0;
+		if (np->user_state == UST_OPEN)
+			netif_wake_queue(dev);
+	}
+}
+
+
+static void rx_refill_timeout(unsigned long data)
+{
+	struct net_device *dev = (struct net_device *)data;
+	netif_rx_schedule(dev);
+}
+
+
+static void network_alloc_rx_buffers(struct net_device *dev)
+{
+	unsigned short id;
+	struct netfront_info *np = netdev_priv(dev);
+	struct sk_buff *skb;
+	int i, batch_target;
+	RING_IDX req_prod = np->rx.req_prod_pvt;
+	struct xen_memory_reservation reservation;
+	grant_ref_t ref;
+
+	if (unlikely(np->backend_state != BEST_CONNECTED))
+		return;
+
+	/*
+	 * Allocate skbuffs greedily, even though we batch updates to the
+	 * receive ring. This creates a less bursty demand on the memory
+	 * allocator, so should reduce the chance of failed allocation requests
+	 * both for ourself and for other kernel subsystems.
+	 */
+	batch_target = np->rx_target - (req_prod - np->rx.rsp_cons);
+	for (i = skb_queue_len(&np->rx_batch); i < batch_target; i++) {
+		/*
+		 * Subtract dev_alloc_skb headroom (16 bytes) and shared info
+		 * tailroom then round down to SKB_DATA_ALIGN boundary.
+		 */
+		skb = __dev_alloc_skb(
+			((PAGE_SIZE - sizeof(struct skb_shared_info)) &
+			 (-SKB_DATA_ALIGN(1))) - 16,
+			GFP_ATOMIC|__GFP_NOWARN);
+		if (skb == NULL) {
+			/* Any skbuffs queued for refill? Force them out. */
+			if (i != 0)
+				goto refill;
+			/* Could not allocate any skbuffs. Try again later. */
+			mod_timer(&np->rx_refill_timer,
+				  jiffies + (HZ/10));
+			return;
+		}
+		__skb_queue_tail(&np->rx_batch, skb);
+	}
+
+	/* Is the batch large enough to be worthwhile? */
+	if (i < (np->rx_target/2))
+		return;
+
+	/* Adjust our fill target if we risked running out of buffers. */
+	if (((req_prod - np->rx.sring->rsp_prod) < (np->rx_target / 4)) &&
+	    ((np->rx_target *= 2) > np->rx_max_target))
+		np->rx_target = np->rx_max_target;
+
+ refill:
+	for (i = 0; ; i++) {
+		if ((skb = __skb_dequeue(&np->rx_batch)) == NULL)
+			break;
+
+		skb->dev = dev;
+
+		id = get_id_from_freelist(np->rx_skbs);
+
+		np->rx_skbs[id] = skb;
+
+		RING_GET_REQUEST(&np->rx, req_prod + i)->id = id;
+		ref = gnttab_claim_grant_reference(&np->gref_rx_head);
+		BUG_ON((signed short)ref < 0);
+		np->grant_rx_ref[id] = ref;
+		gnttab_grant_foreign_transfer_ref(ref,
+						  np->xbdev->otherend_id,
+						  __pa(skb->head) >> PAGE_SHIFT);
+		RING_GET_REQUEST(&np->rx, req_prod + i)->gref = ref;
+		np->rx_pfn_array[i] = virt_to_mfn(skb->head);
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+			/* Remove this page before passing back to Xen. */
+			set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT,
+					    INVALID_P2M_ENTRY);
+			MULTI_update_va_mapping(np->rx_mcl+i,
+						(unsigned long)skb->head,
+						__pte(0), 0);
+		}
+#endif
+	}
+
+#ifdef CONFIG_XEN_BALLOON
+	/* Tell the ballon driver what is going on. */
+	balloon_update_driver_allowance(i);
+#endif
+
+	reservation.extent_start = np->rx_pfn_array;
+	reservation.nr_extents   = i;
+	reservation.extent_order = 0;
+	reservation.address_bits = 0;
+	reservation.domid        = DOMID_SELF;
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+		/* After all PTEs have been zapped, flush the TLB. */
+		np->rx_mcl[i-1].args[MULTI_UVMFLAGS_INDEX] =
+			UVMF_TLB_FLUSH|UVMF_ALL;
+
+		/* Give away a batch of pages. */
+		np->rx_mcl[i].op = __HYPERVISOR_memory_op;
+		np->rx_mcl[i].args[0] = XENMEM_decrease_reservation;
+		np->rx_mcl[i].args[1] = (unsigned long)&reservation;
+
+		/* Zap PTEs and give away pages in one big multicall. */
+		(void)HYPERVISOR_multicall(np->rx_mcl, i+1);
+
+		/* Check return status of HYPERVISOR_memory_op(). */
+		if (unlikely(np->rx_mcl[i].result != i))
+			panic("Unable to reduce memory reservation\n");
+	} else
+#endif
+		if (HYPERVISOR_memory_op(XENMEM_decrease_reservation,
+					 &reservation) != i)
+			panic("Unable to reduce memory reservation\n");
+
+	/* Above is a suitable barrier to ensure backend will see requests. */
+	np->rx.req_prod_pvt = req_prod + i;
+	RING_PUSH_REQUESTS(&np->rx);
+}
+
+
+static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	unsigned short id;
+	struct netfront_info *np = netdev_priv(dev);
+	struct netif_tx_request *tx;
+	RING_IDX i;
+	grant_ref_t ref;
+	unsigned long mfn;
+	int notify;
+
+	if (unlikely(np->tx_full)) {
+		printk(KERN_ALERT "%s: full queue wasn't stopped!\n",
+		       dev->name);
+		netif_stop_queue(dev);
+		goto drop;
+	}
+
+	if (unlikely((((unsigned long)skb->data & ~PAGE_MASK) + skb->len) >=
+		     PAGE_SIZE)) {
+		struct sk_buff *nskb;
+		nskb = __dev_alloc_skb(skb->len, GFP_ATOMIC|__GFP_NOWARN);
+		if (unlikely(nskb == NULL))
+			goto drop;
+		skb_put(nskb, skb->len);
+		memcpy(nskb->data, skb->data, skb->len);
+		nskb->dev = skb->dev;
+		dev_kfree_skb(skb);
+		skb = nskb;
+	}
+
+	spin_lock_irq(&np->tx_lock);
+
+	if (np->backend_state != BEST_CONNECTED) {
+		spin_unlock_irq(&np->tx_lock);
+		goto drop;
+	}
+
+	i = np->tx.req_prod_pvt;
+
+	id = get_id_from_freelist(np->tx_skbs);
+	np->tx_skbs[id] = skb;
+
+	tx = RING_GET_REQUEST(&np->tx, i);
+
+	tx->id   = id;
+	ref = gnttab_claim_grant_reference(&np->gref_tx_head);
+	BUG_ON((signed short)ref < 0);
+	mfn = virt_to_mfn(skb->data);
+	gnttab_grant_foreign_access_ref(
+		ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);
+	tx->gref = np->grant_tx_ref[id] = ref;
+	tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
+	tx->size = skb->len;
+	tx->flags = (skb->ip_summed == CHECKSUM_HW) ? NETTXF_csum_blank : 0;
+
+	np->tx.req_prod_pvt = i + 1;
+	RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);
+	if (notify)
+		notify_remote_via_irq(np->irq);
+
+	network_tx_buf_gc(dev);
+
+	if (RING_FULL(&np->tx)) {
+		np->tx_full = 1;
+		netif_stop_queue(dev);
+	}
+
+	spin_unlock_irq(&np->tx_lock);
+
+	np->stats.tx_bytes += skb->len;
+	np->stats.tx_packets++;
+
+	return 0;
+
+ drop:
+	np->stats.tx_dropped++;
+	dev_kfree_skb(skb);
+	return 0;
+}
+
+static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs)
+{
+	struct net_device *dev = dev_id;
+	struct netfront_info *np = netdev_priv(dev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&np->tx_lock, flags);
+	network_tx_buf_gc(dev);
+	spin_unlock_irqrestore(&np->tx_lock, flags);
+
+	if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx) &&
+	    (np->user_state == UST_OPEN))
+		netif_rx_schedule(dev);
+
+	return IRQ_HANDLED;
+}
+
+
+static int netif_poll(struct net_device *dev, int *pbudget)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	struct sk_buff *skb, *nskb;
+	struct netif_rx_response *rx;
+	RING_IDX i, rp;
+	struct mmu_update *mmu = np->rx_mmu;
+	struct multicall_entry *mcl = np->rx_mcl;
+	int work_done, budget, more_to_do = 1;
+	struct sk_buff_head rxq;
+	unsigned long flags;
+	unsigned long mfn;
+	grant_ref_t ref;
+
+	spin_lock(&np->rx_lock);
+
+	if (np->backend_state != BEST_CONNECTED) {
+		spin_unlock(&np->rx_lock);
+		return 0;
+	}
+
+	skb_queue_head_init(&rxq);
+
+	if ((budget = *pbudget) > dev->quota)
+		budget = dev->quota;
+	rp = np->rx.sring->rsp_prod;
+	rmb(); /* Ensure we see queued responses up to 'rp'. */
+
+	for (i = np->rx.rsp_cons, work_done = 0;
+	     (i != rp) && (work_done < budget);
+	     i++, work_done++) {
+		rx = RING_GET_RESPONSE(&np->rx, i);
+
+		/*
+                 * This definitely indicates a bug, either in this driver or
+                 * in the backend driver. In future this should flag the bad
+                 * situation to the system controller to reboot the backed.
+                 */
+		if ((ref = np->grant_rx_ref[rx->id]) == GRANT_INVALID_REF) {
+			WPRINTK("Bad rx response id %d.\n", rx->id);
+			work_done--;
+			continue;
+		}
+
+		/* Memory pressure, insufficient buffer headroom, ... */
+		if ((mfn = gnttab_end_foreign_transfer_ref(ref)) == 0) {
+			if (net_ratelimit())
+				WPRINTK("Unfulfilled rx req (id=%d, st=%d).\n",
+					rx->id, rx->status);
+			RING_GET_REQUEST(&np->rx, np->rx.req_prod_pvt)->id =
+				rx->id;
+			RING_GET_REQUEST(&np->rx, np->rx.req_prod_pvt)->gref =
+				ref;
+			np->rx.req_prod_pvt++;
+			RING_PUSH_REQUESTS(&np->rx);
+			work_done--;
+			continue;
+		}
+
+		gnttab_release_grant_reference(&np->gref_rx_head, ref);
+		np->grant_rx_ref[rx->id] = GRANT_INVALID_REF;
+
+		skb = np->rx_skbs[rx->id];
+		add_id_to_freelist(np->rx_skbs, rx->id);
+
+		/* NB. We handle skb overflow later. */
+		skb->data = skb->head + rx->offset;
+		skb->len  = rx->status;
+		skb->tail = skb->data + skb->len;
+
+		if (rx->flags & NETRXF_data_validated)
+			skb->ip_summed = CHECKSUM_UNNECESSARY;
+
+		np->stats.rx_packets++;
+		np->stats.rx_bytes += rx->status;
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+			/* Remap the page. */
+			MULTI_update_va_mapping(mcl, (unsigned long)skb->head,
+						pfn_pte_ma(mfn, PAGE_KERNEL),
+						0);
+			mcl++;
+			mmu->ptr = ((maddr_t)mfn << PAGE_SHIFT)
+				| MMU_MACHPHYS_UPDATE;
+			mmu->val = __pa(skb->head) >> PAGE_SHIFT;
+			mmu++;
+
+			set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT,
+					    mfn);
+		}
+#endif
+
+		__skb_queue_tail(&rxq, skb);
+	}
+
+#ifdef CONFIG_XEN_BALLOON
+	/* Some pages are no longer absent... */
+	balloon_update_driver_allowance(-work_done);
+#endif
+
+	/* Do all the remapping work, and M2P updates, in one big hypercall. */
+	if (likely((mcl - np->rx_mcl) != 0)) {
+		mcl->op = __HYPERVISOR_mmu_update;
+		mcl->args[0] = (unsigned long)np->rx_mmu;
+		mcl->args[1] = mmu - np->rx_mmu;
+		mcl->args[2] = 0;
+		mcl->args[3] = DOMID_SELF;
+		mcl++;
+		(void)HYPERVISOR_multicall(np->rx_mcl, mcl - np->rx_mcl);
+	}
+
+	while ((skb = __skb_dequeue(&rxq)) != NULL) {
+		if (skb->len > (dev->mtu + ETH_HLEN + 4)) {
+			if (net_ratelimit())
+				printk(KERN_INFO "Received packet too big for "
+				       "MTU (%d > %d)\n",
+				       skb->len - ETH_HLEN - 4, dev->mtu);
+			skb->len  = 0;
+			skb->tail = skb->data;
+			init_skb_shinfo(skb);
+			dev_kfree_skb(skb);
+			continue;
+		}
+
+		/*
+		 * Enough room in skbuff for the data we were passed? Also,
+		 * Linux expects at least 16 bytes headroom in each rx buffer.
+		 */
+		if (unlikely(skb->tail > skb->end) ||
+		    unlikely((skb->data - skb->head) < 16)) {
+			if (net_ratelimit()) {
+				if (skb->tail > skb->end)
+					printk(KERN_INFO "Received packet "
+					       "is %zd bytes beyond tail.\n",
+					       skb->tail - skb->end);
+				else
+					printk(KERN_INFO "Received packet "
+					       "is %zd bytes before head.\n",
+					       16 - (skb->data - skb->head));
+			}
+
+			nskb = __dev_alloc_skb(skb->len + 2,
+					       GFP_ATOMIC|__GFP_NOWARN);
+			if (nskb != NULL) {
+				skb_reserve(nskb, 2);
+				skb_put(nskb, skb->len);
+				memcpy(nskb->data, skb->data, skb->len);
+				nskb->dev = skb->dev;
+				nskb->ip_summed = skb->ip_summed;
+			}
+
+			/* Reinitialise and then destroy the old skbuff. */
+			skb->len  = 0;
+			skb->tail = skb->data;
+			init_skb_shinfo(skb);
+			dev_kfree_skb(skb);
+
+			/* Switch old for new, if we copied the buffer. */
+			if ((skb = nskb) == NULL)
+				continue;
+		}
+
+		/* Set the shinfo area, which is hidden behind the data. */
+		init_skb_shinfo(skb);
+		/* Ethernet work: Delayed to here as it peeks the header. */
+		skb->protocol = eth_type_trans(skb, dev);
+
+		/* Pass it up. */
+		netif_receive_skb(skb);
+		dev->last_rx = jiffies;
+	}
+
+	np->rx.rsp_cons = i;
+
+	/* If we get a callback with very few responses, reduce fill target. */
+	/* NB. Note exponential increase, linear decrease. */
+	if (((np->rx.req_prod_pvt - np->rx.sring->rsp_prod) >
+	     ((3*np->rx_target) / 4)) &&
+	    (--np->rx_target < np->rx_min_target))
+		np->rx_target = np->rx_min_target;
+
+	network_alloc_rx_buffers(dev);
+
+	*pbudget   -= work_done;
+	dev->quota -= work_done;
+
+	if (work_done < budget) {
+		local_irq_save(flags);
+
+		RING_FINAL_CHECK_FOR_RESPONSES(&np->rx, more_to_do);
+		if (!more_to_do)
+			__netif_rx_complete(dev);
+
+		local_irq_restore(flags);
+	}
+
+	spin_unlock(&np->rx_lock);
+
+	return more_to_do;
+}
+
+
+static int network_close(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	np->user_state = UST_CLOSED;
+	netif_stop_queue(np->netdev);
+	return 0;
+}
+
+
+static struct net_device_stats *network_get_stats(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	return &np->stats;
+}
+
+static void network_connect(struct net_device *dev)
+{
+	struct netfront_info *np;
+	int i, requeue_idx;
+	struct netif_tx_request *tx;
+	struct sk_buff *skb;
+
+	np = netdev_priv(dev);
+	spin_lock_irq(&np->tx_lock);
+	spin_lock(&np->rx_lock);
+
+	/* Recovery procedure: */
+
+	/* Step 1: Reinitialise variables. */
+	np->tx_full = 0;
+
+	/*
+	 * Step 2: Rebuild the RX and TX ring contents.
+	 * NB. We could just free the queued TX packets now but we hope
+	 * that sending them out might do some good.  We have to rebuild
+	 * the RX ring because some of our pages are currently flipped out
+	 * so we can't just free the RX skbs.
+	 * NB2. Freelist index entries are always going to be less than
+	 *  __PAGE_OFFSET, whereas pointers to skbs will always be equal or
+	 * greater than __PAGE_OFFSET: we use this property to distinguish
+	 * them.
+	 */
+
+	/*
+	 * Rebuild the TX buffer freelist and the TX ring itself.
+	 * NB. This reorders packets.  We could keep more private state
+	 * to avoid this but maybe it doesn't matter so much given the
+	 * interface has been down.
+	 */
+	for (requeue_idx = 0, i = 1; i <= NET_TX_RING_SIZE; i++) {
+		if ((unsigned long)np->tx_skbs[i] < __PAGE_OFFSET)
+			continue;
+
+		skb = np->tx_skbs[i];
+
+		tx = RING_GET_REQUEST(&np->tx, requeue_idx);
+		requeue_idx++;
+
+		tx->id = i;
+		gnttab_grant_foreign_access_ref(
+			np->grant_tx_ref[i], np->xbdev->otherend_id,
+			virt_to_mfn(np->tx_skbs[i]->data),
+			GNTMAP_readonly);
+		tx->gref = np->grant_tx_ref[i];
+		tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
+		tx->size = skb->len;
+		tx->flags = (skb->ip_summed == CHECKSUM_HW) ?
+			NETTXF_csum_blank : 0;
+
+		np->stats.tx_bytes += skb->len;
+		np->stats.tx_packets++;
+	}
+
+	np->tx.req_prod_pvt = requeue_idx;
+	RING_PUSH_REQUESTS(&np->tx);
+
+	/* Rebuild the RX buffer freelist and the RX ring itself. */
+	for (requeue_idx = 0, i = 1; i <= NET_RX_RING_SIZE; i++) {
+		if ((unsigned long)np->rx_skbs[i] < __PAGE_OFFSET)
+			continue;
+		gnttab_grant_foreign_transfer_ref(
+			np->grant_rx_ref[i], np->xbdev->otherend_id,
+			__pa(np->rx_skbs[i]->data) >> PAGE_SHIFT);
+		RING_GET_REQUEST(&np->rx, requeue_idx)->gref =
+			np->grant_rx_ref[i];
+		RING_GET_REQUEST(&np->rx, requeue_idx)->id = i;
+		requeue_idx++;
+	}
+
+	np->rx.req_prod_pvt = requeue_idx;
+	RING_PUSH_REQUESTS(&np->rx);
+
+	/*
+	 * Step 3: All public and private state should now be sane.  Get
+	 * ready to start sending and receiving packets and give the driver
+	 * domain a kick because we've probably just requeued some
+	 * packets.
+	 */
+	np->backend_state = BEST_CONNECTED;
+	notify_remote_via_irq(np->irq);
+	network_tx_buf_gc(dev);
+
+	if (np->user_state == UST_OPEN)
+		netif_start_queue(dev);
+
+	spin_unlock(&np->rx_lock);
+	spin_unlock_irq(&np->tx_lock);
+}
+
+static void show_device(struct netfront_info *np)
+{
+#ifdef DEBUG
+	if (np) {
+		IPRINTK("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\n",
+			np->handle,
+			be_state_name[np->backend_state],
+			np->user_state ? "open" : "closed",
+			np->evtchn,
+			np->tx,
+			np->rx);
+	} else
+		IPRINTK("<vif NULL>\n");
+#endif
+}
+
+static void netif_uninit(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	gnttab_free_grant_references(np->gref_tx_head);
+	gnttab_free_grant_references(np->gref_rx_head);
+}
+
+static struct ethtool_ops network_ethtool_ops =
+{
+	.get_tx_csum = ethtool_op_get_tx_csum,
+	.set_tx_csum = ethtool_op_set_tx_csum,
+};
+
+/** Create a network device.
+ * @param handle device handle
+ * @param val return parameter for created device
+ * @return 0 on success, error code otherwise
+ */
+static int create_netdev(int handle, struct xenbus_device *dev,
+			 struct net_device **val)
+{
+	int i, err = 0;
+	struct net_device *netdev = NULL;
+	struct netfront_info *np = NULL;
+
+	if ((netdev = alloc_etherdev(sizeof(struct netfront_info))) == NULL) {
+		printk(KERN_WARNING "%s> alloc_etherdev failed.\n",
+		       __FUNCTION__);
+		err = -ENOMEM;
+		goto exit;
+	}
+
+	np                = netdev_priv(netdev);
+	np->backend_state = BEST_CLOSED;
+	np->user_state    = UST_CLOSED;
+	np->handle        = handle;
+	np->xbdev         = dev;
+
+	spin_lock_init(&np->tx_lock);
+	spin_lock_init(&np->rx_lock);
+
+	skb_queue_head_init(&np->rx_batch);
+	np->rx_target     = RX_DFL_MIN_TARGET;
+	np->rx_min_target = RX_DFL_MIN_TARGET;
+	np->rx_max_target = RX_MAX_TARGET;
+
+	init_timer(&np->rx_refill_timer);
+	np->rx_refill_timer.data = (unsigned long)netdev;
+	np->rx_refill_timer.function = rx_refill_timeout;
+
+	/* Initialise {tx,rx}_skbs as a free chain containing every entry. */
+	for (i = 0; i <= NET_TX_RING_SIZE; i++) {
+		np->tx_skbs[i] = (void *)((unsigned long) i+1);
+		np->grant_tx_ref[i] = GRANT_INVALID_REF;
+	}
+
+	for (i = 0; i <= NET_RX_RING_SIZE; i++) {
+		np->rx_skbs[i] = (void *)((unsigned long) i+1);
+		np->grant_rx_ref[i] = GRANT_INVALID_REF;
+	}
+
+	/* A grant for every tx ring slot */
+	if (gnttab_alloc_grant_references(NET_TX_RING_SIZE,
+					  &np->gref_tx_head) < 0) {
+		printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n");
+		err = -ENOMEM;
+		goto exit;
+	}
+	/* A grant for every rx ring slot */
+	if (gnttab_alloc_grant_references(NET_RX_RING_SIZE,
+					  &np->gref_rx_head) < 0) {
+		printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
+		gnttab_free_grant_references(np->gref_tx_head);
+		err = -ENOMEM;
+		goto exit;
+	}
+
+	netdev->open            = network_open;
+	netdev->hard_start_xmit = network_start_xmit;
+	netdev->stop            = network_close;
+	netdev->get_stats       = network_get_stats;
+	netdev->poll            = netif_poll;
+	netdev->uninit          = netif_uninit;
+	netdev->weight          = 64;
+	netdev->features        = NETIF_F_IP_CSUM;
+
+	SET_ETHTOOL_OPS(netdev, &network_ethtool_ops);
+	SET_MODULE_OWNER(netdev);
+	SET_NETDEV_DEV(netdev, &dev->dev);
+
+	if ((err = register_netdev(netdev)) != 0) {
+		printk(KERN_WARNING "%s> register_netdev err=%d\n",
+		       __FUNCTION__, err);
+		goto exit_free_grefs;
+	}
+
+	if ((err = xennet_proc_addif(netdev)) != 0) {
+		unregister_netdev(netdev);
+		goto exit_free_grefs;
+	}
+
+	np->netdev = netdev;
+
+ exit:
+	if (err != 0) {
+		if (netdev)
+			free_netdev(netdev);
+	} else if (val != NULL)
+		*val = netdev;
+	return err;
+
+ exit_free_grefs:
+	gnttab_free_grant_references(np->gref_tx_head);
+	gnttab_free_grant_references(np->gref_rx_head);
+	goto exit;
+}
+
+/*
+ * We use this notifier to send out a fake ARP reply to reset switches and
+ * router ARP caches when an IP interface is brought up on a VIF.
+ */
+static int
+inetdev_notify(struct notifier_block *this, unsigned long event, void *ptr)
+{
+	struct in_ifaddr  *ifa = (struct in_ifaddr *)ptr;
+	struct net_device *dev = ifa->ifa_dev->dev;
+
+	/* UP event and is it one of our devices? */
+	if (event == NETDEV_UP && dev->open == network_open)
+		(void)send_fake_arp(dev);
+
+	return NOTIFY_DONE;
+}
+
+
+/* ** Close down ** */
+
+
+/**
+ * Handle the change of state of the backend to Closing.  We must delete our
+ * device-layer structures now, to ensure that writes are flushed through to
+ * the backend.  Once is this done, we can switch to Closed in
+ * acknowledgement.
+ */
+static void netfront_closing(struct xenbus_device *dev)
+{
+	struct netfront_info *info = dev->data;
+
+	DPRINTK("netfront_closing: %s removed\n", dev->nodename);
+
+	close_netdev(info);
+
+	xenbus_switch_state(dev, XBT_NULL, XenbusStateClosed);
+}
+
+
+static int netfront_remove(struct xenbus_device *dev)
+{
+	struct netfront_info *info = dev->data;
+
+	DPRINTK("%s\n", dev->nodename);
+
+	netif_disconnect_backend(info);
+	free_netdev(info->netdev);
+
+	return 0;
+}
+
+
+static void close_netdev(struct netfront_info *info)
+{
+	spin_lock_irq(&info->netdev->xmit_lock);
+	netif_stop_queue(info->netdev);
+	spin_unlock_irq(&info->netdev->xmit_lock);
+
+#if defined(CONFIG_PROC_FS) && defined(XEN_XENNET_PROC_INTERFACE)
+	xennet_proc_delif(info->netdev);
+#endif
+
+	del_timer_sync(&info->rx_refill_timer);
+
+	unregister_netdev(info->netdev);
+}
+
+
+static void netif_disconnect_backend(struct netfront_info *info)
+{
+	/* Stop old i/f to prevent errors whilst we rebuild the state. */
+	spin_lock_irq(&info->tx_lock);
+	spin_lock(&info->rx_lock);
+	info->backend_state = BEST_DISCONNECTED;
+	spin_unlock(&info->rx_lock);
+	spin_unlock_irq(&info->tx_lock);
+
+	if (info->irq)
+		unbind_from_irqhandler(info->irq, info->netdev);
+	info->evtchn = info->irq = 0;
+
+	end_access(info->tx_ring_ref, info->tx.sring);
+	end_access(info->rx_ring_ref, info->rx.sring);
+	info->tx_ring_ref = GRANT_INVALID_REF;
+	info->rx_ring_ref = GRANT_INVALID_REF;
+	info->tx.sring = NULL;
+	info->rx.sring = NULL;
+}
+
+
+static void netif_free(struct netfront_info *info)
+{
+	close_netdev(info);
+	netif_disconnect_backend(info);
+	free_netdev(info->netdev);
+}
+
+
+static void end_access(int ref, void *page)
+{
+	if (ref != GRANT_INVALID_REF)
+		gnttab_end_foreign_access(ref, 0, (unsigned long)page);
+}
+
+
+/* ** Driver registration ** */
+
+
+static struct xenbus_device_id netfront_ids[] = {
+	{ "vif" },
+	{ "" }
+};
+
+
+static struct xenbus_driver netfront = {
+	.name = "vif",
+	.owner = THIS_MODULE,
+	.ids = netfront_ids,
+	.probe = netfront_probe,
+	.remove = netfront_remove,
+	.resume = netfront_resume,
+	.otherend_changed = backend_changed,
+};
+
+
+static struct notifier_block notifier_inetdev = {
+	.notifier_call  = inetdev_notify,
+};
+
+static int __init netif_init(void)
+{
+	int err = 0;
+
+	if (xen_start_info->flags & SIF_INITDOMAIN)
+		return 0;
+
+	if ((err = xennet_proc_init()) != 0)
+		return err;
+
+	IPRINTK("Initialising virtual ethernet driver.\n");
+
+	(void)register_inetaddr_notifier(&notifier_inetdev);
+
+	return xenbus_register_frontend(&netfront);
+}
+module_init(netif_init);
+
+
+static void netif_exit(void)
+{
+	unregister_inetaddr_notifier(&notifier_inetdev);
+
+	return xenbus_unregister_driver(&netfront);
+}
+module_exit(netif_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+
+
+/* ** /proc **/
+
+
+#if defined(CONFIG_PROC_FS) && defined(XEN_XENNET_PROC_INTERFACE)
+
+#define TARGET_MIN 0UL
+#define TARGET_MAX 1UL
+#define TARGET_CUR 2UL
+
+static int xennet_proc_read(
+	char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+	struct net_device *dev =
+		(struct net_device *)((unsigned long)data & ~3UL);
+	struct netfront_info *np = netdev_priv(dev);
+	int len = 0, which_target = (long)data & 3;
+
+	switch (which_target) {
+	case TARGET_MIN:
+		len = sprintf(page, "%d\n", np->rx_min_target);
+		break;
+	case TARGET_MAX:
+		len = sprintf(page, "%d\n", np->rx_max_target);
+		break;
+	case TARGET_CUR:
+		len = sprintf(page, "%d\n", np->rx_target);
+		break;
+	}
+
+	*eof = 1;
+	return len;
+}
+
+static int xennet_proc_write(
+	struct file *file, const char __user *buffer,
+	unsigned long count, void *data)
+{
+	struct net_device *dev =
+		(struct net_device *)((unsigned long)data & ~3UL);
+	struct netfront_info *np = netdev_priv(dev);
+	int which_target = (long)data & 3;
+	char string[64];
+	long target;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	if (count <= 1)
+		return -EBADMSG; /* runt */
+	if (count > sizeof(string))
+		return -EFBIG;   /* too long */
+
+	if (copy_from_user(string, buffer, count))
+		return -EFAULT;
+	string[sizeof(string)-1] = '\0';
+
+	target = simple_strtol(string, NULL, 10);
+	if (target < RX_MIN_TARGET)
+		target = RX_MIN_TARGET;
+	if (target > RX_MAX_TARGET)
+		target = RX_MAX_TARGET;
+
+	spin_lock(&np->rx_lock);
+
+	switch (which_target) {
+	case TARGET_MIN:
+		if (target > np->rx_max_target)
+			np->rx_max_target = target;
+		np->rx_min_target = target;
+		if (target > np->rx_target)
+			np->rx_target = target;
+		break;
+	case TARGET_MAX:
+		if (target < np->rx_min_target)
+			np->rx_min_target = target;
+		np->rx_max_target = target;
+		if (target < np->rx_target)
+			np->rx_target = target;
+		break;
+	case TARGET_CUR:
+		break;
+	}
+
+	network_alloc_rx_buffers(dev);
+
+	spin_unlock(&np->rx_lock);
+
+	return count;
+}
+
+static int xennet_proc_init(void)
+{
+	if (proc_mkdir("xen/net", NULL) == NULL)
+		return -ENOMEM;
+	return 0;
+}
+
+static int xennet_proc_addif(struct net_device *dev)
+{
+	struct proc_dir_entry *dir, *min, *max, *cur;
+	char name[30];
+
+	sprintf(name, "xen/net/%s", dev->name);
+
+	dir = proc_mkdir(name, NULL);
+	if (!dir)
+		goto nomem;
+	dir->owner = THIS_MODULE;
+
+	min = create_proc_entry("rxbuf_min", 0644, dir);
+	max = create_proc_entry("rxbuf_max", 0644, dir);
+	cur = create_proc_entry("rxbuf_cur", 0444, dir);
+	if (!min || !max || !cur)
+		goto nomem;
+
+	min->read_proc  = xennet_proc_read;
+	min->write_proc = xennet_proc_write;
+	min->data       = (void *)((unsigned long)dev | TARGET_MIN);
+	min->owner = THIS_MODULE;
+
+	max->read_proc  = xennet_proc_read;
+	max->write_proc = xennet_proc_write;
+	max->data       = (void *)((unsigned long)dev | TARGET_MAX);
+	max->owner = THIS_MODULE;
+
+	cur->read_proc  = xennet_proc_read;
+	cur->write_proc = xennet_proc_write;
+	cur->data       = (void *)((unsigned long)dev | TARGET_CUR);
+	max->owner = THIS_MODULE;
+
+	return 0;
+
+ nomem:
+	xennet_proc_delif(dev);
+	return -ENOMEM;
+}
+
+static void xennet_proc_delif(struct net_device *dev)
+{
+	char name[30];
+
+	sprintf(name, "xen/net/%s/rxbuf_min", dev->name);
+	remove_proc_entry(name, NULL);
+
+	sprintf(name, "xen/net/%s/rxbuf_max", dev->name);
+	remove_proc_entry(name, NULL);
+
+	sprintf(name, "xen/net/%s/rxbuf_cur", dev->name);
+	remove_proc_entry(name, NULL);
+
+	sprintf(name, "xen/net/%s", dev->name);
+	remove_proc_entry(name, NULL);
+}
+
+#endif
--- /dev/null
+++ linus-2.6/include/xen/net_driver_util.h
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ *
+ * Utility functions for Xen network devices.
+ *
+ * Copyright (c) 2005 XenSource Ltd.
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this source file (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 _ASM_XEN_NET_DRIVER_UTIL_H
+#define _ASM_XEN_NET_DRIVER_UTIL_H
+
+
+#include <xen/xenbus.h>
+
+
+/**
+ * Read the 'mac' node at the given device's node in the store, and parse that
+ * as colon-separated octets, placing result the given mac array.  mac must be
+ * a preallocated array of length ETH_ALEN (as declared in linux/if_ether.h).
+ * Return 0 on success, or -errno on error.
+ */
+int xen_net_read_mac(struct xenbus_device *dev, u8 mac[]);
+
+
+#endif /* _ASM_XEN_NET_DRIVER_UTIL_H */

--

^ permalink raw reply	[relevance 4%]

* [PATCH] use dma_ops in arch/x86_64/kernel/pci-dma-xen.c
@ 2006-05-09 20:40  4% Langsdorf, Mark
  0 siblings, 0 replies; 200+ results
From: Langsdorf, Mark @ 2006-05-09 20:40 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

This patch modifies xen-unstable to use the
x86_64 dma_ops structure for performing
x86_64 PCI DMA.  This is a requiring
restructuring before adding new IOMMU
devices.

I'd like to thank Muli Ben-Yehuda and Jon
Mason for their help in creating this patch.

-Mark Langsdorf
AMD, Inc.

signed-off-by: Mark Langsdorf <mark.langsdorf@amd.com>

[-- Attachment #2: dma_ops.changeset --]
[-- Type: application/octet-stream, Size: 12617 bytes --]

# HG changeset patch
# User root@iwillnow.amd.com
# Node ID 41d68788ee0cf1785878874d46d11e6cc589ba11
# Parent  1e3977e029fddc1e53995a3502d590f8a07e5c62
Transition x86-64 PCI DMA to use x86_64 pci-dma-xen and dma_ops

diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Tue May 09 13:51:44 2006 -0700
@@ -88,6 +88,24 @@ static struct phys_addr {
  * Protect the above data structures in the map and unmap calls
  */
 static DEFINE_SPINLOCK(io_tlb_lock);
+
+static inline int
+address_needs_mapping(struct device *hwdev, dma_addr_t addr)
+{
+        dma_addr_t mask = DMA_32BIT_MASK;
+        /* If the device has a mask, use it, otherwise default to 32 bits */
+        if (hwdev && hwdev->dma_mask)
+                mask = *hwdev->dma_mask;
+        return (addr & ~mask) != 0;
+}
+
+static inline int
+range_straddles_page_boundary(void *p, size_t size)
+{
+        extern unsigned long *contiguous_bitmap;
+        return (((((unsigned long)p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
+                !test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap));
+}
 
 static int __init
 setup_io_tlb_npages(char *str)
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile	Tue May 09 13:51:44 2006 -0700
@@ -55,7 +55,7 @@ dmi_scan-y			+= ../../i386/kernel/dmi_sc
 
 ifdef CONFIG_XEN
 time-y				+= ../../i386/kernel/time-xen.o
-pci-dma-y			+= ../../i386/kernel/pci-dma-xen.o
+pci-dma-y			+= pci-dma-xen.o
 microcode-$(subst m,y,$(CONFIG_MICROCODE))  := ../../i386/kernel/microcode-xen.o
 quirks-y			:= ../../i386/kernel/quirks-xen.o
 
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/x86_64/kernel/pci-swiotlb-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/pci-swiotlb-xen.c	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/pci-swiotlb-xen.c	Tue May 09 13:51:44 2006 -0700
@@ -8,13 +8,10 @@
 #include <asm/swiotlb.h>
 #include <asm/dma.h>
 
-#if 0
 int swiotlb __read_mostly;
 EXPORT_SYMBOL(swiotlb);
-#endif
 
 struct dma_mapping_ops swiotlb_dma_ops = {
-#if 0
 	.mapping_error = swiotlb_dma_mapping_error,
 	.alloc_coherent = swiotlb_alloc_coherent,
 	.free_coherent = swiotlb_free_coherent,
@@ -29,12 +26,10 @@ struct dma_mapping_ops swiotlb_dma_ops =
 	.map_sg = swiotlb_map_sg,
 	.unmap_sg = swiotlb_unmap_sg,
 	.dma_supported = NULL,
-#endif
 };
 
 void pci_swiotlb_init(void)
 {
-#if 0
 	/* don't initialize swiotlb if iommu=off (no_iommu=1) */
 	if (!iommu_aperture && !no_iommu &&
 	    (end_pfn > MAX_DMA32_PFN || force_iommu))
@@ -44,11 +39,4 @@ void pci_swiotlb_init(void)
 		swiotlb_init();
 		dma_ops = &swiotlb_dma_ops;
 	}
-#else
-	swiotlb_init();
-	if (swiotlb) {
-		printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
-		dma_ops = &swiotlb_dma_ops;
-	}
-#endif
 }
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/dma-mapping.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/dma-mapping.h	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/dma-mapping.h	Tue May 09 13:51:44 2006 -0700
@@ -56,7 +56,6 @@ extern struct dma_mapping_ops* dma_ops;
 extern struct dma_mapping_ops* dma_ops;
 extern int iommu_merge;
 
-#if 0
 static inline int dma_mapping_error(dma_addr_t dma_addr)
 {
 	if (dma_ops->mapping_error)
@@ -184,8 +183,5 @@ dma_cache_sync(void *vaddr, size_t size,
 
 extern struct device fallback_dev;
 extern int panic_on_overflow;
-#endif
 
 #endif /* _X8664_DMA_MAPPING_H */
-
-#include <asm-i386/mach-xen/asm/dma-mapping.h>
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/lib/Makefile
--- a/linux-2.6-xen-sparse/lib/Makefile	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/lib/Makefile	Tue May 09 13:51:44 2006 -0700
@@ -45,7 +45,7 @@ obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o
 obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o
 
 obj-$(CONFIG_SWIOTLB) += swiotlb.o
-ifneq ($(CONFIG_XEN_IA64_DOM0_NON_VP),y)
+ifeq ($(CONFIG_XEN_I386),y)
 swiotlb-$(CONFIG_XEN) := ../arch/i386/kernel/swiotlb.o
 endif
 
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/x86_64/kernel/pci-dma-xen.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/pci-dma-xen.c	Tue May 09 13:51:44 2006 -0700
@@ -0,0 +1,280 @@
+/*
+ * Dynamic DMA mapping support.
+ */
+
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/pci.h>
+#include <linux/module.h>
+#include <asm/io.h>
+#include <asm/proto.h>
+#include <xen/balloon.h>
+#include <asm/tlbflush.h>
+
+
+int iommu_merge __read_mostly = 0;
+EXPORT_SYMBOL(iommu_merge);
+
+dma_addr_t bad_dma_address __read_mostly;
+EXPORT_SYMBOL(bad_dma_address);
+
+/* This tells the BIO block layer to assume merging. Default to off
+   because we cannot guarantee merging later. */
+int iommu_bio_merge __read_mostly = 0;
+EXPORT_SYMBOL(iommu_bio_merge);
+
+int iommu_sac_force __read_mostly = 0;
+EXPORT_SYMBOL(iommu_sac_force);
+
+int no_iommu __read_mostly;
+#ifdef CONFIG_IOMMU_DEBUG
+int panic_on_overflow __read_mostly = 1;
+int force_iommu __read_mostly = 1;
+#else
+int panic_on_overflow __read_mostly = 0;
+int force_iommu __read_mostly= 0;
+#endif
+
+/* Dummy device used for NULL arguments (normally ISA). Better would
+   be probably a smaller DMA mask, but this is bug-to-bug compatible
+   to i386. */
+struct device fallback_dev = {
+	.bus_id = "fallback device",
+	.coherent_dma_mask = DMA_32BIT_MASK, 
+	.dma_mask = &fallback_dev.coherent_dma_mask,
+};
+
+/* Allocate DMA memory on node near device */
+noinline static void *
+dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
+{
+	struct page *page;
+	int node;
+
+	if (dev->bus == &pci_bus_type)
+		node = pcibus_to_node(to_pci_dev(dev)->bus);
+	else
+		node = numa_node_id();
+	page = alloc_pages_node(node, gfp, order);
+	return page ? page_address(page) : NULL;
+}
+
+/*
+ * Allocate memory for a coherent mapping.
+ */
+void *
+dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+		   gfp_t gfp)
+{
+	void *memory;
+	unsigned long dma_mask = 0;
+	u64 bus;
+
+	if (!dev)
+		dev = &fallback_dev;
+	dma_mask = dev->coherent_dma_mask;
+	if (dma_mask == 0)
+		dma_mask = 0xffffffff;
+
+	/* Kludge to make it bug-to-bug compatible with i386. i386
+	   uses the normal dma_mask for alloc_coherent. */
+	dma_mask &= *dev->dma_mask;
+
+	/* Why <=? Even when the mask is smaller than 4GB it is often
+	   larger than 16MB and in this case we have a chance of
+	   finding fitting memory in the next higher zone first. If
+	   not retry with true GFP_DMA. -AK */
+	if (dma_mask <= DMA_32BIT_MASK)
+		gfp |= GFP_DMA32;
+
+ again:
+	memory = dma_alloc_pages(dev, gfp, get_order(size));
+	if (memory == NULL)
+		return NULL;
+
+	{
+		int high, mmu;
+		bus = virt_to_bus(memory);
+	        high = (bus + size) >= dma_mask;
+		mmu = high;
+		if (force_iommu && !(gfp & GFP_DMA))
+			mmu = 1;
+		else if (high) {
+			free_pages((unsigned long)memory,
+				   get_order(size));
+
+			/* Don't use the 16MB ZONE_DMA unless absolutely
+			   needed. It's better to use remapping first. */
+			if (dma_mask < 0xffffffff && !(gfp & GFP_DMA)) {
+				gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
+				goto again;
+			}
+
+			/* Let low level make its own zone decisions */
+			gfp &= ~(GFP_DMA32|GFP_DMA);
+
+			if (dma_ops->alloc_coherent)
+				return dma_ops->alloc_coherent(dev, size,
+							   dma_handle, gfp);
+			return NULL;
+		}
+
+		/* Hardcode 31 address bits for now: aacraid limitation. */
+		if (xen_create_contiguous_region(memory, get_order(size), 31) != 0) {
+			free_pages(memory, get_order(size));
+			return NULL;
+		}
+
+		memset(memory, 0, size);
+		if (!mmu) {
+			*dma_handle = virt_to_bus(memory);
+			return memory;
+		}
+	}
+
+	if (dma_ops->alloc_coherent) {
+		free_pages((unsigned long)memory, get_order(size));
+		gfp &= ~(GFP_DMA|GFP_DMA32);
+		return dma_ops->alloc_coherent(dev, size, dma_handle, gfp);
+	}
+
+	if (dma_ops->map_simple) {
+		*dma_handle = dma_ops->map_simple(dev, memory,
+					      size,
+					      PCI_DMA_BIDIRECTIONAL);
+		if (*dma_handle != bad_dma_address)
+			return memory;
+	}
+
+	if (panic_on_overflow)
+		panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n",size);
+	free_pages((unsigned long)memory, get_order(size));
+	return NULL;
+}
+EXPORT_SYMBOL(dma_alloc_coherent);
+
+/*
+ * Unmap coherent memory.
+ * The caller must ensure that the device has finished accessing the mapping.
+ */
+void dma_free_coherent(struct device *dev, size_t size,
+			 void *vaddr, dma_addr_t bus)
+{
+	if (dma_ops->unmap_single)
+		dma_ops->unmap_single(dev, bus, size, 0);
+	xen_destroy_contiguous_region((unsigned long) vaddr, get_order(size));
+	free_pages((unsigned long)vaddr, get_order(size));
+}
+EXPORT_SYMBOL(dma_free_coherent);
+
+int dma_supported(struct device *dev, u64 mask)
+{
+	if (dma_ops->dma_supported)
+		return dma_ops->dma_supported(dev, mask);
+
+	/* Copied from i386. Doesn't make much sense, because it will
+	   only work for pci_alloc_coherent.
+	   The caller just has to use GFP_DMA in this case. */
+        if (mask < 0x00ffffff)
+                return 0;
+
+	/* Tell the device to use SAC when IOMMU force is on.  This
+	   allows the driver to use cheaper accesses in some cases.
+
+	   Problem with this is that if we overflow the IOMMU area and
+	   return DAC as fallback address the device may not handle it
+	   correctly.
+
+	   As a special case some controllers have a 39bit address
+	   mode that is as efficient as 32bit (aic79xx). Don't force
+	   SAC for these.  Assume all masks <= 40 bits are of this
+	   type. Normally this doesn't make any difference, but gives
+	   more gentle handling of IOMMU overflow. */
+	if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
+		printk(KERN_INFO "%s: Force SAC with mask %Lx\n", dev->bus_id,mask);
+		return 0;
+	}
+
+	return 1;
+}
+EXPORT_SYMBOL(dma_supported);
+
+int dma_set_mask(struct device *dev, u64 mask)
+{
+	if (!dev->dma_mask || !dma_supported(dev, mask))
+		return -EIO;
+	*dev->dma_mask = mask;
+	return 0;
+}
+EXPORT_SYMBOL(dma_set_mask);
+
+/* iommu=[size][,noagp][,off][,force][,noforce][,leak][,memaper[=order]][,merge]
+         [,forcesac][,fullflush][,nomerge][,biomerge]
+   size  set size of iommu (in bytes)
+   noagp don't initialize the AGP driver and use full aperture.
+   off   don't use the IOMMU
+   leak  turn on simple iommu leak tracing (only when CONFIG_IOMMU_LEAK is on)
+   memaper[=order] allocate an own aperture over RAM with size 32MB^order.
+   noforce don't force IOMMU usage. Default.
+   force  Force IOMMU.
+   merge  Do lazy merging. This may improve performance on some block devices.
+          Implies force (experimental)
+   biomerge Do merging at the BIO layer. This is more efficient than merge,
+            but should be only done with very big IOMMUs. Implies merge,force.
+   nomerge Don't do SG merging.
+   forcesac For SAC mode for masks <40bits  (experimental)
+   fullflush Flush IOMMU on each allocation (default)
+   nofullflush Don't use IOMMU fullflush
+   allowed  overwrite iommu off workarounds for specific chipsets.
+   soft	 Use software bounce buffering (default for Intel machines)
+   noaperture Don't touch the aperture for AGP.
+*/
+__init int iommu_setup(char *p)
+{
+    iommu_merge = 1;
+
+    while (*p) {
+	    if (!strncmp(p,"off",3))
+		    no_iommu = 1;
+	    /* gart_parse_options has more force support */
+	    if (!strncmp(p,"force",5))
+		    force_iommu = 1;
+	    if (!strncmp(p,"noforce",7)) {
+		    iommu_merge = 0;
+		    force_iommu = 0;
+	    }
+
+	    if (!strncmp(p, "biomerge",8)) {
+		    iommu_bio_merge = 4096;
+		    iommu_merge = 1;
+		    force_iommu = 1;
+	    }
+	    if (!strncmp(p, "panic",5))
+		    panic_on_overflow = 1;
+	    if (!strncmp(p, "nopanic",7))
+		    panic_on_overflow = 0;
+	    if (!strncmp(p, "merge",5)) {
+		    iommu_merge = 1;
+		    force_iommu = 1;
+	    }
+	    if (!strncmp(p, "nomerge",7))
+		    iommu_merge = 0;
+	    if (!strncmp(p, "forcesac",8))
+		    iommu_sac_force = 1;
+
+#ifdef CONFIG_SWIOTLB
+	    if (!strncmp(p, "soft",4))
+		    swiotlb = 1;
+#endif
+
+#ifdef CONFIG_GART_IOMMU
+	    gart_parse_options(p);
+#endif
+
+	    p += strcspn(p, ",");
+	    if (*p == ',')
+		    ++p;
+    }
+    return 1;
+}

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 4%]

* [PATCH][resubmit] use dma_ops in arch/x86_64/kernel/pci-dma-xen.c
@ 2006-05-16 13:27  4% Langsdorf, Mark
  0 siblings, 0 replies; 200+ results
From: Langsdorf, Mark @ 2006-05-16 13:27 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

(resubmitting since I think it got lost in the kernel
merge patch flood)

This patch modifies xen-unstable to use the
x86_64 dma_ops structure for performing
x86_64 PCI DMA.  This is a requiring
restructuring before adding new IOMMU
devices.

I'd like to thank Muli Ben-Yehuda and Jon Mason 
for their help in creating this patch.

-Mark Langsdorf
AMD, Inc.

signed-off-by: Mark Langsdorf <mark.langsdorf@amd.com>

[-- Attachment #2: dma_ops.changeset --]
[-- Type: application/octet-stream, Size: 12617 bytes --]

# HG changeset patch
# User root@iwillnow.amd.com
# Node ID 41d68788ee0cf1785878874d46d11e6cc589ba11
# Parent  1e3977e029fddc1e53995a3502d590f8a07e5c62
Transition x86-64 PCI DMA to use x86_64 pci-dma-xen and dma_ops

diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Tue May 09 13:51:44 2006 -0700
@@ -88,6 +88,24 @@ static struct phys_addr {
  * Protect the above data structures in the map and unmap calls
  */
 static DEFINE_SPINLOCK(io_tlb_lock);
+
+static inline int
+address_needs_mapping(struct device *hwdev, dma_addr_t addr)
+{
+        dma_addr_t mask = DMA_32BIT_MASK;
+        /* If the device has a mask, use it, otherwise default to 32 bits */
+        if (hwdev && hwdev->dma_mask)
+                mask = *hwdev->dma_mask;
+        return (addr & ~mask) != 0;
+}
+
+static inline int
+range_straddles_page_boundary(void *p, size_t size)
+{
+        extern unsigned long *contiguous_bitmap;
+        return (((((unsigned long)p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
+                !test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap));
+}
 
 static int __init
 setup_io_tlb_npages(char *str)
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile	Tue May 09 13:51:44 2006 -0700
@@ -55,7 +55,7 @@ dmi_scan-y			+= ../../i386/kernel/dmi_sc
 
 ifdef CONFIG_XEN
 time-y				+= ../../i386/kernel/time-xen.o
-pci-dma-y			+= ../../i386/kernel/pci-dma-xen.o
+pci-dma-y			+= pci-dma-xen.o
 microcode-$(subst m,y,$(CONFIG_MICROCODE))  := ../../i386/kernel/microcode-xen.o
 quirks-y			:= ../../i386/kernel/quirks-xen.o
 
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/x86_64/kernel/pci-swiotlb-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/pci-swiotlb-xen.c	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/pci-swiotlb-xen.c	Tue May 09 13:51:44 2006 -0700
@@ -8,13 +8,10 @@
 #include <asm/swiotlb.h>
 #include <asm/dma.h>
 
-#if 0
 int swiotlb __read_mostly;
 EXPORT_SYMBOL(swiotlb);
-#endif
 
 struct dma_mapping_ops swiotlb_dma_ops = {
-#if 0
 	.mapping_error = swiotlb_dma_mapping_error,
 	.alloc_coherent = swiotlb_alloc_coherent,
 	.free_coherent = swiotlb_free_coherent,
@@ -29,12 +26,10 @@ struct dma_mapping_ops swiotlb_dma_ops =
 	.map_sg = swiotlb_map_sg,
 	.unmap_sg = swiotlb_unmap_sg,
 	.dma_supported = NULL,
-#endif
 };
 
 void pci_swiotlb_init(void)
 {
-#if 0
 	/* don't initialize swiotlb if iommu=off (no_iommu=1) */
 	if (!iommu_aperture && !no_iommu &&
 	    (end_pfn > MAX_DMA32_PFN || force_iommu))
@@ -44,11 +39,4 @@ void pci_swiotlb_init(void)
 		swiotlb_init();
 		dma_ops = &swiotlb_dma_ops;
 	}
-#else
-	swiotlb_init();
-	if (swiotlb) {
-		printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
-		dma_ops = &swiotlb_dma_ops;
-	}
-#endif
 }
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/dma-mapping.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/dma-mapping.h	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/dma-mapping.h	Tue May 09 13:51:44 2006 -0700
@@ -56,7 +56,6 @@ extern struct dma_mapping_ops* dma_ops;
 extern struct dma_mapping_ops* dma_ops;
 extern int iommu_merge;
 
-#if 0
 static inline int dma_mapping_error(dma_addr_t dma_addr)
 {
 	if (dma_ops->mapping_error)
@@ -184,8 +183,5 @@ dma_cache_sync(void *vaddr, size_t size,
 
 extern struct device fallback_dev;
 extern int panic_on_overflow;
-#endif
 
 #endif /* _X8664_DMA_MAPPING_H */
-
-#include <asm-i386/mach-xen/asm/dma-mapping.h>
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/lib/Makefile
--- a/linux-2.6-xen-sparse/lib/Makefile	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/lib/Makefile	Tue May 09 13:51:44 2006 -0700
@@ -45,7 +45,7 @@ obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o
 obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o
 
 obj-$(CONFIG_SWIOTLB) += swiotlb.o
-ifneq ($(CONFIG_XEN_IA64_DOM0_NON_VP),y)
+ifeq ($(CONFIG_XEN_I386),y)
 swiotlb-$(CONFIG_XEN) := ../arch/i386/kernel/swiotlb.o
 endif
 
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/x86_64/kernel/pci-dma-xen.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/pci-dma-xen.c	Tue May 09 13:51:44 2006 -0700
@@ -0,0 +1,280 @@
+/*
+ * Dynamic DMA mapping support.
+ */
+
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/pci.h>
+#include <linux/module.h>
+#include <asm/io.h>
+#include <asm/proto.h>
+#include <xen/balloon.h>
+#include <asm/tlbflush.h>
+
+
+int iommu_merge __read_mostly = 0;
+EXPORT_SYMBOL(iommu_merge);
+
+dma_addr_t bad_dma_address __read_mostly;
+EXPORT_SYMBOL(bad_dma_address);
+
+/* This tells the BIO block layer to assume merging. Default to off
+   because we cannot guarantee merging later. */
+int iommu_bio_merge __read_mostly = 0;
+EXPORT_SYMBOL(iommu_bio_merge);
+
+int iommu_sac_force __read_mostly = 0;
+EXPORT_SYMBOL(iommu_sac_force);
+
+int no_iommu __read_mostly;
+#ifdef CONFIG_IOMMU_DEBUG
+int panic_on_overflow __read_mostly = 1;
+int force_iommu __read_mostly = 1;
+#else
+int panic_on_overflow __read_mostly = 0;
+int force_iommu __read_mostly= 0;
+#endif
+
+/* Dummy device used for NULL arguments (normally ISA). Better would
+   be probably a smaller DMA mask, but this is bug-to-bug compatible
+   to i386. */
+struct device fallback_dev = {
+	.bus_id = "fallback device",
+	.coherent_dma_mask = DMA_32BIT_MASK, 
+	.dma_mask = &fallback_dev.coherent_dma_mask,
+};
+
+/* Allocate DMA memory on node near device */
+noinline static void *
+dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
+{
+	struct page *page;
+	int node;
+
+	if (dev->bus == &pci_bus_type)
+		node = pcibus_to_node(to_pci_dev(dev)->bus);
+	else
+		node = numa_node_id();
+	page = alloc_pages_node(node, gfp, order);
+	return page ? page_address(page) : NULL;
+}
+
+/*
+ * Allocate memory for a coherent mapping.
+ */
+void *
+dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+		   gfp_t gfp)
+{
+	void *memory;
+	unsigned long dma_mask = 0;
+	u64 bus;
+
+	if (!dev)
+		dev = &fallback_dev;
+	dma_mask = dev->coherent_dma_mask;
+	if (dma_mask == 0)
+		dma_mask = 0xffffffff;
+
+	/* Kludge to make it bug-to-bug compatible with i386. i386
+	   uses the normal dma_mask for alloc_coherent. */
+	dma_mask &= *dev->dma_mask;
+
+	/* Why <=? Even when the mask is smaller than 4GB it is often
+	   larger than 16MB and in this case we have a chance of
+	   finding fitting memory in the next higher zone first. If
+	   not retry with true GFP_DMA. -AK */
+	if (dma_mask <= DMA_32BIT_MASK)
+		gfp |= GFP_DMA32;
+
+ again:
+	memory = dma_alloc_pages(dev, gfp, get_order(size));
+	if (memory == NULL)
+		return NULL;
+
+	{
+		int high, mmu;
+		bus = virt_to_bus(memory);
+	        high = (bus + size) >= dma_mask;
+		mmu = high;
+		if (force_iommu && !(gfp & GFP_DMA))
+			mmu = 1;
+		else if (high) {
+			free_pages((unsigned long)memory,
+				   get_order(size));
+
+			/* Don't use the 16MB ZONE_DMA unless absolutely
+			   needed. It's better to use remapping first. */
+			if (dma_mask < 0xffffffff && !(gfp & GFP_DMA)) {
+				gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
+				goto again;
+			}
+
+			/* Let low level make its own zone decisions */
+			gfp &= ~(GFP_DMA32|GFP_DMA);
+
+			if (dma_ops->alloc_coherent)
+				return dma_ops->alloc_coherent(dev, size,
+							   dma_handle, gfp);
+			return NULL;
+		}
+
+		/* Hardcode 31 address bits for now: aacraid limitation. */
+		if (xen_create_contiguous_region(memory, get_order(size), 31) != 0) {
+			free_pages(memory, get_order(size));
+			return NULL;
+		}
+
+		memset(memory, 0, size);
+		if (!mmu) {
+			*dma_handle = virt_to_bus(memory);
+			return memory;
+		}
+	}
+
+	if (dma_ops->alloc_coherent) {
+		free_pages((unsigned long)memory, get_order(size));
+		gfp &= ~(GFP_DMA|GFP_DMA32);
+		return dma_ops->alloc_coherent(dev, size, dma_handle, gfp);
+	}
+
+	if (dma_ops->map_simple) {
+		*dma_handle = dma_ops->map_simple(dev, memory,
+					      size,
+					      PCI_DMA_BIDIRECTIONAL);
+		if (*dma_handle != bad_dma_address)
+			return memory;
+	}
+
+	if (panic_on_overflow)
+		panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n",size);
+	free_pages((unsigned long)memory, get_order(size));
+	return NULL;
+}
+EXPORT_SYMBOL(dma_alloc_coherent);
+
+/*
+ * Unmap coherent memory.
+ * The caller must ensure that the device has finished accessing the mapping.
+ */
+void dma_free_coherent(struct device *dev, size_t size,
+			 void *vaddr, dma_addr_t bus)
+{
+	if (dma_ops->unmap_single)
+		dma_ops->unmap_single(dev, bus, size, 0);
+	xen_destroy_contiguous_region((unsigned long) vaddr, get_order(size));
+	free_pages((unsigned long)vaddr, get_order(size));
+}
+EXPORT_SYMBOL(dma_free_coherent);
+
+int dma_supported(struct device *dev, u64 mask)
+{
+	if (dma_ops->dma_supported)
+		return dma_ops->dma_supported(dev, mask);
+
+	/* Copied from i386. Doesn't make much sense, because it will
+	   only work for pci_alloc_coherent.
+	   The caller just has to use GFP_DMA in this case. */
+        if (mask < 0x00ffffff)
+                return 0;
+
+	/* Tell the device to use SAC when IOMMU force is on.  This
+	   allows the driver to use cheaper accesses in some cases.
+
+	   Problem with this is that if we overflow the IOMMU area and
+	   return DAC as fallback address the device may not handle it
+	   correctly.
+
+	   As a special case some controllers have a 39bit address
+	   mode that is as efficient as 32bit (aic79xx). Don't force
+	   SAC for these.  Assume all masks <= 40 bits are of this
+	   type. Normally this doesn't make any difference, but gives
+	   more gentle handling of IOMMU overflow. */
+	if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
+		printk(KERN_INFO "%s: Force SAC with mask %Lx\n", dev->bus_id,mask);
+		return 0;
+	}
+
+	return 1;
+}
+EXPORT_SYMBOL(dma_supported);
+
+int dma_set_mask(struct device *dev, u64 mask)
+{
+	if (!dev->dma_mask || !dma_supported(dev, mask))
+		return -EIO;
+	*dev->dma_mask = mask;
+	return 0;
+}
+EXPORT_SYMBOL(dma_set_mask);
+
+/* iommu=[size][,noagp][,off][,force][,noforce][,leak][,memaper[=order]][,merge]
+         [,forcesac][,fullflush][,nomerge][,biomerge]
+   size  set size of iommu (in bytes)
+   noagp don't initialize the AGP driver and use full aperture.
+   off   don't use the IOMMU
+   leak  turn on simple iommu leak tracing (only when CONFIG_IOMMU_LEAK is on)
+   memaper[=order] allocate an own aperture over RAM with size 32MB^order.
+   noforce don't force IOMMU usage. Default.
+   force  Force IOMMU.
+   merge  Do lazy merging. This may improve performance on some block devices.
+          Implies force (experimental)
+   biomerge Do merging at the BIO layer. This is more efficient than merge,
+            but should be only done with very big IOMMUs. Implies merge,force.
+   nomerge Don't do SG merging.
+   forcesac For SAC mode for masks <40bits  (experimental)
+   fullflush Flush IOMMU on each allocation (default)
+   nofullflush Don't use IOMMU fullflush
+   allowed  overwrite iommu off workarounds for specific chipsets.
+   soft	 Use software bounce buffering (default for Intel machines)
+   noaperture Don't touch the aperture for AGP.
+*/
+__init int iommu_setup(char *p)
+{
+    iommu_merge = 1;
+
+    while (*p) {
+	    if (!strncmp(p,"off",3))
+		    no_iommu = 1;
+	    /* gart_parse_options has more force support */
+	    if (!strncmp(p,"force",5))
+		    force_iommu = 1;
+	    if (!strncmp(p,"noforce",7)) {
+		    iommu_merge = 0;
+		    force_iommu = 0;
+	    }
+
+	    if (!strncmp(p, "biomerge",8)) {
+		    iommu_bio_merge = 4096;
+		    iommu_merge = 1;
+		    force_iommu = 1;
+	    }
+	    if (!strncmp(p, "panic",5))
+		    panic_on_overflow = 1;
+	    if (!strncmp(p, "nopanic",7))
+		    panic_on_overflow = 0;
+	    if (!strncmp(p, "merge",5)) {
+		    iommu_merge = 1;
+		    force_iommu = 1;
+	    }
+	    if (!strncmp(p, "nomerge",7))
+		    iommu_merge = 0;
+	    if (!strncmp(p, "forcesac",8))
+		    iommu_sac_force = 1;
+
+#ifdef CONFIG_SWIOTLB
+	    if (!strncmp(p, "soft",4))
+		    swiotlb = 1;
+#endif
+
+#ifdef CONFIG_GART_IOMMU
+	    gart_parse_options(p);
+#endif
+
+	    p += strcspn(p, ",");
+	    if (*p == ',')
+		    ++p;
+    }
+    return 1;
+}

[-- Attachment #3: ATT5911454.txt --]
[-- Type: text/plain, Size: 142 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 4%]

* PATCH: fix transparent virtualization issue (Re)
  @ 2006-05-18 12:10 13%   ` Tristan Gingold
    0 siblings, 1 reply; 200+ results
From: Tristan Gingold @ 2006-05-18 12:10 UTC (permalink / raw)
  To: Keir Fraser, Alex Williamson; +Cc: xen-devel, xen-ia64-devel

[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]

Le Jeudi 18 Mai 2006 00:35, Keir Fraser a écrit :
> On 17 May 2006, at 12:17, Tristan Gingold wrote:
> > this patch fixes a few transparent virtualization (ie running
> > xenolinux on
> > bare platform) issues for xen/ia64.
>
> Why not call xen_init() in the two places you added NULL check for
> xen_start_info? Especially in netfront -- you already call xen_init()
> in blkfront, so it seems weird not to do so in netfront. I see no
> reason not to call it in swiotlb.c too.
>
> xen_init() is a pretty bad name by the way, seeing as it's called all
> over the place so it's not really initialising xen state at every call
> site. Given that it is used in most places for the caller to determine
> if you are running on Xen or not, why not call it running_on_xen() and
> have the initialisation on the first call just be a hidden side effect?
Hi,

here are two patches for transparent virtualization.
xen-transvirt4.diffs replaces uses of xen_init() by running_on_xen on common 
and x86 code.

xen-transvirt3.diffs is for xen/ia64: it add a call to xen_init() very early.

I think this is cleaner than previous way.

Tristan.

[-- Attachment #2: xen-transvirt4.diffs --]
[-- Type: text/x-diff, Size: 5754 bytes --]

# HG changeset patch
# User tristan.gingold@bull.net
# Node ID ce125e557225bc409186d82afe86aecdef6356dc
# Parent  d2f6e3d70f223f37ef468ffe7a5dcaa82cfc7c1e
Replace xen_init() by running_on_xen.
Check running_on_xen before setting up a Xen driver.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>

diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Thu May 18 06:29:28 2006
@@ -191,6 +191,7 @@
 	if (swiotlb_force == 1) {
 		swiotlb = 1;
 	} else if ((swiotlb_force != -1) &&
+		   running_on_xen &&
 		   (xen_start_info->flags & SIF_INITDOMAIN)) {
 		/* Domain 0 always has a swiotlb. */
 		ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu May 18 06:29:28 2006
@@ -468,8 +468,8 @@
 
 	IPRINTK("Initialising balloon driver.\n");
 
-	if (xen_init() < 0)
-		return -1;
+	if (!running_on_xen)
+		return -ENODEV;
 
 	current_pages = min(xen_start_info->nr_pages, max_pfn);
 	totalram_pages = current_pages;
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu May 18 06:29:28 2006
@@ -526,7 +526,7 @@
 	struct page *page;
 	int i;
 
-	if (xen_init() < 0)
+	if (!running_on_xen)
 		return -ENODEV;
 
 	mmap_pages            = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu May 18 06:29:28 2006
@@ -792,7 +792,7 @@
 
 static int __init xlblk_init(void)
 {
-	if (xen_init() < 0)
+	if (!running_on_xen)
 		return -ENODEV;
 
 	return xenbus_register_frontend(&blkfront);
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/console/console.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Thu May 18 06:29:28 2006
@@ -183,7 +183,7 @@
 #define __RETCODE 0
 static int __init xen_console_init(void)
 {
-	if (xen_init() < 0)
+	if (!running_on_xen)
 		return __RETCODE;
 
 	if (xen_start_info->flags & SIF_INITDOMAIN) {
@@ -566,7 +566,7 @@
 {
 	int rc;
 
-	if (xen_init() < 0)
+	if (!running_on_xen)
 		return -ENODEV;
 
 	if (xc_mode == XC_OFF)
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu May 18 06:29:28 2006
@@ -443,7 +443,7 @@
 {
 	int i;
 
-	if (xen_init() < 0)
+	if (!running_on_xen)
 		return -ENODEV;
 
 	if (gnttab_resume() < 0)
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu May 18 06:29:28 2006
@@ -808,6 +808,9 @@
 	int i;
 	struct page *page;
 
+	if (!running_on_xen)
+		return -ENODEV;
+
 	/* We can increase reservation by this much in net_rx_action(). */
 	balloon_update_driver_allowance(NET_RX_RING_SIZE);
 
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 18 06:29:28 2006
@@ -1341,6 +1341,9 @@
 {
 	int err = 0;
 
+	if (!running_on_xen)
+		return -ENODEV;
+
 	if (xen_start_info->flags & SIF_INITDOMAIN)
 		return 0;
 
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Thu May 18 06:29:28 2006
@@ -271,6 +271,9 @@
 
 static int __init privcmd_init(void)
 {
+	if (!running_on_xen)
+		return -ENODEV;
+
 	/* Set of hypercalls that privileged applications may execute. */
 	set_bit(__HYPERVISOR_acm_op,           hypercall_permission_map);
 	set_bit(__HYPERVISOR_dom0_op,          hypercall_permission_map);
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu May 18 06:29:28 2006
@@ -966,10 +966,8 @@
 
 	DPRINTK("");
 
-	if (xen_init() < 0) {
-		DPRINTK("failed");
+	if (!running_on_xen)
 		return -ENODEV;
-	}
 
 	/* Register ourselves with the kernel bus subsystem */
 	bus_register(&xenbus_frontend.bus);
@@ -1069,10 +1067,8 @@
 {
 	unsigned long timeout = jiffies + 10*HZ;
 
-	if (xen_init() < 0) {
-		DPRINTK("failed");
+	if (!running_on_xen)
 		return -ENODEV;
-	}
 
 	while (time_before(jiffies, timeout)) {
 		if (all_devices_ready())
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Thu May 18 06:29:28 2006
@@ -118,7 +118,7 @@
 #define MULTI_UVMDOMID_INDEX 4
 #endif
 
-#define xen_init()	(0)
+#define running_on_xen 1
 
 static inline int
 HYPERVISOR_yield(

[-- Attachment #3: xen-transvirt3.diffs --]
[-- Type: text/x-diff, Size: 4575 bytes --]

# HG changeset patch
# User tristan.gingold@bull.net
# Node ID 7e53a91d47ae3354779a16119f9ccb9cc40f3808
# Parent  ce125e557225bc409186d82afe86aecdef6356dc
Sync with transparent virtualization running_on_xen.
Call xen_init in setup_arch.
Declare running_on_xen in xenia64_init.c, remove running_on_xen
and is_running_on_xen from xensetup.S
Remove xen_ksyms.c

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>

diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c	Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c	Thu May 18 06:33:04 2006
@@ -514,6 +514,9 @@
 #ifdef CONFIG_XEN
 	if (running_on_xen) {
 		extern shared_info_t *HYPERVISOR_shared_info;
+		extern int xen_init (void);
+
+		xen_init ();
 
 		/* xen_start_info isn't setup yet, get the flags manually */
 		if (HYPERVISOR_shared_info->arch.flags & SIF_INITDOMAIN) {
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/Makefile
--- a/linux-2.6-xen-sparse/arch/ia64/xen/Makefile	Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/Makefile	Thu May 18 06:33:04 2006
@@ -2,7 +2,7 @@
 # Makefile for Xen components
 #
 
-obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o xenconsole.o xen_ksyms.o
+obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o xenconsole.o
 
 obj-$(CONFIG_XEN_IA64_DOM0_VP) += hypervisor.o pci-dma-xen.o util.o
-pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
\ No newline at end of file
+pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c	Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c	Thu May 18 06:33:04 2006
@@ -11,11 +11,14 @@
 shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)XSI_BASE;
 EXPORT_SYMBOL(HYPERVISOR_shared_info);
 
-static int initialized;
 start_info_t *xen_start_info;
+
+int running_on_xen;
+EXPORT_SYMBOL(running_on_xen);
 
 int xen_init(void)
 {
+	static int initialized;
 	shared_info_t *s = HYPERVISOR_shared_info;
 
 	if (initialized)
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S
--- a/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S	Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S	Thu May 18 06:33:04 2006
@@ -7,12 +7,6 @@
 #include <linux/config.h>
 #include <asm/processor.h>
 #include <asm/asmmacro.h>
-
-	.data
-	.align 8
-	.globl running_on_xen
-running_on_xen:
-	data4 0
 
 #define isBP	p3	// are we the Bootstrap Processor?
 
@@ -28,9 +22,3 @@
 (p7)	mov cr.iva=r10
 	br.ret.sptk.many rp;;
 END(early_xen_setup)
-
-GLOBAL_ENTRY(is_running_on_xen)
-	movl r9=running_on_xen;;
-	ld4 r8=[r9]
-	br.ret.sptk.many rp;;
-END(is_running_on_xen)
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Thu May 18 06:33:04 2006
@@ -53,7 +53,8 @@
 
 void force_evtchn_callback(void);
 
-int xen_init(void);
+/* True if running on xen.  */
+extern int running_on_xen;
 
 /* Turn jiffies into Xen system time. XXX Implement me. */
 #define jiffies_to_st(j)	0
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h	Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h	Thu May 18 06:33:04 2006
@@ -42,12 +42,7 @@
 #endif
 
 #ifndef __ASSEMBLY__
-#ifdef MODULE
-extern int is_running_on_xen(void);
-#define running_on_xen (is_running_on_xen())
-#else
 extern int running_on_xen;
-#endif
 
 #define	XEN_HYPER_SSM_I		asm("break %0" : : "i" (HYPERPRIVOP_SSM_I))
 #define	XEN_HYPER_GET_IVR	asm("break %0" : : "i" (HYPERPRIVOP_GET_IVR))
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c	Thu May 18 06:29:28 2006
+++ /dev/null	Thu May 18 06:33:04 2006
@@ -1,12 +0,0 @@
-/*
- * Architecture-specific kernel symbols
- *
- * Don't put any exports here unless it's defined in an assembler file.
- * All other exports should be put directly after the definition.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-extern int is_running_on_xen(void);
-EXPORT_SYMBOL(is_running_on_xen);

[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 13%]

* Re: PATCH: fix transparent virtualization issue (Re)
  @ 2006-05-19 12:25 13%       ` Tristan Gingold
  0 siblings, 0 replies; 200+ results
From: Tristan Gingold @ 2006-05-19 12:25 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel, Alex Williamson, xen-ia64-devel

[-- Attachment #1: Type: text/plain, Size: 847 bytes --]

Le Jeudi 18 Mai 2006 14:32, Keir Fraser a écrit :
> On 18 May 2006, at 13:10, Tristan Gingold wrote:
> > here are two patches for transparent virtualization.
> > xen-transvirt4.diffs replaces uses of xen_init() by running_on_xen on
> > common
> > and x86 code.
> >
> > xen-transvirt3.diffs is for xen/ia64: it add a call to xen_init() very
> > early.
> >
> > I think this is cleaner than previous way.
>
> Please make running_on_xen a function rather than a variable. I see you
> end up turning it into a function for modules anyway, and I'd rather
> have a function wrapper around a variable than a variable wrapper
> around a function. :-) It'll give us a bit more flexibility in future
> too.
Hi,

here is the updated patch.
The function is now: is_running_on_xen().

Tested on ia64 bare box and on xen/ia64.

Tristan.

[-- Attachment #2: xen-transvirt-comm.diffs --]
[-- Type: text/x-diff, Size: 7994 bytes --]

# HG changeset patch
# User gingold@virtu10
# Node ID c317d53af7a217096ffffb7abfa1c2870e2475ca
# Parent  2fa8573b248f78f716a8926b29e294f97e99e631
Check wether Xen is running before setting up a Xen driver.

Replace calls to xen_init() by is_running_on_xen().

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>

diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Fri May 19 12:45:58 2006 +0200
@@ -191,6 +191,7 @@ swiotlb_init(void)
 	if (swiotlb_force == 1) {
 		swiotlb = 1;
 	} else if ((swiotlb_force != -1) &&
+		   is_running_on_xen() &&
 		   (xen_start_info->flags & SIF_INITDOMAIN)) {
 		/* Domain 0 always has a swiotlb. */
 		ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri May 19 12:45:58 2006 +0200
@@ -468,8 +468,8 @@ static int __init balloon_init(void)
 
 	IPRINTK("Initialising balloon driver.\n");
 
-	if (xen_init() < 0)
-		return -1;
+	if (!is_running_on_xen())
+		return -ENODEV;
 
 	current_pages = min(xen_start_info->nr_pages, max_pfn);
 	totalram_pages = current_pages;
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Fri May 19 12:45:58 2006 +0200
@@ -526,7 +526,7 @@ static int __init blkif_init(void)
 	struct page *page;
 	int i;
 
-	if (xen_init() < 0)
+	if (!is_running_on_xen())
 		return -ENODEV;
 
 	mmap_pages            = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri May 19 12:45:58 2006 +0200
@@ -792,7 +792,7 @@ static struct xenbus_driver blkfront = {
 
 static int __init xlblk_init(void)
 {
-	if (xen_init() < 0)
+	if (!is_running_on_xen())
 		return -ENODEV;
 
 	return xenbus_register_frontend(&blkfront);
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/console/console.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Fri May 19 12:45:58 2006 +0200
@@ -183,7 +183,7 @@ static struct console kcons_info = {
 #define __RETCODE 0
 static int __init xen_console_init(void)
 {
-	if (xen_init() < 0)
+	if (!is_running_on_xen())
 		return __RETCODE;
 
 	if (xen_start_info->flags & SIF_INITDOMAIN) {
@@ -566,7 +566,7 @@ static int __init xencons_init(void)
 {
 	int rc;
 
-	if (xen_init() < 0)
+	if (!is_running_on_xen())
 		return -ENODEV;
 
 	if (xc_mode == XC_OFF)
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Fri May 19 12:45:58 2006 +0200
@@ -443,7 +443,7 @@ gnttab_init(void)
 {
 	int i;
 
-	if (xen_init() < 0)
+	if (!is_running_on_xen())
 		return -ENODEV;
 
 	if (gnttab_resume() < 0)
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c	Fri May 19 12:45:58 2006 +0200
@@ -49,6 +49,9 @@ static struct kobj_type hyp_sysfs_kobj_t
 
 static int __init hypervisor_subsys_init(void)
 {
+	if (!is_running_on_xen())
+		return -ENODEV;
+
 	hypervisor_subsys.kset.kobj.ktype = &hyp_sysfs_kobj_type;
 	return subsystem_register(&hypervisor_subsys);
 }
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c	Fri May 19 12:45:58 2006 +0200
@@ -276,7 +276,12 @@ static void xen_properties_destroy(void)
 
 static int __init hyper_sysfs_init(void)
 {
-	int ret = xen_sysfs_type_init();
+	int ret;
+
+	if (!is_running_on_xen())
+		return -ENODEV;
+
+	ret = xen_sysfs_type_init();
 	if (ret)
 		goto out;
 	ret = xen_sysfs_version_init();
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c
--- a/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Fri May 19 12:45:58 2006 +0200
@@ -429,6 +429,9 @@ static int __init evtchn_init(void)
 {
 	int err;
 
+	if (!is_running_on_xen())
+		return -ENODEV;
+
 	spin_lock_init(&port_user_lock);
 	memset(port_user, 0, sizeof(port_user));
 
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Fri May 19 12:45:58 2006 +0200
@@ -808,6 +808,9 @@ static int __init netback_init(void)
 	int i;
 	struct page *page;
 
+	if (!is_running_on_xen())
+		return -ENODEV;
+
 	/* We can increase reservation by this much in net_rx_action(). */
 	balloon_update_driver_allowance(NET_RX_RING_SIZE);
 
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri May 19 12:45:58 2006 +0200
@@ -1341,6 +1341,9 @@ static int __init netif_init(void)
 {
 	int err = 0;
 
+	if (!is_running_on_xen())
+		return -ENODEV;
+
 	if (xen_start_info->flags & SIF_INITDOMAIN)
 		return 0;
 
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Fri May 19 12:45:58 2006 +0200
@@ -271,6 +271,9 @@ static int capabilities_read(char *page,
 
 static int __init privcmd_init(void)
 {
+	if (!is_running_on_xen())
+		return -ENODEV;
+
 	/* Set of hypercalls that privileged applications may execute. */
 	set_bit(__HYPERVISOR_acm_op,           hypercall_permission_map);
 	set_bit(__HYPERVISOR_dom0_op,          hypercall_permission_map);
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri May 19 12:45:58 2006 +0200
@@ -966,10 +966,8 @@ static int __init xenbus_probe_init(void
 
 	DPRINTK("");
 
-	if (xen_init() < 0) {
-		DPRINTK("failed");
+	if (!is_running_on_xen())
 		return -ENODEV;
-	}
 
 	/* Register ourselves with the kernel bus subsystem */
 	bus_register(&xenbus_frontend.bus);
@@ -1069,10 +1067,8 @@ static int __init wait_for_devices(void)
 {
 	unsigned long timeout = jiffies + 10*HZ;
 
-	if (xen_init() < 0) {
-		DPRINTK("failed");
+	if (!is_running_on_xen())
 		return -ENODEV;
-	}
 
 	while (time_before(jiffies, timeout)) {
 		if (all_devices_ready())
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Thu May 18 14:05:30 2006 -0600
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Fri May 19 12:45:58 2006 +0200
@@ -118,7 +118,7 @@ u64 jiffies_to_st(unsigned long jiffies)
 #define MULTI_UVMDOMID_INDEX 4
 #endif
 
-#define xen_init()	(0)
+#define is_running_on_xen() 1
 
 static inline int
 HYPERVISOR_yield(

[-- Attachment #3: xen-transvirt-ia64.diffs --]
[-- Type: text/x-diff, Size: 4991 bytes --]

# HG changeset patch
# User gingold@virtu10
# Node ID 115ca492cdbb1b5313aa6b69e1f2ff7aad75a62a
# Parent  c317d53af7a217096ffffb7abfa1c2870e2475ca
Sync with transparent virtualization: call is_running_on_xen() to check wether
Xen is running.

Call xen_init in setup_arch.
Declare running_on_xen in xenia64_init.c, remove running_on_xen
and is_running_on_xen from xensetup.S
Remove xen_ksyms.c

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>

diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/arch/ia64/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c	Fri May 19 12:45:58 2006 +0200
+++ b/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c	Fri May 19 12:47:36 2006 +0200
@@ -514,6 +514,9 @@ setup_arch (char **cmdline_p)
 #ifdef CONFIG_XEN
 	if (running_on_xen) {
 		extern shared_info_t *HYPERVISOR_shared_info;
+		extern int xen_init (void);
+
+		xen_init ();
 
 		/* xen_start_info isn't setup yet, get the flags manually */
 		if (HYPERVISOR_shared_info->arch.flags & SIF_INITDOMAIN) {
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/arch/ia64/xen/Makefile
--- a/linux-2.6-xen-sparse/arch/ia64/xen/Makefile	Fri May 19 12:45:58 2006 +0200
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/Makefile	Fri May 19 12:47:36 2006 +0200
@@ -2,7 +2,7 @@
 # Makefile for Xen components
 #
 
-obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o xenconsole.o xen_ksyms.o
+obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o xenconsole.o
 
 obj-$(CONFIG_XEN_IA64_DOM0_VP) += hypervisor.o pci-dma-xen.o util.o
-pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
\ No newline at end of file
+pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c	Fri May 19 12:45:58 2006 +0200
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c	Fri May 19 12:47:36 2006 +0200
@@ -11,17 +11,20 @@ shared_info_t *HYPERVISOR_shared_info = 
 shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)XSI_BASE;
 EXPORT_SYMBOL(HYPERVISOR_shared_info);
 
-static int initialized;
 start_info_t *xen_start_info;
+
+int running_on_xen;
+EXPORT_SYMBOL(running_on_xen);
 
 int xen_init(void)
 {
+	static int initialized;
 	shared_info_t *s = HYPERVISOR_shared_info;
 
 	if (initialized)
 		return running_on_xen ? 0 : -1;
 
-	if (!running_on_xen)
+	if (!is_running_on_xen())
 		return -1;
 
 	xen_start_info = __va(s->arch.start_info_pfn << PAGE_SHIFT);
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S
--- a/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S	Fri May 19 12:45:58 2006 +0200
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S	Fri May 19 12:47:36 2006 +0200
@@ -7,12 +7,6 @@
 #include <linux/config.h>
 #include <asm/processor.h>
 #include <asm/asmmacro.h>
-
-	.data
-	.align 8
-	.globl running_on_xen
-running_on_xen:
-	data4 0
 
 #define isBP	p3	// are we the Bootstrap Processor?
 
@@ -28,9 +22,3 @@ GLOBAL_ENTRY(early_xen_setup)
 (p7)	mov cr.iva=r10
 	br.ret.sptk.many rp;;
 END(early_xen_setup)
-
-GLOBAL_ENTRY(is_running_on_xen)
-	movl r9=running_on_xen;;
-	ld4 r8=[r9]
-	br.ret.sptk.many rp;;
-END(is_running_on_xen)
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Fri May 19 12:45:58 2006 +0200
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Fri May 19 12:47:36 2006 +0200
@@ -53,7 +53,7 @@ extern start_info_t *xen_start_info;
 
 void force_evtchn_callback(void);
 
-int xen_init(void);
+#define is_running_on_xen() running_on_xen
 
 /* Turn jiffies into Xen system time. XXX Implement me. */
 #define jiffies_to_st(j)	0
@@ -158,7 +158,7 @@ xen_create_contiguous_region(unsigned lo
                              unsigned int order, unsigned int address_bits)
 {
 	int ret = 0;
-	if (running_on_xen) {
+	if (is_running_on_xen()) {
 		ret = __xen_create_contiguous_region(vstart, order,
 		                                     address_bits);
 	}
@@ -169,7 +169,7 @@ static inline void
 static inline void
 xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
 {
-	if (running_on_xen)
+	if (is_running_on_xen())
 		__xen_destroy_contiguous_region(vstart, order);
 }
 
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h	Fri May 19 12:45:58 2006 +0200
+++ b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h	Fri May 19 12:47:36 2006 +0200
@@ -42,12 +42,7 @@
 #endif
 
 #ifndef __ASSEMBLY__
-#ifdef MODULE
-extern int is_running_on_xen(void);
-#define running_on_xen (is_running_on_xen())
-#else
 extern int running_on_xen;
-#endif
 
 #define	XEN_HYPER_SSM_I		asm("break %0" : : "i" (HYPERPRIVOP_SSM_I))
 #define	XEN_HYPER_GET_IVR	asm("break %0" : : "i" (HYPERPRIVOP_GET_IVR))

[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 13%]

* [PATCH] Implement a floor for xm mem-set
@ 2006-05-19 16:14  8% Ky Srinivasan
  0 siblings, 0 replies; 200+ results
From: Ky Srinivasan @ 2006-05-19 16:14 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 191 bytes --]

The attached (trivial)  patch implements a floor for the memory a domain
can be ballooned down to.

Please apply this to 3.0 as well

Signed-off-by K. Y. Srinivasan <ksrinivasan@novell.com>


[-- Attachment #2: balloon.diff --]
[-- Type: application/octet-stream, Size: 1553 bytes --]

--- linux-2.6.16/drivers/xen/balloon/balloon.c	2006-05-15 02:57:14.000000000 -0400
+++ NEW/drivers/xen/balloon/balloon.c	2006-05-15 03:00:48.000000000 -0400
@@ -370,11 +370,29 @@
 	.node = "memory/target"
 };
 
+/*
+ * Compute the minimum value this domain can be ballooned down to 
+ * (in kilo bytes). This is little over 2% of the maximum pages the domain
+ * will ever handle (with a floor).
+ */
+static unsigned long long  min_target(void)
+{
+	unsigned long long	min_mem;
+	
+
+	min_mem = 
+	(192000 +  (((max_pfn << (PAGE_SHIFT -10))) >> 6) +
+	(((max_pfn << (PAGE_SHIFT -10))) >> 7));
+	
+	return (min_mem);
+}
+
 /* React to a change in the target key */
 static void watch_target(struct xenbus_watch *watch,
 			 const char **vec, unsigned int len)
 {
 	unsigned long long new_target;
+	unsigned long long min_value = min_target();
 	int err;
 
 	err = xenbus_scanf(XBT_NULL, "memory", "target", "%llu", &new_target);
@@ -382,12 +400,17 @@
 		/* This is ok (for domain0 at least) - so just return */
 		return;
 	} 
-        
+
 	/* The given memory/target value is in KiB, so it needs converting to
 	   pages.  PAGE_SHIFT converts bytes to pages, hence PAGE_SHIFT - 10.
+	   But first make sure that we are not lowering the value below the 
+	   "minimum".
 	*/
-	set_new_target(new_target >> (PAGE_SHIFT - 10));
-    
+	if (new_target > min_value) {
+		set_new_target(new_target >> (PAGE_SHIFT - 10));
+	} else {
+		set_new_target(min_value >> (PAGE_SHIFT - 10));
+	}
 }
 
 static int balloon_init_watcher(struct notifier_block *notifier,

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 8%]

* RE: [PATCH] Make "xm mem-set" be lower boundondomX-min-mem
  @ 2006-05-22 15:21  8% ` Ky Srinivasan
  0 siblings, 0 replies; 200+ results
From: Ky Srinivasan @ 2006-05-22 15:21 UTC (permalink / raw)
  To: Keir Fraser, Aravindh Puthiyaparambil; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 507 bytes --]

I am attaching the patch.

K. Y

>>> On Mon, May 22, 2006 at 10:58 am, in message
<EF8D308BE33AF54D8934DF26520252D30484BC28@USTR-EXCH5.na.uis.unisys.com>,
"Puthiyaparambil, Aravindh" <aravindh.puthiyaparambil@unisys.com>
wrote: 
>>  
>> The patch I sent implements the minimum in the balloon driver and
we
> are
>> currently building sles10 with my patch.
>> 
>> K. Y
> 
> I think I missed this patch when you sent it in. Could you please
send
> it again so that I can take a look?
> 
> Thanks,
> Aravindh


[-- Attachment #2: balloon.diff --]
[-- Type: application/octet-stream, Size: 1553 bytes --]

--- linux-2.6.16/drivers/xen/balloon/balloon.c	2006-05-15 02:57:14.000000000 -0400
+++ NEW/drivers/xen/balloon/balloon.c	2006-05-15 03:00:48.000000000 -0400
@@ -370,11 +370,29 @@
 	.node = "memory/target"
 };
 
+/*
+ * Compute the minimum value this domain can be ballooned down to 
+ * (in kilo bytes). This is little over 2% of the maximum pages the domain
+ * will ever handle (with a floor).
+ */
+static unsigned long long  min_target(void)
+{
+	unsigned long long	min_mem;
+	
+
+	min_mem = 
+	(192000 +  (((max_pfn << (PAGE_SHIFT -10))) >> 6) +
+	(((max_pfn << (PAGE_SHIFT -10))) >> 7));
+	
+	return (min_mem);
+}
+
 /* React to a change in the target key */
 static void watch_target(struct xenbus_watch *watch,
 			 const char **vec, unsigned int len)
 {
 	unsigned long long new_target;
+	unsigned long long min_value = min_target();
 	int err;
 
 	err = xenbus_scanf(XBT_NULL, "memory", "target", "%llu", &new_target);
@@ -382,12 +400,17 @@
 		/* This is ok (for domain0 at least) - so just return */
 		return;
 	} 
-        
+
 	/* The given memory/target value is in KiB, so it needs converting to
 	   pages.  PAGE_SHIFT converts bytes to pages, hence PAGE_SHIFT - 10.
+	   But first make sure that we are not lowering the value below the 
+	   "minimum".
 	*/
-	set_new_target(new_target >> (PAGE_SHIFT - 10));
-    
+	if (new_target > min_value) {
+		set_new_target(new_target >> (PAGE_SHIFT - 10));
+	} else {
+		set_new_target(min_value >> (PAGE_SHIFT - 10));
+	}
 }
 
 static int balloon_init_watcher(struct notifier_block *notifier,

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 8%]

* [PATCH][resubmit 2] use dma_ops in arch/x86_64/kernel/pci-dma-xen.c
@ 2006-05-23 17:17  4% Langsdorf, Mark
  0 siblings, 0 replies; 200+ results
From: Langsdorf, Mark @ 2006-05-23 17:17 UTC (permalink / raw)
  To: xen-devel; +Cc: Wahlig, Elsie

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

(resubmitting since I think it got lost in the 
kernel merge patch flood and haven't seen any
comments or commits on it)

This patch modifies xen-unstable to use the
x86_64 dma_ops structure for performing
x86_64 PCI DMA.  This is a requiring
restructuring before adding new IOMMU
devices.

I'd like to thank Muli Ben-Yehuda and Jon 
Mason for their help in creating this patch.

-Mark Langsdorf
AMD, Inc.

signed-off-by: Mark Langsdorf <mark.langsdorf@amd.com>

[-- Attachment #2: dma_ops.changeset --]
[-- Type: application/octet-stream, Size: 12617 bytes --]

# HG changeset patch
# User root@iwillnow.amd.com
# Node ID 41d68788ee0cf1785878874d46d11e6cc589ba11
# Parent  1e3977e029fddc1e53995a3502d590f8a07e5c62
Transition x86-64 PCI DMA to use x86_64 pci-dma-xen and dma_ops

diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Tue May 09 13:51:44 2006 -0700
@@ -88,6 +88,24 @@ static struct phys_addr {
  * Protect the above data structures in the map and unmap calls
  */
 static DEFINE_SPINLOCK(io_tlb_lock);
+
+static inline int
+address_needs_mapping(struct device *hwdev, dma_addr_t addr)
+{
+        dma_addr_t mask = DMA_32BIT_MASK;
+        /* If the device has a mask, use it, otherwise default to 32 bits */
+        if (hwdev && hwdev->dma_mask)
+                mask = *hwdev->dma_mask;
+        return (addr & ~mask) != 0;
+}
+
+static inline int
+range_straddles_page_boundary(void *p, size_t size)
+{
+        extern unsigned long *contiguous_bitmap;
+        return (((((unsigned long)p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
+                !test_bit(__pa(p) >> PAGE_SHIFT, contiguous_bitmap));
+}
 
 static int __init
 setup_io_tlb_npages(char *str)
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile	Tue May 09 13:51:44 2006 -0700
@@ -55,7 +55,7 @@ dmi_scan-y			+= ../../i386/kernel/dmi_sc
 
 ifdef CONFIG_XEN
 time-y				+= ../../i386/kernel/time-xen.o
-pci-dma-y			+= ../../i386/kernel/pci-dma-xen.o
+pci-dma-y			+= pci-dma-xen.o
 microcode-$(subst m,y,$(CONFIG_MICROCODE))  := ../../i386/kernel/microcode-xen.o
 quirks-y			:= ../../i386/kernel/quirks-xen.o
 
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/x86_64/kernel/pci-swiotlb-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/pci-swiotlb-xen.c	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/pci-swiotlb-xen.c	Tue May 09 13:51:44 2006 -0700
@@ -8,13 +8,10 @@
 #include <asm/swiotlb.h>
 #include <asm/dma.h>
 
-#if 0
 int swiotlb __read_mostly;
 EXPORT_SYMBOL(swiotlb);
-#endif
 
 struct dma_mapping_ops swiotlb_dma_ops = {
-#if 0
 	.mapping_error = swiotlb_dma_mapping_error,
 	.alloc_coherent = swiotlb_alloc_coherent,
 	.free_coherent = swiotlb_free_coherent,
@@ -29,12 +26,10 @@ struct dma_mapping_ops swiotlb_dma_ops =
 	.map_sg = swiotlb_map_sg,
 	.unmap_sg = swiotlb_unmap_sg,
 	.dma_supported = NULL,
-#endif
 };
 
 void pci_swiotlb_init(void)
 {
-#if 0
 	/* don't initialize swiotlb if iommu=off (no_iommu=1) */
 	if (!iommu_aperture && !no_iommu &&
 	    (end_pfn > MAX_DMA32_PFN || force_iommu))
@@ -44,11 +39,4 @@ void pci_swiotlb_init(void)
 		swiotlb_init();
 		dma_ops = &swiotlb_dma_ops;
 	}
-#else
-	swiotlb_init();
-	if (swiotlb) {
-		printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
-		dma_ops = &swiotlb_dma_ops;
-	}
-#endif
 }
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/dma-mapping.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/dma-mapping.h	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/dma-mapping.h	Tue May 09 13:51:44 2006 -0700
@@ -56,7 +56,6 @@ extern struct dma_mapping_ops* dma_ops;
 extern struct dma_mapping_ops* dma_ops;
 extern int iommu_merge;
 
-#if 0
 static inline int dma_mapping_error(dma_addr_t dma_addr)
 {
 	if (dma_ops->mapping_error)
@@ -184,8 +183,5 @@ dma_cache_sync(void *vaddr, size_t size,
 
 extern struct device fallback_dev;
 extern int panic_on_overflow;
-#endif
 
 #endif /* _X8664_DMA_MAPPING_H */
-
-#include <asm-i386/mach-xen/asm/dma-mapping.h>
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/lib/Makefile
--- a/linux-2.6-xen-sparse/lib/Makefile	Mon May 08 19:21:41 2006 +0100
+++ b/linux-2.6-xen-sparse/lib/Makefile	Tue May 09 13:51:44 2006 -0700
@@ -45,7 +45,7 @@ obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o
 obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o
 
 obj-$(CONFIG_SWIOTLB) += swiotlb.o
-ifneq ($(CONFIG_XEN_IA64_DOM0_NON_VP),y)
+ifeq ($(CONFIG_XEN_I386),y)
 swiotlb-$(CONFIG_XEN) := ../arch/i386/kernel/swiotlb.o
 endif
 
diff -r 1e3977e029fd -r 41d68788ee0c linux-2.6-xen-sparse/arch/x86_64/kernel/pci-dma-xen.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/pci-dma-xen.c	Tue May 09 13:51:44 2006 -0700
@@ -0,0 +1,280 @@
+/*
+ * Dynamic DMA mapping support.
+ */
+
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/pci.h>
+#include <linux/module.h>
+#include <asm/io.h>
+#include <asm/proto.h>
+#include <xen/balloon.h>
+#include <asm/tlbflush.h>
+
+
+int iommu_merge __read_mostly = 0;
+EXPORT_SYMBOL(iommu_merge);
+
+dma_addr_t bad_dma_address __read_mostly;
+EXPORT_SYMBOL(bad_dma_address);
+
+/* This tells the BIO block layer to assume merging. Default to off
+   because we cannot guarantee merging later. */
+int iommu_bio_merge __read_mostly = 0;
+EXPORT_SYMBOL(iommu_bio_merge);
+
+int iommu_sac_force __read_mostly = 0;
+EXPORT_SYMBOL(iommu_sac_force);
+
+int no_iommu __read_mostly;
+#ifdef CONFIG_IOMMU_DEBUG
+int panic_on_overflow __read_mostly = 1;
+int force_iommu __read_mostly = 1;
+#else
+int panic_on_overflow __read_mostly = 0;
+int force_iommu __read_mostly= 0;
+#endif
+
+/* Dummy device used for NULL arguments (normally ISA). Better would
+   be probably a smaller DMA mask, but this is bug-to-bug compatible
+   to i386. */
+struct device fallback_dev = {
+	.bus_id = "fallback device",
+	.coherent_dma_mask = DMA_32BIT_MASK, 
+	.dma_mask = &fallback_dev.coherent_dma_mask,
+};
+
+/* Allocate DMA memory on node near device */
+noinline static void *
+dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
+{
+	struct page *page;
+	int node;
+
+	if (dev->bus == &pci_bus_type)
+		node = pcibus_to_node(to_pci_dev(dev)->bus);
+	else
+		node = numa_node_id();
+	page = alloc_pages_node(node, gfp, order);
+	return page ? page_address(page) : NULL;
+}
+
+/*
+ * Allocate memory for a coherent mapping.
+ */
+void *
+dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+		   gfp_t gfp)
+{
+	void *memory;
+	unsigned long dma_mask = 0;
+	u64 bus;
+
+	if (!dev)
+		dev = &fallback_dev;
+	dma_mask = dev->coherent_dma_mask;
+	if (dma_mask == 0)
+		dma_mask = 0xffffffff;
+
+	/* Kludge to make it bug-to-bug compatible with i386. i386
+	   uses the normal dma_mask for alloc_coherent. */
+	dma_mask &= *dev->dma_mask;
+
+	/* Why <=? Even when the mask is smaller than 4GB it is often
+	   larger than 16MB and in this case we have a chance of
+	   finding fitting memory in the next higher zone first. If
+	   not retry with true GFP_DMA. -AK */
+	if (dma_mask <= DMA_32BIT_MASK)
+		gfp |= GFP_DMA32;
+
+ again:
+	memory = dma_alloc_pages(dev, gfp, get_order(size));
+	if (memory == NULL)
+		return NULL;
+
+	{
+		int high, mmu;
+		bus = virt_to_bus(memory);
+	        high = (bus + size) >= dma_mask;
+		mmu = high;
+		if (force_iommu && !(gfp & GFP_DMA))
+			mmu = 1;
+		else if (high) {
+			free_pages((unsigned long)memory,
+				   get_order(size));
+
+			/* Don't use the 16MB ZONE_DMA unless absolutely
+			   needed. It's better to use remapping first. */
+			if (dma_mask < 0xffffffff && !(gfp & GFP_DMA)) {
+				gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
+				goto again;
+			}
+
+			/* Let low level make its own zone decisions */
+			gfp &= ~(GFP_DMA32|GFP_DMA);
+
+			if (dma_ops->alloc_coherent)
+				return dma_ops->alloc_coherent(dev, size,
+							   dma_handle, gfp);
+			return NULL;
+		}
+
+		/* Hardcode 31 address bits for now: aacraid limitation. */
+		if (xen_create_contiguous_region(memory, get_order(size), 31) != 0) {
+			free_pages(memory, get_order(size));
+			return NULL;
+		}
+
+		memset(memory, 0, size);
+		if (!mmu) {
+			*dma_handle = virt_to_bus(memory);
+			return memory;
+		}
+	}
+
+	if (dma_ops->alloc_coherent) {
+		free_pages((unsigned long)memory, get_order(size));
+		gfp &= ~(GFP_DMA|GFP_DMA32);
+		return dma_ops->alloc_coherent(dev, size, dma_handle, gfp);
+	}
+
+	if (dma_ops->map_simple) {
+		*dma_handle = dma_ops->map_simple(dev, memory,
+					      size,
+					      PCI_DMA_BIDIRECTIONAL);
+		if (*dma_handle != bad_dma_address)
+			return memory;
+	}
+
+	if (panic_on_overflow)
+		panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n",size);
+	free_pages((unsigned long)memory, get_order(size));
+	return NULL;
+}
+EXPORT_SYMBOL(dma_alloc_coherent);
+
+/*
+ * Unmap coherent memory.
+ * The caller must ensure that the device has finished accessing the mapping.
+ */
+void dma_free_coherent(struct device *dev, size_t size,
+			 void *vaddr, dma_addr_t bus)
+{
+	if (dma_ops->unmap_single)
+		dma_ops->unmap_single(dev, bus, size, 0);
+	xen_destroy_contiguous_region((unsigned long) vaddr, get_order(size));
+	free_pages((unsigned long)vaddr, get_order(size));
+}
+EXPORT_SYMBOL(dma_free_coherent);
+
+int dma_supported(struct device *dev, u64 mask)
+{
+	if (dma_ops->dma_supported)
+		return dma_ops->dma_supported(dev, mask);
+
+	/* Copied from i386. Doesn't make much sense, because it will
+	   only work for pci_alloc_coherent.
+	   The caller just has to use GFP_DMA in this case. */
+        if (mask < 0x00ffffff)
+                return 0;
+
+	/* Tell the device to use SAC when IOMMU force is on.  This
+	   allows the driver to use cheaper accesses in some cases.
+
+	   Problem with this is that if we overflow the IOMMU area and
+	   return DAC as fallback address the device may not handle it
+	   correctly.
+
+	   As a special case some controllers have a 39bit address
+	   mode that is as efficient as 32bit (aic79xx). Don't force
+	   SAC for these.  Assume all masks <= 40 bits are of this
+	   type. Normally this doesn't make any difference, but gives
+	   more gentle handling of IOMMU overflow. */
+	if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
+		printk(KERN_INFO "%s: Force SAC with mask %Lx\n", dev->bus_id,mask);
+		return 0;
+	}
+
+	return 1;
+}
+EXPORT_SYMBOL(dma_supported);
+
+int dma_set_mask(struct device *dev, u64 mask)
+{
+	if (!dev->dma_mask || !dma_supported(dev, mask))
+		return -EIO;
+	*dev->dma_mask = mask;
+	return 0;
+}
+EXPORT_SYMBOL(dma_set_mask);
+
+/* iommu=[size][,noagp][,off][,force][,noforce][,leak][,memaper[=order]][,merge]
+         [,forcesac][,fullflush][,nomerge][,biomerge]
+   size  set size of iommu (in bytes)
+   noagp don't initialize the AGP driver and use full aperture.
+   off   don't use the IOMMU
+   leak  turn on simple iommu leak tracing (only when CONFIG_IOMMU_LEAK is on)
+   memaper[=order] allocate an own aperture over RAM with size 32MB^order.
+   noforce don't force IOMMU usage. Default.
+   force  Force IOMMU.
+   merge  Do lazy merging. This may improve performance on some block devices.
+          Implies force (experimental)
+   biomerge Do merging at the BIO layer. This is more efficient than merge,
+            but should be only done with very big IOMMUs. Implies merge,force.
+   nomerge Don't do SG merging.
+   forcesac For SAC mode for masks <40bits  (experimental)
+   fullflush Flush IOMMU on each allocation (default)
+   nofullflush Don't use IOMMU fullflush
+   allowed  overwrite iommu off workarounds for specific chipsets.
+   soft	 Use software bounce buffering (default for Intel machines)
+   noaperture Don't touch the aperture for AGP.
+*/
+__init int iommu_setup(char *p)
+{
+    iommu_merge = 1;
+
+    while (*p) {
+	    if (!strncmp(p,"off",3))
+		    no_iommu = 1;
+	    /* gart_parse_options has more force support */
+	    if (!strncmp(p,"force",5))
+		    force_iommu = 1;
+	    if (!strncmp(p,"noforce",7)) {
+		    iommu_merge = 0;
+		    force_iommu = 0;
+	    }
+
+	    if (!strncmp(p, "biomerge",8)) {
+		    iommu_bio_merge = 4096;
+		    iommu_merge = 1;
+		    force_iommu = 1;
+	    }
+	    if (!strncmp(p, "panic",5))
+		    panic_on_overflow = 1;
+	    if (!strncmp(p, "nopanic",7))
+		    panic_on_overflow = 0;
+	    if (!strncmp(p, "merge",5)) {
+		    iommu_merge = 1;
+		    force_iommu = 1;
+	    }
+	    if (!strncmp(p, "nomerge",7))
+		    iommu_merge = 0;
+	    if (!strncmp(p, "forcesac",8))
+		    iommu_sac_force = 1;
+
+#ifdef CONFIG_SWIOTLB
+	    if (!strncmp(p, "soft",4))
+		    swiotlb = 1;
+#endif
+
+#ifdef CONFIG_GART_IOMMU
+	    gart_parse_options(p);
+#endif
+
+	    p += strcspn(p, ",");
+	    if (*p == ',')
+		    ++p;
+    }
+    return 1;
+}

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 4%]

* [patch 1/3] [PATCH] use DEFINE_SPINLOCK in drivers/xen
  @ 2006-05-24  7:00 14% ` Chris Wright
  0 siblings, 0 replies; 200+ results
From: Chris Wright @ 2006-05-24  7:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Christian Limpach

[-- Attachment #1: spinlock-updates.patch --]
[-- Type: text/plain, Size: 4838 bytes --]

Conforming to typical CodingStyle.

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c |    2 +-
 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c |    2 +-
 linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c    |    2 +-
 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c   |    2 +-
 linux-2.6-xen-sparse/drivers/xen/console/console.c |    2 +-
 linux-2.6-xen-sparse/drivers/xen/core/evtchn.c     |    4 +---
 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c     |    2 +-
 linux-2.6-xen-sparse/drivers/xen/netback/netback.c |    4 ++--
 8 files changed, 9 insertions(+), 11 deletions(-)

--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
@@ -67,7 +67,7 @@ static DECLARE_MUTEX(balloon_mutex);
  * Also protects non-atomic updates of current_pages and driver_pages, and
  * balloon lists.
  */
-spinlock_t balloon_lock = SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(balloon_lock);
 
 /* We aim for 'current allocation' == 'target allocation'. */
 static unsigned long current_pages;
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
@@ -82,7 +82,7 @@ typedef struct {
 
 static pending_req_t *pending_reqs;
 static struct list_head pending_free;
-static spinlock_t pending_free_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(pending_free_lock);
 static DECLARE_WAIT_QUEUE_HEAD(pending_free_wq);
 
 #define BLKBACK_INVALID_HANDLE (~0)
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
@@ -93,7 +93,7 @@ static struct block_device_operations xl
 	.ioctl  = blkif_ioctl,
 };
 
-spinlock_t blkif_io_lock = SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(blkif_io_lock);
 
 static struct xlbd_major_info *
 xlbd_alloc_major_info(int major, int minor, int index)
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
@@ -138,7 +138,7 @@ typedef struct {
  */
 static pending_req_t pending_reqs[MAX_PENDING_REQS];
 static unsigned char pending_ring[MAX_PENDING_REQS];
-static spinlock_t pend_prod_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(pend_prod_lock);
 /* NB. We use a different index type to differentiate from shared blk rings. */
 typedef unsigned int PEND_RING_IDX;
 #define MASK_PEND_IDX(_i) ((_i)&(MAX_PENDING_REQS-1))
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/console/console.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/console/console.c
@@ -124,7 +124,7 @@ static int __init xencons_bufsz_setup(ch
 __setup("xencons_bufsz=", xencons_bufsz_setup);
 
 /* This lock protects accesses to the common transmit buffer. */
-static spinlock_t xencons_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(xencons_lock);
 
 /* Common transmit-kick routine. */
 static void __xencons_tx_flush(void);
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
@@ -81,7 +81,7 @@ EXPORT_SYMBOL_GPL(gnttab_grant_foreign_t
 static grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
 static int gnttab_free_count;
 static grant_ref_t gnttab_free_head;
-static spinlock_t gnttab_list_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(gnttab_list_lock);
 
 static grant_entry_t *shared = NULL;
 
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/netback/netback.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/netback/netback.c
@@ -99,7 +99,7 @@ static spinlock_t net_schedule_list_lock
 #define MAX_MFN_ALLOC 64
 static unsigned long mfn_list[MAX_MFN_ALLOC];
 static unsigned int alloc_index = 0;
-static spinlock_t mfn_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(mfn_lock);
 
 static unsigned long alloc_mfn(void)
 {
@@ -691,7 +691,7 @@ static void net_tx_action(unsigned long 
 
 static void netif_idx_release(u16 pending_idx)
 {
-	static spinlock_t _lock = SPIN_LOCK_UNLOCKED;
+	static DEFINE_SPINLOCK(_lock);
 	unsigned long flags;
 
 	spin_lock_irqsave(&_lock, flags);
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c
@@ -51,7 +51,7 @@
  * This lock protects updates to the following mapping and reference-count
  * arrays. The lock does not need to be acquired to read the mapping tables.
  */
-static spinlock_t irq_mapping_update_lock;
+static DEFINE_SPINLOCK(irq_mapping_update_lock);
 
 /* IRQ <-> event-channel mappings. */
 static int evtchn_to_irq[NR_EVENT_CHANNELS];
@@ -815,8 +815,6 @@ void __init xen_init_IRQ(void)
 	int i;
 	int cpu;
 
-	spin_lock_init(&irq_mapping_update_lock);
-
 	init_evtchn_cpu_bindings();
 
 	/* No VIRQ or IPI bindings. */

--

^ permalink raw reply	[relevance 14%]

* [PATCH][BALLOON] Fix minimum target
@ 2006-05-27  5:18 16% Puthiyaparambil, Aravindh
  0 siblings, 0 replies; 200+ results
From: Puthiyaparambil, Aravindh @ 2006-05-27  5:18 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel, Carb, Brian A

[-- Attachment #1: Type: text/plain, Size: 581 bytes --]

Keir,

We tried a few experiments with your 2% patch. We found that 2% is not
good enough. The magic numbers seem to be 3% for DomUs and 5% for Dom0.
Any idea why the difference in percentages?

If this patch is fine by you, could you please apply to both
xen-unstable and xen-3.0-testing?

Thanks,
Aravindh Puthiyaparambil 
Xen Development Team
Unisys, Tredyffrin PA

--------------------------

Do not allow target to be set below 3% of maximum memory for DomUs and
5% for Dom0.
Signed-off-by: Aravindh Puthiyaparambil
<aravindh.puthiyaparambil@unisys.com>


[-- Attachment #2: balloon_percent-unstable.patch --]
[-- Type: application/octet-stream, Size: 972 bytes --]

diff -r 3ed325fa395b linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri May 26 13:53:49 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri May 26 23:15:21 2006 -0400
@@ -360,10 +360,19 @@ static void balloon_process(void *unused
 /* Resets the Xen limit, sets new target, and kicks off processing. */
 static void set_new_target(unsigned long target)
 {
-	unsigned long min_target;
-
-	/* Do not allow target to reduce below 2% of maximum memory size. */
-	min_target = max_pfn / 50;
+	unsigned long min_target, max_mem_percent;
+
+	/*
+	 * Do not allow target to reduce below 3% of maximum memory size
+	 * for DomUs and 5% for Dom0.
+	 */
+
+	if (xen_start_info->flags & SIF_INITDOMAIN)
+		max_mem_percent = 5;
+	else
+		max_mem_percent = 3;
+
+	min_target = (max_pfn * max_mem_percent)/ 100;
 	target = max(target, min_target);
 
 	/* No need for lock. Not read-modify-write updates. */

[-- Attachment #3: balloon_percent-testing.patch --]
[-- Type: application/octet-stream, Size: 890 bytes --]


diff -r 106020760657 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri May 26 13:55:33 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sat May 27 00:58:59 2006 -0400
@@ -359,6 +359,21 @@ static void balloon_process(void *unused
 /* Resets the Xen limit, sets new target, and kicks off processing. */
 static void set_new_target(unsigned long target)
 {
+	unsigned long min_target, max_mem_percent;
+
+	/*
+	 * Do not allow target to reduce below 3% of maximum memory size
+	 * for DomUs and 5% for Dom0.
+	 */
+
+	if (xen_start_info->flags & SIF_INITDOMAIN)
+		max_mem_percent = 5;
+	else
+		max_mem_percent = 3;
+
+	min_target = (max_pfn * max_mem_percent)/ 100;
+	target = max(target, min_target);
+
 	/* No need for lock. Not read-modify-write updates. */
 	hard_limit   = ~0UL;
 	target_pages = target;

[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 16%]

* [PATCH][BLKTAP] remove blktap
@ 2006-06-09  5:37  3% Chris Wright
  0 siblings, 0 replies; 200+ results
From: Chris Wright @ 2006-06-09  5:37 UTC (permalink / raw)
  To: xen-devel

This code doesn't compile, is marked as DANGEROUS, and is said
to be removed when block drivers use grant tables.  So let's remove it.

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
 linux-2.6-xen-sparse/drivers/xen/Kconfig            |   13
 linux-2.6-xen-sparse/drivers/xen/Makefile           |    1
 linux-2.6-xen-sparse/drivers/xen/blktap/Makefile    |    3
 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c    |  900 --------------------
 linux-2.6-xen-sparse/drivers/xen/blktap/common.h    |  100 --
 linux-2.6-xen-sparse/drivers/xen/blktap/interface.c |  134 --
 linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c    |  223 ----
 7 files changed, 1374 deletions(-)

diff -r 4f1e39ec05d6 linux-2.6-xen-sparse/drivers/xen/Kconfig
--- a/linux-2.6-xen-sparse/drivers/xen/Kconfig	Thu Jun 08 16:51:39 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig	Fri Jun 09 01:24:49 2006 -0400
@@ -84,19 +84,6 @@ config XEN_BLKDEV_BACKEND
 	  block devices to other guests via a high-performance shared-memory
 	  interface.
 
-config XEN_BLKDEV_TAP_BE
-        tristate "Block Tap support for backend driver (DANGEROUS)"
-        depends on XEN_BLKDEV_BACKEND
-        default n
-        help
-          If you intend to use the block tap driver, the backend domain will
-          not know the domain id of the real frontend, and so will not be able
-          to map its data pages.  This modifies the backend to attempt to map
-          from both the tap domain and the real frontend.  This presents a
-          security risk, and so should ONLY be used for development
-          with the blktap.  This option will be removed as the block drivers are
-          modified to use grant tables.
-
 config XEN_NETDEV_BACKEND
 	tristate "Network-device backend driver"
         depends on XEN_BACKEND && NET
diff -r 4f1e39ec05d6 linux-2.6-xen-sparse/drivers/xen/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/Makefile	Thu Jun 08 16:51:39 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/Makefile	Fri Jun 09 01:24:49 2006 -0400
@@ -12,6 +12,5 @@ obj-$(CONFIG_XEN_TPMDEV_BACKEND)	+= tpmb
 obj-$(CONFIG_XEN_TPMDEV_BACKEND)	+= tpmback/
 obj-$(CONFIG_XEN_BLKDEV_FRONTEND)	+= blkfront/
 obj-$(CONFIG_XEN_NETDEV_FRONTEND)	+= netfront/
-obj-$(CONFIG_XEN_BLKDEV_TAP)    	+= blktap/
 obj-$(CONFIG_XEN_PCIDEV_BACKEND)	+= pciback/
 obj-$(CONFIG_XEN_PCIDEV_FRONTEND)	+= pcifront/
diff -r 4f1e39ec05d6 linux-2.6-xen-sparse/drivers/xen/blktap/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/Makefile	Thu Jun 08 16:51:39 2006 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-
-obj-y	:= xenbus.o interface.o blktap.o 
-
diff -r 4f1e39ec05d6 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Jun 08 16:51:39 2006 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,900 +0,0 @@
-/******************************************************************************
- * arch/xen/drivers/blkif/blktap/blktap.c
- * 
- * This is a modified version of the block backend driver that remaps requests
- * to a user-space memory region.  It is intended to be used to write 
- * application-level servers that provide block interfaces to client VMs.
- */
-
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <xen/balloon.h>
-#include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/mm.h>
-#include <linux/miscdevice.h>
-#include <linux/errno.h>
-#include <linux/major.h>
-#include <linux/gfp.h>
-#include <linux/poll.h>
-#include <asm/tlbflush.h>
-#include "common.h"
-
-/* Only one process may open /dev/xen/blktap at any time. */
-static unsigned long blktap_dev_inuse;
-unsigned long blktap_ring_ok; /* make this ring->state */
-
-/* Rings up to user space. */
-static blkif_front_ring_t blktap_ufe_ring;
-
-/* for poll: */
-static wait_queue_head_t blktap_wait;
-
-/* current switching mode */
-static unsigned long blktap_mode;
-
-/* local prototypes */
-static int blktap_read_ufe_ring(void);
-
-
-/* /dev/xen/blktap resides at device number major=10, minor=200        */ 
-#define BLKTAP_MINOR 202
-
-/* blktap IOCTLs:                                                      */
-#define BLKTAP_IOCTL_KICK_FE         1
-#define BLKTAP_IOCTL_KICK_BE         2 /* currently unused */
-#define BLKTAP_IOCTL_SETMODE         3
-#define BLKTAP_IOCTL_PRINT_IDXS      100  
-
-/* blktap switching modes: (Set with BLKTAP_IOCTL_SETMODE)             */
-#define BLKTAP_MODE_PASSTHROUGH      0x00000000  /* default            */
-#define BLKTAP_MODE_INTERCEPT_FE     0x00000001
-#define BLKTAP_MODE_INTERCEPT_BE     0x00000002  /* unimp. */
-#define BLKTAP_MODE_COPY_FE          0x00000004  /* unimp. */
-#define BLKTAP_MODE_COPY_BE          0x00000008  /* unimp. */
-#define BLKTAP_MODE_COPY_FE_PAGES    0x00000010  /* unimp. */
-#define BLKTAP_MODE_COPY_BE_PAGES    0x00000020  /* unimp. */
-
-#define BLKTAP_MODE_INTERPOSE \
-           (BLKTAP_MODE_INTERCEPT_FE | BLKTAP_MODE_INTERCEPT_BE)
-
-#define BLKTAP_MODE_COPY_BOTH \
-           (BLKTAP_MODE_COPY_FE | BLKTAP_MODE_COPY_BE)
-
-#define BLKTAP_MODE_COPY_BOTH_PAGES \
-           (BLKTAP_MODE_COPY_FE_PAGES | BLKTAP_MODE_COPY_BE_PAGES)
-
-static inline int BLKTAP_MODE_VALID(unsigned long arg)
-{
-	return ((arg == BLKTAP_MODE_PASSTHROUGH ) ||
-		(arg == BLKTAP_MODE_INTERCEPT_FE) ||
-		(arg == BLKTAP_MODE_INTERPOSE   ));
-/*
-  return (
-  ( arg == BLKTAP_MODE_PASSTHROUGH  ) ||
-  ( arg == BLKTAP_MODE_INTERCEPT_FE ) ||
-  ( arg == BLKTAP_MODE_INTERCEPT_BE ) ||
-  ( arg == BLKTAP_MODE_INTERPOSE    ) ||
-  ( (arg & ~BLKTAP_MODE_COPY_FE_PAGES) == BLKTAP_MODE_COPY_FE ) ||
-  ( (arg & ~BLKTAP_MODE_COPY_BE_PAGES) == BLKTAP_MODE_COPY_BE ) ||
-  ( (arg & ~BLKTAP_MODE_COPY_BOTH_PAGES) == BLKTAP_MODE_COPY_BOTH )
-  );
-*/
-}
-
-
-/******************************************************************
- * MMAP REGION
- */
-
-/*
- * We use a big chunk of address space to map in-flight requests into,
- * and export this region up to user-space.  See the comments in blkback
- * about this -- the two must be kept in sync if the tap is used as a 
- * passthrough.
- */
-
-#define MAX_PENDING_REQS 64
-#define BATCH_PER_DOMAIN 16
-
-/* immediately before the mmap area, we have a bunch of pages reserved
- * for shared memory rings.
- */
-#define RING_PAGES 1 /* Front */ 
-
-/* Where things are inside the device mapping. */
-struct vm_area_struct *blktap_vma = NULL;
-unsigned long mmap_vstart;  /* Kernel pages for mapping in data. */
-unsigned long rings_vstart; /* start of mmaped vma               */
-unsigned long user_vstart;  /* start of user mappings            */
-
-#define MMAP_PAGES						\
-	(MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
-#define MMAP_VADDR(_start, _req,_seg)					\
-	(_start +							\
-	 ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +	\
-	 ((_seg) * PAGE_SIZE))
-
-/*
- * Each outstanding request that we've passed to the lower device layers has a 
- * 'pending_req' allocated to it. Each buffer_head that completes decrements 
- * the pendcnt towards zero. When it hits zero, the specified domain has a 
- * response queued for it, with the saved 'id' passed back.
- */
-typedef struct {
-	blkif_t       *blkif;
-	unsigned long  id;
-	int            nr_pages;
-	atomic_t       pendcnt;
-	unsigned short operation;
-	int            status;
-} pending_req_t;
-
-/*
- * We can't allocate pending_req's in order, since they may complete out of 
- * order. We therefore maintain an allocation ring. This ring also indicates 
- * when enough work has been passed down -- at that point the allocation ring 
- * will be empty.
- */
-static pending_req_t pending_reqs[MAX_PENDING_REQS];
-static unsigned char pending_ring[MAX_PENDING_REQS];
-static DEFINE_SPINLOCK(pend_prod_lock);
-/* NB. We use a different index type to differentiate from shared blk rings. */
-typedef unsigned int PEND_RING_IDX;
-#define MASK_PEND_IDX(_i) ((_i)&(MAX_PENDING_REQS-1))
-static PEND_RING_IDX pending_prod, pending_cons;
-#define NR_PENDING_REQS (MAX_PENDING_REQS - pending_prod + pending_cons)
-
-/* Requests passing through the tap to the backend hijack the id field
- * in the request message.  In it we put the AR index _AND_ the fe domid.
- * the domid is used by the backend to map the pages properly.
- */
-
-static inline unsigned long MAKE_ID(domid_t fe_dom, PEND_RING_IDX idx)
-{
-	return ((fe_dom << 16) | MASK_PEND_IDX(idx));
-}
-
-extern inline PEND_RING_IDX ID_TO_IDX(unsigned long id) 
-{ 
-	return (PEND_RING_IDX)(id & 0x0000ffff);
-}
-
-extern inline domid_t ID_TO_DOM(unsigned long id) 
-{ 
-	return (domid_t)(id >> 16); 
-}
-
-
-
-/******************************************************************
- * GRANT HANDLES
- */
-
-/* When using grant tables to map a frame for device access then the
- * handle returned must be used to unmap the frame. This is needed to
- * drop the ref count on the frame.
- */
-struct grant_handle_pair
-{
-	grant_handle_t kernel;
-	grant_handle_t user;
-};
-static struct grant_handle_pair pending_grant_handles[MMAP_PAGES];
-#define pending_handle(_idx, _i) \
-    (pending_grant_handles[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#define BLKTAP_INVALID_HANDLE(_g) \
-    (((_g->kernel) == 0xFFFF) && ((_g->user) == 0xFFFF))
-#define BLKTAP_INVALIDATE_HANDLE(_g) do {       \
-    (_g)->kernel = 0xFFFF; (_g)->user = 0xFFFF; \
-    } while(0)
-
-
-/******************************************************************
- * BLKTAP VM OPS
- */
-
-static struct page *blktap_nopage(struct vm_area_struct *vma,
-				  unsigned long address,
-				  int *type)
-{
-	/*
-	 * if the page has not been mapped in by the driver then generate
-	 * a SIGBUS to the domain.
-	 */
-	force_sig(SIGBUS, current);
-
-	return 0;
-}
-
-struct vm_operations_struct blktap_vm_ops = {
-	.nopage = blktap_nopage,
-};
-
-/******************************************************************
- * BLKTAP FILE OPS
- */
-
-static int blktap_open(struct inode *inode, struct file *filp)
-{
-	blkif_sring_t *sring;
-
-	if (test_and_set_bit(0, &blktap_dev_inuse))
-		return -EBUSY;
-    
-	/* Allocate the fe ring. */
-	sring = (blkif_sring_t *)get_zeroed_page(GFP_KERNEL);
-	if (sring == NULL)
-		return -ENOMEM;
-
-	SetPageReserved(virt_to_page(sring));
-    
-	SHARED_RING_INIT(sring);
-	FRONT_RING_INIT(&blktap_ufe_ring, sring, PAGE_SIZE);
-
-	return 0;
-}
-
-static int blktap_release(struct inode *inode, struct file *filp)
-{
-	blktap_dev_inuse = 0;
-	blktap_ring_ok = 0;
-
-	/* Free the ring page. */
-	ClearPageReserved(virt_to_page(blktap_ufe_ring.sring));
-	free_page((unsigned long) blktap_ufe_ring.sring);
-
-	/* Clear any active mappings and free foreign map table */
-	if (blktap_vma != NULL) {
-		zap_page_range(
-			blktap_vma, blktap_vma->vm_start, 
-			blktap_vma->vm_end - blktap_vma->vm_start, NULL);
-		blktap_vma = NULL;
-	}
-
-	return 0;
-}
-
-
-/* Note on mmap:
- * We need to map pages to user space in a way that will allow the block
- * subsystem set up direct IO to them.  This couldn't be done before, because
- * there isn't really a sane way to translate a user virtual address down to a 
- * physical address when the page belongs to another domain.
- *
- * My first approach was to map the page in to kernel memory, add an entry
- * for it in the physical frame list (using alloc_lomem_region as in blkback)
- * and then attempt to map that page up to user space.  This is disallowed
- * by xen though, which realizes that we don't really own the machine frame
- * underlying the physical page.
- *
- * The new approach is to provide explicit support for this in xen linux.
- * The VMA now has a flag, VM_FOREIGN, to indicate that it contains pages
- * mapped from other vms.  vma->vm_private_data is set up as a mapping 
- * from pages to actual page structs.  There is a new clause in get_user_pages
- * that does the right thing for this sort of mapping.
- */
-static int blktap_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-	int size;
-	struct page **map;
-	int i;
-
-	DPRINTK(KERN_ALERT "blktap mmap (%lx, %lx)\n",
-		vma->vm_start, vma->vm_end);
-
-	vma->vm_flags |= VM_RESERVED;
-	vma->vm_ops = &blktap_vm_ops;
-
-	size = vma->vm_end - vma->vm_start;
-	if (size != ((MMAP_PAGES + RING_PAGES) << PAGE_SHIFT)) {
-		printk(KERN_INFO 
-		       "blktap: you _must_ map exactly %d pages!\n",
-		       MMAP_PAGES + RING_PAGES);
-		return -EAGAIN;
-	}
-
-	size >>= PAGE_SHIFT;
-	DPRINTK(KERN_INFO "blktap: 2 rings + %d pages.\n", size-1);
-    
-	rings_vstart = vma->vm_start;
-	user_vstart  = rings_vstart + (RING_PAGES << PAGE_SHIFT);
-    
-	/* Map the ring pages to the start of the region and reserve it. */
-
-	/* not sure if I really need to do this... */
-	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-
-	if (remap_pfn_range(vma, vma->vm_start, 
-			    __pa(blktap_ufe_ring.sring) >> PAGE_SHIFT, 
-			    PAGE_SIZE, vma->vm_page_prot)) {
-		WPRINTK("Mapping user ring failed!\n");
-		goto fail;
-	}
-
-	/* Mark this VM as containing foreign pages, and set up mappings. */
-	map = kmalloc(((vma->vm_end - vma->vm_start) >> PAGE_SHIFT)
-		      * sizeof(struct page_struct*),
-		      GFP_KERNEL);
-	if (map == NULL) {
-		WPRINTK("Couldn't alloc VM_FOREIGH map.\n");
-		goto fail;
-	}
-
-	for (i = 0; i < ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT); i++)
-		map[i] = NULL;
-    
-	vma->vm_private_data = map;
-	vma->vm_flags |= VM_FOREIGN;
-
-	blktap_vma = vma;
-	blktap_ring_ok = 1;
-
-	return 0;
- fail:
-	/* Clear any active mappings. */
-	zap_page_range(vma, vma->vm_start, 
-		       vma->vm_end - vma->vm_start, NULL);
-
-	return -ENOMEM;
-}
-
-static int blktap_ioctl(struct inode *inode, struct file *filp,
-                        unsigned int cmd, unsigned long arg)
-{
-	switch(cmd) {
-	case BLKTAP_IOCTL_KICK_FE: /* There are fe messages to process. */
-		return blktap_read_ufe_ring();
-
-	case BLKTAP_IOCTL_SETMODE:
-		if (BLKTAP_MODE_VALID(arg)) {
-			blktap_mode = arg;
-			/* XXX: may need to flush rings here. */
-			printk(KERN_INFO "blktap: set mode to %lx\n", arg);
-			return 0;
-		}
-	case BLKTAP_IOCTL_PRINT_IDXS:
-        {
-		//print_fe_ring_idxs();
-		WPRINTK("User Rings: \n-----------\n");
-		WPRINTK("UF: rsp_cons: %2d, req_prod_prv: %2d "
-			"| req_prod: %2d, rsp_prod: %2d\n",
-			blktap_ufe_ring.rsp_cons,
-			blktap_ufe_ring.req_prod_pvt,
-			blktap_ufe_ring.sring->req_prod,
-			blktap_ufe_ring.sring->rsp_prod);
-            
-        }
-	}
-	return -ENOIOCTLCMD;
-}
-
-static unsigned int blktap_poll(struct file *file, poll_table *wait)
-{
-	poll_wait(file, &blktap_wait, wait);
-	if (blktap_ufe_ring.req_prod_pvt != blktap_ufe_ring.sring->req_prod) {
-		flush_tlb_all();
-		RING_PUSH_REQUESTS(&blktap_ufe_ring);
-		return POLLIN | POLLRDNORM;
-	}
-
-	return 0;
-}
-
-void blktap_kick_user(void)
-{
-	/* blktap_ring->req_prod = blktap_req_prod; */
-	wake_up_interruptible(&blktap_wait);
-}
-
-static struct file_operations blktap_fops = {
-	.owner   = THIS_MODULE,
-	.poll    = blktap_poll,
-	.ioctl   = blktap_ioctl,
-	.open    = blktap_open,
-	.release = blktap_release,
-	.mmap    = blktap_mmap,
-};
-
-
-
-static int do_block_io_op(blkif_t *blkif, int max_to_do);
-static void dispatch_rw_block_io(blkif_t *blkif, blkif_request_t *req);
-static void make_response(blkif_t *blkif, unsigned long id, 
-                          unsigned short op, int st);
-
-
-static void fast_flush_area(int idx, int nr_pages)
-{
-	struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
-	unsigned int i, op = 0;
-	struct grant_handle_pair *handle;
-	uint64_t ptep;
-	int ret;
-
-	for ( i = 0; i < nr_pages; i++)
-	{
-		handle = &pending_handle(idx, i);
-		if (BLKTAP_INVALID_HANDLE(handle))
-			continue;
-
-		gnttab_set_unmap_op(&unmap[op],
-				    MMAP_VADDR(mmap_vstart, idx, i),
-				    GNTMAP_host_map, handle->kernel);
-		op++;
-
-		if (create_lookup_pte_addr(
-			    blktap_vma->vm_mm,
-			    MMAP_VADDR(user_vstart, idx, i), 
-			    &ptep) !=0) {
-			DPRINTK("Couldn't get a pte addr!\n");
-			return;
-		}
-		gnttab_set_unmap_grnat_ref(&unmap[op], ptep,
-					   GNTMAP_host_map |
-					   GNTMAP_application_map |
-					   GNTMAP_contains_pte, handle->user);
-		op++;
-            
-		BLKTAP_INVALIDATE_HANDLE(handle);
-	}
-
-	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, op);
-	BUG_ON(ret);
-
-	if (blktap_vma != NULL)
-		zap_page_range(blktap_vma, 
-			       MMAP_VADDR(user_vstart, idx, 0), 
-			       nr_pages << PAGE_SHIFT, NULL);
-}
-
-/******************************************************************
- * BLOCK-DEVICE SCHEDULER LIST MAINTENANCE
- */
-
-static struct list_head blkio_schedule_list;
-static spinlock_t blkio_schedule_list_lock;
-
-static int __on_blkdev_list(blkif_t *blkif)
-{
-	return blkif->blkdev_list.next != NULL;
-}
-
-static void remove_from_blkdev_list(blkif_t *blkif)
-{
-	unsigned long flags;
-
-	if (!__on_blkdev_list(blkif))
-		return;
-
-	spin_lock_irqsave(&blkio_schedule_list_lock, flags);
-	if (__on_blkdev_list(blkif)) {
-		list_del(&blkif->blkdev_list);
-		blkif->blkdev_list.next = NULL;
-		blkif_put(blkif);
-	}
-	spin_unlock_irqrestore(&blkio_schedule_list_lock, flags);
-}
-
-static void add_to_blkdev_list_tail(blkif_t *blkif)
-{
-	unsigned long flags;
-
-	if (__on_blkdev_list(blkif))
-		return;
-
-	spin_lock_irqsave(&blkio_schedule_list_lock, flags);
-	if (!__on_blkdev_list(blkif) && (blkif->status == CONNECTED)) {
-		list_add_tail(&blkif->blkdev_list, &blkio_schedule_list);
-		blkif_get(blkif);
-	}
-	spin_unlock_irqrestore(&blkio_schedule_list_lock, flags);
-}
-
-
-/******************************************************************
- * SCHEDULER FUNCTIONS
- */
-
-static DECLARE_WAIT_QUEUE_HEAD(blkio_schedule_wait);
-
-static int blkio_schedule(void *arg)
-{
-	DECLARE_WAITQUEUE(wq, current);
-
-	blkif_t          *blkif;
-	struct list_head *ent;
-
-	daemonize("xenblkd");
-
-	for (;;) {
-		/* Wait for work to do. */
-		add_wait_queue(&blkio_schedule_wait, &wq);
-		set_current_state(TASK_INTERRUPTIBLE);
-		if ((NR_PENDING_REQS == MAX_PENDING_REQS) || 
-		    list_empty(&blkio_schedule_list))
-			schedule();
-		__set_current_state(TASK_RUNNING);
-		remove_wait_queue(&blkio_schedule_wait, &wq);
-
-		/* Queue up a batch of requests. */
-		while ((NR_PENDING_REQS < MAX_PENDING_REQS) &&
-		       !list_empty(&blkio_schedule_list)) {
-			ent = blkio_schedule_list.next;
-			blkif = list_entry(ent, blkif_t, blkdev_list);
-			blkif_get(blkif);
-			remove_from_blkdev_list(blkif);
-			if (do_block_io_op(blkif, BATCH_PER_DOMAIN))
-				add_to_blkdev_list_tail(blkif);
-			blkif_put(blkif);
-		}
-	}
-}
-
-static void maybe_trigger_blkio_schedule(void)
-{
-	/*
-	 * Needed so that two processes, who together make the following
-	 * predicate true, don't both read stale values and evaluate the
-	 * predicate incorrectly. Incredibly unlikely to stall the scheduler
-	 * on the x86, but...
-	 */
-	smp_mb();
-
-	if ((NR_PENDING_REQS < (MAX_PENDING_REQS/2)) &&
-	    !list_empty(&blkio_schedule_list))
-		wake_up(&blkio_schedule_wait);
-}
-
-
-
-/******************************************************************
- * COMPLETION CALLBACK -- Called as bh->b_end_io()
- */
-
-
-static int blktap_read_ufe_ring(void)
-{
-	/* This is called to read responses from the UFE ring. */
-
-	RING_IDX i, j, rp;
-	blkif_response_t *resp;
-	blkif_t *blkif;
-	int pending_idx;
-	pending_req_t *pending_req;
-	unsigned long     flags;
-
-	/* if we are forwarding from UFERring to FERing */
-	if (blktap_mode & BLKTAP_MODE_INTERCEPT_FE) {
-
-		/* for each outstanding message on the UFEring  */
-		rp = blktap_ufe_ring.sring->rsp_prod;
-		rmb();
-        
-		for (i = blktap_ufe_ring.rsp_cons; i != rp; i++) {
-			resp = RING_GET_RESPONSE(&blktap_ufe_ring, i);
-			pending_idx = MASK_PEND_IDX(ID_TO_IDX(resp->id));
-			pending_req = &pending_reqs[pending_idx];
-            
-			blkif = pending_req->blkif;
-			for (j = 0; j < pending_req->nr_pages; j++) {
-				unsigned long vaddr;
-				struct page **map = blktap_vma->vm_private_data;
-				int offset; 
-
-				vaddr  = MMAP_VADDR(user_vstart, pending_idx, j);
-				offset = (vaddr - blktap_vma->vm_start) >> PAGE_SHIFT;
-
-				//ClearPageReserved(virt_to_page(vaddr));
-				ClearPageReserved((struct page *)map[offset]);
-				map[offset] = NULL;
-			}
-
-			fast_flush_area(pending_idx, pending_req->nr_pages);
-			make_response(blkif, pending_req->id, resp->operation, 
-				      resp->status);
-			blkif_put(pending_req->blkif);
-			spin_lock_irqsave(&pend_prod_lock, flags);
-			pending_ring[MASK_PEND_IDX(pending_prod++)] = pending_idx;
-			spin_unlock_irqrestore(&pend_prod_lock, flags);
-		}
-		blktap_ufe_ring.rsp_cons = i;
-		maybe_trigger_blkio_schedule();
-	}
-	return 0;
-}
-
-
-/******************************************************************************
- * NOTIFICATION FROM GUEST OS.
- */
-
-irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
-{
-	blkif_t *blkif = dev_id;
-	add_to_blkdev_list_tail(blkif);
-	maybe_trigger_blkio_schedule();
-	return IRQ_HANDLED;
-}
-
-
-
-/******************************************************************
- * DOWNWARD CALLS -- These interface with the block-device layer proper.
- */
-
-static int do_block_io_op(blkif_t *blkif, int max_to_do)
-{
-	blkif_back_ring_t *blk_ring = &blkif->blk_ring;
-	blkif_request_t *req;
-	RING_IDX i, rp;
-	int more_to_do = 0;
-    
-	rp = blk_ring->sring->req_prod;
-	rmb(); /* Ensure we see queued requests up to 'rp'. */
-
-	for (i = blk_ring->req_cons; 
-	     (i != rp) && !RING_REQUEST_CONS_OVERFLOW(blk_ring, i);
-	     i++ ) {
-		if ((max_to_do-- == 0) ||
-		    (NR_PENDING_REQS == MAX_PENDING_REQS)) {
-			more_to_do = 1;
-			break;
-		}
-        
-		req = RING_GET_REQUEST(blk_ring, i);
-		switch (req->operation) {
-		case BLKIF_OP_READ:
-		case BLKIF_OP_WRITE:
-			dispatch_rw_block_io(blkif, req);
-			break;
-
-		default:
-			DPRINTK("error: unknown block io operation [%d]\n",
-				req->operation);
-			make_response(blkif, req->id, req->operation,
-				      BLKIF_RSP_ERROR);
-			break;
-		}
-	}
-
-	blk_ring->req_cons = i;
-	blktap_kick_user();
-
-	return more_to_do;
-}
-
-static void dispatch_rw_block_io(blkif_t *blkif, blkif_request_t *req)
-{
-	blkif_request_t *target;
-	int i, pending_idx = pending_ring[MASK_PEND_IDX(pending_cons)];
-	pending_req_t *pending_req;
-	struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
-	int op, ret;
-	unsigned int nseg;
-	int retval;
-
-	/* Check that number of segments is sane. */
-	nseg = req->nr_segments;
-	if (unlikely(nseg == 0) || 
-	    unlikely(nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) {
-		DPRINTK("Bad number of segments in request (%d)\n", nseg);
-		goto bad_descriptor;
-	}
-
-	/* Make sure userspace is ready. */
-	if (!blktap_ring_ok) {
-		DPRINTK("blktap: ring not ready for requests!\n");
-		goto bad_descriptor;
-	}
-    
-
-	if (RING_FULL(&blktap_ufe_ring)) {
-		WPRINTK("blktap: fe_ring is full, can't add "
-			"(very broken!).\n");
-		goto bad_descriptor;
-	}
-
-	flush_cache_all(); /* a noop on intel... */
-
-	/* Map the foreign pages directly in to the application */    
-	op = 0;
-	for (i = 0; i < req->nr_segments; i++) {
-
-		unsigned long uvaddr;
-		unsigned long kvaddr;
-		uint64_t ptep;
-		uint32_t flags;
-
-		uvaddr = MMAP_VADDR(user_vstart, pending_idx, i);
-		kvaddr = MMAP_VADDR(mmap_vstart, pending_idx, i);
-
-		flags = GNTMAP_host_map;
-		/* This needs a bit more thought in terms of interposition: 
-		 * If we want to be able to modify pages during write using 
-		 * grant table mappings, the guest will either need to allow 
-		 * it, or we'll need to incur a copy. Bit of an fbufs moment. ;) */
-		if (req->operation == BLKIF_OP_WRITE)
-			flags |= GNTMAP_readonly;
-		/* Map the remote page to kernel. */
-		gnttab_set_map_op(&map[op], kvaddr, flags, req->seg[i].gref,
-				  blkif->domid);
-		op++;
-
-		/* Now map it to user. */
-		ret = create_lookup_pte_addr(blktap_vma->vm_mm, uvaddr, &ptep);
-		if (ret) {
-			DPRINTK("Couldn't get a pte addr!\n");
-			fast_flush_area(pending_idx, req->nr_segments);
-			goto bad_descriptor;
-		}
-
-		flags = GNTMAP_host_map | GNTMAP_application_map
-			| GNTMAP_contains_pte;
-		/* Above interposition comment applies here as well. */
-		if (req->operation == BLKIF_OP_WRITE)
-			flags |= GNTMAP_readonly;
-		gnttab_set_map_op(&map[op], ptep, flags, req->seg[i].gref,
-				  blkif->domid);
-		op++;
-	}
-
-	retval = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
-	BUG_ON(retval);
-
-	op = 0;
-	for (i = 0; i < (req->nr_segments*2); i += 2) {
-		unsigned long uvaddr;
-		unsigned long kvaddr;
-		unsigned long offset;
-		int cancel = 0;
-
-		uvaddr = MMAP_VADDR(user_vstart, pending_idx, i/2);
-		kvaddr = MMAP_VADDR(mmap_vstart, pending_idx, i/2);
-
-		if (unlikely(map[i].status)) {
-			DPRINTK("Error on kernel grant mapping (%d)\n",
-				map[i].status);
-			ret = map[i].status;
-			cancel = 1;
-		}
-
-		if (unlikely(map[i+1].status)) {
-			DPRINTK("Error on user grant mapping (%d)\n",
-				map[i+1].status);
-			ret = map[i+1].status;
-			cancel = 1;
-		}
-
-		if (cancel) {
-			fast_flush_area(pending_idx, req->nr_segments);
-			goto bad_descriptor;
-		}
-
-		/* Set the necessary mappings in p2m and in the VM_FOREIGN 
-		 * vm_area_struct to allow user vaddr -> struct page lookups
-		 * to work.  This is needed for direct IO to foreign pages. */
-		set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT,
-				FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
-
-		offset = (uvaddr - blktap_vma->vm_start) >> PAGE_SHIFT;
-		((struct page **)blktap_vma->vm_private_data)[offset] =
-			pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
-
-		/* Save handles for unmapping later. */
-		pending_handle(pending_idx, i/2).kernel = map[i].handle;
-		pending_handle(pending_idx, i/2).user   = map[i+1].handle;
-	}
-
-	/* Mark mapped pages as reserved: */
-	for (i = 0; i < req->nr_segments; i++) {
-		unsigned long kvaddr;
-		kvaddr = MMAP_VADDR(mmap_vstart, pending_idx, i);
-		SetPageReserved(pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT));
-	}
-
-	pending_req = &pending_reqs[pending_idx];
-	pending_req->blkif     = blkif;
-	pending_req->id        = req->id;
-	pending_req->operation = req->operation;
-	pending_req->status    = BLKIF_RSP_OKAY;
-	pending_req->nr_pages  = nseg;
-	req->id = MAKE_ID(blkif->domid, pending_idx);
-	//atomic_set(&pending_req->pendcnt, nbio);
-	pending_cons++;
-	blkif_get(blkif);
-
-	/* Finally, write the request message to the user ring. */
-	target = RING_GET_REQUEST(&blktap_ufe_ring,
-				  blktap_ufe_ring.req_prod_pvt);
-	memcpy(target, req, sizeof(*req));
-	blktap_ufe_ring.req_prod_pvt++;
-	return;
-
- bad_descriptor:
-	make_response(blkif, req->id, req->operation, BLKIF_RSP_ERROR);
-} 
-
-
-
-/******************************************************************
- * MISCELLANEOUS SETUP / TEARDOWN / DEBUGGING
- */
-
-
-static void make_response(blkif_t *blkif, unsigned long id, 
-                          unsigned short op, int st)
-{
-	blkif_response_t *resp;
-	unsigned long     flags;
-	blkif_back_ring_t *blk_ring = &blkif->blk_ring;
-
-	/* Place on the response ring for the relevant domain. */ 
-	spin_lock_irqsave(&blkif->blk_ring_lock, flags);
-	resp = RING_GET_RESPONSE(blk_ring, blk_ring->rsp_prod_pvt);
-	resp->id        = id;
-	resp->operation = op;
-	resp->status    = st;
-	wmb(); /* Ensure other side can see the response fields. */
-	blk_ring->rsp_prod_pvt++;
-	RING_PUSH_RESPONSES(blk_ring);
-	spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
-
-	/* Kick the relevant domain. */
-	notify_remote_via_irq(blkif->irq);
-}
-
-static struct miscdevice blktap_miscdev = {
-	.minor        = BLKTAP_MINOR,
-	.name         = "blktap",
-	.fops         = &blktap_fops,
-	.devfs_name   = "misc/blktap",
-};
-
-void blkif_deschedule(blkif_t *blkif)
-{
-	remove_from_blkdev_list(blkif);
-}
-
-static int __init blkif_init(void)
-{
-	int i, j, err;
-	struct page *page;
-
-	blkif_interface_init();
-
-	page = balloon_alloc_empty_page_range(MMAP_PAGES);
-	BUG_ON(page == NULL);
-	mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
-
-	pending_cons = 0;
-	pending_prod = MAX_PENDING_REQS;
-	memset(pending_reqs, 0, sizeof(pending_reqs));
-	for ( i = 0; i < MAX_PENDING_REQS; i++ )
-		pending_ring[i] = i;
-    
-	spin_lock_init(&blkio_schedule_list_lock);
-	INIT_LIST_HEAD(&blkio_schedule_list);
-
-	i = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
-	BUG_ON(i<0);
-
-	blkif_xenbus_init();
-
-	for (i = 0; i < MAX_PENDING_REQS ; i++)
-		for (j = 0; j < BLKIF_MAX_SEGMENTS_PER_REQUEST; j++)
-			BLKTAP_INVALIDATE_HANDLE(&pending_handle(i, j));
-
-	err = misc_register(&blktap_miscdev);
-	if (err != 0) {
-		printk(KERN_ALERT "Couldn't register /dev/misc/blktap (%d)\n",
-		       err);
-		return err;
-	}
-
-	init_waitqueue_head(&blktap_wait);
-
-	return 0;
-}
-
-__initcall(blkif_init);
diff -r 4f1e39ec05d6 linux-2.6-xen-sparse/drivers/xen/blktap/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/common.h	Thu Jun 08 16:51:39 2006 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-
-#ifndef __BLKIF__BACKEND__COMMON_H__
-#define __BLKIF__BACKEND__COMMON_H__
-
-#include <linux/config.h>
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include <linux/blkdev.h>
-#include <linux/vmalloc.h>
-#include <asm/io.h>
-#include <asm/setup.h>
-#include <asm/pgalloc.h>
-#include <xen/evtchn.h>
-#include <asm/hypervisor.h>
-#include <xen/interface/io/blkif.h>
-#include <xen/interface/io/ring.h>
-#include <xen/gnttab.h>
-#include <xen/driver_util.h>
-
-#define DPRINTK(_f, _a...) pr_debug("(file=%s, line=%d) " _f, \
-                                    __FILE__ , __LINE__ , ## _a )
-
-#define WPRINTK(fmt, args...) printk(KERN_WARNING "blk_tap: " fmt, ##args)
-
-struct vbd {
-	blkif_vdev_t   handle;      /* what the domain refers to this vbd as */
-	unsigned char  readonly;    /* Non-zero -> read-only */
-	unsigned char  type;        /* VDISK_xxx */
-	u32            pdevice;     /* phys device that this vbd maps to */
-	struct block_device *bdev;
-}; 
-
-typedef struct blkif_st {
-	/* Unique identifier for this interface. */
-	domid_t           domid;
-	unsigned int      handle;
-	/* Physical parameters of the comms window. */
-	unsigned int      evtchn;
-	unsigned int      irq;
-	/* Comms information. */
-	blkif_back_ring_t blk_ring;
-	struct vm_struct *blk_ring_area;
-	/* VBDs attached to this interface. */
-	struct vbd        vbd;
-	/* Private fields. */
-	enum { DISCONNECTED, CONNECTED } status;
-#ifdef CONFIG_XEN_BLKDEV_TAP_BE
-	/* Is this a blktap frontend */
-	unsigned int     is_blktap;
-#endif
-	struct list_head blkdev_list;
-	spinlock_t       blk_ring_lock;
-	atomic_t         refcnt;
-
-	struct work_struct free_work;
-
-	grant_handle_t   shmem_handle;
-	grant_ref_t      shmem_ref;
-} blkif_t;
-
-blkif_t *alloc_blkif(domid_t domid);
-void free_blkif_callback(blkif_t *blkif);
-int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn);
-
-#define blkif_get(_b) (atomic_inc(&(_b)->refcnt))
-#define blkif_put(_b)                             \
-    do {                                          \
-        if ( atomic_dec_and_test(&(_b)->refcnt) ) \
-            free_blkif_callback(_b);		  \
-    } while (0)
-
-/* Create a vbd. */
-int vbd_create(blkif_t *blkif, blkif_vdev_t vdevice, u32 pdevice,
-	       int readonly);
-void vbd_free(struct vbd *vbd);
-
-unsigned long vbd_size(struct vbd *vbd);
-unsigned int vbd_info(struct vbd *vbd);
-unsigned long vbd_secsize(struct vbd *vbd);
-
-struct phys_req {
-	unsigned short       dev;
-	unsigned short       nr_sects;
-	struct block_device *bdev;
-	blkif_sector_t       sector_number;
-};
-
-int vbd_translate(struct phys_req *req, blkif_t *blkif, int operation); 
-
-void blkif_interface_init(void);
-
-void blkif_deschedule(blkif_t *blkif);
-
-void blkif_xenbus_init(void);
-
-irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
-
-#endif /* __BLKIF__BACKEND__COMMON_H__ */
diff -r 4f1e39ec05d6 linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Thu Jun 08 16:51:39 2006 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/******************************************************************************
- * arch/xen/drivers/blkif/backend/interface.c
- * 
- * Block-device interface management.
- * 
- * Copyright (c) 2004, Keir Fraser
- */
-
-#include "common.h"
-#include <xen/evtchn.h>
-
-static kmem_cache_t *blkif_cachep;
-
-blkif_t *alloc_blkif(domid_t domid)
-{
-	blkif_t *blkif;
-
-	blkif = kmem_cache_alloc(blkif_cachep, GFP_KERNEL);
-	if (!blkif)
-		return ERR_PTR(-ENOMEM);
-
-	memset(blkif, 0, sizeof(*blkif));
-	blkif->domid = domid;
-	blkif->status = DISCONNECTED;
-	spin_lock_init(&blkif->blk_ring_lock);
-	atomic_set(&blkif->refcnt, 1);
-
-	return blkif;
-}
-
-static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
-{
-	struct gnttab_map_grant_ref op;
-	int ret;
-
-	gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
-			  GNTMAP_host_map, shared_page, blkif->domid);
-
-	lock_vm_area(blkif->blk_ring_area);
-	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-	unlock_vm_area(blkif->blk_ring_area);
-	BUG_ON(ret);
-
-	if (op.status) {
-		DPRINTK(" Grant table operation failure !\n");
-		return op.status;
-	}
-
-	blkif->shmem_ref    = shared_page;
-	blkif->shmem_handle = op.handle;
-
-	return 0;
-}
-
-static void unmap_frontend_page(blkif_t *blkif)
-{
-	struct gnttab_unmap_grant_ref op;
-	int ret;
-
-	gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
-			    GNTMAP_host_map, blkif->shmem_handle);
-
-	lock_vm_area(blkif->blk_ring_area);
-	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-	unlock_vm_area(blkif->blk_ring_area);
-	BUG_ON(ret);
-}
-
-int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
-{
-	blkif_sring_t *sring;
-	int err;
-	struct evtchn_bind_interdomain bind_interdomain;
-
-	if ((blkif->blk_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL)
-		return -ENOMEM;
-
-	err = map_frontend_page(blkif, shared_page);
-	if (err) {
-		free_vm_area(blkif->blk_ring_area);
-		return err;
-	}
-
-	bind_interdomain.remote_dom  = blkif->domid;
-	bind_interdomain.remote_port = evtchn;
-
-	err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-					  &bind_interdomain);
-	if (err) {
-		unmap_frontend_page(blkif);
-		free_vm_area(blkif->blk_ring_area);
-		return err;
-	}
-
-	blkif->evtchn = bind_interdomain.local_port;
-
-	sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
-	BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
-
-	blkif->irq = bind_evtchn_to_irqhandler(
-		blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
-
-	blkif->status = CONNECTED;
-
-	return 0;
-}
-
-static void free_blkif(void *arg)
-{
-	blkif_t *blkif = (blkif_t *)arg;
-
-	if (blkif->irq)
-		unbind_from_irqhandler(blkif->irq, blkif);
-
-	if (blkif->blk_ring.sring) {
-		unmap_frontend_page(blkif);
-		free_vm_area(blkif->blk_ring_area);
-		blkif->blk_ring.sring = NULL;
-	}
-
-	kmem_cache_free(blkif_cachep, blkif);
-}
-
-void free_blkif_callback(blkif_t *blkif)
-{
-	INIT_WORK(&blkif->free_work, free_blkif, (void *)blkif);
-	schedule_work(&blkif->free_work);
-}
-
-void __init blkif_interface_init(void)
-{
-	blkif_cachep = kmem_cache_create(
-		"blkif_cache", sizeof(blkif_t), 0, 0, NULL, NULL);
-}
diff -r 4f1e39ec05d6 linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	Thu Jun 08 16:51:39 2006 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,223 +0,0 @@
-/*  Xenbus code for blkif tap
-
-    A Warfield.
-
-    Hastily modified from the oroginal backend code:
-
-    Copyright (C) 2005 Rusty Russell <rusty@rustcorp.com.au>
-
-    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-#include <stdarg.h>
-#include <linux/module.h>
-#include <xen/xenbus.h>
-#include "common.h"
-
-struct backend_info
-{
-	struct xenbus_device *dev;
-
-	/* our communications channel */
-	blkif_t *blkif;
-
-	long int frontend_id;
-
-	/* watch back end for changes */
-	struct xenbus_watch backend_watch;
-
-	/* watch front end for changes */
-	struct xenbus_watch watch;
-	char *frontpath;
-};
-
-static int blkback_remove(struct xenbus_device *dev)
-{
-	struct backend_info *be = dev->data;
-
-	if (be->watch.node)
-		unregister_xenbus_watch(&be->watch);
-	unregister_xenbus_watch(&be->backend_watch);
-	if (be->blkif)
-		blkif_put(be->blkif);
-	kfree(be->frontpath);
-	kfree(be);
-	return 0;
-}
-
-/* Front end tells us frame. */
-static void frontend_changed(struct xenbus_watch *watch,
-			     const char **vec, unsigned int len)
-{
-	unsigned long ring_ref;
-	unsigned int evtchn;
-	int err;
-	struct backend_info *be
-		= container_of(watch, struct backend_info, watch);
-
-	/* If other end is gone, delete ourself. */
-	if (vec && !xenbus_exists(be->frontpath, "")) {
-		xenbus_rm(be->dev->nodename, "");
-		device_unregister(&be->dev->dev);
-		return;
-	}
-	if (be->blkif == NULL || be->blkif->status == CONNECTED)
-		return;
-
-	err = xenbus_gather(be->frontpath, "ring-ref", "%lu", &ring_ref,
-			    "event-channel", "%u", &evtchn, NULL);
-	if (err) {
-		xenbus_dev_error(be->dev, err,
-				 "reading %s/ring-ref and event-channel",
-				 be->frontpath);
-		return;
-	}
-
-	/* Map the shared frame, irq etc. */
-	err = blkif_map(be->blkif, ring_ref, evtchn);
-	if (err) {
-		xenbus_dev_error(be->dev, err, "mapping ring-ref %lu port %u",
-				 ring_ref, evtchn);
-		goto abort;
-	}
-
-	xenbus_dev_ok(be->dev);
-
-	return;
-
-abort:
-	xenbus_transaction_end(1);
-}
-
-/* 
-   Setup supplies physical device.  
-   We provide event channel and device details to front end.
-   Frontend supplies shared frame and event channel.
- */
-static void backend_changed(struct xenbus_watch *watch,
-			    const char **vec, unsigned int len)
-{
-	int err;
-	char *p;
-	long int handle;
-	struct backend_info *be
-		= container_of(watch, struct backend_info, backend_watch);
-	struct xenbus_device *dev = be->dev;
-
-	if (be->blkif == NULL) {
-		/* Front end dir is a number, which is used as the handle. */
-		p = strrchr(be->frontpath, '/') + 1;
-		handle = simple_strtoul(p, NULL, 0);
-
-		be->blkif = alloc_blkif(be->frontend_id);
-		if (IS_ERR(be->blkif)) {
-			err = PTR_ERR(be->blkif);
-			be->blkif = NULL;
-			xenbus_dev_error(dev, err, "creating block interface");
-			return;
-		}
-
-		/* Pass in NULL node to skip exist test. */
-		frontend_changed(&be->watch, NULL, 0);
-	}
-}
-
-static int blkback_probe(struct xenbus_device *dev,
-			 const struct xenbus_device_id *id)
-{
-	struct backend_info *be;
-	char *frontend;
-	int err;
-
-	be = kzalloc(sizeof(*be), GFP_KERNEL);
-	if (!be) {
-		xenbus_dev_error(dev, -ENOMEM, "allocating backend structure");
-		return -ENOMEM;
-	}
-
-	frontend = NULL;
-	err = xenbus_gather(dev->nodename,
-			    "frontend-id", "%li", &be->frontend_id,
-			    "frontend", NULL, &frontend,
-			    NULL);
-	if (XENBUS_EXIST_ERR(err))
-		goto free_be;
-	if (err < 0) {
-		xenbus_dev_error(dev, err,
-				 "reading %s/frontend or frontend-id",
-				 dev->nodename);
-		goto free_be;
-	}
-	if (strlen(frontend) == 0 || !xenbus_exists(frontend, "")) {
-		/* If we can't get a frontend path and a frontend-id,
-		 * then our bus-id is no longer valid and we need to
-		 * destroy the backend device.
-		 */
-		err = -ENOENT;
-		goto free_be;
-	}
-
-	be->dev = dev;
-	be->backend_watch.node = dev->nodename;
-	be->backend_watch.callback = backend_changed;
-	/* Registration implicitly fires backend_changed once */
-	err = register_xenbus_watch(&be->backend_watch);
-	if (err) {
-		be->backend_watch.node = NULL;
-		xenbus_dev_error(dev, err, "adding backend watch on %s",
-				 dev->nodename);
-		goto free_be;
-	}
-
-	be->frontpath = frontend;
-	be->watch.node = be->frontpath;
-	be->watch.callback = frontend_changed;
-	err = register_xenbus_watch(&be->watch);
-	if (err) {
-		be->watch.node = NULL;
-		xenbus_dev_error(dev, err,
-				 "adding frontend watch on %s",
-				 be->frontpath);
-		goto free_be;
-	}
-
-	dev->data = be;
-	return 0;
-
- free_be:
-	if (be->backend_watch.node)
-		unregister_xenbus_watch(&be->backend_watch);
-	kfree(frontend);
-	kfree(be);
-	return err;
-}
-
-static struct xenbus_device_id blkback_ids[] = {
-	{ "vbd" },
-	{ "" }
-};
-
-static struct xenbus_driver blkback = {
-	.name = "vbd",
-	.owner = THIS_MODULE,
-	.ids = blkback_ids,
-	.probe = blkback_probe,
-	.remove = blkback_remove,
-};
-
-void blkif_xenbus_init(void)
-{
-	xenbus_register_backend(&blkback);
-}

^ permalink raw reply	[relevance 3%]

* [PATCH][XENBUS] replace xenbus_transaction_t with an opaque transaction ID.
@ 2006-06-09  7:04 10% Chris Wright
  0 siblings, 0 replies; 200+ results
From: Chris Wright @ 2006-06-09  7:04 UTC (permalink / raw)
  To: xen-devel; +Cc: Jeremy Fitzhardinge

From: Jeremy Fitzhardinge <jeremy@xensource.com>

replace xenbus_transaction_t with an opaque transaction ID.
xenbus_transaction_t -> struct xenbus_transaction, which just contains
a single u32.  Also renamed XBT_NULL to XBT_NIL to emphasize that it
isn't a NULL pointer, but a NIL transaction ID.  Compile and boot tested.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
[chrisw: updated for xen-unstable from patchqueue]
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
 linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c         |    4 -
 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c      |    2 
 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c       |    8 +--
 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c    |    6 +-
 linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c     |    2 
 linux-2.6-xen-sparse/drivers/xen/core/reboot.c          |    4 -
 linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c       |   12 ++---
 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c    |    8 +--
 linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c       |   14 +++---
 linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c      |    6 +-
 linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c       |    6 +-
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c |    8 +--
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c    |    6 +-
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c  |   16 +++----
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c     |   36 ++++++++--------
 linux-2.6-xen-sparse/include/xen/xenbus.h               |   32 ++++++++------
 16 files changed, 87 insertions(+), 83 deletions(-)

--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
@@ -274,7 +274,7 @@ static int talk_to_backend(struct xenbus
 {
 	const char *message = NULL;
 	int err;
-	xenbus_transaction_t xbt;
+	struct xenbus_transaction xbt;
 
 	err = setup_tpmring(dev, tp);
 	if (err) {
@@ -369,7 +369,7 @@ static int tpmfront_probe(struct xenbus_
 	if (!tp)
 		return -ENOMEM;
 
-	err = xenbus_scanf(XBT_NULL, dev->nodename,
+	err = xenbus_scanf(XBT_NIL, dev->nodename,
 	                   "handle", "%i", &handle);
 	if (XENBUS_EXIST_ERR(err))
 		return err;
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
@@ -378,7 +378,7 @@ static void watch_target(struct xenbus_w
 	unsigned long long new_target;
 	int err;
 
-	err = xenbus_scanf(XBT_NULL, "memory", "target", "%llu", &new_target);
+	err = xenbus_scanf(XBT_NIL, "memory", "target", "%llu", &new_target);
 	if (err != 1) {
 		/* This is ok (for domain0 at least) - so just return */
 		return;
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
@@ -186,7 +186,7 @@ static void backend_changed(struct xenbu
 
 	DPRINTK("");
 
-	err = xenbus_scanf(XBT_NULL, dev->nodename, "physical-device", "%x:%x",
+	err = xenbus_scanf(XBT_NIL, dev->nodename, "physical-device", "%x:%x",
 			   &major, &minor);
 	if (XENBUS_EXIST_ERR(err)) {
 		/* Since this watch will fire once immediately after it is
@@ -208,7 +208,7 @@ static void backend_changed(struct xenbu
 		return;
 	}
 
-	be->mode = xenbus_read(XBT_NULL, dev->nodename, "mode", NULL);
+	be->mode = xenbus_read(XBT_NIL, dev->nodename, "mode", NULL);
 	if (IS_ERR(be->mode)) {
 		err = PTR_ERR(be->mode);
 		be->mode = NULL;
@@ -299,7 +299,7 @@ static void frontend_changed(struct xenb
  */
 static void connect(struct backend_info *be)
 {
-	xenbus_transaction_t xbt;
+	struct xenbus_transaction xbt;
 	int err;
 	struct xenbus_device *dev = be->dev;
 
@@ -364,7 +364,7 @@ static int connect_ring(struct backend_i
 
 	DPRINTK("%s", dev->otherend);
 
-	err = xenbus_gather(XBT_NULL, dev->otherend, "ring-ref", "%lu", &ring_ref,
+	err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%lu", &ring_ref,
 			    "event-channel", "%u", &evtchn, NULL);
 	if (err) {
 		xenbus_dev_fatal(dev, err,
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
@@ -83,7 +83,7 @@ static int blkfront_probe(struct xenbus_
 	struct blkfront_info *info;
 
 	/* FIXME: Use dynamic device id if this is not set. */
-	err = xenbus_scanf(XBT_NULL, dev->nodename,
+	err = xenbus_scanf(XBT_NIL, dev->nodename,
 			   "virtual-device", "%i", &vdevice);
 	if (err != 1) {
 		xenbus_dev_fatal(dev, err, "reading virtual-device");
@@ -148,7 +148,7 @@ static int talk_to_backend(struct xenbus
 			   struct blkfront_info *info)
 {
 	const char *message = NULL;
-	xenbus_transaction_t xbt;
+	struct xenbus_transaction xbt;
 	int err;
 
 	/* Create shared ring, alloc event channel. */
@@ -303,7 +303,7 @@ static void connect(struct blkfront_info
 
 	DPRINTK("blkfront.c:connect:%s.\n", info->xbdev->otherend);
 
-	err = xenbus_gather(XBT_NULL, info->xbdev->otherend,
+	err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
 			    "sectors", "%lu", &sectors,
 			    "info", "%u", &binfo,
 			    "sector-size", "%lu", &sector_size,
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c
@@ -34,7 +34,7 @@ static void vcpu_hotplug(unsigned int cp
 		return;
 
 	sprintf(dir, "cpu/%d", cpu);
-	err = xenbus_scanf(XBT_NULL, dir, "availability", "%s", state);
+	err = xenbus_scanf(XBT_NIL, dir, "availability", "%s", state);
 	if (err != 1) {
 		printk(KERN_ERR "XENBUS: Unable to read cpu state\n");
 		return;
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/core/reboot.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/core/reboot.c
@@ -250,7 +250,7 @@ static void shutdown_handler(struct xenb
 			     const char **vec, unsigned int len)
 {
 	char *str;
-	xenbus_transaction_t xbt;
+	struct xenbus_transaction xbt;
 	int err;
 
 	if (shutting_down != SHUTDOWN_INVALID)
@@ -298,7 +298,7 @@ static void sysrq_handler(struct xenbus_
 			  unsigned int len)
 {
 	char sysrq_key = '\0';
-	xenbus_transaction_t xbt;
+	struct xenbus_transaction xbt;
 	int err;
 
  again:
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
@@ -70,7 +70,7 @@ static int netback_probe(struct xenbus_d
 			 const struct xenbus_device_id *id)
 {
 	const char *message;
-	xenbus_transaction_t xbt;
+	struct xenbus_transaction xbt;
 	int err;
 	struct backend_info *be = kzalloc(sizeof(struct backend_info),
 					  GFP_KERNEL);
@@ -141,7 +141,7 @@ static int netback_uevent(struct xenbus_
 
 	DPRINTK("netback_uevent");
 
-	val = xenbus_read(XBT_NULL, xdev->nodename, "script", NULL);
+	val = xenbus_read(XBT_NIL, xdev->nodename, "script", NULL);
 	if (IS_ERR(val)) {
 		int err = PTR_ERR(val);
 		xenbus_dev_fatal(xdev, err, "reading script");
@@ -177,7 +177,7 @@ static void backend_changed(struct xenbu
 
 	DPRINTK("");
 
-	err = xenbus_scanf(XBT_NULL, dev->nodename, "handle", "%li", &handle);
+	err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%li", &handle);
 	if (XENBUS_EXIST_ERR(err)) {
 		/* Since this watch will fire once immediately after it is
 		   registered, we expect this.  Ignore it, and wait for the
@@ -268,7 +268,7 @@ static void xen_net_read_rate(struct xen
 	*bytes = ~0UL;
 	*usec = 0;
 
-	ratestr = xenbus_read(XBT_NULL, dev->nodename, "rate", NULL);
+	ratestr = xenbus_read(XBT_NIL, dev->nodename, "rate", NULL);
 	if (IS_ERR(ratestr))
 		return;
 
@@ -298,7 +298,7 @@ static int xen_net_read_mac(struct xenbu
 	char *s, *e, *macstr;
 	int i;
 
-	macstr = s = xenbus_read(XBT_NULL, dev->nodename, "mac", NULL);
+	macstr = s = xenbus_read(XBT_NIL, dev->nodename, "mac", NULL);
 	if (IS_ERR(macstr))
 		return PTR_ERR(macstr);
 
@@ -347,7 +347,7 @@ static int connect_rings(struct backend_
 
 	DPRINTK("");
 
-	err = xenbus_gather(XBT_NULL, dev->otherend,
+	err = xenbus_gather(XBT_NIL, dev->otherend,
 			    "tx-ring-ref", "%lu", &tx_ring_ref,
 			    "rx-ring-ref", "%lu", &rx_ring_ref,
 			    "event-channel", "%u", &evtchn, NULL);
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
@@ -193,7 +193,7 @@ static int __devinit netfront_probe(stru
 	struct netfront_info *info;
 	unsigned int handle;
 
-	err = xenbus_scanf(XBT_NULL, dev->nodename, "handle", "%u", &handle);
+	err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%u", &handle);
 	if (err != 1) {
 		xenbus_dev_fatal(dev, err, "reading handle");
 		return err;
@@ -243,7 +243,7 @@ static int xen_net_read_mac(struct xenbu
 	char *s, *e, *macstr;
 	int i;
 
-	macstr = s = xenbus_read(XBT_NULL, dev->nodename, "mac", NULL);
+	macstr = s = xenbus_read(XBT_NIL, dev->nodename, "mac", NULL);
 	if (IS_ERR(macstr))
 		return PTR_ERR(macstr);
 
@@ -265,7 +265,7 @@ static int talk_to_backend(struct xenbus
 			   struct netfront_info *info)
 {
 	const char *message;
-	xenbus_transaction_t xbt;
+	struct xenbus_transaction xbt;
 	int err;
 
 	err = xen_net_read_mac(dev, info->mac);
@@ -1057,7 +1057,7 @@ static int xennet_set_sg(struct net_devi
 		struct netfront_info *np = netdev_priv(dev);
 		int val;
 
-		if (xenbus_scanf(XBT_NULL, np->xbdev->otherend, "feature-sg",
+		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg",
 				 "%d", &val) < 0)
 			val = 0;
 		if (!val)
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c
@@ -125,7 +125,7 @@ static int pciback_attach(struct pciback
 
 	dev_dbg(&pdev->xdev->dev, "Reading frontend config\n");
 
-	err = xenbus_gather(XBT_NULL, pdev->xdev->otherend,
+	err = xenbus_gather(XBT_NIL, pdev->xdev->otherend,
 			    "pci-op-ref", "%u", &gnt_ref,
 			    "event-channel", "%u", &remote_evtchn,
 			    "magic", NULL, &magic, NULL);
@@ -200,7 +200,7 @@ static int pciback_publish_pci_root(stru
 
 	dev_dbg(&pdev->xdev->dev, "Publishing pci roots\n");
 
-	err = xenbus_scanf(XBT_NULL, pdev->xdev->nodename,
+	err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename,
 			   "root_num", "%d", &root_num);
 	if (err == 0 || err == -ENOENT)
 		root_num = 0;
@@ -215,7 +215,7 @@ static int pciback_publish_pci_root(stru
 			goto out;
 		}
 
-		err = xenbus_scanf(XBT_NULL, pdev->xdev->nodename,
+		err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename,
 				   str, "%x:%x", &d, &b);
 		if (err < 0)
 			goto out;
@@ -239,12 +239,12 @@ static int pciback_publish_pci_root(stru
 	dev_dbg(&pdev->xdev->dev, "writing root %d at %04x:%02x\n",
 		root_num, domain, bus);
 
-	err = xenbus_printf(XBT_NULL, pdev->xdev->nodename, str,
+	err = xenbus_printf(XBT_NIL, pdev->xdev->nodename, str,
 			    "%04x:%02x", domain, bus);
 	if (err)
 		goto out;
 
-	err = xenbus_printf(XBT_NULL, pdev->xdev->nodename,
+	err = xenbus_printf(XBT_NIL, pdev->xdev->nodename,
 			    "root_num", "%d", (root_num + 1));
 
       out:
@@ -306,7 +306,7 @@ static int pciback_setup_backend(struct 
 
 	dev_dbg(&pdev->xdev->dev, "getting be setup\n");
 
-	err = xenbus_scanf(XBT_NULL, pdev->xdev->nodename, "num_devs", "%d",
+	err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, "num_devs", "%d",
 			   &num_devs);
 	if (err != 1) {
 		if (err >= 0)
@@ -326,7 +326,7 @@ static int pciback_setup_backend(struct 
 			goto out;
 		}
 
-		err = xenbus_scanf(XBT_NULL, pdev->xdev->nodename, dev_str,
+		err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, dev_str,
 				   "%x:%x:%x.%x", &domain, &bus, &slot, &func);
 		if (err < 0) {
 			xenbus_dev_fatal(pdev->xdev, err,
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c
@@ -67,7 +67,7 @@ static void free_pdev(struct pcifront_de
 static int pcifront_publish_info(struct pcifront_device *pdev)
 {
 	int err = 0;
-	xenbus_transaction_t trans;
+	struct xenbus_transaction trans;
 
 	err = xenbus_grant_ring(pdev->xdev, virt_to_mfn(pdev->sh_info));
 	if (err < 0)
@@ -143,7 +143,7 @@ static int pcifront_try_connect(struct p
 		goto out;
 	}
 
-	err = xenbus_scanf(XBT_NULL, pdev->xdev->otherend,
+	err = xenbus_scanf(XBT_NIL, pdev->xdev->otherend,
 			   "root_num", "%d", &num_roots);
 	if (err == -ENOENT) {
 		xenbus_dev_error(pdev->xdev, err,
@@ -165,7 +165,7 @@ static int pcifront_try_connect(struct p
 			goto out;
 		}
 
-		err = xenbus_scanf(XBT_NULL, pdev->xdev->otherend, str,
+		err = xenbus_scanf(XBT_NIL, pdev->xdev->otherend, str,
 				   "%x:%x", &domain, &bus);
 		if (err != 2) {
 			if (err >= 0)
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
@@ -110,7 +110,7 @@ static void backend_changed(struct xenbu
 		= container_of(watch, struct backend_info, backend_watch);
 	struct xenbus_device *dev = be->dev;
 
-	err = xenbus_scanf(XBT_NULL, dev->nodename,
+	err = xenbus_scanf(XBT_NIL, dev->nodename,
 	                   "instance","%li", &instance);
 	if (XENBUS_EXIST_ERR(err)) {
 		return;
@@ -204,7 +204,7 @@ static void maybe_connect(struct backend
 
 static void connect(struct backend_info *be)
 {
-	xenbus_transaction_t xbt;
+	struct xenbus_transaction xbt;
 	int err;
 	struct xenbus_device *dev = be->dev;
 	unsigned long ready = 1;
@@ -245,7 +245,7 @@ static int connect_ring(struct backend_i
 	unsigned int evtchn;
 	int err;
 
-	err = xenbus_gather(XBT_NULL, dev->otherend,
+	err = xenbus_gather(XBT_NIL, dev->otherend,
 	                    "ring-ref", "%lu", &ring_ref,
 			    "event-channel", "%u", &evtchn, NULL);
 	if (err) {
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
@@ -106,12 +106,12 @@ int xenbus_switch_state(struct xenbus_de
 	if (state == dev->state)
 		return 0;
 
-	err = xenbus_scanf(XBT_NULL, dev->nodename, "state", "%d",
+	err = xenbus_scanf(XBT_NIL, dev->nodename, "state", "%d",
 			   &current_state);
 	if (err != 1)
 		return 0;
 
-	err = xenbus_printf(XBT_NULL, dev->nodename, "state", "%d", state);
+	err = xenbus_printf(XBT_NIL, dev->nodename, "state", "%d", state);
 	if (err) {
 		if (state != XenbusStateClosing) /* Avoid looping */
 			xenbus_dev_fatal(dev, err, "writing new state");
@@ -162,7 +162,7 @@ void _dev_error(struct xenbus_device *de
 		goto fail;
 	}
 
-	if (xenbus_write(XBT_NULL, path_buffer, "error", printf_buffer) != 0) {
+	if (xenbus_write(XBT_NIL, path_buffer, "error", printf_buffer) != 0) {
 		printk("xenbus: failed to write error node for %s (%s)\n",
 		       dev->nodename, printf_buffer);
 		goto fail;
@@ -272,7 +272,7 @@ int xenbus_free_evtchn(struct xenbus_dev
 enum xenbus_state xenbus_read_driver_state(const char *path)
 {
 	enum xenbus_state result;
-	int err = xenbus_gather(XBT_NULL, path, "state", "%d", &result, NULL);
+	int err = xenbus_gather(XBT_NIL, path, "state", "%d", &result, NULL);
 	if (err)
 		result = XenbusStateClosed;
 
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c
@@ -51,7 +51,7 @@
 
 struct xenbus_dev_transaction {
 	struct list_head list;
-	xenbus_transaction_t handle;
+	struct xenbus_transaction handle;
 };
 
 struct xenbus_dev_data {
@@ -154,11 +154,11 @@ static ssize_t xenbus_dev_write(struct f
 		}
 
 		if (msg_type == XS_TRANSACTION_START) {
-			trans->handle = simple_strtoul(reply, NULL, 0);
+			trans->handle.id = simple_strtoul(reply, NULL, 0);
 			list_add(&trans->list, &u->transactions);
 		} else if (msg_type == XS_TRANSACTION_END) {
 			list_for_each_entry(trans, &u->transactions, list)
-				if (trans->handle == u->u.msg.tx_id)
+				if (trans->handle.id == u->u.msg.tx_id)
 					break;
 			BUG_ON(&trans->list == &u->transactions);
 			list_del(&trans->list);
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
@@ -128,7 +128,7 @@ static void free_otherend_watch(struct x
 static int read_otherend_details(struct xenbus_device *xendev,
 				 char *id_node, char *path_node)
 {
-	int err = xenbus_gather(XBT_NULL, xendev->nodename,
+	int err = xenbus_gather(XBT_NIL, xendev->nodename,
 				id_node, "%i", &xendev->otherend_id,
 				path_node, NULL, &xendev->otherend,
 				NULL);
@@ -139,7 +139,7 @@ static int read_otherend_details(struct 
 		return err;
 	}
 	if (strlen(xendev->otherend) == 0 ||
-	    !xenbus_exists(XBT_NULL, xendev->otherend, "")) {
+	    !xenbus_exists(XBT_NIL, xendev->otherend, "")) {
 		xenbus_dev_fatal(xendev, -ENOENT, "missing other end from %s",
 				 xendev->nodename);
 		free_otherend_details(xendev);
@@ -195,14 +195,14 @@ static int backend_bus_id(char bus_id[BU
 
 	devid = strrchr(nodename, '/') + 1;
 
-	err = xenbus_gather(XBT_NULL, nodename, "frontend-id", "%i", &domid,
+	err = xenbus_gather(XBT_NIL, nodename, "frontend-id", "%i", &domid,
 			    "frontend", NULL, &frontend,
 			    NULL);
 	if (err)
 		return err;
 	if (strlen(frontend) == 0)
 		err = -ERANGE;
-	if (!err && !xenbus_exists(XBT_NULL, frontend, ""))
+	if (!err && !xenbus_exists(XBT_NIL, frontend, ""))
 		err = -ENOENT;
 
 	kfree(frontend);
@@ -634,7 +634,7 @@ static int xenbus_probe_backend(const ch
 	if (!nodename)
 		return -ENOMEM;
 
-	dir = xenbus_directory(XBT_NULL, nodename, "", &dir_n);
+	dir = xenbus_directory(XBT_NIL, nodename, "", &dir_n);
 	if (IS_ERR(dir)) {
 		kfree(nodename);
 		return PTR_ERR(dir);
@@ -657,7 +657,7 @@ static int xenbus_probe_device_type(stru
 	unsigned int dir_n = 0;
 	int i;
 
-	dir = xenbus_directory(XBT_NULL, bus->root, type, &dir_n);
+	dir = xenbus_directory(XBT_NIL, bus->root, type, &dir_n);
 	if (IS_ERR(dir))
 		return PTR_ERR(dir);
 
@@ -676,7 +676,7 @@ static int xenbus_probe_devices(struct x
 	char **dir;
 	unsigned int i, dir_n;
 
-	dir = xenbus_directory(XBT_NULL, bus->root, "", &dir_n);
+	dir = xenbus_directory(XBT_NIL, bus->root, "", &dir_n);
 	if (IS_ERR(dir))
 		return PTR_ERR(dir);
 
@@ -722,7 +722,7 @@ static void dev_changed(const char *node
 	if (char_count(node, '/') < 2)
  		return;
 
-	exists = xenbus_exists(XBT_NULL, node, "");
+	exists = xenbus_exists(XBT_NIL, node, "");
 	if (!exists) {
 		xenbus_cleanup_devices(node, &bus->bus);
 		return;
--- xen-unstable.orig/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
+++ xen-unstable/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
@@ -192,7 +192,7 @@ void *xenbus_dev_request_and_reply(struc
 }
 
 /* Send message to xs, get kmalloc'ed reply.  ERR_PTR() on error. */
-static void *xs_talkv(xenbus_transaction_t t,
+static void *xs_talkv(struct xenbus_transaction t,
 		      enum xsd_sockmsg_type type,
 		      const struct kvec *iovec,
 		      unsigned int num_vecs,
@@ -203,7 +203,7 @@ static void *xs_talkv(xenbus_transaction
 	unsigned int i;
 	int err;
 
-	msg.tx_id = t;
+	msg.tx_id = t.id;
 	msg.req_id = 0;
 	msg.type = type;
 	msg.len = 0;
@@ -251,7 +251,7 @@ static void *xs_talkv(xenbus_transaction
 }
 
 /* Simplified version of xs_talkv: single message. */
-static void *xs_single(xenbus_transaction_t t,
+static void *xs_single(struct xenbus_transaction t,
 		       enum xsd_sockmsg_type type,
 		       const char *string,
 		       unsigned int *len)
@@ -318,7 +318,7 @@ static char **split(char *strings, unsig
 	return ret;
 }
 
-char **xenbus_directory(xenbus_transaction_t t,
+char **xenbus_directory(struct xenbus_transaction t,
 			const char *dir, const char *node, unsigned int *num)
 {
 	char *strings, *path;
@@ -338,7 +338,7 @@ char **xenbus_directory(xenbus_transacti
 EXPORT_SYMBOL_GPL(xenbus_directory);
 
 /* Check if a path exists. Return 1 if it does. */
-int xenbus_exists(xenbus_transaction_t t,
+int xenbus_exists(struct xenbus_transaction t,
 		  const char *dir, const char *node)
 {
 	char **d;
@@ -356,7 +356,7 @@ EXPORT_SYMBOL_GPL(xenbus_exists);
  * Returns a kmalloced value: call free() on it after use.
  * len indicates length in bytes.
  */
-void *xenbus_read(xenbus_transaction_t t,
+void *xenbus_read(struct xenbus_transaction t,
 		  const char *dir, const char *node, unsigned int *len)
 {
 	char *path;
@@ -375,7 +375,7 @@ EXPORT_SYMBOL_GPL(xenbus_read);
 /* Write the value of a single file.
  * Returns -err on failure.
  */
-int xenbus_write(xenbus_transaction_t t,
+int xenbus_write(struct xenbus_transaction t,
 		 const char *dir, const char *node, const char *string)
 {
 	const char *path;
@@ -398,7 +398,7 @@ int xenbus_write(xenbus_transaction_t t,
 EXPORT_SYMBOL_GPL(xenbus_write);
 
 /* Create a new directory. */
-int xenbus_mkdir(xenbus_transaction_t t,
+int xenbus_mkdir(struct xenbus_transaction t,
 		 const char *dir, const char *node)
 {
 	char *path;
@@ -415,7 +415,7 @@ int xenbus_mkdir(xenbus_transaction_t t,
 EXPORT_SYMBOL_GPL(xenbus_mkdir);
 
 /* Destroy a file or directory (directories must be empty). */
-int xenbus_rm(xenbus_transaction_t t, const char *dir, const char *node)
+int xenbus_rm(struct xenbus_transaction t, const char *dir, const char *node)
 {
 	char *path;
 	int ret;
@@ -433,19 +433,19 @@ EXPORT_SYMBOL_GPL(xenbus_rm);
 /* Start a transaction: changes by others will not be seen during this
  * transaction, and changes will not be visible to others until end.
  */
-int xenbus_transaction_start(xenbus_transaction_t *t)
+int xenbus_transaction_start(struct xenbus_transaction *t)
 {
 	char *id_str;
 
 	down_read(&xs_state.suspend_mutex);
 
-	id_str = xs_single(XBT_NULL, XS_TRANSACTION_START, "", NULL);
+	id_str = xs_single(XBT_NIL, XS_TRANSACTION_START, "", NULL);
 	if (IS_ERR(id_str)) {
 		up_read(&xs_state.suspend_mutex);
 		return PTR_ERR(id_str);
 	}
 
-	*t = simple_strtoul(id_str, NULL, 0);
+	t->id = simple_strtoul(id_str, NULL, 0);
 	kfree(id_str);
 	return 0;
 }
@@ -454,7 +454,7 @@ EXPORT_SYMBOL_GPL(xenbus_transaction_sta
 /* End a transaction.
  * If abandon is true, transaction is discarded instead of committed.
  */
-int xenbus_transaction_end(xenbus_transaction_t t, int abort)
+int xenbus_transaction_end(struct xenbus_transaction t, int abort)
 {
 	char abortstr[2];
 	int err;
@@ -473,7 +473,7 @@ int xenbus_transaction_end(xenbus_transa
 EXPORT_SYMBOL_GPL(xenbus_transaction_end);
 
 /* Single read and scanf: returns -errno or num scanned. */
-int xenbus_scanf(xenbus_transaction_t t,
+int xenbus_scanf(struct xenbus_transaction t,
 		 const char *dir, const char *node, const char *fmt, ...)
 {
 	va_list ap;
@@ -496,7 +496,7 @@ int xenbus_scanf(xenbus_transaction_t t,
 EXPORT_SYMBOL_GPL(xenbus_scanf);
 
 /* Single printf and write: returns -errno or 0. */
-int xenbus_printf(xenbus_transaction_t t,
+int xenbus_printf(struct xenbus_transaction t,
 		  const char *dir, const char *node, const char *fmt, ...)
 {
 	va_list ap;
@@ -522,7 +522,7 @@ int xenbus_printf(xenbus_transaction_t t
 EXPORT_SYMBOL_GPL(xenbus_printf);
 
 /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
-int xenbus_gather(xenbus_transaction_t t, const char *dir, ...)
+int xenbus_gather(struct xenbus_transaction t, const char *dir, ...)
 {
 	va_list ap;
 	const char *name;
@@ -560,7 +560,7 @@ static int xs_watch(const char *path, co
 	iov[1].iov_base = (void *)token;
 	iov[1].iov_len = strlen(token) + 1;
 
-	return xs_error(xs_talkv(XBT_NULL, XS_WATCH, iov,
+	return xs_error(xs_talkv(XBT_NIL, XS_WATCH, iov,
 				 ARRAY_SIZE(iov), NULL));
 }
 
@@ -573,7 +573,7 @@ static int xs_unwatch(const char *path, 
 	iov[1].iov_base = (char *)token;
 	iov[1].iov_len = strlen(token) + 1;
 
-	return xs_error(xs_talkv(XBT_NULL, XS_UNWATCH, iov,
+	return xs_error(xs_talkv(XBT_NIL, XS_UNWATCH, iov,
 				 ARRAY_SIZE(iov), NULL));
 }
 
--- xen-unstable.orig/linux-2.6-xen-sparse/include/xen/xenbus.h
+++ xen-unstable/linux-2.6-xen-sparse/include/xen/xenbus.h
@@ -42,8 +42,6 @@
 #include <xen/interface/io/xenbus.h>
 #include <xen/interface/io/xs_wire.h>
 
-#define XBT_NULL 0
-
 /* Register callback to watch this node. */
 struct xenbus_watch
 {
@@ -115,35 +113,41 @@ int xenbus_register_frontend(struct xenb
 int xenbus_register_backend(struct xenbus_driver *drv);
 void xenbus_unregister_driver(struct xenbus_driver *drv);
 
-typedef u32 xenbus_transaction_t;
+struct xenbus_transaction
+{
+	u32 id;
+};
+
+/* Nil transaction ID. */
+#define XBT_NIL ((struct xenbus_transaction) { 0 })
 
-char **xenbus_directory(xenbus_transaction_t t,
+char **xenbus_directory(struct xenbus_transaction t,
 			const char *dir, const char *node, unsigned int *num);
-void *xenbus_read(xenbus_transaction_t t,
+void *xenbus_read(struct xenbus_transaction t,
 		  const char *dir, const char *node, unsigned int *len);
-int xenbus_write(xenbus_transaction_t t,
+int xenbus_write(struct xenbus_transaction t,
 		 const char *dir, const char *node, const char *string);
-int xenbus_mkdir(xenbus_transaction_t t,
+int xenbus_mkdir(struct xenbus_transaction t,
 		 const char *dir, const char *node);
-int xenbus_exists(xenbus_transaction_t t,
+int xenbus_exists(struct xenbus_transaction t,
 		  const char *dir, const char *node);
-int xenbus_rm(xenbus_transaction_t t, const char *dir, const char *node);
-int xenbus_transaction_start(xenbus_transaction_t *t);
-int xenbus_transaction_end(xenbus_transaction_t t, int abort);
+int xenbus_rm(struct xenbus_transaction t, const char *dir, const char *node);
+int xenbus_transaction_start(struct xenbus_transaction *t);
+int xenbus_transaction_end(struct xenbus_transaction t, int abort);
 
 /* Single read and scanf: returns -errno or num scanned if > 0. */
-int xenbus_scanf(xenbus_transaction_t t,
+int xenbus_scanf(struct xenbus_transaction t,
 		 const char *dir, const char *node, const char *fmt, ...)
 	__attribute__((format(scanf, 4, 5)));
 
 /* Single printf and write: returns -errno or 0. */
-int xenbus_printf(xenbus_transaction_t t,
+int xenbus_printf(struct xenbus_transaction t,
 		  const char *dir, const char *node, const char *fmt, ...)
 	__attribute__((format(printf, 4, 5)));
 
 /* Generic read function: NULL-terminated triples of name,
  * sprintf-style type string, and pointer. Returns 0 or errno.*/
-int xenbus_gather(xenbus_transaction_t t, const char *dir, ...);
+int xenbus_gather(struct xenbus_transaction t, const char *dir, ...);
 
 /* notifer routines for when the xenstore comes up */
 int register_xenstore_notifier(struct notifier_block *nb);

^ permalink raw reply	[relevance 10%]

* Re: [Xen-changelog] [xen-unstable] [LINUX][XENBUS] replace xenbus_transaction_t with an opaque transaction ID.
       [not found]     <E1FokBa-0003Mv-TD@xenbits.xensource.com>
@ 2006-06-09 19:03  0% ` Anthony Liguori
  0 siblings, 0 replies; 200+ results
From: Anthony Liguori @ 2006-06-09 19:03 UTC (permalink / raw)
  To: xen-devel

Xen patchbot-unstable wrote:
> # HG changeset patch
> # User kaf24@firebug.cl.cam.ac.uk
> # Node ID 49f65e2b0f1c5b96326c764808e819af85e883d7
> # Parent  7cf4cbe7a3be88e7bde56c4093428749bf5320d7
> [LINUX][XENBUS] replace xenbus_transaction_t with an opaque transaction ID.
> xenbus_transaction_t -> struct xenbus_transaction, which just contains
> a single u32.  Also renamed XBT_NULL to XBT_NIL to emphasize that it
> isn't a NULL pointer, but a NIL transaction ID.  Compile and boot tested.
>
> Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
> [chrisw: updated for xen-unstable from patchqueue]
> Signed-off-by: Chris Wright <chrisw@sous-sol.org>
>   

Can't we just go back to the original semantics and s/XBT_NIL/NULL/g.  
The whole reason XBT_NULL was introduced was that it switched to an 
integer and NULL used to represent no transaction.

Regards,

Anthony Liguori

> ---
>  linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c         |    4 -
>  linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c      |    2 
>  linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c       |    8 +--
>  linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c    |    6 +-
>  linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c     |    2 
>  linux-2.6-xen-sparse/drivers/xen/core/reboot.c          |    4 -
>  linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c       |   12 ++---
>  linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c    |    8 +--
>  linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c       |   14 +++---
>  linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c      |    6 +-
>  linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c       |    6 +-
>  linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c |    8 +--
>  linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c    |    6 +-
>  linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c  |   16 +++----
>  linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c     |   36 ++++++++--------
>  linux-2.6-xen-sparse/include/xen/xenbus.h               |   34 ++++++++-------
>  16 files changed, 88 insertions(+), 84 deletions(-)
>
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
> --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -274,7 +274,7 @@ static int talk_to_backend(struct xenbus
>  {
>  	const char *message = NULL;
>  	int err;
> -	xenbus_transaction_t xbt;
> +	struct xenbus_transaction xbt;
>  
>  	err = setup_tpmring(dev, tp);
>  	if (err) {
> @@ -369,7 +369,7 @@ static int tpmfront_probe(struct xenbus_
>  	if (!tp)
>  		return -ENOMEM;
>  
> -	err = xenbus_scanf(XBT_NULL, dev->nodename,
> +	err = xenbus_scanf(XBT_NIL, dev->nodename,
>  	                   "handle", "%i", &handle);
>  	if (XENBUS_EXIST_ERR(err))
>  		return err;
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
> --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -378,7 +378,7 @@ static void watch_target(struct xenbus_w
>  	unsigned long long new_target;
>  	int err;
>  
> -	err = xenbus_scanf(XBT_NULL, "memory", "target", "%llu", &new_target);
> +	err = xenbus_scanf(XBT_NIL, "memory", "target", "%llu", &new_target);
>  	if (err != 1) {
>  		/* This is ok (for domain0 at least) - so just return */
>  		return;
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
> --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -186,7 +186,7 @@ static void backend_changed(struct xenbu
>  
>  	DPRINTK("");
>  
> -	err = xenbus_scanf(XBT_NULL, dev->nodename, "physical-device", "%x:%x",
> +	err = xenbus_scanf(XBT_NIL, dev->nodename, "physical-device", "%x:%x",
>  			   &major, &minor);
>  	if (XENBUS_EXIST_ERR(err)) {
>  		/* Since this watch will fire once immediately after it is
> @@ -208,7 +208,7 @@ static void backend_changed(struct xenbu
>  		return;
>  	}
>  
> -	be->mode = xenbus_read(XBT_NULL, dev->nodename, "mode", NULL);
> +	be->mode = xenbus_read(XBT_NIL, dev->nodename, "mode", NULL);
>  	if (IS_ERR(be->mode)) {
>  		err = PTR_ERR(be->mode);
>  		be->mode = NULL;
> @@ -299,7 +299,7 @@ static void frontend_changed(struct xenb
>   */
>  static void connect(struct backend_info *be)
>  {
> -	xenbus_transaction_t xbt;
> +	struct xenbus_transaction xbt;
>  	int err;
>  	struct xenbus_device *dev = be->dev;
>  
> @@ -364,7 +364,7 @@ static int connect_ring(struct backend_i
>  
>  	DPRINTK("%s", dev->otherend);
>  
> -	err = xenbus_gather(XBT_NULL, dev->otherend, "ring-ref", "%lu", &ring_ref,
> +	err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%lu", &ring_ref,
>  			    "event-channel", "%u", &evtchn, NULL);
>  	if (err) {
>  		xenbus_dev_fatal(dev, err,
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
> --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -83,7 +83,7 @@ static int blkfront_probe(struct xenbus_
>  	struct blkfront_info *info;
>  
>  	/* FIXME: Use dynamic device id if this is not set. */
> -	err = xenbus_scanf(XBT_NULL, dev->nodename,
> +	err = xenbus_scanf(XBT_NIL, dev->nodename,
>  			   "virtual-device", "%i", &vdevice);
>  	if (err != 1) {
>  		xenbus_dev_fatal(dev, err, "reading virtual-device");
> @@ -148,7 +148,7 @@ static int talk_to_backend(struct xenbus
>  			   struct blkfront_info *info)
>  {
>  	const char *message = NULL;
> -	xenbus_transaction_t xbt;
> +	struct xenbus_transaction xbt;
>  	int err;
>  
>  	/* Create shared ring, alloc event channel. */
> @@ -303,7 +303,7 @@ static void connect(struct blkfront_info
>  
>  	DPRINTK("blkfront.c:connect:%s.\n", info->xbdev->otherend);
>  
> -	err = xenbus_gather(XBT_NULL, info->xbdev->otherend,
> +	err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
>  			    "sectors", "%lu", &sectors,
>  			    "info", "%u", &binfo,
>  			    "sector-size", "%lu", &sector_size,
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c
> --- a/linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -34,7 +34,7 @@ static void vcpu_hotplug(unsigned int cp
>  		return;
>  
>  	sprintf(dir, "cpu/%d", cpu);
> -	err = xenbus_scanf(XBT_NULL, dir, "availability", "%s", state);
> +	err = xenbus_scanf(XBT_NIL, dir, "availability", "%s", state);
>  	if (err != 1) {
>  		printk(KERN_ERR "XENBUS: Unable to read cpu state\n");
>  		return;
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/core/reboot.c
> --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -250,7 +250,7 @@ static void shutdown_handler(struct xenb
>  			     const char **vec, unsigned int len)
>  {
>  	char *str;
> -	xenbus_transaction_t xbt;
> +	struct xenbus_transaction xbt;
>  	int err;
>  
>  	if (shutting_down != SHUTDOWN_INVALID)
> @@ -298,7 +298,7 @@ static void sysrq_handler(struct xenbus_
>  			  unsigned int len)
>  {
>  	char sysrq_key = '\0';
> -	xenbus_transaction_t xbt;
> +	struct xenbus_transaction xbt;
>  	int err;
>  
>   again:
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
> --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -70,7 +70,7 @@ static int netback_probe(struct xenbus_d
>  			 const struct xenbus_device_id *id)
>  {
>  	const char *message;
> -	xenbus_transaction_t xbt;
> +	struct xenbus_transaction xbt;
>  	int err;
>  	struct backend_info *be = kzalloc(sizeof(struct backend_info),
>  					  GFP_KERNEL);
> @@ -141,7 +141,7 @@ static int netback_uevent(struct xenbus_
>  
>  	DPRINTK("netback_uevent");
>  
> -	val = xenbus_read(XBT_NULL, xdev->nodename, "script", NULL);
> +	val = xenbus_read(XBT_NIL, xdev->nodename, "script", NULL);
>  	if (IS_ERR(val)) {
>  		int err = PTR_ERR(val);
>  		xenbus_dev_fatal(xdev, err, "reading script");
> @@ -177,7 +177,7 @@ static void backend_changed(struct xenbu
>  
>  	DPRINTK("");
>  
> -	err = xenbus_scanf(XBT_NULL, dev->nodename, "handle", "%li", &handle);
> +	err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%li", &handle);
>  	if (XENBUS_EXIST_ERR(err)) {
>  		/* Since this watch will fire once immediately after it is
>  		   registered, we expect this.  Ignore it, and wait for the
> @@ -268,7 +268,7 @@ static void xen_net_read_rate(struct xen
>  	*bytes = ~0UL;
>  	*usec = 0;
>  
> -	ratestr = xenbus_read(XBT_NULL, dev->nodename, "rate", NULL);
> +	ratestr = xenbus_read(XBT_NIL, dev->nodename, "rate", NULL);
>  	if (IS_ERR(ratestr))
>  		return;
>  
> @@ -298,7 +298,7 @@ static int xen_net_read_mac(struct xenbu
>  	char *s, *e, *macstr;
>  	int i;
>  
> -	macstr = s = xenbus_read(XBT_NULL, dev->nodename, "mac", NULL);
> +	macstr = s = xenbus_read(XBT_NIL, dev->nodename, "mac", NULL);
>  	if (IS_ERR(macstr))
>  		return PTR_ERR(macstr);
>  
> @@ -347,7 +347,7 @@ static int connect_rings(struct backend_
>  
>  	DPRINTK("");
>  
> -	err = xenbus_gather(XBT_NULL, dev->otherend,
> +	err = xenbus_gather(XBT_NIL, dev->otherend,
>  			    "tx-ring-ref", "%lu", &tx_ring_ref,
>  			    "rx-ring-ref", "%lu", &rx_ring_ref,
>  			    "event-channel", "%u", &evtchn, NULL);
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
> --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -193,7 +193,7 @@ static int __devinit netfront_probe(stru
>  	struct netfront_info *info;
>  	unsigned int handle;
>  
> -	err = xenbus_scanf(XBT_NULL, dev->nodename, "handle", "%u", &handle);
> +	err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%u", &handle);
>  	if (err != 1) {
>  		xenbus_dev_fatal(dev, err, "reading handle");
>  		return err;
> @@ -243,7 +243,7 @@ static int xen_net_read_mac(struct xenbu
>  	char *s, *e, *macstr;
>  	int i;
>  
> -	macstr = s = xenbus_read(XBT_NULL, dev->nodename, "mac", NULL);
> +	macstr = s = xenbus_read(XBT_NIL, dev->nodename, "mac", NULL);
>  	if (IS_ERR(macstr))
>  		return PTR_ERR(macstr);
>  
> @@ -265,7 +265,7 @@ static int talk_to_backend(struct xenbus
>  			   struct netfront_info *info)
>  {
>  	const char *message;
> -	xenbus_transaction_t xbt;
> +	struct xenbus_transaction xbt;
>  	int err;
>  
>  	err = xen_net_read_mac(dev, info->mac);
> @@ -1057,7 +1057,7 @@ static int xennet_set_sg(struct net_devi
>  		struct netfront_info *np = netdev_priv(dev);
>  		int val;
>  
> -		if (xenbus_scanf(XBT_NULL, np->xbdev->otherend, "feature-sg",
> +		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg",
>  				 "%d", &val) < 0)
>  			val = 0;
>  		if (!val)
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c
> --- a/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -125,7 +125,7 @@ static int pciback_attach(struct pciback
>  
>  	dev_dbg(&pdev->xdev->dev, "Reading frontend config\n");
>  
> -	err = xenbus_gather(XBT_NULL, pdev->xdev->otherend,
> +	err = xenbus_gather(XBT_NIL, pdev->xdev->otherend,
>  			    "pci-op-ref", "%u", &gnt_ref,
>  			    "event-channel", "%u", &remote_evtchn,
>  			    "magic", NULL, &magic, NULL);
> @@ -200,7 +200,7 @@ static int pciback_publish_pci_root(stru
>  
>  	dev_dbg(&pdev->xdev->dev, "Publishing pci roots\n");
>  
> -	err = xenbus_scanf(XBT_NULL, pdev->xdev->nodename,
> +	err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename,
>  			   "root_num", "%d", &root_num);
>  	if (err == 0 || err == -ENOENT)
>  		root_num = 0;
> @@ -215,7 +215,7 @@ static int pciback_publish_pci_root(stru
>  			goto out;
>  		}
>  
> -		err = xenbus_scanf(XBT_NULL, pdev->xdev->nodename,
> +		err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename,
>  				   str, "%x:%x", &d, &b);
>  		if (err < 0)
>  			goto out;
> @@ -239,12 +239,12 @@ static int pciback_publish_pci_root(stru
>  	dev_dbg(&pdev->xdev->dev, "writing root %d at %04x:%02x\n",
>  		root_num, domain, bus);
>  
> -	err = xenbus_printf(XBT_NULL, pdev->xdev->nodename, str,
> +	err = xenbus_printf(XBT_NIL, pdev->xdev->nodename, str,
>  			    "%04x:%02x", domain, bus);
>  	if (err)
>  		goto out;
>  
> -	err = xenbus_printf(XBT_NULL, pdev->xdev->nodename,
> +	err = xenbus_printf(XBT_NIL, pdev->xdev->nodename,
>  			    "root_num", "%d", (root_num + 1));
>  
>        out:
> @@ -306,7 +306,7 @@ static int pciback_setup_backend(struct 
>  
>  	dev_dbg(&pdev->xdev->dev, "getting be setup\n");
>  
> -	err = xenbus_scanf(XBT_NULL, pdev->xdev->nodename, "num_devs", "%d",
> +	err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, "num_devs", "%d",
>  			   &num_devs);
>  	if (err != 1) {
>  		if (err >= 0)
> @@ -326,7 +326,7 @@ static int pciback_setup_backend(struct 
>  			goto out;
>  		}
>  
> -		err = xenbus_scanf(XBT_NULL, pdev->xdev->nodename, dev_str,
> +		err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, dev_str,
>  				   "%x:%x:%x.%x", &domain, &bus, &slot, &func);
>  		if (err < 0) {
>  			xenbus_dev_fatal(pdev->xdev, err,
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c
> --- a/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -67,7 +67,7 @@ static int pcifront_publish_info(struct 
>  static int pcifront_publish_info(struct pcifront_device *pdev)
>  {
>  	int err = 0;
> -	xenbus_transaction_t trans;
> +	struct xenbus_transaction trans;
>  
>  	err = xenbus_grant_ring(pdev->xdev, virt_to_mfn(pdev->sh_info));
>  	if (err < 0)
> @@ -143,7 +143,7 @@ static int pcifront_try_connect(struct p
>  		goto out;
>  	}
>  
> -	err = xenbus_scanf(XBT_NULL, pdev->xdev->otherend,
> +	err = xenbus_scanf(XBT_NIL, pdev->xdev->otherend,
>  			   "root_num", "%d", &num_roots);
>  	if (err == -ENOENT) {
>  		xenbus_dev_error(pdev->xdev, err,
> @@ -165,7 +165,7 @@ static int pcifront_try_connect(struct p
>  			goto out;
>  		}
>  
> -		err = xenbus_scanf(XBT_NULL, pdev->xdev->otherend, str,
> +		err = xenbus_scanf(XBT_NIL, pdev->xdev->otherend, str,
>  				   "%x:%x", &domain, &bus);
>  		if (err != 2) {
>  			if (err >= 0)
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
> --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -110,7 +110,7 @@ static void backend_changed(struct xenbu
>  		= container_of(watch, struct backend_info, backend_watch);
>  	struct xenbus_device *dev = be->dev;
>  
> -	err = xenbus_scanf(XBT_NULL, dev->nodename,
> +	err = xenbus_scanf(XBT_NIL, dev->nodename,
>  	                   "instance","%li", &instance);
>  	if (XENBUS_EXIST_ERR(err)) {
>  		return;
> @@ -204,7 +204,7 @@ static void maybe_connect(struct backend
>  
>  static void connect(struct backend_info *be)
>  {
> -	xenbus_transaction_t xbt;
> +	struct xenbus_transaction xbt;
>  	int err;
>  	struct xenbus_device *dev = be->dev;
>  	unsigned long ready = 1;
> @@ -245,7 +245,7 @@ static int connect_ring(struct backend_i
>  	unsigned int evtchn;
>  	int err;
>  
> -	err = xenbus_gather(XBT_NULL, dev->otherend,
> +	err = xenbus_gather(XBT_NIL, dev->otherend,
>  	                    "ring-ref", "%lu", &ring_ref,
>  			    "event-channel", "%u", &evtchn, NULL);
>  	if (err) {
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
> --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -106,12 +106,12 @@ int xenbus_switch_state(struct xenbus_de
>  	if (state == dev->state)
>  		return 0;
>  
> -	err = xenbus_scanf(XBT_NULL, dev->nodename, "state", "%d",
> +	err = xenbus_scanf(XBT_NIL, dev->nodename, "state", "%d",
>  			   &current_state);
>  	if (err != 1)
>  		return 0;
>  
> -	err = xenbus_printf(XBT_NULL, dev->nodename, "state", "%d", state);
> +	err = xenbus_printf(XBT_NIL, dev->nodename, "state", "%d", state);
>  	if (err) {
>  		if (state != XenbusStateClosing) /* Avoid looping */
>  			xenbus_dev_fatal(dev, err, "writing new state");
> @@ -162,7 +162,7 @@ void _dev_error(struct xenbus_device *de
>  		goto fail;
>  	}
>  
> -	if (xenbus_write(XBT_NULL, path_buffer, "error", printf_buffer) != 0) {
> +	if (xenbus_write(XBT_NIL, path_buffer, "error", printf_buffer) != 0) {
>  		printk("xenbus: failed to write error node for %s (%s)\n",
>  		       dev->nodename, printf_buffer);
>  		goto fail;
> @@ -272,7 +272,7 @@ enum xenbus_state xenbus_read_driver_sta
>  enum xenbus_state xenbus_read_driver_state(const char *path)
>  {
>  	enum xenbus_state result;
> -	int err = xenbus_gather(XBT_NULL, path, "state", "%d", &result, NULL);
> +	int err = xenbus_gather(XBT_NIL, path, "state", "%d", &result, NULL);
>  	if (err)
>  		result = XenbusStateClosed;
>  
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c
> --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -51,7 +51,7 @@
>  
>  struct xenbus_dev_transaction {
>  	struct list_head list;
> -	xenbus_transaction_t handle;
> +	struct xenbus_transaction handle;
>  };
>  
>  struct xenbus_dev_data {
> @@ -154,11 +154,11 @@ static ssize_t xenbus_dev_write(struct f
>  		}
>  
>  		if (msg_type == XS_TRANSACTION_START) {
> -			trans->handle = simple_strtoul(reply, NULL, 0);
> +			trans->handle.id = simple_strtoul(reply, NULL, 0);
>  			list_add(&trans->list, &u->transactions);
>  		} else if (msg_type == XS_TRANSACTION_END) {
>  			list_for_each_entry(trans, &u->transactions, list)
> -				if (trans->handle == u->u.msg.tx_id)
> +				if (trans->handle.id == u->u.msg.tx_id)
>  					break;
>  			BUG_ON(&trans->list == &u->transactions);
>  			list_del(&trans->list);
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
> --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -128,7 +128,7 @@ static int read_otherend_details(struct 
>  static int read_otherend_details(struct xenbus_device *xendev,
>  				 char *id_node, char *path_node)
>  {
> -	int err = xenbus_gather(XBT_NULL, xendev->nodename,
> +	int err = xenbus_gather(XBT_NIL, xendev->nodename,
>  				id_node, "%i", &xendev->otherend_id,
>  				path_node, NULL, &xendev->otherend,
>  				NULL);
> @@ -139,7 +139,7 @@ static int read_otherend_details(struct 
>  		return err;
>  	}
>  	if (strlen(xendev->otherend) == 0 ||
> -	    !xenbus_exists(XBT_NULL, xendev->otherend, "")) {
> +	    !xenbus_exists(XBT_NIL, xendev->otherend, "")) {
>  		xenbus_dev_fatal(xendev, -ENOENT, "missing other end from %s",
>  				 xendev->nodename);
>  		free_otherend_details(xendev);
> @@ -195,14 +195,14 @@ static int backend_bus_id(char bus_id[BU
>  
>  	devid = strrchr(nodename, '/') + 1;
>  
> -	err = xenbus_gather(XBT_NULL, nodename, "frontend-id", "%i", &domid,
> +	err = xenbus_gather(XBT_NIL, nodename, "frontend-id", "%i", &domid,
>  			    "frontend", NULL, &frontend,
>  			    NULL);
>  	if (err)
>  		return err;
>  	if (strlen(frontend) == 0)
>  		err = -ERANGE;
> -	if (!err && !xenbus_exists(XBT_NULL, frontend, ""))
> +	if (!err && !xenbus_exists(XBT_NIL, frontend, ""))
>  		err = -ENOENT;
>  
>  	kfree(frontend);
> @@ -634,7 +634,7 @@ static int xenbus_probe_backend(const ch
>  	if (!nodename)
>  		return -ENOMEM;
>  
> -	dir = xenbus_directory(XBT_NULL, nodename, "", &dir_n);
> +	dir = xenbus_directory(XBT_NIL, nodename, "", &dir_n);
>  	if (IS_ERR(dir)) {
>  		kfree(nodename);
>  		return PTR_ERR(dir);
> @@ -657,7 +657,7 @@ static int xenbus_probe_device_type(stru
>  	unsigned int dir_n = 0;
>  	int i;
>  
> -	dir = xenbus_directory(XBT_NULL, bus->root, type, &dir_n);
> +	dir = xenbus_directory(XBT_NIL, bus->root, type, &dir_n);
>  	if (IS_ERR(dir))
>  		return PTR_ERR(dir);
>  
> @@ -676,7 +676,7 @@ static int xenbus_probe_devices(struct x
>  	char **dir;
>  	unsigned int i, dir_n;
>  
> -	dir = xenbus_directory(XBT_NULL, bus->root, "", &dir_n);
> +	dir = xenbus_directory(XBT_NIL, bus->root, "", &dir_n);
>  	if (IS_ERR(dir))
>  		return PTR_ERR(dir);
>  
> @@ -722,7 +722,7 @@ static void dev_changed(const char *node
>  	if (char_count(node, '/') < 2)
>   		return;
>  
> -	exists = xenbus_exists(XBT_NULL, node, "");
> +	exists = xenbus_exists(XBT_NIL, node, "");
>  	if (!exists) {
>  		xenbus_cleanup_devices(node, &bus->bus);
>  		return;
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
> --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Fri Jun 09 14:25:46 2006 +0100
> @@ -192,7 +192,7 @@ void *xenbus_dev_request_and_reply(struc
>  }
>  
>  /* Send message to xs, get kmalloc'ed reply.  ERR_PTR() on error. */
> -static void *xs_talkv(xenbus_transaction_t t,
> +static void *xs_talkv(struct xenbus_transaction t,
>  		      enum xsd_sockmsg_type type,
>  		      const struct kvec *iovec,
>  		      unsigned int num_vecs,
> @@ -203,7 +203,7 @@ static void *xs_talkv(xenbus_transaction
>  	unsigned int i;
>  	int err;
>  
> -	msg.tx_id = t;
> +	msg.tx_id = t.id;
>  	msg.req_id = 0;
>  	msg.type = type;
>  	msg.len = 0;
> @@ -251,7 +251,7 @@ static void *xs_talkv(xenbus_transaction
>  }
>  
>  /* Simplified version of xs_talkv: single message. */
> -static void *xs_single(xenbus_transaction_t t,
> +static void *xs_single(struct xenbus_transaction t,
>  		       enum xsd_sockmsg_type type,
>  		       const char *string,
>  		       unsigned int *len)
> @@ -318,7 +318,7 @@ static char **split(char *strings, unsig
>  	return ret;
>  }
>  
> -char **xenbus_directory(xenbus_transaction_t t,
> +char **xenbus_directory(struct xenbus_transaction t,
>  			const char *dir, const char *node, unsigned int *num)
>  {
>  	char *strings, *path;
> @@ -338,7 +338,7 @@ EXPORT_SYMBOL_GPL(xenbus_directory);
>  EXPORT_SYMBOL_GPL(xenbus_directory);
>  
>  /* Check if a path exists. Return 1 if it does. */
> -int xenbus_exists(xenbus_transaction_t t,
> +int xenbus_exists(struct xenbus_transaction t,
>  		  const char *dir, const char *node)
>  {
>  	char **d;
> @@ -356,7 +356,7 @@ EXPORT_SYMBOL_GPL(xenbus_exists);
>   * Returns a kmalloced value: call free() on it after use.
>   * len indicates length in bytes.
>   */
> -void *xenbus_read(xenbus_transaction_t t,
> +void *xenbus_read(struct xenbus_transaction t,
>  		  const char *dir, const char *node, unsigned int *len)
>  {
>  	char *path;
> @@ -375,7 +375,7 @@ EXPORT_SYMBOL_GPL(xenbus_read);
>  /* Write the value of a single file.
>   * Returns -err on failure.
>   */
> -int xenbus_write(xenbus_transaction_t t,
> +int xenbus_write(struct xenbus_transaction t,
>  		 const char *dir, const char *node, const char *string)
>  {
>  	const char *path;
> @@ -398,7 +398,7 @@ EXPORT_SYMBOL_GPL(xenbus_write);
>  EXPORT_SYMBOL_GPL(xenbus_write);
>  
>  /* Create a new directory. */
> -int xenbus_mkdir(xenbus_transaction_t t,
> +int xenbus_mkdir(struct xenbus_transaction t,
>  		 const char *dir, const char *node)
>  {
>  	char *path;
> @@ -415,7 +415,7 @@ EXPORT_SYMBOL_GPL(xenbus_mkdir);
>  EXPORT_SYMBOL_GPL(xenbus_mkdir);
>  
>  /* Destroy a file or directory (directories must be empty). */
> -int xenbus_rm(xenbus_transaction_t t, const char *dir, const char *node)
> +int xenbus_rm(struct xenbus_transaction t, const char *dir, const char *node)
>  {
>  	char *path;
>  	int ret;
> @@ -433,19 +433,19 @@ EXPORT_SYMBOL_GPL(xenbus_rm);
>  /* Start a transaction: changes by others will not be seen during this
>   * transaction, and changes will not be visible to others until end.
>   */
> -int xenbus_transaction_start(xenbus_transaction_t *t)
> +int xenbus_transaction_start(struct xenbus_transaction *t)
>  {
>  	char *id_str;
>  
>  	down_read(&xs_state.suspend_mutex);
>  
> -	id_str = xs_single(XBT_NULL, XS_TRANSACTION_START, "", NULL);
> +	id_str = xs_single(XBT_NIL, XS_TRANSACTION_START, "", NULL);
>  	if (IS_ERR(id_str)) {
>  		up_read(&xs_state.suspend_mutex);
>  		return PTR_ERR(id_str);
>  	}
>  
> -	*t = simple_strtoul(id_str, NULL, 0);
> +	t->id = simple_strtoul(id_str, NULL, 0);
>  	kfree(id_str);
>  	return 0;
>  }
> @@ -454,7 +454,7 @@ EXPORT_SYMBOL_GPL(xenbus_transaction_sta
>  /* End a transaction.
>   * If abandon is true, transaction is discarded instead of committed.
>   */
> -int xenbus_transaction_end(xenbus_transaction_t t, int abort)
> +int xenbus_transaction_end(struct xenbus_transaction t, int abort)
>  {
>  	char abortstr[2];
>  	int err;
> @@ -473,7 +473,7 @@ EXPORT_SYMBOL_GPL(xenbus_transaction_end
>  EXPORT_SYMBOL_GPL(xenbus_transaction_end);
>  
>  /* Single read and scanf: returns -errno or num scanned. */
> -int xenbus_scanf(xenbus_transaction_t t,
> +int xenbus_scanf(struct xenbus_transaction t,
>  		 const char *dir, const char *node, const char *fmt, ...)
>  {
>  	va_list ap;
> @@ -496,7 +496,7 @@ EXPORT_SYMBOL_GPL(xenbus_scanf);
>  EXPORT_SYMBOL_GPL(xenbus_scanf);
>  
>  /* Single printf and write: returns -errno or 0. */
> -int xenbus_printf(xenbus_transaction_t t,
> +int xenbus_printf(struct xenbus_transaction t,
>  		  const char *dir, const char *node, const char *fmt, ...)
>  {
>  	va_list ap;
> @@ -522,7 +522,7 @@ EXPORT_SYMBOL_GPL(xenbus_printf);
>  EXPORT_SYMBOL_GPL(xenbus_printf);
>  
>  /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
> -int xenbus_gather(xenbus_transaction_t t, const char *dir, ...)
> +int xenbus_gather(struct xenbus_transaction t, const char *dir, ...)
>  {
>  	va_list ap;
>  	const char *name;
> @@ -560,7 +560,7 @@ static int xs_watch(const char *path, co
>  	iov[1].iov_base = (void *)token;
>  	iov[1].iov_len = strlen(token) + 1;
>  
> -	return xs_error(xs_talkv(XBT_NULL, XS_WATCH, iov,
> +	return xs_error(xs_talkv(XBT_NIL, XS_WATCH, iov,
>  				 ARRAY_SIZE(iov), NULL));
>  }
>  
> @@ -573,7 +573,7 @@ static int xs_unwatch(const char *path, 
>  	iov[1].iov_base = (char *)token;
>  	iov[1].iov_len = strlen(token) + 1;
>  
> -	return xs_error(xs_talkv(XBT_NULL, XS_UNWATCH, iov,
> +	return xs_error(xs_talkv(XBT_NIL, XS_UNWATCH, iov,
>  				 ARRAY_SIZE(iov), NULL));
>  }
>  
> diff -r 7cf4cbe7a3be -r 49f65e2b0f1c linux-2.6-xen-sparse/include/xen/xenbus.h
> --- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Fri Jun 09 14:23:50 2006 +0100
> +++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Fri Jun 09 14:25:46 2006 +0100
> @@ -41,8 +41,6 @@
>  #include <xen/interface/grant_table.h>
>  #include <xen/interface/io/xenbus.h>
>  #include <xen/interface/io/xs_wire.h>
> -
> -#define XBT_NULL 0
>  
>  /* Register callback to watch this node. */
>  struct xenbus_watch
> @@ -115,35 +113,41 @@ int xenbus_register_backend(struct xenbu
>  int xenbus_register_backend(struct xenbus_driver *drv);
>  void xenbus_unregister_driver(struct xenbus_driver *drv);
>  
> -typedef u32 xenbus_transaction_t;
> -
> -char **xenbus_directory(xenbus_transaction_t t,
> +struct xenbus_transaction
> +{
> +	u32 id;
> +};
> +
> +/* Nil transaction ID. */
> +#define XBT_NIL ((struct xenbus_transaction) { 0 })
> +
> +char **xenbus_directory(struct xenbus_transaction t,
>  			const char *dir, const char *node, unsigned int *num);
> -void *xenbus_read(xenbus_transaction_t t,
> +void *xenbus_read(struct xenbus_transaction t,
>  		  const char *dir, const char *node, unsigned int *len);
> -int xenbus_write(xenbus_transaction_t t,
> +int xenbus_write(struct xenbus_transaction t,
>  		 const char *dir, const char *node, const char *string);
> -int xenbus_mkdir(xenbus_transaction_t t,
> +int xenbus_mkdir(struct xenbus_transaction t,
>  		 const char *dir, const char *node);
> -int xenbus_exists(xenbus_transaction_t t,
> +int xenbus_exists(struct xenbus_transaction t,
>  		  const char *dir, const char *node);
> -int xenbus_rm(xenbus_transaction_t t, const char *dir, const char *node);
> -int xenbus_transaction_start(xenbus_transaction_t *t);
> -int xenbus_transaction_end(xenbus_transaction_t t, int abort);
> +int xenbus_rm(struct xenbus_transaction t, const char *dir, const char *node);
> +int xenbus_transaction_start(struct xenbus_transaction *t);
> +int xenbus_transaction_end(struct xenbus_transaction t, int abort);
>  
>  /* Single read and scanf: returns -errno or num scanned if > 0. */
> -int xenbus_scanf(xenbus_transaction_t t,
> +int xenbus_scanf(struct xenbus_transaction t,
>  		 const char *dir, const char *node, const char *fmt, ...)
>  	__attribute__((format(scanf, 4, 5)));
>  
>  /* Single printf and write: returns -errno or 0. */
> -int xenbus_printf(xenbus_transaction_t t,
> +int xenbus_printf(struct xenbus_transaction t,
>  		  const char *dir, const char *node, const char *fmt, ...)
>  	__attribute__((format(printf, 4, 5)));
>  
>  /* Generic read function: NULL-terminated triples of name,
>   * sprintf-style type string, and pointer. Returns 0 or errno.*/
> -int xenbus_gather(xenbus_transaction_t t, const char *dir, ...);
> +int xenbus_gather(struct xenbus_transaction t, const char *dir, ...);
>  
>  /* notifer routines for when the xenstore comes up */
>  int register_xenstore_notifier(struct notifier_block *nb);
>
> _______________________________________________
> Xen-changelog mailing list
> Xen-changelog@lists.xensource.com
> http://lists.xensource.com/xen-changelog
>   

^ permalink raw reply	[relevance 0%]

* [PATCH 1/4] balloon: the balloon driver's proc entry needs CONFIG_PROC_FS
  @ 2006-06-16  7:50 22% ` Horms
  0 siblings, 0 replies; 200+ results
From: Horms @ 2006-06-16  7:50 UTC (permalink / raw)
  To: xen-devel; +Cc: Horms

balloon: the balloon driver's proc entry needs CONFIG_PROC_FS

CONFIG_PROC_FS is needed in order to compile the proc entry portion
of the baloon driver. I believe that the rest of the driver is still
fully functional with this change.

Signed-Off-By: Horms <horms@verge.net.au>

 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- x/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
+++ x/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
@@ -58,7 +58,9 @@
 
 #define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10))
 
+#ifdef CONFIG_PROC_FS
 static struct proc_dir_entry *balloon_pde;
+#endif
 
 static DECLARE_MUTEX(balloon_mutex);
 
@@ -403,6 +405,7 @@ static int balloon_init_watcher(struct n
 	return NOTIFY_DONE;
 }
 
+#ifdef CONFIG_PROC_FS
 static int balloon_write(struct file *file, const char __user *buffer,
 			 unsigned long count, void *data)
 {
@@ -456,6 +459,7 @@ static int balloon_read(char *page, char
 	*eof = 1;
 	return len;
 }
+#endif
 
 static struct notifier_block xenstore_notifier;
 
@@ -481,6 +485,7 @@ static int __init balloon_init(void)
 	balloon_timer.data = 0;
 	balloon_timer.function = balloon_alarm;
     
+#ifdef CONFIG_PROC_FS
 	if ((balloon_pde = create_xen_proc_entry("balloon", 0644)) == NULL) {
 		WPRINTK("Unable to create /proc/xen/balloon.\n");
 		return -1;
@@ -488,6 +493,7 @@ static int __init balloon_init(void)
 
 	balloon_pde->read_proc  = balloon_read;
 	balloon_pde->write_proc = balloon_write;
+#endif
     
 	/* Initialise the balloon with excess memory space. */
 	for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {

-- 
Horms                                           http://www.vergenet.net/~horms/

^ permalink raw reply	[relevance 22%]

* [PATCH 1/3] Output Virtual Block Device requests information to /proc/xen/vbd
@ 2006-06-21  9:51  5% Satoshi Uchida
  0 siblings, 0 replies; 200+ results
From: Satoshi Uchida @ 2006-06-21  9:51 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1242 bytes --]

 
This patch add /xen/proc/vbd.
This proc file stores counts of I/O requests for VBD.
I/O requests is counted for each Domains.

For example, in case of four VMs, outputs of reading /xen/proc/vbd are as follows.

root@dom0 ~]# more /proc/xen/vbd
Domain 4 - oo        0  rd    18699  wr        2
 xvd 4  8:21 - oo        0  rd    18699  wr        2
Domain 7 - oo        0  rd      869  wr      376
 xvd 7  8:22 - oo        0  rd      869  wr      376
Domain 8 - oo        0  rd      721  wr      197
 xvd 8  8:23 - oo        0  rd      721  wr      197
Domain 9 - oo        0  rd      640  wr       77
 xvd 9  8:24 - oo        0  rd      640  wr       77

The outputs show the following information.

The first line shows domain information.
     Detail: Domain [Domain ID] - oo [oo-reqs] rd  [rd-reqs] wr [wr-reqs].
The second or less than third line shows each VBD information.
        xvd [Domain ID] [device majar]:[device minor]  - oo [oo-reqs] rd  [rd-reqs] wr [wr-reqs].

VBD information handles "xvd [Domain ID] [device majar]:[device minor]" for reason
 that the thread is running same name.

Currently, Domain show domain ID.
Someday, it want to correspond with domain name.


Thanks,
Satoshi UCHIDA

[-- Attachment #2: proc_xen_vbd.patch --]
[-- Type: application/octet-stream, Size: 7360 bytes --]

# HG changeset patch
# User s-uchida@ap.jp.nec.com
# Node ID 55ab88937d77290a54d3315ea4cab6234efd4e78
# Parent  360f9dc71f513c5e371c8c1b09cbb0f3c8e34d63
Add /proc/xen/vbd.  Output vbd request information.

diff -r 360f9dc71f51 -r 55ab88937d77 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Tue Jun 13 11:41:15 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu Jun 15 13:57:11 2006 +0900
@@ -41,6 +41,10 @@
 #include <xen/balloon.h>
 #include <asm/hypervisor.h>
 #include "common.h"
+
+#include <linux/kernel.h>
+#include <xen/xen_proc.h>
+#include <xen/xenbus.h>
 
 /*
  * These are rather arbitrary. They are fairly large because adjacent requests
@@ -85,6 +89,30 @@ static DEFINE_SPINLOCK(pending_free_lock
 static DEFINE_SPINLOCK(pending_free_lock);
 static DECLARE_WAIT_QUEUE_HEAD(pending_free_wq);
 
+/*
+ * VBD(Virtual Block Device) information is allocated to 'dom_io_info'.
+ * by each domain.
+ */
+
+typedef struct {
+	domid_t        dom;
+	unsigned long long rd_req;
+	unsigned long long wr_req;
+	unsigned long long oo_req;
+	struct list_head blkif_list;
+	struct list_head sibling_list;
+} dom_io_info_t;
+
+static struct list_head dom_io_info;
+static spinlock_t dom_io_info_lock = SPIN_LOCK_UNLOCKED;
+static DECLARE_WAIT_QUEUE_HEAD(dom_io_info_wq);
+
+/*
+ * VBD information access proc file system which located /proc/xen/vbd.
+ */
+static struct proc_dir_entry *blkback_pde;
+
+
 #define BLKBACK_INVALID_HANDLE (~0)
 
 static unsigned long mmap_vstart;
@@ -185,6 +213,145 @@ static void fast_flush_area(pending_req_
 	BUG_ON(ret);
 }
 
+
+/********************************************
+ * PROC OUTPUT FUNCTIONS
+ */
+static int put_proc_domain(char *page, dom_io_info_t *info)
+{
+	blkif_t *blkif;
+	int len;
+
+
+	info->oo_req = 0;
+	info->rd_req = 0;
+	info->wr_req = 0;
+
+	list_for_each_entry(blkif, &info->blkif_list, sibling_list) {
+		info->oo_req += blkif->st_oo_req;
+		info->rd_req += blkif->st_rd_req;
+		info->wr_req += blkif->st_wr_req;
+	}
+		
+	len = sprintf(
+		page,
+		"Domain %u - oo %8llu  rd %8llu  wr %8llu"
+		"\n",
+		info->dom, info->oo_req,
+		info->rd_req, info->wr_req
+		);
+
+	list_for_each_entry(blkif, &info->blkif_list, sibling_list) {
+      		len += sprintf(
+			page + len, 
+			" xvd %u %2u:%2u - oo %8d  rd %8d  wr %8d"
+			"\n",
+			blkif->domid,
+			blkif->be->major, blkif->be->minor,
+			blkif->st_oo_req, blkif->st_rd_req, blkif->st_wr_req,
+		      );
+	}
+
+	return len;
+}
+
+static int put_proc_domains(char *page)
+{
+	dom_io_info_t *info;
+	unsigned long flags;
+	int len;
+
+	len = 0;
+	spin_lock_irqsave(&dom_io_info_lock, flags);
+	list_for_each_entry(info, &dom_io_info, sibling_list) {
+	        len += put_proc_domain(page+len, info);
+	}
+	spin_unlock_irqrestore(&dom_io_info_lock, flags);
+
+	return len;
+}
+
+
+static int blkback_read(char *page, char **start, off_t off,
+		       int count, int *eof, void *data)
+{
+	int len;
+
+	len = put_proc_domains(page);
+	
+	*eof = 1;
+	return len;
+}
+
+
+/*****************************************************************
+ * VBD information structure control
+ */
+
+dom_io_info_t *dominfo_get(domid_t dom)
+{
+	dom_io_info_t *info;
+	unsigned long flags;
+
+	spin_lock_irqsave(&dom_io_info_lock, flags);
+	list_for_each_entry(info, &dom_io_info, sibling_list) {
+		if (info->dom == dom) {
+			spin_unlock_irqrestore(&dom_io_info_lock, flags);
+			return info;
+		}
+	}
+	spin_unlock_irqrestore(&dom_io_info_lock, flags);
+
+	return NULL;
+}
+
+
+static int info_add(blkif_t *blkif)
+{
+	dom_io_info_t *info;
+
+	if (!(info = dominfo_get(blkif->domid))) {
+		info = kmalloc(sizeof(*info), GFP_KERNEL);
+		if (!info) {
+			printk("%s: out of memory\n", __FUNCTION__);
+			return -ENOMEM;
+		}
+		info->dom = blkif->domid ;
+		INIT_LIST_HEAD(&info->blkif_list);
+		info->rd_req = 0;
+		info->wr_req = 0;
+		info->oo_req = 0;
+		list_add_tail(&info->sibling_list, &dom_io_info);
+	}
+
+	list_add_tail(&blkif->sibling_list, &info->blkif_list);
+
+	return 0;
+}
+
+
+static int info_del(blkif_t *blkif)
+{
+	dom_io_info_t *info;
+	unsigned long flags;
+
+	if (!(info = dominfo_get(blkif->domid))) {
+		return -1;
+	}
+
+	spin_lock_irqsave(&dom_io_info_lock, flags);
+	list_del(&blkif->sibling_list);
+	
+	if (list_empty(&info->blkif_list)) {
+		list_del(&info->sibling_list);
+		kfree(info);
+	}
+	spin_unlock_irqrestore(&dom_io_info_lock, flags);
+
+	return 0;
+}
+
+
 /******************************************************************
  * SCHEDULER FUNCTIONS
  */
@@ -209,6 +376,8 @@ int blkif_schedule(void *arg)
 	if (debug_lvl)
 		printk(KERN_DEBUG "%s: started\n", current->comm);
 
+	info_add(blkif);
+
 	while (!kthread_should_stop()) {
 		wait_event_interruptible(
 			blkif->wq,
@@ -232,6 +401,8 @@ int blkif_schedule(void *arg)
 		print_stats(blkif);
 	if (debug_lvl)
 		printk(KERN_DEBUG "%s: exiting\n", current->comm);
+
+	info_del(blkif);
 
 	blkif->xenblkd = NULL;
 	blkif_put(blkif);
@@ -554,12 +725,22 @@ static int __init blkif_init(void)
 
 	memset(pending_reqs, 0, sizeof(pending_reqs));
 	INIT_LIST_HEAD(&pending_free);
+	INIT_LIST_HEAD(&dom_io_info);
 
 	for (i = 0; i < blkif_reqs; i++)
 		list_add_tail(&pending_reqs[i].free_list, &pending_free);
     
 	blkif_xenbus_init();
 
+	/* set up /proc/xen/vbd */
+	if ((blkback_pde = create_xen_proc_entry("vbd", 0444)) == NULL) {
+		DPRINTK("xen_vbd: Unable to create /proc/xen/vbd.\n");
+		return -1;
+	}
+
+	blkback_pde->read_proc  = blkback_read;
+
+
 	return 0;
 }
 
diff -r 360f9dc71f51 -r 55ab88937d77 linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Tue Jun 13 11:41:15 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Thu Jun 15 13:57:11 2006 +0900
@@ -44,6 +44,7 @@
 #include <xen/interface/io/ring.h>
 #include <xen/gnttab.h>
 #include <xen/driver_util.h>
+#include <xen/xenbus.h>
 
 #define DPRINTK(_f, _a...)			\
 	pr_debug("(file=%s, line=%d) " _f,	\
@@ -92,7 +93,19 @@ typedef struct blkif_st {
 
 	grant_handle_t shmem_handle;
 	grant_ref_t    shmem_ref;
+
+	struct list_head sibling_list;
 } blkif_t;
+
+struct backend_info
+{
+ 	struct xenbus_device *dev;
+ 	blkif_t *blkif;
+ 	struct xenbus_watch backend_watch;
+ 	unsigned major;
+ 	unsigned minor;
+ 	char *mode;
+}; 
 
 blkif_t *blkif_alloc(domid_t domid);
 void blkif_free(blkif_t *blkif);
diff -r 360f9dc71f51 -r 55ab88937d77 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Tue Jun 13 11:41:15 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Thu Jun 15 13:57:11 2006 +0900
@@ -27,16 +27,6 @@
 #define DPRINTK(fmt, args...)				\
 	pr_debug("blkback/xenbus (%s:%d) " fmt ".\n",	\
 		 __FUNCTION__, __LINE__, ##args)
-
-struct backend_info
-{
-	struct xenbus_device *dev;
-	blkif_t *blkif;
-	struct xenbus_watch backend_watch;
-	unsigned major;
-	unsigned minor;
-	char *mode;
-};
 
 static void connect(struct backend_info *);
 static int connect_ring(struct backend_info *);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 5%]

* PATCH: fix some transparent virtualization issues
@ 2006-06-21 14:44 15% Tristan Gingold
  0 siblings, 0 replies; 200+ results
From: Tristan Gingold @ 2006-06-21 14:44 UTC (permalink / raw)
  To: xen-devel, xen-ia64-devel

[-- Attachment #1: Type: text/plain, Size: 130 bytes --]

Hi,

small patch to fix some issues wrt transparent virtualization.

Tested by booting on ia64 bare box and under xen.

Tristan.


[-- Attachment #2: xen-transvirt2.diffs --]
[-- Type: text/x-diff, Size: 2054 bytes --]

# HG changeset patch
# User gingold@virtu10
# Node ID 2458be180782060cc805bc2f5e3ff165391d50ee
# Parent  8314141cfe543d0e83b15a6eca9569df4b82a0b2
Transparent virtualization fixes.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>

diff -r 8314141cfe54 -r 2458be180782 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Tue Jun 20 17:02:22 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Jun 21 15:19:57 2006 +0200
@@ -464,10 +464,10 @@ static int __init balloon_init(void)
 	unsigned long pfn;
 	struct page *page;
 
-	IPRINTK("Initialising balloon driver.\n");
-
 	if (!is_running_on_xen())
 		return -ENODEV;
+
+	IPRINTK("Initialising balloon driver.\n");
 
 	current_pages = min(xen_start_info->nr_pages, max_pfn);
 	totalram_pages = current_pages;
diff -r 8314141cfe54 -r 2458be180782 linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c	Tue Jun 20 17:02:22 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c	Wed Jun 21 15:19:57 2006 +0200
@@ -109,6 +109,9 @@ static int __init setup_vcpu_hotplug_eve
 	static struct notifier_block xsn_cpu = {
 		.notifier_call = setup_cpu_watcher };
 
+	if (!is_running_on_xen())
+		return -ENODEV;
+
 	register_cpu_notifier(&hotplug_cpu);
 	register_xenstore_notifier(&xsn_cpu);
 
diff -r 8314141cfe54 -r 2458be180782 linux-2.6-xen-sparse/drivers/xen/core/evtchn.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Tue Jun 20 17:02:22 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Wed Jun 21 15:19:57 2006 +0200
@@ -666,7 +666,11 @@ int irq_ignore_unhandled(unsigned int ir
 int irq_ignore_unhandled(unsigned int irq)
 {
 	struct physdev_irq_status_query irq_status = { .irq = irq };
-	(void)HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status);
+
+	if (!is_running_on_xen())
+		return 0;
+
+	(void)HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query,&irq_status);
 	return !!(irq_status.flags & XENIRQSTAT_shared);
 }
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 15%]

* [PATCH] Virtual SCSI frontend and backend drivers
@ 2006-06-21 19:47  5% FUJITA Tomonori
  0 siblings, 0 replies; 200+ results
From: FUJITA Tomonori @ 2006-06-21 19:47 UTC (permalink / raw)
  To: xen-devel

This patch contains virtual SCSI frontend and backend drivers.

The frontend (initiator) and backend (target) drivers exchange SCSI
RDMA Protocol (SRP) messages by using the ring queue like the blkfront
and blkback drivers do.

The backend driver exploits the SCSI target framework (tgt). tgt
handles SCSI protocol (mostly in user-space). The tgt kernel component
enables the backend driver to send the user-space daemon a vectors of
commands through a netlink interface. The daemon executes the commands
and send the results back to the backend driver. Currently, tgt enables
you to emulate SCSI disk devices with regular and block device files.

I can scan and detect disk with the drivers but they are far from
completion, no error handling, no restore support, no clean
shutdown. And I'm too lazy to implement SRP indirect data format so
the drivers cannot handle large data transfer.

The mm-kernels have the SRP helper library because there are other SRP
drivers in mainline (IBM pServer initiator and target drivers and
Infiniband initiator driver). It will simplify the Xen SCSI frontend
and backend drivers greatly, but I've not integrated them.

With the current tgt design, the daemon forces the backend driver to
use page cache. So the backend driver does memory copies between
domain0 and domainU. DIRECT_IO and small extension to tgt would avoid
this problem.

For further information about tgt:

http://www.linuxsymposium.org/2006/view_abstract.php?content_key=19


Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

---
diff -r 2a4377b4361d linux-2.6-xen-sparse/drivers/xen/Kconfig
--- a/linux-2.6-xen-sparse/drivers/xen/Kconfig	Sun Jun 18 19:26:22 2006 +0900
+++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig	Thu Jun 22 04:36:57 2006 +0900
@@ -81,6 +81,15 @@ config XEN_BLKDEV_BACKEND
 	default y
 	help
 	  The block-device backend driver allows the kernel to export its
+	  block devices to other guests via a high-performance shared-memory
+	  interface.
+
+config XEN_VSCSI_BACKEND
+	tristate "Virtual SCSI backend driver"
+        depends on XEN_BACKEND
+	default y
+	help
+	  The virtual SCSI (SRP) backend driver allows the kernel to export its
 	  block devices to other guests via a high-performance shared-memory
 	  interface.
 
@@ -153,6 +162,16 @@ config XEN_BLKDEV_FRONTEND
 	  dedicated device-driver domain, or your master control domain
 	  (domain 0), then you almost certainly want to say Y here.
 
+config XEN_VSCSI_FRONTEND
+	tristate "Virtual SCSI frontend driver"
+	depends on XEN
+	default y
+	help
+	  The virtual SCSI (SRP) frontend driver allows the kernel to access block
+	  devices mounted within another guest OS. Unless you are building a
+	  dedicated device-driver domain, or your master control domain
+	  (domain 0), then you almost certainly want to say Y here.
+
 config XEN_NETDEV_FRONTEND
 	tristate "Network-device frontend driver"
 	depends on XEN
diff -r 2a4377b4361d linux-2.6-xen-sparse/drivers/xen/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/Makefile	Sun Jun 18 19:26:22 2006 +0900
+++ b/linux-2.6-xen-sparse/drivers/xen/Makefile	Thu Jun 22 04:36:57 2006 +0900
@@ -12,9 +12,11 @@ obj-y	+= xenbus/
 
 obj-$(CONFIG_XEN_BLKDEV_BACKEND)	+= blkback/
 obj-$(CONFIG_XEN_NETDEV_BACKEND)	+= netback/
+obj-$(CONFIG_XEN_VSCSI_BACKEND)		+= vscsiback/
 obj-$(CONFIG_XEN_TPMDEV_BACKEND)	+= tpmback/
 obj-$(CONFIG_XEN_BLKDEV_FRONTEND)	+= blkfront/
 obj-$(CONFIG_XEN_NETDEV_FRONTEND)	+= netfront/
+obj-$(CONFIG_XEN_VSCSI_FRONTEND)	+= vscsifront/
 obj-$(CONFIG_XEN_BLKDEV_TAP)    	+= blktap/
 obj-$(CONFIG_XEN_TPMDEV_FRONTEND)	+= tpmfront/
 obj-$(CONFIG_XEN_PCIDEV_BACKEND)	+= pciback/
diff -r 2a4377b4361d linux-2.6-xen-sparse/drivers/xen/vscsiback/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/vscsiback/Makefile	Thu Jun 22 04:36:57 2006 +0900
@@ -0,0 +1,2 @@
+obj-$(CONFIG_XEN_VSCSI_BACKEND)	+= vscsibk.o
+vscsibk-y			+= vscsiback.o interface.o libsrp.o
diff -r 2a4377b4361d linux-2.6-xen-sparse/drivers/xen/vscsiback/interface.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/vscsiback/interface.c	Thu Jun 22 04:36:57 2006 +0900
@@ -0,0 +1,152 @@
+/******************************************************************************
+ * arch/xen/drivers/blkif/backend/interface.c
+ *
+ * Block-device interface management.
+ *
+ * Copyright (c) 2004, Keir Fraser
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <linux/version.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/srp.h>
+#include <xen/driver_util.h>
+#include <xen/evtchn.h>
+#include <xen/xenbus.h>
+#include <xen/interface/xen.h>
+#include <xen/interface/io/vscsi.h>
+#include <xen/interface/io/ring.h>
+#include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
+#include <asm/hypervisor.h>
+#include "vscsiback_priv.h"
+
+static int map_frontend_page(struct vscsiback_info *info, unsigned long shared_page)
+{
+	struct gnttab_map_grant_ref op;
+	int err;
+
+	op.host_addr = (unsigned long)info->ring_area->addr;
+	op.flags     = GNTMAP_host_map;
+	op.ref       = shared_page;
+	op.dom       = info->dev->otherend_id;
+
+	lock_vm_area(info->ring_area);
+	err = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
+	unlock_vm_area(info->ring_area);
+	BUG_ON(err);
+
+	if (op.status) {
+		printk(" Grant table operation failure !\n");
+		return op.status;
+	}
+
+	info->shmem_ref = shared_page;
+	info->shmem_handle = op.handle;
+
+#ifdef CONFIG_XEN_IA64_DOM0_NON_VP
+	/* on some arch's, map_grant_ref behaves like mmap, in that the
+	 * passed address is a hint and a different address may be returned */
+	info->ring_area->addr = gnttab_map_vaddr(op);
+#endif
+
+	return 0;
+}
+
+static void unmap_frontend_page(struct vscsiback_info *info)
+{
+	struct gnttab_unmap_grant_ref op;
+	int err;
+
+	op.host_addr    = (unsigned long)info->ring_area->addr;
+	op.handle       = info->shmem_handle;
+	op.dev_bus_addr = 0;
+
+	lock_vm_area(info->ring_area);
+	err = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
+	unlock_vm_area(info->ring_area);
+	BUG_ON(err);
+}
+
+int vscsiback_init_sring(struct vscsiback_info *info,
+			 unsigned long shared_page, unsigned int evtchn)
+{
+	struct vscsi_sring *sring;
+	int err;
+	evtchn_op_t op = {
+		.cmd = EVTCHNOP_bind_interdomain,
+		.u.bind_interdomain.remote_dom = info->dev->otherend_id,
+		.u.bind_interdomain.remote_port = evtchn };
+
+	if (info->irq) {
+		printk("Already connected through?\n");
+		return 0;
+	}
+
+	info->ring_area = alloc_vm_area(PAGE_SIZE);
+	if (!info)
+		return -ENOMEM;
+
+	err = map_frontend_page(info, shared_page);
+	if (err)
+		goto free_vm;
+
+	err = HYPERVISOR_event_channel_op(&op);
+	if (err)
+		goto unmap_page;
+
+	info->evtchn = op.u.bind_interdomain.local_port;
+
+	sring = (struct vscsi_sring *) info->ring_area->addr;
+	BACK_RING_INIT(&info->ring, sring, PAGE_SIZE);
+
+	info->irq = bind_evtchn_to_irqhandler(info->evtchn, vscsiback_intr,
+					      0, "vscsi-backend", info);
+	return 0;
+
+unmap_page:
+	unmap_frontend_page(info);
+free_vm:
+	free_vm_area(info->ring_area);
+	return err;
+}
+
+void vscsiback_exit_sring(struct vscsiback_info *info)
+{
+	/* Already disconnected? */
+	if (info->irq)
+		unbind_from_irqhandler(info->irq, info);
+
+	if (info->ring.sring) {
+		unmap_frontend_page(info);
+		free_vm_area(info->ring_area);
+	}
+}
diff -r 2a4377b4361d linux-2.6-xen-sparse/drivers/xen/vscsiback/libsrp.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/vscsiback/libsrp.c	Thu Jun 22 04:36:57 2006 +0900
@@ -0,0 +1,259 @@
+/*
+ * SCSI RDAM Protocol lib functions
+ *
+ * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org>
+ *
+ * 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 St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include <linux/err.h>
+#include <linux/kfifo.h>
+#include <linux/scatterlist.h>
+#include <linux/dma-mapping.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_tcq.h>
+#include <scsi/scsi_tgt.h>
+#include <scsi/srp.h>
+#include "libsrp.h"
+
+enum srp_task_attributes {
+	SRP_SIMPLE_TASK = 0,
+	SRP_HEAD_TASK = 1,
+	SRP_ORDERED_TASK = 2,
+	SRP_ACA_TASK = 4
+};
+
+/* tmp - will replace with SCSI logging stuff */
+#define eprintk(fmt, args...)					\
+do {								\
+	printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args);	\
+} while (0)
+#define dprintk eprintk
+/* #define dprintk(fmt, args...) */
+
+static int direct_data(struct scsi_cmnd *sc, struct srp_direct_buf *md,
+		       rdma_io_t rdma_io)
+{
+	struct scatterlist *sg = sc->request_buffer;
+
+	dprintk("%u %u %d\n", sc->request_bufflen, md->len, sc->use_sg);
+	return rdma_io(sc, sg, sc->use_sg, md, 1, min(sc->request_bufflen, md->len));
+}
+
+#if 0
+static int indirect_data(struct scsi_cmnd *scmd, struct srp_cmd *cmd,
+			 struct srp_indirect_buf *id,
+			 enum dma_data_direction dir, rdma_io_t rdma_io)
+{
+	struct iu_entry *iue = (struct iu_entry *) scmd->SCp.ptr;
+	struct srp_target *target = iue->target;
+	struct srp_direct_buf *md;
+	struct scatterlist dummy, *sg = scmd->request_buffer;
+	dma_addr_t token = 0;
+	long err;
+	unsigned int done = 0;
+	int nmd, nsg;
+
+	nmd = id->table_desc.len / sizeof(struct srp_direct_buf);
+
+	dprintk("%p %u %u %u %u %d %d %d\n",
+		iue, scmd->request_bufflen,
+		id->len, scmd->offset, nmd,
+		cmd->data_in_desc_cnt, cmd->data_out_desc_cnt);
+
+	if ((dir == DMA_FROM_DEVICE && nmd == cmd->data_in_desc_cnt) ||
+	    (dir == DMA_TO_DEVICE && nmd == cmd->data_out_desc_cnt)) {
+		md = &id->desc_list[0];
+		goto rdma;
+	}
+
+	md = dma_alloc_coherent(target->dev, id->table_desc.len,
+				 &token, GFP_KERNEL);
+	if (!md) {
+		eprintk("Can't get dma memory %u\n", id->table_desc.len);
+		return 0;
+	}
+
+	sg_init_one(&dummy, md, id->table_desc.len);
+	sg_dma_address(&dummy) = token;
+	err = rdma_io(iue, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE,
+		      id->table_desc.len);
+	if (err < 0) {
+		eprintk("Error copying indirect table %ld\n", err);
+		goto free_mem;
+	}
+
+rdma:
+	nsg = dma_map_sg(target->dev, sg, scmd->use_sg, DMA_BIDIRECTIONAL);
+	if (!nsg) {
+		eprintk("fail to map %p %d\n", iue, scmd->use_sg);
+		goto free_mem;
+	}
+
+	err = rdma_io(iue, sg, nsg, md, nmd, dir,
+		      min(scmd->request_bufflen, id->len));
+	dma_unmap_sg(target->dev, sg, nsg, DMA_BIDIRECTIONAL);
+
+free_mem:
+	if (token)
+		dma_free_coherent(target->dev, id->table_desc.len, md, token);
+
+	return done;
+}
+#endif
+
+static int data_out_desc_size(struct srp_cmd *cmd)
+{
+	int size = 0;
+	u8 fmt = cmd->buf_fmt >> 4;
+
+	switch (fmt) {
+	case SRP_NO_DATA_DESC:
+		break;
+	case SRP_DATA_DESC_DIRECT:
+		size = sizeof(struct srp_direct_buf);
+		break;
+	case SRP_DATA_DESC_INDIRECT:
+		size = sizeof(struct srp_indirect_buf) +
+			sizeof(struct srp_direct_buf) * cmd->data_out_desc_cnt;
+		break;
+	default:
+		eprintk("client error. Invalid data_out_format %x\n", fmt);
+		break;
+	}
+	return size;
+}
+
+int srp_transfer_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
+		      rdma_io_t rdma_io)
+{
+	struct srp_direct_buf *md;
+	struct srp_indirect_buf *id;
+	int offset, err = 0;
+	u8 format;
+
+	offset = cmd->add_cdb_len * 4;
+	if (sc->sc_data_direction == DMA_FROM_DEVICE)
+		offset += data_out_desc_size(cmd);
+
+	if (sc->sc_data_direction == DMA_TO_DEVICE)
+		format = cmd->buf_fmt >> 4;
+	else
+		format = cmd->buf_fmt & ((1U << 4) - 1);
+
+	dprintk("%d %x %d\n", sc->sc_data_direction, format, offset);
+
+	switch (format) {
+	case SRP_NO_DATA_DESC:
+		break;
+	case SRP_DATA_DESC_DIRECT:
+		md = (struct srp_direct_buf *)
+			(cmd->add_data + offset);
+		err = direct_data(sc, md, rdma_io);
+		break;
+	case SRP_DATA_DESC_INDIRECT:
+		id = (struct srp_indirect_buf *)
+			(cmd->add_data + offset);
+/* 		err = indirect_data(sc, cmd, id, dir, rdma_io); */
+		break;
+	default:
+		eprintk("Unknown format %d %x\n", sc->sc_data_direction, format);
+		break;
+	}
+
+	return err;
+}
+
+static int vscsis_data_length(struct srp_cmd *cmd, enum dma_data_direction dir)
+{
+	struct srp_direct_buf *md;
+	struct srp_indirect_buf *id;
+	int len = 0, offset = cmd->add_cdb_len * 4;
+	u8 fmt;
+
+	if (dir == DMA_TO_DEVICE)
+		fmt = cmd->buf_fmt >> 4;
+	else {
+		fmt = cmd->buf_fmt & ((1U << 4) - 1);
+		offset += data_out_desc_size(cmd);
+	}
+
+	switch (fmt) {
+	case SRP_NO_DATA_DESC:
+		break;
+	case SRP_DATA_DESC_DIRECT:
+		md = (struct srp_direct_buf *) (cmd->add_data + offset);
+		len = md->len;
+		break;
+	case SRP_DATA_DESC_INDIRECT:
+		id = (struct srp_indirect_buf *) (cmd->add_data + offset);
+		len = id->len;
+		break;
+	default:
+		eprintk("invalid data format %x\n", fmt);
+		break;
+	}
+	return len;
+}
+
+int srp_cmd_perform(struct Scsi_Host *host, struct srp_cmd *cmd, void *data)
+{
+	enum dma_data_direction data_dir;
+	struct scsi_cmnd *sc;
+	int tag, len;
+
+	tag = MSG_SIMPLE_TAG;
+
+	switch (cmd->task_attr) {
+	case SRP_SIMPLE_TASK:
+		tag = MSG_SIMPLE_TAG;
+		break;
+	case SRP_ORDERED_TASK:
+		tag = MSG_ORDERED_TAG;
+		break;
+	case SRP_HEAD_TASK:
+		tag = MSG_HEAD_TAG;
+		break;
+	default:
+		eprintk("Task attribute %d not supported\n", cmd->task_attr);
+		tag = MSG_ORDERED_TAG;
+	}
+
+	if (cmd->buf_fmt >> 4)
+		data_dir = DMA_TO_DEVICE;
+	else
+		data_dir = DMA_FROM_DEVICE;
+	len = vscsis_data_length(cmd, data_dir);
+
+	dprintk("%x %llx %d %d %d %llx\n", cmd->cdb[0],
+		(unsigned long long) cmd->lun, data_dir,
+		len, tag, (unsigned long long) cmd->tag);
+
+	sc = scsi_host_get_command(host, data_dir, GFP_KERNEL);
+	BUG_ON(!sc);
+	memcpy(sc->cmnd, cmd->cdb, MAX_COMMAND_SIZE);
+	sc->request_bufflen = len;
+	sc->tag = tag;
+	sc->SCp.ptr = data;
+	sc->host_scribble = (void *) host;
+	scsi_tgt_queue_command(sc, (struct scsi_lun *) &cmd->lun, cmd->tag);
+
+	return 0;
+}
+
+MODULE_DESCRIPTION("SCSI RDAM Protocol lib functions");
+MODULE_AUTHOR("FUJITA Tomonori");
+MODULE_LICENSE("GPL");
diff -r 2a4377b4361d linux-2.6-xen-sparse/drivers/xen/vscsiback/libsrp.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/vscsiback/libsrp.h	Thu Jun 22 04:36:57 2006 +0900
@@ -0,0 +1,15 @@
+#ifndef __LIBSRP_H__
+#define __LIBSRP_H__
+
+#include <linux/list.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_host.h>
+#include <scsi/srp.h>
+
+typedef int (rdma_io_t) (struct scsi_cmnd *, struct scatterlist *, int,
+			 struct srp_direct_buf *, int, unsigned int);
+
+extern int srp_cmd_perform(struct Scsi_Host *, struct srp_cmd *, void *);
+extern int srp_transfer_data(struct scsi_cmnd *, struct srp_cmd *, rdma_io_t);
+
+#endif
diff -r 2a4377b4361d linux-2.6-xen-sparse/drivers/xen/vscsiback/vscsiback.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/vscsiback/vscsiback.c	Thu Jun 22 04:36:57 2006 +0900
@@ -0,0 +1,384 @@
+/*
+ * Xen Virtual SCSI target driver
+ *
+ * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org>
+ *
+ * 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 St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <linux/version.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_tgt.h>
+#include <scsi/srp.h>
+#include <xen/evtchn.h>
+#include <xen/balloon.h>
+#include <xen/xenbus.h>
+#include <xen/interface/xen.h>
+#include <xen/interface/io/vscsi.h>
+#include <xen/interface/io/ring.h>
+#include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
+#include <asm/hypervisor.h>
+#include "vscsiback_priv.h"
+#include "libsrp.h"
+
+#define eprintk(fmt, args...)					\
+do {								\
+	printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args);	\
+} while (0)
+
+#define dprintk eprintk
+
+static unsigned int debug = 0;
+module_param(debug, int, 0644);
+
+static struct workqueue_struct *vsbkd;
+
+static int req_index(struct vscsiback_info *info, struct vscsi_request *req)
+{
+	return (req - RING_GET_REQUEST(&info->ring, 0));
+}
+
+static int __idx(struct vscsiback_info *info, struct vscsi_request *req,
+		      int idx)
+{
+	return req_index(info, req) * SRP_MAX_INDIRECT + idx;
+}
+
+static unsigned long vaddr(struct vscsiback_info *info,
+			   struct vscsi_request *req, int i)
+{
+	unsigned long vstart =
+		(unsigned long) pfn_to_kaddr(page_to_pfn(info->page));
+
+	return vstart + (__idx(info, req, i) << PAGE_SHIFT);
+}
+
+static int vscsiback_rdma(struct scsi_cmnd *sc, struct scatterlist *sg, int nsg,
+			  struct srp_direct_buf *md, int nmd,
+			  unsigned int rest)
+{
+	struct Scsi_Host *host = (struct Scsi_Host *) sc->host_scribble;
+	struct vscsiback_info *info = (struct vscsiback_info *) host->hostdata;
+	struct gnttab_map_grant_ref map[SRP_MAX_INDIRECT];
+	struct gnttab_unmap_grant_ref unmap[SRP_MAX_INDIRECT];
+	struct vscsi_request *req = (struct vscsi_request *) sc->SCp.ptr;
+	int i, err;
+	char *p, *q;
+
+	for (i = 0; i < nmd; i++) {
+		map[i].host_addr = vaddr(info, req, i);
+		map[i].dom = info->dev->otherend_id;
+		map[i].ref = md[i].key;
+		map[i].flags = GNTMAP_host_map;
+	}
+
+	err = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, nmd);
+
+	for (i = 0; i < nmd; i++)
+		set_phys_to_machine(__pa(vaddr(info, req, i)) >> PAGE_SHIFT,
+				    FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
+
+	p = (char *) vaddr(info, req, 0) + (md->va & ~PAGE_MASK);
+	q = page_address(sg[0].page) + sg[0].offset;
+	if (sc->sc_data_direction == DMA_FROM_DEVICE)
+		memcpy(p, q, rest);
+	else
+		memcpy(q, p, rest);
+
+	for (i = 0; i < nmd; i++) {
+		unmap[i].host_addr = vaddr(info, req, i);
+		unmap[i].dev_bus_addr = 0;
+		unmap[i].handle = map[i].handle;
+	}
+
+	err = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, nmd);
+	return 0;
+}
+
+static int vscsiback_transfer_data(struct scsi_cmnd *sc,
+				   void (*done)(struct scsi_cmnd *))
+{
+	struct vscsi_request *req = (struct vscsi_request *) sc->SCp.ptr;
+	int err;
+
+	err = srp_transfer_data(sc, (struct srp_cmd *) req->buf, vscsiback_rdma);
+	done(sc);
+	return err;
+}
+
+static int vscsiback_cmd_done(struct scsi_cmnd *sc,
+			      void (*done)(struct scsi_cmnd *))
+{
+	struct Scsi_Host *host = (struct Scsi_Host *) sc->host_scribble;
+	struct vscsiback_info *info = (struct vscsiback_info *) host->hostdata;
+	struct vscsi_back_ring *ring = &info->ring;
+	struct vscsi_response *rsp;
+	struct vscsi_request *req = (struct vscsi_request *) sc->SCp.ptr;
+	struct srp_cmd *cmd = (struct srp_cmd *) req->buf;
+	struct srp_rsp *srsp;
+	int notify;
+
+	rsp = RING_GET_RESPONSE(ring, ring->rsp_prod_pvt);
+	srsp = (struct srp_rsp *) rsp->buf;
+	srsp->opcode = SRP_RSP;
+	srsp->tag = cmd->tag;
+	srsp->resp_data_len = 0;
+	srsp->status = NO_SENSE;
+	srsp->data_in_res_cnt = 0;
+	srsp->data_out_res_cnt = 0;
+	srsp->flags &= ~SRP_RSP_FLAG_RSPVALID;
+
+	ring->rsp_prod_pvt++;
+
+	RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(ring, notify);
+
+	notify_remote_via_irq(info->irq);
+
+	done(sc);
+	return 0;
+}
+
+static int vscsiback_eh_abort_handler(struct scsi_cmnd *scmd)
+{
+	BUG_ON(1);
+	return 0;
+}
+
+static struct scsi_host_template vscsiback_sht = {
+	.module			= THIS_MODULE,
+	.name			= "vscsiback",
+	.can_queue		= 64,
+	.sg_tablesize		= SG_ALL,
+	.use_clustering		= DISABLE_CLUSTERING,
+	.transfer_response	= vscsiback_cmd_done,
+	.transfer_data		= vscsiback_transfer_data,
+	.eh_abort_handler	= vscsiback_eh_abort_handler,
+};
+
+static void vscsiback_worker(void *data)
+{
+	struct vscsiback_info *info = data;
+	struct vscsi_back_ring *ring = &info->ring;
+	struct vscsi_request *req;
+	struct srp_cmd *cmd;
+	RING_IDX rc, rp;
+
+	rc = ring->req_cons;
+	rp = ring->sring->req_prod;
+	rmb();
+
+	while ((rc != rp) && !RING_REQUEST_CONS_OVERFLOW(ring, rc)) {
+		eprintk("%u %u\n", rc, rp);
+		req = RING_GET_REQUEST(ring, rc);
+		ring->req_cons = ++rc;
+		cmd = (struct srp_cmd *) req->buf;
+		srp_cmd_perform(info->host, cmd, req);
+	}
+}
+
+irqreturn_t vscsiback_intr(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct vscsiback_info *info = (struct vscsiback_info *) dev_id;
+
+	queue_work(vsbkd, &info->vscsiback_work);
+
+	return IRQ_HANDLED;
+}
+
+static int vscsiback_connect(struct vscsiback_info *info)
+{
+	struct xenbus_device *dev = info->dev;
+	unsigned long ring_ref;
+	unsigned int evtchn;
+	int err;
+
+	err = xenbus_gather(XBT_NULL, dev->otherend, "ring-ref", "%lu",
+			    &ring_ref, "event-channel", "%u", &evtchn, NULL);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "reading %s ring", dev->otherend);
+		return err;
+	}
+
+	return vscsiback_init_sring(info, ring_ref, evtchn);
+}
+
+/* static void vscsiback_frontend_changed(struct xenbus_device *dev, */
+/* 				       enum xenbus_state frontend_state) */
+static void vscsiback_frontend_changed(struct xenbus_device *dev,
+				       XenbusState frontend_state)
+{
+	struct vscsiback_info *info = dev->data;
+	int err;
+
+	dprintk("%p %u %u\n", dev, dev->state, frontend_state);
+	switch (frontend_state) {
+	case XenbusStateInitialising:
+		break;
+
+	case XenbusStateInitialised:
+	case XenbusStateConnected:
+		if (dev->state == XenbusStateConnected)
+			break;
+
+		err = vscsiback_connect(info);
+		if (err)
+			break;
+
+		err = xenbus_switch_state(dev, XenbusStateConnected);
+		if (err)
+			xenbus_dev_fatal(dev, err, "switching to Connected state",
+					 dev->nodename);
+		break;
+
+	case XenbusStateClosing:
+		xenbus_switch_state(dev, XenbusStateClosing);
+		break;
+
+	case XenbusStateClosed:
+		device_unregister(&dev->dev);
+		break;
+
+	case XenbusStateUnknown:
+	case XenbusStateInitWait:
+	default:
+		xenbus_dev_fatal(dev, -EINVAL, "saw state %d at frontend",
+				 frontend_state);
+		break;
+	}
+}
+
+static void vscsiback_backend_changed(struct xenbus_watch *watch,
+				      const char **vec, unsigned int len)
+{
+	struct vscsiback_info *info =
+		container_of(watch, struct vscsiback_info, backend_watch);
+
+	dprintk("%p %u\n", info->dev, info->dev->state);
+
+	/* TODO */
+}
+
+static int vscsiback_probe(struct xenbus_device *dev,
+			   const struct xenbus_device_id *id)
+{
+	int err;
+	unsigned long nr = SRP_CAN_QUEUE * SRP_MAX_INDIRECT;
+	struct Scsi_Host *host;
+	struct vscsiback_info *info;
+
+	dprintk("%p\n", dev);
+
+	host = scsi_host_alloc(&vscsiback_sht, sizeof(struct vscsiback_info));
+	if (!host)
+		return -ENOMEM;
+	err = scsi_tgt_alloc_queue(host);
+	if (err)
+		goto put_host;
+
+	err = scsi_add_host(host, &dev->dev);
+	if (err)
+		goto put_host;
+
+	info = (struct vscsiback_info *) host->hostdata;
+	dev->data = info;
+	info->dev = dev;
+	info->host = host;
+
+	info->page = balloon_alloc_empty_page_range(nr);
+	if (!info->page)
+		goto put_host;
+
+	INIT_WORK(&info->vscsiback_work, vscsiback_worker, info);
+
+	err = xenbus_watch_path2(dev, dev->nodename,
+				 "vscsi-host",
+				 &info->backend_watch,
+				 vscsiback_backend_changed);
+	if (err)
+		goto free_page;
+
+	err = xenbus_switch_state(dev, XenbusStateInitWait);
+	if (err)
+		goto stop_watch;
+
+	return 0;
+
+stop_watch:
+	/* free resource */
+free_page:
+	balloon_dealloc_empty_page_range(info->page, nr);
+put_host:
+	scsi_host_put(host);
+	return err;
+}
+
+static int vscsiback_remove(struct xenbus_device *dev)
+{
+	struct vscsiback_info *info = dev->data;
+	struct Scsi_Host *host = info->host;
+
+	balloon_dealloc_empty_page_range(info->page,
+					 SRP_CAN_QUEUE * SRP_MAX_INDIRECT);
+	scsi_remove_host(host);
+	scsi_host_put(host);
+	return 0;
+}
+
+static struct xenbus_device_id vscsiback_ids[] = {
+	{ "vscsi" },
+	{ "" }
+};
+
+static struct xenbus_driver vscsiback = {
+	.name			= "vscsi",
+	.owner			= THIS_MODULE,
+	.ids			= vscsiback_ids,
+	.probe			= vscsiback_probe,
+	.remove			= vscsiback_remove,
+	.otherend_changed	= vscsiback_frontend_changed
+};
+
+static int __init vscsiback_init(void)
+{
+	int err;
+
+	if (xen_init() < 0)
+		return -ENODEV;
+
+	vsbkd = create_singlethread_workqueue("vscsibkd");
+	if (!vsbkd)
+		return -ENOMEM;
+
+	err = xenbus_register_backend(&vscsiback);
+	if (err)
+		goto destroy_wq;
+	return 0;
+destroy_wq:
+	destroy_workqueue(vsbkd);
+	return err;
+}
+
+module_init(vscsiback_init);
+
+MODULE_AUTHOR("FUJITA Tomonori");
+MODULE_DESCRIPTION("Xen Virtual SCSI target driver");
+MODULE_LICENSE("GPL");
diff -r 2a4377b4361d linux-2.6-xen-sparse/drivers/xen/vscsiback/vscsiback_priv.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/vscsiback/vscsiback_priv.h	Thu Jun 22 04:36:57 2006 +0900
@@ -0,0 +1,23 @@
+struct vscsiback_info {
+	struct xenbus_device *dev;
+	struct Scsi_Host *host;
+	struct xenbus_watch backend_watch;
+
+	unsigned int evtchn;
+	unsigned int irq;
+
+	struct vscsi_back_ring ring;
+	struct vm_struct *ring_area;
+
+	grant_handle_t shmem_handle;
+	grant_ref_t    shmem_ref;
+
+	struct work_struct vscsiback_work;
+	struct page *page;
+};
+
+extern irqreturn_t vscsiback_intr(int, void *, struct pt_regs *);
+
+extern int vscsiback_init_sring(struct vscsiback_info *,
+				unsigned long, unsigned int);
+extern void vscsiback_exit_sring(struct vscsiback_info *);
diff -r 2a4377b4361d linux-2.6-xen-sparse/drivers/xen/vscsifront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/vscsifront/Makefile	Thu Jun 22 04:36:57 2006 +0900
@@ -0,0 +1,1 @@
+obj-$(CONFIG_XEN_VSCSI_FRONTEND)	+= vscsifront.o
diff -r 2a4377b4361d linux-2.6-xen-sparse/drivers/xen/vscsifront/vscsifront.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/vscsifront/vscsifront.c	Thu Jun 22 04:36:57 2006 +0900
@@ -0,0 +1,454 @@
+/*
+ * Xen Virtual SCSI initiator driver
+ *
+ * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org>
+ *
+ * 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 St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <linux/version.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/srp.h>
+#include <xen/evtchn.h>
+#include <xen/xenbus.h>
+#include <xen/interface/xen.h>
+#include <xen/interface/io/vscsi.h>
+#include <xen/interface/io/ring.h>
+#include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
+#include <asm/hypervisor.h>
+
+#define eprintk(fmt, args...)					\
+do {								\
+	printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args);	\
+} while (0)
+
+#define dprintk eprintk
+
+#define SRP_MAX_INDIRECT	((SRP_MAX_IU_LEN -			\
+				  sizeof (struct srp_cmd) -		\
+				  sizeof (struct srp_indirect_buf)) / 16)
+
+static unsigned int debug = 0;
+module_param(debug, int, 0644);
+
+struct vscsifront_info {
+	struct xenbus_device *dev;
+	struct Scsi_Host *host;
+	unsigned int evtchn;
+	unsigned int irq;
+	unsigned long ring_ref;
+	struct vscsi_front_ring ring;
+};
+
+static int map_data_for_srp_cmd(struct vscsifront_info *info,
+				struct scsi_cmnd *sc, struct srp_cmd *cmd)
+{
+	struct scatterlist *sg = sc->request_buffer;
+	grant_ref_t gref_head;
+	int err, i, ref;
+	u8 fmt;
+
+	if (!sg || sc->sc_data_direction == DMA_NONE)
+		return 0;
+
+	err = gnttab_alloc_grant_references(SRP_MAX_INDIRECT, &gref_head);
+	if (err)
+		return -ENOMEM;
+
+	if (sc->use_sg == 1) {
+		struct srp_direct_buf *buf = (void *) cmd->add_data;
+		fmt = SRP_DATA_DESC_DIRECT;
+
+		ref = gnttab_claim_grant_reference(&gref_head);
+		gnttab_grant_foreign_access_ref(ref, info->dev->otherend_id,
+						page_to_phys(sg->page) >> PAGE_SHIFT, 0);
+
+		buf->va = sg->offset;
+		buf->key = ref;
+		buf->len = sg->length;
+
+		dprintk("%llx %u %u\n", (unsigned long long) buf->va, buf->key,
+			buf->len);
+
+	} else {
+/* 		struct srp_indirect_buf *buf = (void *) cmd->add_data; */
+		fmt = SRP_DATA_DESC_INDIRECT;
+
+		/* TODO */
+		BUG();
+		for (i = 0; i < sc->use_sg; i++) {
+		}
+	}
+
+	if (sc->sc_data_direction == DMA_TO_DEVICE)
+		cmd->buf_fmt = fmt << 4;
+	else
+		cmd->buf_fmt = fmt;
+
+	gnttab_free_grant_references(gref_head);
+
+	return 0;
+}
+
+static int vscsifront_queuecommand(struct scsi_cmnd *sc,
+				   void (*done)(struct scsi_cmnd *))
+{
+	struct Scsi_Host *host = sc->device->host;
+	struct vscsifront_info *info = (struct vscsifront_info *) host->hostdata;
+	struct vscsi_request *ring_req;
+	struct vscsi_front_ring *ring = &info->ring;
+	struct srp_cmd *cmd;
+	int err, notify;
+
+	if (info->dev->state != XenbusStateConnected || RING_FULL(ring)) {
+		eprintk("busy %u!\n", info->dev->state);
+		return SCSI_MLQUEUE_HOST_BUSY;
+	}
+	sc->scsi_done = done;
+	sc->result = 0;
+
+	ring_req = RING_GET_REQUEST(ring, ring->req_prod_pvt);
+	cmd = (struct srp_cmd *) ring_req->buf;
+
+	memset(cmd, 0, SRP_MAX_IU_LEN);
+	cmd->opcode = SRP_CMD;
+	int_to_scsilun(sc->device->lun, (struct scsi_lun *) &cmd->lun);
+	cmd->tag = (long) sc;
+	memcpy(cmd->cdb, sc->cmnd, sc->cmd_len);
+
+	err = map_data_for_srp_cmd(info, sc, cmd);
+	if (err)
+		return SCSI_MLQUEUE_HOST_BUSY;
+
+	ring->req_prod_pvt++;
+
+	RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(ring, notify);
+	notify_remote_via_irq(info->irq);
+
+	return 0;
+}
+
+static int vscsifront_eh_abort_handler(struct scsi_cmnd *sc)
+{
+	BUG();
+	return 0;
+}
+
+static void vscsifront_cmd_done(struct vscsifront_info *info, int idx)
+{
+	struct vscsi_front_ring *ring = &info->ring;
+	struct vscsi_request *ring_req;
+	struct srp_cmd *cmd;
+	struct scsi_cmnd *sc;
+
+	ring_req = RING_GET_REQUEST(ring, idx);
+	cmd = (struct srp_cmd *) ring_req->buf;
+	sc = (struct scsi_cmnd *) (long) cmd->tag;
+
+	if (!sc->request_buffer || (sc->sc_data_direction != DMA_TO_DEVICE &&
+				    sc->sc_data_direction != DMA_FROM_DEVICE))
+		return;
+
+	if (sc->use_sg == 1) {
+		struct srp_direct_buf *buf;
+		buf = (void *) cmd->add_data;
+		gnttab_end_foreign_access(buf->key, 0, 0UL);
+	} else {
+		/* TODO */
+	}
+}
+
+static irqreturn_t vscsifront_intr(int irq, void *dev_id,
+				   struct pt_regs *ptregs)
+{
+	struct vscsifront_info *info = (struct vscsifront_info *) dev_id;
+	struct vscsi_front_ring *ring = &info->ring;
+	struct vscsi_response *ring_res;
+	struct scsi_cmnd *sc;
+	struct srp_rsp *rsp;
+	int i, rp;
+
+	if (info->dev->state != XenbusStateConnected)
+		return IRQ_HANDLED;
+
+again:
+	rp = info->ring.sring->rsp_prod;
+	rmb();
+
+	for (i = info->ring.rsp_cons; i != rp; i++) {
+		ring_res = RING_GET_RESPONSE(ring, i);
+
+		rsp = (struct srp_rsp *) ring_res->buf;
+		sc = ((void *) (unsigned long) rsp->tag);
+		sc->result = rsp->status;
+
+		vscsifront_cmd_done(info, i);
+
+		if (rsp->flags & SRP_RSP_FLAG_SNSVALID) {
+			memcpy(sc->sense_buffer, rsp->data +
+			       be32_to_cpu(rsp->resp_data_len),
+			       min_t(int, be32_to_cpu(rsp->sense_data_len),
+				     SCSI_SENSE_BUFFERSIZE));
+		}
+
+		if (rsp->flags & (SRP_RSP_FLAG_DOOVER | SRP_RSP_FLAG_DOUNDER))
+			sc->resid = be32_to_cpu(rsp->data_out_res_cnt);
+		else if (rsp->flags & (SRP_RSP_FLAG_DIOVER | SRP_RSP_FLAG_DIUNDER))
+			sc->resid = be32_to_cpu(rsp->data_in_res_cnt);
+
+		sc->scsi_done(sc);
+	}
+
+	info->ring.rsp_cons = i;
+	if (i != info->ring.req_prod_pvt) {
+		int more_to_do;
+		RING_FINAL_CHECK_FOR_RESPONSES(ring, more_to_do);
+		if (more_to_do)
+			goto again;
+	} else
+		ring->sring->rsp_event = i + 1;
+
+	return IRQ_HANDLED;
+}
+
+static int vscsifront_alloc_ring(struct vscsifront_info *info)
+{
+	struct xenbus_device *dev = info->dev;
+	struct vscsi_sring *sring;
+	int err = -ENOMEM;
+
+	sring = (struct vscsi_sring *) __get_free_page(GFP_KERNEL);
+	if (!sring) {
+		xenbus_dev_fatal(dev, err, "fail to allocate shared ring");
+		return err;
+	}
+
+	SHARED_RING_INIT(sring);
+	FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);
+	dprintk("%u\n", RING_SIZE(&info->ring));
+
+	err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
+	if (err < 0) {
+		xenbus_dev_fatal(dev, err, "fail to grant shared ring");
+		goto free_sring;
+	}
+	info->ring_ref = err;
+
+	err = xenbus_alloc_evtchn(dev, &info->evtchn);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "fail to allocate evtchn");
+		return err;
+	}
+
+	err = bind_evtchn_to_irqhandler(info->evtchn, vscsifront_intr,
+					SA_SAMPLE_RANDOM, "vscsifront", info);
+	if (err <= 0) {
+		xenbus_dev_fatal(dev, err, "bind_evtchn_to_irqhandler failed");
+		goto fail;
+	}
+	info->irq = err;
+
+	return 0;
+fail:
+	/* free resource */
+free_sring:
+	free_page((unsigned long) sring);
+
+	return err;
+}
+
+static int vscsifront_init_ring(struct vscsifront_info *info)
+{
+	struct xenbus_device *dev = info->dev;
+	xenbus_transaction_t xbt;
+	int err;
+
+	dprintk("");
+
+	err = vscsifront_alloc_ring(info);
+	if (err)
+		return err;
+	dprintk("%lu %u\n", info->ring_ref, info->evtchn);
+
+again:
+	err = xenbus_transaction_start(&xbt);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "starting transaction");
+	}
+
+	err = xenbus_printf(xbt, dev->nodename, "ring-ref", "%lu",
+			    info->ring_ref);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "%s", "writing ring-ref");
+		goto fail;
+	}
+
+	err = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
+			    info->evtchn);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "%s", "writing event-channel");
+		goto fail;
+	}
+
+	err = xenbus_transaction_end(xbt, 0);
+	if (err) {
+		if (err == -EAGAIN)
+			goto again;
+		xenbus_dev_fatal(dev, err, "completing transaction");
+	} else
+		xenbus_switch_state(dev, XenbusStateInitialised);
+
+	return 0;
+fail:
+	xenbus_transaction_end(xbt, 1);
+	/* free resource */
+	return err;
+}
+
+static struct scsi_host_template vscsifront_sht = {
+	.module			= THIS_MODULE,
+	.name			= "vscsifront",
+	.queuecommand		= vscsifront_queuecommand,
+	.eh_abort_handler	= vscsifront_eh_abort_handler,
+	.cmd_per_lun		= 16,
+	.can_queue		= 8,
+	.this_id 		= -1,
+	.sg_tablesize		= SRP_MAX_INDIRECT,
+	.use_clustering		= ENABLE_CLUSTERING,
+};
+
+static int vscsifront_probe(struct xenbus_device *dev,
+			    const struct xenbus_device_id *id)
+{
+	struct Scsi_Host *host;
+	struct vscsifront_info *info;
+	int err = -ENOMEM;
+
+	host = scsi_host_alloc(&vscsifront_sht, sizeof(*info));
+	if (!host) {
+		xenbus_dev_fatal(dev, err, "fail to allocate scsi host");
+		return err;
+	}
+	info = (struct vscsifront_info *) host->hostdata;
+	dev->data = info;
+	info->dev = dev;
+	info->host = host;
+
+	err = vscsifront_init_ring(info);
+	if (err)
+		scsi_host_put(host);
+
+	return err;
+}
+
+static int vscsifront_connect(struct vscsifront_info *info)
+{
+	struct xenbus_device *dev = info->dev;
+	struct Scsi_Host *host = info->host;
+	int err = -ENOMEM;
+
+	dprintk("%u\n", dev->state);
+	if (dev->state == XenbusStateConnected)
+		return 0;
+
+	xenbus_switch_state(dev, XenbusStateConnected);
+
+	host->max_id = 1;
+	host->max_channel = 0;
+
+	err = scsi_add_host(host, &dev->dev);
+	if (err) {
+		eprintk("fail to add scsi host %d\n", err);
+		return err;
+	}
+	scsi_scan_host(host);
+
+	return 0;
+}
+
+static int vscsifront_remove(struct xenbus_device *dev)
+{
+	struct vscsifront_info *info = dev->data;
+
+	scsi_remove_host(info->host);
+	scsi_host_put(info->host);
+
+	return 0;
+}
+
+static void vscsifront_backend_changed(struct xenbus_device *dev,
+				       XenbusState backend_state)
+{
+	struct vscsifront_info *info = dev->data;
+
+	dprintk("%p %u %u\n", dev, dev->state, backend_state);
+
+	switch (backend_state) {
+	case XenbusStateUnknown:
+	case XenbusStateInitialising:
+	case XenbusStateInitWait:
+	case XenbusStateInitialised:
+	case XenbusStateClosed:
+		break;
+
+	case XenbusStateConnected:
+		vscsifront_connect(info);
+		break;
+
+	case XenbusStateClosing:
+		break;
+	}
+}
+
+static struct xenbus_device_id vscsifront_ids[] = {
+	{ "vscsi" },
+	{ "" }
+};
+
+static struct xenbus_driver vscsifront = {
+	.name			= "vscsi",
+	.owner			= THIS_MODULE,
+	.ids			= vscsifront_ids,
+	.probe			= vscsifront_probe,
+	.remove			= vscsifront_remove,
+/* 	.resume			= vscsifront_resume, */
+	.otherend_changed	= vscsifront_backend_changed,
+};
+
+static int __init vscsifront_init(void)
+{
+	if (xen_init() < 0)
+		return -ENODEV;
+
+	return xenbus_register_frontend(&vscsifront);
+}
+static void vscsifront_exit(void)
+{
+	return xenbus_unregister_driver(&vscsifront);
+}
+
+module_init(vscsifront_init);
+module_exit(vscsifront_exit);
+
+MODULE_AUTHOR("FUJITA Tomonori");
+MODULE_DESCRIPTION("Xen Virtual SCSI initiator driver");
+MODULE_LICENSE("GPL");
diff -r 2a4377b4361d xen/include/public/io/vscsi.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/include/public/io/vscsi.h	Thu Jun 22 04:36:57 2006 +0900
@@ -0,0 +1,23 @@
+#ifndef __XEN__PUBLIC_IO_VSCSIIF_H__
+#define __XEN__PUBLIC_IO_VSCSIIF_H__
+
+#include "ring.h"
+
+#define SRP_MAX_IU_LEN	256
+#define SRP_CAN_QUEUE 8
+
+struct vscsi_request {
+	char buf[SRP_MAX_IU_LEN];
+};
+
+struct vscsi_response {
+	char buf[sizeof(struct srp_rsp)];
+};
+
+DEFINE_RING_TYPES(vscsi, struct vscsi_request, struct vscsi_response);
+
+#define SRP_MAX_INDIRECT	((SRP_MAX_IU_LEN -			\
+				  sizeof (struct srp_cmd) -		\
+				  sizeof (struct srp_indirect_buf)) / 16)
+
+#endif

^ permalink raw reply	[relevance 5%]

* [PATCH] [XM-TEST] 03_memset_random_pos double console
@ 2006-06-22 20:05 11% James Dykman
  0 siblings, 0 replies; 200+ results
From: James Dykman @ 2006-06-22 20:05 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 878 bytes --]

03_memset_random_pos connects to the console twice, which now causes a 
console timeout.
The test has been broken since  xen-unstable cset 9929. I checked the 
cset; this is the only test 
broken this way.

Jim
------
Remove second console attach in 03_memset_random_pos

Signed-off-by: Jim Dykman <dykman@us.ibm.com>
 
diff -r 2a99292b1a8a tools/xm-test/tests/memset/03_memset_random_pos.py
--- a/tools/xm-test/tests/memset/03_memset_random_pos.py        Mon Jun 19 
14:44:34 2006 +0100
+++ b/tools/xm-test/tests/memset/03_memset_random_pos.py        Thu Jun 22 
15:24:17 2006 -0400
@@ -22,12 +22,6 @@ except DomainError, e:
     FAIL(str(e))

 times = random.randint(10,50)
-
-try:
-    console = XmConsole(domain.getName())
-    console.sendInput("input")
-except ConsoleError, e:
-    FAIL(str(e))

 try:
     run = console.runCmd("cat /proc/xen/balloon | grep Current");



[-- Attachment #2: 03_memset_timeout.patch --]
[-- Type: application/octet-stream, Size: 542 bytes --]

diff -r 2a99292b1a8a tools/xm-test/tests/memset/03_memset_random_pos.py
--- a/tools/xm-test/tests/memset/03_memset_random_pos.py	Mon Jun 19 14:44:34 2006 +0100
+++ b/tools/xm-test/tests/memset/03_memset_random_pos.py	Thu Jun 22 15:24:17 2006 -0400
@@ -22,12 +22,6 @@ except DomainError, e:
     FAIL(str(e))
 
 times = random.randint(10,50)
-
-try:
-    console = XmConsole(domain.getName())
-    console.sendInput("input")
-except ConsoleError, e:
-    FAIL(str(e))
 
 try:
     run = console.runCmd("cat /proc/xen/balloon | grep Current");

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 11%]

* [PATCH 1/1] Output Virtual Block Device requests information ver. 2. Add information to sysfs.
@ 2006-06-23 11:37  6% Satoshi Uchida
  0 siblings, 0 replies; 200+ results
From: Satoshi Uchida @ 2006-06-23 11:37 UTC (permalink / raw)
  To: 'Keir Fraser', xen-devel

[-- Attachment #1: Type: text/plain, Size: 988 bytes --]

This patch adds VBD statistic informations to sysfs.

It creates 'statistics' directory under each VBD directory, and
makes a sysfs file for each statistical information of VBD.

Examples are as follows.
By applying this patch, sysfs creates "statistics" directory under the "vbd-*" directory.
The "statistics" directory includes three statistical information files  of VBD;
 oo_req, rd_req, wr_req. 

  [root@Domain-0 ~]# ls /sys/devices/xen-backend/vbd-1-2049/
  bus      driver  nodename         power       uevent
  devtype  mode    physical_device  statistics
  [root@Domain-0 ~]# ls /sys/devices/xen-backend/vbd-1-2049/statistics/
  oo_req  rd_req  wr_req
  [root@Domain-0 ~]# cat /sys/devices/xen-backend/vbd-1-2049/statistics/oo_req
  0
  [root@Domain-0 ~]# cat /sys/devices/xen-backend/vbd-1-2049/statistics/rd_req
  1592
  [root@Domain-0 ~]# cat /sys/devices/xen-backend/vbd-1-2049/statistics/wr_req
  565
  [root@Domain-0 ~]#


Thanks,
Satoshi UCHIDA

[-- Attachment #2: Add_VBD_info_to_sysfs.patch --]
[-- Type: application/octet-stream, Size: 6017 bytes --]

# HG changeset patch
# User Satoshi UCHIDA <s-uchida@ap.jp.nec.com>
# Node ID 7b69444493c10e0ee7fbdd787cb28517a75c77f8
# Parent  161473836da3ccf922f44e910f8b5c01c709d1e6
Output VBD request information into sysfs.

   Add group "statistics" and output each information into its group.
   Output information are oo_req, rd_req, and wr_req.

   Signed-off-by: Satoshi UCHIDA <s-uchida@ap.jp.nec.com>

diff -r 161473836da3 -r 7b69444493c1 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Wed Jun 14 22:15:13 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Fri Jun 23 20:18:11 2006 +0900
@@ -40,6 +40,7 @@
 #include <linux/list.h>
 #include <xen/balloon.h>
 #include <asm/hypervisor.h>
+#include <xen/xenbus.h>
 #include "common.h"
 
 /*
@@ -191,7 +192,7 @@ static void fast_flush_area(pending_req_
 
 static void print_stats(blkif_t *blkif)
 {
-	printk(KERN_DEBUG "%s: oo %3d  |  rd %4d  |  wr %4d\n",
+	printk(KERN_DEBUG "%s: oo %3lu  |  rd %4lu  |  wr %4lu\n",
 	       current->comm, blkif->st_oo_req,
 	       blkif->st_rd_req, blkif->st_wr_req);
 	blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000);
@@ -463,6 +464,54 @@ static void dispatch_rw_block_io(blkif_t
 	free_req(pending_req);
 } 
 
+
+
+/****************************************************************
+ *  sysfs interface for VBD I/O requests
+ */
+
+#ifdef CONFIG_SYSFS
+
+VBD_SHOW(oo_req, fmt_ulong, be->blkif->st_oo_req);
+VBD_SHOW(rd_req, fmt_ulong, be->blkif->st_rd_req);
+VBD_SHOW(wr_req, fmt_ulong, be->blkif->st_wr_req);
+
+static struct attribute *vbdstat_attrs[] = {
+	&dev_attr_oo_req.attr,
+	&dev_attr_rd_req.attr,
+	&dev_attr_wr_req.attr,
+	NULL
+};
+
+static struct attribute_group vbdstat_group = {
+	.name = "statistics",
+	.attrs = vbdstat_attrs,
+};
+
+int xenvbd_sysfs_addif(struct xenbus_device *dev)
+{
+	int error = 0;
+
+	error = sysfs_create_group(&dev->dev.kobj,
+				   &vbdstat_group);
+	if (error)
+		goto fail;
+
+	return 0;
+
+ fail:
+	sysfs_remove_group(&dev->dev.kobj,
+			    &vbdstat_group);
+	return error;
+}
+
+void xenvbd_sysfs_delif(struct xenbus_device *dev)
+{
+       	sysfs_remove_group(&dev->dev.kobj,
+			   &vbdstat_group);
+}
+
+#endif /* CONFIG_SYSFS */
 
 
 /******************************************************************
diff -r 161473836da3 -r 7b69444493c1 linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Wed Jun 14 22:15:13 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Fri Jun 23 20:18:11 2006 +0900
@@ -44,6 +44,7 @@
 #include <xen/interface/io/ring.h>
 #include <xen/gnttab.h>
 #include <xen/driver_util.h>
+#include <xen/xenbus.h>
 
 #define DPRINTK(_f, _a...)			\
 	pr_debug("(file=%s, line=%d) " _f,	\
@@ -84,15 +85,25 @@ typedef struct blkif_st {
 
 	/* statistics */
 	unsigned long       st_print;
-	int                 st_rd_req;
-	int                 st_wr_req;
-	int                 st_oo_req;
+	unsigned long       st_rd_req;
+	unsigned long       st_wr_req;
+	unsigned long       st_oo_req;
 
 	wait_queue_head_t waiting_to_free;
 
 	grant_handle_t shmem_handle;
 	grant_ref_t    shmem_ref;
 } blkif_t;
+
+struct backend_info
+{
+	struct xenbus_device *dev;
+	blkif_t *blkif;
+	struct xenbus_watch backend_watch;
+	unsigned major;
+	unsigned minor;
+	char *mode;
+};
 
 blkif_t *blkif_alloc(domid_t domid);
 void blkif_free(blkif_t *blkif);
@@ -130,4 +141,31 @@ irqreturn_t blkif_be_int(int irq, void *
 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
 int blkif_schedule(void *arg);
 
+
+#ifdef CONFIG_SYSFS
+
+struct xenbus_device;
+int xenvbd_sysfs_addif(struct xenbus_device *dev);
+void xenvbd_sysfs_delif(struct xenbus_device *dev);
+
+static const char fmt_ulong[] = "%lu\n";
+
+#define VBD_SHOW(name, format, args...)				     \
+static ssize_t show_##name(struct device *_dev,                      \
+                           struct device_attribute *attr, char *buf) \
+{                                                                    \
+	struct xenbus_device *dev = to_xenbus_device(_dev);          \
+	struct backend_info *be = dev->dev.driver_data;              \
+	                                                             \
+	return sprintf(buf, format, ##args);                         \
+}                                                                    \
+DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
+
+#else
+
+#define xenvbd_sysfs_addif(dev) do { } while(0)
+#define xenvbd_sysfs_delif(dev) do { } while(0)
+
+#endif
+
 #endif /* __BLKIF__BACKEND__COMMON_H__ */
diff -r 161473836da3 -r 7b69444493c1 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Wed Jun 14 22:15:13 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Jun 23 20:18:11 2006 +0900
@@ -27,16 +27,6 @@
 #define DPRINTK(fmt, args...)				\
 	pr_debug("blkback/xenbus (%s:%d) " fmt ".\n",	\
 		 __FUNCTION__, __LINE__, ##args)
-
-struct backend_info
-{
-	struct xenbus_device *dev;
-	blkif_t *blkif;
-	struct xenbus_watch backend_watch;
-	unsigned major;
-	unsigned minor;
-	char *mode;
-};
 
 static void connect(struct backend_info *);
 static int connect_ring(struct backend_info *);
@@ -114,7 +104,8 @@ static int blkback_remove(struct xenbus_
 
 	device_remove_file(&dev->dev, &dev_attr_physical_device);
 	device_remove_file(&dev->dev, &dev_attr_mode);
-
+	xenvbd_sysfs_delif(dev);
+   
 	kfree(be);
 	dev->dev.driver_data = NULL;
 	return 0;
@@ -236,6 +227,7 @@ static void backend_changed(struct xenbu
 
 		device_create_file(&dev->dev, &dev_attr_physical_device);
 		device_create_file(&dev->dev, &dev_attr_mode);
+		xenvbd_sysfs_addif(dev);
 
 		/* We're potentially connected now */
 		update_blkif_status(be->blkif); 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 6%]

* [PATCH] balloon: don't talk about low/high memory when there is no such distinction
@ 2006-06-23 12:26 15% Jan Beulich
    0 siblings, 1 reply; 200+ results
From: Jan Beulich @ 2006-06-23 12:26 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 85 bytes --]

.. in order to not confuse people.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

[-- Attachment #2: xenlinux-balloon-no-highmem.patch --]
[-- Type: text/plain, Size: 1156 bytes --]

Index: head-2006-06-13/drivers/xen/balloon/balloon.c
===================================================================
--- head-2006-06-13.orig/drivers/xen/balloon/balloon.c	2006-06-14 10:14:15.000000000 +0200
+++ head-2006-06-13/drivers/xen/balloon/balloon.c	2006-06-16 17:15:55.000000000 +0200
@@ -492,11 +492,20 @@ static int balloon_read(char *page, char
 		page,
 		"Current allocation: %8lu kB\n"
 		"Requested target:   %8lu kB\n"
+#ifdef CONFIG_HIGHMEM
 		"Low-mem balloon:    %8lu kB\n"
 		"High-mem balloon:   %8lu kB\n"
+#else
+		"Balloon:            %8lu kB\n"
+#endif
 		"Xen hard limit:     ",
 		PAGES2KB(current_pages), PAGES2KB(target_pages), 
+#ifdef CONFIG_HIGHMEM
 		PAGES2KB(balloon_low), PAGES2KB(balloon_high));
+#else
+		PAGES2KB(balloon_low));
+	WARN_ON(balloon_high);
+#endif
 
 	if (hard_limit != ~0UL) {
 		len += sprintf(
@@ -528,9 +537,6 @@ static int __init balloon_init(void)
 	current_pages = min(xen_start_info->nr_pages, max_pfn);
 	totalram_pages = current_pages;
 	target_pages  = current_pages;
-	balloon_low   = 0;
-	balloon_high  = 0;
-	driver_pages  = 0UL;
 	hard_limit    = ~0UL;
 
 	init_timer(&balloon_timer);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 15%]

* [PATCH] balloon: don't fail reservation changes with -ENOMEM
@ 2006-06-23 12:33 14% Jan Beulich
  0 siblings, 0 replies; 200+ results
From: Jan Beulich @ 2006-06-23 12:33 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 141 bytes --]

Add fallback code so that e.g. a domain ballooned too far down can still
(slowly) recover.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

[-- Attachment #2: xenlinux-balloon-no-enomem.patch --]
[-- Type: text/plain, Size: 2804 bytes --]

Index: head-2006-06-13/drivers/xen/balloon/balloon.c
===================================================================
--- head-2006-06-13.orig/drivers/xen/balloon/balloon.c	2006-06-14 10:14:07.000000000 +0200
+++ head-2006-06-13/drivers/xen/balloon/balloon.c	2006-06-14 10:14:15.000000000 +0200
@@ -172,7 +172,7 @@ static unsigned long current_target(void
 
 static int increase_reservation(unsigned long nr_pages)
 {
-	unsigned long *frame_list, pfn, i, flags;
+	unsigned long *frame_list, frame, pfn, i, flags;
 	struct page   *page;
 	long           rc;
 	struct xen_memory_reservation reservation = {
@@ -185,8 +185,11 @@ static int increase_reservation(unsigned
 		nr_pages = PAGE_SIZE / sizeof(unsigned long);
 
 	frame_list = (unsigned long *)__get_free_page(GFP_KERNEL);
-	if (frame_list == NULL)
-		return -ENOMEM;
+	if (frame_list == NULL) {
+		frame_list = &frame;
+		if (nr_pages > 1)
+			nr_pages = 1;
+	}
 
 	balloon_lock(flags);
 
@@ -202,14 +205,17 @@ static int increase_reservation(unsigned
 	rc = HYPERVISOR_memory_op(
 		XENMEM_populate_physmap, &reservation);
 	if (rc < nr_pages) {
-		int ret;
-		/* We hit the Xen hard limit: reprobe. */
-		set_xen_guest_handle(reservation.extent_start, frame_list);
-		reservation.nr_extents   = rc;
-		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
-				&reservation);
-		BUG_ON(ret != rc);
-		hard_limit = current_pages + rc - driver_pages;
+		if (rc > 0) {
+			int ret;
+
+			/* We hit the Xen hard limit: reprobe. */
+			reservation.nr_extents = rc;
+			ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
+					&reservation);
+			BUG_ON(ret != rc);
+		}
+		if (rc >= 0)
+			hard_limit = current_pages + rc - driver_pages;
 		goto out;
 	}
 
@@ -247,14 +253,15 @@ static int increase_reservation(unsigned
  out:
 	balloon_unlock(flags);
 
-	free_page((unsigned long)frame_list);
+	if (frame_list != &frame)
+		free_page((unsigned long)frame_list);
 
 	return 0;
 }
 
 static int decrease_reservation(unsigned long nr_pages)
 {
-	unsigned long *frame_list, pfn, i, flags;
+	unsigned long *frame_list, frame, pfn, i, flags;
 	struct page   *page;
 	void          *v;
 	int            need_sleep = 0;
@@ -269,8 +276,11 @@ static int decrease_reservation(unsigned
 		nr_pages = PAGE_SIZE / sizeof(unsigned long);
 
 	frame_list = (unsigned long *)__get_free_page(GFP_KERNEL);
-	if (frame_list == NULL)
-		return -ENOMEM;
+	if (frame_list == NULL) {
+		frame_list = &frame;
+		if (nr_pages > 1)
+			nr_pages = 1;
+	}
 
 	for (i = 0; i < nr_pages; i++) {
 		if ((page = alloc_page(GFP_HIGHUSER)) == NULL) {
@@ -321,7 +331,8 @@ static int decrease_reservation(unsigned
 
 	balloon_unlock(flags);
 
-	free_page((unsigned long)frame_list);
+	if (frame_list != &frame)
+		free_page((unsigned long)frame_list);
 
 	return need_sleep;
 }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 14%]

* Re: balloon.py unaware of pages on page_scrub_list
  @ 2006-06-23 18:51  7%   ` Charles Coffing
  0 siblings, 0 replies; 200+ results
From: Charles Coffing @ 2006-06-23 18:51 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1772 bytes --]

Keir,

Attached is a patch that makes the ballooning logic in xend aware of
pages that are on the page scrub list.  This fixes the case where
crashing/restarting a domain can cause dom0 to balloon more than
necessary.

I changed the physinfo dictionary in Python to be in KiB, rather than
MiB, to avoid accumulating ugly rounding errors.  I tried to avoid
changing units anywhere else.

The patch is against xen-unstable.  It applies and works against
xen-3.0-testing also (in fact that's where I did most of my testing) but
I don't know if you want to apply it there.  I changed the dom0_physinfo
in a non-backwards-compatible way.  Looked nicer to me to group the
*_pages fields together, but that's probably not something you'd want to
do in 3.0.2...  your call.

Thanks,
Charles

Signed-off-by: Charles Coffing <ccoffing@novell.com>


On Tue, Jun 20, 2006 at  1:20 AM, Keir Fraser
<Keir.Fraser@cl.cam.ac.uk> wrote: 
> On 19 Jun 2006, at 23:15, Charles Coffing wrote:
> 
>> Would it make sense to give this information to balloon.py, and
apply 
>> some heuristics?  Perhaps xend should wait for the scrub list to go
to 
>> zero before trying to balloon.  Or maybe it should consider that 
>> memory as free, and only try to balloon (needed -  to_scrub).
>>
>> The most obvious way (to me) to get that information to xend is via

>> DOM0_PHYSINFO.  That way, the number of free pages and the number of

>> pages to scrub can be gotten atomically.
>>
>> Thoughts?
>>
>> I volunteer to code and test this if there's some agreement on how
it 
>> should be done.
> 
> Your approach sounds fine to me.
> 
>   --  Keir
> 
> 
> _______________________________________________
> Xen- devel mailing list
> Xen- devel@lists.xensource.com
> http://lists.xensource.com/xen- devel



[-- Attachment #2: xen-scrub-pages.diff --]
[-- Type: application/octet-stream, Size: 11781 bytes --]

diff -ru xen-unstable.hg~/tools/python/xen/lowlevel/xc/xc.c xen-unstable.hg/tools/python/xen/lowlevel/xc/xc.c
--- xen-unstable.hg~/tools/python/xen/lowlevel/xc/xc.c	2006-06-09 16:21:40.000000000 -0600
+++ xen-unstable.hg/tools/python/xen/lowlevel/xc/xc.c	2006-06-23 10:03:14.000000000 -0600
@@ -582,6 +582,12 @@
 }
 
 
+static unsigned long pages_to_kib(unsigned long pages)
+{
+    return pages * (XC_PAGE_SIZE / 1024);
+}
+
+
 static PyObject *pyxc_pages_to_kib(XcObject *self, PyObject *args)
 {
     unsigned long pages;
@@ -589,13 +595,7 @@
     if (!PyArg_ParseTuple(args, "l", &pages))
         return NULL;
 
-    return PyLong_FromUnsignedLong(pages * (XC_PAGE_SIZE / 1024));
-}
-
-
-static unsigned long pages_to_mb(unsigned long pages)
-{
-    return (pages * (XC_PAGE_SIZE / 1024) + 1023) / 1024;
+    return PyLong_FromUnsignedLong(pages_to_kib(pages));
 }
 
 
@@ -618,13 +618,14 @@
     if(q>cpu_cap)
         *(q-1)=0;
 
-    return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:i,s:s}",
+    return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:l,s:i,s:s}",
                          "threads_per_core", info.threads_per_core,
                          "cores_per_socket", info.cores_per_socket,
                          "sockets_per_node", info.sockets_per_node,
                          "nr_nodes",         info.nr_nodes,
-                         "total_memory",     pages_to_mb(info.total_pages),
-                         "free_memory",      pages_to_mb(info.free_pages),
+                         "total_memory",     pages_to_kib(info.total_pages),
+                         "free_memory",      pages_to_kib(info.free_pages),
+                         "scrub_memory",     pages_to_kib(info.scrub_pages),
                          "cpu_khz",          info.cpu_khz,
                          "hw_caps",          cpu_cap);
 }
diff -ru xen-unstable.hg~/tools/python/xen/xend/balloon.py xen-unstable.hg/tools/python/xen/xend/balloon.py
--- xen-unstable.hg~/tools/python/xen/xend/balloon.py	2006-06-09 16:21:40.000000000 -0600
+++ xen-unstable.hg/tools/python/xen/xend/balloon.py	2006-06-23 10:03:14.000000000 -0600
@@ -29,8 +29,6 @@
 
 PROC_XEN_BALLOON = '/proc/xen/balloon'
 
-BALLOON_OUT_SLACK = 1 # MiB.  We need this because the physinfo details are
-                      # rounded.
 RETRY_LIMIT = 10
 RETRY_LIMIT_INCR = 5
 ##
@@ -68,22 +66,22 @@
         f.close()
 
 def get_dom0_current_alloc():
-    """Returns the current memory allocation (in MiB) of dom0."""
+    """Returns the current memory allocation (in KiB) of dom0."""
 
     kb = _get_proc_balloon(labels['current'])
     if kb == None:
         raise VmError('Failed to query current memory allocation of dom0.')
-    return kb / 1024
+    return kb
 
 def get_dom0_target_alloc():
-    """Returns the target memory allocation (in MiB) of dom0."""
+    """Returns the target memory allocation (in KiB) of dom0."""
 
     kb = _get_proc_balloon(labels['target'])
     if kb == None:
         raise VmError('Failed to query target memory allocation of dom0.')
-    return kb / 1024
+    return kb
 
-def free(required):
+def free(need_mem):
     """Balloon out memory from the privileged domain so that there is the
     specified required amount (in KiB) free.
     """
@@ -92,9 +90,10 @@
     # to balloon out to free some up.  Memory freed by a destroyed domain may
     # not appear in the free_memory field immediately, because it needs to be
     # scrubbed before it can be released to the free list, which is done
-    # asynchronously by Xen; ballooning is asynchronous also.  No matter where
-    # we expect the free memory to come from, therefore, we need to wait for
-    # it to become available.
+    # asynchronously by Xen; ballooning is asynchronous also.  Such memory
+    # does, however, need to be accounted for when calculating how much dom0
+    # needs to balloon.  No matter where we expect the free memory to come
+    # from, we need to wait for it to become available.
     #
     # We are not allowed to balloon below dom0_min_mem, or if dom0_min_mem
     # is 0, we cannot balloon at all.  Memory can still become available
@@ -108,43 +107,49 @@
     # usage, so we recheck the required alloc each time around the loop, but
     # track the last used value so that we don't trigger too many watches.
 
-    need_mem = (required + 1023) / 1024 + BALLOON_OUT_SLACK
-
     xroot = XendRoot.instance()
     xc = xen.lowlevel.xc.xc()
 
     try:
-        dom0_min_mem = xroot.get_dom0_min_mem()
+        dom0_min_mem = xroot.get_dom0_min_mem() * 1024
 
         retries = 0
         sleep_time = SLEEP_TIME_GROWTH
         last_new_alloc = None
         rlimit = RETRY_LIMIT
         while retries < rlimit:
-            free_mem = xc.physinfo()['free_memory']
+            physinfo = xc.physinfo()
+            free_mem = physinfo['free_memory']
+            scrub_mem = physinfo['scrub_memory']
 
             if free_mem >= need_mem:
-                log.debug("Balloon: free %d; need %d; done.", free_mem,
-                          need_mem)
+                log.debug("Balloon: %d KiB free; need %d; done.",
+                          free_mem, need_mem)
                 return
 
             if retries == 0:
-                rlimit += ((need_mem - free_mem)/1024) * RETRY_LIMIT_INCR
-                log.debug("Balloon: free %d; need %d; retries: %d.", 
-                          free_mem, need_mem, rlimit)
+                rlimit += ((need_mem - free_mem)/1024/1024) * RETRY_LIMIT_INCR
+                log.debug("Balloon: %d KiB free; %d to scrub; need %d; retries: %d.",
+                          free_mem, scrub_mem, need_mem, rlimit)
 
             if dom0_min_mem > 0:
                 dom0_alloc = get_dom0_current_alloc()
-                new_alloc = dom0_alloc - (need_mem - free_mem)
+                new_alloc = dom0_alloc - (need_mem - free_mem - scrub_mem)
 
-                if (new_alloc >= dom0_min_mem and
-                    new_alloc != last_new_alloc):
-                    log.debug("Balloon: setting dom0 target to %d.",
-                              new_alloc)
-                    dom0 = XendDomain.instance().privilegedDomain()
-                    dom0.setMemoryTarget(new_alloc)
-                    last_new_alloc = new_alloc
-                    # Continue to retry, waiting for ballooning.
+                if free_mem + scrub_mem >= need_mem:
+                    if last_new_alloc == None:
+                        log.debug("Balloon: waiting on scrubbing")
+                        last_new_alloc = dom0_alloc
+                else:
+                    if (new_alloc >= dom0_min_mem and
+                        new_alloc != last_new_alloc):
+                        new_alloc_mb = new_alloc / 1024  # Round down
+                        log.debug("Balloon: setting dom0 target to %d MiB.",
+                                  new_alloc_mb)
+                        dom0 = XendDomain.instance().privilegedDomain()
+                        dom0.setMemoryTarget(new_alloc_mb)
+                        last_new_alloc = new_alloc
+                # Continue to retry, waiting for ballooning or scrubbing.
 
             time.sleep(sleep_time)
             if retries < 2 * RETRY_LIMIT:
@@ -154,15 +159,15 @@
         # Not enough memory; diagnose the problem.
         if dom0_min_mem == 0:
             raise VmError(('Not enough free memory and dom0_min_mem is 0, so '
-                           'I cannot release any more.  I need %d MiB but '
+                           'I cannot release any more.  I need %d KiB but '
                            'only have %d.') %
                           (need_mem, free_mem))
         elif new_alloc < dom0_min_mem:
             raise VmError(
-                ('I need %d MiB, but dom0_min_mem is %d and shrinking to '
-                 '%d MiB would leave only %d MiB free.') %
+                ('I need %d KiB, but dom0_min_mem is %d and shrinking to '
+                 '%d KiB would leave only %d KiB free.') %
                 (need_mem, dom0_min_mem, dom0_min_mem,
-                 free_mem + dom0_alloc - dom0_min_mem))
+                 free_mem + scrub_mem + dom0_alloc - dom0_min_mem))
         else:
             raise VmError('The privileged domain did not balloon!')
 
diff -ru xen-unstable.hg~/tools/python/xen/xend/XendNode.py xen-unstable.hg/tools/python/xen/xend/XendNode.py
--- xen-unstable.hg~/tools/python/xen/xend/XendNode.py	2006-05-12 14:18:51.000000000 -0600
+++ xen-unstable.hg/tools/python/xen/xend/XendNode.py	2006-06-23 12:25:53.000000000 -0600
@@ -64,6 +64,9 @@
                            info['cores_per_socket'] *
                            info['threads_per_core'])
         info['cpu_mhz'] = info['cpu_khz'] / 1000
+        # physinfo is in KiB
+        info['total_memory'] = info['total_memory'] / 1024
+        info['free_memory']  = info['free_memory'] / 1024
 
         ITEM_ORDER = ['nr_cpus',
                       'nr_nodes',
diff -ru xen-unstable.hg~/xen/arch/x86/dom0_ops.c xen-unstable.hg/xen/arch/x86/dom0_ops.c
--- xen-unstable.hg~/xen/arch/x86/dom0_ops.c	2006-06-09 16:21:40.000000000 -0600
+++ xen-unstable.hg/xen/arch/x86/dom0_ops.c	2006-06-23 12:21:20.000000000 -0600
@@ -194,6 +194,7 @@
         pi->nr_nodes         = 1;
         pi->total_pages      = total_pages;
         pi->free_pages       = avail_domheap_pages();
+        pi->scrub_pages      = avail_scrub_pages();
         pi->cpu_khz          = cpu_khz;
         memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
         memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4);
diff -ru xen-unstable.hg~/xen/common/page_alloc.c xen-unstable.hg/xen/common/page_alloc.c
--- xen-unstable.hg~/xen/common/page_alloc.c	2006-06-22 17:00:21.000000000 -0600
+++ xen-unstable.hg/xen/common/page_alloc.c	2006-06-23 10:03:14.000000000 -0600
@@ -61,6 +61,7 @@
 
 static DEFINE_SPINLOCK(page_scrub_lock);
 LIST_HEAD(page_scrub_list);
+static unsigned long scrub_pages;
 
 /*********************
  * ALLOCATION BITMAP
@@ -696,6 +697,7 @@
             {
                 spin_lock(&page_scrub_lock);
                 list_add(&pg[i].list, &page_scrub_list);
+                scrub_pages ++;
                 spin_unlock(&page_scrub_lock);
             }
         }
@@ -784,6 +786,7 @@
         /* Remove peeled pages from the list. */
         ent->next->prev = &page_scrub_list;
         page_scrub_list.next = ent->next;
+        scrub_pages -= (i+1);
         
         spin_unlock(&page_scrub_lock);
         
@@ -800,6 +803,11 @@
     } while ( (NOW() - start) < MILLISECS(1) );
 }
 
+unsigned long avail_scrub_pages(void)
+{
+    return scrub_pages;
+}
+
 static __init int page_scrub_init(void)
 {
     open_softirq(PAGE_SCRUB_SOFTIRQ, page_scrub_softirq);
Only in xen-unstable.hg/xen/common: page_alloc.c.orig
diff -ru xen-unstable.hg~/xen/include/public/dom0_ops.h xen-unstable.hg/xen/include/public/dom0_ops.h
--- xen-unstable.hg~/xen/include/public/dom0_ops.h	2006-06-22 17:00:22.000000000 -0600
+++ xen-unstable.hg/xen/include/public/dom0_ops.h	2006-06-23 10:08:20.000000000 -0600
@@ -231,6 +231,7 @@
     uint32_t cpu_khz;
     uint64_t total_pages;
     uint64_t free_pages;
+    uint64_t scrub_pages;
     uint32_t hw_cap[8];
 };
 typedef struct dom0_physinfo dom0_physinfo_t;
diff -ru xen-unstable.hg~/xen/include/xen/mm.h xen-unstable.hg/xen/include/xen/mm.h
--- xen-unstable.hg~/xen/include/xen/mm.h	2006-06-22 17:00:22.000000000 -0600
+++ xen-unstable.hg/xen/include/xen/mm.h	2006-06-23 10:03:14.000000000 -0600
@@ -91,6 +91,7 @@
         if ( !list_empty(&page_scrub_list) )    \
             raise_softirq(PAGE_SCRUB_SOFTIRQ);  \
     } while ( 0 )
+unsigned long avail_scrub_pages(void);
 
 #include <asm/mm.h>
 
Only in xen-unstable.hg/xen/include/xen: mm.h.orig

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 7%]

* [PATCH] [BALLOON] Increase retry_limit (fix for bug #683)
@ 2006-06-23 20:52  8% Krysan, Susan
  0 siblings, 0 replies; 200+ results
From: Krysan, Susan @ 2006-06-23 20:52 UTC (permalink / raw)
  To: xen-devel; +Cc: Krysan, Susan

[-- Attachment #1: Type: text/plain, Size: 613 bytes --]

On an ES7000 with 16GB of memory, when Dom0 boots up with all of system memory, a balloon error is issued when you try to bring up 1GB and 2GB DomUs. This patch increases the retry limit to allow xend more time before issuing a balloon error. This fixes bug #683.
http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=683

Signed-off-by: Susan Krysan
<krysans@unisys.com>
-------------------------------------
If this patch is acceptable, could you please apply it to both xen-unstable
and xen-testing?
 <<balloon_retry_limit.patch>> 
Thanks,
Susan Krysan
Linux Systems Group
Unisys Corporation



[-- Attachment #2: balloon_retry_limit.patch --]
[-- Type: application/octet-stream, Size: 500 bytes --]

diff -r f91cc71173c5 tools/python/xen/xend/balloon.py
--- a/tools/python/xen/xend/balloon.py	Thu Jun 22 21:37:33 2006 +0100
+++ b/tools/python/xen/xend/balloon.py	Fri Jun 23 14:00:17 2006 -0400
@@ -31,7 +31,7 @@ PROC_XEN_BALLOON = '/proc/xen/balloon'
 
 BALLOON_OUT_SLACK = 1 # MiB.  We need this because the physinfo details are
                       # rounded.
-RETRY_LIMIT = 10
+RETRY_LIMIT = 20
 RETRY_LIMIT_INCR = 5
 ##
 # The time to sleep between retries grows linearly, using this value (in

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 8%]

* Re: [PATCH] balloon: don't talk about low/high memory when there is no such distinction
  @ 2006-06-24 15:04  5%   ` Anthony Liguori
  0 siblings, 0 replies; 200+ results
From: Anthony Liguori @ 2006-06-24 15:04 UTC (permalink / raw)
  To: Muli Ben-Yehuda; +Cc: xen-devel, Jan Beulich

Muli Ben-Yehuda wrote:
> On Fri, Jun 23, 2006 at 02:26:38PM +0200, Jan Beulich wrote:
>
>   
>> .. in order to not confuse people.
>>     
>
> Hi Jan,
>
> This will confuse any tool that parses the output of the file
> though. The ifdefs are also pretty ugly... is the current output so
> confusing?
>   

Xend actually relies on the output of /proc/xen/balloon.  See 
tools/python/xen/xend/balloon.py

Regards,

Anthony Liguori

> Cheers,
> Muli
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
>   

^ permalink raw reply	[relevance 5%]

* [PATCH] linux: Add fallback when XENMEM_exchange fails to replace contiguous region
@ 2006-06-29 13:44 15% Jan Beulich
  0 siblings, 0 replies; 200+ results
From: Jan Beulich @ 2006-06-29 13:44 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 121 bytes --]

This avoids losing precious special memory in places where any memory can be
used.

Signed-off-by: jbeulich@novell.com 


[-- Attachment #2: xenlinux-dcr-fallback.patch --]
[-- Type: text/plain, Size: 5193 bytes --]

Index: 2006-06-29/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c
===================================================================
--- 2006-06-29.orig/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	2006-06-29 15:29:06.000000000 +0200
+++ 2006-06-29/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	2006-06-29 15:32:32.000000000 +0200
@@ -42,6 +42,7 @@
 #include <xen/interface/memory.h>
 #include <linux/module.h>
 #include <linux/percpu.h>
+#include <linux/highmem.h>
 #include <asm/tlbflush.h>
 
 #ifdef CONFIG_X86_64
@@ -419,7 +420,8 @@ void xen_destroy_contiguous_region(unsig
 	/* 2. Zap current PTEs. */
 	for (i = 0; i < (1UL<<order); i++) {
 		if (HYPERVISOR_update_va_mapping(vstart + (i*PAGE_SIZE),
-						 __pte_ma(0), 0));
+						 __pte_ma(0), 0))
+			BUG();
 		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
 			INVALID_P2M_ENTRY);
 		out_frames[i] = (__pa(vstart) >> PAGE_SHIFT) + i;
@@ -430,7 +432,7 @@ void xen_destroy_contiguous_region(unsig
 	success = (exchange.nr_exchanged == 1);
 	BUG_ON(!success && ((exchange.nr_exchanged != 0) || (rc == 0)));
 	BUG_ON(success && (rc != 0));
-	if (rc == -ENOSYS) {
+	if (unlikely(rc == -ENOSYS)) {
 		/* Compatibility when XENMEM_exchange is unsupported. */
 		if (HYPERVISOR_memory_op(XENMEM_decrease_reservation,
 					 &exchange.in) != 1)
@@ -455,6 +457,68 @@ void xen_destroy_contiguous_region(unsig
 	flush_tlb_all();
 
 	balloon_unlock(flags);
+
+	if (unlikely(!success)) {
+		/* Try hard to get the special memory back to Xen. */
+		exchange.in.extent_order = 0;
+		set_xen_guest_handle(exchange.in.extent_start, &in_frame);
+
+		for (i = 0; i < (1UL<<order); i++) {
+			struct page *page = alloc_page(GFP_HIGHUSER);
+			unsigned long pfn;
+
+			if (!page) {
+				printk(KERN_WARNING "Xen and kernel out of memory "
+				       "while trying to release an order %u "
+				       "contiguous region\n", order);
+				break;
+			}
+			pfn = page_to_pfn(page);
+			if (!PageHighMem(page)) {
+				void *v = __va(pfn << PAGE_SHIFT);
+
+				scrub_pages(v, 1);
+				if (HYPERVISOR_update_va_mapping((unsigned long)v,
+								 __pte_ma(0),
+								 UVMF_INVLPG|UVMF_ALL))
+					BUG();
+			}
+#ifdef CONFIG_XEN_SCRUB_PAGES
+			else {
+				void *v = kmap(page);
+
+				scrub_pages(v, 1);
+				kunmap(page);
+				kmap_flush_unused();
+			}
+#endif
+
+			balloon_lock(flags);
+
+			frame = pfn_to_mfn(pfn);
+			set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
+
+			if (HYPERVISOR_update_va_mapping(vstart,
+							 pfn_pte_ma(frame, PAGE_KERNEL),
+							 UVMF_INVLPG|UVMF_ALL))
+				BUG();
+			pfn = __pa(vstart) >> PAGE_SHIFT;
+			set_phys_to_machine(pfn, frame);
+			xen_machphys_update(frame, pfn);
+
+			if (HYPERVISOR_memory_op(XENMEM_decrease_reservation,
+						 &exchange.in) != 1)
+				BUG();
+
+			balloon_unlock(flags);
+
+			set_page_count(page, 1);
+			balloon_free_empty_page_range(page, 1);
+
+			in_frame++;
+			vstart += PAGE_SIZE;
+		}
+	}
 }
 
 #ifdef __i386__
Index: 2006-06-29/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
===================================================================
--- 2006-06-29.orig/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	2006-06-29 15:29:06.000000000 +0200
+++ 2006-06-29/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	2006-06-29 15:29:29.000000000 +0200
@@ -597,22 +597,37 @@ struct page *balloon_alloc_empty_page_ra
 	return page;
 }
 
-void balloon_dealloc_empty_page_range(
-	struct page *page, unsigned long nr_pages)
+static void _balloon_free_empty_page_range(
+	struct page *page, unsigned long nr_pages, int account)
 {
 	unsigned long i, flags;
-	unsigned int  order = get_order(nr_pages * PAGE_SIZE);
 
 	balloon_lock(flags);
-	for (i = 0; i < (1UL << order); i++) {
+	for (i = 0; i < nr_pages; i++) {
 		BUG_ON(page_count(page + i) != 1);
 		balloon_append(page + i);
 	}
+	if (account) {
+		current_pages -= nr_pages;
+		totalram_pages = current_pages;
+	}
 	balloon_unlock(flags);
 
 	schedule_work(&balloon_worker);
 }
 
+void balloon_dealloc_empty_page_range(
+	struct page *page, unsigned long nr_pages)
+{
+	_balloon_free_empty_page_range(page, 1UL << get_order(nr_pages * PAGE_SIZE), 0);
+}
+
+void balloon_free_empty_page_range(
+	struct page *page, unsigned long nr_pages)
+{
+	_balloon_free_empty_page_range(page, nr_pages, 1);
+}
+
 EXPORT_SYMBOL_GPL(balloon_update_driver_allowance);
 EXPORT_SYMBOL_GPL(balloon_alloc_empty_page_range);
 EXPORT_SYMBOL_GPL(balloon_dealloc_empty_page_range);
Index: 2006-06-29/linux-2.6-xen-sparse/include/xen/balloon.h
===================================================================
--- 2006-06-29.orig/linux-2.6-xen-sparse/include/xen/balloon.h	2006-06-29 15:29:06.000000000 +0200
+++ 2006-06-29/linux-2.6-xen-sparse/include/xen/balloon.h	2006-06-29 15:29:29.000000000 +0200
@@ -52,6 +52,12 @@ extern void
 balloon_dealloc_empty_page_range(
 	struct page *page, unsigned long nr_pages);
 
+/* Free an empty page range (not allocated through
+   balloon_alloc_empty_page_range), adding to the balloon. */
+extern void
+balloon_free_empty_page_range(
+	struct page *page, unsigned long nr_pages);
+
 /*
  * Prevent the balloon driver from changing the memory reservation during
  * a driver critical region.

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 15%]

* [PATCH] Blktap update (RFC)
@ 2006-07-08  1:48  2% Julian Chesterfield
  0 siblings, 0 replies; 200+ results
From: Julian Chesterfield @ 2006-07-08  1:48 UTC (permalink / raw)
  To: xen-devel; +Cc: andrew.warfield, Julian Chesterfield


[-- Attachment #1.1: Type: text/plain, Size: 2257 bytes --]

Attached is an updated patch to the blktap kernel driver and userspace 
toolset. The patch incorporates comments submitted to the list 
regarding stylistic changes such as the use of C99 initialisation. The 
/proc stats have been removed and will be replaced soon with sysfs 
variables along the same lines as the recent blkback patch.

This patch incorporates 3 new features:

- It now allows local mounts of tap-based images within dom0 
(equivalent to the loopback driver) using the xm block-attach feature. 
Tap disks can be attached to a virtual block device in dom0 which is 
then mountable. This feature is particularly useful for modifying VM 
images before booting them, for instance to update the in-image kernel 
for an HVM guest.

- Faster Qcow performance through metadata allocation optimizations. 
Qcow files remain backwards compatible, but headers contain additional 
information to indicate that allocation has been optimized for access 
from the xen tools.

- the blktapctrl daemon is launched automatically along with xenstored 
and xenconsoled through xend

Performance results indicate that blktap performs very favourably in 
comparison to blkback (raw partition AIO) and that with the qcow 
optimisation feature enabled, the CoW disk performs almost as fast as 
the raw loopback driver:

Bonnie results (block IO summarised):
                      READ     WRITE   (K/sec)
Tap AIO partition    52781    45072
Blkback partition    52596    45429
Loop                 52286    37672
Qcow Normal          43058    29386
Qcow Optimised       51834    37083


Full Bonnie results:
              -------Sequential Output-------- ---Sequential Input-- 
--Random--
               -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- 
--Seeks---
Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  
/sec %CPU
Tap AIO dev 2G 43805 93   45072 8   21896 0    38751 52   52781 0     
121.1 0
Blkback    2G  43400 86   45429 8   22217 0    39075 53   52596 0     
119.0 0
Loop       2G  31459 63   37672 9   16442 0    44122 78   52286 0     
119.7 0

Qcow norm  2G  28341 56   29386 5   15908 0    36006 49   43058 0     
66.9  0
Qcow Opt   2G  33568 67   37083 6   19589 0    39180 58   51834 0     
123.1 0

Thanks,
Julian


[-- Attachment #1.2: Type: text/enriched, Size: 2408 bytes --]

Attached is an updated patch to the blktap kernel driver and userspace
toolset. The patch incorporates comments submitted to the list
regarding stylistic changes such as the use of C99 initialisation. The
/proc stats have been removed and will be replaced soon with sysfs
variables along the same lines as the recent blkback patch.


This patch incorporates 3 new features:


- It now allows local mounts of tap-based images within dom0
(equivalent to the loopback driver) using the xm block-attach feature.
Tap disks can be attached to a virtual block device in dom0 which is
then mountable. <fontfamily><param>Geneva</param>This feature is
particularly useful for modifying VM images before booting them, for
instance to update the in-image kernel for an HVM guest.</fontfamily>


- Faster Qcow performance <fontfamily><param>Geneva</param>through
metadata allocation optimizations</fontfamily>.
<fontfamily><param>Geneva</param>Qcow files remain backwards
compatible, but headers contain additional information to indicate
that allocation has been optimized for access from the xen tools.</fontfamily>


- the blktapctrl daemon is launched automatically along with xenstored
and xenconsoled through xend


Performance results indicate that blktap performs very favourably in
comparison to blkback (raw partition AIO) and that with the qcow
optimisation feature enabled, the CoW disk performs almost as fast as
the raw loopback driver:


<fixed>Bonnie results (block IO summarised):

                     READ     WRITE   (K/sec)

Tap AIO partition    52781    45072

Blkback partition    52596    45429

Loop                 52286    37672

Qcow Normal          43058    29386

Qcow Optimised       51834    37083



Full Bonnie results:

             -------Sequential Output-------- ---Sequential Input--
--Random--

              -Per Char- --Block--- -Rewrite-- -Per Char- --Block---
--Seeks---

Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU 
/sec %CPU

Tap AIO dev 2G 43805 93   45072 8   21896 0    38751 52   52781 0    
121.1 0

Blkback    2G  43400 86   45429 8   22217 0    39075 53   52596 0    
119.0 0

Loop       2G  31459 63   37672 9   16442 0    44122 78   52286 0    
119.7 0


Qcow norm  2G  28341 56   29386 5   15908 0    36006 49   43058 0    
66.9  0 

Qcow Opt   2G  33568 67   37083 6   19589 0    39180 58   51834 0    
123.1 0</fixed>


Thanks,

Julian



[-- Attachment #2: blktap.patch --]
[-- Type: application/octet-stream, Size: 335612 bytes --]

diff -urN xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen0_ia64 xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen0_ia64
--- xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen0_ia64	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen0_ia64	2006-07-08 02:03:49.000000000 +0100
@@ -1528,6 +1528,7 @@
 CONFIG_XEN_BACKEND=y
 # CONFIG_XEN_PCIDEV_BACKEND is not set
 CONFIG_XEN_BLKDEV_BACKEND=y
+CONFIG_XEN_BLKDEV_TAP=n
 CONFIG_XEN_NETDEV_BACKEND=y
 # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
 CONFIG_XEN_NETDEV_LOOPBACK=y
diff -urN xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen0_x86_32 xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen0_x86_32
--- xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen0_x86_32	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen0_x86_32	2006-07-08 02:03:49.000000000 +0100
@@ -1322,6 +1322,7 @@
 CONFIG_XEN_PCIDEV_BACKEND_PASS=y
 # CONFIG_XEN_PCIDEV_BE_DEBUG is not set
 CONFIG_XEN_BLKDEV_BACKEND=y
+CONFIG_XEN_BLKDEV_TAP=y
 CONFIG_XEN_NETDEV_BACKEND=y
 # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
 CONFIG_XEN_NETDEV_LOOPBACK=y
diff -urN xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen0_x86_64 xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen0_x86_64
--- xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen0_x86_64	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen0_x86_64	2006-07-08 02:03:49.000000000 +0100
@@ -1263,6 +1263,7 @@
 CONFIG_XEN_PCIDEV_BACKEND_PASS=y
 # CONFIG_XEN_PCIDEV_BE_DEBUG is not set
 CONFIG_XEN_BLKDEV_BACKEND=y
+CONFIG_XEN_BLKDEV_TAP=y
 CONFIG_XEN_NETDEV_BACKEND=y
 # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
 CONFIG_XEN_NETDEV_LOOPBACK=y
diff -urN xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen_ia64 xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen_ia64
--- xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen_ia64	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen_ia64	2006-07-08 02:03:49.000000000 +0100
@@ -1534,6 +1534,7 @@
 CONFIG_XEN_BACKEND=y
 # CONFIG_XEN_PCIDEV_BACKEND is not set
 CONFIG_XEN_BLKDEV_BACKEND=y
+CONFIG_XEN_BLKDEV_TAP=n
 CONFIG_XEN_NETDEV_BACKEND=y
 # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
 CONFIG_XEN_NETDEV_LOOPBACK=y
diff -urN xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen_x86_32 xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen_x86_32
--- xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen_x86_32	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen_x86_32	2006-07-08 02:03:49.000000000 +0100
@@ -3023,6 +3023,7 @@
 # CONFIG_XEN_PCIDEV_BACKEND_PASS is not set
 # CONFIG_XEN_PCIDEV_BE_DEBUG is not set
 CONFIG_XEN_BLKDEV_BACKEND=y
+CONFIG_XEN_BLKDEV_TAP=y
 CONFIG_XEN_NETDEV_BACKEND=y
 # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
 CONFIG_XEN_NETDEV_LOOPBACK=y
diff -urN xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen_x86_64 xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen_x86_64
--- xen-unstable-pristine.hg/buildconfigs/linux-defconfig_xen_x86_64	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/buildconfigs/linux-defconfig_xen_x86_64	2006-07-08 02:03:49.000000000 +0100
@@ -2855,6 +2855,7 @@
 CONFIG_XEN_PCIDEV_BACKEND_PASS=y
 # CONFIG_XEN_PCIDEV_BE_DEBUG is not set
 CONFIG_XEN_BLKDEV_BACKEND=y
+CONFIG_XEN_BLKDEV_TAP=y
 CONFIG_XEN_NETDEV_BACKEND=y
 # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
 CONFIG_XEN_NETDEV_LOOPBACK=y
diff -urN xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	2006-07-08 02:03:48.000000000 +0100
@@ -0,0 +1,1439 @@
+/******************************************************************************
+ * drivers/xen/blktap/blktap.c
+ * 
+ * Back-end driver for user level virtual block devices. This portion of the
+ * driver exports a 'unified' block-device interface that can be accessed
+ * by any operating system that implements a compatible front end. Requests
+ * are remapped to a user-space memory region.
+ *
+ * Based on the blkback driver code.
+ * 
+ * Copyright (c) 2004-2005, Andrew Warfield and Julian Chesterfield
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <linux/spinlock.h>
+#include <linux/kthread.h>
+#include <linux/list.h>
+#include <asm/hypervisor.h>
+#include "common.h"
+#include <xen/balloon.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/miscdevice.h>
+#include <linux/errno.h>
+#include <linux/major.h>
+#include <linux/gfp.h>
+#include <linux/poll.h>
+#include <asm/tlbflush.h>
+#include <linux/devfs_fs_kernel.h>
+
+#define MAX_TAP_DEV 100     /*the maximum number of tapdisk ring devices    */
+#define MAX_DEV_NAME 100    /*the max tapdisk ring device name e.g. blktap0 */
+
+/*
+ * The maximum number of requests that can be outstanding at any time
+ * is determined by 
+ *
+ *   [mmap_alloc * MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST] 
+ *
+ * where mmap_alloc < MAX_DYNAMIC_MEM.
+ *
+ * TODO:
+ * mmap_alloc is initialised to 2 and should be adjustable on the fly via
+ * sysfs.
+ */
+#define MAX_DYNAMIC_MEM 64
+#define MAX_PENDING_REQS 64   
+#define MMAP_PAGES (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
+#define MMAP_VADDR(_start, _req,_seg)                                   \
+        (_start +                                                       \
+         ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +        \
+         ((_seg) * PAGE_SIZE))
+static int blkif_reqs = MAX_PENDING_REQS;
+static int mmap_pages = MMAP_PAGES;
+
+#define RING_PAGES 1 /* BLKTAP - immediately before the mmap area, we
+		      * have a bunch of pages reserved for shared
+		      * memory rings.
+		      */
+
+/*Data struct associated with each of the tapdisk devices*/
+typedef struct tap_blkif {
+	struct vm_area_struct *vma;   /*Shared memory area                   */
+	unsigned long rings_vstart;   /*Kernel memory mapping                */
+	unsigned long user_vstart;    /*User memory mapping                  */
+	unsigned long dev_inuse;      /*One process opens device at a time.  */
+	unsigned long dev_pending;    /*In process of being opened           */
+	unsigned long ring_ok;        /*make this ring->state                */
+	blkif_front_ring_t ufe_ring;  /*Rings up to user space.              */
+	wait_queue_head_t wait;       /*for poll                             */
+	unsigned long mode;           /*current switching mode               */
+	int minor;                    /*Minor number for tapdisk device      */
+	pid_t pid;                    /*tapdisk process id                   */
+	enum { RUNNING, CLEANSHUTDOWN } status; /*Detect a clean userspace 
+						  shutdown                   */
+	unsigned long *idx_map;       /*Record the user ring id to kern 
+					[req id, idx] tuple                  */
+	blkif_t *blkif;               /*Associate blkif with tapdev          */
+} tap_blkif_t;
+
+/*Private data struct associated with the inode*/
+typedef struct private_info {
+	int idx;
+} private_info_t;
+
+/*Data struct handed back to userspace for tapdisk device to VBD mapping*/
+typedef struct domid_translate {
+	unsigned short domid;
+	unsigned short busid;
+} domid_translate_t ;
+
+
+domid_translate_t  translate_domid[MAX_TAP_DEV];
+tap_blkif_t *tapfds[MAX_TAP_DEV];
+
+static int __init set_blkif_reqs(char *str)
+{
+	get_option(&str, &blkif_reqs);
+	return 1;
+}
+__setup("blkif_reqs=", set_blkif_reqs);
+
+/* Run-time switchable: /sys/module/blktap/parameters/ */
+static unsigned int log_stats = 0;
+static unsigned int debug_lvl = 0;
+module_param(log_stats, int, 0644);
+module_param(debug_lvl, int, 0644);
+
+/*
+ * Each outstanding request that we've passed to the lower device layers has a 
+ * 'pending_req' allocated to it. Each buffer_head that completes decrements 
+ * the pendcnt towards zero. When it hits zero, the specified domain has a 
+ * response queued for it, with the saved 'id' passed back.
+ */
+typedef struct {
+	blkif_t       *blkif;
+	unsigned long  id;
+	unsigned short mem_idx;
+	int            nr_pages;
+	atomic_t       pendcnt;
+	unsigned short operation;
+	int            status;
+	struct list_head free_list;
+	int            inuse;
+} pending_req_t;
+
+static pending_req_t *pending_reqs[MAX_PENDING_REQS];
+static struct list_head pending_free;
+static DEFINE_SPINLOCK(pending_free_lock);
+static DECLARE_WAIT_QUEUE_HEAD (pending_free_wq);
+static int alloc_pending_reqs;
+
+typedef unsigned int PEND_RING_IDX;
+
+static inline int MASK_PEND_IDX(int i) { 
+	return (i & (MAX_PENDING_REQS-1)); 
+}
+
+static inline unsigned int RTN_PEND_IDX(pending_req_t *req, int idx) {
+	return (req - pending_reqs[idx]);
+}
+
+#define NR_PENDING_REQS (MAX_PENDING_REQS - pending_prod + pending_cons)
+
+#define BLKBACK_INVALID_HANDLE (~0)
+
+typedef struct mmap_page {
+	unsigned long start;
+	struct page *mpage;
+} mmap_page_t;
+
+static mmap_page_t mmap_start[MAX_DYNAMIC_MEM];
+static unsigned short mmap_alloc = 0;
+static unsigned short mmap_lock = 0;
+static unsigned short mmap_inuse = 0;
+static unsigned long *pending_addrs[MAX_DYNAMIC_MEM];
+
+/******************************************************************
+ * GRANT HANDLES
+ */
+
+/* When using grant tables to map a frame for device access then the
+ * handle returned must be used to unmap the frame. This is needed to
+ * drop the ref count on the frame.
+ */
+struct grant_handle_pair
+{
+        grant_handle_t kernel;
+        grant_handle_t user;
+};
+
+static struct grant_handle_pair 
+    pending_grant_handles[MAX_DYNAMIC_MEM][MMAP_PAGES];
+#define pending_handle(_id, _idx, _i) \
+    (pending_grant_handles[_id][((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) \
+    + (_i)])
+
+
+static int blktap_read_ufe_ring(int idx); /*local prototypes*/
+
+#define BLKTAP_MINOR 0  /*/dev/xen/blktap resides at device number
+			  major=254, minor numbers begin at 0            */ 
+#define BLKTAP_DEV_MAJOR 254         /* TODO: Make major number dynamic  *
+                                      * and create devices in the kernel *
+				      */
+#define BLKTAP_DEV_DIR  "/dev/xen"
+
+/* blktap IOCTLs: */
+#define BLKTAP_IOCTL_KICK_FE         1
+#define BLKTAP_IOCTL_KICK_BE         2 /* currently unused */
+#define BLKTAP_IOCTL_SETMODE         3
+#define BLKTAP_IOCTL_SENDPID	     4
+#define BLKTAP_IOCTL_NEWINTF	     5
+#define BLKTAP_IOCTL_MINOR	     6
+#define BLKTAP_IOCTL_MAJOR	     7
+#define BLKTAP_QUERY_ALLOC_REQS      8
+#define BLKTAP_IOCTL_FREEINTF        9
+#define BLKTAP_IOCTL_PRINT_IDXS      100  
+
+/* blktap switching modes: (Set with BLKTAP_IOCTL_SETMODE)             */
+#define BLKTAP_MODE_PASSTHROUGH      0x00000000  /* default            */
+#define BLKTAP_MODE_INTERCEPT_FE     0x00000001
+#define BLKTAP_MODE_INTERCEPT_BE     0x00000002  /* unimp.             */
+
+#define BLKTAP_MODE_INTERPOSE \
+           (BLKTAP_MODE_INTERCEPT_FE | BLKTAP_MODE_INTERCEPT_BE)
+
+
+static inline int BLKTAP_MODE_VALID(unsigned long arg)
+{
+	return ((arg == BLKTAP_MODE_PASSTHROUGH ) ||
+		(arg == BLKTAP_MODE_INTERCEPT_FE) ||
+                (arg == BLKTAP_MODE_INTERPOSE   ));
+}
+
+/* Requests passing through the tap to userspace are re-assigned an ID.
+ * We must record a mapping between the BE [IDX,ID] tuple and the userspace
+ * ring ID. 
+ */
+
+static inline unsigned long MAKE_ID(domid_t fe_dom, PEND_RING_IDX idx)
+{
+        return ((fe_dom << 16) | MASK_PEND_IDX(idx));
+}
+
+extern inline PEND_RING_IDX ID_TO_IDX(unsigned long id)
+{
+        return (PEND_RING_IDX)(id & 0x0000ffff);
+}
+
+extern inline int ID_TO_MIDX(unsigned long id)
+{
+        return (int)(id >> 16);
+}
+
+#define INVALID_REQ 0xdead0000
+
+/*TODO: Convert to a free list*/
+static inline int GET_NEXT_REQ(unsigned long *idx_map)
+{
+	int i;
+	for (i = 0; i < MAX_PENDING_REQS; i++)
+		if (idx_map[i] == INVALID_REQ) return i;
+
+	return INVALID_REQ;
+}
+
+
+#define BLKTAP_INVALID_HANDLE(_g) \
+    (((_g->kernel) == 0xFFFF) && ((_g->user) == 0xFFFF))
+
+#define BLKTAP_INVALIDATE_HANDLE(_g) do {       \
+    (_g)->kernel = 0xFFFF; (_g)->user = 0xFFFF; \
+    } while(0)
+
+
+/******************************************************************
+ * BLKTAP VM OPS
+ */
+
+static struct page *blktap_nopage(struct vm_area_struct *vma,
+				  unsigned long address,
+				  int *type)
+{
+	/*
+	 * if the page has not been mapped in by the driver then return
+	 * NOPAGE_SIGBUS to the domain.
+	 */
+
+	return NOPAGE_SIGBUS;
+}
+
+struct vm_operations_struct blktap_vm_ops = {
+	nopage:   blktap_nopage,
+};
+
+/******************************************************************
+ * BLKTAP FILE OPS
+ */
+ 
+/*Function Declarations*/
+static int get_next_free_dev(void);
+static int blktap_open(struct inode *inode, struct file *filp);
+static int blktap_release(struct inode *inode, struct file *filp);
+static int blktap_mmap(struct file *filp, struct vm_area_struct *vma);
+static int blktap_ioctl(struct inode *inode, struct file *filp,
+                        unsigned int cmd, unsigned long arg);
+static unsigned int blktap_poll(struct file *file, poll_table *wait);
+
+struct miscdevice *set_misc(int minor, char *name, int dev);
+
+static struct file_operations blktap_fops = {
+	.owner   = THIS_MODULE,
+	.poll    = blktap_poll,
+	.ioctl   = blktap_ioctl,
+	.open    = blktap_open,
+	.release = blktap_release,
+	.mmap    = blktap_mmap,
+};
+
+
+static int get_next_free_dev(void)
+{
+	tap_blkif_t *info;
+	int i = 0, ret = -1;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+	
+	while (i < MAX_TAP_DEV) {
+		info = tapfds[i];
+		if ( (tapfds[i] != NULL) && (info->dev_inuse == 0)
+			&& (info->dev_pending == 0) ) {
+			info->dev_pending = 1;
+			ret = i;
+			goto done;
+		}
+		i++;
+	}
+	
+done:
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+	return ret;
+}
+
+int dom_to_devid(domid_t domid, int xenbus_id, blkif_t *blkif) 
+{
+	int i;
+		
+	for (i = 0; i < MAX_TAP_DEV; i++)
+		if ( (translate_domid[i].domid == domid)
+		    && (translate_domid[i].busid == xenbus_id) ) {
+			tapfds[i]->blkif = blkif;
+			tapfds[i]->status = RUNNING;
+			return i;
+		}
+	return -1;
+}
+
+void signal_tapdisk(int idx) 
+{
+	tap_blkif_t *info;
+	struct task_struct *ptask;
+
+	info = tapfds[idx];
+	if ( (idx > 0) && (idx < MAX_TAP_DEV) && (info->pid > 0) ) {
+		ptask = find_task_by_pid(info->pid);
+		if (ptask) { 
+			info->status = CLEANSHUTDOWN;
+ 		}
+	}
+	info->blkif = NULL;
+	return;
+}
+
+static int blktap_open(struct inode *inode, struct file *filp)
+{
+	blkif_sring_t *sring;
+	int idx = iminor(inode) - BLKTAP_MINOR;
+	tap_blkif_t *info;
+	private_info_t *prv;
+	int i;
+	
+	if (tapfds[idx] == NULL) {
+		WPRINTK("Unable to open device /dev/xen/blktap%d\n",
+		       idx);
+		return -ENOMEM;
+	}
+	DPRINTK("Opening device /dev/xen/blktap%d\n",idx);
+	
+	info = tapfds[idx];
+	
+	/*Only one process can access device at a time*/
+	if (test_and_set_bit(0, &info->dev_inuse))
+		return -EBUSY;
+
+	info->dev_pending = 0;
+	    
+	/* Allocate the fe ring. */
+	sring = (blkif_sring_t *)get_zeroed_page(GFP_KERNEL);
+	if (sring == NULL)
+		goto fail_nomem;
+
+	SetPageReserved(virt_to_page(sring));
+    
+	SHARED_RING_INIT(sring);
+	FRONT_RING_INIT(&info->ufe_ring, sring, PAGE_SIZE);
+	
+	prv = kzalloc(sizeof(private_info_t),GFP_KERNEL);
+	prv->idx = idx;
+	filp->private_data = prv;
+	info->vma = NULL;
+
+	info->idx_map = kmalloc(sizeof(unsigned long) * MAX_PENDING_REQS, 
+				GFP_KERNEL);
+	
+	if (idx > 0) {
+		init_waitqueue_head(&info->wait);
+		for (i = 0; i < MAX_PENDING_REQS; i++) 
+			info->idx_map[i] = INVALID_REQ;
+	}
+
+	DPRINTK("Tap open: device /dev/xen/blktap%d\n",idx);
+	return 0;
+
+ fail_nomem:
+	return -ENOMEM;
+}
+
+static int blktap_release(struct inode *inode, struct file *filp)
+{
+	int idx = iminor(inode) - BLKTAP_MINOR;
+	tap_blkif_t *info;
+	
+	if (tapfds[idx] == NULL) {
+		WPRINTK("Trying to free device that doesn't exist "
+		       "[/dev/xen/blktap%d]\n",idx);
+		return -1;
+	}
+	info = tapfds[idx];
+	info->dev_inuse = 0;
+	DPRINTK("Freeing device [/dev/xen/blktap%d]\n",idx);
+
+	/* Free the ring page. */
+	ClearPageReserved(virt_to_page(info->ufe_ring.sring));
+	free_page((unsigned long) info->ufe_ring.sring);
+
+	/* Clear any active mappings and free foreign map table */
+	if (info->vma) {
+		zap_page_range(
+			info->vma, info->vma->vm_start, 
+			info->vma->vm_end - info->vma->vm_start, NULL);
+		info->vma = NULL;
+	}
+	
+	if (filp->private_data) kfree(filp->private_data);
+
+	if ( (info->status != CLEANSHUTDOWN) && (info->blkif != NULL) ) {
+		kthread_stop(info->blkif->xenblkd);
+		info->blkif->xenblkd = NULL;
+		info->status = CLEANSHUTDOWN;
+	}	
+	return 0;
+}
+
+
+/* Note on mmap:
+ * We need to map pages to user space in a way that will allow the block
+ * subsystem set up direct IO to them.  This couldn't be done before, because
+ * there isn't really a sane way to translate a user virtual address down to a 
+ * physical address when the page belongs to another domain.
+ *
+ * My first approach was to map the page in to kernel memory, add an entry
+ * for it in the physical frame list (using alloc_lomem_region as in blkback)
+ * and then attempt to map that page up to user space.  This is disallowed
+ * by xen though, which realizes that we don't really own the machine frame
+ * underlying the physical page.
+ *
+ * The new approach is to provide explicit support for this in xen linux.
+ * The VMA now has a flag, VM_FOREIGN, to indicate that it contains pages
+ * mapped from other vms.  vma->vm_private_data is set up as a mapping 
+ * from pages to actual page structs.  There is a new clause in get_user_pages
+ * that does the right thing for this sort of mapping.
+ */
+static int blktap_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+	int size;
+	struct page **map;
+	int i;
+	private_info_t *prv;
+	tap_blkif_t *info;
+
+	/*Retrieve the dev info*/
+	prv = (private_info_t *)filp->private_data;
+	if (prv == NULL) {
+		WPRINTK("blktap: mmap, retrieving idx failed\n");
+		return -ENOMEM;
+	}
+	info = tapfds[prv->idx];
+	
+	vma->vm_flags |= VM_RESERVED;
+	vma->vm_ops = &blktap_vm_ops;
+
+	size = vma->vm_end - vma->vm_start;
+	if (size != ((mmap_pages + RING_PAGES) << PAGE_SHIFT)) {
+		WPRINTK("you _must_ map exactly %d pages!\n",
+		       mmap_pages + RING_PAGES);
+		return -EAGAIN;
+	}
+
+	size >>= PAGE_SHIFT;
+	info->rings_vstart = vma->vm_start;
+	info->user_vstart  = info->rings_vstart + (RING_PAGES << PAGE_SHIFT);
+    
+	/* Map the ring pages to the start of the region and reserve it. */
+	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+	if (remap_pfn_range(vma, vma->vm_start, 
+			    __pa(info->ufe_ring.sring) >> PAGE_SHIFT, 
+			    PAGE_SIZE, vma->vm_page_prot)) {
+		WPRINTK("Mapping user ring failed!\n");
+		goto fail;
+	}
+
+	/* Mark this VM as containing foreign pages, and set up mappings. */
+	map = kzalloc(((vma->vm_end - vma->vm_start) >> PAGE_SHIFT)
+		      * sizeof(struct page_struct*),
+		      GFP_KERNEL);
+	if (map == NULL) {
+		WPRINTK("Couldn't alloc VM_FOREIGN map.\n");
+		goto fail;
+	}
+
+	for (i = 0; i < ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT); i++)
+		map[i] = NULL;
+    
+	vma->vm_private_data = map;
+	vma->vm_flags |= VM_FOREIGN;
+
+	info->vma = vma;
+	info->ring_ok = 1;
+	return 0;
+ fail:
+	/* Clear any active mappings. */
+	zap_page_range(vma, vma->vm_start, 
+		       vma->vm_end - vma->vm_start, NULL);
+
+	return -ENOMEM;
+}
+
+
+static int blktap_ioctl(struct inode *inode, struct file *filp,
+                        unsigned int cmd, unsigned long arg)
+{
+	int idx = iminor(inode) - BLKTAP_MINOR;
+	switch(cmd) {
+	case BLKTAP_IOCTL_KICK_FE: 
+	{
+		/* There are fe messages to process. */
+		return blktap_read_ufe_ring(idx);
+	}
+	case BLKTAP_IOCTL_SETMODE:
+	{
+		tap_blkif_t *info = tapfds[idx];
+		
+		if ( (idx > 0) && (idx < MAX_TAP_DEV) 
+		     && (tapfds[idx] != NULL) ) 
+		{
+			if (BLKTAP_MODE_VALID(arg)) {
+				info->mode = arg;
+				/* XXX: may need to flush rings here. */
+				DPRINTK("blktap: set mode to %lx\n", 
+				       arg);
+				return 0;
+			}
+		}
+		return 0;
+	}
+	case BLKTAP_IOCTL_PRINT_IDXS:
+        {
+		tap_blkif_t *info = tapfds[idx];
+		
+		if ( (idx > 0) && (idx < MAX_TAP_DEV) 
+		     && (tapfds[idx] != NULL) ) 
+		{
+			printk("User Rings: \n-----------\n");
+			printk("UF: rsp_cons: %2d, req_prod_prv: %2d "
+				"| req_prod: %2d, rsp_prod: %2d\n",
+				info->ufe_ring.rsp_cons,
+				info->ufe_ring.req_prod_pvt,
+				info->ufe_ring.sring->req_prod,
+				info->ufe_ring.sring->rsp_prod);
+		}
+            	return 0;
+        }
+	case BLKTAP_IOCTL_SENDPID:
+	{
+		tap_blkif_t *info = tapfds[idx];
+		
+		if ( (idx > 0) && (idx < MAX_TAP_DEV) 
+		     && (tapfds[idx] != NULL) ) 
+		{
+			info->pid = (pid_t)arg;
+			DPRINTK("blktap: pid received %d\n", 
+			       info->pid);
+		}
+		return 0;
+	}
+	case BLKTAP_IOCTL_NEWINTF:
+	{		
+		uint64_t val = (uint64_t)arg;
+		domid_translate_t *tr = (domid_translate_t *)&val;
+		int newdev;
+
+		DPRINTK("NEWINTF Req for domid %d and bus id %d\n", 
+		       tr->domid, tr->busid);
+		newdev = get_next_free_dev();
+		if (newdev < 1) {
+			WPRINTK("Error initialising /dev/xen/blktap - "
+				"No more devices\n");
+			return -1;
+		}
+		translate_domid[newdev].domid = tr->domid;
+		translate_domid[newdev].busid = tr->busid;
+		return newdev;
+	}
+	case BLKTAP_IOCTL_FREEINTF:
+	{
+		unsigned long dev = arg;
+		tap_blkif_t *info = NULL;
+
+		if ( (dev > 0) && (dev < MAX_TAP_DEV) ) info = tapfds[dev];
+
+		if ( (info != NULL) && (info->dev_pending) )
+			info->dev_pending = 0;
+		return 0;
+	}
+	case BLKTAP_IOCTL_MINOR:
+	{
+		unsigned long dev = arg;
+		tap_blkif_t *info = NULL;
+		
+		if ( (dev > 0) && (dev < MAX_TAP_DEV) ) info = tapfds[dev];
+		
+		if (info != NULL) return info->minor;
+		else return -1;
+	}
+	case BLKTAP_IOCTL_MAJOR:
+		return BLKTAP_DEV_MAJOR;
+
+	case BLKTAP_QUERY_ALLOC_REQS:
+	{
+		WPRINTK("BLKTAP_QUERY_ALLOC_REQS ioctl: %d/%d\n",
+		       alloc_pending_reqs, blkif_reqs);
+		return (alloc_pending_reqs/blkif_reqs) * 100;
+	}
+	}
+	return -ENOIOCTLCMD;
+}
+
+static unsigned int blktap_poll(struct file *file, poll_table *wait)
+{
+	private_info_t *prv;
+	tap_blkif_t *info;
+	
+	/*Retrieve the dev info*/
+	prv = (private_info_t *)file->private_data;
+	if (prv == NULL) {
+		WPRINTK(" poll, retrieving idx failed\n");
+		return 0;
+	}
+	
+	if (prv->idx == 0) return 0;
+	
+	info = tapfds[prv->idx];
+	
+	poll_wait(file, &info->wait, wait);
+	if (info->ufe_ring.req_prod_pvt != info->ufe_ring.sring->req_prod) {
+		flush_tlb_all();
+		RING_PUSH_REQUESTS(&info->ufe_ring);
+		return POLLIN | POLLRDNORM;
+	}
+	return 0;
+}
+
+void blktap_kick_user(int idx)
+{
+	tap_blkif_t *info;
+
+	if (idx == 0) return;
+	
+	info = tapfds[idx];
+	
+	if (info != NULL) wake_up_interruptible(&info->wait);
+	return;
+}
+
+static int do_block_io_op(blkif_t *blkif);
+static void dispatch_rw_block_io(blkif_t *blkif,
+				 blkif_request_t *req,
+				 pending_req_t *pending_req);
+static void make_response(blkif_t *blkif, unsigned long id, 
+                          unsigned short op, int st);
+
+/******************************************************************
+ * misc small helpers
+ */
+/* FIXME: Return ENOMEM properly on failure to allocate additional reqs. */
+static void req_increase(void)
+{
+	int i, j;
+	struct page *page;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+
+	if (mmap_alloc >= MAX_PENDING_REQS || mmap_lock) 
+		goto done;
+
+	pending_reqs[mmap_alloc]  = kzalloc(sizeof(pending_req_t) *
+					blkif_reqs, GFP_KERNEL);
+	pending_addrs[mmap_alloc] = kzalloc(sizeof(unsigned long) *
+					mmap_pages, GFP_KERNEL);
+
+	if (!pending_reqs[mmap_alloc] || !pending_addrs[mmap_alloc]) {
+		kfree(pending_reqs[mmap_alloc]);
+		kfree(pending_addrs[mmap_alloc]);
+		WPRINTK("%s: out of memory\n", __FUNCTION__); 
+		goto done;
+	}
+
+#ifdef __ia64__
+	extern unsigned long alloc_empty_foreign_map_page_range(
+		unsigned long pages);
+	mmap_start[mmap_alloc].start = (unsigned long)
+		alloc_empty_foreign_map_page_range(mmap_pages);
+#else /* ! ia64 */
+	page = balloon_alloc_empty_page_range(mmap_pages);
+	BUG_ON(page == NULL);
+
+	/* Pin all of the pages. */
+	for (i=0; i<mmap_pages; i++)
+		get_page(&page[i]);
+
+	mmap_start[mmap_alloc].start = 
+		(unsigned long)pfn_to_kaddr(page_to_pfn(page));
+	mmap_start[mmap_alloc].mpage = page;
+
+#endif
+	DPRINTK("%s: reqs=%d, pages=%d, mmap_vstart=0x%lx\n",
+	        __FUNCTION__, blkif_reqs, mmap_pages, 
+	       mmap_start[mmap_alloc].start);
+
+	BUG_ON(mmap_start[mmap_alloc].start == 0);
+
+	for (i = 0; i < mmap_pages; i++) 
+		pending_addrs[mmap_alloc][i] = 
+			mmap_start[mmap_alloc].start + (i << PAGE_SHIFT);
+
+	for (i = 0; i < MAX_PENDING_REQS ; i++) {
+		list_add_tail(&pending_reqs[mmap_alloc][i].free_list, 
+			      &pending_free);
+		pending_reqs[mmap_alloc][i].mem_idx = mmap_alloc;
+		for (j = 0; j < BLKIF_MAX_SEGMENTS_PER_REQUEST; j++)
+			BLKTAP_INVALIDATE_HANDLE(&pending_handle(mmap_alloc, 
+								 i, j));
+	}
+
+	mmap_alloc++;
+	DPRINTK("# MMAPs increased to %d\n",mmap_alloc);
+ done:
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+
+}
+
+static void mmap_req_del(int mmap)
+{
+	int i;
+	struct page *page;
+
+	/*Spinlock already acquired*/
+	kfree(pending_reqs[mmap]);
+	kfree(pending_addrs[mmap]);
+
+#ifdef __ia64__
+	/*Not sure what goes here yet!*/
+#else
+
+	/* Unpin all of the pages. */
+	page = mmap_start[mmap].mpage;
+	for (i=0; i<mmap_pages; i++)
+		put_page(&page[i]);
+
+	balloon_dealloc_empty_page_range(mmap_start[mmap].mpage, mmap_pages);
+#endif
+
+	mmap_lock = 0;
+	DPRINTK("# MMAPs decreased to %d\n",mmap_alloc);
+	mmap_alloc--;
+}
+
+/*N.B. Currently unused - will be accessed via sysfs*/
+static void req_decrease(void)
+{
+	pending_req_t *req;
+	int i;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+
+	DPRINTK("Req decrease called.\n");
+	if (mmap_lock || mmap_alloc == 1) 
+		goto done;
+
+	mmap_lock = 1;
+	mmap_inuse = MAX_PENDING_REQS;
+	
+        /*Go through reqs and remove any that aren't in use*/
+	for (i = 0; i < MAX_PENDING_REQS ; i++) {
+		req = &pending_reqs[mmap_alloc-1][i];
+		if (req->inuse == 0) {
+			list_del(&req->free_list);
+			mmap_inuse--;
+		}
+	}
+	if (mmap_inuse == 0) mmap_req_del(mmap_alloc-1);
+ done:
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+	return;
+}
+
+static pending_req_t* alloc_req(void)
+{
+	pending_req_t *req = NULL;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+
+	if (!list_empty(&pending_free)) {
+		req = list_entry(pending_free.next, pending_req_t, free_list);
+		list_del(&req->free_list);
+	}
+
+	if (req) {
+		req->inuse = 1;
+		alloc_pending_reqs++;
+	}
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+
+	return req;
+}
+
+static void free_req(pending_req_t *req)
+{
+	unsigned long flags;
+	int was_empty;
+
+	spin_lock_irqsave(&pending_free_lock, flags);
+
+	alloc_pending_reqs--;
+	req->inuse = 0;
+	if (mmap_lock && (req->mem_idx == mmap_alloc-1)) {
+		mmap_inuse--;
+		if (mmap_inuse == 0) mmap_req_del(mmap_alloc-1);
+		spin_unlock_irqrestore(&pending_free_lock, flags);
+		return;
+	}
+	was_empty = list_empty(&pending_free);
+	list_add(&req->free_list, &pending_free);
+
+	spin_unlock_irqrestore(&pending_free_lock, flags);
+
+	if (was_empty)
+		wake_up(&pending_free_wq);
+}
+
+static void fast_flush_area(pending_req_t *req, int k_idx, int u_idx, int 
+			    tapidx)
+{
+	struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
+	unsigned int i, invcount = 0;
+	struct grant_handle_pair *khandle;
+	uint64_t ptep;
+	int ret, mmap_idx;
+	unsigned long kvaddr, uvaddr;
+
+	tap_blkif_t *info = tapfds[tapidx];
+	
+	if (info == NULL) {
+		WPRINTK("fast_flush: Couldn't get info!\n");
+		return;
+	}
+	mmap_idx = req->mem_idx;
+
+	for (i = 0; i < req->nr_pages; i++) {
+		kvaddr = MMAP_VADDR(mmap_start[mmap_idx].start, k_idx, i);
+		uvaddr = MMAP_VADDR(info->user_vstart, u_idx, i);
+
+		khandle = &pending_handle(mmap_idx, k_idx, i);
+		if (BLKTAP_INVALID_HANDLE(khandle)) {
+			WPRINTK("BLKTAP_INVALID_HANDLE\n");
+			continue;
+		}
+		gnttab_set_unmap_op(&unmap[invcount], 
+			MMAP_VADDR(mmap_start[mmap_idx].start, k_idx, i), 
+				    GNTMAP_host_map, khandle->kernel);
+		invcount++;
+
+		if (create_lookup_pte_addr(
+		    info->vma->vm_mm,
+		    MMAP_VADDR(info->user_vstart, u_idx, i), 
+		    &ptep) !=0) {
+			WPRINTK("Couldn't get a pte addr!\n");
+			return;
+		}
+
+		gnttab_set_unmap_op(&unmap[invcount], 
+			ptep, GNTMAP_host_map,
+			khandle->user);
+		invcount++;
+            
+		BLKTAP_INVALIDATE_HANDLE(khandle);
+	}
+	ret = HYPERVISOR_grant_table_op(
+		GNTTABOP_unmap_grant_ref, unmap, invcount);
+	BUG_ON(ret);
+	
+	if (info->vma != NULL)
+		zap_page_range(info->vma, 
+			       MMAP_VADDR(info->user_vstart, u_idx, 0), 
+			       req->nr_pages << PAGE_SHIFT, NULL);
+}
+
+/******************************************************************
+ * SCHEDULER FUNCTIONS
+ */
+
+static void print_stats(blkif_t *blkif)
+{
+	printk(KERN_DEBUG "%s: oo %3d  |  rd %4d  |  wr %4d\n",
+	       current->comm, blkif->st_oo_req,
+	       blkif->st_rd_req, blkif->st_wr_req);
+	blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000);
+	blkif->st_rd_req = 0;
+	blkif->st_wr_req = 0;
+	blkif->st_oo_req = 0;
+}
+
+int tap_blkif_schedule(void *arg)
+{
+	blkif_t *blkif = arg;
+
+	blkif_get(blkif);
+
+	if (debug_lvl)
+		printk(KERN_DEBUG "%s: started\n", current->comm);
+
+	while (!kthread_should_stop()) {
+		wait_event_interruptible(
+			blkif->wq,
+			blkif->waiting_reqs || kthread_should_stop());
+		wait_event_interruptible(
+			pending_free_wq,
+			!list_empty(&pending_free) || kthread_should_stop());
+
+		blkif->waiting_reqs = 0;
+		smp_mb(); /* clear flag *before* checking for work */
+
+		if (do_block_io_op(blkif))
+			blkif->waiting_reqs = 1;
+
+		if (log_stats && time_after(jiffies, blkif->st_print))
+			print_stats(blkif);
+	}
+
+	if (log_stats)
+		print_stats(blkif);
+	if (debug_lvl)
+		printk(KERN_DEBUG "%s: exiting\n", current->comm);
+
+	blkif->xenblkd = NULL;
+	blkif_put(blkif);
+
+	return 0;
+}
+
+/******************************************************************
+ * COMPLETION CALLBACK -- Called by user level ioctl()
+ */
+
+static int blktap_read_ufe_ring(int idx)
+{
+	/* This is called to read responses from the UFE ring. */
+	RING_IDX i, j, rp;
+	blkif_response_t *resp;
+	blkif_t *blkif=NULL;
+	int pending_idx, usr_idx, mmap_idx;
+	pending_req_t *pending_req;
+	tap_blkif_t *info;
+	
+	info = tapfds[idx];
+	if (info == NULL) {
+		return 0;
+	}
+
+	/* We currently only forward packets in INTERCEPT_FE mode. */
+	if (!(info->mode & BLKTAP_MODE_INTERCEPT_FE))
+		return 0;
+
+	/* for each outstanding message on the UFEring  */
+	rp = info->ufe_ring.sring->rsp_prod;
+	rmb();
+        
+	for (i = info->ufe_ring.rsp_cons; i != rp; i++) {
+		resp = RING_GET_RESPONSE(&info->ufe_ring, i);
+		++info->ufe_ring.rsp_cons;
+
+		/*retrieve [usr_idx] to [mmap_idx,pending_idx] mapping*/
+		usr_idx = (int)resp->id;
+		pending_idx = MASK_PEND_IDX(ID_TO_IDX(info->idx_map[usr_idx]));
+		mmap_idx = ID_TO_MIDX(info->idx_map[usr_idx]);
+
+		if ( (mmap_idx >= mmap_alloc) || 
+		   (ID_TO_IDX(info->idx_map[usr_idx]) >= MAX_PENDING_REQS) )
+			WPRINTK("Incorrect req map"
+			       "[%d], internal map [%d,%d (%d)]\n", 
+			       usr_idx, mmap_idx, 
+			       ID_TO_IDX(info->idx_map[usr_idx]),
+			       MASK_PEND_IDX(
+				       ID_TO_IDX(info->idx_map[usr_idx])));
+
+		pending_req = &pending_reqs[mmap_idx][pending_idx];
+		blkif = pending_req->blkif;
+
+		for (j = 0; j < pending_req->nr_pages; j++) {
+
+			unsigned long kvaddr, uvaddr;
+			struct page **map = info->vma->vm_private_data;
+			struct page *pg;
+			int offset; 
+
+			uvaddr  = MMAP_VADDR(info->user_vstart, usr_idx, j);
+			kvaddr = MMAP_VADDR(mmap_start[mmap_idx].start, 
+					    pending_idx, j);
+
+			pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
+			ClearPageReserved(pg);
+			offset = (uvaddr - info->vma->vm_start) 
+				>> PAGE_SHIFT;
+			map[offset] = NULL;
+		}
+		fast_flush_area(pending_req, pending_idx, usr_idx, idx); 
+		make_response(blkif, pending_req->id, resp->operation,
+			      resp->status);
+		info->idx_map[usr_idx] = INVALID_REQ;
+		blkif_put(pending_req->blkif);
+		free_req(pending_req);
+	}
+		
+	return 0;
+}
+
+
+/******************************************************************************
+ * NOTIFICATION FROM GUEST OS.
+ */
+
+static void blkif_notify_work(blkif_t *blkif)
+{
+	blkif->waiting_reqs = 1;
+	wake_up(&blkif->wq);
+}
+
+irqreturn_t tap_blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+	blkif_notify_work(dev_id);
+	return IRQ_HANDLED;
+}
+
+
+
+/******************************************************************
+ * DOWNWARD CALLS -- These interface with the block-device layer proper.
+ */
+static int print_dbug = 1;
+static int do_block_io_op(blkif_t *blkif)
+{
+	blkif_back_ring_t *blk_ring = &blkif->blk_ring;
+	blkif_request_t *req;
+	pending_req_t *pending_req;
+	RING_IDX rc, rp;
+	int more_to_do = 0;
+	tap_blkif_t *info;
+
+	rc = blk_ring->req_cons;
+	rp = blk_ring->sring->req_prod;
+	rmb(); /* Ensure we see queued requests up to 'rp'. */
+
+	/*Check blkif has corresponding UE ring*/
+	if (blkif->dev_num == -1) {
+		/*oops*/
+		if (print_dbug) {
+			WPRINTK("Corresponding UE " 
+			       "ring does not exist!\n");
+			print_dbug = 0; /*We only print this message once*/
+		}
+		return 1; 
+	}
+
+	info = tapfds[blkif->dev_num];
+	if (info == NULL || !info->dev_inuse) {
+		if (print_dbug) {
+			WPRINTK("Can't get UE info!\n");
+			print_dbug = 0;
+		}
+		return 1;
+	}
+
+	while (rc != rp) {
+		
+		if (RING_FULL(&info->ufe_ring)) {
+			WPRINTK("RING_FULL! More to do\n");
+			more_to_do = 1;
+			break;
+		}
+		
+		if (RING_REQUEST_CONS_OVERFLOW(blk_ring, rc)) {
+			WPRINTK("RING_REQUEST_CONS_OVERFLOW!"
+			       " More to do\n");
+			more_to_do = 1;
+			break;		
+		}
+
+		pending_req = alloc_req();
+		if (NULL == pending_req) {
+			blkif->st_oo_req++;
+			more_to_do = 1;
+			break;
+		}
+
+		req = RING_GET_REQUEST(blk_ring, rc);
+		blk_ring->req_cons = ++rc; /* before make_response() */	
+
+		switch (req->operation) {
+		case BLKIF_OP_READ:
+			blkif->st_rd_req++;
+			dispatch_rw_block_io(blkif, req, pending_req);
+			break;
+
+		case BLKIF_OP_WRITE:
+			blkif->st_wr_req++;
+			dispatch_rw_block_io(blkif, req, pending_req);
+			break;
+
+		default:
+			WPRINTK("unknown operation [%d]\n",
+				req->operation);
+			make_response(blkif, req->id, req->operation,
+				      BLKIF_RSP_ERROR);
+			free_req(pending_req);
+			break;
+		}
+	}
+		
+	blktap_kick_user(blkif->dev_num);
+
+	return more_to_do;
+}
+
+static void dispatch_rw_block_io(blkif_t *blkif,
+				 blkif_request_t *req,
+				 pending_req_t *pending_req)
+{
+	extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]); 
+	int op, operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
+	struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
+	unsigned int nseg;
+	int ret, i;
+	tap_blkif_t *info = tapfds[blkif->dev_num];
+	uint64_t sector;
+	
+	blkif_request_t *target;
+	int pending_idx = RTN_PEND_IDX(pending_req,pending_req->mem_idx);
+	int usr_idx = GET_NEXT_REQ(info->idx_map);
+	uint16_t mmap_idx = pending_req->mem_idx;
+
+	/*Check we have space on user ring - should never fail*/
+	if(usr_idx == INVALID_REQ) goto fail_flush;
+	
+	/* Check that number of segments is sane. */
+	nseg = req->nr_segments;
+	if ( unlikely(nseg == 0) || 
+	    unlikely(nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST) ) {
+		WPRINTK("Bad number of segments in request (%d)\n", nseg);
+		goto fail_response;
+	}
+	
+	/* Make sure userspace is ready. */
+	if (!info->ring_ok) {
+		WPRINTK("blktap: ring not ready for requests!\n");
+		goto fail_response;
+	}
+
+	if (RING_FULL(&info->ufe_ring)) {
+		WPRINTK("blktap: fe_ring is full, can't add "
+			"IO Request will be dropped. %d %d\n",
+			RING_SIZE(&info->ufe_ring),
+			RING_SIZE(&blkif->blk_ring));
+		goto fail_response;
+	}
+
+	pending_req->blkif     = blkif;
+	pending_req->id        = req->id;
+	pending_req->operation = operation;
+	pending_req->status    = BLKIF_RSP_OKAY;
+	pending_req->nr_pages  = nseg;
+	op = 0;
+	for (i = 0; i < nseg; i++) {
+		unsigned long uvaddr;
+		unsigned long kvaddr;
+		uint64_t ptep;
+		struct page *page;
+		uint32_t flags;
+
+		uvaddr = MMAP_VADDR(info->user_vstart, usr_idx, i);
+		kvaddr = MMAP_VADDR(mmap_start[mmap_idx].start, 
+				    pending_idx, i);
+		page = virt_to_page(kvaddr);
+
+		sector = req->sector_number + (8*i);
+		if( (blkif->sectors > 0) && (sector >= blkif->sectors) ) {
+			WPRINTK("BLKTAP: Sector request greater" 
+			       "than size\n");
+			WPRINTK("BLKTAP: %s request sector" 
+			       "[%llu,%llu], Total [%llu]\n",
+			       (req->operation == 
+				BLKIF_OP_WRITE ? "WRITE" : "READ"),
+				(long long unsigned) sector,
+				(long long unsigned) sector>>9,
+				blkif->sectors);
+		}
+
+		flags = GNTMAP_host_map;
+		if (operation == WRITE)
+			flags |= GNTMAP_readonly;
+		gnttab_set_map_op(&map[op], kvaddr, flags,
+				  req->seg[i].gref, blkif->domid);
+		op++;
+
+		/* Now map it to user. */
+		ret = create_lookup_pte_addr(info->vma->vm_mm, 
+					     uvaddr, &ptep);
+		if (ret) {
+			WPRINTK("Couldn't get a pte addr!\n");
+			fast_flush_area(pending_req, pending_idx, usr_idx, 
+					blkif->dev_num);
+			goto fail_flush;
+		}
+
+		flags = GNTMAP_host_map | GNTMAP_application_map
+			| GNTMAP_contains_pte;
+		if (operation == WRITE)
+			flags |= GNTMAP_readonly;
+		gnttab_set_map_op(&map[op], ptep, flags,
+				  req->seg[i].gref, blkif->domid);
+		op++;
+	}
+
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
+	BUG_ON(ret);
+
+	for (i = 0; i < (nseg*2); i+=2) {
+		unsigned long uvaddr;
+		unsigned long kvaddr;
+		unsigned long offset;
+		struct page *pg;
+
+		uvaddr = MMAP_VADDR(info->user_vstart, usr_idx, i/2);
+		kvaddr = MMAP_VADDR(mmap_start[mmap_idx].start, 
+				    pending_idx, i/2);
+
+		if (unlikely(map[i].status != 0)) {
+			WPRINTK("invalid kernel buffer -- "
+				"could not remap it\n");
+			goto fail_flush;
+		}
+
+		if (unlikely(map[i+1].status != 0)) {
+			WPRINTK("invalid user buffer -- "
+				"could not remap it\n");
+			goto fail_flush;
+		}
+
+		pending_handle(mmap_idx, pending_idx, i/2).kernel 
+			= map[i].handle;
+		pending_handle(mmap_idx, pending_idx, i/2).user   
+			= map[i+1].handle;
+#ifdef CONFIG_XEN_IA64_DOM0_NON_VP
+		pending_addrs[mmap_idx][vaddr_pagenr(pending_req, i)] =
+			(unsigned long)gnttab_map_vaddr(map[i]);
+#else
+		set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT,
+			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
+#endif
+		offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT;
+		pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
+		((struct page **)info->vma->vm_private_data)[offset] =
+			pg;
+	}
+	/* Mark mapped pages as reserved: */
+	for (i = 0; i < req->nr_segments; i++) {
+		unsigned long kvaddr;
+		struct page *pg;
+
+		kvaddr = MMAP_VADDR(mmap_start[mmap_idx].start, 
+				    pending_idx, i);
+		pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
+		SetPageReserved(pg);
+	}
+	
+	/*record [mmap_idx,pending_idx] to [usr_idx] mapping*/
+	info->idx_map[usr_idx] = MAKE_ID(mmap_idx, pending_idx);
+
+	blkif_get(blkif);
+	/* Finally, write the request message to the user ring. */
+	target = RING_GET_REQUEST(&info->ufe_ring,
+				  info->ufe_ring.req_prod_pvt);
+	memcpy(target, req, sizeof(*req));
+	target->id = usr_idx;
+	info->ufe_ring.req_prod_pvt++;
+	return;
+
+ fail_flush:
+	WPRINTK("Reached Fail_flush\n");
+	fast_flush_area(pending_req, pending_idx, usr_idx, blkif->dev_num);
+ fail_response:
+	make_response(blkif, req->id, req->operation, BLKIF_RSP_ERROR);
+	free_req(pending_req);
+} 
+
+
+
+/******************************************************************
+ * MISCELLANEOUS SETUP / TEARDOWN / DEBUGGING
+ */
+
+
+static void make_response(blkif_t *blkif, unsigned long id, 
+                          unsigned short op, int st)
+{
+	blkif_response_t *resp;
+	unsigned long     flags;
+	blkif_back_ring_t *blk_ring = &blkif->blk_ring;
+	int more_to_do = 0;
+	int notify;
+
+	spin_lock_irqsave(&blkif->blk_ring_lock, flags);
+	/* Place on the response ring for the relevant domain. */ 
+	resp = RING_GET_RESPONSE(blk_ring, blk_ring->rsp_prod_pvt);
+	resp->id        = id;
+	resp->operation = op;
+	resp->status    = st;
+	blk_ring->rsp_prod_pvt++;
+	RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(blk_ring, notify);
+
+	if (blk_ring->rsp_prod_pvt == blk_ring->req_cons) {
+		/*
+		 * Tail check for pending requests. Allows frontend to avoid
+		 * notifications if requests are already in flight (lower
+		 * overheads and promotes batching).
+		 */
+		RING_FINAL_CHECK_FOR_REQUESTS(blk_ring, more_to_do);
+	} else if (RING_HAS_UNCONSUMED_REQUESTS(blk_ring)) {
+		more_to_do = 1;
+
+	}	
+	spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
+	if (more_to_do)
+		blkif_notify_work(blkif);
+	if (notify)
+		notify_remote_via_irq(blkif->irq);
+}
+
+static int __init blkif_init(void)
+{
+	int i,ret,blktap_dir;
+	tap_blkif_t *info;
+
+	if (!is_running_on_xen())
+		return -ENODEV;
+
+	INIT_LIST_HEAD(&pending_free);
+        for(i = 0; i < 2; i++) req_increase();
+
+	tap_blkif_interface_init();
+
+	alloc_pending_reqs = 0;
+
+	tap_blkif_xenbus_init();
+
+	/*Create the blktap devices, but do not map memory or waitqueue*/
+	for(i = 0; i < MAX_TAP_DEV; i++) translate_domid[i].domid = 0xFFFF;
+
+	ret = register_chrdev(BLKTAP_DEV_MAJOR,"blktap",&blktap_fops);
+	blktap_dir = devfs_mk_dir(NULL, "xen", 0, NULL);
+
+	if ( (ret < 0)||(blktap_dir < 0) ) {
+		WPRINTK("Couldn't register /dev/xen/blktap\n");
+		return -ENOMEM;
+	}	
+	
+	for(i = 0; i < MAX_TAP_DEV; i++ ) {
+		info = tapfds[i] = kzalloc(sizeof(tap_blkif_t),GFP_KERNEL);
+		if(tapfds[i] == NULL) return -ENOMEM;
+		info->minor = i;
+		info->pid = 0;
+		info->blkif = NULL;
+
+		ret = devfs_mk_cdev(MKDEV(BLKTAP_DEV_MAJOR, i),
+			S_IFCHR|S_IRUGO|S_IWUSR, "xen/blktap%d", i);
+
+		if(ret != 0) return -ENOMEM;
+		info->dev_pending = info->dev_inuse = 0;
+
+		DPRINTK("Created misc_dev [/dev/xen/blktap%d]\n",i);
+	}
+	
+	DPRINTK("Blktap device successfully created\n");
+
+	return 0;
+}
+
+module_init(blkif_init);
+
+MODULE_LICENSE("Dual BSD/GPL");
diff -urN xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/blktap/common.h xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/blktap/common.h
--- xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/blktap/common.h	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/blktap/common.h	2006-07-08 02:03:48.000000000 +0100
@@ -0,0 +1,120 @@
+/* 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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 __BLKIF__BACKEND__COMMON_H__
+#define __BLKIF__BACKEND__COMMON_H__
+
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/slab.h>
+#include <linux/blkdev.h>
+#include <linux/vmalloc.h>
+#include <asm/io.h>
+#include <asm/setup.h>
+#include <asm/pgalloc.h>
+#include <xen/evtchn.h>
+#include <asm/hypervisor.h>
+#include <xen/interface/io/blkif.h>
+#include <xen/interface/io/ring.h>
+#include <xen/gnttab.h>
+#include <xen/driver_util.h>
+
+#define DPRINTK(_f, _a...) pr_debug("(file=%s, line=%d) " _f, \
+                                    __FILE__ , __LINE__ , ## _a )
+
+#define WPRINTK(fmt, args...) printk(KERN_WARNING "blk_tap: " fmt, ##args)
+
+struct backend_info; 
+
+typedef struct blkif_st {
+	/* Unique identifier for this interface. */
+	domid_t           domid;
+	unsigned int      handle;
+	/* Physical parameters of the comms window. */
+	unsigned int      evtchn;
+	unsigned int      irq;
+	/* Comms information. */
+	blkif_back_ring_t blk_ring;
+	struct vm_struct *blk_ring_area;
+	/* Back pointer to the backend_info. */
+	struct backend_info *be; 
+	/* Private fields. */
+	spinlock_t       blk_ring_lock;
+	atomic_t         refcnt;
+
+	wait_queue_head_t   wq;
+	struct task_struct  *xenblkd;
+	unsigned int        waiting_reqs;
+	request_queue_t     *plug;
+
+	/* statistics */
+	unsigned long       st_print;
+	int                 st_rd_req;
+	int                 st_wr_req;
+	int                 st_oo_req;
+
+	wait_queue_head_t waiting_to_free;
+
+	grant_handle_t shmem_handle;
+	grant_ref_t    shmem_ref;
+	
+	int		dev_num;
+	uint64_t        sectors;
+} blkif_t;
+
+blkif_t *tap_alloc_blkif(domid_t domid);
+void tap_blkif_free(blkif_t *blkif);
+int tap_blkif_map(blkif_t *blkif, unsigned long shared_page, 
+		  unsigned int evtchn);
+
+#define blkif_get(_b) (atomic_inc(&(_b)->refcnt))
+#define blkif_put(_b)					\
+	do {						\
+		if (atomic_dec_and_test(&(_b)->refcnt))	\
+			wake_up(&(_b)->waiting_to_free);\
+	} while (0)
+
+
+struct phys_req {
+	unsigned short       dev;
+	unsigned short       nr_sects;
+	struct block_device *bdev;
+	blkif_sector_t       sector_number;
+};
+
+void tap_blkif_interface_init(void);
+
+void tap_blkif_xenbus_init(void);
+
+irqreturn_t tap_blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
+int tap_blkif_schedule(void *arg);
+
+int dom_to_devid(domid_t domid, int xenbus_id, blkif_t *blkif);
+void signal_tapdisk(int idx);
+
+#endif /* __BLKIF__BACKEND__COMMON_H__ */
diff -urN xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	2006-07-08 02:03:48.000000000 +0100
@@ -0,0 +1,165 @@
+/******************************************************************************
+ * drivers/xen/blktap/interface.c
+ * 
+ * Block-device interface management.
+ * 
+ * Copyright (c) 2004, Keir Fraser
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+
+ */
+
+#include "common.h"
+#include <xen/evtchn.h>
+
+static kmem_cache_t *blkif_cachep;
+
+blkif_t *tap_alloc_blkif(domid_t domid)
+{
+	blkif_t *blkif;
+
+	blkif = kmem_cache_alloc(blkif_cachep, GFP_KERNEL);
+	if (!blkif)
+		return ERR_PTR(-ENOMEM);
+
+	memset(blkif, 0, sizeof(*blkif));
+	blkif->domid = domid;
+	spin_lock_init(&blkif->blk_ring_lock);
+	atomic_set(&blkif->refcnt, 1);
+	init_waitqueue_head(&blkif->wq);
+	blkif->st_print = jiffies;
+	init_waitqueue_head(&blkif->waiting_to_free);
+
+	return blkif;
+}
+
+static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
+{
+	struct gnttab_map_grant_ref op;
+	int ret;
+
+	gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+			  GNTMAP_host_map, shared_page, blkif->domid);
+
+	lock_vm_area(blkif->blk_ring_area);
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
+	unlock_vm_area(blkif->blk_ring_area);
+	BUG_ON(ret);
+
+	if (op.status) {
+		DPRINTK(" Grant table operation failure !\n");
+		return op.status;
+	}
+
+	blkif->shmem_ref = shared_page;
+	blkif->shmem_handle = op.handle;
+
+#ifdef CONFIG_XEN_IA64_DOM0_NON_VP
+	/* on some arch's, map_grant_ref behaves like mmap, in that the
+	 * passed address is a hint and a different address may be returned */
+	blkif->blk_ring_area->addr = gnttab_map_vaddr(op);
+#endif
+
+	return 0;
+}
+
+static void unmap_frontend_page(blkif_t *blkif)
+{
+	struct gnttab_unmap_grant_ref op;
+	int ret;
+
+	gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+			    GNTMAP_host_map, blkif->shmem_handle);
+
+	lock_vm_area(blkif->blk_ring_area);
+	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
+	unlock_vm_area(blkif->blk_ring_area);
+	BUG_ON(ret);
+}
+
+int tap_blkif_map(blkif_t *blkif, unsigned long shared_page, 
+		  unsigned int evtchn)
+{
+	blkif_sring_t *sring;
+	int err;
+	struct evtchn_bind_interdomain bind_interdomain;
+
+	/* Already connected through? */
+	if (blkif->irq)
+		return 0;
+
+	if ( (blkif->blk_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL )
+		return -ENOMEM;
+
+	err = map_frontend_page(blkif, shared_page);
+	if (err) {
+		free_vm_area(blkif->blk_ring_area);
+		return err;
+	}
+
+	bind_interdomain.remote_dom  = blkif->domid;
+	bind_interdomain.remote_port = evtchn;
+
+	err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
+					  &bind_interdomain);
+	if (err) {
+		unmap_frontend_page(blkif);
+		free_vm_area(blkif->blk_ring_area);
+		return err;
+	}
+
+	blkif->evtchn = bind_interdomain.local_port;
+
+	sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
+	BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
+
+	blkif->irq = bind_evtchn_to_irqhandler(
+		blkif->evtchn, tap_blkif_be_int, 0, "blkif-backend", blkif);
+
+	return 0;
+}
+
+void tap_blkif_free(blkif_t *blkif)
+{
+	atomic_dec(&blkif->refcnt);
+	wait_event(blkif->waiting_to_free, atomic_read(&blkif->refcnt) == 0);
+
+	/* Already disconnected? */
+	if (blkif->irq)
+		unbind_from_irqhandler(blkif->irq, blkif);
+
+	if (blkif->blk_ring.sring) {
+		unmap_frontend_page(blkif);
+		free_vm_area(blkif->blk_ring_area);
+	}
+
+	kmem_cache_free(blkif_cachep, blkif);
+}
+
+void __init tap_blkif_interface_init(void)
+{
+	blkif_cachep = kmem_cache_create("blktapif_cache", sizeof(blkif_t), 
+					 0, 0, NULL, NULL);
+}
diff -urN xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/blktap/Makefile xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/blktap/Makefile
--- xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/blktap/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/blktap/Makefile	2006-07-08 02:03:48.000000000 +0100
@@ -0,0 +1,3 @@
+LINUXINCLUDE += -I../xen/include/public/io
+obj-y	:= xenbus.o interface.o blktap.o 
+
diff -urN xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
--- xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	2006-07-08 02:03:48.000000000 +0100
@@ -0,0 +1,354 @@
+/* drivers/xen/blktap/xenbus.c
+ *
+ * Xenbus code for blktap
+ *
+ * Copyright (c) 2004-2005, Andrew Warfield and Julian Chesterfield
+ *
+ * Based on the blkback xenbus code:
+ *
+ * Copyright (C) 2005 Rusty Russell <rusty@rustcorp.com.au>
+ * Copyright (C) 2005 XenSource Ltd
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <stdarg.h>
+#include <linux/module.h>
+#include <linux/kthread.h>
+#include <xen/xenbus.h>
+#include "common.h"
+
+
+struct backend_info
+{
+	struct xenbus_device *dev;
+	blkif_t *blkif;
+	struct xenbus_watch backend_watch;
+	int xenbus_id;
+};
+
+
+static void connect(struct backend_info *);
+static int connect_ring(struct backend_info *);
+static int blktap_remove(struct xenbus_device *dev);
+static int blktap_probe(struct xenbus_device *dev,
+			 const struct xenbus_device_id *id);
+static void tap_backend_changed(struct xenbus_watch *, const char **,
+			    unsigned int);
+static void tap_frontend_changed(struct xenbus_device *dev,
+			     enum xenbus_state frontend_state);
+
+static int strsep_len(const char *str, char c, unsigned int len)
+{
+        unsigned int i;
+
+        for (i = 0; str[i]; i++)
+                if (str[i] == c) {
+                        if (len == 0)
+                                return i;
+                        len--;
+                }
+        return (len == 0) ? i : -ERANGE;
+}
+
+static long get_id(const char *str)
+{
+        int len,end;
+        const char *ptr;
+        char *tptr, num[10];
+	
+        len = strsep_len(str, '/', 2);
+        end = strlen(str);
+        if ( (len < 0) || (end < 0) ) return -1;
+	
+        ptr = str + len + 1;
+        strncpy(num,ptr,end - len);
+        tptr = num + (end - (len + 1));
+        *tptr = '\0';
+	DPRINTK("Get_id called for %s (%s)\n",str,num);
+	
+        return simple_strtol(num, NULL, 10);
+}				
+
+static void tap_update_blkif_status(blkif_t *blkif)
+{ 
+	int err;
+
+	/* Not ready to connect? */
+	if(!blkif->irq || !blkif->sectors) {
+		return;
+	} 
+
+	/* Already connected? */
+	if (blkif->be->dev->state == XenbusStateConnected)
+		return;
+
+	/* Attempt to connect: exit if we fail to. */
+	connect(blkif->be);
+	if (blkif->be->dev->state != XenbusStateConnected)
+		return;
+
+	blkif->xenblkd = kthread_run(tap_blkif_schedule, blkif,
+				     "xvd %d",
+				     blkif->domid);
+
+	if (IS_ERR(blkif->xenblkd)) {
+		err = PTR_ERR(blkif->xenblkd);
+		blkif->xenblkd = NULL;
+		xenbus_dev_fatal(blkif->be->dev, err, "start xenblkd");
+		WPRINTK("Error starting thread\n");
+	}
+}
+
+static int blktap_remove(struct xenbus_device *dev)
+{
+	struct backend_info *be = dev->dev.driver_data;
+
+	if (be->backend_watch.node) {
+		unregister_xenbus_watch(&be->backend_watch);
+		kfree(be->backend_watch.node);
+		be->backend_watch.node = NULL;
+	}
+	if (be->blkif) {
+		if (be->blkif->xenblkd)
+			kthread_stop(be->blkif->xenblkd);
+		signal_tapdisk(be->blkif->dev_num);
+		tap_blkif_free(be->blkif);
+		be->blkif = NULL;
+	}
+	kfree(be);
+	dev->dev.driver_data = NULL;
+	return 0;
+}
+
+/**
+ * Entry point to this code when a new device is created.  Allocate
+ * the basic structures, and watch the store waiting for the
+ * user-space program to tell us the physical device info.  Switch to
+ * InitWait.
+ */
+static int blktap_probe(struct xenbus_device *dev,
+			 const struct xenbus_device_id *id)
+{
+	int err;
+	struct backend_info *be = kzalloc(sizeof(struct backend_info),
+					  GFP_KERNEL);
+	if (!be) {
+		xenbus_dev_fatal(dev, -ENOMEM,
+				 "allocating backend structure");
+		return -ENOMEM;
+	}
+
+	be->dev = dev;
+	dev->dev.driver_data = be;
+	be->xenbus_id = get_id(dev->nodename);
+
+	be->blkif = tap_alloc_blkif(dev->otherend_id);
+	if (IS_ERR(be->blkif)) {
+		err = PTR_ERR(be->blkif);
+		be->blkif = NULL;
+		xenbus_dev_fatal(dev, err, "creating block interface");
+		goto fail;
+	}
+
+	/* setup back pointer */
+	be->blkif->be = be; 
+	be->blkif->sectors = 0;
+
+	/* set a watch on disk info, waiting for userspace to update details*/
+	err = xenbus_watch_path2(dev, dev->nodename, "info",
+				 &be->backend_watch, tap_backend_changed);
+	if (err)
+		goto fail;
+	
+	err = xenbus_switch_state(dev, XenbusStateInitWait);
+	if (err)
+		goto fail;
+	return 0;
+
+fail:
+	DPRINTK("blktap probe failed");
+	blktap_remove(dev);
+	return err;
+}
+
+
+/**
+ * Callback received when the user space code has placed the device
+ * information in xenstore. 
+ */
+static void tap_backend_changed(struct xenbus_watch *watch,
+			    const char **vec, unsigned int len)
+{
+	int err;
+	unsigned long info;
+	struct backend_info *be
+		= container_of(watch, struct backend_info, backend_watch);
+	struct xenbus_device *dev = be->dev;
+	
+	/** 
+	 * Check to see whether userspace code has opened the image 
+	 * and written sector
+	 * and disk info to xenstore
+	 */
+	err = xenbus_gather(XBT_NIL, dev->nodename, "info", "%lu", &info, 
+			    NULL);	
+	if (err) {
+		xenbus_dev_error(dev, err, "getting info");
+		return;
+	}
+
+	DPRINTK("Userspace update on disk info, %lu\n",info);
+
+	err = xenbus_gather(XBT_NIL, dev->nodename, "sectors", "%llu", 
+			    &be->blkif->sectors, NULL);
+
+	/* Associate tap dev with domid*/
+	be->blkif->dev_num = dom_to_devid(be->blkif->domid, be->xenbus_id, 
+					  be->blkif);
+	DPRINTK("Thread started for domid [%d], connecting disk\n", 
+		be->blkif->dev_num);
+
+	tap_update_blkif_status(be->blkif);
+}
+
+/**
+ * Callback received when the frontend's state changes.
+ */
+static void tap_frontend_changed(struct xenbus_device *dev,
+			     enum xenbus_state frontend_state)
+{
+	struct backend_info *be = dev->dev.driver_data;
+	int err;
+
+	DPRINTK("");
+
+	switch (frontend_state) {
+	case XenbusStateInitialising:
+		break;
+
+	case XenbusStateInitialised:
+	case XenbusStateConnected:
+		/* Ensure we connect even when two watches fire in 
+		   close successsion and we miss the intermediate value 
+		   of frontend_state. */
+		if (dev->state == XenbusStateConnected)
+			break;
+
+		err = connect_ring(be);
+		if (err)
+			break;
+		tap_update_blkif_status(be->blkif);
+		break;
+
+	case XenbusStateClosing:
+		xenbus_switch_state(dev, XenbusStateClosing);
+		break;
+
+	case XenbusStateClosed:
+		device_unregister(&dev->dev);
+		break;
+
+	case XenbusStateUnknown:
+	case XenbusStateInitWait:
+	default:
+		xenbus_dev_fatal(dev, -EINVAL, "saw state %d at frontend",
+				 frontend_state);
+		break;
+	}
+}
+
+
+/**
+ * Switch to Connected state.
+ */
+static void connect(struct backend_info *be)
+{
+	int err;
+
+	struct xenbus_device *dev = be->dev;
+
+	err = xenbus_switch_state(dev, XenbusStateConnected);
+	if (err)
+		xenbus_dev_fatal(dev, err, "switching to Connected state",
+				 dev->nodename);
+
+	return;
+}
+
+
+static int connect_ring(struct backend_info *be)
+{
+	struct xenbus_device *dev = be->dev;
+	unsigned long ring_ref;
+	unsigned int evtchn;
+	int err;
+
+	DPRINTK("%s", dev->otherend);
+
+	err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%lu", 
+			    &ring_ref, "event-channel", "%u", &evtchn, NULL);
+	if (err) {
+		xenbus_dev_fatal(dev, err,
+				 "reading %s/ring-ref and event-channel",
+				 dev->otherend);
+		return err;
+	}
+
+	/* Map the shared frame, irq etc. */
+	err = tap_blkif_map(be->blkif, ring_ref, evtchn);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "mapping ring-ref %lu port %u",
+				 ring_ref, evtchn);
+		return err;
+	} 
+
+	return 0;
+}
+
+
+/* ** Driver Registration ** */
+
+
+static struct xenbus_device_id blktap_ids[] = {
+	{ "tap" },
+	{ "" }
+};
+
+
+static struct xenbus_driver blktap = {
+	.name = "tap",
+	.owner = THIS_MODULE,
+	.ids = blktap_ids,
+	.probe = blktap_probe,
+	.remove = blktap_remove,
+	.otherend_changed = tap_frontend_changed
+};
+
+
+void tap_blkif_xenbus_init(void)
+{
+	xenbus_register_backend(&blktap);
+}
diff -urN xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/Kconfig xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/Kconfig
--- xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/Kconfig	2006-07-07 14:20:43.000000000 +0100
+++ xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/Kconfig	2006-07-08 02:03:48.000000000 +0100
@@ -89,6 +89,18 @@
 	  block devices to other guests via a high-performance shared-memory
 	  interface.
 
+config XEN_BLKDEV_TAP
+	tristate "Blockk device tap backend"
+	depends on XEN_BACKEND
+	default XEN_PRIVILEGED_GUEST
+	help
+	  The block tap driver is an alternative to the block back driver 
+          and allows VM block requests to be redirected to userspace through
+          a device interface.  The tap allows user-space development of 
+          high-performance block backends, where disk images may be implemented
+          as files, in memory, or on other hosts across the network.  This 
+	  driver can safely coexist with the existing blockback driver.
+
 config XEN_XENBUS_DEV
 	bool
 	depends on PROC_FS
diff -urN xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/Makefile xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/Makefile
--- xen-unstable-pristine.hg/linux-2.6-xen-sparse/drivers/xen/Makefile	2006-07-07 14:20:43.000000000 +0100
+++ xen-unstable-tapbuild.hg/linux-2.6-xen-sparse/drivers/xen/Makefile	2006-07-08 02:03:48.000000000 +0100
@@ -8,6 +8,7 @@
 obj-$(CONFIG_XEN_BALLOON)		+= balloon/
 obj-$(CONFIG_XEN_DEVMEM)		+= char/
 obj-$(CONFIG_XEN_BLKDEV_BACKEND)	+= blkback/
+obj-$(CONFIG_XEN_BLKDEV_TAP)		+= blktap/
 obj-$(CONFIG_XEN_NETDEV_BACKEND)	+= netback/
 obj-$(CONFIG_XEN_TPMDEV_BACKEND)	+= tpmback/
 obj-$(CONFIG_XEN_BLKDEV_FRONTEND)	+= blkfront/
diff -urN xen-unstable-pristine.hg/patches/linux-2.6.16.13/blktap-aio-16_03_06.patch xen-unstable-tapbuild.hg/patches/linux-2.6.16.13/blktap-aio-16_03_06.patch
--- xen-unstable-pristine.hg/patches/linux-2.6.16.13/blktap-aio-16_03_06.patch	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/patches/linux-2.6.16.13/blktap-aio-16_03_06.patch	2006-07-08 02:03:48.000000000 +0100
@@ -0,0 +1,297 @@
+diff -pruN ../pristine-linux-2.6.16-rc5/fs/aio.c ./fs/aio.c
+--- ../pristine-linux-2.6.16-rc5/fs/aio.c	2006-03-14 14:10:10.827401387 +0000
++++ ./fs/aio.c	2006-03-16 09:57:53.898316582 +0000
+@@ -34,6 +34,11 @@
+ #include <asm/uaccess.h>
+ #include <asm/mmu_context.h>
+ 
++#ifdef CONFIG_EPOLL
++#include <linux/poll.h>
++#include <linux/eventpoll.h>
++#endif
++
+ #if DEBUG > 1
+ #define dprintk		printk
+ #else
+@@ -1016,6 +1021,10 @@ put_rq:
+ 	if (waitqueue_active(&ctx->wait))
+ 		wake_up(&ctx->wait);
+ 
++#ifdef CONFIG_EPOLL
++	if (ctx->file && waitqueue_active(&ctx->poll_wait))
++		wake_up(&ctx->poll_wait);
++#endif
+ 	if (ret)
+ 		put_ioctx(ctx);
+ 
+@@ -1025,6 +1034,8 @@ put_rq:
+ /* aio_read_evt
+  *	Pull an event off of the ioctx's event ring.  Returns the number of 
+  *	events fetched (0 or 1 ;-)
++ *	If ent parameter is 0, just returns the number of events that would
++ *	be fetched.
+  *	FIXME: make this use cmpxchg.
+  *	TODO: make the ringbuffer user mmap()able (requires FIXME).
+  */
+@@ -1047,13 +1058,18 @@ static int aio_read_evt(struct kioctx *i
+ 
+ 	head = ring->head % info->nr;
+ 	if (head != ring->tail) {
+-		struct io_event *evp = aio_ring_event(info, head, KM_USER1);
+-		*ent = *evp;
+-		head = (head + 1) % info->nr;
+-		smp_mb(); /* finish reading the event before updatng the head */
+-		ring->head = head;
+-		ret = 1;
+-		put_aio_ring_event(evp, KM_USER1);
++		if (ent) { /* event requested */
++			struct io_event *evp =
++				aio_ring_event(info, head, KM_USER1);
++			*ent = *evp;
++			head = (head + 1) % info->nr;
++			/* finish reading the event before updatng the head */
++			smp_mb();
++			ring->head = head;
++			ret = 1;
++			put_aio_ring_event(evp, KM_USER1);
++		} else /* only need to know availability */
++			ret = 1;
+ 	}
+ 	spin_unlock(&info->ring_lock);
+ 
+@@ -1236,9 +1252,78 @@ static void io_destroy(struct kioctx *io
+ 
+ 	aio_cancel_all(ioctx);
+ 	wait_for_all_aios(ioctx);
++#ifdef CONFIG_EPOLL
++	/* forget the poll file, but it's up to the user to close it */
++	if (ioctx->file) {
++		ioctx->file->private_data = 0;
++		ioctx->file = 0;
++	}
++#endif
+ 	put_ioctx(ioctx);	/* once for the lookup */
+ }
+ 
++#ifdef CONFIG_EPOLL
++
++static int aio_queue_fd_close(struct inode *inode, struct file *file)
++{
++	struct kioctx *ioctx = file->private_data;
++	if (ioctx) {
++		file->private_data = 0;
++		spin_lock_irq(&ioctx->ctx_lock);
++		ioctx->file = 0;
++		spin_unlock_irq(&ioctx->ctx_lock);
++	}
++	return 0;
++}
++
++static unsigned int aio_queue_fd_poll(struct file *file, poll_table *wait)
++{	unsigned int pollflags = 0;
++	struct kioctx *ioctx = file->private_data;
++
++	if (ioctx) {
++
++		spin_lock_irq(&ioctx->ctx_lock);
++		/* Insert inside our poll wait queue */
++		poll_wait(file, &ioctx->poll_wait, wait);
++
++		/* Check our condition */
++		if (aio_read_evt(ioctx, 0))
++			pollflags = POLLIN | POLLRDNORM;
++		spin_unlock_irq(&ioctx->ctx_lock);
++	}
++
++	return pollflags;
++}
++
++static struct file_operations aioq_fops = {
++	.release	= aio_queue_fd_close,
++	.poll		= aio_queue_fd_poll
++};
++
++/* make_aio_fd:
++ *  Create a file descriptor that can be used to poll the event queue.
++ *  Based and piggybacked on the excellent epoll code.
++ */
++
++static int make_aio_fd(struct kioctx *ioctx)
++{
++	int error, fd;
++	struct inode *inode;
++	struct file *file;
++
++	error = ep_getfd(&fd, &inode, &file, NULL, &aioq_fops);
++	if (error)
++		return error;
++
++	/* associate the file with the IO context */
++	file->private_data = ioctx;
++	ioctx->file = file;
++	init_waitqueue_head(&ioctx->poll_wait);
++	return fd;
++}
++#endif
++
++
+ /* sys_io_setup:
+  *	Create an aio_context capable of receiving at least nr_events.
+  *	ctxp must not point to an aio_context that already exists, and
+@@ -1251,18 +1336,30 @@ static void io_destroy(struct kioctx *io
+  *	resources are available.  May fail with -EFAULT if an invalid
+  *	pointer is passed for ctxp.  Will fail with -ENOSYS if not
+  *	implemented.
++ *
++ *	To request a selectable fd, the user context has to be initialized
++ *	to 1, instead of 0, and the return value is the fd.
++ *	This keeps the system call compatible, since a non-zero value
++ *	was not allowed so far.
+  */
+ asmlinkage long sys_io_setup(unsigned nr_events, aio_context_t __user *ctxp)
+ {
+ 	struct kioctx *ioctx = NULL;
+ 	unsigned long ctx;
+ 	long ret;
++	int make_fd = 0;
+ 
+ 	ret = get_user(ctx, ctxp);
+ 	if (unlikely(ret))
+ 		goto out;
+ 
+ 	ret = -EINVAL;
++#ifdef CONFIG_EPOLL
++	if (ctx == 1) {
++		make_fd = 1;
++		ctx = 0;
++	}
++#endif
+ 	if (unlikely(ctx || nr_events == 0)) {
+ 		pr_debug("EINVAL: io_setup: ctx %lu nr_events %u\n",
+ 		         ctx, nr_events);
+@@ -1273,8 +1370,12 @@ asmlinkage long sys_io_setup(unsigned nr
+ 	ret = PTR_ERR(ioctx);
+ 	if (!IS_ERR(ioctx)) {
+ 		ret = put_user(ioctx->user_id, ctxp);
+-		if (!ret)
+-			return 0;
++#ifdef CONFIG_EPOLL
++		if (make_fd && ret >= 0)
++			ret = make_aio_fd(ioctx);
++#endif
++		if (ret >= 0)
++			return ret;
+ 
+ 		get_ioctx(ioctx); /* io_destroy() expects us to hold a ref */
+ 		io_destroy(ioctx);
+
+diff -pruN ../pristine-linux-2.6.16-rc5/fs/eventpoll.c ./fs/eventpoll.c
+--- ../pristine-linux-2.6.16-rc5/fs/eventpoll.c	2006-01-03 03:21:10.000000000 +0000
++++ ./fs/eventpoll.c	2006-03-16 10:04:35.469956167 +0000
+@@ -235,8 +235,6 @@ struct ep_pqueue {
+ 
+ static void ep_poll_safewake_init(struct poll_safewake *psw);
+ static void ep_poll_safewake(struct poll_safewake *psw, wait_queue_head_t *wq);
+-static int ep_getfd(int *efd, struct inode **einode, struct file **efile,
+-		    struct eventpoll *ep);
+ static int ep_alloc(struct eventpoll **pep);
+ static void ep_free(struct eventpoll *ep);
+ static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd);
+@@ -266,7 +264,7 @@ static int ep_events_transfer(struct eve
+ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
+ 		   int maxevents, long timeout);
+ static int eventpollfs_delete_dentry(struct dentry *dentry);
+-static struct inode *ep_eventpoll_inode(void);
++static struct inode *ep_eventpoll_inode(struct file_operations *fops);
+ static struct super_block *eventpollfs_get_sb(struct file_system_type *fs_type,
+ 					      int flags, const char *dev_name,
+ 					      void *data);
+@@ -525,7 +523,7 @@ asmlinkage long sys_epoll_create(int siz
+ 	 * Creates all the items needed to setup an eventpoll file. That is,
+ 	 * a file structure, and inode and a free file descriptor.
+ 	 */
+-	error = ep_getfd(&fd, &inode, &file, ep);
++	error = ep_getfd(&fd, &inode, &file, ep, &eventpoll_fops);
+ 	if (error)
+ 		goto eexit_2;
+ 
+@@ -710,8 +708,8 @@ eexit_1:
+ /*
+  * Creates the file descriptor to be used by the epoll interface.
+  */
+-static int ep_getfd(int *efd, struct inode **einode, struct file **efile,
+-		    struct eventpoll *ep)
++int ep_getfd(int *efd, struct inode **einode, struct file **efile,
++		    struct eventpoll *ep, struct file_operations *fops)
+ {
+ 	struct qstr this;
+ 	char name[32];
+@@ -727,7 +725,7 @@ static int ep_getfd(int *efd, struct ino
+ 		goto eexit_1;
+ 
+ 	/* Allocates an inode from the eventpoll file system */
+-	inode = ep_eventpoll_inode();
++	inode = ep_eventpoll_inode(fops);
+ 	error = PTR_ERR(inode);
+ 	if (IS_ERR(inode))
+ 		goto eexit_2;
+@@ -758,7 +756,7 @@ static int ep_getfd(int *efd, struct ino
+ 
+ 	file->f_pos = 0;
+ 	file->f_flags = O_RDONLY;
+-	file->f_op = &eventpoll_fops;
++	file->f_op = fops;
+ 	file->f_mode = FMODE_READ;
+ 	file->f_version = 0;
+ 	file->private_data = ep;
+@@ -1574,7 +1572,7 @@ static int eventpollfs_delete_dentry(str
+ }
+ 
+ 
+-static struct inode *ep_eventpoll_inode(void)
++static struct inode *ep_eventpoll_inode(struct file_operations *fops)
+ {
+ 	int error = -ENOMEM;
+ 	struct inode *inode = new_inode(eventpoll_mnt->mnt_sb);
+@@ -1582,7 +1580,7 @@ static struct inode *ep_eventpoll_inode(
+ 	if (!inode)
+ 		goto eexit_1;
+ 
+-	inode->i_fop = &eventpoll_fops;
++	inode->i_fop = fops;
+ 
+ 	/*
+ 	 * Mark the inode dirty from the very beginning,
+
+diff -pruN ../pristine-linux-2.6.16-rc5/include/linux/aio.h ./include/linux/aio.h
+--- ../pristine-linux-2.6.16-rc5/include/linux/aio.h	2006-03-14 14:10:21.597916731 +0000
++++ ./include/linux/aio.h	2006-03-16 10:05:39.848833028 +0000
+@@ -191,6 +191,11 @@ struct kioctx {
+ 	struct aio_ring_info	ring_info;
+ 
+ 	struct work_struct	wq;
++#ifdef CONFIG_EPOLL
++	// poll integration
++	wait_queue_head_t       poll_wait;
++	struct file		*file;
++#endif
+ };
+ 
+ /* prototypes */
+
+diff -pruN ../pristine-linux-2.6.16-rc5/include/linux/eventpoll.h ./include/linux/eventpoll.h
+--- ../pristine-linux-2.6.16-rc5/include/linux/eventpoll.h	2006-01-03 03:21:10.000000000 +0000
++++ ./include/linux/eventpoll.h	2006-03-16 10:08:51.577809317 +0000
+@@ -86,6 +86,12 @@ static inline void eventpoll_release(str
+ }
+ 
+ 
++/*
++ * called by aio code to create fd that can poll the  aio event queueQ
++ */
++struct eventpoll;
++int ep_getfd(int *efd, struct inode **einode, struct file **efile,
++             struct eventpoll *ep, struct file_operations *fops);
+ #else
+ 
+ static inline void eventpoll_init_file(struct file *file) {}
diff -urN xen-unstable-pristine.hg/tools/blktap/blkif.c xen-unstable-tapbuild.hg/tools/blktap/blkif.c
--- xen-unstable-pristine.hg/tools/blktap/blkif.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/blkif.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,185 @@
+/*
+ * tools/blktap_user/blkif.c
+ * 
+ * The blkif interface for blktap.  A blkif describes an in-use virtual disk.
+ * (c) 2005 Andrew Warfield and Julian Chesterfield
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <err.h>
+#include <unistd.h>
+
+#include "blktaplib.h"
+
+#if 0
+#define DPRINTF(_f, _a...) printf ( _f , ## _a )
+#else
+#define DPRINTF(_f, _a...) ((void)0)
+#endif
+
+#define BLKIF_HASHSZ 1024
+#define BLKIF_HASH(_d,_h) (((int)(_d)^(int)(_h))&(BLKIF_HASHSZ-1))
+
+static blkif_t      *blkif_hash[BLKIF_HASHSZ];
+
+blkif_t *blkif_find_by_handle(domid_t domid, unsigned int handle)
+{
+	blkif_t *blkif = blkif_hash[BLKIF_HASH(domid, handle)];
+	while ( (blkif != NULL) && 
+		((blkif->domid != domid) || (blkif->handle != handle)) )
+		blkif = blkif->hash_next;
+	return blkif;
+}
+
+blkif_t *alloc_blkif(domid_t domid)
+{
+	blkif_t *blkif;
+	DPRINTF("Alloc_blkif called [%d]\n",domid);
+	blkif = (blkif_t *)malloc(sizeof(blkif_t));
+	if (!blkif)
+		return NULL;
+	memset(blkif, 0, sizeof(*blkif));
+	blkif->domid = domid;
+	blkif->devnum = -1;
+	return blkif;
+}
+
+/*Controller callbacks*/
+static int (*new_devmap_hook)(blkif_t *blkif) = NULL;
+void register_new_devmap_hook(int (*fn)(blkif_t *blkif))
+{
+	new_devmap_hook = fn;
+}
+
+static int (*new_unmap_hook)(blkif_t *blkif) = NULL;
+void register_new_unmap_hook(int (*fn)(blkif_t *blkif))
+{
+	new_unmap_hook = fn;
+}
+
+static int (*new_blkif_hook)(blkif_t *blkif) = NULL;
+void register_new_blkif_hook(int (*fn)(blkif_t *blkif))
+{
+	new_blkif_hook = fn;
+}
+
+int blkif_init(blkif_t *blkif, long int handle, long int pdev, 
+               long int readonly)
+{
+	domid_t domid;
+	blkif_t **pblkif;
+	int devnum;
+	
+	if (blkif == NULL)
+		return -EINVAL;
+	
+	domid = blkif->domid;
+	blkif->handle   = handle;
+	blkif->pdev     = pdev;
+	blkif->readonly = readonly;
+	
+	/*
+	 * Call out to the new_blkif_hook. 
+	 * The tap application should define this,
+	 * and it should return having set blkif->ops
+	 * 
+	 */
+	if (new_blkif_hook == NULL)
+	{
+		DPRINTF("Probe detected a new blkif, but no new_blkif_hook!");
+		return -1;
+	}
+	if (new_blkif_hook(blkif)!=0) {
+		DPRINTF("BLKIF: Image open failed\n");
+		return -1;
+	}
+	
+	/* Now wire it in. */
+	pblkif = &blkif_hash[BLKIF_HASH(domid, handle)];
+	DPRINTF("Created hash entry: %d [%d,%ld]\n", 
+		BLKIF_HASH(domid, handle), domid, handle);
+	
+	while ( *pblkif != NULL )
+	{
+		if ( ((*pblkif)->domid == domid) && 
+		     ((*pblkif)->handle == handle) )
+		{
+			DPRINTF("Could not create blkif: already exists\n");
+			return -1;
+		}
+		pblkif = &(*pblkif)->hash_next;
+	}
+	blkif->hash_next = NULL;
+	*pblkif = blkif;
+	
+	if (new_devmap_hook == NULL)
+	{
+		DPRINTF("Probe setting up new blkif but no devmap hook!");
+		return -1;
+	}
+	
+	devnum = new_devmap_hook(blkif);
+	if (devnum == -1)
+		return -1;
+	blkif->devnum = devnum;
+	
+	return 0;
+}
+
+void free_blkif(blkif_t *blkif)
+{
+	blkif_t **pblkif, *curs;
+	image_t *image;
+	
+	pblkif = &blkif_hash[BLKIF_HASH(blkif->domid, blkif->handle)];
+	while ( (curs = *pblkif) != NULL )
+	{
+		if ( blkif == curs )
+		{
+			*pblkif = curs->hash_next;
+		}
+		pblkif = &curs->hash_next;
+	}
+	if (blkif != NULL) {
+		if ((image=(image_t *)blkif->prv)!=NULL) {
+			free(blkif->prv);
+		}
+		if (blkif->info!=NULL) {
+			free(blkif->info);
+		}
+		if (new_unmap_hook != NULL) new_unmap_hook(blkif);
+		free(blkif);
+	}
+}
+
+void __init_blkif(void)
+{    
+	memset(blkif_hash, 0, sizeof(blkif_hash));
+}
diff -urN xen-unstable-pristine.hg/tools/blktap/blktaplib.h xen-unstable-tapbuild.hg/tools/blktap/blktaplib.h
--- xen-unstable-pristine.hg/tools/blktap/blktaplib.h	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/blktaplib.h	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,223 @@
+/* blktaplib.h
+ *
+ * Blktap library userspace code.
+ *
+ * (c) 2005 Andrew Warfield and Julian Chesterfield
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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 __BLKTAPLIB_H__
+#define __BLKTAPLIB_H__
+
+#include <xenctrl.h>
+#include <sys/user.h>
+#include <xen/xen.h>
+#include <xen/io/blkif.h>
+#include <xen/io/ring.h>
+#include <xs.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
+
+/* size of the extra VMA area to map in attached pages. */
+#define BLKTAP_VMA_PAGES BLK_RING_SIZE
+
+/* blktap IOCTLs: These must correspond with the blktap driver ioctls*/
+#define BLKTAP_IOCTL_KICK_FE         1
+#define BLKTAP_IOCTL_KICK_BE         2
+#define BLKTAP_IOCTL_SETMODE         3
+#define BLKTAP_IOCTL_SENDPID	     4
+#define BLKTAP_IOCTL_NEWINTF	     5
+#define BLKTAP_IOCTL_MINOR	     6
+#define BLKTAP_IOCTL_MAJOR	     7
+#define BLKTAP_QUERY_ALLOC_REQS      8
+#define BLKTAP_IOCTL_FREEINTF	     9
+#define BLKTAP_IOCTL_PRINT_IDXS      100   
+
+/* blktap switching modes: (Set with BLKTAP_IOCTL_SETMODE)             */
+#define BLKTAP_MODE_PASSTHROUGH      0x00000000  /* default            */
+#define BLKTAP_MODE_INTERCEPT_FE     0x00000001
+#define BLKTAP_MODE_INTERCEPT_BE     0x00000002
+
+#define BLKTAP_MODE_INTERPOSE \
+           (BLKTAP_MODE_INTERCEPT_FE | BLKTAP_MODE_INTERCEPT_BE)
+
+static inline int BLKTAP_MODE_VALID(unsigned long arg)
+{
+	return (
+		( arg == BLKTAP_MODE_PASSTHROUGH  ) ||
+		( arg == BLKTAP_MODE_INTERCEPT_FE ) ||
+		( arg == BLKTAP_MODE_INTERPOSE    ) );
+}
+
+#define MAX_REQUESTS            64
+
+#define BLKTAP_IOCTL_KICK 1
+#define MAX_PENDING_REQS 64
+#define BLKTAP_DEV_DIR   "/dev/xen"
+#define BLKTAP_DEV_NAME  "blktap"
+#define BLKTAP_DEV_MAJOR 254
+#define BLKTAP_DEV_MINOR 0
+
+#define BLKTAP_RING_PAGES       1 /* Front */
+#define BLKTAP_MMAP_REGION_SIZE (BLKTAP_RING_PAGES + MMAP_PAGES)
+
+struct blkif;
+
+typedef struct {
+	blkif_request_t  req;
+	struct blkif         *blkif;
+	int              count;
+        int16_t          status;
+} pending_req_t;
+
+struct blkif_ops {
+	long int (*get_size)(struct blkif *blkif);
+	long int (*get_secsize)(struct blkif *blkif);
+	unsigned (*get_info)(struct blkif *blkif);
+};
+
+typedef struct blkif {
+	domid_t domid;
+	long int handle;
+	
+	long int pdev;
+	long int readonly;
+	
+	enum { DISCONNECTED, DISCONNECTING, CONNECTED } state;
+	
+	struct blkif_ops *ops;
+	struct blkif *hash_next;
+	
+	void *prv;  /* device-specific data */
+	void *info; /*Image parameter passing */
+	pending_req_t    pending_list[MAX_REQUESTS];
+	int devnum;
+	int fds[2];
+	int be_id;
+	int major;
+	int minor;
+	pid_t tappid;
+	int drivertype;
+	uint16_t cookie;
+} blkif_t;
+
+typedef struct blkif_info {
+	char *params;
+} blkif_info_t;
+
+void register_new_devmap_hook(int (*fn)(blkif_t *blkif));
+void register_new_unmap_hook(int (*fn)(blkif_t *blkif));
+void register_new_blkif_hook(int (*fn)(blkif_t *blkif));
+blkif_t *blkif_find_by_handle(domid_t domid, unsigned int handle);
+blkif_t *alloc_blkif(domid_t domid);
+int blkif_init(blkif_t *blkif, long int handle, long int pdev, 
+               long int readonly);
+void free_blkif(blkif_t *blkif);
+void __init_blkif(void);
+
+typedef struct tapdev_info {
+	int fd;
+	char *mem;
+	blkif_sring_t *sring;
+	blkif_back_ring_t  fe_ring;
+	unsigned long vstart;
+	blkif_t *blkif;
+} tapdev_info_t;
+
+typedef struct domid_translate {
+	unsigned short domid;
+	unsigned short busid;
+} domid_translate_t ;
+
+typedef struct image {
+	long int size;
+	long int secsize;
+	long int info;
+} image_t;
+
+typedef struct msg_hdr {
+	uint16_t    type;
+	uint16_t   len;
+	uint16_t   drivertype;
+	uint16_t   cookie;
+} msg_hdr_t;
+
+typedef struct msg_newdev {
+	uint8_t     devnum;
+	uint16_t    domid;
+} msg_newdev_t;
+
+typedef struct msg_pid {
+	pid_t     pid;
+} msg_pid_t;
+
+#define READ 0
+#define WRITE 1
+
+/*Control Messages between manager and tapdev*/
+#define CTLMSG_PARAMS      1
+#define CTLMSG_IMG         2
+#define CTLMSG_IMG_FAIL    3
+#define CTLMSG_NEWDEV      4
+#define CTLMSG_NEWDEV_RSP  5
+#define CTLMSG_NEWDEV_FAIL 6
+#define CTLMSG_CLOSE       7
+#define CTLMSG_CLOSE_RSP   8
+#define CTLMSG_PID         9
+#define CTLMSG_PID_RSP     10
+
+/* xenstore/xenbus: */
+extern int add_blockdevice_probe_watch(struct xs_handle *h, 
+                                       const char *domname);
+int xs_fire_next_watch(struct xs_handle *h);
+
+
+/* Abitrary values, must match the underlying driver... */
+#define MAX_PENDING_REQS 64
+#define MAX_TAP_DEV 100
+
+/* Accessing attached data page mappings */
+#define MMAP_PAGES                                              \
+    (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
+#define MMAP_VADDR(_vstart,_req,_seg)                                   \
+    ((_vstart) +                                              \
+     ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +    \
+     ((_seg) * PAGE_SIZE))
+
+/* Defines that are only used by library clients */
+
+#ifndef __COMPILING_BLKTAP_LIB
+
+static char *blkif_op_name[] = {
+	[BLKIF_OP_READ]       = "READ",
+	[BLKIF_OP_WRITE]      = "WRITE",
+};
+
+#endif /* __COMPILING_BLKTAP_LIB */
+
+#endif /* __BLKTAPLIB_H__ */
diff -urN xen-unstable-pristine.hg/tools/blktap/list.h xen-unstable-tapbuild.hg/tools/blktap/list.h
--- xen-unstable-pristine.hg/tools/blktap/list.h	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/list.h	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,55 @@
+/*
+ * list.h
+ * 
+ * This is a subset of linux's list.h intended to be used in user-space.
+ * 
+ */
+
+#ifndef __LIST_H__
+#define __LIST_H__
+
+#define LIST_POISON1  ((void *) 0x00100100)
+#define LIST_POISON2  ((void *) 0x00200200)
+
+struct list_head {
+        struct list_head *next, *prev;
+};
+ 
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+ 
+#define LIST_HEAD(name) \
+        struct list_head name = LIST_HEAD_INIT(name)
+
+static inline void __list_add(struct list_head *new,
+                              struct list_head *prev,
+                              struct list_head *next)
+{
+        next->prev = new;
+        new->next = next;
+        new->prev = prev;
+        prev->next = new;
+}
+
+static inline void list_add(struct list_head *new, struct list_head *head)
+{
+        __list_add(new, head, head->next);
+}
+static inline void __list_del(struct list_head * prev, struct list_head * next)
+{
+        next->prev = prev;
+        prev->next = next;
+}
+static inline void list_del(struct list_head *entry)
+{
+        __list_del(entry->prev, entry->next);
+        entry->next = LIST_POISON1;
+        entry->prev = LIST_POISON2;
+}
+#define list_entry(ptr, type, member)                                   \
+        ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+#define list_for_each_entry(pos, head, member)                          \
+        for (pos = list_entry((head)->next, typeof(*pos), member);      \
+             &pos->member != (head);                                    \
+             pos = list_entry(pos->member.next, typeof(*pos), member))
+
+#endif /* __LIST_H__ */
diff -urN xen-unstable-pristine.hg/tools/blktap/Makefile xen-unstable-tapbuild.hg/tools/blktap/Makefile
--- xen-unstable-pristine.hg/tools/blktap/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/Makefile	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,77 @@
+XEN_ROOT = ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+MAJOR    = 3.0
+MINOR    = 0
+SONAME   = libblktap.so.$(MAJOR)
+
+XEN_ROOT = ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+SUBDIRS :=
+SUBDIRS += tools
+
+BLKTAP_INSTALL_DIR = /usr/sbin
+
+INSTALL            = install
+INSTALL_PROG       = $(INSTALL) -m0755
+INSTALL_DIR        = $(INSTALL) -d -m0755
+
+INCLUDES += -I. -I $(XEN_LIBXC) -I $(XEN_XENSTORE)
+
+LIBS     := -lz
+
+SRCS     :=
+SRCS     += xenbus.c blkif.c xs_api.c
+
+CFLAGS   += -Werror
+CFLAGS   += -Wno-unused
+CFLAGS   += -fno-strict-aliasing -fPIC
+CFLAGS   += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
+# get asprintf():
+CFLAGS   += -D _GNU_SOURCE
+
+# Get gcc to generate the dependencies for us.
+CFLAGS   += -Wp,-MD,.$(@F).d
+CFLAGS   += $(INCLUDES) 
+DEPS     = .*.d
+
+OBJS     = $(patsubst %.c,%.o,$(SRCS))
+IBINS   :=
+
+LIB      = libblktap.so libblktap.so.$(MAJOR) libblktap.so.$(MAJOR).$(MINOR)
+
+all: mk-symlinks libblktap.so
+	@set -e; for subdir in $(SUBDIRS); do \
+		$(MAKE) -C $$subdir $@;       \
+	done
+
+install: all
+	$(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
+	$(INSTALL_DIR) -p $(DESTDIR)/usr/include
+	$(INSTALL_PROG) $(LIB) $(DESTDIR)/usr/$(LIBDIR)
+	$(INSTALL_PROG) blktaplib.h $(DESTDIR)/usr/include
+	@set -e; for subdir in $(SUBDIRS); do \
+		$(MAKE) -C $$subdir $@;       \
+	done
+
+clean:
+	rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen TAGS
+	@set -e; for subdir in $(SUBDIRS); do \
+		$(MAKE) -C $$subdir $@;       \
+	done
+
+libblktap.so: $(OBJS) 
+	$(CC) $(CFLAGS) -Wl,-soname -Wl,$(SONAME) -shared         \
+	      -L$(XEN_XENSTORE) -l xenstore                       \
+	      -o libblktap.so.$(MAJOR).$(MINOR) $^ $(LIBS)
+	ln -sf libblktap.so.$(MAJOR).$(MINOR) libblktap.so.$(MAJOR)
+	ln -sf libblktap.so.$(MAJOR) $@
+
+.PHONY: TAGS clean install mk-symlinks rpm
+
+TAGS:
+	etags -t $(SRCS) *.h
+
+-include $(DEPS)
+
diff -urN xen-unstable-pristine.hg/tools/blktap/README xen-unstable-tapbuild.hg/tools/blktap/README
--- xen-unstable-pristine.hg/tools/blktap/README	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/README	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,126 @@
+Blktap Userspace Tools + Library
+================================
+
+Andrew Warfield and Julian Chesterfield
+16th June 2006
+
+{firstname.lastname}@cl.cam.ac.uk
+
+The blktap userspace toolkit provides a user-level disk I/O
+interface. The blktap mechanism involves a kernel driver that acts
+similarly to the existing Xen/Linux blkback driver, and a set of
+associated user-level libraries.  Using these tools, blktap allows
+virtual block devices presented to VMs to be implemented in userspace
+and to be backed by raw partitions, files, network, etc.
+
+The key benefit of blktap is that it makes it easy and fast to write
+arbitrary block backends, and that these user-level backends actually
+perform very well.  Specifically:
+
+- Metadata disk formats such as Copy-on-Write, encrypted disks, sparse
+  formats and other compression features can be easily implemented.
+
+- Accessing file-based images from userspace avoids problems related
+  to flushing dirty pages which are present in the Linux loopback
+  driver.  (Specifically, doing a large number of writes to an
+  NFS-backed image don't result in the OOM killer going berserk.)
+
+- Per-disk handler processes enable easier userspace policing of block
+  resources, and process-granularity QoS techniques (disk scheduling
+  and related tools) may be trivially applied to block devices.
+
+- It's very easy to take advantage of userspace facilities such as
+  networking libraries, compression utilities, peer-to-peer
+  file-sharing systems and so on to build more complex block backends.
+
+- Crashes are contained -- incremental development/debugging is very
+  fast.
+
+How it works (in one paragraph):
+
+Working in conjunction with the kernel blktap driver, all disk I/O
+requests from VMs are passed to the userspace deamon (using a shared
+memory interface) through a character device. Each active disk is
+mapped to an individual device node, allowing per-disk processes to
+implement individual block devices where desired.  The userspace
+drivers are implemented using asynchronous (Linux libaio),
+O_DIRECT-based calls to preserve the unbuffered, batched and
+asynchronous request dispatch achieved with the existing blkback
+code.  We provide a simple, asynchronous virtual disk interface that
+makes it quite easy to add new disk implementations.
+
+As of June 2006 the current supported disk formats are:
+
+ - Raw Images (both on partitions and in image files)
+ - File-backed Qcow disks
+ - Standalone sparse Qcow disks
+ - Fast shareable RAM disk between VMs (requires some form of cluster-based 
+   filesystem support e.g. OCFS2 in the guest kernel)
+ - Some VMDK images - your mileage may vary
+
+Raw and QCow images have asynchronous backends and so should perform
+fairly well.  VMDK is based directly on the qemu vmdk driver, which is
+synchronous (a.k.a. slow).
+
+Build and Installation Instructions
+===================================
+
+You will need libaio >= 0.3.104 on your target system to build the
+tools (if you are installing RPMs, this means libaio and
+libaio-devel).
+
+Make to configure the blktap backend driver in your dom0 kernel.  It
+will cooperate fine with the existing backend driver, so you can
+experiment with tap disks without breaking existing VM configs.
+
+To build the tools separately, "make && make install" in 
+tools/blktap_user.
+
+
+Using the Tools
+===============
+
+Prepare the image for booting. For qcow files use the qcow utilities
+installed earlier. e.g. qcow-create generates a blank standalone image
+or a file-backed CoW image. img2qcow takes an existing image or
+partition and creates a sparse, standalone qcow-based file.
+
+Start the userspace disk agent either on system boot (e.g. via an init
+script) or manually => 'blktapctrl'
+
+Customise the VM config file to use the 'tap' handler, followed by the
+driver type. e.g. for a raw image such as a file or partition:
+
+disk = ['tap:aio:<FILENAME>,sda1,w']
+
+e.g. for a qcow image:
+
+disk = ['tap:qcow:<FILENAME>,sda1,w']
+
+
+Mounting images in Dom0 using the blktap driver
+===============================================
+Tap (and blkback) disks are also mountable in Dom0 without requiring an
+active VM to attach. You will need to build a xenlinux Dom0 kernel that
+includes the blkfront driver (e.g. the default 'make world' or 
+'make kernels' build. Simply use the xm command-line tool to activate
+the backend disks, and blkfront will generate a virtual block device that
+can be accessed in the same way as a loop device or partition:
+
+e.g. for a raw image file <FILENAME> that would normally be mounted using
+the loopback driver (such as 'mount -o loop <FILENAME> /mnt/disk'), do the
+following:
+
+xm block-attach 0 tap:aio:<FILENAME> /dev/xvda1 w 0
+mount /dev/xvda1 /mnt/disk        <--- don't use loop driver
+
+In this way, you can use any of the userspace device-type drivers built
+with the blktap userspace toolkit to open and mount disks such as qcow
+or vmdk images:
+
+xm block-attach 0 tap:qcow:<FILENAME> /dev/xvda1 w 0
+mount /dev/xvda1 /mnt/disk
+
+
+
+ 
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/aes.c xen-unstable-tapbuild.hg/tools/blktap/tools/aes.c
--- xen-unstable-pristine.hg/tools/blktap/tools/aes.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/aes.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,1319 @@
+/**
+ * 
+ * aes.c - integrated in QEMU by Fabrice Bellard from the OpenSSL project.
+ */
+/*
+ * rijndael-alg-fst.c
+ *
+ * @version 3.0 (December 2000)
+ *
+ * Optimised ANSI C code for the Rijndael cipher (now AES)
+ *
+ * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
+ * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
+ * @author Paulo Barreto <paulo.barreto@terra.com.br>
+ *
+ * This code is hereby placed in the public domain.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE.
+ */
+//#include "vl.h"
+#include <inttypes.h>
+#include <string.h>
+#include "aes.h"
+
+//#define NDEBUG
+#include <assert.h>
+
+typedef uint32_t u32;
+typedef uint16_t u16;
+typedef uint8_t u8;
+
+#define MAXKC   (256/32)
+#define MAXKB   (256/8)
+#define MAXNR   14
+
+/* This controls loop-unrolling in aes_core.c */
+#undef FULL_UNROLL
+# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] <<  8) ^ ((u32)(pt)[3]))
+# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >>  8); (ct)[3] = (u8)(st); }
+
+/*
+Te0[x] = S [x].[02, 01, 01, 03];
+Te1[x] = S [x].[03, 02, 01, 01];
+Te2[x] = S [x].[01, 03, 02, 01];
+Te3[x] = S [x].[01, 01, 03, 02];
+Te4[x] = S [x].[01, 01, 01, 01];
+
+Td0[x] = Si[x].[0e, 09, 0d, 0b];
+Td1[x] = Si[x].[0b, 0e, 09, 0d];
+Td2[x] = Si[x].[0d, 0b, 0e, 09];
+Td3[x] = Si[x].[09, 0d, 0b, 0e];
+Td4[x] = Si[x].[01, 01, 01, 01];
+*/
+
+static const u32 Te0[256] = {
+    0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
+    0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
+    0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,
+    0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,
+    0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,
+    0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,
+    0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,
+    0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,
+    0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,
+    0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,
+    0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,
+    0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,
+    0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,
+    0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,
+    0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,
+    0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,
+    0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,
+    0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,
+    0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,
+    0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,
+    0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,
+    0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,
+    0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,
+    0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,
+    0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,
+    0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,
+    0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,
+    0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,
+    0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,
+    0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,
+    0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,
+    0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,
+    0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,
+    0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,
+    0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,
+    0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,
+    0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,
+    0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,
+    0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,
+    0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,
+    0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,
+    0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,
+    0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,
+    0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,
+    0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,
+    0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,
+    0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,
+    0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,
+    0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,
+    0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,
+    0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,
+    0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,
+    0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,
+    0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,
+    0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,
+    0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,
+    0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,
+    0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,
+    0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,
+    0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,
+    0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,
+    0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,
+    0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,
+    0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,
+};
+static const u32 Te1[256] = {
+    0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,
+    0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,
+    0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,
+    0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,
+    0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,
+    0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,
+    0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,
+    0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,
+    0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,
+    0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,
+    0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,
+    0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,
+    0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,
+    0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,
+    0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,
+    0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,
+    0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,
+    0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,
+    0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,
+    0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,
+    0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,
+    0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,
+    0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,
+    0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,
+    0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,
+    0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,
+    0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,
+    0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,
+    0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,
+    0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,
+    0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,
+    0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,
+    0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,
+    0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,
+    0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,
+    0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,
+    0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,
+    0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,
+    0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,
+    0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,
+    0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,
+    0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,
+    0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,
+    0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,
+    0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,
+    0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,
+    0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,
+    0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,
+    0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,
+    0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,
+    0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,
+    0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,
+    0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,
+    0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,
+    0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,
+    0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,
+    0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,
+    0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,
+    0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,
+    0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,
+    0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,
+    0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,
+    0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,
+    0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,
+};
+static const u32 Te2[256] = {
+    0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,
+    0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,
+    0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,
+    0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,
+    0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,
+    0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,
+    0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,
+    0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,
+    0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,
+    0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,
+    0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,
+    0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,
+    0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,
+    0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,
+    0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,
+    0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,
+    0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,
+    0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,
+    0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,
+    0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,
+    0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,
+    0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,
+    0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,
+    0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,
+    0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,
+    0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,
+    0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,
+    0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,
+    0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,
+    0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,
+    0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,
+    0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,
+    0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,
+    0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,
+    0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,
+    0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,
+    0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,
+    0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,
+    0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,
+    0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,
+    0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,
+    0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,
+    0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,
+    0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,
+    0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,
+    0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,
+    0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,
+    0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,
+    0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,
+    0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,
+    0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,
+    0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,
+    0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,
+    0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,
+    0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,
+    0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,
+    0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,
+    0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,
+    0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,
+    0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,
+    0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,
+    0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,
+    0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,
+    0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,
+};
+static const u32 Te3[256] = {
+
+    0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,
+    0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,
+    0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,
+    0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,
+    0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,
+    0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,
+    0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,
+    0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,
+    0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,
+    0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,
+    0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,
+    0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,
+    0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,
+    0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,
+    0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,
+    0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,
+    0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,
+    0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,
+    0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,
+    0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,
+    0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,
+    0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,
+    0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,
+    0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,
+    0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,
+    0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,
+    0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,
+    0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,
+    0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,
+    0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,
+    0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,
+    0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,
+    0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,
+    0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,
+    0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,
+    0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,
+    0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,
+    0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,
+    0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,
+    0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,
+    0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,
+    0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,
+    0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,
+    0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,
+    0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,
+    0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,
+    0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,
+    0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,
+    0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,
+    0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,
+    0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,
+    0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,
+    0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,
+    0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,
+    0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,
+    0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,
+    0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,
+    0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,
+    0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,
+    0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,
+    0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,
+    0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,
+    0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,
+    0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,
+};
+static const u32 Te4[256] = {
+    0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,
+    0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,
+    0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,
+    0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,
+    0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,
+    0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,
+    0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,
+    0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,
+    0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,
+    0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,
+    0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,
+    0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,
+    0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,
+    0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,
+    0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,
+    0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,
+    0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,
+    0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,
+    0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,
+    0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,
+    0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,
+    0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,
+    0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,
+    0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,
+    0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,
+    0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,
+    0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,
+    0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,
+    0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,
+    0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,
+    0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,
+    0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,
+    0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,
+    0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,
+    0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,
+    0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,
+    0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,
+    0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,
+    0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,
+    0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,
+    0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,
+    0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,
+    0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,
+    0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,
+    0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,
+    0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,
+    0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,
+    0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,
+    0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,
+    0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,
+    0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,
+    0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,
+    0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,
+    0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,
+    0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,
+    0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,
+    0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,
+    0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,
+    0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,
+    0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,
+    0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,
+    0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,
+    0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,
+    0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
+};
+static const u32 Td0[256] = {
+    0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
+    0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
+    0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,
+    0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,
+    0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,
+    0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,
+    0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,
+    0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,
+    0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,
+    0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,
+    0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,
+    0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,
+    0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,
+    0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,
+    0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,
+    0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,
+    0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,
+    0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,
+    0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,
+    0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,
+    0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,
+    0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,
+    0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,
+    0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,
+    0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,
+    0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,
+    0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,
+    0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,
+    0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,
+    0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,
+    0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,
+    0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,
+    0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,
+    0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,
+    0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,
+    0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,
+    0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,
+    0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,
+    0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,
+    0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,
+    0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,
+    0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,
+    0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,
+    0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,
+    0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,
+    0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,
+    0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,
+    0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,
+    0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,
+    0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,
+    0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,
+    0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,
+    0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,
+    0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,
+    0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,
+    0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,
+    0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,
+    0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,
+    0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,
+    0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,
+    0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,
+    0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,
+    0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,
+    0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,
+};
+static const u32 Td1[256] = {
+    0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,
+    0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,
+    0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,
+    0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,
+    0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,
+    0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,
+    0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,
+    0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,
+    0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,
+    0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,
+    0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,
+    0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,
+    0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,
+    0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,
+    0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,
+    0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,
+    0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,
+    0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,
+    0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,
+    0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,
+    0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,
+    0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,
+    0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,
+    0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,
+    0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,
+    0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,
+    0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,
+    0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,
+    0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,
+    0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,
+    0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,
+    0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,
+    0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,
+    0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,
+    0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,
+    0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,
+    0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,
+    0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,
+    0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,
+    0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,
+    0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,
+    0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,
+    0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,
+    0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,
+    0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,
+    0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,
+    0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,
+    0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,
+    0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,
+    0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,
+    0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,
+    0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,
+    0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,
+    0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,
+    0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,
+    0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,
+    0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,
+    0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,
+    0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,
+    0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,
+    0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,
+    0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,
+    0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,
+    0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,
+};
+static const u32 Td2[256] = {
+    0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,
+    0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,
+    0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,
+    0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,
+    0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,
+    0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,
+    0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,
+    0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,
+    0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,
+    0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,
+    0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,
+    0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,
+    0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,
+    0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,
+    0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,
+    0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,
+    0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,
+    0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,
+    0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,
+    0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,
+
+    0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,
+    0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,
+    0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,
+    0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,
+    0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,
+    0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,
+    0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,
+    0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,
+    0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,
+    0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,
+    0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,
+    0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,
+    0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,
+    0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,
+    0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,
+    0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,
+    0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,
+    0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,
+    0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,
+    0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,
+    0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,
+    0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,
+    0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,
+    0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,
+    0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,
+    0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,
+    0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,
+    0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,
+    0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,
+    0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,
+    0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,
+    0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,
+    0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,
+    0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,
+    0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,
+    0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,
+    0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,
+    0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,
+    0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,
+    0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,
+    0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,
+    0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,
+    0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,
+    0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,
+};
+static const u32 Td3[256] = {
+    0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,
+    0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,
+    0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,
+    0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,
+    0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,
+    0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,
+    0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,
+    0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,
+    0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,
+    0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,
+    0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,
+    0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,
+    0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,
+    0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,
+    0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,
+    0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,
+    0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,
+    0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,
+    0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,
+    0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,
+    0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,
+    0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,
+    0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,
+    0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,
+    0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,
+    0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,
+    0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,
+    0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,
+    0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,
+    0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,
+    0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,
+    0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,
+    0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,
+    0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,
+    0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,
+    0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,
+    0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,
+    0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,
+    0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,
+    0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,
+    0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,
+    0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,
+    0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,
+    0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,
+    0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,
+    0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,
+    0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,
+    0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,
+    0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,
+    0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,
+    0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,
+    0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,
+    0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,
+    0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,
+    0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,
+    0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,
+    0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,
+    0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,
+    0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,
+    0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,
+    0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,
+    0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,
+    0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,
+    0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
+};
+static const u32 Td4[256] = {
+    0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,
+    0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,
+    0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,
+    0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,
+    0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,
+    0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,
+    0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,
+    0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,
+    0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,
+    0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,
+    0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,
+    0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,
+    0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,
+    0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,
+    0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,
+    0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,
+    0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,
+    0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,
+    0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,
+    0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,
+    0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,
+    0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,
+    0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,
+    0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,
+    0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,
+    0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,
+    0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,
+    0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,
+    0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,
+    0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,
+    0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,
+    0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,
+    0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,
+    0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,
+    0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,
+    0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,
+    0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,
+    0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,
+    0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,
+    0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,
+    0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,
+    0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,
+    0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,
+    0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,
+    0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,
+    0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,
+    0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,
+    0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,
+    0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,
+    0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,
+    0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,
+    0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,
+    0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,
+    0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,
+    0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,
+    0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,
+    0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,
+    0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,
+    0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,
+    0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,
+    0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,
+    0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,
+    0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,
+    0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,
+};
+static const u32 rcon[] = {
+	0x01000000, 0x02000000, 0x04000000, 0x08000000,
+	0x10000000, 0x20000000, 0x40000000, 0x80000000,
+	0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
+};
+
+/**
+ * Expand the cipher key into the encryption key schedule.
+ */
+int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
+			AES_KEY *key) {
+
+	u32 *rk;
+   	int i = 0;
+	u32 temp;
+
+	if (!userKey || !key)
+		return -1;
+	if (bits != 128 && bits != 192 && bits != 256)
+		return -2;
+
+	rk = key->rd_key;
+
+	if (bits==128)
+		key->rounds = 10;
+	else if (bits==192)
+		key->rounds = 12;
+	else
+		key->rounds = 14;
+
+	rk[0] = GETU32(userKey     );
+	rk[1] = GETU32(userKey +  4);
+	rk[2] = GETU32(userKey +  8);
+	rk[3] = GETU32(userKey + 12);
+	if (bits == 128) {
+		while (1) {
+			temp  = rk[3];
+			rk[4] = rk[0] ^
+				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
+				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
+				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
+				(Te4[(temp >> 24)       ] & 0x000000ff) ^
+				rcon[i];
+			rk[5] = rk[1] ^ rk[4];
+			rk[6] = rk[2] ^ rk[5];
+			rk[7] = rk[3] ^ rk[6];
+			if (++i == 10) {
+				return 0;
+			}
+			rk += 4;
+		}
+	}
+	rk[4] = GETU32(userKey + 16);
+	rk[5] = GETU32(userKey + 20);
+	if (bits == 192) {
+		while (1) {
+			temp = rk[ 5];
+			rk[ 6] = rk[ 0] ^
+				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
+				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
+				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
+				(Te4[(temp >> 24)       ] & 0x000000ff) ^
+				rcon[i];
+			rk[ 7] = rk[ 1] ^ rk[ 6];
+			rk[ 8] = rk[ 2] ^ rk[ 7];
+			rk[ 9] = rk[ 3] ^ rk[ 8];
+			if (++i == 8) {
+				return 0;
+			}
+			rk[10] = rk[ 4] ^ rk[ 9];
+			rk[11] = rk[ 5] ^ rk[10];
+			rk += 6;
+		}
+	}
+	rk[6] = GETU32(userKey + 24);
+	rk[7] = GETU32(userKey + 28);
+	if (bits == 256) {
+		while (1) {
+			temp = rk[ 7];
+			rk[ 8] = rk[ 0] ^
+				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
+				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
+				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
+				(Te4[(temp >> 24)       ] & 0x000000ff) ^
+				rcon[i];
+			rk[ 9] = rk[ 1] ^ rk[ 8];
+			rk[10] = rk[ 2] ^ rk[ 9];
+			rk[11] = rk[ 3] ^ rk[10];
+			if (++i == 7) {
+				return 0;
+			}
+			temp = rk[11];
+			rk[12] = rk[ 4] ^
+				(Te4[(temp >> 24)       ] & 0xff000000) ^
+				(Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^
+				(Te4[(temp >>  8) & 0xff] & 0x0000ff00) ^
+				(Te4[(temp      ) & 0xff] & 0x000000ff);
+			rk[13] = rk[ 5] ^ rk[12];
+			rk[14] = rk[ 6] ^ rk[13];
+			rk[15] = rk[ 7] ^ rk[14];
+
+			rk += 8;
+        	}
+	}
+	return 0;
+}
+
+/**
+ * Expand the cipher key into the decryption key schedule.
+ */
+int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
+			 AES_KEY *key) {
+
+        u32 *rk;
+	int i, j, status;
+	u32 temp;
+
+	/* first, start with an encryption schedule */
+	status = AES_set_encrypt_key(userKey, bits, key);
+	if (status < 0)
+		return status;
+
+	rk = key->rd_key;
+
+	/* invert the order of the round keys: */
+	for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {
+		temp = rk[i    ]; rk[i    ] = rk[j    ]; rk[j    ] = temp;
+		temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
+		temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
+		temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;
+	}
+	/* apply the inverse MixColumn transform to all round keys but the first and the last: */
+	for (i = 1; i < (key->rounds); i++) {
+		rk += 4;
+		rk[0] =
+			Td0[Te4[(rk[0] >> 24)       ] & 0xff] ^
+			Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^
+			Td2[Te4[(rk[0] >>  8) & 0xff] & 0xff] ^
+			Td3[Te4[(rk[0]      ) & 0xff] & 0xff];
+		rk[1] =
+			Td0[Te4[(rk[1] >> 24)       ] & 0xff] ^
+			Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^
+			Td2[Te4[(rk[1] >>  8) & 0xff] & 0xff] ^
+			Td3[Te4[(rk[1]      ) & 0xff] & 0xff];
+		rk[2] =
+			Td0[Te4[(rk[2] >> 24)       ] & 0xff] ^
+			Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^
+			Td2[Te4[(rk[2] >>  8) & 0xff] & 0xff] ^
+			Td3[Te4[(rk[2]      ) & 0xff] & 0xff];
+		rk[3] =
+			Td0[Te4[(rk[3] >> 24)       ] & 0xff] ^
+			Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^
+			Td2[Te4[(rk[3] >>  8) & 0xff] & 0xff] ^
+			Td3[Te4[(rk[3]      ) & 0xff] & 0xff];
+	}
+	return 0;
+}
+
+#ifndef AES_ASM
+/*
+ * Encrypt a single block
+ * in and out can overlap
+ */
+void AES_encrypt(const unsigned char *in, unsigned char *out,
+		 const AES_KEY *key) {
+
+	const u32 *rk;
+	u32 s0, s1, s2, s3, t0, t1, t2, t3;
+#ifndef FULL_UNROLL
+	int r;
+#endif /* ?FULL_UNROLL */
+
+	assert(in && out && key);
+	rk = key->rd_key;
+
+	/*
+	 * map byte array block to cipher state
+	 * and add initial round key:
+	 */
+	s0 = GETU32(in     ) ^ rk[0];
+	s1 = GETU32(in +  4) ^ rk[1];
+	s2 = GETU32(in +  8) ^ rk[2];
+	s3 = GETU32(in + 12) ^ rk[3];
+#ifdef FULL_UNROLL
+	/* round 1: */
+   	t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4];
+   	t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5];
+   	t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6];
+   	t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7];
+   	/* round 2: */
+   	s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8];
+   	s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9];
+   	s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10];
+   	s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11];
+	/* round 3: */
+   	t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12];
+   	t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13];
+   	t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14];
+   	t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15];
+   	/* round 4: */
+   	s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16];
+   	s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17];
+   	s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18];
+   	s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19];
+	/* round 5: */
+   	t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20];
+   	t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21];
+   	t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22];
+   	t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23];
+   	/* round 6: */
+   	s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24];
+   	s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25];
+   	s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26];
+   	s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27];
+	/* round 7: */
+   	t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28];
+   	t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29];
+   	t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30];
+   	t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31];
+   	/* round 8: */
+   	s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32];
+   	s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33];
+   	s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34];
+   	s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35];
+	/* round 9: */
+   	t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36];
+   	t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37];
+   	t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38];
+   	t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39];
+    if (key->rounds > 10) {
+        /* round 10: */
+        s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40];
+        s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41];
+        s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42];
+        s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43];
+        /* round 11: */
+        t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44];
+        t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45];
+        t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46];
+        t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47];
+        if (key->rounds > 12) {
+            /* round 12: */
+            s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48];
+            s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49];
+            s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50];
+            s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51];
+            /* round 13: */
+            t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52];
+            t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53];
+            t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54];
+            t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55];
+        }
+    }
+    rk += key->rounds << 2;
+#else  /* !FULL_UNROLL */
+    /*
+     * Nr - 1 full rounds:
+     */
+    r = key->rounds >> 1;
+    for (;;) {
+        t0 =
+            Te0[(s0 >> 24)       ] ^
+            Te1[(s1 >> 16) & 0xff] ^
+            Te2[(s2 >>  8) & 0xff] ^
+            Te3[(s3      ) & 0xff] ^
+            rk[4];
+        t1 =
+            Te0[(s1 >> 24)       ] ^
+            Te1[(s2 >> 16) & 0xff] ^
+            Te2[(s3 >>  8) & 0xff] ^
+            Te3[(s0      ) & 0xff] ^
+            rk[5];
+        t2 =
+            Te0[(s2 >> 24)       ] ^
+            Te1[(s3 >> 16) & 0xff] ^
+            Te2[(s0 >>  8) & 0xff] ^
+            Te3[(s1      ) & 0xff] ^
+            rk[6];
+        t3 =
+            Te0[(s3 >> 24)       ] ^
+            Te1[(s0 >> 16) & 0xff] ^
+            Te2[(s1 >>  8) & 0xff] ^
+            Te3[(s2      ) & 0xff] ^
+            rk[7];
+
+        rk += 8;
+        if (--r == 0) {
+            break;
+        }
+
+        s0 =
+            Te0[(t0 >> 24)       ] ^
+            Te1[(t1 >> 16) & 0xff] ^
+            Te2[(t2 >>  8) & 0xff] ^
+            Te3[(t3      ) & 0xff] ^
+            rk[0];
+        s1 =
+            Te0[(t1 >> 24)       ] ^
+            Te1[(t2 >> 16) & 0xff] ^
+            Te2[(t3 >>  8) & 0xff] ^
+            Te3[(t0      ) & 0xff] ^
+            rk[1];
+        s2 =
+            Te0[(t2 >> 24)       ] ^
+            Te1[(t3 >> 16) & 0xff] ^
+            Te2[(t0 >>  8) & 0xff] ^
+            Te3[(t1      ) & 0xff] ^
+            rk[2];
+        s3 =
+            Te0[(t3 >> 24)       ] ^
+            Te1[(t0 >> 16) & 0xff] ^
+            Te2[(t1 >>  8) & 0xff] ^
+            Te3[(t2      ) & 0xff] ^
+            rk[3];
+    }
+#endif /* ?FULL_UNROLL */
+    /*
+	 * apply last round and
+	 * map cipher state to byte array block:
+	 */
+	s0 =
+		(Te4[(t0 >> 24)       ] & 0xff000000) ^
+		(Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
+		(Te4[(t2 >>  8) & 0xff] & 0x0000ff00) ^
+		(Te4[(t3      ) & 0xff] & 0x000000ff) ^
+		rk[0];
+	PUTU32(out     , s0);
+	s1 =
+		(Te4[(t1 >> 24)       ] & 0xff000000) ^
+		(Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
+		(Te4[(t3 >>  8) & 0xff] & 0x0000ff00) ^
+		(Te4[(t0      ) & 0xff] & 0x000000ff) ^
+		rk[1];
+	PUTU32(out +  4, s1);
+	s2 =
+		(Te4[(t2 >> 24)       ] & 0xff000000) ^
+		(Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
+		(Te4[(t0 >>  8) & 0xff] & 0x0000ff00) ^
+		(Te4[(t1      ) & 0xff] & 0x000000ff) ^
+		rk[2];
+	PUTU32(out +  8, s2);
+	s3 =
+		(Te4[(t3 >> 24)       ] & 0xff000000) ^
+		(Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
+		(Te4[(t1 >>  8) & 0xff] & 0x0000ff00) ^
+		(Te4[(t2      ) & 0xff] & 0x000000ff) ^
+		rk[3];
+	PUTU32(out + 12, s3);
+}
+
+/*
+ * Decrypt a single block
+ * in and out can overlap
+ */
+void AES_decrypt(const unsigned char *in, unsigned char *out,
+		 const AES_KEY *key) {
+
+	const u32 *rk;
+	u32 s0, s1, s2, s3, t0, t1, t2, t3;
+#ifndef FULL_UNROLL
+	int r;
+#endif /* ?FULL_UNROLL */
+
+	assert(in && out && key);
+	rk = key->rd_key;
+
+	/*
+	 * map byte array block to cipher state
+	 * and add initial round key:
+	 */
+    s0 = GETU32(in     ) ^ rk[0];
+    s1 = GETU32(in +  4) ^ rk[1];
+    s2 = GETU32(in +  8) ^ rk[2];
+    s3 = GETU32(in + 12) ^ rk[3];
+#ifdef FULL_UNROLL
+    /* round 1: */
+    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4];
+    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5];
+    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6];
+    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7];
+    /* round 2: */
+    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8];
+    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9];
+    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10];
+    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11];
+    /* round 3: */
+    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12];
+    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13];
+    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14];
+    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15];
+    /* round 4: */
+    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16];
+    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17];
+    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18];
+    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19];
+    /* round 5: */
+    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20];
+    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21];
+    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22];
+    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23];
+    /* round 6: */
+    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24];
+    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25];
+    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26];
+    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27];
+    /* round 7: */
+    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28];
+    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29];
+    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30];
+    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31];
+    /* round 8: */
+    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32];
+    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33];
+    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34];
+    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35];
+    /* round 9: */
+    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36];
+    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37];
+    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38];
+    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39];
+    if (key->rounds > 10) {
+        /* round 10: */
+        s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40];
+        s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41];
+        s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42];
+        s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43];
+        /* round 11: */
+        t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44];
+        t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45];
+        t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46];
+        t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47];
+        if (key->rounds > 12) {
+            /* round 12: */
+            s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48];
+            s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49];
+            s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50];
+            s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51];
+            /* round 13: */
+            t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52];
+            t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53];
+            t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54];
+            t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55];
+        }
+    }
+	rk += key->rounds << 2;
+#else  /* !FULL_UNROLL */
+    /*
+     * Nr - 1 full rounds:
+     */
+    r = key->rounds >> 1;
+    for (;;) {
+        t0 =
+            Td0[(s0 >> 24)       ] ^
+            Td1[(s3 >> 16) & 0xff] ^
+            Td2[(s2 >>  8) & 0xff] ^
+            Td3[(s1      ) & 0xff] ^
+            rk[4];
+        t1 =
+            Td0[(s1 >> 24)       ] ^
+            Td1[(s0 >> 16) & 0xff] ^
+            Td2[(s3 >>  8) & 0xff] ^
+            Td3[(s2      ) & 0xff] ^
+            rk[5];
+        t2 =
+            Td0[(s2 >> 24)       ] ^
+            Td1[(s1 >> 16) & 0xff] ^
+            Td2[(s0 >>  8) & 0xff] ^
+            Td3[(s3      ) & 0xff] ^
+            rk[6];
+        t3 =
+            Td0[(s3 >> 24)       ] ^
+            Td1[(s2 >> 16) & 0xff] ^
+            Td2[(s1 >>  8) & 0xff] ^
+            Td3[(s0      ) & 0xff] ^
+            rk[7];
+
+        rk += 8;
+        if (--r == 0) {
+            break;
+        }
+
+        s0 =
+            Td0[(t0 >> 24)       ] ^
+            Td1[(t3 >> 16) & 0xff] ^
+            Td2[(t2 >>  8) & 0xff] ^
+            Td3[(t1      ) & 0xff] ^
+            rk[0];
+        s1 =
+            Td0[(t1 >> 24)       ] ^
+            Td1[(t0 >> 16) & 0xff] ^
+            Td2[(t3 >>  8) & 0xff] ^
+            Td3[(t2      ) & 0xff] ^
+            rk[1];
+        s2 =
+            Td0[(t2 >> 24)       ] ^
+            Td1[(t1 >> 16) & 0xff] ^
+            Td2[(t0 >>  8) & 0xff] ^
+            Td3[(t3      ) & 0xff] ^
+            rk[2];
+        s3 =
+            Td0[(t3 >> 24)       ] ^
+            Td1[(t2 >> 16) & 0xff] ^
+            Td2[(t1 >>  8) & 0xff] ^
+            Td3[(t0      ) & 0xff] ^
+            rk[3];
+    }
+#endif /* ?FULL_UNROLL */
+    /*
+	 * apply last round and
+	 * map cipher state to byte array block:
+	 */
+   	s0 =
+   		(Td4[(t0 >> 24)       ] & 0xff000000) ^
+   		(Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
+   		(Td4[(t2 >>  8) & 0xff] & 0x0000ff00) ^
+   		(Td4[(t1      ) & 0xff] & 0x000000ff) ^
+   		rk[0];
+	PUTU32(out     , s0);
+   	s1 =
+   		(Td4[(t1 >> 24)       ] & 0xff000000) ^
+   		(Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
+   		(Td4[(t3 >>  8) & 0xff] & 0x0000ff00) ^
+   		(Td4[(t2      ) & 0xff] & 0x000000ff) ^
+   		rk[1];
+	PUTU32(out +  4, s1);
+   	s2 =
+   		(Td4[(t2 >> 24)       ] & 0xff000000) ^
+   		(Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
+   		(Td4[(t0 >>  8) & 0xff] & 0x0000ff00) ^
+   		(Td4[(t3      ) & 0xff] & 0x000000ff) ^
+   		rk[2];
+	PUTU32(out +  8, s2);
+   	s3 =
+   		(Td4[(t3 >> 24)       ] & 0xff000000) ^
+   		(Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
+   		(Td4[(t1 >>  8) & 0xff] & 0x0000ff00) ^
+   		(Td4[(t0      ) & 0xff] & 0x000000ff) ^
+   		rk[3];
+	PUTU32(out + 12, s3);
+}
+
+#endif /* AES_ASM */
+
+void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
+		     const unsigned long length, const AES_KEY *key,
+		     unsigned char *ivec, const int enc) 
+{
+
+	unsigned long n;
+	unsigned long len = length;
+	unsigned char tmp[AES_BLOCK_SIZE];
+
+	assert(in && out && key && ivec);
+
+	if (enc) {
+		while (len >= AES_BLOCK_SIZE) {
+			for(n=0; n < AES_BLOCK_SIZE; ++n)
+				tmp[n] = in[n] ^ ivec[n];
+			AES_encrypt(tmp, out, key);
+			memcpy(ivec, out, AES_BLOCK_SIZE);
+			len -= AES_BLOCK_SIZE;
+			in += AES_BLOCK_SIZE;
+			out += AES_BLOCK_SIZE;
+		}
+		if (len) {
+			for(n=0; n < len; ++n)
+				tmp[n] = in[n] ^ ivec[n];
+			for(n=len; n < AES_BLOCK_SIZE; ++n)
+				tmp[n] = ivec[n];
+			AES_encrypt(tmp, tmp, key);
+			memcpy(out, tmp, AES_BLOCK_SIZE);
+			memcpy(ivec, tmp, AES_BLOCK_SIZE);
+		}			
+	} else {
+		while (len >= AES_BLOCK_SIZE) {
+			memcpy(tmp, in, AES_BLOCK_SIZE);
+			AES_decrypt(in, out, key);
+			for(n=0; n < AES_BLOCK_SIZE; ++n)
+				out[n] ^= ivec[n];
+			memcpy(ivec, tmp, AES_BLOCK_SIZE);
+			len -= AES_BLOCK_SIZE;
+			in += AES_BLOCK_SIZE;
+			out += AES_BLOCK_SIZE;
+		}
+		if (len) {
+			memcpy(tmp, in, AES_BLOCK_SIZE);
+			AES_decrypt(tmp, tmp, key);
+			for(n=0; n < len; ++n)
+				out[n] = tmp[n] ^ ivec[n];
+			memcpy(ivec, tmp, AES_BLOCK_SIZE);
+		}			
+	}
+}
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/aes.h xen-unstable-tapbuild.hg/tools/blktap/tools/aes.h
--- xen-unstable-pristine.hg/tools/blktap/tools/aes.h	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/aes.h	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,26 @@
+#ifndef QEMU_AES_H
+#define QEMU_AES_H
+
+#define AES_MAXNR 14
+#define AES_BLOCK_SIZE 16
+
+struct aes_key_st {
+    uint32_t rd_key[4 *(AES_MAXNR + 1)];
+    int rounds;
+};
+typedef struct aes_key_st AES_KEY;
+
+int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
+	AES_KEY *key);
+int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
+	AES_KEY *key);
+
+void AES_encrypt(const unsigned char *in, unsigned char *out,
+	const AES_KEY *key);
+void AES_decrypt(const unsigned char *in, unsigned char *out,
+	const AES_KEY *key);
+void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
+		     const unsigned long length, const AES_KEY *key,
+		     unsigned char *ivec, const int enc);
+
+#endif
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/blktapctrl.c xen-unstable-tapbuild.hg/tools/blktap/tools/blktapctrl.c
--- xen-unstable-pristine.hg/tools/blktap/tools/blktapctrl.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/blktapctrl.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,704 @@
+/*
+ * blktapctrl.c
+ * 
+ * userspace controller for the blktap disks.
+ * As requests for new block devices arrive,
+ * the controller spawns off a separate process
+ * per-disk.
+ *
+ *
+ * Copyright (c) 2005 Julian Chesterfield and Andrew Warfield.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/user.h>
+#include <err.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <linux/types.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <sys/poll.h>
+#include <sys/ioctl.h>
+#include <string.h>
+#include <unistd.h>
+#include <xs.h>
+#include <printf.h>
+#include <sys/time.h>
+#include <syslog.h>
+                                                                     
+#include "blktaplib.h"
+#include "blktapctrl.h"
+#include "tapdisk.h"
+
+#define NUM_POLL_FDS 2
+#define MSG_SIZE 4096
+#define MAX_TIMEOUT 10
+#define MAX_RAND_VAL 0xFFFF
+
+int run = 1;
+int max_timeout = MAX_TIMEOUT;
+int ctlfd = 0;
+
+static int open_ctrl_socket(char *devname);
+static int write_msg(int fd, int msgtype, void *ptr, void *ptr2);
+static int read_msg(int fd, int msgtype, void *ptr);
+static driver_list_entry_t *active_disks[MAX_DISK_TYPES];
+
+void sig_handler(int sig)
+{
+	run = 0;	
+}
+
+static void init_driver_list(void)
+{
+	int i;
+
+	for (i = 0; i < MAX_DISK_TYPES; i++)
+		active_disks[i] = NULL;
+	return;
+}
+
+static void init_rng(void)
+{
+	static uint32_t seed;
+	struct timeval tv;
+
+	gettimeofday(&tv, NULL);
+	seed = tv.tv_usec;
+	srand48(seed);
+	return;
+}
+
+static void make_blktap_dev(char *devname, int major, int minor)
+{
+	struct stat st;
+	
+	if (lstat(devname, &st) != 0) {
+		/*Need to create device*/
+		if (mkdir(BLKTAP_DEV_DIR, 0755) == 0)
+			DPRINTF("Created %s directory\n",BLKTAP_DEV_DIR);
+		if (mknod(devname, S_IFCHR|0600,
+                	makedev(major, minor)) == 0)
+			DPRINTF("Created %s device\n",devname);
+	} else DPRINTF("%s device already exists\n",devname);
+}
+
+static int get_new_dev(int *major, int *minor, blkif_t *blkif)
+{
+	domid_translate_t tr;
+	int ret;
+	char *devname;
+	
+	tr.domid = blkif->domid;
+        tr.busid = (unsigned short)blkif->be_id;
+	ret = ioctl(ctlfd, BLKTAP_IOCTL_NEWINTF, tr );
+	
+	if ( (ret <= 0)||(ret > MAX_TAP_DEV) ) {
+		DPRINTF("Incorrect Dev ID [%d]\n",ret);
+		return -1;
+	}
+	
+	*minor = ret;
+	*major = ioctl(ctlfd, BLKTAP_IOCTL_MAJOR, ret );
+	if (*major < 0) {
+		DPRINTF("Incorrect Major ID [%d]\n",*major);
+		return -1;
+	}
+
+	asprintf(&devname,"%s/%s%d",BLKTAP_DEV_DIR, BLKTAP_DEV_NAME, *minor);
+	make_blktap_dev(devname,*major,*minor);	
+	DPRINTF("Received device id %d and major %d, "
+		"sent domid %d and be_id %d\n",
+		*minor, *major, tr.domid, tr.busid);
+	return 0;
+}
+
+static int get_tapdisk_pid(blkif_t *blkif)
+{
+	int ret;
+
+	if ((ret = write_msg(blkif->fds[WRITE], CTLMSG_PID, blkif, NULL)) 
+	    <= 0) {
+		DPRINTF("Write_msg failed - CTLMSG_PID(%d)\n", ret);
+		return -EINVAL;
+	}
+
+	if ((ret = read_msg(blkif->fds[READ], CTLMSG_PID_RSP, blkif))
+	     <= 0) {
+		DPRINTF("Read_msg failure - CTLMSG_PID(%d)\n", ret);
+		return -EINVAL;
+	}	
+	return 1;
+}
+
+static blkif_t *test_path(char *path, char **dev, int *type)
+{
+	char *ptr, handle[10];
+	int i, size;
+
+	size = sizeof(dtypes)/sizeof(disk_info_t *);
+	*type = MAX_DISK_TYPES + 1;
+
+	if ( (ptr = strstr(path, ":"))!=NULL) {
+		memcpy(handle, path, (ptr - path));
+		*dev = ptr + 1;
+		ptr = handle + (ptr - path);
+		*ptr = '\0';
+		DPRINTF("Detected handle: [%s]\n",handle);
+
+		for (i = 0; i < size; i++) {
+			if (strncmp(handle, dtypes[i]->handle, (ptr - path))
+			    ==0) {
+				*type = dtypes[i]->idnum;
+
+				if (dtypes[i]->single_handler == 1) {
+					/* Check whether tapdisk process 
+					   already exists */
+					if (active_disks[dtypes[i]->idnum] 
+					    == NULL) return NULL;
+					else 
+						return active_disks[dtypes[i]->idnum]->blkif;
+				}
+			}
+		}
+	} else *dev = NULL;
+
+	return NULL;
+}
+
+static void add_disktype(blkif_t *blkif, int type)
+{
+	driver_list_entry_t *entry, *ptr, *last;
+
+	if (type > MAX_DISK_TYPES) return;
+
+	entry = malloc(sizeof(driver_list_entry_t));
+	entry->blkif = blkif;
+	entry->next = NULL;
+	ptr = active_disks[type];
+
+	if (ptr == NULL) {
+		active_disks[type] = entry;
+		entry->prev = NULL;
+		return;
+	}
+
+	while (ptr != NULL) {
+		last = ptr;
+		ptr = ptr->next;
+	}
+
+	/*We've found the end of the list*/
+        last->next = entry;
+	entry->prev = last;
+	
+	return;
+}
+
+static int del_disktype(blkif_t *blkif)
+{
+	driver_list_entry_t *ptr, *cur, *last;
+	int type = blkif->drivertype, count = 0, close = 0;
+
+	if (type > MAX_DISK_TYPES) return 1;
+
+	ptr = active_disks[type];
+	last = NULL;
+	while (ptr != NULL) {
+		count++;
+		if (blkif == ptr->blkif) {
+			cur = ptr;
+			if (ptr->next != NULL) {
+				/*There's more later in the chain*/
+				if (!last) {
+					/*We're first in the list*/
+					active_disks[type] = ptr->next;
+					ptr = ptr->next;
+					ptr->prev = NULL;
+				}
+				else {
+					/*We're sandwiched*/
+					last->next = ptr->next;
+					ptr = ptr->next;
+					ptr->prev = last;
+				}
+				
+			} else if (last) {
+				/*There's more earlier in the chain*/
+				last->next = NULL;
+			} else {
+				/*We're the only entry*/
+				active_disks[type] = NULL;
+				if(dtypes[type]->single_handler == 1) 
+					close = 1;
+			}
+			DPRINTF("DEL_DISKTYPE: Freeing entry\n");
+			free(cur);
+			if (dtypes[type]->single_handler == 0) close = 1;
+
+			return close;
+		}
+		last = ptr;
+		ptr = ptr->next;
+	}
+	DPRINTF("DEL_DISKTYPE: No match\n");
+	return 1;
+}
+
+static int write_msg(int fd, int msgtype, void *ptr, void *ptr2)
+{
+	blkif_t *blkif;
+	blkif_info_t *blk;
+	msg_hdr_t *msg;
+	msg_newdev_t *msg_dev;
+	char *p, *buf, *path;
+	int msglen, len, ret;
+	fd_set writefds;
+	struct timeval timeout;
+	image_t *image, *img;
+	uint32_t seed;
+
+	blkif = (blkif_t *)ptr;
+	blk = blkif->info;
+	image = blkif->prv;
+	len = 0;
+
+	switch (msgtype)
+	{
+	case CTLMSG_PARAMS:
+		path = (char *)ptr2;
+		DPRINTF("Write_msg called: CTLMSG_PARAMS, sending [%s, %s]\n",
+			blk->params, path);
+
+		msglen = sizeof(msg_hdr_t) + strlen(path) + 1;
+		buf = malloc(msglen);
+
+		/*Assign header fields*/
+		msg = (msg_hdr_t *)buf;
+		msg->type = CTLMSG_PARAMS;
+		msg->len = msglen;
+		msg->drivertype = blkif->drivertype;
+
+		gettimeofday(&timeout, NULL);
+		msg->cookie = blkif->cookie;
+		DPRINTF("Generated cookie, %d\n",blkif->cookie);
+
+		/*Copy blk->params to msg*/
+		p = buf + sizeof(msg_hdr_t);
+		memcpy(p, path, strlen(path) + 1);
+
+		break;
+
+	case CTLMSG_NEWDEV:
+		DPRINTF("Write_msg called: CTLMSG_NEWDEV\n");
+
+		msglen = sizeof(msg_hdr_t) + sizeof(msg_newdev_t);
+		buf = malloc(msglen);
+		
+		/*Assign header fields*/
+		msg = (msg_hdr_t *)buf;
+		msg->type = CTLMSG_NEWDEV;
+		msg->len = msglen;
+		msg->drivertype = blkif->drivertype;
+		msg->cookie = blkif->cookie;
+		
+		msg_dev = (msg_newdev_t *)(buf + sizeof(msg_hdr_t));
+		msg_dev->devnum = blkif->minor;
+		msg_dev->domid = blkif->domid;
+
+		break;
+
+	case CTLMSG_CLOSE:
+		DPRINTF("Write_msg called: CTLMSG_CLOSE\n");
+
+		msglen = sizeof(msg_hdr_t);
+		buf = malloc(msglen);
+		
+		/*Assign header fields*/
+		msg = (msg_hdr_t *)buf;
+		msg->type = CTLMSG_CLOSE;
+		msg->len = msglen;
+		msg->drivertype = blkif->drivertype;
+		msg->cookie = blkif->cookie;
+		
+		break;
+
+	case CTLMSG_PID:
+		DPRINTF("Write_msg called: CTLMSG_PID\n");
+
+		msglen = sizeof(msg_hdr_t);
+		buf = malloc(msglen);
+		
+		/*Assign header fields*/
+		msg = (msg_hdr_t *)buf;
+		msg->type = CTLMSG_PID;
+		msg->len = msglen;
+		msg->drivertype = blkif->drivertype;
+		msg->cookie = blkif->cookie;
+		
+		break;
+		
+	default:
+		return -1;
+	}
+
+	/*Now send the message*/
+	ret = 0;
+	FD_ZERO(&writefds);
+	FD_SET(fd,&writefds);
+	timeout.tv_sec = max_timeout; /*Wait for up to max_timeout seconds*/
+	timeout.tv_usec = 0;
+	if (select(fd+1, (fd_set *) 0, &writefds, 
+		  (fd_set *) 0, &timeout) > 0) {
+		len = write(fd, buf, msglen);
+		if (len == -1) DPRINTF("Write failed: (%d)\n",errno);
+	}
+	free(buf);
+
+	return len;
+}
+
+static int read_msg(int fd, int msgtype, void *ptr)
+{
+	blkif_t *blkif;
+	blkif_info_t *blk;
+	msg_hdr_t *msg;
+	msg_pid_t *msg_pid;
+	char *p, *buf;
+	int msglen = MSG_SIZE, len, ret;
+	fd_set readfds;
+	struct timeval timeout;
+	image_t *image, *img;
+
+
+	blkif = (blkif_t *)ptr;
+	blk = blkif->info;
+	image = blkif->prv;
+
+	buf = malloc(MSG_SIZE);
+
+	ret = 0;
+	FD_ZERO(&readfds);
+	FD_SET(fd,&readfds);
+	timeout.tv_sec = max_timeout; /*Wait for up to max_timeout seconds*/ 
+	timeout.tv_usec = 0;
+	if (select(fd+1, &readfds,  (fd_set *) 0,
+		  (fd_set *) 0, &timeout) > 0) {
+		ret = read(fd, buf, msglen);
+		
+	}			
+	if (ret > 0) {
+		msg = (msg_hdr_t *)buf;
+		switch (msg->type)
+		{
+		case CTLMSG_IMG:
+			img = (image_t *)(buf + sizeof(msg_hdr_t));
+			image->size = img->size;
+			image->secsize = img->secsize;
+			image->info = img->info;
+
+			DPRINTF("Received CTLMSG_IMG: %lu, %lu, %lu\n",
+				image->size, image->secsize, image->info);
+			if(msgtype != CTLMSG_IMG) ret = 0;
+			break;
+			
+		case CTLMSG_IMG_FAIL:
+			DPRINTF("Received CTLMSG_IMG_FAIL, "
+				"unable to open image\n");
+			ret = 0;
+			break;
+				
+		case CTLMSG_NEWDEV_RSP:
+			DPRINTF("Received CTLMSG_NEWDEV_RSP\n");
+			if(msgtype != CTLMSG_NEWDEV_RSP) ret = 0;
+			break;
+			
+		case CTLMSG_NEWDEV_FAIL:
+			DPRINTF("Received CTLMSG_NEWDEV_FAIL\n");
+			ret = 0;
+			break;
+			
+		case CTLMSG_CLOSE_RSP:
+			DPRINTF("Received CTLMSG_CLOSE_RSP\n");
+			if (msgtype != CTLMSG_CLOSE_RSP) ret = 0;
+			break;
+
+		case CTLMSG_PID_RSP:
+			DPRINTF("Received CTLMSG_PID_RSP\n");
+			if (msgtype != CTLMSG_PID_RSP) ret = 0;
+			else {
+				msg_pid = (msg_pid_t *)
+					(buf + sizeof(msg_hdr_t));
+				blkif->tappid = msg_pid->pid;
+				DPRINTF("\tPID: [%d]\n",blkif->tappid);
+			}
+			break;
+		default:
+			DPRINTF("UNKNOWN MESSAGE TYPE RECEIVED\n");
+			ret = 0;
+			break;
+		}
+	} 
+	
+	free(buf);
+	
+	return ret;
+
+}
+
+int blktapctrl_new_blkif(blkif_t *blkif)
+{
+	blkif_info_t *blk;
+	int major, minor, fd_read, fd_write, type, new;
+	char *rdctldev, *wrctldev, *cmd, *ptr;
+	image_t *image;
+	blkif_t *exist = NULL;
+
+	DPRINTF("Received a poll for a new vbd\n");
+	if ( ((blk=blkif->info) != NULL) && (blk->params != NULL) ) {
+		if (get_new_dev(&major, &minor, blkif)<0)
+			return -1;
+
+		exist = test_path(blk->params, &ptr, &type);
+		blkif->drivertype = type;
+		blkif->cookie = lrand48() % MAX_RAND_VAL;
+
+		if (!exist) {
+			DPRINTF("Process does not exist:\n");
+			asprintf(&rdctldev, "/dev/xen/tapctrlread%d", minor);
+			blkif->fds[READ] = open_ctrl_socket(rdctldev);
+
+
+			asprintf(&wrctldev, "/dev/xen/tapctrlwrite%d", minor);
+			blkif->fds[WRITE] = open_ctrl_socket(wrctldev);
+			
+			if (blkif->fds[READ] == -1 || blkif->fds[WRITE] == -1) 
+				goto fail;
+
+			/*launch the new process*/
+			asprintf(&cmd, "tapdisk %s %s", wrctldev, rdctldev);
+			DPRINTF("Launching process, CMDLINE [%s]\n",cmd);
+			if (system(cmd) == -1) {
+				DPRINTF("Unable to fork, cmdline: [%s]\n",cmd);
+				return -1;
+			}
+
+			free(rdctldev);
+			free(wrctldev);
+			free(cmd);
+		} else {
+			DPRINTF("Process exists!\n");
+			blkif->fds[READ] = exist->fds[READ];
+			blkif->fds[WRITE] = exist->fds[WRITE];
+		}
+
+		add_disktype(blkif, type);
+		blkif->major = major;
+		blkif->minor = minor;
+
+		image = (image_t *)malloc(sizeof(image_t));
+		blkif->prv = (void *)image;
+		blkif->ops = &tapdisk_ops;
+
+		/*Retrieve the PID of the new process*/
+		if (get_tapdisk_pid(blkif) <= 0) {
+			DPRINTF("Unable to contact disk process\n");
+			goto fail;
+		}
+
+		/* Both of the following read and write calls will block up to 
+		 * max_timeout val*/
+		if (write_msg(blkif->fds[WRITE], CTLMSG_PARAMS, blkif, ptr) 
+		    <= 0) {
+			DPRINTF("Write_msg failed - CTLMSG_PARAMS\n");
+			goto fail;
+		}
+
+		if (read_msg(blkif->fds[READ], CTLMSG_IMG, blkif) <= 0) {
+			DPRINTF("Read_msg failure - CTLMSG_IMG\n");
+			goto fail;
+		}
+
+	} else return -1;
+
+	return 0;
+fail:
+	ioctl(ctlfd, BLKTAP_IOCTL_FREEINTF, minor);
+	return -EINVAL;
+}
+
+int map_new_blktapctrl(blkif_t *blkif)
+{
+	DPRINTF("Received a poll for a new devmap\n");
+	if (write_msg(blkif->fds[WRITE], CTLMSG_NEWDEV, blkif, NULL) <= 0) {
+		DPRINTF("Write_msg failed - CTLMSG_NEWDEV\n");
+		return -EINVAL;
+	}
+
+	if (read_msg(blkif->fds[READ], CTLMSG_NEWDEV_RSP, blkif) <= 0) {
+		DPRINTF("Read_msg failed - CTLMSG_NEWDEV_RSP\n");
+		return -EINVAL;
+	}
+	DPRINTF("Exiting map_new_blktapctrl\n");
+
+	return blkif->minor - 1;
+}
+
+int unmap_blktapctrl(blkif_t *blkif)
+{
+	DPRINTF("Unmapping vbd\n");
+
+	if (write_msg(blkif->fds[WRITE], CTLMSG_CLOSE, blkif, NULL) <= 0) {
+		DPRINTF("Write_msg failed - CTLMSG_CLOSE\n");
+		return -EINVAL;
+	}
+
+	if (del_disktype(blkif)) {
+		close(blkif->fds[WRITE]);
+		close(blkif->fds[READ]);
+
+	}
+	return 0;
+}
+
+int open_ctrl_socket(char *devname)
+{
+	int ret;
+	int ipc_fd;
+	char *cmd;
+	fd_set socks;
+	struct timeval timeout;
+
+	ret = mkfifo(devname,S_IRWXU|S_IRWXG|S_IRWXO);
+	if ( (ret != 0) && (errno != EEXIST) ) {
+		DPRINTF("ERROR: pipe failed (%d)\n", errno);
+		exit(0);
+	}
+
+	ipc_fd = open(devname,O_RDWR|O_NONBLOCK);
+
+	if (ipc_fd < 0) {
+		DPRINTF("FD open failed\n");
+		return -1;
+	}
+
+	return ipc_fd;
+}
+
+static void print_drivers(void)
+{
+	int i, size;
+
+	size = sizeof(dtypes)/sizeof(disk_info_t *);
+	DPRINTF("blktapctrl: v1.0.0\n");
+	for (i = 0; i < size; i++)
+		DPRINTF("Found driver: [%s]\n",dtypes[i]->name);
+} 
+
+int main(int argc, char *argv[])
+{
+	char *devname;
+	tapdev_info_t *ctlinfo;
+	int tap_pfd, store_pfd, xs_fd, ret, timeout, pfd_count;
+	struct xs_handle *h;
+	struct pollfd  pfd[NUM_POLL_FDS];
+	pid_t process;
+
+	__init_blkif();
+	openlog("BLKTAPCTRL", LOG_CONS|LOG_ODELAY, LOG_DAEMON);
+
+	print_drivers();
+	init_driver_list();
+	init_rng();
+
+	register_new_blkif_hook(blktapctrl_new_blkif);
+	register_new_devmap_hook(map_new_blktapctrl);
+	register_new_unmap_hook(unmap_blktapctrl);
+
+	/*Attach to blktap0 */	
+	asprintf(&devname,"%s/%s0", BLKTAP_DEV_DIR, BLKTAP_DEV_NAME);
+	make_blktap_dev(devname,254,0);
+	ctlfd = open(devname, O_RDWR);
+	if (ctlfd == -1) {
+		DPRINTF("blktap0 open failed\n");
+		goto open_failed;
+	}
+
+	/* Set up store connection and watch. */
+	h = xs_daemon_open();
+	if (h == NULL) {
+		DPRINTF("xs_daemon_open failed -- "
+			"is xenstore running?\n");
+		goto open_failed;
+	}
+	
+	ret = add_blockdevice_probe_watch(h, "Domain-0");
+	if (ret != 0) {
+		DPRINTF("adding device probewatch\n");
+		goto open_failed;
+	}
+
+	ioctl(ctlfd, BLKTAP_IOCTL_SETMODE, BLKTAP_MODE_INTERPOSE );
+
+	process = getpid();
+	ret = ioctl(ctlfd, BLKTAP_IOCTL_SENDPID, process );
+
+	/*Static pollhooks*/
+	pfd_count = 0;
+	tap_pfd = pfd_count++;
+	pfd[tap_pfd].fd = ctlfd;
+	pfd[tap_pfd].events = POLLIN;
+	
+	store_pfd = pfd_count++;
+	pfd[store_pfd].fd = xs_fileno(h);
+	pfd[store_pfd].events = POLLIN;
+
+	while (run) {
+		timeout = 1000; /*Milliseconds*/
+                ret = poll(pfd, pfd_count, timeout);
+
+		if (ret > 0) {
+			if (pfd[store_pfd].revents) {
+				ret = xs_fire_next_watch(h);
+			}
+		}
+	}
+
+	ioctl(ctlfd, BLKTAP_IOCTL_SETMODE, BLKTAP_MODE_PASSTHROUGH );
+	close(ctlfd);
+	closelog();
+
+	return 0;
+	
+ open_failed:
+	DPRINTF("Unable to start blktapctrl\n");
+	closelog();
+	return -1;
+}
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/blktapctrl.h xen-unstable-tapbuild.hg/tools/blktap/tools/blktapctrl.h
--- xen-unstable-pristine.hg/tools/blktap/tools/blktapctrl.h	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/blktapctrl.h	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,55 @@
+/* blktapctrl.h
+ *
+ * controller image utils.
+ * 
+ * (c) 2004-6 Andrew Warfield and Julian Chesterfield
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+
+static inline long int tapdisk_get_size(blkif_t *blkif)
+{
+	image_t *img = (image_t *)blkif->prv;
+	return img->size;
+}
+
+static inline long int tapdisk_get_secsize(blkif_t *blkif)
+{
+	image_t *img = (image_t *)blkif->prv;
+	return img->secsize;
+}
+
+static inline unsigned tapdisk_get_info(blkif_t *blkif)
+{
+	image_t *img = (image_t *)blkif->prv;
+	return img->info;
+}
+
+struct blkif_ops tapdisk_ops = {
+	.get_size = tapdisk_get_size,
+	.get_secsize = tapdisk_get_secsize,
+	.get_info = tapdisk_get_info,
+};
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/block-aio.c xen-unstable-tapbuild.hg/tools/blktap/tools/block-aio.c
--- xen-unstable-pristine.hg/tools/blktap/tools/block-aio.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/block-aio.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,327 @@
+/* block-aio.c
+ *
+ * libaio-based raw disk implementation.
+ *
+ * (c) 2006 Andrew Warfield and Julian Chesterfield
+ *
+ * NB: This code is not thread-safe.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+
+#include <errno.h>
+#include <libaio.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include "tapdisk.h"
+
+
+/**
+ * We used a kernel patch to return an fd associated with the AIO context
+ * so that we can concurrently poll on synchronous and async descriptors.
+ * This is signalled by passing 1 as the io context to io_setup.
+ */
+#define REQUEST_ASYNC_FD 1
+
+#define MAX_AIO_REQS (MAX_REQUESTS * MAX_SEGMENTS_PER_REQ * 8)
+
+struct pending_aio {
+	td_callback_t cb;
+	int id;
+	void *private;
+};
+
+struct tdaio_state {
+	int fd;
+	
+	/* libaio state */
+	io_context_t       aio_ctx;
+	struct iocb        iocb_list  [MAX_AIO_REQS];
+	struct iocb       *iocb_free  [MAX_AIO_REQS];
+	struct pending_aio pending_aio[MAX_AIO_REQS];
+	int                iocb_free_count;
+	struct iocb       *iocb_queue[MAX_AIO_REQS];
+	int                iocb_queued;
+	int                poll_fd; /* NB: we require aio_poll support */
+	struct io_event    aio_events[MAX_AIO_REQS];
+};
+
+#define IOCB_IDX(_s, _io) ((_io) - (_s)->iocb_list)
+
+/*Get Image size, secsize*/
+static int get_image_info(struct td_state *s, int fd)
+{
+	int ret;
+	long size;
+	unsigned long total_size;
+	struct statvfs statBuf;
+	struct stat stat;
+
+	ret = fstat(fd, &stat);
+	if (ret != 0) {
+		DPRINTF("ERROR: fstat failed, Couldn't stat image");
+		return -EINVAL;
+	}
+
+	if (S_ISBLK(stat.st_mode)) {
+		/*Accessing block device directly*/
+		s->size = 0;
+		if (ioctl(fd,BLKGETSIZE,&s->size)!=0) {
+			DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image");
+			return -EINVAL;
+		}
+
+		DPRINTF("Image size: \n\tpre sector_shift  [%llu]\n\tpost "
+			"sector_shift [%llu]\n",
+			(long long unsigned)(s->size << SECTOR_SHIFT),
+			(long long unsigned)s->size);
+
+		/*Get the sector size*/
+#if defined(BLKSSZGET)
+		{
+			int arg;
+			s->sector_size = DEFAULT_SECTOR_SIZE;
+			ioctl(fd, BLKSSZGET, &s->sector_size);
+			
+			if (s->sector_size != DEFAULT_SECTOR_SIZE)
+				DPRINTF("Note: sector size is %ld (not %d)\n",
+					s->sector_size, DEFAULT_SECTOR_SIZE);
+		}
+#else
+		s->sector_size = DEFAULT_SECTOR_SIZE;
+#endif
+
+	} else {
+		/*Local file? try fstat instead*/
+		s->size = (stat.st_size >> SECTOR_SHIFT);
+		s->sector_size = DEFAULT_SECTOR_SIZE;
+		DPRINTF("Image size: \n\tpre sector_shift  [%llu]\n\tpost "
+			"sector_shift [%llu]\n",
+			(long long unsigned)(s->size << SECTOR_SHIFT),
+			(long long unsigned)s->size);
+	}
+
+	if (s->size == 0) {		
+		s->size =((uint64_t) 16836057);
+		s->sector_size = DEFAULT_SECTOR_SIZE;
+	}
+	s->info = 0;
+
+	return 0;
+}
+
+/* Open the disk file and initialize aio state. */
+int tdaio_open (struct td_state *s, const char *name)
+{
+	int i, fd, ret = 0;
+	struct tdaio_state *prv = (struct tdaio_state *)s->private;
+	s->private = prv;
+
+	DPRINTF("XXX: block-aio open('%s')", name);
+	/* Initialize AIO */
+	prv->iocb_free_count = MAX_AIO_REQS;
+	prv->iocb_queued     = 0;
+	
+	prv->aio_ctx = (io_context_t) REQUEST_ASYNC_FD;
+	prv->poll_fd = io_setup(MAX_AIO_REQS, &prv->aio_ctx);
+
+	if (prv->poll_fd < 0) {
+		ret = prv->poll_fd;
+		DPRINTF("Couldn't get fd for AIO poll support.  This is "
+			"probably because your kernel does not have the "
+			"aio-poll patch applied.\n");
+		goto done;
+	}
+
+	for (i=0;i<MAX_AIO_REQS;i++)
+		prv->iocb_free[i] = &prv->iocb_list[i];
+
+	/* Open the file */
+        fd = open(name, O_RDWR | O_DIRECT | O_LARGEFILE);
+
+        if ( (fd == -1) && (errno == EINVAL) ) {
+
+                /* Maybe O_DIRECT isn't supported. */
+                fd = open(name, O_RDWR | O_LARGEFILE);
+                if (fd != -1) DPRINTF("WARNING: Accessing image without"
+                                     "O_DIRECT! (%s)\n", name);
+
+        } else if (fd != -1) DPRINTF("open(%s) with O_DIRECT\n", name);
+	
+        if (fd == -1) {
+		DPRINTF("Unable to open [%s] (%d)!\n", name, 0 - errno);
+        	ret = 0 - errno;
+        	goto done;
+        }
+
+        prv->fd = fd;
+
+	ret = get_image_info(s, fd);
+done:
+	return ret;	
+}
+
+int tdaio_queue_read(struct td_state *s, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *private)
+{
+	struct   iocb *io;
+	struct   pending_aio *pio;
+	struct   tdaio_state *prv = (struct tdaio_state *)s->private;
+	int      size    = nb_sectors * s->sector_size;
+	uint64_t offset  = sector * (uint64_t)s->sector_size;
+	long     ioidx;
+	
+	if (prv->iocb_free_count == 0)
+		return -ENOMEM;
+	io = prv->iocb_free[--prv->iocb_free_count];
+	
+	ioidx = IOCB_IDX(prv, io);
+	pio = &prv->pending_aio[ioidx];
+	pio->cb = cb;
+	pio->id = id;
+	pio->private = private;
+	
+	io_prep_pread(io, prv->fd, buf, size, offset);
+	io->data = (void *)ioidx;
+	
+	prv->iocb_queue[prv->iocb_queued++] = io;
+	
+	return 0;
+}
+			
+int tdaio_queue_write(struct td_state *s, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *private)
+{
+	struct   iocb *io;
+	struct   pending_aio *pio;
+	struct   tdaio_state *prv = (struct tdaio_state *)s->private;
+	int      size    = nb_sectors * s->sector_size;
+	uint64_t offset  = sector * (uint64_t)s->sector_size;
+	long     ioidx;
+	
+	if (prv->iocb_free_count == 0)
+		return -ENOMEM;
+	io = prv->iocb_free[--prv->iocb_free_count];
+	
+	ioidx = IOCB_IDX(prv, io);
+	pio = &prv->pending_aio[ioidx];
+	pio->cb = cb;
+	pio->id = id;
+	pio->private = private;
+	
+	io_prep_pwrite(io, prv->fd, buf, size, offset);
+	io->data = (void *)ioidx;
+	
+	prv->iocb_queue[prv->iocb_queued++] = io;
+	
+	return 0;
+}
+			
+int tdaio_submit(struct td_state *s)
+{
+	int ret;
+	struct   tdaio_state *prv = (struct tdaio_state *)s->private;
+
+	ret = io_submit(prv->aio_ctx, prv->iocb_queued, prv->iocb_queue);
+	
+	/* XXX: TODO: Handle error conditions here. */
+	
+	/* Success case: */
+	prv->iocb_queued = 0;
+	
+	return ret;
+}
+
+int *tdaio_get_fd(struct td_state *s)
+{
+	struct tdaio_state *prv = (struct tdaio_state *)s->private;
+	int *fds, i;
+
+	fds = malloc(sizeof(int) * MAX_IOFD);
+	/*initialise the FD array*/
+	for(i=0;i<MAX_IOFD;i++) fds[i] = 0;
+
+	fds[0] = prv->poll_fd;
+
+	return fds;	
+}
+
+int tdaio_close(struct td_state *s)
+{
+	struct tdaio_state *prv = (struct tdaio_state *)s->private;
+	
+	io_destroy(prv->aio_ctx);
+	close(prv->fd);
+	
+	return 0;
+}
+
+int tdaio_do_callbacks(struct td_state *s, int sid)
+{
+	int ret, i, rsp = 0;
+	struct io_event *ep;
+	struct tdaio_state *prv = (struct tdaio_state *)s->private;
+
+	/* Non-blocking test for completed io. */
+	ret = io_getevents(prv->aio_ctx, 0, MAX_AIO_REQS, prv->aio_events,
+			   NULL);
+			
+	for (ep=prv->aio_events,i=ret; i-->0; ep++) {
+		struct iocb        *io  = ep->obj;
+		struct pending_aio *pio;
+		
+		pio = &prv->pending_aio[(long)io->data];
+		
+		if (ep->res != io->u.c.nbytes) {
+			/* TODO: handle this case better. */
+			DPRINTF("AIO did less than I asked it to. \n");
+		}
+		rsp += pio->cb(s, ep->res2, pio->id, pio->private);
+
+		prv->iocb_free[prv->iocb_free_count++] = io;
+	}
+	return rsp;
+}
+	
+struct tap_disk tapdisk_aio = {
+	"tapdisk_aio",
+	sizeof(struct tdaio_state),
+	tdaio_open,
+	tdaio_queue_read,
+	tdaio_queue_write,
+	tdaio_submit,
+	tdaio_get_fd,
+	tdaio_close,
+	tdaio_do_callbacks,
+};
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/block-qcow.c xen-unstable-tapbuild.hg/tools/blktap/tools/block-qcow.c
--- xen-unstable-pristine.hg/tools/blktap/tools/block-qcow.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/block-qcow.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,1369 @@
+/* block-qcow.c
+ *
+ * Asynchronous Qemu copy-on-write disk implementation.
+ * Code based on the Qemu implementation
+ * (see copyright notice below)
+ *
+ * (c) 2006 Andrew Warfield and Julian Chesterfield
+ *
+ */
+
+/*
+ * Block driver for the QCOW format
+ * 
+ * Copyright (c) 2004 Fabrice Bellard
+ * 
+ * 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:
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include <string.h>
+#include <zlib.h>
+#include <inttypes.h>
+#include <libaio.h>
+#include <openssl/md5.h>
+#include "bswap.h"
+#include "aes.h"
+#include "tapdisk.h"
+
+#if 1
+#define ASSERT(_p) \
+    if ( !(_p) ) { DPRINTF("Assertion '%s' failed, line %d, file %s", #_p , \
+    __LINE__, __FILE__); *(int*)0=0; }
+#else
+#define ASSERT(_p) ((void)0)
+#endif
+
+
+/******AIO DEFINES******/
+#define REQUEST_ASYNC_FD 1
+#define MAX_QCOW_IDS  0xFFFF
+#define MAX_AIO_REQS (MAX_REQUESTS * MAX_SEGMENTS_PER_REQ * 8)
+
+struct pending_aio {
+        td_callback_t cb;
+        int id;
+        void *private;
+	int nb_sectors;
+	char *buf;
+	uint64_t sector;
+	int qcow_idx;
+};
+
+#define IOCB_IDX(_s, _io) ((_io) - (_s)->iocb_list)
+
+#define ZERO_TEST(_b) (_b | 0x00)
+
+/**************************************************************/
+/* QEMU COW block driver with compression and encryption support */
+
+#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
+#define XEN_MAGIC  (('X' << 24) | ('E' << 16) | ('N' << 8) | 0xfb)
+#define QCOW_VERSION 1
+
+#define QCOW_CRYPT_NONE 0
+#define QCOW_CRYPT_AES  1
+
+#define QCOW_OFLAG_COMPRESSED (1LL << 63)
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+typedef struct QCowHeader {
+	uint32_t magic;
+	uint32_t version;
+	uint64_t backing_file_offset;
+	uint32_t backing_file_size;
+	uint32_t mtime;
+	uint64_t size; /* in bytes */
+	uint8_t cluster_bits;
+	uint8_t l2_bits;
+	uint32_t crypt_method;
+	uint64_t l1_table_offset;
+} QCowHeader;
+
+/*Extended header for Xen enhancements*/
+typedef struct QCowHeader_ext {
+        uint32_t xmagic;
+        uint32_t cksum;
+        uint32_t min_cluster_alloc;
+} QCowHeader_ext;
+
+#define L2_CACHE_SIZE 16  /*Fixed allocation in Qemu*/
+
+struct tdqcow_state {
+        int fd;                        /*Main Qcow file descriptor */
+	uint64_t fd_end;               /*Store a local record of file length */
+	int bfd;                       /*Backing file descriptor*/
+	char *name;                    /*Record of the filename*/
+	int poll_pipe[2];              /*dummy fd for polling on */
+	int encrypted;                 /*File contents are encrypted or plain*/
+	int cluster_bits;              /*Determines length of cluster as 
+					*indicated by file hdr*/
+	int cluster_size;              /*Length of cluster*/
+	int cluster_sectors;           /*Number of sectors per cluster*/
+	int cluster_alloc;             /*Blktap fix for allocating full 
+					*extents*/
+	int min_cluster_alloc;         /*Blktap historical extent alloc*/
+	int l2_bits;                   /*Size of L2 table entry*/
+	int l2_size;                   /*Full table size*/
+	int l1_size;                   /*L1 table size*/
+	uint64_t cluster_offset_mask;    
+	uint64_t l1_table_offset;      /*L1 table offset from beginning of 
+					*file*/
+	uint64_t *l1_table;            /*L1 table entries*/
+	uint64_t *l2_cache;            /*We maintain a cache of size 
+					*L2_CACHE_SIZE of most read entries*/
+	uint64_t l2_cache_offsets[L2_CACHE_SIZE];     /*L2 cache entries*/
+	uint32_t l2_cache_counts[L2_CACHE_SIZE];      /*Cache access record*/
+	uint8_t *cluster_cache;          
+	uint8_t *cluster_data;
+	uint8_t *sector_lock;          /*Locking bitmap for AIO reads/writes*/
+	uint64_t cluster_cache_offset; /**/
+	uint32_t crypt_method;         /*current crypt method, 0 if no 
+					*key yet */
+	uint32_t crypt_method_header;  /**/
+	AES_KEY aes_encrypt_key;       /*AES key*/
+	AES_KEY aes_decrypt_key;       /*AES key*/
+        /* libaio state */
+        io_context_t       aio_ctx;
+	int		   nr_reqs [MAX_QCOW_IDS];
+        struct iocb        iocb_list  [MAX_AIO_REQS];
+        struct iocb       *iocb_free  [MAX_AIO_REQS];
+        struct pending_aio pending_aio[MAX_AIO_REQS];
+        int                iocb_free_count;
+        struct iocb       *iocb_queue[MAX_AIO_REQS];
+        int                iocb_queued;
+        int                poll_fd;      /* NB: we require aio_poll support */
+        struct io_event    aio_events[MAX_AIO_REQS];
+};
+
+static int decompress_cluster(struct tdqcow_state *s, uint64_t cluster_offset);
+
+static int init_aio_state(struct td_state *bs)
+{
+        int i;
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+        long     ioidx;
+
+        /*Initialize Locking bitmap*/
+	s->sector_lock = calloc(1, bs->size);
+	
+	if (!s->sector_lock) {
+		DPRINTF("Failed to allocate sector lock\n");
+		goto fail;
+	}
+
+        /* Initialize AIO */
+        s->iocb_free_count = MAX_AIO_REQS;
+        s->iocb_queued     = 0;
+
+        /*Signal kernel to create Poll FD for Asyc completion events*/
+        s->aio_ctx = (io_context_t) REQUEST_ASYNC_FD;   
+        s->poll_fd = io_setup(MAX_AIO_REQS, &s->aio_ctx);
+
+        if (s->poll_fd < 0) {
+                DPRINTF("Retrieving Async poll fd failed\n");
+		goto fail;
+        }
+
+        for (i=0;i<MAX_AIO_REQS;i++)
+                s->iocb_free[i] = &s->iocb_list[i];
+	for (i=0;i<MAX_QCOW_IDS;i++)
+		s->nr_reqs[i] = 0;
+        DPRINTF("AIO state initialised\n");
+
+        return 0;
+
+ fail:
+	return -1;
+}
+
+/*
+ *Test if block is zero. 
+ * Return: 
+ *       1 for TRUE
+ *       0 for FALSE
+ */
+static inline int IS_ZERO(char *buf, int len)
+{
+	int i;
+
+	for (i = 0; i < len; i++) {
+		/*if not zero, return false*/
+		if (ZERO_TEST(*(buf + i))) return 0; 
+	}
+	return 1;
+}
+
+static uint32_t gen_cksum(char *ptr, int len)
+{
+	unsigned char *md;
+	uint32_t ret;
+
+	md = malloc(MD5_DIGEST_LENGTH);
+
+	if(!md) return 0;
+
+	if (MD5((unsigned char *)ptr, len, md) != md) return 0;
+
+	memcpy(&ret, md, sizeof(uint32_t));
+	free(md);
+	return ret;
+}
+
+static int qcow_set_key(struct td_state *bs, const char *key)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+	uint8_t keybuf[16];
+	int len, i;
+	
+	memset(keybuf, 0, 16);
+	len = strlen(key);
+	if (len > 16)
+		len = 16;
+	/* XXX: we could compress the chars to 7 bits to increase
+	   entropy */
+	for (i = 0; i < len; i++) {
+		keybuf[i] = key[i];
+	}
+	s->crypt_method = s->crypt_method_header;
+	
+	if (AES_set_encrypt_key(keybuf, 128, &s->aes_encrypt_key) != 0)
+		return -1;
+	if (AES_set_decrypt_key(keybuf, 128, &s->aes_decrypt_key) != 0)
+		return -1;
+#if 0
+	/* test */
+	{
+		uint8_t in[16];
+		uint8_t out[16];
+		uint8_t tmp[16];
+		for (i=0; i<16; i++)
+			in[i] = i;
+		AES_encrypt(in, tmp, &s->aes_encrypt_key);
+		AES_decrypt(tmp, out, &s->aes_decrypt_key);
+		for (i = 0; i < 16; i++)
+			DPRINTF(" %02x", tmp[i]);
+		DPRINTF("\n");
+		for (i = 0; i < 16; i++)
+			DPRINTF(" %02x", out[i]);
+		DPRINTF("\n");
+	}
+#endif
+	return 0;
+}
+
+static int async_read(struct tdqcow_state *s, int fd, int size, 
+		     uint64_t offset,
+		     char *buf, td_callback_t cb,
+		     int id, uint64_t sector, int qcow_idx, void *private)
+{
+        struct   iocb *io;
+        struct   pending_aio *pio;
+	long     ioidx;
+
+        io = s->iocb_free[--s->iocb_free_count];
+
+        ioidx = IOCB_IDX(s, io);
+        pio = &s->pending_aio[ioidx];
+        pio->cb = cb;
+        pio->id = id;
+        pio->private = private;
+	pio->nb_sectors = size/512;
+	pio->buf = buf;
+	pio->sector = sector;
+	pio->qcow_idx = qcow_idx;
+
+        io_prep_pread(io, fd, buf, size, offset);
+        io->data = (void *)ioidx;
+
+        s->iocb_queue[s->iocb_queued++] = io;
+
+        return 1;
+}
+
+static int async_write(struct tdqcow_state *s, int fd, int size, 
+		     uint64_t offset,
+		     char *buf, td_callback_t cb,
+		      int id, uint64_t sector, int qcow_idx, void *private)
+{
+        struct   iocb *io;
+        struct   pending_aio *pio;
+	long     ioidx;
+
+        io = s->iocb_free[--s->iocb_free_count];
+
+        ioidx = IOCB_IDX(s, io);
+        pio = &s->pending_aio[ioidx];
+        pio->cb = cb;
+        pio->id = id;
+        pio->private = private;
+	pio->nb_sectors = size/512;
+	pio->buf = buf;
+	pio->sector = sector;
+	pio->qcow_idx = qcow_idx;
+
+        io_prep_pwrite(io, fd, buf, size, offset);
+        io->data = (void *)ioidx;
+
+        s->iocb_queue[s->iocb_queued++] = io;
+
+        return 1;
+}
+
+/*TODO: Fix sector span!*/
+static int aio_can_lock(struct tdqcow_state *s, uint64_t sector)
+{
+	return (s->sector_lock[sector] ? 0 : 1);
+}
+
+static int aio_lock(struct tdqcow_state *s, uint64_t sector)
+{
+	return ++s->sector_lock[sector];
+}
+
+static void aio_unlock(struct tdqcow_state *s, uint64_t sector)
+{
+	if (!s->sector_lock[sector]) return;
+
+	--s->sector_lock[sector];
+	return;
+}
+
+/*TODO - Use a freelist*/
+static int get_free_idx(struct tdqcow_state *s)
+{
+	int i;
+	
+	for(i = 0; i < MAX_QCOW_IDS; i++) {
+		if(s->nr_reqs[i] == 0) return i;
+	}
+	return -1;
+}
+
+/* 
+ * The crypt function is compatible with the linux cryptoloop
+ * algorithm for < 4 GB images. NOTE: out_buf == in_buf is
+ * supported .
+ */
+static void encrypt_sectors(struct tdqcow_state *s, int64_t sector_num,
+                            uint8_t *out_buf, const uint8_t *in_buf,
+                            int nb_sectors, int enc,
+                            const AES_KEY *key)
+{
+	union {
+		uint64_t ll[2];
+		uint8_t b[16];
+	} ivec;
+	int i;
+	
+	for (i = 0; i < nb_sectors; i++) {
+		ivec.ll[0] = cpu_to_le64(sector_num);
+		ivec.ll[1] = 0;
+		AES_cbc_encrypt(in_buf, out_buf, 512, key, 
+				ivec.b, enc);
+		sector_num++;
+		in_buf += 512;
+		out_buf += 512;
+	}
+}
+
+
+/* 'allocate' is:
+ *
+ * 0 to not allocate.
+ *
+ * 1 to allocate a normal cluster (for sector indexes 'n_start' to
+ * 'n_end')
+ *
+ * 2 to allocate a compressed cluster of size
+ * 'compressed_size'. 'compressed_size' must be > 0 and <
+ * cluster_size 
+ *
+ * return 0 if not allocated.
+ */
+static uint64_t get_cluster_offset(struct td_state *bs,
+                                   uint64_t offset, int allocate,
+                                   int compressed_size,
+                                   int n_start, int n_end)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+	int min_index, i, j, l1_index, l2_index, l2_sector, l1_sector;
+	char *tmp_ptr, *tmp_ptr2, *l2_ptr, *l1_ptr;
+	uint64_t l2_offset, *l2_table, cluster_offset, tmp;
+	uint32_t min_count;
+	int new_l2_table;
+
+	/*Check L1 table for the extent offset*/
+	l1_index = offset >> (s->l2_bits + s->cluster_bits);
+	l2_offset = s->l1_table[l1_index];
+	new_l2_table = 0;
+	if (!l2_offset) {
+		if (!allocate)
+			return 0;
+		/* 
+		 * allocating a new l2 entry + extent 
+		 * at the end of the file, we must also
+		 * update the L1 entry safely.
+		 */
+		l2_offset = s->fd_end;
+
+		/* round to cluster size */
+		l2_offset = (l2_offset + s->cluster_size - 1) 
+			& ~(s->cluster_size - 1);
+
+		/* update the L1 entry */
+		s->l1_table[l1_index] = l2_offset;
+		tmp = cpu_to_be64(l2_offset);
+		
+		/*Truncate file for L2 table 
+		 *(initialised to zero in case we crash)*/
+		ftruncate(s->fd, l2_offset + (s->l2_size * sizeof(uint64_t)));
+		s->fd_end += (s->l2_size * sizeof(uint64_t));
+
+		/*Update the L1 table entry on disk
+                 * (for O_DIRECT we write 4KByte blocks)*/
+		l1_sector = (l1_index * sizeof(uint64_t)) >> 12;
+		l1_ptr = (char *)s->l1_table + (l1_sector << 12);
+
+		if (posix_memalign((void **)&tmp_ptr, 4096, 4096) != 0) {
+			DPRINTF("ERROR allocating memory for L1 table\n");
+		}
+		memcpy(tmp_ptr, l1_ptr, 4096);
+
+		/*
+		 * Issue non-asynchronous L1 write.
+		 * For safety, we must ensure that
+		 * entry is written before blocks.
+		 */
+		lseek(s->fd, s->l1_table_offset + (l1_sector << 12), SEEK_SET);
+		if (write(s->fd, tmp_ptr, 4096) != 4096)
+			return 0;
+		free(tmp_ptr);
+
+		new_l2_table = 1;
+		goto cache_miss;
+	} else if (s->min_cluster_alloc == s->l2_size) {
+		/*Fast-track the request*/
+		cluster_offset = l2_offset + (s->l2_size * sizeof(uint64_t));
+		l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
+		return cluster_offset + (l2_index * s->cluster_size);
+	}
+
+	/*Check to see if L2 entry is already cached*/
+	for (i = 0; i < L2_CACHE_SIZE; i++) {
+		if (l2_offset == s->l2_cache_offsets[i]) {
+			/* increment the hit count */
+			if (++s->l2_cache_counts[i] == 0xffffffff) {
+				for (j = 0; j < L2_CACHE_SIZE; j++) {
+					s->l2_cache_counts[j] >>= 1;
+				}
+			}
+			l2_table = s->l2_cache + (i << s->l2_bits);
+			goto found;
+		}
+	}
+
+cache_miss:
+	/* not found: load a new entry in the least used one */
+	min_index = 0;
+	min_count = 0xffffffff;
+	for (i = 0; i < L2_CACHE_SIZE; i++) {
+		if (s->l2_cache_counts[i] < min_count) {
+			min_count = s->l2_cache_counts[i];
+			min_index = i;
+		}
+	}
+	l2_table = s->l2_cache + (min_index << s->l2_bits);
+
+	/*If extent pre-allocated, read table from disk, 
+	 *otherwise write new table to disk*/
+	if (new_l2_table) {
+		/*Should we allocate the whole extent? Adjustable parameter.*/
+		if (s->cluster_alloc == s->l2_size) {
+			cluster_offset = l2_offset + 
+				(s->l2_size * sizeof(uint64_t));
+			cluster_offset = (cluster_offset + s->cluster_size - 1)
+				& ~(s->cluster_size - 1);
+			ftruncate(s->fd, cluster_offset + 
+				  (s->cluster_size * s->l2_size));
+			s->fd_end = cluster_offset + 
+				(s->cluster_size * s->l2_size);
+			for (i = 0; i < s->l2_size; i++) {
+				l2_table[i] = cpu_to_be64(cluster_offset + 
+							  (i*s->cluster_size));
+			}  
+		} else memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
+
+		lseek(s->fd, l2_offset, SEEK_SET);
+		if (write(s->fd, l2_table, s->l2_size * sizeof(uint64_t)) !=
+		    s->l2_size * sizeof(uint64_t))
+			return 0;
+	} else {
+		lseek(s->fd, l2_offset, SEEK_SET);
+		if (read(s->fd, l2_table, s->l2_size * sizeof(uint64_t)) != 
+		    s->l2_size * sizeof(uint64_t))
+			return 0;
+	}
+	
+	/*Update the cache entries*/ 
+	s->l2_cache_offsets[min_index] = l2_offset;
+	s->l2_cache_counts[min_index] = 1;
+
+found:
+	/*The extent is split into 's->l2_size' blocks of 
+	 *size 's->cluster_size'*/
+	l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
+	cluster_offset = be64_to_cpu(l2_table[l2_index]);
+
+	if (!cluster_offset || 
+	    ((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1) ) {
+		if (!allocate)
+			return 0;
+		
+		if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&
+		    (n_end - n_start) < s->cluster_sectors) {
+			/* cluster is already allocated but compressed, we must
+			   decompress it in the case it is not completely
+			   overwritten */
+			if (decompress_cluster(s, cluster_offset) < 0)
+				return 0;
+			cluster_offset = lseek(s->fd, 0, SEEK_END);
+			cluster_offset = (cluster_offset + s->cluster_size - 1)
+				& ~(s->cluster_size - 1);
+			/* write the cluster content - not asynchronous */
+			lseek(s->fd, cluster_offset, SEEK_SET);
+			if (write(s->fd, s->cluster_cache, s->cluster_size) != 
+			    s->cluster_size)
+			    return -1;
+		} else {
+			/* allocate a new cluster */
+			cluster_offset = lseek(s->fd, 0, SEEK_END);
+			if (allocate == 1) {
+				/* round to cluster size */
+				cluster_offset = 
+					(cluster_offset + s->cluster_size - 1) 
+					& ~(s->cluster_size - 1);
+				ftruncate(s->fd, cluster_offset + 
+					  s->cluster_size);
+				/* if encrypted, we must initialize the cluster
+				   content which won't be written */
+				if (s->crypt_method && 
+				    (n_end - n_start) < s->cluster_sectors) {
+					uint64_t start_sect;
+					start_sect = (offset & 
+						      ~(s->cluster_size - 1)) 
+							      >> 9;
+					memset(s->cluster_data + 512, 
+					       0xaa, 512);
+					for (i = 0; i < s->cluster_sectors;i++)
+					{
+						if (i < n_start || i >= n_end) 
+						{
+							encrypt_sectors(s, start_sect + i, 
+									s->cluster_data, 
+									s->cluster_data + 512, 1, 1,
+									&s->aes_encrypt_key);
+							lseek(s->fd, cluster_offset + i * 512, SEEK_SET);
+							if (write(s->fd, s->cluster_data, 512) != 512)
+								return -1;
+						}
+					}
+				}
+			} else {
+				cluster_offset |= QCOW_OFLAG_COMPRESSED | 
+					(uint64_t)compressed_size 
+						<< (63 - s->cluster_bits);
+			}
+		}
+		/* update L2 table */
+		tmp = cpu_to_be64(cluster_offset);
+		l2_table[l2_index] = tmp;
+
+		/*For IO_DIRECT we write 4KByte blocks*/
+		l2_sector = (l2_index * sizeof(uint64_t)) >> 12;
+		l2_ptr = (char *)l2_table + (l2_sector << 12);
+		
+		if (posix_memalign((void **)&tmp_ptr2, 4096, 4096) != 0) {
+			DPRINTF("ERROR allocating memory for L1 table\n");
+		}
+		memcpy(tmp_ptr2, l2_ptr, 4096);
+		aio_lock(s, offset >> 9);
+		async_write(s, s->fd, 4096, l2_offset + (l2_sector << 12), 
+			    tmp_ptr2, 0, -2, offset >> 9, 0, NULL);
+	}
+	return cluster_offset;
+}
+
+static void init_cluster_cache(struct td_state *bs)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+	uint32_t count = 0;
+	int i, cluster_entries;
+
+	cluster_entries = s->cluster_size / 512;
+	DPRINTF("Initialising Cluster cache, %d sectors per cluster (%d cluster size)\n",
+		cluster_entries, s->cluster_size);
+
+	for (i = 0; i < bs->size; i += cluster_entries) {
+		if (get_cluster_offset(bs, i << 9, 0, 0, 0, 1)) count++;
+		if (count >= L2_CACHE_SIZE) return;
+	}
+	DPRINTF("Finished cluster initialisation, added %d entries\n", count);
+	return;
+}
+
+static int qcow_is_allocated(struct td_state *bs, int64_t sector_num, 
+                             int nb_sectors, int *pnum)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+
+	int index_in_cluster, n;
+	uint64_t cluster_offset;
+
+	cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
+	index_in_cluster = sector_num & (s->cluster_sectors - 1);
+	n = s->cluster_sectors - index_in_cluster;
+	if (n > nb_sectors)
+		n = nb_sectors;
+	*pnum = n;
+	return (cluster_offset != 0);
+}
+
+static int decompress_buffer(uint8_t *out_buf, int out_buf_size,
+                             const uint8_t *buf, int buf_size)
+{
+	z_stream strm1, *strm = &strm1;
+	int ret, out_len;
+	
+	memset(strm, 0, sizeof(*strm));
+	
+	strm->next_in = (uint8_t *)buf;
+	strm->avail_in = buf_size;
+	strm->next_out = out_buf;
+	strm->avail_out = out_buf_size;
+	
+	ret = inflateInit2(strm, -12);
+	if (ret != Z_OK)
+		return -1;
+	ret = inflate(strm, Z_FINISH);
+	out_len = strm->next_out - out_buf;
+	if ( (ret != Z_STREAM_END && ret != Z_BUF_ERROR) ||
+	    (out_len != out_buf_size) ) {
+		inflateEnd(strm);
+		return -1;
+	}
+	inflateEnd(strm);
+	return 0;
+}
+                              
+static int decompress_cluster(struct tdqcow_state *s, uint64_t cluster_offset)
+{
+	int ret, csize;
+	uint64_t coffset;
+
+	coffset = cluster_offset & s->cluster_offset_mask;
+	if (s->cluster_cache_offset != coffset) {
+		csize = cluster_offset >> (63 - s->cluster_bits);
+		csize &= (s->cluster_size - 1);
+		lseek(s->fd, coffset, SEEK_SET);
+		ret = read(s->fd, s->cluster_data, csize);
+		if (ret != csize) 
+			return -1;
+		if (decompress_buffer(s->cluster_cache, s->cluster_size,
+				      s->cluster_data, csize) < 0) {
+			return -1;
+		}
+		s->cluster_cache_offset = coffset;
+	}
+	return 0;
+}
+
+/* Open the disk file and initialize qcow state. */
+int tdqcow_open (struct td_state *bs, const char *name)
+{
+	int fd, len, i, shift, ret, size, l1_table_size;
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+	char *buf;
+	QCowHeader *header;
+	QCowHeader_ext *exthdr;
+	uint32_t cksum;
+
+ 	DPRINTF("QCOW: Opening %s\n",name);
+	/* set up a pipe so that we can hand back a poll fd that won't fire.*/
+	ret = pipe(s->poll_pipe);
+	if (ret != 0)
+		return (0 - errno);
+
+	fd = open(name, O_RDWR | O_DIRECT | O_LARGEFILE);
+	if (fd < 0) {
+		DPRINTF("Unable to open %s (%d)\n",name,0 - errno);
+		return -1;
+	}
+
+	s->fd = fd;
+	asprintf(&s->name,"%s", name);
+
+	ASSERT(sizeof(header) < 512);
+
+	ret = posix_memalign((void **)&buf, 512, 512);
+	if (ret != 0) goto fail;
+
+	if (read(fd, buf, 512) != 512)
+		goto fail;
+
+	header = (QCowHeader *)buf;
+	be32_to_cpus(&header->magic);
+	be32_to_cpus(&header->version);
+	be64_to_cpus(&header->backing_file_offset);
+	be32_to_cpus(&header->backing_file_size);
+	be32_to_cpus(&header->mtime);
+	be64_to_cpus(&header->size);
+	be32_to_cpus(&header->crypt_method);
+	be64_to_cpus(&header->l1_table_offset);
+   
+	if (header->magic != QCOW_MAGIC || header->version > QCOW_VERSION)
+		goto fail;
+	if (header->size <= 1 || header->cluster_bits < 9)
+		goto fail;
+	if (header->crypt_method > QCOW_CRYPT_AES)
+		goto fail;
+	s->crypt_method_header = header->crypt_method;
+	if (s->crypt_method_header)
+		s->encrypted = 1;
+	s->cluster_bits = header->cluster_bits;
+	s->cluster_size = 1 << s->cluster_bits;
+	s->cluster_sectors = 1 << (s->cluster_bits - 9);
+	s->l2_bits = header->l2_bits;
+	s->l2_size = 1 << s->l2_bits;
+	s->cluster_alloc = s->l2_size;
+	bs->size = header->size / 512;
+	s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1;
+	
+	/* read the level 1 table */
+	shift = s->cluster_bits + s->l2_bits;
+	s->l1_size = (header->size + (1LL << shift) - 1) >> shift;
+	
+	s->l1_table_offset = header->l1_table_offset;
+
+	/*allocate a 4Kbyte multiple of memory*/
+	l1_table_size = s->l1_size * sizeof(uint64_t);
+	if (l1_table_size % 4096 > 0) {
+		l1_table_size = ((l1_table_size >> 12) + 1) << 12;
+	}
+	ret = posix_memalign((void **)&s->l1_table, 4096, l1_table_size);
+	if (ret != 0) goto fail;
+	memset(s->l1_table, 0x00, l1_table_size);
+
+	DPRINTF("L1 Table offset detected: %llu, size %d (%d)\n",
+		(long long)s->l1_table_offset,
+		(int) (s->l1_size * sizeof(uint64_t)), 
+		l1_table_size);
+
+	lseek(fd, s->l1_table_offset, SEEK_SET);
+	if (read(fd, s->l1_table, l1_table_size) != l1_table_size)
+		goto fail;
+/*	for(i = 0;i < s->l1_size; i++) {
+		//be64_to_cpus(&s->l1_table[i]);
+		DPRINTF("L1[%d] => %llu\n", i, s->l1_table[i]);
+		}*/
+
+	/* alloc L2 cache */
+	size = s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t);
+	ret = posix_memalign((void **)&s->l2_cache, 4096, size);
+	if(ret != 0) goto fail;
+
+	size = s->cluster_size;
+	ret = posix_memalign((void **)&s->cluster_cache, 4096, size);
+	if(ret != 0) goto fail;
+
+	ret = posix_memalign((void **)&s->cluster_data, 4096, size);
+	if(ret != 0) goto fail;
+	s->cluster_cache_offset = -1;
+
+	/* read the backing file name */
+	s->bfd = -1;
+	if (header->backing_file_offset != 0) {
+		DPRINTF("Reading backing file data\n");
+		len = header->backing_file_size;
+		if (len > 1023)
+			len = 1023;
+
+                /*TODO - Fix read size for O_DIRECT and use original fd!*/
+		fd = open(name, O_RDONLY | O_LARGEFILE);
+
+		lseek(fd, header->backing_file_offset, SEEK_SET);
+		if (read(fd, bs->backing_file, len) != len)
+			goto fail;
+		bs->backing_file[len] = '\0';
+		close(fd);
+		/***********************************/
+
+		/*Open backing file*/
+		fd = open(bs->backing_file, O_RDONLY | O_DIRECT | O_LARGEFILE);
+		if (fd < 0) {
+			DPRINTF("Unable to open backing file: %s\n",
+				bs->backing_file);
+			goto fail;
+		}
+		s->bfd = fd;
+		s->cluster_alloc = 1; /*Cannot use pre-alloc*/
+	}
+
+        bs->sector_size = 512;
+        bs->info = 0;
+	
+	/*Detect min_cluster_alloc*/
+	s->min_cluster_alloc = 1; /*Default*/
+	if (s->bfd == -1 && (s->l1_table_offset % 4096 == 0) ) {
+		/*We test to see if the xen magic # exists*/
+		exthdr = (QCowHeader_ext *)(buf + sizeof(QCowHeader));
+		be32_to_cpus(&exthdr->xmagic);
+		if(exthdr->xmagic != XEN_MAGIC) 
+			goto end_xenhdr;
+
+		/*Finally check the L1 table cksum*/
+		be32_to_cpus(&exthdr->cksum);
+		cksum = gen_cksum((char *)s->l1_table, s->l1_size * sizeof(uint64_t));
+		if(exthdr->cksum != cksum)
+			goto end_xenhdr;
+			
+		be32_to_cpus(&exthdr->min_cluster_alloc);
+		s->min_cluster_alloc = exthdr->min_cluster_alloc; 
+	}
+
+ end_xenhdr:
+	if (init_aio_state(bs)!=0) {
+		DPRINTF("Unable to initialise AIO state\n");
+		goto fail;
+	}
+	s->fd_end = lseek(s->fd, 0, SEEK_END);
+
+	return 0;
+	
+fail:
+	DPRINTF("QCOW Open failed\n");
+	free(s->l1_table);
+	free(s->l2_cache);
+	free(s->cluster_cache);
+	free(s->cluster_data);
+	close(fd);
+	return -1;
+}
+
+ int tdqcow_queue_read(struct td_state *bs, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *private)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+	int ret = 0, index_in_cluster, n, i, qcow_idx, asubmit = 0;
+	uint64_t cluster_offset;
+
+	/*Check we can get a lock*/
+	for (i = 0; i < nb_sectors; i++)
+		if (!aio_can_lock(s, sector + i)) {
+			DPRINTF("AIO_CAN_LOCK failed [%llu]\n", 
+				(long long) sector + i);
+			return -EBUSY;
+		}
+	
+	/*We store a local record of the request*/
+	qcow_idx = get_free_idx(s);
+	while (nb_sectors > 0) {
+		cluster_offset = 
+			get_cluster_offset(bs, sector << 9, 0, 0, 0, 0);
+		index_in_cluster = sector & (s->cluster_sectors - 1);
+		n = s->cluster_sectors - index_in_cluster;
+		if (n > nb_sectors)
+			n = nb_sectors;
+
+		if (s->iocb_free_count == 0 || !aio_lock(s, sector)) {
+			DPRINTF("AIO_LOCK or iocb_free_count (%d) failed" 
+				"[%llu]\n", s->iocb_free_count, 
+				(long long) sector);
+			return -ENOMEM;
+		}
+		
+		if (!cluster_offset && (s->bfd > 0)) {
+			s->nr_reqs[qcow_idx]++;
+			asubmit += async_read(s, s->bfd, n * 512, sector << 9, 
+					      buf, cb, id, sector, 
+					      qcow_idx, private);
+		} else if(!cluster_offset) {
+			memset(buf, 0, 512 * n);
+			aio_unlock(s, sector);
+		} else if (cluster_offset & QCOW_OFLAG_COMPRESSED) {
+			if (decompress_cluster(s, cluster_offset) < 0) {
+				ret = -1;
+				goto done;
+			}
+			memcpy(buf, s->cluster_cache + index_in_cluster * 512, 
+			       512 * n);
+		} else {			
+			s->nr_reqs[qcow_idx]++;
+			asubmit += async_read(s, s->fd, n * 512, 
+					      (cluster_offset + 
+					       index_in_cluster * 512), 
+					      buf, cb, id, sector, 
+					      qcow_idx, private);
+		}
+		nb_sectors -= n;
+		sector += n;
+		buf += n * 512;
+	}
+done:
+        /*Callback if no async requests outstanding*/
+        if (!asubmit) return cb(bs, ret == -1 ? -1 : 0, id, private);
+
+	return 0;
+}
+
+ int tdqcow_queue_write(struct td_state *bs, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *private)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+	int ret = 0, index_in_cluster, n, i, qcow_idx, asubmit = 0;
+	uint64_t cluster_offset;
+
+	/*Check we can get a lock*/
+	for (i = 0; i < nb_sectors; i++)
+		if (!aio_can_lock(s, sector + i))  {
+			DPRINTF("AIO_CAN_LOCK failed [%llu]\n", 
+				(long long) (sector + i));
+			return -EBUSY;
+		}
+		   
+	/*We store a local record of the request*/
+	qcow_idx = get_free_idx(s);	
+	while (nb_sectors > 0) {
+		index_in_cluster = sector & (s->cluster_sectors - 1);
+		n = s->cluster_sectors - index_in_cluster;
+		if (n > nb_sectors)
+			n = nb_sectors;
+
+		if (s->iocb_free_count == 0 || !aio_lock(s, sector)){
+			DPRINTF("AIO_LOCK or iocb_free_count (%d) failed" 
+				"[%llu]\n", s->iocb_free_count, 
+				(long long) sector);
+			return -ENOMEM;
+		}
+
+		if (!IS_ZERO(buf,n * 512)) {
+
+			cluster_offset = get_cluster_offset(bs, sector << 9, 
+							    1, 0, 
+							    index_in_cluster, 
+							    index_in_cluster+n
+				);
+			if (!cluster_offset) {
+				DPRINTF("Ooops, no write cluster offset!\n");
+				ret = -1;
+				goto done;
+			}
+
+			if (s->crypt_method) {
+				encrypt_sectors(s, sector, s->cluster_data, 
+						(unsigned char *)buf, n, 1,
+						&s->aes_encrypt_key);
+				s->nr_reqs[qcow_idx]++;
+				asubmit += async_write(s, s->fd, n * 512, 
+						       (cluster_offset + 
+							index_in_cluster*512), 
+						       (char *)s->cluster_data,
+						       cb, id, sector, 
+						       qcow_idx, private);
+			} else {
+				s->nr_reqs[qcow_idx]++;
+				asubmit += async_write(s, s->fd, n * 512, 
+						       (cluster_offset + 
+							index_in_cluster*512),
+						       buf, cb, id, sector, 
+						       qcow_idx, private);
+			}
+		} else {
+			/*Write data contains zeros, but we must check to see 
+			  if cluster already allocated*/
+			cluster_offset = get_cluster_offset(bs, sector << 9, 
+							    0, 0, 
+							    index_in_cluster, 
+							    index_in_cluster+n
+				);	
+			if(cluster_offset) {
+				if (s->crypt_method) {
+					encrypt_sectors(s, sector, 
+							s->cluster_data, 
+							(unsigned char *)buf, 
+							n, 1,
+							&s->aes_encrypt_key);
+					s->nr_reqs[qcow_idx]++;
+					asubmit += async_write(s, s->fd, 
+							       n * 512, 
+							       (cluster_offset+
+								index_in_cluster * 512), 
+							       (char *)s->cluster_data, cb, id, sector, 
+							       qcow_idx, private);
+				} else {
+					s->nr_reqs[qcow_idx]++;
+					asubmit += async_write(s, s->fd, n*512,
+							       cluster_offset + index_in_cluster * 512, 
+							       buf, cb, id, sector, 
+							       qcow_idx, private);
+				}
+			}
+			else aio_unlock(s, sector);
+		}
+		nb_sectors -= n;
+		sector += n;
+		buf += n * 512;
+	}
+	s->cluster_cache_offset = -1; /* disable compressed cache */
+
+done:
+	/*Callback if no async requests outstanding*/
+        if (!asubmit) return cb(bs, ret == -1 ? -1 : 0, id, private);
+
+	return 0;
+}
+ 		
+int tdqcow_submit(struct td_state *bs)
+{
+        int ret;
+        struct   tdqcow_state *prv = (struct tdqcow_state *)bs->private;
+
+        ret = io_submit(prv->aio_ctx, prv->iocb_queued, prv->iocb_queue);
+
+        /* XXX: TODO: Handle error conditions here. */
+
+        /* Success case: */
+        prv->iocb_queued = 0;
+
+        return ret;
+}
+
+
+int *tdqcow_get_fd(struct td_state *bs)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+	int *fds, i;
+
+	fds = malloc(sizeof(int) * MAX_IOFD);
+	/*initialise the FD array*/
+	for(i=0;i<MAX_IOFD;i++) fds[i] = 0;
+
+	fds[0] = s->poll_fd;
+	return fds;
+}
+
+int tdqcow_close(struct td_state *bs)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+	uint32_t cksum, out;
+	int fd, offset;
+
+	/*Update the hdr cksum*/
+	if(s->min_cluster_alloc == s->l2_size) {
+		cksum = gen_cksum((char *)s->l1_table, s->l1_size * sizeof(uint64_t));
+		printf("Writing cksum: %d",cksum);
+		fd = open(s->name, O_WRONLY | O_LARGEFILE); /*Open without O_DIRECT*/
+		offset = sizeof(QCowHeader) + sizeof(uint32_t);
+		lseek(fd, offset, SEEK_SET);
+		out = cpu_to_be32(cksum);
+		write(fd, &out, sizeof(uint32_t));
+		close(fd);
+	}
+
+	free(s->name);
+	free(s->l1_table);
+	free(s->l2_cache);
+	free(s->cluster_cache);
+	free(s->cluster_data);
+	close(s->fd);	
+	return 0;
+}
+
+int tdqcow_do_callbacks(struct td_state *s, int sid)
+{
+        int ret, i, rsp = 0,*ptr;
+        struct io_event *ep;
+        struct tdqcow_state *prv = (struct tdqcow_state *)s->private;
+
+        if (sid > MAX_IOFD) return 1;
+	
+	/* Non-blocking test for completed io. */
+        ret = io_getevents(prv->aio_ctx, 0, MAX_AIO_REQS, prv->aio_events,
+                           NULL);
+
+        for (ep=prv->aio_events, i = ret; i-->0; ep++) {
+                struct iocb        *io  = ep->obj;
+                struct pending_aio *pio;
+
+                pio = &prv->pending_aio[(long)io->data];
+
+                if (ep->res != io->u.c.nbytes) {
+                        /* TODO: handle this case better. */
+			ptr = (int *)&ep->res;
+                        DPRINTF("AIO did less than I asked it to "
+				"[%lu,%lu,%d]\n", 
+				ep->res, io->u.c.nbytes, *ptr);
+                }
+		aio_unlock(prv, pio->sector);
+		if (pio->id >= 0) {
+			if (prv->crypt_method)
+				encrypt_sectors(prv, pio->sector, 
+						(unsigned char *)pio->buf, 
+						(unsigned char *)pio->buf, 
+						pio->nb_sectors, 0, 
+						&prv->aes_decrypt_key);
+			prv->nr_reqs[pio->qcow_idx]--;
+			if (prv->nr_reqs[pio->qcow_idx] == 0) 
+				rsp += pio->cb(s, ep->res2, pio->id, 
+					       pio->private);
+		} else if (pio->id == -2) free(pio->buf);
+
+                prv->iocb_free[prv->iocb_free_count++] = io;
+        }
+        return rsp;
+}
+
+int qcow_create(const char *filename, uint64_t total_size,
+                      const char *backing_file, int flags)
+{
+	int fd, header_size, backing_filename_len, l1_size, i;
+	int shift, length, adjust, ret = 0;
+	QCowHeader header;
+	QCowHeader_ext exthdr;
+	char backing_filename[1024], *ptr;
+	uint64_t tmp, size;
+	struct stat st;
+
+	DPRINTF("Qcow_create: size %llu\n",(long long unsigned)total_size);
+
+	fd = open(filename, 
+		  O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 
+		  0644);
+	if (fd < 0)
+		return -1;
+
+	memset(&header, 0, sizeof(header));
+	header.magic = cpu_to_be32(QCOW_MAGIC);
+	header.version = cpu_to_be32(QCOW_VERSION);
+
+	/*Create extended header fields*/
+	exthdr.xmagic = cpu_to_be32(XEN_MAGIC);
+
+	header_size = sizeof(header) + sizeof(QCowHeader_ext);
+	backing_filename_len = 0;
+	size = (total_size >> SECTOR_SHIFT);
+	if (backing_file) {
+		if (strcmp(backing_file, "fat:")) {
+			const char *p;
+			/* XXX: this is a hack: we do not attempt to 
+			 *check for URL like syntax */
+			p = strchr(backing_file, ':');
+			if (p && (p - backing_file) >= 2) {
+				/* URL like but exclude "c:" like filenames */
+				strncpy(backing_filename, backing_file,
+					sizeof(backing_filename));
+			} else {
+				realpath(backing_file, backing_filename);
+				if (stat(backing_filename, &st) != 0) {
+					return -1;
+				}
+			}
+			header.backing_file_offset = cpu_to_be64(header_size);
+			backing_filename_len = strlen(backing_filename);
+			header.backing_file_size = cpu_to_be32(
+				backing_filename_len);
+			header_size += backing_filename_len;
+			
+			/*Set to the backing file size*/
+			size = (st.st_size >> SECTOR_SHIFT);
+			DPRINTF("Backing file size detected: %lld sectors" 
+				"(total %lld [%lld MB])\n", 
+				(long long)total_size, 
+				(long long)(total_size << SECTOR_SHIFT), 
+				(long long)(total_size >> 11));
+		} else {
+			backing_file = NULL;
+			DPRINTF("Setting file size: %lld (total %lld)\n", 
+				(long long) total_size, 
+				(long long) (total_size << SECTOR_SHIFT));
+		}
+		header.mtime = cpu_to_be32(st.st_mtime);
+		header.cluster_bits = 9; /* 512 byte cluster to avoid copying
+					    unmodifyed sectors */
+		header.l2_bits = 12; /* 32 KB L2 tables */
+		exthdr.min_cluster_alloc = cpu_to_be32(1);
+	} else {
+		DPRINTF("Setting file size: %lld sectors" 
+			"(total %lld [%lld MB])\n", 
+			(long long) size, 
+			(long long) (size << SECTOR_SHIFT), 
+			(long long) (size >> 11));
+		header.cluster_bits = 12; /* 4 KB clusters */
+		header.l2_bits = 9; /* 4 KB L2 tables */
+		exthdr.min_cluster_alloc = cpu_to_be32(1 << 9);
+	}
+	/*Set the header size value*/
+	header.size = cpu_to_be64(size * 512);
+	
+	header_size = (header_size + 7) & ~7;
+	if (header_size % 4096 > 0) {
+		header_size = ((header_size >> 12) + 1) << 12;
+	}
+
+	shift = header.cluster_bits + header.l2_bits;
+	l1_size = ((size * 512) + (1LL << shift) - 1) >> shift;
+
+	header.l1_table_offset = cpu_to_be64(header_size);
+	DPRINTF("L1 Table offset: %d, size %d\n",
+		header_size,
+		(int)(l1_size * sizeof(uint64_t)));
+	if (flags) {
+		header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
+	} else {
+		header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
+	}
+
+	ptr = calloc(1, l1_size * sizeof(uint64_t));
+	exthdr.cksum = cpu_to_be32(gen_cksum(ptr, l1_size * sizeof(uint64_t)));
+	printf("Created cksum: %d\n",exthdr.cksum);
+	free(ptr);
+	
+	/* write all the data */
+	ret += write(fd, &header, sizeof(header));
+	ret += write(fd, &exthdr, sizeof(exthdr));
+	if (backing_file) {
+		ret += write(fd, backing_filename, backing_filename_len);
+	}
+	lseek(fd, header_size, SEEK_SET);
+	tmp = 0;
+	for (i = 0;i < l1_size; i++) {
+		ret += write(fd, &tmp, sizeof(tmp));
+	}
+
+	/*adjust file length to 4 KByte boundary*/
+	length = header_size + l1_size * sizeof(uint64_t);
+	if (length % 4096 > 0) {
+		length = ((length >> 12) + 1) << 12;
+		ftruncate(fd, length);
+		DPRINTF("Adjusted filelength to %d for 4 "
+			"Kbyte alignment\n",length);
+	}
+
+	close(fd);
+
+	return 0;
+}
+
+int qcow_make_empty(struct td_state *bs)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+	uint32_t l1_length = s->l1_size * sizeof(uint64_t);
+
+	memset(s->l1_table, 0, l1_length);
+	lseek(s->fd, s->l1_table_offset, SEEK_SET);
+	if (write(s->fd, s->l1_table, l1_length) < 0)
+		return -1;
+	ftruncate(s->fd, s->l1_table_offset + l1_length);
+
+	memset(s->l2_cache, 0, s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
+	memset(s->l2_cache_offsets, 0, L2_CACHE_SIZE * sizeof(uint64_t));
+	memset(s->l2_cache_counts, 0, L2_CACHE_SIZE * sizeof(uint32_t));
+
+	return 0;
+}
+
+int qcow_get_cluster_size(struct td_state *bs)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+
+	return s->cluster_size;
+}
+
+/* XXX: put compressed sectors first, then all the cluster aligned
+   tables to avoid losing bytes in alignment */
+int qcow_compress_cluster(struct td_state *bs, int64_t sector_num, 
+                          const uint8_t *buf)
+{
+	struct tdqcow_state *s = (struct tdqcow_state *)bs->private;
+	z_stream strm;
+	int ret, out_len;
+	uint8_t *out_buf;
+	uint64_t cluster_offset;
+
+	out_buf = malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
+	if (!out_buf)
+		return -1;
+
+	/* best compression, small window, no zlib header */
+	memset(&strm, 0, sizeof(strm));
+	ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION,
+			   Z_DEFLATED, -12, 
+			   9, Z_DEFAULT_STRATEGY);
+	if (ret != 0) {
+		free(out_buf);
+		return -1;
+	}
+
+	strm.avail_in = s->cluster_size;
+	strm.next_in = (uint8_t *)buf;
+	strm.avail_out = s->cluster_size;
+	strm.next_out = out_buf;
+
+	ret = deflate(&strm, Z_FINISH);
+	if (ret != Z_STREAM_END && ret != Z_OK) {
+		free(out_buf);
+		deflateEnd(&strm);
+		return -1;
+	}
+	out_len = strm.next_out - out_buf;
+
+	deflateEnd(&strm);
+
+	if (ret != Z_STREAM_END || out_len >= s->cluster_size) {
+		/* could not compress: write normal cluster */
+		//tdqcow_queue_write(bs, sector_num, buf, s->cluster_sectors);
+	} else {
+		cluster_offset = get_cluster_offset(bs, sector_num << 9, 2, 
+                                            out_len, 0, 0);
+		cluster_offset &= s->cluster_offset_mask;
+		lseek(s->fd, cluster_offset, SEEK_SET);
+		if (write(s->fd, out_buf, out_len) != out_len) {
+			free(out_buf);
+			return -1;
+		}
+	}
+	
+	free(out_buf);
+	return 0;
+}
+
+struct tap_disk tapdisk_qcow = {
+	"tapdisk_qcow",
+	sizeof(struct tdqcow_state),
+	tdqcow_open,
+	tdqcow_queue_read,
+	tdqcow_queue_write,
+	tdqcow_submit,
+	tdqcow_get_fd,
+	tdqcow_close,
+	tdqcow_do_callbacks,
+};
+
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/block-ram.c xen-unstable-tapbuild.hg/tools/blktap/tools/block-ram.c
--- xen-unstable-pristine.hg/tools/blktap/tools/block-ram.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/block-ram.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,296 @@
+/* block-ram.c
+ *
+ * Fast Ramdisk implementation.
+ *
+ * (c) 2006 Andrew Warfield and Julian Chesterfield
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include <string.h>
+#include "tapdisk.h"
+
+#define MAX_DISK_SIZE 1024000 /*500MB disk limit*/
+
+char *img;
+long int   disksector_size;
+long int   disksize;
+long int   diskinfo;
+static int connections = 0;
+
+struct tdram_state {
+        int fd;
+	int poll_pipe[2]; /* dummy fd for polling on */
+};
+
+/*Get Image size, secsize*/
+static int get_image_info(struct td_state *s, int fd)
+{
+	int ret;
+	long size;
+	unsigned long total_size;
+	struct statvfs statBuf;
+	struct stat stat;
+
+	ret = fstat(fd, &stat);
+	if (ret != 0) {
+		DPRINTF("ERROR: fstat failed, Couldn't stat image");
+		return -EINVAL;
+	}
+
+	if (S_ISBLK(stat.st_mode)) {
+		/*Accessing block device directly*/
+		s->size = 0;
+		if (ioctl(fd,BLKGETSIZE,&s->size)!=0) {
+			DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image");
+			return -EINVAL;
+		}
+
+		DPRINTF("Image size: \n\tpre sector_shift  [%llu]\n\tpost "
+			"sector_shift [%llu]\n",
+			(long long unsigned)(s->size << SECTOR_SHIFT),
+			(long long unsigned)s->size);
+
+		/*Get the sector size*/
+#if defined(BLKSSZGET)
+		{
+			int arg;
+			s->sector_size = DEFAULT_SECTOR_SIZE;
+			ioctl(fd, BLKSSZGET, &s->sector_size);
+			
+			if (s->sector_size != DEFAULT_SECTOR_SIZE)
+				DPRINTF("Note: sector size is %ld (not %d)\n",
+					s->sector_size, DEFAULT_SECTOR_SIZE);
+		}
+#else
+		s->sector_size = DEFAULT_SECTOR_SIZE;
+#endif
+
+	} else {
+		/*Local file? try fstat instead*/
+		s->size = (stat.st_size >> SECTOR_SHIFT);
+		s->sector_size = DEFAULT_SECTOR_SIZE;
+		DPRINTF("Image size: \n\tpre sector_shift  [%llu]\n\tpost "
+			"sector_shift [%llu]\n",
+			(long long unsigned)(s->size << SECTOR_SHIFT),
+			(long long unsigned)s->size);
+	}
+
+	if (s->size == 0) {		
+		s->size =((uint64_t) MAX_DISK_SIZE);
+		s->sector_size = DEFAULT_SECTOR_SIZE;
+	}
+	s->info = 0;
+
+        /*Store variables locally*/
+	disksector_size = s->sector_size;
+	disksize        = s->size;
+	diskinfo        = s->info;
+	DPRINTF("Image sector_size: \n\t[%lu]\n",
+		s->sector_size);
+
+	return 0;
+}
+
+/* Open the disk file and initialize ram state. */
+int tdram_open (struct td_state *s, const char *name)
+{
+	int i, fd, ret = 0, count = 0;
+	struct tdram_state *prv = (struct tdram_state *)s->private;
+	uint64_t size;
+	char *p;
+	s->private = prv;
+
+	connections++;
+	
+	/* set up a pipe so that we can hand back a poll fd that won't fire.*/
+	ret = pipe(prv->poll_pipe);
+	if (ret != 0)
+		return (0 - errno);
+
+	if (connections > 1) {
+		s->sector_size = disksector_size;
+		s->size        = disksize;
+		s->info        = diskinfo; 
+		DPRINTF("Image already open, returning parameters:\n");
+		DPRINTF("Image size: \n\tpre sector_shift  [%llu]\n\tpost "
+			"sector_shift [%llu]\n",
+			(long long unsigned)(s->size << SECTOR_SHIFT),
+			(long long unsigned)s->size);
+		DPRINTF("Image sector_size: \n\t[%lu]\n",
+			s->sector_size);
+
+		prv->fd = -1;
+		goto done;
+	}
+
+	/* Open the file */
+        fd = open(name, O_RDWR | O_DIRECT | O_LARGEFILE);
+
+        if ((fd == -1) && (errno == EINVAL)) {
+
+                /* Maybe O_DIRECT isn't supported. */
+                fd = open(name, O_RDWR | O_LARGEFILE);
+                if (fd != -1) DPRINTF("WARNING: Accessing image without"
+                                     "O_DIRECT! (%s)\n", name);
+
+        } else if (fd != -1) DPRINTF("open(%s) with O_DIRECT\n", name);
+	
+        if (fd == -1) {
+		DPRINTF("Unable to open [%s]!\n",name);
+        	ret = 0 - errno;
+        	goto done;
+        }
+
+        prv->fd = fd;
+
+	ret = get_image_info(s, fd);
+	size = MAX_DISK_SIZE;
+
+	if (s->size > size) {
+		DPRINTF("Disk exceeds limit, must be less than [%d]MB",
+			(MAX_DISK_SIZE<<SECTOR_SHIFT)>>20);
+		return -ENOMEM;
+	}
+
+	/*Read the image into memory*/
+	p = img = malloc(s->size << SECTOR_SHIFT);
+	if (img == NULL) {
+		DPRINTF("Mem malloc failed\n");
+		return -1;
+	}
+	DPRINTF("Reading %llu bytes.......",(long long unsigned)s->size << SECTOR_SHIFT);
+
+	for (i = 0; i < s->size; i++) {
+		ret = read(prv->fd, p, s->sector_size);
+		if (ret != s->sector_size) {
+			ret = 0 - errno;
+			break;
+		} else {
+			count += ret;
+			p = img + count;
+		}
+	}
+	DPRINTF("[%d]\n",count);
+	if (count != s->size << SECTOR_SHIFT) {
+		ret = -1;
+	} else {
+		ret = 0;
+	} 
+
+done:
+	return ret;
+}
+
+ int tdram_queue_read(struct td_state *s, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *private)
+{
+	struct tdram_state *prv = (struct tdram_state *)s->private;
+	int      size    = nb_sectors * s->sector_size;
+	uint64_t offset  = sector * (uint64_t)s->sector_size;
+	int ret;
+
+	memcpy(buf, img + offset, size);
+	ret = size;
+
+	cb(s, (ret < 0) ? ret: 0, id, private);
+
+	return ret;
+}
+
+ int tdram_queue_write(struct td_state *s, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *private)
+{
+	struct tdram_state *prv = (struct tdram_state *)s->private;
+	int      size    = nb_sectors * s->sector_size;
+	uint64_t offset  = sector * (uint64_t)s->sector_size;
+	int ret;
+	
+	/*We assume that write access is controlled at a higher level for multiple disks*/
+	memcpy(img + offset, buf, size);
+	ret = size;
+
+	cb(s, (ret < 0) ? ret : 0, id, private);
+
+	return ret;
+}
+ 		
+int tdram_submit(struct td_state *s)
+{
+	return 0;	
+}
+
+
+int *tdram_get_fd(struct td_state *s)
+{
+	struct tdram_state *prv = (struct tdram_state *)s->private;
+        int *fds, i;
+
+        fds = malloc(sizeof(int) * MAX_IOFD);
+        /*initialise the FD array*/
+        for(i=0;i<MAX_IOFD;i++) fds[i] = 0;
+
+        fds[0] = prv->poll_pipe[0];
+        return fds;	
+}
+
+int tdram_close(struct td_state *s)
+{
+	struct tdram_state *prv = (struct tdram_state *)s->private;
+	
+	connections--;
+	
+	return 0;
+}
+
+int tdram_do_callbacks(struct td_state *s, int sid)
+{
+	/* always ask for a kick */
+	return 1;
+}
+
+struct tap_disk tapdisk_ram = {
+	"tapdisk_ram",
+	sizeof(struct tdram_state),
+	tdram_open,
+	tdram_queue_read,
+	tdram_queue_write,
+	tdram_submit,
+	tdram_get_fd,
+	tdram_close,
+	tdram_do_callbacks,
+};
+
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/block-sync.c xen-unstable-tapbuild.hg/tools/blktap/tools/block-sync.c
--- xen-unstable-pristine.hg/tools/blktap/tools/block-sync.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/block-sync.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,242 @@
+/* block-sync.c
+ *
+ * simple slow synchronous raw disk implementation.
+ *
+ * (c) 2006 Andrew Warfield and Julian Chesterfield
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include "tapdisk.h"
+
+struct tdsync_state {
+	int fd;
+	int poll_pipe[2]; /* dummy fd for polling on */
+};
+	
+/*Get Image size, secsize*/
+static int get_image_info(struct td_state *s, int fd)
+{
+	int ret;
+	long size;
+	unsigned long total_size;
+	struct statvfs statBuf;
+	struct stat stat;
+
+	ret = fstat(fd, &stat);
+	if (ret != 0) {
+		DPRINTF("ERROR: fstat failed, Couldn't stat image");
+		return -EINVAL;
+	}
+
+	if (S_ISBLK(stat.st_mode)) {
+		/*Accessing block device directly*/
+		s->size = 0;
+		if (ioctl(fd,BLKGETSIZE,&s->size)!=0) {
+			DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image");
+			return -EINVAL;
+		}
+
+		DPRINTF("Image size: \n\tpre sector_shift  [%llu]\n\tpost "
+			"sector_shift [%llu]\n",
+			(long long unsigned)(s->size << SECTOR_SHIFT),
+			(long long unsigned)s->size);
+
+		/*Get the sector size*/
+#if defined(BLKSSZGET)
+		{
+			int arg;
+			s->sector_size = DEFAULT_SECTOR_SIZE;
+			ioctl(fd, BLKSSZGET, &s->sector_size);
+			
+			if (s->sector_size != DEFAULT_SECTOR_SIZE)
+				DPRINTF("Note: sector size is %ld (not %d)\n",
+					s->sector_size, DEFAULT_SECTOR_SIZE);
+		}
+#else
+		s->sector_size = DEFAULT_SECTOR_SIZE;
+#endif
+
+	} else {
+		/*Local file? try fstat instead*/
+		s->size = (stat.st_size >> SECTOR_SHIFT);
+		s->sector_size = DEFAULT_SECTOR_SIZE;
+		DPRINTF("Image size: \n\tpre sector_shift  [%lluu]\n\tpost "
+			"sector_shift [%lluu]\n",
+			(long long unsigned)(s->size << SECTOR_SHIFT),
+			(long long unsigned)s->size);
+	}
+
+	if (s->size == 0)
+		return -EINVAL;
+
+	s->info = 0;
+
+	return 0;
+}
+
+/* Open the disk file and initialize aio state. */
+int tdsync_open (struct td_state *s, const char *name)
+{
+	int i, fd, ret = 0;
+	struct tdsync_state *prv = (struct tdsync_state *)s->private;
+	s->private = prv;
+	
+	/* set up a pipe so that we can hand back a poll fd that won't fire.*/
+	ret = pipe(prv->poll_pipe);
+	if (ret != 0)
+		return (0 - errno);
+	
+	/* Open the file */
+        fd = open(name, O_RDWR | O_DIRECT | O_LARGEFILE);
+
+        if ( (fd == -1) && (errno == EINVAL) ) {
+
+                /* Maybe O_DIRECT isn't supported. */
+                fd = open(name, O_RDWR | O_LARGEFILE);
+                if (fd != -1) DPRINTF("WARNING: Accessing image without"
+                                     "O_DIRECT! (%s)\n", name);
+
+        } else if (fd != -1) DPRINTF("open(%s) with O_DIRECT\n", name);
+	
+        if (fd == -1) {
+		DPRINTF("Unable to open [%s]!\n",name);
+        	ret = 0 - errno;
+        	goto done;
+        }
+
+        prv->fd = fd;
+
+	ret = get_image_info(s, fd);
+done:
+	return ret;	
+}
+
+ int tdsync_queue_read(struct td_state *s, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *private)
+{
+	struct tdsync_state *prv = (struct tdsync_state *)s->private;
+	int      size    = nb_sectors * s->sector_size;
+	uint64_t offset  = sector * (uint64_t)s->sector_size;
+	int ret;
+	
+	ret = lseek(prv->fd, offset, SEEK_SET);
+	if (ret != (off_t)-1) {
+		ret = read(prv->fd, buf, size);
+		if (ret != size) {
+			ret = 0 - errno;
+		} else {
+			ret = 1;
+		} 
+	} else ret = 0 - errno;
+		
+	cb(s, (ret < 0) ? ret: 0, id, private);
+	
+	return 1;
+}
+
+ int tdsync_queue_write(struct td_state *s, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *private)
+{
+	struct tdsync_state *prv = (struct tdsync_state *)s->private;
+	int      size    = nb_sectors * s->sector_size;
+	uint64_t offset  = sector * (uint64_t)s->sector_size;
+	int ret = 0;
+	
+	ret = lseek(prv->fd, offset, SEEK_SET);
+	if (ret != (off_t)-1) {
+		ret = write(prv->fd, buf, size);
+		if (ret != size) {
+			ret = 0 - errno;
+		} else {
+			ret = 1;
+		}
+	} else ret = 0 - errno;
+		
+	cb(s, (ret < 0) ? ret : 0, id, private);
+	
+	return 1;
+}
+ 		
+int tdsync_submit(struct td_state *s)
+{
+	return 0;	
+}
+
+
+int *tdsync_get_fd(struct td_state *s)
+{
+	struct tdsync_state *prv = (struct tdsync_state *)s->private;
+	
+	int *fds, i;
+
+	fds = malloc(sizeof(int) * MAX_IOFD);
+	/*initialise the FD array*/
+	for(i=0;i<MAX_IOFD;i++) fds[i] = 0;
+
+	fds[0] = prv->poll_pipe[0];
+	return fds;
+}
+
+int tdsync_close(struct td_state *s)
+{
+	struct tdsync_state *prv = (struct tdsync_state *)s->private;
+	
+	close(prv->fd);
+	close(prv->poll_pipe[0]);
+	close(prv->poll_pipe[1]);
+	
+	return 0;
+}
+
+int tdsync_do_callbacks(struct td_state *s, int sid)
+{
+	/* always ask for a kick */
+	return 1;
+}
+
+struct tap_disk tapdisk_sync = {
+	"tapdisk_sync",
+	sizeof(struct tdsync_state),
+	tdsync_open,
+	tdsync_queue_read,
+	tdsync_queue_write,
+	tdsync_submit,
+	tdsync_get_fd,
+	tdsync_close,
+	tdsync_do_callbacks,
+};
+
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/block-vmdk.c xen-unstable-tapbuild.hg/tools/blktap/tools/block-vmdk.c
--- xen-unstable-pristine.hg/tools/blktap/tools/block-vmdk.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/block-vmdk.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,415 @@
+/* block-vmdk.c
+ *
+ * VMware Disk format implementation.
+ *
+ * (c) 2006 Andrew Warfield and Julian Chesterfield
+ *
+ * This is largely the same as the vmdk driver in Qemu, I've just twisted it
+ * to match our interfaces.  The original (BSDish) Copyright message appears 
+ * below:
+ */
+ 
+/*
+ * Block driver for the VMDK format
+ * 
+ * Copyright (c) 2004 Fabrice Bellard
+ * Copyright (c) 2005 Filip Navara
+ * 
+ * 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.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include <string.h>
+#include "tapdisk.h"
+#include "bswap.h"
+
+#define safer_free(_x)       \
+  do {                       \
+  	if (NULL != _x) {    \
+  		free(_x);    \
+  		(_x) = NULL; \
+  	}                    \
+  } while (0) ;
+
+#define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
+#define VMDK4_MAGIC (('K' << 24) | ('D' << 16) | ('M' << 8) | 'V')
+
+typedef struct {
+    uint32_t version;
+    uint32_t flags;
+    uint32_t disk_sectors;
+    uint32_t granularity;
+    uint32_t l1dir_offset;
+    uint32_t l1dir_size;
+    uint32_t file_sectors;
+    uint32_t cylinders;
+    uint32_t heads;
+    uint32_t sectors_per_track;
+} VMDK3Header;
+
+typedef struct {
+    uint32_t version;
+    uint32_t flags;
+    int64_t capacity;
+    int64_t granularity;
+    int64_t desc_offset;
+    int64_t desc_size;
+    int32_t num_gtes_per_gte;
+    int64_t rgd_offset;
+    int64_t gd_offset;
+    int64_t grain_offset;
+    char filler[1];
+    char check_bytes[4];
+} __attribute__((packed)) VMDK4Header;
+
+#define L2_CACHE_SIZE 16
+
+struct tdvmdk_state {
+        int fd;
+	int poll_pipe[2]; /* dummy fd for polling on */
+	
+    	unsigned int l1_size;
+    	int64_t l1_table_offset;
+    	int64_t l1_backup_table_offset;
+    	uint32_t l1_entry_sectors;
+    	unsigned int l2_size;
+	
+    	uint32_t *l1_table;
+    	uint32_t *l1_backup_table;
+    	uint32_t *l2_cache;
+    	uint32_t l2_cache_offsets[L2_CACHE_SIZE];
+    	uint32_t l2_cache_counts[L2_CACHE_SIZE];
+    	
+    	unsigned int cluster_sectors;
+};
+
+
+/* Open the disk file and initialize aio state. */
+static int tdvmdk_open (struct td_state *s, const char *name)
+{
+	int ret, fd;
+    	int l1_size, i;
+    	uint32_t magic;
+	struct tdvmdk_state *prv = (struct tdvmdk_state *)s->private;
+
+	/* set up a pipe so that we can hand back a poll fd that won't fire.*/
+	ret = pipe(prv->poll_pipe);
+	if (ret != 0)
+		return -1;
+	
+	/* Open the file */
+        fd = open(name, O_RDWR | O_LARGEFILE); 
+
+        if ( (fd == -1) && (errno == EINVAL) ) {
+
+                /* Maybe O_DIRECT isn't supported. */
+                fd = open(name, O_RDWR | O_LARGEFILE);
+                if (fd != -1) DPRINTF("WARNING: Accessing image without"
+                                     "O_DIRECT! (%s)\n", name);
+
+        } else if (fd != -1) DPRINTF("open(%s) with O_DIRECT\n", name);
+	
+        if (fd == -1) {
+		DPRINTF("Unable to open [%s]!\n",name);
+        	ret = 0 - errno;
+        	return -1;
+        }
+        
+        prv->fd = fd;
+        
+        /* Grok the vmdk header. */
+    	if ((ret = read(fd, &magic, sizeof(magic))) != sizeof(magic))
+        	goto fail;
+    	magic = be32_to_cpu(magic);
+    	if (magic == VMDK3_MAGIC) {
+        	VMDK3Header header;
+        	if (read(fd, &header, sizeof(header)) != 
+            		sizeof(header)) 
+            		goto fail;
+        	prv->cluster_sectors = le32_to_cpu(header.granularity);
+        	prv->l2_size = 1 << 9;
+        	prv->l1_size = 1 << 6;
+        	s->size = le32_to_cpu(header.disk_sectors);
+        	prv->l1_table_offset = le32_to_cpu(header.l1dir_offset) << 9;
+        	prv->l1_backup_table_offset = 0;
+        	prv->l1_entry_sectors = prv->l2_size * prv->cluster_sectors;
+    	} else if (magic == VMDK4_MAGIC) {
+        	VMDK4Header header;
+        
+        	if (read(fd, &header, sizeof(header)) != sizeof(header))
+            		goto fail;
+        	s->size = le32_to_cpu(header.capacity);
+        	prv->cluster_sectors = le32_to_cpu(header.granularity);
+        	prv->l2_size = le32_to_cpu(header.num_gtes_per_gte);
+        	prv->l1_entry_sectors = prv->l2_size * prv->cluster_sectors;
+        	if (prv->l1_entry_sectors <= 0)
+            		goto fail;
+        	prv->l1_size = (s->size + prv->l1_entry_sectors - 1) 
+            		       / prv->l1_entry_sectors;
+        	prv->l1_table_offset = le64_to_cpu(header.rgd_offset) << 9;
+        	prv->l1_backup_table_offset = 
+        		le64_to_cpu(header.gd_offset) << 9;
+    	} else {
+        	goto fail;
+    	}
+    	/* read the L1 table */
+    	l1_size = prv->l1_size * sizeof(uint32_t);
+    	prv->l1_table = malloc(l1_size);
+    	if (!prv->l1_table)
+        	goto fail;
+    	if (lseek(fd, prv->l1_table_offset, SEEK_SET) == -1)
+        	goto fail;
+    	if (read(fd, prv->l1_table, l1_size) != l1_size)
+        	goto fail;
+    	for (i = 0; i < prv->l1_size; i++) {
+        	le32_to_cpus(&prv->l1_table[i]);
+    	}
+
+    	if (prv->l1_backup_table_offset) {
+        	prv->l1_backup_table = malloc(l1_size);
+        	if (!prv->l1_backup_table)
+            		goto fail;
+        	if (lseek(fd, prv->l1_backup_table_offset, SEEK_SET) == -1)
+            		goto fail;
+        	if (read(fd, prv->l1_backup_table, l1_size) != l1_size)
+            		goto fail;
+        	for(i = 0; i < prv->l1_size; i++) {
+            		le32_to_cpus(&prv->l1_backup_table[i]);
+        	}
+    	}
+
+    	prv->l2_cache = malloc(prv->l2_size * L2_CACHE_SIZE *sizeof(uint32_t));
+    	if (!prv->l2_cache)
+        	goto fail;
+    	prv->fd = fd;
+	DPRINTF("VMDK File opened successfully\n");
+    	return 0;
+	
+fail:
+	DPRINTF("VMDK File open failed.\n"); 
+   	safer_free(prv->l1_backup_table);
+    	free(prv->l1_table);
+    	free(prv->l2_cache);
+    	close(fd);
+	return -1;
+}
+
+static uint64_t get_cluster_offset(struct td_state *s, 
+                                   uint64_t offset, int allocate)
+{
+	struct tdvmdk_state *prv = (struct tdvmdk_state *)s->private;
+    	unsigned int l1_index, l2_offset, l2_index;
+    	int min_index, i, j;
+    	uint32_t min_count, *l2_table, tmp;
+    	uint64_t cluster_offset;
+    
+    	l1_index = (offset >> 9) / prv->l1_entry_sectors;
+    	if (l1_index >= prv->l1_size)
+        	return 0;
+    	l2_offset = prv->l1_table[l1_index];
+    	if (!l2_offset)
+        	return 0;
+    	for (i = 0; i < L2_CACHE_SIZE; i++) {
+        	if (l2_offset == prv->l2_cache_offsets[i]) {
+            		/* increment the hit count */
+            		if (++prv->l2_cache_counts[i] == 0xffffffff) {
+	                	for(j = 0; j < L2_CACHE_SIZE; j++) {
+	                    		prv->l2_cache_counts[j] >>= 1;
+	                	}
+            		}
+            		l2_table = prv->l2_cache + (i * prv->l2_size);
+            		goto found;
+        	}
+    	}
+    	/* not found: load a new entry in the least used one */
+    	min_index = 0;
+    	min_count = 0xffffffff;
+    	for (i = 0; i < L2_CACHE_SIZE; i++) {
+        	if (prv->l2_cache_counts[i] < min_count) {
+            		min_count = prv->l2_cache_counts[i];
+            		min_index = i;
+        	}
+    	}
+    	l2_table = prv->l2_cache + (min_index * prv->l2_size);
+    	lseek(prv->fd, (int64_t)l2_offset * 512, SEEK_SET);
+    	if (read(prv->fd, l2_table, prv->l2_size * sizeof(uint32_t)) != 
+        	 prv->l2_size * sizeof(uint32_t))
+        	return 0;
+    	prv->l2_cache_offsets[min_index] = l2_offset;
+    	prv->l2_cache_counts[min_index] = 1;
+ found:
+    	l2_index = ((offset >> 9) / prv->cluster_sectors) % prv->l2_size;
+    	cluster_offset = le32_to_cpu(l2_table[l2_index]);
+    	if (!cluster_offset) {
+        	if (!allocate)
+            		return 0;
+        	cluster_offset = lseek(prv->fd, 0, SEEK_END);
+        	ftruncate(prv->fd, cluster_offset + 
+			  (prv->cluster_sectors << 9));
+        	cluster_offset >>= 9;
+        	/* update L2 table */
+        	tmp = cpu_to_le32(cluster_offset);
+        	l2_table[l2_index] = tmp;
+        	lseek(prv->fd, ((int64_t)l2_offset * 512) + 
+        	      (l2_index * sizeof(tmp)), SEEK_SET);
+        	if (write(prv->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
+            		return 0;
+        	/* update backup L2 table */
+        	if (prv->l1_backup_table_offset != 0) {
+            		l2_offset = prv->l1_backup_table[l1_index];
+            	lseek(prv->fd, ((int64_t)l2_offset * 512) + 
+            		(l2_index * sizeof(tmp)), SEEK_SET);
+            	if (write(prv->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
+                	return 0;
+        	}
+    	}
+    	cluster_offset <<= 9;
+    	return cluster_offset;
+}
+
+static int tdvmdk_queue_read(struct td_state *s, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *private)
+{
+	struct tdvmdk_state *prv = (struct tdvmdk_state *)s->private;
+    	int index_in_cluster, n;
+    	uint64_t cluster_offset;
+    	int ret = 0;
+    	while (nb_sectors > 0) {
+        	cluster_offset = get_cluster_offset(s, sector << 9, 0);
+        	index_in_cluster = sector % prv->cluster_sectors;
+        	n = prv->cluster_sectors - index_in_cluster;
+        	if (n > nb_sectors)
+            		n = nb_sectors;
+        	if (!cluster_offset) {
+            		memset(buf, 0, 512 * n);
+        	} else {
+            		lseek(prv->fd, cluster_offset + index_in_cluster * 512,
+            	      	      SEEK_SET);
+            		ret = read(prv->fd, buf, n * 512);
+            		if (ret != n * 512) {
+                		ret = -1;
+                		goto done;
+            		}
+        	}
+        	nb_sectors -= n;
+        	sector     += n;
+        	buf += n * 512;
+    	}
+done:
+	cb(s, ret == -1 ? -1 : 0, id, private);
+	
+	return 1;
+}
+
+static  int tdvmdk_queue_write(struct td_state *s, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *private)
+{
+	struct tdvmdk_state *prv = (struct tdvmdk_state *)s->private;
+    	int index_in_cluster, n;
+    	uint64_t cluster_offset;
+    	int ret = 0;
+    	
+
+    	while (nb_sectors > 0) {
+        	index_in_cluster = sector & (prv->cluster_sectors - 1);
+        	n = prv->cluster_sectors - index_in_cluster;
+        	if (n > nb_sectors)
+            		n = nb_sectors;
+        	cluster_offset = get_cluster_offset(s, sector << 9, 1);
+        	if (!cluster_offset) {
+            		ret = -1;
+            		goto done;
+        	}
+        	lseek(prv->fd, cluster_offset + index_in_cluster * 512, 
+        	      SEEK_SET);
+        	ret = write(prv->fd, buf, n * 512);
+        	if (ret != n * 512) {
+            		ret = -1;
+            		goto done;
+        	}
+        	nb_sectors -= n;
+        	sector     += n;
+        	buf += n * 512;
+    	}
+done:
+	cb(s, ret == -1 ? -1 : 0, id, private);
+	
+	return 1;
+}
+ 		
+static int tdvmdk_submit(struct td_state *s)
+{
+	return 0;	
+}
+
+
+static int *tdvmdk_get_fd(struct td_state *s)
+{
+	struct tdvmdk_state *prv = (struct tdvmdk_state *)s->private;
+        int *fds, i;
+
+        fds = malloc(sizeof(int) * MAX_IOFD);
+        /*initialise the FD array*/
+        for (i=0;i<MAX_IOFD;i++) fds[i] = 0;
+
+        fds[0] = prv->poll_pipe[0];
+        return fds;
+}
+
+static int tdvmdk_close(struct td_state *s)
+{
+	struct tdvmdk_state *prv = (struct tdvmdk_state *)s->private;
+	
+    	safer_free(prv->l1_table);
+    	safer_free(prv->l1_backup_table);
+    	safer_free(prv->l2_cache);
+    	close(prv->fd);
+	close(prv->poll_pipe[0]);
+	close(prv->poll_pipe[1]);
+	return 0;
+}
+
+static int tdvmdk_do_callbacks(struct td_state *s, int sid)
+{
+	/* always ask for a kick */
+	return 1;
+}
+
+struct tap_disk tapdisk_vmdk = {
+	"tapdisk_vmdk",
+	sizeof(struct tdvmdk_state),
+	tdvmdk_open,
+	tdvmdk_queue_read,
+	tdvmdk_queue_write,
+	tdvmdk_submit,
+	tdvmdk_get_fd,
+	tdvmdk_close,
+	tdvmdk_do_callbacks,
+};
+
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/bswap.h xen-unstable-tapbuild.hg/tools/blktap/tools/bswap.h
--- xen-unstable-pristine.hg/tools/blktap/tools/bswap.h	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/bswap.h	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,202 @@
+#ifndef BSWAP_H
+#define BSWAP_H
+
+//#include "config-host.h"
+
+#include <inttypes.h>
+
+#ifdef HAVE_BYTESWAP_H
+#include <byteswap.h>
+#else
+
+#define bswap_16(x) \
+({ \
+	uint16_t __x = (x); \
+	((uint16_t)( \
+		(((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
+		(((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
+})
+
+#define bswap_32(x) \
+({ \
+	uint32_t __x = (x); \
+	((uint32_t)( \
+		(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
+		(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) <<  8) | \
+		(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >>  8) | \
+		(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
+})
+
+#define bswap_64(x) \
+({ \
+	uint64_t __x = (x); \
+	((uint64_t)( \
+		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
+		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
+		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
+		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) <<  8) | \
+	        (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >>  8) | \
+		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
+		(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
+		(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
+})
+
+#endif /* !HAVE_BYTESWAP_H */
+
+static inline uint16_t bswap16(uint16_t x)
+{
+    return bswap_16(x);
+}
+
+static inline uint32_t bswap32(uint32_t x) 
+{
+    return bswap_32(x);
+}
+
+static inline uint64_t bswap64(uint64_t x) 
+{
+    return bswap_64(x);
+}
+
+static inline void bswap16s(uint16_t *s)
+{
+    *s = bswap16(*s);
+}
+
+static inline void bswap32s(uint32_t *s)
+{
+    *s = bswap32(*s);
+}
+
+static inline void bswap64s(uint64_t *s)
+{
+    *s = bswap64(*s);
+}
+
+#if defined(WORDS_BIGENDIAN)
+#define be_bswap(v, size) (v)
+#define le_bswap(v, size) bswap ## size(v)
+#define be_bswaps(v, size)
+#define le_bswaps(p, size) *p = bswap ## size(*p);
+#else
+#define le_bswap(v, size) (v)
+#define be_bswap(v, size) bswap ## size(v)
+#define le_bswaps(v, size)
+#define be_bswaps(p, size) *p = bswap ## size(*p);
+#endif
+
+#define CPU_CONVERT(endian, size, type)\
+static inline type endian ## size ## _to_cpu(type v)\
+{\
+    return endian ## _bswap(v, size);\
+}\
+\
+static inline type cpu_to_ ## endian ## size(type v)\
+{\
+    return endian ## _bswap(v, size);\
+}\
+\
+static inline void endian ## size ## _to_cpus(type *p)\
+{\
+    endian ## _bswaps(p, size)\
+}\
+\
+static inline void cpu_to_ ## endian ## size ## s(type *p)\
+{\
+    endian ## _bswaps(p, size)\
+}\
+\
+static inline type endian ## size ## _to_cpup(const type *p)\
+{\
+    return endian ## size ## _to_cpu(*p);\
+}\
+\
+static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\
+{\
+     *p = cpu_to_ ## endian ## size(v);\
+}
+
+CPU_CONVERT(be, 16, uint16_t)
+CPU_CONVERT(be, 32, uint32_t)
+CPU_CONVERT(be, 64, uint64_t)
+
+CPU_CONVERT(le, 16, uint16_t)
+CPU_CONVERT(le, 32, uint32_t)
+CPU_CONVERT(le, 64, uint64_t)
+
+/* unaligned versions (optimized for frequent unaligned accesses)*/
+
+#if defined(__i386__) || defined(__powerpc__)
+
+#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v)
+#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v)
+#define le16_to_cpupu(p) le16_to_cpup(p)
+#define le32_to_cpupu(p) le32_to_cpup(p)
+
+#define cpu_to_be16wu(p, v) cpu_to_be16w(p, v)
+#define cpu_to_be32wu(p, v) cpu_to_be32w(p, v)
+
+#else
+
+static inline void cpu_to_le16wu(uint16_t *p, uint16_t v)
+{
+    uint8_t *p1 = (uint8_t *)p;
+
+    p1[0] = v;
+    p1[1] = v >> 8;
+}
+
+static inline void cpu_to_le32wu(uint32_t *p, uint32_t v)
+{
+    uint8_t *p1 = (uint8_t *)p;
+
+    p1[0] = v;
+    p1[1] = v >> 8;
+    p1[2] = v >> 16;
+    p1[3] = v >> 24;
+}
+
+static inline uint16_t le16_to_cpupu(const uint16_t *p)
+{
+    const uint8_t *p1 = (const uint8_t *)p;
+    return p1[0] | (p1[1] << 8);
+}
+
+static inline uint32_t le32_to_cpupu(const uint32_t *p)
+{
+    const uint8_t *p1 = (const uint8_t *)p;
+    return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24);
+}
+
+static inline void cpu_to_be16wu(uint16_t *p, uint16_t v)
+{
+    uint8_t *p1 = (uint8_t *)p;
+
+    p1[0] = v >> 8;
+    p1[1] = v;
+}
+
+static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
+{
+    uint8_t *p1 = (uint8_t *)p;
+
+    p1[0] = v >> 24;
+    p1[1] = v >> 16;
+    p1[2] = v >> 8;
+    p1[3] = v;
+}
+
+#endif
+
+#ifdef WORDS_BIGENDIAN
+#define cpu_to_32wu cpu_to_be32wu
+#else
+#define cpu_to_32wu cpu_to_le32wu
+#endif
+
+#undef le_bswap
+#undef be_bswap
+#undef le_bswaps
+#undef be_bswaps
+
+#endif /* BSWAP_H */
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/img2qcow.c xen-unstable-tapbuild.hg/tools/blktap/tools/img2qcow.c
--- xen-unstable-pristine.hg/tools/blktap/tools/img2qcow.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/img2qcow.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,289 @@
+/* img2qcow.c
+ *
+ * Generates a qcow format disk and fills it from an existing image.
+ *
+ * (c) 2006 Julian Chesterfield and Andrew Warfield
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include <string.h>
+#include "tapdisk.h"
+
+#if 1
+#define DFPRINTF(_f, _a...) fprintf ( stderr, _f , ## _a )
+#else
+#define DFPRINTF(_f, _a...) ((void)0)
+#endif
+
+#define TAPDISK 1
+#define BLOCK_PROCESSSZ 4096
+
+static int maxfds, *io_fd, running = 1, complete = 0;
+static int returned_events = 0, submit_events = 0;
+static uint64_t prev = 0;
+static char output[25];
+
+void print_bytes(void *ptr, int length) {
+
+  int i,k;
+  unsigned char *p = ptr;
+
+    DFPRINTF("Buf dump, length %d:\n",length);
+    for (k = 0; k < length; k++) {
+        DFPRINTF("%x",*p);
+        *p++;
+	if(k % 16 == 0) DFPRINTF("\n");
+        else if(k % 2 == 0) DFPRINTF(" ");	
+    }
+    DFPRINTF("\n");
+    return;
+}
+
+void debug_output(uint64_t progress, uint64_t size)
+{
+	uint64_t blocks = size/20;
+
+	/*Output progress every 5% */	
+	if (progress/blocks > prev) {
+		memcpy(output+prev+1,"=>",2);
+		prev++;
+		DFPRINTF("\r%s     %llu%%", output, 
+			(long long)(prev-1)*5);
+	}
+	return;
+}
+
+static inline void LOCAL_FD_SET(fd_set *readfds) 
+{
+	FD_SET(io_fd[0], readfds);
+	maxfds = io_fd[0] + 1;
+	
+	return;
+}
+
+static int get_image_info(struct td_state *s, int fd)
+{
+	int ret;
+	long size;
+	unsigned long total_size;
+	struct statvfs statBuf;
+	struct stat stat;
+
+	ret = fstat(fd, &stat);
+	if (ret != 0) {
+		DFPRINTF("ERROR: fstat failed, Couldn't stat image");
+		return -EINVAL;
+	}
+
+	if (S_ISBLK(stat.st_mode)) {
+		/*Accessing block device directly*/
+		s->size = 0;
+		if (ioctl(fd,BLKGETSIZE,&s->size)!=0) {
+			DFPRINTF("ERR: BLKGETSIZE failed, "
+				 "couldn't stat image");
+			return -EINVAL;
+		}
+
+		DFPRINTF("Image size: \n\tpre sector_shift  [%llu]\n\tpost "
+			"sector_shift [%llu]\n",
+			(long long unsigned)(s->size << SECTOR_SHIFT),
+			(long long unsigned)s->size);
+
+		/*Get the sector size*/
+#if defined(BLKSSZGET)
+		{
+			int arg;
+			s->sector_size = DEFAULT_SECTOR_SIZE;
+			ioctl(fd, BLKSSZGET, &s->sector_size);
+			
+			if (s->sector_size != DEFAULT_SECTOR_SIZE)
+				DFPRINTF("Note: sector size is %ld (not %d)\n",
+					s->sector_size, DEFAULT_SECTOR_SIZE);
+		}
+#else
+		s->sector_size = DEFAULT_SECTOR_SIZE;
+#endif
+
+	} else {
+		/*Local file? try fstat instead*/
+		s->size = (stat.st_size >> SECTOR_SHIFT);
+		s->sector_size = DEFAULT_SECTOR_SIZE;
+		DFPRINTF("Image size: [%llu]\n",
+			(long long unsigned)s->size);
+	}
+
+	return 0;
+}
+
+static int send_responses(struct td_state *s, int res, int idx, void *private)
+{
+	if (res < 0) DFPRINTF("AIO FAILURE: res [%d]!\n",res);
+	
+	returned_events++;
+	
+	free(private);
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	struct tap_disk *drv;
+	struct td_state *s;
+	int ret = -1, fd, len;
+	fd_set readfds;
+	struct timeval timeout;
+	uint64_t i;
+	char *buf;
+
+	if (argc != 3) {
+		fprintf(stderr, "Qcow-utils: v1.0.0\n");
+		fprintf(stderr, "usage: %s <QCOW FILENAME> <SRC IMAGE>\n", 
+			argv[0]);
+		exit(-1);
+	}
+
+	s = malloc(sizeof(struct td_state));
+	
+	/*Open image*/
+	fd = open(argv[2], O_RDONLY | O_LARGEFILE);
+	
+        if (fd == -1) {
+                DFPRINTF("Unable to open [%s], (err %d)!\n",argv[2],0 - errno);
+                exit(-1);
+        }
+	
+	get_image_info(s, fd);
+	
+	/*Create qcow file*/
+	ret = qcow_create(argv[1],s->size<<SECTOR_SHIFT,NULL,0);
+	
+	if (ret < 0) {
+		DFPRINTF("Unable to create QCOW file\n");
+		exit(-1);
+	} else DFPRINTF("Qcow file created: size %llu sectors\n",
+			(long long unsigned)s->size);
+	
+	drv = &tapdisk_qcow;
+	s->private = malloc(drv->private_data_size);
+
+        /*Open qcow file*/
+        if (drv->td_open(s, argv[1])!=0) {
+		DFPRINTF("Unable to open Qcow file [%s]\n",argv[1]);
+		exit(-1);
+	}
+
+	io_fd = drv->td_get_fd(s);
+
+	/*Initialise the output string*/
+	memset(output,0x20,25);
+	output[0] = '[';
+	output[22] = ']';
+	output[23] = '\0';
+	DFPRINTF("%s",output);
+
+	i = 0;
+	while (running) {
+		timeout.tv_sec = 0;
+		
+		if (!complete) {
+			/*Read sector from image*/
+			if (lseek(fd, i, SEEK_SET) == (off_t)-1) {
+				DFPRINTF("Unable to access file offset %llu\n",
+				       (long long)i);
+				exit(-1);
+			}
+			
+			if( (ret = posix_memalign((void **)&buf, 
+						  BLOCK_PROCESSSZ, 
+						  BLOCK_PROCESSSZ)) != 0) {
+				DFPRINTF("Unable to read memalign buf (%d)\n",ret);
+				exit(-1);				
+			}
+		
+			/*We attempt to read 4k sized blocks*/
+			len = read(fd, buf, BLOCK_PROCESSSZ);
+			if (len < 512) {
+				DFPRINTF("Unable to read sector %llu\n",
+				       (long long unsigned) (i >> 9));
+				complete = 1;
+				continue;
+			}
+			
+			if (len % 512) {
+				len = (len >> 9) << 9;
+			}
+
+			ret = drv->td_queue_write(s, i >> 9,
+						  len >> 9, buf, 
+						  send_responses, 0, buf);
+				
+			if (!ret) submit_events++;
+				
+			if (ret < 0) {
+				DFPRINTF("UNABLE TO WRITE block [%llu]\n",
+				       (long long unsigned) (i >> 9));
+			} else i += len;
+			
+			if (i >> 9 == s->size) complete = 1;
+
+			debug_output(i,s->size << 9);
+			
+			if ((submit_events % 10 == 0) || complete) 
+				drv->td_submit(s);
+			timeout.tv_usec = 0;
+			
+		} else {
+			timeout.tv_usec = 1000;
+			if (!submit_events) running = 0;
+		}
+		
+
+		/*Check AIO FD*/
+		LOCAL_FD_SET(&readfds);
+                ret = select(maxfds + 1, &readfds, (fd_set *) 0,
+                             (fd_set *) 0, &timeout);
+			     
+		if (ret > 0) drv->td_do_callbacks(s, 0);
+		if (complete && (returned_events == submit_events)) 
+			running = 0;
+	}
+	memcpy(output+prev+1,"=",1);
+	DFPRINTF("\r%s     100%%\nTRANSFER COMPLETE\n\n", output);
+        drv->td_close(s);
+        free(s->private);
+        free(s);
+		
+	return 0;
+}
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/Makefile xen-unstable-tapbuild.hg/tools/blktap/tools/Makefile
--- xen-unstable-pristine.hg/tools/blktap/tools/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/Makefile	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,67 @@
+XEN_ROOT = ../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+INCLUDES += -I..
+
+INSTALL      = install
+INSTALL_PROG = $(INSTALL) -m0755
+IBIN         = blktapctrl tapdisk
+QCOW_UTIL    = img2qcow qcow2raw qcow-create
+INSTALL_DIR  = /usr/sbin
+
+CFLAGS   += -fPIC
+CFLAGS   += -Wall
+CFLAGS   += -Werror
+CFLAGS   += -Wno-unused
+CFLAGS   += -g3
+CFLAGS   += -fno-strict-aliasing
+CFLAGS   += -I $(XEN_LIBXC)
+CFLAGS   += $(INCLUDES) -I. -I../../xenstore 
+CFLAGS   += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
+CFLAGS   += -D_GNU_SOURCE
+
+# Get gcc to generate the dependencies for us.
+CFLAGS   += -Wp,-MD,.$(@F).d
+DEPS     = .*.d
+
+THREADLIB := -lpthread -lz
+LIBS      := -L. -L..
+LIBS      += -lcrypto
+LIBS      += -laio
+LIBS      += -lz
+
+BLK-OBJS  := block-aio.o 
+BLK-OBJS  += block-sync.o 
+BLK-OBJS  += block-vmdk.o
+BLK-OBJS  += block-ram.o 
+BLK-OBJS  += block-qcow.o
+BLK-OBJS  += aes.o
+
+all: $(IBIN) qcow-util
+
+LINUX_ROOT := $(wildcard $(XEN_ROOT)/linux-2.6.*-xen-sparse)
+
+
+blktapctrl: 
+	$(CC) $(CFLAGS) -o blktapctrl -L$(XEN_LIBXC) -L. -L..  \
+	      -L$(XEN_XENSTORE) -l xenstore -lblktap blktapctrl.c
+
+tapdisk: $(BLK-OBJS)
+	$(CC) $(CFLAGS) -o tapdisk -L$(XEN_LIBXC)                       \
+	-L$(XEN_XENSTORE) -lxenstore -lblktap $(BLK-OBJS) tapdisk.c $(LIBS)
+
+
+qcow-util: $(BLK-OBJS)
+	$(CC) $(CFLAGS) -o img2qcow $(BLK-OBJS) img2qcow.c $(LIBS)
+	$(CC) $(CFLAGS) -o qcow2raw $(BLK-OBJS) qcow2raw.c $(LIBS)
+	$(CC) $(CFLAGS) -o qcow-create $(BLK-OBJS) qcow-create.c $(LIBS)
+
+install:
+	$(INSTALL_PROG) $(IBIN) $(QCOW_UTIL) $(DESTDIR)$(INSTALL_DIR)
+
+clean:
+	rm -rf *.o *~ $(DEPS) xen TAGS $(IBIN) $(LIB) $(QCOW_UTIL)
+
+.PHONY: clean install
+
+-include $(DEPS)
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/qcow2raw.c xen-unstable-tapbuild.hg/tools/blktap/tools/qcow2raw.c
--- xen-unstable-pristine.hg/tools/blktap/tools/qcow2raw.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/qcow2raw.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,346 @@
+/* qcow2raw.c
+ *
+ * Generates raw image data from an existing qcow image
+ *
+ * (c) 2006 Julian Chesterfield and Andrew Warfield
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include <string.h>
+#include "tapdisk.h"
+
+#if 1
+#define DFPRINTF(_f, _a...) fprintf ( stderr, _f , ## _a )
+#else
+#define DFPRINTF(_f, _a...) ((void)0)
+#endif
+
+#define TAPDISK 1
+#define BLOCK_PROCESSSZ 4096
+
+static int maxfds, *qcowio_fd, *aio_fd, running = 1, complete = 0; 
+static int read_complete = 0, write_complete = 0;
+static int returned_read_events = 0, returned_write_events = 0;
+static int submit_events = 0;
+static uint32_t read_idx = 0, write_idx = 0;
+struct tap_disk *drv1, *drv2;
+struct td_state *sqcow, *saio;
+static uint64_t prev = 0, written = 0;
+static char output[25];
+
+void print_bytes(void *ptr, int length) {
+
+  int i,k;
+  unsigned char *p = ptr;
+
+    DFPRINTF("Buf dump, length %d:\n",length);
+    for (k = 0; k < length; k++) {
+        DFPRINTF("%x",*p);
+        *p++;
+	if (k % 16 == 0) DFPRINTF("\n");
+        else if (k % 2 == 0) DFPRINTF(" ");	
+    }
+    DFPRINTF("\n");
+    return;
+}
+
+void debug_output(uint64_t progress, uint64_t size)
+{
+	/*Output progress every 5% */	
+	uint64_t blocks = size/20;
+
+	if (progress/blocks > prev) {
+		memcpy(output+prev+1,"=>",2);
+		prev++;
+		DFPRINTF("\r%s     %llu%%", 
+			output, (long long)((prev-1)*5));
+	}
+	return;
+}
+
+static inline void LOCAL_FD_SET(fd_set *readfds) 
+{
+	FD_SET(qcowio_fd[0], readfds);
+	FD_SET(aio_fd[0], readfds);
+	
+	maxfds = (qcowio_fd[0] > aio_fd[0] ? qcowio_fd[0] : aio_fd[0]) + 1;
+	
+	return;
+}
+
+static int send_write_responses(struct td_state *s, int res, int idx, void *private)
+{
+	if (res < 0) {
+		DFPRINTF("AIO FAILURE: res [%d]!\n",res);
+		return 0;
+	}
+	written += BLOCK_PROCESSSZ;
+	returned_write_events++;
+	write_idx = idx;
+	if (complete && (returned_write_events == submit_events)) 
+		write_complete = 1;
+
+	debug_output(written, s->size << 9);
+	free(private);
+	return 0;
+}
+
+static int send_read_responses(struct td_state *s, int res, int idx, void *private)
+{
+	int ret;
+
+	if (res < 0) DFPRINTF("AIO FAILURE: res [%d]!\n",res);
+	
+	returned_read_events++;
+	read_idx = idx;
+	if (complete && (returned_read_events == submit_events)) 
+		read_complete = 1;
+	
+	ret = drv2->td_queue_write(saio, idx, BLOCK_PROCESSSZ>>9, private, 
+				   send_write_responses, idx, private);
+	if (ret != 0) {
+		DFPRINTF("ERROR in submitting queue write!\n");
+		return 0;
+	}
+
+	if ( (complete && returned_read_events == submit_events) || 
+	     (returned_read_events % 10 == 0) ) {
+		drv2->td_submit(saio);
+	}
+
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	int ret = -1, fd, len,input;
+	long int size;
+	fd_set readfds;
+	struct timeval timeout;
+	uint64_t i;
+	char *buf;
+	struct stat finfo;
+
+	if (argc != 3) {
+		fprintf(stderr, "Qcow-utils: v1.0.0\n");
+		fprintf(stderr, "usage: %s <Dest File descriptor> "
+			"<Qcow SRC IMAGE>\n", 
+		       argv[0]);
+		exit(-1);
+	}
+
+	sqcow = malloc(sizeof(struct td_state));
+	saio  = malloc(sizeof(struct td_state));
+	
+	/*Open qcow source file*/	
+	drv1 = &tapdisk_qcow;
+	sqcow->private = malloc(drv1->private_data_size);
+
+        if (drv1->td_open(sqcow, argv[2])!=0) {
+		DFPRINTF("Unable to open Qcow file [%s]\n",argv[2]);
+		exit(-1);
+	} else DFPRINTF("QCOW file opened, size %llu\n",
+		      (long long unsigned)sqcow->size);
+
+	qcowio_fd = drv1->td_get_fd(sqcow);
+
+        /*Setup aio destination file*/
+	ret = stat(argv[1],&finfo);
+	if (ret == -1) {
+		/*Check errno*/
+		switch(errno) {
+		case ENOENT:
+			/*File doesn't exist, create*/
+			fd = open(argv[1], 
+				  O_RDWR | O_LARGEFILE | O_CREAT, 0644);
+			if (fd < 0) {
+				DFPRINTF("ERROR creating file [%s] "
+					 "(errno %d)\n",
+				       argv[1], 0 - errno);
+				exit(-1);
+			}
+			if (ftruncate(fd, (off_t)sqcow->size<<9) < 0) {
+				DFPRINTF("Unable to create file "
+					"[%s] of size %llu (errno %d). "
+					 "Exiting...\n",
+					argv[1], 
+					(long long unsigned)sqcow->size<<9, 
+					0 - errno);
+				close(fd);
+				exit(-1);
+			}
+			close(fd);
+			break;
+		case  ENXIO:
+			DFPRINTF("ERROR Device [%s] does not exist\n",argv[1]);
+			exit(-1);
+		default: 
+			DFPRINTF("An error occurred opening Device [%s] "
+				 "(errno %d)\n",
+			       argv[1], 0 - errno);
+			exit(-1);
+		}
+	} else {		
+		fprintf(stderr, "WARNING: All existing data in "
+			"%s will be overwritten.\nDo you wish to continue? "
+			"(y or n)  ",
+			argv[1]);
+		if (getchar() != 'y') {
+			DFPRINTF("Exiting...\n");
+			exit(-1);
+		}
+		
+		/*TODO - Test the existing file or device for adequate space*/
+		fd = open(argv[1], O_RDWR | O_LARGEFILE);
+		if (fd < 0) {
+			DFPRINTF("ERROR: opening file [%s] (errno %d)\n",
+			       argv[1], 0 - errno);
+			exit(-1);
+		}
+
+		if (S_ISBLK(finfo.st_mode)) {
+			if(ioctl(fd,BLKGETSIZE,&size)!=0) {
+				DFPRINTF("ERROR: BLKGETSIZE failed, "
+					"couldn't stat image [%s]\n", 
+					argv[1]);
+				close(fd);
+				exit(-1);
+			}
+			if (size < sqcow->size<<9) {
+				DFPRINTF("ERROR: Not enough space on device "
+					"%s (%lu bytes available, %llu bytes required\n",
+					argv[1], size, 
+					(long long unsigned)sqcow->size<<9);
+				close(fd);
+				exit(-1);				
+			}
+		} else {
+			if (ftruncate(fd, (off_t)sqcow->size<<9) < 0) {
+				DFPRINTF("Unable to create file "
+					"[%s] of size %llu (errno %d). "
+					 "Exiting...\n",
+					argv[1], 
+					(long long unsigned)sqcow->size<<9, 
+					 0 - errno);
+				close(fd);
+				exit(-1);
+			} else DFPRINTF("File [%s] truncated to length %llu "
+					"(%llu)\n", 
+				       argv[1], 
+				       (long long unsigned)sqcow->size<<9, 
+				       (long long unsigned)sqcow->size);
+		}
+		close(fd);
+	}
+
+	/*Open aio destination file*/	
+	drv2 = &tapdisk_aio;
+	saio->private = malloc(drv2->private_data_size);
+
+        if (drv2->td_open(saio, argv[1])!=0) {
+		DFPRINTF("Unable to open Qcow file [%s]\n", argv[1]);
+		exit(-1);
+	}
+
+	aio_fd = drv2->td_get_fd(saio);
+
+	/*Initialise the output string*/
+	memset(output,0x20,25);
+	output[0] = '[';
+	output[22] = ']';
+	output[23] = '\0';
+	DFPRINTF("%s",output);
+
+	i = 0;
+	while (running) {
+		timeout.tv_sec = 0;
+		
+		if (!complete) {
+			/*Read Pages from qcow image*/
+			if ( (ret = posix_memalign((void **)&buf, 
+						   BLOCK_PROCESSSZ, 
+						   BLOCK_PROCESSSZ))
+			     != 0) {
+				DFPRINTF("Unable to alloc memory (%d)\n",ret);
+				exit(-1);				
+			}
+		
+			/*Attempt to read 4k sized blocks*/
+			ret = drv1->td_queue_read(sqcow, i>>9,
+						  BLOCK_PROCESSSZ>>9, buf, 
+						  send_read_responses, i>>9, buf);
+
+			if (ret < 0) {
+				DFPRINTF("UNABLE TO READ block [%llu]\n",
+				       (long long unsigned)i);
+				exit(-1);
+			} else {
+				i += BLOCK_PROCESSSZ;
+				submit_events++;
+			}
+
+			if (i >= sqcow->size<<9) {
+				complete = 1;
+			}
+			
+			if ((submit_events % 10 == 0) || complete) 
+				drv1->td_submit(sqcow);
+			timeout.tv_usec = 0;
+			
+		} else {
+			timeout.tv_usec = 1000;
+			if (!submit_events) running = 0;
+		}
+		
+
+		/*Check AIO FD*/
+		LOCAL_FD_SET(&readfds);
+                ret = select(maxfds + 1, &readfds, (fd_set *) 0,
+                             (fd_set *) 0, &timeout);
+			     
+		if (ret > 0) {
+			if (FD_ISSET(qcowio_fd[0], &readfds)) 
+				drv1->td_do_callbacks(sqcow, 0);
+			if (FD_ISSET(aio_fd[0], &readfds)) 
+				drv2->td_do_callbacks(saio, 0);
+		}
+		if (complete && (returned_write_events == submit_events)) 
+			running = 0;
+	}
+	memcpy(output+prev+1,"=",1);
+	DFPRINTF("\r%s     100%%\nTRANSFER COMPLETE\n\n", output);
+		
+	return 0;
+}
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/qcow-create.c xen-unstable-tapbuild.hg/tools/blktap/tools/qcow-create.c
--- xen-unstable-pristine.hg/tools/blktap/tools/qcow-create.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/qcow-create.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,80 @@
+/* qcow-create.c
+ *
+ * Generates a qcow format disk.
+ *
+ * (c) 2006 Andrew Warfield and Julian Chesterfield
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/statvfs.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include <string.h>
+#include "tapdisk.h"
+
+#if 1
+#define DFPRINTF(_f, _a...) fprintf ( stderr, _f , ## _a )
+#else
+#define DFPRINTF(_f, _a...) ((void)0)
+#endif
+
+
+int main(int argc, char *argv[])
+{
+	int ret = -1;
+	uint64_t size;
+
+	if ( (argc < 3) || (argc > 4) ) {
+		fprintf(stderr, "Qcow-utils: v1.0.0\n");
+		fprintf(stderr, 
+			"usage: %s <SIZE(MB)> <FILENAME> "
+			"[<BACKING_FILENAME>]\n", 
+			argv[0]);
+		exit(-1);
+	}
+
+	size = atoi(argv[1]);
+	size = size << 20;
+	DFPRINTF("Creating file size %llu\n",(long long unsigned)size);
+	switch(argc) {
+	case 3: 
+		ret = qcow_create(argv[2],size,NULL,0);
+		break;
+	case 4:
+		ret = qcow_create(argv[2],size,argv[3],0);
+		break;		
+	}
+	if (ret < 0) DPRINTF("Unable to create QCOW file\n");
+	else DPRINTF("QCOW file successfully created\n");
+
+	return 0;
+}
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/tapdisk.c xen-unstable-tapbuild.hg/tools/blktap/tools/tapdisk.c
--- xen-unstable-pristine.hg/tools/blktap/tools/tapdisk.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/tapdisk.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,671 @@
+/* tapdisk.c
+ *
+ * separate disk process, spawned by blktapctrl. Inherits code from driver 
+ * plugins
+ * 
+ * Copyright (c) 2005 Julian Chesterfield and Andrew Warfield.
+ *
+ */
+
+#define MSG_SIZE 4096
+#define TAPDISK
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/poll.h>
+#include <unistd.h>
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+#include <err.h>
+#include <poll.h>
+#include <sys/statvfs.h>
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#include "blktaplib.h"
+#include "tapdisk.h"
+
+#if 1                                                                        
+#define ASSERT(_p) \
+    if ( !(_p) ) { DPRINTF("Assertion '%s' failed, line %d, file %s", #_p , \
+    __LINE__, __FILE__); *(int*)0=0; }
+#else
+#define ASSERT(_p) ((void)0)
+#endif 
+
+#define INPUT 0
+#define OUTPUT 1
+
+static int maxfds, fds[2], run = 1;
+
+static pid_t process;
+int connected_disks = 0;
+fd_list_entry_t *fd_start = NULL;
+
+void usage(void) 
+{
+	fprintf(stderr, "blktap-utils: v1.0.0\n");
+	fprintf(stderr, "usage: tapdisk <READ fifo> <WRITE fifo>\n");
+        exit(-1);
+}
+
+void daemonize(void)
+{
+	int i;
+
+	if (getppid()==1) return; /* already a daemon */
+	if (fork() != 0) exit(0);
+
+#if 0
+	/*Set new program session ID and close all descriptors*/
+	setsid();
+	for (i = getdtablesize(); i >= 0; --i) close(i);
+
+	/*Send all I/O to /dev/null */
+	i = open("/dev/null",O_RDWR);
+	dup(i); 
+	dup(i);
+#endif
+	return;
+}
+
+static void unmap_disk(struct td_state *s)
+{
+	tapdev_info_t *info = s->ring_info;
+	struct tap_disk *drv = s->drv;
+	fd_list_entry_t *ptr, *prev;
+
+	drv->td_close(s);
+
+	if (info != NULL && info->mem > 0) 
+	        munmap(info->mem, PAGE_SIZE * BLKTAP_MMAP_REGION_SIZE);
+
+	ptr = s->fd_entry;
+	prev = ptr->prev;
+
+	if (prev) {
+		/*There are entries earlier in the list*/
+		prev->next = ptr->next;
+		if (ptr->next) {
+			ptr = ptr->next;
+			ptr->prev = prev;
+		}
+	} else {
+		/*We are the first entry in list*/
+		if (ptr->next) {
+			ptr = ptr->next;
+			fd_start = ptr;
+			ptr->prev = NULL;
+		} else fd_start = NULL;
+	}
+
+	close(info->fd);
+
+	free(s->fd_entry);
+	free(s->blkif);
+	free(s->ring_info);
+	free(s);
+
+	return;
+
+}
+
+void sig_handler(int sig)
+{
+	/*Received signal to close. If no disks are active, we close app.*/
+
+	if (connected_disks < 1) run = 0;	
+}
+
+static inline int LOCAL_FD_SET(fd_set *readfds)
+{
+	fd_list_entry_t *ptr;
+	int i;
+
+	ptr = fd_start;
+	while (ptr != NULL) {
+		if (ptr->tap_fd) {
+			FD_SET(ptr->tap_fd, readfds);
+			for (i = 0; i < MAX_IOFD; i++) {
+				if (ptr->io_fd[i]) 
+					FD_SET(ptr->io_fd[i], readfds);
+				maxfds = (ptr->io_fd[i] > maxfds ? 
+					  ptr->io_fd[i]: maxfds);
+			}
+			maxfds = (ptr->tap_fd > maxfds ? ptr->tap_fd: maxfds);
+		}
+		ptr = ptr->next;
+	}
+
+	return 0;
+}
+
+static inline fd_list_entry_t *add_fd_entry(int tap_fd, int io_fd[MAX_IOFD], struct td_state *s)
+{
+	fd_list_entry_t *ptr, *last, *entry;
+	int i;
+	DPRINTF("Adding fd_list_entry\n");
+
+	/*Add to linked list*/
+	s->fd_entry = entry = malloc(sizeof(fd_list_entry_t));
+	entry->tap_fd = tap_fd;
+	for (i = 0; i < MAX_IOFD; i++) entry->io_fd[i] = io_fd[i];
+	entry->s = s;
+	entry->next = NULL;
+
+	ptr = fd_start;
+	if (ptr == NULL) {
+		/*We are the first entry*/
+		fd_start = entry;
+		entry->prev = NULL;
+		goto finish;
+	}
+
+	while (ptr != NULL) {
+		last = ptr;
+		ptr = ptr->next;
+	}
+	last->next = entry;
+	entry->prev = last;
+
+ finish:
+	return entry;
+}
+
+static inline struct td_state *get_state(int cookie)
+{
+	fd_list_entry_t *ptr;
+
+	ptr = fd_start;
+	while (ptr != NULL) {
+		if (ptr->cookie == cookie) return ptr->s;
+		ptr = ptr->next;
+	}
+	return NULL;
+}
+
+static struct tap_disk *get_driver(int drivertype)
+{
+	/* blktapctrl has passed us the driver type */
+	
+	return dtypes[drivertype]->drv;
+}
+
+static struct td_state *state_init(void)
+{
+	int i;
+	struct td_state *s;
+	blkif_t *blkif;
+
+	s = malloc(sizeof(struct td_state));
+	blkif = s->blkif = malloc(sizeof(blkif_t));
+	s->ring_info = malloc(sizeof(tapdev_info_t));
+
+	for (i = 0; i < MAX_REQUESTS; i++)
+		blkif->pending_list[i].count = 0;
+
+	return s;
+}
+
+static int map_new_dev(struct td_state *s, int minor)
+{
+	int tap_fd;
+	tapdev_info_t *info = s->ring_info;
+	char *devname;
+	fd_list_entry_t *ptr;
+
+	asprintf(&devname,"%s/%s%d", BLKTAP_DEV_DIR, BLKTAP_DEV_NAME, minor);
+	tap_fd = open(devname, O_RDWR);
+	if (tap_fd == -1) 
+	{
+		DPRINTF("open failed on dev %s!",devname);
+		goto fail;
+	} 
+	info->fd = tap_fd;
+
+	/*Map the shared memory*/
+	info->mem = mmap(0, PAGE_SIZE * BLKTAP_MMAP_REGION_SIZE, 
+			  PROT_READ | PROT_WRITE, MAP_SHARED, info->fd, 0);
+	if ((long int)info->mem == -1) 
+	{
+		DPRINTF("mmap failed on dev %s!\n",devname);
+		goto fail;
+	}
+
+	/* assign the rings to the mapped memory */ 
+	info->sring = (blkif_sring_t *)((unsigned long)info->mem);
+	BACK_RING_INIT(&info->fe_ring, info->sring, PAGE_SIZE);
+	
+	info->vstart = 
+	        (unsigned long)info->mem + (BLKTAP_RING_PAGES << PAGE_SHIFT);
+
+	ioctl(info->fd, BLKTAP_IOCTL_SENDPID, process );
+	ioctl(info->fd, BLKTAP_IOCTL_SETMODE, BLKTAP_MODE_INTERPOSE );
+	free(devname);
+
+	/*Update the fd entry*/
+	ptr = fd_start;
+	while (ptr != NULL) {
+		if (s == ptr->s) {
+			ptr->tap_fd = tap_fd;
+			break;
+		}
+		ptr = ptr->next;
+	}	
+
+	return minor;
+
+ fail:
+	free(devname);
+	return -1;
+}
+
+static int read_msg(char *buf)
+{
+	int length, len, msglen, tap_fd, *io_fd;
+	char *ptr, *path;
+	image_t *img;
+	struct timeval timeout;
+	msg_hdr_t *msg;
+	msg_newdev_t *msg_dev;
+	msg_pid_t *msg_pid;
+	struct tap_disk *drv;
+	int ret = -1;
+	struct td_state *s = NULL;
+	fd_list_entry_t *entry;
+
+	length = read(fds[READ], buf, MSG_SIZE);
+
+	if (length > 0 && length >= sizeof(msg_hdr_t)) 
+	{
+		msg = (msg_hdr_t *)buf;
+		DPRINTF("Tapdisk: Received msg, len %d, type %d, UID %d\n",
+			length,msg->type,msg->cookie);
+
+		switch (msg->type) {
+		case CTLMSG_PARAMS: 			
+			ptr = buf + sizeof(msg_hdr_t);
+			len = (length - sizeof(msg_hdr_t));
+			path = calloc(1, len);
+			
+			memcpy(path, ptr, len); 
+			DPRINTF("Received CTLMSG_PARAMS: [%s]\n", path);
+
+			/*Assign driver*/
+			drv = get_driver(msg->drivertype);
+			if (drv == NULL)
+				goto params_done;
+				
+			DPRINTF("Loaded driver: name [%s], type [%d]\n",
+				drv->disk_type, msg->drivertype);
+
+			/* Allocate the disk structs */
+			s = state_init();
+			if (s == NULL)
+				goto params_done;
+
+			s->drv = drv;
+			s->private = malloc(drv->private_data_size);
+			if (s->private == NULL) {
+				free(s);
+				goto params_done;
+			}
+
+			/*Open file*/
+			ret = drv->td_open(s, path);
+			io_fd = drv->td_get_fd(s);
+
+			entry = add_fd_entry(0, io_fd, s);
+			entry->cookie = msg->cookie;
+			DPRINTF("Entered cookie %d\n",entry->cookie);
+			
+			memset(buf, 0x00, MSG_SIZE); 
+			
+		params_done:
+			if (ret == 0) {
+				msglen = sizeof(msg_hdr_t) + sizeof(image_t);
+				msg->type = CTLMSG_IMG;
+				img = (image_t *)(buf + sizeof(msg_hdr_t));
+				img->size = s->size;
+				img->secsize = s->sector_size;
+				img->info = s->info;
+			} else {
+				msglen = sizeof(msg_hdr_t);
+				msg->type = CTLMSG_IMG_FAIL;
+				msg->len = msglen;
+			}
+			len = write(fds[WRITE], buf, msglen);
+			free(path);
+			return 1;
+			
+			
+			
+		case CTLMSG_NEWDEV:
+			msg_dev = (msg_newdev_t *)(buf + sizeof(msg_hdr_t));
+
+			s = get_state(msg->cookie);
+			DPRINTF("Retrieving state, cookie %d.....[%s]\n",msg->cookie, (s == NULL ? "FAIL":"OK"));
+			if (s != NULL) {
+				ret = ((map_new_dev(s, msg_dev->devnum) 
+					== msg_dev->devnum ? 0: -1));
+				connected_disks++;
+			}	
+
+			memset(buf, 0x00, MSG_SIZE); 
+			msglen = sizeof(msg_hdr_t);
+			msg->type = (ret == 0 ? CTLMSG_NEWDEV_RSP 
+				              : CTLMSG_NEWDEV_FAIL);
+			msg->len = msglen;
+
+			len = write(fds[WRITE], buf, msglen);
+			return 1;
+
+		case CTLMSG_CLOSE:
+			s = get_state(msg->cookie);
+			if (s) unmap_disk(s);
+			
+			connected_disks--;
+			sig_handler(SIGINT);
+
+			return 1;			
+
+		case CTLMSG_PID:
+			memset(buf, 0x00, MSG_SIZE);
+			msglen = sizeof(msg_hdr_t) + sizeof(msg_pid_t);
+			msg->type = CTLMSG_PID_RSP;
+			msg->len = msglen;
+
+			msg_pid = (msg_pid_t *)(buf + sizeof(msg_hdr_t));
+			process = getpid();
+			msg_pid->pid = process;
+
+			len = write(fds[WRITE], buf, msglen);
+			return 1;
+
+		default:
+			return 0;
+		}
+	}
+	return 0;
+}
+
+static inline int write_rsp_to_ring(struct td_state *s, blkif_response_t *rsp)
+{
+	tapdev_info_t *info = s->ring_info;
+	blkif_response_t *rsp_d;
+	
+	rsp_d = RING_GET_RESPONSE(&info->fe_ring, info->fe_ring.rsp_prod_pvt);
+	memcpy(rsp_d, rsp, sizeof(blkif_response_t));
+	wmb();
+	info->fe_ring.rsp_prod_pvt++;
+	
+	return 0;
+}
+
+static inline void kick_responses(struct td_state *s)
+{
+	tapdev_info_t *info = s->ring_info;
+
+	if (info->fe_ring.rsp_prod_pvt != info->fe_ring.sring->rsp_prod) 
+	{
+		RING_PUSH_RESPONSES(&info->fe_ring);
+		ioctl(info->fd, BLKTAP_IOCTL_KICK_FE);
+	}
+}
+
+void io_done(struct td_state *s, int sid)
+{
+	struct tap_disk *drv = s->drv;
+
+	if (!run) return; /*We have received signal to close*/
+
+	if (drv->td_do_callbacks(s, sid) > 0) kick_responses(s);
+
+	return;
+}
+
+int send_responses(struct td_state *s, int res, int idx, void *private)
+{
+	blkif_request_t *req;
+	int responses_queued = 0;
+	blkif_t *blkif = s->blkif;
+
+	req   = &blkif->pending_list[idx].req;
+			
+	if ( (idx > MAX_REQUESTS-1) || 
+	    (blkif->pending_list[idx].count == 0) )
+	{
+		DPRINTF("invalid index returned(%u)!\n", idx);
+		return 0;
+	}
+	
+	if (res != 0) {
+		DPRINTF("*** request error %d! \n", res);
+		return 0;
+	}
+
+	blkif->pending_list[idx].count--;
+	
+	if (blkif->pending_list[idx].count == 0) 
+	{
+		blkif_request_t tmp;
+		blkif_response_t *rsp;
+		
+		tmp = blkif->pending_list[idx].req;
+		rsp = (blkif_response_t *)req;
+		
+		rsp->id = tmp.id;
+		rsp->operation = tmp.operation;
+		rsp->status = blkif->pending_list[idx].status;
+		
+		write_rsp_to_ring(s, rsp);
+		responses_queued++;
+	}
+	return responses_queued;
+}
+
+static void get_io_request(struct td_state *s)
+{
+	RING_IDX          rp, rc, j, i, ret;
+	blkif_request_t  *req;
+	int idx, nsects;
+	uint64_t sector_nr;
+	char *page;
+	int early = 0; /* count early completions */
+	struct tap_disk *drv = s->drv;
+	blkif_t *blkif = s->blkif;
+	tapdev_info_t *info = s->ring_info;
+
+	if (!run) return; /*We have received signal to close*/
+
+	rp = info->fe_ring.sring->req_prod; 
+	rmb();
+	for (j = info->fe_ring.req_cons; j != rp; j++)
+	{
+		int done = 0; 
+
+		req = NULL;
+		req = RING_GET_REQUEST(&info->fe_ring, j);
+		++info->fe_ring.req_cons;
+		
+		if (req == NULL) continue;
+		
+		idx = req->id;
+		ASSERT(blkif->pending_list[idx].count == 0);
+		memcpy(&blkif->pending_list[idx].req, req, sizeof(*req));
+		blkif->pending_list[idx].status = BLKIF_RSP_OKAY;
+		blkif->pending_list[idx].count = req->nr_segments;
+
+		sector_nr = req->sector_number;
+
+		for (i = 0; i < req->nr_segments; i++) {
+			nsects = req->seg[i].last_sect - 
+				 req->seg[i].first_sect + 1;
+	
+			if ((req->seg[i].last_sect >= PAGE_SIZE >> 9) ||
+			    (nsects <= 0))
+				continue;
+
+			page  = (char *)MMAP_VADDR(info->vstart, 
+						   (unsigned long)req->id, i);
+			page += (req->seg[i].first_sect << SECTOR_SHIFT);
+
+			if (sector_nr >= s->size) {
+				DPRINTF("Sector request failed:\n");
+				DPRINTF("%s request, idx [%d,%d] size [%llu], "
+					"sector [%llu,%llu]\n",
+					(req->operation == BLKIF_OP_WRITE ? 
+					 "WRITE" : "READ"),
+					idx,i,
+					(long long unsigned) 
+						nsects<<SECTOR_SHIFT,
+					(long long unsigned) 
+						sector_nr<<SECTOR_SHIFT,
+					(long long unsigned) sector_nr);
+				continue;
+			}
+			
+			switch (req->operation) 
+			{
+			case BLKIF_OP_WRITE:
+				ret = drv->td_queue_write(s, sector_nr,
+						nsects, page, send_responses, 
+						idx, NULL);
+				if (ret > 0) early += ret;
+				else if (ret == -EBUSY) {
+					/*
+					 * TODO: Sector is locked         *
+					 * Need to put req back on queue  *
+					 */
+				}
+				break;
+			case BLKIF_OP_READ:
+				ret = drv->td_queue_read(s, sector_nr,
+						nsects, page, send_responses, 
+						idx, NULL);
+				if (ret > 0) early += ret;
+				else if (ret == -EBUSY) {
+					/*
+					 * TODO: Sector is locked         *
+					 * Need to put req back on queue  *
+					 */
+				}
+				break;
+			default:
+				DPRINTF("Unknown block operation\n");
+				break;
+			}
+			sector_nr += nsects;
+		}
+	}
+
+	/*Batch done*/
+	drv->td_submit(s);
+	
+	if (early > 0) 
+		io_done(s,10);
+		
+	return;
+}
+
+int main(int argc, char *argv[])
+{
+	int len, msglen, ret, i;
+	char *p, *buf;
+	fd_set readfds, writefds;
+	struct timeval timeout;
+	fd_list_entry_t *ptr;
+	struct tap_disk *drv;
+	struct td_state *s;
+	
+	if (argc != 3) usage();
+
+	daemonize();
+
+	openlog("TAPDISK", LOG_CONS|LOG_ODELAY, LOG_DAEMON);
+	/*Setup signal handlers*/
+	signal (SIGBUS, sig_handler);
+	signal (SIGINT, sig_handler);
+
+	/*Open the control channel*/
+	fds[READ] = open(argv[1],O_RDWR|O_NONBLOCK);
+	fds[WRITE] = open(argv[2],O_RDWR|O_NONBLOCK);
+
+	if ( (fds[READ] < 0) || (fds[WRITE] < 0) ) 
+	{
+		DPRINTF("FD open failed [%d,%d]\n",fds[READ], fds[WRITE]);
+		exit(-1);
+	}
+
+	buf = calloc(MSG_SIZE, 1);
+
+	if (buf == NULL) 
+        {
+		DPRINTF("ERROR: allocating memory.\n");
+		exit(-1);
+	}
+
+	while (run) 
+        {
+		ret = 0;
+		FD_ZERO(&readfds);
+		FD_SET(fds[READ], &readfds);
+		maxfds = fds[READ];
+
+		/*Set all tap fds*/
+		LOCAL_FD_SET(&readfds);
+
+		timeout.tv_sec = 0; 
+		timeout.tv_usec = 1000; 
+
+		/*Wait for incoming messages*/
+		ret = select(maxfds + 1, &readfds, (fd_set *) 0, 
+			     (fd_set *) 0, &timeout);
+
+		if (ret > 0) 
+                {
+			ptr = fd_start;
+			while (ptr != NULL) {
+				if (FD_ISSET(ptr->tap_fd, &readfds)) 
+					get_io_request(ptr->s);
+				for (i = 0; i < MAX_IOFD; i++) {
+					if (ptr->io_fd[i] && 
+					   FD_ISSET(ptr->io_fd[i], &readfds)) 
+						io_done(ptr->s, i);
+				}
+
+				ptr = ptr->next;
+			}
+
+			if (FD_ISSET(fds[READ], &readfds))
+				read_msg(buf);
+		}
+	}
+	free(buf);
+	close(fds[READ]);
+	close(fds[WRITE]);
+
+	ptr = fd_start;
+	while (ptr != NULL) {
+		s = ptr->s;
+		drv = s->drv;
+
+		unmap_disk(s);
+		drv->td_close(s);
+		free(s->private);
+		free(s->blkif);
+		free(s->ring_info);
+		free(s);
+		close(ptr->tap_fd);
+		ptr = ptr->next;
+	}
+	closelog();
+
+	return 0;
+}
diff -urN xen-unstable-pristine.hg/tools/blktap/tools/tapdisk.h xen-unstable-tapbuild.hg/tools/blktap/tools/tapdisk.h
--- xen-unstable-pristine.hg/tools/blktap/tools/tapdisk.h	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/tools/tapdisk.h	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,211 @@
+/* tapdisk.h
+ *
+ * Generic disk interface for blktap-based image adapters.
+ *
+ * (c) 2006 Andrew Warfield and Julian Chesterfield
+ * 
+ * Some notes on the tap_disk interface:
+ * 
+ * tap_disk aims to provide a generic interface to easily implement new 
+ * types of image accessors.  The structure-of-function-calls is similar
+ * to disk interfaces used in qemu/denali/etc, with the significant 
+ * difference being the expectation of asynchronous rather than synchronous 
+ * I/O.  The asynchronous interface is intended to allow lots of requests to
+ * be pipelined through a disk, without the disk requiring any of its own
+ * threads of control.  As such, a batch of requests is delivered to the disk
+ * using:
+ * 
+ *    td_queue_[read,write]()
+ * 
+ * and passing in a completion callback, which the disk is responsible for 
+ * tracking.  The end of a back is marked with a call to:
+ * 
+ *    td_submit()
+ * 
+ * The disk implementation must provide a file handle, which is used to 
+ * indicate that it needs to do work.  tapdisk will add this file handle 
+ * (returned from td_get_fd()) to it's poll set, and will call into the disk
+ * using td_do_callbacks() whenever there is data pending.
+ * 
+ * Two disk implementations demonstrate how this interface may be used to 
+ * implement disks with both asynchronous and synchronous calls.  block-aio.c
+ * maps this interface down onto the linux libaio calls, while block-sync uses 
+ * normal posix read/write.
+ * 
+ * A few things to realize about the sync case, which doesn't need to defer 
+ * io completions:
+ * 
+ *   - td_queue_[read,write]() call read/write directly, and then call the 
+ *     callback immediately.  The MUST then return a value greater than 0
+ *     in order to tell tapdisk that requests have finished early, and to 
+ *     force responses to be kicked to the clents.
+ * 
+ *   - The fd used for poll is an otherwise unused pipe, which allows poll to 
+ *     be safely called without ever returning anything.
+ * 
+ */
+
+#ifndef TAPDISK_H_
+#define TAPDISK_H_
+
+#include <stdint.h>
+#include <syslog.h>
+#include "blktaplib.h"
+
+/*If enabled, log all debug messages to syslog*/
+#if 1
+#define DPRINTF(_f, _a...) syslog( LOG_DEBUG, _f , ## _a )
+#else
+#define DPRINTF(_f, _a...) ((void)0)
+#endif
+
+/* Things disks need to know about, these should probably be in a higher-level
+ * header. */
+#define MAX_REQUESTS            64
+#define MAX_SEGMENTS_PER_REQ    11
+#define SECTOR_SHIFT             9
+#define DEFAULT_SECTOR_SIZE    512
+
+/* This structure represents the state of an active virtual disk.           */
+struct td_state {
+	void *private;
+	void *drv;
+	void *blkif;
+	void *image;
+	void *ring_info;
+	void *fd_entry;
+	char backing_file[1024]; /*Used by differencing disks, e.g. qcow*/
+	long int   sector_size;
+	uint64_t   size;
+	long int   info;
+};
+
+/* Prototype of the callback to activate as requests complete.              */
+typedef int (*td_callback_t)(struct td_state *s, int res, int id, void *prv);
+
+/* Structure describing the interface to a virtual disk implementation.     */
+/* See note at the top of this file describing this interface.              */
+struct tap_disk {
+	const char *disk_type;
+	int private_data_size;
+	int (*td_open)        (struct td_state *s, const char *name);
+	int (*td_queue_read)  (struct td_state *s, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *prv);
+	int (*td_queue_write) (struct td_state *s, uint64_t sector,
+			       int nb_sectors, char *buf, td_callback_t cb,
+			       int id, void *prv);
+	int (*td_submit)      (struct td_state *s);
+	int *(*td_get_fd)      (struct td_state *s);
+	int (*td_close)       (struct td_state *s);
+	int (*td_do_callbacks)(struct td_state *s, int sid);
+};
+
+typedef struct disk_info {
+	int  idnum;
+	char name[50];       /* e.g. "RAMDISK" */
+	char handle[10];     /* xend handle, e.g. 'ram' */
+	int  single_handler; /* is there a single controller for all */
+	                     /* instances of disk type? */
+#ifdef TAPDISK
+	struct tap_disk *drv;	
+#endif
+} disk_info_t;
+
+void debug_fe_ring(struct td_state *s);
+
+extern struct tap_disk tapdisk_aio;
+extern struct tap_disk tapdisk_sync;
+extern struct tap_disk tapdisk_vmdk;
+extern struct tap_disk tapdisk_ram;
+extern struct tap_disk tapdisk_qcow;
+
+#define MAX_DISK_TYPES  20
+#define MAX_IOFD        2
+
+#define DISK_TYPE_AIO   0
+#define DISK_TYPE_SYNC  1
+#define DISK_TYPE_VMDK  2
+#define DISK_TYPE_RAM   3
+#define DISK_TYPE_QCOW  4
+
+
+/*Define Individual Disk Parameters here */
+static disk_info_t aio_disk = {
+	DISK_TYPE_AIO,
+	"raw image (aio)",
+	"aio",
+	0,
+#ifdef TAPDISK
+	&tapdisk_aio,
+#endif
+};
+
+static disk_info_t sync_disk = {
+	DISK_TYPE_SYNC,
+	"raw image (sync)",
+	"sync",
+	0,
+#ifdef TAPDISK
+	&tapdisk_sync,
+#endif
+};
+
+static disk_info_t vmdk_disk = {
+	DISK_TYPE_VMDK,
+	"vmware image (vmdk)",
+	"vmdk",
+	1,
+#ifdef TAPDISK
+	&tapdisk_vmdk,
+#endif
+};
+
+static disk_info_t ram_disk = {
+	DISK_TYPE_RAM,
+	"ramdisk image (ram)",
+	"ram",
+	1,
+#ifdef TAPDISK
+	&tapdisk_ram,
+#endif
+};
+
+static disk_info_t qcow_disk = {
+	DISK_TYPE_QCOW,
+	"qcow disk (qcow)",
+	"qcow",
+	0,
+#ifdef TAPDISK
+	&tapdisk_qcow,
+#endif
+};
+
+/*Main disk info array */
+static disk_info_t *dtypes[] = {
+	&aio_disk,
+	&sync_disk,
+	&vmdk_disk,
+	&ram_disk,
+	&qcow_disk,
+};
+
+typedef struct driver_list_entry {
+	void *blkif;
+	void *prev;
+	void *next;
+} driver_list_entry_t;
+
+typedef struct fd_list_entry {
+	int cookie;
+	int  tap_fd;
+	int  io_fd[MAX_IOFD];
+	struct td_state *s;
+	void *prev;
+	void *next;
+} fd_list_entry_t;
+
+int qcow_create(const char *filename, uint64_t total_size,
+		const char *backing_file, int flags);
+
+#endif /*TAPDISK_H_*/
diff -urN xen-unstable-pristine.hg/tools/blktap/xenbus.c xen-unstable-tapbuild.hg/tools/blktap/xenbus.c
--- xen-unstable-pristine.hg/tools/blktap/xenbus.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/xenbus.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,387 @@
+/*
+ * xenbus.c
+ * 
+ * xenbus interface to the blocktap.
+ * 
+ * this handles the top-half of integration with block devices through the
+ * store -- the tap driver negotiates the device channel etc, while the
+ * userland tap client needs to sort out the disk parameters etc.
+ * 
+ * (c) 2005 Andrew Warfield and Julian Chesterfield
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <printf.h>
+#include <string.h>
+#include <err.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <xs.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <time.h>
+#include <sys/time.h>
+#include "blktaplib.h"
+#include "list.h"
+#include "xs_api.h"
+
+#if 0
+#define DPRINTF(_f, _a...) printf ( _f , ## _a )
+#else
+#define DPRINTF(_f, _a...) ((void)0)
+#endif
+
+struct backend_info
+{
+	/* our communications channel */
+	blkif_t *blkif;
+	
+	long int frontend_id;
+	long int pdev;
+	long int readonly;
+	
+	char *backpath;
+	char *frontpath;
+	
+	struct list_head list;
+};
+
+static LIST_HEAD(belist);
+
+static int strsep_len(const char *str, char c, unsigned int len)
+{
+	unsigned int i;
+	
+	for (i = 0; str[i]; i++)
+		if (str[i] == c) {
+			if (len == 0)
+				return i;
+			len--;
+		}
+	return (len == 0) ? i : -ERANGE;
+}
+
+static int get_be_id(const char *str)
+{
+	int len,end;
+	const char *ptr;
+	char *tptr, num[10];
+	
+	len = strsep_len(str, '/', 6);
+	end = strlen(str);
+	if( (len < 0) || (end < 0) ) return -1;
+	
+	ptr = str + len + 1;
+	strncpy(num, ptr, end - len);
+	tptr = num + (end - (len + 1));
+	*tptr = '\0';
+
+	return atoi(num);
+}
+
+static struct backend_info *be_lookup_be(const char *bepath)
+{
+	struct backend_info *be;
+	
+	list_for_each_entry(be, &belist, list)
+		if (strcmp(bepath, be->backpath) == 0)
+			return be;
+	return (struct backend_info *)NULL;
+}
+
+static int be_exists_be(const char *bepath)
+{
+	return (be_lookup_be(bepath) != NULL);
+}
+
+static struct backend_info *be_lookup_fe(const char *fepath)
+{
+	struct backend_info *be;
+	
+	list_for_each_entry(be, &belist, list)
+		if (strcmp(fepath, be->frontpath) == 0)
+			return be;
+	return (struct backend_info *)NULL;
+}
+
+static int backend_remove(struct xs_handle *h, struct backend_info *be)
+{
+	/* Unhook from be list. */
+	list_del(&be->list);
+
+	/* Free everything else. */
+	if (be->blkif) {
+		DPRINTF("Freeing blkif dev [%d]\n",be->blkif->devnum);
+		free_blkif(be->blkif);
+	}
+	if (be->frontpath)
+		free(be->frontpath);
+	if (be->backpath)
+		free(be->backpath);
+	free(be);
+	return 0;
+}
+
+static void ueblktap_setup(struct xs_handle *h, char *bepath)
+{
+	struct backend_info *be;
+	char *path = NULL, *p,*dev;
+	int len, er, deverr;
+	long int pdev = 0, handle;
+	blkif_info_t *blk;
+	
+	be = be_lookup_be(bepath);
+	if (be == NULL)
+	{
+		DPRINTF("ERROR: backend changed called for nonexistent "
+			"backend! (%s)\n", bepath);
+		goto fail;
+	}
+
+        deverr = xs_gather(h, bepath, "physical-device", "%li", &pdev, NULL);
+        if (!deverr) {
+                DPRINTF("pdev set to %ld\n",pdev);
+                if (be->pdev && be->pdev != pdev) {
+                        DPRINTF("changing physical-device not supported");
+                        goto fail;
+                }
+                be->pdev = pdev;
+        }
+
+        /*Check to see if device is to be opened read-only*/
+        asprintf(&path, "%s/%s", bepath, "read-only");
+        if (xs_exists(h, path))
+                be->readonly = 1;
+
+        if (be->blkif == NULL) {
+
+                /* Front end dir is a number, which is used as the handle. */
+                p = strrchr(be->frontpath, '/') + 1;
+                handle = strtoul(p, NULL, 0);
+
+                be->blkif = alloc_blkif(be->frontend_id);
+	
+                if (be->blkif == NULL)
+                        goto fail;
+
+		be->blkif->be_id = get_be_id(bepath);
+		
+                /*Insert device specific info*/
+                blk = malloc(sizeof(blkif_info_t));
+		if (!blk) {
+			DPRINTF("Out of memory - blkif_info_t\n");
+			goto fail;
+		}
+                er = xs_gather(h, bepath, "params", NULL, &blk->params, NULL);
+                if (er)
+                        goto fail;
+                be->blkif->info = blk;
+		
+                if (deverr) {
+                        /*Dev number was not available, try to set manually*/
+                        pdev = convert_dev_name_to_num(blk->params);
+                        be->pdev = pdev;
+                }
+
+                er = blkif_init(be->blkif, handle, be->pdev, be->readonly);
+
+                if (er != 0) {
+                        DPRINTF("Unable to open device %s\n",blk->params);
+			goto fail;
+		}
+
+                DPRINTF("[BECHG]: ADDED A NEW BLKIF (%s)\n", bepath);
+        }	
+	/* Supply the information about the device to xenstore */
+	er = xs_printf(h, be->backpath, "sectors", "%lu",
+			be->blkif->ops->get_size(be->blkif));
+
+	if (er == 0) {
+		DPRINTF("ERROR: Failed writing sectors");
+		goto fail;
+	}
+
+	er = xs_printf(h, be->backpath, "sector-size", "%lu",
+			be->blkif->ops->get_secsize(be->blkif));
+
+	if (er == 0) {
+		DPRINTF("ERROR: Failed writing sector-size");
+		goto fail;
+	}
+
+	er = xs_printf(h, be->backpath, "info", "%u",
+			be->blkif->ops->get_info(be->blkif));
+
+	if (er == 0) {
+		DPRINTF("ERROR: Failed writing info");
+		goto fail;
+	}
+
+	be->blkif->state = CONNECTED;
+	DPRINTF("[SETUP] Complete\n\n");
+	goto close;
+	
+fail:
+	if ( (be != NULL) && (be->blkif != NULL) ) 
+		backend_remove(h, be);
+close:
+	if (path)
+		free(path);
+	return;
+}
+
+/**
+ * Xenstore watch callback entry point. This code replaces the hotplug scripts,
+ * and as soon as the xenstore backend driver entries are created, this script
+ * gets called.
+ */
+static void ueblktap_probe(struct xs_handle *h, struct xenbus_watch *w, 
+			   const char *bepath_im)
+{
+	struct backend_info *be = NULL;
+	char *frontend = NULL, *bepath = NULL, *p;
+	int er, len;
+	blkif_t *blkif;
+	
+	
+	bepath = strdup(bepath_im);
+	
+	if (!bepath) {
+		DPRINTF("No path\n");
+		return;
+	}
+	
+	/*
+	 *asserts that xenstore structure is always 7 levels deep
+	 *e.g. /local/domain/0/backend/vbd/1/2049
+	 */
+        len = strsep_len(bepath, '/', 7);
+        if (len < 0) 
+		goto free_be;     
+        bepath[len] = '\0';
+	
+	be = malloc(sizeof(*be));
+	if (!be) {
+		DPRINTF("ERROR: allocating backend structure\n");
+		goto free_be;
+	}
+	memset(be, 0, sizeof(*be));
+	frontend = NULL;
+
+	er = xs_gather(h, bepath,
+		       "frontend-id", "%li", &be->frontend_id,
+		       "frontend", NULL, &frontend,
+		       NULL);
+
+	if (er) {
+		/*
+		 *Unable to find frontend entries, 
+		 *bus-id is no longer valid
+		 */
+		DPRINTF("ERROR: Frontend-id check failed, removing backend: "
+			"[%s]\n",bepath);
+
+		/**
+		 * BE info should already exist, 
+		 * free new mem and find old entry
+		 */
+		free(be);
+		be = be_lookup_be(bepath);
+		if ( (be != NULL) && (be->blkif != NULL) ) 
+			backend_remove(h, be);
+		else goto free_be;
+	        if (bepath)
+			free(bepath);
+		return;
+	}
+	
+        /* Are we already tracking this device? */
+        if (be_exists_be(bepath)) {
+		goto free_be;
+	}
+	
+	be->backpath = bepath;
+       	be->frontpath = frontend;
+	
+        list_add(&be->list, &belist);
+	
+        DPRINTF("[PROBE]\tADDED NEW DEVICE (%s)\n", bepath);
+	DPRINTF("\tFRONTEND (%s),(%ld)\n", frontend,be->frontend_id);
+	
+	ueblktap_setup(h, bepath);	
+	return;
+	
+ free_be:
+	if (frontend)
+		free(frontend);
+        if (bepath)
+		free(bepath);
+	if (be) 
+		free(be);
+	return;
+}
+
+/**
+ *We set a general watch on the backend vbd directory
+ *ueblktap_probe is called for every update
+ *Our job is to monitor for new entries. As they 
+ *are created, we initalise the state and attach a disk.
+ */
+
+int add_blockdevice_probe_watch(struct xs_handle *h, const char *domname)
+{
+	char *domid, *path;
+	struct xenbus_watch *vbd_watch;
+	int er;
+	
+	domid = get_dom_domid(h, domname);
+
+	DPRINTF("%s: %s\n", 
+		domname, (domid != NULL) ? domid : "[ not found! ]");
+	
+	asprintf(&path, "/local/domain/%s/backend/tap", domid);
+	if (path == NULL) 
+		return -ENOMEM;
+	
+	vbd_watch = (struct xenbus_watch *)malloc(sizeof(struct xenbus_watch));
+	if (!vbd_watch) {
+		DPRINTF("ERROR: unable to malloc vbd_watch [%s]\n", path);
+		return -EINVAL;
+	}	
+	vbd_watch->node     = path;
+	vbd_watch->callback = ueblktap_probe;
+	er = register_xenbus_watch(h, vbd_watch);
+	if (er == 0) {
+		DPRINTF("ERROR: adding vbd probe watch %s\n", path);
+		return -EINVAL;
+	}
+	return 0;
+}
diff -urN xen-unstable-pristine.hg/tools/blktap/xs_api.c xen-unstable-tapbuild.hg/tools/blktap/xs_api.c
--- xen-unstable-pristine.hg/tools/blktap/xs_api.c	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/xs_api.c	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,364 @@
+/*
+ * xs_api.c
+ * 
+ * blocktap interface functions to xenstore
+ *
+ * (c) 2005 Andrew Warfield and Julian Chesterfield
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <printf.h>
+#include <string.h>
+#include <err.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <xs.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <poll.h>
+#include "blktaplib.h"
+#include "list.h"
+#include "xs_api.h"
+
+#if 0
+#define DPRINTF(_f, _a...) printf ( _f , ## _a )
+#else
+#define DPRINTF(_f, _a...) ((void)0)
+#endif
+
+static LIST_HEAD(watches);
+#define BASE_DEV_VAL 2048
+
+int xs_gather(struct xs_handle *xs, const char *dir, ...)
+{
+	va_list ap;
+	const char *name;
+	char *path, **e;
+	int ret = 0, num,i;
+	unsigned int len;
+	xs_transaction_t xth;
+
+again:
+	if ( (xth = xs_transaction_start(xs)) == XBT_NULL) {
+		DPRINTF("unable to start xs trasanction\n");
+		ret = ENOMEM;
+		return ret;
+	}
+	
+	va_start(ap, dir);
+	while ( (ret == 0) && (name = va_arg(ap, char *)) != NULL) {
+		const char *fmt = va_arg(ap, char *);
+		void *result = va_arg(ap, void *);
+		char *p;
+		
+		if (asprintf(&path, "%s/%s", dir, name) == -1)
+		{
+			printf("allocation error in xs_gather!\n");
+			ret = ENOMEM;
+			break;
+		}
+		
+		p = xs_read(xs, xth, path, &len);
+		
+		
+		free(path);
+		if (p == NULL) {
+			ret = ENOENT;
+			break;
+		}
+		if (fmt) {
+			if (sscanf(p, fmt, result) == 0)
+				ret = EINVAL;
+			free(p);
+		} else
+			*(char **)result = p;
+	}
+	va_end(ap);
+
+	if (!xs_transaction_end(xs, xth, ret)) {
+		if (ret == 0 && errno == EAGAIN)
+			goto again;
+                else
+			ret = errno;
+	}
+
+	return ret;
+}
+
+
+/* Single printf and write: returns -errno or 0. */
+int xs_printf(struct xs_handle *h, const char *dir, const char *node, 
+	      const char *fmt, ...)
+{
+        char *buf, *path;
+        va_list ap;
+        int ret;
+	
+        va_start(ap, fmt);
+        ret = vasprintf(&buf, fmt, ap);
+        va_end(ap);
+	
+        asprintf(&path, "%s/%s", dir, node);
+	
+        if ( (path == NULL) || (buf == NULL) )
+		return 0;
+
+        ret = xs_write(h, XBT_NULL, path, buf, strlen(buf)+1);
+	
+        free(buf);
+        free(path);
+	
+        return ret;
+}
+
+
+int xs_exists(struct xs_handle *h, const char *path)
+{
+	char **d;
+	unsigned int num;
+	xs_transaction_t xth;
+	
+	if ( (xth = xs_transaction_start(h)) == XBT_NULL) {
+		printf("unable to start xs trasanction\n");
+		return 0;
+	}	
+	
+	d = xs_directory(h, xth, path, &num);
+	xs_transaction_end(h, xth, 0);
+	if (d == NULL)
+		return 0;
+	free(d);
+	return 1;
+}
+
+
+
+/**
+ * This assumes that the domain name we are looking for is unique. 
+ * Name parameter Domain-0 
+ */
+char *get_dom_domid(struct xs_handle *h, const char *name)
+{
+	char **e, *val, *domid = NULL;
+	unsigned int num, len;
+	int i;
+	char *path;
+	xs_transaction_t xth;
+	
+	if ( (xth = xs_transaction_start(h)) == XBT_NULL) {
+		warn("unable to start xs trasanction\n");
+		return NULL;
+	}
+	
+	e = xs_directory(h, xth, "/local/domain", &num);
+	
+	i = 0;
+	while (i < num) {
+		asprintf(&path, "/local/domain/%s/name", e[i]);
+		val = xs_read(h, xth, path, &len);
+		free(path);
+		if (val == NULL)
+			continue;
+		
+		if (strcmp(val, name) == 0) {
+			/* match! */
+			asprintf(&path, "/local/domain/%s/domid", e[i]);
+			domid = xs_read(h, xth, path, &len);
+			free(val);
+			free(path);
+			break;
+		}
+		free(val);
+		i++;
+	}
+	xs_transaction_end(h, xth, 0);
+	
+	free(e);
+	return domid;
+}
+
+int convert_dev_name_to_num(char *name) {
+	char *p_sd, *p_hd, *p_xvd, *p_plx, *p, *alpha,*ptr;
+	int majors[10] = {3,22,33,34,56,57,88,89,90,91};
+	int maj,i;
+
+	asprintf(&p_sd,"/dev/sd");
+	asprintf(&p_hd,"/dev/hd");
+	asprintf(&p_xvd,"/dev/xvd");
+	asprintf(&p_plx,"plx");
+	asprintf(&alpha,"abcdefghijklmnop");
+	
+
+	if (strstr(name, p_sd) != NULL) {
+		p = name + strlen(p_sd);
+		for(i = 0, ptr = alpha; i < strlen(alpha); i++) {
+			if(*ptr == *p)
+				break;
+			*ptr++;
+		}
+		*p++;
+		return BASE_DEV_VAL + (16*i) + atoi(p);
+	} else if (strstr(name, p_hd) != NULL) {
+		p = name + strlen(p_hd);
+		for (i = 0, ptr = alpha; i < strlen(alpha); i++) {
+			if(*ptr == *p) break;
+			*ptr++;
+		}
+		*p++;
+		return (majors[i/2]*256) + atoi(p);
+
+	} else if (strstr(name, p_xvd) != NULL) {
+		p = name + strlen(p_xvd);
+		for(i = 0, ptr = alpha; i < strlen(alpha); i++) {
+			if(*ptr == *p) break;
+			*ptr++;
+		}
+		*p++;
+		return (202*256) + (16*i) + atoi(p);
+
+	} else if (strstr(name, p_plx) != NULL) {
+		p = name + strlen(p_plx);
+		return atoi(p);
+
+	} else {
+		DPRINTF("Unknown device type, setting to default.\n");
+		return BASE_DEV_VAL;
+	}
+	return 0;
+}
+
+/**
+ * A little paranoia: we don't just trust token. 
+ */
+static struct xenbus_watch *find_watch(const char *token)
+{
+	struct xenbus_watch *i, *cmp;
+	
+	cmp = (void *)strtoul(token, NULL, 16);
+	
+	list_for_each_entry(i, &watches, list)
+		if (i == cmp)
+			return i;
+	return NULL;
+}
+
+/**
+ * Register callback to watch this node. 
+ * like xs_watch, return 0 on failure 
+ */
+int register_xenbus_watch(struct xs_handle *h, struct xenbus_watch *watch)
+{
+	/* Pointer in ascii is the token. */
+	char token[sizeof(watch) * 2 + 1];
+	int er;
+	
+	sprintf(token, "%lX", (long)watch);
+	if (find_watch(token)) 
+	{
+		DPRINTF("watch collision!\n");
+		return -EINVAL;
+	}
+	
+	er = xs_watch(h, watch->node, token);
+	if (er != 0) {
+		list_add(&watch->list, &watches);
+	} 
+        
+	return er;
+}
+
+int unregister_xenbus_watch(struct xs_handle *h, struct xenbus_watch *watch)
+{
+	char token[sizeof(watch) * 2 + 1];
+	int er;
+	
+	sprintf(token, "%lX", (long)watch);
+	if (!find_watch(token))
+	{
+		DPRINTF("no such watch!\n");
+		return -EINVAL;
+	}
+	
+	
+	er = xs_unwatch(h, watch->node, token);
+	list_del(&watch->list);
+	
+	if (er == 0)
+		DPRINTF("XENBUS Failed to release watch %s: %i\n",
+		     watch->node, er);
+	return 0;
+}
+
+/**
+ * Re-register callbacks to all watches. 
+ */
+void reregister_xenbus_watches(struct xs_handle *h)
+{
+	struct xenbus_watch *watch;
+	char token[sizeof(watch) * 2 + 1];
+	
+	list_for_each_entry(watch, &watches, list) {
+		sprintf(token, "%lX", (long)watch);
+		xs_watch(h, watch->node, token);
+	}
+}
+
+/**
+ * based on watch_thread() 
+ */
+int xs_fire_next_watch(struct xs_handle *h)
+{
+	char **res;
+	char *token;
+	char *node = NULL;
+	struct xenbus_watch *w;
+	int er;
+	unsigned int num;
+	
+	res = xs_read_watch(h, &num);
+	if (res == NULL) 
+		return -EAGAIN; /* in O_NONBLOCK, read_watch returns 0... */
+	
+	node  = res[XS_WATCH_PATH];
+	token = res[XS_WATCH_TOKEN];
+	
+	w = find_watch(token);
+	if (!w)
+	{
+		DPRINTF("unregistered watch fired\n");
+		goto done;
+	}
+	w->callback(h, w, node);
+	
+ done:
+	free(res);
+	return 1;
+}
diff -urN xen-unstable-pristine.hg/tools/blktap/xs_api.h xen-unstable-tapbuild.hg/tools/blktap/xs_api.h
--- xen-unstable-pristine.hg/tools/blktap/xs_api.h	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/blktap/xs_api.h	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,50 @@
+/*
+ * xs_api.h
+ *
+ * (c) 2005 Andrew Warfield and Julian Chesterfield
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+struct xenbus_watch
+{
+        struct list_head list;
+        char *node;
+        void (*callback)(struct xs_handle *h, 
+                         struct xenbus_watch *, 
+                         const  char *node);
+};
+
+int xs_gather(struct xs_handle *xs, const char *dir, ...);
+int xs_printf(struct xs_handle *h, const char *dir, const char *node, 
+	      const char *fmt, ...);
+int xs_exists(struct xs_handle *h, const char *path);
+char *get_dom_domid(struct xs_handle *h, const char *name);
+int convert_dev_name_to_num(char *name);
+int register_xenbus_watch(struct xs_handle *h, struct xenbus_watch *watch);
+int unregister_xenbus_watch(struct xs_handle *h, struct xenbus_watch *watch);
+void reregister_xenbus_watches(struct xs_handle *h);
+int xs_fire_next_watch(struct xs_handle *h);
diff -urN xen-unstable-pristine.hg/tools/examples/blktap xen-unstable-tapbuild.hg/tools/examples/blktap
--- xen-unstable-pristine.hg/tools/examples/blktap	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/examples/blktap	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# Copyright (c) 2005, XenSource Ltd.
+
+dir=$(dirname "$0")
+. "$dir/xen-hotplug-common.sh"
+
+findCommand "$@"
+
+if [ "$command" == 'add' ]
+then
+ success
+fi
+
+exit 0
+
diff -urN xen-unstable-pristine.hg/tools/examples/Makefile xen-unstable-tapbuild.hg/tools/examples/Makefile
--- xen-unstable-pristine.hg/tools/examples/Makefile	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/examples/Makefile	2006-07-08 02:03:49.000000000 +0100
@@ -26,6 +26,7 @@
 XEN_SCRIPTS += network-nat vif-nat
 XEN_SCRIPTS += block
 XEN_SCRIPTS += block-enbd block-nbd
+XEN_SCRIPTS += blktap
 XEN_SCRIPTS += vtpm vtpm-delete vtpm-addtodb
 XEN_SCRIPTS += xen-hotplug-cleanup
 XEN_SCRIPTS += external-device-migrate
diff -urN xen-unstable-pristine.hg/tools/examples/xen-backend.agent xen-unstable-tapbuild.hg/tools/examples/xen-backend.agent
--- xen-unstable-pristine.hg/tools/examples/xen-backend.agent	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/examples/xen-backend.agent	2006-07-08 02:03:49.000000000 +0100
@@ -7,6 +7,9 @@
 claim_lock xenbus_hotplug_global
 
 case "$XENBUS_TYPE" in
+  tap)
+    /etc/xen/scripts/blktap "$ACTION"
+    ;;
   vbd)
     /etc/xen/scripts/block "$ACTION"
     ;;
diff -urN xen-unstable-pristine.hg/tools/examples/xen-backend.rules xen-unstable-tapbuild.hg/tools/examples/xen-backend.rules
--- xen-unstable-pristine.hg/tools/examples/xen-backend.rules	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/examples/xen-backend.rules	2006-07-08 02:03:49.000000000 +0100
@@ -1,3 +1,4 @@
+SUBSYSTEM=="xen-backend", KERNEL=="tap*", RUN+="/etc/xen/scripts/blktap $env{ACTION}"
 SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block $env{ACTION}"
 SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}"
 SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} online"
diff -urN xen-unstable-pristine.hg/tools/Makefile xen-unstable-tapbuild.hg/tools/Makefile
--- xen-unstable-pristine.hg/tools/Makefile	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/Makefile	2006-07-08 02:03:49.000000000 +0100
@@ -16,6 +16,7 @@
 SUBDIRS-$(VTPM_TOOLS) += vtpm_manager
 SUBDIRS-$(VTPM_TOOLS) += vtpm
 SUBDIRS-y += xenstat
+SUBDIRS-y += blktap
 
 # These don't cross-compile
 ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
diff -urN xen-unstable-pristine.hg/tools/misc/xend xen-unstable-tapbuild.hg/tools/misc/xend
--- xen-unstable-pristine.hg/tools/misc/xend	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/misc/xend	2006-07-08 02:03:49.000000000 +0100
@@ -92,6 +92,10 @@
 def start_consoled():
     if os.fork() == 0:
         os.execvp('xenconsoled', ['xenconsoled'])
+
+def start_blktapctrl():
+    if os.fork() == 0:
+        os.execvp('blktapctrl', ['blktapctrl'])
             
 def main():
     try:
@@ -106,16 +110,19 @@
     elif sys.argv[1] == 'start':
         start_xenstored()
         start_consoled()
+	start_blktapctrl()
         return daemon.start()
     elif sys.argv[1] == 'trace_start':
         start_xenstored()
         start_consoled()
+        start_blktapctrl()
         return daemon.start(trace=1)
     elif sys.argv[1] == 'stop':
         return daemon.stop()
     elif sys.argv[1] == 'restart':
         start_xenstored()
         start_consoled()
+        start_blktapctrl()
         return daemon.stop() or daemon.start()
     elif sys.argv[1] == 'status':
         return daemon.status()
diff -urN xen-unstable-pristine.hg/tools/python/xen/xend/server/BlktapController.py xen-unstable-tapbuild.hg/tools/python/xen/xend/server/BlktapController.py
--- xen-unstable-pristine.hg/tools/python/xen/xend/server/BlktapController.py	1970-01-01 01:00:00.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/python/xen/xend/server/BlktapController.py	2006-07-08 02:03:49.000000000 +0100
@@ -0,0 +1,14 @@
+# Copyright (c) 2005, XenSource Ltd.
+
+
+from xen.xend.server.blkif import BlkifController
+
+
+class BlktapController(BlkifController):
+    def __init__(self, vm):
+        BlkifController.__init__(self, vm)
+        
+    def frontendRoot(self):
+        """@see DevController#frontendRoot"""
+        
+        return "%s/device/vbd" % self.vm.getDomainPath()
diff -urN xen-unstable-pristine.hg/tools/python/xen/xend/XendDomainInfo.py xen-unstable-tapbuild.hg/tools/python/xen/xend/XendDomainInfo.py
--- xen-unstable-pristine.hg/tools/python/xen/xend/XendDomainInfo.py	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/python/xen/xend/XendDomainInfo.py	2006-07-08 02:03:49.000000000 +0100
@@ -1699,6 +1699,7 @@
 
 
 from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, usbif
+from xen.xend.server.BlktapController import BlktapController
 addControllerClass('vbd',  blkif.BlkifController)
 addControllerClass('vif',  netif.NetifController)
 addControllerClass('vtpm', tpmif.TPMifController)
@@ -1706,3 +1707,4 @@
 addControllerClass('ioports', iopif.IOPortsController)
 addControllerClass('irq',  irqif.IRQController)
 addControllerClass('usb',  usbif.UsbifController)
+addControllerClass('tap',  BlktapController)
diff -urN xen-unstable-pristine.hg/tools/python/xen/xm/create.py xen-unstable-tapbuild.hg/tools/python/xen/xm/create.py
--- xen-unstable-pristine.hg/tools/python/xen/xm/create.py	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/python/xen/xm/create.py	2006-07-08 02:03:49.000000000 +0100
@@ -478,7 +478,13 @@
     """Create the config for disks (virtual block devices).
     """
     for (uname, dev, mode, backend) in vals.disk:
-        config_vbd = ['vbd',
+
+        if uname.startswith('tap:'):
+            cls = 'tap'
+        else:
+            cls = 'vbd'
+
+        config_vbd = [cls,
                       ['uname', uname],
                       ['dev', dev ],
                       ['mode', mode ] ]
diff -urN xen-unstable-pristine.hg/tools/python/xen/xm/main.py xen-unstable-tapbuild.hg/tools/python/xen/xm/main.py
--- xen-unstable-pristine.hg/tools/python/xen/xm/main.py	2006-07-07 14:21:02.000000000 +0100
+++ xen-unstable-tapbuild.hg/tools/python/xen/xm/main.py	2006-07-08 02:03:49.000000000 +0100
@@ -985,7 +985,13 @@
     arg_check(args, 'block-attach', 4, 5)
 
     dom = args[0]
-    vbd = ['vbd',
+
+    if args[1].startswith('tap:'):
+        cls = 'tap'
+    else:
+        cls = 'vbd'
+        
+    vbd = [cls,
            ['uname', args[1]],
            ['dev',   args[2]],
            ['mode',  args[3]]]
diff -urN xen-unstable-pristine.hg/xen/common/grant_table.c xen-unstable-tapbuild.hg/xen/common/grant_table.c
--- xen-unstable-pristine.hg/xen/common/grant_table.c	2006-07-07 14:20:43.000000000 +0100
+++ xen-unstable-tapbuild.hg/xen/common/grant_table.c	2006-07-08 02:03:48.000000000 +0100
@@ -110,8 +110,7 @@
         return;
     }
 
-    if ( unlikely((rd = find_domain_by_id(op->dom)) == NULL) ||
-         unlikely(ld == rd) )
+    if ( unlikely((rd = find_domain_by_id(op->dom)) == NULL) )
     {
         if ( rd != NULL )
             put_domain(rd);
@@ -350,8 +349,7 @@
     ref   = map->ref;
     flags = map->flags;
 
-    if ( unlikely((rd = find_domain_by_id(dom)) == NULL) ||
-         unlikely(ld == rd) )
+    if ( unlikely((rd = find_domain_by_id(dom)) == NULL) )
     {
         if ( rd != NULL )
             put_domain(rd);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 2%]

* [PATCH 0/6] xen,xend,tools: NUMA support for Xen
@ 2006-07-11 15:35 20% Ryan Harper
  0 siblings, 0 replies; 200+ results
From: Ryan Harper @ 2006-07-11 15:35 UTC (permalink / raw)
  To: xen-devel

Reposting the latest patches, no significant changes since May when I
last received feedback.  I've done some simple overhead and performance
numbers for these patches.

Measuring NUMA allocator patch overhead via balloon driver and DOM0
involved starting DOM0 with all memory (4G) and ballooning down (256M)
as a starting point, [1]tracking the time it takes to balloon back up
to full memory.  The test was done with and without NUMA patches.

With NUMA:

Try1: 911ms
Try2: 907ms
Try3: 910ms

Without NUMA:

Try1: 606ms
Try2: 604ms
Try3: 608ms


Measuring NUMA allocator patch overhead via increase_reservation memory op
during domain creation we [2]modified the increase_reservation op to
track the time using get_s_time() from start to finish and sampled the
times for various memory sizes.

With NUMA:

MemSize  128M 512M 1G   2G    3G    
-------------------------------------
Try1:    6ms  26ms 53ms 221ms 390ms
Try2:    6ms  26ms 48ms 212ms 390ms
Try3:    6ms  26ms 48ms 212ms 390ms

Without NUMA:
MemSize  128M 512M 1G   2G    3G    
-------------------------------------
Try1:    4ms  16ms 25ms 70ms  100ms
Try2:    3ms  14ms 28ms 56ms  109ms
Try3:    3ms  14ms 23ms 56ms   95ms


Using a microbenchmark which mallocs memory and touches each byte, we
can observe the affects of local memory versus remote.  The domain is
created with 1GB memory, and 1 VCPU coming from the same node.  The
microbenchmark forks off one child per-VCPU and malloc/memsets 512M
buffer each.  We then compare worst-case (All non-local memory) and
best-case (all-local).

Machine Topology:
node_to_cpu            : node0:0
                         node1:1

Domain's memory placement
(bebop) tmp # xen_numastat -d 8
DOM8: NODE0: PAGES: 5
DOM8: NODE1: PAGES: 262144

Domain's vcpu placement
(bebop) tmp # xm vcpu-list 8
Name                              ID  VCPU  CPU  State  Time(s)  CPU
Affinity
hungerforce                        8     0    0   -b-      12.0  0

All-remote memory:
root@amd64-domU:/usr/src # while true; do ./memwrite -j1 -m512M; sleep 1; done
Time to write '0' to 512.000 MiB 1168711 usecs.  Throughput: 438.090 MiB/sec
Time to write '0' to 512.000 MiB 1175179 usecs.  Throughput: 435.678 MiB/sec
Time to write '0' to 512.000 MiB 1172454 usecs.  Throughput: 436.691 MiB/sec
Time to write '0' to 512.000 MiB 1170378 usecs.  Throughput: 437.466 MiB/sec

Domain's vcpu placement
(bebop) tmp # xm vcpu-list 8
Name                              ID  VCPU  CPU  State  Time(s)  CPU
Affinity
hungerforce                        8     0    0   -b-      15.9  1

All-local memory:
root@amd64-domU:/usr/src # while true; do ./memwrite -j1 -m512M; sleep 1; done
Time to write '0' to 512.000 MiB 759186 usecs.  Throughput: 674.406 MiB/sec
Time to write '0' to 512.000 MiB 765143 usecs.  Throughput: 669.156 MiB/sec
Time to write '0' to 512.000 MiB 768462 usecs.  Throughput: 666.266 MiB/sec
Time to write '0' to 512.000 MiB 763406 usecs.  Throughput: 670.679 MiB/sec


1.  diff -r ae245d35457b linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Jun 28 12:59:29 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Jun 26 14:54:10 2006
@@ -44,6 +44,7 @@
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
 #include <linux/vmalloc.h>
+#include <linux/time.h>
 #include <xen/xen_proc.h>
 #include <asm/hypervisor.h>
 #include <xen/balloon.h>
@@ -63,6 +64,9 @@
 #endif
 
 static DECLARE_MUTEX(balloon_mutex);
+
+static struct timeval start, stop, delay;
+static int calc_delay = 0;
 
 /*
  * Protects atomic reservation decrease/increase against concurrent increases.
@@ -337,6 +341,14 @@
 	return need_sleep;
 }
 
+/** Convert to milliseconds */
+static inline __u64 tv_to_ms(const struct timeval* tv)
+{
+        __u64 ms = tv->tv_usec / 1000;
+        ms += (__u64)tv->tv_sec * (__u64)1000;
+        return ms;
+}
+
 /*
  * We avoid multiple worker processes conflicting via the balloon mutex.
  * We may of course race updates of the target counts (which are protected
@@ -350,6 +362,11 @@
 
 	down(&balloon_mutex);
 
+	if (calc_delay) {
+		do_gettimeofday(&delay);
+		calc_delay = 0;
+	}
+ 
 	do {
 		credit = current_target() - current_pages;
 		if (credit > 0)
@@ -366,6 +383,13 @@
 	/* Schedule more work if there is some still to be done. */
 	if (current_target() != current_pages)
 		mod_timer(&balloon_timer, jiffies + HZ);
+	else {
+		/* We've hit target, notify completion */
+		do_gettimeofday(&stop);
+		printk(KERN_WARNING "Ballooning complete.  startup delay: %lums", 
+					tv_to_ms(&delay)-tv_to_ms(&start));
+		printk(" total time: %lums\n", tv_to_ms(&stop)-tv_to_ms(&start));
+	}
 
 	up(&balloon_mutex);
 }
@@ -376,6 +400,11 @@
 	/* No need for lock. Not read-modify-write updates. */
 	hard_limit   = ~0UL;
 	target_pages = target;
+
+	/* note start time of balloon process */
+	do_gettimeofday(&start);
+	calc_delay = 1;
+
 	schedule_work(&balloon_worker);
 }

2.  diff -r c257ac74b5c7 xen/common/memory.c
--- a/xen/common/memory.c	Tue Jul  4 16:31:13 2006
+++ b/xen/common/memory.c	Wed Jul  5 12:12:43 2006
@@ -27,6 +27,10 @@
  * high-order bits of the @cmd parameter, which are otherwise unused and zero.
  */
 #define START_EXTENT_SHIFT 4 /* cmd[:4] == start_extent */
+
+static int calc_start = 1;
+static unsigned long initial_extent;
+static s_time_t start, stop;
 
 static long
 increase_reservation(
@@ -574,6 +578,13 @@
         switch ( op )
         {
         case XENMEM_increase_reservation:
+            if ( calc_start ) {
+                 printk("WARK: calcing start time on IR of %lu pages\n",
+                         reservation.nr_extents);
+                 initial_extent = reservation.nr_extents;
+                 start = get_s_time();
+                 calc_start = 0;
+            }
             rc = increase_reservation(
                 d,
                 reservation.extent_start,
@@ -612,6 +623,12 @@
                 __HYPERVISOR_memory_op, "lh",
                 op | (rc << START_EXTENT_SHIFT), arg);
 
+        if ( op == XENMEM_increase_reservation ) {
+            stop = get_s_time();
+            printk("WARK: increase_reservation of %lu pages took->%lums\n", 
+                   initial_extent, ((u64)stop-(u64)start)/1000000 );
+            calc_start = 1;
+        }
         break;
 
     case XENMEM_exchange:
 
-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh@us.ibm.com

^ permalink raw reply	[relevance 20%]

* [RFC PATCH 32/33] Add the Xen virtual network device driver.
  @ 2006-07-18  7:00  4% ` Chris Wright
  2006-07-18 20:42  5%   ` David Miller
  0 siblings, 1 reply; 200+ results
From: Chris Wright @ 2006-07-18  7:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: virtualization, xen-devel, Jeremy Fitzhardinge, Andi Kleen,
	Andrew Morton, Rusty Russell, Zachary Amsden, Ian Pratt,
	Christian Limpach, netdev

[-- Attachment #1: netfront --]
[-- Type: text/plain, Size: 45072 bytes --]

The network device frontend driver allows the kernel to access network
devices exported exported by a virtual machine containing a physical
network device driver.

Signed-off-by: Ian Pratt <ian.pratt@xensource.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Cc: netdev@vger.kernel.org
---

 drivers/net/Kconfig             |    2
 drivers/xen/Kconfig.net         |   14
 drivers/xen/Makefile            |    3
 drivers/xen/net_driver_util.c   |   58 +
 drivers/xen/netfront/Makefile   |    4
 drivers/xen/netfront/netfront.c | 1326 ++++++++++++++++++++++++++++++++++++++++ include/xen/net_driver_util.h   |   48 +
 7 files changed, 1455 insertions(+)

diff -r eadc12b20f35 drivers/net/Kconfig
--- a/drivers/net/Kconfig	Fri Jun 09 15:02:44 2006 -0400
+++ b/drivers/net/Kconfig	Fri Jun 09 15:03:12 2006 -0400
@@ -2325,6 +2325,8 @@ source "drivers/atm/Kconfig"
 
 source "drivers/s390/net/Kconfig"
 
+source "drivers/xen/Kconfig.net"
+
 config ISERIES_VETH
 	tristate "iSeries Virtual Ethernet driver support"
 	depends on PPC_ISERIES
diff -r eadc12b20f35 drivers/xen/Makefile
--- a/drivers/xen/Makefile	Fri Jun 09 15:02:44 2006 -0400
+++ b/drivers/xen/Makefile	Fri Jun 09 15:03:12 2006 -0400
@@ -5,3 +5,5 @@ obj-y	+= console/
 obj-y	+= console/
 obj-y	+= xenbus/
 
+obj-$(CONFIG_XEN_NETDEV_FRONTEND)	+= netfront/
+
diff -r eadc12b20f35 drivers/xen/Kconfig.net
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/xen/Kconfig.net	Fri Jun 09 15:03:12 2006 -0400
@@ -0,0 +1,14 @@
+menu "Xen network device drivers"
+        depends on NETDEVICES && XEN
+
+config XEN_NETDEV_FRONTEND
+	tristate "Network-device frontend driver"
+	depends on XEN
+	default y
+	help
+	  The network-device frontend driver allows the kernel to access
+	  network interfaces within another guest OS. Unless you are building a
+	  dedicated device-driver domain, or your master control domain
+	  (domain 0), then you almost certainly want to say Y here.
+
+endmenu
diff -r eadc12b20f35 drivers/xen/netfront/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/xen/netfront/Makefile	Fri Jun 09 15:03:12 2006 -0400
@@ -0,0 +1,4 @@
+
+obj-$(CONFIG_XEN_NETDEV_FRONTEND)	:= xennet.o
+
+xennet-objs := netfront.o
diff -r eadc12b20f35 drivers/xen/netfront/netfront.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/xen/netfront/netfront.c	Fri Jun 09 15:03:12 2006 -0400
@@ -0,0 +1,1584 @@
+/******************************************************************************
+ * Virtual network driver for conversing with remote driver backends.
+ *
+ * Copyright (c) 2002-2005, K A Fraser
+ * Copyright (c) 2005, XenSource Ltd
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/netdevice.h>
+#include <linux/inetdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/init.h>
+#include <linux/bitops.h>
+#include <linux/ethtool.h>
+#include <linux/in.h>
+#include <linux/if_ether.h>
+#include <net/sock.h>
+#include <net/pkt_sched.h>
+#include <net/arp.h>
+#include <net/route.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <xen/evtchn.h>
+#include <xen/xenbus.h>
+#include <xen/interface/io/netif.h>
+#include <xen/interface/memory.h>
+#ifdef CONFIG_XEN_BALLOON
+#include <xen/balloon.h>
+#endif
+#include <asm/page.h>
+#include <asm/uaccess.h>
+#include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
+
+#define GRANT_INVALID_REF	0
+
+#define NET_TX_RING_SIZE __RING_SIZE((struct netif_tx_sring *)0, PAGE_SIZE)
+#define NET_RX_RING_SIZE __RING_SIZE((struct netif_rx_sring *)0, PAGE_SIZE)
+
+static inline void init_skb_shinfo(struct sk_buff *skb)
+{
+	atomic_set(&(skb_shinfo(skb)->dataref), 1);
+	skb_shinfo(skb)->nr_frags = 0;
+	skb_shinfo(skb)->frag_list = NULL;
+}
+
+struct netfront_info {
+	struct list_head list;
+	struct net_device *netdev;
+
+	struct net_device_stats stats;
+
+	struct netif_tx_front_ring tx;
+	struct netif_rx_front_ring rx;
+
+	spinlock_t   tx_lock;
+	spinlock_t   rx_lock;
+
+	unsigned int handle;
+	unsigned int evtchn, irq;
+
+	/* Receive-ring batched refills. */
+#define RX_MIN_TARGET 8
+#define RX_DFL_MIN_TARGET 64
+#define RX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
+	unsigned rx_min_target, rx_max_target, rx_target;
+	struct sk_buff_head rx_batch;
+
+	struct timer_list rx_refill_timer;
+
+	/*
+	 * {tx,rx}_skbs store outstanding skbuffs. The first entry in each
+	 * array is an index into a chain of free entries.
+	 */
+	struct sk_buff *tx_skbs[NET_TX_RING_SIZE+1];
+	struct sk_buff *rx_skbs[NET_RX_RING_SIZE+1];
+
+#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
+	grant_ref_t gref_tx_head;
+	grant_ref_t grant_tx_ref[NET_TX_RING_SIZE + 1];
+	grant_ref_t gref_rx_head;
+	grant_ref_t grant_rx_ref[NET_TX_RING_SIZE + 1];
+
+	struct xenbus_device *xbdev;
+	int tx_ring_ref;
+	int rx_ring_ref;
+	u8 mac[ETH_ALEN];
+
+	unsigned long rx_pfn_array[NET_RX_RING_SIZE];
+	struct multicall_entry rx_mcl[NET_RX_RING_SIZE+1];
+	struct mmu_update rx_mmu[NET_RX_RING_SIZE];
+};
+
+/*
+ * Access macros for acquiring freeing slots in {tx,rx}_skbs[].
+ */
+
+static inline void add_id_to_freelist(struct sk_buff **list, unsigned short id)
+{
+	list[id] = list[0];
+	list[0]  = (void *)(unsigned long)id;
+}
+
+static inline unsigned short get_id_from_freelist(struct sk_buff **list)
+{
+	unsigned int id = (unsigned int)(unsigned long)list[0];
+	list[0] = list[id];
+	return id;
+}
+
+#define DPRINTK(fmt, args...) pr_debug("netfront (%s:%d) " fmt, \
+                                       __FUNCTION__, __LINE__, ##args)
+#define IPRINTK(fmt, args...)				\
+	printk(KERN_INFO "netfront: " fmt, ##args)
+#define WPRINTK(fmt, args...)				\
+	printk(KERN_WARNING "netfront: " fmt, ##args)
+
+
+static int talk_to_backend(struct xenbus_device *, struct netfront_info *);
+static int setup_device(struct xenbus_device *, struct netfront_info *);
+static struct net_device *create_netdev(int, struct xenbus_device *);
+
+static void netfront_closing(struct xenbus_device *);
+
+static void end_access(int, void *);
+static void netif_disconnect_backend(struct netfront_info *);
+static void close_netdev(struct netfront_info *);
+static void netif_free(struct netfront_info *);
+
+static void show_device(struct netfront_info *);
+
+static void network_connect(struct net_device *);
+static void network_tx_buf_gc(struct net_device *);
+static void network_alloc_rx_buffers(struct net_device *);
+static int send_fake_arp(struct net_device *);
+
+static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs);
+
+#ifdef CONFIG_SYSFS
+static int xennet_sysfs_addif(struct net_device *netdev);
+static void xennet_sysfs_delif(struct net_device *netdev);
+#else /* !CONFIG_SYSFS */
+#define xennet_sysfs_addif(dev) (0)
+#define xennet_sysfs_delif(dev) do { } while(0)
+#endif
+
+static inline int xennet_can_sg(struct net_device *dev)
+{
+	return dev->features & NETIF_F_SG;
+}
+
+/**
+ * Entry point to this code when a new device is created.  Allocate the basic
+ * structures and the ring buffers for communication with the backend, and
+ * inform the backend of the appropriate details for those.  Switch to
+ * Connected state.
+ */
+static int __devinit netfront_probe(struct xenbus_device *dev,
+				    const struct xenbus_device_id *id)
+{
+	int err;
+	struct net_device *netdev;
+	struct netfront_info *info;
+	unsigned int handle;
+
+	err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%u", &handle);
+	if (err != 1) {
+		xenbus_dev_fatal(dev, err, "reading handle");
+		return err;
+	}
+
+	netdev = create_netdev(handle, dev);
+	if (IS_ERR(netdev)) {
+		err = PTR_ERR(netdev);
+		xenbus_dev_fatal(dev, err, "creating netdev");
+		return err;
+	}
+
+	info = netdev_priv(netdev);
+	dev->dev.driver_data = info;
+
+	err = talk_to_backend(dev, info);
+	if (err) {
+		xennet_sysfs_delif(info->netdev);
+		unregister_netdev(netdev);
+		free_netdev(netdev);
+		dev->dev.driver_data = NULL;
+		return err;
+	}
+
+	return 0;
+}
+
+
+/**
+ * We are reconnecting to the backend, due to a suspend/resume, or a backend
+ * driver restart.  We tear down our netif structure and recreate it, but
+ * leave the device-layer structures intact so that this is transparent to the
+ * rest of the kernel.
+ */
+static int netfront_resume(struct xenbus_device *dev)
+{
+	struct netfront_info *info = dev->dev.driver_data;
+
+	DPRINTK("%s\n", dev->nodename);
+
+	netif_disconnect_backend(info);
+	return talk_to_backend(dev, info);
+}
+
+static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
+{
+	char *s, *e, *macstr;
+	int i;
+
+	macstr = s = xenbus_read(XBT_NIL, dev->nodename, "mac", NULL);
+	if (IS_ERR(macstr))
+		return PTR_ERR(macstr);
+
+	for (i = 0; i < ETH_ALEN; i++) {
+		mac[i] = simple_strtoul(s, &e, 16);
+		if ((s == e) || (*e != ((i == ETH_ALEN-1) ? '\0' : ':'))) {
+			kfree(macstr);
+			return -ENOENT;
+		}
+		s = e+1;
+	}
+
+	kfree(macstr);
+	return 0;
+}
+
+/* Common code used when first setting up, and when resuming. */
+static int talk_to_backend(struct xenbus_device *dev,
+			   struct netfront_info *info)
+{
+	const char *message;
+	struct xenbus_transaction xbt;
+	int err;
+
+	err = xen_net_read_mac(dev, info->mac);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
+		goto out;
+	}
+
+	/* Create shared ring, alloc event channel. */
+	err = setup_device(dev, info);
+	if (err)
+		goto out;
+
+again:
+	err = xenbus_transaction_start(&xbt);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "starting transaction");
+		goto destroy_ring;
+	}
+
+	err = xenbus_printf(xbt, dev->nodename, "tx-ring-ref","%u",
+			    info->tx_ring_ref);
+	if (err) {
+		message = "writing tx ring-ref";
+		goto abort_transaction;
+	}
+	err = xenbus_printf(xbt, dev->nodename, "rx-ring-ref","%u",
+			    info->rx_ring_ref);
+	if (err) {
+		message = "writing rx ring-ref";
+		goto abort_transaction;
+	}
+	err = xenbus_printf(xbt, dev->nodename,
+			    "event-channel", "%u", info->evtchn);
+	if (err) {
+		message = "writing event-channel";
+		goto abort_transaction;
+	}
+
+	err = xenbus_transaction_end(xbt, 0);
+	if (err) {
+		if (err == -EAGAIN)
+			goto again;
+		xenbus_dev_fatal(dev, err, "completing transaction");
+		goto destroy_ring;
+	}
+
+	return 0;
+
+ abort_transaction:
+	xenbus_transaction_end(xbt, 1);
+	xenbus_dev_fatal(dev, err, "%s", message);
+ destroy_ring:
+	netif_free(info);
+ out:
+	return err;
+}
+
+
+static int setup_device(struct xenbus_device *dev, struct netfront_info *info)
+{
+	struct netif_tx_sring *txs;
+	struct netif_rx_sring *rxs;
+	int err;
+	struct net_device *netdev = info->netdev;
+
+	info->tx_ring_ref = GRANT_INVALID_REF;
+	info->rx_ring_ref = GRANT_INVALID_REF;
+	info->rx.sring = NULL;
+	info->tx.sring = NULL;
+	info->irq = 0;
+
+	txs = (struct netif_tx_sring *)get_zeroed_page(GFP_KERNEL);
+	if (!txs) {
+		err = -ENOMEM;
+		xenbus_dev_fatal(dev, err, "allocating tx ring page");
+		goto fail;
+	}
+	SHARED_RING_INIT(txs);
+	FRONT_RING_INIT(&info->tx, txs, PAGE_SIZE);
+
+	err = xenbus_grant_ring(dev, virt_to_mfn(txs));
+	if (err < 0) {
+		free_page((unsigned long)txs);
+		goto fail;
+	}
+
+	info->tx_ring_ref = err;
+	rxs = (struct netif_rx_sring *)get_zeroed_page(GFP_KERNEL);
+	if (!rxs) {
+		err = -ENOMEM;
+		xenbus_dev_fatal(dev, err, "allocating rx ring page");
+		goto fail;
+	}
+	SHARED_RING_INIT(rxs);
+	FRONT_RING_INIT(&info->rx, rxs, PAGE_SIZE);
+
+	err = xenbus_grant_ring(dev, virt_to_mfn(rxs));
+	if (err < 0) {
+		free_page((unsigned long)rxs);
+		goto fail;
+	}
+	info->rx_ring_ref = err;
+
+	err = xenbus_alloc_evtchn(dev, &info->evtchn);
+	if (err)
+		goto fail;
+
+	memcpy(netdev->dev_addr, info->mac, ETH_ALEN);
+	err = bind_evtchn_to_irqhandler(info->evtchn, netif_int,
+					SA_SAMPLE_RANDOM, netdev->name, netdev);
+	if (err < 0)
+		goto fail;
+	info->irq = err;
+	return 0;
+
+ fail:
+	netif_free(info);
+	return err;
+}
+
+
+/**
+ * Callback received when the backend's state changes.
+ */
+static void backend_changed(struct xenbus_device *dev,
+			    enum xenbus_state backend_state)
+{
+	struct netfront_info *np = dev->dev.driver_data;
+	struct net_device *netdev = np->netdev;
+
+	DPRINTK("\n");
+
+	switch (backend_state) {
+	case XenbusStateInitialising:
+	case XenbusStateInitialised:
+	case XenbusStateConnected:
+	case XenbusStateUnknown:
+	case XenbusStateClosed:
+		break;
+
+	case XenbusStateInitWait:
+		network_connect(netdev);
+		xenbus_switch_state(dev, XenbusStateConnected);
+		(void)send_fake_arp(netdev);
+		show_device(np);
+		break;
+
+	case XenbusStateClosing:
+		netfront_closing(dev);
+		break;
+	}
+}
+
+
+/** Send a packet on a net device to encourage switches to learn the
+ * MAC. We send a fake ARP request.
+ *
+ * @param dev device
+ * @return 0 on success, error code otherwise
+ */
+static int send_fake_arp(struct net_device *dev)
+{
+	struct sk_buff *skb;
+	u32             src_ip, dst_ip;
+
+	dst_ip = INADDR_BROADCAST;
+	src_ip = inet_select_addr(dev, dst_ip, RT_SCOPE_LINK);
+
+	/* No IP? Then nothing to do. */
+	if (src_ip == 0)
+		return 0;
+
+	skb = arp_create(ARPOP_REPLY, ETH_P_ARP,
+			 dst_ip, dev, src_ip,
+			 /*dst_hw*/ NULL, /*src_hw*/ NULL,
+			 /*target_hw*/ dev->dev_addr);
+	if (skb == NULL)
+		return -ENOMEM;
+
+	return dev_queue_xmit(skb);
+}
+
+
+static int network_open(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+
+	memset(&np->stats, 0, sizeof(np->stats));
+
+	network_alloc_rx_buffers(dev);
+	np->rx.sring->rsp_event = np->rx.rsp_cons + 1;
+
+	netif_start_queue(dev);
+
+	return 0;
+}
+
+static inline int netfront_tx_slot_available(struct netfront_info *np)
+{
+	return RING_FREE_REQUESTS(&np->tx) >= MAX_SKB_FRAGS + 1;
+}
+
+static inline void network_maybe_wake_tx(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+
+	if (unlikely(netif_queue_stopped(dev)) &&
+	    netfront_tx_slot_available(np) &&
+	    likely(netif_running(dev)))
+		netif_wake_queue(dev);
+}
+
+static void network_tx_buf_gc(struct net_device *dev)
+{
+	RING_IDX cons, prod;
+	unsigned short id;
+	struct netfront_info *np = netdev_priv(dev);
+	struct sk_buff *skb;
+
+	if (unlikely(!netif_carrier_ok(dev)))
+		return;
+
+	do {
+		prod = np->tx.sring->rsp_prod;
+		rmb(); /* Ensure we see responses up to 'rp'. */
+
+		for (cons = np->tx.rsp_cons; cons != prod; cons++) {
+			id  = RING_GET_RESPONSE(&np->tx, cons)->id;
+			skb = np->tx_skbs[id];
+			if (unlikely(gnttab_query_foreign_access(
+				np->grant_tx_ref[id]) != 0)) {
+				printk(KERN_ALERT "network_tx_buf_gc: warning "
+				       "-- grant still in use by backend "
+				       "domain.\n");
+				break; /* bail immediately */
+			}
+			gnttab_end_foreign_access_ref(
+				np->grant_tx_ref[id], GNTMAP_readonly);
+			gnttab_release_grant_reference(
+				&np->gref_tx_head, np->grant_tx_ref[id]);
+			np->grant_tx_ref[id] = GRANT_INVALID_REF;
+			add_id_to_freelist(np->tx_skbs, id);
+			dev_kfree_skb_irq(skb);
+		}
+
+		np->tx.rsp_cons = prod;
+
+		/*
+		 * Set a new event, then check for race with update of tx_cons.
+		 * Note that it is essential to schedule a callback, no matter
+		 * how few buffers are pending. Even if there is space in the
+		 * transmit ring, higher layers may be blocked because too much
+		 * data is outstanding: in such cases notification from Xen is
+		 * likely to be the only kick that we'll get.
+		 */
+		np->tx.sring->rsp_event =
+			prod + ((np->tx.sring->req_prod - prod) >> 1) + 1;
+		mb();
+	} while ((cons == prod) && (prod != np->tx.sring->rsp_prod));
+
+	network_maybe_wake_tx(dev);
+}
+
+
+static void rx_refill_timeout(unsigned long data)
+{
+	struct net_device *dev = (struct net_device *)data;
+	netif_rx_schedule(dev);
+}
+
+
+static void network_alloc_rx_buffers(struct net_device *dev)
+{
+	unsigned short id;
+	struct netfront_info *np = netdev_priv(dev);
+	struct sk_buff *skb;
+	int i, batch_target;
+	RING_IDX req_prod = np->rx.req_prod_pvt;
+	struct xen_memory_reservation reservation;
+	grant_ref_t ref;
+
+	if (unlikely(!netif_carrier_ok(dev)))
+		return;
+
+	/*
+	 * Allocate skbuffs greedily, even though we batch updates to the
+	 * receive ring. This creates a less bursty demand on the memory
+	 * allocator, so should reduce the chance of failed allocation requests
+	 * both for ourself and for other kernel subsystems.
+	 */
+	batch_target = np->rx_target - (req_prod - np->rx.rsp_cons);
+	for (i = skb_queue_len(&np->rx_batch); i < batch_target; i++) {
+		/*
+		 * Subtract dev_alloc_skb headroom (16 bytes) and shared info
+		 * tailroom then round down to SKB_DATA_ALIGN boundary.
+		 */
+		skb = __dev_alloc_skb(
+			((PAGE_SIZE - sizeof(struct skb_shared_info)) &
+			 (-SKB_DATA_ALIGN(1))) - 16,
+			GFP_ATOMIC|__GFP_NOWARN);
+		if (skb == NULL) {
+			/* Any skbuffs queued for refill? Force them out. */
+			if (i != 0)
+				goto refill;
+			/* Could not allocate any skbuffs. Try again later. */
+			mod_timer(&np->rx_refill_timer,
+				  jiffies + (HZ/10));
+			return;
+		}
+		__skb_queue_tail(&np->rx_batch, skb);
+	}
+
+	/* Is the batch large enough to be worthwhile? */
+	if (i < (np->rx_target/2))
+		return;
+
+	/* Adjust our fill target if we risked running out of buffers. */
+	if (((req_prod - np->rx.sring->rsp_prod) < (np->rx_target / 4)) &&
+	    ((np->rx_target *= 2) > np->rx_max_target))
+		np->rx_target = np->rx_max_target;
+
+ refill:
+	for (i = 0; ; i++) {
+		if ((skb = __skb_dequeue(&np->rx_batch)) == NULL)
+			break;
+
+		skb->dev = dev;
+
+		id = get_id_from_freelist(np->rx_skbs);
+
+		np->rx_skbs[id] = skb;
+
+		RING_GET_REQUEST(&np->rx, req_prod + i)->id = id;
+		ref = gnttab_claim_grant_reference(&np->gref_rx_head);
+		BUG_ON((signed short)ref < 0);
+		np->grant_rx_ref[id] = ref;
+		gnttab_grant_foreign_transfer_ref(ref,
+						  np->xbdev->otherend_id,
+						  __pa(skb->head) >> PAGE_SHIFT);
+		RING_GET_REQUEST(&np->rx, req_prod + i)->gref = ref;
+		np->rx_pfn_array[i] = virt_to_mfn(skb->head);
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+			/* Remove this page before passing back to Xen. */
+			set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT,
+					    INVALID_P2M_ENTRY);
+			MULTI_update_va_mapping(np->rx_mcl+i,
+						(unsigned long)skb->head,
+						__pte(0), 0);
+		}
+#endif
+	}
+
+#ifdef CONFIG_XEN_BALLOON
+	/* Tell the ballon driver what is going on. */
+	balloon_update_driver_allowance(i);
+#endif
+
+	reservation.extent_start = np->rx_pfn_array;
+	reservation.nr_extents   = i;
+	reservation.extent_order = 0;
+	reservation.address_bits = 0;
+	reservation.domid        = DOMID_SELF;
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+		/* After all PTEs have been zapped, flush the TLB. */
+		np->rx_mcl[i-1].args[MULTI_UVMFLAGS_INDEX] =
+			UVMF_TLB_FLUSH|UVMF_ALL;
+
+		/* Give away a batch of pages. */
+		np->rx_mcl[i].op = __HYPERVISOR_memory_op;
+		np->rx_mcl[i].args[0] = XENMEM_decrease_reservation;
+		np->rx_mcl[i].args[1] = (unsigned long)&reservation;
+
+		/* Zap PTEs and give away pages in one big multicall. */
+		(void)HYPERVISOR_multicall(np->rx_mcl, i+1);
+
+		/* Check return status of HYPERVISOR_memory_op(). */
+		if (unlikely(np->rx_mcl[i].result != i))
+			panic("Unable to reduce memory reservation\n");
+	} else
+#endif
+		if (HYPERVISOR_memory_op(XENMEM_decrease_reservation,
+					 &reservation) != i)
+			panic("Unable to reduce memory reservation\n");
+
+	/* Above is a suitable barrier to ensure backend will see requests. */
+	np->rx.req_prod_pvt = req_prod + i;
+	RING_PUSH_REQUESTS(&np->rx);
+}
+
+
+static void xennet_make_frags(struct sk_buff *skb, struct net_device *dev,
+			      struct netif_tx_request *tx)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	char *data = skb->data;
+	unsigned long mfn;
+	RING_IDX prod = np->tx.req_prod_pvt;
+	int frags = skb_shinfo(skb)->nr_frags;
+	unsigned int offset = offset_in_page(data);
+	unsigned int len = skb_headlen(skb);
+	unsigned int id;
+	grant_ref_t ref;
+	int i;
+
+	while (len > PAGE_SIZE - offset) {
+		tx->size = PAGE_SIZE - offset;
+		tx->flags |= NETTXF_more_data;
+		len -= tx->size;
+		data += tx->size;
+		offset = 0;
+
+		id = get_id_from_freelist(np->tx_skbs);
+		np->tx_skbs[id] = skb_get(skb);
+		tx = RING_GET_REQUEST(&np->tx, prod++);
+		tx->id = id;
+		ref = gnttab_claim_grant_reference(&np->gref_tx_head);
+		BUG_ON((signed short)ref < 0);
+
+		mfn = virt_to_mfn(data);
+		gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id,
+						mfn, GNTMAP_readonly);
+
+		tx->gref = np->grant_tx_ref[id] = ref;
+		tx->offset = offset;
+		tx->size = len;
+		tx->flags = 0;
+	}
+
+	for (i = 0; i < frags; i++) {
+		skb_frag_t *frag = skb_shinfo(skb)->frags + i;
+
+		tx->flags |= NETTXF_more_data;
+
+		id = get_id_from_freelist(np->tx_skbs);
+		np->tx_skbs[id] = skb_get(skb);
+		tx = RING_GET_REQUEST(&np->tx, prod++);
+		tx->id = id;
+		ref = gnttab_claim_grant_reference(&np->gref_tx_head);
+		BUG_ON((signed short)ref < 0);
+
+		mfn = pfn_to_mfn(page_to_pfn(frag->page));
+		gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id,
+						mfn, GNTMAP_readonly);
+
+		tx->gref = np->grant_tx_ref[id] = ref;
+		tx->offset = frag->page_offset;
+		tx->size = frag->size;
+		tx->flags = 0;
+	}
+
+	np->tx.req_prod_pvt = prod;
+}
+  
+static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	unsigned short id;
+	struct netfront_info *np = netdev_priv(dev);
+	struct netif_tx_request *tx;
+	char *data = skb->data;
+	RING_IDX i;
+	grant_ref_t ref;
+	unsigned long mfn;
+	int notify;
+	int frags = skb_shinfo(skb)->nr_frags;
+	unsigned int offset = offset_in_page(data);
+	unsigned int len = skb_headlen(skb);
+
+	frags += (offset + len + PAGE_SIZE - 1) / PAGE_SIZE;
+	if (unlikely(frags > MAX_SKB_FRAGS + 1)) {
+		printk(KERN_ALERT "xennet: skb rides the rocket: %d frags\n",
+		       frags);
+		dump_stack();
+		goto drop;
+	}
+
+	spin_lock_irq(&np->tx_lock);
+
+	if (unlikely(!netif_carrier_ok(dev) ||
+		     (frags > 1 && !xennet_can_sg(dev)))) {
+		spin_unlock_irq(&np->tx_lock);
+		goto drop;
+	}
+
+	i = np->tx.req_prod_pvt;
+
+	id = get_id_from_freelist(np->tx_skbs);
+	np->tx_skbs[id] = skb;
+
+	tx = RING_GET_REQUEST(&np->tx, i);
+
+	tx->id   = id;
+	ref = gnttab_claim_grant_reference(&np->gref_tx_head);
+	BUG_ON((signed short)ref < 0);
+	mfn = virt_to_mfn(data);
+	gnttab_grant_foreign_access_ref(
+		ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);
+	tx->gref = np->grant_tx_ref[id] = ref;
+	tx->offset = offset;
+	tx->size = len;
+	tx->flags = (skb->ip_summed == CHECKSUM_HW) ? NETTXF_csum_blank : 0;
+
+	np->tx.req_prod_pvt = i + 1;
+
+	xennet_make_frags(skb, dev, tx);
+	tx->size = skb->len;
+
+	RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);
+	if (notify)
+		notify_remote_via_irq(np->irq);
+
+	network_tx_buf_gc(dev);
+
+	if (!netfront_tx_slot_available(np))
+		netif_stop_queue(dev);
+
+	spin_unlock_irq(&np->tx_lock);
+
+	np->stats.tx_bytes += skb->len;
+	np->stats.tx_packets++;
+
+	return 0;
+
+ drop:
+	np->stats.tx_dropped++;
+	dev_kfree_skb(skb);
+	return 0;
+}
+
+static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs)
+{
+	struct net_device *dev = dev_id;
+	struct netfront_info *np = netdev_priv(dev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&np->tx_lock, flags);
+	network_tx_buf_gc(dev);
+	spin_unlock_irqrestore(&np->tx_lock, flags);
+
+	if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx) &&
+	    likely(netif_running(dev)))
+		netif_rx_schedule(dev);
+
+	return IRQ_HANDLED;
+}
+
+
+static int netif_poll(struct net_device *dev, int *pbudget)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	struct sk_buff *skb, *nskb;
+	struct netif_rx_response *rx;
+	RING_IDX i, rp;
+	struct mmu_update *mmu = np->rx_mmu;
+	struct multicall_entry *mcl = np->rx_mcl;
+	int work_done, budget, more_to_do = 1;
+	struct sk_buff_head rxq;
+	unsigned long flags;
+	unsigned long mfn;
+	grant_ref_t ref;
+
+	spin_lock(&np->rx_lock);
+
+	if (unlikely(!netif_carrier_ok(dev))) {
+		spin_unlock(&np->rx_lock);
+		return 0;
+	}
+
+	skb_queue_head_init(&rxq);
+
+	if ((budget = *pbudget) > dev->quota)
+		budget = dev->quota;
+	rp = np->rx.sring->rsp_prod;
+	rmb(); /* Ensure we see queued responses up to 'rp'. */
+
+	for (i = np->rx.rsp_cons, work_done = 0;
+	     (i != rp) && (work_done < budget);
+	     i++, work_done++) {
+		rx = RING_GET_RESPONSE(&np->rx, i);
+
+		/*
+                 * This definitely indicates a bug, either in this driver or
+                 * in the backend driver. In future this should flag the bad
+                 * situation to the system controller to reboot the backed.
+                 */
+		if ((ref = np->grant_rx_ref[rx->id]) == GRANT_INVALID_REF) {
+			WPRINTK("Bad rx response id %d.\n", rx->id);
+			work_done--;
+			continue;
+		}
+
+		/* Memory pressure, insufficient buffer headroom, ... */
+		if ((mfn = gnttab_end_foreign_transfer_ref(ref)) == 0) {
+			if (net_ratelimit())
+				WPRINTK("Unfulfilled rx req (id=%d, st=%d).\n",
+					rx->id, rx->status);
+			RING_GET_REQUEST(&np->rx, np->rx.req_prod_pvt)->id =
+				rx->id;
+			RING_GET_REQUEST(&np->rx, np->rx.req_prod_pvt)->gref =
+				ref;
+			np->rx.req_prod_pvt++;
+			RING_PUSH_REQUESTS(&np->rx);
+			work_done--;
+			continue;
+		}
+
+		gnttab_release_grant_reference(&np->gref_rx_head, ref);
+		np->grant_rx_ref[rx->id] = GRANT_INVALID_REF;
+
+		skb = np->rx_skbs[rx->id];
+		add_id_to_freelist(np->rx_skbs, rx->id);
+
+		/* NB. We handle skb overflow later. */
+		skb->data = skb->head + rx->offset;
+		skb->len  = rx->status;
+		skb->tail = skb->data + skb->len;
+
+		if (rx->flags & NETRXF_data_validated)
+			skb->ip_summed = CHECKSUM_UNNECESSARY;
+
+		np->stats.rx_packets++;
+		np->stats.rx_bytes += rx->status;
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+			/* Remap the page. */
+			MULTI_update_va_mapping(mcl, (unsigned long)skb->head,
+						pfn_pte_ma(mfn, PAGE_KERNEL),
+						0);
+			mcl++;
+			mmu->ptr = ((maddr_t)mfn << PAGE_SHIFT)
+				| MMU_MACHPHYS_UPDATE;
+			mmu->val = __pa(skb->head) >> PAGE_SHIFT;
+			mmu++;
+
+			set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT,
+					    mfn);
+		}
+#endif
+
+		__skb_queue_tail(&rxq, skb);
+	}
+
+#ifdef CONFIG_XEN_BALLOON
+	/* Some pages are no longer absent... */
+	balloon_update_driver_allowance(-work_done);
+#endif
+
+	/* Do all the remapping work, and M2P updates, in one big hypercall. */
+	if (likely((mcl - np->rx_mcl) != 0)) {
+		mcl->op = __HYPERVISOR_mmu_update;
+		mcl->args[0] = (unsigned long)np->rx_mmu;
+		mcl->args[1] = mmu - np->rx_mmu;
+		mcl->args[2] = 0;
+		mcl->args[3] = DOMID_SELF;
+		mcl++;
+		(void)HYPERVISOR_multicall(np->rx_mcl, mcl - np->rx_mcl);
+	}
+
+	while ((skb = __skb_dequeue(&rxq)) != NULL) {
+		if (skb->len > (dev->mtu + ETH_HLEN + 4)) {
+			if (net_ratelimit())
+				printk(KERN_INFO "Received packet too big for "
+				       "MTU (%d > %d)\n",
+				       skb->len - ETH_HLEN - 4, dev->mtu);
+			skb->len  = 0;
+			skb->tail = skb->data;
+			init_skb_shinfo(skb);
+			dev_kfree_skb(skb);
+			continue;
+		}
+
+		/*
+		 * Enough room in skbuff for the data we were passed? Also,
+		 * Linux expects at least 16 bytes headroom in each rx buffer.
+		 */
+		if (unlikely(skb->tail > skb->end) ||
+		    unlikely((skb->data - skb->head) < 16)) {
+			if (net_ratelimit()) {
+				if (skb->tail > skb->end)
+					printk(KERN_INFO "Received packet "
+					       "is %zd bytes beyond tail.\n",
+					       skb->tail - skb->end);
+				else
+					printk(KERN_INFO "Received packet "
+					       "is %zd bytes before head.\n",
+					       16 - (skb->data - skb->head));
+			}
+
+			nskb = __dev_alloc_skb(skb->len + 2,
+					       GFP_ATOMIC|__GFP_NOWARN);
+			if (nskb != NULL) {
+				skb_reserve(nskb, 2);
+				skb_put(nskb, skb->len);
+				memcpy(nskb->data, skb->data, skb->len);
+				nskb->dev = skb->dev;
+				nskb->ip_summed = skb->ip_summed;
+			}
+
+			/* Reinitialise and then destroy the old skbuff. */
+			skb->len  = 0;
+			skb->tail = skb->data;
+			init_skb_shinfo(skb);
+			dev_kfree_skb(skb);
+
+			/* Switch old for new, if we copied the buffer. */
+			if ((skb = nskb) == NULL)
+				continue;
+		}
+
+		/* Set the shinfo area, which is hidden behind the data. */
+		init_skb_shinfo(skb);
+		/* Ethernet work: Delayed to here as it peeks the header. */
+		skb->protocol = eth_type_trans(skb, dev);
+
+		/* Pass it up. */
+		netif_receive_skb(skb);
+		dev->last_rx = jiffies;
+	}
+
+	np->rx.rsp_cons = i;
+
+	/* If we get a callback with very few responses, reduce fill target. */
+	/* NB. Note exponential increase, linear decrease. */
+	if (((np->rx.req_prod_pvt - np->rx.sring->rsp_prod) >
+	     ((3*np->rx_target) / 4)) &&
+	    (--np->rx_target < np->rx_min_target))
+		np->rx_target = np->rx_min_target;
+
+	network_alloc_rx_buffers(dev);
+
+	*pbudget   -= work_done;
+	dev->quota -= work_done;
+
+	if (work_done < budget) {
+		local_irq_save(flags);
+
+		RING_FINAL_CHECK_FOR_RESPONSES(&np->rx, more_to_do);
+		if (!more_to_do)
+			__netif_rx_complete(dev);
+
+		local_irq_restore(flags);
+	}
+
+	spin_unlock(&np->rx_lock);
+
+	return more_to_do;
+}
+
+
+static int network_close(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	netif_stop_queue(np->netdev);
+	return 0;
+}
+
+
+static struct net_device_stats *network_get_stats(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	return &np->stats;
+}
+
+static int xennet_change_mtu(struct net_device *dev, int mtu)
+{
+	int max = xennet_can_sg(dev) ? 65535 - ETH_HLEN : ETH_DATA_LEN;
+
+	if (mtu > max)
+		return -EINVAL;
+	dev->mtu = mtu;
+	return 0;
+}
+
+static int xennet_set_sg(struct net_device *dev, u32 data)
+{
+	if (data) {
+		struct netfront_info *np = netdev_priv(dev);
+		int val;
+
+		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg",
+				 "%d", &val) < 0)
+			val = 0;
+		if (!val)
+			return -ENOSYS;
+	} else if (dev->mtu > ETH_DATA_LEN)
+		dev->mtu = ETH_DATA_LEN;
+
+	return ethtool_op_set_sg(dev, data);
+}
+
+static void xennet_set_features(struct net_device *dev)
+{
+	xennet_set_sg(dev, 1);
+}
+
+static void network_connect(struct net_device *dev)
+{
+	struct netfront_info *np;
+	int i, requeue_idx;
+	struct netif_tx_request *tx;
+	struct sk_buff *skb;
+
+	xennet_set_features(dev);
+
+	np = netdev_priv(dev);
+	spin_lock_irq(&np->tx_lock);
+	spin_lock(&np->rx_lock);
+
+	/* Recovery procedure: */
+
+	/*
+	 * Step 1: Rebuild the RX and TX ring contents.
+	 * NB. We could just free the queued TX packets now but we hope
+	 * that sending them out might do some good.  We have to rebuild
+	 * the RX ring because some of our pages are currently flipped out
+	 * so we can't just free the RX skbs.
+	 * NB2. Freelist index entries are always going to be less than
+	 *  PAGE_OFFSET, whereas pointers to skbs will always be equal or
+	 * greater than PAGE_OFFSET: we use this property to distinguish
+	 * them.
+	 */
+
+	/*
+	 * Rebuild the TX buffer freelist and the TX ring itself.
+	 * NB. This reorders packets.  We could keep more private state
+	 * to avoid this but maybe it doesn't matter so much given the
+	 * interface has been down.
+	 */
+	for (requeue_idx = 0, i = 1; i <= NET_TX_RING_SIZE; i++) {
+		if ((unsigned long)np->tx_skbs[i] < PAGE_OFFSET)
+			continue;
+
+		skb = np->tx_skbs[i];
+
+		tx = RING_GET_REQUEST(&np->tx, requeue_idx);
+		requeue_idx++;
+
+		tx->id = i;
+		gnttab_grant_foreign_access_ref(
+			np->grant_tx_ref[i], np->xbdev->otherend_id,
+			virt_to_mfn(np->tx_skbs[i]->data),
+			GNTMAP_readonly);
+		tx->gref = np->grant_tx_ref[i];
+		tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
+		tx->size = skb->len;
+		tx->flags = (skb->ip_summed == CHECKSUM_HW) ?
+			NETTXF_csum_blank : 0;
+
+		np->stats.tx_bytes += skb->len;
+		np->stats.tx_packets++;
+	}
+
+	np->tx.req_prod_pvt = requeue_idx;
+	RING_PUSH_REQUESTS(&np->tx);
+
+	/* Rebuild the RX buffer freelist and the RX ring itself. */
+	for (requeue_idx = 0, i = 1; i <= NET_RX_RING_SIZE; i++) {
+		if ((unsigned long)np->rx_skbs[i] < PAGE_OFFSET)
+			continue;
+		gnttab_grant_foreign_transfer_ref(
+			np->grant_rx_ref[i], np->xbdev->otherend_id,
+			__pa(np->rx_skbs[i]->data) >> PAGE_SHIFT);
+		RING_GET_REQUEST(&np->rx, requeue_idx)->gref =
+			np->grant_rx_ref[i];
+		RING_GET_REQUEST(&np->rx, requeue_idx)->id = i;
+		requeue_idx++;
+	}
+
+	np->rx.req_prod_pvt = requeue_idx;
+	RING_PUSH_REQUESTS(&np->rx);
+
+	/*
+	 * Step 2: All public and private state should now be sane.  Get
+	 * ready to start sending and receiving packets and give the driver
+	 * domain a kick because we've probably just requeued some
+	 * packets.
+	 */
+	netif_carrier_on(dev);
+	notify_remote_via_irq(np->irq);
+	network_tx_buf_gc(dev);
+
+	spin_unlock(&np->rx_lock);
+	spin_unlock_irq(&np->tx_lock);
+}
+
+static void show_device(struct netfront_info *np)
+{
+#ifdef DEBUG
+	if (np) {
+		IPRINTK("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\n",
+			np->handle,
+			netif_carrier_ok(np->netdev) ? "on" : "off",
+			netif_running(np->netdev) ? "open" : "closed",
+			np->evtchn,
+			np->tx,
+			np->rx);
+	} else
+		IPRINTK("<vif NULL>\n");
+#endif
+}
+
+static void netif_uninit(struct net_device *dev)
+{
+	struct netfront_info *np = netdev_priv(dev);
+	gnttab_free_grant_references(np->gref_tx_head);
+	gnttab_free_grant_references(np->gref_rx_head);
+}
+
+static struct ethtool_ops network_ethtool_ops =
+{
+	.get_tx_csum = ethtool_op_get_tx_csum,
+	.set_tx_csum = ethtool_op_set_tx_csum,
+	.get_sg = ethtool_op_get_sg,
+	.set_sg = xennet_set_sg,
+};
+
+/*
+ * Nothing to do here. Virtual interface is point-to-point and the
+ * physical interface is probably promiscuous anyway.
+ */
+static void network_set_multicast_list(struct net_device *dev)
+{
+}
+
+/** Create a network device.
+ * @param handle device handle
+ * @param val return parameter for created device
+ * @return 0 on success, error code otherwise
+ */
+static struct net_device * __devinit create_netdev(int handle,
+						   struct xenbus_device *dev)
+{
+	int i, err = 0;
+	struct net_device *netdev = NULL;
+	struct netfront_info *np = NULL;
+
+	netdev = alloc_etherdev(sizeof(struct netfront_info));
+	if (!netdev) {
+		printk(KERN_WARNING "%s> alloc_etherdev failed.\n",
+		       __FUNCTION__);
+		return ERR_PTR(-ENOMEM);
+	}
+
+	np                = netdev_priv(netdev);
+	np->handle        = handle;
+	np->xbdev         = dev;
+
+	netif_carrier_off(netdev);
+
+	spin_lock_init(&np->tx_lock);
+	spin_lock_init(&np->rx_lock);
+
+	skb_queue_head_init(&np->rx_batch);
+	np->rx_target     = RX_DFL_MIN_TARGET;
+	np->rx_min_target = RX_DFL_MIN_TARGET;
+	np->rx_max_target = RX_MAX_TARGET;
+
+	init_timer(&np->rx_refill_timer);
+	np->rx_refill_timer.data = (unsigned long)netdev;
+	np->rx_refill_timer.function = rx_refill_timeout;
+
+	/* Initialise {tx,rx}_skbs as a free chain containing every entry. */
+	for (i = 0; i <= NET_TX_RING_SIZE; i++) {
+		np->tx_skbs[i] = (void *)((unsigned long) i+1);
+		np->grant_tx_ref[i] = GRANT_INVALID_REF;
+	}
+
+	for (i = 0; i <= NET_RX_RING_SIZE; i++) {
+		np->rx_skbs[i] = (void *)((unsigned long) i+1);
+		np->grant_rx_ref[i] = GRANT_INVALID_REF;
+	}
+
+	/* A grant for every tx ring slot */
+	if (gnttab_alloc_grant_references(TX_MAX_TARGET,
+					  &np->gref_tx_head) < 0) {
+		printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n");
+		err = -ENOMEM;
+		goto exit;
+	}
+	/* A grant for every rx ring slot */
+	if (gnttab_alloc_grant_references(RX_MAX_TARGET,
+					  &np->gref_rx_head) < 0) {
+		printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
+		err = -ENOMEM;
+		goto exit_free_tx;
+	}
+
+	netdev->open            = network_open;
+	netdev->hard_start_xmit = network_start_xmit;
+	netdev->stop            = network_close;
+	netdev->get_stats       = network_get_stats;
+	netdev->poll            = netif_poll;
+	netdev->set_multicast_list = network_set_multicast_list;
+	netdev->uninit          = netif_uninit;
+	netdev->change_mtu	= xennet_change_mtu;
+	netdev->weight          = 64;
+	netdev->features        = NETIF_F_IP_CSUM;
+
+	SET_ETHTOOL_OPS(netdev, &network_ethtool_ops);
+	SET_MODULE_OWNER(netdev);
+	SET_NETDEV_DEV(netdev, &dev->dev);
+
+	err = register_netdev(netdev);
+	if (err) {
+		printk(KERN_WARNING "%s> register_netdev err=%d\n",
+		       __FUNCTION__, err);
+		goto exit_free_rx;
+	}
+
+	err = xennet_sysfs_addif(netdev);
+	if (err) {
+		/* This can be non-fatal: it only means no tuning parameters */
+		printk(KERN_WARNING "%s> add sysfs failed err=%d\n",
+		       __FUNCTION__, err);
+	}
+
+	np->netdev = netdev;
+
+	return netdev;
+
+ exit_free_rx:
+	gnttab_free_grant_references(np->gref_rx_head);
+ exit_free_tx:
+	gnttab_free_grant_references(np->gref_tx_head);
+ exit:
+	free_netdev(netdev);
+	return ERR_PTR(err);
+}
+
+#ifdef CONFIG_SYSFS
+static ssize_t show_rxbuf_min(struct class_device *cd, char *buf)
+{
+	struct net_device *netdev = container_of(cd, struct net_device,
+						 class_dev);
+	struct netfront_info *info = netdev_priv(netdev);
+
+	return sprintf(buf, "%u\n", info->rx_min_target);
+}
+
+static ssize_t store_rxbuf_min(struct class_device *cd,
+			       const char *buf, size_t len)
+{
+	struct net_device *netdev = container_of(cd, struct net_device,
+						 class_dev);
+	struct netfront_info *np = netdev_priv(netdev);
+	char *endp;
+	unsigned long target;
+
+	if (!capable(CAP_NET_ADMIN))
+		return -EPERM;
+
+	target = simple_strtoul(buf, &endp, 0);
+	if (endp == buf)
+		return -EBADMSG;
+
+	if (target < RX_MIN_TARGET)
+		target = RX_MIN_TARGET;
+	if (target > RX_MAX_TARGET)
+		target = RX_MAX_TARGET;
+
+	spin_lock(&np->rx_lock);
+	if (target > np->rx_max_target)
+		np->rx_max_target = target;
+	np->rx_min_target = target;
+	if (target > np->rx_target)
+		np->rx_target = target;
+
+	network_alloc_rx_buffers(netdev);
+
+	spin_unlock(&np->rx_lock);
+	return len;
+}
+
+static ssize_t show_rxbuf_max(struct class_device *cd, char *buf)
+{
+	struct net_device *netdev = container_of(cd, struct net_device,
+						 class_dev);
+	struct netfront_info *info = netdev_priv(netdev);
+
+	return sprintf(buf, "%u\n", info->rx_max_target);
+}
+
+static ssize_t store_rxbuf_max(struct class_device *cd,
+			       const char *buf, size_t len)
+{
+	struct net_device *netdev = container_of(cd, struct net_device,
+						 class_dev);
+	struct netfront_info *np = netdev_priv(netdev);
+	char *endp;
+	unsigned long target;
+
+	if (!capable(CAP_NET_ADMIN))
+		return -EPERM;
+
+	target = simple_strtoul(buf, &endp, 0);
+	if (endp == buf)
+		return -EBADMSG;
+
+	if (target < RX_MIN_TARGET)
+		target = RX_MIN_TARGET;
+	if (target > RX_MAX_TARGET)
+		target = RX_MAX_TARGET;
+
+	spin_lock(&np->rx_lock);
+	if (target < np->rx_min_target)
+		np->rx_min_target = target;
+	np->rx_max_target = target;
+	if (target < np->rx_target)
+		np->rx_target = target;
+
+	network_alloc_rx_buffers(netdev);
+
+	spin_unlock(&np->rx_lock);
+	return len;
+}
+
+static ssize_t show_rxbuf_cur(struct class_device *cd, char *buf)
+{
+	struct net_device *netdev = container_of(cd, struct net_device,
+						 class_dev);
+	struct netfront_info *info = netdev_priv(netdev);
+
+	return sprintf(buf, "%u\n", info->rx_target);
+}
+
+static const struct class_device_attribute xennet_attrs[] = {
+	__ATTR(rxbuf_min, S_IRUGO|S_IWUSR, show_rxbuf_min, store_rxbuf_min),
+	__ATTR(rxbuf_max, S_IRUGO|S_IWUSR, show_rxbuf_max, store_rxbuf_max),
+	__ATTR(rxbuf_cur, S_IRUGO, show_rxbuf_cur, NULL),
+};
+
+static int xennet_sysfs_addif(struct net_device *netdev)
+{
+	int i;
+	int error = 0;
+
+	for (i = 0; i < ARRAY_SIZE(xennet_attrs); i++) {
+		error = class_device_create_file(&netdev->class_dev, 
+						 &xennet_attrs[i]);
+		if (error)
+			goto fail;
+	}
+	return 0;
+
+ fail:
+	while (--i >= 0)
+		class_device_remove_file(&netdev->class_dev,
+					 &xennet_attrs[i]);
+	return error;
+}
+
+static void xennet_sysfs_delif(struct net_device *netdev)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(xennet_attrs); i++) {
+		class_device_remove_file(&netdev->class_dev,
+					 &xennet_attrs[i]);
+	}
+}
+
+#endif /* CONFIG_SYSFS */
+
+
+/*
+ * We use this notifier to send out a fake ARP reply to reset switches and
+ * router ARP caches when an IP interface is brought up on a VIF.
+ */
+static int
+inetdev_notify(struct notifier_block *this, unsigned long event, void *ptr)
+{
+	struct in_ifaddr  *ifa = (struct in_ifaddr *)ptr;
+	struct net_device *dev = ifa->ifa_dev->dev;
+
+	/* UP event and is it one of our devices? */
+	if (event == NETDEV_UP && dev->open == network_open)
+		(void)send_fake_arp(dev);
+
+	return NOTIFY_DONE;
+}
+
+
+/* ** Close down ** */
+
+
+/**
+ * Handle the change of state of the backend to Closing.  We must delete our
+ * device-layer structures now, to ensure that writes are flushed through to
+ * the backend.  Once is this done, we can switch to Closed in
+ * acknowledgement.
+ */
+static void netfront_closing(struct xenbus_device *dev)
+{
+	struct netfront_info *info = dev->dev.driver_data;
+
+	DPRINTK("netfront_closing: %s removed\n", dev->nodename);
+
+	close_netdev(info);
+
+	xenbus_switch_state(dev, XenbusStateClosed);
+}
+
+
+static int __devexit netfront_remove(struct xenbus_device *dev)
+{
+	struct netfront_info *info = dev->dev.driver_data;
+
+	DPRINTK("%s\n", dev->nodename);
+
+	netif_disconnect_backend(info);
+	free_netdev(info->netdev);
+
+	return 0;
+}
+
+
+static void close_netdev(struct netfront_info *info)
+{
+	del_timer_sync(&info->rx_refill_timer);
+
+	xennet_sysfs_delif(info->netdev);
+	unregister_netdev(info->netdev);
+}
+
+
+static void netif_disconnect_backend(struct netfront_info *info)
+{
+	/* Stop old i/f to prevent errors whilst we rebuild the state. */
+	spin_lock_irq(&info->tx_lock);
+	spin_lock(&info->rx_lock);
+	netif_carrier_off(info->netdev);
+	spin_unlock(&info->rx_lock);
+	spin_unlock_irq(&info->tx_lock);
+
+	if (info->irq)
+		unbind_from_irqhandler(info->irq, info->netdev);
+	info->evtchn = info->irq = 0;
+
+	end_access(info->tx_ring_ref, info->tx.sring);
+	end_access(info->rx_ring_ref, info->rx.sring);
+	info->tx_ring_ref = GRANT_INVALID_REF;
+	info->rx_ring_ref = GRANT_INVALID_REF;
+	info->tx.sring = NULL;
+	info->rx.sring = NULL;
+}
+
+
+static void netif_free(struct netfront_info *info)
+{
+	close_netdev(info);
+	netif_disconnect_backend(info);
+	free_netdev(info->netdev);
+}
+
+
+static void end_access(int ref, void *page)
+{
+	if (ref != GRANT_INVALID_REF)
+		gnttab_end_foreign_access(ref, 0, (unsigned long)page);
+}
+
+
+/* ** Driver registration ** */
+
+
+static struct xenbus_device_id netfront_ids[] = {
+	{ "vif" },
+	{ "" }
+};
+
+
+static struct xenbus_driver netfront = {
+	.name = "vif",
+	.owner = THIS_MODULE,
+	.ids = netfront_ids,
+	.probe = netfront_probe,
+	.remove = __devexit_p(netfront_remove),
+	.resume = netfront_resume,
+	.otherend_changed = backend_changed,
+};
+
+
+static struct notifier_block notifier_inetdev = {
+	.notifier_call  = inetdev_notify,
+};
+
+static int __init netif_init(void)
+{
+	if (xen_start_info->flags & SIF_INITDOMAIN)
+		return 0;
+
+	IPRINTK("Initialising virtual ethernet driver.\n");
+
+	(void)register_inetaddr_notifier(&notifier_inetdev);
+
+	return xenbus_register_frontend(&netfront);
+}
+module_init(netif_init);
+
+
+static void __exit netif_exit(void)
+{
+	unregister_inetaddr_notifier(&notifier_inetdev);
+
+	return xenbus_unregister_driver(&netfront);
+}
+module_exit(netif_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");

--

^ permalink raw reply	[relevance 4%]

* Re: [RFC PATCH 32/33] Add the Xen virtual network device driver.
  2006-07-18  7:00  4% ` [RFC PATCH 32/33] Add the Xen virtual network device driver Chris Wright
@ 2006-07-18 20:42  5%   ` David Miller
  2006-07-18 21:09  5%     ` Chris Wright
  0 siblings, 1 reply; 200+ results
From: David Miller @ 2006-07-18 20:42 UTC (permalink / raw)
  To: chrisw
  Cc: linux-kernel, virtualization, xen-devel, jeremy, ak, akpm, rusty,
	zach, ian.pratt, Christian.Limpach, netdev

From: Chris Wright <chrisw@sous-sol.org>
Date: Tue, 18 Jul 2006 00:00:32 -0700

> +#ifdef CONFIG_XEN_BALLOON
> +#include <xen/balloon.h>
> +#endif

Let's put the ifdefs in xen/balloon.h not in the files
including it.

> +#ifdef CONFIG_XEN_BALLOON
> +	/* Tell the ballon driver what is going on. */
> +	balloon_update_driver_allowance(i);
> +#endif

Similarly let's define empty do-nothing functions in
xen/balloon.h when the config option isn't set so we
don't need to crap up the C sources with these ifdefs.

^ permalink raw reply	[relevance 5%]

* Re: [RFC PATCH 32/33] Add the Xen virtual network device driver.
  2006-07-18 20:42  5%   ` David Miller
@ 2006-07-18 21:09  5%     ` Chris Wright
  0 siblings, 0 replies; 200+ results
From: Chris Wright @ 2006-07-18 21:09 UTC (permalink / raw)
  To: David Miller
  Cc: chrisw, linux-kernel, virtualization, xen-devel, jeremy, ak,
	akpm, rusty, zach, ian.pratt, Christian.Limpach, netdev

* David Miller (davem@davemloft.net) wrote:
> From: Chris Wright <chrisw@sous-sol.org>
> Date: Tue, 18 Jul 2006 00:00:32 -0700
> 
> > +#ifdef CONFIG_XEN_BALLOON
> > +#include <xen/balloon.h>
> > +#endif
> 
> Let's put the ifdefs in xen/balloon.h not in the files
> including it.
> 
> > +#ifdef CONFIG_XEN_BALLOON
> > +	/* Tell the ballon driver what is going on. */
> > +	balloon_update_driver_allowance(i);
> > +#endif
> 
> Similarly let's define empty do-nothing functions in
> xen/balloon.h when the config option isn't set so we
> don't need to crap up the C sources with these ifdefs.

Yeah, sorry it's kept more as a reminder to me.  Upstream Xen doesn't do
this, but this patchset doesn't support ballooning yet, so there just is
not xen/balloon.h in the set.  When merging with upstream Xen there's
patch rejects either way, so I agree, better to just drop this since
it's just future placeholder.

thanks,
-chris

^ permalink raw reply	[relevance 5%]

* [PATCH 3/6] scsiback driver
@ 2006-08-02  8:32  5% FUJITA Tomonori
  0 siblings, 0 replies; 200+ results
From: FUJITA Tomonori @ 2006-08-02  8:32 UTC (permalink / raw)
  To: xen-devel

# HG changeset patch
# User fujita.tomonori@lab.ntt.co.jp
# Node ID 4e1a4618df3a66d8100b3f50c96fafe523858440
# Parent  7111077b493ea53ef055ce38098f8af67f87d749
SCSI backend driver

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

diff -r 7111077b493e -r 4e1a4618df3a linux-2.6-xen-sparse/drivers/xen/scsiback/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/scsiback/Makefile	Wed Aug 02 15:15:04 2006 +0900
@@ -0,0 +1,2 @@
+obj-$(CONFIG_XEN_SCSI_BACKEND)	+= scsibk.o
+scsibk-y			+= interface.o libsrp.o scsiback.o
diff -r 7111077b493e -r 4e1a4618df3a linux-2.6-xen-sparse/drivers/xen/scsiback/interface.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/scsiback/interface.c	Wed Aug 02 15:15:04 2006 +0900
@@ -0,0 +1,153 @@
+/******************************************************************************
+ * arch/xen/drivers/blkif/backend/interface.c
+ *
+ * Block-device interface management.
+ *
+ * Copyright (c) 2004, Keir Fraser
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (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.
+ */
+
+#include <linux/version.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/uio.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/srp.h>
+#include <xen/driver_util.h>
+#include <xen/evtchn.h>
+#include <xen/xenbus.h>
+#include <xen/interface/xen.h>
+#include <xen/interface/io/scsi.h>
+#include <xen/interface/io/ring.h>
+#include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
+#include <asm/hypervisor.h>
+#include "scsiback_priv.h"
+
+static int map_frontend_page(struct scsiback_info *info, unsigned long shared_page)
+{
+	struct gnttab_map_grant_ref op;
+	int err;
+
+	gnttab_set_map_op(&op, (unsigned long)info->ring_area->addr,
+			  GNTMAP_host_map, shared_page,
+			  info->dev->otherend_id);
+
+	lock_vm_area(info->ring_area);
+	err = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
+	unlock_vm_area(info->ring_area);
+	BUG_ON(err);
+
+	if (op.status) {
+		printk(" Grant table operation failure !\n");
+		return op.status;
+	}
+
+	info->shmem_ref = shared_page;
+	info->shmem_handle = op.handle;
+
+#ifdef CONFIG_XEN_IA64_DOM0_NON_VP
+	/* on some arch's, map_grant_ref behaves like mmap, in that the
+	 * passed address is a hint and a different address may be returned */
+	info->ring_area->addr = gnttab_map_vaddr(op);
+#endif
+
+	return 0;
+}
+
+static void unmap_frontend_page(struct scsiback_info *info)
+{
+	struct gnttab_unmap_grant_ref op;
+	int err;
+
+	op.host_addr    = (unsigned long)info->ring_area->addr;
+	op.handle       = info->shmem_handle;
+	op.dev_bus_addr = 0;
+
+	lock_vm_area(info->ring_area);
+	err = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
+	unlock_vm_area(info->ring_area);
+	BUG_ON(err);
+}
+
+int scsiback_init_sring(struct scsiback_info *info,
+			 unsigned long shared_page, unsigned int evtchn)
+{
+	struct scsi_sring *sring;
+	int err;
+	struct evtchn_bind_interdomain bind_interdomain;
+
+	if (info->irq) {
+		printk("Already connected through?\n");
+		return 0;
+	}
+
+	info->ring_area = alloc_vm_area(PAGE_SIZE);
+	if (!info)
+		return -ENOMEM;
+
+	err = map_frontend_page(info, shared_page);
+	if (err)
+		goto free_vm;
+
+	bind_interdomain.remote_dom = info->dev->otherend_id;
+	bind_interdomain.remote_port = evtchn;
+
+	err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
+					  &bind_interdomain);
+	if (err)
+		goto unmap_page;
+
+	info->evtchn = bind_interdomain.local_port;
+
+	sring = (struct scsi_sring *) info->ring_area->addr;
+	BACK_RING_INIT(&info->ring, sring, PAGE_SIZE);
+
+	info->irq = bind_evtchn_to_irqhandler(info->evtchn, scsiback_intr,
+					      0, "scsi-backend", info);
+	return 0;
+
+unmap_page:
+	unmap_frontend_page(info);
+free_vm:
+	free_vm_area(info->ring_area);
+	return err;
+}
+
+void scsiback_exit_sring(struct scsiback_info *info)
+{
+	/* Already disconnected? */
+	if (info->irq)
+		unbind_from_irqhandler(info->irq, info);
+
+	if (info->ring.sring) {
+		unmap_frontend_page(info);
+		free_vm_area(info->ring_area);
+	}
+}
diff -r 7111077b493e -r 4e1a4618df3a linux-2.6-xen-sparse/drivers/xen/scsiback/libsrp.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/scsiback/libsrp.c	Wed Aug 02 15:15:04 2006 +0900
@@ -0,0 +1,264 @@
+/*
+ * SCSI RDAM Protocol lib functions
+ *
+ * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org>
+ *
+ * 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 St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include <linux/err.h>
+#include <linux/kfifo.h>
+#include <linux/scatterlist.h>
+#include <linux/dma-mapping.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_tcq.h>
+#include <scsi/scsi_tgt.h>
+#include <scsi/srp.h>
+#include "libsrp.h"
+
+enum srp_task_attributes {
+	SRP_SIMPLE_TASK = 0,
+	SRP_HEAD_TASK = 1,
+	SRP_ORDERED_TASK = 2,
+	SRP_ACA_TASK = 4
+};
+
+/* tmp - will replace with SCSI logging stuff */
+#define eprintk(fmt, args...)					\
+do {								\
+	printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args);	\
+} while (0)
+#define dprintk eprintk
+/* #define dprintk(fmt, args...) */
+
+static int data_out_desc_size(struct srp_cmd *cmd)
+{
+	int size = 0;
+	u8 fmt = cmd->buf_fmt >> 4;
+
+	switch (fmt) {
+	case SRP_NO_DATA_DESC:
+		break;
+	case SRP_DATA_DESC_DIRECT:
+		size = sizeof(struct srp_direct_buf);
+		break;
+	case SRP_DATA_DESC_INDIRECT:
+		size = sizeof(struct srp_indirect_buf) +
+			sizeof(struct srp_direct_buf) * cmd->data_out_desc_cnt;
+		break;
+	default:
+		eprintk("client error. Invalid data_out_format %x\n", fmt);
+		break;
+	}
+	return size;
+}
+
+int srp_rw(struct srp_cmd *cmd)
+{
+	return (cmd->buf_fmt >> 4) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
+}
+
+static u8 srp_format(struct srp_cmd *cmd)
+{
+	if (srp_rw(cmd) == DMA_TO_DEVICE)
+		return cmd->buf_fmt >> 4;
+	else
+		return cmd->buf_fmt & ((1U << 4) - 1);
+}
+
+static int srp_offset(struct srp_cmd *cmd)
+{
+	int offset, rw;
+
+	offset = cmd->add_cdb_len * 4;
+	rw = srp_rw(cmd);
+	if (rw == DMA_FROM_DEVICE)
+		offset += data_out_desc_size(cmd);
+
+	return offset;
+}
+
+int srp_nmd(struct srp_cmd *cmd)
+{
+	struct srp_indirect_buf *id;
+	u8 format;
+	int rw, nmd, offset;
+
+	rw = srp_rw(cmd);
+	offset = srp_offset(cmd);
+	format = srp_format(cmd);
+	switch (format) {
+	case SRP_NO_DATA_DESC:
+		nmd = 0;
+		break;
+	case SRP_DATA_DESC_DIRECT:
+		nmd = 1;
+		break;
+	case SRP_DATA_DESC_INDIRECT:
+		id = (struct srp_indirect_buf *)(cmd->add_data + offset);
+		nmd = id->table_desc.len / sizeof(struct srp_direct_buf);
+		break;
+	default:
+		eprintk("Unknown format %x\n", format);
+		nmd = -EINVAL;
+		break;
+	}
+
+	return nmd;
+}
+
+static struct srp_direct_buf *srp_md(struct srp_cmd *cmd, int idx)
+{
+	struct srp_direct_buf *md = NULL;
+	struct srp_indirect_buf *id;
+	int rw, nmd, offset;
+	u8 format;
+
+	rw = srp_rw(cmd);
+	offset = srp_offset(cmd);
+	format = srp_format(cmd);
+	switch (format) {
+	case SRP_DATA_DESC_DIRECT:
+		md = (struct srp_direct_buf *)(cmd->add_data + offset);
+		break;
+	case SRP_DATA_DESC_INDIRECT:
+		id = (struct srp_indirect_buf *)
+			(cmd->add_data + offset);
+		nmd = id->table_desc.len / sizeof(struct srp_direct_buf);
+
+		/* This should be true for Xen scsifront */
+		if ((rw == DMA_FROM_DEVICE && nmd == cmd->data_in_desc_cnt) ||
+		    (rw == DMA_TO_DEVICE && nmd == cmd->data_out_desc_cnt))
+			md = &id->desc_list[0];
+		else
+			BUG_ON(1);
+
+		md = &md[idx];
+		break;
+	case SRP_NO_DATA_DESC:
+	default:
+		eprintk("invalid %x\n", format);
+		break;
+	}
+
+	return md;
+}
+
+u64 srp_key(struct srp_cmd *cmd, int idx)
+{
+	struct srp_direct_buf *md = NULL;
+
+	md = srp_md(cmd, idx);
+	return md ? md->key : 0;
+}
+
+u64 srp_addr(struct srp_cmd *cmd, int idx)
+{
+	struct srp_direct_buf *md = NULL;
+
+	md = srp_md(cmd, idx);
+	return md ? md->va : 0;
+}
+
+u32 srp_len(struct srp_cmd *cmd, int idx)
+{
+	struct srp_direct_buf *md = NULL;
+
+	md = srp_md(cmd, idx);
+	return md ? md->len : 0;
+}
+
+static int vscsis_data_length(struct srp_cmd *cmd, enum dma_data_direction dir)
+{
+	struct srp_direct_buf *md;
+	struct srp_indirect_buf *id;
+	int len = 0, offset = cmd->add_cdb_len * 4;
+	u8 fmt;
+
+	if (dir == DMA_TO_DEVICE)
+		fmt = cmd->buf_fmt >> 4;
+	else {
+		fmt = cmd->buf_fmt & ((1U << 4) - 1);
+		offset += data_out_desc_size(cmd);
+	}
+
+	switch (fmt) {
+	case SRP_NO_DATA_DESC:
+		break;
+	case SRP_DATA_DESC_DIRECT:
+		md = (struct srp_direct_buf *) (cmd->add_data + offset);
+		len = md->len;
+		break;
+	case SRP_DATA_DESC_INDIRECT:
+		id = (struct srp_indirect_buf *) (cmd->add_data + offset);
+		len = id->len;
+		break;
+	default:
+		eprintk("invalid data format %x\n", fmt);
+		break;
+	}
+	return len;
+}
+
+int srp_cmd_perform(struct Scsi_Host *host, struct srp_cmd *cmd, void *data, u64 uaddr)
+{
+	enum dma_data_direction data_dir;
+	struct scsi_cmnd *sc;
+	int tag, len;
+
+	tag = MSG_SIMPLE_TAG;
+
+	switch (cmd->task_attr) {
+	case SRP_SIMPLE_TASK:
+		tag = MSG_SIMPLE_TAG;
+		break;
+	case SRP_ORDERED_TASK:
+		tag = MSG_ORDERED_TAG;
+		break;
+	case SRP_HEAD_TASK:
+		tag = MSG_HEAD_TAG;
+		break;
+	default:
+		eprintk("Task attribute %d not supported\n", cmd->task_attr);
+		tag = MSG_ORDERED_TAG;
+	}
+
+	if (cmd->buf_fmt >> 4)
+		data_dir = DMA_TO_DEVICE;
+	else
+		data_dir = DMA_FROM_DEVICE;
+	len = vscsis_data_length(cmd, data_dir);
+
+	dprintk("%x %llx %d %d %d %llx\n", cmd->cdb[0],
+		(unsigned long long) cmd->lun, data_dir,
+		len, tag, (unsigned long long) cmd->tag);
+
+	sc = scsi_host_get_command(host, data_dir, GFP_KERNEL);
+	BUG_ON(!sc);
+	memcpy(sc->cmnd, cmd->cdb, MAX_COMMAND_SIZE);
+	sc->request_bufflen = len;
+	sc->request_buffer = (void *) (unsigned long)uaddr;
+	sc->tag = tag;
+	sc->SCp.ptr = data;
+	sc->host_scribble = (void *) host;
+	scsi_tgt_queue_command(sc, (struct scsi_lun *) &cmd->lun, cmd->tag);
+
+	return 0;
+}
+
+MODULE_DESCRIPTION("SCSI RDAM Protocol lib functions");
+MODULE_AUTHOR("FUJITA Tomonori");
+MODULE_LICENSE("GPL");
diff -r 7111077b493e -r 4e1a4618df3a linux-2.6-xen-sparse/drivers/xen/scsiback/libsrp.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/scsiback/libsrp.h	Wed Aug 02 15:15:04 2006 +0900
@@ -0,0 +1,20 @@
+#ifndef __LIBSRP_H__
+#define __LIBSRP_H__
+
+#include <linux/list.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_host.h>
+#include <scsi/srp.h>
+
+typedef int (rdma_io_t) (struct scsi_cmnd *, struct scatterlist *, int,
+			 struct srp_direct_buf *, int, unsigned int);
+
+extern int srp_cmd_perform(struct Scsi_Host *, struct srp_cmd *, void *, u64);
+extern int srp_transfer_data(struct scsi_cmnd *, struct srp_cmd *, rdma_io_t);
+extern int srp_nmd(struct srp_cmd *);
+extern int srp_rw(struct srp_cmd *);
+extern u64 srp_key(struct srp_cmd *, int);
+extern u64 srp_addr(struct srp_cmd *, int);
+extern u32 srp_len(struct srp_cmd *, int);
+
+#endif
diff -r 7111077b493e -r 4e1a4618df3a linux-2.6-xen-sparse/drivers/xen/scsiback/scsiback.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/scsiback/scsiback.c	Wed Aug 02 15:15:04 2006 +0900
@@ -0,0 +1,579 @@
+/*
+ * Xen SCSI backend driver
+ *
+ * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org>
+ *
+ * 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 St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ * Based on the blktap driver code.
+ *
+ * Copyright (c) 2004-2005, Andrew Warfield and Julian Chesterfield
+ *
+ */
+
+#include <linux/version.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/uio.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_tgt.h>
+#include <scsi/srp.h>
+#include <xen/evtchn.h>
+#include <xen/balloon.h>
+#include <xen/xenbus.h>
+#include <xen/interface/xen.h>
+#include <xen/interface/io/scsi.h>
+#include <xen/interface/io/ring.h>
+#include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
+#include <asm/hypervisor.h>
+#include "scsiback_priv.h"
+#include "libsrp.h"
+
+#define eprintk(fmt, args...)					\
+do {								\
+	printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args);	\
+} while (0)
+
+#define dprintk eprintk
+
+static unsigned int debug = 0;
+static int major;
+static struct workqueue_struct *scsibkd;
+
+module_param(debug, int, 0644);
+
+static int req_index(struct scsiback_info *info, struct scsi_request *req)
+{
+	return (req - RING_GET_REQUEST(&info->ring, 0));
+}
+
+static int __idx(struct scsiback_info *info, struct scsi_request *req,
+		      int idx)
+{
+	return req_index(info, req) * SRP_MAX_INDIRECT + idx;
+}
+
+static unsigned long vaddr(struct scsiback_info *info, u64 start,
+			   struct scsi_request *req, int i)
+{
+	return start + (__idx(info, req, i) << PAGE_SHIFT);
+}
+
+static int scsiback_send_rsp(struct scsiback_info *info, struct scsi_cmnd *sc,
+			     void (*done)(struct scsi_cmnd *))
+{
+	struct scsi_back_ring *ring = &info->ring;
+	struct scsi_response *rsp;
+	struct scsi_request *req = (struct scsi_request *) sc->SCp.ptr;
+	struct srp_cmd *cmd = (struct srp_cmd *) req->buf;
+	struct srp_rsp *srsp;
+	int notify;
+
+	rsp = RING_GET_RESPONSE(ring, ring->rsp_prod_pvt);
+	srsp = (struct srp_rsp *) rsp->buf;
+	srsp->opcode = SRP_RSP;
+	srsp->tag = cmd->tag;
+	srsp->resp_data_len = 0;
+	srsp->status = NO_SENSE;
+	srsp->data_in_res_cnt = 0;
+	srsp->data_out_res_cnt = 0;
+	srsp->flags &= ~SRP_RSP_FLAG_RSPVALID;
+
+	ring->rsp_prod_pvt++;
+
+	RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(ring, notify);
+
+	notify_remote_via_irq(info->irq);
+
+	done(sc);
+	return 0;
+}
+
+static int scsiback_cmd_done(struct scsi_cmnd *sc,
+			      void (*done)(struct scsi_cmnd *))
+{
+	struct Scsi_Host *host = (struct Scsi_Host *) sc->host_scribble;
+	struct scsiback_info *info = (struct scsiback_info *) host->hostdata;
+	struct scsi_request *req = (struct scsi_request *) sc->SCp.ptr;
+	struct srp_cmd *cmd = (struct srp_cmd *) req->buf;
+	struct vm_area_struct *vma = info->mmap_vma;
+	struct gnttab_unmap_grant_ref unmap[SRP_MAX_INDIRECT * 2];
+	int i, op, err, nmd, offset;
+
+	nmd = srp_nmd(cmd);
+	if (!nmd)
+		goto send_rsp;
+	for (op = i = 0; i < nmd; i++) {
+		u64 kaddr, uaddr, ptep;
+		struct page *page, **map = vma->vm_private_data;
+
+		uaddr = vaddr(info, info->ustart, req, i);
+		kaddr = vaddr(info, info->kstart, req, i);
+
+		page = pfn_to_page(__pa(kaddr) >> PAGE_SHIFT);
+		ClearPageReserved(page);
+		offset = (uaddr - vma->vm_start) >> PAGE_SHIFT;
+		map[offset] = NULL;
+
+		gnttab_set_unmap_op(&unmap[op++], kaddr, GNTMAP_host_map,
+				    info->handle[__idx(info, req, i)].k);
+
+		err = create_lookup_pte_addr(vma->vm_mm, uaddr, &ptep);
+		BUG_ON(err); /* FIXME */
+
+		gnttab_set_unmap_op(&unmap[op++], ptep, GNTMAP_host_map,
+				    info->handle[__idx(info, req, i)].u);
+	}
+	err = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, op);
+	BUG_ON(err);
+
+	zap_page_range(vma, vaddr(info, info->ustart, req, 0),
+		       nmd << PAGE_SHIFT, NULL);
+
+send_rsp:
+	scsiback_send_rsp(info, sc, done);
+	return 0;
+}
+
+static int scsiback_eh_abort_handler(struct scsi_cmnd *scmd)
+{
+	BUG_ON(1);
+	return 0;
+}
+
+static struct scsi_host_template scsiback_sht = {
+	.module			= THIS_MODULE,
+	.name			= "scsiback",
+	.can_queue		= SRP_CAN_QUEUE,
+	.sg_tablesize		= SG_ALL,
+	.use_clustering		= DISABLE_CLUSTERING,
+	.transfer_response	= scsiback_cmd_done,
+	.eh_abort_handler	= scsiback_eh_abort_handler,
+};
+
+static void scsiback_worker(void *data)
+{
+	struct scsiback_info *info = data;
+	struct scsi_back_ring *ring = &info->ring;
+	struct scsi_request *req;
+	struct srp_cmd *cmd;
+	struct scsi_iovec *vec;
+	struct vm_area_struct *vma = info->mmap_vma;
+	struct gnttab_map_grant_ref map[SRP_MAX_INDIRECT * 2];
+	struct page *page;
+	struct iovec *iov;
+	RING_IDX rc, rp;
+	int i, op, nmd, err;
+	u64 uaddr, kaddr, ptep;
+
+	rc = ring->req_cons;
+	rp = ring->sring->req_prod;
+	rmb();
+
+	while ((rc != rp) && !RING_REQUEST_CONS_OVERFLOW(ring, rc)) {
+		eprintk("%u %u\n", rc, rp);
+		req = RING_GET_REQUEST(ring, rc);
+		ring->req_cons = ++rc;
+		cmd = (struct srp_cmd *) req->buf;
+		nmd = srp_nmd(cmd);
+
+		eprintk("%d %x %x\n", nmd, cmd->opcode, cmd->cdb[0]);
+
+		vec = (struct scsi_iovec *)
+			(info->uring + sizeof(*vec) * req_index(info, req));
+		vec->iovcnt = nmd;
+		if (!nmd)
+			goto no_data;
+
+		for (op = i = 0; i < nmd; i++) {
+			u32 flags;
+			int dir;
+
+			uaddr = vaddr(info, info->ustart, req, i);
+			kaddr = vaddr(info, info->kstart, req, i);
+
+			eprintk("%d %llx %llx\n", i, uaddr, kaddr);
+
+			page = virt_to_page(kaddr);
+
+			dir = srp_rw(cmd);
+			flags = GNTMAP_host_map;
+			if (dir == DMA_TO_DEVICE)
+				flags |= GNTMAP_readonly;
+
+			gnttab_set_map_op(&map[op], kaddr, flags,
+					  srp_key(cmd, i),
+					  info->dev->otherend_id);
+			op++;
+
+			err = create_lookup_pte_addr(vma->vm_mm, uaddr, &ptep);
+			BUG_ON(err); /* FIXME */
+
+			flags = GNTMAP_host_map | GNTMAP_application_map
+				| GNTMAP_contains_pte;
+			if (dir == DMA_TO_DEVICE)
+				flags |= GNTMAP_readonly;
+
+			gnttab_set_map_op(&map[op], ptep, flags,
+					  srp_key(cmd, i),
+					  info->dev->otherend_id);
+			op++;
+		}
+
+		err = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
+		BUG_ON(err);
+
+		iov = vec->iov;
+		for (i = 0; i < nmd; i++) {
+			int offset, j, idx;
+
+			j = i * 2;
+			idx = __idx(info, req, i);
+
+			uaddr = vaddr(info, info->ustart, req, i);
+			kaddr = vaddr(info, info->kstart, req, i);
+
+			/* FIXME */
+			BUG_ON(map[j].status || map[j + 1].status);
+
+			info->handle[idx].k = map[j].handle;
+			info->handle[idx].u = map[j + 1].handle;
+			set_phys_to_machine(__pa(kaddr) >> PAGE_SHIFT,
+					    FOREIGN_FRAME(map[j].dev_bus_addr >> PAGE_SHIFT));
+			offset = (uaddr - vma->vm_start) >> PAGE_SHIFT;
+			page = pfn_to_page(__pa(kaddr) >> PAGE_SHIFT);
+			((struct page **) vma->vm_private_data)[offset] = page;
+			SetPageReserved(page);
+
+			offset = srp_addr(cmd, i) & (PAGE_SIZE-1);
+			iov[i].iov_base = (void *) ((unsigned long) uaddr + offset);
+			iov[i].iov_len = srp_len(cmd, i);
+
+			eprintk("%llx %d %p %d\n", uaddr, offset, iov[i].iov_base,
+				iov[i].iov_len);
+		}
+
+	no_data:
+		srp_cmd_perform(info->host, cmd, req,
+				vma->vm_start + sizeof(*vec) * req_index(info, req));
+	}
+}
+
+irqreturn_t scsiback_intr(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct scsiback_info *info = (struct scsiback_info *) dev_id;
+
+	queue_work(scsibkd, &info->scsiback_work);
+
+	return IRQ_HANDLED;
+}
+
+static int scsiback_connect(struct scsiback_info *info)
+{
+	struct xenbus_device *dev = info->dev;
+	unsigned long ring_ref;
+	unsigned int evtchn;
+	int err;
+
+	err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%lu",
+			    &ring_ref, "event-channel", "%u", &evtchn, NULL);
+	if (err) {
+		xenbus_dev_fatal(dev, err, "reading %s ring", dev->otherend);
+		return err;
+	}
+
+	return scsiback_init_sring(info, ring_ref, evtchn);
+}
+
+static void scsiback_frontend_changed(struct xenbus_device *dev,
+				       enum xenbus_state frontend_state)
+{
+	struct scsiback_info *info = dev->dev.driver_data;
+	int err;
+
+	dprintk("%p %u %u\n", dev, dev->state, frontend_state);
+	switch (frontend_state) {
+	case XenbusStateInitialising:
+		break;
+
+	case XenbusStateInitialised:
+	case XenbusStateConnected:
+		if (dev->state == XenbusStateConnected)
+			break;
+
+		err = scsiback_connect(info);
+		if (err)
+			break;
+
+		err = xenbus_switch_state(dev, XenbusStateConnected);
+		if (err)
+			xenbus_dev_fatal(dev, err, "switching to Connected state",
+					 dev->nodename);
+		break;
+
+	case XenbusStateClosing:
+		xenbus_switch_state(dev, XenbusStateClosing);
+		break;
+
+	case XenbusStateClosed:
+		device_unregister(&dev->dev);
+		break;
+
+	case XenbusStateUnknown:
+	case XenbusStateInitWait:
+	default:
+		xenbus_dev_fatal(dev, -EINVAL, "saw state %d at frontend",
+				 frontend_state);
+		break;
+	}
+}
+
+static void scsiback_backend_changed(struct xenbus_watch *watch,
+				      const char **vec, unsigned int len)
+{
+	struct scsiback_info *info =
+		container_of(watch, struct scsiback_info, backend_watch);
+
+	dprintk("%p %u\n", info->dev, info->dev->state);
+
+	/* TODO */
+}
+
+static int scsiback_probe(struct xenbus_device *dev,
+			   const struct xenbus_device_id *id)
+{
+	int i, err, nr = SRP_RING_PAGES + SRP_MAPPED_PAGES;
+	struct Scsi_Host *host;
+	struct scsiback_info *info;
+	struct page *page;
+	struct xenbus_transaction xbt;
+
+	dprintk("%p %d\n", dev, dev->otherend_id);
+
+	host = scsi_host_alloc(&scsiback_sht, sizeof(struct scsiback_info));
+	if (!host)
+		return -ENOMEM;
+	err = scsi_tgt_alloc_queue(host);
+	if (err)
+		goto put_host;
+
+	err = scsi_add_host(host, &dev->dev);
+	if (err)
+		goto put_host;
+
+	info = (struct scsiback_info *) host->hostdata;
+	dev->dev.driver_data = info;
+	info->dev = dev;
+	info->host = host;
+
+	info->uring = get_zeroed_page(GFP_KERNEL);
+	if (!info->uring)
+		goto put_host;
+
+	page = balloon_alloc_empty_page_range(nr);
+	if (!page)
+		goto free_ring;
+	SetPageReserved(virt_to_page(info->uring));
+
+	for (i = 0; i < nr; i++)
+		get_page(&page[i]);
+	info->kstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
+	info->mmap_page = page;
+
+	INIT_WORK(&info->scsiback_work, scsiback_worker, info);
+
+	err = xenbus_transaction_start(&xbt);
+	if (err)
+		eprintk("fail to transcation %d\n", err);
+
+	err = xenbus_printf(xbt, dev->nodename, "hostno", "%u", host->host_no);
+	if (err)
+		eprintk("fail to transcation %d\n", err);
+
+	err = xenbus_transaction_end(xbt, 0);
+	if (err)
+		eprintk("fail to transcation %d\n", err);
+
+	err = xenbus_watch_path2(dev, dev->nodename,
+				 "scsi-host",
+				 &info->backend_watch,
+				 scsiback_backend_changed);
+	if (err)
+		goto free_page;
+
+	err = xenbus_switch_state(dev, XenbusStateInitWait);
+	if (err)
+		goto stop_watch;
+
+	return 0;
+
+stop_watch:
+	/* free resource */
+free_page:
+	balloon_dealloc_empty_page_range(info->mmap_page, nr);
+free_ring:
+	free_page(info->uring);
+put_host:
+	scsi_host_put(host);
+	return err;
+}
+
+static int scsiback_remove(struct xenbus_device *dev)
+{
+	struct scsiback_info *info = dev->dev.driver_data;
+	struct Scsi_Host *host = info->host;
+	struct vm_area_struct *vma = info->mmap_vma;
+
+	if (vma) {
+		zap_page_range(vma, vma->vm_start,
+			       vma->vm_end - vma->vm_start, NULL);
+		info->mmap_vma = NULL;
+	}
+
+	free_page(info->uring);
+	balloon_dealloc_empty_page_range(info->mmap_page,
+					 SRP_RING_PAGES + SRP_MAPPED_PAGES);
+	scsi_remove_host(host);
+	scsi_host_put(host);
+	return 0;
+}
+
+static int scsiback_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+	int i, err;
+	unsigned long nr;
+	unsigned int hostno = MINOR(filp->f_dentry->d_inode->i_rdev);
+	struct page **map;
+	struct scsiback_info *info;
+	struct Scsi_Host *host;
+
+	dprintk("%u start %lx, end %lx\n", hostno, vma->vm_start, vma->vm_end);
+
+	host = scsi_host_lookup(hostno);
+	if (!host) {
+		eprintk("no scsi host %d\n", hostno);
+		return -EAGAIN;
+	}
+	info = (struct scsiback_info *)host->hostdata;
+
+	/* TODO we need to prevent this scsi host from going away. */
+
+	vma->vm_flags |= VM_RESERVED;
+/* 	vma->vm_ops = &vscsiback_vm_ops; */
+
+	nr = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+	if (nr != SRP_RING_PAGES + SRP_MAPPED_PAGES) {
+		eprintk("you _must_ map exactly %lu pages!\n", nr);
+		err = -EINVAL;
+		goto host_put;
+	}
+
+	/* not sure if I really need to do this... */
+	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+	err = remap_pfn_range(vma, vma->vm_start,
+			      __pa(info->uring) >> PAGE_SHIFT,
+			      PAGE_SIZE, vma->vm_page_prot);
+	if (err) {
+		eprintk("fail to map frontend ring %d!\n", err);
+		goto host_put;
+	}
+
+	/* Mark this VM as containing foreign pages, and set up mappings. */
+	map = kzalloc(nr * sizeof(struct page_struct *), GFP_KERNEL);
+	if (!map) {
+		eprintk("Couldn't alloc VM_FOREIGN map.\n");
+		err = -ENOMEM;
+		goto zap;
+	}
+
+	for (i = 0; i < nr; i++)
+		map[i] = NULL;
+
+	vma->vm_private_data = map;
+	vma->vm_flags |= VM_FOREIGN;
+
+	info->ustart = vma->vm_start + (SRP_RING_PAGES << PAGE_SHIFT);
+
+	dprintk("%u start %lx, end %lx ustart %llx\n",
+		hostno, vma->vm_start, vma->vm_end, info->ustart);
+
+	info->mmap_vma = vma;
+zap:
+	if (err)
+		zap_page_range(vma, vma->vm_start, vma->vm_end - vma->vm_start, NULL);
+host_put:
+	scsi_host_put(host);
+
+	return err;
+}
+
+static struct file_operations scsiback_fops = {
+	.owner			= THIS_MODULE,
+	.mmap			= scsiback_mmap,
+};
+
+static struct xenbus_device_id scsiback_ids[] = {
+	{ "scsi" },
+	{ "" }
+};
+
+static struct xenbus_driver scsiback = {
+	.name			= "scsi",
+	.owner			= THIS_MODULE,
+	.ids			= scsiback_ids,
+	.probe			= scsiback_probe,
+	.remove			= scsiback_remove,
+	.otherend_changed	= scsiback_frontend_changed
+};
+
+static int __init scsiback_init(void)
+{
+	int err = -ENOMEM;
+
+	eprintk("%u %lu\n", SRP_MAPPED_PAGES, SRP_RING_PAGES);
+
+	if (!is_running_on_xen())
+		return -ENODEV;
+
+	major = register_chrdev(0, "scsiback", &scsiback_fops);
+	if (major < 0)
+		return major;
+
+	scsibkd = create_singlethread_workqueue("scsibkd");
+	if (!scsibkd)
+		goto free_dev;
+
+	err = xenbus_register_backend(&scsiback);
+	if (err)
+		goto destroy_wq;
+	return 0;
+free_dev:
+	unregister_chrdev(major, "scsiback");
+destroy_wq:
+	destroy_workqueue(scsibkd);
+	return err;
+}
+
+module_init(scsiback_init);
+
+MODULE_AUTHOR("FUJITA Tomonori");
+MODULE_DESCRIPTION("Xen SCSI backend driver");
+MODULE_LICENSE("GPL");
diff -r 7111077b493e -r 4e1a4618df3a linux-2.6-xen-sparse/drivers/xen/scsiback/scsiback_priv.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/scsiback/scsiback_priv.h	Wed Aug 02 15:15:04 2006 +0900
@@ -0,0 +1,36 @@
+struct grant_handle_pair {
+        grant_handle_t k;
+        grant_handle_t u;
+};
+
+struct scsiback_info {
+	struct xenbus_device *dev;
+	struct Scsi_Host *host;
+	struct xenbus_watch backend_watch;
+
+	unsigned int evtchn;
+	unsigned int irq;
+
+	struct scsi_back_ring ring;
+	struct vm_struct *ring_area;
+
+	grant_handle_t shmem_handle;
+	grant_ref_t    shmem_ref;
+
+	struct work_struct scsiback_work;
+
+	/* Add something tgt code to support this kind of stuff? */
+	unsigned long uring;
+
+	struct vm_area_struct *mmap_vma;
+	struct page *mmap_page;
+	u64 kstart;
+	u64 ustart;
+
+	struct grant_handle_pair handle[SRP_CAN_QUEUE * SRP_MAX_INDIRECT];
+};
+
+extern irqreturn_t scsiback_intr(int, void *, struct pt_regs *);
+extern int scsiback_init_sring(struct scsiback_info *,
+			       unsigned long, unsigned int);
+extern void scsiback_exit_sring(struct scsiback_info *);

^ permalink raw reply	[relevance 5%]

* xen test results on Unisys ES7000
@ 2006-08-08 18:03  4% Krysan, Susan
  0 siblings, 0 replies; 200+ results
From: Krysan, Susan @ 2006-08-08 18:03 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 783 bytes --]

August 7, 2006

 

Configuration:

 

Unisys ES7000/one, x86_64

32 physical processors, 128 GB RAM

SLES10 RC3 with xen-unstable changeset 10949

 

Ran xm-test (see results below) and successfully booted the following
x86_64 SLES10 domUs:

            a. A uni-processor DomU with 1GB of memory

            b. A 4-processor DomU with 1GB of memory

            c. A uni-processor DomU with 8GB of memory

            d. A 4-processor DomU with 8GB of memory

 

Issues: bug #729 - domU migration causes fatal page fault crash

 

Xm-test fails when attempting to run 01_migrate_localhost_pos, so a
report file is not generated.  The output file is attached.

 

Thanks,

Sue Krysan

Linux Systems Group

Unisys Corporation

 

 


[-- Attachment #1.2: Type: text/html, Size: 5290 bytes --]

[-- Attachment #2: 20060806 32x128GBoutput.txt --]
[-- Type: text/plain, Size: 277917 bytes --]

*** case block-create from group default
*** Running tests for case block-create
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-create'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-create'
cp 01_block_attach_device_pos.py 01_block_attach_device_pos.test
chmod +x 01_block_attach_device_pos.test
cp 02_block_attach_file_device_pos.py 02_block_attach_file_device_pos.test
chmod +x 02_block_attach_file_device_pos.test
cp 04_block_attach_device_repeatedly_pos.py 04_block_attach_device_repeatedly_pos.test
chmod +x 04_block_attach_device_repeatedly_pos.test
cp 05_block_attach_and_dettach_device_repeatedly_pos.py 05_block_attach_and_dettach_device_repeatedly_pos.test
chmod +x 05_block_attach_and_dettach_device_repeatedly_pos.test
cp 06_block_attach_baddomain_neg.py 06_block_attach_baddomain_neg.test
chmod +x 06_block_attach_baddomain_neg.test
cp 07_block_attach_baddevice_neg.py 07_block_attach_baddevice_neg.test
chmod +x 07_block_attach_baddevice_neg.test
cp 08_block_attach_bad_filedevice_neg.py 08_block_attach_bad_filedevice_neg.test
chmod +x 08_block_attach_bad_filedevice_neg.test
cp 09_block_attach_and_dettach_device_check_data_pos.py 09_block_attach_and_dettach_device_check_data_pos.test
chmod +x 09_block_attach_and_dettach_device_check_data_pos.test
cp 11_block_attach_shared_dom0.py 11_block_attach_shared_dom0.test
chmod +x 11_block_attach_shared_dom0.test
cp 12_block_attach_shared_domU.py 12_block_attach_shared_domU.test
chmod +x 12_block_attach_shared_domU.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
01_domu_proc-1154892755            1       64     1 -b----     0.4
Domain-0                           0     5000    32 r-----  2950.1
[dom0] Running `xm destroy 01_domu_proc-1154892755'
*** Finished cleaning domUs
*** Test 01_block_attach_device_pos started at Sun Aug  6 15:32:42 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  2951.3
*** Finished cleaning domUs
*** Test 01_block_attach_device_pos started at Sun Aug  6 15:32:42 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_block_attach_device_pos-1154892762
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_block_attach_device_pos-1154892762']
[01_block_attach_device_pos-1154892762] Sending `input'
[01_block_attach_device_pos-1154892762] Sending `ls'
[01_block_attach_device_pos-1154892762] Sending `echo $?'
[dom0] Running `xm block-attach 01_block_attach_device_pos-1154892762 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 01_block_attach_device_pos-1154892762 | awk '/^2065/ {print $4}''
4
[01_block_attach_device_pos-1154892762] Sending `cat /proc/partitions'
[01_block_attach_device_pos-1154892762] Sending `echo $?'
[dom0] Running `xm shutdown 01_block_attach_device_pos-1154892762'

PASS: 01_block_attach_device_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
01_block_attach_device_pos-1154892762   2       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  2954.4
[dom0] Running `xm destroy 01_block_attach_device_pos-1154892762'
*** Finished cleaning domUs
*** Test 02_block_attach_file_device_pos started at Sun Aug  6 15:32:51 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  2956.4
*** Finished cleaning domUs
*** Test 02_block_attach_file_device_pos started at Sun Aug  6 15:32:52 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 02_block_attach_file_device_pos-1154892772
Console executing: ['/usr/sbin/xm', 'xm', 'console', '02_block_attach_file_device_pos-1154892772']
[02_block_attach_file_device_pos-1154892772] Sending `input'
[02_block_attach_file_device_pos-1154892772] Sending `ls'
[02_block_attach_file_device_pos-1154892772] Sending `echo $?'
[dom0] Running `xm block-attach 02_block_attach_file_device_pos-1154892772 file:/dev/ram1 sdb2 w'

[dom0] Running `xm block-list 02_block_attach_file_device_pos-1154892772 | awk '/^2066/ {print $4}''
4
[02_block_attach_file_device_pos-1154892772] Sending `cat /proc/partitions'
[02_block_attach_file_device_pos-1154892772] Sending `echo $?'
[dom0] Running `xm shutdown 02_block_attach_file_device_pos-1154892772'

PASS: 02_block_attach_file_device_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
02_block_attach_file_device_pos-1154892772   3       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  2959.7
[dom0] Running `xm destroy 02_block_attach_file_device_pos-1154892772'
*** Finished cleaning domUs
*** Test 04_block_attach_device_repeatedly_pos started at Sun Aug  6 15:33:01 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  2960.9
*** Finished cleaning domUs
*** Test 04_block_attach_device_repeatedly_pos started at Sun Aug  6 15:33:01 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 04_block_attach_device_repeatedly_pos-1154892781
Console executing: ['/usr/sbin/xm', 'xm', 'console', '04_block_attach_device_repeatedly_pos-1154892781']
[04_block_attach_device_repeatedly_pos-1154892781] Sending `input'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `ls'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm block-attach 04_block_attach_device_repeatedly_pos-1154892781 phy:ram1 sdb1 w'

[04_block_attach_device_repeatedly_pos-1154892781] Sending `cat /proc/partitions'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm block-attach 04_block_attach_device_repeatedly_pos-1154892781 phy:ram1 sdb1 w'
Error: Device sdb1 (2065, vbd) is already connected.
[04_block_attach_device_repeatedly_pos-1154892781] Sending `cat /proc/partitions'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm block-attach 04_block_attach_device_repeatedly_pos-1154892781 phy:ram1 sdb1 w'
Error: Device sdb1 (2065, vbd) is already connected.
[04_block_attach_device_repeatedly_pos-1154892781] Sending `cat /proc/partitions'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm block-attach 04_block_attach_device_repeatedly_pos-1154892781 phy:ram1 sdb1 w'
Error: Device sdb1 (2065, vbd) is already connected.
[04_block_attach_device_repeatedly_pos-1154892781] Sending `cat /proc/partitions'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm block-attach 04_block_attach_device_repeatedly_pos-1154892781 phy:ram1 sdb1 w'
Error: Device sdb1 (2065, vbd) is already connected.
[04_block_attach_device_repeatedly_pos-1154892781] Sending `cat /proc/partitions'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm block-attach 04_block_attach_device_repeatedly_pos-1154892781 phy:ram1 sdb1 w'
Error: Device sdb1 (2065, vbd) is already connected.
[04_block_attach_device_repeatedly_pos-1154892781] Sending `cat /proc/partitions'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm block-attach 04_block_attach_device_repeatedly_pos-1154892781 phy:ram1 sdb1 w'
Error: Device sdb1 (2065, vbd) is already connected.
[04_block_attach_device_repeatedly_pos-1154892781] Sending `cat /proc/partitions'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm block-attach 04_block_attach_device_repeatedly_pos-1154892781 phy:ram1 sdb1 w'
Error: Device sdb1 (2065, vbd) is already connected.
[04_block_attach_device_repeatedly_pos-1154892781] Sending `cat /proc/partitions'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm block-attach 04_block_attach_device_repeatedly_pos-1154892781 phy:ram1 sdb1 w'
Error: Device sdb1 (2065, vbd) is already connected.
[04_block_attach_device_repeatedly_pos-1154892781] Sending `cat /proc/partitions'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm block-attach 04_block_attach_device_repeatedly_pos-1154892781 phy:ram1 sdb1 w'
Error: Device sdb1 (2065, vbd) is already connected.
[04_block_attach_device_repeatedly_pos-1154892781] Sending `cat /proc/partitions'
[04_block_attach_device_repeatedly_pos-1154892781] Sending `echo $?'
[dom0] Running `xm shutdown 04_block_attach_device_repeatedly_pos-1154892781'

PASS: 04_block_attach_device_repeatedly_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
04_block_attach_device_repeatedly_pos-1154892781   4       64     1 -b----     0.4
Domain-0                           0     5000    32 r-----  2966.6
[dom0] Running `xm destroy 04_block_attach_device_repeatedly_pos-1154892781'
*** Finished cleaning domUs
*** Test 05_block_attach_and_dettach_device_repeatedly_pos started at Sun Aug  6 15:33:30 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  2967.8
*** Finished cleaning domUs
*** Test 05_block_attach_and_dettach_device_repeatedly_pos started at Sun Aug  6 15:33:30 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 05_block_attach_and_dettach_device_repeatedly_pos-1154892810
Console executing: ['/usr/sbin/xm', 'xm', 'console', '05_block_attach_and_dettach_device_repeatedly_pos-1154892810']
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `input'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `ls'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-attach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''
4
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-detach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 sdb1'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''

[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-attach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''
4
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-detach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 sdb1'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''

[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-attach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''
4
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-detach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 sdb1'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''

[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-attach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''
4
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-detach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 sdb1'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''

[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-attach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''
4
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-detach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 sdb1'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''

[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-attach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''
4
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-detach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 sdb1'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''

[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-attach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''
4
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-detach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 sdb1'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''

[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-attach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''
4
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-detach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 sdb1'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''

[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-attach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''
4
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-detach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 sdb1'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''

[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-attach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 phy:ram1 sdb1 w'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''
4
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm block-detach 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 sdb1'

[dom0] Running `xm block-list 05_block_attach_and_dettach_device_repeatedly_pos-1154892810 | awk '/^2065/ {print $4}''

[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `cat /proc/partitions'
[05_block_attach_and_dettach_device_repeatedly_pos-1154892810] Sending `echo $?'
[dom0] Running `xm shutdown 05_block_attach_and_dettach_device_repeatedly_pos-1154892810'

PASS: 05_block_attach_and_dettach_device_repeatedly_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
05_block_attach_and_dettach_device_repeatedly_pos-1154892810   5       64     1 -b----     0.5
Domain-0                           0     5000    32 r-----  2989.5
[dom0] Running `xm destroy 05_block_attach_and_dettach_device_repeatedly_pos-1154892810'
*** Finished cleaning domUs
*** Test 06_block_attach_baddomain_neg started at Sun Aug  6 15:34:31 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  2991.1
*** Finished cleaning domUs
*** Test 06_block_attach_baddomain_neg started at Sun Aug  6 15:34:31 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm block-attach NOT-EXIST phy:ram1 sdb1 w'
Error: the domain 'NOT-EXIST' does not exist.
PASS: 06_block_attach_baddomain_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  2991.8
*** Finished cleaning domUs
*** Test 07_block_attach_baddevice_neg started at Sun Aug  6 15:34:32 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  2992.1
*** Finished cleaning domUs
*** Test 07_block_attach_baddevice_neg started at Sun Aug  6 15:34:32 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_block_attach_baddevice_neg-1154892872
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_block_attach_baddevice_neg-1154892872']
[07_block_attach_baddevice_neg-1154892872] Sending `input'
[07_block_attach_baddevice_neg-1154892872] Sending `ls'
[07_block_attach_baddevice_neg-1154892872] Sending `echo $?'
[dom0] Running `xm block-attach 07_block_attach_baddevice_neg-1154892872 phy:NOT-EXIST sdb1 w'
Error: Device 2065 (vbd) could not be connected. Hotplug scripts not working.
[07_block_attach_baddevice_neg-1154892872] Sending `cat /proc/partitions'
[07_block_attach_baddevice_neg-1154892872] Sending `echo $?'
[dom0] Running `xm shutdown 07_block_attach_baddevice_neg-1154892872'

PASS: 07_block_attach_baddevice_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
07_block_attach_baddevice_neg-1154892872   6       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  2995.0
[dom0] Running `xm destroy 07_block_attach_baddevice_neg-1154892872'
*** Finished cleaning domUs
*** Test 08_block_attach_bad_filedevice_neg started at Sun Aug  6 15:34:51 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  2996.9
*** Finished cleaning domUs
*** Test 08_block_attach_bad_filedevice_neg started at Sun Aug  6 15:34:51 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 08_block_attach_bad_filedevice_neg-1154892891
Console executing: ['/usr/sbin/xm', 'xm', 'console', '08_block_attach_bad_filedevice_neg-1154892891']
[08_block_attach_bad_filedevice_neg-1154892891] Sending `input'
[08_block_attach_bad_filedevice_neg-1154892891] Sending `ls'
[08_block_attach_bad_filedevice_neg-1154892891] Sending `echo $?'
[dom0] Running `xm block-attach 08_block_attach_bad_filedevice_neg-1154892891 file:/dev/NOT-EXIST sdb1 w'
Error: Device 2065 (vbd) could not be connected.
File /dev/NOT-EXIST is read-only, and so I will not
mount it read-write in a guest domain.
[08_block_attach_bad_filedevice_neg-1154892891] Sending `cat /proc/partitions'
[08_block_attach_bad_filedevice_neg-1154892891] Sending `echo $?'
[dom0] Running `xm shutdown 08_block_attach_bad_filedevice_neg-1154892891'

PASS: 08_block_attach_bad_filedevice_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
08_block_attach_bad_filedevice_neg-1154892891   7       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  2999.7
[dom0] Running `xm destroy 08_block_attach_bad_filedevice_neg-1154892891'
*** Finished cleaning domUs
*** Test 09_block_attach_and_dettach_device_check_data_pos started at Sun Aug  6 15:35:00 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3001.3
*** Finished cleaning domUs
*** Test 09_block_attach_and_dettach_device_check_data_pos started at Sun Aug  6 15:35:00 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 09_block_attach_and_dettach_device_check_data_pos-1154892900
Console executing: ['/usr/sbin/xm', 'xm', 'console', '09_block_attach_and_dettach_device_check_data_pos-1154892900']
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `input'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `ls'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `mke2fs -q -F /dev/ram1'

[dom0] Running `xm block-attach 09_block_attach_and_dettach_device_check_data_pos-1154892900 phy:ram1 hda1 w'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''
4
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo "0" > /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
0

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `umount /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-detach 09_block_attach_and_dettach_device_check_data_pos-1154892900 hda1'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-attach 09_block_attach_and_dettach_device_check_data_pos-1154892900 phy:ram1 hda1 w'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''
4
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile | grep 0'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo "1" > /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
1

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `umount /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-detach 09_block_attach_and_dettach_device_check_data_pos-1154892900 hda1'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-attach 09_block_attach_and_dettach_device_check_data_pos-1154892900 phy:ram1 hda1 w'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''
4
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile | grep 1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo "2" > /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
2

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `umount /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-detach 09_block_attach_and_dettach_device_check_data_pos-1154892900 hda1'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-attach 09_block_attach_and_dettach_device_check_data_pos-1154892900 phy:ram1 hda1 w'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''
4
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile | grep 2'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo "3" > /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
3

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `umount /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-detach 09_block_attach_and_dettach_device_check_data_pos-1154892900 hda1'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-attach 09_block_attach_and_dettach_device_check_data_pos-1154892900 phy:ram1 hda1 w'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''
4
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile | grep 3'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo "4" > /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
4

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `umount /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-detach 09_block_attach_and_dettach_device_check_data_pos-1154892900 hda1'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-attach 09_block_attach_and_dettach_device_check_data_pos-1154892900 phy:ram1 hda1 w'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''
4
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile | grep 4'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo "5" > /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
5

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `umount /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-detach 09_block_attach_and_dettach_device_check_data_pos-1154892900 hda1'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-attach 09_block_attach_and_dettach_device_check_data_pos-1154892900 phy:ram1 hda1 w'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''
4
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile | grep 5'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo "6" > /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
6

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `umount /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-detach 09_block_attach_and_dettach_device_check_data_pos-1154892900 hda1'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-attach 09_block_attach_and_dettach_device_check_data_pos-1154892900 phy:ram1 hda1 w'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''
4
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile | grep 6'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo "7" > /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
7

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `umount /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-detach 09_block_attach_and_dettach_device_check_data_pos-1154892900 hda1'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-attach 09_block_attach_and_dettach_device_check_data_pos-1154892900 phy:ram1 hda1 w'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''
4
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile | grep 7'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo "8" > /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
8

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `umount /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-detach 09_block_attach_and_dettach_device_check_data_pos-1154892900 hda1'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-attach 09_block_attach_and_dettach_device_check_data_pos-1154892900 phy:ram1 hda1 w'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''
4
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile | grep 8'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo "9" > /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /mnt/hda1/myfile'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
9

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `umount /mnt/hda1'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm block-detach 09_block_attach_and_dettach_device_check_data_pos-1154892900 hda1'

[dom0] Running `xm block-list 09_block_attach_and_dettach_device_check_data_pos-1154892900 | awk '/^769/ {print $4}''

[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `cat /proc/partitions'
[09_block_attach_and_dettach_device_check_data_pos-1154892900] Sending `echo $?'
[dom0] Running `xm shutdown 09_block_attach_and_dettach_device_check_data_pos-1154892900'

PASS: 09_block_attach_and_dettach_device_check_data_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
09_block_attach_and_dettach_device_check_data_pos-1154892900   8       64     1 -b----     0.7
Domain-0                           0     5000    32 r-----  3025.8
[dom0] Running `xm destroy 09_block_attach_and_dettach_device_check_data_pos-1154892900'
*** Finished cleaning domUs
*** Test 11_block_attach_shared_dom0 started at Sun Aug  6 15:37:39 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3027.4
*** Finished cleaning domUs
*** Test 11_block_attach_shared_dom0 started at Sun Aug  6 15:37:39 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `mkfs /dev/ram0'
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
4096 inodes, 16384 blocks
819 blocks (5.00%) reserved for the super user
First data block=1
2 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
	8193

Writing inode tables: 0/2\b\b\b1/2\b\b\bdone                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[dom0] Running `mkdir -p mnt'

[dom0] Running `mount /dev/ram0 mnt -o rw'

[dom0] Running `xm create /tmp/xm-test.conf'
Error: Device 769 (vbd) could not be connected.
Device /dev/ram0 is mounted in the privileged domain,
and so cannot be mounted by a guest.
Using config file "/tmp/xm-test.conf".
[dom0] Running `umount mnt'

[dom0] Running `xm destroy 11_block_attach_shared_dom0-1154893059'
Error: an integer is required
PASS: 11_block_attach_shared_dom0.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3030.4
*** Finished cleaning domUs
*** Test 12_block_attach_shared_domU started at Sun Aug  6 15:37:41 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3030.7
*** Finished cleaning domUs
*** Test 12_block_attach_shared_domU started at Sun Aug  6 15:37:42 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 12_block_attach_shared_domU-1154893062
Console executing: ['/usr/sbin/xm', 'xm', 'console', '12_block_attach_shared_domU-1154893062']
[12_block_attach_shared_domU-1154893062] Sending `input'
[dom0] Running `xm create /tmp/xm-test.conf'
Error: Device 769 (vbd) could not be connected.
Device /dev/ram0 is mounted in a guest domain,
and so cannot be mounted now.
Using config file "/tmp/xm-test.conf".
[dom0] Running `xm destroy 12_block_attach_shared_domU-1154893062'

[dom0] Running `xm destroy 12_block_attach_shared_domU-1154893062-2'
Error: an integer is required
PASS: 12_block_attach_shared_domU.test
===================
All 10 tests passed
===================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-create'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-create'
*** case block-destroy from group default
*** Running tests for case block-destroy
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-destroy'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-destroy'
cp 01_block-destroy_btblock_pos.py 01_block-destroy_btblock_pos.test
chmod +x 01_block-destroy_btblock_pos.test
cp 02_block-destroy_rtblock_pos.py 02_block-destroy_rtblock_pos.test
chmod +x 02_block-destroy_rtblock_pos.test
cp 03_block-destroy_nonexist_neg.py 03_block-destroy_nonexist_neg.test
chmod +x 03_block-destroy_nonexist_neg.test
cp 04_block-destroy_nonattached_neg.py 04_block-destroy_nonattached_neg.test
chmod +x 04_block-destroy_nonattached_neg.test
cp 05_block-destroy_byname_pos.py 05_block-destroy_byname_pos.test
chmod +x 05_block-destroy_byname_pos.test
cp 06_block-destroy_check_list_pos.py 06_block-destroy_check_list_pos.test
chmod +x 06_block-destroy_check_list_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3036.2
*** Finished cleaning domUs
*** Test 01_block-destroy_btblock_pos started at Sun Aug  6 15:37:47 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3036.6
*** Finished cleaning domUs
*** Test 01_block-destroy_btblock_pos started at Sun Aug  6 15:37:48 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_block-destroy_btblock_pos-1154893068
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_block-destroy_btblock_pos-1154893068']
[01_block-destroy_btblock_pos-1154893068] Sending `input'
[01_block-destroy_btblock_pos-1154893068] Sending `cat /proc/partitions | grep hda1'
[01_block-destroy_btblock_pos-1154893068] Sending `echo $?'
[01_block-destroy_btblock_pos-1154893068] Sending `cat /proc/partitions'
[01_block-destroy_btblock_pos-1154893068] Sending `echo $?'
[dom0] Running `xm block-detach 01_block-destroy_btblock_pos-1154893068 hda1'

[dom0] Running `xm block-list 01_block-destroy_btblock_pos-1154893068 | awk '/^769/ {print $4}''

[01_block-destroy_btblock_pos-1154893068] Sending `cat /proc/partitions | grep hda1'
[01_block-destroy_btblock_pos-1154893068] Sending `echo $?'
[dom0] Running `xm shutdown 01_block-destroy_btblock_pos-1154893068'

PASS: 01_block-destroy_btblock_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
01_block-destroy_btblock_pos-1154893068  12       64     1 -b----     0.4
Domain-0                           0     5000    32 r-----  3040.1
[dom0] Running `xm destroy 01_block-destroy_btblock_pos-1154893068'
*** Finished cleaning domUs
*** Test 02_block-destroy_rtblock_pos started at Sun Aug  6 15:37:59 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3040.9
*** Finished cleaning domUs
*** Test 02_block-destroy_rtblock_pos started at Sun Aug  6 15:37:59 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 02_block-destroy_rtblock_pos-1154893079
Console executing: ['/usr/sbin/xm', 'xm', 'console', '02_block-destroy_rtblock_pos-1154893079']
[02_block-destroy_rtblock_pos-1154893079] Sending `input'
[dom0] Running `xm block-attach 02_block-destroy_rtblock_pos-1154893079 phy:/dev/ram0 hda1 w'

[dom0] Running `xm block-list 02_block-destroy_rtblock_pos-1154893079 | awk '/^769/ {print $4}''
4
[02_block-destroy_rtblock_pos-1154893079] Sending `cat /proc/partitions | grep hda1'
[02_block-destroy_rtblock_pos-1154893079] Sending `echo $?'
[dom0] Running `xm block-detach 02_block-destroy_rtblock_pos-1154893079 hda1'

[dom0] Running `xm block-list 02_block-destroy_rtblock_pos-1154893079 | awk '/^769/ {print $4}''

[02_block-destroy_rtblock_pos-1154893079] Sending `cat /proc/partitions | grep hda1'
[02_block-destroy_rtblock_pos-1154893079] Sending `echo $?'
[dom0] Running `xm shutdown 02_block-destroy_rtblock_pos-1154893079'

PASS: 02_block-destroy_rtblock_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
02_block-destroy_rtblock_pos-1154893079  13       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3044.8
[dom0] Running `xm destroy 02_block-destroy_rtblock_pos-1154893079'
*** Finished cleaning domUs
*** Test 03_block-destroy_nonexist_neg started at Sun Aug  6 15:38:09 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3045.7
*** Finished cleaning domUs
*** Test 03_block-destroy_nonexist_neg started at Sun Aug  6 15:38:10 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm block-detach 9999 769'
Error: the domain '9999' does not exist.
PASS: 03_block-destroy_nonexist_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3046.4
*** Finished cleaning domUs
*** Test 04_block-destroy_nonattached_neg started at Sun Aug  6 15:38:10 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3046.8
*** Finished cleaning domUs
*** Test 04_block-destroy_nonattached_neg started at Sun Aug  6 15:38:11 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 04_block-destroy_nonattached_neg-1154893091
[dom0] Running `xm domid 04_block-destroy_nonattached_neg-1154893091'
14
[dom0] Running `xm block-detach 14 sda1'
Error: Device sda1 not connected
PASS: 04_block-destroy_nonattached_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
04_block-destroy_nonattached_neg-1154893091  14       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3048.3
[dom0] Running `xm destroy 04_block-destroy_nonattached_neg-1154893091'
*** Finished cleaning domUs
*** Test 05_block-destroy_byname_pos started at Sun Aug  6 15:38:12 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3049.1
*** Finished cleaning domUs
*** Test 05_block-destroy_byname_pos started at Sun Aug  6 15:38:13 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 05_block-destroy_byname_pos-1154893093
Console executing: ['/usr/sbin/xm', 'xm', 'console', '05_block-destroy_byname_pos-1154893093']
[05_block-destroy_byname_pos-1154893093] Sending `input'
[05_block-destroy_byname_pos-1154893093] Sending `cat /proc/partitions | grep hda1'
[05_block-destroy_byname_pos-1154893093] Sending `echo $?'
[05_block-destroy_byname_pos-1154893093] Sending `cat /proc/partitions'
[05_block-destroy_byname_pos-1154893093] Sending `echo $?'
[dom0] Running `xm block-detach 05_block-destroy_byname_pos-1154893093 hda1'

[dom0] Running `xm block-list 05_block-destroy_byname_pos-1154893093 | awk '/^769/ {print $4}''

[05_block-destroy_byname_pos-1154893093] Sending `cat /proc/partitions | grep hda1'
[05_block-destroy_byname_pos-1154893093] Sending `echo $?'
[dom0] Running `xm shutdown 05_block-destroy_byname_pos-1154893093'

PASS: 05_block-destroy_byname_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
05_block-destroy_byname_pos-1154893093  15       64     1 -b----     0.4
Domain-0                           0     5000    32 r-----  3052.5
[dom0] Running `xm destroy 05_block-destroy_byname_pos-1154893093'
*** Finished cleaning domUs
*** Test 06_block-destroy_check_list_pos started at Sun Aug  6 15:38:24 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3054.0
*** Finished cleaning domUs
*** Test 06_block-destroy_check_list_pos started at Sun Aug  6 15:38:24 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 06_block-destroy_check_list_pos-1154893104
Console executing: ['/usr/sbin/xm', 'xm', 'console', '06_block-destroy_check_list_pos-1154893104']
[06_block-destroy_check_list_pos-1154893104] Sending `input'
[dom0] Running `xm block-attach 06_block-destroy_check_list_pos-1154893104 phy:/dev/ram0 hda1 w'

[dom0] Running `xm block-list 06_block-destroy_check_list_pos-1154893104 | awk '/^769/ {print $4}''
4
[dom0] Running `xm list --long 06_block-destroy_check_list_pos-1154893104'
(domain
    (domid 16)
    (uuid 56ca38e3-96ff-21cd-0327-d1e7defd22d3)
    (vcpus 1)
    (cpu_weight 1.0)
    (memory 64)
    (maxmem 64)
    (features )
    (name 06_block-destroy_check_list_pos-1154893104)
    (on_poweroff destroy)
    (on_reboot restart)
    (on_crash restart)
    (image
        (linux
            (kernel /boot/vmlinuz-2.6.16.13-xen)
            (ramdisk
                /home/unisys/xen-unstable.hg/tools/xm-test/ramdisk/initrd.img
            )
            (root /dev/ram0)
        )
    )
    (device (vbd (backend 0) (dev hda1) (uname phy:/dev/ram0) (mode w)))
    (state -b----)
    (shutdown_reason poweroff)
    (cpu_time 0.30665032)
    (online_vcpus 1)
    (up_time 3.50040507317)
    (start_time 1154893105.21)
    (store_mfn 32782250)
    (console_mfn 32678893)
)
[dom0] Running `xm block-detach 06_block-destroy_check_list_pos-1154893104 hda1'

[dom0] Running `xm block-list 06_block-destroy_check_list_pos-1154893104 | awk '/^769/ {print $4}''

[dom0] Running `xm list --long 06_block-destroy_check_list_pos-1154893104'
(domain
    (domid 16)
    (uuid 56ca38e3-96ff-21cd-0327-d1e7defd22d3)
    (vcpus 1)
    (cpu_weight 1.0)
    (memory 64)
    (maxmem 64)
    (features )
    (name 06_block-destroy_check_list_pos-1154893104)
    (on_poweroff destroy)
    (on_reboot restart)
    (on_crash restart)
    (image
        (linux
            (kernel /boot/vmlinuz-2.6.16.13-xen)
            (ramdisk
                /home/unisys/xen-unstable.hg/tools/xm-test/ramdisk/initrd.img
            )
            (root /dev/ram0)
        )
    )
    (state -b----)
    (shutdown_reason poweroff)
    (cpu_time 0.307626236)
    (online_vcpus 1)
    (up_time 4.59396004677)
    (start_time 1154893105.21)
    (store_mfn 32782250)
    (console_mfn 32678893)
)
PASS: 06_block-destroy_check_list_pos.test
==================
All 6 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-destroy'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-destroy'
*** case block-list from group default
*** Running tests for case block-list
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-list'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-list'
cp 01_block-list_pos.py 01_block-list_pos.test
chmod +x 01_block-list_pos.test
cp 02_block-list_attachbd_pos.py 02_block-list_attachbd_pos.test
chmod +x 02_block-list_attachbd_pos.test
cp 03_block-list_anotherbd_pos.py 03_block-list_anotherbd_pos.test
chmod +x 03_block-list_anotherbd_pos.test
cp 04_block-list_nodb_pos.py 04_block-list_nodb_pos.test
chmod +x 04_block-list_nodb_pos.test
cp 05_block-list_nonexist_neg.py 05_block-list_nonexist_neg.test
chmod +x 05_block-list_nonexist_neg.test
cp 06_block-list_checkremove_pos.py 06_block-list_checkremove_pos.test
chmod +x 06_block-list_checkremove_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
06_block-destroy_check_list_pos-1154893104  16       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3058.1
[dom0] Running `xm destroy 06_block-destroy_check_list_pos-1154893104'
*** Finished cleaning domUs
*** Test 01_block-list_pos started at Sun Aug  6 15:38:30 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3059.0
*** Finished cleaning domUs
*** Test 01_block-list_pos started at Sun Aug  6 15:38:31 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_block-list_pos-1154893111
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_block-list_pos-1154893111']
[01_block-list_pos-1154893111] Sending `input'
[dom0] Running `xm domid 01_block-list_pos-1154893111'
17
[dom0] Running `xm block-list 17'
Vdev  BE handle state evt-ch ring-ref BE-path
769    0    0     4      6      8     /local/domain/0/backend/vbd/17/769  
[01_block-list_pos-1154893111] Sending `cat /proc/partitions | grep hda1'
[01_block-list_pos-1154893111] Sending `echo $?'
[dom0] Running `xm shutdown 01_block-list_pos-1154893111'

PASS: 01_block-list_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
01_block-list_pos-1154893111      17       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3062.0
[dom0] Running `xm destroy 01_block-list_pos-1154893111'
*** Finished cleaning domUs
*** Test 02_block-list_attachbd_pos started at Sun Aug  6 15:38:38 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3063.3
*** Finished cleaning domUs
*** Test 02_block-list_attachbd_pos started at Sun Aug  6 15:38:38 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 02_block-list_attachbd_pos-1154893118
Console executing: ['/usr/sbin/xm', 'xm', 'console', '02_block-list_attachbd_pos-1154893118']
[02_block-list_attachbd_pos-1154893118] Sending `input'
[dom0] Running `xm block-attach 02_block-list_attachbd_pos-1154893118 phy:/dev/ram0 hda1 w'

[dom0] Running `xm block-list 02_block-list_attachbd_pos-1154893118 | awk '/^769/ {print $4}''
4
[dom0] Running `xm domid 02_block-list_attachbd_pos-1154893118'
18
[dom0] Running `xm block-list 18'
Vdev  BE handle state evt-ch ring-ref BE-path
769    0    0     4      6      8     /local/domain/0/backend/vbd/18/769  
[02_block-list_attachbd_pos-1154893118] Sending `cat /proc/partitions | grep hda1'
[02_block-list_attachbd_pos-1154893118] Sending `echo $?'
[dom0] Running `xm shutdown 02_block-list_attachbd_pos-1154893118'

PASS: 02_block-list_attachbd_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
02_block-list_attachbd_pos-1154893118  18       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3066.6
[dom0] Running `xm destroy 02_block-list_attachbd_pos-1154893118'
*** Finished cleaning domUs
*** Test 03_block-list_anotherbd_pos started at Sun Aug  6 15:38:46 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3068.1
*** Finished cleaning domUs
*** Test 03_block-list_anotherbd_pos started at Sun Aug  6 15:38:46 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 03_block-list_anotherbd_pos-1154893126
Console executing: ['/usr/sbin/xm', 'xm', 'console', '03_block-list_anotherbd_pos-1154893126']
[03_block-list_anotherbd_pos-1154893126] Sending `input'
[dom0] Running `xm domid 03_block-list_anotherbd_pos-1154893126'
19
[dom0] Running `xm block-list 19'
Vdev  BE handle state evt-ch ring-ref BE-path
769    0    0     4      6      8     /local/domain/0/backend/vbd/19/769  
[dom0] Running `xm domid 03_block-list_anotherbd_pos-1154893126'
19
[dom0] Running `xm block-attach 19 phy:/dev/ram1 hda2 w'

[dom0] Running `xm domid 03_block-list_anotherbd_pos-1154893126'
19
[dom0] Running `xm block-list 19'
Vdev  BE handle state evt-ch ring-ref BE-path
769    0    0     4      6      8     /local/domain/0/backend/vbd/19/769  
770    0    0     4      7      9     /local/domain/0/backend/vbd/19/770  
[03_block-list_anotherbd_pos-1154893126] Sending `cat /proc/partitions | grep hda1;cat /proc/partitions | grep hda2'
[03_block-list_anotherbd_pos-1154893126] Sending `echo $?'
[dom0] Running `xm shutdown 03_block-list_anotherbd_pos-1154893126'

PASS: 03_block-list_anotherbd_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_block-list_anotherbd_pos-1154893126  19       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3072.6
[dom0] Running `xm destroy 03_block-list_anotherbd_pos-1154893126'
*** Finished cleaning domUs
*** Test 04_block-list_nodb_pos started at Sun Aug  6 15:38:54 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3074.5
*** Finished cleaning domUs
*** Test 04_block-list_nodb_pos started at Sun Aug  6 15:38:55 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 04_block-list_nodb_pos-1154893135
[dom0] Running `xm domid 04_block-list_nodb_pos-1154893135'
20
[dom0] Running `xm block-list 20'

PASS: 04_block-list_nodb_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
04_block-list_nodb_pos-1154893135  20       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3076.1
[dom0] Running `xm destroy 04_block-list_nodb_pos-1154893135'
*** Finished cleaning domUs
*** Test 05_block-list_nonexist_neg started at Sun Aug  6 15:38:57 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3077.3
*** Finished cleaning domUs
*** Test 05_block-list_nonexist_neg started at Sun Aug  6 15:38:57 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm block-list 9999'
Error: the domain '9999' does not exist.
PASS: 05_block-list_nonexist_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3078.0
*** Finished cleaning domUs
*** Test 06_block-list_checkremove_pos started at Sun Aug  6 15:38:58 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3078.3
*** Finished cleaning domUs
*** Test 06_block-list_checkremove_pos started at Sun Aug  6 15:38:58 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 06_block-list_checkremove_pos-1154893138
[dom0] Running `xm block-list 06_block-list_checkremove_pos-1154893138'

[dom0] Running `xm block-attach 06_block-list_checkremove_pos-1154893138 phy:/dev/ram0 hda1 w'

[dom0] Running `xm block-list 06_block-list_checkremove_pos-1154893138 | awk '/^769/ {print $4}''
4
[dom0] Running `xm block-list 06_block-list_checkremove_pos-1154893138'
Vdev  BE handle state evt-ch ring-ref BE-path
769    0    0     4      6      8     /local/domain/0/backend/vbd/21/769  
[dom0] Running `xm block-attach 06_block-list_checkremove_pos-1154893138 phy:/dev/ram1 hda2 w'

[dom0] Running `xm block-list 06_block-list_checkremove_pos-1154893138 | awk '/^770/ {print $4}''
4
[dom0] Running `xm block-list 06_block-list_checkremove_pos-1154893138'
Vdev  BE handle state evt-ch ring-ref BE-path
769    0    0     4      6      8     /local/domain/0/backend/vbd/21/769  
770    0    0     4      7      9     /local/domain/0/backend/vbd/21/770  
[dom0] Running `xm block-detach 06_block-list_checkremove_pos-1154893138 hda1'

[dom0] Running `xm block-list 06_block-list_checkremove_pos-1154893138 | awk '/^769/ {print $4}''

[dom0] Running `xm block-list 06_block-list_checkremove_pos-1154893138'
Vdev  BE handle state evt-ch ring-ref BE-path
770    0    0     4      7      9     /local/domain/0/backend/vbd/21/770  
[dom0] Running `xm block-detach 06_block-list_checkremove_pos-1154893138 hda2'

[dom0] Running `xm block-list 06_block-list_checkremove_pos-1154893138 | awk '/^770/ {print $4}''

[dom0] Running `xm block-list 06_block-list_checkremove_pos-1154893138'

[dom0] Running `xm shutdown 06_block-list_checkremove_pos-1154893138'

PASS: 06_block-list_checkremove_pos.test
==================
All 6 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-list'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-list'
*** case block-integrity from group default
*** Running tests for case block-integrity
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-integrity'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-integrity'
cp 01_block_device_read_verify.py 01_block_device_read_verify.test
chmod +x 01_block_device_read_verify.test
cp 02_block_device_write_verify.py 02_block_device_write_verify.test
chmod +x 02_block_device_write_verify.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
06_block-list_checkremove_pos-1154893138  21       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3084.7
[dom0] Running `xm destroy 06_block-list_checkremove_pos-1154893138'
*** Finished cleaning domUs
*** Test 01_block_device_read_verify started at Sun Aug  6 15:39:04 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3085.6
*** Finished cleaning domUs
*** Test 01_block_device_read_verify started at Sun Aug  6 15:39:04 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_block_device_read_verify-1154893144
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_block_device_read_verify-1154893144']
[01_block_device_read_verify-1154893144] Sending `input'
[dom0] Running `cat /dev/urandom > /dev/ram1'
cat: write error: No space left on device
[dom0] Running `md5sum /dev/ram1'
bfc0b1b9a3528bd841e293afe890229b  /dev/ram1
[dom0] Running `xm block-attach 01_block_device_read_verify-1154893144 phy:ram1 hda1 w'

[dom0] Running `xm block-list 01_block_device_read_verify-1154893144 | awk '/^769/ {print $4}''
4
[01_block_device_read_verify-1154893144] Sending `md5sum /dev/hda1'
[01_block_device_read_verify-1154893144] Sending `echo $?'
[dom0] Running `xm shutdown 01_block_device_read_verify-1154893144'

md5sum dom0:
bfc0b1b9a3528bd841e293afe890229b
md5sum domU:
bfc0b1b9a3528bd841e293afe890229b
PASS: 01_block_device_read_verify.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
01_block_device_read_verify-1154893144  22       64     1 -b----     0.6
Domain-0                           0     5000    32 r-----  3092.4
[dom0] Running `xm destroy 01_block_device_read_verify-1154893144'
*** Finished cleaning domUs
*** Test 02_block_device_write_verify started at Sun Aug  6 15:39:16 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3093.9
*** Finished cleaning domUs
*** Test 02_block_device_write_verify started at Sun Aug  6 15:39:16 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 02_block_device_write_verify-1154893156
Console executing: ['/usr/sbin/xm', 'xm', 'console', '02_block_device_write_verify-1154893156']
[02_block_device_write_verify-1154893156] Sending `input'
[dom0] Running `xm block-attach 02_block_device_write_verify-1154893156 phy:ram1 hda1 w'

[dom0] Running `xm block-list 02_block_device_write_verify-1154893156 | awk '/^769/ {print $4}''
4
[02_block_device_write_verify-1154893156] Sending `dd if=/dev/urandom bs=512 count=`cat /sys/block/hda1/size` | tee /dev/hda1 | md5sum'
[02_block_device_write_verify-1154893156] Sending `echo $?'
[dom0] Running `xm shutdown 02_block_device_write_verify-1154893156'

[dom0] Running `md5sum /dev/ram1'
0c4324aeb57c9f651d0e87f39382e5ac  /dev/ram1
md5sum domU:
0c4324aeb57c9f651d0e87f39382e5ac
md5sum dom0:
0c4324aeb57c9f651d0e87f39382e5ac
PASS: 02_block_device_write_verify.test
==================
All 2 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-integrity'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/block-integrity'
*** case console from group default
*** Running tests for case console
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/console'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/console'
cp 01_console_badopt_neg.py 01_console_badopt_neg.test
chmod +x 01_console_badopt_neg.test
cp 02_console_baddom_neg.py 02_console_baddom_neg.test
chmod +x 02_console_baddom_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
02_block_device_write_verify-1154893156  23       64     1 -b----     4.9
Domain-0                           0     5000    32 r-----  3097.5
[dom0] Running `xm destroy 02_block_device_write_verify-1154893156'
*** Finished cleaning domUs
*** Test 01_console_badopt_neg started at Sun Aug  6 15:39:28 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3099.2
*** Finished cleaning domUs
*** Test 01_console_badopt_neg started at Sun Aug  6 15:39:28 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm console -x'
Error: the domain '-x' does not exist.
PASS: 01_console_badopt_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3099.9
*** Finished cleaning domUs
*** Test 02_console_baddom_neg started at Sun Aug  6 15:39:29 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3100.3
*** Finished cleaning domUs
*** Test 02_console_baddom_neg started at Sun Aug  6 15:39:29 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm console 5000'
Error: the domain '5000' does not exist.
[dom0] Running `xm console NON_EXIST'
Error: the domain 'NON_EXIST' does not exist.
PASS: 02_console_baddom_neg.test
==================
All 2 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/console'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/console'
*** case create from group default
*** Running tests for case create
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/create'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/create'
cp 01_create_basic_pos.py 01_create_basic_pos.test
chmod +x 01_create_basic_pos.test
cp 02_create_noparm_neg.py 02_create_noparm_neg.test
chmod +x 02_create_noparm_neg.test
cp 03_create_badparm_neg.py 03_create_badparm_neg.test
chmod +x 03_create_badparm_neg.test
cp 04_create_conflictname_neg.py 04_create_conflictname_neg.test
chmod +x 04_create_conflictname_neg.test
cp 06_create_mem_neg.py 06_create_mem_neg.test
chmod +x 06_create_mem_neg.test
cp 07_create_mem64_pos.py 07_create_mem64_pos.test
chmod +x 07_create_mem64_pos.test
cp 08_create_mem128_pos.py 08_create_mem128_pos.test
chmod +x 08_create_mem128_pos.test
cp 09_create_mem256_pos.py 09_create_mem256_pos.test
chmod +x 09_create_mem256_pos.test
cp 10_create_fastdestroy.py 10_create_fastdestroy.test
chmod +x 10_create_fastdestroy.test
cp 11_create_concurrent_pos.py 11_create_concurrent_pos.test
chmod +x 11_create_concurrent_pos.test
cp 12_create_concurrent_stress_pos.py 12_create_concurrent_stress_pos.test
chmod +x 12_create_concurrent_stress_pos.test
cp 13_create_multinic_pos.py 13_create_multinic_pos.test
chmod +x 13_create_multinic_pos.test
cp 14_create_blockroot_pos.py 14_create_blockroot_pos.test
chmod +x 14_create_blockroot_pos.test
cp 15_create_smallmem_pos.py 15_create_smallmem_pos.test
chmod +x 15_create_smallmem_pos.test
cp 16_create_smallmem_neg.py 16_create_smallmem_neg.test
chmod +x 16_create_smallmem_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3101.4
*** Finished cleaning domUs
*** Test 01_create_basic_pos started at Sun Aug  6 15:39:31 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3101.8
*** Finished cleaning domUs
*** Test 01_create_basic_pos started at Sun Aug  6 15:39:31 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_create_basic_pos-1154893171
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_create_basic_pos-1154893171']
[01_create_basic_pos-1154893171] Sending `input'
[01_create_basic_pos-1154893171] Sending `ls'
[01_create_basic_pos-1154893171] Sending `echo $?'
[dom0] Running `xm shutdown 01_create_basic_pos-1154893171'

PASS: 01_create_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
01_create_basic_pos-1154893171    24       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3103.8
[dom0] Running `xm destroy 01_create_basic_pos-1154893171'
*** Finished cleaning domUs
*** Test 02_create_noparm_neg started at Sun Aug  6 15:39:37 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3104.7
*** Finished cleaning domUs
*** Test 02_create_noparm_neg started at Sun Aug  6 15:39:38 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create'
Error: Cannot open config file "xmdefconfig"
PASS: 02_create_noparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3105.3
*** Finished cleaning domUs
*** Test 03_create_badparm_neg started at Sun Aug  6 15:39:38 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3105.6
*** Finished cleaning domUs
*** Test 03_create_badparm_neg started at Sun Aug  6 15:39:38 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create -x'
Error: option -x not recognized
PASS: 03_create_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3106.3
*** Finished cleaning domUs
*** Test 04_create_conflictname_neg started at Sun Aug  6 15:39:39 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3106.7
*** Finished cleaning domUs
*** Test 04_create_conflictname_neg started at Sun Aug  6 15:39:39 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain default
[dom0] Running `xm create /tmp/xm-test.conf'
Error: VM name 'default' already in use by domain 25
Using config file "/tmp/xm-test.conf".
[dom0] Running `xm shutdown default'

PASS: 04_create_conflictname_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3108.3
default                           25       64     1 -b----     0.3
[dom0] Running `xm destroy default'
*** Finished cleaning domUs
*** Test 06_create_mem_neg started at Sun Aug  6 15:39:42 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3109.5
*** Finished cleaning domUs
*** Test 06_create_mem_neg started at Sun Aug  6 15:39:42 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Error: (9, 'Bad file descriptor')
Using config file "/tmp/xm-test.conf".
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Error: I need 134192128 KiB, but dom0_min_mem is 200704 and shrinking to 200704 KiB would leave only 132292260 KiB free.
Using config file "/tmp/xm-test.conf".
PASS: 06_create_mem_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3113.7
*** Finished cleaning domUs
*** Test 07_create_mem64_pos started at Sun Aug  6 15:41:46 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3114.1
*** Finished cleaning domUs
*** Test 07_create_mem64_pos started at Sun Aug  6 15:41:46 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_create_mem64_pos-1154893307
[dom0] Running `xm domid 07_create_mem64_pos-1154893307'
28
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
07_create_mem64_pos-1154893307    28       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3115.6
[dom0] Running `xm shutdown 07_create_mem64_pos-1154893307'

PASS: 07_create_mem64_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
07_create_mem64_pos-1154893307    28       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3116.2
[dom0] Running `xm destroy 07_create_mem64_pos-1154893307'
*** Finished cleaning domUs
*** Test 08_create_mem128_pos started at Sun Aug  6 15:41:49 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3117.9
*** Finished cleaning domUs
*** Test 08_create_mem128_pos started at Sun Aug  6 15:41:49 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 08_create_mem128_pos-1154893309
[dom0] Running `xm domid 08_create_mem128_pos-1154893309'
29
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
08_create_mem128_pos-1154893309   29      128     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3119.5
[dom0] Running `xm shutdown 08_create_mem128_pos-1154893309'

PASS: 08_create_mem128_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
08_create_mem128_pos-1154893309   29      128     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3120.1
[dom0] Running `xm destroy 08_create_mem128_pos-1154893309'
*** Finished cleaning domUs
*** Test 09_create_mem256_pos started at Sun Aug  6 15:41:52 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3122.3
*** Finished cleaning domUs
*** Test 09_create_mem256_pos started at Sun Aug  6 15:41:52 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 09_create_mem256_pos-1154893313
[dom0] Running `xm domid 09_create_mem256_pos-1154893313'
30
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
09_create_mem256_pos-1154893313   30      256     1 r-----     0.4
Domain-0                           0     5000    32 r-----  3124.0
[dom0] Running `xm shutdown 09_create_mem256_pos-1154893313'

PASS: 09_create_mem256_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
09_create_mem256_pos-1154893313   30      256     1 -b----     0.4
Domain-0                           0     5000    32 r-----  3124.6
[dom0] Running `xm destroy 09_create_mem256_pos-1154893313'
*** Finished cleaning domUs
*** Test 10_create_fastdestroy started at Sun Aug  6 15:41:55 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3126.5
*** Finished cleaning domUs
*** Test 10_create_fastdestroy started at Sun Aug  6 15:41:56 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain testdomain
[dom0] Running `xm destroy testdomain'

PASS: 10_create_fastdestroy.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3201.7
*** Finished cleaning domUs
*** Test 11_create_concurrent_pos started at Sun Aug  6 15:42:50 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3202.0
*** Finished cleaning domUs
*** Test 11_create_concurrent_pos started at Sun Aug  6 15:42:50 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
*** 5182 doms is too many: capping at 50
Watch out!  I'm trying to create 50 DomUs!
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_0
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_0']
[11_create_0] Sending `input'
[11_create_0] Sending `ls'
[11_create_0] Sending `echo $?'
[0] Started 11_create_0
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_1
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_1']
[11_create_1] Sending `input'
[11_create_1] Sending `ls'
[11_create_1] Sending `echo $?'
[1] Started 11_create_1
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_2
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_2']
[11_create_2] Sending `input'
[11_create_2] Sending `ls'
[11_create_2] Sending `echo $?'
[2] Started 11_create_2
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_3
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_3']
[11_create_3] Sending `input'
[11_create_3] Sending `ls'
[11_create_3] Sending `echo $?'
[3] Started 11_create_3
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_4
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_4']
[11_create_4] Sending `input'
[11_create_4] Sending `ls'
[11_create_4] Sending `echo $?'
[4] Started 11_create_4
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_5
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_5']
[11_create_5] Sending `input'
[11_create_5] Sending `ls'
[11_create_5] Sending `echo $?'
[5] Started 11_create_5
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_6
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_6']
[11_create_6] Sending `input'
[11_create_6] Sending `ls'
[11_create_6] Sending `echo $?'
[6] Started 11_create_6
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_7
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_7']
[11_create_7] Sending `input'
[11_create_7] Sending `ls'
[11_create_7] Sending `echo $?'
[7] Started 11_create_7
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_8
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_8']
[11_create_8] Sending `input'
[11_create_8] Sending `ls'
[11_create_8] Sending `echo $?'
[8] Started 11_create_8
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_9
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_9']
[11_create_9] Sending `input'
[11_create_9] Sending `ls'
[11_create_9] Sending `echo $?'
[9] Started 11_create_9
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_10
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_10']
[11_create_10] Sending `input'
[11_create_10] Sending `ls'
[11_create_10] Sending `echo $?'
[10] Started 11_create_10
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_11
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_11']
[11_create_11] Sending `input'
[11_create_11] Sending `ls'
[11_create_11] Sending `echo $?'
[11] Started 11_create_11
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_12
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_12']
[11_create_12] Sending `input'
[11_create_12] Sending `ls'
[11_create_12] Sending `echo $?'
[12] Started 11_create_12
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_13
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_13']
[11_create_13] Sending `input'
[11_create_13] Sending `ls'
[11_create_13] Sending `echo $?'
[13] Started 11_create_13
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_14
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_14']
[11_create_14] Sending `input'
[11_create_14] Sending `ls'
[11_create_14] Sending `echo $?'
[14] Started 11_create_14
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_15
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_15']
[11_create_15] Sending `input'
[11_create_15] Sending `ls'
[11_create_15] Sending `echo $?'
[15] Started 11_create_15
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_16
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_16']
[11_create_16] Sending `input'
[11_create_16] Sending `ls'
[11_create_16] Sending `echo $?'
[16] Started 11_create_16
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_17
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_17']
[11_create_17] Sending `input'
[11_create_17] Sending `ls'
[11_create_17] Sending `echo $?'
[17] Started 11_create_17
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_18
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_18']
[11_create_18] Sending `input'
[11_create_18] Sending `ls'
[11_create_18] Sending `echo $?'
[18] Started 11_create_18
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_19
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_19']
[11_create_19] Sending `input'
[11_create_19] Sending `ls'
[11_create_19] Sending `echo $?'
[19] Started 11_create_19
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_20
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_20']
[11_create_20] Sending `input'
[11_create_20] Sending `ls'
[11_create_20] Sending `echo $?'
[20] Started 11_create_20
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_21
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_21']
[11_create_21] Sending `input'
[11_create_21] Sending `ls'
[11_create_21] Sending `echo $?'
[21] Started 11_create_21
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_22
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_22']
[11_create_22] Sending `input'
[11_create_22] Sending `ls'
[11_create_22] Sending `echo $?'
[22] Started 11_create_22
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_23
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_23']
[11_create_23] Sending `input'
[11_create_23] Sending `ls'
[11_create_23] Sending `echo $?'
[23] Started 11_create_23
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_24
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_24']
[11_create_24] Sending `input'
[11_create_24] Sending `ls'
[11_create_24] Sending `echo $?'
[24] Started 11_create_24
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_25
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_25']
[11_create_25] Sending `input'
[11_create_25] Sending `ls'
[11_create_25] Sending `echo $?'
[25] Started 11_create_25
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_26
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_26']
[11_create_26] Sending `input'
[11_create_26] Sending `ls'
[11_create_26] Sending `echo $?'
[26] Started 11_create_26
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_27
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_27']
[11_create_27] Sending `input'
[11_create_27] Sending `ls'
[11_create_27] Sending `echo $?'
[27] Started 11_create_27
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_28
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_28']
[11_create_28] Sending `input'
[11_create_28] Sending `ls'
[11_create_28] Sending `echo $?'
[28] Started 11_create_28
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_29
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_29']
[11_create_29] Sending `input'
[11_create_29] Sending `ls'
[11_create_29] Sending `echo $?'
[29] Started 11_create_29
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_30
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_30']
[11_create_30] Sending `input'
[11_create_30] Sending `ls'
[11_create_30] Sending `echo $?'
[30] Started 11_create_30
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_31
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_31']
[11_create_31] Sending `input'
[11_create_31] Sending `ls'
[11_create_31] Sending `echo $?'
[31] Started 11_create_31
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_32
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_32']
[11_create_32] Sending `input'
[11_create_32] Sending `ls'
[11_create_32] Sending `echo $?'
[32] Started 11_create_32
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 11_create_33
Console executing: ['/usr/sbin/xm', 'xm', 'console', '11_create_33']
Traceback (most recent call last):
  File "./11_create_concurrent_pos.test", line 46, in ?
    cons = dom.start()
  File "/home/unisys/xen-unstable.hg/tools/xm-test/lib/XmTestLib/XenDomain.py", line 233, in start
    return self.getConsole()
  File "/home/unisys/xen-unstable.hg/tools/xm-test/lib/XmTestLib/XenDomain.py", line 284, in getConsole
    self.console.sendInput("input")
  File "/home/unisys/xen-unstable.hg/tools/xm-test/lib/XmTestLib/Console.py", line 241, in sendInput
    realOutput = self.__runCmd(input)
  File "/home/unisys/xen-unstable.hg/tools/xm-test/lib/XmTestLib/Console.py", line 168, in __runCmd
    self.__getprompt(self.consoleFd)
  File "/home/unisys/xen-unstable.hg/tools/xm-test/lib/XmTestLib/Console.py", line 139, in __getprompt
    % self.limit, RUNAWAY)
XmTestLib.Console.ConsoleError: Console run-away (exceeded 131072 bytes)
FAIL: 11_create_concurrent_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
11_create_0                       81       24     1 -b----     0.3
11_create_1                       82       24     1 -b----     0.3
11_create_10                      91       24     1 -b----     0.3
11_create_11                      92       24     1 -b----     0.3
11_create_12                      93       24     1 -b----     0.3
11_create_13                      94       24     1 -b----     0.4
11_create_14                      95       24     1 -b----     0.4
11_create_15                      96       24     1 -b----     0.3
11_create_16                      97       24     1 -b----     0.3
11_create_17                      98       24     1 -b----     0.3
11_create_18                      99       24     1 -b----     0.3
11_create_19                     100       24     1 -b----     0.3
11_create_2                       83       24     1 -b----     0.3
11_create_20                     101       24     1 -b----     0.3
11_create_21                     102       24     1 -b----     0.3
11_create_22                     103       24     1 -b----     0.3
11_create_23                     104       24     1 -b----     0.3
11_create_24                     105       24     1 -b----     0.3
11_create_25                     106       24     1 -b----     0.3
11_create_26                     107       24     1 -b----     0.3
11_create_27                     108       24     1 -b----     0.3
11_create_28                     109       24     1 -b----     0.3
11_create_29                     110       24     1 -b----     0.3
11_create_3                       84       24     1 -b----     0.3
11_create_30                     111       24     1 -b----     0.4
11_create_31                     112       24     1 -b----     0.4
11_create_32                     113       24     1 -b----     0.3
11_create_33                     114       24     1 r-----     3.6
11_create_4                       85       24     1 -b----     0.3
11_create_5                       86       24     1 -b----     0.3
11_create_6                       87       24     1 -b----     0.3
11_create_7                       88       24     1 -b----     0.3
11_create_8                       89       24     1 -b----     0.3
11_create_9                       90       24     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3250.3
[dom0] Running `xm destroy 11_create_0'
[dom0] Running `xm destroy 11_create_1'
[dom0] Running `xm destroy 11_create_10'
[dom0] Running `xm destroy 11_create_11'
[dom0] Running `xm destroy 11_create_12'
[dom0] Running `xm destroy 11_create_13'
[dom0] Running `xm destroy 11_create_14'
[dom0] Running `xm destroy 11_create_15'
[dom0] Running `xm destroy 11_create_16'
[dom0] Running `xm destroy 11_create_17'
[dom0] Running `xm destroy 11_create_18'
[dom0] Running `xm destroy 11_create_19'
[dom0] Running `xm destroy 11_create_2'
[dom0] Running `xm destroy 11_create_20'
[dom0] Running `xm destroy 11_create_21'
[dom0] Running `xm destroy 11_create_22'
[dom0] Running `xm destroy 11_create_23'
[dom0] Running `xm destroy 11_create_24'
[dom0] Running `xm destroy 11_create_25'
[dom0] Running `xm destroy 11_create_26'
[dom0] Running `xm destroy 11_create_27'
[dom0] Running `xm destroy 11_create_28'
[dom0] Running `xm destroy 11_create_29'
[dom0] Running `xm destroy 11_create_3'
[dom0] Running `xm destroy 11_create_30'
[dom0] Running `xm destroy 11_create_31'
[dom0] Running `xm destroy 11_create_32'
[dom0] Running `xm destroy 11_create_33'
[dom0] Running `xm destroy 11_create_4'
[dom0] Running `xm destroy 11_create_5'
[dom0] Running `xm destroy 11_create_6'
[dom0] Running `xm destroy 11_create_7'
[dom0] Running `xm destroy 11_create_8'
[dom0] Running `xm destroy 11_create_9'
*** Finished cleaning domUs
*** Test 12_create_concurrent_stress_pos started at Sun Aug  6 15:46:11 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3275.2
*** Finished cleaning domUs
*** Test 12_create_concurrent_stress_pos started at Sun Aug  6 15:46:12 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 12_create_concurrent_stress_pos-1154893572
Console executing: ['/usr/sbin/xm', 'xm', 'console', '12_create_concurrent_stress_pos-1154893572']
[12_create_concurrent_stress_pos-1154893572] Sending `input'
[0/5] Started 12_create_concurrent_stress_pos-1154893572
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 12_create_concurrent_stress_pos-1154893575
Console executing: ['/usr/sbin/xm', 'xm', 'console', '12_create_concurrent_stress_pos-1154893575']
[12_create_concurrent_stress_pos-1154893575] Sending `input'
[1/5] Started 12_create_concurrent_stress_pos-1154893575
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 12_create_concurrent_stress_pos-1154893578
Console executing: ['/usr/sbin/xm', 'xm', 'console', '12_create_concurrent_stress_pos-1154893578']
[12_create_concurrent_stress_pos-1154893578] Sending `input'
[2/5] Started 12_create_concurrent_stress_pos-1154893578
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 12_create_concurrent_stress_pos-1154893581
Console executing: ['/usr/sbin/xm', 'xm', 'console', '12_create_concurrent_stress_pos-1154893581']
[12_create_concurrent_stress_pos-1154893581] Sending `input'
[3/5] Started 12_create_concurrent_stress_pos-1154893581
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 12_create_concurrent_stress_pos-1154893584
Console executing: ['/usr/sbin/xm', 'xm', 'console', '12_create_concurrent_stress_pos-1154893584']
[12_create_concurrent_stress_pos-1154893584] Sending `input'
[4/5] Started 12_create_concurrent_stress_pos-1154893584
Starting task on 12_create_concurrent_stress_pos-1154893572
[12_create_concurrent_stress_pos-1154893572] Sending `gzip -c </dev/zero >/dev/null &
'
Starting task on 12_create_concurrent_stress_pos-1154893575
[12_create_concurrent_stress_pos-1154893575] Sending `gzip -c </dev/zero >/dev/null &
'
Starting task on 12_create_concurrent_stress_pos-1154893578
[12_create_concurrent_stress_pos-1154893578] Sending `gzip -c </dev/zero >/dev/null &
'
Starting task on 12_create_concurrent_stress_pos-1154893581
[12_create_concurrent_stress_pos-1154893581] Sending `gzip -c </dev/zero >/dev/null &
'
Starting task on 12_create_concurrent_stress_pos-1154893584
[12_create_concurrent_stress_pos-1154893584] Sending `gzip -c </dev/zero >/dev/null &
'
Waiting 60 seconds...
Testing domain 12_create_concurrent_stress_pos-1154893572...
[12_create_concurrent_stress_pos-1154893572] Sending `ls'
[12_create_concurrent_stress_pos-1154893572] Sending `echo $?'
Testing domain 12_create_concurrent_stress_pos-1154893575...
[12_create_concurrent_stress_pos-1154893575] Sending `ls'
[12_create_concurrent_stress_pos-1154893575] Sending `echo $?'
Testing domain 12_create_concurrent_stress_pos-1154893578...
[12_create_concurrent_stress_pos-1154893578] Sending `ls'
[12_create_concurrent_stress_pos-1154893578] Sending `echo $?'
Testing domain 12_create_concurrent_stress_pos-1154893581...
[12_create_concurrent_stress_pos-1154893581] Sending `ls'
[12_create_concurrent_stress_pos-1154893581] Sending `echo $?'
Testing domain 12_create_concurrent_stress_pos-1154893584...
[12_create_concurrent_stress_pos-1154893584] Sending `ls'
[12_create_concurrent_stress_pos-1154893584] Sending `echo $?'
PASS: 12_create_concurrent_stress_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
12_create_concurrent_stress_pos-1154893572 115       32     1 r-----    74.8
12_create_concurrent_stress_pos-1154893575 116       32     1 r-----    73.8
12_create_concurrent_stress_pos-1154893578 117       32     1 r-----    72.8
12_create_concurrent_stress_pos-1154893581 118       32     1 r-----    71.8
12_create_concurrent_stress_pos-1154893584 119       32     1 r-----    70.8
Domain-0                           0     5000    32 r-----  3283.2
[dom0] Running `xm destroy 12_create_concurrent_stress_pos-1154893572'
[dom0] Running `xm destroy 12_create_concurrent_stress_pos-1154893575'
[dom0] Running `xm destroy 12_create_concurrent_stress_pos-1154893578'
[dom0] Running `xm destroy 12_create_concurrent_stress_pos-1154893581'
[dom0] Running `xm destroy 12_create_concurrent_stress_pos-1154893584'
*** Finished cleaning domUs
*** Test 13_create_multinic_pos started at Sun Aug  6 15:47:44 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3286.1
*** Finished cleaning domUs
*** Test 13_create_multinic_pos started at Sun Aug  6 15:47:44 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm domid 13_create_multinic_pos-1154893664'
Error: the domain '13_create_multinic_pos-1154893664' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1154893664
[dom0] Running `ip addr add 169.254.0.2 dev vif0.0'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893664']
[13_create_multinic_pos-1154893664] Sending `input'
[13_create_multinic_pos-1154893664] Sending `ifconfig lo 127.0.0.1'
[13_create_multinic_pos-1154893664] Sending `echo $?'
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893664']
[13_create_multinic_pos-1154893664] Sending `input'
[13_create_multinic_pos-1154893664] Sending `ifconfig eth0 inet 169.254.0.1 netmask 255.255.0.0 up'
[13_create_multinic_pos-1154893664] Sending `echo $?'
[13_create_multinic_pos-1154893664] Sending `ls'
[13_create_multinic_pos-1154893664] Sending `echo $?'
[dom0] Running `ip addr del 169.254.0.2 dev vif0.0'
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (169.254.0.2/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893664']
[13_create_multinic_pos-1154893664] Sending `input'
[13_create_multinic_pos-1154893664] Sending `ifconfig eth0 down'
[13_create_multinic_pos-1154893664] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1154893664'

[dom0] Running `xm domid 13_create_multinic_pos-1154893679'
Error: the domain '13_create_multinic_pos-1154893679' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1154893679
[dom0] Running `ip addr add 169.254.0.2 dev vif0.0'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893679']
[13_create_multinic_pos-1154893679] Sending `input'
[13_create_multinic_pos-1154893679] Sending `ifconfig lo 127.0.0.1'
[13_create_multinic_pos-1154893679] Sending `echo $?'
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893679']
[13_create_multinic_pos-1154893679] Sending `input'
[13_create_multinic_pos-1154893679] Sending `ifconfig eth0 inet 169.254.0.1 netmask 255.255.0.0 up'
[13_create_multinic_pos-1154893679] Sending `echo $?'
[13_create_multinic_pos-1154893679] Sending `ls'
[13_create_multinic_pos-1154893679] Sending `echo $?'
[dom0] Running `ip addr del 169.254.0.2 dev vif0.0'
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (169.254.0.2/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893679']
[13_create_multinic_pos-1154893679] Sending `input'
[13_create_multinic_pos-1154893679] Sending `ifconfig eth0 down'
[13_create_multinic_pos-1154893679] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1154893679'

[dom0] Running `xm domid 13_create_multinic_pos-1154893693'
Error: the domain '13_create_multinic_pos-1154893693' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1154893693
[dom0] Running `ip addr add 169.254.0.2 dev vif0.0'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893693']
[13_create_multinic_pos-1154893693] Sending `input'
[13_create_multinic_pos-1154893693] Sending `ifconfig lo 127.0.0.1'
[13_create_multinic_pos-1154893693] Sending `echo $?'
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893693']
[13_create_multinic_pos-1154893693] Sending `input'
[13_create_multinic_pos-1154893693] Sending `ifconfig eth0 inet 169.254.0.1 netmask 255.255.0.0 up'
[13_create_multinic_pos-1154893693] Sending `echo $?'
[13_create_multinic_pos-1154893693] Sending `ls'
[13_create_multinic_pos-1154893693] Sending `echo $?'
[dom0] Running `ip addr del 169.254.0.2 dev vif0.0'
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (169.254.0.2/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893693']
[13_create_multinic_pos-1154893693] Sending `input'
[13_create_multinic_pos-1154893693] Sending `ifconfig eth0 down'
[13_create_multinic_pos-1154893693] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1154893693'

[dom0] Running `xm domid 13_create_multinic_pos-1154893708'
Error: the domain '13_create_multinic_pos-1154893708' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1154893708
[dom0] Running `ip addr add 169.254.0.2 dev vif0.0'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893708']
[13_create_multinic_pos-1154893708] Sending `input'
[13_create_multinic_pos-1154893708] Sending `ifconfig lo 127.0.0.1'
[13_create_multinic_pos-1154893708] Sending `echo $?'
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893708']
[13_create_multinic_pos-1154893708] Sending `input'
[13_create_multinic_pos-1154893708] Sending `ifconfig eth0 inet 169.254.0.1 netmask 255.255.0.0 up'
[13_create_multinic_pos-1154893708] Sending `echo $?'
[13_create_multinic_pos-1154893708] Sending `ls'
[13_create_multinic_pos-1154893708] Sending `echo $?'
[dom0] Running `ip addr del 169.254.0.2 dev vif0.0'
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (169.254.0.2/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893708']
[13_create_multinic_pos-1154893708] Sending `input'
[13_create_multinic_pos-1154893708] Sending `ifconfig eth0 down'
[13_create_multinic_pos-1154893708] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1154893708'

[dom0] Running `xm domid 13_create_multinic_pos-1154893722'
Error: the domain '13_create_multinic_pos-1154893722' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1154893722
[dom0] Running `ip addr add 169.254.0.2 dev vif0.0'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893722']
[13_create_multinic_pos-1154893722] Sending `input'
[13_create_multinic_pos-1154893722] Sending `ifconfig lo 127.0.0.1'
[13_create_multinic_pos-1154893722] Sending `echo $?'
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893722']
[13_create_multinic_pos-1154893722] Sending `input'
[13_create_multinic_pos-1154893722] Sending `ifconfig eth0 inet 169.254.0.1 netmask 255.255.0.0 up'
[13_create_multinic_pos-1154893722] Sending `echo $?'
[13_create_multinic_pos-1154893722] Sending `ls'
[13_create_multinic_pos-1154893722] Sending `echo $?'
[dom0] Running `ip addr del 169.254.0.2 dev vif0.0'
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (169.254.0.2/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893722']
[13_create_multinic_pos-1154893722] Sending `input'
[13_create_multinic_pos-1154893722] Sending `ifconfig eth0 down'
[13_create_multinic_pos-1154893722] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1154893722'

[dom0] Running `xm domid 13_create_multinic_pos-1154893736'
Error: the domain '13_create_multinic_pos-1154893736' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1154893736
[dom0] Running `ip addr add 169.254.0.2 dev vif0.0'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893736']
[13_create_multinic_pos-1154893736] Sending `input'
[13_create_multinic_pos-1154893736] Sending `ifconfig lo 127.0.0.1'
[13_create_multinic_pos-1154893736] Sending `echo $?'
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893736']
[13_create_multinic_pos-1154893736] Sending `input'
[13_create_multinic_pos-1154893736] Sending `ifconfig eth0 inet 169.254.0.1 netmask 255.255.0.0 up'
[13_create_multinic_pos-1154893736] Sending `echo $?'
[13_create_multinic_pos-1154893736] Sending `ls'
[13_create_multinic_pos-1154893736] Sending `echo $?'
[dom0] Running `ip addr del 169.254.0.2 dev vif0.0'
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (169.254.0.2/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893736']
[13_create_multinic_pos-1154893736] Sending `input'
[13_create_multinic_pos-1154893736] Sending `ifconfig eth0 down'
[13_create_multinic_pos-1154893736] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1154893736'

[dom0] Running `xm domid 13_create_multinic_pos-1154893751'
Error: the domain '13_create_multinic_pos-1154893751' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1154893751
[dom0] Running `ip addr add 169.254.0.2 dev vif0.0'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893751']
[13_create_multinic_pos-1154893751] Sending `input'
[13_create_multinic_pos-1154893751] Sending `ifconfig lo 127.0.0.1'
[13_create_multinic_pos-1154893751] Sending `echo $?'
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893751']
[13_create_multinic_pos-1154893751] Sending `input'
[13_create_multinic_pos-1154893751] Sending `ifconfig eth0 inet 169.254.0.1 netmask 255.255.0.0 up'
[13_create_multinic_pos-1154893751] Sending `echo $?'
[13_create_multinic_pos-1154893751] Sending `ls'
[13_create_multinic_pos-1154893751] Sending `echo $?'
[dom0] Running `ip addr del 169.254.0.2 dev vif0.0'
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (169.254.0.2/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893751']
[13_create_multinic_pos-1154893751] Sending `input'
[13_create_multinic_pos-1154893751] Sending `ifconfig eth0 down'
[13_create_multinic_pos-1154893751] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1154893751'

[dom0] Running `xm domid 13_create_multinic_pos-1154893765'
Error: the domain '13_create_multinic_pos-1154893765' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1154893765
[dom0] Running `ip addr add 169.254.0.2 dev vif0.0'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893765']
[13_create_multinic_pos-1154893765] Sending `input'
[13_create_multinic_pos-1154893765] Sending `ifconfig lo 127.0.0.1'
[13_create_multinic_pos-1154893765] Sending `echo $?'
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893765']
[13_create_multinic_pos-1154893765] Sending `input'
[13_create_multinic_pos-1154893765] Sending `ifconfig eth0 inet 169.254.0.1 netmask 255.255.0.0 up'
[13_create_multinic_pos-1154893765] Sending `echo $?'
[13_create_multinic_pos-1154893765] Sending `ls'
[13_create_multinic_pos-1154893765] Sending `echo $?'
[dom0] Running `ip addr del 169.254.0.2 dev vif0.0'
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (169.254.0.2/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893765']
[13_create_multinic_pos-1154893765] Sending `input'
[13_create_multinic_pos-1154893765] Sending `ifconfig eth0 down'
[13_create_multinic_pos-1154893765] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1154893765'

[dom0] Running `xm domid 13_create_multinic_pos-1154893779'
Error: the domain '13_create_multinic_pos-1154893779' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1154893779
[dom0] Running `ip addr add 169.254.0.2 dev vif0.0'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893779']
[13_create_multinic_pos-1154893779] Sending `input'
[13_create_multinic_pos-1154893779] Sending `ifconfig lo 127.0.0.1'
[13_create_multinic_pos-1154893779] Sending `echo $?'
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893779']
[13_create_multinic_pos-1154893779] Sending `input'
[13_create_multinic_pos-1154893779] Sending `ifconfig eth0 inet 169.254.0.1 netmask 255.255.0.0 up'
[13_create_multinic_pos-1154893779] Sending `echo $?'
[13_create_multinic_pos-1154893779] Sending `ls'
[13_create_multinic_pos-1154893779] Sending `echo $?'
[dom0] Running `ip addr del 169.254.0.2 dev vif0.0'
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (169.254.0.2/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893779']
[13_create_multinic_pos-1154893779] Sending `input'
[13_create_multinic_pos-1154893779] Sending `ifconfig eth0 down'
[13_create_multinic_pos-1154893779] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1154893779'

[dom0] Running `xm domid 13_create_multinic_pos-1154893793'
Error: the domain '13_create_multinic_pos-1154893793' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 13_create_multinic_pos-1154893793
[dom0] Running `ip addr add 169.254.0.2 dev vif0.0'

Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893793']
[13_create_multinic_pos-1154893793] Sending `input'
[13_create_multinic_pos-1154893793] Sending `ifconfig lo 127.0.0.1'
[13_create_multinic_pos-1154893793] Sending `echo $?'
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893793']
[13_create_multinic_pos-1154893793] Sending `input'
[13_create_multinic_pos-1154893793] Sending `ifconfig eth0 inet 169.254.0.1 netmask 255.255.0.0 up'
[13_create_multinic_pos-1154893793] Sending `echo $?'
[13_create_multinic_pos-1154893793] Sending `ls'
[13_create_multinic_pos-1154893793] Sending `echo $?'
[dom0] Running `ip addr del 169.254.0.2 dev vif0.0'
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (169.254.0.2/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
Console executing: ['/usr/sbin/xm', 'xm', 'console', '13_create_multinic_pos-1154893793']
[13_create_multinic_pos-1154893793] Sending `input'
[13_create_multinic_pos-1154893793] Sending `ifconfig eth0 down'
[13_create_multinic_pos-1154893793] Sending `echo $?'
[dom0] Running `xm destroy 13_create_multinic_pos-1154893793'

PASS: 13_create_multinic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3340.5
*** Finished cleaning domUs
*** Test 14_create_blockroot_pos started at Sun Aug  6 15:50:09 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3341.3
*** Finished cleaning domUs
*** Test 14_create_blockroot_pos started at Sun Aug  6 15:50:09 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 14_create_blockroot
Console executing: ['/usr/sbin/xm', 'xm', 'console', '14_create_blockroot']
[14_create_blockroot] Sending `input'
[14_create_blockroot] Sending `ls'
[14_create_blockroot] Sending `echo $?'
PASS: 14_create_blockroot_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
14_create_blockroot              130       64     1 -b----     0.3
Domain-0                           0     5000    32 r-----  3343.6
[dom0] Running `xm destroy 14_create_blockroot'
*** Finished cleaning domUs
*** Test 15_create_smallmem_pos started at Sun Aug  6 15:50:16 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3345.3
*** Finished cleaning domUs
*** Test 15_create_smallmem_pos started at Sun Aug  6 15:50:16 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 15_create_smallmem_pos-1154893816
Console executing: ['/usr/sbin/xm', 'xm', 'console', '15_create_smallmem_pos-1154893816']
[15_create_smallmem_pos-1154893816] Sending `input'
[15_create_smallmem_pos-1154893816] Sending `ls'
[15_create_smallmem_pos-1154893816] Sending `echo $?'
[dom0] Running `xm destroy 15_create_smallmem_pos-1154893816'

PASS: 15_create_smallmem_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3347.5
*** Finished cleaning domUs
*** Test 16_create_smallmem_neg started at Sun Aug  6 15:50:22 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3347.8
*** Finished cleaning domUs
*** Test 16_create_smallmem_neg started at Sun Aug  6 15:50:22 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 16_create_smallmem_neg-1154893822
Console executing: ['/usr/sbin/xm', 'xm', 'console', '16_create_smallmem_neg-1154893822']
Domain with 16 MB has runaway console as expected
[dom0] Running `xm destroy 16_create_smallmem_neg-1154893822'

PASS: 16_create_smallmem_neg.test
====================
1 of 15 tests failed
====================
make[2]: *** [check-TESTS] Error 1
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/create'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/create'
make: *** [check-recursive] Error 1
make: Target `check' not remade because of errors.
*** case destroy from group default
*** Running tests for case destroy
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/destroy'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/destroy'
cp 01_destroy_basic_pos.py 01_destroy_basic_pos.test
chmod +x 01_destroy_basic_pos.test
cp 02_destroy_noparm_neg.py 02_destroy_noparm_neg.test
chmod +x 02_destroy_noparm_neg.test
cp 03_destroy_nonexist_neg.py 03_destroy_nonexist_neg.test
chmod +x 03_destroy_nonexist_neg.test
cp 04_destroy_badparm_neg.py 04_destroy_badparm_neg.test
chmod +x 04_destroy_badparm_neg.test
cp 05_destroy_byid_pos.py 05_destroy_byid_pos.test
chmod +x 05_destroy_byid_pos.test
cp 06_destroy_dom0_neg.py 06_destroy_dom0_neg.test
chmod +x 06_destroy_dom0_neg.test
cp 07_destroy_stale_pos.py 07_destroy_stale_pos.test
chmod +x 07_destroy_stale_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3356.6
*** Finished cleaning domUs
*** Test 01_destroy_basic_pos started at Sun Aug  6 15:50:27 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3357.0
*** Finished cleaning domUs
*** Test 01_destroy_basic_pos started at Sun Aug  6 15:50:28 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_destroy_basic_pos-1154893828
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_destroy_basic_pos-1154893828']
[01_destroy_basic_pos-1154893828] Sending `input'
[01_destroy_basic_pos-1154893828] Sending `ls'
[01_destroy_basic_pos-1154893828] Sending `echo $?'
[dom0] Running `xm destroy 01_destroy_basic_pos-1154893828'

PASS: 01_destroy_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3359.7
*** Finished cleaning domUs
*** Test 02_destroy_noparm_neg started at Sun Aug  6 15:50:34 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3360.1
*** Finished cleaning domUs
*** Test 02_destroy_noparm_neg started at Sun Aug  6 15:50:34 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm destroy'
Error: 'xm destroy' requires 1 argument.

   destroy <DomId>                  Terminate a domain immediately
PASS: 02_destroy_noparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3360.8
*** Finished cleaning domUs
*** Test 03_destroy_nonexist_neg started at Sun Aug  6 15:50:35 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3361.3
*** Finished cleaning domUs
*** Test 03_destroy_nonexist_neg started at Sun Aug  6 15:50:35 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm destroy -x'
Error: an integer is required
PASS: 03_destroy_nonexist_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3362.0
*** Finished cleaning domUs
*** Test 04_destroy_badparm_neg started at Sun Aug  6 15:50:36 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3362.3
*** Finished cleaning domUs
*** Test 04_destroy_badparm_neg started at Sun Aug  6 15:50:36 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm destroy 6666'
Error: an integer is required
PASS: 04_destroy_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3362.9
*** Finished cleaning domUs
*** Test 05_destroy_byid_pos started at Sun Aug  6 15:50:37 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3363.3
*** Finished cleaning domUs
*** Test 05_destroy_byid_pos started at Sun Aug  6 15:50:37 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 05_destroy_byid_pos-1154893837
[dom0] Running `xm domid 05_destroy_byid_pos-1154893837'
134
[dom0] Running `xm destroy 134'

PASS: 05_destroy_byid_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3365.9
*** Finished cleaning domUs
*** Test 06_destroy_dom0_neg started at Sun Aug  6 15:50:39 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3366.2
*** Finished cleaning domUs
*** Test 06_destroy_dom0_neg started at Sun Aug  6 15:50:39 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm destroy 0'
Error: Cannot destroy privileged domain 0
PASS: 06_destroy_dom0_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3366.9
*** Finished cleaning domUs
*** Test 07_destroy_stale_pos started at Sun Aug  6 15:50:40 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3367.3
*** Finished cleaning domUs
*** Test 07_destroy_stale_pos started at Sun Aug  6 15:50:40 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
Running stale tests
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1154893840
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1154893840']
[07_destroy_stale_pos-1154893840] Sending `input'
[07_destroy_stale_pos-1154893840] Sending `ls'
[07_destroy_stale_pos-1154893840] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1154893840'

[dom0] Running `xm mem-set 07_destroy_stale_pos-1154893840 32'
Error: the domain '07_destroy_stale_pos-1154893840' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1154893846
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1154893846']
[07_destroy_stale_pos-1154893846] Sending `input'
[07_destroy_stale_pos-1154893846] Sending `ls'
[07_destroy_stale_pos-1154893846] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1154893846'

[dom0] Running `xm pause 07_destroy_stale_pos-1154893846'
Error: the domain '07_destroy_stale_pos-1154893846' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1154893852
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1154893852']
[07_destroy_stale_pos-1154893852] Sending `input'
[07_destroy_stale_pos-1154893852] Sending `ls'
[07_destroy_stale_pos-1154893852] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1154893852'

[dom0] Running `xm unpause 07_destroy_stale_pos-1154893852'
Error: the domain '07_destroy_stale_pos-1154893852' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1154893857
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1154893857']
[07_destroy_stale_pos-1154893857] Sending `input'
[07_destroy_stale_pos-1154893857] Sending `ls'
[07_destroy_stale_pos-1154893857] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1154893857'

[dom0] Running `xm reboot 07_destroy_stale_pos-1154893857'
Error: the domain '07_destroy_stale_pos-1154893857' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1154893863
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1154893863']
[07_destroy_stale_pos-1154893863] Sending `input'
[07_destroy_stale_pos-1154893863] Sending `ls'
[07_destroy_stale_pos-1154893863] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1154893863'

[dom0] Running `xm save 07_destroy_stale_pos-1154893863 /tmp/foo'
Error: the domain '07_destroy_stale_pos-1154893863' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1154893869
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1154893869']
[07_destroy_stale_pos-1154893869] Sending `input'
[07_destroy_stale_pos-1154893869] Sending `ls'
[07_destroy_stale_pos-1154893869] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1154893869'

[dom0] Running `xm block-list 07_destroy_stale_pos-1154893869'
Error: the domain '07_destroy_stale_pos-1154893869' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1154893874
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1154893874']
[07_destroy_stale_pos-1154893874] Sending `input'
[07_destroy_stale_pos-1154893874] Sending `ls'
[07_destroy_stale_pos-1154893874] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1154893874'

[dom0] Running `xm shutdown 07_destroy_stale_pos-1154893874'
Error: the domain '07_destroy_stale_pos-1154893874' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1154893880
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1154893880']
[07_destroy_stale_pos-1154893880] Sending `input'
[07_destroy_stale_pos-1154893880] Sending `ls'
[07_destroy_stale_pos-1154893880] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1154893880'

[dom0] Running `xm domid 07_destroy_stale_pos-1154893880'
Error: the domain '07_destroy_stale_pos-1154893880' does not exist.
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 07_destroy_stale_pos-1154893886
Console executing: ['/usr/sbin/xm', 'xm', 'console', '07_destroy_stale_pos-1154893886']
[07_destroy_stale_pos-1154893886] Sending `input'
[07_destroy_stale_pos-1154893886] Sending `ls'
[07_destroy_stale_pos-1154893886] Sending `echo $?'
[dom0] Running `xm destroy 07_destroy_stale_pos-1154893886'

[dom0] Running `xm domname 07_destroy_stale_pos-1154893886'
Error: the domain '07_destroy_stale_pos-1154893886' does not exist.
PASS: 07_destroy_stale_pos.test
==================
All 7 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/destroy'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/destroy'
*** case dmesg from group default
*** Running tests for case dmesg
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/dmesg'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/dmesg'
cp 01_dmesg_basic_pos.py 01_dmesg_basic_pos.test
chmod +x 01_dmesg_basic_pos.test
cp 02_dmesg_basic_neg.py 02_dmesg_basic_neg.test
chmod +x 02_dmesg_basic_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3388.8
*** Finished cleaning domUs
*** Test 01_dmesg_basic_pos started at Sun Aug  6 15:51:32 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3389.2
*** Finished cleaning domUs
*** Test 01_dmesg_basic_pos started at Sun Aug  6 15:51:33 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm dmesg'
eck architecture supported.
(XEN) Intel machine check reporting enabled on CPU#22.
(XEN) CPU22: Intel P4/Xeon Extended MCE MSRs (24) available
(XEN) CPU22: Thermal monitoring enabled
(XEN) CPU22: Intel Genuine Intel(R) CPU 3.00GHz stepping 08
(XEN) Booting processor 23/44 eip 90000
(XEN) Initializing CPU#23
(XEN) masked ExtINT on CPU#23
(XEN) CPU: Trace cache: 12K uops, L1 D cache: 16K
(XEN) CPU: L2 cache: 2048K
(XEN) CPU: Physical Processor ID: 11
(XEN) CPU: Processor Core ID: 0
(XEN) VMXON is done
(XEN) Intel machine check architecture supported.
(XEN) Intel machine check reporting enabled on CPU#23.
(XEN) CPU23: Intel P4/Xeon Extended MCE MSRs (24) available
(XEN) CPU23: Thermal monitoring enabled
(XEN) CPU23: Intel Genuine Intel(R) CPU 3.00GHz stepping 08
(XEN) Booting processor 24/48 eip 90000
(XEN) Initializing CPU#24
(XEN) masked ExtINT on CPU#24
(XEN) CPU: Trace cache: 12K uops, L1 D cache: 16K
(XEN) CPU: L2 cache: 2048K
(XEN) CPU: Physical Processor ID: 12
(XEN) CPU: Processor Core ID: 0
(XEN) VMXON is done
(XEN) Intel machine check architecture supported.
(XEN) Intel machine check reporting enabled on CPU#24.
(XEN) CPU24: Intel P4/Xeon Extended MCE MSRs (24) available
(XEN) CPU24: Thermal monitoring enabled
(XEN) CPU24: Intel Genuine Intel(R) CPU 3.00GHz stepping 08
(XEN) Booting processor 25/54 eip 90000
(XEN) Initializing CPU#25
(XEN) masked ExtINT on CPU#25
(XEN) CPU: Trace cache: 12K uops, L1 D cache: 16K
(XEN) CPU: L2 cache: 2048K
(XEN) CPU: Physical Processor ID: 13
(XEN) CPU: Processor Core ID: 1
(XEN) VMXON is done
(XEN) Intel machine check architecture supported.
(XEN) Intel machine check reporting enabled on CPU#25.
(XEN) CPU25: Intel P4/Xeon Extended MCE MSRs (24) available
(XEN) CPU25: Thermal monitoring enabled
(XEN) CPU25: Intel Genuine Intel(R) CPU 3.00GHz stepping 08
(XEN) Booting processor 26/56 eip 90000
(XEN) Initializing CPU#26
(XEN) masked ExtINT on CPU#26
(XEN) CPU: Trace cache: 12K uops, L1 D cache: 16K
(XEN) CPU: L2 cache: 2048K
(XEN) CPU: Physical Processor ID: 14
(XEN) CPU: Processor Core ID: 0
(XEN) VMXON is done
(XEN) Intel machine check architecture supported.
(XEN) Intel machine check reporting enabled on CPU#26.
(XEN) CPU26: Intel P4/Xeon Extended MCE MSRs (24) available
(XEN) CPU26: Thermal monitoring enabled
(XEN) CPU26: Intel Genuine Intel(R) CPU 3.00GHz stepping 08
(XEN) Booting processor 27/62 eip 90000
(XEN) Initializing CPU#27
(XEN) masked ExtINT on CPU#27
(XEN) CPU: Trace cache: 12K uops, L1 D cache: 16K
(XEN) CPU: L2 cache: 2048K
(XEN) CPU: Physical Processor ID: 15
(XEN) CPU: Processor Core ID: 1
(XEN) VMXON is done
(XEN) Intel machine check architecture supported.
(XEN) Intel machine check reporting enabled on CPU#27.
(XEN) CPU27: Intel P4/Xeon Extended MCE MSRs (24) available
(XEN) CPU27: Thermal monitoring enabled
(XEN) CPU27: Intel Genuine Intel(R) CPU 3.00GHz stepping 08
(XEN) Booting processor 28/50 eip 90000
(XEN) Initializing CPU#28
(XEN) masked ExtINT on CPU#28
(XEN) CPU: Trace cache: 12K uops, L1 D cache: 16K
(XEN) CPU: L2 cache: 2048K
(XEN) CPU: Physical Processor ID: 12
(XEN) CPU: Processor Core ID: 1
(XEN) VMXON is done
(XEN) Intel machine check architecture supported.
(XEN) Intel machine check reporting enabled on CPU#28.
(XEN) CPU28: Intel P4/Xeon Extended MCE MSRs (24) available
(XEN) CPU28: Thermal monitoring enabled
(XEN) CPU28: Intel Genuine Intel(R) CPU 3.00GHz stepping 08
(XEN) Booting processor 29/52 eip 90000
(XEN) Initializing CPU#29
(XEN) masked ExtINT on CPU#29
(XEN) CPU: Trace cache: 12K uops, L1 D cache: 16K
(XEN) CPU: L2 cache: 2048K
(XEN) CPU: Physical Processor ID: 13
(XEN) CPU: Processor Core ID: 0
(XEN) VMXON is done
(XEN) Intel machine check architecture supported.
(XEN) Intel machine check reporting enabled on CPU#29.
(XEN) CPU29: Intel P4/Xeon Extended MCE MSRs (24) available
(XEN) CPU29: Thermal monitoring enabled
(XEN) CPU29: Intel Genuine Intel(R) CPU 3.00GHz stepping 08
(XEN) Booting processor 30/58 eip 90000
(XEN) Initializing CPU#30
(XEN) masked ExtINT on CPU#30
(XEN) CPU: Trace cache: 12K uops, L1 D cache: 16K
(XEN) CPU: L2 cache: 2048K
(XEN) CPU: Physical Processor ID: 14
(XEN) CPU: Processor Core ID: 1
(XEN) VMXON is done
(XEN) Intel machine check architecture supported.
(XEN) Intel machine check reporting enabled on CPU#30.
(XEN) CPU30: Intel P4/Xeon Extended MCE MSRs (24) available
(XEN) CPU30: Thermal monitoring enabled
(XEN) CPU30: Intel Genuine Intel(R) CPU 3.00GHz stepping 08
(XEN) Booting processor 31/60 eip 90000
(XEN) Initializing CPU#31
(XEN) masked ExtINT on CPU#31
(XEN) CPU: Trace cache: 12K uops, L1 D cache: 16K
(XEN) CPU: L2 cache: 2048K
(XEN) CPU: Physical Processor ID: 15
(XEN) CPU: Processor Core ID: 0
(XEN) VMXON is done
(XEN) Intel machine check architecture supported.
(XEN) Intel machine check reporting enabled on CPU#31.
(XEN) CPU31: Intel P4/Xeon Extended MCE MSRs (24) available
(XEN) CPU31: Thermal monitoring enabled
(XEN) CPU31: Intel Genuine Intel(R) CPU 3.00GHz stepping 08
(XEN) Total of 32 processors activated.
(XEN) ENABLING IO-APIC IRQs
(XEN)  -> Using new ACK method
(XEN) init IO_APIC IRQs
(XEN)  IO-APIC (apicid-pin) 16-0, 16-16, 16-17, 16-18, 16-19, 16-20, 16-21, 16-22, 16-23, 26-0, 26-1, 26-2, 26-3, 26-4, 26-5, 26-6, 26-7, 26-8, 26-9, 26-10, 26-11, 26-12, 26-13, 26-14, 26-15, 26-16, 26-17, 26-18, 26-19, 26-20, 26-21, 26-22, 26-23, 27-0, 27-1, 27-2, 27-3, 27-4, 27-5, 27-6, 27-7, 27-8, 27-9, 27-10, 27-11, 27-12, 27-13, 27-14, 27-15, 27-16, 27-17, 27-18, 27-19, 27-20, 27-21, 27-22, 27-23 not connected.
(XEN) ..TIMER: vector=0xF0 apic1=0 pin1=2 apic2=0 pin2=0
(XEN) number of MP IRQ sources: 15.
(XEN) number of IO-APIC #16 registers: 24.
(XEN) number of IO-APIC #26 registers: 24.
(XEN) number of IO-APIC #27 registers: 24.
(XEN) testing the IO APIC.......................
(XEN) IO APIC #16......
(XEN) .... register #00: 00000000
(XEN) .......    : physical APIC id: 00
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 00000000
(XEN) .......     : arbitration: 00
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:   
(XEN)  00 000 00  1    0    0   0   0    0    0    00
(XEN)  01 000 00  0    0    0   0   0    0    0    28
(XEN)  02 000 00  0    0    0   0   0    0    0    F0
(XEN)  03 000 00  0    0    0   0   0    0    0    30
(XEN)  04 000 00  0    0    0   0   0    0    0    F1
(XEN)  05 000 00  0    0    0   0   0    0    0    38
(XEN)  06 000 00  0    0    0   0   0    0    0    40
(XEN)  07 000 00  0    0    0   0   0    0    0    48
(XEN)  08 000 00  0    0    0   0   0    0    0    50
(XEN)  09 000 00  1    1    0   0   0    0    0    58
(XEN)  0a 000 00  0    0    0   0   0    0    0    60
(XEN)  0b 000 00  0    0    0   0   0    0    0    68
(XEN)  0c 000 00  0    0    0   0   0    0    0    70
(XEN)  0d 000 00  0    0    0   0   0    0    0    78
(XEN)  0e 000 00  0    0    0   0   0    0    0    88
(XEN)  0f 000 00  0    0    0   0   0    0    0    90
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN) IO APIC #26......
(XEN) .... register #00: 00000000
(XEN) .......    : physical APIC id: 00
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 00000000
(XEN) .......     : arbitration: 00
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:   
(XEN)  00 000 00  1    0    0   0   0    0    0    00
(XEN)  01 000 00  1    0    0   0   0    0    0    00
(XEN)  02 000 00  1    0    0   0   0    0    0    00
(XEN)  03 000 00  1    0    0   0   0    0    0    00
(XEN)  04 000 00  1    0    0   0   0    0    0    00
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 000 00  1    0    0   0   0    0    0    00
(XEN)  07 000 00  1    0    0   0   0    0    0    00
(XEN)  08 000 00  1    0    0   0   0    0    0    00
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 000 00  1    0    0   0   0    0    0    00
(XEN)  0d 000 00  1    0    0   0   0    0    0    00
(XEN)  0e 000 00  1    0    0   0   0    0    0    00
(XEN)  0f 000 00  1    0    0   0   0    0    0    00
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN) IO APIC #27......
(XEN) .... register #00: 00000000
(XEN) .......    : physical APIC id: 00
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00178020
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 1
(XEN) .......     : IO APIC version: 0020
(XEN) .... register #02: 00000000
(XEN) .......     : arbitration: 00
(XEN) .... register #03: 00000001
(XEN) .......     : Boot DT    : 1
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:   
(XEN)  00 000 00  1    0    0   0   0    0    0    00
(XEN)  01 000 00  1    0    0   0   0    0    0    00
(XEN)  02 000 00  1    0    0   0   0    0    0    00
(XEN)  03 000 00  1    0    0   0   0    0    0    00
(XEN)  04 000 00  1    0    0   0   0    0    0    00
(XEN)  05 000 00  1    0    0   0   0    0    0    00
(XEN)  06 000 00  1    0    0   0   0    0    0    00
(XEN)  07 000 00  1    0    0   0   0    0    0    00
(XEN)  08 000 00  1    0    0   0   0    0    0    00
(XEN)  09 000 00  1    0    0   0   0    0    0    00
(XEN)  0a 000 00  1    0    0   0   0    0    0    00
(XEN)  0b 000 00  1    0    0   0   0    0    0    00
(XEN)  0c 000 00  1    0    0   0   0    0    0    00
(XEN)  0d 000 00  1    0    0   0   0    0    0    00
(XEN)  0e 000 00  1    0    0   0   0    0    0    00
(XEN)  0f 000 00  1    0    0   0   0    0    0    00
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN) Using vector-based indexing
(XEN) IRQ to pin mappings:
(XEN) IRQ240 -> 0:2
(XEN) IRQ40 -> 0:1
(XEN) IRQ48 -> 0:3
(XEN) IRQ241 -> 0:4
(XEN) IRQ56 -> 0:5
(XEN) IRQ64 -> 0:6
(XEN) IRQ72 -> 0:7
(XEN) IRQ80 -> 0:8
(XEN) IRQ88 -> 0:9
(XEN) IRQ96 -> 0:10
(XEN) IRQ104 -> 0:11
(XEN) IRQ112 -> 0:12
(XEN) IRQ120 -> 0:13
(XEN) IRQ136 -> 0:14
(XEN) IRQ144 -> 0:15
(XEN) .................................... done.
(XEN) Using local APIC timer interrupts.
(XEN) calibrating APIC timer ...
(XEN) ..... CPU clock speed is 3000.0171 MHz.
(XEN) ..... host bus clock speed is 200.0010 MHz.
(XEN) ..... bus_scale = 0x0000CCD7
(XEN) checking TSC synchronization across 32 CPUs: 
(XEN) CPU#0 had 2124692 usecs TSC skew, fixed it up.
(XEN) CPU#1 had 2124712 usecs TSC skew, fixed it up.
(XEN) CPU#2 had 2124715 usecs TSC skew, fixed it up.
(XEN) CPU#3 had 2124719 usecs TSC skew, fixed it up.
(XEN) CPU#4 had 2124708 usecs TSC skew, fixed it up.
(XEN) CPU#5 had 2124719 usecs TSC skew, fixed it up.
(XEN) CPU#6 had 2124706 usecs TSC skew, fixed it up.
(XEN) CPU#7 had 2124719 usecs TSC skew, fixed it up.
(XEN) CPU#8 had 553572 usecs TSC skew, fixed it up.
(XEN) CPU#9 had 553571 usecs TSC skew, fixed it up.
(XEN) CPU#10 had 553571 usecs TSC skew, fixed it up.
(XEN) CPU#11 had 553570 usecs TSC skew, fixed it up.
(XEN) CPU#12 had 553574 usecs TSC skew, fixed it up.
(XEN) CPU#13 had 553571 usecs TSC skew, fixed it up.
(XEN) CPU#14 had 553571 usecs TSC skew, fixed it up.
(XEN) CPU#15 had 553571 usecs TSC skew, fixed it up.
(XEN) CPU#16 had -703940 usecs TSC skew, fixed it up.
(XEN) CPU#17 had -703939 usecs TSC skew, fixed it up.
(XEN) CPU#18 had -703946 usecs TSC skew, fixed it up.
(XEN) CPU#19 had -703937 usecs TSC skew, fixed it up.
(XEN) CPU#20 had -703940 usecs TSC skew, fixed it up.
(XEN) CPU#21 had -703939 usecs TSC skew, fixed it up.
(XEN) CPU#22 had -703940 usecs TSC skew, fixed it up.
(XEN) CPU#23 had -703944 usecs TSC skew, fixed it up.
(XEN) CPU#24 had -1974339 usecs TSC skew, fixed it up.
(XEN) CPU#25 had -1974349 usecs TSC skew, fixed it up.
(XEN) CPU#26 had -1974332 usecs TSC skew, fixed it up.
(XEN) CPU#27 had -1974342 usecs TSC skew, fixed it up.
(XEN) CPU#28 had -1974345 usecs TSC skew, fixed it up.
(XEN) CPU#29 had -1974338 usecs TSC skew, fixed it up.
(XEN) CPU#30 had -1974351 usecs TSC skew, fixed it up.
(XEN) CPU#31 had -1974338 usecs TSC skew, fixed it up.
(XEN) Platform timer is 1.193MHz PIT
(XEN) Brought up 32 CPUs
(XEN) Machine check exception polling timer started.
(XEN) *** LOADING DOMAIN 0 ***
(XEN) Domain 0 kernel supports features = { 0000000f }.
(XEN) Domain 0 kernel requires features = { 00000000 }.
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Dom0 alloc.:   0000000060000000->0000000080000000 (32959401 pages to be allocated)
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: ffffffff80100000->ffffffff804b4f08
(XEN)  Init. ramdisk: ffffffff804b5000->ffffffff80b8de00
(XEN)  Phys-Mach map: ffffffff80b8e000->ffffffff90803d48
(XEN)  Start info:    ffffffff90804000->ffffffff90805000
(XEN)  Page tables:   ffffffff90805000->ffffffff9088e000
(XEN)  Boot stack:    ffffffff9088e000->ffffffff9088f000
(XEN)  TOTAL:         ffffffff80000000->ffffffff90c00000
(XEN)  ENTRY ADDRESS: ffffffff80100000
(XEN) Dom0 has maximum 32 VCPUs
(XEN) Initrd len 0x6d8e00, start at 0xffffffff804b5000
(XEN) Scrubbing Free RAM: ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................done.
(XEN) Xen trace buffers: disabled
(XEN) Xen is relinquishing VGA console.
(XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen).
(XEN) mtrr: type mismatch for f6000000,400000 old: uncachable new: write-combining
(XEN) mtrr: type mismatch for f6000000,400000 old: uncachable new: write-combining

PASS: 01_dmesg_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3389.8
*** Finished cleaning domUs
*** Test 02_dmesg_basic_neg started at Sun Aug  6 15:51:33 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3390.2
*** Finished cleaning domUs
*** Test 02_dmesg_basic_neg started at Sun Aug  6 15:51:34 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm dmesg -x'
Error: option -x not recognized
PASS: 02_dmesg_basic_neg.test
==================
All 2 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/dmesg'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/dmesg'
*** case domid from group default
*** Running tests for case domid
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/domid'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/domid'
cp 01_domid_basic_pos.py 01_domid_basic_pos.test
chmod +x 01_domid_basic_pos.test
cp 02_domid_basic_neg.py 02_domid_basic_neg.test
chmod +x 02_domid_basic_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3390.9
*** Finished cleaning domUs
*** Test 01_domid_basic_pos started at Sun Aug  6 15:51:34 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3391.3
*** Finished cleaning domUs
*** Test 01_domid_basic_pos started at Sun Aug  6 15:51:35 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm domid Domain-0'
0
PASS: 01_domid_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3392.1
*** Finished cleaning domUs
*** Test 02_domid_basic_neg started at Sun Aug  6 15:51:35 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3392.5
*** Finished cleaning domUs
*** Test 02_domid_basic_neg started at Sun Aug  6 15:51:36 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm domid non_existent_domain'
Error: the domain 'non_existent_domain' does not exist.
PASS: 02_domid_basic_neg.test
==================
All 2 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/domid'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/domid'
*** case domname from group default
*** Running tests for case domname
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/domname'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/domname'
cp 01_domname_basic_pos.py 01_domname_basic_pos.test
chmod +x 01_domname_basic_pos.test
cp 02_domname_basic_neg.py 02_domname_basic_neg.test
chmod +x 02_domname_basic_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3393.2
*** Finished cleaning domUs
*** Test 01_domname_basic_pos started at Sun Aug  6 15:51:36 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3393.6
*** Finished cleaning domUs
*** Test 01_domname_basic_pos started at Sun Aug  6 15:51:37 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm domname 0'
Domain-0
PASS: 01_domname_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3394.4
*** Finished cleaning domUs
*** Test 02_domname_basic_neg started at Sun Aug  6 15:51:38 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3394.8
*** Finished cleaning domUs
*** Test 02_domname_basic_neg started at Sun Aug  6 15:51:38 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm domname 1492'
Error: the domain '1492' does not exist.
PASS: 02_domname_basic_neg.test
==================
All 2 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/domname'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/domname'
*** case enforce_dom0_cpus from group default
*** Running tests for case enforce_dom0_cpus
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/enforce_dom0_cpus'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/enforce_dom0_cpus'
cp 01_enforce_dom0_cpus_basic_pos.py 01_enforce_dom0_cpus_basic_pos.test
chmod +x 01_enforce_dom0_cpus_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3395.5
*** Finished cleaning domUs
*** Test 01_enforce_dom0_cpus_basic_pos started at Sun Aug  6 15:51:39 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3395.9
*** Finished cleaning domUs
*** Test 01_enforce_dom0_cpus_basic_pos started at Sun Aug  6 15:51:39 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5000    32 r-----  3396.8
[dom0] Running `sed -e 's,dom0-cpus 0,dom0-cpus 1,' /etc/xen/xend-config.sxp > /tmp/xend-config.sxp'

*** Restarting xend ...
[dom0] Running `/etc/init.d/xend stop'

[dom0] Running `/etc/init.d/xend start'

[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
30
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
28
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
26
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
23
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
21
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
20
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `grep "^processor" /proc/cpuinfo | wc -l'
17
[dom0] Running `xm vcpu-set 0 32'

*** Restarting xend ...
[dom0] Running `/etc/init.d/xend stop'

[dom0] Running `/etc/init.d/xend start'


REASON: /proc/cpuinfo says xend didn't enforce dom0_cpus (17 != 1)
FAIL: 01_enforce_dom0_cpus_basic_pos.test
===================
1 of 1 tests failed
===================
make[2]: *** [check-TESTS] Error 1
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/enforce_dom0_cpus'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/enforce_dom0_cpus'
make: *** [check-recursive] Error 1
make: Target `check' not remade because of errors.
*** case help from group default
*** Running tests for case help
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/help'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/help'
cp 01_help_basic_pos.py 01_help_basic_pos.test
chmod +x 01_help_basic_pos.test
cp 02_help_basic_neg.py 02_help_basic_neg.test
chmod +x 02_help_basic_neg.test
cp 03_help_badparm_neg.py 03_help_badparm_neg.test
chmod +x 03_help_badparm_neg.test
cp 04_help_long_pos.py 04_help_long_pos.test
chmod +x 04_help_long_pos.test
cp 05_help_nonroot_pos.py 05_help_nonroot_pos.test
chmod +x 05_help_nonroot_pos.test
cp 06_help_allcmds.py 06_help_allcmds.test
chmod +x 06_help_allcmds.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3403.1
*** Finished cleaning domUs
*** Test 01_help_basic_pos started at Sun Aug  6 15:52:16 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3403.5
*** Finished cleaning domUs
*** Test 01_help_basic_pos started at Sun Aug  6 15:52:16 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm help'
Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm common subcommands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   help                             Display this message
   list [--long] [DomId, ...]       List information about domains
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-set <DomId> <VCPUs>         Set the number of active VCPUs for a domain
                                    within the range allowed by the domain
                                    configuration

<DomName> can be substituted for <DomId> in xm subcommands.

For a complete list of subcommands run 'xm help --long'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 01_help_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3404.1
*** Finished cleaning domUs
*** Test 02_help_basic_neg started at Sun Aug  6 15:52:17 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3404.5
*** Finished cleaning domUs
*** Test 02_help_basic_neg started at Sun Aug  6 15:52:17 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm'
Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm common subcommands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   help                             Display this message
   list [--long] [DomId, ...]       List information about domains
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-set <DomId> <VCPUs>         Set the number of active VCPUs for a domain
                                    within the range allowed by the domain
                                    configuration

<DomName> can be substituted for <DomId> in xm subcommands.

For a complete list of subcommands run 'xm help --long'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 02_help_basic_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3405.2
*** Finished cleaning domUs
*** Test 03_help_badparm_neg started at Sun Aug  6 15:52:18 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3405.6
*** Finished cleaning domUs
*** Test 03_help_badparm_neg started at Sun Aug  6 15:52:18 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm -x'
Error: Sub Command -x not found!
Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm common subcommands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   help                             Display this message
   list [--long] [DomId, ...]       List information about domains
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-set <DomId> <VCPUs>         Set the number of active VCPUs for a domain
                                    within the range allowed by the domain
                                    configuration

<DomName> can be substituted for <DomId> in xm subcommands.

For a complete list of subcommands run 'xm help --long'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 03_help_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3406.2
*** Finished cleaning domUs
*** Test 04_help_long_pos started at Sun Aug  6 15:52:19 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3406.6
*** Finished cleaning domUs
*** Test 04_help_long_pos started at Sun Aug  6 15:52:19 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm help --long'
   Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm full list of subcommands:

  Domain Commands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   domid <DomName>                  Converts a domain name to a domain id
   domname <DomId>                  Convert a domain id to a domain name
   list [--long] [DomId, ...]       List information about domains
   list [--label] [DomId, ...]      List information about domains including their labels
   mem-max <DomId> <Mem>            Set maximum memory reservation for a domain
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   rename <DomId> <New Name>        Rename a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   sysrq   <DomId> <letter>         Send a sysrq to a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-list <DomId>                List the VCPUs for a domain (or all domains)
   vcpu-pin <DomId> <VCPU> <CPUs>   Set which cpus a VCPU can use
   vcpu-set <DomId> <VCPUs>         Set the number of active VCPUs for a domain
                                    within the range allowed by the domain
                                    configuration

  Xen Host Commands:
   dmesg [-c|--clear]               Read or clear Xen's message buffer
   info                             Get information about the xen host
   log                              Print the xend log
   serve                            Proxy Xend XML-RPC over stdio

  Scheduler Commands:
   sched-credit                           Set or get credit scheduler parameters
   sched-bvt <Parameters>           Set Borrowed Virtual Time scheduler
                                    parameters
   sched-bvt-ctxallow <Allow>       Set the BVT scheduler context switch
                                    allowance
   sched-sedf [DOM] [OPTIONS]       Show|Set simple EDF parameters
              -p, --period          Relative deadline(ms).
              -s, --slice           Worst-case execution time(ms)
                                    (slice < period).
              -l, --latency         scaled period(ms) in case the domain
                                    is doing heavy I/O.
              -e, --extra           flag (0/1) which controls whether the
                                    domain can run in extra-time
              -w, --weight          mutually exclusive with period/slice and
                                    specifies another way of setting a domain's
                                    cpu period/slice.

  Virtual Device Commands:
   block-attach <DomId> <BackDev> <FrontDev> <Mode>
                [BackDomId]         Create a new virtual block device
   block-detach  <DomId> <DevId>    Destroy a domain's virtual block device,
                                    where <DevId> may either be the device ID
                                    or the device name as mounted in the guest
   block-list <DomId> [--long]      List virtual block devices for a domain
   network-attach  <DomID> [script=<script>] [ip=<ip>] [mac=<mac>]
                           [bridge=<bridge>] [backend=<backDomID>]
                                    Create a new virtual network device 
   network-detach  <DomId> <DevId>  Destroy a domain's virtual network
                                    device, where <DevId> is the device ID.
   network-list <DomId> [--long]    List virtual network interfaces for a domain
   vtpm-list <DomId> [--long]       list virtual TPM devices

  Vnet commands:
   vnet-list [-l|--long]            list vnets
   vnet-create <config>             create a vnet from a config file
   vnet-delete <vnetid>             delete a vnet

  Access Control commands:
   labels [policy] [type=DOM|..]    List <type> labels for (active) policy.
   addlabel <label> dom <configfile> Add security label to domain
            <label> res <resource>   or resource
   rmlabel dom <configfile>         Remove security label from domain
           res <resource>           or resource
   getlabel dom <configfile>        Show security label for domain
            res <resource>          or resource
   dry-run <configfile>             Tests if domain can access its resources
   resources                        Show info for each labeled resource
   makepolicy <policy>              Build policy and create .bin/.map files
   loadpolicy <policy>              Load binary policy into hypervisor
   cfgbootpolicy <policy>           Add policy to boot configuration 
   dumppolicy                       Print hypervisor ACM state information

<DomName> can be substituted for <DomId> in xm subcommands.

For a short list of subcommands run 'xm help'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 04_help_long_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3407.2
*** Finished cleaning domUs
*** Test 05_help_nonroot_pos started at Sun Aug  6 15:52:20 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3407.5
*** Finished cleaning domUs
*** Test 05_help_nonroot_pos started at Sun Aug  6 15:52:20 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm help'
ERROR: Could not obtain handle on privileged command interface (13 = Permission denied)
Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm common subcommands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   help                             Display this message
   list [--long] [DomId, ...]       List information about domains
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-set <DomId> <VCPUs>         Set the number of active VCPUs for a domain
                                    within the range allowed by the domain
                                    configuration

<DomName> can be substituted for <DomId> in xm subcommands.

For a complete list of subcommands run 'xm help --long'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 05_help_nonroot_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3408.2
*** Finished cleaning domUs
*** Test 06_help_allcmds started at Sun Aug  6 15:52:21 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3408.5
*** Finished cleaning domUs
*** Test 06_help_allcmds started at Sun Aug  6 15:52:21 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm help --long'
   Usage: xm <subcommand> [args]
    Control, list, and manipulate Xen guest instances

xm full list of subcommands:

  Domain Commands:
   console <DomId>                  Attach to domain DomId's console.
   create [-c] <ConfigFile>
               [Name=Value]..       Create a domain based on Config File
   destroy <DomId>                  Terminate a domain immediately
   domid <DomName>                  Converts a domain name to a domain id
   domname <DomId>                  Convert a domain id to a domain name
   list [--long] [DomId, ...]       List information about domains
   list [--label] [DomId, ...]      List information about domains including their labels
   mem-max <DomId> <Mem>            Set maximum memory reservation for a domain
   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
   migrate <DomId> <Host>           Migrate a domain to another machine
   pause <DomId>                    Pause execution of a domain
   reboot <DomId> [-w][-a]          Reboot a domain
   rename <DomId> <New Name>        Rename a domain
   restore <File>                   Create a domain from a saved state file
   save <DomId> <File>              Save domain state (and config) to file
   shutdown <DomId> [-w][-a][-R|-H] Shutdown a domain
   sysrq   <DomId> <letter>         Send a sysrq to a domain
   top                              Monitor system and domains in real-time
   unpause <DomId>                  Unpause a paused domain
   vcpu-list <DomId>                List the VCPUs for a domain (or all domains)
   vcpu-pin <DomId> <VCPU> <CPUs>   Set which cpus a VCPU can use
   vcpu-set <DomId> <VCPUs>         Set the number of active VCPUs for a domain
                                    within the range allowed by the domain
                                    configuration

  Xen Host Commands:
   dmesg [-c|--clear]               Read or clear Xen's message buffer
   info                             Get information about the xen host
   log                              Print the xend log
   serve                            Proxy Xend XML-RPC over stdio

  Scheduler Commands:
   sched-credit                           Set or get credit scheduler parameters
   sched-bvt <Parameters>           Set Borrowed Virtual Time scheduler
                                    parameters
   sched-bvt-ctxallow <Allow>       Set the BVT scheduler context switch
                                    allowance
   sched-sedf [DOM] [OPTIONS]       Show|Set simple EDF parameters
              -p, --period          Relative deadline(ms).
              -s, --slice           Worst-case execution time(ms)
                                    (slice < period).
              -l, --latency         scaled period(ms) in case the domain
                                    is doing heavy I/O.
              -e, --extra           flag (0/1) which controls whether the
                                    domain can run in extra-time
              -w, --weight          mutually exclusive with period/slice and
                                    specifies another way of setting a domain's
                                    cpu period/slice.

  Virtual Device Commands:
   block-attach <DomId> <BackDev> <FrontDev> <Mode>
                [BackDomId]         Create a new virtual block device
   block-detach  <DomId> <DevId>    Destroy a domain's virtual block device,
                                    where <DevId> may either be the device ID
                                    or the device name as mounted in the guest
   block-list <DomId> [--long]      List virtual block devices for a domain
   network-attach  <DomID> [script=<script>] [ip=<ip>] [mac=<mac>]
                           [bridge=<bridge>] [backend=<backDomID>]
                                    Create a new virtual network device 
   network-detach  <DomId> <DevId>  Destroy a domain's virtual network
                                    device, where <DevId> is the device ID.
   network-list <DomId> [--long]    List virtual network interfaces for a domain
   vtpm-list <DomId> [--long]       list virtual TPM devices

  Vnet commands:
   vnet-list [-l|--long]            list vnets
   vnet-create <config>             create a vnet from a config file
   vnet-delete <vnetid>             delete a vnet

  Access Control commands:
   labels [policy] [type=DOM|..]    List <type> labels for (active) policy.
   addlabel <label> dom <configfile> Add security label to domain
            <label> res <resource>   or resource
   rmlabel dom <configfile>         Remove security label from domain
           res <resource>           or resource
   getlabel dom <configfile>        Show security label for domain
            res <resource>          or resource
   dry-run <configfile>             Tests if domain can access its resources
   resources                        Show info for each labeled resource
   makepolicy <policy>              Build policy and create .bin/.map files
   loadpolicy <policy>              Load binary policy into hypervisor
   cfgbootpolicy <policy>           Add policy to boot configuration 
   dumppolicy                       Print hypervisor ACM state information

<DomName> can be substituted for <DomId> in xm subcommands.

For a short list of subcommands run 'xm help'
For more help on xm see the xm(1) man page
For more help on xm create, see the xmdomain.cfg(5) man page
PASS: 06_help_allcmds.test
==================
All 6 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/help'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/help'
*** case info from group default
*** Running tests for case info
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/info'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/info'
cp 01_info_basic_pos.py 01_info_basic_pos.test
chmod +x 01_info_basic_pos.test
cp 02_info_compiledata_pos.py 02_info_compiledata_pos.test
chmod +x 02_info_compiledata_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3409.3
*** Finished cleaning domUs
*** Test 01_info_basic_pos started at Sun Aug  6 15:52:22 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3409.6
*** Finished cleaning domUs
*** Test 01_info_basic_pos started at Sun Aug  6 15:52:22 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
PASS: 01_info_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3410.3
*** Finished cleaning domUs
*** Test 02_info_compiledata_pos started at Sun Aug  6 15:52:23 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3410.7
*** Finished cleaning domUs
*** Test 02_info_compiledata_pos started at Sun Aug  6 15:52:23 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm info'
host                   : m1132-xenunstable
release                : 2.6.16.13-xen
version                : #1 SMP Sun Aug 6 11:46:44 EDT 2006
machine                : x86_64
nr_cpus                : 32
nr_nodes               : 1
sockets_per_node       : 16
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 3000
hw_caps                : bfebfbff:20100800:00000000:00000180:000064bd:00000000:00000001
total_memory           : 130943
free_memory            : 124387
xen_major              : 3
xen_minor              : 0
xen_extra              : -unstable
xen_caps               : xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Fri Aug 04 20:34:44 2006 +0100 10949:ffa5b2975dff
cc_compiler            : gcc version 4.1.0 (SUSE Linux)
cc_compile_by          : root
cc_compile_domain      : site
cc_compile_date        : Sun Aug  6 11:39:52 EDT 2006
PASS: 02_info_compiledata_pos.test
==================
All 2 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/info'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/info'
*** case list from group default
*** Running tests for case list
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/list'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/list'
cp 01_list_basic_pos.py 01_list_basic_pos.test
chmod +x 01_list_basic_pos.test
cp 02_list_badparm_neg.py 02_list_badparm_neg.test
chmod +x 02_list_badparm_neg.test
cp 03_list_nonexist_neg.py 03_list_nonexist_neg.test
chmod +x 03_list_nonexist_neg.test
cp 04_list_goodparm_pos.py 04_list_goodparm_pos.test
chmod +x 04_list_goodparm_pos.test
cp 05_list_long_pos.py 05_list_long_pos.test
chmod +x 05_list_long_pos.test
cp 06_list_nonroot.py 06_list_nonroot.test
chmod +x 06_list_nonroot.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3411.4
*** Finished cleaning domUs
*** Test 01_list_basic_pos started at Sun Aug  6 15:52:24 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3411.8
*** Finished cleaning domUs
*** Test 01_list_basic_pos started at Sun Aug  6 15:52:24 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3412.2
PASS: 01_list_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3412.5
*** Finished cleaning domUs
*** Test 02_list_badparm_neg started at Sun Aug  6 15:52:25 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3412.9
*** Finished cleaning domUs
*** Test 02_list_badparm_neg started at Sun Aug  6 15:52:25 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm list -x'
Error: option -x not recognized
PASS: 02_list_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3413.6
*** Finished cleaning domUs
*** Test 03_list_nonexist_neg started at Sun Aug  6 15:52:26 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3413.9
*** Finished cleaning domUs
*** Test 03_list_nonexist_neg started at Sun Aug  6 15:52:26 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm list 6666'
Error: the domain '6666' does not exist.
PASS: 03_list_nonexist_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3414.6
*** Finished cleaning domUs
*** Test 04_list_goodparm_pos started at Sun Aug  6 15:52:27 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3415.0
*** Finished cleaning domUs
*** Test 04_list_goodparm_pos started at Sun Aug  6 15:52:27 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 04_list_goodparm_pos-1154893947
Console executing: ['/usr/sbin/xm', 'xm', 'console', '04_list_goodparm_pos-1154893947']
[04_list_goodparm_pos-1154893947] Sending `input'
[dom0] Running `xm list 04_list_goodparm_pos-1154893947'
Name                              ID Mem(MiB) VCPUs State  Time(s)
04_list_goodparm_pos-1154893947  144       64     1 -b----     0.3
[dom0] Running `xm shutdown 04_list_goodparm_pos-1154893947'

PASS: 04_list_goodparm_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
04_list_goodparm_pos-1154893947  144       64     1 -b----     0.3
Domain-0                           0     5001    32 r-----  3417.0
[dom0] Running `xm destroy 04_list_goodparm_pos-1154893947'
*** Finished cleaning domUs
*** Test 05_list_long_pos started at Sun Aug  6 15:52:31 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3417.8
*** Finished cleaning domUs
*** Test 05_list_long_pos started at Sun Aug  6 15:52:32 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm list --long'
(domain
    (domid 0)
    (uuid 00000000-0000-0000-0000-000000000000)
    (vcpus 16)
    (cpu_weight 1.0)
    (memory 5001)
    (maxmem 5001)
    (features )
    (name Domain-0)
    (on_poweroff destroy)
    (on_reboot restart)
    (on_crash restart)
    (state r-----)
    (shutdown_reason poweroff)
    (cpu_time 3418.1466961)
    (online_vcpus 32)
)
PASS: 05_list_long_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3418.5
*** Finished cleaning domUs
*** Test 06_list_nonroot started at Sun Aug  6 15:52:32 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3418.9
*** Finished cleaning domUs
*** Test 06_list_nonroot started at Sun Aug  6 15:52:33 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm list'
ERROR: Could not obtain handle on privileged command interface (13 = Permission denied)
Error: Most commands need root access.  Please try again as root.
PASS: 06_list_nonroot.test
==================
All 6 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/list'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/list'
*** case memmax from group default
*** Running tests for case memmax
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/memmax'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/memmax'
cp 01_memmax_badparm_neg.py 01_memmax_badparm_neg.test
chmod +x 01_memmax_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3419.6
*** Finished cleaning domUs
*** Test 01_memmax_badparm_neg started at Sun Aug  6 15:52:33 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3420.0
*** Finished cleaning domUs
*** Test 01_memmax_badparm_neg started at Sun Aug  6 15:52:34 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm mem-max'
Error: 'xm mem-max' requires 2 arguments.

   mem-max <DomId> <Mem>            Set maximum memory reservation for a domain
[dom0] Running `xm mem-max 6666'
Error: 'xm mem-max' requires 2 arguments.

   mem-max <DomId> <Mem>            Set maximum memory reservation for a domain
PASS: 01_memmax_badparm_neg.test
==================
All 1 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/memmax'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/memmax'
*** case memset from group default
*** Running tests for case memset
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/memset'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/memset'
cp 01_memset_basic_pos.py 01_memset_basic_pos.test
chmod +x 01_memset_basic_pos.test
cp 02_memset_badparm_neg.py 02_memset_badparm_neg.test
chmod +x 02_memset_badparm_neg.test
cp 03_memset_random_pos.py 03_memset_random_pos.test
chmod +x 03_memset_random_pos.test
cp 04_memset_smallmem_pos.py 04_memset_smallmem_pos.test
chmod +x 04_memset_smallmem_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3421.0
*** Finished cleaning domUs
*** Test 01_memset_basic_pos started at Sun Aug  6 15:52:35 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3421.4
*** Finished cleaning domUs
*** Test 01_memset_basic_pos started at Sun Aug  6 15:52:35 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 01_memset_basic_pos-1154893955
Console executing: ['/usr/sbin/xm', 'xm', 'console', '01_memset_basic_pos-1154893955']
[01_memset_basic_pos-1154893955] Sending `input'
[01_memset_basic_pos-1154893955] Sending `ls'
[01_memset_basic_pos-1154893955] Sending `echo $?'
[01_memset_basic_pos-1154893955] Sending `cat /proc/xen/balloon | grep Current'
[01_memset_basic_pos-1154893955] Sending `echo $?'
[dom0] Running `xm mem-set 01_memset_basic_pos-1154893955 58'

[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
01_memset_basic_pos-1154893955   145       58     1 -b----     0.3
Domain-0                           0     5001    32 r-----  3423.4
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
01_memset_basic_pos-1154893955   145       58     1 -b----     0.3
Domain-0                           0     5001    32 r-----  3423.7
[01_memset_basic_pos-1154893955] Sending `cat /proc/xen/balloon | grep Current'
[01_memset_basic_pos-1154893955] Sending `echo $?'
[dom0] Running `xm shutdown 01_memset_basic_pos-1154893955'

PASS: 01_memset_basic_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
01_memset_basic_pos-1154893955   145       58     1 -b----     0.4
Domain-0                           0     5001    32 r-----  3424.4
[dom0] Running `xm destroy 01_memset_basic_pos-1154893955'
*** Finished cleaning domUs
*** Test 02_memset_badparm_neg started at Sun Aug  6 15:52:46 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3425.3
*** Finished cleaning domUs
*** Test 02_memset_badparm_neg started at Sun Aug  6 15:52:46 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm mem-set'
Error: 'xm mem-set' requires 2 arguments.

   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
[dom0] Running `xm mem-set -x'
Error: 'xm mem-set' requires 2 arguments.

   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
[dom0] Running `xm mem-set 6666'
Error: 'xm mem-set' requires 2 arguments.

   mem-set <DomId> <Mem>            Adjust the current memory usage for a domain
[dom0] Running `xm mem-set 6666 64'
Error: the domain '6666' does not exist.
PASS: 02_memset_badparm_neg.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3426.5
*** Finished cleaning domUs
*** Test 03_memset_random_pos started at Sun Aug  6 15:52:48 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3426.9
*** Finished cleaning domUs
*** Test 03_memset_random_pos started at Sun Aug  6 15:52:48 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 03_memset_random_pos-1154893968
Console executing: ['/usr/sbin/xm', 'xm', 'console', '03_memset_random_pos-1154893968']
[03_memset_random_pos-1154893968] Sending `input'
[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[3/24] Current: 59 Target: 56
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 56'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       56     1 -b----     0.4
Domain-0                           0     5001    32 r-----  3429.0
[6/24] Current: 56 Target: 50
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 50'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       50     1 -b----     0.4
Domain-0                           0     5001    32 r-----  3429.7
[7/24] Current: 50 Target: 52
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 52'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       52     1 -b----     0.4
Domain-0                           0     5001    32 r-----  3430.3
[8/24] Current: 52 Target: 44
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 44'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       44     1 -b----     0.5
Domain-0                           0     5001    32 r-----  3430.8
[9/24] Current: 44 Target: 44
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 44'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       44     1 -b----     0.5
Domain-0                           0     5001    32 r-----  3431.5
[10/24] Current: 44 Target: 40
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 40'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       40     1 -b----     0.5
Domain-0                           0     5001    32 r-----  3432.1
[11/24] Current: 40 Target: 44
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 44'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       44     1 -b----     0.5
Domain-0                           0     5001    32 r-----  3432.6
[12/24] Current: 44 Target: 44
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 44'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       44     1 -b----     0.5
Domain-0                           0     5001    32 r-----  3433.2
[13/24] Current: 44 Target: 48
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 48'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       48     1 -b----     0.6
Domain-0                           0     5001    32 r-----  3433.9
[14/24] Current: 48 Target: 50
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 50'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       50     1 -b----     0.6
Domain-0                           0     5001    32 r-----  3434.5
[15/24] Current: 50 Target: 43
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 43'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       43     1 -b----     0.6
Domain-0                           0     5001    32 r-----  3435.2
[16/24] Current: 43 Target: 42
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 42'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       42     1 -b----     0.6
Domain-0                           0     5001    32 r-----  3435.8
[17/24] Current: 42 Target: 35
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 35'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       35     1 -b----     0.7
Domain-0                           0     5001    32 r-----  3436.4
[18/24] Current: 35 Target: 40
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 40'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       40     1 -b----     0.7
Domain-0                           0     5001    32 r-----  3437.0
[19/24] Current: 40 Target: 39
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 39'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       39     1 -b----     0.7
Domain-0                           0     5001    32 r-----  3437.6
[21/24] Current: 39 Target: 39
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 39'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       39     1 -b----     0.7
Domain-0                           0     5001    32 r-----  3438.1
[22/24] Current: 39 Target: 49
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 49'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       49     1 -b----     0.7
Domain-0                           0     5001    32 r-----  3438.9
[23/24] Current: 49 Target: 47
[dom0] Running `xm mem-set 03_memset_random_pos-1154893968 47'

[03_memset_random_pos-1154893968] Sending `cat /proc/xen/balloon | grep Current'
[03_memset_random_pos-1154893968] Sending `echo $?'
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       47     1 -b----     0.8
Domain-0                           0     5001    32 r-----  3439.5
PASS: 03_memset_random_pos.test
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
03_memset_random_pos-1154893968  146       47     1 -b----     0.8
Domain-0                           0     5001    32 r-----  3439.9
[dom0] Running `xm destroy 03_memset_random_pos-1154893968'
*** Finished cleaning domUs
*** Test 04_memset_smallmem_pos started at Sun Aug  6 15:53:39 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
*** Cleaning all running domU's
[dom0] Running `xm list'
Name                              ID Mem(MiB) VCPUs State  Time(s)
Domain-0                           0     5001    32 r-----  3441.0
*** Finished cleaning domUs
*** Test 04_memset_smallmem_pos started at Sun Aug  6 15:53:40 2006 EDT
[dom0] Running `ip addr show |grep "inet 169.254" | grep -v vif'

[dom0] Running `ip addr show dev vif0.0'
2: vif0.0: <BROADCAST,NOARP,UP> mtu 1500 qdisc noqueue 
    link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcff:ffff:feff:ffff/64 scope link 
       valid_lft forever preferred_lft forever
[dom0] Running `xm create /tmp/xm-test.conf'
Using config file "/tmp/xm-test.conf".
Started domain 04_memset_smallmem_pos-1154894020
Console executing: ['/usr/sbin/xm', 'xm', 'console', '04_memset_smallmem_pos-1154894020']
[04_memset_smallmem_pos-1154894020] Sending `input'
[04_memset_smallmem_pos-1154894020] Sending `ls'
[04_memset_smallmem_pos-1154894020] Sending `echo $?'
[dom0] Running `xm mem-set 04_memset_smallmem_pos-1154894020 15'

[04_memset_smallmem_pos-1154894020] Sending `ls'
[04_memset_smallmem_pos-1154894020] Sending `echo $?'
[dom0] Running `xm destroy 04_memset_smallmem_pos-1154894020'

PASS: 04_memset_smallmem_pos.test
==================
All 4 tests passed
==================
make[2]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/memset'
make[1]: Leaving directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/memset'
*** case migrate from group default
*** Running tests for case migrate
make[1]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/migrate'
make  check-TESTS
make[2]: Entering directory `/home/unisys/xen-unstable.hg/tools/xm-test/tests/migrate'
cp 01_migrate_localhost_pos.py 01_migrate_localhost_pos.test
chmod +x 01_migrate_localhost_pos.test

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 4%]

* [patch/rfc] xenbus and driver issues with kexec
@ 2006-08-14 15:17 13% Gerd Hoffmann
  0 siblings, 0 replies; 200+ results
From: Gerd Hoffmann @ 2006-08-14 15:17 UTC (permalink / raw)
  To: Xen devel list

[-- Attachment #1: Type: text/plain, Size: 1891 bytes --]

  Hi,

There are a number of problems in xenbus and the paravirtualized drivers
when it comes to kexec'ing a domU kernel.  It's not specific to kexec,
but to handing over devices to someone else within the same domU.  The
same issues will come up when someone tries to combine mini-os and grub
to build some kind of in-domain bootloader.

Fundamental issue is that there is no way to cleanly shutdown the
frontend/backend drivers without destroying the domain and the backend
devices.  The patch addresses some but not all of the problems arising
from that.  It also has some debug stuff left in and needs some more
polishing before final submission.

Here are the changes:

  (1) ballon: print unconditionally driver_pages in /proc/xen/balloon.
  (2) xenbus: unregister watches in xs_suspend()
  (3) blk/netback: allow Closing -> Initialising state transition.
  (4) blk/netfront: shutdown (but *not* destroy) devices
      when devices_shutdown is called, by jumping from Closing to
      Initialising state.
  (5) Some cleanups along the way.

Not solved yet:

The netfront driver leaks pages in case it is shutdown while the
interface is active.  Problem is that it can't get back the rx buffers,
the netback driver sits on them and doesn't release them until it has
some packet data to fill in.  The patch adds a netif_release_rx_bufs()
function, but it doesn't work reliable, usually it gets back only a few
pages.

To reproduce this you don't need to play with kexec.  Just apply the
balloon driver patch.  Boot a domU with the new kernel.  Configure the
eth0 interface, "xm network-detach ...", "xm network-attach", repeat.
Watch driver_pages grow in /proc/xen/balloon.

cheers,

  Gerd

PS: documentation and complete domU kexec patches are available from
    http://www.suse.de/~kraxel/xen/kexec.html

-- 
Gerd Hoffmann <kraxel@suse.de>
http://www.suse.de/~kraxel/julika-dora.jpeg

[-- Attachment #2: drivers.diff --]
[-- Type: text/x-patch, Size: 16593 bytes --]

diff -r befab551b0e1 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Sun Aug 13 09:44:07 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Aug 14 12:49:11 2006 +0200
@@ -440,15 +440,17 @@ static int balloon_read(char *page, char
 		"Requested target:   %8lu kB\n"
 		"Low-mem balloon:    %8lu kB\n"
 		"High-mem balloon:   %8lu kB\n"
+		"Driver pages:       %8lu kB\n"
 		"Xen hard limit:     ",
 		PAGES2KB(current_pages), PAGES2KB(target_pages), 
-		PAGES2KB(balloon_low), PAGES2KB(balloon_high));
+		PAGES2KB(balloon_low), PAGES2KB(balloon_high),
+		PAGES2KB(driver_pages));
 
 	if (hard_limit != ~0UL) {
 		len += sprintf(
 			page + len, 
-			"%8lu kB (inc. %8lu kB driver headroom)\n",
-			PAGES2KB(hard_limit), PAGES2KB(driver_pages));
+			"%8lu kB\n",
+			PAGES2KB(hard_limit));
 	} else {
 		len += sprintf(
 			page + len,
diff -r befab551b0e1 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Sun Aug 13 09:44:07 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Mon Aug 14 12:49:11 2006 +0200
@@ -305,6 +305,11 @@ static void frontend_changed(struct xenb
 
 	switch (frontend_state) {
 	case XenbusStateInitialising:
+		if (dev->state == XenbusStateClosing) {
+			printk("%s: %s: prepare for reconnect\n",
+			       __FUNCTION__, dev->nodename);
+			xenbus_switch_state(dev, XenbusStateInitWait);
+		}
 		break;
 
 	case XenbusStateInitialised:
diff -r befab551b0e1 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Sun Aug 13 09:44:07 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Aug 14 12:49:11 2006 +0200
@@ -272,10 +272,13 @@ static void backend_changed(struct xenbu
 			xenbus_dev_fatal(dev, -ENODEV, "bdget failed");
 
 		down(&bd->bd_sem);
-		if (info->users > 0)
+		if (info->users)
+			printk("%-20s: %s: %d user(s) left\n", __FUNCTION__,
+			       dev->nodename, info->users);
+		if (info->users > 0 && !dev->shutdown_in_progress) {
 			xenbus_dev_error(dev, -EBUSY,
 					 "Device in use; refusing to close");
-		else
+		} else
 			blkfront_closing(dev);
 		up(&bd->bd_sem);
 		bdput(bd);
@@ -359,7 +362,7 @@ static void blkfront_closing(struct xenb
 
 	xlvbd_del(info);
 
-	xenbus_switch_state(dev, XenbusStateClosed);
+	xenbus_closing_done(dev);
 }
 
 
diff -r befab551b0e1 linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Sun Aug 13 09:44:07 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Mon Aug 14 12:49:11 2006 +0200
@@ -228,10 +228,25 @@ static void frontend_changed(struct xenb
 
 	switch (frontend_state) {
 	case XenbusStateInitialising:
+		if (dev->state == XenbusStateClosing) {
+			printk("%s: %s: prepare for reconnect\n",
+			       __FUNCTION__, dev->nodename);
+			if (be->netif) {
+				netif_disconnect(be->netif);
+				be->netif = NULL;
+			}
+			xenbus_switch_state(dev, XenbusStateInitWait);
+		}
+		break;
+
 	case XenbusStateInitialised:
 		break;
 
 	case XenbusStateConnected:
+		if (!be->netif) {
+			/* reconnect: setup be->netif */
+			backend_changed(&be->backend_watch, NULL, 0);
+		}
 		maybe_connect(be);
 		break;
 
diff -r befab551b0e1 linux-2.6-xen-sparse/drivers/xen/netfront/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/Makefile	Sun Aug 13 09:44:07 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/Makefile	Mon Aug 14 12:49:11 2006 +0200
@@ -1,3 +1,4 @@
+EXTRA_CFLAGS += -DDEBUG=1
 
 obj-$(CONFIG_XEN_NETDEV_FRONTEND)	:= xennet.o
 
diff -r befab551b0e1 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Sun Aug 13 09:44:07 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Aug 14 12:49:11 2006 +0200
@@ -436,7 +436,7 @@ static void backend_changed(struct xenbu
 	struct netfront_info *np = dev->dev.driver_data;
 	struct net_device *netdev = np->netdev;
 
-	DPRINTK("\n");
+	DPRINTK("%s\n", xenbus_strstate(backend_state));
 
 	switch (backend_state) {
 	case XenbusStateInitialising:
@@ -447,9 +447,11 @@ static void backend_changed(struct xenbu
 		break;
 
 	case XenbusStateInitWait:
-		network_connect(netdev);
-		xenbus_switch_state(dev, XenbusStateConnected);
-		(void)send_fake_arp(netdev);
+		if (!dev->shutdown_in_progress) {
+			network_connect(netdev);
+			xenbus_switch_state(dev, XenbusStateConnected);
+			(void)send_fake_arp(netdev);
+		}
 		break;
 
 	case XenbusStateClosing:
@@ -492,6 +494,7 @@ static int network_open(struct net_devic
 {
 	struct netfront_info *np = netdev_priv(dev);
 
+	DPRINTK("%s\n", np->xbdev->nodename);
 	memset(&np->stats, 0, sizeof(np->stats));
 
 	network_alloc_rx_buffers(dev);
@@ -651,6 +654,8 @@ no_skb:
 	    ((np->rx_target *= 2) > np->rx_max_target))
 		np->rx_target = np->rx_max_target;
 
+//	printk("%s: %d bufs, target %d\n", __FUNCTION__, i, np->rx_target);
+	
  refill:
 	for (i = 0; ; i++) {
 		if ((skb = __skb_dequeue(&np->rx_batch)) == NULL)
@@ -1223,6 +1228,7 @@ err:
 
 	/* Some pages are no longer absent... */
 	balloon_update_driver_allowance(-pages_done);
+//	printk("%s: %d driver pages\n", __FUNCTION__, work_done);
 
 	/* Do all the remapping work, and M2P updates, in one big hypercall. */
 	if (likely(pages_done)) {
@@ -1283,10 +1289,80 @@ err:
 	return more_to_do;
 }
 
+static void netif_release_rx_bufs(struct netfront_info *np)
+{
+	struct mmu_update      *mmu = np->rx_mmu;
+	struct multicall_entry *mcl = np->rx_mcl;
+	struct sk_buff *skb;
+	unsigned long mfn;
+	int bufs = 0, gnttab = 0, unused = 0;
+	int id, ref;
+
+	spin_lock(&np->rx_lock);
+
+	for (id = 0; id < NET_RX_RING_SIZE; id++) {
+		if ((ref = np->grant_rx_ref[id]) == GRANT_INVALID_REF) {
+			unused++;
+			continue;
+		}
+		if ((mfn = gnttab_end_foreign_transfer_ref(ref)) == 0) {
+			gnttab++;
+			continue;
+		}
+
+		gnttab_release_grant_reference(&np->gref_rx_head, ref);
+		np->grant_rx_ref[id] = GRANT_INVALID_REF;
+
+		skb = np->rx_skbs[id];
+		add_id_to_freelist(np->rx_skbs, id);
+
+		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+			/* Remap the page. */
+			MULTI_update_va_mapping(mcl, (unsigned long)skb->head,
+						pfn_pte_ma(mfn, PAGE_KERNEL),
+						0);
+			mcl++;
+			mmu->ptr = ((maddr_t)mfn << PAGE_SHIFT)
+				| MMU_MACHPHYS_UPDATE;
+			mmu->val = __pa(skb->head) >> PAGE_SHIFT;
+			mmu++;
+
+			set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT,
+					    mfn);
+		}
+		bufs++;
+
+#if 0 /* FIXME */
+		dev_kfree_skb(skb);
+#endif
+	}
+
+	printk("%s: %d released ok, %d gnttab errs, %d unused slots\n",
+	       __FUNCTION__, bufs, gnttab, unused);
+	if (0 == bufs)
+		return;
+
+	/* Some pages are no longer absent... */
+	balloon_update_driver_allowance(-bufs);
+
+	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+		/* Do all the remapping work, and M2P updates, in one big hypercall. */
+		mcl->op = __HYPERVISOR_mmu_update;
+		mcl->args[0] = (unsigned long)np->rx_mmu;
+		mcl->args[1] = mmu - np->rx_mmu;
+		mcl->args[2] = 0;
+		mcl->args[3] = DOMID_SELF;
+		mcl++;
+		HYPERVISOR_multicall(np->rx_mcl, mcl - np->rx_mcl);
+	}
+
+	spin_unlock(&np->rx_lock);
+}
 
 static int network_close(struct net_device *dev)
 {
 	struct netfront_info *np = netdev_priv(dev);
+	DPRINTK("%s\n", np->xbdev->nodename);
 	netif_stop_queue(np->netdev);
 	return 0;
 }
@@ -1425,6 +1501,8 @@ static void netif_uninit(struct net_devi
 static void netif_uninit(struct net_device *dev)
 {
 	struct netfront_info *np = netdev_priv(dev);
+	DPRINTK("%s\n", np->xbdev->nodename);
+	netif_release_rx_bufs(np);
 	gnttab_free_grant_references(np->gref_tx_head);
 	gnttab_free_grant_references(np->gref_rx_head);
 }
@@ -1720,11 +1798,11 @@ static void netfront_closing(struct xenb
 {
 	struct netfront_info *info = dev->dev.driver_data;
 
-	DPRINTK("netfront_closing: %s removed\n", dev->nodename);
+	DPRINTK("%s\n", dev->nodename);
 
 	close_netdev(info);
-
-	xenbus_switch_state(dev, XenbusStateClosed);
+//	netif_release_rx_bufs(info);
+	xenbus_closing_done(dev);
 }
 
 
@@ -1740,9 +1818,9 @@ static int __devexit netfront_remove(str
 	return 0;
 }
 
-
 static void close_netdev(struct netfront_info *info)
 {
+	DPRINTK("%s\n", info->xbdev->nodename);
 	del_timer_sync(&info->rx_refill_timer);
 
 	xennet_sysfs_delif(info->netdev);
@@ -1752,6 +1830,7 @@ static void close_netdev(struct netfront
 
 static void netif_disconnect_backend(struct netfront_info *info)
 {
+	DPRINTK("%s\n", info->xbdev->nodename);
 	/* Stop old i/f to prevent errors whilst we rebuild the state. */
 	spin_lock_irq(&info->tx_lock);
 	spin_lock(&info->rx_lock);
@@ -1774,6 +1853,7 @@ static void netif_disconnect_backend(str
 
 static void netif_free(struct netfront_info *info)
 {
+	DPRINTK("%s\n", info->xbdev->nodename);
 	close_netdev(info);
 	netif_disconnect_backend(info);
 	free_netdev(info->netdev);
@@ -1797,9 +1877,9 @@ static struct xenbus_device_id netfront_
 
 
 static struct xenbus_driver netfront = {
+	.ids = netfront_ids,
 	.name = "vif",
 	.owner = THIS_MODULE,
-	.ids = netfront_ids,
 	.probe = netfront_probe,
 	.remove = __devexit_p(netfront_remove),
 	.resume = netfront_resume,
diff -r befab551b0e1 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Sun Aug 13 09:44:07 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Mon Aug 14 12:49:11 2006 +0200
@@ -41,6 +41,21 @@ extern char *kasprintf(const char *fmt, 
 #define DPRINTK(fmt, args...) \
     pr_debug("xenbus_client (%s:%d) " fmt ".\n", __FUNCTION__, __LINE__, ##args)
 
+char *xenbus_strstate(enum xenbus_state state)
+{
+	static char *name[] = {
+		[ XenbusStateUnknown      ] = "Unknown",
+		[ XenbusStateInitialising ] = "Initialising",
+		[ XenbusStateInitWait     ] = "InitWait",
+		[ XenbusStateInitialised  ] = "Initialised",
+		[ XenbusStateConnected    ] = "Connected",
+		[ XenbusStateClosing      ] = "Closing",
+		[ XenbusStateClosed	  ] = "Closed",
+	};
+	return state < sizeof(name)/sizeof(name[0])
+		? name[state] : "INVALID";
+}
+
 int xenbus_watch_path(struct xenbus_device *dev, const char *path,
 		      struct xenbus_watch *watch,
 		      void (*callback)(struct xenbus_watch *,
@@ -124,6 +139,23 @@ int xenbus_switch_state(struct xenbus_de
 }
 EXPORT_SYMBOL_GPL(xenbus_switch_state);
 
+int xenbus_closing_done(struct xenbus_device *dev)
+{
+	if (dev->shutdown_in_progress) {
+		/* frontend (we) triggered closing, because of devices_shutdown(),
+		 * prepare for possible re-connect */
+		printk("%-20s: %s: => Initialising\n", __FUNCTION__, dev->nodename);
+		xenbus_switch_state(dev, XenbusStateInitialising);
+	} else {
+		/* backend triggered closing, probably the device went away,
+		 * thus we are going to close down too. */
+		printk("%-20s: %s: => Closed\n", __FUNCTION__, dev->nodename);
+		xenbus_switch_state(dev, XenbusStateClosed);
+	}
+	complete(&dev->down);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(xenbus_closing_done);
 
 /**
  * Return the path to the error node for the given device, or NULL on failure.
diff -r befab551b0e1 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Sun Aug 13 09:44:07 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Aug 14 12:49:11 2006 +0200
@@ -60,6 +60,15 @@ static struct notifier_block *xenstore_c
 
 static void wait_for_devices(struct xenbus_driver *xendrv);
 
+static int xenbus_probe_frontend(const char *type, const char *name);
+static int xenbus_uevent_backend(struct device *dev, char **envp,
+				 int num_envp, char *buffer, int buffer_size);
+static int xenbus_probe_backend(const char *type, const char *domid);
+
+static int xenbus_dev_probe(struct device *_dev);
+static int xenbus_dev_remove(struct device *_dev);
+static void xenbus_dev_shutdown(struct device *_dev);
+
 /* If something in array of ids matches this device, return it. */
 static const struct xenbus_device_id *
 match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev)
@@ -168,15 +177,17 @@ static int read_frontend_details(struct 
 
 
 /* Bus type for frontend drivers. */
-static int xenbus_probe_frontend(const char *type, const char *name);
 static struct xen_bus_type xenbus_frontend = {
 	.root = "device",
 	.levels = 2, 		/* device/type/<id> */
 	.get_bus_id = frontend_bus_id,
 	.probe = xenbus_probe_frontend,
 	.bus = {
-		.name  = "xen",
-		.match = xenbus_match,
+		.name     = "xen",
+		.match    = xenbus_match,
+		.probe    = xenbus_dev_probe,
+		.remove   = xenbus_dev_remove,
+		.shutdown = xenbus_dev_shutdown,
 	},
 	.dev = {
 		.bus_id = "xen",
@@ -221,18 +232,18 @@ static int backend_bus_id(char bus_id[BU
 	return 0;
 }
 
-static int xenbus_uevent_backend(struct device *dev, char **envp,
-				 int num_envp, char *buffer, int buffer_size);
-static int xenbus_probe_backend(const char *type, const char *domid);
 static struct xen_bus_type xenbus_backend = {
 	.root = "backend",
 	.levels = 3, 		/* backend/type/<frontend>/<id> */
 	.get_bus_id = backend_bus_id,
 	.probe = xenbus_probe_backend,
 	.bus = {
-		.name  = "xen-backend",
-		.match = xenbus_match,
-		.uevent = xenbus_uevent_backend,
+		.name     = "xen-backend",
+		.match    = xenbus_match,
+		.probe    = xenbus_dev_probe,
+		.remove   = xenbus_dev_remove,
+//		.shutdown = xenbus_dev_shutdown,
+		.uevent   = xenbus_uevent_backend,
 	},
 	.dev = {
 		.bus_id = "xen-backend",
@@ -391,6 +402,26 @@ static int xenbus_dev_remove(struct devi
 	return 0;
 }
 
+static void xenbus_dev_shutdown(struct device *_dev)
+{
+	struct xenbus_device *dev = to_xenbus_device(_dev);
+	unsigned long timeout = 5*HZ;
+
+	get_device(&dev->dev);
+	if (dev->state != XenbusStateConnected) {
+		printk("%s: %s: %s != Connected, skipping\n", __FUNCTION__,
+		       dev->nodename, xenbus_strstate(dev->state));
+		goto out;
+	}
+	dev->shutdown_in_progress = 1;
+	xenbus_switch_state(dev, XenbusStateClosing);
+	timeout = wait_for_completion_timeout(&dev->down, timeout);
+	if (!timeout)
+		printk("%s: %s timeout closing device\n", __FUNCTION__, dev->nodename);
+ out:
+	put_device(&dev->dev);
+}
+
 static int xenbus_register_driver_common(struct xenbus_driver *drv,
 					 struct xen_bus_type *bus)
 {
@@ -399,8 +430,6 @@ static int xenbus_register_driver_common
 	drv->driver.name = drv->name;
 	drv->driver.bus = &bus->bus;
 	drv->driver.owner = drv->owner;
-	drv->driver.probe = xenbus_dev_probe;
-	drv->driver.remove = xenbus_dev_remove;
 
 	mutex_lock(&xenwatch_mutex);
 	ret = driver_register(&drv->driver);
@@ -575,6 +604,7 @@ static int xenbus_probe_node(struct xen_
 	tmpstring += strlen(tmpstring) + 1;
 	strcpy(tmpstring, type);
 	xendev->devicetype = tmpstring;
+	init_completion(&xendev->down);
 
 	xendev->dev.parent = &bus->dev;
 	xendev->dev.bus = &bus->bus;
diff -r befab551b0e1 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Sun Aug 13 09:44:07 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Mon Aug 14 12:49:11 2006 +0200
@@ -665,7 +665,18 @@ EXPORT_SYMBOL_GPL(unregister_xenbus_watc
 
 void xs_suspend(void)
 {
+	struct xenbus_watch *watch;
+	char token[sizeof(watch) * 2 + 1];
+
 	down_write(&xs_state.suspend_mutex);
+
+	/* No need for watches_lock: the suspend_mutex is sufficient. */
+	list_for_each_entry(watch, &watches, list) {
+		sprintf(token, "%lX", (long)watch);
+		xs_unwatch(watch->node, token);
+//		printk("%s: unwatch %s\n", __FUNCTION__, watch->node);
+	}
+
 	mutex_lock(&xs_state.request_mutex);
 }
 
diff -r befab551b0e1 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Sun Aug 13 09:44:07 2006 +0100
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Mon Aug 14 12:49:11 2006 +0200
@@ -37,6 +37,7 @@
 #include <linux/device.h>
 #include <linux/notifier.h>
 #include <linux/mutex.h>
+#include <linux/completion.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/grant_table.h>
 #include <xen/interface/io/xenbus.h>
@@ -74,6 +75,9 @@ struct xenbus_device {
 	struct xenbus_watch otherend_watch;
 	struct device dev;
 	enum xenbus_state state;
+
+	struct completion down;
+	int shutdown_in_progress;
 };
 
 static inline struct xenbus_device *to_xenbus_device(struct device *dev)
@@ -296,4 +300,7 @@ void xenbus_dev_fatal(struct xenbus_devi
 		      ...);
 
 
+int xenbus_closing_done(struct xenbus_device *dev);
+char *xenbus_strstate(enum xenbus_state state);
+
 #endif /* _XEN_XENBUS_H */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 13%]

* [patch 2/6] /proc/xen/ballon tweak
@ 2006-08-17 13:42 15% Gerd Hoffmann
  0 siblings, 0 replies; 200+ results
From: Gerd Hoffmann @ 2006-08-17 13:42 UTC (permalink / raw)
  To: Xen devel list

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

  Hi,

The patch below makes  /proc/xen/ballon contain driver_pages (aka
"driver headroom") unconditionally.

please apply,

  Gerd

-- 
Gerd Hoffmann <kraxel@suse.de>
http://www.suse.de/~kraxel/julika-dora.jpeg

[-- Attachment #2: balloon-proc-output --]
[-- Type: text/plain, Size: 1035 bytes --]

Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
Index: source-lnx-stable-22813/drivers/xen/balloon/balloon.c
===================================================================
--- source-lnx-stable-22813.orig/drivers/xen/balloon/balloon.c	2006-08-17 15:19:20.000000000 +0200
+++ source-lnx-stable-22813/drivers/xen/balloon/balloon.c	2006-08-17 15:20:17.000000000 +0200
@@ -440,15 +440,17 @@ static int balloon_read(char *page, char
 		"Requested target:   %8lu kB\n"
 		"Low-mem balloon:    %8lu kB\n"
 		"High-mem balloon:   %8lu kB\n"
+		"Driver pages:       %8lu kB\n"
 		"Xen hard limit:     ",
 		PAGES2KB(current_pages), PAGES2KB(target_pages), 
-		PAGES2KB(balloon_low), PAGES2KB(balloon_high));
+		PAGES2KB(balloon_low), PAGES2KB(balloon_high),
+		PAGES2KB(driver_pages));
 
 	if (hard_limit != ~0UL) {
 		len += sprintf(
 			page + len, 
-			"%8lu kB (inc. %8lu kB driver headroom)\n",
-			PAGES2KB(hard_limit), PAGES2KB(driver_pages));
+			"%8lu kB\n",
+			PAGES2KB(hard_limit));
 	} else {
 		len += sprintf(
 			page + len,

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 15%]

* Re: [patch 6/6] netif_release_rx_bufs
  @ 2006-08-18 12:41 15% ` Gerd Hoffmann
  0 siblings, 0 replies; 200+ results
From: Gerd Hoffmann @ 2006-08-18 12:41 UTC (permalink / raw)
  To: Keir Fraser; +Cc: Xen devel list

[-- Attachment #1: Type: text/plain, Size: 335 bytes --]

  Hi,

> Best bet is to free the page to the balloon driver, and then set nr_frags to
> zero. This is perfectly valid -- it was netfront that set it to non-zero in
> the first place.

Perfect.  New version of the patch is attached below.

cheers,

  Gerd

-- 
Gerd Hoffmann <kraxel@suse.de>
http://www.suse.de/~kraxel/julika-dora.jpeg

[-- Attachment #2: netfront-release-rx --]
[-- Type: text/plain, Size: 5082 bytes --]

Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
Index: source-lnx-stable-22813/drivers/xen/netfront/netfront.c
===================================================================
--- source-lnx-stable-22813.orig/drivers/xen/netfront/netfront.c	2006-08-18 10:47:12.000000000 +0200
+++ source-lnx-stable-22813/drivers/xen/netfront/netfront.c	2006-08-18 14:39:56.000000000 +0200
@@ -494,6 +494,7 @@ static int network_open(struct net_devic
 {
 	struct netfront_info *np = netdev_priv(dev);
 
+	DPRINTK("%s\n", np->xbdev->nodename);
 	memset(&np->stats, 0, sizeof(np->stats));
 
 	network_alloc_rx_buffers(dev);
@@ -1285,10 +1286,86 @@ err:
 	return more_to_do;
 }
 
+static void netif_release_rx_bufs(struct netfront_info *np)
+{
+	struct mmu_update      *mmu = np->rx_mmu;
+	struct multicall_entry *mcl = np->rx_mcl;
+	struct sk_buff *skb;
+	unsigned long mfn;
+	int xfer = 0, noxfer = 0, unused = 0;
+	int id, ref, rc;
+
+	printk("%s: enter\n", __FUNCTION__);
+
+	spin_lock(&np->rx_lock);
+
+	for (id = 0; id < NET_RX_RING_SIZE; id++) {
+		if ((ref = np->grant_rx_ref[id]) == GRANT_INVALID_REF) {
+			unused++;
+			continue;
+		}
+
+		skb = np->rx_skbs[id];
+		mfn = gnttab_end_foreign_transfer_ref(ref);
+		gnttab_release_grant_reference(&np->gref_rx_head, ref);
+		np->grant_rx_ref[id] = GRANT_INVALID_REF;
+		add_id_to_freelist(np->rx_skbs, id);
+
+		if (0 == mfn) {
+			struct page *page = skb_shinfo(skb)->frags[0].page;
+			balloon_release_driver_page(page);
+			skb_shinfo(skb)->nr_frags = 0;
+			dev_kfree_skb(skb);
+			noxfer++;
+			continue;
+		}
+
+		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+			/* Remap the page. */
+			struct page *page = skb_shinfo(skb)->frags[0].page;
+			unsigned long pfn = page_to_pfn(page);
+			void *vaddr = page_address(page);
+
+			MULTI_update_va_mapping(mcl, (unsigned long)vaddr,
+						pfn_pte_ma(mfn, PAGE_KERNEL),
+						0);
+			mcl++;
+			mmu->ptr = ((maddr_t)mfn << PAGE_SHIFT)
+				| MMU_MACHPHYS_UPDATE;
+			mmu->val = pfn;
+			mmu++;
+
+			set_phys_to_machine(pfn, mfn);
+		}
+		dev_kfree_skb(skb);
+		xfer++;
+	}
+	printk("%s: %d xfer, %d noxfer, %d unused\n",
+	       __FUNCTION__, xfer, noxfer, unused);
+
+	if (xfer) {
+		/* Some pages are no longer absent... */
+		balloon_update_driver_allowance(-xfer);
+
+		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+			/* Do all the remapping work, and M2P updates, in one big hypercall. */
+			mcl->op = __HYPERVISOR_mmu_update;
+			mcl->args[0] = (unsigned long)np->rx_mmu;
+			mcl->args[1] = mmu - np->rx_mmu;
+			mcl->args[2] = 0;
+			mcl->args[3] = DOMID_SELF;
+			mcl++;
+			HYPERVISOR_multicall(np->rx_mcl, mcl - np->rx_mcl);
+		}
+	}
+
+	spin_unlock(&np->rx_lock);
+}
 
 static int network_close(struct net_device *dev)
 {
 	struct netfront_info *np = netdev_priv(dev);
+	DPRINTK("%s\n", np->xbdev->nodename);
 	netif_stop_queue(np->netdev);
 	return 0;
 }
@@ -1427,6 +1504,8 @@ static void network_connect(struct net_d
 static void netif_uninit(struct net_device *dev)
 {
 	struct netfront_info *np = netdev_priv(dev);
+	DPRINTK("%s\n", np->xbdev->nodename);
+	netif_release_rx_bufs(np);
 	gnttab_free_grant_references(np->gref_tx_head);
 	gnttab_free_grant_references(np->gref_rx_head);
 }
Index: source-lnx-stable-22813/drivers/xen/balloon/balloon.c
===================================================================
--- source-lnx-stable-22813.orig/drivers/xen/balloon/balloon.c	2006-08-18 10:38:47.000000000 +0200
+++ source-lnx-stable-22813/drivers/xen/balloon/balloon.c	2006-08-18 12:13:44.000000000 +0200
@@ -612,8 +612,21 @@ void balloon_dealloc_empty_page_range(
 	schedule_work(&balloon_worker);
 }
 
+void balloon_release_driver_page(struct page *page)
+{
+	unsigned long flags;
+
+	balloon_lock(flags);
+	balloon_append(page);
+	driver_pages--;
+	balloon_unlock(flags);
+
+	schedule_work(&balloon_worker);
+}
+
 EXPORT_SYMBOL_GPL(balloon_update_driver_allowance);
 EXPORT_SYMBOL_GPL(balloon_alloc_empty_page_range);
 EXPORT_SYMBOL_GPL(balloon_dealloc_empty_page_range);
+EXPORT_SYMBOL_GPL(balloon_release_driver_page);
 
 MODULE_LICENSE("Dual BSD/GPL");
Index: source-lnx-stable-22813/drivers/xen/netfront/Makefile
===================================================================
--- source-lnx-stable-22813.orig/drivers/xen/netfront/Makefile	2006-08-18 11:14:35.000000000 +0200
+++ source-lnx-stable-22813/drivers/xen/netfront/Makefile	2006-08-18 12:20:14.000000000 +0200
@@ -1,3 +1,4 @@
+EXTRA_CFLAGS += -DDEBUG=1
 
 obj-$(CONFIG_XEN_NETDEV_FRONTEND)	:= xennet.o
 
Index: source-lnx-stable-22813/include/xen/balloon.h
===================================================================
--- source-lnx-stable-22813.orig/include/xen/balloon.h	2006-08-17 16:29:59.000000000 +0200
+++ source-lnx-stable-22813/include/xen/balloon.h	2006-08-18 12:13:17.000000000 +0200
@@ -52,6 +52,8 @@ extern void
 balloon_dealloc_empty_page_range(
 	struct page *page, unsigned long nr_pages);
 
+void balloon_release_driver_page(struct page *page);
+
 /*
  * Prevent the balloon driver from changing the memory reservation during
  * a driver critical region.

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 15%]

* [PATCH] Sysfs Interface for balloon driver
@ 2006-09-20  0:26 16% Satoshi Uchida
  0 siblings, 0 replies; 200+ results
From: Satoshi Uchida @ 2006-09-20  0:26 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 2401 bytes --]

 
Hi.

This patch provides a sysfs interface for the balloon driver.

Currently, the interface for the balloon driver is provided by procfs.
However, I was suggested by Kier and Anthony that procfs should handle  only process information and other information should be located in sysfs,  when I made the interface for virtual block devices.

The information for the balloon driver also should be moved to sysfs.
So, I have made a sysfs interface for the balloon driver.

The information for balloon driver is placed in /sys/bus/xen/driver/balloon.
I thought of other locations for the information, such as /sys/class/mem or /sys/devices/xen, but I finally selected the place because the balloon driver is similar to the front-end driver.
Please comments about that location.


Example outputs of the sysfs interface of the balloon driver are as follows:

 Example 1.  Show each information

    [root@Dom0 ~]# ls /sys/bus/xen/drivers/
    balloon/  pcifront/ vbd/
    [root@Dom0 ~]# ls /sys/bus/xen/drivers/balloon/
    bind  statistics  unbind
    [root@Dom0 ~]# ls /sys/bus/xen/drivers/balloon/statistics/
    balloon_high  current_pages  hard_limit
    balloon_low   driver_pages   target_pages
    [root@Dom0 ~]# cat /sys/bus/xen/drivers/balloon/statistics/balloon_high
          0 kB
    [root@Dom0 ~]# cat /sys/bus/xen/drivers/balloon/statistics/balloon_low
       510976 kB
   [root@Dom0 ~]# cat /sys/bus/xen/drivers/balloon/statistics/current_pages
       262144 kB
   [root@Dom0 ~]# cat /sys/bus/xen/drivers/balloon/statistics/driver_pages
       1024 kB
   [root@Dom0 ~]# cat /sys/bus/xen/drivers/balloon/statistics/hard_limit
       ??? kB


 Example 2. Set memory size of a domain

   [root@Dom0 ~]# cat /sys/bus/xen/drivers/balloon/statistics/target_pages
     262144 kB
   [root@Dom0 ~]# echo 1024M > /sys/bus/xen/drivers/balloon/statistics/target_pages
   [root@Dom0 ~]# cat /sys/bus/xen/drivers/balloon/statistics/target_pages
    1048576 kB
   [root@Dom0 ~]# cat /sys/bus/xen/drivers/balloon/statistics/current_pages
     758192 kB
   [root@Dom0 ~]# cat /sys/bus/xen/drivers/balloon/statistics/hard_limit
     758192 kB


The information for VMs should be located one place.
I want to propose a new location for the information of VMs, for example:
  /sys/virtualization -+--- domain
                               +--- hypervisor


Regards
Satoshi UCHIDA 
   NEC Corporation, Japan

[-- Attachment #1.1.2: balloon_sysfs.patch --]
[-- Type: application/octet-stream, Size: 3294 bytes --]

# HG changeset patch
# User root@noir.spf.cl.nec.co.jp
# Node ID 09a04601f89a1652b0d86d1764d02ebe89e7ecde
# Parent  10b05c2e79475f90330fa061b46d6df7e71a41c5
[Balloon]Add sysfs interface.

  This patch provides sysfs interface for balloon driver.
  Information is located under /sys/bus/xen/driver/balloon.

    Signed-off-by: Satoshi UCHIDA <s-uchida@ap.jp.nec.com>

diff -r 10b05c2e7947 -r 09a04601f89a linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Tue Aug 01 18:08:01 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Sep 15 13:08:48 2006 +0900
@@ -460,6 +460,76 @@ static int balloon_read(char *page, char
 }
 #endif
 
+/*****************************************************
+ *  sysfs interface for balloon driver.
+ */
+static struct xenbus_driver balloon = {
+	.name = "balloon",
+	.owner = THIS_MODULE,
+};
+
+#define BALLOON_SHOW(name, format, args...)			\
+	static ssize_t show_##name(struct device_driver *dri,	\
+				   char *buf)			\
+	{							\
+		return sprintf(buf, format, ##args);		\
+	}							\
+  	static DRIVER_ATTR(name, S_IRUGO, show_##name, NULL)
+
+BALLOON_SHOW(current_pages, "%8lu kB\n", PAGES2KB(current_pages));
+BALLOON_SHOW(balloon_low, "%8lu kB\n", PAGES2KB(balloon_low));
+BALLOON_SHOW(balloon_high, "%8lu kB\n", PAGES2KB(balloon_high));
+BALLOON_SHOW(hard_limit,
+	     (hard_limit!=~0UL)?"%8lu kB\n":"??? kB\n" ,
+	     (hard_limit!=~0UL)?PAGES2KB(hard_limit):0);
+BALLOON_SHOW(driver_pages, "%8lu kB\n", PAGES2KB(driver_pages));
+
+static ssize_t show_target_pages(struct device_driver *dri,  
+				 char *buf)
+{							       
+	return sprintf(buf, "%8lu kB\n", PAGES2KB(target_pages));		       
+}							       
+
+static ssize_t store_target_pages(struct device_driver *dri,
+				  const char *buf,
+				  size_t count)
+{
+	char memstring[64], *endchar;
+	unsigned long long target_bytes;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	
+	if (count <= 1)
+		return -EBADMSG; /* runt */
+	if (count > sizeof(memstring))
+		return -EFBIG;   /* too long */
+	printk("Balloon: size OK\n");
+	
+	target_bytes = memparse(buf, &endchar);
+	set_new_target(target_bytes >> PAGE_SHIFT);
+	
+	return count;
+}
+
+static DRIVER_ATTR(target_pages, S_IRUGO | S_IWUSR,
+	    show_target_pages, store_target_pages);
+
+static struct attribute *balloon_attrs[] = {
+	&driver_attr_current_pages.attr,
+	&driver_attr_target_pages.attr,
+	&driver_attr_balloon_low.attr,
+	&driver_attr_balloon_high.attr,
+	&driver_attr_hard_limit.attr,
+	&driver_attr_driver_pages.attr,
+	NULL
+};
+
+static struct attribute_group balloon_group = {
+	.name = "statistics",
+	.attrs = balloon_attrs,
+};
+
 static struct notifier_block xenstore_notifier;
 
 static int __init balloon_init(void)
@@ -493,7 +563,9 @@ static int __init balloon_init(void)
 	balloon_pde->read_proc  = balloon_read;
 	balloon_pde->write_proc = balloon_write;
 #endif
-    
+	xenbus_register_frontend(&balloon);
+	sysfs_create_group(&balloon.driver.kobj , &balloon_group);
+	
 	/* Initialise the balloon with excess memory space. */
 	for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
 		page = pfn_to_page(pfn);

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 4036 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[relevance 16%]

Results 1-200 of ~3000   | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2004-04-03 21:53  3% issues getting more than 16M ram to be used without oopsing. 1.2 and 1.3-unstable Brian Wolfe
2004-04-05 13:21     Keir Fraser
2004-04-05 13:38     ` Keir Fraser
2004-04-05 17:29  3%   ` Brian Wolfe
2004-05-31 20:11  3% Assertion '__task_on_runqueue(prev)' failed, line 458, file schedule.c Kip Macy
2004-06-11 15:20     Error creating block interface Jody Belka
2004-06-11 16:07     ` Ian Pratt
2004-06-11 16:34  5%   ` Jody Belka
2004-07-02 13:52     almost working James Harper
2004-07-02 15:21     ` Ian Pratt
2004-07-04 14:41  3%   ` Jody Belka
2004-07-02 15:06     Xen, gridcluster, boot with red hat ent 3 Ian Pratt
2004-07-05  9:08  4% ` Rune Johan Andresen
2004-07-14  3:20     lvm James Harper
2004-07-14  6:58     ` lvm Ian Pratt
2004-07-14  8:47       ` lvm Christian Limpach
2004-07-14 16:44  4%     ` lvm Derek Glidden
2004-07-16 19:33  7% /proc/xen/memory_target patch David Becker
2004-07-29  9:21     desperate for help on netwrok of xen Steven Hand
2004-07-29 10:33  4% ` Yan Li
2004-08-06 16:41  6% high memory manipulation patch David Becker
2004-08-08  2:58  4% Unknown boot option Daisaku Watanabe
2004-08-08 22:38     Problems booting 2.6.7 Dom0 with 3ware Controllers Sven Kretzschmar
2004-08-09 20:45     ` Problems booting on a Dual-Xeon with 2.4 and 2.6 kernels Sven Kretzschmar
2004-08-09 21:33       ` Christian Limpach
2004-08-09 22:16         ` Sven Kretzschmar
2004-08-10 19:42           ` Christian Limpach
2004-08-10 23:47  3%         ` Problems booting with 3ware Controllers Sven Kretzschmar
2004-08-11  8:51               ` Christian Limpach
2004-08-11 17:40  3%             ` Sven Kretzschmar
2004-08-20 22:21  4% Xen unprivileged domain not booting Will Andrews
2004-08-25 11:49  5% Problems with virtual disks in DomU Stephen Childs
2004-10-17 23:09     problem creating a new domain Sanjay Kumar
2004-10-18 13:20     ` M.A. Williamson
2004-10-19 21:34  5%   ` Sanjay Kumar
2004-10-20 14:54  0%     ` Matthieu PATOU
2004-10-20 19:27  0%       ` Sanjay Kumar
2004-10-20 21:12  0%         ` Matthieu PATOU
2004-11-10  6:44  7% xen2.0 building error yi yang
2004-11-10  7:13  0% ` Niraj Tolia
2004-11-10 11:11  0% ` Steven Hand
2004-11-14 19:53     etherbridge bottleneck Ian Pratt
2004-11-15 16:01  3% ` David Becker
2004-11-25 22:57  5% Virtual ethernet driver Lukasz Grzelak
     [not found]     <E1CXsIv-0003AL-00@mx10.web.de>
2004-11-27 21:31  4% ` Bjoern Sessler
2004-12-02  7:04  5% Kernel panic - not syncing : Question from Xen newbie Mukund Srinivasan
2004-12-02 16:45  6% Revised balloon driver Keir Fraser
2004-12-08 15:45  0% ` Mat
2004-12-09 17:17  5%   ` Keir Fraser
2004-12-10  3:15  0% ` Paul Larson
2004-12-08 23:01  4% Xen 2.0 and VIA Samuel 2 stepping 03 Adam Sulmicki
2004-12-12  5:32  4% Installing Fedora Core 2 inside an unprivileged domain John L Griffin
2004-12-17 22:49  4% Oops on NULL pointer with three disks mapped in to dom1 Ryan Harper
2004-12-18 18:18     Kernel panic - not syncing: Attempted to kill init! Ian Pratt
2004-12-20 16:08  4% ` David F Barrera
2004-12-22 17:51     xen 2.0 testing idle_loop -and -03 Adam Sulmicki
2004-12-22 17:42  5% ` Keir Fraser
2004-12-22 18:25  0%   ` Adam Sulmicki
2004-12-30 15:35  5% can't start domU via NFS Anatoly Asviyan
2005-01-07  5:02  7% [PATCH] arch/xen pudding Rik van Riel
2005-01-07  7:37  5% Cannot start domU from NFS Nauzad Sadry
2005-01-07 10:01     ` Christian Limpach
2005-01-09  0:42  4%   ` Nauzad Sadry
2005-01-11  2:25  0%     ` Nauzad Sadry
2005-01-30 20:43     Xen kernel issue Travis Newman
2005-01-31  1:38     ` Travis Newman
2005-01-31  3:03       ` Mark Williamson
2005-01-31  4:57  7%     ` Travis Newman
2005-01-31  8:00  0% Ian Pratt
2005-02-01 20:30  5% RFC: Creation of virtual bus, hook-up of Xen devices Jeremy Katz
2005-02-08 19:30     [PATCH] netback comment clean-up (trivial) Jon Mason
     [not found]     ` <200502081924.40908.jdmason@us.ibm.com>
2005-02-09  1:58  6%   ` [PATCH 2/2] netfront skb padding Jon Mason
2005-02-09 17:20  4% ` [PATCH 1/2] netfront coding style clean-up (trivial) Jon Mason
2005-02-09  2:12  0% [PATCH 2/2] netfront skb padding Ian Pratt
2005-02-09 17:17  0% ` Jon Mason
2005-02-09  8:43     Balloon driver Jean-Eric Cuendet
2005-02-09 12:53  5% ` Mark Williamson
2005-02-10 22:24  0%   ` Matthieu PATOU
2005-02-13 15:29  0%   ` Jan Kundrát
2005-02-13 15:26  0%     ` Mark Williamson
2005-02-25 18:40  5% DOM0 memory allocation Keir Fraser
2005-02-26 18:47  0% Ian Pratt
2005-03-01 21:51  6% Error compiling balloon.c - nightly testing tarball 1/3/05 Jerome Brown
2005-03-08  9:48 12% compile error "drivers/xen/balloon/ Filip Sergeys
2005-03-08 11:05  5% ` Vincent Hanquez
2005-04-15 21:28  6% [PATCH] Eliminate kernel version checks from i386/kernel/pci-dma.c Chris Wright
2005-04-15 21:30  6% [PATCH] Eliminate kernel version checks from x86_64/kernel/pci-dma.c Chris Wright
2005-05-20 23:30  4% [PATCH] Network Checksum Removal Jon Mason
2005-06-04 22:57 10% PATCH: Full shadow translate mode domUs George Washington Dunlap III
2005-06-06 21:41 11% [PATCH] Full shadow translate mode (round 2) George Washington Dunlap III
2005-06-07 21:02     [patch] predicate NX flag Nakajima, Jun
2005-06-08 18:06     ` [patch] nx bit shouldn't get set when disabled Scott Parish
2005-06-08 19:56       ` Keir Fraser
2005-06-08 19:47         ` Scott Parish
2005-06-08 21:23           ` Keir Fraser
2005-06-09 12:59  3%         ` Scott Parish
2005-06-15 19:14 10% Full translate patch, with grant-table blkif support George Washington Dunlap III
2005-06-16 21:22  7% Balloon driver tests Paul Larson
2005-06-16 22:34  0% ` Kip Macy
2005-07-10 13:00  7% problem to balloon memory beyond initial allocation Xuehai Zhang
2005-07-15 18:26  6% PageReserved ? aq
2005-07-15 18:48     ` Keir Fraser
2005-07-17  7:30  6%   ` aq
2005-07-16  1:30  9% [patch] balloon doc fix aq
2005-07-18  8:45 16% [PATCH] scrub_pages in balloon aq
2005-07-18 10:57     lowest limit for balloon? aq
2005-07-18 12:38  5% ` Keir Fraser
2005-07-18 15:44  0%   ` aq
2005-07-18 15:55  6%   ` Paul Larson
2005-07-29  3:04  8% [PATCH] enforce dom0 cpus and balloon out memory aq
2005-07-29  5:11  8% [PATCH] rename balloon command aq
2005-08-01 17:19 22% [PATCH] Convert balloon driver to xenstore Dan Smith
     [not found]     <260002866C8EBA4EA0AD853F467EC11E04ACDB@EX2.ad.dcs.gla.ac.uk>
2005-08-02 12:48     ` allocate_empty_lowmem_region hypervisor function Mark Williamson
2005-08-02 13:20       ` Ross McIlroy
2005-08-02 13:30         ` Mark Williamson
2005-08-02 15:11 11%       ` [Patch] allocate_empty_lowmem_region in non-privileged domains Ross McIlroy
2005-08-02 15:58  0%         ` Mark Williamson
2005-08-05 17:02  7% Balloon tests Paul Larson
2005-08-05 17:44  6% ` Anthony Liguori
2005-08-05 17:36  5% Ian Pratt
2005-08-05 19:01  0% ` Vincent Hanquez
2005-08-05 19:16  0%   ` Chris Wright
2005-08-05 18:55 15% [PATCH 2/2] Move to new notifier structure Dan Smith
2005-08-05 19:36  6% [RFC] move Xen linux header files Chris Wright
2005-08-05 23:59     ` Dan Magenheimer
2005-08-06  0:09 24%   ` Chris Wright
2005-08-11 22:00  7% [PATCH][VT][4/4] Changing phys_to_machine_mapping[] is not implemented on VMX domains Arun Sharma
2005-08-18 14:50     Re: [Xen-changelog] fail domU creation if memory need couldn't be succeed after ballooning out dom0 Ian Pratt
2005-08-18 15:51  5% ` Anthony Liguori
2005-08-18 16:03  6% Ian Pratt
2005-08-22 10:09 16% [PATCH] Unallocate function for memory regions created by allocate_empty_lowmem_region Ross C Mcilroy
2005-08-22 15:42 16% [PATCH] balloon_dealloc_empty_page_range Ross C Mcilroy
2005-08-23 20:51  4% x86_32 PAE ballooning is busted Jerone Young
2005-08-31 18:52  5% kernel panic doing mem-set Patrick O'Rourke
2005-08-31 22:12  5% questions about mem-max Li Ge
2005-08-31 23:11  0% Ian Pratt
2005-09-08  1:45  6% [RFC] Cleaning up /proc/xen Anthony Liguori
2005-09-08  8:09  0% ` NAHieu
2005-09-08 22:29  0% ` Daniel Stekloff
2005-09-08  2:26  0% Ian Pratt
2005-09-08  2:51  0% ` Steven Hand
2005-09-08  3:24  0%   ` Anthony Liguori
2005-09-19 23:02 14% [PATCH 4/10] (doc) Split user.tex Robb Romans
2005-10-04  4:45 13% [PATCH 2/2] Update kernel watch API to pass the array of watch arguments to the callback instead of just passing the node Anthony Liguori
2005-10-10 10:46 24% unstable: no ballooning Kurt Garloff
2005-10-12 13:06  6% ` Ewan Mellor
2005-10-14  8:40  0%   ` Kurt Garloff
2005-10-15  9:26  0%     ` Ewan Mellor
2005-10-21 11:08 14% [PATCH] kernel /proc information modified for xen mem-set Satoshi Uchida
2005-10-24 17:04  0% ` Vincent Hanquez
2005-10-27 10:29 14% [patch] Lets not put statements with side-effects inside BUG_ON() Arjan van de Ven
2005-10-27 17:49  0% ` Kip Macy
     [not found]     <20051019150719.GC10710@tpkurt.pmc.nue.novell.com>
     [not found]     ` <20051020085107.GA2811@suse.de>
     [not found]       ` <435E56B6.2060707@suse.de>
     [not found]         ` <20051025171505.GG4774@suse.de>
     [not found]           ` <9f07b56a8f036cecd2a0687e040a417b@cl.cam.ac.uk>
     [not found]             ` <4360ABE5.1010705@suse.de>
     [not found]               ` <b943edf9af93016dc65d8090323ed520@cl.cam.ac.uk>
     [not found]                 ` <4360CA79.40605@suse.de>
     [not found]                   ` <efbd0c82d427f99326de12f394c2c90b@cl.cam.ac.uk>
2005-11-09 13:29  3%                 ` [patch] CFQ for xen domains Gerd Knorr
2005-11-15 17:51  3%                   ` Gerd Knorr
2005-11-24 11:31  3%                     ` Gerd Knorr
2005-12-06 15:47  3%                       ` Gerd Knorr
2005-11-10 13:11 15% [PATCH] Abstract writes to phys_to_machine_mapping Jacob Gorm Hansen
     [not found]     <571ACEFD467F7749BC50E0A98C17CDD802C0699C@pdsmsx403>
2005-11-15  2:04  8% ` [Xen-ia64-devel] [Patch] gcc3.4 build patch version2 takebe_akio
2005-11-15  2:14  0% Magenheimer, Dan (HP Labs Fort Collins)
2005-11-16 15:48 29% [PATCH] move /proc/xen to /proc/sys/xen in xen linux Mike D. Day
2005-11-21 13:18  5% [PATCH][2/17] USB virt 2.6 split driver---xenidc buffer resource provider harry
2005-11-21 18:20     Daily Xen Builds David F Barrera
2005-11-21 18:24  6% ` David F Barrera
2005-11-23 16:12  5% [PATCH][2/17] REV 2 USB virt 2.6 split driver---xenidc buffer resource provider harry
2005-11-23 17:05  3% Daily Xen Builds David F Barrera
2005-11-28 20:10  4% David F Barrera
2005-12-07  0:16 16% [PATCH] Arch-neutral balloon driver Magenheimer, Dan (HP Labs Fort Collins)
2005-12-07 21:13  0% ` Hollis Blanchard
2005-12-07  3:35  0% Tian, Kevin
2005-12-07 22:04  2% [PATCH] [XM-TEST] Add support for VMX guests in xm-test Daniel Stekloff
2005-12-07 23:05  0% [PATCH] Arch-neutral balloon driver Magenheimer, Dan (HP Labs Fort Collins)
2005-12-08 14:23 21% Magenheimer, Dan (HP Labs Fort Collins)
2005-12-23 13:05  6% Uses of &frame_table[xfn] Magenheimer, Dan (HP Labs Fort Collins)
2005-12-23 15:27  0% ` Ewan Mellor
2006-01-04 15:21  5% Guest-visible phys2mach part of Xen arch-neutral API? was: " Magenheimer, Dan (HP Labs Fort Collins)
2006-01-04 16:25  0% ` Guest-visible phys2mach part of Xen arch-neutral API? was: [Xen-devel] " Hollis Blanchard
2006-01-30  3:38  4% xm-test status report changset 8602:cfa3b96b056d on IA64 Matsumoto
2006-01-30  4:44  0% ` Matsumoto
2006-02-21 15:56  5% [PATCH] [TPM] Fixes and cleanup Stefan Berger
2006-02-26 22:49     Re: [PATCH] Xen Guest Kexec Ian Pratt
2006-02-27  7:10     ` Keir Fraser
2006-02-27 15:34       ` Gerd Hoffmann
2006-02-27 16:19         ` Keir Fraser
2006-03-01 12:09           ` Gerd Hoffmann
2006-03-01 14:10             ` Gerd Hoffmann
2006-03-01 15:03               ` Keir Fraser
2006-03-01 17:35                 ` Keir Fraser
2006-03-02  9:16                   ` Gerd Hoffmann
2006-03-02  9:43                     ` Keir Fraser
2006-03-02 11:34                       ` Gerd Hoffmann
2006-03-02 11:55                         ` Keir Fraser
2006-03-02 16:36                           ` Gerd Hoffmann
2006-03-02 16:48                             ` Keir Fraser
2006-03-03  8:39                               ` Gerd Hoffmann
2006-03-03  9:14                                 ` Keir Fraser
2006-03-03  9:35                                   ` Keir Fraser
2006-03-06 14:15  5%                                 ` Gerd Hoffmann
2006-03-01 14:51  3% [PATCH] USB split driver Harry Butterworth
2006-03-08  2:59 15% [patch] small fix for memory information Satoshi Uchida
2006-03-09 23:16  6% Grant tables from dom0 userspace? King, Steven R
2006-03-10  0:19 33% [PATCH] clean up parsing of /proc/xen/balloon in xend Charles Coffing
2006-03-10 13:18  5% ` Ewan Mellor
2006-03-10 17:51  3% Daily Xen-HVM Builds: cs9197 Rick Gonzalez
2006-03-10 18:01  4% Daily Xen Builds David F Barrera
2006-03-22  6:30     [RFC PATCH 00/35] Xen i386 paravirtualization support Chris Wright
2006-03-22  6:31  4% ` [RFC PATCH 34/35] Add the Xen virtual network device driver Chris Wright
2006-03-22  8:59  0%   ` Arjan van de Ven
2006-03-30 18:43     xm info showing too much free ram Hans-Christian Armingeon
2006-04-03 16:45  4% ` Keir Fraser
2006-04-03 17:10  0%   ` Ewan Mellor
2006-04-04 10:44  0%     ` Hans-Christian Armingeon
2006-03-30 22:36  6% Growing a para-virtualized domain beyond its initial allocation? John Byrne
2006-03-30 22:45  0% ` Anthony Liguori
2006-03-31 19:26  9% [PATCH] Fix reversed test in balloon.py Charles Coffing
2006-04-10  8:36     [PATCH 4/6] grantable and address conversion patches Isaku Yamahata
2006-04-10 10:24     ` Isaku Yamahata
2006-04-10 10:36       ` Keir Fraser
2006-04-10 12:37         ` Isaku Yamahata
2006-04-10 12:47           ` Keir Fraser
2006-04-12 13:23  4%         ` Isaku Yamahata
2006-04-10 19:59  9% [PATCH] [BUG 143] [2nd try] Fix checksum errors over IPSec ESP tunnels James Dykman
2006-04-14 21:15     [rfc] [patch] 32/64-bit hypercall interface revisited Hollis Blanchard
2006-04-19 18:00     ` Hollis Blanchard
2006-04-24 19:24       ` Hollis Blanchard
2006-04-25  8:01         ` Keir Fraser
2006-04-25 20:24 13%       ` Hollis Blanchard
2006-04-26  7:50             ` Keir Fraser
2006-04-26 21:38  9%           ` Hollis Blanchard
2006-04-26  3:25  7% [PATCH] privcmd_ioctl() clean up for xen/ia64 Isaku Yamahata
2006-04-28  2:52     [PATCH 2/5] [RESEND] changes of common files for xen/ia64 dom0 vp model: privcmd_mmap Isaku Yamahata
2006-04-28 13:43     ` Keir Fraser
2006-04-29  5:51  6%   ` Isaku Yamahata
2006-04-28  6:32 15% [PATCH 1/2] balloon driver: relax BUG_ON() in increasee_reservation() Isaku Yamahata
2006-04-28  6:32 15% [PATCH 2/2] balloon driver: don't use apply_to_page_range for xenLinux/ia64 Isaku Yamahata
2006-04-28  7:00     ` Keir Fraser
2006-04-28  9:14       ` Isaku Yamahata
2006-04-28 13:57         ` Keir Fraser
2006-04-29  4:36 16%       ` Isaku Yamahata
2006-05-01 14:06 12% [PATCH] [XM-TEST] Fix memset tests when backend drivers are compiled into domU kernel James Dykman
2006-05-09  8:49     [RFC PATCH 00/35] Xen i386 paravirtualization support Chris Wright
2006-05-09  7:00  4% ` [RFC PATCH 34/35] Add the Xen virtual network device driver Chris Wright
2006-05-09 20:40  4% [PATCH] use dma_ops in arch/x86_64/kernel/pci-dma-xen.c Langsdorf, Mark
2006-05-16 13:27  4% [PATCH][resubmit] " Langsdorf, Mark
2006-05-17 11:17     PATCH: fix transparent virtualization issue Tristan Gingold
2006-05-17 22:35     ` Keir Fraser
2006-05-18 12:10 13%   ` PATCH: fix transparent virtualization issue (Re) Tristan Gingold
2006-05-18 12:32         ` Keir Fraser
2006-05-19 12:25 13%       ` Tristan Gingold
2006-05-19 16:14  8% [PATCH] Implement a floor for xm mem-set Ky Srinivasan
2006-05-22 14:58     [PATCH] Make "xm mem-set" be lower boundondomX-min-mem Puthiyaparambil, Aravindh
2006-05-22 15:21  8% ` Ky Srinivasan
2006-05-23 17:17  4% [PATCH][resubmit 2] use dma_ops in arch/x86_64/kernel/pci-dma-xen.c Langsdorf, Mark
2006-05-24 10:24     [patch 0/3] a few more cleanups Chris Wright
2006-05-24  7:00 14% ` [patch 1/3] [PATCH] use DEFINE_SPINLOCK in drivers/xen Chris Wright
2006-05-27  5:18 16% [PATCH][BALLOON] Fix minimum target Puthiyaparambil, Aravindh
2006-06-09  5:37  3% [PATCH][BLKTAP] remove blktap Chris Wright
2006-06-09  7:04 10% [PATCH][XENBUS] replace xenbus_transaction_t with an opaque transaction ID Chris Wright
     [not found]     <E1FokBa-0003Mv-TD@xenbits.xensource.com>
2006-06-09 19:03  0% ` [Xen-changelog] [xen-unstable] [LINUX][XENBUS] " Anthony Liguori
2006-06-16  7:50     [PATCH 0/4] Allow compilation without CONFIG_PROC_FS Horms
2006-06-16  7:50 22% ` [PATCH 1/4] balloon: the balloon driver's proc entry needs CONFIG_PROC_FS Horms
2006-06-19 22:15     balloon.py unaware of pages on page_scrub_list Charles Coffing
2006-06-20  7:20     ` Keir Fraser
2006-06-23 18:51  7%   ` Charles Coffing
2006-06-21  9:51  5% [PATCH 1/3] Output Virtual Block Device requests information to /proc/xen/vbd Satoshi Uchida
2006-06-21 14:44 15% PATCH: fix some transparent virtualization issues Tristan Gingold
2006-06-21 19:47  5% [PATCH] Virtual SCSI frontend and backend drivers FUJITA Tomonori
2006-06-22 20:05 11% [PATCH] [XM-TEST] 03_memset_random_pos double console James Dykman
2006-06-23 11:37  6% [PATCH 1/1] Output Virtual Block Device requests information ver. 2. Add information to sysfs Satoshi Uchida
2006-06-23 12:26 15% [PATCH] balloon: don't talk about low/high memory when there is no such distinction Jan Beulich
2006-06-24 14:51     ` Muli Ben-Yehuda
2006-06-24 15:04  5%   ` Anthony Liguori
2006-06-23 12:33 14% [PATCH] balloon: don't fail reservation changes with -ENOMEM Jan Beulich
2006-06-23 20:52  8% [PATCH] [BALLOON] Increase retry_limit (fix for bug #683) Krysan, Susan
2006-06-29 13:44 15% [PATCH] linux: Add fallback when XENMEM_exchange fails to replace contiguous region Jan Beulich
2006-07-08  1:48  2% [PATCH] Blktap update (RFC) Julian Chesterfield
2006-07-11 15:35 20% [PATCH 0/6] xen,xend,tools: NUMA support for Xen Ryan Harper
2006-07-18  9:18     [RFC PATCH 00/33] Xen i386 paravirtualization support Chris Wright
2006-07-18  7:00  4% ` [RFC PATCH 32/33] Add the Xen virtual network device driver Chris Wright
2006-07-18 20:42  5%   ` David Miller
2006-07-18 21:09  5%     ` Chris Wright
2006-08-02  8:32  5% [PATCH 3/6] scsiback driver FUJITA Tomonori
2006-08-08 18:03  4% xen test results on Unisys ES7000 Krysan, Susan
2006-08-14 15:17 13% [patch/rfc] xenbus and driver issues with kexec Gerd Hoffmann
2006-08-17 13:42 15% [patch 2/6] /proc/xen/ballon tweak Gerd Hoffmann
2006-08-18 12:25     [patch 6/6] netif_release_rx_bufs Keir Fraser
2006-08-18 12:41 15% ` Gerd Hoffmann
2006-09-20  0:26 16% [PATCH] Sysfs Interface for balloon driver Satoshi Uchida

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).