sdk/emulator/qemu.git
15 years agoKVM: x86: Refactor persistent CPU state
Jan Kiszka [Sat, 27 Jun 2009 07:27:22 +0000 (09:27 +0200)]
KVM: x86: Refactor persistent CPU state

This patch aligns the KVM-related layout and encoding of the CPU state
to be saved to disk or migrated with qemu-kvm. The major differences are
reordering of fields and a compressed interrupt_bitmap into a single
number as there can be no more than one pending IRQ at a time.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agox86: Factor out pc_new_cpu
Jan Kiszka [Thu, 25 Jun 2009 06:23:39 +0000 (08:23 +0200)]
x86: Factor out pc_new_cpu

At this point, this refactoring looks like overkill. But we will need it
for CPU hotplugging, and qemu-kvm already carries it. Merging it early
would help qemu-kvm when rebasing against upstream.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agomonitor: Refactor acl commnds
Jan Kiszka [Thu, 25 Jun 2009 06:22:08 +0000 (08:22 +0200)]
monitor: Refactor acl commnds

Refactor the ACL monitor interface to make full use of the monitor
command dispatcher. This also gives proper help formatting and command
completion. Note that 'acl allow' and 'acl deny' were combined to
'acl_add aclname match allow|deny [index]' for consistency reasons.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agomonitor: Add completion for help command
Jan Kiszka [Thu, 25 Jun 2009 06:22:02 +0000 (08:22 +0200)]
monitor: Add completion for help command

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRevert "Introduce reset notifier order"
Jan Kiszka [Sat, 27 Jun 2009 07:25:07 +0000 (09:25 +0200)]
Revert "Introduce reset notifier order"

This reverts commit 8217606e6edb49591b4a6fd5a0d1229cebe470a9 (and
updates later added users of qemu_register_reset), we solved the
problem it originally addressed less invasively.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agomonitor: Make pci_add device options truely optional
Jan Kiszka [Thu, 25 Jun 2009 22:04:10 +0000 (00:04 +0200)]
monitor: Make pci_add device options truely optional

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agokvm: Rework VCPU synchronization
Jan Kiszka [Sat, 27 Jun 2009 07:24:58 +0000 (09:24 +0200)]
kvm: Rework VCPU synchronization

During startup and after reset we have to synchronize user space to the
in-kernel KVM state. Namely, we need to transfer the VCPU registers when
they change due to VCPU as well as APIC reset.

This patch refactors the required hooks so that kvm_init_vcpu registers
its own per-VCPU reset handler and adds a cpu_synchronize_state to the
APIC reset. That way we no longer depend on the new reset order (and can
drop this disliked interface again) and we can even drop a KVM hook in
main().

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agomonitor: Drop pci_addr prefix from hotplug commands
Jan Kiszka [Thu, 25 Jun 2009 22:04:00 +0000 (00:04 +0200)]
monitor: Drop pci_addr prefix from hotplug commands

The "pci_addr=" prefix currently required by pci_add/remove and
drive_add has no practical use. Drop it, but still silently accept it
for backward compatibility.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqcow2: Cache refcount blocks during snapshot creation
Kevin Wolf [Fri, 26 Jun 2009 18:19:38 +0000 (20:19 +0200)]
qcow2: Cache refcount blocks during snapshot creation

The really time consuming part of snapshotting is to adjust the reference count
of all clusters. Currently after each adjusted cluster the refcount block is
written to disk.

Don't write each single byte immediately to disk but cache all writes to the
refcount block and write them out once we're done with the block.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoblock-raw: Allow pread beyond the end of growable images
Kevin Wolf [Fri, 26 Jun 2009 17:51:24 +0000 (19:51 +0200)]
block-raw: Allow pread beyond the end of growable images

When using O_DIRECT, qcow2 snapshots didn't work any more for me. In the
process of creating the snapshot, qcow2 tries to pwrite some new information
(e.g. new L1 table) which will often end up being after the old end of the
image file. Now pwrite tries to align things and reads the old contents of the
file, read returns 0 because there is nothing to read after the end of file and
pwrite is stuck in an endless loop.

