From nobody Wed May 15 19:10:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1660217418; cv=none; d=zohomail.com; s=zohoarc; b=X3vwo69QSJN3stvyCLAlRpOa+EAzGSbxvlcXMJo8XpZ9cQHNMJaG5GN3Hr23ZIrpN4F23mhQY4RxWMoNlZxemi3RnT4dq8iZVJhzJt6zxLSCHFKxJkL4y+f9PPkraL2eSP5PlPV8Ow+5s553XO/yQMUHRokfDI31zhANLhV4LhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660217418; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Mk89DK3rrObGRchCWOJwMCYhIUvrOvVjEZixSMDx1cU=; b=hQFKRBLEXA72POudCFUplaRScrEOh2rqIsobHUpZF7yTIT+BKY3EfOsYEzXCiMdbBxK1FBpaWHqH+0I6QxATQzzBtlNH8EAPkMojL2tb/GVL6o7UARuXlzUIZNqzqsAliQ9NTUOJ/bYx5/hI7HNeoj5w9HBqte4hHCDigcLbdG0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1660217418709341.0517298251058; Thu, 11 Aug 2022 04:30:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-346-ICqcteD-PUCS2KFpysd5lA-1; Thu, 11 Aug 2022 07:30:15 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94214294EDDE; Thu, 11 Aug 2022 11:30:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A05D1945D2; Thu, 11 Aug 2022 11:30:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2CCB01946A53; Thu, 11 Aug 2022 11:30:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CAEC01946A41 for ; Thu, 11 Aug 2022 11:30:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 806D640CFD0A; Thu, 11 Aug 2022 11:30:09 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07AB940CF8E7 for ; Thu, 11 Aug 2022 11:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660217417; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Mk89DK3rrObGRchCWOJwMCYhIUvrOvVjEZixSMDx1cU=; b=QuQeitzraJBSa2pxoHFOzsWNDMeWjVvFeCwIvNJbrVIutOlqFwh3UOzOvoj/pz9NwBKBxx hvh8KZK9cCHhSDF8rUdDVaD5eVKUcFPvR320DJl258sAYMdHiMrzYOjZ2d4GGApVnahlhh 5MhxLTq0fwKUGTIWnYd0x4UwQXCjjDw= X-MC-Unique: ICqcteD-PUCS2KFpysd5lA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2] qemuDomainObjWait: Report error when VM is being destroyed Date: Thu, 11 Aug 2022 13:30:07 +0200 Message-Id: <22678872e5565e8e17da177ab52032e2a0c2a03a.1660217122.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660217420132100001 Content-Type: text/plain; charset="utf-8" Since we started handing the monitor EOF event inside a job any code which uses virDomainObjWait would no longer properly abort in case when the VM crashed during the wait. This is because virDomainObjWait uses virDomainObjIsActive which checks 'vm->def->id' to see if the VM is still active. Unfortunately the domain id is cleared in qemuProcessStop which is run only inside the job. To fix this we can use the 'beingDestroyed' flag stored in the VM private data which is set to true around the time when the condition is signalled. Reported-by: Pavel Hrdina Fixes: 8c9ff9960b29d4703a99efdd1cadcf6f48799cc0 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- v2: Fix condition in qemuMigrationSrcWaitForCompletion, where we check whether the VM is active to use same logic src/qemu/qemu_domain.c | 12 +++++++++++- src/qemu/qemu_migration.c | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2caed7315b..43b5ad5d6e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11780,5 +11780,15 @@ qemuDomainRemoveLogs(virQEMUDriver *driver, int qemuDomainObjWait(virDomainObj *vm) { - return virDomainObjWait(vm); + qemuDomainObjPrivate *priv =3D vm->privateData; + + if (virDomainObjWait(vm) < 0) + return -1; + + if (priv->beingDestroyed) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("domain is not ru= nning")); + return -1; + } + + return 0; } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 0b48852b9d..8a8e9ab207 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2078,7 +2078,7 @@ qemuMigrationSrcWaitForCompletion(virDomainObj *vm, return rv; if (qemuDomainObjWait(vm) < 0) { - if (virDomainObjIsActive(vm)) + if (virDomainObjIsActive(vm) && !priv->beingDestroyed) jobData->status =3D VIR_DOMAIN_JOB_STATUS_FAILED; return -2; } --=20 2.37.1