From nobody Mon Feb 9 09:28:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1689694289; cv=none; d=zohomail.com; s=zohoarc; b=l+LC1c51lxZpiGNUiHme4Z8OBs0AVktmUXXaEvt6nZck/T6DjcSAGhtZj3pHciJYpVf5paRaYn6f0Wa4xAqOoWPH3LfV8qcJ3OBiMh7KWTIkrd4Aw8QTMipSrgFn6vs6fXgs3G/TjP4McT1QeqFzmWFL/kn8VPm9BFMhXVJ1UJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689694289; 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=lkCisLVo0zGVi+Rk5cifw+t7GllgLb6G66phRPczZXQ=; b=eCZZzOAIH2S19m8WLUPY4p7o+XmUuIrRVMNdXyNjH/9R+W+8jzHUAN1Iw4fxg04T4I6btuXcc2E0X+yMGnpMiDvbUOSkV0+gzZCkY5JN9OaIVfWMJsnFGnU5a6alFldlss5g9rGHp00XWC2ED9d/uwREV0zxub6h25KNHhmipRc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1689694289561892.8046080879963; Tue, 18 Jul 2023 08:31:29 -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-220-7M5hCDJlONqCLxGDKK9pog-1; Tue, 18 Jul 2023 11:31:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC2BF104D513; Tue, 18 Jul 2023 15:28:02 +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 8B8554087C6A; Tue, 18 Jul 2023 15:28:02 +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 A959D19465B2; Tue, 18 Jul 2023 15:28:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4D4F5194658D for ; Tue, 18 Jul 2023 15:28:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3024FF66D0; Tue, 18 Jul 2023 15:28:01 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAF83F6CCA for ; Tue, 18 Jul 2023 15:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689694288; 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=lkCisLVo0zGVi+Rk5cifw+t7GllgLb6G66phRPczZXQ=; b=PvEHfO6kBqhDz/YWnQ1hNiuRWjVMXhOvDkR4+RtIK7i3NyLuZtFjW5AEzcOih6KQlzwXYs iZ+pa5D93MuQ/2EVgnOI7f8YaeGHcnTs9ZYVMg1VoZfbvpXbkm25kmhdaxmNEaNg1Y06tV jJLGfrt3lQzYU2AWdafq/AQzJNCa1OA= X-MC-Unique: 7M5hCDJlONqCLxGDKK9pog-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/5] virsh: Make cmdVersion() work with split daemon Date: Tue, 18 Jul 2023 17:27:33 +0200 Message-ID: <99d77029b66b2f4dd8af845d7c0ffe8591816e64.1689693984.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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.2 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: 1689694291415100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When virsh connects to a non-hypervisor daemon directly (e.g. "nodedev:///system") and user executes 'version' they are met with an error message. This is because cmdVersion() calls virConnectGetVersion() which fails, hence the error. The reason for virConnectGetVersion() fail is simple - it's documented as: Get the version level of the Hypervisor running. Well, there's no hypervisor in non-hypervisor daemons and thus it doesn't make sense to provide an implementation in each driver's virConnectDriver.hypervisorDriver table (just like we do for other APIs, e.g. nodeConnectIsSecure()). Given all of this, just make cmdVersion() deal with the error in a non-fatal fashion. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/virsh-host.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 0bda327cae..35e6a2eb98 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1447,21 +1447,19 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd G_GNU= C_UNUSED) vshPrint(ctl, _("Using API: %1$s %2$d.%3$d.%4$d\n"), hvType, major, minor, rel); =20 - if (virConnectGetVersion(priv->conn, &hvVersion) < 0) { - vshError(ctl, "%s", _("failed to get the hypervisor version")); - return false; - } - if (hvVersion =3D=3D 0) { - vshPrint(ctl, - _("Cannot extract running %1$s hypervisor version\n"), hv= Type); - } else { - major =3D hvVersion / 1000000; - hvVersion %=3D 1000000; - minor =3D hvVersion / 1000; - rel =3D hvVersion % 1000; + if (virConnectGetVersion(priv->conn, &hvVersion) >=3D 0) { + if (hvVersion =3D=3D 0) { + vshPrint(ctl, + _("Cannot extract running %1$s hypervisor version\n")= , hvType); + } else { + major =3D hvVersion / 1000000; + hvVersion %=3D 1000000; + minor =3D hvVersion / 1000; + rel =3D hvVersion % 1000; =20 - vshPrint(ctl, _("Running hypervisor: %1$s %2$d.%3$d.%4$d\n"), - hvType, major, minor, rel); + vshPrint(ctl, _("Running hypervisor: %1$s %2$d.%3$d.%4$d\n"), + hvType, major, minor, rel); + } } =20 if (vshCommandOptBool(cmd, "daemon")) { --=20 2.41.0