[libvirt-users] How allocate ip for guest in xml file

Laine Stump laine at redhat.com
Tue Apr 17 13:20:35 UTC 2018


On 04/17/2018 02:42 AM, llilulu wrote:
> Hi:
>   I encounter a promble when I use libvirt manager my virtual machine. I
> use dhcp allocate IP for my guest, but use dhcp manager IP source, I
> will ensure guest run NetworkManager auto start NIC in dhcp type get IP.
> But some release system no install NetworkManager, or some installed
> system no install NetworkManager, so when I manager those guest, I
> cann't allocate IP for guest via dhcp server. I want know has other way
> allocate ip for guest in guest xml file when create the guest, I search
> "libvirt domain xml format", I find use blow xml configuration in
> <interface/>*
>                       <ip address='192.168.122.5' prefix='24'/>
> *But I add this in my guest xml file, virsh create guest will report an
> error:
>                        "error: unsupported configuration: Invalid
> attempt to set network interface guest-side IP route and/or address
> info, not supported by QEMU"
> I want to know if I use dhcp allocate IP for guest, has some way auto
> start guest dhclinet when guest start(because NIC can hotplug, I cann't
> write NIC configure file for it). or I want configure IP for guest in
> guest xml file,How cant I do? my libvirt version is 3.4.0, qemu is
> 2.9.0. I compile libvirt and qemu myself, when compile its run
> ./configure script without specific args. If I want qemu or libvirt
> support configure IP in guest xml file, how I compile libvirt and qemu?

Configuration of the guest's IP from the domain XML (via <ip
address='blah'/> in the <interface> is only supported for Xen and LXC,
because they are the only drivers where libvirt is given the opportunity
to directly set the IP address of the guest.

For QEMU, neither libvirt nor qemu has any visibility into the guest's
IP configuration. The best they can do is provide a dhcp server on the
network connection and hope that the guest requests and IP address via
DHCP. For that reason, <ip address='blah'/> in <interface> isn't
supported for QEMU domains.

If you have knowledge of how the IP address configuration is stored in
the guest OS' file system, you can use the libguestfs tools to modify
the proper file in the guest disk image, but setting it via the libvirt
domain XML simply isn't possible.




More information about the libvirt-users mailing list