diff --git a/bugfix-fix-ProcessEventHandler-and-cfg-firmwares.patch b/bugfix-fix-ProcessEventHandler-and-cfg-firmwares.patch new file mode 100644 index 0000000000000000000000000000000000000000..46b22befcbeddaef0605c588e43a65fd379f6ebe --- /dev/null +++ b/bugfix-fix-ProcessEventHandler-and-cfg-firmwares.patch @@ -0,0 +1,123 @@ +From 2ed130a198d5a59bc6cc52978b089dada7144519 Mon Sep 17 00:00:00 2001 +From: mayunlong +Date: Thu, 8 Sep 2022 11:00:25 +0800 +Subject: [PATCH] bugfix: fix ProcessEventHandler and cfg firmwares + +--- + src/stratovirt/stratovirt_conf.c | 13 ++++++++ + src/stratovirt/stratovirt_driver.c | 53 +++++++++++++++++++++++++++++- + 2 files changed, 65 insertions(+), 1 deletion(-) + +diff --git a/src/stratovirt/stratovirt_conf.c b/src/stratovirt/stratovirt_conf.c +index 5c4028616d..f25fb102d2 100644 +--- a/src/stratovirt/stratovirt_conf.c ++++ b/src/stratovirt/stratovirt_conf.c +@@ -106,6 +106,11 @@ virStratoVirtDriverGetCapabilities(virStratoVirtDriverPtr driver, bool refresh) + return ret; + } + ++#ifndef DEFAULT_LOADER_NVRAM ++# define DEFAULT_LOADER_NVRAM \ ++ "/usr/share/edk2/ovmf/OVMF_CODE.fd:/usr/share/edk2/ovmf/OVMF_VARS.fd:" ++#endif ++ + virStratoVirtDriverConfigPtr virStratoVirtDriverConfigNew(bool privileged) + { + virStratoVirtDriverConfigPtr cfg = NULL; +@@ -217,6 +222,11 @@ virStratoVirtDriverConfigPtr virStratoVirtDriverConfigNew(bool privileged) + virBitmapSetBit(cfg->namespaces, 0) < 0) + return NULL; + ++ if (virFirmwareParseList(DEFAULT_LOADER_NVRAM, ++ &cfg->firmwares, ++ &cfg->nfirmwares) < 0) ++ return NULL; ++ + return g_steal_pointer(&cfg); + } + +@@ -246,6 +256,9 @@ static void virStratoVirtDriverConfigDispose(void *obj) + } + VIR_FREE(cfg->hugetlbfs); + VIR_FREE(cfg->autoDumpPath); ++ ++ virFirmwareFreeList(cfg->firmwares, cfg->nfirmwares); ++ + VIR_FREE(cfg->memoryBackingDir); + } + +diff --git a/src/stratovirt/stratovirt_driver.c b/src/stratovirt/stratovirt_driver.c +index a9d9303881..3a6e660c8f 100644 +--- a/src/stratovirt/stratovirt_driver.c ++++ b/src/stratovirt/stratovirt_driver.c +@@ -993,15 +993,66 @@ static int stratovirtSecurityInit(virStratoVirtDriverPtr driver) + return -1; + } + +-static void stratovirtProcessEventHandler(void *data, void *opaque G_GNUC_UNUSED) ++static void processMonitorEOFEvent(virStratoVirtDriverPtr driver, ++ virDomainObjPtr vm) ++{ ++ int stopReason = VIR_DOMAIN_SHUTOFF_SHUTDOWN; ++ const char *auditReason = "shutdown"; ++ unsigned int stopFlags = 0; ++ ++ if (stratovirtPro.stratovirtProcessBeginStopJob(driver, vm, STRATOVIRT_JOB_DESTROY, true) < 0) ++ return; ++ ++ if (!virDomainObjIsActive(vm)) { ++ VIR_DEBUG("Domain %p '%s' is not active, ignoring EOF", vm, vm->def->name); ++ goto endjob; ++ } ++ ++ if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_SHUTDOWN) { ++ VIR_DEBUG("Monitor connection to '%s' closed without SHUTDOWN event; " ++ "assuming the domain crashed", vm->def->name); ++ stopReason = VIR_DOMAIN_SHUTOFF_CRASHED; ++ auditReason = "failed"; ++ } ++ ++ stratovirtPro.stratovirtProcessStop(driver, vm, stopReason, ++ STRATOVIRT_ASYNC_JOB_NONE, ++ stopFlags); ++ virDomainAuditStop(vm, auditReason); ++ ++endjob: ++ stratovirtDom.stratovirtDomainRemoveInactive(driver, vm); ++ stratovirtDom.stratovirtDomainObjEndJob(driver, vm); ++} ++ ++static void stratovirtProcessEventHandler(void *data, void *opaque) + { + stratovirtProcessEventPtr processEvent = data; + virDomainObjPtr vm = processEvent->vm; ++ virStratoVirtDriverPtr driver = opaque; + + VIR_DEBUG("vm=%p, event=%d", vm, processEvent->eventType); + + virObjectLock(vm); + ++ switch (processEvent->eventType) { ++ case STRATOVIRT_PROCESS_EVENT_MONITOR_EOF: ++ processMonitorEOFEvent(driver, vm); ++ break; ++ case STRATOVIRT_PROCESS_EVENT_WATCHDOG: ++ case STRATOVIRT_PROCESS_EVENT_GUESTPANIC: ++ case STRATOVIRT_PROCESS_EVENT_DEVICE_DELETED: ++ case STRATOVIRT_PROCESS_EVENT_NIC_RX_FILTER_CHANGED: ++ case STRATOVIRT_PROCESS_EVENT_SERIAL_CHANGED: ++ case STRATOVIRT_PROCESS_EVENT_BLOCK_JOB: ++ case STRATOVIRT_PROCESS_EVENT_JOB_STATUS_CHANGE: ++ case STRATOVIRT_PROCESS_EVENT_PR_DISCONNECT: ++ case STRATOVIRT_PROCESS_EVENT_RDMA_GID_STATUS_CHANGED: ++ case STRATOVIRT_PROCESS_EVENT_GUEST_CRASHLOADED: ++ case STRATOVIRT_PROCESS_EVENT_LAST: ++ default: ++ break; ++ } + virDomainObjEndAPI(&vm); + stratovirtProcessEventFree(processEvent); + } +-- +2.25.1 + diff --git a/libvirt.spec b/libvirt.spec index 8ab5bae1c752a327a82cd8c23ecea32e2a99c5b6..ccaa3f2781b70a58edd732ff181672d443614ce1 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -102,7 +102,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 6.2.0 -Release: 44 +Release: 45 License: LGPLv2+ URL: https://libvirt.org/ @@ -258,6 +258,7 @@ Patch0144: Add-command-virsh-list-virsh-suspend-virsh-resume-an.patch Patch0145: qemu-Add-missing-lock-in-qemuProcessHandleMonitorEOF.patch Patch0146: Add-command-define-undefine-start-shutdown-in-strato.patch Patch0147: bugfix-fix-command-create-flags-undefine-flags-capsi.patch +Patch0148: bugfix-fix-ProcessEventHandler-and-cfg-firmwares.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2020,6 +2021,9 @@ exit 0 %changelog +* Fri Sep 16 2022 mayunlong - 6.2.0-45 +- bugfix: fix ProcessEventHandler and cfg firmwares + * Mon Aug 29 2022 mayunlong - 6.2.0-44 - add command define undefine start shutdown in stratovirt_driver - bugfix: fix command create flags/undefine flags/capsinit