Revision 802ddc37
b/qemu-nbd.c | ||
---|---|---|
460 | 460 |
} |
461 | 461 |
} |
462 | 462 |
|
463 |
bdrv_init(); |
|
464 |
|
|
465 |
bs = bdrv_new("hda"); |
|
466 |
|
|
467 |
srcpath = argv[optind]; |
|
468 |
if ((ret = bdrv_open(bs, srcpath, flags, NULL)) < 0) { |
|
469 |
errno = -ret; |
|
470 |
err(EXIT_FAILURE, "Failed to bdrv_open '%s'", srcpath); |
|
471 |
} |
|
472 |
|
|
473 |
fd_size = bs->total_sectors * 512; |
|
474 |
|
|
475 |
if (partition != -1 && |
|
476 |
find_partition(bs, partition, &dev_offset, &fd_size)) |
|
477 |
err(EXIT_FAILURE, "Could not find partition %d", partition); |
|
478 |
|
|
479 | 463 |
if (device) { |
480 | 464 |
/* Open before spawning new threads. In the future, we may |
481 | 465 |
* drop privileges after opening. |
... | ... | |
491 | 475 |
} |
492 | 476 |
} |
493 | 477 |
|
478 |
bdrv_init(); |
|
479 |
atexit(bdrv_close_all); |
|
480 |
|
|
481 |
bs = bdrv_new("hda"); |
|
482 |
srcpath = argv[optind]; |
|
483 |
if ((ret = bdrv_open(bs, srcpath, flags, NULL)) < 0) { |
|
484 |
errno = -ret; |
|
485 |
err(EXIT_FAILURE, "Failed to bdrv_open '%s'", argv[optind]); |
|
486 |
} |
|
487 |
|
|
488 |
fd_size = bs->total_sectors * 512; |
|
489 |
|
|
490 |
if (partition != -1 && |
|
491 |
find_partition(bs, partition, &dev_offset, &fd_size)) { |
|
492 |
err(EXIT_FAILURE, "Could not find partition %d", partition); |
|
493 |
} |
|
494 |
|
|
494 | 495 |
sharing_fds = g_malloc((shared + 1) * sizeof(int)); |
495 | 496 |
|
496 | 497 |
if (sockpath) { |
... | ... | |
568 | 569 |
qemu_vfree(data); |
569 | 570 |
|
570 | 571 |
close(sharing_fds[0]); |
571 |
bdrv_close(bs); |
|
572 | 572 |
g_free(sharing_fds); |
573 | 573 |
if (sockpath) { |
574 | 574 |
unlink(sockpath); |
Also available in: Unified diff