From nobody Thu May 16 19:01:02 2024 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 From nobody Thu May 16 19:01:02 2024 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=1689694677; cv=none; d=zohomail.com; s=zohoarc; b=lAtYg/BVBmX+nZztFnLuSztOdpjh8tQrCnh3NDSASMDbxH6ivGzIVIg2rlwdAXHLidpcWb7ksCvHl8x84UEr+qcDXfYDLwWjbll4sdMjR75nZmCIySG/Q6PZEs1awlbQcWdnmwVTS8eY+g/p9sgyXTV76Rke7TEik6nprbqOkEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689694677; 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=C2HmwvcTm4TpiDlbrb67cr9RpSw9/jGIewY9c17alMM=; b=e4ThhxSZKrkSju87sJifCNjrfvZsCVPAZeQ4N5uBEaSjZ1wNC0RItxujfwdDdcGMmMzvKEGup918oTLsjycvDu2M1HtZAxO94l1J4H9clxIrAZ41ox21k8BwgjS3wSMe0VRX9QJ1i71pCO2phElKAfWYCHQSoAYzmdiU46noquY= 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 168969467725051.32225025540424; Tue, 18 Jul 2023 08:37:57 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-3j0GB4QsNfiiCctjR985xA-1; Tue, 18 Jul 2023 11:37:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 796072808B4A; Tue, 18 Jul 2023 15:28: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 646B940C2071; Tue, 18 Jul 2023 15:28: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 4964719465B9; Tue, 18 Jul 2023 15:28:03 +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 A6918194658F for ; Tue, 18 Jul 2023 15:28:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 921F2F6CD2; Tue, 18 Jul 2023 15:28:02 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38DD2F6CCA for ; Tue, 18 Jul 2023 15:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689694676; 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=C2HmwvcTm4TpiDlbrb67cr9RpSw9/jGIewY9c17alMM=; b=gs6QiFO6RYX9v5D/xcR60udMmtjClBlDkFj7S1RsCq2fdFG6kkeY6iDJYv4ej2cJuEh6l2 yvlFbUqujRTM29QJNnJvPcr+zt/ilL41eTa9jNjIfZoYnE8xK9boUXpXIiGz5VYFVAWtJk y86nhMNLTb+VCEM5jov6H1dHH/ZSf5Y= X-MC-Unique: 3j0GB4QsNfiiCctjR985xA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/5] virrandom: Accept "nodedev" driver in virRandomGenerateWWN() Date: Tue, 18 Jul 2023 17:27:35 +0200 Message-ID: <182e17f18e2faa7a0dfe118b8fec7447e722703c.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.1 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: 1689694678904100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The virRandomGenerateWWN() is used solely by nodedev driver to autogenerate WWNN and WWNP when parsing a nodedev XML. Now, the idea was (at least during monolithic daemon) that depending on which hypervisor driver called the nodedev XML parsing (and virRandomGenerateWWN() under the hood) the corresponding OUI is used (e.g. "001a4a" for the QEMU driver). But in era of split daemons things are not that easy. We do not know which hypervisor driver called us. And there might be no hypervisor driver at all - users are allowed to connect to individual drivers directly (e.g. "nodedev:///system"). In this case, we can't use proper OUI. Well, do the next best thing: pick one. By a fair roll of dice the one used by the QEMU driver (QUMRANET_OUI) was chosen. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/util/virrandom.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/virrandom.c b/src/util/virrandom.c index 73c5832a05..7606dd1684 100644 --- a/src/util/virrandom.c +++ b/src/util/virrandom.c @@ -138,7 +138,13 @@ virRandomGenerateWWN(char **wwn, return -1; } =20 - if (STREQ(virt_type, "QEMU")) { + /* In case of split daemon we don't really see the hypervisor + * driver that just re-routed the nodedev driver API. There + * might not be any hypervisor driver even. Yet, we have to + * pick OUI. Pick "QEMU". */ + + if (STREQ(virt_type, "QEMU") || + STREQ(virt_type, "nodedev")) { oui =3D QUMRANET_OUI; } else if (STREQ(virt_type, "Xen") || STREQ(virt_type, "xenlight")) { --=20 2.41.0 From nobody Thu May 16 19:01:02 2024 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=1689694377; cv=none; d=zohomail.com; s=zohoarc; b=gmhmj81Rq4hpvmdIi84rOOwe0KROuaLobuN9W50EKK3JrsDEoukRZ83FyKjdDU5uGzoUOFqYBYXuXuIqBWyM5ma2DwdoA4VgM+2PzdqtnWKdwfEGJqNQpQ+9flsPkjKZ+ThjnsZyHFNQVpJm90+7WvWfhr/bSF1vxwvBfzVY2uE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689694377; 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=d+EiGOt9jY5A4PM8jsaU1xMNRYgIyfqFc8nRS5+a9NU=; b=MmWp2u/kEMIUit4lxOLIZCSvjZkiV1ETOd+UGoAAS2bVot6/VL7SV3Id0w7DMI4fe59P7ApCc/YplyQm8IGbZsVr0lOcsduda5Dc/qdCgnNJdoVyD0R8ntY72PnRtkUO1nN05rRVyoTmfGQ5ZLkYiRxfBX+UU2XR9yzy6RMnQ34= 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 1689694377478823.1972152818106; Tue, 18 Jul 2023 08:32:57 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-156-xCbMcDehMBioekN6BHm4gA-1; Tue, 18 Jul 2023 11:32:48 -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 B94CC1C280B6; Tue, 18 Jul 2023 15:28:05 +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 A3D074087C62; Tue, 18 Jul 2023 15:28:05 +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 8723E194658F; Tue, 18 Jul 2023 15:28:05 +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 434FA19465B6 for ; Tue, 18 Jul 2023 15:28:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2D3DDF66D0; Tue, 18 Jul 2023 15:28:03 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id C898CF6CCA for ; Tue, 18 Jul 2023 15:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689694376; 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=d+EiGOt9jY5A4PM8jsaU1xMNRYgIyfqFc8nRS5+a9NU=; b=QK0x7cHOPnA10gej643hFl1dNdUpaIfv1OG58c5HHCkty0HgBO9k6r0MGvVcEvjhaAEjgo FZnlLBsrcDw4gxS/vPEPF5sWa0tfAM6/LV27mW8DbfVK4QjFN35OU/j/A85ZCruu/EwSsD 2dG8V0UHn38+rQueAsgYmoIir46uQ28= X-MC-Unique: xCbMcDehMBioekN6BHm4gA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/5] virrandom: Fix printf format string in virRandomGenerateWWN() Date: Tue, 18 Jul 2023 17:27:36 +0200 Message-ID: <873612408993649951648e010c2acbd258b803fe.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: 1689694377953100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Firstly, drop needless concatenation of two static strings. Secondly, use proper (portable) formatter for uint64_t so that typecast to ULL can be dropped. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/util/virrandom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/virrandom.c b/src/util/virrandom.c index 7606dd1684..38fcfbc6ba 100644 --- a/src/util/virrandom.c +++ b/src/util/virrandom.c @@ -160,8 +160,7 @@ virRandomGenerateWWN(char **wwn, return -1; } =20 - *wwn =3D g_strdup_printf("5" "%s%09llx", oui, - (unsigned long long)virRandomBits(36)); + *wwn =3D g_strdup_printf("5%s%09" PRIx64, oui, virRandomBits(36)); return 0; } =20 --=20 2.41.0 From nobody Thu May 16 19:01:02 2024 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=1689694370; cv=none; d=zohomail.com; s=zohoarc; b=Soi8NYScQaED6eNCEkFI19UalMLojTMjXolZLsccUdWhsOOYObK0rxH8hvmlo4U6Rz34Ke99n7csFZj0B7+t7Vj9jSVu2RdcENFlHxZslnWOz8IYbJDsxH4ypdRIvgbq7yC4BfSPOku0EdotYNQd4saYyyrUsf+DbULg5gUaXnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689694370; 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=IlxvslDRtKZGx3T73fvX99Eu5vLGDs1Bm6J+sHrIGIo=; b=OGW4q3KsTXybd33seFyu96sTJBq2wWBQyUlkfnLQeciT3dULvZteQHyXW45yVFwdPpZNz7IQfjFUtsRzcaYoOi0c2iRxnxF8SY3Pvas+dhwzMGqDHnqhIzJ93Si7QH5DQcpFSR9Pwn/6yfTNkTPc+ZmD17EGC9enMKwIzIEdMSE= 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 1689694370598371.7450572775091; Tue, 18 Jul 2023 08:32:50 -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-210-rt0kmGB7PZK87wfQApXagw-1; Tue, 18 Jul 2023 11:32:46 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 19E9D18FEAB8; Tue, 18 Jul 2023 15:28:26 +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 06141492B02; Tue, 18 Jul 2023 15:28:26 +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 C4DF5194658F; Tue, 18 Jul 2023 15:28:25 +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 942C7194658D for ; Tue, 18 Jul 2023 15:28:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 68E1AF66D6; Tue, 18 Jul 2023 15:28:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FE6AF6CD6 for ; Tue, 18 Jul 2023 15:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689694369; 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=IlxvslDRtKZGx3T73fvX99Eu5vLGDs1Bm6J+sHrIGIo=; b=UxbKJeCQoE0A/zVxgwWMMgEMI8Ap7kbB/k4+/+HkRw8vFoTkzqF3M4TqapyPHVvJEEEMaB 5Xle7qCtGSANzo4GTFCPgAH/KIwjGdugVbJZbSp8SDm41+gW+ymEC6vsujv59drPu2Boh/ F14hXIeCrby3m6AAIhM/3f2QEnEaa7w= X-MC-Unique: rt0kmGB7PZK87wfQApXagw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/5] test_driver: Pass virt_type to virNodeDeviceDefParse() in testNodeDeviceCreateXML() Date: Tue, 18 Jul 2023 17:27:37 +0200 Message-ID: <25054d87fa4bf78a864fca7e5abe474d5a83d79b.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.9 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: 1689694371868100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This brings the code closer to real implementation: nodeDeviceCreateXML(). For the unique OUI, let's take the value from tests/virrandommock.c: 100000. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/test/test_driver.c | 7 +++++-- src/util/virrandom.c | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e7fce053b4..3767908d9d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -7685,11 +7685,14 @@ testNodeDeviceCreateXML(virConnectPtr conn, g_autofree char *wwnn =3D NULL; g_autofree char *wwpn =3D NULL; bool validate =3D flags & VIR_NODE_DEVICE_CREATE_XML_VALIDATE; + const char *virt_type; =20 virCheckFlags(VIR_NODE_DEVICE_CREATE_XML_VALIDATE, NULL); =20 - if (!(def =3D virNodeDeviceDefParse(xmlDesc, NULL, CREATE_DEVICE, NULL= , NULL, - NULL, validate))) + virt_type =3D virConnectGetType(conn); + + if (!(def =3D virNodeDeviceDefParse(xmlDesc, NULL, CREATE_DEVICE, virt= _type, + NULL, NULL, validate))) goto cleanup; =20 /* We run this simply for validation - it essentially validates that diff --git a/src/util/virrandom.c b/src/util/virrandom.c index 38fcfbc6ba..11f3a94611 100644 --- a/src/util/virrandom.c +++ b/src/util/virrandom.c @@ -124,6 +124,7 @@ virRandomBytes(unsigned char *buf, #define VMWARE_OUI "000569" #define MICROSOFT_OUI "0050f2" #define XEN_OUI "00163e" +#define TEST_DRIVER_OUI "100000" =20 =20 int @@ -154,6 +155,8 @@ virRandomGenerateWWN(char **wwn, oui =3D VMWARE_OUI; } else if (STREQ(virt_type, "HYPER-V")) { oui =3D MICROSOFT_OUI; + } else if (STREQ(virt_type, "TEST")) { + oui =3D TEST_DRIVER_OUI; } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unsupported virt type")); --=20 2.41.0 From nobody Thu May 16 19:01:02 2024 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=1689694304; cv=none; d=zohomail.com; s=zohoarc; b=FIzivElh47yZ2VmSXBCdyWD+zppbbPp89lwsFOPTD99ZZAxu84OOJvuTmnSnI9335E/PtlDIRjXWFw9YM7Gqx+IKLViqZ/gLqv/0BTaJzrBVaCtIFOYOG0IoQZJB+cynJbYSujuuhX+nSDr+oE3lFGy3BOL7m5EWASVm0Xme0N0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689694304; 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=6cJLgmVMIoxdGGMSNutZr9q/bMB2W5betcAJ/qQ/bc4=; b=m3+O9UfCPvgmM5YugPCD9s0zfRQ8rnz18Bk3KRFiyK2bhvunQy7FHSgRU/HxrNrIIaJ6rm+J5Zp1VGZuIGrsZ57V8iuAQU5aTbvRowKXfTVcrX4GKqQRUrZ67w5sRzj06mKSx6fGj8RgUX+xWRIR/oglOz8GpcEs53nVPUr+Wek= 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 1689694304319718.4002122961019; Tue, 18 Jul 2023 08:31:44 -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-587-BXBmdy0SNZuq4STUfdtD1w-1; Tue, 18 Jul 2023 11:31:36 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC6EB8E7148; Tue, 18 Jul 2023 15:28:27 +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 504644A9004; Tue, 18 Jul 2023 15:28:27 +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 153C5194658F; Tue, 18 Jul 2023 15:28:27 +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 32BB0194658D for ; Tue, 18 Jul 2023 15:28:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0526EF66D6; Tue, 18 Jul 2023 15:28:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id A01C0F66D0 for ; Tue, 18 Jul 2023 15:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689694303; 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=6cJLgmVMIoxdGGMSNutZr9q/bMB2W5betcAJ/qQ/bc4=; b=RedqQ9n5RwOGry7SrJ7lBa7XKfVUFD77UVzCoAR+sG3hPl9+CNCnqcGp8nxoVIUgebPjKl 6uvAmcjWqLY7s09soWHF3K9WmNLvqqR6luEzyAeaPCw0LfKpFa2f+QKDdGkSSGjmJ5dcai KcBnIaVvOADelNfmZAYTn9xaYH7QrBo= X-MC-Unique: BXBmdy0SNZuq4STUfdtD1w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/5] virrandommock: Drop virRandomGenerateWWN Date: Tue, 18 Jul 2023 17:27:38 +0200 Message-ID: <20c34051c9e4fbdf5eb13b4b06794848e7018e5a.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.10 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: 1689694305461100001 Content-Type: text/plain; charset="utf-8"; x-default="true" After previous commit, there's no functional difference between real virRandomGenerateWWN() and the mocked version. Drop the mock then. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tests/virrandommock.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/virrandommock.c b/tests/virrandommock.c index 2673230cf7..17c55f4c60 100644 --- a/tests/virrandommock.c +++ b/tests/virrandommock.c @@ -47,14 +47,6 @@ uint64_t virRandomBits(int nbits) return ret; } =20 -int virRandomGenerateWWN(char **wwn, - const char *virt_type G_GNUC_UNUSED) -{ - *wwn =3D g_strdup_printf("5100000%09llx", - (unsigned long long)virRandomBits(36)); - return 0; -} - #else /* WIN32 */ /* Can't mock on WIN32 */ #endif --=20 2.41.0