From nobody Sun Feb 8 23:26:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1596707737; cv=none; d=zohomail.com; s=zohoarc; b=JqKDtvYRIZqubeSc7LWUUrIiK2QNsApag8eQqhJdTFwNmkhvwvklRpTpo2tZqgnLscI29H0SPSCVOXpOxMm2B9lBoGbEPTAoj77eZGlxfDaI/FY7Hsmx7CeFchXzJZDi0feKrEo12gGcqO9eJ8BjGSyAai9UYXE8cLzqxx6hGOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596707737; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7g29VaOQk2iBF0BIptjYu4USm22PzRccS0fcJIeNiuc=; b=fw+t6kRpzTK2xA3BEGc2YMAgiSpwQX1aoUNhjzztHI+u4qkqtKh66PYqXojjOXZLo0dKOWZMxVXuSl8PN3i6qJULZFRcvHRqe0OlIl++DYEou2QyYQagBn2WrNo/cb5JSLfeQthxMjQQ9GICn6Esj/KKdTczPXlUmu8m5sIo1yc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1596707737137567.7533371645582; Thu, 6 Aug 2020 02:55:37 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-lJh9Mip7MsOxV0GF_gKrvw-1; Thu, 06 Aug 2020 05:55:33 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D233100AA22; Thu, 6 Aug 2020 09:55:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 690FB1001B2C; Thu, 6 Aug 2020 09:55:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0B5F09692F; Thu, 6 Aug 2020 09:55:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0769tPxm024685 for ; Thu, 6 Aug 2020 05:55:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DAEC60BF3; Thu, 6 Aug 2020 09:55:25 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 601F870105 for ; Thu, 6 Aug 2020 09:55:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596707736; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7g29VaOQk2iBF0BIptjYu4USm22PzRccS0fcJIeNiuc=; b=NUHSXHa6b3oLWkscoZS/Pj7nQaurssn5Ixm9DR1qpSKy6ToNmPde9r1gKA9zTLNN1Lhv4Z 0jgD8BS7dYNuJDj6ITHrAeoDQ9et7o/dTm+U9n51jwXpSAtFm1+Wh/mPbLOt05uKeBNoAs +JnLID5mYU9AEeD1F4ST9rHNz3vyW/k= X-MC-Unique: lJh9Mip7MsOxV0GF_gKrvw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/5] qemuFileWrapperFDClose: move to qemu_domain.c Date: Thu, 6 Aug 2020 11:55:14 +0200 Message-Id: <8a91bed9c9a784df0c68400735f30f52d8b2da16.1596707671.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move the code to qemu_domain.c so that it can be reused in other parts of the qemu driver. 'qemu_domain' was chosen as we check the domain state after closing the wrapper. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 28 ++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ src/qemu/qemu_driver.c | 36 ++++-------------------------------- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 670db6ebfb..e28f704dba 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10721,3 +10721,31 @@ qemuDomainOpenFile(virQEMUDriverPtr driver, return virQEMUFileOpenAs(user, group, dynamicOwnership, path, oflags, needUnlink); } + + +int +qemuDomainFileWrapperFDClose(virDomainObjPtr vm, + virFileWrapperFdPtr fd) +{ + int ret; + + /* virFileWrapperFd uses iohelper to write data onto disk. + * However, iohelper calls fdatasync() which may take ages to + * finish. Therefore, we shouldn't be waiting with the domain + * object locked. */ + + /* XXX Currently, this function is intended for *Save() only + * as restore needs some reworking before it's ready for + * this. */ + + virObjectUnlock(vm); + ret =3D virFileWrapperFdClose(fd); + virObjectLock(vm); + if (!virDomainObjIsActive(vm)) { + if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("domain is no longer running")); + ret =3D -1; + } + return ret; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index ef03702fa1..e4c22864dc 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1024,3 +1024,7 @@ qemuDomainOpenFile(virQEMUDriverPtr driver, const char *path, int oflags, bool *needUnlink); + +int +qemuDomainFileWrapperFDClose(virDomainObjPtr vm, + virFileWrapperFdPtr fd); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0bc7eebe9a..8f61759f53 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3022,34 +3022,6 @@ qemuCompressGetCommand(virQEMUSaveFormat compression) } -static int -qemuFileWrapperFDClose(virDomainObjPtr vm, - virFileWrapperFdPtr fd) -{ - int ret; - - /* virFileWrapperFd uses iohelper to write data onto disk. - * However, iohelper calls fdatasync() which may take ages to - * finish. Therefore, we shouldn't be waiting with the domain - * object locked. */ - - /* XXX Currently, this function is intended for *Save() only - * as restore needs some reworking before it's ready for - * this. */ - - virObjectUnlock(vm); - ret =3D virFileWrapperFdClose(fd); - virObjectLock(vm); - if (!virDomainObjIsActive(vm)) { - if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("domain is no longer running")); - ret =3D -1; - } - return ret; -} - - /* Helper function to execute a migration to file with a correct save head= er * the caller needs to make sure that the processors are stopped and do al= l other * actions besides saving memory */ @@ -3111,7 +3083,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver, goto cleanup; } - if (qemuFileWrapperFDClose(vm, wrapperFd) < 0) + if (qemuDomainFileWrapperFDClose(vm, wrapperFd) < 0) goto cleanup; if ((fd =3D qemuDomainOpenFile(driver, vm, path, O_WRONLY, NULL)) < 0 = || @@ -3122,7 +3094,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver, cleanup: VIR_FORCE_CLOSE(fd); - if (qemuFileWrapperFDClose(vm, wrapperFd) < 0) + if (qemuDomainFileWrapperFDClose(vm, wrapperFd) < 0) ret =3D -1; virFileWrapperFdFree(wrapperFd); @@ -3703,14 +3675,14 @@ doCoreDump(virQEMUDriverPtr driver, path); goto cleanup; } - if (qemuFileWrapperFDClose(vm, wrapperFd) < 0) + if (qemuDomainFileWrapperFDClose(vm, wrapperFd) < 0) goto cleanup; ret =3D 0; cleanup: VIR_FORCE_CLOSE(fd); - if (qemuFileWrapperFDClose(vm, wrapperFd) < 0) + if (qemuDomainFileWrapperFDClose(vm, wrapperFd) < 0) ret =3D -1; virFileWrapperFdFree(wrapperFd); if (ret !=3D 0) --=20 2.26.2