[libvirt] [PATCH 08/14] nwfilter: pass vm name in when instantiating filters

Daniel P. Berrangé posted 14 patches 6 years, 7 months ago
There is a newer version of this series
[libvirt] [PATCH 08/14] nwfilter: pass vm name in when instantiating filters
Posted by Daniel P. Berrangé 6 years, 7 months ago
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.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/conf/domain_nwfilter.c     | 5 +++--
 src/conf/domain_nwfilter.h     | 6 ++++--
 src/lxc/lxc_process.c          | 2 +-
 src/nwfilter/nwfilter_driver.c | 3 ++-
 src/qemu/qemu_hotplug.c        | 6 ++++--
 src/qemu/qemu_interface.c      | 4 ++--
 src/qemu/qemu_process.c        | 2 +-
 src/uml/uml_conf.c             | 2 +-
 8 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_nwfilter.c b/src/conf/domain_nwfilter.c
index 176e7e6734..e360aceeba 100644
--- a/src/conf/domain_nwfilter.c
+++ b/src/conf/domain_nwfilter.c
@@ -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;
 }
diff --git a/src/conf/domain_nwfilter.h b/src/conf/domain_nwfilter.h
index af047c745a..857cac6c2a 100644
--- a/src/conf/domain_nwfilter.h
+++ b/src/conf/domain_nwfilter.h
@@ -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);
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index e911d88b56..3610523c06 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -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;
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index fef3aa272b..d17a8ec00b 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -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);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index df9e8aa716..3bb0c72257 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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;
     }
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index ffa4b875c0..5d54a85c53 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -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;
     }
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 6a5262ae46..9233d26948 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -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;
         }
     }
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 49589b33c9..9c548f0e80 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -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;
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 08/14] nwfilter: pass vm name in when instantiating filters
Posted by Jiri Denemark 6 years, 7 months ago
On Fri, Apr 27, 2018 at 16:25:07 +0100, Daniel P. Berrangé wrote:
> 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.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  src/conf/domain_nwfilter.c     | 5 +++--
>  src/conf/domain_nwfilter.h     | 6 ++++--
>  src/lxc/lxc_process.c          | 2 +-
>  src/nwfilter/nwfilter_driver.c | 3 ++-
>  src/qemu/qemu_hotplug.c        | 6 ++++--
>  src/qemu/qemu_interface.c      | 4 ++--
>  src/qemu/qemu_process.c        | 2 +-
>  src/uml/uml_conf.c             | 2 +-
>  8 files changed, 18 insertions(+), 12 deletions(-)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 08/14] nwfilter: pass vm name in when instantiating filters
Posted by Daniel P. Berrangé 6 years, 6 months ago
On Mon, Apr 30, 2018 at 04:09:40PM +0200, Jiri Denemark wrote:
> On Fri, Apr 27, 2018 at 16:25:07 +0100, Daniel P. Berrangé wrote:
> > 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.
> > 
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> >  src/conf/domain_nwfilter.c     | 5 +++--
> >  src/conf/domain_nwfilter.h     | 6 ++++--
> >  src/lxc/lxc_process.c          | 2 +-
> >  src/nwfilter/nwfilter_driver.c | 3 ++-
> >  src/qemu/qemu_hotplug.c        | 6 ++++--
> >  src/qemu/qemu_interface.c      | 4 ++--
> >  src/qemu/qemu_process.c        | 2 +-
> >  src/uml/uml_conf.c             | 2 +-
> >  8 files changed, 18 insertions(+), 12 deletions(-)
> 
> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

FYI, I have pushed upto & including this patch.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list