From nobody Thu Apr 25 04:03:06 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com 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 1631607331530261.5360543552757; Tue, 14 Sep 2021 01:15:31 -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-482-PqM0ErlXPqGH2auzrxRDXw-1; Tue, 14 Sep 2021 04:15:28 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E80CB802C88; Tue, 14 Sep 2021 08:15:23 +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 25B0E10016FE; Tue, 14 Sep 2021 08:15:23 +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 59C4F1805986; Tue, 14 Sep 2021 08:15:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18E7vaWL010052 for ; Tue, 14 Sep 2021 03:57:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 75CB48579A; Tue, 14 Sep 2021 07:57:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FA3584457 for ; Tue, 14 Sep 2021 07:57:32 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77AC68934E6 for ; Tue, 14 Sep 2021 07:57:32 +0000 (UTC) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-3ol2oyJOMNugHSdKE8_q_A-1; Tue, 14 Sep 2021 03:57:29 -0400 Received: by mail-pj1-f45.google.com with SMTP id dw14so7367805pjb.1 for ; Tue, 14 Sep 2021 00:57:28 -0700 (PDT) Received: from fedora.zelin.local (61-221-155-12.hinet-ip.hinet.net. [61.221.155.12]) by smtp.gmail.com with ESMTPSA id p9sm11390650pgn.36.2021.09.14.00.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 00:57:27 -0700 (PDT) X-MC-Unique: PqM0ErlXPqGH2auzrxRDXw-1 X-MC-Unique: 3ol2oyJOMNugHSdKE8_q_A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+k1YsB8jjtI4RiJ0Uc9G6bMvloX0Jks3IjPZEJ2/JO4=; b=CZOgpZg5Vd9sOvDDWQSukxotKcvEgUeCbW5Z8iLU4k8uVWV1RH1L/0/7V+PsqTtIwm tBup6GhL2PbOEA96W8NJM9XFGS2RWSrp6xqAdsvsOZhvW0FGmsCqqSq5msCymfZsjXIu EbZHayhr1Kqd3RUH3UThwYvaOqoSFdCiSX0ypqCTgV9oTVbaJ9Adny9QsyAfyhu6QvOe RAWbS9A00L/2XCcEqzj0U0FzTSYyri+cV6wF9qjMZnsnSKyv5mhgomMdqZfe+cOvBosE f2HRxHlUM4x1MQjNrkWyHsxhAgEj6y67AmO+QSLW/WNhw6DlqBD6IEujFMpZtryR6ow7 fdTA== X-Gm-Message-State: AOAM533+ZQ4HlAfXRyYOKv0/Ww2dCyN8Ek7nhwtETsr+fI9ZcxsH6BtV Qu0JPGnXhNl+RG6vFm/b+MKTQfxFvu8JEwqHQr8= X-Google-Smtp-Source: ABdhPJwiR57Vbs40jh51yb9rSsXtBrkQ4e9KTLIt6yw3hPmtKw7N6xRKacZRKFy7rFPdncO/gnFeRw== X-Received: by 2002:a17:902:e88d:b0:13b:8ed2:9f42 with SMTP id w13-20020a170902e88d00b0013b8ed29f42mr9489559plg.67.1631606248087; Tue, 14 Sep 2021 00:57:28 -0700 (PDT) From: zhanglei To: zhanglei@smartx.com, libvir-list@redhat.com Subject: [libvirt PATCH v2 1/4] domain: add interface information to 'virDomainGetGuestInfo' Date: Tue, 14 Sep 2021 15:56:42 +0800 Message-Id: <20210914075645.166703-2-zhanglei@smartx.com> In-Reply-To: <20210914075645.166703-1-zhanglei@smartx.com> References: <20210914075645.166703-1-zhanglei@smartx.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Mimecast-Spam-Signature: yes X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Tue, 14 Sep 2021 04:15:19 -0400 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.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1631607332653100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: zhanglei --- include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 7ef8ac51e5..b088847725 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5074,6 +5074,7 @@ typedef enum { VIR_DOMAIN_GUEST_INFO_HOSTNAME =3D (1 << 3), /* return hostname inform= ation */ VIR_DOMAIN_GUEST_INFO_FILESYSTEM =3D (1 << 4), /* return filesystem in= formation */ VIR_DOMAIN_GUEST_INFO_DISKS =3D (1 << 5), /* return disks information = */ + VIR_DOMAIN_GUEST_INFO_INTERFACES =3D (1 << 6), /* return interfaces in= formation */ } virDomainGuestInfoTypes; =20 int virDomainGetGuestInfo(virDomainPtr domain, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 57baef6889..b4d88f55d4 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12579,6 +12579,19 @@ virDomainSetVcpu(virDomainPtr domain, * * "hostname" - the hostname of the domain * + * VIR_DOMAIN_GUEST_INFO_INTERFACES: + * Returns information about the interfaces within the domain. the typed + * parameter keys are in this format: + * + * "if.count" - the number of interfaces defined on this domain + * as an unsigned int + * "if..name" - interface name in the guest + * "if..hwaddr" - hardware address of interface + * "if..addr.count - the number of ip addresses of interface + * "if..addr..type" - the type of ip address(e.g. ipv4) + * "if..addr..addr" - the ip address + * "if..addr..prefix" - the number of bits of ip address pr= efix + * * Using 0 for @types returns all information groups supported by the given * hypervisor. * --=20 2.31.1 From nobody Thu Apr 25 04:03:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631607331064159.1426305465917; Tue, 14 Sep 2021 01:15:31 -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-423-pkUKCT9aNG-Tafj7X-E4KA-1; Tue, 14 Sep 2021 04:15:28 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D2EA1800D41; Tue, 14 Sep 2021 08:15:23 +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 2D02A19739; Tue, 14 Sep 2021 08:15:23 +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 30DBF1803B30; Tue, 14 Sep 2021 08:15:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18E7vaIu010049 for ; Tue, 14 Sep 2021 03:57:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id E35EC2151500; Tue, 14 Sep 2021 07:57:35 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC87F2151504 for ; Tue, 14 Sep 2021 07:57:33 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F89B8934E5 for ; Tue, 14 Sep 2021 07:57:33 +0000 (UTC) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-NyLu2rVYNAmhL8rLNIzqZg-1; Tue, 14 Sep 2021 03:57:30 -0400 Received: by mail-pj1-f51.google.com with SMTP id k23-20020a17090a591700b001976d2db364so2098809pji.2 for ; Tue, 14 Sep 2021 00:57:30 -0700 (PDT) Received: from fedora.zelin.local (61-221-155-12.hinet-ip.hinet.net. [61.221.155.12]) by smtp.gmail.com with ESMTPSA id p9sm11390650pgn.36.2021.09.14.00.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 00:57:29 -0700 (PDT) X-MC-Unique: pkUKCT9aNG-Tafj7X-E4KA-1 X-MC-Unique: NyLu2rVYNAmhL8rLNIzqZg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kpoqA8ZDSoPHfW7hxiX9hCVZC9QdOPxsELLjemEe6m0=; b=0w/5bqJQkB3llIo7tB9E3J6FrjloArHkgJcFCaVyb+aXS7M1pDE1BpAgdLv33tLnOg 9490PrbgEtsLCrTcCNsQpePaqR+L2p8I9RpIuPLyAa3ieMvrPmG/VfFfyJO88goPd7wS N2C4L2vGlnB1jJtS13GtFaetKZfa8QyK4dCPBJoODY/jiPmCxnCsoCc7x5FGXmbu460+ Ly+XNalV3KFhN2j987fsJYS3RX5uRoGgKiB6heVpNlxhTsSzJtK5z6RpPqNZ5yg2Cd0I LP+xnW/SvE/uu+RPCy4eec0c+G6k57EygB7JU0NvP26fXppDhMICE/BPUxL0zc0GYJ56 aRzQ== X-Gm-Message-State: AOAM530ir5Oiy+oWk2TcmfIdXn+ot4Ox+JMSrGtSlaBehOr6qTw4JekI VHJs0lqliKN3iJByjzTiPHuowbDQuXSDV8jILy4= X-Google-Smtp-Source: ABdhPJwBUWc9ts/um+0xxGaKLGELjg0Ln9BLfPizSqaKkANsI9k7iea3zKSI7zvqbT2r14ooM5YsgQ== X-Received: by 2002:a17:902:ab16:b0:13a:356c:6a03 with SMTP id ik22-20020a170902ab1600b0013a356c6a03mr13849487plb.38.1631606249549; Tue, 14 Sep 2021 00:57:29 -0700 (PDT) From: zhanglei To: zhanglei@smartx.com, libvir-list@redhat.com Subject: [libvirt PATCH v2 2/4] virsh: add interface information to guestinfo command Date: Tue, 14 Sep 2021 15:56:43 +0800 Message-Id: <20210914075645.166703-3-zhanglei@smartx.com> In-Reply-To: <20210914075645.166703-1-zhanglei@smartx.com> References: <20210914075645.166703-1-zhanglei@smartx.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Mimecast-Spam-Signature: yes X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Tue, 14 Sep 2021 04:15:19 -0400 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.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1631607332656100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: zhanglei --- docs/manpages/virsh.rst | 12 ++++++++++-- tools/virsh-domain.c | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 9561b3f59d..dd186ab14d 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -2700,7 +2700,7 @@ guestinfo :: =20 guestinfo domain [--user] [--os] [--timezone] [--hostname] [--filesyste= m] - [--disk] + [--disk] [--interface] =20 Print information about the guest from the point of view of the guest agen= t. Note that this command requires a guest agent to be configured and running= in @@ -2711,7 +2711,7 @@ are supported by the guest agent. You can limit the t= ypes of information that are returned by specifying one or more flags. If a requested information type is not supported, the processes will provide an exit code of 1. Available information types flags are *--user*, *--os*, -*--timezone*, *--hostname*, *--filesystem* and *--disk*. +*--timezone*, *--hostname*, *--filesystem*, *--disk* and *--interface*. =20 Note that depending on the hypervisor type and the version of the guest ag= ent running within the domain, not all of the following information may be @@ -2779,6 +2779,14 @@ returned: * ``disk..alias`` - the device alias of the disk (e.g. sda) * ``disk..guest_alias`` - optional alias assigned to the disk =20 +*--interface* returns: +* ``if.count`` - the number of interfaces defined on this domain +* ``if..name`` - name in the guest (e.g. ``eth0``) for interface +* ``if..hwaddr`` - hardware address in the guest for interface +* ``if..addr.count`` - the number of IP addresses of interface +* ``if..addr..type`` - the type of IP address (e.g. ipv4) +* ``if..addr..addr`` - the address of IP address +* ``if..addr..prefix`` - the prefix of IP address =20 guestvcpus ---------- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index e5bd1fdd75..5ba5bd6b8c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13829,6 +13829,10 @@ static const vshCmdOptDef opts_guestinfo[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("report disk information"), }, + {.name =3D "interface", + .type =3D VSH_OT_BOOL, + .help =3D N_("report interface information"), + }, {.name =3D NULL} }; =20 @@ -13854,6 +13858,8 @@ cmdGuestInfo(vshControl *ctl, const vshCmd *cmd) types |=3D VIR_DOMAIN_GUEST_INFO_FILESYSTEM; if (vshCommandOptBool(cmd, "disk")) types |=3D VIR_DOMAIN_GUEST_INFO_DISKS; + if (vshCommandOptBool(cmd, "interface")) + types |=3D VIR_DOMAIN_GUEST_INFO_INTERFACES; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; --=20 2.31.1 From nobody Thu Apr 25 04:03:06 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com 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 1631607342268766.3444529290804; Tue, 14 Sep 2021 01:15:42 -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-486-jBFyA_p5Ou2sWLISrsZmGA-1; Tue, 14 Sep 2021 04:15:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A559824FAD; Tue, 14 Sep 2021 08:15:33 +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 DBCA560CCC; Tue, 14 Sep 2021 08:15:32 +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 939AC4EA2F; Tue, 14 Sep 2021 08:15:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18E7va1t010051 for ; Tue, 14 Sep 2021 03:57:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 73C007D2B4; Tue, 14 Sep 2021 07:57:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B1A7AB3FD for ; Tue, 14 Sep 2021 07:57:33 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DAEB7800883 for ; Tue, 14 Sep 2021 07:57:33 +0000 (UTC) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-oi77Rzd4M5e75rApTIWyIQ-1; Tue, 14 Sep 2021 03:57:32 -0400 Received: by mail-pj1-f66.google.com with SMTP id oc9so8269011pjb.4 for ; Tue, 14 Sep 2021 00:57:32 -0700 (PDT) Received: from fedora.zelin.local (61-221-155-12.hinet-ip.hinet.net. [61.221.155.12]) by smtp.gmail.com with ESMTPSA id p9sm11390650pgn.36.2021.09.14.00.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 00:57:30 -0700 (PDT) X-MC-Unique: jBFyA_p5Ou2sWLISrsZmGA-1 X-MC-Unique: oi77Rzd4M5e75rApTIWyIQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aQEnABqW1squ9bO2Hb/y1Jv5bXO2QbkrQQcnw+Digps=; b=v/gtUypdUYh/3PeIUT8uU2yQR81EE0IxCL2PLHDAuX08y5KgyTZRe6zby1iwC1PU7R dSzVyIV5SSp/GMbHPSdtX6F7Vx3N6Qcnn3F9OCmfblMCxHfkjg6geVhCAdsdv5zOjNdM gU/aePCQ5Vme52M2mrprUadcg2Uh4zm+O8U9gokjF7os7cBXiLb3dJC6yB1xnsN2H641 rOo3WrMOF62/eqdvUHDyxOfiedvu0vI1JAWxqWR0S6omKUtxUvnYYBhEEEV2yX5o3zJy KrG7VLROo1STvM1hai4klS22I/zCAbz5n4LSJ1ClyWsGYq9xonhyuY3m1o9SEaDPCucV Ouhg== X-Gm-Message-State: AOAM532t3zJPhEhxcZ/Rs5a76XQk0HSo3DVZ5dQN/6jIazA0qKCj0F6s NFPcijG9Od3nqlZU8lH0ye6zPjNYaX611x2Wf1g= X-Google-Smtp-Source: ABdhPJzxlHeaqtrG7qcM4ZCG8gROsipUtZ9Wzi4uNJGBeyEOfHvPy1qV0SBVMa8mdQiXKJbEXiTFLQ== X-Received: by 2002:a17:902:8648:b029:129:dda4:ddc2 with SMTP id y8-20020a1709028648b0290129dda4ddc2mr14044479plt.4.1631606251061; Tue, 14 Sep 2021 00:57:31 -0700 (PDT) From: zhanglei To: zhanglei@smartx.com, libvir-list@redhat.com Subject: [libvirt PATCH v2 3/4] qemu: report guest interface information in 'qemuDomainGetGuestInfo' Date: Tue, 14 Sep 2021 15:56:44 +0800 Message-Id: <20210914075645.166703-4-zhanglei@smartx.com> In-Reply-To: <20210914075645.166703-1-zhanglei@smartx.com> References: <20210914075645.166703-1-zhanglei@smartx.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Mimecast-Spam-Signature: yes X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Tue, 14 Sep 2021 04:15:19 -0400 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.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1631607343462100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: zhanglei --- src/qemu/qemu_agent.c | 9 +++-- src/qemu/qemu_agent.h | 3 +- src/qemu/qemu_driver.c | 89 +++++++++++++++++++++++++++++++++++++++++- tests/qemuagenttest.c | 2 +- 4 files changed, 96 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 5f421be6f6..a7f943e0dc 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2245,17 +2245,20 @@ qemuAgentGetAllInterfaceAddresses(virDomainInterfac= ePtr **ifaces_ret, */ int qemuAgentGetInterfaces(qemuAgent *agent, - virDomainInterfacePtr **ifaces) + virDomainInterfacePtr **ifaces, + bool report_unsupported) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *ret_array =3D NULL; + int rc; =20 if (!(cmd =3D qemuAgentMakeCommand("guest-network-get-interfaces", NUL= L))) return -1; =20 - if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - return -1; + if ((rc =3D qemuAgentCommandFull(agent, cmd, &reply, agent->timeout, + report_unsupported)) < 0) + return rc; =20 if (!(ret_array =3D virJSONValueObjectGetArray(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 81b45b8e5d..94eab9de9f 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -151,7 +151,8 @@ int qemuAgentSetTime(qemuAgent *mon, bool sync); =20 int qemuAgentGetInterfaces(qemuAgent *mon, - virDomainInterfacePtr **ifaces); + virDomainInterfacePtr **ifaces, + bool report_unsupported); =20 int qemuAgentSetUserPassword(qemuAgent *mon, const char *user, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index dfc27572c4..ec5bf0a451 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18950,7 +18950,7 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, goto endjob; =20 agent =3D qemuDomainObjEnterAgent(vm); - ret =3D qemuAgentGetInterfaces(agent, ifaces); + ret =3D qemuAgentGetInterfaces(agent, ifaces, true); qemuDomainObjExitAgent(vm, agent); =20 endjob: @@ -19896,7 +19896,8 @@ static const unsigned int qemuDomainGetGuestInfoSup= portedTypes =3D VIR_DOMAIN_GUEST_INFO_TIMEZONE | VIR_DOMAIN_GUEST_INFO_HOSTNAME | VIR_DOMAIN_GUEST_INFO_FILESYSTEM | - VIR_DOMAIN_GUEST_INFO_DISKS; + VIR_DOMAIN_GUEST_INFO_DISKS | + VIR_DOMAIN_GUEST_INFO_INTERFACES; =20 static int qemuDomainGetGuestInfoCheckSupport(unsigned int types, @@ -20095,6 +20096,70 @@ qemuAgentFSInfoFormatParams(qemuAgentFSInfo **fsin= fo, } } =20 +static void +virDomainInterfaceFormatParams(virDomainInterfacePtr *ifaces, +int nifaces, +virTypedParameterPtr *params, +int *nparams, int * maxparams) +{ + size_t i, j; + const char *type =3D NULL; + + if (virTypedParamsAddUInt(params, nparams, maxparams, + "if.count", nifaces) < 0) + return; + + for (i =3D 0; i < nifaces; i++) { + char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; + + g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "if.%zu.name", i); + if (virTypedParamsAddString(params, nparams, maxparams, + param_name, ifaces[i]->name) < 0) + return; + + g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "if.%zu.hwaddr", i); + if (virTypedParamsAddString(params, nparams, maxparams, + param_name, ifaces[i]->hwaddr) < 0) + return; + + g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "if.%zu.addr.count", i); + if (virTypedParamsAddUInt(params, nparams, maxparams, + param_name, ifaces[i]->naddrs) < 0) + return; + + for (j =3D 0; j < ifaces[i]->naddrs; j++) { + switch (ifaces[i]->addrs[j].type) { + case VIR_IP_ADDR_TYPE_IPV4: + type =3D "ipv4"; + break; + case VIR_IP_ADDR_TYPE_IPV6: + type =3D "ipv6"; + break; + } + + g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "if.%zu.addr.%zu.type", i, j); + if (virTypedParamsAddString(params, nparams, maxparams, + param_name, type) < 0) + return; + + g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "if.%zu.addr.%zu.addr", i, j); + if (virTypedParamsAddString(params, nparams, maxparams, + param_name, ifaces[i]->addrs[j].addr) = < 0) + return; + + g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "if.%zu.addr.%zu.prefix", i, j); + if (virTypedParamsAddUInt(params, nparams, maxparams, + param_name, ifaces[i]->addrs[j].prefix= ) < 0) + return; + } + } +} =20 static int qemuDomainGetGuestInfo(virDomainPtr dom, @@ -20116,6 +20181,8 @@ qemuDomainGetGuestInfo(virDomainPtr dom, qemuAgentFSInfo **agentfsinfo =3D NULL; size_t ndisks =3D 0; qemuAgentDiskInfo **agentdiskinfo =3D NULL; + virDomainInterfacePtr *ifaces =3D NULL; + size_t nifaces =3D 0; size_t i; =20 virCheckFlags(0, -1); @@ -20181,6 +20248,15 @@ qemuDomainGetGuestInfo(virDomainPtr dom, } } =20 + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_INTERFACES) { + rc =3D qemuAgentGetInterfaces(agent, &ifaces, report_unsupported); + if (rc =3D=3D -1) { + goto exitagent; + } else if (rc >=3D 0) { + nifaces =3D rc; + } + } + qemuDomainObjExitAgent(vm, agent); qemuDomainObjEndAgentJob(vm); =20 @@ -20203,6 +20279,10 @@ qemuDomainGetGuestInfo(virDomainPtr dom, qemuDomainObjEndJob(driver, vm); } =20 + if (nifaces > 0) { + virDomainInterfaceFormatParams(ifaces, nifaces, params, nparams, &= maxparams); + } + ret =3D 0; =20 cleanup: @@ -20212,6 +20292,11 @@ qemuDomainGetGuestInfo(virDomainPtr dom, for (i =3D 0; i < ndisks; i++) qemuAgentDiskInfoFree(agentdiskinfo[i]); g_free(agentdiskinfo); + if (ifaces && nifaces > 0) { + for (i =3D 0; i < nifaces; i++) + virDomainInterfaceFree(ifaces[i]); + } + g_free(ifaces); =20 virDomainObjEndAPI(&vm); return ret; diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index bef6dfd152..8fb3da7fef 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -907,7 +907,7 @@ testQemuAgentGetInterfaces(const void *data) goto cleanup; =20 if ((ifaces_count =3D qemuAgentGetInterfaces(qemuMonitorTestGetAgent(t= est), - &ifaces)) < 0) + &ifaces, true)) < 0) goto cleanup; =20 if (ifaces_count !=3D 4) { --=20 2.31.1 From nobody Thu Apr 25 04:03:06 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com 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 1631607340385924.9416296659015; Tue, 14 Sep 2021 01:15:40 -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-286-Prj-QsxlNoW_CovHbJi9RQ-1; Tue, 14 Sep 2021 04:15:37 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D01EF18414A1; Tue, 14 Sep 2021 08:15:32 +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 A417C19739; Tue, 14 Sep 2021 08:15:32 +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 6EE4A4EA29; Tue, 14 Sep 2021 08:15:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18E7viwm010085 for ; Tue, 14 Sep 2021 03:57:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 12DE69C053; Tue, 14 Sep 2021 07:57:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 093A59C04E for ; Tue, 14 Sep 2021 07:57:35 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D8EB1884984 for ; Tue, 14 Sep 2021 07:57:35 +0000 (UTC) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-492-Wct2gqH7Oba5p9Vtu4IV1w-1; Tue, 14 Sep 2021 03:57:33 -0400 Received: by mail-pj1-f48.google.com with SMTP id m21-20020a17090a859500b00197688449c4so2134777pjn.0 for ; Tue, 14 Sep 2021 00:57:33 -0700 (PDT) Received: from fedora.zelin.local (61-221-155-12.hinet-ip.hinet.net. [61.221.155.12]) by smtp.gmail.com with ESMTPSA id p9sm11390650pgn.36.2021.09.14.00.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 00:57:32 -0700 (PDT) X-MC-Unique: Prj-QsxlNoW_CovHbJi9RQ-1 X-MC-Unique: Wct2gqH7Oba5p9Vtu4IV1w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5qOHghDAS7hnECQoxuLPVlsTnxKpvxd1OIGxF6cDxz8=; b=5ur3kg3K0SX7otzgCbyxcJwH4qfNgZqKgRJ8ygaSkR9sui1Ggp0Gtl0/I7TL1FqxR/ MrpTQFJ/J3mXqJJxrwpKu5zfzh2MgZydv8v0jjzewlDsjuv9jmfiHOxiqy/4165YXnNr GixlbAzn3FH58AhvWr3uoAGSTwuMk+IkF6wWzOXz/yoPJNwDcwZFBUXtl2qqI9wlliVI znm8AmymeyDfVkHA8Oh45DgZsKWVMEwFTXxHgj2pUcxPIC5DcCEiTd8k7+Olmmt33jXa sBYNdgB3XaoqU2Ft9OqJiNmq2x069TLP279ISOehh/NYpJGa04uk91zeItT4MLvEqyBu JPLQ== X-Gm-Message-State: AOAM532qlFHbRzUdXXvgpXEvS5+Kx+zDXa5EXHhUwaXEbixLIkfbOUgg MRE6qi4fceXJKI4um5Npm4bYmQet+9wVyyo59fo= X-Google-Smtp-Source: ABdhPJyxkq567mEc5W5otHFpOPmyv//1l8bVqKHrI6247txNJ0oRL+yk+XfQ/Mt385j8RHaBxgYwWw== X-Received: by 2002:a17:903:1104:b0:13a:41f1:6dd5 with SMTP id n4-20020a170903110400b0013a41f16dd5mr13937971plh.48.1631606252543; Tue, 14 Sep 2021 00:57:32 -0700 (PDT) From: zhanglei To: zhanglei@smartx.com, libvir-list@redhat.com Subject: [libvirt PATCH v2 4/4] NEWS: qemu: report guest interfaces information in 'virDomainGetGuestInfo' Date: Tue, 14 Sep 2021 15:56:45 +0800 Message-Id: <20210914075645.166703-5-zhanglei@smartx.com> In-Reply-To: <20210914075645.166703-1-zhanglei@smartx.com> References: <20210914075645.166703-1-zhanglei@smartx.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Mimecast-Spam-Signature: yes X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Tue, 14 Sep 2021 04:15:19 -0400 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.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1631607341369100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: zhanglei --- NEWS.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 4521499db7..9288597f18 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -19,6 +19,11 @@ v7.8.0 (unreleased) =20 * **Improvements** =20 + * qemu: Report guest interfaces information in ``virDomainGetGuestInfo`` + + Libvirt is now able to report interfaces from the guest's + perspective (using guest agent). + * **Bug fixes** =20 =20 --=20 2.31.1