Compare commits

...
50 Commits
Author SHA1 Message Date
Aurelien Jarno b38d3f24d2 exec-all.h: increase MAX_OP_PER_INSTR to 96 from 64
The x86_64 ror instruction on a 32-bit host can generate up to 77 TCG
ops. Some more space should be left for opc that are added at the end
of the translation.

Thanks to Laurent Desnogues for the debugging help.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-09-22 23:33:44 +02:00
Aurelien Jarno 5c59f6c246 Fix Linux task preemption on Versatile board
Backport from master:

  Recent versions of the Linux kernel will not preempt CPU-intensive
  tasks unless the clock used by sched_clock() works.  On -M versatilepb
  that's the 24MHz timer in the system controller.  It's a very simple
  timer, so implement it.

Signed-off-by: Daniel Jacobowitz <dan@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-09-15 00:53:00 +02:00
Aurelien Jarno 36170c5faf curses: save 250MB of memory
Don't call curses_resize() at the end of curses_display_init() as height
and width are not yet defined. It will be called later by code from
vl.c.

This save 250MB of memory when using -curses.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-09-15 00:27:40 +02:00
Chris Webb c2723a9606 vnc: rework VncState release workflow
Split socket closing and releasing of VncState into two steps. First close
the socket and set the variable to -1 to indicate shutdown in progress. Do
the actual release in a few places where we can be sure it doesn't cause
trouble in form of use-after-free. Add some checks for a valid socket handle
to make sure we don't try to use the closed socket.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Backported to 0.10-stable, removing references to vs->force_update and
changing vnc_disconnect_finish() to match the code in the 0.10 version of
vnc_client_io_error() in place of the master branch version.

Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-08-27 05:23:11 -04:00
Zachary Amsden 07ca62486b Don't segfault when changing VNC password on an SDL display.
Signed-off-by: Zachary Amsden <zamsden@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-08-25 16:28:30 -04:00
Chris Lalancette 0cbbf2533e Fix detached migration with exec.
When trying to do detached migration with exec, I found that
the monitor wouldn't always return in a timely manner.  I
tracked this down to exec_start_outgoing_migration.  It
appeared we were setting the fd to NONBLOCK'ing, but in
point of fact we weren't.

This bugfix should also go onto the stable 0.10 branch

Signed-off-by: Chris Lalancette <clalance@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-08-25 16:28:06 -04:00
Torsten Duwe f3c7245f23 BACKPORT: Fix segfault of qemu-system-arm with PXA target
qemu-system-arm (0.10.5) segfaults when invoked with a PXA machine target,
e.g. -M tosa. The reason is fairly obvious:

[backport: current code uses struct scoop_info_s instead of a typedef ]

Signed-off-by: Torsten Duwe <duwe@lst.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrzej Zaborowski <balrogg@gmail.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-08-25 16:27:36 -04:00
Gleb Natapov d4779e9572 make windows notice media change
Windows seems to be very stupid about cdrom media change. It polls
cdrom status and if status goes ready->media not present->ready
it assumes that media was changed. If "media not present" step doesn't
happen even if "medium may have changed" was seen it assumes media
haven't changed. Fake "media not present" step.

Filip Navara did a great job debugging this issue in Windows and this is
what he found out:

BINGO! ... The media present notifications were broken ever since
Windows 2000 it seems. The media change is detected properly and it's
passed to ClassSetMediaChangeState function which in turn calls
ClasspInternalSetMediaChangeState. This function is responsible for
changing some internal state of the device object and sending the PnP
events which later result in application notifications. It has this
tiny bit of code (not copied byte for byte):

if (oldMediaState == NewState) {
  // Media is in the same state it was before.
  return;
}

so the end result is that for the case of UNIT NEEDS ATTENTION /
MEDIUM MAY HAVE CHANGED without NOT READY in-between is really broken.
It results in the internal media change counter incremented, so the
media contents are re-read when necessary, instead of relying on the
cache, but the notifications to applications are never sent.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Message-Id:

Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-08-25 16:22:06 -04:00
Bill Paul 18bae8a516 e1000.c doesn't properly emulate EERD and ICS registers
Once again, the emulation of the EERD and ICS registers in e1000.c is
incorrect. Nobody has noticed this before because none of the Intel-written
e1000 drivers use these registers, and all of the independently written open
source drivers copy Intel's example, so they don't use them either.
Regardless, these registers are documented in the programmer's manuals, and
their emulated behavior doesn't match the verified behavior of real hardware,
so any software that does use them doesn't function correctly.

-Bill

Signed-off-by: Bill Paul <wpaul@windriver.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-08-25 16:16:58 -04:00
Gerd Hoffmann 74ccfe8b7e BACKPORT: vnc: fix copyrect screen corruption
When sending a copyrect command to the vnc client, we must also update
the local server surface.  Otherwise the server's and the client's idea
of the screen content run out of sync and screen updates don't work
correctly.

[ backport: uses ds_get_data() instead of direct dereference ]
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-08-25 16:12:14 -04:00
Paolo Bonzini e24c7580cb fix migration to obey -S
Since migration returns right away, starting the VM right
after calling qemu_start_incoming_migration is wrong even
if -S is not passed.  We have to do this after migration
has completed.

Cc: Glauber Costa  <glommer@redhat.com>
Cc: Anthony Liguori  <aliguori@us.ibm.com>

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-08-25 16:07:34 -04:00
Glauber Costa f16f83481c fix broken migration
While fixing migration with -S, commit
89befdd1a6 broke the rest of us. Poor
glommer, with a poor family, spare him his life from this monstruosity.

Since the unconditional vm_start, not autostart was the villain, I'm putting
back autostart. Let me know if you prefer other solutions, it doesn't really matter,
doesn't really matter to me.

Any way the wind blows...

Signed-off-by: Glauber Costa <glommer@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-07-29 10:39:04 -04:00
Kevin Wolf b358a08e7b vmdk: Fix backing file handling
Instead of storing the backing file in its own BlockDriverState, VMDK uses the
BlockDriverState of the raw image file it opened. This is wrong and breaks
functions that access the backing file or protocols. This fix replaces all
occurrences of s->hd->backing_* with bs->backing_*.

This fixes qemu-iotests failure in 020 (Commit changes to backing file).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-07-23 10:39:19 -04:00
Nolan f81eed9ddb BACKPORT: Add save/restore support to the LSI logic SCSI device model.
This patch requires "Handle BH's queued by AIO completions in
qemu_aio_flush()" to work reliably.  The combination of those two
patches survived 300+ migrations with heavy IO load running in the
guest.

Signed-off-by: Nolan Leake <nolan <at> sigbus.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-07-23 10:38:13 -04:00
Nolan 0dd99a1e37 Handle BH's queued by AIO completions in qemu_aio_flush()
Without this, the call to qemu_aio_flush during migration doesn't
actually flush all in-flight SCSI IOs.

Signed-off-by: Nolan Leake <nolan <at> sigbus.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-07-23 10:37:30 -04:00
Naphtali Sprei 07fdfe83cf fix for bad macaddr of e1000 in Windows 2003 server with original MS driver
The sequence of reading from eeprom is "offset by one" moved because of a false
detection of a clock cycle after an eeprom reset. Keeping the last clock value
after a reset keeps it in sync.

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-07-20 10:14:11 -04:00
Anthony Liguori 9eab386edb Update changelot for 0.10.6 release 2009-07-16 18:50:52 -05:00
Dinesh Subhraveti 0def14568c Initialize PS2 keyboard / mouse state on reset
Currently only common PS2 state is initialized, leaving keyboard and
mouse specific state to contain stale values.

Signed-off-by: Dinesh Subhraveti <dineshs@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16 18:49:08 -05:00
Beth Kon ca888361bb Reset HPET config register on hpet_reset
Without this, after system reset, hpet does not detect transition from
non-legacy to legacy mode.

Signed-off-by: Beth Kon <eak@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16 18:49:08 -05:00
Paolo Bonzini df97ff696b honor -S on incoming migration
-S is not honored by qemu on incoming migration.  If a domain is migrated
while paused, thus, it will start running on the remote machine; this
is wrong.

Given the trivial patch to fix this, it looks more like a thinko
than anything else, probably dating back to the qemu-kvm merge.
The interesting part is that the -S mechanism was in fact *used* when
migrating (setting autostart = 0) and the incoming migration code was
starting the VM at the end of the migration.

Since I was removing the vm_start from there, I also corrected a related
imprecision.  The code was doing a vm_stop "just in case", but we can
be sure that the VM is not running---the vm_start call in vl.c has not
been reached yet.  So the vm_stop is removed together with the vm_start.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16 18:49:07 -05:00
Anthony Liguori cc15f92832 Update for 0.10.6 release 2009-07-10 17:57:42 -05:00
Anthony Liguori 2670257db0 Revert "Make sure to use SDL_CFLAGS everywhere we include SDL headers"
This reverts commit accceed914.

This has proven to cause all sorts of odd build breakages.  I don't think it's
quite ready for stable.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-10 17:57:42 -05:00
Glauber Costa aae9547639 flush pending aio requests
When we finish migration, there may be pending async io requests
in flight. If we don't flush it before stage3 starting, it might be
the case that the guest loses it.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-10 17:26:09 -05:00
Anthony Liguori 2872b8a445 Make sure to only vm_start() a failed migration if we were running to begin
with.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-10 17:26:09 -05:00
Mark McLoughlin 51224c6f78 Unregister savevm callback in eeprom93xx_free()
Otherwise if you hot remove an eepro100 NIC and then migrate,
you get:

  Unknown savevm section or instance 'eeprom' 0

on the destination side.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-10 17:26:09 -05:00
Mark McLoughlin ed8f8da7a6 Don't leak VLANClientState on PCI hot remove
destroy_nic() requires that NICInfo::private by a PCIDevice pointer,
but then goes on to require that the same pointer matches
VLANClientState::opaque.

