Bug 667457 - intel 82576 : mac assignement to a VF is not persistant
intel 82576 : mac assignement to a VF is not persistant
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: libvirt (Show other bugs)
rawhide
x86_64 Linux
low Severity medium
: ---
: ---
Assigned To: Laine Stump
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-05 11:15 EST by mathieu
Modified: 2012-03-07 10:37 EST (History)
16 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-03-06 07:55:04 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description mathieu 2011-01-05 11:15:16 EST
Description of problem:
i'm using the kernel 2.6.35.10-74.fc14.x86_64.
after creating 7 VF per port on a intel 82576 network card, a mac address can be assigned to a specific VF with the command : 
#ip link set dev eth1 vf 0 mac 00.11.22.33.44.55

the corresponding VF is then assigned to a VM through virt-manager and PCI passthrough.

When the VM starts, the Mac address changes and is no longer the one assigned.

Version-Release number of selected component (if applicable):


How reproducible:
5/5


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:
the Mac address should not be changed.

Additional info:
Comment 1 Chuck Ebbert 2011-01-10 11:46:40 EST
(In reply to comment #1)
> #ip link set dev eth1 vf 0 mac 00.11.22.33.44.55
> 

What does it change to in the VM?
Comment 2 mathieu 2011-01-10 12:31:37 EST
(In reply to comment #1)
> (In reply to comment #1)
> > #ip link set dev eth1 vf 0 mac 00.11.22.33.44.55
> > 
> 
> What does it change to in the VM?

nothing happens to the VM if I set the mac address while the VM is running. Even if I restart the network, the VM keep its old Mac address.
Comment 3 mathieu 2011-01-11 03:57:23 EST
(In reply to comment #1)
> (In reply to comment #1)
> > #ip link set dev eth1 vf 0 mac 00.11.22.33.44.55
> > 
> 
> What does it change to in the VM?

nothing happens to the VM if I set the mac address while the VM is running. Even if I restart the network, the VM keep its old Mac address.
Comment 4 Christian Beltrame 2011-09-10 17:31:55 EDT
Hello, 

I am a begginer with Linux. I apologize that my comment is about Centos 6 but I hope it is usefull.

I have been fighting with this bug for a week. I am using an AMD Opteron CPU with an Intel E1G42ET Dual Port NIC. I am using Centos 6.0 and KVM, kernel 2.6.32-71.el6.x86_64 (newer Kernel has issues with LSI card).

I repeated the issue several times but it seemed to dissapear after I did this:

- KVM HOST: With VMs running or not, I modified the MAC of all teh VFs using the command in the first post
- VM: I edited /etc/udev/rules*/70-persistent-net.rules to remove references to the 82576 VFs
- KVM HOST: Restarted libvirtd
- KVM HOST: Verified that the new MACs were still correct with ip link show dev eth0
- VMs: Rebooted all active VMs
- KVM HOST: After VMs were up, verified the new MACs were still correctly assigned to the VFs
- VMs: Verified 

I rebooted the VMs and also shut them down and restarted several times and the issue is gone. 
I will verify what happens when I reboot the host. I assume that I will get some random MACs so I will reassign the new MACs and RESTART libvirtd before I start any VM.

I will let you know what happens in another post.
Have a great day.
Comment 5 Christian Beltrame 2011-09-10 17:53:08 EDT
Hello, 

It looks like it is working for me.

I restarted the host, modified the VF MACs, restarted libvirtd, and then started the VM and the MACs are the same as before.

In the future, I will have to research whether there is a way to permanently set the MACs to the nic or the driver.

Thank you
Comment 6 Christian Beltrame 2011-09-10 17:56:09 EDT
(In reply to comment #3)
> (In reply to comment #1)
> > (In reply to comment #1)
> > > #ip link set dev eth1 vf 0 mac 00.11.22.33.44.55
> > > 
> > 
> > What does it change to in the VM?
> 
> nothing happens to the VM if I set the mac address while the VM is running.
> Even if I restart the network, the VM keep its old Mac address.

It looks like libvirtd keeps the old MACs in memory and reuse then when the VM is rebooted. That is what seems to happen in my host.

Restarting libvirtd seemed to fix it

Hope it helps.
Regards,
Comment 7 Laine Stump 2011-09-14 12:41:56 EDT
I can't explain why "restarting libvirtd seemed to fix it", but it isn't because of libvirtd remembering a MAC address; when a network device is assigned to a virtual guest via PCI passthrough, libvirt doesn't have any idea that it is a network device, and thus doesn't even know that there's a MAC address associated with the device.

Also, I'm curious what the entries in the udev file were for the VFs. I don't have any of this hardware, but I had understood that the VFs are given a new random MAC address on each reboot...

There has been some discussion about making libvirt's <hostdev> (PCI passthrough) aware of info normally associated with network interfaces (e.g. mac address and <virtualport> parameters), which might solve this problem. For example:

https://www.redhat.com/archives/libvir-list/2011-August/msg00937.html

(note that the proposal in that particular mail won't work, for the reasons given in the followups, but a future followup may point to an acceptable design.)
Comment 8 Christian Beltrame 2011-09-14 13:32:02 EDT
(In reply to comment #7)
> I can't explain why "restarting libvirtd seemed to fix it", but it isn't
> because of libvirtd remembering a MAC address; when a network device is
> assigned to a virtual guest via PCI passthrough, libvirt doesn't have any idea
> that it is a network device, and thus doesn't even know that there's a MAC
> address associated with the device.
> 
> Also, I'm curious what the entries in the udev file were for the VFs. I don't
> have any of this hardware, but I had understood that the VFs are given a new
> random MAC address on each reboot...
> 
> There has been some discussion about making libvirt's <hostdev> (PCI
> passthrough) aware of info normally associated with network interfaces (e.g.
> mac address and <virtualport> parameters), which might solve this problem. For
> example:
> 
> https://www.redhat.com/archives/libvir-list/2011-August/msg00937.html
> 
> (note that the proposal in that particular mail won't work, for the reasons
> given in the followups, but a future followup may point to an acceptable
> design.)

Laine, 

Thank you very much for your reply.
Please let me know if there is any file in my system that would give you more information and I will post it.
The workaround has been working fine for me. I haven't yet made the script run upon startup because I like to see how the system is configured before and after I run it.
BTW, you are right in that every time I reboot the MAC are completely different. That became an issue because my Linux guests could not find the NICs as a new eth nic was created for each MAC.

I apologize that I can not be more helpful. I am fairly new in Linux.
Please let me know what info you need and I will get it.

Regards,
Comment 9 Fedora Admin XMLRPC Client 2011-09-22 13:58:23 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 10 Fedora Admin XMLRPC Client 2011-09-22 14:02:04 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 11 Fedora Admin XMLRPC Client 2011-11-30 14:58:15 EST
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 12 Fedora Admin XMLRPC Client 2011-11-30 14:59:16 EST
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 13 Fedora Admin XMLRPC Client 2011-11-30 15:04:25 EST
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 14 Fedora Admin XMLRPC Client 2011-11-30 15:04:54 EST
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 15 Cole Robinson 2012-01-24 17:36:12 EST
Sorry for not addressing this bug, but F14 is EOL now, so I'm closing this
report. Please reopen if this is still relevant in a more recent fedora.
Comment 16 Laine Stump 2012-01-25 08:14:53 EST
I'm again working on a solution for this, hopefully to be in F17.
Comment 17 Laine Stump 2012-02-20 15:26:21 EST
Here is a patch submitted upstream to support parsing/formatting <interface> devices of type='hostdev':

  https://www.redhat.com/archives/libvir-list/2012-February/msg00841.html

These devices will be treated just like <hostdev> devices, except that during attach time the mac address (and virtual port profile info) will be set by the host before assigning the device to the guest.

The low level code is on the way, too. Please comment on the config format in the mailing list thread.
Comment 18 Laine Stump 2012-02-29 15:11:55 EST
I've updated my patches to properly present the PCI device to the guest if it's
defined as <interface type='hostdev'>. This completes all the basic infrastructure functionality, including hotplug attach/detach. All that is left now is the callouts from the hostdev code to save/set/restore mac address.

These patches are available either frmo the list archives:

  https://www.redhat.com/archives/libvir-list/2012-February/msg01126.html

or from a public repo on gitorious:

  git://gitorious.org/~laine/libvirt/laine-staging.git

The code in question is on the "passthrough8" branch. You should be able
to get that branch into your local repo like this:

  git remote add laine-staging \
      git://gitorious.org/~laine/libvirt/laine-staging.git
  git fetch laine-staging
  git checkout laine-staging/passthrough8
Comment 19 Laine Stump 2012-03-06 07:55:04 EST
A 21 patch series to add this functionality has been pushed upstream 

Upstream commit ids in order (short form):

9890b31 conf: add missing device types to virDomainDevice(Type|Def)
4ec60df conf: relocate virDomainDeviceDef and virDomainHostdevDef
fdad9c3 conf: reorder static functions in domain_conf.c
37038d5 qemu: rename virDomainDeviceInfoPtr variables to avoid confusion
2f925c6 conf: add device pointer to args of virDomainDeviceInfoIterate callback
2929393 conf: make hostdev info a separate object
5560170 conf: HostdevDef parse/format helper functions
b973f92 conf: give each hostdevdef a parent pointer
3175df8 conf: put subsys part of virDomainHostdevDef into its own struct
cc5b1fe conf: hostdev utility functions
6fbb957 qemu: re-order functions in qemu_hotplug.c
93870c4 qemu: refactor hotplug detach of hostdevs
3b1c191 conf: parse/format type='hostdev' network interfaces
8639a42 qemu: support type='hostdev' network devices at domain start
ac9ca01 conf: change virDomainNetRemove from static to global
16520d6 qemu: use virDomainNetRemove instead of inline code
cf90342 qemu: support type=hostdev network device live hotplug attach/detach
b8b7027 util: two new pci util functions
5095bf0 util: support functions for mac/portprofile associations on hostdev
15bbfd8 util: Changes to support portprofiles for hostdevs
ce43483 qemu: install port profile and mac address on netdev hostdevs
Comment 20 Laine Stump 2012-03-07 10:37:46 EST
For future reference, these patches will all be in libvirt-0.9.11

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