For a network with <forward mode='hostdev', there is a need to add the newly minted hostdev to the hostdevs array. In this case we also call qemuPrepareHostDevicesas it has already been called by the time we get to here and are building the qemu commandline Signed-off-by: Shradha Shah <sshah@xxxxxxxxxxxxxx> --- src/qemu/qemu_command.c | 39 +++++++++++++++++++++++++++++++++------ 1 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6f6c6cd..1470edd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -24,6 +24,7 @@ #include <config.h> #include "qemu_command.h" +#include "qemu_hostdev.h" #include "qemu_capabilities.h" #include "qemu_bridge_filter.h" #include "cpu/cpu.h" @@ -5221,12 +5222,38 @@ qemuBuildCommandLine(virConnectPtr conn, actualType = virDomainNetGetActualType(net); if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { - /* type='hostdev' interfaces are handled in codepath - * for standard hostdev (NB: when there is a network - * with <forward mode='hostdev', there will need to be - * code here that adds the newly minted hostdev to the - * hostdevs array). - */ + if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) { + virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net); + virDomainHostdevDefPtr found; + /* For a network with <forward mode='hostdev', there is a need to + * add the newly minted hostdev to the hostdevs array. + */ + if (qemuAssignDeviceHostdevAlias(def, hostdev, + (def->nhostdevs-1)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not assign alias to Net Hostdev")); + goto error; + } + + if (virDomainHostdevFind(def, hostdev, &found) < 0) { + if (virDomainHostdevInsert(def, hostdev) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Hostdev not inserted into the array")); + goto error; + } + if (qemuPrepareHostdevPCIDevices(driver, def->name, def->uuid, + &hostdev, 1) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Prepare Hostdev PCI Devices failed")); + goto error; + } + } + else { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("The Hostdev is being used by some other device")); + goto error; + } + } continue; } -- 1.7.4.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list