nbd: add nbd_export_get_blockdev

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2012-09-18 14:31:44 +02:00
parent 6b8c01e781
commit 125afda8cb
2 changed files with 8 additions and 1 deletions

7
nbd.c
View File

@ -914,6 +914,7 @@ void nbd_export_close(NBDExport *exp)
QTAILQ_FOREACH_SAFE(client, &exp->clients, next, next) { QTAILQ_FOREACH_SAFE(client, &exp->clients, next, next) {
nbd_client_close(client); nbd_client_close(client);
} }
nbd_export_set_name(exp, NULL);
nbd_export_put(exp); nbd_export_put(exp);
} }
@ -948,13 +949,17 @@ void nbd_export_put(NBDExport *exp)
} }
} }
BlockDriverState *nbd_export_get_blockdev(NBDExport *exp)
{
return exp->bs;
}
void nbd_export_close_all(void) void nbd_export_close_all(void)
{ {
NBDExport *exp, *next; NBDExport *exp, *next;
QTAILQ_FOREACH_SAFE(exp, &exports, next, next) { QTAILQ_FOREACH_SAFE(exp, &exports, next, next) {
nbd_export_close(exp); nbd_export_close(exp);
nbd_export_set_name(exp, NULL);
} }
} }

2
nbd.h
View File

@ -85,6 +85,8 @@ void nbd_export_close(NBDExport *exp);
void nbd_export_get(NBDExport *exp); void nbd_export_get(NBDExport *exp);
void nbd_export_put(NBDExport *exp); void nbd_export_put(NBDExport *exp);
BlockDriverState *nbd_export_get_blockdev(NBDExport *exp);
NBDExport *nbd_export_find(const char *name); NBDExport *nbd_export_find(const char *name);
void nbd_export_set_name(NBDExport *exp, const char *name); void nbd_export_set_name(NBDExport *exp, const char *name);
void nbd_export_close_all(void); void nbd_export_close_all(void);