From nobody Mon Apr 29 15:22:35 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; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1567443647; cv=none; d=zoho.com; s=zohoarc; b=cjvDj9y+CZMEfKyJhLBzv2suMjyl/Oby813ZGQKZLhRw46Vt/rQJq3DDsBDYqSBJCuULpPmeNWeudaeErdeJ8HyxE/GrKfC9IlknJOWcFZcXI0PBK5Xs2ZPDnF8Eb78vBTjzmT9XuU+c2YyuGER21UHG5u8tUvUpIvRweigjF4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567443647; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=49LC0QjlYfmRcm6sjwUYEKVgu0W9bGUFcfpUGlNTGuY=; b=dyN8LTSuta/JGylVv2H5BN+eBaxuRG0WFkXb5ddFUowXlRgLWC9m6yTuMJiDLo/nGsvH4JM9ZuKb/qo/wI/gobAiIUFkaNQTCn6bJZUUJ1VeyH66ml7PG5gIpfRA+lUrCJuqDUR3ukoBALXGU3ltC9+vLresNXlVbQY8s3dTlrU= ARC-Authentication-Results: i=1; mx.zoho.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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1567443647723154.77643332403613; Mon, 2 Sep 2019 10:00:47 -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 1B2BF8980F3; Mon, 2 Sep 2019 17:00:46 +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 E3AE75D9CC; Mon, 2 Sep 2019 17:00:43 +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 0372846F4A; Mon, 2 Sep 2019 17:00:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x82H0b3Z005376 for ; Mon, 2 Sep 2019 13:00:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id BAB3360610; Mon, 2 Sep 2019 17:00:37 +0000 (UTC) Received: from mx1.redhat.com (ext-mx23.extmail.prod.ext.phx2.redhat.com [10.5.110.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4E1760A9F for ; Mon, 2 Sep 2019 17:00:33 +0000 (UTC) Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (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 AE2DA106E282 for ; Mon, 2 Sep 2019 17:00:32 +0000 (UTC) Received: by mail-qt1-f179.google.com with SMTP id k10so5998773qth.2 for ; Mon, 02 Sep 2019 10:00:32 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7ca:89ab:e588:92b4:27d5:4e35]) by smtp.gmail.com with ESMTPSA id b26sm570qto.28.2019.09.02.10.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2019 10:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YDvDbXMcSaJmpjQYDJHnRIkFoL8h0fiHRNYT6Q2/In0=; b=ixgv+TC40VUUPc2H/+4vDH8lWpIKaOcf/qudnpA++0j3ReAJAWRJtGHD8fSef5jLKE pa6M6bux4AyRGeNtHDbE/zuahUVAD648WuvwuTIAw7ARoZ5yLEYDGxuPhchNim4iEiGX cxjNTbjql8CBR09t8gyCsm7rW9ClOBd24xFxooDTz+sdwpGCR3Fqy938gKElfc/NqBtP YlSY33D4l0JMd0GHpz0BfEhIXX6rVF3AfXR6bhFfoQDrnCZwQJAYsx1xQZHblavKCCpm 2TKUR9OSna0WikSJ3CGRYcNLV5SzI5ImEfO16j8ZLRnOFnQKXQN6yuzdUGwg1B2irpsM h6Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YDvDbXMcSaJmpjQYDJHnRIkFoL8h0fiHRNYT6Q2/In0=; b=ZU2O8dRJzv+Znr4egA8ifM16l49Ylkjc3GJq+D/mQNZggAoAehMyLoudMKq7CKkaTV N2W1FTPGgVmFRDopJegiLpyt0xnK4wXtn6iHSNHMmnto7wflsK0euktIKx84qyBp8Xon powXnHubyfOXPqsKe0Fr/CSC0TgOQ3BiRt0zRjwsWm2cKRSWzRXq+C+/WXOGszyD6Fmb uezJ7hw4Vxjz7YzIN2Mldnv4P91I0MxZNsZsHR/84WMBV9693PaJfSVcYMcN7XEL9CvJ AuaIwbuyml76b4Vy9qYjl2nTNvCmTaEWM+WcX4Yz1bTpMN92ggDAaTUG3aoxGMmQRGzM 7TUw== X-Gm-Message-State: APjAAAWFiA5s2F0I32cWosiN9wiDSkWUo4hle1ZCyWCi9pP6+a11Z+Gn sQi4UnkSKAOl7yBzA+NSZMen64/JPUI= X-Google-Smtp-Source: APXvYqzHAghUXMDTMbWMxW5Sq/bUc07ZMh9N8ZB6RqZ8EnL7mygwflm3UO3p0NYaJ2SY+ooxatxqcw== X-Received: by 2002:ac8:74d5:: with SMTP id j21mr28940514qtr.60.1567443631673; Mon, 02 Sep 2019 10:00:31 -0700 (PDT) From: jcfaracco@gmail.com To: libvir-list@redhat.com Date: Mon, 2 Sep 2019 14:00:27 -0300 Message-Id: <20190902170027.11922-1-jcfaracco@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Mon, 02 Sep 2019 17:00:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Mon, 02 Sep 2019 17:00:32 +0000 (UTC) for IP:'209.85.160.179' DOMAIN:'mail-qt1-f179.google.com' HELO:'mail-qt1-f179.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.099 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.160.179 mail-qt1-f179.google.com 209.85.160.179 mail-qt1-f179.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.64 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Julio Faracco Subject: [libvirt] [PATCH v2] util: Set backing file name for LOOP_GET_STATUS64 queries. 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: , 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.6.2 (mx1.redhat.com [10.5.110.67]); Mon, 02 Sep 2019 17:00:46 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Julio Faracco This is an issue for LXC loop devices when you are trying to get loop devices info using `ioctl`. Modern apps uses `/sys/dev/block` to grab information about devices, but if you use the method mention you won't be able to retrive the associated file with that loop device. See example below from cryptsetup sources: static char *_ioctl_backing_file(const char *loop) { struct loop_info64 lo64 =3D {0}; int loop_fd; loop_fd =3D open(loop, O_RDONLY); if (loop_fd < 0) return NULL; if (ioctl(loop_fd, LOOP_GET_STATUS64, &lo64) < 0) { close(loop_fd); return NULL; } lo64.lo_file_name[LO_NAME_SIZE-2] =3D '*'; lo64.lo_file_name[LO_NAME_SIZE-1] =3D 0; close(loop_fd); return strdup((char*)lo64.lo_file_name); } It will return an empty string because lo_file_name was not set. Function `virFileLoopDeviceOpenSearch()` is using `ioctl` to query data, but it is not checking `lo_file_name` field. v1: I accidentally committed two wrong lines. Signed-off-by: Julio Faracco Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virfile.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util/virfile.c b/src/util/virfile.c index 81a3c096eb..dbfe74e24f 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -781,6 +781,14 @@ int virFileLoopDeviceAssociate(const char *file, memset(&lo, 0, sizeof(lo)); lo.lo_flags =3D LO_FLAGS_AUTOCLEAR; =20 + /* Set backing file name for LOOP_GET_STATUS64 queries */ + if (virStrncpy((char *) lo.lo_file_name, file, + strlen(file), LO_NAME_SIZE) < 0) { + virReportSystemError(errno, + _("Unable to set backing file %s"), file); + goto cleanup; + } + if ((fsfd =3D open(file, O_RDWR)) < 0) { virReportSystemError(errno, _("Unable to open %s"), file); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list