From nobody Thu Apr 25 19:48:16 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=1617897143; cv=none; d=zohomail.com; s=zohoarc; b=WoOioN9h6BbczIKv6ToI/K7DUsIsdG56RMUDXQlscVUWFlVp2mX8Pk6m/gCPDKR3SAJmcqq6M+O1/21xNsawPBTDNPfQ/HMlonTSK4hAxg9GNxLbvpD1+crrSKd+Byc9L5SuMzSfRmmXf13q9cHQbkj+08KF8J1jLomkf1qTVKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617897143; 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=cn8Io+P+IJ0kv8rkVcOLbOlUtBRCz6E5SgI9iswAV4w=; b=ISlA4FGShm8+CX3RnEofuBBcqxX2wkTT3o60GgP1jEpdy6dOpIqNIi/A85RipEH5gx+T+/EaWElo72iiJgWQr2GB7wHrD3QHPqedABRm1UomjqGtJFBBfMyoHrh4YXI0LMEN/Wq2blzqjlEfnX3zEdjgdM49uL+ZWCl1mWdjwSQ= 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 1617897143897353.1726272598179; Thu, 8 Apr 2021 08:52:23 -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-471-2s5_9lpsMRS8yDxPQmGE8w-1; Thu, 08 Apr 2021 11:52:19 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB82A10C0941; Thu, 8 Apr 2021 15:51:51 +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 B0EB060853; Thu, 8 Apr 2021 15:51:49 +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 593445533F; Thu, 8 Apr 2021 15:51:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 138Fpkff007038 for ; Thu, 8 Apr 2021 11:51:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7B8592114D24; Thu, 8 Apr 2021 15:51:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7651C2114D23 for ; Thu, 8 Apr 2021 15:51:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 D50A585A5BF for ; Thu, 8 Apr 2021 15:51:43 +0000 (UTC) Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-46-XrhDrHLgPrKtk-dV8AwLFw-1; Thu, 08 Apr 2021 11:51:40 -0400 Received: by mail-qt1-f181.google.com with SMTP id y2so1734872qtw.13 for ; Thu, 08 Apr 2021 08:51:40 -0700 (PDT) Received: from master-localdomain.lan (ool-2f116ac3.dyn.optonline.net. [47.17.106.195]) by smtp.googlemail.com with ESMTPSA id a19sm21010912qkl.126.2021.04.08.08.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 08:51:39 -0700 (PDT) X-MC-Unique: 2s5_9lpsMRS8yDxPQmGE8w-1 X-MC-Unique: XrhDrHLgPrKtk-dV8AwLFw-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=cn8Io+P+IJ0kv8rkVcOLbOlUtBRCz6E5SgI9iswAV4w=; b=cc99bLPZY25hI+Iz/3yD6Y2YIuDaOqL3InQ2mQVKGiGhFsXt0hEK5FL/7eaqgsPnBT KIMiKPzXNPbx1j8pCaWiNxK6bc0avuV1nAYBQY3SMIo0shyUI5zXxsEUeL9tPAmLHF+O yyR+E1VC9FRpk4bvQgZjiztgoDwriVJm4gS5G+xkoEkr9IBr7j4SV0mGnNh2L7wNig9e Iwzv89FL7ekMQcCD4rL1oGBkkDPJNS11YfkONpGdyqrnIvFexWW1YzDGd+zmDM4JfSs6 KIwyTy/dlxv8QDc4knMFSPrtfTYFCgKIBUcytAJWDFTV0X2bIFguy0Wly14RBKLqZisQ Wkig== X-Gm-Message-State: AOAM531YtB9uJ5ZttEdI9o0/nGOBekrlDyxFAdqlVtUrMlys8rum0maG dtAQGLNo77cxikclOwqBADNrigm6aAtOhQ== X-Google-Smtp-Source: ABdhPJxpsJBuI4oTfQAeOi10WCFKzAJC/mLBfy93BHJFfEdT0vhjh6YRsTmIiL3DZ55JljT+dPbkow== X-Received: by 2002:ac8:124b:: with SMTP id g11mr7778164qtj.239.1617897100127; Thu, 08 Apr 2021 08:51:40 -0700 (PDT) From: Dawid Zamirski X-Google-Original-From: Dawid Zamirski To: libvir-list@redhat.com Subject: [PATCH] hyperv: Handle long CPU models better. Date: Thu, 8 Apr 2021 11:51:05 -0400 Message-Id: <20210408155105.7253-1-dzamirski@datto.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.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Dawid Zamirski 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.13 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" Apparenlly exising code was dealing with stripping down Intel CPU models as reported by Hyper-V host but was still having issues with my AMD CPU for which Hyper-V returns "AMD FX(tm)-8350 Eight-Core Processor". Therefore, this patch deals with it by stripping out the " Processor" part, and if there's another CPU that we don't know of yet that causes trouble, trim the resulting string to 32 characters rather than failing as the node info has other information that are more useful than the model. Reviewed-by: Neal Gompa --- 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