From nobody Sun Apr 28 14:19:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605221305; cv=none; d=zohomail.com; s=zohoarc; b=FIj7q+Y7Vuld+mPfoeAGzHdUhcsqozDYpakukRsLwvXhs9D8dnDQJjqme+pKXnK5oFK5oZc/GzwIk1NlXLtSyTt0/MKLeI/bjM/mk1HbmCy5uv+GBj7oGJcOUt7ZakPxTsfF2CiVm32KMsb7yW4N+/KauB7IK55F690miTPVcZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605221305; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=TvOBx/0tVBrH0hc4l7IIRsN4svZ5u9x4ArGRGp+zG1s=; b=VyJ1x5DNGOCbIjy601m5DK81pfQ2YBcnhiSZ2L8OoPffKy3e9eFXl6xCYnmSsCS4jF5U4OuP+1CD+tLI3VnkLlAwI/JpT3zDfbdnq/y1RWEOjmrcdZ3msiratIS23hIO9hy4TJm5kg6S/I5E1d62bfGxEjfNXRu7B4DDgYVWil8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605221305545770.1454382084215; Thu, 12 Nov 2020 14:48:25 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-489-jB9r1-69PISphQ9fQtVwNw-1; Thu, 12 Nov 2020 17:48:22 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10E8F1007467; Thu, 12 Nov 2020 22:48:15 +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 118BC5C1BB; Thu, 12 Nov 2020 22:48:14 +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 95613997D; Thu, 12 Nov 2020 22:48:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ACMm9ct013308 for ; Thu, 12 Nov 2020 17:48:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1521F1002C1C; Thu, 12 Nov 2020 22:48:09 +0000 (UTC) Received: from thuth.com (ovpn-112-10.ams2.redhat.com [10.36.112.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B6E51002C36; Thu, 12 Nov 2020 22:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605221304; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:content-type:content-type:list-id: list-help:list-unsubscribe:list-subscribe:list-post; bh=TvOBx/0tVBrH0hc4l7IIRsN4svZ5u9x4ArGRGp+zG1s=; b=Sht1MRQsD8B9dIyRbA3dRFbKxMbkUm5H/tXWIlQ0AtQWwJ/J/Qok4HruFH5TlFqloWNCAm E26nGxmLPfFhKUF1G36K+MXNX0OG6bsg8MlsmgJcv9d+88GaoCrAIn11TKqLX0uOCQB67J pHQF4wWKpvCcrYjbcHPzMsgV/Je7f30= X-MC-Unique: jB9r1-69PISphQ9fQtVwNw-1 From: Thomas Huth To: libvir-list@redhat.com Subject: [PATCH] qemu: domfsinfo should print a target name on s390x, not a complete device path Date: Thu, 12 Nov 2020 23:48:02 +0100 Message-Id: <20201112224802.784132-1-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: smitterl@redhat.com, fiuczy@linux.ibm.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" While fixing domfsinfo for non-PCI (i.e. CCW) devices on s390x, I accidentally used the whole device path for the devAlias field. However, it should only contain the base target name. Currently we have the wrong output: $ virsh domfsinfo guestname Mountpoint Name Type Target --------------------------------------- / sda3 xfs /dev/sda3 /boot sda1 xfs /dev/sda1 It should look like this instead: $ virsh domfsinfo guestname Mountpoint Name Type Target ------------------------------------ / sda3 xfs sda /boot sda1 xfs sda Thus we have to strip the "/dev/" prefix and the partition number from the string. Fixes: f8333b3b0a ("qemu: Fix domfsinfo for non-PCI device information ...") Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1858771 Reported-by: Sebastian Mitterle --- src/qemu/qemu_driver.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 05f8eb2cb7..d92bee1d35 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18874,6 +18874,30 @@ qemuDomainGetFSInfoAgent(virQEMUDriverPtr driver, return ret; } =20 +/* Turn device node string like "/dev/vda1" into a target name like "vda" = */ +static char * +qemuAgentDevNodeToTarget(const char *devnode) +{ + char *str =3D g_strdup(devnode); + size_t len =3D strlen(str); + + /* Remove the "/dev/" prefix from the string */ + if (g_str_has_prefix(str, "/dev/")) { + len -=3D 5; + memmove(str, str + 5, len + 1); + } + + /* Remove the partition number from the end of the string */ + while (len > 0) { + len--; + if (!g_ascii_isdigit(str[len])) + break; + str[len] =3D 0; + } + + return str; +} + static virDomainFSInfoPtr qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent, virDomainDefPtr vmdef) @@ -18903,7 +18927,7 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent, if (diskDef !=3D NULL) ret->devAlias[i] =3D g_strdup(diskDef->dst); else if (agentdisk->devnode !=3D NULL) - ret->devAlias[i] =3D g_strdup(agentdisk->devnode); + ret->devAlias[i] =3D qemuAgentDevNodeToTarget(agentdisk->devno= de); else VIR_DEBUG("Missing devnode name for '%s'.", ret->mountpoint); } --=20 2.18.4