qemu-patch-raspberry4/include/block/export.h
Kevin Wolf c69de1bef5 block/export: Move refcount from NBDExport to BlockExport
Having a refcount makes sense for all types of block exports. It is also
a prerequisite for keeping a list of all exports at the BlockExport
level.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200924152717.287415-14-kwolf@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2020-10-02 15:46:40 +02:00

51 lines
1.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"
typedef struct BlockExport BlockExport;
typedef struct BlockExportDriver {
/* The export type that this driver services */
BlockExportType type;
/* Creates and starts a new block export */
BlockExport *(*create)(BlockExportOptions *, Error **);
/*
* Frees a removed block export. This function is only called after all
* references have been dropped.
*/
void (*delete)(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;
};
BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp);
void blk_exp_ref(BlockExport *exp);
void blk_exp_unref(BlockExport *exp);
#endif