|
@@ -140,8 +140,8 @@ void qmp_nbd_server_start(SocketAddressLegacy *addr,
|
|
|
qapi_free_SocketAddress(addr_flat);
|
|
|
}
|
|
|
|
|
|
-void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
|
|
|
- Error **errp)
|
|
|
+void qmp_nbd_server_add(const char *device, bool has_name, const char *name,
|
|
|
+ bool has_writable, bool writable, Error **errp)
|
|
|
{
|
|
|
BlockDriverState *bs = NULL;
|
|
|
BlockBackend *on_eject_blk;
|
|
@@ -152,8 +152,12 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (nbd_export_find(device)) {
|
|
|
- error_setg(errp, "NBD server already exporting device '%s'", device);
|
|
|
+ if (!has_name) {
|
|
|
+ name = device;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (nbd_export_find(name)) {
|
|
|
+ error_setg(errp, "NBD server already has export named '%s'", name);
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -177,7 +181,7 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- nbd_export_set_name(exp, device);
|
|
|
+ nbd_export_set_name(exp, name);
|
|
|
|
|
|
/* The list of named exports has a strong reference to this export now and
|
|
|
* our only way of accessing it is through nbd_export_find(), so we can drop
|