sdk/emulator/qemu.git
14 years agowin32: Add missing function ffs
Stefan Weil [Sat, 12 Jun 2010 14:07:12 +0000 (16:07 +0200)]
win32: Add missing function ffs

mingw32 does not include function ffs.

Commit c6d29ad6e24533cc3762e1d654275607e1d03058 added a
declaration for ffs, but an implementation was missing.

For compilations with optimization, the compiler creates
inline code, so the implementation is not always needed.

Without optimization, linking fails without this patch.

v2: Use __builtin_ffs as suggested by Richard Henderson

Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agowin32: Add define for missing EPROTONOSUPPORT
Stefan Weil [Thu, 24 Jun 2010 20:41:33 +0000 (22:41 +0200)]
win32: Add define for missing EPROTONOSUPPORT

mingw32 does not define EPROTONOSUPPORT (which is used by
migration.c and maybe future patches), so add a
definition which uses a supported errno value.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years ago.gitignore: Ignore libdis*, qemu-options.def
Stefan Weil [Thu, 24 Jun 2010 20:31:06 +0000 (22:31 +0200)]
.gitignore: Ignore libdis*, qemu-options.def

libdis, libdis-user and qemu-options.def are generated
directories / files and should be ignored by git.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agox86: Clean up CPU reset
Jan Kiszka [Wed, 23 Jun 2010 06:20:54 +0000 (08:20 +0200)]
x86: Clean up CPU reset

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agox86: Fix INIT processing
Jan Kiszka [Wed, 23 Jun 2010 06:19:39 +0000 (08:19 +0200)]
x86: Fix INIT processing

This fixes a regression of 0e26b7b892: Reset halted also on INIT.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agomask all interrupts when MASTER_DISABLE is set
Artyom Tarasenko [Mon, 21 Jun 2010 18:23:21 +0000 (20:23 +0200)]
mask all interrupts when MASTER_DISABLE is set

The MASTER_DISABLE bit (aka mask-all) masks all the interrupts.

According to Sun-4M System Architecture
"The level–15 interrupt sources [...] are maskable with the Interrupt Target
Mask Register. While these interrupts are considered ’non–maskable’ within
the SPARC IU, a mask capability is provided to allow the boot firmware
to establish a basic environment before receiving any level–15 interrupts,
which are non–maskable within SPARC. A mask–all bit is provided to allow
disabling of all external interrupts during change of the CIT."

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agofw_cfg: convert to qdev
Blue Swirl [Sun, 27 Jun 2010 16:04:55 +0000 (16:04 +0000)]
fw_cfg: convert to qdev

Convert fw_cfg to qdev.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoRemove useless device dependency of HAS_AUDIO
Blue Swirl [Sun, 27 Jun 2010 16:04:31 +0000 (16:04 +0000)]
Remove useless device dependency of HAS_AUDIO

System architecture dictates whether HAS_AUDIO is defined. It's then
useless to check for HAS_AUDIO in files which are only used on those
architectures which always have audio.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agovirtio-pci: fix bus master bug setting on load
Alex Williamson [Thu, 17 Jun 2010 15:15:02 +0000 (09:15 -0600)]
virtio-pci: fix bus master bug setting on load

The comment suggests we're checking for the driver in the ready
state and bus master disabled, but the code is checking that it's
not in the ready state.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Found-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoFactorize common migration incoming code
Juan Quintela [Wed, 9 Jun 2010 12:10:55 +0000 (14:10 +0200)]
Factorize common migration incoming code

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoExit if incoming migration fails
Juan Quintela [Wed, 9 Jun 2010 12:10:54 +0000 (14:10 +0200)]
Exit if incoming migration fails

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Implement Security model for mksock using mknod.
Venkateswararao Jujjuri (JV) [Mon, 14 Jun 2010 20:34:49 +0000 (13:34 -0700)]
virtio-9p: Implement Security model for mksock using mknod.

This patch uses mknod to create socket.

On Host/Fileserver:
-rw-------. 1 virfsuid virtfsgid 0 2010-05-11 09:57 asocket1

On Guest/Client:
srwxr-xr-x 1 guestuser guestuser 0 2010-05-11 12:57 asocket1

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Implement Security model for mknod
Venkateswararao Jujjuri (JV) [Mon, 14 Jun 2010 20:34:48 +0000 (13:34 -0700)]
virtio-9p: Implement Security model for mknod

Mapped mode stores extended attributes in the user space of the extended
attributes. Given that the user space extended attributes are available
to regular files only, special files are created as regular files on the
fileserver and appropriate mode bits are added to the extended attributes.
This method presents all special files and symlinks as regular files on the
fileserver while they are represented as special files on the guest mount.

On Host/Fileserver:
-rw-------. 1 virfsuid virtfsgid 0 2010-05-11 09:36 afifo
-rw-------. 1 virfsuid virtfsgid 0 2010-05-11 09:32 blkdev
-rw-------. 1 virfsuid virtfsgid 0 2010-05-11 09:33 chardev

On Guest/Client:
prw-r--r-- 1 guestuser guestuser 0 2010-05-11 12:36 afifo
brw-r--r-- 1 guestuser guestuser 0, 0 2010-05-11 12:32 blkdev
crw-r--r-- 1 guestuser guestuser 4, 5 2010-05-11 12:33 chardev

