block.c (779020cbdc67011026c10fb620f701bfc6b85547) | block.c (15489c769b9a4b3bec5b5848af2960689d7b4bd8) |
---|---|
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 --- 749 unchanged lines hidden (view full) --- 758 759 return open_flags; 760} 761 762static void bdrv_assign_node_name(BlockDriverState *bs, 763 const char *node_name, 764 Error **errp) 765{ | 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 --- 749 unchanged lines hidden (view full) --- 758 759 return open_flags; 760} 761 762static void bdrv_assign_node_name(BlockDriverState *bs, 763 const char *node_name, 764 Error **errp) 765{ |
766 if (!node_name) { 767 return; 768 } | 766 char *gen_node_name = NULL; |
769 | 767 |
770 /* Check for empty string or invalid characters */ 771 if (!id_wellformed(node_name)) { | 768 if (!node_name) { 769 node_name = gen_node_name = id_generate(ID_BLOCK); 770 } else if (!id_wellformed(node_name)) { 771 /* 772 * Check for empty string or invalid characters, but not if it is 773 * generated (generated names use characters not available to the user) 774 */ |
772 error_setg(errp, "Invalid node name"); 773 return; 774 } 775 776 /* takes care of avoiding namespaces collisions */ 777 if (blk_by_name(node_name)) { 778 error_setg(errp, "node-name=%s is conflicting with a device id", 779 node_name); | 775 error_setg(errp, "Invalid node name"); 776 return; 777 } 778 779 /* takes care of avoiding namespaces collisions */ 780 if (blk_by_name(node_name)) { 781 error_setg(errp, "node-name=%s is conflicting with a device id", 782 node_name); |
780 return; | 783 goto out; |
781 } 782 783 /* takes care of avoiding duplicates node names */ 784 if (bdrv_find_node(node_name)) { 785 error_setg(errp, "Duplicate node name"); | 784 } 785 786 /* takes care of avoiding duplicates node names */ 787 if (bdrv_find_node(node_name)) { 788 error_setg(errp, "Duplicate node name"); |
786 return; | 789 goto out; |
787 } 788 789 /* copy node name into the bs and insert it into the graph list */ 790 pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); 791 QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); | 790 } 791 792 /* copy node name into the bs and insert it into the graph list */ 793 pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); 794 QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); |
795out: 796 g_free(gen_node_name); |
|
792} 793 794static QemuOptsList bdrv_runtime_opts = { 795 .name = "bdrv_common", 796 .head = QTAILQ_HEAD_INITIALIZER(bdrv_runtime_opts.head), 797 .desc = { 798 { 799 .name = "node-name", --- 3357 unchanged lines hidden --- | 797} 798 799static QemuOptsList bdrv_runtime_opts = { 800 .name = "bdrv_common", 801 .head = QTAILQ_HEAD_INITIALIZER(bdrv_runtime_opts.head), 802 .desc = { 803 { 804 .name = "node-name", --- 3357 unchanged lines hidden --- |