From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1646916053; cv=none; d=zohomail.com; s=zohoarc; b=IrGq+eOhO+H+UuWmF2PgPyP4pBjCeThoBDJOU+7EgeJbMXkNDlbaWhvU6v/2okWTNe/hyHyHf1rf7pcsNjK6+RKIvUrfzrjlNGRhOs9lcV5DwaAscvNsYi8jB035inYXQcDsqoNzCLSbcf5vmEqADeeq5Ufrcq0U14L4jqgvdfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916053; 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=8A6CMjUZL3pBxtE0nnPE6N2fCdda2hTX4GfXEgYPqBU=; b=AF7jKd0e5a9FoludsfnpeVRHOu6qVVtcjHEFa0ooiB2wP6hsxTrUnV36ZI5rBOHNZTdYCeE/Gfe1GbXaEK0UlMu2Sx5Rrb7f1mLFHvmT6mIj4ip7ztGtqOtqrj9RpycC5pjTYxLoBCMcNtITVlLiknHMEqfYJavV0J4OB7nBsI4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1646916053295266.8208486509891; Thu, 10 Mar 2022 04:40:53 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-400-OdHbzX53NbKelX_5o7Nhvg-1; Thu, 10 Mar 2022 07:40:50 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DBEB42A2AD47; Thu, 10 Mar 2022 12:40:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6E01463EC6; Thu, 10 Mar 2022 12:40:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8EF141953576; Thu, 10 Mar 2022 12:40:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4DE48195FD44 for ; Thu, 10 Mar 2022 12:40:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EAB617D3CC; Thu, 10 Mar 2022 12:40:45 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF4EB7D3CD for ; Thu, 10 Mar 2022 12:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916052; 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=8A6CMjUZL3pBxtE0nnPE6N2fCdda2hTX4GfXEgYPqBU=; b=TugzkGEzSg2E3g3sdTNBtyFdGc+2isEqlBn3rJCWwEl3JolWAgi5H0RBUfdME/Pl8lB6Db 9xWZCNC1ncwwOYmGq7b1iRxz/6AqgrgwN+rmzinW7Apd0UxTa1EP1rI+dB4aSWJ+PFyxbe 2kAPaGPGNJZt/DxsI28rvnWF16reniI= X-MC-Unique: OdHbzX53NbKelX_5o7Nhvg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/14] virDomainDiskDefFormat: Refactor to virXMLFormatElement Date: Thu, 10 Mar 2022 13:40:29 +0100 Message-Id: <4e5d61cfe257e23161b6fa8d689e61e7c1fb8f20.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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) X-ZM-MESSAGEID: 1646916053739100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 79 ++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 34fec887a3..69f61aadc1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23568,6 +23568,8 @@ virDomainDiskDefFormat(virBuffer *buf, const char *device =3D virDomainDiskDeviceTypeToString(def->device); const char *bus =3D virDomainDiskBusTypeToString(def->bus); const char *sgio =3D virDomainDeviceSGIOTypeToString(def->sgio); + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); if (!type || !def->src->type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -23590,39 +23592,35 @@ virDomainDiskDefFormat(virBuffer *buf, return -1; } - virBufferAsprintf(buf, - "model) { - virBufferAsprintf(buf, " model=3D'%s'", + virBufferAsprintf(&attrBuf, " model=3D'%s'", virDomainDiskModelTypeToString(def->model)); } if (def->rawio) { - virBufferAsprintf(buf, " rawio=3D'%s'", + virBufferAsprintf(&attrBuf, " rawio=3D'%s'", virTristateBoolTypeToString(def->rawio)); } if (def->sgio) - virBufferAsprintf(buf, " sgio=3D'%s'", sgio); + virBufferAsprintf(&attrBuf, " sgio=3D'%s'", sgio); if (def->snapshot && !(def->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE && def->src->readonly)) - virBufferAsprintf(buf, " snapshot=3D'%s'", + virBufferAsprintf(&attrBuf, " snapshot=3D'%s'", virDomainSnapshotLocationTypeToString(def->snaps= hot)); - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virDomainDiskDefFormatDriver(buf, def); + virDomainDiskDefFormatDriver(&childBuf, def); /* Format as child of if defined there; otherwise, * if defined as child of , then format later */ if (def->src->auth && def->diskElementAuth) - virStorageAuthDefFormat(buf, def->src->auth); + virStorageAuthDefFormat(&childBuf, def->src->auth); - if (virDomainDiskSourceFormat(buf, def->src, "source", def->startupPol= icy, + if (virDomainDiskSourceFormat(&childBuf, def->src, "source", def->star= tupPolicy, true, flags, def->diskElementAuth, def->diskElementEn= c, xmlopt) < 0) @@ -23630,75 +23628,74 @@ virDomainDiskDefFormat(virBuffer *buf, /* Don't format backingStore to inactive XMLs until the code for * persistent storage of backing chains is ready. */ - if (virDomainDiskBackingStoreFormat(buf, def->src, xmlopt, flags) < 0) + if (virDomainDiskBackingStoreFormat(&childBuf, def->src, xmlopt, flags= ) < 0) return -1; - virBufferEscapeString(buf, "\n", def->doma= in_name); + virBufferEscapeString(&childBuf, "\n", def= ->domain_name); - virDomainDiskGeometryDefFormat(buf, def); - virDomainDiskBlockIoDefFormat(buf, def); + virDomainDiskGeometryDefFormat(&childBuf, def); + virDomainDiskBlockIoDefFormat(&childBuf, def); - if (virDomainDiskDefFormatMirror(buf, def, flags, xmlopt) < 0) + if (virDomainDiskDefFormatMirror(&childBuf, def, flags, xmlopt) < 0) return -1; - virBufferAsprintf(buf, "dst, bus); if ((def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY || def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) && def->tray_status !=3D VIR_DOMAIN_DISK_TRAY_CLOSED) - virBufferAsprintf(buf, " tray=3D'%s'", + virBufferAsprintf(&childBuf, " tray=3D'%s'", virDomainDiskTrayTypeToString(def->tray_status)); if (def->bus =3D=3D VIR_DOMAIN_DISK_BUS_USB && def->removable !=3D VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(buf, " removable=3D'%s'", + virBufferAsprintf(&childBuf, " removable=3D'%s'", virTristateSwitchTypeToString(def->removable)); } if (def->rotation_rate) - virBufferAsprintf(buf, " rotation_rate=3D'%u'", def->rotation_rate= ); - virBufferAddLit(buf, "/>\n"); + virBufferAsprintf(&childBuf, " rotation_rate=3D'%u'", def->rotatio= n_rate); + virBufferAddLit(&childBuf, "/>\n"); - virDomainDiskDefFormatIotune(buf, def); + virDomainDiskDefFormatIotune(&childBuf, def); if (def->src->readonly) - virBufferAddLit(buf, "\n"); + virBufferAddLit(&childBuf, "\n"); if (def->src->shared) - virBufferAddLit(buf, "\n"); + virBufferAddLit(&childBuf, "\n"); if (def->transient) { - virBufferAddLit(buf, "transientShareBacking =3D=3D VIR_TRISTATE_BOOL_YES) - virBufferAddLit(buf, " shareBacking=3D'yes'"); - virBufferAddLit(buf, "/>\n"); + virBufferAddLit(&childBuf, " shareBacking=3D'yes'"); + virBufferAddLit(&childBuf, "/>\n"); } - virBufferEscapeString(buf, "%s\n", def->serial); - virBufferEscapeString(buf, "%s\n", def->wwn); - virBufferEscapeString(buf, "%s\n", def->vendor); - virBufferEscapeString(buf, "%s\n", def->product); + virBufferEscapeString(&childBuf, "%s\n", def->serial); + virBufferEscapeString(&childBuf, "%s\n", def->wwn); + virBufferEscapeString(&childBuf, "%s\n", def->vendor); + virBufferEscapeString(&childBuf, "%s\n", def->produ= ct); /* If originally found as a child of , then format thusly; * otherwise, will be formatted as child of */ if (def->src->encryption && def->diskElementEnc && - virStorageEncryptionFormat(buf, def->src->encryption) < 0) + virStorageEncryptionFormat(&childBuf, def->src->encryption) < 0) return -1; - virDomainDeviceInfoFormat(buf, &def->info, flags | VIR_DOMAIN_DEF_FORM= AT_ALLOW_BOOT); + virDomainDeviceInfoFormat(&childBuf, &def->info, flags | VIR_DOMAIN_DE= F_FORMAT_ALLOW_BOOT); - if (virDomainDiskDefFormatPrivateData(buf, def, flags, xmlopt) < 0) + if (virDomainDiskDefFormatPrivateData(&childBuf, def, flags, xmlopt) <= 0) return -1; /* format diskElementAuth and diskElementEnc into status XML to preser= ve * formatting */ if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS) { - g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) secretPlacementAttrBuf =3D VIR_BUFFER_INITIALIZE= R; if (def->diskElementAuth) - virBufferAddLit(&attrBuf, " auth=3D'true'"); + virBufferAddLit(&secretPlacementAttrBuf, " auth=3D'true'"); if (def->diskElementEnc) - virBufferAddLit(&attrBuf, " enc=3D'true'"); + virBufferAddLit(&secretPlacementAttrBuf, " enc=3D'true'"); - virXMLFormatElement(buf, "diskSecretsPlacement", &attrBuf, NULL); + virXMLFormatElement(&childBuf, "diskSecretsPlacement", &secretPlac= ementAttrBuf, NULL); } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virXMLFormatElement(buf, "disk", &attrBuf, &childBuf); return 0; } --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1646916055; cv=none; d=zohomail.com; s=zohoarc; b=BJg+tREJNDMm9ozNlcVK8hlhTpTnV+sTH+3oV1/KOhCudI5VAW1fpeZkFcUju3uwZGJ8yzwiwWbYkishHeqAyt8DzoSk19n+hfT0hl4FhBOH5v/Q+MjOgOuL7MwR56R4zCBDQQWDhsRGrH9yVrc+4Ixbx/fNpW9TprIHKb9gYO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916055; 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=LduOB8ZBc6UoZXYX+ERbWxzM0K06VJ/cQw15genv+5s=; b=IgU0v7oMpYGucJ1xCUbQcUkMNUzmRo8Pn9Xg379ushwfR1ZMl/yNpIGQFqJ0T69R20v1aeQExON2ZfZRFUnUAVudLSuxYeOEPGBdKFKwX0IIj0DG7hQfXkMJiPq8idsAgtPdHVdeupCLzm6f0FRUE2lbmtDI9Si3+LlHBMVoqhc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1646916055907298.2562736732132; Thu, 10 Mar 2022 04:40:55 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-6--0DSuoKMNraFVp5lwJN7fQ-1; Thu, 10 Mar 2022 07:40:51 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 255CA802815; Thu, 10 Mar 2022 12:40:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11461442909; Thu, 10 Mar 2022 12:40:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DF9691953573; Thu, 10 Mar 2022 12:40:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B13A5195FD64 for ; Thu, 10 Mar 2022 12:40:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 737347D3CD; Thu, 10 Mar 2022 12:40:47 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 930947D3CC for ; Thu, 10 Mar 2022 12:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916054; 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=LduOB8ZBc6UoZXYX+ERbWxzM0K06VJ/cQw15genv+5s=; b=TTr348Hnr2VmcnuY3Ry8TqFeNk7Z4D8xb50Le9JidQ7h3vIfVUcaJEabrgYJ0X6YO7uZso p4fZ/lF21g9VZMUbRHINqJmoDSz98Ohpoja7ea7VBPh+Htv50L9S/rH+2xkQJmqZRCgOtV T3qITNIjygueQA1d+BWYeadi2QzQ4sM= X-MC-Unique: -0DSuoKMNraFVp5lwJN7fQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/14] qemuSnapshotDiskPrepareActiveExternal: Handle only external snapshots Date: Thu, 10 Mar 2022 13:40:30 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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) X-ZM-MESSAGEID: 1646916058118100001 Content-Type: text/plain; charset="utf-8" Preparation steps ensure that the 'snapshot' field can only be 'VIR_DOMAIN_SNAPSHOT_LOCATION_NONE' or VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL' at this point, but upcoming patches will change that. Handle only external snapshots. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index cb2a7eb739..f92b571b06 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1165,7 +1165,7 @@ qemuSnapshotDiskPrepareActiveExternal(virDomainObj *v= m, snapctxt =3D qemuSnapshotDiskContextNew(snapdef->ndisks, vm, asyncJob); for (i =3D 0; i < snapdef->ndisks; i++) { - if (snapdef->disks[i].snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NONE) + if (snapdef->disks[i].snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_E= XTERNAL) continue; if (qemuSnapshotDiskPrepareOne(snapctxt, --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1646916057; cv=none; d=zohomail.com; s=zohoarc; b=CZ8ETCPhPbgNlxMTzUKi43MzDC4G3VJpUYdcB2l1BRyzWv920vrcb68Iluzm8V4oUK2C8L7x0khCn9t/e+0OenBSfKaQvfB+HSpZ8pAR+Xd/1IXm2GVXjvupuuMka4oesX1K478P90eH+BYjtH2lnovbLOUB7lk76FRVbAPDJ9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916057; 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=ZJg9yVsKjp+k+A5IoVC+tWcIGU06x5DRDFH6K8xVMbs=; b=RcjjZEZfTEZcbrn+jLfLTEajp6N0kEHgiowuD5DmUwIoCZFmRnerEB7qQ+E04vuY3O+OzZ0E1zK3O3dqh0YUIup+007o13Pk/BryXcfQEBvbcXB6QG7ATGmX/sFKIo1p5idfX1t+pZbT61C0cH7vnbQScL7rgn3AZgFC/MY0oQQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646916057228441.78641975419043; Thu, 10 Mar 2022 04:40:57 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-263-lYcuqaklMXqnERRZFFrgUQ-1; Thu, 10 Mar 2022 07:40:52 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9DF5438025F3; Thu, 10 Mar 2022 12:40:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86482141DC5F; Thu, 10 Mar 2022 12:40:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 34EA81953576; Thu, 10 Mar 2022 12:40:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 15034195FD67 for ; Thu, 10 Mar 2022 12:40:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C8BFB7D3CC; Thu, 10 Mar 2022 12:40:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE5F47D3CD for ; Thu, 10 Mar 2022 12:40:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916056; 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=ZJg9yVsKjp+k+A5IoVC+tWcIGU06x5DRDFH6K8xVMbs=; b=ektS+q5/B1xgI2aZqLmxHrJwur+jpNDLSLRv5JaXFCnutOGHdhs1xYmudwbzQh/w0owiVc VtFTjKMRxgJtXnkUKFLiKQzDLe2uDWDNNxz7TpfpeC8GhObqFHsnVE4zNoVGhyCtnyBkS1 +uehcCbMmWHcLe+IGdktZIFMH28Lgng= X-MC-Unique: lYcuqaklMXqnERRZFFrgUQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/14] qemuSnapshotCreateAlignDisks: Rewrite logic for selecting default memory snapshot mode Date: Thu, 10 Mar 2022 13:40:31 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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) X-ZM-MESSAGEID: 1646916058476100003 Content-Type: text/plain; charset="utf-8" Use an if/else branch rather than a expression with a ternary operator. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index f92b571b06..355a2fd782 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1672,9 +1672,10 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, return -1; } - def->memory =3D (def->state =3D=3D VIR_DOMAIN_SNAPSHOT_SHUTOFF ? - VIR_DOMAIN_SNAPSHOT_LOCATION_NONE : - VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL); + if (def->state =3D=3D VIR_DOMAIN_SNAPSHOT_SHUTOFF) + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + else + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; } if (virDomainSnapshotAlignDisks(def, NULL, align_location, true) < 0) return -1; --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1646916058; cv=none; d=zohomail.com; s=zohoarc; b=UudAStAb5ov1FTjaeNhQnqEOgxvrNVfp8HAyJotCs1cCtuSoGsvOx7lRafoFxTprBnX2Y5CY46uvuEJJJxNN+59mWCk0JjUJkMMFIR0zNWT0FY7ICGxz2ekjIKdOrA9hpIy0NQdnXTnEMs8LcTt+B5SsLFfdFoRFUSctP53rkO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916058; 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=Q4nCTihNHREsd23TL4ZZJ7tQQv52t8WnStanYRUso7E=; b=eHDRP/y4zdrFbbHRTmV8D8UwZX0shxkJVPguPeeIXjZbQB90zi45s7Jul8Qy/TS7bvz5nchwelzusuow7aC1CJxgtAzP46741fe3gtoqJ7XN9DHL4r1QBIfi8CUyv29CyoyidhbcCFcqfA+agZlyPULiC5THZDl7IRNlzRfGaKM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646916058849657.225705619347; Thu, 10 Mar 2022 04:40:58 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-wYTfAXvYPRG2RbWd0LOpkg-1; Thu, 10 Mar 2022 07:40:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF7A038025F6; Thu, 10 Mar 2022 12:40:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A873C40C1244; Thu, 10 Mar 2022 12:40:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7A0BB195FD44; Thu, 10 Mar 2022 12:40:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1F43A195356D for ; Thu, 10 Mar 2022 12:40:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D67E27D3CD; Thu, 10 Mar 2022 12:40:49 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4693E7D3CC for ; Thu, 10 Mar 2022 12:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916057; 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=Q4nCTihNHREsd23TL4ZZJ7tQQv52t8WnStanYRUso7E=; b=WU3fTwEUBn9EfEBLGm2JMquNAJdfko2sJ3ABuaCYqnb3R8trep5/Q1H53Aos8MlXdgeHMs pnQcoKJ2fDB1jmUZf3yIWI/VLKnzxsWj/1SU83pnGJ+3She2g832E5CZ9M3jZaN1q0MOJx MKscsryGP65jpegMSXjvEjK6lzR356E= X-MC-Unique: wYTfAXvYPRG2RbWd0LOpkg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/14] virDomainSnapshotDiskDefParseXML: Automatically free temporary variables and remove cleanup Date: Thu, 10 Mar 2022 13:40:32 +0100 Message-Id: <3aaf667b98d9411e7be9288fe64bd7269240eb49.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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) X-ZM-MESSAGEID: 1646916060646100001 Content-Type: text/plain; charset="utf-8" Refactor the function to avoid the cleanup section used to just free memory associated with the parsed object. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 58 ++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 79a7b891a2..a2e45632bf 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -138,21 +138,20 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, unsigned int flags, virDomainXMLOption *xmlopt) { - int ret =3D -1; - char *snapshot =3D NULL; - char *type =3D NULL; - char *driver =3D NULL; + g_autofree char *snapshot =3D NULL; + g_autofree char *type =3D NULL; + g_autofree char *driver =3D NULL; + g_autofree char *name =3D NULL; + g_autoptr(virStorageSource) src =3D virStorageSourceNew(); xmlNodePtr cur; VIR_XPATH_NODE_AUTORESTORE(ctxt) ctxt->node =3D node; - def->src =3D virStorageSourceNew(); - def->name =3D virXMLPropString(node, "name"); - if (!def->name) { + if (!(name =3D virXMLPropString(node, "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing name from disk snapshot element")); - goto cleanup; + return -1; } snapshot =3D virXMLPropString(node, "snapshot"); @@ -162,59 +161,54 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk snapshot setting '%s'"), snapshot); - goto cleanup; + return -1; } } if ((type =3D virXMLPropString(node, "type"))) { - if ((def->src->type =3D virStorageTypeFromString(type)) <=3D 0 || - def->src->type =3D=3D VIR_STORAGE_TYPE_VOLUME || - def->src->type =3D=3D VIR_STORAGE_TYPE_DIR) { + if ((src->type =3D virStorageTypeFromString(type)) <=3D 0 || + src->type =3D=3D VIR_STORAGE_TYPE_VOLUME || + src->type =3D=3D VIR_STORAGE_TYPE_DIR) { virReportError(VIR_ERR_XML_ERROR, _("unknown disk snapshot type '%s'"), type); - goto cleanup; + return -1; } } else { - def->src->type =3D VIR_STORAGE_TYPE_FILE; + src->type =3D VIR_STORAGE_TYPE_FILE; } if ((cur =3D virXPathNode("./source", ctxt)) && - virDomainStorageSourceParse(cur, ctxt, def->src, flags, xmlopt) < = 0) - goto cleanup; + virDomainStorageSourceParse(cur, ctxt, src, flags, xmlopt) < 0) + return -1; if ((driver =3D virXPathString("string(./driver/@type)", ctxt)) && - (def->src->format =3D virStorageFileFormatTypeFromString(driver)) = <=3D 0) { + (src->format =3D virStorageFileFormatTypeFromString(driver)) <=3D = 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk snapshot driver '%s'"), driver); - goto cleanup; + return -1; } if (virParseScaledValue("./driver/metadata_cache/max_size", NULL, ctxt, - &def->src->metadataCacheMaxSize, + &src->metadataCacheMaxSize, 1, ULLONG_MAX, false) < 0) - goto cleanup; + return -1; /* validate that the passed path is absolute */ - if (virStorageSourceIsRelative(def->src)) { + if (virStorageSourceIsRelative(src)) { virReportError(VIR_ERR_XML_ERROR, _("disk snapshot image path '%s' must be absolute"), - def->src->path); - goto cleanup; + src->path); + return -1; } - if (!def->snapshot && (def->src->path || def->src->format)) + if (!def->snapshot && (src->path || src->format)) def->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - ret =3D 0; - cleanup: + def->name =3D g_steal_pointer(&name); + def->src =3D g_steal_pointer(&src); - VIR_FREE(driver); - VIR_FREE(snapshot); - VIR_FREE(type); - if (ret < 0) - virDomainSnapshotDiskDefClear(def); - return ret; + return 0; } /* flags is bitwise-or of virDomainSnapshotParseFlags. --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1646916125; cv=none; d=zohomail.com; s=zohoarc; b=lI3+zUlVrlJuLAngxos/kXZo87tYl2OGLcfPTN6b8azgC2R69Xbtto/G9WoysDfAG5rpx59ZypjkNrFashI9ADKov8Z7RmbH9SKcHYe+OG910IFb1QgVxiYEMKQTwg9uAxMRukd/PK8KCSRSleJNXdE76YakhIRnNmKG9UpUObs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916125; 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=EKXP2lTTtxe0KftuPLazE7mlKtxfvIpiKd4Ef6jYA4s=; b=jYwute1EYW9pMd27CU8TcYvbuWKBnvZ7OR2vY/2YK2yLDpwZ9bDhUddKGa5UXRDLJPVM8+fdIrJpqAct+TDpoc7qmHPxULo/EesvHaaUPo3Ne9c552GJjSLnjESK1hgyhVjaYHvWty7MhLEvzeq3LsUboykA++QporMc4d6ikY4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646916125851945.1411259488348; Thu, 10 Mar 2022 04:42:05 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-630-UhhT2_FRPBaX638PoMOLOQ-1; Thu, 10 Mar 2022 07:40:55 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 245462A2AD45; Thu, 10 Mar 2022 12:40:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F736482CF9; Thu, 10 Mar 2022 12:40:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D1D471953573; Thu, 10 Mar 2022 12:40:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1E6611953573 for ; Thu, 10 Mar 2022 12:40:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E19F37D3CC; Thu, 10 Mar 2022 12:40:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 461A87D3CD for ; Thu, 10 Mar 2022 12:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916124; 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=EKXP2lTTtxe0KftuPLazE7mlKtxfvIpiKd4Ef6jYA4s=; b=SXE9vdf8//s4fZdYZI5RhoBOc4KfrwKGtiQWu3FFUf0AzNgyGXBlCZYFbN8JdflBmsSMVQ SGTl5DBhyRKOlNTFgFXQZkwwUa6Rs3lQF0WHS82uT8ppIUglcTdMQA60MnxywbTvOpfVek 6lXKjB0zkLux+Rhox1NKFchvaCOqGDg= X-MC-Unique: UhhT2_FRPBaX638PoMOLOQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/14] virStorageSource: Convert 'type' to proper enum Date: Thu, 10 Mar 2022 13:40:33 +0100 Message-Id: <1065accbca0415f37ec00e0c0d9cb9ff3d1cbbda.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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) X-ZM-MESSAGEID: 1646916128072100001 Content-Type: text/plain; charset="utf-8" Use 'virStorageType' as type for the 'type' member and convert the code to work properly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_monitor.c | 1 + src/conf/domain_conf.c | 27 ++++++++++++++------------- src/conf/snapshot_conf.c | 24 +++++++++++++----------- src/conf/storage_source_conf.h | 2 +- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 60905e36c2..84085b7991 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -198,6 +198,7 @@ virCHMonitorBuildDiskJson(virJSONValue *disks, virDomai= nDiskDef *diskdef) case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_LAST: default: virReportEnumRangeError(virStorageType, diskdef->src->type); return -1; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 69f61aadc1..40ff71d7db 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8502,11 +8502,15 @@ virDomainStorageSourceParseBase(const char *type, src =3D virStorageSourceNew(); src->type =3D VIR_STORAGE_TYPE_FILE; - if (type && - (src->type =3D virStorageTypeFromString(type)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown storage source type '%s'"), type); - return NULL; + if (type) { + int tmp; + if ((tmp =3D virStorageTypeFromString(type)) <=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown storage source type '%s'"), type); + return NULL; + } + + src->type =3D tmp; } if (format && @@ -9055,19 +9059,16 @@ virDomainDiskDefParseSourceXML(virDomainXMLOption *= xmlopt, { g_autoptr(virStorageSource) src =3D virStorageSourceNew(); VIR_XPATH_NODE_AUTORESTORE(ctxt) - g_autofree char *type =3D NULL; xmlNodePtr tmp; ctxt->node =3D node; - src->type =3D VIR_STORAGE_TYPE_FILE; - - if ((type =3D virXMLPropString(node, "type")) && - (src->type =3D virStorageTypeFromString(type)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk type '%s'"), type); + if (virXMLPropEnumDefault(node, "type", + virStorageTypeFromString, + VIR_XML_PROP_NONZERO, + &src->type, + VIR_STORAGE_TYPE_FILE) < 0) return NULL; - } if ((tmp =3D virXPathNode("./source[1]", ctxt))) { if (virDomainStorageSourceParse(tmp, ctxt, src, flags, xmlopt) < 0) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index a2e45632bf..812cca2ed1 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -139,7 +139,6 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, virDomainXMLOption *xmlopt) { g_autofree char *snapshot =3D NULL; - g_autofree char *type =3D NULL; g_autofree char *driver =3D NULL; g_autofree char *name =3D NULL; g_autoptr(virStorageSource) src =3D virStorageSourceNew(); @@ -165,16 +164,19 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, } } - if ((type =3D virXMLPropString(node, "type"))) { - if ((src->type =3D virStorageTypeFromString(type)) <=3D 0 || - src->type =3D=3D VIR_STORAGE_TYPE_VOLUME || - src->type =3D=3D VIR_STORAGE_TYPE_DIR) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown disk snapshot type '%s'"), type); - return -1; - } - } else { - src->type =3D VIR_STORAGE_TYPE_FILE; + if (virXMLPropEnumDefault(node, "type", + virStorageTypeFromString, + VIR_XML_PROP_NONZERO, + &src->type, + VIR_STORAGE_TYPE_FILE) < 0) + return -1; + + if (src->type =3D=3D VIR_STORAGE_TYPE_VOLUME || + src->type =3D=3D VIR_STORAGE_TYPE_DIR) { + virReportError(VIR_ERR_XML_ERROR, + _("unsupported disk snapshot type '%s'"), + virStorageTypeToString(src->type)); + return -1; } if ((cur =3D virXPathNode("./source", ctxt)) && diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index c720d093be..e984421e3d 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -269,7 +269,7 @@ struct _virStorageSource { virObject parent; unsigned int id; /* backing chain identifier, 0 is unset */ - int type; /* virStorageType */ + virStorageType type; char *path; int protocol; /* virStorageNetProtocol */ char *volume; /* volume name for remote storage */ --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1646916182; cv=none; d=zohomail.com; s=zohoarc; b=Y7jd5xeJ8MOX4Oyl55YkAgh8hhZ636ecyXa/5jb8pWx6eDFHapYqK/3PG6UpCgM6lCspi2pKGDUxXbJ0e0gc2rLBLzMbrJAI7DydlvcEGqNGVrCDcQMEtojnSD1Fd3LQ0GcrNdJS+wHrIs17uJ2UEUi3HgHmAyp9Bnc/ZWXmKbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916182; 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=d4wh57aeWBY0mboQgsCI9NmDIR9b/sGKxAfJCvf9qwk=; b=W04t2YeeS4n9r/Vdm6UfMoV63Vi/VUl7eHnKqWghjuwGjhTiFb/V9q8IKu0/S0jihn0eR3+A/QRUJkEWho642gNkn1LNRdEOQEceM2j1USbLJnCiwYCb76aZQlgmsMbcXf2mxEpke/P85lZZN0MRLFQQetZMq9dCwtp+rrnwCfE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646916182713157.94907753540656; Thu, 10 Mar 2022 04:43:02 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-221-cydv6N26OmijLj2RO95DWA-1; Thu, 10 Mar 2022 07:40:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B43BB1C168E3; Thu, 10 Mar 2022 12:40:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EAB54010A14; Thu, 10 Mar 2022 12:40:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 37F871953576; Thu, 10 Mar 2022 12:40:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 38076195FD5A for ; Thu, 10 Mar 2022 12:40:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EB5567D3CD; Thu, 10 Mar 2022 12:40:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 591187D3CC for ; Thu, 10 Mar 2022 12:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916181; 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=d4wh57aeWBY0mboQgsCI9NmDIR9b/sGKxAfJCvf9qwk=; b=InFkBP6e2Iiy9V8SJDCNh/pJV4CyWQcbLF0HCSG+1e1QhG9QsO5h9VAIWA+UlHFni8I8kq q0mLtkvmY0tXfcfKfcoAZnn2zbc6c3hXlnP22aK17Fr4c5aiIy+vARmZdwg/+hwc9O9JBk 9CDtamQ4V/Xai347r0APZPkfRS7EvoQ= X-MC-Unique: cydv6N26OmijLj2RO95DWA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/14] conf: Move definition of 'virDomainSnapshotLocation' Date: Thu, 10 Mar 2022 13:40:34 +0100 Message-Id: <67d02c3e04cd3ebaa31b1d1232e1a1fa1343e94c.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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) X-ZM-MESSAGEID: 1646916184648100001 Content-Type: text/plain; charset="utf-8" The snapshot location enum is also needed for the disk definition so if we house it inside domain_conf we can use the proper type for it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 10 +++++++++- src/conf/domain_conf.h | 14 +++++++++++++- src/conf/snapshot_conf.c | 8 -------- src/conf/snapshot_conf.h | 12 ------------ src/libvirt_private.syms | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 40ff71d7db..721623129c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1402,6 +1402,14 @@ VIR_ENUM_IMPL(virDomainIBS, "fixed-na", ); +VIR_ENUM_IMPL(virDomainSnapshotLocation, + VIR_DOMAIN_SNAPSHOT_LOCATION_LAST, + "default", + "no", + "internal", + "external", +); + /* Internal mapping: subset of block job types that can be present in * XML (remaining types are not two-phase). */ VIR_ENUM_DECL(virDomainBlockJob); @@ -23608,7 +23616,7 @@ virDomainDiskDefFormat(virBuffer *buf, if (def->sgio) virBufferAsprintf(&attrBuf, " sgio=3D'%s'", sgio); - if (def->snapshot && + if (def->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT && !(def->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE && def->src->readonly)) virBufferAsprintf(&attrBuf, " snapshot=3D'%s'", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9fcf842ee7..5f6b508e89 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -537,6 +537,18 @@ typedef enum { } virDomainMemoryAllocation; +typedef enum { + VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT =3D 0, + VIR_DOMAIN_SNAPSHOT_LOCATION_NONE, + VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL, + VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL, + + VIR_DOMAIN_SNAPSHOT_LOCATION_LAST +} virDomainSnapshotLocation; + +VIR_ENUM_DECL(virDomainSnapshotLocation); + + /* Stores the virtual disk configuration */ struct _virDomainDiskDef { virStorageSource *src; /* non-NULL. XXX Allow NULL for empty cdrom? */ @@ -581,7 +593,7 @@ struct _virDomainDiskDef { virTristateSwitch ioeventfd; virTristateSwitch event_idx; virTristateSwitch copy_on_read; - unsigned int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */ + virDomainSnapshotLocation snapshot; virDomainStartupPolicy startupPolicy; bool transient; virTristateBool transientShareBacking; diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 812cca2ed1..a4b3cd8c2b 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -67,14 +67,6 @@ virDomainSnapshotOnceInit(void) VIR_ONCE_GLOBAL_INIT(virDomainSnapshot); -VIR_ENUM_IMPL(virDomainSnapshotLocation, - VIR_DOMAIN_SNAPSHOT_LOCATION_LAST, - "default", - "no", - "internal", - "external", -); - /* virDomainSnapshotState is really virDomainState plus one extra state */ VIR_ENUM_IMPL(virDomainSnapshotState, VIR_DOMAIN_SNAPSHOT_LAST, diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index c8997c710c..b7e0d441ff 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -26,17 +26,6 @@ #include "moment_conf.h" #include "virenum.h" -/* Items related to snapshot state */ - -typedef enum { - VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT =3D 0, - VIR_DOMAIN_SNAPSHOT_LOCATION_NONE, - VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL, - VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL, - - VIR_DOMAIN_SNAPSHOT_LOCATION_LAST -} virDomainSnapshotLocation; - /** * This enum has to map all known domain states from the public enum * virDomainState, before adding one additional state possible only @@ -139,5 +128,4 @@ int virDomainSnapshotRedefinePrep(virDomainObj *vm, virDomainXMLOption *xmlopt, unsigned int flags); -VIR_ENUM_DECL(virDomainSnapshotLocation); VIR_ENUM_DECL(virDomainSnapshotState); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6f0d72ca38..01503083ef 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -637,6 +637,8 @@ virDomainSmartcardTypeFromString; virDomainSmartcardTypeToString; virDomainSmbiosModeTypeFromString; virDomainSmbiosModeTypeToString; +virDomainSnapshotLocationTypeFromString; +virDomainSnapshotLocationTypeToString; virDomainSoundDefFind; virDomainSoundDefFree; virDomainSoundDefRemove; @@ -1024,8 +1026,6 @@ virDomainSnapshotDiskDefFree; virDomainSnapshotDiskDefParseXML; virDomainSnapshotFormatConvertXMLFlags; virDomainSnapshotIsExternal; -virDomainSnapshotLocationTypeFromString; -virDomainSnapshotLocationTypeToString; virDomainSnapshotRedefinePrep; virDomainSnapshotStateTypeFromString; virDomainSnapshotStateTypeToString; --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1646916203; cv=none; d=zohomail.com; s=zohoarc; b=hzzRgXGn3Z42MWe2m6E+0A89giGm2gvUL6GntBGoUY8NFtwWXjmErX9YClcLXvcy6spgpf7awsry4BPYKYrKc1QmMYLGHr0BevCOXX3D6horYfP++aI837wZ/3NOdZ9ukdFn1qSGYtkqVeLGTnXSfi9+uM84zHSo5hx5bWzWJbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916203; 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=1sO8iYX8/SEXFCGadnBi0AhZ5mh92eKsx1FLYkW7xrg=; b=gMju8+hDyxioXDMb1Db7jPMn0QoVD1g051EY56VdWE3oIFTMMXZ3dK518n5xHxBlrhor3whepbtbZKIrnFH6GeWnPYQOI1fWvBMSxhE70ak2UW2OT3LwcY1qYOIwhi72bFejqzwVo/YbOpeXR4KGx+oR2iiBJ5FcHc23YE5TS4c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646916203226101.7432947034556; Thu, 10 Mar 2022 04:43:23 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-VtYlVelsMoyyNppMtp4c0A-1; Thu, 10 Mar 2022 07:40:57 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 269B6805F5B; Thu, 10 Mar 2022 12:40:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 104E9406790; Thu, 10 Mar 2022 12:40:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 968DE195FD71; Thu, 10 Mar 2022 12:40:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2FA431953576 for ; Thu, 10 Mar 2022 12:40:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F2DCA7D3CC; Thu, 10 Mar 2022 12:40:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58BA67D3CD for ; Thu, 10 Mar 2022 12:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916201; 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=1sO8iYX8/SEXFCGadnBi0AhZ5mh92eKsx1FLYkW7xrg=; b=fBC2aNNMmyIuml5itebJuNHtuYT5T5DslaAlolt3YzPn61jztGDh5Jo6nji+L6hgcLXpOX gEDLblN3s2XH4VrYHfYLhy7A+yn4rE6GV4a7QMVuHGP6qlKgBFXToy2gOE1NENs5tvNRC9 jq8UqRwSbfVirELSyIxqAK6TH1xewqk= X-MC-Unique: VtYlVelsMoyyNppMtp4c0A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/14] Rename VIR_DOMAIN_SNAPSHOT_LOCATION_NONE to VIR_DOMAIN_SNAPSHOT_LOCATION_NO Date: Thu, 10 Mar 2022 13:40:35 +0100 Message-Id: <1e713db633fe60bf591e299bd80fd78674b17468.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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) X-ZM-MESSAGEID: 1646916203837100001 Content-Type: text/plain; charset="utf-8" The string value associated to the enum is "no". Rename the enum accordingly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 6 +++--- src/conf/domain_conf.h | 2 +- src/conf/domain_validate.c | 2 +- src/conf/snapshot_conf.c | 12 ++++++------ src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_snapshot.c | 12 ++++++------ src/test/test_driver.c | 4 ++-- src/vz/vz_sdk.c | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 721623129c..58fe24a8c1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5521,7 +5521,7 @@ virDomainDiskDefPostParse(virDomainDiskDef *disk, if (disk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT && disk->src->readonly) - disk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + disk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI) { @@ -5536,7 +5536,7 @@ virDomainDiskDefPostParse(virDomainDiskDef *disk, /* vhost-user doesn't allow us to snapshot, disable snapshots by defau= lt */ if (disk->src->type =3D=3D VIR_STORAGE_TYPE_VHOST_USER && disk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT) { - disk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + disk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; } if (disk->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && @@ -23617,7 +23617,7 @@ virDomainDiskDefFormat(virBuffer *buf, virBufferAsprintf(&attrBuf, " sgio=3D'%s'", sgio); if (def->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT && - !(def->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE && + !(def->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO && def->src->readonly)) virBufferAsprintf(&attrBuf, " snapshot=3D'%s'", virDomainSnapshotLocationTypeToString(def->snaps= hot)); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 5f6b508e89..a4de46773c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -539,7 +539,7 @@ typedef enum { typedef enum { VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT =3D 0, - VIR_DOMAIN_SNAPSHOT_LOCATION_NONE, + VIR_DOMAIN_SNAPSHOT_LOCATION_NO, VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL, VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL, diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index f0b8aa2655..d6869e8fd8 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -317,7 +317,7 @@ virDomainDiskVhostUserValidate(const virDomainDiskDef *= disk) return -1; } - if (disk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) { + if (disk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("only snapshot=3Dno is supported with vhostuser d= isk")); return -1; diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index a4b3cd8c2b..f5ae2ee212 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -337,11 +337,11 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; } else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { def->memory =3D (offline ? - VIR_DOMAIN_SNAPSHOT_LOCATION_NONE : + VIR_DOMAIN_SNAPSHOT_LOCATION_NO : VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL); } if (offline && def->memory && - def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) { + def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO) { virReportError(VIR_ERR_XML_ERROR, "%s", _("memory state cannot be saved with offline or " "disk-only snapshot")); @@ -681,15 +681,15 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDef *sna= pdef, if (snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT= ) { if (domdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAUL= T && (!require_match || - domdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NON= E)) { + domdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO)= ) { snapdisk->snapshot =3D domdisk->snapshot; } else { snapdisk->snapshot =3D default_snapshot; } } else if (require_match && snapdisk->snapshot !=3D default_snapshot && - !(snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATIO= N_NONE && - domdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NONE)) { + !(snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATIO= N_NO && + domdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NO)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' must use snapshot mode '%s'"), snapdisk->name, @@ -728,7 +728,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapd= ef, /* Don't snapshot empty drives */ if (virStorageSourceIsEmpty(domdef->disks[i]->src)) - snapdisk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + snapdisk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; else snapdisk->snapshot =3D domdef->disks[i]->snapshot; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6b61fefb8f..936a0c8a35 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6886,7 +6886,7 @@ qemuDomainSnapshotForEachQcow2Raw(virQEMUDriver *driv= er, /* FIXME: we also need to handle LVM here */ if (def->disks[i]->device !=3D VIR_DOMAIN_DISK_DEVICE_DISK || - snapdef->disks[i].snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NONE) + snapdef->disks[i].snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NO) continue; if (!virStorageSourceIsLocalStorage(def->disks[i]->src)) { diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 355a2fd782..c5fc7dcf67 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -692,7 +692,7 @@ qemuSnapshotPrepare(virDomainObj *vm, virDomainSnapshotDiskDef *disk =3D &def->disks[i]; virDomainDiskDef *dom_disk =3D vm->def->disks[i]; - if (disk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE && + if (disk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO && qemuDomainDiskBlockJobIsActive(dom_disk)) return -1; @@ -757,7 +757,7 @@ qemuSnapshotPrepare(virDomainObj *vm, external++; break; - case VIR_DOMAIN_SNAPSHOT_LOCATION_NONE: + case VIR_DOMAIN_SNAPSHOT_LOCATION_NO: /* Remember seeing a disk that has snapshot disabled */ if (!virStorageSourceIsEmpty(dom_disk->src) && !dom_disk->src->readonly) @@ -773,7 +773,7 @@ qemuSnapshotPrepare(virDomainObj *vm, } if (!found_internal && !external && - def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) { + def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("nothing selected for snapshot")); return -1; @@ -1657,7 +1657,7 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, def->state =3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT; else def->state =3D VIR_DOMAIN_SNAPSHOT_SHUTOFF; - def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; } else if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { def->state =3D virDomainObjGetState(vm, NULL); align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; @@ -1665,7 +1665,7 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, def->state =3D virDomainObjGetState(vm, NULL); if (virDomainObjIsActive(vm) && - def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) { + def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("internal snapshot of a running VM " "must include the memory state")); @@ -1673,7 +1673,7 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, } if (def->state =3D=3D VIR_DOMAIN_SNAPSHOT_SHUTOFF) - def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; else def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4eca5c4a65..da1c6c8f6e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8723,14 +8723,14 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, def->state =3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT; else def->state =3D VIR_DOMAIN_SNAPSHOT_SHUTOFF; - def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; } else if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { def->state =3D virDomainObjGetState(vm, NULL); align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; } else { def->state =3D virDomainObjGetState(vm, NULL); def->memory =3D def->state =3D=3D VIR_DOMAIN_SNAPSHOT_SHUTOFF ? - VIR_DOMAIN_SNAPSHOT_LOCATION_NONE : + VIR_DOMAIN_SNAPSHOT_LOCATION_NO : VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; } diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index f149360c03..43d528820e 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4640,7 +4640,7 @@ prlsdkParseSnapshotTree(const char *treexml) def->parent.description =3D virXPathString("string(./Description)"= , ctxt); - def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; xmlstr =3D virXPathString("string(./@state)", ctxt); if (!xmlstr) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1646916121; cv=none; d=zohomail.com; s=zohoarc; b=JQsXxAMxconV6NaBpT0279Y1Bg3mn1LJZ/gjnQjmqM/1mBpy8LuilPFJMDLJOnmQfDAXywvSDpL5bXtisZpVkjOCKgkVDt2KihO6TzO7aP42zUI4XZLcpHEihz58TXPdBbLo/D4hxBDQk3+DwqfXw96eR4pHgaZ2RM2q0jUASxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916121; 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=g8iWd17s8f0WUKO2TWguUIcsrfuQ+NfsArlkp6oKGio=; b=nFCmFHk5oQVTRVFt3TMfcTKBtpUUXczKF7PLT86XASQCBKhxfQJDbr6sHaHRicmTEqT+fBlxt3derrKtzpdH3j6pwIz4yjd8LD/1E5hEzYkzEIx+oGkhCRuyFhJu/paKvwSr1/JhWtNYqzd9r+hRTRcMUtBtaDHI9fsZcCXRnUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646916121452762.1095248271312; Thu, 10 Mar 2022 04:42:01 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-184-1UL__bgbMI2fKb4ZQ9_UXw-1; Thu, 10 Mar 2022 07:40:59 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5BDC12A2AD4C; Thu, 10 Mar 2022 12:40:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 435C7401E9D; Thu, 10 Mar 2022 12:40:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E7A1D195356C; Thu, 10 Mar 2022 12:40:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 38C11195FD44 for ; Thu, 10 Mar 2022 12:40:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 07A407D3CD; Thu, 10 Mar 2022 12:40:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C8827D3CC for ; Thu, 10 Mar 2022 12:40:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916121; 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=g8iWd17s8f0WUKO2TWguUIcsrfuQ+NfsArlkp6oKGio=; b=fu0ft7dbzYBu53V0xqtHUzffXudgX0H2mJSIJZDjZ3Ri6F77+TtBiiBBTDS5xNBuewTZ3C 112QlRgOkY8J/WcqLdixJRDrk01tiaxQw+8/A4E+bf6KGlEOdfdAbSQWybja1ugcEFPMb3 R/HOmjeUtyi15BZ9oZmIjYjH5D0RpnY= X-MC-Unique: 1UL__bgbMI2fKb4ZQ9_UXw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/14] qemuDomainSnapshotForEachQcow2Raw: Act only on internal snapshots Date: Thu, 10 Mar 2022 13:40:36 +0100 Message-Id: <2d4a69d3a1f39fd5ad6b541970e3c60f1d13b0bc.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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) X-ZM-MESSAGEID: 1646916123314100001 Content-Type: text/plain; charset="utf-8" Similarly to the external snapshot code the internal inactive snapshot creation helper should act only when an internal snapshot of the disk is required. For now the callers ensure that it's either _INTERNAL or _NO when control reaches this function. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 936a0c8a35..f61509d00b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6886,7 +6886,7 @@ qemuDomainSnapshotForEachQcow2Raw(virQEMUDriver *driv= er, /* FIXME: we also need to handle LVM here */ if (def->disks[i]->device !=3D VIR_DOMAIN_DISK_DEVICE_DISK || - snapdef->disks[i].snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NO) + snapdef->disks[i].snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_I= NTERNAL) continue; if (!virStorageSourceIsLocalStorage(def->disks[i]->src)) { --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1646916062; cv=none; d=zohomail.com; s=zohoarc; b=Uuoj9hLvSZUCBNjPVcht+5d0/aEfg4CGbJziwZ7nv8OxM06mCuQSs3PLWdvvvjseQK0ozRTFMgFMwMKbK6x7EilXH+L3cAjK0A9maGL7GDVsacBzJvlQoKOCW7mXL3keiBTPGpdJ21nrcr3uC3xWItpxr0hHrTvsEisP+z44aD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916062; 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=AofDM/lC6x1b0oz6QryFG3TBr9D14I6JNIXgkPSlFaQ=; b=HeTMRVgKsoLi+FVvBIUJbh0N2uSoBzYxqs51Li7ayQb/xnyE2MUnkt/hK9hTImNIFgxquXDHinB1IOgU4+Fcvd6tD8R8IxJ1M+FvuUz0XJXs7fd8mkFI/KI0MGpmKuLMvoTxID192DVA0Ik6F/sqiqGWoe2bz/I4hlDmZK2B3E4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646916062431287.98005108216205; Thu, 10 Mar 2022 04:41:02 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-249-c0ULhRRwNdyab2CLDdwL3Q-1; Thu, 10 Mar 2022 07:40:59 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9DDE580231F; Thu, 10 Mar 2022 12:40:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8759A141DC2C; Thu, 10 Mar 2022 12:40:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4D013195FD6D; Thu, 10 Mar 2022 12:40:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 674EA1953573 for ; Thu, 10 Mar 2022 12:40:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 24E4B7C0FF; Thu, 10 Mar 2022 12:40:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 723607D3CC for ; Thu, 10 Mar 2022 12:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916061; 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=AofDM/lC6x1b0oz6QryFG3TBr9D14I6JNIXgkPSlFaQ=; b=XrJQtbaKAzQXyrjh3drifv/AvvczPiTNriq2BYDDgy3FV9UcvFsDFHjvlVv1pvmrV0q4fb P/Cy5oXSCOUmKP8R2soR+XiTE9G2nieuJ6XEA5Sutx5yX77hyThqtOEfAOqdmKLyCQDwJ8 szQlb60OID06bOD1Nv1k73xJ1Fk67w4= X-MC-Unique: c0ULhRRwNdyab2CLDdwL3Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/14] conf: snapshot: Remove VIR_DOMAIN_SNAPSHOT_PARSE_DISKS flag Date: Thu, 10 Mar 2022 13:40:37 +0100 Message-Id: <7842c5c71c67bd0104e0aee7703283506e4d9ff1.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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) X-ZM-MESSAGEID: 1646916063292100001 Content-Type: text/plain; charset="utf-8" All callers except the one in the 'esx' driver pass the flag. The 'esx' driver has a check that 'def->ndisks' is zero after parsing the definition. This means that we can simply always parse the disks. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 22 ++++++++-------------- src/conf/snapshot_conf.h | 7 +++---- src/qemu/qemu_driver.c | 1 - src/qemu/qemu_snapshot.c | 2 +- src/test/test_driver.c | 3 +-- src/vbox/vbox_common.c | 4 +--- src/vz/vz_driver.c | 2 +- tests/qemudomainsnapshotxml2xmltest.c | 2 +- 8 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index f5ae2ee212..f477b67785 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -359,21 +359,15 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, if ((n =3D virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0) goto cleanup; - if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_DISKS) { - if (n) - def->disks =3D g_new0(virDomainSnapshotDiskDef, n); - def->ndisks =3D n; - for (i =3D 0; i < def->ndisks; i++) { - if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt, &def->dis= ks[i], - flags, xmlopt) < 0) - goto cleanup; - } - VIR_FREE(nodes); - } else if (n) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("unable to handle disk requests in snapshot")); - goto cleanup; + if (n) + def->disks =3D g_new0(virDomainSnapshotDiskDef, n); + def->ndisks =3D n; + for (i =3D 0; i < def->ndisks; i++) { + if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt, &def->disks[i= ], + flags, xmlopt) < 0) + goto cleanup; } + VIR_FREE(nodes); if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL) { if (!current) { diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index b7e0d441ff..8823af1ac1 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -84,10 +84,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainSnapshotDef, virO= bjectUnref); typedef enum { VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE =3D 1 << 0, - VIR_DOMAIN_SNAPSHOT_PARSE_DISKS =3D 1 << 1, - VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL =3D 1 << 2, - VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE =3D 1 << 3, - VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE =3D 1 << 4, + VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL =3D 1 << 1, + VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE =3D 1 << 2, + VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE =3D 1 << 3, } virDomainSnapshotParseFlags; typedef enum { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c1b3bd8536..de7d2b93b9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -347,7 +347,6 @@ qemuDomainSnapshotLoad(virDomainObj *vm, virDomainMomentObj *current =3D NULL; bool cur; unsigned int flags =3D (VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE | - VIR_DOMAIN_SNAPSHOT_PARSE_DISKS | VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL); int ret =3D -1; int direrr; diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index c5fc7dcf67..3fb1d3abe0 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1530,7 +1530,7 @@ qemuSnapshotCreateXMLParse(virDomainObj *vm, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; - unsigned int parse_flags =3D VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; + unsigned int parse_flags =3D 0; if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE) parse_flags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index da1c6c8f6e..9ceb0b45c8 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -978,7 +978,6 @@ testParseDomainSnapshots(testDriver *privconn, privconn->xmlopt, NULL, &cur, - VIR_DOMAIN_SNAPSHOT_PARSE_DISK= S | VIR_DOMAIN_SNAPSHOT_PARSE_INTE= RNAL | VIR_DOMAIN_SNAPSHOT_PARSE_REDE= FINE); if (!def) @@ -8777,7 +8776,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain, virObjectEvent *event =3D NULL; bool update_current =3D true; bool redefine =3D flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; - unsigned int parse_flags =3D VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; + unsigned int parse_flags =3D 0; g_autoptr(virDomainSnapshotDef) def =3D NULL; /* diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 36db6e06be..acd18494d3 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -5364,8 +5364,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, nsresult rc; resultCodeUnion result; virDomainSnapshotPtr ret =3D NULL; - unsigned int parse_flags =3D (VIR_DOMAIN_SNAPSHOT_PARSE_DISKS | - VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE); + unsigned int parse_flags =3D VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE; g_autoptr(virDomainSnapshotDef) def =3D NULL; if (!data->vboxObj) @@ -6783,7 +6782,6 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) } def =3D virDomainSnapshotDefParseString(defXml, data->xmlopt, NULL, NULL, - VIR_DOMAIN_SNAPSHOT_PARSE_DISKS | VIR_DOMAIN_SNAPSHOT_PARSE_REDEFI= NE); if (!def) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index fdd776282e..2107785ab2 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -2580,7 +2580,7 @@ vzDomainSnapshotCreateXML(virDomainPtr domain, virDomainObj *dom; struct _vzConn *privconn =3D domain->conn->privateData; struct _vzDriver *driver =3D privconn->driver; - unsigned int parse_flags =3D VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; + unsigned int parse_flags =3D 0; virDomainSnapshotObjList *snapshots =3D NULL; virDomainMomentObj *current; bool job =3D false; diff --git a/tests/qemudomainsnapshotxml2xmltest.c b/tests/qemudomainsnapsh= otxml2xmltest.c index 735d0e21a1..3fa932e755 100644 --- a/tests/qemudomainsnapshotxml2xmltest.c +++ b/tests/qemudomainsnapshotxml2xmltest.c @@ -34,7 +34,7 @@ testCompareXMLToXMLFiles(const char *inxml, g_autofree char *inXmlData =3D NULL; g_autofree char *outXmlData =3D NULL; g_autofree char *actual =3D NULL; - unsigned int parseflags =3D VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; + unsigned int parseflags =3D 0; unsigned int formatflags =3D VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE; bool cur =3D false; g_autoptr(virDomainSnapshotDef) def =3D NULL; --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1646916132; cv=none; d=zohomail.com; s=zohoarc; b=Cl06jz/Ouxd983yEYX7WXH9lCLBYeVv1F44fDLcP6HGMejPnzTRvIBgPQb+z8Py9OfJu1qFlVg5wvnlOcbtLsBWacD4fpctbdPNz+5KaQyU06A5L21NMylNMjrsB/t9Jtk/BOamLWvOHuZ5gVi7SrlNWVHNEZWEVIILiyzHJaHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916132; 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=Bj0CDx9JH4o4RGWhofXO8OxPqbHE4Utl+AggwQQ0Mo4=; b=YKvJV2//GPaqYT5LJJme7YiidaGym16iMidHn+pF+xBAEKMoqEnqZCfDHrlwV9drN6sdhB8YAVIQrlCdFNOd6zwIHoZQRENjcOPnNh5RPQc15iiI1ypsEaUB1fAi7bmSr+JNd20br9oD40om6kH8waTBbLTrwo6lkxlg/41l5xY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646916132868126.92974060271865; Thu, 10 Mar 2022 04:42:12 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-397-lqcZN5UZM0i-BhIINqstGw-1; Thu, 10 Mar 2022 07:40:59 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9BF191C168E6; Thu, 10 Mar 2022 12:40:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87778463EC6; Thu, 10 Mar 2022 12:40:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3E249195FD49; Thu, 10 Mar 2022 12:40:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5AC9A195356C for ; Thu, 10 Mar 2022 12:40:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2E83C7B6D8; Thu, 10 Mar 2022 12:40:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 906C77D3CE for ; Thu, 10 Mar 2022 12:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916131; 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=Bj0CDx9JH4o4RGWhofXO8OxPqbHE4Utl+AggwQQ0Mo4=; b=OHrCgxtJij1pgJl8yV3GlJnzJmllk80unPSUwwh8lRlvxsLWRJBHq3BQuLXYGtLNgfaheK Fi8PcP1egZ6qTjMonZ9anyj97xpnJ/QXA+EpShKLieqiIRlM+fDvOXRD5XdmbRZ9bR3bDx Z0f3O3TBFoX/klbMa3o2Ren/nucJFm8= X-MC-Unique: lqcZN5UZM0i-BhIINqstGw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/14] virDomainSnapshotDefParse: Refactor cleanup Date: Thu, 10 Mar 2022 13:40:38 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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) X-ZM-MESSAGEID: 1646916134931100003 Content-Type: text/plain; charset="utf-8" Use automatic memory cleanup, decrease scope of variables and remove the 'cleanup' label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 74 +++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 42 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index f477b67785..f3b264d2e1 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -216,17 +216,12 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, bool *current, unsigned int flags) { - virDomainSnapshotDef *def =3D NULL; - virDomainSnapshotDef *ret =3D NULL; - xmlNodePtr *nodes =3D NULL; - xmlNodePtr inactiveDomNode =3D NULL; + g_autoptr(virDomainSnapshotDef) def =3D NULL; + g_autofree xmlNodePtr *diskNodes =3D NULL; size_t i; int n; - char *state =3D NULL; - int active; - char *tmp; - char *memorySnapshot =3D NULL; - char *memoryFile =3D NULL; + g_autofree char *memorySnapshot =3D NULL; + g_autofree char *memoryFile =3D NULL; bool offline =3D !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE); virSaveCookieCallbacks *saveCookie =3D virDomainXMLOptionGetSaveCookie= (xmlopt); int domainflags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | @@ -240,18 +235,22 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { virReportError(VIR_ERR_XML_ERROR, "%s", _("a redefined snapshot must have a name")); - goto cleanup; + return NULL; } } def->parent.description =3D virXPathString("string(./description)", ct= xt); if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { + g_autofree char *state =3D NULL; + g_autofree char *domtype =3D NULL; + xmlNodePtr inactiveDomNode =3D NULL; + if (virXPathLongLong("string(./creationTime)", ctxt, &def->parent.creationTime) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing creationTime from existing snapshot"= )); - goto cleanup; + return NULL; } def->parent.parent_name =3D virXPathString("string(./parent/name)"= , ctxt); @@ -263,14 +262,14 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, */ virReportError(VIR_ERR_XML_ERROR, "%s", _("missing state from existing snapshot")); - goto cleanup; + return NULL; } def->state =3D virDomainSnapshotStateTypeFromString(state); if (def->state <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid state '%s' in domain snapshot XML"), state); - goto cleanup; + return NULL; } offline =3D (def->state =3D=3D VIR_DOMAIN_SNAPSHOT_SHUTOFF || def->state =3D=3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT); @@ -279,20 +278,19 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, * lack domain/@type. In that case, leave dom NULL, and * clients will have to decide between best effort * initialization or outright failure. */ - if ((tmp =3D virXPathString("string(./domain/@type)", ctxt))) { + if ((domtype =3D virXPathString("string(./domain/@type)", ctxt))) { xmlNodePtr domainNode =3D virXPathNode("./domain", ctxt); - VIR_FREE(tmp); if (!domainNode) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain in snapshot")); - goto cleanup; + return NULL; } def->parent.dom =3D virDomainDefParseNode(ctxt->node->doc, dom= ainNode, xmlopt, parseOpaque, domainflags); if (!def->parent.dom) - goto cleanup; + return NULL; } else { VIR_WARN("parsing older snapshot that lacks domain"); } @@ -304,10 +302,10 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, def->parent.inactiveDom =3D virDomainDefParseNode(ctxt->node->= doc, inactiveDomNode, xmlopt, NULL, = domainflags); if (!def->parent.inactiveDom) - goto cleanup; + return NULL; } } else if (virDomainXMLOptionRunMomentPostParse(xmlopt, &def->parent) = < 0) { - goto cleanup; + return NULL; } memorySnapshot =3D virXPathString("string(./memory/@snapshot)", ctxt); @@ -318,20 +316,20 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown memory snapshot setting '%s'"), memorySnapshot); - goto cleanup; + return NULL; } if (memoryFile && def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { virReportError(VIR_ERR_XML_ERROR, _("memory filename '%s' requires external snaps= hot"), memoryFile); - goto cleanup; + return NULL; } if (!memoryFile && def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("external memory snapshots require a filename= ")); - goto cleanup; + return NULL; } } else if (memoryFile) { def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; @@ -345,7 +343,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, virReportError(VIR_ERR_XML_ERROR, "%s", _("memory state cannot be saved with offline or " "disk-only snapshot")); - goto cleanup; + return NULL; } def->memorysnapshotfile =3D g_steal_pointer(&memoryFile); @@ -354,48 +352,40 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, virReportError(VIR_ERR_XML_ERROR, _("memory snapshot file path (%s) must be absolute"= ), def->memorysnapshotfile); - goto cleanup; + return NULL; } - if ((n =3D virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0) - goto cleanup; + if ((n =3D virXPathNodeSet("./disks/*", ctxt, &diskNodes)) < 0) + return NULL; if (n) def->disks =3D g_new0(virDomainSnapshotDiskDef, n); def->ndisks =3D n; for (i =3D 0; i < def->ndisks; i++) { - if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt, &def->disks[i= ], + if (virDomainSnapshotDiskDefParseXML(diskNodes[i], ctxt, &def->dis= ks[i], flags, xmlopt) < 0) - goto cleanup; + return NULL; } - VIR_FREE(nodes); if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL) { + int active; + if (!current) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("internal parse requested with NULL current")= ); - goto cleanup; + return NULL; } if (virXPathInt("string(./active)", ctxt, &active) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not find 'active' element")); - goto cleanup; + return NULL; } *current =3D active !=3D 0; } if (!offline && virSaveCookieParse(ctxt, &def->cookie, saveCookie) < 0) - goto cleanup; - - ret =3D g_steal_pointer(&def); - - cleanup: - VIR_FREE(state); - VIR_FREE(nodes); - VIR_FREE(memorySnapshot); - VIR_FREE(memoryFile); - virObjectUnref(def); + return NULL; - return ret; + return g_steal_pointer(&def); } virDomainSnapshotDef * --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1646916064; cv=none; d=zohomail.com; s=zohoarc; b=av6zR2tBHDlwntlFswC1Tio2dqGzhb9CGqMYAskY+cqI7LRVA1WEr5liZGJ0+JfdtuOxDLVpg1hDNxJTiS+btU5cBJQlBAtqdfxUTq/BqfMYowAFE2fgSEkJUpugmgn6BK+Ll8xTSKNOU9W3/J0LXdFQHd/IJTX5Sd9BMEz9w3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916064; 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=ikyg0hIpKsgRz/KvUwm8TrSIYQ3wQBRX5x9iQTjXGHw=; b=ilLL74lcS8I7TyTP3gea45hemes+WBMnOA7ErMvJMDlbAy0I1H0siTnMnOJJLz4HzboilZxLOw2lQxqBbvoeMvevdI+RZb0ckJtC6QOGJyFIXqm5hZJRZRV1eo2R/qQhY8fxkksrZTPTZ7xHy9Ztx5Wovxqd2oGVqnqVD/xc5VU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1646916064253594.2399501109217; Thu, 10 Mar 2022 04:41:04 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-nhlp1fubPhSMyXmeKw9APA-1; Thu, 10 Mar 2022 07:41:02 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 288982A2AD40; Thu, 10 Mar 2022 12:41:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 136BA141DC5F; Thu, 10 Mar 2022 12:41:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B2D3D1953576; Thu, 10 Mar 2022 12:40:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EA5C71953573 for ; Thu, 10 Mar 2022 12:40:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AC9F77B6DF; Thu, 10 Mar 2022 12:40:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 112367B6D8 for ; Thu, 10 Mar 2022 12:40:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916064; 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=ikyg0hIpKsgRz/KvUwm8TrSIYQ3wQBRX5x9iQTjXGHw=; b=ea199HDQPNJmyVPLT2WC2WluyAlih10bk/rTINEIytXherCPLY2vhXAl+Zuhl9HkWMRHSW YcVWcd6MhTrMoLkg8W3m+4379r+aYrO1ME5DzCCWLwteqkW+zElY3vOFMKNW8mUok4p/Pg MTRKwROWVXgjZeFzX30XIDo607dzKXQ= X-MC-Unique: nhlp1fubPhSMyXmeKw9APA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/14] virDomainSnapshotDefParse: Avoid 'memoryfile' temporary variable Date: Thu, 10 Mar 2022 13:40:39 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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) X-ZM-MESSAGEID: 1646916081381100001 Content-Type: text/plain; charset="utf-8" Assign directly into the definition. The cleanup code can deal with that. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index f3b264d2e1..7f98ae6aec 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -221,7 +221,6 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, size_t i; int n; g_autofree char *memorySnapshot =3D NULL; - g_autofree char *memoryFile =3D NULL; bool offline =3D !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE); virSaveCookieCallbacks *saveCookie =3D virDomainXMLOptionGetSaveCookie= (xmlopt); int domainflags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | @@ -309,7 +308,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, } memorySnapshot =3D virXPathString("string(./memory/@snapshot)", ctxt); - memoryFile =3D virXPathString("string(./memory/@file)", ctxt); + def->memorysnapshotfile =3D virXPathString("string(./memory/@file)", c= txt); if (memorySnapshot) { def->memory =3D virDomainSnapshotLocationTypeFromString(memorySnap= shot); if (def->memory <=3D 0) { @@ -318,20 +317,20 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, memorySnapshot); return NULL; } - if (memoryFile && + if (def->memorysnapshotfile && def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { virReportError(VIR_ERR_XML_ERROR, _("memory filename '%s' requires external snaps= hot"), - memoryFile); + def->memorysnapshotfile); return NULL; } - if (!memoryFile && + if (!def->memorysnapshotfile && def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("external memory snapshots require a filename= ")); return NULL; } - } else if (memoryFile) { + } else if (def->memorysnapshotfile) { def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; } else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { def->memory =3D (offline ? @@ -345,7 +344,6 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, "disk-only snapshot")); return NULL; } - def->memorysnapshotfile =3D g_steal_pointer(&memoryFile); /* verify that memory path is absolute */ if (def->memorysnapshotfile && !g_path_is_absolute(def->memorysnapshot= file)) { --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1646916135; cv=none; d=zohomail.com; s=zohoarc; b=I+gnrShJiqL63YQ+p0wde62CYi0+LfkMmCmIOFzm5SmTb2w56KLa8YvsKiY12//89vvBZ/OIZr4Tsb1PHrS58ukKiyvAy6Tqlv14Xw1jp4NjH0NoXSeFaetqYdzGmDDxgtjsklKHEQt5VzNJkTgwp/f9bKKwc2AlKVNXjON+jHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916135; 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=Gcrk9sXtXSTKEgmThIBjgILddceYN75pB44Azz8AWx8=; b=CfuybUcwL4N+molawOmphU7j9jsJ3ThsS5GRwvkeIQUtK5gvKHd7oax8hnO56c2VzBZCyjdTPtV1xK0QdTpMg8hv9XmHYxpelToJL8Wqcj8OkYPZP+3LyT4/adrATLdc4hg66pCnM6hCjz85PwwDk4dontwfYNLUCKgs7sYZh2g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646916135050995.6277813701945; Thu, 10 Mar 2022 04:42:15 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-507-0nfzD7SYOI6ItzSwPbPAQw-1; Thu, 10 Mar 2022 07:41:03 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F357899EC1; Thu, 10 Mar 2022 12:41:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14DD3C080A2; Thu, 10 Mar 2022 12:41:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DB681195FD6E; Thu, 10 Mar 2022 12:40:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EFCFB195356D for ; Thu, 10 Mar 2022 12:40:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BFE587C0F6; Thu, 10 Mar 2022 12:40:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 245177B6D8 for ; Thu, 10 Mar 2022 12:40:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916133; 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=Gcrk9sXtXSTKEgmThIBjgILddceYN75pB44Azz8AWx8=; b=BuSMzRKQTRoYVfgGi8v1BTDYiI9Mxy1Kx2ZxyBHEWAU9RxpBo+JeCYeonvd4Jqi/iqCYEH Vq+Qq7/lNRXQr6LQH1h0xMSkJc+ModyO/cad5AxqFj2hx+Gk6Jo2CxNSfpJe+Pweizg55c /ADMHnW9qbdxuWFJTDr2K30k5euc57c= X-MC-Unique: 0nfzD7SYOI6ItzSwPbPAQw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/14] virDomainSnapshotDefParse: Decouple parsing of memory snapshot config Date: Thu, 10 Mar 2022 13:40:40 +0100 Message-Id: <2a956575f480d4f14299e753284bc9dbfa93568e.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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) X-ZM-MESSAGEID: 1646916137253100001 Content-Type: text/plain; charset="utf-8" Separate the steps of parsing the memory snapshot config from the post-processing and validation code. The upcoming patch refactoring the parsing will be simpler. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 50 ++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 7f98ae6aec..594492ccd2 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -317,27 +317,37 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, memorySnapshot); return NULL; } - if (def->memorysnapshotfile && - def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { - virReportError(VIR_ERR_XML_ERROR, - _("memory filename '%s' requires external snaps= hot"), - def->memorysnapshotfile); - return NULL; - } - if (!def->memorysnapshotfile && - def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("external memory snapshots require a filename= ")); - return NULL; + } + + if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT) { + if (def->memorysnapshotfile) { + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; + } else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { + if (offline) { + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; + } else { + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; + } } - } else if (def->memorysnapshotfile) { - def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - } else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { - def->memory =3D (offline ? - VIR_DOMAIN_SNAPSHOT_LOCATION_NO : - VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL); - } - if (offline && def->memory && + } + + if (def->memorysnapshotfile && + def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { + virReportError(VIR_ERR_XML_ERROR, + _("memory filename '%s' requires external snapshot"= ), + def->memorysnapshotfile); + return NULL; + } + + if (!def->memorysnapshotfile && + def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("external memory snapshots require a filename")); + return NULL; + } + + if (offline && + def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT && def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO) { virReportError(VIR_ERR_XML_ERROR, "%s", _("memory state cannot be saved with offline or " --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1646916123; cv=none; d=zohomail.com; s=zohoarc; b=U3OBbskMzI8b6pP2sII/dZanUtg3s12wfKEU8poipME4bO/2Td+c8M/MXKQlRQ1628YV5VWRR958HY1FITrenVAyXf7L8e+ZCzYQ0fcIFs0+35qan4YpV6pXbXB6YGCRcofLmKCR9g64ufsi44CaabEakCcGaBtGu5BXU8+Mht8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916123; 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=tqP1MPV/E+ioIO9OgyToclbw9dtm5R8AJjb31kyCl0A=; b=NZ6Qwdle3e4FSCfkgfTkdcb3by3VPhaaPPsEPFlt2YjSaD/mIQOzBoGJqHQDp7rFFJP7Ns3nUoYqui3zhc2rJiBRPUb3dM0PW32IXaxlhAcsVAw92f8uOqEBu4GmGyRMNFTtVZNbas4BqlWW052cIbotOPY9yCNOpHjsN9U5KOk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1646916123579328.51873349072787; Thu, 10 Mar 2022 04:42:03 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-BTpyYl76MWS8k__nCaqsZA-1; Thu, 10 Mar 2022 07:41:03 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9A1B738025F5; Thu, 10 Mar 2022 12:41:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 830254010FD5; Thu, 10 Mar 2022 12:41:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2ED3C195FD44; Thu, 10 Mar 2022 12:41:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 659F3195356D for ; Thu, 10 Mar 2022 12:41:00 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 23EC47B6DF; Thu, 10 Mar 2022 12:41:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E2397B6D8 for ; Thu, 10 Mar 2022 12:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916122; 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=tqP1MPV/E+ioIO9OgyToclbw9dtm5R8AJjb31kyCl0A=; b=B54suQxEEbtrNEMJTmnu8033m9mi4BN53qft+gk+6jt1K/q35UvuqrCaPylLxM4k7niXdq 2YZwkFaGoxntuxHWFYoPRofEJfO/kzaMWeFn7OTOyLFQzefEHPMIVqeQW+GxFP3c1cg5ZU mLcNehcpD/O1QwhcFCZpbK8gNI108kc= X-MC-Unique: BTpyYl76MWS8k__nCaqsZA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/14] conf: snapshot: Use proper types for snapshot location Date: Thu, 10 Mar 2022 13:40:41 +0100 Message-Id: <43f843de3dee7d9c26a165c8c3017b8a01e80731.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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) X-ZM-MESSAGEID: 1646916125638100001 Content-Type: text/plain; charset="utf-8" Refactor the code to use proper types for the memory and disk snapshot location and fix the parsing code to be compatible with an unsigned type. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 39 +++++++++++++++++---------------------- src/conf/snapshot_conf.h | 4 ++-- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 594492ccd2..e2442441d0 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -130,7 +130,6 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, unsigned int flags, virDomainXMLOption *xmlopt) { - g_autofree char *snapshot =3D NULL; g_autofree char *driver =3D NULL; g_autofree char *name =3D NULL; g_autoptr(virStorageSource) src =3D virStorageSourceNew(); @@ -145,16 +144,12 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, return -1; } - snapshot =3D virXMLPropString(node, "snapshot"); - if (snapshot) { - def->snapshot =3D virDomainSnapshotLocationTypeFromString(snapshot= ); - if (def->snapshot <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk snapshot setting '%s'"), - snapshot); - return -1; - } - } + if (virXMLPropEnumDefault(node, "snapshot", + virDomainSnapshotLocationTypeFromString, + VIR_XML_PROP_NONZERO, + &def->snapshot, + VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT) < 0) + return -1; if (virXMLPropEnumDefault(node, "type", virStorageTypeFromString, @@ -196,7 +191,8 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, return -1; } - if (!def->snapshot && (src->path || src->format)) + if (def->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT && + (src->path || src->format)) def->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; def->name =3D g_steal_pointer(&name); @@ -220,7 +216,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, g_autofree xmlNodePtr *diskNodes =3D NULL; size_t i; int n; - g_autofree char *memorySnapshot =3D NULL; + xmlNodePtr memoryNode =3D NULL; bool offline =3D !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE); virSaveCookieCallbacks *saveCookie =3D virDomainXMLOptionGetSaveCookie= (xmlopt); int domainflags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | @@ -307,16 +303,15 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, return NULL; } - memorySnapshot =3D virXPathString("string(./memory/@snapshot)", ctxt); - def->memorysnapshotfile =3D virXPathString("string(./memory/@file)", c= txt); - if (memorySnapshot) { - def->memory =3D virDomainSnapshotLocationTypeFromString(memorySnap= shot); - if (def->memory <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown memory snapshot setting '%s'"), - memorySnapshot); + if ((memoryNode =3D virXPathNode("./memory", ctxt))) { + def->memorysnapshotfile =3D virXMLPropString(memoryNode, "file"); + + if (virXMLPropEnumDefault(memoryNode, "snapshot", + virDomainSnapshotLocationTypeFromString, + VIR_XML_PROP_NONZERO, + &def->memory, + VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT) < = 0) return NULL; - } } if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT) { diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 8823af1ac1..1f787f1a94 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -51,7 +51,7 @@ G_STATIC_ASSERT((int)VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT = =3D=3D VIR_DOMAIN_LAST); typedef struct _virDomainSnapshotDiskDef virDomainSnapshotDiskDef; struct _virDomainSnapshotDiskDef { char *name; /* name matching the ndisks */ --=20 2.35.1 From nobody Tue May 14 16:06:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1646916135; cv=none; d=zohomail.com; s=zohoarc; b=ed5pbrvtNvN2BUygsbzlpZGIf3B5l70sDxDiWJmzJtmqp+a+YFDg+9f3xaipFFcvTGBIxljwgdt7vRAW4ktswuOjA3QKI75x2L6PBeYy/WNBQB3tCriuyB8Lbr6WloN9rBZLZ2wPbGitoiW7fsn/3BgPfAwgQiw6z1ZM8kIQDio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646916135; 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=aNZkFmBnKpT6l7wj/ZLI4zVh62Txak8hTmCdGhfy1Y4=; b=FCAkl6cf8WpoOSTtmSBfS5Jf5TypbSEkqd0pySfg9O8lIpoUTxBu2rbTEPfkftLUfQpXq1eHiDQq2k06rrJG2Oq8yGO7lLYrpEQwsneGvXN0+mJ60QiTNKn8/QzgB0G1FO8jCLeOgfSuDzxc/HhJxUVLsP+xk8mkULmo//8y7z4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1646916135135675.9044201656988; Thu, 10 Mar 2022 04:42:15 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-480-ikDvdMzZOFWU3obnS2et3A-1; Thu, 10 Mar 2022 07:41:07 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3C50D38025F2; Thu, 10 Mar 2022 12:41:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2906A141DED9; Thu, 10 Mar 2022 12:41:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D3322195FD49; Thu, 10 Mar 2022 12:41:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9863D1953576 for ; Thu, 10 Mar 2022 12:41:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6551E7C0F6; Thu, 10 Mar 2022 12:41:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 846B77B6D8 for ; Thu, 10 Mar 2022 12:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646916133; 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=aNZkFmBnKpT6l7wj/ZLI4zVh62Txak8hTmCdGhfy1Y4=; b=Wo7t7KbykCOy9tfVwF8VQhsEQTq50L68LW6ELOHkDnz+surIW22RIEwTgbuLo/GYYzKuzx KXu8uaQ9dLNCghxOwFUMJrr5z69EjmmwYSlzIfgXFVLHupb5y3HXICgXCdvdAFe/E+rwZi mUC8PV3XaBWHrVDKG+d0V54aGqV76yc= X-MC-Unique: ikDvdMzZOFWU3obnS2et3A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/14] qemuSnapshotCreateActiveExternal: Remove duplicit assignment Date: Thu, 10 Mar 2022 13:40:42 +0100 Message-Id: <186dd5ac3aac56d9b515e25d651054b79fc25e32.1646915960.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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) X-ZM-MESSAGEID: 1646916137302100002 Content-Type: text/plain; charset="utf-8" The block of code pausing the VM assigns 'resume' to true but it's already true because of the previous condition. The code is deliberately kept in two blocks as upcoming changes will modify both conditions. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 3fb1d3abe0..a7901779fc 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1400,8 +1400,6 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, _("guest unexpectedly quit")); goto cleanup; } - - resume =3D true; } } --=20 2.35.1