From nobody Thu Jun 4 19:52:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1780316189; cv=none; d=zohomail.com; s=zohoarc; b=lRzeIFn9wVAfo6WQMvvR7qbVyYJoain7pBmgJyyBmUhgVClp9Mr7jhxE8CZ7BsFbaQ4c2sl4+jaxeNIhcLVqWILIfpRmySnJvTr5EeAQVHUe0Al/jlua96WBg75N0P8USxhI43rojpNblyamMOKhRn1GeojPEd3+hJ4lbQr5fiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780316189; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id; bh=kfx02X7IaKGfuMJ4z21VJY0JuA9OZxhg8MnvWdaohOE=; b=JPR9LI5aqdNVqXcB1ofNhN7lp1bkWh5Copd4lfo9t5g39HMHuj7OmG+SM9vt8V7emXqXENOkZSYzedR3xoFUXQVvYmxxUu1KWT4IGVs1hUMtS5l3ZBUglAYsdNEeceoH+eikIAiqC3NS6im8Ow0IPYPYJSz9wrnLqrIqLj4lOZk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1780316189673564.0141517531592; Mon, 1 Jun 2026 05:16:29 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 45E01419FE; Mon, 1 Jun 2026 08:16:28 -0400 (EDT) Received: from [172.19.199.4] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id C3B4141B32; Mon, 1 Jun 2026 08:15:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id F3CD54184C; Mon, 1 Jun 2026 08:15:25 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id EA5A73F956 for ; Mon, 1 Jun 2026 08:15:23 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-319-ijybp-7_Ogqsrw5BZp0lzA-1; Mon, 01 Jun 2026 08:15:22 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3683B18005BE for ; Mon, 1 Jun 2026 12:15:21 +0000 (UTC) Received: from rsmigiel-thinkpadx1carbongen11-remote-csb.redhat.com (unknown [10.44.48.81]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E8F5F1956095; Mon, 1 Jun 2026 12:15:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780316123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kfx02X7IaKGfuMJ4z21VJY0JuA9OZxhg8MnvWdaohOE=; b=d/9ZVUShRj1m9j3hPKqHyAcPoLgetWG2e29DeegXHdKUj3QLnB/5dPHGhZRS0YAy/rxrGi 5czyXt2CDu1+EdPqGkJQ4UtP+fmqm0a0a8uJolt49N8apZ3n4suOrkva76t1xi3DECmwYW B3HCDR7N5nHnOgVuO1xyQywonPjgqqA= X-MC-Unique: ijybp-7_Ogqsrw5BZp0lzA-1 X-Mimecast-MFC-AGG-ID: ijybp-7_Ogqsrw5BZp0lzA_1780316121 To: devel@lists.libvirt.org Subject: [PATCHv2] lxc: truncate LOOP_GET_STATUS64.lo_file_name for long loop backing paths Date: Mon, 1 Jun 2026 14:14:51 +0200 Message-ID: <20260601121513.146590-1-rsmigiel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YlpJ9A1CKPAb_W5WAcBmlQ9L0VsBv8U6A87Sx1lCxeo_1780316121 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5GCRZFF325IVKANFGHEW535CDMFMRVET X-Message-ID-Hash: 5GCRZFF325IVKANFGHEW535CDMFMRVET X-MailFrom: rsmigiel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Radoslaw Smigielski X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Radoslaw Smigielski via Devel Reply-To: Radoslaw Smigielski X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1780316193698158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Radoslaw Smigielski LXC domains using a file-backed filesystem with the loop driver fail to start when the backing image path is longer than LO_NAME_SIZE (64 bytes, 63 characters plus NUL). virFileLoopDeviceAssociate() treated a failed virStrcpy() into loop_info64.lo_file_name as fatal and reported a misleading virReportSystemError(errno, ...), so users saw errors such as "Unable to set backing file ...: Success" or ENOENT even when the file existed. The kernel only stores a short name in lo_file_name for LOOP_SET_STATUS64 metadata. The backing file is opened by full path. Copy the path with virStrcpy(), allow truncation into lo_file_name, and mark truncation with '= *' at LO_NAME_SIZE - 2 to match losetup behavior. Log truncation at debug level only. XML example that failed before this change: Fixes: https://gitlab.com/libvirt/libvirt/-/work_items/63 Signed-off-by: Radoslaw Smigielski --- src/util/virfile.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index a0c6cb804862..443d0ed9adab 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -995,11 +995,15 @@ int virFileLoopDeviceAssociate(const char *file, =20 lo.lo_flags =3D LO_FLAGS_AUTOCLEAR; =20 - /* Set backing file name for LOOP_GET_STATUS64 queries */ + /* lo_file_name is loop device name, max length is LO_NAME_SIZE bytes. + * Truncate loop device name if file path is longer than LO_NAME_SIZE, + * and still use the full path to open backing file. */ if (virStrcpy((char *) lo.lo_file_name, file, LO_NAME_SIZE) < 0) { - virReportSystemError(errno, - _("Unable to set backing file %1$s"), file); - goto cleanup; + /* virStrcpy() only returns -1 on truncation. Mark truncation with + * asterisk at position LO_NAME_SIZE-2 to match losetup behavior. = */ + lo.lo_file_name[LO_NAME_SIZE - 2] =3D '*'; + VIR_DEBUG("lo_file_name for '%s' truncated to %d bytes in loop met= adata", + file, LO_NAME_SIZE); } =20 if ((fsfd =3D open(file, O_RDWR)) < 0) { --=20 2.54.0