Created attachment 927046 [details]
The log of virt-install to build rhel-6-x86_64 guest w/o my patch
Description of problem:
virt-install does not look generating random mac addresses for guest's
nics before starting its installation process, just before the message
'Generated install XML:'; more precisely, just before the line "start_xml, final_xml = self._build_xml(is_initial)" in virtinst.Guest.start_install(),
when macaddr for nic of guest was not specified or RANDOM was specified
such as --network=default,model=virtio,mac=RANDOM.
As a result, guest will have 2 nics; one has a random address given and
used during the installation process and another one will be assigned
by libvirt or qemu or virt-install after installation was completed.
Please look at the logs, rhel-6-client-1.build.log and rhel-6-client-1.login.log, also.
(1) In rhel-6-client-1.build.log,
a. I specify --network network=default,model=virtio,mac=RANDOM option
to generate random mac address for 2nd nic of the guest to build.
b. 2nd network interface (install xml seen after the 'Generated
install XML' log message) does not have a <mac/> element.
(and I guess libvirt or virt-install will assign a random mac
for this nic in the back.)
c. boot XML looks same; no mac address def. for the 2nd nic of the guest.
d. 2nd nic has a <mac/> element in XML desc fetched from libvirt.
(2) rhel-6-client-1.login.log is the login session log of the guest built.
a. The guest have the nic eth2 instead of eth1.
b. There is a ifcfg-eth1 in /etc/sysconfig/network-scripts/ and
the mac address in that file is different from the one of eth2.
That is, there is a nic during installation (eth1) and it was
disappeared after installation, and new nic (eth2) was added
after that from the point of view of this guest, I guess.
After my patch described later was applied, this issues looks resolved
like the followings:
(1) rhel-6-client-1.build.after-patched.log shows the mac address of the 2nd nic
of the guest is consistent in install, boot XML and XML desc. from libvirt.
(2) rhel-6-client-1.login.after-patched.log shows that there is no eth2.
Version-Release number of selected component (if applicable):
Confirmed this issue w/ the source of git master HEAD version of virt-manager
and the latest one in F20, virt-install-1.0.1-3.fc20.noarch.
How reproducible: Always
Steps to Reproduce:
1. run virt-install w/ the option --network ...,mac=RANDOM or not set macaddr
2. boot the installed guest; there should be a nic different from the one used during the installation process
Mac addresses of the guest's nic present during installation process and
the one after installation looks different.
Both are same; there is no eth2.
I'll attach an experimental patch tyring to generate random mac address and
set it explicitly just before the installation process starts to fix this issue.
As far as I tested, it looks worked well.
Created attachment 927047 [details]
A login session log of the guest
Created attachment 927048 [details]
The log of virt-install to build rhel-6-x86_64 guest after my patch applied
Created attachment 927049 [details]
A login session log of the guest built with virt-install my patch was applied
Created attachment 927052 [details]
An experimental patch for virt-install to generate and set random mac just before installation process starts
This is an experimental patch for virt-manager (git master branch HEAD version
of today) to generate and set random mac address to nics if it's not set
just before installation process starts.
I confirmed it is also applicable to the latest version of F20's virt-install,
virt-install-1.0.1-3.fc20.noarch, and works as expected.
Thanks for the detailed report, however the real issue here is that when mac=RANDOM is set, we override VirtualInterface.macaddr rather than just leaving it unset. That's why --network network=default will do the right thing and generate a MAC, while --network network=default,mac=RANDOM will do the wrong thing.
I've fixed this upstream now:
Author: Cole Robinson <email@example.com>
Date: Fri Aug 15 15:02:57 2014 -0400
cli: Don't rely on libvirt to generate MAC if mac=RANDOM (bz 1130449)
Oh, i see. I'm not sure libvirt (or linux kenrel, qemu or something other than
virt-install) does generate random mac address for such nics but it looks so.
Anyway, thanks for your quick fix!