sdk/emulator/qemu.git
15 years agoFix Sparse warning
Blue Swirl [Sun, 5 Jul 2009 08:11:39 +0000 (08:11 +0000)]
Fix Sparse warning

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoWork around Solaris gas problem
Blue Swirl [Fri, 3 Jul 2009 19:25:29 +0000 (19:25 +0000)]
Work around Solaris gas problem

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoRename target_cpu to target_arch2
Blue Swirl [Fri, 3 Jul 2009 17:44:00 +0000 (17:44 +0000)]
Rename target_cpu to target_arch2

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agomonitor: Fix typo in documentation
Jan Kiszka [Fri, 3 Jul 2009 06:46:05 +0000 (08:46 +0200)]
monitor: Fix typo in documentation

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
15 years agotarget-mips: fix MADD and MSUB/MSUBU instructions
Nathan Froyd [Wed, 1 Jul 2009 17:52:22 +0000 (10:52 -0700)]
target-mips: fix MADD and MSUB/MSUBU instructions

MADD was not correctly writing to HI.

MSUB/MSUBU are specified as `HI||LO - product', not `product - HI||LO'.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
15 years agoFix hxtool.
Stefan Weil [Wed, 1 Jul 2009 21:13:34 +0000 (23:13 +0200)]
Fix hxtool.

When converting from hx to texi format, hxtool (or to be
more precise sh which interprets hxtool) used standard
shell expansion of wildcards while writing lines to the
output.

Thus, something like "Password: ********"
looked very different in the generated documentation.

The patch disables this unwanted wildcard expansion.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
15 years agoUse ctz64 in favor of ffsll
Jan Kiszka [Thu, 2 Jul 2009 07:11:37 +0000 (09:11 +0200)]
Use ctz64 in favor of ffsll

Not all host platforms support ffsll.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
15 years agoRespect the standard
malc [Thu, 2 Jul 2009 14:19:31 +0000 (18:19 +0400)]
Respect the standard

15 years agoUse pstrcpy and pstrcat to avoid OpenBSD linker warning
Blue Swirl [Wed, 1 Jul 2009 20:29:39 +0000 (20:29 +0000)]
Use pstrcpy and pstrcat to avoid OpenBSD linker warning

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoSuppress a GCC warning
Blue Swirl [Wed, 1 Jul 2009 19:30:50 +0000 (19:30 +0000)]
Suppress a GCC warning

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoFix breakage by obsolete _P() for good
Blue Swirl [Wed, 1 Jul 2009 19:11:17 +0000 (19:11 +0000)]
Fix breakage by obsolete _P() for good

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoFix sdl_zoom compile problems on OpenBSD
Blue Swirl [Wed, 1 Jul 2009 18:49:34 +0000 (18:49 +0000)]
Fix sdl_zoom compile problems on OpenBSD

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoFix missing strnlen problems
Blue Swirl [Wed, 1 Jul 2009 18:24:44 +0000 (18:24 +0000)]
Fix missing strnlen problems

Fix missing strnlen (a GNU extension) problems by using qemu_strnlen
used for user emulators also for system emulators.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoFix typo
malc [Tue, 30 Jun 2009 14:46:46 +0000 (18:46 +0400)]
Fix typo

Signed-off-by: malc <av1474@comtv.ru>
15 years agoRemove bogus -Werror
Paul Brook [Tue, 30 Jun 2009 11:10:52 +0000 (12:10 +0100)]
Remove bogus -Werror

Revert rules.mak changes from aba800a.  These should not have been here
to start with.

Signed-off-by: Paul Brook <paul@codesourcery.com>
15 years agoReplace -no-virtio-balloon by -balloon
Markus Armbruster [Fri, 26 Jun 2009 17:15:14 +0000 (19:15 +0200)]
Replace -no-virtio-balloon by -balloon

We want to do (at least) two things to the virtio-balloon device:
suppress it, and control its PCI address.  Option -no-virtio-balloon
lets us do only the former.  To get the latter, replace
-no-virtio-balloon with

    -balloon none   disable balloon device
    -balloon virtio[,addr=str]
                    enable virtio balloon device (default)

Syntax suggested by Anthony Liguori.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoslirp: tftp: Relax filename format check
Jan Kiszka [Mon, 29 Jun 2009 06:47:30 +0000 (08:47 +0200)]
slirp: tftp: Relax filename format check

[ Applies on top of my recently posted slirp series. ]

Allow tftp requests with filenames that do not start with a slash.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agosdl: Fix memory leakage
Jan Kiszka [Sat, 27 Jun 2009 07:59:40 +0000 (09:59 +0200)]
sdl: Fix memory leakage

Valgrind was so kind to remark that no one bothers to release keycodes
after use and that something is fishy about cleaning up the requested
keyboard descriptor. With this patch applied, we no longer leak about
12k during startup.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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>