hmp-cmds.c (e263120ecc5c48c50e07bbca252d982aa34f2fe6) | hmp-cmds.c (1061f8dd808cc185736094759bd8a2b919435195) |
---|---|
1/* 2 * Human Monitor Interface commands 3 * 4 * Copyright IBM, Corp. 2011 5 * 6 * Authors: 7 * Anthony Liguori <aliguori@us.ibm.com> 8 * --- 34 unchanged lines hidden (view full) --- 43#include "qapi/qapi-visit-migration.h" 44#include "qapi/qmp/qdict.h" 45#include "qapi/qmp/qerror.h" 46#include "qapi/string-input-visitor.h" 47#include "qapi/string-output-visitor.h" 48#include "qom/object_interfaces.h" 49#include "ui/console.h" 50#include "block/qapi.h" | 1/* 2 * Human Monitor Interface commands 3 * 4 * Copyright IBM, Corp. 2011 5 * 6 * Authors: 7 * Anthony Liguori <aliguori@us.ibm.com> 8 * --- 34 unchanged lines hidden (view full) --- 43#include "qapi/qapi-visit-migration.h" 44#include "qapi/qmp/qdict.h" 45#include "qapi/qmp/qerror.h" 46#include "qapi/string-input-visitor.h" 47#include "qapi/string-output-visitor.h" 48#include "qom/object_interfaces.h" 49#include "ui/console.h" 50#include "block/qapi.h" |
51#include "qemu-io.h" | |
52#include "qemu/cutils.h" 53#include "qemu/error-report.h" 54#include "exec/ramlist.h" 55#include "hw/intc/intc.h" 56#include "hw/rdma/rdma.h" 57#include "migration/snapshot.h" 58#include "migration/misc.h" 59 --- 1247 unchanged lines hidden (view full) --- 1307 const char *name = qdict_get_str(qdict, "name"); 1308 bool up = qdict_get_bool(qdict, "up"); 1309 Error *err = NULL; 1310 1311 qmp_set_link(name, up, &err); 1312 hmp_handle_error(mon, err); 1313} 1314 | 51#include "qemu/cutils.h" 52#include "qemu/error-report.h" 53#include "exec/ramlist.h" 54#include "hw/intc/intc.h" 55#include "hw/rdma/rdma.h" 56#include "migration/snapshot.h" 57#include "migration/misc.h" 58 --- 1247 unchanged lines hidden (view full) --- 1306 const char *name = qdict_get_str(qdict, "name"); 1307 bool up = qdict_get_bool(qdict, "up"); 1308 Error *err = NULL; 1309 1310 qmp_set_link(name, up, &err); 1311 hmp_handle_error(mon, err); 1312} 1313 |
1315void hmp_block_passwd(Monitor *mon, const QDict *qdict) 1316{ 1317 const char *device = qdict_get_str(qdict, "device"); 1318 const char *password = qdict_get_str(qdict, "password"); 1319 Error *err = NULL; 1320 1321 qmp_block_passwd(true, device, false, NULL, password, &err); 1322 hmp_handle_error(mon, err); 1323} 1324 | |
1325void hmp_balloon(Monitor *mon, const QDict *qdict) 1326{ 1327 int64_t value = qdict_get_int(qdict, "value"); 1328 Error *err = NULL; 1329 1330 qmp_balloon(value, &err); 1331 hmp_handle_error(mon, err); 1332} 1333 | 1314void hmp_balloon(Monitor *mon, const QDict *qdict) 1315{ 1316 int64_t value = qdict_get_int(qdict, "value"); 1317 Error *err = NULL; 1318 1319 qmp_balloon(value, &err); 1320 hmp_handle_error(mon, err); 1321} 1322 |
1334void hmp_block_resize(Monitor *mon, const QDict *qdict) 1335{ 1336 const char *device = qdict_get_str(qdict, "device"); 1337 int64_t size = qdict_get_int(qdict, "size"); 1338 Error *err = NULL; 1339 1340 qmp_block_resize(true, device, false, NULL, size, &err); 1341 hmp_handle_error(mon, err); 1342} 1343 | |
1344void hmp_loadvm(Monitor *mon, const QDict *qdict) 1345{ 1346 int saved_vm_running = runstate_is_running(); 1347 const char *name = qdict_get_str(qdict, "name"); 1348 Error *err = NULL; 1349 1350 vm_stop(RUN_STATE_RESTORE_VM); 1351 --- 483 unchanged lines hidden (view full) --- 1835 const char *protocol = qdict_get_str(qdict, "protocol"); 1836 const char *whenstr = qdict_get_str(qdict, "time"); 1837 Error *err = NULL; 1838 1839 qmp_expire_password(protocol, whenstr, &err); 1840 hmp_handle_error(mon, err); 1841} 1842 | 1323void hmp_loadvm(Monitor *mon, const QDict *qdict) 1324{ 1325 int saved_vm_running = runstate_is_running(); 1326 const char *name = qdict_get_str(qdict, "name"); 1327 Error *err = NULL; 1328 1329 vm_stop(RUN_STATE_RESTORE_VM); 1330 --- 483 unchanged lines hidden (view full) --- 1814 const char *protocol = qdict_get_str(qdict, "protocol"); 1815 const char *whenstr = qdict_get_str(qdict, "time"); 1816 Error *err = NULL; 1817 1818 qmp_expire_password(protocol, whenstr, &err); 1819 hmp_handle_error(mon, err); 1820} 1821 |
1843void hmp_eject(Monitor *mon, const QDict *qdict) 1844{ 1845 bool force = qdict_get_try_bool(qdict, "force", false); 1846 const char *device = qdict_get_str(qdict, "device"); 1847 Error *err = NULL; | |
1848 | 1822 |
1849 qmp_eject(true, device, false, NULL, true, force, &err); 1850 hmp_handle_error(mon, err); 1851} 1852 | |
1853#ifdef CONFIG_VNC 1854static void hmp_change_read_arg(void *opaque, const char *password, 1855 void *readline_opaque) 1856{ 1857 qmp_change_vnc_password(password, NULL); 1858 monitor_read_command(opaque, 1); 1859} 1860#endif --- 40 unchanged lines hidden (view full) --- 1901 qmp_blockdev_change_medium(true, device, false, NULL, target, 1902 !!arg, arg, !!read_only, read_only_mode, 1903 &err); 1904 } 1905 1906 hmp_handle_error(mon, err); 1907} 1908 | 1823#ifdef CONFIG_VNC 1824static void hmp_change_read_arg(void *opaque, const char *password, 1825 void *readline_opaque) 1826{ 1827 qmp_change_vnc_password(password, NULL); 1828 monitor_read_command(opaque, 1); 1829} 1830#endif --- 40 unchanged lines hidden (view full) --- 1871 qmp_blockdev_change_medium(true, device, false, NULL, target, 1872 !!arg, arg, !!read_only, read_only_mode, 1873 &err); 1874 } 1875 1876 hmp_handle_error(mon, err); 1877} 1878 |
1909void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict) 1910{ 1911 Error *err = NULL; 1912 char *device = (char *) qdict_get_str(qdict, "device"); 1913 BlockIOThrottle throttle = { 1914 .bps = qdict_get_int(qdict, "bps"), 1915 .bps_rd = qdict_get_int(qdict, "bps_rd"), 1916 .bps_wr = qdict_get_int(qdict, "bps_wr"), 1917 .iops = qdict_get_int(qdict, "iops"), 1918 .iops_rd = qdict_get_int(qdict, "iops_rd"), 1919 .iops_wr = qdict_get_int(qdict, "iops_wr"), 1920 }; 1921 1922 /* qmp_block_set_io_throttle has separate parameters for the 1923 * (deprecated) block device name and the qdev ID but the HMP 1924 * version has only one, so we must decide which one to pass. */ 1925 if (blk_by_name(device)) { 1926 throttle.has_device = true; 1927 throttle.device = device; 1928 } else { 1929 throttle.has_id = true; 1930 throttle.id = device; 1931 } 1932 1933 qmp_block_set_io_throttle(&throttle, &err); 1934 hmp_handle_error(mon, err); 1935} 1936 1937void hmp_block_stream(Monitor *mon, const QDict *qdict) 1938{ 1939 Error *error = NULL; 1940 const char *device = qdict_get_str(qdict, "device"); 1941 const char *base = qdict_get_try_str(qdict, "base"); 1942 int64_t speed = qdict_get_try_int(qdict, "speed", 0); 1943 1944 qmp_block_stream(true, device, device, base != NULL, base, false, NULL, 1945 false, NULL, qdict_haskey(qdict, "speed"), speed, true, 1946 BLOCKDEV_ON_ERROR_REPORT, false, false, false, false, 1947 &error); 1948 1949 hmp_handle_error(mon, error); 1950} 1951 | |
1952typedef struct HMPMigrationStatus 1953{ 1954 QEMUTimer *timer; 1955 Monitor *mon; 1956 bool is_block_migration; 1957} HMPMigrationStatus; 1958 1959static void hmp_migrate_status_cb(void *opaque) --- 276 unchanged lines hidden (view full) --- 2236void hmp_chardev_send_break(Monitor *mon, const QDict *qdict) 2237{ 2238 Error *local_err = NULL; 2239 2240 qmp_chardev_send_break(qdict_get_str(qdict, "id"), &local_err); 2241 hmp_handle_error(mon, local_err); 2242} 2243 | 1879typedef struct HMPMigrationStatus 1880{ 1881 QEMUTimer *timer; 1882 Monitor *mon; 1883 bool is_block_migration; 1884} HMPMigrationStatus; 1885 1886static void hmp_migrate_status_cb(void *opaque) --- 276 unchanged lines hidden (view full) --- 2163void hmp_chardev_send_break(Monitor *mon, const QDict *qdict) 2164{ 2165 Error *local_err = NULL; 2166 2167 qmp_chardev_send_break(qdict_get_str(qdict, "id"), &local_err); 2168 hmp_handle_error(mon, local_err); 2169} 2170 |
2244void hmp_qemu_io(Monitor *mon, const QDict *qdict) 2245{ 2246 BlockBackend *blk; 2247 BlockBackend *local_blk = NULL; 2248 bool qdev = qdict_get_try_bool(qdict, "qdev", false); 2249 const char* device = qdict_get_str(qdict, "device"); 2250 const char* command = qdict_get_str(qdict, "command"); 2251 Error *err = NULL; 2252 int ret; 2253 2254 if (qdev) { 2255 blk = blk_by_qdev_id(device, &err); 2256 if (!blk) { 2257 goto fail; 2258 } 2259 } else { 2260 blk = blk_by_name(device); 2261 if (!blk) { 2262 BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err); 2263 if (bs) { 2264 blk = local_blk = blk_new(bdrv_get_aio_context(bs), 2265 0, BLK_PERM_ALL); 2266 ret = blk_insert_bs(blk, bs, &err); 2267 if (ret < 0) { 2268 goto fail; 2269 } 2270 } else { 2271 goto fail; 2272 } 2273 } 2274 } 2275 2276 /* 2277 * Notably absent: Proper permission management. This is sad, but it seems 2278 * almost impossible to achieve without changing the semantics and thereby 2279 * limiting the use cases of the qemu-io HMP command. 2280 * 2281 * In an ideal world we would unconditionally create a new BlockBackend for 2282 * qemuio_command(), but we have commands like 'reopen' and want them to 2283 * take effect on the exact BlockBackend whose name the user passed instead 2284 * of just on a temporary copy of it. 2285 * 2286 * Another problem is that deleting the temporary BlockBackend involves 2287 * draining all requests on it first, but some qemu-iotests cases want to 2288 * issue multiple aio_read/write requests and expect them to complete in 2289 * the background while the monitor has already returned. 2290 * 2291 * This is also what prevents us from saving the original permissions and 2292 * restoring them later: We can't revoke permissions until all requests 2293 * have completed, and we don't know when that is nor can we really let 2294 * anything else run before we have revoken them to avoid race conditions. 2295 * 2296 * What happens now is that command() in qemu-io-cmds.c can extend the 2297 * permissions if necessary for the qemu-io command. And they simply stay 2298 * extended, possibly resulting in a read-only guest device keeping write 2299 * permissions. Ugly, but it appears to be the lesser evil. 2300 */ 2301 qemuio_command(blk, command); 2302 2303fail: 2304 blk_unref(local_blk); 2305 hmp_handle_error(mon, err); 2306} 2307 | |
2308void hmp_object_del(Monitor *mon, const QDict *qdict) 2309{ 2310 const char *id = qdict_get_str(qdict, "id"); 2311 Error *err = NULL; 2312 2313 user_creatable_del(id, &err); 2314 hmp_handle_error(mon, err); 2315} --- 401 unchanged lines hidden --- | 2171void hmp_object_del(Monitor *mon, const QDict *qdict) 2172{ 2173 const char *id = qdict_get_str(qdict, "id"); 2174 Error *err = NULL; 2175 2176 user_creatable_del(id, &err); 2177 hmp_handle_error(mon, err); 2178} --- 401 unchanged lines hidden --- |