[libvirt PATCH v4 4/5] qemu: add guest interface information in 'qemuDomainGetGuestInfo'

Ján Tomko jtomko at redhat.com
Fri Nov 5 12:45:15 UTC 2021


On a Friday in 2021, zhanglei wrote:
>Support return guest interface information from guest agent
>
>Signed-off-by: zhanglei <zhanglei at smartx.com>
>---
> src/qemu/qemu_driver.c | 88 +++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 87 insertions(+), 1 deletion(-)
>
>diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>index 7e058a9309..0688964195 100644
>--- a/src/qemu/qemu_driver.c
>+++ b/src/qemu/qemu_driver.c
>@@ -20036,7 +20036,8 @@ static const unsigned int qemuDomainGetGuestInfoSupportedTypes =
>     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;
>
> static int
> qemuDomainGetGuestInfoCheckSupport(unsigned int types,
>@@ -20235,6 +20236,71 @@ qemuAgentFSInfoFormatParams(qemuAgentFSInfo **fsinfo,
>     }
> }
>
>+static void
>+virDomainInterfaceFormatParams(virDomainInterfacePtr *ifaces,
>+                               int nifaces,
>+                               virTypedParameterPtr *params,
>+                               int *nparams, int * maxparams)

No space after the '*' is the prevailing libvirt style.

>+{
>+    size_t i;
>+    size_t j;
>+    const char *type = NULL;
>+
>+    if (virTypedParamsAddUInt(params, nparams, maxparams,
>+                             "if.count", nifaces) < 0)
>+        return;
>+
>+    for (i = 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 = 0; j < ifaces[i]->naddrs; j++) {

'type' is only used within this block so its scope can be reduced.

>+            switch (ifaces[i]->addrs[j].type) {
>+                case VIR_IP_ADDR_TYPE_IPV4:
>+                    type = "ipv4";
>+                    break;
>+                case VIR_IP_ADDR_TYPE_IPV6:
>+                    type = "ipv6";
>+                    break;
>+            }

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20211105/e2501e88/attachment-0001.sig>


More information about the libvir-list mailing list