Commit Graph

16815 Commits

Author SHA1 Message Date
Juan Quintela 7073693bfb migration: Export a function that tells if the migration has finished correctly
This will allow us to hide the state values.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:54 +02:00
Juan Quintela e0eb7390b0 migration: Pass MigrationState in migration notifiers
Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:54 +02:00
Juan Quintela d0ae46c197 migration: Use bandwidth_limit directly
Now that current_migration always exist, there is no reason for
max_throotle variable.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:54 +02:00
Juan Quintela 17549e84e0 migration: create accessor for current_migration
Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:54 +02:00
Juan Quintela cab3014333 migration: Move exported functions to the end of the file
This means we can remove the two forward declarations.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:54 +02:00
Juan Quintela 767de72258 migration: Remove migration cancel() callback
It is used only in one place

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:54 +02:00
Juan Quintela 48a2f4d6c5 migration: Remove get_status() accessor
It is only used inside migration.c, and fields on that struct are
accessed all around the place on that file.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:54 +02:00
Juan Quintela 92920cd782 migration: Our release callback was just free
We called it from a single place, and always with state !=
MIG_STATE_ACTIVE.  Just remove the whole callback.  For users of the
notifier, notice that this is exactly the case where they don't care,
we are just freeing the state from previous failed migration (it can't
be a sucessful one, otherwise we would not be running on that machine
in the first place).

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:53 +02:00
Juan Quintela 458cf28e6b migration: Introduce migrate_fd_completed() for consistency
This function is a bit different of the others that change the state,
in the sense that if migrate_fd_cleanup() returns an error, it set the
status to error, not completed.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:53 +02:00
Juan Quintela 67afff7911 migration: Refactor and simplify error checking in migrate_fd_put_ready
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:53 +02:00
Juan Quintela d5934dde1c migration: Introduce MIG_STATE_SETUP
Use MIG_STATE_ACTIVE only when migration has really started.  Use this
new state to setup migration parameters.  Change defines for an
anonymous struct.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:53 +02:00
Juan Quintela 07af445291 migration: move migrate_new to do_migrate
Once there, remove all parameters that don't need to be passed to
*start_outgoing_migration() functions

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:53 +02:00
Juan Quintela 8b6b99b356 migration: Make all posible migration functions static
I have to move two functions postions to avoid forward declarations

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:53 +02:00
Juan Quintela 0edda1c42a migration: Refactor MigrationState creation
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:53 +02:00
Juan Quintela 22f00a4445 migration: Rename FdMigrationState MigrationState
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:53 +02:00
Juan Quintela 3f77fc557e migration: Fold MigrationState into FdMigrationState
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:53 +02:00
Juan Quintela dc7acc61b6 migration: Use FdMigrationState instead of MigrationState when possible
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:52 +02:00
Juan Quintela 7be4363a28 migration: Make *start_outgoing_migration return FdMigrationState
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:52 +02:00
Juan Quintela 2975725f6b migration: make *save_live return errors
Make *save_live() return negative values when there is one error, and
updates all callers to check for the error.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:52 +02:00
Juan Quintela 42802d47dd migration: use qemu_file_get_error() return value when possible
Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:52 +02:00
Juan Quintela 3961b4dd0e savevm: Rename has_error to last_error field
Now the field contains the last error name, so rename acordingly.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:52 +02:00
Juan Quintela 624b9cc209 migration: rename qemu_file_has_error to qemu_file_get_error
Now the function returned errno, so it is better the new name.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:52 +02:00
Juan Quintela 3934638539 migration: return real error code
make functions propagate errno, instead of just using -EIO.  Add a
comment about what are the return value of qemu_savevm_state_iterate().

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:52 +02:00
Juan Quintela dcd1d224df migration: change has_error to contain errno values
We normally already have an errno value.  When not, abuse EIO.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:52 +02:00
Juan Quintela af50945081 migration: set error if select return one error
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:51 +02:00
Juan Quintela fdbecb5d0e migration: don't "write" when migration is not active
If migration is not active, just ignore writes.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:51 +02:00
Juan Quintela eff28a5c3b buffered_file: reuse QEMUFile has_error field
Instead of having two has_error fields in QEMUFile & QEMUBufferedFile,
reuse the 1st one.  Notice that the one in buffered_file is only set
after a file operation.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:51 +02:00
Juan Quintela db448a088c buffered_file: Use right "opaque"
buffered_close 's' variable is of type QEMUFileBuffered, and
wait_for_unfreeze() expect to receive a MigrationState, that
'coincidentaly' is s->opaque.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:51 +02:00
Juan Quintela 4fc7d8195f migration: If there is one error, it makes no sense to continue
Once there, add a comment about what each error mean.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:51 +02:00
Yoshiaki Tamura 2350e13c93 migration: add error handling to migrate_fd_put_notify().
Although migrate_fd_put_buffer() sets MIG_STATE_ERROR if it failed,
since migrate_fd_put_notify() isn't checking error of underlying
QEMUFile, those resources are kept open.  This patch checks it and
calls migrate_fd_error() in case of error.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:51 +02:00
Juan Quintela e649406169 migration: Check that migration is active before cancel it
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:51 +02:00
Juan Quintela c0b2ba46c5 migration: simplify state assignmente
Once there, make sure that if we already know that there is one error,
just call migration_fd_cleanup() with the ERROR state.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:51 +02:00
Juan Quintela 3a230256e8 ds1225y: Use stdio instead of QEMUFile
QEMUFile * is only intended for migration nowadays.  Using it for
anything else just adds pain and a layer of buffers for no good
reason.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:51 +02:00
Juan Quintela 3da9eebda9 Revert "savevm: fix corruption in vmstate_subsection_load()."
This reverts commit eb60260de0.

