mirror of https://gitee.com/openkylin/libvirt.git
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: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
1315be9936
commit
5c9277b6dd
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue