Skip to contentSkip to conversation

vhost: fix a migration failed because of vhost region merge

PATCH In review Peng Hao 3 participants 13 messages Jul 23, 2017 – Jul 28, 2017

lore
Share & tools
lore

Peng Hao

author
#0 lore raw

PATCH v2 1/1 vhost: fix a migration failed because of vhost region merge

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +1 -1
index ea67b46..13f3db5 100644
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out;
     }
 
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left");
         goto out;
include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info);
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
 
+bool qemu_is_machine_init_done(void);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done;
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done;
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 20 lines · On Sun, 23 Jul 2017 20:46:11 +0800 Peng Hao <[email protected]> wrote:

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, · line 106

Quoted 7 lines
hw/mem/pc-dimm.c +1 -1
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out;
     }
 
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left");

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime
2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

Quoted 29 lines
hw/mem/pc-dimm.c +0 -0
         goto out;
include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info);
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
 
+bool qemu_is_machine_init_done(void);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done;
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done;
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify);
#2 lore raw

Re: [Qemu-devel] [PATCH V2] vhost: fix a migration failed becauseof vhost region merge

Quoted 31 lines

On Sun, 23 Jul 2017 20:46:11 +0800

Quoted 23 lines · Peng Hao

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out
     }
 
Quoted 13 lines

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,

Quoted 4 lines
hw/mem/pc-dimm.c +1 -1
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left")

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime
2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in
guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

I don't think I undo the previous patch. There are tow scenarios :

hotplugging memory happens after machine_init_done(). so the modified code is no

influence.

hotplugged memory's VM is just migrated . on source its regions is less than

supported by backend ,so on destination it should satisfy. During restoring VM's regions

may be more than supported by backend but after machine_init_done VM's regions

can be less than supported by backend.

Quoted 29 lines

goto out

include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
 void qemu_add_exit_notifier(Notifier *notify)
 void qemu_remove_exit_notifier(Notifier *notify)
 
+bool qemu_is_machine_init_done(void)
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 void qemu_remove_machine_init_done_notifier(Notifier *notify)
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify)
#3 lore raw

Re: [Qemu-devel] [PATCH V2] vhost: fix a migration failed becauseof vhost region merge

Quoted 52 lines · On Mon, 24 Jul 2017 18:32:35 +0800 (CST) <[email protected]> wrote:
Quoted 31 lines

On Sun, 23 Jul 2017 20:46:11 +0800

Quoted 23 lines · Peng Hao

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out
     }
 
Quoted 13 lines

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,

Quoted 4 lines
hw/mem/pc-dimm.c +1 -1
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left")  

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime
2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in
guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

I don't think I undo the previous patch. There are tow scenarios :

hotplugging memory happens after machine_init_done(). so the modified code is no

influence.

hotplugged memory's VM is just migrated . on source its regions is less than

Quoted 7 lines

supported by backend ,so on destination it should satisfy. During restoring VM's regions

may be more than supported by backend but after machine_init_done VM's regions

can be less than supported by backend.

here is simulation with vhost-kernel where /sys/module/vhost/parameters/max_mem_regions set to 8 for limit to look like vhost user.

qemu-system-x86_64 --enable-kvm -m 128,slots=256,maxmem=1T \
-netdev type=tap,id=guest0,vhost=on,script=/bin/true,vhostforce \
-device virtio-net-pci,netdev=guest0 \
i=0; while [ $i -lt 10 ]; do echo "-object memory-backend-ram,id=m$i,size=128M -device pc-dimm,id=d$i,memdev=m$i"; i=$(($i + 1)); done

it end ups with 12 used_memslots, and prints following error messages:

qemu-system-x86_64: vhost_set_mem_table failed: Argument list too long (7)
qemu-system-x86_64: unable to start vhost net: 7: falling back on userspace virtio

above CLI should fail to startup as it's above supported limit even with merging (with merging available slots is 'random' number and merging could happen regardless of the order devices are created).

vhost_dev_init() also has checks vhost_backend_memslots_limit(), and skipping check in pc_dimm_memory_plug() might lead to failure later in vhost_dev_init() - I'm not sure when it's called and to what consequences it would lead.

Quoted 29 lines
Quoted 29 lines

goto out

include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
 void qemu_add_exit_notifier(Notifier *notify)
 void qemu_remove_exit_notifier(Notifier *notify)
 