This patch allows to pread beyond the end of an image file. Whenever the
given offset is after the end of the image file, the read succeeds and fills
the buffer with zeros.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agomake tags useful for block drivers and hardaware devices
Juan Quintela [Mon, 29 Jun 2009 11:49:29 +0000 (13:49 +0200)]
make tags useful for block drivers and hardaware devices

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoSubstitute ifdef CONFIG_FOO by sound-obj-
Juan Quintela [Wed, 24 Jun 2009 22:08:12 +0000 (00:08 +0200)]
Substitute ifdef CONFIG_FOO by sound-obj-

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename SOUND_HW to sound-obj-y
Juan Quintela [Wed, 24 Jun 2009 22:08:11 +0000 (00:08 +0200)]
Rename SOUND_HW to sound-obj-y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoSubstitute ifdef CONFIG_FOO by obj-
Juan Quintela [Wed, 24 Jun 2009 22:08:10 +0000 (00:08 +0200)]
Substitute ifdef CONFIG_FOO by obj-

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoSubstitute ifdef CONFIG_FOO by obj-
Juan Quintela [Wed, 24 Jun 2009 22:08:09 +0000 (00:08 +0200)]
Substitute ifdef CONFIG_FOO by obj-

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agomove CONFIG_* values from yes to y
Juan Quintela [Wed, 24 Jun 2009 22:08:08 +0000 (00:08 +0200)]
move CONFIG_* values from yes to y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename OBJS to obj-y
Juan Quintela [Wed, 24 Jun 2009 22:08:07 +0000 (00:08 +0200)]
Rename OBJS to obj-y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename USER_OBJS to user-obj-y
Juan Quintela [Wed, 24 Jun 2009 22:08:06 +0000 (00:08 +0200)]
Rename USER_OBJS to user-obj-y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename XEN_OBJS to xen-obj-y
Juan Quintela [Wed, 24 Jun 2009 22:08:05 +0000 (00:08 +0200)]
Rename XEN_OBJS to xen-obj-y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename SLIRP_OBJS to slirp-obj-y
Juan Quintela [Wed, 24 Jun 2009 22:08:04 +0000 (00:08 +0200)]
Rename SLIRP_OBJS to slirp-obj-y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename AUDIO_OBJS to audio-obj-y
Juan Quintela [Wed, 24 Jun 2009 22:08:03 +0000 (00:08 +0200)]
Rename AUDIO_OBJS to audio-obj-y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename BLOCK_OBJS to block-obj-y
Juan Quintela [Wed, 24 Jun 2009 22:08:02 +0000 (00:08 +0200)]
Rename BLOCK_OBJS to block-obj-y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename OBJS to obj-y
Juan Quintela [Wed, 24 Jun 2009 22:08:01 +0000 (00:08 +0200)]
Rename OBJS to obj-y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename LIBOBJS to libobj-y
Juan Quintela [Wed, 24 Jun 2009 22:08:00 +0000 (00:08 +0200)]
Rename LIBOBJS to libobj-y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename OBJS to obj-y
Juan Quintela [Wed, 24 Jun 2009 22:07:59 +0000 (00:07 +0200)]
Rename OBJS to obj-y

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agocpu_unregister_map_client: fix memory leak.
Isaku Yamahata [Fri, 26 Jun 2009 09:57:18 +0000 (18:57 +0900)]
cpu_unregister_map_client: fix memory leak.

fix memory leak in cpu_unregister_map_client() and cpu_notify_map_clients().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoAdd documentation for Multiboot
Alexander Graf [Sun, 28 Jun 2009 14:55:55 +0000 (16:55 +0200)]
Add documentation for Multiboot

The documentation shows how to use -kernel and friends for booting Linux,
but obviously knows nothing about multiboot yet.

Let's include some documentation for multiboot, so people know how to fully
exploit this cool new feature.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoMultiboot build system v4
Alexander Graf [Mon, 29 Jun 2009 13:37:40 +0000 (15:37 +0200)]
Multiboot build system v4

In order to build the multiboot option rom, we need a Makefile and a tool
to sign the rom with.

Both are provided by this patch and mostly taken from the extboot source,
written by Anthony Liguori.

Once built, the resulting binary gets copied to pc-bios automatically.

Building also occurs automatically when on an x86 host.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoMultiboot support v5
Alexander Graf [Mon, 29 Jun 2009 13:37:39 +0000 (15:37 +0200)]
Multiboot support v5

This patch implements support for Multiboot on x86 for -kernel.
Multiboot is a "new" approach to get rid of different bootloaders, providing
a unified interface for the kernel. It supports command line options and
kernel modules.

