提交 5c9277b6 编写于 作者: M Michal Privoznik

qemuxml2argvtest: Set more fake drivers

So far we are setting only fake secret and storage drivers.
Therefore if the code wants to call a public NWFilter API (like
qemuBuildInterfaceCommandLine() and qemuBuildNetCommandLine() are
doing) the virGetConnectNWFilter() function will try to actually
spawn session daemon because there's no connection object set to
handle NWFilter driver.

Even though I haven't experienced the same problem with the rest
of the drivers (interface, network and node dev), the reasoning
above can be applied to them as well.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 1315be99
......@@ -262,6 +262,33 @@ static virStorageDriver fakeStorageDriver = {
.storagePoolIsActive = fakeStoragePoolIsActive,
};
/* virNetDevOpenvswitchGetVhostuserIfname mocks a portdev name - handle that */
static virNWFilterBindingPtr
fakeNWFilterBindingLookupByPortDev(virConnectPtr conn,
const char *portdev)
{
if (STREQ(portdev, "vhost-user0"))
return virGetNWFilterBinding(conn, "fake_vnet0", "fakeFilterName");
virReportError(VIR_ERR_NO_NWFILTER_BINDING,
"no nwfilter binding for port dev '%s'", portdev);
return NULL;
}
static int
fakeNWFilterBindingDelete(virNWFilterBindingPtr binding ATTRIBUTE_UNUSED)
{
return 0;
}
static virNWFilterDriver fakeNWFilterDriver = {
.nwfilterBindingLookupByPortDev = fakeNWFilterBindingLookupByPortDev,
.nwfilterBindingDelete = fakeNWFilterBindingDelete,
};
typedef enum {
FLAG_EXPECT_FAILURE = 1 << 0,
FLAG_EXPECT_PARSE_ERROR = 1 << 1,
......@@ -470,7 +497,12 @@ testCompareXMLToArgv(const void *data)
conn->secretDriver = &fakeSecretDriver;
conn->storageDriver = &fakeStorageDriver;
conn->nwfilterDriver = &fakeNWFilterDriver;
virSetConnectInterface(conn);
virSetConnectNetwork(conn);
virSetConnectNWFilter(conn);
virSetConnectNodeDev(conn);
virSetConnectSecret(conn);
virSetConnectStorage(conn);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册