migration: remove duplicate code
version_id is checked twice in the ram_load. Signed-off-by: ChenLiang <chenliang88@huawei.com> Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
		
							parent
							
								
									d99598cc99
								
							
						
					
					
						commit
						21a246a43b
					
				
							
								
								
									
										64
									
								
								arch_init.c
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								arch_init.c
									
									
									
									
									
								
							@ -1010,7 +1010,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    seq_iter++;
 | 
					    seq_iter++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (version_id < 4 || version_id > 4) {
 | 
					    if (version_id != 4) {
 | 
				
			||||||
        return -EINVAL;
 | 
					        return -EINVAL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1021,44 +1021,42 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
 | 
				
			|||||||
        addr &= TARGET_PAGE_MASK;
 | 
					        addr &= TARGET_PAGE_MASK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (flags & RAM_SAVE_FLAG_MEM_SIZE) {
 | 
					        if (flags & RAM_SAVE_FLAG_MEM_SIZE) {
 | 
				
			||||||
            if (version_id == 4) {
 | 
					            /* Synchronize RAM block list */
 | 
				
			||||||
                /* Synchronize RAM block list */
 | 
					            char id[256];
 | 
				
			||||||
                char id[256];
 | 
					            ram_addr_t length;
 | 
				
			||||||
                ram_addr_t length;
 | 
					            ram_addr_t total_ram_bytes = addr;
 | 
				
			||||||
                ram_addr_t total_ram_bytes = addr;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                while (total_ram_bytes) {
 | 
					            while (total_ram_bytes) {
 | 
				
			||||||
                    RAMBlock *block;
 | 
					                RAMBlock *block;
 | 
				
			||||||
                    uint8_t len;
 | 
					                uint8_t len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    len = qemu_get_byte(f);
 | 
					                len = qemu_get_byte(f);
 | 
				
			||||||
                    qemu_get_buffer(f, (uint8_t *)id, len);
 | 
					                qemu_get_buffer(f, (uint8_t *)id, len);
 | 
				
			||||||
                    id[len] = 0;
 | 
					                id[len] = 0;
 | 
				
			||||||
                    length = qemu_get_be64(f);
 | 
					                length = qemu_get_be64(f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    QTAILQ_FOREACH(block, &ram_list.blocks, next) {
 | 
					                QTAILQ_FOREACH(block, &ram_list.blocks, next) {
 | 
				
			||||||
                        if (!strncmp(id, block->idstr, sizeof(id))) {
 | 
					                    if (!strncmp(id, block->idstr, sizeof(id))) {
 | 
				
			||||||
                            if (block->length != length) {
 | 
					                        if (block->length != length) {
 | 
				
			||||||
                                fprintf(stderr,
 | 
					                            fprintf(stderr,
 | 
				
			||||||
                                        "Length mismatch: %s: " RAM_ADDR_FMT
 | 
					                                    "Length mismatch: %s: " RAM_ADDR_FMT
 | 
				
			||||||
                                        " in != " RAM_ADDR_FMT "\n", id, length,
 | 
					                                    " in != " RAM_ADDR_FMT "\n", id, length,
 | 
				
			||||||
                                        block->length);
 | 
					                                    block->length);
 | 
				
			||||||
                                ret =  -EINVAL;
 | 
					                            ret =  -EINVAL;
 | 
				
			||||||
                                goto done;
 | 
					                            goto done;
 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            break;
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    if (!block) {
 | 
					 | 
				
			||||||
                        fprintf(stderr, "Unknown ramblock \"%s\", cannot "
 | 
					 | 
				
			||||||
                                "accept migration\n", id);
 | 
					 | 
				
			||||||
                        ret = -EINVAL;
 | 
					 | 
				
			||||||
                        goto done;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    total_ram_bytes -= length;
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (!block) {
 | 
				
			||||||
 | 
					                    fprintf(stderr, "Unknown ramblock \"%s\", cannot "
 | 
				
			||||||
 | 
					                            "accept migration\n", id);
 | 
				
			||||||
 | 
					                    ret = -EINVAL;
 | 
				
			||||||
 | 
					                    goto done;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                total_ram_bytes -= length;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user