The two probably best known projects using multiboot are Xen and GNU Hurd.

This implementation should be mostly feature-complete. It is missing VBE
extensions, but as no system uses them currently it does not really hurt.

To use multiboot, specify the kernel as -kernel option. Modules should be given
as -initrd options, seperated by a comma (,). -append also works.

Please bear in mind that grub also does gzip decompression, which qemu does
not do yet. To run existing images, please ungzip them first.

The guest multiboot loader code is implemented as option rom using int 19.
Parts of the work are based on efforts by Rene Rebe, who originally ported
my code to int 19.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoExpose fw_cfg v2
Alexander Graf [Mon, 29 Jun 2009 13:37:38 +0000 (15:37 +0200)]
Expose fw_cfg v2

Multiboot passes options to the option rom using the fw_cfg device.
Right now, that device is local to the bochs_bios_init function.

Let's change that and expose it, so everyone may put data in there.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoChange bochs bios init order
Alexander Graf [Mon, 29 Jun 2009 13:37:37 +0000 (15:37 +0200)]
Change bochs bios init order

For multiboot support, we need bochs_bios_init to happen before
load_linux, so we get the fw_cfg device.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agopreserve the hypervisor bit while KVM trims the CPUID bits
Andre Przywara [Wed, 24 Jun 2009 22:08:04 +0000 (00:08 +0200)]
preserve the hypervisor bit while KVM trims the CPUID bits

The KVM kernel will disable all bits in CPUID which are not present in
the host. As this is mostly true for the hypervisor bit (1.ecx),
preserve its value before the trim and restore it afterwards.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoremove CPUID host hacks
Andre Przywara [Wed, 24 Jun 2009 22:08:03 +0000 (00:08 +0200)]
remove CPUID host hacks

KVM provides an in-kernel feature to disable CPUID bits that are not
present in the current host. So there is no need here to duplicate this
work. Additionally allows 3DNow! on capable processors, since the
restriction seems to apply to QEMU/TCG only.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agofix KVMs GET_SUPPORTED_CPUID feature usage
Andre Przywara [Wed, 24 Jun 2009 22:08:02 +0000 (00:08 +0200)]
fix KVMs GET_SUPPORTED_CPUID feature usage

If we want to trim the user provided CPUID bits for KVM to be not greater
than that of the host, we should not remove the bits _after_ we sent
them to the kernel.
This fixes the masking of features that are not present on the host by
moving the trim function and it's call from helper.c to kvm.c.
It helps to use -cpu host.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoCPUID Fn8000_0001.EAX is family/model/stepping, not features
Andre Przywara [Wed, 24 Jun 2009 22:08:01 +0000 (00:08 +0200)]
CPUID Fn8000_0001.EAX is family/model/stepping, not features

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agointroduce -cpu host target
Andre Przywara [Wed, 24 Jun 2009 22:08:00 +0000 (00:08 +0200)]
introduce -cpu host target

Although the guest's CPUID bits can be controlled in a fine grained way
in QEMU, a simple way to inject the host CPU is missing. This is handy
for KVM desktop virtualization, where one wants the guest to support the
full host feature set.
Introduce another CPU type called 'host', which will propagate the host's
CPUID bits to the guest. Unwanted bits can still be turned off by using
the existing syntax (-cpu host,-skinit)

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoallow hypervisor CPUID bit to be overriden
Andre Przywara [Wed, 24 Jun 2009 22:07:59 +0000 (00:07 +0200)]
allow hypervisor CPUID bit to be overriden

KVM defaults to the hypervisor CPUID bit to be set, whereas pure
QEMU clears it. On some occasions one wants to set or clear it the
other way round (for instance to get HyperV running inside a guest).

Move the bit-set to be done before the command line parsing and
enable it by default. One can disable it by using: -cpu qemu64,-hypervisor
Fix some whitespace damage on the way.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agosupport colon in filenames
Ram Pai [Sat, 27 Jun 2009 00:41:50 +0000 (17:41 -0700)]
support colon in filenames

Problem: It is impossible to feed filenames with the character colon because
qemu interprets such names as a protocol. For example filename scsi:0, is
interpreted as a protocol by name "scsi".

This patch allows user to espace colon characters. For example the above
filename can now be expressed either as 'scsi\:0' or as file:scsi:0

anything following the "file:" tag is interpreted verbatin. However if "file:"
tag is omitted then any colon characters in the string must be escaped using
backslash.

