block: Relax bdrv_lookup_bs constraints.

The following patch will reuse bdrv_lookup_bs in order to open images by
references so the rules of usage of bdrv_lookup_bs must be relaxed a bit.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Benoît Canet 2014-02-12 17:15:06 +01:00 committed by Stefan Hajnoczi
parent 57b6bdf37c
commit dd67fa5052

24
block.c
View File

@ -3574,30 +3574,26 @@ BlockDriverState *bdrv_lookup_bs(const char *device,
{
BlockDriverState *bs = NULL;
if ((!device && !node_name) || (device && node_name)) {
error_setg(errp, "Use either device or node-name but not both");
return NULL;
}
if (device) {
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return NULL;
}
if (bs) {
return bs;
}
}
if (node_name) {
bs = bdrv_find_node(node_name);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, node_name);
return NULL;
if (bs) {
return bs;
}
}
return bs;
error_setg(errp, "Cannot find device=%s nor node_name=%s",
device ? device : "",
node_name ? node_name : "");
return NULL;
}
BlockDriverState *bdrv_next(BlockDriverState *bs)