From nobody Fri May 3 00:15:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1623856120; cv=none; d=zohomail.com; s=zohoarc; b=jdrQwZdZnt2bHDKNaACsJKusu0vrhP7VFErV5b4fM1ik2mdSQFMZf2IIFd3YGUagFj5pAiY5y/P/vzwfyL8auV5XoZqbnfX1P77EU0NXohrUgStTp4cm2PlFQg5ctToAYmGnSO+FDunHpuCI9a0QLgb9SBFW0Yx8fopx3vtOLyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623856120; 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=VHOGHUjtz3FCxRbDZNgwpSJtZPDOd4lbraOpE6seXLk=; b=NNls7P6CtKRcSRiS3xr0t/KGTXFJ98Vg5gPolipr1mRRPtsggim4mnYvZTuJL4O1kx0RVx1efd8ViM9oQ6dmR8tCc1+10cHnyrNQWVC9YUmvfa+6rHaVbgfjNUMw4NcRqXuPiTyJphJIMpQBmRKqcAP4/ZXppLpHGZXtxUC8hrg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1623856120158269.8552240979059; Wed, 16 Jun 2021 08:08:40 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-RiVGPA3qNEOzdybAcZxOIA-1; Wed, 16 Jun 2021 11:08:34 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C68841054F92; Wed, 16 Jun 2021 15:05:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 915715C1D0; Wed, 16 Jun 2021 15:05:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3DB241809CAD; Wed, 16 Jun 2021 15:05:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15GF5hMj012816 for ; Wed, 16 Jun 2021 11:05:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 817CE5D9DE; Wed, 16 Jun 2021 15:05:43 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id E266C5D9E2 for ; Wed, 16 Jun 2021 15:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623856119; 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=VHOGHUjtz3FCxRbDZNgwpSJtZPDOd4lbraOpE6seXLk=; b=a+viY8aUek/wHB1YQ70hHQivGVs80BpSlf3Vq9AkqRSF6CG6SYEpcDk3/9o1UOeSjZ/RE5 lirg25dSR4zQ+WjODohNThojfR0/FYwmRLBrbJfL5SY6BA0wxcUHvGIMQntEJH5eoMqrbh ppnTtULbs1Va8exv90NH+//dGvJMX1A= X-MC-Unique: RiVGPA3qNEOzdybAcZxOIA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/7] qemuSnapshotPrepareDiskExternal: Move temp variables into the block using them Date: Wed, 16 Jun 2021 17:05:31 +0200 Message-Id: <274185ad92f4dd048a04cea05fc3f8ae9320ac3f.1623855902.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) Content-Type: text/plain; charset="utf-8" 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 29e86342d6..67180a2b10 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -541,9 +541,6 @@ qemuSnapshotPrepareDiskExternal(virDomainObj *vm, bool reuse, bool blockdev) { - struct stat st; - int err; - int rc; if (disk->src->readonly && !(reuse || blockdev)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -567,6 +564,10 @@ qemuSnapshotPrepareDiskExternal(virDomainObj *vm, } if (virStorageSourceIsLocalStorage(snapdisk->src)) { + struct stat st; + int err; + int rc; + if (virStorageSourceInit(snapdisk->src) < 0) return -1; --=20 2.31.1 From nobody Fri May 3 00:15:14 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=1623855972; cv=none; d=zohomail.com; s=zohoarc; b=ft3UgbfZhfPjc5EszDBWc27pgx31+J/TwKRKYMndeWpMhVcAvJae8mCF0r/RjRMm5JnDw5SeSjK+gSctU4YZ69riULbFujnYJ6u41jsLw6h/3ytpWFjz98bOJsdrcmQLKZFIrXgsYOfc9rDtuqEC11UfbcVwxYESA6nNDzKjD+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623855972; 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=edEbizXu+pzFcDWVJtjiJZBjcPk5fXq2r/fpgMgih14=; b=deBTr7Io9bxSYdZjfnvzk2LjEXbJMXV39x/6Ey3CA1lWgSAsjsfDltMZ8w+5g1gwwrixgpUiB5WBn8q3LFCaWiRxUtpvoZxevKwVBqviOJ1FKoTLwwinTPuglsG1G68k7u0sTVHjFODbGATAFLK0Gjjy1LyZ5a2d+Fh5nOKKNVE= 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 1623855972424758.9447026489268; Wed, 16 Jun 2021 08:06:12 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-xdxAWQgbPKmtK8k26irN8Q-1; Wed, 16 Jun 2021 11:06:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1AA69127A; Wed, 16 Jun 2021 15:05:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9331D421F; Wed, 16 Jun 2021 15:05:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 59C7646F5A; Wed, 16 Jun 2021 15:05:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15GF5iNS012825 for ; Wed, 16 Jun 2021 11:05:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8BB585D9E2; Wed, 16 Jun 2021 15:05:44 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7BD25D9DE for ; Wed, 16 Jun 2021 15:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623855971; 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=edEbizXu+pzFcDWVJtjiJZBjcPk5fXq2r/fpgMgih14=; b=URTTidYURwq5CxJo0iTJbdjKMCfBSLZ3YC2JK4DfMovro7AFZERwltc9r+2k0pAT76Pkzq bPBPMtMuFtkCfTcM68dq2/fBfJXHUOG7TZNhMRawmJgFLDaTjyMSVE+Hs3cQCVlUKE0B9H QtplI6bhfi4t5+IwRv4aCpYLZFleWjA= X-MC-Unique: xdxAWQgbPKmtK8k26irN8Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/7] qemuSnapshotPrepareDiskExternal: Avoid condition squashing Date: Wed, 16 Jun 2021 17:05:32 +0200 Message-Id: <45bd48d3afb4630deaa6c50fb8a5ef65a0219f41.1623855902.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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) Content-Type: text/plain; charset="utf-8" Separate the 'else if' branches into nested conditions so that it's more obvious when we'll be adding additional checks later. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 67180a2b10..81085bf4bd 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -582,18 +582,22 @@ qemuSnapshotPrepareDiskExternal(virDomainObj *vm, _("unable to stat for disk %s: %s"), snapdisk->name, snapdisk->src->path); return -1; - } else if (reuse) { + } + + if (reuse) { virReportSystemError(err, _("missing existing file for disk %s:= %s"), snapdisk->name, snapdisk->src->path); return -1; } - } else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("external snapshot file for disk %s already " - "exists and is not a block device: %s"), - snapdisk->name, snapdisk->src->path); - return -1; + } else { + if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("external snapshot file for disk %s alrea= dy " + "exists and is not a block device: %s"), + snapdisk->name, snapdisk->src->path); + return -1; + } } } --=20 2.31.1 From nobody Fri May 3 00:15:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1623855971; cv=none; d=zohomail.com; s=zohoarc; b=Lnmls6wgENreJaPEnrFvEkKGpyw2+4wwmSUo+DFV0o+CRAm3brZS4wl6MJrGS0Aq9wEInNnPAytFHp7BWYErEXQ2wNAgzd/IeNsC3xie+2cWexA4wHpYPv4v3k4DINdfXzgEcT4Mm7yQFDY5KGJ6VZHyqCKUWvU0LyNSNhY2weI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623855971; 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=22nduQzsyvOaiAT9fRJyFj1eYFjgw2LZTXEYR7RK0yU=; b=DTASv6i79KXjaj8mgrb4gAXMOJ3cTMc4FVv6QeHv35H9mBQ3djrfvRyLOOjVG9Jys0XYkJIvHbaubbphM+jp7Mt2fhgpDab+Wbq2eiQTOZCqioq9mHCuIb05y9gFqC2sbFQHwLA61tjp7YCt+5cun69dYJs7vh8eTkwO8olJKec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1623855971172328.72292179330816; Wed, 16 Jun 2021 08:06:11 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-Rg-KEkE8P1mq-nNkDW5Pag-1; Wed, 16 Jun 2021 11:06:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D2789126D; Wed, 16 Jun 2021 15:05:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3BE360613; Wed, 16 Jun 2021 15:05:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BE73A1809CBB; Wed, 16 Jun 2021 15:05:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15GF5llo012843 for ; Wed, 16 Jun 2021 11:05:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 93BEF5D9DE; Wed, 16 Jun 2021 15:05:47 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id F39BA5D9E2 for ; Wed, 16 Jun 2021 15:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623855970; 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=22nduQzsyvOaiAT9fRJyFj1eYFjgw2LZTXEYR7RK0yU=; b=HYkIUqPy5VW7wJcogaGXXfzPjEo44xD0vXDTX1GS/Gp+8u/xvtudqfDpRQ8wCBScHMtc0M pL13cOjL6l36ffpYcH+PWC+LUx9AI1LEuX4YYBXL5wAKWWUVE0ViOU0+hjoqqDz/JYJwIA LXSZwkbrOYW7QGFp5IhiBOgrlOpGRxc= X-MC-Unique: Rg-KEkE8P1mq-nNkDW5Pag-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/7] qemuSnapshotPrepareDiskExternal: Reject creation of block devices sooner Date: Wed, 16 Jun 2021 17:05:33 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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) Content-Type: text/plain; charset="utf-8" In case when the snapshot target is of VIR_STORAGE_TYPE_BLOCK type and doesn't exist libvirt won't be able to create it. Reject such a config sooner. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 81085bf4bd..f06d0ada38 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -589,6 +589,13 @@ qemuSnapshotPrepareDiskExternal(virDomainObj *vm, _("missing existing file for disk %s:= %s"), snapdisk->name, snapdisk->src->path); return -1; + } else { + if (snapdisk->src->type =3D=3D VIR_STORAGE_TYPE_BLOCK) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("block device snapshot target '%s' do= esn't exist"), + snapdisk->src->path); + return -1; + } } } else { if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) { --=20 2.31.1 From nobody Fri May 3 00:15:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1623855991; cv=none; d=zohomail.com; s=zohoarc; b=Xh6Sug/ZRPXXUhW9P+zJ7zlmlxailmwaQJflaMPhSXEa/Bt+757aFZAve0qcgkYHg638pJkc1dtjkGXK8gB1d1FWT3ds3eyYr61ebctuHTB2qp0+L3Ottst1VkIbX43+NzwWe2SAX56hP9fGeWngQUuB5gr7caJSdowwesjFLvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623855991; 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=J/TZ4WQ/NKOfpnmG2RxTR03CvGdnvWhzI/If011ngx4=; b=X73+Q8WDapODPYi12Sx+m5uTOOwi5FLKkBz+soRwUlekdkMEwc8wJcGnHs491PUPdk90njI7mNDVgEpL72wr/GuTKak0+QP32RTF9HncccDmfAxKOvnA6WAyZsCIAfspIDxPrQIY3Exs9YmPbFPlC+IdogT2nQpv+DFEDx8kjZQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1623855991552484.3567763244514; Wed, 16 Jun 2021 08:06:31 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-223-stLlBAtYNiSZvaAsr-nfqQ-1; Wed, 16 Jun 2021 11:05:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 631F010C79E0; Wed, 16 Jun 2021 15:05:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A4AE10074E1; Wed, 16 Jun 2021 15:05:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F000646F82; Wed, 16 Jun 2021 15:05:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15GF5md3012851 for ; Wed, 16 Jun 2021 11:05:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id A80695D9E3; Wed, 16 Jun 2021 15:05:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A1FA5D9E2 for ; Wed, 16 Jun 2021 15:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623855957; 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=J/TZ4WQ/NKOfpnmG2RxTR03CvGdnvWhzI/If011ngx4=; b=g14Gey1MfME8lZ6CYnRUD0VOMf2cIQHmCz2nHKOCeWUdlH5KzDL2epn2t5lSsEeKefGdC1 +VA1ltf93XOqkpY6N+A3547zknFFvhnEQU8ZP1shuhlNQc500yQCyZb7mZ07YGfvqzG5am 8C9DZN+CZ03ZjL+70xFNt4RJ5shP04s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623855990; 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=J/TZ4WQ/NKOfpnmG2RxTR03CvGdnvWhzI/If011ngx4=; b=eZLopYSnDJQwczux2Ja9zfUKE9G0poIy5Gd8aAPeHWJfOwTqmZCj73fvV0KS4DphkfwhWe 3V1iJHcT8ucVWM/uUVc820R2/I2q+rhGFOexnZsTimKkJoeihoFMa8kUQyHXZX/cs3TP5+ arjsKgkueaITNFXUg3rdEF4CY3rS2Vw= X-MC-Unique: stLlBAtYNiSZvaAsr-nfqQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/7] qemuSnapshotPrepareDiskExternal: Enforce match between snapshot type and existing file type Date: Wed, 16 Jun 2021 17:05:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The code executed later when creating a snapshot makes all decisions based on the configured type rather than the actual type of the existing file, while the check whether the file exists is based solely on the on-disk type. Since a block device is allowed to exist even when not reusing existing files in contrast to regular files this creates a potential for a block device to squeak past the check but then be influenced by other code executed later. Specifically this is a problem when creating a snapshot with the following XML: If the snapshot creation fails, '/dev/sdb' will be removed because it's considered to be a regular file by the cleanup code. Add a check that will force that the configured type matches the on-disk state. Additional supporting reason is that qemu stopped to accept block devices with the 'file' backend, thus the above configuration will not work any more. This allows us to fail sooner. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1972145 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index f06d0ada38..96c43f69e7 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -598,6 +598,15 @@ qemuSnapshotPrepareDiskExternal(virDomainObj *vm, } } } else { + /* at this point VIR_STORAGE_TYPE_DIR was already rejected */ + if ((snapdisk->src->type =3D=3D VIR_STORAGE_TYPE_BLOCK && !S_I= SBLK(st.st_mode)) || + (snapdisk->src->type =3D=3D VIR_STORAGE_TYPE_FILE && !S_IS= REG(st.st_mode))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("mismatch between configured type for sna= pshot disk '%s' and the type of existing file '%s'"), + snapdisk->name, snapdisk->src->path); + return -1; + } + if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("external snapshot file for disk %s alrea= dy " --=20 2.31.1 From nobody Fri May 3 00:15:14 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=1623856033; cv=none; d=zohomail.com; s=zohoarc; b=jqPQmQW9ds3Wcz8ugkD0B0JdUZH8JmIcmMTqZlNDuWaFmV6dyw9vkE8kJ0XHGndW4eI37BlnjMYyyv5iz+qaA1MKcm6iHzmUH8jZHt1DLD+JwHq+JViCK2alwsPIcgR8xLeLteBtB5MC1QcI3zbBNXic4AYYbLDsrdYApSaA85Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623856033; 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=xRJ+fSjbaDLHCiUIu0FIr2L3Z7CDijLQfelpcGCGiDU=; b=YI6DLm7RrwEc2iB9580NW0AcQpYmNEMpSs7kxQ02eCC2VO52YRTVRLF2xdI/yzB6TT6OyT5rTuwtwIZrX0qfYz99y49hBuhRm0+u8niVZcTJWTPfJkBOYgP6d+lxxiw7Ixlr/R9wdTx4oVA0zo79vw4JB89eQLZ6pAJOfzPudCQ= 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 1623856033800897.9500580638011; Wed, 16 Jun 2021 08:07:13 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-602-pfA6ebnCMUGdGz7zit-3uA-1; Wed, 16 Jun 2021 11:06:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB8598049D4; Wed, 16 Jun 2021 15:05:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97EF45DA27; Wed, 16 Jun 2021 15:05:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3411A1809CBC; Wed, 16 Jun 2021 15:05:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15GF5ntu012861 for ; Wed, 16 Jun 2021 11:05:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id B60945D9E3; Wed, 16 Jun 2021 15:05:49 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2114D5D9E2 for ; Wed, 16 Jun 2021 15:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623856031; 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=xRJ+fSjbaDLHCiUIu0FIr2L3Z7CDijLQfelpcGCGiDU=; b=MI/ffGJFGSRX6UpeAykCPpfmQ34RXS7wTeq4WtUS55uzssl88phcXtHWDIrx4/gGC/hiGn VMntBHMHzmulh7sHvuA1FwqLKNpx2vCHCtx+h2HOhkdMjndtohFMOBKdHK9Y9nUh+u069a YPRLuc9GCNCILUubMoRdgwukk2geOf8= X-MC-Unique: pfA6ebnCMUGdGz7zit-3uA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/7] qemuSnapshotPrepareDiskExternal: Refactor existing file check Date: Wed, 16 Jun 2021 17:05:35 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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) Content-Type: text/plain; charset="utf-8" Use the snapshot disk type from the definition now that we validate that it matches. 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 96c43f69e7..dab386e455 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -607,10 +607,11 @@ qemuSnapshotPrepareDiskExternal(virDomainObj *vm, return -1; } - if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) { + if (!reuse && + snapdisk->src->type =3D=3D VIR_STORAGE_TYPE_FILE && + st.st_size > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("external snapshot file for disk %s alrea= dy " - "exists and is not a block device: %s"), + _("external snapshot file for disk %s alrea= dy exists and is not a block device: %s"), snapdisk->name, snapdisk->src->path); return -1; } --=20 2.31.1 From nobody Fri May 3 00:15:14 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=1623856023; cv=none; d=zohomail.com; s=zohoarc; b=U/Dw0ZFfJ4/49G8idhBu/B0b5fMmzjO/vb7lZ0DidnhjdtUD6/8VSvzK03EEVngBC9VtwyqK9NVk82rQC0t8VqHskFd/dMt541p/4pHpWSRNzj9QyOqk/7XZM+Cw5K1TBVbHzOUfemMmiy8coleru0mfgYYULzZzbtvbT98LbjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623856023; 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=d0Az2Xb7UQyI0c4o2UyuzQyZ2j7bK9qu9IayYBrBMtQ=; b=BPnunBaLSnnKokhG1QFC3hNVJ2XfA4EFK+LUr+MhXf8/YAZk+i1ekt6zdivkMlL3wICV+Ta6+CKKZJiUM8dHr1PyvGOmGl47MUn72z7KrtPFMorW3+tTjB1A8pff3DMEeTE1KKWWynczrIGpyklBUw/6I//vzHMBImN0AzPlF/E= 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 1623856023837114.39595587264353; Wed, 16 Jun 2021 08:07:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-91GFwNaXOA2SlvsShVqrOQ-1; Wed, 16 Jun 2021 11:06:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0816A91275; Wed, 16 Jun 2021 15:05:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6A3D5D9F2; Wed, 16 Jun 2021 15:05:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9D6BC46F5D; Wed, 16 Jun 2021 15:05:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15GF5oSl012871 for ; Wed, 16 Jun 2021 11:05:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF2545D9E3; Wed, 16 Jun 2021 15:05:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 447375D9E2 for ; Wed, 16 Jun 2021 15:05:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623856022; 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=d0Az2Xb7UQyI0c4o2UyuzQyZ2j7bK9qu9IayYBrBMtQ=; b=OYn1gbCGoBBUpM0zcPyC7MX0/dhl6yrMZj9vcS8PDlm7KF1mCgCpngLGZ+WKra4XvQbxgS APwvADpqMBPBT9opC9IRkSy8+X5cy9IsYyzjEUPB8A4wJgRxwEXEY95iqjK/jxdIN66CBM v+MMKzj780Q2uKvkDJYnD1ZIDKZ3QUQ= X-MC-Unique: 91GFwNaXOA2SlvsShVqrOQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/7] conf: snapshot: rename variable holding memory snapshot file location Date: Wed, 16 Jun 2021 17:05:36 +0200 Message-Id: <157b3b5f4148210de114c7ecd03cfa7a5ab872ef.1623855902.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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) Content-Type: text/plain; charset="utf-8" 'file' is too generic to know what's going on. Rename it to 'memorysnapshotfile'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 10 +++++----- src/conf/snapshot_conf.h | 2 +- src/qemu/qemu_snapshot.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index df3f2a4c63..0592640dd9 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -125,7 +125,7 @@ virDomainSnapshotDefDispose(void *obj) virDomainSnapshotDef *def =3D obj; size_t i; - g_free(def->file); + g_free(def->memorysnapshotfile); for (i =3D 0; i < def->ndisks; i++) virDomainSnapshotDiskDefClear(&def->disks[i]); g_free(def->disks); @@ -360,13 +360,13 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, "disk-only snapshot")); goto cleanup; } - def->file =3D g_steal_pointer(&memoryFile); + def->memorysnapshotfile =3D g_steal_pointer(&memoryFile); /* verify that memory path is absolute */ - if (def->file && !g_path_is_absolute(def->file)) { + if (def->memorysnapshotfile && !g_path_is_absolute(def->memorysnapshot= file)) { virReportError(VIR_ERR_XML_ERROR, _("memory snapshot file path (%s) must be absolute"= ), - def->file); + def->memorysnapshotfile); goto cleanup; } @@ -863,7 +863,7 @@ virDomainSnapshotDefFormatInternal(virBuffer *buf, if (def->memory) { virBufferAsprintf(buf, "memor= y)); - virBufferEscapeString(buf, " file=3D'%s'", def->file); + virBufferEscapeString(buf, " file=3D'%s'", def->memorysnapshotfile= ); virBufferAddLit(buf, "/>\n"); } diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 7d49a555cd..a3ec0cd410 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -82,7 +82,7 @@ struct _virDomainSnapshotDef { int state; /* virDomainSnapshotState */ int memory; /* virDomainMemorySnapshot */ - char *file; /* memory state file when snapshot is external */ + char *memorysnapshotfile; /* memory state file when snapshot is extern= al */ size_t ndisks; /* should not exceed dom->ndisks */ virDomainSnapshotDiskDef *disks; diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index dab386e455..99fc4b836f 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1451,9 +1451,9 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, goto cleanup; xml =3D NULL; - if ((ret =3D qemuSaveImageCreate(driver, vm, snapdef->file, data, - compressor, 0, - QEMU_ASYNC_JOB_SNAPSHOT)) < 0) + if ((ret =3D qemuSaveImageCreate(driver, vm, snapdef->memorysnapsh= otfile, + data, compressor, 0, + QEMU_ASYNC_JOB_SNAPSHOT)) < 0) goto cleanup; /* the memory image was created, remove it on errors */ @@ -1522,7 +1522,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, virQEMUSaveDataFree(data); if (memory_unlink && ret < 0) - unlink(snapdef->file); + unlink(snapdef->memorysnapshotfile); return ret; } --=20 2.31.1 From nobody Fri May 3 00:15:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1623856033; cv=none; d=zohomail.com; s=zohoarc; b=dmBrJuPCq0RjUM73bGCOL44PybgdZzet+WIC1hbfxrWSAjKl2fPSLC7GEJd976SI3stAR5rsvmHcdW2nIRaeh1XalxJezcexUty2gK/BZjnD3muQLi3bR6CT0sKJw4WvTBTEpsq/s7YEnF21pW5+bWFjE+kUuhxtr345xzuVEsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623856033; 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=5/3sKjPcixzjY7EHUca4yVl14v3h4da5FoYr8AbKPpo=; b=RXedgLXm2xXwwO73B/gw9uriy5O8V5U/NydzlfhhRzrg9RRa6+j8jLXVRYRnYpTt8WBcyEgW7Fu5ksYLOEpX5V5GOoKPIbRtlvHRqcydsSaTX/S8q7wG9wrL++xzliPVHISbLnScChKoI8yhYaD3dEXAq7aPkmVwV5LDAaNaCD0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1623856033683929.557996966563; Wed, 16 Jun 2021 08:07:13 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-66-c8h_O7DSNMWvs500dCAgkA-1; Wed, 16 Jun 2021 11:06:10 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 031018042AD; Wed, 16 Jun 2021 15:06:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2A291001B2C; Wed, 16 Jun 2021 15:05:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9A3491809CBE; Wed, 16 Jun 2021 15:05:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15GF5qMQ012877 for ; Wed, 16 Jun 2021 11:05:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0B2165D9E3; Wed, 16 Jun 2021 15:05:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5676C5D9E2 for ; Wed, 16 Jun 2021 15:05:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623856031; 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=5/3sKjPcixzjY7EHUca4yVl14v3h4da5FoYr8AbKPpo=; b=FjPZw1xlhMD4LAZGjSINasG8QBZbCVwE1J2rGJhNsWtYsni9XOy9mPbuvsXeEXgtimK/zN MEjLI+YSagEbi5AUCQ5CSBuWvkjLn8UnsT4Gvkh3cXQPvg/JEy35HLn3b4NWqpZqhPr2SS hJWIBa/HZ/Y41zlnx+7iarcXBHDVWpU= X-MC-Unique: c8h_O7DSNMWvs500dCAgkA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 7/7] qemuSnapshotCreateActiveExternal: Don't unlink memory snapshot image if it was existing before Date: Wed, 16 Jun 2021 17:05:37 +0200 Message-Id: <1cadd16e7fa882b4f4df278048fdf2072b7d4e23.1623855902.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) Content-Type: text/plain; charset="utf-8" When writing the memory snapshot into an existing file don't remove it if the snapshot fails later. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 99fc4b836f..4e74ddd7f8 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1356,6 +1356,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); bool memory =3D snapdef->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EX= TERNAL; bool memory_unlink =3D false; + bool memory_existing =3D false; bool thaw =3D false; bool pmsuspended =3D false; int compressed; @@ -1451,13 +1452,16 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *dri= ver, goto cleanup; xml =3D NULL; + memory_existing =3D virFileExists(snapdef->memorysnapshotfile); + if ((ret =3D qemuSaveImageCreate(driver, vm, snapdef->memorysnapsh= otfile, data, compressor, 0, QEMU_ASYNC_JOB_SNAPSHOT)) < 0) goto cleanup; /* the memory image was created, remove it on errors */ - memory_unlink =3D true; + if (!memory_existing) + memory_unlink =3D true; /* forbid any further manipulation */ qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_DEFAULT_MASK); --=20 2.31.1