-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Obtaing the ip address of the guest and update address cache #3935
Conversation
The patch helps in obtaining ip address of the guest using "virsh-net-dhcp-leases default" command. If the guest mac address is found in the command output, the mac ipv4 address is obatined and updated in the address.cache Signed-off-by: Tasmiya Nalatwad <tasmiya@linux.vnet.ibm.com>
Please find the avocado test run results executed on the patch 12:24:12 WARNING : Overriding user setting and enabling kvm bootstrap as guest tests are requested |
# Read guest address via serial console and update VM address | ||
# cache to avoid get out-dated address. | ||
utils_net.update_mac_ip_address(self, timeout) | ||
ipaddr = self.get_address(nic_index, ip_version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function "utils_net.update_mac_ip_address" is trying to do serial login (create session and login) and then update the mac_ip_address in address.cache but as there is no ip address, the connection to serial console fails and following function self.get_address also fails.
Hence removing this approach and trying to get the ip address from virsh-net-dhcp-leases command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi @TasmiyaNalatwad |
@chloerh it is like GitHub action (which trigger CI) only calls for first time contributor when maintainer's ACK it , that's why it missed via automation engine , for regular contributor it triggers automatically (as restrict random request to trigger CI (which is not authentic) thus to save resources ) |
@PraveenPenguin I see. Thanks for explaining. I was worried about something might be wrong with our ci-check (randomly) |
Hello @TasmiyaNalatwad @lmr, this introduced a regression against obtaining the guest's ip addresses properly by the changed routine. That's because:
|
@TasmiyaNalatwad @lmr do you have any plan to fix the issue? otherwise, I will revert this commit for the sake of qemu users. |
@luckyh Thanks for the review and inputs. I have a plan to get the IP address without using virsh commands. How about using arp table inspection that lists all known IP-MAC address mappings. This way we can get the ip address of guest for respective Mac address. |
@TasmiyaNalatwad as we also need to deal with ipv6 addresses for this context I'd suggest using Instead, I'd suggest the following approach if the original issue only happened to libvirt testing ( diff --git a/virttest/libvirt_vm.py b/virttest/libvirt_vm.py
index 825674e2f..7ce748804 100644
--- a/virttest/libvirt_vm.py
+++ b/virttest/libvirt_vm.py
@@ -378,6 +378,14 @@ class VM(virt_vm.BaseVM):
LOG.error("Failed to backup xml file:\n%s", detail)
return ""
+ def _get_address(self, index=0, ip_version="ipv4", session=None, timeout=60.0):
+ try:
+ return super()._get_address(index, ip_version, session, timeout)
+ except Exception:
+ output = virsh.domifaddr(self.name)
+ # parse the output and return a valid ip
+ ...
+
def clone(
self,
name=None, Let me know your opinion. [1] arp manual page
|
Hi @TasmiyaNalatwad , finally I sent the PR #3989 in favor of qemu testing, as I feel that the current |
Hi @luckyh , Ok The approach you shared above |
mac = self.get_mac_address(nic_index).lower() | ||
ipaddr = utils_net.obtain_guest_ip_from_dhcp_leases(mac) | ||
# updating cache with the latest ip address value | ||
self.address_cache[mac] = ipaddr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @TasmiyaNalatwad Could you please help redesign this part? Because of the current usage let all the releated
nic_hotplug cases failed which blocking my test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yanglei-rh there is patch already shared by @luckyh #3989 to revert this patch, Which would unblock your tests. Also i will share the new patch with the approach we had discussed in above comments soon.
Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks a lot.
@yanglei-rh I have raised a new PR #4002 which would not affect any other user than libvirt. |
Got it, thanks for help sync this PR. |
Few of the times it is seen that the ip address is not being fetch and the avocado runs were failed with error "ERROR: Failures occurred while postprocess:\n\n: Guest virt-tests-vm1 dmesg verification failed: Login timeout expired (output: 'exceeded 240 s timeout, last failure: No ipv4 DHCP lease for MAC aa:bb:cc:dd:ee:ff') "
To handle this error the patch has been sent. The patch helps in obtaining ip address of the guest using "virsh-net-dhcp-leases default" command. If the guest mac address is found in the command output, the mac ipv4 address is obatined and updated in the address.cache