From nobody Fri May 16 08:44:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1496824732130509.9611735855908; Wed, 7 Jun 2017 01:38:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD74D4DB15; Wed, 7 Jun 2017 08:38:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9242E5C54F; Wed, 7 Jun 2017 08:38:49 +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 C825318523C4; Wed, 7 Jun 2017 08:38:25 +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 v578brxX004867 for ; Wed, 7 Jun 2017 04:37:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F65582788; Wed, 7 Jun 2017 08:37:53 +0000 (UTC) Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7A6882793 for ; Wed, 7 Jun 2017 08:37:51 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7AF66101933; Wed, 7 Jun 2017 10:37:46 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BD74D4DB15 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BD74D4DB15 From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 7 Jun 2017 10:37:33 +0200 Message-Id: <46e323ed3fbbb350dd551d9546a5843cb1c128d4.1496824604.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 08/20] qemu: Introduce virQEMUSaveDataFinish 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 07 Jun 2017 08:38:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function is supposed to update the save image header after a successful migration to the save image file. Signed-off-by: Jiri Denemark --- Notes: Version 2: - new patch (separated from the original 06/15) src/qemu/qemu_driver.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index be6bedd6a..b51a41641 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2877,6 +2877,25 @@ qemuDomainSaveHeader(int fd, const char *path, const= char *xml, } =20 =20 +static int +virQEMUSaveDataFinish(virQEMUSaveHeaderPtr header, + int *fd, + const char *path) +{ + memcpy(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic)); + + if (safewrite(*fd, header, sizeof(*header)) !=3D sizeof(*header) || + VIR_CLOSE(*fd) < 0) { + virReportSystemError(errno, + _("failed to write header to domain save file= '%s'"), + path); + return -1; + } + + return 0; +} + + static virCommandPtr qemuCompressGetCommand(virQEMUSaveFormat compression) { @@ -3149,21 +3168,10 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver, if (virFileWrapperFdClose(wrapperFd) < 0) goto cleanup; =20 - if ((fd =3D qemuOpenFile(driver, vm, path, O_WRONLY, NULL, NULL)) < 0) + if ((fd =3D qemuOpenFile(driver, vm, path, O_WRONLY, NULL, NULL)) < 0 = || + virQEMUSaveDataFinish(header, &fd, path) < 0) goto cleanup; =20 - memcpy(header->magic, QEMU_SAVE_MAGIC, sizeof(header->magic)); - - if (safewrite(fd, &header, sizeof(header)) !=3D sizeof(header)) { - virReportSystemError(errno, _("unable to write %s"), path); - goto cleanup; - } - - if (VIR_CLOSE(fd) < 0) { - virReportSystemError(errno, _("unable to close %s"), path); - goto cleanup; - } - ret =3D 0; =20 cleanup: --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list