1 /* 2 * Block layer qmp and info dump related functions 3 * 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 #include "block/qapi.h" 26 #include "block/block_int.h" 27 #include "block/write-threshold.h" 28 #include "qmp-commands.h" 29 #include "qapi-visit.h" 30 #include "qapi/qmp-output-visitor.h" 31 #include "qapi/qmp/types.h" 32 #include "sysemu/block-backend.h" 33 34 BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs) 35 { 36 BlockDeviceInfo *info = g_malloc0(sizeof(*info)); 37 38 info->file = g_strdup(bs->filename); 39 info->ro = bs->read_only; 40 info->drv = g_strdup(bs->drv->format_name); 41 info->encrypted = bs->encrypted; 42 info->encryption_key_missing = bdrv_key_required(bs); 43 44 info->cache = g_new(BlockdevCacheInfo, 1); 45 *info->cache = (BlockdevCacheInfo) { 46 .writeback = bdrv_enable_write_cache(bs), 47 .direct = !!(bs->open_flags & BDRV_O_NOCACHE), 48 .no_flush = !!(bs->open_flags & BDRV_O_NO_FLUSH), 49 }; 50 51 if (bs->node_name[0]) { 52 info->has_node_name = true; 53 info->node_name = g_strdup(bs->node_name); 54 } 55 56 if (bs->backing_file[0]) { 57 info->has_backing_file = true; 58 info->backing_file = g_strdup(bs->backing_file); 59 } 60 61 info->backing_file_depth = bdrv_get_backing_file_depth(bs); 62 info->detect_zeroes = bs->detect_zeroes; 63 64 if (bs->io_limits_enabled) { 65 ThrottleConfig cfg; 66 throttle_get_config(&bs->throttle_state, &cfg); 67 info->bps = cfg.buckets[THROTTLE_BPS_TOTAL].avg; 68 info->bps_rd = cfg.buckets[THROTTLE_BPS_READ].avg; 69 info->bps_wr = cfg.buckets[THROTTLE_BPS_WRITE].avg; 70 71 info->iops = cfg.buckets[THROTTLE_OPS_TOTAL].avg; 72 info->iops_rd = cfg.buckets[THROTTLE_OPS_READ].avg; 73 info->iops_wr = cfg.buckets[THROTTLE_OPS_WRITE].avg; 74 75 info->has_bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max; 76 info->bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max; 77 info->has_bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max; 78 info->bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max; 79 info->has_bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max; 80 info->bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max; 81 82 info->has_iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max; 83 info->iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max; 84 info->has_iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max; 85 info->iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max; 86 info->has_iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max; 87 info->iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max; 88 89 info->has_iops_size = cfg.op_size; 90 info->iops_size = cfg.op_size; 91 } 92 93 info->write_threshold = bdrv_write_threshold_get(bs); 94 95 return info; 96 } 97 98 /* 99 * Returns 0 on success, with *p_list either set to describe snapshot 100 * information, or NULL because there are no snapshots. Returns -errno on 101 * error, with *p_list untouched. 102 */ 103 int bdrv_query_snapshot_info_list(BlockDriverState *bs, 104 SnapshotInfoList **p_list, 105 Error **errp) 106 { 107 int i, sn_count; 108 QEMUSnapshotInfo *sn_tab = NULL; 109 SnapshotInfoList *info_list, *cur_item = NULL, *head = NULL; 110 SnapshotInfo *info; 111 112 sn_count = bdrv_snapshot_list(bs, &sn_tab); 113 if (sn_count < 0) { 114 const char *dev = bdrv_get_device_name(bs); 115 switch (sn_count) { 116 case -ENOMEDIUM: 117 error_setg(errp, "Device '%s' is not inserted", dev); 118 break; 119 case -ENOTSUP: 120 error_setg(errp, 121 "Device '%s' does not support internal snapshots", 122 dev); 123 break; 124 default: 125 error_setg_errno(errp, -sn_count, 126 "Can't list snapshots of device '%s'", dev); 127 break; 128 } 129 return sn_count; 130 } 131 132 for (i = 0; i < sn_count; i++) { 133 info = g_new0(SnapshotInfo, 1); 134 info->id = g_strdup(sn_tab[i].id_str); 135 info->name = g_strdup(sn_tab[i].name); 136 info->vm_state_size = sn_tab[i].vm_state_size; 137 info->date_sec = sn_tab[i].date_sec; 138 info->date_nsec = sn_tab[i].date_nsec; 139 info->vm_clock_sec = sn_tab[i].vm_clock_nsec / 1000000000; 140 info->vm_clock_nsec = sn_tab[i].vm_clock_nsec % 1000000000; 141 142 info_list = g_new0(SnapshotInfoList, 1); 143 info_list->value = info; 144 145 /* XXX: waiting for the qapi to support qemu-queue.h types */ 146 if (!cur_item) { 147 head = cur_item = info_list; 148 } else { 149 cur_item->next = info_list; 150 cur_item = info_list; 151 } 152 153 } 154 155 g_free(sn_tab); 156 *p_list = head; 157 return 0; 158 } 159 160 /** 161 * bdrv_query_image_info: 162 * @bs: block device to examine 163 * @p_info: location to store image information 164 * @errp: location to store error information 165 * 166 * Store "flat" image information in @p_info. 167 * 168 * "Flat" means it does *not* query backing image information, 169 * i.e. (*pinfo)->has_backing_image will be set to false and 170 * (*pinfo)->backing_image to NULL even when the image does in fact have 171 * a backing image. 172 * 173 * @p_info will be set only on success. On error, store error in @errp. 174 */ 175 void bdrv_query_image_info(BlockDriverState *bs, 176 ImageInfo **p_info, 177 Error **errp) 178 { 179 int64_t size; 180 const char *backing_filename; 181 BlockDriverInfo bdi; 182 int ret; 183 Error *err = NULL; 184 ImageInfo *info; 185 186 size = bdrv_getlength(bs); 187 if (size < 0) { 188 error_setg_errno(errp, -size, "Can't get size of device '%s'", 189 bdrv_get_device_name(bs)); 190 return; 191 } 192 193 info = g_new0(ImageInfo, 1); 194 info->filename = g_strdup(bs->filename); 195 info->format = g_strdup(bdrv_get_format_name(bs)); 196 info->virtual_size = size; 197 info->actual_size = bdrv_get_allocated_file_size(bs); 198 info->has_actual_size = info->actual_size >= 0; 199 if (bdrv_is_encrypted(bs)) { 200 info->encrypted = true; 201 info->has_encrypted = true; 202 } 203 if (bdrv_get_info(bs, &bdi) >= 0) { 204 if (bdi.cluster_size != 0) { 205 info->cluster_size = bdi.cluster_size; 206 info->has_cluster_size = true; 207 } 208 info->dirty_flag = bdi.is_dirty; 209 info->has_dirty_flag = true; 210 } 211 info->format_specific = bdrv_get_specific_info(bs); 212 info->has_format_specific = info->format_specific != NULL; 213 214 backing_filename = bs->backing_file; 215 if (backing_filename[0] != '\0') { 216 char *backing_filename2 = g_malloc0(PATH_MAX); 217 info->backing_filename = g_strdup(backing_filename); 218 info->has_backing_filename = true; 219 bdrv_get_full_backing_filename(bs, backing_filename2, PATH_MAX, &err); 220 if (err) { 221 error_propagate(errp, err); 222 qapi_free_ImageInfo(info); 223 g_free(backing_filename2); 224 return; 225 } 226 227 if (strcmp(backing_filename, backing_filename2) != 0) { 228 info->full_backing_filename = 229 g_strdup(backing_filename2); 230 info->has_full_backing_filename = true; 231 } 232 233 if (bs->backing_format[0]) { 234 info->backing_filename_format = g_strdup(bs->backing_format); 235 info->has_backing_filename_format = true; 236 } 237 g_free(backing_filename2); 238 } 239 240 ret = bdrv_query_snapshot_info_list(bs, &info->snapshots, &err); 241 switch (ret) { 242 case 0: 243 if (info->snapshots) { 244 info->has_snapshots = true; 245 } 246 break; 247 /* recoverable error */ 248 case -ENOMEDIUM: 249 case -ENOTSUP: 250 error_free(err); 251 break; 252 default: 253 error_propagate(errp, err); 254 qapi_free_ImageInfo(info); 255 return; 256 } 257 258 *p_info = info; 259 } 260 261 /* @p_info will be set only on success. */ 262 static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, 263 Error **errp) 264 { 265 BlockInfo *info = g_malloc0(sizeof(*info)); 266 BlockDriverState *bs = blk_bs(blk); 267 BlockDriverState *bs0; 268 ImageInfo **p_image_info; 269 Error *local_err = NULL; 270 info->device = g_strdup(blk_name(blk)); 271 info->type = g_strdup("unknown"); 272 info->locked = blk_dev_is_medium_locked(blk); 273 info->removable = blk_dev_has_removable_media(blk); 274 275 if (blk_dev_has_removable_media(blk)) { 276 info->has_tray_open = true; 277 info->tray_open = blk_dev_is_tray_open(blk); 278 } 279 280 if (bdrv_iostatus_is_enabled(bs)) { 281 info->has_io_status = true; 282 info->io_status = bs->iostatus; 283 } 284 285 if (!QLIST_EMPTY(&bs->dirty_bitmaps)) { 286 info->has_dirty_bitmaps = true; 287 info->dirty_bitmaps = bdrv_query_dirty_bitmaps(bs); 288 } 289 290 if (bs->drv) { 291 info->has_inserted = true; 292 info->inserted = bdrv_block_device_info(bs); 293 294 bs0 = bs; 295 p_image_info = &info->inserted->image; 296 while (1) { 297 bdrv_query_image_info(bs0, p_image_info, &local_err); 298 if (local_err) { 299 error_propagate(errp, local_err); 300 goto err; 301 } 302 if (bs0->drv && bs0->backing_hd) { 303 bs0 = bs0->backing_hd; 304 (*p_image_info)->has_backing_image = true; 305 p_image_info = &((*p_image_info)->backing_image); 306 } else { 307 break; 308 } 309 } 310 } 311 312 *p_info = info; 313 return; 314 315 err: 316 qapi_free_BlockInfo(info); 317 } 318 319 static BlockStats *bdrv_query_stats(const BlockDriverState *bs, 320 bool query_backing) 321 { 322 BlockStats *s; 323 324 s = g_malloc0(sizeof(*s)); 325 326 if (bdrv_get_device_name(bs)[0]) { 327 s->has_device = true; 328 s->device = g_strdup(bdrv_get_device_name(bs)); 329 } 330 331 if (bdrv_get_node_name(bs)[0]) { 332 s->has_node_name = true; 333 s->node_name = g_strdup(bdrv_get_node_name(bs)); 334 } 335 336 s->stats = g_malloc0(sizeof(*s->stats)); 337 s->stats->rd_bytes = bs->stats.nr_bytes[BLOCK_ACCT_READ]; 338 s->stats->wr_bytes = bs->stats.nr_bytes[BLOCK_ACCT_WRITE]; 339 s->stats->rd_operations = bs->stats.nr_ops[BLOCK_ACCT_READ]; 340 s->stats->wr_operations = bs->stats.nr_ops[BLOCK_ACCT_WRITE]; 341 s->stats->rd_merged = bs->stats.merged[BLOCK_ACCT_READ]; 342 s->stats->wr_merged = bs->stats.merged[BLOCK_ACCT_WRITE]; 343 s->stats->wr_highest_offset = 344 bs->stats.wr_highest_sector * BDRV_SECTOR_SIZE; 345 s->stats->flush_operations = bs->stats.nr_ops[BLOCK_ACCT_FLUSH]; 346 s->stats->wr_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_WRITE]; 347 s->stats->rd_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_READ]; 348 s->stats->flush_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_FLUSH]; 349 350 if (bs->file) { 351 s->has_parent = true; 352 s->parent = bdrv_query_stats(bs->file, query_backing); 353 } 354 355 if (query_backing && bs->backing_hd) { 356 s->has_backing = true; 357 s->backing = bdrv_query_stats(bs->backing_hd, query_backing); 358 } 359 360 return s; 361 } 362 363 BlockInfoList *qmp_query_block(Error **errp) 364 { 365 BlockInfoList *head = NULL, **p_next = &head; 366 BlockBackend *blk; 367 Error *local_err = NULL; 368 369 for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { 370 BlockInfoList *info = g_malloc0(sizeof(*info)); 371 bdrv_query_info(blk, &info->value, &local_err); 372 if (local_err) { 373 error_propagate(errp, local_err); 374 goto err; 375 } 376 377 *p_next = info; 378 p_next = &info->next; 379 } 380 381 return head; 382 383 err: 384 qapi_free_BlockInfoList(head); 385 return NULL; 386 } 387 388 BlockStatsList *qmp_query_blockstats(bool has_query_nodes, 389 bool query_nodes, 390 Error **errp) 391 { 392 BlockStatsList *head = NULL, **p_next = &head; 393 BlockDriverState *bs = NULL; 394 395 /* Just to be safe if query_nodes is not always initialized */ 396 query_nodes = has_query_nodes && query_nodes; 397 398 while ((bs = query_nodes ? bdrv_next_node(bs) : bdrv_next(bs))) { 399 BlockStatsList *info = g_malloc0(sizeof(*info)); 400 AioContext *ctx = bdrv_get_aio_context(bs); 401 402 aio_context_acquire(ctx); 403 info->value = bdrv_query_stats(bs, !query_nodes); 404 aio_context_release(ctx); 405 406 *p_next = info; 407 p_next = &info->next; 408 } 409 410 return head; 411 } 412 413 #define NB_SUFFIXES 4 414 415 static char *get_human_readable_size(char *buf, int buf_size, int64_t size) 416 { 417 static const char suffixes[NB_SUFFIXES] = "KMGT"; 418 int64_t base; 419 int i; 420 421 if (size <= 999) { 422 snprintf(buf, buf_size, "%" PRId64, size); 423 } else { 424 base = 1024; 425 for (i = 0; i < NB_SUFFIXES; i++) { 426 if (size < (10 * base)) { 427 snprintf(buf, buf_size, "%0.1f%c", 428 (double)size / base, 429 suffixes[i]); 430 break; 431 } else if (size < (1000 * base) || i == (NB_SUFFIXES - 1)) { 432 snprintf(buf, buf_size, "%" PRId64 "%c", 433 ((size + (base >> 1)) / base), 434 suffixes[i]); 435 break; 436 } 437 base = base * 1024; 438 } 439 } 440 return buf; 441 } 442 443 void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f, 444 QEMUSnapshotInfo *sn) 445 { 446 char buf1[128], date_buf[128], clock_buf[128]; 447 struct tm tm; 448 time_t ti; 449 int64_t secs; 450 451 if (!sn) { 452 func_fprintf(f, 453 "%-10s%-20s%7s%20s%15s", 454 "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK"); 455 } else { 456 ti = sn->date_sec; 457 localtime_r(&ti, &tm); 458 strftime(date_buf, sizeof(date_buf), 459 "%Y-%m-%d %H:%M:%S", &tm); 460 secs = sn->vm_clock_nsec / 1000000000; 461 snprintf(clock_buf, sizeof(clock_buf), 462 "%02d:%02d:%02d.%03d", 463 (int)(secs / 3600), 464 (int)((secs / 60) % 60), 465 (int)(secs % 60), 466 (int)((sn->vm_clock_nsec / 1000000) % 1000)); 467 func_fprintf(f, 468 "%-10s%-20s%7s%20s%15s", 469 sn->id_str, sn->name, 470 get_human_readable_size(buf1, sizeof(buf1), 471 sn->vm_state_size), 472 date_buf, 473 clock_buf); 474 } 475 } 476 477 static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, 478 QDict *dict); 479 static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation, 480 QList *list); 481 482 static void dump_qobject(fprintf_function func_fprintf, void *f, 483 int comp_indent, QObject *obj) 484 { 485 switch (qobject_type(obj)) { 486 case QTYPE_QINT: { 487 QInt *value = qobject_to_qint(obj); 488 func_fprintf(f, "%" PRId64, qint_get_int(value)); 489 break; 490 } 491 case QTYPE_QSTRING: { 492 QString *value = qobject_to_qstring(obj); 493 func_fprintf(f, "%s", qstring_get_str(value)); 494 break; 495 } 496 case QTYPE_QDICT: { 497 QDict *value = qobject_to_qdict(obj); 498 dump_qdict(func_fprintf, f, comp_indent, value); 499 break; 500 } 501 case QTYPE_QLIST: { 502 QList *value = qobject_to_qlist(obj); 503 dump_qlist(func_fprintf, f, comp_indent, value); 504 break; 505 } 506 case QTYPE_QFLOAT: { 507 QFloat *value = qobject_to_qfloat(obj); 508 func_fprintf(f, "%g", qfloat_get_double(value)); 509 break; 510 } 511 case QTYPE_QBOOL: { 512 QBool *value = qobject_to_qbool(obj); 513 func_fprintf(f, "%s", qbool_get_int(value) ? "true" : "false"); 514 break; 515 } 516 case QTYPE_QERROR: { 517 QString *value = qerror_human((QError *)obj); 518 func_fprintf(f, "%s", qstring_get_str(value)); 519 QDECREF(value); 520 break; 521 } 522 case QTYPE_NONE: 523 break; 524 case QTYPE_MAX: 525 default: 526 abort(); 527 } 528 } 529 530 static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation, 531 QList *list) 532 { 533 const QListEntry *entry; 534 int i = 0; 535 536 for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) { 537 qtype_code type = qobject_type(entry->value); 538 bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST); 539 const char *format = composite ? "%*s[%i]:\n" : "%*s[%i]: "; 540 541 func_fprintf(f, format, indentation * 4, "", i); 542 dump_qobject(func_fprintf, f, indentation + 1, entry->value); 543 if (!composite) { 544 func_fprintf(f, "\n"); 545 } 546 } 547 } 548 549 static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, 550 QDict *dict) 551 { 552 const QDictEntry *entry; 553 554 for (entry = qdict_first(dict); entry; entry = qdict_next(dict, entry)) { 555 qtype_code type = qobject_type(entry->value); 556 bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST); 557 const char *format = composite ? "%*s%s:\n" : "%*s%s: "; 558 char key[strlen(entry->key) + 1]; 559 int i; 560 561 /* replace dashes with spaces in key (variable) names */ 562 for (i = 0; entry->key[i]; i++) { 563 key[i] = entry->key[i] == '-' ? ' ' : entry->key[i]; 564 } 565 key[i] = 0; 566 567 func_fprintf(f, format, indentation * 4, "", key); 568 dump_qobject(func_fprintf, f, indentation + 1, entry->value); 569 if (!composite) { 570 func_fprintf(f, "\n"); 571 } 572 } 573 } 574 575 void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f, 576 ImageInfoSpecific *info_spec) 577 { 578 QmpOutputVisitor *ov = qmp_output_visitor_new(); 579 QObject *obj, *data; 580 581 visit_type_ImageInfoSpecific(qmp_output_get_visitor(ov), &info_spec, NULL, 582 &error_abort); 583 obj = qmp_output_get_qobject(ov); 584 assert(qobject_type(obj) == QTYPE_QDICT); 585 data = qdict_get(qobject_to_qdict(obj), "data"); 586 dump_qobject(func_fprintf, f, 1, data); 587 qmp_output_visitor_cleanup(ov); 588 } 589 590 void bdrv_image_info_dump(fprintf_function func_fprintf, void *f, 591 ImageInfo *info) 592 { 593 char size_buf[128], dsize_buf[128]; 594 if (!info->has_actual_size) { 595 snprintf(dsize_buf, sizeof(dsize_buf), "unavailable"); 596 } else { 597 get_human_readable_size(dsize_buf, sizeof(dsize_buf), 598 info->actual_size); 599 } 600 get_human_readable_size(size_buf, sizeof(size_buf), info->virtual_size); 601 func_fprintf(f, 602 "image: %s\n" 603 "file format: %s\n" 604 "virtual size: %s (%" PRId64 " bytes)\n" 605 "disk size: %s\n", 606 info->filename, info->format, size_buf, 607 info->virtual_size, 608 dsize_buf); 609 610 if (info->has_encrypted && info->encrypted) { 611 func_fprintf(f, "encrypted: yes\n"); 612 } 613 614 if (info->has_cluster_size) { 615 func_fprintf(f, "cluster_size: %" PRId64 "\n", 616 info->cluster_size); 617 } 618 619 if (info->has_dirty_flag && info->dirty_flag) { 620 func_fprintf(f, "cleanly shut down: no\n"); 621 } 622 623 if (info->has_backing_filename) { 624 func_fprintf(f, "backing file: %s", info->backing_filename); 625 if (info->has_full_backing_filename) { 626 func_fprintf(f, " (actual path: %s)", info->full_backing_filename); 627 } 628 func_fprintf(f, "\n"); 629 if (info->has_backing_filename_format) { 630 func_fprintf(f, "backing file format: %s\n", 631 info->backing_filename_format); 632 } 633 } 634 635 if (info->has_snapshots) { 636 SnapshotInfoList *elem; 637 638 func_fprintf(f, "Snapshot list:\n"); 639 bdrv_snapshot_dump(func_fprintf, f, NULL); 640 func_fprintf(f, "\n"); 641 642 /* Ideally bdrv_snapshot_dump() would operate on SnapshotInfoList but 643 * we convert to the block layer's native QEMUSnapshotInfo for now. 644 */ 645 for (elem = info->snapshots; elem; elem = elem->next) { 646 QEMUSnapshotInfo sn = { 647 .vm_state_size = elem->value->vm_state_size, 648 .date_sec = elem->value->date_sec, 649 .date_nsec = elem->value->date_nsec, 650 .vm_clock_nsec = elem->value->vm_clock_sec * 1000000000ULL + 651 elem->value->vm_clock_nsec, 652 }; 653 654 pstrcpy(sn.id_str, sizeof(sn.id_str), elem->value->id); 655 pstrcpy(sn.name, sizeof(sn.name), elem->value->name); 656 bdrv_snapshot_dump(func_fprintf, f, &sn); 657 func_fprintf(f, "\n"); 658 } 659 } 660 661 if (info->has_format_specific) { 662 func_fprintf(f, "Format specific information:\n"); 663 bdrv_image_info_specific_dump(func_fprintf, f, info->format_specific); 664 } 665 } 666