+bool qemu_is_machine_init_done(void)
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 void qemu_remove_machine_init_done_notifier(Notifier *notify)
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify  
#4 lore raw

Re: [Qemu-devel] [PATCH V2] vhost: fix a migration failedbecauseof vhost region merge

Quoted 58 lines

On Mon, 24 Jul 2017 18:32:35 +0800 (CST)

Quoted 50 lines · <[email protected]> wrote:
Quoted 27 lines

On Sun, 23 Jul 2017 20:46:11 +0800

Quoted 23 lines · Peng Hao

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out
     }
 
Quoted 13 lines

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,

Quoted 4 lines
hw/mem/pc-dimm.c +1 -1
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left")  

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime
2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in
guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

I don't think I undo the previous patch. There are tow scenarios :

hotplugging memory happens after machine_init_done(). so the modified code is no

influence.

hotplugged memory's VM is just migrated . on source its regions is less than

supported by backend ,so on destination it should satisfy. During restoring VM's regions

Quoted 9 lines
Quoted 3 lines

may be more than supported by backend but after machine_init_done VM's regions

can be less than supported by backend.

here is simulation with vhost-kernel where /sys/module/vhost/parameters/max_mem_regions set to 8 for limit to look like vhost user.

qemu-system-x86_64 --enable-kvm -m 128,slots=256,maxmem=1T \

Quoted 1 line

-netdev type=tap,id=guest0,vhost=on,script=/bin/true,vhostforce \

-device virtio-net-pci,netdev=guest0 \

Quoted 11 lines

i=0 while [ $i -lt 10 ] do echo "-object memory-backend-ram,id=m$i,size=128M -device pc-dimm,id=d$i,memdev=m$i" i=$(($i + 1)) done

it end ups with 12 used_memslots, and prints following error messages:
qemu-system-x86_64: vhost_set_mem_table failed: Argument list too long (7)
qemu-system-x86_64: unable to start vhost net: 7: falling back on userspace virtio

above CLI should fail to startup as it's above supported limit even with merging (with merging available slots is 'random' number and merging could happen regardless of the order devices are created).

Quoted 4 lines

vhost_dev_init() also has checks vhost_backend_memslots_limit(), and skipping check in pc_dimm_memory_plug() might lead to failure later in vhost_dev_init() - I'm not sure when it's called and to what consequences it would lead.

I don't think we describe the same scenario.I mean hotplugged mem VM on source is less than limit,

and after migration on destination VM should satisfy the limit.

before vhost_dev_init all devices initialization don't affect vhost used_memslots statistics

(because no vhost device). so when vhost_dev_init is called, vhost used_memslots statistics is zero.

I test in my migration scenario.

after migration on destination, print used_memslots in vhost_set_memory like this (with my patch)

used_memslots : 1

used_memslots : 2

used_memslots : 1

used_memslots : 2

used_memslots : 3

used_memslots : 4

used_memslots : 5

used_memslots : 6

used_memslots : 7

used_memslots : 8

used_memslots : 9

used_memslots : 10

used_memslots : 9

used_memslots : 10

used_memslots : 9

used_memslots : 10

used_memslots : 11

used_memslots : 12

used_memslots : 11

used_memslots : 10

used_memslots : 9

used_memslots : 9

used_memslots : 9

used_memslots : 9

used_memslots : 8

Quoted 29 lines
Quoted 29 lines

goto out

include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
 void qemu_add_exit_notifier(Notifier *notify)
 void qemu_remove_exit_notifier(Notifier *notify)
 
+bool qemu_is_machine_init_done(void)
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 void qemu_remove_machine_init_done_notifier(Notifier *notify)
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify
#5 lore raw

Re: [Qemu-devel] [PATCH V2] vhost: fix a migration failed becauseof vhost region merge

In reply to Igor Mammedov
Quoted 71 lines · Igor Mammedov
Quoted 52 lines · On Mon, 24 Jul 2017 18:32:35 +0800 (CST) <[email protected]> wrote:
Quoted 31 lines

On Sun, 23 Jul 2017 20:46:11 +0800

Quoted 23 lines · Peng Hao

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out
     }
 
Quoted 13 lines

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,

Quoted 4 lines
hw/mem/pc-dimm.c +1 -1
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left")  

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime
2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in
guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

I don't think I undo the previous patch. There are tow scenarios :