Here are couple of examples:

scsi\:0\:abc is a local file scsi:0:abc
http\://myweb is a local file by name http://myweb
file:scsi:0:abc is a local file scsi:0:abc
file:http://myweb is a local file by name http://myweb

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoPrefer ncurses over curses
Jan Kiszka [Wed, 24 Jun 2009 10:29:11 +0000 (12:29 +0200)]
Prefer ncurses over curses

Not every distro provides libcurses anymore, at least OpenSUSE, and at
least under a standard library search path. So try to link against
standard ncurses first and then fall back to legacy curses.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Basic VLAN client info_str
Jan Kiszka [Wed, 24 Jun 2009 12:42:32 +0000 (14:42 +0200)]
slirp: Basic VLAN client info_str

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Make hostfwd_add/remove multi-instance-aware
Jan Kiszka [Wed, 24 Jun 2009 12:42:32 +0000 (14:42 +0200)]
slirp: Make hostfwd_add/remove multi-instance-aware

Extend the syntax of hostfwd_add/remove to optionally take a tuple of
VLAN ID and slirp stack name. If those are omitted, the commands will
continue to work on the first registered slirp stack.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agonet: Provide VLAN client lookup helper
Jan Kiszka [Wed, 24 Jun 2009 12:42:31 +0000 (14:42 +0200)]
net: Provide VLAN client lookup helper

Introduce qemu_find_vlan_client_by_name for VLANClientState lookup based
on VLAN ID and client name. This is useful for monitor commands.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Enable multi-instance support for the smb service
Jan Kiszka [Wed, 24 Jun 2009 12:42:31 +0000 (14:42 +0200)]
slirp: Enable multi-instance support for the smb service

Push the smb state, smb_dir, into SlirpState and construct it in a way
that allows multiple smb instances (one per slirp stack). Remove the smb
directory on slirp cleanup instead of qemu termination. As VLAN clients
are also cleaned up on process termination, no feature is lost.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Improve error handling in slirp_smb
Jan Kiszka [Wed, 24 Jun 2009 12:42:31 +0000 (14:42 +0200)]
slirp: Improve error handling in slirp_smb

Make sure for invocations from the monitor that slirp_smb properly
reports errors and doesn't terminate qemu.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Use shell to erase smb directory
Jan Kiszka [Wed, 24 Jun 2009 12:42:31 +0000 (14:42 +0200)]
slirp: Use shell to erase smb directory

Instead of open-coding this, we can use the power of the shell to remove
the smb_dir on exit.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Save/restore bootp client states
Jan Kiszka [Wed, 24 Jun 2009 12:42:31 +0000 (14:42 +0200)]
slirp: Save/restore bootp client states

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Enable multiple instances
Jan Kiszka [Wed, 24 Jun 2009 12:42:31 +0000 (14:42 +0200)]
slirp: Enable multiple instances

Once again this was a long journey to reach the destination: Allow to
instantiate slirp multiple times. But as in the past, the journey was
worthwhile, cleaning up, fixing and enhancing various parts of the user
space network stack along the way.

What is this particular change good for? Multiple slirps instances
allow separated user space networks for guests with multiple NICs. This
is already possible, but without any slirp support for the second
network, ie. without a chance to talk to that network from the host via
IP. We have a legacy guest system here that benefits from this slirp
enhancement, allowing us to run both of its NICs purely over
unprivileged user space IP stacks.

Another benefit of this patch is that it simply removes an artificial
restriction of the configuration space qemu is providing, avoiding
another source of surprises that users may face when playing with
possible setups.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Allocate/free stack instance dynamically
Jan Kiszka [Wed, 24 Jun 2009 12:42:31 +0000 (14:42 +0200)]
slirp: Allocate/free stack instance dynamically

Allocate the internal slirp state dynamically and provide and call
slirp_cleanup to properly release it after use. This patch finally
unbreaks slirp release and re-instantiation via host_net_* monitor
commands.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Use internal state in interface
Jan Kiszka [Wed, 24 Jun 2009 12:42:31 +0000 (14:42 +0200)]
slirp: Use internal state in interface

This now also exports the internal state to the slirp users in qemu,
returning it from slirp_init and expecting it along with service
invocations. Additionally provide an opaque value interface for the
callbacks from slirp into the qemu core.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Factor out internal state structure
Jan Kiszka [Wed, 24 Jun 2009 12:42:31 +0000 (14:42 +0200)]
slirp: Factor out internal state structure