In the passthrough securit model, specifal files are directly created
on the fileserver. But the user credential

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Security model for symlink and readlink
Venkateswararao Jujjuri (JV) [Mon, 14 Jun 2010 20:34:47 +0000 (13:34 -0700)]
virtio-9p: Security model for symlink and readlink

Mapped mode stores extended attributes in the user space of the extended
attributes. Given that the user space extended attributes are available
to regular files only, special files are created as regular files on the
fileserver and appropriate mode bits are added to the extended attributes.
This method presents all special files and symlinks as regular files on the
fileserver while they are represented as special files on the guest mount.

Implemntation of symlink in mapped security model:

A regular file is created and the link target is written to it.
readlink() reads it back from the file.

On Guest/Client:
lrwxrwxrwx 1 root root 6 2010-05-11 12:20 asymlink -> afile

On Host/Fileserver:
-rw-------. 1 root root 6 2010-05-11 09:20 asymlink
afile

Under passthrough model, it just calls underlying symlink() readlink()
system calls are used.

Under both security models, client user credentials are changed
after the filesystem objec creation.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Security model for mkdir
Venkateswararao Jujjuri (JV) [Mon, 14 Jun 2010 20:34:46 +0000 (13:34 -0700)]
virtio-9p: Security model for mkdir

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Security model for create/open2
Venkateswararao Jujjuri (JV) [Mon, 14 Jun 2010 20:34:45 +0000 (13:34 -0700)]
virtio-9p: Security model for create/open2

In the mapped security model, VirtFS server intercepts and maps
the file object create and get/set attribute requests. Files on the fileserver
will be created with VirtFS servers (QEMU) user credentials and the
client-users credentials are stored in extended attributes. On the request
to get attributes, server extracts the client-users credentials
from extended attributes and sends them to the client.

On Host/Fileserver:
-rw-------. 2 virfsuid virtfsgid 0 2010-05-11 09:19 afile

On Guest/Client:
-rw-r--r-- 2 guestuser guestuser 0 2010-05-11 12:19 afile

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Implemented Security model for lstat and fstat
Venkateswararao Jujjuri (JV) [Mon, 14 Jun 2010 20:34:44 +0000 (13:34 -0700)]
virtio-9p: Implemented Security model for lstat and fstat

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Security model for chown
Venkateswararao Jujjuri (JV) [Mon, 14 Jun 2010 20:34:43 +0000 (13:34 -0700)]
virtio-9p: Security model for chown

mapped model changes the owner in the extended attributes.
passthrough model does the change through lchown() as the
server don't need to follow the link and client will send the
actual filesystem object.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Security model for chmod
Venkateswararao Jujjuri (JV) [Mon, 14 Jun 2010 20:34:42 +0000 (13:34 -0700)]
virtio-9p: Security model for chmod

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Make infrastructure for the new security model.
Venkateswararao Jujjuri (JV) [Mon, 14 Jun 2010 20:34:41 +0000 (13:34 -0700)]
virtio-9p: Make infrastructure for the new security model.

This patch adds required infrastructure for the new security model.

- A new configure option for attr/xattr.
- if CONFIG_VIRTFS will be defined if both CONFIG_LINUX and CONFIG_ATTR defined.
- Defines routines related to both security models.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Introduces an option to specify the security model.
Venkateswararao Jujjuri (JV) [Mon, 14 Jun 2010 20:34:40 +0000 (13:34 -0700)]
virtio-9p: Introduces an option to specify the security model.

The new option is:

-fsdev fstype,id=myid,path=/share_path/,security_model=[mapped|passthrough]
-virtfs fstype,path=/share_path/,security_model=[mapped|passthrough],mnt_tag=tag

In the case of mapped security model, files are created with QEMU user
credentials and the client-user's credentials are saved in extended attributes.
Whereas in the case of passthrough security model, files on the
filesystem are directly created with client-user's credentials.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-9p: Rearrange fileop structures
Venkateswararao Jujjuri (JV) [Tue, 1 Jun 2010 20:30:51 +0000 (13:30 -0700)]
virtio-9p: Rearrange fileop structures

This patch rearranges the fileop structures by moving the structure definitions
from virtio-9p.c to virtio-9p.h file. No functional changes.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoFlush the debug message out to the log file.
Venkateswararao Jujjuri (JV) [Wed, 2 Jun 2010 15:24:59 +0000 (08:24 -0700)]
Flush the debug message out to the log file.

This patch fluesh the debug messages to the log file  at the end of each
debug message.

Changes from V1:
Used fflush instead fseek for the flush.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agogive some useful error messages when tap open
Michael Tokarev [Wed, 2 Jun 2010 17:33:01 +0000 (14:33 -0300)]
give some useful error messages when tap open

In net/tap-linux.c, when manipulation of /dev/net/tun fails, it prints
(with fprintf) something like this:

  warning: could not open /dev/net/tun: no virtual network emulation

this has 2 issues:
 1) it is not a warning really, it's a fatal error (kvm exits after
that),
 2) there's no indication as of what's actually wrong: printing errno there
    is helpful.

The patch below removes the "warning" prefix, uses %m (since it's linux,
%m is available as format modifier), and changes fprintf() to %qemu_error().
Now it prints something like this instead:

 could not configure /dev/net/tun: Device or resource busy

(there are 2 messages like that in the same function)