hotplugging memory happens after machine_init_done(). so the modified code is no

influence.

hotplugged memory's VM is just migrated . on source its regions is less than

Quoted 7 lines

supported by backend ,so on destination it should satisfy. During restoring VM's regions

may be more than supported by backend but after machine_init_done VM's regions

can be less than supported by backend.

here is simulation with vhost-kernel where /sys/module/vhost/parameters/max_mem_regions set to 8 for limit to look like vhost user.

qemu-system-x86_64 --enable-kvm -m 128,slots=256,maxmem=1T \
-netdev type=tap,id=guest0,vhost=on,script=/bin/true,vhostforce \
-device virtio-net-pci,netdev=guest0 \
i=0; while [ $i -lt 10 ]; do echo "-object memory-backend-ram,id=m$i,size=128M -device pc-dimm,id=d$i,memdev=m$i"; i=$(($i + 1)); done

Quoted 8 lines

it end ups with 12 used_memslots, and prints following error messages:

qemu-system-x86_64: vhost_set_mem_table failed: Argument list too long (7)
qemu-system-x86_64: unable to start vhost net: 7: falling back on userspace virtio

above CLI should fail to startup as it's above supported limit even with merging (with merging available slots is 'random' number and merging could happen regardless of the order devices are created).

Without hotplug there is not need to fail it early at all. It should fail in vhost, need to debug it - falling back should only happen when vhost is not forced.

Quoted 5 lines

vhost_dev_init() also has checks vhost_backend_memslots_limit(), and skipping check in pc_dimm_memory_plug() might lead to failure later in vhost_dev_init() - I'm not sure when it's called and to what consequences it would lead.

It should fail cleanly. Only reason for your patch is for memory hotplug where it's too late to stop vhost.

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines

goto out

include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
 void qemu_add_exit_notifier(Notifier *notify)
 void qemu_remove_exit_notifier(Notifier *notify)
 
+bool qemu_is_machine_init_done(void)
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 void qemu_remove_machine_init_done_notifier(Notifier *notify)
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify  
#6 lore raw
In reply to Igor Mammedov
Quoted 26 lines · Igor Mammedov
Quoted 23 lines · On Sun, 23 Jul 2017 20:46:11 +0800 Peng Hao <[email protected]> wrote:

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out;
     }
 
Quoted 7 lines

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, · line 106

Quoted 4 lines
hw/mem/pc-dimm.c +1 -1
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left");

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime

But that's fine, we want hotplug to fail if we can not guarantee vhost will work.

Quoted 6 lines

2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

Why does it? The issue you fixed there is hotplug, and that means pc_dimm_memory_plug called after machine done.

Quoted 30 lines
Quoted 30 lines
hw/mem/pc-dimm.c +0 -0
         goto out;
include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info);
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
 
+bool qemu_is_machine_init_done(void);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done;
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done;
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify);
#7 lore raw
Quoted 35 lines · On Mon, 24 Jul 2017 23:50:00 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 26 lines · Igor Mammedov
Quoted 23 lines · On Sun, 23 Jul 2017 20:46:11 +0800 Peng Hao <[email protected]> wrote:

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out;
     }
 
Quoted 7 lines

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, · line 106

Quoted 4 lines
hw/mem/pc-dimm.c +1 -1
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left");  

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime

Quoted 2 lines

But that's fine, we want hotplug to fail if we can not guarantee vhost will work.

don't we want guarantee that vhost will work with dimm devices at startup if it were requested on CLI or fail startup cleanly if it can't?

Quoted 10 lines
Quoted 7 lines

2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

Why does it? The issue you fixed there is hotplug, and that means pc_dimm_memory_plug called after machine done.

I wasn't able to crash fc24 guest with current qemu/rhen7 kernel, it fallbacks back to virtio and switches off vhost.

Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
hw/mem/pc-dimm.c +0 -0
         goto out;
include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info);
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
 
+bool qemu_is_machine_init_done(void);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done;
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done;
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify);  
#8 lore raw
Quoted 38 lines · Igor Mammedov
Quoted 35 lines · On Mon, 24 Jul 2017 23:50:00 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 33 lines · Igor Mammedov
Quoted 20 lines · On Sun, 23 Jul 2017 20:46:11 +0800 Peng Hao <[email protected]> wrote:

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, · line 106

