From nobody Thu May 2 06:58:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1571759287; cv=none; d=zoho.com; s=zohoarc; b=AuhBQCeko8U36Ctoa7hmVwDpE5kIU8jUV6upnK2TYUHSfNCJzqYL5QEkgAEll5j2emYGM0KdzPO47XHFxIotpWaXv8fNyi++T7hSBuZMmq6x35PAkJK33uq//wG9lU2Y9NnXLDMzu1pLwaCZ/5rFsdIdcKRe1OvDHQlCg5fSkaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571759287; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=nVACqF6SoM8JZjkYZQT+EC9Jb1tX4JyQn+wHxLZoiQo=; b=VGUIv0Fr/no50YX9gVVQHSx6bhhThaGjm2P12MEinM72FljA1L9/zQ1Noe3OsmTBkbCcS7Vrk5XAoTDBCUQHLdTfV1diSBHHK64MTuwW0VjL6pvIsVDk+j4Z/YOc/9HzaSA5qYhgXqkNcEY3Kx+mMCMuNFgGAvFGKoKKod/DjBU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1571759287019332.19666921549515; Tue, 22 Oct 2019 08:48:07 -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-150-sg3-xGsLP069Vi0ZtwUenw-1; Tue, 22 Oct 2019 11:48:00 -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 D4A13107AFA6; Tue, 22 Oct 2019 15:47:54 +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 446185D6B0; Tue, 22 Oct 2019 15:47:54 +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 E34E44E58A; Tue, 22 Oct 2019 15:47:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9MFlowo010709 for ; Tue, 22 Oct 2019 11:47:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id C257A5DC1E; Tue, 22 Oct 2019 15:47:50 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-117-120.ams2.redhat.com [10.36.117.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5A605DC18; Tue, 22 Oct 2019 15:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571759285; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nVACqF6SoM8JZjkYZQT+EC9Jb1tX4JyQn+wHxLZoiQo=; b=MI8I0Ci3+ZUwBzNk0mJr87IUMfrZxLvd1H40aw27hyV4R13Ipswvh/ewWqeYd//HA3q5/a cX/Hgf/nfXo4oV9qreCexvRUEZo2SEw+4haIKfEMJEyfgqm3Ma+QclCKervMxkPUdpr77y ZCw5sFPmmfhSdLKbnoo7ghzyajAvD7A= From: Stefano Garzarella To: libvir-list@redhat.com Date: Tue, 22 Oct 2019 17:47:46 +0200 Message-Id: <20191022154746.179514-1-sgarzare@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Charlie Smurthwaite Subject: [libvirt] [ruby PATCH] Fix default values for node_cpu_stats() and node_memory_stats() 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 X-MC-Unique: sg3-xGsLP069Vi0ZtwUenw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" ruby_libvirt_value_to_int() returns 0 if the optional value is not defined, but in node_cpu_stats() and node_memory_stats() the default value of cpuNum and cellNum is -1. Reported-by: Charlie Smurthwaite Signed-off-by: Stefano Garzarella Reviewed-by: Cole Robinson --- ext/libvirt/connect.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ext/libvirt/connect.c b/ext/libvirt/connect.c index 5932535..b2d041b 100644 --- a/ext/libvirt/connect.c +++ b/ext/libvirt/connect.c @@ -2079,7 +2079,12 @@ static VALUE libvirt_connect_node_cpu_stats(int argc= , VALUE *argv, VALUE c) =20 rb_scan_args(argc, argv, "02", &intparam, &flags); =20 - tmp =3D ruby_libvirt_value_to_int(intparam); + if (NIL_P(intparam)) { + tmp =3D -1; + } + else { + tmp =3D ruby_libvirt_value_to_int(intparam); + } =20 return ruby_libvirt_get_parameters(c, ruby_libvirt_value_to_uint(flags= ), (void *)&tmp, sizeof(virNodeCPUStat= s), @@ -2139,7 +2144,12 @@ static VALUE libvirt_connect_node_memory_stats(int a= rgc, VALUE *argv, VALUE c) =20 rb_scan_args(argc, argv, "02", &intparam, &flags); =20 - tmp =3D ruby_libvirt_value_to_int(intparam); + if (NIL_P(intparam)) { + tmp =3D -1; + } + else { + tmp =3D ruby_libvirt_value_to_int(intparam); + } =20 return ruby_libvirt_get_parameters(c, ruby_libvirt_value_to_uint(flags= ), (void *)&tmp, sizeof(virNodeMemoryS= tats), --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list