This fixes Debian bug #578154, see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578154

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoExtra scan codes for missing keys
Bernhard M. Wiedemann [Wed, 2 Jun 2010 03:32:30 +0000 (05:32 +0200)]
Extra scan codes for missing keys

The code comes from
http://lists.gnu.org/archive/html/qemu-devel/2010-05/msg02788.html

Without this patch it is not possible to send at least 10 special
characters (\|'"`~:;[]{}) via the monitor sendkey command.

Signed-off-by: Bernhard M. Wiedemann <qemudevbmw@lsmod.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqcow2: Don't try to check tables that couldn't be loaded
Kevin Wolf [Tue, 22 Jun 2010 10:35:07 +0000 (12:35 +0200)]
qcow2: Don't try to check tables that couldn't be loaded

Trying to check them leads to a second error message which is more confusing
than helpful:

    Can't get refcount for cluster 0: Invalid argument
    ERROR cluster 0 refcount=-22 reference=1

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow2: Fix qemu-img check segfault on corrupted images
Kevin Wolf [Tue, 22 Jun 2010 10:31:45 +0000 (12:31 +0200)]
qcow2: Fix qemu-img check segfault on corrupted images

With corrupted images, we can easily get an cluster index that exceeds the
array size of the temporary refcount table.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agovirtio-blk: fix the list operation in virtio_blk_load().
Yoshiaki Tamura [Mon, 21 Jun 2010 08:50:01 +0000 (17:50 +0900)]
virtio-blk: fix the list operation in virtio_blk_load().

Although it is really rare to get in to the while loop, the list
operation in the loop is obviously wrong.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqemu-io: check registered fds in command_loop()
MORITA Kazutaka [Sun, 20 Jun 2010 19:03:52 +0000 (04:03 +0900)]
qemu-io: check registered fds in command_loop()

Some block drivers use an aio handler and do I/O completion routines
in it.  However, the handler is not invoked if we only do
aio_read/write, because registered fds are not checked at all.

This patch registers an aio handler of STDIO to checks whether we can
read a command without blocking, and calls qemu_aio_wait() in
command_loop().  Any other handlers can be invoked when user input is
idle.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agovpc: Use bdrv_(p)write_sync for metadata writes
Kevin Wolf [Fri, 18 Jun 2010 14:19:11 +0000 (16:19 +0200)]
vpc: Use bdrv_(p)write_sync for metadata writes

Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agovmdk: Use bdrv_(p)write_sync for metadata writes
Kevin Wolf [Fri, 18 Jun 2010 14:22:00 +0000 (16:22 +0200)]
vmdk: Use bdrv_(p)write_sync for metadata writes

Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow2: Use bdrv_(p)write_sync for metadata writes
Kevin Wolf [Wed, 16 Jun 2010 15:44:35 +0000 (17:44 +0200)]
qcow2: Use bdrv_(p)write_sync for metadata writes

Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow: Use bdrv_(p)write_sync for metadata writes
Kevin Wolf [Fri, 18 Jun 2010 14:11:53 +0000 (16:11 +0200)]
qcow: Use bdrv_(p)write_sync for metadata writes

Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agocow: Use bdrv_(p)write_sync for metadata writes
Kevin Wolf [Fri, 18 Jun 2010 14:31:14 +0000 (16:31 +0200)]
cow: Use bdrv_(p)write_sync for metadata writes

Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.
While at it, correct the wrong usage of errno.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Add bdrv_(p)write_sync
Kevin Wolf [Wed, 16 Jun 2010 14:38:15 +0000 (16:38 +0200)]
block: Add bdrv_(p)write_sync

Add new functions that write and flush the written data to disk immediately.
This is what needs to be used for image format metadata to maintain integrity
for cache=... modes that don't use O_DSYNC. (Actually, we only need barriers,
and therefore the functions are defined as such, but flushes is what is
implemented in this patch - we can try to change that later)

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agomonitor: allow device to be ejected if no disk is inserted
Eduardo Habkost [Tue, 1 Jun 2010 22:12:19 +0000 (19:12 -0300)]
monitor: allow device to be ejected if no disk is inserted

This changes the monitor eject_device() function to not check for
bdrv_is_inserted().

Example run where the bug manifests itself:

(output of 'info block' is stripped to include only the CD-ROM device)

  (qemu) info block
  ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]
  (qemu) change ide1-cd0 /dev/cdrom host_cdrom
  (qemu) info block
  ide1-cd0: type=cdrom removable=1 locked=0 file=/dev/cdrom ro=1 drv=host_cdrom encrypted=0
  (qemu) eject ide1-cd0
  (qemu) info block
  ide1-cd0: type=cdrom removable=1 locked=0 file=/dev/cdrom ro=1 drv=host_cdrom encrypted=0

  # at this point, a disk was inserted on the host CD-ROM drive

  (qemu) info block
  ide1-cd0: type=cdrom removable=1 locked=0 file=/dev/cdrom ro=1 drv=host_cdrom encrypted=0
  (qemu) eject ide1-cd0
  (qemu) info block
  ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]
  (qemu)

The first eject command didn't work because the is_inserted() check
failed.

I have no clue why the code had the is_inserted() check, as it doesn't matter
if there is a disk present at the host drive, when the user wants the virtual
device to be disconnected from the host device.

