From nobody Sun Feb 8 12:20:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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 ARC-Seal: i=1; a=rsa-sha256; t=1572960606; cv=none; d=zoho.com; s=zohoarc; b=Yg9uZoszSWfWne1TcU2I0zBIqDIBss+e2R0OsHJonFiNhk4xshCjefSYVmcPBYI1YHkyuc+mwk6ufPXBoF18XXWKCLk6BeN2bARy271ILXtDbRO1mLQ4UCgM2mM50bTL5+/uoay6h7XaAuxNj9t7uVFDWnb1lAvOR+AwmKKPKEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572960606; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g9rStb1QoeimPV3oqmwOgxQj0lEmTlrwrb2BusSJogQ=; b=HpiZxZ1GztZQzAdfeoAOrhK7HwdX5XcbBhhspPCF+Kc5qGoRxHLdQytH4x0QuSVkNw4AKoHWV7EoiV1KBLwRUnSh7rmQqdv8IGChro+sDXb+kqoBgTESaECE2S68SITK6dVL5s6CKRdoIJm3htLxyR28mYk2aYEkkg0KluwKOKg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1572960606317422.87646102813926; Tue, 5 Nov 2019 05:30:06 -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-36-AdQShkJ1NGKX-XHm2pf6og-1; Tue, 05 Nov 2019 08:29:36 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AEF7ADB24; Tue, 5 Nov 2019 13:29:31 +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 860B8600F6; Tue, 5 Nov 2019 13:29:31 +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 3A8F9180085D; Tue, 5 Nov 2019 13:29:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xA5DS6qv004166 for ; Tue, 5 Nov 2019 08:28:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3B2FB5D9C9; Tue, 5 Nov 2019 13:28:06 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E00A25D9CD for ; Tue, 5 Nov 2019 13:28:00 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id F120B105D7B; Tue, 5 Nov 2019 14:27:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572960605; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=g9rStb1QoeimPV3oqmwOgxQj0lEmTlrwrb2BusSJogQ=; b=ZVKwIXDHVWWZO5aGs4Wd1H4WWA1bk6cAhocbtVZKZpW1wPnTQzqC/oD9CWfFLUERAdRvGd ye1yhu8uqhHITF82NZKdBU5lBspk+tIg5xaa0hI9jxvukjxybBJL14lLs9Pbwk7Yb/ek0W LdkfOrlPtYvNxZ8mnFPR8gkOLXmUS/k= From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Nov 2019 14:27:31 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 33/52] qemu: Make virQEMUCapsGetMachineTypesCaps static 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.11 X-MC-Unique: AdQShkJ1NGKX-XHm2pf6og-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 3: - new patch src/qemu/qemu_capabilities.c | 150 ++++++++++++++++++----------------- src/qemu/qemu_capabilities.h | 3 - 2 files changed, 76 insertions(+), 77 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c66eef3e94..b9307730f1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -831,6 +831,82 @@ virQEMUCapsInitGuest(virCapsPtr caps, return ret; } =20 + +static int +virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps, + size_t *nmachines, + virCapsGuestMachinePtr **machines) +{ + size_t i; + + *machines =3D NULL; + *nmachines =3D qemuCaps->nmachineTypes; + + if (*nmachines && + VIR_ALLOC_N(*machines, qemuCaps->nmachineTypes) < 0) + goto error; + + for (i =3D 0; i < qemuCaps->nmachineTypes; i++) { + virCapsGuestMachinePtr mach; + if (VIR_ALLOC(mach) < 0) + goto error; + (*machines)[i] =3D mach; + if (qemuCaps->machineTypes[i].alias) { + mach->name =3D g_strdup(qemuCaps->machineTypes[i].alias); + mach->canonical =3D g_strdup(qemuCaps->machineTypes[i].name); + } else { + mach->name =3D g_strdup(qemuCaps->machineTypes[i].name); + } + mach->maxCpus =3D qemuCaps->machineTypes[i].maxCpus; + } + + /* Make sure all canonical machine types also have their own entry so = that + * /capabilities/guest/arch[@name=3D'...']/machine/text() XPath select= s all + * supported machine types. + */ + i =3D 0; + while (i < *nmachines) { + size_t j; + bool found =3D false; + virCapsGuestMachinePtr machine =3D (*machines)[i]; + + if (!machine->canonical) { + i++; + continue; + } + + for (j =3D 0; j < *nmachines; j++) { + if (STREQ(machine->canonical, (*machines)[j]->name)) { + found =3D true; + break; + } + } + + if (!found) { + virCapsGuestMachinePtr mach; + if (VIR_ALLOC(mach) < 0) + goto error; + if (VIR_INSERT_ELEMENT_COPY(*machines, i, *nmachines, mach) < = 0) { + VIR_FREE(mach); + goto error; + } + mach->name =3D g_strdup(machine->canonical); + mach->maxCpus =3D machine->maxCpus; + i++; + } + i++; + } + + return 0; + + error: + virCapabilitiesFreeMachines(*machines, *nmachines); + *nmachines =3D 0; + *machines =3D NULL; + return -1; +} + + int virQEMUCapsInitGuestFromBinary(virCapsPtr caps, const char *binary, @@ -2022,80 +2098,6 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCap= s, } =20 =20 -int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps, - size_t *nmachines, - virCapsGuestMachinePtr **machines) -{ - size_t i; - - *machines =3D NULL; - *nmachines =3D qemuCaps->nmachineTypes; - - if (*nmachines && - VIR_ALLOC_N(*machines, qemuCaps->nmachineTypes) < 0) - goto error; - - for (i =3D 0; i < qemuCaps->nmachineTypes; i++) { - virCapsGuestMachinePtr mach; - if (VIR_ALLOC(mach) < 0) - goto error; - (*machines)[i] =3D mach; - if (qemuCaps->machineTypes[i].alias) { - mach->name =3D g_strdup(qemuCaps->machineTypes[i].alias); - mach->canonical =3D g_strdup(qemuCaps->machineTypes[i].name); - } else { - mach->name =3D g_strdup(qemuCaps->machineTypes[i].name); - } - mach->maxCpus =3D qemuCaps->machineTypes[i].maxCpus; - } - - /* Make sure all canonical machine types also have their own entry so = that - * /capabilities/guest/arch[@name=3D'...']/machine/text() XPath select= s all - * supported machine types. - */ - i =3D 0; - while (i < *nmachines) { - size_t j; - bool found =3D false; - virCapsGuestMachinePtr machine =3D (*machines)[i]; - - if (!machine->canonical) { - i++; - continue; - } - - for (j =3D 0; j < *nmachines; j++) { - if (STREQ(machine->canonical, (*machines)[j]->name)) { - found =3D true; - break; - } - } - - if (!found) { - virCapsGuestMachinePtr mach; - if (VIR_ALLOC(mach) < 0) - goto error; - if (VIR_INSERT_ELEMENT_COPY(*machines, i, *nmachines, mach) < = 0) { - VIR_FREE(mach); - goto error; - } - mach->name =3D g_strdup(machine->canonical); - mach->maxCpus =3D machine->maxCpus; - i++; - } - i++; - } - - return 0; - - error: - virCapabilitiesFreeMachines(*machines, *nmachines); - *nmachines =3D 0; - *machines =3D NULL; - return -1; -} - - /** * virQEMUCapsGetCanonicalMachine: * @qemuCaps: qemu capabilities object diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index f43e56a9ca..ee779d90ed 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -606,9 +606,6 @@ int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCap= s, const char *name); bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps, const char *name); -int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps, - size_t *nmachines, - virCapsGuestMachinePtr **machines); =20 void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps, const char *machineType); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list