From nobody Sun Apr 28 19:21:18 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=1567112220; cv=none; d=zoho.com; s=zohoarc; b=RtpyTtW3M+zVAIwHPI8+yyOE3zqmkKu3rMvtulvg8SiqLZ0d9CPOILCyF66CKLmCkf5YKmADXCG+bL3RCzw0U+Wr4VvS7v2r3jay+AqdrFlwVZZzUw84J6l0G4Bg5fp+NIzKoJI8f4ldklJs7HodLwEyADArK7cCtvI152kWisA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567112220; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=5Bom+DxZxlPbW2objdV1QjtIqc8zHaDPbxHQRWMgdFw=; b=EkxVG3lt/jafFWft0im8tw/mfy1pIMuAK5D1nNJDgoHr3N0JfiSIQ+xLT/DxYcUwouYkdUY/9i7dHwu/s14ZG3L5NSjL+IzKM0vr+KfGRL1Ve3yAVlv5Y8MhfKrJpRTv7pMPudPTvzu5rVvO3Bq0erABTFFNaOBtkqPPhv3y/O4= 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 156711222093463.069606552428695; Thu, 29 Aug 2019 13:57:00 -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 9EDF63084025; Thu, 29 Aug 2019 20:56:59 +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 7AFCD5D713; Thu, 29 Aug 2019 20:56:59 +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 413022551D; Thu, 29 Aug 2019 20:56:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7TKu22u026248 for ; Thu, 29 Aug 2019 16:56:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 789E45D721; Thu, 29 Aug 2019 20:56:02 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB5885D713; Thu, 29 Aug 2019 20:55:59 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 B3D263082141; Thu, 29 Aug 2019 20:55:58 +0000 (UTC) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7TKqCE0005168; Thu, 29 Aug 2019 16:55:58 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2upkqbmxeq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 16:55:58 -0400 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x7TKtvq3037339; Thu, 29 Aug 2019 16:55:57 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 2upkqbmxe4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 16:55:57 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x7TKt3Ub026736; Thu, 29 Aug 2019 20:55:56 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma01wdc.us.ibm.com with ESMTP id 2ujvv6ppkm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 20:55:55 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7TKtuo716122798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Aug 2019 20:55:56 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1ECFCAE060; Thu, 29 Aug 2019 20:55:56 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB759AE05C; Thu, 29 Aug 2019 20:55:54 +0000 (GMT) Received: from maxibm.ibmuc.com (unknown [9.85.226.103]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 29 Aug 2019 20:55:54 +0000 (GMT) From: "Maxiwell S. Garcia" To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 17:55:42 -0300 Message-Id: <20190829205543.25453-2-maxiwell@linux.ibm.com> In-Reply-To: <20190829205543.25453-1-maxiwell@linux.ibm.com> References: <20190829205543.25453-1-maxiwell@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-08-29_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=896 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908290210 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 29 Aug 2019 20:55:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 29 Aug 2019 20:55:58 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-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.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: jdenemar@redhat.com, danielhb413@gmail.com, "Maxiwell S. Garcia" Subject: [libvirt] [PATCH v4 1/2] qemu: formatting XML from domain def choosing the root name 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.40]); Thu, 29 Aug 2019 20:57:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function virDomainDefFormatInternal() has the predefined root name "domain" to format the XML. But to save both active and inactive domain in the snapshot XML, the new root name "inactiveDomain" was created. So, the new function virDomainDefFormatInternalSetRootName() allows to choose the root name of XML. The former function became a tiny wrapper to call the new function setting the correct parameters. Signed-off-by: Maxiwell S. Garcia Reviewed-by: Daniel Henrique Barboza Reviewed-by: Jiri Denemark Tested-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 35 ++++++++++++++++++++++++++--------- src/conf/domain_conf.h | 6 ++++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b7a342bb91..3154c07a86 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21517,10 +21517,11 @@ virDomainDefParseNode(xmlDocPtr xml, virDomainDefPtr def =3D NULL; virDomainDefPtr ret =3D NULL; =20 - if (!virXMLNodeNameEqual(root, "domain")) { + if ((!virXMLNodeNameEqual(root, "domain")) && + (!virXMLNodeNameEqual(root, "inactiveDomain"))) { virReportError(VIR_ERR_XML_ERROR, _("unexpected root element <%s>, " - "expecting "), + "expecting or "), root->name); goto cleanup; } @@ -28277,17 +28278,29 @@ virDomainDefFormatFeatures(virBufferPtr buf, return virXMLFormatElement(buf, "features", NULL, &childBuf); } =20 - -/* This internal version appends to an existing buffer - * (possibly with auto-indent), rather than flattening - * to string. - * Return -1 on failure. */ int virDomainDefFormatInternal(virDomainDefPtr def, virCapsPtr caps, unsigned int flags, virBufferPtr buf, virDomainXMLOptionPtr xmlopt) +{ + return virDomainDefFormatInternalSetRootName(def, caps, flags, buf, + xmlopt, "domain"); +} + + +/* This internal version appends to an existing buffer + * (possibly with auto-indent), rather than flattening + * to string. + * Return -1 on failure. */ +int +virDomainDefFormatInternalSetRootName(virDomainDefPtr def, + virCapsPtr caps, + unsigned int flags, + virBufferPtr buf, + virDomainXMLOptionPtr xmlopt, + const char *rootname) { unsigned char *uuid; char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -28312,7 +28325,11 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (def->id =3D=3D -1) flags |=3D VIR_DOMAIN_DEF_FORMAT_INACTIVE; =20 - virBufferAsprintf(buf, "id); if (def->namespaceData && def->ns.format) @@ -28794,7 +28811,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, virDomainSEVDefFormat(buf, def->sev); =20 virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virBufferAsprintf(buf, "\n", rootname); =20 if (virBufferCheckError(buf) < 0) goto error; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 33cef5b75c..af1335cc16 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3073,6 +3073,12 @@ int virDomainDefFormatInternal(virDomainDefPtr def, unsigned int flags, virBufferPtr buf, virDomainXMLOptionPtr xmlopt); +int virDomainDefFormatInternalSetRootName(virDomainDefPtr def, + virCapsPtr caps, + unsigned int flags, + virBufferPtr buf, + virDomainXMLOptionPtr xmlopt, + const char *rootname); =20 int virDomainDiskSourceFormat(virBufferPtr buf, virStorageSourcePtr src, --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 19:21:18 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=1567112168; cv=none; d=zoho.com; s=zohoarc; b=KdRopxePFiDME8ZnE+tm2kBbpznzSnMOvi8STm18XpNhTKDTp932OvfdoVx1GzBpiIjydmJn6AJthu+hXKWUkRN1J66/NI3xcfLnUpcLUrAlljlnutkyqbWQNHI0BcY3/IEGKKpJQxNlRObftd2lRPJe9nYePOe13EIAQXc8Twc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567112168; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=znoBSa4JzzPxPQaerluEuP3qqqRo4nqBnoIXJa9NGj8=; b=QzMPeqhRaNCFCYP/N2Nv6IlVm5nzvtCOPLjGWF+YiKgpP430PwC456LUIdMReu3USCY6dY55zhX8eAIl1P+5InzFRNHvb1jdLwjqFhV9fe1Lp3k6GhgCQZEIAdMvFCvs/K7SyAkgTvFiEOKq5ClUQiTpFT0PgjKpNVEAF2cCblY= 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 1567112168491823.2667946863808; Thu, 29 Aug 2019 13:56:08 -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 1620310C6974; Thu, 29 Aug 2019 20:56:07 +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 E68B45C1D6; Thu, 29 Aug 2019 20:56:06 +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 ABC542551C; Thu, 29 Aug 2019 20:56:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7TKu4xO026258 for ; Thu, 29 Aug 2019 16:56:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD9B919D7A; Thu, 29 Aug 2019 20:56:04 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E01A196B2; Thu, 29 Aug 2019 20:56:02 +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 5462B89AC9; Thu, 29 Aug 2019 20:56:01 +0000 (UTC) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7TKq74o047294; Thu, 29 Aug 2019 16:56:00 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 2upnq8gw1y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 16:56:00 -0400 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x7TKu0eX054367; Thu, 29 Aug 2019 16:56:00 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 2upnq8gw1e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 16:56:00 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x7TKt5Kd023307; Thu, 29 Aug 2019 20:55:59 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma03dal.us.ibm.com with ESMTP id 2umpctuuwn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 20:55:59 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7TKtwCK48169262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Aug 2019 20:55:58 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49091AE05C; Thu, 29 Aug 2019 20:55:58 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 882EAAE05F; Thu, 29 Aug 2019 20:55:56 +0000 (GMT) Received: from maxibm.ibmuc.com (unknown [9.85.226.103]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 29 Aug 2019 20:55:56 +0000 (GMT) From: "Maxiwell S. Garcia" To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 17:55:43 -0300 Message-Id: <20190829205543.25453-3-maxiwell@linux.ibm.com> In-Reply-To: <20190829205543.25453-1-maxiwell@linux.ibm.com> References: <20190829205543.25453-1-maxiwell@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-08-29_08:, , 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-1906280000 definitions=main-1908290210 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 29 Aug 2019 20:56:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 29 Aug 2019 20:56:01 +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.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: jdenemar@redhat.com, danielhb413@gmail.com, "Maxiwell S. Garcia" Subject: [libvirt] [PATCH v4 2/2] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Thu, 29 Aug 2019 20:56:07 +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 Reviewed-by: Daniel Henrique Barboza Reviewed-by: Jiri Denemark Tested-by: Daniel Henrique Barboza --- src/conf/moment_conf.c | 1 + src/conf/moment_conf.h | 11 +++++++++++ src/conf/snapshot_conf.c | 22 ++++++++++++++++++++-- src/qemu/qemu_driver.c | 37 ++++++++++++++++++++++++++++--------- 4 files changed, 60 insertions(+), 11 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 9fdbef2172..70cc47bd70 100644 --- a/src/conf/moment_conf.h +++ b/src/conf/moment_conf.h @@ -36,7 +36,18 @@ struct _virDomainMomentDef { char *parent_name; long long creationTime; /* in seconds */ =20 + /* + * Store the active domain definition in case of online + * guest and the inactive domain definition in case of + * offline guest + */ virDomainDefPtr dom; + + /* + * Store the inactive domain definition in case of online + * guest and leave NULL in case of offline guest + */ + virDomainDefPtr inactiveDom; }; =20 virClassPtr virClassForDomainMomentDef(void); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 7996589ad2..cce9a7999c 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -235,6 +235,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, virDomainSnapshotDefPtr def =3D NULL; virDomainSnapshotDefPtr ret =3D NULL; xmlNodePtr *nodes =3D NULL; + xmlNodePtr inactiveDomNode =3D NULL; size_t i; int n; char *creation =3D NULL, *state =3D NULL; @@ -244,6 +245,8 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, char *memoryFile =3D NULL; bool offline =3D !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE); virSaveCookieCallbacksPtr saveCookie =3D virDomainXMLOptionGetSaveCook= ie(xmlopt); + int domainflags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; =20 if (!(def =3D virDomainSnapshotDefNew())) return NULL; @@ -293,8 +296,6 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, * clients will have to decide between best effort * initialization or outright failure. */ if ((tmp =3D virXPathString("string(./domain/@type)", ctxt))) { - int domainflags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | - VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; xmlNodePtr domainNode =3D virXPathNode("./domain", ctxt); =20 VIR_FREE(tmp); @@ -311,6 +312,16 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, } else { VIR_WARN("parsing older snapshot that lacks domain"); } + + /* /inactiveDomain 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 ((inactiveDomNode =3D virXPathNode("./inactiveDomain", ctxt))) { + def->parent.inactiveDom =3D virDomainDefParseNode(ctxt->node->= doc, inactiveDomNode, + caps, xmlopt, = NULL, domainflags); + if (!def->parent.inactiveDom) + goto cleanup; + } } else if (virDomainXMLOptionRunMomentPostParse(xmlopt, &def->parent) = < 0) { goto cleanup; } @@ -908,6 +919,13 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, virBufferAddLit(buf, "\n"); } =20 + if (def->parent.inactiveDom) { + if (virDomainDefFormatInternalSetRootName(def->parent.inactiveDom,= caps, + domainflags, buf, xmlopt, + "inactiveDomain") < 0) + goto error; + } + 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 78f5471b79..67511b705a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15939,6 +15939,13 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, VIR_DOMAIN_DEF_PAR= SE_SKIP_VALIDATE))) goto endjob; =20 + if (vm->newDef) { + def->parent.inactiveDom =3D virDomainDefCopy(vm->newDef, caps, + driver->xmlopt, pri= v->qemuCaps, true); + if (!def->parent.inactiveDom) + goto endjob; + } + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) { align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; align_match =3D false; @@ -16471,6 +16478,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; @@ -16572,11 +16580,10 @@ 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, priv->qemuCaps, true); @@ -16584,6 +16591,15 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sn= apshot, goto endjob; } =20 + if (snap->def->inactiveDom) { + inactiveConfig =3D virDomainDefCopy(snap->def->inactiveDom, caps, + driver->xmlopt, priv->qemuCaps, = true); + if (!inactiveConfig) + goto endjob; + } else { + inactiveConfig =3D config; + } + cookie =3D (qemuDomainSaveCookiePtr) snapdef->cookie; =20 switch ((virDomainSnapshotState) snapdef->state) { @@ -16686,16 +16702,19 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr s= napshot, goto endjob; } if (config) { - virDomainObjAssignDef(vm, config, false, NULL); virCPUDefFree(priv->origCPU); VIR_STEAL_PTR(priv->origCPU, origCPU); } + if (inactiveConfig) + virDomainObjAssignDef(vm, inactiveConfig, false, NULL); } else { /* Transitions 2, 3 */ load: was_stopped =3D true; + if (inactiveConfig) + virDomainObjAssignDef(vm, inactiveConfig, false, NULL); if (config) - virDomainObjAssignDef(vm, config, false, NULL); + virDomainObjAssignDef(vm, config, true, NULL); =20 /* No cookie means libvirt which saved the domain was too old = to * mess up the CPU definitions. @@ -16781,8 +16800,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, qemuProcessEndJob(driver, vm); goto cleanup; } - if (config) - virDomainObjAssignDef(vm, config, false, NULL); + if (inactiveConfig) + virDomainObjAssignDef(vm, inactiveConfig, false, NULL); =20 if (flags & (VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING | VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list