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:
parent
57b6bdf37c
commit
dd67fa5052
24
block.c
24
block.c
@ -3574,30 +3574,26 @@ BlockDriverState *bdrv_lookup_bs(const char *device,
|
|||||||
{
|
{
|
||||||
BlockDriverState *bs = NULL;
|
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) {
|
if (device) {
|
||||||
bs = bdrv_find(device);
|
bs = bdrv_find(device);
|
||||||
|
|
||||||
if (!bs) {
|
if (bs) {
|
||||||
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bs;
|
return bs;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node_name) {
|
||||||
bs = bdrv_find_node(node_name);
|
bs = bdrv_find_node(node_name);
|
||||||
|
|
||||||
if (!bs) {
|
if (bs) {
|
||||||
error_set(errp, QERR_DEVICE_NOT_FOUND, node_name);
|
return bs;
|
||||||
return NULL;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
BlockDriverState *bdrv_next(BlockDriverState *bs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user