mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
test: Use VIR_AUTOFREE for test driver
Let's make use of the auto __cleanup capabilities cleaning up any now unnecessary goto paths. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ba045165d4
commit
ceb3255cdf
@ -200,10 +200,10 @@ testDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
|
|||||||
void **data)
|
void **data)
|
||||||
{
|
{
|
||||||
testDomainNamespaceDefPtr nsdata = NULL;
|
testDomainNamespaceDefPtr nsdata = NULL;
|
||||||
xmlNodePtr *nodes = NULL;
|
|
||||||
int tmp, n;
|
int tmp, n;
|
||||||
size_t i;
|
size_t i;
|
||||||
unsigned int tmpuint;
|
unsigned int tmpuint;
|
||||||
|
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
||||||
|
|
||||||
if (xmlXPathRegisterNs(ctxt, BAD_CAST "test",
|
if (xmlXPathRegisterNs(ctxt, BAD_CAST "test",
|
||||||
BAD_CAST TEST_NAMESPACE_HREF) < 0) {
|
BAD_CAST TEST_NAMESPACE_HREF) < 0) {
|
||||||
@ -233,7 +233,6 @@ testDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
|
|||||||
nsdata->snap_nodes[nsdata->num_snap_nodes] = newnode;
|
nsdata->snap_nodes[nsdata->num_snap_nodes] = newnode;
|
||||||
nsdata->num_snap_nodes++;
|
nsdata->num_snap_nodes++;
|
||||||
}
|
}
|
||||||
VIR_FREE(nodes);
|
|
||||||
|
|
||||||
tmp = virXPathBoolean("boolean(./test:transient)", ctxt);
|
tmp = virXPathBoolean("boolean(./test:transient)", ctxt);
|
||||||
if (tmp == -1) {
|
if (tmp == -1) {
|
||||||
@ -280,7 +279,6 @@ testDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
VIR_FREE(nodes);
|
|
||||||
testDomainDefNamespaceFree(nsdata);
|
testDomainDefNamespaceFree(nsdata);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -695,11 +693,10 @@ testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char *type)
|
|||||||
xmlNodePtr ret = NULL;
|
xmlNodePtr ret = NULL;
|
||||||
xmlDocPtr doc = NULL;
|
xmlDocPtr doc = NULL;
|
||||||
char *absFile = NULL;
|
char *absFile = NULL;
|
||||||
char *relFile = virXMLPropString(node, "file");
|
VIR_AUTOFREE(char *) relFile = NULL;
|
||||||
|
|
||||||
if (relFile != NULL) {
|
if ((relFile = virXMLPropString(node, "file"))) {
|
||||||
absFile = testBuildFilename(file, relFile);
|
absFile = testBuildFilename(file, relFile);
|
||||||
VIR_FREE(relFile);
|
|
||||||
if (!absFile) {
|
if (!absFile) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("resolving %s filename"), type);
|
_("resolving %s filename"), type);
|
||||||
@ -722,16 +719,15 @@ testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char *type)
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
VIR_FREE(absFile);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testParseNodeInfo(virNodeInfoPtr nodeInfo, xmlXPathContextPtr ctxt)
|
testParseNodeInfo(virNodeInfoPtr nodeInfo, xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
char *str;
|
|
||||||
long l;
|
long l;
|
||||||
int ret;
|
int ret;
|
||||||
|
VIR_AUTOFREE(char *) str = NULL;
|
||||||
|
|
||||||
ret = virXPathLong("string(/node/cpu/nodes[1])", ctxt, &l);
|
ret = virXPathLong("string(/node/cpu/nodes[1])", ctxt, &l);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
@ -794,10 +790,8 @@ testParseNodeInfo(virNodeInfoPtr nodeInfo, xmlXPathContextPtr ctxt)
|
|||||||
if (virStrcpyStatic(nodeInfo->model, str) < 0) {
|
if (virStrcpyStatic(nodeInfo->model, str) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Model %s too big for destination"), str);
|
_("Model %s too big for destination"), str);
|
||||||
VIR_FREE(str);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
VIR_FREE(str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virXPathLong("string(/node/memory[1])", ctxt, &l);
|
ret = virXPathLong("string(/node/memory[1])", ctxt, &l);
|
||||||
@ -877,12 +871,12 @@ testParseDomains(testDriverPtr privconn,
|
|||||||
{
|
{
|
||||||
int num, ret = -1;
|
int num, ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
xmlNodePtr *nodes = NULL;
|
|
||||||
virDomainObjPtr obj = NULL;
|
virDomainObjPtr obj = NULL;
|
||||||
|
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
||||||
|
|
||||||
num = virXPathNodeSet("/node/domain", ctxt, &nodes);
|
num = virXPathNodeSet("/node/domain", ctxt, &nodes);
|
||||||
if (num < 0)
|
if (num < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
virDomainDefPtr def;
|
virDomainDefPtr def;
|
||||||
@ -928,7 +922,6 @@ testParseDomains(testDriverPtr privconn,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
error:
|
error:
|
||||||
virDomainObjEndAPI(&obj);
|
virDomainObjEndAPI(&obj);
|
||||||
VIR_FREE(nodes);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,38 +931,35 @@ testParseNetworks(testDriverPtr privconn,
|
|||||||
const char *file,
|
const char *file,
|
||||||
xmlXPathContextPtr ctxt)
|
xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
int num, ret = -1;
|
int num;
|
||||||
size_t i;
|
size_t i;
|
||||||
xmlNodePtr *nodes = NULL;
|
|
||||||
virNetworkObjPtr obj;
|
virNetworkObjPtr obj;
|
||||||
|
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
||||||
|
|
||||||
num = virXPathNodeSet("/node/network", ctxt, &nodes);
|
num = virXPathNodeSet("/node/network", ctxt, &nodes);
|
||||||
if (num < 0)
|
if (num < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
virNetworkDefPtr def;
|
virNetworkDefPtr def;
|
||||||
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file, "network");
|
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file, "network");
|
||||||
if (!node)
|
if (!node)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
def = virNetworkDefParseNode(ctxt->doc, node);
|
def = virNetworkDefParseNode(ctxt->doc, node);
|
||||||
if (!def)
|
if (!def)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (!(obj = virNetworkObjAssignDef(privconn->networks, def, 0))) {
|
if (!(obj = virNetworkObjAssignDef(privconn->networks, def, 0))) {
|
||||||
virNetworkDefFree(def);
|
virNetworkDefFree(def);
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virNetworkObjSetActive(obj, true);
|
virNetworkObjSetActive(obj, true);
|
||||||
virNetworkObjEndAPI(&obj);
|
virNetworkObjEndAPI(&obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
error:
|
|
||||||
VIR_FREE(nodes);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -978,39 +968,36 @@ testParseInterfaces(testDriverPtr privconn,
|
|||||||
const char *file,
|
const char *file,
|
||||||
xmlXPathContextPtr ctxt)
|
xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
int num, ret = -1;
|
int num;
|
||||||
size_t i;
|
size_t i;
|
||||||
xmlNodePtr *nodes = NULL;
|
|
||||||
virInterfaceObjPtr obj;
|
virInterfaceObjPtr obj;
|
||||||
|
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
||||||
|
|
||||||
num = virXPathNodeSet("/node/interface", ctxt, &nodes);
|
num = virXPathNodeSet("/node/interface", ctxt, &nodes);
|
||||||
if (num < 0)
|
if (num < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
virInterfaceDefPtr def;
|
virInterfaceDefPtr def;
|
||||||
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
|
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
|
||||||
"interface");
|
"interface");
|
||||||
if (!node)
|
if (!node)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
def = virInterfaceDefParseNode(ctxt->doc, node);
|
def = virInterfaceDefParseNode(ctxt->doc, node);
|
||||||
if (!def)
|
if (!def)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (!(obj = virInterfaceObjListAssignDef(privconn->ifaces, def))) {
|
if (!(obj = virInterfaceObjListAssignDef(privconn->ifaces, def))) {
|
||||||
virInterfaceDefFree(def);
|
virInterfaceDefFree(def);
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virInterfaceObjSetActive(obj, true);
|
virInterfaceObjSetActive(obj, true);
|
||||||
virInterfaceObjEndAPI(&obj);
|
virInterfaceObjEndAPI(&obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
error:
|
|
||||||
VIR_FREE(nodes);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1021,51 +1008,47 @@ testOpenVolumesForPool(const char *file,
|
|||||||
int objidx)
|
int objidx)
|
||||||
{
|
{
|
||||||
virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
|
virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
|
||||||
char *vol_xpath;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
int num, ret = -1;
|
int num;
|
||||||
xmlNodePtr *nodes = NULL;
|
VIR_AUTOFREE(char *) vol_xpath = NULL;
|
||||||
|
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
||||||
VIR_AUTOPTR(virStorageVolDef) volDef = NULL;
|
VIR_AUTOPTR(virStorageVolDef) volDef = NULL;
|
||||||
|
|
||||||
/* Find storage volumes */
|
/* Find storage volumes */
|
||||||
if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0)
|
if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
num = virXPathNodeSet(vol_xpath, ctxt, &nodes);
|
num = virXPathNodeSet(vol_xpath, ctxt, &nodes);
|
||||||
VIR_FREE(vol_xpath);
|
|
||||||
if (num < 0)
|
if (num < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
|
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
|
||||||
"volume");
|
"volume");
|
||||||
if (!node)
|
if (!node)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (!(volDef = virStorageVolDefParseNode(def, ctxt->doc, node, 0)))
|
if (!(volDef = virStorageVolDefParseNode(def, ctxt->doc, node, 0)))
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (!volDef->target.path) {
|
if (!volDef->target.path) {
|
||||||
if (virAsprintf(&volDef->target.path, "%s/%s",
|
if (virAsprintf(&volDef->target.path, "%s/%s",
|
||||||
def->target.path, volDef->name) < 0)
|
def->target.path, volDef->name) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!volDef->key && VIR_STRDUP(volDef->key, volDef->target.path) < 0)
|
if (!volDef->key && VIR_STRDUP(volDef->key, volDef->target.path) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (virStoragePoolObjAddVol(obj, volDef) < 0)
|
if (virStoragePoolObjAddVol(obj, volDef) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
def->allocation += volDef->target.allocation;
|
def->allocation += volDef->target.allocation;
|
||||||
def->available = (def->capacity - def->allocation);
|
def->available = (def->capacity - def->allocation);
|
||||||
volDef = NULL;
|
volDef = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
error:
|
|
||||||
VIR_FREE(nodes);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1074,50 +1057,47 @@ testParseStorage(testDriverPtr privconn,
|
|||||||
const char *file,
|
const char *file,
|
||||||
xmlXPathContextPtr ctxt)
|
xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
int num, ret = -1;
|
int num;
|
||||||
size_t i;
|
size_t i;
|
||||||
xmlNodePtr *nodes = NULL;
|
|
||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
|
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
||||||
|
|
||||||
num = virXPathNodeSet("/node/pool", ctxt, &nodes);
|
num = virXPathNodeSet("/node/pool", ctxt, &nodes);
|
||||||
if (num < 0)
|
if (num < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
virStoragePoolDefPtr def;
|
virStoragePoolDefPtr def;
|
||||||
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
|
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
|
||||||
"pool");
|
"pool");
|
||||||
if (!node)
|
if (!node)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
def = virStoragePoolDefParseNode(ctxt->doc, node);
|
def = virStoragePoolDefParseNode(ctxt->doc, node);
|
||||||
if (!def)
|
if (!def)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (!(obj = virStoragePoolObjAssignDef(privconn->pools, def, false))) {
|
if (!(obj = virStoragePoolObjAssignDef(privconn->pools, def, false))) {
|
||||||
virStoragePoolDefFree(def);
|
virStoragePoolDefFree(def);
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testStoragePoolObjSetDefaults(obj) == -1) {
|
if (testStoragePoolObjSetDefaults(obj) == -1) {
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
virStoragePoolObjSetActive(obj, true);
|
virStoragePoolObjSetActive(obj, true);
|
||||||
|
|
||||||
/* Find storage volumes */
|
/* Find storage volumes */
|
||||||
if (testOpenVolumesForPool(file, ctxt, obj, i+1) < 0) {
|
if (testOpenVolumesForPool(file, ctxt, obj, i+1) < 0) {
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
error:
|
|
||||||
VIR_FREE(nodes);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1126,79 +1106,70 @@ testParseNodedevs(testDriverPtr privconn,
|
|||||||
const char *file,
|
const char *file,
|
||||||
xmlXPathContextPtr ctxt)
|
xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
int num, ret = -1;
|
int num;
|
||||||
size_t i;
|
size_t i;
|
||||||
xmlNodePtr *nodes = NULL;
|
|
||||||
virNodeDeviceObjPtr obj;
|
virNodeDeviceObjPtr obj;
|
||||||
|
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
||||||
|
|
||||||
num = virXPathNodeSet("/node/device", ctxt, &nodes);
|
num = virXPathNodeSet("/node/device", ctxt, &nodes);
|
||||||
if (num < 0)
|
if (num < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
virNodeDeviceDefPtr def;
|
virNodeDeviceDefPtr def;
|
||||||
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
|
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
|
||||||
"nodedev");
|
"nodedev");
|
||||||
if (!node)
|
if (!node)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
def = virNodeDeviceDefParseNode(ctxt->doc, node, 0, NULL);
|
def = virNodeDeviceDefParseNode(ctxt->doc, node, 0, NULL);
|
||||||
if (!def)
|
if (!def)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (!(obj = virNodeDeviceObjListAssignDef(privconn->devs, def))) {
|
if (!(obj = virNodeDeviceObjListAssignDef(privconn->devs, def))) {
|
||||||
virNodeDeviceDefFree(def);
|
virNodeDeviceDefFree(def);
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virNodeDeviceObjSetSkipUpdateCaps(obj, true);
|
virNodeDeviceObjSetSkipUpdateCaps(obj, true);
|
||||||
virNodeDeviceObjEndAPI(&obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
error:
|
|
||||||
VIR_FREE(nodes);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testParseAuthUsers(testDriverPtr privconn,
|
testParseAuthUsers(testDriverPtr privconn,
|
||||||
xmlXPathContextPtr ctxt)
|
xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
int num, ret = -1;
|
int num;
|
||||||
size_t i;
|
size_t i;
|
||||||
xmlNodePtr *nodes = NULL;
|
VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
|
||||||
|
|
||||||
num = virXPathNodeSet("/node/auth/user", ctxt, &nodes);
|
num = virXPathNodeSet("/node/auth/user", ctxt, &nodes);
|
||||||
if (num < 0)
|
if (num < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
privconn->numAuths = num;
|
privconn->numAuths = num;
|
||||||
if (num && VIR_ALLOC_N(privconn->auths, num) < 0)
|
if (num && VIR_ALLOC_N(privconn->auths, num) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
char *username, *password;
|
VIR_AUTOFREE(char *) username = NULL;
|
||||||
|
|
||||||
ctxt->node = nodes[i];
|
ctxt->node = nodes[i];
|
||||||
username = virXPathString("string(.)", ctxt);
|
username = virXPathString("string(.)", ctxt);
|
||||||
if (!username || STREQ(username, "")) {
|
if (!username || STREQ(username, "")) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("missing username in /node/auth/user field"));
|
_("missing username in /node/auth/user field"));
|
||||||
VIR_FREE(username);
|
return -1;
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
/* This field is optional. */
|
/* This field is optional. */
|
||||||
password = virXMLPropString(nodes[i], "password");
|
privconn->auths[i].password = virXMLPropString(nodes[i], "password");
|
||||||
|
VIR_STEAL_PTR(privconn->auths[i].username, username);
|
||||||
privconn->auths[i].username = username;
|
|
||||||
privconn->auths[i].password = password;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
error:
|
|
||||||
VIR_FREE(nodes);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1348,7 +1319,8 @@ testConnectAuthenticate(virConnectPtr conn,
|
|||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
ssize_t i;
|
ssize_t i;
|
||||||
char *username = NULL, *password = NULL;
|
VIR_AUTOFREE(char *) username = NULL;
|
||||||
|
VIR_AUTOFREE(char *) password = NULL;
|
||||||
|
|
||||||
virObjectLock(privconn);
|
virObjectLock(privconn);
|
||||||
if (privconn->numAuths == 0) {
|
if (privconn->numAuths == 0) {
|
||||||
@ -1388,8 +1360,6 @@ testConnectAuthenticate(virConnectPtr conn,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
VIR_FREE(username);
|
|
||||||
VIR_FREE(password);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1977,12 +1947,12 @@ testDomainSaveFlags(virDomainPtr domain, const char *path,
|
|||||||
const char *dxml, unsigned int flags)
|
const char *dxml, unsigned int flags)
|
||||||
{
|
{
|
||||||
testDriverPtr privconn = domain->conn->privateData;
|
testDriverPtr privconn = domain->conn->privateData;
|
||||||
char *xml = NULL;
|
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
int len;
|
int len;
|
||||||
virDomainObjPtr privdom;
|
virDomainObjPtr privdom;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
VIR_AUTOFREE(char *) xml = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
if (dxml) {
|
if (dxml) {
|
||||||
@ -2052,8 +2022,6 @@ testDomainSaveFlags(virDomainPtr domain, const char *path,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(xml);
|
|
||||||
|
|
||||||
/* Don't report failure in close or unlink, because
|
/* Don't report failure in close or unlink, because
|
||||||
* in either case we're already in a failure scenario
|
* in either case we're already in a failure scenario
|
||||||
* and have reported an earlier error */
|
* and have reported an earlier error */
|
||||||
@ -2080,7 +2048,6 @@ testDomainRestoreFlags(virConnectPtr conn,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
char *xml = NULL;
|
|
||||||
char magic[15];
|
char magic[15];
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
int len;
|
int len;
|
||||||
@ -2088,6 +2055,7 @@ testDomainRestoreFlags(virConnectPtr conn,
|
|||||||
virDomainObjPtr dom = NULL;
|
virDomainObjPtr dom = NULL;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
VIR_AUTOFREE(char *) xml = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
if (dxml) {
|
if (dxml) {
|
||||||
@ -2162,7 +2130,6 @@ testDomainRestoreFlags(virConnectPtr conn,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
VIR_FREE(xml);
|
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
virDomainObjEndAPI(&dom);
|
virDomainObjEndAPI(&dom);
|
||||||
virObjectEventStateQueue(privconn->eventState, event);
|
virObjectEventStateQueue(privconn->eventState, event);
|
||||||
@ -2578,7 +2545,7 @@ testDomainRenameCallback(virDomainObjPtr privdom,
|
|||||||
virObjectEventPtr event_new = NULL;
|
virObjectEventPtr event_new = NULL;
|
||||||
virObjectEventPtr event_old = NULL;
|
virObjectEventPtr event_old = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *new_dom_name = NULL;
|
VIR_AUTOFREE(char *) new_dom_name = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
@ -2605,7 +2572,6 @@ testDomainRenameCallback(virDomainObjPtr privdom,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(new_dom_name);
|
|
||||||
virObjectEventStateQueue(driver->eventState, event_old);
|
virObjectEventStateQueue(driver->eventState, event_old);
|
||||||
virObjectEventStateQueue(driver->eventState, event_new);
|
virObjectEventStateQueue(driver->eventState, event_new);
|
||||||
return ret;
|
return ret;
|
||||||
@ -5466,12 +5432,12 @@ testNodeDeviceMockCreateVport(testDriverPtr driver,
|
|||||||
const char *wwnn,
|
const char *wwnn,
|
||||||
const char *wwpn)
|
const char *wwpn)
|
||||||
{
|
{
|
||||||
char *xml = NULL;
|
|
||||||
virNodeDeviceDefPtr def = NULL;
|
virNodeDeviceDefPtr def = NULL;
|
||||||
virNodeDevCapsDefPtr caps;
|
virNodeDevCapsDefPtr caps;
|
||||||
virNodeDeviceObjPtr obj = NULL, objcopy = NULL;
|
virNodeDeviceObjPtr obj = NULL, objcopy = NULL;
|
||||||
virNodeDeviceDefPtr objdef;
|
virNodeDeviceDefPtr objdef;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
|
VIR_AUTOFREE(char *) xml = NULL;
|
||||||
|
|
||||||
/* In the real code, we'd call virVHBAManageVport which would take the
|
/* In the real code, we'd call virVHBAManageVport which would take the
|
||||||
* wwnn/wwpn from the input XML in order to call the "vport_create"
|
* wwnn/wwpn from the input XML in order to call the "vport_create"
|
||||||
@ -5535,7 +5501,6 @@ testNodeDeviceMockCreateVport(testDriverPtr driver,
|
|||||||
virObjectEventStateQueue(driver->eventState, event);
|
virObjectEventStateQueue(driver->eventState, event);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(xml);
|
|
||||||
virNodeDeviceDefFree(def);
|
virNodeDeviceDefFree(def);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -5548,10 +5513,11 @@ testNodeDeviceCreateXML(virConnectPtr conn,
|
|||||||
{
|
{
|
||||||
testDriverPtr driver = conn->privateData;
|
testDriverPtr driver = conn->privateData;
|
||||||
virNodeDeviceDefPtr def = NULL;
|
virNodeDeviceDefPtr def = NULL;
|
||||||
char *wwnn = NULL, *wwpn = NULL;
|
|
||||||
virNodeDevicePtr dev = NULL, ret = NULL;
|
virNodeDevicePtr dev = NULL, ret = NULL;
|
||||||
virNodeDeviceObjPtr obj = NULL;
|
virNodeDeviceObjPtr obj = NULL;
|
||||||
virNodeDeviceDefPtr objdef;
|
virNodeDeviceDefPtr objdef;
|
||||||
|
VIR_AUTOFREE(char *) wwnn = NULL;
|
||||||
|
VIR_AUTOFREE(char *) wwpn = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
@ -5592,8 +5558,6 @@ testNodeDeviceCreateXML(virConnectPtr conn,
|
|||||||
virNodeDeviceObjEndAPI(&obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
virNodeDeviceDefFree(def);
|
virNodeDeviceDefFree(def);
|
||||||
virObjectUnref(dev);
|
virObjectUnref(dev);
|
||||||
VIR_FREE(wwnn);
|
|
||||||
VIR_FREE(wwpn);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5605,8 +5569,9 @@ testNodeDeviceDestroy(virNodeDevicePtr dev)
|
|||||||
virNodeDeviceObjPtr obj = NULL;
|
virNodeDeviceObjPtr obj = NULL;
|
||||||
virNodeDeviceObjPtr parentobj = NULL;
|
virNodeDeviceObjPtr parentobj = NULL;
|
||||||
virNodeDeviceDefPtr def;
|
virNodeDeviceDefPtr def;
|
||||||
char *wwnn = NULL, *wwpn = NULL;
|
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
|
VIR_AUTOFREE(char *) wwnn = NULL;
|
||||||
|
VIR_AUTOFREE(char *) wwpn = NULL;
|
||||||
|
|
||||||
if (!(obj = testNodeDeviceObjFindByName(driver, dev->name)))
|
if (!(obj = testNodeDeviceObjFindByName(driver, dev->name)))
|
||||||
return -1;
|
return -1;
|
||||||
@ -5644,8 +5609,6 @@ testNodeDeviceDestroy(virNodeDevicePtr dev)
|
|||||||
cleanup:
|
cleanup:
|
||||||
virNodeDeviceObjEndAPI(&obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
virObjectEventStateQueue(driver->eventState, event);
|
virObjectEventStateQueue(driver->eventState, event);
|
||||||
VIR_FREE(wwnn);
|
|
||||||
VIR_FREE(wwpn);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user