@@ -898,7 +898,8 @@ static bool qobject_is_empty_dump(const QObject *obj)
898
898
* prepending an optional prefix if the dump is not empty.
899
899
*/
900
900
void bdrv_image_info_specific_dump (ImageInfoSpecific * info_spec ,
901
- const char * prefix )
901
+ const char * prefix ,
902
+ int indentation )
902
903
{
903
904
QObject * obj , * data ;
904
905
Visitor * v = qobject_output_visitor_new (& obj );
@@ -908,48 +909,51 @@ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec,
908
909
data = qdict_get (qobject_to (QDict , obj ), "data" );
909
910
if (!qobject_is_empty_dump (data )) {
910
911
if (prefix ) {
911
- qemu_printf ("%s " , prefix );
912
+ qemu_printf ("%*s%s" , indentation * 4 , " " , prefix );
912
913
}
913
- dump_qobject (1 , data );
914
+ dump_qobject (indentation + 1 , data );
914
915
}
915
916
qobject_unref (obj );
916
917
visit_free (v );
917
918
}
918
919
919
- void bdrv_node_info_dump (BlockNodeInfo * info )
920
+ void bdrv_node_info_dump (BlockNodeInfo * info , int indentation )
920
921
{
921
922
char * size_buf , * dsize_buf ;
923
+ g_autofree char * ind_s = g_strdup_printf ("%*s" , indentation * 4 , "" );
924
+
922
925
if (!info -> has_actual_size ) {
923
926
dsize_buf = g_strdup ("unavailable" );
924
927
} else {
925
928
dsize_buf = size_to_str (info -> actual_size );
926
929
}
927
930
size_buf = size_to_str (info -> virtual_size );
928
- qemu_printf ("image: %s\n"
929
- "file format: %s\n"
930
- "virtual size: %s (%" PRId64 " bytes)\n"
931
- "disk size: %s\n" ,
932
- info -> filename , info -> format , size_buf ,
933
- info -> virtual_size ,
934
- dsize_buf );
931
+ qemu_printf ("%simage: %s\n"
932
+ "%sfile format: %s\n"
933
+ "%svirtual size: %s (%" PRId64 " bytes)\n"
934
+ "%sdisk size: %s\n" ,
935
+ ind_s , info -> filename ,
936
+ ind_s , info -> format ,
937
+ ind_s , size_buf , info -> virtual_size ,
938
+ ind_s , dsize_buf );
935
939
g_free (size_buf );
936
940
g_free (dsize_buf );
937
941
938
942
if (info -> has_encrypted && info -> encrypted ) {
939
- qemu_printf ("encrypted : yes\n" );
943
+ qemu_printf ("%sencrypted : yes\n" , ind_s );
940
944
}
941
945
942
946
if (info -> has_cluster_size ) {
943
- qemu_printf ("cluster_size : %" PRId64 "\n" ,
944
- info -> cluster_size );
947
+ qemu_printf ("%scluster_size : %" PRId64 "\n" ,
948
+ ind_s , info -> cluster_size );
945
949
}
946
950
947
951
if (info -> has_dirty_flag && info -> dirty_flag ) {
948
- qemu_printf ("cleanly shut down: no\n" );
952
+ qemu_printf ("%scleanly shut down: no\n" , ind_s );
949
953
}
950
954
951
955
if (info -> backing_filename ) {
952
- qemu_printf ("backing file: %s" , info -> backing_filename );
956
+ qemu_printf ("%sbacking file: %s" , ind_s , info -> backing_filename );
953
957
if (!info -> full_backing_filename ) {
954
958
qemu_printf (" (cannot determine actual path)" );
955
959
} else if (strcmp (info -> backing_filename ,
@@ -958,15 +962,16 @@ void bdrv_node_info_dump(BlockNodeInfo *info)
958
962
}
959
963
qemu_printf ("\n" );
960
964
if (info -> backing_filename_format ) {
961
- qemu_printf ("backing file format: %s\n" ,
962
- info -> backing_filename_format );
965
+ qemu_printf ("%sbacking file format: %s\n" ,
966
+ ind_s , info -> backing_filename_format );
963
967
}
964
968
}
965
969
966
970
if (info -> has_snapshots ) {
967
971
SnapshotInfoList * elem ;
968
972
969
- qemu_printf ("Snapshot list:\n" );
973
+ qemu_printf ("%sSnapshot list:\n" , ind_s );
974
+ qemu_printf ("%s" , ind_s );
970
975
bdrv_snapshot_dump (NULL );
971
976
qemu_printf ("\n" );
972
977
@@ -986,13 +991,15 @@ void bdrv_node_info_dump(BlockNodeInfo *info)
986
991
987
992
pstrcpy (sn .id_str , sizeof (sn .id_str ), elem -> value -> id );
988
993
pstrcpy (sn .name , sizeof (sn .name ), elem -> value -> name );
994
+ qemu_printf ("%s" , ind_s );
989
995
bdrv_snapshot_dump (& sn );
990
996
qemu_printf ("\n" );
991
997
}
992
998
}
993
999
994
1000
if (info -> format_specific ) {
995
1001
bdrv_image_info_specific_dump (info -> format_specific ,
996
- "Format specific information:\n" );
1002
+ "Format specific information:\n" ,
1003
+ indentation );
997
1004
}
998
1005
}
0 commit comments