qemu: block: Use 'format' nodename accessors in '-blockdev' setup code

Convert the main -blockdev JSON object setup code to use the new
accessors. In these we use mainly the real 'format' layer node name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-03-04 14:54:00 +01:00
parent 90fc8ef2a3
commit 67600bd00d

View File

@ -1282,7 +1282,7 @@ qemuBlockStorageSourceGetBlockdevFormatCommonProps(virStorageSource *src)
src->detect_zeroes); src->detect_zeroes);
g_autoptr(virJSONValue) props = NULL; g_autoptr(virJSONValue) props = NULL;
if (qemuBlockNodeNameValidate(src->nodeformat) < 0) if (qemuBlockNodeNameValidate(qemuBlockStorageSourceGetFormatNodename(src)) < 0)
return NULL; return NULL;
if (src->discard) if (src->discard)
@ -1296,7 +1296,7 @@ qemuBlockStorageSourceGetBlockdevFormatCommonProps(virStorageSource *src)
*/ */
if (virJSONValueObjectAdd(&props, if (virJSONValueObjectAdd(&props,
"s:node-name", src->nodeformat, "s:node-name", qemuBlockStorageSourceGetFormatNodename(src),
"b:read-only", src->readonly, "b:read-only", src->readonly,
"S:discard", discard, "S:discard", discard,
"S:detect-zeroes", detectZeroes, "S:detect-zeroes", detectZeroes,
@ -1530,7 +1530,7 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSource *src,
return NULL; return NULL;
data->storageNodeName = qemuBlockStorageSourceGetStorageNodename(src); data->storageNodeName = qemuBlockStorageSourceGetStorageNodename(src);
data->formatNodeName = src->nodeformat; data->formatNodeName = qemuBlockStorageSourceGetFormatNodename(src);
if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) { if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) {
if (!(data->storageSliceProps = qemuBlockStorageSourceGetBlockdevStorageSliceProps(src))) if (!(data->storageSliceProps = qemuBlockStorageSourceGetBlockdevStorageSliceProps(src)))
@ -1748,7 +1748,7 @@ qemuBlockStorageSourceDetachPrepare(virStorageSource *src)
data = g_new0(qemuBlockStorageSourceAttachData, 1); data = g_new0(qemuBlockStorageSourceAttachData, 1);
data->formatNodeName = src->nodeformat; data->formatNodeName = qemuBlockStorageSourceGetFormatNodename(src);
data->formatAttached = true; data->formatAttached = true;
data->storageNodeName = qemuBlockStorageSourceGetStorageNodename(src); data->storageNodeName = qemuBlockStorageSourceGetStorageNodename(src);
data->storageAttached = true; data->storageAttached = true;
@ -1941,7 +1941,8 @@ qemuBlockStorageSourceDetachOneBlockdev(virDomainObj *vm,
if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
return -1; return -1;
ret = qemuMonitorBlockdevDel(qemuDomainGetMonitor(vm), src->nodeformat); ret = qemuMonitorBlockdevDel(qemuDomainGetMonitor(vm),
qemuBlockStorageSourceGetFormatNodename(src));
if (ret == 0) if (ret == 0)
ret = qemuMonitorBlockdevDel(qemuDomainGetMonitor(vm), ret = qemuMonitorBlockdevDel(qemuDomainGetMonitor(vm),
@ -1959,8 +1960,8 @@ qemuBlockSnapshotAddBlockdev(virJSONValue *actions,
virStorageSource *newsrc) virStorageSource *newsrc)
{ {
return qemuMonitorTransactionSnapshotBlockdev(actions, return qemuMonitorTransactionSnapshotBlockdev(actions,
disk->src->nodeformat, qemuBlockStorageSourceGetEffectiveNodename(disk->src),
newsrc->nodeformat); qemuBlockStorageSourceGetFormatNodename(newsrc));
} }