qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

hmp: Add name parameter to nbd_server_add

Extend the flexibility of the previous QMP patch to also work
in HMP.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20180109192802.17167-1-eblake@redhat.com>

+7 -5
+5 -4
hmp-commands.hx
··· 1553 1553 1554 1554 { 1555 1555 .name = "nbd_server_add", 1556 - .args_type = "writable:-w,device:B", 1557 - .params = "nbd_server_add [-w] device", 1556 + .args_type = "writable:-w,device:B,name:s?", 1557 + .params = "nbd_server_add [-w] device [name]", 1558 1558 .help = "export a block device via NBD", 1559 1559 .cmd = hmp_nbd_server_add, 1560 1560 }, 1561 1561 STEXI 1562 - @item nbd_server_add @var{device} 1562 + @item nbd_server_add @var{device} [ @var{name} ] 1563 1563 @findex nbd_server_add 1564 1564 Export a block device through QEMU's NBD server, which must be started 1565 1565 beforehand with @command{nbd_server_start}. The @option{-w} option makes the 1566 - exported device writable too. 1566 + exported device writable too. The export name is controlled by @var{name}, 1567 + defaulting to @var{device}. 1567 1568 ETEXI 1568 1569 1569 1570 {
+2 -1
hmp.c
··· 2221 2221 void hmp_nbd_server_add(Monitor *mon, const QDict *qdict) 2222 2222 { 2223 2223 const char *device = qdict_get_str(qdict, "device"); 2224 + const char *name = qdict_get_try_str(qdict, "name"); 2224 2225 bool writable = qdict_get_try_bool(qdict, "writable", false); 2225 2226 Error *local_err = NULL; 2226 2227 2227 - qmp_nbd_server_add(device, false, NULL, true, writable, &local_err); 2228 + qmp_nbd_server_add(device, !!name, name, true, writable, &local_err); 2228 2229 2229 2230 if (local_err != NULL) { 2230 2231 hmp_handle_error(mon, &local_err);