[libvirt] [PATCH 2/6] qemuxml2argvtest: Don't spawn session daemon

Daniel P. Berrangé berrange at redhat.com
Mon Jul 9 12:05:01 UTC 2018


On Mon, Jul 09, 2018 at 02:00:06PM +0200, Michal Privoznik wrote:
> On 07/09/2018 12:44 PM, Daniel P. Berrangé wrote:
> > On Mon, Jul 09, 2018 at 11:56:10AM +0200, Michal Privoznik wrote:
> >> After f14c37ce4c2ccd111 the cleanup path for
> >> qemuBuildInterfaceCommandLine() and qemuBuildNetCommandLine()
> >> tries to connect to nwfilter driver in order to tear down any
> >> NWFilter that was brought up during cmd line construction. Since
> >> we also have negative test cases where errors during cmd line
> >> build are expected the cleanup paths are executed and NWFilter
> >> removal is attempted.
> >>
> >> Fortunately, there is another bug that by pure luck prevented us
> >> from actually spawning the daemon and thus modifying actual user
> >> data. See next commit for explanation.
> >>
> >> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> >> ---
> >>  src/driver.h             | 2 +-
> >>  tests/qemuxml2argvmock.c | 7 +++++++
> >>  2 files changed, 8 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/src/driver.h b/src/driver.h
> >> index 0b1f7a2269..0a0d8facee 100644
> >> --- a/src/driver.h
> >> +++ b/src/driver.h
> >> @@ -113,7 +113,7 @@ int virDriverLoadModule(const char *name,
> >>  
> >>  virConnectPtr virGetConnectInterface(void);
> >>  virConnectPtr virGetConnectNetwork(void);
> >> -virConnectPtr virGetConnectNWFilter(void);
> >> +virConnectPtr virGetConnectNWFilter(void) ATTRIBUTE_NOINLINE;
> >>  virConnectPtr virGetConnectNodeDev(void);
> >>  virConnectPtr virGetConnectSecret(void);
> >>  virConnectPtr virGetConnectStorage(void);
> >> diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
> >> index 4df92cf396..13ccfb855d 100644
> >> --- a/tests/qemuxml2argvmock.c
> >> +++ b/tests/qemuxml2argvmock.c
> >> @@ -233,3 +233,10 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev ATTRIBUTE_UNUSED)
> >>          abort();
> >>      return 1729;
> >>  }
> >> +
> >> +
> >> +virConnectPtr
> >> +virGetConnectNWFilter(void)
> >> +{
> >> +    return NULL;
> >> +}
> > 
> > In qemuxml2argvtest.c we actally set a fake shared connection, but I only
> > set it for two of the drivers. We should just register it for all the
> > drivers. eg expand these lines:
> > 
> >     virSetConnectSecret(conn);
> >     virSetConnectStorage(conn);
> 
> Oh, that means I have to provide some basic implementation. I can't just
> set conn->nwFilterDriver = NULL; because then virGetConnectNWFilte()
> would still try to connect.

You shouldn't have to provide any impl - virGetConnectNWFilter() merely
cares about the virConnectPtr being non-NULL - it doesn't check if the
conn->nwfilterDriver pointer is set.

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 :|




More information about the libvir-list mailing list