[PATCH 1/3] qemu: Init address before qemuProcessShutdownOrReboot during reconnect process

Jiang Jiacheng posted 3 patches 3 years, 4 months ago
There is a newer version of this series
[PATCH 1/3] qemu: Init address before qemuProcessShutdownOrReboot during reconnect process
Posted by Jiang Jiacheng 3 years, 4 months ago
When libvirt is restarted, the qemuProcessShutdownReboot command is
executed to restore the VM that is being restarted. In this case, a
coredump may occur when we hotplug a pci device since the PCI address
hasn't be inited yet. Moving the initialization of address to the front
of qemuProcessShutdownOrReboot to ensure that we have the address inited.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
---
 src/qemu/qemu_process.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 32f03ff79a..6c93f28a9e 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8784,6 +8784,11 @@ qemuProcessReconnect(void *opaque)
         goto error;
     }
 
+    if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps,
+                                   driver, obj, false)) < 0) {
+        goto error;
+    }
+
     /* In case the domain shutdown or fake reboot while we were not running,
      * we need to finish the shutdown or fake reboot process. And we need to
      * do it after we have virQEMUCaps filled in.
@@ -8802,11 +8807,6 @@ qemuProcessReconnect(void *opaque)
     if (qemuProcessBuildDestroyMemoryPaths(driver, obj, NULL, true) < 0)
         goto error;
 
-    if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps,
-                                   driver, obj, false)) < 0) {
-        goto error;
-    }
-
     /* if domain requests security driver we haven't loaded, report error, but
      * do not kill the domain
      */
-- 
2.33.0
Re: [PATCH 1/3] qemu: Init address before qemuProcessShutdownOrReboot during reconnect process
Posted by Michal Prívozník 3 years, 4 months ago
On 9/28/22 15:53, Jiang Jiacheng wrote:
> When libvirt is restarted, the qemuProcessShutdownReboot command is
> executed to restore the VM that is being restarted. In this case, a
> coredump may occur when we hotplug a pci device since the PCI address
> hasn't be inited yet. Moving the initialization of address to the front
> of qemuProcessShutdownOrReboot to ensure that we have the address inited.
> 
> Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
> ---
>  src/qemu/qemu_process.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

and pushed.

Michal