OBS User unknown 2007-01-15 23:42:10 +00:00 committed by Git OBS Bridge
commit 27044d0668
97 changed files with 14401 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

575
README.SuSE Normal file
View File

@ -0,0 +1,575 @@
README for the Xen packages
===========================
This file contains SUSE-specific instructions and suggestions for using Xen.
For more in-depth documentation of using Xen on SUSE, consult the
virtualization chapter in the SLES or SUSE Linux manual, or read up-to-date
virtualization information, including a list of known issues, at
http://www.novell.com/documentation/vmserver/.
For more complete documentation on Xen itself, please install one of the
xen-doc-* packages and read the documentation installed into
/usr/share/doc/packages/xen/.
About
-----
Xen allows you to run multiple virtual machines on a single physical machine.
See the Xen homepage for more information:
http://www.cl.cam.ac.uk/Research/SRG/netos/xen/
If you want to use Xen, you need to install the Xen hypervisor and a number of
supporting packages. During the initial SUSE installation (or when installing
from YaST) check-mark the "Xen Virtual Machine Host Server" pattern. If,
instead, you wish to install Xen manually later, install the following packages:
bridge-utils
kernel-xen or kernel-xenpae
python
xen
xen-libs
xen-tools
xen-tools-ioemu (Only required for hardware-assisted virtualization)
xen-doc-* (Optional)
tightvnc (Optional, to view VMs)
yast2-vm (Optional, to facilitate creation and management of VMs)
multipath-tools (Required by yast2-vm, for domUloader)
You then need to reboot your machine. Instead of booting a normal Linux
kernel, you will boot the Xen hypervisor and a slightly changed Linux kernel.
This Linux kernel runs in the first virtual machine and will drive most of your
hardware.
This approach is called para-virtualization, since it is a partial
virtualization (the Linux kernel needs to be changed slightly, to make the
virtualization easier). It results in very good performance (consult
http://www.cl.cam.ac.uk/Research/SRG/netos/xen/performance.html) but has the
downside of unchanged operating systems not being supported. However,
upcoming hardware features (e.g., Intel's VT and AMD's Virtualization) will
help overcome this limitation.
Terminology
-----------
The Xen open-source community has a number of terms that you should be
familiar with.
A "domain" is Xen's term for a virtual machine.
"Domain 0" is the first virtual machine. It can control all other virtual
machines. It also (usually) controls the physical hardware. A kernel used in
domain 0 may sometimes be referred to as a dom0 kernel.
"Domain U" is any virtual machine other than domain 0. The "U" indicates it
is unprivileged (that is, it cannot control other domains). A kernel used in
an unprivileged domain may be referred to as a domU kernel.
Novell documentation will use the more industry-standard term "virtual
machine", or "VM", rather than "domain" where possible. And to that end,
domain 0 will be called the "virtual machine server", since it essentially the
server on which the other VMs run. All other domains are simply "virtual
machines".
The acronym "HVM" refers to a hardware-assisted virtual machine. These are
VMs that have not been modified (e.g., Windows) and therefore need hardware
support such as Intel's VT or AMD's Virtualization to run on Xen.
Kernels
-------
Xen supports two kinds of kernels: A privileged kernel (which boots the
machine, controls other VMs, and usually controls all your physical hardware)
and unprivileged kernels (which can't control other VMs, and usually don't need
drivers for physical hardware). The privileged kernel boots first (as the VM
server); an unprivileged kernel is used in all subsequent VMs.
The VM server takes control of the boot process after Xen has initialized the
CPU and the memory. This VM contains a privileged kernel and all the hardware
drivers.
For the other virtual machines, you usually don't need the hardware drivers.
(It is possible to hide a PCI device from the VM server and re-assign it to
another VM for direct access, but that is a more advanced topic.) Instead you
use virtual network and block device drivers in the unprivileged VMs to access
the physical network and block drivers in the VM server.
For simplicity, SUSE ships a single Xen-enabled Linux kernel, rather than
separate privileged and unprivileged kernels. As most of the hardware drivers
are modules anyway, using this kernel as an unprivileged kernel has very
little extra overhead.
The kernel is contained in the kernel-xen package (or kernel-xenpae for 32 bit
hardware with > 4G of RAM), which you need to install to use Xen.
Booting
-------
If you installed Xen during the initial SUSE installation, or installed one
of the kernel-xen* packages later, a "XEN" option should exist in your Grub
bootloader. Select that to boot SUSE on top of Xen.
If you want to add additional entries, or modify the existing ones, you will
have to edit Grub yourself. All Xen entries in the Grub configuration file
(usually /boot/grub/menu.lst) look something like this:
title XEN
root (hd0,5)
kernel /xen.gz
module /vmlinuz-xen <parameters>
module /initrd-xen
Replace (hd0,5) with the partition that holds your /boot directory in
grub-speak, e.g., hda1 -> (hd0,0) and sda5 -> (hd2,4).
Normally, xen.gz requires no parameters. If you want to add parameters,
see below.
Replace "<parameters>" with the kernel parameters that you want to pass to
your kernel. These should be very similar, if not identical, to those passed
to a normal kernel that you boot on bare iron.
Once you have booted this configuration successfully, you are running Xen with
a privileged kernel on top of it.
Xen Boot Parameters
-------------------
Normally, xen.gz requires no parameters. However, in special cases (such as
debugging or a dedicated VM server) you may wish to pass it parameters.
We have added the following parameters (as compared to upstream Xen):
reboot=option1[,option2,...]
Options are:
warm Reboots will be warm (no memory testing, etc.)
cold Reboots will be cold (with memory testing, etc.)
no No reboots allowed
bios Reboot by calling the BIOS
hard Reboot by toggling RESET and/or crashing the CPU
For a more complete discussion of possible parameters, see the user
documentation in the xen-doc-* packages.
Start Scripts
-------------
Before you can create additional VMs (or use any other xm command) xend must
be running. This init script is part of the xen-tools package, and it is
activated at installation time. You can (de)activate it using insserv (or
chkconfig). You can also start it manually with "rcxend start".
One other relevant startup script is xendomains. This script can be used to
start other VMs when the VM server boots. It also cleanly shuts down the
other VMs when the VM server shuts down. To use this feature, place a
symbolic link in /etc/xen/auto that points to the VM's configuration file.
Look in /etc/sysconfig/xendomains for relevant settings.
Creating a VM with YaST
-----------------------
YaST is the recommended method to create VMs. The YaST module (from the
yast2-vm package) handles creating both the VM's configuration file and
disk(s). YaST can help install any operating system, not just SUSE.
From the command line, run "yast2 xen". From the GUI, start YaST, select
"System", then start "Virtual Machine Management (Xen)". For full
functionality, YaST must run in graphical mode, not ncurses.
The first screen shows all created and running VMs. To create a new one,
click "Add". Now adjust the VM's configuration to your liking.
Xen does not yet properly support removable media in VMs in paravirtual mode,
so installing an operating system from CDs can be difficult. We recommend
using a network installation source, a DVD, or a DVD ISO. CDs do, however,
work as expected in fully-virtual mode.
Note that paravirtualized SUSE Linux will default to using a text-based
installation. To perform a graphical installation, add "vnc=1" to the
"Installation Options" line in YaST. See this page for further guidance on
installing via VNC:
http://www.novell.com/coolsolutions/feature/15568.html
Once you have the VM configured, click "Next". YaST will now create a
configuration file for the VM, and create a disk image. The disk image will
exist in /var/lib/xen/images, and a corresponding config file will exist in
/etc/xen/vm. The operating system's installation program will then run within
the VM.
When the VM shuts down (because the installation -- or at least the first stage
of it -- is done), YaST gives you a chance to finalize the VM's configuration.
This is useful, for example, if the installer and the application that will
run in the VM have different memory or network requirements.
The creation of VMs can be automated with AutoYaST. A single AutoYaST profile
can control the VM's settings (regardless of OS type) and/or the actual
installation of the OS within the VM (for SUSE only). Perhaps the easiest way
to create such a profile is to install a SUSE OS within a VM and "clone" the
operating system in the final stage of the OS installation. Then copy the
resulting file (/root/autoinst.xml) into the VM server's filesystem, into the
directory /var/lib/autoinstall/repository/. Start the AutoYaST tool (YaST >
Miscellaneous > Autoinstall) and then open the profile. Select the "Virtual
Machine Management (Xen)" heading, and add the settings for the VM. Save the
profile. Now the single profile can direct both the configuration of a VM,
and the installation of the OS within the VM.
Creating a VM Manually
----------------------
If you create a VM manually (as opposed to using YaST, which is the recommended
way), you will need to create a disk (or reuse an existing one) and a
configuration file.
Each VM needs to have its own root filesystem. The root filesystem can live on
a block device (e.g., a hard disk partition, or an LVM2 or EVMS volume) or in
a file that holds the filesystem image.
VMs can share filesystems, such as /usr or /opt, that are mounted read-only
from _all_ VMs. Never try to share a filesystem that is mounted read-write;
filesystem corruption will result. For sharing writable data between VMs, use
NFS or other networked or cluster filesystems.
If you are using a disk or disk image that is already installed with an
operating system, you'll probably need to replace its kernel with a Xen-enabled
kernel.
The kernel and ramdisk used to bootstrap the VM must match any kernel modules
that might be present in the VM's disk. It is possible to manually copy the
kernel and ramdisk from the VM's disk (for example, after updating the kernel
within that VM) to the VM server's filesystem. However, an easier (and less
error-prone) method is to use something called the "domUloader". Before a new
VM is started, this loader automatically copies the kernel and ramdisk into
the VM server's filesystem, so that it can be used to bootstrap the new VM.
See /etc/xen/examples/xmexample.domUloader for an example.
Next, make a copy of one of the /etc/xen/examples/* files, and modify it to
suit your needs. For para-virtualized VMs, start with
/etc/xen/examples/xmexample1; for fully-virtualized VMs, start with
/etc/xen/examples/xmexample.hvm. You'll need to change (at very least) the
"name" and "disk" parameters.
When defining the virtual network adapter(s), we recommend using a static MAC
for the VM rather than allowing Xen to randomly select one each time the VM
boots. (See "Network Troubleshooting" below.) XenSource has been allocated a
range of MAC addresses with the OUI of 00-16-3E. By using MACs from this
range you can be sure they will not conflict with any physical adapters.
To get started quickly, you can use a modified rescue image from the Novell
SUSE installation CD/DVD. It's on the first CD/DVD in the boot/ directory with
the name "rescue". To make it usable with Xen, run the script
/usr/share/doc/packages/xen/mk-xen-rescue-img.sh (run it with no arguments to
get help). The script replaces the normal Linux kernel in the image with a
Xen-enabled Linux kernel (among other things; read the script for details).
The script also creates a matching configuration file. The disadvantage of
using the rescue way of constructing a root filesystem is that the result does
not have an RPM database, so you can't easily add packages using rpm. On the
positive side, the result is relatively small yet has most of what's needed to
get started with networking.
Managing Virtual Machines
-------------------------
VMs can be managed from the command line or from YaST.
To create a new VM from the command line, use a command like:
xm create my-vm
If your VM's configuration file is not located in /etc/xen/vm, you must
specify the full path.
Have a look at running sessions with "xm list". Note the ID of the newly
created VM. Attach to that VM with "xm console <ID>" (replacing ID with the
VM's ID). Equivalently, you could have passed "-c" during creation to
immediately connect to the console. Attaching to multiple VM consoles is most
conveniently done with the terminal multiplexer "screen".
Have a look at the other xm commands by typing "xm help". Note that most xm
commands must be done as root.
Using the Mouse via VNC in Fully-Virtual Mode
---------------------------------------------
When accessing a fully-virtualized operating system via VNC, the mouse may be
difficult to control. By default, the VM is emulating a PS/2 mouse. PS/2
provides mouse deltas, but VNC only provides absolute coordinates. The
solution is (when using VNC) to emulate a pointing device that offers absolute
coordinates.
Emulation of a SummaSketch graphics tablet is provided for this reason. To
use the Summa emulation, you will need to configure your fully-virtualized OS.
Note that the virtual tablet is connected to the second virtual serial port
(/dev/ttyS1 or COM2).
Most Linux distributions ship with appropriate drivers, and only need to be
configured. To configure gpm, edit /etc/sysconfig/mouse and add these lines:
MOUSETYPE="summa"
XMOUSETYPE="SUMMA"
DEVICE=/dev/ttyS1
The format and location of your configuration file could vary depending upon
your Linux distribution. The goal is to run the gpm daemon as follows:
gpm -t summa -m /dev/ttyS1
X also needs to be configured to use the Summa emulation. Add the following
stanza to /etc/X11/xorg.conf, or use your distribution's tools to add these
settings:
Section "InputDevice"
Identifier "Mouse0"
Driver "summa"
Option "Device" "/dev/ttyS1"
Option "InputFashion" "Tablet"
Option "Mode" "Absolute"
Option "Name" "EasyPen"
Option "Compatible" "True"
Option "Protocol" "Auto"
Option "SendCoreEvents" "on"
Option "Vendor" "GENIUS"
EndSection
After making these changes, restart gpm and X.
Windows does not ship with a driver for the SummaSketch tablet. You can
obtain an appropriate driver from the device manufacturer's website, or one of
the large Windows driver websites.
HVM Console in Fully-Virtual Mode
---------------------------------
When running a VM in fully-virtual mode, a special console is available that
provides some additional ways to control the VM. Press Ctrl-Alt-2 to access
the console; press Ctrl-Alt-1 to return to the VM.
The two most important commands are "send-key" and "change". The "send-key"
command allows you to send any key sequence to the VM, which might otherwise
be intercepted by your local window manager. The "change" command allows the
target of a block device to be changed; for example, use it to change from one
CD ISO to another. Type "help" for more information.
Networking
----------
Your virtual machines become much more useful if your can reach them via the
network. The default Xen setup creates a virtual bridge (xenbr0) in domain 0
when you start xend. Your eth0 device is enslaved to it. The slave VMs get a
virtual network interface eth0, which is visible to domain 0 as vifN.0 and
connected to the bridge. This means that if you set up an IP address in the
slave VMs belonging to the same subnet as eth0 from your domain 0, you'll be
able to communicate not only with the other slave VMs, but also with domain 0
and with the external network. If you have a DHCP server running in your
network, your slave VMs should succeed in getting an IP address.
Be aware that this may have unwanted security implications. You may want to
opt for routing instead of bridging, so you can set up firewalling rules in
domain 0.
Please read about the network configuration in the Xen manual. You can set up
bridging or routing for other interfaces also.
The network setup is done via the scripts in /etc/xen/scripts. They do not
support ipv6 at this moment, but this is just a limitation of the scripts.
When using SuSEfirewall2 and Xen network bridging, ensure that the Xen
bridges being used (xenbr0, xenbr1, etc.) are listed in
FW_FORWARD_ALWAYS_INOUT_DEV in the SuSEfirewall2 file. The format for
FW_FORWARD_ALWAYS_INOUT_DEV is a list of interfaces separated by a space.
For example, if the Xen bridge xenbr0 is being used, the line should be:
FW_FORWARD_ALWAYS_INOUT_DEV="xenbr0".
If xenbr0 and xenbr1 are being used, the line should be:
FW_FORWARD_ALWAYS_INOUT_DEV="xenbr0 xenbr1".
If you use the rescue images created by the above mentioned script, you'll
have a boot script inside that parses the ip=.... boot parameter. You can set
this parameter in the config file, and can have networking work automatically.
When using bridging, the eth0 in domain 0 device will be renamed to peth0 and
its MAC address will be set to fe:ff:ff:ff:ff:ff and ARP will be disabled.
veth0 will take over the old MAC address, be renamed to eth0, and be enabled
(ifup'ed). vif0.0 and peth0 are then enslaved to xenbr0. veth0 is connected
to vif0.0 behind the scenes.
Caveats:
- rcSuSEfirewall is not currently called from the Xen networking scripts, but
implicitly started by the ifup call; it won't get restarted on starting
additional domains.
This issue may be addressed in a future update.
Configuring network interfaces when using Xen bridging:
Due to the renaming of network interfaces by the network-bridge script
(e.g. eth0 to peth0), network interfaces should not be configured or restarted
while they are enslaved to a Xen bridge. Before configuring a network
interface enslaved to a Xen bridge, shutdown all VMs using the interface.
Then use the network-bridge script to remove the Xen bridge and to restore the
network interface back to normal (put peth0 back to eth0). For example, to
remove the Xen bridge and restore eth0 back to normal do the following:
/etc/xen/scripts/network-bridge stop netdev=eth0
With the Xen bridge removed and eth0 put back to normal, eth0 can then be
configured or restarted. Once the configuration is complete, Xen bridging can
be started back up again (creating the Xen bridge and renaming eth0 to peth0)
by doing the following:
/etc/xen/scripts/network-bridge start netdev=eth0
The VMs can then be started again.
For debugging, here's what happens on bootup of a domU:
- xenstored saves the device setup in xenstore
- domU is created
- vifX.1 shows up in domain 0 and a hotplug event is triggered
- hotplug is /sbin/udev; udev looks at /etc/udev/rules.d/40-xen.rules and
calls /etc/xen/scripts/vif-bridge online
- vif-bridge set the vifX.1 device up and enslaves it to the bridge
- eth0 shows up in domU (hotplug event triggered)
Similar things happen for block devices, except that /etc/xen/scripts/block is
called.
It's not recommended to use ifplugd nor NetworkManager for managing the
interfaces if you use bridging mode. Use routing with nat or proxy-arp
in that case. You also need to do that in case you want to send out packets
on wireless; you can't bridge Xen "ethernet" packets into 802.11 packets.
Thread-Local Storage
--------------------
For some time now, the glibc thread library (NPTL) has used a shortcut to
access thread-local variables at a negative segment offset from the segment
selector GS instead of reading the linear address from the TDB (offset 0).
Unfortunately, this optimization has been made the default by the glibc and
gcc maintainers, as it saves one indirection. For Xen this is bad: The access
to these variables will trap, and Xen will need to use some tricks to make the
access work. It does work, but it's very slow.
SUSE Linux 9.1 and SLES 9 were prior to this change, and thus are not
affected. SUSE Linux 9.2 and 9.3 are affected. For SUSE Linux 10.x and SLES
10, we have disabled negative segment references in gcc and glibc, and so
these are not affected. Other non-SUSE Linux distributions may be affected.
For affected distributions, one way to work around the problem is to rename
the /lib/tls directory, so the pre-i686 version gets used, where no such
tricks are done. An example LSB-compliant init script which automates these
steps is installed at /usr/share/doc/packages/xen/boot.xen. This script
renames /lib/tls when running on Xen, and restores it when not running on Xen.
Modify this script to work with your specific distribution.
Mono has a similar problem, but this has been fixed in SUSE Linux 10.1 and
SLES 10. Older or non-SUSE versions of Mono may have a performance impact.
Security
--------
Domain 0 has control over all domains. This means that care should be taken to
keep domain 0 safe; ideally you strip it down to only do as little there as
possible, preferably with no local users except for the system administrator.
Most commands in domain 0 can only be performed as root, but this protection
scheme only has moderate security and might be defeated. In case domain 0 is
compromised, all other domains are compromised as well.
To allow relocation of VMs (migration), the receiving machine listens on TCP
port 8002. You might want to put firewall rules in place in domain 0 to
restrict this to machines which you trust. You have some access control in
xend-config.sxp as well by tweaking the xend-relocation-hosts-allow
setting. Relocating VMs with sensitive data is not a good idea in untrusted
networks, since the data is not sent encrypted.
The memory protections for the domUs are effective; so far no way to break out
of a virtual machine is known. A VM is an effective jail.
Limitations
-----------
When booting, Linux reserves data structures matching the amount of (virtual)
processors and RAM found. This has the side-effect that you can't dynamically
grow the virtual hardware beyond what the kernel has been booted with. But
you can trick domU Linux to prepare for a larger amount of RAM by passing the
mem= boot parameter.
The export of virtual hard disks from files in Xen is handled via the loopback
driver. You can easily run out of those, as by default only 8 loopback devices
are supported. You can change this by inserting:
options loop max_loop=64
into /etc/modprobe.conf.local in domain 0.
Similarly, the netback driver comes up with 8 virtual network device pairs
(vif0.X - vethX). You can change this by inserting:
options netloop nloopbacks=64
into /etc/modprobe.conf.local in domain 0.
Network Troubleshooting
-----------------------
First ensure the VM server is configured correctly and can access the network.
For starting it's easiest to disable any firewall on the VM server, but enable
IP_FORWARD in /etc/sysconfig/sysctl (/proc/sys/net/ipv4/ip_forward). If you
want to enable SuSEfirewall2 with bridging, add xenbr0 to a device class, set
FW_ROUTE and FW_ALLOW_CLASS_ROUTING. Watch the kernel reject messages ...
Switch off ifplugd and NetworkManager. These can interfere with the changes
xend makes to the network setup.
Specify a static virtual MAC in the VM's configuration file. Random MACs can
be problematic, since with each boot of the VM it appears that some hardware
has been removed (the previous random MAC) and new hardware is present (the
new random MAC). This can cause network configuration files (which were
intended for the old MAC) to not be matched up with the new virtual hardware.
In the VM's filesystem, ensure the ifcfg-eth* files are named appropriately.
For example, if you do decide to use a randomly-selected MAC for the VM, the
ifcfg-eth* file must not include the MAC in its name; name it generically
("ifcfg-eth0") instead. If you use a static virtual MAC for the VM, be sure
that is reflected in the file's name.
Troubleshooting
---------------
First try to get Linux running on bare iron before trying with Xen.
Be sure your Xen hypervisor (xen) and VM kernels (kernel-xen) are compatible.
The hypervisor and domain 0 kernel are a matched set, and usually must be
upgraded together.
If you have trouble early in the boot, try passing pnpacpi=off to the Linux
kernel. If you have trouble with interrupts or timers, passing lapic to Xen
may help. Xen and Linux understand similar ACPI boot parameters. Try the
options acpi=off,force,strict,ht,noirq or acpi_skip_timer_override. Other
useful debugging options to Xen may be nosmp, noreboot, mem=1024M,
sync_console, noirqbalance (Dell). For a complete list of Xen boot options,
consult chapter 10.3 of the Xen users' manual.
If domain 0 Linux crashes on X11 startup, please try to boot into runlevel 3.
To debug Xen or domain 0 Linux crashes or hangs, it may be useful to use the
debug-enabled hypervisor, and to prevent automatic rebooting. Change your
Grub configuration from something like this:
kernel (hd0,5)/xen.gz
To something like this:
kernel (hd0,5)/xen-dbg.gz noreboot
After rebooting, the Xen hypervisor will write any error messages to the log
file (viewable with the "xm dmesg" command).
If problems persist, check if a newer version is available. Well-tested
versions will be shipped with SUSE and via YaST Online Update. More frequent
(but less supported) updates are available on Novell's Forge site:
http://forge.novell.com/modules/xfmod/project/?xenpreview
Known Issues
------------
For a list of known issues and work-arounds, see
http://www.novell.com/documentation/vmserver/.
Disclaimer
----------
Xen performed amazingly well in our tests and proved very stable. Still, you
should be careful when using it, just like you'd be careful if you boot an
experimental kernel. Expect that it may not boot and be prepared to have a
fall-back solution for that scenario. Be prepared that it may not support all
of your hardware. And for the worst of all cases, have your most valuable
data backed up. (This is always a good idea, of course.)
Feedback
--------
In case you have remarks about, problems with, ideas for, or praise for Xen,
please report it back to the xen-devel list:
xen-devel@lists.xensource.com
If you find issues with the packaging or setup done by Novell/SUSE, please
report it to:
http://www.suse.de/feedback/
ENJOY!
Your Novell SUSE Team.

90
block-iscsi Normal file
View File

@ -0,0 +1,90 @@
#!/bin/bash
# Usage: block-iscsi [add tgtname | remove dev]
#
# This assumes you're running a correctly configured
# iscsi target (server) at the other end!
# Note that we assume that the passwords for discovery (if needed)
# are in /etc/iscsid.conf
# and the node session passwords (if required) in the
# open-iscsi database below /var/lib/open-iscsi/node.db
#
# (c) Kurt Garloff <kurt@garloff.de>, 2006-09-04, GNU GPL
dir=$(dirname "$0")
. "$dir/block-common.sh"
#command=$1
#echo "DBG:xen/scripts/block-iscsi $1 $2 XENBUS_PATH=$XENBUS_PATH $par $node"
#write_dev()
#{
# echo "$1"
#}
find_sdev()
{
unset dev
for session in /sys/class/iscsi_session/session*; do
if test $1 = `cat $session/targetname`; then
dev=`readlink $session/device/target*/*:0:*/block*`
dev=${dev##*/}
return
fi
done
}
find_sdev_rev()
{
unset tgt
for session in /sys/class/iscsi_session/session*; do
dev=`readlink $session/device/target*/*:0:*/block*`
dev=${dev##*/}
if test $dev = $1; then
tgt=`cat $session/targetname`
return
fi
done
}
case "$command" in
add)
# load modules and start iscsid
/etc/init.d/open-iscsi status >/dev/null 2>&1 ||
{ /etc/init.d/open-iscsi start >/dev/null 2>&1; sleep 1; }
# list of targets on node
par=`xenstore-read $XENBUS_PATH/params` || true
TGTID=$par; TGTID=${TGTID//@/:}
while read rec port uuid; do
if test $uuid = $TGTID; then
rec=${rec%]}; rec=${rec#[}
find_sdev $TGTID
if test -z "$dev"; then
iscsiadm -m node -r $rec -l || exit 2
usleep 100000
find_sdev $TGTID
fi
xenstore-write $XENBUS_PATH/node /dev/$dev
write_dev /dev/$dev
exit 0
fi
done < <(iscsiadm -m node)
exit 1
;;
remove)
node=`xenstore-read $XENBUS_PATH/node` || true
dev=$node; dev=${dev#/dev/}
find_sdev_rev $dev
#echo $tgt
if test -x /sbin/blockdev -a -n "$node"; then blockdev --flushbufs $node; fi
test -z "$tgt" && exit 2
while read rec port uuid; do
if test $uuid = $tgt; then
rec=${rec%]}; rec=${rec#[}
iscsiadm -m node -r $rec -u
exit 0
fi
done < <(iscsiadm -m node)
exit 1
;;
esac

25
block-losetup-retry.diff Normal file
View File

@ -0,0 +1,25 @@
Index: xen-unstable/tools/examples/block
===================================================================
--- xen-unstable.orig/tools/examples/block
+++ xen-unstable/tools/examples/block
@@ -391,8 +391,18 @@ mount it read-write in a guest domain."
file)
node=$(xenstore_read "$XENBUS_PATH/node")
- losetup -d "$node"
- exit 0
+
+ #In case the loopback is temporarily blocked, retry the losetup -d.
+ for i in 1 2 3 4 5
+ do
+ if losetup -d "$node"
+ then
+ exit 0
+ fi
+ sleep 1
+ done
+ log err "losetup -d $node failed."
+ exit 1
;;
"")

34
block-nbd Normal file
View File

@ -0,0 +1,34 @@
#!/bin/sh
# Usage: block-nbd [bind server ctl_port |unbind node]
#
# The node argument to unbind is the name of the device node we are to
# unbind.
#
# This assumes you're running a correctly configured server at the other end!
dir=$(dirname "$0")
. "$dir/block-common.sh"
#set -x
par=`xenstore-read $XENBUS_PATH/params` || true
echo $par
case "$command" in
add)
modprobe nbd
for dev in /dev/nbd*; do
if nbd-client $par $dev; then
xenstore-write $XENBUS_PATH/node $dev
write_dev $dev
exit 0
fi
done
exit 1
;;
remove)
node=`xenstore-read $XENBUS_PATH/node` || true
nbd-client -d $node
exit 0
;;
esac

42
block-sync.diff Normal file
View File

@ -0,0 +1,42 @@
Index: xen-unstable/tools/examples/block
===================================================================
--- xen-unstable.orig/tools/examples/block
+++ xen-unstable/tools/examples/block
@@ -42,6 +42,20 @@ canonicalise_mode()
fi
}
+##
+# sync_flags mode
+#
+sync_flags()
+{
+ local mode="$1"
+ if expr index "$mode" 'S' >/dev/null
+ then
+ echo "-y"
+ else
+ echo ""
+ fi
+}
+
##
# check_sharing device mode
@@ -262,6 +276,7 @@ case "$command" in
# Canonicalise the file, for sharing check comparison, and the mode
# for ease of use here.
file=$(readlink -f "$p") || fatal "$p does not exist."
+ sync=$(sync_flags "$mode")
mode=$(canonicalise_mode "$mode")
claim_lock "block"
@@ -367,7 +382,7 @@ mount it read-write in a guest domain."
fatal 'Failed to find an unused loop device'
fi
- do_or_die losetup "$loopdev" "$file"
+ do_or_die losetup $sync "$loopdev" "$file"
xenstore_write "$XENBUS_PATH/node" "$loopdev"
write_dev "$loopdev"
release_lock "block"

79
boot.local.xenU Normal file
View File

@ -0,0 +1,79 @@
#! /bin/sh
#
# Copyright (c) 1996 SuSE GmbH Nuernberg, Germany. All rights reserved.
#
# Author: Werner Fink <werner@suse.de>, 1996
# Burchard Steinbild <bs@suse.de>, 1996
#
# /etc/init.d/boot.local
#
# script with local commands to be executed from init on system startup
#
#
# Here you should add things, that should happen directly after booting
# before we're going to the first run level.
#
date
# echo "$MACHINE: running $0 $*"
my_REDIRECT="$(echo $REDIRECT | sed 's#^/dev/##')"
my_DEVICE="$(echo $my_REDIRECT | sed 's#^tty##')"
my_SPEED="$(stty speed)"
# echo REDIRECT $REDIRECT $my_REDIRECT
# echo my_DEVICE $my_DEVICE
# echo my_SPEED $my_SPEED
# compose a line like that for inittab
# S0:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt102
case $my_REDIRECT in
ttyS*)
echo adding this line to inittab
echo "$my_DEVICE:12345:respawn:/sbin/agetty -L $my_SPEED $my_REDIRECT vt102"
echo "$my_DEVICE:12345:respawn:/sbin/agetty -L $my_SPEED $my_REDIRECT vt102" >> /etc/inittab
echo $my_REDIRECT >> /etc/securetty
;;
hvc*)
echo adding this line to inittab
echo "$my_DEVICE:12345:respawn:/sbin/agetty -L $my_SPEED $my_REDIRECT vt320"
echo "$my_DEVICE:12345:respawn:/sbin/agetty -L $my_SPEED $my_REDIRECT vt320" >> /etc/inittab
echo $my_REDIRECT >> /etc/securetty
;;
*)
echo "no modification in inittab needed for: $my_REDIRECT"
;;
esac
telinit q
# Changes for Xen
test -f /lib/modules/`uname -r`/modules.dep || depmod -ae
CMDLINE=`cat /proc/cmdline | grep 'ip='`
if test ! -z "$CMDLINE"; then
OLDIFS=$IFS
IFS=":"
read ip oth mask gw hostname dev dhcp rest < /proc/cmdline
IFS=$OLDIFS
hostname $hostname
ip=`echo $ip | sed 's/ip= *//'`
if test ! -z "$ip"; then
if test -z "$mask"; then
if [ ${ip%/*} = $ip ]; then
ip="$ip/27"
fi
echo "ip addr add $ip dev $dev"
ip addr add $ip dev $dev
ip link set $dev up
else
ifconfig add $ip netmask $mask $dev
fi
fi
if test "${dhcp#dhcp}" != "$dhcp"; then
ifup-dhcp $dev
fi
fi

101
boot.xen Normal file
View File

@ -0,0 +1,101 @@
#! /bin/sh
# Copyright (c) 2005-2006 SUSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# /etc/init.d/boot.xen
#
# LSB compatible service control script; see http://www.linuxbase.org/spec/
#
### BEGIN INIT INFO
# Provides: Xen
# Required-Start: boot.localfs
# Should-Start: boot.localnet
# Required-Stop: boot.localfs
# Should-Stop:
# Default-Start: B
# Default-Stop:
# Short-Description: Switch on and off TLS depending on whether Xen is running
# Description: Xen gets a major performance hit by the way
# recent glibc (& gcc) set up the TLS offset, as it needs to
# play segmentation tricks. This can be avoided by moving away
# the tls libs.
### END INIT INFO
. /etc/rc.status
# Reset status of this service
rc_reset
case "$1" in
start)
echo -n "Starting Xen setup "
if test -d /proc/xen; then
export LD_ASSUME_KERNEL=2.4.21
echo -n "Xen running "
fi
if test -d /proc/xen -a -d /lib/tls; then
echo -n "move /lib/tls away "
mv /lib/tls /lib/tls.save
elif test ! -d /proc/xen -a -d /lib/tls.save; then
echo -n "move back /lib/tls "
mv /lib/tls.save /lib/tls
fi
rc_status -v
;;
stop)
# rc_status -v
;;
try-restart|condrestart)
$0 restart
# Remember status and be quiet
rc_status
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 start
# Remember status and be quiet
rc_status
;;
force-reload)
$0 try-restart
rc_status
;;
reload)
rc_failed 3
rc_status -v
;;
status)
echo -n "Checking for Xen "
# Return value is slightly different for the status command:
# 0 - service up and running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running (unused)
# 4 - service status unknown :-(
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
if test -d /proc/xen; then
if test -d /lib/tls; then
echo -n "Xen running, /lib/tls existing "
rc_failed 1
else
echo -n "Xen running, /lib/tls not existing "
fi
else
if test -d /lib/tls.save; then
echo -n "Xen not running, /lib/tls existing "
rc_failed 2
else
echo -n "Xen not running, /lib/tls not existing "
rc_failed 3
fi
fi
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
exit 1
;;
esac
rc_exit

521
domUloader.py Normal file
View File

@ -0,0 +1,521 @@
#!/usr/bin/env python
# domUloader.py
"""Loader for kernel and (optional) ramdisk from domU filesystem
Uses bootentry = [dev:]kernel[,initrd] to get a kernel [and initrd]
from a domU filesystem to boot it for Xen.
dev is the disk as seen by domU, filenames are relative to
that filesystem. The script uses the disk settings from the
config file to find the domU filesystems.
The bootentry is passed to the script using --entry=
Optionally, dev: can be omitted; the script then looks at the
root filesystem, parses /etc/fstab to resolve the path to the
kernel [and the initrd]. Obviously, the paths relative to the
domU root filesystem needs to be specified for the kernel
and initrd filenames.
The root FS is passed using --root=, the filesystem setup in
--disks=. The disks list is a python list
[[uname, dev, mode, backend], [uname, dev, mode, backend], ...]
passed as a string. The script writes an sxpr specifying the
locations of the copied kernel and initrd into the file
specified by --output (default is stdout).
Limitations:
- It is assumed both kernel and initrd are on the same filesystem.
- domUs might use LVM; the script currently does not have support
for setting up LVM mappings for domUs; it's not trivial and we
might risk namespace conflicts. If you want to use LVM inside domUs,
set up a small non-LVM boot partition and specify it in bootentry.
The script uses kpartx (multipath-tools) to create mappings for
devices that are exported as whole disk devices that are partitioned.
(c) 01/2006 Novell Inc
License: GNU GPL
Author: Kurt Garloff <garloff@suse.de>
"""
import os, sys, getopt
from stat import *
from xen.xend import sxp
import tempfile
import time
# Global options
quiet = False
dryrun = False
verbose = False
tmpdir = '/var/lib/xen/tmp'
# List of partitions
# It's created by setting up the all the devices from the xen disk
# config; every entry creates on Wholedisk object, which does necessary
# preparatory steps such as losetup and kpartx -a; then a Partition
# object is setup for every partition (which may be one or several per
# Wholedisk); it references the Wholedisk if needed; python reference
# counting will take care of the cleanup.
partitions = []
# Helper functions
def traildigits(strg):
"Return the trailing digits, used to split the partition number off"
idx = len(strg)-1
while strg[idx].isdigit():
if len == 0:
return strg
idx -= 1
return strg[idx+1:]
def isWholedisk(domUname):
"Determines whether dev is a wholedisk dev"
return not domUname[-1:].isdigit()
def findPart(dev):
"Find device dev in list of partitions"
if len(dev) > 5 and dev[:5] == "/dev/":
dev = dev[5:]
for part in partitions:
if dev == part.domname:
return part
return None
class Wholedisk:
"Class representing a whole disk that has partitions"
def __init__(self, domname, physdev, loopfile = None):
"c'tor: set up"
self.domname = domname
self.physdev = physdev
self.loopfile = loopfile
self.mapped = 0
self.pcount = self.scanpartitions()
def loopsetup(self):
"Setup the loop mapping"
if self.loopfile and not self.physdev:
# Loops through all loopback devices, attempting to
# find a free one to set up. Don't scan for free and
# then try to set it up as a separate step - too racy!
i = 0
while True:
ldev = '/dev/loop%i' % (i)
if not os.path.exists(ldev):
break
i += 1
fd = os.popen("losetup %s %s 2> /dev/null" % (ldev, self.loopfile))
if not fd.close():
if verbose:
print "domUloader: losetup %s %s" % (ldev, self.loopfile)
self.physdev = ldev
break
if not self.physdev:
raise RuntimeError("domUloader: No free loop device found")
def loopclean(self):
"Delete the loop mapping"
if self.loopfile and self.physdev:
if verbose:
print "domUloader: losetup -d %s" % self.physdev
# Even seemingly innocent queries like "losetup /dev/loop0"
# can temporarily block the loopback and cause transient
# failures deleting the loopback, hence the retry logic.
retries = 10
while retries:
fd = os.popen("losetup -d %s" % self.physdev)
if not fd.close():
self.physdev = None
break
else:
time.sleep(0.1)
retries -= 1
def scanpartitions(self):
"""Scan device for partitions (kpartx -l) and set up data structures,
Returns number of partitions found."""
self.loopsetup()
# TODO: We could use fdisk -l instead and look at the type of
# partitions; this way we could also detect LVM and support it.
fd = os.popen("kpartx -l %s" % self.physdev)
pcount = 0
for line in fd.readlines():
line = line.strip()
(pname, params) = line.split(':')
pno = int(traildigits(pname.strip()))
#if pname.rfind('/') != -1:
# pname = pname[pname.rfind('/')+1:]
#pname = self.physdev[:self.physdev.rfind('/')] + '/' + pname
pname = "/dev/mapper/" + pname
partitions.append(Partition(self, self.domname + '%i' % pno, pname))
pcount += 1
fd.close()
if not pcount:
if self.loopfile:
ref = self
else:
ref = None
partitions.append(Partition(ref, self.domname, self.physdev))
return pcount
def activatepartitions(self):
"Set up loop mapping and device-mapper mappings"
if not self.mapped:
self.loopsetup()
if self.pcount:
if verbose:
print "domUloader: kpartx -a %s" % self.physdev
fd = os.popen("kpartx -a %s" % self.physdev)
fd.close()
self.mapped += 1
def deactivatepartitions(self):
"Remove device-mapper mappings and loop mapping"
if not self.mapped:
return
self.mapped -= 1
if not self.mapped:
if self.pcount:
if verbose:
print "domUloader: kpartx -d %s" % self.physdev
fd = os.popen("kpartx -d %s" % self.physdev)
fd.close()
self.loopclean()
def __del__(self):
"d'tor: clean up"
self.deactivatepartitions()
self.loopclean()
def __repr__(self):
"string representation for debugging"
strg = "[" + self.domname + ","
if self.physdev:
strg += self.physdev
strg += ","
if self.loopfile:
strg += self.loopfile
strg += "," + str(self.pcount) + ",mapped %ix]" % self.mapped
return strg
class Partition:
"""Class representing a domU filesystem (partition) that can be
mounted in dom0"""
def __init__(self, whole = None, domname = None,
physdev = None):
"c'tor: setup"
self.wholedisk = whole
self.domname = domname
self.physdev = physdev
self.mountpoint = None
def __del__(self):
"d'tor: cleanup"
if self.mountpoint:
self.umount()
# Not needed: Refcounting will take care of it.
#if self.wholedisk:
# self.wholedisk.deactivatepartitions()
def __repr__(self):
"string representation for debugging"
strg = "[" + self.domname + "," + self.physdev + ","
if self.mountpoint:
strg += "mounted on " + self.mountpoint + ","
else:
strg += "not mounted,"
if self.wholedisk:
return strg + self.wholedisk.__repr__() + "]"
else:
return strg + "]"
def mount(self, fstype = None, options = "ro"):
"mount filesystem, sets self.mountpoint"
if self.mountpoint:
return
if self.wholedisk:
self.wholedisk.activatepartitions()
mtpt = tempfile.mkdtemp(prefix = "%s." % self.domname, dir = tmpdir)
mopts = ""
if fstype:
mopts += " -t %s" % fstype
mopts += " -o %s" % options
if verbose:
print "domUloader: mount %s %s %s" % (mopts, self.physdev, mtpt)
fd = os.popen("mount %s %s %s" % (mopts, self.physdev, mtpt))
err = fd.close()
if err:
raise RuntimeError("domUloader: Error %i from mount %s %s on %s" % \
(err, mopts, self.physdev, mtpt))
self.mountpoint = mtpt
def umount(self):
"umount filesystem at self.mountpoint"
if not self.mountpoint:
return
if verbose:
print "domUloader: umount %s" % self.mountpoint
fd = os.popen("umount %s" % self.mountpoint)
err = fd.close()
os.rmdir(self.mountpoint)
if err:
raise RuntimeError("domUloader: Error %i from umount %s" % \
(err, self.mountpoint))
self.mountpoint = None
if self.wholedisk:
self.wholedisk.deactivatepartitions()
def setupOneDisk(cfg):
"""Sets up one exported disk (incl. partitions if existing)
@param cfg: 4-tuple (uname, dev, mode, backend)"""
from xen.util.blkif import blkdev_uname_to_file
values = cfg[0].split(':')
if len(values) == 2:
(type, dev) = values
else:
(type, subtype, dev) = values
(loopfile, physdev) = (None, None)
if type == "tap":
if subtype == "aio":
# FIXME: if device, "/dev/" may need to be prepended
mode = os.stat(dev)[ST_MODE]
if S_ISBLK(mode):
physdev = dev
else:
loopfile = dev
else:
raise RuntimeError("domUloader: domUloader supports 'tap' only with 'aio'.")
if type == "file":
loopfile = dev
elif type == "phy":
physdev = blkdev_uname_to_file(cfg[0])
wdisk = Wholedisk(cfg[1], physdev, loopfile)
def setupDisks(vbds):
"""Create a list of all disks from the disk config:
@param vbds: The disk config as list of 4-tuples
(uname, dev, mode, backend)"""
disks = eval(vbds)
for disk in disks:
setupOneDisk(disk)
if verbose:
print "Partitions: " + str(partitions)
class Fstab:
"Class representing an fstab"
class FstabEntry:
"Class representing one fstab line"
def __init__(self, line):
"c'tor: parses one line"
spline = line.split()
self.dev, self.mtpt, self.fstype, self.opts = \
spline[0], spline[1], spline[2], spline[3]
if len(self.mtpt) > 1:
self.mtpt = self.mtpt.rstrip('/')
def __init__(self, filename):
"c'tor: parses fstab"
self.entries = []
fd = open(filename)
for line in fd.readlines():
line = line.strip()
if len(line) == 0 or line[0] == '#':
continue
self.entries.append(Fstab.FstabEntry(line))
def find(self, fname):
"Looks for matching filesystem in fstab"
matchlen = 0
match = None
fnmlst = fname.split('/')
for fs in self.entries:
entlst = fs.mtpt.split('/')
# '/' needs special treatment :-(
if entlst == ['','']:
entlst = ['']
entln = len(entlst)
if len(fnmlst) >= entln and fnmlst[:entln] == entlst \
and entln > matchlen:
match = fs
matchlen = entln
if not match:
return (None, None)
return (match.dev, match.mtpt)
def fsFromFstab(kernel, initrd, root):
"""Investigate rootFS fstab, check for filesystem that contains the kernel
and return it; also returns adapted kernel and initrd path.
"""
part = findPart(root)
if not part:
raise RuntimeError("domUloader: Root fs %s not exported?" % root)
part.mount()
if not os.access(part.mountpoint + '/etc/fstab', os.R_OK):
part.umount()
raise RuntimeError("domUloader: /etc/fstab not found on %s" % root)
fstab = Fstab(part.mountpoint + '/etc/fstab')
(dev, fs) = fstab.find(kernel)
if not fs:
raise RuntimeError("domUloader: no matching filesystem for image %s found in fstab" % kernel)
#return (None, kernel, initrd)
if fs == '/':
ln = 0
# this avoids the stupid /dev/root problem
dev = root
else:
ln = len(fs)
kernel = kernel[ln:]
if initrd:
initrd = initrd[ln:]
if verbose:
print "fsFromFstab: %s %s -- %s,%s" % (dev, fs, kernel, initrd)
return (kernel, initrd, dev)
def parseEntry(entry):
"disects bootentry and returns kernel, initrd, filesys"
fs = None
initrd = None
fsspl = entry.split(':')
if len(fsspl) > 1:
fs = fsspl[0]
entry = fsspl[1]
enspl = entry.split(',')
# Prepend '/' if missing
kernel = enspl[0]
if kernel[0] != '/':
kernel = '/' + kernel
if len(enspl) > 1:
initrd = enspl[1]
if initrd[0] != '/':
initrd = '/' + initrd
return kernel, initrd, fs
def copyFile(src, dst):
"Wrapper for shutil.filecopy"
import shutil
if verbose:
print "domUloader: cp %s %s" % (src, dst)
stat = os.stat(src)
if stat.st_size > 16*1024*1024:
raise RuntimeError("domUloader: Too large file %s (%s larger than 16MB)" \
% (src, stat.st_size))
try:
shutil.copyfile(src, dst)
except:
os.unlink(dst)
raise()
def copyKernelAndInitrd(fs, kernel, initrd):
"""Finds fs in list of partitions, mounts the partition, copies
kernel [and initrd] off to dom0 files, umounts the parition again,
and returns sxpr pointing to these copies."""
if dryrun:
return "linux (kernel vmlinuz.dummy) (ramdisk initrd.dummy)"
import shutil
part = findPart(fs)
if not part:
raise RuntimeError("domUloader: Filesystem %s not exported\n" % fs)
part.mount()
try:
(fd, knm) = tempfile.mkstemp(prefix = "vmlinuz.", dir = tmpdir)
os.close(fd)
copyFile(part.mountpoint + kernel, knm)
except:
os.unlink(knm)
raise
if not quiet:
print "Copy kernel %s from %s to %s for booting" % \
(kernel, fs, knm)
sxpr = "linux (kernel %s)" % knm
if (initrd):
try:
(fd, inm) = tempfile.mkstemp(prefix = "initrd.", dir = tmpdir)
os.close(fd)
copyFile(part.mountpoint + initrd, inm)
except:
os.unlink(knm)
os.unlink(inm)
raise
sxpr += "(ramdisk %s)" % inm
part.umount()
return sxpr
def main(argv):
"Main routine: Parses options etc."
global quiet, dryrun, verbose, tmpdir
def usage():
"Help output (usage info)"
global verbose, quiet, dryrun
print >> sys.stderr, "domUloader usage: domUloader --disks=disklist [--root=rootFS]\n" \
+ " --entry=kernel[,initrd] [--output=fd] [--quiet] [--dryrun] [--verbose] [--help]\n"
print >> sys.stderr, __doc__
#print "domUloader " + str(argv)
try:
(optlist, args) = getopt.gnu_getopt(argv, 'qvh', \
('disks=', 'root=', 'entry=', 'output=',
'tmpdir=', 'help', 'quiet', 'dryrun', 'verbose'))
except:
usage()
sys.exit(1)
entry = None
output = None
root = None
disks = None
for (opt, oarg) in optlist:
if opt in ('-h', '--help'):
usage()
sys.exit(0)
elif opt in ('-q', '--quiet'):
quiet = True
elif opt in ('-n', '--dryrun'):
dryrun = True
elif opt in ('-v', '--verbose'):
verbose = True
elif opt == '--root':
root = oarg
elif opt == '--output':
output = oarg
elif opt == '--disks':
disks = oarg
elif opt == '--entry':
entry = oarg
elif opt == '--tmpdir':
tmpdir = oarg
if not entry or not disks:
usage()
sys.exit(1)
if output is None or output == "-":
fd = sys.stdout.fileno()
else:
fd = os.open(output, os.O_WRONLY)
if not os.access(tmpdir, os.X_OK):
os.mkdir(tmpdir)
os.chmod(tmpdir, 0750)
# We assume kernel and initrd are on the same FS,
# so only one fs
kernel, initrd, fs = parseEntry(entry)
setupDisks(disks)
if not fs:
if not root:
usage()
raise RuntimeError("domUloader: No root= to parse fstab and no disk in bootentry")
sys.exit(1)
kernel, initrd, fs = fsFromFstab(kernel, initrd, root)
sxpr = copyKernelAndInitrd(fs, kernel, initrd)
sys.stdout.flush()
os.write(fd, sxpr)
# Call main if called (and not imported)
if __name__ == "__main__":
main(sys.argv)

151
init.xend Normal file
View File

@ -0,0 +1,151 @@
#!/bin/bash
#
# xend Starts and stops the Xen control daemon
#
# chkconfig: 35 98 01
# description: Starts and stops the Xen control daemon
#
### BEGIN INIT INFO
# Provides: xend
# Required-Start: $syslog
# Should-Start: $time $network $remote_fs
# Required-Stop: $syslog
# Should-Stop: $time $network $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Short-Description: Starts and stops the Xen control daemon
# Description: Starts and stops the Xen control daemon. xend is needed
# to use Xen.
### END INIT INFO
await_daemons_up()
{
i=1
rets=10
xend status
while [ $? -ne 0 -a $i -lt $rets ]; do
sleep 1
echo -n .
i=$(($i + 1))
xend status
done
}
. /etc/rc.status
rc_reset
xend_abort()
{
echo -n "xend "
rc_failed $1
rc_status -v
rc_exit
}
cleanup()
{
rm -f /var/lib/xen/tmp/* 2>/dev/null
rm -f /var/lib/xen/xenbl* 2>/dev/null
}
if [ "$1" == status ]; then
if [ ! -e /proc/xen/capabilities ]; then
xend_abort 3
fi
else
if [ `id -u` != 0 ]; then
xend_abort 4
fi
if [ ! -e /proc/xen/capabilities ] ||
! grep control_d /proc/xen/capabilities >/dev/null 2>&1; then
if [ "$1" == stop ] ||
[ "$1" == try-restart ]; then
xend_abort 0
else
xend_abort 6
fi
fi
fi
XEND=`ps ax | grep xend | grep python | awk '{ print $1 }'`
XEND=`echo $XEND`
#export PYTHONOPTIMIZE=2
case "$1" in
start)
echo -n "Starting xend "
if [ ! -z "$XEND" ]; then
echo -n "(already running pid $XEND) "
else
cleanup
fi
# Load XEN backend modules
# Sidenote: They could be loaded later:
# - netloop at network-bridge init time
# - netbk and blkbk when the dom0 hotplug events occur
# (in xen-network-common.sh and block-common.sh)
# but for now it's safest to have them loaded when xend starts in dom0.
modprobe blktap 2>/dev/null || true
modprobe blkbk 2>/dev/null || true
modprobe netloop 2>/dev/null || true
modprobe netbk 2>/dev/null || true
xend start
await_daemons_up
;;
stop)
echo -n "Stopping xend "
if [ -z "$XEND" ]; then
echo -n "(not running) "
xend stop
rc_reset
else
echo -n "(pid $XEND) "
unset sysrq_sent
while read nm id mem vcpu state time; do
if [ $id = 0 ]; then continue; fi
sysrq_sent=1
echo -en "\n Warning: Domain $nm (ID $id) still up ($state)"
# Domains should be closed down by xendomains; anyway, send
# SysRq-S to avoid the worst in case domains are not shut down.
xm sysrq $id s
done < <(xm list | grep -v ^Name)
if [ -n "$sysrq_sent" ]; then sleep 1; fi
xend stop
cleanup
rc_reset
fi
;;
status)
echo -n "Checking status of xend "
if [ ! -z "$XEND" ]; then
echo -n "(pid $XEND) "
fi
xend status
;;
restart|reload)
echo -n "Restarting xend "
if [ -z "$XEND" ]; then
echo -n "(not running) "
else
echo -n "(old pid $XEND) "
fi
xend restart
await_daemons_up
;;
try-restart)
$0 status
if [ $? = 0 ]; then
$0 restart
else
rc_reset
fi
;;
*)
echo "Usage: $0 {start|stop|restart|try-restart|reload|status}"
rc_failed 2
rc_exit
esac
#unset PYTHONOPTIMIZE
rc_status -v
rc_exit

463
init.xendomains Normal file
View File

@ -0,0 +1,463 @@
#!/bin/bash
#
# xendomains Starts and stops secondary Xen domains
#
# chkconfig: 35 99 00
# description: Starts and stops secondary Xen domains
#
### BEGIN INIT INFO
# Provides: xendomains
# Required-Start: $syslog $remote_fs xend
# Should-Start:
# Required-Stop: $syslog $remote_fs xend
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Short-Description: Starts and stops secondary Xen domains
# Description: Starts and stops secondary Xen domains automatically
# when domain 0 starts and stops.
### END INIT INFO
# FIXME: Watch out for domain names with invalid characters.
. /etc/rc.status
rc_reset
LOCKFILE=/var/lock/subsys/xendomains
XENDOM_CONFIG=/etc/sysconfig/xendomains
RETCODE_FILE=/var/lock/subsys/xendomains.rc.$$
shopt -s dotglob nullglob
smart_term=1
if [ -z "$esc" ]; then
smart_term=0
rc_timer_on()
{
(trap "exit 0" TERM; sleep $1) & _rc_timer_pid=$!
}
rc_timer_off()
{
if [ -n "$_rc_timer_pid" ]; then
kill -TERM $_rc_timer_pid > /dev/null 2>&1
fi
unset _rc_timer_pid
}
fi
xendomains_abort()
{
echo -n "xendomains "
rc_failed $1
rc_status -v
rc_exit
}
if [ "$1" = status ]; then
if [ ! -e /proc/xen/privcmd ]; then
xendomains_abort 3
fi
if [ ! -r "$XENDOM_CONFIG" ]; then
xendomains_abort 3
fi
else
if [ `id -u` != 0 ]; then
xendomains_abort 4
fi
if [ ! -e /proc/xen/privcmd ]; then
if [ "$1" = stop ] ||
[ "$1" = restart ]; then
xendomains_abort 0
else
xendomains_abort 6
fi
fi
if [ ! -r "$XENDOM_CONFIG" ]; then
xendomains_abort 6
fi
fi
. "$XENDOM_CONFIG"
dir_contains_something()
{
[ -d "$1" ] || return 1
local dirfiles=( "$1"/* )
[ ${#dirfiles[@]} != 0 ]
}
get_name_from_cfg()
{
NM=`grep '^name[ ]*=' $1 | sed -e 's/^name[ ]*=[ ]*['\''"]\([^'\''"]*\)['\''"].*$/\1/'`
}
running_auto_names()
{
unset AUTONAMES[@]
if ! dir_contains_something "$XENDOMAINS_AUTO"; then
return
fi
for dom in "$XENDOMAINS_AUTO"/*; do
get_name_from_cfg "$dom"
AUTONAMES+=("$NM")
done
}
parseln()
{
name=`echo "$1" | cut -c0-49`
name=${name%% *}
rest=`echo "$1" | cut -c40- `
read id mem vcpu state tm < <(echo "$rest")
}
is_cfg_running()
{
get_name_from_cfg "$1"
while read LN; do
parseln "$LN"
[ $id = 0 ] && continue
[ "$name" = "$NM" ] && return 0
done < <(xm list | grep -v '^Name')
return 1
}
start()
{
if [ -f "$LOCKFILE" ]; then
echo -n "xendomains already running (lockfile exists)"
rc_reset
rc_status -v
return 0
fi
local printed=0
if [ "$XENDOMAINS_RESTORE" = "true" ] &&
dir_contains_something "$XENDOMAINS_SAVE"; then
mkdir -p $(dirname "$LOCKFILE")
touch "$LOCKFILE"
echo "Restoring saved Xen domains"
printed=1
for dom in "$XENDOMAINS_SAVE"/*; do
echo -n " ${dom##*/}: "
xm restore "$dom" >/dev/null 2>&1
if [ $? -ne 0 ]; then
rc_failed
else
rc_reset
rm -f "$dom"
fi
rc_status -v
done
fi
if dir_contains_something "$XENDOMAINS_AUTO"; then
touch "$LOCKFILE"
echo "Starting auto Xen domains"
printed=1
for dom in "$XENDOMAINS_AUTO"/*; do
echo -n " ${dom##*/}: "
if is_cfg_running "$dom"; then
rc_status -s
else
xm create --quiet --defconfig "$dom"
if [ $? -ne 0 ]; then
rc_failed
else
usleep $XENDOMAINS_CREATE_USLEEP
rc_reset
fi
rc_status -v
fi
done
fi
if [ $printed -eq 0 ]; then
echo -n "Starting xendomains"
rc_failed 6 # not configured
rc_status -v
fi
}
is_zombie_state()
{
[ "$1" = "-b---d" ] || [ "$1" = "-----d" ]
}
any_non_zombies()
{
while read LN; do
parseln "$LN"
[ $id = 0 ] && continue
is_zombie_state "$state" || return 0
done < <(xm list | grep -v '^Name')
return 1
}
migrate_with_watchdog()
{
(xm migrate "$@" ; echo $? > "$RETCODE_FILE") >/dev/null 2>&1 &
watchdog_xm $!
}
save_with_watchdog()
{
(xm save "$@" ; echo $? > "$RETCODE_FILE") >/dev/null 2>&1 &
watchdog_xm $!
}
shutdown_with_watchdog()
{
(xm shutdown -w "$@" ; echo $? > "$RETCODE_FILE") >/dev/null 2>&1 &
watchdog_xm $!
}
get_return_code()
{
local RC=127
[ -r "$RETCODE_FILE" ] && RC=`head -c10 "$RETCODE_FILE"`
rm -f "$RETCODE_FILE"
return $RC
}
# $1: The PID to wait on.
watchdog_xm()
{
local col=$((COLUMNS-11))
if [ -z "$XENDOMAINS_STOP_MAXWAIT" ] || [ "$XENDOMAINS_STOP_MAXWAIT" = "0" ]; then
wait $1 >/dev/null 2>&1
get_return_code
return
fi
rc_timer_on $XENDOMAINS_STOP_MAXWAIT $col
while true; do
# Prefer "jobs" over "ps": faster and no false positives
pid=`jobs -l | grep " $1 Running"`
if [ -z "$pid" ]; then
break
fi
pid=`jobs -l | grep " $_rc_timer_pid Running"`
if [ -z "$pid" ]; then
disown $1 # To avoid the "Terminated..." message
kill $1 >/dev/null 2>&1
fi
sleep 1
done
rc_timer_off
if [ $smart_term -ne 0 ]; then
echo -en "\015${esc}[${col}C "
fi
get_return_code
}
stop()
{
echo "Shutting down Xen domains"
if [ "$XENDOMAINS_AUTO_ONLY" = "true" ]; then
running_auto_names
fi
local printed=0
while read LN; do
parseln "$LN"
[ $id = 0 ] && continue
printed=1
if [ "$XENDOMAINS_AUTO_ONLY" = "true" ]; then
is_auto_domain=0
for n in "${AUTNAMES[@]}"; do
if [ "$name" = "$n" ]; then
is_auto_domain=1
break
fi
done
if [ $is_auto_domain -eq 0 ]; then
echo -n " $name: "
rc_status -s
continue
fi
fi
if [ -n "$XENDOMAINS_SYSRQ" ]; then
for sysrq in $XENDOMAINS_SYSRQ; do
echo -n " $name: "
echo -n "sending sysrq '$sysrq'... "
xm sysrq $id $sysrq
if [ $? -ne 0 ]; then
rc_failed
else
rc_reset
fi
rc_status -v
# usleep just ignores empty arg
usleep $XENDOMAINS_USLEEP
done
fi
if is_zombie_state "$state"; then
echo -n " $name: "
echo -n "destroying zombie... "
xm destroy $id
rc_reset
rc_status -v
continue
fi
# HVM domains currently can't migrate or save so don't even try.
hvm=0
vmpath=`xenstore-read /local/domain/$id/vm 2> /dev/null`
if [ $? = 0 ]; then
[ `xenstore-read "$vmpath/image/ostype" 2> /dev/null` = hvm ] && hvm=1
fi
if [ -n "$XENDOMAINS_MIGRATE" ]; then
echo -n " $name: "
echo -n "migrating... "
if [ $hvm != 0 ]; then
echo -n "(unsupported for fully virtualized)"
rc_status -s
else
migrate_with_watchdog $id "$XENDOMAINS_MIGRATE"
if [ $? -ne 0 ]; then
rc_failed
rc_status -v
else
rc_reset
rc_status -v
continue
fi
fi
fi
if [ -n "$XENDOMAINS_SAVE" ]; then
echo -n " $name: "
echo -n "saving... "
if [ $hvm != 0 ]; then
echo -n "(unsupported for fully virtualized)"
rc_status -s
else
save_with_watchdog $id "$XENDOMAINS_SAVE/$name"
if [ $? -ne 0 ]; then
rm -f "$XENDOMAINS_SAVE/$name"
rc_failed
rc_status -v
else
rc_reset
rc_status -v
continue
fi
fi
fi
if [ -n "$XENDOMAINS_SHUTDOWN" ]; then
echo -n " $name: "
echo -n "shutting down... "
shutdown_with_watchdog $id $XENDOMAINS_SHUTDOWN
if [ $? -ne 0 ]; then
rc_failed
else
rc_reset
fi
rc_status -v
fi
done < <(xm list | grep -v '^Name')
if [ -n "$XENDOMAINS_SHUTDOWN_ALL" ] && any_non_zombies ; then
echo -n " others: shutting down... "
shutdown_with_watchdog $XENDOMAINS_SHUTDOWN_ALL
if [ $? -ne 0 ]; then
rc_failed
else
rc_reset
fi
rc_status -v
fi
if [ $printed -eq 0 ]; then
echo -e "${rc_done_up}"
fi
# Unconditionally delete lock file
rm -f "$LOCKFILE"
}
check_domain_up()
{
while read LN; do
parseln "$LN"
[ $id = 0 ] && continue
[ "$name" = "$1" ] && return 0
done < <(xm list | grep -v "^Name")
return 1
}
check_all_domains_up()
{
if ! dir_contains_something "$XENDOMAINS_AUTO" &&
! dir_contains_something "$XENDOMAINS_SAVE"; then
rc_reset
rc_status -v
return
fi
echo
for nm in "$XENDOMAINS_AUTO"/*; do
get_name_from_cfg "$nm"
echo -n " $nm: "
if check_domain_up "$NM"; then
rc_reset
else
rc_failed 2
fi
rc_status -v
done
for nm in "$XENDOMAINS_SAVE"/*; do
echo -n " $nm: "
rc_failed 3
rc_status -v
done
}
# This does NOT necessarily restart all running domains: instead it
# stops all running domains and then boots all the domains specified in
# AUTODIR. If other domains have been started manually then they will
# not get restarted.
restart()
{
"$0" stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
try-restart)
"$0" status
if [ $? = 0 ]; then
"$0" restart
else
rc_reset
rc_status -v
fi
;;
status)
echo -n "Checking status of Xen domains"
if [ ! -f "$LOCKFILE" ]; then
rc_failed 3
rc_status -v
else
check_all_domains_up
fi
;;
*)
echo "Usage: $0 {start|stop|restart|try-restart|reload|status}"
rc_failed 2
;;
esac
rc_exit

14
logrotate.xend.conf Normal file
View File

@ -0,0 +1,14 @@
/var/log/xen/xend.log /var/log/xen/xend-debug.log {
rotate 5
size 1M
notifempty
missingok
nocompress
copytruncate
}
/var/log/xen/qemu-dm.*.log {
rotate 0
missingok
monthly
}

278
mk-xen-rescue-img.sh Normal file
View File

@ -0,0 +1,278 @@
#!/bin/bash
# Shell script to prepare a root FS image based on the Novell/SUSE rescue
# image source. You must have a xen kernel installed for this to work.
# (c) Kurt Garloff <garloff@suse.de>, 2005-01-24, GNU GPL
# Maintained by Charles Coffing <ccoffing@novell.com>
#
# TODO:
# - trap SIGINT and clean up
# - can't know that /sbin/depmod will work with this rescue image
# - support domUloader
# - check for disk full in exchange_kernel_modules
MB_DEFAULT=88
usage()
{
echo "Usage:"
echo " mk-xen-rescue-img.sh source destination [MB [kernelver]]"
echo "Purpose:"
echo " Creates a root filesystem and an associated config file for a Xen-compatible"
echo " Linux virtual machine."
echo "Arguments:"
echo " * 'source' is the source from which to copy files. Normally, this is"
echo " the SUSE rescue image, such as /media/cdrom/boot/x86_64/rescue,"
echo " but it could also be an already-mounted root filesystem."
echo " * 'destination' is the pathname of a disk image to be created, based on"
echo " 'source'."
echo " * 'MB' is the size of disk image (default $MB_DEFAULT)."
echo " * 'kernelver' is the version of an installed Xen-compatible Linux kernel"
echo " (from the kernel-xen package) to install in the disk image. If not"
echo " specified, the newest of those currently installed will be selected."
exit 2
}
usage_error()
{
echo "Error: $@"
echo ""
usage
}
error()
{
echo "Error: $@"
if [ ! -z "$DST_MNT" ]; then
umount "$DST_MNT"
rmdir "$DST_MNT"
fi
exit 1
}
cp_error()
{
error "Failed to copy files to '$DST'."
}
# Determine Xen kernel version
get_xen_kernel()
{
if [ -z "$KVER" ]; then
KVER="`cd /lib/modules && ls -td *-xen/kernel | head -n1 | sed 's@/kernel@@'`"
else
if [ ! -d /lib/modules/$KVER/kernel ]; then
error "/lib/modules/$KVER/kernel does not exist."
fi
fi
if [ -z "$KVER" ]; then
error "You need to have a 'kernel-xen' package installed."
fi
}
cp_rescue()
{
local LSRC=$1
local LDST=$2
# The rescue image has empty directories all hard-linked to the same
# thing, probably to conserve inodes. This gives 'cp' heartburn.
# I want hard linked directories to be created separately (i.e.,
# dereferenced), but I don't want to dereference soft links.
# 'tar' handles this nicely.
(cd "$LSRC" && tar --atime-preserve --one-file-system -cf - *) | \
(cd "$LDST" && tar -xmf -)
}
# Create FS and copy rescue FS
create_basis_and_mount()
{
echo "Creating disk image within '$DST'..."
dd if=/dev/zero of="$DST" bs=4096 count=1 2>/dev/null >/dev/null 2>&1
dd if=/dev/zero of="$DST" bs=1048576 count=0 seek=$MB >/dev/null 2>&1
/sbin/mke2fs -b 1024 -i 2048 -L xen_rescue -F "$DST" >/dev/null 2>&1
DST_MNT="$DST".mnt
mkdir -p "$DST_MNT"
mount -o loop "$DST" "$DST_MNT"
if [ $? -ne 0 ]; then
error "Failed to mount destination disk image via loopback."
fi
echo "Copying files from '$SRC'..."
if test -d "$SRC"; then
if [ ! -d "$SRC"/dev ] || [ ! -d "$SRC"/sbin ]; then
error "'$SRC' does not look like a valid root filesystem."
fi
cp_rescue "$SRC" "$DST_MNT"
if [ $? -ne 0 ]; then
cp_error
fi
else
mkdir -p "$DST".src
if test ! -z "`file $SRC | grep gzip`"; then
cp -p "$SRC" "$DST".stage.gz
gunzip -f "$DST".stage.gz || rm -f "$DST".stage.gz
mount -o loop "$DST".stage "$DST".src
if [ $? -ne 0 ]; then
rm "$DST".stage
rmdir "$DST".src
error "Failed to mount the source via loopback."
fi
cp_rescue "$DST".src "$DST_MNT"
if [ $? -ne 0 ]; then
umount "$DST".src
rm "$DST".stage
rmdir "$DST".src
cp_error
fi
umount "$DST".src
rm "$DST".stage
else
mount -o loop "$SRC" "$DST".src
if [ $? -ne 0 ]; then
rmdir "$DST".src
error "Failed to mount the source via loopback."
fi
cp_rescue "$DST".src "$DST_MNT"
if [ $? -ne 0 ]; then
umount "$DST".src
rmdir "$DST".src
cp_error
fi
umount "$DST".src
fi
rmdir "$DST".src
fi
}
# Save some inodes
remove_some_files()
{
# these consume an excessive amount of inodes
rm -f "$DST_MNT"/dev/sd[c-z][a-z][0-9]*
# hwclock does not work
rm -f "$DST_MNT"/etc/init.d/boot.d/*boot.clock
}
xenify_image()
{
# Xen doesn't yet support virtualizing USB
sed -i "s/^usbfs/#usbfs/" "$DST_MNT"/etc/fstab
}
# Copy extra files to rescue image
copy_extra_files()
{
test ! -e "$DST_MNT"/sbin/depmod && cp -p /sbin/depmod "$DST_MNT"/sbin/
cp -p /usr/share/doc/packages/xen/boot.local.xenU "$DST_MNT"/etc/init.d/boot.local
}
# Remove kernel modules and replace by ours
exchange_kernel_modules()
{
echo "Updating kernel within '$DST'..."
KMODDIR=/lib/modules/$KVER/kernel
MNTKVER="`cd "$DST_MNT"/lib/modules && ls -td */kernel 2>/dev/null | sed 's@/kernel@@' 2>/dev/null`"
for dir in $MNTKVER; do
if test "$MNTKVER" != "$KVER"; then
rm -rf "$DST_MNT"/lib/modules/$MNTKVER
fi
done
mkdir -p "$DST_MNT"$KMODDIR
# complete trees
for dir in arch crypto lib net security; do
cp -ax $KMODDIR/$dir "$DST_MNT"$KMODDIR/
done
mkdir -p "$DST_MNT"$KMODDIR/fs
cp -p $KMODDIR/fs/*.ko "$DST_MNT"$KMODDIR/fs/
# a selection of FS
for fs in afs autofs autofs4 cifs exportfs ext3 fat jbd jfs msdos ncpfs nfsd nls ntfs reiser4 reiserfs smbfs subfs sysv udf ufs vfat xfs; do
if test -e $KMODDIR/fs/$fs; then
cp -ax $KMODDIR/fs/$fs "$DST_MNT"$KMODDIR/fs/
fi
done
# some drivers
mkdir -p "$DST_MNT"$KMODDIR/drivers/char
for name in lp.ko n_hdlc.ko raw.ko; do
cp -p $KMODDIR/drivers/char/$name "$DST_MNT"$KMODDIR/drivers/char/
done
mkdir -p "$DST_MNT"$KMODDIR/drivers/block
for name in umem.ko nbd.ko loop.ko loop_fish2.ko cryptoloop.ko; do
cp -p $KMODDIR/drivers/block/$name "$DST_MNT"$KMODDIR/drivers/block/
done
mkdir -p "$DST_MNT"$KMODDIR/drivers/base
cp -p $KMODDIR/drivers/base/firmware_class.ko "$DST_MNT"$KMODDIR/drivers/base/
mkdir -p "$DST_MNT"$KMODDIR/drivers/md
cp -p $KMODDIR/drivers/md/*.ko "$DST_MNT"$KMODDIR/drivers/md/
mkdir -p "$DST_MNT"$KMODDIR/drivers/xen
for dir in $KMODDIR/drivers/xen/*front; do
cp -ax $dir "$DST_MNT"$KMODDIR/drivers/xen/
done
if test -e $KMODDIR/kernel; then
mkdir -p "$DST_MNT"$KMODDIR/kernel
cp -ax $KMODDIR/kernel/* "$DST_MNT"$KMODDIR/kernel/
fi
# Kernel image + System.map
mkdir -p "$DST_MNT"/boot
rm -f "$DST_MNT"/boot/vmlinuz-* "$DST_MNT"/boot/System.map-* "$DST_MNT"/boot/initrd-*
cp -p /boot/vmlinuz-$KVER "$DST_MNT"/boot/
if test -e /boot/initrd-$KVER-domU; then
cp -p /boot/initrd-$KVER-domU "$DST_MNT"/boot/initrd-$KVER
else
cp -p /boot/initrd-$KVER "$DST_MNT"/boot/
fi
cp -p /boot/System.map-$KVER "$DST_MNT"/boot/
depmod -a $KVER -b "$DST_MNT" -F "$DST_MNT"/boot/System.map-$KVER
}
# umount and display message
umount_and_msg()
{
umount "$DST_MNT"
rmdir "$DST_MNT"
DST_MNT=
echo "'$DST' has been prepared successfully."
CFGFILE=/etc/xen/vm/${DST##*/}
if test -e $CFGFILE; then
mv -b $CFGFILE $CFGFILE.save
fi
if test "${DST:0:1}" != "/"; then
DST="`pwd`/$DST"
fi
cp -p /etc/xen/examples/xmexample.rescue $CFGFILE
sed -i "/^disk/s@^.*\$@disk = [ \'file:$DST,hda1,w\' ]@" $CFGFILE
# These next two lines are only applicable if not using domUloader,
# but try anyway.
sed -i "/^kernel/s@^.*\$@kernel = \"/boot/vmlinuz-$KVER\"@" $CFGFILE
sed -i "/^ramdisk/s@^.*\$@ramdisk = \"/boot/initrd-$KVER\"@" $CFGFILE
echo ""
echo "Config file '$CFGFILE' has been created. Please review!"
echo "You may also want to add an IP address to the config file."
echo "Start the domain with 'xm create -c $CFGFILE'."
}
if test -z "$1" -o -z "$2"; then
usage
fi
SRC=$1
if [ ! -e "$SRC" ]; then
usage_error "'$SRC' does not exist."
fi
DST=$2
if [ -e "$DST" ]; then
error "'$DST' already exists."
fi
MB=$MB_DEFAULT
[ ! -z "$3" ] && MB=$3
KVER=$4
if [ `id -u` -ne 0 ]; then
usage_error "Please run this script as root."
fi
get_xen_kernel
create_basis_and_mount
remove_some_files
copy_extra_files
xenify_image
exchange_kernel_modules
umount_and_msg

461
non-flat-pm.patch Normal file
View File

@ -0,0 +1,461 @@
From: Jan Beulich
Bugzilla #214568
Index: xen-3.0.3-testing/xen/arch/x86/hvm/platform.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/platform.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/platform.c
@@ -883,19 +883,14 @@ void handle_mmio(unsigned long va, unsig
memcpy(regs, guest_cpu_user_regs(), HVM_CONTEXT_STACK_BYTES);
hvm_store_cpu_guest_regs(v, regs, NULL);
- inst_len = hvm_instruction_length(regs, hvm_guest_x86_mode(v));
+ inst_addr = hvm_get_segment_base(current, seg_cs) + regs->eip;
+ inst_len = hvm_instruction_length(inst_addr, hvm_guest_x86_mode(v));
if ( inst_len <= 0 )
{
printk("handle_mmio: failed to get instruction length\n");
domain_crash_synchronous();
}
- realmode = hvm_realmode(v);
- if (realmode)
- inst_addr = (regs->cs << 4) + regs->eip;
- else
- inst_addr = regs->eip;
-
memset(inst, 0, MAX_INST_LEN);
ret = inst_copy_from_guest(inst, inst_addr, inst_len);
if (ret != inst_len) {
@@ -904,6 +899,7 @@ void handle_mmio(unsigned long va, unsig
}
init_instruction(&mmio_inst);
+ realmode = hvm_realmode(v);
if (hvm_decode(realmode, inst, &mmio_inst) == DECODE_failure) {
printk("handle_mmio: failed to decode instruction\n");
Index: xen-3.0.3-testing/xen/arch/x86/hvm/svm/svm.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/svm/svm.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/svm/svm.c
@@ -507,6 +507,24 @@ unsigned long svm_get_ctrl_reg(struct vc
return 0; /* dummy */
}
+static unsigned long svm_get_segment_base(struct vcpu *v, enum segment seg)
+{
+ switch ( seg )
+ {
+ case seg_cs: return v->arch.hvm_svm.vmcb->cs.base;
+ case seg_ds: return v->arch.hvm_svm.vmcb->ds.base;
+ case seg_es: return v->arch.hvm_svm.vmcb->es.base;
+ case seg_fs: return v->arch.hvm_svm.vmcb->fs.base;
+ case seg_gs: return v->arch.hvm_svm.vmcb->gs.base;
+ case seg_ss: return v->arch.hvm_svm.vmcb->ss.base;
+ case seg_tr: return v->arch.hvm_svm.vmcb->tr.base;
+ case seg_gdtr: return v->arch.hvm_svm.vmcb->gdtr.base;
+ case seg_idtr: return v->arch.hvm_svm.vmcb->idtr.base;
+ case seg_ldtr: return v->arch.hvm_svm.vmcb->ldtr.base;
+ }
+ BUG();
+ return 0;
+}
/* Make sure that xen intercepts any FP accesses from current */
static void svm_stts(struct vcpu *v)
@@ -887,6 +905,7 @@ int start_svm(void)
hvm_funcs.pae_enabled = svm_pae_enabled;
hvm_funcs.guest_x86_mode = svm_guest_x86_mode;
hvm_funcs.get_guest_ctrl_reg = svm_get_ctrl_reg;
+ hvm_funcs.get_segment_base = svm_get_segment_base;
hvm_funcs.update_host_cr3 = svm_update_host_cr3;
Index: xen-3.0.3-testing/xen/arch/x86/hvm/vmx/vmx.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/vmx/vmx.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/vmx/vmx.c
@@ -610,7 +610,27 @@ static unsigned long vmx_get_ctrl_reg(st
return 0; /* dummy */
}
+static unsigned long vmx_get_segment_base(struct vcpu *v, enum segment seg)
+{
+ unsigned long base;
+ BUG_ON(v != current);
+ switch ( seg )
+ {
+ case seg_cs: __vmread(GUEST_CS_BASE, &base); break;
+ case seg_ds: __vmread(GUEST_DS_BASE, &base); break;
+ case seg_es: __vmread(GUEST_ES_BASE, &base); break;
+ case seg_fs: __vmread(GUEST_FS_BASE, &base); break;
+ case seg_gs: __vmread(GUEST_GS_BASE, &base); break;
+ case seg_ss: __vmread(GUEST_SS_BASE, &base); break;
+ case seg_tr: __vmread(GUEST_TR_BASE, &base); break;
+ case seg_gdtr: __vmread(GUEST_GDTR_BASE, &base); break;
+ case seg_idtr: __vmread(GUEST_IDTR_BASE, &base); break;
+ case seg_ldtr: __vmread(GUEST_LDTR_BASE, &base); break;
+ default: BUG(); base = 0; break;
+ }
+ return base;
+}
/* Make sure that xen intercepts any FP accesses from current */
static void vmx_stts(struct vcpu *v)
@@ -753,6 +773,7 @@ static void vmx_setup_hvm_funcs(void)
hvm_funcs.pae_enabled = vmx_pae_enabled;
hvm_funcs.guest_x86_mode = vmx_guest_x86_mode;
hvm_funcs.get_guest_ctrl_reg = vmx_get_ctrl_reg;
+ hvm_funcs.get_segment_base = vmx_get_segment_base;
hvm_funcs.update_host_cr3 = vmx_update_host_cr3;
Index: xen-3.0.3-testing/xen/include/asm-x86/hvm/hvm.h
===================================================================
--- xen-3.0.3-testing.orig/xen/include/asm-x86/hvm/hvm.h
+++ xen-3.0.3-testing/xen/include/asm-x86/hvm/hvm.h
@@ -20,6 +20,19 @@
#ifndef __ASM_X86_HVM_HVM_H__
#define __ASM_X86_HVM_HVM_H__
+enum segment {
+ seg_cs,
+ seg_ss,
+ seg_ds,
+ seg_es,
+ seg_fs,
+ seg_gs,
+ seg_tr,
+ seg_ldtr,
+ seg_gdtr,
+ seg_idtr
+};
+
/*
* The hardware virtual machine (HVM) interface abstracts away from the
* x86/x86_64 CPU virtualization assist specifics. Currently this interface
@@ -52,6 +65,7 @@ struct hvm_function_table {
* 1) determine whether the guest is in real or vm8086 mode,
* 2) determine whether paging is enabled,
* 3) return the current guest control-register value
+ * 4) return the current guest segment descriptor base
*/
int (*realmode)(struct vcpu *v);
int (*paging_enabled)(struct vcpu *v);
@@ -59,6 +73,7 @@ struct hvm_function_table {
int (*pae_enabled)(struct vcpu *v);
int (*guest_x86_mode)(struct vcpu *v);
unsigned long (*get_guest_ctrl_reg)(struct vcpu *v, unsigned int num);
+ unsigned long (*get_segment_base)(struct vcpu *v, enum segment seg);
/*
* Re-set the value of CR3 that Xen runs on when handling VM exits
@@ -157,7 +172,7 @@ hvm_guest_x86_mode(struct vcpu *v)
return hvm_funcs.guest_x86_mode(v);
}
-int hvm_instruction_length(struct cpu_user_regs *regs, int mode);
+int hvm_instruction_length(unsigned long pc, int mode);
static inline void
hvm_update_host_cr3(struct vcpu *v)
@@ -176,6 +191,12 @@ hvm_get_guest_ctrl_reg(struct vcpu *v, u
return 0; /* force to fail */
}
+static inline unsigned long
+hvm_get_segment_base(struct vcpu *v, enum segment seg)
+{
+ return hvm_funcs.get_segment_base(v, seg);
+}
+
void hvm_stts(struct vcpu *v);
void hvm_set_guest_time(struct vcpu *v, u64 gtime);
void hvm_do_resume(struct vcpu *v);
Index: xen-3.0.3-testing/xen/arch/x86/hvm/instrlen.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/instrlen.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/instrlen.c
@@ -20,7 +20,6 @@
#include <xen/config.h>
#include <xen/sched.h>
#include <xen/mm.h>
-#include <asm/regs.h>
#include <asm-x86/x86_emulate.h>
/* read from guest memory */
@@ -195,54 +194,51 @@ static uint8_t twobyte_table[256] = {
};
/*
- * insn_fetch - fetch the next 1 to 4 bytes from instruction stream
- * @_type: u8, u16, u32, s8, s16, or s32
- * @_size: 1, 2, or 4 bytes
+ * insn_fetch - fetch the next byte from instruction stream
*/
-#define insn_fetch(_type, _size) \
-({ unsigned long _x, _ptr = _regs.eip; \
- if ( mode == X86EMUL_MODE_REAL ) _ptr += _regs.cs << 4; \
- rc = inst_copy_from_guest((unsigned char *)(&(_x)), _ptr, _size); \
- if ( rc != _size ) goto done; \
- _regs.eip += (_size); \
- length += (_size); \
- (_type)_x; \
+#define insn_fetch() \
+({ uint8_t _x; \
+ if ( inst_copy_from_guest(&_x, pc, 1) != 1 ) { \
+ DPRINTK("Cannot read from address %lx (eip %lx, mode %d)\n", \
+ pc, org_pc, mode); \
+ return -1; \
+ } \
+ pc += 1; \
+ length += 1; \
+ _x; \
})
/**
* hvm_instruction_length - returns the current instructions length
*
- * @regs: guest register state
+ * @org_pc: guest instruction pointer
* @mode: guest operating mode
*
* EXTERNAL this routine calculates the length of the current instruction
- * pointed to by eip. The guest state is _not_ changed by this routine.
+ * pointed to by org_pc. The guest state is _not_ changed by this routine.
*/
-int hvm_instruction_length(struct cpu_user_regs *regs, int mode)
+int hvm_instruction_length(unsigned long org_pc, int mode)
{
uint8_t b, d, twobyte = 0, rex_prefix = 0;
uint8_t modrm, modrm_mod = 0, modrm_reg = 0, modrm_rm = 0;
- unsigned int op_bytes, ad_bytes, i;
- int rc = 0;
+ unsigned int op_default, op_bytes, ad_default, ad_bytes, i;
int length = 0;
unsigned int tmp;
-
- /* Shadow copy of register state. Committed on successful emulation. */
- struct cpu_user_regs _regs = *regs;
+ unsigned long pc = org_pc;
switch ( mode )
{
case X86EMUL_MODE_REAL:
case X86EMUL_MODE_PROT16:
- op_bytes = ad_bytes = 2;
+ op_bytes = op_default = ad_bytes = ad_default = 2;
break;
case X86EMUL_MODE_PROT32:
- op_bytes = ad_bytes = 4;
+ op_bytes = op_default = ad_bytes = ad_default = 4;
break;
#ifdef __x86_64__
case X86EMUL_MODE_PROT64:
- op_bytes = 4;
- ad_bytes = 8;
+ op_bytes = op_default = 4;
+ ad_bytes = ad_default = 8;
break;
#endif
default:
@@ -252,16 +248,16 @@ int hvm_instruction_length(struct cpu_us
/* Legacy prefixes. */
for ( i = 0; i < 8; i++ )
{
- switch ( b = insn_fetch(uint8_t, 1) )
+ switch ( b = insn_fetch() )
{
case 0x66: /* operand-size override */
- op_bytes ^= 6; /* switch between 2/4 bytes */
+ op_bytes = op_default ^ 6; /* switch between 2/4 bytes */
break;
case 0x67: /* address-size override */
if ( mode == X86EMUL_MODE_PROT64 )
- ad_bytes ^= 12; /* switch between 4/8 bytes */
+ ad_bytes = ad_default ^ 12; /* switch between 4/8 bytes */
else
- ad_bytes ^= 6; /* switch between 2/4 bytes */
+ ad_bytes = ad_default ^ 6; /* switch between 2/4 bytes */
break;
case 0x2e: /* CS override */
case 0x3e: /* DS override */
@@ -273,21 +269,30 @@ int hvm_instruction_length(struct cpu_us
case 0xf3: /* REP/REPE/REPZ */
case 0xf2: /* REPNE/REPNZ */
break;
+#ifdef __x86_64__
+ case 0x40 ... 0x4f:
+ if ( mode == X86EMUL_MODE_PROT64 )
+ {
+ rex_prefix = b;
+ continue;
+ }
+ /* FALLTHRU */
+#endif
default:
goto done_prefixes;
}
+ rex_prefix = 0;
}
done_prefixes:
/* REX prefix. */
- if ( (mode == X86EMUL_MODE_PROT64) && ((b & 0xf0) == 0x40) )
+ if ( rex_prefix )
{
- rex_prefix = b;
- if ( b & 8 )
- op_bytes = 8; /* REX.W */
- modrm_reg = (b & 4) << 1; /* REX.R */
+ if ( rex_prefix & 8 )
+ op_bytes = 8; /* REX.W */
+ modrm_reg = (rex_prefix & 4) << 1; /* REX.R */
/* REX.B and REX.X do not need to be decoded. */
- b = insn_fetch(uint8_t, 1);
+ b = insn_fetch();
}
/* Opcode byte(s). */
@@ -298,7 +303,7 @@ done_prefixes:
if ( b == 0x0f )
{
twobyte = 1;
- b = insn_fetch(uint8_t, 1);
+ b = insn_fetch();
d = twobyte_table[b];
}
@@ -310,7 +315,7 @@ done_prefixes:
/* ModRM and SIB bytes. */
if ( d & ModRM )
{
- modrm = insn_fetch(uint8_t, 1);
+ modrm = insn_fetch();
modrm_mod |= (modrm & 0xc0) >> 6;
modrm_reg |= (modrm & 0x38) >> 3;
modrm_rm |= (modrm & 0x07);
@@ -330,16 +335,16 @@ done_prefixes:
if ( modrm_rm == 6 )
{
length += 2;
- _regs.eip += 2; /* skip disp16 */
+ pc += 2; /* skip disp16 */
}
break;
case 1:
length += 1;
- _regs.eip += 1; /* skip disp8 */
+ pc += 1; /* skip disp8 */
break;
case 2:
length += 2;
- _regs.eip += 2; /* skip disp16 */
+ pc += 2; /* skip disp16 */
break;
}
}
@@ -350,33 +355,34 @@ done_prefixes:
{
case 0:
if ( (modrm_rm == 4) &&
- (((insn_fetch(uint8_t, 1)) & 7)
- == 5) )
+ ((insn_fetch() & 7) == 5) )
{
length += 4;
- _regs.eip += 4; /* skip disp32 specified by SIB.base */
+ pc += 4; /* skip disp32 specified by SIB.base */
}
else if ( modrm_rm == 5 )
{
length += 4;
- _regs.eip += 4; /* skip disp32 */
+ pc += 4; /* skip disp32 */
}
break;
case 1:
if ( modrm_rm == 4 )
{
- insn_fetch(uint8_t, 1);
+ length += 1;
+ pc += 1;
}
length += 1;
- _regs.eip += 1; /* skip disp8 */
+ pc += 1; /* skip disp8 */
break;
case 2:
if ( modrm_rm == 4 )
{
- insn_fetch(uint8_t, 1);
+ length += 1;
+ pc += 1;
}
length += 4;
- _regs.eip += 4; /* skip disp32 */
+ pc += 4; /* skip disp32 */
break;
}
}
@@ -397,15 +403,12 @@ done_prefixes:
tmp = (d & ByteOp) ? 1 : op_bytes;
if ( tmp == 8 ) tmp = 4;
/* NB. Immediates are sign-extended as necessary. */
- switch ( tmp )
- {
- case 1: insn_fetch(int8_t, 1); break;
- case 2: insn_fetch(int16_t, 2); break;
- case 4: insn_fetch(int32_t, 4); break;
- }
+ length += tmp;
+ pc += tmp;
break;
case SrcImmByte:
- insn_fetch(int8_t, 1);
+ length += 1;
+ pc += 1;
break;
}
@@ -414,13 +417,9 @@ done_prefixes:
switch ( b )
{
- case 0xa0 ... 0xa1: /* mov */
- length += ad_bytes;
- _regs.eip += ad_bytes; /* skip src displacement */
- break;
- case 0xa2 ... 0xa3: /* mov */
+ case 0xa0 ... 0xa3: /* mov */
length += ad_bytes;
- _regs.eip += ad_bytes; /* skip dst displacement */
+ pc += ad_bytes; /* skip src/dst displacement */
break;
case 0xf6 ... 0xf7: /* Grp3 */
switch ( modrm_reg )
@@ -429,12 +428,8 @@ done_prefixes:
/* Special case in Grp3: test has an immediate source operand. */
tmp = (d & ByteOp) ? 1 : op_bytes;
if ( tmp == 8 ) tmp = 4;
- switch ( tmp )
- {
- case 1: insn_fetch(int8_t, 1); break;
- case 2: insn_fetch(int16_t, 2); break;
- case 4: insn_fetch(int32_t, 4); break;
- }
+ length += tmp;
+ pc += tmp;
goto done;
}
break;
@@ -445,6 +440,6 @@ done:
cannot_emulate:
DPRINTK("Cannot emulate %02x at address %lx (eip %lx, mode %d)\n",
- b, (unsigned long)_regs.eip, (unsigned long)regs->eip, mode);
+ b, pc, org_pc, mode);
return -1;
}

0
ready Normal file
View File

452
serial-split.patch Normal file
View File

@ -0,0 +1,452 @@
Index: xen-3.0-testing/tools/misc/serial-split/Makefile
===================================================================
--- /dev/null
+++ xen-3.0-testing/tools/misc/serial-split/Makefile
@@ -0,0 +1,20 @@
+CC ?= gcc
+CFLAGS ?= -Wall -Os
+CFILES = $(wildcard *.c)
+OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
+TARGET = serial-split
+
+all: $(TARGET)
+
+install: all
+ install -d $(DESTDIR)/usr/bin
+ install -s $(TARGET) $(DESTDIR)/usr/bin/
+
+clean:
+ rm *.o $(TARGET) *~
+
+$(TARGET): $(OBJS)
+ $(CC) $(CFLAGS) -o $@ $^
+
+%.o: %.c Makefile
+ $(CC) $(CFLAGS) -c -o $@ $<
Index: xen-3.0-testing/tools/misc/serial-split/serial-split.c
===================================================================
--- /dev/null
+++ xen-3.0-testing/tools/misc/serial-split/serial-split.c
@@ -0,0 +1,422 @@
+/*
+ * serial-split.c
+ * pdb / console splitter
+ *
+ * Copyright 2005 Charles Coffing <ccoffing@novell.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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * Typical setup:
+ *
+ * Development box Xen box
+ * ...-----+ +-----...
+ * +---------+ | |
+ * | gdb | | |
+ * | |\ high | |
+ * +---------+ \ | |
+ * \+-----------+ | serial | +------------------+
+ * | splitter |------------| Xen |
+ * /+-----------+ | | | - pdb (com1H)|
+ * +---------+ / | | | - printk (com1) |
+ * | console |/ low | | +------------------+
+ * | viewer | | |
+ * +---------+ | |
+ * ...-----+ +-----...
+ */
+
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <termios.h>
+#include <sys/signal.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <netinet/in.h>
+
+const unsigned int DefaultLowPort = 12010;
+const unsigned int DefaultBaud = 115200;
+const char DefaultSerialDevice[] = "/dev/ttyS0";
+
+#define DEBUG 0
+#define MAX(a,b) ((a)<(b)?(b):(a))
+
+
+static int cook_baud(int baud)
+{
+ int cooked_baud = 0;
+ switch (baud)
+ {
+ case 50: cooked_baud = B50; break;
+ case 75: cooked_baud = B75; break;
+ case 110: cooked_baud = B110; break;
+ case 134: cooked_baud = B134; break;
+ case 150: cooked_baud = B150; break;
+ case 200: cooked_baud = B200; break;
+ case 300: cooked_baud = B300; break;
+ case 600: cooked_baud = B600; break;
+ case 1200: cooked_baud = B1200; break;
+ case 1800: cooked_baud = B1800; break;
+ case 2400: cooked_baud = B2400; break;
+ case 4800: cooked_baud = B4800; break;
+ case 9600: cooked_baud = B9600; break;
+ case 19200: cooked_baud = B19200; break;
+ case 38400: cooked_baud = B38400; break;
+ case 57600: cooked_baud = B57600; break;
+ case 115200: cooked_baud = B115200; break;
+ }
+ return cooked_baud;
+}
+
+
+static int start_listener(unsigned short port)
+{
+ int fd;
+ struct sockaddr_in sin;
+ int on = 1;
+
+ if ((fd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
+ {
+ perror("socket");
+ goto out1;
+ }
+
+ setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on));
+
+ memset(&sin, 0, sizeof(sin));
+ sin.sin_family = AF_INET;
+ sin.sin_port = htons (port);
+ sin.sin_addr.s_addr = INADDR_ANY;
+ if (bind(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0)
+ {
+ perror("bind");
+ goto out2;
+ }
+
+ if (listen(fd, 1) < 0)
+ {
+ perror("listen");
+ goto out2;
+ }
+
+ fprintf(stderr, "Listening on port %d\n", port);
+
+ return fd;
+
+out2:
+ close(fd);
+out1:
+ return -1;
+}
+
+
+static int accept_conn(int fd)
+{
+ int on = 1;
+ int new_fd;
+ struct sockaddr_in from;
+ socklen_t fromlen = sizeof(from);
+
+ new_fd = accept(fd, (struct sockaddr *)&from, &fromlen);
+ if (new_fd < 0)
+ perror("accept");
+ ioctl(new_fd, FIONBIO, &on);
+
+ fprintf(stderr, "Accepted connection on %d\n", new_fd);
+
+ return new_fd;
+}
+
+
+static void close_conn(int * fd)
+{
+ shutdown(*fd, 2);
+ close(*fd);
+ *fd = -1;
+}
+
+
+static int receive_data(int * fd, char * buf, ssize_t max_bytes, int * poll)
+{
+ ssize_t bytes;
+ if ((bytes = read(*fd, buf, max_bytes)) < 0)
+ {
+ perror("read");
+ *poll = 1;
+ return 0;
+ }
+ else if (bytes == 0)
+ {
+ close_conn(fd);
+ *poll = 0;
+ return 0;
+ }
+ else
+ {
+ if (bytes == max_bytes)
+ *poll = 1;
+ else
+ *poll = 0;
+#if DEBUG
+ {
+ ssize_t i;
+ fprintf(stderr, "Received %d bytes on %d:\n", bytes, *fd);
+ for (i = 0; i < bytes; ++ i)
+ {
+ if ((i & 0xf) == 0)
+ printf(" ");
+ printf("%02x", buf[i] & 0xff);
+ if (((i+1) & 0xf) == 0 || i + 1 == bytes)
+ printf("\n");
+ else
+ printf(" ");
+ }
+ }
+#endif
+ return bytes;
+ }
+}
+
+
+static void set_high_bit(char * buf, size_t bytes)
+{
+ size_t i;
+ for(i = 0; i < bytes; ++ i)
+ buf[i] |= 0x80;
+}
+
+
+static void clear_high_bit(char * buf, size_t bytes)
+{
+ size_t i;
+ for(i = 0; i < bytes; ++ i)
+ buf[i] &= 0x7f;
+}
+
+
+static int open_serial(char const * serial_dev, int baud)
+{
+ struct termios newsertio;
+ int serial_fd;
+ memset(&newsertio, 0, sizeof(newsertio));
+
+ if ((serial_fd = open(serial_dev, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0)
+ {
+ perror(serial_dev);
+ return -1;
+ }
+
+ newsertio.c_cflag = baud | CS8 | CLOCAL | CREAD;
+ newsertio.c_iflag = IGNBRK | IGNPAR; /* raw input */
+ newsertio.c_oflag = 0; /* raw output */
+ newsertio.c_lflag = 0; /* no echo, no signals */
+ newsertio.c_cc[VMIN] = 1;
+ newsertio.c_cc[VTIME] = 0;
+ tcflush(serial_fd, TCIFLUSH);
+ tcsetattr(serial_fd, TCSANOW, &newsertio);
+
+ fprintf(stderr, "Listening on %s\n", serial_dev);
+
+ return serial_fd;
+}
+
+
+static void main_loop(int serial_fd, int low_listener, int high_listener)
+{
+ fd_set rdfds;
+ int low_poll = 0, high_poll = 0, serial_poll = 0;
+ int low_fd = -1, high_fd = -1;
+
+ while(1)
+ {
+ char buf[1024];
+ ssize_t bytes;
+ int max;
+
+ FD_ZERO(&rdfds);
+ FD_SET(low_fd < 0 ? low_listener : low_fd, &rdfds);
+ FD_SET(high_fd < 0 ? high_listener : high_fd, &rdfds);
+ FD_SET(serial_fd, &rdfds);
+
+ max = MAX(low_fd, low_listener);
+ max = MAX(max, high_fd);
+ max = MAX(max, high_listener);
+ max = MAX(max, serial_fd);
+
+ if (select(max + 1, &rdfds, NULL, NULL, NULL) < 0)
+ {
+ perror("select");
+ continue;
+ }
+
+ if (FD_ISSET(low_listener, &rdfds))
+ {
+ assert(low_fd < 0);
+ low_fd = accept_conn(low_listener);
+ }
+
+ if (FD_ISSET(high_listener, &rdfds))
+ {
+ assert(high_fd < 0);
+ high_fd = accept_conn(high_listener);
+ }
+
+ if (low_poll || (low_fd >= 0 && FD_ISSET(low_fd, &rdfds)))
+ {
+ if ((bytes = receive_data(&low_fd, &buf[0], sizeof(buf),
+ &low_poll)) > 0)
+ {
+ clear_high_bit(&buf[0], bytes);
+ if (write(serial_fd, &buf[0], bytes) < 0)
+ perror("write");
+ }
+ }
+
+ if (high_poll || (high_fd >= 0 && FD_ISSET(high_fd, &rdfds)))
+ {
+ if ((bytes = receive_data(&high_fd, &buf[0], sizeof(buf),
+ &high_poll)) > 0)
+ {
+ set_high_bit(&buf[0], bytes);
+ if (write(serial_fd, &buf[0], bytes) < 0)
+ perror("write");
+ }
+ }
+
+ if (serial_poll || FD_ISSET(serial_fd, &rdfds))
+ {
+ if ((bytes = receive_data(&serial_fd, &buf[0], sizeof(buf),
+ &serial_poll)) > 0)
+ {
+ ssize_t i;
+ for (i = 0; i < bytes; ++ i)
+ {
+ if (buf[i] & 0x80)
+ {
+ if (high_fd >= 0)
+ {
+ buf[i] &= 0x7f;
+ if ((write(high_fd, &buf[i], 1)) < 0)
+ {
+ perror("write");
+ close_conn(&high_fd);
+ high_poll = 0;
+ }
+ }
+ }
+ else
+ {
+ if (low_fd >= 0)
+ {
+ if ((write(low_fd, &buf[i], 1)) < 0)
+ {
+ perror("write");
+ close_conn(&low_fd);
+ low_poll = 0;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+static void usage()
+{
+ printf(
+"Description:\n"
+" Splits the serial port between two TCP ports. Bytes read from the\n"
+" serial port will be delivered to one of the two TCP ports (high or\n"
+" low) depending on whether the high bit is set. Bytes written to the\n"
+" TCP ports will be forwarded to the serial port; the high bit will be\n"
+" set or cleared to denote the source.\n"
+"Usage:\n"
+" serial-split [-d<serial-device>] [-b<baud>]\n"
+" [-l<low-port>] [-h<high-port>]\n"
+"Parameters:\n"
+" -d<serial-device> Defaults to %s.\n"
+" -b<baud> Baud rate of the serial port. Defaults to %d.\n"
+" Also assumes 8N1.\n"
+" -l<low-port> Low TCP port. Defaults to %d, or one less than\n"
+" the high port.\n"
+" -h<high-port> High TCP port. Defaults to %d, or one more than\n"
+" the low port.\n",
+DefaultSerialDevice, DefaultBaud, DefaultLowPort, DefaultLowPort + 1);
+
+ exit(1);
+}
+
+
+int main(int argc, char **argv)
+{
+ int cooked_baud = cook_baud(DefaultBaud);
+ char const * serial_dev = DefaultSerialDevice;
+ int low_port = -1, high_port = -1;
+ int serial_fd, low_listener, high_listener;
+
+ while ( --argc != 0 )
+ {
+ char *p = argv[argc];
+ if ( *(p++) != '-' )
+ usage();
+ switch (*(p++))
+ {
+ case 'b':
+ if ( (cooked_baud = cook_baud(atoi(p))) == 0 )
+ {
+ fprintf(stderr, "Bad baud rate\n");
+ exit(1);
+ }
+ break;
+ case 'd':
+ serial_dev = p;
+ break;
+ case 'l':
+ if ((low_port = atoi(p)) <= 0)
+ usage();
+ break;
+ case 'h':
+ if ((high_port = atoi(p)) <= 0)
+ usage();
+ break;
+ default:
+ usage();
+ }
+ }
+
+ if (low_port == -1 && high_port == -1)
+ low_port = DefaultLowPort;
+ if (low_port == -1)
+ low_port = high_port - 1;
+ if (high_port == -1)
+ high_port = low_port + 1;
+
+ if ((serial_fd = open_serial(serial_dev, cooked_baud)) < 0 ||
+ (low_listener = start_listener(low_port)) < 0 ||
+ (high_listener = start_listener(high_port)) < 0)
+ exit(1);
+
+ main_loop(serial_fd, low_listener, high_listener);
+
+ return 0;
+}
+

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:50d18f4e082110db27a98ffcd39d98cc12058a6dd89c58a378ce283fa911ba89
size 4580110

65
xen-bonding.diff Normal file
View File

@ -0,0 +1,65 @@
Index: xen-unstable/tools/examples/network-bridge
===================================================================
--- xen-unstable.orig/tools/examples/network-bridge
+++ xen-unstable/tools/examples/network-bridge
@@ -145,6 +145,21 @@ antispoofing () {
iptables -A FORWARD -m physdev --physdev-in ${vif0} -j ACCEPT
}
+# Find the netdev that is associated with the bridge by matching MAC addresses.
+find_bridged_netdev () {
+ local bridge=$1
+
+ bmac=`ip link show ${bridge} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
+ for i in `ls /sys/class/net/${bridge}/brif` ; do
+ mac=`ip link show ${i} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
+ if [ "${bmac}" = "${mac}" ] && [ ! "${bridge}" = "${i}" ] ; then
+ netdev=${i}
+ return 0
+ fi
+ done
+ return 1
+}
+
# Usage: show_status dev bridge
# Print ifconfig and routes.
show_status () {
@@ -187,10 +202,11 @@ using loopback.nloopbacks=<N> on the dom
create_bridge ${bridge}
- if link_exists "$vdev"; then
+ preiftransfer
+ . /etc/sysconfig/network/ifcfg-${hwddev}
+ if [ ! "$BONDING_MASTER" = yes ] && link_exists "$vdev"; then
mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
ifup ${netdev} # To ensure there is an IP to transfer
- preiftransfer
transfer_addrs ${netdev} ${vdev}
ifdown ${netdev}
ip link set ${netdev} name ${pdev}
@@ -205,6 +221,13 @@ using loopback.nloopbacks=<N> on the dom
add_to_bridge2 ${bridge} ${pdev}
ip link set ${netdev} up
ifup ${hwddev}
+ elif [ "$BONDING_MASTER" = yes ]; then
+ ip link set ${bridge} arp on
+ add_to_bridge ${bridge} ${vif0}
+ ip link set ${vif0} up
+ add_to_bridge2 ${bridge} ${netdev}
+ transfer_addrs ${netdev} ${bridge}
+ transfer_routes ${netdev} ${bridge}
else
# old style without ${vdev}
transfer_addrs ${netdev} ${bridge}
@@ -243,6 +266,10 @@ op_stop () {
ip link set ${pdev} name ${netdev}
ifup ${netdev}
else
+ if [ ${netdev} = ${bridge} ]; then
+ find_bridged_netdev ${bridge}
+ fi
+ ip link set dev ${vif0} down
transfer_routes ${bridge} ${netdev}
ip link set ${bridge} down
fi

21
xen-changeset.diff Normal file
View File

@ -0,0 +1,21 @@
Index: xen-3.0.3-testing/xen/Makefile
===================================================================
--- xen-3.0.3-testing.orig/xen/Makefile
+++ xen-3.0.3-testing/xen/Makefile
@@ -3,6 +3,7 @@
export XEN_VERSION = 3
export XEN_SUBVERSION = 0
export XEN_EXTRAVERSION ?= .3-0
+export XEN_CHANGESET = unavailable
export XEN_FULLVERSION = $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)
-include xen-version
@@ -103,7 +104,7 @@ include/xen/compile.h: include/xen/compi
-e 's/@@version@@/$(XEN_VERSION)/g' \
-e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \
-e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
- -e 's!@@changeset@@!$(shell ((hg parents || head -n 7 ../ChangeLog || echo date: unavailable) | awk '{FS="changeset:[ ]+"}/^changeset/{CS=$$2};{FS="date:[ ]+"}/^date/{D=$$2}; END {print D, CS}') 2>/dev/null)!g' \
+ -e 's!@@changeset@@!$(XEN_CHANGESET)!g' \
< include/xen/compile.h.in > $@.new
tools/figlet/figlet -d tools/figlet Xen $(XEN_FULLVERSION) >> $@.new
@mv -f $@.new $@

35
xen-config-defaults.diff Normal file
View File

@ -0,0 +1,35 @@
Index: xen-unstable/tools/examples/init.d/sysconfig.xendomains
===================================================================
--- xen-unstable.orig/tools/examples/init.d/sysconfig.xendomains
+++ xen-unstable/tools/examples/init.d/sysconfig.xendomains
@@ -98,7 +98,6 @@ XENDOMAINS_RESTORE=true
# Note that the script tries to be clever if both RESTORE and AUTO are
# set: It will first restore saved domains and then only start domains
# in AUTO which are not running yet.
-# Note that the name matching is somewhat fuzzy.
#
XENDOMAINS_AUTO=/etc/xen/auto
@@ -109,9 +108,8 @@ XENDOMAINS_AUTO=/etc/xen/auto
# files in XENDOMAINS_AUTO will be treated according to XENDOMAINS_SYSRQ,
# XENDOMAINS_MIGRATE, XENDOMAINS_SAVE, XENDMAINS_SHUTDOWN; otherwise
# all running domains will be.
-# Note that the name matching is somewhat fuzzy.
#
-XENDOMAINS_AUTO_ONLY=false
+XENDOMAINS_AUTO_ONLY=true
## Type: integer
## Default: 300
Index: xen-unstable/tools/examples/xend-config.sxp
===================================================================
--- xen-unstable.orig/tools/examples/xend-config.sxp
+++ xen-unstable/tools/examples/xend-config.sxp
@@ -19,7 +19,6 @@
#(xend-tcp-xmlrpc-server no)
#(xend-unix-xmlrpc-server yes)
#(xend-relocation-server no)
-(xend-relocation-server yes)
#(xend-unix-path /var/lib/xend/xend-socket)

63
xen-console.diff Normal file
View File

@ -0,0 +1,63 @@
Subject: video mode detection (161541)
Charles, attached the promised patch for replacing xen-console.diff. Jan
Index: xen-unstable/xen/drivers/video/vga.c
===================================================================
--- xen-unstable.orig/xen/drivers/video/vga.c
+++ xen-unstable/xen/drivers/video/vga.c
@@ -573,6 +573,30 @@ string_param("vga", opt_vga);
#define ATTRIBUTE 7
#define VIDEO_SIZE (COLUMNS * LINES * 2)
+static int gfx_vga(void)
+{
+ unsigned char idx, data;
+
+ idx = inb(0x3ce);
+ outb(0x06, 0x3ce);
+ data = inb(0x3cf);
+ outb(idx, 0x3ce);
+
+ if ( data & 0x01 )
+ return 1;
+
+ /* Unfortunately many cards don't reflect their mode in the GDC
+ * miscellaneous register, bit 0 (and even fewer reflect it in the
+ * ATC mode control register, bit 0). Therefore we further check
+ * horizontal display width against our original setting. */
+ idx = inb(0x3d4);
+ outb(0x01, 0x3d4);
+ data = inb(0x3d5);
+ outb(idx, 0x3d4);
+
+ return data != COLUMNS - 1;
+}
+
void vga_init(void)
{
char *p;
@@ -656,14 +680,21 @@ static void put_newline(void)
void vga_putchar(int c)
{
+ static int vga_in_gfx = -1;
+
if ( !vgacon_enabled )
return;
+ if ( vga_in_gfx < 0 )
+ vga_in_gfx = gfx_vga();
+
if ( c == '\n' )
{
- put_newline();
+ if ( vga_in_gfx <= 0 )
+ put_newline();
+ vga_in_gfx = -1;
}
- else
+ else if ( vga_in_gfx <= 0 )
{
if ( xpos >= COLUMNS )
put_newline();

151
xen-destdir.diff Normal file
View File

@ -0,0 +1,151 @@
Index: xen-3.0.3-testing/docs/Makefile
===================================================================
--- xen-3.0.3-testing.orig/docs/Makefile
+++ xen-3.0.3-testing/docs/Makefile
@@ -12,8 +12,8 @@ LATEX2HTML := latex2html
DOXYGEN := doxygen
POD2MAN := pod2man
-pkgdocdir := /usr/share/doc/xen
-mandir := /usr/share/man
+pkgdocdir := $(DOCDIR)
+mandir := $(MANDIR)
DOC_MAN5SRC := $(wildcard man/*.pod.5)
DOC_MAN1SRC := $(wildcard man/*.pod.1)
Index: xen-3.0.3-testing/tools/xentrace/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/xentrace/Makefile
+++ xen-3.0.3-testing/tools/xentrace/Makefile
@@ -43,14 +43,14 @@ install: build
[ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
[ -z "$(LIBBIN)" ] || [ -d $(DESTDIR)/usr/$(LIBDIR)/xen/bin ] || \
$(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)/xen/bin
- [ -d $(DESTDIR)/usr/share/man/man1 ] || \
- $(INSTALL_DIR) $(DESTDIR)/usr/share/man/man1
- [ -d $(DESTDIR)/usr/share/man/man8 ] || \
- $(INSTALL_DIR) $(DESTDIR)/usr/share/man/man8
+ [ -d $(DESTDIR)$(MANDIR)/man1 ] || \
+ $(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man1
+ [ -d $(DESTDIR)$(MANDIR)/man8 ] || \
+ $(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man8
$(INSTALL_PROG) $(BIN) $(SCRIPTS) $(DESTDIR)/usr/bin
[ -z "$(LIBBIN)" ] || $(INSTALL_PROG) $(LIBBIN) $(DESTDIR)/usr/$(LIBDIR)/xen/bin
- $(INSTALL_DATA) $(MAN1) $(DESTDIR)/usr/share/man/man1
- $(INSTALL_DATA) $(MAN8) $(DESTDIR)/usr/share/man/man8
+ $(INSTALL_DATA) $(MAN1) $(DESTDIR)$(MANDIR)/man1
+ $(INSTALL_DATA) $(MAN8) $(DESTDIR)$(MANDIR)/man8
.PHONY: clean
clean:
Index: xen-3.0.3-testing/tools/examples/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/examples/Makefile
+++ xen-3.0.3-testing/tools/examples/Makefile
@@ -43,18 +43,6 @@ XEN_HOTPLUG_SCRIPTS = xen-backend.agent
UDEV_RULES_DIR = /etc/udev
UDEV_RULES = xen-backend.rules
-DI = $(if $(DISTDIR),$(shell readlink -f $(DISTDIR)),)
-DE = $(if $(DESTDIR),$(shell readlink -f $(DESTDIR)),)
-ifeq ($(findstring $(DI),$(DE)),$(DI))
-HOTPLUGS=install-hotplug install-udev
-else
-ifeq ($(shell [ -x /usr/bin/udevinfo ] && [ `/usr/bin/udevinfo -V | sed -e 's/^[^0-9]* \([0-9]\{1,\}\)[^0-9]\{0,\}/\1/'` -ge 059 ] && echo 1),1)
-HOTPLUGS=install-udev
-else
-HOTPLUGS=install-hotplug
-endif
-endif
-
.PHONY: all
all:
@@ -62,15 +50,15 @@ all:
build:
.PHONY: install
-install: all install-initd install-configs install-scripts $(HOTPLUGS)
+install: all install-initd install-configs install-scripts install-udev
.PHONY: install-initd
install-initd:
[ -d $(DESTDIR)/etc/init.d ] || $(INSTALL_DIR) $(DESTDIR)/etc/init.d
- [ -d $(DESTDIR)/etc/sysconfig ] || $(INSTALL_DIR) $(DESTDIR)/etc/sysconfig
+ [ -d $(DESTDIR)/var/adm/fillup-templates ] || $(INSTALL_DIR) $(DESTDIR)/var/adm/fillup-templates/
$(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)/etc/init.d
$(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)/etc/init.d
- $(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)/etc/sysconfig/xendomains
+ $(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)/var/adm/fillup-templates/
.PHONY: install-configs
install-configs: $(XEN_CONFIGS)
@@ -111,9 +99,7 @@ install-udev:
$(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d
for i in $(UDEV_RULES); \
do \
- $(INSTALL_DATA) $$i $(DESTDIR)$(UDEV_RULES_DIR); \
- ( cd $(DESTDIR)$(UDEV_RULES_DIR)/rules.d ; \
- ln -sf ../$$i . ) \
+ $(INSTALL_DATA) $$i $(DESTDIR)$(UDEV_RULES_DIR)/rules.d; \
done
.PHONY: clean
Index: xen-3.0.3-testing/tools/security/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/security/Makefile
+++ xen-3.0.3-testing/tools/security/Makefile
@@ -73,9 +73,9 @@ install: all $(ACM_CONFIG_FILE)
$(INSTALL_DIR) -p $(DESTDIR)$(ACM_SECGEN_CGIDIR)
$(INSTALL_PROG) -p $(ACM_INST_CGI) $(DESTDIR)$(ACM_SECGEN_CGIDIR)
ifndef XEN_PYTHON_NATIVE_INSTALL
- python python/setup.py install --home="$(DESTDIR)/usr"
+ python python/setup.py install --home="$(DESTDIR)/usr" --prefix=""
else
- python python/setup.py install --root="$(DESTDIR)"
+ python python/setup.py install --root="$(DESTDIR)" --prefix="/usr"
endif
else
.PHONY: all
Index: xen-3.0.3-testing/tools/pygrub/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/pygrub/Makefile
+++ xen-3.0.3-testing/tools/pygrub/Makefile
@@ -15,7 +15,7 @@ install: all
$(INSTALL_DIR) -p $(DESTDIR)/var/lib/xen
else
install: all
- CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)"
+ CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --prefix="/usr"
$(INSTALL_DIR) -p $(DESTDIR)/var/lib/xen
endif
Index: xen-3.0.3-testing/tools/python/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/python/Makefile
+++ xen-3.0.3-testing/tools/python/Makefile
@@ -14,7 +14,7 @@ install: all
CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --force
else
install: all
- CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force
+ CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --prefix="/usr" --force
endif
.PHONY: test
Index: xen-3.0.3-testing/xen/Makefile
===================================================================
--- xen-3.0.3-testing.orig/xen/Makefile
+++ xen-3.0.3-testing/xen/Makefile
@@ -31,8 +31,11 @@ _install: $(TARGET).gz
$(INSTALL_DATA) $(TARGET)-syms $(DESTDIR)/boot/$(notdir $(TARGET))-syms-$(XEN_FULLVERSION)
[ -d $(DESTDIR)/usr/include/xen/io ] || \
$(INSTALL_DIR) $(DESTDIR)/usr/include/xen/io
+ [ -d $(DESTDIR)/usr/include/xen/hvm ] || \
+ $(INSTALL_DIR) $(DESTDIR)/usr/include/xen/hvm
$(INSTALL_DATA) include/public/*.h $(DESTDIR)/usr/include/xen
$(INSTALL_DATA) include/public/io/*.h $(DESTDIR)/usr/include/xen/io
+ $(INSTALL_DATA) include/public/hvm/*.h $(DESTDIR)/usr/include/xen/hvm
$(INSTALL_DATA) include/public/COPYING $(DESTDIR)/usr/include/xen
.PHONY: _debug

30
xen-docs.diff Normal file
View File

@ -0,0 +1,30 @@
Index: xen-3.0.3-testing/docs/Makefile
===================================================================
--- xen-3.0.3-testing.orig/docs/Makefile
+++ xen-3.0.3-testing/docs/Makefile
@@ -86,13 +86,13 @@ distclean: clean
.PHONY: install
install: all
rm -rf $(DESTDIR)$(pkgdocdir)
- $(INSTALL_DIR) $(DESTDIR)$(pkgdocdir)
+ $(INSTALL_DIR) $(DESTDIR)$(pkgdocdir)/html
cp -dR ps $(DESTDIR)$(pkgdocdir)
cp -dR pdf $(DESTDIR)$(pkgdocdir)
+ cp -dR html.done/* $(DESTDIR)$(pkgdocdir)/html
$(INSTALL_DIR) $(DESTDIR)$(mandir)
cp -dR man1 $(DESTDIR)$(mandir)
cp -dR man5 $(DESTDIR)$(mandir)
- [ ! -d html ] || cp -dR html $(DESTDIR)$(pkgdocdir)
pdf/%.pdf: ps/%.ps
$(INSTALL_DIR) $(@D)
@@ -116,3 +116,9 @@ html/%/index.html: src/%.tex
$(LATEX2HTML) -split 0 -show_section_numbers -toc_depth 3 -nonavigation \
-numbered_footnotes -local_icons -noinfo -math -dir $(@D) \
$< 1>/dev/null 2>/dev/null
+ rm -rf html.done/$*/
+ mkdir -p html.done/$*/
+ cp html/$*/*.html html/$*/*.css html/$*/*.png html.done/$*/
+ ln -sf $*.html html.done/$*/index.html
+ rm -rf html/
+

View File

@ -0,0 +1,16 @@
Index: xen-unstable/tools/pygrub/src/pygrub
===================================================================
--- xen-unstable.orig/tools/pygrub/src/pygrub
+++ xen-unstable/tools/pygrub/src/pygrub
@@ -432,9 +432,9 @@ if __name__ == "__main__":
print >> sys.stderr, "Usage: %s [-q|--quiet] [--output=] [--entry=] <image>" %(sys.argv[0],)
try:
- opts, args = getopt.gnu_getopt(sys.argv[1:], 'qh::',
+ opts, args = getopt.gnu_getopt(sys.argv[1:], 'qvh::',
["quiet", "help", "output=", "entry=",
- "isconfig"])
+ "isconfig", "root=", "disks=", "verbose="])
except getopt.GetoptError:
usage()
sys.exit(1)

123
xen-domUloader.diff Normal file
View File

@ -0,0 +1,123 @@
Index: xen-3.0.3-testing/tools/python/xen/xm/create.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xm/create.py
+++ xen-3.0.3-testing/tools/python/xen/xm/create.py
@@ -126,7 +126,7 @@ gopts.var('bootloader', val='FILE',
use="Path to bootloader.")
gopts.var('bootargs', val='NAME',
- fn=set_value, default=None,
+ fn=set_value, default='',
use="Arguments to pass to boot loader")
gopts.var('bootentry', val='NAME',
@@ -649,16 +649,17 @@ def run_bootloader(vals, config_image):
err("Bootloader isn't executable")
if len(vals.disk) < 1:
err("No disks configured and boot loader requested")
- (uname, dev, mode, backend) = vals.disk[0]
- file = blkif.blkdev_uname_to_file(uname)
if vals.bootentry:
warn("The bootentry option is deprecated. Use bootargs and pass "
"--entry= directly.")
vals.bootargs = "--entry=%s" %(vals.bootentry,)
+ if vals.root:
+ vals.bootargs += " --root=%s" % vals.root.split()[0]
+ vals.bootargs += " --disks=\"%s\"" % str(vals.disk)
- return bootloader(vals.bootloader, file, not vals.console_autoconnect,
- vals.bootargs, config_image)
+ return bootloader(vals.bootloader, not vals.console_autoconnect,
+ vals.dryrun, vals.bootargs, config_image)
def make_config(vals):
"""Create the domain configuration.
Index: xen-3.0.3-testing/tools/python/xen/xend/XendBootloader.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xend/XendBootloader.py
+++ xen-3.0.3-testing/tools/python/xen/xend/XendBootloader.py
@@ -20,11 +20,9 @@ import shlex
from XendLogging import log
from XendError import VmError
-def bootloader(blexec, disk, quiet = 0, blargs = None, imgcfg = None):
- """Run the boot loader executable on the given disk and return a
- config image.
+def bootloader(blexec, quiet = 0, dryrun = 0, blargs = None, imgcfg = None):
+ """Run the boot loader executable and return a config image.
@param blexec Binary to use as the boot loader
- @param disk Disk to run the boot loader on.
@param quiet Run in non-interactive mode, just booting the default.
@param blargs Arguments to pass to the bootloader."""
@@ -32,10 +30,6 @@ def bootloader(blexec, disk, quiet = 0,
msg = "Bootloader isn't executable"
log.error(msg)
raise VmError(msg)
- if not os.access(disk, os.R_OK):
- msg = "Disk isn't accessible"
- log.error(msg)
- raise VmError(msg)
while True:
fifo = "/var/lib/xen/xenbl.%s" %(random.randint(0, 32000),)
@@ -48,10 +42,11 @@ def bootloader(blexec, disk, quiet = 0,
args = [ blexec ]
if quiet:
args.append("-q")
+ if dryrun:
+ args.append("--dryrun")
args.append("--output=%s" %(fifo,))
if blargs is not None:
args.extend(shlex.split(blargs))
- args.append(disk)
try:
os.execvp(args[0], args)
@@ -68,6 +63,7 @@ def bootloader(blexec, disk, quiet = 0,
continue
break
ret = ""
+ # TODO: Add timeout, cleanup and raise VmError if it occurs
while 1:
select.select([r], [], [])
s = os.read(r, 1024)
Index: xen-3.0.3-testing/tools/python/xen/xend/XendDomainInfo.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xend/XendDomainInfo.py
+++ xen-3.0.3-testing/tools/python/xen/xend/XendDomainInfo.py
@@ -1743,18 +1743,27 @@ class XendDomainInfo:
if not self.info['bootloader']:
return
blcfg = None
- # FIXME: this assumes that we want to use the first disk device
+ """This code is currently unneeded, but will be used
+ again when boot device selection is more dynamic.
+ vbds = []
for (n,c) in self.info['device']:
if not n or not c or not(n in ["vbd", "tap"]):
continue
disk = sxp.child_value(c, "uname")
if disk is None:
continue
- fn = blkdev_uname_to_file(disk)
- blcfg = bootloader(self.info['bootloader'], fn, 1,
- self.info['bootloader_args'],
- self.info['image'])
- break
+ vbds.append([sxp.child_value(c, "uname"),
+ sxp.child_value(c, "dev"),
+ sxp.child_value(c, "mode"),
+ sxp.child_value(c, "backend")])
+ if vbds:
+ bootargs = self.info['bootloader_args'] + \
+ " --disks=\"%s\"" % str(vbds)
+ if self.info['root']:
+ bootargs += " --root=%s" % self.info['root'].split()[0]
+ """
+ blcfg = bootloader(self.info['bootloader'], 1, 0,
+ self.info['bootloader_args'], self.info['image'])
if blcfg is None:
msg = "Had a bootloader specified, but can't find disk"
log.error(msg)

110
xen-enable-hvm-debug.diff Normal file
View File

@ -0,0 +1,110 @@
Index: xen-unstable/tools/firmware/vmxassist/vm86.c
===================================================================
--- xen-unstable.orig/tools/firmware/vmxassist/vm86.c
+++ xen-unstable/tools/firmware/vmxassist/vm86.c
@@ -38,7 +38,7 @@ unsigned prev_eip = 0;
enum vm86_mode mode;
#ifdef DEBUG
-int traceset = 0;
+int traceset = 0xffffffff;
char *states[] = {
"<VM86_REAL>",
@@ -72,6 +72,35 @@ address(struct regs *regs, unsigned seg,
return addr;
}
+void
+panic_eip(struct regs *regs, char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ printf("\n");
+ va_end(ap);
+#ifdef DEBUG
+ if (regs->eflags & EFLAGS_VM) {
+ unsigned int range = 20;
+ unsigned int eip = address(regs, regs->cs, regs->eip);
+ unsigned int start = (eip < range) ? 0 : eip - range;
+ unsigned int stop = (eip > 0x100000 - range) ? 0x100000 : eip + range;
+ int size = (stop - start);
+ unsigned int i;
+ unsigned char data[size];
+
+ printf("Dumping %x..%x eip=%x\n", start, stop, eip);
+ for (i = start; i < stop; ++i)
+ data[i-start] = *(unsigned char *) i;
+ hexdump(data, size);
+ }
+#else
+ regs = regs;
+#endif
+ halt();
+}
+
#ifdef DEBUG
void
trace(struct regs *regs, int adjust, char *fmt, ...)
@@ -1037,7 +1066,7 @@ emulate(struct regs *regs)
/* detect the case where we are not making progress */
if (nemul == 0 && prev_eip == regs->eip) {
flteip = address(regs, MASK16(regs->cs), regs->eip);
- panic("Unknown opcode at %04x:%04x=0x%x",
+ panic_eip(regs, "Unknown opcode at %04x:%04x=0x%x",
MASK16(regs->cs), regs->eip, flteip);
} else
prev_eip = regs->eip;
@@ -1061,7 +1090,7 @@ trap(int trapno, int errno, struct regs
if (regs->eflags & EFLAGS_VM) {
/* emulate any 8086 instructions */
if (mode != VM86_REAL_TO_PROTECTED)
- panic("not in real-to-protected mode");
+ panic_eip(regs, "not in real-to-protected mode");
emulate(regs);
return;
}
@@ -1071,7 +1100,7 @@ trap(int trapno, int errno, struct regs
if (regs->eflags & EFLAGS_VM) {
/* emulate any 8086 instructions */
if (mode == VM86_PROTECTED)
- panic("unexpected protected mode");
+ panic_eip(regs, "unexpected protected mode");
emulate(regs);
return;
}
Index: xen-unstable/tools/firmware/rombios/rombios.c
===================================================================
--- xen-unstable.orig/tools/firmware/rombios/rombios.c
+++ xen-unstable/tools/firmware/rombios/rombios.c
@@ -129,18 +129,18 @@
//
// BCC Bug: find a generic way to handle the bug of #asm after an "if" (fixed in 0.16.7)
-#define DEBUG_ROMBIOS 0
+#define DEBUG_ROMBIOS 1
-#define DEBUG_ATA 0
-#define DEBUG_INT13_HD 0
-#define DEBUG_INT13_CD 0
-#define DEBUG_INT13_ET 0
-#define DEBUG_INT13_FL 0
-#define DEBUG_INT15 0
-#define DEBUG_INT16 0
-#define DEBUG_INT1A 0
-#define DEBUG_INT74 0
-#define DEBUG_APM 0
+#define DEBUG_ATA 1
+#define DEBUG_INT13_HD 1
+#define DEBUG_INT13_CD 1
+#define DEBUG_INT13_ET 1
+#define DEBUG_INT13_FL 1
+#define DEBUG_INT15 1
+#define DEBUG_INT16 1
+#define DEBUG_INT1A 1
+#define DEBUG_INT74 1
+#define DEBUG_APM 1
#define BX_CPU 3
#define BX_USE_PS2_MOUSE 1

View File

@ -0,0 +1,86 @@
Index: xen-3.0.3-testing/tools/examples/xend-config.sxp
===================================================================
--- xen-3.0.3-testing.orig/tools/examples/xend-config.sxp
+++ xen-3.0.3-testing/tools/examples/xend-config.sxp
@@ -76,7 +76,8 @@
#
# (network-script 'network-bridge netdev=eth1')
#
-# The bridge is named xenbr0, by default. To rename the bridge, use
+# The bridge is named to match the outgoing interface, by default. For example,
+# eth1 is on xenbr1. To rename the bridge, use
#
# (network-script 'network-bridge bridge=<name>')
#
Index: xen-3.0.3-testing/tools/ioemu/vl.c
===================================================================
--- xen-3.0.3-testing.orig/tools/ioemu/vl.c
+++ xen-3.0.3-testing/tools/ioemu/vl.c
@@ -89,7 +89,6 @@
#include "exec-all.h"
#define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup"
-#define DEFAULT_BRIDGE "xenbr0"
//#define DEBUG_UNUSED_IOPORT
//#define DEBUG_IOPORT
@@ -3773,10 +3772,10 @@ int net_client_init(const char *str)
if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) {
pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT);
}
- if (get_param_value(bridge, sizeof(bridge), "bridge", p) == 0) {
- pstrcpy(bridge, sizeof(bridge), DEFAULT_BRIDGE);
- }
- ret = net_tap_init(vlan, ifname, setup_script, bridge);
+ if (get_param_value(bridge, sizeof(bridge), "bridge", p) == 0)
+ ret = net_tap_init(vlan, ifname, setup_script, NULL);
+ else
+ ret = net_tap_init(vlan, ifname, setup_script, bridge);
}
} else
#endif
Index: xen-3.0.3-testing/tools/python/xen/xend/image.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xend/image.py
+++ xen-3.0.3-testing/tools/python/xen/xend/image.py
@@ -339,13 +339,16 @@ class HVMImageHandler(ImageHandler):
mac = sxp.child_value(info, 'mac')
if mac == None:
mac = randomMAC()
- bridge = sxp.child_value(info, 'bridge', 'xenbr0')
+ bridge = sxp.child_value(info, 'bridge', None)
model = sxp.child_value(info, 'model', 'rtl8139')
ret.append("-net")
ret.append("nic,vlan=%d,macaddr=%s,model=%s" %
(nics, mac, model))
ret.append("-net")
- ret.append("tap,vlan=%d,bridge=%s" % (nics, bridge))
+ net = "tap,vlan=%d" % (nics,)
+ if bridge:
+ net += ",bridge=%s" % (bridge,)
+ ret.append(net)
return ret
def configVNC(self, config):
Index: xen-3.0.3-testing/tools/ioemu/target-i386-dm/qemu-ifup
===================================================================
--- xen-3.0.3-testing.orig/tools/ioemu/target-i386-dm/qemu-ifup
+++ xen-3.0.3-testing/tools/ioemu/target-i386-dm/qemu-ifup
@@ -1,10 +1,11 @@
#!/bin/sh
-#. /etc/rc.d/init.d/functions
-#ulimit -c unlimited
-
-echo -c 'config qemu network with xen bridge for '
-echo $*
+bridge=$2
+if [ -z "$bridge" ]; then
+ brnum=$(ip route list | awk '/^default / { print $NF }' | sed 's/^[^0-9]*//')
+ brnum=${brnum:-0}
+ bridge=xenbr${brnum}
+fi
ifconfig $1 0.0.0.0 up
-brctl addif $2 $1
+brctl addif $bridge $1

15
xen-hvm-default-pae.diff Normal file
View File

@ -0,0 +1,15 @@
PAE must be on for 64-on-64 to work at all.
Index: xen-3.0.3-testing/tools/python/xen/xend/image.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xend/image.py
+++ xen-3.0.3-testing/tools/python/xen/xend/image.py
@@ -263,7 +263,7 @@ class HVMImageHandler(ImageHandler):
self.dmargs += self.configVNC(imageConfig)
- self.pae = int(sxp.child_value(imageConfig, 'pae', 0))
+ self.pae = int(sxp.child_value(imageConfig, 'pae', 1))
self.acpi = int(sxp.child_value(imageConfig, 'acpi', 0))
self.apic = int(sxp.child_value(imageConfig, 'apic', 0))

18
xen-hvm-netfront.diff Normal file
View File

@ -0,0 +1,18 @@
Index: xen-3.0.3-testing/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
===================================================================
--- xen-3.0.3-testing.orig/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
+++ xen-3.0.3-testing/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
@@ -275,6 +275,13 @@ static int __devinit netfront_probe(stru
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(dev);
if (IS_ERR(netdev)) {

View File

@ -0,0 +1,680 @@
From: Jan Beulich
Bugzilla #192150
Index: xen-unstable/xen/arch/x86/domain_build.c
===================================================================
--- xen-unstable.orig/xen/arch/x86/domain_build.c
+++ xen-unstable/xen/arch/x86/domain_build.c
@@ -33,6 +33,11 @@
extern unsigned long initial_images_nrpages(void);
extern void discard_initial_images(void);
+/* I/O-port Xen-enforced or admin-specified access control. */
+struct rangeset *ioport_caps = NULL;
+/* I/O-port admin-specified non-special access requirements. */
+struct rangeset *ioport_emul = NULL;
+
static long dom0_nrpages;
/*
@@ -64,6 +69,12 @@ integer_param("dom0_max_vcpus", opt_dom0
static unsigned int opt_dom0_shadow;
boolean_param("dom0_shadow", opt_dom0_shadow);
+static char opt_ioports_noemul[200] = "";
+string_param("ioports_noemul", opt_ioports_noemul);
+
+static char opt_ioports_disable[200] = "";
+string_param("ioports_disable", opt_ioports_disable);
+
static char opt_dom0_ioports_disable[200] = "";
string_param("dom0_ioports_disable", opt_dom0_ioports_disable);
@@ -103,10 +114,10 @@ static struct page_info *alloc_chunk(str
return page;
}
-static void process_dom0_ioports_disable(void)
+static void process_ioports(char *opt)
{
unsigned long io_from, io_to;
- char *t, *u, *s = opt_dom0_ioports_disable;
+ char *t, *u, *s = opt;
if ( *s == '\0' )
return;
@@ -118,7 +129,9 @@ static void process_dom0_ioports_disable
{
parse_error:
printk("Invalid ioport range <%s> "
- "in dom0_ioports_disable, skipping\n", t);
+ "in %sioports_%s, skipping\n", t,
+ opt == opt_dom0_ioports_disable ? "dom0_" : "",
+ opt != opt_ioports_noemul ? "disable" : "noemul");
continue;
}
@@ -132,11 +145,26 @@ static void process_dom0_ioports_disable
if ( (*u != '\0') || (io_to < io_from) || (io_to >= 65536) )
goto parse_error;
- printk("Disabling dom0 access to ioport range %04lx-%04lx\n",
- io_from, io_to);
+ if ( opt != opt_ioports_noemul )
+ {
+ printk("Disabling %saccess to ioport range %04lx-%04lx\n",
+ opt != opt_ioports_disable ? "dom0 " : "",
+ io_from, io_to);
- if ( ioports_deny_access(dom0, io_from, io_to) != 0 )
- BUG();
+ if ( opt == opt_ioports_disable
+ && ioports_deny_access_all(io_from, io_to) != 0 )
+ BUG();
+ if ( ioports_deny_access(dom0, io_from, io_to) != 0 )
+ BUG();
+ }
+ else
+ {
+ printk("Setting non-emulated access for ioport range %04lx-%04lx\n",
+ io_from, io_to);
+
+ if ( ioports_set_noemul(io_from, io_to) != 0 )
+ BUG();
+ }
}
}
@@ -812,6 +840,13 @@ int construct_dom0(struct domain *d,
rc = 0;
+ /* Command-line I/O ranges. */
+ ioport_caps = rangeset_new(NULL,
+ "global I/O Port access control",
+ RANGESETF_prettyprint_hex);
+ BUG_ON(!ioport_caps);
+ rc |= ioports_permit_access_all(0, 0xFFFF);
+
/* DOM0 is permitted full I/O capabilities. */
rc |= ioports_permit_access(dom0, 0, 0xFFFF);
rc |= iomem_permit_access(dom0, 0UL, ~0UL);
@@ -821,15 +856,20 @@ int construct_dom0(struct domain *d,
* Modify I/O port access permissions.
*/
/* Master Interrupt Controller (PIC). */
+ rc |= ioports_deny_access_all(0x20, 0x21);
rc |= ioports_deny_access(dom0, 0x20, 0x21);
/* Slave Interrupt Controller (PIC). */
+ rc |= ioports_deny_access_all(0xA0, 0xA1);
rc |= ioports_deny_access(dom0, 0xA0, 0xA1);
/* Interval Timer (PIT). */
+ rc |= ioports_deny_access_all(0x40, 0x43);
rc |= ioports_deny_access(dom0, 0x40, 0x43);
/* PIT Channel 2 / PC Speaker Control. */
+ rc |= ioports_deny_access_all(0x61, 0x61);
rc |= ioports_deny_access(dom0, 0x61, 0x61);
/* Command-line I/O ranges. */
- process_dom0_ioports_disable();
+ process_ioports(opt_ioports_disable);
+ process_ioports(opt_dom0_ioports_disable);
/*
* Modify I/O memory access permissions.
@@ -848,6 +888,14 @@ int construct_dom0(struct domain *d,
rc |= iomem_deny_access(dom0, mfn, mfn);
}
+ /* Command-line I/O ranges requiring full register context access. */
+ ioport_emul = rangeset_new(NULL,
+ "I/O Port emulation control",
+ RANGESETF_prettyprint_hex);
+ BUG_ON(!ioport_emul);
+ rc |= ioports_set_emul(0, 0xFFFF);
+ process_ioports(opt_ioports_noemul);
+
BUG_ON(rc != 0);
return 0;
Index: xen-unstable/xen/arch/x86/sysctl.c
===================================================================
--- xen-unstable.orig/xen/arch/x86/sysctl.c
+++ xen-unstable/xen/arch/x86/sysctl.c
@@ -57,6 +57,23 @@ long arch_do_sysctl(
}
break;
+ case XEN_SYSCTL_ioport_emulation:
+ {
+ unsigned int fp = sysctl->u.ioport_emulation.first_port;
+ unsigned int np = sysctl->u.ioport_emulation.nr_ports;
+
+ ret = -EINVAL;
+ if ( (fp + np) > 65536 )
+ break;
+
+ if ( np == 0 )
+ ret = 0;
+ else if ( sysctl->u.ioport_emulation.emulate )
+ ret = ioports_set_emul(fp, fp + np - 1);
+ else
+ ret = ioports_set_noemul(fp, fp + np - 1);
+ }
+ break;
default:
ret = -ENOSYS;
Index: xen-unstable/xen/arch/x86/traps.c
===================================================================
--- xen-unstable.orig/xen/arch/x86/traps.c
+++ xen-unstable/xen/arch/x86/traps.c
@@ -1002,9 +1002,20 @@ static inline int admin_io_okay(
return ioports_access_permitted(v->domain, port, port + bytes - 1);
}
+typedef unsigned long io_emul_stub_t(struct cpu_user_regs *) __attribute__((__regparm__(1)));
+long io_emul_stub_offset = 0, io_emul_insn_offset = 0;
+
+/* Can the I/O access be carried out without full register context? */
+static inline int normal_io_okay(
+ unsigned int port, unsigned int bytes)
+{
+ return ioports_emul(port, port + bytes - 1);
+}
+
/* Check admin limits. Silently fail the access if it is disallowed. */
static inline unsigned char inb_user(
- unsigned int port, struct vcpu *v, struct cpu_user_regs *regs)
+ unsigned int port, io_emul_stub_t *stub,
+ struct vcpu *v, struct cpu_user_regs *regs)
{
/*
* Allow read access to port 0x61. Bit 4 oscillates with period 30us, and
@@ -1014,18 +1025,54 @@ static inline unsigned char inb_user(
* but there's not really a good reason to do so.
*/
if ( admin_io_okay(port, 1, v, regs) || (port == 0x61) )
- return inb(port);
+ return !stub || normal_io_okay(port, 1) ? inb(port) : stub(regs);
return ~0;
}
-//#define inb_user(_p, _d, _r) (admin_io_okay(_p, 1, _d, _r) ? inb(_p) : ~0)
-#define inw_user(_p, _d, _r) (admin_io_okay(_p, 2, _d, _r) ? inw(_p) : ~0)
-#define inl_user(_p, _d, _r) (admin_io_okay(_p, 4, _d, _r) ? inl(_p) : ~0)
-#define outb_user(_v, _p, _d, _r) \
- (admin_io_okay(_p, 1, _d, _r) ? outb(_v, _p) : ((void)0))
-#define outw_user(_v, _p, _d, _r) \
- (admin_io_okay(_p, 2, _d, _r) ? outw(_v, _p) : ((void)0))
-#define outl_user(_v, _p, _d, _r) \
- (admin_io_okay(_p, 4, _d, _r) ? outl(_v, _p) : ((void)0))
+
+static inline unsigned short inw_user(
+ unsigned int port, io_emul_stub_t *stub,
+ struct vcpu *v, struct cpu_user_regs *regs)
+{
+ if ( admin_io_okay(port, 2, v, regs) )
+ return !stub || normal_io_okay(port, 2) ? inw(port) : stub(regs);
+ return ~0;
+}
+
+static inline unsigned int inl_user(
+ unsigned int port, io_emul_stub_t *stub,
+ struct vcpu *v, struct cpu_user_regs *regs)
+{
+ if ( admin_io_okay(port, 4, v, regs) )
+ return !stub || normal_io_okay(port, 4) ? inl(port) : stub(regs);
+ return ~0;
+}
+
+static inline void outb_user(
+ unsigned char value, unsigned int port,
+ io_emul_stub_t *stub,
+ struct vcpu *v, struct cpu_user_regs *regs)
+{
+ if ( admin_io_okay(port, 1, v, regs) )
+ !stub || normal_io_okay(port, 1) ? outb(value, port) : (void)stub(regs);
+}
+
+static inline void outw_user(
+ unsigned short value, unsigned int port,
+ io_emul_stub_t *stub,
+ struct vcpu *v, struct cpu_user_regs *regs)
+{
+ if ( admin_io_okay(port, 2, v, regs) )
+ !stub || normal_io_okay(port, 2) ? outw(value, port) : (void)stub(regs);
+}
+
+static inline void outl_user(
+ unsigned int value, unsigned int port,
+ io_emul_stub_t *stub,
+ struct vcpu *v, struct cpu_user_regs *regs)
+{
+ if ( admin_io_okay(port, 4, v, regs) )
+ !stub || normal_io_okay(port, 4) ? outl(value, port) : (void)stub(regs);
+}
/* Instruction fetch with error handling. */
#define insn_fetch(_type, _size, cs, eip) \
@@ -1046,6 +1093,8 @@ static int emulate_privileged_op(struct
u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0;
unsigned int port, i, op_bytes = 4, data, rc;
u32 l, h;
+ io_emul_stub_t *stub;
+ char *insn;
/* Legacy prefixes. */
for ( i = 0; i < 8; i++ )
@@ -1103,13 +1152,13 @@ static int emulate_privileged_op(struct
switch ( op_bytes )
{
case 1:
- data = (u8)inb_user((u16)regs->edx, v, regs);
+ data = (u8)inb_user((u16)regs->edx, NULL, v, regs);
break;
case 2:
- data = (u16)inw_user((u16)regs->edx, v, regs);
+ data = (u16)inw_user((u16)regs->edx, NULL, v, regs);
break;
case 4:
- data = (u32)inl_user((u16)regs->edx, v, regs);
+ data = (u32)inl_user((u16)regs->edx, NULL, v, regs);
break;
}
if ( (rc = copy_to_user((void *)regs->edi, &data, op_bytes)) != 0 )
@@ -1135,13 +1184,13 @@ static int emulate_privileged_op(struct
switch ( op_bytes )
{
case 1:
- outb_user((u8)data, (u16)regs->edx, v, regs);
+ outb_user((u8)data, (u16)regs->edx, NULL, v, regs);
break;
case 2:
- outw_user((u16)data, (u16)regs->edx, v, regs);
+ outw_user((u16)data, (u16)regs->edx, NULL, v, regs);
break;
case 4:
- outl_user((u32)data, (u16)regs->edx, v, regs);
+ outl_user((u32)data, (u16)regs->edx, NULL, v, regs);
break;
}
regs->esi += (int)((regs->eflags & EF_DF) ? -op_bytes : op_bytes);
@@ -1159,27 +1208,33 @@ static int emulate_privileged_op(struct
}
/* I/O Port and Interrupt Flag instructions. */
+ insn = (char *)get_stack_bottom();
+ stub = (io_emul_stub_t *)(insn + io_emul_stub_offset);
+ insn += io_emul_insn_offset;
+ *insn++ = op_bytes != 2 ? 0x90 : 0x66;
+ *insn++ = opcode;
switch ( opcode )
{
case 0xe4: /* IN imm8,%al */
op_bytes = 1;
case 0xe5: /* IN imm8,%eax */
port = insn_fetch(u8, 1, cs, eip);
+ *insn = port;
exec_in:
if ( !guest_io_okay(port, op_bytes, v, regs) )
goto fail;
switch ( op_bytes )
{
case 1:
- regs->eax &= ~0xffUL;
- regs->eax |= (u8)inb_user(port, v, regs);
+ res = regs->eax & ~0xffUL;
+ regs->eax = res | (u8)inb_user(port, stub, v, regs);
break;
case 2:
- regs->eax &= ~0xffffUL;
- regs->eax |= (u16)inw_user(port, v, regs);
+ res = regs->eax & ~0xffffUL;
+ regs->eax = res | (u16)inw_user(port, stub, v, regs);
break;
case 4:
- regs->eax = (u32)inl_user(port, v, regs);
+ regs->eax = (u32)inl_user(port, stub, v, regs);
break;
}
goto done;
@@ -1188,25 +1243,27 @@ static int emulate_privileged_op(struct
op_bytes = 1;
case 0xed: /* IN %dx,%eax */
port = (u16)regs->edx;
+ *insn = 0x90;
goto exec_in;
case 0xe6: /* OUT %al,imm8 */
op_bytes = 1;
case 0xe7: /* OUT %eax,imm8 */
port = insn_fetch(u8, 1, cs, eip);
+ *insn = port;
exec_out:
if ( !guest_io_okay(port, op_bytes, v, regs) )
goto fail;
switch ( op_bytes )
{
case 1:
- outb_user((u8)regs->eax, port, v, regs);
+ outb_user((u8)regs->eax, port, stub, v, regs);
break;
case 2:
- outw_user((u16)regs->eax, port, v, regs);
+ outw_user((u16)regs->eax, port, stub, v, regs);
break;
case 4:
- outl_user((u32)regs->eax, port, v, regs);
+ outl_user((u32)regs->eax, port, stub, v, regs);
break;
}
goto done;
@@ -1215,6 +1272,7 @@ static int emulate_privileged_op(struct
op_bytes = 1;
case 0xef: /* OUT %eax,%dx */
port = (u16)regs->edx;
+ *insn = 0x90;
goto exec_out;
case 0xfa: /* CLI */
Index: xen-unstable/xen/arch/x86/x86_32/Makefile
===================================================================
--- xen-unstable.orig/xen/arch/x86/x86_32/Makefile
+++ xen-unstable/xen/arch/x86/x86_32/Makefile
@@ -1,5 +1,6 @@
obj-y += domain_page.o
obj-y += entry.o
+obj-y += io.o
obj-y += mm.o
obj-y += seg_fixup.o
obj-y += traps.o
Index: xen-unstable/xen/arch/x86/x86_32/io.S
===================================================================
--- /dev/null
+++ xen-unstable/xen/arch/x86/x86_32/io.S
@@ -0,0 +1,42 @@
+/*
+ * Special (full-context) I/O handling routines.
+ *
+ * Copyright (c) 2006, Novell, Inc.
+ */
+
+#include <xen/config.h>
+#include <asm/asm_defns.h>
+
+ENTRY(save_host_restore_guest)
+ movl (%esp), %ecx
+ movl %eax, (%esp)
+ movl UREGS_edx(%eax), %edx
+ pushl %ebx
+ movl UREGS_ebx(%eax), %ebx
+ pushl %ebp
+ movl UREGS_ebp(%eax), %ebp
+ pushl %esi
+ movl UREGS_esi(%eax), %esi
+ pushl %edi
+ movl UREGS_edi(%eax), %edi
+ pushl %ecx
+ movl UREGS_ecx(%eax), %ecx
+ movl UREGS_eax(%eax), %eax
+ ret
+
+ENTRY(save_guest_restore_host)
+ pushl %edx
+ movl 5*4(%esp), %edx
+ movl %eax, UREGS_eax(%edx)
+ popl UREGS_edx(%edx)
+ movl %edi, UREGS_edi(%edx)
+ popl %edi
+ movl %esi, UREGS_esi(%edx)
+ popl %esi
+ movl %ebp, UREGS_ebp(%edx)
+ popl %ebp
+ movl %ebx, UREGS_ebx(%edx)
+ popl %ebx
+ movl %ecx, UREGS_ecx(%edx)
+ popl %ecx
+ ret
Index: xen-unstable/xen/arch/x86/x86_32/traps.c
===================================================================
--- xen-unstable.orig/xen/arch/x86/x86_32/traps.c
+++ xen-unstable/xen/arch/x86/x86_32/traps.c
@@ -13,6 +13,7 @@
#include <xen/nmi.h>
#include <asm/current.h>
#include <asm/flushtlb.h>
+#include <asm/io.h>
#include <asm/hvm/hvm.h>
#include <asm/hvm/support.h>
@@ -250,6 +251,7 @@ fastcall void smp_deferred_nmi(struct cp
void __init percpu_traps_init(void)
{
struct tss_struct *tss = &doublefault_tss;
+ char *stack_bottom, *stack;
asmlinkage int hypercall(void);
if ( smp_processor_id() != 0 )
@@ -283,6 +285,28 @@ void __init percpu_traps_init(void)
(unsigned long)tss, 235, 9);
set_task_gate(TRAP_double_fault, __DOUBLEFAULT_TSS_ENTRY<<3);
+
+ /*
+ * Stub for full-context I/O emulation.
+ */
+ stack_bottom = (char *)get_stack_bottom();
+ stack = (char *)((unsigned long)stack_bottom & ~(STACK_SIZE - 1));
+ if ( !io_emul_stub_offset )
+ io_emul_stub_offset = stack - stack_bottom;
+ else
+ BUG_ON(io_emul_stub_offset != stack - stack_bottom);
+ /* call save_host_restore_guest */
+ stack[0] = 0xe8;
+ *(s32*)&stack[1] = (char *)save_host_restore_guest - &stack[5];
+ stack += 5;
+ if ( !io_emul_insn_offset )
+ io_emul_insn_offset = stack - stack_bottom;
+ else
+ BUG_ON(io_emul_insn_offset != stack - stack_bottom);
+ stack += 3; /* operand size prefix, opcode, immediate */
+ /* jmp save_guest_restore_host */
+ stack[0] = 0xe9;
+ *(s32*)&stack[1] = (char *)save_guest_restore_host - &stack[5];
}
void init_int80_direct_trap(struct vcpu *v)
Index: xen-unstable/xen/arch/x86/x86_64/Makefile
===================================================================
--- xen-unstable.orig/xen/arch/x86/x86_64/Makefile
+++ xen-unstable/xen/arch/x86/x86_64/Makefile
@@ -1,3 +1,4 @@
obj-y += entry.o
+obj-y += io.o
obj-y += mm.o
obj-y += traps.o
Index: xen-unstable/xen/arch/x86/x86_64/io.S
===================================================================
--- /dev/null
+++ xen-unstable/xen/arch/x86/x86_64/io.S
@@ -0,0 +1,62 @@
+/*
+ * Special (full-context) I/O handling routines.
+ *
+ * Copyright (c) 2006, Novell, Inc.
+ */
+
+#include <xen/config.h>
+#include <asm/asm_defns.h>
+
+ENTRY(save_host_restore_guest)
+ movq (%rsp), %rcx
+ movq %rdi, (%rsp)
+ movq UREGS_rdx(%rdi), %rdx
+ pushq %rbx
+ movq UREGS_rax(%rdi), %rax
+ movq UREGS_rbx(%rdi), %rbx
+ pushq %rbp
+ movq UREGS_rsi(%rdi), %rsi
+ movq UREGS_rbp(%rdi), %rbp
+ pushq %r12
+ movq UREGS_r8(%rdi), %r8
+ movq UREGS_r12(%rdi), %r12
+ pushq %r13
+ movq UREGS_r9(%rdi), %r9
+ movq UREGS_r13(%rdi), %r13
+ pushq %r14
+ movq UREGS_r10(%rdi), %r10
+ movq UREGS_r14(%rdi), %r14
+ pushq %r15
+ movq UREGS_r11(%rdi), %r11
+ movq UREGS_r15(%rdi), %r15
+ pushq %rcx
+ movq UREGS_rcx(%rdi), %rcx
+ movq UREGS_rdi(%rdi), %rdi
+ ret
+
+ENTRY(save_guest_restore_host)
+ pushq %rdi
+ movq 7*8(%rsp), %rdi
+ movq %rax, UREGS_rax(%rdi)
+ popq UREGS_rdi(%rdi)
+ movq %r15, UREGS_r15(%rdi)
+ movq %r11, UREGS_r11(%rdi)
+ popq %r15
+ movq %r14, UREGS_r14(%rdi)
+ movq %r10, UREGS_r10(%rdi)
+ popq %r14
+ movq %r13, UREGS_r13(%rdi)
+ movq %r9, UREGS_r9(%rdi)
+ popq %r13
+ movq %r12, UREGS_r12(%rdi)
+ movq %r8, UREGS_r8(%rdi)
+ popq %r12
+ movq %rbp, UREGS_rbp(%rdi)
+ movq %rsi, UREGS_rsi(%rdi)
+ popq %rbp
+ movq %rbx, UREGS_rbx(%rdi)
+ movq %rdx, UREGS_rdx(%rdi)
+ popq %rbx
+ movq %rcx, UREGS_rcx(%rdi)
+ popq %rcx
+ ret
Index: xen-unstable/xen/arch/x86/x86_64/traps.c
===================================================================
--- xen-unstable.orig/xen/arch/x86/x86_64/traps.c
+++ xen-unstable/xen/arch/x86/x86_64/traps.c
@@ -14,6 +14,7 @@
#include <xen/nmi.h>
#include <asm/current.h>
#include <asm/flushtlb.h>
+#include <asm/io.h>
#include <asm/msr.h>
#include <asm/page.h>
#include <asm/shadow.h>
@@ -337,6 +338,29 @@ void __init percpu_traps_init(void)
wrmsr(MSR_STAR, 0, (FLAT_RING3_CS32<<16) | __HYPERVISOR_CS);
wrmsr(MSR_SYSCALL_MASK, EF_VM|EF_RF|EF_NT|EF_DF|EF_IE|EF_TF, 0U);
+
+ /*
+ * Stub for full-context I/O emulation.
+ */
+
+ /* Skip the compatibility-mode entry trampoline. */
+ stack += 26;
+ if ( !io_emul_stub_offset )
+ io_emul_stub_offset = stack - stack_bottom;
+ else
+ BUG_ON(io_emul_stub_offset != stack - stack_bottom);
+ /* call save_host_restore_guest */
+ stack[0] = 0xe8;
+ *(s32*)&stack[1] = (char *)save_host_restore_guest - &stack[5];
+ stack += 5;
+ if ( !io_emul_insn_offset )
+ io_emul_insn_offset = stack - stack_bottom;
+ else
+ BUG_ON(io_emul_insn_offset != stack - stack_bottom);
+ stack += 3; /* operand size prefix, opcode, immediate */
+ /* jmp save_guest_restore_host */
+ stack[0] = 0xe9;
+ *(s32*)&stack[1] = (char *)save_guest_restore_host - &stack[5];
}
static long register_guest_callback(struct callback_register *reg)
Index: xen-unstable/xen/include/asm-x86/io.h
===================================================================
--- xen-unstable.orig/xen/include/asm-x86/io.h
+++ xen-unstable/xen/include/asm-x86/io.h
@@ -50,4 +50,10 @@ __OUT(b,"b",char)
__OUT(w,"w",short)
__OUT(l,,int)
+struct cpu_user_regs;
+void save_host_restore_guest(struct cpu_user_regs *) __attribute__((__regparm__(1)));
+unsigned long save_guest_restore_host(unsigned long) __attribute__((__regparm__(1)));
+
+extern long io_emul_stub_offset, io_emul_insn_offset;
+
#endif
Index: xen-unstable/xen/include/asm-x86/iocap.h
===================================================================
--- xen-unstable.orig/xen/include/asm-x86/iocap.h
+++ xen-unstable/xen/include/asm-x86/iocap.h
@@ -7,6 +7,15 @@
#ifndef __X86_IOCAP_H__
#define __X86_IOCAP_H__
+extern struct rangeset *ioport_caps, *ioport_emul;
+
+#define ioports_permit_access_all(s, e) \
+ rangeset_add_range(ioport_caps, s, e)
+#define ioports_deny_access_all(s, e) \
+ rangeset_remove_range(ioport_caps, s, e)
+#define ioports_any_access_permitted(s, e) \
+ rangeset_contains_range(ioport_caps, s, e)
+
#define ioports_permit_access(d, s, e) \
rangeset_add_range((d)->arch.ioport_caps, s, e)
#define ioports_deny_access(d, s, e) \
@@ -14,6 +23,13 @@
#define ioports_access_permitted(d, s, e) \
rangeset_contains_range((d)->arch.ioport_caps, s, e)
+#define ioports_set_emul(s, e) \
+ rangeset_add_range(ioport_emul, s, e)
+#define ioports_set_noemul(s, e) \
+ rangeset_remove_range(ioport_emul, s, e)
+#define ioports_emul(s, e) \
+ rangeset_contains_range(ioport_emul, s, e)
+
#define cache_flush_permitted(d) \
(!rangeset_is_empty((d)->iomem_caps))
Index: xen-unstable/xen/include/public/sysctl.h
===================================================================
--- xen-unstable.orig/xen/include/public/sysctl.h
+++ xen-unstable/xen/include/public/sysctl.h
@@ -122,6 +122,15 @@ struct xen_sysctl_getdomaininfolist {
typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
+#define XEN_SYSCTL_ioport_emulation 7
+struct xen_sysctl_ioport_emulation {
+ uint32_t first_port; /* first port int range */
+ uint32_t nr_ports; /* size of port range */
+ uint8_t emulate; /* emulate access to range? */
+};
+typedef struct xen_sysctl_ioport_emulation xen_sysctl_ioport_emulation_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_ioport_emulation_t);
+
struct xen_sysctl {
uint32_t cmd;
uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
@@ -132,6 +141,7 @@ struct xen_sysctl {
struct xen_sysctl_sched_id sched_id;
struct xen_sysctl_perfc_op perfc_op;
struct xen_sysctl_getdomaininfolist getdomaininfolist;
+ struct xen_sysctl_ioport_emulation ioport_emulation;
uint8_t pad[128];
} u;
};

View File

@ -0,0 +1,25 @@
Change default IO-APIC ack mode for single IO-APIC systems to old-style. Jan
Index: xen-unstable/xen/arch/x86/io_apic.c
===================================================================
--- xen-unstable.orig/xen/arch/x86/io_apic.c
+++ xen-unstable/xen/arch/x86/io_apic.c
@@ -1342,7 +1342,7 @@ static unsigned int startup_level_ioapic
return 0; /* don't check for pending */
}
-int ioapic_ack_new = 1;
+int ioapic_ack_new = -1;
static void setup_ioapic_ack(char *s)
{
if ( !strcmp(s, "old") )
@@ -1779,6 +1779,8 @@ void __init setup_IO_APIC(void)
else
io_apic_irqs = ~PIC_IRQS;
+ if (ioapic_ack_new < 0)
+ ioapic_ack_new = (nr_ioapics > 1);
printk("ENABLING IO-APIC IRQs\n");
printk(" -> Using %s ACK method\n", ioapic_ack_new ? "new" : "old");

47
xen-keymap.diff Normal file
View File

@ -0,0 +1,47 @@
Index: xen-3.0.3-testing/tools/python/xen/xm/create.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xm/create.py
+++ xen-3.0.3-testing/tools/python/xen/xm/create.py
@@ -428,6 +428,10 @@ gopts.var('sdl', val='',
fn=set_value, default=None,
use="""Should the device model use SDL?""")
+gopts.var('keymap', val='',
+ fn=set_value, default=None,
+ use="""Keyboard mapping for SDL/VNC""")
+
gopts.var('display', val='DISPLAY',
fn=set_value, default=None,
use="X11 display to use")
@@ -639,7 +643,7 @@ def configure_hvm(config_image, vals):
'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'vnclisten',
'sdl', 'display', 'xauthority',
- 'acpi', 'apic', 'usb', 'usbdevice' ]
+ 'acpi', 'apic', 'usb', 'usbdevice', 'keymap' ]
for a in args:
if (vals.__dict__[a]):
config_image.append([a, vals.__dict__[a]])
Index: xen-3.0.3-testing/tools/python/xen/xend/image.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xend/image.py
+++ xen-3.0.3-testing/tools/python/xen/xend/image.py
@@ -352,6 +352,10 @@ class HVMImageHandler(ImageHandler):
if nographic:
ret.append('-nographic')
return ret
+ keymap = sxp.child_value(config, 'keymap')
+ if not keymap:
+ keymap = "en-us"
+ ret += ['-k', keymap]
if vnc:
vncdisplay = sxp.child_value(config, 'vncdisplay',
int(self.vm.getDomid()))
@@ -360,7 +364,6 @@ class HVMImageHandler(ImageHandler):
ret += ['-vncunused']
else:
ret += ['-vnc', '%d' % vncdisplay]
- ret += ['-k', 'en-us']
vnclisten = sxp.child_value(config, 'vnclisten')
if not(vnclisten):
vnclisten = xen.xend.XendRoot.instance().get_vnclisten_address()

20
xen-lost-mouse.diff Normal file
View File

@ -0,0 +1,20 @@
From: ?
Upstream: xen-unstable
SIGKILL causes atexit to not be called, so mouse SDL cleanup wasn't
performed, so mouse wasn't released.
Index: xen-unstable/tools/python/xen/xend/image.py
===================================================================
--- xen-unstable.orig/tools/python/xen/xend/image.py
+++ xen-unstable/tools/python/xen/xend/image.py
@@ -412,7 +412,7 @@ class HVMImageHandler(ImageHandler):
import signal
if not self.pid:
return
- os.kill(self.pid, signal.SIGKILL)
+ os.kill(self.pid, signal.SIGTERM)
os.waitpid(self.pid, 0)
self.pid = 0

View File

@ -0,0 +1,47 @@
Index: xen-unstable/xen/arch/x86/x86_32/mm.c
===================================================================
--- xen-unstable.orig/xen/arch/x86/x86_32/mm.c
+++ xen-unstable/xen/arch/x86/x86_32/mm.c
@@ -62,6 +62,8 @@ l2_pgentry_t *virt_to_xen_l2e(unsigned l
return &idle_pg_table_l2[l2_linear_offset(v)];
}
+extern unsigned long lowmem_emergency_pool_pages;
+
void __init paging_init(void)
{
void *ioremap_pt;
@@ -129,6 +131,20 @@ void __init setup_idle_pagetable(void)
l2e_from_page(virt_to_page(idle_vcpu[0]->domain->
arch.mm_perdomain_pt) + i,
__PAGE_HYPERVISOR);
+
+ /*
+ * Size the lowmem_emergency_pool based on the total memory on the box
+ * This pool is needed only on 32 bit PAE configurations (4g to 16g).
+ */
+ if (lowmem_emergency_pool_pages)
+ return;
+
+ if (total_pages > (4 * 1024 * 1024))
+ lowmem_emergency_pool_pages = 12000;
+ else if (total_pages > (2 * 1024 * 1024))
+ lowmem_emergency_pool_pages = 8000;
+ else if (total_pages > (1 * 1024 * 1024) || max_page >= (1 * 1024 * 1024))
+ lowmem_emergency_pool_pages = 4000;
}
void __init zap_low_mappings(l2_pgentry_t *base)
Index: xen-unstable/xen/common/page_alloc.c
===================================================================
--- xen-unstable.orig/xen/common/page_alloc.c
+++ xen-unstable/xen/common/page_alloc.c
@@ -47,7 +47,7 @@ string_param("badpage", opt_badpage);
* allocation requests. Ordinary requests will not fall back to the
* lowmem emergency pool.
*/
-static unsigned long lowmem_emergency_pool_pages;
+unsigned long lowmem_emergency_pool_pages;
static void parse_lowmem_emergency_pool(char *s)
{
unsigned long long bytes;

13
xen-man-permissions.patch Normal file
View File

@ -0,0 +1,13 @@
Index: xen-3.0.3-testing/tools/ioemu/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/ioemu/Makefile
+++ xen-3.0.3-testing/tools/ioemu/Makefile
@@ -68,7 +68,7 @@ install-doc: $(DOCS)
$(INSTALL) -m 644 qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
ifndef CONFIG_WIN32
mkdir -p "$(DESTDIR)$(mandir)/man1"
- $(INSTALL) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
+ $(INSTALL) -m 644 qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
endif
install: all $(if $(BUILD_DOCS),install-doc)

43
xen-man-xm-bad-char.diff Normal file
View File

@ -0,0 +1,43 @@
Index: xen-3.0.3-testing/docs/man/xm.pod.1
===================================================================
--- xen-3.0.3-testing.orig/docs/man/xm.pod.1
+++ xen-3.0.3-testing/docs/man/xm.pod.1
@@ -554,29 +554,29 @@ B<EXAMPLES>
I<normal EDF (20ms/5ms):>
xm sched-sedf <dom-id> 20000000 5000000 0 0 0
-
+
I<best-effort domains (i.e. non-realtime):>
xm sched-sedf <dom-id> 20000000 0 0 1 0
- 
+
I<normal EDF (20ms/5ms) + share of extra-time:>
- 
+
xm sched-sedf <dom-id> 20000000 5000000 0 1 0
I<4 domains with weights 2:3:4:2>
xm sched-sedf <d1> 0 0 0 0 2
-  xm sched-sedf <d2> 0 0 0 0 3
-  xm sched-sedf <d3> 0 0 0 0 4
-  xm sched-sedf <d4> 0 0 0 0 2
+ xm sched-sedf <d2> 0 0 0 0 3
+ xm sched-sedf <d3> 0 0 0 0 4
+ xm sched-sedf <d4> 0 0 0 0 2
I<1 fully-specified (10ms/3ms) domain, 3 other domains share available
rest in 2:7:3 ratio:>
- xm sched-sedf <d1> 10000000 3000000 0 0 0  
- xm sched-sedf <d2> 0 0 0 0 2  
+ xm sched-sedf <d1> 10000000 3000000 0 0 0
+ xm sched-sedf <d2> 0 0 0 0 2
xm sched-sedf <d3> 0 0 0 0 7
-   xm sched-sedf <d4> 0 0 0 0 3
+ xm sched-sedf <d4> 0 0 0 0 3
=back

134
xen-max-free-mem.diff Normal file
View File

@ -0,0 +1,134 @@
Index: xen-3.0.3-testing/tools/python/xen/xend/XendNode.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xend/XendNode.py
+++ xen-3.0.3-testing/tools/python/xen/xend/XendNode.py
@@ -59,9 +59,34 @@ class XendNode:
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
+ import XendRoot
+ configured_floor = XendRoot.instance().get_dom0_min_mem() * 1024
+ from xen.xend import balloon
+ try:
+ kernel_floor = balloon.get_dom0_min_target()
+ except:
+ kernel_floor = 0
+ dom0_min_mem = max(configured_floor, kernel_floor)
+ dom0_mem = balloon.get_dom0_current_alloc()
+ extra_mem = 0
+ if dom0_min_mem > 0 and dom0_mem > dom0_min_mem:
+ extra_mem = dom0_mem - dom0_min_mem
+ info['free_memory'] = info['free_memory'] + info['scrub_memory']
+ info['max_free_memory'] = info['free_memory'] + extra_mem
+
+ # Convert KiB to MiB, rounding down to be conservative
+ info['total_memory'] = info['total_memory'] / 1024
+ info['free_memory'] = info['free_memory'] / 1024
+ info['max_free_memory'] = info['max_free_memory'] / 1024
+
+ # FIXME: These are hard-coded to be the inverse of the getXenMemory
+ # functions in image.py. Find a cleaner way.
+ info['max_para_memory'] = info['max_free_memory'] - 4
+ if info['max_para_memory'] < 0:
+ info['max_para_memory'] = 0
+ info['max_hvm_memory'] = int((info['max_free_memory']-12) * (1-2.4/1024))
+ if info['max_hvm_memory'] < 0:
+ info['max_hvm_memory'] = 0
ITEM_ORDER = ['nr_cpus',
'nr_nodes',
@@ -72,6 +97,9 @@ class XendNode:
'hw_caps',
'total_memory',
'free_memory',
+ 'max_free_memory',
+ 'max_para_memory',
+ 'max_hvm_memory',
]
return [[k, info[k]] for k in ITEM_ORDER]
Index: xen-3.0.3-testing/tools/python/xen/xend/balloon.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xend/balloon.py
+++ xen-3.0.3-testing/tools/python/xen/xend/balloon.py
@@ -43,6 +43,8 @@ SLEEP_TIME_GROWTH = 0.1
# label actually shown in the PROC_XEN_BALLOON file.
labels = { 'current' : 'Current allocation',
'target' : 'Requested target',
+ 'min-target' : 'Minimum target',
+ 'max-target' : 'Maximum target',
'low-balloon' : 'Low-mem balloon',
'high-balloon' : 'High-mem balloon',
'limit' : 'Xen hard limit' }
@@ -81,6 +83,23 @@ def get_dom0_target_alloc():
raise VmError('Failed to query target memory allocation of dom0.')
return kb
+def get_dom0_min_target():
+ """Returns the minimum amount of memory (in KiB) that dom0 will accept."""
+
+ kb = _get_proc_balloon(labels['min-target'])
+ if kb == None:
+ raise VmError('Failed to query minimum target memory allocation of dom0.')
+ return kb
+
+def get_dom0_max_target():
+ """Returns the maximum amount of memory (in KiB) that is potentially
+ visible to dom0."""
+
+ kb = _get_proc_balloon(labels['max-target'])
+ if kb == None:
+ raise VmError('Failed to query maximum target memory allocation of dom0.')
+ return kb
+
def free(need_mem):
"""Balloon out memory from the privileged domain so that there is the
specified required amount (in KiB) free.
Index: xen-3.0.3-testing/tools/python/xen/xend/XendDomainInfo.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xend/XendDomainInfo.py
+++ xen-3.0.3-testing/tools/python/xen/xend/XendDomainInfo.py
@@ -1005,6 +1005,27 @@ class XendDomainInfo:
## public:
+ def capAndSetMemoryTarget(self, target):
+ """Potentially lowers the requested target to the largest possible
+ value (i.e., caps it), and then sets the memory target of this domain
+ to that value.
+ @param target in MiB.
+ """
+ max_target = 0
+ if self.domid == 0:
+ try:
+ from balloon import get_dom0_max_target
+ max_target = get_dom0_max_target() / 1024
+ except:
+ # It's nice to cap the max at sane values, but harmless to set
+ # them high. Carry on.
+ pass
+ if max_target and target > max_target:
+ log.debug("Requested memory target %d MiB; maximum reasonable is %d MiB.",
+ target, max_target)
+ target = max_target
+ self.setMemoryTarget(target)
+
def setMemoryTarget(self, target):
"""Set the memory target of this domain.
@param target In MiB.
Index: xen-3.0.3-testing/tools/python/xen/xend/server/SrvDomain.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/xend/server/SrvDomain.py
+++ xen-3.0.3-testing/tools/python/xen/xend/server/SrvDomain.py
@@ -147,7 +147,7 @@ class SrvDomain(SrvDir):
def op_mem_target_set(self, _, req):
- return self.call(self.dom.setMemoryTarget,
+ return self.call(self.dom.capAndSetMemoryTarget,
[['target', 'int']],
req)

33
xen-messages.diff Normal file
View File

@ -0,0 +1,33 @@
Index: xen-unstable/tools/misc/xend
===================================================================
--- xen-unstable.orig/tools/misc/xend
+++ xen-unstable/tools/misc/xend
@@ -64,14 +64,7 @@ def check_logging():
try:
import logging
except ImportError:
- hline()
- msg("Python logging is not installed.")
- msg("Use 'make install-logging' at the xen root to install.")
- msg("")
- msg("Alternatively download and install from")
- msg("http://www.red-dove.com/python_logging.html")
- hline()
- raise CheckError("logging is not installed")
+ raise CheckError("logging is not installed; try Python 2.3 or later")
def check_user():
"""Check that the effective user id is 0 (root).
Index: xen-unstable/tools/python/xen/xend/XendDomain.py
===================================================================
--- xen-unstable.orig/tools/python/xen/xend/XendDomain.py
+++ xen-unstable/tools/python/xen/xend/XendDomain.py
@@ -467,6 +467,8 @@ class XendDomain:
if dominfo.getDomid() == PRIV_DOMAIN:
raise XendError("Cannot save privileged domain %s" % domid)
+ if dominfo.readVm('image/ostype') == "hvm":
+ raise XendError("Cannot save fully virtualized domains")
fd = os.open(dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
try:

168
xen-network-bridge.diff Normal file
View File

@ -0,0 +1,168 @@
Index: xen-3.0.3-testing/tools/examples/network-bridge
===================================================================
--- xen-3.0.3-testing.orig/tools/examples/network-bridge
+++ xen-3.0.3-testing/tools/examples/network-bridge
@@ -69,23 +69,6 @@ pdev="p${netdev}"
vdev="veth${vifnum}"
vif0="vif0.${vifnum}"
-get_ip_info() {
- addr_pfx=`ip addr show dev $1 | egrep '^ *inet' | sed -e 's/ *inet //' -e 's/ .*//'`
- gateway=`ip route show dev $1 | fgrep default | sed 's/default via //'`
-}
-
-do_ifup() {
- if ! ifup $1 ; then
- if [ ${addr_pfx} ] ; then
- # use the info from get_ip_info()
- ip addr flush $1
- ip addr add ${addr_pfx} dev $1
- ip link set dev $1 up
- [ ${gateway} ] && ip route add default via ${gateway}
- fi
- fi
-}
-
# Usage: transfer_addrs src dst
# Copy all IP addresses (including aliases) from device $src to device $dst.
transfer_addrs () {
@@ -204,14 +187,10 @@ using loopback.nloopbacks=<N> on the dom
if link_exists "$vdev"; then
mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
- preiftransfer ${netdev}
+ ifup ${netdev} # To ensure there is an IP to transfer
+ preiftransfer
transfer_addrs ${netdev} ${vdev}
- if ! ifdown ${netdev}; then
- # If ifdown fails, remember the IP details.
- get_ip_info ${netdev}
- ip link set ${netdev} down
- ip addr flush ${netdev}
- fi
+ ifdown ${netdev}
ip link set ${netdev} name ${pdev}
ip link set ${vdev} name ${netdev}
@@ -222,7 +201,8 @@ using loopback.nloopbacks=<N> on the dom
ip link set ${bridge} up
add_to_bridge ${bridge} ${vif0}
add_to_bridge2 ${bridge} ${pdev}
- do_ifup ${netdev}
+ ip link set ${netdev} up
+ ifup ${hwddev}
else
# old style without ${vdev}
transfer_addrs ${netdev} ${bridge}
@@ -246,9 +226,7 @@ op_stop () {
ip link set dev ${vif0} down
mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
transfer_addrs ${netdev} ${pdev}
- if ! ifdown ${netdev}; then
- get_ip_info ${netdev}
- fi
+ ifdown ${netdev}
ip link set ${netdev} down arp off
ip link set ${netdev} addr fe:ff:ff:ff:ff:ff
ip link set ${pdev} down
@@ -261,7 +239,7 @@ op_stop () {
ip link set ${netdev} name ${vdev}
ip link set ${pdev} name ${netdev}
- do_ifup ${netdev}
+ ifup ${netdev}
else
transfer_routes ${bridge} ${netdev}
ip link set ${bridge} down
Index: xen-3.0.3-testing/tools/examples/xen-network-common.sh
===================================================================
--- xen-3.0.3-testing.orig/tools/examples/xen-network-common.sh
+++ xen-3.0.3-testing/tools/examples/xen-network-common.sh
@@ -16,57 +16,33 @@
#
-# On SuSE it is necessary to run a command before transfering addresses and
-# routes from the physical interface to the virtual. This command creates a
-# variable $HWD_CONFIG_0 that specifies the appropriate configuration for
-# ifup.
+# Reads the global variable "netdev" (which is the kernel interface name,
+# e.g., "eth0") and sets the global variable "hwddev" (which is the persistent
+# interface name, e.g., "eth-id-00:e0:81:54:12:34").
-# Gentoo doesn't have ifup/ifdown, so we define appropriate alternatives.
-
-# Other platforms just use ifup / ifdown directly.
+preiftransfer()
+{
+ local HWD_CONFIG_0
+ eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- "$netdev" | grep HWD_CONFIG_0=`
+ if [ -n "$HWD_CONFIG_0" ]; then
+ hwddev="$HWD_CONFIG_0"
+ fi
+}
-##
-# preiftransfer
-#
-# @param $1 The current name for the physical device, which is also the name
-# that the virtual device will take once the physical device has
-# been renamed.
-
-if [ -e /etc/SuSE-release ]
-then
- preiftransfer()
- {
- eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- $1`
- }
- ifup()
- {
- /sbin/ifup ${HWD_CONFIG_0} $1
- }
-elif ! which ifup >/dev/null 2>/dev/null
-then
- preiftransfer()
- {
- true
- }
- ifup()
- {
- false
- }
- ifdown()
- {
- false
- }
-else
- preiftransfer()
- {
- true
- }
-fi
+ifup()
+{
+ /sbin/ifup $1 -o rc || true
+}
+ifdown()
+{
+ /sbin/ifdown $1 -o rc
+}
first_file()
{
- t="$1"
+ local t="$1"
+ local file
shift
for file in $@
do
@@ -80,7 +56,7 @@ first_file()
find_dhcpd_conf_file()
{
- first_file -f /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf
+ first_file -f /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf /etc/dhcpd.conf.pxe
}

15
xen-no-dummy-nfs-ip.diff Normal file
View File

@ -0,0 +1,15 @@
Index: xen-unstable/tools/python/xen/xm/create.py
===================================================================
--- xen-unstable.orig/tools/python/xen/xm/create.py
+++ xen-unstable/tools/python/xen/xm/create.py
@@ -808,9 +808,8 @@ def preprocess_access_control(vals):
def preprocess_ip(vals):
if vals.ip or vals.dhcp != 'off':
- dummy_nfs_server = '1.2.3.4'
ip = (vals.ip
- + ':' + (vals.nfs_server or dummy_nfs_server)
+ + ':' + (vals.nfs_server or '')
+ ':' + vals.gateway
+ ':' + vals.netmask
+ ':' + vals.hostname

69
xen-paths.diff Normal file
View File

@ -0,0 +1,69 @@
Index: xen-unstable/tools/python/xen/xm/create.py
===================================================================
--- xen-unstable.orig/tools/python/xen/xm/create.py
+++ xen-unstable/tools/python/xen/xm/create.py
@@ -64,7 +64,7 @@ gopts.opt('quiet', short='q',
use="Quiet.")
gopts.opt('path', val='PATH',
- fn=set_value, default='.:/etc/xen',
+ fn=set_value, default='.:/etc/xen/vm',
use="Search path for configuration scripts. "
"The value of PATH is a colon-separated directory list.")
Index: xen-unstable/docs/man/xm.pod.1
===================================================================
--- xen-unstable.orig/docs/man/xm.pod.1
+++ xen-unstable/docs/man/xm.pod.1
@@ -72,7 +72,7 @@ format, and possible options used in eit
Name=Value combinations.
Configfile can either be an absolute path to a file, or a relative
-path to a file located in /etc/xen.
+path to a file located in /etc/xen/vm.
Create will return B<as soon> as the domain is started. This B<does
not> mean the guest OS in the domain has actually booted, or is
@@ -97,7 +97,7 @@ B<EXAMPLES>
xm create Fedora4
-This creates a domain with the file /etc/xen/Fedora4, and returns as
+This creates a domain with the file /etc/xen/vm/Fedora4, and returns as
soon as it is run.
=item I<without config file>
Index: xen-unstable/docs/man/xmdomain.cfg.pod.5
===================================================================
--- xen-unstable.orig/docs/man/xmdomain.cfg.pod.5
+++ xen-unstable/docs/man/xmdomain.cfg.pod.5
@@ -4,9 +4,9 @@ xmdomain.cfg - xm domain config file for
=head1 SYNOPSIS
- /etc/xen/myxendomain
- /etc/xen/myxendomain2
- /etc/xen/auto/myxenautostarted
+ /etc/xen/auto/
+ /etc/xen/examples/
+ /etc/xen/vm/
=head1 DESCRIPTION
@@ -14,14 +14,14 @@ The B<xm>(1) program uses python executa
domains to create from scratch. Each of these config files needs to
contain a number of required options, and may specify many more.
-Domain configuration files live in /etc/xen by default, if you store
+Domain configuration files live in /etc/xen/vm by default. If you store
config files anywhere else the full path to the config file must be
specified in the I<xm create> command.
/etc/xen/auto is a special case. Domain config files in that
directory will be started automatically at system boot if the
xendomain init script is enabled. The contents of /etc/xen/auto
-should be symlinks to files in /etc/xen to allow I<xm create> to be
+should be symlinks to files in /etc/xen/vm to allow I<xm create> to be
used without full paths.
Options are specified by I<name = value> statements in the

57
xen-poweroff.diff Normal file
View File

@ -0,0 +1,57 @@
diff -uNrp xen-2.0-testing/xen/arch/x86/acpi.c xen-2.0-testing.pwroff/xen/arch/x86/acpi.c
--- xen-2.0-testing/xen/arch/x86/acpi.c 2005-03-01 04:45:17.000000000 +0100
+++ xen-2.0-testing.pwroff/xen/arch/x86/acpi.c 2005-03-01 15:48:13.011511087 +0100
@@ -719,3 +719,13 @@ acpi_sleep_done:
#endif /*CONFIG_ACPI_SLEEP*/
+int acpi_poweroff()
+{
+ if (acpi_enter_sleep_state_prep (ACPI_STATE_S5) == AE_OK) {
+ __asm__ __volatile__ ( "cli" );
+ acpi_enter_sleep_state (ACPI_STATE_S5);
+ __asm__ __volatile__ ( "sti" );
+ acpi_leave_sleep_state (ACPI_STATE_S5);
+ }
+ return 1;
+}
diff -uNrp xen-2.0-testing/xen/arch/x86/domain.c xen-2.0-testing.pwroff/xen/arch/x86/domain.c
--- xen-2.0-testing/xen/arch/x86/domain.c 2005-03-01 04:45:18.000000000 +0100
+++ xen-2.0-testing.pwroff/xen/arch/x86/domain.c 2005-03-01 15:48:26.133212475 +0100
@@ -34,6 +34,7 @@
#include <xen/console.h>
#include <xen/elf.h>
#include <xen/multicall.h>
+#include <xen/acpi.h>
/* opt_noreboot: If true, machine will need manual reset on error. */
static int opt_noreboot = 0;
@@ -186,6 +187,7 @@ void machine_restart(char * __unused)
void __attribute__((noreturn)) __machine_halt(void *unused)
{
+ acpi_poweroff();
for ( ; ; )
__asm__ __volatile__ ( "cli; hlt" );
}
diff -uNrp xen-2.0-testing/xen/drivers/acpi/acpi_ksyms.c xen-2.0-testing.pwroff/xen/drivers/acpi/acpi_ksyms.c
--- xen-2.0-testing/xen/drivers/acpi/acpi_ksyms.c 2005-03-01 04:45:17.000000000 +0100
+++ xen-2.0-testing.pwroff/xen/drivers/acpi/acpi_ksyms.c 2005-03-01 15:36:50.941976570 +0100
@@ -87,6 +87,7 @@ EXPORT_SYMBOL(acpi_get_register);
EXPORT_SYMBOL(acpi_set_register);
EXPORT_SYMBOL(acpi_enter_sleep_state);
EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
+EXPORT_SYMBOL(acpi_leave_sleep_state);
EXPORT_SYMBOL(acpi_get_system_info);
EXPORT_SYMBOL(acpi_get_devices);
diff -uNrp xen-2.0-testing/xen/include/asm-x86/acpi.h xen-2.0-testing.pwroff/xen/include/asm-x86/acpi.h
--- xen-2.0-testing/xen/include/asm-x86/acpi.h 2005-03-01 04:45:21.000000000 +0100
+++ xen-2.0-testing.pwroff/xen/include/asm-x86/acpi.h 2005-03-01 15:49:22.719299798 +0100
@@ -163,4 +163,6 @@ extern void acpi_reserve_bootmem(void);
#endif /*CONFIG_ACPI_SLEEP*/
+extern int acpi_poweroff(void);
+
#endif /*_ASM_ACPI_H*/

1122
xen-pvfb-2.patch Normal file

File diff suppressed because it is too large Load Diff

129
xen-pvfb-3.patch Normal file
View File

@ -0,0 +1,129 @@
Index: xen-unstable/tools/python/xen/xend/image.py
===================================================================
--- xen-unstable.orig/tools/python/xen/xend/image.py
+++ xen-unstable/tools/python/xen/xend/image.py
@@ -20,8 +20,10 @@
import os, string
import re
import math
+import signal
import xen.lowlevel.xc
+import xen.util.auxbin
from xen.xend import sxp
from xen.xend.XendError import VmError
from xen.xend.XendLogging import log
@@ -205,6 +207,68 @@ class LinuxImageHandler(ImageHandler):
ramdisk = self.ramdisk,
features = self.vm.getFeatures())
+ def configure(self, imageConfig, deviceConfig):
+ ImageHandler.configure(self, imageConfig, deviceConfig)
+
+ self.pid = 0
+ log.info("configuring linux guest")
+
+ # set up the graphics bits.
+ # FIXME: this is much like what we do for HVM, should it be
+ # for all image types now?
+ self.display = sxp.child_value(imageConfig, 'display')
+ self.xauthority = sxp.child_value(imageConfig, 'xauthority')
+ self.vncconsole = sxp.child_value(imageConfig, 'vncconsole')
+ self.vnc = sxp.child_value(imageConfig, 'vnc')
+ self.sdl = sxp.child_value(imageConfig, 'sdl')
+ if self.vnc:
+ self.vncdisplay = sxp.child_value(imageConfig, 'vncdisplay',
+ int(self.vm.getDomid()))
+ self.vncunused = sxp.child_value(imageConfig, 'vncunused')
+ self.vnclisten = sxp.child_value(imageConfig, 'vnclisten')
+ if self.vnc or self.sdl:
+ log.info("setting use_graphics")
+ self.vm.writeDom("console/use_graphics", "1")
+ else:
+ self.vm.writeDom("console/use_graphics", "0")
+
+ def createDeviceModel(self):
+ if self.pid:
+ return
+ # Execute device model (for us, it's just the fb frontend)
+ if not self.vnc and not self.sdl:
+ return
+
+ if self.vnc:
+ args = [xen.util.auxbin.pathTo("xen-vncfb")]
+ if self.vncunused:
+ args += ['--unused']
+ elif self.vncdisplay:
+ args += [ "--vncport", "%d" %(5900 + self.vncdisplay,) ]
+ if self.vnclisten:
+ args += [ "--listen", self.vnclisten ]
+ if self.vncconsole:
+ args += [ "--vncviewer" ]
+ elif self.sdl:
+ args = [xen.util.auxbin.pathTo("xen-sdlfb")]
+ args = args + [ "--domid", "%d" % self.vm.getDomid(),
+ "--title", self.vm.info['name'] ]
+ env = dict(os.environ)
+ if self.display:
+ env['DISPLAY'] = self.display
+ if self.xauthority:
+ env['XAUTHORITY'] = self.xauthority
+ log.info("spawning video: %s", args)
+ self.pid = os.spawnve(os.P_NOWAIT, args[0], args, env)
+ log.info("device model pid: %d", self.pid)
+
+ def destroy(self):
+ if not self.pid:
+ return
+ os.kill(self.pid, signal.SIGKILL)
+ os.waitpid(self.pid, 0)
+ self.pid = 0
+
class PPC_LinuxImageHandler(LinuxImageHandler):
ostype = "linux"
@@ -382,7 +446,6 @@ class HVMImageHandler(ImageHandler):
def destroy(self):
self.unregister_shutdown_watch();
- import signal
if not self.pid:
return
os.kill(self.pid, signal.SIGKILL)
Index: xen-unstable/tools/python/xen/xm/create.py
===================================================================
--- xen-unstable.orig/tools/python/xen/xm/create.py
+++ xen-unstable/tools/python/xen/xm/create.py
@@ -481,6 +481,8 @@ def configure_image(vals):
if vals.builder == 'hvm':
configure_hvm(config_image, vals)
+
+ configure_graphics(config_image, vals)
return config_image
@@ -627,14 +629,21 @@ def configure_vifs(config_devs, vals):
map(f, d.keys())
config_devs.append(['device', config_vif])
+def configure_graphics(config_image, vals):
+ """Create the config for graphic consoles.
+ """
+ args = [ 'vnc', 'vncdisplay', 'vncconsole', 'vncunused',
+ 'sdl', 'display', 'xauthority' ]
+ for a in args:
+ if (vals.__dict__[a]):
+ config_image.append([a, vals.__dict__[a]])
def configure_hvm(config_image, vals):
"""Create the config for HVM devices.
"""
args = [ 'device_model', 'pae', 'vcpus', 'boot', 'fda', 'fdb',
'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
- 'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'sdl', 'display',
- 'acpi', 'apic', 'xauthority', 'usb', 'usbdevice' ]
+ 'acpi', 'apic', 'usb', 'usbdevice' ]
for a in args:
if (vals.__dict__[a]):
config_image.append([a, vals.__dict__[a]])

152
xen-python25-warnings.diff Normal file
View File

@ -0,0 +1,152 @@
Index: xen-3.0.3-testing/tools/python/xen/lowlevel/xc/xc.c
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/lowlevel/xc/xc.c
+++ xen-3.0.3-testing/tools/python/xen/lowlevel/xc/xc.c
@@ -23,6 +23,13 @@
#define PyMODINIT_FUNC DL_EXPORT(void)
#endif
+/* Needed for Python versions earlier than 2.5, due to PEP353 */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#endif
+
#define PKG "xen.lowlevel.xc"
#define CLS "xc"
@@ -65,9 +72,12 @@ static PyObject *pyxc_domain_create(XcOb
PyObject *args,
PyObject *kwds)
{
- uint32_t dom = 0;
- int ret, i;
- uint32_t ssidref = 0;
+ uint32_t dom;
+ Py_ssize_t _dom = 0;
+ uint32_t ssidref;
+ Py_ssize_t _ssidref = 0;
+ Py_ssize_t i;
+ int ret;
PyObject *pyhandle = NULL;
xen_domain_handle_t handle = {
0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef,
@@ -76,8 +86,10 @@ static PyObject *pyxc_domain_create(XcOb
static char *kwd_list[] = { "dom", "ssidref", "handle", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiO", kwd_list,
- &dom, &ssidref, &pyhandle))
+ &_dom, &_ssidref, &pyhandle))
return NULL;
+ dom = Py_SAFE_DOWNCAST(_dom, Py_ssize_t, uint32_t);
+ ssidref = Py_SAFE_DOWNCAST(_ssidref, Py_ssize_t, uint32_t);
if ( pyhandle != NULL )
{
@@ -140,7 +152,8 @@ static PyObject *pyxc_vcpu_setaffinity(X
PyObject *kwds)
{
uint32_t dom;
- int vcpu = 0, i;
+ int vcpu = 0;
+ Py_ssize_t i;
uint64_t cpumap = ~0ULL;
PyObject *cpulist = NULL;
@@ -186,7 +199,7 @@ static PyObject *pyxc_domain_setcpuweigh
static PyObject *pyxc_domain_sethandle(XcObject *self, PyObject *args)
{
- int i;
+ Py_ssize_t i;
uint32_t dom;
PyObject *pyhandle;
xen_domain_handle_t handle;
Index: xen-3.0.3-testing/tools/python/xen/lowlevel/xs/xs.c
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/lowlevel/xs/xs.c
+++ xen-3.0.3-testing/tools/python/xen/lowlevel/xs/xs.c
@@ -21,6 +21,13 @@
#include <Python.h>
+/* Needed for Python versions earlier than 2.5, due to PEP353 */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#endif
+
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -320,6 +327,7 @@ static PyObject *xspy_set_permissions(Xs
int i, result;
struct xs_permissions *xsperms = NULL;
int xsperms_n;
+ Py_ssize_t _xsperms_n;
PyObject *tuple0 = NULL;
xs_transaction_t th;
@@ -336,7 +344,9 @@ static PyObject *xspy_set_permissions(Xs
xs_set_error(EINVAL);
goto exit;
}
- xsperms_n = PyList_Size(perms);
+ _xsperms_n = PyList_Size(perms);
+ /* Should never overflow an int, since xs interface uses int */
+ xsperms_n = Py_SAFE_DOWNCAST(_xsperms_n, Py_ssize_t, int);
xsperms = calloc(xsperms_n, sizeof(struct xs_permissions));
if (!xsperms) {
xs_set_error(ENOMEM);
@@ -393,7 +403,7 @@ static PyObject *xspy_watch(XsHandle *se
PyObject *token;
char token_str[MAX_STRLEN(unsigned long) + 1];
int result;
- int i;
+ Py_ssize_t i;
if (!xh)
return NULL;
@@ -439,7 +449,7 @@ static PyObject *xspy_read_watch(XsHandl
PyObject *val = NULL;
char **xsval;
PyObject *token;
- int i;
+ Py_ssize_t i;
unsigned int num;
if (!xh)
@@ -658,7 +668,7 @@ static PyObject *xspy_release_domain(XsH
static PyObject *xspy_close(XsHandle *self)
{
struct xs_handle *xh = xshandle(self);
- int i;
+ Py_ssize_t i;
if (!xh)
return NULL;
@@ -716,7 +726,7 @@ static PyObject *xspy_get_domain_path(Xs
*/
static void remove_watch(XsHandle *self, PyObject *token)
{
- int i;
+ Py_ssize_t i;
for (i = 0; i < PyList_Size(self->watches); i++) {
if (PyList_GetItem(self->watches, i) == token) {
Index: xen-3.0.3-testing/tools/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/Makefile
+++ xen-3.0.3-testing/tools/Makefile
@@ -22,7 +22,8 @@ SUBDIRS-y += blktap
# These don't cross-compile
ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
SUBDIRS-y += python
-SUBDIRS-y += pygrub
+# pygrub is unsupported by SUSE, and does not build cleanly with Python 2.5
+#SUBDIRS-y += pygrub
endif
.PHONY: all

722
xen-removable.diff Normal file
View File

@ -0,0 +1,722 @@
Index: xen-unstable/tools/ioemu/block.c
===================================================================
--- xen-unstable.orig/tools/ioemu/block.c
+++ xen-unstable/tools/ioemu/block.c
@@ -332,6 +332,8 @@ int bdrv_open2(BlockDriverState *bs, con
goto fail;
}
+ shdev_set_media_instance(bs);
+
bs->inserted = 1;
/* call the change callback */
@@ -356,6 +358,7 @@ void bdrv_close(BlockDriverState *bs)
bs->opaque = NULL;
bs->drv = NULL;
bs->inserted = 0;
+ bs->media_instance = 0;
/* call the change callback */
if (bs->change_cb)
@@ -601,6 +604,15 @@ BlockDriverState *bdrv_find(const char *
return NULL;
}
+BlockDriverState *bdrv_find_bs(int (*it)(BlockDriverState *, void *), void *opaque)
+{
+ BlockDriverState *bs;
+
+ for (bs = bdrv_first; bs != NULL && !it(bs, opaque); bs = bs->next);
+
+ return( bs );
+}
+
void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque)
{
BlockDriverState *bs;
Index: xen-unstable/tools/ioemu/block_int.h
===================================================================
--- xen-unstable.orig/tools/ioemu/block_int.h
+++ xen-unstable/tools/ioemu/block_int.h
@@ -51,6 +51,8 @@ struct BlockDriverState {
int removable; /* if true, the media can be removed */
int locked; /* if true, the media cannot temporarily be ejected */
int encrypted; /* if true, the media is encrypted */
+ int media_instance;
+ int shdev_el;
/* event callback when inserting/removing */
void (*change_cb)(void *opaque);
void *change_opaque;
Index: xen-unstable/tools/ioemu/hw/ide.c
===================================================================
--- xen-unstable.orig/tools/ioemu/hw/ide.c
+++ xen-unstable/tools/ioemu/hw/ide.c
@@ -23,6 +23,9 @@
*/
#include "vl.h"
#include <pthread.h>
+#include <sys/ioctl.h>
+#include <scsi/scsi.h>
+#include <scsi/sg.h>
/* debug IDE devices */
//#define DEBUG_IDE
@@ -278,6 +281,7 @@
#define ASC_ILLEGAL_OPCODE 0x20
#define ASC_LOGICAL_BLOCK_OOR 0x21
#define ASC_INV_FIELD_IN_CMD_PACKET 0x24
+#define ASC_MEDIA_CHANGED 0x28
#define ASC_MEDIUM_NOT_PRESENT 0x3a
#define ASC_SAVING_PARAMETERS_NOT_SUPPORTED 0x39
@@ -294,6 +298,7 @@ typedef void EndTransferFunc(struct IDES
typedef struct IDEState {
/* ide config */
int is_cdrom;
+ int media_changed;
int cylinders, heads, sectors;
int64_t nb_sectors;
int mult_sectors;
@@ -1141,6 +1146,51 @@ static void ide_atapi_cmd_read(IDEState
}
}
+static int cd_media_inserted(IDEState *s)
+{
+ int inserted = 0;
+
+ if (s->bs->removable) {
+ int h = open(s->bs->filename, O_NONBLOCK, O_RDONLY);
+
+ if (h >= 0) {
+ struct stat statbuf;
+ if (fstat(h, &statbuf) == 0 && S_ISREG(statbuf.st_mode)) {
+ inserted = 1;
+ } else {
+ int status;
+ sg_io_hdr_t io_hdr;
+ unsigned char test_unit_ready_cmd[6] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
+ unsigned char inqBuff[2];
+ unsigned char sb[32];
+
+ memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
+ io_hdr.interface_id = 'S';
+ io_hdr.cmd_len = 6;
+ io_hdr.mx_sb_len = sizeof(sb);
+ io_hdr.dxfer_direction = SG_DXFER_NONE;
+ io_hdr.dxfer_len = 0;
+ io_hdr.dxferp = inqBuff;
+ io_hdr.sbp = (unsigned char *) sb;
+ io_hdr.timeout = 2000;
+ io_hdr.cmdp = test_unit_ready_cmd;
+
+ sb[0] = 0xFF;
+
+ status = ioctl(h, SG_IO, (void *)&io_hdr);
+
+ if ( (status == 0) && (sb[0] == 0xFF))
+ inserted = 1;
+ }
+
+ close(h);
+ }
+ } else
+ inserted = 1;
+
+ return inserted;
+}
+
static void ide_atapi_cmd(IDEState *s)
{
const uint8_t *packet;
@@ -1162,11 +1212,25 @@ static void ide_atapi_cmd(IDEState *s)
switch(s->io_buffer[0]) {
case GPCMD_TEST_UNIT_READY:
if (bdrv_is_inserted(s->bs)) {
- ide_atapi_cmd_ok(s);
+ if (s->media_changed) {
+ s->media_changed = 0;
+ ide_atapi_cmd_error(s, SENSE_UNIT_ATTENTION, ASC_MEDIA_CHANGED);
+ }
+ else {
+ if (!cd_media_inserted(s) || shdev_media_check(s->bs)) {
+ bdrv_close(s->bs);
+ ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+ }
+ else
+ ide_atapi_cmd_ok(s);
+ }
} else {
ide_atapi_cmd_error(s, SENSE_NOT_READY,
ASC_MEDIUM_NOT_PRESENT);
- xenstore_check_new_media_present(1000);
+// xenstore_check_new_media_present(1000);
+ if (cd_media_inserted(s)) {
+ do_insert_request();
+ }
}
break;
case GPCMD_MODE_SENSE_10:
@@ -1298,6 +1362,13 @@ static void ide_atapi_cmd(IDEState *s)
ASC_MEDIUM_NOT_PRESENT);
break;
}
+
+ if (shdev_media_check(s->bs)) {
+ bdrv_close(s->bs);
+ ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+ break;
+ }
+
nb_sectors = (packet[6] << 16) | (packet[7] << 8) | packet[8];
lba = ube32_to_cpu(packet + 2);
if (nb_sectors == 0) {
@@ -1355,7 +1426,7 @@ static void ide_atapi_cmd(IDEState *s)
if (eject && !start) {
/* eject the disk */
- bdrv_close(s->bs);
+ do_eject(1, s->bs->device_name);
}
ide_atapi_cmd_ok(s);
}
@@ -1382,6 +1453,13 @@ static void ide_atapi_cmd(IDEState *s)
ASC_MEDIUM_NOT_PRESENT);
break;
}
+
+ if (shdev_media_check(s->bs)) {
+ bdrv_close(s->bs);
+ ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+ break;
+ }
+
max_len = ube16_to_cpu(packet + 7);
format = packet[9] >> 6;
msf = (packet[1] >> 1) & 1;
@@ -1454,9 +1532,9 @@ static void cdrom_change_cb(void *opaque
IDEState *s = opaque;
int64_t nb_sectors;
- /* XXX: send interrupt too */
bdrv_get_geometry(s->bs, &nb_sectors);
s->nb_sectors = nb_sectors;
+ s->media_changed = 1;
}
static void ide_cmd_lba48_transform(IDEState *s, int lba48)
@@ -1756,6 +1834,7 @@ static void ide_ioport_write(void *opaqu
ide_set_signature(s);
s->status = 0x00; /* NOTE: READY is _not_ set */
s->error = 0x01;
+ s->media_changed = 0;
break;
case WIN_PACKETCMD:
if (!s->is_cdrom)
Index: xen-unstable/tools/ioemu/monitor.c
===================================================================
--- xen-unstable.orig/tools/ioemu/monitor.c
+++ xen-unstable/tools/ioemu/monitor.c
@@ -24,6 +24,7 @@
#include "vl.h"
#include "disas.h"
#include <dirent.h>
+#include <sys/shm.h>
#include "block_int.h"
//#define DEBUG
@@ -340,7 +341,44 @@ void do_eject(int force, const char *fil
term_printf("device not found\n");
return;
}
- eject_device(bs, force);
+
+ if (eject_device(bs, force) == 0) {
+ char cmd[strlen(bs->filename) + 16];
+ shdev_eject_notice(bs);
+ sprintf(cmd, "eject %s", bs->filename);
+ system(cmd);
+ }
+}
+
+void do_insert(const char *device)
+{
+ BlockDriverState *bs;
+
+ bs = bdrv_find(device);
+
+ if (!bs) {
+ term_printf("'%s' not found\n", device);
+ return;
+ }
+
+ if (!bs->removable) {
+ term_printf("'%s' is not removable\n", device);
+ return;
+ }
+
+ if (bs->inserted) {
+ term_printf("'%s' is already inserted\n", device);
+ return;
+ }
+
+ bdrv_open(bs, bs->filename, 0);
+}
+
+static int find_bs_by_type(BlockDriverState *bs, void *opaque)
+{
+ int *type = (int *)opaque;
+
+ return( (bs->type == *type) );
}
void do_change(const char *device, const char *filename)
@@ -356,7 +394,8 @@ void do_change(const char *device, const
}
if (eject_device(bs, 0) < 0)
return;
- bdrv_open(bs, filename, 0);
+ pstrcpy(bs->filename, sizeof(bs->filename), filename);
+ do_insert(bs->device_name);
if (bdrv_is_encrypted(bs)) {
term_printf("%s is encrypted.\n", device);
for(i = 0; i < 3; i++) {
@@ -368,6 +407,19 @@ void do_change(const char *device, const
}
}
+void do_insert_request()
+{
+ BlockDriverState *bs = NULL;
+ int type = BDRV_TYPE_CDROM;
+
+ bs = bdrv_find_bs(find_bs_by_type, &type);
+
+ if (bs)
+ do_change(bs->device_name, bs->filename);
+ else
+ term_printf("Did not find cdrom bs.\n");
+}
+
static void do_screen_dump(const char *filename)
{
vga_hw_screen_dump(filename);
Index: xen-unstable/tools/ioemu/sdl.c
===================================================================
--- xen-unstable.orig/tools/ioemu/sdl.c
+++ xen-unstable/tools/ioemu/sdl.c
@@ -544,7 +544,7 @@ void sdl_display_init(DisplayState *ds,
#ifndef _WIN32
/* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */
signal(SIGINT, SIG_DFL);
- signal(SIGQUIT, SIG_DFL);
+// signal(SIGQUIT, SIG_DFL);
#endif
ds->dpy_update = sdl_update;
Index: xen-unstable/tools/ioemu/vl.h
===================================================================
--- xen-unstable.orig/tools/ioemu/vl.h
+++ xen-unstable/tools/ioemu/vl.h
@@ -180,6 +180,8 @@ extern int smp_cpus;
#define BIOS_SIZE ((256 + 64) * 1024)
#endif
+#define CDROM_DISK_POSITION 2
+
/* keyboard/mouse support */
#define MOUSE_EVENT_LBUTTON 0x01
@@ -561,6 +563,7 @@ void bdrv_set_change_cb(BlockDriverState
void (*change_cb)(void *opaque), void *opaque);
void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
void bdrv_info(void);
+BlockDriverState *bdrv_find_bs(int (*it)(BlockDriverState *bs, void *opaque), void *opaque);
BlockDriverState *bdrv_find(const char *name);
void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
int bdrv_is_encrypted(BlockDriverState *bs);
@@ -1180,6 +1183,15 @@ pflash_t *pflash_register (target_ulong
#endif /* defined(QEMU_TOOL) */
+/* shdev.h */
+
+int shdev_init(void);
+int shdev_report_device(BlockDriverState *bs, const char *name);
+void shdev_set_media_instance(BlockDriverState *bs);
+void shdev_eject_notice(BlockDriverState *bs);
+inline int shdev_media_check(BlockDriverState *bs);
+void do_info_shdev(void);
+
/* monitor.c */
void monitor_init(CharDriverState *hd, int show_banner);
void term_puts(const char *str);
@@ -1189,6 +1201,7 @@ void term_flush(void);
void term_print_help(void);
void monitor_readline(const char *prompt, int is_password,
char *buf, int buf_size);
+void do_insert_request(void);
void do_eject(int force, const char *filename);
void do_change(const char *device, const char *filename);
Index: xen-unstable/tools/ioemu/shdev.c
===================================================================
--- /dev/null
+++ xen-unstable/tools/ioemu/shdev.c
@@ -0,0 +1,138 @@
+/*
+ * Managment for Devices Shared Across Guests
+ *
+ * Copyright (c) 2006 Novell, Inc.
+ *
+ * - Author: Ross Maxfield (ross.maxfield@novell.com)
+ *
+ * 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 "vl.h"
+#include "block_int.h"
+#include <sys/shm.h>
+
+#define MAX_SHARED_DEVS 4
+#define SHDEV_NAME_LEN 128
+#define SHARED_DEVS_SIGNATURE "ShRdDeVs"
+#define QEMU_KEY_PATH "/etc/xen"
+
+typedef struct SharedDevice {
+ char name[SHDEV_NAME_LEN];
+ int media_instance;
+} SharedDevice;
+
+typedef struct SharedDevices {
+ char signature[sizeof(SHARED_DEVS_SIGNATURE)];
+ SharedDevice device[MAX_SHARED_DEVS];
+} SharedDevices;
+
+SharedDevices *shdevs;
+
+int shdev_init()
+{
+ key_t shm_key;
+ int shm_id;
+
+ /* Alloc/Get shared device memory */
+ shm_key = ftok(QEMU_KEY_PATH, 'X');
+
+ if (((shm_id = shmget(shm_key,
+ sizeof(SharedDevices),
+ IPC_CREAT|IPC_EXCL|0660)) != -1)
+ && ((shdevs = shmat(shm_id, 0, 0)) != (void *)-1)) {
+ memcpy(&shdevs->signature, SHARED_DEVS_SIGNATURE,
+ sizeof(SHARED_DEVS_SIGNATURE));
+ }
+ else
+ if (errno == EEXIST)
+ {
+ if (((shm_id = shmget(shm_key, sizeof(SharedDevices), 0)) == -1)
+ || ((shdevs = shmat(shm_id, 0, 0)) == (void *)-1)
+ || (memcmp(shdevs->signature, SHARED_DEVS_SIGNATURE,
+ sizeof(SHARED_DEVS_SIGNATURE)) != 0)) {
+ shdevs = NULL;
+ fprintf(stderr, "Could not setup support for shared devices.\n");
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+void shdev_set_media_instance(BlockDriverState *bs)
+{
+ bs->media_instance = shdevs->device[bs->shdev_el].media_instance;
+}
+
+void shdev_eject_notice(BlockDriverState *bs)
+{
+ shdevs->device[bs->shdev_el].media_instance++;
+}
+
+inline int shdev_media_check(BlockDriverState *bs)
+{
+ return(!(bs->media_instance == shdevs->device[bs->shdev_el].media_instance));
+}
+
+int shdev_report_device(BlockDriverState *bs, const char *name)
+{
+ int i;
+
+ for (i = 0;
+ (i < MAX_SHARED_DEVS) && strcmp(shdevs->device[i].name, name);
+ i++);
+
+ if (i == MAX_SHARED_DEVS) {
+ for (i = 0;
+ (i < MAX_SHARED_DEVS) && (shdevs->device[i].name[0] != '\0');
+ i++);
+
+ if (i < MAX_SHARED_DEVS) {
+ pstrcpy(shdevs->device[i].name, SHDEV_NAME_LEN, name);
+ shdevs->device[i].media_instance = 0;
+ }
+ else {
+ fprintf(stderr, "%s exceeds maximum of %d shared devices.\n",
+ name, MAX_SHARED_DEVS );
+ return -1;
+ }
+ }
+
+ bs->media_instance = shdevs->device[i].media_instance;
+ bs->shdev_el = i;
+
+ return 0;
+}
+
+void do_info_shdev(void)
+{
+ int i;
+
+ /* Can this device be made availble to this domain? */
+ for (i = 0; i < MAX_SHARED_DEVS; i++) {
+ if (shdevs->device[i].name[0] != '\0') {
+ term_printf("'%s' [%d]\n",
+ shdevs->device[i].name,
+ shdevs->device[i].media_instance);
+ }
+ }
+}
+
+
Index: xen-unstable/tools/ioemu/Makefile.target
===================================================================
--- xen-unstable.orig/tools/ioemu/Makefile.target
+++ xen-unstable/tools/ioemu/Makefile.target
@@ -307,7 +307,7 @@ ifeq ($(ARCH),alpha)
endif
# must use static linking to avoid leaving stuff in virtual address space
-VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
+VL_OBJS=vl.o osdep.o block.o shdev.o readline.o monitor.o pci.o console.o
VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
ifdef CONFIG_WIN32
VL_OBJS+=tap-win32.o
Index: xen-unstable/tools/ioemu/vl.c
===================================================================
--- xen-unstable.orig/tools/ioemu/vl.c
+++ xen-unstable/tools/ioemu/vl.c
@@ -5843,6 +5843,8 @@ int main(int argc, char **argv)
int usb_devices_index;
unsigned long nr_pages, tmp_nr_pages, shared_page_nr;
xen_pfn_t *page_array;
+ int dev_type;
+ char buf[64];
extern void *shared_page;
extern void *buffered_io_page;
@@ -5073,7 +5073,7 @@ int main(int argc, char **argv)
#ifdef CONFIG_GDBSTUB
int use_gdbstub, gdbstub_port;
#endif
- int i, has_cdrom;
+ int i, has_cdrom = 0;
int snapshot, linux_boot;
CPUState *env;
const char *initrd_filename;
@@ -5094,6 +5094,8 @@ int main(int argc, char **argv)
const char *loadvm = NULL;
unsigned long nr_pages, extra_pages, ram_pages, *page_array;
xc_dominfo_t info;
+ int dev_type;
+ char buf[64];
extern void *shared_page;
extern void *shared_vram;
extern void *buffered_io_page;
@@ -5122,7 +5124,6 @@ int main(int argc, char **argv)
vncconnect=NULL;
kernel_filename = NULL;
kernel_cmdline = "";
- has_cdrom = 1;
cyls = heads = secs = 0;
pstrcpy(monitor_device, sizeof(monitor_device), "vc");
@@ -5185,12 +5186,6 @@ int main(int argc, char **argv)
case QEMU_OPTION_initrd:
initrd_filename = optarg;
break;
- case QEMU_OPTION_hda:
- hd_filename[0] = optarg;
- break;
- case QEMU_OPTION_hdb:
- hd_filename[1] = optarg;
- break;
case QEMU_OPTION_snapshot:
snapshot = 1;
break;
@@ -5263,15 +5258,56 @@ int main(int argc, char **argv)
}
}
break;
+ case QEMU_OPTION_hda:
+ if (hd_filename[0]) {
+ fprintf(stderr,
+ "qemu: virtual device 'hd%c' already defined as %s\n",
+ 'a',
+ hd_filename[0] );
+ break;
+ }
+ hd_filename[0] = optarg;
+ break;
+ case QEMU_OPTION_hdb:
+ if (hd_filename[1]) {
+ fprintf(stderr,
+ "qemu: virtual device 'hd%c' already defined as %s\n",
+ 'b',
+ hd_filename[1] );
+ break;
+ }
+ hd_filename[1] = optarg;
+ break;
case QEMU_OPTION_hdc:
+ if (hd_filename[2]) {
+ fprintf(stderr,
+ "qemu: virtual device 'hd%c' already defined as %s\n",
+ 'c',
+ hd_filename[2] );
+ break;
+ }
hd_filename[2] = optarg;
- has_cdrom = 0;
break;
case QEMU_OPTION_hdd:
+ if (hd_filename[3]) {
+ fprintf(stderr,
+ "qemu: virtual device 'hd%c' already defined as %s\n",
+ 'd',
+ hd_filename[3] );
+ break;
+ }
hd_filename[3] = optarg;
break;
case QEMU_OPTION_cdrom:
- hd_filename[2] = optarg;
+ if (hd_filename[CDROM_DISK_POSITION]) {
+ fprintf(stderr,
+ "qemu: virtual device 'hd%c' for cdrom "
+ "is already defined as %s\n",
+ 'a' + CDROM_DISK_POSITION,
+ hd_filename[CDROM_DISK_POSITION] );
+ break;
+ }
+ hd_filename[CDROM_DISK_POSITION] = optarg;
has_cdrom = 1;
break;
case QEMU_OPTION_boot:
@@ -5487,7 +5523,7 @@ int main(int argc, char **argv)
linux_boot = (kernel_filename != NULL);
if ( !linux_boot && hd_filename[0] == '\0' &&
- hd_filename[2] == '\0' && fd_filename[0] == '\0' )
+ hd_filename[CDROM_DISK_POSITION] == '\0' && fd_filename[0] == '\0' )
help();
/* boot to cd by default if no hard disk */
@@ -5668,59 +5704,55 @@ int main(int argc, char **argv)
fprintf(logfile, "shared page at pfn:%lx, mfn: %lx\n", (nr_pages-1),
(page_array[nr_pages - 1]));
- /* we always create the cdrom drive, even if no disk is there */
bdrv_init();
- if (has_cdrom) {
- int fd;
- if ( (fd = open(hd_filename[2], O_RDONLY | O_BINARY)) < 0) {
- hd_filename[2]=NULL;
- bs_table[2]=NULL;
- fprintf(logfile, "Could not open CD %s.\n", hd_filename[i]);
- }
- else {
- close(fd);
- bs_table[2] = bdrv_new("cdrom");
- bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM);
- }
- }
+
+ shdev_init();
/* open the virtual block devices */
for(i = 0; i < MAX_DISKS; i++) {
if (hd_filename[i]) {
- if (!bs_table[i]) {
- char buf[64];
+ if ((i == CDROM_DISK_POSITION) && has_cdrom) {
+ snprintf(buf, sizeof(buf), "cdrom");
+ dev_type = BDRV_TYPE_CDROM;
+ }
+ else {
snprintf(buf, sizeof(buf), "hd%c", i + 'a');
- bs_table[i] = bdrv_new(buf);
+ dev_type = BDRV_TYPE_HD;
}
+
+ bs_table[i] = bdrv_new(buf);
+
+ bdrv_set_type_hint(bs_table[i], dev_type);
+
+ if (bs_table[i]->removable)
+ shdev_report_device(bs_table[i], hd_filename[i]);
+
if (bdrv_open(bs_table[i], hd_filename[i], snapshot) < 0) {
+ if (bs_table[i]->removable)
+ continue;
+
fprintf(stderr, "qemu: could not open hard disk image '%s'\n",
hd_filename[i]);
exit(1);
}
+
if (i == 0 && cyls != 0)
bdrv_set_geometry_hint(bs_table[i], cyls, heads, secs);
}
}
- /* we always create at least one floppy disk */
- fd_table[0] = bdrv_new("fda");
- bdrv_set_type_hint(fd_table[0], BDRV_TYPE_FLOPPY);
-
for(i = 0; i < MAX_FD; i++) {
if (fd_filename[i]) {
if (!fd_table[i]) {
- char buf[64];
snprintf(buf, sizeof(buf), "fd%c", i + 'a');
fd_table[i] = bdrv_new(buf);
bdrv_set_type_hint(fd_table[i], BDRV_TYPE_FLOPPY);
+ shdev_report_device(fd_table[i], fd_filename[i]);
}
- if (fd_filename[i] != '\0') {
- if (bdrv_open(fd_table[i], fd_filename[i], snapshot) < 0) {
- fprintf(stderr, "qemu: could not open floppy disk image '%s'\n",
+
+ if (bdrv_open(fd_table[i], fd_filename[i], snapshot) < 0)
+ fprintf(stderr, "qemu: could not open floppy disk '%s'\n",
fd_filename[i]);
- exit(1);
- }
- }
}
}

78
xen-rpmoptflags.diff Normal file
View File

@ -0,0 +1,78 @@
Index: xen-3.0.3-testing/tools/firmware/hvmloader/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/firmware/hvmloader/Makefile
+++ xen-3.0.3-testing/tools/firmware/hvmloader/Makefile
@@ -37,7 +37,8 @@ CFLAGS += $(call test-gcc-flag,$(CC),-f
CFLAGS += $(call test-gcc-flag,$(CC),-fno-stack-protector-all)
OBJCOPY = objcopy
-CFLAGS += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
+# Optimizations cause problems on 64 bit. Investigate.
+CFLAGS += $(DEFINES) -I. $(XENINC) -fno-builtin -O0 -msoft-float
LDFLAGS = -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR)
SRCS = hvmloader.c acpi_madt.c mp_tables.c util.c smbios.c
Index: xen-3.0.3-testing/tools/blktap/drivers/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/blktap/drivers/Makefile
+++ xen-3.0.3-testing/tools/blktap/drivers/Makefile
@@ -10,7 +10,6 @@ QCOW_UTIL = img2qcow qcow2raw qcow-cr
INSTALL_DIR = /usr/sbin
LIBAIO_DIR = ../../libaio/src
-CFLAGS += -Werror
CFLAGS += -Wno-unused
CFLAGS += -fno-strict-aliasing
CFLAGS += -I $(XEN_LIBXC) -I $(LIBAIO_DIR)
Index: xen-3.0.3-testing/tools/console/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/console/Makefile
+++ xen-3.0.3-testing/tools/console/Makefile
@@ -9,7 +9,7 @@ INSTALL = install
INSTALL_PROG = $(INSTALL) -m0755
INSTALL_DIR = $(INSTALL) -d -m0755
-CFLAGS += -Werror -g
+CFLAGS += -Werror
CFLAGS += -I $(XEN_LIBXC)
CFLAGS += -I $(XEN_XENSTORE)
Index: xen-3.0.3-testing/tools/ioemu/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/ioemu/Makefile
+++ xen-3.0.3-testing/tools/ioemu/Makefile
@@ -8,7 +8,7 @@ include $(XEN_ROOT)/tools/Rules.mk
.PHONY: all clean distclean dvi info install install-doc tar tarbin \
speed test test2 html dvi info
-CFLAGS+=-Wall -O2 -g -fno-strict-aliasing -I.
+CFLAGS+=-Wall -fno-strict-aliasing -I.
ifdef CONFIG_DARWIN
CFLAGS+= -mdynamic-no-pic
endif
Index: xen-3.0.3-testing/tools/xenstore/Makefile
===================================================================
--- xen-3.0.3-testing.orig/tools/xenstore/Makefile
+++ xen-3.0.3-testing/tools/xenstore/Makefile
@@ -11,7 +11,7 @@ INSTALL_PROG = $(INSTALL) -m0755
INSTALL_DIR = $(INSTALL) -d -m0755
PROFILE=#-pg
-BASECFLAGS=-Wall -g -Werror
+BASECFLAGS=-Wall -Werror
# Make gcc generate dependencies.
BASECFLAGS += -Wp,-MD,.$(@F).d
PROG_DEP = .*.d
Index: xen-3.0.3-testing/Config.mk
===================================================================
--- xen-3.0.3-testing.orig/Config.mk
+++ xen-3.0.3-testing/Config.mk
@@ -10,7 +10,7 @@ XEN_TARGET_X86_PAE ?= n
# Tools to run on system hosting the build
HOSTCC = gcc
-HOSTCFLAGS = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer
+HOSTCFLAGS:= -Wall -Werror -Wstrict-prototypes $(RPM_OPT_FLAGS)
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld

14
xen-tightvnc-args.diff Normal file
View File

@ -0,0 +1,14 @@
Index: xen-unstable/tools/python/xen/xm/create.py
===================================================================
--- xen-unstable.orig/tools/python/xen/xm/create.py
+++ xen-unstable/tools/python/xen/xm/create.py
@@ -902,8 +902,7 @@ def spawn_vnc(display):
returns the port that the vncviewer is listening on and sets the global
vncpid. On failure, returns 0. Note that vncviewer is daemonized.
"""
- vncargs = (["vncviewer", "-log", "*:stdout:0",
- "-listen", "%d" % (VNC_BASE_PORT + display) ])
+ vncargs = (["vncviewer", "-listen", "%d" % (display) ])
global vncpid
vncpid = daemonize("vncviewer", vncargs)
if vncpid == 0:

51
xen-warnings.diff Normal file
View File

@ -0,0 +1,51 @@
Index: xen-3.0.3-testing/xen/tools/symbols.c
===================================================================
--- xen-3.0.3-testing.orig/xen/tools/symbols.c
+++ xen-3.0.3-testing/xen/tools/symbols.c
@@ -120,7 +120,8 @@ read_symbol(FILE *in, struct sym_entry *
if (rc != 3) {
if (rc != EOF) {
/* skip line */
- fgets(str, 500, in);
+ if (fgets(str, sizeof(str), in) == NULL)
+ ; /* don't care */
}
return -1;
}
Index: xen-3.0.3-testing/tools/misc/miniterm/miniterm.c
===================================================================
--- xen-3.0.3-testing.orig/tools/misc/miniterm/miniterm.c
+++ xen-3.0.3-testing/tools/misc/miniterm/miniterm.c
@@ -157,7 +157,7 @@ int main(int argc, char **argv)
case 0:
close(1); /* stdout not needed */
for ( c = (char)getchar(); c != ENDMINITERM; c = (char)getchar() )
- write(fd,&c,1);
+ if (write(fd,&c,1)) ;
tcsetattr(fd,TCSANOW,&oldsertio);
tcsetattr(0,TCSANOW,&oldstdtio);
close(fd);
@@ -169,19 +169,19 @@ int main(int argc, char **argv)
close(fd);
exit(-1);
default:
- write(1, start_str, strlen(start_str));
+ if (write(1, start_str, strlen(start_str))) ;
close(0); /* stdin not needed */
sa.sa_handler = child_handler;
sa.sa_flags = 0;
sigaction(SIGCHLD,&sa,NULL); /* handle dying child */
while ( !stop )
{
- read(fd,&c,1); /* modem */
+ if (read(fd,&c,1)) ; /* modem */
c = (char)c;
- write(1,&c,1); /* stdout */
+ if (write(1,&c,1)) ; /* stdout */
}
wait(NULL); /* wait for child to die or it will become a zombie */
- write(1, end_str, strlen(end_str));
+ if (write(1, end_str, strlen(end_str))) ;
break;
}

View File

@ -0,0 +1,18 @@
From: Charles Coffing <ccoffing@novell.com>
Upstream: no
Index: xen-unstable/tools/python/xen/xm/main.py
===================================================================
--- xen-unstable.orig/tools/python/xen/xm/main.py
+++ xen-unstable/tools/python/xen/xm/main.py
@@ -1018,6 +1018,10 @@ def xm_sysrq(args):
def xm_top(args):
arg_check(args, "top", 0)
+ # A hack to get a clear error message if ran as non-root
+ if os.geteuid() != 0:
+ raise IOError()
+
os.execvp('xentop', ['xentop'])
def xm_dmesg(args):

13
xen-xmexample-nbd.diff Normal file
View File

@ -0,0 +1,13 @@
Index: xen-unstable/tools/examples/Makefile
===================================================================
--- xen-unstable.orig/tools/examples/Makefile
+++ xen-unstable/tools/examples/Makefile
@@ -17,7 +17,7 @@ XEN_CONFIGS = xend-config.sxp
XEN_CONFIGS += xmexample1
XEN_CONFIGS += xmexample2
XEN_CONFIGS += xmexample.hvm
-XEN_CONFIGS += xmexample.vti
+XEN_CONFIGS += xmexample.nbd
XEN_CONFIGS += xend-pci-quirks.sxp
XEN_CONFIGS += xend-pci-permissive.sxp

181
xen-xmexample.diff Normal file
View File

@ -0,0 +1,181 @@
Change various example paths in the config files to match SUSE.
Index: xen-unstable/tools/examples/xmexample1
===================================================================
--- xen-unstable.orig/tools/examples/xmexample1
+++ xen-unstable/tools/examples/xmexample1
@@ -7,11 +7,14 @@
#============================================================================
#----------------------------------------------------------------------------
-# Kernel image file.
-kernel = "/boot/vmlinuz-2.6.10-xenU"
-
-# Optional ramdisk.
-#ramdisk = "/boot/initrd.gz"
+# Kernel image file and (optional) ramdisk (initrd).
+kernel = "/boot/vmlinuz-xen"
+ramdisk = "/boot/initrd-xen"
+
+# Or use domUloader instead of kernel/ramdisk to get kernel from domU FS
+#bootloader = "/usr/lib/xen/boot/domUlaoder.py"
+#bootentry = "hda2:/vmlinuz-xen,/initrd-xen"
+#bootentry = "/boot/vmlinuz-xen,/boot/initrd-xen"
# The domain build function. Default is 'linux'.
#builder='linux'
@@ -96,7 +99,7 @@ disk = [ 'phy:hda1,hda1,w' ]
#hostname= "vm%d" % vmid
# Set root device.
-root = "/dev/hda1 ro"
+root = "/dev/hda1"
# Root device for nfs.
#root = "/dev/nfs"
@@ -105,8 +108,8 @@ root = "/dev/hda1 ro"
# Root directory on the nfs server.
#nfs_root = '/full/path/to/root/directory'
-# Sets runlevel 4.
-extra = "4"
+# Extra arguments to pass to the kernel.
+extra = ""
#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
Index: xen-unstable/tools/examples/xmexample2
===================================================================
--- xen-unstable.orig/tools/examples/xmexample2
+++ xen-unstable/tools/examples/xmexample2
@@ -35,11 +35,14 @@ xm_vars.var('vmid',
xm_vars.check()
#----------------------------------------------------------------------------
-# Kernel image file.
-kernel = "/boot/vmlinuz-2.6.10-xenU"
-
-# Optional ramdisk.
-#ramdisk = "/boot/initrd.gz"
+# Kernel image file and (optional) ramdisk (initrd).
+kernel = "/boot/vmlinuz-xen"
+ramdisk = "/boot/initrd-xen"
+
+# Or use domUloader instead of kernel/ramdisk to get kernel from domU FS
+#bootloader = "/usr/lib/xen/boot/domUlaoder.py"
+#bootentry = "hda2:/vmlinuz-xen,/initrd-xen"
+#bootentry = "/boot/vmlinuz-xen,/boot/initrd-xen"
# The domain build function. Default is 'linux'.
#builder='linux'
@@ -132,7 +135,7 @@ disk = [ 'phy:sda%d,sda1,w' % (7+vmid),
#hostname= "vm%d" % vmid
# Set root device.
-root = "/dev/sda1 ro"
+root = "/dev/sda1"
# Root device for nfs.
#root = "/dev/nfs"
@@ -141,8 +144,8 @@ root = "/dev/sda1 ro"
# Root directory on the nfs server.
#nfs_root = '/full/path/to/root/directory'
-# Sets runlevel 4 and the device for /usr.
-extra = "4 VMID=%d usr=/dev/sda6" % vmid
+# Sets the device for /usr.
+extra = "VMID=%d usr=/dev/sda6" % vmid
#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
Index: xen-unstable/tools/examples/xmexample3
===================================================================
--- xen-unstable.orig/tools/examples/xmexample3
+++ xen-unstable/tools/examples/xmexample3
@@ -35,11 +35,14 @@ xm_vars.var('vmid',
xm_vars.check()
#----------------------------------------------------------------------------
-# Kernel image file.
-kernel = "/path/to/domU/kernel"
-
-# Optional ramdisk.
-#ramdisk = "/boot/initrd.gz"
+# Kernel image file and (optional) ramdisk (initrd).
+kernel = "/boot/vmlinuz-xen"
+ramdisk = "/boot/initrd-xen"
+
+# Or use domUloader instead of kernel/ramdisk to get kernel from domU FS
+#bootloader = "/usr/lib/xen/boot/domUlaoder.py"
+#bootentry = "hda2:/vmlinuz-xen,/initrd-xen"
+#bootentry = "/boot/vmlinuz-xen,/boot/initrd-xen"
# The domain build function. Default is 'linux'.
#builder='linux'
Index: xen-unstable/tools/examples/xmexample.hvm
===================================================================
--- xen-unstable.orig/tools/examples/xmexample.hvm
+++ xen-unstable/tools/examples/xmexample.hvm
@@ -70,7 +70,7 @@ vif = [ 'type=ioemu, bridge=xenbr0' ]
# and MODE is r for read-only, w for read-write.
#disk = [ 'phy:hda1,hda1,r' ]
-disk = [ 'file:/var/images/min-el3-i386.img,hda,w', ',hdc:cdrom,r' ]
+disk = [ 'file:/var/lib/xen/images/disk.img,ioemu:hda,w', ',hdc:cdrom,r' ]
#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
Index: xen-unstable/docs/man/xmdomain.cfg.pod.5
===================================================================
--- xen-unstable.orig/docs/man/xmdomain.cfg.pod.5
+++ xen-unstable/docs/man/xmdomain.cfg.pod.5
@@ -38,13 +38,13 @@ file.
The kernel image for the domain. The format of the parameter is the
fully qualified path to the kernel image file,
-i.e. I</boot/vmlinuz-2.6.12-xenU>.
+i.e. I</boot/vmlinuz-xen>.
=item B<ramdisk>
The initial ramdisk for the domain. The format of the parameter is
-the fully qualified path to the initrd, i.e. I</boot/initrd.gz>. On
+the fully qualified path to the initrd, i.e. I</boot/initrd-xen>. On
many Linux distros you will not need a ramdisk if using the default
xen kernel.
@@ -258,14 +258,14 @@ configured. They should not be consider
=item I<A Loopback File as Root>
- kernel = "/boot/vmlinuz-2.6-xenU"
+ kernel = "/boot/vmlinuz-xen"
memory = 128
name = "MyLinux"
- root = "/dev/hda1 ro"
- disk = [ "file:/var/xen/mylinux.img,hda1,w" ]
+ root = "/dev/hda1"
+ disk = [ "file:/var/lib/xen/images/MyLinux/hda1,hda1,w" ]
This creates a domain called MyLinux with 128 MB of memory using a
-default xen kernel, and the file /var/xen/mylinux.img loopback mounted
+default xen kernel, and the file hda1 loopback mounted
at hda1, which is the root filesystem.
=item I<NFS Root>
Index: xen-unstable/docs/man/xm.pod.1
===================================================================
--- xen-unstable.orig/docs/man/xm.pod.1
+++ xen-unstable/docs/man/xm.pod.1
@@ -102,8 +102,8 @@ soon as it is run.
=item I<without config file>
- xm create /dev/null ramdisk=initrd.img \
- kernel=/boot/vmlinuz-2.6.12.6-xenU \
+ xm create /dev/null ramdisk=initrd-xen \
+ kernel=/boot/vmlinuz-xen \
name=ramdisk nics=0 vcpus=1 \
memory=64 root=/dev/ram0

1490
xen.changes Normal file

File diff suppressed because it is too large Load Diff

1690
xen.spec Normal file

File diff suppressed because it is too large Load Diff

135
xend-xmlrpc-large-ints.diff Normal file
View File

@ -0,0 +1,135 @@
# HG changeset patch
# User anthony@rhesis.austin.ibm.com
# Node ID 8dc8c7bdcbac0e56c606fe5c9205b4d9742e60d7
# Parent 8b5a752167a17785b998a080a5c1ce1991b9379b
In some cases, Xend can return a very large integer. This so far only happens
on 64bit systems where the sizeof the Python integer is > 32bit. Presumably,
this is occuring because of the fact that we return PFNs as part of the
domain info so on a system with greater than 2G of memory we get into the
invalid integer range.
For now, the work-around is to overload the xmlrpclib Marshaller and instead
of throwing an exception when we get out-of-range integers, we marshal them
as strings. In the future, we can handle this in a more elegant way by
introducing higher-level types. We also won't have to deal with things like
PFNs once we clean up the XML-RPC interface.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Index: xen-3.0.3-testing/tools/python/xen/util/xmlrpclib2.py
===================================================================
--- xen-3.0.3-testing.orig/tools/python/xen/util/xmlrpclib2.py
+++ xen-3.0.3-testing/tools/python/xen/util/xmlrpclib2.py
@@ -25,10 +25,11 @@ import types
import fcntl
from httplib import HTTPConnection, HTTP
-from xmlrpclib import Transport
+from xmlrpclib import Transport, Fault
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
import SocketServer
-import xmlrpclib, socket, os, stat
+import xmlrpclib, socket, os, stat, string
+from types import *
from xen.xend.XendLogging import log
@@ -48,6 +49,9 @@ except ImportError:
#
# It assumes that the RPC handler is /RPC2. This probably needs to be improved
+MAXINT = 2L**31-1
+MININT = -2L**31
+
# We're forced to subclass the RequestHandler class so that we can work around
# some bugs in Keep-Alive handling and also enabled it by default
class XMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
@@ -127,6 +131,67 @@ class ServerProxy(xmlrpclib.ServerProxy)
return conv_string(response)
+class Marshaller(xmlrpclib.Marshaller):
+ def __init__(self, encoding=None, allow_none=0):
+ xmlrpclib.Marshaller.__init__(self, encoding, allow_none)
+ self.dispatch[IntType] = Marshaller.dump_int
+ self.dispatch[LongType] = Marshaller.dump_long
+
+ def dump_int(self, value, write):
+ if value > MAXINT or value < MININT:
+ self.dispatch[StringType](self, str(value), write)
+ else:
+ xmlrpclib.Marshaller.dump_int(self, value, write)
+
+ def dump_long(self, value, write):
+ if value > MAXINT or value < MININT:
+ self.dispatch[StringType](self, str(value), write)
+ else:
+ xmlrpclib.Marshaller.dump_long(self, value, write)
+
+def dumps(params, methodname=None, methodresponse=None, encoding=None,
+ allow_none=0):
+ assert isinstance(params, TupleType) or isinstance(params, Fault),\
+ "argument must be tuple or Fault instance"
+
+ if isinstance(params, Fault):
+ methodresponse = 1
+ elif methodresponse and isinstance(params, TupleType):
+ assert len(params) == 1, "response tuple must be a singleton"
+
+ if not encoding:
+ encoding = "utf-8"
+
+ m = Marshaller(encoding, allow_none)
+
+ data = m.dumps(params)
+
+ if encoding != "utf-8":
+ xmlheader = "<?xml version='1.0' encoding='%s'?>\n" % str(encoding)
+ else:
+ xmlheader = "<?xml version='1.0'?>\n" # utf-8 is default
+
+ if methodname:
+ if not isinstance(methodname, StringType):
+ methodname = methodname.encode(encoding)
+ data = (
+ xmlheader,
+ "<methodCall>\n"
+ "<methodName>", methodname, "</methodName>\n",
+ data,
+ "</methodCall>\n"
+ )
+ elif methodresponse:
+ data = (
+ xmlheader,
+ "<methodResponse>\n",
+ data,
+ "</methodResponse>\n"
+ )
+ else:
+ return data
+ return string.join(data, "")
+
# This is a base XML-RPC server for TCP. It sets allow_reuse_address to
# true, and has an improved marshaller that logs and serializes exceptions.
@@ -174,15 +239,15 @@ class TCPXMLRPCServer(SocketServer.Threa
response = repr(response)[1:-1]
response = (response,)
- response = xmlrpclib.dumps(response,
- methodresponse=1,
- allow_none=1)
+ response = dumps(response,
+ methodresponse=1,
+ allow_none=1)
except xmlrpclib.Fault, fault:
- response = xmlrpclib.dumps(fault)
+ response = dumps(fault)
except Exception, exn:
import xen.xend.XendClient
log.exception(exn)
- response = xmlrpclib.dumps(
+ response = dumps(
xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn)))
return response

150
xmexample.domUloader Normal file
View File

@ -0,0 +1,150 @@
# -*- mode: python; -*-
#============================================================================
# Python configuration setup for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
# You use a separate script for each domain you want to create, or
# you can set the parameters for the domain on the xm command line.
#============================================================================
#----------------------------------------------------------------------------
# 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 = "ExampleDomain"
# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
#cpus = "0" # all vcpus run on CPU0
#cpus = "0-3,5,^1" # run on cpus 0,2,3,5
# Number of Virtual CPUS to use, default is 1
#vcpus = 1
#----------------------------------------------------------------------------
# Define network interfaces.
# By default, no network interfaces are configured. You may have one created
# with sensible defaults using an empty vif clause:
#
# vif = [ '' ]
#
# or optionally override backend, bridge, ip, mac, script, type, or vifname:
#
# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ]
#
# or more than one interface may be configured:
#
# vif = [ '', 'bridge=xenbr1' ]
vif = [ '' ]
#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.
disk = [ 'phy:hda1,hda1,w' ]
# This is a bootloader used to boot paravirtualized domains. You can
# optionally plug in a different boot loader here, e.g., pygrub. There is
# usually no reason to change this. Don't use kernel and ramdisk if you
# use a bootloader.
bootloader = "/usr/lib/xen/boot/domUloader.py"
# The domUloader will pull the specified kernel and initrd out of the domU's
# disk, and use that to boot. This is easier to manage, compared to manually
# keeping a copy of the kernel and initrd in sync in dom0's filesystem and
# pointing to them with the "kernel" and "ramdisk" parameters. Syntax is
# "VDEV:KERNEL,INITRD", where VDEV is the block device (from domU's point of
# view) within which KERNEL and INITRD can be found. VDEV is optional; if it's
# not specified, the root= parameter will be evaluated, /etc/fstab from the
# root FS be consulted and a path relative to the domU root FS be used.
bootentry = "hda1:/boot/vmlinuz-xen,/boot/initrd-xen"
#----------------------------------------------------------------------------
# Define to which TPM instance the user domain should communicate.
# The vtpm entry is of the form 'instance=INSTANCE,backend=DOM'
# where INSTANCE indicates the instance number of the TPM the VM
# should be talking to and DOM provides the domain where the backend
# is located.
# Note that no two virtual machines should try to connect to the same
# TPM instance. The handling of all TPM instances does require
# some management effort in so far that VM configration files (and thus
# a VM) should be associated with a TPM instance throughout the lifetime
# of the VM / VM configuration file. The instance number must be
# greater or equal to 1.
#vtpm = [ 'instance=1,backend=0' ]
#----------------------------------------------------------------------------
# Set the kernel command line for the new domain.
# You only need to define the IP parameters and hostname if the domain's
# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP.
# You can use 'extra' to set the runlevel and custom environment
# variables used by custom rc scripts (e.g. VMID=, usr= ).
# Set if you want dhcp to allocate the IP address.
#dhcp="dhcp"
# Set netmask.
#netmask=
# Set default gateway.
#gateway=
# Set the hostname.
#hostname= "vm%d" % vmid
# Set root device.
root = "/dev/hda1"
# Root device for nfs.
#root = "/dev/nfs"
# The nfs server.
#nfs_server = '169.254.1.0'
# Root directory on the nfs server.
#nfs_root = '/full/path/to/root/directory'
# Sets runlevel 4.
extra = "4"
#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
# for a domain to stop: poweroff, reboot, and crash. For each of these you
# may specify:
#
# "destroy", meaning that the domain is cleaned up as normal;
# "restart", meaning that a new domain is started in place of the old
# one;
# "preserve", meaning that no clean-up is done until the domain is
# manually destroyed (using xm destroy, for example); or
# "rename-restart", meaning that the old domain is not cleaned up, but is
# renamed and a new domain started in its place.
#
# The default is
#
# on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# For backwards compatibility we also support the deprecated option restart
#
# restart = 'onreboot' means on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'destroy'
#
# restart = 'always' means on_poweroff = 'restart'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# restart = 'never' means on_poweroff = 'destroy'
# on_reboot = 'destroy'
# on_crash = 'destroy'
#on_poweroff = 'destroy'
#on_reboot = 'restart'
#on_crash = 'restart'
#============================================================================

12
xmexample.iscsi Normal file
View File

@ -0,0 +1,12 @@
kernel = "/boot/vmlinuz-xen"
ramdisk = "/boot/initrd-xen"
memory = 128
name = "nbd"
# Please change MAC
vif = [ 'mac=00:16:e3:10:00:a0, bridge=xenbr0' ]
# Replaced the ':' in the iname with '@'
disk = [ 'iscsi:iqn.2006-09.de.suse@0ac47ee2-216e-452a-a341-a12624cd0225,hda,w' ]
dhcp = "dhcp"
hostname= "nbd"
root = "/dev/hda1"
extra = "3"

12
xmexample.nbd Normal file
View File

@ -0,0 +1,12 @@
kernel = "/boot/vmlinuz-xen"
ramdisk = "/boot/initrd-xen"
memory = 128
name = "nbd"
# Please change MAC
vif = [ 'mac=00:16:e3:10:00:a0, bridge=xenbr0' ]
# Please change PORT
disk = [ 'nbd:192.168.0.1 20004,hda1,w' ]
dhcp = "dhcp"
hostname= "nbd"
root = "/dev/hda1"
extra = "3"

85
xmexample.rescue Normal file
View File

@ -0,0 +1,85 @@
# -*- mode: python; -*-
#============================================================================
# Python configuration setup for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
# You use a separate script for each domain you want to create, or
# you can set the parameters for the domain on the xm command line.
#============================================================================
#----------------------------------------------------------------------------
# Kernel image file and (optional) ramdisk (initrd).
kernel = "/boot/vmlinuz-xen"
ramdisk = "/boot/initrd-xen"
# Or use domUloader instead of kernel/ramdisk to get kernel from domU FS
#bootloader = "/usr/lib/xen/boot/domUloader.py"
#bootentry = "hda2:/vmlinuz-xen,/initrd-xen"
#bootentry = "/boot/vmlinuz-xen,/boot/initrd-xen"
# 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 = "Rescue"
# Which CPU to start domain on?
#cpu = -1 # leave to Xen to pick
#----------------------------------------------------------------------------
# Define network interfaces.
# Optionally define mac and/or bridge for the network interfaces.
# Random MACs are assigned if not given.
vif = [ '' ]
#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.
disk = [ 'file:/var/lib/xen/images/rescue,hda1,w' ]
#----------------------------------------------------------------------------
# Set the kernel command line for the new domain.
# You only need to define the IP parameters and hostname if the domain's
# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP.
# You can use 'extra' to set the runlevel and custom environment
# variables used by custom rc scripts (e.g. VMID=, usr= ).
# Set if you want dhcp to allocate the IP address.
#dhcp = "dhcp"
# Set ip
#ip = "192.168.222.9/27"
# Set netmask.
#netmask = "255.255.255.192"
# Set default gateway.
#gateway = "192.168.222.1"
# Set the hostname.
#hostname= "rescue"
# Set root device, see disk def above.
root = "/dev/hda1 rw"
# Root device for nfs.
#root = "/dev/nfs"
# The nfs server.
#nfs_server = '169.254.1.0'
# Root directory on the nfs server.
#nfs_root = '/full/path/to/root/directory'
# Sets runlevel 3.
extra = "1"
#----------------------------------------------------------------------------
# Set according to whether you want the domain restarted when it exits.
# The default is 'onreboot', which restarts the domain when it shuts down
# with exit code reboot.
# Other values are 'always', and 'never'.
#restart = 'onreboot'
#============================================================================

View File

@ -0,0 +1,75 @@
# HG changeset patch
# User kfraser@localhost.localdomain
# Date Fri Oct 20 10:09:55 2006 +0100
# Node ID 2fbf11ad58f37313350e71f98f2eadb8ac37a8e4
# parent: 02506a7443155611d6bbf03e49fbf193e96d24db
[HVM][SVM] Fix 1/2 to interrupt delivery logic.
This patch uses the VINTR intercept to signal the hypervisor when a
guest can take an interrupt. When guest's interrupts are masked by
EFLAGS.IF or the guests are in an interrupt shadow, we create a 'fake'
virtual interrupt to inject while also enabling the VINTR intercept.
When the guest _can_ take interrupts, the hypervisor will #VMEXIT
on VINTR. The VINTR exit handler then clears the VINTR intercept bit
and clears the V_IRQ bit so that svm_intr_assist() can inject a
legitimate interrupt.
Signed-off-by: Travis Betak <travis.betak@amd.com>
Signed-off-by: Wei Huang <wei.huang2@amd.com>
Signed-off-by: Tom Woller <thomas.woller@amd.com>
Index: xen-3.0.3-testing/xen/arch/x86/hvm/svm/intr.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/svm/intr.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/svm/intr.c
@@ -43,7 +43,7 @@
* to be suitable for SVM.
*/
-static inline int svm_inject_extint(struct vcpu *v, int trap, int error_code)
+static inline int svm_inject_extint(struct vcpu *v, int trap)
{
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
vintr_t intr;
@@ -87,6 +87,16 @@ asmlinkage void svm_intr_assist(void)
re_injecting = 1;
}
+ /*
+ * create a 'fake' virtual interrupt on to intercept as soon
+ * as the guest _can_ take interrupts
+ */
+ if (irq_masked(vmcb->rflags) || vmcb->interrupt_shadow) {
+ vmcb->general1_intercepts |= GENERAL1_INTERCEPT_VINTR;
+ svm_inject_extint(v, 0x0); /* actual vector doesn't really matter */
+ return;
+ }
+
/* Guest's interrputs masked? */
rflags = vmcb->rflags;
if (irq_masked(rflags)) {
@@ -146,7 +156,7 @@ asmlinkage void svm_intr_assist(void)
}
/* let's inject this interrupt */
TRACE_3D(TRC_VMX_INT, v->domain->domain_id, intr_vector, 0);
- svm_inject_extint(v, intr_vector, VMX_DELIVER_NO_ERROR_CODE);
+ svm_inject_extint(v, intr_vector);
hvm_interrupt_post(v, intr_vector, intr_type);
break;
case APIC_DM_SMI:
Index: xen-3.0.3-testing/xen/arch/x86/hvm/svm/svm.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/svm/svm.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/svm/svm.c
@@ -2802,6 +2802,11 @@ asmlinkage void svm_vmexit_handler(struc
svm_inject_exception(v, TRAP_double_fault, 1, 0);
break;
+ case VMEXIT_VINTR:
+ vmcb->vintr.fields.irq = 0;
+ vmcb->general1_intercepts &= ~GENERAL1_INTERCEPT_VINTR;
+ break;
+
case VMEXIT_INTR:
break;

View File

@ -0,0 +1,121 @@
# HG changeset patch
# User kfraser@localhost.localdomain
# Date Fri Oct 20 10:10:36 2006 +0100
# Node ID c436ab500c9988f3a295f66b690ad7a98c16b54f
# parent: 2fbf11ad58f37313350e71f98f2eadb8ac37a8e4
[HVM][SVM] Fix 2/2 to nterrupt delivery logic.
Add flag to indicate that an exception event needs injecting, and to
delay the ext interrupt injection.
Remove unnecessary check of RFLAGS.IF for ExtInt injection.
Signed-off-by: Travis Betak <travis.betak@amd.com>
Signed-off-by: Wei Huang <wei.huang2@amd.com>
Signed-off-by: Tom Woller <thomas.woller@amd.com>
Index: xen-3.0.3-testing/xen/arch/x86/hvm/svm/intr.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/svm/intr.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/svm/intr.c
@@ -62,7 +62,7 @@ static inline int svm_inject_extint(stru
// printf( "IRQ = %d\n", trap );
return 0;
}
-
+
asmlinkage void svm_intr_assist(void)
{
struct vcpu *v = current;
@@ -74,7 +74,6 @@ asmlinkage void svm_intr_assist(void)
int intr_type = APIC_DM_EXTINT;
int intr_vector = -1;
int re_injecting = 0;
- unsigned long rflags;
ASSERT(vmcb);
@@ -82,12 +81,19 @@ asmlinkage void svm_intr_assist(void)
/* Previous Interrupt delivery caused this Intercept? */
if (vmcb->exitintinfo.fields.v && (vmcb->exitintinfo.fields.type == 0)) {
v->arch.hvm_svm.saved_irq_vector = vmcb->exitintinfo.fields.vector;
-// printk("Injecting PF#: saving IRQ from ExitInfo\n");
vmcb->exitintinfo.bytes = 0;
re_injecting = 1;
}
/*
+ * If event requires injecting then do not inject int.
+ */
+ if (unlikely(v->arch.hvm_svm.inject_event)) {
+ v->arch.hvm_svm.inject_event = 0;
+ return;
+ }
+
+ /*
* create a 'fake' virtual interrupt on to intercept as soon
* as the guest _can_ take interrupts
*/
@@ -97,14 +103,6 @@ asmlinkage void svm_intr_assist(void)
return;
}
- /* Guest's interrputs masked? */
- rflags = vmcb->rflags;
- if (irq_masked(rflags)) {
- HVM_DBG_LOG(DBG_LEVEL_1, "Guest IRQs masked: rflags: %lx", rflags);
- /* bail out, we won't be injecting an interrupt this time */
- return;
- }
-
/* Previous interrupt still pending? */
if (vmcb->vintr.fields.irq) {
// printk("Re-injecting IRQ from Vintr\n");
@@ -157,7 +155,6 @@ asmlinkage void svm_intr_assist(void)
/* let's inject this interrupt */
TRACE_3D(TRC_VMX_INT, v->domain->domain_id, intr_vector, 0);
svm_inject_extint(v, intr_vector);
- hvm_interrupt_post(v, intr_vector, intr_type);
break;
case APIC_DM_SMI:
case APIC_DM_NMI:
@@ -168,6 +165,7 @@ asmlinkage void svm_intr_assist(void)
BUG();
break;
}
+ hvm_interrupt_post(v, intr_vector, intr_type);
}
}
Index: xen-3.0.3-testing/xen/arch/x86/hvm/svm/svm.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/svm/svm.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/svm/svm.c
@@ -196,6 +196,7 @@ static inline void svm_inject_exception(
ASSERT(vmcb->eventinj.fields.v == 0);
vmcb->eventinj = event;
+ v->arch.hvm_svm.inject_event=1;
}
static void stop_svm(void)
@@ -2589,7 +2590,7 @@ asmlinkage void svm_vmexit_handler(struc
save_svm_cpu_user_regs(v, regs);
vmcb->tlb_control = 1;
-
+ v->arch.hvm_svm.inject_event = 0;
if (exit_reason == VMEXIT_INVALID)
{
Index: xen-3.0.3-testing/xen/include/asm-x86/hvm/svm/vmcb.h
===================================================================
--- xen-3.0.3-testing.orig/xen/include/asm-x86/hvm/svm/vmcb.h
+++ xen-3.0.3-testing/xen/include/asm-x86/hvm/svm/vmcb.h
@@ -484,6 +484,7 @@ struct arch_svm_struct {
u32 *msrpm;
u64 vmexit_tsc; /* tsc read at #VMEXIT. for TSC_OFFSET */
int saved_irq_vector;
+ u32 inject_event;
u32 launch_core;
u32 asid_core;

View File

@ -0,0 +1,33 @@
# HG changeset patch
# User kfraser@localhost.localdomain
# Date Fri Oct 20 10:11:45 2006 +0100
# Node ID 899836e04387bec0fc9f7c080e03ca9c4b9b11fd
# parent: c436ab500c9988f3a295f66b690ad7a98c16b54f
[HVM][SVM] Avoid double-execution of NMI handler.
Remove the do_nmi() call from the vmexit logic, as the NMI is held
pending and will be handled in the context of the host when the STGI
instruction is executed.
Signed-off-by: Tom Woller <thomas.woller@amd.com>
Index: xen-3.0.3-testing/xen/arch/x86/hvm/svm/svm.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/svm/svm.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/svm/svm.c
@@ -54,7 +54,6 @@
/* External functions. We should move these to some suitable header file(s) */
-extern void do_nmi(struct cpu_user_regs *, unsigned long);
extern int inst_copy_from_guest(unsigned char *buf, unsigned long guest_eip,
int inst_len);
extern uint32_t vlapic_update_ppr(struct vlapic *vlapic);
@@ -2730,7 +2729,6 @@ asmlinkage void svm_vmexit_handler(struc
break;
case VMEXIT_NMI:
- do_nmi(regs, 0);
break;
case VMEXIT_SMI:

74
xu-11847-pv-hvm.diff Normal file
View File

@ -0,0 +1,74 @@
# HG changeset patch
# User kfraser@localhost.localdomain
# Date Fri Oct 20 10:58:15 2006 +0100
# Node ID dde8c8038e174ecd8a3ee2f289008465b036d5f8
# parent: 16f1f8ac89024de4a2d5399411d703e281f40c49
Allow default target architecture of PV-on-HVM drivers to be overridden.
Signed-off-by: Travis Betak <travis.betak@amd.com>
--- a/unmodified_drivers/linux-2.6/mkbuildtree Fri Oct 20 10:48:34 2006 +0100
+++ b/unmodified_drivers/linux-2.6/mkbuildtree Fri Oct 20 10:58:15 2006 +0100
@@ -1,4 +1,12 @@
#! /bin/sh
+
+if [ $1 ]; then
+ uname="$1"
+else
+ uname=`uname -m`
+ echo "Defaulting to this machine's architecture, $uname, for linking."
+ echo "This may be overridden on the command line (i386,x86_64,ia64)."
+fi
C=$PWD
@@ -26,30 +34,29 @@ ln -sf ${XEN}/include/public include/xen
# Need to be quite careful here: we don't want the files we link in to
# risk overriding the native Linux ones (in particular, system.h must
# be native and not xenolinux).
-uname=`uname -m`
case "$uname"
in
"x86_64")
- ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/hypervisor.h include/asm
- ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/hypercall.h include/asm
- ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/synch_bitops.h include/asm
- ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/maddr.h include/asm
- ln -sf ${XL}/include/asm-i386 include/asm-i386
- ;;
+ ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/hypervisor.h include/asm
+ ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/hypercall.h include/asm
+ ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/synch_bitops.h include/asm
+ ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/maddr.h include/asm
+ ln -sf ${XL}/include/asm-i386 include/asm-i386
+ ;;
i[34567]86)
- ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypervisor.h include/asm
- ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypercall.h include/asm
- ln -sf ${XL}/include/asm-i386/mach-xen/asm/synch_bitops.h include/asm
- ln -sf ${XL}/include/asm-i386/mach-xen/asm/maddr.h include/asm
- ;;
+ ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypervisor.h include/asm
+ ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypercall.h include/asm
+ ln -sf ${XL}/include/asm-i386/mach-xen/asm/synch_bitops.h include/asm
+ ln -sf ${XL}/include/asm-i386/mach-xen/asm/maddr.h include/asm
+ ;;
"ia64")
- ln -sf ${XL}/include/asm-ia64/hypervisor.h include/asm
- ln -sf ${XL}/include/asm-ia64/hypercall.h include/asm
- ln -sf ${XL}/include/asm-ia64/synch_bitops.h include/asm
- ln -sf ${XL}/include/asm-ia64/maddr.h include/asm
- ;;
+ ln -sf ${XL}/include/asm-ia64/hypervisor.h include/asm
+ ln -sf ${XL}/include/asm-ia64/hypercall.h include/asm
+ ln -sf ${XL}/include/asm-ia64/synch_bitops.h include/asm
+ ln -sf ${XL}/include/asm-ia64/maddr.h include/asm
+ ;;
*)
- echo unknown architecture $uname
- exit 1
- ;;
+ echo unknown architecture $uname
+ exit 1
+ ;;
esac

45
xu-11888-pv-hvm.diff Normal file
View File

@ -0,0 +1,45 @@
# HG changeset patch
# User kfraser@localhost.localdomain
# Date Wed Oct 25 10:59:00 2006 +0100
# Node ID ffbd9e4668a6cfd3c936c7344c194afe368f2642
# parent: 4be49a3be040f0951a9be971e9b4cf0a399589ec
[BLOCK] blkback: Fix potential grant entry leaks on error
As it stands grant entries for the actual data are mapped in bulk.
If one of the earlier entries fail to be mapped, it can cause all
subsequent entries to be leaked if they were successfully mapped.
This patch changes it so that we will continue to reap grant entries
even when an error is detected.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Wed Oct 25 10:56:50 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Wed Oct 25 10:59:00 2006 +0100
@@ -392,16 +392,24 @@ static void dispatch_rw_block_io(blkif_t
for (i = 0; i < nseg; i++) {
if (unlikely(map[i].status != 0)) {
DPRINTK("invalid buffer -- could not remap it\n");
- goto fail_flush;
+ map[i].handle = BLKBACK_INVALID_HANDLE;
+ ret |= 1;
}
pending_handle(pending_req, i) = map[i].handle;
+
+ if (ret)
+ continue;
+
set_phys_to_machine(__pa(vaddr(
pending_req, i)) >> PAGE_SHIFT,
FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
seg[i].buf = map[i].dev_bus_addr |
(req->seg[i].first_sect << 9);
}
+
+ if (ret)
+ goto fail_flush;
if (vbd_translate(&preq, blkif, operation) != 0) {
DPRINTK("access denied: %s of [%llu,%llu] on dev=%04x\n",

65
xu-11896-pv-hvm.diff Normal file
View File

@ -0,0 +1,65 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID e715360e82f8d8aa72356fc77df7f4e564a97062
# parent: 041507e2754cda7a21bb878f703daee47cbe843e
[LINUX] PV-on-HVM: Directly include headers which are used in various
files rather than relying on them being included indirectly.
This is required because these headers are not pulled in indirectly on
older kernels.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c Wed Oct 25 12:30:08 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c Wed Oct 25 13:58:30 2006 +0100
@@ -40,6 +40,7 @@
#include <linux/wait.h>
#include <linux/fs.h>
#include <linux/poll.h>
+#include <linux/mutex.h>
#include "xenbus_comms.h"
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 12:30:08 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
@@ -42,6 +42,7 @@
#include <linux/mm.h>
#include <linux/notifier.h>
#include <linux/kthread.h>
+#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/page.h>
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Wed Oct 25 12:30:08 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Wed Oct 25 13:58:30 2006 +0100
@@ -42,6 +42,8 @@
#include <linux/fcntl.h>
#include <linux/kthread.h>
#include <linux/rwsem.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
#include <xen/xenbus.h>
#include "xenbus_comms.h"
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h Wed Oct 25 12:30:08 2006 +0100
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h Wed Oct 25 13:58:30 2006 +0100
@@ -38,6 +38,7 @@
#include <linux/notifier.h>
#include <linux/mutex.h>
#include <linux/completion.h>
+#include <linux/init.h>
#include <xen/interface/xen.h>
#include <xen/interface/grant_table.h>
#include <xen/interface/io/xenbus.h>
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c Wed Oct 25 12:30:08 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c Wed Oct 25 13:58:30 2006 +0100
@@ -33,6 +33,7 @@
#include <asm/irq.h>
#include <asm/uaccess.h>
#include <asm/hypervisor.h>
+#include <asm/pgtable.h>
#include <xen/interface/memory.h>
#include <xen/features.h>

40
xu-11897-pv-hvm.diff Normal file
View File

@ -0,0 +1,40 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID 266aef9b0386b0742e05893e24e09375b31bf835
# parent: e715360e82f8d8aa72356fc77df7f4e564a97062
PV-on-HVM: Include a Makefile in each subdirectory to maintain
compatability with kernels from before Kbuild files were introduced.
This follows best practice as described in
Documentation/kbuild/modules.txt
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/blkfront/Makefile Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/netfront/Makefile Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/Makefile Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/xenbus/Makefile Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,3 @@
+ifneq ($(KERNELRELEASE),)
+include $(src)/Kbuild
+endif

764
xu-11898-pv-hvm.diff Normal file
View File

@ -0,0 +1,764 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID 47cc7392741ad120a0c5745f7aeaf00a1aefd538
# parent: 266aef9b0386b0742e05893e24e09375b31bf835
[LINUX] Move xenbus backend probing into a separate source file and
only build it when CONFIG_XEN_BACKEND is set.
This removes unused code from frontend only configurations and also
makes PV-on-HVM drivers on older kernels simpler by removing code
which would otherwise require extra code in the compatability shim.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile Wed Oct 25 13:58:30 2006 +0100
@@ -9,4 +9,5 @@ xenbus-objs += xenbus_comms.o
xenbus-objs += xenbus_comms.o
xenbus-objs += xenbus_xs.o
xenbus-objs += xenbus_probe.o
+obj-$(CONFIG_XEN_BACKEND) += xenbus_probe_backend.o
obj-$(CONFIG_XEN_XENBUS_DEV) += xenbus_dev.o
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
@@ -56,6 +56,7 @@
#include <xen/hvm.h>
#include "xenbus_comms.h"
+#include "xenbus_probe.h"
int xen_store_evtchn;
struct xenstore_domain_interface *xen_store_interface;
@@ -68,12 +69,7 @@ static void wait_for_devices(struct xenb
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. */
@@ -87,7 +83,7 @@ match_device(const struct xenbus_device_
return NULL;
}
-static int xenbus_match(struct device *_dev, struct device_driver *_drv)
+int xenbus_match(struct device *_dev, struct device_driver *_drv)
{
struct xenbus_driver *drv = to_xenbus_driver(_drv);
@@ -96,17 +92,6 @@ static int xenbus_match(struct device *_
return match_device(drv->ids, to_xenbus_device(_dev)) != NULL;
}
-
-struct xen_bus_type
-{
- char *root;
- unsigned int levels;
- int (*get_bus_id)(char bus_id[BUS_ID_SIZE], const char *nodename);
- int (*probe)(const char *type, const char *dir);
- struct bus_type bus;
- struct device dev;
-};
-
/* device/<type>/<id> => <type>-<id> */
static int frontend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
@@ -144,7 +129,7 @@ static void free_otherend_watch(struct x
}
-static int read_otherend_details(struct xenbus_device *xendev,
+int read_otherend_details(struct xenbus_device *xendev,
char *id_node, char *path_node)
{
int err = xenbus_gather(XBT_NIL, xendev->nodename,
@@ -174,12 +159,6 @@ static int read_backend_details(struct x
static int read_backend_details(struct xenbus_device *xendev)
{
return read_otherend_details(xendev, "backend-id", "backend");
-}
-
-
-static int read_frontend_details(struct xenbus_device *xendev)
-{
- return read_otherend_details(xendev, "frontend-id", "frontend");
}
@@ -201,106 +180,6 @@ static struct xen_bus_type xenbus_fronte
},
};
-/* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
-static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
-{
- int domid, err;
- const char *devid, *type, *frontend;
- unsigned int typelen;
-
- type = strchr(nodename, '/');
- if (!type)
- return -EINVAL;
- type++;
- typelen = strcspn(type, "/");
- if (!typelen || type[typelen] != '/')
- return -EINVAL;
-
- devid = strrchr(nodename, '/') + 1;
-
- 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_NIL, frontend, ""))
- err = -ENOENT;
-
- kfree(frontend);
-
- if (err)
- return err;
-
- if (snprintf(bus_id, BUS_ID_SIZE,
- "%.*s-%i-%s", typelen, type, domid, devid) >= BUS_ID_SIZE)
- return -ENOSPC;
- return 0;
-}
-
-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,
- .probe = xenbus_dev_probe,
- .remove = xenbus_dev_remove,
-// .shutdown = xenbus_dev_shutdown,
- .uevent = xenbus_uevent_backend,
- },
- .dev = {
- .bus_id = "xen-backend",
- },
-};
-
-static int xenbus_uevent_backend(struct device *dev, char **envp,
- int num_envp, char *buffer, int buffer_size)
-{
- struct xenbus_device *xdev;
- struct xenbus_driver *drv;
- int i = 0;
- int length = 0;
-
- DPRINTK("");
-
- if (dev == NULL)
- return -ENODEV;
-
- xdev = to_xenbus_device(dev);
- if (xdev == NULL)
- return -ENODEV;
-
- /* stuff we want to pass to /sbin/hotplug */
- add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
- "XENBUS_TYPE=%s", xdev->devicetype);
-
- add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
- "XENBUS_PATH=%s", xdev->nodename);
-
- add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
- "XENBUS_BASE_PATH=%s", xenbus_backend.root);
-
- /* terminate, set to next free slot, shrink available space */
- envp[i] = NULL;
- envp = &envp[i];
- num_envp -= i;
- buffer = &buffer[length];
- buffer_size -= length;
-
- if (dev->driver) {
- drv = to_xenbus_driver(dev->driver);
- if (drv && drv->uevent)
- return drv->uevent(xdev, envp, num_envp, buffer,
- buffer_size);
- }
-
- return 0;
-}
-
static void otherend_changed(struct xenbus_watch *watch,
const char **vec, unsigned int len)
{
@@ -360,7 +239,7 @@ static int watch_otherend(struct xenbus_
}
-static int xenbus_dev_probe(struct device *_dev)
+int xenbus_dev_probe(struct device *_dev)
{
struct xenbus_device *dev = to_xenbus_device(_dev);
struct xenbus_driver *drv = to_xenbus_driver(_dev->driver);
@@ -407,7 +286,7 @@ fail:
return -ENODEV;
}
-static int xenbus_dev_remove(struct device *_dev)
+int xenbus_dev_remove(struct device *_dev)
{
struct xenbus_device *dev = to_xenbus_device(_dev);
struct xenbus_driver *drv = to_xenbus_driver(_dev->driver);
@@ -445,8 +324,8 @@ static void xenbus_dev_shutdown(struct d
put_device(&dev->dev);
}
-static int xenbus_register_driver_common(struct xenbus_driver *drv,
- struct xen_bus_type *bus)
+int xenbus_register_driver_common(struct xenbus_driver *drv,
+ struct xen_bus_type *bus)
{
int ret;
@@ -476,14 +355,6 @@ int xenbus_register_frontend(struct xenb
return 0;
}
EXPORT_SYMBOL_GPL(xenbus_register_frontend);
-
-int xenbus_register_backend(struct xenbus_driver *drv)
-{
- drv->read_otherend_details = read_frontend_details;
-
- return xenbus_register_driver_common(drv, &xenbus_backend);
-}
-EXPORT_SYMBOL_GPL(xenbus_register_backend);
void xenbus_unregister_driver(struct xenbus_driver *drv)
{
@@ -596,9 +467,9 @@ DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP |
DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_devtype, NULL);
-static int xenbus_probe_node(struct xen_bus_type *bus,
- const char *type,
- const char *nodename)
+int xenbus_probe_node(struct xen_bus_type *bus,
+ const char *type,
+ const char *nodename)
{
int err;
struct xenbus_device *xendev;
@@ -668,55 +539,6 @@ static int xenbus_probe_frontend(const c
return err;
}
-/* backend/<typename>/<frontend-uuid>/<name> */
-static int xenbus_probe_backend_unit(const char *dir,
- const char *type,
- const char *name)
-{
- char *nodename;
- int err;
-
- nodename = kasprintf("%s/%s", dir, name);
- if (!nodename)
- return -ENOMEM;
-
- DPRINTK("%s\n", nodename);
-
- err = xenbus_probe_node(&xenbus_backend, type, nodename);
- kfree(nodename);
- return err;
-}
-
-/* backend/<typename>/<frontend-domid> */
-static int xenbus_probe_backend(const char *type, const char *domid)
-{
- char *nodename;
- int err = 0;
- char **dir;
- unsigned int i, dir_n = 0;
-
- DPRINTK("");
-
- nodename = kasprintf("%s/%s/%s", xenbus_backend.root, type, domid);
- if (!nodename)
- return -ENOMEM;
-
- dir = xenbus_directory(XBT_NIL, nodename, "", &dir_n);
- if (IS_ERR(dir)) {
- kfree(nodename);
- return PTR_ERR(dir);
- }
-
- for (i = 0; i < dir_n; i++) {
- err = xenbus_probe_backend_unit(nodename, type, dir[i]);
- if (err)
- break;
- }
- kfree(dir);
- kfree(nodename);
- return err;
-}
-
static int xenbus_probe_device_type(struct xen_bus_type *bus, const char *type)
{
int err = 0;
@@ -737,7 +559,7 @@ static int xenbus_probe_device_type(stru
return err;
}
-static int xenbus_probe_devices(struct xen_bus_type *bus)
+int xenbus_probe_devices(struct xen_bus_type *bus)
{
int err = 0;
char **dir;
@@ -779,7 +601,7 @@ static int strsep_len(const char *str, c
return (len == 0) ? i : -ERANGE;
}
-static void dev_changed(const char *node, struct xen_bus_type *bus)
+void dev_changed(const char *node, struct xen_bus_type *bus)
{
int exists, rootlen;
struct xenbus_device *dev;
@@ -824,23 +646,10 @@ static void frontend_changed(struct xenb
dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend);
}
-static void backend_changed(struct xenbus_watch *watch,
- const char **vec, unsigned int len)
-{
- DPRINTK("");
-
- dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
-}
-
/* We watch for devices appearing and vanishing. */
static struct xenbus_watch fe_watch = {
.node = "device",
.callback = frontend_changed,
-};
-
-static struct xenbus_watch be_watch = {
- .node = "backend",
- .callback = backend_changed,
};
static int suspend_dev(struct device *dev, void *data)
@@ -913,7 +722,7 @@ void xenbus_suspend(void)
DPRINTK("");
bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
- bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, suspend_dev);
+ xenbus_backend_suspend(suspend_dev);
xs_suspend();
}
EXPORT_SYMBOL_GPL(xenbus_suspend);
@@ -923,7 +732,7 @@ void xenbus_resume(void)
xb_init_comms();
xs_resume();
bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
- bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev);
+ xenbus_backend_resume(resume_dev);
}
EXPORT_SYMBOL_GPL(xenbus_resume);
@@ -956,13 +765,10 @@ void xenbus_probe(void *unused)
{
BUG_ON((xenstored_ready <= 0));
- /* Enumerate devices in xenstore. */
+ /* Enumerate devices in xenstore and watch for changes. */
xenbus_probe_devices(&xenbus_frontend);
- xenbus_probe_devices(&xenbus_backend);
-
- /* Watch for changes. */
register_xenbus_watch(&fe_watch);
- register_xenbus_watch(&be_watch);
+ xenbus_backend_probe_and_watch();
/* Notify others that xenstore is up */
notifier_call_chain(&xenstore_chain, 0, NULL);
@@ -1021,7 +827,7 @@ static int __init xenbus_probe_init(void
/* Register ourselves with the kernel bus subsystem */
bus_register(&xenbus_frontend.bus);
- bus_register(&xenbus_backend.bus);
+ xenbus_backend_bus_register();
/*
* Domain0 doesn't have a store_evtchn or store_mfn yet.
@@ -1092,7 +898,7 @@ static int __init xenbus_probe_init(void
/* Register ourselves with the kernel device subsystem */
device_register(&xenbus_frontend.dev);
- device_register(&xenbus_backend.dev);
+ xenbus_backend_device_register();
if (!is_initial_xendomain())
xenbus_probe(NULL);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.h Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * xenbus_probe.h
+ *
+ * Talks to Xen Store to figure out what devices we have.
+ *
+ * Copyright (C) 2005 Rusty Russell, IBM Corporation
+ * 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 _XENBUS_PROBE_H
+#define _XENBUS_PROBE_H
+
+#ifdef CONFIG_XEN_BACKEND
+extern void xenbus_backend_suspend(int (*fn)(struct device *, void *));
+extern void xenbus_backend_resume(int (*fn)(struct device *, void *));
+extern void xenbus_backend_probe_and_watch(void);
+extern void xenbus_backend_bus_register(void);
+extern void xenbus_backend_device_register(void);
+#else
+static inline void xenbus_backend_suspend(int (*fn)(struct device *, void *)) {}
+static inline void xenbus_backend_resume(int (*fn)(struct device *, void *)) {}
+static inline void xenbus_backend_probe_and_watch(void) {}
+static inline void xenbus_backend_bus_register(void) {}
+static inline void xenbus_backend_device_register(void) {}
+#endif
+
+struct xen_bus_type
+{
+ char *root;
+ unsigned int levels;
+ int (*get_bus_id)(char bus_id[BUS_ID_SIZE], const char *nodename);
+ int (*probe)(const char *type, const char *dir);
+ struct bus_type bus;
+ struct device dev;
+};
+
+extern int xenbus_match(struct device *_dev, struct device_driver *_drv);
+extern int xenbus_dev_probe(struct device *_dev);
+extern int xenbus_dev_remove(struct device *_dev);
+extern int xenbus_register_driver_common(struct xenbus_driver *drv,
+ struct xen_bus_type *bus);
+extern int xenbus_probe_node(struct xen_bus_type *bus,
+ const char *type,
+ const char *nodename);
+extern int xenbus_probe_devices(struct xen_bus_type *bus);
+
+extern void dev_changed(const char *node, struct xen_bus_type *bus);
+
+/* Simplified asprintf. Probably belongs in lib */
+extern char *kasprintf(const char *fmt, ...);
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe_backend.c Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,271 @@
+/******************************************************************************
+ * Talks to Xen Store to figure out what devices we have (backend half).
+ *
+ * Copyright (C) 2005 Rusty Russell, IBM Corporation
+ * Copyright (C) 2005 Mike Wray, Hewlett-Packard
+ * Copyright (C) 2005, 2006 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.
+ */
+
+#define DPRINTK(fmt, args...) \
+ pr_debug("xenbus_probe (%s:%d) " fmt ".\n", \
+ __FUNCTION__, __LINE__, ##args)
+
+#include <linux/kernel.h>
+#include <linux/err.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/fcntl.h>
+#include <linux/mm.h>
+#include <linux/notifier.h>
+#include <linux/kthread.h>
+
+#include <asm/io.h>
+#include <asm/page.h>
+#include <asm/maddr.h>
+#include <asm/pgtable.h>
+#include <asm/hypervisor.h>
+#include <xen/xenbus.h>
+#include <xen/xen_proc.h>
+#include <xen/evtchn.h>
+#include <xen/features.h>
+#include <xen/hvm.h>
+
+#include "xenbus_comms.h"
+#include "xenbus_probe.h"
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
+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);
+
+extern int read_otherend_details(struct xenbus_device *xendev,
+ char *id_node, char *path_node);
+
+static int read_frontend_details(struct xenbus_device *xendev)
+{
+ return read_otherend_details(xendev, "frontend-id", "frontend");
+}
+
+/* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
+static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
+{
+ int domid, err;
+ const char *devid, *type, *frontend;
+ unsigned int typelen;
+
+ type = strchr(nodename, '/');
+ if (!type)
+ return -EINVAL;
+ type++;
+ typelen = strcspn(type, "/");
+ if (!typelen || type[typelen] != '/')
+ return -EINVAL;
+
+ devid = strrchr(nodename, '/') + 1;
+
+ 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_NIL, frontend, ""))
+ err = -ENOENT;
+ kfree(frontend);
+
+ if (err)
+ return err;
+
+ if (snprintf(bus_id, BUS_ID_SIZE,
+ "%.*s-%i-%s", typelen, type, domid, devid) >= BUS_ID_SIZE)
+ return -ENOSPC;
+ return 0;
+}
+
+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,
+ .probe = xenbus_dev_probe,
+ .remove = xenbus_dev_remove,
+// .shutdown = xenbus_dev_shutdown,
+ .uevent = xenbus_uevent_backend,
+ },
+ .dev = {
+ .bus_id = "xen-backend",
+ },
+};
+
+static int xenbus_uevent_backend(struct device *dev, char **envp,
+ int num_envp, char *buffer, int buffer_size)
+{
+ struct xenbus_device *xdev;
+ struct xenbus_driver *drv;
+ int i = 0;
+ int length = 0;
+
+ DPRINTK("");
+
+ if (dev == NULL)
+ return -ENODEV;
+
+ xdev = to_xenbus_device(dev);
+ if (xdev == NULL)
+ return -ENODEV;
+
+ /* stuff we want to pass to /sbin/hotplug */
+ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
+ "XENBUS_TYPE=%s", xdev->devicetype);
+
+ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
+ "XENBUS_PATH=%s", xdev->nodename);
+
+ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
+ "XENBUS_BASE_PATH=%s", xenbus_backend.root);
+
+ /* terminate, set to next free slot, shrink available space */
+ envp[i] = NULL;
+ envp = &envp[i];
+ num_envp -= i;
+ buffer = &buffer[length];
+ buffer_size -= length;
+
+ if (dev->driver) {
+ drv = to_xenbus_driver(dev->driver);
+ if (drv && drv->uevent)
+ return drv->uevent(xdev, envp, num_envp, buffer,
+ buffer_size);
+ }
+
+ return 0;
+}
+
+int xenbus_register_backend(struct xenbus_driver *drv)
+{
+ drv->read_otherend_details = read_frontend_details;
+
+ return xenbus_register_driver_common(drv, &xenbus_backend);
+}
+EXPORT_SYMBOL_GPL(xenbus_register_backend);
+
+/* backend/<typename>/<frontend-uuid>/<name> */
+static int xenbus_probe_backend_unit(const char *dir,
+ const char *type,
+ const char *name)
+{
+ char *nodename;
+ int err;
+
+ nodename = kasprintf("%s/%s", dir, name);
+ if (!nodename)
+ return -ENOMEM;
+
+ DPRINTK("%s\n", nodename);
+
+ err = xenbus_probe_node(&xenbus_backend, type, nodename);
+ kfree(nodename);
+ return err;
+}
+
+/* backend/<typename>/<frontend-domid> */
+static int xenbus_probe_backend(const char *type, const char *domid)
+{
+ char *nodename;
+ int err = 0;
+ char **dir;
+ unsigned int i, dir_n = 0;
+
+ DPRINTK("");
+
+ nodename = kasprintf("%s/%s/%s", xenbus_backend.root, type, domid);
+ if (!nodename)
+ return -ENOMEM;
+
+ dir = xenbus_directory(XBT_NIL, nodename, "", &dir_n);
+ if (IS_ERR(dir)) {
+ kfree(nodename);
+ return PTR_ERR(dir);
+ }
+
+ for (i = 0; i < dir_n; i++) {
+ err = xenbus_probe_backend_unit(nodename, type, dir[i]);
+ if (err)
+ break;
+ }
+ kfree(dir);
+ kfree(nodename);
+ return err;
+}
+
+static void backend_changed(struct xenbus_watch *watch,
+ const char **vec, unsigned int len)
+{
+ DPRINTK("");
+
+ dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
+}
+
+static struct xenbus_watch be_watch = {
+ .node = "backend",
+ .callback = backend_changed,
+};
+
+void xenbus_backend_suspend(int (*fn)(struct device *, void *))
+{
+ DPRINTK("");
+ bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, fn);
+}
+
+void xenbus_backend_resume(int (*fn)(struct device *, void *))
+{
+ DPRINTK("");
+ bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, fn);
+}
+
+void xenbus_backend_probe_and_watch(void)
+{
+ xenbus_probe_devices(&xenbus_backend);
+ register_xenbus_watch(&be_watch);
+}
+
+void xenbus_backend_bus_register(void)
+{
+ bus_register(&xenbus_backend.bus);
+}
+
+void xenbus_backend_device_register(void)
+{
+ device_register(&xenbus_backend.dev);
+}

39
xu-11899-pv-hvm.diff Normal file
View File

@ -0,0 +1,39 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID bd643d9db83860ca35ef53f9a3e584985c725c14
# parent: 47cc7392741ad120a0c5745f7aeaf00a1aefd538
[LINUX] PV-on-HVM: Remove the attr parameter from device attribute
show methods on kernels prior to 2.6.13. The parameter was not present
before that.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
@@ -453,14 +453,20 @@ char *kasprintf(const char *fmt, ...)
}
static ssize_t xendev_show_nodename(struct device *dev,
- struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
+ struct device_attribute *attr,
+#endif
+ char *buf)
{
return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
}
DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
static ssize_t xendev_show_devtype(struct device *dev,
- struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
+ struct device_attribute *attr,
+#endif
+ char *buf)
{
return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
}

34
xu-11900-pv-hvm.diff Normal file
View File

@ -0,0 +1,34 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID 40107f658bd984190e14746f25dac750badf4d8c
# parent: bd643d9db83860ca35ef53f9a3e584985c725c14
[LINUX] Exclude support for /proc/xen/xsd_kva when building a
non-privileged guest.
This is useful for PV-on-HVM because it removes code which would
otherwise require extra code in the compatability shim.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
@@ -781,7 +781,7 @@ void xenbus_probe(void *unused)
}
-#ifdef CONFIG_PROC_FS
+#if defined(CONFIG_PROC_FS) && defined(CONFIG_XEN_PRIVILEGED_GUEST)
static struct file_operations xsd_kva_fops;
static struct proc_dir_entry *xsd_kva_intf;
static struct proc_dir_entry *xsd_port_intf;
@@ -862,7 +862,7 @@ static int __init xenbus_probe_init(void
xen_store_evtchn = xen_start_info->store_evtchn =
alloc_unbound.port;
-#ifdef CONFIG_PROC_FS
+#if defined(CONFIG_PROC_FS) && defined(CONFIG_XEN_PRIVILEGED_GUEST)
/* And finally publish the above info in /proc/xen */
xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0600);
if (xsd_kva_intf) {

26
xu-11901-pv-hvm.diff Normal file
View File

@ -0,0 +1,26 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID 8102ccad440d3218a179e45c296e328aba564983
# parent: 40107f658bd984190e14746f25dac750badf4d8c
[LINUX] PV-on-HVM: Only initialize the owner field of struct
device_driver on kernels from 2.6.10 onward. The field was not
available until then.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
@@ -331,7 +331,9 @@ int xenbus_register_driver_common(struct
drv->driver.name = drv->name;
drv->driver.bus = &bus->bus;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
drv->driver.owner = drv->owner;
+#endif
mutex_lock(&xenwatch_mutex);
ret = driver_register(&drv->driver);

40
xu-11902-pv-hvm.diff Normal file
View File

@ -0,0 +1,40 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID a0919d3f7d50dad3db4268611213a3923a497afd
# parent: 8102ccad440d3218a179e45c296e328aba564983
[LINUX] PV-on-HVM: The probe, remove and shutdown methods were added
to struct bus_type in 2.6.16. For older kernels use the methods on the
struct device_driver.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
@@ -171,9 +171,11 @@ static struct xen_bus_type xenbus_fronte
.bus = {
.name = "xen",
.match = xenbus_match,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
.probe = xenbus_dev_probe,
.remove = xenbus_dev_remove,
.shutdown = xenbus_dev_shutdown,
+#endif
},
.dev = {
.bus_id = "xen",
@@ -333,6 +335,11 @@ int xenbus_register_driver_common(struct
drv->driver.bus = &bus->bus;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
drv->driver.owner = drv->owner;
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+ drv->driver.probe = xenbus_dev_probe;
+ drv->driver.remove = xenbus_dev_remove;
+ drv->driver.shutdown = xenbus_dev_shutdown;
#endif
mutex_lock(&xenwatch_mutex);

55
xu-11903-pv-hvm.diff Normal file
View File

@ -0,0 +1,55 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID 1c985a2e47eadc66e747443dfa65099e5f1dec86
# parent: a0919d3f7d50dad3db4268611213a3923a497afd
[LINUX] PV-on-HVM: Implement HDIO_GETGEO ioctl on kernels before
2.6.16.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Wed Oct 25 13:58:30 2006 +0100
@@ -468,6 +468,27 @@ int blkif_ioctl(struct inode *inode, str
command, (long)argument, inode->i_rdev);
switch (command) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+ case HDIO_GETGEO: {
+ struct block_device *bd = inode->i_bdev;
+ struct hd_geometry geo;
+ int ret;
+
+ if (!argument)
+ return -EINVAL;
+
+ geo.start = get_start_sect(bd);
+ ret = blkif_getgeo(bd, &geo);
+ if (ret)
+ return ret;
+
+ if (copy_to_user((struct hd_geometry __user *)argument, &geo,
+ sizeof(geo)))
+ return -EFAULT;
+
+ return 0;
+ }
+#endif
case CDROMMULTISESSION:
DPRINTK("FIXME: support multisession CDs later\n");
for (i = 0; i < sizeof(struct cdrom_multisession); i++)
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c Wed Oct 25 13:58:30 2006 +0100
@@ -91,7 +91,9 @@ static struct block_device_operations xl
.open = blkif_open,
.release = blkif_release,
.ioctl = blkif_ioctl,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
.getgeo = blkif_getgeo
+#endif
};
DEFINE_SPINLOCK(blkif_io_lock);

26
xu-11904-pv-hvm.diff Normal file
View File

@ -0,0 +1,26 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID db23596992f9388fb776a4518ae638b22ee7c8c2
# parent: 1c985a2e47eadc66e747443dfa65099e5f1dec86
[LINUX] PV-on-HVM: The elevator_init prototype changed in 2.6.10
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c Wed Oct 25 13:58:30 2006 +0100
@@ -188,7 +188,11 @@ xlvbd_init_blk_queue(struct gendisk *gd,
if (rq == NULL)
return -1;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
elevator_init(rq, "noop");
+#else
+ elevator_init(rq, &elevator_noop);
+#endif
/* Hard sector size and max sectors impersonate the equiv. hardware. */
blk_queue_hardsect_size(rq, sector_size);

230
xu-11905-pv-hvm.diff Normal file
View File

@ -0,0 +1,230 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID 206e20b7b54e09394ed161006439ee2b75ecee5e
# parent: db23596992f9388fb776a4518ae638b22ee7c8c2
PV-on-HVM: Add infrastructure for a compatibility shim in order to
support PV-on-HVM drivers for older kernel releases.
The compatability code is included in the xen-platform-pci module
since this module underpins all the others.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Wed Oct 25 13:58:30 2006 +0100
@@ -48,6 +48,10 @@
#include <asm/hypervisor.h>
#include <asm/maddr.h>
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
#define BLKIF_STATE_DISCONNECTED 0
#define BLKIF_STATE_CONNECTED 1
#define BLKIF_STATE_SUSPENDED 2
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c Wed Oct 25 13:58:30 2006 +0100
@@ -35,6 +35,10 @@
#include "block.h"
#include <linux/blkdev.h>
#include <linux/list.h>
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
#define BLKIF_MAJOR(dev) ((dev)>>8)
#define BLKIF_MINOR(dev) ((dev) & 0xff)
--- a/linux-2.6-xen-sparse/drivers/xen/core/features.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/features.c Wed Oct 25 13:58:30 2006 +0100
@@ -10,6 +10,10 @@
#include <linux/module.h>
#include <asm/hypervisor.h>
#include <xen/features.h>
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly;
/* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c Wed Oct 25 13:58:30 2006 +0100
@@ -44,6 +44,10 @@
#include <asm/io.h>
#include <xen/interface/memory.h>
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
/* External tools reserve first few grant table entries. */
#define NR_RESERVED_ENTRIES 8
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Wed Oct 25 13:58:30 2006 +0100
@@ -64,6 +64,10 @@
#include <xen/interface/grant_table.h>
#include <xen/gnttab.h>
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
/*
* Mutually-exclusive module options to select receive data path:
* rx_copy : Packets are copied by network backend into local memory
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c Wed Oct 25 13:58:30 2006 +0100
@@ -34,6 +34,10 @@
#include <xen/gnttab.h>
#include <xen/xenbus.h>
#include <xen/driver_util.h>
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
/* xenbus_probe.c */
extern char *kasprintf(const char *fmt, ...);
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c Wed Oct 25 13:58:30 2006 +0100
@@ -39,6 +39,10 @@
#include <xen/xenbus.h>
#include "xenbus_comms.h"
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
static int xenbus_irq;
extern void xenbus_probe(void *);
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c Wed Oct 25 13:58:30 2006 +0100
@@ -49,6 +49,10 @@
#include <xen/xenbus.h>
#include <xen/xen_proc.h>
#include <asm/hypervisor.h>
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
struct xenbus_dev_transaction {
struct list_head list;
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 25 13:58:30 2006 +0100
@@ -58,6 +58,10 @@
#include "xenbus_comms.h"
#include "xenbus_probe.h"
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
int xen_store_evtchn;
struct xenstore_domain_interface *xen_store_interface;
static unsigned long xen_store_mfn;
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Wed Oct 25 13:58:30 2006 +0100
@@ -47,6 +47,10 @@
#include <xen/xenbus.h>
#include "xenbus_comms.h"
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
/* xenbus_probe.c */
extern char *kasprintf(const char *fmt, ...);
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h Wed Oct 25 13:58:30 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h Wed Oct 25 13:58:30 2006 +0100
@@ -8,6 +8,10 @@
*/
#include <linux/config.h>
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
#define ADDR (*(volatile long *) addr)
--- a/unmodified_drivers/linux-2.6/overrides.mk Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/overrides.mk Wed Oct 25 13:58:30 2006 +0100
@@ -9,4 +9,4 @@ EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRAN
EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRANT -DXEN_EVTCHN_MASK_OPS
EXTRA_CFLAGS += -DCONFIG_XEN_NETDEV_GRANT_RX -DCONFIG_XEN_NETDEV_GRANT_TX
EXTRA_CFLAGS += -D__XEN_INTERFACE_VERSION__=0x00030202
-EXTRA_CFLAGS += -I$(M)/include
+EXTRA_CFLAGS += -I$(M)/include -I$(M)/compat-include -DHAVE_XEN_PLATFORM_COMPAT_H
--- a/unmodified_drivers/linux-2.6/platform-pci/Kbuild Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/Kbuild Wed Oct 25 13:58:30 2006 +0100
@@ -4,4 +4,4 @@ obj-m := xen-platform-pci.o
EXTRA_CFLAGS += -I$(M)/platform-pci
-xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o
+xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o platform-compat.o
--- a/unmodified_drivers/linux-2.6/platform-pci/evtchn.c Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/evtchn.c Wed Oct 25 13:58:30 2006 +0100
@@ -35,6 +35,10 @@
#include <xen/interface/hvm/ioreq.h>
#include <xen/features.h>
#include "platform-pci.h"
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
void *shared_info_area;
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c Wed Oct 25 13:58:30 2006 +0100
@@ -39,6 +39,10 @@
#include "platform-pci.h"
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
#define DRV_NAME "xen-platform-pci"
#define DRV_VERSION "0.10"
#define DRV_RELDATE "03/03/2005"
--- a/unmodified_drivers/linux-2.6/platform-pci/xen_support.c Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/xen_support.c Wed Oct 25 13:58:30 2006 +0100
@@ -26,6 +26,10 @@
#include <asm/hypervisor.h>
#include "platform-pci.h"
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
+
void xen_machphys_update(unsigned long mfn, unsigned long pfn)
{
BUG();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,6 @@
+#ifndef COMPAT_INCLUDE_XEN_PLATFORM_COMPAT_H
+#define COMPAT_INCLUDE_XEN_PLATFORM_COMPAT_H
+
+#include <linux/version.h>
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,4 @@
+#include <linux/config.h>
+#include <linux/version.h>
+
+#include <xen/platform-compat.h>

25
xu-11906-pv-hvm.diff Normal file
View File

@ -0,0 +1,25 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID d008b6b44f3c9bd7d7f49737fdc1c93370bf783d
# parent: 206e20b7b54e09394ed161006439ee2b75ecee5e
PV-on-HVM: Add a compatibility linux/io.h for kernels before 2.6.16
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/io.h Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,10 @@
+#ifndef _LINUX_IO_H
+#define _LINUX_IO_H
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#error "This version of Linux should not need compat linux/io.h"
+#endif
+
+#include <asm/io.h>
+
+#endif

48
xu-11907-pv-hvm.diff Normal file
View File

@ -0,0 +1,48 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID ecc1782f69680d94b7d2fe4283616e4890b55504
# parent: d008b6b44f3c9bd7d7f49737fdc1c93370bf783d
PV-on-HVM: Add a compatibility linux/mutex.h for kernels before
2.6.16. This implements the new mutex type in terms of the old
semaphore type.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/mutex.h Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2006 Cisco Systems. All rights reserved.
+ *
+ * This file is released under the GPLv2.
+ */
+
+/* mutex compatibility for pre-2.6.16 kernels */
+
+#ifndef __LINUX_MUTEX_H
+#define __LINUX_MUTEX_H
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#error "This version of Linux should not need compat mutex.h"
+#endif
+
+#include <linux/version.h>
+#include <asm/semaphore.h>
+
+#define mutex semaphore
+#define DEFINE_MUTEX(foo) DECLARE_MUTEX(foo)
+#define mutex_init(foo) init_MUTEX(foo)
+#define mutex_lock(foo) down(foo)
+#define mutex_lock_interruptible(foo) down_interruptible(foo)
+/* this function follows the spin_trylock() convention, so *
+ * it is negated to the down_trylock() return values! Be careful */
+#define mutex_trylock(foo) !down_trylock(foo)
+#define mutex_unlock(foo) up(foo)
+
+#endif /* __LINUX_MUTEX_H */

47
xu-11908-pv-hvm.diff Normal file
View File

@ -0,0 +1,47 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID e09720caf72dbdc0fe0689c8e2bf8ace97abaae4
# parent: ecc1782f69680d94b7d2fe4283616e4890b55504
PV-on-HVM: Include compatability headers for asm/pgtable-no{pmd,pud}.h
for kernels before 2.6.11.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopmd.h Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPMD_H
+#define _PGTABLE_NOPMD_H
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+#error "This version of Linux should not need compat pgtable-nopmd.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud) 0
+#define pud_present(pud) 1
+#define PTRS_PER_PUD 1
+
+#endif /* _PGTABLE_NOPMD_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/unmodified_drivers/linux-2.6/compat-include/asm-generic/pgtable-nopud.h Wed Oct 25 13:58:30 2006 +0100
@@ -0,0 +1,14 @@
+#ifndef _PGTABLE_NOPUD_H
+#define _PGTABLE_NOPUD_H
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+#error "This version of Linux should not need compat pgtable-nopud.h"
+#endif
+
+#define pud_t pgd_t
+#define pud_offset(d, va) d
+#define pud_none(pud) 0
+#define pud_present(pud) 1
+#define PTRS_PER_PUD 1
+
+#endif /* _PGTABLE_NOPUD_H */

42
xu-11909-pv-hvm.diff Normal file
View File

@ -0,0 +1,42 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID ded9d1ae21f794f924bb312077bab69f782f87b8
# parent: e09720caf72dbdc0fe0689c8e2bf8ace97abaae4
PV-to-HVM: Add compatibility definitions of various #defines when they
are not present in the kernel we are building against.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
@@ -3,4 +3,26 @@
#include <linux/version.h>
+#include <linux/spinlock.h>
+
+#if defined(__LINUX_COMPILER_H) && !defined(__always_inline)
+#define __always_inline inline
#endif
+
+#if defined(__LINUX_SPINLOCK_H) && !defined(DEFINE_SPINLOCK)
+#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
+#endif
+
+#if defined(_LINUX_INIT_H) && !defined(__init)
+#define __init
+#endif
+
+#if defined(__LINUX_CACHE_H) && !defined(__read_mostly)
+#define __read_mostly
+#endif
+
+#if defined(_LINUX_SKBUFF_H) && !defined(NET_IP_ALIGN)
+#define NET_IP_ALIGN 0
+#endif
+
+#endif

22
xu-11910-pv-hvm.diff Normal file
View File

@ -0,0 +1,22 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID f4b878188b5d521828d8120646ab1192ea5c8483
# parent: ded9d1ae21f794f924bb312077bab69f782f87b8
PV-to-HVM: Implement compatibility nonseekable_open as a nop on
kernels before 2.6.9
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
--- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
@@ -25,4 +25,8 @@
#define NET_IP_ALIGN 0
#endif
+#if defined(_LINUX_FS_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
+#define nonseekable_open(inode, filp) /* Nothing to do */
#endif
+
+#endif

26
xu-11911-pv-hvm.diff Normal file
View File

@ -0,0 +1,26 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID 5d2f91f9b2f09fc57d24ef44f3ce31a4f0a9adfb
# parent: f4b878188b5d521828d8120646ab1192ea5c8483
PV-on-HVM: Define system_state as 1 (SYSTEM_RUNNING) on kernels prior
to 2.6.7. These kernels did not export the system_state variable to
modules.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
@@ -1,4 +1,11 @@
#include <linux/config.h>
#include <linux/version.h>
+#include <linux/module.h>
+
#include <xen/platform-compat.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)
+static int system_state = 1;
+EXPORT_SYMBOL(system_state);
+#endif

39
xu-11912-pv-hvm.diff Normal file
View File

@ -0,0 +1,39 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID 4dcf172e699e094bc772baa66b9dc93083332941
# parent: 5d2f91f9b2f09fc57d24ef44f3ce31a4f0a9adfb
PV-on-HVM: Kernels prior to 2.6.8 did not export strcspn to modules
therefore implement our own and export it.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
@@ -9,3 +9,23 @@ static int system_state = 1;
static int system_state = 1;
EXPORT_SYMBOL(system_state);
#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
+size_t strcspn(const char *s, const char *reject)
+{
+ const char *p;
+ const char *r;
+ size_t count = 0;
+
+ for (p = s; *p != '\0'; ++p) {
+ for (r = reject; *r != '\0'; ++r) {
+ if (*p == *r)
+ return count;
+ }
+ ++count;
+ }
+
+ return count;
+}
+EXPORT_SYMBOL(strcspn);
+#endif

48
xu-11913-pv-hvm.diff Normal file
View File

@ -0,0 +1,48 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID ac6e4405ab6c363eae43fd7384b7dca975e9e28e
# parent: 4dcf172e699e094bc772baa66b9dc93083332941
PV-on-HVM: Include compatability vmalloc_to_pfn for kernels before 2.6.10
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
@@ -29,4 +29,8 @@
#define nonseekable_open(inode, filp) /* Nothing to do */
#endif
+#if defined(_LINUX_MM_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+unsigned long vmalloc_to_pfn(void *addr);
#endif
+
+#endif
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
@@ -1,6 +1,7 @@
#include <linux/config.h>
#include <linux/version.h>
+#include <linux/mm.h>
#include <linux/module.h>
#include <xen/platform-compat.h>
@@ -29,3 +30,14 @@ size_t strcspn(const char *s, const char
}
EXPORT_SYMBOL(strcspn);
#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+/*
+ * Map a vmalloc()-space virtual address to the physical page frame number.
+ */
+unsigned long vmalloc_to_pfn(void * vmalloc_addr)
+{
+ return page_to_pfn(vmalloc_to_page(vmalloc_addr));
+}
+EXPORT_SYMBOL(vmalloc_to_pfn);
+#endif

67
xu-11914-pv-hvm.diff Normal file
View File

@ -0,0 +1,67 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID 0886fc73e787076a7ee2247e71da68f48d311e0b
# parent: ac6e4405ab6c363eae43fd7384b7dca975e9e28e
PV-on-HVM: Implement compatibilty version of wait_for_completion_timeout
for kernels before 2.6.11
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
--- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
@@ -33,4 +33,8 @@ unsigned long vmalloc_to_pfn(void *addr)
unsigned long vmalloc_to_pfn(void *addr);
#endif
+#if defined(__LINUX_COMPLETION_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
+unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout);
#endif
+
+#endif
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
@@ -3,6 +3,7 @@
#include <linux/mm.h>
#include <linux/module.h>
+#include <linux/sched.h>
#include <xen/platform-compat.h>
@@ -41,3 +42,34 @@ unsigned long vmalloc_to_pfn(void * vmal
}
EXPORT_SYMBOL(vmalloc_to_pfn);
#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
+unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout)
+{
+ might_sleep();
+
+ spin_lock_irq(&x->wait.lock);
+ if (!x->done) {
+ DECLARE_WAITQUEUE(wait, current);
+
+ wait.flags |= WQ_FLAG_EXCLUSIVE;
+ __add_wait_queue_tail(&x->wait, &wait);
+ do {
+ __set_current_state(TASK_UNINTERRUPTIBLE);
+ spin_unlock_irq(&x->wait.lock);
+ timeout = schedule_timeout(timeout);
+ spin_lock_irq(&x->wait.lock);
+ if (!timeout) {
+ __remove_wait_queue(&x->wait, &wait);
+ goto out;
+ }
+ } while (!x->done);
+ __remove_wait_queue(&x->wait, &wait);
+ }
+ x->done--;
+out:
+ spin_unlock_irq(&x->wait.lock);
+ return timeout;
+}
+EXPORT_SYMBOL(wait_for_completion_timeout);
+#endif

34
xu-11915-pv-hvm.diff Normal file
View File

@ -0,0 +1,34 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID d30a4d4ccd94c41f607e54d2c2233f9be909dda7
# parent: 0886fc73e787076a7ee2247e71da68f48d311e0b
PV-on-HVM: Implement and export a compatibility version of do_exit().
Kernels prior to 2.6.12 did not export do_exit().
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
@@ -73,3 +73,18 @@ out:
}
EXPORT_SYMBOL(wait_for_completion_timeout);
#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
+/*
+ fake do_exit using complete_and_exit
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+asmlinkage NORET_TYPE void do_exit(long code)
+#else
+fastcall NORET_TYPE void do_exit(long code)
+#endif
+{
+ complete_and_exit(NULL, code);
+}
+EXPORT_SYMBOL_GPL(do_exit);
+#endif

39
xu-11916-pv-hvm.diff Normal file
View File

@ -0,0 +1,39 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID db0d3f22e149d832e722173fa0e037e574db5f37
# parent: d30a4d4ccd94c41f607e54d2c2233f9be909dda7
PV-to-HVM: Impletement compatibility version of
schedule_timeout_interruptible for kernels before 2.6.14
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
@@ -37,4 +37,8 @@ unsigned long wait_for_completion_timeou
unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout);
#endif
+#if defined(_LINUX_SCHED_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+signed long schedule_timeout_interruptible(signed long timeout);
#endif
+
+#endif
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
@@ -88,3 +88,12 @@ fastcall NORET_TYPE void do_exit(long co
}
EXPORT_SYMBOL_GPL(do_exit);
#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+signed long schedule_timeout_interruptible(signed long timeout)
+{
+ __set_current_state(TASK_INTERRUPTIBLE);
+ return schedule_timeout(timeout);
+}
+EXPORT_SYMBOL(schedule_timeout_interruptible);
+#endif

54
xu-11917-pv-hvm.diff Normal file
View File

@ -0,0 +1,54 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID 9f0b88aaf17076bcdc42dfef0870ba9f39e72f23
# parent: db0d3f22e149d832e722173fa0e037e574db5f37
PV-on-HVM: Include compatibility kzalloc implementation for kernels
before 2.6.14.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
@@ -41,4 +41,8 @@ signed long schedule_timeout_interruptib
signed long schedule_timeout_interruptible(signed long timeout);
#endif
+#if defined(_LINUX_SLAB_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+void *kzalloc(size_t size, int flags);
#endif
+
+#endif
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c Wed Oct 25 13:58:30 2006 +0100
@@ -4,6 +4,7 @@
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/slab.h>
#include <xen/platform-compat.h>
@@ -97,3 +98,19 @@ signed long schedule_timeout_interruptib
}
EXPORT_SYMBOL(schedule_timeout_interruptible);
#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+/**
+ * kzalloc - allocate memory. The memory is set to zero.
+ * @size: how many bytes of memory are required.
+ * @flags: the type of memory to allocate.
+ */
+void *kzalloc(size_t size, int flags)
+{
+ void *ret = kmalloc(size, flags);
+ if (ret)
+ memset(ret, 0, size);
+ return ret;
+}
+EXPORT_SYMBOL(kzalloc);
+#endif

24
xu-11918-pv-hvm.diff Normal file
View File

@ -0,0 +1,24 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Wed Oct 25 13:58:30 2006 +0100
# Node ID fc68e3ef9139b5483649a6bfe87b83a8ce1e9f12
# parent: 9f0b88aaf17076bcdc42dfef0870ba9f39e72f23
PV-to-HVM: Add a compatibility define for the end_that_request_last
which changed prototype in 2.6.16.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
--- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Oct 25 13:58:30 2006 +0100
@@ -45,4 +45,8 @@ void *kzalloc(size_t size, int flags);
void *kzalloc(size_t size, int flags);
#endif
+#if defined(_LINUX_BLKDEV_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+#define end_that_request_last(req, uptodate) end_that_request_last(req)
#endif
+
+#endif

72
xu-11974-pv-hvm.diff Normal file
View File

@ -0,0 +1,72 @@
# HG changeset patch
# User awilliam@xenbuild.aw
# Date Sat Oct 14 16:28:32 2006 -0600
# Node ID 7c2a5f96a192a07cc73991a52ff3ffd80658cf94
# parent: 9e8fdcc46fa31a6e4f607c67e97f8a9d3fa0455c
[IA64] Xencomm fixes for HVM PV-drivers
Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
Index: xen-3.0.3-testing/unmodified_drivers/linux-2.6/mkbuildtree
===================================================================
--- xen-3.0.3-testing.orig/unmodified_drivers/linux-2.6/mkbuildtree
+++ xen-3.0.3-testing/unmodified_drivers/linux-2.6/mkbuildtree
@@ -27,6 +27,7 @@ mkdir -p include
mkdir -p include/xen
mkdir -p include/public
mkdir -p include/asm
+mkdir -p include/asm/xen
lndir -silent ${XL}/include/xen include/xen
ln -sf ${XEN}/include/public include/xen/interface
@@ -54,6 +55,10 @@ i[34567]86)
ln -sf ${XL}/include/asm-ia64/hypercall.h include/asm
ln -sf ${XL}/include/asm-ia64/synch_bitops.h include/asm
ln -sf ${XL}/include/asm-ia64/maddr.h include/asm
+ ln -sf ${XL}/include/asm-ia64/xen/xcom_hcall.h include/asm/xen
+ ln -sf ${XL}/include/asm-ia64/xen/xencomm.h include/asm/xen
+ ln -sf ${XL}/arch/ia64/xen/xcom_mini.c platform-pci
+ ln -sf ${XL}/arch/ia64/xen/xencomm.c platform-pci
;;
*)
echo unknown architecture $uname
Index: xen-3.0.3-testing/unmodified_drivers/linux-2.6/platform-pci/Kbuild
===================================================================
--- xen-3.0.3-testing.orig/unmodified_drivers/linux-2.6/platform-pci/Kbuild
+++ xen-3.0.3-testing/unmodified_drivers/linux-2.6/platform-pci/Kbuild
@@ -5,3 +5,8 @@ obj-m := xen-platform-pci.o
EXTRA_CFLAGS += -I$(M)/platform-pci
xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o platform-compat.o
+
+# Can we do better ?
+ifeq ($(ARCH),ia64)
+ xen-platform-pci-objs += xcom_mini.o xencomm.o
+endif
Index: xen-3.0.3-testing/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
===================================================================
--- xen-3.0.3-testing.orig/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
+++ xen-3.0.3-testing/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
@@ -36,6 +36,9 @@
#include <asm/pgtable.h>
#include <xen/interface/memory.h>
#include <xen/features.h>
+#ifdef __ia64__
+#include <asm/xen/xencomm.h>
+#endif
#include "platform-pci.h"
@@ -64,6 +67,10 @@ static int __init init_xen_info(void)
struct xen_add_to_physmap xatp;
extern void *shared_info_area;
+#ifdef __ia64__
+ xencomm_init();
+#endif
+
setup_xen_features();
shared_info_frame = alloc_xen_mmio(PAGE_SIZE) >> PAGE_SHIFT;

140
xu-12012-hvm-smp-timer.diff Normal file
View File

@ -0,0 +1,140 @@
# HG changeset patch
# User kaf24@localhost.localdomain
# Date Fri Oct 27 18:00:03 2006 +0100
# Node ID a1939d76c0e8e27bdac5233df7bd78c004ea8deb
# parent: 66fe61db9e69e03e12d0c4086683bebfb4a67780
[HVM] Fix SMP timer issues:
* Sync AP TSCs with BP at startup
* Only halt BP TSC when descheduled
* Correctly handle IPIs on timer vector
Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
Index: xen-3.0.3-testing/xen/arch/x86/hvm/hvm.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/hvm.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/hvm.c
@@ -226,7 +226,7 @@ void hvm_do_resume(struct vcpu *v)
hvm_stts(v);
/* pick up the elapsed PIT ticks and re-enable pit_timer */
- if ( pt->enabled && pt->first_injected ) {
+ if ( pt->enabled && v->vcpu_id == pt->bind_vcpu && pt->first_injected ) {
if ( v->arch.hvm_vcpu.guest_time ) {
hvm_set_guest_time(v, v->arch.hvm_vcpu.guest_time);
v->arch.hvm_vcpu.guest_time = 0;
Index: xen-3.0.3-testing/xen/arch/x86/hvm/intercept.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/intercept.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/intercept.c
@@ -339,6 +339,7 @@ struct periodic_time * create_periodic_t
stop_timer (&pt->timer);
pt->enabled = 0;
}
+ pt->bind_vcpu = 0; /* timer interrupt delivered to BSP by default */
pt->pending_intr_nr = 0;
pt->first_injected = 0;
if (period < 900000) { /* < 0.9 ms */
Index: xen-3.0.3-testing/xen/arch/x86/hvm/io.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/io.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/io.c
@@ -680,7 +680,7 @@ void hvm_interrupt_post(struct vcpu *v,
struct periodic_time *pt =
&(v->domain->arch.hvm_domain.pl_time.periodic_tm);
- if ( is_pit_irq(v, vector, type) ) {
+ if ( is_pit_irq(v, vector, type) && (v->vcpu_id == pt->bind_vcpu) ) {
if ( !pt->first_injected ) {
pt->pending_intr_nr = 0;
pt->last_plt_gtime = hvm_get_guest_time(v);
Index: xen-3.0.3-testing/xen/arch/x86/hvm/svm/svm.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/svm/svm.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/svm/svm.c
@@ -763,7 +763,8 @@ static void svm_freeze_time(struct vcpu
{
struct periodic_time *pt=&v->domain->arch.hvm_domain.pl_time.periodic_tm;
- if ( pt->enabled && pt->first_injected && !v->arch.hvm_vcpu.guest_time ) {
+ if ( pt->enabled && pt->first_injected && v->vcpu_id == pt->bind_vcpu
+ && !v->arch.hvm_vcpu.guest_time ) {
v->arch.hvm_vcpu.guest_time = hvm_get_guest_time(v);
stop_timer(&(pt->timer));
}
Index: xen-3.0.3-testing/xen/arch/x86/hvm/vmx/vmcs.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/vmx/vmcs.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/vmx/vmcs.c
@@ -314,14 +314,20 @@ static void vmx_set_host_env(struct vcpu
error |= __vmwrite(HOST_RSP, (unsigned long)get_stack_bottom());
}
+/* Update CR3, CR0, CR4, GDT, LDT, TR */
static void vmx_do_launch(struct vcpu *v)
{
-/* Update CR3, CR0, CR4, GDT, LDT, TR */
unsigned int error = 0;
unsigned long cr0, cr4;
- if (v->vcpu_id == 0)
+ if ( v->vcpu_id == 0 )
hvm_setup_platform(v->domain);
+ else {
+ /* Sync AP's TSC with BSP's */
+ v->arch.hvm_vcpu.cache_tsc_offset =
+ v->domain->vcpu[0]->arch.hvm_vcpu.cache_tsc_offset;
+ hvm_funcs.set_tsc_offset(v, v->arch.hvm_vcpu.cache_tsc_offset);
+ }
__asm__ __volatile__ ("mov %%cr0,%0" : "=r" (cr0) : );
@@ -360,9 +366,6 @@ static void vmx_do_launch(struct vcpu *v
__vmwrite(HOST_CR3, v->arch.cr3);
v->arch.schedule_tail = arch_vmx_do_resume;
-
- /* init guest tsc to start from 0 */
- hvm_set_guest_time(v, 0);
}
/*
Index: xen-3.0.3-testing/xen/arch/x86/hvm/vmx/vmx.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/vmx/vmx.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/vmx/vmx.c
@@ -456,7 +456,8 @@ static void vmx_freeze_time(struct vcpu
{
struct periodic_time *pt=&v->domain->arch.hvm_domain.pl_time.periodic_tm;
- if ( pt->enabled && pt->first_injected && !v->arch.hvm_vcpu.guest_time ) {
+ if ( pt->enabled && pt->first_injected && v->vcpu_id == pt->bind_vcpu
+ && !v->arch.hvm_vcpu.guest_time ) {
v->arch.hvm_vcpu.guest_time = hvm_get_guest_time(v);
stop_timer(&(pt->timer));
}
@@ -1927,6 +1928,13 @@ static inline void vmx_do_msr_write(stru
switch (regs->ecx) {
case MSR_IA32_TIME_STAMP_COUNTER:
+ {
+ struct periodic_time *pt =
+ &(v->domain->arch.hvm_domain.pl_time.periodic_tm);
+ if ( pt->enabled && pt->first_injected
+ && v->vcpu_id == pt->bind_vcpu )
+ pt->first_injected = 0;
+ }
hvm_set_guest_time(v, msr_content);
break;
case MSR_IA32_SYSENTER_CS:
Index: xen-3.0.3-testing/xen/include/asm-x86/hvm/vpit.h
===================================================================
--- xen-3.0.3-testing.orig/xen/include/asm-x86/hvm/vpit.h
+++ xen-3.0.3-testing/xen/include/asm-x86/hvm/vpit.h
@@ -58,6 +58,7 @@ struct periodic_time {
char one_shot; /* one shot time */
char irq;
char first_injected; /* flag to prevent shadow window */
+ u32 bind_vcpu; /* vcpu timer interrupt delivers to */
u32 pending_intr_nr; /* the couner for pending timer interrupts */
u32 period; /* frequency in ns */
u64 period_cycles; /* frequency in cpu cycles */

59
xu-12013-hvm-ioapic.diff Normal file
View File

@ -0,0 +1,59 @@
# HG changeset patch
# User kaf24@localhost.localdomain
# Date Fri Oct 27 18:02:40 2006 +0100
# Node ID ee140fbcb88df2e55259b0c6519de7645641468a
# parent: a1939d76c0e8e27bdac5233df7bd78c004ea8deb
[HVM] Ensure that, if AP is blocked, it is woken by interrupt delivered by IOAPIC.
This fixes 64-bit SMP Windows 2k3 boot.
Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
Signed-off-by: Xin Li <xin.b.li@intel.com>
Index: xen-3.0.3-testing/xen/arch/x86/hvm/vioapic.c
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/vioapic.c
+++ xen-3.0.3-testing/xen/arch/x86/hvm/vioapic.c
@@ -39,6 +39,7 @@
#include <asm/hvm/vpic.h>
#include <asm/hvm/support.h>
#include <asm/current.h>
+#include <asm/event.h>
/* HACK: Route IRQ0 only to VCPU0 to prevent time jumps. */
#define IRQ0_SPECIAL_ROUTING 1
@@ -436,9 +437,10 @@ static void ioapic_deliver(hvm_vioapic_t
#endif
target = apic_round_robin(s->domain, dest_mode,
vector, deliver_bitmask);
- if (target)
+ if (target) {
ioapic_inj_irq(s, target, vector, trig_mode, delivery_mode);
- else
+ vcpu_kick(target->vcpu);
+ } else
HVM_DBG_LOG(DBG_LEVEL_IOAPIC,
"null round robin mask %x vector %x delivery_mode %x\n",
deliver_bitmask, vector, dest_LowestPrio);
@@ -448,6 +450,7 @@ static void ioapic_deliver(hvm_vioapic_t
case dest_Fixed:
case dest_ExtINT:
{
+ struct vlapic* target;
uint8_t bit;
for (bit = 0; bit < s->lapic_count; bit++) {
if (deliver_bitmask & (1 << bit)) {
@@ -458,9 +461,10 @@ static void ioapic_deliver(hvm_vioapic_t
domain_crash_synchronous();
}
#endif
- if (s->lapic_info[bit]) {
- ioapic_inj_irq(s, s->lapic_info[bit],
- vector, trig_mode, delivery_mode);
+ target = s->lapic_info[bit];
+ if (target) {
+ ioapic_inj_irq(s, target, vector, trig_mode, delivery_mode);
+ vcpu_kick(target->vcpu);
}
}
}

99
xu-12030-pv-hvm.diff Normal file
View File

@ -0,0 +1,99 @@
# HG changeset patch
# User kfraser@localhost.localdomain
# Date Mon Oct 30 14:09:13 2006 +0000
# Node ID 44caba9460afd444a6a56c5d4517f938ca99130c
# parent: c3b4fef4f751e1fc57b8ee48abf06f1e3e802ce4
[LINUX] Declare structs as 'static __initdata' where possible.
Probably still not catching all possible cases, but using static
(where not already the case) makes the code size smaller, and using __initdata
has the usual advantages.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
--- a/linux-2.6-xen-sparse/arch/i386/kernel/sysenter.c Mon Oct 30 14:04:44 2006 +0000
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/sysenter.c Mon Oct 30 14:09:13 2006 +0000
@@ -60,7 +60,7 @@ int __init sysenter_setup(void)
#ifdef CONFIG_XEN
if (boot_cpu_has(X86_FEATURE_SEP)) {
- struct callback_register sysenter = {
+ static struct callback_register __initdata sysenter = {
.type = CALLBACKTYPE_sysenter,
.address = { __KERNEL_CS, (unsigned long)sysenter_entry },
};
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h Mon Oct 30 14:04:44 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h Mon Oct 30 14:09:13 2006 +0000
@@ -56,15 +56,15 @@ static void __init machine_specific_arch
struct xen_machphys_mapping mapping;
unsigned long machine_to_phys_nr_ents;
struct xen_platform_parameters pp;
- struct callback_register event = {
+ static struct callback_register __initdata event = {
.type = CALLBACKTYPE_event,
.address = { __KERNEL_CS, (unsigned long)hypervisor_callback },
};
- struct callback_register failsafe = {
+ static struct callback_register __initdata failsafe = {
.type = CALLBACKTYPE_failsafe,
.address = { __KERNEL_CS, (unsigned long)failsafe_callback },
};
- struct callback_register nmi_cb = {
+ static struct callback_register __initdata nmi_cb = {
.type = CALLBACKTYPE_nmi,
.address = { __KERNEL_CS, (unsigned long)nmi },
};
@@ -80,9 +80,10 @@ static void __init machine_specific_arch
ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb);
if (ret == -ENOSYS) {
- struct xennmi_callback cb;
+ static struct xennmi_callback __initdata cb = {
+ .handler_address = (unsigned long)nmi;
+ };
- cb.handler_address = nmi_cb.address.eip;
HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);
}
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/setup_arch_post.h Mon Oct 30 14:04:44 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/setup_arch_post.h Mon Oct 30 14:09:13 2006 +0000
@@ -15,20 +15,20 @@ static void __init machine_specific_arch
static void __init machine_specific_arch_setup(void)
{
int ret;
- struct callback_register event = {
+ static struct callback_register __initdata event = {
.type = CALLBACKTYPE_event,
.address = (unsigned long) hypervisor_callback,
};
- struct callback_register failsafe = {
+ static struct callback_register __initdata failsafe = {
.type = CALLBACKTYPE_failsafe,
.address = (unsigned long)failsafe_callback,
};
- struct callback_register syscall = {
+ static struct callback_register __initdata syscall = {
.type = CALLBACKTYPE_syscall,
.address = (unsigned long)system_call,
};
#ifdef CONFIG_X86_LOCAL_APIC
- struct callback_register nmi_cb = {
+ static struct callback_register __initdata nmi_cb = {
.type = CALLBACKTYPE_nmi,
.address = (unsigned long)nmi,
};
@@ -49,9 +49,10 @@ static void __init machine_specific_arch
#ifdef CONFIG_X86_LOCAL_APIC
ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb);
if (ret == -ENOSYS) {
- struct xennmi_callback cb;
+ static struct xennmi_callback __initdata cb = {
+ .handler_address = (unsigned long)nmi;
+ };
- cb.handler_address = nmi_cb.address;
HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);
}
#endif

243
xu-12031-pv-hvm.diff Normal file
View File

@ -0,0 +1,243 @@
# HG changeset patch
# User kfraser@localhost.localdomain
# Date Mon Oct 30 14:14:46 2006 +0000
# Node ID 6f3865b4d3d3bddbd64c0ed7c21b03bd98e78a0a
# parent: 44caba9460afd444a6a56c5d4517f938ca99130c
[LINUX] Use CONFIG_XEN_COMPAT_030002 where possible.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
--- a/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c Mon Oct 30 14:09:13 2006 +0000
+++ b/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c Mon Oct 30 14:14:46 2006 +0000
@@ -325,6 +325,7 @@ int xen_create_contiguous_region(
success = (exchange.nr_exchanged == (1UL << order));
BUG_ON(!success && ((exchange.nr_exchanged != 0) || (rc == 0)));
BUG_ON(success && (rc != 0));
+#ifdef CONFIG_XEN_COMPAT_030002
if (unlikely(rc == -ENOSYS)) {
/* Compatibility when XENMEM_exchange is unsupported. */
if (HYPERVISOR_memory_op(XENMEM_decrease_reservation,
@@ -341,6 +342,7 @@ int xen_create_contiguous_region(
BUG();
}
}
+#endif
/* 3. Map the new extent in place of old pages. */
for (i = 0; i < (1UL<<order); i++) {
@@ -419,6 +421,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));
+#ifdef CONFIG_XEN_COMPAT_030002
if (unlikely(rc == -ENOSYS)) {
/* Compatibility when XENMEM_exchange is unsupported. */
if (HYPERVISOR_memory_op(XENMEM_decrease_reservation,
@@ -429,6 +432,7 @@ void xen_destroy_contiguous_region(unsig
BUG();
success = 1;
}
+#endif
/* 4. Map new pages in place of old pages. */
for (i = 0; i < (1UL<<order); i++) {
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h Mon Oct 30 14:09:13 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h Mon Oct 30 14:14:46 2006 +0000
@@ -260,6 +260,8 @@ HYPERVISOR_event_channel_op(
int cmd, void *arg)
{
int rc = _hypercall2(int, event_channel_op, cmd, arg);
+
+#ifdef CONFIG_XEN_COMPAT_030002
if (unlikely(rc == -ENOSYS)) {
struct evtchn_op op;
op.cmd = cmd;
@@ -267,6 +269,8 @@ HYPERVISOR_event_channel_op(
rc = _hypercall1(int, event_channel_op_compat, &op);
memcpy(arg, &op.u, sizeof(op.u));
}
+#endif
+
return rc;
}
@@ -296,6 +300,8 @@ HYPERVISOR_physdev_op(
int cmd, void *arg)
{
int rc = _hypercall2(int, physdev_op, cmd, arg);
+
+#ifdef CONFIG_XEN_COMPAT_030002
if (unlikely(rc == -ENOSYS)) {
struct physdev_op op;
op.cmd = cmd;
@@ -303,6 +309,8 @@ HYPERVISOR_physdev_op(
rc = _hypercall1(int, physdev_op_compat, &op);
memcpy(arg, &op.u, sizeof(op.u));
}
+#endif
+
return rc;
}
@@ -350,9 +358,11 @@ HYPERVISOR_suspend(
int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
&sched_shutdown, srec);
+#ifdef CONFIG_XEN_COMPAT_030002
if (rc == -ENOSYS)
rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
SHUTDOWN_suspend, srec);
+#endif
return rc;
}
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h Mon Oct 30 14:09:13 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h Mon Oct 30 14:14:46 2006 +0000
@@ -131,8 +131,10 @@ HYPERVISOR_yield(
{
int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
+#ifdef CONFIG_XEN_COMPAT_030002
if (rc == -ENOSYS)
rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
+#endif
return rc;
}
@@ -143,8 +145,10 @@ HYPERVISOR_block(
{
int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
+#ifdef CONFIG_XEN_COMPAT_030002
if (rc == -ENOSYS)
rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
+#endif
return rc;
}
@@ -159,8 +163,10 @@ HYPERVISOR_shutdown(
int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+#ifdef CONFIG_XEN_COMPAT_030002
if (rc == -ENOSYS)
rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
+#endif
return rc;
}
@@ -177,8 +183,10 @@ HYPERVISOR_poll(
set_xen_guest_handle(sched_poll.ports, ports);
rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
+#ifdef CONFIG_XEN_COMPAT_030002
if (rc == -ENOSYS)
rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
+#endif
return rc;
}
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h Mon Oct 30 14:09:13 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h Mon Oct 30 14:14:46 2006 +0000
@@ -72,13 +72,16 @@ static void __init machine_specific_arch
ret = HYPERVISOR_callback_op(CALLBACKOP_register, &event);
if (ret == 0)
ret = HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe);
+#ifdef CONFIG_XEN_COMPAT_030002
if (ret == -ENOSYS)
ret = HYPERVISOR_set_callbacks(
event.address.cs, event.address.eip,
failsafe.address.cs, failsafe.address.eip);
+#endif
BUG_ON(ret);
ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb);
+#ifdef CONFIG_XEN_COMPAT_030002
if (ret == -ENOSYS) {
static struct xennmi_callback __initdata cb = {
.handler_address = (unsigned long)nmi;
@@ -86,6 +89,7 @@ static void __init machine_specific_arch
HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);
}
+#endif
if (HYPERVISOR_xen_version(XENVER_platform_parameters,
&pp) == 0)
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h Mon Oct 30 14:09:13 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h Mon Oct 30 14:14:46 2006 +0000
@@ -258,6 +258,8 @@ HYPERVISOR_event_channel_op(
int cmd, void *arg)
{
int rc = _hypercall2(int, event_channel_op, cmd, arg);
+
+#ifdef CONFIG_XEN_COMPAT_030002
if (unlikely(rc == -ENOSYS)) {
struct evtchn_op op;
op.cmd = cmd;
@@ -265,6 +267,8 @@ HYPERVISOR_event_channel_op(
rc = _hypercall1(int, event_channel_op_compat, &op);
memcpy(arg, &op.u, sizeof(op.u));
}
+#endif
+
return rc;
}
@@ -294,6 +298,8 @@ HYPERVISOR_physdev_op(
int cmd, void *arg)
{
int rc = _hypercall2(int, physdev_op, cmd, arg);
+
+#ifdef CONFIG_XEN_COMPAT_030002
if (unlikely(rc == -ENOSYS)) {
struct physdev_op op;
op.cmd = cmd;
@@ -301,6 +307,8 @@ HYPERVISOR_physdev_op(
rc = _hypercall1(int, physdev_op_compat, &op);
memcpy(arg, &op.u, sizeof(op.u));
}
+#endif
+
return rc;
}
@@ -351,9 +359,11 @@ HYPERVISOR_suspend(
int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
&sched_shutdown, srec);
+#ifdef CONFIG_XEN_COMPAT_030002
if (rc == -ENOSYS)
rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
SHUTDOWN_suspend, srec);
+#endif
return rc;
}
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/setup_arch_post.h Mon Oct 30 14:09:13 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/setup_arch_post.h Mon Oct 30 14:14:46 2006 +0000
@@ -39,15 +39,18 @@ static void __init machine_specific_arch
ret = HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe);
if (ret == 0)
ret = HYPERVISOR_callback_op(CALLBACKOP_register, &syscall);
+#ifdef CONFIG_XEN_COMPAT_030002
if (ret == -ENOSYS)
ret = HYPERVISOR_set_callbacks(
event.address,
failsafe.address,
syscall.address);
+#endif
BUG_ON(ret);
#ifdef CONFIG_X86_LOCAL_APIC
ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb);
+#ifdef CONFIG_XEN_COMPAT_030002
if (ret == -ENOSYS) {
static struct xennmi_callback __initdata cb = {
.handler_address = (unsigned long)nmi;
@@ -56,4 +59,5 @@ static void __init machine_specific_arch
HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);
}
#endif
+#endif
}

31
xu-12032-pv-hvm.diff Normal file
View File

@ -0,0 +1,31 @@
# HG changeset patch
# User kfraser@localhost.localdomain
# Date Mon Oct 30 14:28:29 2006 +0000
# Node ID d6802cfaf5f8abb7bec33e65425f41d2086d4b04
# parent: 6f3865b4d3d3bddbd64c0ed7c21b03bd98e78a0a
[LINUX] Fix build breakage from previous patch.
Signed-off-by: Keir Fraser <keir@xensource.com>
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h Mon Oct 30 14:14:46 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h Mon Oct 30 14:28:29 2006 +0000
@@ -84,7 +84,7 @@ static void __init machine_specific_arch
#ifdef CONFIG_XEN_COMPAT_030002
if (ret == -ENOSYS) {
static struct xennmi_callback __initdata cb = {
- .handler_address = (unsigned long)nmi;
+ .handler_address = (unsigned long)nmi
};
HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/setup_arch_post.h Mon Oct 30 14:14:46 2006 +0000
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/setup_arch_post.h Mon Oct 30 14:28:29 2006 +0000
@@ -53,7 +53,7 @@ static void __init machine_specific_arch
#ifdef CONFIG_XEN_COMPAT_030002
if (ret == -ENOSYS) {
static struct xennmi_callback __initdata cb = {
- .handler_address = (unsigned long)nmi;
+ .handler_address = (unsigned long)nmi
};
HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);

View File

@ -0,0 +1,44 @@
# HG changeset patch
# User Steven Smith <ssmith@xensource.com>
# Date Tue Oct 31 11:38:55 2006 +0000
# Node ID 79a40acadb41fbe5e5b88b20de5fe53f4dd6b413
# parent: b2371c9e05f5146767464db8504214ae2b77c25c
[PV-ON-HVM] Don't generate lots of spurious interrupts when using event
channel upcalls.
The issue here was that the Xen platform PCI interrupt is only updated
when you return from the hypervisor into guest context, and so remained
asserted for a short interval after the interrupt handler ran. If
it happened that the first subsequent trap to the hypervisor was
for unmasking the 8259 interrupt again, the unmasking caused the interrupt
to be reinjected. This caused an edge on the chaining interrupt from
the slave PIC to the master. The platform interrupt on the slave
would then be cleared as we returned to the guest, and so you
eventually end up injecting an interrupt on the master chained
interrupt with nothing pending on the slave, which shows up as
a spurious interrupt in the guest.
Signed-off-by: Steven Smith <sos22@cam.ac.uk>
--- a/unmodified_drivers/linux-2.6/platform-pci/evtchn.c Tue Oct 31 11:31:34 2006 +0000
+++ b/unmodified_drivers/linux-2.6/platform-pci/evtchn.c Tue Oct 31 11:38:55 2006 +0000
@@ -167,11 +167,17 @@ irqreturn_t evtchn_interrupt(int irq, vo
l2 = s->evtchn_pending[l1i] & ~s->evtchn_mask[l1i];
}
}
+
+ /* Make sure the hypervisor has a chance to notice that the
+ upcall_pending condition has been cleared, so that we don't
+ try and reinject the interrupt again. */
+ (void)HYPERVISOR_xen_version(0, NULL);
+
return IRQ_HANDLED;
}
void force_evtchn_callback(void)
{
- evtchn_interrupt(0, NULL, NULL);
+ (void)HYPERVISOR_xen_version(0, NULL);
}
EXPORT_SYMBOL(force_evtchn_callback);

23
xu-12205-pv-hvm.diff Normal file
View File

@ -0,0 +1,23 @@
# HG changeset patch
# User Ian Campbell <ian.campbell@xensource.com>
# Date Thu Nov 02 11:56:26 2006 +0000
# Node ID af1403dd13af9f2e3e778001c1ff681036753aca
# parent: e6fdb32b786c3e57b9c641274607603897b97334
PV-on-HVM: Use ln -nsf in mkbuildtree to avoid creating a symlink loop
if include/xen/interfaces already exists.
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
Index: xen-3.0.3-testing/unmodified_drivers/linux-2.6/mkbuildtree
===================================================================
--- xen-3.0.3-testing.orig/unmodified_drivers/linux-2.6/mkbuildtree
+++ xen-3.0.3-testing/unmodified_drivers/linux-2.6/mkbuildtree
@@ -30,7 +30,7 @@ mkdir -p include/asm
mkdir -p include/asm/xen
lndir -silent ${XL}/include/xen include/xen
-ln -sf ${XEN}/include/public include/xen/interface
+ln -nsf ${XEN}/include/public include/xen/interface
# Need to be quite careful here: we don't want the files we link in to
# risk overriding the native Linux ones (in particular, system.h must

View File

@ -0,0 +1,57 @@
# HG changeset patch
# User kfraser@localhost.localdomain
# Date Tue Nov 07 17:48:18 2006 +0000
# Node ID 2b89ebf00fc884f68168abea4159c11f31db131a
# parent: cba947bc845063ed820142bb921121ab8ead6452
[SVM] Fix an interrupt race window in the do_launch/vmrun/vmexit loop for AMD-V.
This problem found by Virtual Iron (Dave Winchell), and patch also
provided by VI.
Signed-off-by: Tom Woller <thomas.woller@amd.com>
Signed-off-by: Dave Winchell <dwinchell@virtualiron.com>
Index: xen-3.0.3-testing/xen/arch/x86/hvm/svm/x86_32/exits.S
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/svm/x86_32/exits.S
+++ xen-3.0.3-testing/xen/arch/x86/hvm/svm/x86_32/exits.S
@@ -89,8 +89,8 @@
#define CLGI .byte 0x0F,0x01,0xDD
ENTRY(svm_asm_do_launch)
- sti
CLGI
+ sti
GET_CURRENT(%ebx)
movl VCPU_svm_vmcb(%ebx), %ecx
movl 24(%esp), %eax
@@ -153,7 +153,6 @@ svm_restore_all_guest:
call svm_intr_assist
call svm_asid
call svm_load_cr2
- sti
/*
* Check if we are going back to SVM-based VM
* By this time, all the setups in the VMCB must be complete.
Index: xen-3.0.3-testing/xen/arch/x86/hvm/svm/x86_64/exits.S
===================================================================
--- xen-3.0.3-testing.orig/xen/arch/x86/hvm/svm/x86_64/exits.S
+++ xen-3.0.3-testing/xen/arch/x86/hvm/svm/x86_64/exits.S
@@ -99,8 +99,8 @@
#define CLGI .byte 0x0F,0x01,0xDD
ENTRY(svm_asm_do_launch)
- sti
CLGI
+ sti
GET_CURRENT(%rbx)
movq VCPU_svm_vmcb(%rbx), %rcx
movq UREGS_rax(%rsp), %rax
@@ -165,7 +165,6 @@ svm_restore_all_guest:
call svm_intr_assist
call svm_asid
call svm_load_cr2
- sti
/*
* Check if we are going back to VMX-based VM
* By this time, all the setups in the VMCS must be complete.