That is no longer the case for virtio-net since qdev and wasn't
previously the case for rtl8139, ne2k_pci or eepro100.

Make the situation a lot more clear by maintaining a VLANClientState
pointer in NICInfo.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-10 17:26:03 -05:00
G 3 960b646371 Substitute O_DSYNC with O_SYNC or O_FSYNC when needed.
Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-10 17:15:03 -05:00
Jan Kiszka fc78bd4503 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>
2009-07-10 17:15:03 -05:00
Isaku Yamahata 259cf68eb1 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>
2009-07-10 17:15:03 -05:00
Eduardo Habkost 41de90f32c Fix vga_screen_dump_blank() PPM generation
vga_screen_dump_blank() was not generating a valid PPM file: the width of the
image made no sense (why it was multiplied by sizeof(uint32_t)?), and there was
only one sample per pixel, instead of three.

(cherry picked from commit 77d4db015c)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:46:59 -05:00
Mark McLoughlin 3e6b53eb32 Prevent CD-ROM media eject while device is locked
Section 10.8.25 ("START/STOP UNIT Command") of SFF-8020i states that
if the device is locked we should refuse to eject if the device is
locked.

ASC_MEDIA_REMOVAL_PREVENTED is the appropriate return in this case.

In order to stop itself from ejecting the media it is running from,
Fedora's installer (anaconda) requires the CDROMEJECT ioctl() to fail
if the drive has been previously locked.

See also https://bugzilla.redhat.com/501412

(cherry picked from commit aea2a33c73)

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:46:59 -05:00
Jan Kiszka 80de8ace66 kvm: Fix IRQ injection into full queue
User space may only inject interrupts during kvm_arch_pre_run if
ready_for_interrupt_injection is set in kvm_run. But that field is
updated on exit from KVM_RUN, so we must ensure that we enter the
kernel after potentially queuing an interrupt, otherwise we risk to
loose one - like it happens with the current code against latest
kernel modules (since kvm-86) that started to queue only a single
interrupt.

Fix the problem by reordering kvm_cpu_exec.

Credits go to Gleb Natapov for analyzing the issue in details.

(cherry picked from commit 8c14c17395)

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:46:58 -05:00
Nitin A Kamble ea0c91a0af QEMU KVM: i386: Fix the cpu reset state
As per the IA32 processor manual, the accessed bit is set to 1 in the
processor state after reset. qemu pc cpu_reset code was missing this
accessed bit setting.

(cherry picked from commit 538f368612)

Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:46:58 -05:00
Gerd Hoffmann 71080d96fd virtio blk: fix warning.
(cherry picked from commit 5c5dafdc5e)

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:46:58 -05:00
Sebastian Herbszt a5617318fe lsi53c895a: Implement write access to DMA Byte Counter
Adds CASE_SET_REG24 and fixes the following errors:

lsi_scsi: error: Unhandled writeb 0x24 = 0x0
lsi_scsi: error: Unhandled writeb 0x25 = 0x0

(cherry picked from commit 49c47daa32)

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:46:58 -05:00
Sebastian Herbszt 73cf22cb60 lsi53c895a: Implement read and write access to DMA Next Address
Fixes the following errors:

lsi_scsi: error: Unhandled writeb 0x28 = 0x0
lsi_scsi: error: Unhandled writeb 0x29 = 0x0
lsi_scsi: error: Unhandled writeb 0x2a = 0x0
lsi_scsi: error: Unhandled writeb 0x2b = 0x0

(cherry picked from commit 4b9a2d6de7)

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:46:58 -05:00
Sebastian Herbszt 04f4e710a0 lsi53c895a: Implement Scratch Byte Register
Fixes the following errors:

lsi_scsi: error: Unhandled writeb 0x3a = 0x0
lsi_scsi: error: readb 0x3a

(cherry picked from commit bd8ee11a6b)

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:46:57 -05:00
Anthony Liguori accceed914 Make sure to use SDL_CFLAGS everywhere we include SDL headers
(cherry picked from commit 537fe2d63f)

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:46:57 -05:00
Andrea Arcangeli f29602ca0e fix qemu_aio_flush
qemu_aio_wait by invoking the bh or one of the aio completion
callbacks, could end up submitting new pending aio, breaking the
invariant that qemu_aio_flush returns only when no pending aio is
outstanding (possibly a problem for migration as such).

(cherry picked from commit 986c28d655)

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Kevin Wolf <kwolf@redhat.com>
2009-06-16 17:46:57 -05:00
Uri Lublin 17489dd7e9 migrate_fd_close: delete associated io-handler before closing the fd
It may happen that the io-handler is still registered. That causes
select() to return with EBADF, not calling handlers for other fds.

The io-handler would be registered when (on the source) the whole state
was written but not yet flushed. For example when using QEMUFileBuffered,
(tcp-migration) there may be data left in a buffer waiting to be transferred.
In such a case buffered_close() calls buffered_flush() which calls
migrate_fd_put_buffer, which may, upon EAGAIN, register migrate_fd_put_notify
as a handler.

(cherry picked from commit e19252d32c)

Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:11:19 -05:00
Uri Lublin 936d7bf944 exec-migration: handle EINTR in popen_get_buffer()
Sometimes, upon interrupt, fread returns with no data, and
the (incoming exec) migration fails.

Fix by retrying on such a case.

(cherry picked from commit 8a67ec4d84)

Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:11:13 -05:00
Stefan Weil d13317e197 Fix prototype of function zfree.
(cherry picked from commit d084eab6f8)

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16 17:11:02 -05:00
Jason Wessel 75204ffc5b serial: fix lost character after sysrq
After creating an automated regression test to test the sysrq
responses while running a linux image in qemu, I found that the
simulated uart was eating the character right after the sysrq about
75% of the time.

The problem is that the qemu sets the LSR_DR (data ready) bit on a
serial break.  The automated tests can send a break and the sysrq
character quickly enough that the qemu serial fifo has a real
character available. When there is valid character in the fifo, it
gets consumed by the serial driver in the guest OS.

The real hardware also appears to set the LSR_DR but always appears to
have a null byte in this condition.  This patch changes the qemu
behavior to match the tested characteristics of a real 16550 chip.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-28 02:04:20 -05:00
Gleb Natapov 9fb2ec9a1e Don't send all gratuitous packets at once.
Use timer to separate them in time.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-05-28 02:02:38 -05:00
Gleb Natapov a8bc8570fa Minimal ethernet frame length is 64 bytes.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-05-28 02:02:34 -05:00
aliguori 700ece804f net: Fix -net socket,listen (Jan Kiszka)
In case no symbolic name is provided when requesting VLAN connection via
listening TCP socket ('-net socket,listen=...'), qemu crashes. This
fixes the cause.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Glauber Costa <glommer@redhat.com>
2009-05-28 02:02:04 -05:00
Chris Lalancette 71c55593c0 Allow monitor interaction when using migrate -exec
All,
     I've recently been playing around with migration via exec.  Unfortunately,
when starting the incoming qemu process with "-incoming exec:cmd", it suffers
the same problem that -incoming tcp used to suffer; namely, that you can't
interact with the monitor until after the migration has happened.  This causes
problems for libvirt usage of -incoming exec, since libvirt expects to be able
to access the monitor ahead of time.  This fairly simple patch allows you to
access the monitor both before and after the migration has completed using exec.

(note: developed/tested with qemu-kvm, but applies perfectly fine to qemu)

Signed-off-by: Chris Lalancette <clalance@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-27 09:47:39 -05:00
Christoph Hellwig 5982abd9ca fix raw_pread_aligned return value
raw_pread_aligned currently returns the raw return value from
lseek/read, which is always -1 in case of an error.  But the
callers higher up the stack expect it to return the negated
errno just like raw_pwrite_aligned.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-27 09:47:30 -05:00
Stefan Weil 738208b656 VNC: Fix memory allocation (wrong structure size).
Pointer vs addresses a VncDisplay structure,
so it is sufficient to allocate sizeof(VncDisplay)
or sizeof(*vs) bytes instead of the much larger
sizeof(VncState).

Maybe the misleading name should be fixed, too:
the code contains many places where vs is used,
sometimes it is a VncState *, sometimes it is a
VncDisplay *. vd would be a better name.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-27 09:47:25 -05:00
Kevin Wolf 61348b076b e1000: Ignore reset command
When a reset is requested, the current e1000 emulation never clears the
reset bit which may cause a driver to hang. This patch masks the reset
bit out when setting the control registert, so the reset is immediately
completed.

Signed-off-by: Kevin Wolf <mail@kevin-wolf.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-27 09:47:11 -05:00
42 changed files with 608 additions and 193 deletions

No files matched your search

