mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
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: Jiri Denemark <jdenemar@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
593ba43f1f
commit
23ed8eb21d
@ -38,11 +38,12 @@ virDomainConfNWFilterRegister(virDomainConfNWFilterDriverPtr driver)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
virDomainConfNWFilterInstantiate(const unsigned char *vmuuid,
|
virDomainConfNWFilterInstantiate(const char *vmname,
|
||||||
|
const unsigned char *vmuuid,
|
||||||
virDomainNetDefPtr net)
|
virDomainNetDefPtr net)
|
||||||
{
|
{
|
||||||
if (nwfilterDriver != NULL)
|
if (nwfilterDriver != NULL)
|
||||||
return nwfilterDriver->instantiateFilter(vmuuid, net);
|
return nwfilterDriver->instantiateFilter(vmname, vmuuid, net);
|
||||||
/* driver module not available -- don't indicate failure */
|
/* driver module not available -- don't indicate failure */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
#ifndef DOMAIN_NWFILTER_H
|
#ifndef DOMAIN_NWFILTER_H
|
||||||
# define 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);
|
virDomainNetDefPtr net);
|
||||||
typedef void (*virDomainConfTeardownNWFilter)(virDomainNetDefPtr net);
|
typedef void (*virDomainConfTeardownNWFilter)(virDomainNetDefPtr net);
|
||||||
|
|
||||||
@ -35,7 +36,8 @@ typedef virDomainConfNWFilterDriver *virDomainConfNWFilterDriverPtr;
|
|||||||
|
|
||||||
void virDomainConfNWFilterRegister(virDomainConfNWFilterDriverPtr driver);
|
void virDomainConfNWFilterRegister(virDomainConfNWFilterDriverPtr driver);
|
||||||
|
|
||||||
int virDomainConfNWFilterInstantiate(const unsigned char *vmuuid,
|
int virDomainConfNWFilterInstantiate(const char *vmname,
|
||||||
|
const unsigned char *vmuuid,
|
||||||
virDomainNetDefPtr net);
|
virDomainNetDefPtr net);
|
||||||
void virDomainConfNWFilterTeardown(virDomainNetDefPtr net);
|
void virDomainConfNWFilterTeardown(virDomainNetDefPtr net);
|
||||||
void virDomainConfVMNWFilterTeardown(virDomainObjPtr vm);
|
void virDomainConfVMNWFilterTeardown(virDomainObjPtr vm);
|
||||||
|
@ -304,7 +304,7 @@ virLXCProcessSetupInterfaceTap(virDomainDefPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (net->filter &&
|
if (net->filter &&
|
||||||
virDomainConfNWFilterInstantiate(vm->uuid, net) < 0)
|
virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = containerVeth;
|
ret = containerVeth;
|
||||||
|
@ -642,7 +642,8 @@ nwfilterGetXMLDesc(virNWFilterPtr nwfilter,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nwfilterInstantiateFilter(const unsigned char *vmuuid,
|
nwfilterInstantiateFilter(const char *vmname ATTRIBUTE_UNUSED,
|
||||||
|
const unsigned char *vmuuid,
|
||||||
virDomainNetDefPtr net)
|
virDomainNetDefPtr net)
|
||||||
{
|
{
|
||||||
return virNWFilterInstantiateFilter(driver, vmuuid, net);
|
return virNWFilterInstantiateFilter(driver, vmuuid, net);
|
||||||
|
@ -3016,7 +3016,8 @@ qemuDomainChangeNetFilter(virDomainObjPtr vm,
|
|||||||
virDomainConfNWFilterTeardown(olddev);
|
virDomainConfNWFilterTeardown(olddev);
|
||||||
|
|
||||||
if (newdev->filter &&
|
if (newdev->filter &&
|
||||||
virDomainConfNWFilterInstantiate(vm->def->uuid, newdev) < 0) {
|
virDomainConfNWFilterInstantiate(vm->def->name,
|
||||||
|
vm->def->uuid, newdev) < 0) {
|
||||||
virErrorPtr errobj;
|
virErrorPtr errobj;
|
||||||
|
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
@ -3024,7 +3025,8 @@ qemuDomainChangeNetFilter(virDomainObjPtr vm,
|
|||||||
"- attempting to restore old rules"),
|
"- attempting to restore old rules"),
|
||||||
olddev->ifname);
|
olddev->ifname);
|
||||||
virErrorPreserveLast(&errobj);
|
virErrorPreserveLast(&errobj);
|
||||||
ignore_value(virDomainConfNWFilterInstantiate(vm->def->uuid, olddev));
|
ignore_value(virDomainConfNWFilterInstantiate(vm->def->name,
|
||||||
|
vm->def->uuid, olddev));
|
||||||
virErrorRestore(&errobj);
|
virErrorRestore(&errobj);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (net->filter &&
|
if (net->filter &&
|
||||||
virDomainConfNWFilterInstantiate(def->uuid, net) < 0) {
|
virDomainConfNWFilterInstantiate(def->name, def->uuid, net) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,7 +586,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (net->filter &&
|
if (net->filter &&
|
||||||
virDomainConfNWFilterInstantiate(def->uuid, net) < 0) {
|
virDomainConfNWFilterInstantiate(def->name, def->uuid, net) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2952,7 +2952,7 @@ qemuProcessFiltersInstantiate(virDomainDefPtr def)
|
|||||||
for (i = 0; i < def->nnets; i++) {
|
for (i = 0; i < def->nnets; i++) {
|
||||||
virDomainNetDefPtr net = def->nets[i];
|
virDomainNetDefPtr net = def->nets[i];
|
||||||
if ((net->filter) && (net->ifname)) {
|
if ((net->filter) && (net->ifname)) {
|
||||||
if (virDomainConfNWFilterInstantiate(def->uuid, net) < 0)
|
if (virDomainConfNWFilterInstantiate(def->name, def->uuid, net) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ umlConnectTapDevice(virDomainDefPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (net->filter) {
|
if (net->filter) {
|
||||||
if (virDomainConfNWFilterInstantiate(vm->uuid, net) < 0) {
|
if (virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net) < 0) {
|
||||||
if (template_ifname)
|
if (template_ifname)
|
||||||
VIR_FREE(net->ifname);
|
VIR_FREE(net->ifname);
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
Reference in New Issue
Block a user