From nobody Mon May 6 02:03:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; 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 1515367926335937.3433727882092; Sun, 7 Jan 2018 15:32:06 -0800 (PST) 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 99A6BC04B94A; Sun, 7 Jan 2018 23:32:03 +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 6B0715DC1E; Sun, 7 Jan 2018 23:32:01 +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 01D144EBDE; Sun, 7 Jan 2018 23:31:57 +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 w07NVtkS032280 for ; Sun, 7 Jan 2018 18:31:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0CAD85DC1E; Sun, 7 Jan 2018 23:31:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04D1E5D9CD for ; Sun, 7 Jan 2018 23:31:52 +0000 (UTC) Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E016B81127 for ; Sun, 7 Jan 2018 23:31:51 +0000 (UTC) Received: by mail-qk0-f193.google.com with SMTP id r8so7928876qke.6 for ; Sun, 07 Jan 2018 15:31:51 -0800 (PST) Received: from localhost.localdomain ([187.107.180.10]) by smtp.googlemail.com with ESMTPSA id z17sm6574620qti.59.2018.01.07.15.31.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 07 Jan 2018 15:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=62wDiApDy4CpNiOl6l2jwSDvi1MpNmMLah3NtF+qMLE=; b=KUguWJKWso9GhXUDN4KBjIRd5aAcmbiXu8dmrmm7rMgDMB0nR1knrMKCzZJ7xLkSqe TxTOHbrj0s3Hjb2bJKmnODI3364qnLy529OoqyojRV3n4br58fygJgbvRDbfV87A6CGx 0N4QF4Bkly9q8hbfQH2cHMF/h/CVXTBvMONpvg/30EmehIjobkcJFC1JbkLbYMdRbQxg kE08hQR06Qa5RGhwXv6ch0eUix67+O9G8GnGTA2HLsj40a1dMCVvYeZj3aaeh3Dego0I jWZwgiUp2g63Ue+BNo4P3ndqVLuQ16iaL1zA1ylbYdZ32gauqlDflE3TbkrZYk4Gb1oh GyVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=62wDiApDy4CpNiOl6l2jwSDvi1MpNmMLah3NtF+qMLE=; b=RTFOfsXN1AqgLuXYijBQCX8ctxjSGTZf2d/CQNo/A5QPQ5nTSeSlqUeAWC7hXNCnYs /VdJBbx7zmRdmbj0eHuQeO1iw+irPhtmzMccRWjx9HYj2ZKqkcqrqaBln1poEREUzShv r/309GE5fqWSm5bm+OTNb/F+LV9ULq62foz8tgGgElv+4skoeYjUj8igvK/EM5PBBueL U3nKh/JgKHUh28FMackVXZ90QTTAcJKO55Knhj6+cswlWhkb9n8i/WaHT+yRcj8SHGXb e+eEcKV456MYwQw+LE60ZqGzrawp6Ria4isNj6Q/9QYBnN4udLjTLV2vztn6DNi+VU78 myMg== X-Gm-Message-State: AKwxyteqPYSGnUKM6axUh074ENEDrQ/Uw163X65s88tM1udGRJ0226zm hxG9EsdwGOS+SrBtJwCXjrIQTQ== X-Google-Smtp-Source: ACJfBosyMW4Y44jHUTSaZowBrvV/ZuwUsFtZPfExmVPIEz8Xbwccrs2PeR8HXzjonOW7NTz7Op7KWQ== X-Received: by 10.55.89.67 with SMTP id n64mr783017qkb.178.1515367910572; Sun, 07 Jan 2018 15:31:50 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Sun, 7 Jan 2018 21:31:24 -0200 Message-Id: <1515367884-31376-1-git-send-email-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 07 Jan 2018 23:31:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 07 Jan 2018 23:31:52 +0000 (UTC) for IP:'209.85.220.193' DOMAIN:'mail-qk0-f193.google.com' HELO:'mail-qk0-f193.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.220.193 mail-qk0-f193.google.com 209.85.220.193 mail-qk0-f193.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] virsh: Checking the volume capacity before uploading a new file. 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.31]); Sun, 07 Jan 2018 23:32:05 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The current command 'vol-upload' is not checking if the volume accepts=20 a file bigger than its capacity. It can cause an interrupt of the=20 upload stream. This commit adds a check that fails before starting to=20 send new file to volume if the file is bigger. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1529059 Signed-off-by: Julio Faracco --- tools/virsh-volume.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 8265a39..1359dba 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -672,6 +672,7 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) { const char *file =3D NULL; virStorageVolPtr vol =3D NULL; + virStorageVolInfo volumeInfo; bool ret =3D false; int fd =3D -1; virStreamPtr st =3D NULL; @@ -701,6 +702,9 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) cbData.ctl =3D ctl; cbData.fd =3D fd; =20 + if (virStorageVolGetInfo(vol, &volumeInfo) < 0) + goto cleanup; + if (vshCommandOptBool(cmd, "sparse")) flags |=3D VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM; =20 @@ -709,6 +713,11 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 + if (volumeInfo.capacity <=3D virFileLength(file, fd)) { + vshError(ctl, _("file is bigger than volume %s capacity"), name); + goto cleanup; + } + if (virStorageVolUpload(vol, st, offset, length, flags) < 0) { vshError(ctl, _("cannot upload to volume %s"), name); goto cleanup; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list