kvm: add detail error message when fail to add ioeventfd

I try to hotplug 28 * 8 multiple-function devices to guest with
old host kernel, ioeventfds in host kernel will be exhausted, then
qemu fails to allocate ioeventfds for blk/nic devices.

It's better to add detail error here.

Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
kvm: zero-initialize KVM_SET_GSI_ROUTING input

kvm_add_routing_entry makes an attempt to
zero-initialize any new routing entry.
However, it fails to initialize padding
within the u field of the structure
kvm_irq_routing_entry.

Other functions like kvm_irqchip_update_msi_route
also fail to initialize the padding field in
kvm_irq_routing_entry.

It's better to just make sure all input is initialized.

Once it is, we can also drop complex field by field assignment and just
do the simple *a = *b to update a route entry.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
kvm: skip system call when msi route is unchanged

Some guests do a large number of mask/unmask
calls which currently trigger expensive route update
system calls.
Detect that route in unchanged and skip the system call.

Reported-by: "Zhanghaoyu (A)" <haoyu.zhang@huawei.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
pci-assign: remove the duplicate function name in debug message

While DEBUG() already includes the function name.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
kvmclock: clock should count only if vm is running

kvmclock should not count while vm is paused, because:

1) if the vm is paused for long periods, timekeeping
math can overflow while converting the (large) clocksource
delta to nanoseconds.

2) Users rely on CLOCK_MONOTONIC to count run time, that is,
time which OS has been in a runnable state (see CLOCK_BOOTTIME).

Change kvmclock driver so as to save clock value when vm transitions
from runnable to stopped state, and to restore clock value from stopped
to runnable transition.

Cc: qemu-stable@nongnu.org
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging

# By Michael S. Tsirkin (2) and others
# Via Paolo Bonzini
* qemu-kvm/uq/master:
  kvmclock: clock should count only if vm is running
  pci-assign: remove the duplicate function name in debug message
  kvm: skip system call when msi route is unchanged
  kvm: zero-initialize KVM_SET_GSI_ROUTING input
  kvm: add detail error message when fail to add ioeventfd

Message-id: 1372841072-22265-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw: Avoid use of QOM type name macros in VMStateDescriptions

The name field in a VMStateDescription is part of the migration state
versioning, so changing it will break migration.  It's therefore a
bad idea to use a QOM typename macro to initialize it, because in
general we're free to rename QOM types as part of code refactoring
and cleanup.  For the handful of devices that were doing this by
mistake, replace the QOM typenames with the corresponding literal
strings.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
[AF: Use TYPE_PVSCI for TypeInfo instead]
Signed-off-by: Andreas Färber <afaerber@suse.de>
net/e1000: QOM Upcast Sweep

Define and use standard QOM cast macro. Remove usages of DO_UPCAST()
and direct -> style upcasting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
net/e1000: QOM parent field cleanup

Replace direct uses of E1000State::dev field with QOM casts and rename
it to parent_obj.

Signed-off-by: Andreas Färber <afaerber@suse.de>
net/rtl8139: QOM Upcast Sweep

Define and use standard QOM cast macro. Remove usages of DO_UPCAST()
and direct -> style upcasting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
net/rtl8139: QOM parent field cleanup

Replace direct uses of RTL8139State::dev with QOM casts and rename it to
parent_obj.

Signed-off-by: Andreas Färber <afaerber@suse.de>
net/pcnet-pci: QOM Upcast Sweep

Define and use standard QOM cast macro. Remove usages of DO_UPCAST()
and direct -> style upcasting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[AF: Renamed parent field]
Signed-off-by: Andreas Färber <afaerber@suse.de>
usb/hcd-xhci: QOM Upcast Sweep

Define and use standard QOM cast macro. Remove usages of DO_UPCAST()
and direct -> style upcasting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[AF: Dropped usb_xhci_init() DeviceState argument and renamed variable]
Signed-off-by: Andreas Färber <afaerber@suse.de>
usb/hcd-xhci: QOM parent field cleanup

Replace direct uses of XHCIState::pci_dev with QOM casts and rename it
to parent_obj.

Signed-off-by: Andreas Färber <afaerber@suse.de>
scsi/lsi53c895a: QOM Upcast Sweep

Define and use standard QOM cast macro. Remove usages of DO_UPCAST()
and direct -> style upcasting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
scsi/lsi53c895a: QOM parent field cleanup

Replace direct uses of LSIState::dev with QOM casts and rename it to
parent_obj.

Signed-off-by: Andreas Färber <afaerber@suse.de>
scsi/megasas: QOM Upcast Sweep

Define and use standard QOM cast macro. Remove usages of DO_UPCAST()
and direct -> style upcasting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
scsi/megasas: QOM parent field cleanup

Replace direct uses of MegasasState::dev with QOM casts and rename it to
parent_obj.

Signed-off-by: Andreas Färber <afaerber@suse.de>
scsi/esp-pci: QOM Upcast Sweep

Define and use standard QOM cast macro. Remove usages of DO_UPCAST()
and direct -> style upcasting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
scsi/esp-pci: QOM parent field cleanup

Replace direct uses of PCIESPState::dev with QOM casts and rename it to
parent_obj.

Signed-off-by: Andreas Färber <afaerber@suse.de>