vvfat.c (facdbb0272402618b6ca3b306a933e56dc4085c5) vvfat.c (c282e1fdf7ec9659c7f320123be397477a359d01)
1/* vim:set shiftwidth=4 ts=4: */
2/*
3 * QEMU Block driver for virtual VFAT (shadows a local directory)
4 *
5 * Copyright (c) 2004,2005 Johannes E. Schindelin
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal

--- 2897 unchanged lines hidden (view full) ---

2906 .format_name = "vvfat_write_target",
2907 .bdrv_write = write_target_commit,
2908 .bdrv_close = write_target_close,
2909};
2910
2911static int enable_write_target(BDRVVVFATState *s, Error **errp)
2912{
2913 BlockDriver *bdrv_qcow = NULL;
1/* vim:set shiftwidth=4 ts=4: */
2/*
3 * QEMU Block driver for virtual VFAT (shadows a local directory)
4 *
5 * Copyright (c) 2004,2005 Johannes E. Schindelin
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal

--- 2897 unchanged lines hidden (view full) ---

2906 .format_name = "vvfat_write_target",
2907 .bdrv_write = write_target_commit,
2908 .bdrv_close = write_target_close,
2909};
2910
2911static int enable_write_target(BDRVVVFATState *s, Error **errp)
2912{
2913 BlockDriver *bdrv_qcow = NULL;
2914 QemuOptsList *create_opts = NULL;
2915 QemuOpts *opts = NULL;
2916 int ret;
2917 int size = sector2cluster(s, s->sector_count);
2918 s->used_clusters = calloc(size, 1);
2919
2920 array_init(&(s->commits), sizeof(commit_t));
2921
2922 s->qcow_filename = g_malloc(1024);
2923 ret = get_tmp_filename(s->qcow_filename, 1024);
2924 if (ret < 0) {
2925 error_setg_errno(errp, -ret, "can't create temporary file");
2926 goto err;
2927 }
2928
2929 bdrv_qcow = bdrv_find_format("qcow");
2914 QemuOpts *opts = NULL;
2915 int ret;
2916 int size = sector2cluster(s, s->sector_count);
2917 s->used_clusters = calloc(size, 1);
2918
2919 array_init(&(s->commits), sizeof(commit_t));
2920
2921 s->qcow_filename = g_malloc(1024);
2922 ret = get_tmp_filename(s->qcow_filename, 1024);
2923 if (ret < 0) {
2924 error_setg_errno(errp, -ret, "can't create temporary file");
2925 goto err;
2926 }
2927
2928 bdrv_qcow = bdrv_find_format("qcow");
2930 assert(!(bdrv_qcow->create_opts && bdrv_qcow->create_options));
2931 if (bdrv_qcow->create_options) {
2932 create_opts = params_to_opts(bdrv_qcow->create_options);
2933 } else {
2934 create_opts = bdrv_qcow->create_opts;
2935 }
2936 opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
2929 opts = qemu_opts_create(bdrv_qcow->create_opts, NULL, 0, &error_abort);
2937 qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512);
2938 qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, "fat:");
2939
2930 qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512);
2931 qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, "fat:");
2932
2940 ret = bdrv_create(bdrv_qcow, s->qcow_filename, NULL, opts, errp);
2933 ret = bdrv_create(bdrv_qcow, s->qcow_filename, opts, errp);
2941 qemu_opts_del(opts);
2934 qemu_opts_del(opts);
2942 if (bdrv_qcow->create_options) {
2943 qemu_opts_free(create_opts);
2944 }
2945 if (ret < 0) {
2946 goto err;
2947 }
2948
2949 s->qcow = NULL;
2950 ret = bdrv_open(&s->qcow, s->qcow_filename, NULL, NULL,
2951 BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH,
2952 bdrv_qcow, errp);

--- 81 unchanged lines hidden ---
2935 if (ret < 0) {
2936 goto err;
2937 }
2938
2939 s->qcow = NULL;
2940 ret = bdrv_open(&s->qcow, s->qcow_filename, NULL, NULL,
2941 BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH,
2942 bdrv_qcow, errp);

--- 81 unchanged lines hidden ---