The essence of this patch is to stuff (almost) all global variables of
the slirp stack into the structure Slirp. In this step, we still keep
the structure as global variable, directly accessible by the whole
stack. Changes to the external interface of slirp will be applied in
the following patches.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Drop link_up checks from if_output and slirp_socket_can_recv
Jan Kiszka [Wed, 24 Jun 2009 12:42:30 +0000 (14:42 +0200)]
slirp: Drop link_up checks from if_output and slirp_socket_can_recv

link_up is true once slirp is initialized, so these check are really not
required.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Clean up timeout handling around slirp_select_fill/poll
Jan Kiszka [Wed, 24 Jun 2009 12:42:30 +0000 (14:42 +0200)]
slirp: Clean up timeout handling around slirp_select_fill/poll

Again lot of dead code. Remove it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Drop redundant checks from slirp_output
Jan Kiszka [Wed, 24 Jun 2009 12:42:30 +0000 (14:42 +0200)]
slirp: Drop redundant checks from slirp_output

Slirp doesn't invoke slirp[_can]_output before it is initialized. The
motivation for these checks (3b7f5d479c) no longer applies. So drop
them.

Note: slirp_vc will become invalid if the slirp stack is removed during
runtime. But this is no new bug and will be fixed later.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Kill slirp_is_inited
Jan Kiszka [Wed, 24 Jun 2009 12:42:30 +0000 (14:42 +0200)]
slirp: Kill slirp_is_inited

Avoid the need for slirp_is_inited by refactoring the protected
slirp_select_* functions. This also avoids the clearing of all fd sets
on select errors.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Clean up updtime
Jan Kiszka [Wed, 24 Jun 2009 12:42:30 +0000 (14:42 +0200)]
slirp: Clean up updtime

Drop redundant typecasts in both variants and remove the pointless
round-up in the UNIX version.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Make IP packet ID consistent
Jan Kiszka [Wed, 24 Jun 2009 12:42:30 +0000 (14:42 +0200)]
slirp: Make IP packet ID consistent

Currently, ip_id is always initialized to 0 on slirp startup (despite
the broken attempt to derive it from the clock). This is good for
reproducibility. But it is not preserved across save/restore. This patch
therefore drops the dead initialization code from ip_init and introduces
ip_id to the persistent slirp state.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Factor out one-time initialization
Jan Kiszka [Wed, 24 Jun 2009 12:42:30 +0000 (14:42 +0200)]
slirp: Factor out one-time initialization

In order to prepare re-initialization and multi-instance slirp, factor
out init code that is of global scope and (at least for now) only need
to be run once.

This also fixes the potentially uninitialized use of our_addr in
get_dns_addr.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: tftp: Rework filename handling
Jan Kiszka [Wed, 24 Jun 2009 12:42:30 +0000 (14:42 +0200)]
slirp: tftp: Rework filename handling

This changes the filename handling from a static buffer in tftp_session
for the client-provided name + prefix to a dynamically allocated buffer
that keeps the combined path in one place.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: tftp: Refactor tftp_handle_rrq
Jan Kiszka [Wed, 24 Jun 2009 12:42:30 +0000 (14:42 +0200)]
slirp: tftp: Refactor tftp_handle_rrq

Specifically make the filename extraction more readable, and always
report errors back to the client.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: tftp: Clean up tftp_send_error
Jan Kiszka [Wed, 24 Jun 2009 12:42:30 +0000 (14:42 +0200)]
slirp: tftp: Clean up tftp_send_error

The return code of tftp_send_error is not used, drop it. And also make
sure to always terminate the session.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: tftp: Cleanup tftp_prefix check
Jan Kiszka [Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)]
slirp: tftp: Cleanup tftp_prefix check

Perform check for set prefix early (if it's not given, tftp is disabled)
and drop redundant second check.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Drop unused icmp_var.h
Jan Kiszka [Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)]
slirp: Drop unused icmp_var.h

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Cleanup and basic reanimation of debug code
Jan Kiszka [Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)]
slirp: Cleanup and basic reanimation of debug code

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Drop statistic code
Jan Kiszka [Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)]
slirp: Drop statistic code

