mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
virQEMUBuildDriveCommandlineFromJSON: Open-code in callers
Optimize the number of string copies by using the virBuffers in the callers directly. Simplest way to achieve this is to just open code the one function call 'virQEMUBuildDriveCommandlineFromJSON' was wrapping in the two callers. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
424dc5d2d2
commit
803d3f2ca0
@ -3119,7 +3119,6 @@ virQEMUBuildCommandLineJSON;
|
||||
virQEMUBuildCommandLineJSONArrayBitmap;
|
||||
virQEMUBuildCommandLineJSONArrayNumbered;
|
||||
virQEMUBuildCommandLineJSONArrayObjectsStr;
|
||||
virQEMUBuildDriveCommandlineFromJSON;
|
||||
|
||||
|
||||
# util/virrandom.h
|
||||
|
@ -1252,10 +1252,9 @@ qemuBuildDriveSourceStr(virDomainDiskDef *disk,
|
||||
if (qemuBuildDriveSourcePR(buf, disk) < 0)
|
||||
return -1;
|
||||
} else {
|
||||
if (!(source = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
|
||||
if (virQEMUBuildCommandLineJSON(srcprops, buf, NULL,
|
||||
virQEMUBuildCommandLineJSONArrayNumbered) < 0)
|
||||
return -1;
|
||||
|
||||
virBufferAdd(buf, source, -1);
|
||||
}
|
||||
virBufferAddLit(buf, ",");
|
||||
|
||||
@ -4533,16 +4532,18 @@ static char *
|
||||
qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDef *dev)
|
||||
{
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
g_autofree char *netsource = NULL;
|
||||
g_autoptr(virJSONValue) srcprops = NULL;
|
||||
virDomainHostdevSubsysSCSI *scsisrc = &dev->source.subsys.u.scsi;
|
||||
virDomainHostdevSubsysSCSIiSCSI *iscsisrc = &scsisrc->u.iscsi;
|
||||
|
||||
if (!(srcprops = qemuDiskSourceGetProps(iscsisrc->src)))
|
||||
return NULL;
|
||||
if (!(netsource = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
|
||||
|
||||
if (virQEMUBuildCommandLineJSON(srcprops, &buf, NULL,
|
||||
virQEMUBuildCommandLineJSONArrayNumbered) < 0)
|
||||
return NULL;
|
||||
virBufferAsprintf(&buf, "%s,if=none,format=raw", netsource);
|
||||
|
||||
virBufferAddLit(&buf, ",if=none,format=raw");
|
||||
|
||||
return virBufferContentAndReset(&buf);
|
||||
}
|
||||
|
@ -283,19 +283,6 @@ virQEMUBuildCommandLineJSON(virJSONValue *value,
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
virQEMUBuildDriveCommandlineFromJSON(virJSONValue *srcdef)
|
||||
{
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
if (virQEMUBuildCommandLineJSON(srcdef, &buf, NULL,
|
||||
virQEMUBuildCommandLineJSONArrayNumbered) < 0)
|
||||
return NULL;
|
||||
|
||||
return virBufferContentAndReset(&buf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virQEMUBuildBufferEscapeComma:
|
||||
* @buf: buffer to append the escaped string
|
||||
|
@ -48,6 +48,4 @@ int virQEMUBuildCommandLineJSON(virJSONValue *value,
|
||||
const char *skipKey,
|
||||
virQEMUBuildCommandLineJSONArrayFormatFunc array);
|
||||
|
||||
char *virQEMUBuildDriveCommandlineFromJSON(virJSONValue *src);
|
||||
|
||||
void virQEMUBuildBufferEscapeComma(virBuffer *buf, const char *str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user