From nobody Tue May 7 08:54:08 2024 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1558963310; cv=none; d=zoho.com; s=zohoarc; b=WMWCjTX65HXtz/aLh3KE/WQt/V8YrNZjvsT3XN193xAVjFS9YNso2sig/igNHQSKFCdrf19QZQv/nXf3PWMks1K6zMe4db4KOqbrMeinYILiNvTsQSxKAzSKYfVXlZ+c778/MM/3sO0KHrgp07QOIBG3GzTLGkLBdgnz9KQjxHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558963310; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=NxWo195C5WS4kXOZ4CBKwcqzb6DjfVLj7Cx1tmDEPXQ=; b=B/k2BNd0QB9jfRZ7OYA6OjJC2eUv7kCKb6m94RUku/IfbXhuB1Dbf/y0GoQrU9xjNrmny3XXvatdgIL1cfqozYLqXl2luc5Oyj/3MnEptEj3HN0UdiUpnZg9EqlmHWHkY/4DXSH+rwoUvaHAfRHeCv3Q2L0Nfipe/u+qO0fSBUU= ARC-Authentication-Results: i=1; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558963310444349.5984923274955; Mon, 27 May 2019 06:21:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19C00821C3; Mon, 27 May 2019 13:21:48 +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 56D745D70D; Mon, 27 May 2019 13:21:47 +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 015F918433A1; Mon, 27 May 2019 13:21:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4RDKHQV017148 for ; Mon, 27 May 2019 09:20:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id E0AA61001DC2; Mon, 27 May 2019 13:20:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DADC31001E71 for ; Mon, 27 May 2019 13:20:15 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 87D9D3007149 for ; Mon, 27 May 2019 13:20:05 +0000 (UTC) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4RDGvWP059131 for ; Mon, 27 May 2019 09:20:05 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0b-001b2d01.pphosted.com with ESMTP id 2srfuptwfw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 May 2019 09:20:04 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 May 2019 14:20:04 +0100 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 27 May 2019 14:20:01 +0100 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4RDIkjp35913746 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 May 2019 13:18:46 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15C3B112064; Mon, 27 May 2019 13:18:46 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CC85112061; Mon, 27 May 2019 13:18:45 +0000 (GMT) Received: from maxibm.ibmuc.com (unknown [9.85.177.246]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 27 May 2019 13:18:45 +0000 (GMT) From: "Maxiwell S. Garcia" To: libvir-list@redhat.com Date: Mon, 27 May 2019 10:18:42 -0300 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19052713-0064-0000-0000-000003E5831C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011172; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01209322; UDB=6.00635274; IPR=6.00990349; MB=3.00027072; MTD=3.00000008; XFM=3.00000015; UTC=2019-05-27 13:20:02 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19052713-0065-0000-0000-00003DA26111 Message-Id: <20190527131842.12756-1-maxiwell@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-27_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905270094 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 27 May 2019 13:20:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 27 May 2019 13:20:05 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'maxiwell@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: "Maxiwell S. Garcia" Subject: [libvirt] [PATCH] snapshot: Store both config and live XML in the snapshot domain 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 27 May 2019 13:21:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The snapshot-create operation of running guests saves the live XML and uses it to replace the active and inactive domain in case of revert. So, the config XML is ignored by the snapshot process. This commit changes it and adds the config XML in the snapshot XML as the entry. In case of offline guest, the behavior remains the same and the config XML is saved in the snapshot XML as entry. The behavior of older snapshots of running guests, that don't have the new , remains the same too. The revert, in this case, overrides both active and inactive domain with the entry. So, the in the snapshot XML is not required to snapshot work, but it's useful to preserve the config XML of running guests. Signed-off-by: Maxiwell S. Garcia --- src/conf/moment_conf.c | 1 + src/conf/moment_conf.h | 1 + src/conf/snapshot_conf.c | 42 ++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_driver.c | 29 ++++++++++++++++++++++----- 4 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/conf/moment_conf.c b/src/conf/moment_conf.c index fea13f0f97..f54a44b33e 100644 --- a/src/conf/moment_conf.c +++ b/src/conf/moment_conf.c @@ -66,6 +66,7 @@ virDomainMomentDefDispose(void *obj) VIR_FREE(def->description); VIR_FREE(def->parent_name); virDomainDefFree(def->dom); + virDomainDefFree(def->inactiveDom); } =20 /* Provide defaults for creation time and moment name after parsing XML */ diff --git a/src/conf/moment_conf.h b/src/conf/moment_conf.h index 00ec1c1904..b8bec7e456 100644 --- a/src/conf/moment_conf.h +++ b/src/conf/moment_conf.h @@ -38,6 +38,7 @@ struct _virDomainMomentDef { long long creationTime; /* in seconds */ =20 virDomainDefPtr dom; + virDomainDefPtr inactiveDom; }; =20 virClassPtr virClassForDomainMomentDef(void); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index c7f29360e7..c66ee997a4 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -294,6 +294,28 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, } else { VIR_WARN("parsing older snapshot that lacks domain"); } + + /* /inactive/domain entry saves the config XML present in a running + * VM. In case of absent, leave parent.inactiveDom NULL and use + * parent.dom for config and live XML. */ + if ((tmp =3D virXPathString("string(./inactive/domain/@type)", ctx= t))) { + int domainflags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; + xmlNodePtr domainNode =3D virXPathNode("./inactive/domain", ct= xt); + + VIR_FREE(tmp); + if (!domainNode) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing inactive domain in snapshot")); + + goto cleanup; + } + def->parent.inactiveDom =3D virDomainDefParseNode(ctxt->node->= doc, domainNode, + caps, xmlopt, = NULL, domainflags); + if (!def->parent.inactiveDom) + goto cleanup; + } + } else if (virDomainXMLOptionRunMomentPostParse(xmlopt, &def->parent) = < 0) { goto cleanup; } @@ -511,6 +533,16 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDef= Ptr def, VIR_STEAL_PTR(def->parent.dom, otherdef->parent.dom); } } + if (otherdef->parent.inactiveDom) { + if (def->parent.inactiveDom) { + if (!virDomainDefCheckABIStability(otherdef->parent.inacti= veDom, + def->parent.inactiveDom= , xmlopt)) + return -1; + } else { + /* Transfer the inactive domain def */ + VIR_STEAL_PTR(def->parent.inactiveDom, otherdef->parent.in= activeDom); + } + } } =20 if (def->parent.dom) { @@ -876,6 +908,16 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, virBufferAddLit(buf, "\n"); } =20 + if (def->parent.inactiveDom) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + if (virDomainDefFormatInternal(def->parent.inactiveDom, caps, + domainflags, buf, xmlopt) < 0) + goto error; + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + if (virSaveCookieFormatBuf(buf, def->cookie, virDomainXMLOptionGetSaveCookie(xmlopt)) < = 0) goto error; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 42b1ce2521..1ce7aa7b42 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15707,6 +15707,15 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, VIR_DOMAIN_DEF_PAR= SE_SKIP_VALIDATE))) goto endjob; =20 + if (vm->newDef) { + if (!(xml =3D qemuDomainDefFormatLive(driver, vm->newDef, priv= ->origCPU, + true, true)) || + !(def->parent.inactiveDom =3D virDomainDefParseString(xml,= caps, driver->xmlopt, NULL, + VIR_DOMAIN_= DEF_PARSE_INACTIVE | + VIR_DOMAIN_= DEF_PARSE_SKIP_VALIDATE))) + goto endjob; + } + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) { align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; align_match =3D false; @@ -16241,6 +16250,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, qemuDomainObjPrivatePtr priv; int rc; virDomainDefPtr config =3D NULL; + virDomainDefPtr inactiveConfig =3D NULL; virQEMUDriverConfigPtr cfg =3D NULL; virCapsPtr caps =3D NULL; bool was_stopped =3D false; @@ -16341,17 +16351,22 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr s= napshot, * in the failure cases where we know there was no change? */ } =20 - /* Prepare to copy the snapshot inactive xml as the config of this - * domain. - * - * XXX Should domain snapshots track live xml rather - * than inactive xml? */ + /* Prepare to copy the snapshot inactive domain as the config XML + * and the snapshot domain as the live XML. In case of inactive domain + * NULL, both config and live XML will be copied from snapshot domain. + */ if (snap->def->dom) { config =3D virDomainDefCopy(snap->def->dom, caps, driver->xmlopt, NULL, true); if (!config) goto endjob; } + if (snap->def->inactiveDom) { + inactiveConfig =3D virDomainDefCopy(snap->def->inactiveDom, caps, + driver->xmlopt, NULL, true); + if (!inactiveConfig) + goto endjob; + } =20 cookie =3D (qemuDomainSaveCookiePtr) snapdef->cookie; =20 @@ -16602,6 +16617,10 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sn= apshot, goto endjob; } =20 + if (inactiveConfig) { + virDomainDefFree(vm->newDef); + VIR_STEAL_PTR(vm->newDef, inactiveConfig); + } ret =3D 0; =20 endjob: --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list