Bug 1130449 - [PATCH] virt-install does not looks generating random mac address as expected before installation process starts
Summary: [PATCH] virt-install does not looks generating random mac address as expected...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: virt-manager
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: Cole Robinson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-15 09:23 UTC by Satoru SATOH
Modified: 2014-08-17 05:44 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-15 19:05:27 UTC


Attachments (Terms of Use)
The log of virt-install to build rhel-6-x86_64 guest w/o my patch (17.63 KB, text/x-log)
2014-08-15 09:23 UTC, Satoru SATOH
no flags Details
A login session log of the guest (3.51 KB, text/plain)
2014-08-15 09:25 UTC, Satoru SATOH
no flags Details
The log of virt-install to build rhel-6-x86_64 guest after my patch applied (17.02 KB, text/plain)
2014-08-15 09:26 UTC, Satoru SATOH
no flags Details
A login session log of the guest built with virt-install my patch was applied (1.90 KB, text/plain)
2014-08-15 09:27 UTC, Satoru SATOH
no flags Details
An experimental patch for virt-install to generate and set random mac just before installation process starts (577 bytes, patch)
2014-08-15 09:34 UTC, Satoru SATOH
no flags Details | Diff

Description Satoru SATOH 2014-08-15 09:23:31 UTC
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.
    It shows:

    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


Actual results:
Mac addresses of the guest's nic present during installation process and
the one after installation looks different.

Expected results:
Both are same; there is no eth2.


Additional info:
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.

Comment 1 Satoru SATOH 2014-08-15 09:25:01 UTC
Created attachment 927047 [details]
A login session log of the guest

Comment 2 Satoru SATOH 2014-08-15 09:26:29 UTC
Created attachment 927048 [details]
The log of virt-install to build rhel-6-x86_64 guest after my patch applied

Comment 3 Satoru SATOH 2014-08-15 09:27:55 UTC
Created attachment 927049 [details]
A login session log of the guest built with virt-install my patch was applied

Comment 4 Satoru SATOH 2014-08-15 09:34:22 UTC
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.

Comment 5 Cole Robinson 2014-08-15 19:05:27 UTC
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:

commit d1f46a75e70e99eb4bf16e99300556689008eaf6
Author: Cole Robinson <crobinso@redhat.com>
Date:   Fri Aug 15 15:02:57 2014 -0400

    cli: Don't rely on libvirt to generate MAC if mac=RANDOM (bz 1130449)

Comment 6 Satoru SATOH 2014-08-17 05:44:05 UTC
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!


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