diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 64bece59aa..3af5c3b7ed 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -536,6 +536,20 @@ virNodeDeviceCapSCSIDefFormat(virBuffer *buf, } +static void +virNodeDeviceCapStorageDefFormatBlocksize(virBuffer *buf, + const virNodeDevCapData *data) +{ + if (data->storage.logical_block_size > 0) + virBufferAsprintf(buf, "%llu\n", + data->storage.logical_block_size); + + if (data->storage.num_blocks > 0) + virBufferAsprintf(buf, "%llu\n", + data->storage.num_blocks); +} + + static void virNodeDeviceCapStorageDefFormat(virBuffer *buf, const virNodeDevCapData *data) @@ -557,27 +571,14 @@ virNodeDeviceCapStorageDefFormat(virBuffer *buf, virBufferAsprintf(buf, "%llu\n", data->storage.removable_media_size); virBufferEscapeString(buf, "%s\n", data->storage.media_label); - if (data->storage.logical_block_size > 0) - virBufferAsprintf(buf, "%llu" - "\n", - data->storage.logical_block_size); - if (data->storage.num_blocks > 0) - virBufferAsprintf(buf, - "%llu\n", - data->storage.num_blocks); + virNodeDeviceCapStorageDefFormatBlocksize(buf, data); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } else { - virBufferAsprintf(buf, "%llu\n", - data->storage.size); - if (data->storage.logical_block_size > 0) - virBufferAsprintf(buf, "%llu" - "\n", - data->storage.logical_block_size); - if (data->storage.num_blocks > 0) - virBufferAsprintf(buf, "%llu\n", - data->storage.num_blocks); + virBufferAsprintf(buf, "%llu\n", data->storage.size); + virNodeDeviceCapStorageDefFormatBlocksize(buf, data); } + if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE) virBufferAddLit(buf, "\n"); }