From 308aafe289ae377d6508964512d41df2712c50b3 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 16 Jun 2021 15:43:03 +0200 Subject: [PATCH] qemuSnapshotPrepareDiskExternal: Refactor existing file check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the snapshot disk type from the definition now that we validate that it matches. Signed-off-by: Peter Krempa Reviewed-by: Ján 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 == VIR_STORAGE_TYPE_FILE && + st.st_size > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("external snapshot file for disk %s already " - "exists and is not a block device: %s"), + _("external snapshot file for disk %s already exists and is not a block device: %s"), snapdisk->name, snapdisk->src->path); return -1; }