[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/14] qemu-nbd: Use blk_new_open() in main()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH 08/14] qemu-nbd: Use blk_new_open() in main() |
Date: |
Thu, 11 Dec 2014 14:20:47 +0100 |
Signed-off-by: Max Reitz <address@hidden>
---
qemu-nbd.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index d222512..fdc9590 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -386,7 +386,6 @@ int main(int argc, char **argv)
{
BlockBackend *blk;
BlockDriverState *bs;
- BlockDriver *drv;
off_t dev_offset = 0;
uint32_t nbdflags = 0;
bool disconnect = false;
@@ -429,7 +428,7 @@ int main(int argc, char **argv)
char *end;
int flags = BDRV_O_RDWR;
int partition = -1;
- int ret;
+ int ret = 0;
int fd;
bool seen_cache = false;
bool seen_discard = false;
@@ -440,6 +439,7 @@ int main(int argc, char **argv)
const char *fmt = NULL;
Error *local_err = NULL;
BlockdevDetectZeroesOptions detect_zeroes =
BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;
+ QDict *options = NULL;
/* The client thread uses SIGTERM to interrupt the server. A signal
* handler ensures that "qemu-nbd -v -c" exits with a nice status code.
@@ -684,24 +684,17 @@ int main(int argc, char **argv)
atexit(bdrv_close_all);
if (fmt) {
- drv = bdrv_find_format(fmt);
- if (!drv) {
- errx(EXIT_FAILURE, "Unknown file format '%s'", fmt);
- }
- } else {
- drv = NULL;
+ options = qdict_new();
+ qdict_put_obj(options, "driver", QOBJECT(qstring_from_str(fmt)));
}
- blk = blk_new_with_bs("hda", &error_abort);
- bs = blk_bs(blk);
-
srcpath = argv[optind];
- ret = bdrv_open(&bs, srcpath, NULL, NULL, flags, drv, &local_err);
- if (ret < 0) {
- errno = -ret;
- err(EXIT_FAILURE, "Failed to bdrv_open '%s': %s", argv[optind],
- error_get_pretty(local_err));
+ blk = blk_new_open("hda", srcpath, NULL, options, flags, &local_err);
+ if (!blk) {
+ errx(EXIT_FAILURE, "Failed to blk_new_open '%s': %s", argv[optind],
+ error_get_pretty(local_err));
}
+ bs = blk_bs(blk);
if (sn_opts) {
ret = bdrv_snapshot_load_tmp(bs,
--
1.9.3
- [Qemu-devel] [PATCH 00/14] block: Remove "growable", add blk_new_open(), Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 02/14] block: Add blk_new_open(), Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 04/14] block/xen: Use blk_new_open() in blk_connect(), Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 05/14] qemu-img: Use blk_new_open() in img_open(), Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 06/14] qemu-img: Use blk_new_open() in img_rebase(), Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 07/14] qemu-img: Use BlockBackend as far as possible, Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 10/14] qemu-io: Remove "growable" option, Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 08/14] qemu-nbd: Use blk_new_open() in main(),
Max Reitz <=
- [Qemu-devel] [PATCH 11/14] qemu-io: Use BlockBackend, Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 13/14] block: Remove "growable" from BDS, Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 14/14] block: Keep bdrv_check*_request()'s return value, Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 09/14] qemu-io: Use blk_new_open() in openfile(), Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 03/14] blockdev: Use blk_new_open() in blockdev_init(), Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 01/14] block: Lift some BDS functions to the BlockBackend, Max Reitz, 2014/12/11
- [Qemu-devel] [PATCH 12/14] block: Clamp BlockBackend requests, Max Reitz, 2014/12/11
- Re: [Qemu-devel] [PATCH 00/14] block: Remove "growable", add blk_new_open(), Kevin Wolf, 2014/12/18