mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Move qemuFreeKeywords into qemu_parse_command.c
Move qemuFreeKeywords into qemu_parse_command.c as qemuParseKeywordsFree and call it rather than inline code in multiple places. Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
This commit is contained in:
parent
0997257016
commit
7702cc1f80
@ -468,17 +468,6 @@ qemuMonitorJSONMakeCommandRaw(bool wrap, const char *cmdname, ...)
|
|||||||
#define qemuMonitorJSONMakeCommand(cmdname, ...) \
|
#define qemuMonitorJSONMakeCommand(cmdname, ...) \
|
||||||
qemuMonitorJSONMakeCommandRaw(false, cmdname, __VA_ARGS__)
|
qemuMonitorJSONMakeCommandRaw(false, cmdname, __VA_ARGS__)
|
||||||
|
|
||||||
static void
|
|
||||||
qemuFreeKeywords(int nkeywords, char **keywords, char **values)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
for (i = 0; i < nkeywords; i++) {
|
|
||||||
VIR_FREE(keywords[i]);
|
|
||||||
VIR_FREE(values[i]);
|
|
||||||
}
|
|
||||||
VIR_FREE(keywords);
|
|
||||||
VIR_FREE(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
static virJSONValuePtr
|
static virJSONValuePtr
|
||||||
qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
|
qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
|
||||||
@ -513,11 +502,11 @@ qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuFreeKeywords(nkeywords, keywords, values);
|
qemuParseKeywordsFree(nkeywords, keywords, values);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
qemuFreeKeywords(nkeywords, keywords, values);
|
qemuParseKeywordsFree(nkeywords, keywords, values);
|
||||||
virJSONValueFree(ret);
|
virJSONValueFree(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -381,6 +381,22 @@ static const char *qemuFindEnv(char **progenv,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
qemuParseKeywordsFree(int nkeywords,
|
||||||
|
char **keywords,
|
||||||
|
char **values)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < nkeywords; i++) {
|
||||||
|
VIR_FREE(keywords[i]);
|
||||||
|
VIR_FREE(values[i]);
|
||||||
|
}
|
||||||
|
VIR_FREE(keywords);
|
||||||
|
VIR_FREE(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Takes a string containing a set of key=value,key=value,key...
|
* Takes a string containing a set of key=value,key=value,key...
|
||||||
* parameters and splits them up, returning two arrays with
|
* parameters and splits them up, returning two arrays with
|
||||||
@ -401,7 +417,6 @@ qemuParseKeywords(const char *str,
|
|||||||
char **values = NULL;
|
char **values = NULL;
|
||||||
const char *start = str;
|
const char *start = str;
|
||||||
const char *end;
|
const char *end;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
*retkeywords = NULL;
|
*retkeywords = NULL;
|
||||||
*retvalues = NULL;
|
*retvalues = NULL;
|
||||||
@ -479,12 +494,7 @@ qemuParseKeywords(const char *str,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (i = 0; i < keywordCount; i++) {
|
qemuParseKeywordsFree(keywordCount, keywords, values);
|
||||||
VIR_FREE(keywords[i]);
|
|
||||||
VIR_FREE(values[i]);
|
|
||||||
}
|
|
||||||
VIR_FREE(keywords);
|
|
||||||
VIR_FREE(values);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,12 +959,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
for (i = 0; i < nkeywords; i++) {
|
qemuParseKeywordsFree(nkeywords, keywords, values);
|
||||||
VIR_FREE(keywords[i]);
|
|
||||||
VIR_FREE(values[i]);
|
|
||||||
}
|
|
||||||
VIR_FREE(keywords);
|
|
||||||
VIR_FREE(values);
|
|
||||||
return def;
|
return def;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -1132,12 +1137,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
|
|||||||
virDomainNetGenerateMAC(xmlopt, &def->mac);
|
virDomainNetGenerateMAC(xmlopt, &def->mac);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
for (i = 0; i < nkeywords; i++) {
|
qemuParseKeywordsFree(nkeywords, keywords, values);
|
||||||
VIR_FREE(keywords[i]);
|
|
||||||
VIR_FREE(values[i]);
|
|
||||||
}
|
|
||||||
VIR_FREE(keywords);
|
|
||||||
VIR_FREE(values);
|
|
||||||
return def;
|
return def;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -1704,13 +1704,7 @@ qemuParseCommandLineMem(virDomainDefPtr dom,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
for (i = 0; i < nkws; i++) {
|
qemuParseKeywordsFree(nkws, kws, vals);
|
||||||
VIR_FREE(kws[i]);
|
|
||||||
VIR_FREE(vals[i]);
|
|
||||||
}
|
|
||||||
VIR_FREE(kws);
|
|
||||||
VIR_FREE(vals);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1795,13 +1789,7 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
for (i = 0; i < nkws; i++) {
|
qemuParseKeywordsFree(nkws, kws, vals);
|
||||||
VIR_FREE(kws[i]);
|
|
||||||
VIR_FREE(vals[i]);
|
|
||||||
}
|
|
||||||
VIR_FREE(kws);
|
|
||||||
VIR_FREE(vals);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
syntax:
|
syntax:
|
||||||
|
@ -43,6 +43,11 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr caps,
|
|||||||
virDomainChrSourceDefPtr *monConfig,
|
virDomainChrSourceDefPtr *monConfig,
|
||||||
bool *monJSON);
|
bool *monJSON);
|
||||||
|
|
||||||
|
void
|
||||||
|
qemuParseKeywordsFree(int nkeywords,
|
||||||
|
char **keywords,
|
||||||
|
char **values);
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuParseKeywords(const char *str,
|
qemuParseKeywords(const char *str,
|
||||||
char ***retkeywords,
|
char ***retkeywords,
|
||||||
|
Loading…
Reference in New Issue
Block a user