static int
qemuInitCgroup(virQEMUDriverPtr driver,
- virDomainObjPtr vm)
+ virDomainObjPtr vm,
+ size_t nnicindexes,
+ int *nicindexes)
{
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
NULL,
vm->pid,
false,
- 0, NULL,
+ nnicindexes, nicindexes,
vm->def->resource->partition,
cfg->cgroupControllers,
&priv->cgroup) < 0) {
int
qemuSetupCgroup(virQEMUDriverPtr driver,
- virDomainObjPtr vm)
+ virDomainObjPtr vm,
+ size_t nnicindexes,
+ int *nicindexes)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virCapsPtr caps = NULL;
return -1;
}
- if (qemuInitCgroup(driver, vm) < 0)
+ if (qemuInitCgroup(driver, vm, nnicindexes, nicindexes) < 0)
return -1;
if (!priv->cgroup)
/* If we don't know VCPU<->PID mapping or all vcpu runs in the same
* thread, we cannot control each vcpu.
*/
- VIR_WARN("Unable to get vcpus' pids.");
return 0;
}
int qemuConnectCgroup(virQEMUDriverPtr driver,
virDomainObjPtr vm);
int qemuSetupCgroup(virQEMUDriverPtr driver,
- virDomainObjPtr vm);
+ virDomainObjPtr vm,
+ size_t nnicindexes,
+ int *nicindexes);
int qemuSetupCpusetMems(virDomainObjPtr vm);
int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
unsigned long long period,
virDomainNetDefPtr net,
virQEMUCapsPtr qemuCaps,
int *tapfd,
- size_t *tapfdSize)
+ size_t *tapfdSize,
+ int *nicindex)
{
const char *brname;
int ret = -1;
virDomainAuditNetDevice(def, net, tunpath, false);
goto cleanup;
}
+ if (virNetDevGetIndex(net->ifname, nicindex) < 0)
+ goto cleanup;
if (virDomainNetGetActualBridgeMACTableManager(net)
== VIR_NETWORK_BRIDGE_MAC_TABLE_MANAGER_LIBVIRT) {
/* libvirt is managing the FDB of the bridge this device
int vlan,
int bootindex,
virNetDevVPortProfileOp vmop,
- bool standalone)
+ bool standalone,
+ int *nicindex)
{
int ret = -1;
char *nic = NULL, *host = NULL;
virNetDevBandwidthPtr actualBandwidth;
size_t i;
+ *nicindex = -1;
+
if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)
return qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps);
memset(tapfd, -1, tapfdSize * sizeof(tapfd[0]));
if (qemuNetworkIfaceConnect(def, driver, net,
- qemuCaps, tapfd, &tapfdSize) < 0)
+ qemuCaps, tapfd,
+ &tapfdSize, nicindex) < 0)
goto cleanup;
} else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) {
if (VIR_ALLOC(tapfd) < 0 || VIR_ALLOC(tapfdName) < 0)
qemuBuildCommandLineCallbacksPtr callbacks,
bool standalone,
bool enableFips,
- virBitmapPtr nodeset)
+ virBitmapPtr nodeset,
+ size_t *nnicindexes,
+ int **nicindexes)
{
virErrorPtr originalError = NULL;
size_t i, j;
virUUIDFormat(def->uuid, uuid);
+ *nnicindexes = 0;
+ *nicindexes = NULL;
+
emulator = def->emulator;
if (!cfg->privileged) {
else
vlan = i;
+ if (VIR_EXPAND_N(*nicindexes, *nnicindexes, 1) < 0)
+ goto error;
+
if (qemuBuildInterfaceCommandLine(cmd, driver, def, net,
qemuCaps, vlan, bootNet, vmop,
- standalone) < 0)
+ standalone,
+ &((*nicindexes)[*nnicindexes - 1])) < 0)
goto error;
+
last_good_net = i;
bootNet = 0;
}
qemuBuildCommandLineCallbacksPtr callbacks,
bool forXMLToArgv,
bool enableFips,
- virBitmapPtr nodeset)
+ virBitmapPtr nodeset,
+ size_t *nnicindexes,
+ int **nicindexes)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(11);
/* Generate '-device' string for chardev device */
virDomainNetDefPtr net,
virQEMUCapsPtr qemuCaps,
int *tapfd,
- size_t *tapfdSize)
+ size_t *tapfdSize,
+ int *nicindex)
ATTRIBUTE_NONNULL(2);
int qemuPhysIfaceConnect(virDomainDefPtr def,
size_t i;
virQEMUDriverConfigPtr cfg;
virCapsPtr caps = NULL;
+ size_t nnicindexes = 0;
+ int *nicindexes = NULL;
virCheckFlags(0, NULL);
&buildCommandLineCallbacks,
true,
qemuCheckFips(),
- NULL)))
+ NULL,
+ &nnicindexes, &nicindexes)))
goto cleanup;
ret = virCommandToString(cmd);
cleanup:
-
+ VIR_FREE(nicindexes);
virObjectUnref(qemuCaps);
virCommandFree(cmd);
virDomainDefFree(def);
qemuDomainObjPrivatePtr priv = vm->privateData;
char **tapfdName = NULL;
int *tapfd = NULL;
+ int nicindex = -1;
size_t tapfdSize = 0;
char **vhostfdName = NULL;
int *vhostfd = NULL;
goto cleanup;
memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize);
if (qemuNetworkIfaceConnect(vm->def, driver, net,
- priv->qemuCaps, tapfd, &tapfdSize) < 0)
+ priv->qemuCaps, tapfd, &tapfdSize,
+ &nicindex) < 0)
goto cleanup;
iface_connected = true;
if (qemuOpenVhostNet(vm->def, net, priv->qemuCaps, vhostfd, &vhostfdSize) < 0)
virQEMUDriverConfigPtr cfg;
virCapsPtr caps = NULL;
unsigned int hostdev_flags = 0;
+ size_t nnicindexes = 0;
+ int *nicindexes = NULL;
VIR_DEBUG("vm=%p name=%s id=%d pid=%llu",
vm, vm->def->name, vm->def->id,
migrateFrom, stdin_fd, snapshot, vmop,
&buildCommandLineCallbacks, false,
qemuCheckFips(),
- nodemask)))
+ nodemask,
+ &nnicindexes, &nicindexes)))
goto cleanup;
/* now that we know it is about to start call the hook if present */
}
VIR_DEBUG("Setting up domain cgroup (if required)");
- if (qemuSetupCgroup(driver, vm) < 0)
+ if (qemuSetupCgroup(driver, vm, nnicindexes, nicindexes) < 0)
goto cleanup;
/* This must be done after cgroup placement to avoid resetting CPU
VIR_FORCE_CLOSE(logfile);
virObjectUnref(cfg);
virObjectUnref(caps);
+ VIR_FREE(nicindexes);
return 0;
qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, stop_flags);
virObjectUnref(cfg);
virObjectUnref(caps);
+ VIR_FREE(nicindexes);
return -1;
char *log = NULL;
virCommandPtr cmd = NULL;
size_t i;
+ size_t nnicindexes = 0;
+ int *nicindexes = NULL;
if (!(conn = virGetConnect()))
goto out;
VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
&testCallbacks, false,
(flags & FLAG_FIPS),
- NULL))) {
+ NULL, &nnicindexes, &nicindexes))) {
if (!virtTestOOMActive() &&
(flags & FLAG_EXPECT_FAILURE)) {
ret = 0;
ret = 0;
out:
+ VIR_FREE(nicindexes);
VIR_FREE(log);
VIR_FREE(expectargv);
VIR_FREE(actualargv);
char *log = NULL;
char *emulator = NULL;
virCommandPtr cmd = NULL;
+ size_t nnicindexes = 0;
+ int *nicindexes = NULL;
if (!(conn = virGetConnect()))
goto fail;
vmdef, &monitor_chr, json, extraFlags,
migrateFrom, migrateFd, NULL,
VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
- &testCallbacks, false, false, NULL)))
+ &testCallbacks, false, false, NULL,
+ &nnicindexes, &nicindexes)))
goto fail;
if (!virtTestOOMActive()) {
ret = 0;
fail:
+ VIR_FREE(nicindexes);
VIR_FREE(log);
VIR_FREE(emulator);
VIR_FREE(expectargv);