Quoted 7 lines
hw/mem/pc-dimm.c +1 -1
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out;
     }
 
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left");  

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime

Quoted 4 lines
Quoted 2 lines

But that's fine, we want hotplug to fail if we can not guarantee vhost will work.

don't we want guarantee that vhost will work with dimm devices at startup if it were requested on CLI or fail startup cleanly if it can't?

Yes. And failure to start vhost will achieve this without need to much with DIMMs. The issue is only with DIMM hotplug when vhost is already running, specifically because notifiers have no way to report or handle errors.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

Quoted 4 lines
Quoted 2 lines

Why does it? The issue you fixed there is hotplug, and that means pc_dimm_memory_plug called after machine done.

I wasn't able to crash fc24 guest with current qemu/rhen7 kernel, it fallbacks back to virtio and switches off vhost.

I think vhostforce should make vhost fail and not fall back, but that is another bug.

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
hw/mem/pc-dimm.c +0 -0
         goto out;
include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info);
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
 
+bool qemu_is_machine_init_done(void);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done;
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done;
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify);  
#9 lore raw
Quoted 56 lines · On Tue, 25 Jul 2017 22:47:18 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 38 lines · Igor Mammedov
Quoted 35 lines · On Mon, 24 Jul 2017 23:50:00 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 33 lines · Igor Mammedov
Quoted 20 lines · On Sun, 23 Jul 2017 20:46:11 +0800 Peng Hao <[email protected]> wrote:

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, · line 106

Quoted 7 lines
hw/mem/pc-dimm.c +1 -1
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out;
     }
 
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left");    

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime

Quoted 4 lines
Quoted 2 lines

But that's fine, we want hotplug to fail if we can not guarantee vhost will work.

don't we want guarantee that vhost will work with dimm devices at startup if it were requested on CLI or fail startup cleanly if it can't?

Yes. And failure to start vhost will achieve this without need to much with DIMMs. The issue is only with DIMM hotplug when vhost is already running, specifically because notifiers have no way to report or handle errors.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Why does it? The issue you fixed there is hotplug, and that means pc_dimm_memory_plug called after machine done.

I wasn't able to crash fc24 guest with current qemu/rhen7 kernel, it fallbacks back to virtio and switches off vhost.

I think vhostforce should make vhost fail and not fall back, but that is another bug.

currently vhostforce is broken, qemu continues to happily run with this patch and without patch it fails to start up so I'd just NACK this patch on this behavioral change and ask to fix both issues in the same series.

While looking at vhost memmap, I've also noticed that option rom "pc.rom" maps/remaps it self multiple times and it affects number of vhost mem map slots. I suspect that vhost is not interested in accessing pc.rom occupied memory and to hide it from vhost we need to make it RO. Also looking at roms initialization I've noticed that roms are typically mapped as RO if PCI is enabled. Taking in account that vhost is available only when PCI is enabled could be following patch be acceptable:

hw/i386/pc.c +3 -0
index e3fcd51..de459e2 100644
@@ -1449,6 +1449,9 @@ void pc_memory_init(PCMachineState *pcms,
     option_rom_mr = g_malloc(sizeof(*option_rom_mr));
     memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE,
                            &error_fatal);
+    if (pcmc->pci_enabled) {
+        memory_region_set_readonly(option_rom_mr, true);
+    }
     vmstate_register_ram_global(option_rom_mr);
     memory_region_add_subregion_overlap(rom_memory,
                                         PC_ROM_MIN_VGA,

it will keep ROM as RW on isa machine but RO for the rest PCI based.

Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
hw/mem/pc-dimm.c +0 -0
         goto out;
include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info);
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
 
+bool qemu_is_machine_init_done(void);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done;
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done;
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify);    
#10 lore raw
Quoted 61 lines · Igor Mammedov
Quoted 58 lines · On Tue, 25 Jul 2017 22:47:18 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 38 lines · Igor Mammedov
Quoted 35 lines · On Mon, 24 Jul 2017 23:50:00 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 33 lines · Igor Mammedov
Quoted 20 lines · On Sun, 23 Jul 2017 20:46:11 +0800 Peng Hao <[email protected]> wrote:

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, · line 106

Quoted 7 lines
hw/mem/pc-dimm.c +1 -1
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out;
     }
 
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left");    

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime

Quoted 4 lines
Quoted 2 lines

But that's fine, we want hotplug to fail if we can not guarantee vhost will work.

