----- Original Message -----
> Hi there,
> 
> how can you elegantly assign a static IP address to a NIC with a
> fixed MAC
> address in the latest kvm autotest module?

Hi Kristóf,

You can only assign fixed MAC in config file.
static IP is not supported.

However, 'static IP' support is necessary, what we need to do is adding ip&mac
record to vm.address_cache when init the guest.


> I need to set up a guest virtual machine with a fixed MAC and static
> IP
> address between tests.
> 
> The guest OS is configured with a static IP address. Initially I
> tried the
> nic_mac parameter, and it indeed sets the MAC properly, but the
> autotest
> framework just does not catch the corresponding IP address.
> 
> I get "Could not verify DHCP lease: 9a:75:34:e5:b8:79 -->
> 172.16.2.112"
> messages, the IP is always something that does not make any sense,
> although the IP is statically set in the guest to "172.16.1.127".
> During a
> test run I can ping the guest with this latter one.
> 
> The NIC parameters are:
> 
> nic_mode = tap
> bridge = br0
> run_tcpdump = yes
> nic_mac = 9a:75:34:e5:b8:79
> 
> 
> I figured out the following workaround:
> 1) Disabled tcpdump: "run_tcpdump = no"
> 2) Edited the "env" file in "autotest/client/tests/kvm/", namely:
> searched for
> my guest MAC and replaced one of the following lines, that contained
> an IP
> address to my static IP address
> 
> This way executing tests just work fine. But I still have the feeling
> that it
> should not be the right solution, and I did not find any IP address
> related
> paramaters.
> 
> I am not familiar with the code base, but I tried to check the git
> tree. It
> seems that previously kvm autotest had some kind of manual mapping
> mechanism along with a dynamic one, e.g. see:
> 
> 2009-08-13 06:05:47 commit bc0e41f85fa55ed38d986f919486f198def36068
> (KVM test: add some MAC/IP address utilities to kvm_utils)
> 
> 2009-08-13 06:12:19 commit
> bd45a92e7dd6fe6825d1a42cda767425122a9762 (KVM test: make VMs use a
> dynamic MAC-IP mapping generated by tcpdump)
> 
> 
> Then later on the old code was removed:
> 
> 2010-10-27 14:09:47 commit ccc7ac44337a3d2a7a86893876f91717e0c2f7f9
> (KVM test: simplify MAC address management)
> 
> 2010-10-27 14:20:49 commit cfb012dd8ad7f0880d79ff9104acb5754f0e0a63
> (KVM test: VM.get_address(): fix handling of multiple NICs)
> 
> 2010-10-27 14:29:00 commit 681a37be663607231a1fa8b4a644a90da129f711
> (KVM test: remove all code related to the old MAC address pool
> method)
> -- The commit message here mentions: "Note that now running in TAP
> mode
> requires an external DHCP server that accepts *any* MAC address,
> because
> MAC addresses are randomly generated and cannot be manually
> configured."
> 
> 
> But then the nic_mac setting is added:
> 
> 2010-12-20 22:15:15 commit 6161e80bf9da191bfaebcc53776b438d0b0f0e16
> (KVM test: kvm_vm: Allow NIC MACs to be defined on config file)
> 
> 
> And then the bridge setup was automatized:
> 
> 2011-06-06 19:17:25 commit
> 0e78eaac9942611dbe589978401b78b81e270661 (KVM test: Adding
> framework code to control bridge creation)
> 
> 
> My questions here are the following:
> - Why was this manual address mapping completely removed?

We need to run autotest clients in public bridge (not only userspace net, 
private bridge)
So we need use unique mac for each guests. The default mac is computed by 
virt_utils.generate_mac_address()

> - What is the best way to enforce the framework to catch a previously
> provided IP address in the config files?

If we provide the same "mac_source" to create vm, new guest will use same macs 
as old guest.
vm.create():
        @param mac_source: A VM object from which to copy MAC addresses. If not
                specified, new addresses will be generated.


Thanks, Amos
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to