From nobody Wed Nov 27 02:26:26 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=1558555952; cv=none; d=zoho.com; s=zohoarc; b=kNVsnY0Qcyyhidz0fVfWvYRU6jUYfP93gJcyEE5q15C/M4X37otRQagGO7ZZHEWHpcs7v4W8Jp0lhRzpm90/OeRGqInxkYqFXflPXvi7gOFq+wO++gnfUxXOsZS1auymZYqKWjyO3kFARl1iyhRumtCQaFenzQ70TxbSshpDnwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558555952; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=wjSvqK3IiHaejFSwie7lCQ2GlcJ3O84dN2QuVJffn5c=; b=mQpaXDzDKGiGRPOKDtZKSzyQUjvAE6fWmGtGyYR41I7hkFfG5pMV88bpB057/wtmDu2u+2NSGRM+3HFdMG72kmqDcb8lZVTCwmOe1tSqZT+s7yaHiAPLsL2RsNdKt0wULsyqB0Wan+DnxXrlN+N8jEIes0dxBPusPu5WFdwoaNA= 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 1558555951999178.13085600502166; Wed, 22 May 2019 13:12:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 23529C04AC69; Wed, 22 May 2019 20:12:17 +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 E9F6660572; Wed, 22 May 2019 20:12:09 +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 3A3D85B423; Wed, 22 May 2019 20:11:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4MKBhv7013204 for ; Wed, 22 May 2019 16:11:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id D72C160589; Wed, 22 May 2019 20:11:43 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F31CE60572; Wed, 22 May 2019 20:11:40 +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 DED9385360; Wed, 22 May 2019 20:11:31 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id b8so5537199edm.11; Wed, 22 May 2019 13:11:31 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id r2sm4057471ejp.76.2019.05.22.13.11.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 13:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=GDnQHBJtKuyq1+EXcRgC2m8YlvjQhyQomOL1nIrYJow=; b=rEmZIJFggXDlo2Xjkk7bj+MLuzQttN9ouDmtw8qtQME4GexLgrFgP72hlFNQu6iFRz dyNudo8m83mouNRZVK7aMwX/Pil1yJReJlFIxidPmYSYNBrI3WcER8O78wRPfL4Ae5q2 EF7MlwLcvwYbFKyca14dgOdRf/O33ht16eDmOaCNw+0oUmfBg7ElBMf4DIuvi0lD4ZJu lwd/sgNYdYzbtKjo6mcLngYtqwPruUZCDADhvrgXqyzvmLwgOjFSz6wFU6sKwAvxlKt6 JdI0tJ8FNb8dU5VVnL/X53BCKPlrnSwHOXPIqn21F8CRYfm/A5uDs5KjPT9QZjqtda5H CpRA== 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:mime-version :content-transfer-encoding; bh=GDnQHBJtKuyq1+EXcRgC2m8YlvjQhyQomOL1nIrYJow=; b=Y0IByvbYr09RS8o6FKHrmDXa93WL7zyvSiaLPDUEgidGuRn60DNxFv9f4sIub6Nvvz LOfdpNLpOUkZJolwptQaKwRc5Ye8vqHwBXcQSRlifxgdF0rvgkuwZSSnLo1hf0Yz1sPI I7qCMMLwjy10RF4ka1DmCRIGpGobHm+vOCy2DU2yWrUMxjTbGwFQsktadfkqNXU6e4yD 69EPhi96Jyh96RwiI4KgxnobP7kjSgmeSBRIdqD5MI6694uF6Cgr/gpZGws+X/5PZqj4 rLl5l4N12M/QbczDiefBELF8WGA19gABbyTQ5Y2JwZeKWD6uTDPBqaVeuZ7rlP4g/EB5 gnzw== X-Gm-Message-State: APjAAAWpRoWeqd7lpiMKKkjjayFpGADNf843OJ5DUqYuMPUxwXfpS9C4 toAq6odDYl6RQQggohhzCEGkFZZo X-Google-Smtp-Source: APXvYqzobkwSnORULLp8Of8vi+qCu2JE+/nJ7sI2HXSNDmEDOmCxT6nZwihbcvBU5wHbdeMgIyl7+Q== X-Received: by 2002:a17:906:1315:: with SMTP id w21mr36246349ejb.193.1558555888912; Wed, 22 May 2019 13:11:28 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 22 May 2019 22:10:34 +0200 Message-Id: <20190522201034.7292-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.25]); Wed, 22 May 2019 20:11:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 22 May 2019 20:11:32 +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.109 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] test_driver: implement virDomainInterfaceAddresses 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 22 May 2019 20:12:30 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Ignore @source in the case of the test driver and return fixed private IPv4 addresses for all the interfaces defined in the domain. Signed-off-by: Ilias Stamatis --- The default config of the test driver has no guest interfaces defined, so this must be tested with a custom config. Maybe it would be a good idea to add one or more guest interfaces in the default config. I could send an additional patch for this. src/test/test_driver.c | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index a4c17ef0df..3a81f51a88 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3220,6 +3220,76 @@ static int testDomainBlockStats(virDomainPtr domain, return ret; } +static int +testDomainInterfaceAddresses(virDomainPtr dom, + virDomainInterfacePtr **ifaces, + unsigned int source ATTRIBUTE_UNUSED, + unsigned int flags) +{ + size_t i; + size_t ifaces_count =3D 0; + int ret =3D -1; + char ipaddr[32]; + char macaddr[VIR_MAC_STRING_BUFLEN]; + virDomainObjPtr vm =3D NULL; + virDomainInterfacePtr iface =3D NULL; + virDomainInterfacePtr *ifaces_ret =3D NULL; + + virCheckFlags(0, -1); + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + 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 (VIR_ALLOC(iface) < 0) + goto cleanup; + + if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0) + goto cleanup; + + virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr); + if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) + goto cleanup; + + if (VIR_ALLOC(iface->addrs) < 0) + goto cleanup; + + iface->addrs[0].type =3D VIR_IP_ADDR_TYPE_IPV4; + iface->addrs[0].prefix =3D 24; + + sprintf(ipaddr, "192.168.0.%ld", 100 + (i % 155)); + if (VIR_STRDUP(iface->addrs[0].addr, ipaddr) < 0) + goto cleanup; + + iface->naddrs =3D 1; + + VIR_STEAL_PTR(ifaces_ret[i], iface); + ifaces_count++; + } + + VIR_STEAL_PTR(*ifaces, ifaces_ret); + ret =3D ifaces_count; + + cleanup: + virDomainObjEndAPI(&vm); + + if (ifaces_ret) { + for (i =3D 0; i < ifaces_count; i++) + virDomainInterfaceFree(ifaces_ret[i]); + } + virDomainInterfaceFree(iface); + + VIR_FREE(ifaces_ret); + + return ret; +} + static int testDomainInterfaceStats(virDomainPtr domain, const char *device, @@ -6876,6 +6946,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainSetSchedulerParameters =3D testDomainSetSchedulerParameters, /*= 0.3.2 */ .domainSetSchedulerParametersFlags =3D testDomainSetSchedulerParameter= sFlags, /* 0.9.2 */ .domainBlockStats =3D testDomainBlockStats, /* 0.7.0 */ + .domainInterfaceAddresses =3D testDomainInterfaceAddresses, /* 5.4.0 */ .domainInterfaceStats =3D testDomainInterfaceStats, /* 0.7.0 */ .nodeGetCellsFreeMemory =3D testNodeGetCellsFreeMemory, /* 0.4.2 */ .connectDomainEventRegister =3D testConnectDomainEventRegister, /* 0.6= .0 */ -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list