Revision 007f5f6b src/vm/VirtualMachine.cc

View differences:

src/vm/VirtualMachine.cc
1098 1098
/* -------------------------------------------------------------------------- */
1099 1099
/* -------------------------------------------------------------------------- */
1100 1100

  
1101
int VirtualMachine::save_disk(int disk_id, int img_id)
1102
{
1103
    int                   num_disks;
1104
    vector<Attribute  * > disks;
1105
    VectorAttribute *     disk;
1106

  
1107
    string                disk_id_str;
1108
    int                   tmp_disk_id;
1109

  
1110
    ostringstream oss;
1111
    istringstream iss;
1112

  
1113

  
1114
    num_disks  = vm_template->get("DISK",disks);
1115

  
1116
    for(int i=0; i<num_disks; i++)
1117
    {
1118
        disk = dynamic_cast<VectorAttribute * >(disks[i]);
1119

  
1120
        if ( disk == 0 )
1121
        {
1122
            continue;
1123
        }
1124

  
1125
        disk_id_str = disk->vector_value("DISK_ID");
1126

  
1127
        iss.str(disk_id_str);
1128
        iss >> tmp_disk_id;
1129

  
1130
        if( tmp_disk_id == disk_id )
1131
        {
1132
            disk->replace("SAVE", "YES");
1133

  
1134
            oss << (img_id);
1135
            disk->replace("SAVE_AS", oss.str());
1136

  
1137
            return 0;
1138
        }
1139
    }
1140

  
1141
    return -1;
1142
}
1143

  
1144
/* -------------------------------------------------------------------------- */
1145
/* -------------------------------------------------------------------------- */
1146

  
1101 1147
pthread_mutex_t VirtualMachine::lex_mutex = PTHREAD_MUTEX_INITIALIZER;
1102 1148

  
1103 1149
extern "C"

Also available in: Unified diff