Conflicts:

	savevm.c

We changed qemu_peek_byte() prototype, just fixed the rejects.

Signed-off-by: Juan Quintela<quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:11 +02:00
Juan Quintela c63807244f savevm: improve subsections detection on load
We add qemu_peek_buffer, that is identical to qemu_get_buffer, just
that it don't update f->buf_index.

We add a paramenter to qemu_peek_byte() to be able to peek more than
one byte.

Once this is done, to see if we have a subsection we look:
- 1st byte is QEMU_VM_SUBSECTION
- 2nd byte is a length, and is bigger than section name
- 3rd element is a string that starts with section_name

So, we shouldn't have false positives (yes, content could still get us
wrong but probabilities are really low).

v2:
- Alex Williamsom found that we could get negative values on index.
- Rework code to fix that part.
- Rewrite qemu_get_buffer() using qemu_peek_buffer()

v3:
- return "done" on error case

v4:
- fix qemu_file_skip() off by one.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20 13:23:11 +02:00
Juan Quintela 65f3bb3da3 savevm: define qemu_get_byte() using qemu_peek_byte()
Signed-off-by: Juan Quintela<quintela@redhat.com>
2011-10-20 13:23:11 +02:00
Juan Quintela b9ce1454e1 savevm: some coding style cleanups
This patch will make moving code on next patches and having checkpatch
happy easier.

Signed-off-by: Juan Quintela<quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:11 +02:00
Juan Quintela 0046c45bc1 savevm: teach qemu_fill_buffer to do partial refills
We will need on next patch to be able to lookahead on next patch

v2: rename "used" to "pending" (Alex Williams)

Signed-off-by: Juan Quintela<quintela@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20 13:23:11 +02:00
Jan Kiszka cfce6d8934 i8259: Move to hw library
No target-specific bits remaining, let's move it over.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:56 +00:00
Jan Kiszka 661f1929d0 monitor: Restrict pic/irq_info to supporting targets
This allows to drop various stubs and move the i8359 into hwlib.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:55 +00:00
Jan Kiszka 81a02f93ba i8259: Fix coding style
No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:55 +00:00
Jan Kiszka 747c70af78 i8259: Convert to qdev
This key cleanup step requires to move the IRQ debugging bit from
i8259_set_irq directly to the per-PIC pic_set_irq, to pass the PIC
parameters (I/O base, ELCR address and mask, master/slave mode) as
qdev properties, and to interconnect the PICs with their environment via
GPIO pins.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:53 +00:00
Jan Kiszka 6835678c25 qdev: Add HEX8 property
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:51 +00:00
Jan Kiszka c17725f473 i8259: Eliminate PicState2
Introduce a reference to the slave PIC for the few cases we need to
access it without a proper pointer at hand and drop PicState2. We could
even live without slave_pic if we had a better way of modeling the
cascade bus the PICs are attached to (in addition to the ISA bus).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:13 +00:00
Jan Kiszka 2598539642 i8259: Replace PicState::pics_state with master flag
This reflects how real PICs indentify their role (in non-buffered mode):
Pass the state of the /SP input on pic_init and use it instead of
pics_state to differentiate between master and slave mode.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:12 +00:00
Jan Kiszka 6e5580ca2b i8259: PREP: Replace pic_intack_read with pic_read_irq
There is nothing in the i8259 spec that justifies the special
pic_intack_read. At least the Linux PREP kernels configure the PICs
properly so that pic_read_irq returns identical values, and setting
read_reg_select in PIC0 cannot be derived from any special i8259 mode.

So switch ppc_prep to pic_read_irq and drop the now unused PIC code.

CC: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:10 +00:00
Jan Kiszka fc1a5e0a24 i8259: Clean up pic_ioport_read
Drop redundant local address variable.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:09 +00:00
Jan Kiszka 8d484caa84 i8259: Fix poll command
This was probably never used so far: According to the spec, polling
means ack'ing the pending IRQ and setting its corresponding bit in isr.
Moreover, we have to signal a pending IRQ via bit 7 of the returned
value, and we must not return a spurious IRQ if none is pending.

This implements the poll command without the help of pic_poll_read which
is left untouched as pic_intack_read is still using it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:08 +00:00
Jan Kiszka b76750c1ab i8259: Switch to per-PIC IRQ update
This converts pic_update_irq to work against a single PIC instead of the
complete cascade. Along this change, the required update after
pic_set_irq1 is now moved into that function.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:07 +00:00
Jan Kiszka 86fbf97ceb i8259: Clear ELCR on reset
The ELCR is actually part of the chipset but we model it here for
simplicity reasons. The PIIX3 clears the ELCR on reset, which was once
broken by 4dbe19e181. Fix this by splitting up pic_init_reset from
pic_reset and clearing the register in the latter.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:06 +00:00