From nobody Sun May 5 22:21:23 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602060919; cv=none; d=zohomail.com; s=zohoarc; b=jk/o0c98OBYjq9wWWcaZjwGMH+I5+vQHhN2O4Ai+TM/EIirKq2VKZpog5pQOChd3aBN4+E21NG90xPqcW76ZvvH40rXjCFwLAg1GPJEidH0SisGWKf9nWr8fuWkXv1dyzoSo2SrFBLuBfY2n+awm5AKFdg0eCLT3X/nNytSEqG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602060919; h=Content-Type:Content-Transfer-Encoding:Cc: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=IBu4QhBLdX2hTRhYYKMHgMpZEInMuLtLOhdP1mdMIYc=; b=oID7QCzt/eUah+u5bHEByvg+rNJ2A01CDAjDD3e8mcwq+0zAy5k1rxEan3Wn5j5REyJNV0VivBIfpwjOvLUObvhaLGK+XDItox4CY07WdhcaCurWTUzxrzaO38Ej0nrWIHmr1k6iDRAoOzgOt/iAnZT5T/heRrqateTJQgK4l3U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160206091956718.63769570549789; Wed, 7 Oct 2020 01:55:19 -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-399-E247qxR7Nw-OglyBvEnGzg-1; Wed, 07 Oct 2020 04:55:16 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB90F803F64; Wed, 7 Oct 2020 08:55:10 +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 9FAAA5C1BD; Wed, 7 Oct 2020 08:55:10 +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 85707181A06B; Wed, 7 Oct 2020 08:55:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0978t5LB016889 for ; Wed, 7 Oct 2020 04:55:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 20B3A76654; Wed, 7 Oct 2020 08:55:05 +0000 (UTC) Received: from work.redhat.com (ovpn-112-213.ams2.redhat.com [10.36.112.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69FE976650; Wed, 7 Oct 2020 08:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602060918; 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=IBu4QhBLdX2hTRhYYKMHgMpZEInMuLtLOhdP1mdMIYc=; b=LbEXxoD6tVaVSt87GhgHT7vkaFoKWtQNnHV8EvNtXq1u54dkg79lWynE6ro7Wn0ypYaR9p ds2ziIpAQs7jLAK3P47y7vihoo9Lco5YRKGFfLyiHo7dP//FsVF2qHmI1VydtG6tp6rjlc a982kN+0rRQ5NzvfE9XmqW781Ild69Q= X-MC-Unique: E247qxR7Nw-OglyBvEnGzg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 1/5] schema: Make element "topology" in host CPU definition optional Date: Wed, 7 Oct 2020 10:54:54 +0200 Message-Id: <20201007085458.231179-2-twiederh@redhat.com> In-Reply-To: <20201007085458.231179-1-twiederh@redhat.com> References: <20201007085458.231179-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.16 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This element is not always present, see e.g. x86_64-cpuid-Xeon-X5460-host.xml, x86_64-cpuid-Pentium-P6100-host.xml, or x86_64-cpuid-EPYC-7601-32-Core-ibpb-host.xml. Signed-off-by: Tim Wiederhake Reviewed-by: Jiri Denemark --- docs/schemas/cputypes.rng | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/schemas/cputypes.rng b/docs/schemas/cputypes.rng index 88f6904343..aea6ff0267 100644 --- a/docs/schemas/cputypes.rng +++ b/docs/schemas/cputypes.rng @@ -336,17 +336,19 @@ - - - - - - - - - - - + + + + + + + + + + + + + --=20 2.26.2 From nobody Sun May 5 22:21:23 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602060964; cv=none; d=zohomail.com; s=zohoarc; b=VG6ycYaS1V2bKnUc5mMXkTCGwVfiLk/sFg6o40F3efnS2Azw4/h34j41si0p3Sqy+ccckDOSyD95AQ/oxYwyVW/VqoIHkcnBKjruYomInJypH0hTZza0GE+1z6O4PjJ/D734pM4zZbI0748LTHobp5VD7IdMmQy6e7g1IFnnBBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602060964; h=Content-Type:Content-Transfer-Encoding:Cc: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=mQYKA1aQUWlTUN7Dm16FyXpgk7NvmEGoaFJ/ITuRp8I=; b=NkIuKkgPIzgK3u5GEA4Cmr4dJ08ondJRJM2ywf2xwGI0mblf5oWNHzq6IEsupROl/2qLFooj9OffLSuyDhgkDm0BPx93dUgLAuqerp76XmkocsyuijUjRr7746tZpoR/NzcyzNrwsoUXmYUQNkaWRLszdTLY6sXb94mABitiDEg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160206096487670.33290369702308; Wed, 7 Oct 2020 01:56:04 -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-551-TBxALMP_Mbq9vroaJmBRDg-1; Wed, 07 Oct 2020 04:55:31 -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 0B66780400D; Wed, 7 Oct 2020 08:55:26 +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 DEE806EF5E; Wed, 7 Oct 2020 08:55:25 +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 AD4EA181A06E; Wed, 7 Oct 2020 08:55:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0978t6X4016898 for ; Wed, 7 Oct 2020 04:55:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 39F017664C; Wed, 7 Oct 2020 08:55:06 +0000 (UTC) Received: from work.redhat.com (ovpn-112-213.ams2.redhat.com [10.36.112.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79C4376644; Wed, 7 Oct 2020 08:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602060963; 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=mQYKA1aQUWlTUN7Dm16FyXpgk7NvmEGoaFJ/ITuRp8I=; b=HsPWFOa06Knd8kYfCgPtANjjJ/eW5d/mu9YFGk85tmhx1W/TMPs0/w1sJ6VEgxS2/RVPoi h45NXcgzJf4tBAMvSprJjZIJYbhIyA6jUq6fWWQvsH9Wv9JwE8ISwJ8SreTBV9Ruh/4XuE vYsJPZ3/YZX5M1M5pO0uRCMw+kVxqPs= X-MC-Unique: TBxALMP_Mbq9vroaJmBRDg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 2/5] cpu: Wire in XML validation Date: Wed, 7 Oct 2020 10:54:55 +0200 Message-Id: <20201007085458.231179-3-twiederh@redhat.com> In-Reply-To: <20201007085458.231179-1-twiederh@redhat.com> References: <20201007085458.231179-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This adds a new value to virConnectCompareCPUFlags, "VIR_CONNECT_CPU_VALIDATE_XML", that governs XML document validation in virCPUDefParseXML. In src/conf/cpu_conf.c, include configmake.h for PKGDATADIR and virfile.h for virFileFindResource. Signed-off-by: Tim Wiederhake Reviewed-by: Peter Krempa --- include/libvirt/libvirt-host.h | 2 ++ src/bhyve/bhyve_driver.c | 7 +++++-- src/conf/cpu_conf.c | 25 +++++++++++++++++++++---- src/conf/cpu_conf.h | 6 ++++-- src/conf/domain_conf.c | 3 ++- src/cpu/cpu.c | 5 +++-- src/cpu/cpu.h | 3 ++- src/libxl/libxl_driver.c | 7 +++++-- src/qemu/qemu_domain.c | 5 +++-- src/qemu/qemu_driver.c | 18 +++++++++++++----- src/qemu/qemu_migration_cookie.c | 3 ++- tests/cputest.c | 5 +++-- 12 files changed, 65 insertions(+), 24 deletions(-) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 6972834175..4caed94a77 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -754,6 +754,8 @@ typedef enum { typedef enum { VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE =3D (1 << 0), /* treat incom= patible CPUs as failu= re */ + VIR_CONNECT_COMPARE_CPU_VALIDATE_XML =3D (1 << 1), /* validate the xml + document */ } virConnectCompareCPUFlags; =20 int virConnectCompareCPU(virConnectPtr conn, diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 91f41aa238..78c3241293 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1441,14 +1441,17 @@ bhyveConnectCompareCPU(virConnectPtr conn, int ret =3D VIR_CPU_COMPARE_ERROR; virCapsPtr caps =3D NULL; bool failIncompatible; + bool validateXML; =20 - virCheckFlags(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE, + virCheckFlags(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE | + VIR_CONNECT_COMPARE_CPU_VALIDATE_XML, VIR_CPU_COMPARE_ERROR); =20 if (virConnectCompareCPUEnsureACL(conn) < 0) goto cleanup; =20 failIncompatible =3D !!(flags & VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATI= BLE); + validateXML =3D !!(flags & VIR_CONNECT_COMPARE_CPU_VALIDATE_XML); =20 if (!(caps =3D bhyveDriverGetCapabilities(driver))) goto cleanup; @@ -1464,7 +1467,7 @@ bhyveConnectCompareCPU(virConnectPtr conn, } } else { ret =3D virCPUCompareXML(caps->host.arch, caps->host.cpu, - xmlDesc, failIncompatible); + xmlDesc, failIncompatible, validateXML); } =20 cleanup: diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index dea950ce68..1910470836 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -20,9 +20,11 @@ =20 #include =20 +#include "configmake.h" #include "virerror.h" #include "viralloc.h" #include "virbuffer.h" +#include "virfile.h" #include "cpu_conf.h" #include "domain_conf.h" #include "virstring.h" @@ -281,7 +283,8 @@ virCPUDefCopy(const virCPUDef *cpu) int virCPUDefParseXMLString(const char *xml, virCPUType type, - virCPUDefPtr *cpu) + virCPUDefPtr *cpu, + bool validateXML) { xmlDocPtr doc =3D NULL; xmlXPathContextPtr ctxt =3D NULL; @@ -295,7 +298,7 @@ virCPUDefParseXMLString(const char *xml, if (!(doc =3D virXMLParseStringCtxt(xml, _("(CPU_definition)"), &ctxt)= )) goto cleanup; =20 - if (virCPUDefParseXML(ctxt, NULL, type, cpu) < 0) + if (virCPUDefParseXML(ctxt, NULL, type, cpu, validateXML) < 0) goto cleanup; =20 ret =3D 0; @@ -323,7 +326,8 @@ int virCPUDefParseXML(xmlXPathContextPtr ctxt, const char *xpath, virCPUType type, - virCPUDefPtr *cpu) + virCPUDefPtr *cpu, + bool validateXML) { g_autoptr(virCPUDef) def =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; @@ -348,6 +352,19 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, return -1; } =20 + if (validateXML) { + g_autofree char *schemafile =3D NULL; + + if (!(schemafile =3D virFileFindResource("cpu.rng", + abs_top_srcdir "/docs/schem= as", + PKGDATADIR "/schemas"))) + return -1; + + if (virXMLValidateNodeAgainstSchema(schemafile, ctxt->doc, + ctxt->node) < 0) + return -1; + } + def =3D virCPUDefNew(); =20 if (type =3D=3D VIR_CPU_TYPE_AUTO) { @@ -1146,7 +1163,7 @@ virCPUDefListParse(const char **xmlCPUs, if (!(doc =3D virXMLParseStringCtxt(xmlCPUs[i], _("(CPU_definition= )"), &ctxt))) goto error; =20 - if (virCPUDefParseXML(ctxt, NULL, cpuType, &cpus[i]) < 0) + if (virCPUDefParseXML(ctxt, NULL, cpuType, &cpus[i], false) < 0) goto error; =20 xmlXPathFreeContext(ctxt); diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index 24c51e3a63..3ef14b7932 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -192,13 +192,15 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu); int virCPUDefParseXMLString(const char *xml, virCPUType type, - virCPUDefPtr *cpu); + virCPUDefPtr *cpu, + bool validateXML); =20 int virCPUDefParseXML(xmlXPathContextPtr ctxt, const char *xpath, virCPUType mode, - virCPUDefPtr *cpu); + virCPUDefPtr *cpu, + bool validateXML); =20 bool virCPUDefIsEqual(virCPUDefPtr src, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 175b632a38..c003b5c030 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21917,7 +21917,8 @@ virDomainDefParseXML(xmlDocPtr xml, if (virDomainDefTunablesParse(def, ctxt, xmlopt, flags) < 0) goto error; =20 - if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &def->cpu)= < 0) + if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &def->cpu, + false) < 0) goto error; =20 if (virDomainNumaDefParseXML(def->numa, ctxt) < 0) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 188c5d86b5..bf94811960 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -109,14 +109,15 @@ virCPUCompareResult virCPUCompareXML(virArch arch, virCPUDefPtr host, const char *xml, - bool failIncompatible) + bool failIncompatible, + bool validateXML) { g_autoptr(virCPUDef) cpu =3D NULL; =20 VIR_DEBUG("arch=3D%s, host=3D%p, xml=3D%s", virArchToString(arch), host, NULLSTR(xml)); =20 - if (virCPUDefParseXMLString(xml, VIR_CPU_TYPE_AUTO, &cpu) < 0) + if (virCPUDefParseXMLString(xml, VIR_CPU_TYPE_AUTO, &cpu, validateXML)= < 0) return VIR_CPU_COMPARE_ERROR; =20 return virCPUCompare(arch, host, cpu, failIncompatible); diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index ba8fdd07ba..cc2d132275 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -153,7 +153,8 @@ virCPUCompareResult virCPUCompareXML(virArch arch, virCPUDefPtr host, const char *xml, - bool failIncompatible); + bool failIncompatible, + bool validateXML); =20 virCPUCompareResult virCPUCompare(virArch arch, diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index e28c649688..824ed60dfd 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6529,19 +6529,22 @@ libxlConnectCompareCPU(virConnectPtr conn, libxlDriverConfigPtr cfg; int ret =3D VIR_CPU_COMPARE_ERROR; bool failIncompatible; + bool validateXML; =20 - virCheckFlags(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE, + virCheckFlags(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE | + VIR_CONNECT_COMPARE_CPU_VALIDATE_XML, VIR_CPU_COMPARE_ERROR); =20 if (virConnectCompareCPUEnsureACL(conn) < 0) return ret; =20 failIncompatible =3D !!(flags & VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATI= BLE); + validateXML =3D !!(flags & VIR_CONNECT_COMPARE_CPU_VALIDATE_XML); =20 cfg =3D libxlDriverConfigGet(driver); =20 ret =3D virCPUCompareXML(cfg->caps->host.arch, cfg->caps->host.cpu, - xmlDesc, failIncompatible); + xmlDesc, failIncompatible, validateXML); =20 virObjectUnref(cfg); return ret; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0687f4584c..9623123d3c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3130,7 +3130,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, =20 qemuDomainSetPrivatePathsOld(driver, vm); =20 - if (virCPUDefParseXML(ctxt, "./cpu", VIR_CPU_TYPE_GUEST, &priv->origCP= U) < 0) + if (virCPUDefParseXML(ctxt, "./cpu", VIR_CPU_TYPE_GUEST, &priv->origCP= U, + false) < 0) goto error; =20 priv->chardevStdioLogd =3D virXPathBoolean("boolean(./chardevStdioLogd= )", @@ -9997,7 +9998,7 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt G_G= NUC_UNUSED, return -1; =20 if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, - &cookie->cpu) < 0) + &cookie->cpu, false) < 0) return -1; =20 cookie->slirpHelper =3D virXPathBoolean("boolean(./slirpHelper)", ctxt= ) > 0; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5aaa969409..8ef812cd94 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12202,20 +12202,23 @@ qemuConnectCompareCPU(virConnectPtr conn, virQEMUDriverPtr driver =3D conn->privateData; g_autoptr(virCPUDef) cpu =3D NULL; bool failIncompatible; + bool validateXML; =20 - virCheckFlags(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE, + virCheckFlags(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE | + VIR_CONNECT_COMPARE_CPU_VALIDATE_XML, VIR_CPU_COMPARE_ERROR); =20 if (virConnectCompareCPUEnsureACL(conn) < 0) return VIR_CPU_COMPARE_ERROR; =20 failIncompatible =3D !!(flags & VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATI= BLE); + validateXML =3D !!(flags & VIR_CONNECT_COMPARE_CPU_VALIDATE_XML); =20 if (!(cpu =3D virQEMUDriverGetHostCPU(driver))) return VIR_CPU_COMPARE_ERROR; =20 return virCPUCompareXML(driver->hostarch, cpu, - xmlDesc, failIncompatible); + xmlDesc, failIncompatible, validateXML); } =20 =20 @@ -12270,18 +12273,21 @@ qemuConnectCompareHypervisorCPU(virConnectPtr con= n, g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virQEMUCaps) qemuCaps =3D NULL; bool failIncompatible; + bool validateXML; virCPUDefPtr hvCPU; virCPUDefPtr cpu =3D NULL; virArch arch; virDomainVirtType virttype; =20 - virCheckFlags(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE, + virCheckFlags(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE | + VIR_CONNECT_COMPARE_CPU_VALIDATE_XML, VIR_CPU_COMPARE_ERROR); =20 if (virConnectCompareHypervisorCPUEnsureACL(conn) < 0) goto cleanup; =20 failIncompatible =3D !!(flags & VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATI= BLE); + validateXML =3D !!(flags & VIR_CONNECT_COMPARE_CPU_VALIDATE_XML); =20 qemuCaps =3D virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, emulator, @@ -12305,10 +12311,12 @@ qemuConnectCompareHypervisorCPU(virConnectPtr con= n, } =20 if (ARCH_IS_X86(arch)) { - ret =3D virCPUCompareXML(arch, hvCPU, xmlCPU, failIncompatible); + ret =3D virCPUCompareXML(arch, hvCPU, xmlCPU, failIncompatible, + validateXML); } else if (ARCH_IS_S390(arch) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_COMPARIS= ON)) { - if (virCPUDefParseXMLString(xmlCPU, VIR_CPU_TYPE_AUTO, &cpu) < 0) + if (virCPUDefParseXMLString(xmlCPU, VIR_CPU_TYPE_AUTO, &cpu, + validateXML) < 0) goto cleanup; =20 if (!cpu->model) { diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 91694000d8..abe797759d 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1263,7 +1263,8 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, return -1; =20 if (flags & QEMU_MIGRATION_COOKIE_CPU && - virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &mig->cpu)= < 0) + virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &mig->cpu, + false) < 0) return -1; =20 if (flags & QEMU_MIGRATION_COOKIE_ALLOW_REBOOT && diff --git a/tests/cputest.c b/tests/cputest.c index 383da94938..78a7f2437a 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -81,7 +81,7 @@ cpuTestLoadXML(virArch arch, const char *name) if (!(doc =3D virXMLParseFileCtxt(xml, &ctxt))) goto cleanup; =20 - virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu); + virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, false); =20 cleanup: xmlXPathFreeContext(ctxt); @@ -120,7 +120,8 @@ cpuTestLoadMultiXML(virArch arch, =20 for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; - if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i]) < 0) + if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i], + false) < 0) goto cleanup_cpus; } =20 --=20 2.26.2 From nobody Sun May 5 22:21:23 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602060938; cv=none; d=zohomail.com; s=zohoarc; b=BjO01rFCI1F4njKA3i/LZL1EL6vgAdTqe4ky/9zOY7dE7S1DqY5TJYYQh8oxQvG269Q1yw2z94y042iuMy74x/HVvX+MC0UZKBZPcDozNXkOXh+mhyG4hcnZoZx9vhifO/3ImjU8rtySnWYeyDTTKwuoicqhrpkdUr//mZkhWh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602060938; h=Content-Type:Content-Transfer-Encoding:Cc: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=njsge6VVWN2mjMGnCH+l6eIlZKveykFQmKsLEgI2aLc=; b=Yl+LLwzh07vsy+KclfsTz8f3YCgDLqORXJtDkVYnGw2lA7e8pSd4lA15BzozoZGa8vQ1FT3tsYL2+8oqs2Li9zH1WnJvlc5GDHWCyhuFjynRMTlA+C+MUDS7ZAm1DgLwK8VVSQ6sWHoTFDUc0Pc6ifkNreSFc9RfmQm6Icn0Rj0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602060938175654.2419569776799; Wed, 7 Oct 2020 01:55:38 -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-25-tsN6AsvJMyGagT86y5AniA-1; Wed, 07 Oct 2020 04:55:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE63810A02E4; Wed, 7 Oct 2020 08:55:28 +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 AABAD5D9F7; Wed, 7 Oct 2020 08:55:28 +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 73293181A07C; Wed, 7 Oct 2020 08:55:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0978t7Mj016906 for ; Wed, 7 Oct 2020 04:55:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4756B7664C; Wed, 7 Oct 2020 08:55:07 +0000 (UTC) Received: from work.redhat.com (ovpn-112-213.ams2.redhat.com [10.36.112.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CCCE76644; Wed, 7 Oct 2020 08:55:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602060936; 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=njsge6VVWN2mjMGnCH+l6eIlZKveykFQmKsLEgI2aLc=; b=E7ic/bJs2X05oUzjtkb7hYsRg8XXw0UPNANkoCJ5n1q8wV0bFsBEPa3MFLUC0M/cGizCeb +1D9MUZe8G7vWziEfiflklCT81TxEYA5bXjEP+lcgJ26I9BOIuTBHm1BLITA1U4GzPQknA mpv7vrUBxfvThaOQD7IgF59cU6AY1Qg= X-MC-Unique: tsN6AsvJMyGagT86y5AniA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 3/5] tests: Rename some test files in cputestdata Date: Wed, 7 Oct 2020 10:54:56 +0200 Message-Id: <20201007085458.231179-4-twiederh@redhat.com> In-Reply-To: <20201007085458.231179-1-twiederh@redhat.com> References: <20201007085458.231179-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.14 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The files contained the "-invalid" marker in their filename, marking them as test cases that are supposed to fail. Unfortunately, the "-invalid" marker does not discriminate between different tests the files might be used in. A later patch will introduce a new test validating the XML. This test is not supposed to fail, as the files contain valid XML. Signed-off-by: Tim Wiederhake Reviewed-by: Peter Krempa --- tests/cputest.c | 10 +++++----- ...t-compat-invalid.xml =3D> ppc64-guest-compat-bad.xml} | 0 ...t-legacy-invalid.xml =3D> ppc64-guest-legacy-bad.xml} | 0 ...pat-invalid.xml =3D> ppc64-host+guest-compat-bad.xml} | 0 ...acy-invalid.xml =3D> ppc64-host+guest-legacy-bad.xml} | 0 5 files changed, 5 insertions(+), 5 deletions(-) rename tests/cputestdata/{ppc64-guest-compat-invalid.xml =3D> ppc64-guest-= compat-bad.xml} (100%) rename tests/cputestdata/{ppc64-guest-legacy-invalid.xml =3D> ppc64-guest-= legacy-bad.xml} (100%) rename tests/cputestdata/{ppc64-host+guest-compat-invalid.xml =3D> ppc64-h= ost+guest-compat-bad.xml} (100%) rename tests/cputestdata/{ppc64-host+guest-legacy-invalid.xml =3D> ppc64-h= ost+guest-legacy-bad.xml} (100%) diff --git a/tests/cputest.c b/tests/cputest.c index 78a7f2437a..90f319bf9c 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -1137,10 +1137,10 @@ mymain(void) DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-exact", VIR_CPU_COMPARE= _INCOMPATIBLE); DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-legacy", VIR_CPU_COMPAR= E_IDENTICAL); DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-legacy-incompatible", V= IR_CPU_COMPARE_INCOMPATIBLE); - DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-legacy-invalid", VIR_CP= U_COMPARE_ERROR); + DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-legacy-bad", VIR_CPU_CO= MPARE_ERROR); DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-compat-none", VIR_CPU_C= OMPARE_IDENTICAL); DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-compat-valid", VIR_CPU_= COMPARE_IDENTICAL); - DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-compat-invalid", VIR_CP= U_COMPARE_ERROR); + DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-compat-bad", VIR_CPU_CO= MPARE_ERROR); DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-compat-incompatible", V= IR_CPU_COMPARE_INCOMPATIBLE); =20 /* guest updates for migration @@ -1158,10 +1158,10 @@ mymain(void) DO_TEST_UPDATE(VIR_ARCH_PPC64, "host", "guest-nofallback", VIR_CPU_COM= PARE_INCOMPATIBLE); DO_TEST_UPDATE(VIR_ARCH_PPC64, "host", "guest-legacy", VIR_CPU_COMPARE= _IDENTICAL); DO_TEST_UPDATE(VIR_ARCH_PPC64, "host", "guest-legacy-incompatible", VI= R_CPU_COMPARE_INCOMPATIBLE); - DO_TEST_UPDATE(VIR_ARCH_PPC64, "host", "guest-legacy-invalid", VIR_CPU= _COMPARE_ERROR); + DO_TEST_UPDATE(VIR_ARCH_PPC64, "host", "guest-legacy-bad", VIR_CPU_COM= PARE_ERROR); DO_TEST_UPDATE(VIR_ARCH_PPC64, "host", "guest-compat-none", VIR_CPU_CO= MPARE_IDENTICAL); DO_TEST_UPDATE(VIR_ARCH_PPC64, "host", "guest-compat-valid", VIR_CPU_C= OMPARE_IDENTICAL); - DO_TEST_UPDATE(VIR_ARCH_PPC64, "host", "guest-compat-invalid", VIR_CPU= _COMPARE_ERROR); + DO_TEST_UPDATE(VIR_ARCH_PPC64, "host", "guest-compat-bad", VIR_CPU_COM= PARE_ERROR); DO_TEST_UPDATE(VIR_ARCH_PPC64, "host", "guest-compat-incompatible", VI= R_CPU_COMPARE_INCOMPATIBLE); =20 /* computing baseline CPUs */ @@ -1216,7 +1216,7 @@ mymain(void) DO_TEST_GUESTCPU(VIR_ARCH_PPC64, "host", "guest-nofallback", ppc_model= s, -1); DO_TEST_GUESTCPU(VIR_ARCH_PPC64, "host", "guest-legacy", ppc_models, 0= ); DO_TEST_GUESTCPU(VIR_ARCH_PPC64, "host", "guest-legacy-incompatible", = ppc_models, -1); - DO_TEST_GUESTCPU(VIR_ARCH_PPC64, "host", "guest-legacy-invalid", ppc_m= odels, -1); + DO_TEST_GUESTCPU(VIR_ARCH_PPC64, "host", "guest-legacy-bad", ppc_model= s, -1); =20 DO_TEST_CPUID(VIR_ARCH_X86_64, "A10-5800K", JSON_HOST); DO_TEST_CPUID(VIR_ARCH_X86_64, "Atom-D510", JSON_NONE); diff --git a/tests/cputestdata/ppc64-guest-compat-invalid.xml b/tests/cpute= stdata/ppc64-guest-compat-bad.xml similarity index 100% rename from tests/cputestdata/ppc64-guest-compat-invalid.xml rename to tests/cputestdata/ppc64-guest-compat-bad.xml diff --git a/tests/cputestdata/ppc64-guest-legacy-invalid.xml b/tests/cpute= stdata/ppc64-guest-legacy-bad.xml similarity index 100% rename from tests/cputestdata/ppc64-guest-legacy-invalid.xml rename to tests/cputestdata/ppc64-guest-legacy-bad.xml diff --git a/tests/cputestdata/ppc64-host+guest-compat-invalid.xml b/tests/= cputestdata/ppc64-host+guest-compat-bad.xml similarity index 100% rename from tests/cputestdata/ppc64-host+guest-compat-invalid.xml rename to tests/cputestdata/ppc64-host+guest-compat-bad.xml diff --git a/tests/cputestdata/ppc64-host+guest-legacy-invalid.xml b/tests/= cputestdata/ppc64-host+guest-legacy-bad.xml similarity index 100% rename from tests/cputestdata/ppc64-host+guest-legacy-invalid.xml rename to tests/cputestdata/ppc64-host+guest-legacy-bad.xml --=20 2.26.2 From nobody Sun May 5 22:21:23 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602060942; cv=none; d=zohomail.com; s=zohoarc; b=Im16yI6QlFD7iabi2QwypiNOZvUqVTmfHy98UMaWw9/NUTsPixGCaeCK3V7jCgiHYy8ORDSy2hH69OccTXTsIL9b6jMucFD+1OHD2ShGQyFgY3M/ZAKW8l6RdOvEHbCYUmd4QQWdrZH3sO1B9gEFBA1CqXE05XtyRmYXWDi0BF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602060942; h=Content-Type:Content-Transfer-Encoding:Cc: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=PMncSi7zhQSIOFvS1UjRMCgVbLXAJB+8crOPGmGBl7k=; b=l54OtfDlqsSQldVeEGJpZvnnOJx09MU6fGWMSSGBwfOlmI5+k3Z5AUIFxvyCEraly7rHw0qNMVoSVu8n2s7YRSxSvRVf2ybYBRG7wNOhFprCKRmY9SLhq3nBgm6gv5NA25f+FWYU03uQiLKaDbgIKa60tOcFHle/d8BCXNfXT+Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602060942653505.4691150076429; Wed, 7 Oct 2020 01:55:42 -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-383-eQbcYR2wNIauUQvSIeh6_A-1; Wed, 07 Oct 2020 04:55:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B95A9D6888; Wed, 7 Oct 2020 08:55: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 9362775120; Wed, 7 Oct 2020 08:55: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 628E7181A2E5; Wed, 7 Oct 2020 08:55:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0978t8PE016914 for ; Wed, 7 Oct 2020 04:55:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 542A17664C; Wed, 7 Oct 2020 08:55:08 +0000 (UTC) Received: from work.redhat.com (ovpn-112-213.ams2.redhat.com [10.36.112.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A57E76644; Wed, 7 Oct 2020 08:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602060941; 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=PMncSi7zhQSIOFvS1UjRMCgVbLXAJB+8crOPGmGBl7k=; b=ZRpCwqLTMGX/XYUo7fWtqr1lpEvTjrv3IoGNT/fwoQe98NMDVzeX/WExyvPB2e5Kp5BH7/ D4dPC+vilZGGvj23gWztnoAHl4KPT5hnp+Nl087HR7ICZurjE5COsNG6JFZIeJP2EP02pI iYm2tPxQH/uKVzV89WYhZgfUa5X8Jfk= X-MC-Unique: eQbcYR2wNIauUQvSIeh6_A-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 4/5] tests: Enable CPU XML validation in the tests. Date: Wed, 7 Oct 2020 10:54:57 +0200 Message-Id: <20201007085458.231179-5-twiederh@redhat.com> In-Reply-To: <20201007085458.231179-1-twiederh@redhat.com> References: <20201007085458.231179-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- docs/schemas/cpu_test.rng | 48 +++++++++++++++++++++++++++++++++++++++ docs/schemas/meson.build | 1 + tests/cputest.c | 2 +- tests/virschematest.c | 1 + 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 docs/schemas/cpu_test.rng diff --git a/docs/schemas/cpu_test.rng b/docs/schemas/cpu_test.rng new file mode 100644 index 0000000000..471958bb7b --- /dev/null +++ b/docs/schemas/cpu_test.rng @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/schemas/meson.build b/docs/schemas/meson.build index bb6a48787f..51c917d1ac 100644 --- a/docs/schemas/meson.build +++ b/docs/schemas/meson.build @@ -2,6 +2,7 @@ docs_schema_files =3D [ 'basictypes.rng', 'capability.rng', 'cpu.rng', + 'cpu_test.rng', 'cputypes.rng', 'domainbackup.rng', 'domaincaps.rng', diff --git a/tests/cputest.c b/tests/cputest.c index 90f319bf9c..e31c2c0820 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -81,7 +81,7 @@ cpuTestLoadXML(virArch arch, const char *name) if (!(doc =3D virXMLParseFileCtxt(xml, &ctxt))) goto cleanup; =20 - virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, false); + virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, true); =20 cleanup: xmlXPathFreeContext(ctxt); diff --git a/tests/virschematest.c b/tests/virschematest.c index 17eb2a4b34..fa7c64c0b8 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -198,6 +198,7 @@ mymain(void) } while (0) =20 DO_TEST_DIR("capability.rng", "capabilityschemadata", "vircaps2xmldata= "); + DO_TEST_DIR("cpu_test.rng", "cputestdata"); DO_TEST_DIR("domain.rng", "domainschemadata", "qemuxml2argvdata", "xmconfigdata", "qemuxml2xmloutdata", "lxcxml2xmldata", --=20 2.26.2 From nobody Sun May 5 22:21:23 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602060935; cv=none; d=zohomail.com; s=zohoarc; b=aY1MPMpUVOICvKMC9kQkbjgZpQqaLYAWWXaYoSPDpL3l0bf2hHunHe14Ci/mWSzy8Lv3pA7OzUqs67GX81sj3e1iwxOI3uVdELaYE4YVrOJQ40FDEoIAOl1QsfN46f4a4+LTYNaFbJo8sSiIQmQwQvHZNfyCLB5JmyZzzHoQ/zk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602060935; h=Content-Type:Content-Transfer-Encoding:Cc: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=RIM032KrZRFlf9wHiB0OR+aaJWsOFj+TC/UYDYk/uyI=; b=Ny6LdFJu1OpdIdQFSpRDPVvd7JZdssEe9+RvlmqoeJI7s896+Wm/9ukAdcwA2QrS/2LiIg0nFQ1DEh1krc3b5Y0RYe1cFC8NBZCrE06N7DeE1vlgL2bXWvPq9PgJGRc0Tw9BAGUF6UGlGZuO/F6lLoRXzSnpLESNHMwDeVd4gyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602060935334307.98083772368545; Wed, 7 Oct 2020 01:55:35 -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-551-d-J5qkMcPe6Jta3HN8ZHDw-1; Wed, 07 Oct 2020 04:55:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0BF24D6880; Wed, 7 Oct 2020 08:55:26 +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 DBA9D5C1CF; Wed, 7 Oct 2020 08:55:25 +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 AC32C8B2B6; Wed, 7 Oct 2020 08:55:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0978t91c016928 for ; Wed, 7 Oct 2020 04:55:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 68D327664C; Wed, 7 Oct 2020 08:55:09 +0000 (UTC) Received: from work.redhat.com (ovpn-112-213.ams2.redhat.com [10.36.112.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id A65AF76644; Wed, 7 Oct 2020 08:55:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602060934; 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=RIM032KrZRFlf9wHiB0OR+aaJWsOFj+TC/UYDYk/uyI=; b=dMk8AdzbL7d/2OpCbJylR2y+a9H8qm6M8oKY+1aiku4j8ypfIe8dJQxORMY4HgWz9yEvL1 QilKKudAff2BT+s/J+x2zQD+txxRADSOKDiK8lbOIRAS/nLpjz9L8OBMUeb/4MapycMiqD 12wNIrBd3ksUmNZZOqUXPqMWywaC3Bw= X-MC-Unique: d-J5qkMcPe6Jta3HN8ZHDw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v4 5/5] virsh: Add "validate" argument to [hypervisor-]cpu-compare Date: Wed, 7 Oct 2020 10:54:58 +0200 Message-Id: <20201007085458.231179-6-twiederh@redhat.com> In-Reply-To: <20201007085458.231179-1-twiederh@redhat.com> References: <20201007085458.231179-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.16 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Peter Krempa --- docs/manpages/virsh.rst | 9 ++++++--- tools/virsh-host.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index c855269041..8fee4c7afe 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -866,7 +866,7 @@ cpu-compare =20 :: =20 - cpu-compare FILE [--error] + cpu-compare FILE [--error] [--validate] =20 Compare CPU definition from XML with host CPU. (See ``hypervisor-cpu-compare`` command for comparing the CPU definition with t= he CPU @@ -882,7 +882,8 @@ the CPU definition. For more information on guest CPU d= efinition see: `https://libvirt.org/formatdomain.html#elementsCPU `__. If *--error* is specified, the command will return an error when the given CPU is incompatible with host CPU and a message providing more details about the -incompatibility will be printed out. +incompatibility will be printed out. If *--validate* is specified, validat= es +the format of the XML document against an internal RNG schema. =20 =20 cpu-models @@ -928,7 +929,7 @@ hypervisor-cpu-compare =20 :: =20 - hypervisor-cpu-compare FILE [virttype] [emulator] [arch] [machine] [--e= rror] + hypervisor-cpu-compare FILE [virttype] [emulator] [arch] [machine] [--e= rror] [--validate] =20 Compare CPU definition from XML with the CPU the hypervisor is able= to provide on the host. (This is different from ``cpu-compare`` which compare= s the @@ -951,6 +952,8 @@ specifies the path to the emulator, *arch* specifies th= e CPU architecture, and *machine* specifies the machine type. If *--error* is specified, the comma= nd will return an error when the given CPU is incompatible with the host CPU = and a message providing more details about the incompatibility will be printed o= ut. +If *--validate* is specified, validates the format of the XML document aga= inst +an internal RNG schema. =20 =20 hypervisor-cpu-baseline diff --git a/tools/virsh-host.c b/tools/virsh-host.c index d4eb3f977d..cda2ef4ac1 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1214,6 +1214,10 @@ static const vshCmdOptDef opts_cpu_compare[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("report error if CPUs are incompatible") }, + {.name =3D "validate", + .type =3D VSH_OT_BOOL, + .help =3D N_("validate the XML document against schema") + }, {.name =3D NULL} }; =20 @@ -1230,6 +1234,9 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "error")) flags |=3D VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE; =20 + if (vshCommandOptBool(cmd, "validate")) + flags |=3D VIR_CONNECT_COMPARE_CPU_VALIDATE_XML; + if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; =20 @@ -1636,6 +1643,10 @@ static const vshCmdOptDef opts_hypervisor_cpu_compar= e[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("report error if CPUs are incompatible") }, + {.name =3D "validate", + .type =3D VSH_OT_BOOL, + .help =3D N_("validate the XML document against schema") + }, {.name =3D NULL} }; =20 @@ -1657,6 +1668,9 @@ cmdHypervisorCPUCompare(vshControl *ctl, if (vshCommandOptBool(cmd, "error")) flags |=3D VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE; =20 + if (vshCommandOptBool(cmd, "validate")) + flags |=3D VIR_CONNECT_COMPARE_CPU_VALIDATE_XML; + if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0 || vshCommandOptStringReq(ctl, cmd, "virttype", &virttype) < 0 || vshCommandOptStringReq(ctl, cmd, "emulator", &emulator) < 0 || --=20 2.26.2