]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: add interface information to guestinfo command
authorzhanglei <zhanglei@smartx.com>
Fri, 15 Oct 2021 10:07:48 +0000 (18:07 +0800)
committerJán Tomko <jtomko@redhat.com>
Fri, 5 Nov 2021 12:38:40 +0000 (13:38 +0100)
The new parameter group returns information about network interfaces

Signed-off-by: zhanglei <zhanglei@smartx.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
docs/manpages/virsh.rst
tools/virsh-domain.c

index ac564d94f2cb63175bc37df40ad251720e0d4443..5f5ccfeafe6eff8437ec8fe10673f1fcfd28f160 100644 (file)
@@ -2700,7 +2700,7 @@ guestinfo
 ::
 
    guestinfo domain [--user] [--os] [--timezone] [--hostname] [--filesystem]
-      [--disk]
+      [--disk] [--interface]
 
 Print information about the guest from the point of view of the guest agent.
 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 types 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*.
 
 Note that depending on the hypervisor type and the version of the guest agent
 running within the domain, not all of the following information may be
@@ -2779,6 +2779,14 @@ returned:
 * ``disk.<num>.alias`` - the device alias of the disk (e.g. sda)
 * ``disk.<num>.guest_alias`` - optional alias assigned to the disk
 
+*--interface* returns:
+* ``if.count`` - the number of interfaces defined on this domain
+* ``if.<num>.name`` - name in the guest (e.g. ``eth0``) for interface <num>
+* ``if.<num>.hwaddr`` - hardware address in the guest for interface <num>
+* ``if.<num>.addr.count`` - the number of IP addresses of interface <num>
+* ``if.<num>.addr.<num1>.type`` - the IP address type of addr <num1> (e.g. ipv4)
+* ``if.<num>.addr.<num1>.addr`` - the IP address of addr <num1>
+* ``if.<num>.addr.<num1>.prefix`` - the prefix of IP address of addr <num1>
 
 guestvcpus
 ----------
index d454075dfcefc69988c69baf200a4c7c3dcca62b..22f428f7023d36afae9fd0b192431c6e1e6bc064 100644 (file)
@@ -14077,6 +14077,10 @@ static const vshCmdOptDef opts_guestinfo[] = {
      .type = VSH_OT_BOOL,
      .help = N_("report disk information"),
     },
+    {.name = "interface",
+     .type = VSH_OT_BOOL,
+     .help = N_("report interface information"),
+    },
     {.name = NULL}
 };
 
@@ -14102,6 +14106,8 @@ cmdGuestInfo(vshControl *ctl, const vshCmd *cmd)
         types |= VIR_DOMAIN_GUEST_INFO_FILESYSTEM;
     if (vshCommandOptBool(cmd, "disk"))
         types |= VIR_DOMAIN_GUEST_INFO_DISKS;
+    if (vshCommandOptBool(cmd, "interface"))
+        types |= VIR_DOMAIN_GUEST_INFO_INTERFACES;
 
     if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;