From nobody Sun Feb 8 17:42:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1665163337; cv=none; d=zohomail.com; s=zohoarc; b=RJtC1eHmm4I0YRWyKOxK5Zjtk4MgwmRyYGBvaPIAC4Tb0W3GjUwVN92JkuiaRww1M/wCFWHVijjh/+riAyILmQOOVTiEMUTZQopLXVD9itoR0cgcN4tIeo+40pe0ekspwB8J0+bDzyGxfEK6T/QYi0k5nKPwqDsxbVasfE7qGrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665163337; 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=IkPu+H25etQjVgoj/Bc9k0wnFIzr4tCW277HJbTiM5I=; b=OZg+poXjGvWQihCG6J/lfVxkxYmGLhvX9DZDCG/CrOvQegB9LeAavgmU0rqQc3+jTygKRg+Q9BNUJO+GBvLrAWfWwqAYvWi9HP1zejSs3SLB3wrBOqoycuAe6Rdq0gO1gXDVzv8jWqWeOVvuCl7ELk0e4N+dOl6TSAB59cKiyvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1665163337246542.8247429725436; Fri, 7 Oct 2022 10:22:17 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-297-3HJhgDjzMbuQenx3-L7J7Q-1; Fri, 07 Oct 2022 13:22:11 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A56A185A7A4; Fri, 7 Oct 2022 17:22:04 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C540145BA5C; Fri, 7 Oct 2022 17:22:04 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E006E1949763; Fri, 7 Oct 2022 17:22:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 52AE81946A66 for ; Fri, 7 Oct 2022 17:21:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 43C1E145BA57; Fri, 7 Oct 2022 17:21:57 +0000 (UTC) Received: from rein.int.mamuti.net (unknown [10.40.194.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E800145BA56 for ; Fri, 7 Oct 2022 17:21:57 +0000 (UTC) Received: by rein.int.mamuti.net (Postfix, from userid 500) id 3B12818010D; Fri, 7 Oct 2022 19:21:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665163336; 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=IkPu+H25etQjVgoj/Bc9k0wnFIzr4tCW277HJbTiM5I=; b=M8jW5c9yixVcJ0y2Vc8VRA8XDzixqDsBR9Ow6Mm8eLvWzm/WPfUuynwnOOHY1R+cV3a1w5 Cy+lwBOADgVQp+HlgUeDIa3haO2TzoqOY0rjxm1NUGG7nEadnDYmy4exE9KX5+kkbOHwTl 2t06eI/B4bL8SVcaC53Gi+gOg4zYlSY= X-MC-Unique: 3HJhgDjzMbuQenx3-L7J7Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 13/14] virsh: Add completer for hypervisor-cpu-baseline --model Date: Fri, 7 Oct 2022 19:21:50 +0200 Message-Id: <8b9a6c0e4e5817daafeea28c4fcc9143f8e33415.1665162978.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665163338789100015 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 2: - new patch tools/virsh-completer-host.c | 50 ++++++++++++++++++++++++++++++++++++ tools/virsh-completer-host.h | 5 ++++ tools/virsh-host.c | 1 + 3 files changed, 56 insertions(+) diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c index 05a84a43bb..93b633eb64 100644 --- a/tools/virsh-completer-host.c +++ b/tools/virsh-completer-host.c @@ -205,3 +205,53 @@ virshArchCompleter(vshControl *ctl G_GNUC_UNUSED, return virshEnumComplete(VIR_ARCH_LAST, (const char *(*)(int))virArchToString); } + + +char ** +virshCPUModelCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + virshControl *priv =3D ctl->privData; + const char *virttype =3D NULL; + const char *emulator =3D NULL; + const char *arch =3D NULL; + const char *machine =3D NULL; + g_autofree char *domcaps =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; + g_auto(GStrv) models =3D NULL; + int nmodels =3D 0; + size_t i; + + virCheckFlags(0, NULL); + + if (vshCommandOptStringReq(ctl, cmd, "virttype", &virttype) < 0 || + vshCommandOptStringReq(ctl, cmd, "emulator", &emulator) < 0 || + vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 || + vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0) + return NULL; + + if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) + return NULL; + + if (!(domcaps =3D virConnectGetDomainCapabilities(priv->conn, emulator= , arch, + machine, virttype, 0))) + return NULL; + + if (!(xml =3D virXMLParseStringCtxt(domcaps, _("domain capabilities"),= &ctxt))) + return NULL; + + nmodels =3D virXPathNodeSet("/domainCapabilities/cpu/mode[@name=3D'cus= tom']/model", + ctxt, &nodes); + if (nmodels <=3D 0) + return NULL; + + models =3D g_new0(char *, nmodels + 1); + + for (i =3D 0; i < nmodels; i++) + models[i] =3D virXMLNodeContentString(nodes[i]); + + return g_steal_pointer(&models); +} diff --git a/tools/virsh-completer-host.h b/tools/virsh-completer-host.h index b182661cde..608ae9e3e7 100644 --- a/tools/virsh-completer-host.h +++ b/tools/virsh-completer-host.h @@ -51,3 +51,8 @@ char ** virshArchCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshCPUModelCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 16c3585a1a..21d479fd01 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1719,6 +1719,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_baselin= e[] =3D { }, {.name =3D "model", .type =3D VSH_OT_STRING, + .completer =3D virshCPUModelCompleter, .help =3D N_("Shortcut for calling the command with a single CPU mode= l " "and no additional features") }, --=20 2.38.0