From nobody Sun May 19 22:21:37 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1618296329; cv=none; d=zohomail.com; s=zohoarc; b=NmmE37ALl2O0iDze3/VQch9JEQWnw7y5og24eGujyyq1qMGWFEdmqh0UvRNcom+CrU+qy/G8p4gBKb0f3jpytKjJzWsBA32v1tGKpqicK+4GP+8bD0z53VujXFg5r9NSK/+Kb+/Ex6MmuBe4pD/pnYWE94yT8ybdjPEIwQJZrt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618296329; 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; bh=zqvz0O3bFMyYOv+eHoF9y6V1Sle8oiSXIYRpn9pdLBs=; b=YvV6n+sleNHxi5i/ZWMd+psopR0XnAx2xdSHWpPVLWm3nxroIRvcBIOV7O6X+2AX3nG6YzWVeBDF80EvAgTLOEQiF0WOgL8uCmDgvdQSFGQxiJSdQzMfRefUf6WO1TOENYZRU3WqpUlsA9pCO8hODu2Tre3cNfcjwf7aCS0bZG4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1618296329053421.5669152299481; Mon, 12 Apr 2021 23:45:29 -0700 (PDT) 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-387-Z8kTYwxjM1S7nyyouLR2PQ-1; Tue, 13 Apr 2021 02:45:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2FB211804968; Tue, 13 Apr 2021 06:45:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CEB9260C5F; Tue, 13 Apr 2021 06:45:16 +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 22FB11806D0E; Tue, 13 Apr 2021 06:45:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13D6jDt8024754 for ; Tue, 13 Apr 2021 02:45:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 997626E1D6; Tue, 13 Apr 2021 06:45:13 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93BBA6E1DC for ; Tue, 13 Apr 2021 06:45:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3175A80A1D3 for ; Tue, 13 Apr 2021 06:45:11 +0000 (UTC) Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-427-4fFdcQ_0Msqf1cL_VbCrEQ-1; Tue, 13 Apr 2021 02:45:08 -0400 Received: by mail-qt1-f169.google.com with SMTP id u8so11918093qtq.12 for ; Mon, 12 Apr 2021 23:45:08 -0700 (PDT) Received: from master-localdomain.lan (ool-2f116ac3.dyn.optonline.net. [47.17.106.195]) by smtp.googlemail.com with ESMTPSA id r9sm5581543qtf.62.2021.04.12.23.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 23:45:06 -0700 (PDT) X-MC-Unique: Z8kTYwxjM1S7nyyouLR2PQ-1 X-MC-Unique: 4fFdcQ_0Msqf1cL_VbCrEQ-1 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=zqvz0O3bFMyYOv+eHoF9y6V1Sle8oiSXIYRpn9pdLBs=; b=KK/QBiYLIggUKpkORvvXQ4Vetbkk2SvKjqT20np1rbWYpD5u8h08nL3dqHekXRhEfl SZZVr0oOj8ZntHTFHKGFQdxI5NKpMusQLn5R78piSna0nVi+u8UjZEDOPAJgIQbgYWpE 6Ix8ooSjcY9mcatYEs6u6CSfgrmBeQ0lZwFHyq3nQRgGXgPhSdVGhWJT8jSQ9a5uXH0+ UenVT51PLEnKiNg+IR9jDb9nTTi7fxtSb2IfrviigoKi4dCRZli7OV1bD9hRi6A5+KTv D+jTwa57222tME2zfvqomufvf6TxkpPLw/7OYPqypOJW/QbxF62L9pqQW/RaNK3NlPNq Rh2A== X-Gm-Message-State: AOAM533DEHKSTqFqeGsLVGVjmmA1edr6PlLINJF8DfQC3MqRI1nnNezK zj90OU6gvPTs9ggdnxYGAZR4LqrpKHfkbA== X-Google-Smtp-Source: ABdhPJy/iDtBtfUeVYR2pA4XFER4b/w4+f3OjycFyWFVHFh/1uIUdIb7CCJiAIaUIkv4V0V7sWKL3Q== X-Received: by 2002:a05:622a:312:: with SMTP id q18mr29154540qtw.271.1618296307393; Mon, 12 Apr 2021 23:45:07 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Subject: [libvirt PATCH v2] hyperv: Handle long CPU models better. Date: Tue, 13 Apr 2021 02:45:05 -0400 Message-Id: <20210413064505.72042-1-dzrudy@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Neal Gompa 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.12 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The existing driver code strips down CPU model strings returned by Hyper-V hosts so they fit into the 32 character limit of the virNodeInfo.model field. However, this did not work well for my AMD CPU for which Hyper-V returns the string "AMD FX(tm)-8350 Eight-Core Processor". Therefore, this patch improves that code block to be case insensitive (so that the "(tm)" part is removed) and additionally removes the trailing " Processor" suffix. While this change alone worked for me, I have also added a line to terminate the stripped down string at 32nd character to make sure that any other CPU string we did not come across yet won't trigger the error - the virNodeInfo has other useful info that is arguably more important than CPU model string, e.g. core count, or memory size Signed-off-by: Dawid Zamirski Reviewed-by: Neal Gompa --- Changes since v1: * Added missing Signed-off-by * Add Reviewed-by * Reworded commit message src/hyperv/hyperv_driver.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 17f5be1f0d..6e03aa4f18 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1948,14 +1948,14 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPt= r info) if (STRPREFIX(tmp, " ")) { memmove(tmp, tmp + 1, strlen(tmp + 1) + 1); continue; - } else if (STRPREFIX(tmp, "(R)") || STRPREFIX(tmp, "(C)")) { + } else if (STRCASEPREFIX(tmp, "(R)") || STRCASEPREFIX(tmp, "(C)"))= { memmove(tmp, tmp + 3, strlen(tmp + 3) + 1); continue; - } else if (STRPREFIX(tmp, "(TM)")) { + } else if (STRCASEPREFIX(tmp, "(TM)")) { memmove(tmp, tmp + 4, strlen(tmp + 4) + 1); continue; - } else if (STRPREFIX(tmp, " @ ")) { - /* Remove " @ X.YZGHz" from the end. */ + } else if (STRPREFIX(tmp, " @ ") || STRPREFIX(tmp, " Processor")) { + /* Remove " @ X.YZGHz" or " Processor" from the end. */ *tmp =3D '\0'; break; } @@ -1963,13 +1963,12 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPt= r info) ++tmp; } =20 + /* trim whatever is left to 32 characters - better this than nothing = */ + processorList->data->Name[31] =3D '\0'; + /* Fill struct */ - if (virStrcpyStatic(info->model, processorList->data->Name) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU model %s too long for destination"), - processorList->data->Name); + if (virStrcpyStatic(info->model, processorList->data->Name) < 0) return -1; - } =20 info->memory =3D computerSystem->data->TotalPhysicalMemory / 1024; /* = byte to kilobyte */ info->mhz =3D processorList->data->MaxClockSpeed; --=20 2.31.1