Add machine type pc-1.0-qemu-kvm for live migrate compatibility with qemu-kvm
v2 cover Add machine type pc-1.0-qemu-kvm for live migrate compatibility with qemu-kvm
This patch series adds inbound migrate capability from qemu-kvm version 1.0. The main ideas are those set out in Cole Robinson's patch here:
http://pkgs.fedoraproject.org/cgit/qemu.git/tree/0001-Fix-migration-from-qemu-kvm.patch?h=f20
however, rather than patching statically (and breaking inbound migration on existing machine types), I have added a new machine type (pc-1.0-qemu-kvm) without affecting any other machine types. The existing pc-1.0 machine type is renamed to pc-1.0-qemu-git, with pc-1.0 becoming an alias for one or another, as selected by a configure option (defaulting to pc-1.0-qemu-git, IE no change).
This requires 'hot patching' the VMStateDescription in a couple of places, which in turn is less than obvious as there may be (indeed are for i8259) derived classes. Whilst pretty nausea-inducing, this approach has the benefit of being entirely self-contained.
I developed this on qemu 2.0 but have forward ported it (trivially) to master. My testing has been on a VM live-migrated-to-file from Ubuntu Precise qemu-kvm 1.0.
I have given this a moderate degree of testing but it could do with more.
Note that certain hardware devices (including QXL) will not migrate properly due to a fundamental difference in their internal state between versions.
Also note that (as expected) migratino from qemu-2.x to qemu-1.0 will not work, even if the machine types are the same.
Alex Bligh (2):
Add machine type pc-1.0-qemu-kvm for live migrate compatibility with
qemu-kvm
Add configure option --enable-pc-1-0-qemu-kvm
configure | 12 ++++++++++++ hw/acpi/piix4.c | 49 ++++++++++++++++++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 39 +++++++++++++++++++++++++++++++++++- hw/timer/i8254_common.c | 41 ++++++++++++++++++++++++++++++++++++++ include/hw/acpi/piix4.h | 1 + include/hw/timer/i8254.h | 2 ++ 6 files changed, 141 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/2 Add machine type pc-1.0-qemu-kvm for live migrate compatibility with qemu-kvm
Add a machine type pc-1.0-qemu-kvm for live migrate compatibility with qemu-kvm version 1.0.
--- hw/acpi/piix4.c | 49 ++++++++++++++++++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 31 +++++++++++++++++++++++++++++ hw/timer/i8254_common.c | 41 ++++++++++++++++++++++++++++++++++++++ include/hw/acpi/piix4.h | 1 + include/hw/timer/i8254.h | 2 ++ 5 files changed, 122 insertions(+), 2 deletions(-)
hw/acpi/piix4.c +47 -2
@@ -267,8 +267,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 +308,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 = acpi_load_old, + .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;
@@ -619,6 +648,22 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) adevc->ospm_status = piix4_ospm_status; } +void piix4_pm_class_fix_compat (void ) +{ +GSList *el, *devices =object_class_get_list (TYPE_DEVICE , false); +/* +* Change the vmstate field in this class and any derived classes +* if not overriden. As no other classes should be using this +* vmstate, we can simply iterate the class list +*/ +for (el = devices; el; el = el->next) { +DeviceClass *dc = el->data; +if (dc->vmsd == &vmstate_acpi) { + dc->vmsd = &vmstate_acpi_compat; + } + } +} +static const TypeInfo piix4_pm_info = { .name =TYPE_PIIX4_PM , .parent =TYPE_PCI_DEVICE ,
hw/i386/pc_piix.c +31 -0
@@ -49,6 +49,8 @@#include "hw/acpi/acpi.h" #include "cpu.h" #include "qemu/error-report.h" +#include "hw/acpi/piix4.h" +#include "hw/timer/i8254.h" #ifdef CONFIG_XEN # include <xen/hvm/hvm_info_table.h> #endif
@@ -386,6 +388,15 @@ 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) +{ +piix4_pm_class_fix_compat (); +pit_common_class_fix_compat (); +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 +655,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" , + .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 +916,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);
hw/timer/i8254_common.c +41 -0
53 lines not on this page · raw message
include/hw/acpi/piix4.h +1 -0
@@ -4,5 +4,6 @@#include "qemu/typedefs.h" Object *piix4_pm_find (void ); +void piix4_pm_class_fix_compat (void );#endif
include/hw/timer/i8254.h +2 -0
@@ -72,4 +72,6 @@ static inline ISADevice *kvm_pit_init(ISABus *bus, int base)void pit_set_gate (ISADevice *dev,int channel,int val);void pit_get_channel_info (ISADevice *dev,int channel,PITChannelInfo *info); +void pit_common_class_fix_compat (void ); +#endif /* !HW_I8254_H */
Signature · 1 line
1.7.9.5
PATCH v2 2/2 Add configure option --enable-pc-1-0-qemu-kvm
In reply to Alex BlighAdd a configure option --enable-pc-1-0-qemu-kvm and the corresponding --disable-pc-1-0-qemu-kvm, defaulting to disabled.
Rename machine type pc-1.0 to pc-1.0-qemu-git.
Make pc-1.0 machine type an alias of either pc-1.0-qemu-kvm or pc-1.0-qemu-git depending on the value of the config option.
--- configure | 12 ++++++++++++ hw/i386/pc_piix.c | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
configure +12 -0
@@ -335,6 +335,7 @@ libssh2="" vhdx="" quorum="" numa="" +pc_1_0_qemu_kvm="no" # parse CC options first for opt do
@@ -1125,6 +1126,10 @@ for opt do ;; --enable-numa) numa="yes" ;; + --disable-pc-1-0-qemu-kvm) pc_1_0_qemu_kvm="no" + ;; + --enable-pc-1-0-qemu-kvm) pc_1_0_qemu_kvm="yes" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information"
@@ -1394,6 +1399,8 @@ Advanced options (experts only): --enable-quorum enable quorum block filter support --disable-numa disable libnuma support --enable-numa enable libnuma support + --disable-pc-1-0-qemu-kvm disable pc-1.0 machine type reflecting qemu-kvm + --enable-pc-1-0-qemu-kvm enable pc-1.0 machine type reflecting qemu-kvm NOTE: The object files are built at the place where configure is launched EOF
@@ -4262,6 +4269,7 @@ echo "Quorum $quorum" echo "lzo support $lzo" echo "snappy support $snappy" echo "NUMA host support $numa" +echo "pc-1.0 qemu-kvm $pc_1_0_qemu_kvm" if test "$sdl_too_old" = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -5241,6 +5249,10 @@ if test "$numa" = "yes"; then echo "CONFIG_NUMA=y" >> $config_host_mak fi +if test "$pc_1_0_qemu_kvm" = "yes"; then + echo "CONFIG_PC_1_0_QEMU_KVM=y" >> $config_host_mak +fi + # build tree in object directory in case the source is not in the current directory DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests" DIRS="$DIRS fsdev"
hw/i386/pc_piix.c +7 -1
@@ -647,7 +647,10 @@ static QEMUMachine pc_machine_v1_1 = {static QEMUMachine pc_machine_v1_0 = {PC_I440FX_1_2_MACHINE_OPTIONS , - .name ="pc-1.0" , + .name ="pc-1.0-qemu-git" , +#ifndef CONFIG_PC_1_0_QEMU_KVM + .alias ="pc-1.0" , +#endif .compat_props = (GlobalProperty []) {PC_COMPAT_1_0 , {/* end of list */ }
@@ -666,6 +669,9 @@ static QEMUMachine pc_machine_v1_0 = {static QEMUMachine pc_machine_v1_0_qemu_kvm = {PC_I440FX_1_2_MACHINE_OPTIONS , .name ="pc-1.0-qemu-kvm" , +#ifdef CONFIG_PC_1_0_QEMU_KVM + .alias ="pc-1.0" , +#endif .init = pc_init_pci_1_2_qemu_kvm, .compat_props = (GlobalProperty []) {PC_COMPAT_1_0_QEMU_KVM ,
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v2 2/2] Add configure option --enable-pc-1-0-qemu-kvm
Quoted 11 lines · Alex Bligh
Add a configure option --enable-pc-1-0-qemu-kvm and the corresponding --disable-pc-1-0-qemu-kvm, defaulting to disabled.
Rename machine type pc-1.0 to pc-1.0-qemu-git.
Make pc-1.0 machine type an alias of either pc-1.0-qemu-kvm or pc-1.0-qemu-git depending on the value of the config option.
Signed-off-by Alex Bligh <[email protected]>
Nah that's too messy.
qemu-kvm should have used a different machine type, it didn't but we should not perpetuate this mistake. Please add a work around for this in management.
Quoted 84 lines
--- configure | 12 ++++++++++++ hw/i386/pc_piix.c | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-)configure +12
-0@@ -335,6 +335,7 @@ libssh2="" vhdx="" quorum="" numa="" +pc_1_0_qemu_kvm="no" # parse CC options first for opt do@@ -1125,6 +1126,10 @@ for opt do ;; --enable-numa) numa="yes" ;; + --disable-pc-1-0-qemu-kvm) pc_1_0_qemu_kvm="no" + ;; + --enable-pc-1-0-qemu-kvm) pc_1_0_qemu_kvm="yes" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information"@@ -1394,6 +1399,8 @@ Advanced options (experts only): --enable-quorum enable quorum block filter support --disable-numa disable libnuma support --enable-numa enable libnuma support + --disable-pc-1-0-qemu-kvm disable pc-1.0 machine type reflecting qemu-kvm + --enable-pc-1-0-qemu-kvm enable pc-1.0 machine type reflecting qemu-kvm NOTE: The object files are built at the place where configure is launched EOF@@ -4262,6 +4269,7 @@ echo "Quorum $quorum" echo "lzo support $lzo" echo "snappy support $snappy" echo "NUMA host support $numa" +echo "pc-1.0 qemu-kvm $pc_1_0_qemu_kvm" if test "$sdl_too_old" = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support"@@ -5241,6 +5249,10 @@ if test "$numa" = "yes"; then echo "CONFIG_NUMA=y" >> $config_host_mak fi +if test "$pc_1_0_qemu_kvm" = "yes"; then + echo "CONFIG_PC_1_0_QEMU_KVM=y" >> $config_host_mak +fi + # build tree in object directory in case the source is not in the current directory DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests" DIRS="$DIRS fsdev"hw/i386/pc_piix.c +7
-1@@ -647,7 +647,10 @@ static QEMUMachine pc_machine_v1_1 = {static QEMUMachine pc_machine_v1_0 = {PC_I440FX_1_2_MACHINE_OPTIONS , - .name ="pc-1.0" , + .name ="pc-1.0-qemu-git" , +#ifndef CONFIG_PC_1_0_QEMU_KVM + .alias ="pc-1.0" , +#endif .compat_props = (GlobalProperty []) {PC_COMPAT_1_0 , {/* end of list */ }@@ -666,6 +669,9 @@ static QEMUMachine pc_machine_v1_0 = {static QEMUMachine pc_machine_v1_0_qemu_kvm = {PC_I440FX_1_2_MACHINE_OPTIONS , .name ="pc-1.0-qemu-kvm" , +#ifdef CONFIG_PC_1_0_QEMU_KVM + .alias ="pc-1.0" , +#endif .init = pc_init_pci_1_2_qemu_kvm, .compat_props = (GlobalProperty []) {PC_COMPAT_1_0_QEMU_KVM ,Signature · 1 line
1.7.9.5
Quoted 11 lines · Alex Bligh
This patch series adds inbound migrate capability from qemu-kvm version 1.0. The main ideas are those set out in Cole Robinson's patch here:
http://pkgs.fedoraproject.org/cgit/qemu.git/tree/0001-Fix-migration-from-qemu-kvm.patch?h=f20
however, rather than patching statically (and breaking inbound migration on existing machine types), I have added a new machine type (pc-1.0-qemu-kvm) without affecting any other machine types. The existing pc-1.0 machine type is renamed to pc-1.0-qemu-git, with pc-1.0 becoming an alias for one or another, as selected by a configure option (defaulting to pc-1.0-qemu-git, IE no change).
Quoted 4 lines
This requires 'hot patching' the VMStateDescription in a couple of places, which in turn is less than obvious as there may be (indeed are for i8259) derived classes. Whilst pretty nausea-inducing, this approach has the benefit of being entirely self-contained.
Ow come on.
Just add a flag and select the appropriate format based on it, using field_exists.
Quoted 29 lines
I developed this on qemu 2.0 but have forward ported it (trivially) to master. My testing has been on a VM live-migrated-to-file from Ubuntu Precise qemu-kvm 1.0.
I have given this a moderate degree of testing but it could do with more.
Note that certain hardware devices (including QXL) will not migrate properly due to a fundamental difference in their internal state between versions.
Also note that (as expected) migratino from qemu-2.x to qemu-1.0 will not work, even if the machine types are the same.
Alex Bligh (2):
Add machine type pc-1.0-qemu-kvm for live migrate compatibility with
qemu-kvm
Add configure option --enable-pc-1-0-qemu-kvmconfigure | 12 ++++++++++++ hw/acpi/piix4.c | 49 ++++++++++++++++++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 39 +++++++++++++++++++++++++++++++++++- hw/timer/i8254_common.c | 41 ++++++++++++++++++++++++++++++++++++++ include/hw/acpi/piix4.h | 1 + include/hw/timer/i8254.h | 2 ++ 6 files changed, 141 insertions(+), 3 deletions(-)Signature · 1 line
1.7.9.5
Quoted 12 lines · Michael S. Tsirkin
Quoted 11 lines · Alex Bligh
This patch series adds inbound migrate capability from qemu-kvm version 1.0. The main ideas are those set out in Cole Robinson's patch here:
http://pkgs.fedoraproject.org/cgit/qemu.git/tree/0001-Fix-migration-from-qemu-kvm.patch?h=f20
however, rather than patching statically (and breaking inbound migration on existing machine types), I have added a new machine type (pc-1.0-qemu-kvm) without affecting any other machine types. The existing pc-1.0 machine type is renamed to pc-1.0-qemu-git, with pc-1.0 becoming an alias for one or another, as selected by a configure option (defaulting to pc-1.0-qemu-git, IE no change).
Quoted 8 lines
Quoted 4 lines
This requires 'hot patching' the VMStateDescription in a couple of places, which in turn is less than obvious as there may be (indeed are for i8259) derived classes. Whilst pretty nausea-inducing, this approach has the benefit of being entirely self-contained.
Ow come on.
Just add a flag and select the appropriate format based on it, usingfield_exists.
I don't think it is that simple. All those things are initialised well before the command line is parsed.
Unless I'm missing what you are saying?
Signature · 1 line
Alex Bligh
Quoted 20 lines · Alex Bligh
Quoted 17 lines · Michael S. Tsirkin
Quoted 15 lines · Alex Bligh
This patch series adds inbound migrate capability from qemu-kvm version 1.0. The main ideas are those set out in Cole Robinson's patch here:
http://pkgs.fedoraproject.org/cgit/qemu.git/tree/0001-Fix-migration-from-qemu-kvm.patch?h=f20
however, rather than patching statically (and breaking inbound migration on existing machine types), I have added a new machine type (pc-1.0-qemu-kvm) without affecting any other machine types. The existing pc-1.0 machine type is renamed to pc-1.0-qemu-git, with pc-1.0 becoming an alias for one or another, as selected by a configure option (defaulting to pc-1.0-qemu-git, IE no change).This requires 'hot patching' the VMStateDescription in a couple of places, which in turn is less than obvious as there may be (indeed are for i8259) derived classes. Whilst pretty nausea-inducing, this approach has the benefit of being entirely self-contained.
Quoted 6 lines
Quoted 3 lines
Ow come on.
Just add a flag and select the appropriate format based on it, usingfield_exists.I don't think it is that simple. All those things are initialised well before the command line is parsed.
You initialize both and select the correct one at migration time.
Quoted 1 line
Unless I'm missing what you are saying?
I think you are: check how vmstate_test_use_acpi_pci_hotplug and vmstate_test_no_use_acpi_pci_hotplug are used in vmstate_acpi.
Quoted 5 lines
Signature · 1 line
Alex Bligh
Michael,
Quoted 6 lines · Michael S. Tsirkin
Quoted 2 lines
Unless I'm missing what you are saying?
I think you are: check how
vmstate_test_use_acpi_pci_hotplugandvmstate_test_no_use_acpi_pci_hotplugare used invmstate_acpi.
I /think/ you are talking about using the VMSTATE_FOO_TEST macros.
These are capable of modifying fields within the VMStateDescription of the relevant object.
However, the PIIX4 change modifies the minimum_version_id (outside fields); I don't quite see how that would work. Can you help here?
The i8254 change modifies a field which is marked with a minimum version to be a field with no versioning; I guess the route there would be a test function that (somehow) accesses the version of the inbound migration inside it, does the comparison manually, and returns 1 if EITHER the inbound version >=3 or the compatibility thing is set.
Is that what you meant? I'm rather new to this so you may have to lead me a little - apologies.
I was trying to produce code which would be 'obviously correct' in the sense of not breaking the existing pc-1.0 migrations; if playing around with the existing vmstate fields is permissible then clearly I have a few more degrees of freedom.
I did try modifying the objects live after the command line has been parsed; this doesn't work because the QOM inheritance memcpy's the structs for classes derived from i8254 etc.
Signature · 1 line
Alex Bligh
Quoted 5 lines · Alex Bligh
Michael,
Quoted 1 line · Michael S. Tsirkin
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Unless I'm missing what you are saying?
I think you are: check how
vmstate_test_use_acpi_pci_hotplugandvmstate_test_no_use_acpi_pci_hotplugare used invmstate_acpi.I /think/ you are talking about using the
VMSTATE_FOO_TESTmacros.
These use field_exists internally.
Quoted 6 lines
These are capable of modifying fields within the VMStateDescription of the relevant object.
However, the PIIX4 change modifies the
minimum_version_id(outside fields); I don't quite see how that would work. Can you help here?
If you want to support lower version IDs,
you can just decrease minimum_version_id.
field_exists gets the version ID so you can
parse different fields depending on the
version.
Quoted 5 lines
The i8254 change modifies a field which is marked with a minimum version to be a field with no versioning; I guess the route there would be a test function that (somehow) accesses the version of the inbound migration inside it,
Yes, field_exists gets the version value so no problem here.
Quoted 5 lines
does the comparison manually, and returns
1 if EITHER the inbound version >=3 or the compatibility thing is set.Is that what you meant?
I think so, yes.
Quoted 8 lines
I'm rather new to this so
you may have to lead me a little - apologies.I was trying to produce code which would be 'obviously correct' in the sense of not breaking the existing pc-1.0 migrations; if playing around with the existing vmstate fields is permissible then clearly I have a few more degrees of freedom.
Yes I think is should be simple but not to the
exclusion of maintainability.
Quoted 4 lines
I did try modifying the objects live after the command line has been parsed; this doesn't work because the QOM inheritance memcpy's the structs for classes derived from i8254 etc.
Right, just add a new flag for this thing.
Quoted 5 lines
Signature · 1 line
Alex Bligh
Michael,
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines
These are capable of modifying fields within the VMStateDescription of the relevant object.
However, the PIIX4 change modifies the
minimum_version_id(outside fields); I don't quite see how that would work. Can you help here?
Quoted 6 lines
If you want to support lower version IDs,
you can just decreaseminimum_version_id.
field_existsgets the version ID so you can
parse different fields depending on the
version.
The issue is that qemu-kvm 1.0 used version ID 2 but is actually sending a version 3 structure.
I don't think I can just reduce the minimum version ID. As per the comment in the original patch from Cole Robinson:
http://pkgs.fedoraproject.org/cgit/qemu.git/tree/0001-Fix-migration-from-qemu-kvm.patch?h=f20
hw/acpi/piix4.c +7 -1
@@ -289,7 +289,13 @@ static int acpi_load_old(QEMUFile *f, void *opaque, int version_id)static const VMStateDescription vmstate_acpi = { .name ="piix4_pm" , .version_id =3 , - .minimum_version_id =3 , +/* +* qemu-kvm 1.2 uses qemu.git version 3 format, but advertised as 2. +* This allows incoming migration from qemu-kvm, but breaks incoming +* migration from qemu < 1.3. +*/ +//minimum_version_id = 3, + .minimum_version_id =2 , .minimum_version_id_old =1 , .load_state_old = acpi_load_old, .post_load = vmstate_acpi_post_load,
An inbound migration from qemu-1.0-git, qemu-1.1 or qemu-1.2 will have version ID 2 and actually mean version 2; currently (i.e. with minimum_version_id = 3), these use the minimum_version_id_old field (1) and acpi_load_old routine.
If I decrease minimum_version_id to 2, as far as I can tell this will break inbound migration from the 'good' earlier versions, whilst fixing qemu-1.0-kvm (which uses version 2 to mean version 3).
So as far as I can tell, the minimum version ID needs to be dependent upon inbound machine type (or machine parameters). By the time the command line is parsed, these structures have already been built. That's why I took the approach I did, but again I'm new to this so may be missing something.
Or were you suggesting I introduced a
test_force_use_new_load_vm_state
type field into VMStateDescription so it can dynamically choose not to use the load_state_old but rather to use the new method, irrespective of the minimum version mismatch?
Signature · 1 line
Alex Bligh
Quoted 68 lines · Alex Bligh
Michael,
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines
These are capable of modifying fields within the VMStateDescription of the relevant object.
However, the PIIX4 change modifies the
minimum_version_id(outside fields); I don't quite see how that would work. Can you help here?Quoted 6 lines
If you want to support lower version IDs,
you can just decreaseminimum_version_id.
field_existsgets the version ID so you can
parse different fields depending on the
version.The issue is that qemu-kvm 1.0 used version ID 2 but is actually sending a version 3 structure.
I don't think I can just reduce the minimum version ID.
As per the comment in the original patch from Cole Robinson:
http://pkgs.fedoraproject.org/cgit/qemu.git/tree/0001-Fix-migration-from-qemu-kvm.patch?h=f20
hw/acpi/piix4.c +7
-1@@ -289,7 +289,13 @@ static int acpi_load_old(QEMUFile *f, void *opaque, int version_id)static const VMStateDescription vmstate_acpi = { .name ="piix4_pm" , .version_id =3 , - .minimum_version_id =3 , +/* +* qemu-kvm 1.2 uses qemu.git version 3 format, but advertised as 2. +* This allows incoming migration from qemu-kvm, but breaks incoming +* migration from qemu < 1.3. +*/ +//minimum_version_id = 3, + .minimum_version_id =2 , .minimum_version_id_old =1 , .load_state_old = acpi_load_old, .post_load = vmstate_acpi_post_load,An inbound migration from qemu-1.0-git, qemu-1.1 or qemu-1.2 will have version ID 2 and actually mean version 2; currently (i.e. with
minimum_version_id= 3), these use theminimum_version_id_oldfield (1) andacpi_load_oldroutine.If I decrease
minimum_version_idto 2, as far as I can tell this will break inbound migration from the 'good' earlier versions, whilst fixing qemu-1.0-kvm (which uses version 2 to mean version 3).So as far as I can tell, the minimum version ID needs to be dependent upon inbound machine type (or machine parameters). By the time the command line is parsed, these structures have already been built. That's why I took the approach I did, but again I'm new to this so may be missing something.
Quoted 6 lines
Or were you suggesting I introduced a
test_force_use_new_load_vm_state
type field into VMStateDescription so it can dynamically choose not to use theload_state_oldbut rather to use the new method, irrespective of the minimum version mismatch?
I was merely suggesting changing acpi_load_old to detect the new flag and parse the qemu-kvm format.
Quoted 5 lines
Signature · 1 line
Alex Bligh
Quoted 2 lines · Michael S. Tsirkin
I was merely suggesting changing
acpi_load_oldto detect the new flag and parse the qemu-kvm format.
Oh OK - far simpler.
If the machine is subsequently migrated to another qemu-2.x device, I take it that will still write out a proper version 3 object?
Signature · 1 line
Alex Bligh
Quoted 11 lines · Alex Bligh
Quoted 2 lines · Michael S. Tsirkin
I was merely suggesting changing
acpi_load_oldto detect the new flag and parse the qemu-kvm format.Oh OK - far simpler.
If the machine is subsequently migrated to another qemu-2.x device, I take it that will still write out a proper version 3 object?
I think so, yes.
Quoted 5 lines
Signature · 1 line
Alex Bligh
Quoted 27 lines · Alex Bligh
This patch series adds inbound migrate capability from qemu-kvm version 1.0. The main ideas are those set out in Cole Robinson's patch here:
http://pkgs.fedoraproject.org/cgit/qemu.git/tree/0001-Fix-migration-from-qemu-kvm.patch?h=f20
however, rather than patching statically (and breaking inbound migration on existing machine types), I have added a new machine type (pc-1.0-qemu-kvm) without affecting any other machine types. The existing pc-1.0 machine type is renamed to pc-1.0-qemu-git, with pc-1.0 becoming an alias for one or another, as selected by a configure option (defaulting to pc-1.0-qemu-git, IE no change).This requires 'hot patching' the VMStateDescription in a couple of places, which in turn is less than obvious as there may be (indeed are for i8259) derived classes. Whilst pretty nausea-inducing, this approach has the benefit of being entirely self-contained.
I developed this on qemu 2.0 but have forward ported it (trivially) to master. My testing has been on a VM live-migrated-to-file from Ubuntu Precise qemu-kvm 1.0.
I have given this a moderate degree of testing but it could do with more.
Note that certain hardware devices (including QXL) will not migrate properly due to a fundamental difference in their internal state between versions.
Quoted 7 lines
Also note that (as expected) migratino from qemu-2.x to qemu-1.0 will not work, even if the machine types are the same.
Alex Bligh (2):
Add machine type pc-1.0-qemu-kvm for live migrate compatibility with
qemu-kvm
Add configure option --enable-pc-1-0-qemu-kvm
Thanks, Alex, I hope to set up a test of this this afternoon.
Quoted 11 lines
configure | 12 ++++++++++++ hw/acpi/piix4.c | 49 ++++++++++++++++++++++++++++++++++++++++++++-- hw/i386/pc_piix.c | 39 +++++++++++++++++++++++++++++++++++- hw/timer/i8254_common.c | 41 ++++++++++++++++++++++++++++++++++++++ include/hw/acpi/piix4.h | 1 + include/hw/timer/i8254.h | 2 ++ 6 files changed, 141 insertions(+), 3 deletions(-)Signature · 1 line
1.7.9.5
This worked for me when migrating by hand. I'm trying to make it work through libvirt, using the following patch. (So whether to have pc-1.0 be treated as qemu's or qemu-kvm's pc-1.0 is specifed using a boolean in /etc/libvirt/qemu.conf) Qemu starts with decent looking args, but for some reason the the migration is failing - still looking through the logfile to figure out why. Now sadly my tests are being further slowed down by qcow corruption on my host, but I don't think that was the cause of my failure.
src/qemu/qemu_conf.c +3 -0
@@ -230,6 +230,8 @@ virQEMUDriverConfigPtr virQEMUDriverConf cfg->migrationPortMin =QEMU_MIGRATION_PORT_MIN ; cfg->migrationPortMax =QEMU_MIGRATION_PORT_MAX ; + cfg->incoming_assume_qemukvm = false; +#if definedHAVE_MNTENT_H && definedHAVE_GETMNTENT_R /* For privileged driver, try and find hugepage mount automatically. * Non-privileged driver requires admin to create a dir for the
@@ -355,6 +357,7 @@ int virQEMUDriverConfigLoadFile(virQEMUD goto cleanup; \ } +GET_VALUE_BOOL ("incoming_assume_qemukvm" , cfg->incoming_assume_qemukvm);GET_VALUE_BOOL ("vnc_auto_unix_socket" , cfg->vncAutoUnixSocket);GET_VALUE_BOOL ("vnc_tls" , cfg->vncTLS);GET_VALUE_BOOL ("vnc_tls_x509_verify" , cfg->vncTLSx509verify);
src/qemu/qemu_conf.h +2 -0
@@ -168,6 +168,8 @@ struct _virQEMUDriverConfig {char *migrationAddress;int migrationPortMin;int migrationPortMax; +/* Whether incoming pc-1.0 migration should come from qemu-kvm */ +bool incoming_assume_qemukvm;bool logTimestamp; };
src/qemu/qemu_migration.c +17 -0
@@ -2131,6 +2131,16 @@ static charif (!qemuDomainDefCheckABIStability (driver, vm->def, def)) goto cleanup; +if (driver->config->incoming_assume_qemukvm) { +if (STREQ_NULLABLE (vm->def->os.machine,"pc-1.0" )) { +VIR_FREE (vm->def->os.machine); +VIR_FREE (def->os.machine); +if (VIR_STRDUP (vm->def->os.machine,"pc-1.0-qemu-kvm" ) <0 || +VIR_STRDUP (def->os.machine,"pc-1.0-qemu-kvm" ) <0 ) + goto cleanup; + } + } + rv =qemuDomainDefFormatLive (driver, def, false, true); }else { rv =qemuDomainDefFormatLive (driver, vm->def, false, true);
@@ -2461,6 +2471,13 @@ qemuMigrationPrepareAny(virQEMUDriverPtr goto endjob; } +if (driver->config->incoming_assume_qemukvm) { +if (STREQ_NULLABLE (vm->def->os.machine,"pc-1.0" )) { +VIR_FREE (vm->def->os.machine); +if (VIR_STRDUP (vm->def->os.machine,"pc-1.0-qemu-kvm" ) <0 ) + goto endjob; + } + }/* Start the QEMU daemon, with the same command-line arguments plus * -incoming $migrateFrom */
src/qemu/qemu_command.c +6 -0
@@ -7093,6 +7093,7 @@ qemuBuildCommandLine(virConnectPtr conn,virArch hostarch =virArchFromHost ();virQEMUDriverConfigPtr cfg =virQEMUDriverGetConfig (driver); + VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d " "qemuCaps=%p migrateFrom=%s migrateFD=%d " "snapshot=%p vmop=%d",
@@ -7172,6 +7173,11 @@ qemuBuildCommandLine(virConnectPtr conn,if (virQEMUCapsGet (qemuCaps,QEMU_CAPS_ENABLE_FIPS ))virCommandAddArg (cmd,"-enable-fips" ); +VIR_DEBUG ("qemu_command: os.machine is %s\n" , def->os.machine); +if (STREQ_NULLABLE (def->os.machine,"pc-1.0-qemu-kvm" )) { +virCommandAddArgList (cmd,"-global" , +"virtio-net-pci.romfile=pxe-virtio.rom.12.04" ,NULL ); + }if (qemuBuildMachineArgStr (cmd, def, qemuCaps) <0 ) goto error;
Serge,
Quoted 6 lines · Serge Hallyn
This worked for me when migrating by hand. I'm trying to make it work through libvirt, using the following patch. (So whether to have pc-1.0 be treated as qemu's or qemu-kvm's pc-1.0 is specifed using a boolean in
/etc/libvirt/qemu.conf) Qemu starts with decent looking args, but for some reason the the migration is failing - still looking through the logfile to figure out why.
Are you using exactly the same arguments by hand and with libvirt?
Also, on reflection, given one of the changes between 1.0 and 2.0 is ACPI, I should probably have done some testing with an ACPI enabled image, rather than just cirros (which not ACPI enabled); any chance this is ACPI related?
Quoted 3 lines
Now sadly my
tests are being further slowed down by qcow corruption on my host, but I don't think that was the cause of my failure.
Whilst getting the patch right in the first place I tend to cp from a known good image. Obviously once it works, qcow2 corruption should not happen. But failed migrations (with or without my patch) do appear to cause this relatively frequently.
Signature · 1 line
Alex Bligh
Quoted 11 lines · Alex Bligh
Serge,
Quoted 6 lines · Serge Hallyn
This worked for me when migrating by hand. I'm trying to make it work through libvirt, using the following patch. (So whether to have pc-1.0 be treated as qemu's or qemu-kvm's pc-1.0 is specifed using a boolean in
/etc/libvirt/qemu.conf) Qemu starts with decent looking args, but for some reason the the migration is failing - still looking through the logfile to figure out why.
Quoted 6 lines
Are you using exactly the same arguments by hand and with libvirt?
Also, on reflection, given one of the changes between 1.0 and 2.0 is ACPI, I should probably have done some testing with an ACPI enabled image, rather than just cirros (which not ACPI enabled); any chance this is ACPI related?
Turning off acpi (well, commenting it out in the xml, which I'm assuming dtrt) doesn't help:
===============================================
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -name cirros -S -global virtio-net-pci.romfile=pxe-virtio.rom.12.04 -machine pc-1.0-qemu-kvm,accel=kvm,usb=off -m 512 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 2542c328-6842-33ef-d30e-866c3f3189a8 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/cirros.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -no-acpi -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/cirros.img,if=none,id=drive-ide0-0-0,format=raw -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -netdev tap,fd=26,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:be:d8:99,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:0 -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device AC97,id=sound0,bus=pci.0,addr=0x4 -incoming fd:23 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -msg timestamp=on
2014-08-07 12:51:02.400+0000: 1539: debug : virFileClose:99 : Closed fd 25 2014-08-07 12:51:02.401+0000: 1539: debug : virFileClose:99 : Closed fd 31 2014-08-07 12:51:02.401+0000: 1539: debug : virFileClose:99 : Closed fd 3 2014-08-07 12:51:02.401+0000: 1540: debug : virExec:616 : Run hook 0x7f25cb17bca0 0x7f25d3aedf20 2014-08-07 12:51:02.401+0000: 1540: debug : qemuProcessHook:2719 : Obtaining domain lock 2014-08-07 12:51:02.401+0000: 1540: debug : virDomainLockProcessStart:175 : plugin=0x7f25c4170290 dom=0x7f25c4186510 paused=1 fd=0x7f25d3aedb44 2014-08-07 12:51:02.401+0000: 1540: debug : virDomainLockManagerNew:133 : plugin=0x7f25c4170290 dom=0x7f25c4186510 withResources=1 2014-08-07 12:51:02.401+0000: 1540: debug : virLockManagerPluginGetDriver:281 : plugin=0x7f25c4170290 2014-08-07 12:51:02.401+0000: 1540: debug : virLockManagerNew:305 : driver=0x7f25da723580 type=0 nparams=5 params=0x7f25d3aeda30 flags=0 2014-08-07 12:51:02.401+0000: 1540: debug : virLockManagerLogParams:98 : key=uuid type=uuid value=2542c328-6842-33ef-d30e-866c3f3189a8 2014-08-07 12:51:02.401+0000: 1540: debug : virLockManagerLogParams:91 : key=name type=string value=cirros 2014-08-07 12:51:02.401+0000: 1540: debug : virLockManagerLogParams:79 : key=id type=uint value=2 2014-08-07 12:51:02.401+0000: 1540: debug : virLockManagerLogParams:79 : key=pid type=uint value=1540 2014-08-07 12:51:02.401+0000: 1540: debug : virLockManagerLogParams:94 : key=uri type=cstring value=qemu:///system 2014-08-07 12:51:02.401+0000: 1540: debug : virDomainLockManagerNew:145 : Adding leases 2014-08-07 12:51:02.401+0000: 1540: debug : virDomainLockManagerNew:150 : Adding disks 2014-08-07 12:51:02.401+0000: 1540: debug : virDomainLockManagerAddDisk:91 : Add disk /var/lib/libvirt/images/cirros.img 2014-08-07 12:51:02.401+0000: 1540: debug : virLockManagerAddResource:332 : lock=0x7f25c417b080 type=0 name=/var/lib/libvirt/images/cirros.img nparams=0 params=(nil) flags=0 2014-08-07 12:51:02.401+0000: 1540: debug : virLockManagerAcquire:350 : lock=0x7f25c417b080 state='<null>' flags=3 action=0 fd=0x7f25d3aedb44 2014-08-07 12:51:02.401+0000: 1540: debug : virLockManagerFree:387 : lock=0x7f25c417b080 2014-08-07 12:51:02.401+0000: 1540: debug : virObjectUnref:259 : OBJECT_UNREF: obj=0x7f25c415e620 2014-08-07 12:51:02.401+0000: 1540: debug : qemuProcessHook:2746 : Hook complete ret=0 2014-08-07 12:51:02.401+0000: 1540: debug : virExec:618 : Done hook 0 2014-08-07 12:51:02.401+0000: 1540: debug : virExec:638 : Setting child AppArmor profile to libvirt-2542c328-6842-33ef-d30e-866c3f3189a8 2014-08-07 12:51:02.402+0000: 1540: debug : virExec:655 : Setting child uid:gid to 107:113 with caps 0 2014-08-07 12:51:02.402+0000: 1540: debug : virCommandHandshakeChild:358 : Notifying parent for handshake start on 28 2014-08-07 12:51:02.402+0000: 1540: debug : virCommandHandshakeChild:366 : Waiting on parent for handshake complete on 29 libvirt: error : libvirtd quit during handshake: Input/output error 2014-08-07 12:51:02.424+0000: shutting down
===============================================
Perhaps the key is here:
===============================================
2014-08-07 12:51:02.416+0000: 1119: debug : virEventPollDispatchHandles:508 : EVENT_POLL_DISPATCH_HANDLE: watch=7 events=1 2014-08-07 12:51:02.416+0000: 1119: debug : udevEventHandleCallback:1585 : udev action: 'add' 2014-08-07 12:51:02.416+0000: 1119: debug : udevGetDeviceProperty:125 : udev reports device 'rx-0' does not have property 'DRIVER' 2014-08-07 12:51:02.416+0000: 1119: debug : udevGetDeviceProperty:143 : Found property key 'SUBSYSTEM' value 'queues' for device with sysname 'rx-0' 2014-08-07 12:51:02.416+0000: 1119: debug : udevGetDeviceType:1279 : Could not determine device type for device with sysfs name 'rx-0' 2014-08-07 12:51:02.416+0000: 1119: debug : udevAddOneDevice:1454 : Discarding device -1 0x7f25dcb40e80 /sys/devices/virtual/net/vnet0/queues/rx-0
===============================================
Quoted 9 lines
Quoted 3 lines
Now sadly my
tests are being further slowed down by qcow corruption on my host, but I don't think that was the cause of my failure.Whilst getting the patch right in the first place I tend to cp from a known good image. Obviously once it works, qcow2 corruption should not happen. But failed migrations (with or without my patch) do appear to cause this relatively frequently.
No no, the qcow2 corruption is nothing to do with the migration itself. I'm testing migration between two vms on my laptop which are using qcow2 snapshots for rootfs, and those are the ones getting the corruption. This is
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1319578
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1315162 and
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1292234
which i could never reproduce before.
-serge
Quoted 11 lines · Alex Bligh
Serge,
Quoted 6 lines · Serge Hallyn
This worked for me when migrating by hand. I'm trying to make it work through libvirt, using the following patch. (So whether to have pc-1.0 be treated as qemu's or qemu-kvm's pc-1.0 is specifed using a boolean in
/etc/libvirt/qemu.conf) Qemu starts with decent looking args, but for some reason the the migration is failing - still looking through the logfile to figure out why.
Quoted 6 lines
Are you using exactly the same arguments by hand and with libvirt?
Also, on reflection, given one of the changes between 1.0 and 2.0 is ACPI, I should probably have done some testing with an ACPI enabled image, rather than just cirros (which not ACPI enabled); any chance this is ACPI related?
A-ha, acpi wasn't a problem. I actually had a general migration problem even when coming from other utopic hosts. With that fixed, I've got successful migration from qemu-kvm 1.0 in precise to a utopic host.
-serge
Quoted 4 lines · Serge E. Hallyn
A-ha, acpi wasn't a problem. I actually had a general migration problem even when coming from other utopic hosts. With that fixed, I've got successful migration from qemu-kvm 1.0 in precise to a utopic host.
That's good news. You might try the 2 patches here:
https://github.com/abligh/qemu/tree/livemigrate-qemu-kvm-to-qemu-2.0.0-test-2
and see if you can get Precise to Trusty migration working (as well as Precise to Utopic)
Signature · 1 line
Alex Bligh
Quoted 8 lines · Alex Bligh
Quoted 4 lines · Serge E. Hallyn
A-ha, acpi wasn't a problem. I actually had a general migration problem even when coming from other utopic hosts. With that fixed, I've got successful migration from qemu-kvm 1.0 in precise to a utopic host.
Quoted 6 lines
That's good news. You might try the 2 patches here:
https://github.com/abligh/qemu/tree/livemigrate-qemu-kvm-to-qemu-2.0.0-test-2
and see if you can get Precise to Trusty migration working (as well as Precise to Utopic)
These have built at https://launchpad.net/~serge-hallyn/+archive/ubuntu/qemu-p-migration