提交 486bfba8 编写于 作者: P Peter Krempa

util: virqemu: Introduce virQEMUBuildNetdevCommandlineFromJSON

In preparation for converting the generator of -netdev to generate JSON
which will be used to do the command line rather than the other way
around we need to introduce a convertor which properly configures
virQEMUBuildCommandLineJSON for the quirks of -netdev.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
上级 eb56a986
......@@ -2915,6 +2915,7 @@ virQEMUBuildCommandLineJSON;
virQEMUBuildCommandLineJSONArrayBitmap;
virQEMUBuildCommandLineJSONArrayNumbered;
virQEMUBuildDriveCommandlineFromJSON;
virQEMUBuildNetdevCommandlineFromJSON;
virQEMUBuildObjectCommandlineFromJSON;
virQEMUBuildQemuImgKeySecretOpts;
......
......@@ -252,6 +252,28 @@ virQEMUBuildCommandLineJSON(virJSONValuePtr value,
}
/**
* virQEMUBuildNetdevCommandlineFromJSON:
* @props: JSON properties describing a netdev
*
* Converts @props into arguments for -netdev including all the quirks and
* differences between the monitor and command line syntax.
*/
char *
virQEMUBuildNetdevCommandlineFromJSON(virJSONValuePtr props)
{
const char *type = virJSONValueObjectGetString(props, "type");
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virBufferAsprintf(&buf, "%s,", type);
if (virQEMUBuildCommandLineJSON(props, &buf, "type", true, NULL) < 0)
return NULL;
return virBufferContentAndReset(&buf);
}
static int
virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf,
const char *type,
......
......@@ -49,6 +49,9 @@ int virQEMUBuildCommandLineJSON(virJSONValuePtr value,
bool onOff,
virQEMUBuildCommandLineJSONArrayFormatFunc array);
char *
virQEMUBuildNetdevCommandlineFromJSON(virJSONValuePtr props);
int virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf,
virJSONValuePtr objprops);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册