The is_inserted() check has another side effect: a memory leak if the "change"
command is used multiple times, as do_change() calls eject_device() before
re-opening the block device, but bdrv_close() is never called.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: fix physical_block_size calculation
Christoph Hellwig [Tue, 15 Jun 2010 15:52:52 +0000 (17:52 +0200)]
block: fix physical_block_size calculation

Both SCSI and virtio expect the physical block size relative to the
logical block size.  So get the factor first before calculating the
log2.

Reported-by: Mike Cao <bcao@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoscsi-bus: Add MAINTENANCE_IN and MAINTENANCE_OUT SCSIRequest xfer and mode assignments
Nicholas Bellinger [Wed, 16 Jun 2010 13:43:06 +0000 (06:43 -0700)]
scsi-bus: Add MAINTENANCE_IN and MAINTENANCE_OUT SCSIRequest xfer and mode assignments

This patch updates hw/scsi-bus.c to add MAINTENANCE_IN and MAINTENANCE_OUT case in
scsi_req_length() for TYPE_ROM with MMC commands.  It also adds the MAINTENANCE_OUT
case in scsi_req_xfer_mode() to set SCSI_XFER_TO_DEV for outgoing write data.

Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoscsi-bus: Add PERSISTENT_RESERVE_OUT SCSIRequest->cmd.mode setup
Nicholas Bellinger [Wed, 16 Jun 2010 13:42:58 +0000 (06:42 -0700)]
scsi-bus: Add PERSISTENT_RESERVE_OUT SCSIRequest->cmd.mode setup

This patch updates hw/scsi-bus.c to add the PERSISTENT_RESERVE_OUT cdb
case in scsi_req_xfer_mode() to set SCSI_XFER_TO_DEV for outgoing WRITE data.

Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoUpdate OpenBIOS images
Blue Swirl [Sun, 20 Jun 2010 07:55:12 +0000 (07:55 +0000)]
Update OpenBIOS images

Update PPC, Sparc32 and Sparc64 OpenBIOS images to R795.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoapic: qdev conversion cleanup
Blue Swirl [Sat, 19 Jun 2010 07:47:42 +0000 (07:47 +0000)]
apic: qdev conversion cleanup

Make APICState completely private to apic.c by using DeviceState
in external APIs.

Move apic_init() to pc.c.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoapic: convert to qdev
Blue Swirl [Sat, 19 Jun 2010 07:44:07 +0000 (07:44 +0000)]
apic: convert to qdev

Convert to qdev.

Use an opaque CPUState pointer because of missing VMState
implementation for CPUState.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoapic: avoid using CPUState internals
Blue Swirl [Sat, 19 Jun 2010 07:42:34 +0000 (10:42 +0300)]
apic: avoid using CPUState internals

Move the actual CPUState contents handling to cpu.h and cpuid.c.

Handle CPU reset and set env->halted in pc.c.

Add a function to get the local APIC state of the current
CPU for the MMIO.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoapic: avoid passing CPUState from CPU code
Blue Swirl [Sat, 19 Jun 2010 07:42:31 +0000 (10:42 +0300)]
apic: avoid passing CPUState from CPU code

Pass only APICState when accessing APIC from CPU code.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoapic: avoid passing CPUState from devices
Blue Swirl [Sat, 19 Jun 2010 07:42:08 +0000 (10:42 +0300)]
apic: avoid passing CPUState from devices

Pass only APICState from pc.c.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoioapic: convert to qdev
Blue Swirl [Sat, 19 Jun 2010 07:41:43 +0000 (07:41 +0000)]
ioapic: convert to qdev

Convert to qdev.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoioapic: unexport ioapic_set_irq
Blue Swirl [Thu, 17 Jun 2010 16:32:47 +0000 (16:32 +0000)]
ioapic: unexport ioapic_set_irq

There's no need to use ioapic_set_irq() outside of ioapic.c, so
make it static.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoUsermode exec-stack fix
Paul Brook [Wed, 16 Jun 2010 12:03:51 +0000 (13:03 +0100)]
Usermode exec-stack fix

When loading a shared library that requires an executable stack,
glibc uses the mprotext PROT_GROWSDOWN flag to achieve this.
We don't support PROT_GROWSDOWN.
Add a special case to handle changing the stack permissions in this way.

Signed-off-by: Paul Brook <paul@codesourcery.com>
14 years agoStrace mprotect flags.
Paul Brook [Wed, 16 Jun 2010 12:03:51 +0000 (13:03 +0100)]
Strace mprotect flags.

Teach strace code about linux specific mprotect flags.

Signed-off-by: Paul Brook <paul@codesourcery.com>
14 years agoGDB exit status for semihosting
Paul Brook [Wed, 16 Jun 2010 12:03:51 +0000 (13:03 +0100)]
GDB exit status for semihosting

Report exit status to GDB when a semihosted application exits.

Signed-off-by: Paul Brook <paul@codesourcery.com>
14 years agocris: Move sign extension.
Edgar E. Iglesias [Wed, 16 Jun 2010 11:46:15 +0000 (13:46 +0200)]
cris: Move sign extension.

Move it in preparation for further changes.
No functional change.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@axis.com>
14 years agocris: Centralize fetching
Edgar E. Iglesias [Wed, 16 Jun 2010 09:49:30 +0000 (11:49 +0200)]
cris: Centralize fetching

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
14 years agocris: Make the CRISv32 insn decoders return signed int.
Edgar E. Iglesias [Wed, 16 Jun 2010 09:28:53 +0000 (11:28 +0200)]
cris: Make the CRISv32 insn decoders return signed int.

