On 12/14/2016 03:53 AM, Joao Martins wrote:
libvirt libxl picks its own default with respect to the default NIC
to use. libxlMakeNic is the one responsible for this and on boot it
picks LIBXL_NIC_TYPE_VIF_IOEMU for HVM domains such that it accomodates
both PV and emulated one. The good behaving guest at boot will then
select the pv and unplug the emulated device.
Now, on HVM when attaching an interface it will pick the same default
that is LIBXL_NIC_TYPE_VIF_IOEMU which as a result will fail the attach
(see xen commit 32e9d0f ("libxl: nic type defaults to vif in hotplug for
hvm guest"). Xen doesn't yet support the hotplug of emulated devices,
but we don't want to rule out that case either, which might get support
in the future. Hence we simply reverse the defaults when we are
attaching the interface which allows libvirt to prefer the PV nic first
without adding "model='netfront'" following the same pattern as above
commit. Also to avoid ruling out the emulated one we set to
LIBXL_NIC_TYPE_IOEMU when setting a model type that is not 'netfront'.
Signed-off-by: Joao Martins <joao.m.martins(a)oracle.com>
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
Since RFC:
- Joao: Add mention to HVM domains in the first paragraph of commit
message.
- Jim: Add comment about libxl_device_nic type inner workings
- Jim: Prevent attach on PV when model != netfront
- Joao: Remove now unused ioemu_nic variable
- Joao: Append one small paragraph about why we mimic xl/libxl
---
src/libxl/libxl_conf.c | 39 +++++++++++++++++++++++++++++++--------
src/libxl/libxl_conf.h | 3 ++-
src/libxl/libxl_driver.c | 2 +-
3 files changed, 34 insertions(+), 10 deletions(-)
ACK and pushed.
Regards,
Jim