From 35030239f2c238eab9e4f914970d56c292a45784 Mon Sep 17 00:00:00 2001 From: Simon Kobyda Date: Mon, 15 May 2023 14:47:52 +0200 Subject: [PATCH] Show virtual interface's TAP device Network interfaces that are attached to VMs have a TUN/TAP device. If you want to check manually, e.g. why the device is not working correctly, you need to know the interface name. Name of the tap device is be specified with attribute of the element. If no target dev is specified upon vnic attachement, libvirt will create a new standard tap device with a name of the pattern "vnetN" Shot this device in the list of VM's interfaces. In the future, we could also allow user to choose/name a tap device during vNIC attachement. Fixes #1047 --- src/components/vm/nics/vmNicsCard.jsx | 75 +++++++++++++++++++++------ src/machines.scss | 11 ---- test/check-machines-nics | 4 +- test/reference | 2 +- 4 files changed, 62 insertions(+), 30 deletions(-) diff --git a/src/components/vm/nics/vmNicsCard.jsx b/src/components/vm/nics/vmNicsCard.jsx index 73001a346..1cc97a122 100644 --- a/src/components/vm/nics/vmNicsCard.jsx +++ b/src/components/vm/nics/vmNicsCard.jsx @@ -19,6 +19,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Button } from "@patternfly/react-core/dist/esm/components/Button"; +import { DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm } from "@patternfly/react-core/dist/esm/components/DescriptionList"; import { Flex, FlexItem } from "@patternfly/react-core/dist/esm/layouts/Flex"; import { Tooltip } from "@patternfly/react-core/dist/esm/components/Tooltip"; import { DialogsContext } from 'dialogs.jsx'; @@ -124,13 +125,46 @@ const NetworkSource = ({ network, networkId, vm, hostDevices }) => { }; }; - const singleSourceElem = source => checkDeviceAviability(source) ? : source; - const addressPortSourceElem = (source, networkId) => ( - - - - -
{_("Address")}{source.address}
{_("Port")}{source.port}
); + const singleSourceElem = source => { + let label = rephraseUI("networkType", network.type); + label = label.charAt(0).toUpperCase() + label.slice(1); + + return ( + + + {label} + + + + + {checkDeviceAviability(source) + ? + : source} + + {needsShutdownIfaceSource(vm, network) && } + + + + ); + }; + const addressPortSourceElem = source => (<> + + + {_("Address")} + + + {source.address} + + + + + {_("Port")} + + + {source.port} + + + ); const getSourceElem = { direct: singleSourceElem, @@ -142,16 +176,23 @@ const NetworkSource = ({ network, networkId, vm, hostDevices }) => { udp: addressPortSourceElem, }; - if (getSourceElem[network.type] !== undefined) { - return ( - - {getSourceElem[network.type](getIfaceSourceName(network), networkId)} - {needsShutdownIfaceSource(vm, network) && } - - ); - } else { - return null; - } + let source; + if (getSourceElem[network.type] !== undefined) + source = getSourceElem[network.type](getIfaceSourceName(network), networkId); + + return ( + + {source} + {network.target && + + {_("TAP device")} + + + {network.target} + + } + + ); }; export class VmNetworkTab extends React.Component { diff --git a/src/machines.scss b/src/machines.scss index 71b041db1..71bb2ccce 100644 --- a/src/machines.scss +++ b/src/machines.scss @@ -35,17 +35,6 @@ font-size: inherit; } -.machines-network-source-descr { - color: var(--ct-color-subtle-copy); - text-align: right; - padding: 5px 10px !important; -} - -.machines-network-source-value { - padding: 5px 10px !important; - text-align: left !important; -} - .machines-listing-actions { display: flex; justify-content: flex-end; diff --git a/test/check-machines-nics b/test/check-machines-nics index 3f657fa63..5eaa837fa 100755 --- a/test/check-machines-nics +++ b/test/check-machines-nics @@ -59,6 +59,7 @@ class TestMachinesNICs(VirtualMachinesCase): b.wait_in_text("#vm-subVmTest1-network-1-type", "network") b.wait_in_text("#vm-subVmTest1-network-1-source", "default") + b.wait_in_text("#vm-subVmTest1-network-1-tapdevice", "vnet0") b.wait_in_text("#vm-subVmTest1-network-1-ipv4-address", "192.168.122.") b.wait_in_text("#vm-subVmTest1-network-1-state", "up") b.assert_pixels("#vm-subVmTest1-networks", @@ -72,10 +73,11 @@ class TestMachinesNICs(VirtualMachinesCase): self.deleteIface(1) # Test add network - m.execute("virsh attach-interface --domain subVmTest1 --type network --source default --model virtio --mac 52:54:00:4b:73:5f --config --live") + m.execute("virsh attach-interface --domain subVmTest1 --type network --source default --target vnet1 --model virtio --mac 52:54:00:4b:73:5f --config --live") b.wait_in_text("#vm-subVmTest1-network-1-type", "network") b.wait_in_text("#vm-subVmTest1-network-1-source", "default") + b.wait_in_text("#vm-subVmTest1-network-1-tapdevice", "vnet1") b.wait_in_text("#vm-subVmTest1-network-1-model", "virtio") b.wait_in_text("#vm-subVmTest1-network-1-mac", "52:54:00:4b:73:5f") b.wait_in_text("#vm-subVmTest1-network-1-ipv4-address", "192.168.122.") diff --git a/test/reference b/test/reference index d23242a0b..d35e7ccc4 160000 --- a/test/reference +++ b/test/reference @@ -1 +1 @@ -Subproject commit d23242a0b7e7bdb197e39e43e3a4a0156f239b8b +Subproject commit d35e7ccc40fe96679a99d17858b593d4c8983e62