don't we want guarantee that vhost will work with dimm devices at startup if it were requested on CLI or fail startup cleanly if it can't?

Yes. And failure to start vhost will achieve this without need to much with DIMMs. The issue is only with DIMM hotplug when vhost is already running, specifically because notifiers have no way to report or handle errors.

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines

2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

Why does it? The issue you fixed there is hotplug, and that means pc_dimm_memory_plug called after machine done.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I wasn't able to crash fc24 guest with current qemu/rhen7 kernel, it fallbacks back to virtio and switches off vhost.

I think vhostforce should make vhost fail and not fall back, but that is another bug.

currently vhostforce is broken, qemu continues to happily run with this patch and without patch it fails to start up so I'd just NACK this patch on this behavioral change and ask to fix both issues in the same series.

Please do not send nacks. They are not really helpful.

Ack is like +1. You save some space since all you are saying is "all's well". But if there's an issue you want to explain what it is 99% of the time. So nack does not save any space and just pushes contributors away. Especially if it's in all caps, that's just against netiquette.

Quoted 26 lines

While looking at vhost memmap, I've also noticed that option rom "pc.rom" maps/remaps it self multiple times and it affects number of vhost mem map slots. I suspect that vhost is not interested in accessing pc.rom occupied memory and to hide it from vhost we need to make it RO. Also looking at roms initialization I've noticed that roms are typically mapped as RO if PCI is enabled. Taking in account that vhost is available only when PCI is enabled could be following patch be acceptable:

hw/i386/pc.c +3 -0
index e3fcd51..de459e2 100644
@@ -1449,6 +1449,9 @@ void pc_memory_init(PCMachineState *pcms,
     option_rom_mr = g_malloc(sizeof(*option_rom_mr));
     memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE,
                            &error_fatal);
+    if (pcmc->pci_enabled) {
+        memory_region_set_readonly(option_rom_mr, true);
+    }
     vmstate_register_ram_global(option_rom_mr);
     memory_region_add_subregion_overlap(rom_memory,
                                         PC_ROM_MIN_VGA,
Quoted 1 line

it will keep ROM as RW on isa machine but RO for the rest PCI based.

Makes sense.

Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
hw/mem/pc-dimm.c +0 -0
         goto out;
include/sysemu/sysemu.h +1 -0
index b213696..48228ad 100644
@@ -88,6 +88,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info);
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
 
+bool qemu_is_machine_init_done(void);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
vl.c +5 -0
index fb6b2ef..43aee22 100644
@@ -2681,6 +2681,11 @@ static void qemu_run_exit_notifiers(void)
 
 static bool machine_init_done;
 
+bool qemu_is_machine_init_done(void)
+{
+    return machine_init_done;
+}
+
 void qemu_add_machine_init_done_notifier(Notifier *notify)
 {
     notifier_list_add(&machine_init_done_notifiers, notify);    
#11 lore raw
Quoted 71 lines · On Wed, 26 Jul 2017 19:01:39 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 61 lines · Igor Mammedov
Quoted 58 lines · On Tue, 25 Jul 2017 22:47:18 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 38 lines · Igor Mammedov
Quoted 35 lines · On Mon, 24 Jul 2017 23:50:00 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 33 lines · Igor Mammedov
Quoted 20 lines · On Sun, 23 Jul 2017 20:46:11 +0800 Peng Hao <[email protected]> wrote:

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, · line 106

Quoted 7 lines
hw/mem/pc-dimm.c +1 -1
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out;
     }
 
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left");      

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime

Quoted 4 lines
Quoted 2 lines

But that's fine, we want hotplug to fail if we can not guarantee vhost will work.

don't we want guarantee that vhost will work with dimm devices at startup if it were requested on CLI or fail startup cleanly if it can't?

Yes. And failure to start vhost will achieve this without need to much with DIMMs. The issue is only with DIMM hotplug when vhost is already running, specifically because notifiers have no way to report or handle errors.

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines

2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

Why does it? The issue you fixed there is hotplug, and that means pc_dimm_memory_plug called after machine done.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I wasn't able to crash fc24 guest with current qemu/rhen7 kernel, it fallbacks back to virtio and switches off vhost.

I think vhostforce should make vhost fail and not fall back, but that is another bug.

currently vhostforce is broken, qemu continues to happily run with this patch and without patch it fails to start up so I'd just NACK this patch on this behavioral change and ask to fix both issues in the same series.