As agreed on the mailing list, there is no interest in keeping the
usually disabled slirp statistics in the tree. So this patch removes
them.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Drop dead code
Jan Kiszka [Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)]
slirp: Drop dead code

After all its years inside the qemu tree, there is no point in keeping
the dead code paths of slirp. This patch is a first round of removing
usually commented out code parts. More cleanups need to follow (and
maybe finally a proper reindention).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Add info usernet for dumping connection states
Jan Kiszka [Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)]
slirp: Add info usernet for dumping connection states

Break out sockstats from the slirp statistics and present them under the
new info category "usernet". This patch also improves the current output
/wrt proper reporting connection source and destination.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Mark sockets of incoming TCP connections
Jan Kiszka [Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)]
slirp: Mark sockets of incoming TCP connections

Required for pretty-printing.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Do not allow to remove non-hostfwd sockets
Jan Kiszka [Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)]
slirp: Do not allow to remove non-hostfwd sockets

Prevent that the users accidentally shoots down dynamic sockets. This
allows to remove looping for removals as there can now only be one
match.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Explicitely mark host-forwarding sockets
Jan Kiszka [Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)]
slirp: Explicitely mark host-forwarding sockets

Mark sockets that describe host forwardings. This is required for their
(and only their) proper deletion and for pretty-printing.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Prepare for persistent socket state flags
Jan Kiszka [Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)]
slirp: Prepare for persistent socket state flags

This prepares for adding flags to socket.so_state that must not be
removed during the lifetime of a socket.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Bind support for host forwarding rules
Jan Kiszka [Wed, 24 Jun 2009 12:42:28 +0000 (14:42 +0200)]
slirp: Bind support for host forwarding rules

Extend the hostfwd rule format so that the user can specify on which
host interface qemu should listen for incoming connections. If omitted,
binding will takes place against all interfaces.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Rework monitor commands for host forwarding
Jan Kiszka [Wed, 24 Jun 2009 12:42:28 +0000 (14:42 +0200)]
slirp: Rework monitor commands for host forwarding

Improve the monitor interface for adding and removing host forwarding
rules by splitting it up in two commands and rename them to hostfwd_add
and hostfwd_remove. Also split up the paths taken for legacy -redir
support and the monitor add command as the latter will be extended later
on.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Fix port comparision in slirp_remove_hostfwd
Jan Kiszka [Wed, 24 Jun 2009 12:42:28 +0000 (14:42 +0200)]
slirp: Fix port comparision in slirp_remove_hostfwd

For UDP host forwardings, fport is not stable, every outgoing packet of
the redirection can modify it. Use getsockname instead to look up the
port that is actually used on the host side.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Rework external configuration interface
Jan Kiszka [Wed, 24 Jun 2009 12:42:28 +0000 (14:42 +0200)]
slirp: Rework external configuration interface

With the internal IP configuration made more flexible, we can now
enhance the user interface. This patch adds a number of new options to
"-net user": net (address and mask), host, dhcpstart, dns and smbserver.
It also renames "redir" to "hostfwd" and "channel" to "guestfwd" in
order to (hopefully) clarify their meanings. The format of guestfwd is
extended so that the user can define not only the port but also the
virtual server's IP address the forwarding starts from.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Rework internal configuration
Jan Kiszka [Wed, 24 Jun 2009 12:42:28 +0000 (14:42 +0200)]
slirp: Rework internal configuration

The user mode IP stack is currently only minimally configurable /wrt to
its virtual IP addresses. This is unfortunate if some guest has a fixed
idea of which IP addresses to use.

Therefore this patch prepares the stack for fully configurable IP
addresses and masks. The user interface and default addresses remain
untouched in this step, they will be enhanced in the following patch.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Move smb, redir, tftp and bootp parameters and -net channel
Jan Kiszka [Wed, 24 Jun 2009 12:42:28 +0000 (14:42 +0200)]
slirp: Move smb, redir, tftp and bootp parameters and -net channel

So far a couple of slirp-related parameters were expressed via
stand-alone command line options. This it inconsistent and unintuitive.
Moreover, it prevents both dynamically reconfigured (host_net_add/
delete) and multi-instance slirp.

This patch refactors the configuration by turning -smb, -redir, -tftp
and -bootp as well as -net channel into options of "-net user". The old
stand-alone command line options are still processed, but no longer
advertised. This allows smooth migration of management applications to
to the new syntax and also the extension of that syntax later in this
series.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoIntroduce get_next_param_value
Jan Kiszka [Wed, 24 Jun 2009 12:42:28 +0000 (14:42 +0200)]
Introduce get_next_param_value

