Depois de um diskussion na Mailinglist eu descobri: isso atualmente não é possível!
Estou usando o libvirt e o kvm para virtualizar meu servidor. Eu configurei o libvirt para iniciar um dhcp-server na bridge-network-interface para dar ao vm seus ips. Toda VM's recebe sempre o mesmo ip baseado em seu mac, isso é configurado assim:
<dhcp>
<range start='10.1.1.2' end='10.1.1.254' />
<host mac='54:52:00:21:01:ba' name='virstvm' ip='10.1.1.10' />
<host mac='00:16:36:2d:71:f9' name='secvm' ip='10.1.1.20' />
</dhcp>
O problema: Sempre que eu adiciono um novo host na seção dhcp eu tenho que reiniciar o libvirt-bin que reinicia todos os meus vm's . Isso não pode ser a solução, porque significa um tempo de inatividade toda vez que eu adiciono um novo servidor. Existe uma solução?
O comando net-update adicionado no virsh deve permitir uma atualização do dhcp-host sem reiniciar a rede virtual (ainda não testei).
man virsh:
net-update network command section xml [--parent-index index] [[--live] [--config] | [--current]]
Update the given section of an existing network definition, with the changes optionally taking effect immediately, without needing to destroy and re-start the network.
command is one of "add-first", "add-last", "add" (a synonym for add-last), "delete", or "modify".
section is one of "bridge", "domain", "ip", "ip-dhcp-host", "ip-dhcp-range", "forward", "forward-interface", "forward-pf", "portgroup", "dns-host", "dns-txt", or "dns-srv", each section being named by a concatenation of the xml element hierarchy leading to the element being changed. For example, "ip-dhcp-host" will change a
<host>
element that is contained inside a<dhcp>
element inside an<ip>
element of the network.xml is either the text of a complete xml element of the type being changed (e.g. "<host mac="00:11:22:33:44:55' ip='1.2.3.4'/>", or the name of a file that contains a complete xml element. Disambiguation is done by looking at the first character of the provided text - if the first character is "<", it is xml text, if the first character is not "<", it is the name of a file that contains the xml text to be used.
The --parent-index option is used to specify which of several parent elements the requested element is in (0-based). For example, a dhcp
<host>
element could be in any one of multiple<ip>
elements in the network; if a parent-index isn't provided, the "most appropriate"<ip>
element will be selected (usually the only one that already has a<dhcp>
element), but if --parent-index is given, that particular instance of<ip>
will get the modification.If --live is specified, affect a running network. If --config is specified, affect the next startup of a persistent network. If --current is specified, affect the current network state. Both --live and --config flags may be given, but --current is exclusive. Not specifying any flag is the same as specifying --current.
O seguinte procedimento funcionou para mim com libvirt Versão: 0.7.5-5ubuntu27 em um host LTS do Ubuntu 10.04.4:
virsh net-dumpxml default > default.xml
$EDITOR default.xml
virsh net-destroy default
virsh net-define default.xml
virsh net-start default
Isso também funciona para outras redes além da rede padrão. Apenas substituir a palavra default no exemplo com o nome da rede.
@ A solução de pefu fez isso também para o CentOS 6.4!
O uso de net-edit
em virsh
não atualizou o arquivo XML em /var/lib/libvirt/network/default.xml
nem alterou o estado da configuração de rede em execução.
A reexecução de net-edit
mostrou a versão editada mesmo depois de uma reinicialização, mas ela não foi carregada!
Exportando para um arquivo XML real, editá-lo e recarregá-lo funciona!
Eu acho que o libvirt usa o dnsmaq para seu servidor dhcp. Talvez você pudesse apenas reiniciar o dnsmasq e tudo estaria bem?