From nobody Mon Apr 29 23:47:30 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=1567435117; cv=none; d=zoho.com; s=zohoarc; b=h4Ctd5AOGGrPSG8jooIUQ5CE6I5tm1J9aqkt/OAjDZZMbgpdq90dB9ng4Z1gfJDZkPHbHzIUCzQHAzUu0on4hAXcCNTFAaoxpPZia2G26QtIM68XT81/xMi73HmIzDXYxxQ6EIMmt/RObm6P+yrpVK+HrihHv7ggHJQElasFyrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567435117; 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=SYEBQJRyIfjDeuW9/5fvkpdWFUQ4/ckVzzt6tYNOLYw=; b=EA9DgX4t4Al06gi9WbI1VpPoRt+D+G81p8J6dDe6G43ppkVw8Kfs19DimB2mjQMyLrIDR8+aWE/h5ZSTo+Z3CxNqmrJSctTG777JNkB0JIz6uEVODVHGPcaMLJXiS2FZ3ME4p14ox4vCBAhqek0Rnv/3r4WquC0XhT1J9MZfxL4= 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 1567435117799364.53908021110556; Mon, 2 Sep 2019 07:38:37 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 6C1C6C002966; Mon, 2 Sep 2019 14:38:36 +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 4BE871001959; Mon, 2 Sep 2019 14:38:36 +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 0CAE22551C; Mon, 2 Sep 2019 14:38:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x82EcZPg001465 for ; Mon, 2 Sep 2019 10:38:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A4345D6C8; Mon, 2 Sep 2019 14:38:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 535C25D6B7 for ; Mon, 2 Sep 2019 14:38:32 +0000 (UTC) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 5C77A30001EB for ; Mon, 2 Sep 2019 14:38:32 +0000 (UTC) Received: by mail-qk1-f181.google.com with SMTP id i78so11225888qke.11 for ; Mon, 02 Sep 2019 07:38:32 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7ca:89ab:e588:92b4:27d5:4e35]) by smtp.gmail.com with ESMTPSA id c18sm2670985qkb.93.2019.09.02.07.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2019 07:38:30 -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=N+ehNnJ2hLFkJZjl/O7idOL5xWhuefOIKnmnEuYieIU=; b=ESf8mXp3mrOJqdzTmdLcImQhuh9ZGzYN6LzZ0wZbTKo2JQ1oZnPE5dMZIy4H3xNWDO R9G0jaNEpQwDkIxbMd1tqlHyj+CaP8YnJXuEbJ2OZCwwDiUOURIzMt5bY9cSuOD9MEPG PpSi6ELGPMIry9ylL2mFzioXpFK9vBeQjdWBkLYfzSUX34jOu1W76mztUXAwlRHqASkb NDs0Nuc8NWW4UQsKDZ8M1pk2WlxnNJB+bizLg/yzFj96kYW8ylFWQNiOOGEjR6Y4RJLy X0HrYPQwHBZtN+oTXTvxByD9zoh/hISVdlZ+B55G78CW7b5ucIBhRfe/ZKYOIsiEM1yn wBOw== 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=N+ehNnJ2hLFkJZjl/O7idOL5xWhuefOIKnmnEuYieIU=; b=AcyBVB/bKs8FBGNYvdIPyurVTZs5/f8lZoC2ku7ftdNY2BbQKagTGYUipTI5M85O5n GjiKbZ0adQJqnYBZ7hthR7UnNjoT/bWmHeCAUzHAqwVk0rmNohKL/AbSkUq3/t2HuehN LnrcrpQB8bwIdgk3CqaQs19RLCokCj6xUzWviGWkB9O9std7u8DK191XJ1unei6B85sy 7THziO+mqgT8ABXITxZ6wcktd0hQr3V/g8FrMdJcvosEIE2S8wzLoIxCje/ATJLcEH4U H3wzOFOFMxsKHCxwVOFXiDQD7ArJNkeLp7IQNy3aohcAIP+7Y/wl8qLO08X57yYmG5jx 2WZQ== X-Gm-Message-State: APjAAAXLYjabjAQhiZEgm9oXU9NplLT9sDZVCfa1ULCSVf/UbPiFVT4D JqUNENW6AmaJ3So9I1BE8SZxe09p X-Google-Smtp-Source: APXvYqwL33ztfOxK5pGtbPy7jaaQ/299W8i/2dwPXw7FFc9kTEr2+98zQ49BC3ANi+zZU90GlULahA== X-Received: by 2002:a37:6085:: with SMTP id u127mr20644947qkb.312.1567435111266; Mon, 02 Sep 2019 07:38:31 -0700 (PDT) From: jcfaracco@gmail.com To: libvir-list@redhat.com Date: Mon, 2 Sep 2019 11:38:25 -0300 Message-Id: <20190902143825.7568-1-jcfaracco@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 02 Sep 2019 14:38:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 02 Sep 2019 14:38:32 +0000 (UTC) for IP:'209.85.222.181' DOMAIN:'mail-qk1-f181.google.com' HELO:'mail-qk1-f181.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.222.181 mail-qk1-f181.google.com 209.85.222.181 mail-qk1-f181.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Julio Faracco Subject: [libvirt] [PATCH] 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 02 Sep 2019 14:38:36 +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. Signed-off-by: Julio Faracco --- src/util/virfile.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/util/virfile.c b/src/util/virfile.c index 81a3c096eb..fe0aa54eb6 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -781,6 +781,16 @@ 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; + } + lo.lo_file_name[LO_NAME_SIZE-2] =3D '*'; + lo.lo_file_name[LO_NAME_SIZE-1] =3D 0; + 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