From nobody Thu May 2 13:39:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1560943184; cv=none; d=zoho.com; s=zohoarc; b=m+p3ZUoOW3qQFfR/cwFYbIMt2pZIUEUQHwPOoNSrjMtjlNgULIEdiVitaO2XM00D4b/uY+V1L3rCCSOSUtqT14Q7XhZEQo/zb6z7zSGio7RGZ9FcxukSaSmebIbuSdzk1v8iBiOP7kMIxUCfUHkIKpafjbVxR3WU0lxmDjez+7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560943184; 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:ARC-Authentication-Results; bh=Pi0KkGD6g4caMKvPGsZTLkfiyJopVUWsQYkRBLo7EA8=; b=GfJX0dYDkdB/Wpcruv0W3eFiRhV80vqASiZa5oKC7psk/7VbXMuEgZJYTU7Ju41omDhWDPqZIw/icMJHih0jWBbBjefyjl2preFQ2FOpg6otbDUHI0CthyehLof+StbF2iE1uwk3VhY+mG0Vh8AQ5DocZKZxW/e0+9CRtOaDAVI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560943184091303.0168300478837; Wed, 19 Jun 2019 04:19:44 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D9F51C04BD4A; Wed, 19 Jun 2019 11:19:25 +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 275CB5D71C; Wed, 19 Jun 2019 11:19:21 +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 8068C19725; Wed, 19 Jun 2019 11:19:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5JBJD2B012239 for ; Wed, 19 Jun 2019 07:19:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3922E61090; Wed, 19 Jun 2019 11:19:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 348A760FAB for ; Wed, 19 Jun 2019 11:19:10 +0000 (UTC) Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2FEC223879 for ; Wed, 19 Jun 2019 11:19:00 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id p26so26678505edr.2 for ; Wed, 19 Jun 2019 04:19:00 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id y21sm3183020ejm.60.2019.06.19.04.18.58 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 04:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=WDXzZ9qi/UwUGEdvCexRjW6YKxOXVAMr06FQNRIeKr0=; b=KoqCT82EgXVdBYOxPA38LapMc2HavEl9C4s3a3wSnZhxEuybry/G1xNK013bgTtoli UfgtabCc+6M6oEV8Utin1CLz47QWflBTujIJlCjIb/jRqRmS7Qubm2qZjfg3W3FHjNhQ GMR/Np6XQnNWCB2ZMy5zDdPGDXQk3Huvu+ipoGM6k+bYhitU77v+tVpIW54MsJ533Xip CJPbsw515HAngL4q5OIVUw8Kh83tZGJEQlLk8h1uDVEflU6BmvGEMxGEdLcu/UQ2epUh 7l8XodPteJeRvToc6xnxUC/adjg+/p92msIyYitITMCA0rueiM71ftBEQnUiSdAQ+p+n MdOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WDXzZ9qi/UwUGEdvCexRjW6YKxOXVAMr06FQNRIeKr0=; b=j6b/iDo5mmkjFPeLs5D/nqxr7t8zEt9Bzqcr6fCSedlG+kKto0FfV2KAQ1bDwGKkdZ Sk8HhjWh2yxrJ5CYf/3wUbV6amYQa8wjoBv3NZU1paqA0FTLKDZj+kM/RAuYDbdLHtVn KmkjWYMvrjMY9adu0kgYHPzG0NdJ8HgdtwXTeSNCFwoq3L+MXJJNgYLCTgLo30vhiD/A JDA5IiqSdaXv5sDU44YYQIEU2aLn7k/xnbUI6yQPM4Wi2qUzUbAUzzPi6LL+LFE+3R8B 3FnUdfNnBB+m/+EXMJWFf+2jEG2rGR5jL6/lsa+uFbcJx7QbSGHngrM5n4FBdE1oP6/i abuw== X-Gm-Message-State: APjAAAXF0x21ag7/GYQmDz8AcYQ9rLBTNmZzFa05h7sGTw8wGPJCKq7g 9GID+T+shifiQr6OkC64Scy7q/ZBV/VKOA== X-Google-Smtp-Source: APXvYqwkA7i+bCguWvCIxjV0cPUuc3Xtn1NMmuKyk/UGv86si7iZNxM3NLj/3Pwd0+theqinYGmXZQ== X-Received: by 2002:a50:97ac:: with SMTP id e41mr75138782edb.27.1560943139140; Wed, 19 Jun 2019 04:18:59 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 19 Jun 2019 13:18:15 +0200 Message-Id: <20190619111817.19562-2-stamatis.iliass@gmail.com> In-Reply-To: <20190619111817.19562-1-stamatis.iliass@gmail.com> References: <20190619111817.19562-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 19 Jun 2019 11:19:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 19 Jun 2019 11:19:00 +0000 (UTC) for IP:'209.85.208.65' DOMAIN:'mail-ed1-f65.google.com' HELO:'mail-ed1-f65.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.1 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.208.65 mail-ed1-f65.google.com 209.85.208.65 mail-ed1-f65.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] test_driver: validate @source in testDomainInterfaceAddresses 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 19 Jun 2019 11:19:42 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis --- src/test/test_driver.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 8ef843b203..437df9cdf9 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3383,7 +3383,7 @@ static int testDomainBlockStats(virDomainPtr domain, static int testDomainInterfaceAddresses(virDomainPtr dom, virDomainInterfacePtr **ifaces, - unsigned int source ATTRIBUTE_UNUSED, + unsigned int source, unsigned int flags) { size_t i; @@ -3396,6 +3396,13 @@ testDomainInterfaceAddresses(virDomainPtr dom, virCheckFlags(0, -1); + if (source >=3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _("Unknown IP address data source %d"), + source); + return -1; + } + if (!(vm =3D testDomObjFromDomain(dom))) goto cleanup; -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 13:39:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1560943211; cv=none; d=zoho.com; s=zohoarc; b=kQcbSf6bdFXQQEtVOOjgfo8Ik8mJe3MlsojFts7T9e8KpHlG4+cq4Rl1BjaLLmZkRTc5sk5DxVIuIzDaTvTszImCZppOhGhJMkrOFCJEeGEZ9I/AJi9dscNnYRJAUWhH9qY5vcb9nkqRvHZ9cLvLUiHazGfA00F+jQtborSaxj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560943211; 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:ARC-Authentication-Results; bh=Fe85qowUptBQhn2PiKZf52tqzp9sFaC7roq6KcdOrqQ=; b=nCYjJUbPDdXV99vtLOGl4DcT4FdPHf6q3L9xkz1CbKPuG4LjaEWopphLgcaacfiJzEuInAuCOUk/gm60xr1Waj2jga2+9YF7CGm7gBfbLBkHVRfFJbzlYpDZJ1hKXK7xg5huM8Uv3lr+Ek+w99D6HNA9ZUzp1g1SCXg8oK2BY0U= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560943211382807.1549807190731; Wed, 19 Jun 2019 04:20:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 34A9B30860B3; Wed, 19 Jun 2019 11:19:58 +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 0F70810190A7; Wed, 19 Jun 2019 11:19:55 +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 C6A9219726; Wed, 19 Jun 2019 11:19:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5JBJZwr012267 for ; Wed, 19 Jun 2019 07:19:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4F7CB5D71D; Wed, 19 Jun 2019 11:19:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AEF85D71B for ; Wed, 19 Jun 2019 11:19:33 +0000 (UTC) Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE71036883 for ; Wed, 19 Jun 2019 11:19:21 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id m10so26658075edv.6 for ; Wed, 19 Jun 2019 04:19:21 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id y21sm3183020ejm.60.2019.06.19.04.19.19 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 04:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lbT/QvIitcQQBm0TYJwTHYw4cluwmAy77FIU8cuIWg0=; b=NCjNRoPvlTbUY4pPrMD9pQJt3Yg9sACiZQ4XxpCfD8jOIRNlWvvqSJZTUXvMLm9XZF gRaH5SdNvKlbmghF/1/J15xNqSg2qLvgp4PqNwxnwxnM/U2PFmOU/hSO3E785CGEBR9d qwgLjCqKYoAJJikiUtYWlxYNBKTcSYz62J2iqJaFmru1griTdEEL2GhFRvafKAeM4iHX SDXluWLCCiA6hSOgpicyBKg9d5E7oAwW/E+W1jHSQvmIYVq+VmSqv6J35jT18JHG1vXV kHhmqrWbJ4GoF3w8RTcwgaOAahI/yReZeQn0tydCc9korOVOR8SHSjF88x2AgqdHjJQn pgXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lbT/QvIitcQQBm0TYJwTHYw4cluwmAy77FIU8cuIWg0=; b=LajsVaQfB7bbw1pv33ucVZuG/AZklEgg/mV1ROQY0tl7SGODp3lw5Ymxs3NYcQuEor MbLf86dGXYNKC0drpAMAnr1v4m6pdJIeGPKhYsTD/xhmXpgO9USve5i1JCr6mm3hfjsW vI8yaQVNVpfacVAO9yjMyM618mBIUBA0DF4WGpYT2OPZfoqmijOE7FLAREx/G9lTTDvS 2CA0LmROk3ZmapeV4dMUc3ALyhHElwfbq9fGWIhKAtEfwsRXlp241TscB6HR+whB/BxB yK1aYc5MROFwCb1xCgyxCil+fBztIVBlhUb+9DHQcWQVxCXYDitcZVKt7GUE9ugPY/x1 9Gdw== X-Gm-Message-State: APjAAAWVag+f0AZJJEialQn2cjkvu+8Rg/3ZnOoDd4jcYZkRGnljkoRQ 6+9bKH4WQ6FLsc08FR6k+pH4FgpCy7q/ag== X-Google-Smtp-Source: APXvYqz26VH1PmH1gNAmkWV3ZW1KPq4lv92oTR1gWxOhbNwVdS8FXUo9kTtN4ig7s7Ijm+bZqwaZBQ== X-Received: by 2002:a17:906:d052:: with SMTP id bo18mr24622755ejb.311.1560943160193; Wed, 19 Jun 2019 04:19:20 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 19 Jun 2019 13:18:16 +0200 Message-Id: <20190619111817.19562-3-stamatis.iliass@gmail.com> In-Reply-To: <20190619111817.19562-1-stamatis.iliass@gmail.com> References: <20190619111817.19562-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 19 Jun 2019 11:19:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 19 Jun 2019 11:19:21 +0000 (UTC) for IP:'209.85.208.66' DOMAIN:'mail-ed1-f66.google.com' HELO:'mail-ed1-f66.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.1 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS) 209.85.208.66 mail-ed1-f66.google.com 209.85.208.66 mail-ed1-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] test_driver: return addresses only for nets of type network 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 19 Jun 2019 11:20:02 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis --- src/test/test_driver.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 437df9cdf9..0c2cfdd2f7 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3409,10 +3409,10 @@ testDomainInterfaceAddresses(virDomainPtr dom, if (virDomainObjCheckActive(vm) < 0) goto cleanup; - if (VIR_ALLOC_N(ifaces_ret, vm->def->nnets) < 0) - goto cleanup; - for (i =3D 0; i < vm->def->nnets; i++) { + if (vm->def->nets[i]->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) + continue; + if (VIR_ALLOC(iface) < 0) goto cleanup; @@ -3433,7 +3433,8 @@ testDomainInterfaceAddresses(virDomainPtr dom, iface->naddrs =3D 1; - VIR_APPEND_ELEMENT_INPLACE(ifaces_ret, ifaces_count, iface); + if (VIR_APPEND_ELEMENT(ifaces_ret, ifaces_count, iface) < 0) + goto cleanup; } VIR_STEAL_PTR(*ifaces, ifaces_ret); -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 13:39:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1560943214; cv=none; d=zoho.com; s=zohoarc; b=dlOC5PXhICu/POfeCU4ILmkJV7MpNdHXWsRI2WWWbi/zU07ZOqg811e0eFAaW1vnBQBGUhcy3SrC3/BVmBUDQakUCjo9qx5uJVxMA0GE/S53wjZ7znwj7PV05mq27QtMwVTEEO7OOU17JHfK7cOdDJZJ9z7K//i2a+/cdK44I28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560943214; 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:ARC-Authentication-Results; bh=h25RYCpSw9e61tJAUOrZTnV6FquH3zyNdX9c3KfwVp0=; b=STfICdzXnEhQHY83ksfbyCW8otii1G/Ms0KlgiDA/FnavfiXooj4kJZReYuJZ547N0vu3P1s0PMRv3AsC6lN8BX2TInEj41051gAGyVuVhr4g7YeVKlXIgBrZngODu1fO4YOdhaU3o8iZ4TH79HNOxufvEhVMdDKYUQIHEalP9k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1560943214946936.7193307337976; Wed, 19 Jun 2019 04:20:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0859A368B1; Wed, 19 Jun 2019 11:20:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC3B919C6F; Wed, 19 Jun 2019 11:20:01 +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 76F201806B1A; Wed, 19 Jun 2019 11:19:59 +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 x5JBJpn1012291 for ; Wed, 19 Jun 2019 07:19:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6588C19C6F; Wed, 19 Jun 2019 11:19:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E76319C6A for ; Wed, 19 Jun 2019 11:19:49 +0000 (UTC) Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E167308A9E2 for ; Wed, 19 Jun 2019 11:19:44 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id p15so26622111eds.8 for ; Wed, 19 Jun 2019 04:19:44 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id y21sm3183020ejm.60.2019.06.19.04.19.41 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 04:19:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kXn/bMH0eblccv4qGoZnLzhDXO2lfKSdXva1QcHjM38=; b=Ewag1GWNovCryvew2/7hfeWlHxLbEokxOdMRJKkkM3ZdiTpADXyjdnNrq3YrPayy0I uchjK2XwvdF3S6QZ1+r07q5/Iw4pA6fJT/8PFzaly9gph2LtEq+rfeSp11vKin/2rXph nL+SZ+OVS/GBRiSl3L3nkwfxKGnEURHjRer2sBMa8zdW5svKZltbiBbHfg4CQVEB87bE lHa9VE2lLeBWKrcJC6qjjemnbbF7w/tWUOzWmV7pVXA4jULb8gkOvMjlS0qzYA1XJwsT mLdPJS+aug/yquy8LOdA1dr3UqPVPr5bkZXNhhlvR3Nwv2wnK7luaif3ZCJGRuw5dXwn uMNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kXn/bMH0eblccv4qGoZnLzhDXO2lfKSdXva1QcHjM38=; b=sw3MGlOkHXt5pyMtoWKzEaOHj3MEC42rs0Px6P9RYseA6GfME76FWN9yQYI19/I2Ez vnQKR5YpY0lpRwNUP4yY5RoOWFlRSsoWOvlrvkv7qIomAX0NMLYIIyhhURFT28+keJAi 1h++BIANn3KnEcDqY2GmOYr14Ii8r5i4TrNjYcw4nxw4iNLaWdlFu2WCFGe9wMpZQHZ8 DzSHbFm0JlnCdopvgPRhEM7X4LRCUfif8cGSVqCNzmExGfFVCaERDubmTCblI9PWlzWQ 1GoG3tPQPKVWQi7ZAPHSyOv0LK4bh2B0YmXuxegYG9ORvO41gM2Gcgr8PDPAHOPkOJkN W2nw== X-Gm-Message-State: APjAAAW9Emfjr/x92nrpglRYVdk8rnRxp+hzeT53LObKszIQ2wiVDjy1 TMMO3z8AmybbytXCUtOiJKa0SNibMQh2Kg== X-Google-Smtp-Source: APXvYqwe887qRgrYcZFRRY+2EJTTCnyXsoh09zTalFpoiwbtARgm6oVu8QbWYYSDPfy5y18MJtO0Vw== X-Received: by 2002:a50:eb96:: with SMTP id y22mr17784937edr.211.1560943182591; Wed, 19 Jun 2019 04:19:42 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 19 Jun 2019 13:18:17 +0200 Message-Id: <20190619111817.19562-4-stamatis.iliass@gmail.com> In-Reply-To: <20190619111817.19562-1-stamatis.iliass@gmail.com> References: <20190619111817.19562-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 19 Jun 2019 11:19:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 19 Jun 2019 11:19:44 +0000 (UTC) for IP:'209.85.208.65' DOMAIN:'mail-ed1-f65.google.com' HELO:'mail-ed1-f65.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.208.65 mail-ed1-f65.google.com 209.85.208.65 mail-ed1-f65.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] test_driver: consider DHCP ranges in testDomainInterfaceAddresses 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 19 Jun 2019 11:20:05 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" testDomainInterfaceAddresses always returns the same hard-coded addresses. Change the behavior such as if there is a DHCP range defined, addresses are returned from that pool. The specific address returned depends on both the domain id and the specific guest interface in an attempt to return unique addresses *most of the time*. Additionally, return IPv6 addresses too when needed. Signed-off-by: Ilias Stamatis --- src/test/test_driver.c | 78 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 0c2cfdd2f7..96142b549c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "virerror.h" @@ -3380,6 +3381,11 @@ static int testDomainBlockStats(virDomainPtr domain, return ret; } + +static virNetworkObjPtr testNetworkObjFindByName(testDriverPtr privconn, c= onst char *name); +static virNetworkPtr testNetworkLookupByName(virConnectPtr conn, const cha= r *name); + + static int testDomainInterfaceAddresses(virDomainPtr dom, virDomainInterfacePtr **ifaces, @@ -3388,11 +3394,18 @@ testDomainInterfaceAddresses(virDomainPtr dom, { size_t i; size_t ifaces_count =3D 0; + size_t addr_offset; int ret =3D -1; char macaddr[VIR_MAC_STRING_BUFLEN]; + char ip_str[INET6_ADDRSTRLEN]; + struct sockaddr_in ipv4_addr; + struct sockaddr_in6 ipv6_addr; virDomainObjPtr vm =3D NULL; virDomainInterfacePtr iface =3D NULL; virDomainInterfacePtr *ifaces_ret =3D NULL; + virNetworkPtr net =3D NULL; + virNetworkObjPtr net_obj =3D NULL; + virNetworkDefPtr net_obj_def =3D NULL; virCheckFlags(0, -1); @@ -3413,6 +3426,16 @@ testDomainInterfaceAddresses(virDomainPtr dom, if (vm->def->nets[i]->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) continue; + virObjectUnref(net); + if (!(net =3D testNetworkLookupByName(dom->conn, + vm->def->nets[i]->data.network= .name))) + goto cleanup; + + if (!(net_obj =3D testNetworkObjFindByName(net->conn->privateData,= net->name))) + goto cleanup; + + net_obj_def =3D virNetworkObjGetDef(net_obj); + if (VIR_ALLOC(iface) < 0) goto cleanup; @@ -3426,15 +3449,58 @@ testDomainInterfaceAddresses(virDomainPtr dom, if (VIR_ALLOC(iface->addrs) < 0) goto cleanup; - iface->addrs[0].type =3D VIR_IP_ADDR_TYPE_IPV4; - iface->addrs[0].prefix =3D 24; - if (virAsprintf(&iface->addrs[0].addr, "192.168.0.%zu", 1 + i) < 0) - goto cleanup; - iface->naddrs =3D 1; + if (net_obj_def->ips->family && STREQ(net_obj_def->ips->family, "i= pv6")) + iface->addrs[0].type =3D VIR_IP_ADDR_TYPE_IPV6; + else + iface->addrs[0].type =3D VIR_IP_ADDR_TYPE_IPV4; + + /* try using different addresses per different inf and domain */ + addr_offset =3D 20 * (vm->def->id - 1) + i; + + if (net_obj_def->ips->nranges > 0) { + /* use ip addresses from the defined DHCP range */ + + if (iface->addrs[0].type =3D=3D VIR_IP_ADDR_TYPE_IPV6) { + ipv6_addr =3D net_obj_def->ips->ranges[0].start.data.inet6; + ipv6_addr.sin6_addr.s6_addr[15] +=3D addr_offset; + inet_ntop(AF_INET6, &(ipv6_addr.sin6_addr), ip_str, INET6_= ADDRSTRLEN); + } else { + ipv4_addr =3D net_obj_def->ips->ranges[0].start.data.inet4; + ipv4_addr.sin_addr.s_addr =3D htonl(ntohl(ipv4_addr.sin_ad= dr.s_addr) + + addr_offset); + inet_ntop(AF_INET, &(ipv4_addr.sin_addr), ip_str, INET_ADD= RSTRLEN); + } + + if (VIR_STRDUP(iface->addrs[0].addr, ip_str) < 0) + goto cleanup; + + iface->addrs[0].prefix =3D virSocketAddrGetIPPrefix( + &net_obj_def->ips->ranges[0].star= t, + &net_obj_def->ips->netmask, + net_obj_def->ips->prefix); + + } else { + /* use hard-coded addresses when a DHCP range isn't defined */ + + if (iface->addrs[0].type =3D=3D VIR_IP_ADDR_TYPE_IPV6) { + iface->addrs[0].prefix =3D 64; + if (virAsprintf(&iface->addrs[0].addr, "fc00::%zu", + 1 + addr_offset) < 0) + goto cleanup; + } else { + iface->addrs[0].prefix =3D 24; + if (virAsprintf(&iface->addrs[0].addr, "192.168.0.%zu", + 1 + addr_offset) < 0) + goto cleanup; + } + } + if (VIR_APPEND_ELEMENT(ifaces_ret, ifaces_count, iface) < 0) goto cleanup; + + virNetworkObjEndAPI(&net_obj); } VIR_STEAL_PTR(*ifaces, ifaces_ret); @@ -3442,6 +3508,8 @@ testDomainInterfaceAddresses(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); + virNetworkObjEndAPI(&net_obj); + virObjectUnref(net); if (ifaces_ret) { for (i =3D 0; i < ifaces_count; i++) -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list