17.06.2015 16:38, Laine Stump пишет:
On 06/17/2015 08:35 AM, Mikhail Feoktistov wrote:
> Let network adapter use DHCP server to get network configuration.
> To do this we use PrlVmDevNet_SetConfigureWithDhcp to enable it and
> PrlVmDevNet_SetAutoApply to makes necessary settings within guest OS
> In linux case it creates network startup scripts
> /etc/sysconfig/network-scripts/ifcfg-ethN and fills it with necessary
> parameters.
(sorry for getting a bit off-topic)
The semantics of this are different for qemu - attaching a network
device only presents the hardware to the virtual machine; it doesn't
attempt to make any configuration changes in the guest OS. I *think*
that the xen and lxc drivers do configure the guest though (at least
they pay attention to the <ip> element in the <interface>). So this
isn't any criticism of your implementation, I'm just wondering whether
or not this will make a difference to any management apps using libvirt.
(actually this also brings to mind an idle thought I've had for awhile -
while it's possible to configure an IP address for a qemu guest from the
libvirt configuration in some cases (when the guest interface is
connected to a libvirt virtual network, you can add a static IP entry to
the network's dhcp config), it might be nice to recognize the <ip>
element in the <interface>, and use it to dynamically add a static IP
entry to the dnsmasq instance for the attached network. Does anyone have
an opinion on whether that would be useful/ugly/confusing?)
I think it could be
useful. Actually, I intended to make a comment to
this patch that we
should pay attention to <ip> element in the <interface> and set DHCP
only if address
isn't configured explicitly, otherwise we should call
PrlVmDevNet_SetNetAddresses
which will interact with guest tools (if any) and set specified IP
addresses with help
of guest agent.
As for automatic dnsmasq configuration it could be useful too if guest
agent is
absent. But I wonder, wouldn't this contradict with OpenStack usecase,
for example,
when dnsmasq is configured with certain IP addresses and other network
parameters, and
nothing is specified in libvirt config regarding adapter configuration?
> ---
> src/vz/vz_sdk.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
> index 98f7a57..090a3ad 100644
> --- a/src/vz/vz_sdk.c
> +++ b/src/vz/vz_sdk.c
> @@ -2815,6 +2815,12 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom,
> pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
> prlsdkCheckRetGoto(pret, cleanup);
>
> + pret = PrlVmDevNet_SetConfigureWithDhcp(sdknet, true);
> + prlsdkCheckRetGoto(pret, cleanup);
> +
> + pret = PrlVmDevNet_SetAutoApply(sdknet, true);
> + prlsdkCheckRetGoto(pret, cleanup);
> +
> if (isCt) {
> if (net->model)
> VIR_WARN("Setting network adapter for containers is not "