From nobody Fri May 16 17:11:28 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1494598975561776.482707131372; Fri, 12 May 2017 07:22:55 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id E4930C057FA7; Fri, 12 May 2017 14:22:53 +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 BF3677DB69; Fri, 12 May 2017 14:22: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 66E4A1800C96; Fri, 12 May 2017 14:22: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 v4CEMpcq021069 for ; Fri, 12 May 2017 10:22:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 214517DB54; Fri, 12 May 2017 14:22:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BF1C7DB58 for ; Fri, 12 May 2017 14:22:49 +0000 (UTC) Received: from relay.sw.ru (mailhub.sw.ru [195.214.232.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5CF2D1555A for ; Fri, 12 May 2017 14:22:47 +0000 (UTC) Received: from dim-vz7.qa.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4CDbfTf007950; Fri, 12 May 2017 16:37:41 +0300 (MSK) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E4930C057FA7 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E4930C057FA7 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5CF2D1555A Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=nshirokovskiy@virtuozzo.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5CF2D1555A From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Fri, 12 May 2017 16:37:24 +0300 Message-Id: <1494596248-446694-9-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1494596248-446694-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1494596248-446694-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Greylist: Delayed for 00:44:58 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:22:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 12 May 2017 14:22:48 +0000 (UTC) for IP:'195.214.232.25' DOMAIN:'mailhub.sw.ru' HELO:'relay.sw.ru' FROM:'nshirokovskiy@virtuozzo.com' RCPT:'' X-RedHat-Spam-Score: 0.799 (BAYES_50, SPF_PASS) 195.214.232.25 mailhub.sw.ru 195.214.232.25 mailhub.sw.ru X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Dmitry Mishin Subject: [libvirt] [PATCH v2 RFC 08/12] qemu: backup: check backup destination before start 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 12 May 2017 14:22:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If backup target is file then check it is not present or regular empty file otherwise. If backup target is block device then check that it is present and block device actually. --- src/qemu/qemu_driver.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 73 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b20e359..f4456da 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20468,6 +20468,76 @@ qemuDomainSetBlockThreshold(virDomainPtr dom, } =20 =20 +static int +qemuDomainBackupCheckTarget(virDomainBackupDiskDefPtr disk) +{ + int ret =3D -1; + struct stat st; + virStorageSourcePtr target =3D disk->target; + + if (virStorageFileInit(target) < 0) + return -1; + + if (virStorageFileStat(target, &st) < 0) { + if (errno !=3D ENOENT) { + virReportSystemError(errno, + _("unable to stat target path '%s' for di= sk '%s'"), + target->path, disk->name); + goto cleanup; + } + switch (target->type) { + case VIR_STORAGE_TYPE_FILE: + break; + + case VIR_STORAGE_TYPE_BLOCK: + virReportError(VIR_ERR_INVALID_ARG, + _("missing target block device '%s' for disk '%= s'"), + target->path, disk->name); + goto cleanup; + + default: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected backup target type '%s' for disk = '%s'"), + virStorageTypeToString(target->type), + disk->name); + goto cleanup; + } + } else { + switch (target->type) { + case VIR_STORAGE_TYPE_FILE: + if (!S_ISREG(st.st_mode) || st.st_size > 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid existing target file '%s' for di= sk '%s'"), + target->path, disk->name); + goto cleanup; + } + break; + + case VIR_STORAGE_TYPE_BLOCK: + if (!S_ISBLK(st.st_mode)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("target file '%s' for disk '%s' is not a = block device"), + target->path, disk->name); + goto cleanup; + } + break; + + default: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected backup target type '%s' for disk = '%s'"), + virStorageTypeToString(target->type), disk->nam= e); + goto cleanup; + } + } + + ret =3D 0; + + cleanup: + virStorageFileDeinit(target); + return ret; +} + + static virDomainBackupPtr qemuDomainBackupCreateXML(virDomainPtr domain, const char *xmlDesc, @@ -20529,6 +20599,9 @@ qemuDomainBackupCreateXML(virDomainPtr domain, if (qemuDomainDiskBlockJobIsActive(disk)) goto cleanup; =20 + if (qemuDomainBackupCheckTarget(&def->disks[i]) < 0) + goto cleanup; + if (qemuGetDriveSourceString(target, NULL, &path) < 0) goto cleanup; =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list