From 64bf4fb8f4097cc554f1f8326693dd7c62ef8c4e Mon Sep 17 00:00:00 2001 From: Li Fei1 Date: Wed, 26 Feb 2020 17:17:55 +0800 Subject: [PATCH] dm: don't deassign pass through PCIe device in DM Let the ACRN HV to do this in shutdown sequence. In this case, the RTVM could be still alive if something wrong happened to cause the DM died. Tracked-On: #4428 Signed-off-by: Li Fei1 --- devicemodel/core/main.c | 3 ++- devicemodel/hw/pci/passthrough.c | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/devicemodel/core/main.c b/devicemodel/core/main.c index 2ac893f40..f2b30e0d3 100644 --- a/devicemodel/core/main.c +++ b/devicemodel/core/main.c @@ -686,7 +686,8 @@ vm_loop(struct vmctx *ctx) break; } - if (VM_SUSPEND_SYSTEM_RESET == vm_get_suspend_mode()) { + /* RTVM can't be reset */ + if ((VM_SUSPEND_SYSTEM_RESET == vm_get_suspend_mode()) && (!is_rtvm)) { vm_system_reset(ctx); } diff --git a/devicemodel/hw/pci/passthrough.c b/devicemodel/hw/pci/passthrough.c index cf754233d..2c04a051e 100644 --- a/devicemodel/hw/pci/passthrough.c +++ b/devicemodel/hw/pci/passthrough.c @@ -45,6 +45,7 @@ #include "pciio.h" #include "pci_core.h" #include "acpi.h" +#include "dm.h" /* Some audio drivers get topology data from ACPI NHLT table. @@ -558,7 +559,13 @@ passthru_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts) pcidev.phys_bdf = ptdev->phys_bdf; pciaccess_cleanup(); free(ptdev); - vm_deassign_pcidev(ctx, &pcidev); + + if (!is_rtvm) { + /* Let the HV to deassign the pt device for RTVM, In this case, the RTVM + * could still be alive if DM died. + */ + vm_deassign_pcidev(ctx, &pcidev); + } } /* bind pin info for pass-through device */