+29
View File
@@ -1,3 +1,32 @@
version 0.10.6:
- e1000: ignore reset command (Kevin Wolf)
- fix VNC memory allocation (Stefan Weil)
- fix raw_pread_aligned return value (Christoph Hellwig)
- allow monitor interaction when using -incoming exec: (Chris Lalancette)
- fix -net socket,listen (Jan Kiszka)
- live migration: don't send gratuitous packets all at once (Gleb Natapov)
- serial: fix lost characters after sysrq (Jason Wessel)
- Fix prototype of zfree (Stefan Weil)
- Handle EINTR with exec: migration (Uri Lublin)
- Delete io-handler before closing fd after migration (Uri Lublin)
- Fix qemu_aio_flush (Andrea Arcangeli)
- lsi53c895a: Implement additional registers (Sebastian Herbszt)
- virtio-blk: fix warning (Gerd Hoffman)
- i386: fix cpu reset (Nitin Kamble)
- kvm: fix irq injection into full queue (Jan Kiszka)
- Prevent CD-ROM eject while device is locked (Mark McLoughlin)
- Fix screen dump with blank screen (Eduardo Habkost)
- Fix memory leak with cpu_unregister_map_client (Isaku Yamahata)
- Fix memory leak in SDL (Jan Kiszka)
- Fix build on OS X 10.4 (John Arbuckle)
- Fix leak of vlan clients after hot remove (Mark McLoughlin)
- Fix migration after hot remove with eepro100 (Mark McLoughlin)
- Don't start a VM after failed migration if stopped (Anthony Liguori)
- Fix live migration under heavy IO load (Glauber Costa)
- Honor -S on incoming migration (Paolo Bonzini)
- Reset HPET config register on reset (Beth Kon)
- Reset PS2 keyboard/mouse on reset (Dinesh Subraveti)
version 0.10.5:
- kvm: trim unsupported cpu features from cpuid (Avi Kivity)
- kvm: provide a better error message for -smp > 1 (Mark McLoughlin)
+1 -1
View File
@@ -1 +1 @@
0.10.5
0.10.6
+7 -3
View File
@@ -103,12 +103,16 @@ void qemu_aio_flush(void)
do {
ret = 0;
/*
* If there are pending emulated aio start them now so flush
* will be able to return 1.
*/
qemu_aio_wait();
LIST_FOREACH(node, &aio_handlers, node) {
ret |= node->io_flush(node->opaque);
}
qemu_aio_wait();
} while (ret > 0);
} while (qemu_bh_poll() || ret > 0);
}
void qemu_aio_wait(void)
+5 -1
View File
@@ -75,7 +75,11 @@
/* OS X does not have O_DSYNC */
#ifndef O_DSYNC
#ifdef O_SYNC
#define O_DSYNC O_SYNC
#elif defined(O_FSYNC)
#define O_DSYNC O_FSYNC
#endif
#endif
/* Approximate O_DIRECT with O_DSYNC if O_DIRECT isn't available */
@@ -234,7 +238,7 @@ static int raw_pread_aligned(BlockDriverState *bs, int64_t offset,
label__raw_read__success:
return ret;
return (ret < 0) ? -errno : ret;
}
/*
+15 -14
View File
@@ -169,7 +169,7 @@ static int vmdk_is_cid_valid(BlockDriverState *bs)
{
#ifdef CHECK_CID
BDRVVmdkState *s = bs->opaque;
BlockDriverState *p_bs = s->hd->backing_hd;
BlockDriverState *p_bs = bs->backing_hd;
uint32_t cur_pcid;
if (p_bs) {
@@ -337,26 +337,26 @@ static int vmdk_parent_open(BlockDriverState *bs, const char * filename)
p_name += sizeof("parentFileNameHint") + 1;
if ((end_name = strchr(p_name,'\"')) == 0)
return -1;
if ((end_name - p_name) > sizeof (s->hd->backing_file) - 1)
if ((end_name - p_name) > sizeof (bs->backing_file) - 1)
return -1;
pstrcpy(s->hd->backing_file, end_name - p_name + 1, p_name);
if (stat(s->hd->backing_file, &file_buf) != 0) {
pstrcpy(bs->backing_file, end_name - p_name + 1, p_name);
if (stat(bs->backing_file, &file_buf) != 0) {
path_combine(parent_img_name, sizeof(parent_img_name),
filename, s->hd->backing_file);
filename, bs->backing_file);
} else {
pstrcpy(parent_img_name, sizeof(parent_img_name),
s->hd->backing_file);
bs->backing_file);
}
s->hd->backing_hd = bdrv_new("");
if (!s->hd->backing_hd) {
bs->backing_hd = bdrv_new("");
if (!bs->backing_hd) {
failure:
bdrv_close(s->hd);
return -1;
}
parent_open = 1;
if (bdrv_open(s->hd->backing_hd, parent_img_name, BDRV_O_RDONLY) < 0)
if (bdrv_open(bs->backing_hd, parent_img_name, BDRV_O_RDONLY) < 0)
goto failure;
parent_open = 0;
}
@@ -463,13 +463,14 @@ static int get_whole_cluster(BlockDriverState *bs, uint64_t cluster_offset,
// we will be here if it's first write on non-exist grain(cluster).
// try to read from parent image, if exist
if (s->hd->backing_hd) {
BDRVVmdkState *ps = s->hd->backing_hd->opaque;
if (bs->backing_hd) {
BDRVVmdkState *ps = bs->backing_hd->opaque;
if (!vmdk_is_cid_valid(bs))
return -1;
parent_cluster_offset = get_cluster_offset(s->hd->backing_hd, NULL, offset, allocate);
parent_cluster_offset = get_cluster_offset(bs->backing_hd, NULL,
offset, allocate);
if (parent_cluster_offset) {
BDRVVmdkState *act_s = activeBDRV.hd->opaque;
@@ -620,10 +621,10 @@ static int vmdk_read(BlockDriverState *bs, int64_t sector_num,
n = nb_sectors;
if (!cluster_offset) {
// try to read from parent image, if exist
if (s->hd->backing_hd) {
if (bs->backing_hd) {
if (!vmdk_is_cid_valid(bs))
return -1;
ret = bdrv_read(s->hd->backing_hd, sector_num, buf, n);
ret = bdrv_read(bs->backing_hd, sector_num, buf, n);
if (ret < 0)
return -1;
} else {
+8 -1
View File
@@ -1664,11 +1664,15 @@ int bdrv_media_changed(BlockDriverState *bs)
/**
* If eject_flag is TRUE, eject the media. Otherwise, close the tray
*/
void bdrv_eject(BlockDriverState *bs, int eject_flag)
int bdrv_eject(BlockDriverState *bs, int eject_flag)
{
BlockDriver *drv = bs->drv;
int ret;
if (bs->locked) {
return -EBUSY;
}
if (!drv || !drv->bdrv_eject) {
ret = -ENOTSUP;
} else {
@@ -1677,7 +1681,10 @@ void bdrv_eject(BlockDriverState *bs, int eject_flag)
if (ret == -ENOTSUP) {
if (eject_flag)
bdrv_close(bs);
ret = 0;
}
return ret;
}
int bdrv_is_locked(BlockDriverState *bs)
+1 -1
View File
@@ -132,7 +132,7 @@ int bdrv_is_inserted(BlockDriverState *bs);
int bdrv_media_changed(BlockDriverState *bs);
int bdrv_is_locked(BlockDriverState *bs);
void bdrv_set_locked(BlockDriverState *bs, int locked);
void bdrv_eject(BlockDriverState *bs, int eject_flag);
int bdrv_eject(BlockDriverState *bs, int eject_flag);
void bdrv_set_change_cb(BlockDriverState *bs,
void (*change_cb)(void *opaque), void *opaque);
void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
-3
View File
@@ -370,7 +370,4 @@ void curses_display_init(DisplayState *ds, int full_screen)
ds->surface = qemu_create_displaysurface_from(640, 400, 0, 0, (uint8_t*) screen);
invalidate = 1;
/* Standard VGA initial text mode dimensions */
curses_resize(ds);
}
+1 -1
View File
@@ -35,7 +35,7 @@
typedef struct TranslationBlock TranslationBlock;
/* XXX: make safe guess about sizes */
#define MAX_OP_PER_INSTR 64
#define MAX_OP_PER_INSTR 96
/* A Call op needs up to 6 + 2N parameters (N = number of arguments). */
#define MAX_OPC_PARAM 10
#define OPC_BUF_SIZE 512
+2 -1
View File
@@ -3110,6 +3110,7 @@ void cpu_unregister_map_client(void *_client)
MapClient *client = (MapClient *)_client;
LIST_REMOVE(client, link);
qemu_free(client);
}
static void cpu_notify_map_clients(void)
@@ -3119,7 +3120,7 @@ static void cpu_notify_map_clients(void)
while (!LIST_EMPTY(&map_client_list)) {
client = LIST_FIRST(&map_client_list);
client->callback(client->opaque);
LIST_REMOVE(client, link);
cpu_unregister_map_client(client);
}
}
+2 -2
View File
@@ -8,6 +8,7 @@
*/
#include "hw.h"
#include "qemu-timer.h"
#include "primecell.h"
#include "sysemu.h"
@@ -70,8 +71,7 @@ static uint32_t arm_sysctl_read(void *opaque, target_phys_addr_t offset)
case 0x58: /* BOOTCS */
return 0;
case 0x5c: /* 24MHz */
/* ??? not implemented. */
return 0;
return muldiv64(qemu_get_clock(vm_clock), 24000000, ticks_per_sec);
case 0x60: /* MISC */
return 0;
case 0x84: /* PROCID0 */
+1 -6
View File
@@ -55,12 +55,7 @@ void destroy_nic(dev_match_fn *match_fn, void *arg)
nic = &nd_table[i];
if (nic->used) {
if (nic->private && match_fn(nic->private, arg)) {
if (nic->vlan) {
VLANClientState *vc;
vc = qemu_find_vlan_client(nic->vlan, nic->private);
if (vc)
qemu_del_vlan_client(vc);
}
qemu_del_vlan_client(nic->vc);
net_client_uninit(nic);
}
}
+23 -6
View File
@@ -155,6 +155,7 @@ set_interrupt_cause(E1000State *s, int index, uint32_t val)
if (val)
val |= E1000_ICR_INT_ASSERTED;
s->mac_reg[ICR] = val;
s->mac_reg[ICS] = val;
qemu_set_irq(s->dev.irq[0], (s->mac_reg[IMS] & s->mac_reg[ICR]) != 0);
}
@@ -189,6 +190,13 @@ rxbufsize(uint32_t v)
return 2048;
}
static void
set_ctrl(E1000State *s, int index, uint32_t val)
{
/* RST is self clearing */
s->mac_reg[CTRL] = val & ~E1000_CTRL_RST;
}
static void
set_rx_control(E1000State *s, int index, uint32_t val)
{
@@ -255,6 +263,11 @@ set_eecd(E1000State *s, int index, uint32_t val)
}
if (!(val & E1000_EECD_CS)) { // rising, no CS (EEPROM reset)
memset(&s->eecd_state, 0, sizeof s->eecd_state);
/*
* restore old_eecd's E1000_EECD_SK (known to be on)
* to avoid false detection of a clock edge
*/
s->eecd_state.old_eecd = E1000_EECD_SK;
return;
}
s->eecd_state.val_in <<= 1;
@@ -275,10 +288,14 @@ flash_eerd_read(E1000State *s, int x)
{
unsigned int index, r = s->mac_reg[EERD] & ~E1000_EEPROM_RW_REG_START;
if ((s->mac_reg[EERD] & E1000_EEPROM_RW_REG_START) == 0)
return (s->mac_reg[EERD]);
if ((index = r >> E1000_EEPROM_RW_ADDR_SHIFT) > EEPROM_CHECKSUM_REG)
return 0;
return (s->eeprom_data[index] << E1000_EEPROM_RW_REG_DATA) |
E1000_EEPROM_RW_REG_DONE | r;
return (E1000_EEPROM_RW_REG_DONE | r);
return ((s->eeprom_data[index] << E1000_EEPROM_RW_REG_DATA) |
E1000_EEPROM_RW_REG_DONE | r);
}
static void
@@ -767,7 +784,7 @@ static uint32_t (*macreg_readops[])(E1000State *, int) = {
getreg(WUFC), getreg(TDT), getreg(CTRL), getreg(LEDCTL),
getreg(MANC), getreg(MDIC), getreg(SWSM), getreg(STATUS),
getreg(TORL), getreg(TOTL), getreg(IMS), getreg(TCTL),
getreg(RDH), getreg(RDT), getreg(VET),
getreg(RDH), getreg(RDT), getreg(VET), getreg(ICS),
[TOTH] = mac_read_clr8, [TORH] = mac_read_clr8, [GPRC] = mac_read_clr4,
[GPTC] = mac_read_clr4, [TPR] = mac_read_clr4, [TPT] = mac_read_clr4,
@@ -783,12 +800,12 @@ enum { NREADOPS = ARRAY_SIZE(macreg_readops) };
static void (*macreg_writeops[])(E1000State *, int, uint32_t) = {
putreg(PBA), putreg(EERD), putreg(SWSM), putreg(WUFC),
putreg(TDBAL), putreg(TDBAH), putreg(TXDCTL), putreg(RDBAH),
putreg(RDBAL), putreg(LEDCTL), putreg(CTRL), putreg(VET),
putreg(RDBAL), putreg(LEDCTL), putreg(VET),
[TDLEN] = set_dlen, [RDLEN] = set_dlen, [TCTL] = set_tctl,
[TDT] = set_tctl, [MDIC] = set_mdic, [ICS] = set_ics,
[TDH] = set_16bit, [RDH] = set_16bit, [RDT] = set_rdt,
[IMC] = set_imc, [IMS] = set_ims, [ICR] = set_icr,
[EECD] = set_eecd, [RCTL] = set_rx_control,
[EECD] = set_eecd, [RCTL] = set_rx_control, [CTRL] = set_ctrl,
[RA ... RA+31] = &mac_writereg,
[MTA ... MTA+127] = &mac_writereg,
[VFTA ... VFTA+127] = &mac_writereg,
+1
View File
@@ -301,6 +301,7 @@ void eeprom93xx_free(eeprom_t *eeprom)
{
/* Destroy EEPROM. */
logout("eeprom = 0x%p\n", eeprom);
unregister_savevm("eeprom", eeprom);
qemu_free(eeprom);
}
+3 -3
View File
@@ -594,9 +594,9 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
eth->ethregs = cpu_register_io_memory(0, eth_read, eth_write, eth);
cpu_register_physical_memory (base, 0x5c, eth->ethregs);
eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
eth_receive, eth_can_receive,
eth_cleanup, eth);
eth->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
eth_receive, eth_can_receive,
eth_cleanup, eth);
eth->vc->opaque = eth;
eth->vc->link_status_changed = eth_set_link;
+1
View File
@@ -554,6 +554,7 @@ static void hpet_reset(void *opaque) {
/* 64-bit main counter; 3 timers supported; LegacyReplacementRoute. */
s->capability = 0x8086a201ULL;
s->capability |= ((HPET_CLK_PERIOD) << 32);
s->config = 0ULL;
if (count > 0)
/* we don't enable pit when hpet_reset is first called (by hpet_init)
* because hpet is taking over for pit here. On subsequent invocations,
+1
View File
@@ -37,6 +37,7 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode);
QEMUFile *qemu_fopen_socket(int fd);
QEMUFile *qemu_popen(FILE *popen_file, const char *mode);
QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
int qemu_popen_fd(QEMUFile *f);
void qemu_fflush(QEMUFile *f);
int qemu_fclose(QEMUFile *f);
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
+43 -21
View File
@@ -359,6 +359,7 @@
#define ASC_INCOMPATIBLE_FORMAT 0x30
#define ASC_MEDIUM_NOT_PRESENT 0x3a
#define ASC_SAVING_PARAMETERS_NOT_SUPPORTED 0x39
#define ASC_MEDIA_REMOVAL_PREVENTED 0x53
#define CFA_NO_ERROR 0x00
#define CFA_MISC_ERROR 0x09
@@ -417,6 +418,7 @@ typedef struct IDEState {
/* ATAPI specific */
uint8_t sense_key;
uint8_t asc;
uint8_t cdrom_changed;
int packet_transfer_size;
int elementary_transfer_size;
int io_buffer_index;
@@ -1639,9 +1641,10 @@ static void ide_atapi_cmd(IDEState *s)
}
switch(s->io_buffer[0]) {
case GPCMD_TEST_UNIT_READY:
if (bdrv_is_inserted(s->bs)) {
if (bdrv_is_inserted(s->bs) && !s->cdrom_changed) {
ide_atapi_cmd_ok(s);
} else {
s->cdrom_changed = 0;
ide_atapi_cmd_error(s, SENSE_NOT_READY,
ASC_MEDIUM_NOT_PRESENT);
}
@@ -1818,18 +1821,27 @@ static void ide_atapi_cmd(IDEState *s)
break;
case GPCMD_START_STOP_UNIT:
{
int start, eject;
int start, eject, err = 0;
start = packet[4] & 1;
eject = (packet[4] >> 1) & 1;
if (eject && !start) {
/* eject the disk */
bdrv_eject(s->bs, 1);
} else if (eject && start) {
/* close the tray */
bdrv_eject(s->bs, 0);
if (eject) {
err = bdrv_eject(s->bs, !start);
}
switch (err) {
case 0:
ide_atapi_cmd_ok(s);
break;
case -EBUSY:
ide_atapi_cmd_error(s, SENSE_NOT_READY,
ASC_MEDIA_REMOVAL_PREVENTED);
break;
default:
ide_atapi_cmd_error(s, SENSE_NOT_READY,
ASC_MEDIUM_NOT_PRESENT);
break;
}
ide_atapi_cmd_ok(s);
}
break;
case GPCMD_MECHANISM_STATUS:
@@ -2092,7 +2104,7 @@ static void cdrom_change_cb(void *opaque)
s->sense_key = SENSE_UNIT_ATTENTION;
s->asc = ASC_MEDIUM_MAY_HAVE_CHANGED;
s->cdrom_changed = 1;
ide_set_irq(s);
}
@@ -2860,7 +2872,7 @@ static void ide_save(QEMUFile* f, IDEState *s)
}
/* load per IDE drive data */
static void ide_load(QEMUFile* f, IDEState *s)
static void ide_load(QEMUFile* f, IDEState *s, int version_id)
{
s->mult_sectors=qemu_get_be32(f);
s->identify_set=qemu_get_be32(f);
@@ -2884,6 +2896,13 @@ static void ide_load(QEMUFile* f, IDEState *s)
qemu_get_8s(f, &s->sense_key);
qemu_get_8s(f, &s->asc);
if (version_id == 3) {
qemu_get_8s(f, &s->cdrom_changed);
} else {
if (s->sense_key == SENSE_UNIT_ATTENTION &&
s->asc == ASC_MEDIUM_MAY_HAVE_CHANGED)
s->cdrom_changed = 1;
}
/* XXX: if a transfer is pending, we do not save it yet */
}
@@ -3205,7 +3224,7 @@ static int pci_ide_load(QEMUFile* f, void *opaque, int version_id)
PCIIDEState *d = opaque;
int ret, i;
if (version_id != 2)
if (version_id != 2 && version_id != 3)
return -EINVAL;
ret = pci_device_load(&d->dev, f);
if (ret < 0)
@@ -3235,7 +3254,7 @@ static int pci_ide_load(QEMUFile* f, void *opaque, int version_id)
/* per IDE drive data */
for(i = 0; i < 4; i++) {
ide_load(f, &d->ide_if[i]);
ide_load(f, &d->ide_if[i], version_id);
}
return 0;
}
@@ -3325,7 +3344,7 @@ void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table,
ide_init2(&d->ide_if[0], hd_table[0], hd_table[1], irq[0]);
ide_init2(&d->ide_if[2], hd_table[2], hd_table[3], irq[1]);
register_savevm("ide", 0, 2, pci_ide_save, pci_ide_load, d);
register_savevm("ide", 0, 3, pci_ide_save, pci_ide_load, d);
qemu_register_reset(cmd646_reset, d);
cmd646_reset(d);
}
@@ -3384,7 +3403,7 @@ void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
if (hd_table[i])
hd_table[i]->private = &d->dev;
register_savevm("ide", 0, 2, pci_ide_save, pci_ide_load, d);
register_savevm("ide", 0, 3, pci_ide_save, pci_ide_load, d);
}
/* hd_table must contain 4 block drivers */
@@ -3420,7 +3439,7 @@ void pci_piix4_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
ide_init_ioport(&d->ide_if[2], 0x170, 0x376);
register_savevm("ide", 0, 2, pci_ide_save, pci_ide_load, d);
register_savevm("ide", 0, 3, pci_ide_save, pci_ide_load, d);
}
#if defined(TARGET_PPC)
@@ -3708,7 +3727,7 @@ static int pmac_ide_load(QEMUFile *f, void *opaque, int version_id)
uint8_t drive1_selected;
unsigned int i;
if (version_id != 1)
if (version_id != 1 && version_id != 3)
return -EINVAL;
/* per IDE interface data */
@@ -3718,7 +3737,7 @@ static int pmac_ide_load(QEMUFile *f, void *opaque, int version_id)
/* per IDE drive data */
for(i = 0; i < 2; i++) {
ide_load(f, &s[i]);
ide_load(f, &s[i], version_id);
}
return 0;
}
@@ -3749,7 +3768,7 @@ int pmac_ide_init (BlockDriverState **hd_table, qemu_irq irq,
pmac_ide_memory = cpu_register_io_memory(0, pmac_ide_read,
pmac_ide_write, d);
register_savevm("ide", 0, 1, pmac_ide_save, pmac_ide_load, d);
register_savevm("ide", 0, 3, pmac_ide_save, pmac_ide_load, d);
qemu_register_reset(pmac_ide_reset, d);
pmac_ide_reset(d);
@@ -4142,6 +4161,9 @@ static int md_load(QEMUFile *f, void *opaque, int version_id)
int i;
uint8_t drive1_selected;
if (version_id != 0 && version_id != 3)
return -EINVAL;
qemu_get_8s(f, &s->opt);
qemu_get_8s(f, &s->stat);
qemu_get_8s(f, &s->pins);
@@ -4155,7 +4177,7 @@ static int md_load(QEMUFile *f, void *opaque, int version_id)
s->ide->cur_drive = &s->ide[(drive1_selected != 0)];
for (i = 0; i < 2; i ++)
ide_load(f, &s->ide[i]);
ide_load(f, &s->ide[i], version_id);
return 0;
}
@@ -4386,7 +4408,7 @@ struct pcmcia_card_s *dscm1xxxx_init(BlockDriverState *bdrv)
md->ide->mdata_size = METADATA_SIZE;
md->ide->mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
register_savevm("microdrive", -1, 0, md_save, md_load, md);
register_savevm("microdrive", -1, 3, md_save, md_load, md);
return &md->card;
}
+189
View File
@@ -10,6 +10,8 @@
/* ??? Need to check if the {read,write}[wl] routines work properly on
big-endian targets. */
#include <assert.h> \
#include "hw.h"
#include "pci.h"
#include "scsi-disk.h"
@@ -262,6 +264,7 @@ typedef struct {
uint32_t sbc;
uint32_t csbc;
uint32_t scratch[18]; /* SCRATCHA-SCRATCHR */
uint8_t sbr;
/* Script ram is stored as 32-bit words in host byteorder. */
uint32_t script_ram[2048];
@@ -330,6 +333,7 @@ static void lsi_soft_reset(LSIState *s)
s->ia = 0;
s->sbc = 0;
s->csbc = 0;
s->sbr = 0;
}
static int lsi_dma_40bit(LSIState *s)
@@ -1400,6 +1404,7 @@ static uint8_t lsi_reg_readb(LSIState *s, int offset)
CASE_GET_REG24(dbc, 0x24)
case 0x27: /* DCMD */
return s->dcmd;
CASE_GET_REG32(dnad, 0x28)
CASE_GET_REG32(dsp, 0x2c)
CASE_GET_REG32(dsps, 0x30)
CASE_GET_REG32(scratch[0], 0x34)
@@ -1407,6 +1412,8 @@ static uint8_t lsi_reg_readb(LSIState *s, int offset)
return s->dmode;
case 0x39: /* DIEN */
return s->dien;
case 0x3a: /* SBR */
return s->sbr;
case 0x3b: /* DCNTL */
return s->dcntl;
case 0x40: /* SIEN0 */
@@ -1486,6 +1493,11 @@ static uint8_t lsi_reg_readb(LSIState *s, int offset)
static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
{
#define CASE_SET_REG24(name, addr) \
case addr : s->name &= 0xffffff00; s->name |= val; break; \
case addr + 1: s->name &= 0xffff00ff; s->name |= val << 8; break; \
case addr + 2: s->name &= 0xff00ffff; s->name |= val << 16; break;
#define CASE_SET_REG32(name, addr) \
case addr : s->name &= 0xffffff00; s->name |= val; break; \
case addr + 1: s->name &= 0xffff00ff; s->name |= val << 8; break; \
@@ -1590,6 +1602,8 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
}
s->ctest5 = val;
break;
CASE_SET_REG24(dbc, 0x24)
CASE_SET_REG32(dnad, 0x28)
case 0x2c: /* DSP[0:7] */
s->dsp &= 0xffffff00;
s->dsp |= val;
@@ -1621,6 +1635,9 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
s->dien = val;
lsi_update_irq(s);
break;
case 0x3a: /* SBR */
s->sbr = val;
break;
case 0x3b: /* DCNTL */
s->dcntl = val & ~(LSI_DCNTL_PFF | LSI_DCNTL_STD);
if ((val & LSI_DCNTL_STD) && (s->istat1 & LSI_ISTAT1_SRUN) == 0)
@@ -1700,6 +1717,7 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
BADF("Unhandled writeb 0x%x = 0x%x\n", offset, val);
}
}
#undef CASE_SET_REG24
#undef CASE_SET_REG32
}
@@ -1964,6 +1982,174 @@ void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id)
bd->private = &s->pci_dev;
}
static void lsi_scsi_save(QEMUFile *f, void *opaque)
{
LSIState *s = opaque;
assert(s->dma_buf == NULL);
assert(s->current_dma_len == 0);
assert(s->active_commands == 0);
pci_device_save(&s->pci_dev, f);
qemu_put_sbe32s(f, &s->carry);
qemu_put_sbe32s(f, &s->sense);
qemu_put_sbe32s(f, &s->msg_action);
qemu_put_sbe32s(f, &s->msg_len);
qemu_put_buffer(f, s->msg, sizeof (s->msg));
qemu_put_sbe32s(f, &s->waiting);
qemu_put_be32s(f, &s->dsa);
qemu_put_be32s(f, &s->temp);
qemu_put_be32s(f, &s->dnad);
qemu_put_be32s(f, &s->dbc);
qemu_put_8s(f, &s->istat0);
qemu_put_8s(f, &s->istat1);
qemu_put_8s(f, &s->dcmd);
qemu_put_8s(f, &s->dstat);
qemu_put_8s(f, &s->dien);
qemu_put_8s(f, &s->sist0);
qemu_put_8s(f, &s->sist1);
qemu_put_8s(f, &s->sien0);
qemu_put_8s(f, &s->sien1);
qemu_put_8s(f, &s->mbox0);
qemu_put_8s(f, &s->mbox1);
qemu_put_8s(f, &s->dfifo);
qemu_put_8s(f, &s->ctest2);
qemu_put_8s(f, &s->ctest3);
qemu_put_8s(f, &s->ctest4);
qemu_put_8s(f, &s->ctest5);
qemu_put_8s(f, &s->ccntl0);
qemu_put_8s(f, &s->ccntl1);
qemu_put_be32s(f, &s->dsp);
qemu_put_be32s(f, &s->dsps);
qemu_put_8s(f, &s->dmode);
qemu_put_8s(f, &s->dcntl);
qemu_put_8s(f, &s->scntl0);
qemu_put_8s(f, &s->scntl1);
qemu_put_8s(f, &s->scntl2);
qemu_put_8s(f, &s->scntl3);
qemu_put_8s(f, &s->sstat0);
qemu_put_8s(f, &s->sstat1);
qemu_put_8s(f, &s->scid);
qemu_put_8s(f, &s->sxfer);
qemu_put_8s(f, &s->socl);
qemu_put_8s(f, &s->sdid);
qemu_put_8s(f, &s->ssid);
qemu_put_8s(f, &s->sfbr);
qemu_put_8s(f, &s->stest1);
qemu_put_8s(f, &s->stest2);
qemu_put_8s(f, &s->stest3);
qemu_put_8s(f, &s->sidl);
qemu_put_8s(f, &s->stime0);
qemu_put_8s(f, &s->respid0);
qemu_put_8s(f, &s->respid1);
qemu_put_be32s(f, &s->mmrs);
qemu_put_be32s(f, &s->mmws);
qemu_put_be32s(f, &s->sfs);
qemu_put_be32s(f, &s->drs);
qemu_put_be32s(f, &s->sbms);
qemu_put_be32s(f, &s->dbms);
qemu_put_be32s(f, &s->dnad64);
qemu_put_be32s(f, &s->pmjad1);
qemu_put_be32s(f, &s->pmjad2);
qemu_put_be32s(f, &s->rbc);
qemu_put_be32s(f, &s->ua);
qemu_put_be32s(f, &s->ia);
qemu_put_be32s(f, &s->sbc);
qemu_put_be32s(f, &s->csbc);
qemu_put_buffer(f, (uint8_t *)s->scratch, sizeof (s->scratch));
qemu_put_8s(f, &s->sbr);
qemu_put_buffer(f, (uint8_t *)s->script_ram, sizeof (s->script_ram));
}
static int lsi_scsi_load(QEMUFile *f, void *opaque, int version_id)
{
LSIState *s = opaque;
int ret;
if (version_id > 0) {
return -EINVAL;
}
if ((ret = pci_device_load(&s->pci_dev, f)) < 0)
return ret;
qemu_get_sbe32s(f, &s->carry);
qemu_get_sbe32s(f, &s->sense);
qemu_get_sbe32s(f, &s->msg_action);
qemu_get_sbe32s(f, &s->msg_len);
qemu_get_buffer(f, s->msg, sizeof (s->msg));
qemu_get_sbe32s(f, &s->waiting);
qemu_get_be32s(f, &s->dsa);
qemu_get_be32s(f, &s->temp);
qemu_get_be32s(f, &s->dnad);
qemu_get_be32s(f, &s->dbc);
qemu_get_8s(f, &s->istat0);
qemu_get_8s(f, &s->istat1);
qemu_get_8s(f, &s->dcmd);
qemu_get_8s(f, &s->dstat);
qemu_get_8s(f, &s->dien);
qemu_get_8s(f, &s->sist0);
qemu_get_8s(f, &s->sist1);
qemu_get_8s(f, &s->sien0);
qemu_get_8s(f, &s->sien1);
qemu_get_8s(f, &s->mbox0);
qemu_get_8s(f, &s->mbox1);
qemu_get_8s(f, &s->dfifo);
qemu_get_8s(f, &s->ctest2);
qemu_get_8s(f, &s->ctest3);
qemu_get_8s(f, &s->ctest4);
qemu_get_8s(f, &s->ctest5);
qemu_get_8s(f, &s->ccntl0);
qemu_get_8s(f, &s->ccntl1);
qemu_get_be32s(f, &s->dsp);
qemu_get_be32s(f, &s->dsps);
qemu_get_8s(f, &s->dmode);
qemu_get_8s(f, &s->dcntl);
qemu_get_8s(f, &s->scntl0);
qemu_get_8s(f, &s->scntl1);
qemu_get_8s(f, &s->scntl2);
qemu_get_8s(f, &s->scntl3);
qemu_get_8s(f, &s->sstat0);
qemu_get_8s(f, &s->sstat1);
qemu_get_8s(f, &s->scid);
qemu_get_8s(f, &s->sxfer);
qemu_get_8s(f, &s->socl);
qemu_get_8s(f, &s->sdid);
qemu_get_8s(f, &s->ssid);
qemu_get_8s(f, &s->sfbr);
qemu_get_8s(f, &s->stest1);
qemu_get_8s(f, &s->stest2);
qemu_get_8s(f, &s->stest3);
qemu_get_8s(f, &s->sidl);
qemu_get_8s(f, &s->stime0);
qemu_get_8s(f, &s->respid0);
qemu_get_8s(f, &s->respid1);
qemu_get_be32s(f, &s->mmrs);
qemu_get_be32s(f, &s->mmws);
qemu_get_be32s(f, &s->sfs);
qemu_get_be32s(f, &s->drs);
qemu_get_be32s(f, &s->sbms);
qemu_get_be32s(f, &s->dbms);
qemu_get_be32s(f, &s->dnad64);
qemu_get_be32s(f, &s->pmjad1);
qemu_get_be32s(f, &s->pmjad2);
qemu_get_be32s(f, &s->rbc);
qemu_get_be32s(f, &s->ua);
qemu_get_be32s(f, &s->ia);
qemu_get_be32s(f, &s->sbc);
qemu_get_be32s(f, &s->csbc);
qemu_get_buffer(f, (uint8_t *)s->scratch, sizeof (s->scratch));
qemu_get_8s(f, &s->sbr);
qemu_get_buffer(f, (uint8_t *)s->script_ram, sizeof (s->script_ram));
return 0;
}
static int lsi_scsi_uninit(PCIDevice *d)
{
LSIState *s = (LSIState *) d;
@@ -2022,5 +2208,8 @@ void *lsi_scsi_init(PCIBus *bus, int devfn)
lsi_soft_reset(s);
register_savevm("lsiscsi", -1, 0, lsi_scsi_save, lsi_scsi_load, s);
return s;
}
+3 -3
View File
@@ -463,9 +463,9 @@ void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq)
mcf_fec_writefn, s);
cpu_register_physical_memory(base, 0x400, s->mmio_index);
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
mcf_fec_receive, mcf_fec_can_receive,
mcf_fec_cleanup, s);
s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
mcf_fec_receive, mcf_fec_can_receive,
mcf_fec_cleanup, s);
memcpy(s->macaddr, nd->macaddr, 6);
qemu_format_nic_info_str(s->vc, s->macaddr);
}
+4 -3
View File
@@ -261,9 +261,10 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd)
s->io_base = base;
s->irq = irq;
if (nd && nd->vlan) {
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
mipsnet_receive, mipsnet_can_receive,
mipsnet_cleanup, s);
s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
mipsnet_receive,
mipsnet_can_receive,
mipsnet_cleanup, s);
} else {
s->vc = NULL;
}
+3 -3
View File
@@ -756,9 +756,9 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
ne2000_reset(s);
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
ne2000_receive, ne2000_can_receive,
isa_ne2000_cleanup, s);
s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
ne2000_receive, ne2000_can_receive,
isa_ne2000_cleanup, s);
qemu_format_nic_info_str(s->vc, s->macaddr);
+32 -6
View File
@@ -488,9 +488,8 @@ void ps2_write_mouse(void *opaque, int val)
}
}
static void ps2_reset(void *opaque)
static void ps2_common_reset(PS2State *s)
{
PS2State *s = (PS2State *)opaque;
PS2Queue *q;
s->write_cmd = -1;
q = &s->queue;
@@ -500,6 +499,33 @@ static void ps2_reset(void *opaque)
s->update_irq(s->update_arg, 0);
}
static void ps2_kbd_reset(void *opaque)
{
PS2KbdState *s = (PS2KbdState *) opaque;
ps2_common_reset(&s->common);
s->scan_enabled = 0;
s->translate = 0;
s->scancode_set = 0;
}
static void ps2_mouse_reset(void *opaque)
{
PS2MouseState *s = (PS2MouseState *) opaque;
ps2_common_reset(&s->common);
s->mouse_status = 0;
s->mouse_resolution = 0;
s->mouse_sample_rate = 0;
s->mouse_wrap = 0;
s->mouse_type = 0;
s->mouse_detect_state = 0;
s->mouse_dx = 0;
s->mouse_dy = 0;
s->mouse_dz = 0;
s->mouse_buttons = 0;
}
static void ps2_common_save (QEMUFile *f, PS2State *s)
{
qemu_put_be32 (f, s->write_cmd);
@@ -590,10 +616,10 @@ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg)
s->common.update_irq = update_irq;
s->common.update_arg = update_arg;
s->scancode_set = 2;
ps2_reset(&s->common);
ps2_kbd_reset(s);
register_savevm("ps2kbd", 0, 3, ps2_kbd_save, ps2_kbd_load, s);
qemu_add_kbd_event_handler(ps2_put_keycode, s);
qemu_register_reset(ps2_reset, &s->common);
qemu_register_reset(ps2_kbd_reset, s);
return s;
}
@@ -603,9 +629,9 @@ void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg)
s->common.update_irq = update_irq;
s->common.update_arg = update_arg;
ps2_reset(&s->common);
ps2_mouse_reset(s);
register_savevm("ps2mouse", 0, 2, ps2_mouse_save, ps2_mouse_load, s);
qemu_add_mouse_event_handler(ps2_mouse_event, s, 0, "QEMU PS/2 Mouse");
qemu_register_reset(ps2_reset, &s->common);
qemu_register_reset(ps2_mouse_reset, s);
return s;
}
+2
View File
@@ -586,6 +586,8 @@ static int serial_can_receive(SerialState *s)
static void serial_receive_break(SerialState *s)
{
s->rbr = 0;
/* When the LSR_DR is set a null byte is pushed into the fifo */
fifo_put(s, RECV_FIFO, '\0');
s->lsr |= UART_LSR_BI | UART_LSR_DR;
serial_update_irq(s);
}
+4 -4
View File
@@ -1457,10 +1457,10 @@ USBDevice *usb_net_init(NICInfo *nd)
pstrcpy(s->dev.devname, sizeof(s->dev.devname),
"QEMU USB Network Interface");
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
usbnet_receive,
usbnet_can_receive,
usbnet_cleanup, s);
s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
usbnet_receive,
usbnet_can_receive,
usbnet_cleanup, s);
qemu_format_nic_info_str(s->vc, s->mac);
+3 -2
View File
@@ -2606,8 +2606,9 @@ static void vga_screen_dump_blank(VGAState *s, const char *filename)
{
FILE *f;
unsigned int y, x, w, h;
unsigned char blank_sample[3] = { 0, 0, 0 };
w = s->last_scr_width * sizeof(uint32_t);
w = s->last_scr_width;
h = s->last_scr_height;
f = fopen(filename, "wb");
@@ -2616,7 +2617,7 @@ static void vga_screen_dump_blank(VGAState *s, const char *filename)
fprintf(f, "P6\n%d %d\n%d\n", w, h, 255);
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
fputc(0, f);
fwrite(blank_sample, 3, 1, f);
}
}
fclose(f);
+1
View File
@@ -247,6 +247,7 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
bdrv_get_geometry(s->bs, &capacity);
bdrv_get_geometry_hint(s->bs, &cylinders, &heads, &secs);
memset(&blkcfg, 0, sizeof(blkcfg));
stq_raw(&blkcfg.capacity, capacity);
stl_raw(&blkcfg.seg_max, 128 - 2);
stw_raw(&blkcfg.cylinders, cylinders);
+1 -1
View File
@@ -160,7 +160,7 @@ static CPUWriteMemoryFunc *scoop_writefn[] = {
void scoop_gpio_set(void *opaque, int line, int level)
{
struct scoop_info_s *s = (struct scoop_info_s *) s;
struct scoop_info_s *s = (struct scoop_info_s *) opaque;
if (level)
s->gpio_level |= (1 << line);
+1 -2
View File
@@ -451,14 +451,13 @@ int kvm_cpu_exec(CPUState *env)
dprintf("kvm_cpu_exec()\n");
do {
kvm_arch_pre_run(env, run);
if (env->exit_request) {
dprintf("interrupt exit requested\n");
ret = 0;
break;
}
kvm_arch_pre_run(env, run);
ret = kvm_vcpu_ioctl(env, KVM_RUN, 0);
kvm_arch_post_run(env, run);
+2 -2
View File
@@ -383,7 +383,7 @@ static void *zalloc(void *x, unsigned items, unsigned size)
return (p);
}
static void zfree(void *x, void *addr, unsigned nb)
static void zfree(void *x, void *addr)
{
qemu_free(addr);
}
@@ -431,7 +431,7 @@ static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
}
s.zalloc = zalloc;
s.zfree = (free_func)zfree;
s.zfree = zfree;
r = inflateInit2(&s, -MAX_WBITS);
if (r != Z_OK) {
+27 -19
View File
@@ -74,10 +74,7 @@ MigrationState *exec_start_outgoing_migration(const char *command,
goto err_after_open;
}
if (fcntl(s->fd, F_SETFD, O_NONBLOCK) == -1) {
dprintf("Unable to set nonblocking mode on file descriptor\n");
goto err_after_open;
}
socket_set_nonblock(s->fd);
s->opaque = qemu_popen(f, "w");
@@ -108,9 +105,29 @@ err_after_alloc:
return NULL;
}
static void exec_accept_incoming_migration(void *opaque)
{
QEMUFile *f = opaque;
int ret;
ret = qemu_loadvm_state(f);
if (ret < 0) {
fprintf(stderr, "load of migration failed\n");
goto err;
}
qemu_announce_self();
dprintf("successfully loaded vm state\n");
/* we've successfully migrated, close the fd */
qemu_set_fd_handler2(qemu_popen_fd(f), NULL, NULL, NULL, NULL);
if (autostart)
vm_start();
err:
qemu_fclose(f);
}
int exec_start_incoming_migration(const char *command)
{
int ret;
QEMUFile *f;
dprintf("Attempting to start an incoming migration\n");
@@ -119,19 +136,10 @@ int exec_start_incoming_migration(const char *command)
dprintf("Unable to apply qemu wrapper to popen file\n");
return -errno;
}
vm_stop(0); /* just in case */
ret = qemu_loadvm_state(f);
if (ret < 0) {
fprintf(stderr, "load of migration failed\n");
goto err;
}
qemu_announce_self();
dprintf("successfully loaded vm state\n");
vm_start();
qemu_fclose(f);
return 0;
err:
qemu_fclose(f);
return -errno;
qemu_set_fd_handler2(qemu_popen_fd(f), NULL,
exec_accept_incoming_migration, NULL,
(void *)(unsigned long)f);
return 0;
}
+2 -3
View File
@@ -159,7 +159,6 @@ static void tcp_accept_incoming_migration(void *opaque)
goto out;
}
vm_stop(0); /* just in case */
ret = qemu_loadvm_state(f);
if (ret < 0) {
fprintf(stderr, "load of migration failed\n");
@@ -171,8 +170,8 @@ static void tcp_accept_incoming_migration(void *opaque)
/* we've successfully migrated, close the server socket */
qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
close(s);
vm_start();
if (autostart)
vm_start();
out_fopen:
qemu_fclose(f);
+8 -1
View File
@@ -213,12 +213,17 @@ void migrate_fd_put_ready(void *opaque)
dprintf("iterate\n");
if (qemu_savevm_state_iterate(s->file) == 1) {
int state;
int old_vm_running = vm_running;
dprintf("done iterating\n");
vm_stop(0);
qemu_aio_flush();
bdrv_flush_all();
if ((qemu_savevm_state_complete(s->file)) < 0) {
vm_start();
if (old_vm_running) {
vm_start();
}
state = MIG_STATE_ERROR;
} else {
state = MIG_STATE_COMPLETED;
@@ -283,5 +288,7 @@ void migrate_fd_wait_for_unfreeze(void *opaque)
int migrate_fd_close(void *opaque)
{
FdMigrationState *s = opaque;
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
return s->close(s);
}
+1 -1
View File
@@ -1468,7 +1468,7 @@ static int net_socket_listen_init(VLANState *vlan,
}
s->vlan = vlan;
s->model = strdup(model);
s->name = strdup(name);
s->name = name ? strdup(name) : NULL;
s->fd = fd;
qemu_set_fd_handler(fd, net_socket_accept, NULL, s);
return 0;
+1
View File
@@ -68,6 +68,7 @@ struct NICInfo {
const char *model;
const char *name;
VLANState *vlan;
VLANClientState *vc;
void *private;
int used;
};
+4 -3
View File
@@ -24,9 +24,10 @@ typedef int (AioFlushHandler)(void *opaque);
* outstanding AIO operations have been completed or cancelled. */
void qemu_aio_flush(void);
/* Wait for a single AIO completion to occur. This function will until a
* single AIO opeartion has completed. It is intended to be used as a looping
* primative when simulating synchronous IO based on asynchronous IO. */
/* Wait for a single AIO completion to occur. This function will wait
* until a single AIO event has completed and it will ensure something
* has moved before returning. This can issue new pending aio as
* result of executing I/O completion or bh callbacks. */
void qemu_aio_wait(void);
/* Register a file descriptor and associated callbacks. Behaves very similarly
+40 -8
View File
@@ -103,31 +103,46 @@ static int announce_self_create(uint8_t *buf,
/* FIXME: should we send a different packet (arp/rarp/ping)? */
memset(buf, 0, 64);
memset(buf, 0xff, 6); /* h_dst */
memcpy(buf + 6, mac_addr, 6); /* h_src */
memcpy(buf + 12, &proto, 2); /* h_proto */
memcpy(buf + 14, &magic, 4); /* magic */
return 18; /* len */
return 64; /* len */
}
void qemu_announce_self(void)
static void qemu_announce_self_once(void *opaque)
{
int i, j, len;
int i, len;
VLANState *vlan;
VLANClientState *vc;
uint8_t buf[256];
static int count = SELF_ANNOUNCE_ROUNDS;
QEMUTimer *timer = *(QEMUTimer **)opaque;
for (i = 0; i < MAX_NICS; i++) {
if (!nd_table[i].used)
continue;
len = announce_self_create(buf, nd_table[i].macaddr);
vlan = nd_table[i].vlan;
for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
for (j=0; j < SELF_ANNOUNCE_ROUNDS; j++)
vc->fd_read(vc->opaque, buf, len);
for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
vc->fd_read(vc->opaque, buf, len);
}
}
if (count--) {
qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100);
} else {
qemu_del_timer(timer);
qemu_free_timer(timer);
}
}
void qemu_announce_self(void)
{
static QEMUTimer *timer;
timer = qemu_new_timer(rt_clock, qemu_announce_self_once, &timer);
qemu_announce_self_once(&timer);
}
/***********************************************************/
@@ -195,7 +210,14 @@ static int popen_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int s
static int popen_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
{
QEMUFilePopen *s = opaque;
return fread(buf, 1, size, s->popen_file);
FILE *fp = s->popen_file;
int bytes;
do {
clearerr(fp);
bytes = fread(buf, 1, size, fp);
} while ((bytes == 0) && ferror(fp) && (errno == EINTR));
return bytes;
}
static int popen_close(void *opaque)
@@ -224,7 +246,6 @@ QEMUFile *qemu_popen(FILE *popen_file, const char *mode)
} else {
s->file = qemu_fopen_ops(s, popen_put_buffer, NULL, popen_close, NULL);
}
fprintf(stderr, "qemu_popen: returning result of qemu_fopen_ops\n");
return s->file;
}
@@ -240,6 +261,17 @@ QEMUFile *qemu_popen_cmd(const char *command, const char *mode)
return qemu_popen(popen_file, mode);
}
int qemu_popen_fd(QEMUFile *f)
{
QEMUFilePopen *p;
int fd;
p = (QEMUFilePopen *)f->opaque;
fd = fileno(p->popen_file);
return fd;
}
QEMUFile *qemu_fopen_socket(int fd)
{
QEMUFileSocket *s = qemu_mallocz(sizeof(QEMUFileSocket));
+21 -18
View File
@@ -144,32 +144,35 @@ static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
static int check_for_evdev(void)
{
SDL_SysWMinfo info;
XkbDescPtr desc;
XkbDescPtr desc = NULL;
int has_evdev = 0;
const char *keycodes;
char *keycodes = NULL;
SDL_VERSION(&info.version);
if (!SDL_GetWMInfo(&info))
if (!SDL_GetWMInfo(&info)) {
return 0;
}
desc = XkbGetKeyboard(info.info.x11.display,
XkbGBN_AllComponentsMask,
XkbUseCoreKbd);
if (desc == NULL || desc->names == NULL)
return 0;
keycodes = XGetAtomName(info.info.x11.display, desc->names->keycodes);
if (keycodes == NULL)
fprintf(stderr, "could not lookup keycode name\n");
else if (strstart(keycodes, "evdev", NULL))
has_evdev = 1;
else if (!strstart(keycodes, "xfree86", NULL))
fprintf(stderr,
"unknown keycodes `%s', please report to qemu-devel@nongnu.org\n",
keycodes);
XkbFreeClientMap(desc, XkbGBN_AllComponentsMask, True);
if (desc && desc->names) {
keycodes = XGetAtomName(info.info.x11.display, desc->names->keycodes);
if (keycodes == NULL) {
fprintf(stderr, "could not lookup keycode name\n");
} else if (strstart(keycodes, "evdev", NULL)) {
has_evdev = 1;
} else if (!strstart(keycodes, "xfree86", NULL)) {
fprintf(stderr, "unknown keycodes `%s', please report to "
"qemu-devel@nongnu.org\n", keycodes);
}
}
if (desc) {
XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True);
}
if (keycodes) {
XFree(keycodes);
}
return has_evdev;
}
#else
+1
View File
@@ -77,6 +77,7 @@ int tap_win32_init(VLANState *vlan, const char *model,
/* SLIRP */
void do_info_slirp(void);
extern int autostart;
extern int bios_size;
extern int cirrus_vga_enabled;
extern int std_vga_enabled;
+12 -6
View File
@@ -494,17 +494,23 @@ void cpu_reset(CPUX86State *env)
env->tr.flags = DESC_P_MASK | (11 << DESC_TYPE_SHIFT);
cpu_x86_load_seg_cache(env, R_CS, 0xf000, 0xffff0000, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_CS_MASK | DESC_R_MASK);
DESC_P_MASK | DESC_S_MASK | DESC_CS_MASK |
DESC_R_MASK | DESC_A_MASK);
cpu_x86_load_seg_cache(env, R_DS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK);
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
DESC_A_MASK);
cpu_x86_load_seg_cache(env, R_ES, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK);
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
DESC_A_MASK);
cpu_x86_load_seg_cache(env, R_SS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK);
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
DESC_A_MASK);
cpu_x86_load_seg_cache(env, R_FS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK);
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
DESC_A_MASK);
cpu_x86_load_seg_cache(env, R_GS, 0, 0, 0xffff,
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK);
DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
DESC_A_MASK);
env->eip = 0xfff0;
env->regs[R_EDX] = env->cpuid_version;
+3 -3
View File
@@ -201,7 +201,7 @@ ram_addr_t ram_size;
int nb_nics;
NICInfo nd_table[MAX_NICS];
int vm_running;
static int autostart;
int autostart;
static int rtc_utc = 1;
static int rtc_date_offset = -1; /* -1 means no change */
int cirrus_vga_enabled = 1;
@@ -5722,11 +5722,11 @@ int main(int argc, char **argv, char **envp)
do_loadvm(loadvm);
if (incoming) {
autostart = 0; /* fixme how to deal with -daemonize */
autostart = 0;
qemu_start_incoming_migration(incoming);
}
if (autostart)
else if (autostart)
vm_start();
if (daemonize) {
+99 -41
View File
@@ -200,6 +200,8 @@ static void vnc_write_u16(VncState *vs, uint16_t value);
static void vnc_write_u8(VncState *vs, uint8_t value);
static void vnc_flush(VncState *vs);
static void vnc_update_client(void *opaque);
static void vnc_disconnect_start(VncState *vs);
static void vnc_disconnect_finish(VncState *vs);
static void vnc_client_read(void *opaque);
static void vnc_colordepth(VncState *vs);
@@ -633,8 +635,14 @@ static void send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
{
uint8_t *src_row;
uint8_t *dst_row;
int y,pitch,depth;
vnc_update_client(vs);
/* send bitblit op to the vnc client */
vnc_write_u8(vs, 0); /* msg id */
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1); /* number of rects */
@@ -642,18 +650,43 @@ static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, i
vnc_write_u16(vs, src_x);
vnc_write_u16(vs, src_y);
vnc_flush(vs);
/* do bitblit op on the local surface too */
pitch = ds_get_linesize(vs->ds);
depth = ds_get_bytes_per_pixel(vs->ds);
src_row = ds_get_data(vs->ds) + pitch * src_y + depth * src_x;
dst_row = ds_get_data(vs->ds) + pitch * dst_y + depth * dst_x;
if (dst_y > src_y) {
/* copy backwards */
src_row += pitch * (h-1);
dst_row += pitch * (h-1);
pitch = -pitch;
}
for (y = 0; y < h; y++) {
memmove(dst_row, src_row, w * depth);
src_row += pitch;
dst_row += pitch;
}
}
static void vnc_dpy_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
{
VncDisplay *vd = ds->opaque;
VncState *vs = vd->clients;
while (vs != NULL) {
VncState *vs, *vn;
for (vs = vd->clients; vs != NULL; vs = vn) {
vn = vs->next;
if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT)) {
vnc_update_client(vs);
/* vs might be free()ed here */
}
}
for (vs = vd->clients; vs != NULL; vs = vs->next) {
if (vnc_has_feature(vs, VNC_FEATURE_COPYRECT))
vnc_copy(vs, src_x, src_y, dst_x, dst_y, w, h);
else /* TODO */
vnc_update(vs, dst_x, dst_y, w, h);
vs = vs->next;
}
}
@@ -763,6 +796,8 @@ static void vnc_update_client(void *opaque)
if (vs->csock != -1) {
qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock) + VNC_REFRESH_INTERVAL);
} else {
vnc_disconnect_finish(vs);
}
}
@@ -832,6 +867,47 @@ static void audio_del(VncState *vs)
}
}
static void vnc_disconnect_start(VncState *vs)
{
if (vs->csock == -1)
return;
qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL);
closesocket(vs->csock);
vs->csock = -1;
}
static void vnc_disconnect_finish(VncState *vs)
{
qemu_del_timer(vs->timer);
qemu_free_timer(vs->timer);
if (vs->input.buffer) qemu_free(vs->input.buffer);
if (vs->output.buffer) qemu_free(vs->output.buffer);
#ifdef CONFIG_VNC_TLS
if (vs->tls_session) {
gnutls_deinit(vs->tls_session);
vs->tls_session = NULL;
}
#endif /* CONFIG_VNC_TLS */
audio_del(vs);
VncState *p, *parent = NULL;
for (p = vs->vd->clients; p != NULL; p = p->next) {
if (p == vs) {
if (parent)
parent->next = p->next;
else
vs->vd->clients = p->next;
break;
}
parent = p;
}
if (!vs->vd->clients)
dcl->idle = 1;
qemu_free(vs->old_data);
qemu_free(vs);
}
static int vnc_client_io_error(VncState *vs, int ret, int last_errno)
{
if (ret == 0 || ret == -1) {
@@ -849,36 +925,7 @@ static int vnc_client_io_error(VncState *vs, int ret, int last_errno)
}
VNC_DEBUG("Closing down client sock %d %d\n", ret, ret < 0 ? last_errno : 0);
qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL);
closesocket(vs->csock);
qemu_del_timer(vs->timer);
qemu_free_timer(vs->timer);
if (vs->input.buffer) qemu_free(vs->input.buffer);
if (vs->output.buffer) qemu_free(vs->output.buffer);
#ifdef CONFIG_VNC_TLS
if (vs->tls_session) {
gnutls_deinit(vs->tls_session);
vs->tls_session = NULL;
}
#endif /* CONFIG_VNC_TLS */
audio_del(vs);
VncState *p, *parent = NULL;
for (p = vs->vd->clients; p != NULL; p = p->next) {
if (p == vs) {
if (parent)
parent->next = p->next;
else
vs->vd->clients = p->next;
break;
}
parent = p;
}
if (!vs->vd->clients)
dcl->idle = 1;
qemu_free(vs->old_data);
qemu_free(vs);
vnc_disconnect_start(vs);
return 0;
}
@@ -887,7 +934,8 @@ static int vnc_client_io_error(VncState *vs, int ret, int last_errno)
static void vnc_client_error(VncState *vs)
{
vnc_client_io_error(vs, -1, EINVAL);
VNC_DEBUG("Closing down client sock: protocol error\n");
vnc_disconnect_start(vs);
}
static void vnc_client_write(void *opaque)
@@ -947,8 +995,11 @@ static void vnc_client_read(void *opaque)
#endif /* CONFIG_VNC_TLS */
ret = recv(vs->csock, buffer_end(&vs->input), 4096, 0);
ret = vnc_client_io_error(vs, ret, socket_error());
if (!ret)
if (!ret) {
if (vs->csock == -1)
vnc_disconnect_finish(vs);
return;
}
vs->input.offset += ret;
@@ -957,8 +1008,10 @@ static void vnc_client_read(void *opaque)
int ret;
ret = vs->read_handler(vs, vs->input.buffer, len);
if (vs->csock == -1)
if (vs->csock == -1) {
vnc_disconnect_finish(vs);
return;
}
if (!ret) {
memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len));
@@ -973,7 +1026,7 @@ static void vnc_write(VncState *vs, const void *data, size_t len)
{
buffer_reserve(&vs->output, len);
if (buffer_empty(&vs->output)) {
if (vs->csock != -1 && buffer_empty(&vs->output)) {
qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, vnc_client_write, vs);
}
@@ -1014,7 +1067,7 @@ static void vnc_write_u8(VncState *vs, uint8_t value)
static void vnc_flush(VncState *vs)
{
if (vs->output.offset)
if (vs->csock != -1 && vs->output.offset)
vnc_client_write(vs);
}
@@ -2282,11 +2335,13 @@ static void vnc_connect(VncDisplay *vd, int csock)
vnc_read_when(vs, protocol_version, 12);
memset(vs->old_data, 0, ds_get_linesize(vs->ds) * ds_get_height(vs->ds));
memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));
vnc_update_client(vs);
reset_keys(vs);
vs->next = vd->clients;
vd->clients = vs;
vnc_update_client(vs);
/* vs might be free()ed here */
}
static void vnc_listen_read(void *opaque)
@@ -2306,9 +2361,8 @@ static void vnc_listen_read(void *opaque)
void vnc_display_init(DisplayState *ds)
{
VncDisplay *vs;
VncDisplay *vs = qemu_mallocz(sizeof(*vs));
vs = qemu_mallocz(sizeof(VncState));
dcl = qemu_mallocz(sizeof(DisplayChangeListener));
ds->opaque = vs;
@@ -2416,6 +2470,10 @@ int vnc_display_password(DisplayState *ds, const char *password)
{
VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;
if (!vs) {
return -1;
}
if (vs->password) {
qemu_free(vs->password);
vs->password = NULL;