Skip to content

Commit

Permalink
Use VIF.move only if just the network is changed and not the MAC addr…
Browse files Browse the repository at this point in the history
…ess. If the MAC is changed, recreate the interface instead.

Backgound: VIF.move can just move a VIF to another network, but not change the MAC properly (and this is also not expected from an action named move).

#128
  • Loading branch information
borzel committed May 11, 2019
1 parent 4cd256f commit 1ebb4bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion XenModel/Actions/VM/ImportVmAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,16 @@ protected override void Run()
if (network != null)
networks.Add(network);

string oldmac = VIF.get_MAC(Session, vif);

if (canMoveVifs)
{
var vifObj = Connection.Resolve(vif);
if (vifObj == null)
continue;
// try to find a matching VIF in the m_proxyVIFs list, based on the device field
var matchingProxyVif = m_VIFs.FirstOrDefault(proxyVIF => proxyVIF.device == vifObj.device);
if (matchingProxyVif != null)
if (matchingProxyVif != null && matchingProxyVif.MAC == oldmac)
{
// move the VIF to the desired network
VIF.move(Session, vif, matchingProxyVif.network);
Expand Down

0 comments on commit 1ebb4bd

Please sign in to comment.