提交 72e8c721 编写于 作者: D Daniel P. Berrangé

storage: pass struct _virStorageBackendQemuImgInfo by reference

The struct _virStorageBackendQemuImgInfo is quite large so it is
preferrable to pass it by reference instead of by value. This requires
us to stop modifying the "compat" field.
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 75d4defe
...@@ -742,38 +742,40 @@ struct _virStorageBackendQemuImgInfo { ...@@ -742,38 +742,40 @@ struct _virStorageBackendQemuImgInfo {
static int static int
storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr encinfo, storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr encinfo,
char **opts, char **opts,
struct _virStorageBackendQemuImgInfo info) struct _virStorageBackendQemuImgInfo *info)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
if (info.backingPath) if (info->backingPath)
virBufferAsprintf(&buf, "backing_fmt=%s,", virBufferAsprintf(&buf, "backing_fmt=%s,",
virStorageFileFormatTypeToString(info.backingFormat)); virStorageFileFormatTypeToString(info->backingFormat));
if (encinfo) if (encinfo)
virQEMUBuildQemuImgKeySecretOpts(&buf, encinfo, info.secretAlias); virQEMUBuildQemuImgKeySecretOpts(&buf, encinfo, info->secretAlias);
if (info.preallocate) { if (info->preallocate) {
if (info.size_arg > info.allocation) if (info->size_arg > info->allocation)
virBufferAddLit(&buf, "preallocation=metadata,"); virBufferAddLit(&buf, "preallocation=metadata,");
else else
virBufferAddLit(&buf, "preallocation=falloc,"); virBufferAddLit(&buf, "preallocation=falloc,");
} }
if (info.nocow) if (info->nocow)
virBufferAddLit(&buf, "nocow=on,"); virBufferAddLit(&buf, "nocow=on,");
if (info.compat) if (info->compat)
virBufferAsprintf(&buf, "compat=%s,", info.compat); virBufferAsprintf(&buf, "compat=%s,", info->compat);
else if (info->format == VIR_STORAGE_FILE_QCOW2)
virBufferAddLit(&buf, "compat=0.10,");
if (info.features && info.format == VIR_STORAGE_FILE_QCOW2) { if (info->features && info->format == VIR_STORAGE_FILE_QCOW2) {
if (virBitmapIsBitSet(info.features, if (virBitmapIsBitSet(info->features,
VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS)) { VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS)) {
if (STREQ_NULLABLE(info.compat, "0.10")) { if (STREQ_NULLABLE(info->compat, "0.10")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("lazy_refcounts not supported with compat" _("lazy_refcounts not supported with compat"
" level %s"), " level %s"),
info.compat); info->compat);
goto error; goto error;
} }
virBufferAddLit(&buf, "lazy_refcounts,"); virBufferAddLit(&buf, "lazy_refcounts,");
...@@ -942,13 +944,10 @@ storageBackendCreateQemuImgSetBacking(virStoragePoolObjPtr pool, ...@@ -942,13 +944,10 @@ storageBackendCreateQemuImgSetBacking(virStoragePoolObjPtr pool,
static int static int
storageBackendCreateQemuImgSetOptions(virCommandPtr cmd, storageBackendCreateQemuImgSetOptions(virCommandPtr cmd,
virStorageEncryptionInfoDefPtr encinfo, virStorageEncryptionInfoDefPtr encinfo,
struct _virStorageBackendQemuImgInfo info) struct _virStorageBackendQemuImgInfo *info)
{ {
char *opts = NULL; char *opts = NULL;
if (info.format == VIR_STORAGE_FILE_QCOW2 && !info.compat)
info.compat = "0.10";
if (storageBackendCreateQemuImgOpts(encinfo, &opts, info) < 0) if (storageBackendCreateQemuImgOpts(encinfo, &opts, info) < 0)
return -1; return -1;
if (opts) if (opts)
...@@ -1196,7 +1195,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, ...@@ -1196,7 +1195,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool,
} }
if (convertStep != VIR_STORAGE_VOL_ENCRYPT_CONVERT) { if (convertStep != VIR_STORAGE_VOL_ENCRYPT_CONVERT) {
if (storageBackendCreateQemuImgSetOptions(cmd, encinfo, info) < 0) if (storageBackendCreateQemuImgSetOptions(cmd, encinfo, &info) < 0)
goto error; goto error;
if (info.inputPath) if (info.inputPath)
virCommandAddArg(cmd, info.inputPath); virCommandAddArg(cmd, info.inputPath);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册