From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alex Bligh <alex@alex.org.uk>
Cc: "Ryan Harper" <ryan.harper@canonical.com>,
"Serge Hallyn" <serge.hallyn@canonical.com>,
"quintela@redhat.com" <quintela@redhat.com>,
Libvirt <libvir-list@redhat.com>,
"Serge Hallyn" <serge.hallyn@ubuntu.com>,
qemu-devel@nongnu.org, "Alexander Graf" <agraf@suse.de>,
"Cole Robinson" <crobinso@redhat.com>,
"Amit Shah" <amit.shah@redhat.com>,
"Bruce Rogers" <brogers@suse.com>,
"Andreas Färber" <afaerber@suse.de>,
"Serge E. Hallyn" <serge@hallyn.com>
Subject: Re: [Qemu-devel] [PATCH v3 1/2] Add machine type pc-1.0-qemu-kvm for live migrate compatibility with qemu-kvm
Date: Mon, 22 Sep 2014 14:50:39 +0300 [thread overview]
Message-ID: <20140922115039.GJ14882@redhat.com> (raw)
In-Reply-To: <1411310339-27733-2-git-send-email-alex@alex.org.uk>
On Sun, Sep 21, 2014 at 03:38:58PM +0100, Alex Bligh wrote:
> Add a machine type pc-1.0-qemu-kvm for live migrate compatibility
> with qemu-kvm version 1.0.
>
> Signed-off-by: Alex Bligh <alex@alex.org.uk>
> ---
> hw/acpi/piix4.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
> hw/i386/pc_piix.c | 30 ++++++++++++++++++++++++++++++
> hw/timer/i8254_common.c | 10 +++++++++-
> 3 files changed, 84 insertions(+), 3 deletions(-)
>
> diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> index b72b34e..e016005 100644
> --- a/hw/acpi/piix4.c
> +++ b/hw/acpi/piix4.c
> @@ -37,6 +37,8 @@
> #include "hw/acpi/memory_hotplug.h"
> #include "hw/acpi/acpi_dev_interface.h"
>
> +extern int qemu_kvm_1_0_compat;
> +
> //#define DEBUG
>
> #ifdef DEBUG
Please dont' put extern declarations in C files.
You lose a useful type-safety compile-time check.
> @@ -200,12 +202,24 @@ static const VMStateDescription vmstate_pci_status = {
> }
> };
>
> +static const VMStateDescription vmstate_acpi_compat;
> +
Don't declare things like this, re-order them in a separate patch so forward
declarations are not necessary.
> static int acpi_load_old(QEMUFile *f, void *opaque, int version_id)
> {
> PIIX4PMState *s = opaque;
> int ret, i;
> uint16_t temp;
>
> + /* If we are expecting the inbound migration to come from
> + * qemu-kvm 1.0, it will have a version_id of 2 but really
> + * be version 3, so call back the original vmstate_load_state
> + * with a different more tolerant vmstate descriptor
> + */
> + if ((version_id == 2) && (qemu_kvm_1_0_compat)) {
> + return vmstate_load_state(f, &vmstate_acpi_compat,
> + opaque, version_id);
> + }
> +
> ret = pci_device_load(PCI_DEVICE(s), f);
> if (ret < 0) {
> return ret;
> @@ -267,8 +281,9 @@ static const VMStateDescription vmstate_memhp_state = {
> };
>
> /* qemu-kvm 1.2 uses version 3 but advertised as 2
> - * To support incoming qemu-kvm 1.2 migration, change version_id
> - * and minimum_version_id to 2 below (which breaks migration from
> + * To support incoming qemu-kvm 1.2 migration, we support
> + * via a command line option a change to minimum_version_id
> + * of 2 in a _compat structure (which breaks migration from
> * qemu 1.2).
> *
> */
> @@ -307,6 +322,34 @@ static const VMStateDescription vmstate_acpi = {
> }
> };
>
> +static const VMStateDescription vmstate_acpi_compat = {
> + .name = "piix4_pm",
> + .version_id = 3,
> + .minimum_version_id = 2,
> + .minimum_version_id_old = 1,
> + .load_state_old = NULL, /* to avoid recursion */
> + .post_load = vmstate_acpi_post_load,
> + .fields = (VMStateField[]) {
> + VMSTATE_PCI_DEVICE(parent_obj, PIIX4PMState),
> + VMSTATE_UINT16(ar.pm1.evt.sts, PIIX4PMState),
> + VMSTATE_UINT16(ar.pm1.evt.en, PIIX4PMState),
> + VMSTATE_UINT16(ar.pm1.cnt.cnt, PIIX4PMState),
> + VMSTATE_STRUCT(apm, PIIX4PMState, 0, vmstate_apm, APMState),
> + VMSTATE_TIMER(ar.tmr.timer, PIIX4PMState),
> + VMSTATE_INT64(ar.tmr.overflow_time, PIIX4PMState),
> + VMSTATE_STRUCT(ar.gpe, PIIX4PMState, 2, vmstate_gpe, ACPIGPE),
> + VMSTATE_STRUCT_TEST(
> + acpi_pci_hotplug.acpi_pcihp_pci_status[ACPI_PCIHP_BSEL_DEFAULT],
> + PIIX4PMState,
> + vmstate_test_no_use_acpi_pci_hotplug,
> + 2, vmstate_pci_status,
> + struct AcpiPciHpPciStatus),
> + VMSTATE_PCI_HOTPLUG(acpi_pci_hotplug, PIIX4PMState,
> + vmstate_test_use_acpi_pci_hotplug),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> static void piix4_reset(void *opaque)
> {
> PIIX4PMState *s = opaque;
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 7081c08..48a4942 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -70,6 +70,8 @@ static bool smbios_legacy_mode;
> static bool gigabyte_align = true;
> static bool has_reserved_memory = true;
>
> +int qemu_kvm_1_0_compat;
> +
> /* PC hardware initialisation */
> static void pc_init1(MachineState *machine,
> int pci_enabled,
> @@ -386,6 +388,14 @@ static void pc_init_pci_1_2(MachineState *machine)
> pc_init_pci(machine);
> }
>
> +/* PC machine init function for qemu-kvm 1.0 */
> +static void pc_init_pci_1_2_qemu_kvm(MachineState *machine)
> +{
> + qemu_kvm_1_0_compat = 1;
> + pc_compat_1_2(machine);
> + pc_init_pci(machine);
> +}
> +
> /* PC init function for pc-0.10 to pc-0.13 */
> static void pc_init_pci_no_kvmclock(MachineState *machine)
> {
> @@ -644,6 +654,25 @@ static QEMUMachine pc_machine_v1_0 = {
> .hw_version = "1.0",
> };
>
> +#define PC_COMPAT_1_0_QEMU_KVM \
> + PC_COMPAT_1_0,\
> + {\
> + .driver = "cirrus-vga",\
> + .property = "vgamem_mb",\
> + .value = stringify(16),\
> + }
> +
> +static QEMUMachine pc_machine_v1_0_qemu_kvm = {
> + PC_I440FX_1_2_MACHINE_OPTIONS,
> + .name = "pc-1.0-qemu-kvm",
I think pc-qemu-kvm-1.0 is slightly better - more consistent with
other machine names.
> + .init = pc_init_pci_1_2_qemu_kvm,
> + .compat_props = (GlobalProperty[]) {
> + PC_COMPAT_1_0_QEMU_KVM,
> + { /* end of list */ }
> + },
> + .hw_version = "1.0",
> +};
> +
> #define PC_COMPAT_0_15 \
> PC_COMPAT_1_0
>
> @@ -886,6 +915,7 @@ static void pc_machine_init(void)
> qemu_register_pc_machine(&pc_machine_v1_2);
> qemu_register_pc_machine(&pc_machine_v1_1);
> qemu_register_pc_machine(&pc_machine_v1_0);
> + qemu_register_pc_machine(&pc_machine_v1_0_qemu_kvm);
> qemu_register_pc_machine(&pc_machine_v0_15);
> qemu_register_pc_machine(&pc_machine_v0_14);
> qemu_register_pc_machine(&pc_machine_v0_13);
> diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
> index 07345f6..b4deead 100644
> --- a/hw/timer/i8254_common.c
> +++ b/hw/timer/i8254_common.c
> @@ -29,6 +29,8 @@
> #include "hw/timer/i8254.h"
> #include "hw/timer/i8254_internal.h"
>
> +extern int qemu_kvm_1_0_compat;
> +
> /* val must be 0 or 1 */
> void pit_set_gate(ISADevice *dev, int channel, int val)
> {
Can you add a device property like we do for
other compat behaviours?
That's better than a global variable.
Same for other devices.
> @@ -257,6 +259,11 @@ static int pit_dispatch_post_load(void *opaque, int version_id)
> return 0;
> }
>
> +static bool has_irq_disabled(void *opaque, int version_id)
> +{
> + return (version_id >= 3) || ((version_id == 2) && qemu_kvm_1_0_compat);
> +}
> +
> static const VMStateDescription vmstate_pit_common = {
> .name = "i8254",
> .version_id = 3,
> @@ -266,7 +273,8 @@ static const VMStateDescription vmstate_pit_common = {
> .pre_save = pit_dispatch_pre_save,
> .post_load = pit_dispatch_post_load,
> .fields = (VMStateField[]) {
> - VMSTATE_UINT32_V(channels[0].irq_disabled, PITCommonState, 3),
> + VMSTATE_UINT32_TEST(channels[0].irq_disabled, PITCommonState,
> + has_irq_disabled),
> VMSTATE_STRUCT_ARRAY(channels, PITCommonState, 3, 2,
> vmstate_pit_channel, PITChannelState),
> VMSTATE_INT64(channels[0].next_transition_time,
> --
> 1.7.9.5
next prev parent reply other threads:[~2014-09-22 11:47 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-21 14:38 [Qemu-devel] [PATCH v3 0/2] Add machine type pc-1.0-qemu-kvm for live migrate compatibility with qemu-kvm Alex Bligh
2014-09-21 14:38 ` [Qemu-devel] [PATCH v3 1/2] " Alex Bligh
2014-09-22 11:50 ` Michael S. Tsirkin [this message]
2014-09-22 12:28 ` Alex Bligh
2014-09-22 12:38 ` Michael S. Tsirkin
2014-09-21 14:38 ` [Qemu-devel] [PATCH v3 2/2] Add configure option --enable-pc-1-0-qemu-kvm Alex Bligh
2014-09-22 11:36 ` Michael S. Tsirkin
2014-09-22 11:42 ` [Qemu-devel] [libvirt] " Daniel P. Berrange
2014-09-22 11:53 ` Michael S. Tsirkin
2014-09-22 15:24 ` Markus Armbruster
2014-09-22 15:36 ` Michael S. Tsirkin
2014-09-22 15:47 ` Serge Hallyn
2014-09-22 15:44 ` Paolo Bonzini
2014-09-22 17:30 ` Alex Bligh
2014-09-22 19:10 ` Paolo Bonzini
2014-09-22 19:36 ` Alex Bligh
2014-09-23 0:12 ` Serge Hallyn
2014-09-22 11:50 ` [Qemu-devel] " Alex Bligh
2014-09-22 12:10 ` Michael S. Tsirkin
2014-09-22 13:05 ` Alex Bligh
2014-09-22 15:45 ` Andreas Färber
2014-09-22 16:54 ` Alex Bligh
2014-09-22 17:26 ` Markus Armbruster
2014-09-23 3:46 ` Michael S. Tsirkin
2014-09-23 3:44 ` Michael S. Tsirkin
2014-09-22 15:32 ` Markus Armbruster
2014-09-22 17:21 ` Michael S. Tsirkin
2014-09-23 7:59 ` Markus Armbruster
2014-09-23 8:24 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140922115039.GJ14882@redhat.com \
--to=mst@redhat.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=alex@alex.org.uk \
--cc=amit.shah@redhat.com \
--cc=brogers@suse.com \
--cc=crobinso@redhat.com \
--cc=libvir-list@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=ryan.harper@canonical.com \
--cc=serge.hallyn@canonical.com \
--cc=serge.hallyn@ubuntu.com \
--cc=serge@hallyn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).