Skip to contentSkip to conversation

non-migratable devices

PATCH In review Gerd Hoffmann 4 participants 19 messages Jul 8, 2011 – Jul 11, 2011

lore
Share & tools
lore
#0 lore raw

cover non-migratable devices

Hi,

This patch series adds an easy way to tag devices as non-migratable puts it into use for ahci and ehci.

Gerd Hoffmann (3):
vmstate: add no_migrate flag to VMStateDescription ahci doesn't support migration
ehci doesn't support migration

 hw/hw.h       |    1 +
 hw/ide/ich.c  |    6 ++++++
 hw/usb-ehci.c |    6 ++++++
 savevm.c      |    1 +
 4 files changed, 14 insertions(+), 0 deletions(-)
#1 lore raw

PATCH 1/3 vmstate: add no_migrate flag to VMStateDescription

This allows to easily tag devices as non-migratable, so any attempt to migrate a virtual machine with the device in question active will make migration fail.

---
 hw/hw.h  |    1 +
 savevm.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
hw/hw.h +1 -0
index 9dd7096..1eb3486 100644
@@ -324,6 +324,7 @@ typedef struct VMStateSubsection {
 
 struct VMStateDescription {
     const char *name;
+    int no_migrate;
     int version_id;
     int minimum_version_id;
     int minimum_version_id_old;
savevm.c +1 -0
index 8139bc7..fa2da3e 100644
@@ -1234,6 +1234,7 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
     se->opaque = opaque;
     se->vmsd = vmsd;
     se->alias_id = alias_id;
+    se->no_migrate = vmsd->no_migrate;
 
     if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) {
         char *id = dev->parent_bus->info->get_dev_path(dev);
Signature · 1 line
1.7.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] vmstate: add no_migrate flag to VMStateDescription

Quoted 5 lines · Gerd Hoffmann

This allows to easily tag devices as non-migratable, so any attempt to migrate a virtual machine with the device in question active will make migration fail.

register_device_unmigratable()?

Regards,

Anthony Liguori

Quoted 29 lines
---
  hw/hw.h  |    1 +
  savevm.c |    1 +
  2 files changed, 2 insertions(+), 0 deletions(-)
hw/hw.h +1 -0
index 9dd7096..1eb3486 100644
@@ -324,6 +324,7 @@ typedef struct VMStateSubsection {
 
  struct VMStateDescription {
      const char *name;
+    int no_migrate;
      int version_id;
      int minimum_version_id;
      int minimum_version_id_old;
savevm.c +1 -0
index 8139bc7..fa2da3e 100644
@@ -1234,6 +1234,7 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
      se->opaque = opaque;
      se->vmsd = vmsd;
      se->alias_id = alias_id;
+    se->no_migrate = vmsd->no_migrate;
 
      if (dev&&  dev->parent_bus&&  dev->parent_bus->info->get_dev_path) {
          char *id = dev->parent_bus->info->get_dev_path(dev);
#3 lore raw

Re: [Qemu-devel] [PATCH 1/3] vmstate: add no_migrate flag to VMStateDescription

Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Gerd Hoffmann

This allows to easily tag devices as non-migratable, so any attempt to migrate a virtual machine with the device in question active will make migration fail.

register_device_unmigratable()?

That is just a more complicated way to do the same ;) Wanna have a patch to zap it?

cheers,
Gerd

#4 lore raw

Re: [Qemu-devel] [PATCH 1/3] vmstate: add no_migrate flag to VMStateDescription

Quoted 4 lines · Gerd Hoffmann
Quoted 1 line · Anthony Liguori

register_device_unmigratable()?

Wanna have a patch to zap it?

Ah, no, we can't, for ivshmem this isn't fixed but depends on the configuration, so a static flag in the VMStateDescription doesn't cut it.

cheers,
Gerd

#5 lore raw

Re: [Qemu-devel] [PATCH 1/3] vmstate: add no_migrate flag to VMStateDescription

Quoted 8 lines · Gerd Hoffmann
Quoted 4 lines · Gerd Hoffmann
Quoted 1 line · Anthony Liguori

register_device_unmigratable()?

Wanna have a patch to zap it?

Ah, no, we can't, for ivshmem this isn't fixed but depends on the configuration, so a static flag in the VMStateDescription doesn't cut it.

Right, but can we have some continuity at least between the two interfaces?

At least make the vmstate flag 'unmigratable' or rename the function to qdev_set_no_migrate().

BTW, should this be a vmstate flag or a qdev flag?

Regards,

Anthony Liguori

Quoted 4 lines

cheers,
Gerd

#6 lore raw

Re: [Qemu-devel] [PATCH 1/3] vmstate: add no_migrate flag to VMStateDescription

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

register_device_unmigratable()?

Right, but can we have some continuity at least between the two interfaces?

At least make the vmstate flag 'unmigratable' or rename the function to qdev_set_no_migrate().

Will rename the flag.

Quoted 1 line

BTW, should this be a vmstate flag or a qdev flag?

vmstate. savevm.c doesn't look at the qdev tree.

cheers,
Gerd

#7 lore raw

PATCH 2/3 ahci doesn't support migration

In reply to Gerd Hoffmann
---
 hw/ide/ich.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
hw/ide/ich.c +6 -0
index 054e073..0f26603 100644
@@ -72,6 +72,11 @@
 #include <hw/ide/pci.h>
 #include <hw/ide/ahci.h>
 
+static const VMStateDescription vmstate_ahci = {
+    .name = "ahci",
+    .no_migrate = 1,
+};
+
 static int pci_ich9_ahci_init(PCIDevice *dev)
 {
     struct AHCIPCIState *d;
@@ -123,6 +128,7 @@ static PCIDeviceInfo ich_ahci_info[] = {
         .qdev.name    = "ich9-ahci",
         .qdev.alias   = "ahci",
         .qdev.size    = sizeof(AHCIPCIState),
+        .qdev.vmsd    = &vmstate_ahci,
         .init         = pci_ich9_ahci_init,
         .exit         = pci_ich9_uninit,
         .config_write = pci_ich9_write_config,
Signature · 1 line
1.7.1
#8 lore raw

PATCH 3/3 ehci doesn't support migration

In reply to Gerd Hoffmann
---
 hw/usb-ehci.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
hw/usb-ehci.c +6 -0
index 91fb7de..a0449be 100644
@@ -2136,9 +2136,15 @@ static USBBusOps ehci_bus_ops = {
     .device_destroy = ehci_device_destroy,
 };
 
+static const VMStateDescription vmstate_ehci = {
+    .name = "ehci",
+    .no_migrate = 1,
+};
+
 static PCIDeviceInfo ehci_info = {
     .qdev.name    = "usb-ehci",
     .qdev.size    = sizeof(EHCIState),
+    .qdev.vmsd    = &vmstate_ehci,
     .init         = usb_ehci_initfn,
     .vendor_id    = PCI_VENDOR_ID_INTEL,
     .device_id    = PCI_DEVICE_ID_INTEL_82801D,
Signature · 1 line
1.7.1
#9 lore raw
In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann
   Hi,

This patch series adds an easy way to tag devices as non-migratable puts it into use for ahci and ehci.

Gerd Hoffmann (3):
vmstate: add no_migrate flag to VMStateDescription ahci doesn't support migration
ehci doesn't support migration

Quoted 8 lines
  hw/hw.h       |    1 +
  hw/ide/ich.c  |    6 ++++++
  hw/usb-ehci.c |    6 ++++++
  savevm.c      |    1 +
  4 files changed, 14 insertions(+), 0 deletions(-)

ACK series

For scsi-cd and other empty-but-generally-migratable devices we should probably add an empty vmstate, so that any further addition can be done as subsections.

Paolo

#10 lore raw

Hi,

Quoted 3 lines

For scsi-cd and other empty-but-generally-migratable devices we should probably add an empty vmstate, so that any further addition can be done as subsections.

That will break migration to older versions which don't know about the new sections, even if they are empty ...

cheers,
Gerd

#11 lore raw
Quoted 8 lines · Gerd Hoffmann
Quoted 5 lines

For scsi-cd and other empty-but-generally-migratable devices we should probably add an empty vmstate, so that any further addition can be done as subsections.

That will break migration to older versions which don't know about the new sections, even if they are empty ...

scsi-cd is new in 0.15, older versions have scsi-disk only. That's why we should take the occasion to add the empty vmstate at least to it.

For other devices, it's better to make the breakage in a single version.
It also allows to make 0.15 the "flag day" where each device shall
have a VMState or the entire VM will not be migratable. If desired, in the future we can revert this behavior for pc-0.14 and earlier machines.

Paolo

#12 lore raw

Hi,

Quoted 2 lines

scsi-cd is new in 0.15, older versions have scsi-disk only. That's why we should take the occasion to add the empty vmstate at least to it.

Ok, good opportunity in that specific case.

Quoted 3 lines

For other devices, it's better to make the breakage in a single version. It also allows to make 0.15 the "flag day" where each device shall have a VMState or the entire VM will not be migratable.

Not that easy given that we didn't fully migrate to vmstate yet, otherwise we could simply fail migration in case we find any device with qdev->vmsd == NULL.

Quoted 2 lines

If desired, in the
future we can revert this behavior for pc-0.14 and earlier machines.

And I'm still looking for a sane way to handle *this*.

cheers,
Gerd

#13 lore raw
Quoted 7 lines · Gerd Hoffmann
Quoted 4 lines

scsi-cd is new in 0.15, older versions have scsi-disk only. That's why we should take the occasion to add the empty vmstate at least to it.

Ok, good opportunity in that specific case.

Quoted 7 lines
Quoted 3 lines

For other devices, it's better to make the breakage in a single version. It also allows to make 0.15 the "flag day" where each device shall have a VMState or the entire VM will not be migratable.

Not that easy given that we didn't fully migrate to vmstate yet, otherwise we could simply fail migration in case we find any device with qdev->vmsd == NULL.

You can always add

#define VMSD_NONE ((const VMStateDescription *) 1)

Quoted 4 lines
Quoted 2 lines

If desired, in the
future we can revert this behavior for pc-0.14 and earlier machines.

And I'm still looking for a sane way to handle *this*.

One possibility is to add device name remapping to machine types, like "ide is actually ide-0.14 when using pc-0.14" and put a different VMState in ide-0.14.

Paolo

#14 lore raw

Hi,

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

If desired, in the
future we can revert this behavior for pc-0.14 and earlier machines.

And I'm still looking for a sane way to handle *this*.

One possibility is to add device name remapping to machine types, like "ide is actually ide-0.14 when using pc-0.14" and put a different VMState in ide-0.14.

That isn't very different from subsections.

Problem is that the old qemu version doesn't have the section at all, not that it looks somehow different.

cheers,
Gerd

#15 lore raw
Quoted 9 lines · Gerd Hoffmann
Quoted 4 lines

One possibility is to add device name remapping to machine types, like "ide is actually ide-0.14 when using pc-0.14" and put a different VMState in ide-0.14.

That isn't very different from subsections.

Problem is that the old qemu version doesn't have the section at all, not that it looks somehow different.

No, I meant a different qdev name, i.e. mapping the same device name to a different DeviceInfo.

Paolo

#16 lore raw
Quoted 6 lines · Paolo Bonzini
Quoted 5 lines · Gerd Hoffmann
Quoted 4 lines

One possibility is to add device name remapping to machine types, like "ide is actually ide-0.14 when using pc-0.14" and put a different VMState in ide-0.14.

Quoted 7 lines
Quoted 4 lines

That isn't very different from subsections.

Problem is that the old qemu version doesn't have the section at all, not that it looks somehow different.

No, I meant a different qdev name, i.e. mapping the same device name to a different DeviceInfo.

That is an idea. This could also replace compat properties (by giving ide-0.14 different default values for the properties) and thereby move the compat info from hw/pc.c to hw/ide/xxx.c.

cheers,
Gerd

#17 lore raw
In reply to Gerd Hoffmann
Quoted 8 lines · Gerd Hoffmann

Hi,

Quoted 3 lines

For scsi-cd and other empty-but-generally-migratable devices we should probably add an empty vmstate, so that any further addition can be done as subsections.

That will break migration to older versions which don't know about the new sections, even if they are empty ...

Send them only when running a sufficiently recent -M?

#18 lore raw

[Qemu-devel] [PATCH 4/3] vmstate: complain about devices without vmstate

In reply to Gerd Hoffmann
---
 hw/hw.h   |    2 ++
 hw/qdev.c |    7 ++++++-
 2 files changed, 8 insertions(+), 1 deletions(-)
hw/hw.h +2 -0
index 1eb3486..6d6c493 100644
@@ -336,6 +336,8 @@ struct VMStateDescription {
     const VMStateSubsection *subsections;
 };
 
+#define VMSD_NONE ((const VMStateDescription*)1)
+
 extern const VMStateInfo vmstate_info_bool;
 
 extern const VMStateInfo vmstate_info_int8;
hw/qdev.c +6 -1
index 292b52f..fafbbae 100644
@@ -283,7 +283,12 @@ int qdev_init(DeviceState *dev)
         qdev_free(dev);
         return rc;
     }
-    if (dev->info->vmsd) {
+    if (dev->info->vmsd == NULL) {
+        /* TODO: fixup qemu source code, then make this an assert() */
+        error_report("WARNING: device %s has no vmstate\n", dev->info->name);
+    } else if (dev->info->vmsd == VMSD_NONE) {
+        /* device doesn't need vmstate */;
+    } else {
         vmstate_register_with_alias_id(dev, -1, dev->info->vmsd, dev,
                                        dev->instance_id_alias,
                                        dev->alias_required_for_version);
Signature · 1 line
1.7.1