mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00

This adds a function to shut down all block exports, and another one to shut down the block exports of a single type. The latter is used for now when stopping the NBD server. As soon as we implement support for multiple NBD servers, we'll need a per-server list of exports and it will be replaced by a function using that. As a side effect, the BlockExport layer has a list tracking all existing exports now. closed_exports loses its only user and can go away. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200924152717.287415-18-kwolf@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
74 lines
2 KiB
C
74 lines
2 KiB
C
/*
|
|
* Declarations for block exports
|
|
*
|
|
* Copyright (c) 2012, 2020 Red Hat, Inc.
|
|
*
|
|
* Authors:
|
|
* Paolo Bonzini <pbonzini@redhat.com>
|
|
* Kevin Wolf <kwolf@redhat.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or
|
|
* later. See the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#ifndef BLOCK_EXPORT_H
|
|
#define BLOCK_EXPORT_H
|
|
|
|
#include "qapi/qapi-types-block-export.h"
|
|
#include "qemu/queue.h"
|
|
|
|
typedef struct BlockExport BlockExport;
|
|
|
|
typedef struct BlockExportDriver {
|
|
/* The export type that this driver services */
|
|
BlockExportType type;
|
|
|
|
/*
|
|
* The size of the driver-specific state that contains BlockExport as its
|
|
* first field.
|
|
*/
|
|
size_t instance_size;
|
|
|
|
/* Creates and starts a new block export */
|
|
int (*create)(BlockExport *, BlockExportOptions *, Error **);
|
|
|
|
/*
|
|
* Frees a removed block export. This function is only called after all
|
|
* references have been dropped.
|
|
*/
|
|
void (*delete)(BlockExport *);
|
|
|
|
/*
|
|
* Start to disconnect all clients and drop other references held
|
|
* internally by the export driver. When the function returns, there may
|
|
* still be active references while the export is in the process of
|
|
* shutting down.
|
|
*/
|
|
void (*request_shutdown)(BlockExport *);
|
|
} BlockExportDriver;
|
|
|
|
struct BlockExport {
|
|
const BlockExportDriver *drv;
|
|
|
|
/*
|
|
* Reference count for this block export. This includes strong references
|
|
* both from the owner (qemu-nbd or the monitor) and clients connected to
|
|
* the export.
|
|
*/
|
|
int refcount;
|
|
|
|
/* The AioContext whose lock protects this BlockExport object. */
|
|
AioContext *ctx;
|
|
|
|
/* List entry for block_exports */
|
|
QLIST_ENTRY(BlockExport) next;
|
|
};
|
|
|
|
BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp);
|
|
void blk_exp_ref(BlockExport *exp);
|
|
void blk_exp_unref(BlockExport *exp);
|
|
void blk_exp_request_shutdown(BlockExport *exp);
|
|
void blk_exp_close_all(void);
|
|
void blk_exp_close_all_type(BlockExportType type);
|
|
|
|
#endif
|