blockdev-nbd.c (3fc63c3f339a61f4e4526f88150927424744f687) blockdev-nbd.c (cd7fca952ce8456955f7f4e11df9ced14204c2f1)
1/*
2 * Serving QEMU block devices via NBD
3 *
4 * Copyright (c) 2012 Red Hat, Inc.
5 *
6 * Author: Paolo Bonzini <pbonzini@redhat.com>
7 *
8 * This work is licensed under the terms of the GNU GPL, version 2 or

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

171
172 if (!has_writable) {
173 writable = false;
174 }
175 if (blk_is_read_only(blk)) {
176 writable = false;
177 }
178
1/*
2 * Serving QEMU block devices via NBD
3 *
4 * Copyright (c) 2012 Red Hat, Inc.
5 *
6 * Author: Paolo Bonzini <pbonzini@redhat.com>
7 *
8 * This work is licensed under the terms of the GNU GPL, version 2 or

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

171
172 if (!has_writable) {
173 writable = false;
174 }
175 if (blk_is_read_only(blk)) {
176 writable = false;
177 }
178
179 exp = nbd_export_new(blk, 0, -1, writable ? 0 : NBD_FLAG_READ_ONLY, NULL,
180 errp);
179 exp = nbd_export_new(blk_bs(blk), 0, -1, writable ? 0 : NBD_FLAG_READ_ONLY,
180 NULL, false, blk, errp);
181 if (!exp) {
182 return;
183 }
184
185 nbd_export_set_name(exp, device);
186
187 /* The list of named exports has a strong reference to this export now and
188 * our only way of accessing it is through nbd_export_find(), so we can drop
189 * the strong reference that is @exp. */
190 nbd_export_put(exp);
191}
192
193void qmp_nbd_server_stop(Error **errp)
194{
195 nbd_export_close_all();
196
197 nbd_server_free(nbd_server);
198 nbd_server = NULL;
199}
181 if (!exp) {
182 return;
183 }
184
185 nbd_export_set_name(exp, device);
186
187 /* The list of named exports has a strong reference to this export now and
188 * our only way of accessing it is through nbd_export_find(), so we can drop
189 * the strong reference that is @exp. */
190 nbd_export_put(exp);
191}
192
193void qmp_nbd_server_stop(Error **errp)
194{
195 nbd_export_close_all();
196
197 nbd_server_free(nbd_server);
198 nbd_server = NULL;
199}