Skip to contentSkip to conversation

failover: unregister ram on unplug

PATCH Superseded Laurent Vivier 4 participants 6 messages Jul 20, 2021 – Jul 21, 2021

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 failover: unregister ram on unplug

This simple change allows to test failover with a simulated device like e1000e rather than a vfio device.

This is interesting to developers that want to test failover on a system with no vfio device. Moreover it simplifies host networking configuration as we can use the same bridge for virtio-net and the other failover networking device.

Without this change the migration of a system configured with failover fails with:

Unknown ramblock "0000:00:01.1:00.0/e1000e.rom", cannot accept migration error while loading state for instance 0x0 of device 'ram' load of migration failed: Invalid argument

---
 hw/net/virtio-net.c | 3 +++
 1 file changed, 3 insertions(+)
hw/net/virtio-net.c +3 -0
index 16d20cdee52a..8f7735bad4f2 100644
@@ -3256,6 +3256,9 @@ static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationState *s)
     if (migration_in_setup(s) && !should_be_hidden) {
         if (failover_unplug_primary(n, dev)) {
             vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev);
+            if (PCI_DEVICE(dev)->has_rom) {
+                vmstate_unregister_ram(&PCI_DEVICE(dev)->rom , dev);
+            }
             qapi_event_send_unplug_primary(dev->id);
             qatomic_set(&n->failover_primary_hidden, true);
         } else {
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Tue, 20 Jul 2021 20:16:44 +0200 Laurent Vivier <[email protected]> wrote:

This simple change allows to test failover with a simulated device like e1000e rather than a vfio device.

This is interesting to developers that want to test failover on a system with no vfio device. Moreover it simplifies host networking configuration as we can use the same bridge for virtio-net and the other failover networking device.

Quoted 8 lines

Without this change the migration of a system configured with failover fails with:

Unknown ramblock "0000:00:01.1:00.0/e1000e.rom", cannot accept migration error while loading state for instance 0x0 of device 'ram' load of migration failed: Invalid argument

Quoted 18 lines
---
 hw/net/virtio-net.c | 3 +++
 1 file changed, 3 insertions(+)
hw/net/virtio-net.c +3 -0
index 16d20cdee52a..8f7735bad4f2 100644
@@ -3256,6 +3256,9 @@ static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationState *s)
     if (migration_in_setup(s) && !should_be_hidden) {
         if (failover_unplug_primary(n, dev)) {
             vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev);
+            if (PCI_DEVICE(dev)->has_rom) {
+                vmstate_unregister_ram(&PCI_DEVICE(dev)->rom , dev);
+            }
             qapi_event_send_unplug_primary(dev->id);
             qatomic_set(&n->failover_primary_hidden, true);
         } else {
#2 lore raw
Quoted 14 lines · Igor Mammedov
Quoted 11 lines · On Tue, 20 Jul 2021 20:16:44 +0200 Laurent Vivier <[email protected]> wrote:

This simple change allows to test failover with a simulated device like e1000e rather than a vfio device.

This is interesting to developers that want to test failover on a system with no vfio device. Moreover it simplifies host networking configuration as we can use the same bridge for virtio-net and the other failover networking device.

Without this change the migration of a system configured with failover fails with:

Quoted 8 lines
Quoted 5 lines

Unknown ramblock "0000:00:01.1:00.0/e1000e.rom", cannot accept migration error while loading state for instance 0x0 of device 'ram' load of migration failed: Invalid argument

I've sent a v2 of this patch to reset has_rom to false.

I've updated the commit log message and the subject of the email to "failover: unregister ROM on unplug" (that is more correct).

Thanks,
Laurent

#3 lore raw
In reply to Igor Mammedov
Quoted 26 lines · Igor Mammedov
Quoted 8 lines · On Tue, 20 Jul 2021 20:16:44 +0200 Laurent Vivier <[email protected]> wrote:

This simple change allows to test failover with a simulated device like e1000e rather than a vfio device.

This is interesting to developers that want to test failover on a system with no vfio device. Moreover it simplifies host networking configuration as we can use the same bridge for virtio-net and the other failover networking device.

Quoted 8 lines

Without this change the migration of a system configured with failover fails with:

Unknown ramblock "0000:00:01.1:00.0/e1000e.rom", cannot accept migration error while loading state for instance 0x0 of device 'ram' load of migration failed: Invalid argument

Quoted 4 lines
---
 hw/net/virtio-net.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 9 lines

hw/net/virtio-net.c static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationState *s) · line 3259

