From nobody Sun Feb 8 17:13:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1487177346092789.523206998904; Wed, 15 Feb 2017 08:49:06 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1FGjTcQ027996; Wed, 15 Feb 2017 11:45:29 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1FGjDCK025678 for ; Wed, 15 Feb 2017 11:45:13 -0500 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1FGjCWb010207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 15 Feb 2017 11:45:13 -0500 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 3C4C5105DF7; Wed, 15 Feb 2017 17:45:08 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 15 Feb 2017 17:44:53 +0100 Message-Id: <1eafea9d18872551cdfaed4fca1cfebe1e0b1c5c.1487176962.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 19/33] cpu_x86: Introduce virCPUx86DataSetVendor 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- Notes: Version 2: - no change src/cpu/cpu_x86.c | 45 +++++++++++++++++++++++++++++++++++---------- src/cpu/cpu_x86.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index e3f860bc6..ab5e5257d 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -478,6 +478,26 @@ x86DataToVendor(const virCPUx86Data *data, } =20 =20 +static int +virCPUx86VendorToCPUID(const char *vendor, + virCPUx86CPUID *cpuid) +{ + if (strlen(vendor) !=3D VENDOR_STRING_LENGTH) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid CPU vendor string '%s'"), vendor); + return -1; + } + + cpuid->eax_in =3D 0; + cpuid->ecx_in =3D 0; + cpuid->ebx =3D virReadBufInt32LE(vendor); + cpuid->edx =3D virReadBufInt32LE(vendor + 4); + cpuid->ecx =3D virReadBufInt32LE(vendor + 8); + + return 0; +} + + static uint32_t x86MakeSignature(unsigned int family, unsigned int model) @@ -651,17 +671,9 @@ x86VendorParse(xmlXPathContextPtr ctxt, vendor->name); goto error; } - if (strlen(string) !=3D VENDOR_STRING_LENGTH) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid CPU vendor string '%s'"), string); - goto error; - } =20 - vendor->cpuid.eax_in =3D 0; - vendor->cpuid.ecx_in =3D 0; - vendor->cpuid.ebx =3D virReadBufInt32LE(string); - vendor->cpuid.edx =3D virReadBufInt32LE(string + 4); - vendor->cpuid.ecx =3D virReadBufInt32LE(string + 8); + if (virCPUx86VendorToCPUID(string, &vendor->cpuid) < 0) + goto error; =20 cleanup: VIR_FREE(string); @@ -2731,6 +2743,19 @@ virCPUx86DataSetSignature(virCPUDataPtr cpuData, } =20 =20 +int +virCPUx86DataSetVendor(virCPUDataPtr cpuData, + const char *vendor) +{ + virCPUx86CPUID cpuid =3D { 0 }; + + if (virCPUx86VendorToCPUID(vendor, &cpuid) < 0) + return -1; + + return virCPUx86DataAddCPUID(cpuData, &cpuid); +} + + struct cpuArchDriver cpuDriverX86 =3D { .name =3D "x86", .arch =3D archs, diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h index ffbd064b4..ab5394914 100644 --- a/src/cpu/cpu_x86.h +++ b/src/cpu/cpu_x86.h @@ -36,4 +36,7 @@ int virCPUx86DataSetSignature(virCPUDataPtr cpuData, unsigned int family, unsigned int model); =20 +int virCPUx86DataSetVendor(virCPUDataPtr cpuData, + const char *vendor); + #endif /* __VIR_CPU_X86_H__ */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6b2dddc95..7338c31e7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1007,6 +1007,7 @@ virCPUUpdate; # cpu/cpu_x86.h virCPUx86DataAddCPUID; virCPUx86DataSetSignature; +virCPUx86DataSetVendor; =20 =20 # datatypes.h --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list