In order to parse multiple instances of the same param=value pair,
introduce get_next_param_value which can pass back to string parsing
position after reading a parameter value.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRevert "User networking: Show active connections"
Jan Kiszka [Wed, 24 Jun 2009 12:42:28 +0000 (14:42 +0200)]
Revert "User networking: Show active connections"

This reverts commit 1c6ed9f3379faac83da0ed3e95cbd49003ac0dd1.

It's redundant to slirp statistics, which are going to be split up /
reworked later on.

Conflicts:

monitor.c
net.c

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Refactor tcp_ctl
Jan Kiszka [Wed, 24 Jun 2009 12:42:28 +0000 (14:42 +0200)]
slirp: Refactor tcp_ctl

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: Drop redundant lines from udp_input
Jan Kiszka [Wed, 24 Jun 2009 12:42:27 +0000 (14:42 +0200)]
slirp: Drop redundant lines from udp_input

The socket faddr/fport is already updated a few lines below, so these
are completely redundant.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agosdl zooming
Stefano Stabellini [Wed, 24 Jun 2009 10:58:25 +0000 (11:58 +0100)]
sdl zooming

Hi all,
this patch implements zooming capabilities for the sdl interface.
A new sdl_zoom_blit function is added that is able to scale and blit a
portion of a surface into another.
This way we can enable SDL_RESIZABLE and have a real_screen surface with
a different size than the guest surface and let sdl_zoom_blit take care
of the problem.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoFix QCOW2 debugging code to compile again
Filip Navara [Wed, 24 Jun 2009 00:17:30 +0000 (19:17 -0500)]
Fix QCOW2 debugging code to compile again

Updated to use C99 comments.

Signed-off-by: Filip Navara <filip.navara@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoAdd serial number support for virtio_blk
john cooper [Mon, 22 Jun 2009 18:26:51 +0000 (14:26 -0400)]
Add serial number support for virtio_blk

[brought forward to current qemu-kvm.git]

This patch implements the missing qemu logic to
interpret a '-drive .. serial=XYZ ..' flag for
a virtio_blk device.

The serial number string is contained in a
skeletal IDENTIFY DEVICE data structure and
this structure is made available to the guest
virtio_blk driver via pci i/o region 0.

Signed-off-by: john cooper <john.cooper@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRemove unused gen_bx_T0 function.
Filip Navara [Mon, 22 Jun 2009 18:40:10 +0000 (13:40 -0500)]
Remove unused gen_bx_T0 function.

Signed-off-by: Filip Navara <filip.navara@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoMake sure to zero out memory before calling madvise to increase robustness
Anthony Liguori [Mon, 22 Jun 2009 17:39:00 +0000 (12:39 -0500)]
Make sure to zero out memory before calling madvise to increase robustness

Avi pointed out that it's not entirely safe to rely on madvise zeroing out
memory.  So let's do it explicitly before calling madvise.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu-io: add aio read/write/flush commands
Christoph Hellwig [Sat, 20 Jun 2009 19:10:44 +0000 (21:10 +0200)]
qemu-io: add aio read/write/flush commands

Add commands to exercise asynchronous reads/writes and to flush all
outstanding aio commands.  Commands to exercise aio cancellations will
follow in a separate patch.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu-io: Fix spelling in help message.
Stefan Weil [Mon, 22 Jun 2009 13:08:47 +0000 (15:08 +0200)]
qemu-io: Fix spelling in help message.

excerciser -> exerciser

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoFix dump output in qemu-io.
Stefan Weil [Sun, 21 Jun 2009 16:35:03 +0000 (18:35 +0200)]
Fix dump output in qemu-io.

The dump output was not nicely formatted for bytes
larger than 0x7f, because signed values expanded to
sizeof(int) bytes. So for example 0xab did not print
as "ab", but as "ffffffab".

I also cleaned the function prototype, which avoids
new type casts and allows to remove an existing
type cast.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/net: flag to control the number of vectors a nic has
Michael S. Tsirkin [Sun, 21 Jun 2009 16:51:18 +0000 (19:51 +0300)]
qemu/net: flag to control the number of vectors a nic has

