Bug 1395178 - [Hyper-V][RHEL7]Inconsistent behaviour when setting static IP using WMI from Hyper-V
Summary: [Hyper-V][RHEL7]Inconsistent behaviour when setting static IP using WMI from ...
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: hyperv-daemons
Version: 7.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Vitaly Kuznetsov
QA Contact: xuli
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-15 10:54 UTC by yonatan.amir
Modified: 2019-02-15 07:22 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Hyper-V (Windows Server 2012 R2)
Last Closed: 2019-02-15 07:22:44 UTC
Target Upstream Version:


Attachments (Terms of Use)
ip injection script (3.46 KB, text/plain)
2016-11-17 06:35 UTC, xuli
no flags Details
Modified IP injection script (4.21 KB, text/plain)
2016-11-17 07:48 UTC, yonatan.amir
no flags Details

Description yonatan.amir 2016-11-15 10:54:46 UTC
Description of problem:
If a Hyper-V VM with a NIC configured to use DHCP is booted and an attempt to set the NIC to a static IP address is made immediately following Hyper-V reporting that it has received an IP address (using DHCP), the static address will be added as a secondary address, and the DHCP address will remain the primary address. However, if the attempt to set a static address is made an arbitrary span of time later, it will be set as the primary address.

Version-Release number of selected component (if applicable):
Kernel 3.10.0-514.el7.x86_64
hyperv-daemons-0-0.29.20160216git.el7.x86_64

How reproducible:

Steps to Reproduce:
1. Install/import a RHEL 7.3 VM with a NIC on Hyper-V.
2. Set the NIC to use DHCP.
3. Shut down the VM.
4. Start the VM and immediately try to set a static IP, e.g. using Msvm_VirtualSystemManagementService.SetGuestNetworkAdapterConfiguration()
5. Wait an arbitrary length of time and repeat step 4.

Actual results:
After step 4 above, NIC is configured with a primary IP address from DHCP and a secondary static IP address. After step 5, it is configured with only the static address.

Expected results:
The IP configuration following 4 and following 5 should be identical.

Additional info:
The following should be handy in reproducing:
https://blogs.msdn.microsoft.com/taylorb/2014/11/03/setting-guest-ip-addresses-from-the-host/

