From nobody Mon Feb 9 10:12:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1600693697; cv=none; d=zohomail.com; s=zohoarc; b=XhSigGUi9pzOIB71a/5Ezt/6Xui4f+muysO2XiRFuD3JKtoeu4vCuSpdoLCAuth/YFGIfu2KRVIUwpahlbYKsW3/OznF4KcfldKKTROsqv3MWJl8KiruDXPCYZd1NPdFtuUer2hZvgIoXMbCyaSlK06Hb6OM5XoJNZpYkP0pRL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600693697; 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=wvXEgoioeTbMLhJd9O3apV/bwpmUTTRyh8+X7x2GyOg=; b=kKrFYe4k/N6ODO3v0n15tYMgbABojM+kmuC3Hzre2JnwYRDmDgY9ARp5Am1Zjb108ymPxZ8oS6JR4TOMxZDvy/PpNPNYF7hm5kE9K+dpvfe0kpj5kWpvyE2B9d838G/CM1lNNzo1MmaOT8Hi1IgflyC64s0z3q1enGyWYVFkMok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1600693697347114.37104601267424; Mon, 21 Sep 2020 06:08:17 -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-376-Vy12ipKRMuS0m-T_4w3xyQ-1; Mon, 21 Sep 2020 09:08:13 -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 7A69110082F9; Mon, 21 Sep 2020 13:08:07 +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 58E4273689; Mon, 21 Sep 2020 13:08:07 +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 269F38C7C9; Mon, 21 Sep 2020 13:08:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08LD7lIG020137 for ; Mon, 21 Sep 2020 09:07:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2994F1A913; Mon, 21 Sep 2020 13:07:47 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-154.ams2.redhat.com [10.36.112.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6ACBB27BA6; Mon, 21 Sep 2020 13:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600693696; 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=wvXEgoioeTbMLhJd9O3apV/bwpmUTTRyh8+X7x2GyOg=; b=CT1eNJ+jC5KJixPhCsOc+SuFGTVpYP1f2F2MeUimxHCCx6chwAu+xSt3osJ2OwzbTx4bea aqy42EEMkjpQG5mtsNpv51rK9G7KK+gaFKJOQ5QdkpBfutDGF+UWn8YPDW8zqTIRsHbsG+ loN6O74HW7NI+hvW7+hsHYFudfi6RxQ= X-MC-Unique: Vy12ipKRMuS0m-T_4w3xyQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 7/9] virsh: Add "validate" argument to [hypervisor-]cpu-compare Date: Mon, 21 Sep 2020 15:07:30 +0200 Message-Id: <20200921130732.305622-8-twiederh@redhat.com> In-Reply-To: <20200921130732.305622-1-twiederh@redhat.com> References: <20200921130732.305622-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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" Signed-off-by: Tim Wiederhake --- include/libvirt/libvirt-host.h | 1 + src/bhyve/bhyve_driver.c | 7 +++++-- src/libxl/libxl_driver.c | 7 +++++-- src/qemu/qemu_driver.c | 18 +++++++++++++----- tools/virsh-host.c | 14 ++++++++++++++ 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 6972834175..9e7840b9c2 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -754,6 +754,7 @@ 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 xml fil= es */ } virConnectCompareCPUFlags; =20 int virConnectCompareCPU(virConnectPtr conn, diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index fc57ccd504..7dce3f8648 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1442,14 +1442,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; @@ -1465,7 +1468,7 @@ bhyveConnectCompareCPU(virConnectPtr conn, } } else { ret =3D virCPUCompareXML(caps->host.arch, caps->host.cpu, - xmlDesc, failIncompatible, false); + xmlDesc, failIncompatible, validateXML); } =20 cleanup: diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 72864c2dc9..6d1f2edd54 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, false); + xmlDesc, failIncompatible, validateXML); =20 virObjectUnref(cfg); return ret; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a7961ad3f0..a0c0a4c777 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12227,20 +12227,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, false); + xmlDesc, failIncompatible, validateXML); } =20 =20 @@ -12295,18 +12298,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, @@ -12330,10 +12336,12 @@ qemuConnectCompareHypervisorCPU(virConnectPtr con= n, } =20 if (ARCH_IS_X86(arch)) { - ret =3D virCPUCompareXML(arch, hvCPU, xmlCPU, failIncompatible, fa= lse); + 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, false= ) < 0) + if (virCPUDefParseXMLString(xmlCPU, VIR_CPU_TYPE_AUTO, &cpu, + validateXML) < 0) goto cleanup; =20 ret =3D qemuConnectCPUModelComparison(qemuCaps, cfg->libDir, diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 722c47958b..80edfae16c 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_("enable XML file validation") + }, {.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_("enable XML file validation") + }, {.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