Add an option to specify the number of MSI-X vectors for PCI NIC cards. This
can also be used to disable MSI-X, for compatibility with old qemu. This
option currently only affects virtio cards.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/net: request 3 vectors in virtio-net
Michael S. Tsirkin [Sun, 21 Jun 2009 16:51:04 +0000 (19:51 +0300)]
qemu/net: request 3 vectors in virtio-net

Request up to 3 vectors in virtio-net. Actual bindings might supply
less.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: add pci_get/set_byte
Michael S. Tsirkin [Sun, 21 Jun 2009 16:50:57 +0000 (19:50 +0300)]
qemu/pci: add pci_get/set_byte

Add pci_get/set_byte to keep *_word and *_long access functions company.
They are unused for now.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/virtio: virtio save/load bindings
Michael S. Tsirkin [Sun, 21 Jun 2009 16:50:40 +0000 (19:50 +0300)]
qemu/virtio: virtio save/load bindings

Implement bindings for virtio save/load. Use them in virtio pci.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/virtio: MSI-X support in virtio PCI
Michael S. Tsirkin [Sun, 21 Jun 2009 16:50:26 +0000 (19:50 +0300)]
qemu/virtio: MSI-X support in virtio PCI

This enables actual support for MSI-X in virtio PCI.
First user will be virtio-net.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/virtio: virtio support for many interrupt vectors
Michael S. Tsirkin [Sun, 21 Jun 2009 16:50:13 +0000 (19:50 +0300)]
qemu/virtio: virtio support for many interrupt vectors

Extend virtio to support many interrupt vectors, and rearrange code in
preparation for multi-vector support (mostly move reset out to bindings,
because we will have to reset the vectors in transport-specific code).
Actual bindings in pci, and use in net, to follow.
Load and save are not connected to bindings yet, so they are left
stubbed out for now.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/apic: minimal MSI/MSI-X implementation for PC
Michael S. Tsirkin [Sun, 21 Jun 2009 16:50:03 +0000 (19:50 +0300)]
qemu/apic: minimal MSI/MSI-X implementation for PC

Implement MSI support in APIC. Note that MSI and MMIO APIC registers
are at the same memory location, but actually not on the global bus: MSI
is on PCI bus, APIC is connected directly to the CPU. We map them on the
global bus at the same address which happens to work because MSI
registers are reserved in APIC MMIO and vice versa.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: MSI-X support functions
Michael S. Tsirkin [Sun, 21 Jun 2009 16:49:54 +0000 (19:49 +0300)]
qemu/pci: MSI-X support functions

Add functions implementing MSI-X support. First user will be virtio-pci.
Note that platform must set a flag to declare MSI supported: this
is a safety measure to avoid breaking platforms which should support
MSI-X but currently lack this in the interrupt controller emulation.
For PC this will be set by APIC.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: check constant registers on load
Michael S. Tsirkin [Sun, 21 Jun 2009 16:49:40 +0000 (19:49 +0300)]
qemu/pci: check constant registers on load

Add "cmask" table of constant register masks: if a bit is not writeable
and is set in cmask table, this bit is checked on load.  An attempt to
load an image that would change such a register causes load to fail.
Use this table to make sure that load does not modify registers that
guest can not change (directly or indirectly).

Note: we can't just assume that read-only registers never change,
because the guest could change a register indirectly.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: add routines to manage PCI capabilities
Michael S. Tsirkin [Sun, 21 Jun 2009 16:45:40 +0000 (19:45 +0300)]
qemu/pci: add routines to manage PCI capabilities

Add routines to manage PCI capability list. First user will be MSI-X.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: helper routines for pci access
Michael S. Tsirkin [Sun, 21 Jun 2009 16:45:30 +0000 (19:45 +0300)]
qemu/pci: helper routines for pci access

Add inline routines for convenient access to pci devices
with correct (little) endianness. Will be used by MSI-X support.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: make default_write_config use mask table
Michael S. Tsirkin [Sun, 21 Jun 2009 16:45:18 +0000 (19:45 +0300)]
qemu/pci: make default_write_config use mask table

Change much of hw/pci to use symbolic constants and a table-driven
design: add a mask table with writable bits set and readonly bits unset.
Detect change by comparing original and new registers.

This makes it easy to support capabilities where read-only/writeable
bit layout differs between devices, depending on capabilities present.

As a result, writing a single byte in BAR registers now works as
it should. Writing to upper limit registers in the bridge
also works as it should. Code is also shorter.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>