summaryrefslogtreecommitdiff
path: root/src/util/virqemu.c
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2021-02-16 12:36:15 +0000
committerDaniel P. Berrangé <berrange@redhat.com>2021-02-16 14:03:13 +0000
commit29318399667114b3dd8a054f7ef898b3ba74828d (patch)
treed2a596baab601cd6138e07c2320502f6ced51ae7 /src/util/virqemu.c
parent0d981fcd9754397b11b923ed10209239533f9e86 (diff)
downloadlibvirt-29318399667114b3dd8a054f7ef898b3ba74828d.tar.gz
qemu: remove support for generating yes|no boolean options
All callers are now using the on|off syntax, so yes|no is a unreachable code path. Reviewed-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'src/util/virqemu.c')
-rw-r--r--src/util/virqemu.c50
1 files changed, 17 insertions, 33 deletions
diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index 5b0dc25bc1..57ee42dd16 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -37,7 +37,6 @@ struct virQEMUCommandLineJSONIteratorData {
const char *prefix;
virBufferPtr buf;
const char *skipKey;
- bool onOff;
virQEMUBuildCommandLineJSONArrayFormatFunc arrayFunc;
};
@@ -47,7 +46,6 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
virJSONValuePtr value,
virBufferPtr buf,
const char *skipKey,
- bool onOff,
virQEMUBuildCommandLineJSONArrayFormatFunc arrayFunc,
bool nested);
@@ -57,8 +55,7 @@ int
virQEMUBuildCommandLineJSONArrayBitmap(const char *key,
virJSONValuePtr array,
virBufferPtr buf,
- const char *skipKey G_GNUC_UNUSED,
- bool onOff G_GNUC_UNUSED)
+ const char *skipKey G_GNUC_UNUSED)
{
ssize_t pos = -1;
ssize_t end;
@@ -87,8 +84,7 @@ int
virQEMUBuildCommandLineJSONArrayNumbered(const char *key,
virJSONValuePtr array,
virBufferPtr buf,
- const char *skipKey,
- bool onOff)
+ const char *skipKey)
{
virJSONValuePtr member;
size_t i;
@@ -99,7 +95,7 @@ virQEMUBuildCommandLineJSONArrayNumbered(const char *key,
member = virJSONValueArrayGet((virJSONValuePtr) array, i);
prefix = g_strdup_printf("%s.%zu", key, i);
- if (virQEMUBuildCommandLineJSONRecurse(prefix, member, buf, skipKey, onOff,
+ if (virQEMUBuildCommandLineJSONRecurse(prefix, member, buf, skipKey,
virQEMUBuildCommandLineJSONArrayNumbered,
true) < 0)
return 0;
@@ -125,8 +121,7 @@ static int
virQEMUBuildCommandLineJSONArrayObjectsStr(const char *key,
virJSONValuePtr array,
virBufferPtr buf,
- const char *skipKey G_GNUC_UNUSED,
- bool onOff G_GNUC_UNUSED)
+ const char *skipKey G_GNUC_UNUSED)
{
g_auto(virBuffer) tmp = VIR_BUFFER_INITIALIZER;
size_t i;
@@ -163,11 +158,11 @@ virQEMUBuildCommandLineJSONIterate(const char *key,
tmpkey = g_strdup_printf("%s.%s", data->prefix, key);
return virQEMUBuildCommandLineJSONRecurse(tmpkey, value, data->buf,
- data->skipKey, data->onOff,
+ data->skipKey,
data->arrayFunc, false);
} else {
return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf,
- data->skipKey, data->onOff,
+ data->skipKey,
data->arrayFunc, false);
}
}
@@ -178,11 +173,10 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
virJSONValuePtr value,
virBufferPtr buf,
const char *skipKey,
- bool onOff,
virQEMUBuildCommandLineJSONArrayFormatFunc arrayFunc,
bool nested)
{
- struct virQEMUCommandLineJSONIteratorData data = { key, buf, skipKey, onOff, arrayFunc };
+ struct virQEMUCommandLineJSONIteratorData data = { key, buf, skipKey, arrayFunc };
virJSONType type = virJSONValueGetType(value);
virJSONValuePtr elem;
bool tmp;
@@ -207,18 +201,10 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
case VIR_JSON_TYPE_BOOLEAN:
virJSONValueGetBoolean(value, &tmp);
- if (onOff) {
- if (tmp)
- virBufferAsprintf(buf, "%s=on,", key);
- else
- virBufferAsprintf(buf, "%s=off,", key);
- } else {
- if (tmp)
- virBufferAsprintf(buf, "%s=yes,", key);
- else
- virBufferAsprintf(buf, "%s=no,", key);
- }
-
+ if (tmp)
+ virBufferAsprintf(buf, "%s=on,", key);
+ else
+ virBufferAsprintf(buf, "%s=off,", key);
break;
case VIR_JSON_TYPE_ARRAY:
@@ -229,7 +215,7 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
return -1;
}
- if (!arrayFunc || arrayFunc(key, value, buf, skipKey, onOff) < 0) {
+ if (!arrayFunc || arrayFunc(key, value, buf, skipKey) < 0) {
/* fallback, treat the array as a non-bitmap, adding the key
* for each member */
for (i = 0; i < virJSONValueArraySize(value); i++) {
@@ -237,7 +223,7 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
/* recurse to avoid duplicating code */
if (virQEMUBuildCommandLineJSONRecurse(key, elem, buf, skipKey,
- onOff, arrayFunc, true) < 0)
+ arrayFunc, true) < 0)
return -1;
}
}
@@ -265,7 +251,6 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
* @value: json object containing the value
* @buf: otuput buffer
* @skipKey: name of key that will be handled separately by caller
- * @onOff: Use 'on' and 'off' for boolean values rather than 'yes' and 'no'
* @arrayFunc: array formatter function to allow for different syntax
*
* Formats JSON value object into command line parameters suitable for use with
@@ -277,10 +262,9 @@ int
virQEMUBuildCommandLineJSON(virJSONValuePtr value,
virBufferPtr buf,
const char *skipKey,
- bool onOff,
virQEMUBuildCommandLineJSONArrayFormatFunc array)
{
- if (virQEMUBuildCommandLineJSONRecurse(NULL, value, buf, skipKey, onOff, array, false) < 0)
+ if (virQEMUBuildCommandLineJSONRecurse(NULL, value, buf, skipKey, array, false) < 0)
return -1;
virBufferTrim(buf, ",");
@@ -311,7 +295,7 @@ virQEMUBuildNetdevCommandlineFromJSON(virJSONValuePtr props,
virBufferAsprintf(&buf, "%s,", type);
- if (virQEMUBuildCommandLineJSON(props, &buf, "type", true,
+ if (virQEMUBuildCommandLineJSON(props, &buf, "type",
virQEMUBuildCommandLineJSONArrayObjectsStr) < 0)
return NULL;
@@ -336,7 +320,7 @@ virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf,
if (props) {
virBufferAddLit(buf, ",");
- if (virQEMUBuildCommandLineJSON(props, buf, NULL, true,
+ if (virQEMUBuildCommandLineJSON(props, buf, NULL,
virQEMUBuildCommandLineJSONArrayBitmap) < 0)
return -1;
}
@@ -362,7 +346,7 @@ virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr srcdef)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- if (virQEMUBuildCommandLineJSON(srcdef, &buf, NULL, true,
+ if (virQEMUBuildCommandLineJSON(srcdef, &buf, NULL,
virQEMUBuildCommandLineJSONArrayNumbered) < 0)
return NULL;