提交 23ed8eb2 编写于 作者: D Daniel P. Berrangé

nwfilter: pass vm name in when instantiating filters

The vm name is not needed for any functional requirement, but it will be
useful when debugging problems to identify which VM is associated with a
filter, since UUID is not human friendly.
Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 593ba43f
......@@ -38,11 +38,12 @@ virDomainConfNWFilterRegister(virDomainConfNWFilterDriverPtr driver)
}
int
virDomainConfNWFilterInstantiate(const unsigned char *vmuuid,
virDomainConfNWFilterInstantiate(const char *vmname,
const unsigned char *vmuuid,
virDomainNetDefPtr net)
{
if (nwfilterDriver != NULL)
return nwfilterDriver->instantiateFilter(vmuuid, net);
return nwfilterDriver->instantiateFilter(vmname, vmuuid, net);
/* driver module not available -- don't indicate failure */
return 0;
}
......
......@@ -23,7 +23,8 @@
#ifndef DOMAIN_NWFILTER_H
# define DOMAIN_NWFILTER_H
typedef int (*virDomainConfInstantiateNWFilter)(const unsigned char *vmuuid,
typedef int (*virDomainConfInstantiateNWFilter)(const char *vmname,
const unsigned char *vmuuid,
virDomainNetDefPtr net);
typedef void (*virDomainConfTeardownNWFilter)(virDomainNetDefPtr net);
......@@ -35,7 +36,8 @@ typedef virDomainConfNWFilterDriver *virDomainConfNWFilterDriverPtr;
void virDomainConfNWFilterRegister(virDomainConfNWFilterDriverPtr driver);
int virDomainConfNWFilterInstantiate(const unsigned char *vmuuid,
int virDomainConfNWFilterInstantiate(const char *vmname,
const unsigned char *vmuuid,
virDomainNetDefPtr net);
void virDomainConfNWFilterTeardown(virDomainNetDefPtr net);
void virDomainConfVMNWFilterTeardown(virDomainObjPtr vm);
......
......@@ -304,7 +304,7 @@ virLXCProcessSetupInterfaceTap(virDomainDefPtr vm,
}
if (net->filter &&
virDomainConfNWFilterInstantiate(vm->uuid, net) < 0)
virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net) < 0)
goto cleanup;
ret = containerVeth;
......
......@@ -642,7 +642,8 @@ nwfilterGetXMLDesc(virNWFilterPtr nwfilter,
static int
nwfilterInstantiateFilter(const unsigned char *vmuuid,
nwfilterInstantiateFilter(const char *vmname ATTRIBUTE_UNUSED,
const unsigned char *vmuuid,
virDomainNetDefPtr net)
{
return virNWFilterInstantiateFilter(driver, vmuuid, net);
......
......@@ -3016,7 +3016,8 @@ qemuDomainChangeNetFilter(virDomainObjPtr vm,
virDomainConfNWFilterTeardown(olddev);
if (newdev->filter &&
virDomainConfNWFilterInstantiate(vm->def->uuid, newdev) < 0) {
virDomainConfNWFilterInstantiate(vm->def->name,
vm->def->uuid, newdev) < 0) {
virErrorPtr errobj;
virReportError(VIR_ERR_OPERATION_FAILED,
......@@ -3024,7 +3025,8 @@ qemuDomainChangeNetFilter(virDomainObjPtr vm,
"- attempting to restore old rules"),
olddev->ifname);
virErrorPreserveLast(&errobj);
ignore_value(virDomainConfNWFilterInstantiate(vm->def->uuid, olddev));
ignore_value(virDomainConfNWFilterInstantiate(vm->def->name,
vm->def->uuid, olddev));
virErrorRestore(&errobj);
return -1;
}
......
......@@ -467,7 +467,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
goto cleanup;
if (net->filter &&
virDomainConfNWFilterInstantiate(def->uuid, net) < 0) {
virDomainConfNWFilterInstantiate(def->name, def->uuid, net) < 0) {
goto cleanup;
}
......@@ -586,7 +586,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
goto cleanup;
if (net->filter &&
virDomainConfNWFilterInstantiate(def->uuid, net) < 0) {
virDomainConfNWFilterInstantiate(def->name, def->uuid, net) < 0) {
goto cleanup;
}
......
......@@ -2952,7 +2952,7 @@ qemuProcessFiltersInstantiate(virDomainDefPtr def)
for (i = 0; i < def->nnets; i++) {
virDomainNetDefPtr net = def->nets[i];
if ((net->filter) && (net->ifname)) {
if (virDomainConfNWFilterInstantiate(def->uuid, net) < 0)
if (virDomainConfNWFilterInstantiate(def->name, def->uuid, net) < 0)
return 1;
}
}
......
......@@ -137,7 +137,7 @@ umlConnectTapDevice(virDomainDefPtr vm,
}
if (net->filter) {
if (virDomainConfNWFilterInstantiate(vm->uuid, net) < 0) {
if (virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net) < 0) {
if (template_ifname)
VIR_FREE(net->ifname);
goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册