From nobody Sat Feb 7 09:42:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580217128971483.0641351470356; Tue, 28 Jan 2020 05:12:08 -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-29-8IHgX0RSNw62wjAjkHB0CQ-1; Tue, 28 Jan 2020 08:12:04 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A094800D48; Tue, 28 Jan 2020 13:11:58 +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 F24981001DE0; Tue, 28 Jan 2020 13:11:57 +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 AB185870BE; Tue, 28 Jan 2020 13:11:57 +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 00SDBiYK019075 for ; Tue, 28 Jan 2020 08:11:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id CD4681001DE1; Tue, 28 Jan 2020 13:11:44 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 199FC1001DD8; Tue, 28 Jan 2020 13:11:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217127; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eMpH6BE4x18caZ3rYdf0Qdtinw5M7wxl4ZWQbc7ZTOk=; b=K4UrakJlaHXPGQ3+Hs8VwfTVhX1cHmXmxp1wO6F66xPzU2fIvteyazkSMr/1mIeTwwZ9cy XfsfF9O2I2A1SopQcfCyKbSHHECT8p5l6h+KWx4utPB7zzmVWNGUhfHibGruT7L4Ux4Nrm ayVqvSUKY4HvPCa05YLyslUz2oyHPko= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 02/56] util: add a virArchFromHost() impl for Windows Date: Tue, 28 Jan 2020 13:10:43 +0000 Message-Id: <20200128131137.1762449-3-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina 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.84 on 10.5.11.22 X-MC-Unique: 8IHgX0RSNw62wjAjkHB0CQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Instead of relying on GNULIb's uname() impl, directly use the Windows API for determining CPU architecture. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- src/util/virarch.c | 52 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/util/virarch.c b/src/util/virarch.c index b132e178c3..f088b6b676 100644 --- a/src/util/virarch.c +++ b/src/util/virarch.c @@ -21,7 +21,12 @@ =20 #include =20 -#include +#ifdef WIN32 +# define WIN32_LEAN_AND_MEAN +# include +#else +# include +#endif =20 #include "virlog.h" #include "virarch.h" @@ -154,6 +159,50 @@ virArch virArchFromString(const char *archstr) * uname 'machine' field, since this will canonicalize * architecture names like 'amd64' into 'x86_64'. */ +#ifdef WIN32 + +/* + * Missing in ming64 headers 6.0.0, but defined as '12' in: + * + * https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinf= oapi-system_info + */ +# ifndef PROCESSOR_ARCHITECTURE_ARM64 +# define PROCESSOR_ARCHITECTURE_ARM64 12 +# endif + +virArch virArchFromHost(void) +{ + SYSTEM_INFO info; + + GetSystemInfo(&info); + + switch (info.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_AMD64: + return VIR_ARCH_X86_64; + case PROCESSOR_ARCHITECTURE_IA64: + return VIR_ARCH_ITANIUM; + case PROCESSOR_ARCHITECTURE_INTEL: + case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: + return VIR_ARCH_I686; + case PROCESSOR_ARCHITECTURE_MIPS: + return VIR_ARCH_MIPS; + case PROCESSOR_ARCHITECTURE_ALPHA: + return VIR_ARCH_ALPHA; + case PROCESSOR_ARCHITECTURE_PPC: + return VIR_ARCH_PPC; + case PROCESSOR_ARCHITECTURE_SHX: + return VIR_ARCH_SH4; + case PROCESSOR_ARCHITECTURE_ARM: + return VIR_ARCH_ARMV7L; + case PROCESSOR_ARCHITECTURE_ARM64: + return VIR_ARCH_AARCH64; + default: + VIR_WARN("Unknown host arch '%d', report to libvir-list@redhat.com= ", + info.wProcessorArchitecture); + return VIR_ARCH_NONE; + } +} +#else /* !WIN32 */ virArch virArchFromHost(void) { struct utsname ut; @@ -184,3 +233,4 @@ virArch virArchFromHost(void) =20 return arch; } +#endif /* !WIN32 */ --=20 2.24.1