mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
nwfilter: Make a common UUID lookup function from driver
Rather than separate calls, use a common call and generate a better error message which includes the incorrect uuidstr. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
6181e404d9
commit
6b73a13212
@ -356,6 +356,21 @@ nwfilterStateCleanup(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static virNWFilterObjPtr
|
||||||
|
nwfilterObjFromNWFilter(const unsigned char *uuid)
|
||||||
|
{
|
||||||
|
virNWFilterObjPtr obj;
|
||||||
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
|
if (!(obj = virNWFilterObjListFindByUUID(driver->nwfilters, uuid))) {
|
||||||
|
virUUIDFormat(uuid, uuidstr);
|
||||||
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
|
_("no nwfilter with matching uuid '%s'"), uuidstr);
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virNWFilterPtr
|
static virNWFilterPtr
|
||||||
nwfilterLookupByUUID(virConnectPtr conn,
|
nwfilterLookupByUUID(virConnectPtr conn,
|
||||||
const unsigned char *uuid)
|
const unsigned char *uuid)
|
||||||
@ -365,14 +380,11 @@ nwfilterLookupByUUID(virConnectPtr conn,
|
|||||||
virNWFilterPtr ret = NULL;
|
virNWFilterPtr ret = NULL;
|
||||||
|
|
||||||
nwfilterDriverLock();
|
nwfilterDriverLock();
|
||||||
obj = virNWFilterObjListFindByUUID(driver->nwfilters, uuid);
|
obj = nwfilterObjFromNWFilter(uuid);
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj)
|
||||||
virReportError(VIR_ERR_NO_NWFILTER,
|
|
||||||
"%s", _("no nwfilter with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
def = virNWFilterObjGetDef(obj);
|
def = virNWFilterObjGetDef(obj);
|
||||||
|
|
||||||
if (virNWFilterLookupByUUIDEnsureACL(conn, def) < 0)
|
if (virNWFilterLookupByUUIDEnsureACL(conn, def) < 0)
|
||||||
@ -528,12 +540,8 @@ nwfilterUndefine(virNWFilterPtr nwfilter)
|
|||||||
virNWFilterWriteLockFilterUpdates();
|
virNWFilterWriteLockFilterUpdates();
|
||||||
virNWFilterCallbackDriversLock();
|
virNWFilterCallbackDriversLock();
|
||||||
|
|
||||||
obj = virNWFilterObjListFindByUUID(driver->nwfilters, nwfilter->uuid);
|
if (!(obj = nwfilterObjFromNWFilter(nwfilter->uuid)))
|
||||||
if (!obj) {
|
|
||||||
virReportError(VIR_ERR_NO_NWFILTER,
|
|
||||||
"%s", _("no nwfilter with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
def = virNWFilterObjGetDef(obj);
|
def = virNWFilterObjGetDef(obj);
|
||||||
|
|
||||||
if (virNWFilterUndefineEnsureACL(nwfilter->conn, def) < 0)
|
if (virNWFilterUndefineEnsureACL(nwfilter->conn, def) < 0)
|
||||||
@ -575,14 +583,11 @@ nwfilterGetXMLDesc(virNWFilterPtr nwfilter,
|
|||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
nwfilterDriverLock();
|
nwfilterDriverLock();
|
||||||
obj = virNWFilterObjListFindByUUID(driver->nwfilters, nwfilter->uuid);
|
obj = nwfilterObjFromNWFilter(nwfilter->uuid);
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj)
|
||||||
virReportError(VIR_ERR_NO_NWFILTER,
|
|
||||||
"%s", _("no nwfilter with matching uuid"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
def = virNWFilterObjGetDef(obj);
|
def = virNWFilterObjGetDef(obj);
|
||||||
|
|
||||||
if (virNWFilterGetXMLDescEnsureACL(nwfilter->conn, def) < 0)
|
if (virNWFilterGetXMLDescEnsureACL(nwfilter->conn, def) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user