Prepare to return error from the individual decoders.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@axis.com>
14 years agotcg: Optionally sign-extend 32-bit arguments for 64-bit hosts.
Richard Henderson [Tue, 15 Jun 2010 00:35:27 +0000 (17:35 -0700)]
tcg: Optionally sign-extend 32-bit arguments for 64-bit hosts.

Some hosts (amd64, ia64) have an ABI that ignores the high bits
of the 64-bit register when passing 32-bit arguments.  Others
require the value to be properly sign-extended for the type.
I.e. "int32_t" must be sign-extended and "uint32_t" must be
zero-extended to 64-bits.

To effect this, extend the "sizemask" parameter to tcg_gen_callN
to include the signedness of the type of each parameter.  If the
tcg target requires it, extend each 32-bit argument into a 64-bit
temp and pass that to the function call.

This ABI feature is required by sparc64, ppc64 and s390x.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoFix comparison which always returned false
Stefan Weil [Tue, 15 Jun 2010 21:03:28 +0000 (23:03 +0200)]
Fix comparison which always returned false

Comparing an 8 bit value with ~0 does not work as expected.
Replace ~0 by UINT8_MAX in comparison and also in assignment
(and fix coding style, too).

Cc: Gleb Natapov <gleb@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: malc <av1474@comtv.ru>
14 years agoxen: Fix build error due to missing include
Jan Kiszka [Mon, 14 Jun 2010 21:11:05 +0000 (23:11 +0200)]
xen: Fix build error due to missing include

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: fix a warning and possible truncation
Blue Swirl [Mon, 14 Jun 2010 18:55:33 +0000 (18:55 +0000)]
block: fix a warning and possible truncation

Fix a warning from OpenBSD gcc (3.3.5 (propolice)):
/src/qemu/block.c: In function `bdrv_info_stats_bs':
/src/qemu/block.c:1548: warning: long long int format, long unsigned
int arg (arg 6)

There may be also truncation effects.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoCorrect definitions for FD_CMD_SAVE and FD_CMD_RESTORE
Jes Sorensen [Fri, 11 Jun 2010 14:02:34 +0000 (16:02 +0200)]
Correct definitions for FD_CMD_SAVE and FD_CMD_RESTORE

Correct definitions for FD_CMD_SAVE and FD_CMD_RESTORE in hw/fdc.c

Per https://bugs.launchpad.net/qemu/+bug/424453 the correct values
for FD_CMD_SAVE is 0x2e and FD_CMD_RESTORE is 0x4e. Verified against
the Intel 82078 manual which can be found at:
http://wiki.qemu.org/Documentation/HardwareManuals page 22.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblockdev: Give drives internal linkage
Markus Armbruster [Wed, 2 Jun 2010 16:55:22 +0000 (18:55 +0200)]
blockdev: Give drives internal linkage

This is the list of drives defined with drive_init().  Hide it, so it
doesn't get abused.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Decouple savevm from DriveInfo
Markus Armbruster [Wed, 2 Jun 2010 16:55:21 +0000 (18:55 +0200)]
block: Decouple savevm from DriveInfo

We find snapshots by iterating over the list of drives defined with
drive_init().  This misses host block devices defined by other means.
Such means don't exist now, but will be introduced later in this
series.

Iterate over all host block devices instead, with bdrv_next().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: New bdrv_next()
Markus Armbruster [Wed, 2 Jun 2010 16:55:20 +0000 (18:55 +0200)]
block: New bdrv_next()

This is a more flexible alternative to bdrv_iterate().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agomonitor: Make "commit FOO" complain when FOO doesn't exist
Markus Armbruster [Wed, 2 Jun 2010 16:55:19 +0000 (18:55 +0200)]
monitor: Make "commit FOO" complain when FOO doesn't exist

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Decouple block device "commit all" from DriveInfo
Markus Armbruster [Wed, 2 Jun 2010 16:55:18 +0000 (18:55 +0200)]
block: Decouple block device "commit all" from DriveInfo

do_commit() and mux_proc_byte() iterate over the list of drives
defined with drive_init().  This misses host block devices defined by
other means.  Such means don't exist now, but will be introduced later
in this series.

Change them to use new bdrv_commit_all(), which iterates over all host
block devices.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Move error actions from DriveInfo to BlockDriverState
Markus Armbruster [Wed, 2 Jun 2010 16:55:17 +0000 (18:55 +0200)]
block: Move error actions from DriveInfo to BlockDriverState

That's where they belong semantically (block device host part), even
though the actions are actually executed by guest device code.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agocow: use qemu block API
Christoph Hellwig [Mon, 7 Jun 2010 10:06:47 +0000 (12:06 +0200)]
cow: use qemu block API

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agocow: stop using mmap
Christoph Hellwig [Mon, 7 Jun 2010 10:06:37 +0000 (12:06 +0200)]
cow: stop using mmap

We don't have an equivalent to mmap in the qemu block API, so read and
write the bitmap directly.  At least in the dumb implementation added
in this patch this is a lot less efficient, but it means cow can also
work on windows, and over nbd or curl.  And it fixes qemu-iotests testcase
012 which did not work properly due to issues with read-only mmap access.

In addition we can also get rid of the now unused get_mmap_addr function.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agocow: use pread/pwrite
Christoph Hellwig [Mon, 7 Jun 2010 10:06:28 +0000 (12:06 +0200)]
cow: use pread/pwrite

Use pread/pwrite instead of lseek + read/write in preparation of using the
qemu block API.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow2: Restore L1 entry on l2_allocate failure
Kevin Wolf [Mon, 7 Jun 2010 14:43:22 +0000 (16:43 +0200)]
qcow2: Restore L1 entry on l2_allocate failure

If writing the L1 table to disk failed, we need to restore its old content in
memory to avoid inconsistencies.

Reported-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoFix regression for "-drive file="
Markus Armbruster [Tue, 11 May 2010 13:36:46 +0000 (15:36 +0200)]
Fix regression for "-drive file="

Empty file used to create an empty drive (no media).  Since commit
9dfd7c7a, it's an error: "qemu: could not open disk image : No such
file or directory".  Older versions of libvirt can choke on this.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agosavevm: Really verify if a drive supports snapshots
Miguel Di Ciurcio Filho [Tue, 8 Jun 2010 13:40:55 +0000 (10:40 -0300)]
savevm: Really verify if a drive supports snapshots

Both bdrv_can_snapshot() and bdrv_has_snapshot() does not work as advertized.

First issue: Their names implies different porpouses, but they do the same thing
and have exactly the same code. Maybe copied and pasted and forgotten?
bdrv_has_snapshot() is called in various places for actually checking if there
is snapshots or not.

Second issue: the way bdrv_can_snapshot() verifies if a block driver supports or
not snapshots does not catch all cases. E.g.: a raw image.

So when do_savevm() is called, first thing it does is to set a global
BlockDriverState to save the VM memory state calling get_bs_snapshots().

static BlockDriverState *get_bs_snapshots(void)
{
    BlockDriverState *bs;
    DriveInfo *dinfo;

    if (bs_snapshots)
        return bs_snapshots;
    QTAILQ_FOREACH(dinfo, &drives, next) {
        bs = dinfo->bdrv;
        if (bdrv_can_snapshot(bs))
            goto ok;
    }
    return NULL;
 ok:
    bs_snapshots = bs;
    return bs;
}

bdrv_can_snapshot() may return a BlockDriverState that does not support
snapshots and do_savevm() goes on.

Later on in do_savevm(), we find:

    QTAILQ_FOREACH(dinfo, &drives, next) {
        bs1 = dinfo->bdrv;
        if (bdrv_has_snapshot(bs1)) {
            /* Write VM state size only to the image that contains the state */
            sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
            ret = bdrv_snapshot_create(bs1, sn);
            if (ret < 0) {
                monitor_printf(mon, "Error while creating snapshot on '%s'\n",
                               bdrv_get_device_name(bs1));
            }
        }
    }

bdrv_has_snapshot(bs1) is not checking if the device does support or has
snapshots as explained above. Only in bdrv_snapshot_create() the device is
actually checked for snapshot support.

So, in cases where the first device supports snapshots, and the second does not,
the snapshot on the first will happen anyways. I believe this is not a good
behavior. It should be an all or nothing process.

This patch addresses these issues by making bdrv_can_snapshot() actually do
what it must do and enforces better tests to avoid errors in the middle of
do_savevm(). bdrv_has_snapshot() is removed and replaced by bdrv_can_snapshot()
where appropriate.

bdrv_can_snapshot() was moved from savevm.c to block.c. It makes more sense to me.

The loadvm_state() function was updated too to enforce that when loading a VM at
least all writable devices must support snapshots too.

Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow2: Return real error code in load_refcount_block
Kevin Wolf [Fri, 4 Jun 2010 09:27:08 +0000 (11:27 +0200)]
qcow2: Return real error code in load_refcount_block

This fixes load_refcount_block which completely ignored the return value of
write_refcount_block and always returned -EIO for bdrv_pwrite failure.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow2: Allow alloc_clusters_noref to return errors
Kevin Wolf [Fri, 4 Jun 2010 09:22:39 +0000 (11:22 +0200)]
qcow2: Allow alloc_clusters_noref to return errors

Currently it would consider blocks for which get_refcount fails used. However,
it's unlikely that get_refcount would succeed for the next cluster, so it's not
really helpful. Return an error instead.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqcow2: Allow get_refcount to return errors
Kevin Wolf [Fri, 4 Jun 2010 09:16:11 +0000 (11:16 +0200)]
qcow2: Allow get_refcount to return errors

get_refcount might need to load a refcount block from disk, so errors may
happen. Return the error code instead of assuming a refcount of 1 and change
the callers to respect error return values.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agovpc: Read/write multiple sectors at once
Kevin Wolf [Fri, 4 Jun 2010 07:49:04 +0000 (09:49 +0200)]
vpc: Read/write multiple sectors at once

This changes the vpc block driver (for VHD) to read/write multiple sectors at
once instead of doing a request for each single sector.

Before this, running qemu-iotests for VPC took ages, now it's actually quite
reasonable to run it always (down from ~1 hour to 40 seconds for me).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoAdd exit notifiers.
Gerd Hoffmann [Fri, 4 Jun 2010 12:08:07 +0000 (14:08 +0200)]
Add exit notifiers.

Hook up any cleanup work which needs to be done here.  Advantages over
using atexit(3):

  (1) You get passed in a pointer to the notifier.  If you embed that
      into your state struct you can use container_of() to get get your
      state info.
  (2) You can unregister, say when un-plugging a device.

[ v2: move code out of #ifndef _WIN32 ]

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoacpi_piix4: save gpe and pci hotplug slot status
Alex Williamson [Wed, 2 Jun 2010 16:58:29 +0000 (10:58 -0600)]
acpi_piix4: save gpe and pci hotplug slot status

PCI hotplug currently doesn't work after a migration because
we don't migrate the enable bits of the GPE state.  Pull hotplug
structs into vmstate.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqemu-option: Reject anti-social IDs
Markus Armbruster [Tue, 8 Jun 2010 11:54:26 +0000 (13:54 +0200)]
qemu-option: Reject anti-social IDs

Restrict IDs to letters, digits, '-', '.', '_', starting with a
letter.

This takes care of '/' in qdev IDs breaking qbus_find().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqdev: Revert the hack to let -net nic and pci_add set qdev ID
Markus Armbruster [Tue, 8 Jun 2010 11:54:04 +0000 (13:54 +0200)]
qdev: Revert the hack to let -net nic and pci_add set qdev ID

Setting the ID in pci_nic_init() is a blatant violation of the
DeviceState abstraction.  Which even carries a comment advising
against this:

/* This structure should not be accessed directly.  We declare it here
   so that it can be embedded in individual device state structures.  */

What's worse, it bypasses the code ensuring unique qdev IDs: "-device
virtio-net-pci,id=foo -net nic,id=foo -net nic,name=foo" happily
creates three qdevs with ID "foo".  That's because qdev relies on
qemu_opts_create() to ensure unique IDs, but -net nic uses a different
QemuOptsList, which means id is in a different namespace.  And its
name is not checked for uniqueness at all.

-net nic and pci_add are legacy.  Use -device and device_add if you
want a NIC with a qdev ID.

This reverts what's still left of commit eb54b6dc "qdev: add id=
support for pci nics."

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoClarify error message when a PCI slot is already in use (v2)
Daniel P. Berrange [Tue, 8 Jun 2010 14:24:25 +0000 (15:24 +0100)]
Clarify error message when a PCI slot is already in use (v2)

When mistakenly configuring two devices in the same PCI slot,
QEMU gives a not entirely obvious message about a 'devfn' being
in use:

$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3
qemu-kvm: -device virtio-balloon-pci,bus=pci.0,addr=0x3: PCI: devfn 24 not available for virtio-balloon-pci, in use by rtl8139

The user does not configure 'devfn' numbers, they use slot+function.
Thus the error messages should be reported back to the user with that
same terminology rather than the internal QEMU terminology. This
patch makes it report:

$ qemu -device rtl8139 -device virtio-balloon-pci,bus=pci.0,addr=0x3
qemu: -device virtio-balloon-pci,bus=pci.0,addr=0x3.7: PCI: slot 3 function 0 not available for virtio-balloon-pci, in use by rtl8139

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-blk: simplify multiwrite calling conventions
Christoph Hellwig [Tue, 8 Jun 2010 16:26:07 +0000 (18:26 +0200)]
virtio-blk: simplify multiwrite calling conventions

Pass the MultiReqBuffer structure down all the way to the I/O submission
instead of takin it apart.  Also mark num_writes unsigned as it can't
go negative, and take the check for any pending I/O requests into the
submission function.  Last but not least rename do_multiwrite to
virtio_submit_multiwrite to fit the general naming scheme and make clear
what it does.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-blk: stop tracking old_bs
Christoph Hellwig [Tue, 8 Jun 2010 16:25:54 +0000 (18:25 +0200)]
virtio-blk: stop tracking old_bs

There is a 1:1 relation between VirtIOBlock and BlockDriverState instances,
no need to track it because it won't change.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoun-register kbd driver in case of USB kbd unplug.
Jes Sorensen [Tue, 8 Jun 2010 13:12:18 +0000 (15:12 +0200)]
un-register kbd driver in case of USB kbd unplug.

If a USB keyboard is unplugged, the keyboard eventhandler is never
removed, and events will continue to be passed through to the device,
causing crashes or memory corruption.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomake qemu_thread_create block all signals
Paolo Bonzini [Thu, 3 Jun 2010 13:20:32 +0000 (15:20 +0200)]
make qemu_thread_create block all signals

All signals will thus be routed through the IO thread.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomigration-tcp: call migrate_fd_error() instead of close() and free().
Yoshiaki Tamura [Wed, 9 Jun 2010 21:50:10 +0000 (06:50 +0900)]
migration-tcp: call migrate_fd_error() instead of close() and free().

This patch fixes the following error report.  When changing
migration-tcp.c to call migrate_fd_error() instead of close() and
free() by itself, monitor is resumed, and returns allocated mig_state
is set to current_migration in migration.c allows us to print "info
migrate".

Reported-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomigration: use qemu_free() instead of free().
Yoshiaki Tamura [Wed, 9 Jun 2010 05:44:31 +0000 (14:44 +0900)]
migration: use qemu_free() instead of free().

Although there is no difference, other migration related code use
qemu_free(), and it should be better to be consistent.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoetrax-ser: Support the uart rx fifo.
Edgar E. Iglesias [Mon, 14 Jun 2010 16:41:12 +0000 (18:41 +0200)]
etrax-ser: Support the uart rx fifo.

Add support for the rx fifo to speed up bulk transfers.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@axis.com>
14 years agoram_blocks: Convert to a QLIST
Alex Williamson [Fri, 11 Jun 2010 17:11:42 +0000 (11:11 -0600)]
ram_blocks: Convert to a QLIST

This makes the RAM block list easier to manipulate.  Also incorporate
relevant variables into the RAMList struct.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Chris Wright <chrisw@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoMake netdev_del delete the netdev even when it's in use
Markus Armbruster [Fri, 11 Jun 2010 12:21:34 +0000 (14:21 +0200)]
Make netdev_del delete the netdev even when it's in use

To hot-unplug guest and host part of a network device, you do:

    device_del NIC-ID
    netdev_del NETDEV-ID

For PCI devices, device_del merely tells ACPI to unplug the device.
The device goes away for real only after the guest processed the ACPI
unplug event.

You have to wait until then (e.g. by polling info pci) before you can
unplug the netdev.  Not good.

Fix by removing the "in use" check from do_netdev_del().  Deleting a
netdev while it's in use is safe; packets simply get routed to the bit
bucket.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agopass info about hpets to seabios.]
Gleb Natapov [Mon, 14 Jun 2010 08:29:28 +0000 (11:29 +0300)]
pass info about hpets to seabios.]

Currently HPET ACPI table is created regardless of whether qemu actually
created hpet device. This may confuse some guests that don't check that
hpet is functional before using it. Solve this by passing info about
hpets in qemu to seabios via fw config interface. Additional benefit is
that seabios no longer uses hard coded hpet configuration. Proposed
interface supports up to 8 hpets. This is the number defined by hpet
spec.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agohpet: Init capability register only once
Jan Kiszka [Mon, 14 Jun 2010 06:40:29 +0000 (08:40 +0200)]
hpet: Init capability register only once

The capability register is read-only from guest POV, so we do not need
to update it on reset.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqemu-option: Fix uninitialized value in append_option_parameter
Kevin Wolf [Fri, 11 Jun 2010 08:19:41 +0000 (10:19 +0200)]
qemu-option: Fix uninitialized value in append_option_parameter

When dest is NULL, i.e. a new copy of the list is created, we don't get a
properly terminated list after the realloc. Initialize it as an empty list.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoChange #define DEBUG to #define E1000_DEBUG in hw/e1000.c
Jes Sorensen [Mon, 14 Jun 2010 15:05:17 +0000 (17:05 +0200)]
Change #define DEBUG to #define E1000_DEBUG in hw/e1000.c

Change #define DEBUG to #define E1000_DEBUG in hw/e1000.c to make
it possible to build QEMU with -DDEBUG

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoRemove unused DEBUG defines from hw/msix.c
Jes Sorensen [Mon, 14 Jun 2010 15:05:16 +0000 (17:05 +0200)]
Remove unused DEBUG defines from hw/msix.c

Remove unused DEBUG defines from hw/msix.c to avoid having anything
define the word DEBUG without any additions such as MSIX_DEBUG.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoMerge remote branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 14 Jun 2010 15:33:36 +0000 (10:33 -0500)]
Merge remote branch 'kwolf/for-anthony' into staging

Conflicts:
hw/pc.c

14 years agoMerge remote branch 'qmp/for-anthony' into staging
Anthony Liguori [Mon, 14 Jun 2010 14:39:01 +0000 (09:39 -0500)]
Merge remote branch 'qmp/for-anthony' into staging

14 years agoOHCI address decoding fix
Paul Brook [Sun, 13 Jun 2010 22:37:31 +0000 (23:37 +0100)]
OHCI address decoding fix

Ignore high address bits when PCI memory window is not mapped on a page
boundary.

Signed-off-by: Paul Brook <paul@codesourcery.com>
14 years agoMove stdbool.h
Paul Brook [Sun, 13 Jun 2010 18:00:50 +0000 (19:00 +0100)]
Move stdbool.h

Move inclusion of stdbool.h to common header files, instead of including
in an ad-hoc manner.

Signed-off-by: Paul Brook <paul@codesourcery.com>
14 years agomonitor/QMP: Drop info hpet / query-hpet
Jan Kiszka [Sun, 13 Jun 2010 12:15:46 +0000 (14:15 +0200)]
monitor/QMP: Drop info hpet / query-hpet

This command was of minimal use before, now it is useless as the hpet
become a qdev device and is thus easily discoverable. We should
definitely not set query-hpet in QMP's stone, and there is also no good
reason to keep it for the interactive monitor.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agohpet: Add MSI support
Jan Kiszka [Sun, 13 Jun 2010 12:15:45 +0000 (14:15 +0200)]
hpet: Add MSI support

This implements the HPET capability of routing IRQs to the front-side
bus, aka MSI support. This feature can be enabled via the qdev property
"msi" and is off by default.

Note that switching it on can cause guests (at least Linux) to use the
HPET as timer instead of the LAPIC. KVM users should recall that only
the latter is currently available as fast in-kernel model.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agohpet: Make number of timers configurable
Jan Kiszka [Sun, 13 Jun 2010 12:15:44 +0000 (14:15 +0200)]
hpet: Make number of timers configurable

One HPET block supports up to 32 timers. Allow to instantiate more than
the recommended and implemented minimum of 3. The number is configured
via the qdev property "timers". It is also saved/restored so that it
need not match between migration peers.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>