block.c (d224469d87140f0ab9496f752f6042606b80718b) | block.c (9aebf3b89281a173d2dfeee379b800be5e3f363e) |
---|---|
1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 321 unchanged lines hidden (view full) --- 330 bdrv->bdrv_aio_readv = bdrv_aio_readv_em; 331 bdrv->bdrv_aio_writev = bdrv_aio_writev_em; 332 } 333 } 334 335 QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list); 336} 337 | 1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 321 unchanged lines hidden (view full) --- 330 bdrv->bdrv_aio_readv = bdrv_aio_readv_em; 331 bdrv->bdrv_aio_writev = bdrv_aio_writev_em; 332 } 333 } 334 335 QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list); 336} 337 |
338static bool bdrv_is_valid_name(const char *name) 339{ 340 return qemu_opts_id_wellformed(name); 341} 342 |
|
338/* create a new block device (by default it is empty) */ 339BlockDriverState *bdrv_new(const char *device_name, Error **errp) 340{ 341 BlockDriverState *bs; 342 int i; 343 | 343/* create a new block device (by default it is empty) */ 344BlockDriverState *bdrv_new(const char *device_name, Error **errp) 345{ 346 BlockDriverState *bs; 347 int i; 348 |
349 if (*device_name && !bdrv_is_valid_name(device_name)) { 350 error_setg(errp, "Invalid device name"); 351 return NULL; 352 } 353 |
|
344 if (bdrv_find(device_name)) { 345 error_setg(errp, "Device with id '%s' already exists", 346 device_name); 347 return NULL; 348 } 349 if (bdrv_find_node(device_name)) { 350 error_setg(errp, 351 "Device name '%s' conflicts with an existing node name", --- 506 unchanged lines hidden (view full) --- 858static void bdrv_assign_node_name(BlockDriverState *bs, 859 const char *node_name, 860 Error **errp) 861{ 862 if (!node_name) { 863 return; 864 } 865 | 354 if (bdrv_find(device_name)) { 355 error_setg(errp, "Device with id '%s' already exists", 356 device_name); 357 return NULL; 358 } 359 if (bdrv_find_node(device_name)) { 360 error_setg(errp, 361 "Device name '%s' conflicts with an existing node name", --- 506 unchanged lines hidden (view full) --- 868static void bdrv_assign_node_name(BlockDriverState *bs, 869 const char *node_name, 870 Error **errp) 871{ 872 if (!node_name) { 873 return; 874 } 875 |
866 /* empty string node name is invalid */ 867 if (node_name[0] == '\0') { 868 error_setg(errp, "Empty node name"); | 876 /* Check for empty string or invalid characters */ 877 if (!bdrv_is_valid_name(node_name)) { 878 error_setg(errp, "Invalid node name"); |
869 return; 870 } 871 872 /* takes care of avoiding namespaces collisions */ 873 if (bdrv_find(node_name)) { 874 error_setg(errp, "node-name=%s is conflicting with a device id", 875 node_name); 876 return; --- 5228 unchanged lines hidden --- | 879 return; 880 } 881 882 /* takes care of avoiding namespaces collisions */ 883 if (bdrv_find(node_name)) { 884 error_setg(errp, "node-name=%s is conflicting with a device id", 885 node_name); 886 return; --- 5228 unchanged lines hidden --- |