From nobody Sun Apr 28 22:56:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1587994927; cv=none; d=zohomail.com; s=zohoarc; b=TU+/SgLL/xPaljeeWaJAI/TuArlY25btZ4K50wKwASbdd6PtzfTTG2a+8Hby7/NR9eZPeMuUcDLo+0unbLTo8JTQG8mssEQjcSuzI+R2vVpjNt9msTdJ6ntI7TDcr7nQZ3zWeepeERGxBb3uij8AFZNU1h/3puzpABy5V26QeAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587994927; 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=o2YeoqhrBxGfz9zPzUbabvmCn+mqOQlq/JWhKsHpNko=; b=bRVBevRIQuCJke9/lv49L1uryta51dldZyyQZS3fj9ujgVa16o+V3WsHqZVq2TC7+b13y6ZDivCtfEzJHUgFFf/rK8z2ABKX09WR59TUA264tKv4QQ5Pk6+BUCvc6xROgFFoTyEZOCXA6uxxpDhIoCVsgvww1yHmA2hSsgnFpF8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1587994927587527.0748974211639; Mon, 27 Apr 2020 06:42:07 -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-155-G_4DvI5RMbycUdEdA8aKpw-1; Mon, 27 Apr 2020 09:42:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75A9A102C7EC; Mon, 27 Apr 2020 13:41:57 +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 3F76C60CD3; Mon, 27 Apr 2020 13:41:57 +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 D8CAB4CA95; Mon, 27 Apr 2020 13:41:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03RDftkt015462 for ; Mon, 27 Apr 2020 09:41:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 60A145D9E4; Mon, 27 Apr 2020 13:41:55 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.110.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9744C5D9E2; Mon, 27 Apr 2020 13:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587994926; 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=o2YeoqhrBxGfz9zPzUbabvmCn+mqOQlq/JWhKsHpNko=; b=OupYHyoRlIWYuQdA/z6Gc2rDDz9KTk9Se6RnjbK2bCrZ9SpaT8RnrUV48QDJHx3+9+P540 4J/uTXAs+Vpcx1hj2zsS2FLOSMcKZgIb5dZDoi1c3ajRkdqmwuKRdn0srU+0gs59ocj+HK PVm3sFu+afp/7OcypgA6Pyw/h+cAroU= X-MC-Unique: G_4DvI5RMbycUdEdA8aKpw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu: re-add padding to the saved state images Date: Mon, 27 Apr 2020 14:41:47 +0100 Message-Id: <20200427134147.1369948-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.79 on 10.5.11.12 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" In the past we added 1024 bytes of padding to saved state images so that users can run "virsh managedsave-edit $GUEST" and make XML changes which increase the size of the XML document. This padding was accidentally lost a while back commit 6b9b21db7079888a05d192b079e68290bdf14a76 Author: Peter Krempa Date: Wed Feb 17 13:10:11 2016 +0100 qemu: Remove unnecessary calculations in qemuDomainSaveMemory The original 1024 bytes was unreasonably stingy when we consider that the QEMU state is typically going to be many 100's of MB in size. Thus this adds 64 KB of padding after the XML which should cope with any plausible modifications a user will want to make. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Eric Blake --- src/qemu/qemu_driver.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 01330e55e7..d5aeeac66d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2922,20 +2922,23 @@ virQEMUSaveDataWrite(virQEMUSaveDataPtr data, =20 len =3D xml_len + cookie_len; =20 - if (header->data_len > 0) { + if (header->data_len =3D=3D 0) { + /* This 64kb padding allows the user to edit the XML in + * a saved state image and have the new XML be larger + * that what was originally saved + */ + header->data_len =3D len + (64 * 1024); + } else { if (len > header->data_len) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("new xml too large to fit in file")); return -1; } - - zerosLen =3D header->data_len - len; - if (VIR_ALLOC_N(zeros, zerosLen) < 0) - return -1; - } else { - header->data_len =3D len; } =20 + zerosLen =3D header->data_len - len; + zeros =3D g_new0(char, zerosLen); + if (data->cookie) header->cookieOffset =3D xml_len; =20 --=20 2.25.3