Hello,

Looking through the code (around client/virt/kvm_vm.py:589).  I think 
what you're needing is called user-mode networking and the dhcpstart 
option for qemu-kvm.  That will enable qemu's built-in dhcp server and 
allow you to populate it with IPs and not have to worry about setting 
the mac.  You need the run_tcpdump so that autotest can catch the 
address assignment for test-access.  So, I'm thinking something along 
these lines should work:

run_tcpdump = yes
nic_mode = user
netdev_extra_params = "dhcpstart=172.16.1.127,dns=whatever,net=addr[/mask]"

Hopefully that helps, or at least gets you moving in the right direction.

On 12/15/2011 11:53 AM, Kristóf Katus wrote:
> 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?
>
> 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?
> - What is the best way to enforce the framework to catch a previously
> provided IP address in the config files?
>
>
> Thanks,
>
> Kristóf
> _______________________________________________
> Autotest mailing list
> [email protected]
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest


-- 
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to