Quoted 6 lines

Please do not send nacks. They are not really helpful.

Ack is like +1. You save some space since all you are saying is "all's well". But if there's an issue you want to explain what it is 99% of the time. So nack does not save any space and just pushes contributors away. Especially if it's in all caps, that's just against netiquette.

I'm sorry to the author if it were taken as offense,
an intent was to say that by itself patch allows to start QEMU in invalid configuration and that it should be fixed as well.

Anyway I've just posted an alternative patch that should workaround issue at the hand while not removing check:
[PATCH for 2.10] pc: make 'pc.rom' readonly when machine has PCI enabled

Peng Hao,
could you check if it solves the problem for you

#12 lore raw

Re: [Qemu-devel] [PATCH V2] vhost: fix a migration failed becauseof vhost region merge

Quoted 89 lines

On Wed, 26 Jul 2017 19:01:39 +0300

Quoted 71 lines · Michael S. Tsirkin
Quoted 61 lines · Igor Mammedov
Quoted 58 lines · On Tue, 25 Jul 2017 22:47:18 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 38 lines · Igor Mammedov
Quoted 35 lines · On Mon, 24 Jul 2017 23:50:00 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 33 lines · Igor Mammedov
Quoted 20 lines · On Sun, 23 Jul 2017 20:46:11 +0800 Peng Hao <[email protected]> wrote:

When a guest that has several hotplugged dimms is migrated, on destination it will fail to resume. Because regions on source are merged and on destination the order of realizing devices is different from on source with dimms, so when part of devices are realizd some region can not be merged.That may be more than vhost slot limit.

---
 hw/mem/pc-dimm.c        | 2 +-
 include/sysemu/sysemu.h | 1 +
 vl.c                    | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +0 -0
index ea67b46..13f3db5 100644

hw/mem/pc-dimm.c void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, · line 106

Quoted 7 lines
hw/mem/pc-dimm.c +1 -1
@@ -101,7 +101,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
         goto out
     }
 
-    if (!vhost_has_free_slot()) {
+    if (!vhost_has_free_slot() && qemu_is_machine_init_done()) {
         error_setg(&local_err, "a used vhost backend has no free"
                                " memory slots left")      

that doesn't fix issue,
1st: number of used entries is changing after machine_init_done() is called
as regions continue to mapped/unmapped during runtime

Quoted 4 lines
Quoted 2 lines

But that's fine, we want hotplug to fail if we can not guarantee vhost will work.

don't we want guarantee that vhost will work with dimm devices at startup if it were requested on CLI or fail startup cleanly if it can't?

Yes. And failure to start vhost will achieve this without need to much with DIMMs. The issue is only with DIMM hotplug when vhost is already running, specifically because notifiers have no way to report or handle errors.

Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

2nd: it brings regression and allows to start QEMU with number memory
regions more than supported by backend, which combined with missing error handling in vhost will lead to qemu crashes or obscure bugs in guest breaking vhost enabled drivers.
i.e. patch undoes what were fixed by
https://lists.gnu.org/archive/html/qemu-devel/2015-10/msg00789.html

Why does it? The issue you fixed there is hotplug, and that means pc_dimm_memory_plug called after machine done.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I wasn't able to crash fc24 guest with current qemu/rhen7 kernel, it fallbacks back to virtio and switches off vhost.

I think vhostforce should make vhost fail and not fall back, but that is another bug.

currently vhostforce is broken, qemu continues to happily run with this patch and without patch it fails to start up so I'd just NACK this patch on this behavioral change and ask to fix both issues in the same series.

Quoted 6 lines

Please do not send nacks. They are not really helpful.

Ack is like +1. You save some space since all you are saying is "all's well". But if there's an issue you want to explain what it is 99% of the time. So nack does not save any space and just pushes contributors away. Especially if it's in all caps, that's just against netiquette.

I'm sorry to the author if it were taken as offense,
an intent was to say that by itself patch allows to start QEMU in invalid configuration and that it should be fixed as well.

Quoted 6 lines

Anyway I've just posted an alternative patch that should workaround issue at the hand while not removing check:
[PATCH for 2.10] pc: make 'pc.rom' readonly when machine has PCI enabled

Peng Hao,
could you check if it solves the problem for you

yes,it works. I never think of it before.

Thanks. Mst,too.

.