Comment 1 yonatan.amir 2016-11-15 11:00:18 UTC
(In reply to yonatan.amir from comment #0)
> 4. Start the VM and immediately try to set a static IP, e.g. using
> Msvm_VirtualSystemManagementService.SetGuestNetworkAdapterConfiguration()
This should read: Start the VM and immediately *following Hyper-V reporting an IP for the NIC*, try to set a static IP, e.g. using Msvm_VirtualSystemManagementService.SetGuestNetworkAdapterConfiguration()

Comment 3 yonatan.amir 2016-11-16 10:16:19 UTC
Seeing this in /var/log/messages:
Nov 15 16:36:40 localhost network: Determining IP information for eth0.../etc/sysconfig/network-scripts/ifup-eth: line 297:   932 Terminated              /sbin/dhclient ${DHCLIENTARGS} ${DEVICE}
So it looks like the script terminates while dhclient is running.

Comment 4 yonatan.amir 2016-11-16 10:37:06 UTC
Looks like a race condition with ifup, probably one can avoid having to boot the VM and simply run the WMI command right after running ifup in the guest.

Comment 5 yonatan.amir 2016-11-16 12:38:32 UTC
(In reply to yonatan.amir from comment #4)
> Looks like a race condition with ifup, probably one can avoid having to boot
> the VM and simply run the WMI command right after running ifup in the guest.

I couldn't reproduce in the above fashion. Perhaps the CPU load at boot makes this more likely to occur, as it reproduces reliably for me.

Comment 6 xuli 2016-11-17 06:34:47 UTC
Test on Kernel 3.10.0-514.el7.x86_64, hyperv-daemons-0-0.29.20160216git.el7.x86_64, I cannot reproduce this issue after try 5 times  in local test enviroment (VM 1 CPU, 2G Memory with host Hyper-v server core 2016). Could you please use ip-injection.ps1 from attachment to check whether can reproduce in your enviroment?

Test steps:
1. Install/import a RHEL 7.3 VM with a NIC on Hyper-V.
2. Set the NIC to use DHCP, 
#cat ifcfg-eth0
IPV6INIT="yes"
DHCP_HOSTNAME="rhel7"
BOOTPROTO="dhcp"
DEVICE="eth0"
ONBOOT="yes"
#UUID=""
3. Shut down the VM.
4. Start the VM and immediately set a static IP by ip-injection.ps1 (execute "Get-VMNetworkAdapter -vmName xuli_rhel7.3 | ft ipaddresses", after just get vm ip, execute ./ip-injection.ps1 ).
5. View that it only shows static ip when checking by ifconfig.
#cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
IPADDR0=192.168.1.12
NETMASK0=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.2
IPV6INIT=yes
NM_CONTROLLED=no
PEERDNS=yes
ONBOOT=yes

Comment 7 xuli 2016-11-17 06:35:50 UTC
Created attachment 1221493 [details]
ip injection script

Comment 8 yonatan.amir 2016-11-17 07:48:48 UTC
Created attachment 1221501 [details]
Modified IP injection script

I've modified the script, partly because it didn't execute for me, but also to ensure it reproduces the issue. Note that the injection must be done immediately after the VM reports an IP address.
To reproduce:
1. Configure the VM to use DHCP
2. Stop the VM
3. Run the script

In my case, this is the output (truncated), note the 2 IPv4 addresses for the first NIC:
__GENUS          : 2
__CLASS          : Msvm_GuestNetworkAdapterConfiguration
__SUPERCLASS     : 
__DYNASTY        : Msvm_GuestNetworkAdapterConfiguration
__RELPATH        : Msvm_GuestNetworkAdapterConfiguration.InstanceID="Microsoft:GuestNetwork\\37DF2DF8-2700-4E87-91F2-0A7E3202DAAE\\
                   663C9F90-1E91-4859-8B8D-CCB8DE1B4556"
__PROPERTY_COUNT : 8
__DERIVATION     : {}
__SERVER         : ZNEST159HV01
__NAMESPACE      : root\virtualization\v2
__PATH           : \\ZNEST159HV01\root\virtualization\v2:Msvm_GuestNetworkAdapterConfiguration.InstanceID="Microsoft:GuestNetwork\\
                   37DF2DF8-2700-4E87-91F2-0A7E3202DAAE\\663C9F90-1E91-4859-8B8D-CCB8DE1B4556"
DefaultGateways  : {}
DHCPEnabled      : True
DNSServers       : {172.20.0.95, 172.20.0.96}
InstanceID       : Microsoft:GuestNetwork\37DF2DF8-2700-4E87-91F2-0A7E3202DAAE\663C9F90-1E91-4859-8B8D-CCB8DE1B4556
IPAddresses      : {fe80::215:5dff:fecd:3329}
IPAddressOrigins : {}
ProtocolIFType   : 4097
Subnets          : {/64}
PSComputerName   : ZNEST159HV01

Operation completed successfully



VMName                     Name                       MacAddress                IPAddresses                         VirtualSubnetId
------                     ----                       ----------                -----------                         ---------------
RHEL                       Network Adapter            00155DCD3329              {172.20.205.109, 172.2...                         0
RHEL                       Network Adapter            00155DCD332A              {172.20.205.120, fe80:...                         0

Comment 12 xuli 2019-02-15 05:30:56 UTC
Retest this bug on RHEL 7 kernel with 3.10.0-957.el7.x86_64 build by following https://bugzilla.redhat.com/show_bug.cgi?id=1395178#c6, still cannot reproduce this issue.

When use "ip injection script" in attachment, need to remove VM's snapshot, and only one network-adapter. Also tried add "Start-vm ----- write-host "done" to my ip injection script, still cannot reproduce this issue.

When use modified "ip injection script" from Yonatan, get error "GuestNetworkAdapterConfiguration not found for nic", this is script issue.

Hi Yonatan,
I will close this bug based on cannot reproduce. If you disagree, please feel free to comment on this bug.

Thank you so much.
Best Regards,
Xuemin


Note You need to log in before you can comment on or make changes to this bug.