Quoted 9 lines
hw/net/virtio-net.c +1 -0
index 16d20cdee52a..8f7735bad4f2 100644
@@ -3256,6 +3256,9 @@ static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationState *s)
     if (migration_in_setup(s) && !should_be_hidden) {
         if (failover_unplug_primary(n, dev)) {
             vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev);
+            if (PCI_DEVICE(dev)->has_rom) {

Hmm. Any way to hide this behind an interface so
we don't need to poke at pci device internals?

Quoted 5 lines
Quoted 5 lines
hw/net/virtio-net.c +2 -0
+                vmstate_unregister_ram(&PCI_DEVICE(dev)->rom , dev);
+            }
             qapi_event_send_unplug_primary(dev->id);
             qatomic_set(&n->failover_primary_hidden, true);
         } else {
#4 lore raw
Quoted 27 lines · Michael S. Tsirkin
Quoted 26 lines · Igor Mammedov
Quoted 8 lines · On Tue, 20 Jul 2021 20:16:44 +0200 Laurent Vivier <[email protected]> wrote:

This simple change allows to test failover with a simulated device like e1000e rather than a vfio device.

This is interesting to developers that want to test failover on a system with no vfio device. Moreover it simplifies host networking configuration as we can use the same bridge for virtio-net and the other failover networking device.

Quoted 8 lines

Without this change the migration of a system configured with failover fails with:

Unknown ramblock "0000:00:01.1:00.0/e1000e.rom", cannot accept migration error while loading state for instance 0x0 of device 'ram' load of migration failed: Invalid argument

Quoted 4 lines
---
 hw/net/virtio-net.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 13 lines
Quoted 9 lines

hw/net/virtio-net.c static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationState *s) · line 3259

Quoted 9 lines
hw/net/virtio-net.c +1 -0
index 16d20cdee52a..8f7735bad4f2 100644
@@ -3256,6 +3256,9 @@ static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationState *s)
     if (migration_in_setup(s) && !should_be_hidden) {
         if (failover_unplug_primary(n, dev)) {
             vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev);
+            if (PCI_DEVICE(dev)->has_rom) {

Hmm. Any way to hide this behind an interface so
we don't need to poke at pci device internals?

There is the pci_del_option_rom() but it's not exported.

Do you want I export and use it?

Thanks,
Laurent

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
hw/net/virtio-net.c +2 -0
+                vmstate_unregister_ram(&PCI_DEVICE(dev)->rom , dev);
+            }
             qapi_event_send_unplug_primary(dev->id);
             qatomic_set(&n->failover_primary_hidden, true);
         } else {
#5 lore raw
Quoted 42 lines · Laurent Vivier
Quoted 27 lines · Michael S. Tsirkin
Quoted 26 lines · Igor Mammedov
Quoted 8 lines · On Tue, 20 Jul 2021 20:16:44 +0200 Laurent Vivier <[email protected]> wrote:

This simple change allows to test failover with a simulated device like e1000e rather than a vfio device.

This is interesting to developers that want to test failover on a system with no vfio device. Moreover it simplifies host networking configuration as we can use the same bridge for virtio-net and the other failover networking device.

Quoted 8 lines

Without this change the migration of a system configured with failover fails with:

Unknown ramblock "0000:00:01.1:00.0/e1000e.rom", cannot accept migration error while loading state for instance 0x0 of device 'ram' load of migration failed: Invalid argument

Quoted 4 lines
---
 hw/net/virtio-net.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 13 lines
Quoted 9 lines

hw/net/virtio-net.c static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationState *s) · line 3259

Quoted 9 lines
hw/net/virtio-net.c +1 -0
index 16d20cdee52a..8f7735bad4f2 100644
@@ -3256,6 +3256,9 @@ static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationState *s)
     if (migration_in_setup(s) && !should_be_hidden) {
         if (failover_unplug_primary(n, dev)) {
             vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev);
+            if (PCI_DEVICE(dev)->has_rom) {

Hmm. Any way to hide this behind an interface so
we don't need to poke at pci device internals?

Quoted 3 lines

There is the pci_del_option_rom() but it's not exported.

Do you want I export and use it?

Looks cleaner indeed.