uvt-kvm: error: no IP address found for libvirt machine

Bug #1428674 reported by Jorge Niedbalski
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
uvtool (Ubuntu)
Fix Released
High
Robie Basak

Bug Description

[Background]

Since libvirt v1.2.11 though, it adds --leasefile-ro which stops it updating the dnsmasq lease file and makes libvirt store the leases itself, so uvt-kvm can no longer find the IP address allocated to the new VM as the old lease file's not updated.

2014-12-03 Nehal J Wani <email address hidden>

    leaseshelper: improvements to support all events
        This patch enables the helper program to detect event(s) triggered when
there is a change in lease length or expiry and client-id. This
         transfers complete control of leases database to libvirt and obsoletes
        use of the lease database file (<network-name>.leases). That file will
        not be created, read, or written. This is achieved by adding the option
        --leasefile-ro to dnsmasq and passing a custom env var to leaseshelper,
        which helps us map events related to leases with their corresponding
        network bridges, no matter what the event be.

[System]
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu Vivid Vervet (development branch)
Release: 15.04
Codename: vivid

ii uvtool-libvirt 0~bzr92-0ubuntu2 all Library and tools for using Ubuntu Cloud Images with libvirt

[Reproduce]

$ uvt-kvm create precise release=precise
$ uvt-kvm wait precise
uvt-kvm: error: libvirt domain 'precise' has no NIC MACs available.
$ uvt-kvm ip precise

[Others]

[1]:niedbalski@theos-mobile:~:> cat /var/lib/libvirt/dnsmasq/default.hostsfile
[0]:niedbalski@theos-mobile:~:> cat /var/lib/libvirt/dnsmasq/default.leases
[0]:niedbalski@theos-mobile:~:> cat /var/lib/libvirt/dnsmasq/virbr0.status
[
    {
        "ip-address": "192.168.122.100",
        "mac-address": "52:54:00:33:d2:45",
        "hostname": "ubuntu",
        "expiry-time": 1425569970
    },
    {
        "ip-address": "192.168.122.237",
        "mac-address": "52:54:00:67:03:38",
        "hostname": "ubuntu",
        "expiry-time": 1425570362
    }
]

Related branches

description: updated
description: updated
Revision history for this message
Jorge Niedbalski (niedbalski) wrote :

sudo VIR_BRIDGE_NAME=virbr0 /usr/lib/libvirt/libvirt_leaseshelper init

1425571755 52:54:00:67:03:38 192.168.122.237 ubuntu *
1425569970 52:54:00:33:d2:45 192.168.122.100 * *

Also another way for getting this:

arp -n | grep $mac | cut -d' ' -f 1

Or by reading /proc/net/arp

Changed in uvtool (Ubuntu):
assignee: nobody → Jorge Niedbalski (niedbalski)
importance: Undecided → High
status: New → In Progress
Changed in uvtool (Ubuntu):
status: In Progress → Fix Committed
status: Fix Committed → In Progress
Robie Basak (racb)
Changed in uvtool (Ubuntu):
milestone: none → ubuntu-15.04
Revision history for this message
Robie Basak (racb) wrote :

Thank you for reporting this and for the merge proposal. Unfortunately it breaks "uvt-kvm wait" though, since that command uses inotify against the same file.

I think reading /proc/net/arp is fine as a fallback, but there is no guarantee that the VM will have an entry in the host's arp cache at the time that "uvt-kvm ip" is needed, so we can't rely on this.

It looks like libvirt's "leaseshelper" maintains /var/lib/libvirt/dnsmasq/virbr0.status in a similar manner to default.leases was maintained by dnsmasq before, so can we use this instead? Then we can just inotify on that for "uvt-kvm wait" when it is available, instead of default.leases.

So I think that the logic should be:

Look for /var/lib/libvirt/dnsmasq/virbr0.status. If it exists, check it, and if not present, inotify on it and check it again. If it does not exist, fall back to /var/lib/libvirt/dnsmasq/default.leases with the same behaviour. If that does not exist, fall back to /proc/net/arp. Perhaps we should also fall back if the file did exist but the entry was not found, though that needs some thinking for maintaining active inotify waits on both files at once.

This way we'll cover both "uvt-kvm wait" and "uvt-kvm ip" as well as be easily backportable to previous releases. Any objections to this approach?

Jorge: I'll go ahead and start to implement this tomorrow. Or if you'd like to do it, let me know.

Robie Basak (racb)
Changed in uvtool (Ubuntu):
assignee: Jorge Niedbalski (niedbalski) → Robie Basak (racb)
Revision history for this message
Robie Basak (racb) wrote :

Fixed in upstream rev 93.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package uvtool - 0~bzr99-0ubuntu1

---------------
uvtool (0~bzr99-0ubuntu1) vivid; urgency=medium

  * New upstream snapshot (bugfixes only):
    - Also use libvirt's virbr0.status for IP scan (LP: #1428674).
    - Fix wait when guest is systemd.
    - Document --backing-image-file in the manpage (LP: #1317266).
      Thanks to Louis Bouchard.
    - Do not recommend libnss-mdns (LP: #1357400).
    - Fix --user-data typo in manpage (LP: #1401749). Thanks to David
      Medberry.
    - ssh: fix error message when guest is not ready (LP: #1303877).
 -- Robie Basak <email address hidden> Mon, 13 Apr 2015 17:41:34 +0100

Changed in uvtool (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.